@xyo-network/diviner-jsonpath-aggregate-memory 3.8.0 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,32 @@
1
- export * from './Diviner.ts';
2
- export * from './jsonpath/index.ts';
3
- //# sourceMappingURL=index.d.ts.map
1
+ import { AbstractDiviner } from '@xyo-network/diviner-abstract';
2
+ import { JsonPathAggregateDivinerParams, PayloadTransformer, SchemaToPayloadTransformersDictionary, SchemaToJsonPathTransformExpressionsDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model';
3
+ import { DivinerModuleEventData, DivinerInstance } from '@xyo-network/diviner-model';
4
+ import * as _xyo_network_payload_model from '@xyo-network/payload-model';
5
+ import { Payload, Schema } from '@xyo-network/payload-model';
6
+ import * as _xylabs_object from '@xylabs/object';
7
+
8
+ declare class JsonPathAggregateDiviner<TParams extends JsonPathAggregateDivinerParams = JsonPathAggregateDivinerParams, TIn extends Payload = Payload, TOut extends Payload = Payload, TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut>> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {
9
+ static readonly configSchemas: Schema[];
10
+ static readonly defaultConfigSchema: Schema;
11
+ protected _transforms: PayloadTransformer[] | undefined;
12
+ private _payloadTransformers;
13
+ private _transformableSchemas;
14
+ protected get destinationSchema(): string;
15
+ protected get payloadTransformers(): SchemaToPayloadTransformersDictionary;
16
+ protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary;
17
+ protected get transformableSchemas(): string[];
18
+ protected divineHandler(payloads?: TIn[]): Promise<TOut[]>;
19
+ protected isTransformablePayload: (x: Payload) => boolean;
20
+ protected isTransformableSchema: (schema?: string | null) => boolean;
21
+ }
22
+
23
+ declare const jsonPathToTransformersDictionary: (schemaTransforms: SchemaToJsonPathTransformExpressionsDictionary) => SchemaToPayloadTransformersDictionary;
24
+
25
+ declare const reducePayloads: <T extends Payload = _xylabs_object.DeepRestrictToStringKeys<{
26
+ schema: _xyo_network_payload_model.Schema;
27
+ }>>(payloads: Payload[], payloadTransformers: SchemaToPayloadTransformersDictionary, destinationSchema: string, excludeSources?: boolean) => Promise<T>;
28
+ declare const reducePayloadsArray: <T extends Payload = _xylabs_object.DeepRestrictToStringKeys<{
29
+ schema: _xyo_network_payload_model.Schema;
30
+ }>>(payloadsArray: Payload[][], payloadTransformers: SchemaToPayloadTransformersDictionary, destinationSchema: string, excludeSources?: boolean) => Promise<T[]>;
31
+
32
+ export { JsonPathAggregateDiviner, jsonPathToTransformersDictionary, reducePayloads, reducePayloadsArray };
@@ -27,7 +27,7 @@ var reducePayloads = async (payloads, payloadTransformers, destinationSchema, ex
27
27
  return transformers ? transformers.map((transform) => transform(payload)) : [];
28
28
  });
29
29
  const baseObject = excludeSources ? {} : { sources: await PayloadBuilder.dataHashes(payloads) };
30
- return await new PayloadBuilder({ schema: destinationSchema }).fields(Object.assign(baseObject, ...payloadFields)).build();
30
+ return new PayloadBuilder({ schema: destinationSchema }).fields(Object.assign(baseObject, ...payloadFields)).build();
31
31
  };
32
32
  var reducePayloadsArray = async (payloadsArray, payloadTransformers, destinationSchema, excludeSources = false) => {
33
33
  return await Promise.all(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/Diviner.ts","../../src/jsonpath/jsonPathToTransformersDictionary.ts","../../src/jsonpath/reducePayloads.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type {\n JsonPathAggregateDivinerParams,\n PayloadTransformer,\n SchemaToJsonPathTransformExpressionsDictionary,\n SchemaToPayloadTransformersDictionary,\n} from '@xyo-network/diviner-jsonpath-aggregate-model'\nimport { JsonPathAggregateDivinerConfigSchema } from '@xyo-network/diviner-jsonpath-aggregate-model'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { PayloadSchema } from '@xyo-network/payload-model'\nimport { combinationsByBoundwitness, combinationsBySchema } from '@xyo-network/payload-utils'\n\nimport { jsonPathToTransformersDictionary, reducePayloads } from './jsonpath/index.ts'\n\nconst moduleName = 'JsonPathAggregateDiviner'\n\nexport class JsonPathAggregateDiviner<\n TParams extends JsonPathAggregateDivinerParams = JsonPathAggregateDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\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, JsonPathAggregateDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = JsonPathAggregateDivinerConfigSchema\n\n protected _transforms: PayloadTransformer[] | undefined\n\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n private _transformableSchemas: string[] | undefined\n\n /**\n * The schema to use for the destination payloads\n */\n protected get destinationSchema(): string {\n return this.config.destinationSchema ?? PayloadSchema\n }\n\n /**\n * Dictionary of schemas to payload transformers\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return assertEx(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`)\n }\n\n /**\n * List of transformable schemas for this diviner\n */\n protected get transformableSchemas(): string[] {\n if (!this._transformableSchemas) this._transformableSchemas = Object.keys(this.schemaTransforms)\n return this._transformableSchemas\n }\n\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n if (!payloads) return []\n const strippedPayloads = payloads.map((payload) => {\n const p = { ...payload } as TIn\n return PayloadBuilder.omitMeta(p as TIn)\n })\n const combinations\n = this.transformableSchemas.includes(BoundWitnessSchema)\n ? await combinationsByBoundwitness(strippedPayloads)\n : await combinationsBySchema(strippedPayloads, this.transformableSchemas)\n return await Promise.all(\n combinations.map((combination) => {\n return reducePayloads<TOut>(combination, this.payloadTransformers, this.destinationSchema, this.config.excludeSources ?? false)\n }),\n )\n }\n\n /**\n * Identifies if a payload is one that is transformed by this diviner\n * @param x The candidate payload\n * @returns True if the payload is one transformed by this diviner, false otherwise\n */\n protected isTransformablePayload = (x: Payload) => {\n return this.transformableSchemas.includes(x?.schema)\n }\n\n /**\n * Identifies if a schema is one that is transformed by this diviner\n * @param schema The candidate schema\n * @returns True if this schema is one transformed by this diviner, false otherwise\n */\n protected isTransformableSchema = (schema?: string | null) => {\n return typeof schema === 'string' ? this.transformableSchemas.includes(schema) : false\n }\n}\n","import type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model'\nimport { toPayloadTransformer } from '@xyo-network/diviner-jsonpath-memory'\n\n/**\n * Materializes the JSON-path expressions into memoized functions by converting a\n * dictionary of schema to JSON Path transform expressions to a dictionary\n * of schema to payload transformers\n * @param schemaTransforms The schema transforms to convert\n * @returns A dictionary of schema to payload transformers\n */\nexport const jsonPathToTransformersDictionary = (\n schemaTransforms: SchemaToJsonPathTransformExpressionsDictionary,\n): SchemaToPayloadTransformersDictionary => {\n return Object.fromEntries(\n Object.entries(schemaTransforms).map(([schema, jsonPathTransformerExpressions]) => {\n const transformers = jsonPathTransformerExpressions.map(toPayloadTransformer)\n return [schema, transformers]\n }),\n )\n}\n","import { exists } from '@xylabs/exists'\nimport type { SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, WithoutSchema } from '@xyo-network/payload-model'\n\n/**\n * Reduces the payloads to a single payload using the supplied transformers\n * @param payloads The payloads to reduce\n * @param payloadTransformers The transformers to use to convert the payloads to the destination payload\n * @param destinationSchema The schema of the destination payload\n * @param excludeSources Exclude the source hashes from the destination payload\n * @returns The reduced payload\n */\nexport const reducePayloads = async <T extends Payload = Payload>(\n payloads: Payload[],\n payloadTransformers: SchemaToPayloadTransformersDictionary,\n destinationSchema: string,\n excludeSources = false,\n): Promise<T> => {\n // Use the payload transformers to convert the fields from the source payloads to the destination fields\n const payloadFields = payloads.filter(exists).flatMap<WithoutSchema<Payload>[]>((payload) => {\n // Find the transformers for this payload\n const transformers = payloadTransformers[payload.schema]\n // If transformers exist, apply them to the payload otherwise return an empty array\n return transformers ? transformers.map(transform => transform(payload)) : []\n })\n // Include all the sources for reference\n const baseObject = excludeSources ? {} : { sources: await PayloadBuilder.dataHashes(payloads) }\n // Build and return the payload\n return await new PayloadBuilder<T>({ schema: destinationSchema }).fields(Object.assign(baseObject, ...payloadFields)).build()\n}\n\n/**\n * Reduces the arrays of payload arrays to an array of payloads using the supplied transformers\n * @param payloadsArray The arrays of payloads to reduce\n * @param payloadTransformers The transformers to use to convert the payloads to the destination payloads\n * @param excludeSources Exclude the source hashes from the destination payload\n * @returns The reduced payloads\n */\nexport const reducePayloadsArray = async <T extends Payload = Payload>(\n payloadsArray: Payload[][],\n payloadTransformers: SchemaToPayloadTransformersDictionary,\n destinationSchema: string,\n excludeSources = false,\n): Promise<T[]> => {\n return await Promise.all(\n payloadsArray.map(async (payloads) => {\n return await reducePayloads<T>(payloads, payloadTransformers, destinationSchema, excludeSources)\n }),\n )\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAOhC,SAAS,4CAA4C;AAErD,SAAS,kBAAAA,uBAAsB;AAE/B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B,4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}
1
+ {"version":3,"sources":["../../src/Diviner.ts","../../src/jsonpath/jsonPathToTransformersDictionary.ts","../../src/jsonpath/reducePayloads.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { BoundWitnessSchema } from '@xyo-network/boundwitness-model'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type {\n JsonPathAggregateDivinerParams,\n PayloadTransformer,\n SchemaToJsonPathTransformExpressionsDictionary,\n SchemaToPayloadTransformersDictionary,\n} from '@xyo-network/diviner-jsonpath-aggregate-model'\nimport { JsonPathAggregateDivinerConfigSchema } from '@xyo-network/diviner-jsonpath-aggregate-model'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport { PayloadSchema } from '@xyo-network/payload-model'\nimport { combinationsByBoundwitness, combinationsBySchema } from '@xyo-network/payload-utils'\n\nimport { jsonPathToTransformersDictionary, reducePayloads } from './jsonpath/index.ts'\n\nconst moduleName = 'JsonPathAggregateDiviner'\n\nexport class JsonPathAggregateDiviner<\n TParams extends JsonPathAggregateDivinerParams = JsonPathAggregateDivinerParams,\n TIn extends Payload = Payload,\n TOut extends Payload = Payload,\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, JsonPathAggregateDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = JsonPathAggregateDivinerConfigSchema\n\n protected _transforms: PayloadTransformer[] | undefined\n\n private _payloadTransformers: SchemaToPayloadTransformersDictionary | undefined\n private _transformableSchemas: string[] | undefined\n\n /**\n * The schema to use for the destination payloads\n */\n protected get destinationSchema(): string {\n return this.config.destinationSchema ?? PayloadSchema\n }\n\n /**\n * Dictionary of schemas to payload transformers\n */\n protected get payloadTransformers(): SchemaToPayloadTransformersDictionary {\n if (!this._payloadTransformers) this._payloadTransformers = jsonPathToTransformersDictionary(this.schemaTransforms)\n return this._payloadTransformers\n }\n\n /**\n * The dictionary of schemas to JSON Path transform expressions\n */\n protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary {\n return assertEx(this.config?.schemaTransforms, () => `${moduleName}: Missing config.schemaTransforms section`)\n }\n\n /**\n * List of transformable schemas for this diviner\n */\n protected get transformableSchemas(): string[] {\n if (!this._transformableSchemas) this._transformableSchemas = Object.keys(this.schemaTransforms)\n return this._transformableSchemas\n }\n\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n if (!payloads) return []\n const strippedPayloads = payloads.map((payload) => {\n const p = { ...payload } as TIn\n return PayloadBuilder.omitMeta(p as TIn)\n })\n const combinations\n = this.transformableSchemas.includes(BoundWitnessSchema)\n ? await combinationsByBoundwitness(strippedPayloads)\n : await combinationsBySchema(strippedPayloads, this.transformableSchemas)\n return await Promise.all(\n combinations.map((combination) => {\n return reducePayloads<TOut>(combination, this.payloadTransformers, this.destinationSchema, this.config.excludeSources ?? false)\n }),\n )\n }\n\n /**\n * Identifies if a payload is one that is transformed by this diviner\n * @param x The candidate payload\n * @returns True if the payload is one transformed by this diviner, false otherwise\n */\n protected isTransformablePayload = (x: Payload) => {\n return this.transformableSchemas.includes(x?.schema)\n }\n\n /**\n * Identifies if a schema is one that is transformed by this diviner\n * @param schema The candidate schema\n * @returns True if this schema is one transformed by this diviner, false otherwise\n */\n protected isTransformableSchema = (schema?: string | null) => {\n return typeof schema === 'string' ? this.transformableSchemas.includes(schema) : false\n }\n}\n","import type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model'\nimport { toPayloadTransformer } from '@xyo-network/diviner-jsonpath-memory'\n\n/**\n * Materializes the JSON-path expressions into memoized functions by converting a\n * dictionary of schema to JSON Path transform expressions to a dictionary\n * of schema to payload transformers\n * @param schemaTransforms The schema transforms to convert\n * @returns A dictionary of schema to payload transformers\n */\nexport const jsonPathToTransformersDictionary = (\n schemaTransforms: SchemaToJsonPathTransformExpressionsDictionary,\n): SchemaToPayloadTransformersDictionary => {\n return Object.fromEntries(\n Object.entries(schemaTransforms).map(([schema, jsonPathTransformerExpressions]) => {\n const transformers = jsonPathTransformerExpressions.map(toPayloadTransformer)\n return [schema, transformers]\n }),\n )\n}\n","import { exists } from '@xylabs/exists'\nimport type { SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload, WithoutSchema } from '@xyo-network/payload-model'\n\n/**\n * Reduces the payloads to a single payload using the supplied transformers\n * @param payloads The payloads to reduce\n * @param payloadTransformers The transformers to use to convert the payloads to the destination payload\n * @param destinationSchema The schema of the destination payload\n * @param excludeSources Exclude the source hashes from the destination payload\n * @returns The reduced payload\n */\nexport const reducePayloads = async <T extends Payload = Payload>(\n payloads: Payload[],\n payloadTransformers: SchemaToPayloadTransformersDictionary,\n destinationSchema: string,\n excludeSources = false,\n): Promise<T> => {\n // Use the payload transformers to convert the fields from the source payloads to the destination fields\n const payloadFields = payloads.filter(exists).flatMap<WithoutSchema<Payload>[]>((payload) => {\n // Find the transformers for this payload\n const transformers = payloadTransformers[payload.schema]\n // If transformers exist, apply them to the payload otherwise return an empty array\n return transformers ? transformers.map(transform => transform(payload)) : []\n })\n // Include all the sources for reference\n const baseObject = excludeSources ? {} : { sources: await PayloadBuilder.dataHashes(payloads) }\n // Build and return the payload\n return new PayloadBuilder<T>({ schema: destinationSchema }).fields(Object.assign(baseObject, ...payloadFields)).build()\n}\n\n/**\n * Reduces the arrays of payload arrays to an array of payloads using the supplied transformers\n * @param payloadsArray The arrays of payloads to reduce\n * @param payloadTransformers The transformers to use to convert the payloads to the destination payloads\n * @param excludeSources Exclude the source hashes from the destination payload\n * @returns The reduced payloads\n */\nexport const reducePayloadsArray = async <T extends Payload = Payload>(\n payloadsArray: Payload[][],\n payloadTransformers: SchemaToPayloadTransformersDictionary,\n destinationSchema: string,\n excludeSources = false,\n): Promise<T[]> => {\n return await Promise.all(\n payloadsArray.map(async (payloads) => {\n return await reducePayloads<T>(payloads, payloadTransformers, destinationSchema, excludeSources)\n }),\n )\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,0BAA0B;AACnC,SAAS,uBAAuB;AAOhC,SAAS,4CAA4C;AAErD,SAAS,kBAAAA,uBAAsB;AAE/B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B,4BAA4B;;;ACbjE,SAAS,4BAA4B;AAS9B,IAAM,mCAAmC,CAC9C,qBAC0C;AAC1C,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,gBAAgB,EAAE,IAAI,CAAC,CAAC,QAAQ,8BAA8B,MAAM;AACjF,YAAM,eAAe,+BAA+B,IAAI,oBAAoB;AAC5E,aAAO,CAAC,QAAQ,YAAY;AAAA,IAC9B,CAAC;AAAA,EACH;AACF;;;ACnBA,SAAS,cAAc;AAEvB,SAAS,sBAAsB;AAWxB,IAAM,iBAAiB,OAC5B,UACA,qBACA,mBACA,iBAAiB,UACF;AAEf,QAAM,gBAAgB,SAAS,OAAO,MAAM,EAAE,QAAkC,CAAC,YAAY;AAE3F,UAAM,eAAe,oBAAoB,QAAQ,MAAM;AAEvD,WAAO,eAAe,aAAa,IAAI,eAAa,UAAU,OAAO,CAAC,IAAI,CAAC;AAAA,EAC7E,CAAC;AAED,QAAM,aAAa,iBAAiB,CAAC,IAAI,EAAE,SAAS,MAAM,eAAe,WAAW,QAAQ,EAAE;AAE9F,SAAO,IAAI,eAAkB,EAAE,QAAQ,kBAAkB,CAAC,EAAE,OAAO,OAAO,OAAO,YAAY,GAAG,aAAa,CAAC,EAAE,MAAM;AACxH;AASO,IAAM,sBAAsB,OACjC,eACA,qBACA,mBACA,iBAAiB,UACA;AACjB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B,aAAa,KAAK,qBAAqB,KAAK,mBAAmB,KAAK,OAAO,kBAAkB,KAAK;AAAA,MAChI,CAAC;AAAA,IACH;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,yBAAyB,CAAC,MAAe;AACjD,WAAO,KAAK,qBAAqB,SAAS,GAAG,MAAM;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,wBAAwB,CAAC,WAA2B;AAC5D,WAAO,OAAO,WAAW,WAAW,KAAK,qBAAqB,SAAS,MAAM,IAAI;AAAA,EACnF;AACF;","names":["PayloadBuilder","PayloadBuilder"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/diviner-jsonpath-aggregate-memory",
3
- "version": "3.8.0",
3
+ "version": "3.8.1",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -31,25 +31,25 @@
31
31
  "dependencies": {
32
32
  "@xylabs/assert": "^4.5.1",
33
33
  "@xylabs/exists": "^4.5.1",
34
- "@xyo-network/boundwitness-model": "^3.8.0",
35
- "@xyo-network/diviner-abstract": "^3.8.0",
36
- "@xyo-network/diviner-jsonpath-aggregate-model": "^3.8.0",
37
- "@xyo-network/diviner-jsonpath-memory": "^3.8.0",
38
- "@xyo-network/diviner-model": "^3.8.0",
39
- "@xyo-network/payload-builder": "^3.8.0",
40
- "@xyo-network/payload-model": "^3.8.0",
41
- "@xyo-network/payload-utils": "^3.8.0"
34
+ "@xyo-network/boundwitness-model": "^3.8.1",
35
+ "@xyo-network/diviner-abstract": "^3.8.1",
36
+ "@xyo-network/diviner-jsonpath-aggregate-model": "^3.8.1",
37
+ "@xyo-network/diviner-jsonpath-memory": "^3.8.1",
38
+ "@xyo-network/diviner-model": "^3.8.1",
39
+ "@xyo-network/payload-builder": "^3.8.1",
40
+ "@xyo-network/payload-model": "^3.8.1",
41
+ "@xyo-network/payload-utils": "^3.8.1"
42
42
  },
43
43
  "devDependencies": {
44
- "@xylabs/ts-scripts-yarn3": "^4.2.6",
45
- "@xylabs/tsconfig": "^4.2.6",
44
+ "@xylabs/ts-scripts-yarn3": "^5.0.22",
45
+ "@xylabs/tsconfig": "^5.0.22",
46
46
  "@xylabs/vitest-extended": "^4.5.1",
47
- "@xyo-network/account": "^3.8.0",
48
- "@xyo-network/account-model": "^3.8.0",
49
- "@xyo-network/boundwitness-builder": "^3.8.0",
50
- "@xyo-network/diviner-jsonpath-model": "^3.8.0",
47
+ "@xyo-network/account": "^3.8.1",
48
+ "@xyo-network/account-model": "^3.8.1",
49
+ "@xyo-network/boundwitness-builder": "^3.8.1",
50
+ "@xyo-network/diviner-jsonpath-model": "^3.8.1",
51
51
  "typescript": "^5.7.3",
52
- "vitest": "^3.0.4"
52
+ "vitest": "^3.0.5"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"
@@ -27,7 +27,7 @@ export const reducePayloads = async <T extends Payload = Payload>(
27
27
  // Include all the sources for reference
28
28
  const baseObject = excludeSources ? {} : { sources: await PayloadBuilder.dataHashes(payloads) }
29
29
  // Build and return the payload
30
- return await new PayloadBuilder<T>({ schema: destinationSchema }).fields(Object.assign(baseObject, ...payloadFields)).build()
30
+ return new PayloadBuilder<T>({ schema: destinationSchema }).fields(Object.assign(baseObject, ...payloadFields)).build()
31
31
  }
32
32
 
33
33
  /**
@@ -1,41 +0,0 @@
1
- import { AbstractDiviner } from '@xyo-network/diviner-abstract';
2
- import type { JsonPathAggregateDivinerParams, PayloadTransformer, SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model';
3
- import type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model';
4
- import type { Payload, Schema } from '@xyo-network/payload-model';
5
- export declare class JsonPathAggregateDiviner<TParams extends JsonPathAggregateDivinerParams = JsonPathAggregateDivinerParams, TIn extends Payload = Payload, TOut extends Payload = Payload, TEventData extends DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut> = DivinerModuleEventData<DivinerInstance<TParams, TIn, TOut>, TIn, TOut>> extends AbstractDiviner<TParams, TIn, TOut, TEventData> {
6
- static readonly configSchemas: Schema[];
7
- static readonly defaultConfigSchema: Schema;
8
- protected _transforms: PayloadTransformer[] | undefined;
9
- private _payloadTransformers;
10
- private _transformableSchemas;
11
- /**
12
- * The schema to use for the destination payloads
13
- */
14
- protected get destinationSchema(): string;
15
- /**
16
- * Dictionary of schemas to payload transformers
17
- */
18
- protected get payloadTransformers(): SchemaToPayloadTransformersDictionary;
19
- /**
20
- * The dictionary of schemas to JSON Path transform expressions
21
- */
22
- protected get schemaTransforms(): SchemaToJsonPathTransformExpressionsDictionary;
23
- /**
24
- * List of transformable schemas for this diviner
25
- */
26
- protected get transformableSchemas(): string[];
27
- protected divineHandler(payloads?: TIn[]): Promise<TOut[]>;
28
- /**
29
- * Identifies if a payload is one that is transformed by this diviner
30
- * @param x The candidate payload
31
- * @returns True if the payload is one transformed by this diviner, false otherwise
32
- */
33
- protected isTransformablePayload: (x: Payload) => boolean;
34
- /**
35
- * Identifies if a schema is one that is transformed by this diviner
36
- * @param schema The candidate schema
37
- * @returns True if this schema is one transformed by this diviner, false otherwise
38
- */
39
- protected isTransformableSchema: (schema?: string | null) => boolean;
40
- }
41
- //# sourceMappingURL=Diviner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Diviner.d.ts","sourceRoot":"","sources":["../../src/Diviner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,KAAK,EACV,8BAA8B,EAC9B,kBAAkB,EAClB,8CAA8C,EAC9C,qCAAqC,EACtC,MAAM,+CAA+C,CAAA;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAEzF,OAAO,KAAK,EAAE,OAAO,EAAE,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AAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './jsonPathToTransformersDictionary.ts';
2
- export * from './reducePayloads.ts';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/jsonpath/index.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAA;AACrD,cAAc,qBAAqB,CAAA"}
@@ -1,10 +0,0 @@
1
- import type { SchemaToJsonPathTransformExpressionsDictionary, SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model';
2
- /**
3
- * Materializes the JSON-path expressions into memoized functions by converting a
4
- * dictionary of schema to JSON Path transform expressions to a dictionary
5
- * of schema to payload transformers
6
- * @param schemaTransforms The schema transforms to convert
7
- * @returns A dictionary of schema to payload transformers
8
- */
9
- export declare const jsonPathToTransformersDictionary: (schemaTransforms: SchemaToJsonPathTransformExpressionsDictionary) => SchemaToPayloadTransformersDictionary;
10
- //# sourceMappingURL=jsonPathToTransformersDictionary.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonPathToTransformersDictionary.d.ts","sourceRoot":"","sources":["../../../src/jsonpath/jsonPathToTransformersDictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8CAA8C,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAAA;AAG1J;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,qBACzB,8CAA8C,KAC/D,qCAOF,CAAA"}
@@ -1,24 +0,0 @@
1
- import type { SchemaToPayloadTransformersDictionary } from '@xyo-network/diviner-jsonpath-aggregate-model';
2
- import type { Payload } from '@xyo-network/payload-model';
3
- /**
4
- * Reduces the payloads to a single payload using the supplied transformers
5
- * @param payloads The payloads to reduce
6
- * @param payloadTransformers The transformers to use to convert the payloads to the destination payload
7
- * @param destinationSchema The schema of the destination payload
8
- * @param excludeSources Exclude the source hashes from the destination payload
9
- * @returns The reduced payload
10
- */
11
- export declare const reducePayloads: <T extends Payload = import("@xylabs/object").DeepRestrictToStringKeys<{
12
- schema: import("@xyo-network/payload-model").Schema;
13
- }>>(payloads: Payload[], payloadTransformers: SchemaToPayloadTransformersDictionary, destinationSchema: string, excludeSources?: boolean) => Promise<T>;
14
- /**
15
- * Reduces the arrays of payload arrays to an array of payloads using the supplied transformers
16
- * @param payloadsArray The arrays of payloads to reduce
17
- * @param payloadTransformers The transformers to use to convert the payloads to the destination payloads
18
- * @param excludeSources Exclude the source hashes from the destination payload
19
- * @returns The reduced payloads
20
- */
21
- export declare const reducePayloadsArray: <T extends Payload = import("@xylabs/object").DeepRestrictToStringKeys<{
22
- schema: import("@xyo-network/payload-model").Schema;
23
- }>>(payloadsArray: Payload[][], payloadTransformers: SchemaToPayloadTransformersDictionary, destinationSchema: string, excludeSources?: boolean) => Promise<T[]>;
24
- //# sourceMappingURL=reducePayloads.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reducePayloads.d.ts","sourceRoot":"","sources":["../../../src/jsonpath/reducePayloads.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAAA;AAE1G,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,4BAA4B,CAAA;AAExE;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAU,CAAC,SAAS,OAAO;;cAC1C,OAAO,EAAE,uBACE,qCAAqC,qBACvC,MAAM,+BAExB,OAAO,CAAC,CAAC,CAYX,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAU,CAAC,SAAS,OAAO;;mBAC1C,OAAO,EAAE,EAAE,uBACL,qCAAqC,qBACvC,MAAM,+BAExB,OAAO,CAAC,CAAC,EAAE,CAMb,CAAA"}