@peerbit/document 14.0.1 → 15.0.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/dist/src/program.d.ts +0 -1
- package/dist/src/program.d.ts.map +1 -1
- package/dist/src/program.js +8 -41
- package/dist/src/program.js.map +1 -1
- package/dist/src/search.d.ts +0 -2
- package/dist/src/search.d.ts.map +1 -1
- package/dist/src/search.js +6 -47
- package/dist/src/search.js.map +1 -1
- package/package.json +8 -8
- package/src/program.ts +8 -40
- package/src/search.ts +5 -64
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peerbit/document",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.1",
|
|
4
4
|
"description": "Document store implementation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -65,16 +65,16 @@
|
|
|
65
65
|
"@peerbit/document-interface": "3.2.60",
|
|
66
66
|
"@peerbit/indexer-cache": "0.2.12",
|
|
67
67
|
"@peerbit/indexer-interface": "3.0.9",
|
|
68
|
-
"@peerbit/indexer-simple": "1.2.13",
|
|
69
68
|
"@peerbit/indexer-sqlite3": "3.0.14",
|
|
70
|
-
"@peerbit/log": "6.2.17",
|
|
71
69
|
"@peerbit/logger": "2.0.1",
|
|
70
|
+
"@peerbit/log": "6.2.17",
|
|
72
71
|
"@peerbit/pubsub": "5.4.1",
|
|
73
72
|
"@peerbit/program": "6.0.49",
|
|
74
73
|
"@peerbit/rpc": "6.1.17",
|
|
75
|
-
"@peerbit/shared-log": "
|
|
76
|
-
"@peerbit/
|
|
77
|
-
"@peerbit/time": "3.0.1"
|
|
74
|
+
"@peerbit/shared-log": "16.0.1",
|
|
75
|
+
"@peerbit/indexer-simple": "1.2.13",
|
|
76
|
+
"@peerbit/time": "3.0.1",
|
|
77
|
+
"@peerbit/stream-interface": "6.0.15"
|
|
78
78
|
},
|
|
79
79
|
"optionalDependencies": {
|
|
80
80
|
"@peerbit/document-rust": "0.1.1"
|
|
@@ -85,10 +85,10 @@
|
|
|
85
85
|
"@types/pidusage": "^2.0.5",
|
|
86
86
|
"pidusage": "^4.0.1",
|
|
87
87
|
"uuid": "^11.1.1",
|
|
88
|
-
"@peerbit/log-rust": "1.1.3",
|
|
89
88
|
"@peerbit/native-backbone": "0.2.5",
|
|
89
|
+
"@peerbit/test-utils": "3.1.23",
|
|
90
90
|
"peerbit": "5.3.23",
|
|
91
|
-
"@peerbit/
|
|
91
|
+
"@peerbit/log-rust": "1.1.3"
|
|
92
92
|
},
|
|
93
93
|
"repository": {
|
|
94
94
|
"type": "git",
|
package/src/program.ts
CHANGED
|
@@ -1098,8 +1098,6 @@ export class Documents<
|
|
|
1098
1098
|
private strictHistory: boolean;
|
|
1099
1099
|
canOpen?: (program: T) => Promise<boolean> | boolean;
|
|
1100
1100
|
|
|
1101
|
-
compatibility: 6 | 7 | undefined;
|
|
1102
|
-
|
|
1103
1101
|
constructor(properties?: {
|
|
1104
1102
|
id?: Uint8Array;
|
|
1105
1103
|
immutable?: boolean;
|
|
@@ -1242,9 +1240,6 @@ export class Documents<
|
|
|
1242
1240
|
if (options.domain) {
|
|
1243
1241
|
unsupported.push("custom domain");
|
|
1244
1242
|
}
|
|
1245
|
-
if ((options as any).compatibility != null) {
|
|
1246
|
-
unsupported.push("legacy compatibility");
|
|
1247
|
-
}
|
|
1248
1243
|
if (options.strictHistory) {
|
|
1249
1244
|
unsupported.push("strict history");
|
|
1250
1245
|
}
|
|
@@ -1474,9 +1469,6 @@ export class Documents<
|
|
|
1474
1469
|
if (this.strictHistory) {
|
|
1475
1470
|
unsupported.push("strict history");
|
|
1476
1471
|
}
|
|
1477
|
-
if (this.compatibility === 6) {
|
|
1478
|
-
unsupported.push("legacy compatibility");
|
|
1479
|
-
}
|
|
1480
1472
|
if (Program.isPrototypeOf(this._clazz)) {
|
|
1481
1473
|
unsupported.push("program-valued document type");
|
|
1482
1474
|
}
|
|
@@ -1823,9 +1815,6 @@ export class Documents<
|
|
|
1823
1815
|
if (this.strictHistory) {
|
|
1824
1816
|
unsupported.push("strict history");
|
|
1825
1817
|
}
|
|
1826
|
-
if (this.compatibility === 6) {
|
|
1827
|
-
unsupported.push("legacy compatibility");
|
|
1828
|
-
}
|
|
1829
1818
|
if (Program.isPrototypeOf(this._clazz)) {
|
|
1830
1819
|
unsupported.push("program-valued document type");
|
|
1831
1820
|
}
|
|
@@ -1851,9 +1840,6 @@ export class Documents<
|
|
|
1851
1840
|
if (this.strictHistory) {
|
|
1852
1841
|
unsupported.push("strict history");
|
|
1853
1842
|
}
|
|
1854
|
-
if (this.compatibility === 6) {
|
|
1855
|
-
unsupported.push("legacy compatibility");
|
|
1856
|
-
}
|
|
1857
1843
|
if (Program.isPrototypeOf(this._clazz)) {
|
|
1858
1844
|
unsupported.push("program-valued document type");
|
|
1859
1845
|
}
|
|
@@ -2300,9 +2286,6 @@ export class Documents<
|
|
|
2300
2286
|
indexerTypes.extractFieldValue(obj, idProperty as string[]));
|
|
2301
2287
|
|
|
2302
2288
|
this.idResolver = idResolver;
|
|
2303
|
-
// B12: permanently undefined (the option rejects above); the field and
|
|
2304
|
-
// its residual gates die in a later cleanup stage.
|
|
2305
|
-
this.compatibility = (options as any).compatibility;
|
|
2306
2289
|
this.strictHistory = options.strictHistory ?? false;
|
|
2307
2290
|
this._hasLogTrim = options.log?.trim != null;
|
|
2308
2291
|
|
|
@@ -2315,7 +2298,6 @@ export class Documents<
|
|
|
2315
2298
|
documentType: this._clazz,
|
|
2316
2299
|
transform: options.index,
|
|
2317
2300
|
indexBy: idProperty,
|
|
2318
|
-
compatibility: (options as any).compatibility,
|
|
2319
2301
|
cache: options?.index?.cache,
|
|
2320
2302
|
replicate: async (query, results) => {
|
|
2321
2303
|
// here we arrive for all the results we want to persist.
|
|
@@ -3009,24 +2991,14 @@ export class Documents<
|
|
|
3009
2991
|
}
|
|
3010
2992
|
|
|
3011
2993
|
const key = indexerTypes.toId(keyValue);
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
} else {
|
|
3021
|
-
throw new Error("Key must be a string in compatibility mode v6");
|
|
3022
|
-
}
|
|
3023
|
-
} else {
|
|
3024
|
-
encodedOperation = encodePutOperationPayload(encodedDocument);
|
|
3025
|
-
encodedDocument = encodedOperation.subarray(PUT_OPERATION_PREFIX_LENGTH);
|
|
3026
|
-
operation = new PutOperation({
|
|
3027
|
-
data: encodedDocument,
|
|
3028
|
-
});
|
|
3029
|
-
}
|
|
2994
|
+
// B12: writes always encode PutOperation. The compatibility-6
|
|
2995
|
+
// PutWithKeyOperation ENCODE branch is retired; the tag-0 DECODE stays
|
|
2996
|
+
// forever (see operation-tombstone pins).
|
|
2997
|
+
const encodedOperation = encodePutOperationPayload(encodedDocument);
|
|
2998
|
+
encodedDocument = encodedOperation.subarray(PUT_OPERATION_PREFIX_LENGTH);
|
|
2999
|
+
const operation = new PutOperation({
|
|
3000
|
+
data: encodedDocument,
|
|
3001
|
+
});
|
|
3030
3002
|
return {
|
|
3031
3003
|
document: doc,
|
|
3032
3004
|
encodedDocument,
|
|
@@ -3038,9 +3010,6 @@ export class Documents<
|
|
|
3038
3010
|
}
|
|
3039
3011
|
|
|
3040
3012
|
private preparePlainPut(doc: T): PreparedPlainPut<T> {
|
|
3041
|
-
if (this.compatibility === 6) {
|
|
3042
|
-
throw new Error("Plain put preparation is not supported in v6 mode");
|
|
3043
|
-
}
|
|
3044
3013
|
const keyValue = this.idResolver(doc);
|
|
3045
3014
|
indexerTypes.checkId(keyValue);
|
|
3046
3015
|
const documentBytes = serialize(doc);
|
|
@@ -3230,7 +3199,6 @@ export class Documents<
|
|
|
3230
3199
|
this.canPerformAllowsPlainPutFastPath(doc) &&
|
|
3231
3200
|
!this.immutable &&
|
|
3232
3201
|
!this.strictHistory &&
|
|
3233
|
-
this.compatibility !== 6 &&
|
|
3234
3202
|
!Program.isPrototypeOf(this._clazz) &&
|
|
3235
3203
|
!options?.canAppend &&
|
|
3236
3204
|
!options?.onChange &&
|
package/src/search.ts
CHANGED
|
@@ -538,7 +538,6 @@ const coerceQuery = <Resolve extends boolean | undefined>(
|
|
|
538
538
|
| types.IterationRequest
|
|
539
539
|
| QueryLike,
|
|
540
540
|
options?: QueryOptions<any, any, any, Resolve>,
|
|
541
|
-
compatibility?: number,
|
|
542
541
|
):
|
|
543
542
|
| types.SearchRequest
|
|
544
543
|
| types.SearchRequestIndexed
|
|
@@ -546,7 +545,6 @@ const coerceQuery = <Resolve extends boolean | undefined>(
|
|
|
546
545
|
const replicate =
|
|
547
546
|
typeof options?.remote !== "boolean" ? options?.remote?.replicate : false;
|
|
548
547
|
const shouldResolve = options?.resolve !== false;
|
|
549
|
-
const useLegacyRequests = compatibility != null && compatibility <= 9;
|
|
550
548
|
|
|
551
549
|
if (
|
|
552
550
|
query instanceof types.SearchRequestIndexed &&
|
|
@@ -565,40 +563,11 @@ const coerceQuery = <Resolve extends boolean | undefined>(
|
|
|
565
563
|
}
|
|
566
564
|
|
|
567
565
|
if (query instanceof types.IterationRequest) {
|
|
568
|
-
if (useLegacyRequests) {
|
|
569
|
-
if (query.resolve === false) {
|
|
570
|
-
return new types.SearchRequestIndexed({
|
|
571
|
-
query: query.query,
|
|
572
|
-
sort: query.sort,
|
|
573
|
-
fetch: query.fetch,
|
|
574
|
-
replicate: query.replicate ?? replicate,
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
return new types.SearchRequest({
|
|
578
|
-
query: query.query,
|
|
579
|
-
sort: query.sort,
|
|
580
|
-
fetch: query.fetch,
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
566
|
return query;
|
|
584
567
|
}
|
|
585
568
|
|
|
586
569
|
const queryObject = query as QueryLike;
|
|
587
570
|
|
|
588
|
-
if (useLegacyRequests) {
|
|
589
|
-
if (shouldResolve) {
|
|
590
|
-
return new types.SearchRequest({
|
|
591
|
-
query: indexerTypes.toQuery(queryObject.query),
|
|
592
|
-
sort: indexerTypes.toSort(queryObject.sort),
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
return new types.SearchRequestIndexed({
|
|
596
|
-
query: indexerTypes.toQuery(queryObject.query),
|
|
597
|
-
sort: indexerTypes.toSort(queryObject.sort),
|
|
598
|
-
replicate,
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
|
|
602
571
|
return new types.IterationRequest({
|
|
603
572
|
query: indexerTypes.toQuery(queryObject.query),
|
|
604
573
|
sort: indexerTypes.toSort(queryObject.sort),
|
|
@@ -859,7 +828,6 @@ export type OpenOptions<
|
|
|
859
828
|
resolver?: number;
|
|
860
829
|
query?: QueryCacheOptions;
|
|
861
830
|
};
|
|
862
|
-
compatibility: 6 | 7 | 8 | 9 | undefined;
|
|
863
831
|
maybeOpen: (value: T & Program) => Promise<T & Program>;
|
|
864
832
|
prefetch?: boolean | Partial<PrefetchOptions>;
|
|
865
833
|
includeIndexed?: boolean; // if true, indexed representations will always be included in the search results
|
|
@@ -1100,8 +1068,6 @@ export class DocumentIndex<
|
|
|
1100
1068
|
private includeIndexed: boolean | undefined = undefined;
|
|
1101
1069
|
private immutable: boolean = false;
|
|
1102
1070
|
|
|
1103
|
-
compatibility: 6 | 7 | 8 | 9 | undefined;
|
|
1104
|
-
|
|
1105
1071
|
// Transformation, indexer
|
|
1106
1072
|
/* fields: IndexableFields<T, I>; */
|
|
1107
1073
|
|
|
@@ -1555,10 +1521,6 @@ export class DocumentIndex<
|
|
|
1555
1521
|
const previousEvents = this.documentEvents;
|
|
1556
1522
|
this.documentEvents =
|
|
1557
1523
|
properties.documentEvents ?? previousEvents ?? (this.events as any);
|
|
1558
|
-
this.compatibility =
|
|
1559
|
-
properties.compatibility !== undefined
|
|
1560
|
-
? properties.compatibility
|
|
1561
|
-
: this.compatibility;
|
|
1562
1524
|
|
|
1563
1525
|
let prefectOptions =
|
|
1564
1526
|
typeof properties.prefetch === "object"
|
|
@@ -3479,11 +3441,7 @@ export class DocumentIndex<
|
|
|
3479
3441
|
coercedOptions?.remote &&
|
|
3480
3442
|
typeof coercedOptions.remote !== "boolean" &&
|
|
3481
3443
|
coercedOptions.remote.replicate;
|
|
3482
|
-
if (
|
|
3483
|
-
resolve &&
|
|
3484
|
-
wantsReplication &&
|
|
3485
|
-
(this.compatibility == null || this.compatibility > 8)
|
|
3486
|
-
) {
|
|
3444
|
+
if (resolve && wantsReplication) {
|
|
3487
3445
|
// SearchRequest cannot carry entries, so a replicated resolved get would
|
|
3488
3446
|
// fetch the value and then fetch the entry again during sync.
|
|
3489
3447
|
requestClazz = types.SearchRequestIndexed;
|
|
@@ -4502,11 +4460,7 @@ export class DocumentIndex<
|
|
|
4502
4460
|
options?: O,
|
|
4503
4461
|
): Promise<ValueTypeFromRequest<Resolve, T, I>[]> {
|
|
4504
4462
|
// Set fetch to search size, or max value (default to max u32 (4294967295))
|
|
4505
|
-
const coercedRequest = coerceQuery(
|
|
4506
|
-
queryRequest,
|
|
4507
|
-
options,
|
|
4508
|
-
this.compatibility,
|
|
4509
|
-
);
|
|
4463
|
+
const coercedRequest = coerceQuery(queryRequest, options);
|
|
4510
4464
|
coercedRequest.fetch = coercedRequest.fetch ?? 0xffffffff;
|
|
4511
4465
|
|
|
4512
4466
|
const searchOptions =
|
|
@@ -4617,11 +4571,7 @@ export class DocumentIndex<
|
|
|
4617
4571
|
throw new Error("Cannot use resolve=false with SearchRequest"); // TODO make this work
|
|
4618
4572
|
}
|
|
4619
4573
|
|
|
4620
|
-
let queryRequestCoerced = coerceQuery(
|
|
4621
|
-
queryRequest ?? {},
|
|
4622
|
-
options,
|
|
4623
|
-
this.compatibility,
|
|
4624
|
-
);
|
|
4574
|
+
let queryRequestCoerced = coerceQuery(queryRequest ?? {}, options);
|
|
4625
4575
|
|
|
4626
4576
|
const self = this;
|
|
4627
4577
|
function normalizeUpdatesOption(u?: UpdateOptions<T, I, Resolve>): {
|
|
@@ -4760,12 +4710,7 @@ export class DocumentIndex<
|
|
|
4760
4710
|
!(queryRequestCoerced instanceof types.IterationRequest) &&
|
|
4761
4711
|
pushUpdates
|
|
4762
4712
|
) {
|
|
4763
|
-
// Push streaming only works on IterationRequest;
|
|
4764
|
-
if (this.compatibility !== undefined) {
|
|
4765
|
-
throw new Error(
|
|
4766
|
-
"updates.push requires IterationRequest support; not available when compatibility is set",
|
|
4767
|
-
);
|
|
4768
|
-
}
|
|
4713
|
+
// Push streaming only works on IterationRequest; upgrade other callers.
|
|
4769
4714
|
queryRequestCoerced = new types.IterationRequest({
|
|
4770
4715
|
query: queryRequestCoerced.query,
|
|
4771
4716
|
sort: queryRequestCoerced.sort,
|
|
@@ -4782,11 +4727,7 @@ export class DocumentIndex<
|
|
|
4782
4727
|
options?.resolve !== false
|
|
4783
4728
|
) {
|
|
4784
4729
|
// Legacy requests can't carry replicate=true; swap to indexed search so replication intent is preserved.
|
|
4785
|
-
if (
|
|
4786
|
-
(queryRequest instanceof types.SearchRequestIndexed === false &&
|
|
4787
|
-
this.compatibility == null) ||
|
|
4788
|
-
(this.compatibility != null && this.compatibility > 8)
|
|
4789
|
-
) {
|
|
4730
|
+
if (queryRequest instanceof types.SearchRequestIndexed === false) {
|
|
4790
4731
|
queryRequestCoerced = new types.SearchRequestIndexed({
|
|
4791
4732
|
query: queryRequestCoerced.query,
|
|
4792
4733
|
fetch: queryRequestCoerced.fetch,
|