convex-ents 0.19.0 → 0.20.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/functions.d.ts +1 -1
- package/dist/functions.js +132 -3
- package/dist/functions.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +132 -3
- package/dist/index.js.map +1 -1
- package/dist/shared.d.ts +1 -1
- package/dist/writer.d.ts +101 -1
- package/dist/writer.js +132 -3
- package/dist/writer.js.map +1 -1
- package/package.json +1 -1
package/dist/functions.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import 'convex/values';
|
|
|
3
3
|
import './deletion.js';
|
|
4
4
|
import './schema.js';
|
|
5
5
|
import './shared.js';
|
|
6
|
-
export {
|
|
6
|
+
export { a2 as DocRetriever, K as Ent, a1 as EntMutationCtx, a0 as EntQueryCtx, I as EntsTable, J as EntsTableWriter, L as GenericEnt, _ as GenericEntWriter, F as PromiseArray, E as PromiseArrayOrNull, M as PromiseEdge, z as PromiseEdgeEnts, v as PromiseEdgeEntsOrNull, B as PromiseEdgeEntsWriter, x as PromiseEdgeEntsWriterOrNull, N as PromiseEdgeOrThrow, y as PromiseEdgeOrderedEnts, u as PromiseEdgeOrderedEntsOrNull, A as PromiseEdgeOrderedEntsWriter, w as PromiseEdgeOrderedEntsWriterOrNull, O as PromiseEdgeWriter, R as PromiseEdgeWriterOrNull, Q as PromiseEdgeWriterOrThrow, D as PromiseEnt, $ as PromiseEntId, C as PromiseEntOrNull, Z as PromiseEntWriter, Y as PromiseEntWriterOrNull, q as PromiseEnts, o as PromiseEntsOrNull, r as PromiseEntsOrNulls, U as PromiseEntsWriter, p as PromiseEntsWriterOrNull, t as PromiseIds, s as PromiseIdsOrNull, n as PromiseIdsPaginationResult, m as PromiseIdsPaginationResultOrNull, i as PromiseOrderedIdsQuery, a as PromiseOrderedIdsQueryOrNull, h as PromiseOrderedQuery, g as PromiseOrderedQueryBase, P as PromiseOrderedQueryOrNull, S as PromiseOrderedQueryWriter, b as PromiseOrderedQueryWriterOrNull, l as PromisePaginationResult, k as PromisePaginationResultOrNull, W as PromisePaginationResultWriter, V as PromisePaginationResultWriterOrNull, j as PromiseQuery, c as PromiseQueryOrNull, T as PromiseQueryWriter, d as PromiseQueryWriterOrNull, f as PromiseTable, e as PromiseTableBase, X as PromiseTableWriter, a3 as addEntRules, G as entWrapper, H as entsTableFactory, a6 as getDeletionConfig, a4 as getReadRule, a5 as getWriteRule } from './writer.js';
|
package/dist/functions.js
CHANGED
|
@@ -366,7 +366,7 @@ var PromiseQueryOrNullImpl = class _PromiseQueryOrNullImpl extends Promise {
|
|
|
366
366
|
);
|
|
367
367
|
}
|
|
368
368
|
map(callbackFn) {
|
|
369
|
-
return new
|
|
369
|
+
return new PromiseArrayOrNullImpl(async () => {
|
|
370
370
|
const array = await this;
|
|
371
371
|
if (array === null) {
|
|
372
372
|
return null;
|
|
@@ -527,6 +527,90 @@ var PromiseQueryOrNullImpl = class _PromiseQueryOrNullImpl extends Promise {
|
|
|
527
527
|
);
|
|
528
528
|
}
|
|
529
529
|
};
|
|
530
|
+
var PromiseIdsQueryOrNullImpl = class extends Promise {
|
|
531
|
+
constructor(retrieve, field) {
|
|
532
|
+
super(() => {
|
|
533
|
+
});
|
|
534
|
+
this.retrieve = retrieve;
|
|
535
|
+
this.field = field;
|
|
536
|
+
}
|
|
537
|
+
map(callbackFn) {
|
|
538
|
+
return new PromiseArrayOrNullImpl(async () => {
|
|
539
|
+
const array = await this;
|
|
540
|
+
if (array === null) {
|
|
541
|
+
return null;
|
|
542
|
+
}
|
|
543
|
+
return await Promise.all(array.map(callbackFn));
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
paginate(paginationOpts) {
|
|
547
|
+
return new PromiseIdsPaginationResultOrNullImpl(async () => {
|
|
548
|
+
const query = await this.retrieve();
|
|
549
|
+
if (query === null) {
|
|
550
|
+
return null;
|
|
551
|
+
}
|
|
552
|
+
const result = await query.paginate(paginationOpts);
|
|
553
|
+
return {
|
|
554
|
+
...result,
|
|
555
|
+
page: result.page.map((id) => this._getId(id))
|
|
556
|
+
};
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
take(n) {
|
|
560
|
+
return new PromiseIdsOrNullImpl(async () => {
|
|
561
|
+
const query = await this.retrieve();
|
|
562
|
+
if (query === null) {
|
|
563
|
+
return null;
|
|
564
|
+
}
|
|
565
|
+
const result = await query.take(n);
|
|
566
|
+
return result.map((id) => this._getId(id));
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
async first() {
|
|
570
|
+
const query = await this.retrieve();
|
|
571
|
+
if (query === null) {
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
574
|
+
const doc = await query.first();
|
|
575
|
+
if (doc === null) {
|
|
576
|
+
return null;
|
|
577
|
+
}
|
|
578
|
+
return this._getId(doc);
|
|
579
|
+
}
|
|
580
|
+
async firstX() {
|
|
581
|
+
const id = await this.first();
|
|
582
|
+
if (id === null) {
|
|
583
|
+
throw new Error("Expected at least one ID, but got none");
|
|
584
|
+
}
|
|
585
|
+
return id;
|
|
586
|
+
}
|
|
587
|
+
async unique() {
|
|
588
|
+
const query = await this.retrieve();
|
|
589
|
+
if (query === null) {
|
|
590
|
+
return null;
|
|
591
|
+
}
|
|
592
|
+
const result = await query.unique();
|
|
593
|
+
if (result === null) {
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
return this._getId(result);
|
|
597
|
+
}
|
|
598
|
+
async uniqueX() {
|
|
599
|
+
const id = await this.unique();
|
|
600
|
+
if (id === null) {
|
|
601
|
+
throw new Error("Expected one unique ID, but got none");
|
|
602
|
+
}
|
|
603
|
+
return id;
|
|
604
|
+
}
|
|
605
|
+
then(onfulfilled, onrejected) {
|
|
606
|
+
return this.retrieve().then((query) => query === null ? null : query.collect()).then(
|
|
607
|
+
(docs) => docs === null ? null : docs.map((doc) => this._getId(doc))
|
|
608
|
+
).then(onfulfilled, onrejected);
|
|
609
|
+
}
|
|
610
|
+
_getId(doc) {
|
|
611
|
+
return doc[this.field];
|
|
612
|
+
}
|
|
613
|
+
};
|
|
530
614
|
var PromisePaginationResultOrNullImpl = class extends Promise {
|
|
531
615
|
constructor(ctx, entDefinitions, table, retrieve) {
|
|
532
616
|
super(() => {
|
|
@@ -573,6 +657,26 @@ var PromisePaginationResultOrNullImpl = class extends Promise {
|
|
|
573
657
|
).then(onfulfilled, onrejected);
|
|
574
658
|
}
|
|
575
659
|
};
|
|
660
|
+
var PromiseIdsPaginationResultOrNullImpl = class extends Promise {
|
|
661
|
+
constructor(retrieve) {
|
|
662
|
+
super(() => {
|
|
663
|
+
});
|
|
664
|
+
this.retrieve = retrieve;
|
|
665
|
+
}
|
|
666
|
+
async map(callbackFn) {
|
|
667
|
+
const result = await this;
|
|
668
|
+
if (result === null) {
|
|
669
|
+
return null;
|
|
670
|
+
}
|
|
671
|
+
return {
|
|
672
|
+
...result,
|
|
673
|
+
page: await Promise.all(result.page.map(callbackFn))
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
then(onfulfilled, onrejected) {
|
|
677
|
+
return this.retrieve().then(onfulfilled, onrejected);
|
|
678
|
+
}
|
|
679
|
+
};
|
|
576
680
|
var PromiseTableImpl = class extends PromiseQueryOrNullImpl {
|
|
577
681
|
constructor(ctx, entDefinitions, table) {
|
|
578
682
|
super(
|
|
@@ -738,7 +842,7 @@ var PromiseEntsOrNullImpl = class extends Promise {
|
|
|
738
842
|
this.throwIfNull = throwIfNull;
|
|
739
843
|
}
|
|
740
844
|
map(callbackFn) {
|
|
741
|
-
return new
|
|
845
|
+
return new PromiseArrayOrNullImpl(async () => {
|
|
742
846
|
const array = await this;
|
|
743
847
|
if (array === null) {
|
|
744
848
|
return null;
|
|
@@ -840,6 +944,25 @@ var PromiseEntsOrNullImpl = class extends Promise {
|
|
|
840
944
|
).then(onfulfilled, onrejected);
|
|
841
945
|
}
|
|
842
946
|
};
|
|
947
|
+
var PromiseIdsOrNullImpl = class extends Promise {
|
|
948
|
+
constructor(retrieve) {
|
|
949
|
+
super(() => {
|
|
950
|
+
});
|
|
951
|
+
this.retrieve = retrieve;
|
|
952
|
+
}
|
|
953
|
+
map(callbackFn) {
|
|
954
|
+
return new PromiseArrayOrNullImpl(async () => {
|
|
955
|
+
const array = await this;
|
|
956
|
+
if (array === null) {
|
|
957
|
+
return null;
|
|
958
|
+
}
|
|
959
|
+
return await Promise.all(array.map(callbackFn));
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
then(onfulfilled, onrejected) {
|
|
963
|
+
return this.retrieve().then(onfulfilled, onrejected);
|
|
964
|
+
}
|
|
965
|
+
};
|
|
843
966
|
var PromiseEdgeOrNullImpl = class _PromiseEdgeOrNullImpl extends PromiseEntsOrNullImpl {
|
|
844
967
|
constructor(ctx, entDefinitions, table, edgeDefinition, retrieveSourceId, retrieveQuery, retrieveDoc = async (edgeDoc) => {
|
|
845
968
|
const sourceId = edgeDoc[edgeDefinition.field];
|
|
@@ -875,6 +998,12 @@ var PromiseEdgeOrNullImpl = class _PromiseEdgeOrNullImpl extends PromiseEntsOrNu
|
|
|
875
998
|
this.retrieveQuery = retrieveQuery;
|
|
876
999
|
this.retrieveDoc = retrieveDoc;
|
|
877
1000
|
}
|
|
1001
|
+
ids() {
|
|
1002
|
+
return new PromiseIdsQueryOrNullImpl(
|
|
1003
|
+
() => this.retrieveQuery(),
|
|
1004
|
+
this.edgeDefinition.ref
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
878
1007
|
async has(targetId) {
|
|
879
1008
|
const sourceId = await this.retrieveSourceId();
|
|
880
1009
|
if (sourceId === null) {
|
|
@@ -1162,7 +1291,7 @@ var PromiseEntOrNullImpl = class extends Promise {
|
|
|
1162
1291
|
);
|
|
1163
1292
|
}
|
|
1164
1293
|
};
|
|
1165
|
-
var
|
|
1294
|
+
var PromiseArrayOrNullImpl = class extends Promise {
|
|
1166
1295
|
constructor(retrieve) {
|
|
1167
1296
|
super(() => {
|
|
1168
1297
|
});
|