@causa/workspace-google 0.1.1 → 0.2.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/dist/assets/firebase-auth.json +12 -0
- package/dist/assets/firebase-storage.json +15 -0
- package/dist/cli/google-app-check.d.ts +5 -0
- package/dist/cli/google-app-check.js +9 -0
- package/dist/cli/google-identity-platform.d.ts +5 -0
- package/dist/cli/google-identity-platform.js +9 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +2 -0
- package/dist/configurations/google.d.ts +15 -8
- package/dist/configurations/index.d.ts +1 -0
- package/dist/configurations/index.js +1 -1
- package/dist/configurations/utils.d.ts +10 -0
- package/dist/configurations/utils.js +17 -0
- package/dist/emulators/firebase-storage.d.ts +20 -0
- package/dist/emulators/firebase-storage.js +27 -0
- package/dist/emulators/firestore.d.ts +20 -0
- package/dist/emulators/firestore.js +27 -0
- package/dist/emulators/identity-platform.d.ts +16 -0
- package/dist/emulators/identity-platform.js +23 -0
- package/dist/emulators/index.d.ts +5 -0
- package/dist/emulators/index.js +5 -0
- package/dist/emulators/pubsub.d.ts +25 -0
- package/dist/emulators/pubsub.js +35 -0
- package/dist/emulators/spanner.d.ts +24 -0
- package/dist/emulators/spanner.js +31 -0
- package/dist/functions/emulator-start-firebase-storage.d.ts +17 -0
- package/dist/functions/emulator-start-firebase-storage.js +64 -0
- package/dist/functions/emulator-start-firestore.d.ts +17 -0
- package/dist/functions/emulator-start-firestore.js +58 -0
- package/dist/functions/emulator-start-identity-platform.d.ts +16 -0
- package/dist/functions/emulator-start-identity-platform.js +49 -0
- package/dist/functions/emulator-start-pubsub.d.ts +33 -0
- package/dist/functions/emulator-start-pubsub.js +86 -0
- package/dist/functions/emulator-start-spanner.d.ts +40 -0
- package/dist/functions/emulator-start-spanner.js +112 -0
- package/dist/functions/emulator-stop-firebase-storage.d.ts +9 -0
- package/dist/functions/emulator-stop-firebase-storage.js +17 -0
- package/dist/functions/emulator-stop-firestore.d.ts +9 -0
- package/dist/functions/emulator-stop-firestore.js +17 -0
- package/dist/functions/emulator-stop-identity-platform.d.ts +9 -0
- package/dist/functions/emulator-stop-identity-platform.js +17 -0
- package/dist/functions/emulator-stop-pubsub.d.ts +9 -0
- package/dist/functions/emulator-stop-pubsub.js +17 -0
- package/dist/functions/emulator-stop-spanner.d.ts +9 -0
- package/dist/functions/emulator-stop-spanner.js +17 -0
- package/dist/functions/google-app-check-generate-token.d.ts +13 -0
- package/dist/functions/google-app-check-generate-token.js +67 -0
- package/dist/functions/google-identity-platform-generate-custom-token.d.ts +20 -0
- package/dist/functions/google-identity-platform-generate-custom-token.js +49 -0
- package/dist/functions/google-identity-platform-generate-token.d.ts +18 -0
- package/dist/functions/google-identity-platform-generate-token.js +74 -0
- package/dist/functions/google-spanner-list-databases.d.ts +33 -0
- package/dist/functions/google-spanner-list-databases.js +66 -0
- package/dist/functions/index.js +16 -1
- package/dist/functions/project-get-artefact-destination-service-container.d.ts +10 -0
- package/dist/functions/project-get-artefact-destination-service-container.js +17 -0
- package/dist/services/firebase-app.d.ts +151 -0
- package/dist/services/firebase-app.errors.d.ts +26 -0
- package/dist/services/firebase-app.errors.js +35 -0
- package/dist/services/firebase-app.js +286 -0
- package/dist/services/firebase-emulator.d.ts +35 -0
- package/dist/services/firebase-emulator.js +65 -0
- package/dist/services/gcloud-emulator.d.ts +55 -0
- package/dist/services/gcloud-emulator.js +66 -0
- package/dist/services/google-apis.d.ts +34 -0
- package/dist/services/google-apis.js +48 -0
- package/dist/services/google-apis.types.d.ts +226 -0
- package/dist/services/google-apis.types.js +4 -0
- package/dist/services/index.d.ts +5 -0
- package/dist/services/index.js +5 -0
- package/package.json +19 -6
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { googleCommandDefinition } from './google.js';
|
|
2
|
+
/**
|
|
3
|
+
* The parent `google appCheck` command.
|
|
4
|
+
*/
|
|
5
|
+
export const appCheckCommandDefinition = {
|
|
6
|
+
parent: googleCommandDefinition,
|
|
7
|
+
name: 'appCheck',
|
|
8
|
+
description: 'Performs AppCheck-related operations.',
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { googleCommandDefinition } from './google.js';
|
|
2
|
+
/**
|
|
3
|
+
* The parent `google identityPlatform` command.
|
|
4
|
+
*/
|
|
5
|
+
export const identityPlatformCommandDefinition = {
|
|
6
|
+
parent: googleCommandDefinition,
|
|
7
|
+
name: 'identityPlatform',
|
|
8
|
+
description: 'Performs Identity Platform-related operations.',
|
|
9
|
+
};
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { appCheckCommandDefinition } from './google-app-check.js';
|
|
1
2
|
export { firebaseStorageCommandDefinition } from './google-firebase-storage.js';
|
|
2
3
|
export { firestoreCommandDefinition } from './google-firestore.js';
|
|
4
|
+
export { identityPlatformCommandDefinition } from './google-identity-platform.js';
|
|
3
5
|
export { googleCommandDefinition } from './google.js';
|
package/dist/cli/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { appCheckCommandDefinition } from './google-app-check.js';
|
|
1
2
|
export { firebaseStorageCommandDefinition } from './google-firebase-storage.js';
|
|
2
3
|
export { firestoreCommandDefinition } from './google-firestore.js';
|
|
4
|
+
export { identityPlatformCommandDefinition } from './google-identity-platform.js';
|
|
3
5
|
export { googleCommandDefinition } from './google.js';
|
|
@@ -50,21 +50,28 @@ export type GoogleConfiguration = {
|
|
|
50
50
|
* the API.
|
|
51
51
|
*/
|
|
52
52
|
apiKey?: string;
|
|
53
|
+
/**
|
|
54
|
+
* The Firebase app ID used by clients.
|
|
55
|
+
* This can be found in the Firebase Console. Each platform (Android, iOS, Web) has its own app ID.
|
|
56
|
+
* If this is not set and is needed by an operation, an attempt will be made to find the first eligible app ID
|
|
57
|
+
* using the Firebase API.
|
|
58
|
+
*/
|
|
59
|
+
appId?: string;
|
|
53
60
|
/**
|
|
54
61
|
* The domain name for the project.
|
|
55
62
|
* If not set, this default to `<GCP project>.firebaseapp.com`.
|
|
56
63
|
*/
|
|
57
64
|
authDomain?: string;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Configuration for Firebase tools (the CLI).
|
|
61
|
-
* This applies to Dockerized calls to the `firebase` CLI.
|
|
62
|
-
*/
|
|
63
|
-
firebaseTools?: {
|
|
64
65
|
/**
|
|
65
|
-
*
|
|
66
|
+
* Configuration for Firebase tools (the CLI).
|
|
67
|
+
* This applies to Dockerized calls to the `firebase` CLI.
|
|
66
68
|
*/
|
|
67
|
-
|
|
69
|
+
tools?: {
|
|
70
|
+
/**
|
|
71
|
+
* The version of the CLI to use.
|
|
72
|
+
*/
|
|
73
|
+
version?: string;
|
|
74
|
+
};
|
|
68
75
|
};
|
|
69
76
|
/**
|
|
70
77
|
* Configuration for the Secret Manager service.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './utils.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
/**
|
|
3
|
+
* Gets or formats the ID of the local GCP project.
|
|
4
|
+
* For some emulators to work correctly, the ID must start with `demo-`.
|
|
5
|
+
* By default, the name of the workspace is appended to this.
|
|
6
|
+
*
|
|
7
|
+
* @param context The {@link WorkspaceContext}.
|
|
8
|
+
* @returns The ID of the local GCP project that should be used with emulators.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getLocalGcpProject(context: WorkspaceContext): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets or formats the ID of the local GCP project.
|
|
3
|
+
* For some emulators to work correctly, the ID must start with `demo-`.
|
|
4
|
+
* By default, the name of the workspace is appended to this.
|
|
5
|
+
*
|
|
6
|
+
* @param context The {@link WorkspaceContext}.
|
|
7
|
+
* @returns The ID of the local GCP project that should be used with emulators.
|
|
8
|
+
*/
|
|
9
|
+
export function getLocalGcpProject(context) {
|
|
10
|
+
const googleConf = context.asConfiguration();
|
|
11
|
+
const localProject = googleConf.get('google.localProject');
|
|
12
|
+
if (localProject) {
|
|
13
|
+
return localProject;
|
|
14
|
+
}
|
|
15
|
+
const workspaceName = googleConf.getOrThrow('workspace.name');
|
|
16
|
+
return `demo-${workspaceName}`;
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
/**
|
|
3
|
+
* The name of the Firebase Storage emulator.
|
|
4
|
+
*/
|
|
5
|
+
export declare const FIREBASE_STORAGE_EMULATOR_NAME = "google.firebaseStorage";
|
|
6
|
+
/**
|
|
7
|
+
* Gets the name of the Firebase Storage emulator Docker container from the configuration.
|
|
8
|
+
*
|
|
9
|
+
* @param context The {@link WorkspaceContext}.
|
|
10
|
+
* @returns The name of the Firebase Storage emulator Docker container.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getFirebaseStorageContainerName(context: WorkspaceContext): string;
|
|
13
|
+
/**
|
|
14
|
+
* The exposed port for Firebase Storage.
|
|
15
|
+
*/
|
|
16
|
+
export declare const FIREBASE_STORAGE_PORT = 9199;
|
|
17
|
+
/**
|
|
18
|
+
* The location of the Firebase Storage security rules file within the container.
|
|
19
|
+
*/
|
|
20
|
+
export declare const FIREBASE_CONTAINER_STORAGE_RULES_FILE = "/home/node/storage.rules";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name of the Firebase Storage emulator.
|
|
3
|
+
*/
|
|
4
|
+
export const FIREBASE_STORAGE_EMULATOR_NAME = 'google.firebaseStorage';
|
|
5
|
+
/**
|
|
6
|
+
* Gets the name of the Firebase Storage emulator Docker container from the configuration.
|
|
7
|
+
*
|
|
8
|
+
* @param context The {@link WorkspaceContext}.
|
|
9
|
+
* @returns The name of the Firebase Storage emulator Docker container.
|
|
10
|
+
*/
|
|
11
|
+
export function getFirebaseStorageContainerName(context) {
|
|
12
|
+
const googleConf = context.asConfiguration();
|
|
13
|
+
const containerName = googleConf.get('google.firebaseStorage.emulator.containerName');
|
|
14
|
+
if (containerName) {
|
|
15
|
+
return containerName;
|
|
16
|
+
}
|
|
17
|
+
const workspaceName = googleConf.getOrThrow('workspace.name');
|
|
18
|
+
return `${workspaceName}-firebase-storage`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The exposed port for Firebase Storage.
|
|
22
|
+
*/
|
|
23
|
+
export const FIREBASE_STORAGE_PORT = 9199;
|
|
24
|
+
/**
|
|
25
|
+
* The location of the Firebase Storage security rules file within the container.
|
|
26
|
+
*/
|
|
27
|
+
export const FIREBASE_CONTAINER_STORAGE_RULES_FILE = '/home/node/storage.rules';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
/**
|
|
3
|
+
* The name of the Firestore emulator.
|
|
4
|
+
*/
|
|
5
|
+
export declare const FIRESTORE_EMULATOR_NAME = "google.firestore";
|
|
6
|
+
/**
|
|
7
|
+
* Gets the name of the Firestore emulator Docker container from the configuration.
|
|
8
|
+
*
|
|
9
|
+
* @param context The {@link WorkspaceContext}.
|
|
10
|
+
* @returns The name of the Firestore emulator Docker container.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getFirestoreContainerName(context: WorkspaceContext): string;
|
|
13
|
+
/**
|
|
14
|
+
* The path to the Firestore security rules file within the container.
|
|
15
|
+
*/
|
|
16
|
+
export declare const FIRESTORE_CONTAINER_RULES_FILE = "/firestore.rules";
|
|
17
|
+
/**
|
|
18
|
+
* The port on which the Firestore emulator listens.
|
|
19
|
+
*/
|
|
20
|
+
export declare const FIRESTORE_PORT = 8080;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name of the Firestore emulator.
|
|
3
|
+
*/
|
|
4
|
+
export const FIRESTORE_EMULATOR_NAME = 'google.firestore';
|
|
5
|
+
/**
|
|
6
|
+
* Gets the name of the Firestore emulator Docker container from the configuration.
|
|
7
|
+
*
|
|
8
|
+
* @param context The {@link WorkspaceContext}.
|
|
9
|
+
* @returns The name of the Firestore emulator Docker container.
|
|
10
|
+
*/
|
|
11
|
+
export function getFirestoreContainerName(context) {
|
|
12
|
+
const googleConf = context.asConfiguration();
|
|
13
|
+
const containerName = googleConf.get('google.firestore.emulator.containerName');
|
|
14
|
+
if (containerName) {
|
|
15
|
+
return containerName;
|
|
16
|
+
}
|
|
17
|
+
const workspaceName = googleConf.getOrThrow('workspace.name');
|
|
18
|
+
return `${workspaceName}-firestore`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The path to the Firestore security rules file within the container.
|
|
22
|
+
*/
|
|
23
|
+
export const FIRESTORE_CONTAINER_RULES_FILE = '/firestore.rules';
|
|
24
|
+
/**
|
|
25
|
+
* The port on which the Firestore emulator listens.
|
|
26
|
+
*/
|
|
27
|
+
export const FIRESTORE_PORT = 8080;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
/**
|
|
3
|
+
* The name of the Identity Platform emulator.
|
|
4
|
+
*/
|
|
5
|
+
export declare const IDENTITY_PLATFORM_EMULATOR_NAME = "google.identityPlatform";
|
|
6
|
+
/**
|
|
7
|
+
* Gets the name of the Identity Platform emulator Docker container from the configuration.
|
|
8
|
+
*
|
|
9
|
+
* @param context The {@link WorkspaceContext}.
|
|
10
|
+
* @returns The name of the Identity Platform emulator Docker container.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getIdentityPlatformContainerName(context: WorkspaceContext): string;
|
|
13
|
+
/**
|
|
14
|
+
* The port on which the Firebase Auth emulator is listening.
|
|
15
|
+
*/
|
|
16
|
+
export declare const FIREBASE_AUTH_PORT = 9099;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name of the Identity Platform emulator.
|
|
3
|
+
*/
|
|
4
|
+
export const IDENTITY_PLATFORM_EMULATOR_NAME = 'google.identityPlatform';
|
|
5
|
+
/**
|
|
6
|
+
* Gets the name of the Identity Platform emulator Docker container from the configuration.
|
|
7
|
+
*
|
|
8
|
+
* @param context The {@link WorkspaceContext}.
|
|
9
|
+
* @returns The name of the Identity Platform emulator Docker container.
|
|
10
|
+
*/
|
|
11
|
+
export function getIdentityPlatformContainerName(context) {
|
|
12
|
+
const googleConf = context.asConfiguration();
|
|
13
|
+
const containerName = googleConf.get('google.identityPlatform.emulator.containerName');
|
|
14
|
+
if (containerName) {
|
|
15
|
+
return containerName;
|
|
16
|
+
}
|
|
17
|
+
const workspaceName = googleConf.getOrThrow('workspace.name');
|
|
18
|
+
return `${workspaceName}-identity-platform`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The port on which the Firebase Auth emulator is listening.
|
|
22
|
+
*/
|
|
23
|
+
export const FIREBASE_AUTH_PORT = 9099;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
/**
|
|
3
|
+
* The name of the Pub/Sub emulator.
|
|
4
|
+
*/
|
|
5
|
+
export declare const PUBSUB_EMULATOR_NAME = "google.pubSub";
|
|
6
|
+
/**
|
|
7
|
+
* Gets the name of the Pub/Sub emulator Docker container from the configuration.
|
|
8
|
+
*
|
|
9
|
+
* @param context The {@link WorkspaceContext}.
|
|
10
|
+
* @returns The name of the Pub/Sub emulator Docker container.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getPubSubContainerName(context: WorkspaceContext): string;
|
|
13
|
+
/**
|
|
14
|
+
* The port on which the Pub/Sub emulator is listening.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PUBSUB_PORT = 8085;
|
|
17
|
+
/**
|
|
18
|
+
* Formats the name of a Pub/Sub topic as an environment variable.
|
|
19
|
+
* The value of the corresponding environment variable is expected to be the Pub/Sub topic ID, e.g.
|
|
20
|
+
* `projects/my-project/topics/my-topic`.
|
|
21
|
+
*
|
|
22
|
+
* @param topicId The ID of the event topic.
|
|
23
|
+
* @returns The name of the environment variable that should be used to configure the Pub/Sub topic.
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatPubSubTopicAsEnvironmentVariable(topicId: string): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name of the Pub/Sub emulator.
|
|
3
|
+
*/
|
|
4
|
+
export const PUBSUB_EMULATOR_NAME = 'google.pubSub';
|
|
5
|
+
/**
|
|
6
|
+
* Gets the name of the Pub/Sub emulator Docker container from the configuration.
|
|
7
|
+
*
|
|
8
|
+
* @param context The {@link WorkspaceContext}.
|
|
9
|
+
* @returns The name of the Pub/Sub emulator Docker container.
|
|
10
|
+
*/
|
|
11
|
+
export function getPubSubContainerName(context) {
|
|
12
|
+
const googleConf = context.asConfiguration();
|
|
13
|
+
const containerName = googleConf.get('google.pubSub.emulator.containerName');
|
|
14
|
+
if (containerName) {
|
|
15
|
+
return containerName;
|
|
16
|
+
}
|
|
17
|
+
const workspaceName = googleConf.getOrThrow('workspace.name');
|
|
18
|
+
return `${workspaceName}-pubsub`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The port on which the Pub/Sub emulator is listening.
|
|
22
|
+
*/
|
|
23
|
+
export const PUBSUB_PORT = 8085;
|
|
24
|
+
/**
|
|
25
|
+
* Formats the name of a Pub/Sub topic as an environment variable.
|
|
26
|
+
* The value of the corresponding environment variable is expected to be the Pub/Sub topic ID, e.g.
|
|
27
|
+
* `projects/my-project/topics/my-topic`.
|
|
28
|
+
*
|
|
29
|
+
* @param topicId The ID of the event topic.
|
|
30
|
+
* @returns The name of the environment variable that should be used to configure the Pub/Sub topic.
|
|
31
|
+
*/
|
|
32
|
+
export function formatPubSubTopicAsEnvironmentVariable(topicId) {
|
|
33
|
+
const formattedTopicName = topicId.toUpperCase().replace(/[-\.]/g, '_');
|
|
34
|
+
return `PUBSUB_TOPIC_${formattedTopicName}`;
|
|
35
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
/**
|
|
3
|
+
* The name of the Spanner emulator.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SPANNER_EMULATOR_NAME = "google.spanner";
|
|
6
|
+
/**
|
|
7
|
+
* Gets the name of the Spanner emulator Docker container from the configuration.
|
|
8
|
+
*
|
|
9
|
+
* @param context The {@link WorkspaceContext}.
|
|
10
|
+
* @returns The name of the Spanner emulator Docker container.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getSpannerContainerName(context: WorkspaceContext): string;
|
|
13
|
+
/**
|
|
14
|
+
* The Docker image containing the emulator.
|
|
15
|
+
*/
|
|
16
|
+
export declare const SPANNER_IMAGE = "gcr.io/cloud-spanner-emulator/emulator";
|
|
17
|
+
/**
|
|
18
|
+
* The port on which the Spanner emulator exposes its gRPC API.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SPANNER_GRPC_PORT = 9010;
|
|
21
|
+
/**
|
|
22
|
+
* The port on which the Spanner emulator exposes its HTTP API.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SPANNER_HTTP_PORT = 9020;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The name of the Spanner emulator.
|
|
3
|
+
*/
|
|
4
|
+
export const SPANNER_EMULATOR_NAME = 'google.spanner';
|
|
5
|
+
/**
|
|
6
|
+
* Gets the name of the Spanner emulator Docker container from the configuration.
|
|
7
|
+
*
|
|
8
|
+
* @param context The {@link WorkspaceContext}.
|
|
9
|
+
* @returns The name of the Spanner emulator Docker container.
|
|
10
|
+
*/
|
|
11
|
+
export function getSpannerContainerName(context) {
|
|
12
|
+
const googleConf = context.asConfiguration();
|
|
13
|
+
const containerName = googleConf.get('google.spanner.emulator.containerName');
|
|
14
|
+
if (containerName) {
|
|
15
|
+
return containerName;
|
|
16
|
+
}
|
|
17
|
+
const workspaceName = googleConf.getOrThrow('workspace.name');
|
|
18
|
+
return `${workspaceName}-spanner`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The Docker image containing the emulator.
|
|
22
|
+
*/
|
|
23
|
+
export const SPANNER_IMAGE = `gcr.io/cloud-spanner-emulator/emulator`;
|
|
24
|
+
/**
|
|
25
|
+
* The port on which the Spanner emulator exposes its gRPC API.
|
|
26
|
+
*/
|
|
27
|
+
export const SPANNER_GRPC_PORT = 9010;
|
|
28
|
+
/**
|
|
29
|
+
* The port on which the Spanner emulator exposes its HTTP API.
|
|
30
|
+
*/
|
|
31
|
+
export const SPANNER_HTTP_PORT = 9020;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
import { EmulatorStart, EmulatorStartResult } from '@causa/workspace-core';
|
|
3
|
+
/**
|
|
4
|
+
* Implements {@link EmulatorStart} for the Firebase Storage container.
|
|
5
|
+
* This first merges the Firebase Storage security rules into a single file, and uses this file to configure the
|
|
6
|
+
* emulator.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EmulatorStartForFirebaseStorage extends EmulatorStart {
|
|
9
|
+
_call(context: WorkspaceContext): Promise<EmulatorStartResult>;
|
|
10
|
+
_supports(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Merges the Firebase Storage security rules into a single file, and starts the Firebase Storage emulator using them.
|
|
13
|
+
*
|
|
14
|
+
* @param context The {@link WorkspaceContext}.
|
|
15
|
+
*/
|
|
16
|
+
private startFirebaseStorage;
|
|
17
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { EmulatorStart } from '@causa/workspace-core';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { FIREBASE_CONTAINER_STORAGE_RULES_FILE, FIREBASE_STORAGE_EMULATOR_NAME, FIREBASE_STORAGE_PORT, getFirebaseStorageContainerName, } from '../emulators/index.js';
|
|
4
|
+
import { FirebaseEmulatorService } from '../services/index.js';
|
|
5
|
+
import { GoogleFirebaseStorageMergeRules } from './google-firebase-storage-merge-rules.js';
|
|
6
|
+
/**
|
|
7
|
+
* The Firebase configuration file enabling only the Storage emulator.
|
|
8
|
+
*/
|
|
9
|
+
const FIREBASE_CONF_FILE = fileURLToPath(new URL('../assets/firebase-storage.json', import.meta.url));
|
|
10
|
+
/**
|
|
11
|
+
* Implements {@link EmulatorStart} for the Firebase Storage container.
|
|
12
|
+
* This first merges the Firebase Storage security rules into a single file, and uses this file to configure the
|
|
13
|
+
* emulator.
|
|
14
|
+
*/
|
|
15
|
+
export class EmulatorStartForFirebaseStorage extends EmulatorStart {
|
|
16
|
+
async _call(context) {
|
|
17
|
+
const configuration = await this.startFirebaseStorage(context);
|
|
18
|
+
return { name: FIREBASE_STORAGE_EMULATOR_NAME, configuration };
|
|
19
|
+
}
|
|
20
|
+
_supports() {
|
|
21
|
+
return (this.name === undefined || this.name === FIREBASE_STORAGE_EMULATOR_NAME);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Merges the Firebase Storage security rules into a single file, and starts the Firebase Storage emulator using them.
|
|
25
|
+
*
|
|
26
|
+
* @param context The {@link WorkspaceContext}.
|
|
27
|
+
*/
|
|
28
|
+
async startFirebaseStorage(context) {
|
|
29
|
+
if (this.dryRun) {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
const { securityRuleFile } = await context.call(GoogleFirebaseStorageMergeRules, {});
|
|
33
|
+
context.logger.info('️🍱 Starting Firebase Storage emulator.');
|
|
34
|
+
const containerName = getFirebaseStorageContainerName(context);
|
|
35
|
+
const firebaseEmulatorService = context.service(FirebaseEmulatorService);
|
|
36
|
+
await firebaseEmulatorService.start(containerName, FIREBASE_CONF_FILE, [
|
|
37
|
+
{
|
|
38
|
+
host: '127.0.0.1',
|
|
39
|
+
container: FIREBASE_STORAGE_PORT,
|
|
40
|
+
local: FIREBASE_STORAGE_PORT,
|
|
41
|
+
},
|
|
42
|
+
], {
|
|
43
|
+
mounts: [
|
|
44
|
+
{
|
|
45
|
+
type: 'bind',
|
|
46
|
+
source: securityRuleFile ?? '',
|
|
47
|
+
destination: FIREBASE_CONTAINER_STORAGE_RULES_FILE,
|
|
48
|
+
readonly: true,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
// The Firebase Storage emulator returns "not implemented" when a request to the root is made.
|
|
52
|
+
expectedStatus: 501,
|
|
53
|
+
});
|
|
54
|
+
context.logger.info('️🍱 Successfully initialized Firebase Storage emulator.');
|
|
55
|
+
return {
|
|
56
|
+
FIREBASE_STORAGE_EMULATOR_HOST: `127.0.0.1:${FIREBASE_STORAGE_PORT}`,
|
|
57
|
+
GOOGLE_CLOUD_PROJECT: firebaseEmulatorService.localGcpProject,
|
|
58
|
+
GCP_PROJECT: firebaseEmulatorService.localGcpProject,
|
|
59
|
+
GCLOUD_PROJECT: firebaseEmulatorService.localGcpProject,
|
|
60
|
+
FIREBASE_STORAGE_BUCKET_NAME: `${firebaseEmulatorService.localGcpProject}.appspot.com`,
|
|
61
|
+
FIREBASE_CONFIG: '{}',
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
import { EmulatorStart, EmulatorStartResult } from '@causa/workspace-core';
|
|
3
|
+
/**
|
|
4
|
+
* Implements {@link EmulatorStart} for the Firestore emulator.
|
|
5
|
+
* This first merges the Firestore security rules into a single file, and uses this file to configure the emulator.
|
|
6
|
+
*/
|
|
7
|
+
export declare class EmulatorStartForFirestore extends EmulatorStart {
|
|
8
|
+
_call(context: WorkspaceContext): Promise<EmulatorStartResult>;
|
|
9
|
+
_supports(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Merges the Firestore security rules into a single file, and starts the Firestore emulator using them.
|
|
12
|
+
*
|
|
13
|
+
* @param context The {@link WorkspaceContext}.
|
|
14
|
+
* @returns The configuration for the Firestore emulator.
|
|
15
|
+
*/
|
|
16
|
+
private startFirestore;
|
|
17
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { EmulatorStart } from '@causa/workspace-core';
|
|
2
|
+
import { FIRESTORE_CONTAINER_RULES_FILE, FIRESTORE_EMULATOR_NAME, FIRESTORE_PORT, getFirestoreContainerName, } from '../emulators/index.js';
|
|
3
|
+
import { GcloudEmulatorService } from '../index.js';
|
|
4
|
+
import { GoogleFirestoreMergeRules } from './google-firestore-merge-rules.js';
|
|
5
|
+
/**
|
|
6
|
+
* Implements {@link EmulatorStart} for the Firestore emulator.
|
|
7
|
+
* This first merges the Firestore security rules into a single file, and uses this file to configure the emulator.
|
|
8
|
+
*/
|
|
9
|
+
export class EmulatorStartForFirestore extends EmulatorStart {
|
|
10
|
+
async _call(context) {
|
|
11
|
+
const configuration = await this.startFirestore(context);
|
|
12
|
+
return { name: FIRESTORE_EMULATOR_NAME, configuration };
|
|
13
|
+
}
|
|
14
|
+
_supports() {
|
|
15
|
+
return this.name === undefined || this.name === FIRESTORE_EMULATOR_NAME;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Merges the Firestore security rules into a single file, and starts the Firestore emulator using them.
|
|
19
|
+
*
|
|
20
|
+
* @param context The {@link WorkspaceContext}.
|
|
21
|
+
* @returns The configuration for the Firestore emulator.
|
|
22
|
+
*/
|
|
23
|
+
async startFirestore(context) {
|
|
24
|
+
if (this.dryRun) {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
const { securityRuleFile } = await context.call(GoogleFirestoreMergeRules, {});
|
|
28
|
+
context.logger.info('🗃️ Starting Firestore emulator.');
|
|
29
|
+
const containerName = getFirestoreContainerName(context);
|
|
30
|
+
const gcloudEmulatorService = context.service(GcloudEmulatorService);
|
|
31
|
+
await gcloudEmulatorService.start('firestore', containerName, [
|
|
32
|
+
{
|
|
33
|
+
host: '127.0.0.1',
|
|
34
|
+
local: FIRESTORE_PORT,
|
|
35
|
+
container: FIRESTORE_PORT,
|
|
36
|
+
},
|
|
37
|
+
], {
|
|
38
|
+
mounts: [
|
|
39
|
+
{
|
|
40
|
+
type: 'bind',
|
|
41
|
+
source: securityRuleFile ?? '',
|
|
42
|
+
destination: FIRESTORE_CONTAINER_RULES_FILE,
|
|
43
|
+
readonly: true,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
additionalArguments: ['--rules', FIRESTORE_CONTAINER_RULES_FILE],
|
|
47
|
+
availabilityEndpoint: `http://127.0.0.1:${FIRESTORE_PORT}/`,
|
|
48
|
+
});
|
|
49
|
+
context.logger.info('🗃️ Successfully initialized Firestore emulator.');
|
|
50
|
+
return {
|
|
51
|
+
FIRESTORE_EMULATOR_HOST: `127.0.0.1:${FIRESTORE_PORT}`,
|
|
52
|
+
GOOGLE_CLOUD_PROJECT: gcloudEmulatorService.localGcpProject,
|
|
53
|
+
GCP_PROJECT: gcloudEmulatorService.localGcpProject,
|
|
54
|
+
GCLOUD_PROJECT: gcloudEmulatorService.localGcpProject,
|
|
55
|
+
FIREBASE_CONFIG: '{}',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WorkspaceContext } from '@causa/workspace';
|
|
2
|
+
import { EmulatorStart, EmulatorStartResult } from '@causa/workspace-core';
|
|
3
|
+
/**
|
|
4
|
+
* Implements {@link EmulatorStart} for the Identity Platform emulator.
|
|
5
|
+
* This actually runs the "legacy" Firebase Auth emulator, which is the same service before it was re-branded.
|
|
6
|
+
*/
|
|
7
|
+
export declare class EmulatorStartForIdentityPlatform extends EmulatorStart {
|
|
8
|
+
_call(context: WorkspaceContext): Promise<EmulatorStartResult>;
|
|
9
|
+
_supports(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Starts the Identity Platform (Firebase Auth) emulator.
|
|
12
|
+
*
|
|
13
|
+
* @param context The {@link WorkspaceContext}.
|
|
14
|
+
*/
|
|
15
|
+
private startIdentityPlatform;
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { EmulatorStart } from '@causa/workspace-core';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { FIREBASE_AUTH_PORT, IDENTITY_PLATFORM_EMULATOR_NAME, getIdentityPlatformContainerName, } from '../emulators/index.js';
|
|
4
|
+
import { FirebaseEmulatorService } from '../services/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* The Firebase configuration file enabling only the Auth emulator.
|
|
7
|
+
*/
|
|
8
|
+
const FIREBASE_CONF_FILE = fileURLToPath(new URL('../assets/firebase-auth.json', import.meta.url));
|
|
9
|
+
/**
|
|
10
|
+
* Implements {@link EmulatorStart} for the Identity Platform emulator.
|
|
11
|
+
* This actually runs the "legacy" Firebase Auth emulator, which is the same service before it was re-branded.
|
|
12
|
+
*/
|
|
13
|
+
export class EmulatorStartForIdentityPlatform extends EmulatorStart {
|
|
14
|
+
async _call(context) {
|
|
15
|
+
const configuration = await this.startIdentityPlatform(context);
|
|
16
|
+
return { name: IDENTITY_PLATFORM_EMULATOR_NAME, configuration };
|
|
17
|
+
}
|
|
18
|
+
_supports() {
|
|
19
|
+
return (this.name === undefined || this.name === IDENTITY_PLATFORM_EMULATOR_NAME);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Starts the Identity Platform (Firebase Auth) emulator.
|
|
23
|
+
*
|
|
24
|
+
* @param context The {@link WorkspaceContext}.
|
|
25
|
+
*/
|
|
26
|
+
async startIdentityPlatform(context) {
|
|
27
|
+
if (this.dryRun) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
context.logger.info('🛂 Starting the Identity Platform emulator.');
|
|
31
|
+
const containerName = getIdentityPlatformContainerName(context);
|
|
32
|
+
const firebaseEmulatorService = context.service(FirebaseEmulatorService);
|
|
33
|
+
await firebaseEmulatorService.start(containerName, FIREBASE_CONF_FILE, [
|
|
34
|
+
{
|
|
35
|
+
host: '127.0.0.1',
|
|
36
|
+
local: FIREBASE_AUTH_PORT,
|
|
37
|
+
container: FIREBASE_AUTH_PORT,
|
|
38
|
+
},
|
|
39
|
+
]);
|
|
40
|
+
context.logger.info('🛂 Successfully initialized the Identity Platform emulator.');
|
|
41
|
+
return {
|
|
42
|
+
FIREBASE_AUTH_EMULATOR_HOST: `127.0.0.1:${FIREBASE_AUTH_PORT}`,
|
|
43
|
+
GOOGLE_CLOUD_PROJECT: firebaseEmulatorService.localGcpProject,
|
|
44
|
+
GCP_PROJECT: firebaseEmulatorService.localGcpProject,
|
|
45
|
+
GCLOUD_PROJECT: firebaseEmulatorService.localGcpProject,
|
|
46
|
+
FIREBASE_CONFIG: '{}',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|