@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 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
@@ -1,6 +1,6 @@
1
1
  BSD 3-Clause License
2
2
 
3
- Copyright (c) 2024, Salesforce.com, Inc.
3
+ Copyright (c) 2025, Salesforce.com, Inc.
4
4
  All rights reserved.
5
5
 
6
6
  Redistribution and use in source and binary forms, with or without modification,
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-applnk) `applink:project` template:
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.HTTPResponseError) {
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 { HTTPResponseError } from "./utils/request.js";
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 { HTTPResponseError };
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.HTTPResponseError = void 0;
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, "HTTPResponseError", { enumerable: true, get: function () { return request_js_1.HTTPResponseError; } });
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() {
@@ -1,7 +1,10 @@
1
- export declare class HTTPResponseError extends Error {
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
  }
@@ -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.HTTPResponseError = void 0;
4
- class HTTPResponseError extends Error {
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.HTTPResponseError = HTTPResponseError;
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 defaultOpts = {
21
+ const mergedOpts = {
22
+ ...opts,
14
23
  headers: {
15
- "User-Agent": `heroku-applink-node-sdk/1.0`,
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, { ...defaultOpts, ...opts });
29
+ const response = await fetch(url, mergedOpts);
19
30
  if (!response.ok) {
20
- throw new HTTPResponseError(response);
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.1",
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",