firebase-tools-with-isolate 14.10.1-1 → 14.16.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/api.js +5 -1
- package/lib/apphosting/backend.js +40 -15
- package/lib/apptesting/ensureProjectConfigured.js +56 -0
- package/lib/apptesting/invokeTests.js +40 -0
- package/lib/apptesting/parseTestFiles.js +75 -0
- package/lib/apptesting/types.js +18 -0
- package/lib/auth.js +37 -2
- package/lib/command.js +24 -5
- package/lib/commands/apphosting-backends-create.js +8 -5
- package/lib/commands/apptesting-execute.js +101 -0
- package/lib/commands/dataconnect-sdk-generate.js +28 -26
- package/lib/commands/dataconnect-services-list.js +1 -1
- package/lib/commands/dataconnect-sql-diff.js +2 -2
- package/lib/commands/dataconnect-sql-grant.js +7 -2
- package/lib/commands/dataconnect-sql-migrate.js +2 -2
- package/lib/commands/dataconnect-sql-setup.js +3 -5
- package/lib/commands/dataconnect-sql-shell.js +2 -2
- package/lib/commands/ext-export.js +1 -1
- package/lib/commands/firestore-bulkdelete.js +73 -0
- package/lib/commands/firestore-databases-create.js +11 -0
- package/lib/commands/firestore-operations-cancel.js +44 -0
- package/lib/commands/firestore-operations-describe.js +29 -0
- package/lib/commands/firestore-operations-list.js +29 -0
- package/lib/commands/firestore-utils.js +15 -0
- package/lib/commands/functions-config-clone.js +2 -0
- package/lib/commands/functions-config-export.js +5 -2
- package/lib/commands/functions-config-get.js +2 -0
- package/lib/commands/functions-config-set.js +2 -0
- package/lib/commands/functions-config-unset.js +2 -0
- package/lib/commands/index.js +9 -0
- package/lib/commands/init.js +24 -4
- package/lib/commands/internaltesting-functions-discover.js +20 -5
- package/lib/commands/login.js +13 -9
- package/lib/commands/use.js +5 -0
- package/lib/config.js +16 -4
- package/lib/crashlytics/addNote.js +27 -0
- package/lib/crashlytics/buildToolsJarHelper.js +1 -2
- package/lib/crashlytics/deleteNote.js +23 -0
- package/lib/crashlytics/getIssueDetails.js +26 -0
- package/lib/crashlytics/getSampleCrash.js +34 -0
- package/lib/crashlytics/listNotes.js +29 -0
- package/lib/crashlytics/listTopDevices.js +33 -0
- package/lib/crashlytics/listTopIssues.js +8 -23
- package/lib/crashlytics/listTopOperatingSystems.js +32 -0
- package/lib/crashlytics/listTopVersions.js +32 -0
- package/lib/crashlytics/updateIssue.js +35 -0
- package/lib/crashlytics/utils.js +38 -0
- package/lib/dataconnect/appFinder.js +102 -0
- package/lib/dataconnect/client.js +23 -15
- package/lib/dataconnect/ensureApis.js +6 -9
- package/lib/dataconnect/errors.js +7 -1
- package/lib/dataconnect/freeTrial.js +16 -38
- package/lib/dataconnect/load.js +105 -6
- package/lib/dataconnect/provisionCloudSql.js +67 -70
- package/lib/dataconnect/schemaMigration.js +219 -169
- package/lib/deploy/dataconnect/deploy.js +7 -9
- package/lib/deploy/dataconnect/prepare.js +7 -12
- package/lib/deploy/dataconnect/release.js +43 -31
- package/lib/deploy/firestore/deploy.js +10 -0
- package/lib/deploy/functions/backend.js +7 -1
- package/lib/deploy/functions/build.js +28 -14
- package/lib/deploy/functions/deploy.js +3 -2
- package/lib/deploy/functions/ensure.js +1 -1
- package/lib/deploy/functions/functionsDeployHelper.js +8 -1
- package/lib/deploy/functions/params.js +4 -0
- package/lib/deploy/functions/prepare.js +25 -13
- package/lib/deploy/functions/pricing.js +12 -5
- package/lib/deploy/functions/release/fabricator.js +25 -3
- package/lib/deploy/functions/release/reporter.js +1 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +52 -5
- package/lib/deploy/functions/runtimes/node/index.js +83 -51
- package/lib/emulator/auth/operations.js +10 -1
- package/lib/emulator/commandUtils.js +7 -1
- package/lib/emulator/controller.js +22 -34
- package/lib/emulator/dataconnectEmulator.js +27 -24
- package/lib/emulator/downloadableEmulatorInfo.json +18 -18
- package/lib/emulator/env.js +2 -1
- package/lib/emulator/functionsEmulator.js +12 -2
- package/lib/emulator/hub.js +11 -8
- package/lib/emulator/tasksEmulator.js +1 -1
- package/lib/emulator/ui.js +3 -1
- package/lib/env.js +18 -0
- package/lib/experiments.js +20 -0
- package/lib/extensions/extensionsHelper.js +4 -15
- package/lib/extensions/runtimes/common.js +3 -2
- package/lib/extensions/utils.js +1 -12
- package/lib/firestore/api-sort.js +96 -3
- package/lib/firestore/api-types.js +20 -1
- package/lib/firestore/api.js +144 -15
- package/lib/firestore/pretty-print.js +35 -1
- package/lib/firestore/validator.js +1 -1
- package/lib/functional.js +7 -1
- package/lib/functions/deprecationWarnings.js +21 -0
- package/lib/functions/env.js +31 -16
- package/lib/functions/projectConfig.js +87 -8
- package/lib/functions/secrets.js +3 -0
- package/lib/gcp/cloudfunctions.js +1 -6
- package/lib/gcp/cloudfunctionsv2.js +3 -39
- package/lib/gcp/cloudscheduler.js +1 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +4 -16
- package/lib/gcp/cloudsql/connect.js +4 -3
- package/lib/gcp/cloudsql/permissionsSetup.js +23 -16
- package/lib/gcp/k8s.js +32 -0
- package/lib/gcp/runv2.js +181 -0
- package/lib/gemini/fdcExperience.js +5 -3
- package/lib/init/features/aitools/claude.js +43 -0
- package/lib/init/features/aitools/cursor.js +61 -0
- package/lib/init/features/aitools/gemini.js +58 -0
- package/lib/init/features/aitools/index.js +28 -0
- package/lib/init/features/aitools/promptUpdater.js +111 -0
- package/lib/init/features/aitools/studio.js +17 -0
- package/lib/init/features/aitools/types.js +2 -0
- package/lib/init/features/aitools.js +83 -0
- package/lib/init/features/apptesting/index.js +34 -0
- package/lib/init/features/dataconnect/create_app.js +53 -0
- package/lib/init/features/dataconnect/index.js +280 -186
- package/lib/init/features/dataconnect/sdk.js +232 -144
- package/lib/init/features/index.js +8 -3
- package/lib/init/features/project.js +4 -0
- package/lib/init/index.js +18 -2
- package/lib/management/apps.js +3 -3
- package/lib/management/studio.js +120 -0
- package/lib/mcp/errors.js +5 -7
- package/lib/mcp/index.js +179 -61
- package/lib/mcp/logging-transport.js +23 -0
- package/lib/mcp/prompt.js +10 -0
- package/lib/mcp/prompts/core/deploy.js +101 -0
- package/lib/mcp/prompts/core/index.js +5 -0
- package/lib/mcp/prompts/crashlytics/connect.js +114 -0
- package/lib/mcp/prompts/crashlytics/index.js +5 -0
- package/lib/mcp/prompts/dataconnect/index.js +9 -0
- package/lib/mcp/prompts/dataconnect/schema.js +67 -0
- package/lib/mcp/prompts/index.js +47 -0
- package/lib/mcp/tools/apphosting/fetch_logs.js +22 -22
- package/lib/mcp/tools/apphosting/list_backends.js +10 -10
- package/lib/mcp/tools/auth/disable_user.js +7 -7
- package/lib/mcp/tools/auth/get_user.js +13 -6
- package/lib/mcp/tools/auth/index.js +10 -10
- package/lib/mcp/tools/auth/list_users.js +6 -6
- package/lib/mcp/tools/auth/set_claims.js +7 -7
- package/lib/mcp/tools/auth/set_sms_region_policy.js +6 -6
- package/lib/mcp/tools/core/consult_assistant.js +13 -8
- package/lib/mcp/tools/core/create_android_sha.js +9 -9
- package/lib/mcp/tools/core/create_app.js +7 -7
- package/lib/mcp/tools/core/create_project.js +13 -13
- package/lib/mcp/tools/core/get_admin_sdk_config.js +7 -7
- package/lib/mcp/tools/core/get_environment.js +8 -8
- package/lib/mcp/tools/core/get_project.js +5 -5
- package/lib/mcp/tools/core/get_sdk_config.js +19 -9
- package/lib/mcp/tools/core/index.js +28 -24
- package/lib/mcp/tools/core/init.js +39 -16
- package/lib/mcp/tools/core/list_apps.js +6 -6
- package/lib/mcp/tools/core/list_projects.js +6 -6
- package/lib/mcp/tools/core/login.js +46 -0
- package/lib/mcp/tools/core/logout.js +62 -0
- package/lib/mcp/tools/core/update_environment.js +10 -10
- package/lib/mcp/tools/crashlytics/add_note.js +32 -0
- package/lib/mcp/tools/crashlytics/constants.js +11 -0
- package/lib/mcp/tools/crashlytics/delete_note.js +35 -0
- package/lib/mcp/tools/crashlytics/get_issue_details.js +31 -0
- package/lib/mcp/tools/crashlytics/get_sample_crash.js +43 -0
- package/lib/mcp/tools/crashlytics/index.js +22 -2
- package/lib/mcp/tools/crashlytics/list_notes.js +37 -0
- package/lib/mcp/tools/crashlytics/list_top_devices.js +33 -0
- package/lib/mcp/tools/crashlytics/list_top_issues.js +12 -13
- package/lib/mcp/tools/crashlytics/list_top_operating_systems.js +33 -0
- package/lib/mcp/tools/crashlytics/list_top_versions.js +33 -0
- package/lib/mcp/tools/crashlytics/update_issue.js +37 -0
- package/lib/mcp/tools/database/get_data.js +49 -0
- package/lib/mcp/tools/database/get_rules.js +39 -0
- package/lib/mcp/tools/database/index.js +8 -0
- package/lib/mcp/tools/database/set_data.js +57 -0
- package/lib/mcp/tools/database/validate_rules.js +41 -0
- package/lib/mcp/tools/dataconnect/compile.js +43 -0
- package/lib/mcp/tools/dataconnect/execute.js +71 -0
- package/lib/mcp/tools/dataconnect/generate_operation.js +8 -8
- package/lib/mcp/tools/dataconnect/generate_schema.js +6 -6
- package/lib/mcp/tools/dataconnect/index.js +10 -18
- package/lib/mcp/tools/dataconnect/list_services.js +107 -11
- package/lib/mcp/tools/firestore/delete_document.js +13 -13
- package/lib/mcp/tools/firestore/get_documents.js +13 -13
- package/lib/mcp/tools/firestore/list_collections.js +7 -10
- package/lib/mcp/tools/firestore/query_collection.js +13 -13
- package/lib/mcp/tools/index.js +24 -18
- package/lib/mcp/tools/messaging/index.js +2 -2
- package/lib/mcp/tools/messaging/send_message.js +7 -7
- package/lib/mcp/tools/remoteconfig/get_template.js +5 -5
- package/lib/mcp/tools/remoteconfig/index.js +4 -4
- package/lib/mcp/tools/remoteconfig/publish_template.js +7 -7
- package/lib/mcp/tools/remoteconfig/rollback_template.js +6 -6
- package/lib/mcp/tools/rules/get_rules.js +8 -8
- package/lib/mcp/tools/rules/validate_rules.js +10 -10
- package/lib/mcp/tools/storage/get_download_url.js +8 -8
- package/lib/mcp/tools/storage/get_rules.js +8 -8
- package/lib/mcp/types.js +2 -0
- package/lib/mcp/util/dataconnect/compile.js +20 -0
- package/lib/mcp/util/dataconnect/content.js +655 -0
- package/lib/mcp/util/dataconnect/emulator.js +16 -0
- package/lib/mcp/util.js +5 -18
- package/lib/requireAuth.js +14 -4
- package/lib/rtdb.js +10 -6
- package/lib/scopes.js +2 -1
- package/lib/serve/functions.js +4 -3
- package/lib/timeout.js +21 -0
- package/lib/track.js +18 -1
- package/lib/unzip.js +13 -0
- package/lib/utils.js +76 -2
- package/package.json +6 -4
- package/prompts/FIREBASE.md +121 -0
- package/prompts/FIREBASE_FUNCTIONS.md +221 -0
- package/schema/apptesting-yaml.json +64 -0
- package/schema/firebase-config.json +163 -53
- package/templates/init/aitools/cursor-rules-header.txt +8 -0
- package/templates/init/aitools/gemini-extension.json +11 -0
- package/templates/init/apptesting/smoke_test.yaml +6 -0
- package/templates/init/dataconnect/connector.yaml +0 -16
- package/templates/init/dataconnect/dataconnect.yaml +2 -1
- package/templates/init/dataconnect/mutations.gql +29 -29
- package/templates/init/dataconnect/queries.gql +73 -73
- package/templates/init/dataconnect/schema.gql +48 -48
- package/templates/init/firestore/firestore.indexes.json +26 -1
- package/lib/dataconnect/fileUtils.js +0 -168
- package/lib/emulator/adminSdkConfig.test.js +0 -16
- package/lib/extensions/resolveSource.js +0 -23
- package/lib/firestore/api-sort.test.js +0 -74
- package/lib/firestore/backupUtils.test.js +0 -18
- package/lib/firestore/pretty-print.test.js +0 -61
- package/lib/firestore/util.test.js +0 -42
- package/lib/mcp/tools/dataconnect/emulator.js +0 -16
- package/lib/mcp/tools/dataconnect/execute_graphql.js +0 -48
- package/lib/mcp/tools/dataconnect/execute_graphql_read.js +0 -48
- package/lib/mcp/tools/dataconnect/execute_mutation.js +0 -62
- package/lib/mcp/tools/dataconnect/execute_query.js +0 -62
- package/lib/mcp/tools/dataconnect/get_connector.js +0 -31
- package/lib/mcp/tools/dataconnect/get_schema.js +0 -31
- /package/lib/mcp/{tools → util}/dataconnect/converter.js +0 -0
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const clc = require("colorette");
|
|
4
4
|
const load_1 = require("../../dataconnect/load");
|
|
5
|
-
const fileUtils_1 = require("../../dataconnect/fileUtils");
|
|
6
5
|
const logger_1 = require("../../logger");
|
|
7
6
|
const utils = require("../../utils");
|
|
8
7
|
const projectUtils_1 = require("../../projectUtils");
|
|
@@ -25,10 +24,8 @@ async function default_1(context, options) {
|
|
|
25
24
|
}
|
|
26
25
|
await (0, ensureApis_1.ensureApis)(projectId);
|
|
27
26
|
await (0, requireTosAcceptance_1.requireTosAcceptance)(firedata_1.DATA_CONNECT_TOS_ID)(options);
|
|
28
|
-
const serviceCfgs = (0, fileUtils_1.readFirebaseJson)(options.config);
|
|
29
|
-
utils.logLabeledBullet("dataconnect", `Preparing to deploy`);
|
|
30
27
|
const filters = (0, filters_1.getResourceFilters)(options);
|
|
31
|
-
const serviceInfos = await
|
|
28
|
+
const serviceInfos = await (0, load_1.loadAll)(projectId, options.config);
|
|
32
29
|
for (const si of serviceInfos) {
|
|
33
30
|
si.deploymentMetadata = await (0, build_1.build)(options, si.sourceDirectory, options.dryRun);
|
|
34
31
|
}
|
|
@@ -49,10 +46,10 @@ async function default_1(context, options) {
|
|
|
49
46
|
serviceInfos,
|
|
50
47
|
filters,
|
|
51
48
|
};
|
|
52
|
-
utils.logLabeledBullet("dataconnect", `Successfully
|
|
49
|
+
utils.logLabeledBullet("dataconnect", `Successfully compiled schema and connectors`);
|
|
53
50
|
if (options.dryRun) {
|
|
54
51
|
for (const si of serviceInfos) {
|
|
55
|
-
await (0, schemaMigration_1.diffSchema)(options, si.schema, si.dataConnectYaml.schema
|
|
52
|
+
await (0, schemaMigration_1.diffSchema)(options, si.schema, si.dataConnectYaml.schema?.datasource?.postgresql?.schemaValidation);
|
|
56
53
|
}
|
|
57
54
|
utils.logLabeledBullet("dataconnect", "Checking for CloudSQL resources...");
|
|
58
55
|
await Promise.all(serviceInfos
|
|
@@ -62,20 +59,18 @@ async function default_1(context, options) {
|
|
|
62
59
|
.map(async (s) => {
|
|
63
60
|
const postgresDatasource = s.schema.datasources.find((d) => d.postgresql);
|
|
64
61
|
if (postgresDatasource) {
|
|
65
|
-
const instanceId = postgresDatasource.postgresql?.cloudSql
|
|
62
|
+
const instanceId = postgresDatasource.postgresql?.cloudSql?.instance.split("/").pop();
|
|
66
63
|
const databaseId = postgresDatasource.postgresql?.database;
|
|
67
64
|
if (!instanceId || !databaseId) {
|
|
68
65
|
return Promise.resolve();
|
|
69
66
|
}
|
|
70
|
-
|
|
71
|
-
return (0, provisionCloudSql_1.provisionCloudSql)({
|
|
67
|
+
return (0, provisionCloudSql_1.setupCloudSql)({
|
|
72
68
|
projectId,
|
|
73
69
|
location: (0, names_1.parseServiceName)(s.serviceName).location,
|
|
74
70
|
instanceId,
|
|
75
71
|
databaseId,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
dryRun: options.dryRun,
|
|
72
|
+
requireGoogleMlIntegration: (0, types_1.requiresVector)(s.deploymentMetadata),
|
|
73
|
+
dryRun: true,
|
|
79
74
|
});
|
|
80
75
|
}
|
|
81
76
|
}));
|
|
@@ -5,6 +5,8 @@ const client_1 = require("../../dataconnect/client");
|
|
|
5
5
|
const prompts_1 = require("../../dataconnect/prompts");
|
|
6
6
|
const schemaMigration_1 = require("../../dataconnect/schemaMigration");
|
|
7
7
|
const projectUtils_1 = require("../../projectUtils");
|
|
8
|
+
const names_1 = require("../../dataconnect/names");
|
|
9
|
+
const logger_1 = require("../../logger");
|
|
8
10
|
async function default_1(context, options) {
|
|
9
11
|
const project = (0, projectUtils_1.needProjectId)(options);
|
|
10
12
|
const serviceInfos = context.dataconnect.serviceInfos;
|
|
@@ -18,22 +20,9 @@ async function default_1(context, options) {
|
|
|
18
20
|
})
|
|
19
21
|
.map((s) => ({
|
|
20
22
|
schema: s.schema,
|
|
21
|
-
validationMode: s.dataConnectYaml
|
|
23
|
+
validationMode: s.dataConnectYaml?.schema?.datasource?.postgresql?.schemaValidation,
|
|
22
24
|
}));
|
|
23
|
-
|
|
24
|
-
utils.logLabeledBullet("dataconnect", "Deploying Data Connect schemas...");
|
|
25
|
-
for (const s of wantSchemas) {
|
|
26
|
-
await (0, schemaMigration_1.migrateSchema)({
|
|
27
|
-
options,
|
|
28
|
-
schema: s.schema,
|
|
29
|
-
validateOnly: false,
|
|
30
|
-
schemaValidation: s.validationMode,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
utils.logLabeledBullet("dataconnect", "Schemas deployed.");
|
|
34
|
-
}
|
|
35
|
-
let wantConnectors = [];
|
|
36
|
-
wantConnectors = wantConnectors.concat(...serviceInfos.map((si) => si.connectorInfo
|
|
25
|
+
const wantConnectors = serviceInfos.flatMap((si) => si.connectorInfo
|
|
37
26
|
.filter((c) => {
|
|
38
27
|
return (!filters ||
|
|
39
28
|
filters.some((f) => {
|
|
@@ -41,30 +30,53 @@ async function default_1(context, options) {
|
|
|
41
30
|
(f.connectorId === c.connectorYaml.connectorId || f.fullService));
|
|
42
31
|
}));
|
|
43
32
|
})
|
|
44
|
-
.map((c) => c.connector))
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
.map((c) => c.connector));
|
|
34
|
+
const remainingConnectors = await Promise.all(wantConnectors.map(async (c) => {
|
|
35
|
+
try {
|
|
36
|
+
await (0, client_1.upsertConnector)(c);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
logger_1.logger.debug("Error pre-deploying connector", c.name, err);
|
|
40
|
+
return c;
|
|
41
|
+
}
|
|
42
|
+
utils.logLabeledSuccess("dataconnect", `Deployed connector ${c.name}`);
|
|
43
|
+
return undefined;
|
|
44
|
+
}));
|
|
45
|
+
for (const s of wantSchemas) {
|
|
46
|
+
await (0, schemaMigration_1.migrateSchema)({
|
|
47
|
+
options,
|
|
48
|
+
schema: s.schema,
|
|
49
|
+
validateOnly: false,
|
|
50
|
+
schemaValidation: s.validationMode,
|
|
51
|
+
});
|
|
52
|
+
utils.logLabeledSuccess("dataconnect", `Migrated schema ${s.schema.name}`);
|
|
53
|
+
}
|
|
54
|
+
await Promise.all(remainingConnectors.map(async (c) => {
|
|
55
|
+
if (c) {
|
|
52
56
|
await (0, client_1.upsertConnector)(c);
|
|
53
57
|
utils.logLabeledSuccess("dataconnect", `Deployed connector ${c.name}`);
|
|
54
|
-
}));
|
|
55
|
-
for (const c of connectorsToDelete) {
|
|
56
|
-
await (0, prompts_1.promptDeleteConnector)(options, c.name);
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
+
}));
|
|
60
|
+
const allConnectors = await deployedConnectors(serviceInfos);
|
|
61
|
+
const connectorsToDelete = filters
|
|
62
|
+
? []
|
|
63
|
+
: allConnectors.filter((h) => !wantConnectors.some((w) => w.name === h.name));
|
|
64
|
+
for (const c of connectorsToDelete) {
|
|
65
|
+
await (0, prompts_1.promptDeleteConnector)(options, c.name);
|
|
59
66
|
}
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
let consolePath = "/dataconnect";
|
|
68
|
+
if (serviceInfos.length === 1) {
|
|
69
|
+
const sn = (0, names_1.parseServiceName)(serviceInfos[0].serviceName);
|
|
70
|
+
consolePath += `/locations/${sn.location}/services/${sn.serviceId}/schema`;
|
|
62
71
|
}
|
|
63
|
-
utils.logLabeledSuccess("dataconnect", `Deployment complete! View your deployed schema and connectors at
|
|
72
|
+
utils.logLabeledSuccess("dataconnect", `Deployment complete! View your deployed schema and connectors at
|
|
73
|
+
|
|
74
|
+
${utils.consoleUrl(project, consolePath)}
|
|
75
|
+
`);
|
|
64
76
|
return;
|
|
65
77
|
}
|
|
66
78
|
exports.default = default_1;
|
|
67
|
-
async function
|
|
79
|
+
async function deployedConnectors(serviceInfos) {
|
|
68
80
|
let connectors = [];
|
|
69
81
|
for (const si of serviceInfos) {
|
|
70
82
|
connectors = connectors.concat(await (0, client_1.listConnectors)(si.serviceName));
|
|
@@ -22,6 +22,15 @@ async function createDatabase(context, options) {
|
|
|
22
22
|
if (!firestoreCfg.database) {
|
|
23
23
|
firestoreCfg.database = "(default)";
|
|
24
24
|
}
|
|
25
|
+
let edition = types.DatabaseEdition.STANDARD;
|
|
26
|
+
if (firestoreCfg.edition) {
|
|
27
|
+
const upperEdition = firestoreCfg.edition.toUpperCase();
|
|
28
|
+
if (upperEdition !== types.DatabaseEdition.STANDARD &&
|
|
29
|
+
upperEdition !== types.DatabaseEdition.ENTERPRISE) {
|
|
30
|
+
throw new error_1.FirebaseError(`Invalid edition specified for database in firebase.json: ${firestoreCfg.edition}`);
|
|
31
|
+
}
|
|
32
|
+
edition = upperEdition;
|
|
33
|
+
}
|
|
25
34
|
const api = new api_1.FirestoreApi();
|
|
26
35
|
try {
|
|
27
36
|
await api.getDatabase(options.projectId, firestoreCfg.database);
|
|
@@ -34,6 +43,7 @@ async function createDatabase(context, options) {
|
|
|
34
43
|
databaseId: firestoreCfg.database,
|
|
35
44
|
locationId: firestoreCfg.location || "nam5",
|
|
36
45
|
type: types.DatabaseType.FIRESTORE_NATIVE,
|
|
46
|
+
databaseEdition: edition,
|
|
37
47
|
deleteProtectionState: types.DatabaseDeleteProtectionState.DISABLED,
|
|
38
48
|
pointInTimeRecoveryEnablement: types.PointInTimeRecoveryEnablement.DISABLED,
|
|
39
49
|
};
|
|
@@ -93,7 +93,7 @@ function secretVersionName(s) {
|
|
|
93
93
|
return `projects/${s.projectId}/secrets/${s.secret}/versions/${s.version ?? "latest"}`;
|
|
94
94
|
}
|
|
95
95
|
exports.secretVersionName = secretVersionName;
|
|
96
|
-
exports.AllFunctionsPlatforms = ["gcfv1", "gcfv2"];
|
|
96
|
+
exports.AllFunctionsPlatforms = ["gcfv1", "gcfv2", "run"];
|
|
97
97
|
function isHttpsTriggered(triggered) {
|
|
98
98
|
return {}.hasOwnProperty.call(triggered, "httpsTrigger");
|
|
99
99
|
}
|
|
@@ -184,6 +184,7 @@ async function loadExistingBackend(ctx) {
|
|
|
184
184
|
ctx.unreachableRegions = {
|
|
185
185
|
gcfV1: [],
|
|
186
186
|
gcfV2: [],
|
|
187
|
+
run: [],
|
|
187
188
|
};
|
|
188
189
|
const gcfV1Results = await gcf.listAllFunctions(ctx.projectId);
|
|
189
190
|
for (const apiFunction of gcfV1Results.functions) {
|
|
@@ -247,6 +248,11 @@ async function checkAvailability(context, want) {
|
|
|
247
248
|
context.unreachableRegions.gcfV2.join("\n") +
|
|
248
249
|
"\nCloud Functions in these regions won't be deleted.");
|
|
249
250
|
}
|
|
251
|
+
if (context.unreachableRegions?.run.length) {
|
|
252
|
+
utils.logLabeledWarning("functions", "The following Cloud Run regions are currently unreachable:\n" +
|
|
253
|
+
context.unreachableRegions.run.join("\n") +
|
|
254
|
+
"\nCloud Run services in these regions won't be deleted.");
|
|
255
|
+
}
|
|
250
256
|
}
|
|
251
257
|
exports.checkAvailability = checkAvailability;
|
|
252
258
|
function allEndpoints(backend) {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toBackend = exports.envWithTypes = exports.resolveBackend = exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.AllFunctionsPlatforms = exports.isBlockingTriggered = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isCallableTriggered = exports.isHttpsTriggered = exports.of = exports.empty = void 0;
|
|
3
|
+
exports.applyPrefix = exports.toBackend = exports.envWithTypes = exports.resolveBackend = exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.AllFunctionsPlatforms = exports.isBlockingTriggered = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isCallableTriggered = exports.isHttpsTriggered = exports.of = exports.empty = void 0;
|
|
4
4
|
const backend = require("./backend");
|
|
5
5
|
const proto = require("../../gcp/proto");
|
|
6
|
-
const api = require("
|
|
6
|
+
const api = require("../../api");
|
|
7
7
|
const params = require("./params");
|
|
8
8
|
const error_1 = require("../../error");
|
|
9
9
|
const functional_1 = require("../../functional");
|
|
10
|
-
const env_1 = require("../../functions/env");
|
|
11
10
|
const cel_1 = require("./cel");
|
|
12
11
|
function empty() {
|
|
13
12
|
return {
|
|
@@ -56,17 +55,7 @@ exports.AllIngressSettings = [
|
|
|
56
55
|
"ALLOW_INTERNAL_AND_GCLB",
|
|
57
56
|
];
|
|
58
57
|
async function resolveBackend(opts) {
|
|
59
|
-
|
|
60
|
-
paramValues = await params.resolveParams(opts.build.params, opts.firebaseConfig, envWithTypes(opts.build.params, opts.userEnvs), opts.nonInteractive, opts.isEmulator);
|
|
61
|
-
const toWrite = {};
|
|
62
|
-
for (const paramName of Object.keys(paramValues)) {
|
|
63
|
-
const paramValue = paramValues[paramName];
|
|
64
|
-
if (Object.prototype.hasOwnProperty.call(opts.userEnvs, paramName) || paramValue.internal) {
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
toWrite[paramName] = paramValue.toString();
|
|
68
|
-
}
|
|
69
|
-
(0, env_1.writeUserEnvs)(toWrite, opts.userEnvOpt);
|
|
58
|
+
const paramValues = await params.resolveParams(opts.build.params, opts.firebaseConfig, envWithTypes(opts.build.params, opts.userEnvs), opts.nonInteractive, opts.isEmulator);
|
|
70
59
|
return { backend: toBackend(opts.build, paramValues), envs: paramValues };
|
|
71
60
|
}
|
|
72
61
|
exports.resolveBackend = resolveBackend;
|
|
@@ -332,3 +321,28 @@ function discoverTrigger(endpoint, region, r) {
|
|
|
332
321
|
}
|
|
333
322
|
(0, functional_1.assertExhaustive)(endpoint);
|
|
334
323
|
}
|
|
324
|
+
function applyPrefix(build, prefix) {
|
|
325
|
+
if (!prefix) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
const newEndpoints = {};
|
|
329
|
+
for (const [id, endpoint] of Object.entries(build.endpoints)) {
|
|
330
|
+
const newId = `${prefix}-${id}`;
|
|
331
|
+
if (newId.length > 63) {
|
|
332
|
+
throw new error_1.FirebaseError(`Function id '${newId}' exceeds 63 characters after applying prefix '${prefix}'. Please shorten the prefix or function name.`);
|
|
333
|
+
}
|
|
334
|
+
const fnIdRegex = /^[a-zA-Z][a-zA-Z0-9_-]{0,62}$/;
|
|
335
|
+
if (!fnIdRegex.test(newId)) {
|
|
336
|
+
throw new error_1.FirebaseError(`Function id '${newId}' is invalid after applying prefix '${prefix}'. Function names must start with a letter and can contain letters, numbers, underscores, and hyphens, with a maximum length of 63 characters.`);
|
|
337
|
+
}
|
|
338
|
+
newEndpoints[newId] = endpoint;
|
|
339
|
+
if (endpoint.secretEnvironmentVariables) {
|
|
340
|
+
endpoint.secretEnvironmentVariables = endpoint.secretEnvironmentVariables.map((secret) => ({
|
|
341
|
+
...secret,
|
|
342
|
+
secret: `${prefix}-${secret.secret}`,
|
|
343
|
+
}));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
build.endpoints = newEndpoints;
|
|
347
|
+
}
|
|
348
|
+
exports.applyPrefix = applyPrefix;
|
|
@@ -66,9 +66,10 @@ async function uploadCodebase(context, codebase, wantBackend) {
|
|
|
66
66
|
if (storage) {
|
|
67
67
|
source.storage = storage;
|
|
68
68
|
}
|
|
69
|
-
const
|
|
69
|
+
const cfg = (0, projectConfig_1.configForCodebase)(context.config, codebase);
|
|
70
|
+
const label = cfg.source ?? cfg.remoteSource?.dir ?? "remote";
|
|
70
71
|
if (uploads.length) {
|
|
71
|
-
(0, utils_1.
|
|
72
|
+
(0, utils_1.logLabeledSuccess)("functions", `${clc.bold(label)} source uploaded successfully`);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
catch (err) {
|
|
@@ -23,7 +23,7 @@ async function defaultServiceAccount(e) {
|
|
|
23
23
|
if (e.platform === "gcfv1") {
|
|
24
24
|
return `${metadata.projectId}@appspot.gserviceaccount.com`;
|
|
25
25
|
}
|
|
26
|
-
else if (e.platform === "gcfv2") {
|
|
26
|
+
else if (e.platform === "gcfv2" || e.platform === "run") {
|
|
27
27
|
return await (0, computeEngine_1.getDefaultServiceAccount)(metadata.projectNumber);
|
|
28
28
|
}
|
|
29
29
|
(0, functional_1.assertExhaustive)(e.platform);
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isEndpointFiltered = exports.isCodebaseFiltered = exports.groupEndpointsByCodebase = exports.targetCodebases = exports.getFunctionLabel = exports.getHumanFriendlyPlatformName = exports.getEndpointFilters = exports.parseFunctionSelector = exports.endpointMatchesFilter = exports.endpointMatchesAnyFilter = void 0;
|
|
4
4
|
const backend = require("./backend");
|
|
5
5
|
const projectConfig_1 = require("../../functions/projectConfig");
|
|
6
|
+
const functional_1 = require("../../functional");
|
|
6
7
|
function endpointMatchesAnyFilter(endpoint, filters) {
|
|
7
8
|
if (!filters) {
|
|
8
9
|
return true;
|
|
@@ -71,7 +72,13 @@ function getHumanFriendlyPlatformName(platform) {
|
|
|
71
72
|
if (platform === "gcfv1") {
|
|
72
73
|
return "1st Gen";
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
+
else if (platform === "gcfv2") {
|
|
76
|
+
return "2nd Gen";
|
|
77
|
+
}
|
|
78
|
+
else if (platform === "run") {
|
|
79
|
+
return "Cloud Run";
|
|
80
|
+
}
|
|
81
|
+
(0, functional_1.assertExhaustive)(platform);
|
|
75
82
|
}
|
|
76
83
|
exports.getHumanFriendlyPlatformName = getHumanFriendlyPlatformName;
|
|
77
84
|
function getFunctionLabel(fn) {
|
|
@@ -108,6 +108,10 @@ class ParamValue {
|
|
|
108
108
|
return ["true", "y", "yes", "1"].includes(this.rawValue);
|
|
109
109
|
}
|
|
110
110
|
asList() {
|
|
111
|
+
if (this.rawValue.includes("[")) {
|
|
112
|
+
const unquoted = this.rawValue.replace(/'/g, '"');
|
|
113
|
+
return JSON.parse(unquoted);
|
|
114
|
+
}
|
|
111
115
|
return this.rawValue.split(this.delimiter);
|
|
112
116
|
}
|
|
113
117
|
asNumber() {
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ensureAllRequiredAPIsEnabled = exports.warnIfNewGenkitFunctionIsMissingSecrets = exports.loadCodebases = exports.resolveCpuAndConcurrency = exports.inferBlockingDetails = exports.updateEndpointTargetedStatus = exports.inferDetailsFromExisting = exports.prepare = exports.EVENTARC_SOURCE_ENV = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
|
+
const proto = require("../../gcp/proto");
|
|
6
|
+
const experiments = require("../../experiments");
|
|
5
7
|
const api_1 = require("../../api");
|
|
6
8
|
const ensureApiEnabled = require("../../ensureApiEnabled");
|
|
7
9
|
const error_1 = require("../../error");
|
|
@@ -50,11 +52,13 @@ async function prepare(context, options, payload) {
|
|
|
50
52
|
]);
|
|
51
53
|
const firebaseConfig = await functionsConfig.getFirebaseConfig(options);
|
|
52
54
|
context.firebaseConfig = firebaseConfig;
|
|
55
|
+
context.codebaseDeployEvents = {};
|
|
53
56
|
let runtimeConfig = { firebase: firebaseConfig };
|
|
54
|
-
|
|
57
|
+
const allowFunctionsConfig = experiments.isEnabled("dangerouslyAllowFunctionsConfig");
|
|
58
|
+
if (allowFunctionsConfig && checkAPIsEnabled[1]) {
|
|
55
59
|
runtimeConfig = { ...runtimeConfig, ...(await (0, prepareFunctionsUpload_1.getFunctionsConfig)(projectId)) };
|
|
56
60
|
}
|
|
57
|
-
context.
|
|
61
|
+
context.hasRuntimeConfig = Object.keys(runtimeConfig).some((k) => k !== "firebase");
|
|
58
62
|
const wantBuilds = await loadCodebases(context.config, options, firebaseConfig, runtimeConfig, context.filters);
|
|
59
63
|
if (Object.values(wantBuilds).some((b) => b.extensions)) {
|
|
60
64
|
const extContext = {};
|
|
@@ -68,21 +72,23 @@ async function prepare(context, options, payload) {
|
|
|
68
72
|
for (const [codebase, wantBuild] of Object.entries(wantBuilds)) {
|
|
69
73
|
const config = (0, projectConfig_1.configForCodebase)(context.config, codebase);
|
|
70
74
|
const firebaseEnvs = functionsEnv.loadFirebaseEnvs(firebaseConfig, projectId);
|
|
75
|
+
const localCfg = (0, projectConfig_1.requireLocal)(config, "Remote sources are not supported.");
|
|
71
76
|
const userEnvOpt = {
|
|
72
|
-
functionsSource: options.config.path(
|
|
77
|
+
functionsSource: options.config.path(localCfg.source),
|
|
73
78
|
projectId: projectId,
|
|
74
79
|
projectAlias: options.projectAlias,
|
|
75
80
|
};
|
|
81
|
+
proto.convertIfPresent(userEnvOpt, localCfg, "configDir", (cd) => options.config.path(cd));
|
|
76
82
|
const userEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
77
83
|
const envs = { ...userEnvs, ...firebaseEnvs };
|
|
78
84
|
const { backend: wantBackend, envs: resolvedEnvs } = await build.resolveBackend({
|
|
79
85
|
build: wantBuild,
|
|
80
86
|
firebaseConfig,
|
|
81
|
-
userEnvOpt,
|
|
82
87
|
userEnvs,
|
|
83
88
|
nonInteractive: options.nonInteractive,
|
|
84
89
|
isEmulator: false,
|
|
85
90
|
});
|
|
91
|
+
functionsEnv.writeResolvedParams(resolvedEnvs, userEnvs, userEnvOpt);
|
|
86
92
|
let hasEnvsFromParams = false;
|
|
87
93
|
wantBackend.environmentVariables = envs;
|
|
88
94
|
for (const envName of Object.keys(resolvedEnvs)) {
|
|
@@ -96,12 +102,12 @@ async function prepare(context, options, payload) {
|
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
104
|
for (const endpoint of backend.allEndpoints(wantBackend)) {
|
|
99
|
-
endpoint.environmentVariables = { ...wantBackend.environmentVariables };
|
|
105
|
+
endpoint.environmentVariables = { ...(wantBackend.environmentVariables || {}) };
|
|
100
106
|
let resource;
|
|
101
107
|
if (endpoint.platform === "gcfv1") {
|
|
102
108
|
resource = `projects/${endpoint.project}/locations/${endpoint.region}/functions/${endpoint.id}`;
|
|
103
109
|
}
|
|
104
|
-
else if (endpoint.platform === "gcfv2") {
|
|
110
|
+
else if (endpoint.platform === "gcfv2" || endpoint.platform === "run") {
|
|
105
111
|
resource = `projects/${endpoint.project}/locations/${endpoint.region}/services/${endpoint.id}`;
|
|
106
112
|
}
|
|
107
113
|
else {
|
|
@@ -136,23 +142,24 @@ async function prepare(context, options, payload) {
|
|
|
136
142
|
validate.endpointsAreUnique(wantBackends);
|
|
137
143
|
context.sources = {};
|
|
138
144
|
for (const [codebase, wantBackend] of Object.entries(wantBackends)) {
|
|
139
|
-
const
|
|
140
|
-
const
|
|
145
|
+
const cfg = (0, projectConfig_1.configForCodebase)(context.config, codebase);
|
|
146
|
+
const localCfg = (0, projectConfig_1.requireLocal)(cfg, "Remote sources are not supported.");
|
|
147
|
+
const sourceDirName = localCfg.source;
|
|
141
148
|
let sourceDir = options.config.path(sourceDirName);
|
|
142
149
|
const source = {};
|
|
143
150
|
if (backend.someEndpoint(wantBackend, () => true)) {
|
|
144
151
|
(0, utils_1.logLabeledBullet)("functions", `preparing ${clc.bold(sourceDirName)} directory for uploading...`);
|
|
145
152
|
}
|
|
146
|
-
if (
|
|
153
|
+
if (localCfg.isolate === true) {
|
|
147
154
|
sourceDir = await (0, prepareFunctionsUpload_1.runIsolate)(sourceDirName);
|
|
148
155
|
}
|
|
149
156
|
if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv2")) {
|
|
150
|
-
const packagedSource = await (0, prepareFunctionsUpload_1.prepareFunctionsUpload)(sourceDir,
|
|
157
|
+
const packagedSource = await (0, prepareFunctionsUpload_1.prepareFunctionsUpload)(sourceDir, localCfg);
|
|
151
158
|
source.functionsSourceV2 = packagedSource?.pathToSource;
|
|
152
159
|
source.functionsSourceV2Hash = packagedSource?.hash;
|
|
153
160
|
}
|
|
154
161
|
if (backend.someEndpoint(wantBackend, (e) => e.platform === "gcfv1")) {
|
|
155
|
-
const packagedSource = await (0, prepareFunctionsUpload_1.prepareFunctionsUpload)(sourceDir,
|
|
162
|
+
const packagedSource = await (0, prepareFunctionsUpload_1.prepareFunctionsUpload)(sourceDir, localCfg, runtimeConfig);
|
|
156
163
|
source.functionsSourceV1 = packagedSource?.pathToSource;
|
|
157
164
|
source.functionsSourceV1Hash = packagedSource?.hash;
|
|
158
165
|
}
|
|
@@ -310,11 +317,16 @@ async function loadCodebases(config, options, firebaseConfig, runtimeConfig, fil
|
|
|
310
317
|
await runtimeDelegate.build();
|
|
311
318
|
const firebaseEnvs = functionsEnv.loadFirebaseEnvs(firebaseConfig, projectId);
|
|
312
319
|
(0, utils_1.logLabeledBullet)("functions", `Loading and analyzing source code for codebase ${codebase} to determine what to deploy`);
|
|
313
|
-
|
|
320
|
+
const discoveredBuild = await runtimeDelegate.discoverBuild(runtimeConfig, {
|
|
314
321
|
...firebaseEnvs,
|
|
315
322
|
GOOGLE_CLOUD_QUOTA_PROJECT: projectId,
|
|
316
323
|
});
|
|
317
|
-
|
|
324
|
+
discoveredBuild.runtime = codebaseConfig.runtime;
|
|
325
|
+
const prefix = (0, projectConfig_1.isLocalConfig)(codebaseConfig)
|
|
326
|
+
? codebaseConfig.prefix ?? ""
|
|
327
|
+
: "";
|
|
328
|
+
build.applyPrefix(discoveredBuild, prefix);
|
|
329
|
+
wantBuilds[codebase] = discoveredBuild;
|
|
318
330
|
}
|
|
319
331
|
return wantBuilds;
|
|
320
332
|
}
|
|
@@ -130,6 +130,7 @@ function monthlyMinInstanceCost(endpoints) {
|
|
|
130
130
|
const usage = {
|
|
131
131
|
gcfv1: { 1: { ram: 0, cpu: 0 }, 2: { ram: 0, cpu: 0 } },
|
|
132
132
|
gcfv2: { 1: { ram: 0, cpu: 0 }, 2: { ram: 0, cpu: 0 } },
|
|
133
|
+
run: { 1: { ram: 0, cpu: 0 }, 2: { ram: 0, cpu: 0 } },
|
|
133
134
|
};
|
|
134
135
|
for (const endpoint of endpoints) {
|
|
135
136
|
if (endpoint.minInstances === undefined || endpoint.minInstances === null) {
|
|
@@ -147,10 +148,10 @@ function monthlyMinInstanceCost(endpoints) {
|
|
|
147
148
|
}
|
|
148
149
|
else {
|
|
149
150
|
const tier = V2_REGION_TO_TIER[endpoint.region];
|
|
150
|
-
usage[
|
|
151
|
-
usage[
|
|
152
|
-
usage[
|
|
153
|
-
usage[
|
|
151
|
+
usage[endpoint.platform][tier].ram =
|
|
152
|
+
usage[endpoint.platform][tier].ram + ramGb * SECONDS_PER_MONTH * endpoint.minInstances;
|
|
153
|
+
usage[endpoint.platform][tier].cpu =
|
|
154
|
+
usage[endpoint.platform][tier].cpu +
|
|
154
155
|
endpoint.cpu * SECONDS_PER_MONTH * endpoint.minInstances;
|
|
155
156
|
}
|
|
156
157
|
}
|
|
@@ -166,6 +167,12 @@ function monthlyMinInstanceCost(endpoints) {
|
|
|
166
167
|
let v2CpuBill = usage["gcfv2"][1].cpu * exports.V2_RATES.idleVCpu[1] + usage["gcfv2"][2].cpu * exports.V2_RATES.idleVCpu[2];
|
|
167
168
|
v2CpuBill -= exports.V2_FREE_TIER.vCpu * exports.V2_RATES.vCpu[1];
|
|
168
169
|
v2CpuBill = Math.max(v2CpuBill, 0);
|
|
169
|
-
|
|
170
|
+
let runMemoryBill = usage["run"][1].ram * exports.V2_RATES.memoryGb[1] + usage["run"][2].ram * exports.V2_RATES.memoryGb[2];
|
|
171
|
+
runMemoryBill -= exports.V2_FREE_TIER.memoryGb * exports.V2_RATES.memoryGb[1];
|
|
172
|
+
runMemoryBill = Math.max(runMemoryBill, 0);
|
|
173
|
+
let runCpuBill = usage["run"][1].cpu * exports.V2_RATES.idleVCpu[1] + usage["run"][2].cpu * exports.V2_RATES.idleVCpu[2];
|
|
174
|
+
runCpuBill -= exports.V2_FREE_TIER.vCpu * exports.V2_RATES.vCpu[1];
|
|
175
|
+
runCpuBill = Math.max(runCpuBill, 0);
|
|
176
|
+
return v1MemoryBill + v1CpuBill + v2MemoryBill + v2CpuBill + runMemoryBill + runCpuBill;
|
|
170
177
|
}
|
|
171
178
|
exports.monthlyMinInstanceCost = monthlyMinInstanceCost;
|
|
@@ -136,6 +136,11 @@ class Fabricator {
|
|
|
136
136
|
else if (endpoint.platform === "gcfv2") {
|
|
137
137
|
await this.createV2Function(endpoint, scraperV2);
|
|
138
138
|
}
|
|
139
|
+
else if (endpoint.platform === "run") {
|
|
140
|
+
throw new error_1.FirebaseError("Creating new Cloud Run functions is not supported yet.", {
|
|
141
|
+
exit: 1,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
139
144
|
else {
|
|
140
145
|
(0, functional_1.assertExhaustive)(endpoint.platform);
|
|
141
146
|
}
|
|
@@ -154,6 +159,9 @@ class Fabricator {
|
|
|
154
159
|
else if (update.endpoint.platform === "gcfv2") {
|
|
155
160
|
await this.updateV2Function(update.endpoint, scraperV2);
|
|
156
161
|
}
|
|
162
|
+
else if (update.endpoint.platform === "run") {
|
|
163
|
+
throw new error_1.FirebaseError("Updating Cloud Run functions is not supported yet.", { exit: 1 });
|
|
164
|
+
}
|
|
157
165
|
else {
|
|
158
166
|
(0, functional_1.assertExhaustive)(update.endpoint.platform);
|
|
159
167
|
}
|
|
@@ -162,11 +170,15 @@ class Fabricator {
|
|
|
162
170
|
async deleteEndpoint(endpoint) {
|
|
163
171
|
await this.deleteTrigger(endpoint);
|
|
164
172
|
if (endpoint.platform === "gcfv1") {
|
|
165
|
-
|
|
173
|
+
return this.deleteV1Function(endpoint);
|
|
166
174
|
}
|
|
167
|
-
else {
|
|
168
|
-
|
|
175
|
+
else if (endpoint.platform === "gcfv2") {
|
|
176
|
+
return this.deleteV2Function(endpoint);
|
|
169
177
|
}
|
|
178
|
+
else if (endpoint.platform === "run") {
|
|
179
|
+
throw new error_1.FirebaseError("Deleting Cloud Run functions is not supported yet.", { exit: 1 });
|
|
180
|
+
}
|
|
181
|
+
(0, functional_1.assertExhaustive)(endpoint.platform);
|
|
170
182
|
}
|
|
171
183
|
async createV1Function(endpoint, scraper) {
|
|
172
184
|
const sourceUrl = this.sources[endpoint.codebase]?.sourceUrl;
|
|
@@ -499,6 +511,11 @@ class Fabricator {
|
|
|
499
511
|
.catch(rethrowAs(endpoint, "set concurrency"));
|
|
500
512
|
}
|
|
501
513
|
async setTrigger(endpoint) {
|
|
514
|
+
if (endpoint.platform === "run") {
|
|
515
|
+
throw new error_1.FirebaseError("Setting triggers for Cloud Run functions is not supported yet.", {
|
|
516
|
+
exit: 1,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
502
519
|
if (backend.isScheduleTriggered(endpoint)) {
|
|
503
520
|
if (endpoint.platform === "gcfv1") {
|
|
504
521
|
await this.upsertScheduleV1(endpoint);
|
|
@@ -518,6 +535,11 @@ class Fabricator {
|
|
|
518
535
|
}
|
|
519
536
|
}
|
|
520
537
|
async deleteTrigger(endpoint) {
|
|
538
|
+
if (endpoint.platform === "run") {
|
|
539
|
+
throw new error_1.FirebaseError("Deleting triggers for Cloud Run functions is not supported yet.", {
|
|
540
|
+
exit: 1,
|
|
541
|
+
});
|
|
542
|
+
}
|
|
521
543
|
if (backend.isScheduleTriggered(endpoint)) {
|
|
522
544
|
if (endpoint.platform === "gcfv1") {
|
|
523
545
|
await this.deleteScheduleV1(endpoint);
|
|
@@ -80,6 +80,7 @@ async function logAndTrackDeployStats(summary, context) {
|
|
|
80
80
|
fn_deploy_num_successes: totalSuccesses,
|
|
81
81
|
fn_deploy_num_canceled: totalAborts,
|
|
82
82
|
fn_deploy_num_failures: totalErrors,
|
|
83
|
+
has_runtime_config: String(!!context?.hasRuntimeConfig),
|
|
83
84
|
};
|
|
84
85
|
reports.push((0, track_1.trackGA4)("function_deploy_group", fnDeployGroupEvent));
|
|
85
86
|
const avgTime = totalTime / (totalSuccesses + totalErrors);
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.detectFromOutputPath = exports.detectFromPort = exports.detectFromYaml = exports.yamlToBuild = exports.getFunctionDiscoveryTimeout = void 0;
|
|
4
4
|
const node_fetch_1 = require("node-fetch");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const yaml = require("yaml");
|
|
8
|
-
const util_1 = require("util");
|
|
9
8
|
const logger_1 = require("../../../../logger");
|
|
10
|
-
const api = require("
|
|
9
|
+
const api = require("../../../../api");
|
|
11
10
|
const v1alpha1 = require("./v1alpha1");
|
|
12
11
|
const error_1 = require("../../../../error");
|
|
13
|
-
exports.readFileAsync = (0, util_1.promisify)(fs.readFile);
|
|
14
12
|
const TIMEOUT_OVERRIDE_ENV_VAR = "FUNCTIONS_DISCOVERY_TIMEOUT";
|
|
15
13
|
function getFunctionDiscoveryTimeout() {
|
|
16
14
|
return +(process.env[TIMEOUT_OVERRIDE_ENV_VAR] || 0) * 1000;
|
|
@@ -34,7 +32,7 @@ exports.yamlToBuild = yamlToBuild;
|
|
|
34
32
|
async function detectFromYaml(directory, project, runtime) {
|
|
35
33
|
let text;
|
|
36
34
|
try {
|
|
37
|
-
text = await
|
|
35
|
+
text = await fs.promises.readFile(path.join(directory, "functions.yaml"), "utf8");
|
|
38
36
|
}
|
|
39
37
|
catch (err) {
|
|
40
38
|
if (err.code === "ENOENT") {
|
|
@@ -96,3 +94,52 @@ async function detectFromPort(port, project, runtime, initialDelay = 0, timeout
|
|
|
96
94
|
return yamlToBuild(parsed, project, api.functionsDefaultRegion(), runtime);
|
|
97
95
|
}
|
|
98
96
|
exports.detectFromPort = detectFromPort;
|
|
97
|
+
async function detectFromOutputPath(childProcess, manifestPath, project, runtime, timeout = 10000) {
|
|
98
|
+
return new Promise((resolve, reject) => {
|
|
99
|
+
let stderrBuffer = "";
|
|
100
|
+
let resolved = false;
|
|
101
|
+
const discoveryTimeout = getFunctionDiscoveryTimeout() || timeout;
|
|
102
|
+
const timer = setTimeout(() => {
|
|
103
|
+
if (!resolved) {
|
|
104
|
+
resolved = true;
|
|
105
|
+
reject(new error_1.FirebaseError(`User code failed to load. Cannot determine backend specification. Timeout after ${discoveryTimeout}ms`));
|
|
106
|
+
}
|
|
107
|
+
}, discoveryTimeout);
|
|
108
|
+
childProcess.stderr?.on("data", (chunk) => {
|
|
109
|
+
stderrBuffer += chunk.toString();
|
|
110
|
+
});
|
|
111
|
+
childProcess.on("exit", async (code) => {
|
|
112
|
+
if (!resolved) {
|
|
113
|
+
clearTimeout(timer);
|
|
114
|
+
resolved = true;
|
|
115
|
+
if (code !== 0 && code !== null) {
|
|
116
|
+
const errorMessage = stderrBuffer.trim() ?? `Discovery process exited with code ${code}`;
|
|
117
|
+
reject(new error_1.FirebaseError(`User code failed to load. Cannot determine backend specification.\n${errorMessage}`));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
try {
|
|
121
|
+
const manifestContent = await fs.promises.readFile(manifestPath, "utf8");
|
|
122
|
+
const parsed = yaml.parse(manifestContent);
|
|
123
|
+
resolve(yamlToBuild(parsed, project, api.functionsDefaultRegion(), runtime));
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
if (err.code === "ENOENT") {
|
|
127
|
+
reject(new error_1.FirebaseError(`Discovery process completed but no function manifest was found at ${manifestPath}`));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
reject(new error_1.FirebaseError(`Failed to read or parse manifest file: ${err.message}`));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
childProcess.on("error", (err) => {
|
|
137
|
+
if (!resolved) {
|
|
138
|
+
clearTimeout(timer);
|
|
139
|
+
resolved = true;
|
|
140
|
+
reject(new error_1.FirebaseError(`Discovery process failed: ${err.message}`));
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
exports.detectFromOutputPath = detectFromOutputPath;
|