firebase-tools-with-isolate 15.13.0 → 15.15.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/README.md +17 -17
- package/lib/api.js +2 -6
- package/lib/apphosting/constants.js +1 -1
- package/lib/command.js +7 -0
- package/lib/commands/dataconnect-compile.js +6 -6
- package/lib/commands/dataconnect-execute.js +1 -1
- package/lib/commands/dataconnect-sdk-generate.js +3 -3
- package/lib/commands/dataconnect-services-list.js +1 -1
- package/lib/commands/dataconnect-sql-diff.js +3 -3
- package/lib/commands/dataconnect-sql-grant.js +2 -2
- package/lib/commands/dataconnect-sql-migrate.js +4 -4
- package/lib/commands/dataconnect-sql-setup.js +2 -2
- package/lib/commands/dataconnect-sql-shell.js +4 -4
- package/lib/commands/ext-dev-usage.js +0 -2
- package/lib/commands/init.js +3 -3
- package/lib/commands/open.js +1 -1
- package/lib/commands/setup-emulators-dataconnect.js +1 -1
- package/lib/dataconnect/freeTrial.js +2 -2
- package/lib/dataconnect/load.js +2 -2
- package/lib/dataconnect/provisionCloudSql.js +3 -3
- package/lib/dataconnect/schemaMigration.js +11 -11
- package/lib/dataconnect/webhook.js +1 -1
- package/lib/deploy/functions/backend.js +1 -1
- package/lib/deploy/functions/build.js +3 -3
- package/lib/deploy/functions/deploy.js +5 -2
- package/lib/deploy/functions/prepare.js +59 -1
- package/lib/deploy/functions/prepareFunctionsUpload.js +25 -9
- package/lib/deploy/functions/release/fabricator.js +59 -46
- package/lib/deploy/functions/release/index.js +5 -0
- package/lib/deploy/functions/release/planner.js +1 -1
- package/lib/deploy/functions/runtimes/dart/index.js +3 -1
- package/lib/deploy/functions/runtimes/dart/triggerSupport.js +123 -0
- package/lib/deploy/functions/runtimes/index.js +1 -4
- package/lib/deploy/functions/runtimes/supported/index.js +0 -4
- package/lib/deploy/functions/services/ailogic.js +17 -5
- package/lib/deploy/functions/services/dataconnect.js +1 -1
- package/lib/deploy/functions/services/index.js +2 -2
- package/lib/deploy/functions/validate.js +7 -1
- package/lib/emulator/constants.js +1 -1
- package/lib/emulator/controller.js +13 -2
- package/lib/emulator/dataconnectEmulator.js +14 -14
- package/lib/emulator/dataconnectToolkitController.js +2 -2
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/downloadableEmulators.js +1 -0
- package/lib/emulator/extensionsEmulator.js +1 -2
- package/lib/emulator/functionsEmulator.js +20 -6
- package/lib/emulator/functionsRuntimeWorker.js +1 -1
- package/lib/emulator/hub.js +3 -3
- package/lib/emulator/hubExport.js +2 -2
- package/lib/emulator/initEmulators.js +1 -1
- package/lib/experiments.js +11 -6
- package/lib/frameworks/next/constants.js +2 -1
- package/lib/frameworks/next/index.js +3 -2
- package/lib/frameworks/next/utils.js +50 -12
- package/lib/functions/events/v2.js +10 -1
- package/lib/gcp/ailogic.js +13 -9
- package/lib/gcp/runv2.js +9 -2
- package/lib/init/features/dataconnect/index.js +7 -7
- package/lib/init/features/dataconnect/resolver.js +2 -2
- package/lib/init/features/dataconnect/sdk.js +8 -8
- package/lib/init/features/functions/index.js +1 -1
- package/lib/mcp/prompts/dataconnect/schema.js +6 -6
- package/lib/mcp/resources/guides/init_data_connect.js +2 -2
- package/lib/mcp/resources/guides/init_firestore.js +1 -1
- package/lib/mcp/tools/core/init.js +9 -9
- package/lib/mcp/tools/dataconnect/compile.js +5 -5
- package/lib/mcp/tools/dataconnect/execute.js +6 -6
- package/lib/mcp/tools/dataconnect/list_services.js +7 -7
- package/lib/mcp/util/dataconnect/content.js +19 -19
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +19 -6
- package/schema/firebase-config.json +3 -0
- package/templates/init/functions/dart/pubspec.yaml +6 -7
- package/templates/init/functions/dart/server.dart +3 -1
- package/lib/shortenUrl.js +0 -28
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EVENTARC_SOURCE_ENV = void 0;
|
|
4
4
|
exports.prepare = prepare;
|
|
5
|
+
exports.matchRegionsForExisting = matchRegionsForExisting;
|
|
6
|
+
exports.resolveDefaultRegions = resolveDefaultRegions;
|
|
5
7
|
exports.inferDetailsFromExisting = inferDetailsFromExisting;
|
|
6
8
|
exports.updateEndpointTargetedStatus = updateEndpointTargetedStatus;
|
|
7
9
|
exports.inferBlockingDetails = inferBlockingDetails;
|
|
@@ -24,6 +26,7 @@ const ensure = require("./ensure");
|
|
|
24
26
|
const api_1 = require("../../api");
|
|
25
27
|
const functionsDeployHelper_1 = require("./functionsDeployHelper");
|
|
26
28
|
const utils_1 = require("../../utils");
|
|
29
|
+
const triggerSupport_1 = require("./runtimes/dart/triggerSupport");
|
|
27
30
|
const prepareFunctionsUpload_1 = require("./prepareFunctionsUpload");
|
|
28
31
|
const prompts_1 = require("./prompts");
|
|
29
32
|
const projectUtils_1 = require("../../projectUtils");
|
|
@@ -159,6 +162,9 @@ async function prepare(context, options, payload) {
|
|
|
159
162
|
(0, utils_1.logLabeledBullet)("functions", `preparing ${clc.bold(sourceDirName)} directory for uploading...`);
|
|
160
163
|
}
|
|
161
164
|
if (localCfg.isolate === true) {
|
|
165
|
+
(0, utils_1.logLabeledWarning)("functions", "The 'isolate' flag in firebase.json is deprecated and no longer needed — monorepo detection is now automatic. Please remove 'isolate' from your functions config.");
|
|
166
|
+
}
|
|
167
|
+
if ((0, prepareFunctionsUpload_1.isMonorepoSource)(sourceDir)) {
|
|
162
168
|
sourceDir = await (0, prepareFunctionsUpload_1.runIsolate)(sourceDirName);
|
|
163
169
|
}
|
|
164
170
|
if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv2" || e.platform === "run")) {
|
|
@@ -172,7 +178,9 @@ async function prepare(context, options, payload) {
|
|
|
172
178
|
const exportType = backend.someEndpoint(wantBackend, (e) => e.platform === "run")
|
|
173
179
|
? "tar.gz"
|
|
174
180
|
: "zip";
|
|
175
|
-
const
|
|
181
|
+
const isDart = supported.runtimeIsLanguage(wantBuilds[codebase].runtime, "dart");
|
|
182
|
+
const executablePaths = isDart ? ["bin/server"] : [];
|
|
183
|
+
const packagedSource = await (0, prepareFunctionsUpload_1.prepareFunctionsUpload)(options.config.projectDir, sourceDir, localCfg, [...schPathSet], undefined, { exportType, executablePaths });
|
|
176
184
|
source.functionsSourceV2 = packagedSource?.pathToSource;
|
|
177
185
|
source.functionsSourceV2Hash = packagedSource?.hash;
|
|
178
186
|
}
|
|
@@ -191,6 +199,7 @@ async function prepare(context, options, payload) {
|
|
|
191
199
|
payload.functions[codebase] = { wantBackend, haveBackend };
|
|
192
200
|
}
|
|
193
201
|
for (const [codebase, { wantBackend, haveBackend }] of Object.entries(payload.functions)) {
|
|
202
|
+
await resolveDefaultRegions(wantBackend, haveBackend);
|
|
194
203
|
inferDetailsFromExisting(wantBackend, haveBackend, codebaseUsesEnvs.includes(codebase));
|
|
195
204
|
await (0, triggerRegionHelper_1.ensureTriggerRegions)(wantBackend);
|
|
196
205
|
resolveCpuAndConcurrency(wantBackend);
|
|
@@ -201,6 +210,7 @@ async function prepare(context, options, payload) {
|
|
|
201
210
|
const haveBackend = backend.merge(...Object.values(haveBackends));
|
|
202
211
|
await ensureAllRequiredAPIsEnabled(projectNumber, wantBackend);
|
|
203
212
|
await warnIfNewGenkitFunctionIsMissingSecrets(wantBackend, haveBackend, options);
|
|
213
|
+
warnIfDartBackendHasUnsupportedTriggers(wantBackend);
|
|
204
214
|
const matchingBackend = backend.matchingBackend(wantBackend, (endpoint) => {
|
|
205
215
|
return (0, functionsDeployHelper_1.endpointMatchesAnyFilter)(endpoint, context.filters);
|
|
206
216
|
});
|
|
@@ -215,6 +225,41 @@ async function prepare(context, options, payload) {
|
|
|
215
225
|
validate.checkFiltersIntegrity(wantBackends, context.filters);
|
|
216
226
|
(0, applyHash_1.applyBackendHashToBackends)(wantBackends, context);
|
|
217
227
|
}
|
|
228
|
+
function moveEndpointToRegion(backend, endpoint, region) {
|
|
229
|
+
endpoint.region = region;
|
|
230
|
+
backend.endpoints[region] = backend.endpoints[region] || {};
|
|
231
|
+
backend.endpoints[region][endpoint.id] = endpoint;
|
|
232
|
+
delete backend.endpoints[build.REGION_TBD][endpoint.id];
|
|
233
|
+
if (Object.keys(backend.endpoints[build.REGION_TBD]).length === 0) {
|
|
234
|
+
delete backend.endpoints[build.REGION_TBD];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function matchRegionsForExisting(want, have) {
|
|
238
|
+
for (const [id, wantE] of Object.entries(want.endpoints[build.REGION_TBD] || {})) {
|
|
239
|
+
let matching;
|
|
240
|
+
for (const region of Object.keys(have.endpoints)) {
|
|
241
|
+
if (region === build.REGION_TBD) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (have.endpoints[region][id]) {
|
|
245
|
+
if (matching) {
|
|
246
|
+
throw new error_1.FirebaseError(`Cannot resolve default region for function ${id}. It exists in multiple regions. The region must be specified to continue.`);
|
|
247
|
+
}
|
|
248
|
+
matching = have.endpoints[region][id];
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (!matching) {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
moveEndpointToRegion(want, wantE, matching.region);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
async function resolveDefaultRegions(want, have) {
|
|
258
|
+
matchRegionsForExisting(want, have);
|
|
259
|
+
for (const endpoint of Object.values(want.endpoints[build.REGION_TBD] || {})) {
|
|
260
|
+
moveEndpointToRegion(want, endpoint, "us-central1");
|
|
261
|
+
}
|
|
262
|
+
}
|
|
218
263
|
function inferDetailsFromExisting(want, have, usedDotenv) {
|
|
219
264
|
for (const wantE of backend.allEndpoints(want)) {
|
|
220
265
|
const haveE = have.endpoints[wantE.region]?.[wantE.id];
|
|
@@ -348,6 +393,19 @@ async function loadCodebases(config, options, firebaseConfig, runtimeConfig, fil
|
|
|
348
393
|
}
|
|
349
394
|
return wantBuilds;
|
|
350
395
|
}
|
|
396
|
+
function warnIfDartBackendHasUnsupportedTriggers(want) {
|
|
397
|
+
const dartEndpoints = backend.allEndpoints(want).filter(triggerSupport_1.isDartEndpoint);
|
|
398
|
+
if (dartEndpoints.length === 0) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
const { emulatorOnly, experimental } = (0, triggerSupport_1.classifyNonProductionEndpoints)(dartEndpoints);
|
|
402
|
+
const unsupported = [...emulatorOnly, ...experimental];
|
|
403
|
+
if (unsupported.length > 0) {
|
|
404
|
+
(0, utils_1.logLabeledWarning)("functions", `The following Dart functions use triggers that are not yet supported for production deployment: ${unsupported.map((ep) => ep.id).join(", ")}. ` +
|
|
405
|
+
"They will be deployed but may not work as expected. " +
|
|
406
|
+
"See https://github.com/firebase/firebase-functions-dart for current trigger support.");
|
|
407
|
+
}
|
|
408
|
+
}
|
|
351
409
|
async function warnIfNewGenkitFunctionIsMissingSecrets(have, want, options) {
|
|
352
410
|
if (options.force) {
|
|
353
411
|
return;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFunctionsConfig = getFunctionsConfig;
|
|
4
|
+
exports.addFilesToArchive = addFilesToArchive;
|
|
4
5
|
exports.prepareFunctionsUpload = prepareFunctionsUpload;
|
|
6
|
+
exports.isMonorepoSource = isMonorepoSource;
|
|
5
7
|
exports.runIsolate = runIsolate;
|
|
6
8
|
exports.convertToSortedKeyValueArray = convertToSortedKeyValueArray;
|
|
7
9
|
const archiver = require("archiver");
|
|
@@ -11,6 +13,7 @@ const fs = require("fs");
|
|
|
11
13
|
const path = require("path");
|
|
12
14
|
const tmp = require("tmp");
|
|
13
15
|
const crypto = require("crypto");
|
|
16
|
+
const detect_monorepo_1 = require("detect-monorepo");
|
|
14
17
|
const dynamicImport_1 = require("../../dynamicImport");
|
|
15
18
|
const error_1 = require("../../error");
|
|
16
19
|
const logger_1 = require("../../logger");
|
|
@@ -47,6 +50,24 @@ async function pipeAsync(from, to) {
|
|
|
47
50
|
to.on("error", reject);
|
|
48
51
|
});
|
|
49
52
|
}
|
|
53
|
+
async function addFilesToArchive(archive, files, sourceDir, executablePaths) {
|
|
54
|
+
const hashes = [];
|
|
55
|
+
for (const file of files) {
|
|
56
|
+
const name = path.relative(sourceDir, file.name);
|
|
57
|
+
const normalizedName = name.split(path.sep).join("/");
|
|
58
|
+
const fileHash = await (0, hash_1.getSourceHash)(file.name);
|
|
59
|
+
hashes.push(fileHash);
|
|
60
|
+
let mode = file.mode;
|
|
61
|
+
if (executablePaths?.includes(normalizedName)) {
|
|
62
|
+
mode = 0o755;
|
|
63
|
+
}
|
|
64
|
+
archive.file(file.name, {
|
|
65
|
+
name: normalizedName,
|
|
66
|
+
mode,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return hashes;
|
|
70
|
+
}
|
|
50
71
|
async function packageSource(projectDir, sourceDir, config, additionalSources, runtimeConfig, options) {
|
|
51
72
|
const exportType = options?.exportType || "zip";
|
|
52
73
|
const postfix = `.${exportType}`;
|
|
@@ -62,15 +83,7 @@ async function packageSource(projectDir, sourceDir, config, additionalSources, r
|
|
|
62
83
|
ignore.push("firebase-debug.log", "firebase-debug.*.log", CONFIG_DEST_FILE);
|
|
63
84
|
try {
|
|
64
85
|
const files = await fsAsync.readdirRecursive({ path: sourceDir, ignore: ignore });
|
|
65
|
-
|
|
66
|
-
const name = path.relative(sourceDir, file.name);
|
|
67
|
-
const fileHash = await (0, hash_1.getSourceHash)(file.name);
|
|
68
|
-
hashes.push(fileHash);
|
|
69
|
-
archive.file(file.name, {
|
|
70
|
-
name,
|
|
71
|
-
mode: file.mode,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
86
|
+
hashes.push(...(await addFilesToArchive(archive, files, sourceDir, options?.executablePaths)));
|
|
74
87
|
for (const name of additionalSources) {
|
|
75
88
|
const absPath = utils.resolveWithin(projectDir, name);
|
|
76
89
|
if (!fs.existsSync(absPath)) {
|
|
@@ -120,6 +133,9 @@ async function packageSource(projectDir, sourceDir, config, additionalSources, r
|
|
|
120
133
|
async function prepareFunctionsUpload(projectDir, sourceDir, config, additionalSources, runtimeConfig, options) {
|
|
121
134
|
return packageSource(projectDir, sourceDir, config, additionalSources, runtimeConfig, options);
|
|
122
135
|
}
|
|
136
|
+
function isMonorepoSource(absoluteSourceDir) {
|
|
137
|
+
return (0, detect_monorepo_1.detectMonorepo)(absoluteSourceDir) !== null;
|
|
138
|
+
}
|
|
123
139
|
async function runIsolate(sourceDirName) {
|
|
124
140
|
try {
|
|
125
141
|
utils.logLabeledBullet("isolate", "Isolating the source");
|
|
@@ -68,68 +68,81 @@ class Fabricator {
|
|
|
68
68
|
totalTime: 0,
|
|
69
69
|
results: [],
|
|
70
70
|
};
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
const changesets = Object.values(plan);
|
|
72
|
+
const scraperV1 = new sourceTokenScraper_1.SourceTokenScraper();
|
|
73
|
+
const scraperV2 = new sourceTokenScraper_1.SourceTokenScraper();
|
|
74
|
+
const createAndUpdatePromises = changesets.map((changes) => {
|
|
75
|
+
return this.applyUpserts(changes, scraperV1, scraperV2);
|
|
75
76
|
});
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
logger_1.logger.debug("Fabricator.
|
|
82
|
-
|
|
77
|
+
const createAndUpdateResultsArray = await Promise.allSettled(createAndUpdatePromises);
|
|
78
|
+
summary.results = createAndUpdateResultsArray.reduce((acc, r) => {
|
|
79
|
+
if (r.status === "fulfilled") {
|
|
80
|
+
return [...acc, ...r.value];
|
|
81
|
+
}
|
|
82
|
+
logger_1.logger.debug("Fabricator.applyUpserts returned an unhandled exception.", JSON.stringify(r.reason, null, 2));
|
|
83
|
+
return acc;
|
|
84
|
+
}, []);
|
|
85
|
+
const hasFailures = summary.results.some((r) => r.error);
|
|
86
|
+
if (hasFailures) {
|
|
87
|
+
utils.logLabeledWarning("functions", "Deploys failed. Skipping deletes.");
|
|
88
|
+
summary.results = changesets.reduce((accum, changes) => {
|
|
89
|
+
const currentAborts = changes.endpointsToDelete.map((endpoint) => ({
|
|
90
|
+
endpoint,
|
|
91
|
+
durationMs: 0,
|
|
92
|
+
error: new reporter.AbortedDeploymentError(endpoint),
|
|
93
|
+
}));
|
|
94
|
+
return [...accum, ...currentAborts];
|
|
95
|
+
}, summary.results);
|
|
96
|
+
summary.totalTime = timer.stop();
|
|
97
|
+
return summary;
|
|
98
|
+
}
|
|
99
|
+
const deleteResultsArray = await Promise.allSettled(changesets.map((changes) => this.applyDeletes(changes)));
|
|
100
|
+
const deleteResults = deleteResultsArray.reduce((acc, r) => {
|
|
101
|
+
if (r.status === "fulfilled") {
|
|
102
|
+
return [...acc, ...r.value];
|
|
103
|
+
}
|
|
104
|
+
logger_1.logger.debug("Fabricator.applyDeletes returned an unhandled exception. This should never happen", JSON.stringify(r.reason, null, 2));
|
|
105
|
+
return acc;
|
|
106
|
+
}, []);
|
|
107
|
+
summary.results.push(...deleteResults);
|
|
83
108
|
summary.totalTime = timer.stop();
|
|
84
109
|
return summary;
|
|
85
110
|
}
|
|
86
|
-
async
|
|
87
|
-
const
|
|
88
|
-
const handle = async (op, endpoint, fn) => {
|
|
89
|
-
const timer = new timer_1.Timer();
|
|
90
|
-
const result = { endpoint };
|
|
91
|
-
try {
|
|
92
|
-
await fn();
|
|
93
|
-
this.logOpSuccess(op, endpoint);
|
|
94
|
-
}
|
|
95
|
-
catch (err) {
|
|
96
|
-
result.error = err;
|
|
97
|
-
}
|
|
98
|
-
result.durationMs = timer.stop();
|
|
99
|
-
deployResults.push(result);
|
|
100
|
-
};
|
|
101
|
-
const upserts = [];
|
|
102
|
-
const scraperV1 = new sourceTokenScraper_1.SourceTokenScraper();
|
|
103
|
-
const scraperV2 = new sourceTokenScraper_1.SourceTokenScraper();
|
|
111
|
+
async applyUpserts(changes, scraperV1, scraperV2) {
|
|
112
|
+
const ops = [];
|
|
104
113
|
for (const endpoint of changes.endpointsToCreate) {
|
|
105
114
|
this.logOpStart("creating", endpoint);
|
|
106
|
-
|
|
115
|
+
ops.push(this.wrapOperation("create", endpoint, () => this.createEndpoint(endpoint, scraperV1, scraperV2)));
|
|
107
116
|
}
|
|
108
117
|
for (const endpoint of changes.endpointsToSkip) {
|
|
109
118
|
utils.logSuccess(this.getLogSuccessMessage("skip", endpoint));
|
|
110
119
|
}
|
|
111
120
|
for (const update of changes.endpointsToUpdate) {
|
|
112
121
|
this.logOpStart("updating", update.endpoint);
|
|
113
|
-
|
|
122
|
+
ops.push(this.wrapOperation("update", update.endpoint, () => this.updateEndpoint(update, scraperV1, scraperV2)));
|
|
114
123
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
endpoint,
|
|
120
|
-
durationMs: 0,
|
|
121
|
-
error: new reporter.AbortedDeploymentError(endpoint),
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
return deployResults;
|
|
125
|
-
}
|
|
126
|
-
const deletes = [];
|
|
124
|
+
return Promise.all(ops);
|
|
125
|
+
}
|
|
126
|
+
async applyDeletes(changes) {
|
|
127
|
+
const ops = [];
|
|
127
128
|
for (const endpoint of changes.endpointsToDelete) {
|
|
128
129
|
this.logOpStart("deleting", endpoint);
|
|
129
|
-
|
|
130
|
+
ops.push(this.wrapOperation("delete", endpoint, () => this.deleteEndpoint(endpoint)));
|
|
131
|
+
}
|
|
132
|
+
return Promise.all(ops);
|
|
133
|
+
}
|
|
134
|
+
async wrapOperation(op, endpoint, fn) {
|
|
135
|
+
const timer = new timer_1.Timer();
|
|
136
|
+
const result = { endpoint };
|
|
137
|
+
try {
|
|
138
|
+
await fn();
|
|
139
|
+
this.logOpSuccess(op, endpoint);
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
result.error = err;
|
|
130
143
|
}
|
|
131
|
-
|
|
132
|
-
return
|
|
144
|
+
result.durationMs = timer.stop();
|
|
145
|
+
return result;
|
|
133
146
|
}
|
|
134
147
|
async createEndpoint(endpoint, scraperV1, scraperV2) {
|
|
135
148
|
endpoint.labels = { ...endpoint.labels, ...deploymentTool.labels() };
|
|
@@ -18,6 +18,7 @@ const error_1 = require("../../../error");
|
|
|
18
18
|
const getProjectNumber_1 = require("../../../getProjectNumber");
|
|
19
19
|
const extensions_1 = require("../../extensions");
|
|
20
20
|
const artifacts = require("../../../functions/artifacts");
|
|
21
|
+
const supported_1 = require("../runtimes/supported");
|
|
21
22
|
async function release(context, options, payload) {
|
|
22
23
|
if (context.extensions && payload.extensions) {
|
|
23
24
|
await (0, extensions_1.release)(context.extensions, options, payload.extensions);
|
|
@@ -88,6 +89,10 @@ async function release(context, options, payload) {
|
|
|
88
89
|
reporter.printErrors(summary);
|
|
89
90
|
const wantBackend = backend.merge(...Object.values(payload.functions).map((p) => p.wantBackend));
|
|
90
91
|
printTriggerUrls(wantBackend, projectNumber);
|
|
92
|
+
if (backend.someEndpoint(wantBackend, (endpoint) => (0, supported_1.runtimeIsLanguage)(endpoint.runtime, "dart"))) {
|
|
93
|
+
utils.logLabeledBullet("functions", "Dart functions may not yet be visible in the Firebase Console. " +
|
|
94
|
+
`View them in the Cloud Console at https://console.cloud.google.com/run/services?project=${context.projectId}`);
|
|
95
|
+
}
|
|
91
96
|
await setupArtifactCleanupPolicies(options, options.projectId, Object.keys(wantBackend.endpoints));
|
|
92
97
|
const allErrors = summary.results.filter((r) => r.error).map((r) => r.error);
|
|
93
98
|
if (allErrors.length) {
|
|
@@ -178,7 +178,7 @@ function checkForIllegalUpdate(want, have) {
|
|
|
178
178
|
return "an HTTPS";
|
|
179
179
|
}
|
|
180
180
|
else if (backend.isDataConnectGraphqlTriggered(e)) {
|
|
181
|
-
return "a
|
|
181
|
+
return "a SQL Connect HTTPS";
|
|
182
182
|
}
|
|
183
183
|
else if (backend.isCallableTriggered(e)) {
|
|
184
184
|
return "a callable";
|
|
@@ -13,12 +13,14 @@ const error_1 = require("../../../../error");
|
|
|
13
13
|
const utils_1 = require("../../../../utils");
|
|
14
14
|
const registry_1 = require("../../../../emulator/registry");
|
|
15
15
|
const types_1 = require("../../../../emulator/types");
|
|
16
|
+
const experiments = require("../../../../experiments");
|
|
16
17
|
async function tryCreateDelegate(context) {
|
|
17
18
|
const pubspecYamlPath = path.join(context.sourceDir, "pubspec.yaml");
|
|
18
19
|
if (!(await (0, util_1.promisify)(fs.exists)(pubspecYamlPath))) {
|
|
19
20
|
logger_1.logger.debug("Customer code is not Dart code.");
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
23
|
+
experiments.assertEnabled("dartfunctions", "use Dart functions");
|
|
22
24
|
const runtime = context.runtime ?? supported.latest("dart");
|
|
23
25
|
if (!supported.isRuntime(runtime)) {
|
|
24
26
|
throw new error_1.FirebaseError(`Runtime ${runtime} is not a valid Dart runtime`);
|
|
@@ -28,7 +30,7 @@ async function tryCreateDelegate(context) {
|
|
|
28
30
|
}
|
|
29
31
|
return Promise.resolve(new Delegate(context.projectId, context.sourceDir, runtime));
|
|
30
32
|
}
|
|
31
|
-
const MIN_DART_SDK_VERSION = "3.
|
|
33
|
+
const MIN_DART_SDK_VERSION = "3.9.0";
|
|
32
34
|
exports.DART_ENTRY_POINT = "bin/server.dart";
|
|
33
35
|
class Delegate {
|
|
34
36
|
constructor(projectId, sourceDir, runtime) {
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.endpointSupportLevel = endpointSupportLevel;
|
|
4
|
+
exports.isDartEndpoint = isDartEndpoint;
|
|
5
|
+
exports.classifyNonProductionEndpoints = classifyNonProductionEndpoints;
|
|
6
|
+
exports.triggerTypeLabel = triggerTypeLabel;
|
|
7
|
+
exports.groupByTriggerLabel = groupByTriggerLabel;
|
|
8
|
+
const backend = require("../../backend");
|
|
9
|
+
const supported = require("../supported");
|
|
10
|
+
const constants_1 = require("../../../../emulator/constants");
|
|
11
|
+
const EMULATOR_ONLY_SERVICES = new Set([
|
|
12
|
+
constants_1.Constants.SERVICE_FIRESTORE,
|
|
13
|
+
constants_1.Constants.SERVICE_REALTIME_DATABASE,
|
|
14
|
+
constants_1.Constants.SERVICE_STORAGE,
|
|
15
|
+
]);
|
|
16
|
+
const EXPERIMENTAL_SERVICES = new Set([
|
|
17
|
+
constants_1.Constants.SERVICE_PUBSUB,
|
|
18
|
+
constants_1.Constants.SERVICE_EVENTARC,
|
|
19
|
+
constants_1.Constants.SERVICE_AUTH,
|
|
20
|
+
constants_1.Constants.SERVICE_FIREALERTS,
|
|
21
|
+
constants_1.Constants.SERVICE_REMOTE_CONFIG,
|
|
22
|
+
constants_1.Constants.SERVICE_TEST_LAB,
|
|
23
|
+
constants_1.Constants.SERVICE_CLOUD_TASKS,
|
|
24
|
+
]);
|
|
25
|
+
function endpointSupportLevel(ep) {
|
|
26
|
+
if (backend.isHttpsTriggered(ep) || backend.isCallableTriggered(ep)) {
|
|
27
|
+
if (backend.isTaskQueueTriggered(ep)) {
|
|
28
|
+
return "experimental";
|
|
29
|
+
}
|
|
30
|
+
return "production";
|
|
31
|
+
}
|
|
32
|
+
if (backend.isScheduleTriggered(ep)) {
|
|
33
|
+
return "experimental";
|
|
34
|
+
}
|
|
35
|
+
if (backend.isBlockingTriggered(ep)) {
|
|
36
|
+
return "experimental";
|
|
37
|
+
}
|
|
38
|
+
if (backend.isEventTriggered(ep)) {
|
|
39
|
+
if (ep.eventTrigger.channel) {
|
|
40
|
+
return "experimental";
|
|
41
|
+
}
|
|
42
|
+
const service = ep.eventTrigger.eventType
|
|
43
|
+
? serviceFromEventType(ep.eventTrigger.eventType)
|
|
44
|
+
: undefined;
|
|
45
|
+
if (service && EMULATOR_ONLY_SERVICES.has(service)) {
|
|
46
|
+
return "emulatorOnly";
|
|
47
|
+
}
|
|
48
|
+
if (service && EXPERIMENTAL_SERVICES.has(service)) {
|
|
49
|
+
return "experimental";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return "experimental";
|
|
53
|
+
}
|
|
54
|
+
function isDartEndpoint(ep) {
|
|
55
|
+
return supported.runtimeIsLanguage(ep.runtime, "dart");
|
|
56
|
+
}
|
|
57
|
+
function classifyNonProductionEndpoints(endpoints) {
|
|
58
|
+
const emulatorOnly = [];
|
|
59
|
+
const experimental = [];
|
|
60
|
+
for (const ep of endpoints) {
|
|
61
|
+
switch (endpointSupportLevel(ep)) {
|
|
62
|
+
case "production":
|
|
63
|
+
break;
|
|
64
|
+
case "emulatorOnly":
|
|
65
|
+
emulatorOnly.push(ep);
|
|
66
|
+
break;
|
|
67
|
+
case "experimental":
|
|
68
|
+
experimental.push(ep);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { emulatorOnly, experimental };
|
|
73
|
+
}
|
|
74
|
+
function triggerTypeLabel(ep) {
|
|
75
|
+
if (backend.isScheduleTriggered(ep))
|
|
76
|
+
return "scheduler";
|
|
77
|
+
if (backend.isTaskQueueTriggered(ep))
|
|
78
|
+
return "tasks";
|
|
79
|
+
if (backend.isBlockingTriggered(ep))
|
|
80
|
+
return "identity";
|
|
81
|
+
if (backend.isCallableTriggered(ep))
|
|
82
|
+
return "callable";
|
|
83
|
+
if (backend.isHttpsTriggered(ep))
|
|
84
|
+
return "https";
|
|
85
|
+
if (backend.isEventTriggered(ep)) {
|
|
86
|
+
if (ep.eventTrigger.channel)
|
|
87
|
+
return "eventarc";
|
|
88
|
+
const svc = serviceFromEventType(ep.eventTrigger.eventType);
|
|
89
|
+
return svc ? constants_1.Constants.getServiceName(svc) : ep.eventTrigger.eventType;
|
|
90
|
+
}
|
|
91
|
+
return "unknown";
|
|
92
|
+
}
|
|
93
|
+
function groupByTriggerLabel(endpoints) {
|
|
94
|
+
const groups = new Map();
|
|
95
|
+
for (const ep of endpoints) {
|
|
96
|
+
const label = triggerTypeLabel(ep);
|
|
97
|
+
const ids = groups.get(label) ?? [];
|
|
98
|
+
ids.push(ep.id);
|
|
99
|
+
groups.set(label, ids);
|
|
100
|
+
}
|
|
101
|
+
return groups;
|
|
102
|
+
}
|
|
103
|
+
function serviceFromEventType(eventType) {
|
|
104
|
+
if (eventType.includes("firestore"))
|
|
105
|
+
return constants_1.Constants.SERVICE_FIRESTORE;
|
|
106
|
+
if (eventType.includes("database"))
|
|
107
|
+
return constants_1.Constants.SERVICE_REALTIME_DATABASE;
|
|
108
|
+
if (eventType.includes("pubsub"))
|
|
109
|
+
return constants_1.Constants.SERVICE_PUBSUB;
|
|
110
|
+
if (eventType.includes("storage"))
|
|
111
|
+
return constants_1.Constants.SERVICE_STORAGE;
|
|
112
|
+
if (eventType.includes("eventarc"))
|
|
113
|
+
return constants_1.Constants.SERVICE_EVENTARC;
|
|
114
|
+
if (eventType.includes("firebasealerts"))
|
|
115
|
+
return constants_1.Constants.SERVICE_FIREALERTS;
|
|
116
|
+
if (eventType.includes("auth"))
|
|
117
|
+
return constants_1.Constants.SERVICE_AUTH;
|
|
118
|
+
if (eventType.includes("remoteconfig"))
|
|
119
|
+
return constants_1.Constants.SERVICE_REMOTE_CONFIG;
|
|
120
|
+
if (eventType.includes("testlab") || eventType.includes("testing"))
|
|
121
|
+
return constants_1.Constants.SERVICE_TEST_LAB;
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
@@ -7,13 +7,10 @@ const python = require("./python");
|
|
|
7
7
|
const validate = require("../validate");
|
|
8
8
|
const error_1 = require("../../../error");
|
|
9
9
|
const supported = require("./supported");
|
|
10
|
-
const experiments = require("../../../experiments");
|
|
11
10
|
const factories = [
|
|
12
11
|
node.tryCreateDelegate,
|
|
13
12
|
python.tryCreateDelegate,
|
|
14
|
-
|
|
15
|
-
? dart.tryCreateDelegate(ctx)
|
|
16
|
-
: Promise.resolve(undefined),
|
|
13
|
+
dart.tryCreateDelegate,
|
|
17
14
|
];
|
|
18
15
|
async function getRuntimeDelegate(context) {
|
|
19
16
|
const { projectDir, sourceDir, runtime } = context;
|
|
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.isRuntime = isRuntime;
|
|
18
18
|
exports.runtimeIsLanguage = runtimeIsLanguage;
|
|
19
|
-
exports.isLanguageRuntime = isLanguageRuntime;
|
|
20
19
|
exports.latest = latest;
|
|
21
20
|
exports.isDecommissioned = isDecommissioned;
|
|
22
21
|
exports.guardVersionSupport = guardVersionSupport;
|
|
@@ -28,9 +27,6 @@ function isRuntime(maybe) {
|
|
|
28
27
|
return maybe in types_1.RUNTIMES;
|
|
29
28
|
}
|
|
30
29
|
function runtimeIsLanguage(runtime, language) {
|
|
31
|
-
return runtime.startsWith(language);
|
|
32
|
-
}
|
|
33
|
-
function isLanguageRuntime(runtime, language) {
|
|
34
30
|
return !!runtime && runtime.startsWith(language);
|
|
35
31
|
}
|
|
36
32
|
function latest(language, runtimes = Object.keys(types_1.RUNTIMES)) {
|
|
@@ -5,11 +5,13 @@ exports.isAILogicEvent = isAILogicEvent;
|
|
|
5
5
|
const backend = require("../backend");
|
|
6
6
|
const error_1 = require("../../../error");
|
|
7
7
|
const ailogicApi = require("../../../gcp/ailogic");
|
|
8
|
-
|
|
9
|
-
exports
|
|
8
|
+
const ailogic_1 = require("../../../gcp/ailogic");
|
|
9
|
+
Object.defineProperty(exports, "AI_LOGIC_BEFORE_GENERATE_CONTENT", { enumerable: true, get: function () { return ailogic_1.AI_LOGIC_BEFORE_GENERATE_CONTENT; } });
|
|
10
|
+
Object.defineProperty(exports, "AI_LOGIC_AFTER_GENERATE_CONTENT", { enumerable: true, get: function () { return ailogic_1.AI_LOGIC_AFTER_GENERATE_CONTENT; } });
|
|
11
|
+
const utils_1 = require("../../../utils");
|
|
10
12
|
exports.AI_LOGIC_EVENTS = [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
ailogic_1.AI_LOGIC_BEFORE_GENERATE_CONTENT,
|
|
14
|
+
ailogic_1.AI_LOGIC_AFTER_GENERATE_CONTENT,
|
|
13
15
|
];
|
|
14
16
|
function isAILogicEvent(endpoint) {
|
|
15
17
|
if (!backend.isBlockingTriggered(endpoint)) {
|
|
@@ -62,7 +64,17 @@ class AILogicService {
|
|
|
62
64
|
if (!isAILogicEvent(ep)) {
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
try {
|
|
68
|
+
await ailogicApi.deleteBlockingFunction(ep);
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
if ((0, error_1.getErrStatus)(err) === 404) {
|
|
72
|
+
(0, utils_1.logLabeledWarning)("functions", `Tried deleting trigger registration for function ${ep.id} but it is not currently registered`);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
throw err;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
66
78
|
}
|
|
67
79
|
}
|
|
68
80
|
exports.AILogicService = AILogicService;
|
|
@@ -12,7 +12,7 @@ function ensureDataConnectTriggerRegion(endpoint) {
|
|
|
12
12
|
endpoint.eventTrigger.region = endpoint.region;
|
|
13
13
|
}
|
|
14
14
|
if (endpoint.eventTrigger.region !== endpoint.region) {
|
|
15
|
-
throw new error_1.FirebaseError("The Firebase
|
|
15
|
+
throw new error_1.FirebaseError("The Firebase SQL Connect trigger location must match the function region.");
|
|
16
16
|
}
|
|
17
17
|
return Promise.resolve();
|
|
18
18
|
}
|
|
@@ -124,8 +124,8 @@ const EVENT_SERVICE_MAPPING = {
|
|
|
124
124
|
"google.cloud.firestore.document.v1.updated.withAuthContext": firestoreService,
|
|
125
125
|
"google.cloud.firestore.document.v1.deleted.withAuthContext": firestoreService,
|
|
126
126
|
"google.firebase.dataconnect.connector.v1.mutationExecuted": dataconnectService,
|
|
127
|
-
"firebase.
|
|
128
|
-
"firebase.
|
|
127
|
+
"google.firebase.ailogic.v1.beforeGenerate": aiLogicService,
|
|
128
|
+
"google.firebase.ailogic.v1.afterGenerate": aiLogicService,
|
|
129
129
|
};
|
|
130
130
|
function serviceForEndpoint(endpoint) {
|
|
131
131
|
if (backend.isEventTriggered(endpoint)) {
|
|
@@ -55,7 +55,13 @@ function endpointsAreValid(wantBackend) {
|
|
|
55
55
|
validateTimeoutConfig(endpoints);
|
|
56
56
|
for (const ep of endpoints) {
|
|
57
57
|
validateScheduledTimeout(ep);
|
|
58
|
-
(0, services_1.serviceForEndpoint)(ep)
|
|
58
|
+
const service = (0, services_1.serviceForEndpoint)(ep);
|
|
59
|
+
if (backend.isBlockingTriggered(ep)) {
|
|
60
|
+
if (service.name === "noop") {
|
|
61
|
+
throw new error_1.FirebaseError(`Unrecognized blocking trigger type: ${ep.blockingTrigger.eventType}. Please update your CLI with ${clc.bold("npm install -g firebase-tools@latest")}.`, { exit: 1 });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
service.validateTrigger(ep, wantBackend);
|
|
59
65
|
}
|
|
60
66
|
const gcfV1WithConcurrency = matchingIds(endpoints, (endpoint) => (endpoint.concurrency || 1) !== 1 && endpoint.platform === "gcfv1");
|
|
61
67
|
if (gcfV1WithConcurrency.length) {
|
|
@@ -49,7 +49,7 @@ exports.EMULATOR_DESCRIPTION = {
|
|
|
49
49
|
storage: "Storage Emulator",
|
|
50
50
|
extensions: "Extensions Emulator",
|
|
51
51
|
eventarc: "Eventarc Emulator",
|
|
52
|
-
dataconnect: "
|
|
52
|
+
dataconnect: "SQL Connect Emulator",
|
|
53
53
|
tasks: "Cloud Tasks Emulator",
|
|
54
54
|
};
|
|
55
55
|
exports.DEFAULT_HOST = "localhost";
|
|
@@ -419,10 +419,20 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
419
419
|
const firestoreLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.FIRESTORE);
|
|
420
420
|
const firestoreAddr = legacyGetFirstAddr(types_1.Emulators.FIRESTORE);
|
|
421
421
|
const websocketPort = legacyGetFirstAddr("firestore.websocket").port;
|
|
422
|
+
const prodEdition = options.config.data.firestore?.edition;
|
|
423
|
+
const emulatorEdition = options.config.src.emulators?.firestore?.edition;
|
|
424
|
+
if (prodEdition !== emulatorEdition) {
|
|
425
|
+
firestoreLogger.logLabeled("WARN", "firestore", `The edition configured in your firebase.json#firestore and firebase.json#emulators.firestore do not match. The latter will be used to start up the Firestore emulator.`);
|
|
426
|
+
}
|
|
427
|
+
const edition = (emulatorEdition || prodEdition || "standard").toLowerCase();
|
|
428
|
+
if (edition !== "standard" && edition !== "enterprise") {
|
|
429
|
+
throw new error_1.FirebaseError("The Firestore emulator edition must be either 'standard' or 'enterprise'.", { exit: 1 });
|
|
430
|
+
}
|
|
422
431
|
const args = {
|
|
423
432
|
host: firestoreAddr.host,
|
|
424
433
|
port: firestoreAddr.port,
|
|
425
434
|
websocket_port: websocketPort,
|
|
435
|
+
"database-edition": edition,
|
|
426
436
|
project_id: projectId,
|
|
427
437
|
auto_download: true,
|
|
428
438
|
};
|
|
@@ -472,6 +482,7 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
472
482
|
}
|
|
473
483
|
const firestoreEmulator = new firestoreEmulator_1.FirestoreEmulator(args);
|
|
474
484
|
await startEmulator(firestoreEmulator);
|
|
485
|
+
firestoreLogger.logLabeled("SUCCESS", types_1.Emulators.FIRESTORE, `Firestore Emulator was started in ${edition} edition.`);
|
|
475
486
|
firestoreLogger.logLabeled("SUCCESS", types_1.Emulators.FIRESTORE, `Firestore Emulator UI websocket is running on ${websocketPort}.`);
|
|
476
487
|
}
|
|
477
488
|
if (listenForEmulator.database) {
|
|
@@ -556,10 +567,10 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
556
567
|
if (listenForEmulator.dataconnect) {
|
|
557
568
|
const config = (0, load_1.readFirebaseJson)(options.config);
|
|
558
569
|
if (!config.length) {
|
|
559
|
-
throw new error_1.FirebaseError("No
|
|
570
|
+
throw new error_1.FirebaseError("No SQL Connect service found in firebase.json");
|
|
560
571
|
}
|
|
561
572
|
else if (config.length > 1) {
|
|
562
|
-
logger_1.logger.warn(`TODO: Add support for multiple services in the
|
|
573
|
+
logger_1.logger.warn(`TODO: Add support for multiple services in the SQL Connect emulator. Currently emulating first service ${config[0].source}`);
|
|
563
574
|
}
|
|
564
575
|
const args = {
|
|
565
576
|
listen: listenForEmulator.dataconnect,
|