@forge/api
8.0.0-next.28.0.0
out/api/runtime.js~
out/api/runtime.jsModified+7−7
Index: package/out/api/runtime.js
===================================================================
--- package/out/api/runtime.js
+++ package/out/api/runtime.js
@@ -1,7 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.bindInvocationContext = exports.wrapInMetrics = exports.getAppContext = exports.__getRuntime = exports.MissingPermissions = exports.PermissionRequirements = exports.RuntimePermissions = exports.Permissions = void 0;
+exports.MissingPermissions = exports.PermissionRequirements = exports.RuntimePermissions = exports.Permissions = void 0;
+exports.__getRuntime = __getRuntime;
+exports.getAppContext = getAppContext;
+exports.wrapInMetrics = wrapInMetrics;
+exports.bindInvocationContext = bindInvocationContext;
const errors_1 = require("./errors");
const ari_1 = require("./ari");
const extractUrlString = (item) => {
if (typeof item === 'string') {
@@ -32,9 +36,9 @@
}
else {
const externalUrls = external[type];
if (externalUrls && Array.isArray(externalUrls) && externalUrls.length > 0) {
- const capitalizedType = type.charAt(0).toUpperCase() + type.slice(1);
+ const capitalizedType = String(type).charAt(0).toUpperCase() + String(type).slice(1);
const urlList = externalUrls.map(extractUrlString).join(', ');
externalParts.push(`${capitalizedType}: ${urlList}`);
}
}
@@ -49,9 +53,9 @@
Object.keys(fetch).forEach((fetchType) => {
const urls = fetch[fetchType];
if (urls && urls.length > 0) {
const urlList = urls.map(extractUrlString).join(', ');
- const capitalizedType = fetchType.charAt(0).toUpperCase() + fetchType.slice(1);
+ const capitalizedType = String(fetchType).charAt(0).toUpperCase() + String(fetchType).slice(1);
fetchParts.push(`Fetch ${capitalizedType}: ${urlList}`);
}
});
return fetchParts;
@@ -107,9 +111,8 @@
throw new Error('Forge runtime not found.');
}
return runtime;
}
-exports.__getRuntime = __getRuntime;
function getAppContext() {
const runtime = __getRuntime();
const { appId, appVersion, environmentId, environmentType, invocationId, installationId, moduleKey, license, installation, permissions } = runtime.appContext;
const invocationRemainingTimeInMillis = runtime.lambdaContext.getRemainingTimeInMillis ??
@@ -129,9 +132,8 @@
installation,
permissions: new RuntimePermissions(permissions?.scopes || [], permissions?.external || {})
};
}
-exports.getAppContext = getAppContext;
function wrapInMetrics(name, fn) {
return async (...args) => {
const { metrics } = __getRuntime();
metrics.counter(name).incr();
@@ -152,10 +154,8 @@
timer.stop({ success: success.toString() });
}
};
}
-exports.wrapInMetrics = wrapInMetrics;
function bindInvocationContext(fn) {
const AsyncLocalStorage = require('async_hooks').AsyncLocalStorage;
return AsyncLocalStorage.bind(fn);
}
-exports.bindInvocationContext = bindInvocationContext;