@cipherstash/stack 0.19.0 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +596 -0
- package/README.md +376 -276
- package/dist/adapter-kit.cjs +1002 -0
- package/dist/adapter-kit.cjs.map +1 -0
- package/dist/adapter-kit.d.cts +120 -0
- package/dist/adapter-kit.d.ts +120 -0
- package/dist/adapter-kit.js +122 -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-U66S7VIF.js → chunk-6SGN52W6.js} +166 -107
- package/dist/chunk-6SGN52W6.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-OFQ555AX.js → chunk-IDKP6ABU.js} +2 -2
- package/dist/{chunk-36AA7IBJ.js → chunk-L7ISHSG7.js} +53 -20
- package/dist/chunk-L7ISHSG7.js.map +1 -0
- package/dist/{chunk-LBMC4D6D.js → chunk-NVKK7UDN.js} +1 -1
- package/dist/chunk-NVKK7UDN.js.map +1 -0
- package/dist/chunk-X3JRXEIB.js +98 -0
- package/dist/chunk-X3JRXEIB.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-CIH7jZ2h.d.ts → columns-0lbT9stl.d.ts} +157 -138
- package/dist/{table-DihEAlxG.d.cts → columns-Bxv7Oo9o.d.cts} +157 -138
- 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 +6 -6
- 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 +50 -22
- 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/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.cts +5 -5
- package/dist/errors/index.d.ts +5 -5
- package/dist/errors/index.js +1 -1
- package/dist/identity/index.cjs.map +1 -1
- package/dist/identity/index.js +2 -2
- 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 +6 -6
- 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-LBMC4D6D.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
- /package/dist/{chunk-OFQ555AX.js.map → chunk-IDKP6ABU.js.map} +0 -0
|
@@ -0,0 +1,1002 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/adapter-kit.ts
|
|
21
|
+
var adapter_kit_exports = {};
|
|
22
|
+
__export(adapter_kit_exports, {
|
|
23
|
+
DATE_LIKE_CASTS: () => DATE_LIKE_CASTS,
|
|
24
|
+
DOMAIN_REGISTRY: () => DOMAIN_REGISTRY,
|
|
25
|
+
EncryptedV3Column: () => EncryptedV3Column,
|
|
26
|
+
bulkModelsToEncryptedPgComposites: () => bulkModelsToEncryptedPgComposites,
|
|
27
|
+
factoryForDomain: () => factoryForDomain,
|
|
28
|
+
jsonPathOf: () => jsonPathOf,
|
|
29
|
+
logger: () => logger,
|
|
30
|
+
matchNeedleError: () => matchNeedleError,
|
|
31
|
+
modelToEncryptedPgComposites: () => modelToEncryptedPgComposites,
|
|
32
|
+
parseSelectorSegments: () => parseSelectorSegments,
|
|
33
|
+
reconstructSelectorDocument: () => reconstructSelectorDocument,
|
|
34
|
+
stripDomainSchema: () => stripDomainSchema,
|
|
35
|
+
unsupportedLeafReason: () => unsupportedLeafReason
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(adapter_kit_exports);
|
|
38
|
+
|
|
39
|
+
// src/encryption/helpers/index.ts
|
|
40
|
+
function encryptedToPgComposite(obj) {
|
|
41
|
+
return {
|
|
42
|
+
data: obj
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function modelToEncryptedPgComposites(model) {
|
|
46
|
+
const result = {};
|
|
47
|
+
for (const [key, value] of Object.entries(model)) {
|
|
48
|
+
if (isEncryptedPayload(value)) {
|
|
49
|
+
result[key] = encryptedToPgComposite(value);
|
|
50
|
+
} else {
|
|
51
|
+
result[key] = value;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
function bulkModelsToEncryptedPgComposites(models) {
|
|
57
|
+
return models.map((model) => modelToEncryptedPgComposites(model));
|
|
58
|
+
}
|
|
59
|
+
function isEncryptedPayload(value) {
|
|
60
|
+
if (value === null) return false;
|
|
61
|
+
if (typeof value !== "object") return false;
|
|
62
|
+
const obj = value;
|
|
63
|
+
if (!("v" in obj) || typeof obj.v !== "number") return false;
|
|
64
|
+
if (!("i" in obj) || typeof obj.i !== "object") return false;
|
|
65
|
+
if (!("c" in obj) && !("sv" in obj)) return false;
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/schema/match-defaults.ts
|
|
70
|
+
function defaultMatchOpts() {
|
|
71
|
+
return {
|
|
72
|
+
tokenizer: { kind: "ngram", token_length: 3 },
|
|
73
|
+
token_filters: [{ kind: "downcase" }],
|
|
74
|
+
k: 6,
|
|
75
|
+
m: 2048,
|
|
76
|
+
include_original: true
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function matchNeedleMinLength(opts) {
|
|
80
|
+
const tokenizer = opts.tokenizer ?? defaultMatchOpts().tokenizer;
|
|
81
|
+
return tokenizer.kind === "ngram" ? tokenizer.token_length : void 0;
|
|
82
|
+
}
|
|
83
|
+
function matchNeedleError(needle, opts) {
|
|
84
|
+
if (typeof needle !== "string") return void 0;
|
|
85
|
+
const length = [...needle].length;
|
|
86
|
+
const min = matchNeedleMinLength(opts);
|
|
87
|
+
if (length === 0) {
|
|
88
|
+
return `free-text search needs a non-empty search term; an empty term produces no tokens and would match every row.`;
|
|
89
|
+
}
|
|
90
|
+
if (min === void 0 || length >= min) return void 0;
|
|
91
|
+
return `free-text search needs at least ${min} characters (the index tokenizer's token_length), but the search term ${JSON.stringify(needle)} has ${length}. A shorter term produces no tokens and would match every row.`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/eql/v3/columns.ts
|
|
95
|
+
var DATE_LIKE_CASTS = ["date", "timestamp"];
|
|
96
|
+
var STORAGE_ONLY = {
|
|
97
|
+
equality: false,
|
|
98
|
+
orderAndRange: false,
|
|
99
|
+
freeTextSearch: false
|
|
100
|
+
};
|
|
101
|
+
var EQUALITY_ONLY = {
|
|
102
|
+
equality: true,
|
|
103
|
+
orderAndRange: false,
|
|
104
|
+
freeTextSearch: false
|
|
105
|
+
};
|
|
106
|
+
var ORDER_AND_RANGE = {
|
|
107
|
+
equality: true,
|
|
108
|
+
orderAndRange: true,
|
|
109
|
+
freeTextSearch: false
|
|
110
|
+
};
|
|
111
|
+
var MATCH_ONLY = {
|
|
112
|
+
equality: false,
|
|
113
|
+
orderAndRange: false,
|
|
114
|
+
freeTextSearch: true
|
|
115
|
+
};
|
|
116
|
+
var TEXT_SEARCH = {
|
|
117
|
+
equality: true,
|
|
118
|
+
orderAndRange: true,
|
|
119
|
+
freeTextSearch: true
|
|
120
|
+
};
|
|
121
|
+
var TEXT_SEARCH_EQL_TYPE = "public.eql_v3_text_search";
|
|
122
|
+
var INTEGER = {
|
|
123
|
+
eqlType: "public.eql_v3_integer",
|
|
124
|
+
castAs: "number",
|
|
125
|
+
capabilities: STORAGE_ONLY
|
|
126
|
+
};
|
|
127
|
+
var INTEGER_EQ = {
|
|
128
|
+
eqlType: "public.eql_v3_integer_eq",
|
|
129
|
+
castAs: "number",
|
|
130
|
+
capabilities: EQUALITY_ONLY
|
|
131
|
+
};
|
|
132
|
+
var INTEGER_ORD_ORE = {
|
|
133
|
+
eqlType: "public.eql_v3_integer_ord_ore",
|
|
134
|
+
castAs: "number",
|
|
135
|
+
capabilities: ORDER_AND_RANGE
|
|
136
|
+
};
|
|
137
|
+
var INTEGER_ORD = {
|
|
138
|
+
eqlType: "public.eql_v3_integer_ord",
|
|
139
|
+
castAs: "number",
|
|
140
|
+
capabilities: ORDER_AND_RANGE
|
|
141
|
+
};
|
|
142
|
+
var SMALLINT = {
|
|
143
|
+
eqlType: "public.eql_v3_smallint",
|
|
144
|
+
castAs: "number",
|
|
145
|
+
capabilities: STORAGE_ONLY
|
|
146
|
+
};
|
|
147
|
+
var SMALLINT_EQ = {
|
|
148
|
+
eqlType: "public.eql_v3_smallint_eq",
|
|
149
|
+
castAs: "number",
|
|
150
|
+
capabilities: EQUALITY_ONLY
|
|
151
|
+
};
|
|
152
|
+
var SMALLINT_ORD_ORE = {
|
|
153
|
+
eqlType: "public.eql_v3_smallint_ord_ore",
|
|
154
|
+
castAs: "number",
|
|
155
|
+
capabilities: ORDER_AND_RANGE
|
|
156
|
+
};
|
|
157
|
+
var SMALLINT_ORD = {
|
|
158
|
+
eqlType: "public.eql_v3_smallint_ord",
|
|
159
|
+
castAs: "number",
|
|
160
|
+
capabilities: ORDER_AND_RANGE
|
|
161
|
+
};
|
|
162
|
+
var BIGINT = {
|
|
163
|
+
eqlType: "public.eql_v3_bigint",
|
|
164
|
+
castAs: "bigint",
|
|
165
|
+
capabilities: STORAGE_ONLY
|
|
166
|
+
};
|
|
167
|
+
var BIGINT_EQ = {
|
|
168
|
+
eqlType: "public.eql_v3_bigint_eq",
|
|
169
|
+
castAs: "bigint",
|
|
170
|
+
capabilities: EQUALITY_ONLY
|
|
171
|
+
};
|
|
172
|
+
var BIGINT_ORD_ORE = {
|
|
173
|
+
eqlType: "public.eql_v3_bigint_ord_ore",
|
|
174
|
+
castAs: "bigint",
|
|
175
|
+
capabilities: ORDER_AND_RANGE
|
|
176
|
+
};
|
|
177
|
+
var BIGINT_ORD = {
|
|
178
|
+
eqlType: "public.eql_v3_bigint_ord",
|
|
179
|
+
castAs: "bigint",
|
|
180
|
+
capabilities: ORDER_AND_RANGE
|
|
181
|
+
};
|
|
182
|
+
var DATE = {
|
|
183
|
+
eqlType: "public.eql_v3_date",
|
|
184
|
+
castAs: "date",
|
|
185
|
+
capabilities: STORAGE_ONLY
|
|
186
|
+
};
|
|
187
|
+
var DATE_EQ = {
|
|
188
|
+
eqlType: "public.eql_v3_date_eq",
|
|
189
|
+
castAs: "date",
|
|
190
|
+
capabilities: EQUALITY_ONLY
|
|
191
|
+
};
|
|
192
|
+
var DATE_ORD_ORE = {
|
|
193
|
+
eqlType: "public.eql_v3_date_ord_ore",
|
|
194
|
+
castAs: "date",
|
|
195
|
+
capabilities: ORDER_AND_RANGE
|
|
196
|
+
};
|
|
197
|
+
var DATE_ORD = {
|
|
198
|
+
eqlType: "public.eql_v3_date_ord",
|
|
199
|
+
castAs: "date",
|
|
200
|
+
capabilities: ORDER_AND_RANGE
|
|
201
|
+
};
|
|
202
|
+
var TIMESTAMP = {
|
|
203
|
+
eqlType: "public.eql_v3_timestamp",
|
|
204
|
+
castAs: "timestamp",
|
|
205
|
+
capabilities: STORAGE_ONLY
|
|
206
|
+
};
|
|
207
|
+
var TIMESTAMP_EQ = {
|
|
208
|
+
eqlType: "public.eql_v3_timestamp_eq",
|
|
209
|
+
castAs: "timestamp",
|
|
210
|
+
capabilities: EQUALITY_ONLY
|
|
211
|
+
};
|
|
212
|
+
var TIMESTAMP_ORD_ORE = {
|
|
213
|
+
eqlType: "public.eql_v3_timestamp_ord_ore",
|
|
214
|
+
castAs: "timestamp",
|
|
215
|
+
capabilities: ORDER_AND_RANGE
|
|
216
|
+
};
|
|
217
|
+
var TIMESTAMP_ORD = {
|
|
218
|
+
eqlType: "public.eql_v3_timestamp_ord",
|
|
219
|
+
castAs: "timestamp",
|
|
220
|
+
capabilities: ORDER_AND_RANGE
|
|
221
|
+
};
|
|
222
|
+
var NUMERIC = {
|
|
223
|
+
eqlType: "public.eql_v3_numeric",
|
|
224
|
+
castAs: "number",
|
|
225
|
+
capabilities: STORAGE_ONLY
|
|
226
|
+
};
|
|
227
|
+
var NUMERIC_EQ = {
|
|
228
|
+
eqlType: "public.eql_v3_numeric_eq",
|
|
229
|
+
castAs: "number",
|
|
230
|
+
capabilities: EQUALITY_ONLY
|
|
231
|
+
};
|
|
232
|
+
var NUMERIC_ORD_ORE = {
|
|
233
|
+
eqlType: "public.eql_v3_numeric_ord_ore",
|
|
234
|
+
castAs: "number",
|
|
235
|
+
capabilities: ORDER_AND_RANGE
|
|
236
|
+
};
|
|
237
|
+
var NUMERIC_ORD = {
|
|
238
|
+
eqlType: "public.eql_v3_numeric_ord",
|
|
239
|
+
castAs: "number",
|
|
240
|
+
capabilities: ORDER_AND_RANGE
|
|
241
|
+
};
|
|
242
|
+
var TEXT = {
|
|
243
|
+
eqlType: "public.eql_v3_text",
|
|
244
|
+
castAs: "string",
|
|
245
|
+
capabilities: STORAGE_ONLY
|
|
246
|
+
};
|
|
247
|
+
var TEXT_EQ = {
|
|
248
|
+
eqlType: "public.eql_v3_text_eq",
|
|
249
|
+
castAs: "string",
|
|
250
|
+
capabilities: EQUALITY_ONLY
|
|
251
|
+
};
|
|
252
|
+
var TEXT_MATCH = {
|
|
253
|
+
eqlType: "public.eql_v3_text_match",
|
|
254
|
+
castAs: "string",
|
|
255
|
+
capabilities: MATCH_ONLY
|
|
256
|
+
};
|
|
257
|
+
var TEXT_ORD_ORE = {
|
|
258
|
+
eqlType: "public.eql_v3_text_ord_ore",
|
|
259
|
+
castAs: "string",
|
|
260
|
+
capabilities: ORDER_AND_RANGE
|
|
261
|
+
};
|
|
262
|
+
var TEXT_ORD = {
|
|
263
|
+
eqlType: "public.eql_v3_text_ord",
|
|
264
|
+
castAs: "string",
|
|
265
|
+
capabilities: ORDER_AND_RANGE
|
|
266
|
+
};
|
|
267
|
+
var BOOLEAN = {
|
|
268
|
+
eqlType: "public.eql_v3_boolean",
|
|
269
|
+
castAs: "boolean",
|
|
270
|
+
capabilities: STORAGE_ONLY
|
|
271
|
+
};
|
|
272
|
+
var REAL = {
|
|
273
|
+
eqlType: "public.eql_v3_real",
|
|
274
|
+
castAs: "number",
|
|
275
|
+
capabilities: STORAGE_ONLY
|
|
276
|
+
};
|
|
277
|
+
var REAL_EQ = {
|
|
278
|
+
eqlType: "public.eql_v3_real_eq",
|
|
279
|
+
castAs: "number",
|
|
280
|
+
capabilities: EQUALITY_ONLY
|
|
281
|
+
};
|
|
282
|
+
var REAL_ORD_ORE = {
|
|
283
|
+
eqlType: "public.eql_v3_real_ord_ore",
|
|
284
|
+
castAs: "number",
|
|
285
|
+
capabilities: ORDER_AND_RANGE
|
|
286
|
+
};
|
|
287
|
+
var REAL_ORD = {
|
|
288
|
+
eqlType: "public.eql_v3_real_ord",
|
|
289
|
+
castAs: "number",
|
|
290
|
+
capabilities: ORDER_AND_RANGE
|
|
291
|
+
};
|
|
292
|
+
var DOUBLE = {
|
|
293
|
+
eqlType: "public.eql_v3_double",
|
|
294
|
+
castAs: "number",
|
|
295
|
+
capabilities: STORAGE_ONLY
|
|
296
|
+
};
|
|
297
|
+
var DOUBLE_EQ = {
|
|
298
|
+
eqlType: "public.eql_v3_double_eq",
|
|
299
|
+
castAs: "number",
|
|
300
|
+
capabilities: EQUALITY_ONLY
|
|
301
|
+
};
|
|
302
|
+
var DOUBLE_ORD_ORE = {
|
|
303
|
+
eqlType: "public.eql_v3_double_ord_ore",
|
|
304
|
+
castAs: "number",
|
|
305
|
+
capabilities: ORDER_AND_RANGE
|
|
306
|
+
};
|
|
307
|
+
var DOUBLE_ORD = {
|
|
308
|
+
eqlType: "public.eql_v3_double_ord",
|
|
309
|
+
castAs: "number",
|
|
310
|
+
capabilities: ORDER_AND_RANGE
|
|
311
|
+
};
|
|
312
|
+
function indexesForCapabilities(capabilities, castAs, ordering) {
|
|
313
|
+
const indexes = {};
|
|
314
|
+
if (capabilities.equality && (!capabilities.orderAndRange || castAs === "string")) {
|
|
315
|
+
indexes.unique = { token_filters: [] };
|
|
316
|
+
}
|
|
317
|
+
if (capabilities.orderAndRange) {
|
|
318
|
+
indexes[ordering] = {};
|
|
319
|
+
}
|
|
320
|
+
if (capabilities.freeTextSearch) {
|
|
321
|
+
indexes.match = { ...defaultMatchOpts(), include_original: false };
|
|
322
|
+
}
|
|
323
|
+
if (capabilities.searchableJson) {
|
|
324
|
+
indexes.ste_vec = {
|
|
325
|
+
prefix: "enabled",
|
|
326
|
+
array_index_mode: { item: true, wildcard: true, position: false },
|
|
327
|
+
mode: "compat"
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
return indexes;
|
|
331
|
+
}
|
|
332
|
+
function orderingForEqlType(eqlType) {
|
|
333
|
+
return eqlType.endsWith("_ord_ore") ? "ore" : "ope";
|
|
334
|
+
}
|
|
335
|
+
function isQueryableCapabilities(capabilities) {
|
|
336
|
+
return capabilities.equality || capabilities.orderAndRange || capabilities.freeTextSearch || (capabilities.searchableJson ?? false);
|
|
337
|
+
}
|
|
338
|
+
var EncryptedV3Column = class {
|
|
339
|
+
constructor(columnName, definition) {
|
|
340
|
+
this.columnName = columnName;
|
|
341
|
+
this.definition = definition;
|
|
342
|
+
}
|
|
343
|
+
columnName;
|
|
344
|
+
definition;
|
|
345
|
+
getName() {
|
|
346
|
+
return this.columnName;
|
|
347
|
+
}
|
|
348
|
+
/** The concrete EQL v3 domain name. Metadata only; not emitted by `build()`. */
|
|
349
|
+
getEqlType() {
|
|
350
|
+
return this.definition.eqlType;
|
|
351
|
+
}
|
|
352
|
+
/** The semantic query capabilities this domain exposes. Metadata only. */
|
|
353
|
+
getQueryCapabilities() {
|
|
354
|
+
return this.definition.capabilities;
|
|
355
|
+
}
|
|
356
|
+
/** `true` when this domain can produce at least one kind of query term. */
|
|
357
|
+
isQueryable() {
|
|
358
|
+
return isQueryableCapabilities(
|
|
359
|
+
this.definition.capabilities
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
/** Emit the encrypt-config column: `cast_as` plus capability-derived indexes. */
|
|
363
|
+
build() {
|
|
364
|
+
return {
|
|
365
|
+
cast_as: this.definition.castAs,
|
|
366
|
+
indexes: indexesForCapabilities(
|
|
367
|
+
this.definition.capabilities,
|
|
368
|
+
this.definition.castAs,
|
|
369
|
+
orderingForEqlType(this.definition.eqlType)
|
|
370
|
+
)
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
var TEXT_SEARCH_DOMAIN = {
|
|
375
|
+
eqlType: TEXT_SEARCH_EQL_TYPE,
|
|
376
|
+
castAs: "string",
|
|
377
|
+
capabilities: TEXT_SEARCH
|
|
378
|
+
};
|
|
379
|
+
var EncryptedTextSearchColumn = class extends EncryptedV3Column {
|
|
380
|
+
constructor(columnName) {
|
|
381
|
+
super(columnName, TEXT_SEARCH_DOMAIN);
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
var EncryptedIntegerColumn = class extends EncryptedV3Column {
|
|
385
|
+
};
|
|
386
|
+
var EncryptedIntegerEqColumn = class extends EncryptedV3Column {
|
|
387
|
+
};
|
|
388
|
+
var EncryptedIntegerOrdOreColumn = class extends EncryptedV3Column {
|
|
389
|
+
};
|
|
390
|
+
var EncryptedIntegerOrdColumn = class extends EncryptedV3Column {
|
|
391
|
+
};
|
|
392
|
+
var EncryptedSmallintColumn = class extends EncryptedV3Column {
|
|
393
|
+
};
|
|
394
|
+
var EncryptedSmallintEqColumn = class extends EncryptedV3Column {
|
|
395
|
+
};
|
|
396
|
+
var EncryptedSmallintOrdOreColumn = class extends EncryptedV3Column {
|
|
397
|
+
};
|
|
398
|
+
var EncryptedSmallintOrdColumn = class extends EncryptedV3Column {
|
|
399
|
+
};
|
|
400
|
+
var EncryptedBigintColumn = class extends EncryptedV3Column {
|
|
401
|
+
};
|
|
402
|
+
var EncryptedBigintEqColumn = class extends EncryptedV3Column {
|
|
403
|
+
};
|
|
404
|
+
var EncryptedBigintOrdOreColumn = class extends EncryptedV3Column {
|
|
405
|
+
};
|
|
406
|
+
var EncryptedBigintOrdColumn = class extends EncryptedV3Column {
|
|
407
|
+
};
|
|
408
|
+
var EncryptedDateColumn = class extends EncryptedV3Column {
|
|
409
|
+
};
|
|
410
|
+
var EncryptedDateEqColumn = class extends EncryptedV3Column {
|
|
411
|
+
};
|
|
412
|
+
var EncryptedDateOrdOreColumn = class extends EncryptedV3Column {
|
|
413
|
+
};
|
|
414
|
+
var EncryptedDateOrdColumn = class extends EncryptedV3Column {
|
|
415
|
+
};
|
|
416
|
+
var EncryptedTimestampColumn = class extends EncryptedV3Column {
|
|
417
|
+
};
|
|
418
|
+
var EncryptedTimestampEqColumn = class extends EncryptedV3Column {
|
|
419
|
+
};
|
|
420
|
+
var EncryptedTimestampOrdOreColumn = class extends EncryptedV3Column {
|
|
421
|
+
};
|
|
422
|
+
var EncryptedTimestampOrdColumn = class extends EncryptedV3Column {
|
|
423
|
+
};
|
|
424
|
+
var EncryptedNumericColumn = class extends EncryptedV3Column {
|
|
425
|
+
};
|
|
426
|
+
var EncryptedNumericEqColumn = class extends EncryptedV3Column {
|
|
427
|
+
};
|
|
428
|
+
var EncryptedNumericOrdOreColumn = class extends EncryptedV3Column {
|
|
429
|
+
};
|
|
430
|
+
var EncryptedNumericOrdColumn = class extends EncryptedV3Column {
|
|
431
|
+
};
|
|
432
|
+
var EncryptedTextColumn = class extends EncryptedV3Column {
|
|
433
|
+
};
|
|
434
|
+
var EncryptedTextEqColumn = class extends EncryptedV3Column {
|
|
435
|
+
};
|
|
436
|
+
var EncryptedTextMatchColumn = class extends EncryptedV3Column {
|
|
437
|
+
};
|
|
438
|
+
var EncryptedTextOrdOreColumn = class extends EncryptedV3Column {
|
|
439
|
+
};
|
|
440
|
+
var EncryptedTextOrdColumn = class extends EncryptedV3Column {
|
|
441
|
+
};
|
|
442
|
+
var EncryptedBooleanColumn = class extends EncryptedV3Column {
|
|
443
|
+
};
|
|
444
|
+
var EncryptedRealColumn = class extends EncryptedV3Column {
|
|
445
|
+
};
|
|
446
|
+
var EncryptedRealEqColumn = class extends EncryptedV3Column {
|
|
447
|
+
};
|
|
448
|
+
var EncryptedRealOrdOreColumn = class extends EncryptedV3Column {
|
|
449
|
+
};
|
|
450
|
+
var EncryptedRealOrdColumn = class extends EncryptedV3Column {
|
|
451
|
+
};
|
|
452
|
+
var EncryptedDoubleColumn = class extends EncryptedV3Column {
|
|
453
|
+
};
|
|
454
|
+
var EncryptedDoubleEqColumn = class extends EncryptedV3Column {
|
|
455
|
+
};
|
|
456
|
+
var EncryptedDoubleOrdOreColumn = class extends EncryptedV3Column {
|
|
457
|
+
};
|
|
458
|
+
var EncryptedDoubleOrdColumn = class extends EncryptedV3Column {
|
|
459
|
+
};
|
|
460
|
+
var JSON_DOMAIN = {
|
|
461
|
+
eqlType: "public.eql_v3_json",
|
|
462
|
+
castAs: "json",
|
|
463
|
+
capabilities: {
|
|
464
|
+
equality: false,
|
|
465
|
+
orderAndRange: false,
|
|
466
|
+
freeTextSearch: false,
|
|
467
|
+
searchableJson: true
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
var EncryptedJsonColumn = class extends EncryptedV3Column {
|
|
471
|
+
constructor(columnName) {
|
|
472
|
+
super(columnName, JSON_DOMAIN);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
// src/eql/v3/types.ts
|
|
477
|
+
var types = {
|
|
478
|
+
// integer
|
|
479
|
+
Integer: (name) => new EncryptedIntegerColumn(name, INTEGER),
|
|
480
|
+
IntegerEq: (name) => new EncryptedIntegerEqColumn(name, INTEGER_EQ),
|
|
481
|
+
IntegerOrdOre: (name) => new EncryptedIntegerOrdOreColumn(name, INTEGER_ORD_ORE),
|
|
482
|
+
IntegerOrd: (name) => new EncryptedIntegerOrdColumn(name, INTEGER_ORD),
|
|
483
|
+
// smallint
|
|
484
|
+
Smallint: (name) => new EncryptedSmallintColumn(name, SMALLINT),
|
|
485
|
+
SmallintEq: (name) => new EncryptedSmallintEqColumn(name, SMALLINT_EQ),
|
|
486
|
+
SmallintOrdOre: (name) => new EncryptedSmallintOrdOreColumn(name, SMALLINT_ORD_ORE),
|
|
487
|
+
SmallintOrd: (name) => new EncryptedSmallintOrdColumn(name, SMALLINT_ORD),
|
|
488
|
+
// bigint (int8) — plaintext is a JS `bigint`, round-tripped losslessly by
|
|
489
|
+
// the native protect-ffi boundary (see ./columns)
|
|
490
|
+
Bigint: (name) => new EncryptedBigintColumn(name, BIGINT),
|
|
491
|
+
BigintEq: (name) => new EncryptedBigintEqColumn(name, BIGINT_EQ),
|
|
492
|
+
BigintOrdOre: (name) => new EncryptedBigintOrdOreColumn(name, BIGINT_ORD_ORE),
|
|
493
|
+
BigintOrd: (name) => new EncryptedBigintOrdColumn(name, BIGINT_ORD),
|
|
494
|
+
// date
|
|
495
|
+
Date: (name) => new EncryptedDateColumn(name, DATE),
|
|
496
|
+
DateEq: (name) => new EncryptedDateEqColumn(name, DATE_EQ),
|
|
497
|
+
DateOrdOre: (name) => new EncryptedDateOrdOreColumn(name, DATE_ORD_ORE),
|
|
498
|
+
DateOrd: (name) => new EncryptedDateOrdColumn(name, DATE_ORD),
|
|
499
|
+
// timestamp
|
|
500
|
+
Timestamp: (name) => new EncryptedTimestampColumn(name, TIMESTAMP),
|
|
501
|
+
TimestampEq: (name) => new EncryptedTimestampEqColumn(name, TIMESTAMP_EQ),
|
|
502
|
+
TimestampOrdOre: (name) => new EncryptedTimestampOrdOreColumn(name, TIMESTAMP_ORD_ORE),
|
|
503
|
+
TimestampOrd: (name) => new EncryptedTimestampOrdColumn(name, TIMESTAMP_ORD),
|
|
504
|
+
// numeric
|
|
505
|
+
Numeric: (name) => new EncryptedNumericColumn(name, NUMERIC),
|
|
506
|
+
NumericEq: (name) => new EncryptedNumericEqColumn(name, NUMERIC_EQ),
|
|
507
|
+
NumericOrdOre: (name) => new EncryptedNumericOrdOreColumn(name, NUMERIC_ORD_ORE),
|
|
508
|
+
NumericOrd: (name) => new EncryptedNumericOrdColumn(name, NUMERIC_ORD),
|
|
509
|
+
// text
|
|
510
|
+
Text: (name) => new EncryptedTextColumn(name, TEXT),
|
|
511
|
+
TextEq: (name) => new EncryptedTextEqColumn(name, TEXT_EQ),
|
|
512
|
+
TextMatch: (name) => new EncryptedTextMatchColumn(name, TEXT_MATCH),
|
|
513
|
+
TextOrdOre: (name) => new EncryptedTextOrdOreColumn(name, TEXT_ORD_ORE),
|
|
514
|
+
TextOrd: (name) => new EncryptedTextOrdColumn(name, TEXT_ORD),
|
|
515
|
+
TextSearch: (name) => new EncryptedTextSearchColumn(name),
|
|
516
|
+
// boolean
|
|
517
|
+
Boolean: (name) => new EncryptedBooleanColumn(name, BOOLEAN),
|
|
518
|
+
// real
|
|
519
|
+
Real: (name) => new EncryptedRealColumn(name, REAL),
|
|
520
|
+
RealEq: (name) => new EncryptedRealEqColumn(name, REAL_EQ),
|
|
521
|
+
RealOrdOre: (name) => new EncryptedRealOrdOreColumn(name, REAL_ORD_ORE),
|
|
522
|
+
RealOrd: (name) => new EncryptedRealOrdColumn(name, REAL_ORD),
|
|
523
|
+
// double
|
|
524
|
+
Double: (name) => new EncryptedDoubleColumn(name, DOUBLE),
|
|
525
|
+
DoubleEq: (name) => new EncryptedDoubleEqColumn(name, DOUBLE_EQ),
|
|
526
|
+
DoubleOrdOre: (name) => new EncryptedDoubleOrdOreColumn(name, DOUBLE_ORD_ORE),
|
|
527
|
+
DoubleOrd: (name) => new EncryptedDoubleOrdColumn(name, DOUBLE_ORD),
|
|
528
|
+
// json (encrypted JSONB document, ste_vec containment)
|
|
529
|
+
Json: (name) => new EncryptedJsonColumn(name)
|
|
530
|
+
// `satisfies` is load-bearing, not decoration: `DOMAIN_REGISTRY` derives itself
|
|
531
|
+
// by calling every value here at module load. A non-factory export would throw
|
|
532
|
+
// during module evaluation and take the supabase introspect/schema-build/verify
|
|
533
|
+
// path down with it. This turns that into a compile error at the offending line.
|
|
534
|
+
// `as const` applies first, so literal key inference is preserved.
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
// src/eql/v3/domain-registry.ts
|
|
538
|
+
var DOMAIN_REGISTRY = (() => {
|
|
539
|
+
const registry = /* @__PURE__ */ Object.create(null);
|
|
540
|
+
for (const factory of Object.values(types)) {
|
|
541
|
+
const key = stripDomainSchema(factory("_probe").getEqlType());
|
|
542
|
+
if (Object.hasOwn(registry, key)) {
|
|
543
|
+
throw new Error(`duplicate EQL v3 domain key: ${key}`);
|
|
544
|
+
}
|
|
545
|
+
registry[key] = factory;
|
|
546
|
+
}
|
|
547
|
+
return registry;
|
|
548
|
+
})();
|
|
549
|
+
function stripDomainSchema(eqlType) {
|
|
550
|
+
return eqlType.startsWith("public.") ? eqlType.slice("public.".length) : eqlType;
|
|
551
|
+
}
|
|
552
|
+
function factoryForDomain(domainName) {
|
|
553
|
+
return Object.hasOwn(DOMAIN_REGISTRY, domainName) ? DOMAIN_REGISTRY[domainName] : void 0;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// src/eql/v3/selector-path.ts
|
|
557
|
+
var FORBIDDEN_SEGMENTS = /* @__PURE__ */ new Set([
|
|
558
|
+
"__proto__",
|
|
559
|
+
"prototype",
|
|
560
|
+
"constructor"
|
|
561
|
+
]);
|
|
562
|
+
function parseSelectorSegments(path) {
|
|
563
|
+
const trimmed = path.trim();
|
|
564
|
+
let body = trimmed.startsWith("$") ? trimmed.slice(1) : trimmed;
|
|
565
|
+
if (body.startsWith(".")) body = body.slice(1);
|
|
566
|
+
if (body === "") {
|
|
567
|
+
throw new Error(
|
|
568
|
+
`JSON selector path "${path}" addresses no field \u2014 use e.g. "$.a" or "$.a.b".`
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
if (/[[\]*]/.test(body)) {
|
|
572
|
+
throw new Error(
|
|
573
|
+
`JSON selector path "${path}" uses array/wildcard syntax, which is not yet supported \u2014 use dot-notation object keys (e.g. "$.a.b").`
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
const segments = body.split(".");
|
|
577
|
+
for (const segment of segments) {
|
|
578
|
+
if (segment === "") {
|
|
579
|
+
throw new Error(
|
|
580
|
+
`JSON selector path "${path}" is malformed (empty segment / ".." / stray dot) \u2014 use dot-notation object keys (e.g. "$.a.b").`
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
if (segment !== segment.trim()) {
|
|
584
|
+
throw new Error(
|
|
585
|
+
`JSON selector path "${path}" has whitespace at a segment boundary ("${segment}") \u2014 it would address a different key. Remove the spacing around the dot.`
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
if (FORBIDDEN_SEGMENTS.has(segment)) {
|
|
589
|
+
throw new Error(
|
|
590
|
+
`JSON selector path "${path}" addresses the forbidden key "${segment}".`
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return segments;
|
|
595
|
+
}
|
|
596
|
+
function jsonPathOf(segments) {
|
|
597
|
+
return `$.${segments.join(".")}`;
|
|
598
|
+
}
|
|
599
|
+
function unsupportedLeafReason(value, ordering) {
|
|
600
|
+
if (value == null) {
|
|
601
|
+
return "a selector compares a non-null scalar leaf, but got null/undefined \u2014 SQL NULL never equals anything; use is(column, null) for null checks.";
|
|
602
|
+
}
|
|
603
|
+
const isScalar = value instanceof Date || typeof value === "number" || typeof value === "bigint" || typeof value === "string" || typeof value === "boolean";
|
|
604
|
+
if (!isScalar) {
|
|
605
|
+
return `a selector compares a scalar leaf, but got ${Array.isArray(value) ? "an array" : "an object"} \u2014 use contains() for sub-object matching.`;
|
|
606
|
+
}
|
|
607
|
+
if (ordering && typeof value === "boolean") {
|
|
608
|
+
return "a boolean leaf has no ordering \u2014 use eq/ne (or contains()).";
|
|
609
|
+
}
|
|
610
|
+
return null;
|
|
611
|
+
}
|
|
612
|
+
function reconstructSelectorDocument(segments, value) {
|
|
613
|
+
const root = /* @__PURE__ */ Object.create(null);
|
|
614
|
+
let cursor = root;
|
|
615
|
+
segments.forEach((segment, index) => {
|
|
616
|
+
if (index === segments.length - 1) {
|
|
617
|
+
cursor[segment] = value;
|
|
618
|
+
} else {
|
|
619
|
+
const next = /* @__PURE__ */ Object.create(null);
|
|
620
|
+
cursor[segment] = next;
|
|
621
|
+
cursor = next;
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
return root;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// ../../node_modules/.pnpm/evlog@1.11.0_next@15.5.18_react-dom@19.2.3_react@19.2.3__react@19.2.3__react@19.2.3/node_modules/evlog/dist/utils.mjs
|
|
628
|
+
function formatDuration(ms) {
|
|
629
|
+
if (ms < 1e3) return `${Math.round(ms)}ms`;
|
|
630
|
+
return `${(ms / 1e3).toFixed(2)}s`;
|
|
631
|
+
}
|
|
632
|
+
function isDev() {
|
|
633
|
+
if (typeof process !== "undefined") return process.env.NODE_ENV !== "production";
|
|
634
|
+
if (typeof window !== "undefined") return true;
|
|
635
|
+
return false;
|
|
636
|
+
}
|
|
637
|
+
function detectEnvironment() {
|
|
638
|
+
const env = typeof process !== "undefined" ? process.env : {};
|
|
639
|
+
const defaultEnvironment = isDev() ? "development" : "production";
|
|
640
|
+
return {
|
|
641
|
+
environment: env.NODE_ENV || defaultEnvironment,
|
|
642
|
+
service: env.SERVICE_NAME || "app",
|
|
643
|
+
version: env.APP_VERSION,
|
|
644
|
+
commitHash: env.COMMIT_SHA || env.GITHUB_SHA || env.VERCEL_GIT_COMMIT_SHA || env.CF_PAGES_COMMIT_SHA,
|
|
645
|
+
region: env.VERCEL_REGION || env.AWS_REGION || env.FLY_REGION || env.CF_REGION
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
function getConsoleMethod(level) {
|
|
649
|
+
return level;
|
|
650
|
+
}
|
|
651
|
+
var colors = {
|
|
652
|
+
reset: "\x1B[0m",
|
|
653
|
+
bold: "\x1B[1m",
|
|
654
|
+
dim: "\x1B[2m",
|
|
655
|
+
red: "\x1B[31m",
|
|
656
|
+
green: "\x1B[32m",
|
|
657
|
+
yellow: "\x1B[33m",
|
|
658
|
+
blue: "\x1B[34m",
|
|
659
|
+
magenta: "\x1B[35m",
|
|
660
|
+
cyan: "\x1B[36m",
|
|
661
|
+
white: "\x1B[37m",
|
|
662
|
+
gray: "\x1B[90m"
|
|
663
|
+
};
|
|
664
|
+
function getLevelColor(level) {
|
|
665
|
+
switch (level) {
|
|
666
|
+
case "error":
|
|
667
|
+
return colors.red;
|
|
668
|
+
case "warn":
|
|
669
|
+
return colors.yellow;
|
|
670
|
+
case "info":
|
|
671
|
+
return colors.cyan;
|
|
672
|
+
case "debug":
|
|
673
|
+
return colors.gray;
|
|
674
|
+
default:
|
|
675
|
+
return colors.white;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
function matchesPattern(path, pattern) {
|
|
679
|
+
const regexPattern = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "{{GLOBSTAR}}").replace(/\*/g, "[^/]*").replace(/{{GLOBSTAR}}/g, ".*").replace(/\?/g, "[^/]");
|
|
680
|
+
return new RegExp(`^${regexPattern}$`).test(path);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// ../../node_modules/.pnpm/evlog@1.11.0_next@15.5.18_react-dom@19.2.3_react@19.2.3__react@19.2.3__react@19.2.3/node_modules/evlog/dist/logger.mjs
|
|
684
|
+
function isPlainObject(val) {
|
|
685
|
+
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
686
|
+
}
|
|
687
|
+
function deepDefaults(base, defaults) {
|
|
688
|
+
const result = { ...base };
|
|
689
|
+
for (const key in defaults) {
|
|
690
|
+
const baseVal = result[key];
|
|
691
|
+
const defaultVal = defaults[key];
|
|
692
|
+
if (baseVal === void 0 || baseVal === null) result[key] = defaultVal;
|
|
693
|
+
else if (isPlainObject(baseVal) && isPlainObject(defaultVal)) result[key] = deepDefaults(baseVal, defaultVal);
|
|
694
|
+
}
|
|
695
|
+
return result;
|
|
696
|
+
}
|
|
697
|
+
var globalEnv = {
|
|
698
|
+
service: "app",
|
|
699
|
+
environment: "development"
|
|
700
|
+
};
|
|
701
|
+
var globalPretty = isDev();
|
|
702
|
+
var globalSampling = {};
|
|
703
|
+
var globalStringify = true;
|
|
704
|
+
var globalDrain;
|
|
705
|
+
var globalEnabled = true;
|
|
706
|
+
function initLogger(config = {}) {
|
|
707
|
+
globalEnabled = config.enabled ?? true;
|
|
708
|
+
const detected = detectEnvironment();
|
|
709
|
+
globalEnv = {
|
|
710
|
+
service: config.env?.service ?? detected.service ?? "app",
|
|
711
|
+
environment: config.env?.environment ?? detected.environment ?? "development",
|
|
712
|
+
version: config.env?.version ?? detected.version,
|
|
713
|
+
commitHash: config.env?.commitHash ?? detected.commitHash,
|
|
714
|
+
region: config.env?.region ?? detected.region
|
|
715
|
+
};
|
|
716
|
+
globalPretty = config.pretty ?? isDev();
|
|
717
|
+
globalSampling = config.sampling ?? {};
|
|
718
|
+
globalStringify = config.stringify ?? true;
|
|
719
|
+
globalDrain = config.drain;
|
|
720
|
+
}
|
|
721
|
+
function shouldSample(level) {
|
|
722
|
+
const { rates } = globalSampling;
|
|
723
|
+
if (!rates) return true;
|
|
724
|
+
const percentage = level === "error" && rates.error === void 0 ? 100 : rates[level] ?? 100;
|
|
725
|
+
if (percentage <= 0) return false;
|
|
726
|
+
if (percentage >= 100) return true;
|
|
727
|
+
return Math.random() * 100 < percentage;
|
|
728
|
+
}
|
|
729
|
+
function shouldKeep(ctx) {
|
|
730
|
+
const { keep } = globalSampling;
|
|
731
|
+
if (!keep?.length) return false;
|
|
732
|
+
return keep.some((condition) => {
|
|
733
|
+
if (condition.status !== void 0 && ctx.status !== void 0 && ctx.status >= condition.status) return true;
|
|
734
|
+
if (condition.duration !== void 0 && ctx.duration !== void 0 && ctx.duration >= condition.duration) return true;
|
|
735
|
+
if (condition.path && ctx.path && matchesPattern(ctx.path, condition.path)) return true;
|
|
736
|
+
return false;
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
function emitWideEvent(level, event, skipSamplingCheck = false) {
|
|
740
|
+
if (!globalEnabled) return null;
|
|
741
|
+
if (!skipSamplingCheck && !shouldSample(level)) return null;
|
|
742
|
+
const formatted = {
|
|
743
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
744
|
+
level,
|
|
745
|
+
...globalEnv,
|
|
746
|
+
...event
|
|
747
|
+
};
|
|
748
|
+
if (globalPretty) prettyPrintWideEvent(formatted);
|
|
749
|
+
else if (globalStringify) console[getConsoleMethod(level)](JSON.stringify(formatted));
|
|
750
|
+
else console[getConsoleMethod(level)](formatted);
|
|
751
|
+
if (globalDrain) Promise.resolve(globalDrain({ event: formatted })).catch((err) => {
|
|
752
|
+
console.error("[evlog] drain failed:", err);
|
|
753
|
+
});
|
|
754
|
+
return formatted;
|
|
755
|
+
}
|
|
756
|
+
function emitTaggedLog(level, tag, message) {
|
|
757
|
+
if (!globalEnabled) return;
|
|
758
|
+
if (globalPretty) {
|
|
759
|
+
if (!shouldSample(level)) return;
|
|
760
|
+
const color = getLevelColor(level);
|
|
761
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().slice(11, 23);
|
|
762
|
+
console.log(`${colors.dim}${timestamp}${colors.reset} ${color}[${tag}]${colors.reset} ${message}`);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
emitWideEvent(level, {
|
|
766
|
+
tag,
|
|
767
|
+
message
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
function formatValue(value) {
|
|
771
|
+
if (value === null || value === void 0) return String(value);
|
|
772
|
+
if (typeof value === "object") {
|
|
773
|
+
const pairs = [];
|
|
774
|
+
for (const [k, v] of Object.entries(value)) if (v !== void 0 && v !== null) if (typeof v === "object") pairs.push(`${k}=${JSON.stringify(v)}`);
|
|
775
|
+
else pairs.push(`${k}=${v}`);
|
|
776
|
+
return pairs.join(" ");
|
|
777
|
+
}
|
|
778
|
+
return String(value);
|
|
779
|
+
}
|
|
780
|
+
function prettyPrintWideEvent(event) {
|
|
781
|
+
const { timestamp, level, service, environment, version, ...rest } = event;
|
|
782
|
+
const levelColor = getLevelColor(level);
|
|
783
|
+
const ts = timestamp.slice(11, 23);
|
|
784
|
+
let header = `${colors.dim}${ts}${colors.reset} ${levelColor}${level.toUpperCase()}${colors.reset}`;
|
|
785
|
+
header += ` ${colors.cyan}[${service}]${colors.reset}`;
|
|
786
|
+
if (rest.method && rest.path) {
|
|
787
|
+
header += ` ${rest.method} ${rest.path}`;
|
|
788
|
+
delete rest.method;
|
|
789
|
+
delete rest.path;
|
|
790
|
+
}
|
|
791
|
+
if (rest.status) {
|
|
792
|
+
const statusColor = rest.status >= 400 ? colors.red : colors.green;
|
|
793
|
+
header += ` ${statusColor}${rest.status}${colors.reset}`;
|
|
794
|
+
delete rest.status;
|
|
795
|
+
}
|
|
796
|
+
if (rest.duration) {
|
|
797
|
+
header += ` ${colors.dim}in ${rest.duration}${colors.reset}`;
|
|
798
|
+
delete rest.duration;
|
|
799
|
+
}
|
|
800
|
+
console.log(header);
|
|
801
|
+
const entries = Object.entries(rest).filter(([_, v]) => v !== void 0);
|
|
802
|
+
const lastIndex = entries.length - 1;
|
|
803
|
+
entries.forEach(([key, value], index) => {
|
|
804
|
+
const prefix = index === lastIndex ? "\u2514\u2500" : "\u251C\u2500";
|
|
805
|
+
const formatted = formatValue(value);
|
|
806
|
+
console.log(` ${colors.dim}${prefix}${colors.reset} ${colors.cyan}${key}:${colors.reset} ${formatted}`);
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
function createLogMethod(level) {
|
|
810
|
+
return function logMethod(tagOrEvent, message) {
|
|
811
|
+
if (typeof tagOrEvent === "string" && message !== void 0) emitTaggedLog(level, tagOrEvent, message);
|
|
812
|
+
else if (typeof tagOrEvent === "object") emitWideEvent(level, tagOrEvent);
|
|
813
|
+
else emitTaggedLog(level, "log", String(tagOrEvent));
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
var _log = {
|
|
817
|
+
info: createLogMethod("info"),
|
|
818
|
+
error: createLogMethod("error"),
|
|
819
|
+
warn: createLogMethod("warn"),
|
|
820
|
+
debug: createLogMethod("debug")
|
|
821
|
+
};
|
|
822
|
+
var noopLogger = {
|
|
823
|
+
set() {
|
|
824
|
+
},
|
|
825
|
+
error() {
|
|
826
|
+
},
|
|
827
|
+
info() {
|
|
828
|
+
},
|
|
829
|
+
warn() {
|
|
830
|
+
},
|
|
831
|
+
emit() {
|
|
832
|
+
return null;
|
|
833
|
+
},
|
|
834
|
+
getContext() {
|
|
835
|
+
return {};
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
function createRequestLogger(options = {}) {
|
|
839
|
+
if (!globalEnabled) return noopLogger;
|
|
840
|
+
const startTime = Date.now();
|
|
841
|
+
let context = {
|
|
842
|
+
method: options.method,
|
|
843
|
+
path: options.path,
|
|
844
|
+
requestId: options.requestId
|
|
845
|
+
};
|
|
846
|
+
let hasError = false;
|
|
847
|
+
let hasWarn = false;
|
|
848
|
+
function addRequestLog(level, message) {
|
|
849
|
+
const entry = {
|
|
850
|
+
level,
|
|
851
|
+
message,
|
|
852
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
853
|
+
};
|
|
854
|
+
const requestLogs = Array.isArray(context.requestLogs) ? [...context.requestLogs, entry] : [entry];
|
|
855
|
+
context = {
|
|
856
|
+
...context,
|
|
857
|
+
requestLogs
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
return {
|
|
861
|
+
set(data) {
|
|
862
|
+
context = deepDefaults(data, context);
|
|
863
|
+
},
|
|
864
|
+
error(error, errorContext) {
|
|
865
|
+
hasError = true;
|
|
866
|
+
const err = typeof error === "string" ? new Error(error) : error;
|
|
867
|
+
context = deepDefaults({
|
|
868
|
+
...errorContext,
|
|
869
|
+
error: {
|
|
870
|
+
name: err.name,
|
|
871
|
+
message: err.message,
|
|
872
|
+
stack: err.stack,
|
|
873
|
+
..."status" in err && { status: err.status },
|
|
874
|
+
..."statusText" in err && { statusText: err.statusText },
|
|
875
|
+
..."statusCode" in err && { statusCode: err.statusCode },
|
|
876
|
+
..."statusMessage" in err && { statusMessage: err.statusMessage },
|
|
877
|
+
..."data" in err && { data: err.data },
|
|
878
|
+
..."cause" in err && { cause: err.cause }
|
|
879
|
+
}
|
|
880
|
+
}, context);
|
|
881
|
+
},
|
|
882
|
+
info(message, infoContext) {
|
|
883
|
+
addRequestLog("info", message);
|
|
884
|
+
if (infoContext) {
|
|
885
|
+
const { requestLogs: _, ...rest } = infoContext;
|
|
886
|
+
context = deepDefaults(rest, context);
|
|
887
|
+
}
|
|
888
|
+
},
|
|
889
|
+
warn(message, warnContext) {
|
|
890
|
+
hasWarn = true;
|
|
891
|
+
addRequestLog("warn", message);
|
|
892
|
+
if (warnContext) {
|
|
893
|
+
const { requestLogs: _, ...rest } = warnContext;
|
|
894
|
+
context = deepDefaults(rest, context);
|
|
895
|
+
}
|
|
896
|
+
},
|
|
897
|
+
emit(overrides) {
|
|
898
|
+
const durationMs = Date.now() - startTime;
|
|
899
|
+
const duration = formatDuration(durationMs);
|
|
900
|
+
const level = hasError ? "error" : hasWarn ? "warn" : "info";
|
|
901
|
+
const { _forceKeep, ...restOverrides } = overrides ?? {};
|
|
902
|
+
const tailCtx = {
|
|
903
|
+
status: context.status ?? restOverrides.status,
|
|
904
|
+
duration: durationMs,
|
|
905
|
+
path: context.path,
|
|
906
|
+
method: context.method,
|
|
907
|
+
context: {
|
|
908
|
+
...context,
|
|
909
|
+
...restOverrides
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
if (!(_forceKeep || shouldKeep(tailCtx)) && !shouldSample(level)) return null;
|
|
913
|
+
return emitWideEvent(level, {
|
|
914
|
+
...context,
|
|
915
|
+
...restOverrides,
|
|
916
|
+
duration
|
|
917
|
+
}, true);
|
|
918
|
+
},
|
|
919
|
+
getContext() {
|
|
920
|
+
return { ...context };
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// src/utils/logger/index.ts
|
|
926
|
+
var validLevels = ["debug", "info", "error"];
|
|
927
|
+
function levelFromEnv() {
|
|
928
|
+
const env = process.env.STASH_STACK_LOG;
|
|
929
|
+
if (env && validLevels.includes(env)) return env;
|
|
930
|
+
return "error";
|
|
931
|
+
}
|
|
932
|
+
function samplingRatesForLevel(level) {
|
|
933
|
+
switch (level) {
|
|
934
|
+
case "debug":
|
|
935
|
+
return { debug: 100, info: 100, warn: 100, error: 100 };
|
|
936
|
+
case "info":
|
|
937
|
+
return { debug: 0, info: 100, warn: 100, error: 100 };
|
|
938
|
+
case "error":
|
|
939
|
+
default:
|
|
940
|
+
return { debug: 0, info: 0, warn: 0, error: 100 };
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
var initialized = false;
|
|
944
|
+
function initStackLogger() {
|
|
945
|
+
if (initialized) return;
|
|
946
|
+
initialized = true;
|
|
947
|
+
const level = levelFromEnv();
|
|
948
|
+
const rates = samplingRatesForLevel(level);
|
|
949
|
+
initLogger({
|
|
950
|
+
env: { service: "@cipherstash/stack" },
|
|
951
|
+
enabled: true,
|
|
952
|
+
sampling: { rates }
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
initStackLogger();
|
|
956
|
+
function safeMessage(args) {
|
|
957
|
+
return typeof args[0] === "string" ? args[0] : "";
|
|
958
|
+
}
|
|
959
|
+
var logger = {
|
|
960
|
+
debug(...args) {
|
|
961
|
+
const log = createRequestLogger();
|
|
962
|
+
log.set({
|
|
963
|
+
level: "debug",
|
|
964
|
+
source: "@cipherstash/stack",
|
|
965
|
+
message: safeMessage(args)
|
|
966
|
+
});
|
|
967
|
+
log.emit();
|
|
968
|
+
},
|
|
969
|
+
info(...args) {
|
|
970
|
+
const log = createRequestLogger();
|
|
971
|
+
log.set({ source: "@cipherstash/stack" });
|
|
972
|
+
log.info(safeMessage(args));
|
|
973
|
+
log.emit();
|
|
974
|
+
},
|
|
975
|
+
warn(...args) {
|
|
976
|
+
const log = createRequestLogger();
|
|
977
|
+
log.warn(safeMessage(args));
|
|
978
|
+
log.emit();
|
|
979
|
+
},
|
|
980
|
+
error(...args) {
|
|
981
|
+
const log = createRequestLogger();
|
|
982
|
+
log.error(safeMessage(args));
|
|
983
|
+
log.emit();
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
987
|
+
0 && (module.exports = {
|
|
988
|
+
DATE_LIKE_CASTS,
|
|
989
|
+
DOMAIN_REGISTRY,
|
|
990
|
+
EncryptedV3Column,
|
|
991
|
+
bulkModelsToEncryptedPgComposites,
|
|
992
|
+
factoryForDomain,
|
|
993
|
+
jsonPathOf,
|
|
994
|
+
logger,
|
|
995
|
+
matchNeedleError,
|
|
996
|
+
modelToEncryptedPgComposites,
|
|
997
|
+
parseSelectorSegments,
|
|
998
|
+
reconstructSelectorDocument,
|
|
999
|
+
stripDomainSchema,
|
|
1000
|
+
unsupportedLeafReason
|
|
1001
|
+
});
|
|
1002
|
+
//# sourceMappingURL=adapter-kit.cjs.map
|