@xyo-network/xl1-protocol-sdk 3.0.5 → 3.0.6
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/neutral/Archivists/MemoryArchivistFactory.d.ts +5 -2
- package/dist/neutral/Archivists/MemoryArchivistFactory.d.ts.map +1 -1
- package/dist/neutral/Archivists/archivistFactoryRegistry.d.ts +9 -0
- package/dist/neutral/Archivists/archivistFactoryRegistry.d.ts.map +1 -0
- package/dist/neutral/Archivists/connectArchivist.d.ts +4 -4
- package/dist/neutral/Archivists/connectArchivist.d.ts.map +1 -1
- package/dist/neutral/Archivists/index.d.ts +1 -0
- package/dist/neutral/Archivists/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +40 -26
- package/dist/neutral/index.mjs.map +4 -4
- package/dist/neutral/test/index.mjs +26 -19
- package/dist/neutral/test/index.mjs.map +4 -4
- package/package.json +6 -6
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { ArchivistInstance } from '@xyo-network/sdk-js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TransportConfig } from '../config/transports/Transport.ts';
|
|
3
3
|
import type { ArchivistConnectOptions } from './ArchivistConnectOptions.ts';
|
|
4
4
|
/**
|
|
5
5
|
* Static, process-global factory for in-memory archivists. `connect` caches by
|
|
6
6
|
* (connectionName, archivistName) so two callers binding the same memory connection
|
|
7
7
|
* and role share one MemoryArchivist — i.e. the same physical store. Without this,
|
|
8
8
|
* each caller would create an isolated Map and silently read/write divergent data.
|
|
9
|
+
*
|
|
10
|
+
* `connect` accepts the wide `TransportConfig` (the memory variant carries no fields)
|
|
11
|
+
* so the class satisfies `ArchivistFactory` and can be held in the factory registry.
|
|
9
12
|
*/
|
|
10
13
|
export declare class MemoryArchivistFactory {
|
|
11
14
|
private static readonly cache;
|
|
12
|
-
static connect(connectionName: string, _config:
|
|
15
|
+
static connect(connectionName: string, _config: TransportConfig, options: ArchivistConnectOptions): Promise<ArchivistInstance>;
|
|
13
16
|
/** Test-only: drop all cached memory archivists so a fresh process state can be simulated. */
|
|
14
17
|
static reset(): Promise<void>;
|
|
15
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryArchivistFactory.d.ts","sourceRoot":"","sources":["../../../src/Archivists/MemoryArchivistFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAG5D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"MemoryArchivistFactory.d.ts","sourceRoot":"","sources":["../../../src/Archivists/MemoryArchivistFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAG5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAG3E;;;;;;;;GAQG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAA+B;WAE/C,OAAO,CAClB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC;IAW7B,8FAA8F;WACjF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAGpC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TransportConfig } from '../config/transports/Transport.ts';
|
|
2
|
+
import type { ArchivistFactory } from './ArchivistFactory.ts';
|
|
3
|
+
/** Register the factory used to self-provision archivists for a connection type. */
|
|
4
|
+
export declare function registerArchivistFactory(type: TransportConfig['type'], factory: ArchivistFactory): void;
|
|
5
|
+
/** The factory registered for a connection type, or undefined if none. */
|
|
6
|
+
export declare function getArchivistFactory(type: TransportConfig['type']): ArchivistFactory | undefined;
|
|
7
|
+
/** Test-only: clear host-registered factories, restoring the default (memory-only) state. */
|
|
8
|
+
export declare function resetArchivistFactories(): void;
|
|
9
|
+
//# sourceMappingURL=archivistFactoryRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archivistFactoryRegistry.d.ts","sourceRoot":"","sources":["../../../src/Archivists/archivistFactoryRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAY7D,oFAAoF;AACpF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAEvG;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,gBAAgB,GAAG,SAAS,CAE/F;AAKD,6FAA6F;AAC7F,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C"}
|
|
@@ -2,10 +2,10 @@ import type { ArchivistInstance } from '@xyo-network/sdk-js';
|
|
|
2
2
|
import type { ArchivistConnectOptions } from './ArchivistConnectOptions.ts';
|
|
3
3
|
import type { ArchivistConnectionBinding } from './ArchivistFactory.ts';
|
|
4
4
|
/**
|
|
5
|
-
* Connect an archivist for a connection binding + logical role, dispatching
|
|
6
|
-
* connection's substrate type. Memory is
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Connect an archivist for a connection binding + logical role, dispatching to the
|
|
6
|
+
* factory registered for the connection's substrate type. Memory is registered by the
|
|
7
|
+
* protocol SDK; hosts register lmdb/mongo (etc.) via `registerArchivistFactory`. An
|
|
8
|
+
* unregistered type is a configuration error and throws loudly.
|
|
9
9
|
*/
|
|
10
10
|
export declare function connectArchivist(binding: ArchivistConnectionBinding, options: ArchivistConnectOptions): Promise<ArchivistInstance>;
|
|
11
11
|
//# sourceMappingURL=connectArchivist.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectArchivist.d.ts","sourceRoot":"","sources":["../../../src/Archivists/connectArchivist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAGvE;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,0BAA0B,EACnC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"connectArchivist.d.ts","sourceRoot":"","sources":["../../../src/Archivists/connectArchivist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAGvE;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,0BAA0B,EACnC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAM5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Archivists/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Archivists/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uBAAuB,CAAA;AACrC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -216,13 +216,6 @@ var ArchivistInstanceCache = class {
|
|
|
216
216
|
}
|
|
217
217
|
};
|
|
218
218
|
|
|
219
|
-
// src/Archivists/archivistRoles.ts
|
|
220
|
-
var CHAIN_ARCHIVIST_ROLE = "chain";
|
|
221
|
-
var PENDING_TRANSACTIONS_ARCHIVIST_ROLE = "pending-transactions";
|
|
222
|
-
var PENDING_BLOCKS_ARCHIVIST_ROLE = "pending-blocks";
|
|
223
|
-
var REJECTED_BLOCKS_ARCHIVIST_ROLE = "rejected-blocks";
|
|
224
|
-
var REJECTED_TRANSACTIONS_ARCHIVIST_ROLE = "rejected-transactions";
|
|
225
|
-
|
|
226
219
|
// src/Archivists/MemoryArchivistFactory.ts
|
|
227
220
|
import { MemoryArchivist } from "@xyo-network/sdk-js";
|
|
228
221
|
var MemoryArchivistFactory = class _MemoryArchivistFactory {
|
|
@@ -243,16 +236,34 @@ var MemoryArchivistFactory = class _MemoryArchivistFactory {
|
|
|
243
236
|
}
|
|
244
237
|
};
|
|
245
238
|
|
|
239
|
+
// src/Archivists/archivistFactoryRegistry.ts
|
|
240
|
+
var registry = /* @__PURE__ */ new Map();
|
|
241
|
+
function registerArchivistFactory(type, factory) {
|
|
242
|
+
registry.set(type, factory);
|
|
243
|
+
}
|
|
244
|
+
function getArchivistFactory(type) {
|
|
245
|
+
return registry.get(type);
|
|
246
|
+
}
|
|
247
|
+
registerArchivistFactory("memory", MemoryArchivistFactory);
|
|
248
|
+
function resetArchivistFactories() {
|
|
249
|
+
registry.clear();
|
|
250
|
+
registerArchivistFactory("memory", MemoryArchivistFactory);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// src/Archivists/archivistRoles.ts
|
|
254
|
+
var CHAIN_ARCHIVIST_ROLE = "chain";
|
|
255
|
+
var PENDING_TRANSACTIONS_ARCHIVIST_ROLE = "pending-transactions";
|
|
256
|
+
var PENDING_BLOCKS_ARCHIVIST_ROLE = "pending-blocks";
|
|
257
|
+
var REJECTED_BLOCKS_ARCHIVIST_ROLE = "rejected-blocks";
|
|
258
|
+
var REJECTED_TRANSACTIONS_ARCHIVIST_ROLE = "rejected-transactions";
|
|
259
|
+
|
|
246
260
|
// src/Archivists/connectArchivist.ts
|
|
247
261
|
async function connectArchivist(binding, options) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
default: {
|
|
253
|
-
throw new Error(`connectArchivist: connection type '${binding.config.type}' is not self-provisioned \u2014 inject the archivist instead`);
|
|
254
|
-
}
|
|
262
|
+
const factory = getArchivistFactory(binding.config.type);
|
|
263
|
+
if (factory === void 0) {
|
|
264
|
+
throw new Error(`connectArchivist: no archivist factory registered for connection type '${binding.config.type}'`);
|
|
255
265
|
}
|
|
266
|
+
return await factory.connect(binding.name, binding.config, options);
|
|
256
267
|
}
|
|
257
268
|
|
|
258
269
|
// src/block/hydrate/allHashesPresent.ts
|
|
@@ -1265,7 +1276,7 @@ var buildProviderFactory = (provider, defaultParams, labels) => {
|
|
|
1265
1276
|
};
|
|
1266
1277
|
return factory;
|
|
1267
1278
|
};
|
|
1268
|
-
var registerCreatableProviderFactory = (
|
|
1279
|
+
var registerCreatableProviderFactory = (registry2, factory, labels, primary = false) => {
|
|
1269
1280
|
const primaryMonikers = primary !== true && isTruthy(primary) ? Array.isArray(primary) ? primary : [primary] : [];
|
|
1270
1281
|
for (const primaryMoniker of primaryMonikers) {
|
|
1271
1282
|
if (!factory.monikers.includes(primaryMoniker)) {
|
|
@@ -1289,17 +1300,17 @@ var registerCreatableProviderFactory = (registry, factory, labels, primary = fal
|
|
|
1289
1300
|
throw new Error(`Invalid primary value: ${String(primary)}`);
|
|
1290
1301
|
};
|
|
1291
1302
|
const factoryClone = buildProviderFactory(factory, factory.defaultParams, labels);
|
|
1292
|
-
|
|
1303
|
+
registry2[factoryClone.defaultMoniker] = [factoryClone, ...registry2[factoryClone.defaultMoniker] ?? []];
|
|
1293
1304
|
for (const moniker of factoryClone.monikers) {
|
|
1294
1305
|
if (moniker === factoryClone.defaultMoniker) continue;
|
|
1295
|
-
|
|
1306
|
+
registry2[moniker] = isPrimaryForMoniker(moniker) ? [factoryClone, ...registry2[moniker] ?? []] : [...registry2[moniker] ?? [], factoryClone];
|
|
1296
1307
|
}
|
|
1297
1308
|
};
|
|
1298
|
-
var registerCreatableProviderFactories = (factories,
|
|
1309
|
+
var registerCreatableProviderFactories = (factories, registry2 = {}, primary = false) => {
|
|
1299
1310
|
for (const factory of factories) {
|
|
1300
|
-
registerCreatableProviderFactory(
|
|
1311
|
+
registerCreatableProviderFactory(registry2, factory, void 0, primary);
|
|
1301
1312
|
}
|
|
1302
|
-
return
|
|
1313
|
+
return registry2;
|
|
1303
1314
|
};
|
|
1304
1315
|
|
|
1305
1316
|
// src/CreatableProvider/LabeledCreatableProviderFactory.ts
|
|
@@ -1319,8 +1330,8 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
1319
1330
|
_frozen = false;
|
|
1320
1331
|
_parent;
|
|
1321
1332
|
_validateDepsOnRegister;
|
|
1322
|
-
constructor(context,
|
|
1323
|
-
this._registry =
|
|
1333
|
+
constructor(context, registry2 = {}, validateDepsOnRegister = false) {
|
|
1334
|
+
this._registry = registry2;
|
|
1324
1335
|
this._context = { ...context, locator: this };
|
|
1325
1336
|
this._parent = context.locator;
|
|
1326
1337
|
this._validateDepsOnRegister = validateDepsOnRegister;
|
|
@@ -1365,16 +1376,16 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
1365
1376
|
);
|
|
1366
1377
|
}
|
|
1367
1378
|
merge(locator) {
|
|
1368
|
-
const
|
|
1379
|
+
const registry2 = { ...this.registry };
|
|
1369
1380
|
for (const moniker in locator.registry) {
|
|
1370
|
-
const existing =
|
|
1381
|
+
const existing = registry2[moniker];
|
|
1371
1382
|
if (existing === void 0) {
|
|
1372
|
-
|
|
1383
|
+
registry2[moniker] = locator.registry[moniker];
|
|
1373
1384
|
} else {
|
|
1374
1385
|
existing.push(...locator.registry[moniker] ?? []);
|
|
1375
1386
|
}
|
|
1376
1387
|
}
|
|
1377
|
-
return new _ProviderFactoryLocator(this.context,
|
|
1388
|
+
return new _ProviderFactoryLocator(this.context, registry2);
|
|
1378
1389
|
}
|
|
1379
1390
|
/**
|
|
1380
1391
|
* Registers a single module factory (with optional tags) with the locator
|
|
@@ -8286,6 +8297,7 @@ export {
|
|
|
8286
8297
|
flattenHydratedTransaction,
|
|
8287
8298
|
flattenHydratedTransactions,
|
|
8288
8299
|
generateXyoBaseWalletFromPhrase,
|
|
8300
|
+
getArchivistFactory,
|
|
8289
8301
|
getBlockRateBlocks,
|
|
8290
8302
|
getEmptyContext,
|
|
8291
8303
|
getEmptyProviderContext,
|
|
@@ -8354,9 +8366,11 @@ export {
|
|
|
8354
8366
|
providerFactoryDescription,
|
|
8355
8367
|
rateMultipliers,
|
|
8356
8368
|
readPayloadMapFromStore,
|
|
8369
|
+
registerArchivistFactory,
|
|
8357
8370
|
registerCreatableProviderFactories,
|
|
8358
8371
|
registerCreatableProviderFactory,
|
|
8359
8372
|
registerFactoriesFromPlan,
|
|
8373
|
+
resetArchivistFactories,
|
|
8360
8374
|
resolveConfig,
|
|
8361
8375
|
resolveProviders,
|
|
8362
8376
|
resolveProvidersFromConfig,
|