@xyo-network/diviner-jsonpatch-memory 3.18.9 → 4.0.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.
- package/dist/neutral/index.mjs +22 -2
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/types/Diviner.d.ts.map +1 -1
- package/package.json +14 -13
- package/src/Diviner.ts +2 -0
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __reflectGet = Reflect.get;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
7
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
8
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9
|
+
if (decorator = decorators[i])
|
|
10
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
11
|
+
if (kind && result) __defProp(target, key, result);
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
16
|
+
|
|
1
17
|
// src/Diviner.ts
|
|
2
18
|
import { assertEx } from "@xylabs/assert";
|
|
3
19
|
import { exists } from "@xylabs/exists";
|
|
4
20
|
import { AbstractDiviner } from "@xyo-network/diviner-abstract";
|
|
5
21
|
import { JsonPatchDivinerConfigSchema } from "@xyo-network/diviner-jsonpatch-model";
|
|
22
|
+
import { creatableModule } from "@xyo-network/module-model";
|
|
6
23
|
import fastJsonPatch from "fast-json-patch";
|
|
7
24
|
var FJP = fastJsonPatch;
|
|
8
25
|
var JsonPatchDiviner = class extends AbstractDiviner {
|
|
9
|
-
static configSchemas = [...super.configSchemas, JsonPatchDivinerConfigSchema];
|
|
10
|
-
static defaultConfigSchema = JsonPatchDivinerConfigSchema;
|
|
11
26
|
get operations() {
|
|
12
27
|
return assertEx(this.config?.operations, () => "JsonPatchDiviner: invalid operations");
|
|
13
28
|
}
|
|
@@ -24,6 +39,11 @@ var JsonPatchDiviner = class extends AbstractDiviner {
|
|
|
24
39
|
return await Promise.resolve(results ?? []);
|
|
25
40
|
}
|
|
26
41
|
};
|
|
42
|
+
__publicField(JsonPatchDiviner, "configSchemas", [...__superGet(JsonPatchDiviner, JsonPatchDiviner, "configSchemas"), JsonPatchDivinerConfigSchema]);
|
|
43
|
+
__publicField(JsonPatchDiviner, "defaultConfigSchema", JsonPatchDivinerConfigSchema);
|
|
44
|
+
JsonPatchDiviner = __decorateClass([
|
|
45
|
+
creatableModule()
|
|
46
|
+
], JsonPatchDiviner);
|
|
27
47
|
export {
|
|
28
48
|
JsonPatchDiviner
|
|
29
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Diviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { JsonPatchDivinerParams } from '@xyo-network/diviner-jsonpatch-model'\nimport { JsonPatchDivinerConfigSchema } from '@xyo-network/diviner-jsonpatch-model'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport type { applyPatch, Operation } from 'fast-json-patch'\nimport fastJsonPatch from 'fast-json-patch'\n\nconst FJP = fastJsonPatch as { applyPatch: typeof applyPatch }\n\nexport class JsonPatchDiviner<\n TParams extends JsonPatchDivinerParams = JsonPatchDivinerParams,\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, JsonPatchDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = JsonPatchDivinerConfigSchema\n\n protected get operations(): readonly Operation[] {\n return assertEx(this.config?.operations, () => 'JsonPatchDiviner: invalid operations')\n }\n\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n const results = payloads\n ?.map((payload) => {\n try {\n const result = FJP.applyPatch(payload, this.operations, false, false)\n return result[0].newDocument as unknown as TOut\n } catch (error) {\n this.logger?.error('JsonPatchDiviner: failed to apply patch', error)\n return\n }\n })\n .filter(exists)\n return await Promise.resolve(results ?? [])\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/Diviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { AbstractDiviner } from '@xyo-network/diviner-abstract'\nimport type { JsonPatchDivinerParams } from '@xyo-network/diviner-jsonpatch-model'\nimport { JsonPatchDivinerConfigSchema } from '@xyo-network/diviner-jsonpatch-model'\nimport type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'\nimport { creatableModule } from '@xyo-network/module-model'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport type { applyPatch, Operation } from 'fast-json-patch'\nimport fastJsonPatch from 'fast-json-patch'\n\nconst FJP = fastJsonPatch as { applyPatch: typeof applyPatch }\n\n@creatableModule()\nexport class JsonPatchDiviner<\n TParams extends JsonPatchDivinerParams = JsonPatchDivinerParams,\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, JsonPatchDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = JsonPatchDivinerConfigSchema\n\n protected get operations(): readonly Operation[] {\n return assertEx(this.config?.operations, () => 'JsonPatchDiviner: invalid operations')\n }\n\n protected override async divineHandler(payloads?: TIn[]): Promise<TOut[]> {\n const results = payloads\n ?.map((payload) => {\n try {\n const result = FJP.applyPatch(payload, this.operations, false, false)\n return result[0].newDocument as unknown as TOut\n } catch (error) {\n this.logger?.error('JsonPatchDiviner: failed to apply patch', error)\n return\n }\n })\n .filter(exists)\n return await Promise.resolve(results ?? [])\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,uBAAuB;AAEhC,SAAS,oCAAoC;AAE7C,SAAS,uBAAuB;AAGhC,OAAO,mBAAmB;AAE1B,IAAM,MAAM;AAGL,IAAM,mBAAN,cASG,gBAAgD;AAAA,EAIxD,IAAc,aAAmC;AAC/C,WAAO,SAAS,KAAK,QAAQ,YAAY,MAAM,sCAAsC;AAAA,EACvF;AAAA,EAEA,MAAyB,cAAc,UAAmC;AACxE,UAAM,UAAU,UACZ,IAAI,CAAC,YAAY;AACjB,UAAI;AACF,cAAM,SAAS,IAAI,WAAW,SAAS,KAAK,YAAY,OAAO,KAAK;AACpE,eAAO,OAAO,CAAC,EAAE;AAAA,MACnB,SAAS,OAAO;AACd,aAAK,QAAQ,MAAM,2CAA2C,KAAK;AACnE;AAAA,MACF;AAAA,IACF,CAAC,EACA,OAAO,MAAM;AAChB,WAAO,MAAM,QAAQ,QAAQ,WAAW,CAAC,CAAC;AAAA,EAC5C;AACF;AArBE,cAVW,kBAUc,iBAA0B,CAAC,GAAG,+CAAM,kBAAe,4BAA4B;AACxG,cAXW,kBAWc,uBAA8B;AAX5C,mBAAN;AAAA,EADN,gBAAgB;AAAA,GACJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
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,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAA;AAElF,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;
|
|
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,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAA;AAElF,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAEzF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAK5D,qBACa,gBAAgB,CAC3B,OAAO,SAAS,sBAAsB,GAAG,sBAAsB,EAC/D,GAAG,SAAS,OAAO,GAAG,OAAO,EAC7B,IAAI,SAAS,OAAO,GAAG,OAAO,EAC9B,UAAU,SAAS,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,sBAAsB,CAChH,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,EACnC,GAAG,EACH,IAAI,CACL,CACD,SAAQ,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC;IACvD,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAAyD;IACzG,gBAAyB,mBAAmB,EAAE,MAAM,CAA+B;IAEnF,SAAS,KAAK,UAAU,IAAI,SAAS,SAAS,EAAE,CAE/C;cAEwB,aAAa,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;CAc1E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/diviner-jsonpatch-memory",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -29,22 +29,23 @@
|
|
|
29
29
|
"module": "dist/neutral/index.mjs",
|
|
30
30
|
"types": "dist/types/index.d.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@xylabs/assert": "^4.
|
|
33
|
-
"@xylabs/exists": "^4.
|
|
34
|
-
"@xyo-network/diviner-abstract": "^
|
|
35
|
-
"@xyo-network/diviner-jsonpatch-model": "^
|
|
36
|
-
"@xyo-network/diviner-model": "^
|
|
37
|
-
"@xyo-network/
|
|
32
|
+
"@xylabs/assert": "^4.12.30",
|
|
33
|
+
"@xylabs/exists": "^4.12.30",
|
|
34
|
+
"@xyo-network/diviner-abstract": "^4.0.0",
|
|
35
|
+
"@xyo-network/diviner-jsonpatch-model": "^4.0.0",
|
|
36
|
+
"@xyo-network/diviner-model": "^4.0.0",
|
|
37
|
+
"@xyo-network/module-model": "^4.0.0",
|
|
38
|
+
"@xyo-network/payload-model": "^4.0.0",
|
|
38
39
|
"fast-json-patch": "^3.1.1"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@xylabs/ts-scripts-yarn3": "^6.5.
|
|
42
|
-
"@xylabs/tsconfig": "^6.5.
|
|
43
|
-
"@xylabs/vitest-extended": "^4.
|
|
44
|
-
"@xyo-network/wallet": "^
|
|
45
|
-
"@xyo-network/wallet-model": "^
|
|
42
|
+
"@xylabs/ts-scripts-yarn3": "^6.5.12",
|
|
43
|
+
"@xylabs/tsconfig": "^6.5.12",
|
|
44
|
+
"@xylabs/vitest-extended": "^4.12.30",
|
|
45
|
+
"@xyo-network/wallet": "^4.0.0",
|
|
46
|
+
"@xyo-network/wallet-model": "^4.0.0",
|
|
46
47
|
"typescript": "^5.8.3",
|
|
47
|
-
"vitest": "^3.2.
|
|
48
|
+
"vitest": "^3.2.4"
|
|
48
49
|
},
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"access": "public"
|
package/src/Diviner.ts
CHANGED
|
@@ -4,12 +4,14 @@ import { AbstractDiviner } from '@xyo-network/diviner-abstract'
|
|
|
4
4
|
import type { JsonPatchDivinerParams } from '@xyo-network/diviner-jsonpatch-model'
|
|
5
5
|
import { JsonPatchDivinerConfigSchema } from '@xyo-network/diviner-jsonpatch-model'
|
|
6
6
|
import type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'
|
|
7
|
+
import { creatableModule } from '@xyo-network/module-model'
|
|
7
8
|
import type { Payload, Schema } from '@xyo-network/payload-model'
|
|
8
9
|
import type { applyPatch, Operation } from 'fast-json-patch'
|
|
9
10
|
import fastJsonPatch from 'fast-json-patch'
|
|
10
11
|
|
|
11
12
|
const FJP = fastJsonPatch as { applyPatch: typeof applyPatch }
|
|
12
13
|
|
|
14
|
+
@creatableModule()
|
|
13
15
|
export class JsonPatchDiviner<
|
|
14
16
|
TParams extends JsonPatchDivinerParams = JsonPatchDivinerParams,
|
|
15
17
|
TIn extends Payload = Payload,
|