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.
Files changed (156) hide show
  1. package/lib/_virtual/rolldown_runtime.js +34 -0
  2. package/lib/bin/firebase-functions.js +78 -103
  3. package/lib/common/app.js +35 -55
  4. package/lib/common/change.js +54 -75
  5. package/lib/common/config.js +41 -41
  6. package/lib/common/debug.js +23 -47
  7. package/lib/common/encoding.js +59 -82
  8. package/lib/common/onInit.js +26 -28
  9. package/lib/common/options.js +22 -42
  10. package/lib/common/params.d.ts +6 -6
  11. package/lib/common/params.js +0 -23
  12. package/lib/common/providers/database.js +270 -300
  13. package/lib/common/providers/firestore.js +66 -92
  14. package/lib/common/providers/https.d.ts +0 -1
  15. package/lib/common/providers/https.js +537 -539
  16. package/lib/common/providers/identity.js +393 -444
  17. package/lib/common/providers/tasks.js +64 -98
  18. package/lib/common/timezone.js +544 -542
  19. package/lib/common/trace.d.ts +0 -1
  20. package/lib/common/trace.js +63 -55
  21. package/lib/common/utilities/assertions.d.ts +11 -0
  22. package/lib/common/utilities/assertions.js +18 -0
  23. package/lib/common/utilities/encoder.js +20 -37
  24. package/lib/common/utilities/path-pattern.js +106 -132
  25. package/lib/common/utilities/path.js +28 -27
  26. package/lib/common/utilities/utils.js +23 -45
  27. package/lib/esm/_virtual/rolldown_runtime.mjs +16 -0
  28. package/lib/esm/bin/firebase-functions.mjs +91 -0
  29. package/lib/esm/common/app.mjs +39 -0
  30. package/lib/esm/common/change.mjs +57 -0
  31. package/lib/esm/common/config.mjs +45 -0
  32. package/lib/esm/common/debug.mjs +28 -0
  33. package/lib/esm/common/encoding.mjs +69 -0
  34. package/lib/esm/common/onInit.mjs +33 -0
  35. package/lib/esm/common/options.mjs +22 -0
  36. package/lib/esm/common/params.mjs +1 -0
  37. package/lib/esm/common/providers/database.mjs +269 -0
  38. package/lib/esm/common/providers/firestore.mjs +78 -0
  39. package/lib/esm/common/providers/https.mjs +573 -0
  40. package/lib/esm/common/providers/identity.mjs +428 -0
  41. package/lib/esm/common/providers/tasks.mjs +67 -0
  42. package/lib/esm/common/timezone.mjs +544 -0
  43. package/lib/esm/common/trace.mjs +73 -0
  44. package/lib/esm/common/utilities/assertions.mjs +17 -0
  45. package/lib/esm/common/utilities/encoder.mjs +21 -0
  46. package/lib/esm/common/utilities/path-pattern.mjs +116 -0
  47. package/lib/esm/common/utilities/path.mjs +35 -0
  48. package/lib/esm/common/utilities/utils.mjs +29 -0
  49. package/lib/esm/function-configuration.mjs +1 -0
  50. package/lib/esm/logger/common.mjs +23 -0
  51. package/lib/esm/logger/compat.mjs +25 -0
  52. package/lib/esm/logger/index.mjs +131 -0
  53. package/lib/esm/params/index.mjs +160 -0
  54. package/lib/esm/params/types.mjs +400 -0
  55. package/lib/esm/runtime/loader.mjs +132 -0
  56. package/lib/esm/runtime/manifest.mjs +134 -0
  57. package/lib/esm/types/global.d.mjs +1 -0
  58. package/lib/esm/v1/cloud-functions.mjs +206 -0
  59. package/lib/esm/v1/config.mjs +14 -0
  60. package/lib/esm/v1/function-builder.mjs +252 -0
  61. package/lib/esm/v1/function-configuration.mjs +72 -0
  62. package/lib/esm/v1/index.mjs +27 -0
  63. package/lib/esm/v1/providers/analytics.mjs +212 -0
  64. package/lib/esm/v1/providers/auth.mjs +156 -0
  65. package/lib/esm/v1/providers/database.mjs +243 -0
  66. package/lib/esm/v1/providers/firestore.mjs +131 -0
  67. package/lib/esm/v1/providers/https.mjs +82 -0
  68. package/lib/esm/v1/providers/pubsub.mjs +175 -0
  69. package/lib/esm/v1/providers/remoteConfig.mjs +64 -0
  70. package/lib/esm/v1/providers/storage.mjs +163 -0
  71. package/lib/esm/v1/providers/tasks.mjs +63 -0
  72. package/lib/esm/v1/providers/testLab.mjs +94 -0
  73. package/lib/esm/v2/core.mjs +4 -0
  74. package/lib/esm/v2/index.mjs +28 -0
  75. package/lib/esm/v2/options.mjs +102 -0
  76. package/lib/esm/v2/providers/alerts/alerts.mjs +85 -0
  77. package/lib/esm/v2/providers/alerts/appDistribution.mjs +75 -0
  78. package/lib/esm/v2/providers/alerts/billing.mjs +51 -0
  79. package/lib/esm/v2/providers/alerts/crashlytics.mjs +122 -0
  80. package/lib/esm/v2/providers/alerts/index.mjs +22 -0
  81. package/lib/esm/v2/providers/alerts/performance.mjs +66 -0
  82. package/lib/esm/v2/providers/database.mjs +197 -0
  83. package/lib/esm/v2/providers/dataconnect.mjs +130 -0
  84. package/lib/esm/v2/providers/eventarc.mjs +51 -0
  85. package/lib/esm/v2/providers/firestore.mjs +294 -0
  86. package/lib/esm/v2/providers/https.mjs +210 -0
  87. package/lib/esm/v2/providers/identity.mjs +103 -0
  88. package/lib/esm/v2/providers/pubsub.mjs +148 -0
  89. package/lib/esm/v2/providers/remoteConfig.mjs +52 -0
  90. package/lib/esm/v2/providers/scheduler.mjs +84 -0
  91. package/lib/esm/v2/providers/storage.mjs +155 -0
  92. package/lib/esm/v2/providers/tasks.mjs +65 -0
  93. package/lib/esm/v2/providers/testLab.mjs +53 -0
  94. package/lib/esm/v2/trace.mjs +20 -0
  95. package/lib/function-configuration.d.ts +0 -0
  96. package/lib/function-configuration.js +0 -0
  97. package/lib/logger/common.js +21 -41
  98. package/lib/logger/compat.js +18 -33
  99. package/lib/logger/index.js +119 -130
  100. package/lib/params/index.d.ts +4 -2
  101. package/lib/params/index.js +150 -144
  102. package/lib/params/types.js +389 -423
  103. package/lib/runtime/loader.js +114 -148
  104. package/lib/runtime/manifest.js +106 -126
  105. package/lib/types/global.d.js +0 -0
  106. package/lib/v1/cloud-functions.d.ts +2 -2
  107. package/lib/v1/cloud-functions.js +193 -241
  108. package/lib/v1/config.d.ts +4 -7
  109. package/lib/v1/config.js +13 -75
  110. package/lib/v1/function-builder.js +239 -368
  111. package/lib/v1/function-configuration.js +70 -63
  112. package/lib/v1/index.js +118 -73
  113. package/lib/v1/providers/analytics.js +188 -235
  114. package/lib/v1/providers/auth.d.ts +2 -1
  115. package/lib/v1/providers/auth.js +159 -164
  116. package/lib/v1/providers/database.js +237 -242
  117. package/lib/v1/providers/firestore.js +131 -130
  118. package/lib/v1/providers/https.d.ts +2 -1
  119. package/lib/v1/providers/https.js +79 -86
  120. package/lib/v1/providers/pubsub.js +175 -172
  121. package/lib/v1/providers/remoteConfig.js +64 -68
  122. package/lib/v1/providers/storage.js +161 -163
  123. package/lib/v1/providers/tasks.d.ts +1 -1
  124. package/lib/v1/providers/tasks.js +65 -80
  125. package/lib/v1/providers/testLab.js +94 -94
  126. package/lib/v2/core.d.ts +1 -1
  127. package/lib/v2/core.js +5 -32
  128. package/lib/v2/index.d.ts +6 -3
  129. package/lib/v2/index.js +123 -75
  130. package/lib/v2/options.js +88 -114
  131. package/lib/v2/providers/alerts/alerts.js +76 -95
  132. package/lib/v2/providers/alerts/appDistribution.js +73 -78
  133. package/lib/v2/providers/alerts/billing.js +49 -53
  134. package/lib/v2/providers/alerts/crashlytics.js +110 -102
  135. package/lib/v2/providers/alerts/index.js +56 -53
  136. package/lib/v2/providers/alerts/performance.js +64 -74
  137. package/lib/v2/providers/database.js +177 -180
  138. package/lib/v2/providers/dataconnect.d.ts +95 -0
  139. package/lib/v2/providers/dataconnect.js +137 -0
  140. package/lib/v2/providers/eventarc.js +55 -77
  141. package/lib/v2/providers/firestore.js +262 -260
  142. package/lib/v2/providers/https.d.ts +3 -2
  143. package/lib/v2/providers/https.js +210 -247
  144. package/lib/v2/providers/identity.d.ts +2 -1
  145. package/lib/v2/providers/identity.js +96 -105
  146. package/lib/v2/providers/pubsub.js +149 -167
  147. package/lib/v2/providers/remoteConfig.js +54 -63
  148. package/lib/v2/providers/scheduler.js +84 -96
  149. package/lib/v2/providers/storage.js +147 -162
  150. package/lib/v2/providers/tasks.d.ts +1 -1
  151. package/lib/v2/providers/tasks.js +68 -95
  152. package/lib/v2/providers/testLab.js +55 -64
  153. package/lib/v2/trace.js +18 -19
  154. package/package.json +321 -88
  155. package/protos/compiledFirestore.mjs +3512 -0
  156. package/protos/update.sh +28 -7
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { AsyncLocalStorage } from "async_hooks";
3
2
  export declare const traceContext: AsyncLocalStorage<TraceContext>;
4
3
  export interface TraceContext {
@@ -1,68 +1,76 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractTraceContext = exports.traceContext = void 0;
4
- const async_hooks_1 = require("async_hooks");
5
- exports.traceContext = new async_hooks_1.AsyncLocalStorage();
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
- * A regex to match the Cloud Trace header.
8
- * - ([A-Fa-f0-9]{32}): The trace id, a 32 character hex value. (e.g. 4bf92f3577b34da6a3ce929d0e0e4736)
9
- * - ([0-9]+): The parent span id, a 64 bit integer. (e.g. 00f067aa0ba902b7)
10
- * - (?:;o=([0-3])): The trace mask, 1-3 denote it should be traced.
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
- let header = carrier === null || carrier === void 0 ? void 0 : carrier[CLOUD_TRACE_HEADER];
16
- if (!header) {
17
- // try lowercase header
18
- header = carrier === null || carrier === void 0 ? void 0 : 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
- // Convert parentId from unsigned int to hex
25
- const parentId = parseInt(parentIdInt);
26
- if (isNaN(parentId)) {
27
- // Ignore traces with invalid parentIds
28
- return;
29
- }
30
- const sample = !!traceMask && traceMask !== "0";
31
- return { traceId, parentId: parentId.toString(16), sample, version: "00" };
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
- * A regex to match the traceparent header.
37
- * - ^([a-f0-9]{2}): The specification version (e.g. 00)
38
- * - ([a-f0-9]{32}): The trace id, a 16-byte array. (e.g. 4bf92f3577b34da6a3ce929d0e0e4736)
39
- * - ([a-f0-9]{16}): The parent span id, an 8-byte array. (e.g. 00f067aa0ba902b7)
40
- * - ([a-f0-9]{2}: The sampled flag. (e.g. 00)
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
- const header = carrier === null || carrier === void 0 ? void 0 : 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 { traceId, parentId, sample, version };
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
- * Extracts trace context from given carrier object, if any.
60
- *
61
- * Supports Cloud Trace and traceparent format.
62
- *
63
- * @param carrier
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
- return matchCloudTraceHeader(carrier) || matchTraceparentHeader(carrier);
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
- "use strict";
2
- // The MIT License (MIT)
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
- if (typeof timeString === "undefined") {
27
- return;
28
- }
29
- const date = new Date(timeString);
30
- const seconds = Math.floor(date.getTime() / 1000);
31
- let nanos = 0;
32
- if (timeString.length > 20) {
33
- const nanoString = timeString.substring(20, timeString.length - 1);
34
- const trailingZeroes = 9 - nanoString.length;
35
- nanos = parseInt(nanoString, 10) * Math.pow(10, trailingZeroes);
36
- }
37
- return { seconds, nanos };
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
- exports.dateToTimestampProto = dateToTimestampProto;
20
+
21
+ //#endregion
22
+ exports.dateToTimestampProto = dateToTimestampProto;
@@ -1,143 +1,117 @@
1
- "use strict";
2
- // The MIT License (MIT)
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
- const paramNoBraces = param.slice(1, -1);
32
- if (paramNoBraces.includes("=")) {
33
- return paramNoBraces.slice(0, paramNoBraces.indexOf("="));
34
- }
35
- return paramNoBraces;
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
- class Segment {
40
- constructor(value) {
41
- this.value = value;
42
- this.name = "segment";
43
- this.trimmed = value;
44
- }
45
- isSingleSegmentWildcard() {
46
- return this.value.includes("*") && !this.isMultiSegmentWildcard();
47
- }
48
- isMultiSegmentWildcard() {
49
- return this.value.includes("**");
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
- class SingleCaptureSegment {
54
- constructor(value) {
55
- this.value = value;
56
- this.name = "single-capture";
57
- this.trimmed = trimParam(value);
58
- }
59
- isSingleSegmentWildcard() {
60
- return true;
61
- }
62
- isMultiSegmentWildcard() {
63
- return false;
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
- class MultiCaptureSegment {
68
- constructor(value) {
69
- this.value = value;
70
- this.name = "multi-capture";
71
- this.trimmed = trimParam(value);
72
- }
73
- isSingleSegmentWildcard() {
74
- return false;
75
- }
76
- isMultiSegmentWildcard() {
77
- return true;
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
- * Implements Eventarc's path pattern from the spec https://cloud.google.com/eventarc/docs/path-patterns
82
- * @internal
83
- */
84
- class PathPattern {
85
- /** @throws on validation error */
86
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
87
- static compile(rawPath) {
88
- return undefined;
89
- }
90
- constructor(raw) {
91
- this.raw = raw;
92
- this.segments = [];
93
- this.initPathSegments(raw);
94
- }
95
- getValue() {
96
- return this.raw;
97
- }
98
- // If false, we don't need to use pathPattern as our eventarc match type.
99
- hasWildcards() {
100
- return this.segments.some((segment) => segment.isSingleSegmentWildcard() || segment.isMultiSegmentWildcard());
101
- }
102
- hasCaptures() {
103
- return this.segments.some((segment) => segment.name === "single-capture" || segment.name === "multi-capture");
104
- }
105
- extractMatches(path) {
106
- const matches = {};
107
- if (!this.hasCaptures()) {
108
- return matches;
109
- }
110
- const pathSegments = (0, path_1.pathParts)(path);
111
- let pathNdx = 0;
112
- for (let segmentNdx = 0; segmentNdx < this.segments.length && pathNdx < pathSegments.length; segmentNdx++) {
113
- const segment = this.segments[segmentNdx];
114
- const remainingSegments = this.segments.length - 1 - segmentNdx;
115
- const nextPathNdx = pathSegments.length - remainingSegments;
116
- if (segment.name === "single-capture") {
117
- matches[segment.trimmed] = pathSegments[pathNdx];
118
- }
119
- else if (segment.name === "multi-capture") {
120
- matches[segment.trimmed] = pathSegments.slice(pathNdx, nextPathNdx).join("/");
121
- }
122
- pathNdx = segment.isMultiSegmentWildcard() ? nextPathNdx : pathNdx + 1;
123
- }
124
- return matches;
125
- }
126
- initPathSegments(raw) {
127
- const parts = (0, path_1.pathParts)(raw);
128
- for (const part of parts) {
129
- let segment;
130
- const capture = part.match(WILDCARD_CAPTURE_REGEX);
131
- if (capture && capture.length === 1) {
132
- segment = part.includes("**")
133
- ? new MultiCaptureSegment(part)
134
- : new SingleCaptureSegment(part);
135
- }
136
- else {
137
- segment = new Segment(part);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.joinPath = exports.pathParts = exports.normalizePath = void 0;
1
+
2
+ //#region src/common/utilities/path.ts
4
3
  /** @hidden
5
- * Removes leading and trailing slashes from a path.
6
- *
7
- * @param path A path to normalize, in POSIX format.
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
- if (!path) {
11
- return "";
12
- }
13
- return path.replace(/^\//, "").replace(/\/$/, "");
9
+ if (!path) {
10
+ return "";
11
+ }
12
+ return path.replace(/^\//, "").replace(/\/$/, "");
14
13
  }
15
- exports.normalizePath = normalizePath;
16
14
  /**
17
- * Normalizes a given path and splits it into an array of segments.
18
- *
19
- * @param path A path to split, in POSIX format.
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
- if (!path || path === "" || path === "/") {
23
- return [];
24
- }
25
- return normalizePath(path).split("/");
20
+ if (!path || path === "" || path === "/") {
21
+ return [];
22
+ }
23
+ return normalizePath(path).split("/");
26
24
  }
27
- exports.pathParts = pathParts;
28
25
  /**
29
- * Normalizes given paths and joins these together using a POSIX separator.
30
- *
31
- * @param base A first path segment, in POSIX format.
32
- * @param child A second path segment, in POSIX format.
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
- return pathParts(base).concat(pathParts(child)).join("/");
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
- "use strict";
2
- // The MIT License (MIT)
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
- return typeof obj === "object" && !!obj;
4
+ return typeof obj === "object" && !!obj;
27
5
  }
28
6
  /** @hidden */
29
7
  function applyChange(src, dest) {
30
- // if not mergeable, don't merge
31
- if (!isObject(dest) || !isObject(src)) {
32
- return dest;
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
- const res = {};
39
- const keys = new Set([...Object.keys(src), ...Object.keys(dest)]);
40
- for (const key of keys.values()) {
41
- if (key in dest) {
42
- if (dest[key] === null) {
43
- continue;
44
- }
45
- res[key] = applyChange(src[key], dest[key]);
46
- }
47
- else if (src[key] !== null) {
48
- res[key] = src[key];
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 };