Skip to content

get tests running #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
fail-fast: false
matrix:
version: [22, 20, 18, 16, 14]
os: [windows-latest, macos-latest-large, ubuntu-latest]
os:
[sfdc-hk-ubuntu-latest, sfdc-hk-macos-latest, sfdc-hk-windows-latest]
Comment on lines +16 to +17
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes issue with pulling from github repo

name: Node ${{ matrix.version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extension": ["ts"],
"test": "test/**/*.test.ts",
"loader": "ts-node/esm",
"loader": "ts-node",
"recursive": true,
"require": ["test/setup.ts"],
"require": ["ts-node/register", "test/setup.ts"],
Comment on lines -4 to +6
Copy link
Collaborator Author

@ekozilforce ekozilforce May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our tests use esm loader but our codebase is configured for commonjs per package.json 🤔 . To get tests running I found paths either using type: module in package.json with esm, or using ts-node with commonjs and the default type.

"timeout": 4000
}
68 changes: 30 additions & 38 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"port": 9230,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
]
}
]
}
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"port": 9230,
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"type": "node"
},
{
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"type": "node"
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"program": "${file}",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
15 changes: 11 additions & 4 deletions bin/bump-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import { readFile, readFileSync, writeFileSync } from "fs";
import { exec } from "child_process";
const version = process.argv[2];

const semver = new RegExp(/^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)?)$/);
const semver = new RegExp(
/^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)?)$/
);

if (!version.match(semver)) {
console.error("Please use a valid numeric semver string:", "https://semver.org/");
console.error(
"Please use a valid numeric semver string:",
"https://semver.org/"
);
process.exit(1);
}

Expand All @@ -24,13 +29,15 @@ readFile("./package.json", (err, jsonString) => {
// bump CHANGELOG
console.log("Bumping version in CHANGELOG.md...");

const changelog = readFileSync('./CHANGELOG.md').toString().split("## [Unreleased]");
const changelog = readFileSync("./CHANGELOG.md")
.toString()
.split("## [Unreleased]");
const today = new Date();

// JS doesn't support custom date formatting strings such as 'YYYY-MM-DD', so the best we can
// do is extract the date from the ISO 8601 string (which is YYYY-MM-DDTHH:mm:ss.sssZ).
// As an added bonus this uses UTC, ensuring consistency regardless of which machine runs this script.
const date = today.toISOString().split("T")[0]
const date = today.toISOString().split("T")[0];
changelog.splice(1, 0, `## [Unreleased]\n\n## [${version}] - ${date}`);
writeFileSync("./CHANGELOG.md", changelog.join(""));

Expand Down
2 changes: 1 addition & 1 deletion mappings/query-unparseable-body.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"X-Cache": "404-HIT"
}
},
"uuid": "b843b8c1-6492-4048-90d5-08d6f90cb739",
"uuid": "b843b8c1-6492-4048-90d5-08d6f90cb738",
"persistent": true,
"insertionIndex": 7
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint:fix": "npm run lint -- --fix",
"wiremock": "wiremock --port 8080 --bind-address 127.0.0.1 --disable-banner",
"mocha": "mocha",
"test": "concurrently -k -s first \"npm run wiremock\" \"npm run mocha\"",
"test": "TS_NODE_PROJECT=tsconfig.test.json concurrently -k -s first \"npm run wiremock\" \"mocha\"",
"format": "npm run format:write && npm run format:check",
"format:check": "prettier --check .",
"format:write": "prettier --write .",
Expand Down
27 changes: 16 additions & 11 deletions src/add-ons/heroku-applink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,37 @@ export async function getConnection(name: string): Promise<Org> {
throw Error(`Connection name not provided`);
}

const addonEndpoint = process.env.HEROKU_APPLINK_API_URL || process.env.HEROKU_APPLINK_STAGING_API_URL;
const addonEndpoint =
process.env.HEROKU_APPLINK_API_URL ||
process.env.HEROKU_APPLINK_STAGING_API_URL;
if (!addonEndpoint) {
throw Error(`Heroku Applink add-on not provisioned on app or endpoint not provided`);
throw Error(
`Heroku Applink add-on not provisioned on app or endpoint not provided`
);
}

const addonAuthToken = process.env.HEROKU_APPLINK_TOKEN;
if (!addonAuthToken) {
throw Error(`Heroku Applink add-on not provisioned on app or authorization token not found`);
throw Error(
`Heroku Applink add-on not provisioned on app or authorization token not found`
);
}

const authUrl = `${addonEndpoint}/invocations/authorization`;
const opts = {
method: 'POST',
method: "POST",
headers: {
'Authorization': `Bearer ${addonAuthToken}`,
'Content-Type': 'application/json'
Authorization: `Bearer ${addonAuthToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
'org_name': name
org_name: name,
}),
retry: {
limit: 1
}
limit: 1,
},
};


let response;
try {
response = await HTTP_REQUEST.request(authUrl, opts);
Expand All @@ -69,4 +74,4 @@ export async function getConnection(name: string): Promise<Org> {
response.datacloud_token,
response.datacloud_instance_url
);
}
}
9 changes: 4 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ export function init() {
return {
addons: {
applink: {
getConnection
}
getConnection,
},
},
dataCloud: {
parseDataActionEvent
parseDataActionEvent,
},
salesforce: {
parseRequest,
Expand Down Expand Up @@ -100,7 +100,7 @@ export function parseRequest(
* @property body The request's body
* @returns {DataCloudActionEvent}
*/
export function parseDataActionEvent(payload: any) : DataCloudActionEvent {
export function parseDataActionEvent(payload: any): DataCloudActionEvent {
return payload as DataCloudActionEvent;
}

Expand Down Expand Up @@ -1100,7 +1100,6 @@ export interface DataCloudUpsertResponse {
}

export interface DataCloudApi {

/**
* {@link https://developer.salesforce.com/docs/atlas.en-us.c360a_api.meta/c360a_api/c360a_api_query_v2.htm | Data Cloud Query API} *
* @param sql
Expand Down
12 changes: 6 additions & 6 deletions src/sdk/bulk-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,28 @@ import {
IngestJobState,
GetQueryJobResultsOptions,
QueryJobOptions,
} from "../index.js";
} from "../index";
import {
createConnection,
CreateConnectionOptions,
} from "../utils/create-connections.js";
} from "../utils/create-connections";
import {
IngestJobV2,
IngestJobV2FailedResults,
IngestJobV2SuccessfulResults,
IngestJobV2UnprocessedRecords,
JobInfoV2,
QueryJobV2,
} from "jsforce/lib/api/bulk.js";
} from "jsforce/lib/api/bulk";
import {
HttpResponse,
Schema,
Record as JSForceRecord,
} from "jsforce/lib/types";
import { stringify } from "csv-stringify/sync";
import { stringify as stringifyStream } from "csv-stringify";
import { HttpApi } from "jsforce/lib/http-api.js";
import { Connection } from "jsforce/lib/connection.js";
import { HttpApi } from "jsforce/lib/http-api";
import { Connection } from "jsforce/lib/connection";
import { parse } from "csv-parse/sync";
import { DateTime } from "luxon";

Expand Down Expand Up @@ -591,4 +591,4 @@ class BulkApiClient extends HttpApi<Schema> {
message: body[0].message,
};
}
}
}
2 changes: 1 addition & 1 deletion src/sdk/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ContextImpl implements Context {
orgId: string,
orgDomainUrl: string,
userId: string,
username: string,
username: string
) {
this.id = id;
this.org = new OrgImpl(
Expand Down
14 changes: 6 additions & 8 deletions src/sdk/data-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { Connection } from "jsforce/lib/connection.js";
import { UnitOfWorkImpl } from "./unit-of-work.js";
import { Connection } from "jsforce/lib/connection";
import { UnitOfWorkImpl } from "./unit-of-work";
import {
DataApi,
Record,
Expand All @@ -17,8 +17,8 @@ import {
QueriedRecord,
ReferenceId,
UnitOfWork,
} from "../index.js";
import { createCaseInsensitiveMap } from "../utils/maps.js";
} from "../index";
import { createCaseInsensitiveMap } from "../utils/maps";

const knownBinaryFields = { ContentVersion: ["VersionData"] };

Expand All @@ -28,9 +28,7 @@ export class DataApiImpl implements DataApi {
private conn: Connection;
private readonly domainUrl: string;

constructor(accessToken: string,
apiVersion: string,
domainUrl: string) {
constructor(accessToken: string, apiVersion: string, domainUrl: string) {
this.accessToken = accessToken;
this.apiVersion = apiVersion;
this.domainUrl = domainUrl;
Expand All @@ -41,7 +39,7 @@ export class DataApiImpl implements DataApi {
this.conn = new Connection({
accessToken: this.accessToken,
instanceUrl: this.domainUrl,
version: this.apiVersion
version: this.apiVersion,
});
}

Expand Down
Loading
Loading