@prestack/thread 0.1.3 → 0.1.5

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 (270) hide show
  1. package/CHANGELOG.md +563 -0
  2. package/dist/core/actor.d.ts +1 -1
  3. package/dist/core/actor.js +5 -4
  4. package/dist/core/actor.ts +5 -4
  5. package/dist/core/attach.d.ts +0 -7
  6. package/dist/core/attach.js +38 -67
  7. package/dist/core/attach.ts +34 -80
  8. package/dist/core/chain.js +13 -17
  9. package/dist/core/chain.ts +11 -15
  10. package/dist/core/condition.d.ts +4 -4
  11. package/dist/core/condition.js +2 -2
  12. package/dist/core/descend.d.ts +4 -2
  13. package/dist/core/descend.js +91 -23
  14. package/dist/core/descend.ts +90 -21
  15. package/dist/core/errors/catalogue.d.ts +52 -0
  16. package/dist/{operations/errors/errors.js → core/errors/catalogue.js} +1 -1
  17. package/dist/{operations/errors/errors.ts → core/errors/catalogue.ts} +1 -1
  18. package/dist/{operations/errors/catalog.d.ts → core/errors/error.d.ts} +2 -3
  19. package/dist/{operations/errors/catalog.js → core/errors/error.js} +1 -16
  20. package/dist/{operations/errors/catalog.ts → core/errors/error.ts} +3 -19
  21. package/dist/core/errors/namespaces.d.ts +3 -0
  22. package/dist/core/errors/namespaces.js +15 -0
  23. package/dist/core/errors/namespaces.ts +19 -0
  24. package/dist/core/finding.js +2 -2
  25. package/dist/core/finding.ts +1 -2
  26. package/dist/core/init.d.ts +1 -1
  27. package/dist/core/init.js +51 -5
  28. package/dist/core/init.ts +58 -5
  29. package/dist/core/invoked.d.ts +1 -1
  30. package/dist/core/invoked.js +3 -1
  31. package/dist/core/invoked.ts +5 -2
  32. package/dist/core/round.js +36 -22
  33. package/dist/core/round.ts +26 -9
  34. package/dist/core/rows.d.ts +4 -0
  35. package/dist/core/rows.js +31 -2
  36. package/dist/core/rows.ts +33 -1
  37. package/dist/core/scope.d.ts +1 -0
  38. package/dist/core/scope.js +1 -0
  39. package/dist/core/scope.ts +2 -0
  40. package/dist/core/thread.d.ts +3 -3
  41. package/dist/core/tree.d.ts +4 -1
  42. package/dist/core/tree.js +26 -6
  43. package/dist/core/tree.ts +29 -6
  44. package/dist/core/types.d.ts +3 -3
  45. package/dist/core/types.js +3 -1
  46. package/dist/core/types.ts +2 -1
  47. package/dist/derivation/attach.js +3 -2
  48. package/dist/derivation/attach.ts +2 -1
  49. package/dist/derivation/generators/build.js +6 -6
  50. package/dist/derivation/generators/build.ts +1 -1
  51. package/dist/derivation/generators/check.js +1 -1
  52. package/dist/derivation/generators/determinism.js +1 -1
  53. package/dist/derivation/generators/release.js +60 -47
  54. package/dist/derivation/generators/release.ts +66 -43
  55. package/dist/derivation/release.d.ts +7 -3
  56. package/dist/derivation/release.js +14 -1
  57. package/dist/derivation/release.ts +22 -2
  58. package/dist/integrations/attach.d.ts +4 -0
  59. package/dist/integrations/attach.js +37 -56
  60. package/dist/integrations/attach.ts +54 -60
  61. package/dist/integrations/cli.d.ts +37 -0
  62. package/dist/integrations/cli.js +440 -0
  63. package/dist/integrations/cli.ts +543 -0
  64. package/dist/{core/files.d.ts → integrations/disk.d.ts} +16 -24
  65. package/dist/integrations/disk.js +435 -0
  66. package/dist/integrations/disk.ts +465 -0
  67. package/dist/integrations/generators/read.js +6 -6
  68. package/dist/integrations/generators/read.ts +4 -4
  69. package/dist/integrations/generators/vault.js +10 -11
  70. package/dist/integrations/generators/vault.ts +4 -5
  71. package/dist/{operations/http.d.ts → integrations/https.d.ts} +10 -6
  72. package/dist/integrations/https.js +170 -0
  73. package/dist/integrations/https.ts +216 -0
  74. package/dist/integrations/pglite.d.ts +26 -0
  75. package/dist/integrations/pglite.js +143 -0
  76. package/dist/integrations/pglite.ts +206 -0
  77. package/dist/integrations/secret.d.ts +8 -2
  78. package/dist/integrations/secret.js +3 -5
  79. package/dist/integrations/secret.ts +10 -6
  80. package/dist/integrations/target.d.ts +155 -14
  81. package/dist/integrations/target.js +171 -50
  82. package/dist/integrations/target.ts +377 -61
  83. package/dist/integrations/vault.d.ts +1 -0
  84. package/dist/integrations/vault.js +20 -5
  85. package/dist/integrations/vault.ts +17 -5
  86. package/dist/integrity/attach.js +8 -77
  87. package/dist/integrity/attach.ts +7 -76
  88. package/dist/integrity/check-threads.js +5 -5
  89. package/dist/integrity/check-threads.ts +2 -2
  90. package/dist/integrity/constraint.d.ts +0 -1
  91. package/dist/integrity/constraint.js +267 -366
  92. package/dist/integrity/constraint.ts +267 -375
  93. package/dist/integrity/generators/compiler.js +14 -17
  94. package/dist/integrity/generators/compiler.ts +10 -15
  95. package/dist/integrity/generators/gate.js +15 -15
  96. package/dist/integrity/generators/gate.ts +10 -10
  97. package/dist/integrity/generators/issues.js +7 -7
  98. package/dist/integrity/generators/publish.js +39 -57
  99. package/dist/integrity/generators/publish.ts +44 -55
  100. package/dist/integrity/generators/trial.d.ts +3 -3
  101. package/dist/integrity/generators/trial.js +133 -165
  102. package/dist/integrity/generators/trial.ts +145 -169
  103. package/dist/integrity/lint.js +9 -13
  104. package/dist/integrity/lint.ts +7 -10
  105. package/dist/integrity/lsp/bin.js +5 -4
  106. package/dist/integrity/lsp/bin.ts +3 -1
  107. package/dist/integrity/lsp/diagnostics.js +3 -3
  108. package/dist/integrity/lsp/diagnostics.ts +1 -1
  109. package/dist/integrity/lsp/lint.js +19 -30
  110. package/dist/integrity/lsp/lint.ts +16 -32
  111. package/dist/integrity/lsp/server.js +3 -3
  112. package/dist/integrity/slopnator.d.ts +3 -13
  113. package/dist/integrity/slopnator.js +59 -38
  114. package/dist/integrity/slopnator.ts +54 -38
  115. package/dist/integrity/slopnators/sl_broken_lineage.js +2 -2
  116. package/dist/integrity/slopnators/sl_declared_elsewhere.js +1 -1
  117. package/dist/integrity/slopnators/sl_derived_drift.js +4 -4
  118. package/dist/integrity/slopnators/sl_derived_drift.ts +1 -1
  119. package/dist/integrity/slopnators/sl_door_in_a_node.js +220 -0
  120. package/dist/integrity/slopnators/sl_door_in_a_node.ts +250 -0
  121. package/dist/integrity/slopnators/sl_inert_island.js +10 -8
  122. package/dist/integrity/slopnators/sl_inert_island.ts +8 -6
  123. package/dist/integrity/slopnators/sl_missing_row.js +6 -51
  124. package/dist/integrity/slopnators/sl_missing_row.ts +4 -50
  125. package/dist/integrity/slopnators/sl_no_barrel.js +1 -1
  126. package/dist/integrity/slopnators/sl_no_child_process.js +36 -18
  127. package/dist/integrity/slopnators/sl_no_child_process.ts +44 -18
  128. package/dist/integrity/slopnators/sl_no_dispatch_bypass.js +80 -149
  129. package/dist/integrity/slopnators/sl_no_dispatch_bypass.ts +95 -147
  130. package/dist/integrity/slopnators/sl_no_import_cycle.js +15 -4
  131. package/dist/integrity/slopnators/sl_no_import_cycle.ts +20 -4
  132. package/dist/integrity/slopnators/sl_no_such_command.js +2 -2
  133. package/dist/integrity/slopnators/sl_no_such_command.ts +1 -1
  134. package/dist/integrity/slopnators/sl_outside_an_operation.js +20 -0
  135. package/dist/integrity/slopnators/sl_outside_an_operation.ts +25 -0
  136. package/dist/integrity/slopnators/sl_screen_holds_only_declared.d.ts +2 -0
  137. package/dist/integrity/slopnators/sl_screen_holds_only_declared.js +61 -0
  138. package/dist/integrity/slopnators/sl_screen_holds_only_declared.ts +70 -0
  139. package/dist/integrity/slopnators/sl_secret_literal.js +1 -33
  140. package/dist/integrity/slopnators/sl_secret_literal.ts +1 -33
  141. package/dist/integrity/slopnators/sl_stale_path.js +5 -22
  142. package/dist/integrity/slopnators/sl_stale_path.ts +4 -20
  143. package/dist/integrity/slopnators/sl_twice_meant.js +1 -1
  144. package/dist/integrity/slopnators/sl_twice_parented.js +29 -5
  145. package/dist/integrity/slopnators/sl_twice_parented.ts +28 -4
  146. package/dist/integrity/slopnators/sl_undeclared_crossing.d.ts +4 -1
  147. package/dist/integrity/slopnators/sl_undeclared_crossing.js +426 -62
  148. package/dist/integrity/slopnators/sl_undeclared_crossing.ts +454 -70
  149. package/dist/integrity/slopnators/sl_undeclared_destination.js +59 -25
  150. package/dist/integrity/slopnators/sl_undeclared_destination.ts +69 -21
  151. package/dist/integrity/slopnators/sl_undeclared_list.d.ts +2 -0
  152. package/dist/integrity/slopnators/sl_undeclared_list.js +363 -0
  153. package/dist/integrity/slopnators/sl_undeclared_list.ts +358 -0
  154. package/dist/integrity/slopnators/sl_undeclared_node.js +1 -11
  155. package/dist/integrity/slopnators/sl_undeclared_node.ts +0 -10
  156. package/dist/integrity/slopnators/sl_undeclared_operation.js +111 -29
  157. package/dist/integrity/slopnators/sl_undeclared_operation.ts +134 -26
  158. package/dist/integrity/slopnators/sl_undeclared_variant.js +2 -2
  159. package/dist/integrity/slopnators/sl_undeclared_webhook.d.ts +2 -0
  160. package/dist/integrity/slopnators/sl_undeclared_webhook.js +90 -0
  161. package/dist/integrity/slopnators/sl_undeclared_webhook.ts +108 -0
  162. package/dist/integrity/slopnators/sl_underived_route.d.ts +2 -0
  163. package/dist/integrity/slopnators/sl_underived_route.js +61 -0
  164. package/dist/integrity/slopnators/sl_underived_route.ts +72 -0
  165. package/dist/integrity/slopnators/sl_ungoverned_island.js +3 -3
  166. package/dist/integrity/slopnators/sl_ungoverned_island.ts +1 -1
  167. package/dist/integrity/slopnators/sl_unlisted_program.d.ts +2 -0
  168. package/dist/integrity/slopnators/sl_unlisted_program.js +39 -0
  169. package/dist/integrity/slopnators/sl_unlisted_program.ts +40 -0
  170. package/dist/integrity/slopnators/sl_unnamed_island.js +1 -1
  171. package/dist/integrity/slopnators/sl_unpaired_member.js +3 -3
  172. package/dist/integrity/slopnators/sl_unpaired_member.ts +1 -1
  173. package/dist/integrity/slopnators/sl_unpaired_slopnator.js +4 -4
  174. package/dist/integrity/slopnators/sl_unpaired_slopnator.ts +1 -1
  175. package/dist/integrity/slopnators/sl_unprefixed_member.js +5 -31
  176. package/dist/integrity/slopnators/sl_unprefixed_member.ts +2 -28
  177. package/dist/integrity/slopnators/sl_unthreaded.js +11 -7
  178. package/dist/integrity/slopnators/sl_unthreaded.ts +6 -7
  179. package/dist/integrity/slopnators/sl_untranslated_key.js +2 -25
  180. package/dist/integrity/slopnators/sl_untranslated_key.ts +1 -25
  181. package/dist/integrity/slopnators/sl_unvaulted_secret.d.ts +2 -0
  182. package/dist/integrity/slopnators/sl_unvaulted_secret.js +107 -0
  183. package/dist/integrity/slopnators/sl_unvaulted_secret.ts +132 -0
  184. package/dist/integrity/slopnators/sl_unversioned.js +6 -4
  185. package/dist/integrity/slopnators/sl_unversioned.ts +5 -3
  186. package/dist/integrity/sweep.d.ts +1 -0
  187. package/dist/integrity/sweep.js +105 -42
  188. package/dist/integrity/sweep.ts +115 -42
  189. package/dist/knowledge/attach.js +4 -3
  190. package/dist/knowledge/attach.ts +3 -2
  191. package/dist/knowledge/generators/docsgen.js +8 -6
  192. package/dist/knowledge/generators/docsgen.ts +4 -2
  193. package/dist/knowledge/generators/glossary.js +4 -4
  194. package/dist/knowledge/generators/glossary.ts +1 -1
  195. package/dist/operations/access.d.ts +23 -0
  196. package/dist/operations/access.js +28 -1
  197. package/dist/operations/access.ts +43 -0
  198. package/dist/operations/attach.js +33 -113
  199. package/dist/operations/attach.ts +51 -117
  200. package/dist/operations/capabilities.d.ts +14 -5
  201. package/dist/operations/capabilities.js +13 -4
  202. package/dist/operations/capabilities.ts +27 -8
  203. package/dist/operations/dispatch.d.ts +8 -2
  204. package/dist/operations/dispatch.js +128 -185
  205. package/dist/operations/dispatch.ts +138 -191
  206. package/dist/operations/error-results.d.ts +1 -1
  207. package/dist/operations/error-results.js +2 -2
  208. package/dist/operations/error-results.ts +2 -2
  209. package/dist/operations/generators/capability.d.ts +11 -1
  210. package/dist/operations/generators/capability.js +481 -224
  211. package/dist/operations/generators/capability.ts +562 -233
  212. package/dist/operations/generators/compile.js +66 -39
  213. package/dist/operations/generators/compile.ts +78 -39
  214. package/dist/operations/generators/permits.js +11 -12
  215. package/dist/operations/generators/permits.ts +3 -4
  216. package/dist/operations/generators/seed.d.ts +1 -0
  217. package/dist/operations/generators/seed.js +19 -17
  218. package/dist/operations/generators/seed.ts +22 -14
  219. package/dist/operations/generators/trial.d.ts +6 -8
  220. package/dist/operations/generators/trial.js +200 -70
  221. package/dist/operations/generators/trial.ts +230 -93
  222. package/dist/operations/nodes.d.ts +15 -16
  223. package/dist/operations/nodes.ts +16 -17
  224. package/dist/operations/operations.d.ts +40 -4
  225. package/dist/operations/operations.js +1 -0
  226. package/dist/operations/operations.ts +61 -4
  227. package/dist/operations/result.d.ts +2 -2
  228. package/dist/operations/result.ts +2 -2
  229. package/package.json +1 -4
  230. package/dist/core/answers.d.ts +0 -171
  231. package/dist/core/answers.js +0 -789
  232. package/dist/core/answers.ts +0 -999
  233. package/dist/core/client.d.ts +0 -63
  234. package/dist/core/client.js +0 -249
  235. package/dist/core/client.ts +0 -289
  236. package/dist/core/files.js +0 -171
  237. package/dist/core/files.ts +0 -222
  238. package/dist/integrations/module.d.ts +0 -6
  239. package/dist/integrations/module.js +0 -153
  240. package/dist/integrations/module.ts +0 -191
  241. package/dist/integrity/slopnators/sl_unkept_rows.js +0 -104
  242. package/dist/integrity/slopnators/sl_unkept_rows.ts +0 -111
  243. package/dist/integrity/slopnators/sl_unseamed_reach.js +0 -73
  244. package/dist/integrity/slopnators/sl_unseamed_reach.ts +0 -79
  245. package/dist/operations/cost.d.ts +0 -14
  246. package/dist/operations/cost.js +0 -37
  247. package/dist/operations/cost.ts +0 -58
  248. package/dist/operations/errors/errors.d.ts +0 -52
  249. package/dist/operations/http.js +0 -124
  250. package/dist/operations/http.ts +0 -169
  251. package/dist/operations/memory.d.ts +0 -104
  252. package/dist/operations/memory.js +0 -365
  253. package/dist/operations/memory.ts +0 -470
  254. package/dist/operations/metering.d.ts +0 -55
  255. package/dist/operations/metering.js +0 -247
  256. package/dist/operations/metering.ts +0 -328
  257. package/dist/operations/queue-policy.d.ts +0 -3
  258. package/dist/operations/queue-policy.js +0 -8
  259. package/dist/operations/queue-policy.ts +0 -10
  260. package/dist/operations/seams.d.ts +0 -239
  261. package/dist/operations/seams.js +0 -45
  262. package/dist/operations/seams.ts +0 -364
  263. package/dist/operations/store.d.ts +0 -14
  264. package/dist/operations/store.js +0 -1
  265. package/dist/operations/store.ts +0 -29
  266. /package/dist/{operations → core}/errors/classes.d.ts +0 -0
  267. /package/dist/{operations → core}/errors/classes.js +0 -0
  268. /package/dist/{operations → core}/errors/classes.ts +0 -0
  269. /package/dist/integrity/slopnators/{sl_unkept_rows.d.ts → sl_door_in_a_node.d.ts} +0 -0
  270. /package/dist/integrity/slopnators/{sl_unseamed_reach.d.ts → sl_outside_an_operation.d.ts} +0 -0
@@ -1,239 +0,0 @@
1
- import type { Actor } from '../core/actor.ts';
2
- export type { FieldList, ReadField, Row, Store } from './store.ts';
3
- import type { Row, Store } from './store.ts';
4
- export interface Span {
5
- ok(): void;
6
- error(e: unknown): void;
7
- end(): void;
8
- }
9
- export interface Telemetry {
10
- start(action: string, run: string, tags: Record<string, unknown>): Span;
11
- record?(span: {
12
- readonly key: string;
13
- readonly traceId: string;
14
- readonly spanId: string;
15
- readonly durationMs: number;
16
- readonly ok: boolean;
17
- readonly attrs?: Record<string, unknown>;
18
- readonly actor?: Actor;
19
- readonly nodeId?: string;
20
- readonly workflowId?: string;
21
- readonly error?: string;
22
- }): void;
23
- }
24
- export type PropertyValue = string | number | boolean | null | readonly (string | number | boolean)[];
25
- export type LogLevel = 'info' | 'warn' | 'error';
26
- export interface Log {
27
- write(level: LogLevel, action: string, actor: Actor, data: Record<string, unknown>): void;
28
- }
29
- export interface AuditRecord {
30
- readonly action: string;
31
- readonly outcome: AuditOutcome;
32
- readonly subject: {
33
- type: string;
34
- id: string;
35
- };
36
- readonly changed?: readonly string[];
37
- readonly because?: string;
38
- }
39
- export interface Audit {
40
- append(actor: Actor, record: AuditRecord): Promise<void>;
41
- }
42
- export interface ErrorRecord {
43
- readonly code: string;
44
- readonly class: string;
45
- readonly action: string;
46
- readonly because?: string;
47
- }
48
- export interface Errors {
49
- record(actor: Actor, error: ErrorRecord): Promise<void>;
50
- }
51
- export interface Search {
52
- index(actor: Actor, entity: string, row: Row): Promise<void>;
53
- query(actor: Actor, entity: string, q: string): Promise<Row[]>;
54
- }
55
- export interface Views {
56
- query<T = Record<string, unknown>>(actor: Actor, sql: string, params: readonly unknown[]): Promise<readonly T[]>;
57
- }
58
- export interface Cost {
59
- meter(action: string, actor: Actor, units?: number): void;
60
- }
61
- export interface Idempotency {
62
- check(key: string | undefined, action: string): Promise<unknown | null>;
63
- store(key: string | undefined, action: string, output: unknown): Promise<void>;
64
- }
65
- export interface PlatformEvent {
66
- kind: string;
67
- entity?: string;
68
- id?: string;
69
- run?: string;
70
- actor: string | null;
71
- at: number;
72
- payload?: Readonly<Record<string, unknown>>;
73
- }
74
- export interface EventBus {
75
- publish(event: PlatformEvent): Promise<void>;
76
- }
77
- export interface RateLimiter {
78
- check(actor: Actor, action: string, operation?: string): Promise<boolean>;
79
- checkPolicy(actor: Actor, policy: string): Promise<boolean>;
80
- }
81
- export interface FeatureGate {
82
- check(actor: Actor, feature: string): Promise<boolean>;
83
- }
84
- export interface QuotaHold {
85
- readonly ok: boolean;
86
- readonly behavior: string | null;
87
- readonly retryAfterSeconds: number;
88
- commit(actual: number): Promise<void>;
89
- release(): Promise<void>;
90
- }
91
- export interface Quotas {
92
- reserve(actor: Actor, meter: string, estimate: number): Promise<QuotaHold>;
93
- lower?(actor: Actor, meter: string, amount: number): Promise<void>;
94
- }
95
- export interface Outbox {
96
- emit(actor: Actor, event: PlatformEvent): Promise<void>;
97
- }
98
- export interface Transactional {
99
- transaction<T>(actor: Actor, fn: () => Promise<T>): Promise<T>;
100
- }
101
- export declare function isTransactional(store: Store): store is Store & Transactional;
102
- export interface Job<T = unknown> {
103
- id: string;
104
- kind: string;
105
- payload: T;
106
- attempts: number;
107
- actor: Actor;
108
- }
109
- export interface EnqueueOpts {
110
- runAt?: number;
111
- dedupeKey?: string;
112
- }
113
- export interface SchedulerSeam {
114
- readonly endpoint: string;
115
- readonly secret: string;
116
- register(app: {
117
- id: string;
118
- endpoint: string;
119
- secret: string;
120
- }): Promise<void>;
121
- schedule(call: {
122
- appId: string;
123
- runAt: Date;
124
- reason: string;
125
- runId?: string;
126
- dedupeKey?: string;
127
- }): Promise<string>;
128
- cancelForRun(appId: string, runId: string): Promise<void>;
129
- }
130
- export interface Queue {
131
- enqueue<T>(actor: Actor, kind: string, payload: T, opts?: EnqueueOpts): Promise<string>;
132
- poll(kinds: string[], limit: number, now: number): Promise<Job[]>;
133
- ack(id: string): Promise<void>;
134
- fail(id: string, error: string, now: number): Promise<void>;
135
- deadLetter(id: string, error: string): Promise<void>;
136
- deadLetters(): Promise<Job[]>;
137
- }
138
- export interface Files {
139
- put(actor: Actor, key: string, body: Uint8Array, contentType: string): Promise<{
140
- size: number;
141
- }>;
142
- get(actor: Actor, key: string): Promise<{
143
- body: Uint8Array;
144
- contentType: string;
145
- } | null>;
146
- signedUrl(actor: Actor, key: string, expiresInSeconds: number): Promise<string>;
147
- remove(actor: Actor, key: string): Promise<void>;
148
- }
149
- export interface Clock {
150
- now(): number;
151
- }
152
- export interface Random {
153
- next(): number;
154
- uuid(): string;
155
- }
156
- export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
157
- export interface HttpRequest {
158
- readonly target: string;
159
- readonly address: string;
160
- readonly method: HttpMethod;
161
- readonly path: string;
162
- readonly headers?: Readonly<Record<string, string>>;
163
- readonly body?: Uint8Array;
164
- readonly contentType?: string;
165
- readonly idempotencyKey?: string;
166
- }
167
- export interface HttpResponse {
168
- readonly status: number;
169
- readonly headers: Readonly<Record<string, string>>;
170
- readonly body: Uint8Array;
171
- readonly bytesSent: number;
172
- readonly bytesReceived: number;
173
- readonly durationMs: number;
174
- }
175
- export interface Http {
176
- call(request: HttpRequest): Promise<HttpResponse>;
177
- }
178
- export interface Vault {
179
- resolve(refs: readonly string[]): Promise<Readonly<Record<string, string>>>;
180
- }
181
- export interface Seams {
182
- store?: Store;
183
- search?: Search;
184
- events?: EventBus;
185
- queue?: Queue;
186
- telemetry?: Telemetry;
187
- log: Log;
188
- audit: Audit;
189
- errors: Errors;
190
- cost?: Cost;
191
- idempotency?: Idempotency;
192
- rateLimiter?: RateLimiter;
193
- flush?: () => Promise<void>;
194
- scheduler?: SchedulerSeam;
195
- featureGate?: FeatureGate;
196
- permits?: {
197
- check(actor: Actor, action: string, resource: Row | null): Promise<{
198
- readonly allow: boolean;
199
- readonly because?: string;
200
- }>;
201
- };
202
- quotas?: Quotas;
203
- outbox?: Outbox;
204
- drainKick?: () => void;
205
- vault?: Vault;
206
- views?: Views;
207
- clock: Clock;
208
- random: Random;
209
- files?: Files;
210
- http?: Http;
211
- }
212
- export type AuditOutcome = 'ok' | 'denied' | 'rate_limited' | 'failed' | 'feature_denied' | 'quota_exceeded';
213
- export declare function isRow(v: unknown): v is Row;
214
- export declare const SUPPLY: {
215
- readonly sm_store: "store";
216
- readonly sm_search: "search";
217
- readonly sm_queue: "queue";
218
- readonly sm_events: "events";
219
- readonly sm_clock: "clock";
220
- readonly sm_random: "random";
221
- readonly sm_vault: "vault";
222
- readonly sm_views: "views";
223
- readonly sm_files: "files";
224
- };
225
- export type Supplied = keyof typeof SUPPLY;
226
- export declare const SUPPLIES: readonly Supplied[];
227
- export declare const supplies: (one: string) => one is Supplied;
228
- export type Handed<R extends string = Supplied> = {
229
- readonly actor: Actor;
230
- } & {
231
- readonly [K in R as K extends Supplied ? (typeof SUPPLY)[K] : K]: K extends Supplied ? NonNullable<Seams[(typeof SUPPLY)[K]]> : Readonly<Record<string, (given?: {
232
- readonly fills?: Readonly<Record<string, string | number>>;
233
- readonly json?: unknown;
234
- readonly body?: Uint8Array;
235
- readonly contentType?: string;
236
- }) => Promise<HttpResponse>>>;
237
- };
238
- export type Reads<H> = Pick<H, Extract<keyof H, 'actor' | 'store' | 'search' | 'views'>>;
239
- export declare const SAID: Readonly<Record<keyof Seams, string>>;
@@ -1,45 +0,0 @@
1
- export function isTransactional(store) {
2
- return typeof store.transaction === 'function';
3
- }
4
- export function isRow(v) {
5
- return typeof v === 'object' && v !== null && typeof v.id === 'string';
6
- }
7
- export const SUPPLY = {
8
- sm_store: 'store',
9
- sm_search: 'search',
10
- sm_queue: 'queue',
11
- sm_events: 'events',
12
- sm_clock: 'clock',
13
- sm_random: 'random',
14
- sm_vault: 'vault',
15
- sm_views: 'views',
16
- sm_files: 'files',
17
- };
18
- export const SUPPLIES = Object.keys(SUPPLY);
19
- export const supplies = (one) => one in SUPPLY;
20
- export const SAID = {
21
- store: 'where rows are kept: insert, get, list, update and remove, bound to whoever asked',
22
- search: 'indexing a row and querying an index, for what cannot be found by id',
23
- events: 'announcing that something happened, to whoever is listening',
24
- queue: 'handing work to something else to run later',
25
- telemetry: 'the span opened around every run, and where it is recorded',
26
- log: 'the line written for every run: its outcome, who was allowed, what it spent',
27
- audit: 'the record of what was done, by whom, to what',
28
- errors: 'the record of every failure, by code and class',
29
- cost: 'metering what a run spent',
30
- idempotency: 'remembering an answer under its key, so a repeated request is answered once',
31
- rateLimiter: 'refusing a caller who asks too often',
32
- flush: 'what runs when the process is about to stop, so nothing buffered is lost',
33
- scheduler: 'registering this app with a scheduler and booking a later run',
34
- featureGate: 'refusing an operation the caller\'s plan does not include',
35
- permits: 'the gate every operation passes: who may ask for what, from the grants',
36
- quotas: 'reserving what a run may spend before it starts, and settling it after',
37
- outbox: 'events written with the transaction and published after it commits',
38
- drainKick: 'nudging the queue worker that work has arrived',
39
- vault: 'opening a secret by name at the moment of use',
40
- views: 'reading through a declared view rather than a table',
41
- clock: 'the current time',
42
- random: 'randomness: a number, a uuid',
43
- files: 'putting a file somewhere, fetching one back, handing out a signed link to one',
44
- http: 'how a call leaves the process, and what it comes back with',
45
- };
@@ -1,364 +0,0 @@
1
- import type { Actor } from '../core/actor.ts'
2
-
3
- export type { FieldList, ReadField, Row, Store } from './store.ts'
4
-
5
- import type { FieldList, Row, Store } from './store.ts'
6
-
7
- export interface Span {
8
- ok(): void
9
- error(e: unknown): void
10
- end(): void
11
- }
12
- export interface Telemetry {
13
- start(action: string, run: string, tags: Record<string, unknown>): Span
14
-
15
- record?(span: {
16
- readonly key: string
17
- readonly traceId: string
18
- readonly spanId: string
19
- readonly durationMs: number
20
- readonly ok: boolean
21
- readonly attrs?: Record<string, unknown>
22
-
23
- readonly actor?: Actor
24
-
25
- readonly nodeId?: string
26
-
27
- readonly workflowId?: string
28
-
29
- readonly error?: string
30
- }): void
31
- }
32
-
33
- export type PropertyValue = string | number | boolean | null | readonly (string | number | boolean)[]
34
-
35
- export type LogLevel = 'info' | 'warn' | 'error'
36
-
37
- export interface Log {
38
- write(level: LogLevel, action: string, actor: Actor, data: Record<string, unknown>): void
39
- }
40
-
41
- export interface AuditRecord {
42
- readonly action: string
43
- readonly outcome: AuditOutcome
44
-
45
- readonly subject: { type: string; id: string }
46
-
47
- readonly changed?: readonly string[]
48
-
49
- readonly because?: string
50
- }
51
-
52
- export interface Audit {
53
- append(actor: Actor, record: AuditRecord): Promise<void>
54
- }
55
-
56
- export interface ErrorRecord {
57
- readonly code: string
58
- readonly class: string
59
- readonly action: string
60
- readonly because?: string
61
- }
62
-
63
- export interface Errors {
64
- record(actor: Actor, error: ErrorRecord): Promise<void>
65
- }
66
-
67
- export interface Search {
68
- index(actor: Actor, entity: string, row: Row): Promise<void>
69
- query(actor: Actor, entity: string, q: string): Promise<Row[]>
70
- }
71
-
72
- export interface Views {
73
- query<T = Record<string, unknown>>(
74
- actor: Actor,
75
- sql: string,
76
- params: readonly unknown[],
77
- ): Promise<readonly T[]>
78
- }
79
-
80
- export interface Cost {
81
- meter(action: string, actor: Actor, units?: number): void
82
- }
83
-
84
- export interface Idempotency {
85
- check(key: string | undefined, action: string): Promise<unknown | null>
86
- store(key: string | undefined, action: string, output: unknown): Promise<void>
87
- }
88
-
89
- export interface PlatformEvent {
90
- kind: string
91
- entity?: string
92
- id?: string
93
- run?: string
94
- actor: string | null
95
- at: number
96
-
97
- payload?: Readonly<Record<string, unknown>>
98
- }
99
- export interface EventBus {
100
- publish(event: PlatformEvent): Promise<void>
101
- }
102
-
103
- export interface RateLimiter {
104
- check(actor: Actor, action: string, operation?: string): Promise<boolean>
105
-
106
- checkPolicy(actor: Actor, policy: string): Promise<boolean>
107
- }
108
-
109
- export interface FeatureGate {
110
- check(actor: Actor, feature: string): Promise<boolean>
111
- }
112
-
113
- export interface QuotaHold {
114
- readonly ok: boolean
115
-
116
- readonly behavior: string | null
117
- readonly retryAfterSeconds: number
118
-
119
- commit(actual: number): Promise<void>
120
-
121
- release(): Promise<void>
122
- }
123
-
124
- export interface Quotas {
125
- reserve(actor: Actor, meter: string, estimate: number): Promise<QuotaHold>
126
-
127
- lower?(actor: Actor, meter: string, amount: number): Promise<void>
128
- }
129
-
130
- export interface Outbox {
131
- emit(actor: Actor, event: PlatformEvent): Promise<void>
132
- }
133
-
134
- export interface Transactional {
135
- transaction<T>(actor: Actor, fn: () => Promise<T>): Promise<T>
136
- }
137
-
138
- export function isTransactional(store: Store): store is Store & Transactional {
139
- return typeof (store as Partial<Transactional>).transaction === 'function'
140
- }
141
-
142
- export interface Job<T = unknown> {
143
- id: string
144
- kind: string
145
- payload: T
146
- attempts: number
147
-
148
- actor: Actor
149
- }
150
-
151
- export interface EnqueueOpts {
152
-
153
- runAt?: number
154
-
155
- dedupeKey?: string
156
- }
157
-
158
- export interface SchedulerSeam {
159
-
160
- readonly endpoint: string
161
-
162
- readonly secret: string
163
-
164
- register(app: { id: string; endpoint: string; secret: string }): Promise<void>
165
- schedule(call: {
166
- appId: string
167
- runAt: Date
168
- reason: string
169
- runId?: string
170
-
171
- dedupeKey?: string
172
- }): Promise<string>
173
- cancelForRun(appId: string, runId: string): Promise<void>
174
- }
175
-
176
- export interface Queue {
177
- enqueue<T>(actor: Actor, kind: string, payload: T, opts?: EnqueueOpts): Promise<string>
178
-
179
- poll(kinds: string[], limit: number, now: number): Promise<Job[]>
180
-
181
- ack(id: string): Promise<void>
182
-
183
- fail(id: string, error: string, now: number): Promise<void>
184
-
185
- deadLetter(id: string, error: string): Promise<void>
186
-
187
- deadLetters(): Promise<Job[]>
188
- }
189
-
190
- export interface Files {
191
-
192
- put(actor: Actor, key: string, body: Uint8Array, contentType: string): Promise<{ size: number }>
193
-
194
- get(actor: Actor, key: string): Promise<{ body: Uint8Array; contentType: string } | null>
195
-
196
- signedUrl(actor: Actor, key: string, expiresInSeconds: number): Promise<string>
197
-
198
- remove(actor: Actor, key: string): Promise<void>
199
- }
200
-
201
- export interface Clock {
202
-
203
- now(): number
204
- }
205
-
206
- export interface Random {
207
-
208
- next(): number
209
-
210
- uuid(): string
211
- }
212
-
213
- export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
214
-
215
- export interface HttpRequest {
216
-
217
- readonly target: string
218
-
219
- readonly address: string
220
- readonly method: HttpMethod
221
-
222
- readonly path: string
223
-
224
- readonly headers?: Readonly<Record<string, string>>
225
-
226
- readonly body?: Uint8Array
227
- readonly contentType?: string
228
-
229
- readonly idempotencyKey?: string
230
- }
231
-
232
- export interface HttpResponse {
233
- readonly status: number
234
- readonly headers: Readonly<Record<string, string>>
235
- readonly body: Uint8Array
236
-
237
- readonly bytesSent: number
238
- readonly bytesReceived: number
239
- readonly durationMs: number
240
- }
241
-
242
- export interface Http {
243
-
244
- call(request: HttpRequest): Promise<HttpResponse>
245
- }
246
-
247
- export interface Vault {
248
-
249
- resolve(refs: readonly string[]): Promise<Readonly<Record<string, string>>>
250
- }
251
-
252
- export interface Seams {
253
-
254
- store?: Store
255
- search?: Search
256
- events?: EventBus
257
- queue?: Queue
258
-
259
- telemetry?: Telemetry
260
- log: Log
261
- audit: Audit
262
- errors: Errors
263
- cost?: Cost
264
- idempotency?: Idempotency
265
- rateLimiter?: RateLimiter
266
-
267
- flush?: () => Promise<void>
268
-
269
- scheduler?: SchedulerSeam
270
-
271
- featureGate?: FeatureGate
272
-
273
- permits?: {
274
- check(
275
- actor: Actor,
276
- action: string,
277
- resource: Row | null,
278
- ): Promise<{ readonly allow: boolean; readonly because?: string }>
279
- }
280
- quotas?: Quotas
281
- outbox?: Outbox
282
-
283
- drainKick?: () => void
284
-
285
- vault?: Vault
286
-
287
- views?: Views
288
-
289
- clock: Clock
290
- random: Random
291
-
292
- files?: Files
293
-
294
- http?: Http
295
- }
296
-
297
- export type AuditOutcome = 'ok' | 'denied' | 'rate_limited' | 'failed' | 'feature_denied' | 'quota_exceeded'
298
-
299
- export function isRow(v: unknown): v is Row {
300
- return typeof v === 'object' && v !== null && typeof (v as { id?: unknown }).id === 'string'
301
- }
302
-
303
- export const SUPPLY = {
304
- sm_store: 'store',
305
- sm_search: 'search',
306
- sm_queue: 'queue',
307
- sm_events: 'events',
308
- sm_clock: 'clock',
309
- sm_random: 'random',
310
- sm_vault: 'vault',
311
- sm_views: 'views',
312
- sm_files: 'files',
313
- } as const satisfies Readonly<Record<string, keyof Seams>>
314
-
315
- export type Supplied = keyof typeof SUPPLY
316
-
317
- export const SUPPLIES: readonly Supplied[] = Object.keys(SUPPLY) as readonly Supplied[]
318
-
319
- export const supplies = (one: string): one is Supplied => one in SUPPLY
320
-
321
- export type Handed<R extends string = Supplied> = { readonly actor: Actor } & {
322
- readonly [K in R as K extends Supplied ? (typeof SUPPLY)[K] : K]: K extends Supplied
323
- ? NonNullable<Seams[(typeof SUPPLY)[K]]>
324
- : Readonly<
325
- Record<
326
- string,
327
- (given?: {
328
- readonly fills?: Readonly<Record<string, string | number>>
329
- readonly json?: unknown
330
- readonly body?: Uint8Array
331
- readonly contentType?: string
332
- }) => Promise<HttpResponse>
333
- >
334
- >
335
- }
336
-
337
- export type Reads<H> = Pick<H, Extract<keyof H, 'actor' | 'store' | 'search' | 'views'>>
338
-
339
- export const SAID: Readonly<Record<keyof Seams, string>> = {
340
- store: 'where rows are kept: insert, get, list, update and remove, bound to whoever asked',
341
- search: 'indexing a row and querying an index, for what cannot be found by id',
342
- events: 'announcing that something happened, to whoever is listening',
343
- queue: 'handing work to something else to run later',
344
- telemetry: 'the span opened around every run, and where it is recorded',
345
- log: 'the line written for every run: its outcome, who was allowed, what it spent',
346
- audit: 'the record of what was done, by whom, to what',
347
- errors: 'the record of every failure, by code and class',
348
- cost: 'metering what a run spent',
349
- idempotency: 'remembering an answer under its key, so a repeated request is answered once',
350
- rateLimiter: 'refusing a caller who asks too often',
351
- flush: 'what runs when the process is about to stop, so nothing buffered is lost',
352
- scheduler: 'registering this app with a scheduler and booking a later run',
353
- featureGate: 'refusing an operation the caller\'s plan does not include',
354
- permits: 'the gate every operation passes: who may ask for what, from the grants',
355
- quotas: 'reserving what a run may spend before it starts, and settling it after',
356
- outbox: 'events written with the transaction and published after it commits',
357
- drainKick: 'nudging the queue worker that work has arrived',
358
- vault: 'opening a secret by name at the moment of use',
359
- views: 'reading through a declared view rather than a table',
360
- clock: 'the current time',
361
- random: 'randomness: a number, a uuid',
362
- files: 'putting a file somewhere, fetching one back, handing out a signed link to one',
363
- http: 'how a call leaves the process, and what it comes back with',
364
- }
@@ -1,14 +0,0 @@
1
- import type { Actor } from '../core/actor.ts';
2
- export type Row = Record<string, unknown>;
3
- export type ReadField = `fld_${string}` | `rel_${string}` | (string & {});
4
- export type FieldList = readonly [ReadField, ...ReadField[]];
5
- export interface Store {
6
- insert(actor: Actor, entity: string, row: Row): Promise<Row>;
7
- get(actor: Actor, entity: string, key: string | number, fields: FieldList): Promise<Row | null>;
8
- list(actor: Actor, entity: string, opts?: {
9
- limit?: number;
10
- where?: Readonly<Record<string, string | number | boolean | null>>;
11
- }): Promise<Row[]>;
12
- update(actor: Actor, entity: string, key: string | number, patch: Record<string, unknown>, expectedVersion?: number): Promise<Row>;
13
- remove(actor: Actor, entity: string, key: string | number): Promise<void>;
14
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,29 +0,0 @@
1
- import type { Actor } from '../core/actor.ts'
2
-
3
- export type Row = Record<string, unknown>
4
-
5
- export type ReadField = `fld_${string}` | `rel_${string}` | (string & {})
6
-
7
- export type FieldList = readonly [ReadField, ...ReadField[]]
8
-
9
- export interface Store {
10
- insert(actor: Actor, entity: string, row: Row): Promise<Row>
11
-
12
- get(actor: Actor, entity: string, key: string | number, fields: FieldList): Promise<Row | null>
13
-
14
- list(
15
- actor: Actor,
16
- entity: string,
17
- opts?: { limit?: number; where?: Readonly<Record<string, string | number | boolean | null>> },
18
- ): Promise<Row[]>
19
-
20
- update(
21
- actor: Actor,
22
- entity: string,
23
- key: string | number,
24
- patch: Record<string, unknown>,
25
- expectedVersion?: number,
26
- ): Promise<Row>
27
-
28
- remove(actor: Actor, entity: string, key: string | number): Promise<void>
29
- }
File without changes
File without changes
File without changes