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
package/lib/common/trace.d.ts
CHANGED
package/lib/common/trace.js
CHANGED
|
@@ -1,68 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
let async_hooks = require("async_hooks");
|
|
3
|
+
async_hooks = require_rolldown_runtime.__toESM(async_hooks);
|
|
4
|
+
|
|
5
|
+
//#region src/common/trace.ts
|
|
6
|
+
const traceContext = new async_hooks.AsyncLocalStorage();
|
|
6
7
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
* A regex to match the Cloud Trace header.
|
|
9
|
+
* - ([A-Fa-f0-9]{32}): The trace id, a 32 character hex value. (e.g. 4bf92f3577b34da6a3ce929d0e0e4736)
|
|
10
|
+
* - ([0-9]+): The parent span id, a 64 bit integer. (e.g. 00f067aa0ba902b7)
|
|
11
|
+
* - (?:;o=([0-3])): The trace mask, 1-3 denote it should be traced.
|
|
12
|
+
*/
|
|
12
13
|
const CLOUD_TRACE_REGEX = new RegExp("^(?<traceId>[A-Fa-f0-9]{32})/" + "(?<parentIdInt>[0-9]+)" + "(?:;o=(?<traceMask>[0-3]))?$");
|
|
13
14
|
const CLOUD_TRACE_HEADER = "X-Cloud-Trace-Context";
|
|
14
15
|
function matchCloudTraceHeader(carrier) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
let header = carrier?.[CLOUD_TRACE_HEADER];
|
|
17
|
+
if (!header) {
|
|
18
|
+
header = carrier?.[CLOUD_TRACE_HEADER.toLowerCase()];
|
|
19
|
+
}
|
|
20
|
+
if (header && typeof header === "string") {
|
|
21
|
+
const matches = CLOUD_TRACE_REGEX.exec(header);
|
|
22
|
+
if (matches && matches.groups) {
|
|
23
|
+
const { traceId, parentIdInt, traceMask } = matches.groups;
|
|
24
|
+
const parentId = parseInt(parentIdInt);
|
|
25
|
+
if (isNaN(parentId)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const sample = !!traceMask && traceMask !== "0";
|
|
29
|
+
return {
|
|
30
|
+
traceId,
|
|
31
|
+
parentId: parentId.toString(16),
|
|
32
|
+
sample,
|
|
33
|
+
version: "00"
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
38
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const TRACEPARENT_REGEX = new RegExp("^(?<version>[a-f0-9]{2})-" +
|
|
43
|
-
"(?<traceId>[a-f0-9]{32})-" +
|
|
44
|
-
"(?<parentId>[a-f0-9]{16})-" +
|
|
45
|
-
"(?<flag>[a-f0-9]{2})$");
|
|
39
|
+
* A regex to match the traceparent header.
|
|
40
|
+
* - ^([a-f0-9]{2}): The specification version (e.g. 00)
|
|
41
|
+
* - ([a-f0-9]{32}): The trace id, a 16-byte array. (e.g. 4bf92f3577b34da6a3ce929d0e0e4736)
|
|
42
|
+
* - ([a-f0-9]{16}): The parent span id, an 8-byte array. (e.g. 00f067aa0ba902b7)
|
|
43
|
+
* - ([a-f0-9]{2}: The sampled flag. (e.g. 00)
|
|
44
|
+
*/
|
|
45
|
+
const TRACEPARENT_REGEX = new RegExp("^(?<version>[a-f0-9]{2})-" + "(?<traceId>[a-f0-9]{32})-" + "(?<parentId>[a-f0-9]{16})-" + "(?<flag>[a-f0-9]{2})$");
|
|
46
46
|
const TRACEPARENT_HEADER = "traceparent";
|
|
47
47
|
function matchTraceparentHeader(carrier) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
const header = carrier?.[TRACEPARENT_HEADER];
|
|
49
|
+
if (header && typeof header === "string") {
|
|
50
|
+
const matches = TRACEPARENT_REGEX.exec(header);
|
|
51
|
+
if (matches && matches.groups) {
|
|
52
|
+
const { version, traceId, parentId, flag } = matches.groups;
|
|
53
|
+
const sample = flag === "01";
|
|
54
|
+
return {
|
|
55
|
+
traceId,
|
|
56
|
+
parentId,
|
|
57
|
+
sample,
|
|
58
|
+
version
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
57
62
|
}
|
|
58
63
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
* Extracts trace context from given carrier object, if any.
|
|
65
|
+
*
|
|
66
|
+
* Supports Cloud Trace and traceparent format.
|
|
67
|
+
*
|
|
68
|
+
* @param carrier
|
|
69
|
+
*/
|
|
65
70
|
function extractTraceContext(carrier) {
|
|
66
|
-
|
|
71
|
+
return matchCloudTraceHeader(carrier) || matchTraceparentHeader(carrier);
|
|
67
72
|
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
68
75
|
exports.extractTraceContext = extractTraceContext;
|
|
76
|
+
exports.traceContext = traceContext;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @hidden
|
|
2
|
+
* @file Provides common assertion helpers which can be used to improve
|
|
3
|
+
* strictness of both type checking and runtime.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Checks that the given value is of type `never` — the type that’s left after
|
|
7
|
+
* all other cases have been removed.
|
|
8
|
+
*
|
|
9
|
+
* @param x A value of type `never`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function assertNever(x: never): never;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/common/utilities/assertions.ts
|
|
3
|
+
/** @hidden
|
|
4
|
+
* @file Provides common assertion helpers which can be used to improve
|
|
5
|
+
* strictness of both type checking and runtime.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Checks that the given value is of type `never` — the type that’s left after
|
|
9
|
+
* all other cases have been removed.
|
|
10
|
+
*
|
|
11
|
+
* @param x A value of type `never`.
|
|
12
|
+
*/
|
|
13
|
+
function assertNever(x) {
|
|
14
|
+
throw new Error(`Unhandled discriminated union member: ${JSON.stringify(x)}.`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.assertNever = assertNever;
|
|
@@ -1,39 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
// Copyright (c) 2017 Firebase
|
|
5
|
-
//
|
|
6
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
// in the Software without restriction, including without limitation the rights
|
|
9
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
// furnished to do so, subject to the following conditions:
|
|
12
|
-
//
|
|
13
|
-
// The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
// copies or substantial portions of the Software.
|
|
15
|
-
//
|
|
16
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
// SOFTWARE.
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.dateToTimestampProto = void 0;
|
|
1
|
+
|
|
2
|
+
//#region src/common/utilities/encoder.ts
|
|
25
3
|
function dateToTimestampProto(timeString) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
4
|
+
if (typeof timeString === "undefined") {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const date = new Date(timeString);
|
|
8
|
+
const seconds = Math.floor(date.getTime() / 1e3);
|
|
9
|
+
let nanos = 0;
|
|
10
|
+
if (timeString.length > 20) {
|
|
11
|
+
const nanoString = timeString.substring(20, timeString.length - 1);
|
|
12
|
+
const trailingZeroes = 9 - nanoString.length;
|
|
13
|
+
nanos = parseInt(nanoString, 10) * Math.pow(10, trailingZeroes);
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
seconds,
|
|
17
|
+
nanos
|
|
18
|
+
};
|
|
38
19
|
}
|
|
39
|
-
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.dateToTimestampProto = dateToTimestampProto;
|
|
@@ -1,143 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// Copyright (c) 2022 Firebase
|
|
5
|
-
//
|
|
6
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
// in the Software without restriction, including without limitation the rights
|
|
9
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
// furnished to do so, subject to the following conditions:
|
|
12
|
-
//
|
|
13
|
-
// The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
// copies or substantial portions of the Software.
|
|
15
|
-
//
|
|
16
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
// SOFTWARE.
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.PathPattern = exports.trimParam = void 0;
|
|
25
|
-
const path_1 = require("./path");
|
|
1
|
+
const require_common_utilities_path = require('./path.js');
|
|
2
|
+
|
|
3
|
+
//#region src/common/utilities/path-pattern.ts
|
|
26
4
|
/** https://cloud.google.com/eventarc/docs/path-patterns */
|
|
27
5
|
/** @hidden */
|
|
28
6
|
const WILDCARD_CAPTURE_REGEX = new RegExp("{[^/{}]+}", "g");
|
|
29
7
|
/** @internal */
|
|
30
8
|
function trimParam(param) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
9
|
+
const paramNoBraces = param.slice(1, -1);
|
|
10
|
+
if (paramNoBraces.includes("=")) {
|
|
11
|
+
return paramNoBraces.slice(0, paramNoBraces.indexOf("="));
|
|
12
|
+
}
|
|
13
|
+
return paramNoBraces;
|
|
36
14
|
}
|
|
37
|
-
exports.trimParam = trimParam;
|
|
38
15
|
/** @hidden */
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
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
|
+
};
|
|
52
29
|
/** @hidden */
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
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
|
+
};
|
|
66
43
|
/** @hidden */
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
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
|
+
};
|
|
80
57
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
this.segments.push(segment);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
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 = require_common_utilities_path.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 = require_common_utilities_path.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
|
|
143
116
|
exports.PathPattern = PathPattern;
|
|
117
|
+
exports.trimParam = trimParam;
|
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.joinPath = exports.pathParts = exports.normalizePath = void 0;
|
|
1
|
+
|
|
2
|
+
//#region src/common/utilities/path.ts
|
|
4
3
|
/** @hidden
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
* Removes leading and trailing slashes from a path.
|
|
5
|
+
*
|
|
6
|
+
* @param path A path to normalize, in POSIX format.
|
|
7
|
+
*/
|
|
9
8
|
function normalizePath(path) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
if (!path) {
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
return path.replace(/^\//, "").replace(/\/$/, "");
|
|
14
13
|
}
|
|
15
|
-
exports.normalizePath = normalizePath;
|
|
16
14
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
* Normalizes a given path and splits it into an array of segments.
|
|
16
|
+
*
|
|
17
|
+
* @param path A path to split, in POSIX format.
|
|
18
|
+
*/
|
|
21
19
|
function pathParts(path) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
if (!path || path === "" || path === "/") {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return normalizePath(path).split("/");
|
|
26
24
|
}
|
|
27
|
-
exports.pathParts = pathParts;
|
|
28
25
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
* Normalizes given paths and joins these together using a POSIX separator.
|
|
27
|
+
*
|
|
28
|
+
* @param base A first path segment, in POSIX format.
|
|
29
|
+
* @param child A second path segment, in POSIX format.
|
|
30
|
+
*/
|
|
34
31
|
function joinPath(base, child) {
|
|
35
|
-
|
|
32
|
+
return pathParts(base).concat(pathParts(child)).join("/");
|
|
36
33
|
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
37
36
|
exports.joinPath = joinPath;
|
|
37
|
+
exports.normalizePath = normalizePath;
|
|
38
|
+
exports.pathParts = pathParts;
|
|
@@ -1,52 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
// Copyright (c) 2017 Firebase
|
|
5
|
-
//
|
|
6
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
// in the Software without restriction, including without limitation the rights
|
|
9
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
// furnished to do so, subject to the following conditions:
|
|
12
|
-
//
|
|
13
|
-
// The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
// copies or substantial portions of the Software.
|
|
15
|
-
//
|
|
16
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
// SOFTWARE.
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.applyChange = void 0;
|
|
1
|
+
|
|
2
|
+
//#region src/common/utilities/utils.ts
|
|
25
3
|
function isObject(obj) {
|
|
26
|
-
|
|
4
|
+
return typeof obj === "object" && !!obj;
|
|
27
5
|
}
|
|
28
6
|
/** @hidden */
|
|
29
7
|
function applyChange(src, dest) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return merge(src, dest);
|
|
8
|
+
if (!isObject(dest) || !isObject(src)) {
|
|
9
|
+
return dest;
|
|
10
|
+
}
|
|
11
|
+
return merge(src, dest);
|
|
35
12
|
}
|
|
36
|
-
exports.applyChange = applyChange;
|
|
37
13
|
function merge(src, dest) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return res;
|
|
14
|
+
const res = {};
|
|
15
|
+
const keys = new Set([...Object.keys(src), ...Object.keys(dest)]);
|
|
16
|
+
for (const key of keys.values()) {
|
|
17
|
+
if (key in dest) {
|
|
18
|
+
if (dest[key] === null) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
res[key] = applyChange(src[key], dest[key]);
|
|
22
|
+
} else if (src[key] !== null) {
|
|
23
|
+
res[key] = src[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return res;
|
|
52
27
|
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.applyChange = applyChange;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __export = (all) => {
|
|
6
|
+
let target = {};
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { __export, __require };
|