@xyo-network/sdk 8.1.0 → 8.1.2

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.
Files changed (90) hide show
  1. package/README.md +25 -0
  2. package/dist/neutral/account-custody.d.ts +2 -0
  3. package/dist/neutral/account-custody.d.ts.map +1 -0
  4. package/dist/neutral/account-custody.mjs +542 -0
  5. package/dist/neutral/account-custody.mjs.map +7 -0
  6. package/dist/neutral/address-payload-plugin.mjs +3 -14
  7. package/dist/neutral/address-payload-plugin.mjs.map +4 -4
  8. package/dist/neutral/api-location-diviner.mjs +0 -2
  9. package/dist/neutral/api-location-diviner.mjs.map +2 -2
  10. package/dist/neutral/archivist-abstract.mjs +54 -11
  11. package/dist/neutral/archivist-abstract.mjs.map +3 -3
  12. package/dist/neutral/archivist-memory.mjs +1 -4
  13. package/dist/neutral/archivist-memory.mjs.map +2 -2
  14. package/dist/neutral/bridge-abstract.mjs +4 -7
  15. package/dist/neutral/bridge-abstract.mjs.map +2 -2
  16. package/dist/neutral/bridge-http.mjs +1 -1
  17. package/dist/neutral/bridge-http.mjs.map +2 -2
  18. package/dist/neutral/diviner-boundwitness.memory.mjs +1 -1
  19. package/dist/neutral/diviner-boundwitness.memory.mjs.map +2 -2
  20. package/dist/neutral/diviner-boundwitness.mjs +1 -1
  21. package/dist/neutral/diviner-boundwitness.mjs.map +2 -2
  22. package/dist/neutral/diviner-payload-generic.mjs +3 -3
  23. package/dist/neutral/diviner-payload-generic.mjs.map +2 -2
  24. package/dist/neutral/index.d.ts +1 -0
  25. package/dist/neutral/index.d.ts.map +1 -1
  26. package/dist/neutral/index.mjs +1 -0
  27. package/dist/neutral/index.mjs.map +2 -2
  28. package/dist/neutral/module-abstract.mjs +4 -4
  29. package/dist/neutral/module-abstract.mjs.map +3 -3
  30. package/dist/neutral/module-resolver.mjs +3 -6
  31. package/dist/neutral/module-resolver.mjs.map +2 -2
  32. package/dist/neutral/modules/account-custody/AccountCustody.d.ts +14 -0
  33. package/dist/neutral/modules/account-custody/AccountCustody.d.ts.map +1 -0
  34. package/dist/neutral/modules/account-custody/AccountCustodyClient.d.ts +4 -0
  35. package/dist/neutral/modules/account-custody/AccountCustodyClient.d.ts.map +1 -0
  36. package/dist/neutral/modules/account-custody/clientExecution.d.ts +11 -0
  37. package/dist/neutral/modules/account-custody/clientExecution.d.ts.map +1 -0
  38. package/dist/neutral/modules/account-custody/clientModel.d.ts +49 -0
  39. package/dist/neutral/modules/account-custody/clientModel.d.ts.map +1 -0
  40. package/dist/neutral/modules/account-custody/clientOwner.d.ts +7 -0
  41. package/dist/neutral/modules/account-custody/clientOwner.d.ts.map +1 -0
  42. package/dist/neutral/modules/account-custody/clientSignals.d.ts +4 -0
  43. package/dist/neutral/modules/account-custody/clientSignals.d.ts.map +1 -0
  44. package/dist/neutral/modules/account-custody/clientState.d.ts +31 -0
  45. package/dist/neutral/modules/account-custody/clientState.d.ts.map +1 -0
  46. package/dist/neutral/modules/account-custody/error.d.ts +8 -0
  47. package/dist/neutral/modules/account-custody/error.d.ts.map +1 -0
  48. package/dist/neutral/modules/account-custody/index.d.ts +7 -0
  49. package/dist/neutral/modules/account-custody/index.d.ts.map +1 -0
  50. package/dist/neutral/modules/account-custody/model.d.ts +65 -0
  51. package/dist/neutral/modules/account-custody/model.d.ts.map +1 -0
  52. package/dist/neutral/modules/account-custody/realmRegistry.d.ts +2 -0
  53. package/dist/neutral/modules/account-custody/realmRegistry.d.ts.map +1 -0
  54. package/dist/neutral/modules/address-payload-plugin/Plugin.d.ts.map +1 -1
  55. package/dist/neutral/modules/address-payload-plugin/index.d.ts +0 -1
  56. package/dist/neutral/modules/address-payload-plugin/index.d.ts.map +1 -1
  57. package/dist/neutral/modules/api-location-diviner/RemoteDivinerConfig.d.ts +0 -2
  58. package/dist/neutral/modules/api-location-diviner/RemoteDivinerConfig.d.ts.map +1 -1
  59. package/dist/neutral/modules/archivist-abstract/AbstractArchivist.d.ts +1 -0
  60. package/dist/neutral/modules/archivist-abstract/AbstractArchivist.d.ts.map +1 -1
  61. package/dist/neutral/modules/archivist-abstract/InsertSequencer.d.ts +25 -0
  62. package/dist/neutral/modules/archivist-abstract/InsertSequencer.d.ts.map +1 -0
  63. package/dist/neutral/modules/archivist-memory/MemoryDriver.d.ts.map +1 -1
  64. package/dist/neutral/modules/bridge-abstract/AbstractModuleProxy/ModuleProxyResolver.d.ts.map +1 -1
  65. package/dist/neutral/modules/bridge-http/HttpBridge.d.ts.map +1 -1
  66. package/dist/neutral/modules/diviner-boundwitness/applyBoundWitnessDivinerQueryPayload.d.ts.map +1 -1
  67. package/dist/neutral/modules/diviner-payload-generic/Diviner.d.ts.map +1 -1
  68. package/dist/neutral/modules/module-resolver/AbstractModuleResolver.d.ts.map +1 -1
  69. package/dist/neutral/modules/module-resolver/ResolverEventEmitter.d.ts.map +1 -1
  70. package/dist/neutral/modules/node-memory/MemoryNode.d.ts.map +1 -1
  71. package/dist/neutral/node-memory.mjs +1 -4
  72. package/dist/neutral/node-memory.mjs.map +2 -2
  73. package/dist/node/account-custody.d.ts +2 -0
  74. package/dist/node/account-custody.d.ts.map +1 -0
  75. package/dist/node/index.d.ts +1 -0
  76. package/dist/node/index.d.ts.map +1 -1
  77. package/dist/node/index.mjs +1 -0
  78. package/dist/node/index.mjs.map +2 -2
  79. package/dist/node/modules/account-custody/clientExecution.d.ts +11 -0
  80. package/dist/node/modules/account-custody/clientExecution.d.ts.map +1 -0
  81. package/dist/node/modules/account-custody/clientSignals.d.ts +4 -0
  82. package/dist/node/modules/account-custody/clientSignals.d.ts.map +1 -0
  83. package/dist/node/modules/account-custody/realmRegistry.d.ts +2 -0
  84. package/dist/node/modules/account-custody/realmRegistry.d.ts.map +1 -0
  85. package/dist/node/modules/archivist-abstract/InsertSequencer.d.ts +25 -0
  86. package/dist/node/modules/archivist-abstract/InsertSequencer.d.ts.map +1 -0
  87. package/dist/node/modules/archivist-memory/MemoryDriver.d.ts.map +1 -1
  88. package/package.json +19 -13
  89. package/dist/neutral/modules/address-payload-plugin/Template.d.ts +0 -3
  90. package/dist/neutral/modules/address-payload-plugin/Template.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/modules/diviner-boundwitness/applyBoundWitnessDivinerQueryPayload.ts", "../../src/modules/diviner-boundwitness/MemoryBoundWitnessDiviner.ts", "../../src/modules/diviner-boundwitness/BoundWitnessDiviner.ts", "../../src/modules/diviner-boundwitness/Config.ts", "../../src/modules/diviner-boundwitness/Schema.ts", "../../src/modules/diviner-boundwitness/Query.ts"],
4
- "sourcesContent": ["import {\n assertEx, containsAll,\n exists, hexFromHexString,\n} from '@ariestools/sdk'\nimport type {\n BoundWitness, Payload, WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport {\n isBoundWitness, PayloadBuilder, SequenceConstants,\n} from '@xyo-network/sdk-protocol'\n\nimport type { BoundWitnessDivinerQueryPayload } from './Query.ts'\n\n// eslint-disable-next-line complexity\nexport const applyBoundWitnessDivinerQueryPayload = (filter?: BoundWitnessDivinerQueryPayload, payloads: WithStorageMeta<Payload>[] = []): BoundWitness[] => {\n if (!filter) return []\n const {\n addresses, cursor, destination, limit, order = 'desc', payload_hashes, payload_schemas, sourceQuery,\n } = filter\n\n const sortedPayloads = PayloadBuilder.sortByStorageMeta(payloads, order === 'desc' ? -1 : 1)\n const parsedCursor = cursor ?? ((order === 'desc') ? SequenceConstants.maxLocalSequence : SequenceConstants.minLocalSequence)\n const parsedOffset = (order === 'desc')\n ? sortedPayloads.findIndex(bw => bw._sequence < parsedCursor)\n : sortedPayloads.findIndex(bw => bw._sequence > parsedCursor)\n if (parsedOffset === -1) return []\n const payloadSubset = sortedPayloads.slice(parsedOffset)\n\n let bws = payloadSubset.filter(isBoundWitness)\n const allAddresses = addresses?.map(address => hexFromHexString(address)).filter(exists)\n if (allAddresses !== undefined && allAddresses.length > 0) bws = bws.filter(bw => containsAll<string>(bw.addresses, allAddresses))\n if (payload_hashes !== undefined && payload_hashes.length > 0) bws = bws.filter(bw => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas !== undefined && payload_schemas.length > 0) bws = bws.filter(bw => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery !== undefined && sourceQuery !== '') bws = bws.filter(bw => bw?.$sourceQuery === sourceQuery)\n // If there's a destination filter of the right kind\n if (destination && Array.isArray(destination) && destination?.length > 0) {\n const targetFilter = assertEx(destination, () => 'Missing destination')\n // Find all BWs that satisfy the destination constraint\n bws = bws.filter((bw) => {\n const targetDestinationField = (bw as { $destination?: string | string[] })?.$destination\n // If the destination field is an array and contains at least one element\n // If the destination field is an array with at least one element, keep bound witnesses that contain the filter.\n return targetDestinationField !== undefined\n && Array.isArray(targetDestinationField)\n && targetDestinationField.length > 0\n && containsAll(targetFilter, targetDestinationField ?? [])\n })\n }\n const parsedLimit = limit ?? bws.length\n return bws.slice(0, parsedLimit)\n}\n", "import { assertEx } from '@ariestools/sdk'\nimport { type BoundWitness, isBoundWitness } from '@xyo-network/sdk-protocol'\nimport { isStorageMeta } from '@xyo-network/sdk-protocol'\n\nimport { applyBoundWitnessDivinerQueryPayload } from './applyBoundWitnessDivinerQueryPayload.ts'\nimport { BoundWitnessDiviner } from './BoundWitnessDiviner.ts'\nimport type { BoundWitnessDivinerParams } from './Params.ts'\nimport { type BoundWitnessDivinerQueryPayload, isBoundWitnessDivinerQueryPayload } from './Query.ts'\n\nexport interface EqualityComparisonOperators {\n /**\n * 'Not Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value does not match the provided string.\n * Example: field != 'value'\n */\n '!=': string\n\n /**\n * 'Less Than' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically less than the provided string.\n * Example: field < 'value'\n */\n '<': string\n\n /**\n * 'Less Than or Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically less than or equal to the provided string.\n * Example: field <= 'value'\n */\n '<=': string\n\n /**\n * 'Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value matches the provided string exactly.\n * Example: field = 'value'\n */\n '=': string\n\n /**\n * 'Greater Than' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically greater than the provided string.\n * Example: field > 'value'\n */\n '>': string\n\n /**\n * 'Greater Than or Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically greater than or equal to the provided string.\n * Example: field >= 'value'\n */\n '>=': string\n}\n\nexport class MemoryBoundWitnessDiviner<\n TParams extends BoundWitnessDivinerParams = BoundWitnessDivinerParams,\n TIn extends BoundWitnessDivinerQueryPayload = BoundWitnessDivinerQueryPayload,\n TOut extends BoundWitness = BoundWitness,\n> extends BoundWitnessDiviner<TParams, TIn, TOut> {\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const bws = ((await archivist?.next({ limit: 10_000 })) ?? []).filter(x => isBoundWitness(x) && isStorageMeta(x))\n return applyBoundWitnessDivinerQueryPayload(filter, bws) as TOut[]\n }\n}\n", "import type { BoundWitness, Schema } from '@xyo-network/sdk-protocol'\n\nimport { AbstractDiviner } from '#diviner-abstract'\nimport type { DivinerInstance, DivinerModuleEventData } from '#diviner-model'\n\nimport { BoundWitnessDivinerConfigSchema } from './Config.ts'\nimport type { BoundWitnessDivinerParams } from './Params.ts'\nimport type { BoundWitnessDivinerQueryPayload } from './Query.ts'\n\nexport abstract class BoundWitnessDiviner<\n TParams extends BoundWitnessDivinerParams = BoundWitnessDivinerParams,\n TIn extends BoundWitnessDivinerQueryPayload = BoundWitnessDivinerQueryPayload,\n TOut extends BoundWitness = BoundWitness,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, BoundWitnessDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = BoundWitnessDivinerConfigSchema\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, type Payload } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { DivinerConfig } from '#diviner-model'\nimport { DivinerConfigZod } from '#diviner-model'\n\nimport { BoundWitnessDivinerSchema } from './Schema.ts'\n\nexport const BoundWitnessDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${BoundWitnessDivinerSchema}.config`, true)\nexport type BoundWitnessDivinerConfigSchema = typeof BoundWitnessDivinerConfigSchema\n\nexport const BoundWitnessDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n schema: z.ZodMiniLiteral<BoundWitnessDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, { schema: z.literal(BoundWitnessDivinerConfigSchema) })\n\nexport type BoundWitnessDivinerConfigBase = z.infer<typeof BoundWitnessDivinerConfigZod>\n\nexport const isBoundWitnessDivinerConfig: ReturnType<typeof zodIsFactory<BoundWitnessDivinerConfigBase>> = zodIsFactory(BoundWitnessDivinerConfigZod)\nexport const asBoundWitnessDivinerConfig: ReturnType<typeof zodAsFactory<BoundWitnessDivinerConfigBase>> = zodAsFactory(BoundWitnessDivinerConfigZod, 'asBoundWitnessDivinerConfig')\nexport const toBoundWitnessDivinerConfig: ReturnType<typeof zodToFactory<BoundWitnessDivinerConfigBase>> = zodToFactory(BoundWitnessDivinerConfigZod, 'toBoundWitnessDivinerConfig')\n\nexport type BoundWitnessDivinerConfig<T extends Payload = Payload> = DivinerConfig<\n T & {\n schema: BoundWitnessDivinerConfigSchema\n }\n>\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nexport const BoundWitnessDivinerSchema: 'network.xyo.diviner.boundwitness' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.boundwitness', true)\nexport type BoundWitnessDivinerSchema = typeof BoundWitnessDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport {\n asSchema, PayloadZodOfSchema, QueryFieldsZod,\n} from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { BoundWitnessDivinerPredicate } from './Predicate.ts'\nimport { BoundWitnessDivinerSchema } from './Schema.ts'\n\nexport const BoundWitnessDivinerQuerySchema: string & {\n readonly __schema: true\n} = asSchema(`${BoundWitnessDivinerSchema}.query`, true)\nexport type BoundWitnessDivinerQuerySchema = typeof BoundWitnessDivinerQuerySchema\n\nexport const BoundWitnessDivinerQueryPayloadZod: z.ZodMiniIntersection<\n z.ZodMiniObject<\n & { schema: z.ZodMiniLiteral<BoundWitnessDivinerQuerySchema> }\n & (typeof QueryFieldsZod)['shape'],\n z.core.$strip\n >,\n z.ZodMiniCustom<BoundWitnessDivinerPredicate, BoundWitnessDivinerPredicate>\n> = z.intersection(\n z.extend(PayloadZodOfSchema(BoundWitnessDivinerQuerySchema), { ...QueryFieldsZod.shape }),\n z.custom<BoundWitnessDivinerPredicate>(),\n)\n\nexport type BoundWitnessDivinerQueryPayload = z.infer<typeof BoundWitnessDivinerQueryPayloadZod>\n\nexport const isBoundWitnessDivinerQueryPayload: ReturnType<typeof zodIsFactory<BoundWitnessDivinerQueryPayload>> = zodIsFactory(BoundWitnessDivinerQueryPayloadZod)\nexport const asBoundWitnessDivinerQueryPayload: ReturnType<typeof zodAsFactory<BoundWitnessDivinerQueryPayload>> = zodAsFactory(BoundWitnessDivinerQueryPayloadZod, 'asBoundWitnessDivinerQueryPayload')\nexport const toBoundWitnessDivinerQueryPayload: ReturnType<typeof zodToFactory<BoundWitnessDivinerQueryPayload>> = zodToFactory(BoundWitnessDivinerQueryPayloadZod, 'toBoundWitnessD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B,UAAU,IAAI;AAGhD,IAAM,qCAOP;AAAA,EACF,UAAO,mBAAmB,8BAA8B,GAAG,EAAE,GAAG,eAAe,MAAM,CAAC;AAAA,EACtF,UAAqC;AACzC;AAIO,IAAM,oCAAsGC,cAAa,kCAAkC;AAC3J,IAAM,oCAAsGC,cAAa,oCAAoC,mCAAmC;AAChM,IAAM,oCAAsGC,cAAa,oCAAoC,mCAAmC;;;AJ2BhM,IAAM,4BAAN,cAIG,oBAAwC;AAAA,EAChD,MAAyB,cAAc,UAAmC;AACxE,UAAM,SAASC,UAAS,UAAU,OAAO,iCAAiC,GAAG,IAAI,GAAG,MAAM,uBAAuB;AACjH,UAAM,YAAYA,UAAS,MAAM,KAAK,kBAAkB,GAAG,MAAM,6BAA6B;AAC9F,UAAM,OAAQ,MAAM,WAAW,KAAK,EAAE,OAAO,IAAO,CAAC,KAAM,CAAC,GAAG,OAAO,OAAKC,gBAAe,CAAC,KAAK,cAAc,CAAC,CAAC;AAChH,WAAO,qCAAqC,QAAQ,GAAG;AAAA,EACzD;AACF;",
4
+ "sourcesContent": ["import {\n assertEx, containsAll,\n exists, hexFromHexString,\n} from '@ariestools/sdk'\nimport type {\n BoundWitness, Payload, WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport {\n isBoundWitness, PayloadBuilder, SequenceConstants,\n} from '@xyo-network/sdk-protocol'\n\nimport type { BoundWitnessDivinerQueryPayload } from './Query.ts'\n\n// eslint-disable-next-line complexity\nexport const applyBoundWitnessDivinerQueryPayload = (filter?: BoundWitnessDivinerQueryPayload, payloads: WithStorageMeta<Payload>[] = []): BoundWitness[] => {\n if (!filter) return []\n const {\n addresses, cursor, destination, limit, order = 'desc', payload_hashes, payload_schemas, sourceQuery,\n } = filter\n\n const sortedPayloads = PayloadBuilder.sortByStorageMeta(payloads, order === 'desc' ? -1 : 1)\n const parsedCursor = cursor ?? ((order === 'desc') ? SequenceConstants.maxLocalSequence : SequenceConstants.minLocalSequence)\n const parsedOffset = sortedPayloads.findIndex((order === 'desc') ? bw => bw._sequence < parsedCursor : bw => bw._sequence > parsedCursor)\n if (parsedOffset === -1) return []\n const payloadSubset = sortedPayloads.slice(parsedOffset)\n\n let bws = payloadSubset.filter(isBoundWitness)\n const allAddresses = addresses?.map(address => hexFromHexString(address)).filter(exists)\n if (allAddresses !== undefined && allAddresses.length > 0) bws = bws.filter(bw => containsAll<string>(bw.addresses, allAddresses))\n if (payload_hashes !== undefined && payload_hashes.length > 0) bws = bws.filter(bw => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas !== undefined && payload_schemas.length > 0) bws = bws.filter(bw => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery !== undefined && sourceQuery !== '') bws = bws.filter(bw => bw?.$sourceQuery === sourceQuery)\n // If there's a destination filter of the right kind\n if (destination && Array.isArray(destination) && destination?.length > 0) {\n const targetFilter = assertEx(destination, () => 'Missing destination')\n // Find all BWs that satisfy the destination constraint\n bws = bws.filter((bw) => {\n const targetDestinationField = (bw as { $destination?: string | string[] })?.$destination\n // If the destination field is an array and contains at least one element\n // If the destination field is an array with at least one element, keep bound witnesses that contain the filter.\n return targetDestinationField !== undefined\n && Array.isArray(targetDestinationField)\n && targetDestinationField.length > 0\n && containsAll(targetFilter, targetDestinationField ?? [])\n })\n }\n const parsedLimit = limit ?? bws.length\n return bws.slice(0, parsedLimit)\n}\n", "import { assertEx } from '@ariestools/sdk'\nimport { type BoundWitness, isBoundWitness } from '@xyo-network/sdk-protocol'\nimport { isStorageMeta } from '@xyo-network/sdk-protocol'\n\nimport { applyBoundWitnessDivinerQueryPayload } from './applyBoundWitnessDivinerQueryPayload.ts'\nimport { BoundWitnessDiviner } from './BoundWitnessDiviner.ts'\nimport type { BoundWitnessDivinerParams } from './Params.ts'\nimport { type BoundWitnessDivinerQueryPayload, isBoundWitnessDivinerQueryPayload } from './Query.ts'\n\nexport interface EqualityComparisonOperators {\n /**\n * 'Not Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value does not match the provided string.\n * Example: field != 'value'\n */\n '!=': string\n\n /**\n * 'Less Than' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically less than the provided string.\n * Example: field < 'value'\n */\n '<': string\n\n /**\n * 'Less Than or Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically less than or equal to the provided string.\n * Example: field <= 'value'\n */\n '<=': string\n\n /**\n * 'Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value matches the provided string exactly.\n * Example: field = 'value'\n */\n '=': string\n\n /**\n * 'Greater Than' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically greater than the provided string.\n * Example: field > 'value'\n */\n '>': string\n\n /**\n * 'Greater Than or Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically greater than or equal to the provided string.\n * Example: field >= 'value'\n */\n '>=': string\n}\n\nexport class MemoryBoundWitnessDiviner<\n TParams extends BoundWitnessDivinerParams = BoundWitnessDivinerParams,\n TIn extends BoundWitnessDivinerQueryPayload = BoundWitnessDivinerQueryPayload,\n TOut extends BoundWitness = BoundWitness,\n> extends BoundWitnessDiviner<TParams, TIn, TOut> {\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const bws = ((await archivist?.next({ limit: 10_000 })) ?? []).filter(x => isBoundWitness(x) && isStorageMeta(x))\n return applyBoundWitnessDivinerQueryPayload(filter, bws) as TOut[]\n }\n}\n", "import type { BoundWitness, Schema } from '@xyo-network/sdk-protocol'\n\nimport { AbstractDiviner } from '#diviner-abstract'\nimport type { DivinerInstance, DivinerModuleEventData } from '#diviner-model'\n\nimport { BoundWitnessDivinerConfigSchema } from './Config.ts'\nimport type { BoundWitnessDivinerParams } from './Params.ts'\nimport type { BoundWitnessDivinerQueryPayload } from './Query.ts'\n\nexport abstract class BoundWitnessDiviner<\n TParams extends BoundWitnessDivinerParams = BoundWitnessDivinerParams,\n TIn extends BoundWitnessDivinerQueryPayload = BoundWitnessDivinerQueryPayload,\n TOut extends BoundWitness = BoundWitness,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, BoundWitnessDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = BoundWitnessDivinerConfigSchema\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, type Payload } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { DivinerConfig } from '#diviner-model'\nimport { DivinerConfigZod } from '#diviner-model'\n\nimport { BoundWitnessDivinerSchema } from './Schema.ts'\n\nexport const BoundWitnessDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${BoundWitnessDivinerSchema}.config`, true)\nexport type BoundWitnessDivinerConfigSchema = typeof BoundWitnessDivinerConfigSchema\n\nexport const BoundWitnessDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n schema: z.ZodMiniLiteral<BoundWitnessDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, { schema: z.literal(BoundWitnessDivinerConfigSchema) })\n\nexport type BoundWitnessDivinerConfigBase = z.infer<typeof BoundWitnessDivinerConfigZod>\n\nexport const isBoundWitnessDivinerConfig: ReturnType<typeof zodIsFactory<BoundWitnessDivinerConfigBase>> = zodIsFactory(BoundWitnessDivinerConfigZod)\nexport const asBoundWitnessDivinerConfig: ReturnType<typeof zodAsFactory<BoundWitnessDivinerConfigBase>> = zodAsFactory(BoundWitnessDivinerConfigZod, 'asBoundWitnessDivinerConfig')\nexport const toBoundWitnessDivinerConfig: ReturnType<typeof zodToFactory<BoundWitnessDivinerConfigBase>> = zodToFactory(BoundWitnessDivinerConfigZod, 'toBoundWitnessDivinerConfig')\n\nexport type BoundWitnessDivinerConfig<T extends Payload = Payload> = DivinerConfig<\n T & {\n schema: BoundWitnessDivinerConfigSchema\n }\n>\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nexport const BoundWitnessDivinerSchema: 'network.xyo.diviner.boundwitness' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.boundwitness', true)\nexport type BoundWitnessDivinerSchema = typeof BoundWitnessDivinerSchema\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport {\n asSchema, PayloadZodOfSchema, QueryFieldsZod,\n} from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { BoundWitnessDivinerPredicate } from './Predicate.ts'\nimport { BoundWitnessDivinerSchema } from './Schema.ts'\n\nexport const BoundWitnessDivinerQuerySchema: string & {\n readonly __schema: true\n} = asSchema(`${BoundWitnessDivinerSchema}.query`, true)\nexport type BoundWitnessDivinerQuerySchema = typeof BoundWitnessDivinerQuerySchema\n\nexport const BoundWitnessDivinerQueryPayloadZod: z.ZodMiniIntersection<\n z.ZodMiniObject<\n & { schema: z.ZodMiniLiteral<BoundWitnessDivinerQuerySchema> }\n & (typeof QueryFieldsZod)['shape'],\n z.core.$strip\n >,\n z.ZodMiniCustom<BoundWitnessDivinerPredicate, BoundWitnessDivinerPredicate>\n> = z.intersection(\n z.extend(PayloadZodOfSchema(BoundWitnessDivinerQuerySchema), { ...QueryFieldsZod.shape }),\n z.custom<BoundWitnessDivinerPredicate>(),\n)\n\nexport type BoundWitnessDivinerQueryPayload = z.infer<typeof BoundWitnessDivinerQueryPayloadZod>\n\nexport const isBoundWitnessDivinerQueryPayload: ReturnType<typeof zodIsFactory<BoundWitnessDivinerQueryPayload>> = zodIsFactory(BoundWitnessDivinerQueryPayloadZod)\nexport const asBoundWitnessDivinerQueryPayload: ReturnType<typeof zodAsFactory<BoundWitnessDivinerQueryPayload>> = zodAsFactory(BoundWitnessDivinerQueryPayloadZod, 'asBoundWitnessDivinerQueryPayload')\nexport const toBoundWitnessDivinerQueryPayload: ReturnType<typeof zodToFactory<BoundWitnessDivinerQueryPayload>> = zodToFactory(BoundWitnessDivinerQueryPayloadZod, 'toBoundWitnessDivinerQueryPayload')\n"],
5
+ "mappings": ";AAAA;AAAA,EACE;AAAA,EAAU;AAAA,EACV;AAAA,EAAQ;AAAA,OACH;AAIP;AAAA,EACE;AAAA,EAAgB;AAAA,EAAgB;AAAA,OAC3B;AAKA,IAAM,uCAAuC,CAAC,QAA0C,WAAuC,CAAC,MAAsB;AAC3J,MAAI,CAAC,OAAQ,QAAO,CAAC;AACrB,QAAM;AAAA,IACJ;AAAA,IAAW;AAAA,IAAQ;AAAA,IAAa;AAAA,IAAO,QAAQ;AAAA,IAAQ;AAAA,IAAgB;AAAA,IAAiB;AAAA,EAC1F,IAAI;AAEJ,QAAM,iBAAiB,eAAe,kBAAkB,UAAU,UAAU,SAAS,KAAK,CAAC;AAC3F,QAAM,eAAe,WAAY,UAAU,SAAU,kBAAkB,mBAAmB,kBAAkB;AAC5G,QAAM,eAAe,eAAe,UAAW,UAAU,SAAU,QAAM,GAAG,YAAY,eAAe,QAAM,GAAG,YAAY,YAAY;AACxI,MAAI,iBAAiB,GAAI,QAAO,CAAC;AACjC,QAAM,gBAAgB,eAAe,MAAM,YAAY;AAEvD,MAAI,MAAM,cAAc,OAAO,cAAc;AAC7C,QAAM,eAAe,WAAW,IAAI,aAAW,iBAAiB,OAAO,CAAC,EAAE,OAAO,MAAM;AACvF,MAAI,iBAAiB,UAAa,aAAa,SAAS,EAAG,OAAM,IAAI,OAAO,QAAM,YAAoB,GAAG,WAAW,YAAY,CAAC;AACjI,MAAI,mBAAmB,UAAa,eAAe,SAAS,EAAG,OAAM,IAAI,OAAO,QAAM,YAAY,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+BAA+B;AAAA,EAC3G,OAAyB,sBAA8B;AACzD;;;AGrBA;AAAA,EACE,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,OACvB;AACP;AAAA,EACE,YAAAC;AAAA,EAAU;AAAA,EAAoB;AAAA,OACzB;AACP,YAAYC,QAAO;AAKZ,IAAM,iCAETC,UAAS,GAAG,yBAAyB,UAAU,IAAI;AAGhD,IAAM,qCAOP;AAAA,EACF,UAAO,mBAAmB,8BAA8B,GAAG,EAAE,GAAG,eAAe,MAAM,CAAC;AAAA,EACtF,UAAqC;AACzC;AAIO,IAAM,oCAAsGC,cAAa,kCAAkC;AAC3J,IAAM,oCAAsGC,cAAa,oCAAoC,mCAAmC;AAChM,IAAM,oCAAsGC,cAAa,oCAAoC,mCAAmC;;;AJ2BhM,IAAM,4BAAN,cAIG,oBAAwC;AAAA,EAChD,MAAyB,cAAc,UAAmC;AACxE,UAAM,SAASC,UAAS,UAAU,OAAO,iCAAiC,GAAG,IAAI,GAAG,MAAM,uBAAuB;AACjH,UAAM,YAAYA,UAAS,MAAM,KAAK,kBAAkB,GAAG,MAAM,6BAA6B;AAC9F,UAAM,OAAQ,MAAM,WAAW,KAAK,EAAE,OAAO,IAAO,CAAC,KAAM,CAAC,GAAG,OAAO,OAAKC,gBAAe,CAAC,KAAK,cAAc,CAAC,CAAC;AAChH,WAAO,qCAAqC,QAAQ,GAAG;AAAA,EACzD;AACF;",
6
6
  "names": ["assertEx", "isBoundWitness", "asSchema", "asSchema", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "z", "asSchema", "zodIsFactory", "zodAsFactory", "zodToFactory", "assertEx", "isBoundWitness"]
7
7
  }
@@ -54,7 +54,7 @@ var applyBoundWitnessDivinerQueryPayload = (filter, payloads = []) => {
54
54
  } = filter;
55
55
  const sortedPayloads = PayloadBuilder.sortByStorageMeta(payloads, order === "desc" ? -1 : 1);
56
56
  const parsedCursor = cursor ?? (order === "desc" ? SequenceConstants.maxLocalSequence : SequenceConstants.minLocalSequence);
57
- const parsedOffset = order === "desc" ? sortedPayloads.findIndex((bw) => bw._sequence < parsedCursor) : sortedPayloads.findIndex((bw) => bw._sequence > parsedCursor);
57
+ const parsedOffset = sortedPayloads.findIndex(order === "desc" ? (bw) => bw._sequence < parsedCursor : (bw) => bw._sequence > parsedCursor);
58
58
  if (parsedOffset === -1) return [];
59
59
  const payloadSubset = sortedPayloads.slice(parsedOffset);
60
60
  let bws = payloadSubset.filter(isBoundWitness);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/modules/diviner-boundwitness/BoundWitnessDiviner.ts", "../../src/modules/diviner-boundwitness/Config.ts", "../../src/modules/diviner-boundwitness/Schema.ts", "../../src/modules/diviner-boundwitness/applyBoundWitnessDivinerQueryPayload.ts", "../../src/modules/diviner-boundwitness/MemoryBoundWitnessDiviner.ts", "../../src/modules/diviner-boundwitness/Query.ts"],
4
- "sourcesContent": ["import type { BoundWitness, Schema } from '@xyo-network/sdk-protocol'\n\nimport { AbstractDiviner } from '#diviner-abstract'\nimport type { DivinerInstance, DivinerModuleEventData } from '#diviner-model'\n\nimport { BoundWitnessDivinerConfigSchema } from './Config.ts'\nimport type { BoundWitnessDivinerParams } from './Params.ts'\nimport type { BoundWitnessDivinerQueryPayload } from './Query.ts'\n\nexport abstract class BoundWitnessDiviner<\n TParams extends BoundWitnessDivinerParams = BoundWitnessDivinerParams,\n TIn extends BoundWitnessDivinerQueryPayload = BoundWitnessDivinerQueryPayload,\n TOut extends BoundWitness = BoundWitness,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, BoundWitnessDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = BoundWitnessDivinerConfigSchema\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, type Payload } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { DivinerConfig } from '#diviner-model'\nimport { DivinerConfigZod } from '#diviner-model'\n\nimport { BoundWitnessDivinerSchema } from './Schema.ts'\n\nexport const BoundWitnessDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${BoundWitnessDivinerSchema}.config`, true)\nexport type BoundWitnessDivinerConfigSchema = typeof BoundWitnessDivinerConfigSchema\n\nexport const BoundWitnessDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n schema: z.ZodMiniLiteral<BoundWitnessDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, { schema: z.literal(BoundWitnessDivinerConfigSchema) })\n\nexport type BoundWitnessDivinerConfigBase = z.infer<typeof BoundWitnessDivinerConfigZod>\n\nexport const isBoundWitnessDivinerConfig: ReturnType<typeof zodIsFactory<BoundWitnessDivinerConfigBase>> = zodIsFactory(BoundWitnessDivinerConfigZod)\nexport const asBoundWitnessDivinerConfig: ReturnType<typeof zodAsFactory<BoundWitnessDivinerConfigBase>> = zodAsFactory(BoundWitnessDivinerConfigZod, 'asBoundWitnessDivinerConfig')\nexport const toBoundWitnessDivinerConfig: ReturnType<typeof zodToFactory<BoundWitnessDivinerConfigBase>> = zodToFactory(BoundWitnessDivinerConfigZod, 'toBoundWitnessDivinerConfig')\n\nexport type BoundWitnessDivinerConfig<T extends Payload = Payload> = DivinerConfig<\n T & {\n schema: BoundWitnessDivinerConfigSchema\n }\n>\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nexport const BoundWitnessDivinerSchema: 'network.xyo.diviner.boundwitness' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.boundwitness', true)\nexport type BoundWitnessDivinerSchema = typeof BoundWitnessDivinerSchema\n", "import {\n assertEx, containsAll,\n exists, hexFromHexString,\n} from '@ariestools/sdk'\nimport type {\n BoundWitness, Payload, WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport {\n isBoundWitness, PayloadBuilder, SequenceConstants,\n} from '@xyo-network/sdk-protocol'\n\nimport type { BoundWitnessDivinerQueryPayload } from './Query.ts'\n\n// eslint-disable-next-line complexity\nexport const applyBoundWitnessDivinerQueryPayload = (filter?: BoundWitnessDivinerQueryPayload, payloads: WithStorageMeta<Payload>[] = []): BoundWitness[] => {\n if (!filter) return []\n const {\n addresses, cursor, destination, limit, order = 'desc', payload_hashes, payload_schemas, sourceQuery,\n } = filter\n\n const sortedPayloads = PayloadBuilder.sortByStorageMeta(payloads, order === 'desc' ? -1 : 1)\n const parsedCursor = cursor ?? ((order === 'desc') ? SequenceConstants.maxLocalSequence : SequenceConstants.minLocalSequence)\n const parsedOffset = (order === 'desc')\n ? sortedPayloads.findIndex(bw => bw._sequence < parsedCursor)\n : sortedPayloads.findIndex(bw => bw._sequence > parsedCursor)\n if (parsedOffset === -1) return []\n const payloadSubset = sortedPayloads.slice(parsedOffset)\n\n let bws = payloadSubset.filter(isBoundWitness)\n const allAddresses = addresses?.map(address => hexFromHexString(address)).filter(exists)\n if (allAddresses !== undefined && allAddresses.length > 0) bws = bws.filter(bw => containsAll<string>(bw.addresses, allAddresses))\n if (payload_hashes !== undefined && payload_hashes.length > 0) bws = bws.filter(bw => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas !== undefined && payload_schemas.length > 0) bws = bws.filter(bw => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery !== undefined && sourceQuery !== '') bws = bws.filter(bw => bw?.$sourceQuery === sourceQuery)\n // If there's a destination filter of the right kind\n if (destination && Array.isArray(destination) && destination?.length > 0) {\n const targetFilter = assertEx(destination, () => 'Missing destination')\n // Find all BWs that satisfy the destination constraint\n bws = bws.filter((bw) => {\n const targetDestinationField = (bw as { $destination?: string | string[] })?.$destination\n // If the destination field is an array and contains at least one element\n // If the destination field is an array with at least one element, keep bound witnesses that contain the filter.\n return targetDestinationField !== undefined\n && Array.isArray(targetDestinationField)\n && targetDestinationField.length > 0\n && containsAll(targetFilter, targetDestinationField ?? [])\n })\n }\n const parsedLimit = limit ?? bws.length\n return bws.slice(0, parsedLimit)\n}\n", "import { assertEx } from '@ariestools/sdk'\nimport { type BoundWitness, isBoundWitness } from '@xyo-network/sdk-protocol'\nimport { isStorageMeta } from '@xyo-network/sdk-protocol'\n\nimport { applyBoundWitnessDivinerQueryPayload } from './applyBoundWitnessDivinerQueryPayload.ts'\nimport { BoundWitnessDiviner } from './BoundWitnessDiviner.ts'\nimport type { BoundWitnessDivinerParams } from './Params.ts'\nimport { type BoundWitnessDivinerQueryPayload, isBoundWitnessDivinerQueryPayload } from './Query.ts'\n\nexport interface EqualityComparisonOperators {\n /**\n * 'Not Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value does not match the provided string.\n * Example: field != 'value'\n */\n '!=': string\n\n /**\n * 'Less Than' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically less than the provided string.\n * Example: field < 'value'\n */\n '<': string\n\n /**\n * 'Less Than or Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically less than or equal to the provided string.\n * Example: field <= 'value'\n */\n '<=': string\n\n /**\n * 'Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value matches the provided string exactly.\n * Example: field = 'value'\n */\n '=': string\n\n /**\n * 'Greater Than' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically greater than the provided string.\n * Example: field > 'value'\n */\n '>': string\n\n /**\n * 'Greater Than or Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically greater than or equal to the provided string.\n * Example: field >= 'value'\n */\n '>=': string\n}\n\nexport class MemoryBoundWitnessDiviner<\n TParams extends BoundWitnessDivinerParams = BoundWitnessDivinerParams,\n TIn extends BoundWitnessDivinerQueryPayload = BoundWitnessDivinerQueryPayload,\n TOut extends BoundWitness = BoundWitness,\n> extends BoundWitnessDiviner<TParams, TIn, TOut> {\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const bws = ((await archivist?.next({ limit: 10_000 })) ?? []).filter(x => isBoundWitness(x) && isStorageMeta(x))\n return applyBoundWitnessDivinerQueryPayload(filter, bws) as TOut[]\n }\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport {\n asSchema, PayloadZodOfSchema, QueryFieldsZod,\n} from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { BoundWitnessDivinerPredicate } from './Predicate.ts'\nimport { BoundWitnessDivinerSchema } from './Schema.ts'\n\nexport const BoundWitnessDivinerQuerySchema: string & {\n readonly __schema: true\n} = asSchema(`${BoundWitnessDivinerSchema}.query`, true)\nexport type BoundWitnessDivinerQuerySchema = typeof BoundWitnessDivinerQuerySchema\n\nexport const BoundWitnessDivinerQueryPayloadZod: z.ZodMiniIntersection<\n z.ZodMiniObject<\n & { schema: z.ZodMiniLiteral<BoundWitnessDivinerQuerySchema> }\n & (typeof QueryFieldsZod)['shape'],\n z.core.$strip\n >,\n z.ZodMiniCustom<BoundWitnessDivinerPredicate, BoundWitnessDivinerPredicate>\n> = z.intersection(\n z.extend(PayloadZodOfSchema(BoundWitnessDivinerQuerySchema), { ...QueryFieldsZod.shape }),\n z.custom<BoundWitnessDivinerPredicate>(),\n)\n\nexport type BoundWitnessDivinerQueryPayload = z.infer<typeof BoundWitnessDivinerQueryPayloadZod>\n\nexport const isBoundWitnessDivinerQueryPayload: ReturnType<typeof zodIsFactory<BoundWitnessDivinerQueryPayload>> = zodIsFactory(BoundWitnessDivinerQueryPayloadZod)\nexport const asBoundWitnessDivinerQueryPayload: ReturnType<typeof zodAsFactory<BoundWitnessDivinerQueryPayload>> = zodAsFactory(BoundWitnessDivinerQueryPayloadZod, 'asBoundWitnessDivinerQueryPayload')\nexport const toBoundWitnessDivinerQueryPayload: ReturnType<typeof zodToFactory<BoundWitnessDivinerQueryPayload>> = zodToFactory(BoundWitnessDivinerQueryPayloadZod, 'toBoundWitnessDivinerQueryPayload')\n"],
5
- "mappings": ";AAEA,SAAS,uBAAuB;;;ACFhC;AAAA,EACE;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AACP,SAAS,YAAAA,iBAA8B;AACvC,YAAY,OAAO;AAGnB,SAAS,wBAAwB;;;ACPjC,SAAS,gBAAgB;AAElB,IAAM,4BAET,SAAS,oCAAoC,IAAI;;;ADO9C,IAAM,kCAETC,UAAS,GAAG,yBAAyB,WAAW,IAAI;AAGjD,IAAM,+BAKP,SAAO,kBAAkB,EAAE,QAAU,UAAQ,+BAA+B,EAAE,CAAC;AAI9E,IAAM,8BAA8F,aAAa,4BAA4B;AAC7I,IAAM,8BAA8F,aAAa,8BAA8B,6BAA6B;AAC5K,IAAM,8BAA8F,aAAa,8BAA8B,6BAA6B;;;ADlB5K,IAAe,sBAAf,cASG,gBAAgD;AAAA,EACxD,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,+BAA+B;AAAA,EAC3G,OAAyB,sBAA8B;AACzD;;;AGrBA;AAAA,EACE;AAAA,EAAU;AAAA,EACV;AAAA,EAAQ;AAAA,OACH;AAIP;AAAA,EACE;AAAA,EAAgB;AAAA,EAAgB;AAAA,OAC3B;AAKA,IAAM,uCAAuC,CAAC,QAA0C,WAAuC,CAAC,MAAsB;AAC3J,MAAI,CAAC,OAAQ,QAAO,CAAC;AACrB,QAAM;AAAA,IACJ;AAAA,IAAW;AAAA,IAAQ;AAAA,IAAa;AAAA,IAAO,QAAQ;AAAA,IAAQ;AAAA,IAAgB;AAAA,IAAiB;AAAA,EAC1F,IAAI;AAEJ,QAAM,iBAAiB,eAAe,kBA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B;AAClD,SAAS,qBAAqB;;;ACF9B;AAAA,EACE,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,OACvB;AACP;AAAA,EACE,YAAAC;AAAA,EAAU;AAAA,EAAoB;AAAA,OACzB;AACP,YAAYC,QAAO;AAKZ,IAAM,iCAETC,UAAS,GAAG,yBAAyB,UAAU,IAAI;AAGhD,IAAM,qCAOP;AAAA,EACF,UAAO,mBAAmB,8BAA8B,GAAG,EAAE,GAAG,eAAe,MAAM,CAAC;AAAA,EACtF,UAAqC;AACzC;AAIO,IAAM,oCAAsGC,cAAa,kCAAkC;AAC3J,IAAM,oCAAsGC,cAAa,oCAAoC,mCAAmC;AAChM,IAAM,oCAAsGC,cAAa,oCAAoC,mCAAmC;;;AD2BhM,IAAM,4BAAN,cAIG,oBAAwC;AAAA,EAChD,MAAyB,cAAc,UAAmC;AACxE,UAAM,SAASC,UAAS,UAAU,OAAO,iCAAiC,GAAG,IAAI,GAAG,MAAM,uBAAuB;AACjH,UAAM,YAAYA,UAAS,MAAM,KAAK,kBAAkB,GAAG,MAAM,6BAA6B;AAC9F,UAAM,OAAQ,MAAM,WAAW,KAAK,EAAE,OAAO,IAAO,CAAC,KAAM,CAAC,GAAG,OAAO,OAAKC,gBAAe,CAAC,KAAK,cAAc,CAAC,CAAC;AAChH,WAAO,qCAAqC,QAAQ,GAAG;AAAA,EACzD;AACF;",
4
+ "sourcesContent": ["import type { BoundWitness, Schema } from '@xyo-network/sdk-protocol'\n\nimport { AbstractDiviner } from '#diviner-abstract'\nimport type { DivinerInstance, DivinerModuleEventData } from '#diviner-model'\n\nimport { BoundWitnessDivinerConfigSchema } from './Config.ts'\nimport type { BoundWitnessDivinerParams } from './Params.ts'\nimport type { BoundWitnessDivinerQueryPayload } from './Query.ts'\n\nexport abstract class BoundWitnessDiviner<\n TParams extends BoundWitnessDivinerParams = BoundWitnessDivinerParams,\n TIn extends BoundWitnessDivinerQueryPayload = BoundWitnessDivinerQueryPayload,\n TOut extends BoundWitness = BoundWitness,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, BoundWitnessDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = BoundWitnessDivinerConfigSchema\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, type Payload } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { DivinerConfig } from '#diviner-model'\nimport { DivinerConfigZod } from '#diviner-model'\n\nimport { BoundWitnessDivinerSchema } from './Schema.ts'\n\nexport const BoundWitnessDivinerConfigSchema: string & {\n readonly __schema: true\n} = asSchema(`${BoundWitnessDivinerSchema}.config`, true)\nexport type BoundWitnessDivinerConfigSchema = typeof BoundWitnessDivinerConfigSchema\n\nexport const BoundWitnessDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n schema: z.ZodMiniLiteral<BoundWitnessDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, { schema: z.literal(BoundWitnessDivinerConfigSchema) })\n\nexport type BoundWitnessDivinerConfigBase = z.infer<typeof BoundWitnessDivinerConfigZod>\n\nexport const isBoundWitnessDivinerConfig: ReturnType<typeof zodIsFactory<BoundWitnessDivinerConfigBase>> = zodIsFactory(BoundWitnessDivinerConfigZod)\nexport const asBoundWitnessDivinerConfig: ReturnType<typeof zodAsFactory<BoundWitnessDivinerConfigBase>> = zodAsFactory(BoundWitnessDivinerConfigZod, 'asBoundWitnessDivinerConfig')\nexport const toBoundWitnessDivinerConfig: ReturnType<typeof zodToFactory<BoundWitnessDivinerConfigBase>> = zodToFactory(BoundWitnessDivinerConfigZod, 'toBoundWitnessDivinerConfig')\n\nexport type BoundWitnessDivinerConfig<T extends Payload = Payload> = DivinerConfig<\n T & {\n schema: BoundWitnessDivinerConfigSchema\n }\n>\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nexport const BoundWitnessDivinerSchema: 'network.xyo.diviner.boundwitness' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.boundwitness', true)\nexport type BoundWitnessDivinerSchema = typeof BoundWitnessDivinerSchema\n", "import {\n assertEx, containsAll,\n exists, hexFromHexString,\n} from '@ariestools/sdk'\nimport type {\n BoundWitness, Payload, WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport {\n isBoundWitness, PayloadBuilder, SequenceConstants,\n} from '@xyo-network/sdk-protocol'\n\nimport type { BoundWitnessDivinerQueryPayload } from './Query.ts'\n\n// eslint-disable-next-line complexity\nexport const applyBoundWitnessDivinerQueryPayload = (filter?: BoundWitnessDivinerQueryPayload, payloads: WithStorageMeta<Payload>[] = []): BoundWitness[] => {\n if (!filter) return []\n const {\n addresses, cursor, destination, limit, order = 'desc', payload_hashes, payload_schemas, sourceQuery,\n } = filter\n\n const sortedPayloads = PayloadBuilder.sortByStorageMeta(payloads, order === 'desc' ? -1 : 1)\n const parsedCursor = cursor ?? ((order === 'desc') ? SequenceConstants.maxLocalSequence : SequenceConstants.minLocalSequence)\n const parsedOffset = sortedPayloads.findIndex((order === 'desc') ? bw => bw._sequence < parsedCursor : bw => bw._sequence > parsedCursor)\n if (parsedOffset === -1) return []\n const payloadSubset = sortedPayloads.slice(parsedOffset)\n\n let bws = payloadSubset.filter(isBoundWitness)\n const allAddresses = addresses?.map(address => hexFromHexString(address)).filter(exists)\n if (allAddresses !== undefined && allAddresses.length > 0) bws = bws.filter(bw => containsAll<string>(bw.addresses, allAddresses))\n if (payload_hashes !== undefined && payload_hashes.length > 0) bws = bws.filter(bw => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas !== undefined && payload_schemas.length > 0) bws = bws.filter(bw => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery !== undefined && sourceQuery !== '') bws = bws.filter(bw => bw?.$sourceQuery === sourceQuery)\n // If there's a destination filter of the right kind\n if (destination && Array.isArray(destination) && destination?.length > 0) {\n const targetFilter = assertEx(destination, () => 'Missing destination')\n // Find all BWs that satisfy the destination constraint\n bws = bws.filter((bw) => {\n const targetDestinationField = (bw as { $destination?: string | string[] })?.$destination\n // If the destination field is an array and contains at least one element\n // If the destination field is an array with at least one element, keep bound witnesses that contain the filter.\n return targetDestinationField !== undefined\n && Array.isArray(targetDestinationField)\n && targetDestinationField.length > 0\n && containsAll(targetFilter, targetDestinationField ?? [])\n })\n }\n const parsedLimit = limit ?? bws.length\n return bws.slice(0, parsedLimit)\n}\n", "import { assertEx } from '@ariestools/sdk'\nimport { type BoundWitness, isBoundWitness } from '@xyo-network/sdk-protocol'\nimport { isStorageMeta } from '@xyo-network/sdk-protocol'\n\nimport { applyBoundWitnessDivinerQueryPayload } from './applyBoundWitnessDivinerQueryPayload.ts'\nimport { BoundWitnessDiviner } from './BoundWitnessDiviner.ts'\nimport type { BoundWitnessDivinerParams } from './Params.ts'\nimport { type BoundWitnessDivinerQueryPayload, isBoundWitnessDivinerQueryPayload } from './Query.ts'\n\nexport interface EqualityComparisonOperators {\n /**\n * 'Not Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value does not match the provided string.\n * Example: field != 'value'\n */\n '!=': string\n\n /**\n * 'Less Than' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically less than the provided string.\n * Example: field < 'value'\n */\n '<': string\n\n /**\n * 'Less Than or Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically less than or equal to the provided string.\n * Example: field <= 'value'\n */\n '<=': string\n\n /**\n * 'Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value matches the provided string exactly.\n * Example: field = 'value'\n */\n '=': string\n\n /**\n * 'Greater Than' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically greater than the provided string.\n * Example: field > 'value'\n */\n '>': string\n\n /**\n * 'Greater Than or Equal To' comparison operator.\n * Compares the field with the specified string value,\n * selecting records where the field value is lexicographically greater than or equal to the provided string.\n * Example: field >= 'value'\n */\n '>=': string\n}\n\nexport class MemoryBoundWitnessDiviner<\n TParams extends BoundWitnessDivinerParams = BoundWitnessDivinerParams,\n TIn extends BoundWitnessDivinerQueryPayload = BoundWitnessDivinerQueryPayload,\n TOut extends BoundWitness = BoundWitness,\n> extends BoundWitnessDiviner<TParams, TIn, TOut> {\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const bws = ((await archivist?.next({ limit: 10_000 })) ?? []).filter(x => isBoundWitness(x) && isStorageMeta(x))\n return applyBoundWitnessDivinerQueryPayload(filter, bws) as TOut[]\n }\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport {\n asSchema, PayloadZodOfSchema, QueryFieldsZod,\n} from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport type { BoundWitnessDivinerPredicate } from './Predicate.ts'\nimport { BoundWitnessDivinerSchema } from './Schema.ts'\n\nexport const BoundWitnessDivinerQuerySchema: string & {\n readonly __schema: true\n} = asSchema(`${BoundWitnessDivinerSchema}.query`, true)\nexport type BoundWitnessDivinerQuerySchema = typeof BoundWitnessDivinerQuerySchema\n\nexport const BoundWitnessDivinerQueryPayloadZod: z.ZodMiniIntersection<\n z.ZodMiniObject<\n & { schema: z.ZodMiniLiteral<BoundWitnessDivinerQuerySchema> }\n & (typeof QueryFieldsZod)['shape'],\n z.core.$strip\n >,\n z.ZodMiniCustom<BoundWitnessDivinerPredicate, BoundWitnessDivinerPredicate>\n> = z.intersection(\n z.extend(PayloadZodOfSchema(BoundWitnessDivinerQuerySchema), { ...QueryFieldsZod.shape }),\n z.custom<BoundWitnessDivinerPredicate>(),\n)\n\nexport type BoundWitnessDivinerQueryPayload = z.infer<typeof BoundWitnessDivinerQueryPayloadZod>\n\nexport const isBoundWitnessDivinerQueryPayload: ReturnType<typeof zodIsFactory<BoundWitnessDivinerQueryPayload>> = zodIsFactory(BoundWitnessDivinerQueryPayloadZod)\nexport const asBoundWitnessDivinerQueryPayload: ReturnType<typeof zodAsFactory<BoundWitnessDivinerQueryPayload>> = zodAsFactory(BoundWitnessDivinerQueryPayloadZod, 'asBoundWitnessDivinerQueryPayload')\nexport const toBoundWitnessDivinerQueryPayload: ReturnType<typeof zodToFactory<BoundWitnessDivinerQueryPayload>> = zodToFactory(BoundWitnessDivinerQueryPayloadZod, 'toBoundWitnessDivinerQueryPayload')\n"],
5
+ "mappings": ";AAEA,SAAS,uBAAuB;;;ACFhC;AAAA,EACE;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AACP,SAAS,YAAAA,iBAA8B;AACvC,YAAY,OAAO;AAGnB,SAAS,wBAAwB;;;ACPjC,SAAS,gBAAgB;AAElB,IAAM,4BAET,SAAS,oCAAoC,IAAI;;;ADO9C,IAAM,kCAETC,UAAS,GAAG,yBAAyB,WAAW,IAAI;AAGjD,IAAM,+BAKP,SAAO,kBAAkB,EAAE,QAAU,UAAQ,+BAA+B,EAAE,CAAC;AAI9E,IAAM,8BAA8F,aAAa,4BAA4B;AAC7I,IAAM,8BAA8F,aAAa,8BAA8B,6BAA6B;AAC5K,IAAM,8BAA8F,aAAa,8BAA8B,6BAA6B;;;ADlB5K,IAAe,sBAAf,cASG,gBAAgD;AAAA,EACxD,OAAyB,gBAA0B,CAAC,GAAG,MAAM,eAAe,+BAA+B;AAAA,EAC3G,OAAyB,sBAA8B;AACzD;;;AGrBA;AAAA,EACE;AAAA,EAAU;AAAA,EACV;AAAA,EAAQ;AAAA,OACH;AAIP;AAAA,EACE;AAAA,EAAgB;AAAA,EAAgB;AAAA,OAC3B;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,MAAM,QAAQ,sBAAsB,KACpC,uBAAuB,SAAS,KAChC,YAAY,cAAc,0BAA0B,CAAC,CAAC;AAAA,IAC7D,CAAC;AAAA,EACH;AACA,QAAM,cAAc,SAAS,IAAI;AACjC,SAAO,IAAI,MAAM,GAAG,WAAW;AACjC;;;AChDA,SAAS,YAAAC,iBAAgB;AACzB,SAA4B,kBAAAC,uBAAsB;AAClD,SAAS,qBAAqB;;;ACF9B;AAAA,EACE,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,EAAc,gBAAAC;AAAA,OACvB;AACP;AAAA,EACE,YAAAC;AAAA,EAAU;AAAA,EAAoB;AAAA,OACzB;AACP,YAAYC,QAAO;AAKZ,IAAM,iCAETC,UAAS,GAAG,yBAAyB,UAAU,IAAI;AAGhD,IAAM,qCAOP;AAAA,EACF,UAAO,mBAAmB,8BAA8B,GAAG,EAAE,GAAG,eAAe,MAAM,CAAC;AAAA,EACtF,UAAqC;AACzC;AAIO,IAAM,oCAAsGC,cAAa,kCAAkC;AAC3J,IAAM,oCAAsGC,cAAa,oCAAoC,mCAAmC;AAChM,IAAM,oCAAsGC,cAAa,oCAAoC,mCAAmC;;;AD2BhM,IAAM,4BAAN,cAIG,oBAAwC;AAAA,EAChD,MAAyB,cAAc,UAAmC;AACxE,UAAM,SAASC,UAAS,UAAU,OAAO,iCAAiC,GAAG,IAAI,GAAG,MAAM,uBAAuB;AACjH,UAAM,YAAYA,UAAS,MAAM,KAAK,kBAAkB,GAAG,MAAM,6BAA6B;AAC9F,UAAM,OAAQ,MAAM,WAAW,KAAK,EAAE,OAAO,IAAO,CAAC,KAAM,CAAC,GAAG,OAAO,OAAKC,gBAAe,CAAC,KAAK,cAAc,CAAC,CAAC;AAChH,WAAO,qCAAqC,QAAQ,GAAG;AAAA,EACzD;AACF;",
6
6
  "names": ["asSchema", "asSchema", "assertEx", "isBoundWitness", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "z", "asSchema", "zodIsFactory", "zodAsFactory", "zodToFactory", "assertEx", "isBoundWitness"]
7
7
  }
@@ -102,13 +102,13 @@ var GenericPayloadDiviner = class extends PayloadDiviner {
102
102
  const additionalFilterCriteria = Object.entries(props);
103
103
  for (const [prop, filter2] of additionalFilterCriteria) {
104
104
  const property = prop;
105
- all = Array.isArray(filter2) ? all.filter((payload) => filter2.every((value) => {
105
+ all = all.filter((payload) => Array.isArray(filter2) ? filter2.every((value) => {
106
106
  const prop2 = payload?.[property];
107
107
  return Array.isArray(prop2) && prop2.includes?.(value);
108
- })) : all.filter((payload) => payload?.[property] === filter2);
108
+ }) : payload?.[property] === filter2);
109
109
  }
110
110
  }
111
- return limit !== void 0 && limit !== 0 ? all.slice(0, limit) : all;
111
+ return limit === void 0 || limit === 0 ? all : all.slice(0, limit);
112
112
  }
113
113
  onArchivistCleared = () => {
114
114
  forget(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/modules/diviner-payload-generic/Diviner.ts"],
4
- "sourcesContent": ["import type { EventListener, Hex } from '@ariestools/sdk'\nimport {\n assertEx, filterAs, forget,\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { PayloadBuilder } from '@xyo-network/sdk-protocol'\nimport {\n asSchema,\n type Payload, type Schema,\n type Sequence,\n type WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport { Mutex } from 'async-mutex'\nimport * as z from 'zod/mini'\n\nimport type { ArchivistInstance, ArchivistModuleEventData } from '#archivist-model'\nimport type { DivinerInstance, DivinerModuleEventData } from '#diviner-model'\nimport { PayloadDiviner } from '#diviner-payload-abstract'\nimport type {\n Order,\n PayloadDivinerConfig,\n PayloadDivinerParams,\n PayloadDivinerQueryPayload,\n} from '#diviner-payload-model'\nimport { asPayloadDivinerQueryPayload, PayloadDivinerConfigZod } from '#diviner-payload-model'\nimport { creatableModule } from '#module-model'\n\nconst DEFAULT_INDEX_BATCH_SIZE = 100 as const\nconst DEFAULT_MAX_INDEX_SIZE = 8000 as const\n\nexport const GenericPayloadDivinerConfigSchema: 'network.xyo.diviner.payload.generic.config' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.payload.generic.config', true)\nexport type GenericPayloadDivinerConfigSchema = typeof GenericPayloadDivinerConfigSchema\n\nexport const GenericPayloadDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof PayloadDivinerConfigZod)['shape'], 'schema'> & {\n indexes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>\n schema: z.ZodMiniLiteral<GenericPayloadDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(PayloadDivinerConfigZod, {\n indexes: z.optional(z.array(z.string())),\n schema: z.literal(GenericPayloadDivinerConfigSchema),\n})\n\nexport type GenericPayloadDivinerConfigBase = z.infer<typeof GenericPayloadDivinerConfigZod>\n\nexport const isGenericPayloadDivinerConfig: ReturnType<typeof zodIsFactory<GenericPayloadDivinerConfigBase>> = zodIsFactory(GenericPayloadDivinerConfigZod)\nexport const asGenericPayloadDivinerConfig: ReturnType<typeof zodAsFactory<GenericPayloadDivinerConfigBase>> = zodAsFactory(GenericPayloadDivinerConfigZod, 'asGenericPayloadDivinerConfig')\nexport const toGenericPayloadDivinerConfig: ReturnType<typeof zodToFactory<GenericPayloadDivinerConfigBase>> = zodToFactory(GenericPayloadDivinerConfigZod, 'toGenericPayloadDivinerConfig')\n\nexport type GenericPayloadDivinerConfig = PayloadDivinerConfig<\n {\n indexes?: string[]\n },\n GenericPayloadDivinerConfigSchema\n>\n\n@creatableModule()\nexport class GenericPayloadDiviner<\n TParams extends PayloadDivinerParams<GenericPayloadDivinerConfig> = PayloadDivinerParams<GenericPayloadDivinerConfig>,\n TIn extends PayloadDivinerQueryPayload = PayloadDivinerQueryPayload,\n TOut extends WithStorageMeta<Payload> = WithStorageMeta<Payload>,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends PayloadDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, GenericPayloadDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = GenericPayloadDivinerConfigSchema\n\n protected indexMaps: Record<string, WithStorageMeta<TOut>[]> = {}\n protected payloadsWithMeta: WithStorageMeta<TOut>[] = []\n\n private _archivistInstance?: ArchivistInstance\n private _cursor?: Sequence\n private _updatePayloadPairsMutex = new Mutex()\n\n protected get indexBatchSize(): number {\n return this.config.indexBatchSize ?? DEFAULT_INDEX_BATCH_SIZE\n }\n\n protected get indexes(): string[] {\n return ['schema', ...(this.config.indexes ?? [])]\n }\n\n protected get maxIndexSize(): number {\n return this.config.maxIndexSize ?? DEFAULT_MAX_INDEX_SIZE\n }\n\n protected all(order: Order = 'desc', cursor?: Hex): WithStorageMeta<TOut>[] {\n const payloads = this.payloadsWithMeta.toSorted(PayloadBuilder.compareStorageMeta)\n if (order === 'desc') payloads.reverse()\n const startIndex = (cursor ? (payloads.findIndex(payload => payload._sequence === cursor) ?? -1) : -1) + 1\n return payloads.slice(startIndex)\n }\n\n protected override async archivistInstance(): Promise<ArchivistInstance | undefined>\n protected override async archivistInstance(required: true): Promise<ArchivistInstance>\n protected override async archivistInstance(required = false): Promise<ArchivistInstance | undefined> {\n if (!this._archivistInstance) {\n const archivist = await super.archivistInstance()\n if (required && !archivist) {\n throw new Error('Failed to find archivist')\n }\n archivist?.on('inserted', this.onArchivistInserted)\n archivist?.on('cleared', this.onArchivistCleared)\n archivist?.on('deleted', this.onArchivistDeleted)\n this._archivistInstance = archivist\n }\n return this._archivistInstance\n }\n\n protected async clearIndex(): Promise<void> {\n await this._updatePayloadPairsMutex.runExclusive(() => {\n this._cursor = undefined\n this.payloadsWithMeta = []\n this.indexMaps = {}\n })\n }\n\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n const filters = filterAs(payloads ?? [], asPayloadDivinerQueryPayload)\n assertEx(filters.length < 2, () => 'Multiple PayloadDivinerQuery payloads may not be specified')\n const filter = assertEx(filters.shift(), () => 'No PayloadDivinerQuery specified')\n await this.updateIndex()\n\n const {\n\n schema, schemas, order, limit, cursor, ...props\n } = filter\n let all: TOut[] = this.all(order, cursor)\n if (schemas !== undefined && schemas.length > 0) all = all.filter(payload => schemas.includes(payload.schema))\n if (Object.keys(props).length > 0) {\n const additionalFilterCriteria = Object.entries(props)\n for (const [prop, filter] of additionalFilterCriteria) {\n const property = prop as keyof TOut\n all\n = Array.isArray(filter)\n ? all.filter(payload =>\n filter.every((value) => {\n const prop = payload?.[property]\n // TODO: This seems to be written just to check arrays, and now that $meta is there, need to check type?\n return Array.isArray(prop) && prop.includes?.(value)\n }))\n : all.filter(payload => payload?.[property] === filter)\n }\n }\n return limit !== undefined && limit !== 0 ? all.slice(0, limit) : all\n }\n\n protected onArchivistCleared: EventListener<ArchivistModuleEventData['cleared']> = () => {\n forget(\n (async () => {\n await this.clearIndex()\n await this.updateIndex()\n })(),\n )\n }\n\n // we are just rebuilding the entire index at this point on delete since large archivists do not support delete\n protected onArchivistDeleted: EventListener<ArchivistModuleEventData['deleted']> = () => {\n forget(\n (async () => {\n await this.clearIndex()\n await this.updateIndex()\n })(),\n )\n }\n\n protected onArchivistInserted: EventListener<ArchivistModuleEventData['inserted']> = () => {\n forget(this.updateIndex())\n }\n\n protected override async stopHandler(_timeout?: number): Promise<void> {\n await super.stopHandler()\n const archivist = await this.archivistInstance(true)\n archivist.off('inserted', this.onArchivistInserted)\n archivist.off('deleted', this.onArchivistDeleted)\n archivist.off('cleared', this.onArchivistCleared)\n }\n\n // index any new payloads\n protected async updateIndex(): Promise<void> {\n await this._updatePayloadPairsMutex.runExclusive(async () => {\n const archivist = await this.archivistInstance(true)\n let newPayloads = await archivist.next({ limit: 100, cursor: this._cursor }) as TOut[]\n while (newPayloads.length > 0) {\n this._cursor = newPayloads.at(-1)?._sequence\n assertEx(this.payloadsWithMeta.length + newPayloads.length <= this.maxIndexSize, () => 'maxIndexSize exceeded')\n this.indexPayloads(newPayloads)\n newPayloads = await archivist.next({ limit: 100, cursor: this._cursor }) as TOut[]\n }\n })\n }\n\n private indexPayloads(payloads: WithStorageMeta<TOut>[]): Hex {\n this.payloadsWithMeta.push(...payloads)\n\n // update the custom indexes\n const indexes = this.indexes ?? []\n for (const index of indexes) {\n this.indexMaps[index] ??= []\n for (const payload of payloads) {\n this.indexMaps[index].push(payload)\n }\n }\n return assertEx(payloads.at(-1), () => 'No payloads to index')._sequence\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EAAU;AAAA,EAAU;AAAA,EACpB;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AACP,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,OAIK;AACP,SAAS,aAAa;AACtB,YAAY,OAAO;AAInB,SAAS,sBAAsB;AAO/B,SAAS,8BAA8B,+BAA+B;AACtE,SAAS,uBAAuB;AAEhC,IAAM,2BAA2B;AACjC,IAAM,yBAAyB;AAExB,IAAM,oCAET,SAAS,8CAA8C,IAAI;AAGxD,IAAM,iCAMP,SAAO,yBAAyB;AAAA,EACpC,SAAW,WAAW,QAAQ,SAAO,CAAC,CAAC;AAAA,EACvC,QAAU,UAAQ,iCAAiC;AACrD,CAAC;AAIM,IAAM,gCAAkG,aAAa,8BAA8B;AACnJ,IAAM,gCAAkG,aAAa,gCAAgC,+BAA+B;AACpL,IAAM,gCAAkG,aAAa,gCAAgC,+BAA+B;AAUpL,IAAM,wBAAN,cASG,eAA+C;AAAA,EAI7C,YAAqD,CAAC;AAAA,EACtD,mBAA4C,CAAC;AAAA,EAE/C;AAAA,EACA;AAAA,EACA,2BAA2B,IAAI,MAAM;AAAA,EAE7C,IAAc,iBAAyB;AACrC,WAAO,KAAK,OAAO,kBAAkB;AAAA,EACvC;AAAA,EAEA,IAAc,UAAoB;AAChC,WAAO,CAAC,UAAU,GAAI,KAAK,OAAO,WAAW,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AAM,KAAK,yBAAyB,aAAa,YAAY;AAC3D,YAAM,YAAY,MAAM,KAAK,kBAAkB,IAAI;AACnD,UAAI,cAAc,MAAM,UAAU,KAAK,EAAE,OAAO,KAAK,QAAQ,KAAK,QAAQ,CAAC;AAC3E,aAAO,YAAY,SAAS,GAAG;AAC7B,aAAK,UAAU,YAAY,GAAG,EAAE,GAAG;AACnC,iBAAS,KAAK,iBAAiB,SAAS,YAAY,UAAU,KAAK,cAAc,MAAM,uBAAuB;AAC9G,aAAK,cAAc,WAAW;AAC9B,sBAAc,MAAM,UAAU,KAAK,EAAE,OAAO,KAAK,QAAQ,KAAK,QAAQ,CAAC;AAAA,MACzE;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEQ,cAAc,UAAwC;AAC5D,SAAK,iBAAiB,KAAK,GAAG,QAAQ;AAGtC,UAAM,UAAU,KAAK,WAAW,CAAC;AACjC,eAAW,SAAS,SAAS;AAC3B,WAAK,UAAU,KAAK,MAAM,CAAC;AAC3B,iBAAW,WAAW,UAAU;AAC9B,aAAK,UAAU,KAAK,EAAE,KAAK,OAAO;AAAA,MACpC;AAAA,IACF;AACA,WAAO,SAAS,SAAS,GAAG,EAAE,GAAG,MAAM,sBAAsB,EAAE;AAAA,EACjE;AACF;AA7IE,cAVW,uBAUc,iBAA0B,CAAC,GAAG,yDAAM,kBAAe,iCAAiC;AAC7G,cAXW,uBAWc,uBAA8B;AAX5C,wBAAN;AAAA,EADN,gBAAgB;AAAA,GACJ;",
4
+ "sourcesContent": ["import type { EventListener, Hex } from '@ariestools/sdk'\nimport {\n assertEx, filterAs, forget,\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { PayloadBuilder } from '@xyo-network/sdk-protocol'\nimport {\n asSchema,\n type Payload, type Schema,\n type Sequence,\n type WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport { Mutex } from 'async-mutex'\nimport * as z from 'zod/mini'\n\nimport type { ArchivistInstance, ArchivistModuleEventData } from '#archivist-model'\nimport type { DivinerInstance, DivinerModuleEventData } from '#diviner-model'\nimport { PayloadDiviner } from '#diviner-payload-abstract'\nimport type {\n Order,\n PayloadDivinerConfig,\n PayloadDivinerParams,\n PayloadDivinerQueryPayload,\n} from '#diviner-payload-model'\nimport { asPayloadDivinerQueryPayload, PayloadDivinerConfigZod } from '#diviner-payload-model'\nimport { creatableModule } from '#module-model'\n\nconst DEFAULT_INDEX_BATCH_SIZE = 100 as const\nconst DEFAULT_MAX_INDEX_SIZE = 8000 as const\n\nexport const GenericPayloadDivinerConfigSchema: 'network.xyo.diviner.payload.generic.config' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.payload.generic.config', true)\nexport type GenericPayloadDivinerConfigSchema = typeof GenericPayloadDivinerConfigSchema\n\nexport const GenericPayloadDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof PayloadDivinerConfigZod)['shape'], 'schema'> & {\n indexes: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>\n schema: z.ZodMiniLiteral<GenericPayloadDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(PayloadDivinerConfigZod, {\n indexes: z.optional(z.array(z.string())),\n schema: z.literal(GenericPayloadDivinerConfigSchema),\n})\n\nexport type GenericPayloadDivinerConfigBase = z.infer<typeof GenericPayloadDivinerConfigZod>\n\nexport const isGenericPayloadDivinerConfig: ReturnType<typeof zodIsFactory<GenericPayloadDivinerConfigBase>> = zodIsFactory(GenericPayloadDivinerConfigZod)\nexport const asGenericPayloadDivinerConfig: ReturnType<typeof zodAsFactory<GenericPayloadDivinerConfigBase>> = zodAsFactory(GenericPayloadDivinerConfigZod, 'asGenericPayloadDivinerConfig')\nexport const toGenericPayloadDivinerConfig: ReturnType<typeof zodToFactory<GenericPayloadDivinerConfigBase>> = zodToFactory(GenericPayloadDivinerConfigZod, 'toGenericPayloadDivinerConfig')\n\nexport type GenericPayloadDivinerConfig = PayloadDivinerConfig<\n {\n indexes?: string[]\n },\n GenericPayloadDivinerConfigSchema\n>\n\n@creatableModule()\nexport class GenericPayloadDiviner<\n TParams extends PayloadDivinerParams<GenericPayloadDivinerConfig> = PayloadDivinerParams<GenericPayloadDivinerConfig>,\n TIn extends PayloadDivinerQueryPayload = PayloadDivinerQueryPayload,\n TOut extends WithStorageMeta<Payload> = WithStorageMeta<Payload>,\n TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<\n DivinerInstance<TParams, TIn, TOut>,\n TIn,\n TOut\n >,\n> extends PayloadDiviner<TParams, TIn, TOut, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, GenericPayloadDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = GenericPayloadDivinerConfigSchema\n\n protected indexMaps: Record<string, WithStorageMeta<TOut>[]> = {}\n protected payloadsWithMeta: WithStorageMeta<TOut>[] = []\n\n private _archivistInstance?: ArchivistInstance\n private _cursor?: Sequence\n private _updatePayloadPairsMutex = new Mutex()\n\n protected get indexBatchSize(): number {\n return this.config.indexBatchSize ?? DEFAULT_INDEX_BATCH_SIZE\n }\n\n protected get indexes(): string[] {\n return ['schema', ...(this.config.indexes ?? [])]\n }\n\n protected get maxIndexSize(): number {\n return this.config.maxIndexSize ?? DEFAULT_MAX_INDEX_SIZE\n }\n\n protected all(order: Order = 'desc', cursor?: Hex): WithStorageMeta<TOut>[] {\n const payloads = this.payloadsWithMeta.toSorted(PayloadBuilder.compareStorageMeta)\n if (order === 'desc') payloads.reverse()\n const startIndex = (cursor ? (payloads.findIndex(payload => payload._sequence === cursor) ?? -1) : -1) + 1\n return payloads.slice(startIndex)\n }\n\n protected override async archivistInstance(): Promise<ArchivistInstance | undefined>\n protected override async archivistInstance(required: true): Promise<ArchivistInstance>\n protected override async archivistInstance(required = false): Promise<ArchivistInstance | undefined> {\n if (!this._archivistInstance) {\n const archivist = await super.archivistInstance()\n if (required && !archivist) {\n throw new Error('Failed to find archivist')\n }\n archivist?.on('inserted', this.onArchivistInserted)\n archivist?.on('cleared', this.onArchivistCleared)\n archivist?.on('deleted', this.onArchivistDeleted)\n this._archivistInstance = archivist\n }\n return this._archivistInstance\n }\n\n protected async clearIndex(): Promise<void> {\n await this._updatePayloadPairsMutex.runExclusive(() => {\n this._cursor = undefined\n this.payloadsWithMeta = []\n this.indexMaps = {}\n })\n }\n\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n const filters = filterAs(payloads ?? [], asPayloadDivinerQueryPayload)\n assertEx(filters.length < 2, () => 'Multiple PayloadDivinerQuery payloads may not be specified')\n const filter = assertEx(filters.shift(), () => 'No PayloadDivinerQuery specified')\n await this.updateIndex()\n\n const {\n\n schema, schemas, order, limit, cursor, ...props\n } = filter\n let all: TOut[] = this.all(order, cursor)\n if (schemas !== undefined && schemas.length > 0) all = all.filter(payload => schemas.includes(payload.schema))\n if (Object.keys(props).length > 0) {\n const additionalFilterCriteria = Object.entries(props)\n for (const [prop, filter] of additionalFilterCriteria) {\n const property = prop as keyof TOut\n all = all.filter(payload =>\n Array.isArray(filter)\n ? filter.every((value) => {\n const prop = payload?.[property]\n // TODO: This seems to be written just to check arrays, and now that $meta is there, need to check type?\n return Array.isArray(prop) && prop.includes?.(value)\n })\n : payload?.[property] === filter)\n }\n }\n return limit === undefined || limit === 0 ? all : all.slice(0, limit)\n }\n\n protected onArchivistCleared: EventListener<ArchivistModuleEventData['cleared']> = () => {\n forget(\n (async () => {\n await this.clearIndex()\n await this.updateIndex()\n })(),\n )\n }\n\n // we are just rebuilding the entire index at this point on delete since large archivists do not support delete\n protected onArchivistDeleted: EventListener<ArchivistModuleEventData['deleted']> = () => {\n forget(\n (async () => {\n await this.clearIndex()\n await this.updateIndex()\n })(),\n )\n }\n\n protected onArchivistInserted: EventListener<ArchivistModuleEventData['inserted']> = () => {\n forget(this.updateIndex())\n }\n\n protected override async stopHandler(_timeout?: number): Promise<void> {\n await super.stopHandler()\n const archivist = await this.archivistInstance(true)\n archivist.off('inserted', this.onArchivistInserted)\n archivist.off('deleted', this.onArchivistDeleted)\n archivist.off('cleared', this.onArchivistCleared)\n }\n\n // index any new payloads\n protected async updateIndex(): Promise<void> {\n await this._updatePayloadPairsMutex.runExclusive(async () => {\n const archivist = await this.archivistInstance(true)\n let newPayloads = await archivist.next({ limit: 100, cursor: this._cursor }) as TOut[]\n while (newPayloads.length > 0) {\n this._cursor = newPayloads.at(-1)?._sequence\n assertEx(this.payloadsWithMeta.length + newPayloads.length <= this.maxIndexSize, () => 'maxIndexSize exceeded')\n this.indexPayloads(newPayloads)\n newPayloads = await archivist.next({ limit: 100, cursor: this._cursor }) as TOut[]\n }\n })\n }\n\n private indexPayloads(payloads: WithStorageMeta<TOut>[]): Hex {\n this.payloadsWithMeta.push(...payloads)\n\n // update the custom indexes\n const indexes = this.indexes ?? []\n for (const index of indexes) {\n this.indexMaps[index] ??= []\n for (const payload of payloads) {\n this.indexMaps[index].push(payload)\n }\n }\n return assertEx(payloads.at(-1), () => 'No payloads to index')._sequence\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EAAU;AAAA,EAAU;AAAA,EACpB;AAAA,EAAc;AAAA,EAAc;AAAA,OACvB;AACP,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,OAIK;AACP,SAAS,aAAa;AACtB,YAAY,OAAO;AAInB,SAAS,sBAAsB;AAO/B,SAAS,8BAA8B,+BAA+B;AACtE,SAAS,uBAAuB;AAEhC,IAAM,2BAA2B;AACjC,IAAM,yBAAyB;AAExB,IAAM,oCAET,SAAS,8CAA8C,IAAI;AAGxD,IAAM,iCAMP,SAAO,yBAAyB;AAAA,EACpC,SAAW,WAAW,QAAQ,SAAO,CAAC,CAAC;AAAA,EACvC,QAAU,UAAQ,iCAAiC;AACrD,CAAC;AAIM,IAAM,gCAAkG,aAAa,8BAA8B;AACnJ,IAAM,gCAAkG,aAAa,gCAAgC,+BAA+B;AACpL,IAAM,gCAAkG,aAAa,g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@@ -1,4 +1,5 @@
1
1
  export * from '@xyo-network/sdk-protocol';
2
+ export * from './modules/account-custody/index.js';
2
3
  export * from './modules/archivist-generic/index.js';
3
4
  export * from './modules/archivist-view/index.js';
4
5
  export * from './modules/bridge-http/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,2BAA2B,CAAA;AACzC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  // src/index.ts
2
2
  export * from "@xyo-network/sdk-protocol";
3
+ export * from "#account-custody";
3
4
  export * from "#archivist-generic";
4
5
  export * from "#archivist-view";
5
6
  export * from "#bridge-http";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["// Generated by xy monolith layout sync (package-sync-layout) \u2014 do not edit by hand.\nexport * from '@xyo-network/sdk-protocol'\nexport * from '#archivist-generic'\nexport * from '#archivist-view'\nexport * from '#bridge-http'\nexport * from '#diviner-boundwitness'\nexport * from '#diviner-identity'\nexport * from '#diviner-payload-abstract'\nexport * from '#diviner-payload-generic'\nexport * from '#diviner-payload-model'\nexport * from '#modules'\nexport * from '#node-view'\nexport * from '#witness-adhoc'\n"],
5
- "mappings": ";AACA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
4
+ "sourcesContent": ["// Generated by xy monolith layout sync (package-sync-layout) \u2014 do not edit by hand.\nexport * from '@xyo-network/sdk-protocol'\nexport * from '#account-custody'\nexport * from '#archivist-generic'\nexport * from '#archivist-view'\nexport * from '#bridge-http'\nexport * from '#diviner-boundwitness'\nexport * from '#diviner-identity'\nexport * from '#diviner-payload-abstract'\nexport * from '#diviner-payload-generic'\nexport * from '#diviner-payload-model'\nexport * from '#modules'\nexport * from '#node-view'\nexport * from '#witness-adhoc'\n"],
5
+ "mappings": ";AACA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
@@ -259,7 +259,7 @@ var AbstractModule = class _AbstractModule extends AbstractCreatable {
259
259
  get logger() {
260
260
  if (isUndefined2(this._logger)) {
261
261
  const logLevel = this.config.logLevel;
262
- const newLogger = this._logger ?? (this.params?.logger ? new IdLogger(this.params.logger, () => `${this.constructor.name}[${this.id}]`) : null);
262
+ const newLogger = this._logger ?? (this.params?.logger ? new IdLogger(this.params.logger, () => `${this.config.schema}[${this.id}]`) : null);
263
263
  this._logger = isObject(newLogger) && isDefined2(logLevel) ? new LevelLogger(newLogger, logLevel) : newLogger;
264
264
  }
265
265
  return this._logger ?? void 0;
@@ -298,7 +298,7 @@ var AbstractModule = class _AbstractModule extends AbstractCreatable {
298
298
  const allowedSchemas = this.configSchemas;
299
299
  assertEx2(this.isAllowedSchema(schema), () => `Bad Config Schema [Received ${schema}] [Expected ${JSON.stringify(allowedSchemas)}]`);
300
300
  } else {
301
- throw new TypeError(`Invalid instance type [${instance.constructor.name}] for [${this.name}]`);
301
+ throw new TypeError(`Invalid instance type [${instance.name}] for [${this.name}]`);
302
302
  }
303
303
  return instance;
304
304
  }
@@ -536,7 +536,7 @@ var AbstractModule = class _AbstractModule extends AbstractCreatable {
536
536
  async generateDescribe() {
537
537
  const description = {
538
538
  address: this.address,
539
- name: this.modName ?? `Unnamed ${this.constructor.name}`,
539
+ name: this.modName ?? `Unnamed ${this.config.schema}`,
540
540
  queries: this.queries,
541
541
  schema: ModuleDescriptionSchema
542
542
  };
@@ -664,7 +664,7 @@ function filterIdentity(mod, identityFunc) {
664
664
  if (Array.isArray(mod)) {
665
665
  return identityFunc ? mod.filter((module) => identityFunc(module)) : mod;
666
666
  }
667
- return (mod ? !identityFunc || identityFunc(mod) : false) ? mod : void 0;
667
+ return isDefined3(mod) && (!identityFunc || identityFunc(mod)) ? mod : void 0;
668
668
  }
669
669
  var AbstractModuleInstance = class _AbstractModuleInstance extends AbstractModule {
670
670
  // switches between old and new resolution system