@comapeo/core 1.0.1 → 2.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/blob-store/index.d.ts +18 -41
- package/dist/blob-store/index.d.ts.map +1 -1
- package/dist/config-import.d.ts.map +1 -1
- package/dist/core-manager/core-index.d.ts +1 -1
- package/dist/core-manager/core-index.d.ts.map +1 -1
- package/dist/core-manager/index.d.ts +1 -0
- package/dist/core-manager/index.d.ts.map +1 -1
- package/dist/core-ownership.d.ts.map +1 -1
- package/dist/fastify-controller.d.ts.map +1 -1
- package/dist/fastify-plugins/{maps/index.d.ts → maps.d.ts} +8 -8
- package/dist/fastify-plugins/maps.d.ts.map +1 -0
- package/dist/fastify-plugins/utils.d.ts +4 -0
- package/dist/fastify-plugins/utils.d.ts.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/hashmap.d.ts +2 -2
- package/dist/lib/hashmap.d.ts.map +1 -1
- package/dist/lib/key-by.d.ts +15 -0
- package/dist/lib/key-by.d.ts.map +1 -0
- package/dist/lib/noise-secret-stream-helpers.d.ts.map +1 -1
- package/dist/lib/omit.d.ts +17 -0
- package/dist/lib/omit.d.ts.map +1 -0
- package/dist/local-peers.d.ts +3 -2
- package/dist/local-peers.d.ts.map +1 -1
- package/dist/logger.d.ts +12 -9
- package/dist/logger.d.ts.map +1 -1
- package/dist/mapeo-manager.d.ts +9 -1
- package/dist/mapeo-manager.d.ts.map +1 -1
- package/dist/mapeo-project.d.ts +6 -22
- package/dist/mapeo-project.d.ts.map +1 -1
- package/dist/member-api.d.ts +3 -1
- package/dist/member-api.d.ts.map +1 -1
- package/dist/roles.d.ts.map +1 -1
- package/dist/schema/project.d.ts +1 -1
- package/dist/schema/utils.d.ts.map +1 -1
- package/dist/sync/core-sync-state.d.ts +10 -3
- package/dist/sync/core-sync-state.d.ts.map +1 -1
- package/dist/sync/namespace-sync-state.d.ts +8 -12
- package/dist/sync/namespace-sync-state.d.ts.map +1 -1
- package/dist/sync/peer-sync-controller.d.ts.map +1 -1
- package/dist/sync/sync-api.d.ts.map +1 -1
- package/dist/sync/sync-state.d.ts +7 -1
- package/dist/sync/sync-state.d.ts.map +1 -1
- package/dist/translation-api.d.ts +1 -3
- package/dist/translation-api.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +0 -13
- package/dist/utils.d.ts.map +1 -1
- package/package.json +12 -11
- package/src/blob-store/index.js +17 -2
- package/src/config-import.js +0 -1
- package/src/core-manager/index.js +13 -10
- package/src/core-ownership.js +5 -2
- package/src/datastore/README.md +2 -2
- package/src/datatype/README.md +1 -1
- package/src/fastify-controller.js +7 -1
- package/src/fastify-plugins/maps.js +130 -0
- package/src/fastify-plugins/utils.js +6 -0
- package/src/index-writer/index.js +1 -1
- package/src/index.js +1 -3
- package/src/lib/hashmap.js +1 -1
- package/src/lib/key-by.js +24 -0
- package/src/lib/omit.js +28 -0
- package/src/local-peers.js +2 -1
- package/src/logger.js +52 -16
- package/src/mapeo-manager.js +41 -12
- package/src/mapeo-project.js +2 -5
- package/src/member-api.js +12 -5
- package/src/sync/core-sync-state.js +35 -7
- package/src/sync/namespace-sync-state.js +26 -24
- package/src/sync/peer-sync-controller.js +44 -37
- package/src/sync/sync-api.js +9 -6
- package/src/sync/sync-state.js +12 -1
- package/src/translation-api.js +3 -6
- package/src/types.ts +0 -1
- package/src/utils.js +11 -39
- package/dist/fastify-plugins/maps/index.d.ts.map +0 -1
- package/dist/fastify-plugins/maps/offline-fallback-map.d.ts +0 -12
- package/dist/fastify-plugins/maps/offline-fallback-map.d.ts.map +0 -1
- package/dist/fastify-plugins/maps/static-maps.d.ts +0 -11
- package/dist/fastify-plugins/maps/static-maps.d.ts.map +0 -1
- package/src/fastify-plugins/maps/index.js +0 -173
- package/src/fastify-plugins/maps/offline-fallback-map.js +0 -114
- package/src/fastify-plugins/maps/static-maps.js +0 -271
package/dist/schema/project.d.ts
CHANGED
|
@@ -897,7 +897,7 @@ export const fieldTable: import("drizzle-orm/sqlite-core").SQLiteTableWithColumn
|
|
|
897
897
|
tableName: "field";
|
|
898
898
|
dataType: "string";
|
|
899
899
|
columnType: "SQLiteText";
|
|
900
|
-
data: "number" | "UNRECOGNIZED" | "
|
|
900
|
+
data: "number" | "UNRECOGNIZED" | "text" | "type_unspecified" | "selectOne" | "selectMultiple";
|
|
901
901
|
driverParam: string;
|
|
902
902
|
notNull: true;
|
|
903
903
|
hasDefault: false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/schema/utils.js"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,2CAFW,WAAW;;;;;;;;;;;;;;;;;;GAOrB;AAED;;GAEG;AACH,gDAFW,MAAM,UAIhB;AA/BD,wEAAwE;AAExE;;;;;;;;GAQG;AAEH,iDAAiD;AAqBjD;;;;;;;GAWE;wBAzCqB,KAAK,SAAf,MAAQ,aACR,uBAAuB;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/schema/utils.js"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,2CAFW,WAAW;;;;;;;;;;;;;;;;;;GAOrB;AAED;;GAEG;AACH,gDAFW,MAAM,UAIhB;AA/BD,wEAAwE;AAExE;;;;;;;;GAQG;AAEH,iDAAiD;AAqBjD;;;;;;;GAWE;wBAzCqB,KAAK,SAAf,MAAQ,aACR,uBAAuB;IAC/B,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,EAAE,QAAQ,CAAC;IAClB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,GAAG,CAAA;CACb,CAAC;4CATuC,yBAAyB"}
|
|
@@ -36,7 +36,7 @@ export function bitCount32(n: number): number;
|
|
|
36
36
|
* @typedef {object} LocalCoreState
|
|
37
37
|
* @property {number} have blocks we have
|
|
38
38
|
* @property {number} want unique blocks we want from any other peer
|
|
39
|
-
* @property {number} wanted blocks
|
|
39
|
+
* @property {number} wanted unique blocks any other peer wants from us
|
|
40
40
|
*/
|
|
41
41
|
/**
|
|
42
42
|
* @typedef {object} PeerNamespaceState
|
|
@@ -79,11 +79,13 @@ export class CoreSyncState {
|
|
|
79
79
|
* @param {() => void} opts.onUpdate Called when a state update is available (via getState())
|
|
80
80
|
* @param {Map<string, import('./peer-sync-controller.js').PeerSyncController>} opts.peerSyncControllers
|
|
81
81
|
* @param {Namespace} opts.namespace
|
|
82
|
+
* @param {Logger} [opts.logger]
|
|
82
83
|
*/
|
|
83
|
-
constructor({ onUpdate, peerSyncControllers, namespace }: {
|
|
84
|
+
constructor({ onUpdate, peerSyncControllers, namespace, logger }: {
|
|
84
85
|
onUpdate: () => void;
|
|
85
86
|
peerSyncControllers: Map<string, import("./peer-sync-controller.js").PeerSyncController>;
|
|
86
87
|
namespace: Namespace;
|
|
88
|
+
logger?: Logger | undefined;
|
|
87
89
|
});
|
|
88
90
|
getState(): DerivedState;
|
|
89
91
|
/**
|
|
@@ -120,6 +122,10 @@ export class CoreSyncState {
|
|
|
120
122
|
* @param {PeerId} peerId
|
|
121
123
|
*/
|
|
122
124
|
addPeer(peerId: PeerId): void;
|
|
125
|
+
/**
|
|
126
|
+
* @param {PeerId} peerId
|
|
127
|
+
*/
|
|
128
|
+
disconnectPeer(peerId: PeerId): void;
|
|
123
129
|
#private;
|
|
124
130
|
}
|
|
125
131
|
/**
|
|
@@ -213,7 +219,7 @@ export type LocalCoreState = {
|
|
|
213
219
|
*/
|
|
214
220
|
want: number;
|
|
215
221
|
/**
|
|
216
|
-
* blocks
|
|
222
|
+
* unique blocks any other peer wants from us
|
|
217
223
|
*/
|
|
218
224
|
wanted: number;
|
|
219
225
|
};
|
|
@@ -247,6 +253,7 @@ export type DerivedState = {
|
|
|
247
253
|
remoteStates: { [peerId in PeerId]: PeerNamespaceState; };
|
|
248
254
|
};
|
|
249
255
|
import type { Namespace } from '../types.js';
|
|
256
|
+
import { Logger } from '../logger.js';
|
|
250
257
|
import RemoteBitfield from '../core-manager/remote-bitfield.js';
|
|
251
258
|
import type { HypercoreRemoteBitfield } from '../types.js';
|
|
252
259
|
//# sourceMappingURL=core-sync-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-sync-state.d.ts","sourceRoot":"","sources":["../../src/sync/core-sync-state.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core-sync-state.d.ts","sourceRoot":"","sources":["../../src/sync/core-sync-state.js"],"names":[],"mappings":"AAwXA;;;;;;;GAOG;AACH,uCALW,aAAa;;;;EA6DvB;AAED;;;;GAIG;AACH,8BAFW,MAAM,UAMhB;AA9bD,uFAAuF;AAEvF;;GAEG;AACH;;GAEG;AACH;;;;;;;GAOG;AACH;;;;;GAKG;AACH;;;;;;GAMG;AACH;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IAaE;;;;;;OAMG;IACH,kEALG;QAAyB,QAAQ,EAAzB,MAAM,IAAI;QACgE,mBAAmB,EAA7F,GAAG,CAAC,MAAM,EAAE,OAAO,2BAA2B,EAAE,kBAAkB,CAAC;QACnD,SAAS,EAAzB,SAAS;QACK,MAAM;KAAC,EAY/B;IAEU,YAAM,YAAY,CAAA;IAY7B;;;;;;OAMG;IACH,iBAFW,OAAO,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,QAiC/C;IAED;;;;;;;;OAQG;IACH,uBAJW,MAAM,SACN,MAAM,YACN,WAAW,QAsBrB;IAED;;;;;;;OAOG;IACH,qBAHW,MAAM,UACN,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,QAQlD;IAED;;OAEG;IACH,gBAFW,MAAM,QAMhB;IAED;;OAEG;IACH,uBAFW,MAAM,QAOhB;;CAkEF;AAED;;;;;;;;GAQG;AACH;IAUE;;OAEC;IALD,2CAA2C;IAC3C,QADW,kBAAkB,CAAC,QAAQ,CAAC,CACrB;IAKlB,uCAEC;IACD;;;OAGG;IACH,sBAHW,MAAM,YACN,WAAW,WAIrB;IACD;;OAEG;IACH,2BAFW,uBAAuB,QAIjC;IACD;;;;;;;;OAQG;IACH,gCAFW;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,QAK3C;IACD;;;;;OAKG;IACH,YAFW,MAAM,WAIhB;IACD;;;;;;OAMG;IACH,gBAJW,MAAM,GACJ,MAAM,CAOlB;IACD;;;;OAIG;IACH,YAFW,MAAM,WAKhB;IACD;;;;;;OAMG;IACH,gBAJW,MAAM,GACJ,MAAM,CASlB;;CACF;uBA9WY,cAAc;qBAGd,MAAM;;;;;YAIL,MAAM,GAAG,SAAS;gBAClB,SAAS;kBACT,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC;yBACtB,GAAG,CAAC,MAAM,EAAE,OAAO,2BAA2B,EAAE,kBAAkB,CAAC;eACnE,SAAS;;;;;;UAIT,MAAM;;;;UACN,MAAM;;;;YACN,MAAM;;;;;;UAIN,MAAM;;;;UACN,MAAM;;;;YACN,MAAM;YACN,SAAS,GAAG,UAAU,GAAG,SAAS;;;;;;gBAIlC,MAAM;;;;gBACN,cAAc;;;;kBACd,GAAG,MAAgB,IAAN,MAAM,GAAG,kBAAkB,GAAE;;+BAjCe,aAAa;uBAD7D,cAAc;2BAD9B,oCAAoC;6CAE4B,aAAa"}
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @overload
|
|
3
|
-
* @returns {SyncState['localState']}
|
|
4
|
-
*/
|
|
5
|
-
export function createState(): SyncState["localState"];
|
|
6
|
-
/**
|
|
7
|
-
* @overload
|
|
8
|
-
* @param {import('./core-sync-state.js').PeerNamespaceState['status']} status
|
|
9
|
-
* @returns {import('./core-sync-state.js').PeerNamespaceState}
|
|
10
|
-
*/
|
|
11
|
-
export function createState(status: import("./core-sync-state.js").PeerNamespaceState["status"]): import("./core-sync-state.js").PeerNamespaceState;
|
|
12
1
|
/** @import { Namespace } from '../types.js' */
|
|
13
2
|
/**
|
|
14
3
|
* @typedef {Omit<import('./core-sync-state.js').DerivedState, 'coreLength'> & { dataToSync: boolean, coreCount: number }} SyncState
|
|
@@ -23,12 +12,14 @@ export class NamespaceSyncState<TNamespace extends Namespace = "blob" | "auth" |
|
|
|
23
12
|
* @param {import('../core-manager/index.js').CoreManager} opts.coreManager
|
|
24
13
|
* @param {() => void} opts.onUpdate Called when a state update is available (via getState())
|
|
25
14
|
* @param {Map<string, import('./peer-sync-controller.js').PeerSyncController>} opts.peerSyncControllers
|
|
15
|
+
* @param {Logger} [opts.logger]
|
|
26
16
|
*/
|
|
27
|
-
constructor({ namespace, coreManager, onUpdate, peerSyncControllers }: {
|
|
17
|
+
constructor({ namespace, coreManager, onUpdate, peerSyncControllers, logger, }: {
|
|
28
18
|
namespace: TNamespace;
|
|
29
19
|
coreManager: import("../core-manager/index.js").CoreManager;
|
|
30
20
|
onUpdate: () => void;
|
|
31
21
|
peerSyncControllers: Map<string, import("./peer-sync-controller.js").PeerSyncController>;
|
|
22
|
+
logger?: Logger | undefined;
|
|
32
23
|
});
|
|
33
24
|
get namespace(): TNamespace;
|
|
34
25
|
/** @returns {SyncState} */
|
|
@@ -37,6 +28,10 @@ export class NamespaceSyncState<TNamespace extends Namespace = "blob" | "auth" |
|
|
|
37
28
|
* @param {string} peerId
|
|
38
29
|
*/
|
|
39
30
|
addPeer(peerId: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* @param {string} peerId
|
|
33
|
+
*/
|
|
34
|
+
disconnectPeer(peerId: string): void;
|
|
40
35
|
#private;
|
|
41
36
|
}
|
|
42
37
|
export type SyncState = Omit<import("./core-sync-state.js").DerivedState, "coreLength"> & {
|
|
@@ -44,4 +39,5 @@ export type SyncState = Omit<import("./core-sync-state.js").DerivedState, "coreL
|
|
|
44
39
|
coreCount: number;
|
|
45
40
|
};
|
|
46
41
|
import type { Namespace } from '../types.js';
|
|
42
|
+
import { Logger } from '../logger.js';
|
|
47
43
|
//# sourceMappingURL=namespace-sync-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace-sync-state.d.ts","sourceRoot":"","sources":["../../src/sync/namespace-sync-state.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"namespace-sync-state.d.ts","sourceRoot":"","sources":["../../src/sync/namespace-sync-state.js"],"names":[],"mappings":"AAGA,+CAA+C;AAE/C;;GAEG;AAEH;;GAEG;AACH,gCAF0B,UAAU,SAAvB,SAAW;IAatB;;;;;;;OAOG;IACH,gFANG;QAAyB,SAAS,EAA1B,UAAU;QAC2C,WAAW,EAAhE,OAAO,0BAA0B,EAAE,WAAW;QAC7B,QAAQ,EAAzB,MAAM,IAAI;QACgE,mBAAmB,EAA7F,GAAG,CAAC,MAAM,EAAE,OAAO,2BAA2B,EAAE,kBAAkB,CAAC;QACrD,MAAM;KAAC,EAiC/B;IAED,4BAEC;IAED,2BAA2B;IAC3B,YADc,SAAS,CA4BtB;IAED;;OAEG;IACH,gBAFW,MAAM,QAMhB;IAED;;OAEG;IACH,uBAFW,MAAM,QAMhB;;CA2CF;wBAvJY,IAAI,CAAC,OAAO,sBAAsB,EAAE,YAAY,EAAE,YAAY,CAAC,GAAG;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;+BAH1F,aAAa;uBAHrB,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer-sync-controller.d.ts","sourceRoot":"","sources":["../../src/sync/peer-sync-controller.js"],"names":[],"mappings":"AAKA,6DAA6D;AAC7D,0CAA0C;AAC1C,wDAAwD;AACxD,+CAA+C;AAC/C,iFAAiF;AAEjF;;GAEG;AAEH;
|
|
1
|
+
{"version":3,"file":"peer-sync-controller.d.ts","sourceRoot":"","sources":["../../src/sync/pe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iBAAiB;mCAWR,sBAAsB;uBATlC,cAAc"}
|
|
@@ -18,16 +18,22 @@ export class SyncState extends TypedEmitter<{
|
|
|
18
18
|
* @param {import('../core-manager/index.js').CoreManager} opts.coreManager
|
|
19
19
|
* @param {Map<string, import('./peer-sync-controller.js').PeerSyncController>} opts.peerSyncControllers
|
|
20
20
|
* @param {number} [opts.throttleMs]
|
|
21
|
+
* @param {import('../logger.js').Logger} [opts.logger]
|
|
21
22
|
*/
|
|
22
|
-
constructor({ coreManager, peerSyncControllers, throttleMs }: {
|
|
23
|
+
constructor({ coreManager, peerSyncControllers, throttleMs, logger }: {
|
|
23
24
|
coreManager: import("../core-manager/index.js").CoreManager;
|
|
24
25
|
peerSyncControllers: Map<string, import("./peer-sync-controller.js").PeerSyncController>;
|
|
25
26
|
throttleMs?: number | undefined;
|
|
27
|
+
logger?: import("../logger.js").Logger | undefined;
|
|
26
28
|
});
|
|
27
29
|
/**
|
|
28
30
|
* @param {string} peerId
|
|
29
31
|
*/
|
|
30
32
|
addPeer(peerId: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* @param {string} peerId
|
|
35
|
+
*/
|
|
36
|
+
disconnectPeer(peerId: string): void;
|
|
31
37
|
/**
|
|
32
38
|
* @returns {State}
|
|
33
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-state.d.ts","sourceRoot":"","sources":["../../src/sync/sync-state.js"],"names":[],"mappings":"AAKA,+CAA+C;AAE/C;;;;;GAKG;AAEH;;;GAGG;AACH;WAFmC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;;IAIvD
|
|
1
|
+
{"version":3,"file":"sync-state.d.ts","sourceRoot":"","sources":["../../src/sync/sync-state.js"],"names":[],"mappings":"AAKA,+CAA+C;AAE/C;;;;;GAKG;AAEH;;;GAGG;AACH;WAFmC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;;IAIvD;;;;;;;OAOG;IACH,sEALG;QAA6D,WAAW,EAAhE,OAAO,0BAA0B,EAAE,WAAW;QAC4B,mBAAmB,EAA7F,GAAG,CAAC,MAAM,EAAE,OAAO,2BAA2B,EAAE,kBAAkB,CAAC;QACrD,UAAU;QACa,MAAM;KAAC,EActD;IAED;;OAEG;IACH,gBAFW,MAAM,QAMhB;IAED;;OAEG;IACH,uBAFW,MAAM,QAMhB;IAED;;OAEG;IACH,YAFa,KAAK,CAOjB;;CAKF;oBAjEY,MAAM,CAClB,SAAY,EACZ,OAAU,2BAA2B,EAAE,SAAS,CAC7C;6BAXyB,oBAAoB;+BAKlB,aAAa"}
|
|
@@ -11,11 +11,9 @@ export default class TranslationApi {
|
|
|
11
11
|
* Translation,
|
|
12
12
|
* TranslationValue
|
|
13
13
|
* >} opts.dataType
|
|
14
|
-
* @param {typeof import('./schema/project.js').translationTable} opts.table
|
|
15
14
|
*/
|
|
16
|
-
constructor({ dataType
|
|
15
|
+
constructor({ dataType }: {
|
|
17
16
|
dataType: import("./datatype/index.js").DataType<import("./datastore/index.js").DataStore<"config">, typeof import("./schema/project.js").translationTable, "translation", Translation, TranslationValue>;
|
|
18
|
-
table: typeof import("./schema/project.js").translationTable;
|
|
19
17
|
});
|
|
20
18
|
/** @returns {Promise<void>} */
|
|
21
19
|
ready(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation-api.d.ts","sourceRoot":"","sources":["../src/translation-api.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"translation-api.d.ts","sourceRoot":"","sources":["../src/translation-api.js"],"names":[],"mappings":"AAKA,uEAAuE;AACvE,+CAA+C;AAE/C,iEAEC;AACD;IAQE;;;;;;;;;OASG;IACH,0BARG;QAMS,QAAQ,EANT,OAAO,qBAAqB,EAAE,QAAQ,CAChD,OAAW,sBAAsB,EAAE,SAAS,CAAC,QAAQ,CAAC,EACtD,cAAkB,qBAAqB,EAAE,gBAAgB,EACzD,aAAiB,EACjB,WAAe,EACf,gBAAoB,CACjB;KACH,EAWA;IAED,+BAA+B;IAC/B,SADc,OAAO,CAAC,IAAI,CAAC,CAG1B;IAED;;OAEG;IACH,WAFW,gBAAgB;;;;;;;;;;;;;;;;;;;;OAe1B;IAED,kGAAkG;IAElG;;;;;OAKG;IACH,WALW,YACR,IAAI,CAAC,gBAAgB,EAAC,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC,EAC5D,aAAe,GAAG,YAAY,CAAC,GAAG;QAAC,MAAM;;;UAA6B;KAAC,GAC3D,OAAO,CAAC,OAAO,iBAAiB,EAAE,WAAW,EAAE,CAAC,CAqC5D;IAED;;OAEG;IACH,WAFW,gBAAgB,QAkB1B;IAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAEC;IALD,mHAEC;;CAIF;sCApIkD,iBAAiB;iCACnC,WAAW;iCADO,iBAAiB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -100,7 +100,6 @@ export type HypercorePeer = {
|
|
|
100
100
|
length: number;
|
|
101
101
|
}) => void;
|
|
102
102
|
};
|
|
103
|
-
export { NoiseStream };
|
|
104
103
|
type ProtocolStream = Omit<NoiseStream, 'userData'> & {
|
|
105
104
|
userData: Protomux;
|
|
106
105
|
};
|
|
@@ -112,4 +111,5 @@ export type DefaultEmitterEvents<L extends ListenerSignature<L> = DefaultListene
|
|
|
112
111
|
newListener: (event: keyof L, listener: L[keyof L]) => void;
|
|
113
112
|
removeListener: (event: keyof L, listener: L[keyof L]) => void;
|
|
114
113
|
};
|
|
114
|
+
export {};
|
|
115
115
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1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AAI,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CAC7E,CAAA;AAED,KAAK,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG;IACpD,QAAQ,EAAE,QAAQ,CAAA;CACnB,CAAA;AACD,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG;IAAE,WAAW,EAAE,cAAc,CAAA;CAAE,CAAA;AAExE,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,mBAAmB,CAAA;AAE/D,MAAM,MAAM,oBAAoB,CAC9B,CAAC,SAAS,iBAAiB,CAAC,CAAC,CAAC,GAAG,eAAe,IAC9C;IACF,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,CAAA;IAC3D,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,CAAA;CAC/D,CAAA"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {String|Buffer} id
|
|
3
|
-
* @returns {Buffer | Uint8Array}
|
|
4
|
-
*/
|
|
5
|
-
export function idToKey(id: string | Buffer): Buffer | Uint8Array;
|
|
6
1
|
/**
|
|
7
2
|
*
|
|
8
3
|
* @param {Buffer|String} key
|
|
9
4
|
* @returns {String}
|
|
10
5
|
*/
|
|
11
6
|
export function keyToId(key: Buffer | string): string;
|
|
12
|
-
/**
|
|
13
|
-
* @param {String} version
|
|
14
|
-
* @returns {{coreId: String, blockIndex: Number}}
|
|
15
|
-
*/
|
|
16
|
-
export function parseVersion(version: string): {
|
|
17
|
-
coreId: string;
|
|
18
|
-
blockIndex: number;
|
|
19
|
-
};
|
|
20
7
|
/**
|
|
21
8
|
* @returns {void}
|
|
22
9
|
*/
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAQA
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,6BAHW,MAAM,SAAO,UASvB;AAUD;;GAEG;AACH,wBAFa,IAAI,CAEQ;AAEzB;;;;GAIG;AACH,kCAJW,OAAO,WACP,MAAM,GACJ,QAAQ,SAAS,CAI7B;AAED;;;;;;;;;;;;;GAaG;AACH,uBATa,CAAC,OACH,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAUd,OAAO,KACL,KAAK,IAAI,CAAC,CAGxB;AAED;;;;GAIG;AACH,0BAJa,CAAC,SACH,SAAS,GAAG,CAAC,GACX,KAAK,IAAI,CAAC,CAItB;AAED;;;;;;;GAOG;AAEH,0BALkB,CAAC,SAAN,EAAI,OACN,CAAC,GACC,OAAO,YAAY,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAUtD;AAED;;;;GAIG;AACH,wBAJyE,CAAC,SAA5D,OAAO,iBAAiB,EAAE,QAAQ,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CAAG,OAC7D,CAAC,GACC,IAAI,CAAC,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,mBAAmB,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,CAAC,CAa5H;AAED;;;;GAIG;AACH,2CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,iDAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,wDAHW,QAAQ,CAAC,MAAM,CAAC,GACd,MAAM,CAMlB;AAED;;;GAGG;AACH,4CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;GAGG;AACH,wCAHW,2CAAkC,GAChC,MAAM,CAIlB;AAED;;;;;;;2DAO2D;AAC3D,0BALsB,CAAC,SAAV,MAAQ,EACF,CAAC,wBACT,aAAa,CAAC,CAAC,CAAC,SAChB,CAAC,GACC,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAOtD;AAED;;;;GAIG;AACH,gCAHW,MAAM,UAQhB;AAhKD;IACE,2BAA2B;IAC3B,mBADY,KAAK,EAIhB;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comapeo/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Offline p2p mapping library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"test": "npm-run-all lint test:prettier build:types type test:buildConfigs test:unit test:e2e test:types",
|
|
12
12
|
"test:prettier": "prettier --check .",
|
|
13
13
|
"test:buildConfigs": "node scripts/build-config-fixtures.js",
|
|
14
|
-
"test:unit": "node --test
|
|
14
|
+
"test:unit": "node --test",
|
|
15
15
|
"test:e2e": "node --test test-e2e/*.js test-e2e/**/*.js",
|
|
16
16
|
"test:types": "tsc -p test-types/tsconfig.json",
|
|
17
17
|
"build:types": "tsc -p tsconfig.npm.json && cpy 'src/**/*.d.ts' dist",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@types/json-schema": "^7.0.11",
|
|
119
119
|
"@types/json-stable-stringify": "^1.0.36",
|
|
120
120
|
"@types/nanobench": "^3.0.0",
|
|
121
|
-
"@types/node": "^18.19.
|
|
121
|
+
"@types/node": "^18.19.54",
|
|
122
122
|
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
123
123
|
"@types/streamx": "^2.9.5",
|
|
124
124
|
"@types/sub-encoder": "^2.1.0",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"@types/varint": "^6.0.1",
|
|
127
127
|
"@types/yauzl-promise": "^4.0.0",
|
|
128
128
|
"@types/yazl": "^2.4.5",
|
|
129
|
-
"bitfield": "^4.
|
|
129
|
+
"bitfield": "^4.2.0",
|
|
130
130
|
"cpy": "^10.1.0",
|
|
131
131
|
"cpy-cli": "^5.0.0",
|
|
132
132
|
"drizzle-kit": "^0.20.14",
|
|
@@ -142,22 +142,22 @@
|
|
|
142
142
|
"random-access-file": "^4.0.7",
|
|
143
143
|
"random-access-memory": "^6.2.1",
|
|
144
144
|
"rimraf": "^5.0.5",
|
|
145
|
+
"supports-color": "^9.4.0",
|
|
145
146
|
"tempy": "^3.1.0",
|
|
146
147
|
"ts-proto": "^1.156.7",
|
|
147
|
-
"typedoc": "^0.26.
|
|
148
|
-
"typedoc-plugin-markdown": "^4.2.
|
|
148
|
+
"typedoc": "^0.26.7",
|
|
149
|
+
"typedoc-plugin-markdown": "^4.2.7",
|
|
149
150
|
"typedoc-plugin-missing-exports": "^3.0.0",
|
|
150
|
-
"typescript": "^5.
|
|
151
|
+
"typescript": "^5.6.2",
|
|
151
152
|
"yazl": "^2.5.1"
|
|
152
153
|
},
|
|
153
154
|
"dependencies": {
|
|
155
|
+
"@comapeo/fallback-smp": "^1.0.0",
|
|
154
156
|
"@comapeo/schema": "1.0.0",
|
|
155
157
|
"@digidem/types": "^2.3.0",
|
|
156
|
-
"@electron/asar": "^3.2.8",
|
|
157
158
|
"@fastify/error": "^3.4.1",
|
|
158
|
-
"@fastify/
|
|
159
|
-
"@
|
|
160
|
-
"@hyperswarm/secret-stream": "^6.1.2",
|
|
159
|
+
"@fastify/type-provider-typebox": "^4.1.0",
|
|
160
|
+
"@hyperswarm/secret-stream": "^6.6.3",
|
|
161
161
|
"@mapeo/crypto": "1.0.0-alpha.10",
|
|
162
162
|
"@mapeo/sqlite-indexer": "1.0.0-alpha.9",
|
|
163
163
|
"@sinclair/typebox": "^0.29.6",
|
|
@@ -191,6 +191,7 @@
|
|
|
191
191
|
"sodium-universal": "^4.0.0",
|
|
192
192
|
"start-stop-state-machine": "^1.2.0",
|
|
193
193
|
"streamx": "^2.19.0",
|
|
194
|
+
"styled-map-package": "^2.0.0",
|
|
194
195
|
"sub-encoder": "^2.1.1",
|
|
195
196
|
"throttle-debounce": "^5.0.0",
|
|
196
197
|
"tiny-typed-emitter": "^2.1.0",
|
package/src/blob-store/index.js
CHANGED
|
@@ -4,7 +4,15 @@ import util from 'node:util'
|
|
|
4
4
|
import { discoveryKey } from 'hypercore-crypto'
|
|
5
5
|
import { TypedEmitter } from 'tiny-typed-emitter'
|
|
6
6
|
import { LiveDownload } from './live-download.js'
|
|
7
|
+
/** @import { Readable as NodeReadable } from 'node:stream' */
|
|
8
|
+
/** @import { Readable as StreamxReadable, Writable } from 'streamx' */
|
|
7
9
|
/** @import { BlobId } from '../types.js' */
|
|
10
|
+
/** @import { BlobDownloadEvents } from './live-download.js' */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* @typedef {NodeReadable | StreamxReadable} Readable
|
|
15
|
+
*/
|
|
8
16
|
|
|
9
17
|
/** @typedef {TypedEmitter<{ 'add-drive': (drive: import('hyperdrive')) => void }>} InternalDriveEmitter */
|
|
10
18
|
|
|
@@ -74,12 +82,16 @@ export class BlobStore {
|
|
|
74
82
|
})
|
|
75
83
|
}
|
|
76
84
|
|
|
85
|
+
/**
|
|
86
|
+
* @returns {string}
|
|
87
|
+
*/
|
|
77
88
|
get writerDriveId() {
|
|
78
89
|
return getDiscoveryId(this.#writer.key)
|
|
79
90
|
}
|
|
80
91
|
|
|
81
92
|
/**
|
|
82
93
|
* @param {string} driveId hex-encoded discovery key
|
|
94
|
+
* @returns {Hyperdrive}
|
|
83
95
|
*/
|
|
84
96
|
#getDrive(driveId) {
|
|
85
97
|
const drive = this.#hyperdrives.get(driveId)
|
|
@@ -92,6 +104,7 @@ export class BlobStore {
|
|
|
92
104
|
* @param {object} opts
|
|
93
105
|
* @param {false} [opts.wait=false] Set to `true` to wait for a blob to download, otherwise will throw if blob is not available locally
|
|
94
106
|
* @param {never} [opts.timeout] Optional timeout to wait for a blob to download
|
|
107
|
+
* @returns {Promise<Uint8Array>}
|
|
95
108
|
*/
|
|
96
109
|
async get({ type, variant, name, driveId }, { wait = false, timeout } = {}) {
|
|
97
110
|
const drive = this.#getDrive(driveId)
|
|
@@ -112,7 +125,7 @@ export class BlobStore {
|
|
|
112
125
|
* @param {import('../types.js').BlobFilter} [filter] Filter blob types and/or variants to download. Filter is { [BlobType]: BlobVariants[] }. At least one blob variant must be specified for each blob type.
|
|
113
126
|
* @param {object} options
|
|
114
127
|
* @param {AbortSignal} [options.signal] Optional AbortSignal to cancel in-progress download
|
|
115
|
-
* @returns
|
|
128
|
+
* @returns {TypedEmitter<BlobDownloadEvents>}
|
|
116
129
|
*/
|
|
117
130
|
download(filter, { signal } = {}) {
|
|
118
131
|
return new LiveDownload(this.#hyperdrives.values(), this.#driveEmitter, {
|
|
@@ -126,6 +139,7 @@ export class BlobStore {
|
|
|
126
139
|
* @param {object} [options]
|
|
127
140
|
* @param {boolean} [options.wait=false] Set to `true` to wait for a blob to download, otherwise will throw if blob is not available locally
|
|
128
141
|
* @param {number} [options.timeout] Optional timeout to wait for a blob to download
|
|
142
|
+
* @returns {Readable}
|
|
129
143
|
*/
|
|
130
144
|
createReadStream(
|
|
131
145
|
{ type, variant, name, driveId },
|
|
@@ -146,6 +160,7 @@ export class BlobStore {
|
|
|
146
160
|
* @param {import('hyperdrive').HyperdriveEntry} entry Hyperdrive entry
|
|
147
161
|
* @param {object} [options]
|
|
148
162
|
* @param {boolean} [options.wait=false] Set to `true` to wait for a blob to download, otherwise will throw if blob is not available locally
|
|
163
|
+
* @returns {Promise<Readable>}
|
|
149
164
|
*/
|
|
150
165
|
async createEntryReadStream(driveId, entry, options = { wait: false }) {
|
|
151
166
|
const drive = this.#getDrive(driveId)
|
|
@@ -165,7 +180,6 @@ export class BlobStore {
|
|
|
165
180
|
* @param {import('hyperdrive').HyperdriveEntry} entry Hyperdrive entry
|
|
166
181
|
* @param {object} [opts]
|
|
167
182
|
* @param {number} [opts.length]
|
|
168
|
-
*
|
|
169
183
|
* @returns {Promise<Buffer | null>}
|
|
170
184
|
*/
|
|
171
185
|
async getEntryBlob(driveId, entry, { length } = {}) {
|
|
@@ -199,6 +213,7 @@ export class BlobStore {
|
|
|
199
213
|
* @param {Omit<BlobId, 'driveId'>} blobId
|
|
200
214
|
* @param {object} [options]
|
|
201
215
|
* @param {{mimeType: string}} [options.metadata] Metadata to store with the blob
|
|
216
|
+
* @returns {Writable & { driveId: string }}
|
|
202
217
|
*/
|
|
203
218
|
createWriteStream({ type, variant, name }, options) {
|
|
204
219
|
const path = makePath({ type, variant, name })
|
package/src/config-import.js
CHANGED
|
@@ -516,7 +516,6 @@ function parseIcon(filename, buf) {
|
|
|
516
516
|
if (!matches) {
|
|
517
517
|
throw new Error(`Unexpected icon filename ${filename}`)
|
|
518
518
|
}
|
|
519
|
-
/* eslint-disable no-unused-vars */
|
|
520
519
|
const [_, name, size, pixelDensityStr] = matches
|
|
521
520
|
const pixelDensity = Number(pixelDensityStr)
|
|
522
521
|
if (!(pixelDensity === 1 || pixelDensity === 2 || pixelDensity === 3)) {
|
|
@@ -33,8 +33,8 @@ export const kCoreManagerReplicate = Symbol('replicate core manager')
|
|
|
33
33
|
export class CoreManager extends TypedEmitter {
|
|
34
34
|
#corestore
|
|
35
35
|
#coreIndex
|
|
36
|
-
/** @type {
|
|
37
|
-
#
|
|
36
|
+
/** @type {CoreRecord} */
|
|
37
|
+
#creatorCoreRecord
|
|
38
38
|
#projectKey
|
|
39
39
|
#queries
|
|
40
40
|
#encryptionKeys
|
|
@@ -128,12 +128,12 @@ export class CoreManager extends TypedEmitter {
|
|
|
128
128
|
}
|
|
129
129
|
const writer = this.#addCore(keyPair, namespace)
|
|
130
130
|
if (namespace === 'auth' && projectSecretKey) {
|
|
131
|
-
this.#
|
|
131
|
+
this.#creatorCoreRecord = writer
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
// For anyone other than the project creator, creatorCore is readonly
|
|
136
|
-
this.#
|
|
136
|
+
this.#creatorCoreRecord ??= this.#addCore({ publicKey: projectKey }, 'auth')
|
|
137
137
|
|
|
138
138
|
// Load persisted cores
|
|
139
139
|
const rows = db.select().from(coresTable).all()
|
|
@@ -141,7 +141,7 @@ export class CoreManager extends TypedEmitter {
|
|
|
141
141
|
this.#addCore({ publicKey }, namespace)
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
this.#projectExtension = this
|
|
144
|
+
this.#projectExtension = this.creatorCore.registerExtension(
|
|
145
145
|
'mapeo/project',
|
|
146
146
|
{
|
|
147
147
|
encoding: ProjectExtensionCodec,
|
|
@@ -151,14 +151,14 @@ export class CoreManager extends TypedEmitter {
|
|
|
151
151
|
}
|
|
152
152
|
)
|
|
153
153
|
|
|
154
|
-
this.#haveExtension = this
|
|
154
|
+
this.#haveExtension = this.creatorCore.registerExtension('mapeo/have', {
|
|
155
155
|
encoding: HaveExtensionCodec,
|
|
156
156
|
onmessage: (msg, peer) => {
|
|
157
157
|
this.#handleHaveMessage(msg, peer)
|
|
158
158
|
},
|
|
159
159
|
})
|
|
160
160
|
|
|
161
|
-
this
|
|
161
|
+
this.creatorCore.on('peer-add', (peer) => {
|
|
162
162
|
this.#sendHaves(peer, this.#coreIndex).catch(() => {
|
|
163
163
|
this.#l.log('Failed to send pre-haves to newly-connected peer')
|
|
164
164
|
})
|
|
@@ -179,7 +179,11 @@ export class CoreManager extends TypedEmitter {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
get creatorCore() {
|
|
182
|
-
return this.#
|
|
182
|
+
return this.#creatorCoreRecord.core
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
get creatorCoreRecord() {
|
|
186
|
+
return this.#creatorCoreRecord
|
|
183
187
|
}
|
|
184
188
|
|
|
185
189
|
/**
|
|
@@ -255,7 +259,6 @@ export class CoreManager extends TypedEmitter {
|
|
|
255
259
|
* @returns {CoreRecord}
|
|
256
260
|
*/
|
|
257
261
|
addCore(key, namespace) {
|
|
258
|
-
this.#l.log('Adding remote core %k to %s', key, namespace)
|
|
259
262
|
return this.#addCore({ publicKey: key }, namespace, true)
|
|
260
263
|
}
|
|
261
264
|
|
|
@@ -298,7 +301,7 @@ export class CoreManager extends TypedEmitter {
|
|
|
298
301
|
|
|
299
302
|
if (writer) {
|
|
300
303
|
const sendHaves = debounce(WRITER_CORE_PREHAVES_DEBOUNCE_DELAY, () => {
|
|
301
|
-
for (const peer of this
|
|
304
|
+
for (const peer of this.creatorCore.peers) {
|
|
302
305
|
this.#sendHaves(peer, [{ core, namespace }]).catch(() => {
|
|
303
306
|
this.#l.log('Failed to send new pre-haves to other peers')
|
|
304
307
|
})
|
package/src/core-ownership.js
CHANGED
|
@@ -15,6 +15,7 @@ import { discoveryKey } from 'hypercore-crypto'
|
|
|
15
15
|
import pDefer from 'p-defer'
|
|
16
16
|
import { NAMESPACES } from './constants.js'
|
|
17
17
|
import { TypedEmitter } from 'tiny-typed-emitter'
|
|
18
|
+
import { omit } from './lib/omit.js'
|
|
18
19
|
/**
|
|
19
20
|
* @import {
|
|
20
21
|
* CoreOwnershipWithSignatures,
|
|
@@ -167,8 +168,10 @@ export function mapAndValidateCoreOwnership(doc, { coreDiscoveryKey }) {
|
|
|
167
168
|
if (!verifyCoreOwnership(doc)) {
|
|
168
169
|
throw new Error('Invalid coreOwnership record: signatures are invalid')
|
|
169
170
|
}
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
const docWithoutSignatures = omit(doc, [
|
|
172
|
+
'identitySignature',
|
|
173
|
+
'coreSignatures',
|
|
174
|
+
])
|
|
172
175
|
docWithoutSignatures.links = []
|
|
173
176
|
return docWithoutSignatures
|
|
174
177
|
}
|
package/src/datastore/README.md
CHANGED
|
@@ -10,7 +10,7 @@ The `DataStore` class is an API over a CoreManager namespace, responsible for re
|
|
|
10
10
|
|
|
11
11
|
The `DataStore` class is used internally by the [`DataType`](../datatype/) class.
|
|
12
12
|
|
|
13
|
-
An example of `DataStore` usage taken from the [datastore tests](../../
|
|
13
|
+
An example of `DataStore` usage taken from the [datastore tests](../../test/datastore.js):
|
|
14
14
|
|
|
15
15
|
```js
|
|
16
16
|
const datastore = new DataStore({
|
|
@@ -43,4 +43,4 @@ TODO!
|
|
|
43
43
|
|
|
44
44
|
## Tests
|
|
45
45
|
|
|
46
|
-
Tests for this module are in [
|
|
46
|
+
Tests for this module are in [test/datastore.js](../../test/datastore.js)
|
package/src/datatype/README.md
CHANGED
|
@@ -64,7 +64,13 @@ export class FastifyController {
|
|
|
64
64
|
|
|
65
65
|
async #stopServer() {
|
|
66
66
|
const { server } = this.#fastify
|
|
67
|
-
|
|
67
|
+
|
|
68
|
+
const closePromise = promisify(server.close.bind(server))()
|
|
69
|
+
|
|
70
|
+
// We call this after `server.close()` as recommended by the Node docs (see https://nodejs.org/docs/latest-v20.x/api/http.html#servercloseidleconnections)
|
|
71
|
+
server.closeIdleConnections()
|
|
72
|
+
|
|
73
|
+
await closePromise
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
/**
|