firebase-tools 11.4.1 → 11.4.2

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compareFunctions = exports.missingEndpoint = exports.hasEndpoint = exports.regionalEndpoints = exports.matchingBackend = exports.findEndpoint = exports.someEndpoint = exports.allEndpoints = exports.checkAvailability = exports.existingBackend = exports.scheduleIdForFunction = exports.functionName = exports.isEmptyBackend = exports.merge = exports.of = exports.empty = exports.isBlockingTriggered = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isCallableTriggered = exports.isHttpsTriggered = exports.AllFunctionsPlatforms = exports.secretVersionName = exports.SCHEDULED_FUNCTION_LABEL = exports.MIN_CPU_FOR_CONCURRENCY = exports.DEFAULT_MEMORY = exports.DEFAULT_CONCURRENCY = exports.memoryToGen2Cpu = exports.memoryToGen1Cpu = exports.memoryOptionDisplayName = exports.AllMemoryOptions = exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.endpointTriggerType = void 0;
3
+ exports.compareFunctions = exports.missingEndpoint = exports.hasEndpoint = exports.regionalEndpoints = exports.matchingBackend = exports.findEndpoint = exports.someEndpoint = exports.allEndpoints = exports.checkAvailability = exports.existingBackend = exports.scheduleIdForFunction = exports.functionName = exports.isEmptyBackend = exports.merge = exports.of = exports.empty = exports.isBlockingTriggered = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isCallableTriggered = exports.isHttpsTriggered = exports.AllFunctionsPlatforms = exports.secretVersionName = exports.SCHEDULED_FUNCTION_LABEL = exports.MIN_CPU_FOR_CONCURRENCY = exports.DEFAULT_MEMORY = exports.DEFAULT_CONCURRENCY = exports.memoryToGen2Cpu = exports.memoryToGen1Cpu = exports.memoryOptionDisplayName = exports.isValidMemoryOption = exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.endpointTriggerType = void 0;
4
4
  const gcf = require("../../gcp/cloudfunctions");
5
5
  const gcfV2 = require("../../gcp/cloudfunctionsv2");
6
6
  const run = require("../../gcp/run");
@@ -37,9 +37,11 @@ exports.AllIngressSettings = [
37
37
  "ALLOW_INTERNAL_ONLY",
38
38
  "ALLOW_INTERNAL_AND_GCLB",
39
39
  ];
40
- exports.AllMemoryOptions = [
41
- 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768,
42
- ];
40
+ const allMemoryOptions = [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768];
41
+ function isValidMemoryOption(mem) {
42
+ return allMemoryOptions.includes(mem);
43
+ }
44
+ exports.isValidMemoryOption = isValidMemoryOption;
43
45
  function memoryOptionDisplayName(option) {
44
46
  return {
45
47
  128: "128MB",
@@ -8,6 +8,7 @@ const params = require("./params");
8
8
  const previews_1 = require("../../previews");
9
9
  const error_1 = require("../../error");
10
10
  const functional_1 = require("../../functional");
11
+ const logger_1 = require("../../logger");
11
12
  function empty() {
12
13
  return {
13
14
  requiredAPIs: [],
@@ -22,9 +23,6 @@ function of(endpoints) {
22
23
  return build;
23
24
  }
24
25
  exports.of = of;
25
- function isMemoryOption(value) {
26
- return value == null || [128, 256, 512, 1024, 2048, 4096, 8192].includes(value);
27
- }
28
26
  async function resolveBackend(build, userEnvOpt, userEnvs) {
29
27
  const projectId = userEnvOpt.projectId;
30
28
  let paramValues = {};
@@ -34,7 +32,49 @@ async function resolveBackend(build, userEnvOpt, userEnvs) {
34
32
  return toBackend(build, paramValues);
35
33
  }
36
34
  exports.resolveBackend = resolveBackend;
35
+ class Resolver {
36
+ constructor(paramValues) {
37
+ this.paramValues = paramValues;
38
+ this.resolveInt = (i) => {
39
+ if (i === null) {
40
+ return i;
41
+ }
42
+ return params.resolveInt(i, this.paramValues);
43
+ };
44
+ this.resolveBoolean = (i) => {
45
+ if (i === null) {
46
+ return i;
47
+ }
48
+ return params.resolveBoolean(i, this.paramValues);
49
+ };
50
+ this.resolveString = (i) => {
51
+ if (i === null) {
52
+ return i;
53
+ }
54
+ return params.resolveString(i, this.paramValues);
55
+ };
56
+ }
57
+ resolveStrings(dest, src, ...keys) {
58
+ for (const key of keys) {
59
+ const orig = src[key];
60
+ if (typeof orig === "undefined") {
61
+ continue;
62
+ }
63
+ dest[key] = orig === null ? null : params.resolveString(orig, this.paramValues);
64
+ }
65
+ }
66
+ resolveInts(dest, src, ...keys) {
67
+ for (const key of keys) {
68
+ const orig = src[key];
69
+ if (typeof orig === "undefined") {
70
+ continue;
71
+ }
72
+ dest[key] = orig === null ? null : params.resolveInt(orig, this.paramValues);
73
+ }
74
+ }
75
+ }
37
76
  function toBackend(build, paramValues) {
77
+ const r = new Resolver(paramValues);
38
78
  const bkEndpoints = [];
39
79
  for (const endpointId of Object.keys(build.endpoints)) {
40
80
  const bdEndpoint = build.endpoints[endpointId];
@@ -43,39 +83,37 @@ function toBackend(build, paramValues) {
43
83
  regions = [api.functionsDefaultRegion];
44
84
  }
45
85
  for (const region of regions) {
46
- const trigger = discoverTrigger(bdEndpoint, paramValues);
86
+ const trigger = discoverTrigger(bdEndpoint, region, r);
47
87
  if (typeof bdEndpoint.platform === "undefined") {
48
88
  throw new error_1.FirebaseError("platform can't be undefined");
49
89
  }
50
- if (!isMemoryOption(bdEndpoint.availableMemoryMb)) {
90
+ if (bdEndpoint.availableMemoryMb != null &&
91
+ !backend.isValidMemoryOption(bdEndpoint.availableMemoryMb)) {
51
92
  throw new error_1.FirebaseError("available memory must be a supported value, if present");
52
93
  }
53
- let timeout;
54
- if (bdEndpoint.timeoutSeconds) {
55
- timeout = params.resolveInt(bdEndpoint.timeoutSeconds, paramValues);
56
- }
57
- else {
58
- timeout = 60;
59
- }
60
- const bkEndpoint = Object.assign({ id: endpointId, project: bdEndpoint.project, region: region, entryPoint: bdEndpoint.entryPoint, platform: bdEndpoint.platform, runtime: bdEndpoint.runtime, timeoutSeconds: timeout }, trigger);
61
- proto.renameIfPresent(bkEndpoint, bdEndpoint, "maxInstances", "maxInstances", (from) => {
62
- return params.resolveInt(from, paramValues);
94
+ const bkEndpoint = Object.assign({ id: endpointId, project: bdEndpoint.project, region: region, entryPoint: bdEndpoint.entryPoint, platform: bdEndpoint.platform, runtime: bdEndpoint.runtime }, trigger);
95
+ proto.copyIfPresent(bkEndpoint, bdEndpoint, "environmentVariables", "labels", "secretEnvironmentVariables", "serviceAccount");
96
+ proto.convertIfPresent(bkEndpoint, bdEndpoint, "ingressSettings", (from) => {
97
+ if (from !== null && !backend.AllIngressSettings.includes(from)) {
98
+ throw new error_1.FirebaseError(`Cannot set ingress settings to invalid value ${from}`);
99
+ }
100
+ return from;
63
101
  });
64
- proto.renameIfPresent(bkEndpoint, bdEndpoint, "minInstances", "minInstances", (from) => {
65
- return params.resolveInt(from, paramValues);
102
+ proto.convertIfPresent(bkEndpoint, bdEndpoint, "availableMemoryMb", (from) => {
103
+ const mem = r.resolveInt(from);
104
+ if (mem !== null && !backend.isValidMemoryOption(mem)) {
105
+ logger_1.logger.debug("Warning; setting memory to unexpected value", mem);
106
+ }
107
+ return mem;
66
108
  });
67
- proto.renameIfPresent(bkEndpoint, bdEndpoint, "concurrency", "concurrency", (from) => {
68
- return params.resolveInt(from, paramValues);
69
- });
70
- proto.copyIfPresent(bkEndpoint, bdEndpoint, "ingressSettings", "availableMemoryMb", "environmentVariables", "labels");
71
- proto.copyIfPresent(bkEndpoint, bdEndpoint, "secretEnvironmentVariables");
109
+ r.resolveInts(bkEndpoint, bdEndpoint, "timeoutSeconds", "maxInstances", "minInstances", "concurrency");
110
+ proto.convertIfPresent(bkEndpoint, bdEndpoint, "cpu", (0, functional_1.nullsafeVisitor)((cpu) => (cpu === "gcf_gen1" ? cpu : r.resolveInt(cpu))));
72
111
  if (bdEndpoint.vpc) {
73
112
  bkEndpoint.vpc = { connector: params.resolveString(bdEndpoint.vpc.connector, paramValues) };
74
113
  proto.copyIfPresent(bkEndpoint.vpc, bdEndpoint.vpc, "egressSettings");
75
114
  }
76
- proto.renameIfPresent(bkEndpoint, bdEndpoint, "serviceAccountEmail", "serviceAccount");
77
- if ("serviceAccountEmail" in bkEndpoint && !bdEndpoint.serviceAccount) {
78
- delete bkEndpoint.serviceAccountEmail;
115
+ else if (bdEndpoint.vpc === null) {
116
+ bkEndpoint.vpc = null;
79
117
  }
80
118
  bkEndpoints.push(bkEndpoint);
81
119
  }
@@ -85,101 +123,75 @@ function toBackend(build, paramValues) {
85
123
  return bkend;
86
124
  }
87
125
  exports.toBackend = toBackend;
88
- function discoverTrigger(endpoint, paramValues) {
89
- const resolveInt = (from) => params.resolveInt(from, paramValues);
90
- const resolveString = (from) => params.resolveString(from, paramValues);
91
- const resolveBoolean = (from) => params.resolveBoolean(from, paramValues);
92
- let trigger;
126
+ function discoverTrigger(endpoint, region, r) {
93
127
  if ("httpsTrigger" in endpoint) {
94
- const bkHttps = {};
95
- if (endpoint.httpsTrigger.invoker) {
96
- bkHttps.invoker = endpoint.httpsTrigger.invoker;
128
+ const httpsTrigger = {};
129
+ if (endpoint.httpsTrigger.invoker === null) {
130
+ httpsTrigger.invoker = null;
131
+ }
132
+ else if (typeof endpoint.httpsTrigger.invoker !== "undefined") {
133
+ httpsTrigger.invoker = endpoint.httpsTrigger.invoker.map(r.resolveString);
97
134
  }
98
- trigger = { httpsTrigger: bkHttps };
135
+ return { httpsTrigger };
99
136
  }
100
137
  else if ("callableTrigger" in endpoint) {
101
- trigger = { callableTrigger: {} };
138
+ return { callableTrigger: {} };
102
139
  }
103
140
  else if ("blockingTrigger" in endpoint) {
104
- trigger = { blockingTrigger: endpoint.blockingTrigger };
141
+ return { blockingTrigger: endpoint.blockingTrigger };
105
142
  }
106
143
  else if ("eventTrigger" in endpoint) {
107
- const bkEventFilters = {};
108
- for (const [key, value] of Object.entries(endpoint.eventTrigger.eventFilters)) {
109
- bkEventFilters[key] = params.resolveString(value, paramValues);
110
- }
111
- const bkEvent = {
144
+ const eventTrigger = {
112
145
  eventType: endpoint.eventTrigger.eventType,
113
- eventFilters: bkEventFilters,
114
- retry: resolveBoolean(endpoint.eventTrigger.retry || false),
146
+ retry: r.resolveBoolean(endpoint.eventTrigger.retry) || false,
115
147
  };
116
- if (endpoint.eventTrigger.eventFilterPathPatterns) {
117
- const bkEventFiltersPathPatterns = {};
118
- for (const [key, value] of Object.entries(endpoint.eventTrigger.eventFilterPathPatterns)) {
119
- bkEventFiltersPathPatterns[key] = params.resolveString(value, paramValues);
120
- }
121
- bkEvent.eventFilterPathPatterns = bkEventFiltersPathPatterns;
122
- }
123
- if (endpoint.eventTrigger.serviceAccount) {
124
- bkEvent.serviceAccountEmail = endpoint.eventTrigger.serviceAccount;
148
+ if (endpoint.eventTrigger.eventFilters) {
149
+ eventTrigger.eventFilters = (0, functional_1.mapObject)(endpoint.eventTrigger.eventFilters, r.resolveString);
125
150
  }
126
- if (endpoint.eventTrigger.region) {
127
- bkEvent.region = resolveString(endpoint.eventTrigger.region);
128
- }
129
- if (endpoint.eventTrigger.channel) {
130
- bkEvent.channel = endpoint.eventTrigger.channel;
151
+ if (endpoint.eventTrigger.eventFilterPathPatterns) {
152
+ eventTrigger.eventFilterPathPatterns = (0, functional_1.mapObject)(endpoint.eventTrigger.eventFilterPathPatterns, r.resolveString);
131
153
  }
132
- trigger = { eventTrigger: bkEvent };
154
+ r.resolveStrings(eventTrigger, endpoint.eventTrigger, "serviceAccount", "region", "channel");
155
+ return { eventTrigger };
133
156
  }
134
157
  else if ("scheduleTrigger" in endpoint) {
135
158
  const bkSchedule = {
136
- schedule: resolveString(endpoint.scheduleTrigger.schedule),
137
- timeZone: resolveString(endpoint.scheduleTrigger.timeZone),
159
+ schedule: r.resolveString(endpoint.scheduleTrigger.schedule),
160
+ timeZone: r.resolveString(endpoint.scheduleTrigger.timeZone),
138
161
  };
139
- const bkRetry = {};
140
- if (endpoint.scheduleTrigger.retryConfig.maxBackoffSeconds) {
141
- bkRetry.maxBackoffDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.maxBackoffSeconds));
162
+ if (endpoint.scheduleTrigger.retryConfig) {
163
+ const bkRetry = {};
164
+ r.resolveInts(bkRetry, endpoint.scheduleTrigger.retryConfig, "maxBackoffSeconds", "minBackoffSeconds", "maxRetrySeconds", "retryCount", "maxDoublings");
165
+ bkSchedule.retryConfig = bkRetry;
142
166
  }
143
- if (endpoint.scheduleTrigger.retryConfig.minBackoffSeconds) {
144
- bkRetry.minBackoffDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.minBackoffSeconds));
167
+ else if (endpoint.scheduleTrigger.retryConfig === null) {
168
+ bkSchedule.retryConfig = null;
145
169
  }
146
- if (endpoint.scheduleTrigger.retryConfig.maxRetrySeconds) {
147
- bkRetry.maxRetryDuration = proto.durationFromSeconds(resolveInt(endpoint.scheduleTrigger.retryConfig.maxRetrySeconds));
148
- }
149
- proto.copyIfPresent(bkRetry, endpoint.scheduleTrigger.retryConfig, "retryCount", "maxDoublings");
150
- bkSchedule.retryConfig = bkRetry;
151
- trigger = { scheduleTrigger: bkSchedule };
170
+ return { scheduleTrigger: bkSchedule };
152
171
  }
153
172
  else if ("taskQueueTrigger" in endpoint) {
154
- const bkTaskQueue = {};
173
+ const taskQueueTrigger = {};
155
174
  if (endpoint.taskQueueTrigger.rateLimits) {
156
- const bkRateLimits = {};
157
- proto.renameIfPresent(bkRateLimits, endpoint.taskQueueTrigger.rateLimits, "maxConcurrentDispatches", "maxConcurrentDispatches", resolveInt);
158
- proto.renameIfPresent(bkRateLimits, endpoint.taskQueueTrigger.rateLimits, "maxDispatchesPerSecond", "maxDispatchesPerSecond", resolveInt);
159
- bkTaskQueue.rateLimits = bkRateLimits;
175
+ taskQueueTrigger.rateLimits = {};
176
+ r.resolveInts(taskQueueTrigger.rateLimits, endpoint.taskQueueTrigger.rateLimits, "maxConcurrentDispatches", "maxDispatchesPerSecond");
177
+ }
178
+ else if (endpoint.taskQueueTrigger.rateLimits === null) {
179
+ taskQueueTrigger.rateLimits = null;
160
180
  }
161
181
  if (endpoint.taskQueueTrigger.retryConfig) {
162
- const bkRetryConfig = {};
163
- proto.renameIfPresent(bkRetryConfig, endpoint.taskQueueTrigger.retryConfig, "maxAttempts", "maxAttempts", resolveInt);
164
- proto.renameIfPresent(bkRetryConfig, endpoint.taskQueueTrigger.retryConfig, "maxBackoffSeconds", "maxBackoffSeconds", (from) => {
165
- return proto.durationFromSeconds(resolveInt(from));
166
- });
167
- proto.renameIfPresent(bkRetryConfig, endpoint.taskQueueTrigger.retryConfig, "minBackoffSeconds", "minBackoffSeconds", (from) => {
168
- return proto.durationFromSeconds(resolveInt(from));
169
- });
170
- proto.renameIfPresent(bkRetryConfig, endpoint.taskQueueTrigger.retryConfig, "maxRetrySeconds", "maxRetryDurationSeconds", (from) => {
171
- return proto.durationFromSeconds(resolveInt(from));
172
- });
173
- proto.renameIfPresent(bkRetryConfig, endpoint.taskQueueTrigger.retryConfig, "maxDoublings", "maxDoublings", resolveInt);
174
- bkTaskQueue.retryConfig = bkRetryConfig;
182
+ taskQueueTrigger.retryConfig = {};
183
+ r.resolveInts(taskQueueTrigger.retryConfig, endpoint.taskQueueTrigger.retryConfig, "maxAttempts", "maxBackoffSeconds", "minBackoffSeconds", "maxRetrySeconds", "maxDoublings");
184
+ }
185
+ else if (endpoint.taskQueueTrigger.retryConfig === null) {
186
+ taskQueueTrigger.retryConfig = null;
175
187
  }
176
188
  if (endpoint.taskQueueTrigger.invoker) {
177
- bkTaskQueue.invoker = endpoint.taskQueueTrigger.invoker.map((sa) => resolveString(sa));
189
+ taskQueueTrigger.invoker = endpoint.taskQueueTrigger.invoker.map(r.resolveString);
178
190
  }
179
- trigger = { taskQueueTrigger: bkTaskQueue };
180
- }
181
- else {
182
- (0, functional_1.assertExhaustive)(endpoint);
191
+ else if (endpoint.taskQueueTrigger.invoker === null) {
192
+ taskQueueTrigger.invoker = null;
193
+ }
194
+ return { taskQueueTrigger };
183
195
  }
184
- return trigger;
196
+ (0, functional_1.assertExhaustive)(endpoint);
185
197
  }
@@ -67,7 +67,7 @@ exports.cloudBuildEnabled = cloudBuildEnabled;
67
67
  async function secretsToServiceAccounts(b) {
68
68
  const secretsToSa = {};
69
69
  for (const e of backend.allEndpoints(b)) {
70
- const sa = e.serviceAccountEmail || (await module.exports.defaultServiceAccount(e));
70
+ const sa = e.serviceAccount || (await module.exports.defaultServiceAccount(e));
71
71
  for (const s of e.secretEnvironmentVariables || []) {
72
72
  const serviceAccounts = secretsToSa[s.secret] || new Set();
73
73
  serviceAccounts.add(sa);
@@ -104,7 +104,10 @@ function canSatisfyParam(param, value) {
104
104
  }
105
105
  async function resolveParams(params, projectId, userEnvs) {
106
106
  const paramValues = {};
107
- for (const param of params.filter((param) => userEnvs.hasOwnProperty(param.param))) {
107
+ const [provided, outstanding] = (0, functional_1.partition)(params, (param) => {
108
+ return {}.hasOwnProperty.call(userEnvs, param.param);
109
+ });
110
+ for (const param of provided) {
108
111
  if (!canSatisfyParam(param, userEnvs[param.param])) {
109
112
  throw new error_1.FirebaseError("Parameter " +
110
113
  param.param +
@@ -114,7 +117,7 @@ async function resolveParams(params, projectId, userEnvs) {
114
117
  }
115
118
  paramValues[param.param] = userEnvs[param.param];
116
119
  }
117
- for (const param of params.filter((param) => !userEnvs.hasOwnProperty(param.param))) {
120
+ for (const param of outstanding) {
118
121
  let paramDefault = param.default;
119
122
  if (paramDefault && isCEL(paramDefault)) {
120
123
  paramDefault = resolveDefaultCEL(param.type, paramDefault, paramValues);
@@ -172,13 +172,13 @@ function inferDetailsFromExisting(want, have, usedDotenv) {
172
172
  if (!usedDotenv) {
173
173
  wantE.environmentVariables = Object.assign(Object.assign({}, haveE.environmentVariables), wantE.environmentVariables);
174
174
  }
175
- if (!wantE.availableMemoryMb && haveE.availableMemoryMb) {
175
+ if (typeof wantE.availableMemoryMb === "undefined" && haveE.availableMemoryMb) {
176
176
  wantE.availableMemoryMb = haveE.availableMemoryMb;
177
177
  }
178
- if (!wantE.concurrency && haveE.concurrency) {
178
+ if (typeof wantE.concurrency === "undefined" && haveE.concurrency) {
179
179
  wantE.concurrency = haveE.concurrency;
180
180
  }
181
- if (!wantE.cpu && haveE.cpu) {
181
+ if (typeof wantE.cpu === "undefined" && haveE.cpu) {
182
182
  wantE.cpu = haveE.cpu;
183
183
  }
184
184
  wantE.securityLevel = haveE.securityLevel ? haveE.securityLevel : "SECURE_ALWAYS";
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.monthlyMinInstanceCost = exports.canCalculateMinInstanceCost = exports.V2_FREE_TIER = exports.V1_FREE_TIER = exports.V2_RATES = exports.V1_RATES = void 0;
4
+ const backend = require("./backend");
4
5
  const V1_REGION_TO_TIER = {
5
6
  "us-central1": 1,
6
7
  "us-east1": 1,
@@ -110,7 +111,7 @@ function canCalculateMinInstanceCost(endpoint) {
110
111
  return true;
111
112
  }
112
113
  if (endpoint.platform === "gcfv1") {
113
- if (!MB_TO_GHZ[endpoint.availableMemoryMb || 256]) {
114
+ if (!MB_TO_GHZ[endpoint.availableMemoryMb || backend.DEFAULT_MEMORY]) {
114
115
  return false;
115
116
  }
116
117
  if (!V1_REGION_TO_TIER[endpoint.region]) {
@@ -134,7 +135,7 @@ function monthlyMinInstanceCost(endpoints) {
134
135
  if (!endpoint.minInstances) {
135
136
  continue;
136
137
  }
137
- const ramMb = endpoint.availableMemoryMb || 256;
138
+ const ramMb = endpoint.availableMemoryMb || backend.DEFAULT_MEMORY;
138
139
  const ramGb = ramMb / 1024;
139
140
  if (endpoint.platform === "gcfv1") {
140
141
  const cpu = MB_TO_GHZ[ramMb];
@@ -122,7 +122,7 @@ async function promptForMinInstances(options, want, have) {
122
122
  .sort(backend.compareFunctions)
123
123
  .map((fn) => {
124
124
  return (`\t${(0, functionsDeployHelper_1.getFunctionLabel)(fn)}: ${fn.minInstances} instances, ` +
125
- backend.memoryOptionDisplayName(fn.availableMemoryMb || 256) +
125
+ backend.memoryOptionDisplayName(fn.availableMemoryMb || backend.DEFAULT_MEMORY) +
126
126
  " of memory each");
127
127
  })
128
128
  .join("\n");
@@ -301,10 +301,10 @@ class Fabricator {
301
301
  endpoint.uri = (_b = resultFunction === null || resultFunction === void 0 ? void 0 : resultFunction.httpsTrigger) === null || _b === void 0 ? void 0 : _b.url;
302
302
  let invoker;
303
303
  if (backend.isHttpsTriggered(endpoint)) {
304
- invoker = endpoint.httpsTrigger.invoker;
304
+ invoker = endpoint.httpsTrigger.invoker === null ? ["public"] : endpoint.httpsTrigger.invoker;
305
305
  }
306
306
  else if (backend.isTaskQueueTriggered(endpoint)) {
307
- invoker = endpoint.taskQueueTrigger.invoker;
307
+ invoker = endpoint.taskQueueTrigger.invoker === null ? [] : endpoint.taskQueueTrigger.invoker;
308
308
  }
309
309
  else if (backend.isBlockingTriggered(endpoint) &&
310
310
  v1_1.AUTH_BLOCKING_EVENTS.includes(endpoint.blockingTrigger.eventType)) {
@@ -337,10 +337,10 @@ class Fabricator {
337
337
  const serviceName = resultFunction.serviceConfig.service;
338
338
  let invoker;
339
339
  if (backend.isHttpsTriggered(endpoint)) {
340
- invoker = endpoint.httpsTrigger.invoker;
340
+ invoker = endpoint.httpsTrigger.invoker === null ? ["public"] : endpoint.httpsTrigger.invoker;
341
341
  }
342
342
  else if (backend.isTaskQueueTriggered(endpoint)) {
343
- invoker = endpoint.taskQueueTrigger.invoker;
343
+ invoker = endpoint.taskQueueTrigger.invoker === null ? [] : endpoint.taskQueueTrigger.invoker;
344
344
  }
345
345
  else if (backend.isBlockingTriggered(endpoint) &&
346
346
  v1_1.AUTH_BLOCKING_EVENTS.includes(endpoint.blockingTrigger.eventType)) {
@@ -477,12 +477,13 @@ class Fabricator {
477
477
  .catch(rethrowAs(endpoint, "register blocking trigger"));
478
478
  }
479
479
  async deleteScheduleV1(endpoint) {
480
- const job = scheduler.jobFromEndpoint(endpoint, this.appEngineLocation);
480
+ const jobName = scheduler.jobNameForEndpoint(endpoint, this.appEngineLocation);
481
481
  await this.executor
482
- .run(() => scheduler.deleteJob(job.name))
482
+ .run(() => scheduler.deleteJob(jobName))
483
483
  .catch(rethrowAs(endpoint, "delete schedule"));
484
+ const topicName = scheduler.topicNameForEndpoint(endpoint);
484
485
  await this.executor
485
- .run(() => pubsub.deleteTopic(job.pubsubTarget.topicName))
486
+ .run(() => pubsub.deleteTopic(topicName))
486
487
  .catch(rethrowAs(endpoint, "delete topic"));
487
488
  }
488
489
  deleteScheduleV2(endpoint) {
@@ -23,35 +23,46 @@ function assertKeyTypes(prefix, yaml, schema) {
23
23
  if (!schema[key] || schema[key] === "omit") {
24
24
  throw new error_1.FirebaseError(`Unexpected key ${fullKey}. You may need to install a newer version of the Firebase CLI.`);
25
25
  }
26
- const schemaType = schema[key];
26
+ let schemaType = schema[key];
27
27
  if (typeof schemaType === "function") {
28
28
  if (!schemaType(value)) {
29
- throw new error_1.FirebaseError(`${Array.isArray(value) ? "array" : typeof value} ${fullKey} failed validation`);
29
+ const friendlyName = value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
30
+ throw new error_1.FirebaseError(`${friendlyName} ${fullKey} failed validation`);
30
31
  }
32
+ continue;
31
33
  }
32
- else if (schemaType === "string") {
34
+ if (value === null) {
35
+ if (schemaType.endsWith("?")) {
36
+ continue;
37
+ }
38
+ throw new error_1.FirebaseError(`Expected ${fullKey}} to be type ${schemaType}; was null`);
39
+ }
40
+ if (schemaType.endsWith("?")) {
41
+ schemaType = schemaType.slice(0, schemaType.length - 1);
42
+ }
43
+ if (schemaType === "string") {
33
44
  if (typeof value !== "string") {
34
- throw new error_1.FirebaseError(`Expected ${fullKey} to be string; was ${typeof value}`);
45
+ throw new error_1.FirebaseError(`Expected ${fullKey} to be type string; was ${typeof value}`);
35
46
  }
36
47
  }
37
48
  else if (schemaType === "number") {
38
49
  if (typeof value !== "number") {
39
- throw new error_1.FirebaseError(`Expected ${fullKey} to be a number; was ${typeof value}`);
50
+ throw new error_1.FirebaseError(`Expected ${fullKey} to be type number; was ${typeof value}`);
40
51
  }
41
52
  }
42
53
  else if (schemaType === "boolean") {
43
54
  if (typeof value !== "boolean") {
44
- throw new error_1.FirebaseError(`Expected ${fullKey} to be a boolean; was ${typeof value}`);
55
+ throw new error_1.FirebaseError(`Expected ${fullKey} to be type boolean; was ${typeof value}`);
45
56
  }
46
57
  }
47
58
  else if (schemaType === "array") {
48
59
  if (!Array.isArray(value)) {
49
- throw new error_1.FirebaseError(`Expected ${fullKey} to be an array; was ${typeof value}`);
60
+ throw new error_1.FirebaseError(`Expected ${fullKey} to be type array; was ${typeof value}`);
50
61
  }
51
62
  }
52
63
  else if (schemaType === "object") {
53
64
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
54
- throw new error_1.FirebaseError(`Expected ${fullKey} to be an object; was ${typeof value}`);
65
+ throw new error_1.FirebaseError(`Expected ${fullKey} to be type object; was ${typeof value}`);
55
66
  }
56
67
  }
57
68
  else {