firebase-tools-with-isolate 13.11.2 → 13.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.
Files changed (134) hide show
  1. package/lib/api.js +4 -2
  2. package/lib/apphosting/githubConnections.js +125 -37
  3. package/lib/apphosting/index.js +3 -8
  4. package/lib/auth.js +14 -15
  5. package/lib/bin/firebase.js +7 -5
  6. package/lib/commands/dataconnect-sdk-generate.js +5 -9
  7. package/lib/commands/dataconnect-services-list.js +1 -1
  8. package/lib/commands/deploy.js +10 -2
  9. package/lib/commands/ext-configure.js +1 -6
  10. package/lib/commands/ext-dev-init.js +27 -30
  11. package/lib/commands/ext-dev-upload.js +4 -6
  12. package/lib/commands/ext-info.js +3 -5
  13. package/lib/commands/ext-install.js +0 -5
  14. package/lib/commands/ext-uninstall.js +0 -5
  15. package/lib/commands/ext-update.js +0 -5
  16. package/lib/commands/firestore-backups-schedules-create.js +11 -14
  17. package/lib/commands/firestore-backups-schedules-list.js +1 -1
  18. package/lib/commands/firestore-backups-schedules-update.js +4 -3
  19. package/lib/commands/firestore-databases-create.js +24 -7
  20. package/lib/commands/firestore-databases-restore.js +4 -4
  21. package/lib/commands/firestore-databases-update.js +5 -6
  22. package/lib/commands/functions-secrets-set.js +9 -6
  23. package/lib/commands/help.js +2 -0
  24. package/lib/commands/hosting-channel-create.js +1 -1
  25. package/lib/commands/hosting-channel-delete.js +1 -1
  26. package/lib/commands/hosting-channel-deploy.js +1 -1
  27. package/lib/commands/hosting-clone.js +1 -2
  28. package/lib/commands/index.js +9 -11
  29. package/lib/commands/init.js +16 -12
  30. package/lib/commands/login.js +1 -2
  31. package/lib/commands/setup-emulators-dataconnect.js +22 -3
  32. package/lib/config.js +5 -0
  33. package/lib/crashlytics/buildToolsJarHelper.js +1 -1
  34. package/lib/dataconnect/client.js +57 -9
  35. package/lib/dataconnect/fileUtils.js +71 -7
  36. package/lib/dataconnect/filters.js +12 -1
  37. package/lib/dataconnect/load.js +9 -7
  38. package/lib/dataconnect/provisionCloudSql.js +5 -1
  39. package/lib/dataconnect/schemaMigration.js +21 -0
  40. package/lib/dataconnect/types.js +8 -1
  41. package/lib/deploy/dataconnect/prepare.js +16 -2
  42. package/lib/deploy/extensions/planner.js +52 -1
  43. package/lib/deploy/extensions/prepare.js +98 -23
  44. package/lib/deploy/extensions/release.js +6 -0
  45. package/lib/deploy/functions/build.js +15 -6
  46. package/lib/deploy/functions/deploy.js +12 -12
  47. package/lib/deploy/functions/params.js +5 -3
  48. package/lib/deploy/functions/prepare.js +8 -1
  49. package/lib/deploy/functions/release/index.js +4 -0
  50. package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
  51. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +46 -0
  52. package/lib/emulator/adminSdkConfig.test.js +16 -0
  53. package/lib/emulator/constants.js +8 -0
  54. package/lib/emulator/controller.js +14 -10
  55. package/lib/emulator/dataconnectEmulator.js +122 -18
  56. package/lib/emulator/downloadableEmulators.js +24 -25
  57. package/lib/emulator/env.js +3 -0
  58. package/lib/emulator/eventarcEmulator.js +68 -18
  59. package/lib/emulator/functionsEmulator.js +119 -1
  60. package/lib/emulator/functionsEmulatorShared.js +20 -0
  61. package/lib/emulator/hub.js +1 -1
  62. package/lib/emulator/portUtils.js +10 -0
  63. package/lib/emulator/pubsubEmulator.js +1 -1
  64. package/lib/emulator/registry.js +2 -1
  65. package/lib/emulator/storage/apis/shared.js +2 -1
  66. package/lib/emulator/storage/persistence.js +5 -13
  67. package/lib/emulator/storage/rfc.js +9 -0
  68. package/lib/emulator/storage/rules/config.js +4 -2
  69. package/lib/emulator/taskQueue.js +348 -0
  70. package/lib/emulator/tasksEmulator.js +237 -0
  71. package/lib/emulator/types.js +3 -0
  72. package/lib/experiments.js +8 -3
  73. package/lib/extensions/askUserForEventsConfig.js +18 -8
  74. package/lib/extensions/askUserForParam.js +3 -2
  75. package/lib/extensions/change-log.js +2 -4
  76. package/lib/extensions/displayExtensionInfo.js +5 -10
  77. package/lib/extensions/extensionsApi.js +1 -1
  78. package/lib/extensions/extensionsHelper.js +30 -10
  79. package/lib/extensions/localHelper.js +1 -1
  80. package/lib/extensions/provisioningHelper.js +1 -1
  81. package/lib/extensions/refs.js +26 -11
  82. package/lib/extensions/runtimes/common.js +75 -0
  83. package/lib/extensions/types.js +56 -1
  84. package/lib/extensions/updateHelper.js +1 -2
  85. package/lib/extensions/warnings.js +2 -7
  86. package/lib/firestore/api-sort.test.js +74 -0
  87. package/lib/firestore/api.js +8 -7
  88. package/lib/firestore/backupUtils.test.js +18 -0
  89. package/lib/firestore/pretty-print.js +21 -1
  90. package/lib/firestore/pretty-print.test.js +61 -0
  91. package/lib/firestore/util.test.js +42 -0
  92. package/lib/frameworks/angular/utils.js +13 -5
  93. package/lib/frameworks/compose/discover/mockFileSystem.js +36 -0
  94. package/lib/frameworks/constants.js +1 -1
  95. package/lib/frameworks/index.js +2 -6
  96. package/lib/frameworks/next/constants.js +1 -1
  97. package/lib/frameworks/next/index.js +35 -15
  98. package/lib/frameworks/next/utils.js +53 -9
  99. package/lib/frameworks/nuxt/index.js +3 -3
  100. package/lib/functions/events/v2.js +2 -1
  101. package/lib/gcp/cloudsql/cloudsqladmin.js +6 -1
  102. package/lib/gcp/devConnect.js +36 -1
  103. package/lib/hosting/implicitInit.js +2 -2
  104. package/lib/init/features/dataconnect/index.js +104 -32
  105. package/lib/init/features/dataconnect/sdk.js +147 -0
  106. package/lib/init/features/firestore/indexes.js +2 -2
  107. package/lib/init/features/firestore/rules.js +2 -2
  108. package/lib/init/features/functions/javascript.js +6 -8
  109. package/lib/init/features/functions/python.js +4 -6
  110. package/lib/init/features/functions/typescript.js +8 -10
  111. package/lib/init/features/hosting/github.js +43 -21
  112. package/lib/init/features/hosting/index.js +3 -3
  113. package/lib/init/features/index.js +3 -1
  114. package/lib/init/features/storage.js +2 -2
  115. package/lib/init/index.js +1 -0
  116. package/lib/listFiles.js +1 -1
  117. package/lib/management/apps.js +2 -2
  118. package/lib/prompt.js +22 -1
  119. package/lib/rc.js +1 -0
  120. package/lib/requireAuth.js +8 -3
  121. package/lib/rulesDeploy.js +14 -12
  122. package/lib/templates.js +23 -0
  123. package/lib/utils.js +2 -2
  124. package/package.json +25 -24
  125. package/schema/connector-yaml.json +36 -4
  126. package/schema/dataconnect-yaml.json +4 -0
  127. package/schema/firebase-config.json +12 -8
  128. package/templates/_gitignore +3 -0
  129. package/templates/init/dataconnect/connector.yaml +15 -2
  130. package/templates/init/dataconnect/dataconnect.yaml +5 -4
  131. package/templates/init/dataconnect/mutations.gql +45 -25
  132. package/templates/init/dataconnect/queries.gql +69 -36
  133. package/templates/init/dataconnect/schema.gql +38 -21
  134. package/lib/extensions/billingMigrationHelper.js +0 -61
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "firebase-tools-with-isolate",
3
+ "version": "13.16.0",
3
4
  "description": "Command-Line Interface for Firebase with monorepo support",
4
- "version": "13.11.2",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {
7
7
  "firebase": "lib/bin/firebase.js"
@@ -16,13 +16,14 @@
16
16
  "format:other": "npm run lint:other -- --write",
17
17
  "format:ts": "npm run lint:ts -- --fix --quiet",
18
18
  "generate:auth-api": "ts-node scripts/gen-auth-api-spec.ts",
19
- "generate:json-schema": "typescript-json-schema --strictNullChecks --required --noExtraProps src/firebaseConfig.ts FirebaseConfig > schema/firebase-config.json",
19
+ "generate:json-schema": "typescript-json-schema --strictNullChecks --required --noExtraProps --ignoreErrors src/firebaseConfig.ts FirebaseConfig > schema/firebase-config.json",
20
20
  "lint": "npm run lint:ts && npm run lint:other",
21
21
  "lint:changed-files": "ts-node ./scripts/lint-changed-files.ts",
22
22
  "lint:other": "prettier --check '**/*.{md,yaml,yml}'",
23
23
  "lint:quiet": "npm run lint:ts -- --quiet && npm run lint:other",
24
24
  "lint:ts": "eslint --config .eslintrc.js --ext .ts,.js .",
25
- "mocha": "nyc mocha 'src/test/**/*.{ts,js}'",
25
+ "mocha:fast": "mocha 'src/**/*.spec.{ts,js}'",
26
+ "mocha": "nyc mocha 'src/**/*.spec.{ts,js}'",
26
27
  "prepare": "npm run clean && npm run build:publish",
27
28
  "test": "npm run lint:quiet && npm run test:compile && npm run mocha",
28
29
  "test:client-integration": "bash ./scripts/client-integration-tests/run.sh",
@@ -90,18 +91,20 @@
90
91
  ".ts"
91
92
  ],
92
93
  "exclude": [
94
+ "src/**/*.spec.*",
95
+ "src/**/testing/**/*",
93
96
  "src/test/**/*"
94
97
  ]
95
98
  },
96
99
  "dependencies": {
97
- "@google-cloud/cloud-sql-connector": "^1.2.3",
98
- "@google-cloud/pubsub": "^4.4.0",
100
+ "@google-cloud/cloud-sql-connector": "^1.3.3",
101
+ "@google-cloud/pubsub": "^4.5.0",
99
102
  "abort-controller": "^3.0.0",
100
103
  "ajv": "^6.12.6",
101
- "archiver": "^5.0.0",
102
- "async-lock": "1.3.2",
104
+ "archiver": "^7.0.0",
105
+ "async-lock": "1.4.1",
103
106
  "body-parser": "^1.19.0",
104
- "chokidar": "^3.0.2",
107
+ "chokidar": "^3.6.0",
105
108
  "cjson": "^0.3.1",
106
109
  "cli-table": "0.3.11",
107
110
  "colorette": "^2.0.19",
@@ -112,16 +115,16 @@
112
115
  "cross-spawn": "^7.0.3",
113
116
  "csv-parse": "^5.0.4",
114
117
  "deep-equal-in-any-order": "^2.0.6",
115
- "exegesis": "^4.1.0",
118
+ "exegesis": "^4.2.0",
116
119
  "exegesis-express": "^4.0.0",
117
120
  "express": "^4.16.4",
118
121
  "filesize": "^6.1.0",
119
122
  "form-data": "^4.0.0",
120
123
  "fs-extra": "^10.1.0",
121
124
  "fuzzy": "^0.1.3",
122
- "gaxios": "^6.1.1",
123
- "glob": "^7.1.2",
124
- "google-auth-library": "^9.7.0",
125
+ "gaxios": "^6.7.0",
126
+ "glob": "^10.4.1",
127
+ "google-auth-library": "^9.11.0",
125
128
  "inquirer": "^8.2.6",
126
129
  "inquirer-autocomplete-prompt": "^2.0.1",
127
130
  "isolate-package": "^1.18.0",
@@ -129,8 +132,8 @@
129
132
  "leven": "^3.1.0",
130
133
  "libsodium-wrappers": "^0.7.10",
131
134
  "lodash": "^4.17.21",
132
- "marked": "^4.0.14",
133
- "marked-terminal": "^5.1.1",
135
+ "marked": "^13.0.2",
136
+ "marked-terminal": "^7.0.0",
134
137
  "mime": "^2.5.2",
135
138
  "minimatch": "^3.0.4",
136
139
  "morgan": "^1.10.0",
@@ -143,7 +146,7 @@
143
146
  "progress": "^2.0.3",
144
147
  "proxy-agent": "^6.3.0",
145
148
  "retry": "^0.13.1",
146
- "rimraf": "^3.0.0",
149
+ "rimraf": "^5.0.0",
147
150
  "semver": "^7.5.2",
148
151
  "sql-formatter": "^15.3.0",
149
152
  "stream-chain": "^2.2.4",
@@ -152,22 +155,22 @@
152
155
  "superstatic": "^9.0.3",
153
156
  "tar": "^6.1.11",
154
157
  "tcp-port-used": "^1.0.2",
155
- "tmp": "^0.2.1",
158
+ "tmp": "^0.2.3",
156
159
  "triple-beam": "^1.3.0",
157
160
  "universal-analytics": "^0.5.3",
158
161
  "update-notifier-cjs": "^5.1.6",
159
162
  "uuid": "^8.3.2",
160
163
  "winston": "^3.0.0",
161
164
  "winston-transport": "^4.4.0",
162
- "ws": "^7.2.3",
165
+ "ws": "^7.5.10",
163
166
  "yaml": "^2.4.1"
164
167
  },
165
168
  "devDependencies": {
166
169
  "@angular-devkit/architect": "^0.1402.2",
167
170
  "@angular-devkit/core": "^14.2.2",
168
171
  "@google/events": "^5.1.1",
169
- "@types/archiver": "^5.1.0",
170
- "@types/async-lock": "^1.1.5",
172
+ "@types/archiver": "^6.0.0",
173
+ "@types/async-lock": "^1.4.2",
171
174
  "@types/body-parser": "^1.17.0",
172
175
  "@types/chai": "^4.3.0",
173
176
  "@types/chai-as-promised": "^7.1.4",
@@ -180,7 +183,6 @@
180
183
  "@types/express": "^4.17.0",
181
184
  "@types/express-serve-static-core": "^4.17.8",
182
185
  "@types/fs-extra": "^9.0.13",
183
- "@types/glob": "^7.1.1",
184
186
  "@types/html-escaper": "^3.0.0",
185
187
  "@types/inquirer": "^8.1.3",
186
188
  "@types/inquirer-autocomplete-prompt": "^2.0.2",
@@ -188,19 +190,17 @@
188
190
  "@types/jsonwebtoken": "^9.0.5",
189
191
  "@types/libsodium-wrappers": "^0.7.9",
190
192
  "@types/lodash": "^4.14.149",
191
- "@types/marked": "^4.0.3",
192
- "@types/marked-terminal": "^3.1.3",
193
+ "@types/marked-terminal": "^6.1.1",
193
194
  "@types/mocha": "^9.0.0",
195
+ "@types/mock-fs": "4.13.4",
194
196
  "@types/multer": "^1.4.3",
195
197
  "@types/node": "^18.19.1",
196
198
  "@types/node-fetch": "^2.5.12",
197
199
  "@types/pg": "^8.11.2",
198
200
  "@types/progress": "^2.0.3",
199
- "@types/puppeteer": "^5.4.2",
200
201
  "@types/react": "^18.2.58",
201
202
  "@types/react-dom": "^18.2.19",
202
203
  "@types/retry": "^0.12.1",
203
- "@types/rimraf": "^2.0.3",
204
204
  "@types/semver": "^6.0.0",
205
205
  "@types/sinon": "^9.0.10",
206
206
  "@types/sinon-chai": "^3.2.2",
@@ -231,6 +231,7 @@
231
231
  "google-discovery-to-swagger": "^2.1.0",
232
232
  "googleapis": "^105.0.0",
233
233
  "mocha": "^9.1.3",
234
+ "mock-fs": "5.2.0",
234
235
  "next": "^14.1.0",
235
236
  "nock": "^13.0.5",
236
237
  "node-mocks-http": "^1.11.0",
@@ -2,7 +2,39 @@
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "additionalProperties": false,
4
4
  "definitions": {
5
- "generatable": {
5
+ "javascriptSdk": {
6
+ "additionalProperties": true,
7
+ "type": "object",
8
+ "properties": {
9
+ "outputDir": {
10
+ "type": "string",
11
+ "description": "Path to the directory where generated files should be written to."
12
+ },
13
+ "package": {
14
+ "type": "string",
15
+ "description": "The package name to use for the generated code."
16
+ },
17
+ "packageJSONDir": {
18
+ "type": "string",
19
+ "description": "The directory containining the package.json to install the generated package in."
20
+ }
21
+ }
22
+ },
23
+ "kotlinSdk": {
24
+ "additionalProperties": true,
25
+ "type": "object",
26
+ "properties": {
27
+ "outputDir": {
28
+ "type": "string",
29
+ "description": "Path to the directory where generated files should be written to."
30
+ },
31
+ "package": {
32
+ "type": "string",
33
+ "description": "The package name to use for the generated code."
34
+ }
35
+ }
36
+ },
37
+ "swiftSdk": {
6
38
  "additionalProperties": true,
7
39
  "type": "object",
8
40
  "properties": {
@@ -30,21 +62,21 @@
30
62
  "javascriptSdk": {
31
63
  "type": "array",
32
64
  "items": {
33
- "$ref": "#/definitions/generatable"
65
+ "$ref": "#/definitions/javascriptSdk"
34
66
  },
35
67
  "description": "Configuration for a generated Javascript SDK"
36
68
  },
37
69
  "kotlinSdk": {
38
70
  "type": "array",
39
71
  "items": {
40
- "$ref": "#/definitions/generatable"
72
+ "$ref": "#/definitions/kotlinSdk"
41
73
  },
42
74
  "description": "Configuration for a generated Kotlin SDK"
43
75
  },
44
76
  "swiftSdk": {
45
77
  "type": "array",
46
78
  "items": {
47
- "$ref": "#/definitions/generatable"
79
+ "$ref": "#/definitions/swiftSdk"
48
80
  },
49
81
  "description": "Configuration for a generated Swift SDK"
50
82
  }
@@ -58,6 +58,10 @@
58
58
  "type": "string",
59
59
  "description": "The ID of the Firebase Data Connect service."
60
60
  },
61
+ "location": {
62
+ "type": "string",
63
+ "description": "The region of the Firebase Data Connect service."
64
+ },
61
65
  "connectorDirs": {
62
66
  "type": "array",
63
67
  "items": {
@@ -276,9 +276,6 @@
276
276
  {
277
277
  "additionalProperties": false,
278
278
  "properties": {
279
- "location": {
280
- "type": "string"
281
- },
282
279
  "postdeploy": {
283
280
  "anyOf": [
284
281
  {
@@ -310,7 +307,6 @@
310
307
  }
311
308
  },
312
309
  "required": [
313
- "location",
314
310
  "source"
315
311
  ],
316
312
  "type": "object"
@@ -319,9 +315,6 @@
319
315
  "items": {
320
316
  "additionalProperties": false,
321
317
  "properties": {
322
- "location": {
323
- "type": "string"
324
- },
325
318
  "postdeploy": {
326
319
  "anyOf": [
327
320
  {
@@ -353,7 +346,6 @@
353
346
  }
354
347
  },
355
348
  "required": [
356
- "location",
357
349
  "source"
358
350
  ],
359
351
  "type": "object"
@@ -508,6 +500,18 @@
508
500
  },
509
501
  "type": "object"
510
502
  },
503
+ "tasks": {
504
+ "additionalProperties": false,
505
+ "properties": {
506
+ "host": {
507
+ "type": "string"
508
+ },
509
+ "port": {
510
+ "type": "number"
511
+ }
512
+ },
513
+ "type": "object"
514
+ },
511
515
  "ui": {
512
516
  "additionalProperties": false,
513
517
  "properties": {
@@ -64,3 +64,6 @@ node_modules/
64
64
 
65
65
  # dotenv environment variables file
66
66
  .env
67
+
68
+ # dataconnect generated files
69
+ .dataconnect
@@ -1,2 +1,15 @@
1
- connectorId: "__connectorId__"
2
- authMode: "PUBLIC"
1
+ connectorId: __connectorId__
2
+ authMode: "PUBLIC"
3
+ ## ## Here's an example of how to add generated SDKs.
4
+ ## ## You'll need to replace the outputDirs with ones pointing to where you want the generated code in your app.
5
+ # generate:
6
+ # javascriptSdk:
7
+ # outputDir: <Path where you want the generated SDK to be written to, relative to this file>
8
+ # package: "@firebasegen/my-connector"
9
+ # packageJsonDir: < Optional. Path to your Javascript app's package.json>
10
+ # swiftSdk:
11
+ # outputDir: <Path where you want the generated SDK to be written to, relative to this file>
12
+ # package: "firebasegen/default"
13
+ # kotlinSdk:
14
+ # outputDir: <Path where you want the generated SDK to be written to, relative to this file>
15
+ # package: connectors.default
@@ -1,10 +1,11 @@
1
1
  specVersion: "v1alpha"
2
- serviceId: "__serviceId__"
2
+ serviceId: __serviceId__
3
+ location: __location__
3
4
  schema:
4
5
  source: "./schema"
5
6
  datasource:
6
7
  postgresql:
7
- database: "__cloudSqlDatabase__"
8
+ database: __cloudSqlDatabase__
8
9
  cloudSql:
9
- instanceId: "__cloudSqlInstanceId__"
10
- connectorDirs: ["./__connectorId__"]
10
+ instanceId: __cloudSqlInstanceId__
11
+ connectorDirs: __connectorDirs__
@@ -1,30 +1,50 @@
1
- # # Example mutations for a simple email app
1
+ # # Example mutations for a simple movie app
2
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
- # })
3
+ # # Create a movie based on user input
4
+ # mutation CreateMovie(
5
+ # $title: String!
6
+ # $genre: String!
7
+ # $imageUrl: String!
8
+ # ) @auth(level: USER_EMAIL_VERIFIED) {
9
+ # movie_insert(
10
+ # data: {
11
+ # title: $title
12
+ # genre: $genre
13
+ # imageUrl: $imageUrl
14
+ # }
15
+ # )
10
16
  # }
11
- # mutation CreateEmail($content: String, $subject: String, $fromUid: String) @auth(level: PUBLIC) {
12
- # email_insert(data: {
13
- # text: $content, # The request variable name doesn't have to match the field name.
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
- # })
17
+
18
+ # # Upsert (update or insert) a user's username based on their auth.uid
19
+ # mutation UpsertUser($username: String!) @auth(level: USER) {
20
+ # user_upsert(
21
+ # data: {
22
+ # id_expr: "auth.uid"
23
+ # username: $username
24
+ # }
25
+ # )
20
26
  # }
21
- # mutation CreateRecipient($emailId: UUID, $uid: String) @auth(level: PUBLIC) {
22
- # recipient_insert(data: {
23
- # emailId: $emailId,
24
- # userUid: $uid
25
- # })
27
+
28
+ # # Add a review for a movie
29
+ # mutation AddReview(
30
+ # $movieId: UUID!
31
+ # $rating: Int!
32
+ # $reviewText: String!
33
+ # ) @auth(level: USER) {
34
+ # review_upsert(
35
+ # data: {
36
+ # userId_expr: "auth.uid"
37
+ # movieId: $movieId
38
+ # rating: $rating
39
+ # reviewText: $reviewText
40
+ # # reviewDate defaults to today in the schema. No need to set it manually.
41
+ # }
42
+ # )
26
43
  # }
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})
44
+
45
+ # # Logged in user can delete their review for a movie
46
+ # mutation DeleteReview(
47
+ # $movieId: UUID!
48
+ # ) @auth(level: USER) {
49
+ # review_delete(key: { userId_expr: "auth.uid", movieId: $movieId })
30
50
  # }
@@ -1,51 +1,84 @@
1
- # # Example queries for a simple email app.
1
+ # # Example queries for a simple movie app.
2
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 }
3
+ # # @auth() directives control who can call each operation.
4
+ # # Anyone should be able to list all movies, so the auth level is set to PUBLIC
5
+ # query ListMovies @auth(level: PUBLIC) {
6
+ # movies {
7
+ # id
8
+ # title
9
+ # imageUrl
10
+ # genre
11
+ # }
7
12
  # }
8
13
 
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 # Select the `text` field but alias it as `content` in the response.
22
- # sender: from { name email: address uid }
14
+ # # List all users, only admins should be able to list all users, so we use NO_ACCESS
15
+ # query ListUsers @auth(level: NO_ACCESS) {
16
+ # users { id, username }
17
+ # }
23
18
 
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 }
19
+ # # Logged in user can list all their reviews and movie titles associated with the review
20
+ # # Since the query requires the uid of the current authenticated user, the auth level is set to USER
21
+ # query ListUserReviews @auth(level: USER) {
22
+ # user(key: {id_expr: "auth.uid"}) {
23
+ # id
24
+ # username
25
+ # # <field>_on_<foreign_key_field> makes it easy to grab info from another table
26
+ # # Here, we use it to grab all the reviews written by the user.
27
+ # reviews: reviews_on_user {
28
+ # id
29
+ # rating
30
+ # reviewDate
31
+ # reviewText
32
+ # movie {
33
+ # id
34
+ # title
35
+ # }
28
36
  # }
29
37
  # }
30
38
  # }
31
39
 
32
- # query GetUidByEmail($emails: [String!]) @auth(level: PUBLIC) {
33
- # users(where: { address: { in: $emails } }) {
34
- # uid email: address
40
+ # # Get movie by id
41
+ # query GetMovieById($id: UUID!) @auth(level: PUBLIC) {
42
+ # movie(id: $id) {
43
+ # id
44
+ # title
45
+ # imageUrl
46
+ # genre
47
+ # metadata: movieMetadatas_on_movie {
48
+ # director
49
+ # rating
50
+ # releaseYear
51
+ # description
52
+ # }
53
+ # reviews: reviews_on_movie {
54
+ # id
55
+ # reviewText
56
+ # reviewDate
57
+ # rating
58
+ # user {
59
+ # id
60
+ # username
61
+ # }
62
+ # }
35
63
  # }
36
64
  # }
37
65
 
38
- # query ListSent(
39
- # $uid: String
66
+ # # Search for movies, actors, and reviews
67
+ # query SearchMovie(
68
+ # $titleInput: String
69
+ # $genre: String
40
70
  # ) @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 }
71
+ # movies(
72
+ # where: {
73
+ # _and: [
74
+ # { genre: { eq: $genre } }
75
+ # { title: { contains: $titleInput } }
76
+ # ]
49
77
  # }
78
+ # ) {
79
+ # id
80
+ # title
81
+ # genre
82
+ # imageUrl
50
83
  # }
51
84
  # }
@@ -1,28 +1,45 @@
1
- ## Example schema for simple email app
2
- # type User @table(key: "uid") {
3
- # uid: String!
4
- # name: String!
5
- # address: String!
1
+ # # Example schema for simple movie review app
2
+
3
+ # # Users
4
+ # # Suppose a user can leave reviews for movies
5
+ # # user -> reviews is a one to many relationship,
6
+ # # movie -> reviews is a one to many relationship
7
+ # # movie <-> user is a many to many relationship
8
+ # type User @table {
9
+ # id: String! @col(name: "user_auth")
10
+ # username: String! @col(name: "username", dataType: "varchar(50)")
11
+ # # The following are generated by the user: User! field in the Review table
12
+ # # reviews_on_user
13
+ # # movies_via_Review
6
14
  # }
7
15
 
8
- # type Email @table {
9
- # subject: String!
10
- # sent: Date!
11
- # text: String!
12
- # from: User!
16
+ # # Movies
17
+ # type Movie @table {
18
+ # # The below parameter values are generated by default with @table, and can be edited manually.
19
+ # # implies directive `@col(name: "movie_id")`, generating a column name
20
+ # id: UUID! @default(expr: "uuidV4()")
21
+ # title: String!
22
+ # imageUrl: String!
23
+ # genre: String
13
24
  # }
14
25
 
15
- # type Recipient @table(key: ["email", "user"]) {
16
- # email: Email!
17
- # user: User!
26
+ # # Movie Metadata
27
+ # # Movie - MovieMetadata is a one-to-one relationship
28
+ # type MovieMetadata @table {
29
+ # # @unique indicates a 1-1 relationship
30
+ # movie: Movie! @unique
31
+ # # movieId: UUID <- this is created by the above reference
32
+ # rating: Float
33
+ # releaseYear: Int
34
+ # description: String
18
35
  # }
19
36
 
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
37
+ # # Reviews
38
+ # type Review @table(name: "Reviews", key: ["movie", "user"]) {
39
+ # id: UUID! @default(expr: "uuidV4()")
40
+ # user: User!
41
+ # movie: Movie!
42
+ # rating: Int
43
+ # reviewText: String
44
+ # reviewDate: Date! @default(expr: "request.time")
28
45
  # }
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.displayNode10CreateBillingNotice = exports.displayNode10UpdateBillingNotice = void 0;
4
- const marked_1 = require("marked");
5
- const TerminalRenderer = require("marked-terminal");
6
- const error_1 = require("../error");
7
- const extensionsHelper_1 = require("./extensionsHelper");
8
- const prompt_1 = require("../prompt");
9
- const utils = require("../utils");
10
- const utils_1 = require("./utils");
11
- marked_1.marked.setOptions({
12
- renderer: new TerminalRenderer(),
13
- });
14
- const urlPricingExamples = "https://cloud.google.com/functions/pricing#pricing_examples";
15
- const urlFAQ = "https://firebase.google.com/support/faq/#extensions-pricing";
16
- const billingMsgUpdate = "This update includes an upgrade to Node.js 10 from Node.js 8, which is no" +
17
- " longer maintained. Starting with this update, you will be charged a" +
18
- " small amount (typically around $0.01/month) for the Firebase resources" +
19
- " required by this extension (even if it is not used), in addition to any" +
20
- " charges associated with its usage.\n\n" +
21
- `See pricing examples: **[${urlPricingExamples}](${urlPricingExamples})**\n` +
22
- `See the FAQ: **[${urlFAQ}](${urlFAQ})**\n`;
23
- const billingMsgCreate = "You will be charged around $0.01/month for the Firebase resources" +
24
- " required by this extension (even if it is not used). Additionally," +
25
- " using this extension will contribute to your project's overall usage" +
26
- " level of Firebase services. However, you'll only be charged for usage" +
27
- " that exceeds Firebase's free tier for those services.\n\n" +
28
- `See pricing examples: **[${urlPricingExamples}](${urlPricingExamples})**\n` +
29
- `See the FAQ: **[${urlFAQ}](${urlFAQ})**\n`;
30
- const defaultSpecVersion = "v1beta";
31
- const defaultRuntimes = {
32
- v1beta: "nodejs8",
33
- };
34
- function hasRuntime(spec, runtime) {
35
- const specVersion = spec.specVersion || defaultSpecVersion;
36
- const defaultRuntime = defaultRuntimes[specVersion];
37
- const resources = spec.resources || [];
38
- return resources.some((r) => runtime === ((0, utils_1.getResourceRuntime)(r) || defaultRuntime));
39
- }
40
- function displayNode10UpdateBillingNotice(curSpec, newSpec) {
41
- if (hasRuntime(curSpec, "nodejs8") && hasRuntime(newSpec, "nodejs10")) {
42
- utils.logLabeledWarning(extensionsHelper_1.logPrefix, (0, marked_1.marked)(billingMsgUpdate));
43
- }
44
- }
45
- exports.displayNode10UpdateBillingNotice = displayNode10UpdateBillingNotice;
46
- async function displayNode10CreateBillingNotice(spec, prompt) {
47
- if (hasRuntime(spec, "nodejs10")) {
48
- utils.logLabeledWarning(extensionsHelper_1.logPrefix, (0, marked_1.marked)(billingMsgCreate));
49
- if (prompt) {
50
- const continueUpdate = await (0, prompt_1.promptOnce)({
51
- type: "confirm",
52
- message: "Do you wish to continue?",
53
- default: true,
54
- });
55
- if (!continueUpdate) {
56
- throw new error_1.FirebaseError(`Cancelled.`, { exit: 2 });
57
- }
58
- }
59
- }
60
- }
61
- exports.displayNode10CreateBillingNotice = displayNode10CreateBillingNotice;