@drhomet/mithaq 0.0.0-stage → 0.1.1

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 (151) hide show
  1. package/LICENSE +22 -0
  2. package/LICENSES/payload.txt +22 -0
  3. package/LICENSES/ponytail.txt +21 -0
  4. package/dist/asas/actor.d.ts +96 -0
  5. package/dist/asas/actor.js +114 -0
  6. package/dist/asas/build.d.ts +231 -0
  7. package/dist/asas/build.js +787 -0
  8. package/dist/asas/cli/mithaq.d.ts +2 -0
  9. package/dist/asas/cli/mithaq.js +145 -0
  10. package/dist/asas/cli/upgrade.d.ts +20 -0
  11. package/dist/asas/cli/upgrade.js +147 -0
  12. package/dist/asas/http/fetch.d.ts +23 -0
  13. package/dist/asas/http/fetch.js +115 -0
  14. package/dist/asas/http/orpc.d.ts +43 -0
  15. package/dist/asas/http/orpc.js +135 -0
  16. package/dist/asas/runner/bulk.d.ts +20 -0
  17. package/dist/asas/runner/bulk.js +191 -0
  18. package/dist/asas/runner/errors.d.ts +60 -0
  19. package/dist/asas/runner/errors.js +59 -0
  20. package/dist/asas/runner/read.d.ts +68 -0
  21. package/dist/asas/runner/read.js +579 -0
  22. package/dist/asas/runner/runtime.d.ts +21 -0
  23. package/dist/asas/runner/runtime.js +8 -0
  24. package/dist/asas/runner/steps.d.ts +400 -0
  25. package/dist/asas/runner/steps.js +271 -0
  26. package/dist/asas/runner/tenant.d.ts +54 -0
  27. package/dist/asas/runner/tenant.js +213 -0
  28. package/dist/asas/runner/write.d.ts +444 -0
  29. package/dist/asas/runner/write.js +791 -0
  30. package/dist/auth/better-auth/access.d.ts +15 -0
  31. package/dist/auth/better-auth/access.js +71 -0
  32. package/dist/auth/better-auth/generate.d.ts +29 -0
  33. package/dist/auth/better-auth/generate.js +310 -0
  34. package/dist/auth/better-auth/index.d.ts +92 -0
  35. package/dist/auth/better-auth/index.js +81 -0
  36. package/dist/auth/better-auth/tenant.d.ts +18 -0
  37. package/dist/auth/better-auth/tenant.js +26 -0
  38. package/dist/auth/local/index.d.ts +285 -0
  39. package/dist/auth/local/index.js +736 -0
  40. package/dist/base/decimal.d.ts +9 -0
  41. package/dist/base/decimal.js +16 -0
  42. package/dist/base/fields.d.ts +123 -0
  43. package/dist/base/fields.js +51 -0
  44. package/dist/base/index.d.ts +46 -0
  45. package/dist/base/index.js +5 -0
  46. package/dist/base/kinds.d.ts +54 -0
  47. package/dist/base/kinds.js +78 -0
  48. package/dist/base/rules.d.ts +73 -0
  49. package/dist/base/rules.js +80 -0
  50. package/dist/drizzle/index.d.ts +438 -0
  51. package/dist/drizzle/index.js +832 -0
  52. package/dist/drizzle/kinds.d.ts +27 -0
  53. package/dist/drizzle/kinds.js +41 -0
  54. package/dist/drizzle/migrate.d.ts +133 -0
  55. package/dist/drizzle/migrate.js +1285 -0
  56. package/dist/drizzle/proxy/index.d.ts +1 -0
  57. package/dist/drizzle/proxy/index.js +1 -0
  58. package/dist/drizzle/proxy/node-postgres.d.ts +1 -0
  59. package/dist/drizzle/proxy/node-postgres.js +1 -0
  60. package/dist/drizzle/proxy/pg-core.d.ts +1 -0
  61. package/dist/drizzle/proxy/pg-core.js +1 -0
  62. package/dist/drizzle/rules.d.ts +336 -0
  63. package/dist/drizzle/rules.js +44 -0
  64. package/dist/index.d.ts +45 -0
  65. package/dist/index.js +36 -0
  66. package/dist/mithaq/define.d.ts +288 -0
  67. package/dist/mithaq/define.js +43 -0
  68. package/dist/mithaq/generate-messages.d.ts +38 -0
  69. package/dist/mithaq/generate-messages.js +234 -0
  70. package/dist/mithaq/language.d.ts +335 -0
  71. package/dist/mithaq/language.js +76 -0
  72. package/dist/mithaq/lock.d.ts +71 -0
  73. package/dist/mithaq/lock.js +329 -0
  74. package/dist/mithaq/messages.d.ts +55 -0
  75. package/dist/mithaq/messages.js +106 -0
  76. package/dist/mithaq/refusal.d.ts +6 -0
  77. package/dist/mithaq/refusal.js +6 -0
  78. package/dist/mithaq/resolve.d.ts +10 -0
  79. package/dist/mithaq/resolve.js +954 -0
  80. package/dist/mithaq/rows.d.ts +87 -0
  81. package/dist/mithaq/rows.js +174 -0
  82. package/dist/mithaq/rukn.d.ts +72 -0
  83. package/dist/mithaq/rukn.js +15 -0
  84. package/dist/mithaq/standard-schema.d.ts +38 -0
  85. package/dist/mithaq/standard-schema.js +2 -0
  86. package/dist/mithaq/types.d.ts +358 -0
  87. package/dist/mithaq/types.js +15 -0
  88. package/dist/mithaq/user.d.ts +19 -0
  89. package/dist/mithaq/user.js +16 -0
  90. package/dist/mithaq/where.d.ts +32 -0
  91. package/dist/mithaq/where.js +87 -0
  92. package/dist/rbac/index.d.ts +105 -0
  93. package/dist/rbac/index.js +182 -0
  94. package/dist/rbac/steps.d.ts +22 -0
  95. package/dist/rbac/steps.js +161 -0
  96. package/dist/rich-text/index.d.ts +27 -0
  97. package/dist/rich-text/index.js +58 -0
  98. package/dist/rich-text/rich-text.d.ts +159 -0
  99. package/dist/rich-text/rich-text.js +372 -0
  100. package/dist/screen/client.d.ts +153 -0
  101. package/dist/screen/client.js +68 -0
  102. package/dist/screen/generate.d.ts +14 -0
  103. package/dist/screen/generate.js +226 -0
  104. package/dist/screen/index.d.ts +479 -0
  105. package/dist/screen/index.js +645 -0
  106. package/dist/screen/react.d.ts +95 -0
  107. package/dist/screen/react.js +58 -0
  108. package/dist/screen/studio.d.ts +24 -0
  109. package/dist/screen/studio.js +68 -0
  110. package/dist/service/index.d.ts +63 -0
  111. package/dist/service/index.js +15 -0
  112. package/dist/storage/allowed-type.d.ts +5 -0
  113. package/dist/storage/allowed-type.js +7 -0
  114. package/dist/storage/index.d.ts +43 -0
  115. package/dist/storage/index.js +44 -0
  116. package/dist/storage/storage.d.ts +384 -0
  117. package/dist/storage/storage.js +405 -0
  118. package/dist/versions/index.d.ts +37 -0
  119. package/dist/versions/index.js +8 -0
  120. package/dist/versions/versions.d.ts +104 -0
  121. package/dist/versions/versions.js +160 -0
  122. package/dist/zod/index.d.ts +184 -0
  123. package/dist/zod/index.js +121 -0
  124. package/dist/zod/kinds.d.ts +34 -0
  125. package/dist/zod/kinds.js +49 -0
  126. package/dist/zod/rules.d.ts +117 -0
  127. package/dist/zod/rules.js +67 -0
  128. package/package.json +63 -4
  129. package/r/mithaq-cells.json +20 -0
  130. package/r/mithaq-controls.json +37 -0
  131. package/r/mithaq-directional-icon.json +15 -0
  132. package/r/mithaq-expected-updated-at.json +15 -0
  133. package/r/mithaq-field-shell.json +18 -0
  134. package/r/mithaq-filter-operators.json +15 -0
  135. package/r/mithaq-form.json +33 -0
  136. package/r/mithaq-list-columns.json +23 -0
  137. package/r/mithaq-list-filters.json +24 -0
  138. package/r/mithaq-list-pagination.json +24 -0
  139. package/r/mithaq-list-query.json +18 -0
  140. package/r/mithaq-list-selection.json +19 -0
  141. package/r/mithaq-list.json +33 -0
  142. package/r/mithaq-nav.json +24 -0
  143. package/r/mithaq-nodes.json +34 -0
  144. package/r/mithaq-relationship-cell.json +20 -0
  145. package/r/mithaq-relationship-control.json +20 -0
  146. package/r/mithaq-rich-text.json +40 -0
  147. package/r/mithaq-screens-host.json +96 -0
  148. package/r/mithaq-storage.json +44 -0
  149. package/r/mithaq-upload.json +29 -0
  150. package/r/registry.json +550 -0
  151. package/README.md +0 -3
@@ -0,0 +1,400 @@
1
+ import type { StandardSchemaIssue, StandardSchemaV1 } from '../../mithaq/standard-schema.ts';
2
+ import type { BoundOf } from './write.ts';
3
+ import type { Where } from '../../mithaq/where.ts';
4
+ import type { ResolvedKayan, RuntimeField, ServiceOf } from '../../mithaq/types.ts';
5
+ import type { Store } from '../../mithaq/language.ts';
6
+ /**
7
+ * What the caller passed, plus the three keys the runner keeps. `Extra` is the service target's
8
+ * `context`, so a project reads its own keys typed. Held in an `AsyncLocalStorage`, so nested writes are counted.
9
+ */
10
+ export type Context<Extra extends Record<string, unknown> = Record<string, unknown>> = {
11
+ /** How many writes deep this one is. The runner raises it by one. */
12
+ depth: number;
13
+ /** What started the write. A call in the app is `local`. */
14
+ source: string;
15
+ /** `${kayan}.${operation}` per write, so one past the cap can name its way in. */
16
+ chain: string[];
17
+ } & Extra;
18
+ /** What a step is handed. No `db`: a step writes through `ctx.tx`, so it cannot land outside the list's transaction. */
19
+ export type Ctx<Data = Record<string, unknown>, Actor = unknown, Tx = unknown, Extra extends Record<string, unknown> = Record<string, unknown>> = {
20
+ kayan: ResolvedKayan;
21
+ /** The write's values, and after the store step the row that was written. */
22
+ data: Data;
23
+ /** Whoever the write was given, or null. */
24
+ actor: Actor;
25
+ /** Same user as `actor`, named like access callbacks. */
26
+ user: Actor;
27
+ /** The row loaded before an update or delete; `undefined` in `beforeTransaction`, which runs before the load. */
28
+ dataBefore?: Readonly<Record<string, unknown>>;
29
+ /** The persisted row currently known to the runner. */
30
+ dataAfter?: Readonly<Record<string, unknown>>;
31
+ /** The store's transaction. Every write in the list goes through it. */
32
+ tx: Tx;
33
+ context: Context<Extra>;
34
+ };
35
+ /** The keys the project put on the service target's `context`, or the open record where it put none. */
36
+ export type ContextOf<Service> = Service extends {
37
+ context: infer Extra extends Record<string, unknown>;
38
+ } ? Extra : Record<string, unknown>;
39
+ /** What a step of this project is handed: `Ctx` with the project's context filled in. */
40
+ export type CtxOf<Service, Data = Record<string, unknown>, Actor = unknown, Tx = unknown> = Ctx<Data, Actor, Tx, ContextOf<Service>>;
41
+ /** The audit sink the `audit` step calls before commit. */
42
+ export type AuditHandler<Actor = unknown, Tx = unknown> = (entry: {
43
+ context: Context;
44
+ effect: OperationEffect;
45
+ kayan: ResolvedKayan;
46
+ operation: string;
47
+ dataBefore?: Readonly<Record<string, unknown>>;
48
+ dataAfter: unknown;
49
+ store?: Pick<Store, 'insert' | 'remove' | 'update'>;
50
+ tx?: Tx;
51
+ user: Actor | null;
52
+ }) => void | Promise<void>;
53
+ export type CommonTools<Kayans = unknown, Actor = unknown, Tx = unknown> = {
54
+ /** The key this list sits under in the `operations` record. */
55
+ operation: string;
56
+ /** The shape this operation parses against: its validate function's, or the derived one. */
57
+ schema: StandardSchemaV1;
58
+ /** Final row boundary, applied after every step so public row types are proved. */
59
+ output: StandardSchemaV1;
60
+ /** Custom output schemas are public contracts and run after masking. */
61
+ publicOutput?: StandardSchemaV1;
62
+ /** Managed nested calls bound to the runner's current user, context and transaction. */
63
+ kayans: Kayans;
64
+ /** Optional audit sink configured on the service target. */
65
+ audit?: AuditHandler<Actor, Tx>;
66
+ /** Every permission key this project has, as `asas.catalog` publishes it; empty where none was handed over, which refuses every key. */
67
+ catalog: readonly string[];
68
+ };
69
+ /** What a read step can do: run the managed read fetcher. No write store exists. */
70
+ export type ReadTools<Kayans = unknown, Actor = unknown, Tx = unknown> = CommonTools<Kayans, Actor, Tx> & {
71
+ /** The public access callback this operation uses. */
72
+ effect: 'read';
73
+ /** What the list's managed read step does: one row, or a page of them. */
74
+ kind: ReadMode;
75
+ /** Managed read fetcher, present only for read steps. */
76
+ read: (data: unknown) => Promise<unknown>;
77
+ /** One kayan's read operations out of `kayans`, found by the declaration rather than by its name. */
78
+ of: BoundOf<'read'>;
79
+ };
80
+ /** What a write step can do: call the protected writes already bound to a transaction. */
81
+ export type WriteTools<Kayans = unknown, Actor = unknown, Tx = unknown> = CommonTools<Kayans, Actor, Tx> & {
82
+ /** The public access callback this operation uses. */
83
+ effect: Exclude<OperationEffect, 'read'>;
84
+ /** What the list's store step does. A bulk word means `bulk` runs the list. */
85
+ kind: 'deleteMany' | 'insert' | 'remove' | 'update' | 'updateMany';
86
+ /** One kayan's bound operations, found and typed by the declaration handed in, so a step imports the kayan it calls. */
87
+ of: BoundOf<'write'>;
88
+ /** The store's three writes, each bound, and the store itself is not here. */
89
+ store: Pick<Store, 'insert' | 'remove' | 'update'>;
90
+ /** Access constraint already granted for this operation, if access returned one. */
91
+ where?: Where;
92
+ /** The keys the caller's own object carried, read before any step ran, so validation can tell the runner's values from the caller's. */
93
+ sent?: readonly string[];
94
+ /** The shape a global's update parses against when there is no row yet, and a publish of a never-published row. */
95
+ insertSchema?: StandardSchemaV1;
96
+ /** The shape a draft save parses against and a draft is read back through: every field's kind, nullable and optional, no rules. */
97
+ draftSchema?: StandardSchemaV1;
98
+ /** The draft save's shape where it differs from `draftSchema`: a kind may check a written value harder than a stored one. */
99
+ draftWrite?: StandardSchemaV1;
100
+ /** What a draft save of an insert with its own `input` parses against: that input over the draft shape. */
101
+ draftInput?: StandardSchemaV1;
102
+ /** Runs the single-row write once per row the `where` matched, in this transaction; present only for a bulk list. */
103
+ many?: (data: Record<string, unknown>) => Promise<BulkResult>;
104
+ };
105
+ /**
106
+ * What a bulk operation answers. All or nothing in one transaction, so no row is in `errors` because
107
+ * its write failed; `errors` lists the unpublished rows the `where` names, for an actor who may read drafts.
108
+ */
109
+ export type BulkResult<Doc = Record<string, unknown>> = {
110
+ docs: Doc[];
111
+ errors: {
112
+ id: unknown;
113
+ message: string;
114
+ }[];
115
+ };
116
+ export type Tools = ReadTools | WriteTools;
117
+ /** The positions `resolve` checks: the store and read steps, each named after the `Store` method it calls. */
118
+ export type Seal = 'audit' | 'count' | 'defaults' | 'deleteMany' | 'find' | 'findOne' | 'insert' | 'remove' | 'update' | 'updateMany' | 'validate' | 'findVersions' | 'findVersionByID' | 'restoreVersion';
119
+ type Holds<Name extends Seal> = {
120
+ readonly __seal: Name;
121
+ };
122
+ type AnyStep<Input extends Record<string, unknown> = Record<string, unknown>, Output extends Record<string, unknown> = Input, Actor = unknown, Tx = unknown, GivenTools = Tools, Extra extends Record<string, unknown> = Record<string, unknown>> = {
123
+ (ctx: Ctx<Input, Actor, Tx, Extra>, tools: GivenTools): Ctx<Output, Actor, Tx> | Promise<Ctx<Output, Actor, Tx>>;
124
+ };
125
+ export type CommonStep<Input extends Record<string, unknown> = Record<string, unknown>, Output extends Record<string, unknown> = Input, Actor = unknown, Tx = unknown, Kayans = unknown, Extra extends Record<string, unknown> = Record<string, unknown>> = AnyStep<Input, Output, Actor, Tx, ReadTools<Kayans, Actor, Tx> | WriteTools<Kayans, Actor, Tx>, Extra>;
126
+ export type ReadStep<Input extends Record<string, unknown> = Record<string, unknown>, Output extends Record<string, unknown> = Input, Actor = unknown, Tx = unknown, Kayans = unknown, Extra extends Record<string, unknown> = Record<string, unknown>> = AnyStep<Input, Output, Actor, Tx, ReadTools<Kayans, Actor, Tx>, Extra>;
127
+ export type WriteStep<Input extends Record<string, unknown> = Record<string, unknown>, Output extends Record<string, unknown> = Input, Actor = unknown, Tx = unknown, Kayans = unknown, Extra extends Record<string, unknown> = Record<string, unknown>> = AnyStep<Input, Output, Actor, Tx, WriteTools<Kayans, Actor, Tx>, Extra>;
128
+ export type Step<Input extends Record<string, unknown> = Record<string, unknown>, Output extends Record<string, unknown> = Input, Actor = unknown, Tx = unknown, Kayans = unknown, Extra extends Record<string, unknown> = Record<string, unknown>> = CommonStep<Input, Output, Actor, Tx, Kayans, Extra>;
129
+ /** Any of the three, at one context. `never` is the bound a resolved list is stored at, which every project's list fits. */
130
+ export type OperationStep<Extra extends Record<string, unknown> = Record<string, unknown>> = Step<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Extra> | ReadStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Extra> | WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Extra>;
131
+ /** The six shapes a schema target derives from a kayan's fields, each a Standard Schema. */
132
+ export type DerivedShapes<Schema extends StandardSchemaV1 = StandardSchemaV1> = {
133
+ /** Every field, with the id optional: what a list that makes the row parses. */
134
+ create: Schema;
135
+ /** The same shape partial, with the id required: what a list that finds it parses. */
136
+ update: Schema;
137
+ /** The id alone and no other key: what `delete` parses, and what a version is addressed by. */
138
+ id: Schema;
139
+ /** The `id` shape with an optional `depth`: what `findByID` parses. */
140
+ byID: Schema;
141
+ /** The row that comes back, every column present. */
142
+ row: Schema;
143
+ /** What a list read or a bulk with no schema of its own parses: the page query and a bulk's `data`. */
144
+ list: Schema;
145
+ /** What a draft save parses and a draft is read back through: every field's kind alone, nullable and optional. */
146
+ draft?: Schema;
147
+ /** What a draft save parses where it differs from `draft`: each kind checks a written value as a write does. */
148
+ draftWrite?: Schema;
149
+ };
150
+ /**
151
+ * One schema target's derivation as a type: a target extends this with `shapes` reading `FieldsOf<this>`.
152
+ * Needed because a conditional type cannot instantiate `derive`'s generic signature.
153
+ */
154
+ export interface Derives {
155
+ /** One kayan's fields, `unknown` so filling it in replaces rather than narrows it. */
156
+ readonly fields: unknown;
157
+ /** The six shapes that target derives from them. */
158
+ readonly shapes: DerivedShapes;
159
+ }
160
+ /** The fields a target reads off itself, at the constraint every field record has. */
161
+ export type FieldsOf<Of extends Derives> = Extract<Of['fields'], Record<string, RuntimeField>>;
162
+ /** The shapes one schema target returns for one kayan's fields, typed by that target. */
163
+ export type DerivedSchemas<Schema = unknown, Fields extends Record<string, RuntimeField> = Record<string, RuntimeField>> = Schema extends {
164
+ derives?: infer Of extends Derives;
165
+ } ? (Of & {
166
+ readonly fields: Fields;
167
+ })['shapes'] : DerivedShapes;
168
+ /** The shapes the language's own schema target derives. */
169
+ export type SchemasOf<L, Fields extends Record<string, RuntimeField> = Record<string, RuntimeField>> = L extends {
170
+ targets: infer Targets;
171
+ } ? ServiceOf<L> extends {
172
+ schema: infer Name;
173
+ } ? Name extends keyof Targets ? DerivedSchemas<Targets[Name], Fields> : DerivedShapes : DerivedShapes : DerivedShapes;
174
+ export type OperationEffect = 'create' | 'read' | 'update' | 'delete';
175
+ /** What a managed read returns: one row, a page, `{ totalDocs }`, or one version or a page of them. */
176
+ export type ReadMode = 'count' | 'many' | 'one' | 'version' | 'versions';
177
+ type RowOutput = StandardSchemaV1<unknown, Record<string, unknown>>;
178
+ /** A list of all read steps or all write steps; a mixed one is refused where it is written. */
179
+ export type OperationSteps<Data extends Record<string, unknown> = Record<string, unknown>, Extra extends Record<string, unknown> = Record<string, unknown>> = readonly ReadStep<Data, Record<string, unknown>, unknown, unknown, unknown, Extra>[] | readonly WriteStep<Data, Record<string, unknown>, unknown, unknown, unknown, Extra>[];
180
+ export declare const atEffect: <Held extends OperationStep<never>>(list: readonly OperationStep<never>[]) => readonly Held[];
181
+ /** The lists a steps function is handed, one per operation the language has. */
182
+ export type Lists = Record<string, OperationSteps>;
183
+ /** The steps of one declaration, whether it was written as a list or as a function. */
184
+ export type StepsOf<Declaration> = Declaration extends {
185
+ steps: infer Given;
186
+ } ? Given extends (...args: never[]) => infer Returned ? Returned : Given : never;
187
+ /**
188
+ * What a steps or operations function is handed: the shipped lists by operation name, the sealed steps
189
+ * by `Store` method, and the service target's three slots: `afterSteps: ({ afterSteps }) => [...afterSteps, notify]`.
190
+ */
191
+ export type OperationDefaults<Given = Lists> = {
192
+ operations: Given;
193
+ steps: Sealed;
194
+ beforeSteps: readonly CommonStep[];
195
+ afterSteps: readonly CommonStep[];
196
+ afterCommit: readonly CommonStep[];
197
+ };
198
+ /** One of the three lists an operation may write beside `steps`, at the project's context. */
199
+ export type SlotSteps<Given = Lists, Extra extends Record<string, unknown> = Record<string, unknown>> = OperationSteps<Record<string, unknown>, Extra> | ((defaults: OperationDefaults<Given>) => OperationSteps<Record<string, unknown>, Extra>);
200
+ /** An operation: data, or a function of the defaults that returns data, run once where it is declared. */
201
+ export type OperationDeclaration<Given = Lists, Schemas = DerivedShapes, Locale extends string = string, Input = never,
202
+ /** What this operation parses, which is `ctx.data` in every step. */
203
+ Data extends Record<string, unknown> = Record<string, unknown>,
204
+ /** The keys the project declared on its runner's `context`. */
205
+ Extra extends Record<string, unknown> = Record<string, unknown>> = {
206
+ /** The shape this operation parses, once, before the first step. Without it, the shape its store or read step implies. */
207
+ input?: (schemas: Schemas) => StandardSchemaV1;
208
+ /** The list: exactly one store or managed read step and whatever surrounds it. `defaults`, `validate` and `audit` here are refused. */
209
+ steps: OperationSteps<Data, Extra> | ((defaults: OperationDefaults<Given>) => OperationSteps<Data, Extra>);
210
+ /** Outside the transaction, before it opens: no lock is held and `ctx.dataBefore` is `undefined`. Not on a read. */
211
+ beforeTransaction?: SlotSteps<Given, Extra>;
212
+ /** Inside the transaction after the list, where `audit` runs. Replaces the service target's for this operation. */
213
+ afterSteps?: SlotSteps<Given, Extra>;
214
+ /** Outside the transaction, after the commit, where a webhook or an email belongs. A throw leaves the write standing and answers `AfterCommitError`. */
215
+ afterCommit?: SlotSteps<Given, Extra>;
216
+ /** A public output contract, parsed after field masking. */
217
+ output?: RowOutput | ((schemas: Schemas) => RowOutput);
218
+ /** One entry per target with something to say about this operation, by the target's name: `targets.<screen>` is what that screen's button asks for. */
219
+ targets?: Readonly<Record<string, OperationScreen<Input> | undefined>>;
220
+ };
221
+ /** What a screen's button over one of a kayan's own operations asks for. */
222
+ export type OperationScreen<Input = RuntimeField> = {
223
+ /**
224
+ * What the button's dialog asks for beyond the row's id, as fields. Chrome, not the contract:
225
+ * `input` stays the shape; a field it names no key for fails the build.
226
+ */
227
+ readonly fields?: Readonly<Record<string, Input>>;
228
+ };
229
+ /** A declaration whatever lists its steps function was typed against. */
230
+ export type AnyOperation = {
231
+ input?: (schemas: never) => StandardSchemaV1;
232
+ steps: OperationSteps<never, never> | ((defaults: never) => OperationSteps<never, never>);
233
+ /** The three slots at the same bound `steps` above is held at, and for the same reason. */
234
+ beforeTransaction?: OperationSteps<never, never> | ((defaults: never) => OperationSteps<never, never>);
235
+ afterSteps?: OperationSteps<never, never> | ((defaults: never) => OperationSteps<never, never>);
236
+ afterCommit?: OperationSteps<never, never> | ((defaults: never) => OperationSteps<never, never>);
237
+ output?: RowOutput | ((schemas: never) => RowOutput);
238
+ targets?: Readonly<Record<string, OperationScreen | undefined>>;
239
+ };
240
+ export type Operations<Given = Lists, Schemas = DerivedShapes, Locale extends string = string, Input = never> = {
241
+ [operation: string]: OperationDeclaration<Given, Schemas, Locale, Input> | undefined;
242
+ };
243
+ /** An operation after `resolve` has run its steps function and read its effect. */
244
+ export type ResolvedOperation = {
245
+ /** The shape function this operation named, held until `build` has the derived shapes. */
246
+ input?: (schemas: never) => StandardSchemaV1;
247
+ /** The lists, at the context bound every project's own is inside. */
248
+ steps: readonly OperationStep<never>[];
249
+ /** The four lists around the steps, each already merged with the language's. */
250
+ beforeTransaction: readonly OperationStep<never>[];
251
+ beforeSteps: readonly OperationStep<never>[];
252
+ afterSteps: readonly OperationStep<never>[];
253
+ afterCommit: readonly OperationStep<never>[];
254
+ effect: OperationEffect;
255
+ mode?: ReadMode;
256
+ /** Always a schema: an `output` written as a function is resolved at build. */
257
+ output?: RowOutput;
258
+ /** What each target says about this operation, as the declaration wrote it. */
259
+ targets?: Readonly<Record<string, OperationScreen | undefined>>;
260
+ };
261
+ /** What position this step holds, or nothing at all for a step of the app's own. */
262
+ export declare const sealOf: (step: OperationStep<never>) => Seal | undefined;
263
+ /** Hold an operation's `output` function until `build` has the derived shapes. */
264
+ export declare const holdOutput: (operation: ResolvedOperation, of: (schemas: never) => RowOutput) => void;
265
+ /** The schema function this operation's `output` carries, or nothing for a bare schema. */
266
+ export declare const outputOf: (operation: ResolvedOperation) => ((schemas: never) => RowOutput) | undefined;
267
+ /** The list's store step, the one that makes, changes or removes the row. */
268
+ export declare const storeSeals: readonly Seal[];
269
+ export declare const readSeals: readonly Seal[];
270
+ export declare const bulkSeals: readonly Seal[];
271
+ export declare const versionSeals: readonly Seal[];
272
+ /** The read no actor holds, which a secret column carries. One function, so a column is known by it. */
273
+ export declare const neverRead: () => boolean;
274
+ /**
275
+ * The audit step a project lists in the service target's `afterSteps`. A step after the store
276
+ * that changes persistence must return the persisted row in `ctx.data`. Listing it without a sink fails the build.
277
+ */
278
+ export declare const audit: CommonStep & Holds<'audit'>;
279
+ /**
280
+ * Fills what the write left out. On a list that only changes a row only `nowOnUpdate` fields
281
+ * are filled, or `createdAt` would take the edit's moment. The runner runs it; a list naming it is refused.
282
+ */
283
+ export declare const defaults: WriteStep & Holds<'defaults'>;
284
+ /** The refusal a list of Standard Schema issues becomes, shared by the parse and the oRPC boundary so every 400 has one shape. */
285
+ export declare const issueRefusal: (issues: readonly StandardSchemaIssue[], vendor?: string) => import("./errors.ts").AsasError;
286
+ /** A plain object copied without a prototype, because zod reads an unsent key off the prototype. */
287
+ export declare const withoutPrototype: (value: unknown) => any;
288
+ /** Validates through Standard Schema's own `validate`, sync or async, never one library's `parse`. */
289
+ export declare const validated: (schema: StandardSchemaV1, value: unknown) => Promise<unknown>;
290
+ /**
291
+ * The runner's parse. A field the client does not supply is absent from the wire shape, so a value the
292
+ * runner put there is set aside, the rest parsed, and the set-aside values put back. `id` is never set aside.
293
+ */
294
+ export declare const parse: ({ schema, ctx, tools }: {
295
+ schema: StandardSchemaV1;
296
+ ctx: Ctx;
297
+ tools: ParseTools;
298
+ }) => Promise<Ctx>;
299
+ export type ParseTools = Pick<CommonTools, 'schema'> & Partial<Pick<WriteTools, 'sent'>> & {
300
+ kind?: ReadMode | WriteTools['kind'];
301
+ };
302
+ /** A marker, refused by name in a list: the parse is the runner's own. The shape it carried is the operation's `input`. */
303
+ export declare const validate: CommonStep & Holds<'validate'> & ((of?: unknown) => CommonStep);
304
+ /** Make the row, and what came back is what the rest of the list sees. */
305
+ export declare const insert: WriteStep & Holds<'insert'>;
306
+ /** Change the one row the id names; everything else in `data` is the change. An id alone is refused with a 400. */
307
+ export declare const update: WriteStep & Holds<'update'>;
308
+ /** Remove the one row the id names, and hand back what was removed. */
309
+ export declare const remove: WriteStep & Holds<'remove'>;
310
+ /**
311
+ * Change every row the `where` matches. A wrapper of its own, because a seal is keyed on
312
+ * the step object and two seals on one object would answer for both.
313
+ */
314
+ export declare const updateMany: WriteStep & Holds<'updateMany'>;
315
+ /** Remove every row the `where` matches, or mark it where the language names a soft delete. */
316
+ export declare const deleteMany: WriteStep & Holds<'deleteMany'>;
317
+ /** One row, the way `Store.find` with a limit of one answers for it. */
318
+ export declare const findOne: ReadStep & Holds<'findOne'>;
319
+ /** A paginated page of rows. */
320
+ export declare const find: ReadStep & Holds<'find'>;
321
+ /** How many rows the `where` matches, as `{ totalDocs }`, through the store's own `count` where it has one. */
322
+ export declare const count: ReadStep & Holds<'count'>;
323
+ /** A page of one kayan's versions, read through the row's own read access. */
324
+ export declare const findVersions: ReadStep & Holds<'findVersions'>;
325
+ /** One version by its own id. */
326
+ export declare const findVersionByID: ReadStep & Holds<'findVersionByID'>;
327
+ /** Write one version back to its row; the runner turns it into the row's own update before anything is asked. */
328
+ export declare const restoreVersion: WriteStep & Holds<'restoreVersion'>;
329
+ declare const sealedSteps: {
330
+ audit: CommonStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"audit">;
331
+ count: ReadStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"count">;
332
+ defaults: WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"defaults">;
333
+ deleteMany: WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"deleteMany">;
334
+ find: ReadStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"find">;
335
+ findOne: ReadStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"findOne">;
336
+ findVersionByID: ReadStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"findVersionByID">;
337
+ findVersions: ReadStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"findVersions">;
338
+ insert: WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"insert">;
339
+ remove: WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"remove">;
340
+ restoreVersion: WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"restoreVersion">;
341
+ update: WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"update">;
342
+ updateMany: WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"updateMany">;
343
+ validate: CommonStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"validate"> & ((of?: unknown) => CommonStep);
344
+ };
345
+ export type Sealed = Omit<typeof sealedSteps, 'audit' | 'defaults' | 'validate'>;
346
+ /** The shipped lists a kayan spreads into its own `targets.service.operations`: `operations: { ...defaultOperations, archive }`. */
347
+ export declare const defaultOperations: {
348
+ create: {
349
+ steps: (WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"insert">)[];
350
+ };
351
+ update: {
352
+ steps: (WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"update">)[];
353
+ };
354
+ delete: {
355
+ steps: (WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"remove">)[];
356
+ };
357
+ find: {
358
+ steps: (ReadStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"find">)[];
359
+ };
360
+ findByID: {
361
+ steps: (ReadStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"findOne">)[];
362
+ };
363
+ count: {
364
+ steps: (ReadStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"count">)[];
365
+ };
366
+ updateMany: {
367
+ steps: (WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"updateMany">)[];
368
+ };
369
+ deleteMany: {
370
+ steps: (WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"deleteMany">)[];
371
+ };
372
+ };
373
+ /** The two lists a global spreads into its own `targets.service.operations`: `findOne` and `update`. */
374
+ export declare const defaultGlobalOperations: {
375
+ update: {
376
+ steps: (WriteStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"update">)[];
377
+ };
378
+ findOne: {
379
+ input: () => StandardSchemaV1<{
380
+ depth?: number;
381
+ }>;
382
+ steps: (ReadStep<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, Record<string, unknown>> & Holds<"findOne">)[];
383
+ };
384
+ };
385
+ /** The lists the shipped record carries, as a steps function is handed them. */
386
+ export type DefaultLists = {
387
+ [Name in keyof typeof defaultOperations]: StepsOf<(typeof defaultOperations)[Name]>;
388
+ };
389
+ /** Any operations record, whatever lists its steps functions were typed against. */
390
+ type DeclaredOperations = Record<string, AnyOperation | undefined>;
391
+ /** A step of the runner's own three lists. `serviceTarget` narrows it to the context the same target declares. */
392
+ export type ProjectStep = Step<Record<string, unknown>, Record<string, unknown>, unknown, unknown, unknown, never>;
393
+ /** The language's own three lists, as an operation's function of one is handed them. */
394
+ export type LanguageSlots = {
395
+ beforeSteps?: readonly ProjectStep[];
396
+ afterSteps?: readonly ProjectStep[];
397
+ afterCommit?: readonly ProjectStep[];
398
+ };
399
+ export declare const resolveOperations: (declared: DeclaredOperations | ((defaults: never) => DeclaredOperations) | undefined, slots?: LanguageSlots) => Record<string, AnyOperation>;
400
+ export {};