firebase-functions 6.6.0 → 7.0.0-rc.1
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/lib/_virtual/rolldown_runtime.js +34 -0
- package/lib/bin/firebase-functions.js +78 -103
- package/lib/common/app.js +35 -55
- package/lib/common/change.js +54 -75
- package/lib/common/config.js +41 -41
- package/lib/common/debug.js +23 -47
- package/lib/common/encoding.js +59 -82
- package/lib/common/onInit.js +26 -28
- package/lib/common/options.js +22 -42
- package/lib/common/params.d.ts +6 -6
- package/lib/common/params.js +0 -23
- package/lib/common/providers/database.js +270 -300
- package/lib/common/providers/firestore.js +66 -92
- package/lib/common/providers/https.d.ts +0 -1
- package/lib/common/providers/https.js +537 -539
- package/lib/common/providers/identity.js +393 -444
- package/lib/common/providers/tasks.js +64 -98
- package/lib/common/timezone.js +544 -542
- package/lib/common/trace.d.ts +0 -1
- package/lib/common/trace.js +63 -55
- package/lib/common/utilities/assertions.d.ts +11 -0
- package/lib/common/utilities/assertions.js +18 -0
- package/lib/common/utilities/encoder.js +20 -37
- package/lib/common/utilities/path-pattern.js +106 -132
- package/lib/common/utilities/path.js +28 -27
- package/lib/common/utilities/utils.js +23 -45
- package/lib/esm/_virtual/rolldown_runtime.mjs +16 -0
- package/lib/esm/bin/firebase-functions.mjs +91 -0
- package/lib/esm/common/app.mjs +39 -0
- package/lib/esm/common/change.mjs +57 -0
- package/lib/esm/common/config.mjs +45 -0
- package/lib/esm/common/debug.mjs +28 -0
- package/lib/esm/common/encoding.mjs +69 -0
- package/lib/esm/common/onInit.mjs +33 -0
- package/lib/esm/common/options.mjs +22 -0
- package/lib/esm/common/params.mjs +1 -0
- package/lib/esm/common/providers/database.mjs +269 -0
- package/lib/esm/common/providers/firestore.mjs +78 -0
- package/lib/esm/common/providers/https.mjs +573 -0
- package/lib/esm/common/providers/identity.mjs +428 -0
- package/lib/esm/common/providers/tasks.mjs +67 -0
- package/lib/esm/common/timezone.mjs +544 -0
- package/lib/esm/common/trace.mjs +73 -0
- package/lib/esm/common/utilities/assertions.mjs +17 -0
- package/lib/esm/common/utilities/encoder.mjs +21 -0
- package/lib/esm/common/utilities/path-pattern.mjs +116 -0
- package/lib/esm/common/utilities/path.mjs +35 -0
- package/lib/esm/common/utilities/utils.mjs +29 -0
- package/lib/esm/function-configuration.mjs +1 -0
- package/lib/esm/logger/common.mjs +23 -0
- package/lib/esm/logger/compat.mjs +25 -0
- package/lib/esm/logger/index.mjs +131 -0
- package/lib/esm/params/index.mjs +160 -0
- package/lib/esm/params/types.mjs +400 -0
- package/lib/esm/runtime/loader.mjs +132 -0
- package/lib/esm/runtime/manifest.mjs +134 -0
- package/lib/esm/types/global.d.mjs +1 -0
- package/lib/esm/v1/cloud-functions.mjs +206 -0
- package/lib/esm/v1/config.mjs +14 -0
- package/lib/esm/v1/function-builder.mjs +252 -0
- package/lib/esm/v1/function-configuration.mjs +72 -0
- package/lib/esm/v1/index.mjs +27 -0
- package/lib/esm/v1/providers/analytics.mjs +212 -0
- package/lib/esm/v1/providers/auth.mjs +156 -0
- package/lib/esm/v1/providers/database.mjs +243 -0
- package/lib/esm/v1/providers/firestore.mjs +131 -0
- package/lib/esm/v1/providers/https.mjs +82 -0
- package/lib/esm/v1/providers/pubsub.mjs +175 -0
- package/lib/esm/v1/providers/remoteConfig.mjs +64 -0
- package/lib/esm/v1/providers/storage.mjs +163 -0
- package/lib/esm/v1/providers/tasks.mjs +63 -0
- package/lib/esm/v1/providers/testLab.mjs +94 -0
- package/lib/esm/v2/core.mjs +4 -0
- package/lib/esm/v2/index.mjs +28 -0
- package/lib/esm/v2/options.mjs +102 -0
- package/lib/esm/v2/providers/alerts/alerts.mjs +85 -0
- package/lib/esm/v2/providers/alerts/appDistribution.mjs +75 -0
- package/lib/esm/v2/providers/alerts/billing.mjs +51 -0
- package/lib/esm/v2/providers/alerts/crashlytics.mjs +122 -0
- package/lib/esm/v2/providers/alerts/index.mjs +22 -0
- package/lib/esm/v2/providers/alerts/performance.mjs +66 -0
- package/lib/esm/v2/providers/database.mjs +197 -0
- package/lib/esm/v2/providers/dataconnect.mjs +130 -0
- package/lib/esm/v2/providers/eventarc.mjs +51 -0
- package/lib/esm/v2/providers/firestore.mjs +294 -0
- package/lib/esm/v2/providers/https.mjs +210 -0
- package/lib/esm/v2/providers/identity.mjs +103 -0
- package/lib/esm/v2/providers/pubsub.mjs +148 -0
- package/lib/esm/v2/providers/remoteConfig.mjs +52 -0
- package/lib/esm/v2/providers/scheduler.mjs +84 -0
- package/lib/esm/v2/providers/storage.mjs +155 -0
- package/lib/esm/v2/providers/tasks.mjs +65 -0
- package/lib/esm/v2/providers/testLab.mjs +53 -0
- package/lib/esm/v2/trace.mjs +20 -0
- package/lib/function-configuration.d.ts +0 -0
- package/lib/function-configuration.js +0 -0
- package/lib/logger/common.js +21 -41
- package/lib/logger/compat.js +18 -33
- package/lib/logger/index.js +119 -130
- package/lib/params/index.d.ts +4 -2
- package/lib/params/index.js +150 -144
- package/lib/params/types.js +389 -423
- package/lib/runtime/loader.js +114 -148
- package/lib/runtime/manifest.js +106 -126
- package/lib/types/global.d.js +0 -0
- package/lib/v1/cloud-functions.d.ts +2 -2
- package/lib/v1/cloud-functions.js +193 -241
- package/lib/v1/config.d.ts +4 -7
- package/lib/v1/config.js +13 -75
- package/lib/v1/function-builder.js +239 -368
- package/lib/v1/function-configuration.js +70 -63
- package/lib/v1/index.js +118 -73
- package/lib/v1/providers/analytics.js +188 -235
- package/lib/v1/providers/auth.d.ts +2 -1
- package/lib/v1/providers/auth.js +159 -164
- package/lib/v1/providers/database.js +237 -242
- package/lib/v1/providers/firestore.js +131 -130
- package/lib/v1/providers/https.d.ts +2 -1
- package/lib/v1/providers/https.js +79 -86
- package/lib/v1/providers/pubsub.js +175 -172
- package/lib/v1/providers/remoteConfig.js +64 -68
- package/lib/v1/providers/storage.js +161 -163
- package/lib/v1/providers/tasks.d.ts +1 -1
- package/lib/v1/providers/tasks.js +65 -80
- package/lib/v1/providers/testLab.js +94 -94
- package/lib/v2/core.d.ts +1 -1
- package/lib/v2/core.js +5 -32
- package/lib/v2/index.d.ts +6 -3
- package/lib/v2/index.js +123 -75
- package/lib/v2/options.js +88 -114
- package/lib/v2/providers/alerts/alerts.js +76 -95
- package/lib/v2/providers/alerts/appDistribution.js +73 -78
- package/lib/v2/providers/alerts/billing.js +49 -53
- package/lib/v2/providers/alerts/crashlytics.js +110 -102
- package/lib/v2/providers/alerts/index.js +56 -53
- package/lib/v2/providers/alerts/performance.js +64 -74
- package/lib/v2/providers/database.js +177 -180
- package/lib/v2/providers/dataconnect.d.ts +95 -0
- package/lib/v2/providers/dataconnect.js +137 -0
- package/lib/v2/providers/eventarc.js +55 -77
- package/lib/v2/providers/firestore.js +262 -260
- package/lib/v2/providers/https.d.ts +3 -2
- package/lib/v2/providers/https.js +210 -247
- package/lib/v2/providers/identity.d.ts +2 -1
- package/lib/v2/providers/identity.js +96 -105
- package/lib/v2/providers/pubsub.js +149 -167
- package/lib/v2/providers/remoteConfig.js +54 -63
- package/lib/v2/providers/scheduler.js +84 -96
- package/lib/v2/providers/storage.js +147 -162
- package/lib/v2/providers/tasks.d.ts +1 -1
- package/lib/v2/providers/tasks.js +68 -95
- package/lib/v2/providers/testLab.js +55 -64
- package/lib/v2/trace.js +18 -19
- package/package.json +321 -88
- package/protos/compiledFirestore.mjs +3512 -0
- package/protos/update.sh +28 -7
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { __export } from "../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { makeCloudFunction } from "../cloud-functions.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/v1/providers/testLab.ts
|
|
5
|
+
var testLab_exports = /* @__PURE__ */ __export({
|
|
6
|
+
ClientInfo: () => ClientInfo,
|
|
7
|
+
PROVIDER: () => PROVIDER,
|
|
8
|
+
ResultStorage: () => ResultStorage,
|
|
9
|
+
SERVICE: () => SERVICE,
|
|
10
|
+
TEST_MATRIX_COMPLETE_EVENT_TYPE: () => TEST_MATRIX_COMPLETE_EVENT_TYPE,
|
|
11
|
+
TestMatrix: () => TestMatrix,
|
|
12
|
+
TestMatrixBuilder: () => TestMatrixBuilder,
|
|
13
|
+
_testMatrixWithOpts: () => _testMatrixWithOpts,
|
|
14
|
+
testMatrix: () => testMatrix
|
|
15
|
+
});
|
|
16
|
+
/** @internal */
|
|
17
|
+
const PROVIDER = "google.testing";
|
|
18
|
+
/** @internal */
|
|
19
|
+
const SERVICE = "testing.googleapis.com";
|
|
20
|
+
/** @internal */
|
|
21
|
+
const TEST_MATRIX_COMPLETE_EVENT_TYPE = "testMatrix.complete";
|
|
22
|
+
/** Handle events related to Test Lab test matrices. */
|
|
23
|
+
function testMatrix() {
|
|
24
|
+
return _testMatrixWithOpts({});
|
|
25
|
+
}
|
|
26
|
+
/** @internal */
|
|
27
|
+
function _testMatrixWithOpts(opts) {
|
|
28
|
+
return new TestMatrixBuilder(() => {
|
|
29
|
+
if (!process.env.GCLOUD_PROJECT) {
|
|
30
|
+
throw new Error("process.env.GCLOUD_PROJECT is not set.");
|
|
31
|
+
}
|
|
32
|
+
return "projects/" + process.env.GCLOUD_PROJECT + "/testMatrices/{matrix}";
|
|
33
|
+
}, opts);
|
|
34
|
+
}
|
|
35
|
+
/** Builder used to create Cloud Functions for Test Lab test matrices events. */
|
|
36
|
+
var TestMatrixBuilder = class {
|
|
37
|
+
/** @internal */
|
|
38
|
+
constructor(triggerResource, options) {
|
|
39
|
+
this.triggerResource = triggerResource;
|
|
40
|
+
this.options = options;
|
|
41
|
+
}
|
|
42
|
+
/** Handle a TestMatrix that reached a final test state. */
|
|
43
|
+
onComplete(handler) {
|
|
44
|
+
const dataConstructor = (raw) => {
|
|
45
|
+
return new TestMatrix(raw.data);
|
|
46
|
+
};
|
|
47
|
+
return makeCloudFunction({
|
|
48
|
+
provider: PROVIDER,
|
|
49
|
+
eventType: TEST_MATRIX_COMPLETE_EVENT_TYPE,
|
|
50
|
+
triggerResource: this.triggerResource,
|
|
51
|
+
service: SERVICE,
|
|
52
|
+
dataConstructor,
|
|
53
|
+
handler,
|
|
54
|
+
options: this.options
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/** TestMatrix captures details about a test run. */
|
|
59
|
+
var TestMatrix = class {
|
|
60
|
+
/** @internal */
|
|
61
|
+
constructor(data) {
|
|
62
|
+
this.testMatrixId = data.testMatrixId;
|
|
63
|
+
this.createTime = data.timestamp;
|
|
64
|
+
this.state = data.state;
|
|
65
|
+
this.outcomeSummary = data.outcomeSummary;
|
|
66
|
+
this.invalidMatrixDetails = data.invalidMatrixDetails;
|
|
67
|
+
this.resultStorage = new ResultStorage(data.resultStorage);
|
|
68
|
+
this.clientInfo = new ClientInfo(data.clientInfo);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/** Information about the client which invoked the test. */
|
|
72
|
+
var ClientInfo = class {
|
|
73
|
+
/** @internal */
|
|
74
|
+
constructor(data) {
|
|
75
|
+
this.name = data?.name || "";
|
|
76
|
+
this.details = {};
|
|
77
|
+
for (const detail of data?.clientInfoDetails || []) {
|
|
78
|
+
this.details[detail.key] = detail.value || "";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
/** Locations where the test results are stored. */
|
|
83
|
+
var ResultStorage = class {
|
|
84
|
+
/** @internal */
|
|
85
|
+
constructor(data) {
|
|
86
|
+
this.gcsPath = data?.googleCloudStorage?.gcsPath;
|
|
87
|
+
this.toolResultsHistoryId = data?.toolResultsHistory?.historyId;
|
|
88
|
+
this.toolResultsExecutionId = data?.toolResultsExecution?.executionId;
|
|
89
|
+
this.resultsUrl = data?.resultsUrl;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { ClientInfo, PROVIDER, ResultStorage, SERVICE, TEST_MATRIX_COMPLETE_EVENT_TYPE, TestMatrix, TestMatrixBuilder, _testMatrixWithOpts, testLab_exports, testMatrix };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { traceContext } from "../common/trace.mjs";
|
|
2
|
+
import { logger_exports } from "../logger/index.mjs";
|
|
3
|
+
import { params_exports } from "../params/index.mjs";
|
|
4
|
+
import { setApp } from "../common/app.mjs";
|
|
5
|
+
import { Change } from "../common/change.mjs";
|
|
6
|
+
import { onInit } from "../common/onInit.mjs";
|
|
7
|
+
import { config } from "../v1/config.mjs";
|
|
8
|
+
import "./core.mjs";
|
|
9
|
+
import { setGlobalOptions } from "./options.mjs";
|
|
10
|
+
import { alerts_exports } from "./providers/alerts/index.mjs";
|
|
11
|
+
import { database_exports } from "./providers/database.mjs";
|
|
12
|
+
import { eventarc_exports } from "./providers/eventarc.mjs";
|
|
13
|
+
import { https_exports } from "./providers/https.mjs";
|
|
14
|
+
import { identity_exports } from "./providers/identity.mjs";
|
|
15
|
+
import { pubsub_exports } from "./providers/pubsub.mjs";
|
|
16
|
+
import { scheduler_exports } from "./providers/scheduler.mjs";
|
|
17
|
+
import { storage_exports } from "./providers/storage.mjs";
|
|
18
|
+
import { tasks_exports } from "./providers/tasks.mjs";
|
|
19
|
+
import { remoteConfig_exports } from "./providers/remoteConfig.mjs";
|
|
20
|
+
import { testLab_exports } from "./providers/testLab.mjs";
|
|
21
|
+
import { firestore_exports } from "./providers/firestore.mjs";
|
|
22
|
+
import { dataconnect_exports } from "./providers/dataconnect.mjs";
|
|
23
|
+
|
|
24
|
+
//#region src/v2/index.ts
|
|
25
|
+
const app = { setEmulatedAdminApp: setApp };
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Change, alerts_exports as alerts, app, config, database_exports as database, dataconnect_exports as dataconnect, eventarc_exports as eventarc, firestore_exports as firestore, https_exports as https, identity_exports as identity, logger_exports as logger, onInit, params_exports as params, pubsub_exports as pubsub, remoteConfig_exports as remoteConfig, scheduler_exports as scheduler, setGlobalOptions, storage_exports as storage, tasks_exports as tasks, testLab_exports as testLab, traceContext };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { warn } from "../logger/index.mjs";
|
|
2
|
+
import { SecretParam } from "../params/types.mjs";
|
|
3
|
+
import { declaredParams } from "../params/index.mjs";
|
|
4
|
+
import { RESET_VALUE, ResetValue } from "../common/options.mjs";
|
|
5
|
+
import { convertIfPresent, copyIfPresent, durationFromSeconds, serviceAccountFromShorthand } from "../common/encoding.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/v2/options.ts
|
|
8
|
+
const MemoryOptionToMB = {
|
|
9
|
+
"128MiB": 128,
|
|
10
|
+
"256MiB": 256,
|
|
11
|
+
"512MiB": 512,
|
|
12
|
+
"1GiB": 1024,
|
|
13
|
+
"2GiB": 2048,
|
|
14
|
+
"4GiB": 4096,
|
|
15
|
+
"8GiB": 8192,
|
|
16
|
+
"16GiB": 16384,
|
|
17
|
+
"32GiB": 32768
|
|
18
|
+
};
|
|
19
|
+
let globalOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Sets default options for all functions written using the 2nd gen SDK.
|
|
22
|
+
* @param options Options to set as default
|
|
23
|
+
*/
|
|
24
|
+
function setGlobalOptions(options) {
|
|
25
|
+
if (globalOptions) {
|
|
26
|
+
warn("Calling setGlobalOptions twice leads to undefined behavior");
|
|
27
|
+
}
|
|
28
|
+
globalOptions = options;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get the currently set default options.
|
|
32
|
+
* Used only for trigger generation.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
function getGlobalOptions() {
|
|
36
|
+
return globalOptions || {};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Apply GlobalOptions to trigger definitions.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
function optionsToTriggerAnnotations(opts) {
|
|
43
|
+
const annotation = {};
|
|
44
|
+
copyIfPresent(annotation, opts, "concurrency", "minInstances", "maxInstances", "ingressSettings", "labels", "vpcConnector", "vpcConnectorEgressSettings", "secrets");
|
|
45
|
+
convertIfPresent(annotation, opts, "availableMemoryMb", "memory", (mem) => {
|
|
46
|
+
return MemoryOptionToMB[mem];
|
|
47
|
+
});
|
|
48
|
+
convertIfPresent(annotation, opts, "regions", "region", (region) => {
|
|
49
|
+
if (typeof region === "string") {
|
|
50
|
+
return [region];
|
|
51
|
+
}
|
|
52
|
+
return region;
|
|
53
|
+
});
|
|
54
|
+
convertIfPresent(annotation, opts, "serviceAccountEmail", "serviceAccount", serviceAccountFromShorthand);
|
|
55
|
+
convertIfPresent(annotation, opts, "timeout", "timeoutSeconds", durationFromSeconds);
|
|
56
|
+
convertIfPresent(annotation, opts, "failurePolicy", "retry", (retry) => {
|
|
57
|
+
return retry ? { retry: true } : null;
|
|
58
|
+
});
|
|
59
|
+
return annotation;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Apply GlobalOptions to endpoint manifest.
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
function optionsToEndpoint(opts) {
|
|
66
|
+
const endpoint = {};
|
|
67
|
+
copyIfPresent(endpoint, opts, "omit", "concurrency", "minInstances", "maxInstances", "ingressSettings", "labels", "timeoutSeconds", "cpu");
|
|
68
|
+
convertIfPresent(endpoint, opts, "serviceAccountEmail", "serviceAccount");
|
|
69
|
+
if (opts.vpcConnector !== undefined) {
|
|
70
|
+
if (opts.vpcConnector === null || opts.vpcConnector instanceof ResetValue) {
|
|
71
|
+
endpoint.vpc = RESET_VALUE;
|
|
72
|
+
} else {
|
|
73
|
+
const vpc = { connector: opts.vpcConnector };
|
|
74
|
+
convertIfPresent(vpc, opts, "egressSettings", "vpcConnectorEgressSettings");
|
|
75
|
+
endpoint.vpc = vpc;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
convertIfPresent(endpoint, opts, "availableMemoryMb", "memory", (mem) => {
|
|
79
|
+
return typeof mem === "object" ? mem : MemoryOptionToMB[mem];
|
|
80
|
+
});
|
|
81
|
+
convertIfPresent(endpoint, opts, "region", "region", (region) => {
|
|
82
|
+
if (typeof region === "string") {
|
|
83
|
+
return [region];
|
|
84
|
+
}
|
|
85
|
+
return region;
|
|
86
|
+
});
|
|
87
|
+
convertIfPresent(endpoint, opts, "secretEnvironmentVariables", "secrets", (secrets) => secrets.map((secret) => ({ key: secret instanceof SecretParam ? secret.name : secret })));
|
|
88
|
+
return endpoint;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @hidden
|
|
92
|
+
* @alpha
|
|
93
|
+
*/
|
|
94
|
+
function __getSpec() {
|
|
95
|
+
return {
|
|
96
|
+
globalOptions: getGlobalOptions(),
|
|
97
|
+
params: declaredParams.map((p) => p.toSpec())
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { RESET_VALUE, __getSpec, getGlobalOptions, optionsToEndpoint, optionsToTriggerAnnotations, setGlobalOptions };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { initV2Endpoint } from "../../../runtime/manifest.mjs";
|
|
2
|
+
import { withInit } from "../../../common/onInit.mjs";
|
|
3
|
+
import { wrapTraceContext } from "../../trace.mjs";
|
|
4
|
+
import { getGlobalOptions, optionsToEndpoint } from "../../options.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/v2/providers/alerts/alerts.ts
|
|
7
|
+
/** @internal */
|
|
8
|
+
const eventType = "google.firebase.firebasealerts.alerts.v1.published";
|
|
9
|
+
function onAlertPublished(alertTypeOrOpts, handler) {
|
|
10
|
+
const [opts, alertType, appId] = getOptsAndAlertTypeAndApp(alertTypeOrOpts);
|
|
11
|
+
const func = (raw) => {
|
|
12
|
+
return wrapTraceContext(withInit(handler))(convertAlertAndApp(raw));
|
|
13
|
+
};
|
|
14
|
+
func.run = handler;
|
|
15
|
+
func.__endpoint = getEndpointAnnotation(opts, alertType, appId);
|
|
16
|
+
return func;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Helper function for getting the endpoint annotation used in alert handling functions.
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
function getEndpointAnnotation(opts, alertType, appId) {
|
|
23
|
+
const baseOpts = optionsToEndpoint(getGlobalOptions());
|
|
24
|
+
const specificOpts = optionsToEndpoint(opts);
|
|
25
|
+
const endpoint = {
|
|
26
|
+
...initV2Endpoint(getGlobalOptions(), opts),
|
|
27
|
+
platform: "gcfv2",
|
|
28
|
+
...baseOpts,
|
|
29
|
+
...specificOpts,
|
|
30
|
+
labels: {
|
|
31
|
+
...baseOpts?.labels,
|
|
32
|
+
...specificOpts?.labels
|
|
33
|
+
},
|
|
34
|
+
eventTrigger: {
|
|
35
|
+
eventType,
|
|
36
|
+
eventFilters: { alerttype: alertType },
|
|
37
|
+
retry: opts.retry ?? false
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
if (appId) {
|
|
41
|
+
endpoint.eventTrigger.eventFilters.appid = appId;
|
|
42
|
+
}
|
|
43
|
+
return endpoint;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Helper function to parse the function opts, alert type, and appId.
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
function getOptsAndAlertTypeAndApp(alertTypeOrOpts) {
|
|
50
|
+
let opts;
|
|
51
|
+
let alertType;
|
|
52
|
+
let appId;
|
|
53
|
+
if (typeof alertTypeOrOpts === "string") {
|
|
54
|
+
alertType = alertTypeOrOpts;
|
|
55
|
+
opts = {};
|
|
56
|
+
} else {
|
|
57
|
+
alertType = alertTypeOrOpts.alertType;
|
|
58
|
+
appId = alertTypeOrOpts.appId;
|
|
59
|
+
opts = { ...alertTypeOrOpts };
|
|
60
|
+
delete opts.alertType;
|
|
61
|
+
delete opts.appId;
|
|
62
|
+
}
|
|
63
|
+
return [
|
|
64
|
+
opts,
|
|
65
|
+
alertType,
|
|
66
|
+
appId
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Helper function to covert alert type & app id in the CloudEvent to camel case.
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
function convertAlertAndApp(raw) {
|
|
74
|
+
const event = { ...raw };
|
|
75
|
+
if ("alerttype" in event) {
|
|
76
|
+
event.alertType = event.alerttype;
|
|
77
|
+
}
|
|
78
|
+
if ("appid" in event) {
|
|
79
|
+
event.appId = event.appid;
|
|
80
|
+
}
|
|
81
|
+
return event;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
export { convertAlertAndApp, eventType, getEndpointAnnotation, getOptsAndAlertTypeAndApp, onAlertPublished };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { __export } from "../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { withInit } from "../../../common/onInit.mjs";
|
|
3
|
+
import { wrapTraceContext } from "../../trace.mjs";
|
|
4
|
+
import { convertAlertAndApp, getEndpointAnnotation } from "./alerts.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/v2/providers/alerts/appDistribution.ts
|
|
7
|
+
var appDistribution_exports = /* @__PURE__ */ __export({
|
|
8
|
+
getOptsAndApp: () => getOptsAndApp,
|
|
9
|
+
inAppFeedbackAlert: () => inAppFeedbackAlert,
|
|
10
|
+
newTesterIosDeviceAlert: () => newTesterIosDeviceAlert,
|
|
11
|
+
onInAppFeedbackPublished: () => onInAppFeedbackPublished,
|
|
12
|
+
onNewTesterIosDevicePublished: () => onNewTesterIosDevicePublished
|
|
13
|
+
});
|
|
14
|
+
/** @internal */
|
|
15
|
+
const newTesterIosDeviceAlert = "appDistribution.newTesterIosDevice";
|
|
16
|
+
/** @internal */
|
|
17
|
+
const inAppFeedbackAlert = "appDistribution.inAppFeedback";
|
|
18
|
+
/**
|
|
19
|
+
* Declares a function that can handle adding a new tester iOS device.
|
|
20
|
+
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
|
21
|
+
* @param handler - Event handler which is run every time a new tester iOS device is added.
|
|
22
|
+
* @returns A function that you can export and deploy.
|
|
23
|
+
*/
|
|
24
|
+
function onNewTesterIosDevicePublished(appIdOrOptsOrHandler, handler) {
|
|
25
|
+
if (typeof appIdOrOptsOrHandler === "function") {
|
|
26
|
+
handler = appIdOrOptsOrHandler;
|
|
27
|
+
appIdOrOptsOrHandler = {};
|
|
28
|
+
}
|
|
29
|
+
const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
|
|
30
|
+
const func = (raw) => {
|
|
31
|
+
return wrapTraceContext(withInit(handler))(convertAlertAndApp(raw));
|
|
32
|
+
};
|
|
33
|
+
func.run = handler;
|
|
34
|
+
func.__endpoint = getEndpointAnnotation(opts, newTesterIosDeviceAlert, appId);
|
|
35
|
+
return func;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Declares a function that can handle receiving new in-app feedback from a tester.
|
|
39
|
+
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
|
40
|
+
* @param handler - Event handler which is run every time new feedback is received.
|
|
41
|
+
* @returns A function that you can export and deploy.
|
|
42
|
+
*/
|
|
43
|
+
function onInAppFeedbackPublished(appIdOrOptsOrHandler, handler) {
|
|
44
|
+
if (typeof appIdOrOptsOrHandler === "function") {
|
|
45
|
+
handler = appIdOrOptsOrHandler;
|
|
46
|
+
appIdOrOptsOrHandler = {};
|
|
47
|
+
}
|
|
48
|
+
const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
|
|
49
|
+
const func = (raw) => {
|
|
50
|
+
return wrapTraceContext(withInit(handler))(convertAlertAndApp(raw));
|
|
51
|
+
};
|
|
52
|
+
func.run = handler;
|
|
53
|
+
func.__endpoint = getEndpointAnnotation(opts, inAppFeedbackAlert, appId);
|
|
54
|
+
return func;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Helper function to parse the function opts and appId.
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
function getOptsAndApp(appIdOrOpts) {
|
|
61
|
+
let opts;
|
|
62
|
+
let appId;
|
|
63
|
+
if (typeof appIdOrOpts === "string") {
|
|
64
|
+
opts = {};
|
|
65
|
+
appId = appIdOrOpts;
|
|
66
|
+
} else {
|
|
67
|
+
appId = appIdOrOpts.appId;
|
|
68
|
+
opts = { ...appIdOrOpts };
|
|
69
|
+
delete opts.appId;
|
|
70
|
+
}
|
|
71
|
+
return [opts, appId];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
export { appDistribution_exports, getOptsAndApp, inAppFeedbackAlert, newTesterIosDeviceAlert, onInAppFeedbackPublished, onNewTesterIosDevicePublished };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { __export } from "../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { withInit } from "../../../common/onInit.mjs";
|
|
3
|
+
import { wrapTraceContext } from "../../trace.mjs";
|
|
4
|
+
import { convertAlertAndApp, getEndpointAnnotation } from "./alerts.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/v2/providers/alerts/billing.ts
|
|
7
|
+
var billing_exports = /* @__PURE__ */ __export({
|
|
8
|
+
onOperation: () => onOperation,
|
|
9
|
+
onPlanAutomatedUpdatePublished: () => onPlanAutomatedUpdatePublished,
|
|
10
|
+
onPlanUpdatePublished: () => onPlanUpdatePublished,
|
|
11
|
+
planAutomatedUpdateAlert: () => planAutomatedUpdateAlert,
|
|
12
|
+
planUpdateAlert: () => planUpdateAlert
|
|
13
|
+
});
|
|
14
|
+
/** @internal */
|
|
15
|
+
const planUpdateAlert = "billing.planUpdate";
|
|
16
|
+
/** @internal */
|
|
17
|
+
const planAutomatedUpdateAlert = "billing.planAutomatedUpdate";
|
|
18
|
+
/**
|
|
19
|
+
* Declares a function that can handle a billing plan update event.
|
|
20
|
+
* @param optsOrHandler - Options or an event-handling function.
|
|
21
|
+
* @param handler - Event handler which is run every time a billing plan is updated.
|
|
22
|
+
* @returns A function that you can export and deploy.
|
|
23
|
+
*/
|
|
24
|
+
function onPlanUpdatePublished(optsOrHandler, handler) {
|
|
25
|
+
return onOperation(planUpdateAlert, optsOrHandler, handler);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Declares a function that can handle an automated billing plan update event.
|
|
29
|
+
* @param optsOrHandler - Options or an event-handling function.
|
|
30
|
+
* @param handler - Event handler which is run every time an automated billing plan update occurs.
|
|
31
|
+
* @returns A function that you can export and deploy.
|
|
32
|
+
*/
|
|
33
|
+
function onPlanAutomatedUpdatePublished(optsOrHandler, handler) {
|
|
34
|
+
return onOperation(planAutomatedUpdateAlert, optsOrHandler, handler);
|
|
35
|
+
}
|
|
36
|
+
/** @internal */
|
|
37
|
+
function onOperation(alertType, optsOrHandler, handler) {
|
|
38
|
+
if (typeof optsOrHandler === "function") {
|
|
39
|
+
handler = optsOrHandler;
|
|
40
|
+
optsOrHandler = {};
|
|
41
|
+
}
|
|
42
|
+
const func = (raw) => {
|
|
43
|
+
return wrapTraceContext(withInit(handler))(convertAlertAndApp(raw));
|
|
44
|
+
};
|
|
45
|
+
func.run = handler;
|
|
46
|
+
func.__endpoint = getEndpointAnnotation(optsOrHandler, alertType);
|
|
47
|
+
return func;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
export { billing_exports, onOperation, onPlanAutomatedUpdatePublished, onPlanUpdatePublished, planAutomatedUpdateAlert, planUpdateAlert };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { __export } from "../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { withInit } from "../../../common/onInit.mjs";
|
|
3
|
+
import { wrapTraceContext } from "../../trace.mjs";
|
|
4
|
+
import { convertAlertAndApp, getEndpointAnnotation } from "./alerts.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/v2/providers/alerts/crashlytics.ts
|
|
7
|
+
var crashlytics_exports = /* @__PURE__ */ __export({
|
|
8
|
+
getOptsAndApp: () => getOptsAndApp,
|
|
9
|
+
newAnrIssueAlert: () => newAnrIssueAlert,
|
|
10
|
+
newFatalIssueAlert: () => newFatalIssueAlert,
|
|
11
|
+
newNonfatalIssueAlert: () => newNonfatalIssueAlert,
|
|
12
|
+
onNewAnrIssuePublished: () => onNewAnrIssuePublished,
|
|
13
|
+
onNewFatalIssuePublished: () => onNewFatalIssuePublished,
|
|
14
|
+
onNewNonfatalIssuePublished: () => onNewNonfatalIssuePublished,
|
|
15
|
+
onOperation: () => onOperation,
|
|
16
|
+
onRegressionAlertPublished: () => onRegressionAlertPublished,
|
|
17
|
+
onStabilityDigestPublished: () => onStabilityDigestPublished,
|
|
18
|
+
onVelocityAlertPublished: () => onVelocityAlertPublished,
|
|
19
|
+
regressionAlert: () => regressionAlert,
|
|
20
|
+
stabilityDigestAlert: () => stabilityDigestAlert,
|
|
21
|
+
velocityAlert: () => velocityAlert
|
|
22
|
+
});
|
|
23
|
+
/** @internal */
|
|
24
|
+
const newFatalIssueAlert = "crashlytics.newFatalIssue";
|
|
25
|
+
/** @internal */
|
|
26
|
+
const newNonfatalIssueAlert = "crashlytics.newNonfatalIssue";
|
|
27
|
+
/** @internal */
|
|
28
|
+
const regressionAlert = "crashlytics.regression";
|
|
29
|
+
/** @internal */
|
|
30
|
+
const stabilityDigestAlert = "crashlytics.stabilityDigest";
|
|
31
|
+
/** @internal */
|
|
32
|
+
const velocityAlert = "crashlytics.velocity";
|
|
33
|
+
/** @internal */
|
|
34
|
+
const newAnrIssueAlert = "crashlytics.newAnrIssue";
|
|
35
|
+
/**
|
|
36
|
+
* Declares a function that can handle a new fatal issue published to Crashlytics.
|
|
37
|
+
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
|
38
|
+
* @param handler - Event handler that is triggered when a new fatal issue is published to Crashlytics.
|
|
39
|
+
* @returns A function that you can export and deploy.
|
|
40
|
+
*/
|
|
41
|
+
function onNewFatalIssuePublished(appIdOrOptsOrHandler, handler) {
|
|
42
|
+
return onOperation(newFatalIssueAlert, appIdOrOptsOrHandler, handler);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Declares a function that can handle a new non-fatal issue published to Crashlytics.
|
|
46
|
+
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
|
47
|
+
* @param handler - Event handler that is triggered when a new non-fatal issue is published to Crashlytics.
|
|
48
|
+
* @returns A function that you can export and deploy.
|
|
49
|
+
*/
|
|
50
|
+
function onNewNonfatalIssuePublished(appIdOrOptsOrHandler, handler) {
|
|
51
|
+
return onOperation(newNonfatalIssueAlert, appIdOrOptsOrHandler, handler);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Declares a function that can handle a regression alert published to Crashlytics.
|
|
55
|
+
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
|
56
|
+
* @param handler - Event handler that is triggered when a regression alert is published to Crashlytics.
|
|
57
|
+
* @returns A function that you can export and deploy.
|
|
58
|
+
*/
|
|
59
|
+
function onRegressionAlertPublished(appIdOrOptsOrHandler, handler) {
|
|
60
|
+
return onOperation(regressionAlert, appIdOrOptsOrHandler, handler);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Declares a function that can handle a stability digest published to Crashlytics.
|
|
64
|
+
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
|
65
|
+
* @param handler - Event handler that is triggered when a stability digest is published to Crashlytics.
|
|
66
|
+
* @returns A function that you can export and deploy.
|
|
67
|
+
*/
|
|
68
|
+
function onStabilityDigestPublished(appIdOrOptsOrHandler, handler) {
|
|
69
|
+
return onOperation(stabilityDigestAlert, appIdOrOptsOrHandler, handler);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Declares a function that can handle a velocity alert published to Crashlytics.
|
|
73
|
+
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
|
74
|
+
* @param handler - Event handler that is triggered when a velocity alert is published to Crashlytics.
|
|
75
|
+
* @returns A function that you can export and deploy.
|
|
76
|
+
*/
|
|
77
|
+
function onVelocityAlertPublished(appIdOrOptsOrHandler, handler) {
|
|
78
|
+
return onOperation(velocityAlert, appIdOrOptsOrHandler, handler);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Declares a function that can handle a new Application Not Responding issue published to Crashlytics.
|
|
82
|
+
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
|
83
|
+
* @param handler - Event handler that is triggered when a new Application Not Responding issue is published to Crashlytics.
|
|
84
|
+
* @returns A function that you can export and deploy.
|
|
85
|
+
*/
|
|
86
|
+
function onNewAnrIssuePublished(appIdOrOptsOrHandler, handler) {
|
|
87
|
+
return onOperation(newAnrIssueAlert, appIdOrOptsOrHandler, handler);
|
|
88
|
+
}
|
|
89
|
+
/** @internal */
|
|
90
|
+
function onOperation(alertType, appIdOrOptsOrHandler, handler) {
|
|
91
|
+
if (typeof appIdOrOptsOrHandler === "function") {
|
|
92
|
+
handler = appIdOrOptsOrHandler;
|
|
93
|
+
appIdOrOptsOrHandler = {};
|
|
94
|
+
}
|
|
95
|
+
const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
|
|
96
|
+
const func = (raw) => {
|
|
97
|
+
return wrapTraceContext(withInit(handler))(convertAlertAndApp(raw));
|
|
98
|
+
};
|
|
99
|
+
func.run = handler;
|
|
100
|
+
func.__endpoint = getEndpointAnnotation(opts, alertType, appId);
|
|
101
|
+
return func;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Helper function to parse the function opts and appId.
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
function getOptsAndApp(appIdOrOpts) {
|
|
108
|
+
let opts;
|
|
109
|
+
let appId;
|
|
110
|
+
if (typeof appIdOrOpts === "string") {
|
|
111
|
+
opts = {};
|
|
112
|
+
appId = appIdOrOpts;
|
|
113
|
+
} else {
|
|
114
|
+
appId = appIdOrOpts.appId;
|
|
115
|
+
opts = { ...appIdOrOpts };
|
|
116
|
+
delete opts.appId;
|
|
117
|
+
}
|
|
118
|
+
return [opts, appId];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
export { crashlytics_exports, getOptsAndApp, newAnrIssueAlert, newFatalIssueAlert, newNonfatalIssueAlert, onNewAnrIssuePublished, onNewFatalIssuePublished, onNewNonfatalIssuePublished, onOperation, onRegressionAlertPublished, onStabilityDigestPublished, onVelocityAlertPublished, regressionAlert, stabilityDigestAlert, velocityAlert };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { __export } from "../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { convertAlertAndApp, eventType, getEndpointAnnotation, getOptsAndAlertTypeAndApp, onAlertPublished } from "./alerts.mjs";
|
|
3
|
+
import { appDistribution_exports } from "./appDistribution.mjs";
|
|
4
|
+
import { billing_exports } from "./billing.mjs";
|
|
5
|
+
import { crashlytics_exports } from "./crashlytics.mjs";
|
|
6
|
+
import { performance_exports } from "./performance.mjs";
|
|
7
|
+
|
|
8
|
+
//#region src/v2/providers/alerts/index.ts
|
|
9
|
+
var alerts_exports = /* @__PURE__ */ __export({
|
|
10
|
+
appDistribution: () => appDistribution_exports,
|
|
11
|
+
billing: () => billing_exports,
|
|
12
|
+
convertAlertAndApp: () => convertAlertAndApp,
|
|
13
|
+
crashlytics: () => crashlytics_exports,
|
|
14
|
+
eventType: () => eventType,
|
|
15
|
+
getEndpointAnnotation: () => getEndpointAnnotation,
|
|
16
|
+
getOptsAndAlertTypeAndApp: () => getOptsAndAlertTypeAndApp,
|
|
17
|
+
onAlertPublished: () => onAlertPublished,
|
|
18
|
+
performance: () => performance_exports
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { alerts_exports, appDistribution_exports as appDistribution, billing_exports as billing, convertAlertAndApp, crashlytics_exports as crashlytics, eventType, getEndpointAnnotation, getOptsAndAlertTypeAndApp, onAlertPublished, performance_exports as performance };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { __export } from "../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { withInit } from "../../../common/onInit.mjs";
|
|
3
|
+
import { wrapTraceContext } from "../../trace.mjs";
|
|
4
|
+
import { convertAlertAndApp, getEndpointAnnotation } from "./alerts.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/v2/providers/alerts/performance.ts
|
|
7
|
+
var performance_exports = /* @__PURE__ */ __export({
|
|
8
|
+
convertPayload: () => convertPayload,
|
|
9
|
+
getOptsAndApp: () => getOptsAndApp,
|
|
10
|
+
onThresholdAlertPublished: () => onThresholdAlertPublished,
|
|
11
|
+
thresholdAlert: () => thresholdAlert
|
|
12
|
+
});
|
|
13
|
+
/** @internal */
|
|
14
|
+
const thresholdAlert = "performance.threshold";
|
|
15
|
+
/**
|
|
16
|
+
* Declares a function that can handle receiving performance threshold alerts.
|
|
17
|
+
* @param appIdOrOptsOrHandler - A specific application, options, or an event-handling function.
|
|
18
|
+
* @param handler - Event handler which is run every time a threshold alert is received.
|
|
19
|
+
* @returns A function that you can export and deploy.
|
|
20
|
+
*/
|
|
21
|
+
function onThresholdAlertPublished(appIdOrOptsOrHandler, handler) {
|
|
22
|
+
if (typeof appIdOrOptsOrHandler === "function") {
|
|
23
|
+
handler = appIdOrOptsOrHandler;
|
|
24
|
+
appIdOrOptsOrHandler = {};
|
|
25
|
+
}
|
|
26
|
+
const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
|
|
27
|
+
const func = (raw) => {
|
|
28
|
+
const event = convertAlertAndApp(raw);
|
|
29
|
+
const convertedPayload = convertPayload(event.data.payload);
|
|
30
|
+
event.data.payload = convertedPayload;
|
|
31
|
+
return wrapTraceContext(withInit(handler(event)));
|
|
32
|
+
};
|
|
33
|
+
func.run = handler;
|
|
34
|
+
func.__endpoint = getEndpointAnnotation(opts, thresholdAlert, appId);
|
|
35
|
+
return func;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Helper function to parse the function opts and appId.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
function getOptsAndApp(appIdOrOpts) {
|
|
42
|
+
if (typeof appIdOrOpts === "string") {
|
|
43
|
+
return [{}, appIdOrOpts];
|
|
44
|
+
}
|
|
45
|
+
const opts = { ...appIdOrOpts };
|
|
46
|
+
const appId = appIdOrOpts.appId;
|
|
47
|
+
delete opts.appId;
|
|
48
|
+
return [opts, appId];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Helper function to convert the raw payload of a {@link PerformanceEvent} to a {@link ThresholdAlertPayload}
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
function convertPayload(raw) {
|
|
55
|
+
const payload = { ...raw };
|
|
56
|
+
if (typeof payload.conditionPercentile !== "undefined" && payload.conditionPercentile === 0) {
|
|
57
|
+
delete payload.conditionPercentile;
|
|
58
|
+
}
|
|
59
|
+
if (typeof payload.appVersion !== "undefined" && payload.appVersion.length === 0) {
|
|
60
|
+
delete payload.appVersion;
|
|
61
|
+
}
|
|
62
|
+
return payload;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
export { convertPayload, getOptsAndApp, onThresholdAlertPublished, performance_exports, thresholdAlert };
|