@aglyn/tenant-data-admin 1.20.1 → 1.20.3
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/package.json +7 -7
- package/src/lib/server/erase.js +33 -1
- package/src/lib/server/erase.js.map +1 -1
- package/src/lib/server/firestore-transient.d.ts +37 -0
- package/src/lib/server/firestore-transient.js +68 -0
- package/src/lib/server/firestore-transient.js.map +1 -0
- package/src/lib/server/payment-provider-stripe-connect.d.ts +12 -0
- package/src/lib/server/payment-provider-stripe-connect.js +14 -0
- package/src/lib/server/payment-provider-stripe-connect.js.map +1 -1
- package/src/lib/server/payment-provider.d.ts +36 -0
- package/src/lib/server/payment-provider.js +44 -0
- package/src/lib/server/payment-provider.js.map +1 -1
- package/src/lib/server/tenant-dns-check.d.ts +33 -0
- package/src/lib/server/tenant-dns-check.js +141 -4
- package/src/lib/server/tenant-dns-check.js.map +1 -1
- package/src/tenancy.d.ts +1 -1
- package/src/tenancy.js +1 -1
- package/src/tenancy.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/tenant-data-admin",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.20.
|
|
29
|
-
"@aglyn/shared-util-email": "1.20.
|
|
30
|
-
"@aglyn/shared-util-fbserver": "1.20.
|
|
31
|
-
"@aglyn/shared-util-first-touch": "1.20.
|
|
32
|
-
"@aglyn/shared-util-http": "1.20.
|
|
33
|
-
"@aglyn/shared-util-tools": "1.20.
|
|
28
|
+
"@aglyn/aglyn": "1.20.3",
|
|
29
|
+
"@aglyn/shared-util-email": "1.20.3",
|
|
30
|
+
"@aglyn/shared-util-fbserver": "1.20.3",
|
|
31
|
+
"@aglyn/shared-util-first-touch": "1.20.3",
|
|
32
|
+
"@aglyn/shared-util-http": "1.20.3",
|
|
33
|
+
"@aglyn/shared-util-tools": "1.20.3",
|
|
34
34
|
"@msgpack/msgpack": "^3.1.3",
|
|
35
35
|
"@swc/helpers": "0.5.23",
|
|
36
36
|
"sharp": "^0.35.5",
|
package/src/lib/server/erase.js
CHANGED
|
@@ -39,6 +39,7 @@ import { releasedHostNames } from "./host-released-names.js";
|
|
|
39
39
|
import { readOrgBilling } from "./org-billing.js";
|
|
40
40
|
import { disposeHostSendingDomain, readSendingDomainTeardownByLabel } from "./sending-domain-debt.js";
|
|
41
41
|
import { addAdminAudit } from "./admin-audit-write.js";
|
|
42
|
+
import { retryTransientFirestore } from "./firestore-transient.js";
|
|
42
43
|
/** The reversible hold before a requested erasure is executed (AGL-485). */ export const ERASURE_HOLD_MS = 7 * 24 * 60 * 60 * 1000;
|
|
43
44
|
/**
|
|
44
45
|
* The admin app is initialized without a default storageBucket, so every
|
|
@@ -223,6 +224,37 @@ import { addAdminAudit } from "./admin-audit-write.js";
|
|
|
223
224
|
this.hold = hold;
|
|
224
225
|
}
|
|
225
226
|
}
|
|
227
|
+
/*==========================================
|
|
228
|
+
* ONE FAILED WRITE IN THE TREE IS NOT A FAILED DELETE.
|
|
229
|
+
*
|
|
230
|
+
* `recursiveDelete` is a bulk writer: a site is hundreds of deletes, and one
|
|
231
|
+
* that meets `UNAVAILABLE` or a deadline under load rejects the whole call
|
|
232
|
+
* with that write's code. Thrown from here it reached the delete route as a
|
|
233
|
+
* 500, for a site whose tree was gone, so the console said the delete failed
|
|
234
|
+
* and a retry found nothing to delete.
|
|
235
|
+
*
|
|
236
|
+
* So a transient failure runs the delete again, which is safe because a
|
|
237
|
+
* delete of what is already gone does nothing, and walks the subcollections
|
|
238
|
+
* whether or not the parent document still exists. When the retries are
|
|
239
|
+
* spent, or the failure was not transient, the host document decides: the
|
|
240
|
+
* bulk writer deletes it LAST, so its absence means the site is erased and
|
|
241
|
+
* no reader can route to it. What a write left behind is logged; the
|
|
242
|
+
* delete answers as done. A host document still standing is a real failure
|
|
243
|
+
* and is thrown.
|
|
244
|
+
*=========================================*/ async function eraseHostTree(firestore, hostRef, hostId) {
|
|
245
|
+
try {
|
|
246
|
+
await retryTransientFirestore(()=>firestore.recursiveDelete(hostRef), {
|
|
247
|
+
onRetry: (error, attempt)=>console.warn(`eraseHost: retrying the tree delete for ${hostId} (${attempt})`, error)
|
|
248
|
+
});
|
|
249
|
+
} catch (error) {
|
|
250
|
+
const remaining = await retryTransientFirestore(()=>hostRef.get()).catch(()=>null);
|
|
251
|
+
if (remaining && !remaining.exists) {
|
|
252
|
+
console.error(`eraseHost: the tree delete for ${hostId} reported a failure after the site was erased`, error);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
226
258
|
export async function eraseHost(hostId, options = {}) {
|
|
227
259
|
var _hostSnapshot_get, _hostSnapshot_get1;
|
|
228
260
|
const firestore = firebaseAdmin.app().firestore();
|
|
@@ -334,7 +366,7 @@ export async function eraseHost(hostId, options = {}) {
|
|
|
334
366
|
});
|
|
335
367
|
}
|
|
336
368
|
// The host document tree (screens/layouts/versions/counters/products/…).
|
|
337
|
-
await firestore
|
|
369
|
+
await eraseHostTree(firestore, hostRef, hostId);
|
|
338
370
|
// The plugin rows keyed by the site that its tree does not hold (AGL-4214).
|
|
339
371
|
// After the tree, so a register's display can no longer verify against it.
|
|
340
372
|
await erasePluginHostKeyedCollections(hostId);
|