firebase-functions 6.6.0 → 7.0.0-rc.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/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 +290 -226
- package/protos/compiledFirestore.mjs +3512 -0
- package/protos/update.sh +28 -7
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { pathParts } from "./path.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/common/utilities/path-pattern.ts
|
|
4
|
+
/** https://cloud.google.com/eventarc/docs/path-patterns */
|
|
5
|
+
/** @hidden */
|
|
6
|
+
const WILDCARD_CAPTURE_REGEX = new RegExp("{[^/{}]+}", "g");
|
|
7
|
+
/** @internal */
|
|
8
|
+
function trimParam(param) {
|
|
9
|
+
const paramNoBraces = param.slice(1, -1);
|
|
10
|
+
if (paramNoBraces.includes("=")) {
|
|
11
|
+
return paramNoBraces.slice(0, paramNoBraces.indexOf("="));
|
|
12
|
+
}
|
|
13
|
+
return paramNoBraces;
|
|
14
|
+
}
|
|
15
|
+
/** @hidden */
|
|
16
|
+
var Segment = class {
|
|
17
|
+
constructor(value) {
|
|
18
|
+
this.value = value;
|
|
19
|
+
this.name = "segment";
|
|
20
|
+
this.trimmed = value;
|
|
21
|
+
}
|
|
22
|
+
isSingleSegmentWildcard() {
|
|
23
|
+
return this.value.includes("*") && !this.isMultiSegmentWildcard();
|
|
24
|
+
}
|
|
25
|
+
isMultiSegmentWildcard() {
|
|
26
|
+
return this.value.includes("**");
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/** @hidden */
|
|
30
|
+
var SingleCaptureSegment = class {
|
|
31
|
+
constructor(value) {
|
|
32
|
+
this.value = value;
|
|
33
|
+
this.name = "single-capture";
|
|
34
|
+
this.trimmed = trimParam(value);
|
|
35
|
+
}
|
|
36
|
+
isSingleSegmentWildcard() {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
isMultiSegmentWildcard() {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/** @hidden */
|
|
44
|
+
var MultiCaptureSegment = class {
|
|
45
|
+
constructor(value) {
|
|
46
|
+
this.value = value;
|
|
47
|
+
this.name = "multi-capture";
|
|
48
|
+
this.trimmed = trimParam(value);
|
|
49
|
+
}
|
|
50
|
+
isSingleSegmentWildcard() {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
isMultiSegmentWildcard() {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Implements Eventarc's path pattern from the spec https://cloud.google.com/eventarc/docs/path-patterns
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
var PathPattern = class {
|
|
62
|
+
/** @throws on validation error */
|
|
63
|
+
static compile(rawPath) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
constructor(raw) {
|
|
67
|
+
this.raw = raw;
|
|
68
|
+
this.segments = [];
|
|
69
|
+
this.initPathSegments(raw);
|
|
70
|
+
}
|
|
71
|
+
getValue() {
|
|
72
|
+
return this.raw;
|
|
73
|
+
}
|
|
74
|
+
hasWildcards() {
|
|
75
|
+
return this.segments.some((segment) => segment.isSingleSegmentWildcard() || segment.isMultiSegmentWildcard());
|
|
76
|
+
}
|
|
77
|
+
hasCaptures() {
|
|
78
|
+
return this.segments.some((segment) => segment.name === "single-capture" || segment.name === "multi-capture");
|
|
79
|
+
}
|
|
80
|
+
extractMatches(path) {
|
|
81
|
+
const matches = {};
|
|
82
|
+
if (!this.hasCaptures()) {
|
|
83
|
+
return matches;
|
|
84
|
+
}
|
|
85
|
+
const pathSegments = pathParts(path);
|
|
86
|
+
let pathNdx = 0;
|
|
87
|
+
for (let segmentNdx = 0; segmentNdx < this.segments.length && pathNdx < pathSegments.length; segmentNdx++) {
|
|
88
|
+
const segment = this.segments[segmentNdx];
|
|
89
|
+
const remainingSegments = this.segments.length - 1 - segmentNdx;
|
|
90
|
+
const nextPathNdx = pathSegments.length - remainingSegments;
|
|
91
|
+
if (segment.name === "single-capture") {
|
|
92
|
+
matches[segment.trimmed] = pathSegments[pathNdx];
|
|
93
|
+
} else if (segment.name === "multi-capture") {
|
|
94
|
+
matches[segment.trimmed] = pathSegments.slice(pathNdx, nextPathNdx).join("/");
|
|
95
|
+
}
|
|
96
|
+
pathNdx = segment.isMultiSegmentWildcard() ? nextPathNdx : pathNdx + 1;
|
|
97
|
+
}
|
|
98
|
+
return matches;
|
|
99
|
+
}
|
|
100
|
+
initPathSegments(raw) {
|
|
101
|
+
const parts = pathParts(raw);
|
|
102
|
+
for (const part of parts) {
|
|
103
|
+
let segment;
|
|
104
|
+
const capture = part.match(WILDCARD_CAPTURE_REGEX);
|
|
105
|
+
if (capture && capture.length === 1) {
|
|
106
|
+
segment = part.includes("**") ? new MultiCaptureSegment(part) : new SingleCaptureSegment(part);
|
|
107
|
+
} else {
|
|
108
|
+
segment = new Segment(part);
|
|
109
|
+
}
|
|
110
|
+
this.segments.push(segment);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
export { PathPattern, trimParam };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/common/utilities/path.ts
|
|
2
|
+
/** @hidden
|
|
3
|
+
* Removes leading and trailing slashes from a path.
|
|
4
|
+
*
|
|
5
|
+
* @param path A path to normalize, in POSIX format.
|
|
6
|
+
*/
|
|
7
|
+
function normalizePath(path) {
|
|
8
|
+
if (!path) {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
return path.replace(/^\//, "").replace(/\/$/, "");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Normalizes a given path and splits it into an array of segments.
|
|
15
|
+
*
|
|
16
|
+
* @param path A path to split, in POSIX format.
|
|
17
|
+
*/
|
|
18
|
+
function pathParts(path) {
|
|
19
|
+
if (!path || path === "" || path === "/") {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
return normalizePath(path).split("/");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Normalizes given paths and joins these together using a POSIX separator.
|
|
26
|
+
*
|
|
27
|
+
* @param base A first path segment, in POSIX format.
|
|
28
|
+
* @param child A second path segment, in POSIX format.
|
|
29
|
+
*/
|
|
30
|
+
function joinPath(base, child) {
|
|
31
|
+
return pathParts(base).concat(pathParts(child)).join("/");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { joinPath, normalizePath, pathParts };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/common/utilities/utils.ts
|
|
2
|
+
function isObject(obj) {
|
|
3
|
+
return typeof obj === "object" && !!obj;
|
|
4
|
+
}
|
|
5
|
+
/** @hidden */
|
|
6
|
+
function applyChange(src, dest) {
|
|
7
|
+
if (!isObject(dest) || !isObject(src)) {
|
|
8
|
+
return dest;
|
|
9
|
+
}
|
|
10
|
+
return merge(src, dest);
|
|
11
|
+
}
|
|
12
|
+
function merge(src, dest) {
|
|
13
|
+
const res = {};
|
|
14
|
+
const keys = new Set([...Object.keys(src), ...Object.keys(dest)]);
|
|
15
|
+
for (const key of keys.values()) {
|
|
16
|
+
if (key in dest) {
|
|
17
|
+
if (dest[key] === null) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
res[key] = applyChange(src[key], dest[key]);
|
|
21
|
+
} else if (src[key] !== null) {
|
|
22
|
+
res[key] = src[key];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return res;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { applyChange };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/logger/common.ts
|
|
2
|
+
/** @hidden */
|
|
3
|
+
const CONSOLE_SEVERITY = {
|
|
4
|
+
DEBUG: "debug",
|
|
5
|
+
INFO: "info",
|
|
6
|
+
NOTICE: "info",
|
|
7
|
+
WARNING: "warn",
|
|
8
|
+
ERROR: "error",
|
|
9
|
+
CRITICAL: "error",
|
|
10
|
+
ALERT: "error",
|
|
11
|
+
EMERGENCY: "error"
|
|
12
|
+
};
|
|
13
|
+
/** @hidden */
|
|
14
|
+
const UNPATCHED_CONSOLE = {
|
|
15
|
+
debug: console.debug,
|
|
16
|
+
info: console.info,
|
|
17
|
+
log: console.log,
|
|
18
|
+
warn: console.warn,
|
|
19
|
+
error: console.error
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { CONSOLE_SEVERITY, UNPATCHED_CONSOLE };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CONSOLE_SEVERITY, UNPATCHED_CONSOLE } from "./common.mjs";
|
|
2
|
+
import { format } from "util";
|
|
3
|
+
|
|
4
|
+
//#region src/logger/compat.ts
|
|
5
|
+
/** @hidden */
|
|
6
|
+
function patchedConsole(severity) {
|
|
7
|
+
return function(data, ...args) {
|
|
8
|
+
let message = format(data, ...args);
|
|
9
|
+
if (severity === "ERROR") {
|
|
10
|
+
message = new Error(message).stack || message;
|
|
11
|
+
}
|
|
12
|
+
UNPATCHED_CONSOLE[CONSOLE_SEVERITY[severity]](JSON.stringify({
|
|
13
|
+
severity,
|
|
14
|
+
message
|
|
15
|
+
}));
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
console.debug = patchedConsole("DEBUG");
|
|
19
|
+
console.info = patchedConsole("INFO");
|
|
20
|
+
console.log = patchedConsole("INFO");
|
|
21
|
+
console.warn = patchedConsole("WARNING");
|
|
22
|
+
console.error = patchedConsole("ERROR");
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { __export } from "../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { traceContext } from "../common/trace.mjs";
|
|
3
|
+
import { CONSOLE_SEVERITY, UNPATCHED_CONSOLE } from "./common.mjs";
|
|
4
|
+
import { format } from "util";
|
|
5
|
+
|
|
6
|
+
//#region src/logger/index.ts
|
|
7
|
+
var logger_exports = /* @__PURE__ */ __export({
|
|
8
|
+
debug: () => debug,
|
|
9
|
+
error: () => error,
|
|
10
|
+
info: () => info,
|
|
11
|
+
log: () => log,
|
|
12
|
+
warn: () => warn,
|
|
13
|
+
write: () => write
|
|
14
|
+
});
|
|
15
|
+
/** @internal */
|
|
16
|
+
function removeCircular(obj, refs = new Set()) {
|
|
17
|
+
if (typeof obj !== "object" || !obj) {
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
20
|
+
if (obj.toJSON && typeof obj.toJSON === "function") {
|
|
21
|
+
return obj.toJSON();
|
|
22
|
+
}
|
|
23
|
+
if (refs.has(obj)) {
|
|
24
|
+
return "[Circular]";
|
|
25
|
+
} else {
|
|
26
|
+
refs.add(obj);
|
|
27
|
+
}
|
|
28
|
+
let returnObj;
|
|
29
|
+
if (Array.isArray(obj)) {
|
|
30
|
+
returnObj = new Array(obj.length);
|
|
31
|
+
} else {
|
|
32
|
+
returnObj = {};
|
|
33
|
+
}
|
|
34
|
+
for (const k in obj) {
|
|
35
|
+
if (obj.hasOwnProperty(k)) {
|
|
36
|
+
try {
|
|
37
|
+
if (refs.has(obj[k])) {
|
|
38
|
+
returnObj[k] = "[Circular]";
|
|
39
|
+
} else {
|
|
40
|
+
returnObj[k] = removeCircular(obj[k], refs);
|
|
41
|
+
}
|
|
42
|
+
} catch {
|
|
43
|
+
returnObj[k] = "[Error - cannot serialize]";
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
returnObj[k] = "[Error - defined in the prototype but missing in the object]";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
refs.delete(obj);
|
|
50
|
+
return returnObj;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Writes a `LogEntry` to `stdout`/`stderr` (depending on severity).
|
|
54
|
+
* @param entry - The `LogEntry` including severity, message, and any additional structured metadata.
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
function write(entry) {
|
|
58
|
+
const ctx = traceContext.getStore();
|
|
59
|
+
if (ctx?.traceId) {
|
|
60
|
+
entry["logging.googleapis.com/trace"] = `projects/${process.env.GCLOUD_PROJECT}/traces/${ctx.traceId}`;
|
|
61
|
+
}
|
|
62
|
+
UNPATCHED_CONSOLE[CONSOLE_SEVERITY[entry.severity]](JSON.stringify(removeCircular(entry)));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Writes a `DEBUG` severity log. If the last argument provided is a plain object,
|
|
66
|
+
* it is added to the `jsonPayload` in the Cloud Logging entry.
|
|
67
|
+
* @param args - Arguments, concatenated into the log message with space separators.
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
function debug(...args) {
|
|
71
|
+
write(entryFromArgs("DEBUG", args));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Writes an `INFO` severity log. If the last argument provided is a plain object,
|
|
75
|
+
* it is added to the `jsonPayload` in the Cloud Logging entry.
|
|
76
|
+
* @param args - Arguments, concatenated into the log message with space separators.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
function log(...args) {
|
|
80
|
+
write(entryFromArgs("INFO", args));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Writes an `INFO` severity log. If the last argument provided is a plain object,
|
|
84
|
+
* it is added to the `jsonPayload` in the Cloud Logging entry.
|
|
85
|
+
* @param args - Arguments, concatenated into the log message with space separators.
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
function info(...args) {
|
|
89
|
+
write(entryFromArgs("INFO", args));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Writes a `WARNING` severity log. If the last argument provided is a plain object,
|
|
93
|
+
* it is added to the `jsonPayload` in the Cloud Logging entry.
|
|
94
|
+
* @param args - Arguments, concatenated into the log message with space separators.
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
function warn(...args) {
|
|
98
|
+
write(entryFromArgs("WARNING", args));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Writes an `ERROR` severity log. If the last argument provided is a plain object,
|
|
102
|
+
* it is added to the `jsonPayload` in the Cloud Logging entry.
|
|
103
|
+
* @param args - Arguments, concatenated into the log message with space separators.
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
function error(...args) {
|
|
107
|
+
write(entryFromArgs("ERROR", args));
|
|
108
|
+
}
|
|
109
|
+
/** @hidden */
|
|
110
|
+
function entryFromArgs(severity, args) {
|
|
111
|
+
let entry = {};
|
|
112
|
+
const lastArg = args[args.length - 1];
|
|
113
|
+
if (lastArg && typeof lastArg === "object" && lastArg.constructor === Object) {
|
|
114
|
+
entry = args.pop();
|
|
115
|
+
}
|
|
116
|
+
let message = format(...args);
|
|
117
|
+
if (severity === "ERROR" && !args.find((arg) => arg instanceof Error)) {
|
|
118
|
+
message = new Error(message).stack || message;
|
|
119
|
+
}
|
|
120
|
+
const out = {
|
|
121
|
+
...entry,
|
|
122
|
+
severity
|
|
123
|
+
};
|
|
124
|
+
if (message) {
|
|
125
|
+
out.message = message;
|
|
126
|
+
}
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//#endregion
|
|
131
|
+
export { debug, error, info, log, logger_exports, warn, write };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { __export } from "../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { BUCKET_PICKER, BooleanParam, Expression, FloatParam, IntParam, InternalExpression, JsonSecretParam, ListParam, SecretParam, StringParam, multiSelect, select } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/params/index.ts
|
|
5
|
+
var params_exports = /* @__PURE__ */ __export({
|
|
6
|
+
BUCKET_PICKER: () => BUCKET_PICKER,
|
|
7
|
+
Expression: () => Expression,
|
|
8
|
+
clearParams: () => clearParams,
|
|
9
|
+
databaseURL: () => databaseURL,
|
|
10
|
+
declaredParams: () => declaredParams,
|
|
11
|
+
defineBoolean: () => defineBoolean,
|
|
12
|
+
defineFloat: () => defineFloat,
|
|
13
|
+
defineInt: () => defineInt,
|
|
14
|
+
defineJsonSecret: () => defineJsonSecret,
|
|
15
|
+
defineList: () => defineList,
|
|
16
|
+
defineSecret: () => defineSecret,
|
|
17
|
+
defineString: () => defineString,
|
|
18
|
+
gcloudProject: () => gcloudProject,
|
|
19
|
+
multiSelect: () => multiSelect,
|
|
20
|
+
projectID: () => projectID,
|
|
21
|
+
select: () => select,
|
|
22
|
+
storageBucket: () => storageBucket
|
|
23
|
+
});
|
|
24
|
+
const declaredParams = [];
|
|
25
|
+
/**
|
|
26
|
+
* Use a helper to manage the list such that parameters are uniquely
|
|
27
|
+
* registered once only but order is preserved.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
function registerParam(param) {
|
|
31
|
+
for (let i = 0; i < declaredParams.length; i++) {
|
|
32
|
+
if (declaredParams[i].name === param.name) {
|
|
33
|
+
declaredParams.splice(i, 1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
declaredParams.push(param);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* For testing.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
function clearParams() {
|
|
43
|
+
declaredParams.splice(0, declaredParams.length);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A built-in parameter that resolves to the default RTDB database URL associated
|
|
47
|
+
* with the project, without prompting the deployer. Empty string if none exists.
|
|
48
|
+
*/
|
|
49
|
+
const databaseURL = new InternalExpression("DATABASE_URL", (env) => JSON.parse(env.FIREBASE_CONFIG)?.databaseURL || "");
|
|
50
|
+
/**
|
|
51
|
+
* A built-in parameter that resolves to the Cloud project ID associated with
|
|
52
|
+
* the project, without prompting the deployer.
|
|
53
|
+
*/
|
|
54
|
+
const projectID = new InternalExpression("PROJECT_ID", (env) => JSON.parse(env.FIREBASE_CONFIG)?.projectId || "");
|
|
55
|
+
/**
|
|
56
|
+
* A built-in parameter that resolves to the Cloud project ID, without prompting
|
|
57
|
+
* the deployer.
|
|
58
|
+
*/
|
|
59
|
+
const gcloudProject = new InternalExpression("GCLOUD_PROJECT", (env) => JSON.parse(env.FIREBASE_CONFIG)?.projectId || "");
|
|
60
|
+
/**
|
|
61
|
+
* A builtin parameter that resolves to the Cloud storage bucket associated
|
|
62
|
+
* with the function, without prompting the deployer. Empty string if not
|
|
63
|
+
* defined.
|
|
64
|
+
*/
|
|
65
|
+
const storageBucket = new InternalExpression("STORAGE_BUCKET", (env) => JSON.parse(env.FIREBASE_CONFIG)?.storageBucket || "");
|
|
66
|
+
/**
|
|
67
|
+
* Declares a secret param, that will persist values only in Cloud Secret Manager.
|
|
68
|
+
* Secrets are stored internally as bytestrings. Use `ParamOptions.as` to provide type
|
|
69
|
+
* hinting during parameter resolution.
|
|
70
|
+
*
|
|
71
|
+
* @param name The name of the environment variable to use to load the parameter.
|
|
72
|
+
* @returns A parameter with a `string` return type for `.value`.
|
|
73
|
+
*/
|
|
74
|
+
function defineSecret(name) {
|
|
75
|
+
const param = new SecretParam(name);
|
|
76
|
+
registerParam(param);
|
|
77
|
+
return param;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Declares a secret parameter that retrieves a structured JSON object in Cloud Secret Manager.
|
|
81
|
+
* This is useful for managing groups of related configuration values, such as all settings
|
|
82
|
+
* for a third-party API, as a single unit.
|
|
83
|
+
*
|
|
84
|
+
* The secret value must be a valid JSON string. At runtime, the value will be automatically parsed
|
|
85
|
+
* and returned as a JavaScript object. If the value is not set or is not valid JSON, an error will be thrown.
|
|
86
|
+
*
|
|
87
|
+
* @param name The name of the environment variable to use to load the parameter.
|
|
88
|
+
* @returns A parameter whose `.value()` method returns the parsed JSON object.
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
function defineJsonSecret(name) {
|
|
92
|
+
const param = new JsonSecretParam(name);
|
|
93
|
+
registerParam(param);
|
|
94
|
+
return param;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Declare a string parameter.
|
|
98
|
+
*
|
|
99
|
+
* @param name The name of the environment variable to use to load the parameter.
|
|
100
|
+
* @param options Configuration options for the parameter.
|
|
101
|
+
* @returns A parameter with a `string` return type for `.value`.
|
|
102
|
+
*/
|
|
103
|
+
function defineString(name, options = {}) {
|
|
104
|
+
const param = new StringParam(name, options);
|
|
105
|
+
registerParam(param);
|
|
106
|
+
return param;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Declare a boolean parameter.
|
|
110
|
+
*
|
|
111
|
+
* @param name The name of the environment variable to use to load the parameter.
|
|
112
|
+
* @param options Configuration options for the parameter.
|
|
113
|
+
* @returns A parameter with a `boolean` return type for `.value`.
|
|
114
|
+
*/
|
|
115
|
+
function defineBoolean(name, options = {}) {
|
|
116
|
+
const param = new BooleanParam(name, options);
|
|
117
|
+
registerParam(param);
|
|
118
|
+
return param;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Declare an integer parameter.
|
|
122
|
+
*
|
|
123
|
+
* @param name The name of the environment variable to use to load the parameter.
|
|
124
|
+
* @param options Configuration options for the parameter.
|
|
125
|
+
* @returns A parameter with a `number` return type for `.value`.
|
|
126
|
+
*/
|
|
127
|
+
function defineInt(name, options = {}) {
|
|
128
|
+
const param = new IntParam(name, options);
|
|
129
|
+
registerParam(param);
|
|
130
|
+
return param;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Declare a float parameter.
|
|
134
|
+
*
|
|
135
|
+
* @param name The name of the environment variable to use to load the parameter.
|
|
136
|
+
* @param options Configuration options for the parameter.
|
|
137
|
+
* @returns A parameter with a `number` return type for `.value`.
|
|
138
|
+
*
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
function defineFloat(name, options = {}) {
|
|
142
|
+
const param = new FloatParam(name, options);
|
|
143
|
+
registerParam(param);
|
|
144
|
+
return param;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Declare a list parameter.
|
|
148
|
+
*
|
|
149
|
+
* @param name The name of the environment variable to use to load the parameter.
|
|
150
|
+
* @param options Configuration options for the parameter.
|
|
151
|
+
* @returns A parameter with a `string[]` return type for `.value`.
|
|
152
|
+
*/
|
|
153
|
+
function defineList(name, options = {}) {
|
|
154
|
+
const param = new ListParam(name, options);
|
|
155
|
+
registerParam(param);
|
|
156
|
+
return param;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
//#endregion
|
|
160
|
+
export { BUCKET_PICKER, Expression, clearParams, databaseURL, declaredParams, defineBoolean, defineFloat, defineInt, defineJsonSecret, defineList, defineSecret, defineString, gcloudProject, multiSelect, params_exports, projectID, select, storageBucket };
|