@camstack/types 1.2.397 → 1.2.399

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 (40) hide show
  1. package/dist/addon.js +17 -2
  2. package/dist/addon.mjs +15 -3
  3. package/dist/capabilities/dishwasher.cap.d.ts +9 -0
  4. package/dist/capabilities/index.d.ts +2 -2
  5. package/dist/capabilities/notification-rules.cap.d.ts +92 -0
  6. package/dist/capabilities/osd-manager.cap.d.ts +24 -0
  7. package/dist/capabilities/pipeline-orchestrator.cap.d.ts +0 -16
  8. package/dist/capabilities/records.cap.d.ts +67 -3
  9. package/dist/capabilities/storage-admin.cap.d.ts +0 -2
  10. package/dist/capabilities/user-management.cap.d.ts +2 -28
  11. package/dist/client.js +88 -9
  12. package/dist/client.mjs +88 -9
  13. package/dist/enums/event-category.d.ts +9 -0
  14. package/dist/enums.js +1 -1
  15. package/dist/enums.mjs +1 -1
  16. package/dist/{event-category-kpu1bZMs.js → event-category-7AwNbPjm.js} +9 -0
  17. package/dist/{event-category-7pZEBmVg.mjs → event-category-BfJwUd2S.mjs} +9 -0
  18. package/dist/generated/addon-api.d.ts +7 -14
  19. package/dist/generated/addon-cap-facts.d.ts +1 -1
  20. package/dist/generated/method-access-map.d.ts +1 -1
  21. package/dist/generated/system-proxy.d.ts +1 -1
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.js +305 -135
  24. package/dist/index.mjs +300 -134
  25. package/dist/interfaces/auth.d.ts +1 -1
  26. package/dist/interfaces/event-bus.d.ts +24 -5
  27. package/dist/notification/alert-episode.d.ts +7 -0
  28. package/dist/pipeline/auto-tune/detector-performance.d.ts +2 -1
  29. package/dist/pipeline/auto-tune/plan-schemas.d.ts +0 -28
  30. package/dist/pipeline/auto-tune/recommend.d.ts +9 -1
  31. package/dist/pipeline/load-balancing/share-election.d.ts +7 -0
  32. package/dist/records/errors.d.ts +9 -1
  33. package/dist/records/index.d.ts +1 -0
  34. package/dist/records/record-kind.d.ts +62 -2
  35. package/dist/records/records-access.d.ts +36 -1
  36. package/dist/records/transact-rules.d.ts +7 -0
  37. package/dist/schemas/auth-records.d.ts +0 -12
  38. package/dist/{sleep-Bo7fq491.js → sleep-CD18m9HF.js} +478 -311
  39. package/dist/{sleep-CueztlR1.mjs → sleep-DJFUfKvA.mjs} +461 -312
  40. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- export { type UserRecord, type ApiKeyRecord, type TokenScope } from '../schemas/auth-records.js';
1
+ export { type UserRecord, type TokenScope } from '../schemas/auth-records.js';
2
2
  import type { TokenScope } from '../schemas/auth-records.js';
3
3
  export interface UserPermissions {
4
4
  isAdmin: boolean;
@@ -484,6 +484,15 @@ export interface StorageLocationsChangedPayload {
484
484
  * when a camera is assigned to or unassigned from an agent runner. Used by
485
485
  * the UI / metrics dashboard. No frame data.
486
486
  */
487
+ export type PipelineMotionNoisePayload = {
488
+ readonly deviceId: number;
489
+ /** The rolling window the figures are over, in ms. */
490
+ readonly windowMs: number;
491
+ /** Share of the window with a detection session open, whole percent. */
492
+ readonly dutyPct: number;
493
+ /** Sessions opened in the window. */
494
+ readonly sessions: number;
495
+ };
487
496
  export interface PipelineCameraAssignmentPayload {
488
497
  readonly deviceId: number;
489
498
  readonly agentNodeId: string;
@@ -1270,15 +1279,25 @@ export interface EventCatalog {
1270
1279
  /** The enabled device keys the live probe did not report. */
1271
1280
  readonly unavailableDeviceKeys: readonly string[];
1272
1281
  };
1273
- /** A camera with an open detection session that has detected nothing for
1274
- * longer than the blind threshold. */
1282
+ /** A camera that MOVED (enough session time over enough sessions), was
1283
+ * analysed, and whose detector produced no raw output at all (D907). */
1275
1284
  'pipeline.detection-blind': {
1276
1285
  readonly deviceId: number;
1277
- /** How long it has been blind, in ms. */
1286
+ /** Wall time since its last detection, in ms — context, not the gate. */
1278
1287
  readonly blindForMs: number;
1279
- /** The threshold that was crossed, in ms. */
1288
+ /** The motion bar that was crossed, in ms. */
1280
1289
  readonly thresholdMs: number;
1281
- };
1290
+ /** Session-open time since the detector last produced anything, in ms. */
1291
+ readonly motionMs: number;
1292
+ /** Sessions opened in that time. */
1293
+ readonly sessions: number;
1294
+ /** Frames since the last detection where candidates fell under the floor. */
1295
+ readonly belowFloor: number;
1296
+ };
1297
+ /** A camera whose motion has been constant with no detection (D907). */
1298
+ 'pipeline.motion-noisy': PipelineMotionNoisePayload;
1299
+ /** The camera's motion fell back, or a detection arrived (D907). */
1300
+ 'pipeline.motion-calm': PipelineMotionNoisePayload;
1282
1301
  /** Per-camera pipeline config changed — orchestrator hot-reloads the assigned runner. */
1283
1302
  'pipeline.camera-updated': {
1284
1303
  readonly deviceId: number;
@@ -59,4 +59,11 @@ export declare function alertNodeId(alert: Pick<Alert, 'source' | 'metadata'>):
59
59
  * (an `error` episode announces its opening only).
60
60
  */
61
61
  export declare function alertEpisodeKind(severity: AlertSeverity, phase: AlertEpisodePhase): NcSystemEventKind | null;
62
+ /**
63
+ * The kind of a CRITICAL episode edge about a DEVICE (D911): the alert's source
64
+ * is `device`, so it is announced in the devices family as
65
+ * `device-attention-required` / `-resolved` INSTEAD of `alert-critical`. One
66
+ * alert notifies once, through one family. `null` for any other severity.
67
+ */
68
+ export declare function deviceAttentionKind(severity: AlertSeverity, phase: AlertEpisodePhase): NcSystemEventKind | null;
62
69
  export declare function alertEpisodePayload(alert: Alert, phase: AlertEpisodePhase, at: number): AlertEpisodePayload;
@@ -7,7 +7,8 @@
7
7
  * `docs/benchmarks/model-floors.json` (person precision / recall at the
8
8
  * shipped floor). `__tests__/detector-performance.spec.ts` holds both tables
9
9
  * equal to those files, so a re-measurement replaces the JSON and this file
10
- * together. Only the YOLOv9 t/s/m family is here: the cluster runs ONE family
10
+ * together. Only the YOLOv9 t/s/m family is here (plus, in each `coral` column,
11
+ * the one Edge TPU build a Coral runs by default, `yolov9s-320-edgetpu`, D912): the cluster runs ONE family
11
12
  * (YOLOv9 — the one that runs well on every accelerator class measured), and
12
13
  * tier c is not offered (a few recall points for 25–50 % more latency).
13
14
  */
@@ -52,8 +52,6 @@ export declare const RecommendationReasonSchema: z.ZodDiscriminatedUnion<[z.ZodO
52
52
  modelId: z.ZodString;
53
53
  }, z.core.$strip>, z.ZodObject<{
54
54
  kind: z.ZodLiteral<"cpu-device">;
55
- }, z.core.$strip>, z.ZodObject<{
56
- kind: z.ZodLiteral<"coral-untouched">;
57
55
  }, z.core.$strip>, z.ZodObject<{
58
56
  kind: z.ZodLiteral<"device-disabled">;
59
57
  }, z.core.$strip>, z.ZodObject<{
@@ -172,8 +170,6 @@ export declare const DeviceRecommendationSchema: z.ZodObject<{
172
170
  modelId: z.ZodString;
173
171
  }, z.core.$strip>, z.ZodObject<{
174
172
  kind: z.ZodLiteral<"cpu-device">;
175
- }, z.core.$strip>, z.ZodObject<{
176
- kind: z.ZodLiteral<"coral-untouched">;
177
173
  }, z.core.$strip>, z.ZodObject<{
178
174
  kind: z.ZodLiteral<"device-disabled">;
179
175
  }, z.core.$strip>, z.ZodObject<{
@@ -276,8 +272,6 @@ export declare const NodeRecommendationSchema: z.ZodObject<{
276
272
  modelId: z.ZodString;
277
273
  }, z.core.$strip>, z.ZodObject<{
278
274
  kind: z.ZodLiteral<"cpu-device">;
279
- }, z.core.$strip>, z.ZodObject<{
280
- kind: z.ZodLiteral<"coral-untouched">;
281
275
  }, z.core.$strip>, z.ZodObject<{
282
276
  kind: z.ZodLiteral<"device-disabled">;
283
277
  }, z.core.$strip>, z.ZodObject<{
@@ -334,8 +328,6 @@ export declare const NodeRecommendationSchema: z.ZodObject<{
334
328
  modelId: z.ZodString;
335
329
  }, z.core.$strip>, z.ZodObject<{
336
330
  kind: z.ZodLiteral<"cpu-device">;
337
- }, z.core.$strip>, z.ZodObject<{
338
- kind: z.ZodLiteral<"coral-untouched">;
339
331
  }, z.core.$strip>, z.ZodObject<{
340
332
  kind: z.ZodLiteral<"device-disabled">;
341
333
  }, z.core.$strip>, z.ZodObject<{
@@ -411,10 +403,6 @@ export declare const AutoTuneWarningSchema: z.ZodDiscriminatedUnion<[z.ZodObject
411
403
  }, z.core.$strip>, z.ZodObject<{
412
404
  kind: z.ZodLiteral<"detector-store-unreadable">;
413
405
  error: z.ZodString;
414
- }, z.core.$strip>, z.ZodObject<{
415
- kind: z.ZodLiteral<"coral-enabled">;
416
- nodeId: z.ZodString;
417
- deviceKey: z.ZodString;
418
406
  }, z.core.$strip>, z.ZodObject<{
419
407
  kind: z.ZodLiteral<"custom-pin-kept">;
420
408
  nodeId: z.ZodString;
@@ -504,8 +492,6 @@ export declare const AutoTunePlanSchema: z.ZodObject<{
504
492
  modelId: z.ZodString;
505
493
  }, z.core.$strip>, z.ZodObject<{
506
494
  kind: z.ZodLiteral<"cpu-device">;
507
- }, z.core.$strip>, z.ZodObject<{
508
- kind: z.ZodLiteral<"coral-untouched">;
509
495
  }, z.core.$strip>, z.ZodObject<{
510
496
  kind: z.ZodLiteral<"device-disabled">;
511
497
  }, z.core.$strip>, z.ZodObject<{
@@ -562,8 +548,6 @@ export declare const AutoTunePlanSchema: z.ZodObject<{
562
548
  modelId: z.ZodString;
563
549
  }, z.core.$strip>, z.ZodObject<{
564
550
  kind: z.ZodLiteral<"cpu-device">;
565
- }, z.core.$strip>, z.ZodObject<{
566
- kind: z.ZodLiteral<"coral-untouched">;
567
551
  }, z.core.$strip>, z.ZodObject<{
568
552
  kind: z.ZodLiteral<"device-disabled">;
569
553
  }, z.core.$strip>, z.ZodObject<{
@@ -634,10 +618,6 @@ export declare const AutoTunePlanSchema: z.ZodObject<{
634
618
  }, z.core.$strip>, z.ZodObject<{
635
619
  kind: z.ZodLiteral<"detector-store-unreadable">;
636
620
  error: z.ZodString;
637
- }, z.core.$strip>, z.ZodObject<{
638
- kind: z.ZodLiteral<"coral-enabled">;
639
- nodeId: z.ZodString;
640
- deviceKey: z.ZodString;
641
621
  }, z.core.$strip>, z.ZodObject<{
642
622
  kind: z.ZodLiteral<"custom-pin-kept">;
643
623
  nodeId: z.ZodString;
@@ -769,8 +749,6 @@ export declare const AutoTuneApplyResultSchema: z.ZodDiscriminatedUnion<[z.ZodOb
769
749
  modelId: z.ZodString;
770
750
  }, z.core.$strip>, z.ZodObject<{
771
751
  kind: z.ZodLiteral<"cpu-device">;
772
- }, z.core.$strip>, z.ZodObject<{
773
- kind: z.ZodLiteral<"coral-untouched">;
774
752
  }, z.core.$strip>, z.ZodObject<{
775
753
  kind: z.ZodLiteral<"device-disabled">;
776
754
  }, z.core.$strip>, z.ZodObject<{
@@ -827,8 +805,6 @@ export declare const AutoTuneApplyResultSchema: z.ZodDiscriminatedUnion<[z.ZodOb
827
805
  modelId: z.ZodString;
828
806
  }, z.core.$strip>, z.ZodObject<{
829
807
  kind: z.ZodLiteral<"cpu-device">;
830
- }, z.core.$strip>, z.ZodObject<{
831
- kind: z.ZodLiteral<"coral-untouched">;
832
808
  }, z.core.$strip>, z.ZodObject<{
833
809
  kind: z.ZodLiteral<"device-disabled">;
834
810
  }, z.core.$strip>, z.ZodObject<{
@@ -899,10 +875,6 @@ export declare const AutoTuneApplyResultSchema: z.ZodDiscriminatedUnion<[z.ZodOb
899
875
  }, z.core.$strip>, z.ZodObject<{
900
876
  kind: z.ZodLiteral<"detector-store-unreadable">;
901
877
  error: z.ZodString;
902
- }, z.core.$strip>, z.ZodObject<{
903
- kind: z.ZodLiteral<"coral-enabled">;
904
- nodeId: z.ZodString;
905
- deviceKey: z.ZodString;
906
878
  }, z.core.$strip>, z.ZodObject<{
907
879
  kind: z.ZodLiteral<"custom-pin-kept">;
908
880
  nodeId: z.ZodString;
@@ -25,7 +25,10 @@
25
25
  * variant down from m-640 is s-640-int8, not m-320. When nothing fits,
26
26
  * the candidate with the most capacity is used and the plan says so.
27
27
  * 5. An enabled CPU device (the fallback pool) gets its own pick the same
28
- * way; a Coral is never touched (no YOLOv9 build), only reported.
28
+ * way. An ENABLED Coral is sized at its one default build
29
+ * (`CORAL_DEFAULT_MODEL_ID`) from the `coral` column, outside the
30
+ * accelerator group — it shares no model with it. A DISABLED Coral stays
31
+ * out like any disabled device; a Coral is enabled by default (D912).
29
32
  * 6. A device whose root detector is pinned to a CUSTOM-registry model (a
30
33
  * fine-tune, a canary) is KEPT (D786): no model is chosen for it, so Apply
31
34
  * writes nothing there. One kept accelerator keeps the whole accelerator
@@ -37,6 +40,11 @@ import { type DetectorPerfTable } from './detector-performance.js';
37
40
  import { type NodeRecommendation } from './plan-schemas.js';
38
41
  /** The family the cluster runs. */
39
42
  export declare const AUTO_TUNE_FAMILY = "yolov9";
43
+ /**
44
+ * The model a Coral runs by default (D908) and the only one Auto tune sizes it
45
+ * at (D912). Auto tune never enables a device; it sizes the enabled ones.
46
+ */
47
+ export declare const CORAL_DEFAULT_MODEL_ID = "yolov9s-320-edgetpu";
40
48
  /** Recall within this of the best counts as a tie — the faster one wins. */
41
49
  export declare const RECALL_TIE = 0.02;
42
50
  /** Default share of an accelerator's throughput kept free. */
@@ -29,6 +29,13 @@ export interface ShareCandidate {
29
29
  readonly share: number;
30
30
  /** Sessions running on this candidate now. */
31
31
  readonly running: number;
32
+ /**
33
+ * Recent elections that are not running now, decayed over time (default 0).
34
+ * Sessions that never overlap leave `running` at 0 at every election, so the
35
+ * deficits tie forever and the key order hands every session to the same
36
+ * candidate; counting history makes the CUMULATIVE split follow the shares.
37
+ */
38
+ readonly recent?: number;
32
39
  /** At an explicit cap — never elected. */
33
40
  readonly capped: boolean;
34
41
  /** Drowning (pool queue at its shed cap) — stepped over while another is free. */
@@ -8,7 +8,7 @@
8
8
  * A failed read is never `[]` or `undefined`: it throws one of these.
9
9
  */
10
10
  /** Every code a records failure carries. */
11
- export declare const RECORDS_ERROR_CODES: readonly ['rev-conflict', 'too-large', 'unindexed-filter', 'filter-required', 'unknown-kind', 'not-found', 'unique-violation', 'plaintext-secret', 'foreign-marker', 'secret-unavailable', 'invalid-record', 'declaration-refused', 'no-caller', 'batch-too-large'];
11
+ export declare const RECORDS_ERROR_CODES: readonly ['rev-conflict', 'too-large', 'unindexed-filter', 'filter-required', 'unknown-kind', 'not-found', 'unique-violation', 'plaintext-secret', 'foreign-marker', 'secret-unavailable', 'invalid-record', 'declaration-refused', 'no-caller', 'batch-too-large', 'transact-refused'];
12
12
  export type RecordsErrorCode = (typeof RECORDS_ERROR_CODES)[number];
13
13
  /** The base of every records failure. `detail` is the human part of the message. */
14
14
  export declare class RecordsError extends Error {
@@ -68,6 +68,14 @@ export declare class NoCallerError extends RecordsError {
68
68
  export declare class BatchTooLargeError extends RecordsError {
69
69
  constructor(detail: string);
70
70
  }
71
+ /**
72
+ * A `transact` the engine refuses before touching a row: an op on a kind the
73
+ * caller did not declare in ONE file and ONE `transactFamily`. The detail names
74
+ * which rule (`cross-file`, `cross-family`, `no-family`); it is never a silent split.
75
+ */
76
+ export declare class TransactRefusedError extends RecordsError {
77
+ constructor(detail: string);
78
+ }
71
79
  /**
72
80
  * Rebuild the typed error from a message that crossed a wire; `null` when the
73
81
  * message is not a records failure.
@@ -2,6 +2,7 @@ export * from './constants.js';
2
2
  export * from './errors.js';
3
3
  export * from './record-kind.js';
4
4
  export * from './secret-paths.js';
5
+ export * from './transact-rules.js';
5
6
  export * from './records-access.js';
6
7
  export * from './entry-kind.js';
7
8
  export { makeInMemoryRecords, type InMemoryRecords, type InMemoryRecordsOptions, type InMemorySeedRow, type InMemoryStoredRow, } from './in-memory-records.js';
@@ -42,7 +42,7 @@ export declare const EntryDescriptorSchema: z.ZodObject<{
42
42
  fields: z.ZodRecord<z.ZodString, z.ZodUnknown>;
43
43
  }, z.core.$strict>;
44
44
  export type EntryDescriptor = z.infer<typeof EntryDescriptorSchema>;
45
- /** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
45
+ /** What crosses the wire from an addon: JSON only, no Zod. An unknown key is refused. */
46
46
  export declare const RecordKindDeclarationSchema: z.ZodObject<{
47
47
  database: z.ZodDefault<z.ZodEnum<{
48
48
  events: "events";
@@ -92,7 +92,6 @@ export declare const RecordKindDeclarationSchema: z.ZodObject<{
92
92
  maxDataBytes: z.ZodDefault<z.ZodNumber>;
93
93
  secretPaths: z.ZodDefault<z.ZodArray<z.ZodString>>;
94
94
  secretArrayKeys: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
95
- adoptsFrom: z.ZodOptional<z.ZodString>;
96
95
  transactFamily: z.ZodOptional<z.ZodString>;
97
96
  entry: z.ZodOptional<z.ZodObject<{
98
97
  title: z.ZodString;
@@ -100,6 +99,67 @@ export declare const RecordKindDeclarationSchema: z.ZodObject<{
100
99
  fields: z.ZodRecord<z.ZodString, z.ZodUnknown>;
101
100
  }, z.core.$strict>>;
102
101
  }, z.core.$strict>;
102
+ /**
103
+ * A declaration as the engine's catalog stored it: an unknown key is DROPPED,
104
+ * because a row written by an older engine must never stop records from
105
+ * starting. Only for rows read back from the catalog, never for input.
106
+ */
107
+ export declare const StoredRecordKindDeclarationSchema: z.ZodObject<{
108
+ database: z.ZodDefault<z.ZodEnum<{
109
+ events: "events";
110
+ settings: "settings";
111
+ }>>;
112
+ class: z.ZodEnum<{
113
+ audit: "audit";
114
+ config: "config";
115
+ ephemeral: "ephemeral";
116
+ ledger: "ledger";
117
+ mirror: "mirror";
118
+ }>;
119
+ writeTrigger: z.ZodString;
120
+ device: z.ZodDefault<z.ZodEnum<{
121
+ none: "none";
122
+ optional: "optional";
123
+ required: "required";
124
+ }>>;
125
+ at: z.ZodDefault<z.ZodEnum<{
126
+ none: "none";
127
+ required: "required";
128
+ }>>;
129
+ indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
130
+ name: z.ZodString;
131
+ fields: z.ZodArray<z.ZodString>;
132
+ unique: z.ZodOptional<z.ZodBoolean>;
133
+ }, z.core.$strict>>>;
134
+ retention: z.ZodUnion<readonly [z.ZodObject<{
135
+ ttlMs: z.ZodNumber;
136
+ from: z.ZodEnum<{
137
+ at: "at";
138
+ write: "write";
139
+ }>;
140
+ }, z.core.$strict>, z.ZodObject<{
141
+ maxRows: z.ZodOptional<z.ZodNumber>;
142
+ maxRowsPerDevice: z.ZodOptional<z.ZodNumber>;
143
+ }, z.core.$strict>, z.ZodObject<{
144
+ owner: z.ZodString;
145
+ reason: z.ZodString;
146
+ }, z.core.$strict>, z.ZodObject<{
147
+ none: z.ZodString;
148
+ }, z.core.$strict>]>;
149
+ deviceRemoval: z.ZodDefault<z.ZodEnum<{
150
+ delete: "delete";
151
+ none: "none";
152
+ }>>;
153
+ maxDataBytes: z.ZodDefault<z.ZodNumber>;
154
+ secretPaths: z.ZodDefault<z.ZodArray<z.ZodString>>;
155
+ secretArrayKeys: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
156
+ transactFamily: z.ZodOptional<z.ZodString>;
157
+ entry: z.ZodOptional<z.ZodObject<{
158
+ title: z.ZodString;
159
+ nameField: z.ZodString;
160
+ fields: z.ZodRecord<z.ZodString, z.ZodUnknown>;
161
+ }, z.core.$strict>>;
162
+ }, z.core.$strip>;
103
163
  export type RecordKindDeclaration = z.infer<typeof RecordKindDeclarationSchema>;
104
164
  /** The kind names: lower-case, dash separated, short enough for an index name. */
105
165
  export declare const RecordKindNameSchema: z.ZodString;
@@ -24,7 +24,7 @@
24
24
  * - **delete**: the keychain values of the removed rows go with them.
25
25
  */
26
26
  import type { z } from 'zod';
27
- import type { DeclareKindResult, IRecordsProvider, RecordQueryInput, RecordWhere } from '../capabilities/records.cap.js';
27
+ import type { DeclareKindResult, IRecordsProvider, RecordQueryInput, RecordTransactOp, RecordWhere } from '../capabilities/records.cap.js';
28
28
  import type { SecretsAccess } from '../keychain/secrets-access.js';
29
29
  import { type DefinedRecordKind } from './record-kind.js';
30
30
  /** The wire: the `records` provider's methods. The owner is never an argument. */
@@ -64,8 +64,36 @@ export interface RecordQueryOptions {
64
64
  /** Resolve the secret fields of the page in ONE keychain call. A failure throws. */
65
65
  readonly resolveSecrets?: boolean;
66
66
  }
67
+ /**
68
+ * One write prepared for {@link RecordsAccess.transact}: the wire op plus the
69
+ * undo of the keychain writes made for it (a refused transaction puts the
70
+ * previous secret values back). Build it with the kind handle's `txPut`,
71
+ * `txPatch` and `txDelete`, which run the same validation and secret handling
72
+ * as the single `put` / `patch` / `delete`.
73
+ */
74
+ export interface PreparedTransactOp {
75
+ readonly wire: RecordTransactOp;
76
+ readonly rollback: () => Promise<void>;
77
+ }
78
+ /** What one op of a transaction did, in op order. `rev` is `null` for a delete. */
79
+ export interface TransactOpResult {
80
+ readonly rev: number | null;
81
+ readonly deleted: boolean;
82
+ }
67
83
  export interface RecordKindHandle<T> {
68
84
  readonly name: string;
85
+ /** `put` as an op of {@link RecordsAccess.transact}. */
86
+ txPut(input: RecordPut<T>, opts?: {
87
+ readonly ifRev?: number;
88
+ }): Promise<PreparedTransactOp>;
89
+ /** `patch` as an op of {@link RecordsAccess.transact}. */
90
+ txPatch(id: string, partial: Readonly<Record<string, unknown>>, opts?: {
91
+ readonly ifRev?: number;
92
+ readonly at?: number | null;
93
+ readonly expiresAt?: number | null;
94
+ }): Promise<PreparedTransactOp>;
95
+ /** `delete` as an op of {@link RecordsAccess.transact}. */
96
+ txDelete(id: string): PreparedTransactOp;
69
97
  get(id: string): Promise<RecordRow<T> | null>;
70
98
  getMany(ids: readonly string[]): Promise<readonly RecordRow<T>[]>;
71
99
  /** `get` with the secret fields resolved from the keychain. */
@@ -133,6 +161,13 @@ export interface RecordsAccess {
133
161
  */
134
162
  declare(kinds: Readonly<Record<string, DefinedRecordKind>>): Promise<Readonly<Record<string, DeclareKindResult>>>;
135
163
  kind<S extends z.ZodType>(definition: DefinedRecordKind<S>): RecordKindHandle<z.infer<S>>;
164
+ /**
165
+ * Several writes in ONE transaction: all land or none does. Every op's kind
166
+ * must be declared by this owner in ONE database file under ONE
167
+ * `transactFamily`; anything else throws `records/transact-refused` before a
168
+ * row is touched. Results are in op order.
169
+ */
170
+ transact(ops: readonly PreparedTransactOp[]): Promise<readonly TransactOpResult[]>;
136
171
  /**
137
172
  * In-process SYSTEM builtins only (the entries service): act as the door of
138
173
  * another owner. `null` everywhere else - a forked addon has no way to state
@@ -0,0 +1,7 @@
1
+ import type { RecordKindDeclaration } from './record-kind.js';
2
+ export interface TransactMember {
3
+ readonly kind: string;
4
+ readonly declaration: Pick<RecordKindDeclaration, 'database' | 'transactFamily'>;
5
+ }
6
+ /** Throws {@link TransactRefusedError} unless the kinds may share one transaction. */
7
+ export declare function assertTransactScope(members: readonly TransactMember[]): void;
@@ -202,18 +202,6 @@ export declare const UserRecordSchema: z.ZodObject<{
202
202
  updatedAt: z.ZodNumber;
203
203
  }, z.core.$strip>;
204
204
  export type UserRecord = z.infer<typeof UserRecordSchema>;
205
- export declare const ApiKeyRecordSchema: z.ZodObject<{
206
- id: z.ZodString;
207
- label: z.ZodString;
208
- isAdmin: z.ZodDefault<z.ZodBoolean>;
209
- allowedProviders: z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>;
210
- allowedDevices: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>>;
211
- tokenHash: z.ZodString;
212
- tokenPrefix: z.ZodString;
213
- createdAt: z.ZodNumber;
214
- lastUsedAt: z.ZodOptional<z.ZodNumber>;
215
- }, z.core.$strip>;
216
- export type ApiKeyRecord = z.infer<typeof ApiKeyRecordSchema>;
217
205
  export declare const ScopedTokenSchema: z.ZodObject<{
218
206
  id: z.ZodString;
219
207
  userId: z.ZodString;