@vibeorm/runtime 1.3.0 → 2.0.0-alpha.10

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 (96) hide show
  1. package/README.md +50 -107
  2. package/dist/adapter.d.ts +250 -0
  3. package/dist/adapter.d.ts.map +1 -0
  4. package/dist/bulk-upsert.d.ts +282 -0
  5. package/dist/bulk-upsert.d.ts.map +1 -0
  6. package/dist/client.d.ts +200 -0
  7. package/dist/client.d.ts.map +1 -0
  8. package/dist/codecs.d.ts +170 -0
  9. package/dist/codecs.d.ts.map +1 -0
  10. package/dist/computed.d.ts +43 -0
  11. package/dist/computed.d.ts.map +1 -0
  12. package/dist/db-now.d.ts +41 -0
  13. package/dist/db-now.d.ts.map +1 -0
  14. package/dist/diagnostics/index.d.ts +12 -0
  15. package/dist/diagnostics/index.d.ts.map +1 -0
  16. package/dist/diagnostics/insight.d.ts +63 -0
  17. package/dist/diagnostics/insight.d.ts.map +1 -0
  18. package/dist/diagnostics/plan.d.ts +88 -0
  19. package/dist/diagnostics/plan.d.ts.map +1 -0
  20. package/dist/diagnostics/preview.d.ts +43 -0
  21. package/dist/diagnostics/preview.d.ts.map +1 -0
  22. package/dist/diagnostics/types.d.ts +223 -0
  23. package/dist/diagnostics/types.d.ts.map +1 -0
  24. package/dist/diagnostics/workload.d.ts +32 -0
  25. package/dist/diagnostics/workload.d.ts.map +1 -0
  26. package/dist/extensions.d.ts +102 -0
  27. package/dist/extensions.d.ts.map +1 -0
  28. package/dist/index.d.ts +59 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +13070 -0
  31. package/dist/index.js.map +43 -0
  32. package/dist/keyset-iterator.d.ts +73 -0
  33. package/dist/keyset-iterator.d.ts.map +1 -0
  34. package/dist/keyset.d.ts +121 -0
  35. package/dist/keyset.d.ts.map +1 -0
  36. package/dist/model-meta.d.ts +200 -0
  37. package/dist/model-meta.d.ts.map +1 -0
  38. package/dist/nested-writes.d.ts +67 -0
  39. package/dist/nested-writes.d.ts.map +1 -0
  40. package/dist/policy-operation.d.ts +14 -0
  41. package/dist/policy-operation.d.ts.map +1 -0
  42. package/dist/policy.d.ts +17 -0
  43. package/dist/policy.d.ts.map +1 -0
  44. package/dist/query-builder.d.ts +271 -0
  45. package/dist/query-builder.d.ts.map +1 -0
  46. package/dist/relation-key.d.ts +23 -0
  47. package/dist/relation-key.d.ts.map +1 -0
  48. package/dist/relation-loader.d.ts +46 -0
  49. package/dist/relation-loader.d.ts.map +1 -0
  50. package/dist/relation-plan.d.ts +141 -0
  51. package/dist/relation-plan.d.ts.map +1 -0
  52. package/dist/render-cache.d.ts +48 -0
  53. package/dist/render-cache.d.ts.map +1 -0
  54. package/dist/rls-context.d.ts +14 -0
  55. package/dist/rls-context.d.ts.map +1 -0
  56. package/dist/rls-readiness.d.ts +114 -0
  57. package/dist/rls-readiness.d.ts.map +1 -0
  58. package/dist/scoped.d.ts +104 -0
  59. package/dist/scoped.d.ts.map +1 -0
  60. package/dist/strict-args.d.ts +47 -0
  61. package/dist/strict-args.d.ts.map +1 -0
  62. package/dist/telemetry/collector.d.ts +53 -0
  63. package/dist/telemetry/collector.d.ts.map +1 -0
  64. package/dist/telemetry/config.d.ts +53 -0
  65. package/dist/telemetry/config.d.ts.map +1 -0
  66. package/dist/telemetry/fingerprint.d.ts +38 -0
  67. package/dist/telemetry/fingerprint.d.ts.map +1 -0
  68. package/dist/telemetry/index.d.ts +18 -0
  69. package/dist/telemetry/index.d.ts.map +1 -0
  70. package/dist/telemetry/recorder.d.ts +93 -0
  71. package/dist/telemetry/recorder.d.ts.map +1 -0
  72. package/dist/telemetry/statement.d.ts +53 -0
  73. package/dist/telemetry/statement.d.ts.map +1 -0
  74. package/dist/telemetry/types.d.ts +265 -0
  75. package/dist/telemetry/types.d.ts.map +1 -0
  76. package/dist/validators.d.ts +61 -0
  77. package/dist/validators.d.ts.map +1 -0
  78. package/dist/views.d.ts +97 -0
  79. package/dist/views.d.ts.map +1 -0
  80. package/dist/write-scope.d.ts +14 -0
  81. package/dist/write-scope.d.ts.map +1 -0
  82. package/package.json +33 -26
  83. package/src/adapter.ts +0 -146
  84. package/src/client.ts +0 -2172
  85. package/src/coerce.ts +0 -184
  86. package/src/count-loader.ts +0 -152
  87. package/src/errors.ts +0 -492
  88. package/src/id-generators.ts +0 -151
  89. package/src/index.ts +0 -55
  90. package/src/lateral-join-builder.ts +0 -1053
  91. package/src/query-builder.ts +0 -1832
  92. package/src/relation-loader.ts +0 -534
  93. package/src/retry.ts +0 -183
  94. package/src/types.ts +0 -317
  95. package/src/view.ts +0 -629
  96. package/src/where-builder.ts +0 -772
@@ -0,0 +1,265 @@
1
+ /**
2
+ * The vendor-neutral observability contract (EPIC 1).
3
+ *
4
+ * An OPERATION is one public ORM call (`user.findMany()`, `$queryRaw`, one
5
+ * `$transaction`, one extension mount call). A STATEMENT is one SQL execution
6
+ * inside it. VibeORM emits operations and statements to an exporter the HOST
7
+ * owns; it never owns a tracer, never starts a provider, and never shuts one
8
+ * down.
9
+ *
10
+ * Privacy defaults, deliberately conservative:
11
+ * - parameter VALUES are redacted (only `parameterCount` is reported),
12
+ * - rendered SQL text is not captured (it can embed literals and secrets),
13
+ * - error CAUSES are never serialized into attributes — only the stable
14
+ * `VibeError.code` travels.
15
+ * Both captures are separate opt-ins.
16
+ *
17
+ * Honesty rules encoded in these types: anything unknown or unavailable is
18
+ * ABSENT, never invented as zero. `rowCount`, `durationMs`, `statementDurationMs`
19
+ * and every `detail` subdivision are optional for that reason.
20
+ */
21
+ import type { Dialect, Provider, VibeErrorCode } from "@vibeorm/schema";
22
+ /** What kind of public call an operation represents. */
23
+ export type TelemetryOperationKind = "model" | "raw" | "transaction" | "extension";
24
+ /** Which execution path ran a statement. */
25
+ export type TelemetryStatementKind = "rows" | "affected" | "raw" | "extension";
26
+ /** Terminal result of an operation or statement. */
27
+ export type TelemetryOutcome = "success" | "failure";
28
+ /**
29
+ * Where an operation ended. `completed` is the only success stage; the rest name
30
+ * the phase that failed, so a consumer can tell a refusal before any SQL from a
31
+ * rollback failure after every statement succeeded.
32
+ */
33
+ export type TelemetryStage =
34
+ /** Never dispatched: refused before it could run (array-$transaction claim refusal, expired handle). */
35
+ "refused"
36
+ /** Failed before any SQL was sent: argument validation, planning, capability refusal. */
37
+ | "validation"
38
+ /** A statement failed at the adapter. */
39
+ | "statement"
40
+ /**
41
+ * Statements succeeded; the ORM failed while producing the result — row
42
+ * decoding, relation loading, computed fields, or an `OrThrow` miss.
43
+ */
44
+ | "decode"
45
+ /** Statements succeeded; the surrounding transaction failed to commit or roll back. */
46
+ | "transaction"
47
+ /** Everything succeeded. */
48
+ | "completed"
49
+ /** Failure that could not be attributed to a phase. */
50
+ | "unknown";
51
+ /** Which exporter callback a throw came out of. */
52
+ export type TelemetryExportPhase = "operation" | "statement" | "drop" | "flush" | "shutdown" | "sampler" | "context";
53
+ /**
54
+ * The host's parent context, captured SYNCHRONOUSLY at call time and carried
55
+ * back on the operation event. Opaque on purpose: an OpenTelemetry `Context`, a
56
+ * request object, a trace id — VibeORM never inspects it, never serializes it
57
+ * and never uses it as a metric label.
58
+ */
59
+ export type TelemetryParentContext = unknown;
60
+ /** One SQL execution inside an operation. */
61
+ export type TelemetryStatementEvent = {
62
+ readonly operationId: string;
63
+ /** 0-based position inside its operation. */
64
+ readonly index: number;
65
+ readonly kind: TelemetryStatementKind;
66
+ /** `null` for raw SQL, which has no model. */
67
+ readonly model: string | null;
68
+ readonly method: string;
69
+ readonly dialect: Dialect;
70
+ readonly provider: Provider;
71
+ /** Stable normalized grouping key — bounded, literal-free, safe as a metric label. */
72
+ readonly fingerprint: string;
73
+ readonly outcome: TelemetryOutcome;
74
+ /**
75
+ * Elapsed time of the adapter call. This includes networking and may include
76
+ * pool wait and driver-side decoding — it is NOT pure server execution time.
77
+ */
78
+ readonly durationMs: number;
79
+ /** How many bound parameters the statement carried. Values are not reported. */
80
+ readonly parameterCount: number;
81
+ readonly inTransaction: boolean;
82
+ /** Absent when this path cannot know the row count. */
83
+ readonly rowCount?: number;
84
+ /** Stable code of the failure; message text and cause are never attached. */
85
+ readonly errorCode?: VibeErrorCode;
86
+ /** True when `durationMs` crossed the configured slow-statement threshold. */
87
+ readonly slow?: boolean;
88
+ /** Rendered SQL — only with `captureSql: true`. */
89
+ readonly sql?: string;
90
+ /** Parameter values — only with `captureParameterValues: true`. */
91
+ readonly parameters?: readonly unknown[];
92
+ };
93
+ /** Optional timing subdivision; every member is absent when unavailable. */
94
+ export type TelemetryTimingDetail = {
95
+ /** Statement rendering (cache hit or real render) inside this operation. */
96
+ readonly renderMs?: number;
97
+ /** Summed adapter-call elapsed time — networking and possibly pool wait included. */
98
+ readonly adapterMs?: number;
99
+ /** Operation time not spent in the adapter: planning, decoding, relations, computed fields. */
100
+ readonly processingMs?: number;
101
+ };
102
+ /** One public ORM call, start to terminal outcome. Emitted exactly once. */
103
+ export type TelemetryOperationEvent = {
104
+ readonly operationId: string;
105
+ /** The enclosing transaction/extension operation, when there is one. */
106
+ readonly parentOperationId?: string;
107
+ /** The host context captured at call time, handed straight back. */
108
+ readonly context?: TelemetryParentContext;
109
+ readonly kind: TelemetryOperationKind;
110
+ readonly model: string | null;
111
+ readonly method: string;
112
+ readonly dialect: Dialect;
113
+ readonly provider: Provider;
114
+ readonly outcome: TelemetryOutcome;
115
+ readonly stage: TelemetryStage;
116
+ /** False when the operation was refused before it ever ran. */
117
+ readonly dispatched: boolean;
118
+ /** Epoch milliseconds at ACTUAL dispatch. Absent when never dispatched. */
119
+ readonly startedAt?: number;
120
+ /** Dispatch to terminal outcome. Absent when never dispatched. */
121
+ readonly durationMs?: number;
122
+ /**
123
+ * Creation to dispatch — the deferred-dispatch queue delay. Labelled
124
+ * separately and never folded into `durationMs`.
125
+ */
126
+ readonly queueWaitMs?: number;
127
+ readonly statementCount: number;
128
+ /** Summed statement elapsed time. Absent when no statement ran. */
129
+ readonly statementDurationMs?: number;
130
+ /** Rows the operation is known to have produced or affected. Absent when unknown. */
131
+ readonly rowCount?: number;
132
+ readonly errorCode?: VibeErrorCode;
133
+ readonly detail?: TelemetryTimingDetail;
134
+ readonly statements: readonly TelemetryStatementEvent[];
135
+ /** Statements observed beyond `maxStatementsPerOperation` (counted, not kept). */
136
+ readonly droppedStatements?: number;
137
+ /** True when `durationMs` crossed the configured slow-operation threshold. */
138
+ readonly slow?: boolean;
139
+ /** An emitted span is by definition a sampled span — see the metrics snapshot for totals. */
140
+ readonly sampled: true;
141
+ };
142
+ /** Something was counted but not delivered. */
143
+ export type TelemetryDropEvent = {
144
+ readonly reason: "buffer_full" | "statement_limit";
145
+ readonly count: number;
146
+ };
147
+ /**
148
+ * Where events go. Every callback is invoked inside a guard: a throw is routed
149
+ * to `onExporterError` and can never change a database outcome, a query's
150
+ * arguments or its results.
151
+ *
152
+ * `shutdown` is NEVER called by the client — `$disconnect()` flushes only,
153
+ * because the provider behind a shared exporter belongs to the host.
154
+ */
155
+ export type TelemetryExporter = {
156
+ readonly onOperation?: (event: TelemetryOperationEvent) => void;
157
+ readonly onStatement?: (event: TelemetryStatementEvent) => void;
158
+ readonly onDrop?: (event: TelemetryDropEvent) => void;
159
+ readonly flush?: () => void | Promise<void>;
160
+ readonly shutdown?: () => void | Promise<void>;
161
+ };
162
+ /** What a sampler is told, before any work is done. */
163
+ export type TelemetrySamplerInput = {
164
+ readonly kind: TelemetryOperationKind;
165
+ readonly model: string | null;
166
+ readonly method: string;
167
+ readonly context?: TelemetryParentContext;
168
+ };
169
+ /** How exported operations reach the exporter. */
170
+ export type TelemetryDelivery = "immediate" | "buffered";
171
+ /**
172
+ * The host's handle on this client's telemetry: complete counters (spans may be
173
+ * sampled, these are not) and EXPLICIT lifecycle. `shutdown` exists here and
174
+ * only here — the client itself never calls it.
175
+ */
176
+ export type TelemetryHandle = {
177
+ readonly metrics: () => TelemetryMetricsSnapshot;
178
+ readonly flush: () => Promise<void>;
179
+ readonly shutdown: () => Promise<void>;
180
+ };
181
+ /** Telemetry configuration — the single `ClientOptions.telemetry` value. */
182
+ export type TelemetryOptions = {
183
+ /** Where events go. Required. */
184
+ readonly exporter: TelemetryExporter;
185
+ /** Attach rendered SQL text to statement events. Default FALSE: raw text can embed secrets. */
186
+ readonly captureSql?: boolean;
187
+ /** Attach parameter VALUES. Default FALSE: values are redacted, only the count is reported. */
188
+ readonly captureParameterValues?: boolean;
189
+ /** Split render / adapter / processing time on the operation event. Default FALSE. */
190
+ readonly detailedTimings?: boolean;
191
+ /** Probability a span is kept, 0..1 (default 1). Counters still count every execution. */
192
+ readonly sampleRate?: number;
193
+ /** Deterministic sampling decision; takes precedence over `sampleRate`. */
194
+ readonly sampler?: (input: TelemetrySamplerInput) => boolean;
195
+ /**
196
+ * Read the host's current parent context. Called SYNCHRONOUSLY when the ORM
197
+ * call is created — before the deferred dispatch — so an application span
198
+ * survives the async boundary between call and execution.
199
+ */
200
+ readonly context?: () => TelemetryParentContext;
201
+ /** `"immediate"` (default) exports at settle; `"buffered"` holds until `flush()`. */
202
+ readonly delivery?: TelemetryDelivery;
203
+ /** Buffered-delivery ceiling; the oldest entries are dropped and counted. */
204
+ readonly maxBufferedOperations?: number;
205
+ /** Statements kept per operation; the rest are counted in `droppedStatements`. */
206
+ readonly maxStatementsPerOperation?: number;
207
+ /** `slow` marker threshold for a statement, in milliseconds. */
208
+ readonly slowStatementMs?: number;
209
+ /** `slow` marker threshold for an operation, in milliseconds. */
210
+ readonly slowOperationMs?: number;
211
+ /** Told when an exporter callback throws. Itself guarded; never rethrows into the query. */
212
+ readonly onExporterError?: (params: {
213
+ error: unknown;
214
+ phase: TelemetryExportPhase;
215
+ }) => void;
216
+ /**
217
+ * Called ONCE, synchronously, while the client is being built, with the
218
+ * handle that owns metrics and lifecycle. Take it if you want complete
219
+ * counters under sampling, or if you want to flush/shut down deliberately.
220
+ */
221
+ readonly onReady?: (handle: TelemetryHandle) => void;
222
+ };
223
+ /** A fixed-bucket latency histogram. */
224
+ export type TelemetryHistogram = {
225
+ /** Upper bucket bounds in milliseconds; the implicit last bucket is unbounded. */
226
+ readonly bounds: readonly number[];
227
+ /** One count per bound plus one overflow bucket. */
228
+ readonly counts: readonly number[];
229
+ readonly sum: number;
230
+ readonly count: number;
231
+ };
232
+ /**
233
+ * Counters and histograms.
234
+ *
235
+ * `countsRepresent: "all"` is a promise, not decoration: counters and histograms
236
+ * are updated for EVERY execution regardless of sampling, so they never pretend
237
+ * sampled spans are complete query counts. `sampledOperations` says how many of
238
+ * those also produced a span.
239
+ */
240
+ export type TelemetryMetricsSnapshot = {
241
+ readonly countsRepresent: "all";
242
+ readonly sampleRate: number;
243
+ readonly sampledOperations: number;
244
+ readonly operations: {
245
+ readonly total: number;
246
+ readonly failed: number;
247
+ readonly refused: number;
248
+ };
249
+ readonly statements: {
250
+ readonly total: number;
251
+ readonly failed: number;
252
+ };
253
+ /** `known` = operations whose row count was knowable; `total` = the sum of those. */
254
+ readonly rows: {
255
+ readonly known: number;
256
+ readonly total: number;
257
+ };
258
+ readonly operationLatencyMs: TelemetryHistogram;
259
+ readonly statementLatencyMs: TelemetryHistogram;
260
+ readonly dropped: {
261
+ readonly operations: number;
262
+ readonly statements: number;
263
+ };
264
+ };
265
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/telemetry/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIxE,wDAAwD;AACxD,MAAM,MAAM,sBAAsB,GAAG,OAAO,GAAG,KAAK,GAAG,aAAa,GAAG,WAAW,CAAC;AAEnF,4CAA4C;AAC5C,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,GAAG,WAAW,CAAC;AAE/E,oDAAoD;AACpD,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAA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KAAE,CAAC;IACzE,qFAAqF;IACrF,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAChD,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CAChF,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Opt-in write-boundary validation (EPIC 3) — Standard-Schema validators
3
+ * mounted per model × field, run on every write path (nested creates
4
+ * included) BEFORE the data reaches the encoder. Decode-side is deliberately
5
+ * untouched: validation taxes writes the caller opted into, never every row
6
+ * materialization (rule 8; board #30).
7
+ *
8
+ * The interface is the published Standard Schema contract
9
+ * (https://standardschema.dev) — zod, valibot and arktype all implement it —
10
+ * vendored as a minimal type so the runtime takes no dependency.
11
+ */
12
+ import type { ModelMeta, RuntimeMeta } from "./model-meta.ts";
13
+ /** One validation issue as Standard Schema defines it. */
14
+ export type StandardIssue = {
15
+ readonly message: string;
16
+ readonly path?: ReadonlyArray<PropertyKey | {
17
+ readonly key: PropertyKey;
18
+ }>;
19
+ };
20
+ /** The Standard Schema v1 contract — the only surface the runtime touches. */
21
+ export type StandardSchemaV1<Input = unknown, Output = Input> = {
22
+ readonly "~standard": {
23
+ readonly version: 1;
24
+ readonly vendor: string;
25
+ readonly validate: (value: unknown) => {
26
+ value: Output;
27
+ issues?: undefined;
28
+ } | {
29
+ issues: readonly StandardIssue[];
30
+ } | Promise<unknown>;
31
+ };
32
+ };
33
+ /** Per-model, per-field validator config: `{ User: { settings: zodSchema } }`. */
34
+ export type WriteValidators = {
35
+ readonly [model: string]: {
36
+ readonly [field: string]: StandardSchemaV1;
37
+ };
38
+ };
39
+ /**
40
+ * Validate one data row (create/update shape) for `model`, recursing into
41
+ * every nested write body on every related model. Returns the (possibly
42
+ * transformed) data — Standard Schema allows coercion.
43
+ *
44
+ * Traversal is UNCONDITIONAL (F09): it does not stop at a related model that
45
+ * configures no validators of its own, because a model further down may.
46
+ */
47
+ export declare function validateWriteData(params: {
48
+ meta: RuntimeMeta;
49
+ model: ModelMeta;
50
+ data: Record<string, unknown>;
51
+ validators: WriteValidators;
52
+ }): Record<string, unknown>;
53
+ /** Rewrite a write method's args through the validators; non-write args pass through untouched. */
54
+ export declare function applyWriteValidators(params: {
55
+ meta: RuntimeMeta;
56
+ model: ModelMeta;
57
+ method: string;
58
+ args: Record<string, unknown>;
59
+ validators: WriteValidators;
60
+ }): Record<string, unknown>;
61
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9D,0DAA0D;AAC1D,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,WAAW,GAAG;QAAE,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;CAC5E,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK,IAAI;IAC9D,QAAQ,CAAC,WAAW,EAAE;QACpB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,QAAQ,EAAE,CACjB,KAAK,EAAE,OAAO,KACX;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,SAAS,CAAA;SAAE,GAAG;YAAE,MAAM,EAAE,SAAS,aAAa,EAAE,CAAA;SAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;KACtG,CAAC;CACH,CAAC;AAEF,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAAA;KAAE,CAAC;CAC1E,CAAC;AAmEF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,UAAU,EAAE,eAAe,CAAC;CAC7B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgC1B;AA8CD,mGAAmG;AACnG,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,UAAU,EAAE,eAAe,CAAC;CAC7B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAsB1B"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Field-masking views — the v1 `db.defineView()` surface ported to v2
3
+ * (board #11), renamed `$defineView` per v2's $-prefixed client-name rule.
4
+ *
5
+ * A view is a READ-ONLY scoped client over the models named in its definition.
6
+ * Rows come back as `ViewResult` instances that expose only the definition's
7
+ * fields; `reveal: { field: true }` makes an extra field readable as a
8
+ * property while `JSON.stringify` still excludes it, and `$unsafe()` returns
9
+ * everything. Relations load normally: when the related model is ALSO in the
10
+ * definition its rows are masked recursively; when it is not, they pass
11
+ * through untouched (v1 semantics).
12
+ *
13
+ * Isolated by design: this module wraps the public delegate surface
14
+ * (`client.$models`) and never reaches into the query builder — the same SQL
15
+ * runs, the ARGS are rewritten (definition fields become a `select`) and the
16
+ * RESULT objects are wrapped.
17
+ *
18
+ * v1 → v2 deltas (documented in apps/tests/parity-fragments/views.md):
19
+ * - `defineView` → `$defineView`; errors are `VibeError` codes, not strings.
20
+ * - The definition is validated eagerly (unknown model / unknown field /
21
+ * empty field set throw `VIBE_VALIDATION` at definition time).
22
+ * - Write verbs exist on the view delegate but throw `VIBE_VALIDATION`
23
+ * (mirroring v2's database-view read-only contract) — v1 left them
24
+ * `undefined`.
25
+ * - A nested `include` under a masked relation stays masked (v1 dropped the
26
+ * restriction one level down); `omit` on a view query is refused loudly
27
+ * (v1 stripped it silently).
28
+ */
29
+ import type { ClientRow, ModelDelegate } from "./client.ts";
30
+ import type { RuntimeMeta } from "./model-meta.ts";
31
+ /**
32
+ * A view definition: client-name model keys → the set of visible fields.
33
+ * Example: `{ user: { id: true, name: true }, post: { id: true, title: true } }`.
34
+ */
35
+ export type ViewDefinition = Record<string, Record<string, boolean | undefined>>;
36
+ /** The read surface of one model under a view — writes throw `VIBE_VALIDATION`. */
37
+ export type ViewModelDelegate = {
38
+ readonly findMany: (args?: ClientRow) => Promise<ViewResult[]>;
39
+ readonly findFirst: (args?: ClientRow) => Promise<ViewResult | null>;
40
+ readonly findFirstOrThrow: (args?: ClientRow) => Promise<ViewResult>;
41
+ readonly findUnique: (args: ClientRow) => Promise<ViewResult | null>;
42
+ readonly findUniqueOrThrow: (args: ClientRow) => Promise<ViewResult>;
43
+ readonly count: (args?: ClientRow) => Promise<number | Record<string, number>>;
44
+ readonly aggregate: (args: ClientRow) => Promise<ClientRow>;
45
+ readonly groupBy: (args: ClientRow) => Promise<ClientRow[]>;
46
+ } & Record<string, unknown>;
47
+ /** What `$defineView` returns at the runtime level — the generated d.ts narrows it. */
48
+ export type ViewClientShape = Record<string, ViewModelDelegate>;
49
+ /** The `$defineView` client method (runtime-level shape). */
50
+ export type DefineViewFn = (options: {
51
+ readonly name: string;
52
+ readonly definition: ViewDefinition;
53
+ }) => ViewClientShape;
54
+ /**
55
+ * A masked row: visible + revealed fields are enumerable own properties,
56
+ * `toJSON()` (used by `JSON.stringify`) drops revealed fields recursively,
57
+ * `$unsafe()` returns a plain object with everything. Class methods are
58
+ * prototype members, so they never show up in `Object.keys` / spread.
59
+ */
60
+ export declare class ViewResult {
61
+ /** Dynamic property access for view/revealed/relation fields. */
62
+ [key: string]: unknown;
63
+ /** @internal Field names revealed on this row (non-enumerable). */
64
+ readonly _revealed: ReadonlySet<string>;
65
+ constructor(params: {
66
+ record: Readonly<Record<string, unknown>>;
67
+ /** Every key to expose as a property (fields + revealed + relations). */
68
+ expose: ReadonlySet<string>;
69
+ revealed: ReadonlySet<string>;
70
+ });
71
+ /** Plain object WITHOUT revealed fields (what `JSON.stringify` sees), recursively. */
72
+ toJSON(): Record<string, unknown>;
73
+ /** Plain object with ALL fields (view + revealed), recursively — the escape hatch. */
74
+ $unsafe(): Record<string, unknown>;
75
+ }
76
+ /**
77
+ * Build a field-masking view client over an existing client's delegates.
78
+ *
79
+ * @throws VibeError `VIBE_VALIDATION` on an invalid definition (unknown model,
80
+ * unknown or relation field, empty field set).
81
+ */
82
+ export declare function createView(params: {
83
+ meta: RuntimeMeta;
84
+ models: Readonly<Record<string, ModelDelegate>>;
85
+ name: string;
86
+ definition: ViewDefinition;
87
+ }): ViewClientShape;
88
+ /**
89
+ * Attach `$defineView` to a built client (called by `buildClient`; transaction
90
+ * clients get their own attachment because `$transaction` rebuilds the client).
91
+ */
92
+ export declare function attachDefineView(params: {
93
+ client: object;
94
+ meta: RuntimeMeta;
95
+ models: Readonly<Record<string, ModelDelegate>>;
96
+ }): void;
97
+ //# sourceMappingURL=views.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.d.ts","sourceRoot":"","sources":["../src/views.ts"],"names":[],"mappings":"AAAA;;;;;;;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EAAE,aAAa,CAAC,CAAC,CAAC;CACjD,GAAG,IAAI,CAKP"}
@@ -0,0 +1,14 @@
1
+ import type { VibeError } from "@vibeorm/schema";
2
+ /** Carry a protected field's required value through nested-write rewriting. */
3
+ export declare function protectWriteScope(params: {
4
+ data: Record<string, unknown>;
5
+ field: string;
6
+ value: unknown;
7
+ error: VibeError;
8
+ }): Record<string, unknown>;
9
+ /** Refuse a relation-derived assignment before it can overwrite a protected field. */
10
+ export declare function assertWriteScope(params: {
11
+ data: Record<string, unknown>;
12
+ assignments: Record<string, unknown>;
13
+ }): void;
14
+ //# sourceMappingURL=write-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-scope.d.ts","sourceRoot":"","sources":["../src/write-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAWjD,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,SAAS,CAAC;CAClB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAG1B;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC,GAAG,IAAI,CAIP"}
package/package.json CHANGED
@@ -1,45 +1,52 @@
1
1
  {
2
2
  "name": "@vibeorm/runtime",
3
- "version": "1.3.0",
4
- "description": "Driver-agnostic query engine and client runtime for VibeORM",
5
- "license": "MIT",
3
+ "version": "2.0.0-alpha.10",
4
+ "description": "Driver-agnostic query engine and client runtime for VibeORM v2",
6
5
  "keywords": [
7
6
  "orm",
8
- "runtime",
9
- "query-builder",
10
- "bun",
11
7
  "typescript",
12
- "postgresql"
8
+ "sql",
9
+ "database",
10
+ "bun",
11
+ "type-safe",
12
+ "query-builder",
13
+ "client",
14
+ "adapter",
15
+ "relations"
13
16
  ],
14
- "type": "module",
15
- "exports": {
16
- ".": {
17
- "default": "./src/index.ts",
18
- "types": "./src/index.ts"
19
- }
17
+ "homepage": "https://github.com/vibeorm/vibeorm/tree/master/packages/runtime#readme",
18
+ "bugs": {
19
+ "url": "https://github.com/vibeorm/vibeorm/issues"
20
20
  },
21
- "files": [
22
- "src"
23
- ],
24
21
  "repository": {
25
22
  "type": "git",
26
23
  "url": "https://github.com/vibeorm/vibeorm.git",
27
24
  "directory": "packages/runtime"
28
25
  },
29
- "homepage": "https://github.com/vibeorm/vibeorm/tree/master/packages/runtime",
30
- "bugs": {
31
- "url": "https://github.com/vibeorm/vibeorm/issues"
26
+ "license": "MIT",
27
+ "author": "VibeORM contributors",
28
+ "type": "module",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "default": "./dist/index.js"
33
+ }
32
34
  },
35
+ "files": [
36
+ "dist",
37
+ "README.md"
38
+ ],
33
39
  "engines": {
34
- "bun": ">=1.1.0"
40
+ "node": ">=18",
41
+ "bun": ">=1.2.0"
35
42
  },
36
- "peerDependencies": {
37
- "zod": ">=4"
43
+ "dependencies": {
44
+ "@vibeorm/schema": "2.0.0-alpha.8",
45
+ "@vibeorm/sql": "2.0.0-alpha.8"
38
46
  },
39
- "peerDependenciesMeta": {
40
- "zod": {
41
- "optional": true
42
- }
47
+ "devDependencies": {
48
+ "@electric-sql/pglite": "^0.5.4",
49
+ "@vibeorm/scoped-conformance": "0.1.0-alpha.0"
43
50
  },
44
51
  "publishConfig": {
45
52
  "access": "public"