@heroku/applink 1.0.0-ea → 1.0.0-ea.0
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
|
@@ -9,8 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
- Initial
|
|
11
11
|
|
|
12
|
-
## [1.0.0-ea] - 2025-
|
|
12
|
+
## [1.0.0-ea] - 2025-06-05
|
|
13
13
|
- Update CODEOWNERS
|
|
14
14
|
- Updated `getAuthorization` to use the correct API URL.
|
|
15
15
|
- Rename `getConnection(name: string)` -> `getAuthorization(developerName: string, attachmentNameOrColorUrl = "HEROKU_APPLINK")`, accepting a new attachmentNameOrColorOrUrl to use a specific Applink addon's config.
|
|
16
16
|
- Remove node-fetch in favor of native fetch, add `HTTPResponseError`
|
|
17
|
+
|
|
18
|
+
## [1.0.0-ea.0] - 2025-06-06
|
|
19
|
+
- Add `X-App-UUID` header, `heroku-applink-node-sdk` UA.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
type AppUuid = string;
|
|
1
2
|
interface AddonConfig {
|
|
2
3
|
apiUrl: string;
|
|
3
4
|
token: string;
|
|
5
|
+
appUuid: AppUuid;
|
|
4
6
|
}
|
|
5
7
|
export declare function resolveAddonConfigByAttachmentOrColor(attachmentOrColor: string): AddonConfig;
|
|
6
8
|
export declare function resolveAddonConfigByUrl(url: string): AddonConfig;
|
|
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.resolveAddonConfigByAttachmentOrColor = resolveAddonConfigByAttachmentOrColor;
|
|
4
4
|
exports.resolveAddonConfigByUrl = resolveAddonConfigByUrl;
|
|
5
5
|
function resolveAddonConfigByAttachmentOrColor(attachmentOrColor) {
|
|
6
|
+
const appUuid = process.env.HEROKU_APP_ID;
|
|
7
|
+
if (!appUuid) {
|
|
8
|
+
throw Error(`Heroku Applink app UUID not found`);
|
|
9
|
+
}
|
|
6
10
|
const addon = process.env.HEROKU_APPLINK_ADDON_NAME || "HEROKU_APPLINK";
|
|
7
11
|
let apiUrl;
|
|
8
12
|
let token;
|
|
@@ -18,9 +22,14 @@ function resolveAddonConfigByAttachmentOrColor(attachmentOrColor) {
|
|
|
18
22
|
return {
|
|
19
23
|
apiUrl,
|
|
20
24
|
token,
|
|
25
|
+
appUuid,
|
|
21
26
|
};
|
|
22
27
|
}
|
|
23
28
|
function resolveAddonConfigByUrl(url) {
|
|
29
|
+
const appUuid = process.env.HEROKU_APP_ID;
|
|
30
|
+
if (!appUuid) {
|
|
31
|
+
throw Error(`Heroku Applink app UUID not found`);
|
|
32
|
+
}
|
|
24
33
|
const envVarEntries = Object.entries(process.env);
|
|
25
34
|
const matchingApiUrlEntry = envVarEntries.find(([key, value]) => key.endsWith("_API_URL") && value.toLowerCase() === url.toLowerCase());
|
|
26
35
|
if (!matchingApiUrlEntry) {
|
|
@@ -35,5 +44,6 @@ function resolveAddonConfigByUrl(url) {
|
|
|
35
44
|
return {
|
|
36
45
|
apiUrl: matchingApiUrlEntry[1],
|
|
37
46
|
token,
|
|
47
|
+
appUuid,
|
|
38
48
|
};
|
|
39
49
|
}
|
package/dist/utils/request.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
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
6
|
exports.HttpRequestUtil = exports.HTTPResponseError = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
4
9
|
class HTTPResponseError extends Error {
|
|
5
10
|
constructor(response) {
|
|
6
11
|
super(`HTTP Error Response: ${response.status}: ${response.statusText}`);
|
|
@@ -10,7 +15,14 @@ class HTTPResponseError extends Error {
|
|
|
10
15
|
exports.HTTPResponseError = HTTPResponseError;
|
|
11
16
|
class HttpRequestUtil {
|
|
12
17
|
async request(url, opts, json = true) {
|
|
13
|
-
const
|
|
18
|
+
const pjson = fs_1.default.readFileSync(path_1.default.join(__dirname, "..", "package.json"), "utf8");
|
|
19
|
+
const pkg = JSON.parse(pjson);
|
|
20
|
+
const defaultOpts = {
|
|
21
|
+
headers: {
|
|
22
|
+
"User-Agent": `heroku-applink-node-sdk/${pkg.version}`,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
const response = await fetch(url, { ...defaultOpts, ...opts });
|
|
14
26
|
if (!response.ok) {
|
|
15
27
|
throw new HTTPResponseError(response);
|
|
16
28
|
}
|