firebase-functions 6.6.0 → 7.0.0-rc.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/lib/_virtual/rolldown_runtime.js +34 -0
- package/lib/bin/firebase-functions.js +78 -103
- package/lib/common/app.js +35 -55
- package/lib/common/change.js +54 -75
- package/lib/common/config.js +41 -41
- package/lib/common/debug.js +23 -47
- package/lib/common/encoding.js +59 -82
- package/lib/common/onInit.js +26 -28
- package/lib/common/options.js +22 -42
- package/lib/common/params.d.ts +6 -6
- package/lib/common/params.js +0 -23
- package/lib/common/providers/database.js +270 -300
- package/lib/common/providers/firestore.js +66 -92
- package/lib/common/providers/https.d.ts +0 -1
- package/lib/common/providers/https.js +537 -539
- package/lib/common/providers/identity.js +393 -444
- package/lib/common/providers/tasks.js +64 -98
- package/lib/common/timezone.js +544 -542
- package/lib/common/trace.d.ts +0 -1
- package/lib/common/trace.js +63 -55
- package/lib/common/utilities/assertions.d.ts +11 -0
- package/lib/common/utilities/assertions.js +18 -0
- package/lib/common/utilities/encoder.js +20 -37
- package/lib/common/utilities/path-pattern.js +106 -132
- package/lib/common/utilities/path.js +28 -27
- package/lib/common/utilities/utils.js +23 -45
- package/lib/esm/_virtual/rolldown_runtime.mjs +16 -0
- package/lib/esm/bin/firebase-functions.mjs +91 -0
- package/lib/esm/common/app.mjs +39 -0
- package/lib/esm/common/change.mjs +57 -0
- package/lib/esm/common/config.mjs +45 -0
- package/lib/esm/common/debug.mjs +28 -0
- package/lib/esm/common/encoding.mjs +69 -0
- package/lib/esm/common/onInit.mjs +33 -0
- package/lib/esm/common/options.mjs +22 -0
- package/lib/esm/common/params.mjs +1 -0
- package/lib/esm/common/providers/database.mjs +269 -0
- package/lib/esm/common/providers/firestore.mjs +78 -0
- package/lib/esm/common/providers/https.mjs +573 -0
- package/lib/esm/common/providers/identity.mjs +428 -0
- package/lib/esm/common/providers/tasks.mjs +67 -0
- package/lib/esm/common/timezone.mjs +544 -0
- package/lib/esm/common/trace.mjs +73 -0
- package/lib/esm/common/utilities/assertions.mjs +17 -0
- package/lib/esm/common/utilities/encoder.mjs +21 -0
- package/lib/esm/common/utilities/path-pattern.mjs +116 -0
- package/lib/esm/common/utilities/path.mjs +35 -0
- package/lib/esm/common/utilities/utils.mjs +29 -0
- package/lib/esm/function-configuration.mjs +1 -0
- package/lib/esm/logger/common.mjs +23 -0
- package/lib/esm/logger/compat.mjs +25 -0
- package/lib/esm/logger/index.mjs +131 -0
- package/lib/esm/params/index.mjs +160 -0
- package/lib/esm/params/types.mjs +400 -0
- package/lib/esm/runtime/loader.mjs +132 -0
- package/lib/esm/runtime/manifest.mjs +134 -0
- package/lib/esm/types/global.d.mjs +1 -0
- package/lib/esm/v1/cloud-functions.mjs +206 -0
- package/lib/esm/v1/config.mjs +14 -0
- package/lib/esm/v1/function-builder.mjs +252 -0
- package/lib/esm/v1/function-configuration.mjs +72 -0
- package/lib/esm/v1/index.mjs +27 -0
- package/lib/esm/v1/providers/analytics.mjs +212 -0
- package/lib/esm/v1/providers/auth.mjs +156 -0
- package/lib/esm/v1/providers/database.mjs +243 -0
- package/lib/esm/v1/providers/firestore.mjs +131 -0
- package/lib/esm/v1/providers/https.mjs +82 -0
- package/lib/esm/v1/providers/pubsub.mjs +175 -0
- package/lib/esm/v1/providers/remoteConfig.mjs +64 -0
- package/lib/esm/v1/providers/storage.mjs +163 -0
- package/lib/esm/v1/providers/tasks.mjs +63 -0
- package/lib/esm/v1/providers/testLab.mjs +94 -0
- package/lib/esm/v2/core.mjs +4 -0
- package/lib/esm/v2/index.mjs +28 -0
- package/lib/esm/v2/options.mjs +102 -0
- package/lib/esm/v2/providers/alerts/alerts.mjs +85 -0
- package/lib/esm/v2/providers/alerts/appDistribution.mjs +75 -0
- package/lib/esm/v2/providers/alerts/billing.mjs +51 -0
- package/lib/esm/v2/providers/alerts/crashlytics.mjs +122 -0
- package/lib/esm/v2/providers/alerts/index.mjs +22 -0
- package/lib/esm/v2/providers/alerts/performance.mjs +66 -0
- package/lib/esm/v2/providers/database.mjs +197 -0
- package/lib/esm/v2/providers/dataconnect.mjs +130 -0
- package/lib/esm/v2/providers/eventarc.mjs +51 -0
- package/lib/esm/v2/providers/firestore.mjs +294 -0
- package/lib/esm/v2/providers/https.mjs +210 -0
- package/lib/esm/v2/providers/identity.mjs +103 -0
- package/lib/esm/v2/providers/pubsub.mjs +148 -0
- package/lib/esm/v2/providers/remoteConfig.mjs +52 -0
- package/lib/esm/v2/providers/scheduler.mjs +84 -0
- package/lib/esm/v2/providers/storage.mjs +155 -0
- package/lib/esm/v2/providers/tasks.mjs +65 -0
- package/lib/esm/v2/providers/testLab.mjs +53 -0
- package/lib/esm/v2/trace.mjs +20 -0
- package/lib/function-configuration.d.ts +0 -0
- package/lib/function-configuration.js +0 -0
- package/lib/logger/common.js +21 -41
- package/lib/logger/compat.js +18 -33
- package/lib/logger/index.js +119 -130
- package/lib/params/index.d.ts +4 -2
- package/lib/params/index.js +150 -144
- package/lib/params/types.js +389 -423
- package/lib/runtime/loader.js +114 -148
- package/lib/runtime/manifest.js +106 -126
- package/lib/types/global.d.js +0 -0
- package/lib/v1/cloud-functions.d.ts +2 -2
- package/lib/v1/cloud-functions.js +193 -241
- package/lib/v1/config.d.ts +4 -7
- package/lib/v1/config.js +13 -75
- package/lib/v1/function-builder.js +239 -368
- package/lib/v1/function-configuration.js +70 -63
- package/lib/v1/index.js +118 -73
- package/lib/v1/providers/analytics.js +188 -235
- package/lib/v1/providers/auth.d.ts +2 -1
- package/lib/v1/providers/auth.js +159 -164
- package/lib/v1/providers/database.js +237 -242
- package/lib/v1/providers/firestore.js +131 -130
- package/lib/v1/providers/https.d.ts +2 -1
- package/lib/v1/providers/https.js +79 -86
- package/lib/v1/providers/pubsub.js +175 -172
- package/lib/v1/providers/remoteConfig.js +64 -68
- package/lib/v1/providers/storage.js +161 -163
- package/lib/v1/providers/tasks.d.ts +1 -1
- package/lib/v1/providers/tasks.js +65 -80
- package/lib/v1/providers/testLab.js +94 -94
- package/lib/v2/core.d.ts +1 -1
- package/lib/v2/core.js +5 -32
- package/lib/v2/index.d.ts +6 -3
- package/lib/v2/index.js +123 -75
- package/lib/v2/options.js +88 -114
- package/lib/v2/providers/alerts/alerts.js +76 -95
- package/lib/v2/providers/alerts/appDistribution.js +73 -78
- package/lib/v2/providers/alerts/billing.js +49 -53
- package/lib/v2/providers/alerts/crashlytics.js +110 -102
- package/lib/v2/providers/alerts/index.js +56 -53
- package/lib/v2/providers/alerts/performance.js +64 -74
- package/lib/v2/providers/database.js +177 -180
- package/lib/v2/providers/dataconnect.d.ts +95 -0
- package/lib/v2/providers/dataconnect.js +137 -0
- package/lib/v2/providers/eventarc.js +55 -77
- package/lib/v2/providers/firestore.js +262 -260
- package/lib/v2/providers/https.d.ts +3 -2
- package/lib/v2/providers/https.js +210 -247
- package/lib/v2/providers/identity.d.ts +2 -1
- package/lib/v2/providers/identity.js +96 -105
- package/lib/v2/providers/pubsub.js +149 -167
- package/lib/v2/providers/remoteConfig.js +54 -63
- package/lib/v2/providers/scheduler.js +84 -96
- package/lib/v2/providers/storage.js +147 -162
- package/lib/v2/providers/tasks.d.ts +1 -1
- package/lib/v2/providers/tasks.js +68 -95
- package/lib/v2/providers/testLab.js +55 -64
- package/lib/v2/trace.js +18 -19
- package/package.json +290 -226
- package/protos/compiledFirestore.mjs +3512 -0
- package/protos/update.sh +28 -7
|
@@ -1,219 +1,216 @@
|
|
|
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
|
-
const path_pattern_1 = require("../../common/utilities/path-pattern");
|
|
30
|
-
const utils_1 = require("../../common/utilities/utils");
|
|
31
|
-
const manifest_1 = require("../../runtime/manifest");
|
|
32
|
-
const trace_1 = require("../trace");
|
|
33
|
-
const options = require("../options");
|
|
34
|
-
const onInit_1 = require("../../common/onInit");
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_runtime_manifest = require('../../runtime/manifest.js');
|
|
3
|
+
const require_common_app = require('../../common/app.js');
|
|
4
|
+
const require_common_onInit = require('../../common/onInit.js');
|
|
5
|
+
const require_common_utilities_path = require('../../common/utilities/path.js');
|
|
6
|
+
const require_common_providers_database = require('../../common/providers/database.js');
|
|
7
|
+
const require_common_utilities_utils = require('../../common/utilities/utils.js');
|
|
8
|
+
const require_v2_trace = require('../trace.js');
|
|
9
|
+
const require_v2_options = require('../options.js');
|
|
10
|
+
const require_common_utilities_path_pattern = require('../../common/utilities/path-pattern.js');
|
|
11
|
+
|
|
12
|
+
//#region src/v2/providers/database.ts
|
|
13
|
+
var database_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
|
|
14
|
+
DataSnapshot: () => require_common_providers_database.DataSnapshot,
|
|
15
|
+
createdEventType: () => createdEventType,
|
|
16
|
+
deletedEventType: () => deletedEventType,
|
|
17
|
+
getOpts: () => getOpts,
|
|
18
|
+
makeEndpoint: () => makeEndpoint,
|
|
19
|
+
makeParams: () => makeParams,
|
|
20
|
+
onChangedOperation: () => onChangedOperation,
|
|
21
|
+
onOperation: () => onOperation,
|
|
22
|
+
onValueCreated: () => onValueCreated,
|
|
23
|
+
onValueDeleted: () => onValueDeleted,
|
|
24
|
+
onValueUpdated: () => onValueUpdated,
|
|
25
|
+
onValueWritten: () => onValueWritten,
|
|
26
|
+
updatedEventType: () => updatedEventType,
|
|
27
|
+
writtenEventType: () => writtenEventType
|
|
28
|
+
});
|
|
35
29
|
/** @internal */
|
|
36
|
-
|
|
30
|
+
const writtenEventType = "google.firebase.database.ref.v1.written";
|
|
37
31
|
/** @internal */
|
|
38
|
-
|
|
32
|
+
const createdEventType = "google.firebase.database.ref.v1.created";
|
|
39
33
|
/** @internal */
|
|
40
|
-
|
|
34
|
+
const updatedEventType = "google.firebase.database.ref.v1.updated";
|
|
41
35
|
/** @internal */
|
|
42
|
-
|
|
36
|
+
const deletedEventType = "google.firebase.database.ref.v1.deleted";
|
|
43
37
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
* Event handler which triggers when data is created, updated, or deleted in Realtime Database.
|
|
39
|
+
*
|
|
40
|
+
* @param referenceOrOpts - Options or a string reference.
|
|
41
|
+
* @param handler - Event handler which is run every time a Realtime Database create, update, or delete occurs.
|
|
42
|
+
*/
|
|
49
43
|
function onValueWritten(referenceOrOpts, handler) {
|
|
50
|
-
|
|
44
|
+
return onChangedOperation(writtenEventType, referenceOrOpts, handler);
|
|
51
45
|
}
|
|
52
|
-
exports.onValueWritten = onValueWritten;
|
|
53
46
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
* Event handler which triggers when data is created in Realtime Database.
|
|
48
|
+
*
|
|
49
|
+
* @param referenceOrOpts - Options or a string reference.
|
|
50
|
+
* @param handler - Event handler which is run every time a Realtime Database create occurs.
|
|
51
|
+
*/
|
|
59
52
|
function onValueCreated(referenceOrOpts, handler) {
|
|
60
|
-
|
|
53
|
+
return onOperation(createdEventType, referenceOrOpts, handler);
|
|
61
54
|
}
|
|
62
|
-
exports.onValueCreated = onValueCreated;
|
|
63
55
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
* Event handler which triggers when data is updated in Realtime Database.
|
|
57
|
+
*
|
|
58
|
+
* @param referenceOrOpts - Options or a string reference.
|
|
59
|
+
* @param handler - Event handler which is run every time a Realtime Database update occurs.
|
|
60
|
+
*/
|
|
69
61
|
function onValueUpdated(referenceOrOpts, handler) {
|
|
70
|
-
|
|
62
|
+
return onChangedOperation(updatedEventType, referenceOrOpts, handler);
|
|
71
63
|
}
|
|
72
|
-
exports.onValueUpdated = onValueUpdated;
|
|
73
64
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
* Event handler which triggers when data is deleted in Realtime Database.
|
|
66
|
+
*
|
|
67
|
+
* @param referenceOrOpts - Options or a string reference.
|
|
68
|
+
* @param handler - Event handler which is run every time a Realtime Database deletion occurs.
|
|
69
|
+
*/
|
|
79
70
|
function onValueDeleted(referenceOrOpts, handler) {
|
|
80
|
-
|
|
81
|
-
return onOperation(exports.deletedEventType, referenceOrOpts, handler);
|
|
71
|
+
return onOperation(deletedEventType, referenceOrOpts, handler);
|
|
82
72
|
}
|
|
83
|
-
exports.onValueDeleted = onValueDeleted;
|
|
84
73
|
/** @internal */
|
|
85
74
|
function getOpts(referenceOrOpts) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
75
|
+
let path;
|
|
76
|
+
let instance;
|
|
77
|
+
let opts;
|
|
78
|
+
if (typeof referenceOrOpts === "string") {
|
|
79
|
+
path = require_common_utilities_path.normalizePath(referenceOrOpts);
|
|
80
|
+
instance = "*";
|
|
81
|
+
opts = {};
|
|
82
|
+
} else {
|
|
83
|
+
path = require_common_utilities_path.normalizePath(referenceOrOpts.ref);
|
|
84
|
+
instance = referenceOrOpts.instance || "*";
|
|
85
|
+
opts = { ...referenceOrOpts };
|
|
86
|
+
delete opts.ref;
|
|
87
|
+
delete opts.instance;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
path,
|
|
91
|
+
instance,
|
|
92
|
+
opts
|
|
93
|
+
};
|
|
106
94
|
}
|
|
107
|
-
exports.getOpts = getOpts;
|
|
108
95
|
/** @internal */
|
|
109
96
|
function makeParams(event, path, instance) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
97
|
+
return {
|
|
98
|
+
...path.extractMatches(event.ref),
|
|
99
|
+
...instance.extractMatches(event.instance)
|
|
100
|
+
};
|
|
114
101
|
}
|
|
115
|
-
exports.makeParams = makeParams;
|
|
116
102
|
/** @hidden */
|
|
117
103
|
function makeDatabaseEvent(event, data, instance, params) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
104
|
+
const snapshot = new require_common_providers_database.DataSnapshot(data, event.ref, require_common_app.getApp(), instance);
|
|
105
|
+
const databaseEvent = {
|
|
106
|
+
...event,
|
|
107
|
+
firebaseDatabaseHost: event.firebasedatabasehost,
|
|
108
|
+
data: snapshot,
|
|
109
|
+
params
|
|
110
|
+
};
|
|
111
|
+
delete databaseEvent.firebasedatabasehost;
|
|
112
|
+
return databaseEvent;
|
|
127
113
|
}
|
|
128
114
|
/** @hidden */
|
|
129
115
|
function makeChangedDatabaseEvent(event, instance, params) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
116
|
+
const before = new require_common_providers_database.DataSnapshot(event.data.data, event.ref, require_common_app.getApp(), instance);
|
|
117
|
+
const after = new require_common_providers_database.DataSnapshot(require_common_utilities_utils.applyChange(event.data.data, event.data.delta), event.ref, require_common_app.getApp(), instance);
|
|
118
|
+
const databaseEvent = {
|
|
119
|
+
...event,
|
|
120
|
+
firebaseDatabaseHost: event.firebasedatabasehost,
|
|
121
|
+
data: {
|
|
122
|
+
before,
|
|
123
|
+
after
|
|
124
|
+
},
|
|
125
|
+
params
|
|
126
|
+
};
|
|
127
|
+
delete databaseEvent.firebasedatabasehost;
|
|
128
|
+
return databaseEvent;
|
|
143
129
|
}
|
|
144
130
|
/** @internal */
|
|
145
131
|
function makeEndpoint(eventType, opts, path, instance) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
},
|
|
172
|
-
};
|
|
132
|
+
const baseOpts = require_v2_options.optionsToEndpoint(require_v2_options.getGlobalOptions());
|
|
133
|
+
const specificOpts = require_v2_options.optionsToEndpoint(opts);
|
|
134
|
+
const eventFilters = {};
|
|
135
|
+
const eventFilterPathPatterns = { ref: path.getValue() };
|
|
136
|
+
if (instance.hasWildcards()) {
|
|
137
|
+
eventFilterPathPatterns.instance = instance.getValue();
|
|
138
|
+
} else {
|
|
139
|
+
eventFilters.instance = instance.getValue();
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
...require_runtime_manifest.initV2Endpoint(require_v2_options.getGlobalOptions(), opts),
|
|
143
|
+
platform: "gcfv2",
|
|
144
|
+
...baseOpts,
|
|
145
|
+
...specificOpts,
|
|
146
|
+
labels: {
|
|
147
|
+
...baseOpts?.labels,
|
|
148
|
+
...specificOpts?.labels
|
|
149
|
+
},
|
|
150
|
+
eventTrigger: {
|
|
151
|
+
eventType,
|
|
152
|
+
eventFilters,
|
|
153
|
+
eventFilterPathPatterns,
|
|
154
|
+
retry: opts.retry ?? false
|
|
155
|
+
}
|
|
156
|
+
};
|
|
173
157
|
}
|
|
174
|
-
exports.makeEndpoint = makeEndpoint;
|
|
175
158
|
/** @internal */
|
|
176
159
|
function onChangedOperation(eventType, referenceOrOpts, handler) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
func.run = handler;
|
|
191
|
-
func.__endpoint = makeEndpoint(eventType, opts, pathPattern, instancePattern);
|
|
192
|
-
return func;
|
|
160
|
+
const { path, instance, opts } = getOpts(referenceOrOpts);
|
|
161
|
+
const pathPattern = new require_common_utilities_path_pattern.PathPattern(path);
|
|
162
|
+
const instancePattern = new require_common_utilities_path_pattern.PathPattern(instance);
|
|
163
|
+
const func = (raw) => {
|
|
164
|
+
const event = raw;
|
|
165
|
+
const instanceUrl = getInstance(event);
|
|
166
|
+
const params = makeParams(event, pathPattern, instancePattern);
|
|
167
|
+
const databaseEvent = makeChangedDatabaseEvent(event, instanceUrl, params);
|
|
168
|
+
return require_v2_trace.wrapTraceContext(require_common_onInit.withInit(handler))(databaseEvent);
|
|
169
|
+
};
|
|
170
|
+
func.run = handler;
|
|
171
|
+
func.__endpoint = makeEndpoint(eventType, opts, pathPattern, instancePattern);
|
|
172
|
+
return func;
|
|
193
173
|
}
|
|
194
|
-
exports.onChangedOperation = onChangedOperation;
|
|
195
174
|
/** @internal */
|
|
196
175
|
function onOperation(eventType, referenceOrOpts, handler) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return func;
|
|
176
|
+
const { path, instance, opts } = getOpts(referenceOrOpts);
|
|
177
|
+
const pathPattern = new require_common_utilities_path_pattern.PathPattern(path);
|
|
178
|
+
const instancePattern = new require_common_utilities_path_pattern.PathPattern(instance);
|
|
179
|
+
const func = (raw) => {
|
|
180
|
+
const event = raw;
|
|
181
|
+
const instanceUrl = getInstance(event);
|
|
182
|
+
const params = makeParams(event, pathPattern, instancePattern);
|
|
183
|
+
const data = eventType === deletedEventType ? event.data.data : event.data.delta;
|
|
184
|
+
const databaseEvent = makeDatabaseEvent(event, data, instanceUrl, params);
|
|
185
|
+
return require_v2_trace.wrapTraceContext(require_common_onInit.withInit(handler))(databaseEvent);
|
|
186
|
+
};
|
|
187
|
+
func.run = handler;
|
|
188
|
+
func.__endpoint = makeEndpoint(eventType, opts, pathPattern, instancePattern);
|
|
189
|
+
return func;
|
|
212
190
|
}
|
|
213
|
-
exports.onOperation = onOperation;
|
|
214
191
|
function getInstance(event) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
? `http://${emuHost}/?ns=${event.instance}`
|
|
218
|
-
: `https://${event.instance}.${event.firebasedatabasehost}`;
|
|
192
|
+
const emuHost = process.env.FIREBASE_DATABASE_EMULATOR_HOST;
|
|
193
|
+
return emuHost ? `http://${emuHost}/?ns=${event.instance}` : `https://${event.instance}.${event.firebasedatabasehost}`;
|
|
219
194
|
}
|
|
195
|
+
|
|
196
|
+
//#endregion
|
|
197
|
+
exports.DataSnapshot = require_common_providers_database.DataSnapshot;
|
|
198
|
+
exports.createdEventType = createdEventType;
|
|
199
|
+
Object.defineProperty(exports, 'database_exports', {
|
|
200
|
+
enumerable: true,
|
|
201
|
+
get: function () {
|
|
202
|
+
return database_exports;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
exports.deletedEventType = deletedEventType;
|
|
206
|
+
exports.getOpts = getOpts;
|
|
207
|
+
exports.makeEndpoint = makeEndpoint;
|
|
208
|
+
exports.makeParams = makeParams;
|
|
209
|
+
exports.onChangedOperation = onChangedOperation;
|
|
210
|
+
exports.onOperation = onOperation;
|
|
211
|
+
exports.onValueCreated = onValueCreated;
|
|
212
|
+
exports.onValueDeleted = onValueDeleted;
|
|
213
|
+
exports.onValueUpdated = onValueUpdated;
|
|
214
|
+
exports.onValueWritten = onValueWritten;
|
|
215
|
+
exports.updatedEventType = updatedEventType;
|
|
216
|
+
exports.writtenEventType = writtenEventType;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { CloudEvent, CloudFunction } from "../core";
|
|
2
|
+
import { ParamsOf, VarName } from "../../common/params";
|
|
3
|
+
import { EventHandlerOptions, SupportedRegion } from "../options";
|
|
4
|
+
import { Expression } from "../../params";
|
|
5
|
+
import { ResetValue } from "../../common/options";
|
|
6
|
+
/** @hidden */
|
|
7
|
+
export interface SourceLocation {
|
|
8
|
+
line: number;
|
|
9
|
+
column: number;
|
|
10
|
+
}
|
|
11
|
+
/** @hidden */
|
|
12
|
+
export interface GraphqlErrorExtensions {
|
|
13
|
+
file: string;
|
|
14
|
+
code: string;
|
|
15
|
+
debugDetails: string;
|
|
16
|
+
}
|
|
17
|
+
/** @hidden */
|
|
18
|
+
export interface GraphqlError {
|
|
19
|
+
message: string;
|
|
20
|
+
locations: Array<SourceLocation>;
|
|
21
|
+
path: Array<string>;
|
|
22
|
+
extensions: GraphqlErrorExtensions;
|
|
23
|
+
}
|
|
24
|
+
/** @hidden */
|
|
25
|
+
export interface RawMutation<V, R> {
|
|
26
|
+
data: R;
|
|
27
|
+
variables: V;
|
|
28
|
+
errors: Array<GraphqlError>;
|
|
29
|
+
}
|
|
30
|
+
/** @hidden */
|
|
31
|
+
export interface MutationEventData<V, R> {
|
|
32
|
+
["@type"]: "type.googleapis.com/google.events.firebase.dataconnect.v1.MutationEventData";
|
|
33
|
+
payload: RawMutation<V, R>;
|
|
34
|
+
}
|
|
35
|
+
/** @hidden */
|
|
36
|
+
export interface RawDataConnectEvent<T> extends CloudEvent<T> {
|
|
37
|
+
project: string;
|
|
38
|
+
location: string;
|
|
39
|
+
service: string;
|
|
40
|
+
schema: string;
|
|
41
|
+
connector: string;
|
|
42
|
+
operation: string;
|
|
43
|
+
authtype: AuthType;
|
|
44
|
+
authid?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* AuthType defines the possible values for the authType field in a Firebase Data Connect event.
|
|
48
|
+
* - app_user: an end user of an application..
|
|
49
|
+
* - admin: an admin user of an application. In the context of impersonate endpoints used by the admin SDK, the impersonator.
|
|
50
|
+
* - unknown: a general type to capture all other principals not captured in the other auth types.
|
|
51
|
+
*/
|
|
52
|
+
export type AuthType = "app_user" | "admin" | "unknown";
|
|
53
|
+
/** OperationOptions extend EventHandlerOptions with a provided service, connector, and operation. */
|
|
54
|
+
export interface OperationOptions<Service extends string = string, Connector extends string = string, Operation extends string = string> extends EventHandlerOptions {
|
|
55
|
+
/** Firebase Data Connect service ID */
|
|
56
|
+
service?: Service;
|
|
57
|
+
/** Firebase Data Connect connector ID */
|
|
58
|
+
connector?: Connector;
|
|
59
|
+
/** Name of the operation */
|
|
60
|
+
operation?: Operation;
|
|
61
|
+
/**
|
|
62
|
+
* Region where functions should be deployed. Defaults to us-central1.
|
|
63
|
+
*/
|
|
64
|
+
region?: SupportedRegion | string | Expression<string> | ResetValue;
|
|
65
|
+
}
|
|
66
|
+
export type DataConnectParams<PathPatternOrOptions extends string | OperationOptions> = PathPatternOrOptions extends string ? ParamsOf<PathPatternOrOptions> : PathPatternOrOptions extends OperationOptions<infer Service extends string, infer Connector extends string, infer Operation extends string> ? Record<VarName<Service> | VarName<Connector> | VarName<Operation>, string> : never;
|
|
67
|
+
export interface DataConnectEvent<T, Params extends Record<never, string>> extends CloudEvent<T> {
|
|
68
|
+
/** The location of the Firebase Data Connect instance */
|
|
69
|
+
location: string;
|
|
70
|
+
/** The project identifier */
|
|
71
|
+
project: string;
|
|
72
|
+
/**
|
|
73
|
+
* An object containing the values of the path patterns.
|
|
74
|
+
* Only named capture groups will be populated - {key}, {key=*}, {key=**}.
|
|
75
|
+
*/
|
|
76
|
+
params: Params;
|
|
77
|
+
/** The type of principal that triggered the event */
|
|
78
|
+
authType: AuthType;
|
|
79
|
+
/** The unique identifier for the principal */
|
|
80
|
+
authId?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Event handler that triggers when a mutation is executed in Firebase Data Connect.
|
|
84
|
+
*
|
|
85
|
+
* @param mutation - The mutation path to trigger on.
|
|
86
|
+
* @param handler - Event handler which is run every time a mutation is executed.
|
|
87
|
+
*/
|
|
88
|
+
export declare function onMutationExecuted<Mutation extends string, Variables = unknown, ResponseData = unknown>(mutation: Mutation, handler: (event: DataConnectEvent<MutationEventData<Variables, ResponseData>, DataConnectParams<Mutation>>) => unknown | Promise<unknown>): CloudFunction<DataConnectEvent<MutationEventData<Variables, ResponseData>, DataConnectParams<Mutation>>>;
|
|
89
|
+
/**
|
|
90
|
+
* Event handler that triggers when a mutation is executed in Firebase Data Connect.
|
|
91
|
+
*
|
|
92
|
+
* @param opts - Options that can be set on an individual event-handling function.
|
|
93
|
+
* @param handler - Event handler which is run every time a mutation is executed.
|
|
94
|
+
*/
|
|
95
|
+
export declare function onMutationExecuted<Options extends OperationOptions, Variables = unknown, ResponseData = unknown>(opts: Options, handler: (event: DataConnectEvent<MutationEventData<Variables, ResponseData>, DataConnectParams<Options>>) => unknown | Promise<unknown>): CloudFunction<DataConnectEvent<MutationEventData<Variables, ResponseData>, DataConnectParams<Options>>>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_runtime_manifest = require('../../runtime/manifest.js');
|
|
3
|
+
const require_common_onInit = require('../../common/onInit.js');
|
|
4
|
+
const require_common_utilities_path = require('../../common/utilities/path.js');
|
|
5
|
+
const require_v2_trace = require('../trace.js');
|
|
6
|
+
const require_v2_options = require('../options.js');
|
|
7
|
+
const require_common_utilities_path_pattern = require('../../common/utilities/path-pattern.js');
|
|
8
|
+
|
|
9
|
+
//#region src/v2/providers/dataconnect.ts
|
|
10
|
+
var dataconnect_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
|
|
11
|
+
mutationExecutedEventType: () => mutationExecutedEventType,
|
|
12
|
+
onMutationExecuted: () => onMutationExecuted
|
|
13
|
+
});
|
|
14
|
+
/** @internal */
|
|
15
|
+
const mutationExecutedEventType = "google.firebase.dataconnect.connector.v1.mutationExecuted";
|
|
16
|
+
/**
|
|
17
|
+
* Event handler that triggers when a mutation is executed in Firebase Data Connect.
|
|
18
|
+
*
|
|
19
|
+
* @param mutationOrOpts - Options or string mutation path.
|
|
20
|
+
* @param handler - Event handler which is run every time a mutation is executed.
|
|
21
|
+
*/
|
|
22
|
+
function onMutationExecuted(mutationOrOpts, handler) {
|
|
23
|
+
return onOperation(mutationExecutedEventType, mutationOrOpts, handler);
|
|
24
|
+
}
|
|
25
|
+
function getOpts(mutationOrOpts) {
|
|
26
|
+
const operationRegex = new RegExp("services/([^/]+)/connectors/([^/]*)/operations/([^/]+)");
|
|
27
|
+
let service;
|
|
28
|
+
let connector;
|
|
29
|
+
let operation;
|
|
30
|
+
let opts;
|
|
31
|
+
if (typeof mutationOrOpts === "string") {
|
|
32
|
+
const path = require_common_utilities_path.normalizePath(mutationOrOpts);
|
|
33
|
+
const match = path.match(operationRegex);
|
|
34
|
+
if (!match) {
|
|
35
|
+
throw new Error(`Invalid operation path: ${path}`);
|
|
36
|
+
}
|
|
37
|
+
service = match[1];
|
|
38
|
+
connector = match[2];
|
|
39
|
+
operation = match[3];
|
|
40
|
+
opts = {};
|
|
41
|
+
} else {
|
|
42
|
+
service = mutationOrOpts.service;
|
|
43
|
+
connector = mutationOrOpts.connector;
|
|
44
|
+
operation = mutationOrOpts.operation;
|
|
45
|
+
opts = { ...mutationOrOpts };
|
|
46
|
+
delete opts.service;
|
|
47
|
+
delete opts.connector;
|
|
48
|
+
delete opts.operation;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
service,
|
|
52
|
+
connector,
|
|
53
|
+
operation,
|
|
54
|
+
opts
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function makeEndpoint(eventType, opts, service, connector, operation) {
|
|
58
|
+
const baseOpts = require_v2_options.optionsToEndpoint(require_v2_options.getGlobalOptions());
|
|
59
|
+
const specificOpts = require_v2_options.optionsToEndpoint(opts);
|
|
60
|
+
const eventFilters = {};
|
|
61
|
+
const eventFilterPathPatterns = {};
|
|
62
|
+
if (service) {
|
|
63
|
+
if (service.hasWildcards()) {
|
|
64
|
+
eventFilterPathPatterns.service = service.getValue();
|
|
65
|
+
} else {
|
|
66
|
+
eventFilters.service = service.getValue();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (connector) {
|
|
70
|
+
if (connector.hasWildcards()) {
|
|
71
|
+
eventFilterPathPatterns.connector = connector.getValue();
|
|
72
|
+
} else {
|
|
73
|
+
eventFilters.connector = connector.getValue();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (operation) {
|
|
77
|
+
if (operation.hasWildcards()) {
|
|
78
|
+
eventFilterPathPatterns.operation = operation.getValue();
|
|
79
|
+
} else {
|
|
80
|
+
eventFilters.operation = operation.getValue();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
...require_runtime_manifest.initV2Endpoint(require_v2_options.getGlobalOptions(), opts),
|
|
85
|
+
platform: "gcfv2",
|
|
86
|
+
...baseOpts,
|
|
87
|
+
...specificOpts,
|
|
88
|
+
labels: {
|
|
89
|
+
...baseOpts?.labels,
|
|
90
|
+
...specificOpts?.labels
|
|
91
|
+
},
|
|
92
|
+
eventTrigger: {
|
|
93
|
+
eventType,
|
|
94
|
+
eventFilters,
|
|
95
|
+
eventFilterPathPatterns,
|
|
96
|
+
retry: opts.retry ?? false
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function makeParams(event, service, connector, operation) {
|
|
101
|
+
return {
|
|
102
|
+
...service?.extractMatches(event.service),
|
|
103
|
+
...connector?.extractMatches(event.connector),
|
|
104
|
+
...operation?.extractMatches(event.operation)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function onOperation(eventType, mutationOrOpts, handler) {
|
|
108
|
+
const { service, connector, operation, opts } = getOpts(mutationOrOpts);
|
|
109
|
+
const servicePattern = service ? new require_common_utilities_path_pattern.PathPattern(service) : undefined;
|
|
110
|
+
const connectorPattern = connector ? new require_common_utilities_path_pattern.PathPattern(connector) : undefined;
|
|
111
|
+
const operationPattern = operation ? new require_common_utilities_path_pattern.PathPattern(operation) : undefined;
|
|
112
|
+
const func = (raw) => {
|
|
113
|
+
const event = raw;
|
|
114
|
+
const params = makeParams(event, servicePattern, connectorPattern, operationPattern);
|
|
115
|
+
const { authtype, authid, service: service$1, connector: connector$1, operation: operation$1,...rest } = event;
|
|
116
|
+
const dataConnectEvent = {
|
|
117
|
+
...rest,
|
|
118
|
+
authType: authtype,
|
|
119
|
+
authId: authid,
|
|
120
|
+
params
|
|
121
|
+
};
|
|
122
|
+
return require_v2_trace.wrapTraceContext(require_common_onInit.withInit(handler))(dataConnectEvent);
|
|
123
|
+
};
|
|
124
|
+
func.run = handler;
|
|
125
|
+
func.__endpoint = makeEndpoint(eventType, opts, servicePattern, connectorPattern, operationPattern);
|
|
126
|
+
return func;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
//#endregion
|
|
130
|
+
Object.defineProperty(exports, 'dataconnect_exports', {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function () {
|
|
133
|
+
return dataconnect_exports;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
exports.mutationExecutedEventType = mutationExecutedEventType;
|
|
137
|
+
exports.onMutationExecuted = onMutationExecuted;
|