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/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { EntDefinition, defineEnt, defineEntFromTable, defineEntSchema, defineEntsFromTables, getEntDefinitions } from './schema.js';
|
|
2
|
-
export {
|
|
2
|
+
export { L as GenericEnt, _ as GenericEntWriter, z as PromiseEdgeEnts, v as PromiseEdgeEntsOrNull, B as PromiseEdgeEntsWriter, 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, h as PromiseOrderedQuery, g as PromiseOrderedQueryBase, P as PromiseOrderedQueryOrNull, S as PromiseOrderedQueryWriter, b as PromiseOrderedQueryWriterOrNull, j as PromiseQuery, c as PromiseQueryOrNull, T as PromiseQueryWriter, d as PromiseQueryWriterOrNull, f as PromiseTable, e as PromiseTableBase, X as PromiseTableWriter, a3 as addEntRules, H as entsTableFactory } from './writer.js';
|
|
3
3
|
export { scheduledDeleteFactory } from './deletion.js';
|
|
4
4
|
import 'convex/server';
|
|
5
5
|
import 'convex/values';
|
package/dist/index.js
CHANGED
|
@@ -786,7 +786,7 @@ var PromiseQueryOrNullImpl = class _PromiseQueryOrNullImpl extends Promise {
|
|
|
786
786
|
);
|
|
787
787
|
}
|
|
788
788
|
map(callbackFn) {
|
|
789
|
-
return new
|
|
789
|
+
return new PromiseArrayOrNullImpl(async () => {
|
|
790
790
|
const array = await this;
|
|
791
791
|
if (array === null) {
|
|
792
792
|
return null;
|
|
@@ -947,6 +947,90 @@ var PromiseQueryOrNullImpl = class _PromiseQueryOrNullImpl extends Promise {
|
|
|
947
947
|
);
|
|
948
948
|
}
|
|
949
949
|
};
|
|
950
|
+
var PromiseIdsQueryOrNullImpl = class extends Promise {
|
|
951
|
+
constructor(retrieve, field) {
|
|
952
|
+
super(() => {
|
|
953
|
+
});
|
|
954
|
+
this.retrieve = retrieve;
|
|
955
|
+
this.field = field;
|
|
956
|
+
}
|
|
957
|
+
map(callbackFn) {
|
|
958
|
+
return new PromiseArrayOrNullImpl(async () => {
|
|
959
|
+
const array = await this;
|
|
960
|
+
if (array === null) {
|
|
961
|
+
return null;
|
|
962
|
+
}
|
|
963
|
+
return await Promise.all(array.map(callbackFn));
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
paginate(paginationOpts) {
|
|
967
|
+
return new PromiseIdsPaginationResultOrNullImpl(async () => {
|
|
968
|
+
const query = await this.retrieve();
|
|
969
|
+
if (query === null) {
|
|
970
|
+
return null;
|
|
971
|
+
}
|
|
972
|
+
const result = await query.paginate(paginationOpts);
|
|
973
|
+
return {
|
|
974
|
+
...result,
|
|
975
|
+
page: result.page.map((id) => this._getId(id))
|
|
976
|
+
};
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
take(n) {
|
|
980
|
+
return new PromiseIdsOrNullImpl(async () => {
|
|
981
|
+
const query = await this.retrieve();
|
|
982
|
+
if (query === null) {
|
|
983
|
+
return null;
|
|
984
|
+
}
|
|
985
|
+
const result = await query.take(n);
|
|
986
|
+
return result.map((id) => this._getId(id));
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
async first() {
|
|
990
|
+
const query = await this.retrieve();
|
|
991
|
+
if (query === null) {
|
|
992
|
+
return null;
|
|
993
|
+
}
|
|
994
|
+
const doc = await query.first();
|
|
995
|
+
if (doc === null) {
|
|
996
|
+
return null;
|
|
997
|
+
}
|
|
998
|
+
return this._getId(doc);
|
|
999
|
+
}
|
|
1000
|
+
async firstX() {
|
|
1001
|
+
const id = await this.first();
|
|
1002
|
+
if (id === null) {
|
|
1003
|
+
throw new Error("Expected at least one ID, but got none");
|
|
1004
|
+
}
|
|
1005
|
+
return id;
|
|
1006
|
+
}
|
|
1007
|
+
async unique() {
|
|
1008
|
+
const query = await this.retrieve();
|
|
1009
|
+
if (query === null) {
|
|
1010
|
+
return null;
|
|
1011
|
+
}
|
|
1012
|
+
const result = await query.unique();
|
|
1013
|
+
if (result === null) {
|
|
1014
|
+
return null;
|
|
1015
|
+
}
|
|
1016
|
+
return this._getId(result);
|
|
1017
|
+
}
|
|
1018
|
+
async uniqueX() {
|
|
1019
|
+
const id = await this.unique();
|
|
1020
|
+
if (id === null) {
|
|
1021
|
+
throw new Error("Expected one unique ID, but got none");
|
|
1022
|
+
}
|
|
1023
|
+
return id;
|
|
1024
|
+
}
|
|
1025
|
+
then(onfulfilled, onrejected) {
|
|
1026
|
+
return this.retrieve().then((query) => query === null ? null : query.collect()).then(
|
|
1027
|
+
(docs) => docs === null ? null : docs.map((doc) => this._getId(doc))
|
|
1028
|
+
).then(onfulfilled, onrejected);
|
|
1029
|
+
}
|
|
1030
|
+
_getId(doc) {
|
|
1031
|
+
return doc[this.field];
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
950
1034
|
var PromisePaginationResultOrNullImpl = class extends Promise {
|
|
951
1035
|
constructor(ctx, entDefinitions, table, retrieve) {
|
|
952
1036
|
super(() => {
|
|
@@ -993,6 +1077,26 @@ var PromisePaginationResultOrNullImpl = class extends Promise {
|
|
|
993
1077
|
).then(onfulfilled, onrejected);
|
|
994
1078
|
}
|
|
995
1079
|
};
|
|
1080
|
+
var PromiseIdsPaginationResultOrNullImpl = class extends Promise {
|
|
1081
|
+
constructor(retrieve) {
|
|
1082
|
+
super(() => {
|
|
1083
|
+
});
|
|
1084
|
+
this.retrieve = retrieve;
|
|
1085
|
+
}
|
|
1086
|
+
async map(callbackFn) {
|
|
1087
|
+
const result = await this;
|
|
1088
|
+
if (result === null) {
|
|
1089
|
+
return null;
|
|
1090
|
+
}
|
|
1091
|
+
return {
|
|
1092
|
+
...result,
|
|
1093
|
+
page: await Promise.all(result.page.map(callbackFn))
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
then(onfulfilled, onrejected) {
|
|
1097
|
+
return this.retrieve().then(onfulfilled, onrejected);
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
996
1100
|
var PromiseTableImpl = class extends PromiseQueryOrNullImpl {
|
|
997
1101
|
constructor(ctx, entDefinitions, table) {
|
|
998
1102
|
super(
|
|
@@ -1158,7 +1262,7 @@ var PromiseEntsOrNullImpl = class extends Promise {
|
|
|
1158
1262
|
this.throwIfNull = throwIfNull;
|
|
1159
1263
|
}
|
|
1160
1264
|
map(callbackFn) {
|
|
1161
|
-
return new
|
|
1265
|
+
return new PromiseArrayOrNullImpl(async () => {
|
|
1162
1266
|
const array = await this;
|
|
1163
1267
|
if (array === null) {
|
|
1164
1268
|
return null;
|
|
@@ -1260,6 +1364,25 @@ var PromiseEntsOrNullImpl = class extends Promise {
|
|
|
1260
1364
|
).then(onfulfilled, onrejected);
|
|
1261
1365
|
}
|
|
1262
1366
|
};
|
|
1367
|
+
var PromiseIdsOrNullImpl = class extends Promise {
|
|
1368
|
+
constructor(retrieve) {
|
|
1369
|
+
super(() => {
|
|
1370
|
+
});
|
|
1371
|
+
this.retrieve = retrieve;
|
|
1372
|
+
}
|
|
1373
|
+
map(callbackFn) {
|
|
1374
|
+
return new PromiseArrayOrNullImpl(async () => {
|
|
1375
|
+
const array = await this;
|
|
1376
|
+
if (array === null) {
|
|
1377
|
+
return null;
|
|
1378
|
+
}
|
|
1379
|
+
return await Promise.all(array.map(callbackFn));
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
then(onfulfilled, onrejected) {
|
|
1383
|
+
return this.retrieve().then(onfulfilled, onrejected);
|
|
1384
|
+
}
|
|
1385
|
+
};
|
|
1263
1386
|
var PromiseEdgeOrNullImpl = class _PromiseEdgeOrNullImpl extends PromiseEntsOrNullImpl {
|
|
1264
1387
|
constructor(ctx, entDefinitions, table, edgeDefinition, retrieveSourceId, retrieveQuery, retrieveDoc = async (edgeDoc) => {
|
|
1265
1388
|
const sourceId = edgeDoc[edgeDefinition.field];
|
|
@@ -1295,6 +1418,12 @@ var PromiseEdgeOrNullImpl = class _PromiseEdgeOrNullImpl extends PromiseEntsOrNu
|
|
|
1295
1418
|
this.retrieveQuery = retrieveQuery;
|
|
1296
1419
|
this.retrieveDoc = retrieveDoc;
|
|
1297
1420
|
}
|
|
1421
|
+
ids() {
|
|
1422
|
+
return new PromiseIdsQueryOrNullImpl(
|
|
1423
|
+
() => this.retrieveQuery(),
|
|
1424
|
+
this.edgeDefinition.ref
|
|
1425
|
+
);
|
|
1426
|
+
}
|
|
1298
1427
|
async has(targetId) {
|
|
1299
1428
|
const sourceId = await this.retrieveSourceId();
|
|
1300
1429
|
if (sourceId === null) {
|
|
@@ -1582,7 +1711,7 @@ var PromiseEntOrNullImpl = class extends Promise {
|
|
|
1582
1711
|
);
|
|
1583
1712
|
}
|
|
1584
1713
|
};
|
|
1585
|
-
var
|
|
1714
|
+
var PromiseArrayOrNullImpl = class extends Promise {
|
|
1586
1715
|
constructor(retrieve) {
|
|
1587
1716
|
super(() => {
|
|
1588
1717
|
});
|