@heroku/applink 1.0.0-ea.1 → 1.0.0-ea.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/add-ons/heroku-applink.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/utils/request.d.ts +4 -1
- package/dist/utils/request.js +18 -7
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -20,3 +20,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
20
20
|
|
|
21
21
|
## [1.0.0-ea.1] - 2025-06-06
|
|
22
22
|
- Remove dynamic UA.
|
|
23
|
+
|
|
24
|
+
## [1.0.0-ea.2] - 2025-06-20
|
|
25
|
+
- Update `HttpRequestUtil.request` documentation
|
|
26
|
+
- Update license year
|
|
27
|
+
- Add `X-Request-Id` header
|
|
28
|
+
- Extract `User-Agent` header from package.json
|
|
29
|
+
- Rename `HTTPResponseError` -> `HttpResponseError`
|
|
30
|
+
- Add GitHub pull request template
|
|
31
|
+
- Fix Java heap memory test issue
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ And much more!
|
|
|
14
14
|
For more information, see [API docs](docs/README.md).
|
|
15
15
|
|
|
16
16
|
## Example
|
|
17
|
-
Example use of the Node.js SDK for Heroku AppLink provided as part of the [Heroku AppLink CLI Plugin's](https://github.com/heroku/heroku-cli-plugin-
|
|
17
|
+
Example use of the Node.js SDK for Heroku AppLink provided as part of the [Heroku AppLink CLI Plugin's](https://github.com/heroku/heroku-cli-plugin-applink) `applink:project` template:
|
|
18
18
|
```javascript
|
|
19
19
|
fastify.get('/accounts', async function (request, reply) {
|
|
20
20
|
const {event, context, logger} = request.sdk;
|
|
@@ -38,7 +38,7 @@ async function getAuthorization(developerName, attachmentNameOrColorOrUrl = proc
|
|
|
38
38
|
response = await HTTP_REQUEST.request(authUrl, opts);
|
|
39
39
|
}
|
|
40
40
|
catch (err) {
|
|
41
|
-
if (err instanceof request_1.
|
|
41
|
+
if (err instanceof request_1.HttpResponseError) {
|
|
42
42
|
let errorResponse;
|
|
43
43
|
try {
|
|
44
44
|
errorResponse = await err.response.json();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QueryOperation } from "jsforce/lib/api/bulk";
|
|
2
2
|
import { getAuthorization } from "./add-ons/heroku-applink.js";
|
|
3
|
-
import {
|
|
3
|
+
import { HttpResponseError } from "./utils/request.js";
|
|
4
4
|
export declare function init(): {
|
|
5
5
|
addons: {
|
|
6
6
|
applink: {
|
|
@@ -20,7 +20,7 @@ export declare function parseRequest(headers: any, body: any, log: any): {
|
|
|
20
20
|
logger: Logger;
|
|
21
21
|
};
|
|
22
22
|
export declare function parseDataActionEvent(payload: any): DataCloudActionEvent;
|
|
23
|
-
export {
|
|
23
|
+
export { HttpResponseError };
|
|
24
24
|
export interface InvocationEvent<A> {
|
|
25
25
|
readonly data: A;
|
|
26
26
|
readonly dataContentType?: string;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.HttpResponseError = void 0;
|
|
4
4
|
exports.init = init;
|
|
5
5
|
exports.parseRequest = parseRequest;
|
|
6
6
|
exports.parseDataActionEvent = parseDataActionEvent;
|
|
@@ -9,7 +9,7 @@ const invocation_event_js_1 = require("./sdk/invocation-event.js");
|
|
|
9
9
|
const logger_js_1 = require("./sdk/logger.js");
|
|
10
10
|
const heroku_applink_js_1 = require("./add-ons/heroku-applink.js");
|
|
11
11
|
const request_js_1 = require("./utils/request.js");
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "HttpResponseError", { enumerable: true, get: function () { return request_js_1.HttpResponseError; } });
|
|
13
13
|
const CONTENT_TYPE_HEADER = "Content-Type";
|
|
14
14
|
const X_CLIENT_CONTEXT_HEADER = "x-client-context";
|
|
15
15
|
function init() {
|
package/dist/utils/request.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class HttpResponseError extends Error {
|
|
2
2
|
response: any;
|
|
3
3
|
constructor(response: Response);
|
|
4
4
|
}
|
|
5
|
+
export declare const uuidGenerator: {
|
|
6
|
+
generate: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
7
|
+
};
|
|
5
8
|
export declare class HttpRequestUtil {
|
|
6
9
|
request(url: string, opts: any, json?: boolean): Promise<any>;
|
|
7
10
|
}
|
package/dist/utils/request.js
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpRequestUtil = exports.
|
|
4
|
-
|
|
6
|
+
exports.HttpRequestUtil = exports.uuidGenerator = exports.HttpResponseError = void 0;
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
9
|
+
class HttpResponseError extends Error {
|
|
5
10
|
constructor(response) {
|
|
6
11
|
super(`HTTP Error Response: ${response.status}: ${response.statusText}`);
|
|
7
12
|
this.response = response;
|
|
8
13
|
}
|
|
9
14
|
}
|
|
10
|
-
exports.
|
|
15
|
+
exports.HttpResponseError = HttpResponseError;
|
|
16
|
+
exports.uuidGenerator = {
|
|
17
|
+
generate: () => (0, node_crypto_1.randomUUID)(),
|
|
18
|
+
};
|
|
11
19
|
class HttpRequestUtil {
|
|
12
20
|
async request(url, opts, json = true) {
|
|
13
|
-
const
|
|
21
|
+
const mergedOpts = {
|
|
22
|
+
...opts,
|
|
14
23
|
headers: {
|
|
15
|
-
"User-Agent":
|
|
24
|
+
"User-Agent": `${package_json_1.default.name}/${package_json_1.default.version}`,
|
|
25
|
+
"X-Request-Id": exports.uuidGenerator.generate(),
|
|
26
|
+
...(opts?.headers ?? {}),
|
|
16
27
|
},
|
|
17
28
|
};
|
|
18
|
-
const response = await fetch(url,
|
|
29
|
+
const response = await fetch(url, mergedOpts);
|
|
19
30
|
if (!response.ok) {
|
|
20
|
-
throw new
|
|
31
|
+
throw new HttpResponseError(response);
|
|
21
32
|
}
|
|
22
33
|
return json ? response.json() : response;
|
|
23
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heroku/applink",
|
|
3
|
-
"version": "1.0.0-ea.
|
|
3
|
+
"version": "1.0.0-ea.2",
|
|
4
4
|
"description": "Applink SDK for Heroku Apps.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"build": "tsc -b",
|
|
9
9
|
"lint": "eslint . --ext .ts --max-warnings 0 --report-unused-disable-directives --format codeframe",
|
|
10
10
|
"lint:fix": "npm run lint -- --fix",
|
|
11
|
-
"wiremock": "wiremock --port 8080 --bind-address 127.0.0.1 --disable-banner",
|
|
11
|
+
"wiremock": "JAVA_OPTS='-Xmx1536m -Xms768m' wiremock --port 8080 --bind-address 127.0.0.1 --disable-banner --disable-request-logging --no-request-journal",
|
|
12
12
|
"mocha": "mocha",
|
|
13
13
|
"test": "cross-env NODE_ENV=test TS_NODE_PROJECT=tsconfig.test.json concurrently -k -s first \"wiremock\" \"mocha\"",
|
|
14
14
|
"test:coverage": "nyc --reporter=lcov --reporter=text-summary yarn test",
|