@substrat-run/adapter-cloudflare 0.228.0 → 0.230.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/dist/broker-lake.d.ts +26 -2
- package/dist/broker-lake.d.ts.map +1 -1
- package/dist/broker-lake.js +56 -3
- package/dist/broker-lake.js.map +1 -1
- package/dist/control-plane-do.d.ts +50 -13
- package/dist/control-plane-do.d.ts.map +1 -1
- package/dist/control-plane-do.js +128 -52
- package/dist/control-plane-do.js.map +1 -1
- package/dist/delivery-broker-do.d.ts +26 -1
- package/dist/delivery-broker-do.d.ts.map +1 -1
- package/dist/delivery-broker-do.js +50 -3
- package/dist/delivery-broker-do.js.map +1 -1
- package/dist/delivery-broker-platform.d.ts +24 -2
- package/dist/delivery-broker-platform.d.ts.map +1 -1
- package/dist/delivery-broker-platform.js +43 -2
- package/dist/delivery-broker-platform.js.map +1 -1
- package/dist/delivery-handoff.d.ts +8 -1
- package/dist/delivery-handoff.d.ts.map +1 -1
- package/dist/delivery-handoff.js +8 -5
- package/dist/delivery-handoff.js.map +1 -1
- package/dist/directory-cutover.d.ts +93 -1
- package/dist/directory-cutover.d.ts.map +1 -1
- package/dist/directory-cutover.js +85 -2
- package/dist/directory-cutover.js.map +1 -1
- package/dist/directory-objects.d.ts +12 -0
- package/dist/directory-objects.d.ts.map +1 -1
- package/dist/directory-objects.js +8 -1
- package/dist/directory-objects.js.map +1 -1
- package/dist/directory-placement.d.ts.map +1 -1
- package/dist/directory-placement.js +1 -0
- package/dist/directory-placement.js.map +1 -1
- package/dist/directory-tenant-identities.d.ts +30 -0
- package/dist/directory-tenant-identities.d.ts.map +1 -0
- package/dist/directory-tenant-identities.js +64 -0
- package/dist/directory-tenant-identities.js.map +1 -0
- package/dist/directory-tenant-tuples.d.ts +30 -3
- package/dist/directory-tenant-tuples.d.ts.map +1 -1
- package/dist/directory-tenant-tuples.js +27 -0
- package/dist/directory-tenant-tuples.js.map +1 -1
- package/dist/host.d.ts +35 -5
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +110 -19
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/peer-call-target.d.ts +16 -2
- package/dist/peer-call-target.d.ts.map +1 -1
- package/dist/peer-call-target.js +36 -6
- package/dist/peer-call-target.js.map +1 -1
- package/dist/reconcile-on-wake.d.ts +17 -1
- package/dist/reconcile-on-wake.d.ts.map +1 -1
- package/dist/reconcile-on-wake.js +84 -12
- package/dist/reconcile-on-wake.js.map +1 -1
- package/dist/route-read-model-publisher.d.ts.map +1 -1
- package/dist/route-read-model-publisher.js +4 -0
- package/dist/route-read-model-publisher.js.map +1 -1
- package/dist/route-resolver.d.ts +19 -2
- package/dist/route-resolver.d.ts.map +1 -1
- package/dist/route-resolver.js +25 -5
- package/dist/route-resolver.js.map +1 -1
- package/dist/scope-do.d.ts +19 -0
- package/dist/scope-do.d.ts.map +1 -1
- package/dist/scope-do.js +398 -25
- package/dist/scope-do.js.map +1 -1
- package/dist/scope-facets.d.ts +121 -0
- package/dist/scope-facets.d.ts.map +1 -0
- package/dist/scope-facets.js +98 -0
- package/dist/scope-facets.js.map +1 -0
- package/dist/scope-supervisor-do.d.ts +93 -0
- package/dist/scope-supervisor-do.d.ts.map +1 -0
- package/dist/scope-supervisor-do.js +504 -0
- package/dist/scope-supervisor-do.js.map +1 -0
- package/dist/scope-sweeper-do.d.ts +7 -1
- package/dist/scope-sweeper-do.d.ts.map +1 -1
- package/dist/scope-sweeper-do.js +17 -1
- package/dist/scope-sweeper-do.js.map +1 -1
- package/dist/scope-wake.d.ts +5 -0
- package/dist/scope-wake.d.ts.map +1 -1
- package/dist/scope-wake.js +2 -0
- package/dist/scope-wake.js.map +1 -1
- package/dist/scope-work.d.ts +1 -1
- package/dist/scope-work.js +1 -1
- package/dist/scope-work.js.map +1 -1
- package/dist/supplied-pass-box.d.ts +77 -0
- package/dist/supplied-pass-box.d.ts.map +1 -0
- package/dist/supplied-pass-box.js +265 -0
- package/dist/supplied-pass-box.js.map +1 -0
- package/dist/tenant-due-index-do.d.ts +76 -0
- package/dist/tenant-due-index-do.d.ts.map +1 -0
- package/dist/tenant-due-index-do.js +90 -0
- package/dist/tenant-due-index-do.js.map +1 -0
- package/dist/tenant-due-nudge.d.ts +66 -0
- package/dist/tenant-due-nudge.d.ts.map +1 -0
- package/dist/tenant-due-nudge.js +77 -0
- package/dist/tenant-due-nudge.js.map +1 -0
- package/dist/tenant-due-work-do.d.ts +26 -0
- package/dist/tenant-due-work-do.d.ts.map +1 -1
- package/dist/tenant-due-work-do.js +69 -5
- package/dist/tenant-due-work-do.js.map +1 -1
- package/package.json +12 -12
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { DurableObject } from 'cloudflare:workers';
|
|
2
|
+
/**
|
|
3
|
+
* K-69 (no scheduled walk over tenants), the safety net's first half (#3540): which tenants' due-work
|
|
4
|
+
* objects hold work that should have run long ago, read without visiting every tenant.
|
|
5
|
+
*
|
|
6
|
+
* Each tenant's due-work object (`tenant-due-work-do.ts`) keeps its rows and one alarm. When its
|
|
7
|
+
* deployment gives it an index, it notes here, after every arm and every clear, the earliest time any
|
|
8
|
+
* of its rows is due (`null` once it holds none). This object keeps ONE row per tenant, ordered by
|
|
9
|
+
* that time, so the tenants whose earliest row is more than an hour gone (K-69's overdue bound) are
|
|
10
|
+
* the head of one index range and are read a bounded page at a time: `overdue`. `lag` says how far
|
|
11
|
+
* behind the head is. Both are reads: nothing here wakes, arms or runs anything. The nudger that acts
|
|
12
|
+
* on the selection is a later step, and until it exists the `*\/15` pass's handoff stays the check.
|
|
13
|
+
*
|
|
14
|
+
* A note is a hint, as a due row is: an object's alarm still decides when its rows run. So:
|
|
15
|
+
* - a note carries a stamp, and one older than the row's is dropped (`stale`), so two notes that
|
|
16
|
+
* arrive out of order leave the later one standing. A clear keeps its stamp on the row, so a late
|
|
17
|
+
* arm noted before it cannot bring the tenant back;
|
|
18
|
+
* - an object reset loses its rows, not the clock its stamps are read from, so its next note is
|
|
19
|
+
* newer than any it sent before and replaces what the index held;
|
|
20
|
+
* - a lost note leaves the index behind its object. The selection may then name a tenant with nothing
|
|
21
|
+
* overdue (its object answers that when asked), or miss one, which the pass's handoff still covers.
|
|
22
|
+
*
|
|
23
|
+
* One object per environment: `ns.get(ns.idFromName(TENANT_DUE_INDEX_NAME))`.
|
|
24
|
+
*/
|
|
25
|
+
/** The one index object's name. */
|
|
26
|
+
export declare const TENANT_DUE_INDEX_NAME = "tenant-due-index";
|
|
27
|
+
/** How far past its time a tenant's earliest row may be before the selection calls it overdue: K-69's hour. */
|
|
28
|
+
export declare const TENANT_DUE_INDEX_OVERDUE_MS: number;
|
|
29
|
+
/** The most tenants one `overdue` page returns, and the most one `lag` counts. */
|
|
30
|
+
export declare const TENANT_DUE_INDEX_PAGE = 100;
|
|
31
|
+
export declare const TENANT_DUE_INDEX_LAG_CAP = 1000;
|
|
32
|
+
/** What a note did: `kept` replaced the row (or wrote the first), `stale` was older than it and was dropped. */
|
|
33
|
+
export type TenantDueNote = 'kept' | 'stale';
|
|
34
|
+
export interface TenantDueOverdueQuery {
|
|
35
|
+
/** Epoch ms the selection is judged at. */
|
|
36
|
+
now: number;
|
|
37
|
+
/** Default {@link TENANT_DUE_INDEX_OVERDUE_MS}. */
|
|
38
|
+
overdueAfterMs?: number;
|
|
39
|
+
/** The previous page's `next`. */
|
|
40
|
+
after?: string;
|
|
41
|
+
/** Default and ceiling {@link TENANT_DUE_INDEX_PAGE}. */
|
|
42
|
+
limit?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface TenantDueOverdue {
|
|
45
|
+
tenantId: string;
|
|
46
|
+
/** Epoch ms of the tenant's earliest due row, as last noted. */
|
|
47
|
+
earliestAt: number;
|
|
48
|
+
/** `now - earliestAt`. */
|
|
49
|
+
lagMs: number;
|
|
50
|
+
}
|
|
51
|
+
export interface TenantDueOverduePage {
|
|
52
|
+
tenants: TenantDueOverdue[];
|
|
53
|
+
/** Hand back as `after` for the next page; null when this page was the last. */
|
|
54
|
+
next: string | null;
|
|
55
|
+
}
|
|
56
|
+
export interface TenantDueLag {
|
|
57
|
+
/** Tenants overdue, counted up to `cap`. */
|
|
58
|
+
overdue: number;
|
|
59
|
+
/** True when there were more than `cap`. */
|
|
60
|
+
capped: boolean;
|
|
61
|
+
/** How long the oldest overdue tenant's earliest row has waited; 0 when none is overdue. */
|
|
62
|
+
maxLagMs: number;
|
|
63
|
+
oldestTenantId: string | null;
|
|
64
|
+
}
|
|
65
|
+
/** The RPC surface a `defineTenantDueIndexDO` class exposes over its stub. */
|
|
66
|
+
export interface TenantDueIndexDo {
|
|
67
|
+
note(tenantId: string, stamp: number, earliestAt: number | null): Promise<TenantDueNote>;
|
|
68
|
+
overdue(query: TenantDueOverdueQuery): Promise<TenantDueOverduePage>;
|
|
69
|
+
lag(query: {
|
|
70
|
+
now: number;
|
|
71
|
+
overdueAfterMs?: number;
|
|
72
|
+
cap?: number;
|
|
73
|
+
}): Promise<TenantDueLag>;
|
|
74
|
+
}
|
|
75
|
+
export declare function defineTenantDueIndexDO<Env>(): new (ctx: DurableObjectState, env: Env) => DurableObject<Env> & TenantDueIndexDo;
|
|
76
|
+
//# sourceMappingURL=tenant-due-index-do.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-due-index-do.d.ts","sourceRoot":"","sources":["../src/tenant-due-index-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,mCAAmC;AACnC,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD,+GAA+G;AAC/G,eAAO,MAAM,2BAA2B,QAAc,CAAC;AAEvD,kFAAkF;AAClF,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,wBAAwB,O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AC3F;AAUD,wBAAgB,sBAAsB,CAAC,GAAG,KAAK,KAAK,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,KAAK,aAAa,CAAC,GAAG,CAAC,GAAG,gBAAgB,CAiE9H"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { DurableObject } from 'cloudflare:workers';
|
|
2
|
+
/**
|
|
3
|
+
* K-69 (no scheduled walk over tenants), the safety net's first half (#3540): which tenants' due-work
|
|
4
|
+
* objects hold work that should have run long ago, read without visiting every tenant.
|
|
5
|
+
*
|
|
6
|
+
* Each tenant's due-work object (`tenant-due-work-do.ts`) keeps its rows and one alarm. When its
|
|
7
|
+
* deployment gives it an index, it notes here, after every arm and every clear, the earliest time any
|
|
8
|
+
* of its rows is due (`null` once it holds none). This object keeps ONE row per tenant, ordered by
|
|
9
|
+
* that time, so the tenants whose earliest row is more than an hour gone (K-69's overdue bound) are
|
|
10
|
+
* the head of one index range and are read a bounded page at a time: `overdue`. `lag` says how far
|
|
11
|
+
* behind the head is. Both are reads: nothing here wakes, arms or runs anything. The nudger that acts
|
|
12
|
+
* on the selection is a later step, and until it exists the `*\/15` pass's handoff stays the check.
|
|
13
|
+
*
|
|
14
|
+
* A note is a hint, as a due row is: an object's alarm still decides when its rows run. So:
|
|
15
|
+
* - a note carries a stamp, and one older than the row's is dropped (`stale`), so two notes that
|
|
16
|
+
* arrive out of order leave the later one standing. A clear keeps its stamp on the row, so a late
|
|
17
|
+
* arm noted before it cannot bring the tenant back;
|
|
18
|
+
* - an object reset loses its rows, not the clock its stamps are read from, so its next note is
|
|
19
|
+
* newer than any it sent before and replaces what the index held;
|
|
20
|
+
* - a lost note leaves the index behind its object. The selection may then name a tenant with nothing
|
|
21
|
+
* overdue (its object answers that when asked), or miss one, which the pass's handoff still covers.
|
|
22
|
+
*
|
|
23
|
+
* One object per environment: `ns.get(ns.idFromName(TENANT_DUE_INDEX_NAME))`.
|
|
24
|
+
*/
|
|
25
|
+
/** The one index object's name. */
|
|
26
|
+
export const TENANT_DUE_INDEX_NAME = 'tenant-due-index';
|
|
27
|
+
/** How far past its time a tenant's earliest row may be before the selection calls it overdue: K-69's hour. */
|
|
28
|
+
export const TENANT_DUE_INDEX_OVERDUE_MS = 60 * 60_000;
|
|
29
|
+
/** The most tenants one `overdue` page returns, and the most one `lag` counts. */
|
|
30
|
+
export const TENANT_DUE_INDEX_PAGE = 100;
|
|
31
|
+
export const TENANT_DUE_INDEX_LAG_CAP = 1_000;
|
|
32
|
+
const cursorOf = (earliestAt, tenantId) => `${earliestAt}:${tenantId}`;
|
|
33
|
+
function parseCursor(after) {
|
|
34
|
+
const at = after.indexOf(':');
|
|
35
|
+
const earliestAt = Number(after.slice(0, at));
|
|
36
|
+
if (at <= 0 || !Number.isSafeInteger(earliestAt))
|
|
37
|
+
throw new Error(`not a tenant due index cursor: ${after}`);
|
|
38
|
+
return [earliestAt, after.slice(at + 1)];
|
|
39
|
+
}
|
|
40
|
+
export function defineTenantDueIndexDO() {
|
|
41
|
+
return class TenantDueIndexDO extends DurableObject {
|
|
42
|
+
constructor(ctx, env) {
|
|
43
|
+
super(ctx, env);
|
|
44
|
+
// `earliest_at` null is a cleared tenant: its row stays only to hold the stamp a late note is judged by.
|
|
45
|
+
ctx.storage.sql.exec(`CREATE TABLE IF NOT EXISTS tenant_due (tenant_id TEXT PRIMARY KEY, earliest_at INTEGER, stamp INTEGER NOT NULL)`);
|
|
46
|
+
ctx.storage.sql.exec(`CREATE INDEX IF NOT EXISTS tenant_due_earliest ON tenant_due (earliest_at, tenant_id) WHERE earliest_at IS NOT NULL`);
|
|
47
|
+
}
|
|
48
|
+
async note(tenantId, stamp, earliestAt) {
|
|
49
|
+
if (!tenantId || !Number.isSafeInteger(stamp) || (earliestAt !== null && !Number.isSafeInteger(earliestAt))) {
|
|
50
|
+
throw new Error(`not a tenant due note: ${JSON.stringify({ tenantId, stamp, earliestAt })}`);
|
|
51
|
+
}
|
|
52
|
+
// One statement, so a note is judged and written at once: the newer stamp wins, ties to the later arrival.
|
|
53
|
+
const changed = this.ctx.storage.sql.exec(`INSERT INTO tenant_due (tenant_id, earliest_at, stamp) VALUES (?, ?, ?)
|
|
54
|
+
ON CONFLICT (tenant_id) DO UPDATE SET earliest_at = excluded.earliest_at, stamp = excluded.stamp
|
|
55
|
+
WHERE excluded.stamp >= tenant_due.stamp`, tenantId, earliestAt, stamp).rowsWritten;
|
|
56
|
+
return changed > 0 ? 'kept' : 'stale';
|
|
57
|
+
}
|
|
58
|
+
async overdue(query) {
|
|
59
|
+
const cutoff = query.now - (query.overdueAfterMs ?? TENANT_DUE_INDEX_OVERDUE_MS);
|
|
60
|
+
const limit = Math.max(1, Math.min(query.limit ?? TENANT_DUE_INDEX_PAGE, TENANT_DUE_INDEX_PAGE));
|
|
61
|
+
const [afterAt, afterTenant] = query.after === undefined ? [Number.MIN_SAFE_INTEGER, ''] : parseCursor(query.after);
|
|
62
|
+
// The index range, in (earliest_at, tenant_id) order, after the cursor: one row per tenant, so a
|
|
63
|
+
// page never names a tenant twice. One more than the page says whether there is a next.
|
|
64
|
+
const rows = this.ctx.storage.sql.exec(`SELECT tenant_id, earliest_at FROM tenant_due
|
|
65
|
+
WHERE earliest_at IS NOT NULL AND earliest_at <= ? AND (earliest_at, tenant_id) > (?, ?)
|
|
66
|
+
ORDER BY earliest_at, tenant_id LIMIT ?`, cutoff, afterAt, afterTenant, limit + 1).toArray();
|
|
67
|
+
const page = rows.slice(0, limit);
|
|
68
|
+
const last = page.at(-1);
|
|
69
|
+
return {
|
|
70
|
+
tenants: page.map((r) => ({ tenantId: r.tenant_id, earliestAt: r.earliest_at, lagMs: query.now - r.earliest_at })),
|
|
71
|
+
next: rows.length > limit && last ? cursorOf(last.earliest_at, last.tenant_id) : null,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async lag(query) {
|
|
75
|
+
const cutoff = query.now - (query.overdueAfterMs ?? TENANT_DUE_INDEX_OVERDUE_MS);
|
|
76
|
+
const cap = Math.max(1, Math.min(query.cap ?? TENANT_DUE_INDEX_LAG_CAP, TENANT_DUE_INDEX_LAG_CAP));
|
|
77
|
+
const rows = this.ctx.storage.sql.exec(`SELECT tenant_id, earliest_at FROM tenant_due
|
|
78
|
+
WHERE earliest_at IS NOT NULL AND earliest_at <= ?
|
|
79
|
+
ORDER BY earliest_at, tenant_id LIMIT ?`, cutoff, cap + 1).toArray();
|
|
80
|
+
const oldest = rows[0];
|
|
81
|
+
return {
|
|
82
|
+
overdue: Math.min(rows.length, cap),
|
|
83
|
+
capped: rows.length > cap,
|
|
84
|
+
maxLagMs: oldest ? query.now - oldest.earliest_at : 0,
|
|
85
|
+
oldestTenantId: oldest?.tenant_id ?? null,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=tenant-due-index-do.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-due-index-do.js","sourceRoot":"","sources":["../src/tenant-due-index-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,mCAAmC;AACnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAExD,+GAA+G;AAC/G,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,GAAG,MAAM,CAAC;AAEvD,kFAAkF;AAClF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AA+C9C,MAAM,QAAQ,GAAG,CAAC,UAAkB,EAAE,QAAgB,EAAE,EAAE,CAAC,GAAG,UAAU,IAAI,QAAQ,EAAE,CAAC;AACvF,SAAS,WAAW,CAAC,KAAa;IAChC,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,UAA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AAQ,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI;aACtF,CAAC;QACJ,CAAC;QAED,KAAK,CAAC,GAAG,CAAC,KAA6D;YACrE,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,cAAc,IAAI,2BAA2B,CAAC,CAAC;YACjF,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,wBAAwB,EAAE,wBAAwB,CAAC,CAAC,CAAC;YACnG,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CACpC;;iDAEyC,EACzC,MAAM,EAAE,GAAG,GAAG,CAAC,CAChB,CAAC,OAAO,EAAE,CAAC;YACZ,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACvB,OAAO;gBACL,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC;gBACnC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,GAAG;gBACzB,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;gBACrD,cAAc,EAAE,MAAM,EAAE,SAAS,IAAI,IAAI;aAC1C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type TenantDueIndexDo } from './tenant-due-index-do.js';
|
|
2
|
+
import type { TenantDueWorkDo } from './tenant-due-work-do.js';
|
|
3
|
+
/**
|
|
4
|
+
* K-69's safety net, second half (#3540): act on the tenant due index's selection
|
|
5
|
+
* (`tenant-due-index-do.ts`, `overdue`) by asking each selected tenant's due-work object to re-check
|
|
6
|
+
* itself (`tenant-due-work-do.ts`, `recheck`). Its work is the number of tenants whose alarm failed,
|
|
7
|
+
* never the number of tenants.
|
|
8
|
+
*
|
|
9
|
+
* Bound nowhere: no deployment calls it, and no cron runs it. When it runs and how overdue a row must
|
|
10
|
+
* be before it is kicked are the owner's choices K-69 leaves open, so both are the caller's.
|
|
11
|
+
*
|
|
12
|
+
* - **Bounded.** One run reads the selection a page at a time, oldest first, and stops at `maxTenants`
|
|
13
|
+
* (`truncated`); the next run starts from the oldest again.
|
|
14
|
+
* - **Each tenant once per run.** A re-check re-notes the tenant, and a note that moves its row later
|
|
15
|
+
* while it stays overdue would put it ahead of the cursor; the run counts and skips it (`duplicates`).
|
|
16
|
+
* - **Fresh, never trusted.** The selection is a hint. The object decides from its own rows and alarm
|
|
17
|
+
* whether anything needs arming, refuses a tenant it does not hold, drops a kind its deployment no
|
|
18
|
+
* longer owns, and notes what it found, which removes a stale index row.
|
|
19
|
+
* - **One tenant's failure is its own.** A re-check that throws is counted and named; the run goes on.
|
|
20
|
+
*
|
|
21
|
+
* What it cannot see: a tenant whose note never reached the index. The object notes AFTER its alarm is
|
|
22
|
+
* armed and logs a note that fails, so such a tenant still runs from its alarm, and is invisible only if
|
|
23
|
+
* that alarm is later lost too. The `*\/15` pass's handoff check is what covers that today: each
|
|
24
|
+
* `ensure` it makes notes the tenant again. K-69 orders the other way round (the index row first, and
|
|
25
|
+
* no alarm when it fails); until one of the two holds, the handoff check is the missed-note fallback
|
|
26
|
+
* and is not retired by this.
|
|
27
|
+
*/
|
|
28
|
+
export interface TenantDueNudgeOptions {
|
|
29
|
+
/** The index whose selection is read. */
|
|
30
|
+
index: Pick<TenantDueIndexDo, 'overdue'>;
|
|
31
|
+
/** The tenant's due-work object: `ns.get(ns.idFromName(tenantDueWorkName(tenantId)))`. */
|
|
32
|
+
objectOf(tenantId: string): Pick<TenantDueWorkDo, 'recheck'>;
|
|
33
|
+
/** Epoch ms the selection is judged at. */
|
|
34
|
+
now: number;
|
|
35
|
+
/** How overdue a tenant's earliest row must be to be selected; the index's hour by default. An owner choice. */
|
|
36
|
+
overdueAfterMs?: number;
|
|
37
|
+
/** Tenants per index page; capped by the index at {@link TENANT_DUE_INDEX_PAGE}. */
|
|
38
|
+
pageLimit?: number;
|
|
39
|
+
/** The most tenants one run re-checks. Default {@link TENANT_DUE_NUDGE_MAX_TENANTS}. */
|
|
40
|
+
maxTenants?: number;
|
|
41
|
+
/** Re-checks in flight at once. Default 8. */
|
|
42
|
+
concurrency?: number;
|
|
43
|
+
onError?(err: unknown, tenantId: string): void;
|
|
44
|
+
}
|
|
45
|
+
export interface TenantDueNudgeReport {
|
|
46
|
+
/** Index pages read. */
|
|
47
|
+
pages: number;
|
|
48
|
+
/** Distinct tenants re-checked. */
|
|
49
|
+
selected: number;
|
|
50
|
+
/** Selected again later in the same run, after their own re-check moved their row: skipped. */
|
|
51
|
+
duplicates: number;
|
|
52
|
+
/** True when the run stopped at `maxTenants` with more selected. */
|
|
53
|
+
truncated: boolean;
|
|
54
|
+
armed: number;
|
|
55
|
+
onTime: number;
|
|
56
|
+
cleared: number;
|
|
57
|
+
/** Rows of an unowned kind the re-checks dropped. */
|
|
58
|
+
dropped: number;
|
|
59
|
+
failed: number;
|
|
60
|
+
/** The first few tenants whose re-check failed. */
|
|
61
|
+
failedTenantIds: string[];
|
|
62
|
+
}
|
|
63
|
+
/** The most tenants one nudge run re-checks by default. */
|
|
64
|
+
export declare const TENANT_DUE_NUDGE_MAX_TENANTS = 500;
|
|
65
|
+
export declare function runTenantDueNudge(options: TenantDueNudgeOptions): Promise<TenantDueNudgeReport>;
|
|
66
|
+
//# sourceMappingURL=tenant-due-nudge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-due-nudge.d.ts","sourceRoot":"","sources":["../src/tenant-due-nudge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,KAAK,EAAoB,eAAe,EAA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E_INDEX_PAGE } from './tenant-due-index-do.js';
|
|
2
|
+
/** The most tenants one nudge run re-checks by default. */
|
|
3
|
+
export const TENANT_DUE_NUDGE_MAX_TENANTS = 500;
|
|
4
|
+
const FAILED_IDS_REPORTED = 20;
|
|
5
|
+
export async function runTenantDueNudge(options) {
|
|
6
|
+
const maxTenants = Math.max(1, options.maxTenants ?? TENANT_DUE_NUDGE_MAX_TENANTS);
|
|
7
|
+
const concurrency = Math.max(1, options.concurrency ?? 8);
|
|
8
|
+
const report = {
|
|
9
|
+
pages: 0, selected: 0, duplicates: 0, truncated: false,
|
|
10
|
+
armed: 0, onTime: 0, cleared: 0, dropped: 0, failed: 0, failedTenantIds: [],
|
|
11
|
+
};
|
|
12
|
+
const seen = new Set();
|
|
13
|
+
const tally = (r) => {
|
|
14
|
+
report.dropped += r.dropped;
|
|
15
|
+
if (r.outcome === 'armed')
|
|
16
|
+
report.armed += 1;
|
|
17
|
+
else if (r.outcome === 'on-time')
|
|
18
|
+
report.onTime += 1;
|
|
19
|
+
else
|
|
20
|
+
report.cleared += 1;
|
|
21
|
+
};
|
|
22
|
+
const recheck = async (tenantId) => {
|
|
23
|
+
try {
|
|
24
|
+
tally(await options.objectOf(tenantId).recheck(tenantId));
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
report.failed += 1;
|
|
28
|
+
if (report.failedTenantIds.length < FAILED_IDS_REPORTED)
|
|
29
|
+
report.failedTenantIds.push(tenantId);
|
|
30
|
+
if (options.onError)
|
|
31
|
+
options.onError(err, tenantId);
|
|
32
|
+
else
|
|
33
|
+
console.error('tenant due nudge: a re-check failed; the next run asks again', { tenantId, err });
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
let after;
|
|
37
|
+
for (;;) {
|
|
38
|
+
const page = await options.index.overdue({
|
|
39
|
+
now: options.now,
|
|
40
|
+
...(options.overdueAfterMs !== undefined ? { overdueAfterMs: options.overdueAfterMs } : {}),
|
|
41
|
+
...(options.pageLimit !== undefined ? { limit: options.pageLimit } : {}),
|
|
42
|
+
...(after !== undefined ? { after } : {}),
|
|
43
|
+
});
|
|
44
|
+
report.pages += 1;
|
|
45
|
+
const fresh = [];
|
|
46
|
+
for (const { tenantId } of page.tenants) {
|
|
47
|
+
if (seen.has(tenantId)) {
|
|
48
|
+
report.duplicates += 1;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (seen.size >= maxTenants) {
|
|
52
|
+
report.truncated = true;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
seen.add(tenantId);
|
|
56
|
+
fresh.push(tenantId);
|
|
57
|
+
}
|
|
58
|
+
for (let i = 0; i < fresh.length; i += concurrency)
|
|
59
|
+
await Promise.all(fresh.slice(i, i + concurrency).map(recheck));
|
|
60
|
+
report.selected = seen.size;
|
|
61
|
+
if (report.truncated || page.next === null)
|
|
62
|
+
return report;
|
|
63
|
+
if (seen.size >= maxTenants) {
|
|
64
|
+
// The budget is spent exactly at a page's end: truncated only if the selection goes on.
|
|
65
|
+
const more = await options.index.overdue({
|
|
66
|
+
now: options.now,
|
|
67
|
+
...(options.overdueAfterMs !== undefined ? { overdueAfterMs: options.overdueAfterMs } : {}),
|
|
68
|
+
limit: TENANT_DUE_INDEX_PAGE,
|
|
69
|
+
after: page.next,
|
|
70
|
+
});
|
|
71
|
+
report.truncated = more.next !== null || more.tenants.some((t) => !seen.has(t.tenantId));
|
|
72
|
+
return report;
|
|
73
|
+
}
|
|
74
|
+
after = page.next;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=tenant-due-nudge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-due-nudge.js","sourceRoot":"","sources":["../src/tenant-due-nudge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAyB,MAAM,0BAA0B,CAAC;AAkExF,2DAA2D;AAC3D,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DurableObject } from 'cloudflare:workers';
|
|
2
|
+
import type { TenantDueIndexDo } from './tenant-due-index-do.js';
|
|
2
3
|
/**
|
|
3
4
|
* K-69 (no scheduled walk over tenants), #3650: a tenant's reaps and copy cleanup run from the alarm
|
|
4
5
|
* of one object per tenant, not from a phase of the `*\/15` pass (rfc/tenant-scale.md §7.4: "copy
|
|
@@ -66,9 +67,25 @@ export interface TenantDueCheck {
|
|
|
66
67
|
/** Held, and due more than `overdueAfterMs` ago: the alarm was lost or keeps failing; armed for now. */
|
|
67
68
|
overdue: number;
|
|
68
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* What a safety-net re-check found (`recheck`, K-69's nudge, #3540):
|
|
72
|
+
* - `armed`: rows are held and the alarm was missing or a row is overdue: armed for now;
|
|
73
|
+
* - `on-time`: rows are held and the alarm stands for them: nothing changed but the index note;
|
|
74
|
+
* - `cleared`: nothing is held (any more): the object cleared, and its index row with it.
|
|
75
|
+
*/
|
|
76
|
+
export interface TenantDueRecheck {
|
|
77
|
+
outcome: 'armed' | 'on-time' | 'cleared';
|
|
78
|
+
/** Rows held after the re-check. */
|
|
79
|
+
rows: number;
|
|
80
|
+
/** Rows of a kind this deployment no longer owns, dropped unrun as the alarm drops them. */
|
|
81
|
+
dropped: number;
|
|
82
|
+
/** The earliest row's time as noted, null when cleared. */
|
|
83
|
+
earliestAt: number | null;
|
|
84
|
+
}
|
|
69
85
|
/** The RPC surface a `defineTenantDueWorkDO` class exposes over its stub. */
|
|
70
86
|
export interface TenantDueWorkDo {
|
|
71
87
|
ensure(tenantId: string, items: readonly TenantDueItem[]): Promise<TenantDueCheck>;
|
|
88
|
+
recheck(tenantId: string): Promise<TenantDueRecheck>;
|
|
72
89
|
}
|
|
73
90
|
/** The one object per tenant: `ns.get(ns.idFromName(tenantDueWorkName(tenantId)))`. */
|
|
74
91
|
export declare function tenantDueWorkName(tenantId: string): string;
|
|
@@ -93,6 +110,15 @@ export interface TenantDueWorkConfig<Env> {
|
|
|
93
110
|
/** Default {@link tenantDueBackoffMs}. */
|
|
94
111
|
backoffMs?(attempts: number): number;
|
|
95
112
|
onError?(err: unknown, env: Env, row: TenantDueRow): void;
|
|
113
|
+
/**
|
|
114
|
+
* K-69's safety net (#3540, `tenant-due-index-do.ts`): where this object notes its earliest due row
|
|
115
|
+
* after every arm, and `null` after it clears. Absent, or answering undefined, notes nothing, which is
|
|
116
|
+
* how a deployment that binds no index runs. A note that fails is reported through `onIndexError`
|
|
117
|
+
* (or logged) and never thrown: the index is a hint, and the alarm, the rows and the pass's handoff
|
|
118
|
+
* stand without it.
|
|
119
|
+
*/
|
|
120
|
+
index?(env: Env): Pick<TenantDueIndexDo, 'note'> | undefined;
|
|
121
|
+
onIndexError?(err: unknown, env: Env, tenantId: string): void;
|
|
96
122
|
}
|
|
97
123
|
export declare function defineTenantDueWorkDO<Env>(config: TenantDueWorkConfig<Env>): new (ctx: DurableObjectState, env: Env) => DurableObject<Env> & TenantDueWorkDo & {
|
|
98
124
|
alarm(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant-due-work-do.d.ts","sourceRoot":"","sources":["../src/tenant-due-work-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"tenant-due-work-do.d.ts","sourceRoot":"","sources":["../src/tenant-due-work-do.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,UAAU,GAAG,eAAe,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;AAGxH,uDAAuD;AACvD,MAA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{
|
|
|
21
21
|
const overdueAfterMs = config.overdueAfterMs ?? TENANT_DUE_OVERDUE_MS;
|
|
22
22
|
const rowsPerAlarm = config.rowsPerAlarm ?? TENANT_DUE_ROWS_PER_ALARM;
|
|
23
23
|
const backoffMs = config.backoffMs ?? tenantDueBackoffMs;
|
|
24
|
+
/** Ties within one millisecond of one object: notes it sends in one turn keep their order. */
|
|
25
|
+
let seq = 0;
|
|
24
26
|
return class TenantDueWorkDO extends DurableObject {
|
|
25
27
|
/**
|
|
26
28
|
* The pass's check: hold a row for each item, and arm the alarm for the earliest. Never runs a
|
|
27
29
|
* row itself, so the pass is never held by a tenant's reap.
|
|
28
30
|
*/
|
|
29
31
|
async ensure(tenantId, items) {
|
|
30
|
-
|
|
32
|
+
let armed;
|
|
33
|
+
const check = await this.ctx.blockConcurrencyWhile(async () => {
|
|
31
34
|
const stored = await this.ctx.storage.get(TENANT_KEY);
|
|
32
35
|
if (stored !== undefined && stored !== tenantId) {
|
|
33
36
|
throw new Error(`this object holds the due work of tenant ${stored}, not ${tenantId}`);
|
|
@@ -60,9 +63,49 @@ export function defineTenantDueWorkDO(config) {
|
|
|
60
63
|
else
|
|
61
64
|
check.held += 1;
|
|
62
65
|
}
|
|
63
|
-
await this.#arm(now, check.overdue > 0);
|
|
66
|
+
armed = await this.#arm(now, check.overdue > 0);
|
|
64
67
|
return check;
|
|
65
68
|
});
|
|
69
|
+
if (armed)
|
|
70
|
+
await this.#note(tenantId, armed);
|
|
71
|
+
return check;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* K-69's safety net (#3540): the nudge for a tenant the index selected as overdue. The index is a
|
|
75
|
+
* hint, so this judges the object's own state afresh, never the selection's: it refuses an object
|
|
76
|
+
* holding another tenant's work, drops rows of a kind the deployment no longer owns (as the alarm
|
|
77
|
+
* would), re-arms only when the alarm is missing or a row is overdue (the handoff check's own
|
|
78
|
+
* rule), and notes what it found, so an index row that was ahead of or behind the object, or
|
|
79
|
+
* stood for an object that holds nothing, is put right. It runs no row: the alarm does.
|
|
80
|
+
*/
|
|
81
|
+
async recheck(tenantId) {
|
|
82
|
+
// Refused before the block: a throw inside it would reset this object, which belongs to another
|
|
83
|
+
// tenant and may be mid-alarm. An object's tenant never changes to another, only to none.
|
|
84
|
+
const stored = await this.ctx.storage.get(TENANT_KEY);
|
|
85
|
+
if (stored !== undefined && stored !== tenantId) {
|
|
86
|
+
throw new Error(`this object holds the due work of tenant ${stored}, not ${tenantId}`);
|
|
87
|
+
}
|
|
88
|
+
const result = await this.ctx.blockConcurrencyWhile(async () => {
|
|
89
|
+
const now = Date.now();
|
|
90
|
+
let dropped = 0;
|
|
91
|
+
let overdue = false;
|
|
92
|
+
for (const row of await this.#rows()) {
|
|
93
|
+
if (!config.owned(this.env, row.kind)) {
|
|
94
|
+
await this.ctx.storage.delete(rowKey(row.kind, row.unit));
|
|
95
|
+
dropped += 1;
|
|
96
|
+
}
|
|
97
|
+
else if (row.nextAt < now - overdueAfterMs) {
|
|
98
|
+
overdue = true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const lost = (await this.ctx.storage.getAlarm()) === null;
|
|
102
|
+
const armed = await this.#arm(now, overdue || lost);
|
|
103
|
+
const rows = (await this.#rows()).length;
|
|
104
|
+
const outcome = armed.earliestAt === null ? 'cleared' : overdue || lost ? 'armed' : 'on-time';
|
|
105
|
+
return { armed, recheck: { outcome, rows, dropped, earliestAt: armed.earliestAt } };
|
|
106
|
+
});
|
|
107
|
+
await this.#note(tenantId, result.armed);
|
|
108
|
+
return result.recheck;
|
|
66
109
|
}
|
|
67
110
|
async alarm() {
|
|
68
111
|
const tenantId = await this.ctx.storage.get(TENANT_KEY);
|
|
@@ -115,7 +158,24 @@ export function defineTenantDueWorkDO(config) {
|
|
|
115
158
|
}
|
|
116
159
|
});
|
|
117
160
|
}
|
|
118
|
-
await this.ctx.blockConcurrencyWhile(() => this.#arm(Date.now(), true));
|
|
161
|
+
const armed = await this.ctx.blockConcurrencyWhile(() => this.#arm(Date.now(), true));
|
|
162
|
+
await this.#note(tenantId, armed);
|
|
163
|
+
}
|
|
164
|
+
/** Note what an arm left in the index, after the arm's block, so the RPC never holds this object. */
|
|
165
|
+
async #note(tenantId, armed) {
|
|
166
|
+
const index = config.index?.(this.env);
|
|
167
|
+
if (!index)
|
|
168
|
+
return;
|
|
169
|
+
seq = (seq + 1) % 1_000;
|
|
170
|
+
try {
|
|
171
|
+
await index.note(tenantId, Date.now() * 1_000 + seq, armed.earliestAt);
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
if (config.onIndexError)
|
|
175
|
+
config.onIndexError(err, this.env, tenantId);
|
|
176
|
+
else
|
|
177
|
+
console.error('tenant due work: the index note failed; the alarm and the pass still hold the work', { tenantId, err });
|
|
178
|
+
}
|
|
119
179
|
}
|
|
120
180
|
async #armRecovery(now) {
|
|
121
181
|
await this.ctx.blockConcurrencyWhile(async () => {
|
|
@@ -133,12 +193,16 @@ export function defineTenantDueWorkDO(config) {
|
|
|
133
193
|
const rows = await this.#rows();
|
|
134
194
|
if (rows.length === 0) {
|
|
135
195
|
await this.#clear();
|
|
136
|
-
return;
|
|
196
|
+
return { earliestAt: null };
|
|
137
197
|
}
|
|
138
|
-
|
|
198
|
+
// The index is told when the earliest row is due, not when the alarm fires: a row overdue by an
|
|
199
|
+
// hour is overdue whatever the alarm says.
|
|
200
|
+
const due = Math.min(...rows.map((r) => r.nextAt));
|
|
201
|
+
const earliest = Math.max(due, now + MIN_GAP_MS);
|
|
139
202
|
const current = await this.ctx.storage.getAlarm();
|
|
140
203
|
if (current === null || current > earliest || reset)
|
|
141
204
|
await this.ctx.storage.setAlarm(earliest);
|
|
205
|
+
return { earliestAt: due };
|
|
142
206
|
}
|
|
143
207
|
async #clear() {
|
|
144
208
|
await this.ctx.storage.deleteAlarm();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant-due-work-do.js","sourceRoot":"","sources":["../src/tenant-due-work-do.ts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AAM,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/adapter-cloudflare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.230.0",
|
|
4
4
|
"description": "Cloudflare Durable-Object scope host (D-14): DO-per-scope, real kernel semantics on Workers",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@substrat-run/contracts": "^0.
|
|
38
|
-
"@substrat-run/
|
|
39
|
-
"@substrat-run/
|
|
37
|
+
"@substrat-run/contracts": "^0.226.0",
|
|
38
|
+
"@substrat-run/kernel": "^0.230.0",
|
|
39
|
+
"@substrat-run/model-view": "^0.8.7"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@cloudflare/vitest-plugin": "^1.9.0",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"typescript": "^7.0.0",
|
|
46
46
|
"vitest": "5.0.5",
|
|
47
47
|
"wrangler": "^4.166.0",
|
|
48
|
-
"@substrat-run/
|
|
49
|
-
"@substrat-run/
|
|
50
|
-
"@substrat-run/
|
|
51
|
-
"@substrat-run/
|
|
52
|
-
"@substrat-run/vertical-auth": "^0.41.
|
|
53
|
-
"@substrat-run/vertical-host": "^0.
|
|
48
|
+
"@substrat-run/attachment-extractors": "^0.2.91",
|
|
49
|
+
"@substrat-run/cli": "^0.71.0",
|
|
50
|
+
"@substrat-run/contract-tests": "^0.230.0",
|
|
51
|
+
"@substrat-run/control-plane-api": "^0.230.0",
|
|
52
|
+
"@substrat-run/vertical-auth": "^0.41.3",
|
|
53
|
+
"@substrat-run/vertical-host": "^0.230.0"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsc -p tsconfig.json",
|
|
60
60
|
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
61
|
-
"test": "vitest run && vitest run -c vitest.supplied-sweeper.config.ts",
|
|
61
|
+
"test": "vitest run && vitest run -c vitest.supplied-sweeper.config.ts && vitest run -c vitest.scope-facets.config.ts",
|
|
62
62
|
"test:contract-hosts": "vitest run test/contract-hosts.test.ts",
|
|
63
63
|
"test:contract-switch": "vitest run test/contract-switch.test.ts",
|
|
64
64
|
"test:contract-data": "vitest run test/contract-data.test.ts",
|
|
65
65
|
"test:rest-1": "vitest run --exclude test/contract-hosts.test.ts --exclude test/contract-switch.test.ts --exclude test/contract-data.test.ts --shard=1/2",
|
|
66
|
-
"test:rest-2": "vitest run --exclude test/contract-hosts.test.ts --exclude test/contract-switch.test.ts --exclude test/contract-data.test.ts --shard=2/2 && vitest run -c vitest.supplied-sweeper.config.ts"
|
|
66
|
+
"test:rest-2": "vitest run --exclude test/contract-hosts.test.ts --exclude test/contract-switch.test.ts --exclude test/contract-data.test.ts --shard=2/2 && vitest run -c vitest.supplied-sweeper.config.ts && vitest run -c vitest.scope-facets.config.ts"
|
|
67
67
|
}
|
|
68
68
|
}
|