@xyo-network/diviner-jsonpatch-memory 3.0.1 → 3.0.3
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.map +1 -1
- package/package.json +12 -12
- package/src/Diviner.ts +6 -4
- package/xy.config.ts +1 -1
|
@@ -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 {
|
|
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 { Operation } from 'json-joy/lib/json-patch/index.js'\nimport { applyPatch } from 'json-joy/lib/json-patch/index.js'\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 = applyPatch(payload, this.operations, { mutate: false })\n return result.res?.[0]?.doc as TOut\n } catch {\n return\n }\n })\n .filter(exists)\n return await Promise.resolve(results ?? [])\n }\n}\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,uBAAuB;AAEhC,SAASC,oCAAoC;AAI7C,SAASC,kBAAkB;AAEpB,IAAMC,mBAAN,cASGC,gBAAAA;EAnBV,OAmBUA;;;EACR,OAAyBC,gBAA0B;OAAI,MAAMA;IAAeC;;EAC5E,OAAyBC,sBAA8BD;EAEvD,IAAcE,aAAmC;AAC/C,WAAOC,SAAS,KAAKC,QAAQF,YAAY,MAAM,sCAAA;EACjD;EAEA,MAAyBG,cAAcC,UAAmC;AACxE,UAAMC,UAAUD,UACZE,IAAI,CAACC,YAAAA;AACL,UAAI;AACF,cAAMC,SAASC,WAAWF,SAAS,KAAKP,YAAY;UAAEU,QAAQ;QAAM,CAAA;AACpE,eAAOF,OAAOG,MAAM,CAAA,GAAIC;MAC1B,QAAQ;AACN;MACF;IACF,CAAA,EACCC,OAAOC,MAAAA;AACV,WAAO,MAAMC,QAAQC,QAAQX,WAAW,CAAA,CAAE;EAC5C;AACF;","names":["assertEx","exists","AbstractDiviner","JsonPatchDivinerConfigSchema","applyPatch","JsonPatchDiviner","AbstractDiviner","configSchemas","JsonPatchDivinerConfigSchema","defaultConfigSchema","operations","assertEx","config","divineHandler","payloads","results","map","payload","result","applyPatch","mutate","res","doc","filter","exists","Promise","resolve"]}
|
package/package.json
CHANGED
|
@@ -7,22 +7,22 @@
|
|
|
7
7
|
},
|
|
8
8
|
"bugs": {
|
|
9
9
|
"email": "support@xyo.network",
|
|
10
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
10
|
+
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xylabs/assert": "^4.0.
|
|
14
|
-
"@xylabs/exists": "^4.0.
|
|
15
|
-
"@xyo-network/diviner-abstract": "^3.0.
|
|
16
|
-
"@xyo-network/diviner-jsonpatch-model": "^3.0.
|
|
17
|
-
"@xyo-network/diviner-model": "^3.0.
|
|
18
|
-
"@xyo-network/payload-model": "^3.0.
|
|
13
|
+
"@xylabs/assert": "^4.0.2",
|
|
14
|
+
"@xylabs/exists": "^4.0.2",
|
|
15
|
+
"@xyo-network/diviner-abstract": "^3.0.3",
|
|
16
|
+
"@xyo-network/diviner-jsonpatch-model": "^3.0.3",
|
|
17
|
+
"@xyo-network/diviner-model": "^3.0.3",
|
|
18
|
+
"@xyo-network/payload-model": "^3.0.3",
|
|
19
19
|
"json-joy": "~16.19.0",
|
|
20
20
|
"tslib": "^2.6.3"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@xylabs/ts-scripts-yarn3": "^4.0.0-rc.
|
|
24
|
-
"@xylabs/tsconfig": "^4.0.0-rc.
|
|
25
|
-
"@xyo-network/account": "^3.0.
|
|
23
|
+
"@xylabs/ts-scripts-yarn3": "^4.0.0-rc.20",
|
|
24
|
+
"@xylabs/tsconfig": "^4.0.0-rc.20",
|
|
25
|
+
"@xyo-network/account": "^3.0.3",
|
|
26
26
|
"typescript": "^5.5.4"
|
|
27
27
|
},
|
|
28
28
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|
|
45
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
45
|
+
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
46
46
|
},
|
|
47
47
|
"sideEffects": false,
|
|
48
|
-
"version": "3.0.
|
|
48
|
+
"version": "3.0.3",
|
|
49
49
|
"type": "module"
|
|
50
50
|
}
|
package/src/Diviner.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
2
|
import { exists } from '@xylabs/exists'
|
|
3
3
|
import { AbstractDiviner } from '@xyo-network/diviner-abstract'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import type { JsonPatchDivinerParams } from '@xyo-network/diviner-jsonpatch-model'
|
|
5
|
+
import { JsonPatchDivinerConfigSchema } from '@xyo-network/diviner-jsonpatch-model'
|
|
6
|
+
import type { DivinerInstance, DivinerModuleEventData } from '@xyo-network/diviner-model'
|
|
7
|
+
import type { Payload, Schema } from '@xyo-network/payload-model'
|
|
8
|
+
import type { Operation } from 'json-joy/lib/json-patch/index.js'
|
|
9
|
+
import { applyPatch } from 'json-joy/lib/json-patch/index.js'
|
|
8
10
|
|
|
9
11
|
export class JsonPatchDiviner<
|
|
10
12
|
TParams extends JsonPatchDivinerParams = JsonPatchDivinerParams,
|
package/xy.config.ts
CHANGED