@cipherstash/stack 0.19.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.
- package/CHANGELOG.md +531 -0
- package/README.md +95 -77
- package/dist/adapter-kit.cjs +923 -0
- package/dist/adapter-kit.cjs.map +1 -0
- package/dist/adapter-kit.d.cts +82 -0
- package/dist/adapter-kit.d.ts +82 -0
- package/dist/adapter-kit.js +47 -0
- package/dist/adapter-kit.js.map +1 -0
- package/dist/base-operation-AOAIvsSB.d.cts +32 -0
- package/dist/base-operation-FXEzUXIq.d.ts +32 -0
- package/dist/{chunk-4AVL4VZD.js → chunk-3B5ZX3IS.js} +3 -1
- package/dist/chunk-3B5ZX3IS.js.map +1 -0
- package/dist/chunk-7333ZC6L.js +48 -0
- package/dist/chunk-7333ZC6L.js.map +1 -0
- package/dist/{chunk-MP3SSDNN.js → chunk-CLM7E4I6.js} +15 -15
- package/dist/{chunk-MP3SSDNN.js.map → chunk-CLM7E4I6.js.map} +1 -1
- package/dist/{chunk-U66S7VIF.js → chunk-V2Q3NYIH.js} +166 -107
- package/dist/chunk-V2Q3NYIH.js.map +1 -0
- package/dist/chunk-X3JRXEIB.js +98 -0
- package/dist/chunk-X3JRXEIB.js.map +1 -0
- package/dist/{chunk-36AA7IBJ.js → chunk-ZTP5QJ27.js} +51 -18
- package/dist/chunk-ZTP5QJ27.js.map +1 -0
- package/dist/client.cjs +29 -12
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +3 -2
- package/dist/client.d.ts +3 -2
- package/dist/client.js +2 -2
- package/dist/{table-DihEAlxG.d.cts → columns-D2_YzrCX.d.cts} +155 -136
- package/dist/{table-CIH7jZ2h.d.ts → columns-rZc7fQHI.d.ts} +155 -136
- package/dist/dynamodb/index.d.cts +3 -2
- package/dist/dynamodb/index.d.ts +3 -2
- package/dist/encryption/index.cjs +54 -16
- package/dist/encryption/index.cjs.map +1 -1
- package/dist/encryption/index.d.cts +807 -6
- package/dist/encryption/index.d.ts +807 -6
- package/dist/encryption/index.js +4 -4
- package/dist/encryption/v3.cjs +1078 -973
- package/dist/encryption/v3.cjs.map +1 -1
- package/dist/encryption/v3.d.cts +15 -12
- package/dist/encryption/v3.d.ts +15 -12
- package/dist/encryption/v3.js +49 -21
- package/dist/encryption/v3.js.map +1 -1
- package/dist/eql/v3/index.cjs +130 -79
- package/dist/eql/v3/index.cjs.map +1 -1
- package/dist/eql/v3/index.d.cts +115 -13
- package/dist/eql/v3/index.d.ts +115 -13
- package/dist/eql/v3/index.js +16 -6
- package/dist/index-BquA71_Y.d.ts +24 -0
- package/dist/index-fhWTOV0K.d.cts +24 -0
- package/dist/index.cjs +79 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -17
- package/dist/index.d.ts +5 -17
- package/dist/index.js +4 -4
- package/dist/schema/index.cjs +29 -12
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +1 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.js +2 -2
- package/dist/{types-public-CpS5KjwX.d.ts → types-public-QMjYNfQO.d.cts} +765 -726
- package/dist/{types-public-CpS5KjwX.d.cts → types-public-QMjYNfQO.d.ts} +765 -726
- package/dist/types-public.cjs.map +1 -1
- package/dist/types-public.d.cts +1 -1
- package/dist/types-public.d.ts +1 -1
- package/dist/types-public.js +1 -1
- package/dist/wasm-inline.d.ts +779 -405
- package/dist/wasm-inline.js +606 -299
- package/dist/wasm-inline.js.map +1 -1
- package/package.json +25 -53
- package/dist/chunk-36AA7IBJ.js.map +0 -1
- package/dist/chunk-4AVL4VZD.js.map +0 -1
- package/dist/chunk-IADZCZEA.js +0 -23
- package/dist/chunk-IADZCZEA.js.map +0 -1
- package/dist/chunk-IBSK6P33.js +0 -209
- package/dist/chunk-IBSK6P33.js.map +0 -1
- package/dist/chunk-U66S7VIF.js.map +0 -1
- package/dist/client-DSGHBN-g.d.cts +0 -834
- package/dist/client-DfCrlHXh.d.ts +0 -834
- package/dist/drizzle/index.cjs +0 -5617
- package/dist/drizzle/index.cjs.map +0 -1
- package/dist/drizzle/index.d.cts +0 -358
- package/dist/drizzle/index.d.ts +0 -358
- package/dist/drizzle/index.js +0 -1220
- package/dist/drizzle/index.js.map +0 -1
- package/dist/supabase/index.cjs +0 -5951
- package/dist/supabase/index.cjs.map +0 -1
- package/dist/supabase/index.d.cts +0 -223
- package/dist/supabase/index.d.ts +0 -223
- package/dist/supabase/index.js +0 -1217
- package/dist/supabase/index.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
cloneMatchOpts,
|
|
3
2
|
defaultMatchOpts
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7333ZC6L.js";
|
|
5
4
|
|
|
6
5
|
// src/eql/v3/columns.ts
|
|
6
|
+
var DATE_LIKE_CASTS = ["date", "timestamp"];
|
|
7
7
|
var STORAGE_ONLY = {
|
|
8
8
|
equality: false,
|
|
9
9
|
orderAndRange: false,
|
|
@@ -29,192 +29,222 @@ var TEXT_SEARCH = {
|
|
|
29
29
|
orderAndRange: true,
|
|
30
30
|
freeTextSearch: true
|
|
31
31
|
};
|
|
32
|
-
var TEXT_SEARCH_EQL_TYPE = "
|
|
32
|
+
var TEXT_SEARCH_EQL_TYPE = "public.eql_v3_text_search";
|
|
33
33
|
var INTEGER = {
|
|
34
|
-
eqlType: "
|
|
34
|
+
eqlType: "public.eql_v3_integer",
|
|
35
35
|
castAs: "number",
|
|
36
36
|
capabilities: STORAGE_ONLY
|
|
37
37
|
};
|
|
38
38
|
var INTEGER_EQ = {
|
|
39
|
-
eqlType: "
|
|
39
|
+
eqlType: "public.eql_v3_integer_eq",
|
|
40
40
|
castAs: "number",
|
|
41
41
|
capabilities: EQUALITY_ONLY
|
|
42
42
|
};
|
|
43
43
|
var INTEGER_ORD_ORE = {
|
|
44
|
-
eqlType: "
|
|
44
|
+
eqlType: "public.eql_v3_integer_ord_ore",
|
|
45
45
|
castAs: "number",
|
|
46
46
|
capabilities: ORDER_AND_RANGE
|
|
47
47
|
};
|
|
48
48
|
var INTEGER_ORD = {
|
|
49
|
-
eqlType: "
|
|
49
|
+
eqlType: "public.eql_v3_integer_ord",
|
|
50
50
|
castAs: "number",
|
|
51
51
|
capabilities: ORDER_AND_RANGE
|
|
52
52
|
};
|
|
53
53
|
var SMALLINT = {
|
|
54
|
-
eqlType: "
|
|
54
|
+
eqlType: "public.eql_v3_smallint",
|
|
55
55
|
castAs: "number",
|
|
56
56
|
capabilities: STORAGE_ONLY
|
|
57
57
|
};
|
|
58
58
|
var SMALLINT_EQ = {
|
|
59
|
-
eqlType: "
|
|
59
|
+
eqlType: "public.eql_v3_smallint_eq",
|
|
60
60
|
castAs: "number",
|
|
61
61
|
capabilities: EQUALITY_ONLY
|
|
62
62
|
};
|
|
63
63
|
var SMALLINT_ORD_ORE = {
|
|
64
|
-
eqlType: "
|
|
64
|
+
eqlType: "public.eql_v3_smallint_ord_ore",
|
|
65
65
|
castAs: "number",
|
|
66
66
|
capabilities: ORDER_AND_RANGE
|
|
67
67
|
};
|
|
68
68
|
var SMALLINT_ORD = {
|
|
69
|
-
eqlType: "
|
|
69
|
+
eqlType: "public.eql_v3_smallint_ord",
|
|
70
70
|
castAs: "number",
|
|
71
71
|
capabilities: ORDER_AND_RANGE
|
|
72
72
|
};
|
|
73
|
+
var BIGINT = {
|
|
74
|
+
eqlType: "public.eql_v3_bigint",
|
|
75
|
+
castAs: "bigint",
|
|
76
|
+
capabilities: STORAGE_ONLY
|
|
77
|
+
};
|
|
78
|
+
var BIGINT_EQ = {
|
|
79
|
+
eqlType: "public.eql_v3_bigint_eq",
|
|
80
|
+
castAs: "bigint",
|
|
81
|
+
capabilities: EQUALITY_ONLY
|
|
82
|
+
};
|
|
83
|
+
var BIGINT_ORD_ORE = {
|
|
84
|
+
eqlType: "public.eql_v3_bigint_ord_ore",
|
|
85
|
+
castAs: "bigint",
|
|
86
|
+
capabilities: ORDER_AND_RANGE
|
|
87
|
+
};
|
|
88
|
+
var BIGINT_ORD = {
|
|
89
|
+
eqlType: "public.eql_v3_bigint_ord",
|
|
90
|
+
castAs: "bigint",
|
|
91
|
+
capabilities: ORDER_AND_RANGE
|
|
92
|
+
};
|
|
73
93
|
var DATE = {
|
|
74
|
-
eqlType: "
|
|
94
|
+
eqlType: "public.eql_v3_date",
|
|
75
95
|
castAs: "date",
|
|
76
96
|
capabilities: STORAGE_ONLY
|
|
77
97
|
};
|
|
78
98
|
var DATE_EQ = {
|
|
79
|
-
eqlType: "
|
|
99
|
+
eqlType: "public.eql_v3_date_eq",
|
|
80
100
|
castAs: "date",
|
|
81
101
|
capabilities: EQUALITY_ONLY
|
|
82
102
|
};
|
|
83
103
|
var DATE_ORD_ORE = {
|
|
84
|
-
eqlType: "
|
|
104
|
+
eqlType: "public.eql_v3_date_ord_ore",
|
|
85
105
|
castAs: "date",
|
|
86
106
|
capabilities: ORDER_AND_RANGE
|
|
87
107
|
};
|
|
88
108
|
var DATE_ORD = {
|
|
89
|
-
eqlType: "
|
|
109
|
+
eqlType: "public.eql_v3_date_ord",
|
|
90
110
|
castAs: "date",
|
|
91
111
|
capabilities: ORDER_AND_RANGE
|
|
92
112
|
};
|
|
93
113
|
var TIMESTAMP = {
|
|
94
|
-
eqlType: "
|
|
114
|
+
eqlType: "public.eql_v3_timestamp",
|
|
95
115
|
castAs: "timestamp",
|
|
96
116
|
capabilities: STORAGE_ONLY
|
|
97
117
|
};
|
|
98
118
|
var TIMESTAMP_EQ = {
|
|
99
|
-
eqlType: "
|
|
119
|
+
eqlType: "public.eql_v3_timestamp_eq",
|
|
100
120
|
castAs: "timestamp",
|
|
101
121
|
capabilities: EQUALITY_ONLY
|
|
102
122
|
};
|
|
103
123
|
var TIMESTAMP_ORD_ORE = {
|
|
104
|
-
eqlType: "
|
|
124
|
+
eqlType: "public.eql_v3_timestamp_ord_ore",
|
|
105
125
|
castAs: "timestamp",
|
|
106
126
|
capabilities: ORDER_AND_RANGE
|
|
107
127
|
};
|
|
108
128
|
var TIMESTAMP_ORD = {
|
|
109
|
-
eqlType: "
|
|
129
|
+
eqlType: "public.eql_v3_timestamp_ord",
|
|
110
130
|
castAs: "timestamp",
|
|
111
131
|
capabilities: ORDER_AND_RANGE
|
|
112
132
|
};
|
|
113
133
|
var NUMERIC = {
|
|
114
|
-
eqlType: "
|
|
134
|
+
eqlType: "public.eql_v3_numeric",
|
|
115
135
|
castAs: "number",
|
|
116
136
|
capabilities: STORAGE_ONLY
|
|
117
137
|
};
|
|
118
138
|
var NUMERIC_EQ = {
|
|
119
|
-
eqlType: "
|
|
139
|
+
eqlType: "public.eql_v3_numeric_eq",
|
|
120
140
|
castAs: "number",
|
|
121
141
|
capabilities: EQUALITY_ONLY
|
|
122
142
|
};
|
|
123
143
|
var NUMERIC_ORD_ORE = {
|
|
124
|
-
eqlType: "
|
|
144
|
+
eqlType: "public.eql_v3_numeric_ord_ore",
|
|
125
145
|
castAs: "number",
|
|
126
146
|
capabilities: ORDER_AND_RANGE
|
|
127
147
|
};
|
|
128
148
|
var NUMERIC_ORD = {
|
|
129
|
-
eqlType: "
|
|
149
|
+
eqlType: "public.eql_v3_numeric_ord",
|
|
130
150
|
castAs: "number",
|
|
131
151
|
capabilities: ORDER_AND_RANGE
|
|
132
152
|
};
|
|
133
153
|
var TEXT = {
|
|
134
|
-
eqlType: "
|
|
154
|
+
eqlType: "public.eql_v3_text",
|
|
135
155
|
castAs: "string",
|
|
136
156
|
capabilities: STORAGE_ONLY
|
|
137
157
|
};
|
|
138
158
|
var TEXT_EQ = {
|
|
139
|
-
eqlType: "
|
|
159
|
+
eqlType: "public.eql_v3_text_eq",
|
|
140
160
|
castAs: "string",
|
|
141
161
|
capabilities: EQUALITY_ONLY
|
|
142
162
|
};
|
|
143
163
|
var TEXT_MATCH = {
|
|
144
|
-
eqlType: "
|
|
164
|
+
eqlType: "public.eql_v3_text_match",
|
|
145
165
|
castAs: "string",
|
|
146
166
|
capabilities: MATCH_ONLY
|
|
147
167
|
};
|
|
148
168
|
var TEXT_ORD_ORE = {
|
|
149
|
-
eqlType: "
|
|
169
|
+
eqlType: "public.eql_v3_text_ord_ore",
|
|
150
170
|
castAs: "string",
|
|
151
171
|
capabilities: ORDER_AND_RANGE
|
|
152
172
|
};
|
|
153
173
|
var TEXT_ORD = {
|
|
154
|
-
eqlType: "
|
|
174
|
+
eqlType: "public.eql_v3_text_ord",
|
|
155
175
|
castAs: "string",
|
|
156
176
|
capabilities: ORDER_AND_RANGE
|
|
157
177
|
};
|
|
158
178
|
var BOOLEAN = {
|
|
159
|
-
eqlType: "
|
|
179
|
+
eqlType: "public.eql_v3_boolean",
|
|
160
180
|
castAs: "boolean",
|
|
161
181
|
capabilities: STORAGE_ONLY
|
|
162
182
|
};
|
|
163
183
|
var REAL = {
|
|
164
|
-
eqlType: "
|
|
184
|
+
eqlType: "public.eql_v3_real",
|
|
165
185
|
castAs: "number",
|
|
166
186
|
capabilities: STORAGE_ONLY
|
|
167
187
|
};
|
|
168
188
|
var REAL_EQ = {
|
|
169
|
-
eqlType: "
|
|
189
|
+
eqlType: "public.eql_v3_real_eq",
|
|
170
190
|
castAs: "number",
|
|
171
191
|
capabilities: EQUALITY_ONLY
|
|
172
192
|
};
|
|
173
193
|
var REAL_ORD_ORE = {
|
|
174
|
-
eqlType: "
|
|
194
|
+
eqlType: "public.eql_v3_real_ord_ore",
|
|
175
195
|
castAs: "number",
|
|
176
196
|
capabilities: ORDER_AND_RANGE
|
|
177
197
|
};
|
|
178
198
|
var REAL_ORD = {
|
|
179
|
-
eqlType: "
|
|
199
|
+
eqlType: "public.eql_v3_real_ord",
|
|
180
200
|
castAs: "number",
|
|
181
201
|
capabilities: ORDER_AND_RANGE
|
|
182
202
|
};
|
|
183
203
|
var DOUBLE = {
|
|
184
|
-
eqlType: "
|
|
204
|
+
eqlType: "public.eql_v3_double",
|
|
185
205
|
castAs: "number",
|
|
186
206
|
capabilities: STORAGE_ONLY
|
|
187
207
|
};
|
|
188
208
|
var DOUBLE_EQ = {
|
|
189
|
-
eqlType: "
|
|
209
|
+
eqlType: "public.eql_v3_double_eq",
|
|
190
210
|
castAs: "number",
|
|
191
211
|
capabilities: EQUALITY_ONLY
|
|
192
212
|
};
|
|
193
213
|
var DOUBLE_ORD_ORE = {
|
|
194
|
-
eqlType: "
|
|
214
|
+
eqlType: "public.eql_v3_double_ord_ore",
|
|
195
215
|
castAs: "number",
|
|
196
216
|
capabilities: ORDER_AND_RANGE
|
|
197
217
|
};
|
|
198
218
|
var DOUBLE_ORD = {
|
|
199
|
-
eqlType: "
|
|
219
|
+
eqlType: "public.eql_v3_double_ord",
|
|
200
220
|
castAs: "number",
|
|
201
221
|
capabilities: ORDER_AND_RANGE
|
|
202
222
|
};
|
|
203
|
-
function indexesForCapabilities(capabilities, castAs) {
|
|
223
|
+
function indexesForCapabilities(capabilities, castAs, ordering) {
|
|
204
224
|
const indexes = {};
|
|
205
225
|
if (capabilities.equality && (!capabilities.orderAndRange || castAs === "string")) {
|
|
206
226
|
indexes.unique = { token_filters: [] };
|
|
207
227
|
}
|
|
208
228
|
if (capabilities.orderAndRange) {
|
|
209
|
-
indexes
|
|
229
|
+
indexes[ordering] = {};
|
|
210
230
|
}
|
|
211
231
|
if (capabilities.freeTextSearch) {
|
|
212
|
-
indexes.match = defaultMatchOpts();
|
|
232
|
+
indexes.match = { ...defaultMatchOpts(), include_original: false };
|
|
233
|
+
}
|
|
234
|
+
if (capabilities.searchableJson) {
|
|
235
|
+
indexes.ste_vec = {
|
|
236
|
+
prefix: "enabled",
|
|
237
|
+
array_index_mode: { item: true, wildcard: true, position: false },
|
|
238
|
+
mode: "compat"
|
|
239
|
+
};
|
|
213
240
|
}
|
|
214
241
|
return indexes;
|
|
215
242
|
}
|
|
243
|
+
function orderingForEqlType(eqlType) {
|
|
244
|
+
return eqlType.endsWith("_ord_ore") ? "ore" : "ope";
|
|
245
|
+
}
|
|
216
246
|
function isQueryableCapabilities(capabilities) {
|
|
217
|
-
return capabilities.equality || capabilities.orderAndRange || capabilities.freeTextSearch;
|
|
247
|
+
return capabilities.equality || capabilities.orderAndRange || capabilities.freeTextSearch || (capabilities.searchableJson ?? false);
|
|
218
248
|
}
|
|
219
249
|
var EncryptedV3Column = class {
|
|
220
250
|
constructor(columnName, definition) {
|
|
@@ -246,7 +276,8 @@ var EncryptedV3Column = class {
|
|
|
246
276
|
cast_as: this.definition.castAs,
|
|
247
277
|
indexes: indexesForCapabilities(
|
|
248
278
|
this.definition.capabilities,
|
|
249
|
-
this.definition.castAs
|
|
279
|
+
this.definition.castAs,
|
|
280
|
+
orderingForEqlType(this.definition.eqlType)
|
|
250
281
|
)
|
|
251
282
|
};
|
|
252
283
|
}
|
|
@@ -257,37 +288,8 @@ var TEXT_SEARCH_DOMAIN = {
|
|
|
257
288
|
capabilities: TEXT_SEARCH
|
|
258
289
|
};
|
|
259
290
|
var EncryptedTextSearchColumn = class extends EncryptedV3Column {
|
|
260
|
-
matchOpts;
|
|
261
291
|
constructor(columnName) {
|
|
262
292
|
super(columnName, TEXT_SEARCH_DOMAIN);
|
|
263
|
-
this.matchOpts = defaultMatchOpts();
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Tune the match index. Each provided key replaces its default; omitted
|
|
267
|
-
* keys keep the default. This NEVER enables a capability — match is always
|
|
268
|
-
* on for this type. Merge semantics mirror v2's `opts?.x ?? default`.
|
|
269
|
-
*/
|
|
270
|
-
freeTextSearch(opts) {
|
|
271
|
-
const defaults = defaultMatchOpts();
|
|
272
|
-
this.matchOpts = cloneMatchOpts({
|
|
273
|
-
tokenizer: opts?.tokenizer ?? defaults.tokenizer,
|
|
274
|
-
token_filters: opts?.token_filters ?? defaults.token_filters,
|
|
275
|
-
k: opts?.k ?? defaults.k,
|
|
276
|
-
m: opts?.m ?? defaults.m,
|
|
277
|
-
include_original: opts?.include_original ?? defaults.include_original
|
|
278
|
-
});
|
|
279
|
-
return this;
|
|
280
|
-
}
|
|
281
|
-
/** Emit the encrypt-config column. Byte-identical to a v2 equality+order+match column. */
|
|
282
|
-
build() {
|
|
283
|
-
return {
|
|
284
|
-
cast_as: "string",
|
|
285
|
-
indexes: {
|
|
286
|
-
unique: { token_filters: [] },
|
|
287
|
-
ore: {},
|
|
288
|
-
match: cloneMatchOpts(this.matchOpts)
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
293
|
}
|
|
292
294
|
};
|
|
293
295
|
var EncryptedIntegerColumn = class extends EncryptedV3Column {
|
|
@@ -306,6 +308,14 @@ var EncryptedSmallintOrdOreColumn = class extends EncryptedV3Column {
|
|
|
306
308
|
};
|
|
307
309
|
var EncryptedSmallintOrdColumn = class extends EncryptedV3Column {
|
|
308
310
|
};
|
|
311
|
+
var EncryptedBigintColumn = class extends EncryptedV3Column {
|
|
312
|
+
};
|
|
313
|
+
var EncryptedBigintEqColumn = class extends EncryptedV3Column {
|
|
314
|
+
};
|
|
315
|
+
var EncryptedBigintOrdOreColumn = class extends EncryptedV3Column {
|
|
316
|
+
};
|
|
317
|
+
var EncryptedBigintOrdColumn = class extends EncryptedV3Column {
|
|
318
|
+
};
|
|
309
319
|
var EncryptedDateColumn = class extends EncryptedV3Column {
|
|
310
320
|
};
|
|
311
321
|
var EncryptedDateEqColumn = class extends EncryptedV3Column {
|
|
@@ -358,43 +368,86 @@ var EncryptedDoubleOrdOreColumn = class extends EncryptedV3Column {
|
|
|
358
368
|
};
|
|
359
369
|
var EncryptedDoubleOrdColumn = class extends EncryptedV3Column {
|
|
360
370
|
};
|
|
371
|
+
var JSON_DOMAIN = {
|
|
372
|
+
eqlType: "public.eql_v3_json",
|
|
373
|
+
castAs: "json",
|
|
374
|
+
capabilities: {
|
|
375
|
+
equality: false,
|
|
376
|
+
orderAndRange: false,
|
|
377
|
+
freeTextSearch: false,
|
|
378
|
+
searchableJson: true
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
var EncryptedJsonColumn = class extends EncryptedV3Column {
|
|
382
|
+
constructor(columnName) {
|
|
383
|
+
super(columnName, JSON_DOMAIN);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
// src/eql/v3/types.ts
|
|
388
|
+
var types = {
|
|
389
|
+
// integer
|
|
390
|
+
Integer: (name) => new EncryptedIntegerColumn(name, INTEGER),
|
|
391
|
+
IntegerEq: (name) => new EncryptedIntegerEqColumn(name, INTEGER_EQ),
|
|
392
|
+
IntegerOrdOre: (name) => new EncryptedIntegerOrdOreColumn(name, INTEGER_ORD_ORE),
|
|
393
|
+
IntegerOrd: (name) => new EncryptedIntegerOrdColumn(name, INTEGER_ORD),
|
|
394
|
+
// smallint
|
|
395
|
+
Smallint: (name) => new EncryptedSmallintColumn(name, SMALLINT),
|
|
396
|
+
SmallintEq: (name) => new EncryptedSmallintEqColumn(name, SMALLINT_EQ),
|
|
397
|
+
SmallintOrdOre: (name) => new EncryptedSmallintOrdOreColumn(name, SMALLINT_ORD_ORE),
|
|
398
|
+
SmallintOrd: (name) => new EncryptedSmallintOrdColumn(name, SMALLINT_ORD),
|
|
399
|
+
// bigint (int8) — plaintext is a JS `bigint`, round-tripped losslessly by
|
|
400
|
+
// the native protect-ffi boundary (see ./columns)
|
|
401
|
+
Bigint: (name) => new EncryptedBigintColumn(name, BIGINT),
|
|
402
|
+
BigintEq: (name) => new EncryptedBigintEqColumn(name, BIGINT_EQ),
|
|
403
|
+
BigintOrdOre: (name) => new EncryptedBigintOrdOreColumn(name, BIGINT_ORD_ORE),
|
|
404
|
+
BigintOrd: (name) => new EncryptedBigintOrdColumn(name, BIGINT_ORD),
|
|
405
|
+
// date
|
|
406
|
+
Date: (name) => new EncryptedDateColumn(name, DATE),
|
|
407
|
+
DateEq: (name) => new EncryptedDateEqColumn(name, DATE_EQ),
|
|
408
|
+
DateOrdOre: (name) => new EncryptedDateOrdOreColumn(name, DATE_ORD_ORE),
|
|
409
|
+
DateOrd: (name) => new EncryptedDateOrdColumn(name, DATE_ORD),
|
|
410
|
+
// timestamp
|
|
411
|
+
Timestamp: (name) => new EncryptedTimestampColumn(name, TIMESTAMP),
|
|
412
|
+
TimestampEq: (name) => new EncryptedTimestampEqColumn(name, TIMESTAMP_EQ),
|
|
413
|
+
TimestampOrdOre: (name) => new EncryptedTimestampOrdOreColumn(name, TIMESTAMP_ORD_ORE),
|
|
414
|
+
TimestampOrd: (name) => new EncryptedTimestampOrdColumn(name, TIMESTAMP_ORD),
|
|
415
|
+
// numeric
|
|
416
|
+
Numeric: (name) => new EncryptedNumericColumn(name, NUMERIC),
|
|
417
|
+
NumericEq: (name) => new EncryptedNumericEqColumn(name, NUMERIC_EQ),
|
|
418
|
+
NumericOrdOre: (name) => new EncryptedNumericOrdOreColumn(name, NUMERIC_ORD_ORE),
|
|
419
|
+
NumericOrd: (name) => new EncryptedNumericOrdColumn(name, NUMERIC_ORD),
|
|
420
|
+
// text
|
|
421
|
+
Text: (name) => new EncryptedTextColumn(name, TEXT),
|
|
422
|
+
TextEq: (name) => new EncryptedTextEqColumn(name, TEXT_EQ),
|
|
423
|
+
TextMatch: (name) => new EncryptedTextMatchColumn(name, TEXT_MATCH),
|
|
424
|
+
TextOrdOre: (name) => new EncryptedTextOrdOreColumn(name, TEXT_ORD_ORE),
|
|
425
|
+
TextOrd: (name) => new EncryptedTextOrdColumn(name, TEXT_ORD),
|
|
426
|
+
TextSearch: (name) => new EncryptedTextSearchColumn(name),
|
|
427
|
+
// boolean
|
|
428
|
+
Boolean: (name) => new EncryptedBooleanColumn(name, BOOLEAN),
|
|
429
|
+
// real
|
|
430
|
+
Real: (name) => new EncryptedRealColumn(name, REAL),
|
|
431
|
+
RealEq: (name) => new EncryptedRealEqColumn(name, REAL_EQ),
|
|
432
|
+
RealOrdOre: (name) => new EncryptedRealOrdOreColumn(name, REAL_ORD_ORE),
|
|
433
|
+
RealOrd: (name) => new EncryptedRealOrdColumn(name, REAL_ORD),
|
|
434
|
+
// double
|
|
435
|
+
Double: (name) => new EncryptedDoubleColumn(name, DOUBLE),
|
|
436
|
+
DoubleEq: (name) => new EncryptedDoubleEqColumn(name, DOUBLE_EQ),
|
|
437
|
+
DoubleOrdOre: (name) => new EncryptedDoubleOrdOreColumn(name, DOUBLE_ORD_ORE),
|
|
438
|
+
DoubleOrd: (name) => new EncryptedDoubleOrdColumn(name, DOUBLE_ORD),
|
|
439
|
+
// json (encrypted JSONB document, ste_vec containment)
|
|
440
|
+
Json: (name) => new EncryptedJsonColumn(name)
|
|
441
|
+
// `satisfies` is load-bearing, not decoration: `DOMAIN_REGISTRY` derives itself
|
|
442
|
+
// by calling every value here at module load. A non-factory export would throw
|
|
443
|
+
// during module evaluation and take the supabase introspect/schema-build/verify
|
|
444
|
+
// path down with it. This turns that into a compile error at the offending line.
|
|
445
|
+
// `as const` applies first, so literal key inference is preserved.
|
|
446
|
+
};
|
|
361
447
|
|
|
362
448
|
export {
|
|
449
|
+
DATE_LIKE_CASTS,
|
|
363
450
|
TEXT_SEARCH_EQL_TYPE,
|
|
364
|
-
INTEGER,
|
|
365
|
-
INTEGER_EQ,
|
|
366
|
-
INTEGER_ORD_ORE,
|
|
367
|
-
INTEGER_ORD,
|
|
368
|
-
SMALLINT,
|
|
369
|
-
SMALLINT_EQ,
|
|
370
|
-
SMALLINT_ORD_ORE,
|
|
371
|
-
SMALLINT_ORD,
|
|
372
|
-
DATE,
|
|
373
|
-
DATE_EQ,
|
|
374
|
-
DATE_ORD_ORE,
|
|
375
|
-
DATE_ORD,
|
|
376
|
-
TIMESTAMP,
|
|
377
|
-
TIMESTAMP_EQ,
|
|
378
|
-
TIMESTAMP_ORD_ORE,
|
|
379
|
-
TIMESTAMP_ORD,
|
|
380
|
-
NUMERIC,
|
|
381
|
-
NUMERIC_EQ,
|
|
382
|
-
NUMERIC_ORD_ORE,
|
|
383
|
-
NUMERIC_ORD,
|
|
384
|
-
TEXT,
|
|
385
|
-
TEXT_EQ,
|
|
386
|
-
TEXT_MATCH,
|
|
387
|
-
TEXT_ORD_ORE,
|
|
388
|
-
TEXT_ORD,
|
|
389
|
-
BOOLEAN,
|
|
390
|
-
REAL,
|
|
391
|
-
REAL_EQ,
|
|
392
|
-
REAL_ORD_ORE,
|
|
393
|
-
REAL_ORD,
|
|
394
|
-
DOUBLE,
|
|
395
|
-
DOUBLE_EQ,
|
|
396
|
-
DOUBLE_ORD_ORE,
|
|
397
|
-
DOUBLE_ORD,
|
|
398
451
|
EncryptedV3Column,
|
|
399
452
|
EncryptedTextSearchColumn,
|
|
400
453
|
EncryptedIntegerColumn,
|
|
@@ -405,6 +458,10 @@ export {
|
|
|
405
458
|
EncryptedSmallintEqColumn,
|
|
406
459
|
EncryptedSmallintOrdOreColumn,
|
|
407
460
|
EncryptedSmallintOrdColumn,
|
|
461
|
+
EncryptedBigintColumn,
|
|
462
|
+
EncryptedBigintEqColumn,
|
|
463
|
+
EncryptedBigintOrdOreColumn,
|
|
464
|
+
EncryptedBigintOrdColumn,
|
|
408
465
|
EncryptedDateColumn,
|
|
409
466
|
EncryptedDateEqColumn,
|
|
410
467
|
EncryptedDateOrdOreColumn,
|
|
@@ -430,6 +487,8 @@ export {
|
|
|
430
487
|
EncryptedDoubleColumn,
|
|
431
488
|
EncryptedDoubleEqColumn,
|
|
432
489
|
EncryptedDoubleOrdOreColumn,
|
|
433
|
-
EncryptedDoubleOrdColumn
|
|
490
|
+
EncryptedDoubleOrdColumn,
|
|
491
|
+
EncryptedJsonColumn,
|
|
492
|
+
types
|
|
434
493
|
};
|
|
435
|
-
//# sourceMappingURL=chunk-
|
|
494
|
+
//# sourceMappingURL=chunk-V2Q3NYIH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/eql/v3/columns.ts","../src/eql/v3/types.ts"],"sourcesContent":["import type { ColumnSchema } from '@/schema'\nimport { defaultMatchOpts } from '@/schema/match-defaults'\n\n/**\n * The query capabilities a v3 concrete domain exposes. These are SDK-facing\n * semantic flags describing what kinds of query terms a column can produce —\n * NOT the raw EQL index keys. They are metadata only and never emitted by\n * `build()`.\n *\n * - `equality`: exact-match lookups (EQL `hm`, or comparison via `ob`).\n * - `orderAndRange`: comparison / range lookups (EQL `op`, or `ob` on `_ord_ore` domains).\n * - `freeTextSearch`: tokenised substring match (EQL `bf`).\n * - `searchableJson`: encrypted-JSONB containment / selector lookups (EQL\n * `ste_vec`). Optional and mutually exclusive with the scalar flags — a\n * `public.eql_v3_json` document is queried by structure, not by scalar term.\n */\nexport type QueryCapabilities = Readonly<{\n equality: boolean\n orderAndRange: boolean\n freeTextSearch: boolean\n searchableJson?: boolean\n}>\n\n/**\n * The `cast_as` kinds whose decrypted plaintext reconstructs to a JS `Date`.\n *\n * SINGLE SOURCE OF TRUTH for the date-like set. Both the type-level\n * {@link PlaintextFromKind} and the runtime `rowReconstructor` (encryption/v3.ts)\n * derive their \"reconstructs to `Date`\" decision from this array, so the next\n * `Date`-backed cast is added in exactly one place — never hand-synced across a\n * type and a runtime guard that could silently drift.\n *\n * (`timestamp` reconstructs to `Date` just like `date`, but its `cast_as` tells\n * the FFI not to truncate the time-of-day.)\n */\nexport const DATE_LIKE_CASTS = ['date', 'timestamp'] as const\n/** A `cast_as` kind that reconstructs to `Date` — see {@link DATE_LIKE_CASTS}. */\nexport type DateLikeCast = (typeof DATE_LIKE_CASTS)[number]\n\n/** The plaintext (TypeScript) kind a v3 domain decrypts to. A subset of the\n * SDK `CastAs` enum, restricted to the scalar kinds v3 domains actually use. */\ntype PlaintextKind =\n | 'string'\n | 'number'\n | 'bigint'\n | 'boolean'\n | 'json'\n | DateLikeCast\n\n/**\n * The full, literal definition of a v3 domain. This is the LOAD-BEARING type:\n * the base column class carries a private field of this type so that every\n * concrete (otherwise-empty) subclass is discriminated by its literal\n * `eqlType`/`castAs`/`capabilities` — TypeScript empty subclasses are NOT\n * nominal, so without this a storage-only `boolean` column would be assignable to\n * a storage-only `date` column and plaintext inference would collapse.\n */\ntype V3DomainDefinition = Readonly<{\n eqlType: `public.${string}`\n castAs: PlaintextKind\n capabilities: QueryCapabilities\n}>\n\n/** Type-level mirror of {@link isQueryableCapabilities}: `false` for a\n * storage-only domain (all capability flags `false`), `true` otherwise. */\ntype QueryableFlag<D extends V3DomainDefinition> = D['capabilities'] extends {\n equality: false\n orderAndRange: false\n freeTextSearch: false\n searchableJson?: false | undefined\n}\n ? false\n : true\n\nconst STORAGE_ONLY = {\n equality: false,\n orderAndRange: false,\n freeTextSearch: false,\n} as const\n\nconst EQUALITY_ONLY = {\n equality: true,\n orderAndRange: false,\n freeTextSearch: false,\n} as const\n\nconst ORDER_AND_RANGE = {\n equality: true,\n orderAndRange: true,\n freeTextSearch: false,\n} as const\n\nconst MATCH_ONLY = {\n equality: false,\n orderAndRange: false,\n freeTextSearch: true,\n} as const\n\nconst TEXT_SEARCH = {\n equality: true,\n orderAndRange: true,\n freeTextSearch: true,\n} as const\n\n/**\n * The concrete EQL v3 domain name for a full-capability text column.\n * Recorded as metadata for future DDL / query-dialect increments; it is\n * intentionally absent from the emitted encrypt config.\n */\nexport const TEXT_SEARCH_EQL_TYPE = 'public.eql_v3_text_search'\n\n// Per-domain literal definitions. Each concrete column subclass is parameterised\n// by `typeof <CONST>`; the literal `eqlType`/`castAs`/`capabilities` on each is\n// what makes the otherwise-empty subclasses nominally distinct (see\n// V3DomainDefinition). Order mirrors eql-bindings `CATALOG` order.\n//\n// Exported for the `types` namespace factory (see ./types); they are internal\n// building blocks and are intentionally NOT re-exported from the public barrel.\nexport const INTEGER = {\n eqlType: 'public.eql_v3_integer',\n castAs: 'number',\n capabilities: STORAGE_ONLY,\n} as const\nexport const INTEGER_EQ = {\n eqlType: 'public.eql_v3_integer_eq',\n castAs: 'number',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const INTEGER_ORD_ORE = {\n eqlType: 'public.eql_v3_integer_ord_ore',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const INTEGER_ORD = {\n eqlType: 'public.eql_v3_integer_ord',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\n\nexport const SMALLINT = {\n eqlType: 'public.eql_v3_smallint',\n castAs: 'number',\n capabilities: STORAGE_ONLY,\n} as const\nexport const SMALLINT_EQ = {\n eqlType: 'public.eql_v3_smallint_eq',\n castAs: 'number',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const SMALLINT_ORD_ORE = {\n eqlType: 'public.eql_v3_smallint_ord_ore',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const SMALLINT_ORD = {\n eqlType: 'public.eql_v3_smallint_ord',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\n\n// bigint (int8) domains. Plaintext is a JS `bigint` (always decrypts to\n// `bigint`); bounds are the full i64 range. protect-ffi round-trips an in-range\n// native bigint losslessly, and values outside the signed 64-bit range are\n// rejected client-side by `assertValidNumericValue` before they reach the FFI\n// (`*_ord_ope` variants are out of scope — CIP-3403.)\nexport const BIGINT = {\n eqlType: 'public.eql_v3_bigint',\n castAs: 'bigint',\n capabilities: STORAGE_ONLY,\n} as const\nexport const BIGINT_EQ = {\n eqlType: 'public.eql_v3_bigint_eq',\n castAs: 'bigint',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const BIGINT_ORD_ORE = {\n eqlType: 'public.eql_v3_bigint_ord_ore',\n castAs: 'bigint',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const BIGINT_ORD = {\n eqlType: 'public.eql_v3_bigint_ord',\n castAs: 'bigint',\n capabilities: ORDER_AND_RANGE,\n} as const\n\nexport const DATE = {\n eqlType: 'public.eql_v3_date',\n castAs: 'date',\n capabilities: STORAGE_ONLY,\n} as const\nexport const DATE_EQ = {\n eqlType: 'public.eql_v3_date_eq',\n castAs: 'date',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const DATE_ORD_ORE = {\n eqlType: 'public.eql_v3_date_ord_ore',\n castAs: 'date',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const DATE_ORD = {\n eqlType: 'public.eql_v3_date_ord',\n castAs: 'date',\n capabilities: ORDER_AND_RANGE,\n} as const\n\nexport const TIMESTAMP = {\n eqlType: 'public.eql_v3_timestamp',\n castAs: 'timestamp',\n capabilities: STORAGE_ONLY,\n} as const\nexport const TIMESTAMP_EQ = {\n eqlType: 'public.eql_v3_timestamp_eq',\n castAs: 'timestamp',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const TIMESTAMP_ORD_ORE = {\n eqlType: 'public.eql_v3_timestamp_ord_ore',\n castAs: 'timestamp',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const TIMESTAMP_ORD = {\n eqlType: 'public.eql_v3_timestamp_ord',\n castAs: 'timestamp',\n capabilities: ORDER_AND_RANGE,\n} as const\n\nexport const NUMERIC = {\n eqlType: 'public.eql_v3_numeric',\n castAs: 'number',\n capabilities: STORAGE_ONLY,\n} as const\nexport const NUMERIC_EQ = {\n eqlType: 'public.eql_v3_numeric_eq',\n castAs: 'number',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const NUMERIC_ORD_ORE = {\n eqlType: 'public.eql_v3_numeric_ord_ore',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const NUMERIC_ORD = {\n eqlType: 'public.eql_v3_numeric_ord',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\n\nexport const TEXT = {\n eqlType: 'public.eql_v3_text',\n castAs: 'string',\n capabilities: STORAGE_ONLY,\n} as const\nexport const TEXT_EQ = {\n eqlType: 'public.eql_v3_text_eq',\n castAs: 'string',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const TEXT_MATCH = {\n eqlType: 'public.eql_v3_text_match',\n castAs: 'string',\n capabilities: MATCH_ONLY,\n} as const\nexport const TEXT_ORD_ORE = {\n eqlType: 'public.eql_v3_text_ord_ore',\n castAs: 'string',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const TEXT_ORD = {\n eqlType: 'public.eql_v3_text_ord',\n castAs: 'string',\n capabilities: ORDER_AND_RANGE,\n} as const\n\nexport const BOOLEAN = {\n eqlType: 'public.eql_v3_boolean',\n castAs: 'boolean',\n capabilities: STORAGE_ONLY,\n} as const\n\nexport const REAL = {\n eqlType: 'public.eql_v3_real',\n castAs: 'number',\n capabilities: STORAGE_ONLY,\n} as const\nexport const REAL_EQ = {\n eqlType: 'public.eql_v3_real_eq',\n castAs: 'number',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const REAL_ORD_ORE = {\n eqlType: 'public.eql_v3_real_ord_ore',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const REAL_ORD = {\n eqlType: 'public.eql_v3_real_ord',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\n\nexport const DOUBLE = {\n eqlType: 'public.eql_v3_double',\n castAs: 'number',\n capabilities: STORAGE_ONLY,\n} as const\nexport const DOUBLE_EQ = {\n eqlType: 'public.eql_v3_double_eq',\n castAs: 'number',\n capabilities: EQUALITY_ONLY,\n} as const\nexport const DOUBLE_ORD_ORE = {\n eqlType: 'public.eql_v3_double_ord_ore',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\nexport const DOUBLE_ORD = {\n eqlType: 'public.eql_v3_double_ord',\n castAs: 'number',\n capabilities: ORDER_AND_RANGE,\n} as const\n\n/**\n * Translate a domain's semantic {@link QueryCapabilities} (plus its plaintext\n * `castAs`, which decides how equality is answered, and its ordering flavour)\n * into the concrete EQL index block emitted by `build()`.\n *\n * - `unique` (the `hm` HMAC index) whenever equality is answered via HMAC:\n * equality-only domains of ANY type, AND text order domains. Text equality is\n * HMAC-based — the `public.eql_v3_text_ord` / `public.eql_v3_text_ord_ore` SQL domains\n * REQUIRE `hm` in the stored ciphertext (their `eql_v3.eq_term` extracts it).\n * - ONE ordering index for any order/range domain, selected by the domain's\n * name (eql-3.0.0): plain `_ord` domains (and `text_search`) are OPE-backed —\n * `ope`, the `op` CLLW-OPE term — while `_ord_ore` domains keep block-ORE —\n * `ore`, the `ob` term. The two terms are not cross-comparable, and each\n * domain's SQL CHECK requires exactly its own. For numeric/date order\n * domains the ordering term also answers equality (via the SQL `=`\n * operator), so those emit no `hm`. Text order domains emit BOTH `unique`\n * and the ordering index.\n * - `match` (the `bf` bloom-filter index) for free-text search, deep-cloned from\n * the per-call defaults so no nested object is ever shared across columns, and\n * emitted with `include_original: false` (see below).\n */\nfunction indexesForCapabilities(\n capabilities: QueryCapabilities,\n castAs: PlaintextKind,\n ordering: 'ope' | 'ore',\n): ColumnSchema['indexes'] {\n const indexes: ColumnSchema['indexes'] = {}\n\n // Text equality is always HMAC-based, so a text order domain (`string` +\n // order/range) still needs `unique`; numeric/date order domains answer\n // equality via their ordering term and must NOT emit `unique`.\n if (\n capabilities.equality &&\n (!capabilities.orderAndRange || castAs === 'string')\n ) {\n indexes.unique = { token_filters: [] }\n }\n\n if (capabilities.orderAndRange) {\n indexes[ordering] = {}\n }\n\n if (capabilities.freeTextSearch) {\n // The factory returns fresh, unaliased nested objects per call, so no\n // column's emitted match block ever shares state with another's.\n //\n // `include_original` is overridden off the v2 builder's `true`. protect-ffi\n // ignores the flag entirely (measured across 0.24 and 0.29, EQL v2 and v3:\n // the emitted bloom is trigram-only either way, and a value shorter than\n // `token_length` blooms to nothing regardless), so this is inert today. It\n // is set to the value a substring-search domain actually wants — matching\n // the zod schema's own default — so that a protect-ffi release which starts\n // honouring the flag cannot silently break `contains`.\n indexes.match = { ...defaultMatchOpts(), include_original: false }\n }\n\n if (capabilities.searchableJson) {\n // Encrypted-JSONB index (the protect-ffi config kind is named `ste_vec`).\n // `prefix: 'enabled'` is a sentinel the table's `build()` rewrites to\n // `${tableName}/${columnName}` — the same scheme v2 `searchableJson` uses —\n // so each document's selectors are scoped to their column.\n //\n // `array_index_mode` indexes array elements by identity (`item`) and enables\n // `$[*]` wildcard selectors, but deliberately drops `position`: `@>`\n // containment must be a subset test (jsonb `@>` semantics), so `{roles:['x']}`\n // matches any document whose `roles` array contains `x` REGARDLESS of index.\n // With positional terms emitted (v2 `searchableJson`'s `'all'`), the needle\n // for `x`-at-index-0 would miss a document holding `x` at index 1.\n //\n // `mode: 'compat'` is REQUIRED for eql-3.0.0: `public.eql_v3_json` orders the\n // document's entries by the CLLW-OPE `op` term, so the index must emit `op`\n // (compat) terms. `'standard'` emits v2's CLLW-ORE `oc` terms, which the v3\n // domain rejects at encrypt time.\n indexes.ste_vec = {\n prefix: 'enabled',\n array_index_mode: { item: true, wildcard: true, position: false },\n mode: 'compat',\n }\n }\n\n return indexes\n}\n\n/**\n * The ordering flavour a domain's name pins (eql-3.0.0): `_ord_ore` domains\n * are block-ORE (`ore` index, `ob` term); every other ordering domain —\n * `_ord` and `text_search` — is CLLW-OPE (`ope` index, `op` term).\n */\nfunction orderingForEqlType(eqlType: string): 'ope' | 'ore' {\n return eqlType.endsWith('_ord_ore') ? 'ore' : 'ope'\n}\n\n/** Whether a domain's capabilities make it queryable at all (any flag set). */\nfunction isQueryableCapabilities(capabilities: QueryCapabilities): boolean {\n return (\n capabilities.equality ||\n capabilities.orderAndRange ||\n capabilities.freeTextSearch ||\n (capabilities.searchableJson ?? false)\n )\n}\n\n/**\n * Shared base for every v3 concrete domain column. Parameterised by the FULL\n * literal {@link V3DomainDefinition} (not by capabilities alone): the private\n * `definition` field carries the literal `eqlType`/`castAs`/`capabilities`, so\n * two otherwise-empty subclasses (e.g. `EncryptedBooleanColumn` and\n * `EncryptedDateColumn`, both storage-only) are NOT mutually assignable. This\n * nominality is what keeps plaintext inference precise.\n */\nexport class EncryptedV3Column<D extends V3DomainDefinition> {\n constructor(\n private readonly columnName: string,\n private readonly definition: D,\n ) {}\n\n getName(): string {\n return this.columnName\n }\n\n /** The concrete EQL v3 domain name. Metadata only; not emitted by `build()`. */\n getEqlType(): D['eqlType'] {\n return this.definition.eqlType\n }\n\n /** The semantic query capabilities this domain exposes. Metadata only. */\n getQueryCapabilities(): D['capabilities'] {\n return this.definition.capabilities\n }\n\n /** `true` when this domain can produce at least one kind of query term. */\n isQueryable(): QueryableFlag<D> {\n return isQueryableCapabilities(\n this.definition.capabilities,\n ) as QueryableFlag<D>\n }\n\n /** Emit the encrypt-config column: `cast_as` plus capability-derived indexes. */\n build(): ColumnSchema {\n return {\n cast_as: this.definition.castAs,\n indexes: indexesForCapabilities(\n this.definition.capabilities,\n this.definition.castAs,\n orderingForEqlType(this.definition.eqlType),\n ),\n }\n }\n}\n\nconst TEXT_SEARCH_DOMAIN = {\n eqlType: TEXT_SEARCH_EQL_TYPE,\n castAs: 'string',\n capabilities: TEXT_SEARCH,\n} as const\n\n/**\n * Builder for a `public.eql_v3_text_search` column.\n *\n * The concrete type inherently enables equality + order/range + free-text\n * match — there are no capability-enabling or tuning methods. The match index\n * is always emitted with the default configuration.\n *\n * NOTE — querying: a `text_search` column emits all three indexes (`unique`,\n * `ope`, `match`), and the shared index-inference picks them by fixed priority\n * `unique > match > ordering`. So `encryptQuery(value, { column, table })` with NO\n * explicit `queryType` builds an EQUALITY term (via `unique`), NOT a free-text\n * match — a substring like `'joh'` then matches nothing. To run a free-text\n * match query you MUST pass `queryType: 'freeTextSearch'`:\n *\n * ```typescript\n * // equality (default): exact value only\n * client.encryptQuery('john@example.com', { column: users.email, table: users })\n * // free-text match: substring/token search\n * client.encryptQuery('joh', { column: users.email, table: users, queryType: 'freeTextSearch' })\n * ```\n */\nexport class EncryptedTextSearchColumn extends EncryptedV3Column<\n typeof TEXT_SEARCH_DOMAIN\n> {\n constructor(columnName: string) {\n super(columnName, TEXT_SEARCH_DOMAIN)\n }\n}\n\n// ---------------------------------------------------------------------------\n// Concrete domain columns\n//\n// Every concrete class is an empty subclass parameterised by its literal domain\n// definition (see EncryptedV3Column). The `types` namespace (see ./types)\n// constructs these with the SAME literal constant so the instance's private\n// `definition` field carries full literal type data — that is what keeps\n// distinct domains nominally incompatible.\n// ---------------------------------------------------------------------------\n\n// integer\nexport class EncryptedIntegerColumn extends EncryptedV3Column<typeof INTEGER> {}\nexport class EncryptedIntegerEqColumn extends EncryptedV3Column<\n typeof INTEGER_EQ\n> {}\nexport class EncryptedIntegerOrdOreColumn extends EncryptedV3Column<\n typeof INTEGER_ORD_ORE\n> {}\nexport class EncryptedIntegerOrdColumn extends EncryptedV3Column<\n typeof INTEGER_ORD\n> {}\n\n// smallint\nexport class EncryptedSmallintColumn extends EncryptedV3Column<\n typeof SMALLINT\n> {}\nexport class EncryptedSmallintEqColumn extends EncryptedV3Column<\n typeof SMALLINT_EQ\n> {}\nexport class EncryptedSmallintOrdOreColumn extends EncryptedV3Column<\n typeof SMALLINT_ORD_ORE\n> {}\nexport class EncryptedSmallintOrdColumn extends EncryptedV3Column<\n typeof SMALLINT_ORD\n> {}\n\n// bigint (int8) — plaintext is a JS `bigint`, round-tripped losslessly by the\n// native protect-ffi boundary (see the BIGINT domain definitions above).\nexport class EncryptedBigintColumn extends EncryptedV3Column<typeof BIGINT> {}\nexport class EncryptedBigintEqColumn extends EncryptedV3Column<\n typeof BIGINT_EQ\n> {}\nexport class EncryptedBigintOrdOreColumn extends EncryptedV3Column<\n typeof BIGINT_ORD_ORE\n> {}\nexport class EncryptedBigintOrdColumn extends EncryptedV3Column<\n typeof BIGINT_ORD\n> {}\n\n// date\nexport class EncryptedDateColumn extends EncryptedV3Column<typeof DATE> {}\nexport class EncryptedDateEqColumn extends EncryptedV3Column<typeof DATE_EQ> {}\nexport class EncryptedDateOrdOreColumn extends EncryptedV3Column<\n typeof DATE_ORD_ORE\n> {}\nexport class EncryptedDateOrdColumn extends EncryptedV3Column<\n typeof DATE_ORD\n> {}\n\n// timestamp\nexport class EncryptedTimestampColumn extends EncryptedV3Column<\n typeof TIMESTAMP\n> {}\nexport class EncryptedTimestampEqColumn extends EncryptedV3Column<\n typeof TIMESTAMP_EQ\n> {}\nexport class EncryptedTimestampOrdOreColumn extends EncryptedV3Column<\n typeof TIMESTAMP_ORD_ORE\n> {}\nexport class EncryptedTimestampOrdColumn extends EncryptedV3Column<\n typeof TIMESTAMP_ORD\n> {}\n\n// numeric\nexport class EncryptedNumericColumn extends EncryptedV3Column<typeof NUMERIC> {}\nexport class EncryptedNumericEqColumn extends EncryptedV3Column<\n typeof NUMERIC_EQ\n> {}\nexport class EncryptedNumericOrdOreColumn extends EncryptedV3Column<\n typeof NUMERIC_ORD_ORE\n> {}\nexport class EncryptedNumericOrdColumn extends EncryptedV3Column<\n typeof NUMERIC_ORD\n> {}\n\n// text (text_search is defined above with its match-tuning override)\nexport class EncryptedTextColumn extends EncryptedV3Column<typeof TEXT> {}\nexport class EncryptedTextEqColumn extends EncryptedV3Column<typeof TEXT_EQ> {}\nexport class EncryptedTextMatchColumn extends EncryptedV3Column<\n typeof TEXT_MATCH\n> {}\nexport class EncryptedTextOrdOreColumn extends EncryptedV3Column<\n typeof TEXT_ORD_ORE\n> {}\nexport class EncryptedTextOrdColumn extends EncryptedV3Column<\n typeof TEXT_ORD\n> {}\n\n// boolean\nexport class EncryptedBooleanColumn extends EncryptedV3Column<typeof BOOLEAN> {}\n\n// real\nexport class EncryptedRealColumn extends EncryptedV3Column<typeof REAL> {}\nexport class EncryptedRealEqColumn extends EncryptedV3Column<typeof REAL_EQ> {}\nexport class EncryptedRealOrdOreColumn extends EncryptedV3Column<\n typeof REAL_ORD_ORE\n> {}\nexport class EncryptedRealOrdColumn extends EncryptedV3Column<\n typeof REAL_ORD\n> {}\n\n// double\nexport class EncryptedDoubleColumn extends EncryptedV3Column<typeof DOUBLE> {}\nexport class EncryptedDoubleEqColumn extends EncryptedV3Column<\n typeof DOUBLE_EQ\n> {}\nexport class EncryptedDoubleOrdOreColumn extends EncryptedV3Column<\n typeof DOUBLE_ORD_ORE\n> {}\nexport class EncryptedDoubleOrdColumn extends EncryptedV3Column<\n typeof DOUBLE_ORD\n> {}\n\n// json\nconst JSON_DOMAIN = {\n eqlType: 'public.eql_v3_json',\n castAs: 'json',\n capabilities: {\n equality: false,\n orderAndRange: false,\n freeTextSearch: false,\n searchableJson: true,\n },\n} as const\n\n/**\n * Builder for a `public.eql_v3_json` column — an encrypted JSONB document\n * (a {@link JsonDocument}: object, array, or null). It round-trips through\n * `encrypt`/`decrypt`, and containment queries use the encrypted-JSONB index\n * emitted by `build()`. (The stored payload is protect-ffi's `SteVecDocument`,\n * and the config index kind is `ste_vec` — both protect-ffi names.)\n */\nexport class EncryptedJsonColumn extends EncryptedV3Column<typeof JSON_DOMAIN> {\n constructor(columnName: string) {\n super(columnName, JSON_DOMAIN)\n }\n}\n\n/**\n * Union of every v3 concrete column type. Used as the value type for v3 table\n * columns so a table may mix any generated domains.\n */\nexport type AnyEncryptedV3Column =\n | EncryptedIntegerColumn\n | EncryptedIntegerEqColumn\n | EncryptedIntegerOrdOreColumn\n | EncryptedIntegerOrdColumn\n | EncryptedSmallintColumn\n | EncryptedSmallintEqColumn\n | EncryptedSmallintOrdOreColumn\n | EncryptedSmallintOrdColumn\n | EncryptedBigintColumn\n | EncryptedBigintEqColumn\n | EncryptedBigintOrdOreColumn\n | EncryptedBigintOrdColumn\n | EncryptedDateColumn\n | EncryptedDateEqColumn\n | EncryptedDateOrdOreColumn\n | EncryptedDateOrdColumn\n | EncryptedTimestampColumn\n | EncryptedTimestampEqColumn\n | EncryptedTimestampOrdOreColumn\n | EncryptedTimestampOrdColumn\n | EncryptedNumericColumn\n | EncryptedNumericEqColumn\n | EncryptedNumericOrdOreColumn\n | EncryptedNumericOrdColumn\n | EncryptedTextColumn\n | EncryptedTextEqColumn\n | EncryptedTextMatchColumn\n | EncryptedTextOrdOreColumn\n | EncryptedTextOrdColumn\n | EncryptedTextSearchColumn\n | EncryptedBooleanColumn\n | EncryptedRealColumn\n | EncryptedRealEqColumn\n | EncryptedRealOrdOreColumn\n | EncryptedRealOrdColumn\n | EncryptedDoubleColumn\n | EncryptedDoubleEqColumn\n | EncryptedDoubleOrdOreColumn\n | EncryptedDoubleOrdColumn\n | EncryptedJsonColumn\n\n/**\n * A factory that builds a concrete v3 column for a given DB column name.\n *\n * Declared here rather than beside `DOMAIN_REGISTRY` so that `./types` can\n * constrain its own export against it without importing from `./domain-registry`,\n * which imports `./types` back as a value.\n */\nexport type V3ColumnFactory = (name: string) => AnyEncryptedV3Column\n\n/**\n * Shape of v3 table columns: every value is a v3 concrete column builder.\n * (Nested fields are deferred to later increments.)\n */\nexport type EncryptedV3TableColumn = {\n [key: string]: AnyEncryptedV3Column\n}\n\n/** A JSON value at any depth. Used for the values NESTED inside a document. */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue }\n\n/**\n * The plaintext a `public.eql_v3_json` column encrypts and reconstructs: a JSON\n * DOCUMENT — an object, an array, or `null`. NOT a bare top-level scalar:\n * protect-ffi's `json` cast rejects a top-level string/number/boolean\n * (\"Cannot convert … to Json\"), because a scalar belongs in a scalar domain\n * (`types.TextEq`, `types.IntegerEq`, …). Nested scalars are ordinary\n * {@link JsonValue}s and are fully supported.\n */\nexport type JsonDocument = null | JsonValue[] | { [key: string]: JsonValue }\n\n/** Map a domain's {@link PlaintextKind} to its TypeScript plaintext type. */\ntype PlaintextFromKind<K extends PlaintextKind> = K extends 'string'\n ? string\n : K extends 'number'\n ? number\n : K extends 'bigint'\n ? bigint\n : K extends 'boolean'\n ? boolean\n : K extends DateLikeCast\n ? Date\n : K extends 'json'\n ? JsonDocument\n : never\n\n/**\n * The plaintext type for a single v3 column, read from the literal domain\n * definition carried on the base class's private field. This is stable across\n * empty subclasses that share the same base generic — a subclass-name\n * conditional would collapse because those subclasses are structurally\n * assignable to one another.\n */\nexport type PlaintextForColumn<C> =\n C extends EncryptedV3Column<infer D> ? PlaintextFromKind<D['castAs']> : never\n\n/**\n * The user-facing `queryType` names a v3 column supports, derived 1:1 from its\n * capability flags. Resolves to `never` for a storage-only column (all flags\n * `false`) and for any non-v3 value. The names mirror the {@link QueryCapabilities}\n * keys and the first three {@link import('@/types').QueryTypeName} members.\n */\nexport type QueryTypesForColumn<C> =\n C extends EncryptedV3Column<infer D>\n ?\n | (D['capabilities']['equality'] extends true ? 'equality' : never)\n | (D['capabilities']['orderAndRange'] extends true\n ? 'orderAndRange'\n : never)\n | (D['capabilities']['freeTextSearch'] extends true\n ? 'freeTextSearch'\n : never)\n : never\n\n/**\n * The concrete EQL v3 type string for a single column, read from the literal\n * domain definition carried on the base class's private field (mirrors\n * {@link PlaintextForColumn}). Distributes over a union of columns, so\n * `EqlTypeForColumn<AnyEncryptedV3Column>` yields the union of every domain's\n * `eqlType` — the canonical, source-of-truth key set for a type-driven test\n * matrix keyed by domain.\n */\nexport type EqlTypeForColumn<C> =\n C extends EncryptedV3Column<infer D> ? D['eqlType'] : never\n","import {\n BIGINT,\n BIGINT_EQ,\n BIGINT_ORD,\n BIGINT_ORD_ORE,\n BOOLEAN,\n DATE,\n DATE_EQ,\n DATE_ORD,\n DATE_ORD_ORE,\n DOUBLE,\n DOUBLE_EQ,\n DOUBLE_ORD,\n DOUBLE_ORD_ORE,\n EncryptedBigintColumn,\n EncryptedBigintEqColumn,\n EncryptedBigintOrdColumn,\n EncryptedBigintOrdOreColumn,\n EncryptedBooleanColumn,\n EncryptedDateColumn,\n EncryptedDateEqColumn,\n EncryptedDateOrdColumn,\n EncryptedDateOrdOreColumn,\n EncryptedDoubleColumn,\n EncryptedDoubleEqColumn,\n EncryptedDoubleOrdColumn,\n EncryptedDoubleOrdOreColumn,\n EncryptedIntegerColumn,\n EncryptedIntegerEqColumn,\n EncryptedIntegerOrdColumn,\n EncryptedIntegerOrdOreColumn,\n EncryptedJsonColumn,\n EncryptedNumericColumn,\n EncryptedNumericEqColumn,\n EncryptedNumericOrdColumn,\n EncryptedNumericOrdOreColumn,\n EncryptedRealColumn,\n EncryptedRealEqColumn,\n EncryptedRealOrdColumn,\n EncryptedRealOrdOreColumn,\n EncryptedSmallintColumn,\n EncryptedSmallintEqColumn,\n EncryptedSmallintOrdColumn,\n EncryptedSmallintOrdOreColumn,\n EncryptedTextColumn,\n EncryptedTextEqColumn,\n EncryptedTextMatchColumn,\n EncryptedTextOrdColumn,\n EncryptedTextOrdOreColumn,\n EncryptedTextSearchColumn,\n EncryptedTimestampColumn,\n EncryptedTimestampEqColumn,\n EncryptedTimestampOrdColumn,\n EncryptedTimestampOrdOreColumn,\n INTEGER,\n INTEGER_EQ,\n INTEGER_ORD,\n INTEGER_ORD_ORE,\n NUMERIC,\n NUMERIC_EQ,\n NUMERIC_ORD,\n NUMERIC_ORD_ORE,\n REAL,\n REAL_EQ,\n REAL_ORD,\n REAL_ORD_ORE,\n SMALLINT,\n SMALLINT_EQ,\n SMALLINT_ORD,\n SMALLINT_ORD_ORE,\n TEXT,\n TEXT_EQ,\n TEXT_MATCH,\n TEXT_ORD,\n TEXT_ORD_ORE,\n TIMESTAMP,\n TIMESTAMP_EQ,\n TIMESTAMP_ORD,\n TIMESTAMP_ORD_ORE,\n type V3ColumnFactory,\n} from './columns'\n\n/**\n * The v3 column-type namespace. Each member is a public, semantic factory name\n * for a concrete EQL v3 column. Most members mirror the underlying domain name;\n * JS-friendly scalar names map to Postgres concrete domains, e.g.\n * `types.IntegerOrd` builds a `public.eql_v3_integer_ord` column and `types.Boolean`\n * builds a `public.eql_v3_boolean` column.\n *\n * If these factory names stop matching the emitted capability/domain surface,\n * the stack package is out of sync with the underlying EQL build. That is a\n * version mismatch, not a harmless naming drift.\n *\n * Each factory returns the CONCRETE column class instance (never the widened\n * `AnyEncryptedV3Column`) so per-column plaintext / query-capability inference\n * stays precise.\n *\n * ```ts\n * import { encryptedTable, types } from '@cipherstash/stack/eql/v3'\n *\n * const events = encryptedTable('events', {\n * actor: types.TextEq('actor'), // equality\n * weight: types.IntegerOrd('weight'), // order + range\n * createdAt: types.Timestamp('created_at'), // storage only\n * })\n * ```\n *\n * `types.TextSearch` is fully described by its type — like every other domain,\n * it has no capability-bearing or tuning chain. Its match index is always\n * emitted with the default configuration; run a free-text query by passing\n * `queryType: 'freeTextSearch'` to `encryptQuery`.\n */\nexport const types = {\n // integer\n Integer: (name: string) => new EncryptedIntegerColumn(name, INTEGER),\n IntegerEq: (name: string) => new EncryptedIntegerEqColumn(name, INTEGER_EQ),\n IntegerOrdOre: (name: string) =>\n new EncryptedIntegerOrdOreColumn(name, INTEGER_ORD_ORE),\n IntegerOrd: (name: string) =>\n new EncryptedIntegerOrdColumn(name, INTEGER_ORD),\n\n // smallint\n Smallint: (name: string) => new EncryptedSmallintColumn(name, SMALLINT),\n SmallintEq: (name: string) =>\n new EncryptedSmallintEqColumn(name, SMALLINT_EQ),\n SmallintOrdOre: (name: string) =>\n new EncryptedSmallintOrdOreColumn(name, SMALLINT_ORD_ORE),\n SmallintOrd: (name: string) =>\n new EncryptedSmallintOrdColumn(name, SMALLINT_ORD),\n\n // bigint (int8) — plaintext is a JS `bigint`, round-tripped losslessly by\n // the native protect-ffi boundary (see ./columns)\n Bigint: (name: string) => new EncryptedBigintColumn(name, BIGINT),\n BigintEq: (name: string) => new EncryptedBigintEqColumn(name, BIGINT_EQ),\n BigintOrdOre: (name: string) =>\n new EncryptedBigintOrdOreColumn(name, BIGINT_ORD_ORE),\n BigintOrd: (name: string) => new EncryptedBigintOrdColumn(name, BIGINT_ORD),\n\n // date\n Date: (name: string) => new EncryptedDateColumn(name, DATE),\n DateEq: (name: string) => new EncryptedDateEqColumn(name, DATE_EQ),\n DateOrdOre: (name: string) =>\n new EncryptedDateOrdOreColumn(name, DATE_ORD_ORE),\n DateOrd: (name: string) => new EncryptedDateOrdColumn(name, DATE_ORD),\n\n // timestamp\n Timestamp: (name: string) => new EncryptedTimestampColumn(name, TIMESTAMP),\n TimestampEq: (name: string) =>\n new EncryptedTimestampEqColumn(name, TIMESTAMP_EQ),\n TimestampOrdOre: (name: string) =>\n new EncryptedTimestampOrdOreColumn(name, TIMESTAMP_ORD_ORE),\n TimestampOrd: (name: string) =>\n new EncryptedTimestampOrdColumn(name, TIMESTAMP_ORD),\n\n // numeric\n Numeric: (name: string) => new EncryptedNumericColumn(name, NUMERIC),\n NumericEq: (name: string) => new EncryptedNumericEqColumn(name, NUMERIC_EQ),\n NumericOrdOre: (name: string) =>\n new EncryptedNumericOrdOreColumn(name, NUMERIC_ORD_ORE),\n NumericOrd: (name: string) =>\n new EncryptedNumericOrdColumn(name, NUMERIC_ORD),\n\n // text\n Text: (name: string) => new EncryptedTextColumn(name, TEXT),\n TextEq: (name: string) => new EncryptedTextEqColumn(name, TEXT_EQ),\n TextMatch: (name: string) => new EncryptedTextMatchColumn(name, TEXT_MATCH),\n TextOrdOre: (name: string) =>\n new EncryptedTextOrdOreColumn(name, TEXT_ORD_ORE),\n TextOrd: (name: string) => new EncryptedTextOrdColumn(name, TEXT_ORD),\n TextSearch: (name: string) => new EncryptedTextSearchColumn(name),\n\n // boolean\n Boolean: (name: string) => new EncryptedBooleanColumn(name, BOOLEAN),\n\n // real\n Real: (name: string) => new EncryptedRealColumn(name, REAL),\n RealEq: (name: string) => new EncryptedRealEqColumn(name, REAL_EQ),\n RealOrdOre: (name: string) =>\n new EncryptedRealOrdOreColumn(name, REAL_ORD_ORE),\n RealOrd: (name: string) => new EncryptedRealOrdColumn(name, REAL_ORD),\n\n // double\n Double: (name: string) => new EncryptedDoubleColumn(name, DOUBLE),\n DoubleEq: (name: string) => new EncryptedDoubleEqColumn(name, DOUBLE_EQ),\n DoubleOrdOre: (name: string) =>\n new EncryptedDoubleOrdOreColumn(name, DOUBLE_ORD_ORE),\n DoubleOrd: (name: string) => new EncryptedDoubleOrdColumn(name, DOUBLE_ORD),\n\n // json (encrypted JSONB document, ste_vec containment)\n Json: (name: string) => new EncryptedJsonColumn(name),\n // `satisfies` is load-bearing, not decoration: `DOMAIN_REGISTRY` derives itself\n // by calling every value here at module load. A non-factory export would throw\n // during module evaluation and take the supabase introspect/schema-build/verify\n // path down with it. This turns that into a compile error at the offending line.\n // `as const` applies first, so literal key inference is preserved.\n} as const satisfies Record<string, V3ColumnFactory>\n"],"mappings":";;;;;AAmCO,IAAM,kBAAkB,CAAC,QAAQ,WAAW;AAuCnD,IAAM,eAAe;AAAA,EACnB,UAAU;AAAA,EACV,eAAe;AAAA,EACf,gBAAg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AAM,QAAQ;AAAA;AAAA,EAGpE,QAAQ,CAAC,SAAiB,IAAI,sBAAsB,MAAM,MAAM;AAAA,EAChE,UAAU,CAAC,SAAiB,IAAI,wBAAwB,MAAM,SAAS;AAAA,EACvE,cAAc,CAAC,SACb,IAAI,4BAA4B,MAAM,cAAc;AAAA,EACtD,WAAW,CAAC,SAAiB,IAAI,yBAAyB,MAAM,UAAU;AAAA;AAAA,EAG1E,MAAM,CAAC,SAAiB,IAAI,oBAAoB,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAMtD;","names":[]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// src/eql/v3/table.ts
|
|
2
|
+
var EncryptedTable = class {
|
|
3
|
+
constructor(tableName, columnBuilders) {
|
|
4
|
+
this.tableName = tableName;
|
|
5
|
+
this.columnBuilders = columnBuilders;
|
|
6
|
+
}
|
|
7
|
+
tableName;
|
|
8
|
+
columnBuilders;
|
|
9
|
+
build() {
|
|
10
|
+
const builtColumns = /* @__PURE__ */ Object.create(null);
|
|
11
|
+
for (const builder of Object.values(this.columnBuilders)) {
|
|
12
|
+
const name = builder.getName();
|
|
13
|
+
if (Object.hasOwn(builtColumns, name)) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
`[eql/v3]: duplicate column name "${name}" in table "${this.tableName}" \u2014 two columns resolve to the same DB name`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
builtColumns[name] = builder.build();
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
tableName: this.tableName,
|
|
22
|
+
columns: builtColumns
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Map each column's JS property name to its DB column name (`getName()`).
|
|
27
|
+
* The model path matches user models by property name but must address the
|
|
28
|
+
* encrypt config and FFI by DB name — `build()` keys columns by DB name, so
|
|
29
|
+
* the two only agree when property == name. This recovers the mapping that
|
|
30
|
+
* `build()` discards.
|
|
31
|
+
*
|
|
32
|
+
* NULL PROTOTYPE — load-bearing. Callers index this map by a column name that
|
|
33
|
+
* ultimately comes from the database (`addJsonbCastsV3`, `filterColumnName`,
|
|
34
|
+
* the mutation transform). On a plain object literal, a column named
|
|
35
|
+
* `constructor` / `toString` / `valueOf` / `__proto__` resolves to an
|
|
36
|
+
* inherited `Object.prototype` member, which is truthy — so a *plaintext*
|
|
37
|
+
* column with such a name would be mistaken for a mapped encrypted column and
|
|
38
|
+
* its `Object.prototype` value interpolated into the emitted select string.
|
|
39
|
+
* `encryptedTable()` rejects such names as JS *properties*, but nothing
|
|
40
|
+
* constrains the DB column names a table may contain.
|
|
41
|
+
*/
|
|
42
|
+
buildColumnKeyMap() {
|
|
43
|
+
const map = /* @__PURE__ */ Object.create(null);
|
|
44
|
+
for (const [property, builder] of Object.entries(this.columnBuilders)) {
|
|
45
|
+
map[property] = builder.getName();
|
|
46
|
+
}
|
|
47
|
+
return map;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var RESERVED_TABLE_KEYS = /* @__PURE__ */ new Set([
|
|
51
|
+
"tableName",
|
|
52
|
+
"columnBuilders",
|
|
53
|
+
"_columnType",
|
|
54
|
+
"build",
|
|
55
|
+
"buildColumnKeyMap"
|
|
56
|
+
]);
|
|
57
|
+
function isReservedTableKey(tableBuilder, colName) {
|
|
58
|
+
return RESERVED_TABLE_KEYS.has(colName) || colName in tableBuilder;
|
|
59
|
+
}
|
|
60
|
+
function encryptedTable(tableName, columns) {
|
|
61
|
+
const tableBuilder = new EncryptedTable(
|
|
62
|
+
tableName,
|
|
63
|
+
columns
|
|
64
|
+
);
|
|
65
|
+
for (const [colName, colBuilder] of Object.entries(columns)) {
|
|
66
|
+
if (isReservedTableKey(tableBuilder, colName)) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`Column name "${colName}" collides with a reserved EncryptedTable property`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
;
|
|
72
|
+
tableBuilder[colName] = colBuilder;
|
|
73
|
+
}
|
|
74
|
+
return tableBuilder;
|
|
75
|
+
}
|
|
76
|
+
function buildEncryptConfig(...tables) {
|
|
77
|
+
const config = {
|
|
78
|
+
v: 1,
|
|
79
|
+
tables: {}
|
|
80
|
+
};
|
|
81
|
+
for (const tb of tables) {
|
|
82
|
+
const tableDef = tb.build();
|
|
83
|
+
if (Object.hasOwn(config.tables, tableDef.tableName)) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
`[eql/v3]: duplicate table name "${tableDef.tableName}" passed to buildEncryptConfig \u2014 each table must have a unique name`
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
config.tables[tableDef.tableName] = tableDef.columns;
|
|
89
|
+
}
|
|
90
|
+
return config;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export {
|
|
94
|
+
EncryptedTable,
|
|
95
|
+
encryptedTable,
|
|
96
|
+
buildEncryptConfig
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=chunk-X3JRXEIB.js.map
|