firebase-functions 7.0.0 → 7.0.1-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/common/options.d.ts +10 -0
- package/lib/common/options.js +13 -0
- package/lib/esm/common/options.mjs +13 -0
- package/lib/esm/params/index.mjs +14 -1
- package/lib/esm/params/types.mjs +13 -0
- package/lib/esm/runtime/manifest.mjs +7 -2
- package/lib/esm/v2/providers/scheduler.mjs +2 -1
- package/lib/params/index.js +14 -1
- package/lib/params/types.d.ts +9 -0
- package/lib/params/types.js +13 -0
- package/lib/runtime/manifest.d.ts +1 -0
- package/lib/runtime/manifest.js +7 -2
- package/lib/v2/providers/scheduler.d.ts +6 -0
- package/lib/v2/providers/scheduler.js +2 -1
- package/package.json +1 -1
package/lib/common/options.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
declare const RESET_VALUE_TAG: unique symbol;
|
|
1
2
|
/**
|
|
2
3
|
* Special configuration type to reset configuration to platform default.
|
|
3
4
|
*
|
|
4
5
|
* @alpha
|
|
5
6
|
*/
|
|
6
7
|
export declare class ResetValue {
|
|
8
|
+
/**
|
|
9
|
+
* Handle the "Dual-Package Hazard".
|
|
10
|
+
*
|
|
11
|
+
* We implement custom `Symbol.hasInstance` to so CJS/ESM ResetValue instances
|
|
12
|
+
* are recognized as the same type.
|
|
13
|
+
*/
|
|
14
|
+
static [Symbol.hasInstance](instance: unknown): boolean;
|
|
15
|
+
get [RESET_VALUE_TAG](): boolean;
|
|
7
16
|
toJSON(): null;
|
|
8
17
|
private constructor();
|
|
9
18
|
static getInstance(): ResetValue;
|
|
@@ -12,3 +21,4 @@ export declare class ResetValue {
|
|
|
12
21
|
* Special configuration value to reset configuration to platform default.
|
|
13
22
|
*/
|
|
14
23
|
export declare const RESET_VALUE: ResetValue;
|
|
24
|
+
export {};
|
package/lib/common/options.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/common/options.ts
|
|
3
|
+
const RESET_VALUE_TAG = Symbol.for("firebase-functions:ResetValue:Tag");
|
|
3
4
|
/**
|
|
4
5
|
* Special configuration type to reset configuration to platform default.
|
|
5
6
|
*
|
|
6
7
|
* @alpha
|
|
7
8
|
*/
|
|
8
9
|
var ResetValue = class ResetValue {
|
|
10
|
+
/**
|
|
11
|
+
* Handle the "Dual-Package Hazard".
|
|
12
|
+
*
|
|
13
|
+
* We implement custom `Symbol.hasInstance` to so CJS/ESM ResetValue instances
|
|
14
|
+
* are recognized as the same type.
|
|
15
|
+
*/
|
|
16
|
+
static [Symbol.hasInstance](instance) {
|
|
17
|
+
return instance?.[RESET_VALUE_TAG] === true;
|
|
18
|
+
}
|
|
19
|
+
get [RESET_VALUE_TAG]() {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
9
22
|
toJSON() {
|
|
10
23
|
return null;
|
|
11
24
|
}
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
//#region src/common/options.ts
|
|
2
|
+
const RESET_VALUE_TAG = Symbol.for("firebase-functions:ResetValue:Tag");
|
|
2
3
|
/**
|
|
3
4
|
* Special configuration type to reset configuration to platform default.
|
|
4
5
|
*
|
|
5
6
|
* @alpha
|
|
6
7
|
*/
|
|
7
8
|
var ResetValue = class ResetValue {
|
|
9
|
+
/**
|
|
10
|
+
* Handle the "Dual-Package Hazard".
|
|
11
|
+
*
|
|
12
|
+
* We implement custom `Symbol.hasInstance` to so CJS/ESM ResetValue instances
|
|
13
|
+
* are recognized as the same type.
|
|
14
|
+
*/
|
|
15
|
+
static [Symbol.hasInstance](instance) {
|
|
16
|
+
return instance?.[RESET_VALUE_TAG] === true;
|
|
17
|
+
}
|
|
18
|
+
get [RESET_VALUE_TAG]() {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
8
21
|
toJSON() {
|
|
9
22
|
return null;
|
|
10
23
|
}
|
package/lib/esm/params/index.mjs
CHANGED
|
@@ -21,7 +21,20 @@ var params_exports = /* @__PURE__ */ __export({
|
|
|
21
21
|
select: () => select,
|
|
22
22
|
storageBucket: () => storageBucket
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Use a global singleton to manage the list of declared parameters.
|
|
26
|
+
*
|
|
27
|
+
* This ensures that parameters are shared between CJS and ESM builds,
|
|
28
|
+
* avoiding the "dual-package hazard" where the src/bin/firebase-functions.ts (CJS) sees
|
|
29
|
+
* an empty list while the user's code (ESM) populates a different list.
|
|
30
|
+
*/
|
|
31
|
+
const majorVersion = typeof "7" !== "undefined" ? "7" : "0";
|
|
32
|
+
const GLOBAL_SYMBOL = Symbol.for(`firebase-functions:params:declaredParams:v${majorVersion}`);
|
|
33
|
+
const globalSymbols = globalThis;
|
|
34
|
+
if (!globalSymbols[GLOBAL_SYMBOL]) {
|
|
35
|
+
globalSymbols[GLOBAL_SYMBOL] = [];
|
|
36
|
+
}
|
|
37
|
+
const declaredParams = globalSymbols[GLOBAL_SYMBOL];
|
|
25
38
|
/**
|
|
26
39
|
* Use a helper to manage the list such that parameters are uniquely
|
|
27
40
|
* registered once only but order is preserved.
|
package/lib/esm/params/types.mjs
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { warn } from "../logger/index.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/params/types.ts
|
|
4
|
+
const EXPRESSION_TAG = Symbol.for("firebase-functions:Expression:Tag");
|
|
4
5
|
var Expression = class {
|
|
6
|
+
/**
|
|
7
|
+
* Handle the "Dual-Package Hazard" .
|
|
8
|
+
*
|
|
9
|
+
* We implement custom `Symbol.hasInstance` to so CJS/ESM Expression instances
|
|
10
|
+
* are recognized as the same type.
|
|
11
|
+
*/
|
|
12
|
+
static [Symbol.hasInstance](instance) {
|
|
13
|
+
return instance?.[EXPRESSION_TAG] === true;
|
|
14
|
+
}
|
|
15
|
+
get [EXPRESSION_TAG]() {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
5
18
|
/** Returns the expression's runtime value, based on the CLI's resolution of parameters. */
|
|
6
19
|
value() {
|
|
7
20
|
if (process.env.FUNCTIONS_CONTROL_API === "true") {
|
|
@@ -99,7 +99,8 @@ const RESETTABLE_V2_SCHEDULE_OPTIONS = {
|
|
|
99
99
|
maxDoublings: null,
|
|
100
100
|
maxRetrySeconds: null,
|
|
101
101
|
minBackoffSeconds: null,
|
|
102
|
-
maxBackoffSeconds: null
|
|
102
|
+
maxBackoffSeconds: null,
|
|
103
|
+
attemptDeadlineSeconds: null
|
|
103
104
|
};
|
|
104
105
|
function initScheduleTrigger(resetOptions, schedule, ...opts) {
|
|
105
106
|
let scheduleTrigger = {
|
|
@@ -108,7 +109,11 @@ function initScheduleTrigger(resetOptions, schedule, ...opts) {
|
|
|
108
109
|
};
|
|
109
110
|
if (opts.every((opt) => !opt?.preserveExternalChanges)) {
|
|
110
111
|
for (const key of Object.keys(resetOptions)) {
|
|
111
|
-
|
|
112
|
+
if (key === "attemptDeadlineSeconds") {
|
|
113
|
+
scheduleTrigger[key] = RESET_VALUE;
|
|
114
|
+
} else {
|
|
115
|
+
scheduleTrigger.retryConfig[key] = RESET_VALUE;
|
|
116
|
+
}
|
|
112
117
|
}
|
|
113
118
|
scheduleTrigger = {
|
|
114
119
|
...scheduleTrigger,
|
|
@@ -22,6 +22,7 @@ function getOpts(args) {
|
|
|
22
22
|
return {
|
|
23
23
|
schedule: args.schedule,
|
|
24
24
|
timeZone: args.timeZone,
|
|
25
|
+
attemptDeadlineSeconds: args.attemptDeadlineSeconds,
|
|
25
26
|
retryConfig: {
|
|
26
27
|
retryCount: args.retryCount,
|
|
27
28
|
maxRetrySeconds: args.maxRetrySeconds,
|
|
@@ -70,7 +71,7 @@ function onSchedule(args, handler) {
|
|
|
70
71
|
},
|
|
71
72
|
scheduleTrigger: initV2ScheduleTrigger(separatedOpts.schedule, globalOpts, separatedOpts.opts)
|
|
72
73
|
};
|
|
73
|
-
copyIfPresent(ep.scheduleTrigger, separatedOpts, "timeZone");
|
|
74
|
+
copyIfPresent(ep.scheduleTrigger, separatedOpts, "timeZone", "attemptDeadlineSeconds");
|
|
74
75
|
copyIfPresent(ep.scheduleTrigger.retryConfig, separatedOpts.retryConfig, "retryCount", "maxRetrySeconds", "minBackoffSeconds", "maxBackoffSeconds", "maxDoublings");
|
|
75
76
|
func.__endpoint = ep;
|
|
76
77
|
func.__requiredAPIs = [{
|
package/lib/params/index.js
CHANGED
|
@@ -21,7 +21,20 @@ var params_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
|
|
|
21
21
|
select: () => require_params_types.select,
|
|
22
22
|
storageBucket: () => storageBucket
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Use a global singleton to manage the list of declared parameters.
|
|
26
|
+
*
|
|
27
|
+
* This ensures that parameters are shared between CJS and ESM builds,
|
|
28
|
+
* avoiding the "dual-package hazard" where the src/bin/firebase-functions.ts (CJS) sees
|
|
29
|
+
* an empty list while the user's code (ESM) populates a different list.
|
|
30
|
+
*/
|
|
31
|
+
const majorVersion = typeof "7" !== "undefined" ? "7" : "0";
|
|
32
|
+
const GLOBAL_SYMBOL = Symbol.for(`firebase-functions:params:declaredParams:v${majorVersion}`);
|
|
33
|
+
const globalSymbols = globalThis;
|
|
34
|
+
if (!globalSymbols[GLOBAL_SYMBOL]) {
|
|
35
|
+
globalSymbols[GLOBAL_SYMBOL] = [];
|
|
36
|
+
}
|
|
37
|
+
const declaredParams = globalSymbols[GLOBAL_SYMBOL];
|
|
25
38
|
/**
|
|
26
39
|
* Use a helper to manage the list such that parameters are uniquely
|
|
27
40
|
* registered once only but order is preserved.
|
package/lib/params/types.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
declare const EXPRESSION_TAG: unique symbol;
|
|
1
2
|
export declare abstract class Expression<T extends string | number | boolean | string[]> {
|
|
3
|
+
/**
|
|
4
|
+
* Handle the "Dual-Package Hazard" .
|
|
5
|
+
*
|
|
6
|
+
* We implement custom `Symbol.hasInstance` to so CJS/ESM Expression instances
|
|
7
|
+
* are recognized as the same type.
|
|
8
|
+
*/
|
|
9
|
+
static [Symbol.hasInstance](instance: unknown): boolean;
|
|
10
|
+
get [EXPRESSION_TAG](): boolean;
|
|
2
11
|
/** Returns the expression's runtime value, based on the CLI's resolution of parameters. */
|
|
3
12
|
value(): T;
|
|
4
13
|
/** Returns the expression's representation as a braced CEL expression. */
|
package/lib/params/types.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
const require_logger_index = require('../logger/index.js');
|
|
2
2
|
|
|
3
3
|
//#region src/params/types.ts
|
|
4
|
+
const EXPRESSION_TAG = Symbol.for("firebase-functions:Expression:Tag");
|
|
4
5
|
var Expression = class {
|
|
6
|
+
/**
|
|
7
|
+
* Handle the "Dual-Package Hazard" .
|
|
8
|
+
*
|
|
9
|
+
* We implement custom `Symbol.hasInstance` to so CJS/ESM Expression instances
|
|
10
|
+
* are recognized as the same type.
|
|
11
|
+
*/
|
|
12
|
+
static [Symbol.hasInstance](instance) {
|
|
13
|
+
return instance?.[EXPRESSION_TAG] === true;
|
|
14
|
+
}
|
|
15
|
+
get [EXPRESSION_TAG]() {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
5
18
|
/** Returns the expression's runtime value, based on the CLI's resolution of parameters. */
|
|
6
19
|
value() {
|
|
7
20
|
if (process.env.FUNCTIONS_CONTROL_API === "true") {
|
|
@@ -70,6 +70,7 @@ export interface ManifestEndpoint {
|
|
|
70
70
|
scheduleTrigger?: {
|
|
71
71
|
schedule: string | Expression<string>;
|
|
72
72
|
timeZone?: string | Expression<string> | ResetValue;
|
|
73
|
+
attemptDeadlineSeconds?: number | Expression<number> | ResetValue;
|
|
73
74
|
retryConfig?: {
|
|
74
75
|
retryCount?: number | Expression<number> | ResetValue;
|
|
75
76
|
maxRetrySeconds?: string | Expression<string> | ResetValue;
|
package/lib/runtime/manifest.js
CHANGED
|
@@ -99,7 +99,8 @@ const RESETTABLE_V2_SCHEDULE_OPTIONS = {
|
|
|
99
99
|
maxDoublings: null,
|
|
100
100
|
maxRetrySeconds: null,
|
|
101
101
|
minBackoffSeconds: null,
|
|
102
|
-
maxBackoffSeconds: null
|
|
102
|
+
maxBackoffSeconds: null,
|
|
103
|
+
attemptDeadlineSeconds: null
|
|
103
104
|
};
|
|
104
105
|
function initScheduleTrigger(resetOptions, schedule, ...opts) {
|
|
105
106
|
let scheduleTrigger = {
|
|
@@ -108,7 +109,11 @@ function initScheduleTrigger(resetOptions, schedule, ...opts) {
|
|
|
108
109
|
};
|
|
109
110
|
if (opts.every((opt) => !opt?.preserveExternalChanges)) {
|
|
110
111
|
for (const key of Object.keys(resetOptions)) {
|
|
111
|
-
|
|
112
|
+
if (key === "attemptDeadlineSeconds") {
|
|
113
|
+
scheduleTrigger[key] = require_common_options.RESET_VALUE;
|
|
114
|
+
} else {
|
|
115
|
+
scheduleTrigger.retryConfig[key] = require_common_options.RESET_VALUE;
|
|
116
|
+
}
|
|
112
117
|
}
|
|
113
118
|
scheduleTrigger = {
|
|
114
119
|
...scheduleTrigger,
|
|
@@ -36,6 +36,12 @@ export interface ScheduleOptions extends options.GlobalOptions {
|
|
|
36
36
|
schedule: string;
|
|
37
37
|
/** The timezone that the schedule executes in. */
|
|
38
38
|
timeZone?: timezone | Expression<string> | ResetValue;
|
|
39
|
+
/**
|
|
40
|
+
* The deadline for job attempts in seconds. If the request handler does not respond by this deadline,
|
|
41
|
+
* the request is cancelled and the attempt is marked as a `DEADLINE_EXCEEDED` failure.
|
|
42
|
+
* The value must be between 15 and 1800. Defaults to 180.
|
|
43
|
+
*/
|
|
44
|
+
attemptDeadlineSeconds?: number | Expression<number> | ResetValue;
|
|
39
45
|
/** The number of retry attempts for a failed run. */
|
|
40
46
|
retryCount?: number | Expression<number> | ResetValue;
|
|
41
47
|
/** The time limit for retrying. */
|
|
@@ -22,6 +22,7 @@ function getOpts(args) {
|
|
|
22
22
|
return {
|
|
23
23
|
schedule: args.schedule,
|
|
24
24
|
timeZone: args.timeZone,
|
|
25
|
+
attemptDeadlineSeconds: args.attemptDeadlineSeconds,
|
|
25
26
|
retryConfig: {
|
|
26
27
|
retryCount: args.retryCount,
|
|
27
28
|
maxRetrySeconds: args.maxRetrySeconds,
|
|
@@ -70,7 +71,7 @@ function onSchedule(args, handler) {
|
|
|
70
71
|
},
|
|
71
72
|
scheduleTrigger: require_runtime_manifest.initV2ScheduleTrigger(separatedOpts.schedule, globalOpts, separatedOpts.opts)
|
|
72
73
|
};
|
|
73
|
-
require_common_encoding.copyIfPresent(ep.scheduleTrigger, separatedOpts, "timeZone");
|
|
74
|
+
require_common_encoding.copyIfPresent(ep.scheduleTrigger, separatedOpts, "timeZone", "attemptDeadlineSeconds");
|
|
74
75
|
require_common_encoding.copyIfPresent(ep.scheduleTrigger.retryConfig, separatedOpts.retryConfig, "retryCount", "maxRetrySeconds", "minBackoffSeconds", "maxBackoffSeconds", "maxDoublings");
|
|
75
76
|
func.__endpoint = ep;
|
|
76
77
|
func.__requiredAPIs = [{
|