@substrat-run/kernel 0.204.0 → 0.206.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 (48) hide show
  1. package/dist/connection-landings.d.ts +52 -2
  2. package/dist/connection-landings.d.ts.map +1 -1
  3. package/dist/connection-landings.js +72 -6
  4. package/dist/connection-landings.js.map +1 -1
  5. package/dist/cost-rollup.d.ts +186 -0
  6. package/dist/cost-rollup.d.ts.map +1 -0
  7. package/dist/cost-rollup.js +475 -0
  8. package/dist/cost-rollup.js.map +1 -0
  9. package/dist/index.d.ts +9 -4
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +8 -2
  12. package/dist/index.js.map +1 -1
  13. package/dist/markup-schedule.d.ts +51 -0
  14. package/dist/markup-schedule.d.ts.map +1 -0
  15. package/dist/markup-schedule.js +70 -0
  16. package/dist/markup-schedule.js.map +1 -0
  17. package/dist/model-usage.d.ts +8 -1
  18. package/dist/model-usage.d.ts.map +1 -1
  19. package/dist/model-usage.js +38 -19
  20. package/dist/model-usage.js.map +1 -1
  21. package/dist/module-erasure.d.ts +17 -0
  22. package/dist/module-erasure.d.ts.map +1 -1
  23. package/dist/module-erasure.js +18 -3
  24. package/dist/module-erasure.js.map +1 -1
  25. package/dist/platform-sweep.d.ts +86 -5
  26. package/dist/platform-sweep.d.ts.map +1 -1
  27. package/dist/platform-sweep.js +180 -19
  28. package/dist/platform-sweep.js.map +1 -1
  29. package/dist/scope-host.d.ts +82 -4
  30. package/dist/scope-host.d.ts.map +1 -1
  31. package/dist/scope-host.js.map +1 -1
  32. package/dist/scope-work-bindings.d.ts +19 -0
  33. package/dist/scope-work-bindings.d.ts.map +1 -0
  34. package/dist/scope-work-bindings.js +17 -0
  35. package/dist/scope-work-bindings.js.map +1 -0
  36. package/dist/snapshot-retention.d.ts +19 -0
  37. package/dist/snapshot-retention.d.ts.map +1 -0
  38. package/dist/snapshot-retention.js +21 -0
  39. package/dist/snapshot-retention.js.map +1 -0
  40. package/dist/subject-access.d.ts +38 -0
  41. package/dist/subject-access.d.ts.map +1 -0
  42. package/dist/subject-access.js +123 -0
  43. package/dist/subject-access.js.map +1 -0
  44. package/dist/timeline.d.ts +12 -0
  45. package/dist/timeline.d.ts.map +1 -1
  46. package/dist/timeline.js +19 -0
  47. package/dist/timeline.js.map +1 -1
  48. package/package.json +2 -2
@@ -25,6 +25,11 @@ import type { ScopeFilter, ScopeHost } from './scope-host.js';
25
25
  * A landing declared `bind: 'on-request'` (#2732) is passed over: its connections are granted and
26
26
  * bound one scope at a time, when that scope asks, so the pass writes nothing for them.
27
27
  *
28
+ * A provider whose binder is `exclusive` (#3221, a payment provider) lands each scope through ONE
29
+ * connection: the one already bound there, else the oldest active one. The others are passed over
30
+ * for that scope, so a second connected account binds nowhere until a tenant chooses it for an
31
+ * install, and a choice the tenant made is never undone by a later pass.
32
+ *
28
33
  * Nothing is unbound. A version that stops declaring a landing (or makes it `on-request`) leaves its
29
34
  * bindings in place, and a pass that lands through an operation the version no longer has reports
30
35
  * the refusal on the connection's sweep row; `unbind` stays a person's act. A revoked connection is never reached:
@@ -88,6 +93,18 @@ export interface ConnectionBinder {
88
93
  * landed stays. Absent means the provider cannot unbind, and the relay refuses an unbind of it.
89
94
  */
90
95
  unbind?(host: ScopeHost, connection: Connection, scopeId: ScopeId): Promise<void>;
96
+ /**
97
+ * #3221: a scope lands through at most ONE connection of this provider, so the pass never adds a
98
+ * second. A payment provider is the case: a checkout goes through the one connection bound to the
99
+ * scope, and two bound is refused, since which account takes the money is never guessed. Under it
100
+ * the pass binds a scope only to the connection already bound there (re-writing it as usual) or,
101
+ * when none of the provider's tenant connections is, to the OLDEST active one. Every other
102
+ * connection of the provider is passed over for that scope, key and binding both. Which one an
103
+ * install uses is then the binding itself: the tenant moves it (`chooseScopeConnection`), and the
104
+ * pass, finding the scope bound, keeps it. Disconnecting the bound one leaves the scope unbound, and
105
+ * the next pass binds the oldest active one left. Absent, every live connection binds everywhere.
106
+ */
107
+ readonly exclusive?: true;
91
108
  }
92
109
  export interface ConnectionLandingOptionsInput {
93
110
  /** The version's declared landings, read off its stored manifest (`connectionLandingsOfManifestJson`). */
@@ -103,10 +120,25 @@ export interface ConnectionLandingOptionsInput {
103
120
  }
104
121
  /** The binder a connection is bound through: the record's entry, else `binderFor`'s. */
105
122
  export declare function binderOf(input: Pick<ConnectionLandingOptionsInput, 'binders' | 'binderFor'>, connection: Connection): ConnectionBinder | undefined;
123
+ /** One landing a version declares for a provider, as the pass and the doors read it. */
124
+ export interface DeclaredLanding {
125
+ operation: string;
126
+ permission: PermissionKey;
127
+ options?: ConnectionLandingOptions;
128
+ bind?: 'every-install' | 'on-request';
129
+ }
130
+ /**
131
+ * The landing `scope`'s RUNNING version declares for `provider`, or why there is none: read as the
132
+ * landing pass reads a version, so a door is held to the declaration the pass would apply there.
133
+ */
134
+ export declare function declaredLandingFor(admin: Pick<ScopeHost['admin'], 'listVerticals'>, actor: PlatformActorId, read: ConnectionLandingOptionsInput['read'], scope: Scope, provider: string): Promise<{
135
+ landing: DeclaredLanding;
136
+ } | {
137
+ refused: string;
138
+ }>;
106
139
  /**
107
140
  * The `on-request` landing `scope`'s RUNNING version declares for `provider` (#2732), the one a
108
- * scope binds its own connection through, or why there is none: read as the landing pass reads a
109
- * version, so a scope is held to the declaration the pass would apply there.
141
+ * scope binds its own connection through, or why there is none.
110
142
  */
111
143
  export declare function onRequestLandingFor(admin: Pick<ScopeHost['admin'], 'listVerticals'>, actor: PlatformActorId, read: ConnectionLandingOptionsInput['read'], scope: Scope, provider: string): Promise<{
112
144
  landing: {
@@ -117,6 +149,21 @@ export declare function onRequestLandingFor(admin: Pick<ScopeHost['admin'], 'lis
117
149
  } | {
118
150
  refused: string;
119
151
  }>;
152
+ /**
153
+ * For an {@link ConnectionBinder.exclusive} provider, the connections of one (tenant, vertical) a
154
+ * scope may land through: each scope's bound ones, and the one an unbound scope is given (the oldest
155
+ * active tenant connection, or none). Only the tenant's connections count: a scope's own is never
156
+ * landed by the pass, and its checkout reads it beside these.
157
+ */
158
+ export interface ExclusiveLandings {
159
+ bound: ReadonlyMap<string, ReadonlySet<string>>;
160
+ first: Connection['id'] | null;
161
+ }
162
+ export declare function exclusiveLandingsOf(host: ScopeHost, actor: PlatformActorId, input: Pick<ConnectionLandingOptionsInput, 'binders' | 'binderFor'>, of: {
163
+ tenantId: TenantId;
164
+ vertical: string;
165
+ provider: string;
166
+ }): Promise<ExclusiveLandings>;
120
167
  /** What one connection's landing step did, folded into its sweep row and the pass report. */
121
168
  export interface LandingOutcome {
122
169
  /** Scopes whose key this step granted. */
@@ -147,6 +194,7 @@ export declare class LandingPass {
147
194
  private readonly listScopes;
148
195
  private readonly targets;
149
196
  private readonly held;
197
+ private readonly exclusive;
150
198
  constructor(host: ScopeHost, actor: PlatformActorId, input: ConnectionLandingOptionsInput, concurrency: number,
151
199
  /**
152
200
  * How the pass reads a tenant's scopes: the sweep's own reader, so a directory row that does
@@ -158,6 +206,8 @@ export declare class LandingPass {
158
206
  apply(connection: Connection): Promise<LandingOutcome>;
159
207
  /** Every primary, active install of `vertical` in `tenantId`, with what its running version declares. */
160
208
  private targetsOf;
209
+ /** {@link exclusiveLandingsOf} for `connection`'s provider, read once per pass. */
210
+ private exclusiveOf;
161
211
  /** The keys connections hold on one scope, as its enforced tuples say. */
162
212
  private grantsIn;
163
213
  }
@@ -1 +1 @@
1
- {"version":3,"file":"connection-landings.d.ts","sourceRoot":"","sources":["../src/connection-landings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,aAAa,EACb,eAAe,EAEf,KAAK,EACL,OAAO,EACP,QAAQ,EACT,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAM9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;;;GAGG;AACH,MAAM,WAA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AC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC9C;AASD;;;;GAIG;AACH,qBAAa,WAAW;IAMpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU;IAd7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwC;IAChE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA0D;IAC/E,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiD;IAE3E,YACmB,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,6BAA6B,EACpC,WAAW,EAAE,MAAM;IACpC;;;;OAIG;IACc,UAAU,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,EACpE;IAEJ,mGAAmG;IAC7F,KAAK,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CA2F3D;IAED,yGAAyG;IACzG,OAAO,CAAC,SAAS;IAwBjB,mFAAmF;IACnF,OAAO,CAAC,WAAW;IAUnB,0EAA0E;IAC1E,OAAO,CAAC,QAAQ;CASjB"}
@@ -7,11 +7,10 @@ export function binderOf(input, connection) {
7
7
  return input.binders[connection.provider] ?? input.binderFor?.(connection);
8
8
  }
9
9
  /**
10
- * The `on-request` landing `scope`'s RUNNING version declares for `provider` (#2732), the one a
11
- * scope binds its own connection through, or why there is none: read as the landing pass reads a
12
- * version, so a scope is held to the declaration the pass would apply there.
10
+ * The landing `scope`'s RUNNING version declares for `provider`, or why there is none: read as the
11
+ * landing pass reads a version, so a door is held to the declaration the pass would apply there.
13
12
  */
14
- export async function onRequestLandingFor(admin, actor, read, scope, provider) {
13
+ export async function declaredLandingFor(admin, actor, read, scope, provider) {
15
14
  const [running] = await runningFactsOf(admin, actor, [scope], read, (reason) => ({ kind: 'unreadable', reason }), 1);
16
15
  const fact = running?.fact;
17
16
  if (!fact || fact.kind === 'none')
@@ -21,10 +20,47 @@ export async function onRequestLandingFor(admin, actor, read, scope, provider) {
21
20
  const landing = fact.rows.find((r) => r.provider === provider);
22
21
  if (!landing)
23
22
  return { refused: `the version scope ${scope.id} runs declares no landing for '${provider}'` };
24
- if (landing.bind !== 'on-request') {
23
+ return {
24
+ landing: {
25
+ operation: landing.operation,
26
+ permission: landing.permission,
27
+ ...(landing.options ? { options: landing.options } : {}),
28
+ ...(landing.bind ? { bind: landing.bind } : {}),
29
+ },
30
+ };
31
+ }
32
+ /**
33
+ * The `on-request` landing `scope`'s RUNNING version declares for `provider` (#2732), the one a
34
+ * scope binds its own connection through, or why there is none.
35
+ */
36
+ export async function onRequestLandingFor(admin, actor, read, scope, provider) {
37
+ const declared = await declaredLandingFor(admin, actor, read, scope, provider);
38
+ if ('refused' in declared)
39
+ return declared;
40
+ const { bind, ...landing } = declared.landing;
41
+ if (bind !== 'on-request') {
25
42
  return { refused: `the '${provider}' landing is bound to every install by the platform; only an on-request landing is bound by a scope` };
26
43
  }
27
- return { landing: { operation: landing.operation, permission: landing.permission, ...(landing.options ? { options: landing.options } : {}) } };
44
+ return { landing };
45
+ }
46
+ export async function exclusiveLandingsOf(host, actor, input, of) {
47
+ const rows = (await host.admin.listConnections(actor, { tenantId: of.tenantId, vertical: of.vertical, provider: of.provider, ownerScopeId: null })).filter((c) => c.revokedAt === null && c.ownerScopeId === null);
48
+ const bound = new Map();
49
+ for (const c of rows) {
50
+ const binder = binderOf(input, c);
51
+ if (!binder)
52
+ continue;
53
+ for (const b of await binder.list(host, c)) {
54
+ let set = bound.get(b.scopeId);
55
+ if (!set)
56
+ bound.set(b.scopeId, (set = new Set()));
57
+ set.add(c.id);
58
+ }
59
+ }
60
+ const active = rows
61
+ .filter((c) => c.status === 'active')
62
+ .sort((a, b) => (a.createdAt < b.createdAt ? -1 : a.createdAt > b.createdAt ? 1 : a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
63
+ return { bound, first: active[0]?.id ?? null };
28
64
  }
29
65
  /**
30
66
  * The per-pass memory of the landing step: which installs each (tenant, vertical) has and what
@@ -39,6 +75,7 @@ export class LandingPass {
39
75
  listScopes;
40
76
  targets = new Map();
41
77
  held = new Map();
78
+ exclusive = new Map();
42
79
  constructor(host, actor, input, concurrency,
43
80
  /**
44
81
  * How the pass reads a tenant's scopes: the sweep's own reader, so a directory row that does
@@ -62,6 +99,9 @@ export class LandingPass {
62
99
  if (!binder)
63
100
  return out;
64
101
  const targets = await this.targetsOf(connection.tenantId, connection.vertical);
102
+ // #3221: read once per (tenant, vertical, provider) per pass. A bind this pass makes is not seen
103
+ // by it, and need not be: an unbound scope is only ever given the one oldest active connection.
104
+ const exclusive = binder.exclusive && targets.length > 0 ? await this.exclusiveOf(connection) : undefined;
65
105
  let existing;
66
106
  for (const t of targets) {
67
107
  const scopeId = t.scope.id;
@@ -75,6 +115,12 @@ export class LandingPass {
75
115
  // #2732: an `on-request` landing is bound by the scope that asks, never by this pass.
76
116
  if (!landing || landing.bind === 'on-request')
77
117
  continue;
118
+ if (exclusive) {
119
+ const holders = exclusive.bound.get(scopeId);
120
+ // Bound elsewhere: that is the install's choice, and this connection is passed over there.
121
+ if (holders && holders.size > 0 ? !holders.has(connection.id) : exclusive.first !== connection.id)
122
+ continue;
123
+ }
78
124
  try {
79
125
  existing ??= await binder.list(this.host, connection);
80
126
  const current = existing.find((b) => b.scopeId === scopeId);
@@ -82,6 +128,16 @@ export class LandingPass {
82
128
  // Providers may refuse a kind change even when the declaration omits its default kind.
83
129
  const bindingOptions = binder.options ? binder.options(landing.options, current) : {};
84
130
  const needsBind = !current || !sameLanding(current, landing.operation, landing.permission, bindingOptions) || !!binder.stale?.(current, connection);
131
+ // #3221: the pass's snapshot may predate a tenant's choice. Before an exclusive provider binds,
132
+ // its bindings are read again: if the install is now held by another connection, or this one's
133
+ // binding was taken off since the snapshot, the choice stands and this connection is passed over.
134
+ if (exclusive && needsBind) {
135
+ const now = await exclusiveLandingsOf(this.host, this.actor, this.input, connection);
136
+ const holders = now.bound.get(scopeId);
137
+ const mine = exclusive.bound.get(scopeId)?.has(connection.id) === true;
138
+ if (holders && holders.size > 0 ? !holders.has(connection.id) : mine || now.first !== connection.id)
139
+ continue;
140
+ }
85
141
  const operationId = ulid();
86
142
  const audit = {
87
143
  tenantId: connection.tenantId,
@@ -149,6 +205,16 @@ export class LandingPass {
149
205
  }
150
206
  return found;
151
207
  }
208
+ /** {@link exclusiveLandingsOf} for `connection`'s provider, read once per pass. */
209
+ exclusiveOf(connection) {
210
+ const key = `${connection.tenantId}\u0000${connection.vertical}\u0000${connection.provider}`;
211
+ let found = this.exclusive.get(key);
212
+ if (!found) {
213
+ found = exclusiveLandingsOf(this.host, this.actor, this.input, connection);
214
+ this.exclusive.set(key, found);
215
+ }
216
+ return found;
217
+ }
152
218
  /** The keys connections hold on one scope, as its enforced tuples say. */
153
219
  grantsIn(tenantId, scopeId) {
154
220
  const key = `${tenantId}\u0000${scopeId}`;
@@ -1 +1 @@
1
- {"version":3,"file":"connection-landings.js","sourceRoot":"","sources":["../src/connection-landings.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA6FjC,wFAAwF;AACxF,MAAM,UAAU,QAAQ,CAAC,KAAmE,EAAE,UAAsB;IAClH,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,CAAC;AAC7E,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,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K,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,+FAA+F;AAC/F,SAAS,WAAW,CAClB,OAAkD,EAClD,SAAiB,EACjB,UAAkB,EAClB,OAAgC;IAEhC,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI,OAAO,CAAC,UAAU,KAAK,UAAU;QAAE,OAAO,KAAK,CAAC;IACvF,MAAM,IAAI,GAAG,OAA4C,CAAC;IAC1D,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;AAClH,CAAC"}
@@ -0,0 +1,186 @@
1
+ import { type CloudflareUsageDay, type CostAttribution, type CostDay, type RequestRollupDay, type ScopeId, type TenantId } from '@substrat-run/contracts';
2
+ import type { RedactionSql } from './subject-redaction.js';
3
+ /**
4
+ * The daily Cloudflare cost rollup (#3316, #3311), as statements both adapters run against their
5
+ * directory, beside the request rollup (`request-rollup.ts`).
6
+ *
7
+ * Cloudflare's GraphQL Analytics answer for 90 days. This keeps one row per (UTC day, script,
8
+ * scope, Durable Object class, billed dimension), so the history outlives them. The rows are COST
9
+ * INPUTS ONLY: quantities in the analytics' own units, never a price. A markup schedule prices them
10
+ * at read.
11
+ *
12
+ * Attribution happens HERE, in the transaction that records the day, through the directory and
13
+ * never through a script name's prefix: a Durable Object maps to a scope by the object id recorded
14
+ * for it (`_substrat_scope_objects`), and a script to its vertical, version and owner by the
15
+ * `verticals`, `vertical_versions` and `_substrat_vertical_owners` rows. The scheduled pass and the
16
+ * backfill loader hand the same raw day (`CloudflareUsageDay`) to the same code, so a loaded day
17
+ * and a read day cannot be attributed by different rules.
18
+ *
19
+ * `_substrat_cost_day_reads` is the request rollup's day ledger, for the same reason: a day without
20
+ * a successful read has no rows to say anything with. Empty strings stand for "none" in the key
21
+ * columns (`scope_id`, `object_class`, `object_id`), which a primary key cannot hold as NULL.
22
+ *
23
+ * Every per-object row keeps its object id, so a day read before its scopes' ids were recorded
24
+ * (a pass that ran before a vertical could answer, a loaded snapshot) is attributed when they are:
25
+ * recording an id re-attributes that object's `unmapped` and `unknown` rows in the same transaction.
26
+ *
27
+ * `_substrat_scope_objects` is the directory's record of each scope's Durable Object id: the hex id
28
+ * Cloudflare reports, which is `SCOPE.idFromName(scopeId)` inside the script that holds the scope's
29
+ * data and cannot be computed anywhere else. It keeps the scope's tenant, vertical and kind beside
30
+ * the id, so an object stays attributable after its scope is reaped. `_substrat_scope_object_reads`
31
+ * holds the last failed attempt per (scope, script), so a deployment that predates the read is
32
+ * asked again a day later, not every pass.
33
+ */
34
+ export declare const COST_ROLLUP_DDL = "\n CREATE TABLE IF NOT EXISTS _substrat_cost_days (\n day TEXT NOT NULL,\n script TEXT NOT NULL,\n scope_id TEXT NOT NULL,\n object_class TEXT NOT NULL,\n object_id TEXT NOT NULL,\n dimension TEXT NOT NULL,\n attribution TEXT NOT NULL,\n tenant_id TEXT,\n vertical TEXT,\n kind TEXT NOT NULL,\n version_id TEXT,\n preview_tag TEXT,\n quantity TEXT NOT NULL,\n lower TEXT,\n upper TEXT,\n PRIMARY KEY (day, script, scope_id, object_class, object_id, dimension)\n );\n CREATE INDEX IF NOT EXISTS _substrat_cost_days_tenant ON _substrat_cost_days (tenant_id, day);\n CREATE INDEX IF NOT EXISTS _substrat_cost_days_object ON _substrat_cost_days (object_id, attribution);\n CREATE TABLE IF NOT EXISTS _substrat_cost_day_reads (\n day TEXT PRIMARY KEY,\n attempted_at TEXT NOT NULL,\n read_at TEXT,\n row_count INTEGER,\n error TEXT,\n failing_since TEXT,\n failing_count INTEGER\n );\n CREATE TABLE IF NOT EXISTS _substrat_scope_objects (\n object_id TEXT PRIMARY KEY,\n scope_id TEXT NOT NULL,\n tenant_id TEXT NOT NULL,\n script TEXT NOT NULL,\n vertical TEXT NOT NULL,\n kind TEXT NOT NULL,\n version_id TEXT,\n preview_tag TEXT,\n recorded_at TEXT NOT NULL\n );\n CREATE INDEX IF NOT EXISTS _substrat_scope_objects_scope ON _substrat_scope_objects (scope_id, script);\n CREATE TABLE IF NOT EXISTS _substrat_scope_object_reads (\n scope_id TEXT NOT NULL,\n script TEXT NOT NULL,\n attempted_at TEXT NOT NULL,\n error TEXT NOT NULL,\n PRIMARY KEY (scope_id, script)\n );\n";
35
+ /**
36
+ * How many days back the cost rollup reaches. Cloudflare answers for 90 days ("cannot request data
37
+ * older than 12w6d"); this stays inside them with a margin, so no day is read while it ages out.
38
+ */
39
+ export declare const COST_ROLLUP_LOOKBACK_DAYS = 85;
40
+ /** The furthest back a lookback may be set: inside the 90 days with a day's margin for the first day's start. */
41
+ export declare const COST_ROLLUP_MAX_LOOKBACK_DAYS = 88;
42
+ /**
43
+ * How long after a day ends it may be read. The periodic Durable Object dataset is an aggregate
44
+ * Cloudflare writes after the fact, so this waits longer than the request rollup does: the first
45
+ * pass after 03:00 UTC takes the day before.
46
+ */
47
+ export declare const COST_ROLLUP_SETTLE_MS: number;
48
+ /** How long a day whose read failed waits before it is tried again. */
49
+ export declare const COST_ROLLUP_RETRY_MS = 3600000;
50
+ /** How long one day's read (several GraphQL pages and the namespace list) may take. */
51
+ export declare const COST_ROLLUP_READ_TIMEOUT_MS = 60000;
52
+ /** The most days one pass reads. A first pass catches up over several. */
53
+ export declare const COST_ROLLUP_DAYS_PER_PASS = 3;
54
+ /** How many rows one `pruneCostDays` call deletes, by default. */
55
+ export declare const COST_ROLLUP_PRUNE_BATCH = 500;
56
+ /** The most rows one `listCostDays` call returns, and its default. */
57
+ export declare const COST_ROLLUP_LIMIT_MAX = 10000;
58
+ export declare const COST_ROLLUP_LIMIT_DEFAULT = 1000;
59
+ /** How many scopes one pass asks for their object id. Asking wakes no object: it is `idFromName`. */
60
+ export declare const SCOPE_OBJECTS_PER_PASS = 100;
61
+ /** How long a scope whose object id could not be read waits before it is asked again. */
62
+ export declare const SCOPE_OBJECT_RETRY_MS = 86400000;
63
+ /** One attempt to roll up a day: the raw usage the analytics answered, or why the read failed. */
64
+ export type CostDayReadInput = {
65
+ day: string;
66
+ attemptedAt: string;
67
+ usage: CloudflareUsageDay;
68
+ } | {
69
+ day: string;
70
+ attemptedAt: string;
71
+ error: string;
72
+ failingSince?: string;
73
+ failingCount?: number;
74
+ };
75
+ /** Filter for `listCostDays`: inclusive UTC days, at most `limit` rows, in key order. */
76
+ export interface CostDayFilter {
77
+ tenantId?: TenantId;
78
+ scopeId?: ScopeId;
79
+ vertical?: string;
80
+ attribution?: CostAttribution;
81
+ since?: string;
82
+ until?: string;
83
+ limit?: number;
84
+ }
85
+ /** Filter for `listCostRollupDays`: inclusive UTC days. */
86
+ export interface CostRollupDayFilter {
87
+ since?: string;
88
+ until?: string;
89
+ }
90
+ /** A scope's recorded Durable Object, as attribution reads it. */
91
+ export interface ScopeObjectRecord {
92
+ scopeId: string;
93
+ tenantId: string;
94
+ script: string;
95
+ vertical: string;
96
+ kind: 'live' | 'preview';
97
+ versionId: string | null;
98
+ previewTag: string | null;
99
+ }
100
+ /** What the directory knows that attribution needs, for one day. Built by `readCostDirectory`. */
101
+ export interface CostDirectory {
102
+ /** Object id → the scope it was recorded for. */
103
+ objects: ReadonlyMap<string, ScopeObjectRecord>;
104
+ /** A stable script name (its stem, its serving ref, a jurisdiction script) → the vertical's slug. */
105
+ slugByScript: ReadonlyMap<string, string>;
106
+ /** A per-version script name → the version. */
107
+ versionByScript: ReadonlyMap<string, {
108
+ slug: string;
109
+ versionId: string;
110
+ }>;
111
+ /** A version id → its vertical, for a per-version script whose deployment ref was never stored. */
112
+ versionById: ReadonlyMap<string, {
113
+ slug: string;
114
+ versionId: string;
115
+ }>;
116
+ /** Who owned each slug on the day; null for a platform-owned vertical. */
117
+ ownerBySlug: ReadonlyMap<string, string | null>;
118
+ /** The scripts that hold some non-preview scope's data: a per-version script among them is live. */
119
+ liveScripts: ReadonlySet<string>;
120
+ }
121
+ /**
122
+ * Attribute one day of raw usage through the directory (#3316). Pure: the rows it returns are what
123
+ * `recordCostDayRows` writes. Rows that land on one key are summed, their intervals too. A figure
124
+ * of zero writes no row: a read day with no row for a dimension had none of it.
125
+ */
126
+ export declare function attributeCostDay(usage: CloudflareUsageDay, dir: CostDirectory): CostDay[];
127
+ /**
128
+ * The directory as attribution reads it for `day`: every recorded object, every vertical and
129
+ * version, who owned each slug that day, and which scripts hold live scopes' data. Whole tables,
130
+ * never an `IN` list, so no statement nears a Durable Object's parameter limit.
131
+ */
132
+ export declare function readCostDirectory(sql: RedactionSql, day: string): CostDirectory;
133
+ /**
134
+ * Record one attempt. A successful read is attributed through the directory, replaces the day's
135
+ * rows in the caller's transaction, and marks the day read. A failed one records only the attempt:
136
+ * the day's rows and its last successful read stay as they were. The raw day is parsed, and every
137
+ * row it attributes to, before anything is written. Returns how many rows were written.
138
+ */
139
+ export declare function recordCostDayRows(sql: RedactionSql, input: CostDayReadInput): number;
140
+ /** Read stored cost rows — see `CostDayFilter`. Every row is parsed on the way out. */
141
+ export declare function listCostDayRows(sql: RedactionSql, filter?: CostDayFilter): CostDay[];
142
+ /** The rollup's record of each day it tried, in day order, in the request rollup's shape (never saturated). */
143
+ export declare function listCostRollupDayRows(sql: RedactionSql, filter?: CostRollupDayFilter): RequestRollupDay[];
144
+ /** Delete at most `limit` cost rows past a retention of `months`, as `pruneRequestDayRows` does. */
145
+ export declare function pruneCostDayRows(sql: RedactionSql, nowMs: number, limit: number, months: number | null): number;
146
+ /** A scope whose Durable Object id is not recorded for the script that holds its data now. */
147
+ export interface ScopeObjectTarget {
148
+ tenantId: TenantId;
149
+ scopeId: ScopeId;
150
+ /** The script that holds the scope's data: its serving ref, or its bound version's own script. */
151
+ script: string;
152
+ vertical: string;
153
+ kind: 'live' | 'preview';
154
+ /** The bound version, when the data lives in that version's own script (a preview, a legacy scope). */
155
+ versionId: string | null;
156
+ /** The tag that asked for a preview, from the scope's slug. */
157
+ previewTag: string | null;
158
+ }
159
+ /** One answer for a target: its object id, or why it could not be read. */
160
+ export type ScopeObjectReadInput = ScopeObjectTarget & {
161
+ attemptedAt: string;
162
+ } & ({
163
+ objectId: string;
164
+ } | {
165
+ error: string;
166
+ });
167
+ /**
168
+ * The scopes whose object id is due, newest first (a preview fork is short-lived and the costliest
169
+ * thing to lose): every scope with a vertical and a data script that has no object recorded for
170
+ * that script, and no failed attempt within `retryMs`. A scope whose data moved to another script
171
+ * is due again, because the new script holds a new object.
172
+ */
173
+ export declare function scopeObjectsDueRows(sql: RedactionSql, input: {
174
+ nowMs: number;
175
+ retryMs: number;
176
+ limit: number;
177
+ }): ScopeObjectTarget[];
178
+ /**
179
+ * Record one target's answer. An object id replaces whatever the id was recorded as before (the
180
+ * same id is the same object), clears the target's failed attempt, and attributes every cost row
181
+ * already stored for that object that named no scope, so a day read before the id was known is not
182
+ * left without its tenant. A failure records only the attempt, so the target waits `retryMs`. An id
183
+ * that is not Cloudflare's 64-hex shape is refused.
184
+ */
185
+ export declare function recordScopeObjectRow(sql: RedactionSql, input: ScopeObjectReadInput): void;
186
+ //# sourceMappingURL=cost-rollup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cost-rollup.d.ts","sourceRoot":"","sources":["../src/cost-rollup.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,OAAO,EAEZ,KAAK,gBAAgB,EACrB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,eAAe,4jDAiD3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,KA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