@xyo-network/diviner-boundwitness-memory 2.110.19 → 2.111.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,10 +55,7 @@ var MemoryBoundWitnessDiviner = class extends import_diviner_boundwitness_abstra
55
55
  const targetFilter = (0, import_assert.assertEx)(destination, () => "Missing destination");
56
56
  bws = bws.filter((bw) => {
57
57
  const targetDestinationField = bw?.$meta?.destination;
58
- return targetDestinationField !== void 0 && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ? (
59
- // Check that the targetDestinationField contains all the elements in the targetFilter
60
- (0, import_array.containsAll)(targetFilter, targetDestinationField ?? [])
61
- ) : false;
58
+ return targetDestinationField !== void 0 && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ? (0, import_array.containsAll)(targetFilter, targetDestinationField ?? []) : false;
62
59
  });
63
60
  }
64
61
  if (timestamp !== void 0) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/MemoryBoundWitnessDiviner.ts"],"sourcesContent":["export * from './MemoryBoundWitnessDiviner.ts'\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { hexFromHexString } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport {\n BoundWitnessDivinerParams,\n BoundWitnessDivinerQueryPayload,\n isBoundWitnessDivinerQueryPayload,\n} from '@xyo-network/diviner-boundwitness-model'\nimport { WithMeta } from '@xyo-network/payload-model'\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\ntype WithTimestamp = BoundWitness & { timestamp: number }\nconst hasTimestamp = (bw: BoundWitness): bw is WithTimestamp => bw.timestamp !== undefined\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 // eslint-disable-next-line complexity\n protected override async divineHandler(payloads?: TIn[]) {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n if (!filter) return []\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter\n let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]\n if (order === 'desc') bws = bws.reverse()\n const allAddresses = addresses?.map((address) => hexFromHexString(address)).filter(exists)\n if (allAddresses?.length) bws = bws.filter((bw) => containsAll(bw.addresses, allAddresses))\n if (payload_hashes?.length) bws = bws.filter((bw) => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas?.length) bws = bws.filter((bw) => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery) bws = bws.filter((bw) => (bw?.$meta as { sourceQuery?: string })?.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?.$meta as { destination?: string[] })?.destination\n // If the destination field is an array and contains at least one element\n return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ?\n // Check that the targetDestinationField contains all the elements in the targetFilter\n containsAll(targetFilter, targetDestinationField ?? [])\n // Otherwise, filter it out\n : false\n })\n }\n if (timestamp !== undefined) {\n bws =\n order === 'desc' ?\n bws.filter(hasTimestamp).filter((bw) => bw.timestamp <= timestamp)\n : bws.filter(hasTimestamp).filter((bw) => bw.timestamp >= timestamp)\n }\n const parsedLimit = limit ?? bws.length\n const parsedOffset = offset ?? 0\n return bws.slice(parsedOffset, parsedLimit) as WithMeta<TOut>[]\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,mBAA4B;AAC5B,oBAAyB;AACzB,oBAAuB;AACvB,iBAAiC;AACjC,gCAA6C;AAC7C,2CAAoC;AACpC,wCAIO;AAsDP,IAAMA,eAAe,wBAACC,OAA0CA,GAAGC,cAAcC,QAA5D;AAEd,IAAMC,4BAAN,cAIGC,yDAAAA;EAtEV,OAsEUA;;;;EAER,MAAyBC,cAAcC,UAAkB;AACvD,UAAMC,aAASC,wBAASF,UAAUC,OAAOE,mEAAAA,GAAoCC,IAAAA,GAAO,MAAM,uBAAA;AAC1F,QAAI,CAACH,OAAQ,QAAO,CAAA;AACpB,UAAMI,gBAAYH,wBAAS,MAAM,KAAKI,kBAAiB,GAAI,MAAM,6BAAA;AACjE,UAAM,EAAEC,WAAWC,gBAAgBC,iBAAiBC,OAAOC,QAAQC,QAAQ,QAAQC,aAAaC,aAAanB,UAAS,IAAKM;AAC3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AerB,UAAU;AAC/B,WAAOI,IAAIkB,MAAMD,cAAcD,WAAAA;EACjC;AACF;","names":["hasTimestamp","bw","timestamp","undefined","MemoryBoundWitnessDiviner","BoundWitnessDiviner","divineHandler","payloads","filter","assertEx","isBoundWitnessDivinerQueryPayload","pop","archivist","archivistInstance","addresses","payload_hashes","payload_schemas","limit","offset","order","sourceQuery","destination","bws","all","isBoundWitness","reverse","allAddresses","map","address","hexFromHexString","exists","length","containsAll","$meta","Array","isArray","targetFilter","targetDestinationField","parsedLimit","parsedOffset","slice"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/MemoryBoundWitnessDiviner.ts"],"sourcesContent":["export * from './MemoryBoundWitnessDiviner.ts'\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { hexFromHexString } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport {\n BoundWitnessDivinerParams,\n BoundWitnessDivinerQueryPayload,\n isBoundWitnessDivinerQueryPayload,\n} from '@xyo-network/diviner-boundwitness-model'\nimport { WithMeta } from '@xyo-network/payload-model'\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\ntype WithTimestamp = BoundWitness & { timestamp: number }\nconst hasTimestamp = (bw: BoundWitness): bw is WithTimestamp => bw.timestamp !== undefined\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 // eslint-disable-next-line complexity\n protected override async divineHandler(payloads?: TIn[]) {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n if (!filter) return []\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter\n let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]\n if (order === 'desc') bws = bws.reverse()\n const allAddresses = addresses?.map(address => hexFromHexString(address)).filter(exists)\n if (allAddresses?.length) bws = bws.filter(bw => containsAll(bw.addresses, allAddresses))\n if (payload_hashes?.length) bws = bws.filter(bw => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas?.length) bws = bws.filter(bw => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery) bws = bws.filter(bw => (bw?.$meta as { sourceQuery?: string })?.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?.$meta as { destination?: string[] })?.destination\n // If the destination field is an array and contains at least one element\n return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0\n // Check that the targetDestinationField contains all the elements in the targetFilter\n ? containsAll(targetFilter, targetDestinationField ?? [])\n // Otherwise, filter it out\n : false\n })\n }\n if (timestamp !== undefined) {\n bws\n = order === 'desc'\n ? bws.filter(hasTimestamp).filter(bw => bw.timestamp <= timestamp)\n : bws.filter(hasTimestamp).filter(bw => bw.timestamp >= timestamp)\n }\n const parsedLimit = limit ?? bws.length\n const parsedOffset = offset ?? 0\n return bws.slice(parsedOffset, parsedLimit) as WithMeta<TOut>[]\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,mBAA4B;AAC5B,oBAAyB;AACzB,oBAAuB;AACvB,iBAAiC;AACjC,gCAA6C;AAC7C,2CAAoC;AACpC,wCAIO;AAsDP,IAAMA,eAAe,wBAACC,OAA0CA,GAAGC,cAAcC,QAA5D;AAEd,IAAMC,4BAAN,cAIGC,yDAAAA;EAtEV,OAsEUA;;;;EAER,MAAyBC,cAAcC,UAAkB;AACvD,UAAMC,aAASC,wBAASF,UAAUC,OAAOE,mEAAAA,GAAoCC,IAAAA,GAAO,MAAM,uBAAA;AAC1F,QAAI,CAACH,OAAQ,QAAO,CAAA;AACpB,UAAMI,gBAAYH,wBAAS,MAAM,KAAKI,kBAAiB,GAAI,MAAM,6BAAA;AACjE,UAAM,EAAEC,WAAWC,gBAAgBC,iBAAiBC,OAAOC,QAAQC,QAAQ,QAAQC,aAAaC,aAAanB,UAAS,IAAKM;AAC3H,QAAIc,OAAQ,MAAMV,WAAWW,MAAAA,KAAY,CAAA,GAAIf,OAAOgB,wCAAAA;AACpD,QAAIL,UAAU,OAAQG,OAAMA,IAAIG,QAAO;AACvC,UAAMC,eAAeZ,WAAWa,IAAIC,CAAAA,gBAAWC,6BAAiBD,OAAAA,CAAAA,EAAUpB,OAAOsB,oBAAAA;AACjF,QAAIJ,cAAcK,OAAQT,OAAMA,IAAId,OAAOP,CAAAA,WAAM+B,0BAAY/B,GAAGa,WAAWY,YAAAA,CAAAA;AAC3E,QAAIX,gBAAgBgB,OAAQT,OAAMA,IAAId,OAAOP,CAAAA,WAAM+B,0BAAY/B,GAAGc,gBAAgBA,cAAAA,CAAAA;AAClF,QAAIC,iBAAiBe,OAAQT,OAAMA,IAAId,OAAOP,CAAAA,WAAM+B,0BAAY/B,GAAGe,iBAAiBA,eAAAA,CAAAA;AACpF,QAAII,YAAaE,OAAMA,IAAId,OAAOP,CAAAA,OAAOA,IAAIgC,OAAoCb,gBAAgBA,WAAAA;AAEjG,QAAIC,eAAea,MAAMC,QAAQd,WAAAA,KAAgBA,aAAaU,SAAS,GAAG;AACxE,YAAMK,mBAAe3B,wBAASY,aAAa,MAAM,qBAAA;AAEjDC,YAAMA,IAAId,OAAO,CAACP,OAAAA;AAChB,cAAMoC,yBAA0BpC,IAAIgC,OAAsCZ;AAE1E,eAAOgB,2BAA2BlC,UAAa+B,MAAMC,QAAQE,sBAAAA,KAA2BA,uBAAuBN,SAAS,QAEpHC,0BAAYI,cAAcC,0BAA0B,CAAA,CAAE,IAEtD;MACN,CAAA;IACF;AACA,QAAInC,cAAcC,QAAW;AAC3BmB,YACIH,UAAU,SACRG,IAAId,OAAOR,YAAAA,EAAcQ,OAAOP,CAAAA,OAAMA,GAAGC,aAAaA,SAAAA,IACtDoB,IAAId,OAAOR,YAAAA,EAAcQ,OAAOP,CAAAA,OAAMA,GAAGC,aAAaA,SAAAA;IAC9D;AACA,UAAMoC,cAAcrB,SAASK,IAAIS;AACjC,UAAMQ,eAAerB,UAAU;AAC/B,WAAOI,IAAIkB,MAAMD,cAAcD,WAAAA;EACjC;AACF;","names":["hasTimestamp","bw","timestamp","undefined","MemoryBoundWitnessDiviner","BoundWitnessDiviner","divineHandler","payloads","filter","assertEx","isBoundWitnessDivinerQueryPayload","pop","archivist","archivistInstance","addresses","payload_hashes","payload_schemas","limit","offset","order","sourceQuery","destination","bws","all","isBoundWitness","reverse","allAddresses","map","address","hexFromHexString","exists","length","containsAll","$meta","Array","isArray","targetFilter","targetDestinationField","parsedLimit","parsedOffset","slice"]}
@@ -31,10 +31,7 @@ var MemoryBoundWitnessDiviner = class extends BoundWitnessDiviner {
31
31
  const targetFilter = assertEx(destination, () => "Missing destination");
32
32
  bws = bws.filter((bw) => {
33
33
  const targetDestinationField = bw?.$meta?.destination;
34
- return targetDestinationField !== void 0 && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ? (
35
- // Check that the targetDestinationField contains all the elements in the targetFilter
36
- containsAll(targetFilter, targetDestinationField ?? [])
37
- ) : false;
34
+ return targetDestinationField !== void 0 && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ? containsAll(targetFilter, targetDestinationField ?? []) : false;
38
35
  });
39
36
  }
40
37
  if (timestamp !== void 0) {
@@ -48,4 +45,4 @@ var MemoryBoundWitnessDiviner = class extends BoundWitnessDiviner {
48
45
  export {
49
46
  MemoryBoundWitnessDiviner
50
47
  };
51
- //# sourceMappingURL=index.js.map
48
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/MemoryBoundWitnessDiviner.ts"],"sourcesContent":["import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { hexFromHexString } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport {\n BoundWitnessDivinerParams,\n BoundWitnessDivinerQueryPayload,\n isBoundWitnessDivinerQueryPayload,\n} from '@xyo-network/diviner-boundwitness-model'\nimport { WithMeta } from '@xyo-network/payload-model'\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\ntype WithTimestamp = BoundWitness & { timestamp: number }\nconst hasTimestamp = (bw: BoundWitness): bw is WithTimestamp => bw.timestamp !== undefined\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 // eslint-disable-next-line complexity\n protected override async divineHandler(payloads?: TIn[]) {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n if (!filter) return []\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter\n let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]\n if (order === 'desc') bws = bws.reverse()\n const allAddresses = addresses?.map(address => hexFromHexString(address)).filter(exists)\n if (allAddresses?.length) bws = bws.filter(bw => containsAll(bw.addresses, allAddresses))\n if (payload_hashes?.length) bws = bws.filter(bw => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas?.length) bws = bws.filter(bw => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery) bws = bws.filter(bw => (bw?.$meta as { sourceQuery?: string })?.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?.$meta as { destination?: string[] })?.destination\n // If the destination field is an array and contains at least one element\n return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0\n // Check that the targetDestinationField contains all the elements in the targetFilter\n ? containsAll(targetFilter, targetDestinationField ?? [])\n // Otherwise, filter it out\n : false\n })\n }\n if (timestamp !== undefined) {\n bws\n = order === 'desc'\n ? bws.filter(hasTimestamp).filter(bw => bw.timestamp <= timestamp)\n : bws.filter(hasTimestamp).filter(bw => bw.timestamp >= timestamp)\n }\n const parsedLimit = limit ?? bws.length\n const parsedOffset = offset ?? 0\n return bws.slice(parsedOffset, parsedLimit) as WithMeta<TOut>[]\n }\n}\n"],"mappings":";;;;AAAA,SAASA,mBAAmB;AAC5B,SAASC,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,wBAAwB;AACjC,SAAuBC,sBAAsB;AAC7C,SAASC,2BAA2B;AACpC,SAGEC,yCACK;AAsDP,IAAMC,eAAe,wBAACC,OAA0CA,GAAGC,cAAcC,QAA5D;AAEd,IAAMC,4BAAN,cAIGC,oBAAAA;EAtEV,OAsEUA;;;;EAER,MAAyBC,cAAcC,UAAkB;AACvD,UAAMC,SAASC,SAASF,UAAUC,OAAOE,iCAAAA,GAAoCC,IAAAA,GAAO,MAAM,uBAAA;AAC1F,QAAI,CAACH,OAAQ,QAAO,CAAA;AACpB,UAAMI,YAAYH,SAAS,MAAM,KAAKI,kBAAiB,GAAI,MAAM,6BAAA;AACjE,UAAM,EAAEC,WAAWC,gBAAgBC,iBAAiBC,OAAOC,QAAQC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;AACA,UAAMoC,cAAcrB,SAASK,IAAIS;AACjC,UAAMQ,eAAerB,UAAU;AAC/B,WAAOI,IAAIkB,MAAMD,cAAcD,WAAAA;EACjC;AACF;","names":["containsAll","assertEx","exists","hexFromHexString","isBoundWitness","BoundWitnessDiviner","isBoundWitnessDivinerQueryPayload","hasTimestamp","bw","timestamp","undefined","MemoryBoundWitnessDiviner","BoundWitnessDiviner","divineHandler","payloads","filter","assertEx","isBoundWitnessDivinerQueryPayload","pop","archivist","archivistInstance","addresses","payload_hashes","payload_schemas","limit","offset","order","sourceQuery","destination","bws","all","isBoundWitness","reverse","allAddresses","map","address","hexFromHexString","exists","length","containsAll","$meta","Array","isArray","targetFilter","targetDestinationField","parsedLimit","parsedOffset","slice"]}
@@ -55,10 +55,7 @@ var MemoryBoundWitnessDiviner = class extends import_diviner_boundwitness_abstra
55
55
  const targetFilter = (0, import_assert.assertEx)(destination, () => "Missing destination");
56
56
  bws = bws.filter((bw) => {
57
57
  const targetDestinationField = bw?.$meta?.destination;
58
- return targetDestinationField !== void 0 && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ? (
59
- // Check that the targetDestinationField contains all the elements in the targetFilter
60
- (0, import_array.containsAll)(targetFilter, targetDestinationField ?? [])
61
- ) : false;
58
+ return targetDestinationField !== void 0 && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ? (0, import_array.containsAll)(targetFilter, targetDestinationField ?? []) : false;
62
59
  });
63
60
  }
64
61
  if (timestamp !== void 0) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/MemoryBoundWitnessDiviner.ts"],"sourcesContent":["export * from './MemoryBoundWitnessDiviner.ts'\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { hexFromHexString } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport {\n BoundWitnessDivinerParams,\n BoundWitnessDivinerQueryPayload,\n isBoundWitnessDivinerQueryPayload,\n} from '@xyo-network/diviner-boundwitness-model'\nimport { WithMeta } from '@xyo-network/payload-model'\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\ntype WithTimestamp = BoundWitness & { timestamp: number }\nconst hasTimestamp = (bw: BoundWitness): bw is WithTimestamp => bw.timestamp !== undefined\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 // eslint-disable-next-line complexity\n protected override async divineHandler(payloads?: TIn[]) {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n if (!filter) return []\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter\n let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]\n if (order === 'desc') bws = bws.reverse()\n const allAddresses = addresses?.map((address) => hexFromHexString(address)).filter(exists)\n if (allAddresses?.length) bws = bws.filter((bw) => containsAll(bw.addresses, allAddresses))\n if (payload_hashes?.length) bws = bws.filter((bw) => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas?.length) bws = bws.filter((bw) => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery) bws = bws.filter((bw) => (bw?.$meta as { sourceQuery?: string })?.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?.$meta as { destination?: string[] })?.destination\n // If the destination field is an array and contains at least one element\n return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ?\n // Check that the targetDestinationField contains all the elements in the targetFilter\n containsAll(targetFilter, targetDestinationField ?? [])\n // Otherwise, filter it out\n : false\n })\n }\n if (timestamp !== undefined) {\n bws =\n order === 'desc' ?\n bws.filter(hasTimestamp).filter((bw) => bw.timestamp <= timestamp)\n : bws.filter(hasTimestamp).filter((bw) => bw.timestamp >= timestamp)\n }\n const parsedLimit = limit ?? bws.length\n const parsedOffset = offset ?? 0\n return bws.slice(parsedOffset, parsedLimit) as WithMeta<TOut>[]\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,mBAA4B;AAC5B,oBAAyB;AACzB,oBAAuB;AACvB,iBAAiC;AACjC,gCAA6C;AAC7C,2CAAoC;AACpC,wCAIO;AAsDP,IAAMA,eAAe,wBAACC,OAA0CA,GAAGC,cAAcC,QAA5D;AAEd,IAAMC,4BAAN,cAIGC,yDAAAA;EAt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BAAuBN,SAAS;;cAEpHC,0BAAYI,cAAcC,0BAA0B,CAAA,CAAE;YAEtD;MACN,CAAA;IACF;AACA,QAAInC,cAAcC,QAAW;AAC3BmB,YACEH,UAAU,SACRG,IAAId,OAAOR,YAAAA,EAAcQ,OAAO,CAACP,OAAOA,GAAGC,aAAaA,SAAAA,IACxDoB,IAAId,OAAOR,YAAAA,EAAcQ,OAAO,CAACP,OAAOA,GAAGC,aAAaA,SAAAA;IAC9D;AACA,UAAMoC,cAAcrB,SAASK,IAAIS;AACjC,UAAMQ,eAAerB,UAAU;AAC/B,WAAOI,IAAIkB,MAAMD,cAAcD,WAAAA;EACjC;AACF;","names":["hasTimestamp","bw","timestamp","undefined","MemoryBoundWitnessDiviner","BoundWitnessDiviner","divineHandler","payloads","filter","assertEx","isBoundWitnessDivinerQueryPayload","pop","archivist","archivistInstance","addresses","payload_hashes","payload_schemas","limit","offset","order","sourceQuery","destination","bws","all","isBoundWitness","reverse","allAddresses","map","address","hexFromHexString","exists","length","containsAll","$meta","Array","isArray","targetFilter","targetDestinationField","parsedLimit","parsedOffset","slice"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/MemoryBoundWitnessDiviner.ts"],"sourcesContent":["export * from './MemoryBoundWitnessDiviner.ts'\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { hexFromHexString } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport {\n BoundWitnessDivinerParams,\n BoundWitnessDivinerQueryPayload,\n isBoundWitnessDivinerQueryPayload,\n} from '@xyo-network/diviner-boundwitness-model'\nimport { WithMeta } from '@xyo-network/payload-model'\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\ntype WithTimestamp = BoundWitness & { timestamp: number }\nconst hasTimestamp = (bw: BoundWitness): bw is WithTimestamp => bw.timestamp !== undefined\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 // eslint-disable-next-line complexity\n protected override async divineHandler(payloads?: TIn[]) {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n if (!filter) return []\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter\n let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]\n if (order === 'desc') bws = bws.reverse()\n const allAddresses = addresses?.map(address => hexFromHexString(address)).filter(exists)\n if (allAddresses?.length) bws = bws.filter(bw => containsAll(bw.addresses, allAddresses))\n if (payload_hashes?.length) bws = bws.filter(bw => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas?.length) bws = bws.filter(bw => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery) bws = bws.filter(bw => (bw?.$meta as { sourceQuery?: string })?.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?.$meta as { destination?: string[] })?.destination\n // If the destination field is an array and contains at least one element\n return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0\n // Check that the targetDestinationField contains all the elements in the targetFilter\n ? containsAll(targetFilter, targetDestinationField ?? [])\n // Otherwise, filter it out\n : false\n })\n }\n if (timestamp !== undefined) {\n bws\n = order === 'desc'\n ? bws.filter(hasTimestamp).filter(bw => bw.timestamp <= timestamp)\n : bws.filter(hasTimestamp).filter(bw => bw.timestamp >= timestamp)\n }\n const parsedLimit = limit ?? bws.length\n const parsedOffset = offset ?? 0\n return bws.slice(parsedOffset, parsedLimit) as WithMeta<TOut>[]\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,mBAA4B;AAC5B,oBAAyB;AACzB,oBAAuB;AACvB,iBAAiC;AACjC,gCAA6C;AAC7C,2CAAoC;AACpC,wCAIO;AAsDP,IAAMA,eAAe,wBAACC,OAA0CA,GAAGC,cAAcC,QAA5D;AAEd,IAAMC,4BAAN,cAIGC,yDAAAA;EAtEV,OAsEUA;;;;EAER,MAAyBC,cAAcC,UAAkB;AACvD,UAAMC,aAASC,wBAASF,UAAUC,OAAOE,mEAAAA,GAAoCC,IAAAA,GAAO,MAAM,uBAAA;AAC1F,QAAI,CAACH,OAAQ,QAAO,CAAA;AACpB,UAAMI,gBAAYH,wBAAS,MAAM,KAAKI,kBAAiB,GAAI,MAAM,6BAAA;AACjE,UAAM,EAAEC,WAAWC,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,CAAAA,OAAMA,GAAGC,aAAaA,SAAAA;IAC9D;AACA,UAAMoC,cAAcrB,SAASK,IAAIS;AACjC,UAAMQ,eAAerB,UAAU;AAC/B,WAAOI,IAAIkB,MAAMD,cAAcD,WAAAA;EACjC;AACF;","names":["hasTimestamp","bw","timestamp","undefined","MemoryBoundWitnessDiviner","BoundWitnessDiviner","divineHandler","payloads","filter","assertEx","isBoundWitnessDivinerQueryPayload","pop","archivist","archivistInstance","addresses","payload_hashes","payload_schemas","limit","offset","order","sourceQuery","destination","bws","all","isBoundWitness","reverse","allAddresses","map","address","hexFromHexString","exists","length","containsAll","$meta","Array","isArray","targetFilter","targetDestinationField","parsedLimit","parsedOffset","slice"]}
@@ -31,10 +31,7 @@ var MemoryBoundWitnessDiviner = class extends BoundWitnessDiviner {
31
31
  const targetFilter = assertEx(destination, () => "Missing destination");
32
32
  bws = bws.filter((bw) => {
33
33
  const targetDestinationField = bw?.$meta?.destination;
34
- return targetDestinationField !== void 0 && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ? (
35
- // Check that the targetDestinationField contains all the elements in the targetFilter
36
- containsAll(targetFilter, targetDestinationField ?? [])
37
- ) : false;
34
+ return targetDestinationField !== void 0 && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ? containsAll(targetFilter, targetDestinationField ?? []) : false;
38
35
  });
39
36
  }
40
37
  if (timestamp !== void 0) {
@@ -48,4 +45,4 @@ var MemoryBoundWitnessDiviner = class extends BoundWitnessDiviner {
48
45
  export {
49
46
  MemoryBoundWitnessDiviner
50
47
  };
51
- //# sourceMappingURL=index.js.map
48
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/MemoryBoundWitnessDiviner.ts"],"sourcesContent":["import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { hexFromHexString } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport {\n BoundWitnessDivinerParams,\n BoundWitnessDivinerQueryPayload,\n isBoundWitnessDivinerQueryPayload,\n} from '@xyo-network/diviner-boundwitness-model'\nimport { WithMeta } from '@xyo-network/payload-model'\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\ntype WithTimestamp = BoundWitness & { timestamp: number }\nconst hasTimestamp = (bw: BoundWitness): bw is WithTimestamp => bw.timestamp !== undefined\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 // eslint-disable-next-line complexity\n protected override async divineHandler(payloads?: TIn[]) {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n if (!filter) return []\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter\n let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]\n if (order === 'desc') bws = bws.reverse()\n const allAddresses = addresses?.map(address => hexFromHexString(address)).filter(exists)\n if (allAddresses?.length) bws = bws.filter(bw => containsAll(bw.addresses, allAddresses))\n if (payload_hashes?.length) bws = bws.filter(bw => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas?.length) bws = bws.filter(bw => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery) bws = bws.filter(bw => (bw?.$meta as { sourceQuery?: string })?.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?.$meta as { destination?: string[] })?.destination\n // If the destination field is an array and contains at least one element\n return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0\n // Check that the targetDestinationField contains all the elements in the targetFilter\n ? containsAll(targetFilter, targetDestinationField ?? [])\n // Otherwise, filter it out\n : false\n })\n }\n if (timestamp !== undefined) {\n bws\n = order === 'desc'\n ? bws.filter(hasTimestamp).filter(bw => bw.timestamp <= timestamp)\n : bws.filter(hasTimestamp).filter(bw => bw.timestamp >= timestamp)\n }\n const parsedLimit = limit ?? bws.length\n const parsedOffset = offset ?? 0\n return bws.slice(parsedOffset, parsedLimit) as WithMeta<TOut>[]\n }\n}\n"],"mappings":";;;;AAAA,SAASA,mBAAmB;AAC5B,SAASC,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,wBAAwB;AACjC,SAAuBC,sBAAsB;AAC7C,SAASC,2BAA2B;AACpC,SAGEC,yCACK;AAsDP,IAAMC,eAAe,wBAACC,OAA0CA,GAAGC,cA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BAA2BlC,UAAa+B,MAAMC,QAAQE,sBAAAA,KAA2BA,uBAAuBN,SAAS,IAEpHC,YAAYI,cAAcC,0BAA0B,CAAA,CAAE,IAEtD;MACN,CAAA;IACF;AACA,QAAInC,cAAcC,QAAW;AAC3BmB,YACIH,UAAU,SACRG,IAAId,OAAOR,YAAAA,EAAcQ,OAAOP,CAAAA,OAAMA,GAAGC,aAAaA,SAAAA,IACtDoB,IAAId,OAAOR,YAAAA,EAAcQ,OAAOP,CAAAA,OAAMA,GAAGC,aAAaA,SAAAA;IAC9D;AACA,UAAMoC,cAAcrB,SAASK,IAAIS;AACjC,UAAMQ,eAAerB,UAAU;AAC/B,WAAOI,IAAIkB,MAAMD,cAAcD,WAAAA;EACjC;AACF;","names":["containsAll","assertEx","exists","hexFromHexString","isBoundWitness","BoundWitnessDiviner","isBoundWitnessDivinerQueryPayload","hasTimestamp","bw","timestamp","undefined","MemoryBoundWitnessDiviner","BoundWitnessDiviner","divineHandler","payloads","filter","assertEx","isBoundWitnessDivinerQueryPayload","pop","archivist","archivistInstance","addresses","payload_hashes","payload_schemas","limit","offset","order","sourceQuery","destination","bws","all","isBoundWitness","reverse","allAddresses","map","address","hexFromHexString","exists","length","containsAll","$meta","Array","isArray","targetFilter","targetDestinationField","parsedLimit","parsedOffset","slice"]}
@@ -57,10 +57,7 @@ var _MemoryBoundWitnessDiviner = class _MemoryBoundWitnessDiviner extends import
57
57
  bws = bws.filter((bw) => {
58
58
  var _a2;
59
59
  const targetDestinationField = (_a2 = bw == null ? void 0 : bw.$meta) == null ? void 0 : _a2.destination;
60
- return targetDestinationField !== void 0 && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ? (
61
- // Check that the targetDestinationField contains all the elements in the targetFilter
62
- (0, import_array.containsAll)(targetFilter, targetDestinationField ?? [])
63
- ) : false;
60
+ return targetDestinationField !== void 0 && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ? (0, import_array.containsAll)(targetFilter, targetDestinationField ?? []) : false;
64
61
  });
65
62
  }
66
63
  if (timestamp !== void 0) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/MemoryBoundWitnessDiviner.ts"],"sourcesContent":["export * from './MemoryBoundWitnessDiviner.ts'\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { hexFromHexString } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport {\n BoundWitnessDivinerParams,\n BoundWitnessDivinerQueryPayload,\n isBoundWitnessDivinerQueryPayload,\n} from '@xyo-network/diviner-boundwitness-model'\nimport { WithMeta } from '@xyo-network/payload-model'\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\ntype WithTimestamp = BoundWitness & { timestamp: number }\nconst hasTimestamp = (bw: BoundWitness): bw is WithTimestamp => bw.timestamp !== undefined\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 // eslint-disable-next-line complexity\n protected override async divineHandler(payloads?: TIn[]) {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n if (!filter) return []\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter\n let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]\n if (order === 'desc') bws = bws.reverse()\n const allAddresses = addresses?.map((address) => hexFromHexString(address)).filter(exists)\n if (allAddresses?.length) bws = bws.filter((bw) => containsAll(bw.addresses, allAddresses))\n if (payload_hashes?.length) bws = bws.filter((bw) => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas?.length) bws = bws.filter((bw) => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery) bws = bws.filter((bw) => (bw?.$meta as { sourceQuery?: string })?.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?.$meta as { destination?: string[] })?.destination\n // If the destination field is an array and contains at least one element\n return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ?\n // Check that the targetDestinationField contains all the elements in the targetFilter\n containsAll(targetFilter, targetDestinationField ?? [])\n // Otherwise, filter it out\n : false\n })\n }\n if (timestamp !== undefined) {\n bws =\n order === 'desc' ?\n bws.filter(hasTimestamp).filter((bw) => bw.timestamp <= timestamp)\n : bws.filter(hasTimestamp).filter((bw) => bw.timestamp >= timestamp)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AMA,IAAId,OAAO,CAACP,OAAAA;AAnFvC,UAAAgC;AAmF+ChC,eAAAA,MAAAA,yBAAIiC,UAAJjC,gBAAAA,IAAwCmB,iBAAgBA;KAAAA;AAEnG,QAAIC,eAAec,MAAMC,QAAQf,WAAAA,MAAgBA,2CAAaU,UAAS,GAAG;AACxE,YAAMM,mBAAe5B,wBAASY,aAAa,MAAM,qBAAA;AAEjDC,YAAMA,IAAId,OAAO,CAACP,OAAAA;AAxFxB,YAAAgC;AAyFQ,cAAMK,0BAA0BrC,MAAAA,yBAAIiC,UAAJjC,gBAAAA,IAA0CoB;AAE1E,eAAOiB,2BAA2BnC,UAAagC,MAAMC,QAAQE,sBAAAA,KAA2BA,uBAAuBP,SAAS;;cAEpHC,0BAAYK,cAAcC,0BAA0B,CAAA,CAAE;YAEtD;MACN,CAAA;IACF;AACA,QAAIpC,cAAcC,QAAW;AAC3BmB,YACEH,UAAU,SACRG,IAAId,OAAOR,YAAAA,EAAcQ,OAAO,CAACP,OAAOA,GAAGC,aAAaA,SAAAA,IACxDoB,IAAId,OAAOR,YAAAA,EAAcQ,OAAO,CAACP,OAAOA,GAAGC,aAAaA,SAAAA;IAC9D;AACA,UAAMqC,cAActB,SAASK,IAAIS;AACjC,UAAMS,eAAetB,UAAU;AAC/B,WAAOI,IAAImB,MAAMD,cAAcD,WAAAA;EACjC;AACF;AAtCUlC;AAJH,IAAMD,4BAAN;","names":["hasTimestamp","bw","timestamp","undefined","MemoryBoundWitnessDiviner","BoundWitnessDiviner","divineHandler","payloads","filter","assertEx","isBoundWitnessDivinerQueryPayload","pop","archivist","archivistInstance","addresses","payload_hashes","payload_schemas","limit","offset","order","sourceQuery","destination","bws","all","isBoundWitness","reverse","allAddresses","map","address","hexFromHexString","exists","length","containsAll","_a","$meta","Array","isArray","targetFilter","targetDestinationField","parsedLimit","parsedOffset","slice"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/MemoryBoundWitnessDiviner.ts"],"sourcesContent":["export * from './MemoryBoundWitnessDiviner.ts'\n","import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { hexFromHexString } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport {\n BoundWitnessDivinerParams,\n BoundWitnessDivinerQueryPayload,\n isBoundWitnessDivinerQueryPayload,\n} from '@xyo-network/diviner-boundwitness-model'\nimport { WithMeta } from '@xyo-network/payload-model'\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\ntype WithTimestamp = BoundWitness & { timestamp: number }\nconst hasTimestamp = (bw: BoundWitness): bw is WithTimestamp => bw.timestamp !== undefined\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 // eslint-disable-next-line complexity\n protected override async divineHandler(payloads?: TIn[]) {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n if (!filter) return []\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter\n let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]\n if (order === 'desc') bws = bws.reverse()\n const allAddresses = addresses?.map(address => hexFromHexString(address)).filter(exists)\n if (allAddresses?.length) bws = bws.filter(bw => containsAll(bw.addresses, allAddresses))\n if (payload_hashes?.length) bws = bws.filter(bw => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas?.length) bws = bws.filter(bw => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery) bws = bws.filter(bw => (bw?.$meta as { sourceQuery?: string })?.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?.$meta as { destination?: string[] })?.destination\n // If the destination field is an array and contains at least one element\n return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0\n // Check that the targetDestinationField contains all the elements in the targetFilter\n ? containsAll(targetFilter, targetDestinationField ?? [])\n // Otherwise, filter it out\n : false\n })\n }\n if (timestamp !== undefined) {\n bws\n = order === 'desc'\n ? bws.filter(hasTimestamp).filter(bw => bw.timestamp <= timestamp)\n : bws.filter(hasTimestamp).filter(bw => bw.timestamp >= timestamp)\n }\n const parsedLimit = limit ?? bws.length\n const parsedOffset = offset ?? 0\n return bws.slice(parsedOffset, parsedLimit) as WithMeta<TOut>[]\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;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EjG,QAAIC,eAAec,MAAMC,QAAQf,WAAAA,MAAgBA,2CAAaU,UAAS,GAAG;AACxE,YAAMM,mBAAe5B,wBAASY,aAAa,MAAM,qBAAA;AAEjDC,YAAMA,IAAId,OAAO,CAACP,OAAAA;AAxFxB,YAAAgC;AAyFQ,cAAMK,0BAA0BrC,MAAAA,yBAAIiC,UAAJjC,gBAAAA,IAA0CoB;AAE1E,eAAOiB,2BAA2BnC,UAAagC,MAAMC,QAAQE,sBAAAA,KAA2BA,uBAAuBP,SAAS,QAEpHC,0BAAYK,cAAcC,0BAA0B,CAAA,CAAE,IAEtD;MACN,CAAA;IACF;AACA,QAAIpC,cAAcC,QAAW;AAC3BmB,YACIH,UAAU,SACRG,IAAId,OAAOR,YAAAA,EAAcQ,OAAOP,CAAAA,OAAMA,GAAGC,aAAaA,SAAAA,IACtDoB,IAAId,OAAOR,YAAAA,EAAcQ,OAAOP,CAAAA,OAAMA,GAAGC,aAAaA,SAAAA;IAC9D;AACA,UAAMqC,cAActB,SAASK,IAAIS;AACjC,UAAMS,eAAetB,UAAU;AAC/B,WAAOI,IAAImB,MAAMD,cAAcD,WAAAA;EACjC;AACF;AAtCUlC;AAJH,IAAMD,4BAAN;","names":["hasTimestamp","bw","timestamp","undefined","MemoryBoundWitnessDiviner","BoundWitnessDiviner","divineHandler","payloads","filter","assertEx","isBoundWitnessDivinerQueryPayload","pop","archivist","archivistInstance","addresses","payload_hashes","payload_schemas","limit","offset","order","sourceQuery","destination","bws","all","isBoundWitness","reverse","allAddresses","map","address","hexFromHexString","exists","length","containsAll","_a","$meta","Array","isArray","targetFilter","targetDestinationField","parsedLimit","parsedOffset","slice"]}
@@ -33,10 +33,7 @@ var _MemoryBoundWitnessDiviner = class _MemoryBoundWitnessDiviner extends BoundW
33
33
  bws = bws.filter((bw) => {
34
34
  var _a2;
35
35
  const targetDestinationField = (_a2 = bw == null ? void 0 : bw.$meta) == null ? void 0 : _a2.destination;
36
- return targetDestinationField !== void 0 && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ? (
37
- // Check that the targetDestinationField contains all the elements in the targetFilter
38
- containsAll(targetFilter, targetDestinationField ?? [])
39
- ) : false;
36
+ return targetDestinationField !== void 0 && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ? containsAll(targetFilter, targetDestinationField ?? []) : false;
40
37
  });
41
38
  }
42
39
  if (timestamp !== void 0) {
@@ -52,4 +49,4 @@ var MemoryBoundWitnessDiviner = _MemoryBoundWitnessDiviner;
52
49
  export {
53
50
  MemoryBoundWitnessDiviner
54
51
  };
55
- //# sourceMappingURL=index.js.map
52
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/MemoryBoundWitnessDiviner.ts"],"sourcesContent":["import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { hexFromHexString } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport {\n BoundWitnessDivinerParams,\n BoundWitnessDivinerQueryPayload,\n isBoundWitnessDivinerQueryPayload,\n} from '@xyo-network/diviner-boundwitness-model'\nimport { WithMeta } from '@xyo-network/payload-model'\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\ntype WithTimestamp = BoundWitness & { timestamp: number }\nconst hasTimestamp = (bw: BoundWitness): bw is WithTimestamp => bw.timestamp !== undefined\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 // eslint-disable-next-line complexity\n protected override async divineHandler(payloads?: TIn[]) {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n if (!filter) return []\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter\n let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]\n if (order === 'desc') bws = bws.reverse()\n const allAddresses = addresses?.map(address => hexFromHexString(address)).filter(exists)\n if (allAddresses?.length) bws = bws.filter(bw => containsAll(bw.addresses, allAddresses))\n if (payload_hashes?.length) bws = bws.filter(bw => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas?.length) bws = bws.filter(bw => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery) bws = bws.filter(bw => (bw?.$meta as { sourceQuery?: string })?.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?.$meta as { destination?: string[] })?.destination\n // If the destination field is an array and contains at least one element\n return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0\n // Check that the targetDestinationField contains all the elements in the targetFilter\n ? containsAll(targetFilter, targetDestinationField ?? [])\n // Otherwise, filter it out\n : false\n })\n }\n if (timestamp !== undefined) {\n bws\n = order === 'desc'\n ? bws.filter(hasTimestamp).filter(bw => bw.timestamp <= timestamp)\n : bws.filter(hasTimestamp).filter(bw => bw.timestamp >= timestamp)\n }\n const parsedLimit = limit ?? bws.length\n const parsedOffset = offset ?? 0\n return bws.slice(parsedOffset, parsedLimit) as WithMeta<TOut>[]\n }\n}\n"],"mappings":";;;;AAAA,SAASA,mBAAmB;AAC5B,SAASC,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,wBAAwB;AACjC,SAAuBC,sBAAsB;AAC7C,SAASC,2BAA2B;AACpC,SAGEC,yCACK;AAsDP,IAAMC,eAAe,wBAACC,OAA0CA,GAAGC,cAAcC,QAA5D;AAEd,IAAMC,6BAAN,MAAMA,mCAIHC,oBAAAA;;EAER,MAAyBC,cAAcC,UAAkB;AAxE3D;AAyEI,UAAMC,SAASC,UAASF,0CAAUC,OAAOE,uCAAjBH,mBAAqDI,OAAO,MAAM,uBAAA;AAC1F,QAAI,CAACH,OAAQ,QAAO,CAAA;AACpB,UAAMI,YAAYH,SAAS,MAAM,KAAKI,kBAAiB,GAAI,MAAM,6BAAA;AACjE,UAAM,EAAEC,WAAWC,gBAAgBC,iBAAiBC,OAAOC,QAAQC,QAAQ,QAAQC,aAAaC,aAAanB,UAAS,IAAKM;AAC3H,QAAIc,OAAQ,QAAMV,4CAAWW,QAAXX,uCAAuB,CAAA,GAAIJ,OAAOgB,cAAAA;AACpD,QAAIL,UAAU,OAAQG,OAAMA,IAAIG,QAAO;AACvC,UAAMC,eAAeZ,uCAAWa,IAAIC,CAAAA,YAAWC,iBAAiBD,OAAAA,GAAUpB,OAAOsB;AACjF,QAAIJ,6CA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undWitness","BoundWitnessDiviner","isBoundWitnessDivinerQueryPayload","hasTimestamp","bw","timestamp","undefined","MemoryBoundWitnessDiviner","BoundWitnessDiviner","divineHandler","payloads","filter","assertEx","isBoundWitnessDivinerQueryPayload","pop","archivist","archivistInstance","addresses","payload_hashes","payload_schemas","limit","offset","order","sourceQuery","destination","bws","all","isBoundWitness","reverse","allAddresses","map","address","hexFromHexString","exists","length","containsAll","_a","$meta","Array","isArray","targetFilter","targetDestinationField","parsedLimit","parsedOffset","slice"]}
package/package.json CHANGED
@@ -10,23 +10,23 @@
10
10
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
11
11
  },
12
12
  "dependencies": {
13
- "@xylabs/array": "^3.6.6",
14
- "@xylabs/assert": "^3.6.6",
15
- "@xylabs/exists": "^3.6.6",
16
- "@xylabs/hex": "^3.6.6",
17
- "@xyo-network/boundwitness-model": "^2.110.19",
18
- "@xyo-network/diviner-boundwitness-abstract": "^2.110.19",
19
- "@xyo-network/diviner-boundwitness-model": "^2.110.19",
20
- "@xyo-network/payload-model": "^2.110.19"
13
+ "@xylabs/array": "^3.6.8",
14
+ "@xylabs/assert": "^3.6.8",
15
+ "@xylabs/exists": "^3.6.8",
16
+ "@xylabs/hex": "^3.6.8",
17
+ "@xyo-network/boundwitness-model": "^2.111.0",
18
+ "@xyo-network/diviner-boundwitness-abstract": "^2.111.0",
19
+ "@xyo-network/diviner-boundwitness-model": "^2.111.0",
20
+ "@xyo-network/payload-model": "^2.111.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@xylabs/ts-scripts-yarn3": "^3.14.1",
24
- "@xylabs/tsconfig": "^3.14.1",
25
- "@xyo-network/account": "^2.110.19",
26
- "@xyo-network/archivist-memory": "^2.110.19",
27
- "@xyo-network/boundwitness-builder": "^2.110.19",
28
- "@xyo-network/node-memory": "^2.110.19",
29
- "@xyo-network/payload-builder": "^2.110.19",
23
+ "@xylabs/ts-scripts-yarn3": "^3.15.5",
24
+ "@xylabs/tsconfig": "^3.15.5",
25
+ "@xyo-network/account": "^2.111.0",
26
+ "@xyo-network/archivist-memory": "^2.111.0",
27
+ "@xyo-network/boundwitness-builder": "^2.111.0",
28
+ "@xyo-network/node-memory": "^2.111.0",
29
+ "@xyo-network/payload-builder": "^2.111.0",
30
30
  "typescript": "^5.5.4"
31
31
  },
32
32
  "description": "Primary SDK for using XYO Protocol 2.0",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "import": {
42
42
  "types": "./dist/browser/index.d.mts",
43
- "default": "./dist/browser/index.js"
43
+ "default": "./dist/browser/index.mjs"
44
44
  }
45
45
  },
46
46
  "node": {
@@ -50,14 +50,14 @@
50
50
  },
51
51
  "import": {
52
52
  "types": "./dist/node/index.d.mts",
53
- "default": "./dist/node/index.js"
53
+ "default": "./dist/node/index.mjs"
54
54
  }
55
55
  }
56
56
  },
57
57
  "./package.json": "./package.json"
58
58
  },
59
59
  "main": "dist/node/index.cjs",
60
- "module": "dist/node/index.js",
60
+ "module": "dist/node/index.mjs",
61
61
  "homepage": "https://xyo.network",
62
62
  "license": "LGPL-3.0-only",
63
63
  "publishConfig": {
@@ -68,6 +68,6 @@
68
68
  "url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
69
69
  },
70
70
  "sideEffects": false,
71
- "version": "2.110.19",
71
+ "version": "2.111.0",
72
72
  "type": "module"
73
73
  }
@@ -77,11 +77,11 @@ export class MemoryBoundWitnessDiviner<
77
77
  const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter
78
78
  let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]
79
79
  if (order === 'desc') bws = bws.reverse()
80
- const allAddresses = addresses?.map((address) => hexFromHexString(address)).filter(exists)
81
- if (allAddresses?.length) bws = bws.filter((bw) => containsAll(bw.addresses, allAddresses))
82
- if (payload_hashes?.length) bws = bws.filter((bw) => containsAll(bw.payload_hashes, payload_hashes))
83
- if (payload_schemas?.length) bws = bws.filter((bw) => containsAll(bw.payload_schemas, payload_schemas))
84
- if (sourceQuery) bws = bws.filter((bw) => (bw?.$meta as { sourceQuery?: string })?.sourceQuery === sourceQuery)
80
+ const allAddresses = addresses?.map(address => hexFromHexString(address)).filter(exists)
81
+ if (allAddresses?.length) bws = bws.filter(bw => containsAll(bw.addresses, allAddresses))
82
+ if (payload_hashes?.length) bws = bws.filter(bw => containsAll(bw.payload_hashes, payload_hashes))
83
+ if (payload_schemas?.length) bws = bws.filter(bw => containsAll(bw.payload_schemas, payload_schemas))
84
+ if (sourceQuery) bws = bws.filter(bw => (bw?.$meta as { sourceQuery?: string })?.sourceQuery === sourceQuery)
85
85
  // If there's a destination filter of the right kind
86
86
  if (destination && Array.isArray(destination) && destination?.length > 0) {
87
87
  const targetFilter = assertEx(destination, () => 'Missing destination')
@@ -89,18 +89,18 @@ export class MemoryBoundWitnessDiviner<
89
89
  bws = bws.filter((bw) => {
90
90
  const targetDestinationField = (bw?.$meta as { destination?: string[] })?.destination
91
91
  // If the destination field is an array and contains at least one element
92
- return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ?
93
- // Check that the targetDestinationField contains all the elements in the targetFilter
94
- containsAll(targetFilter, targetDestinationField ?? [])
95
- // Otherwise, filter it out
92
+ return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0
93
+ // Check that the targetDestinationField contains all the elements in the targetFilter
94
+ ? containsAll(targetFilter, targetDestinationField ?? [])
95
+ // Otherwise, filter it out
96
96
  : false
97
97
  })
98
98
  }
99
99
  if (timestamp !== undefined) {
100
- bws =
101
- order === 'desc' ?
102
- bws.filter(hasTimestamp).filter((bw) => bw.timestamp <= timestamp)
103
- : bws.filter(hasTimestamp).filter((bw) => bw.timestamp >= timestamp)
100
+ bws
101
+ = order === 'desc'
102
+ ? bws.filter(hasTimestamp).filter(bw => bw.timestamp <= timestamp)
103
+ : bws.filter(hasTimestamp).filter(bw => bw.timestamp >= timestamp)
104
104
  }
105
105
  const parsedLimit = limit ?? bws.length
106
106
  const parsedOffset = offset ?? 0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/MemoryBoundWitnessDiviner.ts"],"sourcesContent":["import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { hexFromHexString } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport {\n BoundWitnessDivinerParams,\n BoundWitnessDivinerQueryPayload,\n isBoundWitnessDivinerQueryPayload,\n} from '@xyo-network/diviner-boundwitness-model'\nimport { WithMeta } from '@xyo-network/payload-model'\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\ntype WithTimestamp = BoundWitness & { timestamp: number }\nconst hasTimestamp = (bw: BoundWitness): bw is WithTimestamp => bw.timestamp !== undefined\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 // eslint-disable-next-line complexity\n protected override async divineHandler(payloads?: TIn[]) {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n if (!filter) return []\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter\n let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]\n if (order === 'desc') bws = bws.reverse()\n const allAddresses = addresses?.map((address) => hexFromHexString(address)).filter(exists)\n if (allAddresses?.length) bws = bws.filter((bw) => containsAll(bw.addresses, allAddresses))\n if (payload_hashes?.length) bws = bws.filter((bw) => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas?.length) bws = bws.filter((bw) => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery) bws = bws.filter((bw) => (bw?.$meta as { sourceQuery?: string })?.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?.$meta as { destination?: string[] })?.destination\n // If the destination field is an array and contains at least one element\n return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ?\n // Check that the targetDestinationField contains all the elements in the targetFilter\n containsAll(targetFilter, targetDestinationField ?? [])\n // Otherwise, filter it out\n : false\n })\n }\n if (timestamp !== undefined) {\n bws =\n order === 'desc' ?\n bws.filter(hasTimestamp).filter((bw) => bw.timestamp <= timestamp)\n : bws.filter(hasTimestamp).filter((bw) => bw.timestamp >= timestamp)\n }\n const parsed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MA,IAAId,OAAO,CAACP,OAAQA,IAAIgC,OAAoCb,gBAAgBA,WAAAA;AAEnG,QAAIC,eAAea,MAAMC,QAAQd,WAAAA,KAAgBA,aAAaU,SAAS,GAAG;AACxE,YAAMK,eAAe3B,SAASY,aAAa,MAAM,qBAAA;AAEjDC,YAAMA,IAAId,OAAO,CAACP,OAAAA;AAChB,cAAMoC,yBAA0BpC,IAAIgC,OAAsCZ;AAE1E,eAAOgB,2BAA2BlC,UAAa+B,MAAMC,QAAQE,sBAAAA,KAA2BA,uBAAuBN,SAAS;;UAEpHC,YAAYI,cAAcC,0BAA0B,CAAA,CAAE;YAEtD;MACN,CAAA;IACF;AACA,QAAInC,cAAcC,QAAW;AAC3BmB,YACEH,UAAU,SACRG,IAAId,OAAOR,YAAAA,EAAcQ,OAAO,CAACP,OAAOA,GAAGC,aAAaA,SAAAA,IACxDoB,IAAId,OAAOR,YAAAA,EAAcQ,OAAO,CAACP,OAAOA,GAAGC,aAAaA,SAAAA;IAC9D;AACA,UAAMoC,cAAcrB,SAASK,IAAIS;AACjC,UAAMQ,eAAerB,UAAU;AAC/B,WAAOI,IAAIkB,MAAMD,cAAcD,WAAAA;EACjC;AACF;","names":["containsAll","assertEx","exists","hexFromHexString","isBoundWitness","BoundWitnessDiviner","isBoundWitnessDivinerQueryPayload","hasTimestamp","bw","timestamp","undefined","MemoryBoundWitnessDiviner","BoundWitnessDiviner","divineHandler","payloads","filter","assertEx","isBoundWitnessDivinerQueryPayload","pop","archivist","archivistInstance","addresses","payload_hashes","payload_schemas","limit","offset","order","sourceQuery","destination","bws","all","isBoundWitness","reverse","allAddresses","map","address","hexFromHexString","exists","length","containsAll","$meta","Array","isArray","targetFilter","targetDestinationField","parsedLimit","parsedOffset","slice"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/MemoryBoundWitnessDiviner.ts"],"sourcesContent":["import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { hexFromHexString } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport {\n BoundWitnessDivinerParams,\n BoundWitnessDivinerQueryPayload,\n isBoundWitnessDivinerQueryPayload,\n} from '@xyo-network/diviner-boundwitness-model'\nimport { WithMeta } from '@xyo-network/payload-model'\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\ntype WithTimestamp = BoundWitness & { timestamp: number }\nconst hasTimestamp = (bw: BoundWitness): bw is WithTimestamp => bw.timestamp !== undefined\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 // eslint-disable-next-line complexity\n protected override async divineHandler(payloads?: TIn[]) {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n if (!filter) return []\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter\n let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]\n if (order === 'desc') bws = bws.reverse()\n const allAddresses = addresses?.map((address) => hexFromHexString(address)).filter(exists)\n if (allAddresses?.length) bws = bws.filter((bw) => containsAll(bw.addresses, allAddresses))\n if (payload_hashes?.length) bws = bws.filter((bw) => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas?.length) bws = bws.filter((bw) => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery) bws = bws.filter((bw) => (bw?.$meta as { sourceQuery?: string })?.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?.$meta as { destination?: string[] })?.destination\n // If the destination field is an array and contains at least one element\n return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ?\n // Check that the targetDestinationField contains all the elements in the targetFilter\n containsAll(targetFilter, targetDestinationField ?? [])\n // Otherwise, filter it out\n : false\n })\n }\n if (timestamp !== undefined) {\n bws =\n order === 'desc' ?\n bws.filter(hasTimestamp).filter((bw) => bw.timestamp <= timestamp)\n : bws.filter(hasTimestamp).filter((bw) => bw.timestamp >= timestamp)\n }\n const parsedLimit = limit ?? bws.length\n const parsedOffset = offset ?? 0\n return bws.slice(parsedOffset, parsedLimit) as WithMeta<TOut>[]\n }\n}\n"],"mappings":";;;;AAAA,SAASA,mBAAmB;AAC5B,SAASC,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,wBAAwB;AACjC,SAAuBC,sBAAsB;AAC7C,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OAAAA;AAChB,cAAMoC,yBAA0BpC,IAAIgC,OAAsCZ;AAE1E,eAAOgB,2BAA2BlC,UAAa+B,MAAMC,QAAQE,sBAAAA,KAA2BA,uBAAuBN,SAAS;;UAEpHC,YAAYI,cAAcC,0BAA0B,CAAA,CAAE;YAEtD;MACN,CAAA;IACF;AACA,QAAInC,cAAcC,QAAW;AAC3BmB,YACEH,UAAU,SACRG,IAAId,OAAOR,YAAAA,EAAcQ,OAAO,CAACP,OAAOA,GAAGC,aAAaA,SAAAA,IACxDoB,IAAId,OAAOR,YAAAA,EAAcQ,OAAO,CAACP,OAAOA,GAAGC,aAAaA,SAAAA;IAC9D;AACA,UAAMoC,cAAcrB,SAASK,IAAIS;AACjC,UAAMQ,eAAerB,UAAU;AAC/B,WAAOI,IAAIkB,MAAMD,cAAcD,WAAAA;EACjC;AACF;","names":["containsAll","assertEx","exists","hexFromHexString","isBoundWitness","BoundWitnessDiviner","isBoundWitnessDivinerQueryPayload","hasTimestamp","bw","timestamp","undefined","MemoryBoundWitnessDiviner","BoundWitnessDiviner","divineHandler","payloads","filter","assertEx","isBoundWitnessDivinerQueryPayload","pop","archivist","archivistInstance","addresses","payload_hashes","payload_schemas","limit","offset","order","sourceQuery","destination","bws","all","isBoundWitness","reverse","allAddresses","map","address","hexFromHexString","exists","length","containsAll","$meta","Array","isArray","targetFilter","targetDestinationField","parsedLimit","parsedOffset","slice"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/MemoryBoundWitnessDiviner.ts"],"sourcesContent":["import { containsAll } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { hexFromHexString } from '@xylabs/hex'\nimport { BoundWitness, isBoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessDiviner } from '@xyo-network/diviner-boundwitness-abstract'\nimport {\n BoundWitnessDivinerParams,\n BoundWitnessDivinerQueryPayload,\n isBoundWitnessDivinerQueryPayload,\n} from '@xyo-network/diviner-boundwitness-model'\nimport { WithMeta } from '@xyo-network/payload-model'\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\ntype WithTimestamp = BoundWitness & { timestamp: number }\nconst hasTimestamp = (bw: BoundWitness): bw is WithTimestamp => bw.timestamp !== undefined\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 // eslint-disable-next-line complexity\n protected override async divineHandler(payloads?: TIn[]) {\n const filter = assertEx(payloads?.filter(isBoundWitnessDivinerQueryPayload)?.pop(), () => 'Missing query payload')\n if (!filter) return []\n const archivist = assertEx(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const { addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp } = filter\n let bws = ((await archivist?.all?.()) ?? []).filter(isBoundWitness) as WithMeta<BoundWitness>[]\n if (order === 'desc') bws = bws.reverse()\n const allAddresses = addresses?.map((address) => hexFromHexString(address)).filter(exists)\n if (allAddresses?.length) bws = bws.filter((bw) => containsAll(bw.addresses, allAddresses))\n if (payload_hashes?.length) bws = bws.filter((bw) => containsAll(bw.payload_hashes, payload_hashes))\n if (payload_schemas?.length) bws = bws.filter((bw) => containsAll(bw.payload_schemas, payload_schemas))\n if (sourceQuery) bws = bws.filter((bw) => (bw?.$meta as { sourceQuery?: string })?.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?.$meta as { destination?: string[] })?.destination\n // If the destination field is an array and contains at least one element\n return targetDestinationField !== undefined && Array.isArray(targetDestinationField) && targetDestinationField.length > 0 ?\n // Check that the targetDestinationField contains all the elements in the targetFilter\n containsAll(targetFilter, targetDestinationField ?? [])\n // Otherwise, filter it out\n : false\n })\n }\n if (timestamp !== undefined) {\n bws =\n order === 'desc' ?\n bws.filter(hasTimestamp).filter((bw) => bw.timestamp <= timestamp)\n : bws.filter(hasTimestamp).filter((bw) => bw.timestamp >= timestamp)\n }\n const parsedLimit = limit ?? bws.length\n const parsedOffset = offset ?? 0\n return bws.slice(parsedOffset, parsedLimit) as WithMeta<TOut>[]\n }\n}\n"],"mappings":";;;;AAAA,SAASA,mBAAmB;AAC5B,SAASC,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,wBAAwB;AACjC,SAAuBC,sBAAsB;AAC7C,SAASC,2BAA2B;AACpC,SAGEC,yCACK;AAsDP,IAAMC,eAAe,wBAACC,OAA0CA,GAAGC,cAAcC,QAA5D;AAEd,IAAMC,6BAAN,MAAMA,mCAIHC,oBAAAA;;EAER,MAAyBC,cAAcC,UAAkB;AAxE3D;AAyEI,UAAMC,SAASC,UAASF,0CAAUC,OAAO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AAuBP,SAAS;;UAEpHC,YAAYK,cAAcC,0BAA0B,CAAA,CAAE;YAEtD;MACN,CAAA;IACF;AACA,QAAIpC,cAAcC,QAAW;AAC3BmB,YACEH,UAAU,SACRG,IAAId,OAAOR,YAAAA,EAAcQ,OAAO,CAACP,OAAOA,GAAGC,aAAaA,SAAAA,IACxDoB,IAAId,OAAOR,YAAAA,EAAcQ,OAAO,CAACP,OAAOA,GAAGC,aAAaA,SAAAA;IAC9D;AACA,UAAMqC,cAActB,SAASK,IAAIS;AACjC,UAAMS,eAAetB,UAAU;AAC/B,WAAOI,IAAImB,MAAMD,cAAcD,WAAAA;EACjC;AACF;AAtCUlC;AAJH,IAAMD,4BAAN;","names":["containsAll","assertEx","exists","hexFromHexString","isBoundWitness","BoundWitnessDiviner","isBoundWitnessDivinerQueryPayload","hasTimestamp","bw","timestamp","undefined","MemoryBoundWitnessDiviner","BoundWitnessDiviner","divineHandler","payloads","filter","assertEx","isBoundWitnessDivinerQueryPayload","pop","archivist","archivistInstance","addresses","payload_hashes","payload_schemas","limit","offset","order","sourceQuery","destination","bws","all","isBoundWitness","reverse","allAddresses","map","address","hexFromHexString","exists","length","containsAll","_a","$meta","Array","isArray","targetFilter","targetDestinationField","parsedLimit","parsedOffset","slice"]}