kitcn 0.24.0 → 0.25.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/dist/aggregate/index.d.ts +11 -1
- package/dist/aggregate/index.js +1 -1
- package/dist/auth/generated/index.d.ts +1 -1
- package/dist/auth/generated/index.js +1 -1
- package/dist/auth/http/index.d.ts +1 -1
- package/dist/auth/index.d.ts +4 -4
- package/dist/auth/index.js +10 -9
- package/dist/auth/nextjs/index.d.ts +2 -2
- package/dist/auth/nextjs/index.js +3 -3
- package/dist/auth/start/server/index.d.ts +1 -1
- package/dist/auth/start/server/index.js +1 -1
- package/dist/{builder-CsxVc5xC.js → builder-1Vx-tEnS.js} +3 -3
- package/dist/{caller-factory-CWa0ELLD.js → caller-factory-Dd3H7j3V.js} +3 -3
- package/dist/{where-clause-compiler-DW6jy2er.d.ts → capabilities-Bem7xvGK.d.ts} +2958 -4145
- package/dist/cli.mjs +59 -40
- package/dist/{convex-plugin-D8B0oCFq.js → convex-plugin-DfOhBU9g.js} +1 -1
- package/dist/{create-schema-orm-B3f2Kc8O.js → create-schema-orm-Bu2JCiBS.js} +1 -1
- package/dist/crpc/index.d.ts +2 -2
- package/dist/crpc/index.js +3 -3
- package/dist/{customFunctions-DxEEO4Dq.js → customFunctions-BbhgdRGl.js} +2 -2
- package/dist/definitions-D9vhJ6OV.js +215 -0
- package/dist/extensions-DzjCJXYl.js +55 -0
- package/dist/filter-expression-Dydt8wS0.js +402 -0
- package/dist/{generated-contract-disabled-B-nmd7Ne.d.ts → generated-contract-disabled-BEc4d98x.d.ts} +2 -2
- package/dist/{http-types-DXOgaerG.d.ts → http-types-90mapMP9.d.ts} +2 -2
- package/dist/id-Bibg34Yb.js +37 -0
- package/dist/{local-env-yFKub75x.mjs → local-env-Du24tdbp.mjs} +2243 -2113
- package/dist/{middleware-Br5zubu7.d.ts → middleware-CE_MC6Gi.d.ts} +1 -1
- package/dist/{middleware-DUd1Sj39.js → middleware-cJDRHTRY.js} +1 -1
- package/dist/orm/aggregate-index/index.d.ts +20 -0
- package/dist/orm/aggregate-index/index.js +2136 -0
- package/dist/orm/index.d.ts +5 -4
- package/dist/orm/index.js +126 -4292
- package/dist/orm/migrations/index.d.ts +3 -0
- package/dist/orm/migrations/index.js +506 -0
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/{procedure-caller-DQxnLBS_.js → procedure-caller-DIzXfX2E.js} +2 -2
- package/dist/{procedure-name-C20pFZnk.d.ts → procedure-name-B09-cf1-.d.ts} +3 -3
- package/dist/{query-context-BzihIpnM.js → query-context-DOm5Xm3H.js} +1 -402
- package/dist/ratelimit/index.d.ts +2 -2
- package/dist/ratelimit/index.js +3 -3
- package/dist/rsc/index.d.ts +4 -4
- package/dist/rsc/index.js +4 -4
- package/dist/runtime-DfGsZtx3.js +1074 -0
- package/dist/schema-Besl-rpv.js +1411 -0
- package/dist/server/index.d.ts +4 -4
- package/dist/server/index.js +4 -4
- package/dist/{runtime-6DJxpDfb.js → table-rmJm5Qio.js} +3 -1095
- package/dist/{token-xlpENMVn.js → token-DcV_0fkF.js} +1 -1
- package/dist/{types-BHR7ZKKD.d.ts → types-In-ZZOsd.d.ts} +1 -1
- package/dist/{validators-C7LelqTN.js → validators-Dmbhsd3U.js} +1 -1
- package/dist/watcher.mjs +1 -1
- package/dist/where-clause-compiler-mohWFiG0.d.ts +2042 -0
- package/package.json +3 -2
- package/skills/kitcn/SKILL.md +19 -18
- package/skills/kitcn/references/features/aggregates.md +21 -0
- package/skills/kitcn/references/features/auth-organizations.md +3 -3
- package/skills/kitcn/references/features/auth-polar.md +2 -1
- package/skills/kitcn/references/features/auth.md +8 -1
- package/skills/kitcn/references/setup/auth.md +52 -42
- package/skills/kitcn/references/setup/index.md +1 -1
- package/skills/kitcn/references/setup/server.md +2 -1
- /package/dist/{api-entry-N3nBOlI2.js → api-entry-CkDpGYVg.js} +0 -0
- /package/dist/{context-utils-BBUtBqjN.d.ts → context-utils-DwZ3Cam1.d.ts} +0 -0
- /package/dist/{create-schema-BXrKE2YY.js → create-schema-BRFjdgRr.js} +0 -0
- /package/dist/{error-Bvo7YEhk.js → error-CMLeCadS.js} +0 -0
- /package/dist/{generated-contract-disabled-BXaz7JCE.js → generated-contract-disabled-CZa0iyV0.js} +0 -0
- /package/dist/{meta-utils-D9K4fICl.js → meta-utils-D2lqN2Lg.js} +0 -0
- /package/dist/{query-context-CNo9ffvI.d.ts → query-context-DJONf8X5.d.ts} +0 -0
- /package/dist/{query-options-CzRV4G4N.js → query-options-DUiOj01a.js} +0 -0
- /package/dist/{token-B9Bjcqug.d.ts → token-kQaqFby4.d.ts} +0 -0
- /package/dist/{transformer-yZuBWo8v.js → transformer-D8wO-kEj.js} +0 -0
- /package/dist/{types-BCl8gfGy.d.ts → types-Bf3XQex5.d.ts} +0 -0
- /package/dist/{types-DF2cg_w0.d.ts → types-MHYXboyy.d.ts} +0 -0
- /package/dist/{types-CnTpHR1F.d.ts → types-eNzQmbqM.d.ts} +0 -0
- /package/dist/{upstream-BR6sBLg3.js → upstream-BCgGZX6q.js} +0 -0
- /package/dist/{validators-BhsByJeg.d.ts → validators-V4eM2-Jg.d.ts} +0 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
//#region src/orm/filter-expression.ts
|
|
2
|
+
/**
|
|
3
|
+
* Unique symbol for FilterExpression brand
|
|
4
|
+
* Prevents structural typing - only expressions created by factory functions are valid
|
|
5
|
+
*/
|
|
6
|
+
const FilterExpressionBrand = Symbol("FilterExpression");
|
|
7
|
+
/**
|
|
8
|
+
* Create a field reference
|
|
9
|
+
* Used internally by operator functions
|
|
10
|
+
*/
|
|
11
|
+
function fieldRef(fieldName) {
|
|
12
|
+
return {
|
|
13
|
+
__brand: "FieldReference",
|
|
14
|
+
fieldName
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Type guard for FieldReference
|
|
19
|
+
*/
|
|
20
|
+
function isFieldReference(value) {
|
|
21
|
+
return value && typeof value === "object" && value.__brand === "FieldReference";
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The pattern is the same for every row of a scan while the value is not, so
|
|
25
|
+
* only the value genuinely has to be split per call. A small bounded cache
|
|
26
|
+
* keeps the split pattern across rows without unbounded growth on
|
|
27
|
+
* caller-supplied patterns; a query with a handful of LIKE filters still hits
|
|
28
|
+
* on every row.
|
|
29
|
+
*/
|
|
30
|
+
const LIKE_PATTERN_CACHE_MAX = 16;
|
|
31
|
+
const likePatternCache = /* @__PURE__ */ new Map();
|
|
32
|
+
function likePatternCodePoints(pattern, caseInsensitive) {
|
|
33
|
+
const key = caseInsensitive ? `i:${pattern}` : `s:${pattern}`;
|
|
34
|
+
const cached = likePatternCache.get(key);
|
|
35
|
+
if (cached) return cached;
|
|
36
|
+
const source = Array.from(caseInsensitive ? pattern.toLowerCase() : pattern);
|
|
37
|
+
if (likePatternCache.size >= LIKE_PATTERN_CACHE_MAX) for (const oldest of likePatternCache.keys()) {
|
|
38
|
+
likePatternCache.delete(oldest);
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
likePatternCache.set(key, source);
|
|
42
|
+
return source;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* SQL `LIKE` semantics: `%` matches any run of characters, `_` matches exactly
|
|
46
|
+
* one, everything else is literal. Wildcards work anywhere in the pattern, not
|
|
47
|
+
* only at the ends.
|
|
48
|
+
*
|
|
49
|
+
* Matched with a single-backtrack scan rather than a compiled regex. A pattern
|
|
50
|
+
* is caller data — anything interpolated into `` `%${query}%` `` reaches here —
|
|
51
|
+
* and translating `%` to a regex quantifier makes `'%%%%%z'` backtrack
|
|
52
|
+
* exponentially, which would burn the whole Convex function CPU budget on one
|
|
53
|
+
* row. This scan remembers only the most recent `%`, so the worst case is
|
|
54
|
+
* O(value * pattern) with no catastrophic case at all.
|
|
55
|
+
*/
|
|
56
|
+
function matchLikePattern(value, pattern, caseInsensitive) {
|
|
57
|
+
const target = Array.from(caseInsensitive ? value.toLowerCase() : value);
|
|
58
|
+
const source = likePatternCodePoints(pattern, caseInsensitive);
|
|
59
|
+
let valueIndex = 0;
|
|
60
|
+
let patternIndex = 0;
|
|
61
|
+
let wildcardPatternIndex = -1;
|
|
62
|
+
let wildcardValueIndex = 0;
|
|
63
|
+
while (valueIndex < target.length) {
|
|
64
|
+
const patternChar = patternIndex < source.length ? source[patternIndex] : void 0;
|
|
65
|
+
if (patternChar === "_" || patternChar === target[valueIndex]) {
|
|
66
|
+
valueIndex += 1;
|
|
67
|
+
patternIndex += 1;
|
|
68
|
+
} else if (patternChar === "%") {
|
|
69
|
+
wildcardPatternIndex = patternIndex;
|
|
70
|
+
wildcardValueIndex = valueIndex;
|
|
71
|
+
patternIndex += 1;
|
|
72
|
+
} else if (wildcardPatternIndex === -1) return false;
|
|
73
|
+
else {
|
|
74
|
+
wildcardValueIndex += 1;
|
|
75
|
+
valueIndex = wildcardValueIndex;
|
|
76
|
+
patternIndex = wildcardPatternIndex + 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
while (patternIndex < source.length && source[patternIndex] === "%") patternIndex += 1;
|
|
80
|
+
return patternIndex === source.length;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Structural equality matching Convex's own `q.eq`. Arrays, objects and bytes
|
|
84
|
+
* are compared by content: reference identity would make every `eq`/`in` filter
|
|
85
|
+
* on a `custom(v.array(...))` / `custom(v.object(...))` column match nothing.
|
|
86
|
+
*/
|
|
87
|
+
function filterValuesEqual(a, b) {
|
|
88
|
+
if (a === b) return true;
|
|
89
|
+
if (a === null || b === null || typeof a !== "object" || typeof b !== "object") return false;
|
|
90
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
91
|
+
if (!(Array.isArray(a) && Array.isArray(b)) || a.length !== b.length) return false;
|
|
92
|
+
return a.every((item, index) => filterValuesEqual(item, b[index]));
|
|
93
|
+
}
|
|
94
|
+
if (a instanceof ArrayBuffer || b instanceof ArrayBuffer) {
|
|
95
|
+
if (!(a instanceof ArrayBuffer && b instanceof ArrayBuffer) || a.byteLength !== b.byteLength) return false;
|
|
96
|
+
const left = new Uint8Array(a);
|
|
97
|
+
const right = new Uint8Array(b);
|
|
98
|
+
return left.every((byte, index) => byte === right[index]);
|
|
99
|
+
}
|
|
100
|
+
const aKeys = Object.keys(a);
|
|
101
|
+
const bKeys = Object.keys(b);
|
|
102
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
103
|
+
return aKeys.every((key) => Object.hasOwn(b, key) && filterValuesEqual(a[key], b[key]));
|
|
104
|
+
}
|
|
105
|
+
/** `inArray`/`notInArray` membership using {@link filterValuesEqual}. */
|
|
106
|
+
function filterValueInList(value, list) {
|
|
107
|
+
return list.some((candidate) => filterValuesEqual(candidate, value));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Create a column wrapper
|
|
111
|
+
* Used internally by query builder's _createColumnProxies
|
|
112
|
+
*/
|
|
113
|
+
function column(builder, columnName) {
|
|
114
|
+
return {
|
|
115
|
+
builder,
|
|
116
|
+
columnName
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function resolveColumn(col) {
|
|
120
|
+
if (col && typeof col === "object" && "columnName" in col) return col;
|
|
121
|
+
if (isFieldReference(col)) return {
|
|
122
|
+
builder: col,
|
|
123
|
+
columnName: col.fieldName
|
|
124
|
+
};
|
|
125
|
+
const builder = col;
|
|
126
|
+
const columnName = builder?.config?.name;
|
|
127
|
+
if (!columnName) throw new Error("Column builder is missing a column name");
|
|
128
|
+
return column(builder, columnName);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Internal binary expression implementation
|
|
132
|
+
* Private class - only accessible via factory functions
|
|
133
|
+
*/
|
|
134
|
+
var BinaryExpressionImpl = class {
|
|
135
|
+
[FilterExpressionBrand] = true;
|
|
136
|
+
type = "binary";
|
|
137
|
+
constructor(operator, operands) {
|
|
138
|
+
this.operator = operator;
|
|
139
|
+
this.operands = operands;
|
|
140
|
+
}
|
|
141
|
+
accept(visitor) {
|
|
142
|
+
return visitor.visitBinary(this);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Internal logical expression implementation
|
|
147
|
+
* Private class - only accessible via factory functions
|
|
148
|
+
*/
|
|
149
|
+
var LogicalExpressionImpl = class {
|
|
150
|
+
[FilterExpressionBrand] = true;
|
|
151
|
+
type = "logical";
|
|
152
|
+
constructor(operator, operands) {
|
|
153
|
+
this.operator = operator;
|
|
154
|
+
this.operands = operands;
|
|
155
|
+
}
|
|
156
|
+
accept(visitor) {
|
|
157
|
+
return visitor.visitLogical(this);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Internal unary expression implementation
|
|
162
|
+
* Private class - only accessible via factory functions
|
|
163
|
+
*/
|
|
164
|
+
var UnaryExpressionImpl = class {
|
|
165
|
+
[FilterExpressionBrand] = true;
|
|
166
|
+
type = "unary";
|
|
167
|
+
constructor(operator, operands) {
|
|
168
|
+
this.operator = operator;
|
|
169
|
+
this.operands = operands;
|
|
170
|
+
}
|
|
171
|
+
accept(visitor) {
|
|
172
|
+
return visitor.visitUnary(this);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Equality operator: field == value
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* const filter = eq(cols.name, 'Alice');
|
|
180
|
+
*/
|
|
181
|
+
function eq(col, value) {
|
|
182
|
+
return new BinaryExpressionImpl("eq", [fieldRef(resolveColumn(col).columnName), value]);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Not equal operator: field != value
|
|
186
|
+
*/
|
|
187
|
+
function ne(col, value) {
|
|
188
|
+
return new BinaryExpressionImpl("ne", [fieldRef(resolveColumn(col).columnName), value]);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Greater than operator: field > value
|
|
192
|
+
*/
|
|
193
|
+
function gt(col, value) {
|
|
194
|
+
return new BinaryExpressionImpl("gt", [fieldRef(resolveColumn(col).columnName), value]);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Greater than or equal operator: field >= value
|
|
198
|
+
*/
|
|
199
|
+
function gte(col, value) {
|
|
200
|
+
return new BinaryExpressionImpl("gte", [fieldRef(resolveColumn(col).columnName), value]);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Less than operator: field < value
|
|
204
|
+
*/
|
|
205
|
+
function lt(col, value) {
|
|
206
|
+
return new BinaryExpressionImpl("lt", [fieldRef(resolveColumn(col).columnName), value]);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Less than or equal operator: field <= value
|
|
210
|
+
*/
|
|
211
|
+
function lte(col, value) {
|
|
212
|
+
return new BinaryExpressionImpl("lte", [fieldRef(resolveColumn(col).columnName), value]);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Between operator: field BETWEEN min AND max (inclusive)
|
|
216
|
+
*
|
|
217
|
+
* Sugar for and(gte(field, min), lte(field, max)).
|
|
218
|
+
*/
|
|
219
|
+
function between(col, min, max) {
|
|
220
|
+
return and(gte(col, min), lte(col, max));
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Not between operator: field < min OR field > max
|
|
224
|
+
*
|
|
225
|
+
* Sugar for or(lt(field, min), gt(field, max)).
|
|
226
|
+
*/
|
|
227
|
+
function notBetween(col, min, max) {
|
|
228
|
+
return or(lt(col, min), gt(col, max));
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* LIKE operator: SQL-style pattern matching with % wildcards
|
|
232
|
+
* Note: Implemented as post-filter (Convex has no native LIKE)
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* const users = await db.query.users.findMany({
|
|
236
|
+
* where: like(users.name, '%alice%'),
|
|
237
|
+
* });
|
|
238
|
+
*/
|
|
239
|
+
function like(col, pattern) {
|
|
240
|
+
return new BinaryExpressionImpl("like", [fieldRef(resolveColumn(col).columnName), pattern]);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* ILIKE operator: Case-insensitive LIKE
|
|
244
|
+
* Note: Implemented as post-filter (Convex has no native LIKE)
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* const users = await db.query.users.findMany({
|
|
248
|
+
* where: ilike(users.name, '%ALICE%'),
|
|
249
|
+
* });
|
|
250
|
+
*/
|
|
251
|
+
function ilike(col, pattern) {
|
|
252
|
+
return new BinaryExpressionImpl("ilike", [fieldRef(resolveColumn(col).columnName), pattern]);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* NOT LIKE operator: Negated LIKE pattern
|
|
256
|
+
*/
|
|
257
|
+
function notLike(col, pattern) {
|
|
258
|
+
return new BinaryExpressionImpl("notLike", [fieldRef(resolveColumn(col).columnName), pattern]);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* NOT ILIKE operator: Negated case-insensitive LIKE
|
|
262
|
+
*/
|
|
263
|
+
function notIlike(col, pattern) {
|
|
264
|
+
return new BinaryExpressionImpl("notIlike", [fieldRef(resolveColumn(col).columnName), pattern]);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* startsWith operator: Check if string starts with prefix
|
|
268
|
+
* Optimized for prefix matching
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* const users = await db.query.users.findMany({
|
|
272
|
+
* where: startsWith(users.email, 'admin@'),
|
|
273
|
+
* });
|
|
274
|
+
*/
|
|
275
|
+
function startsWith(col, prefix) {
|
|
276
|
+
return new BinaryExpressionImpl("startsWith", [fieldRef(resolveColumn(col).columnName), prefix]);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* endsWith operator: Check if string ends with suffix
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* const users = await db.query.users.findMany({
|
|
283
|
+
* where: endsWith(users.email, '@example.com'),
|
|
284
|
+
* });
|
|
285
|
+
*/
|
|
286
|
+
function endsWith(col, suffix) {
|
|
287
|
+
return new BinaryExpressionImpl("endsWith", [fieldRef(resolveColumn(col).columnName), suffix]);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* contains operator: Check if string contains substring
|
|
291
|
+
* Can use search index for optimization when available
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* const posts = await db.query.posts.findMany({
|
|
295
|
+
* where: contains(posts.title, 'javascript'),
|
|
296
|
+
* });
|
|
297
|
+
*/
|
|
298
|
+
function contains(col, substring) {
|
|
299
|
+
return new BinaryExpressionImpl("contains", [fieldRef(resolveColumn(col).columnName), substring]);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Logical AND: all expressions must be true
|
|
303
|
+
* Filters out undefined expressions (following Drizzle pattern)
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* const filter = and(
|
|
307
|
+
* eq(fieldRef('age'), 25),
|
|
308
|
+
* eq(fieldRef('name'), 'Alice')
|
|
309
|
+
* );
|
|
310
|
+
*/
|
|
311
|
+
function and(...expressions) {
|
|
312
|
+
const defined = expressions.filter((expr) => expr !== void 0);
|
|
313
|
+
if (defined.length === 0) return;
|
|
314
|
+
if (defined.length === 1) return defined[0];
|
|
315
|
+
return new LogicalExpressionImpl("and", defined);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Logical OR: at least one expression must be true
|
|
319
|
+
* Filters out undefined expressions (following Drizzle pattern)
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* const filter = or(
|
|
323
|
+
* eq(fieldRef('status'), 'active'),
|
|
324
|
+
* eq(fieldRef('status'), 'pending')
|
|
325
|
+
* );
|
|
326
|
+
*/
|
|
327
|
+
function or(...expressions) {
|
|
328
|
+
const defined = expressions.filter((expr) => expr !== void 0);
|
|
329
|
+
if (defined.length === 0) return;
|
|
330
|
+
if (defined.length === 1) return defined[0];
|
|
331
|
+
return new LogicalExpressionImpl("or", defined);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Logical NOT: negates expression
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* const filter = not(eq(fieldRef('isDeleted'), true));
|
|
338
|
+
*/
|
|
339
|
+
function not(expression) {
|
|
340
|
+
return new UnaryExpressionImpl("not", [expression]);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Array membership operator: field IN array
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* const filter = inArray(cols.status, ['active', 'pending']);
|
|
347
|
+
*/
|
|
348
|
+
function inArray(col, values) {
|
|
349
|
+
return new BinaryExpressionImpl("inArray", [fieldRef(resolveColumn(col).columnName), values]);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Array exclusion operator: field NOT IN array
|
|
353
|
+
* Validates array is non-empty at construction time
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* const filter = notInArray(cols.role, ['admin', 'moderator']);
|
|
357
|
+
*/
|
|
358
|
+
function notInArray(col, values) {
|
|
359
|
+
if (!Array.isArray(values) || values.length === 0) throw new Error("notInArray requires a non-empty array of values");
|
|
360
|
+
return new BinaryExpressionImpl("notInArray", [fieldRef(resolveColumn(col).columnName), values]);
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Array contains operator: field @> array
|
|
364
|
+
*/
|
|
365
|
+
function arrayContains(col, values) {
|
|
366
|
+
return new BinaryExpressionImpl("arrayContains", [fieldRef(resolveColumn(col).columnName), values]);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Array contained operator: field <@ array
|
|
370
|
+
*/
|
|
371
|
+
function arrayContained(col, values) {
|
|
372
|
+
return new BinaryExpressionImpl("arrayContained", [fieldRef(resolveColumn(col).columnName), values]);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Array overlaps operator: field && array
|
|
376
|
+
*/
|
|
377
|
+
function arrayOverlaps(col, values) {
|
|
378
|
+
return new BinaryExpressionImpl("arrayOverlaps", [fieldRef(resolveColumn(col).columnName), values]);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Null check operator: field IS NULL
|
|
382
|
+
* Type validation: Only works with nullable fields
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* const filter = isNull(cols.deletedAt);
|
|
386
|
+
*/
|
|
387
|
+
function isNull(col) {
|
|
388
|
+
return new UnaryExpressionImpl("isNull", [fieldRef(resolveColumn(col).columnName)]);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Not null check operator: field IS NOT NULL
|
|
392
|
+
* Type validation: Only works with nullable fields
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* const filter = isNotNull(cols.deletedAt);
|
|
396
|
+
*/
|
|
397
|
+
function isNotNull(col) {
|
|
398
|
+
return new UnaryExpressionImpl("isNotNull", [fieldRef(resolveColumn(col).columnName)]);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
//#endregion
|
|
402
|
+
export { or as A, matchLikePattern as C, notIlike as D, notBetween as E, notInArray as O, lte as S, not as T, isFieldReference as _, between as a, like as b, endsWith as c, filterValueInList as d, filterValuesEqual as f, inArray as g, ilike as h, arrayOverlaps as i, startsWith as j, notLike as k, eq as l, gte as m, arrayContained as n, column as o, gt as p, arrayContains as r, contains as s, and as t, fieldRef as u, isNotNull as v, ne as w, lt as x, isNull as y };
|
package/dist/{generated-contract-disabled-B-nmd7Ne.d.ts → generated-contract-disabled-BEc4d98x.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as GetAuth } from "./types-
|
|
2
|
-
import { t as GenericCtx } from "./context-utils-
|
|
1
|
+
import { t as GetAuth } from "./types-Bf3XQex5.js";
|
|
2
|
+
import { t as GenericCtx } from "./context-utils-DwZ3Cam1.js";
|
|
3
3
|
import * as convex_server0 from "convex/server";
|
|
4
4
|
import { DocumentByName, FunctionReference, GenericDataModel, GenericMutationCtx, GenericSchema, PaginationResult, SchemaDefinition, TableNamesInDataModel, internalMutationGeneric } from "convex/server";
|
|
5
5
|
import * as better_auth_adapters0 from "better-auth/adapters";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as Simplify } from "./types-
|
|
2
|
-
import { g as UnsetMarker, t as AnyMiddleware } from "./types-
|
|
1
|
+
import { o as Simplify } from "./types-MHYXboyy.js";
|
|
2
|
+
import { g as UnsetMarker, t as AnyMiddleware } from "./types-eNzQmbqM.js";
|
|
3
3
|
import { GenericActionCtx, GenericDataModel, HttpRouter } from "convex/server";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { Context, Hono } from "hono";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { I as ConvexColumnBuilder, L as entityKind } from "./table-rmJm5Qio.js";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
|
|
4
|
+
//#region src/orm/builders/id.ts
|
|
5
|
+
/**
|
|
6
|
+
* ID column builder class
|
|
7
|
+
* Compiles to v.id(tableName) or v.optional(v.id(tableName))
|
|
8
|
+
*/
|
|
9
|
+
var ConvexIdBuilder = class extends ConvexColumnBuilder {
|
|
10
|
+
static [entityKind] = "ConvexIdBuilder";
|
|
11
|
+
constructor(name, tableName) {
|
|
12
|
+
super(name, "string", "ConvexId");
|
|
13
|
+
this.tableName = tableName;
|
|
14
|
+
this.config.referenceTable = tableName;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Expose Convex validator for schema integration
|
|
18
|
+
*/
|
|
19
|
+
get convexValidator() {
|
|
20
|
+
if (this.config.notNull) return v.id(this.tableName);
|
|
21
|
+
return v.optional(v.union(v.null(), v.id(this.tableName)));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Compile to Convex validator
|
|
25
|
+
* .notNull() → v.id(tableName)
|
|
26
|
+
* nullable → v.optional(v.id(tableName))
|
|
27
|
+
*/
|
|
28
|
+
build() {
|
|
29
|
+
return this.convexValidator;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function id(tableName) {
|
|
33
|
+
return new ConvexIdBuilder("", tableName);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { id as t };
|