@firebase-function-kits/delete-user-data 0.0.1 → 0.0.2-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.
Files changed (76) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/README.md +151 -0
  3. package/lib/config.d.ts +22 -0
  4. package/lib/config.d.ts.map +1 -0
  5. package/lib/config.js +86 -0
  6. package/lib/config.js.map +1 -0
  7. package/lib/events.d.ts +18 -0
  8. package/lib/events.d.ts.map +1 -0
  9. package/lib/events.js +71 -0
  10. package/lib/events.js.map +1 -0
  11. package/lib/export-config.d.ts +55 -0
  12. package/lib/export-config.d.ts.map +1 -0
  13. package/lib/export-config.js +56 -0
  14. package/lib/export-config.js.map +1 -0
  15. package/lib/handlers.d.ts +35 -0
  16. package/lib/handlers.d.ts.map +1 -0
  17. package/lib/handlers.js +243 -0
  18. package/lib/handlers.js.map +1 -0
  19. package/lib/helpers.d.ts +19 -0
  20. package/lib/helpers.d.ts.map +1 -0
  21. package/lib/helpers.js +39 -0
  22. package/lib/helpers.js.map +1 -0
  23. package/lib/index.d.ts +6 -0
  24. package/lib/index.d.ts.map +1 -0
  25. package/lib/index.js +112 -0
  26. package/lib/index.js.map +1 -0
  27. package/lib/lib.d.ts +23 -0
  28. package/lib/lib.d.ts.map +1 -0
  29. package/lib/lib.js +38 -0
  30. package/lib/lib.js.map +1 -0
  31. package/lib/logs.d.ts +26 -0
  32. package/lib/logs.d.ts.map +1 -0
  33. package/lib/logs.js +116 -0
  34. package/lib/logs.js.map +1 -0
  35. package/lib/recursiveDelete.d.ts +18 -0
  36. package/lib/recursiveDelete.d.ts.map +1 -0
  37. package/lib/recursiveDelete.js +37 -0
  38. package/lib/recursiveDelete.js.map +1 -0
  39. package/lib/runBatchPubSubDeletions.d.ts +27 -0
  40. package/lib/runBatchPubSubDeletions.d.ts.map +1 -0
  41. package/lib/runBatchPubSubDeletions.js +47 -0
  42. package/lib/runBatchPubSubDeletions.js.map +1 -0
  43. package/lib/runCustomSearchFunction.d.ts +18 -0
  44. package/lib/runCustomSearchFunction.d.ts.map +1 -0
  45. package/lib/runCustomSearchFunction.js +78 -0
  46. package/lib/runCustomSearchFunction.js.map +1 -0
  47. package/lib/search.d.ts +19 -0
  48. package/lib/search.d.ts.map +1 -0
  49. package/lib/search.js +29 -0
  50. package/lib/search.js.map +1 -0
  51. package/package.json +37 -4
  52. package/src/config.ts +98 -0
  53. package/src/events.ts +38 -0
  54. package/src/export-config.ts +112 -0
  55. package/src/handlers.ts +271 -0
  56. package/src/helpers.ts +42 -0
  57. package/src/index.ts +100 -0
  58. package/src/lib.ts +41 -0
  59. package/src/logs.ts +127 -0
  60. package/src/recursiveDelete.ts +42 -0
  61. package/src/runBatchPubSubDeletions.ts +66 -0
  62. package/src/runCustomSearchFunction.ts +50 -0
  63. package/src/search.ts +37 -0
  64. package/tests/config.test.ts +180 -0
  65. package/tests/export-config.test.ts +117 -0
  66. package/tests/fakes.ts +325 -0
  67. package/tests/handlers.test.ts +517 -0
  68. package/tests/helpers.test.ts +126 -0
  69. package/tests/lib.test.ts +40 -0
  70. package/tests/recursiveDelete.test.ts +102 -0
  71. package/tests/runBatchPubSubDeletions.test.ts +164 -0
  72. package/tests/runCustomSearchFunction.test.ts +125 -0
  73. package/tests/search.test.ts +127 -0
  74. package/tsconfig.json +18 -0
  75. package/tsconfig.tsbuildinfo +1 -0
  76. package/index.js +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ - Initial release
package/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # @firebase/delete-user-data
2
+
3
+ Delete user data across Firestore, RTDB, and Storage on account deletion. This
4
+ is the Delete User Data Firebase Extension as an npm package you add to your own
5
+ Firebase Functions codebase and deploy.
6
+
7
+ It listens for Firebase Auth user deletions, discovers configured (and optional
8
+ auto-discovered) paths containing the user id, and clears matching data in
9
+ Firestorestore, Realtime Database, and Cloud Storage. The functions run in your own
10
+ Firebase project; there is no hosted version, so you deploy them yourself.
11
+
12
+ ## Install
13
+
14
+ ```sh
15
+ npm install @firebase/delete-user-data
16
+ ```
17
+
18
+ ## Required IAM
19
+
20
+ Deploy needs these Google Cloud roles on the function's service account.
21
+ Firebase CLI 15.23.0 or later creates that account, grants the roles below,
22
+ and attaches it to every function in this kit. Do not set a custom runtime
23
+ service account for this codebase — it conflicts with that automatic setup.
24
+
25
+ | Role | Why |
26
+ |---|---|
27
+ | `roles/datastore.owner` | discover and delete Firestore user data |
28
+ | `roles/firebasedatabase.admin` | delete Realtime Database user data |
29
+ | `roles/storage.admin` | delete Cloud Storage user objects |
30
+ | `roles/pubsub.admin` | publish/subscribe discovery and deletion topics |
31
+ | `roles/eventarc.eventReceiver` | receive Gen2 event triggers |
32
+ | `roles/run.invoker` | allow Eventarc to invoke the Gen2 Cloud Run service |
33
+
34
+ ## Usage
35
+
36
+ Export the functions from your functions codebase entry:
37
+
38
+ ```ts
39
+ // functions/src/index.ts
40
+ export {
41
+ clearData,
42
+ handleSearch,
43
+ handleDeletion,
44
+ } from "@firebase/delete-user-data";
45
+ ```
46
+
47
+ and configure with a `.env` (or `.env.<projectId>`).
48
+
49
+ Importing the package without exporting its functions deploys nothing — the CLI
50
+ only deploys what your entry file exports.
51
+
52
+ ## Deploy
53
+
54
+ The package's `firebase.json` declares a `kit` stanza (Firebase CLI 15.25.1 or
55
+ later, behind the `kits` experiment):
56
+
57
+ ```json
58
+ {
59
+ "functions": [
60
+ {
61
+ "source": ".",
62
+ "kit": "delete-user-data",
63
+ "instances": {
64
+ "default": "."
65
+ }
66
+ }
67
+ ]
68
+ }
69
+ ```
70
+
71
+ `instances` maps each instance id to the directory (relative to
72
+ `firebase.json`) holding that instance's `.env`. The CLI prefixes every
73
+ function and task queue name with `kit-<instance id>-`, so the functions above
74
+ deploy as `kit-default-clearData`, `kit-default-handleSearch`, and
75
+ `kit-default-handleDeletion`.
76
+
77
+ ```sh
78
+ firebase experiments:enable kits
79
+ firebase deploy --only functions
80
+ ```
81
+
82
+ Deploy a single instance with `firebase deploy --only functions:<instance id>`.
83
+
84
+ ## Configuration
85
+
86
+ Set these values in a `.env` (or `.env.<projectId>`) file. The Firebase CLI
87
+ loads them at deploy time and prompts for any required values that are missing.
88
+
89
+ | Field | Env var | Required | Default | Description |
90
+ |---|---|---|---|---|
91
+ | `instanceId` | `INSTANCE_ID` | yes | — | Must match this instance's key in the `instances` map |
92
+ | `firestorePaths` | `FIRESTORE_PATHS` | no | (empty) | Comma-separated Firestore paths with `{UID}` |
93
+ | `firestoreDatabaseId` | `FIRESTORE_DATABASE_ID` | no | `(default)` | Firestore database id |
94
+ | `firestoreDeleteMode` | `FIRESTORE_DELETE_MODE` | no | `shallow` | `shallow` or `recursive` |
95
+ | `rtdbInstance` | `SELECTED_DATABASE_INSTANCE` | no | (empty) | RTDB instance id |
96
+ | `rtdbLocation` | `SELECTED_DATABASE_LOCATION` | no | `us-central1` | RTDB location |
97
+ | `rtdbPaths` | `RTDB_PATHS` | no | (empty) | Comma-separated RTDB paths with `{UID}` |
98
+ | `storageBucket` | `CLOUD_STORAGE_BUCKET` | no | default Storage bucket | Bucket to clear |
99
+ | `storagePaths` | `STORAGE_PATHS` | no | (empty) | Comma-separated Storage paths with `{UID}` |
100
+ | `enableAutoDiscovery` | `ENABLE_AUTO_DISCOVERY` | no | `false` | Auto-discover user-linked docs |
101
+ | `searchDepth` | `AUTO_DISCOVERY_SEARCH_DEPTH` | no | `3` | Discovery depth |
102
+ | `searchFields` | `AUTO_DISCOVERY_SEARCH_FIELDS` | no | `id,uid,userId` | Fields treated as user ids |
103
+ | `searchFunction` | `SEARCH_FUNCTION` | no | (empty) | Optional custom search function |
104
+ | `discoveryTopicName` | `DISCOVERY_TOPIC_NAME` | no | `kit-<INSTANCE_ID>-discovery` | Pub/Sub discovery topic |
105
+ | `deletionTopicName` | `DELETION_TOPIC_NAME` | no | `kit-<INSTANCE_ID>-deletion` | Pub/Sub deletion topic |
106
+
107
+ ## Multiple instances
108
+
109
+ To run several deletion pipelines, add one entry per instance to the `instances`
110
+ map, each pointing at its own config directory with its own `.env`:
111
+
112
+ ```json
113
+ {
114
+ "functions": [
115
+ {
116
+ "source": ".",
117
+ "kit": "delete-user-data",
118
+ "instances": {
119
+ "app": "instances/app",
120
+ "admin": "instances/admin"
121
+ }
122
+ }
123
+ ]
124
+ }
125
+ ```
126
+
127
+ Instance ids must be unique across all kit stanzas in the project, and every
128
+ instance's function names are namespaced by its `kit-<instance id>-` prefix, so
129
+ the instances cannot collide. Set `INSTANCE_ID` in each config directory to the
130
+ same value as that directory's key in the `instances` map.
131
+
132
+ ## Events
133
+
134
+ When `EVENTARC_CHANNEL` is configured, the functions publish deletion events
135
+ for each backend under `firebase.extensions.delete-user-data.v1.*`
136
+ (`firestore`, `database`, and `storage`).
137
+
138
+ ## API surface
139
+
140
+ - **Main entry** (`@firebase/delete-user-data`): exports `clearData`,
141
+ `handleSearch`, and `handleDeletion`. The main entry reads environment
142
+ variables when the module loads, so use it from Firebase deploy/emulator/runtime.
143
+ For your own triggers, import from `./lib` instead.
144
+ - **Library entry** (`./lib`): handlers (`handleClear`, `handleSearch`,
145
+ `handleDeletion`), path helpers, search / batch-deletion utilities, and config
146
+ types (`DeleteUserDataConfig`, `resolveDeleteUserDataConfig`) for owning
147
+ trigger registration yourself.
148
+
149
+ ## License
150
+
151
+ Apache-2.0
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { DeleteUserDataConfig } from "./export-config";
17
+ export declare const CONFIG_EXPRESSIONS: {
18
+ readonly discoveryTopicName: import("firebase-functions/params").StringParam;
19
+ readonly deletionTopicName: import("firebase-functions/params").StringParam;
20
+ };
21
+ export declare function configFromEnv(): DeleteUserDataConfig;
22
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAWH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AA0C5D,eAAO,MAAM,kBAAkB;aAC7B,kBAAkB;aAClB,iBAAiB;CACT,CAAC;AAMX,wBAAgB,aAAa,IAAI,oBAAoB,CAqBpD"}
package/lib/config.js ADDED
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2026 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.CONFIG_EXPRESSIONS = void 0;
19
+ exports.configFromEnv = configFromEnv;
20
+ const params_1 = require("firebase-functions/params");
21
+ const instanceId = (0, params_1.defineString)("INSTANCE_ID");
22
+ const params = {
23
+ instanceId,
24
+ firestorePaths: (0, params_1.defineString)("FIRESTORE_PATHS", { default: "" }),
25
+ firestoreDatabaseId: (0, params_1.defineString)("FIRESTORE_DATABASE_ID", {
26
+ default: "(default)",
27
+ }),
28
+ firestoreDeleteMode: (0, params_1.defineString)("FIRESTORE_DELETE_MODE", {
29
+ default: "shallow",
30
+ input: (0, params_1.select)(["recursive", "shallow"]),
31
+ }),
32
+ rtdbInstance: (0, params_1.defineString)("SELECTED_DATABASE_INSTANCE", { default: "" }),
33
+ rtdbLocation: (0, params_1.defineString)("SELECTED_DATABASE_LOCATION", {
34
+ default: "us-central1",
35
+ input: (0, params_1.select)(["us-central1", "europe-west1", "asia-southeast1"]),
36
+ }),
37
+ rtdbPaths: (0, params_1.defineString)("RTDB_PATHS", { default: "" }),
38
+ storageBucket: (0, params_1.defineString)("CLOUD_STORAGE_BUCKET", {
39
+ default: params_1.storageBucket,
40
+ }),
41
+ storagePaths: (0, params_1.defineString)("STORAGE_PATHS", { default: "" }),
42
+ enableAutoDiscovery: (0, params_1.defineBoolean)("ENABLE_AUTO_DISCOVERY", {
43
+ default: false,
44
+ }),
45
+ searchDepth: (0, params_1.defineInt)("AUTO_DISCOVERY_SEARCH_DEPTH", { default: 3 }),
46
+ searchFields: (0, params_1.defineString)("AUTO_DISCOVERY_SEARCH_FIELDS", {
47
+ default: "id,uid,userId",
48
+ }),
49
+ searchFunction: (0, params_1.defineString)("SEARCH_FUNCTION", { default: "" }),
50
+ // Non-empty defaults so Pub/Sub trigger bindings resolve during deploy
51
+ // discovery without freezing an empty topic name into the manifest.
52
+ discoveryTopicName: (0, params_1.defineString)("DISCOVERY_TOPIC_NAME", {
53
+ default: (0, params_1.expr) `kit-${instanceId}-discovery`,
54
+ }),
55
+ deletionTopicName: (0, params_1.defineString)("DELETION_TOPIC_NAME", {
56
+ default: (0, params_1.expr) `kit-${instanceId}-deletion`,
57
+ }),
58
+ };
59
+ exports.CONFIG_EXPRESSIONS = {
60
+ discoveryTopicName: params.discoveryTopicName,
61
+ deletionTopicName: params.deletionTopicName,
62
+ };
63
+ function optional(value) {
64
+ return value.length > 0 ? value : undefined;
65
+ }
66
+ function configFromEnv() {
67
+ return {
68
+ firestorePaths: optional(params.firestorePaths.value()),
69
+ firestoreDatabaseId: params.firestoreDatabaseId.value(),
70
+ firestoreDeleteMode: params.firestoreDeleteMode.value(),
71
+ rtdbInstance: optional(params.rtdbInstance.value()),
72
+ rtdbLocation: optional(params.rtdbLocation.value()),
73
+ rtdbPaths: optional(params.rtdbPaths.value()),
74
+ storageBucket: optional(params.storageBucket.value()) ?? process.env.STORAGE_BUCKET,
75
+ storagePaths: optional(params.storagePaths.value()),
76
+ enableAutoDiscovery: params.enableAutoDiscovery.value(),
77
+ searchDepth: params.searchDepth.value(),
78
+ searchFields: params.searchFields.value(),
79
+ searchFunction: optional(params.searchFunction.value()),
80
+ instanceId: params.instanceId.value(),
81
+ discoveryTopicName: optional(params.discoveryTopicName.value()),
82
+ deletionTopicName: optional(params.deletionTopicName.value()),
83
+ projectId: params_1.projectID.value(),
84
+ };
85
+ }
86
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,sDAQmC;AAGnC,MAAM,UAAU,GAAG,IAAA,qBAAY,EAAC,aAAa,CAAC,CAAC;AAE/C,MAAM,MAAM,GAAG;IACb,UAAU;IACV,cAAc,EAAE,IAAA,qBAAY,EAAC,iBAAiB,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAChE,mBAAmB,EAAE,IAAA,qBAAY,EAAC,uBAAuB,EAAE;QACzD,OAAO,EAAE,WAAW;KACrB,CAAC;IACF,mBAAmB,EAAE,IAAA,qBAAY,EAAC,uBAAuB,EAAE;QACzD,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,IAAA,eAAM,EAAC,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;KACxC,CAAC;IACF,YAAY,EAAE,IAAA,qBAAY,EAAC,4BAA4B,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACzE,YAAY,EAAE,IAAA,qBAAY,EAAC,4BAA4B,EAAE;QACvD,OAAO,EAAE,aAAa;QACtB,KAAK,EAAE,IAAA,eAAM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file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare const setupEventChannel: () => void;
17
+ export declare function publishDeletionEvent(target: "firestore" | "database" | "storage", data: object): Promise<unknown>;
18
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,eAAO,MAAM,iBAAiB,QAAO,IAMpC,CAAC;AAEF,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,EAC5C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAMlB"}
package/lib/events.js ADDED
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2026 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || (function () {
34
+ var ownKeys = function(o) {
35
+ ownKeys = Object.getOwnPropertyNames || function (o) {
36
+ var ar = [];
37
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
38
+ return ar;
39
+ };
40
+ return ownKeys(o);
41
+ };
42
+ return function (mod) {
43
+ if (mod && mod.__esModule) return mod;
44
+ var result = {};
45
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
46
+ __setModuleDefault(result, mod);
47
+ return result;
48
+ };
49
+ })();
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.setupEventChannel = void 0;
52
+ exports.publishDeletionEvent = publishDeletionEvent;
53
+ const eventArc = __importStar(require("firebase-admin/eventarc"));
54
+ let eventChannel;
55
+ const setupEventChannel = () => {
56
+ eventChannel = process.env.EVENTARC_CHANNEL
57
+ ? eventArc.getEventarc().channel(process.env.EVENTARC_CHANNEL, {
58
+ allowedEventTypes: process.env.EXT_SELECTED_EVENTS,
59
+ })
60
+ : undefined;
61
+ };
62
+ exports.setupEventChannel = setupEventChannel;
63
+ async function publishDeletionEvent(target, data) {
64
+ if (!eventChannel)
65
+ return Promise.resolve();
66
+ return eventChannel.publish({
67
+ type: `firebase.extensions.delete-user-data.v1.${target}`,
68
+ data,
69
+ });
70
+ }
71
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,MAAY,QAAQ,oDAAgC;AAEpD,IAAI,YAA0C,CAAC;AAExC,MAAM,iBAAiB,GAAG,GAAS,EAAE;IAC1C,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB;QACzC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE;YAC3D,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;SACnD,CAAC;QACJ,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC;AANW,QAAA,iBAAiB,GAAjB,iBAAiB,CAM5B;AAEK,KAAK,+BACV,MAA4C,EAC5C,IAAY;IAEZ,IAAI,CAAC,YAAY;QAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5C,OAAO,YAAY,CAAC,OAAO,CAAC;QAC1B,IAAI,EAAE,2CAA2C,MAAM,EAAE;QACzD,IAAI;KACL,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export type FirestoreDeleteMode = "recursive" | "shallow";
17
+ export interface DeleteUserDataConfig {
18
+ firestorePaths?: string;
19
+ firestoreDatabaseId?: string;
20
+ firestoreDeleteMode?: FirestoreDeleteMode;
21
+ rtdbInstance?: string;
22
+ rtdbLocation?: string;
23
+ rtdbPaths?: string;
24
+ storageBucket?: string;
25
+ storagePaths?: string;
26
+ enableAutoDiscovery?: boolean;
27
+ searchDepth?: number;
28
+ searchFields?: string;
29
+ searchFunction?: string;
30
+ instanceId: string;
31
+ discoveryTopicName?: string;
32
+ deletionTopicName?: string;
33
+ projectId?: string;
34
+ }
35
+ export interface ResolvedDeleteUserDataConfig {
36
+ firestorePaths?: string;
37
+ firestoreDatabaseId: string;
38
+ firestoreDeleteMode: FirestoreDeleteMode;
39
+ rtdbInstance?: string;
40
+ rtdbLocation?: string;
41
+ rtdbPaths?: string;
42
+ storageBucket?: string;
43
+ storagePaths?: string;
44
+ enableAutoDiscovery: boolean;
45
+ searchDepth: number;
46
+ searchFields: string;
47
+ searchFunction?: string;
48
+ instanceId: string;
49
+ discoveryTopicName: string;
50
+ deletionTopicName: string;
51
+ projectId?: string;
52
+ }
53
+ export declare function resolveDeleteUserDataConfig(config: DeleteUserDataConfig): ResolvedDeleteUserDataConfig;
54
+ export declare function getDatabaseUrl(selectedDatabaseInstance: string | undefined, selectedDatabaseLocation: string | undefined): string | null;
55
+ //# sourceMappingURL=export-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-config.d.ts","sourceRoot":"","sources":["../src/export-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,SAAS,CAAC;AAE1D,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,4BAA4B;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAcD,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,oBAAoB,GAC3B,4BAA4B,CA8B9B;AAED,wBAAgB,cAAc,CAC5B,wBAAwB,EAAE,MAAM,GAAG,SAAS,EAC5C,wBAAwB,EAAE,MAAM,GAAG,SAAS,GAC3C,MAAM,GAAG,IAAI,CAMf"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2026 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.resolveDeleteUserDataConfig = resolveDeleteUserDataConfig;
19
+ exports.getDatabaseUrl = getDatabaseUrl;
20
+ const DEFAULT_FIRESTORE_DATABASE_ID = "(default)";
21
+ const DEFAULT_FIRESTORE_DELETE_MODE = "shallow";
22
+ const DEFAULT_SEARCH_DEPTH = 3;
23
+ const DEFAULT_SEARCH_FIELDS = "id,uid,userId";
24
+ function topicName(name, instanceId, suffix) {
25
+ return name ?? `kit-${instanceId}-${suffix}`;
26
+ }
27
+ function resolveDeleteUserDataConfig(config) {
28
+ const instanceId = config.instanceId;
29
+ return {
30
+ firestorePaths: config.firestorePaths,
31
+ firestoreDatabaseId: config.firestoreDatabaseId ?? DEFAULT_FIRESTORE_DATABASE_ID,
32
+ firestoreDeleteMode: config.firestoreDeleteMode ?? DEFAULT_FIRESTORE_DELETE_MODE,
33
+ rtdbInstance: config.rtdbInstance,
34
+ rtdbLocation: config.rtdbLocation,
35
+ rtdbPaths: config.rtdbPaths,
36
+ storageBucket: config.storageBucket,
37
+ storagePaths: config.storagePaths,
38
+ enableAutoDiscovery: config.enableAutoDiscovery ?? false,
39
+ searchDepth: config.searchDepth ?? DEFAULT_SEARCH_DEPTH,
40
+ searchFields: config.searchFields ?? DEFAULT_SEARCH_FIELDS,
41
+ searchFunction: config.searchFunction,
42
+ instanceId,
43
+ discoveryTopicName: topicName(config.discoveryTopicName, instanceId, "discovery"),
44
+ deletionTopicName: topicName(config.deletionTopicName, instanceId, "deletion"),
45
+ projectId: config.projectId,
46
+ };
47
+ }
48
+ function getDatabaseUrl(selectedDatabaseInstance, selectedDatabaseLocation) {
49
+ if (!selectedDatabaseLocation || !selectedDatabaseInstance)
50
+ return null;
51
+ if (selectedDatabaseLocation === "us-central1") {
52
+ return `https://${selectedDatabaseInstance}.firebaseio.com`;
53
+ }
54
+ return `https://${selectedDatabaseInstance}.${selectedDatabaseLocation}.firebasedatabase.app`;
55
+ }
56
+ //# sourceMappingURL=export-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-config.js","sourceRoot":"","sources":["../src/export-config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AA0CH,MAAM,6BAA6B,GAAG,WAAW,CAAC;AAClD,MAAM,6BAA6B,GAAwB,SAAS,CAAC;AACrE,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAC9C,SAAS,SAAS,CAChB,IAAwB,EACxB,UAAkB,EAClB,MAAc;IAEd,OAAO,IAAI,IAAI,OAAO,UAAU,IAAI,MAAM,EAAE,CAAC;AAC/C,CAAC;AAED,qCACE,MAA4B;IAE5B,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACrC,OAAO;QACL,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,mBAAmB,EACjB,MAAM,CAAC,mBAAmB,IAAI,6BAA6B;QAC7D,mBAAmB,EACjB,MAAM,CAAC,mBAAmB,IAAI,6BAA6B;QAC7D,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,IAAI,KAAK;QACxD,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,oBAAoB;QACvD,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,qBAAqB;QAC1D,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,UAAU;QACV,kBAAkB,EAAE,SAAS,CAC3B,MAAM,CAAC,kBAAkB,EACzB,UAAU,EACV,WAAW,CACZ;QACD,iBAAiB,EAAE,SAAS,CAC1B,MAAM,CAAC,iBAAiB,EACxB,UAAU,EACV,UAAU,CACX;QACD,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC;AACJ,CAAC;AAED,wBACE,wBAA4C,EAC5C,wBAA4C;IAE5C,IAAI,CAAC,wBAAwB,IAAI,CAAC,wBAAwB;QAAE,OAAO,IAAI,CAAC;IACxE,IAAI,wBAAwB,KAAK,aAAa,EAAE,CAAC;QAC/C,OAAO,WAAW,wBAAwB,iBAAiB,CAAC;IAC9D,CAAC;IACD,OAAO,WAAW,wBAAwB,IAAI,wBAAwB,uBAAuB,CAAC;AAChG,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright 2026 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type * as admin from "firebase-admin";
17
+ import { type PublisherContext } from "./runBatchPubSubDeletions";
18
+ export interface HandlerContext extends PublisherContext {
19
+ firestore: admin.firestore.Firestore;
20
+ storage: admin.storage.Storage;
21
+ database: admin.database.Database;
22
+ }
23
+ export interface DeleteMessageData {
24
+ paths: string[];
25
+ uid: string;
26
+ }
27
+ export interface SearchMessageData {
28
+ path: string;
29
+ depth: number;
30
+ uid: string;
31
+ }
32
+ export declare function handleDeletion(data: DeleteMessageData, ctx: HandlerContext): Promise<void>;
33
+ export declare function handleSearch(data: SearchMessageData, ctx: HandlerContext): Promise<void>;
34
+ export declare function handleClear(uid: string, ctx: HandlerContext): Promise<void>;
35
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,gBAAgB,CAAC;AAQ7C,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,2BAA2B,CAAC;AAInC,MAAM,WAAW,cAAe,SAAQ,gBAAgB;IACtD,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC;IACrC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;IAC/B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;CACnC;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,iBAAiB,EACvB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,IAAI,CAAC,CAwCf;AAED,wBAAsB,YAAY,CAChC,IAAI,EAAE,iBAAiB,EACvB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,IAAI,CAAC,CAgDf;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,IAAI,CAAC,CA+Bf"}