@digital-agora/friday-google-cloud 0.1.2 → 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/conventions/firebase/firebase-emulators.yaml +17 -0
- package/conventions/firebase/firebase-functions.yaml +23 -0
- package/conventions/{firestore-data.yaml → firebase/firestore-data.yaml} +1 -0
- package/conventions/firebase/firestore-pii.yaml +21 -0
- package/conventions/{firestore-rules.yaml → firebase/firestore-rules.yaml} +1 -0
- package/conventions/firebase/group.yaml +3 -0
- package/conventions/google-cloud/group.yaml +3 -0
- package/conventions/google-cloud/regions.yaml +22 -0
- package/package.json +3 -2
- /package/conventions/{cloud-run.yaml → google-cloud/cloud-run.yaml} +0 -0
- /package/conventions/{gcp-iam.yaml → google-cloud/gcp-iam.yaml} +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
id: firebase-emulators
|
|
2
|
+
stack: firebase
|
|
3
|
+
refines: [testing]
|
|
4
|
+
description: Testing against the Firebase Local Emulator Suite, at the integration level only.
|
|
5
|
+
appliesTo:
|
|
6
|
+
paths: ["firebase.json", "**/*.rules", "**/*.test.*", "**/test_*.py"]
|
|
7
|
+
emit: [rule]
|
|
8
|
+
rules:
|
|
9
|
+
- id: demo-project
|
|
10
|
+
rule: "Emulator tests use a `demo-` project id, so no call can reach a real project."
|
|
11
|
+
source: https://firebase.google.com/docs/emulator-suite/connect_and_prototype#choose_a_firebase_project
|
|
12
|
+
- id: integration-only
|
|
13
|
+
rule: "Emulator suites run at the integration level (`firebase emulators:exec`), never in a task loop."
|
|
14
|
+
source: https://firebase.google.com/docs/emulator-suite/install_and_configure
|
|
15
|
+
- id: own-data
|
|
16
|
+
rule: "Each suite seeds its own data and clears it after (`clearFirestore`), and loads the same rules file that is deployed."
|
|
17
|
+
source: https://firebase.google.com/docs/rules/unit-tests
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
id: firebase-functions
|
|
2
|
+
stack: firebase-functions
|
|
3
|
+
refines: [entry-points]
|
|
4
|
+
description: Cloud Functions for Firebase (2nd gen) as entry points onto the core.
|
|
5
|
+
appliesTo:
|
|
6
|
+
paths: ["functions/**", "firebase.json"]
|
|
7
|
+
emit: [rule, skill]
|
|
8
|
+
rules:
|
|
9
|
+
- id: v2-region
|
|
10
|
+
rule: "Functions use the 2nd-generation APIs (`firebase-functions/v2/*`), with the region set per function or once with `setGlobalOptions`, next to the data they read."
|
|
11
|
+
source: https://firebase.google.com/docs/functions/locations
|
|
12
|
+
- id: entry-point
|
|
13
|
+
rule: "A function is an entry point: it parses its input, builds the Caller from `request.auth`, calls a use case and maps the Result; it holds no logic."
|
|
14
|
+
source: https://alistair.cockburn.us/hexagonal-architecture/
|
|
15
|
+
- id: callable-errors
|
|
16
|
+
rule: "A callable maps each domain error to an `HttpsError` code (`invalid-argument`, `permission-denied`, `not-found`, ...) with a message that carries no internal detail."
|
|
17
|
+
source: https://firebase.google.com/docs/functions/callable#handle_errors
|
|
18
|
+
- id: secrets
|
|
19
|
+
rule: "Secrets are `defineSecret` parameters bound to the functions that use them (`secrets: [...]`), never environment literals or committed config."
|
|
20
|
+
source: https://firebase.google.com/docs/functions/config-env#secret-manager
|
|
21
|
+
- id: retries
|
|
22
|
+
rule: "An event-triggered function is idempotent by its event id, and retries are turned on explicitly (`retry: true`) for the handlers that are."
|
|
23
|
+
source: https://firebase.google.com/docs/functions/retries
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
id: firestore-pii
|
|
2
|
+
stack: firestore
|
|
3
|
+
topics: [pii]
|
|
4
|
+
refines: [special-category-data, pii-exposure]
|
|
5
|
+
description: Personal data in Firestore, separated by reader into private subdocuments the rules let only their owner read.
|
|
6
|
+
appliesTo:
|
|
7
|
+
paths: ["**/*.rules", "firebase.json", "**/firestore.indexes.json"]
|
|
8
|
+
emit: [rule, skill]
|
|
9
|
+
rules:
|
|
10
|
+
- id: split-by-reader
|
|
11
|
+
rule: "One document per set of readers: a document keeps only the fields every one of its readers may see; a field only some readers may see moves to a subdocument with a fixed id per reader set (`private/owner`, `private/staff`) under the same parent."
|
|
12
|
+
source: https://firebase.google.com/docs/firestore/security/rules-fields
|
|
13
|
+
- id: owner-rule
|
|
14
|
+
rule: "A subdocument with special category or other owner-only data has `allow read: if request.auth != null && request.auth.uid == <the owner id in the path>` and `allow write: if false`: never a custom claim, never `get()` or `exists()` on another document, never a collection-group match."
|
|
15
|
+
source: https://firebase.google.com/docs/rules/rules-and-auth
|
|
16
|
+
- id: static-check
|
|
17
|
+
rule: "A static test over the rules file fails when an owner-only path's rule uses `request.auth.token`, `get(`, `exists(` or a recursive wildcard, and an emulator test proves that the owner reads it and every other caller kind is refused."
|
|
18
|
+
source: https://firebase.google.com/docs/rules/unit-tests
|
|
19
|
+
- id: erase-subdocuments
|
|
20
|
+
rule: "Erasure deletes each fixed-id private subdocument by its path: deleting a parent document does not delete its subcollections."
|
|
21
|
+
source: https://firebase.google.com/docs/firestore/manage-data/delete-data#collections
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
id: regions
|
|
2
|
+
stack: gcp
|
|
3
|
+
description: Where each runtime and store runs, chosen once inside the project's data residency scope and kept the same in every file.
|
|
4
|
+
appliesTo:
|
|
5
|
+
paths: ["firebase.json", "cloudbuild/**", "infra/**", "apphosting*.yaml", "services/**/Dockerfile", "**/*.tf"]
|
|
6
|
+
emit: [rule, skill]
|
|
7
|
+
rules:
|
|
8
|
+
- id: residency-scope
|
|
9
|
+
rule: "Each project records, as a decision, its residency scope (the jurisdiction its data must stay in, such as the EU) and its base region inside that scope; every region it uses is inside the scope."
|
|
10
|
+
source: https://cloud.google.com/docs/geography-and-regions
|
|
11
|
+
- id: one-base-region
|
|
12
|
+
rule: "Cloud Run, Functions, Cloud Build, Artifact Registry, Cloud Tasks and Scheduler run in the base region; a product the base region does not offer runs in the nearest region inside the scope that does, named in the decision."
|
|
13
|
+
source: https://cloud.google.com/about/locations
|
|
14
|
+
- id: data-location
|
|
15
|
+
rule: "Each store (Firestore, Cloud Storage, Cloud SQL) sits in the base region or a multi-region inside the scope; a store's location is chosen once, as a decision, before it is created."
|
|
16
|
+
source: https://firebase.google.com/docs/firestore/locations
|
|
17
|
+
- id: next-to-data
|
|
18
|
+
rule: "Compute runs in the region of the data it reads, so a request does not cross regions for each read."
|
|
19
|
+
source: https://firebase.google.com/docs/functions/locations
|
|
20
|
+
- id: one-setting
|
|
21
|
+
rule: "The region is one setting per project (a Terraform variable, `setGlobalOptions`, `firebase.json`), read wherever it is needed, never repeated as a literal across files."
|
|
22
|
+
source: https://firebase.google.com/docs/functions/locations#best_practices_for_changing_region
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digital-agora/friday-google-cloud",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Google Cloud's specialization of Friday: Firestore, Cloud Run, Cloud Functions, Secret Manager and IAM conventions on top of Friday's generic pack, each citing Google's documentation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"specialization.yaml",
|
|
12
|
+
"decisions.yaml",
|
|
12
13
|
"conventions",
|
|
13
14
|
"personas",
|
|
14
15
|
"bin",
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
"node": ">=20"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@digital-agora/friday": "^0.
|
|
23
|
+
"@digital-agora/friday": "^0.14.0"
|
|
23
24
|
},
|
|
24
25
|
"repository": {
|
|
25
26
|
"type": "git",
|
|
File without changes
|
|
File without changes
|