firebase-tools-with-isolate 13.15.0-0 → 13.26.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 +3 -1
- package/lib/apiv2.js +10 -3
- package/lib/appdistribution/client.js +62 -8
- package/lib/appdistribution/distribution.js +1 -1
- package/lib/apphosting/backend.js +299 -0
- package/lib/apphosting/config.js +31 -8
- package/lib/apphosting/githubConnections.js +70 -22
- package/lib/apphosting/index.js +3 -312
- package/lib/apphosting/rollout.js +138 -0
- package/lib/apphosting/secrets/index.js +70 -5
- package/lib/apphosting/utils.js +41 -0
- package/lib/apphosting/yaml.js +82 -0
- package/lib/archiveDirectory.js +1 -1
- package/lib/auth.js +31 -5
- package/lib/bin/firebase.js +2 -2
- package/lib/command.js +18 -4
- package/lib/commands/appdistribution-distribute.js +4 -4
- package/lib/commands/{appdistribution-group-create.js → appdistribution-groups-create.js} +2 -1
- package/lib/commands/{appdistribution-group-delete.js → appdistribution-groups-delete.js} +3 -2
- package/lib/commands/appdistribution-groups-list.js +55 -0
- package/lib/commands/appdistribution-testers-list.js +52 -0
- package/lib/commands/appdistribution-testers-remove.js +1 -1
- package/lib/commands/apphosting-backends-create.js +4 -4
- package/lib/commands/apphosting-backends-delete.js +7 -15
- package/lib/commands/apphosting-backends-get.js +1 -1
- package/lib/commands/apphosting-config-export.js +51 -0
- package/lib/commands/apphosting-repos-create.js +23 -0
- package/lib/commands/apphosting-rollouts-create.js +14 -15
- package/lib/commands/apphosting-secrets-grantaccess.js +2 -2
- package/lib/commands/database-import.js +4 -2
- package/lib/commands/database-push.js +4 -2
- package/lib/commands/database-set.js +4 -2
- package/lib/commands/database-settings-get.js +1 -1
- package/lib/commands/database-settings-set.js +1 -1
- package/lib/commands/dataconnect-sdk-generate.js +4 -1
- package/lib/commands/dataconnect-services-list.js +4 -3
- package/lib/commands/dataconnect-sql-diff.js +1 -1
- package/lib/commands/dataconnect-sql-grant.js +37 -0
- package/lib/commands/dataconnect-sql-migrate.js +1 -1
- package/lib/commands/dataconnect-sql-shell.js +115 -0
- package/lib/commands/deploy.js +5 -1
- package/lib/commands/emulators-start.js +4 -1
- package/lib/commands/ext-dev-init.js +2 -2
- package/lib/commands/ext-dev-list.js +1 -1
- package/lib/commands/ext-dev-register.js +2 -2
- package/lib/commands/ext-dev-upload.js +2 -2
- package/lib/commands/ext-dev-usage.js +2 -2
- package/lib/commands/ext-info.js +3 -1
- package/lib/commands/ext-install.js +2 -2
- package/lib/commands/ext-sdk-install.js +88 -0
- package/lib/commands/ext.js +1 -0
- package/lib/commands/firestore-databases-restore.js +39 -1
- package/lib/commands/functions-secrets-access.js +2 -4
- package/lib/commands/index.js +15 -2
- package/lib/commands/init.js +25 -15
- package/lib/commands/setup-emulators-dataconnect.js +0 -13
- package/lib/commands/use.js +1 -1
- package/lib/config.js +14 -4
- package/lib/crashlytics/buildToolsJarHelper.js +2 -2
- package/lib/dataconnect/client.js +3 -2
- package/lib/dataconnect/dataplaneClient.js +12 -9
- package/lib/dataconnect/ensureApis.js +6 -1
- package/lib/dataconnect/fileUtils.js +29 -12
- package/lib/dataconnect/freeTrial.js +45 -9
- package/lib/dataconnect/load.js +3 -1
- package/lib/dataconnect/provisionCloudSql.js +41 -24
- package/lib/dataconnect/schemaMigration.js +215 -74
- package/lib/dataconnect/types.js +4 -1
- package/lib/dataconnect/webhook.js +32 -0
- package/lib/deploy/dataconnect/deploy.js +18 -15
- package/lib/deploy/dataconnect/prepare.js +41 -0
- package/lib/deploy/dataconnect/release.js +16 -7
- package/lib/deploy/extensions/deploy.js +3 -1
- package/lib/deploy/extensions/deploymentSummary.js +7 -3
- package/lib/deploy/extensions/planner.js +95 -5
- package/lib/deploy/extensions/prepare.js +89 -42
- package/lib/deploy/extensions/release.js +17 -10
- package/lib/deploy/extensions/tasks.js +32 -21
- package/lib/deploy/firestore/prepare.js +9 -0
- package/lib/deploy/firestore/release.js +3 -6
- package/lib/deploy/functions/build.js +5 -5
- package/lib/deploy/functions/checkIam.js +7 -2
- package/lib/deploy/functions/deploy.js +12 -12
- package/lib/deploy/functions/ensure.js +11 -3
- package/lib/deploy/functions/params.js +5 -3
- package/lib/deploy/functions/prepare.js +18 -3
- package/lib/deploy/functions/release/index.js +4 -0
- package/lib/deploy/functions/release/planner.js +2 -1
- package/lib/deploy/functions/runtimes/discovery/index.js +6 -2
- package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +46 -0
- package/lib/deploy/functions/runtimes/node/index.js +5 -0
- package/lib/deploy/functions/services/auth.js +34 -3
- package/lib/deploy/functions/services/index.js +2 -0
- package/lib/deploy/index.js +8 -5
- package/lib/deploy/lifecycleHooks.js +2 -1
- package/lib/emulator/apphosting/config.js +27 -0
- package/lib/emulator/apphosting/index.js +38 -0
- package/lib/emulator/apphosting/serve.js +50 -0
- package/lib/emulator/apphosting/utils.js +18 -0
- package/lib/emulator/auth/handlers.js +27 -0
- package/lib/emulator/auth/operations.js +41 -2
- package/lib/emulator/auth/state.js +2 -1
- package/lib/emulator/commandUtils.js +8 -3
- package/lib/emulator/constants.js +11 -1
- package/lib/emulator/controller.js +59 -6
- package/lib/emulator/dataconnect/pg-gateway/auth/base-auth-flow.js +11 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/cert.js +58 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/index.js +22 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/md5.js +124 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/password.js +54 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/sasl-mechanism.js +34 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/sasl/scram-sha-256.js +270 -0
- package/lib/emulator/dataconnect/pg-gateway/auth/trust.js +2 -0
- package/lib/emulator/dataconnect/pg-gateway/backend-error.js +75 -0
- package/lib/emulator/dataconnect/pg-gateway/buffer-reader.js +54 -0
- package/lib/emulator/dataconnect/pg-gateway/buffer-writer.js +79 -0
- package/lib/emulator/dataconnect/pg-gateway/connection.js +315 -0
- package/lib/emulator/dataconnect/pg-gateway/connection.types.js +8 -0
- package/lib/emulator/dataconnect/pg-gateway/crypto.js +40 -0
- package/lib/emulator/dataconnect/pg-gateway/duplex.js +53 -0
- package/lib/emulator/dataconnect/pg-gateway/index.js +27 -0
- package/lib/emulator/dataconnect/pg-gateway/message-buffer.js +82 -0
- package/lib/emulator/dataconnect/pg-gateway/message-codes.js +52 -0
- package/lib/emulator/dataconnect/pg-gateway/platforms/node/index.js +16 -0
- package/lib/emulator/dataconnect/pg-gateway/polyfills/readable-stream-async-iterator.js +35 -0
- package/lib/emulator/dataconnect/pg-gateway/utils.js +40 -0
- package/lib/emulator/dataconnect/pgliteServer.js +95 -0
- package/lib/emulator/dataconnectEmulator.js +58 -75
- package/lib/emulator/dataconnectToolkitController.js +44 -0
- package/lib/emulator/downloadableEmulators.js +30 -19
- package/lib/emulator/emulatorLogger.js +3 -0
- package/lib/emulator/env.js +3 -0
- package/lib/emulator/eventarcEmulator.js +1 -1
- package/lib/emulator/extensionsEmulator.js +38 -6
- package/lib/emulator/functionsEmulator.js +115 -42
- package/lib/emulator/functionsEmulatorShared.js +18 -1
- package/lib/emulator/functionsRuntimeWorker.js +2 -1
- package/lib/emulator/hub.js +13 -9
- package/lib/emulator/hubExport.js +10 -3
- package/lib/emulator/loggingEmulator.js +2 -2
- package/lib/emulator/portUtils.js +11 -11
- package/lib/emulator/registry.js +2 -0
- package/lib/emulator/storage/persistence.js +2 -2
- package/lib/emulator/storage/rules/runtime.js +1 -1
- package/lib/emulator/taskQueue.js +348 -0
- package/lib/emulator/tasksEmulator.js +240 -0
- package/lib/emulator/types.js +6 -0
- package/lib/emulator/ui.js +51 -25
- package/lib/error.js +31 -1
- package/lib/experiments.js +5 -0
- package/lib/extensions/askUserForEventsConfig.js +18 -8
- package/lib/extensions/askUserForParam.js +2 -1
- package/lib/extensions/displayExtensionInfo.js +5 -5
- package/lib/extensions/emulator/triggerHelper.js +1 -1
- package/lib/extensions/extensionsApi.js +15 -11
- package/lib/extensions/extensionsHelper.js +39 -8
- package/lib/extensions/localHelper.js +32 -1
- package/lib/extensions/refs.js +26 -11
- package/lib/extensions/runtimes/common.js +215 -0
- package/lib/extensions/runtimes/node.js +401 -0
- package/lib/extensions/types.js +67 -1
- package/lib/extensions/warnings.js +5 -2
- package/lib/firestore/api.js +2 -1
- package/lib/firestore/checkDatabaseType.js +10 -3
- package/lib/firestore/delete.js +11 -0
- package/lib/firestore/options.js +7 -0
- package/lib/frameworks/angular/index.js +15 -3
- package/lib/frameworks/constants.js +2 -2
- package/lib/frameworks/flutter/index.js +6 -6
- package/lib/frameworks/flutter/utils.js +34 -1
- package/lib/frameworks/next/constants.js +1 -1
- package/lib/frameworks/next/index.js +45 -17
- package/lib/frameworks/next/utils.js +57 -4
- package/lib/frameworks/vite/index.js +2 -2
- package/lib/fsutils.js +13 -1
- package/lib/functions/constants.js +4 -0
- package/lib/functions/events/v1.js +9 -2
- package/lib/gcp/apphosting.js +1 -1
- package/lib/gcp/cloudmonitoring.js +3 -3
- package/lib/gcp/cloudsql/cloudsqladmin.js +32 -20
- package/lib/gcp/cloudsql/connect.js +49 -37
- package/lib/gcp/cloudsql/interactive.js +49 -0
- package/lib/gcp/cloudsql/permissions.js +165 -0
- package/lib/gcp/devConnect.js +38 -1
- package/lib/gcp/firestore.js +5 -1
- package/lib/gcp/secretManager.js +12 -5
- package/lib/getProjectNumber.js +1 -1
- package/lib/init/features/apphosting.js +15 -0
- package/lib/init/features/dataconnect/index.js +166 -121
- package/lib/init/features/dataconnect/sdk.js +90 -81
- package/lib/init/features/emulators.js +2 -15
- package/lib/init/features/firestore/index.js +20 -1
- package/lib/init/features/firestore/indexes.js +4 -4
- package/lib/init/features/genkit/index.js +444 -0
- package/lib/init/features/hosting/index.js +2 -2
- package/lib/init/features/index.js +1 -1
- package/lib/init/features/project.js +6 -6
- package/lib/init/features/storage.js +0 -2
- package/lib/init/index.js +1 -0
- package/lib/init/spawn.js +23 -2
- package/lib/logger.js +2 -2
- package/lib/management/projects.js +24 -4
- package/lib/projectUtils.js +1 -1
- package/lib/prompt.js +22 -1
- package/lib/rc.js +1 -8
- package/lib/requireAuth.js +19 -5
- package/lib/requireDatabaseInstance.js +1 -1
- package/lib/requirePermissions.js +1 -1
- package/lib/responseToError.js +5 -2
- package/lib/rulesDeploy.js +1 -1
- package/lib/templates.js +2 -2
- package/lib/utils.js +16 -11
- package/lib/vsCodeUtils.js +8 -0
- package/package.json +8 -7
- package/schema/connector-yaml.json +57 -17
- package/schema/firebase-config.json +36 -0
- package/templates/extensions/javascript/package.lint.json +2 -2
- package/templates/extensions/javascript/package.nolint.json +2 -2
- package/templates/extensions/typescript/package.lint.json +2 -2
- package/templates/extensions/typescript/package.nolint.json +2 -2
- package/templates/genkit/firebase.0.9.0.template +57 -0
- package/templates/init/apphosting/apphosting.yaml +23 -0
- package/templates/init/dataconnect/connector.yaml +4 -3
- package/templates/init/dataconnect/dataconnect-fdccompatiblemode.yaml +12 -0
- package/templates/init/dataconnect/dataconnect.yaml +6 -6
- package/templates/init/dataconnect/mutations.gql +44 -29
- package/templates/init/dataconnect/queries.gql +65 -38
- package/templates/init/dataconnect/schema.gql +38 -21
- package/templates/init/functions/javascript/package.lint.json +2 -2
- package/templates/init/functions/javascript/package.nolint.json +2 -2
- package/templates/init/functions/typescript/package.lint.json +2 -2
- package/templates/init/functions/typescript/package.nolint.json +2 -2
- package/lib/ensureCloudResourceLocation.js +0 -12
- package/lib/init/features/genkit.js +0 -53
|
@@ -11,9 +11,19 @@ const build_1 = require("../../dataconnect/build");
|
|
|
11
11
|
const ensureApis_1 = require("../../dataconnect/ensureApis");
|
|
12
12
|
const requireTosAcceptance_1 = require("../../requireTosAcceptance");
|
|
13
13
|
const firedata_1 = require("../../gcp/firedata");
|
|
14
|
+
const provisionCloudSql_1 = require("../../dataconnect/provisionCloudSql");
|
|
15
|
+
const cloudbilling_1 = require("../../gcp/cloudbilling");
|
|
16
|
+
const names_1 = require("../../dataconnect/names");
|
|
14
17
|
const error_1 = require("../../error");
|
|
18
|
+
const types_1 = require("../../dataconnect/types");
|
|
19
|
+
const schemaMigration_1 = require("../../dataconnect/schemaMigration");
|
|
20
|
+
const node_path_1 = require("node:path");
|
|
21
|
+
const freeTrial_1 = require("../../dataconnect/freeTrial");
|
|
15
22
|
async function default_1(context, options) {
|
|
16
23
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
24
|
+
if (!(await (0, cloudbilling_1.checkBillingEnabled)(projectId))) {
|
|
25
|
+
throw new error_1.FirebaseError((0, freeTrial_1.upgradeInstructions)(projectId));
|
|
26
|
+
}
|
|
17
27
|
await (0, ensureApis_1.ensureApis)(projectId);
|
|
18
28
|
await (0, requireTosAcceptance_1.requireTosAcceptance)(firedata_1.DATA_CONNECT_TOS_ID)(options);
|
|
19
29
|
const serviceCfgs = (0, fileUtils_1.readFirebaseJson)(options.config);
|
|
@@ -41,6 +51,37 @@ async function default_1(context, options) {
|
|
|
41
51
|
filters,
|
|
42
52
|
};
|
|
43
53
|
utils.logLabeledBullet("dataconnect", `Successfully prepared schema and connectors`);
|
|
54
|
+
if (options.dryRun) {
|
|
55
|
+
for (const si of serviceInfos) {
|
|
56
|
+
await (0, schemaMigration_1.diffSchema)(si.schema, si.dataConnectYaml.schema.datasource.postgresql?.schemaValidation);
|
|
57
|
+
}
|
|
58
|
+
utils.logLabeledBullet("dataconnect", "Checking for CloudSQL resources...");
|
|
59
|
+
await Promise.all(serviceInfos
|
|
60
|
+
.filter((si) => {
|
|
61
|
+
return !filters || filters?.some((f) => si.dataConnectYaml.serviceId === f.serviceId);
|
|
62
|
+
})
|
|
63
|
+
.map(async (s) => {
|
|
64
|
+
const postgresDatasource = s.schema.datasources.find((d) => d.postgresql);
|
|
65
|
+
if (postgresDatasource) {
|
|
66
|
+
const instanceId = postgresDatasource.postgresql?.cloudSql.instance.split("/").pop();
|
|
67
|
+
const databaseId = postgresDatasource.postgresql?.database;
|
|
68
|
+
if (!instanceId || !databaseId) {
|
|
69
|
+
return Promise.resolve();
|
|
70
|
+
}
|
|
71
|
+
const enableGoogleMlIntegration = (0, types_1.requiresVector)(s.deploymentMetadata);
|
|
72
|
+
return (0, provisionCloudSql_1.provisionCloudSql)({
|
|
73
|
+
projectId,
|
|
74
|
+
locationId: (0, names_1.parseServiceName)(s.serviceName).location,
|
|
75
|
+
instanceId,
|
|
76
|
+
databaseId,
|
|
77
|
+
configYamlPath: (0, node_path_1.join)(s.sourceDirectory, "dataconnect.yaml"),
|
|
78
|
+
enableGoogleMlIntegration,
|
|
79
|
+
waitForCreation: true,
|
|
80
|
+
dryRun: options.dryRun,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
44
85
|
logger_1.logger.debug(JSON.stringify(context.dataconnect, null, 2));
|
|
45
86
|
return;
|
|
46
87
|
}
|
|
@@ -4,7 +4,9 @@ const utils = require("../../utils");
|
|
|
4
4
|
const client_1 = require("../../dataconnect/client");
|
|
5
5
|
const prompts_1 = require("../../dataconnect/prompts");
|
|
6
6
|
const schemaMigration_1 = require("../../dataconnect/schemaMigration");
|
|
7
|
+
const projectUtils_1 = require("../../projectUtils");
|
|
7
8
|
async function default_1(context, options) {
|
|
9
|
+
const project = (0, projectUtils_1.needProjectId)(options);
|
|
8
10
|
const serviceInfos = context.dataconnect.serviceInfos;
|
|
9
11
|
const filters = context.dataconnect.filters;
|
|
10
12
|
const wantSchemas = serviceInfos
|
|
@@ -14,17 +16,21 @@ async function default_1(context, options) {
|
|
|
14
16
|
return f.serviceId === si.dataConnectYaml.serviceId && (f.schemaOnly || f.fullService);
|
|
15
17
|
}));
|
|
16
18
|
})
|
|
17
|
-
.map((s) =>
|
|
19
|
+
.map((s) => ({
|
|
20
|
+
schema: s.schema,
|
|
21
|
+
validationMode: s.dataConnectYaml.schema.datasource.postgresql?.schemaValidation,
|
|
22
|
+
}));
|
|
18
23
|
if (wantSchemas.length) {
|
|
19
|
-
utils.logLabeledBullet("dataconnect", "
|
|
24
|
+
utils.logLabeledBullet("dataconnect", "Deploying Data Connect schemas...");
|
|
20
25
|
for (const s of wantSchemas) {
|
|
21
26
|
await (0, schemaMigration_1.migrateSchema)({
|
|
22
27
|
options,
|
|
23
|
-
schema: s,
|
|
28
|
+
schema: s.schema,
|
|
24
29
|
validateOnly: false,
|
|
30
|
+
schemaValidation: s.validationMode,
|
|
25
31
|
});
|
|
26
32
|
}
|
|
27
|
-
utils.logLabeledBullet("dataconnect", "Schemas
|
|
33
|
+
utils.logLabeledBullet("dataconnect", "Schemas deployed.");
|
|
28
34
|
}
|
|
29
35
|
let wantConnectors = [];
|
|
30
36
|
wantConnectors = wantConnectors.concat(...serviceInfos.map((si) => si.connectorInfo
|
|
@@ -41,7 +47,7 @@ async function default_1(context, options) {
|
|
|
41
47
|
? []
|
|
42
48
|
: haveConnectors.filter((h) => !wantConnectors.some((w) => w.name === h.name));
|
|
43
49
|
if (wantConnectors.length) {
|
|
44
|
-
utils.logLabeledBullet("dataconnect", "
|
|
50
|
+
utils.logLabeledBullet("dataconnect", "Deploying connectors...");
|
|
45
51
|
await Promise.all(wantConnectors.map(async (c) => {
|
|
46
52
|
await (0, client_1.upsertConnector)(c);
|
|
47
53
|
utils.logLabeledSuccess("dataconnect", `Deployed connector ${c.name}`);
|
|
@@ -49,9 +55,12 @@ async function default_1(context, options) {
|
|
|
49
55
|
for (const c of connectorsToDelete) {
|
|
50
56
|
await (0, prompts_1.promptDeleteConnector)(options, c.name);
|
|
51
57
|
}
|
|
52
|
-
utils.logLabeledBullet("dataconnect", "Connectors
|
|
58
|
+
utils.logLabeledBullet("dataconnect", "Connectors deployed.");
|
|
53
59
|
}
|
|
54
|
-
|
|
60
|
+
else {
|
|
61
|
+
utils.logLabeledBullet("dataconnect", "No connectors to deploy.");
|
|
62
|
+
}
|
|
63
|
+
utils.logLabeledSuccess("dataconnect", `Deployment complete! View your deployed schema and connectors at ${utils.consoleUrl(project, "/dataconnect")}`);
|
|
55
64
|
return;
|
|
56
65
|
}
|
|
57
66
|
exports.default = default_1;
|
|
@@ -17,7 +17,9 @@ async function deploy(context, options, payload) {
|
|
|
17
17
|
...(payload.instancesToUpdate ?? []),
|
|
18
18
|
...(payload.instancesToConfigure ?? []),
|
|
19
19
|
]);
|
|
20
|
-
|
|
20
|
+
if (context.have) {
|
|
21
|
+
await (0, secrets_1.handleSecretParams)(payload, context.have, options.nonInteractive);
|
|
22
|
+
}
|
|
21
23
|
const errorHandler = new errors_1.ErrorHandler();
|
|
22
24
|
const validationQueue = new queue_1.default({
|
|
23
25
|
retries: 5,
|
|
@@ -10,7 +10,7 @@ const humanReadableUpdate = (from, to) => {
|
|
|
10
10
|
to.ref &&
|
|
11
11
|
from.ref.publisherId === to.ref.publisherId &&
|
|
12
12
|
from.ref.extensionId === to.ref.extensionId) {
|
|
13
|
-
return `\t${clc.bold(from.instanceId)} (${refs.toExtensionVersionRef(from.ref)} => ${to.ref?.version})`;
|
|
13
|
+
return `\t${clc.bold(from.instanceId)} (${refs.toExtensionVersionRef(from.ref)} => ${to.ref?.version || ""})`;
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
16
|
const fromRef = from.ref
|
|
@@ -31,6 +31,9 @@ function updatesSummary(toUpdate, have) {
|
|
|
31
31
|
const instancesToUpdate = toUpdate
|
|
32
32
|
.map((to) => {
|
|
33
33
|
const from = have.find((exists) => exists.instanceId === to.instanceId);
|
|
34
|
+
if (!from) {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
34
37
|
return humanReadableUpdate(from, to);
|
|
35
38
|
})
|
|
36
39
|
.join("\n");
|
|
@@ -46,10 +49,11 @@ function configuresSummary(toConfigure) {
|
|
|
46
49
|
: "";
|
|
47
50
|
}
|
|
48
51
|
exports.configuresSummary = configuresSummary;
|
|
49
|
-
function deletesSummary(toDelete) {
|
|
52
|
+
function deletesSummary(toDelete, isDynamic) {
|
|
50
53
|
const instancesToDelete = toDelete.map((s) => `\t${(0, exports.humanReadable)(s)}`).join("\n");
|
|
54
|
+
const definedLocation = isDynamic ? "your local source code" : "'firebase.json'";
|
|
51
55
|
return toDelete.length
|
|
52
|
-
? `The following extension instances are not
|
|
56
|
+
? `The following extension instances are found in your project but do not exist in ${definedLocation}:\n${instancesToDelete}\n`
|
|
53
57
|
: "";
|
|
54
58
|
}
|
|
55
59
|
exports.deletesSummary = deletesSummary;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveVersion = exports.want = exports.have = exports.getExtensionSpec = exports.getExtension = exports.getExtensionVersion = void 0;
|
|
3
|
+
exports.resolveVersion = exports.want = exports.wantDynamic = exports.have = exports.haveDynamic = exports.getExtensionSpec = exports.getExtension = exports.getExtensionVersion = void 0;
|
|
4
4
|
const semver = require("semver");
|
|
5
5
|
const extensionsApi = require("../../extensions/extensionsApi");
|
|
6
6
|
const refs = require("../../extensions/refs");
|
|
@@ -11,6 +11,7 @@ const manifest_1 = require("../../extensions/manifest");
|
|
|
11
11
|
const paramHelper_1 = require("../../extensions/paramHelper");
|
|
12
12
|
const specHelper_1 = require("../../extensions/emulator/specHelper");
|
|
13
13
|
const functional_1 = require("../../functional");
|
|
14
|
+
const askUserForEventsConfig_1 = require("../../extensions/askUserForEventsConfig");
|
|
14
15
|
async function getExtensionVersion(i) {
|
|
15
16
|
if (!i.extensionVersion) {
|
|
16
17
|
if (!i.ref) {
|
|
@@ -45,20 +46,57 @@ async function getExtensionSpec(i) {
|
|
|
45
46
|
throw new error_1.FirebaseError("InstanceSpec had no ref or localPath, unable to get extensionSpec");
|
|
46
47
|
}
|
|
47
48
|
}
|
|
49
|
+
if (!i.extensionSpec) {
|
|
50
|
+
throw new error_1.FirebaseError("Internal error getting extension");
|
|
51
|
+
}
|
|
48
52
|
return i.extensionSpec;
|
|
49
53
|
}
|
|
50
54
|
exports.getExtensionSpec = getExtensionSpec;
|
|
55
|
+
async function haveDynamic(projectId) {
|
|
56
|
+
return (await extensionsApi.listInstances(projectId))
|
|
57
|
+
.filter((i) => i.labels?.createdBy === "SDK")
|
|
58
|
+
.map((i) => {
|
|
59
|
+
const instanceId = i.name.split("/").pop();
|
|
60
|
+
if (!instanceId) {
|
|
61
|
+
throw new error_1.FirebaseError(`Internal error getting instanceId from ${i.name}`);
|
|
62
|
+
}
|
|
63
|
+
const dep = {
|
|
64
|
+
instanceId,
|
|
65
|
+
params: i.config.params,
|
|
66
|
+
systemParams: i.config.systemParams ?? {},
|
|
67
|
+
allowedEventTypes: i.config.allowedEventTypes,
|
|
68
|
+
eventarcChannel: i.config.eventarcChannel,
|
|
69
|
+
etag: i.etag,
|
|
70
|
+
labels: i.labels,
|
|
71
|
+
};
|
|
72
|
+
if (i.config.extensionRef) {
|
|
73
|
+
const ref = refs.parse(i.config.extensionRef);
|
|
74
|
+
dep.ref = ref;
|
|
75
|
+
dep.ref.version = i.config.extensionVersion;
|
|
76
|
+
}
|
|
77
|
+
return dep;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
exports.haveDynamic = haveDynamic;
|
|
51
81
|
async function have(projectId) {
|
|
52
|
-
|
|
53
|
-
|
|
82
|
+
return (await extensionsApi.listInstances(projectId))
|
|
83
|
+
.filter((i) => !(i.labels?.createdBy === "SDK"))
|
|
84
|
+
.map((i) => {
|
|
85
|
+
const instanceId = i.name.split("/").pop();
|
|
86
|
+
if (!instanceId) {
|
|
87
|
+
throw new error_1.FirebaseError(`Internal error getting instanceId from ${i.name}`);
|
|
88
|
+
}
|
|
54
89
|
const dep = {
|
|
55
|
-
instanceId
|
|
90
|
+
instanceId,
|
|
56
91
|
params: i.config.params,
|
|
57
92
|
systemParams: i.config.systemParams ?? {},
|
|
58
93
|
allowedEventTypes: i.config.allowedEventTypes,
|
|
59
94
|
eventarcChannel: i.config.eventarcChannel,
|
|
60
95
|
etag: i.etag,
|
|
61
96
|
};
|
|
97
|
+
if (i.labels) {
|
|
98
|
+
dep.labels = i.labels;
|
|
99
|
+
}
|
|
62
100
|
if (i.config.extensionRef) {
|
|
63
101
|
const ref = refs.parse(i.config.extensionRef);
|
|
64
102
|
dep.ref = ref;
|
|
@@ -68,9 +106,61 @@ async function have(projectId) {
|
|
|
68
106
|
});
|
|
69
107
|
}
|
|
70
108
|
exports.have = have;
|
|
109
|
+
async function wantDynamic(args) {
|
|
110
|
+
const instanceSpecs = [];
|
|
111
|
+
const errors = [];
|
|
112
|
+
if (!args.extensions) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
for (const [instanceId, ext] of Object.entries(args.extensions)) {
|
|
116
|
+
const autoPopulatedParams = await (0, extensionsHelper_1.getFirebaseProjectParams)(args.projectId, args.emulatorMode);
|
|
117
|
+
const subbedParams = (0, extensionsHelper_1.substituteParams)(ext.params, autoPopulatedParams);
|
|
118
|
+
const eventarcChannel = ext.params["_EVENT_ARC_REGION"]
|
|
119
|
+
? (0, askUserForEventsConfig_1.getEventArcChannel)(args.projectId, ext.params["_EVENT_ARC_REGION"])
|
|
120
|
+
: undefined;
|
|
121
|
+
delete subbedParams["_EVENT_ARC_REGION"];
|
|
122
|
+
const subbedSecretParams = await (0, extensionsHelper_1.substituteSecretParams)(args.projectNumber, subbedParams);
|
|
123
|
+
const [systemParams, params] = (0, functional_1.partitionRecord)(subbedSecretParams, paramHelper_1.isSystemParam);
|
|
124
|
+
const allowedEventTypes = ext.events.length ? ext.events : undefined;
|
|
125
|
+
if (allowedEventTypes && !eventarcChannel) {
|
|
126
|
+
errors.push(new error_1.FirebaseError("EventArcRegion must be specified if event handlers are defined"));
|
|
127
|
+
}
|
|
128
|
+
if (ext.localPath) {
|
|
129
|
+
instanceSpecs.push({
|
|
130
|
+
instanceId,
|
|
131
|
+
localPath: ext.localPath,
|
|
132
|
+
params,
|
|
133
|
+
systemParams,
|
|
134
|
+
allowedEventTypes,
|
|
135
|
+
eventarcChannel,
|
|
136
|
+
labels: ext.labels,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else if (ext.ref) {
|
|
140
|
+
instanceSpecs.push({
|
|
141
|
+
instanceId,
|
|
142
|
+
ref: refs.parse(ext.ref),
|
|
143
|
+
params,
|
|
144
|
+
systemParams,
|
|
145
|
+
allowedEventTypes,
|
|
146
|
+
eventarcChannel,
|
|
147
|
+
labels: ext.labels,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (errors.length) {
|
|
152
|
+
const messages = errors.map((err) => `- ${err.message}`).join("\n");
|
|
153
|
+
throw new error_1.FirebaseError(`Errors while reading 'extensions' in app code\n${messages}`);
|
|
154
|
+
}
|
|
155
|
+
return instanceSpecs;
|
|
156
|
+
}
|
|
157
|
+
exports.wantDynamic = wantDynamic;
|
|
71
158
|
async function want(args) {
|
|
72
159
|
const instanceSpecs = [];
|
|
73
160
|
const errors = [];
|
|
161
|
+
if (!args.extensions) {
|
|
162
|
+
return [];
|
|
163
|
+
}
|
|
74
164
|
for (const e of Object.entries(args.extensions)) {
|
|
75
165
|
try {
|
|
76
166
|
const instanceId = e[0];
|
|
@@ -115,7 +205,7 @@ async function want(args) {
|
|
|
115
205
|
}
|
|
116
206
|
}
|
|
117
207
|
catch (err) {
|
|
118
|
-
logger_1.logger.debug(`Got error reading extensions entry ${e}: ${err}`);
|
|
208
|
+
logger_1.logger.debug(`Got error reading extensions entry ${e[0]} (${e[1]}): ${(0, error_1.getErrMsg)(err)}`);
|
|
119
209
|
errors.push(err);
|
|
120
210
|
}
|
|
121
211
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prepare = void 0;
|
|
3
|
+
exports.prepare = exports.prepareDynamicExtensions = void 0;
|
|
4
4
|
const planner = require("./planner");
|
|
5
5
|
const deploymentSummary = require("./deploymentSummary");
|
|
6
6
|
const prompt = require("../../prompt");
|
|
@@ -16,31 +16,36 @@ const warnings_1 = require("../../extensions/warnings");
|
|
|
16
16
|
const etags_1 = require("../../extensions/etags");
|
|
17
17
|
const v2FunctionHelper_1 = require("./v2FunctionHelper");
|
|
18
18
|
const tos_1 = require("../../extensions/tos");
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const common_1 = require("../../extensions/runtimes/common");
|
|
20
|
+
const functionsDeployHelper_1 = require("../functions/functionsDeployHelper");
|
|
21
|
+
const matchesInstanceId = (dep) => (test) => {
|
|
22
|
+
return dep.instanceId === test.instanceId;
|
|
23
|
+
};
|
|
24
|
+
const isUpdate = (dep) => (test) => {
|
|
25
|
+
return dep.instanceId === test.instanceId && !refs.equal(dep.ref, test.ref);
|
|
26
|
+
};
|
|
27
|
+
const isConfigure = (dep) => (test) => {
|
|
28
|
+
return dep.instanceId === test.instanceId && refs.equal(dep.ref, test.ref);
|
|
29
|
+
};
|
|
30
|
+
async function prepareHelper(context, options, payload, wantExtensions, haveExtensions, isDynamic) {
|
|
21
31
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
await (0, extensionsHelper_1.ensureExtensionsApiEnabled)(options);
|
|
25
|
-
await (0, requirePermissions_1.requirePermissions)(options, ["firebaseextensions.instances.list"]);
|
|
26
|
-
context.have = await planner.have(projectId);
|
|
27
|
-
context.want = await planner.want({
|
|
28
|
-
projectId,
|
|
29
|
-
projectNumber,
|
|
30
|
-
aliases,
|
|
31
|
-
projectDir: options.config.projectDir,
|
|
32
|
-
extensions: options.config.get("extensions"),
|
|
33
|
-
});
|
|
32
|
+
context.want = wantExtensions;
|
|
33
|
+
context.have = haveExtensions;
|
|
34
34
|
const etagsChanged = (0, etags_1.detectEtagChanges)(options.rc, projectId, context.have);
|
|
35
35
|
if (etagsChanged.length) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
const wantChangedIds = wantExtensions
|
|
37
|
+
.map((e) => e.instanceId)
|
|
38
|
+
.filter((id) => etagsChanged.includes(id));
|
|
39
|
+
if (wantChangedIds.length) {
|
|
40
|
+
(0, warnings_1.outOfBandChangesWarning)(wantChangedIds, isDynamic);
|
|
41
|
+
if (!(await prompt.confirm({
|
|
42
|
+
message: `Do you wish to continue deploying these extension instances?`,
|
|
43
|
+
default: false,
|
|
44
|
+
nonInteractive: options.nonInteractive,
|
|
45
|
+
force: options.force,
|
|
46
|
+
}))) {
|
|
47
|
+
throw new error_1.FirebaseError("Deployment cancelled");
|
|
48
|
+
}
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
const usingSecrets = await Promise.all(context.want?.map(secrets_1.checkSpecForSecrets));
|
|
@@ -79,15 +84,20 @@ async function prepare(context, options, payload) {
|
|
|
79
84
|
logger_1.logger.info(deploymentSummary.configuresSummary(payload.instancesToConfigure));
|
|
80
85
|
}
|
|
81
86
|
if (payload.instancesToDelete.length) {
|
|
82
|
-
logger_1.logger.info(deploymentSummary.deletesSummary(payload.instancesToDelete));
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
logger_1.logger.info(deploymentSummary.deletesSummary(payload.instancesToDelete, isDynamic));
|
|
88
|
+
if (options.dryRun) {
|
|
89
|
+
logger_1.logger.info("On your next deploy, you will be asked if you want to delete these instances.");
|
|
90
|
+
logger_1.logger.info("If you deploy --force, they will be deleted.");
|
|
91
|
+
}
|
|
92
|
+
if (!options.dryRun &&
|
|
93
|
+
!(await prompt.confirm({
|
|
94
|
+
message: `Would you like to delete ${payload.instancesToDelete
|
|
95
|
+
.map((i) => i.instanceId)
|
|
96
|
+
.join(", ")}?`,
|
|
97
|
+
default: false,
|
|
98
|
+
nonInteractive: options.nonInteractive,
|
|
99
|
+
force: options.force,
|
|
100
|
+
}))) {
|
|
91
101
|
payload.instancesToDelete = [];
|
|
92
102
|
}
|
|
93
103
|
else {
|
|
@@ -95,15 +105,52 @@ async function prepare(context, options, payload) {
|
|
|
95
105
|
}
|
|
96
106
|
}
|
|
97
107
|
await (0, requirePermissions_1.requirePermissions)(options, permissionsNeeded);
|
|
98
|
-
|
|
108
|
+
if (options.dryRun) {
|
|
109
|
+
const appDevTos = await (0, tos_1.getAppDeveloperTOSStatus)(projectId);
|
|
110
|
+
if (!appDevTos.lastAcceptedVersion) {
|
|
111
|
+
logger_1.logger.info("On your next deploy, you will be asked to accept the Firebase Extensions App Developer Terms of Service");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
await (0, tos_1.acceptLatestAppDeveloperTOS)(options, projectId, context.want.map((i) => i.instanceId));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async function prepareDynamicExtensions(context, options, payload, builds) {
|
|
119
|
+
const filters = (0, functionsDeployHelper_1.getEndpointFilters)(options);
|
|
120
|
+
const extensions = (0, common_1.extractExtensionsFromBuilds)(builds, filters);
|
|
121
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
122
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
123
|
+
await (0, extensionsHelper_1.ensureExtensionsApiEnabled)(options);
|
|
124
|
+
await (0, requirePermissions_1.requirePermissions)(options, ["firebaseextensions.instances.list"]);
|
|
125
|
+
let haveExtensions = await planner.haveDynamic(projectId);
|
|
126
|
+
haveExtensions = haveExtensions.filter((e) => (0, common_1.extensionMatchesAnyFilter)(e.labels?.codebase, e.instanceId, filters));
|
|
127
|
+
if (Object.keys(extensions).length === 0 && haveExtensions.length === 0) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const dynamicWant = await planner.wantDynamic({
|
|
131
|
+
projectId,
|
|
132
|
+
projectNumber,
|
|
133
|
+
extensions,
|
|
134
|
+
});
|
|
135
|
+
return prepareHelper(context, options, payload, dynamicWant, haveExtensions, true);
|
|
136
|
+
}
|
|
137
|
+
exports.prepareDynamicExtensions = prepareDynamicExtensions;
|
|
138
|
+
async function prepare(context, options, payload) {
|
|
139
|
+
context.extensionsStartTime = Date.now();
|
|
140
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
141
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
142
|
+
const aliases = (0, projectUtils_1.getAliases)(options, projectId);
|
|
143
|
+
const projectDir = options.config.projectDir;
|
|
144
|
+
await (0, extensionsHelper_1.ensureExtensionsApiEnabled)(options);
|
|
145
|
+
await (0, requirePermissions_1.requirePermissions)(options, ["firebaseextensions.instances.list"]);
|
|
146
|
+
const wantExtensions = await planner.want({
|
|
147
|
+
projectId,
|
|
148
|
+
projectNumber,
|
|
149
|
+
aliases,
|
|
150
|
+
projectDir,
|
|
151
|
+
extensions: options.config.get("extensions", {}),
|
|
152
|
+
});
|
|
153
|
+
const haveExtensions = await planner.have(projectId);
|
|
154
|
+
return prepareHelper(context, options, payload, wantExtensions, haveExtensions, false);
|
|
99
155
|
}
|
|
100
156
|
exports.prepare = prepare;
|
|
101
|
-
const matchesInstanceId = (dep) => (test) => {
|
|
102
|
-
return dep.instanceId === test.instanceId;
|
|
103
|
-
};
|
|
104
|
-
const isUpdate = (dep) => (test) => {
|
|
105
|
-
return dep.instanceId === test.instanceId && !refs.equal(dep.ref, test.ref);
|
|
106
|
-
};
|
|
107
|
-
const isConfigure = (dep) => (test) => {
|
|
108
|
-
return dep.instanceId === test.instanceId && refs.equal(dep.ref, test.ref);
|
|
109
|
-
};
|
|
@@ -10,6 +10,12 @@ const projectUtils_1 = require("../../projectUtils");
|
|
|
10
10
|
const etags_1 = require("../../extensions/etags");
|
|
11
11
|
const track_1 = require("../../track");
|
|
12
12
|
async function release(context, options, payload) {
|
|
13
|
+
if (!payload.instancesToCreate &&
|
|
14
|
+
!payload.instancesToUpdate &&
|
|
15
|
+
!payload.instancesToConfigure &&
|
|
16
|
+
!payload.instancesToDelete) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
13
19
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
14
20
|
const errorHandler = new errors_1.ErrorHandler();
|
|
15
21
|
const deploymentQueue = new queue_1.default({
|
|
@@ -17,20 +23,20 @@ async function release(context, options, payload) {
|
|
|
17
23
|
concurrency: 5,
|
|
18
24
|
handler: tasks.extensionsDeploymentHandler(errorHandler),
|
|
19
25
|
});
|
|
20
|
-
for (const
|
|
21
|
-
const task = tasks.
|
|
26
|
+
for (const inst of payload.instancesToConfigure ?? []) {
|
|
27
|
+
const task = tasks.configureExtensionInstanceTask(projectId, inst);
|
|
22
28
|
void deploymentQueue.run(task);
|
|
23
29
|
}
|
|
24
|
-
for (const
|
|
25
|
-
const task = tasks.
|
|
30
|
+
for (const inst of payload.instancesToDelete ?? []) {
|
|
31
|
+
const task = tasks.deleteExtensionInstanceTask(projectId, inst);
|
|
26
32
|
void deploymentQueue.run(task);
|
|
27
33
|
}
|
|
28
|
-
for (const
|
|
29
|
-
const task = tasks.
|
|
34
|
+
for (const inst of payload.instancesToCreate ?? []) {
|
|
35
|
+
const task = tasks.createExtensionInstanceTask(projectId, inst);
|
|
30
36
|
void deploymentQueue.run(task);
|
|
31
37
|
}
|
|
32
|
-
for (const
|
|
33
|
-
const task = tasks.
|
|
38
|
+
for (const inst of payload.instancesToUpdate ?? []) {
|
|
39
|
+
const task = tasks.updateExtensionInstanceTask(projectId, inst);
|
|
34
40
|
void deploymentQueue.run(task);
|
|
35
41
|
}
|
|
36
42
|
const deploymentPromise = deploymentQueue.wait();
|
|
@@ -46,8 +52,9 @@ async function release(context, options, payload) {
|
|
|
46
52
|
errors: errorHandler.errors.length ?? 0,
|
|
47
53
|
interactive: options.nonInteractive ? "false" : "true",
|
|
48
54
|
}, duration);
|
|
49
|
-
const
|
|
50
|
-
|
|
55
|
+
const have = await planner.have(projectId);
|
|
56
|
+
const dynamicHave = await planner.haveDynamic(projectId);
|
|
57
|
+
(0, etags_1.saveEtags)(options.rc, projectId, have.concat(dynamicHave));
|
|
51
58
|
if (errorHandler.hasErrors()) {
|
|
52
59
|
errorHandler.print();
|
|
53
60
|
throw new error_1.FirebaseError(`Extensions deployment failed.`);
|
|
@@ -7,6 +7,7 @@ const extensionsApi = require("../../extensions/extensionsApi");
|
|
|
7
7
|
const extensionsHelper_1 = require("../../extensions/extensionsHelper");
|
|
8
8
|
const refs = require("../../extensions/refs");
|
|
9
9
|
const utils = require("../../utils");
|
|
10
|
+
const types_1 = require("../../extensions/types");
|
|
10
11
|
const isRetryable = (err) => err.status === 429 || err.status === 409;
|
|
11
12
|
function extensionsDeploymentHandler(errorHandler) {
|
|
12
13
|
return async (task) => {
|
|
@@ -26,34 +27,37 @@ function extensionsDeploymentHandler(errorHandler) {
|
|
|
26
27
|
exports.extensionsDeploymentHandler = extensionsDeploymentHandler;
|
|
27
28
|
function createExtensionInstanceTask(projectId, instanceSpec, validateOnly = false) {
|
|
28
29
|
const run = async () => {
|
|
30
|
+
if (!validateOnly) {
|
|
31
|
+
utils.logLabeledBullet("extensions", `Creating ${clc.bold(instanceSpec.instanceId)} extension instance`);
|
|
32
|
+
}
|
|
33
|
+
const createArgs = {
|
|
34
|
+
projectId,
|
|
35
|
+
instanceId: instanceSpec.instanceId,
|
|
36
|
+
params: instanceSpec.params,
|
|
37
|
+
systemParams: instanceSpec.systemParams,
|
|
38
|
+
allowedEventTypes: instanceSpec.allowedEventTypes,
|
|
39
|
+
eventarcChannel: instanceSpec.eventarcChannel,
|
|
40
|
+
validateOnly,
|
|
41
|
+
labels: instanceSpec.labels,
|
|
42
|
+
};
|
|
29
43
|
if (instanceSpec.ref) {
|
|
30
|
-
|
|
31
|
-
projectId,
|
|
32
|
-
instanceId: instanceSpec.instanceId,
|
|
33
|
-
params: instanceSpec.params,
|
|
34
|
-
systemParams: instanceSpec.systemParams,
|
|
35
|
-
extensionVersionRef: refs.toExtensionVersionRef(instanceSpec.ref),
|
|
36
|
-
allowedEventTypes: instanceSpec.allowedEventTypes,
|
|
37
|
-
eventarcChannel: instanceSpec.eventarcChannel,
|
|
38
|
-
validateOnly,
|
|
39
|
-
});
|
|
44
|
+
createArgs.extensionVersionRef = refs.toExtensionVersionRef(instanceSpec.ref);
|
|
40
45
|
}
|
|
41
46
|
else if (instanceSpec.localPath) {
|
|
42
|
-
|
|
43
|
-
await extensionsApi.createInstance({
|
|
44
|
-
projectId,
|
|
45
|
-
instanceId: instanceSpec.instanceId,
|
|
46
|
-
params: instanceSpec.params,
|
|
47
|
-
systemParams: instanceSpec.systemParams,
|
|
48
|
-
extensionSource,
|
|
49
|
-
allowedEventTypes: instanceSpec.allowedEventTypes,
|
|
50
|
-
eventarcChannel: instanceSpec.eventarcChannel,
|
|
51
|
-
validateOnly,
|
|
52
|
-
});
|
|
47
|
+
createArgs.extensionSource = await (0, extensionsHelper_1.createSourceFromLocation)(projectId, instanceSpec.localPath);
|
|
53
48
|
}
|
|
54
49
|
else {
|
|
55
50
|
throw new error_1.FirebaseError(`Tried to create extension instance ${instanceSpec.instanceId} without a ref or a local path. This should never happen.`);
|
|
56
51
|
}
|
|
52
|
+
try {
|
|
53
|
+
await extensionsApi.createInstance(createArgs);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
if ((0, types_1.isObject)(err) && err.status === 409) {
|
|
57
|
+
throw new error_1.FirebaseError(`Failed to create extension instance. Extension instance ${clc.bold(instanceSpec.instanceId)} already exists.`);
|
|
58
|
+
}
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
57
61
|
printSuccess(instanceSpec.instanceId, "create", validateOnly);
|
|
58
62
|
return;
|
|
59
63
|
};
|
|
@@ -66,6 +70,9 @@ function createExtensionInstanceTask(projectId, instanceSpec, validateOnly = fal
|
|
|
66
70
|
exports.createExtensionInstanceTask = createExtensionInstanceTask;
|
|
67
71
|
function updateExtensionInstanceTask(projectId, instanceSpec, validateOnly = false) {
|
|
68
72
|
const run = async () => {
|
|
73
|
+
if (!validateOnly) {
|
|
74
|
+
utils.logLabeledBullet("extensions", `Updating ${clc.bold(instanceSpec.instanceId)} extension instance`);
|
|
75
|
+
}
|
|
69
76
|
if (instanceSpec.ref) {
|
|
70
77
|
await extensionsApi.updateInstanceFromRegistry({
|
|
71
78
|
projectId,
|
|
@@ -108,6 +115,9 @@ function updateExtensionInstanceTask(projectId, instanceSpec, validateOnly = fal
|
|
|
108
115
|
exports.updateExtensionInstanceTask = updateExtensionInstanceTask;
|
|
109
116
|
function configureExtensionInstanceTask(projectId, instanceSpec, validateOnly = false) {
|
|
110
117
|
const run = async () => {
|
|
118
|
+
if (!validateOnly) {
|
|
119
|
+
utils.logLabeledBullet("extensions", `Configuring ${clc.bold(instanceSpec.instanceId)} extension instance`);
|
|
120
|
+
}
|
|
111
121
|
if (instanceSpec.ref) {
|
|
112
122
|
await extensionsApi.configureInstance({
|
|
113
123
|
projectId,
|
|
@@ -138,6 +148,7 @@ function configureExtensionInstanceTask(projectId, instanceSpec, validateOnly =
|
|
|
138
148
|
exports.configureExtensionInstanceTask = configureExtensionInstanceTask;
|
|
139
149
|
function deleteExtensionInstanceTask(projectId, instanceSpec) {
|
|
140
150
|
const run = async () => {
|
|
151
|
+
utils.logLabeledBullet("extensions", `Deleting ${clc.bold(instanceSpec.instanceId)} extension instance`);
|
|
141
152
|
await extensionsApi.deleteInstance(projectId, instanceSpec.instanceId);
|
|
142
153
|
printSuccess(instanceSpec.instanceId, "delete", false);
|
|
143
154
|
return;
|
|
@@ -5,6 +5,7 @@ const loadCJSON_1 = require("../../loadCJSON");
|
|
|
5
5
|
const rulesDeploy_1 = require("../../rulesDeploy");
|
|
6
6
|
const utils = require("../../utils");
|
|
7
7
|
const fsConfig = require("../../firestore/fsConfig");
|
|
8
|
+
const logger_1 = require("../../logger");
|
|
8
9
|
function prepareRules(context, rulesDeploy, databaseId, rulesFile) {
|
|
9
10
|
rulesDeploy.addFile(rulesFile);
|
|
10
11
|
context.firestore.rules.push({
|
|
@@ -57,5 +58,13 @@ async function default_1(context, options) {
|
|
|
57
58
|
if (context.firestore.rules.length > 0) {
|
|
58
59
|
await rulesDeploy.compile();
|
|
59
60
|
}
|
|
61
|
+
const rulesContext = context?.firestore?.rules;
|
|
62
|
+
for (const ruleContext of rulesContext) {
|
|
63
|
+
const databaseId = ruleContext.databaseId;
|
|
64
|
+
const rulesFile = ruleContext.rulesFile;
|
|
65
|
+
if (!rulesFile) {
|
|
66
|
+
logger_1.logger.error(`Invalid firestore config for ${databaseId} database: ${JSON.stringify(options.config.src.firestore)}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
60
69
|
}
|
|
61
70
|
exports.default = default_1;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const rulesDeploy_1 = require("../../rulesDeploy");
|
|
4
|
-
|
|
5
|
-
async function default_1(context, options) {
|
|
4
|
+
async function default_1(context) {
|
|
6
5
|
const rulesDeploy = context?.firestore?.rulesDeploy;
|
|
7
6
|
if (!context.firestoreRules || !rulesDeploy) {
|
|
8
7
|
return;
|
|
@@ -11,11 +10,9 @@ async function default_1(context, options) {
|
|
|
11
10
|
await Promise.all(rulesContext.map(async (ruleContext) => {
|
|
12
11
|
const databaseId = ruleContext.databaseId;
|
|
13
12
|
const rulesFile = ruleContext.rulesFile;
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
return;
|
|
13
|
+
if (rulesFile) {
|
|
14
|
+
return rulesDeploy.release(rulesFile, rulesDeploy_1.RulesetServiceType.CLOUD_FIRESTORE, databaseId);
|
|
17
15
|
}
|
|
18
|
-
return rulesDeploy.release(rulesFile, rulesDeploy_1.RulesetServiceType.CLOUD_FIRESTORE, databaseId);
|
|
19
16
|
}));
|
|
20
17
|
}
|
|
21
18
|
exports.default = default_1;
|