@causa/workspace-google 0.18.0-beta.1 → 0.18.0-beta.3

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 (57) hide show
  1. package/dist/configurations/generated.d.ts +30 -0
  2. package/dist/configurations/generated.js +60 -0
  3. package/dist/configurations/schemas/google.yaml +43 -0
  4. package/dist/emulators/firebase-storage.d.ts +9 -1
  5. package/dist/emulators/firebase-storage.js +13 -1
  6. package/dist/emulators/firestore.d.ts +9 -1
  7. package/dist/emulators/firestore.js +13 -1
  8. package/dist/emulators/identity-platform.d.ts +9 -1
  9. package/dist/emulators/identity-platform.js +13 -1
  10. package/dist/emulators/pubsub.d.ts +9 -1
  11. package/dist/emulators/pubsub.js +13 -1
  12. package/dist/emulators/spanner.d.ts +18 -2
  13. package/dist/emulators/spanner.js +26 -2
  14. package/dist/functions/emulator/start-firebase-storage.js +4 -3
  15. package/dist/functions/emulator/start-firestore.js +5 -10
  16. package/dist/functions/emulator/start-identity-platform.js +4 -7
  17. package/dist/functions/emulator/start-pubsub.call.js +10 -9
  18. package/dist/functions/emulator/start-spanner.call.js +14 -13
  19. package/dist/functions/event-topic/broker-delete-trigger-resource-pubsub-subscription.js +2 -1
  20. package/dist/functions/event-topic/broker-wait-for-processing-pubsub.call.d.ts +2 -0
  21. package/dist/functions/event-topic/broker-wait-for-processing-pubsub.call.js +119 -0
  22. package/dist/functions/event-topic/broker-wait-for-processing-pubsub.d.ts +16 -0
  23. package/dist/functions/event-topic/broker-wait-for-processing-pubsub.js +23 -0
  24. package/dist/functions/event-topic/index.d.ts +1 -0
  25. package/dist/functions/event-topic/index.js +1 -0
  26. package/dist/functions/google-firestore/generate-typescript-decorators.d.ts +13 -0
  27. package/dist/functions/google-firestore/generate-typescript-decorators.js +78 -0
  28. package/dist/functions/google-firestore/index.d.ts +1 -0
  29. package/dist/functions/google-firestore/index.js +1 -0
  30. package/dist/functions/google-spanner/generate-typescript-decorators.d.ts +14 -0
  31. package/dist/functions/google-spanner/generate-typescript-decorators.js +120 -0
  32. package/dist/functions/google-spanner/index.d.ts +1 -0
  33. package/dist/functions/google-spanner/index.js +1 -0
  34. package/dist/functions/index.js +4 -5
  35. package/dist/services/cloud-monitoring.d.ts +44 -0
  36. package/dist/services/cloud-monitoring.js +61 -0
  37. package/dist/services/index.d.ts +2 -1
  38. package/dist/services/index.js +2 -1
  39. package/dist/services/pubsub.d.ts +1 -0
  40. package/dist/services/pubsub.js +1 -0
  41. package/dist/services/pubsub.utils.d.ts +9 -0
  42. package/dist/services/pubsub.utils.js +11 -0
  43. package/package.json +8 -8
  44. package/dist/code-generation/google-firestore-renderer.d.ts +0 -12
  45. package/dist/code-generation/google-firestore-renderer.js +0 -89
  46. package/dist/code-generation/google-spanner-renderer.d.ts +0 -11
  47. package/dist/code-generation/google-spanner-renderer.js +0 -100
  48. package/dist/code-generation/index.d.ts +0 -2
  49. package/dist/code-generation/index.js +0 -2
  50. package/dist/code-generation/utils.d.ts +0 -12
  51. package/dist/code-generation/utils.js +0 -21
  52. package/dist/functions/typescript/get-decorator-renderer-google-firestore.d.ts +0 -8
  53. package/dist/functions/typescript/get-decorator-renderer-google-firestore.js +0 -14
  54. package/dist/functions/typescript/get-decorator-renderer-google-spanner.d.ts +0 -8
  55. package/dist/functions/typescript/get-decorator-renderer-google-spanner.js +0 -14
  56. package/dist/functions/typescript/index.d.ts +0 -2
  57. package/dist/functions/typescript/index.js +0 -2
@@ -173,6 +173,11 @@ export declare class GoogleFirebaseStorageEmulator {
173
173
  * The name of the local Docker container running the emulator.
174
174
  */
175
175
  readonly containerName?: string;
176
+ /**
177
+ * The host port to which the Firebase Storage emulator is bound.
178
+ * Override this to run several workspaces in parallel on the same machine. Defaults to `9199`.
179
+ */
180
+ readonly port?: number;
176
181
  [property: string]: any;
177
182
  }
178
183
  /**
@@ -203,6 +208,11 @@ export declare class GoogleFirestoreEmulator {
203
208
  * The name of the local Docker container running the emulator.
204
209
  */
205
210
  readonly containerName?: string;
211
+ /**
212
+ * The host port to which the Firestore emulator is bound.
213
+ * Override this to run several workspaces in parallel on the same machine. Defaults to `8080`.
214
+ */
215
+ readonly port?: number;
206
216
  [property: string]: any;
207
217
  }
208
218
  /**
@@ -245,6 +255,11 @@ export declare class GoogleIdentityPlatformEmulator {
245
255
  * The name of the local Docker container running the emulator.
246
256
  */
247
257
  readonly containerName?: string;
258
+ /**
259
+ * The host port to which the Identity Platform (Firebase Auth) emulator is bound.
260
+ * Override this to run several workspaces in parallel on the same machine. Defaults to `9099`.
261
+ */
262
+ readonly port?: number;
248
263
  [property: string]: any;
249
264
  }
250
265
  /**
@@ -294,6 +309,11 @@ export declare class GooglePubSubEmulator {
294
309
  * The name of the local Docker container running the emulator.
295
310
  */
296
311
  readonly containerName?: string;
312
+ /**
313
+ * The host port to which the Pub/Sub emulator is bound.
314
+ * Override this to run several workspaces in parallel on the same machine. Defaults to `8085`.
315
+ */
316
+ readonly port?: number;
297
317
  [property: string]: any;
298
318
  }
299
319
  /**
@@ -393,6 +413,16 @@ export declare class GoogleSpannerEmulator {
393
413
  * The name of the local Docker container running the emulator.
394
414
  */
395
415
  readonly containerName?: string;
416
+ /**
417
+ * The host port to which the Spanner emulator gRPC API is bound.
418
+ * Override this to run several workspaces in parallel on the same machine. Defaults to `9010`.
419
+ */
420
+ readonly grpcPort?: number;
421
+ /**
422
+ * The host port to which the Spanner emulator HTTP API is bound.
423
+ * Override this to run several workspaces in parallel on the same machine. Defaults to `9020`.
424
+ */
425
+ readonly httpPort?: number;
396
426
  /**
397
427
  * The name of the Spanner instance that will automatically be created in the emulator.
398
428
  */
@@ -301,12 +301,22 @@ export class GoogleFirebaseStorageEmulator {
301
301
  * The name of the local Docker container running the emulator.
302
302
  */
303
303
  containerName;
304
+ /**
305
+ * The host port to which the Firebase Storage emulator is bound.
306
+ * Override this to run several workspaces in parallel on the same machine. Defaults to `9199`.
307
+ */
308
+ port;
304
309
  }
305
310
  __decorate([
306
311
  AllowMissing(),
307
312
  IsString(),
308
313
  __metadata("design:type", String)
309
314
  ], GoogleFirebaseStorageEmulator.prototype, "containerName", void 0);
315
+ __decorate([
316
+ AllowMissing(),
317
+ IsNumber(),
318
+ __metadata("design:type", Number)
319
+ ], GoogleFirebaseStorageEmulator.prototype, "port", void 0);
310
320
  /**
311
321
  * Configuration for the Firebase Storage service.
312
322
  */
@@ -353,12 +363,22 @@ export class GoogleFirestoreEmulator {
353
363
  * The name of the local Docker container running the emulator.
354
364
  */
355
365
  containerName;
366
+ /**
367
+ * The host port to which the Firestore emulator is bound.
368
+ * Override this to run several workspaces in parallel on the same machine. Defaults to `8080`.
369
+ */
370
+ port;
356
371
  }
357
372
  __decorate([
358
373
  AllowMissing(),
359
374
  IsString(),
360
375
  __metadata("design:type", String)
361
376
  ], GoogleFirestoreEmulator.prototype, "containerName", void 0);
377
+ __decorate([
378
+ AllowMissing(),
379
+ IsNumber(),
380
+ __metadata("design:type", Number)
381
+ ], GoogleFirestoreEmulator.prototype, "port", void 0);
362
382
  /**
363
383
  * Configuration for the Firestore service.
364
384
  */
@@ -423,12 +443,22 @@ export class GoogleIdentityPlatformEmulator {
423
443
  * The name of the local Docker container running the emulator.
424
444
  */
425
445
  containerName;
446
+ /**
447
+ * The host port to which the Identity Platform (Firebase Auth) emulator is bound.
448
+ * Override this to run several workspaces in parallel on the same machine. Defaults to `9099`.
449
+ */
450
+ port;
426
451
  }
427
452
  __decorate([
428
453
  AllowMissing(),
429
454
  IsString(),
430
455
  __metadata("design:type", String)
431
456
  ], GoogleIdentityPlatformEmulator.prototype, "containerName", void 0);
457
+ __decorate([
458
+ AllowMissing(),
459
+ IsNumber(),
460
+ __metadata("design:type", Number)
461
+ ], GoogleIdentityPlatformEmulator.prototype, "port", void 0);
432
462
  /**
433
463
  * Configuration for the Identity Platform (formerly Firebase Auth) service.
434
464
  */
@@ -501,12 +531,22 @@ export class GooglePubSubEmulator {
501
531
  * The name of the local Docker container running the emulator.
502
532
  */
503
533
  containerName;
534
+ /**
535
+ * The host port to which the Pub/Sub emulator is bound.
536
+ * Override this to run several workspaces in parallel on the same machine. Defaults to `8085`.
537
+ */
538
+ port;
504
539
  }
505
540
  __decorate([
506
541
  AllowMissing(),
507
542
  IsString(),
508
543
  __metadata("design:type", String)
509
544
  ], GooglePubSubEmulator.prototype, "containerName", void 0);
545
+ __decorate([
546
+ AllowMissing(),
547
+ IsNumber(),
548
+ __metadata("design:type", Number)
549
+ ], GooglePubSubEmulator.prototype, "port", void 0);
510
550
  /**
511
551
  * Configuration for the Pub/Sub service.
512
552
  */
@@ -684,6 +724,16 @@ export class GoogleSpannerEmulator {
684
724
  * The name of the local Docker container running the emulator.
685
725
  */
686
726
  containerName;
727
+ /**
728
+ * The host port to which the Spanner emulator gRPC API is bound.
729
+ * Override this to run several workspaces in parallel on the same machine. Defaults to `9010`.
730
+ */
731
+ grpcPort;
732
+ /**
733
+ * The host port to which the Spanner emulator HTTP API is bound.
734
+ * Override this to run several workspaces in parallel on the same machine. Defaults to `9020`.
735
+ */
736
+ httpPort;
687
737
  /**
688
738
  * The name of the Spanner instance that will automatically be created in the emulator.
689
739
  */
@@ -698,6 +748,16 @@ __decorate([
698
748
  IsString(),
699
749
  __metadata("design:type", String)
700
750
  ], GoogleSpannerEmulator.prototype, "containerName", void 0);
751
+ __decorate([
752
+ AllowMissing(),
753
+ IsNumber(),
754
+ __metadata("design:type", Number)
755
+ ], GoogleSpannerEmulator.prototype, "grpcPort", void 0);
756
+ __decorate([
757
+ AllowMissing(),
758
+ IsNumber(),
759
+ __metadata("design:type", Number)
760
+ ], GoogleSpannerEmulator.prototype, "httpPort", void 0);
701
761
  __decorate([
702
762
  AllowMissing(),
703
763
  IsString(),
@@ -125,6 +125,13 @@ properties:
125
125
  containerName:
126
126
  type: string
127
127
  description: The name of the local Docker container running the emulator.
128
+ port:
129
+ type: number
130
+ description: >-
131
+ The host port to which the Firebase Storage emulator is bound.
132
+
133
+ Override this to run several workspaces in parallel on the
134
+ same machine. Defaults to `9199`.
128
135
  securityRuleFiles:
129
136
  type: array
130
137
  items:
@@ -149,6 +156,14 @@ properties:
149
156
  containerName:
150
157
  type: string
151
158
  description: The name of the local Docker container running the emulator.
159
+ port:
160
+ type: number
161
+ description: >-
162
+ The host port to which the Identity Platform (Firebase Auth)
163
+ emulator is bound.
164
+
165
+ Override this to run several workspaces in parallel on the
166
+ same machine. Defaults to `9099`.
152
167
  firestore:
153
168
  title: GoogleFirestore
154
169
  type: object
@@ -162,6 +177,13 @@ properties:
162
177
  containerName:
163
178
  type: string
164
179
  description: The name of the local Docker container running the emulator.
180
+ port:
181
+ type: number
182
+ description: >-
183
+ The host port to which the Firestore emulator is bound.
184
+
185
+ Override this to run several workspaces in parallel on the
186
+ same machine. Defaults to `8080`.
165
187
  securityRuleFiles:
166
188
  type: array
167
189
  items:
@@ -185,6 +207,13 @@ properties:
185
207
  containerName:
186
208
  type: string
187
209
  description: The name of the local Docker container running the emulator.
210
+ port:
211
+ type: number
212
+ description: >-
213
+ The host port to which the Pub/Sub emulator is bound.
214
+
215
+ Override this to run several workspaces in parallel on the
216
+ same machine. Defaults to `8085`.
188
217
  topicConfigurationsDirectory:
189
218
  type: string
190
219
  description: The directory where the topic configuration files are written by
@@ -233,6 +262,20 @@ properties:
233
262
  type: string
234
263
  description: The name of the Spanner instance that will automatically be created
235
264
  in the emulator.
265
+ grpcPort:
266
+ type: number
267
+ description: >-
268
+ The host port to which the Spanner emulator gRPC API is bound.
269
+
270
+ Override this to run several workspaces in parallel on the
271
+ same machine. Defaults to `9010`.
272
+ httpPort:
273
+ type: number
274
+ description: >-
275
+ The host port to which the Spanner emulator HTTP API is bound.
276
+
277
+ Override this to run several workspaces in parallel on the
278
+ same machine. Defaults to `9020`.
236
279
  instance:
237
280
  title: GoogleSpannerInstance
238
281
  type: object
@@ -11,9 +11,17 @@ export declare const FIREBASE_STORAGE_EMULATOR_NAME = "google.firebaseStorage";
11
11
  */
12
12
  export declare function getFirebaseStorageContainerName(context: WorkspaceContext): string;
13
13
  /**
14
- * The exposed port for Firebase Storage.
14
+ * The default exposed host port for Firebase Storage.
15
15
  */
16
16
  export declare const FIREBASE_STORAGE_PORT = 9199;
17
+ /**
18
+ * Returns the host port to which the Firebase Storage emulator should be bound.
19
+ * Reads `google.firebaseStorage.emulator.port`, falling back to {@link FIREBASE_STORAGE_PORT}.
20
+ *
21
+ * @param context The {@link WorkspaceContext}.
22
+ * @returns The host port for the Firebase Storage emulator.
23
+ */
24
+ export declare function getFirebaseStorageEmulatorPort(context: WorkspaceContext): number;
17
25
  /**
18
26
  * The location of the Firebase Storage security rules file within the container.
19
27
  */
@@ -19,9 +19,21 @@ export function getFirebaseStorageContainerName(context) {
19
19
  return `${workspaceName}-firebase-storage`;
20
20
  }
21
21
  /**
22
- * The exposed port for Firebase Storage.
22
+ * The default exposed host port for Firebase Storage.
23
23
  */
24
24
  export const FIREBASE_STORAGE_PORT = 9199;
25
+ /**
26
+ * Returns the host port to which the Firebase Storage emulator should be bound.
27
+ * Reads `google.firebaseStorage.emulator.port`, falling back to {@link FIREBASE_STORAGE_PORT}.
28
+ *
29
+ * @param context The {@link WorkspaceContext}.
30
+ * @returns The host port for the Firebase Storage emulator.
31
+ */
32
+ export function getFirebaseStorageEmulatorPort(context) {
33
+ return (context
34
+ .asConfiguration()
35
+ .get('google.firebaseStorage.emulator.port') ?? FIREBASE_STORAGE_PORT);
36
+ }
25
37
  /**
26
38
  * The location of the Firebase Storage security rules file within the container.
27
39
  */
@@ -15,6 +15,14 @@ export declare function getFirestoreContainerName(context: WorkspaceContext): st
15
15
  */
16
16
  export declare const FIRESTORE_CONTAINER_RULES_FILE = "/firestore.rules";
17
17
  /**
18
- * The port on which the Firestore emulator listens.
18
+ * The default host port on which the Firestore emulator listens.
19
19
  */
20
20
  export declare const FIRESTORE_PORT = 8080;
21
+ /**
22
+ * Returns the host port to which the Firestore emulator should be bound.
23
+ * Reads `google.firestore.emulator.port`, falling back to {@link FIRESTORE_PORT}.
24
+ *
25
+ * @param context The {@link WorkspaceContext}.
26
+ * @returns The host port for the Firestore emulator.
27
+ */
28
+ export declare function getFirestoreEmulatorPort(context: WorkspaceContext): number;
@@ -23,6 +23,18 @@ export function getFirestoreContainerName(context) {
23
23
  */
24
24
  export const FIRESTORE_CONTAINER_RULES_FILE = '/firestore.rules';
25
25
  /**
26
- * The port on which the Firestore emulator listens.
26
+ * The default host port on which the Firestore emulator listens.
27
27
  */
28
28
  export const FIRESTORE_PORT = 8080;
29
+ /**
30
+ * Returns the host port to which the Firestore emulator should be bound.
31
+ * Reads `google.firestore.emulator.port`, falling back to {@link FIRESTORE_PORT}.
32
+ *
33
+ * @param context The {@link WorkspaceContext}.
34
+ * @returns The host port for the Firestore emulator.
35
+ */
36
+ export function getFirestoreEmulatorPort(context) {
37
+ return (context
38
+ .asConfiguration()
39
+ .get('google.firestore.emulator.port') ?? FIRESTORE_PORT);
40
+ }
@@ -11,6 +11,14 @@ export declare const IDENTITY_PLATFORM_EMULATOR_NAME = "google.identityPlatform"
11
11
  */
12
12
  export declare function getIdentityPlatformContainerName(context: WorkspaceContext): string;
13
13
  /**
14
- * The port on which the Firebase Auth emulator is listening.
14
+ * The default host port on which the Firebase Auth emulator is listening.
15
15
  */
16
16
  export declare const FIREBASE_AUTH_PORT = 9099;
17
+ /**
18
+ * Returns the host port to which the Identity Platform (Firebase Auth) emulator should be bound.
19
+ * Reads `google.identityPlatform.emulator.port`, falling back to {@link FIREBASE_AUTH_PORT}.
20
+ *
21
+ * @param context The {@link WorkspaceContext}.
22
+ * @returns The host port for the Identity Platform emulator.
23
+ */
24
+ export declare function getIdentityPlatformEmulatorPort(context: WorkspaceContext): number;
@@ -19,6 +19,18 @@ export function getIdentityPlatformContainerName(context) {
19
19
  return `${workspaceName}-identity-platform`;
20
20
  }
21
21
  /**
22
- * The port on which the Firebase Auth emulator is listening.
22
+ * The default host port on which the Firebase Auth emulator is listening.
23
23
  */
24
24
  export const FIREBASE_AUTH_PORT = 9099;
25
+ /**
26
+ * Returns the host port to which the Identity Platform (Firebase Auth) emulator should be bound.
27
+ * Reads `google.identityPlatform.emulator.port`, falling back to {@link FIREBASE_AUTH_PORT}.
28
+ *
29
+ * @param context The {@link WorkspaceContext}.
30
+ * @returns The host port for the Identity Platform emulator.
31
+ */
32
+ export function getIdentityPlatformEmulatorPort(context) {
33
+ return (context
34
+ .asConfiguration()
35
+ .get('google.identityPlatform.emulator.port') ?? FIREBASE_AUTH_PORT);
36
+ }
@@ -11,9 +11,17 @@ export declare const PUBSUB_EMULATOR_NAME = "google.pubSub";
11
11
  */
12
12
  export declare function getPubSubContainerName(context: WorkspaceContext): string;
13
13
  /**
14
- * The port on which the Pub/Sub emulator is listening.
14
+ * The default host port on which the Pub/Sub emulator is listening.
15
15
  */
16
16
  export declare const PUBSUB_PORT = 8085;
17
+ /**
18
+ * Returns the host port to which the Pub/Sub emulator should be bound.
19
+ * Reads `google.pubSub.emulator.port`, falling back to {@link PUBSUB_PORT}.
20
+ *
21
+ * @param context The {@link WorkspaceContext}.
22
+ * @returns The host port for the Pub/Sub emulator.
23
+ */
24
+ export declare function getPubSubEmulatorPort(context: WorkspaceContext): number;
17
25
  /**
18
26
  * Formats the name of a Pub/Sub topic as an environment variable.
19
27
  * The value of the corresponding environment variable is expected to be the Pub/Sub topic ID, e.g.
@@ -19,9 +19,21 @@ export function getPubSubContainerName(context) {
19
19
  return `${workspaceName}-pubsub`;
20
20
  }
21
21
  /**
22
- * The port on which the Pub/Sub emulator is listening.
22
+ * The default host port on which the Pub/Sub emulator is listening.
23
23
  */
24
24
  export const PUBSUB_PORT = 8085;
25
+ /**
26
+ * Returns the host port to which the Pub/Sub emulator should be bound.
27
+ * Reads `google.pubSub.emulator.port`, falling back to {@link PUBSUB_PORT}.
28
+ *
29
+ * @param context The {@link WorkspaceContext}.
30
+ * @returns The host port for the Pub/Sub emulator.
31
+ */
32
+ export function getPubSubEmulatorPort(context) {
33
+ return (context
34
+ .asConfiguration()
35
+ .get('google.pubSub.emulator.port') ?? PUBSUB_PORT);
36
+ }
25
37
  /**
26
38
  * Formats the name of a Pub/Sub topic as an environment variable.
27
39
  * The value of the corresponding environment variable is expected to be the Pub/Sub topic ID, e.g.
@@ -15,10 +15,26 @@ export declare function getSpannerContainerName(context: WorkspaceContext): stri
15
15
  */
16
16
  export declare const SPANNER_IMAGE = "gcr.io/cloud-spanner-emulator/emulator";
17
17
  /**
18
- * The port on which the Spanner emulator exposes its gRPC API.
18
+ * The default host port on which the Spanner emulator exposes its gRPC API.
19
19
  */
20
20
  export declare const SPANNER_GRPC_PORT = 9010;
21
21
  /**
22
- * The port on which the Spanner emulator exposes its HTTP API.
22
+ * The default host port on which the Spanner emulator exposes its HTTP API.
23
23
  */
24
24
  export declare const SPANNER_HTTP_PORT = 9020;
25
+ /**
26
+ * Returns the host port to which the Spanner emulator gRPC API should be bound.
27
+ * Reads `google.spanner.emulator.grpcPort`, falling back to {@link SPANNER_GRPC_PORT}.
28
+ *
29
+ * @param context The {@link WorkspaceContext}.
30
+ * @returns The host gRPC port for the Spanner emulator.
31
+ */
32
+ export declare function getSpannerEmulatorGrpcPort(context: WorkspaceContext): number;
33
+ /**
34
+ * Returns the host port to which the Spanner emulator HTTP API should be bound.
35
+ * Reads `google.spanner.emulator.httpPort`, falling back to {@link SPANNER_HTTP_PORT}.
36
+ *
37
+ * @param context The {@link WorkspaceContext}.
38
+ * @returns The host HTTP port for the Spanner emulator.
39
+ */
40
+ export declare function getSpannerEmulatorHttpPort(context: WorkspaceContext): number;
@@ -23,10 +23,34 @@ export function getSpannerContainerName(context) {
23
23
  */
24
24
  export const SPANNER_IMAGE = `gcr.io/cloud-spanner-emulator/emulator`;
25
25
  /**
26
- * The port on which the Spanner emulator exposes its gRPC API.
26
+ * The default host port on which the Spanner emulator exposes its gRPC API.
27
27
  */
28
28
  export const SPANNER_GRPC_PORT = 9010;
29
29
  /**
30
- * The port on which the Spanner emulator exposes its HTTP API.
30
+ * The default host port on which the Spanner emulator exposes its HTTP API.
31
31
  */
32
32
  export const SPANNER_HTTP_PORT = 9020;
33
+ /**
34
+ * Returns the host port to which the Spanner emulator gRPC API should be bound.
35
+ * Reads `google.spanner.emulator.grpcPort`, falling back to {@link SPANNER_GRPC_PORT}.
36
+ *
37
+ * @param context The {@link WorkspaceContext}.
38
+ * @returns The host gRPC port for the Spanner emulator.
39
+ */
40
+ export function getSpannerEmulatorGrpcPort(context) {
41
+ return (context
42
+ .asConfiguration()
43
+ .get('google.spanner.emulator.grpcPort') ?? SPANNER_GRPC_PORT);
44
+ }
45
+ /**
46
+ * Returns the host port to which the Spanner emulator HTTP API should be bound.
47
+ * Reads `google.spanner.emulator.httpPort`, falling back to {@link SPANNER_HTTP_PORT}.
48
+ *
49
+ * @param context The {@link WorkspaceContext}.
50
+ * @returns The host HTTP port for the Spanner emulator.
51
+ */
52
+ export function getSpannerEmulatorHttpPort(context) {
53
+ return (context
54
+ .asConfiguration()
55
+ .get('google.spanner.emulator.httpPort') ?? SPANNER_HTTP_PORT);
56
+ }
@@ -1,6 +1,6 @@
1
1
  import { EmulatorStart } from '@causa/workspace-core';
2
2
  import { fileURLToPath } from 'url';
3
- import { FIREBASE_CONTAINER_STORAGE_RULES_FILE, FIREBASE_STORAGE_EMULATOR_NAME, FIREBASE_STORAGE_PORT, getFirebaseStorageContainerName, } from '../../emulators/index.js';
3
+ import { FIREBASE_CONTAINER_STORAGE_RULES_FILE, FIREBASE_STORAGE_EMULATOR_NAME, FIREBASE_STORAGE_PORT, getFirebaseStorageContainerName, getFirebaseStorageEmulatorPort, } from '../../emulators/index.js';
4
4
  import { FirebaseEmulatorService } from '../../services/firebase-emulator.js';
5
5
  import { GoogleFirebaseStorageMergeRules } from '../google-firebase-storage/index.js';
6
6
  /**
@@ -30,12 +30,13 @@ export class EmulatorStartForFirebaseStorage extends EmulatorStart {
30
30
  const { securityRuleFile } = await this._context.call(GoogleFirebaseStorageMergeRules, {});
31
31
  this._context.logger.info('️🍱 Starting Firebase Storage emulator.');
32
32
  const containerName = getFirebaseStorageContainerName(this._context);
33
+ const hostPort = getFirebaseStorageEmulatorPort(this._context);
33
34
  const firebaseEmulatorService = this._context.service(FirebaseEmulatorService);
34
35
  await firebaseEmulatorService.start(containerName, FIREBASE_CONF_FILE, [
35
36
  {
36
37
  host: '127.0.0.1',
37
38
  container: FIREBASE_STORAGE_PORT,
38
- local: FIREBASE_STORAGE_PORT,
39
+ local: hostPort,
39
40
  },
40
41
  ], {
41
42
  mounts: [
@@ -51,7 +52,7 @@ export class EmulatorStartForFirebaseStorage extends EmulatorStart {
51
52
  });
52
53
  this._context.logger.info('️🍱 Successfully initialized Firebase Storage emulator.');
53
54
  return {
54
- FIREBASE_STORAGE_EMULATOR_HOST: `127.0.0.1:${FIREBASE_STORAGE_PORT}`,
55
+ FIREBASE_STORAGE_EMULATOR_HOST: `127.0.0.1:${hostPort}`,
55
56
  GOOGLE_CLOUD_PROJECT: firebaseEmulatorService.localGcpProject,
56
57
  GCP_PROJECT: firebaseEmulatorService.localGcpProject,
57
58
  GCLOUD_PROJECT: firebaseEmulatorService.localGcpProject,
@@ -1,5 +1,5 @@
1
1
  import { EmulatorStart } from '@causa/workspace-core';
2
- import { FIRESTORE_CONTAINER_RULES_FILE, FIRESTORE_EMULATOR_NAME, FIRESTORE_PORT, getFirestoreContainerName, } from '../../emulators/index.js';
2
+ import { FIRESTORE_CONTAINER_RULES_FILE, FIRESTORE_EMULATOR_NAME, FIRESTORE_PORT, getFirestoreContainerName, getFirestoreEmulatorPort, } from '../../emulators/index.js';
3
3
  import { GcloudEmulatorService } from '../../services/gcloud-emulator.js';
4
4
  import { GoogleFirestoreMergeRules } from '../google-firestore/index.js';
5
5
  /**
@@ -26,14 +26,9 @@ export class EmulatorStartForFirestore extends EmulatorStart {
26
26
  const { securityRuleFile } = await this._context.call(GoogleFirestoreMergeRules, {});
27
27
  this._context.logger.info('🗃️ Starting Firestore emulator.');
28
28
  const containerName = getFirestoreContainerName(this._context);
29
+ const hostPort = getFirestoreEmulatorPort(this._context);
29
30
  const gcloudEmulatorService = this._context.service(GcloudEmulatorService);
30
- await gcloudEmulatorService.start('firestore', containerName, [
31
- {
32
- host: '127.0.0.1',
33
- local: FIRESTORE_PORT,
34
- container: FIRESTORE_PORT,
35
- },
36
- ], {
31
+ await gcloudEmulatorService.start('firestore', containerName, [{ host: '127.0.0.1', local: hostPort, container: FIRESTORE_PORT }], {
37
32
  mounts: [
38
33
  {
39
34
  type: 'bind',
@@ -43,11 +38,11 @@ export class EmulatorStartForFirestore extends EmulatorStart {
43
38
  },
44
39
  ],
45
40
  additionalArguments: ['--rules', FIRESTORE_CONTAINER_RULES_FILE],
46
- availabilityEndpoint: `http://127.0.0.1:${FIRESTORE_PORT}/`,
41
+ availabilityEndpoint: `http://127.0.0.1:${hostPort}/`,
47
42
  });
48
43
  this._context.logger.info('🗃️ Successfully initialized Firestore emulator.');
49
44
  return {
50
- FIRESTORE_EMULATOR_HOST: `127.0.0.1:${FIRESTORE_PORT}`,
45
+ FIRESTORE_EMULATOR_HOST: `127.0.0.1:${hostPort}`,
51
46
  GOOGLE_CLOUD_PROJECT: gcloudEmulatorService.localGcpProject,
52
47
  GCP_PROJECT: gcloudEmulatorService.localGcpProject,
53
48
  GCLOUD_PROJECT: gcloudEmulatorService.localGcpProject,
@@ -1,6 +1,6 @@
1
1
  import { EmulatorStart } from '@causa/workspace-core';
2
2
  import { fileURLToPath } from 'url';
3
- import { FIREBASE_AUTH_PORT, IDENTITY_PLATFORM_EMULATOR_NAME, getIdentityPlatformContainerName, } from '../../emulators/index.js';
3
+ import { FIREBASE_AUTH_PORT, IDENTITY_PLATFORM_EMULATOR_NAME, getIdentityPlatformContainerName, getIdentityPlatformEmulatorPort, } from '../../emulators/index.js';
4
4
  import { FirebaseEmulatorService } from '../../services/firebase-emulator.js';
5
5
  /**
6
6
  * The Firebase configuration file enabling only the Auth emulator.
@@ -27,17 +27,14 @@ export class EmulatorStartForIdentityPlatform extends EmulatorStart {
27
27
  }
28
28
  this._context.logger.info('🛂 Starting the Identity Platform emulator.');
29
29
  const containerName = getIdentityPlatformContainerName(this._context);
30
+ const hostPort = getIdentityPlatformEmulatorPort(this._context);
30
31
  const firebaseEmulatorService = this._context.service(FirebaseEmulatorService);
31
32
  await firebaseEmulatorService.start(containerName, FIREBASE_CONF_FILE, [
32
- {
33
- host: '127.0.0.1',
34
- local: FIREBASE_AUTH_PORT,
35
- container: FIREBASE_AUTH_PORT,
36
- },
33
+ { host: '127.0.0.1', local: hostPort, container: FIREBASE_AUTH_PORT },
37
34
  ]);
38
35
  this._context.logger.info('🛂 Successfully initialized the Identity Platform emulator.');
39
36
  return {
40
- FIREBASE_AUTH_EMULATOR_HOST: `127.0.0.1:${FIREBASE_AUTH_PORT}`,
37
+ FIREBASE_AUTH_EMULATOR_HOST: `127.0.0.1:${hostPort}`,
41
38
  GOOGLE_CLOUD_PROJECT: firebaseEmulatorService.localGcpProject,
42
39
  GCP_PROJECT: firebaseEmulatorService.localGcpProject,
43
40
  GCLOUD_PROJECT: firebaseEmulatorService.localGcpProject,
@@ -1,7 +1,7 @@
1
1
  import { EventTopicList, } from '@causa/workspace-core';
2
2
  import { PubSub } from '@google-cloud/pubsub';
3
3
  import { getLocalGcpProject } from '../../configurations/utils.js';
4
- import { PUBSUB_EMULATOR_NAME, PUBSUB_PORT, formatPubSubTopicAsEnvironmentVariable, getPubSubContainerName, } from '../../emulators/index.js';
4
+ import { PUBSUB_EMULATOR_NAME, PUBSUB_PORT, formatPubSubTopicAsEnvironmentVariable, getPubSubContainerName, getPubSubEmulatorPort, } from '../../emulators/index.js';
5
5
  import { GcloudEmulatorService } from '../../services/gcloud-emulator.js';
6
6
  export default async function call() {
7
7
  const configuration = await startPubSub(this, this._context);
@@ -11,27 +11,28 @@ async function startPubSub(self, context) {
11
11
  if (self.dryRun) {
12
12
  return {};
13
13
  }
14
- const emulatorConf = await startPubSubEmulator(context);
15
- const topicsConf = await createTopicsIfNeeded(context);
14
+ const hostPort = getPubSubEmulatorPort(context);
15
+ const emulatorConf = await startPubSubEmulator(context, hostPort);
16
+ const topicsConf = await createTopicsIfNeeded(context, hostPort);
16
17
  context.logger.info('📫 Successfully initialized Pub/Sub emulator.');
17
18
  return { ...emulatorConf, ...topicsConf };
18
19
  }
19
- async function startPubSubEmulator(context) {
20
+ async function startPubSubEmulator(context, hostPort) {
20
21
  context.logger.info('📫 Starting Pub/Sub emulator.');
21
22
  const gcpProject = getLocalGcpProject(context);
22
23
  const containerName = getPubSubContainerName(context);
23
24
  const gcloudEmulatorService = context.service(GcloudEmulatorService);
24
- await gcloudEmulatorService.start('pubsub', containerName, [{ host: '127.0.0.1', local: PUBSUB_PORT, container: PUBSUB_PORT }], {
25
- availabilityEndpoint: `http://127.0.0.1:${PUBSUB_PORT}/v1/projects/${gcpProject}/topics`,
25
+ await gcloudEmulatorService.start('pubsub', containerName, [{ host: '127.0.0.1', local: hostPort, container: PUBSUB_PORT }], {
26
+ availabilityEndpoint: `http://127.0.0.1:${hostPort}/v1/projects/${gcpProject}/topics`,
26
27
  });
27
28
  return {
28
- PUBSUB_EMULATOR_HOST: `127.0.0.1:${PUBSUB_PORT}`,
29
+ PUBSUB_EMULATOR_HOST: `127.0.0.1:${hostPort}`,
29
30
  GOOGLE_CLOUD_PROJECT: gcloudEmulatorService.localGcpProject,
30
31
  GCP_PROJECT: gcloudEmulatorService.localGcpProject,
31
32
  GCLOUD_PROJECT: gcloudEmulatorService.localGcpProject,
32
33
  };
33
34
  }
34
- async function createTopicsIfNeeded(context) {
35
+ async function createTopicsIfNeeded(context, hostPort) {
35
36
  if (context.get('events.broker') !== 'google.pubSub') {
36
37
  context.logger.warn('📫️ Pub/Sub is not set as the event broker. Skipping event topics setup.');
37
38
  return {};
@@ -40,7 +41,7 @@ async function createTopicsIfNeeded(context) {
40
41
  const gcpProject = getLocalGcpProject(context);
41
42
  const pubSub = new PubSub({
42
43
  projectId: gcpProject,
43
- apiEndpoint: `127.0.0.1:${PUBSUB_PORT}`,
44
+ apiEndpoint: `127.0.0.1:${hostPort}`,
44
45
  });
45
46
  const envVars = await Promise.all(topics.map(async ({ id }) => {
46
47
  context.logger.info(`📫 Creating Pub/Sub emulator topic '${id}'.`);