@cipherstash/stack 0.18.0 → 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/CHANGELOG.md +704 -0
  2. package/README.md +97 -79
  3. package/dist/adapter-kit.cjs +923 -0
  4. package/dist/adapter-kit.cjs.map +1 -0
  5. package/dist/adapter-kit.d.cts +82 -0
  6. package/dist/adapter-kit.d.ts +82 -0
  7. package/dist/adapter-kit.js +47 -0
  8. package/dist/adapter-kit.js.map +1 -0
  9. package/dist/base-operation-AOAIvsSB.d.cts +32 -0
  10. package/dist/base-operation-FXEzUXIq.d.ts +32 -0
  11. package/dist/{chunk-VPOTNP4K.js → chunk-3B5ZX3IS.js} +3 -1
  12. package/dist/chunk-3B5ZX3IS.js.map +1 -0
  13. package/dist/chunk-7333ZC6L.js +48 -0
  14. package/dist/chunk-7333ZC6L.js.map +1 -0
  15. package/dist/{chunk-XWPGAHBZ.js → chunk-BNO32ZMV.js} +1 -1
  16. package/dist/chunk-BNO32ZMV.js.map +1 -0
  17. package/dist/chunk-CLM7E4I6.js +4439 -0
  18. package/dist/chunk-CLM7E4I6.js.map +1 -0
  19. package/dist/{chunk-LLCCNKDL.js → chunk-HQANMV7R.js} +3 -3
  20. package/dist/{chunk-LLCCNKDL.js.map → chunk-HQANMV7R.js.map} +1 -1
  21. package/dist/chunk-JSG2AMDI.js +17 -0
  22. package/dist/chunk-JSG2AMDI.js.map +1 -0
  23. package/dist/chunk-OFQ555AX.js +191 -0
  24. package/dist/chunk-OFQ555AX.js.map +1 -0
  25. package/dist/chunk-PZ5AY32C.js +10 -0
  26. package/dist/chunk-PZ5AY32C.js.map +1 -0
  27. package/dist/chunk-V2Q3NYIH.js +494 -0
  28. package/dist/chunk-V2Q3NYIH.js.map +1 -0
  29. package/dist/chunk-X3JRXEIB.js +98 -0
  30. package/dist/chunk-X3JRXEIB.js.map +1 -0
  31. package/dist/{chunk-ZYOZHZMJ.js → chunk-ZTP5QJ27.js} +193 -169
  32. package/dist/chunk-ZTP5QJ27.js.map +1 -0
  33. package/dist/client.cjs +4124 -49
  34. package/dist/client.cjs.map +1 -1
  35. package/dist/client.d.cts +6 -5
  36. package/dist/client.d.ts +6 -5
  37. package/dist/client.js +3 -1
  38. package/dist/columns-D2_YzrCX.d.cts +622 -0
  39. package/dist/columns-rZc7fQHI.d.ts +622 -0
  40. package/dist/dynamodb/index.cjs +19 -12
  41. package/dist/dynamodb/index.cjs.map +1 -1
  42. package/dist/dynamodb/index.d.cts +3 -2
  43. package/dist/dynamodb/index.d.ts +3 -2
  44. package/dist/dynamodb/index.js +8 -10
  45. package/dist/dynamodb/index.js.map +1 -1
  46. package/dist/encryption/index.cjs +4496 -222
  47. package/dist/encryption/index.cjs.map +1 -1
  48. package/dist/encryption/index.d.cts +807 -6
  49. package/dist/encryption/index.d.ts +807 -6
  50. package/dist/encryption/index.js +15 -7
  51. package/dist/encryption/v3.cjs +7896 -0
  52. package/dist/encryption/v3.cjs.map +1 -0
  53. package/dist/encryption/v3.d.cts +103 -0
  54. package/dist/encryption/v3.d.ts +103 -0
  55. package/dist/encryption/v3.js +189 -0
  56. package/dist/encryption/v3.js.map +1 -0
  57. package/dist/eql/v3/index.cjs +663 -0
  58. package/dist/eql/v3/index.cjs.map +1 -0
  59. package/dist/eql/v3/index.d.cts +173 -0
  60. package/dist/eql/v3/index.d.ts +173 -0
  61. package/dist/eql/v3/index.js +99 -0
  62. package/dist/eql/v3/index.js.map +1 -0
  63. package/dist/errors/index.js +1 -0
  64. package/dist/identity/index.cjs +55 -35
  65. package/dist/identity/index.cjs.map +1 -1
  66. package/dist/identity/index.d.cts +54 -30
  67. package/dist/identity/index.d.ts +54 -30
  68. package/dist/identity/index.js +9 -177
  69. package/dist/identity/index.js.map +1 -1
  70. package/dist/index-BquA71_Y.d.ts +24 -0
  71. package/dist/index-fhWTOV0K.d.cts +24 -0
  72. package/dist/index.cjs +4547 -243
  73. package/dist/index.cjs.map +1 -1
  74. package/dist/index.d.cts +18 -19
  75. package/dist/index.d.ts +18 -19
  76. package/dist/index.js +20 -5
  77. package/dist/index.js.map +1 -1
  78. package/dist/schema/index.cjs +4128 -49
  79. package/dist/schema/index.cjs.map +1 -1
  80. package/dist/schema/index.d.cts +1 -1
  81. package/dist/schema/index.d.ts +1 -1
  82. package/dist/schema/index.js +3 -1
  83. package/dist/{types-public-BTxqjmtv.d.cts → types-public-QMjYNfQO.d.cts} +448 -251
  84. package/dist/{types-public-BTxqjmtv.d.ts → types-public-QMjYNfQO.d.ts} +448 -251
  85. package/dist/types-public.cjs.map +1 -1
  86. package/dist/types-public.d.cts +2 -2
  87. package/dist/types-public.d.ts +2 -2
  88. package/dist/types-public.js +2 -1
  89. package/dist/wasm-inline.d.ts +1643 -0
  90. package/dist/wasm-inline.js +4901 -0
  91. package/dist/wasm-inline.js.map +1 -0
  92. package/package.json +74 -52
  93. package/dist/chunk-VPOTNP4K.js.map +0 -1
  94. package/dist/chunk-XWPGAHBZ.js.map +0 -1
  95. package/dist/chunk-YWQXTZ5M.js +0 -383
  96. package/dist/chunk-YWQXTZ5M.js.map +0 -1
  97. package/dist/chunk-ZYOZHZMJ.js.map +0 -1
  98. package/dist/client-CIsfZ2zg.d.ts +0 -692
  99. package/dist/client-Dt98Rugc.d.cts +0 -692
  100. package/dist/drizzle/index.cjs +0 -1558
  101. package/dist/drizzle/index.cjs.map +0 -1
  102. package/dist/drizzle/index.d.cts +0 -358
  103. package/dist/drizzle/index.d.ts +0 -358
  104. package/dist/drizzle/index.js +0 -1215
  105. package/dist/drizzle/index.js.map +0 -1
  106. package/dist/supabase/index.cjs +0 -1526
  107. package/dist/supabase/index.cjs.map +0 -1
  108. package/dist/supabase/index.d.cts +0 -144
  109. package/dist/supabase/index.d.ts +0 -144
  110. package/dist/supabase/index.js +0 -899
  111. package/dist/supabase/index.js.map +0 -1
@@ -0,0 +1,1643 @@
1
+ import { AccessKeyStrategy, OidcFederationStrategy } from '@cipherstash/auth/wasm-inline';
2
+ export { AccessKeyStrategy, OidcFederationStrategy } from '@cipherstash/auth/wasm-inline';
3
+ import { z } from 'zod';
4
+ import { EncryptedPayload } from '@cipherstash/protect-ffi';
5
+
6
+ /** Structural type representing encrypted data stored in the database. Always
7
+ * carries a ciphertext. Covers BOTH wire formats: the EQL v2.3 payloads
8
+ * (`k: "ct"` / `k: "sv"`) and the EQL v3 payloads (flat `{v: 3, i, c, …}`
9
+ * scalars and `{v: 3, k: "sv", i, sv}` SteVec documents). Which format
10
+ * `encrypt` produces is selected by the client's
11
+ * {@link ClientConfig.eqlVersion}; `decrypt` accepts both regardless.
12
+ * v3 scalars carry no `k` discriminator, so narrow with `'k' in payload`
13
+ * before reading it. See also `EncryptedValue` for branded nominal typing,
14
+ * and {@link EncryptedQuery} for the search-term shape returned by
15
+ * `encryptQuery`. */
16
+ type Encrypted = EncryptedPayload;
17
+ /** Structural contract for a column builder the client can consume for STORAGE
18
+ * (`encrypt`). Satisfied by v2 `EncryptedColumn` / `EncryptedField` AND v3
19
+ * `EncryptedTextSearchColumn` — fields ARE encryptable, so this stays wide. */
20
+ interface BuildableColumn {
21
+ getName(): string;
22
+ build(): ColumnSchema;
23
+ }
24
+ /** Structural contract for a table builder the client can consume. Satisfied by
25
+ * v2 and v3 `EncryptedTable` alike. */
26
+ interface BuildableTable {
27
+ tableName: string;
28
+ build(): {
29
+ tableName: string;
30
+ columns: Record<string, ColumnSchema>;
31
+ };
32
+ /**
33
+ * Optional map from a model field's JS property name to its encrypt-config
34
+ * column name (the DB name). Present when the two can differ — v3 tables key
35
+ * their config by DB name (`column.getName()`) while models are written with
36
+ * JS property keys, so the model path must match by property but address the
37
+ * FFI/config by DB name.
38
+ *
39
+ * Absent on v2 tables, whose `build()` already keys columns by the JS property
40
+ * name; the model path then matches and addresses by that same key.
41
+ */
42
+ buildColumnKeyMap?(): Record<string, string>;
43
+ }
44
+ /**
45
+ * Options for single-value encrypt operations.
46
+ * Use a column from your table schema (from {@link encryptedColumn}) or a nested
47
+ * field (from {@link encryptedField}) as the target for encryption.
48
+ */
49
+ type EncryptOptions = {
50
+ /** The column or nested field to encrypt into. From {@link EncryptedColumn} or {@link EncryptedField}. */
51
+ column: BuildableColumn;
52
+ table: BuildableTable;
53
+ };
54
+
55
+ declare const columnSchema: z.ZodDefault<z.ZodObject<{
56
+ cast_as: z.ZodDefault<z.ZodEnum<["bigint", "boolean", "date", "timestamp", "number", "string", "json", "text"]>>;
57
+ indexes: z.ZodDefault<z.ZodObject<{
58
+ ore: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
59
+ ope: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
60
+ unique: z.ZodOptional<z.ZodObject<{
61
+ token_filters: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
62
+ kind: z.ZodLiteral<"downcase">;
63
+ }, "strip", z.ZodTypeAny, {
64
+ kind: "downcase";
65
+ }, {
66
+ kind: "downcase";
67
+ }>, "many">>>;
68
+ }, "strip", z.ZodTypeAny, {
69
+ token_filters?: {
70
+ kind: "downcase";
71
+ }[] | undefined;
72
+ }, {
73
+ token_filters?: {
74
+ kind: "downcase";
75
+ }[] | undefined;
76
+ }>>;
77
+ match: z.ZodOptional<z.ZodObject<{
78
+ tokenizer: z.ZodOptional<z.ZodDefault<z.ZodUnion<[z.ZodObject<{
79
+ kind: z.ZodLiteral<"standard">;
80
+ }, "strip", z.ZodTypeAny, {
81
+ kind: "standard";
82
+ }, {
83
+ kind: "standard";
84
+ }>, z.ZodObject<{
85
+ kind: z.ZodLiteral<"ngram">;
86
+ token_length: z.ZodNumber;
87
+ }, "strip", z.ZodTypeAny, {
88
+ kind: "ngram";
89
+ token_length: number;
90
+ }, {
91
+ kind: "ngram";
92
+ token_length: number;
93
+ }>]>>>;
94
+ token_filters: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
95
+ kind: z.ZodLiteral<"downcase">;
96
+ }, "strip", z.ZodTypeAny, {
97
+ kind: "downcase";
98
+ }, {
99
+ kind: "downcase";
100
+ }>, "many">>>;
101
+ k: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
102
+ m: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
103
+ include_original: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
104
+ }, "strip", z.ZodTypeAny, {
105
+ token_filters?: {
106
+ kind: "downcase";
107
+ }[] | undefined;
108
+ tokenizer?: {
109
+ kind: "standard";
110
+ } | {
111
+ kind: "ngram";
112
+ token_length: number;
113
+ } | undefined;
114
+ k?: number | undefined;
115
+ m?: number | undefined;
116
+ include_original?: boolean | undefined;
117
+ }, {
118
+ token_filters?: {
119
+ kind: "downcase";
120
+ }[] | undefined;
121
+ tokenizer?: {
122
+ kind: "standard";
123
+ } | {
124
+ kind: "ngram";
125
+ token_length: number;
126
+ } | undefined;
127
+ k?: number | undefined;
128
+ m?: number | undefined;
129
+ include_original?: boolean | undefined;
130
+ }>>;
131
+ ste_vec: z.ZodOptional<z.ZodObject<{
132
+ prefix: z.ZodString;
133
+ array_index_mode: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"all">, z.ZodLiteral<"none">, z.ZodObject<{
134
+ item: z.ZodOptional<z.ZodBoolean>;
135
+ wildcard: z.ZodOptional<z.ZodBoolean>;
136
+ position: z.ZodOptional<z.ZodBoolean>;
137
+ }, "strip", z.ZodTypeAny, {
138
+ item?: boolean | undefined;
139
+ wildcard?: boolean | undefined;
140
+ position?: boolean | undefined;
141
+ }, {
142
+ item?: boolean | undefined;
143
+ wildcard?: boolean | undefined;
144
+ position?: boolean | undefined;
145
+ }>]>>;
146
+ mode: z.ZodOptional<z.ZodEnum<["compat", "standard"]>>;
147
+ }, "strip", z.ZodTypeAny, {
148
+ prefix: string;
149
+ array_index_mode?: "all" | "none" | {
150
+ item?: boolean | undefined;
151
+ wildcard?: boolean | undefined;
152
+ position?: boolean | undefined;
153
+ } | undefined;
154
+ mode?: "standard" | "compat" | undefined;
155
+ }, {
156
+ prefix: string;
157
+ array_index_mode?: "all" | "none" | {
158
+ item?: boolean | undefined;
159
+ wildcard?: boolean | undefined;
160
+ position?: boolean | undefined;
161
+ } | undefined;
162
+ mode?: "standard" | "compat" | undefined;
163
+ }>>;
164
+ }, "strip", z.ZodTypeAny, {
165
+ ore?: {} | undefined;
166
+ ope?: {} | undefined;
167
+ unique?: {
168
+ token_filters?: {
169
+ kind: "downcase";
170
+ }[] | undefined;
171
+ } | undefined;
172
+ match?: {
173
+ token_filters?: {
174
+ kind: "downcase";
175
+ }[] | undefined;
176
+ tokenizer?: {
177
+ kind: "standard";
178
+ } | {
179
+ kind: "ngram";
180
+ token_length: number;
181
+ } | undefined;
182
+ k?: number | undefined;
183
+ m?: number | undefined;
184
+ include_original?: boolean | undefined;
185
+ } | undefined;
186
+ ste_vec?: {
187
+ prefix: string;
188
+ array_index_mode?: "all" | "none" | {
189
+ item?: boolean | undefined;
190
+ wildcard?: boolean | undefined;
191
+ position?: boolean | undefined;
192
+ } | undefined;
193
+ mode?: "standard" | "compat" | undefined;
194
+ } | undefined;
195
+ }, {
196
+ ore?: {} | undefined;
197
+ ope?: {} | undefined;
198
+ unique?: {
199
+ token_filters?: {
200
+ kind: "downcase";
201
+ }[] | undefined;
202
+ } | undefined;
203
+ match?: {
204
+ token_filters?: {
205
+ kind: "downcase";
206
+ }[] | undefined;
207
+ tokenizer?: {
208
+ kind: "standard";
209
+ } | {
210
+ kind: "ngram";
211
+ token_length: number;
212
+ } | undefined;
213
+ k?: number | undefined;
214
+ m?: number | undefined;
215
+ include_original?: boolean | undefined;
216
+ } | undefined;
217
+ ste_vec?: {
218
+ prefix: string;
219
+ array_index_mode?: "all" | "none" | {
220
+ item?: boolean | undefined;
221
+ wildcard?: boolean | undefined;
222
+ position?: boolean | undefined;
223
+ } | undefined;
224
+ mode?: "standard" | "compat" | undefined;
225
+ } | undefined;
226
+ }>>;
227
+ }, "strip", z.ZodTypeAny, {
228
+ cast_as: "string" | "number" | "bigint" | "boolean" | "date" | "timestamp" | "json" | "text";
229
+ indexes: {
230
+ ore?: {} | undefined;
231
+ ope?: {} | undefined;
232
+ unique?: {
233
+ token_filters?: {
234
+ kind: "downcase";
235
+ }[] | undefined;
236
+ } | undefined;
237
+ match?: {
238
+ token_filters?: {
239
+ kind: "downcase";
240
+ }[] | undefined;
241
+ tokenizer?: {
242
+ kind: "standard";
243
+ } | {
244
+ kind: "ngram";
245
+ token_length: number;
246
+ } | undefined;
247
+ k?: number | undefined;
248
+ m?: number | undefined;
249
+ include_original?: boolean | undefined;
250
+ } | undefined;
251
+ ste_vec?: {
252
+ prefix: string;
253
+ array_index_mode?: "all" | "none" | {
254
+ item?: boolean | undefined;
255
+ wildcard?: boolean | undefined;
256
+ position?: boolean | undefined;
257
+ } | undefined;
258
+ mode?: "standard" | "compat" | undefined;
259
+ } | undefined;
260
+ };
261
+ }, {
262
+ cast_as?: "string" | "number" | "bigint" | "boolean" | "date" | "timestamp" | "json" | "text" | undefined;
263
+ indexes?: {
264
+ ore?: {} | undefined;
265
+ ope?: {} | undefined;
266
+ unique?: {
267
+ token_filters?: {
268
+ kind: "downcase";
269
+ }[] | undefined;
270
+ } | undefined;
271
+ match?: {
272
+ token_filters?: {
273
+ kind: "downcase";
274
+ }[] | undefined;
275
+ tokenizer?: {
276
+ kind: "standard";
277
+ } | {
278
+ kind: "ngram";
279
+ token_length: number;
280
+ } | undefined;
281
+ k?: number | undefined;
282
+ m?: number | undefined;
283
+ include_original?: boolean | undefined;
284
+ } | undefined;
285
+ ste_vec?: {
286
+ prefix: string;
287
+ array_index_mode?: "all" | "none" | {
288
+ item?: boolean | undefined;
289
+ wildcard?: boolean | undefined;
290
+ position?: boolean | undefined;
291
+ } | undefined;
292
+ mode?: "standard" | "compat" | undefined;
293
+ } | undefined;
294
+ } | undefined;
295
+ }>>;
296
+ /** @internal */
297
+ declare const encryptConfigSchema: z.ZodObject<{
298
+ v: z.ZodNumber;
299
+ tables: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodDefault<z.ZodObject<{
300
+ cast_as: z.ZodDefault<z.ZodEnum<["bigint", "boolean", "date", "timestamp", "number", "string", "json", "text"]>>;
301
+ indexes: z.ZodDefault<z.ZodObject<{
302
+ ore: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
303
+ ope: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
304
+ unique: z.ZodOptional<z.ZodObject<{
305
+ token_filters: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
306
+ kind: z.ZodLiteral<"downcase">;
307
+ }, "strip", z.ZodTypeAny, {
308
+ kind: "downcase";
309
+ }, {
310
+ kind: "downcase";
311
+ }>, "many">>>;
312
+ }, "strip", z.ZodTypeAny, {
313
+ token_filters?: {
314
+ kind: "downcase";
315
+ }[] | undefined;
316
+ }, {
317
+ token_filters?: {
318
+ kind: "downcase";
319
+ }[] | undefined;
320
+ }>>;
321
+ match: z.ZodOptional<z.ZodObject<{
322
+ tokenizer: z.ZodOptional<z.ZodDefault<z.ZodUnion<[z.ZodObject<{
323
+ kind: z.ZodLiteral<"standard">;
324
+ }, "strip", z.ZodTypeAny, {
325
+ kind: "standard";
326
+ }, {
327
+ kind: "standard";
328
+ }>, z.ZodObject<{
329
+ kind: z.ZodLiteral<"ngram">;
330
+ token_length: z.ZodNumber;
331
+ }, "strip", z.ZodTypeAny, {
332
+ kind: "ngram";
333
+ token_length: number;
334
+ }, {
335
+ kind: "ngram";
336
+ token_length: number;
337
+ }>]>>>;
338
+ token_filters: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
339
+ kind: z.ZodLiteral<"downcase">;
340
+ }, "strip", z.ZodTypeAny, {
341
+ kind: "downcase";
342
+ }, {
343
+ kind: "downcase";
344
+ }>, "many">>>;
345
+ k: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
346
+ m: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
347
+ include_original: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
348
+ }, "strip", z.ZodTypeAny, {
349
+ token_filters?: {
350
+ kind: "downcase";
351
+ }[] | undefined;
352
+ tokenizer?: {
353
+ kind: "standard";
354
+ } | {
355
+ kind: "ngram";
356
+ token_length: number;
357
+ } | undefined;
358
+ k?: number | undefined;
359
+ m?: number | undefined;
360
+ include_original?: boolean | undefined;
361
+ }, {
362
+ token_filters?: {
363
+ kind: "downcase";
364
+ }[] | undefined;
365
+ tokenizer?: {
366
+ kind: "standard";
367
+ } | {
368
+ kind: "ngram";
369
+ token_length: number;
370
+ } | undefined;
371
+ k?: number | undefined;
372
+ m?: number | undefined;
373
+ include_original?: boolean | undefined;
374
+ }>>;
375
+ ste_vec: z.ZodOptional<z.ZodObject<{
376
+ prefix: z.ZodString;
377
+ array_index_mode: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"all">, z.ZodLiteral<"none">, z.ZodObject<{
378
+ item: z.ZodOptional<z.ZodBoolean>;
379
+ wildcard: z.ZodOptional<z.ZodBoolean>;
380
+ position: z.ZodOptional<z.ZodBoolean>;
381
+ }, "strip", z.ZodTypeAny, {
382
+ item?: boolean | undefined;
383
+ wildcard?: boolean | undefined;
384
+ position?: boolean | undefined;
385
+ }, {
386
+ item?: boolean | undefined;
387
+ wildcard?: boolean | undefined;
388
+ position?: boolean | undefined;
389
+ }>]>>;
390
+ mode: z.ZodOptional<z.ZodEnum<["compat", "standard"]>>;
391
+ }, "strip", z.ZodTypeAny, {
392
+ prefix: string;
393
+ array_index_mode?: "all" | "none" | {
394
+ item?: boolean | undefined;
395
+ wildcard?: boolean | undefined;
396
+ position?: boolean | undefined;
397
+ } | undefined;
398
+ mode?: "standard" | "compat" | undefined;
399
+ }, {
400
+ prefix: string;
401
+ array_index_mode?: "all" | "none" | {
402
+ item?: boolean | undefined;
403
+ wildcard?: boolean | undefined;
404
+ position?: boolean | undefined;
405
+ } | undefined;
406
+ mode?: "standard" | "compat" | undefined;
407
+ }>>;
408
+ }, "strip", z.ZodTypeAny, {
409
+ ore?: {} | undefined;
410
+ ope?: {} | undefined;
411
+ unique?: {
412
+ token_filters?: {
413
+ kind: "downcase";
414
+ }[] | undefined;
415
+ } | undefined;
416
+ match?: {
417
+ token_filters?: {
418
+ kind: "downcase";
419
+ }[] | undefined;
420
+ tokenizer?: {
421
+ kind: "standard";
422
+ } | {
423
+ kind: "ngram";
424
+ token_length: number;
425
+ } | undefined;
426
+ k?: number | undefined;
427
+ m?: number | undefined;
428
+ include_original?: boolean | undefined;
429
+ } | undefined;
430
+ ste_vec?: {
431
+ prefix: string;
432
+ array_index_mode?: "all" | "none" | {
433
+ item?: boolean | undefined;
434
+ wildcard?: boolean | undefined;
435
+ position?: boolean | undefined;
436
+ } | undefined;
437
+ mode?: "standard" | "compat" | undefined;
438
+ } | undefined;
439
+ }, {
440
+ ore?: {} | undefined;
441
+ ope?: {} | undefined;
442
+ unique?: {
443
+ token_filters?: {
444
+ kind: "downcase";
445
+ }[] | undefined;
446
+ } | undefined;
447
+ match?: {
448
+ token_filters?: {
449
+ kind: "downcase";
450
+ }[] | undefined;
451
+ tokenizer?: {
452
+ kind: "standard";
453
+ } | {
454
+ kind: "ngram";
455
+ token_length: number;
456
+ } | undefined;
457
+ k?: number | undefined;
458
+ m?: number | undefined;
459
+ include_original?: boolean | undefined;
460
+ } | undefined;
461
+ ste_vec?: {
462
+ prefix: string;
463
+ array_index_mode?: "all" | "none" | {
464
+ item?: boolean | undefined;
465
+ wildcard?: boolean | undefined;
466
+ position?: boolean | undefined;
467
+ } | undefined;
468
+ mode?: "standard" | "compat" | undefined;
469
+ } | undefined;
470
+ }>>;
471
+ }, "strip", z.ZodTypeAny, {
472
+ cast_as: "string" | "number" | "bigint" | "boolean" | "date" | "timestamp" | "json" | "text";
473
+ indexes: {
474
+ ore?: {} | undefined;
475
+ ope?: {} | undefined;
476
+ unique?: {
477
+ token_filters?: {
478
+ kind: "downcase";
479
+ }[] | undefined;
480
+ } | undefined;
481
+ match?: {
482
+ token_filters?: {
483
+ kind: "downcase";
484
+ }[] | undefined;
485
+ tokenizer?: {
486
+ kind: "standard";
487
+ } | {
488
+ kind: "ngram";
489
+ token_length: number;
490
+ } | undefined;
491
+ k?: number | undefined;
492
+ m?: number | undefined;
493
+ include_original?: boolean | undefined;
494
+ } | undefined;
495
+ ste_vec?: {
496
+ prefix: string;
497
+ array_index_mode?: "all" | "none" | {
498
+ item?: boolean | undefined;
499
+ wildcard?: boolean | undefined;
500
+ position?: boolean | undefined;
501
+ } | undefined;
502
+ mode?: "standard" | "compat" | undefined;
503
+ } | undefined;
504
+ };
505
+ }, {
506
+ cast_as?: "string" | "number" | "bigint" | "boolean" | "date" | "timestamp" | "json" | "text" | undefined;
507
+ indexes?: {
508
+ ore?: {} | undefined;
509
+ ope?: {} | undefined;
510
+ unique?: {
511
+ token_filters?: {
512
+ kind: "downcase";
513
+ }[] | undefined;
514
+ } | undefined;
515
+ match?: {
516
+ token_filters?: {
517
+ kind: "downcase";
518
+ }[] | undefined;
519
+ tokenizer?: {
520
+ kind: "standard";
521
+ } | {
522
+ kind: "ngram";
523
+ token_length: number;
524
+ } | undefined;
525
+ k?: number | undefined;
526
+ m?: number | undefined;
527
+ include_original?: boolean | undefined;
528
+ } | undefined;
529
+ ste_vec?: {
530
+ prefix: string;
531
+ array_index_mode?: "all" | "none" | {
532
+ item?: boolean | undefined;
533
+ wildcard?: boolean | undefined;
534
+ position?: boolean | undefined;
535
+ } | undefined;
536
+ mode?: "standard" | "compat" | undefined;
537
+ } | undefined;
538
+ } | undefined;
539
+ }>>>>>>;
540
+ }, "strip", z.ZodTypeAny, {
541
+ v: number;
542
+ tables: Record<string, Record<string, {
543
+ cast_as: "string" | "number" | "bigint" | "boolean" | "date" | "timestamp" | "json" | "text";
544
+ indexes: {
545
+ ore?: {} | undefined;
546
+ ope?: {} | undefined;
547
+ unique?: {
548
+ token_filters?: {
549
+ kind: "downcase";
550
+ }[] | undefined;
551
+ } | undefined;
552
+ match?: {
553
+ token_filters?: {
554
+ kind: "downcase";
555
+ }[] | undefined;
556
+ tokenizer?: {
557
+ kind: "standard";
558
+ } | {
559
+ kind: "ngram";
560
+ token_length: number;
561
+ } | undefined;
562
+ k?: number | undefined;
563
+ m?: number | undefined;
564
+ include_original?: boolean | undefined;
565
+ } | undefined;
566
+ ste_vec?: {
567
+ prefix: string;
568
+ array_index_mode?: "all" | "none" | {
569
+ item?: boolean | undefined;
570
+ wildcard?: boolean | undefined;
571
+ position?: boolean | undefined;
572
+ } | undefined;
573
+ mode?: "standard" | "compat" | undefined;
574
+ } | undefined;
575
+ };
576
+ }>>;
577
+ }, {
578
+ v: number;
579
+ tables?: Record<string, Record<string, {
580
+ cast_as?: "string" | "number" | "bigint" | "boolean" | "date" | "timestamp" | "json" | "text" | undefined;
581
+ indexes?: {
582
+ ore?: {} | undefined;
583
+ ope?: {} | undefined;
584
+ unique?: {
585
+ token_filters?: {
586
+ kind: "downcase";
587
+ }[] | undefined;
588
+ } | undefined;
589
+ match?: {
590
+ token_filters?: {
591
+ kind: "downcase";
592
+ }[] | undefined;
593
+ tokenizer?: {
594
+ kind: "standard";
595
+ } | {
596
+ kind: "ngram";
597
+ token_length: number;
598
+ } | undefined;
599
+ k?: number | undefined;
600
+ m?: number | undefined;
601
+ include_original?: boolean | undefined;
602
+ } | undefined;
603
+ ste_vec?: {
604
+ prefix: string;
605
+ array_index_mode?: "all" | "none" | {
606
+ item?: boolean | undefined;
607
+ wildcard?: boolean | undefined;
608
+ position?: boolean | undefined;
609
+ } | undefined;
610
+ mode?: "standard" | "compat" | undefined;
611
+ } | undefined;
612
+ } | undefined;
613
+ } | undefined> | undefined> | undefined;
614
+ }>;
615
+ type ColumnSchema = z.infer<typeof columnSchema>;
616
+ type EncryptConfig = z.infer<typeof encryptConfigSchema>;
617
+
618
+ /**
619
+ * The query capabilities a v3 concrete domain exposes. These are SDK-facing
620
+ * semantic flags describing what kinds of query terms a column can produce —
621
+ * NOT the raw EQL index keys. They are metadata only and never emitted by
622
+ * `build()`.
623
+ *
624
+ * - `equality`: exact-match lookups (EQL `hm`, or comparison via `ob`).
625
+ * - `orderAndRange`: comparison / range lookups (EQL `op`, or `ob` on `_ord_ore` domains).
626
+ * - `freeTextSearch`: tokenised substring match (EQL `bf`).
627
+ * - `searchableJson`: encrypted-JSONB containment / selector lookups (EQL
628
+ * `ste_vec`). Optional and mutually exclusive with the scalar flags — a
629
+ * `public.eql_v3_json` document is queried by structure, not by scalar term.
630
+ */
631
+ type QueryCapabilities = Readonly<{
632
+ equality: boolean;
633
+ orderAndRange: boolean;
634
+ freeTextSearch: boolean;
635
+ searchableJson?: boolean;
636
+ }>;
637
+ /**
638
+ * The `cast_as` kinds whose decrypted plaintext reconstructs to a JS `Date`.
639
+ *
640
+ * SINGLE SOURCE OF TRUTH for the date-like set. Both the type-level
641
+ * {@link PlaintextFromKind} and the runtime `rowReconstructor` (encryption/v3.ts)
642
+ * derive their "reconstructs to `Date`" decision from this array, so the next
643
+ * `Date`-backed cast is added in exactly one place — never hand-synced across a
644
+ * type and a runtime guard that could silently drift.
645
+ *
646
+ * (`timestamp` reconstructs to `Date` just like `date`, but its `cast_as` tells
647
+ * the FFI not to truncate the time-of-day.)
648
+ */
649
+ declare const DATE_LIKE_CASTS: readonly ["date", "timestamp"];
650
+ /** A `cast_as` kind that reconstructs to `Date` — see {@link DATE_LIKE_CASTS}. */
651
+ type DateLikeCast = (typeof DATE_LIKE_CASTS)[number];
652
+ /** The plaintext (TypeScript) kind a v3 domain decrypts to. A subset of the
653
+ * SDK `CastAs` enum, restricted to the scalar kinds v3 domains actually use. */
654
+ type PlaintextKind = 'string' | 'number' | 'bigint' | 'boolean' | 'json' | DateLikeCast;
655
+ /**
656
+ * The full, literal definition of a v3 domain. This is the LOAD-BEARING type:
657
+ * the base column class carries a private field of this type so that every
658
+ * concrete (otherwise-empty) subclass is discriminated by its literal
659
+ * `eqlType`/`castAs`/`capabilities` — TypeScript empty subclasses are NOT
660
+ * nominal, so without this a storage-only `boolean` column would be assignable to
661
+ * a storage-only `date` column and plaintext inference would collapse.
662
+ */
663
+ type V3DomainDefinition = Readonly<{
664
+ eqlType: `public.${string}`;
665
+ castAs: PlaintextKind;
666
+ capabilities: QueryCapabilities;
667
+ }>;
668
+ /** Type-level mirror of {@link isQueryableCapabilities}: `false` for a
669
+ * storage-only domain (all capability flags `false`), `true` otherwise. */
670
+ type QueryableFlag<D extends V3DomainDefinition> = D['capabilities'] extends {
671
+ equality: false;
672
+ orderAndRange: false;
673
+ freeTextSearch: false;
674
+ searchableJson?: false | undefined;
675
+ } ? false : true;
676
+ /**
677
+ * The concrete EQL v3 domain name for a full-capability text column.
678
+ * Recorded as metadata for future DDL / query-dialect increments; it is
679
+ * intentionally absent from the emitted encrypt config.
680
+ */
681
+ declare const TEXT_SEARCH_EQL_TYPE = "public.eql_v3_text_search";
682
+ declare const INTEGER: {
683
+ readonly eqlType: "public.eql_v3_integer";
684
+ readonly castAs: "number";
685
+ readonly capabilities: {
686
+ readonly equality: false;
687
+ readonly orderAndRange: false;
688
+ readonly freeTextSearch: false;
689
+ };
690
+ };
691
+ declare const INTEGER_EQ: {
692
+ readonly eqlType: "public.eql_v3_integer_eq";
693
+ readonly castAs: "number";
694
+ readonly capabilities: {
695
+ readonly equality: true;
696
+ readonly orderAndRange: false;
697
+ readonly freeTextSearch: false;
698
+ };
699
+ };
700
+ declare const INTEGER_ORD_ORE: {
701
+ readonly eqlType: "public.eql_v3_integer_ord_ore";
702
+ readonly castAs: "number";
703
+ readonly capabilities: {
704
+ readonly equality: true;
705
+ readonly orderAndRange: true;
706
+ readonly freeTextSearch: false;
707
+ };
708
+ };
709
+ declare const INTEGER_ORD: {
710
+ readonly eqlType: "public.eql_v3_integer_ord";
711
+ readonly castAs: "number";
712
+ readonly capabilities: {
713
+ readonly equality: true;
714
+ readonly orderAndRange: true;
715
+ readonly freeTextSearch: false;
716
+ };
717
+ };
718
+ declare const SMALLINT: {
719
+ readonly eqlType: "public.eql_v3_smallint";
720
+ readonly castAs: "number";
721
+ readonly capabilities: {
722
+ readonly equality: false;
723
+ readonly orderAndRange: false;
724
+ readonly freeTextSearch: false;
725
+ };
726
+ };
727
+ declare const SMALLINT_EQ: {
728
+ readonly eqlType: "public.eql_v3_smallint_eq";
729
+ readonly castAs: "number";
730
+ readonly capabilities: {
731
+ readonly equality: true;
732
+ readonly orderAndRange: false;
733
+ readonly freeTextSearch: false;
734
+ };
735
+ };
736
+ declare const SMALLINT_ORD_ORE: {
737
+ readonly eqlType: "public.eql_v3_smallint_ord_ore";
738
+ readonly castAs: "number";
739
+ readonly capabilities: {
740
+ readonly equality: true;
741
+ readonly orderAndRange: true;
742
+ readonly freeTextSearch: false;
743
+ };
744
+ };
745
+ declare const SMALLINT_ORD: {
746
+ readonly eqlType: "public.eql_v3_smallint_ord";
747
+ readonly castAs: "number";
748
+ readonly capabilities: {
749
+ readonly equality: true;
750
+ readonly orderAndRange: true;
751
+ readonly freeTextSearch: false;
752
+ };
753
+ };
754
+ declare const BIGINT: {
755
+ readonly eqlType: "public.eql_v3_bigint";
756
+ readonly castAs: "bigint";
757
+ readonly capabilities: {
758
+ readonly equality: false;
759
+ readonly orderAndRange: false;
760
+ readonly freeTextSearch: false;
761
+ };
762
+ };
763
+ declare const BIGINT_EQ: {
764
+ readonly eqlType: "public.eql_v3_bigint_eq";
765
+ readonly castAs: "bigint";
766
+ readonly capabilities: {
767
+ readonly equality: true;
768
+ readonly orderAndRange: false;
769
+ readonly freeTextSearch: false;
770
+ };
771
+ };
772
+ declare const BIGINT_ORD_ORE: {
773
+ readonly eqlType: "public.eql_v3_bigint_ord_ore";
774
+ readonly castAs: "bigint";
775
+ readonly capabilities: {
776
+ readonly equality: true;
777
+ readonly orderAndRange: true;
778
+ readonly freeTextSearch: false;
779
+ };
780
+ };
781
+ declare const BIGINT_ORD: {
782
+ readonly eqlType: "public.eql_v3_bigint_ord";
783
+ readonly castAs: "bigint";
784
+ readonly capabilities: {
785
+ readonly equality: true;
786
+ readonly orderAndRange: true;
787
+ readonly freeTextSearch: false;
788
+ };
789
+ };
790
+ declare const DATE: {
791
+ readonly eqlType: "public.eql_v3_date";
792
+ readonly castAs: "date";
793
+ readonly capabilities: {
794
+ readonly equality: false;
795
+ readonly orderAndRange: false;
796
+ readonly freeTextSearch: false;
797
+ };
798
+ };
799
+ declare const DATE_EQ: {
800
+ readonly eqlType: "public.eql_v3_date_eq";
801
+ readonly castAs: "date";
802
+ readonly capabilities: {
803
+ readonly equality: true;
804
+ readonly orderAndRange: false;
805
+ readonly freeTextSearch: false;
806
+ };
807
+ };
808
+ declare const DATE_ORD_ORE: {
809
+ readonly eqlType: "public.eql_v3_date_ord_ore";
810
+ readonly castAs: "date";
811
+ readonly capabilities: {
812
+ readonly equality: true;
813
+ readonly orderAndRange: true;
814
+ readonly freeTextSearch: false;
815
+ };
816
+ };
817
+ declare const DATE_ORD: {
818
+ readonly eqlType: "public.eql_v3_date_ord";
819
+ readonly castAs: "date";
820
+ readonly capabilities: {
821
+ readonly equality: true;
822
+ readonly orderAndRange: true;
823
+ readonly freeTextSearch: false;
824
+ };
825
+ };
826
+ declare const TIMESTAMP: {
827
+ readonly eqlType: "public.eql_v3_timestamp";
828
+ readonly castAs: "timestamp";
829
+ readonly capabilities: {
830
+ readonly equality: false;
831
+ readonly orderAndRange: false;
832
+ readonly freeTextSearch: false;
833
+ };
834
+ };
835
+ declare const TIMESTAMP_EQ: {
836
+ readonly eqlType: "public.eql_v3_timestamp_eq";
837
+ readonly castAs: "timestamp";
838
+ readonly capabilities: {
839
+ readonly equality: true;
840
+ readonly orderAndRange: false;
841
+ readonly freeTextSearch: false;
842
+ };
843
+ };
844
+ declare const TIMESTAMP_ORD_ORE: {
845
+ readonly eqlType: "public.eql_v3_timestamp_ord_ore";
846
+ readonly castAs: "timestamp";
847
+ readonly capabilities: {
848
+ readonly equality: true;
849
+ readonly orderAndRange: true;
850
+ readonly freeTextSearch: false;
851
+ };
852
+ };
853
+ declare const TIMESTAMP_ORD: {
854
+ readonly eqlType: "public.eql_v3_timestamp_ord";
855
+ readonly castAs: "timestamp";
856
+ readonly capabilities: {
857
+ readonly equality: true;
858
+ readonly orderAndRange: true;
859
+ readonly freeTextSearch: false;
860
+ };
861
+ };
862
+ declare const NUMERIC: {
863
+ readonly eqlType: "public.eql_v3_numeric";
864
+ readonly castAs: "number";
865
+ readonly capabilities: {
866
+ readonly equality: false;
867
+ readonly orderAndRange: false;
868
+ readonly freeTextSearch: false;
869
+ };
870
+ };
871
+ declare const NUMERIC_EQ: {
872
+ readonly eqlType: "public.eql_v3_numeric_eq";
873
+ readonly castAs: "number";
874
+ readonly capabilities: {
875
+ readonly equality: true;
876
+ readonly orderAndRange: false;
877
+ readonly freeTextSearch: false;
878
+ };
879
+ };
880
+ declare const NUMERIC_ORD_ORE: {
881
+ readonly eqlType: "public.eql_v3_numeric_ord_ore";
882
+ readonly castAs: "number";
883
+ readonly capabilities: {
884
+ readonly equality: true;
885
+ readonly orderAndRange: true;
886
+ readonly freeTextSearch: false;
887
+ };
888
+ };
889
+ declare const NUMERIC_ORD: {
890
+ readonly eqlType: "public.eql_v3_numeric_ord";
891
+ readonly castAs: "number";
892
+ readonly capabilities: {
893
+ readonly equality: true;
894
+ readonly orderAndRange: true;
895
+ readonly freeTextSearch: false;
896
+ };
897
+ };
898
+ declare const TEXT: {
899
+ readonly eqlType: "public.eql_v3_text";
900
+ readonly castAs: "string";
901
+ readonly capabilities: {
902
+ readonly equality: false;
903
+ readonly orderAndRange: false;
904
+ readonly freeTextSearch: false;
905
+ };
906
+ };
907
+ declare const TEXT_EQ: {
908
+ readonly eqlType: "public.eql_v3_text_eq";
909
+ readonly castAs: "string";
910
+ readonly capabilities: {
911
+ readonly equality: true;
912
+ readonly orderAndRange: false;
913
+ readonly freeTextSearch: false;
914
+ };
915
+ };
916
+ declare const TEXT_MATCH: {
917
+ readonly eqlType: "public.eql_v3_text_match";
918
+ readonly castAs: "string";
919
+ readonly capabilities: {
920
+ readonly equality: false;
921
+ readonly orderAndRange: false;
922
+ readonly freeTextSearch: true;
923
+ };
924
+ };
925
+ declare const TEXT_ORD_ORE: {
926
+ readonly eqlType: "public.eql_v3_text_ord_ore";
927
+ readonly castAs: "string";
928
+ readonly capabilities: {
929
+ readonly equality: true;
930
+ readonly orderAndRange: true;
931
+ readonly freeTextSearch: false;
932
+ };
933
+ };
934
+ declare const TEXT_ORD: {
935
+ readonly eqlType: "public.eql_v3_text_ord";
936
+ readonly castAs: "string";
937
+ readonly capabilities: {
938
+ readonly equality: true;
939
+ readonly orderAndRange: true;
940
+ readonly freeTextSearch: false;
941
+ };
942
+ };
943
+ declare const BOOLEAN: {
944
+ readonly eqlType: "public.eql_v3_boolean";
945
+ readonly castAs: "boolean";
946
+ readonly capabilities: {
947
+ readonly equality: false;
948
+ readonly orderAndRange: false;
949
+ readonly freeTextSearch: false;
950
+ };
951
+ };
952
+ declare const REAL: {
953
+ readonly eqlType: "public.eql_v3_real";
954
+ readonly castAs: "number";
955
+ readonly capabilities: {
956
+ readonly equality: false;
957
+ readonly orderAndRange: false;
958
+ readonly freeTextSearch: false;
959
+ };
960
+ };
961
+ declare const REAL_EQ: {
962
+ readonly eqlType: "public.eql_v3_real_eq";
963
+ readonly castAs: "number";
964
+ readonly capabilities: {
965
+ readonly equality: true;
966
+ readonly orderAndRange: false;
967
+ readonly freeTextSearch: false;
968
+ };
969
+ };
970
+ declare const REAL_ORD_ORE: {
971
+ readonly eqlType: "public.eql_v3_real_ord_ore";
972
+ readonly castAs: "number";
973
+ readonly capabilities: {
974
+ readonly equality: true;
975
+ readonly orderAndRange: true;
976
+ readonly freeTextSearch: false;
977
+ };
978
+ };
979
+ declare const REAL_ORD: {
980
+ readonly eqlType: "public.eql_v3_real_ord";
981
+ readonly castAs: "number";
982
+ readonly capabilities: {
983
+ readonly equality: true;
984
+ readonly orderAndRange: true;
985
+ readonly freeTextSearch: false;
986
+ };
987
+ };
988
+ declare const DOUBLE: {
989
+ readonly eqlType: "public.eql_v3_double";
990
+ readonly castAs: "number";
991
+ readonly capabilities: {
992
+ readonly equality: false;
993
+ readonly orderAndRange: false;
994
+ readonly freeTextSearch: false;
995
+ };
996
+ };
997
+ declare const DOUBLE_EQ: {
998
+ readonly eqlType: "public.eql_v3_double_eq";
999
+ readonly castAs: "number";
1000
+ readonly capabilities: {
1001
+ readonly equality: true;
1002
+ readonly orderAndRange: false;
1003
+ readonly freeTextSearch: false;
1004
+ };
1005
+ };
1006
+ declare const DOUBLE_ORD_ORE: {
1007
+ readonly eqlType: "public.eql_v3_double_ord_ore";
1008
+ readonly castAs: "number";
1009
+ readonly capabilities: {
1010
+ readonly equality: true;
1011
+ readonly orderAndRange: true;
1012
+ readonly freeTextSearch: false;
1013
+ };
1014
+ };
1015
+ declare const DOUBLE_ORD: {
1016
+ readonly eqlType: "public.eql_v3_double_ord";
1017
+ readonly castAs: "number";
1018
+ readonly capabilities: {
1019
+ readonly equality: true;
1020
+ readonly orderAndRange: true;
1021
+ readonly freeTextSearch: false;
1022
+ };
1023
+ };
1024
+ /**
1025
+ * Shared base for every v3 concrete domain column. Parameterised by the FULL
1026
+ * literal {@link V3DomainDefinition} (not by capabilities alone): the private
1027
+ * `definition` field carries the literal `eqlType`/`castAs`/`capabilities`, so
1028
+ * two otherwise-empty subclasses (e.g. `EncryptedBooleanColumn` and
1029
+ * `EncryptedDateColumn`, both storage-only) are NOT mutually assignable. This
1030
+ * nominality is what keeps plaintext inference precise.
1031
+ */
1032
+ declare class EncryptedV3Column<D extends V3DomainDefinition> {
1033
+ private readonly columnName;
1034
+ private readonly definition;
1035
+ constructor(columnName: string, definition: D);
1036
+ getName(): string;
1037
+ /** The concrete EQL v3 domain name. Metadata only; not emitted by `build()`. */
1038
+ getEqlType(): D['eqlType'];
1039
+ /** The semantic query capabilities this domain exposes. Metadata only. */
1040
+ getQueryCapabilities(): D['capabilities'];
1041
+ /** `true` when this domain can produce at least one kind of query term. */
1042
+ isQueryable(): QueryableFlag<D>;
1043
+ /** Emit the encrypt-config column: `cast_as` plus capability-derived indexes. */
1044
+ build(): ColumnSchema;
1045
+ }
1046
+ declare const TEXT_SEARCH_DOMAIN: {
1047
+ readonly eqlType: "public.eql_v3_text_search";
1048
+ readonly castAs: "string";
1049
+ readonly capabilities: {
1050
+ readonly equality: true;
1051
+ readonly orderAndRange: true;
1052
+ readonly freeTextSearch: true;
1053
+ };
1054
+ };
1055
+ /**
1056
+ * Builder for a `public.eql_v3_text_search` column.
1057
+ *
1058
+ * The concrete type inherently enables equality + order/range + free-text
1059
+ * match — there are no capability-enabling or tuning methods. The match index
1060
+ * is always emitted with the default configuration.
1061
+ *
1062
+ * NOTE — querying: a `text_search` column emits all three indexes (`unique`,
1063
+ * `ope`, `match`), and the shared index-inference picks them by fixed priority
1064
+ * `unique > match > ordering`. So `encryptQuery(value, { column, table })` with NO
1065
+ * explicit `queryType` builds an EQUALITY term (via `unique`), NOT a free-text
1066
+ * match — a substring like `'joh'` then matches nothing. To run a free-text
1067
+ * match query you MUST pass `queryType: 'freeTextSearch'`:
1068
+ *
1069
+ * ```typescript
1070
+ * // equality (default): exact value only
1071
+ * client.encryptQuery('john@example.com', { column: users.email, table: users })
1072
+ * // free-text match: substring/token search
1073
+ * client.encryptQuery('joh', { column: users.email, table: users, queryType: 'freeTextSearch' })
1074
+ * ```
1075
+ */
1076
+ declare class EncryptedTextSearchColumn extends EncryptedV3Column<typeof TEXT_SEARCH_DOMAIN> {
1077
+ constructor(columnName: string);
1078
+ }
1079
+ declare class EncryptedIntegerColumn extends EncryptedV3Column<typeof INTEGER> {
1080
+ }
1081
+ declare class EncryptedIntegerEqColumn extends EncryptedV3Column<typeof INTEGER_EQ> {
1082
+ }
1083
+ declare class EncryptedIntegerOrdOreColumn extends EncryptedV3Column<typeof INTEGER_ORD_ORE> {
1084
+ }
1085
+ declare class EncryptedIntegerOrdColumn extends EncryptedV3Column<typeof INTEGER_ORD> {
1086
+ }
1087
+ declare class EncryptedSmallintColumn extends EncryptedV3Column<typeof SMALLINT> {
1088
+ }
1089
+ declare class EncryptedSmallintEqColumn extends EncryptedV3Column<typeof SMALLINT_EQ> {
1090
+ }
1091
+ declare class EncryptedSmallintOrdOreColumn extends EncryptedV3Column<typeof SMALLINT_ORD_ORE> {
1092
+ }
1093
+ declare class EncryptedSmallintOrdColumn extends EncryptedV3Column<typeof SMALLINT_ORD> {
1094
+ }
1095
+ declare class EncryptedBigintColumn extends EncryptedV3Column<typeof BIGINT> {
1096
+ }
1097
+ declare class EncryptedBigintEqColumn extends EncryptedV3Column<typeof BIGINT_EQ> {
1098
+ }
1099
+ declare class EncryptedBigintOrdOreColumn extends EncryptedV3Column<typeof BIGINT_ORD_ORE> {
1100
+ }
1101
+ declare class EncryptedBigintOrdColumn extends EncryptedV3Column<typeof BIGINT_ORD> {
1102
+ }
1103
+ declare class EncryptedDateColumn extends EncryptedV3Column<typeof DATE> {
1104
+ }
1105
+ declare class EncryptedDateEqColumn extends EncryptedV3Column<typeof DATE_EQ> {
1106
+ }
1107
+ declare class EncryptedDateOrdOreColumn extends EncryptedV3Column<typeof DATE_ORD_ORE> {
1108
+ }
1109
+ declare class EncryptedDateOrdColumn extends EncryptedV3Column<typeof DATE_ORD> {
1110
+ }
1111
+ declare class EncryptedTimestampColumn extends EncryptedV3Column<typeof TIMESTAMP> {
1112
+ }
1113
+ declare class EncryptedTimestampEqColumn extends EncryptedV3Column<typeof TIMESTAMP_EQ> {
1114
+ }
1115
+ declare class EncryptedTimestampOrdOreColumn extends EncryptedV3Column<typeof TIMESTAMP_ORD_ORE> {
1116
+ }
1117
+ declare class EncryptedTimestampOrdColumn extends EncryptedV3Column<typeof TIMESTAMP_ORD> {
1118
+ }
1119
+ declare class EncryptedNumericColumn extends EncryptedV3Column<typeof NUMERIC> {
1120
+ }
1121
+ declare class EncryptedNumericEqColumn extends EncryptedV3Column<typeof NUMERIC_EQ> {
1122
+ }
1123
+ declare class EncryptedNumericOrdOreColumn extends EncryptedV3Column<typeof NUMERIC_ORD_ORE> {
1124
+ }
1125
+ declare class EncryptedNumericOrdColumn extends EncryptedV3Column<typeof NUMERIC_ORD> {
1126
+ }
1127
+ declare class EncryptedTextColumn extends EncryptedV3Column<typeof TEXT> {
1128
+ }
1129
+ declare class EncryptedTextEqColumn extends EncryptedV3Column<typeof TEXT_EQ> {
1130
+ }
1131
+ declare class EncryptedTextMatchColumn extends EncryptedV3Column<typeof TEXT_MATCH> {
1132
+ }
1133
+ declare class EncryptedTextOrdOreColumn extends EncryptedV3Column<typeof TEXT_ORD_ORE> {
1134
+ }
1135
+ declare class EncryptedTextOrdColumn extends EncryptedV3Column<typeof TEXT_ORD> {
1136
+ }
1137
+ declare class EncryptedBooleanColumn extends EncryptedV3Column<typeof BOOLEAN> {
1138
+ }
1139
+ declare class EncryptedRealColumn extends EncryptedV3Column<typeof REAL> {
1140
+ }
1141
+ declare class EncryptedRealEqColumn extends EncryptedV3Column<typeof REAL_EQ> {
1142
+ }
1143
+ declare class EncryptedRealOrdOreColumn extends EncryptedV3Column<typeof REAL_ORD_ORE> {
1144
+ }
1145
+ declare class EncryptedRealOrdColumn extends EncryptedV3Column<typeof REAL_ORD> {
1146
+ }
1147
+ declare class EncryptedDoubleColumn extends EncryptedV3Column<typeof DOUBLE> {
1148
+ }
1149
+ declare class EncryptedDoubleEqColumn extends EncryptedV3Column<typeof DOUBLE_EQ> {
1150
+ }
1151
+ declare class EncryptedDoubleOrdOreColumn extends EncryptedV3Column<typeof DOUBLE_ORD_ORE> {
1152
+ }
1153
+ declare class EncryptedDoubleOrdColumn extends EncryptedV3Column<typeof DOUBLE_ORD> {
1154
+ }
1155
+ declare const JSON_DOMAIN: {
1156
+ readonly eqlType: "public.eql_v3_json";
1157
+ readonly castAs: "json";
1158
+ readonly capabilities: {
1159
+ readonly equality: false;
1160
+ readonly orderAndRange: false;
1161
+ readonly freeTextSearch: false;
1162
+ readonly searchableJson: true;
1163
+ };
1164
+ };
1165
+ /**
1166
+ * Builder for a `public.eql_v3_json` column — an encrypted JSONB document
1167
+ * (a {@link JsonDocument}: object, array, or null). It round-trips through
1168
+ * `encrypt`/`decrypt`, and containment queries use the encrypted-JSONB index
1169
+ * emitted by `build()`. (The stored payload is protect-ffi's `SteVecDocument`,
1170
+ * and the config index kind is `ste_vec` — both protect-ffi names.)
1171
+ */
1172
+ declare class EncryptedJsonColumn extends EncryptedV3Column<typeof JSON_DOMAIN> {
1173
+ constructor(columnName: string);
1174
+ }
1175
+ /**
1176
+ * Union of every v3 concrete column type. Used as the value type for v3 table
1177
+ * columns so a table may mix any generated domains.
1178
+ */
1179
+ type AnyEncryptedV3Column = EncryptedIntegerColumn | EncryptedIntegerEqColumn | EncryptedIntegerOrdOreColumn | EncryptedIntegerOrdColumn | EncryptedSmallintColumn | EncryptedSmallintEqColumn | EncryptedSmallintOrdOreColumn | EncryptedSmallintOrdColumn | EncryptedBigintColumn | EncryptedBigintEqColumn | EncryptedBigintOrdOreColumn | EncryptedBigintOrdColumn | EncryptedDateColumn | EncryptedDateEqColumn | EncryptedDateOrdOreColumn | EncryptedDateOrdColumn | EncryptedTimestampColumn | EncryptedTimestampEqColumn | EncryptedTimestampOrdOreColumn | EncryptedTimestampOrdColumn | EncryptedNumericColumn | EncryptedNumericEqColumn | EncryptedNumericOrdOreColumn | EncryptedNumericOrdColumn | EncryptedTextColumn | EncryptedTextEqColumn | EncryptedTextMatchColumn | EncryptedTextOrdOreColumn | EncryptedTextOrdColumn | EncryptedTextSearchColumn | EncryptedBooleanColumn | EncryptedRealColumn | EncryptedRealEqColumn | EncryptedRealOrdOreColumn | EncryptedRealOrdColumn | EncryptedDoubleColumn | EncryptedDoubleEqColumn | EncryptedDoubleOrdOreColumn | EncryptedDoubleOrdColumn | EncryptedJsonColumn;
1180
+ /**
1181
+ * Shape of v3 table columns: every value is a v3 concrete column builder.
1182
+ * (Nested fields are deferred to later increments.)
1183
+ */
1184
+ type EncryptedV3TableColumn = {
1185
+ [key: string]: AnyEncryptedV3Column;
1186
+ };
1187
+ /** A JSON value at any depth. Used for the values NESTED inside a document. */
1188
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
1189
+ [key: string]: JsonValue;
1190
+ };
1191
+ /**
1192
+ * The plaintext a `public.eql_v3_json` column encrypts and reconstructs: a JSON
1193
+ * DOCUMENT — an object, an array, or `null`. NOT a bare top-level scalar:
1194
+ * protect-ffi's `json` cast rejects a top-level string/number/boolean
1195
+ * ("Cannot convert … to Json"), because a scalar belongs in a scalar domain
1196
+ * (`types.TextEq`, `types.IntegerEq`, …). Nested scalars are ordinary
1197
+ * {@link JsonValue}s and are fully supported.
1198
+ */
1199
+ type JsonDocument = null | JsonValue[] | {
1200
+ [key: string]: JsonValue;
1201
+ };
1202
+ /** Map a domain's {@link PlaintextKind} to its TypeScript plaintext type. */
1203
+ type PlaintextFromKind<K extends PlaintextKind> = K extends 'string' ? string : K extends 'number' ? number : K extends 'bigint' ? bigint : K extends 'boolean' ? boolean : K extends DateLikeCast ? Date : K extends 'json' ? JsonDocument : never;
1204
+ /**
1205
+ * The plaintext type for a single v3 column, read from the literal domain
1206
+ * definition carried on the base class's private field. This is stable across
1207
+ * empty subclasses that share the same base generic — a subclass-name
1208
+ * conditional would collapse because those subclasses are structurally
1209
+ * assignable to one another.
1210
+ */
1211
+ type PlaintextForColumn<C> = C extends EncryptedV3Column<infer D> ? PlaintextFromKind<D['castAs']> : never;
1212
+ /**
1213
+ * The user-facing `queryType` names a v3 column supports, derived 1:1 from its
1214
+ * capability flags. Resolves to `never` for a storage-only column (all flags
1215
+ * `false`) and for any non-v3 value. The names mirror the {@link QueryCapabilities}
1216
+ * keys and the first three {@link import('@/types').QueryTypeName} members.
1217
+ */
1218
+ type QueryTypesForColumn<C> = C extends EncryptedV3Column<infer D> ? (D['capabilities']['equality'] extends true ? 'equality' : never) | (D['capabilities']['orderAndRange'] extends true ? 'orderAndRange' : never) | (D['capabilities']['freeTextSearch'] extends true ? 'freeTextSearch' : never) : never;
1219
+ /**
1220
+ * The concrete EQL v3 type string for a single column, read from the literal
1221
+ * domain definition carried on the base class's private field (mirrors
1222
+ * {@link PlaintextForColumn}). Distributes over a union of columns, so
1223
+ * `EqlTypeForColumn<AnyEncryptedV3Column>` yields the union of every domain's
1224
+ * `eqlType` — the canonical, source-of-truth key set for a type-driven test
1225
+ * matrix keyed by domain.
1226
+ */
1227
+ type EqlTypeForColumn<C> = C extends EncryptedV3Column<infer D> ? D['eqlType'] : never;
1228
+
1229
+ interface TableDefinition {
1230
+ tableName: string;
1231
+ columns: Record<string, ColumnSchema>;
1232
+ }
1233
+ /**
1234
+ * A v3 encrypted table. Mirrors the v2 `EncryptedTable` but only accepts v3
1235
+ * column builders. Emits the same `{ tableName, columns }` definition shape.
1236
+ */
1237
+ declare class EncryptedTable<T extends EncryptedV3TableColumn> {
1238
+ readonly tableName: string;
1239
+ readonly columnBuilders: T;
1240
+ /** @internal Type-level brand so TypeScript can infer `T` from `EncryptedTable<T>`. */
1241
+ readonly _columnType: T;
1242
+ constructor(tableName: string, columnBuilders: T);
1243
+ build(): TableDefinition;
1244
+ /**
1245
+ * Map each column's JS property name to its DB column name (`getName()`).
1246
+ * The model path matches user models by property name but must address the
1247
+ * encrypt config and FFI by DB name — `build()` keys columns by DB name, so
1248
+ * the two only agree when property == name. This recovers the mapping that
1249
+ * `build()` discards.
1250
+ *
1251
+ * NULL PROTOTYPE — load-bearing. Callers index this map by a column name that
1252
+ * ultimately comes from the database (`addJsonbCastsV3`, `filterColumnName`,
1253
+ * the mutation transform). On a plain object literal, a column named
1254
+ * `constructor` / `toString` / `valueOf` / `__proto__` resolves to an
1255
+ * inherited `Object.prototype` member, which is truthy — so a *plaintext*
1256
+ * column with such a name would be mistaken for a mapped encrypted column and
1257
+ * its `Object.prototype` value interpolated into the emitted select string.
1258
+ * `encryptedTable()` rejects such names as JS *properties*, but nothing
1259
+ * constrains the DB column names a table may contain.
1260
+ */
1261
+ buildColumnKeyMap(): Record<string, string>;
1262
+ }
1263
+ /**
1264
+ * Define a v3 encrypted table. Intentionally shadows the v2 `encryptedTable`
1265
+ * name but lives on the `/eql/v3` subpath — the importer picks the model by
1266
+ * import path. The returned object is also a column accessor (`users.email`).
1267
+ */
1268
+ declare function encryptedTable<T extends EncryptedV3TableColumn>(tableName: string, columns: T): EncryptedTable<T> & T;
1269
+ /**
1270
+ * Build an `EncryptConfig` (`v: 1`) from one or more v3 tables. Emits the same
1271
+ * shape as v2's `buildEncryptConfig`.
1272
+ */
1273
+ declare function buildEncryptConfig(...tables: Array<EncryptedTable<EncryptedV3TableColumn>>): EncryptConfig;
1274
+ /**
1275
+ * Infer the plaintext (decrypted) shape from a v3 table schema. Each column maps
1276
+ * to the TypeScript type of its domain's `castAs` kind.
1277
+ */
1278
+ type InferPlaintext<T extends EncryptedTable<EncryptedV3TableColumn>> = T extends EncryptedTable<infer C> ? {
1279
+ [K in keyof C]: PlaintextForColumn<C[K]>;
1280
+ } : never;
1281
+ /**
1282
+ * Infer the encrypted shape from a v3 table schema. See {@link InferPlaintext}
1283
+ * for why no key-remap filter is needed in the flat single-type model.
1284
+ */
1285
+ type InferEncrypted<T extends EncryptedTable<EncryptedV3TableColumn>> = T extends EncryptedTable<infer C> ? {
1286
+ [K in keyof C]: Encrypted;
1287
+ } : never;
1288
+ /** Any v3 table, regardless of its column map. */
1289
+ type AnyV3Table = EncryptedTable<EncryptedV3TableColumn>;
1290
+ /** Union of the concrete column builders declared on a v3 table. */
1291
+ type ColumnsOf<T extends AnyV3Table> = T extends EncryptedTable<infer C> ? C[keyof C] : never;
1292
+ /**
1293
+ * Union of the *queryable* column builders on a v3 table. Storage-only columns
1294
+ * (whose {@link QueryTypesForColumn} is `never`) are filtered out, so they can't
1295
+ * be passed to a query method.
1296
+ */
1297
+ type QueryableColumnsOf<T extends AnyV3Table> = T extends EncryptedTable<infer C> ? {
1298
+ [K in keyof C]: [QueryTypesForColumn<C[K]>] extends [never] ? never : C[K];
1299
+ }[keyof C] : never;
1300
+ /**
1301
+ * The accepted input model for {@link import('@/encryption/v3').TypedEncryptionClient.encryptModel}.
1302
+ * `T` is inferred from the argument: keys that name a schema column are pinned to
1303
+ * the column's plaintext type (nullable if the field is nullable), so a wrong-typed
1304
+ * field fails assignability; all other keys pass through unchanged.
1305
+ */
1306
+ type V3ModelInput<Table extends AnyV3Table, T> = {
1307
+ [K in keyof T]: K extends keyof InferPlaintext<Table> ? null extends T[K] ? InferPlaintext<Table>[K] | null : InferPlaintext<Table>[K] : T[K];
1308
+ };
1309
+ /** The encrypted result model: schema columns become `Encrypted`, others pass through. */
1310
+ type V3EncryptedModel<Table extends AnyV3Table, T> = {
1311
+ [K in keyof T]: K extends keyof InferPlaintext<Table> ? null extends T[K] ? Encrypted | null : Encrypted : T[K];
1312
+ };
1313
+ /**
1314
+ * The decrypted result model: schema columns become their plaintext type, others
1315
+ * pass through. Structurally identical to {@link V3ModelInput} — decrypt yields
1316
+ * the same plaintext shape encrypt accepts — so it is aliased rather than
1317
+ * re-declared to keep the input and output shapes from silently drifting when
1318
+ * one copy is edited. The distinct name is kept for call-site readability.
1319
+ */
1320
+ type V3DecryptedModel<Table extends AnyV3Table, T> = V3ModelInput<Table, T>;
1321
+
1322
+ /**
1323
+ * The v3 column-type namespace. Each member is a public, semantic factory name
1324
+ * for a concrete EQL v3 column. Most members mirror the underlying domain name;
1325
+ * JS-friendly scalar names map to Postgres concrete domains, e.g.
1326
+ * `types.IntegerOrd` builds a `public.eql_v3_integer_ord` column and `types.Boolean`
1327
+ * builds a `public.eql_v3_boolean` column.
1328
+ *
1329
+ * If these factory names stop matching the emitted capability/domain surface,
1330
+ * the stack package is out of sync with the underlying EQL build. That is a
1331
+ * version mismatch, not a harmless naming drift.
1332
+ *
1333
+ * Each factory returns the CONCRETE column class instance (never the widened
1334
+ * `AnyEncryptedV3Column`) so per-column plaintext / query-capability inference
1335
+ * stays precise.
1336
+ *
1337
+ * ```ts
1338
+ * import { encryptedTable, types } from '@cipherstash/stack/eql/v3'
1339
+ *
1340
+ * const events = encryptedTable('events', {
1341
+ * actor: types.TextEq('actor'), // equality
1342
+ * weight: types.IntegerOrd('weight'), // order + range
1343
+ * createdAt: types.Timestamp('created_at'), // storage only
1344
+ * })
1345
+ * ```
1346
+ *
1347
+ * `types.TextSearch` is fully described by its type — like every other domain,
1348
+ * it has no capability-bearing or tuning chain. Its match index is always
1349
+ * emitted with the default configuration; run a free-text query by passing
1350
+ * `queryType: 'freeTextSearch'` to `encryptQuery`.
1351
+ */
1352
+ declare const types: {
1353
+ readonly Integer: (name: string) => EncryptedIntegerColumn;
1354
+ readonly IntegerEq: (name: string) => EncryptedIntegerEqColumn;
1355
+ readonly IntegerOrdOre: (name: string) => EncryptedIntegerOrdOreColumn;
1356
+ readonly IntegerOrd: (name: string) => EncryptedIntegerOrdColumn;
1357
+ readonly Smallint: (name: string) => EncryptedSmallintColumn;
1358
+ readonly SmallintEq: (name: string) => EncryptedSmallintEqColumn;
1359
+ readonly SmallintOrdOre: (name: string) => EncryptedSmallintOrdOreColumn;
1360
+ readonly SmallintOrd: (name: string) => EncryptedSmallintOrdColumn;
1361
+ readonly Bigint: (name: string) => EncryptedBigintColumn;
1362
+ readonly BigintEq: (name: string) => EncryptedBigintEqColumn;
1363
+ readonly BigintOrdOre: (name: string) => EncryptedBigintOrdOreColumn;
1364
+ readonly BigintOrd: (name: string) => EncryptedBigintOrdColumn;
1365
+ readonly Date: (name: string) => EncryptedDateColumn;
1366
+ readonly DateEq: (name: string) => EncryptedDateEqColumn;
1367
+ readonly DateOrdOre: (name: string) => EncryptedDateOrdOreColumn;
1368
+ readonly DateOrd: (name: string) => EncryptedDateOrdColumn;
1369
+ readonly Timestamp: (name: string) => EncryptedTimestampColumn;
1370
+ readonly TimestampEq: (name: string) => EncryptedTimestampEqColumn;
1371
+ readonly TimestampOrdOre: (name: string) => EncryptedTimestampOrdOreColumn;
1372
+ readonly TimestampOrd: (name: string) => EncryptedTimestampOrdColumn;
1373
+ readonly Numeric: (name: string) => EncryptedNumericColumn;
1374
+ readonly NumericEq: (name: string) => EncryptedNumericEqColumn;
1375
+ readonly NumericOrdOre: (name: string) => EncryptedNumericOrdOreColumn;
1376
+ readonly NumericOrd: (name: string) => EncryptedNumericOrdColumn;
1377
+ readonly Text: (name: string) => EncryptedTextColumn;
1378
+ readonly TextEq: (name: string) => EncryptedTextEqColumn;
1379
+ readonly TextMatch: (name: string) => EncryptedTextMatchColumn;
1380
+ readonly TextOrdOre: (name: string) => EncryptedTextOrdOreColumn;
1381
+ readonly TextOrd: (name: string) => EncryptedTextOrdColumn;
1382
+ readonly TextSearch: (name: string) => EncryptedTextSearchColumn;
1383
+ readonly Boolean: (name: string) => EncryptedBooleanColumn;
1384
+ readonly Real: (name: string) => EncryptedRealColumn;
1385
+ readonly RealEq: (name: string) => EncryptedRealEqColumn;
1386
+ readonly RealOrdOre: (name: string) => EncryptedRealOrdOreColumn;
1387
+ readonly RealOrd: (name: string) => EncryptedRealOrdColumn;
1388
+ readonly Double: (name: string) => EncryptedDoubleColumn;
1389
+ readonly DoubleEq: (name: string) => EncryptedDoubleEqColumn;
1390
+ readonly DoubleOrdOre: (name: string) => EncryptedDoubleOrdOreColumn;
1391
+ readonly DoubleOrd: (name: string) => EncryptedDoubleOrdColumn;
1392
+ readonly Json: (name: string) => EncryptedJsonColumn;
1393
+ };
1394
+
1395
+ /**
1396
+ * WASM-inline entry for `@cipherstash/stack` — for Deno, Bun, Cloudflare
1397
+ * Workers, Supabase Edge Functions, and any runtime where the native
1398
+ * `@cipherstash/protect-ffi` NAPI bindings are unavailable.
1399
+ *
1400
+ * Mirrors the protect-ffi / auth `/wasm-inline` pattern: the WASM module
1401
+ * is inlined into the JS bundle as a base64 blob (no separate `.wasm`
1402
+ * fetch / file read), so this entry works in environments that disallow
1403
+ * `fs` or relative asset loading.
1404
+ *
1405
+ * Use this import path: `@cipherstash/stack/wasm-inline`
1406
+ *
1407
+ * This entry is EQL v3: author schemas with the `types` DSL / `encryptedTable`
1408
+ * re-exported here (the same authoring surface as `@cipherstash/stack/eql/v3`).
1409
+ *
1410
+ * @example
1411
+ * ```ts
1412
+ * import {
1413
+ * Encryption, encryptedTable, types,
1414
+ * } from "@cipherstash/stack/wasm-inline"
1415
+ *
1416
+ * const users = encryptedTable("users", { email: types.TextSearch("email") })
1417
+ *
1418
+ * const client = await Encryption({
1419
+ * schemas: [users],
1420
+ * config: {
1421
+ * workspaceCrn: Deno.env.get("CS_WORKSPACE_CRN")!,
1422
+ * accessKey: Deno.env.get("CS_CLIENT_ACCESS_KEY")!,
1423
+ * clientId: Deno.env.get("CS_CLIENT_ID")!,
1424
+ * clientKey: Deno.env.get("CS_CLIENT_KEY")!,
1425
+ * },
1426
+ * })
1427
+ *
1428
+ * const enc = await client.encrypt("alice@example.com", {
1429
+ * column: users.email,
1430
+ * table: users,
1431
+ * })
1432
+ * const dec = await client.decrypt(enc)
1433
+ * ```
1434
+ *
1435
+ * For per-user, identity-bound encryption on the edge, build an
1436
+ * `OidcFederationStrategy` (federates an end user's OIDC JWT — Clerk,
1437
+ * Supabase, … — into a CTS service token) and pass it via
1438
+ * `config.authStrategy`:
1439
+ *
1440
+ * ```ts
1441
+ * import { OidcFederationStrategy } from "@cipherstash/stack/wasm-inline"
1442
+ * import { cookieStore } from "@cipherstash/auth/cookies"
1443
+ *
1444
+ * const authStrategy = OidcFederationStrategy.create(
1445
+ * "crn:ap-southeast-2.aws:my-workspace-id", () => getClerkSessionToken(req),
1446
+ * { store: cookieStore({ request: req, responseHeaders }) },
1447
+ * )
1448
+ * const client = await Encryption({ schemas, config: { authStrategy, clientId, clientKey } })
1449
+ * ```
1450
+ *
1451
+ * For service-to-service / CI use with a custom token store, build an
1452
+ * `AccessKeyStrategy.create(workspaceCrn, accessKey, { store })` the same
1453
+ * way (it derives the region from the CRN). Both strategies are
1454
+ * re-exported from this entry.
1455
+ */
1456
+
1457
+ /** Re-exported convenience predicate — same as the raw protect-ffi one. */
1458
+ declare function isEncrypted(value: unknown): boolean;
1459
+ /**
1460
+ * The plaintext shape accepted by `encrypt` and returned by `decrypt`.
1461
+ * Mirrors protect-ffi's `JsPlaintext` (recursive: arrays of any of
1462
+ * these are valid), plus `bigint` for `int8` columns. Re-defined here so
1463
+ * the wasm-inline `.d.ts` doesn't pull in the Node-only protect-ffi types.
1464
+ *
1465
+ * `bigint` is carried natively across the wasm boundary by protect-ffi
1466
+ * 0.28's Rust `encode_plaintext` (which i64-bounds-checks on encrypt and
1467
+ * builds a `js_sys::BigInt` on decrypt), so widening the type here is all
1468
+ * the SDK needs to accept/return `bigint` on the wasm entry point.
1469
+ */
1470
+ type WasmPlaintext = string | number | bigint | boolean | null | Record<string, unknown> | WasmPlaintext[];
1471
+ /**
1472
+ * Config for {@link Encryption} on the WASM entry point.
1473
+ *
1474
+ * The workspace CRN is the single source of truth for workspace
1475
+ * identity and deployment region — matching the Node entry and
1476
+ * protect-ffi 0.25+, which read `CS_WORKSPACE_CRN` and no longer
1477
+ * consult a separate `CS_REGION`. The CRN is passed straight to the
1478
+ * underlying `AccessKeyStrategy`, which derives the region from it, so
1479
+ * there is no `region` field to keep in sync.
1480
+ *
1481
+ * For service-to-service / CI use, pass `accessKey` plus the workspace
1482
+ * `clientId` / `clientKey` and we construct an `AccessKeyStrategy` for
1483
+ * you. To plug in a custom token store (cookies on Supabase Edge, KV on
1484
+ * Cloudflare Workers, …) or to bind encryption to an end user, build the
1485
+ * strategy yourself — `AccessKeyStrategy` or `OidcFederationStrategy` —
1486
+ * and hand it to `config.authStrategy` instead. A pre-built strategy
1487
+ * already carries the CRN, so `workspaceCrn` is optional on that path.
1488
+ *
1489
+ * Mirrors the Node `ClientConfig`: `authStrategy` is the documented field,
1490
+ * `strategy` is retained as a deprecated alias (see below).
1491
+ */
1492
+ type WasmClientConfig = {
1493
+ /** Workspace client identifier — required by the WASM client. */
1494
+ clientId: string;
1495
+ /** Workspace client key — required by the WASM client. */
1496
+ clientKey: string;
1497
+ } & ({
1498
+ /**
1499
+ * CipherStash workspace CRN, e.g.
1500
+ * `"crn:ap-southeast-2.aws:my-workspace-id"`. Required on the
1501
+ * access-key path — it is the single source of truth for workspace
1502
+ * identity and `AccessKeyStrategy` derives the region from it.
1503
+ */
1504
+ workspaceCrn: string;
1505
+ accessKey: string;
1506
+ authStrategy?: never;
1507
+ strategy?: never;
1508
+ } | {
1509
+ /**
1510
+ * Optional on the strategy path. A pre-built `authStrategy` (e.g.
1511
+ * `OidcFederationStrategy.create(workspaceCrn, …)`) already
1512
+ * encapsulates the workspace CRN and region, so the SDK never reads
1513
+ * this — supply it if convenient, omit it otherwise.
1514
+ */
1515
+ workspaceCrn?: string;
1516
+ accessKey?: never;
1517
+ /** A pre-built auth strategy for per-user or M2M authentication. */
1518
+ authStrategy: WasmAuthStrategy;
1519
+ /**
1520
+ * @deprecated Renamed to `authStrategy`. Still honoured for backwards
1521
+ * compatibility (it logs a deprecation warning at runtime) but will be
1522
+ * removed in a future release.
1523
+ */
1524
+ strategy?: WasmAuthStrategy;
1525
+ } | {
1526
+ workspaceCrn?: string;
1527
+ accessKey?: never;
1528
+ authStrategy?: never;
1529
+ /**
1530
+ * @deprecated Renamed to `authStrategy`. Still honoured for backwards
1531
+ * compatibility (it logs a deprecation warning at runtime) but will be
1532
+ * removed in a future release.
1533
+ */
1534
+ strategy: WasmAuthStrategy;
1535
+ });
1536
+ /**
1537
+ * Any auth strategy accepted on the WASM path. Both expose
1538
+ * `getToken(): Promise<Result<TokenResult, AuthFailure>>` — as of
1539
+ * `@cipherstash/auth` 0.41 the token is wrapped in a `@byteslice/result`
1540
+ * envelope. `@cipherstash/protect-ffi` 0.28+ unwraps that envelope (reading
1541
+ * `.data.token`, surfacing `.failure`) inside its WASM `newClient`; 0.27 read
1542
+ * `.token` off the envelope and saw `undefined`, so keep the ffi floor at 0.28.
1543
+ *
1544
+ * - {@link AccessKeyStrategy} — static M2M / CI access key.
1545
+ * - {@link OidcFederationStrategy} — federates an end-user OIDC JWT into a
1546
+ * CTS service token, for per-user identity-bound encryption.
1547
+ */
1548
+ type WasmAuthStrategy = AccessKeyStrategy | OidcFederationStrategy;
1549
+ type WasmEncryptionConfig = {
1550
+ /** One or more EQL v3 tables, authored with `types` / `encryptedTable` from
1551
+ * this entry. The WASM entry is EQL v3 only. */
1552
+ schemas: [AnyV3Table, ...AnyV3Table[]];
1553
+ config: WasmClientConfig;
1554
+ };
1555
+ /**
1556
+ * WASM encryption client. Returned by {@link Encryption}.
1557
+ *
1558
+ * Wraps an opaque `wasmNewClient` handle and exposes a minimal
1559
+ * `encrypt` / `decrypt` surface. Larger surface (bulk, query, model
1560
+ * helpers) lives on the Node entry — port lazily as Deno / edge
1561
+ * consumers demand it.
1562
+ *
1563
+ * Construct via {@link Encryption} — the constructor is private to
1564
+ * prevent callers from wrapping arbitrary objects in this type.
1565
+ */
1566
+ declare class WasmEncryptionClient {
1567
+ /** @internal */
1568
+ private readonly client;
1569
+ /**
1570
+ * @internal Gated by the module-scoped {@link INTERNAL_CONSTRUCT}
1571
+ * symbol: external callers can't obtain it, so {@link Encryption} is
1572
+ * effectively the only constructor. (A `private` constructor would
1573
+ * block {@link Encryption} too, since it lives outside the class.)
1574
+ */
1575
+ constructor(token: symbol, client: unknown);
1576
+ encrypt(plaintext: WasmPlaintext, opts: EncryptOptions): Promise<Encrypted>;
1577
+ decrypt(encrypted: Encrypted): Promise<WasmPlaintext>;
1578
+ isEncrypted(value: unknown): boolean;
1579
+ }
1580
+ /**
1581
+ * Initialize a WASM-backed encryption client.
1582
+ *
1583
+ * Mirrors the Node entry's {@link import('./encryption').Encryption}
1584
+ * factory, but constructs the protect-ffi client via the WASM strategy
1585
+ * API. Use from Deno / Edge / Workers / Bun.
1586
+ */
1587
+ declare function Encryption(config: WasmEncryptionConfig): Promise<WasmEncryptionClient>;
1588
+ /**
1589
+ * Convert SDK-facing `cast_as` values (`'string'`, `'number'`, …) to the
1590
+ * EQL-native variants (`'text'`, `'double'`, …) that the WASM
1591
+ * `newClient` accepts.
1592
+ *
1593
+ * The Node entry of protect-ffi performs this normalization internally
1594
+ * via `normalizeEncryptConfig.js`; the WASM bindings do not. Without
1595
+ * this, the WASM client rejects an `encryptedColumn('email')` (which
1596
+ * defaults to `cast_as: 'string'`) with
1597
+ * `unknown variant `string`, expected one of `big_int`, …`.
1598
+ *
1599
+ * `toEqlCastAs` is exhaustive over the current `CastAs` union; if a new
1600
+ * SDK-facing variant is added without updating that switch, this
1601
+ * function throws synchronously at startup with a clear message rather
1602
+ * than handing `undefined` to the WASM serde (which surfaces as an
1603
+ * opaque `unknown variant 'null'` error).
1604
+ *
1605
+ * @internal exported for unit-test coverage of the drift-guard branch.
1606
+ */
1607
+ declare function normalizeCastAs(config: EncryptConfig): unknown;
1608
+ /**
1609
+ * Resolve a column's name structurally. Accepts any column builder exposing
1610
+ * `getName()` — v2 `EncryptedColumn` / `EncryptedField` AND v3 column builders
1611
+ * (e.g. `EncryptedTextSearchColumn`) alike — matching the structural
1612
+ * `BuildableColumn` contract that `EncryptOptions.column` was widened to.
1613
+ *
1614
+ * An `instanceof EncryptedColumn || EncryptedField` gate would type-check after
1615
+ * the widening but throw at runtime for a v3 column, breaking the type promise;
1616
+ * resolving the name structurally keeps the wasm-inline encrypt entry honest.
1617
+ * The `typeof` check still fails loudly for plain JS callers passing a value
1618
+ * that is not a column builder.
1619
+ *
1620
+ * @internal exported for unit-test coverage.
1621
+ */
1622
+ declare function getColumnName(col: EncryptOptions['column']): string;
1623
+ /**
1624
+ * Reset the once-per-process deprecation-warning latch. Test-only hook so
1625
+ * suites can assert the warning fires deterministically, independent of test
1626
+ * ordering.
1627
+ * @internal
1628
+ */
1629
+ declare function __resetStrategyDeprecationWarningForTests(): void;
1630
+ /**
1631
+ * Resolve the auth strategy for the WASM client from its config: an explicit
1632
+ * `config.authStrategy` (or the deprecated `config.strategy` alias), or — for
1633
+ * the access-key path — an `AccessKeyStrategy` built from the workspace CRN
1634
+ * (region derived from it inside `@cipherstash/auth`). An auth strategy and
1635
+ * `accessKey` are mutually exclusive.
1636
+ *
1637
+ * @internal exported for offline unit coverage of the strategy wiring; the
1638
+ * gated Deno e2e (`e2e/wasm/roundtrip.test.ts`) is the only other exercise of
1639
+ * this path and it skips without real `CS_*` secrets.
1640
+ */
1641
+ declare function resolveStrategy(cfg: WasmClientConfig): WasmAuthStrategy;
1642
+
1643
+ export { type AnyEncryptedV3Column, type AnyV3Table, type ColumnsOf, type Encrypted, EncryptedBigintColumn, EncryptedBigintEqColumn, EncryptedBigintOrdColumn, EncryptedBigintOrdOreColumn, EncryptedBooleanColumn, EncryptedDateColumn, EncryptedDateEqColumn, EncryptedDateOrdColumn, EncryptedDateOrdOreColumn, EncryptedDoubleColumn, EncryptedDoubleEqColumn, EncryptedDoubleOrdColumn, EncryptedDoubleOrdOreColumn, EncryptedIntegerColumn, EncryptedIntegerEqColumn, EncryptedIntegerOrdColumn, EncryptedIntegerOrdOreColumn, EncryptedJsonColumn, EncryptedNumericColumn, EncryptedNumericEqColumn, EncryptedNumericOrdColumn, EncryptedNumericOrdOreColumn, EncryptedRealColumn, EncryptedRealEqColumn, EncryptedRealOrdColumn, EncryptedRealOrdOreColumn, EncryptedSmallintColumn, EncryptedSmallintEqColumn, EncryptedSmallintOrdColumn, EncryptedSmallintOrdOreColumn, EncryptedTable, EncryptedTextColumn, EncryptedTextEqColumn, EncryptedTextMatchColumn, EncryptedTextOrdColumn, EncryptedTextOrdOreColumn, EncryptedTextSearchColumn, EncryptedTimestampColumn, EncryptedTimestampEqColumn, EncryptedTimestampOrdColumn, EncryptedTimestampOrdOreColumn, type EncryptedV3TableColumn, Encryption, type EqlTypeForColumn, type InferEncrypted, type InferPlaintext, type JsonDocument, type JsonValue, type PlaintextForColumn, type QueryCapabilities, type QueryTypesForColumn, type QueryableColumnsOf, TEXT_SEARCH_EQL_TYPE, type V3DecryptedModel, type V3EncryptedModel, type V3ModelInput, type WasmAuthStrategy, type WasmClientConfig, WasmEncryptionClient, type WasmEncryptionConfig, type WasmPlaintext, __resetStrategyDeprecationWarningForTests, buildEncryptConfig, encryptedTable, getColumnName, isEncrypted, normalizeCastAs, resolveStrategy, types };