Skip to content

Ci fix #12

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ jobs:
fail-fast: false
matrix:
version: [22, 20, 18, 16, 14]
os: [windows-latest, macos-latest-large, ubuntu-latest]
os:
[
sfdc-hk-windows-latest,
sfdc-hk-macos-latest-large,
sfdc-hk-ubuntu-latest,
]
name: Node ${{ matrix.version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
Expand Down
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
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
2 changes: 1 addition & 1 deletion src/sdk/bulk-api.ts
Original file line number Diff line number Diff line change
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
6 changes: 2 additions & 4 deletions src/sdk/data-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
125 changes: 64 additions & 61 deletions src/sdk/data-cloud-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,72 +6,75 @@
*/

import {
DataCloudApi,
DataCloudQuery,
DataCloudQueryResponse,
DataCloudUpsertResponse,
DataCloudApi,
DataCloudQuery,
DataCloudQueryResponse,
DataCloudUpsertResponse,
} from "../index.js";
import { HttpRequestUtil } from "../utils/request";

export class DataCloudApiImpl implements DataCloudApi {
readonly accessToken: string;
private readonly domainUrl: string;
private request: HttpRequestUtil;
readonly accessToken: string;
private readonly domainUrl: string;
private request: HttpRequestUtil;

constructor(accessToken: string,
domainUrl: string) {
this.accessToken = accessToken;
this.domainUrl = domainUrl;
this.request = new HttpRequestUtil();
}
constructor(accessToken: string, domainUrl: string) {
this.accessToken = accessToken;
this.domainUrl = domainUrl;
this.request = new HttpRequestUtil();
}

async query(sql: DataCloudQuery): Promise<DataCloudQueryResponse> {
const url = `${this.domainUrl}/api/v2/query`;
const opts = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.accessToken}`
},
retry: {
limit: 1
},
json: sql
};
const response = await this.request.request(url, opts);
return response as DataCloudQueryResponse;
}
async query(sql: DataCloudQuery): Promise<DataCloudQueryResponse> {
const url = `${this.domainUrl}/api/v2/query`;
const opts = {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.accessToken}`,
},
retry: {
limit: 1,
},
json: sql,
};
const response = await this.request.request(url, opts);
return response as DataCloudQueryResponse;
}

async queryNextBatch(nextBatchId: string): Promise<DataCloudQueryResponse> {
const url = `${this.domainUrl}/api/v2/query/${nextBatchId}`;
const opts = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.accessToken}`
},
retry: {
limit: 1
}
};
const response = await this.request.request(url, opts);
return response as DataCloudQueryResponse;
}
async queryNextBatch(nextBatchId: string): Promise<DataCloudQueryResponse> {
const url = `${this.domainUrl}/api/v2/query/${nextBatchId}`;
const opts = {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.accessToken}`,
},
retry: {
limit: 1,
},
};
const response = await this.request.request(url, opts);
return response as DataCloudQueryResponse;
}

async upsert(name: string, objectName: string, data: any): Promise<DataCloudUpsertResponse> {
const url = `${this.domainUrl}/api/v1/ingest/sources/${name}/${objectName}`;
const opts = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.accessToken}`
},
retry: {
limit: 1
},
json: data
};
const response = await this.request.request(url, opts);
return response as DataCloudUpsertResponse;
}
}
async upsert(
name: string,
objectName: string,
data: any
): Promise<DataCloudUpsertResponse> {
const url = `${this.domainUrl}/api/v1/ingest/sources/${name}/${objectName}`;
const opts = {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.accessToken}`,
},
retry: {
limit: 1,
},
json: data,
};
const response = await this.request.request(url, opts);
return response as DataCloudUpsertResponse;
}
}
Loading
Loading