convex-ents 0.10.0 → 0.11.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/deletion.d.ts +1 -1
- package/dist/functions.d.ts +1 -1
- package/dist/functions.js +18 -491
- package/dist/functions.js.map +1 -1
- package/dist/{index-olos0Rx-.d.ts → index-kwzjMMHy.d.ts} +6 -375
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -657
- package/dist/index.js.map +1 -1
- package/dist/writer.d.ts +2 -2
- package/dist/writer.js +8 -11
- package/dist/writer.js.map +1 -1
- package/package.json +1 -1
- package/dist/actions.d.ts +0 -6
- package/dist/actions.js +0 -662
- package/dist/actions.js.map +0 -1
package/dist/deletion.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ type Origin = {
|
|
|
13
13
|
table: string;
|
|
14
14
|
deletionTime: number;
|
|
15
15
|
};
|
|
16
|
-
declare const vApproach: convex_values.VUnion<"
|
|
16
|
+
declare const vApproach: convex_values.VUnion<"cascade" | "paginate", [convex_values.VLiteral<"cascade", "required">, convex_values.VLiteral<"paginate", "required">], "required", never>;
|
|
17
17
|
type Approach = Infer<typeof vApproach>;
|
|
18
18
|
declare function scheduledDeleteFactory<EntsDataModel extends GenericEntsDataModel>(entDefinitions: EntsDataModel, options?: {
|
|
19
19
|
scheduledDelete: ScheduledDeleteFuncRef;
|
package/dist/functions.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'convex/values';
|
|
2
2
|
import 'convex/server';
|
|
3
|
-
export { a1 as DocRetriever, I as Ent, a0 as EntMutationCtx, $ as EntQueryCtx, G as EntsTable, H as EntsTableWriter, J as GenericEnt, Z as GenericEntWriter, C as PromiseArray, B as PromiseArrayOrNull, K as PromiseEdge, w as PromiseEdgeEnts, s as PromiseEdgeEntsOrNull, y as PromiseEdgeEntsWriter, u as PromiseEdgeEntsWriterOrNull, L as PromiseEdgeOrThrow, v as PromiseEdgeOrderedEnts, r as PromiseEdgeOrderedEntsOrNull, x as PromiseEdgeOrderedEntsWriter, t as PromiseEdgeOrderedEntsWriterOrNull, M as PromiseEdgeWriter, O as PromiseEdgeWriterOrNull, N as PromiseEdgeWriterOrThrow, A as PromiseEnt, _ as PromiseEntId, z as PromiseEntOrNull, Y as PromiseEntWriter, X as PromiseEntWriterOrNull, p as PromiseEnts, n as PromiseEntsOrNull, q as PromiseEntsOrNulls, S as PromiseEntsWriter, o as PromiseEntsWriterOrNull, j as PromiseOrderedQuery, i as PromiseOrderedQueryBase, P as PromiseOrderedQueryOrNull, Q as PromiseOrderedQueryWriter, d as PromiseOrderedQueryWriterOrNull, m as PromisePaginationResult, l as PromisePaginationResultOrNull, U as PromisePaginationResultWriter, T as PromisePaginationResultWriterOrNull, k as PromiseQuery, e as PromiseQueryOrNull, R as PromiseQueryWriter, f as PromiseQueryWriterOrNull, h as PromiseTable, g as PromiseTableBase, V as PromiseTableWriter, a2 as addEntRules, D as entWrapper, F as entsTableFactory, a5 as getDeletionConfig, a3 as getReadRule, a4 as getWriteRule } from './index-olos0Rx-.js';
|
|
4
3
|
import './deletion.js';
|
|
5
4
|
import './schema.js';
|
|
6
5
|
import './shared.js';
|
|
6
|
+
export { a1 as DocRetriever, I as Ent, a0 as EntMutationCtx, $ as EntQueryCtx, G as EntsTable, H as EntsTableWriter, J as GenericEnt, Z as GenericEntWriter, C as PromiseArray, B as PromiseArrayOrNull, K as PromiseEdge, w as PromiseEdgeEnts, s as PromiseEdgeEntsOrNull, y as PromiseEdgeEntsWriter, u as PromiseEdgeEntsWriterOrNull, L as PromiseEdgeOrThrow, v as PromiseEdgeOrderedEnts, r as PromiseEdgeOrderedEntsOrNull, x as PromiseEdgeOrderedEntsWriter, t as PromiseEdgeOrderedEntsWriterOrNull, M as PromiseEdgeWriter, O as PromiseEdgeWriterOrNull, N as PromiseEdgeWriterOrThrow, A as PromiseEnt, _ as PromiseEntId, z as PromiseEntOrNull, Y as PromiseEntWriter, X as PromiseEntWriterOrNull, p as PromiseEnts, n as PromiseEntsOrNull, q as PromiseEntsOrNulls, S as PromiseEntsWriter, o as PromiseEntsWriterOrNull, j as PromiseOrderedQuery, i as PromiseOrderedQueryBase, P as PromiseOrderedQueryOrNull, Q as PromiseOrderedQueryWriter, d as PromiseOrderedQueryWriterOrNull, m as PromisePaginationResult, l as PromisePaginationResultOrNull, U as PromisePaginationResultWriter, T as PromisePaginationResultWriterOrNull, k as PromiseQuery, e as PromiseQueryOrNull, R as PromiseQueryWriter, f as PromiseQueryWriterOrNull, h as PromiseTable, g as PromiseTableBase, V as PromiseTableWriter, a2 as addEntRules, D as entWrapper, F as entsTableFactory, a5 as getDeletionConfig, a3 as getReadRule, a4 as getWriteRule } from './index-kwzjMMHy.js';
|
package/dist/functions.js
CHANGED
|
@@ -29,471 +29,8 @@ __export(functions_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(functions_exports);
|
|
31
31
|
|
|
32
|
-
// src/actions.ts
|
|
33
|
-
var import_server = require("convex/server");
|
|
34
|
-
|
|
35
|
-
// src/shared.ts
|
|
36
|
-
function getEdgeDefinitions(entDefinitions, table) {
|
|
37
|
-
return entDefinitions[table].edges;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// src/actions.ts
|
|
41
|
-
var PromiseQueryActionOrNullImpl = class _PromiseQueryActionOrNullImpl extends Promise {
|
|
42
|
-
constructor(ctx, entDefinitions, table, read) {
|
|
43
|
-
super(() => {
|
|
44
|
-
});
|
|
45
|
-
this.ctx = ctx;
|
|
46
|
-
this.entDefinitions = entDefinitions;
|
|
47
|
-
this.table = table;
|
|
48
|
-
this.read = read;
|
|
49
|
-
}
|
|
50
|
-
filter(predicate) {
|
|
51
|
-
return new _PromiseQueryActionOrNullImpl(
|
|
52
|
-
this.ctx,
|
|
53
|
-
this.entDefinitions,
|
|
54
|
-
this.table,
|
|
55
|
-
this.read.concat({ filter: serializeFilterPredicate(predicate) })
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
order(order, indexName) {
|
|
59
|
-
return new _PromiseQueryActionOrNullImpl(
|
|
60
|
-
this.ctx,
|
|
61
|
-
this.entDefinitions,
|
|
62
|
-
this.table,
|
|
63
|
-
this.read.concat({
|
|
64
|
-
order: [
|
|
65
|
-
order,
|
|
66
|
-
...indexName === void 0 ? [] : [indexName]
|
|
67
|
-
]
|
|
68
|
-
})
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
paginate(paginationOpts) {
|
|
72
|
-
return new PromisePaginationResultActionOrNullImpl(
|
|
73
|
-
this.ctx,
|
|
74
|
-
this.entDefinitions,
|
|
75
|
-
this.table,
|
|
76
|
-
this.read.concat({ paginate: paginationOpts })
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
async take(n) {
|
|
80
|
-
return await runRead(this.ctx, this.read.concat({ take: n }));
|
|
81
|
-
}
|
|
82
|
-
first() {
|
|
83
|
-
return new PromiseEntActionImpl(
|
|
84
|
-
this.ctx,
|
|
85
|
-
this.entDefinitions,
|
|
86
|
-
this.table,
|
|
87
|
-
this.read.concat({ first: true })
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
firstX() {
|
|
91
|
-
return new PromiseEntActionImpl(
|
|
92
|
-
this.ctx,
|
|
93
|
-
this.entDefinitions,
|
|
94
|
-
this.table,
|
|
95
|
-
this.read.concat({ firstX: true })
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
unique() {
|
|
99
|
-
return new PromiseEntActionImpl(
|
|
100
|
-
this.ctx,
|
|
101
|
-
this.entDefinitions,
|
|
102
|
-
this.table,
|
|
103
|
-
this.read.concat({ unique: true })
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
uniqueX() {
|
|
107
|
-
return new PromiseEntActionImpl(
|
|
108
|
-
this.ctx,
|
|
109
|
-
this.entDefinitions,
|
|
110
|
-
this.table,
|
|
111
|
-
this.read.concat({ uniqueX: true })
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
then(onfulfilled, onrejected) {
|
|
115
|
-
const docs = runRead(this.ctx, this.read);
|
|
116
|
-
return docs.then(onfulfilled, onrejected);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
var PromiseEdgeActionOrNullImpl = class extends PromiseQueryActionOrNullImpl {
|
|
120
|
-
async has(targetId) {
|
|
121
|
-
return runRead(this.ctx, this.read.concat({ has: targetId }));
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
var PromiseTableActionImpl = class extends PromiseQueryActionOrNullImpl {
|
|
125
|
-
constructor(ctx, entDefinitions, table) {
|
|
126
|
-
super(ctx, entDefinitions, table, [{ table: [table] }]);
|
|
127
|
-
}
|
|
128
|
-
get(...args) {
|
|
129
|
-
return new PromiseEntActionImpl(
|
|
130
|
-
this.ctx,
|
|
131
|
-
this.entDefinitions,
|
|
132
|
-
this.table,
|
|
133
|
-
this.read.concat({ get: args })
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
getX(...args) {
|
|
137
|
-
return new PromiseEntActionImpl(
|
|
138
|
-
this.ctx,
|
|
139
|
-
this.entDefinitions,
|
|
140
|
-
this.table,
|
|
141
|
-
this.read.concat({ getX: args })
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
async getMany(...args) {
|
|
145
|
-
return await runRead(this.ctx, this.read.concat({ getMany: args }));
|
|
146
|
-
}
|
|
147
|
-
async getManyX(...args) {
|
|
148
|
-
return await runRead(this.ctx, this.read.concat({ getManyX: args }));
|
|
149
|
-
}
|
|
150
|
-
async normalizeId(id) {
|
|
151
|
-
return await runRead(this.ctx, this.read.concat({ normalizeId: id }));
|
|
152
|
-
}
|
|
153
|
-
async normalizeIdX(id) {
|
|
154
|
-
return await runRead(this.ctx, this.read.concat({ normalizeIdX: id }));
|
|
155
|
-
}
|
|
156
|
-
withIndex(indexName, indexRange) {
|
|
157
|
-
return new PromiseQueryActionOrNullImpl(
|
|
158
|
-
this.ctx,
|
|
159
|
-
this.entDefinitions,
|
|
160
|
-
this.table,
|
|
161
|
-
[
|
|
162
|
-
{
|
|
163
|
-
table: [
|
|
164
|
-
this.table,
|
|
165
|
-
indexName,
|
|
166
|
-
serializeIndexRange(indexRange)
|
|
167
|
-
]
|
|
168
|
-
}
|
|
169
|
-
]
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
search(indexName, searchFilter) {
|
|
173
|
-
return new PromiseQueryActionOrNullImpl(
|
|
174
|
-
this.ctx,
|
|
175
|
-
this.entDefinitions,
|
|
176
|
-
this.table,
|
|
177
|
-
this.read.concat({
|
|
178
|
-
search: [indexName, serializeSearchFilter(searchFilter)]
|
|
179
|
-
})
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
insert(value) {
|
|
183
|
-
return new PromiseEntIdActionImpl(
|
|
184
|
-
this.ctx,
|
|
185
|
-
this.entDefinitions,
|
|
186
|
-
this.table,
|
|
187
|
-
this.read.concat({ insert: value })
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
// TODO: fluent API
|
|
191
|
-
async insertMany(values) {
|
|
192
|
-
return await runWrite(
|
|
193
|
-
this.ctx,
|
|
194
|
-
this.read.concat({ insertMany: values })
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
var PromisePaginationResultActionOrNullImpl = class extends Promise {
|
|
199
|
-
constructor(ctx, entDefinitions, table, read) {
|
|
200
|
-
super(() => {
|
|
201
|
-
});
|
|
202
|
-
this.ctx = ctx;
|
|
203
|
-
this.entDefinitions = entDefinitions;
|
|
204
|
-
this.table = table;
|
|
205
|
-
this.read = read;
|
|
206
|
-
}
|
|
207
|
-
then(onfulfilled, onrejected) {
|
|
208
|
-
return runRead(this.ctx, this.read).then(onfulfilled, onrejected);
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
var PromiseEntActionImpl = class _PromiseEntActionImpl extends Promise {
|
|
212
|
-
constructor(ctx, entDefinitions, table, read) {
|
|
213
|
-
super(() => {
|
|
214
|
-
});
|
|
215
|
-
this.ctx = ctx;
|
|
216
|
-
this.entDefinitions = entDefinitions;
|
|
217
|
-
this.table = table;
|
|
218
|
-
this.read = read;
|
|
219
|
-
}
|
|
220
|
-
then(onfulfilled, onrejected) {
|
|
221
|
-
return runRead(this.ctx, this.read).then(onfulfilled, onrejected);
|
|
222
|
-
}
|
|
223
|
-
edge(edge) {
|
|
224
|
-
return this.edgeImpl(edge);
|
|
225
|
-
}
|
|
226
|
-
edgeX(edge) {
|
|
227
|
-
return this.edgeImpl(edge, true);
|
|
228
|
-
}
|
|
229
|
-
edgeImpl(edge, throwIfNull = false) {
|
|
230
|
-
const edgeDefinition = getEdgeDefinitions(this.entDefinitions, this.table)[edge];
|
|
231
|
-
const read = throwIfNull ? { edgeX: edge } : { edge };
|
|
232
|
-
if (edgeDefinition.cardinality === "multiple") {
|
|
233
|
-
if (edgeDefinition.type === "ref") {
|
|
234
|
-
return new PromiseEdgeActionOrNullImpl(
|
|
235
|
-
this.ctx,
|
|
236
|
-
this.entDefinitions,
|
|
237
|
-
edgeDefinition.to,
|
|
238
|
-
this.read.concat(read)
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
return new PromiseQueryActionOrNullImpl(
|
|
242
|
-
this.ctx,
|
|
243
|
-
this.entDefinitions,
|
|
244
|
-
edgeDefinition.to,
|
|
245
|
-
this.read.concat(read)
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
return new _PromiseEntActionImpl(
|
|
249
|
-
this.ctx,
|
|
250
|
-
this.entDefinitions,
|
|
251
|
-
edgeDefinition.to,
|
|
252
|
-
this.read.concat(read)
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
patch(value) {
|
|
256
|
-
return new PromiseEntIdActionImpl(
|
|
257
|
-
this.ctx,
|
|
258
|
-
this.entDefinitions,
|
|
259
|
-
this.table,
|
|
260
|
-
this.read.concat({ patch: value })
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
replace(value) {
|
|
264
|
-
return new PromiseEntIdActionImpl(
|
|
265
|
-
this.ctx,
|
|
266
|
-
this.entDefinitions,
|
|
267
|
-
this.table,
|
|
268
|
-
this.read.concat({ replace: value })
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
async delete() {
|
|
272
|
-
return await runWrite(
|
|
273
|
-
this.ctx,
|
|
274
|
-
this.read.concat({ delete: true })
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
var PromiseEntIdActionImpl = class extends Promise {
|
|
279
|
-
constructor(ctx, entDefinitions, table, write) {
|
|
280
|
-
super(() => {
|
|
281
|
-
});
|
|
282
|
-
this.ctx = ctx;
|
|
283
|
-
this.entDefinitions = entDefinitions;
|
|
284
|
-
this.table = table;
|
|
285
|
-
this.write = write;
|
|
286
|
-
}
|
|
287
|
-
async get() {
|
|
288
|
-
return await runWrite(this.ctx, this.write.concat({ get: [] }));
|
|
289
|
-
}
|
|
290
|
-
then(onfulfilled, onrejected) {
|
|
291
|
-
return runWrite(this.ctx, this.write).then(onfulfilled, onrejected);
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
async function runRead(ctx, read) {
|
|
295
|
-
const readRef = ctx?.actionRead ?? (0, import_server.makeFunctionReference)("functions:read");
|
|
296
|
-
return await ctx.runQuery(readRef, { read });
|
|
297
|
-
}
|
|
298
|
-
async function runWrite(ctx, write) {
|
|
299
|
-
const writeRef = ctx?.actionRead ?? (0, import_server.makeFunctionReference)("functions:write");
|
|
300
|
-
return await ctx.runMutation(writeRef, { write });
|
|
301
|
-
}
|
|
302
|
-
var IndexRangeBuilderImpl = class _IndexRangeBuilderImpl {
|
|
303
|
-
constructor(rangeExpressions) {
|
|
304
|
-
this.rangeExpressions = rangeExpressions;
|
|
305
|
-
}
|
|
306
|
-
static new() {
|
|
307
|
-
return new _IndexRangeBuilderImpl([]);
|
|
308
|
-
}
|
|
309
|
-
eq(fieldName, value) {
|
|
310
|
-
return new _IndexRangeBuilderImpl(
|
|
311
|
-
this.rangeExpressions.concat({
|
|
312
|
-
type: "Eq",
|
|
313
|
-
fieldPath: fieldName,
|
|
314
|
-
value: value === void 0 ? "$undefined" : value
|
|
315
|
-
})
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
gt(fieldName, value) {
|
|
319
|
-
return new _IndexRangeBuilderImpl(
|
|
320
|
-
this.rangeExpressions.concat({
|
|
321
|
-
type: "Gt",
|
|
322
|
-
fieldPath: fieldName,
|
|
323
|
-
value
|
|
324
|
-
})
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
gte(fieldName, value) {
|
|
328
|
-
return new _IndexRangeBuilderImpl(
|
|
329
|
-
this.rangeExpressions.concat({
|
|
330
|
-
type: "Gte",
|
|
331
|
-
fieldPath: fieldName,
|
|
332
|
-
value
|
|
333
|
-
})
|
|
334
|
-
);
|
|
335
|
-
}
|
|
336
|
-
lt(fieldName, value) {
|
|
337
|
-
return new _IndexRangeBuilderImpl(
|
|
338
|
-
this.rangeExpressions.concat({
|
|
339
|
-
type: "Lt",
|
|
340
|
-
fieldPath: fieldName,
|
|
341
|
-
value
|
|
342
|
-
})
|
|
343
|
-
);
|
|
344
|
-
}
|
|
345
|
-
lte(fieldName, value) {
|
|
346
|
-
return new _IndexRangeBuilderImpl(
|
|
347
|
-
this.rangeExpressions.concat({
|
|
348
|
-
type: "Lte",
|
|
349
|
-
fieldPath: fieldName,
|
|
350
|
-
value
|
|
351
|
-
})
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
function serializeIndexRange(indexRange) {
|
|
356
|
-
if (indexRange === void 0) {
|
|
357
|
-
return void 0;
|
|
358
|
-
}
|
|
359
|
-
return (indexRange?.(
|
|
360
|
-
IndexRangeBuilderImpl.new()
|
|
361
|
-
)).rangeExpressions;
|
|
362
|
-
}
|
|
363
|
-
function serializeFilterPredicate(predicate) {
|
|
364
|
-
return serializeExpression(predicate(filterBuilderImpl));
|
|
365
|
-
}
|
|
366
|
-
var filterBuilderImpl = {
|
|
367
|
-
// Comparisons /////////////////////////////////////////////////////////////
|
|
368
|
-
eq(l, r) {
|
|
369
|
-
return new FilterExpression({
|
|
370
|
-
eq: [serializeExpression(l), serializeExpression(r)]
|
|
371
|
-
});
|
|
372
|
-
},
|
|
373
|
-
neq(l, r) {
|
|
374
|
-
return new FilterExpression({
|
|
375
|
-
neq: [serializeExpression(l), serializeExpression(r)]
|
|
376
|
-
});
|
|
377
|
-
},
|
|
378
|
-
lt(l, r) {
|
|
379
|
-
return new FilterExpression({
|
|
380
|
-
lt: [serializeExpression(l), serializeExpression(r)]
|
|
381
|
-
});
|
|
382
|
-
},
|
|
383
|
-
lte(l, r) {
|
|
384
|
-
return new FilterExpression({
|
|
385
|
-
lte: [serializeExpression(l), serializeExpression(r)]
|
|
386
|
-
});
|
|
387
|
-
},
|
|
388
|
-
gt(l, r) {
|
|
389
|
-
return new FilterExpression({
|
|
390
|
-
gt: [serializeExpression(l), serializeExpression(r)]
|
|
391
|
-
});
|
|
392
|
-
},
|
|
393
|
-
gte(l, r) {
|
|
394
|
-
return new FilterExpression({
|
|
395
|
-
gte: [serializeExpression(l), serializeExpression(r)]
|
|
396
|
-
});
|
|
397
|
-
},
|
|
398
|
-
// Arithmetic //////////////////////////////////////////////////////////////
|
|
399
|
-
add(l, r) {
|
|
400
|
-
return new FilterExpression({
|
|
401
|
-
add: [serializeExpression(l), serializeExpression(r)]
|
|
402
|
-
});
|
|
403
|
-
},
|
|
404
|
-
sub(l, r) {
|
|
405
|
-
return new FilterExpression({
|
|
406
|
-
sub: [serializeExpression(l), serializeExpression(r)]
|
|
407
|
-
});
|
|
408
|
-
},
|
|
409
|
-
mul(l, r) {
|
|
410
|
-
return new FilterExpression({
|
|
411
|
-
mul: [serializeExpression(l), serializeExpression(r)]
|
|
412
|
-
});
|
|
413
|
-
},
|
|
414
|
-
div(l, r) {
|
|
415
|
-
return new FilterExpression({
|
|
416
|
-
div: [serializeExpression(l), serializeExpression(r)]
|
|
417
|
-
});
|
|
418
|
-
},
|
|
419
|
-
mod(l, r) {
|
|
420
|
-
return new FilterExpression({
|
|
421
|
-
mod: [serializeExpression(l), serializeExpression(r)]
|
|
422
|
-
});
|
|
423
|
-
},
|
|
424
|
-
neg(x) {
|
|
425
|
-
return new FilterExpression({ neg: serializeExpression(x) });
|
|
426
|
-
},
|
|
427
|
-
// Logic ///////////////////////////////////////////////////////////////////
|
|
428
|
-
and(...exprs) {
|
|
429
|
-
return new FilterExpression({ and: exprs.map(serializeExpression) });
|
|
430
|
-
},
|
|
431
|
-
or(...exprs) {
|
|
432
|
-
return new FilterExpression({ or: exprs.map(serializeExpression) });
|
|
433
|
-
},
|
|
434
|
-
not(x) {
|
|
435
|
-
return new FilterExpression({ not: serializeExpression(x) });
|
|
436
|
-
},
|
|
437
|
-
// Other ///////////////////////////////////////////////////////////////////
|
|
438
|
-
field(fieldPath) {
|
|
439
|
-
return new FilterExpression({ field: fieldPath });
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
function serializeExpression(expr) {
|
|
443
|
-
if (expr instanceof FilterExpression) {
|
|
444
|
-
return expr.serialize();
|
|
445
|
-
} else {
|
|
446
|
-
return {
|
|
447
|
-
literal: expr === void 0 ? "$undefined" : expr
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
var FilterExpression = class {
|
|
452
|
-
inner;
|
|
453
|
-
constructor(inner) {
|
|
454
|
-
this.inner = inner;
|
|
455
|
-
}
|
|
456
|
-
serialize() {
|
|
457
|
-
return this.inner;
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
function serializeSearchFilter(searchFilter) {
|
|
461
|
-
return searchFilter(
|
|
462
|
-
SearchFilterBuilderImpl.new()
|
|
463
|
-
).export();
|
|
464
|
-
}
|
|
465
|
-
var SearchFilterBuilderImpl = class _SearchFilterBuilderImpl {
|
|
466
|
-
constructor(filters) {
|
|
467
|
-
this.filters = filters;
|
|
468
|
-
}
|
|
469
|
-
static new() {
|
|
470
|
-
return new _SearchFilterBuilderImpl([]);
|
|
471
|
-
}
|
|
472
|
-
search(fieldName, query) {
|
|
473
|
-
return new _SearchFilterBuilderImpl(
|
|
474
|
-
this.filters.concat({
|
|
475
|
-
type: "Search",
|
|
476
|
-
fieldPath: fieldName,
|
|
477
|
-
value: query
|
|
478
|
-
})
|
|
479
|
-
);
|
|
480
|
-
}
|
|
481
|
-
eq(fieldName, value) {
|
|
482
|
-
return new _SearchFilterBuilderImpl(
|
|
483
|
-
this.filters.concat({
|
|
484
|
-
type: "Eq",
|
|
485
|
-
fieldPath: fieldName,
|
|
486
|
-
value: value === void 0 ? "$undefiend" : value
|
|
487
|
-
})
|
|
488
|
-
);
|
|
489
|
-
}
|
|
490
|
-
export() {
|
|
491
|
-
return this.filters;
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
|
|
495
32
|
// src/schema.ts
|
|
496
|
-
var
|
|
33
|
+
var import_server = require("convex/server");
|
|
497
34
|
var import_values = require("convex/values");
|
|
498
35
|
function edgeCompoundIndexName(edgeDefinition) {
|
|
499
36
|
return edgeCompoundIndexNameRaw(edgeDefinition.field, edgeDefinition.ref);
|
|
@@ -502,8 +39,13 @@ function edgeCompoundIndexNameRaw(idA, idB) {
|
|
|
502
39
|
return `${idA}_${idB}`;
|
|
503
40
|
}
|
|
504
41
|
|
|
42
|
+
// src/shared.ts
|
|
43
|
+
function getEdgeDefinitions(entDefinitions, table) {
|
|
44
|
+
return entDefinitions[table].edges;
|
|
45
|
+
}
|
|
46
|
+
|
|
505
47
|
// src/writer.ts
|
|
506
|
-
var
|
|
48
|
+
var import_server2 = require("convex/server");
|
|
507
49
|
var WriterImplBase = class _WriterImplBase {
|
|
508
50
|
constructor(ctx, entDefinitions, table) {
|
|
509
51
|
this.ctx = ctx;
|
|
@@ -560,7 +102,7 @@ var WriterImplBase = class _WriterImplBase {
|
|
|
560
102
|
}
|
|
561
103
|
await this.writeEdges(id, edges, isDeletingSoftly);
|
|
562
104
|
if (deletionConfig !== void 0 && deletionConfig.type === "scheduled") {
|
|
563
|
-
const fnRef = this.ctx.scheduledDelete ?? (0,
|
|
105
|
+
const fnRef = this.ctx.scheduledDelete ?? (0, import_server2.makeFunctionReference)(
|
|
564
106
|
"functions:scheduledDelete"
|
|
565
107
|
);
|
|
566
108
|
await this.ctx.scheduler.runAfter(deletionConfig.delayMs ?? 0, fnRef, {
|
|
@@ -1646,36 +1188,21 @@ function entsTableFactory(ctx, entDefinitions, options) {
|
|
|
1646
1188
|
if (typeof table2 !== "string") {
|
|
1647
1189
|
throw new Error(`Expected table name, got \`${table2}\``);
|
|
1648
1190
|
}
|
|
1649
|
-
if (
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
return new
|
|
1191
|
+
if (indexName !== void 0) {
|
|
1192
|
+
return new PromiseTableImpl(
|
|
1193
|
+
enrichedCtx,
|
|
1194
|
+
entDefinitions,
|
|
1195
|
+
table2
|
|
1196
|
+
).withIndex(indexName, indexRange);
|
|
1197
|
+
}
|
|
1198
|
+
if (ctx.db.insert !== void 0) {
|
|
1199
|
+
return new PromiseTableWriterImpl(
|
|
1658
1200
|
enrichedCtx,
|
|
1659
1201
|
entDefinitions,
|
|
1660
1202
|
table2
|
|
1661
1203
|
);
|
|
1662
|
-
} else {
|
|
1663
|
-
if (indexName !== void 0) {
|
|
1664
|
-
return new PromiseTableImpl(
|
|
1665
|
-
enrichedCtx,
|
|
1666
|
-
entDefinitions,
|
|
1667
|
-
table2
|
|
1668
|
-
).withIndex(indexName, indexRange);
|
|
1669
|
-
}
|
|
1670
|
-
if (ctx.db.insert !== void 0) {
|
|
1671
|
-
return new PromiseTableWriterImpl(
|
|
1672
|
-
enrichedCtx,
|
|
1673
|
-
entDefinitions,
|
|
1674
|
-
table2
|
|
1675
|
-
);
|
|
1676
|
-
}
|
|
1677
|
-
return new PromiseTableImpl(enrichedCtx, entDefinitions, table2);
|
|
1678
1204
|
}
|
|
1205
|
+
return new PromiseTableImpl(enrichedCtx, entDefinitions, table2);
|
|
1679
1206
|
};
|
|
1680
1207
|
table.system = table;
|
|
1681
1208
|
return table;
|