firebase-tools-with-isolate 13.7.3 → 13.9.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.
Files changed (106) hide show
  1. package/lib/api.js +18 -8
  2. package/lib/apiv2.js +19 -13
  3. package/lib/apphosting/app.js +40 -59
  4. package/lib/apphosting/constants.js +2 -2
  5. package/lib/apphosting/githubConnections.js +7 -9
  6. package/lib/apphosting/index.js +122 -58
  7. package/lib/apphosting/repo.js +3 -3
  8. package/lib/apphosting/secrets/index.js +7 -1
  9. package/lib/checkValidTargetFilters.js +8 -1
  10. package/lib/commands/apphosting-backends-create.js +7 -6
  11. package/lib/commands/apphosting-backends-delete.js +24 -28
  12. package/lib/commands/apphosting-backends-list.js +4 -5
  13. package/lib/commands/apphosting-secrets-access.js +1 -1
  14. package/lib/commands/apphosting-secrets-grantaccess.js +11 -7
  15. package/lib/commands/apphosting-secrets-set.js +1 -1
  16. package/lib/commands/dataconnect-sdk-generate.js +37 -0
  17. package/lib/commands/dataconnect-services-list.js +80 -0
  18. package/lib/commands/dataconnect-sql-diff.js +25 -0
  19. package/lib/commands/dataconnect-sql-migrate.js +45 -0
  20. package/lib/commands/deploy.js +27 -1
  21. package/lib/commands/index.js +11 -0
  22. package/lib/commands/init.js +10 -3
  23. package/lib/commands/setup-emulators-dataconnect.js +12 -0
  24. package/lib/config.js +1 -0
  25. package/lib/dataconnect/build.js +22 -0
  26. package/lib/dataconnect/checkIam.js +30 -0
  27. package/lib/dataconnect/client.js +112 -0
  28. package/lib/dataconnect/dataplaneClient.js +16 -0
  29. package/lib/dataconnect/ensureApis.js +12 -0
  30. package/lib/dataconnect/errors.js +29 -0
  31. package/lib/dataconnect/fileUtils.js +92 -0
  32. package/lib/dataconnect/filters.js +45 -0
  33. package/lib/dataconnect/freeTrial.js +22 -0
  34. package/lib/dataconnect/graphqlError.js +12 -0
  35. package/lib/dataconnect/load.js +40 -0
  36. package/lib/dataconnect/names.js +46 -0
  37. package/lib/dataconnect/prompts.js +20 -0
  38. package/lib/dataconnect/provisionCloudSql.js +74 -0
  39. package/lib/dataconnect/schemaMigration.js +246 -0
  40. package/lib/dataconnect/types.js +22 -0
  41. package/lib/deploy/dataconnect/deploy.js +75 -0
  42. package/lib/deploy/dataconnect/index.js +9 -0
  43. package/lib/deploy/dataconnect/prepare.js +33 -0
  44. package/lib/deploy/dataconnect/release.js +65 -0
  45. package/lib/deploy/functions/checkIam.js +4 -34
  46. package/lib/deploy/functions/release/fabricator.js +7 -2
  47. package/lib/deploy/index.js +2 -0
  48. package/lib/downloadUtils.js +2 -2
  49. package/lib/emulator/constants.js +3 -0
  50. package/lib/emulator/controller.js +39 -12
  51. package/lib/emulator/dataconnectEmulator.js +95 -0
  52. package/lib/emulator/download.js +1 -1
  53. package/lib/emulator/downloadableEmulators.js +57 -8
  54. package/lib/emulator/portUtils.js +3 -3
  55. package/lib/emulator/registry.js +6 -1
  56. package/lib/emulator/types.js +3 -0
  57. package/lib/experiments.js +19 -6
  58. package/lib/extensions/emulator/specHelper.js +5 -39
  59. package/lib/frameworks/next/index.js +6 -4
  60. package/lib/frameworks/next/utils.js +2 -1
  61. package/lib/functions/python.js +4 -3
  62. package/lib/gcp/apphosting.js +11 -1
  63. package/lib/gcp/cloudsql/cloudsqladmin.js +174 -0
  64. package/lib/gcp/cloudsql/connect.js +144 -0
  65. package/lib/gcp/cloudsql/fbToolsAuthClient.js +44 -0
  66. package/lib/gcp/devConnect.js +1 -1
  67. package/lib/gcp/firedata.js +27 -0
  68. package/lib/gcp/iam.js +33 -1
  69. package/lib/gcp/secretManager.js +1 -1
  70. package/lib/hosting/interactive.js +4 -0
  71. package/lib/init/features/dataconnect/index.js +166 -0
  72. package/lib/init/features/emulators.js +13 -1
  73. package/lib/init/features/functions/index.js +19 -3
  74. package/lib/init/features/functions/npm-dependencies.js +12 -23
  75. package/lib/init/features/genkit.js +53 -0
  76. package/lib/init/features/index.js +5 -1
  77. package/lib/init/index.js +2 -0
  78. package/lib/init/spawn.js +23 -0
  79. package/lib/logger.js +22 -2
  80. package/lib/operation-poller.js +8 -2
  81. package/lib/rc.js +9 -1
  82. package/lib/requireAuth.js +1 -8
  83. package/lib/requireTosAcceptance.js +22 -0
  84. package/lib/utils.js +55 -4
  85. package/package.json +9 -3
  86. package/schema/connector-yaml.json +54 -0
  87. package/schema/dataconnect-yaml.json +72 -0
  88. package/schema/firebase-config.json +103 -0
  89. package/templates/extensions/javascript/package.lint.json +2 -2
  90. package/templates/extensions/javascript/package.nolint.json +2 -2
  91. package/templates/extensions/typescript/package.lint.json +2 -2
  92. package/templates/extensions/typescript/package.nolint.json +2 -2
  93. package/templates/init/dataconnect/connector.yaml +2 -0
  94. package/templates/init/dataconnect/dataconnect.yaml +10 -0
  95. package/templates/init/dataconnect/mutations.gql +30 -0
  96. package/templates/init/dataconnect/queries.gql +51 -0
  97. package/templates/init/dataconnect/schema.gql +28 -0
  98. package/templates/init/functions/javascript/_gitignore +2 -1
  99. package/templates/init/functions/javascript/package.lint.json +2 -2
  100. package/templates/init/functions/javascript/package.nolint.json +2 -2
  101. package/templates/init/functions/python/_gitignore +1 -0
  102. package/templates/init/functions/typescript/_gitignore +1 -0
  103. package/templates/init/functions/typescript/package.lint.json +2 -2
  104. package/templates/init/functions/typescript/package.nolint.json +2 -2
  105. package/lib/monospace/index.js +0 -82
  106. /package/lib/{monospace/interfaces.js → gcp/cloudsql/types.js} +0 -0
@@ -271,6 +271,97 @@
271
271
  }
272
272
  ]
273
273
  },
274
+ "dataconnect": {
275
+ "anyOf": [
276
+ {
277
+ "additionalProperties": false,
278
+ "properties": {
279
+ "location": {
280
+ "type": "string"
281
+ },
282
+ "postdeploy": {
283
+ "anyOf": [
284
+ {
285
+ "items": {
286
+ "type": "string"
287
+ },
288
+ "type": "array"
289
+ },
290
+ {
291
+ "type": "string"
292
+ }
293
+ ]
294
+ },
295
+ "predeploy": {
296
+ "anyOf": [
297
+ {
298
+ "items": {
299
+ "type": "string"
300
+ },
301
+ "type": "array"
302
+ },
303
+ {
304
+ "type": "string"
305
+ }
306
+ ]
307
+ },
308
+ "source": {
309
+ "type": "string"
310
+ }
311
+ },
312
+ "required": [
313
+ "location",
314
+ "source"
315
+ ],
316
+ "type": "object"
317
+ },
318
+ {
319
+ "items": {
320
+ "additionalProperties": false,
321
+ "properties": {
322
+ "location": {
323
+ "type": "string"
324
+ },
325
+ "postdeploy": {
326
+ "anyOf": [
327
+ {
328
+ "items": {
329
+ "type": "string"
330
+ },
331
+ "type": "array"
332
+ },
333
+ {
334
+ "type": "string"
335
+ }
336
+ ]
337
+ },
338
+ "predeploy": {
339
+ "anyOf": [
340
+ {
341
+ "items": {
342
+ "type": "string"
343
+ },
344
+ "type": "array"
345
+ },
346
+ {
347
+ "type": "string"
348
+ }
349
+ ]
350
+ },
351
+ "source": {
352
+ "type": "string"
353
+ }
354
+ },
355
+ "required": [
356
+ "location",
357
+ "source"
358
+ ],
359
+ "type": "object"
360
+ },
361
+ "type": "array"
362
+ }
363
+ ]
364
+ },
274
365
  "emulators": {
275
366
  "additionalProperties": false,
276
367
  "properties": {
@@ -298,6 +389,18 @@
298
389
  },
299
390
  "type": "object"
300
391
  },
392
+ "dataconnect": {
393
+ "additionalProperties": false,
394
+ "properties": {
395
+ "host": {
396
+ "type": "string"
397
+ },
398
+ "port": {
399
+ "type": "number"
400
+ }
401
+ },
402
+ "type": "object"
403
+ },
301
404
  "eventarc": {
302
405
  "additionalProperties": false,
303
406
  "properties": {
@@ -3,8 +3,8 @@
3
3
  "description": "Greet the world",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
- "firebase-admin": "^11.5.0",
7
- "firebase-functions": "^4.2.0"
6
+ "firebase-admin": "^12.1.0",
7
+ "firebase-functions": "^5.0.0"
8
8
  },
9
9
  "devDependencies": {
10
10
  "eslint": "^8.15.1",
@@ -3,8 +3,8 @@
3
3
  "description": "Greet the world",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
- "firebase-admin": "^11.5.0",
7
- "firebase-functions": "^4.2.0"
6
+ "firebase-admin": "^12.1.0",
7
+ "firebase-functions": "^5.0.0"
8
8
  },
9
9
  "devDependencies": {
10
10
  "axios": "^1.3.2",
@@ -10,8 +10,8 @@
10
10
  },
11
11
  "main": "lib/index.js",
12
12
  "dependencies": {
13
- "firebase-admin": "^11.5.0",
14
- "firebase-functions": "^4.2.0"
13
+ "firebase-admin": "^12.1.0",
14
+ "firebase-functions": "^5.0.0"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@types/chai": "^4.3.4",
@@ -8,8 +8,8 @@
8
8
  },
9
9
  "main": "lib/index.js",
10
10
  "dependencies": {
11
- "firebase-admin": "^11.5.0",
12
- "firebase-functions": "^4.2.0"
11
+ "firebase-admin": "^12.1.0",
12
+ "firebase-functions": "^5.0.0"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/chai": "^4.3.4",
@@ -0,0 +1,2 @@
1
+ connectorId: "__connectorId__"
2
+ authMode: "PUBLIC"
@@ -0,0 +1,10 @@
1
+ specVersion: "v1alpha"
2
+ serviceId: "__serviceId__"
3
+ schema:
4
+ source: "./schema"
5
+ datasource:
6
+ postgresql:
7
+ database: "__cloudSqlDatabase__"
8
+ cloudSql:
9
+ instanceId: "__cloudSqlInstanceId__"
10
+ connectorDirs: ["./connector"]
@@ -0,0 +1,30 @@
1
+ # # Example mutations for a simple email app
2
+
3
+ # mutation CreateUser($uid: String, $name: String, $address: String) @auth(level: NO_ACCESS) {
4
+ ## <type>_insert lets you create a new row in your table.
5
+ # user_insert(data: {
6
+ # uid: $uid,
7
+ # name: $name,
8
+ # address: $address
9
+ # })
10
+ # }
11
+ # mutation CreateEmail($content: String, $subject: String, $fromUid: String) @auth(level: PUBLIC) {
12
+ # email_insert(data: {
13
+ # text: $content,
14
+ # subject: $subject,
15
+ # fromUid: $fromUid,
16
+ ## Server values let your service populate data for you
17
+ ## Here, we use sent_date: { today: true } to set 'sent' to today's date.
18
+ # sent_date: { today: true }
19
+ # })
20
+ # }
21
+ # mutation CreateRecipient($emailId: UUID, $uid: String) @auth(level: PUBLIC) {
22
+ # recipient_insert(data: {
23
+ # emailId: $emailId,
24
+ # userUid: $uid
25
+ # })
26
+ # }
27
+ # mutation DeleteEmail($emailId: UUID, $uid: String) @auth(level: PUBLIC) {
28
+ ## <type>_ delete lets you delete rows from your table.
29
+ # recipient_delete(key: {emailId: $emailId, userUid: $uid})
30
+ # }
@@ -0,0 +1,51 @@
1
+ # # Example queries for a simple email app.
2
+
3
+ ## @auth() directives control who can call each operation.
4
+ ## Only admins should be able to list all users, so we use NO_ACCESS
5
+ # query ListUsers @auth(level: NO_ACCESS) {
6
+ # users { uid, name, email: address }
7
+ # }
8
+
9
+ ## Everyone should be able to see their inbox though, so we use PUBLIC
10
+ # query ListInbox(
11
+ # $uid: String
12
+ # ) @auth(level: PUBLIC) {
13
+ ## where allows you to filter lists
14
+ ## Here, we use it to filter to only emails where this user is one of the recipients.
15
+ # emails(where: {
16
+ # users_via_Recipient: {
17
+ # exist: { uid: { eq: $uid }
18
+ # }}
19
+ # }) {
20
+ # id subject sent
21
+ # content: text
22
+ # sender: from { name email: address uid }
23
+
24
+ ## <field>_on_<foreign_key_field> makes it easy to grab info from another table
25
+ ## Here, we use it to grab all the recipients of the email.
26
+ # to: recipients_on_email {
27
+ # user { name email: address uid }
28
+ # }
29
+ # }
30
+ # }
31
+
32
+ # query GetUidByEmail($emails: [String!]) @auth(level: PUBLIC) {
33
+ # users(where: { address: { in: $emails } }) {
34
+ # uid email: address
35
+ # }
36
+ # }
37
+
38
+ # query ListSent(
39
+ # $uid: String
40
+ # ) @auth(level: PUBLIC) {
41
+ # emails(where: {
42
+ # fromUid: { eq: $uid }
43
+ # }) {
44
+ # id subject sent
45
+ # content: text
46
+ # sender: from { name email: address uid }
47
+ # to: recipients_on_email {
48
+ # user { name email: address uid }
49
+ # }
50
+ # }
51
+ # }
@@ -0,0 +1,28 @@
1
+ ## Example schema for simple email app
2
+ # type User @table(key: "uid") {
3
+ # uid: String!
4
+ # name: String!
5
+ # address: String!
6
+ # }
7
+
8
+ # type Email @table {
9
+ # subject: String!
10
+ # sent: Date!
11
+ # text: String!
12
+ # from: User!
13
+ # }
14
+
15
+ # type Recipient @table(key: ["email", "user"]) {
16
+ # email: Email!
17
+ # user: User!
18
+ # }
19
+
20
+ # type EmailMeta @table(key: ["user", "email"]) {
21
+ # user: User!
22
+ # email: Email!
23
+ # labels: [String]
24
+ # read: Boolean!
25
+ # starred: Boolean!
26
+ # muted: Boolean!
27
+ # snoozed: Date
28
+ # }
@@ -1 +1,2 @@
1
- node_modules/
1
+ node_modules/
2
+ *.local
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "main": "index.js",
16
16
  "dependencies": {
17
- "firebase-admin": "^11.8.0",
18
- "firebase-functions": "^4.3.1"
17
+ "firebase-admin": "^12.1.0",
18
+ "firebase-functions": "^5.0.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "eslint": "^8.15.0",
@@ -13,8 +13,8 @@
13
13
  },
14
14
  "main": "index.js",
15
15
  "dependencies": {
16
- "firebase-admin": "^11.8.0",
17
- "firebase-functions": "^4.3.1"
16
+ "firebase-admin": "^12.1.0",
17
+ "firebase-functions": "^5.0.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "firebase-functions-test": "^3.1.0"
@@ -0,0 +1 @@
1
+ *.local
@@ -7,3 +7,4 @@ typings/
7
7
 
8
8
  # Node.js dependency directory
9
9
  node_modules/
10
+ *.local
@@ -15,8 +15,8 @@
15
15
  },
16
16
  "main": "lib/index.js",
17
17
  "dependencies": {
18
- "firebase-admin": "^11.8.0",
19
- "firebase-functions": "^4.3.1"
18
+ "firebase-admin": "^12.1.0",
19
+ "firebase-functions": "^5.0.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@typescript-eslint/eslint-plugin": "^5.12.0",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "main": "lib/index.js",
16
16
  "dependencies": {
17
- "firebase-admin": "^11.8.0",
18
- "firebase-functions": "^4.3.1"
17
+ "firebase-admin": "^12.1.0",
18
+ "firebase-functions": "^5.0.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "typescript": "^4.9.0",
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMonospaceEnv = exports.selectProjectInMonospace = void 0;
4
- const node_fetch_1 = require("node-fetch");
5
- const error_1 = require("../error");
6
- const logger_1 = require("../logger");
7
- const rc_1 = require("../rc");
8
- const POLL_USER_RESPONSE_MILLIS = 2000;
9
- async function selectProjectInMonospace({ projectRoot, project, isVSCE, }) {
10
- const initFirebaseResponse = await initFirebase(project);
11
- if (initFirebaseResponse.success === false) {
12
- throw new Error(String(initFirebaseResponse.error));
13
- }
14
- const { rid } = initFirebaseResponse;
15
- const authorizedProject = await pollAuthorizedProject(rid);
16
- if (!authorizedProject)
17
- return null;
18
- if (isVSCE)
19
- return authorizedProject;
20
- if (projectRoot)
21
- createFirebaseRc(projectRoot, authorizedProject);
22
- }
23
- exports.selectProjectInMonospace = selectProjectInMonospace;
24
- async function pollAuthorizedProject(rid) {
25
- const getInitFirebaseRes = await getInitFirebaseResponse(rid);
26
- if ("userResponse" in getInitFirebaseRes) {
27
- if (getInitFirebaseRes.userResponse.success) {
28
- return getInitFirebaseRes.userResponse.projectId;
29
- }
30
- return null;
31
- }
32
- const { error } = getInitFirebaseRes;
33
- if (error === "WAITING_FOR_RESPONSE") {
34
- await new Promise((res) => setTimeout(res, POLL_USER_RESPONSE_MILLIS));
35
- return pollAuthorizedProject(rid);
36
- }
37
- if (error === "USER_CANCELED") {
38
- throw new error_1.FirebaseError("User canceled without authorizing any project");
39
- }
40
- throw new error_1.FirebaseError(`Unhandled /get-init-firebase-response error`, {
41
- original: new Error(error),
42
- });
43
- }
44
- async function initFirebase(project) {
45
- const port = getMonospaceDaemonPort();
46
- if (!port)
47
- throw new error_1.FirebaseError("Undefined MONOSPACE_DAEMON_PORT");
48
- const initFirebaseURL = new URL(`http://localhost:${port}/init-firebase`);
49
- if (project) {
50
- initFirebaseURL.searchParams.set("known_project", project);
51
- }
52
- const initFirebaseRes = await (0, node_fetch_1.default)(initFirebaseURL.toString(), {
53
- method: "POST",
54
- headers: {
55
- "Content-Type": "application/json",
56
- },
57
- });
58
- const initFirebaseResponse = (await initFirebaseRes.json());
59
- return initFirebaseResponse;
60
- }
61
- async function getInitFirebaseResponse(rid) {
62
- const port = getMonospaceDaemonPort();
63
- if (!port)
64
- throw new error_1.FirebaseError("Undefined MONOSPACE_DAEMON_PORT");
65
- const getInitFirebaseRes = await (0, node_fetch_1.default)(`http://localhost:${port}/get-init-firebase-response?rid=${rid}`);
66
- const getInitFirebaseJson = (await getInitFirebaseRes.json());
67
- logger_1.logger.debug(`/get-init-firebase-response?rid=${rid} response:`);
68
- logger_1.logger.debug(getInitFirebaseJson);
69
- return getInitFirebaseJson;
70
- }
71
- function createFirebaseRc(projectDir, authorizedProject) {
72
- const firebaseRc = (0, rc_1.loadRC)({ cwd: projectDir });
73
- firebaseRc.addProjectAlias("default", authorizedProject);
74
- return firebaseRc.save();
75
- }
76
- function isMonospaceEnv() {
77
- return getMonospaceDaemonPort() !== undefined;
78
- }
79
- exports.isMonospaceEnv = isMonospaceEnv;
80
- function getMonospaceDaemonPort() {
81
- return process.env.MONOSPACE_DAEMON_PORT;
82
- }