-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.yaml
105 lines (95 loc) · 4.26 KB
/
extension.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Learn detailed information about the fields of an extension.yaml file in the docs:
# https://firebase.google.com/docs/extensions/reference/extension-yaml
name: historian
version: 0.2.0 # Follow semver versioning
specVersion: v1beta # Version of the Firebase Extensions specification
# Friendly display name for your extension (~3-5 words)
displayName: Historian
# Brief description of the task your extension performs (~1 sentence)
description: >-
Store your Firestore document history in a subcollection.
license: Apache-2.0 # https://spdx.org/licenses/
icon: historian.png
tags: [utilities]
# Public URL for the source code of your extension.
sourceUrl: https://github.com/nushio/historian
# Specify whether a paid-tier billing plan is required to use your extension.
# Learn more in the docs: https://firebase.google.com/docs/extensions/reference/extension-yaml#billing-required-field
billingRequired: true
# In an `apis` field, list any Google APIs (like Cloud Translation, BigQuery, etc.)
# required for your extension to operate.
# Learn more in the docs:
# https://firebase.google.com/docs/extensions/reference/extension-yaml#apis-field
# In a `roles` field, list any IAM access roles required for your extension to operate.
# Learn more in the docs:
# https://firebase.google.com/docs/extensions/reference/extension-yaml#roles-field
roles:
- role: datastore.user
reason: Allows the extension to write to Firestore.
# In the `resources` field, list each of your extension's functions, including the trigger for each function.
# Learn more in the docs:
# https://firebase.google.com/docs/extensions/reference/extension-yaml#resources-field
resources:
- name: processEvent
type: firebaseextensions.v1beta.function
properties:
eventTrigger:
eventType: providers/cloud.firestore/eventTypes/document.write
resource: projects/${PROJECT_ID}/databases/(default)/documents/${param:YOUR_COLLECTION}/{id}
runtime: "nodejs18"
# In the `params` field, set up your extension's user-configured parameters.
# Learn more in the docs:
# https://firebase.google.com/docs/extensions/reference/extension-yaml#params-field
params:
- param: YOUR_COLLECTION
label: Monitored Collection Name
description: Where do you want to watch for changes?
type: string
default: path/to/{collectionId} # Specifying a default is optional.
required: true
- param: CHANGED_SUBCOLLECTION_NAME
label: SubCollection Name where changes will be stored
description: >-
Where the difference will be stored, in a subcollection.
type: string
default: historian
required: true
immutable: false
- param: DELETE_AFTER
label: Delete After, (Days), For Time-to-Live
description: >-
Adds deleteAfter to the document. Use with Firebase TTL so changes are deleted after a certain amount of time.
Set to 0 to disable.
type: string
validationRegex: ^\d+$
default: 30
required: true
immutable: false
- param: EXCLUDED_DOCUMENT_KEYS
label: Excluded fields, comma separated
description: >-
Document Fields that will be excluded. If these fields change, historian won't make a changelog document.
This is useful for documents where fields change often, but the data is otherwise unnecessary, like a "lastUpdated" field.
No spaces, just comma separated. E.g. "lastUpdated,lastModified,lastChanged"
type: string
default:
required: true
immutable: false
- param: HISTORIAN_UNDO_FIELD
label: Undo field name, to revert document changes
description: >-
This field allows you to specify a version on your document's historian sub-collection and automatically revert the change, by grabbing the "before" version.
This must be the only field in the document's update, in order to revert the change.
type: string
default: historianUndo
required: true
immutable: false
- param: HISTORIAN_REDO_FIELD
label: Re-do field name
description: >-
This field allows you to specify a version on your document's historian sub-collection and automatically re-apply the change, by grabbing the "after" version.
This must be the only field in the document's update, in order to re-apply the change.
type: string
default: historianRedo
required: true
immutable: false