@fgv/ts-json 5.0.0-8 → 5.0.1-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/CHANGELOG.json +9 -3
- package/dist/tsdoc-metadata.json +1 -1
- package/eslint.config.js +16 -0
- package/lib/packlets/context/compositeJsonMap.js +0 -1
- package/package.json +19 -18
- package/CHANGELOG.md +0 -115
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/packlets/context/compositeJsonMap.d.ts.map +0 -1
- package/lib/packlets/context/compositeJsonMap.js.map +0 -1
- package/lib/packlets/context/contextHelpers.d.ts.map +0 -1
- package/lib/packlets/context/contextHelpers.js.map +0 -1
- package/lib/packlets/context/index.d.ts.map +0 -1
- package/lib/packlets/context/index.js.map +0 -1
- package/lib/packlets/context/jsonContext.d.ts.map +0 -1
- package/lib/packlets/context/jsonContext.js.map +0 -1
- package/lib/packlets/converters/converters.d.ts.map +0 -1
- package/lib/packlets/converters/converters.js.map +0 -1
- package/lib/packlets/converters/index.d.ts.map +0 -1
- package/lib/packlets/converters/index.js.map +0 -1
- package/lib/packlets/converters/jsonConverter.d.ts.map +0 -1
- package/lib/packlets/converters/jsonConverter.js.map +0 -1
- package/lib/packlets/diff/detailedDiff.d.ts.map +0 -1
- package/lib/packlets/diff/detailedDiff.js.map +0 -1
- package/lib/packlets/diff/index.d.ts.map +0 -1
- package/lib/packlets/diff/index.js.map +0 -1
- package/lib/packlets/diff/threeWayDiff.d.ts.map +0 -1
- package/lib/packlets/diff/threeWayDiff.js.map +0 -1
- package/lib/packlets/diff/utils.d.ts.map +0 -1
- package/lib/packlets/diff/utils.js.map +0 -1
- package/lib/packlets/editor/common.d.ts.map +0 -1
- package/lib/packlets/editor/common.js.map +0 -1
- package/lib/packlets/editor/index.d.ts.map +0 -1
- package/lib/packlets/editor/index.js.map +0 -1
- package/lib/packlets/editor/jsonEditor.d.ts.map +0 -1
- package/lib/packlets/editor/jsonEditor.js.map +0 -1
- package/lib/packlets/editor/jsonEditorRule.d.ts.map +0 -1
- package/lib/packlets/editor/jsonEditorRule.js.map +0 -1
- package/lib/packlets/editor/jsonEditorState.d.ts.map +0 -1
- package/lib/packlets/editor/jsonEditorState.js.map +0 -1
- package/lib/packlets/editor/jsonReferenceMap.d.ts.map +0 -1
- package/lib/packlets/editor/jsonReferenceMap.js.map +0 -1
- package/lib/packlets/editor/rules/conditional.d.ts.map +0 -1
- package/lib/packlets/editor/rules/conditional.js.map +0 -1
- package/lib/packlets/editor/rules/index.d.ts.map +0 -1
- package/lib/packlets/editor/rules/index.js.map +0 -1
- package/lib/packlets/editor/rules/multivalue.d.ts.map +0 -1
- package/lib/packlets/editor/rules/multivalue.js.map +0 -1
- package/lib/packlets/editor/rules/references.d.ts.map +0 -1
- package/lib/packlets/editor/rules/references.js.map +0 -1
- package/lib/packlets/editor/rules/templates.d.ts.map +0 -1
- package/lib/packlets/editor/rules/templates.js.map +0 -1
package/CHANGELOG.json
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-json",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "5.0.1",
|
|
6
|
+
"tag": "@fgv/ts-json_v5.0.1",
|
|
7
|
+
"date": "Tue, 23 Sep 2025 03:13:55 GMT",
|
|
8
|
+
"comments": {}
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "5.0.0",
|
|
6
12
|
"tag": "@fgv/ts-json_v5.0.0",
|
|
7
|
-
"date": "
|
|
13
|
+
"date": "Tue, 23 Sep 2025 02:54:20 GMT",
|
|
8
14
|
"comments": {
|
|
9
15
|
"none": [
|
|
10
16
|
{
|
|
11
|
-
"comment": "
|
|
17
|
+
"comment": "- add json diff engine, ability to control array merge behavior"
|
|
12
18
|
},
|
|
13
19
|
{
|
|
14
|
-
"comment": "
|
|
20
|
+
"comment": "update rushstack"
|
|
15
21
|
}
|
|
16
22
|
]
|
|
17
23
|
}
|
package/dist/tsdoc-metadata.json
CHANGED
package/eslint.config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// ESLint 9 flat config
|
|
2
|
+
const nodeProfile = require('@rushstack/eslint-config/flat/profile/node');
|
|
3
|
+
const packletsPlugin = require('@rushstack/eslint-config/flat/mixins/packlets');
|
|
4
|
+
const tsdocPlugin = require('@rushstack/eslint-config/flat/mixins/tsdoc');
|
|
5
|
+
|
|
6
|
+
module.exports = [
|
|
7
|
+
...nodeProfile,
|
|
8
|
+
packletsPlugin,
|
|
9
|
+
...tsdocPlugin,
|
|
10
|
+
{
|
|
11
|
+
// Override specific rules if needed
|
|
12
|
+
rules: {
|
|
13
|
+
'@rushstack/packlets/mechanics': 'warn'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
];
|
|
@@ -88,7 +88,6 @@ class CompositeJsonMap {
|
|
|
88
88
|
* if no such object exists, or failure with detail `'error'` if the object was found but
|
|
89
89
|
* could not be formatted.
|
|
90
90
|
*/
|
|
91
|
-
// eslint-disable-next-line no-use-before-define
|
|
92
91
|
getJsonValue(key, context) {
|
|
93
92
|
for (const map of this._maps) {
|
|
94
93
|
if (map.keyIsInRange(key)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-json",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.1-0",
|
|
4
4
|
"description": "Typescript utilities for working with JSON",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-json.d.ts",
|
|
@@ -19,35 +19,36 @@
|
|
|
19
19
|
"@types/jest": "^29.5.14",
|
|
20
20
|
"@types/mustache": "^4.2.5",
|
|
21
21
|
"@types/node": "^20.14.9",
|
|
22
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
23
|
-
"@typescript-eslint/parser": "^
|
|
24
|
-
"eslint": "^
|
|
22
|
+
"@typescript-eslint/eslint-plugin": "^8.42.0",
|
|
23
|
+
"@typescript-eslint/parser": "^8.42.0",
|
|
24
|
+
"eslint": "^9.35.0",
|
|
25
25
|
"eslint-plugin-import": "^2.32.0",
|
|
26
26
|
"eslint-plugin-node": "^11.1.0",
|
|
27
|
-
"eslint-plugin-promise": "^
|
|
27
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
28
28
|
"jest": "^29.7.0",
|
|
29
29
|
"jest-extended": "^4.0.2",
|
|
30
30
|
"mustache": "^4.2.0",
|
|
31
|
-
"rimraf": "^
|
|
32
|
-
"ts-jest": "^29.4.
|
|
31
|
+
"rimraf": "^6.0.1",
|
|
32
|
+
"ts-jest": "^29.4.1",
|
|
33
33
|
"ts-node": "^10.9.2",
|
|
34
|
-
"typescript": "
|
|
35
|
-
"eslint-plugin-n": "^
|
|
36
|
-
"@rushstack/heft-node-rig": "
|
|
37
|
-
"@rushstack/heft": "
|
|
34
|
+
"typescript": "5.8.3",
|
|
35
|
+
"eslint-plugin-n": "^17.21.3",
|
|
36
|
+
"@rushstack/heft-node-rig": "2.9.5",
|
|
37
|
+
"@rushstack/heft": "0.74.4",
|
|
38
38
|
"heft-jest": "~1.0.2",
|
|
39
39
|
"@types/heft-jest": "1.0.6",
|
|
40
|
-
"@microsoft/api-documenter": "^7.26.
|
|
41
|
-
"@rushstack/eslint-config": "
|
|
40
|
+
"@microsoft/api-documenter": "^7.26.31",
|
|
41
|
+
"@rushstack/eslint-config": "4.4.0",
|
|
42
42
|
"eslint-plugin-tsdoc": "~0.4.0",
|
|
43
|
-
"@
|
|
44
|
-
"@fgv/ts-utils-jest": "5.0.0
|
|
45
|
-
"@fgv/ts-
|
|
43
|
+
"@rushstack/heft-jest-plugin": "0.16.13",
|
|
44
|
+
"@fgv/ts-utils-jest": "5.0.1-0",
|
|
45
|
+
"@fgv/ts-utils": "5.0.1-0",
|
|
46
|
+
"@fgv/ts-json-base": "5.0.1-0"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
49
|
"mustache": "^4.2.0",
|
|
49
|
-
"@fgv/ts-utils": "5.0.0
|
|
50
|
-
"@fgv/ts-json-base": "5.0.0
|
|
50
|
+
"@fgv/ts-utils": "5.0.1-0",
|
|
51
|
+
"@fgv/ts-json-base": "5.0.1-0"
|
|
51
52
|
},
|
|
52
53
|
"scripts": {
|
|
53
54
|
"build": "heft build --clean",
|
package/CHANGELOG.md
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Change Log - @fgv/ts-json
|
|
2
|
-
|
|
3
|
-
This log was last generated on Thu, 17 Jul 2025 00:13:24 GMT and should not be manually modified.
|
|
4
|
-
|
|
5
|
-
## 5.0.0
|
|
6
|
-
Thu, 17 Jul 2025 00:13:24 GMT
|
|
7
|
-
|
|
8
|
-
### Updates
|
|
9
|
-
|
|
10
|
-
- upgrade dependencies
|
|
11
|
-
- bump version
|
|
12
|
-
|
|
13
|
-
## 4.6.0
|
|
14
|
-
Wed, 02 Jul 2025 05:48:16 GMT
|
|
15
|
-
|
|
16
|
-
_Version update only_
|
|
17
|
-
|
|
18
|
-
## 4.5.1
|
|
19
|
-
Wed, 02 Jul 2025 05:47:11 GMT
|
|
20
|
-
|
|
21
|
-
### Updates
|
|
22
|
-
|
|
23
|
-
- update rushstack
|
|
24
|
-
|
|
25
|
-
## 4.5.0
|
|
26
|
-
Tue, 01 Jul 2025 03:26:11 GMT
|
|
27
|
-
|
|
28
|
-
### Patches
|
|
29
|
-
|
|
30
|
-
- Fix incorrect build script in package.json that was running tests instead of build
|
|
31
|
-
|
|
32
|
-
## 4.4.0
|
|
33
|
-
Sat, 01 Feb 2025 17:13:10 GMT
|
|
34
|
-
|
|
35
|
-
_Version update only_
|
|
36
|
-
|
|
37
|
-
## 4.3.0
|
|
38
|
-
Thu, 30 Jan 2025 00:35:17 GMT
|
|
39
|
-
|
|
40
|
-
_Version update only_
|
|
41
|
-
|
|
42
|
-
## 4.2.2
|
|
43
|
-
Thu, 23 Jan 2025 06:19:32 GMT
|
|
44
|
-
|
|
45
|
-
_Version update only_
|
|
46
|
-
|
|
47
|
-
## 4.2.1
|
|
48
|
-
Tue, 21 Jan 2025 04:19:21 GMT
|
|
49
|
-
|
|
50
|
-
_Version update only_
|
|
51
|
-
|
|
52
|
-
## 4.2.0
|
|
53
|
-
Mon, 20 Jan 2025 09:46:53 GMT
|
|
54
|
-
|
|
55
|
-
_Version update only_
|
|
56
|
-
|
|
57
|
-
## 4.1.0
|
|
58
|
-
Thu, 09 Jan 2025 05:33:39 GMT
|
|
59
|
-
|
|
60
|
-
### Updates
|
|
61
|
-
|
|
62
|
-
- update dependencies
|
|
63
|
-
|
|
64
|
-
## 4.0.2
|
|
65
|
-
Tue, 14 May 2024 14:45:53 GMT
|
|
66
|
-
|
|
67
|
-
_Version update only_
|
|
68
|
-
|
|
69
|
-
## 4.0.1
|
|
70
|
-
Tue, 14 May 2024 05:02:20 GMT
|
|
71
|
-
|
|
72
|
-
### Updates
|
|
73
|
-
|
|
74
|
-
- publish
|
|
75
|
-
|
|
76
|
-
## 4.0.0
|
|
77
|
-
Tue, 14 May 2024 03:09:27 GMT
|
|
78
|
-
|
|
79
|
-
### Updates
|
|
80
|
-
|
|
81
|
-
- update dependencies
|
|
82
|
-
- update tsdoc comments and generated docs
|
|
83
|
-
|
|
84
|
-
## 3.0.0
|
|
85
|
-
Mon, 22 Jan 2024 07:00:18 GMT
|
|
86
|
-
|
|
87
|
-
### Updates
|
|
88
|
-
|
|
89
|
-
- fix export issues
|
|
90
|
-
- fix peers
|
|
91
|
-
- bump versions
|
|
92
|
-
- refactor
|
|
93
|
-
- major refactor
|
|
94
|
-
- Match ts-utils refactor
|
|
95
|
-
- version upgrades
|
|
96
|
-
- update dependencies
|
|
97
|
-
- update peer dependencies
|
|
98
|
-
- bump version
|
|
99
|
-
|
|
100
|
-
## 2.2.0
|
|
101
|
-
Thu, 18 Jan 2024 05:45:04 GMT
|
|
102
|
-
|
|
103
|
-
### Updates
|
|
104
|
-
|
|
105
|
-
- fix export issues
|
|
106
|
-
- fix peers
|
|
107
|
-
- bump versions
|
|
108
|
-
- refactor
|
|
109
|
-
- major refactor
|
|
110
|
-
- Match ts-utils refactor
|
|
111
|
-
- version upgrades
|
|
112
|
-
- update dependencies
|
|
113
|
-
- update peer dependencies
|
|
114
|
-
- bump version
|
|
115
|
-
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAElC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qDAAmC;AACnC,wDAAsC;AACtC,oDAAkC;AAElC,sDAAwC;AAE/B,oBAAI","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './packlets/context';\nexport * from './packlets/converters';\nexport * from './packlets/editor';\n\nimport * as Diff from './packlets/diff';\n\nexport { Diff };\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compositeJsonMap.d.ts","sourceRoot":"","sources":["../../../src/packlets/context/compositeJsonMap.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAgB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAoD,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAE/F;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,iBAAiB;IACxD;;;OAGG;IACH,SAAS,CAAC,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAErC;;;;;OAKG;IACH,SAAS,aAAa,IAAI,EAAE,iBAAiB,EAAE;IAI/C;;;;OAIG;WACW,MAAM,CAAC,IAAI,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAIzE;;;;;OAKG;IACI,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzC;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIhC;;;;;;;OAOG;IACI,aAAa,CAClB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,YAAY,GACrB,cAAc,CAAC,UAAU,EAAE,6BAA6B,CAAC;IAS5D;;;;;;;OAOG;IAEI,YAAY,CACjB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,Y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AA,4BAAiB,EAAC,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,gDAAgD;IACzC,YAAY,CACjB,GAAW,EACX,OAAsB;QAEtB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC7B,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC1B,MAAM,MAAM,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;gBAC9C,IAAI,MAAM,CAAC,SAAS,EAAE,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;oBACpD,OAAO,MAAM,CAAC;gBAChB,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAA,yBAAc,EAAC,GAAG,GAAG,mBAAmB,EAAE,SAAS,CAAC,CAAC;IAC9D,CAAC;CACF;AAxFD,4CAwFC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonObject, JsonValue, isJsonObject } from '@fgv/ts-json-base';\nimport { DetailedResult, Result, captureResult, failWithDetail, succeedWithDetail } from '@fgv/ts-utils';\nimport { IJsonContext, IJsonReferenceMap, JsonReferenceMapFailureReason } from './jsonContext';\n\n/**\n * A {@link CompositeJsonMap | CompositeJsonMap} presents a composed view of one or more other\n * {@link IJsonReferenceMap | JSON reference maps}.\n * @public\n */\nexport class CompositeJsonMap implements IJsonReferenceMap {\n /**\n * The {@link IJsonReferenceMap | reference maps} from which this map is composed.\n * @internal\n */\n protected _maps: IJsonReferenceMap[];\n\n /**\n * The {@link IJsonReferenceMap | reference maps} from which this map is to be composed.\n * @param maps - An array o {@link IJsonReferenceMap | IJsonReferenceMap} containing the maps\n * from which this map is to be composed.\n * @internal\n */\n protected constructor(maps: IJsonReferenceMap[]) {\n this._maps = maps;\n }\n\n /**\n * Creates a new {@link CompositeJsonMap | CompositeJsonMap} from supplied\n * {@link IJsonReferenceMap | maps}.\n * @param maps - one or more {@link IJsonReferenceMap | object maps} to be composed.\n */\n public static create(maps: IJsonReferenceMap[]): Result<CompositeJsonMap> {\n return captureResult(() => new CompositeJsonMap(maps));\n }\n\n /**\n * Determine if a key might be valid for this map but does not determine\n * if key actually exists. Allows key range to be constrained.\n * @param key - The key to be tested.\n * @returns `true` if the key is in the valid range, `false` otherwise.\n */\n public keyIsInRange(key: string): boolean {\n return this._maps.find((map) => map.keyIsInRange(key)) !== undefined;\n }\n\n /**\n * Determines if an object with the specified key actually exists in the map.\n * @param key - The key to be tested.\n * @returns `true` if an object with the specified key exists, `false` otherwise.\n */\n public has(key: string): boolean {\n return this._maps.find((map) => map.has(key)) !== undefined;\n }\n\n /**\n * Gets a JSON object specified by key.\n * @param key - The key of the object to be retrieved.\n * @param context - An optional {@link IJsonContext | JSON Context} used to format the object.\n * @returns `Success` with the formatted object if successful. `Failure` with detail `'unknown'`\n * if no such object exists, or `Failure` with detail `'error'` if the object was found but\n * could not be formatted.\n */\n public getJsonObject(\n key: string,\n context?: IJsonContext\n ): DetailedResult<JsonObject, JsonReferenceMapFailureReason> {\n return this.getJsonValue(key, context).onSuccess((jv) => {\n if (!isJsonObject(jv)) {\n return failWithDetail(`${key}: not an object`, 'error');\n }\n return succeedWithDetail(jv);\n });\n }\n\n /**\n * Gets a JSON value specified by key.\n * @param key - The key of the object to be retrieved.\n * @param context - An optional {@link IJsonContext | JSON Context} used to format the value.\n * @returns `Success` with the formatted object if successful. `Failure` with detail `'unknown'`\n * if no such object exists, or failure with detail `'error'` if the object was found but\n * could not be formatted.\n */\n // eslint-disable-next-line no-use-before-define\n public getJsonValue(\n key: string,\n context?: IJsonContext\n ): DetailedResult<JsonValue, JsonReferenceMapFailureReason> {\n for (const map of this._maps) {\n if (map.keyIsInRange(key)) {\n const result = map.getJsonValue(key, context);\n if (result.isSuccess() || result.detail === 'error') {\n return result;\n }\n }\n }\n return failWithDetail(`${key}: value not found`, 'unknown');\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contextHelpers.d.ts","sourceRoot":"","sources":["../../../src/packlets/context/contextHelpers.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAA0B,MAAM,eAAe,CAAC;AAE/D,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,aAAa,EAEd,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC;IAElC;;;;OAIG;gBACgB,OAAO,CAAC,EAAE,YAAY;IAIzC;;;;;;OAMG;WACW,MAAM,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAIvE;;;;;;;;;OASG;WACW,iBAAiB,CAC7B,WAAW,EAAE,YAAY,GAAG,SAAS,EACrC,IAAI,CAAC,EAAE,a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Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, succeed } from '@fgv/ts-utils';\nimport { CompositeJsonMap } from './compositeJsonMap';\nimport {\n IJsonContext,\n IJsonReferenceMap,\n TemplateVars,\n VariableValue,\n defaultExtendVars\n} from './jsonContext';\n\n/**\n * Helper class for working with {@link IJsonContext | IJsonContext} objects.\n * @public\n */\nexport class JsonContextHelper {\n /**\n * The base {@link IJsonContext | context} on which we are operating.\n * @internal\n */\n protected _context?: IJsonContext;\n\n /**\n * Constructs a new {@link JsonContextHelper | JsonContextHelper}.\n * @param context - The base {@link IJsonContext | IJsonContext} on\n * which to operate.\n */\n public constructor(context?: IJsonContext) {\n this._context = context;\n }\n\n /**\n * Creates a new {@link IJsonContext | context}.\n * @param context - The base {@link IJsonContext | IJsonContext} on\n * which to operate.\n * @returns `Success` with the new {@link IJsonContext | IJsonContext},\n * or `Failure` with more information if an error occurs.\n */\n public static create(context?: IJsonContext): Result<JsonContextHelper> {\n return captureResult(() => new JsonContextHelper(context));\n }\n\n /**\n * Static helper to extend context variables for a supplied {@link IJsonContext | IJsonContext}.\n * @param baseContext - The {@link IJsonContext | IJsonContext} to be extended, or `undefined`\n * to start from an empty context.\n * @param vars - Optional {@link VariableValue | variable values} to be added to the\n * {@link IJsonContext | context}.\n * @returns `Success` with a new {@link TemplateVars | TemplateVars} containing the variables\n * from the base context, merged with and overridden by any that were passed in, or `Failure`\n * with a message if an error occurs.\n */\n public static extendContextVars(\n baseContext: IJsonContext | undefined,\n vars?: VariableValue[]\n ): Result<TemplateVars | undefined> {\n if (vars && vars.length > 0) {\n const extend = baseContext?.extendVars ?? defaultExtendVars;\n return extend(baseContext?.vars ?? {}, vars);\n }\n return succeed(baseContext?.vars);\n }\n\n /**\n * Static helper to extend context references for a supplied {@link IJsonContext | IJsonContext}.\n * @param baseContext - The {@link IJsonContext | IJsonContext} to be extended, or `undefined`\n * to start from an empty context.\n * @param refs - Optional {@link IJsonReferenceMap | reference maps} to be added to the\n * {@link IJsonContext | context}.\n * @returns `Success` with a new {@link IJsonReferenceMap | reference map} which projects\n * the references from the base context, merged with and overridden by any that were passed in,\n * or `Failure` with a message if an error occurs.\n */\n public static extendContextRefs(\n baseContext: IJsonContext | undefined,\n refs?: IJsonReferenceMap[]\n ): Result<IJsonReferenceMap | undefined> {\n if (refs && refs.length > 0) {\n const full = baseContext?.refs ? [...refs, baseContext.refs] : refs;\n if (full.length > 1) {\n return CompositeJsonMap.create(full);\n }\n return succeed(full[0]);\n }\n return succeed(baseContext?.refs);\n }\n\n /**\n * Static helper to extend context variables and references for a supplied {@link IJsonContext | IJsonContext}.\n * @param baseContext - The {@link IJsonContext | IJsonContext} to be extended, or `undefined`\n * to start from an empty context.\n * @param add - Optional initializer containing {@link VariableValue | variable values} and/or\n * {@link IJsonReferenceMap | reference maps} to be added to the {@link IJsonContext | context}.\n * @returns `Success` with a new {@link IJsonContext | IJsonContext} containing the variables and\n * references from the base context, merged with and overridden by any that were passed in, or\n * `Failure` with a message if an error occurs.\n */\n public static extendContext(\n baseContext?: IJsonContext | undefined,\n add?: { vars?: VariableValue[]; refs?: IJsonReferenceMap[] }\n ): Result<IJsonContext | undefined> {\n return JsonContextHelper.extendContextVars(baseContext, add?.vars || []).onSuccess((vars) => {\n return JsonContextHelper.extendContextRefs(baseContext, add?.refs || []).onSuccess((refs) => {\n if (!vars && !refs && !baseContext?.extendVars) {\n return succeed(undefined);\n }\n const rtrn: IJsonContext = { vars, refs };\n if (baseContext?.extendVars) {\n rtrn.extendVars = baseContext.extendVars;\n }\n return succeed(rtrn);\n });\n });\n }\n\n /**\n * Static helper to merge context variables and references for a supplied {@link IJsonContext | IJsonContext}.\n * @param baseContext - The {@link IJsonContext | IJsonContext} into which variables and references\n * are to be merged, or `undefined` to start from an empty context.\n * @param add - Optional initializer containing {@link VariableValue | variable values} and/or\n * {@link IJsonReferenceMap | reference maps} to be added to the {@link IJsonContext | context}.\n * @returns `Success` with a new {@link IJsonContext | IJsonContext} containing the variables and\n * references from the base context, merged with and overridden by any that were passed in, or\n * `Failure` with a message if an error occurs.\n */\n public static mergeContext(\n baseContext: IJsonContext | undefined,\n add: IJsonContext | undefined\n ): Result<IJsonContext | undefined> {\n if (baseContext) {\n if (add) {\n const rtrn: IJsonContext = {\n vars: add.vars ?? baseContext.vars,\n refs: add.refs ?? baseContext.refs\n };\n if (add.hasOwnProperty('extendVars')) {\n rtrn.extendVars = add.extendVars;\n } else if (baseContext.hasOwnProperty('extendVars')) {\n rtrn.extendVars = baseContext.extendVars;\n }\n return succeed(rtrn);\n }\n return succeed(baseContext);\n }\n return succeed(add);\n }\n\n /**\n * Applies {@link JsonContextHelper.extendContextVars | extendContextVars} to the\n * {@link IJsonContext | IJsonContext} associated with this helper.\n * @param vars - Optional {@link VariableValue | variable values} to be added to the\n * @returns `Success` with a new {@link TemplateVars | TemplateVars} containing the variables\n * from the base context, merged with and overridden by any that were passed in, or `Failure`\n * with a message if an error occurs.\n */\n public extendVars(vars?: VariableValue[]): Result<TemplateVars | undefined> {\n return JsonContextHelper.extendContextVars(this._context, vars);\n }\n\n /**\n * Applies {@link JsonContextHelper.extendContextRefs | extendContextRefs} to the\n * {@link IJsonContext | IJsonContext} associated with this helper.\n * @param refs - Optional {@link IJsonReferenceMap | reference maps} to be added to the\n * @returns `Success` with a new {@link IJsonReferenceMap | reference map} which projects\n * the references from the base context, merged with and overridden by any that were passed in,\n * or `Failure` with a message if an error occurs.\n */\n public extendRefs(refs?: IJsonReferenceMap[]): Result<IJsonReferenceMap | undefined> {\n return JsonContextHelper.extendContextRefs(this._context, refs);\n }\n\n /**\n * Applies static `JsonContextHelper.extendContext` to the\n * {@link IJsonContext | IJsonContext} associated with this helper.\n * @param add - Optional initializer containing {@link VariableValue | variable values} and/or\n * {@link IJsonReferenceMap | reference maps} to be added to the {@link IJsonContext | context}.\n * @returns `Success` with a new {@link IJsonContext | IJsonContext} containing the variables and\n * references from the base context, merged with and overridden by any that were passed in, or\n * `Failure` with a message if an error occurs.\n */\n public extendContext(add?: {\n vars?: VariableValue[];\n refs?: IJsonReferenceMap[];\n }): Result<IJsonContext | undefined> {\n return JsonContextHelper.extendContext(this._context, add);\n }\n\n /**\n * Applies static `JsonContextHelper.mergeContext` to the\n * {@link IJsonContext | IJsonContext} associated with this helper.\n * @param add - Optional initializer containing {@link VariableValue | variable values} and/or\n * {@link IJsonReferenceMap | reference maps} to be added to the {@link IJsonContext | context}.\n * @returns `Success` with a new {@link IJsonContext | IJsonContext} containing the variables and\n * references from the base context, merged with and overridden by any that were passed in, or\n * `Failure` with a message if an error occurs.\n */\n public mergeContext(merge?: IJsonContext): Result<IJsonContext | undefined> {\n return JsonContextHelper.mergeContext(this._context, merge);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/context/index.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,6BAA6B,EAC7B,YAAY,EACZ,0BAA0B,EAC1B,aAAa,EACb,iBAAiB,EAClB,MAAM,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/context/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,mDAAqD;AAA5C,mHAAA,iBAAiB,OAAA;AAC1B,6CAQuB;AADrB,gHAAA,iBAAiB,OAAA","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport { CompositeJsonMap } from './compositeJsonMap';\nexport { JsonContextHelper } from './contextHelpers';\nexport {\n IJsonContext,\n IJsonReferenceMap,\n JsonReferenceMapFailureReason,\n TemplateVars,\n TemplateVarsExtendFunction,\n VariableValue,\n defaultExtendVars\n} from './jsonContext';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonContext.d.ts","sourceRoot":"","sources":["../../../src/packlets/context/jsonContext.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,EAAW,MAAM,eAAe,CAAC;AAEhE;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE9C;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACvC,IAAI,EAAE,YAAY,GAAG,SAAS,EAC9B,MAAM,EAAE,aAAa,EAAE,KACpB,MAAM,CAAC,YAAY,GAAG,SAAS,CAAC,CAAC;AAEtC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,YAAY,GAAG,SAAS,EAC9B,MAAM,EAAE,aAAa,EAAE,GACtB,MAAM,CAAC,YAAY,GAAG,SAAS,CAAC,CAOlC;AAED;;;;;GAKG;AACH,MAAM,MAAM,6BAA6B,GAAG,SAAS,GAAG,OAAO,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAEnC;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAE1B;;;;;;;;OAQG;IAEH,aAAa,CACX,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,YAAY,GACrB,cAAc,CAAC,UAAU,EAAE,6BAA6B,CAAC,CAAC;IAE7D;;;;;;;OAOG;IAEH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,cAAc,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC;CAC7G;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,UAAU,CAAC,EAAE,0BAA0B,CAAC;CACzC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonContext.js","sourceRoot":"","sources":["../../../src/packlets/context/jsonContext.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAoCH,8CAUC;AA3CD,4CAAgE;AA0BhE;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,IAA8B,EAC9B,MAAuB;IAEvB,sBAAsB;IACtB,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7C,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC;AACvB,CAAC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonObject, JsonValue } from '@fgv/ts-json-base';\nimport { DetailedResult, Result, succeed } from '@fgv/ts-utils';\n\n/**\n * Collection of variables used for template replacement in a JSON edit or\n * conversion.\n * @public\n */\nexport type TemplateVars = Record<string, unknown>;\n\n/**\n * Describes one value in a {@link TemplateVars | TemplateVars} collection of\n * variables.\n * @public\n */\nexport type VariableValue = [string, unknown];\n\n/**\n * Function used to create a new collection of {@link TemplateVars | TemplateVars} with\n * one or more new or changed values.\n * @public\n */\nexport type TemplateVarsExtendFunction = (\n base: TemplateVars | undefined,\n values: VariableValue[]\n) => Result<TemplateVars | undefined>;\n\n/**\n * This default implementation of a {@link TemplateVarsExtendFunction | TemplateVarsExtendFunction}\n * creates a new collection via inheritance from the supplied collection.\n * @param base - The base {@link TemplateVars | variables} to be extended.\n * @param values - The {@link VariableValue | values} to be added or overridden in the new variables.\n * @public\n */\nexport function defaultExtendVars(\n base: TemplateVars | undefined,\n values: VariableValue[]\n): Result<TemplateVars | undefined> {\n /* c8 ignore next 1 */\n const rtrn = base ? Object.create(base) : {};\n for (const v of values) {\n rtrn[v[0]] = v[1];\n }\n return succeed(rtrn);\n}\n\n/**\n * Failure reason for {@link IJsonReferenceMap | IJsonReferenceMap} lookup, where `'unknown'`\n * means that the object is not present in the map and `'error'` means\n * that an error occurred while retrieving or converting it.\n * @public\n */\nexport type JsonReferenceMapFailureReason = 'unknown' | 'error';\n\n/**\n * Interface for a simple map that returns named `JsonValue` values with templating,\n * conditional logic, and external reference lookups applied using an optionally supplied context.\n * @public\n */\nexport interface IJsonReferenceMap {\n /**\n * Determine if a key might be valid for this map but does not determine if key actually\n * exists. Allows key range to be constrained.\n * @param key - The key to be tested.\n * @returns `true` if the key is in the valid range, `false` otherwise.\n */\n keyIsInRange(key: string): boolean;\n\n /**\n * Determines if an object with the specified key actually exists in the map.\n * @param key - The key to be tested.\n * @returns `true` if an object with the specified key exists, `false` otherwise.\n */\n has(key: string): boolean;\n\n /**\n * Gets a `JsonObject` specified by key.\n * @param key - The key of the object to be retrieved.\n * @param context - Optional {@link IJsonContext | IJsonContext} used to construct\n * the object.\n * @returns `Success` with the formatted JsonObject if successful. `Failure`\n * with detail `'unknown'` if no such object exists, or `Failure` with detail `'error'` if\n * the object was found but could not be formatted.\n */\n // eslint-disable-next-line no-use-before-define\n getJsonObject(\n key: string,\n context?: IJsonContext\n ): DetailedResult<JsonObject, JsonReferenceMapFailureReason>;\n\n /**\n * Gets a `JsonValue` specified by key.\n * @param key - The key of the object to be retrieved.\n * @param context - Optional {@link IJsonContext | JSON Context} used to format the value\n * @returns `Success` with the formatted `JsonValue` if successful. `Failure`\n * with detail `'unknown'` if no such object exists, or `Failure` with detail `'error'` if\n * the object was found but could not be formatted.\n */\n // eslint-disable-next-line no-use-before-define\n getJsonValue(key: string, context?: IJsonContext): DetailedResult<JsonValue, JsonReferenceMapFailureReason>;\n}\n\n/**\n * Context used to convert or edit JSON objects.\n * @public\n */\nexport interface IJsonContext {\n vars?: TemplateVars;\n refs?: IJsonReferenceMap;\n extendVars?: TemplateVarsExtendFunction;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/packlets/converters/converters.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,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5E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC1B,oBAAoB,GAAG,IAAI,sCAAsB,EAAE,CAAC;QACtD,CAAC;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD,OAAO,IAAI,sCAAsB,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAAC,OAAkD;IAChF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC5B,sBAAsB,GAAG,IAAI,wCAAwB,EAAE,CAAC;QAC1D,CAAC;QACD,OAAO,sBAAsB,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,wCAAwB,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,QAAQ,CAAC,OAA2C;IAClE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,eAAe,GAAG,IAAI,iCAAiB,EAAE,CAAC;QAC5C,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,iCAAiB,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonArray, JsonObject } from '@fgv/ts-json-base';\nimport { Converter } from '@fgv/ts-utils';\nimport { IJsonContext } from '../context';\nimport {\n ConditionalJsonConverter,\n ConditionalJsonConverterOptions,\n JsonConverter,\n RichJsonConverter,\n RichJsonConverterOptions,\n TemplatedJsonConverter,\n TemplatedJsonConverterOptions\n} from './jsonConverter';\n\n/**\n * A simple validating {@link JsonConverter | JSON converter}. Converts unknown to\n * JSON or fails if the unknown contains any invalid JSON values.\n * @public\n */\nexport const json: JsonConverter = new JsonConverter();\n\n/**\n * A simple validating {@link JsonConverter | JSON converter}. Converts unknown\n * to a `JsonObject`, or fails if the `unknown` contains invalid\n * JSON or is not an object.\n * @public\n */\nexport const jsonObject: Converter<JsonObject, IJsonContext> = json.object();\n\n/**\n * A simple validating {@link JsonConverter | JSON converter}. Converts `unknown` to a\n * `JsonArray`, or fails if the unknown contains invalid JSON or is\n * not an array.\n * @public\n */\nexport const jsonArray: Converter<JsonArray, IJsonContext> = json.array();\n\nlet templatedJsonDefault: JsonConverter | undefined;\nlet conditionalJsonDefault: JsonConverter | undefined;\nlet richJsonDefault: JsonConverter | undefined;\n\n/**\n * Helper function which creates a new {@link JsonConverter | JsonConverter} which converts an\n * `unknown` value to JSON, rendering any property names or string values using mustache with\n * the supplied context. See the mustache documentation for details of mustache syntax and view.\n * @param options - {@link TemplatedJsonConverterOptions | Options and context} for\n * the conversion.\n * @public\n */\nexport function templatedJson(options?: Partial<TemplatedJsonConverterOptions>): JsonConverter {\n if (!options) {\n if (!templatedJsonDefault) {\n templatedJsonDefault = new TemplatedJsonConverter();\n }\n return templatedJsonDefault;\n }\n return new TemplatedJsonConverter(options);\n}\n\n/**\n * Helper function which creates a new {@link JsonConverter | JsonConverter} which converts a\n * supplied `unknown` to strongly-typed JSON, by first rendering any property\n * names or string values using mustache with the supplied context, then applying\n * multi-value property expansion and conditional flattening based on property names.\n * @param options - {@link ConditionalJsonConverterOptions | Options and context} for\n * the conversion.\n * @public\n */\nexport function conditionalJson(options?: Partial<ConditionalJsonConverterOptions>): JsonConverter {\n if (!options) {\n if (!conditionalJsonDefault) {\n conditionalJsonDefault = new ConditionalJsonConverter();\n }\n return conditionalJsonDefault;\n }\n return new ConditionalJsonConverter(options);\n}\n\n/**\n * Helper function which creates a new {@link JsonConverter | JsonConverter} which converts a\n * supplied `unknown` to strongly-typed JSON, by first rendering any property\n * names or string values using mustache with the supplied context, then applying\n * multi-value property expansion and conditional flattening based on property names.\n * @param options - {@link RichJsonConverterOptions | Options and context} for\n * the conversion.\n * @public\n */\nexport function richJson(options?: Partial<RichJsonConverterOptions>): JsonConverter {\n if (!options) {\n if (!richJsonDefault) {\n richJsonDefault = new RichJsonConverter();\n }\n return richJsonDefault;\n }\n return new RichJsonConverter(options);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/converters/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/converters/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yDAA2C;AAGlC,gCAAU;AADnB,kDAAgC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Converters from './converters';\n\nexport * from './jsonConverter';\nexport { Converters };\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonConverter.d.ts","sourceRoot":"","sources":["../../../src/packlets/converters/jsonConverter.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAgB,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAgC,MAAM,eAAe,CAAC;AAC5F,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAE3B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAoD,UAAU,EAAE,MAAM,WAAW,CAAC;AAEzF;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;OAQG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAE3B;;;;;;;;OAQG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAE1B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,mBAAmB;IAUxD;;;;;OAKG;IACH,YAAmB,OAA2C;QAC5D,OAAO,mCAAQ,OAAO,GAAK,iBAAiB,CAAC,WAAW,CAAE,CAAC;QAC3D,MAAM,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;QAC3D,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAA2C;QAC9D,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7D,CAAC;;AA9BH,8CA+BC;AA9BC;;;GAGG;AACoB,6BAAW,mCAC7B,wBAAwB,CAAC,kBAAkB,KAC9C,aAAa,EAAE,IAAI,IACnB","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonArray, JsonObject, JsonValue, isJsonObject } from '@fgv/ts-json-base';\nimport { Conversion, Converter, Result, captureResult, fail, succeed } from '@fgv/ts-utils';\nimport {\n IJsonContext,\n IJsonReferenceMap,\n TemplateVars,\n TemplateVarsExtendFunction,\n defaultExtendVars\n} from '../context';\n\nimport { EditorRules, IJsonEditorOptions, IJsonEditorRule, JsonEditor } from '../editor';\n\n/**\n * Conversion options for {@link JsonConverter | JsonConverter}.\n * @public\n */\nexport interface IJsonConverterOptions {\n /**\n * If `true` and if template variables are available,\n * then string property values will be rendered using\n * mustache and those variable values. Otherwise string\n * properties are copied without modification.\n *\n * Defaults to `true` if vars are supplied with options,\n * `false` otherwise.\n */\n useValueTemplates: boolean;\n\n /**\n * If `true` and if template variables are available,\n * then property names will be rendered using\n * mustache and those variable values. Otherwise\n * property names are copied without modification.\n *\n * Defaults to `true` if vars are supplied with options,\n * `false` otherwise.\n */\n useNameTemplates: boolean;\n\n /**\n * If `true` and if template variables are available,\n * then string property names will be considered for\n * conditionals.\n *\n * Default is to match {@link IJsonConverterOptions.useNameTemplates | useNameTemplates}.\n */\n useConditionalNames: boolean;\n\n /**\n * If `true` (default) then properties with unconditional names\n * (which start with !) are flattened.\n */\n flattenUnconditionalValues: boolean;\n\n /**\n * If `true` and if both template variables and a\n * context derivation function is available, then properties\n * which match the multi-value name pattern will be expanded.\n * Default matches {@link IJsonConverterOptions.useNameTemplates | useNameTemplates}.\n *\n * Default is `true` unless {@link IJsonConverterOptions.extendVars | extendVars} is\n * explicitly set to `undefined`.\n */\n useMultiValueTemplateNames: boolean;\n\n /**\n * The variables (mustache view) used to render templated string names\n * and properties. See the mustache documentation for details of mustache\n * syntax and the template view.\n */\n vars?: TemplateVars;\n\n /**\n * Method used to extend variables for children of an array node during\n * expansion. Default is to use a built-in extension function unless\n * {@link IJsonConverterOptions.extendVars | extendVars} is explicitly set to undefined.\n */\n extendVars?: TemplateVarsExtendFunction;\n\n /**\n * If `true` and if a {@link IJsonReferenceMap | references map} is supplied\n * in {@link IJsonConverterOptions.refs | refs}, then references in the source\n * object will be replaced with the corresponding value from the reference map.\n *\n * Default is `true` if {@link IJsonConverterOptions.refs | refs} are present in options,\n * `false` otherwise.\n */\n useReferences: boolean;\n\n /**\n * An optional {@link IJsonReferenceMap | reference map} used to insert any references\n * in the converted JSON.\n */\n refs?: IJsonReferenceMap;\n\n /**\n * If {@link IJsonConverterOptions.onInvalidPropertyName | onInvalidPropertyName} is `'error'`\n * (default) then any property name that is invalid after template rendering causes an error\n * and stops conversion. If {@link IJsonConverterOptions.onInvalidPropertyName | onInvalidPropertyName}\n * is `'ignore'`, then names which are invalid after template rendering are passed through unchanged.\n */\n onInvalidPropertyName: 'error' | 'ignore';\n\n /**\n * If {@link IJsonConverterOptions.onInvalidPropertyValue | onInvalidPropertyValue} is `'error'`\n * (default) then any illegal property value causes an error and stops conversion. If\n * {@link IJsonConverterOptions.onInvalidPropertyValue | onInvalidPropertyValue} is `'ignore'` then\n * any invalid property values are silently ignored.\n */\n onInvalidPropertyValue: 'error' | 'ignore';\n\n /**\n * If {@link IJsonConverterOptions.onUndefinedPropertyValue | onUndefinedPropertyValue} is `'error'`,\n * then any property with value `undefined` will cause an error and stop conversion. If\n * {@link IJsonConverterOptions.onUndefinedPropertyValue | onUndefinedPropertyValue} is `'ignore'` (default)\n * then any property with value `undefined` is silently ignored.\n */\n onUndefinedPropertyValue: 'error' | 'ignore';\n}\n\n/**\n * Merges an optionally supplied partial set of {@link IJsonConverterOptions | options} with\n * the default converter options and taking all dynamic rules into account (e.g. template usage enabled\n * if variables are supplied and disabled if not), producing a fully-resolved set of\n * {@link IJsonConverterOptions | IJsonConverterOptions}.\n * @param partial - An optional partial {@link IJsonConverterOptions | IJsonConverterOptions}\n * to be merged.\n * @public\n */\nexport function mergeDefaultJsonConverterOptions(\n partial?: Partial<IJsonConverterOptions>\n): IJsonConverterOptions {\n const haveVars = partial?.vars !== undefined;\n const haveRefs = partial?.refs !== undefined;\n const extender = partial?.hasOwnProperty('extendVars') ? partial.extendVars : defaultExtendVars;\n const haveExtender = extender !== undefined;\n const namesDefault = partial?.useNameTemplates ?? haveVars;\n const conditionsDefault = partial?.useConditionalNames ?? namesDefault;\n\n const options: IJsonConverterOptions = {\n useValueTemplates: partial?.useValueTemplates ?? haveVars,\n useNameTemplates: namesDefault,\n useConditionalNames: conditionsDefault,\n flattenUnconditionalValues: partial?.flattenUnconditionalValues ?? conditionsDefault,\n useMultiValueTemplateNames: partial?.useMultiValueTemplateNames ?? (haveExtender && namesDefault),\n useReferences: partial?.useReferences ?? haveRefs,\n onInvalidPropertyName: partial?.onInvalidPropertyName ?? 'error',\n onInvalidPropertyValue: partial?.onInvalidPropertyValue ?? 'error',\n onUndefinedPropertyValue: partial?.onUndefinedPropertyValue ?? 'ignore',\n extendVars: extender\n };\n if (partial?.vars) {\n options.vars = partial.vars;\n }\n if (partial?.refs) {\n options.refs = partial.refs;\n }\n return options;\n}\n\n/**\n * Creates a new {@link IJsonContext | JSON context} using values supplied in an optional partial\n * {@link IJsonConverterOptions | converter options}.\n * @param partial - Optional partial {@link IJsonConverterOptions | IJsonConverterOptions} used to\n * populate the context.\n * @public\n */\nexport function contextFromConverterOptions(\n partial?: Partial<IJsonConverterOptions>\n): IJsonContext | undefined {\n const context: IJsonContext = {};\n if (partial?.vars) {\n context.vars = partial.vars;\n }\n if (partial?.refs) {\n context.refs = partial.refs;\n }\n if (partial?.hasOwnProperty('extendVars')) {\n context.extendVars = partial.extendVars;\n }\n return context.vars || context.refs || context.extendVars ? context : undefined;\n}\n\n/**\n * Creates a new {@link JsonEditor | JsonEditor} from an optionally supplied partial\n * {@link IJsonConverterOptions | JSON converter options}.\n * Expands supplied options with default values and constructs an editor with\n * matching configuration and defined rules.\n * @param partial - Optional partial {@link IJsonConverterOptions | IJsonConverterOptions}\n * used to create the editor.\n * @public\n */\nexport function converterOptionsToEditor(partial?: Partial<IJsonConverterOptions>): Result<JsonEditor> {\n const converterOptions = mergeDefaultJsonConverterOptions(partial);\n const context = contextFromConverterOptions(partial);\n const validation = {\n onInvalidPropertyName: converterOptions.onInvalidPropertyName,\n onInvalidPropertyValue: converterOptions.onInvalidPropertyValue,\n onUndefinedPropertyValue: converterOptions.onUndefinedPropertyValue\n };\n const editorOptions: IJsonEditorOptions = { context, validation };\n\n const rules: IJsonEditorRule[] = [];\n if (converterOptions.useNameTemplates || converterOptions.useValueTemplates) {\n const templateOptions = {\n ...editorOptions,\n useNameTemplates: converterOptions.useNameTemplates,\n useValueTemplates: converterOptions.useValueTemplates\n };\n rules.push(new EditorRules.TemplatedJsonEditorRule(templateOptions));\n }\n if (converterOptions.useConditionalNames || converterOptions.flattenUnconditionalValues) {\n const conditionalOptions = {\n ...editorOptions,\n flattenUnconditionalValues: converterOptions.flattenUnconditionalValues\n };\n rules.push(new EditorRules.ConditionalJsonEditorRule(conditionalOptions));\n }\n if (converterOptions.useMultiValueTemplateNames) {\n rules.push(new EditorRules.MultiValueJsonEditorRule(editorOptions));\n }\n if (converterOptions.useReferences) {\n rules.push(new EditorRules.ReferenceJsonEditorRule(editorOptions));\n }\n\n return JsonEditor.create(editorOptions, rules);\n}\n\n/**\n * A thin wrapper to allow an arbitrary {@link JsonEditor | JsonEditor} to be used via the\n * \\@fgv/ts-utils `Converter` pattern.\n * @public\n */\nexport class JsonEditorConverter extends Conversion.BaseConverter<JsonValue, IJsonContext> {\n public readonly editor: JsonEditor;\n\n /**\n * Constructs a new {@link JsonEditor | JsonEditor}Converter which uses the supplied editor\n * @param editor -\n */\n public constructor(editor: JsonEditor) {\n super((from, __self, context) => this._convert(from, context), editor.options.context);\n this.editor = editor;\n }\n\n /**\n * Constructs a new {@link JsonEditor | JsonEditor}Converter which uses the supplied editor\n * @param editor -\n */\n public static createWithEditor(editor: JsonEditor): Result<JsonEditorConverter> {\n return captureResult(() => new JsonEditorConverter(editor));\n }\n\n /**\n * Gets a derived converter which fails if the resulting converted\n * `JsonValue` is not a `JsonObject`.\n */\n public object(): Converter<JsonObject, IJsonContext> {\n return this.map((jv) => {\n if (!isJsonObject(jv)) {\n return fail(`Cannot convert \"${JSON.stringify(jv)}\" to JSON object.`);\n }\n return succeed(jv);\n });\n }\n\n /**\n * Gets a derived converter which fails if the resulting converted\n * `JsonValue` is not a `JsonArray`.\n */\n public array(): Converter<JsonArray, IJsonContext> {\n return this.map((jv) => {\n if (!Array.isArray(jv) || typeof jv !== 'object') {\n return fail(`Cannot convert \"${JSON.stringify(jv)}\" to JSON array.`);\n }\n return succeed(jv);\n });\n }\n\n protected _convert(from: unknown, context?: IJsonContext): Result<JsonValue> {\n return this.editor.clone(from as JsonValue, context);\n }\n}\n\n/**\n * An \\@fgv/ts-utils `Converter` from `unknown` to type-safe JSON, optionally\n * rendering any string property names or values using mustache with a supplied view.\n * @public\n */\nexport class JsonConverter extends JsonEditorConverter {\n /**\n * Constructs a new {@link JsonConverter | JsonConverter} with\n * supplied or default options.\n * @param options - Optional partial {@link IJsonConverterOptions | options}\n * to configure the converter.\n */\n public constructor(options?: Partial<IJsonConverterOptions>) {\n const editor = converterOptionsToEditor(options).orThrow();\n super(editor);\n }\n\n /**\n * Creates a new {@link JsonConverter | JsonConverter}.\n * @param options - Optional partial {@link IJsonConverterOptions | options}\n * to configure the converter.\n * @returns `Success` with a new {@link JsonConverter | JsonConverter}, or `Failure`\n * with an informative message if an error occurs.\n */\n public static create(options?: Partial<IJsonConverterOptions>): Result<JsonConverter> {\n return captureResult(() => new JsonConverter(options));\n }\n}\n\n/**\n * Initialization options for a {@link TemplatedJsonConverter | TemplatedJsonConverter}.\n * @public\n */\nexport type TemplatedJsonConverterOptions = Omit<\n IJsonConverterOptions,\n 'useNameTemplates' | 'useValueTemplates' | 'useMultiValueTemplateNames'\n>;\n\n/**\n * An \\@fgv/ts-utils `Converter` from `unknown` to type-safe JSON\n * with mustache template rendering and multi-value property name rules enabled\n * regardless of initial context.\n * @public\n */\nexport class TemplatedJsonConverter extends JsonEditorConverter {\n /**\n * Default {@link IJsonConverterOptions | JSON converter options}\n * to enable templated conversion.\n */\n public static readonly templateOptions: Partial<IJsonConverterOptions> = {\n useNameTemplates: true,\n useValueTemplates: true,\n useMultiValueTemplateNames: true,\n useConditionalNames: false,\n flattenUnconditionalValues: false\n };\n\n /**\n * Constructs a new {@link TemplatedJsonConverter | TemplatedJsonConverter} with\n * supplied or default options.\n * @param options - Optional partial {@link TemplatedJsonConverterOptions | options}\n * to configure the converter.\n */\n public constructor(options?: Partial<TemplatedJsonConverterOptions>) {\n options = { ...options, ...TemplatedJsonConverter.templateOptions };\n const editor = converterOptionsToEditor(options).orThrow();\n super(editor);\n }\n\n /**\n * Constructs a new {@link TemplatedJsonConverter | TemplatedJsonConverter} with\n * supplied or default options.\n * @param options - Optional partial {@link TemplatedJsonConverterOptions | options}\n * to configure the converter.\n */\n public static create(options?: Partial<TemplatedJsonConverterOptions>): Result<JsonConverter> {\n return captureResult(() => new TemplatedJsonConverter(options));\n }\n}\n\n/**\n * Options for a {@link ConditionalJsonConverter | ConditionalJsonConverter}.\n * @public\n */\nexport type ConditionalJsonConverterOptions = Omit<TemplatedJsonConverterOptions, 'useConditionalNames'>;\n\n/**\n * An \\@fgv/ts-utils `Converter` from `unknown` to type-safe JSON with mustache\n * template rendering, multi-value property name and conditional property\n * name rules enabled regardless of initial context.\n * @public\n */\nexport class ConditionalJsonConverter extends JsonEditorConverter {\n /**\n * Default {@link IJsonConverterOptions | JSON converter options}\n * to enable conditional conversion.\n */\n public static readonly conditionalOptions: Partial<IJsonConverterOptions> = {\n ...TemplatedJsonConverter.templateOptions,\n useConditionalNames: true,\n flattenUnconditionalValues: true\n };\n\n /**\n * Constructs a new {@link ConditionalJsonConverter | ConditionalJsonConverter} with supplied or\n * default options.\n * @param options - Optional partial {@link ConditionalJsonConverterOptions | configuration or context}\n * for the converter.\n */\n public constructor(options?: Partial<ConditionalJsonConverterOptions>) {\n options = { ...options, ...ConditionalJsonConverter.conditionalOptions };\n const editor = converterOptionsToEditor(options).orThrow();\n super(editor);\n }\n\n /**\n * Constructs a new {@link ConditionalJsonConverter | ConditionalJsonConverter} with supplied or\n * default options.\n * @param options - Optional partial {@link ConditionalJsonConverterOptions | configuration or context}\n * for the converter.\n */\n public static create(options?: Partial<ConditionalJsonConverterOptions>): Result<JsonConverter> {\n return captureResult(() => new ConditionalJsonConverter(options));\n }\n}\n\n/**\n * Initialization options for a {@link RichJsonConverter | RichJsonConverter}.\n * @public\n */\nexport type RichJsonConverterOptions = Omit<ConditionalJsonConverterOptions, 'useReferences'>;\n\n/**\n * A \\@fgv/ts-utils `Converter` from `unknown` to type-safe JSON with mustache\n * template rendering, multi-value property name, conditional property\n * name, and external reference rules enabled regardless of initial context.\n * @public\n */\nexport class RichJsonConverter extends JsonEditorConverter {\n /**\n * Default {@link IJsonConverterOptions | JSON converter options}\n * to enable rich conversion.\n */\n public static readonly richOptions: Partial<IJsonConverterOptions> = {\n ...ConditionalJsonConverter.conditionalOptions,\n useReferences: true\n };\n\n /**\n * Constructs a new {@link RichJsonConverter | RichJsonConverter} with supplied or\n * default options.\n * @param options - Optional partial {@link RichJsonConverterOptions | configuration or context}\n * for the converter.\n */\n public constructor(options?: Partial<RichJsonConverterOptions>) {\n options = { ...options, ...RichJsonConverter.richOptions };\n const editor = converterOptionsToEditor(options).orThrow();\n super(editor);\n }\n\n /**\n * Constructs a new {@link RichJsonConverter | RichJsonConverter} with supplied or\n * default options\n * @param options - Optional partial {@link RichJsonConverterOptions | configuration or context}\n * for the converter.\n */\n public static create(options?: Partial<RichJsonConverterOptions>): Result<JsonConverter> {\n return captureResult(() => new RichJsonConverter(options));\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detailedDiff.d.ts","sourceRoot":"","sources":["../../../src/packlets/diff/detailedDiff.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,SAAS,EAA8C,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAW,MAAM,eAAe,CAAC;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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O,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QACD,OAAO;IACT,CAAC;IACD,oGAAoG;IAEpG,4BAA4B;IAC5B,OAAO,CAAC,IAAI,CAAC;QACX,IAAI;QACJ,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,SAAgB,QAAQ,CACtB,IAAe,EACf,IAAe,EACf,UAA4B,EAAE;IAE9B,MAAM,IAAI,mBACR,gBAAgB,EAAE,KAAK,EACvB,aAAa,EAAE,GAAG,EAClB,iBAAiB,EAAE,IAAI,IACpB,OAAO,CACX,CAAC;IAEF,MAAM,OAAO,GAAkB,EAAE,CAAC;IAClC,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAE7C,MAAM,MAAM,GAAgB;QAC1B,OAAO;QACP,SAAS,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC;KAChF,CAAC;IAEF,OAAO,IAAA,kBAAO,EAAC,MAAM,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AACH,SAAgB,UAAU,CAAC,IAAe,EAAE,IAAe;IACzD,OAAO,IAAA,kBAAU,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonValue, isJsonObject, isJsonArray, isJsonPrimitive } from '@fgv/ts-json-base';\nimport { Result, succeed } from '@fgv/ts-utils';\nimport { deepEquals } from './utils';\n\n/**\n * JSON Diff Utilities for TypeScript\n *\n * This module provides comprehensive tools for comparing JSON values and identifying\n * differences between them. It offers two complementary approaches:\n *\n * ## **Detailed Diff API** (`jsonDiff`)\n * Best for analysis, debugging, and understanding specific changes:\n * - Returns a list of individual changes with exact paths and values\n * - Ideal for logging, change tracking, and detailed analysis\n * - Configurable options for array handling and path notation\n *\n * ## **Three-Way Diff API** (`jsonThreeWayDiff`)\n * Best for applying changes and programmatic manipulation:\n * - Returns three objects representing removed, unchanged, and added data\n * - Perfect for merging, UI displays, and actionable results\n * - Treats arrays as atomic units for simpler handling\n *\n * ## **Simple Equality** (`jsonEquals`)\n * Fast boolean check for JSON equality without change details.\n *\n * **Key Features:**\n * - Deep recursive comparison of nested structures\n * - Support for all JSON types: objects, arrays, primitives, null\n * - TypeScript-first with comprehensive type safety\n * - Result pattern for consistent error handling\n * - Extensive TSDoc documentation with practical examples\n *\n * @example Quick comparison of the two main APIs\n * ```typescript\n * const before = { name: \"John\", age: 30, city: \"NYC\" };\n * const after = { name: \"Jane\", age: 30, country: \"USA\" };\n *\n * // Detailed analysis\n * const detailed = jsonDiff(before, after);\n * // Returns: [\n * // { path: \"name\", type: \"modified\", oldValue: \"John\", newValue: \"Jane\" },\n * // { path: \"city\", type: \"removed\", oldValue: \"NYC\" },\n * // { path: \"country\", type: \"added\", newValue: \"USA\" }\n * // ]\n *\n * // Actionable objects\n * const actionable = jsonThreeWayDiff(before, after);\n * // Returns: {\n * // onlyInA: { name: \"John\", city: \"NYC\" },\n * // unchanged: { age: 30 },\n * // onlyInB: { name: \"Jane\", country: \"USA\" }\n * // }\n *\n * // Apply changes: { ...unchanged, ...onlyInB }\n * // Revert changes: { ...unchanged, ...onlyInA }\n * ```\n */\n\n/**\n * Type of change detected in a JSON diff operation.\n *\n * - `'added'` - Property exists only in the second object\n * - `'removed'` - Property exists only in the first object\n * - `'modified'` - Property exists in both objects but with different values\n * - `'unchanged'` - Property exists in both objects with identical values (only included when `includeUnchanged` is true)\n *\n * @public\n */\nexport type DiffChangeType = 'added' | 'removed' | 'modified' | 'unchanged';\n\n/**\n * Represents a single change in a JSON diff operation.\n *\n * Each change describes a specific difference between two JSON values, including\n * the location of the change and the old/new values involved.\n *\n * @example\n * ```typescript\n * // Example changes from diffing { name: \"John\", age: 30 } vs { name: \"Jane\", city: \"NYC\" }\n * const changes: IDiffChange[] = [\n * { path: \"name\", type: \"modified\", oldValue: \"John\", newValue: \"Jane\" },\n * { path: \"age\", type: \"removed\", oldValue: 30 },\n * { path: \"city\", type: \"added\", newValue: \"NYC\" }\n * ];\n * ```\n *\n * @public\n */\nexport interface IDiffChange {\n /**\n * The path to the changed value using dot notation.\n *\n * For nested objects, uses dots to separate levels (e.g., \"user.profile.name\").\n * For arrays, uses numeric indices (e.g., \"items.0.id\", \"tags.2\").\n * Empty string indicates the root value itself changed.\n *\n * @example \"user.name\", \"items.0.id\", \"settings.theme\", \"\"\n */\n path: string;\n\n /**\n * The type of change that occurred.\n *\n * @see {@link DiffChangeType} for detailed descriptions of each change type.\n */\n type: DiffChangeType;\n\n /**\n * The value in the first object.\n *\n * - Present for `'removed'` and `'modified'` changes\n * - Present for `'unchanged'` changes when `includeUnchanged` is true\n * - Undefined for `'added'` changes\n */\n oldValue?: JsonValue;\n\n /**\n * The value in the second object.\n *\n * - Present for `'added'` and `'modified'` changes\n * - Present for `'unchanged'` changes when `includeUnchanged` is true\n * - Undefined for `'removed'` changes\n */\n newValue?: JsonValue;\n}\n\n/**\n * Result of a JSON diff operation containing all detected changes.\n *\n * This interface provides detailed information about every difference found\n * between two JSON values, making it ideal for analysis, debugging, and\n * understanding exactly what changed.\n *\n * @example\n * ```typescript\n * const result: IDiffResult = {\n * changes: [\n * { path: \"name\", type: \"modified\", oldValue: \"John\", newValue: \"Jane\" },\n * { path: \"hobbies.1\", type: \"added\", newValue: \"gaming\" }\n * ],\n * identical: false\n * };\n * ```\n *\n * @see {@link IDiffChange} for details about individual change objects\n * @see {@link Diff.jsonDiff} for the function that produces this result\n * @public\n */\nexport interface IDiffResult {\n /**\n * Array of all changes detected between the two JSON objects.\n *\n * Changes are ordered by the path where they occur. For nested structures,\n * parent changes appear before child changes.\n */\n changes: IDiffChange[];\n\n /**\n * True if the objects are identical, false otherwise.\n *\n * When true, the `changes` array will be empty (unless `includeUnchanged`\n * option was used, in which case it may contain 'unchanged' entries).\n */\n identical: boolean;\n}\n\n/**\n * Options for customizing JSON diff behavior.\n *\n * These options allow you to control how the diff algorithm processes\n * different types of JSON structures and what information is included\n * in the results.\n *\n * @example\n * ```typescript\n * // Include unchanged values and use custom path separator\n * const options: IJsonDiffOptions = {\n * includeUnchanged: true,\n * pathSeparator: '/',\n * arrayOrderMatters: false\n * };\n *\n * const result = jsonDiff(obj1, obj2, options);\n * ```\n *\n * @public\n */\nexport interface IJsonDiffOptions {\n /**\n * If true, includes unchanged values in the result.\n *\n * When enabled, the diff result will include entries with `type: 'unchanged'`\n * for properties that exist in both objects with identical values. This can\n * be useful for displaying complete side-by-side comparisons.\n *\n * @defaultValue false\n */\n includeUnchanged?: boolean;\n\n /**\n * Custom path separator for nested property paths.\n *\n * Controls the character used to separate levels in nested object paths.\n * For example, with separator `'/'`, a nested property would be reported\n * as `\"user/profile/name\"` instead of `\"user.profile.name\"`.\n *\n * @defaultValue \".\"\n * @example \"/\", \"-\\>\", \"::\"\n */\n pathSeparator?: string;\n\n /**\n * If true, treats arrays as ordered lists where position matters.\n * If false, treats arrays as unordered sets.\n *\n * When `true` (default), array changes are reported by index position:\n * `[1,2,3]` vs `[1,3,2]` shows modifications at indices 1 and 2.\n *\n * When `false`, arrays are compared as sets: `[1,2,3]` vs `[1,3,2]`\n * may be considered equivalent (simplified unordered comparison).\n *\n * @defaultValue true\n */\n arrayOrderMatters?: boolean;\n}\n\n/**\n * Internal recursive diff function that builds the change list.\n */\nfunction diffRecursive(\n obj1: JsonValue,\n obj2: JsonValue,\n path: string,\n options: Required<IJsonDiffOptions>,\n changes: IDiffChange[]\n): void {\n const pathPrefix = path ? `${path}${options.pathSeparator}` : '';\n\n // Handle primitive values\n if (isJsonPrimitive(obj1) || isJsonPrimitive(obj2)) {\n if (!deepEquals(obj1, obj2)) {\n changes.push({\n path,\n type: 'modified',\n oldValue: obj1,\n newValue: obj2\n });\n } else if (options.includeUnchanged) {\n changes.push({\n path,\n type: 'unchanged',\n oldValue: obj1,\n newValue: obj2\n });\n }\n return;\n }\n\n // Handle arrays\n if (isJsonArray(obj1) && isJsonArray(obj2)) {\n if (options.arrayOrderMatters) {\n // Ordered array comparison\n const maxLength = Math.max(obj1.length, obj2.length);\n for (let i = 0; i < maxLength; i++) {\n const itemPath = `${pathPrefix}${i}`;\n\n if (i >= obj1.length) {\n changes.push({\n path: itemPath,\n type: 'added',\n newValue: obj2[i]\n });\n } else if (i >= obj2.length) {\n changes.push({\n path: itemPath,\n type: 'removed',\n oldValue: obj1[i]\n });\n } else {\n diffRecursive(obj1[i], obj2[i], itemPath, options, changes);\n }\n }\n } else {\n // Unordered array comparison - simplified approach\n // This is a basic implementation; a more sophisticated approach would use\n // algorithms like longest common subsequence for better matching\n const processed = new Set<number>();\n\n // Find matching elements\n for (let i = 0; i < obj1.length; i++) {\n let found = false;\n for (let j = 0; j < obj2.length; j++) {\n if (!processed.has(j) && deepEquals(obj1[i], obj2[j])) {\n processed.add(j);\n found = true;\n if (options.includeUnchanged) {\n changes.push({\n path: `${pathPrefix}${i}`,\n type: 'unchanged',\n oldValue: obj1[i],\n newValue: obj2[j]\n });\n }\n break;\n }\n }\n if (!found) {\n changes.push({\n path: `${pathPrefix}${i}`,\n type: 'removed',\n oldValue: obj1[i]\n });\n }\n }\n\n // Find added elements\n for (let j = 0; j < obj2.length; j++) {\n if (!processed.has(j)) {\n changes.push({\n path: `${pathPrefix}${j}`,\n type: 'added',\n newValue: obj2[j]\n });\n }\n }\n }\n return;\n }\n\n // Handle one array, one non-array\n if (isJsonArray(obj1) || isJsonArray(obj2)) {\n changes.push({\n path,\n type: 'modified',\n oldValue: obj1,\n newValue: obj2\n });\n return;\n }\n\n // Handle objects\n if (isJsonObject(obj1) && isJsonObject(obj2)) {\n const keys1 = new Set(Object.keys(obj1));\n const keys2 = new Set(Object.keys(obj2));\n const allKeys = new Set([...keys1, ...keys2]);\n\n for (const key of allKeys) {\n const keyPath = path ? `${path}${options.pathSeparator}${key}` : key;\n\n if (!keys1.has(key)) {\n changes.push({\n path: keyPath,\n type: 'added',\n newValue: obj2[key]\n });\n } else if (!keys2.has(key)) {\n changes.push({\n path: keyPath,\n type: 'removed',\n oldValue: obj1[key]\n });\n } else {\n diffRecursive(obj1[key], obj2[key], keyPath, options, changes);\n }\n }\n return;\n }\n /* c8 ignore next 9 - defensive code path that should never be reached with valid JsonValue types */\n\n // Handle mixed object types\n changes.push({\n path,\n type: 'modified',\n oldValue: obj1,\n newValue: obj2\n });\n}\n\n/**\n * Performs a deep diff comparison between two JSON values.\n *\n * This function provides detailed change tracking by analyzing every difference\n * between two JSON structures. It returns a list of specific changes with paths,\n * making it ideal for debugging, logging, change analysis, and understanding\n * exactly what has changed between two data states.\n *\n * **Key Features:**\n * - Deep recursive comparison of nested objects and arrays\n * - Precise path tracking using dot notation (e.g., \"user.profile.name\")\n * - Support for all JSON value types: objects, arrays, primitives, null\n * - Configurable array comparison (ordered vs unordered)\n * - Optional inclusion of unchanged values for complete comparisons\n *\n * **Use Cases:**\n * - Debugging data changes in applications\n * - Generating change logs or audit trails\n * - Validating API responses against expected data\n * - Creating detailed diff reports for data synchronization\n *\n * @param obj1 - The first JSON value to compare (often the \"before\" state)\n * @param obj2 - The second JSON value to compare (often the \"after\" state)\n * @param options - Optional configuration for customizing diff behavior\n * @returns A Result containing the diff result with all detected changes\n *\n * @example Basic usage with objects\n * ```typescript\n * const before = { name: \"John\", age: 30, city: \"NYC\" };\n * const after = { name: \"Jane\", age: 30, country: \"USA\" };\n *\n * const result = jsonDiff(before, after);\n * if (result.success) {\n * result.value.changes.forEach(change => {\n * console.log(`${change.path}: ${change.type}`);\n * // Output:\n * // name: modified\n * // city: removed\n * // country: added\n * });\n * }\n * ```\n *\n * @example With arrays and nested structures\n * ```typescript\n * const user1 = {\n * profile: { name: \"John\", hobbies: [\"reading\"] },\n * settings: { theme: \"dark\" }\n * };\n * const user2 = {\n * profile: { name: \"John\", hobbies: [\"reading\", \"gaming\"] },\n * settings: { theme: \"light\", notifications: true }\n * };\n *\n * const result = jsonDiff(user1, user2);\n * if (result.success) {\n * console.log(result.value.changes);\n * // [\n * // { path: \"profile.hobbies.1\", type: \"added\", newValue: \"gaming\" },\n * // { path: \"settings.theme\", type: \"modified\", oldValue: \"dark\", newValue: \"light\" },\n * // { path: \"settings.notifications\", type: \"added\", newValue: true }\n * // ]\n * }\n * ```\n *\n * @example Using options for custom behavior\n * ```typescript\n * const options: IJsonDiffOptions = {\n * includeUnchanged: true, // Include unchanged properties\n * pathSeparator: '/', // Use '/' instead of '.' in paths\n * arrayOrderMatters: false // Treat arrays as unordered sets\n * };\n *\n * const result = jsonDiff(obj1, obj2, options);\n * ```\n *\n * @see {@link IDiffResult} for the structure of returned results\n * @see {@link IDiffChange} for details about individual changes\n * @see {@link IJsonDiffOptions} for available configuration options\n * @see {@link jsonThreeWayDiff} for an alternative API focused on actionable results\n * @see {@link jsonEquals} for simple equality checking without change details\n *\n * @public\n */\nexport function jsonDiff(\n obj1: JsonValue,\n obj2: JsonValue,\n options: IJsonDiffOptions = {}\n): Result<IDiffResult> {\n const opts: Required<IJsonDiffOptions> = {\n includeUnchanged: false,\n pathSeparator: '.',\n arrayOrderMatters: true,\n ...options\n };\n\n const changes: IDiffChange[] = [];\n diffRecursive(obj1, obj2, '', opts, changes);\n\n const result: IDiffResult = {\n changes,\n identical: changes.length === 0 || changes.every((c) => c.type === 'unchanged')\n };\n\n return succeed(result);\n}\n\n/**\n * A simpler helper function that returns true if two JSON values are deeply equal.\n *\n * This function provides a fast boolean check for JSON equality without the overhead\n * of tracking individual changes. It performs the same deep comparison logic as\n * {@link Diff.jsonDiff} but returns only a true/false result, making it ideal for\n * conditional logic and validation scenarios.\n *\n * **Key Features:**\n * - Deep recursive comparison of all nested structures\n * - Handles all JSON types: objects, arrays, primitives, null\n * - Object property order independence\n * - Array order significance (index positions matter)\n * - Performance optimized for equality checking\n *\n * **Use Cases:**\n * - Conditional logic based on data equality\n * - Input validation and testing assertions\n * - Caching and memoization keys\n * - Quick checks before expensive diff operations\n *\n * @param obj1 - The first JSON value to compare\n * @param obj2 - The second JSON value to compare\n * @returns True if the values are deeply equal, false otherwise\n *\n * @example Basic equality checking\n * ```typescript\n * // Objects with same structure and values\n * const user1 = { name: \"John\", hobbies: [\"reading\", \"gaming\"] };\n * const user2 = { name: \"John\", hobbies: [\"reading\", \"gaming\"] };\n * console.log(jsonEquals(user1, user2)); // true\n *\n * // Different property order (still equal)\n * const obj1 = { a: 1, b: 2 };\n * const obj2 = { b: 2, a: 1 };\n * console.log(jsonEquals(obj1, obj2)); // true\n *\n * // Different values\n * const before = { status: \"pending\" };\n * const after = { status: \"completed\" };\n * console.log(jsonEquals(before, after)); // false\n * ```\n *\n * @example With nested structures\n * ```typescript\n * const config1 = {\n * database: { host: \"localhost\", port: 5432 },\n * features: [\"auth\", \"cache\"]\n * };\n * const config2 = {\n * database: { host: \"localhost\", port: 5432 },\n * features: [\"auth\", \"cache\"]\n * };\n *\n * if (jsonEquals(config1, config2)) {\n * console.log(\"Configurations are identical\");\n * }\n * ```\n *\n * @example Array order sensitivity\n * ```typescript\n * const list1 = [1, 2, 3];\n * const list2 = [3, 2, 1];\n * console.log(jsonEquals(list1, list2)); // false - order matters\n *\n * const list3 = [1, 2, 3];\n * const list4 = [1, 2, 3];\n * console.log(jsonEquals(list3, list4)); // true - same order\n * ```\n *\n * @see {@link Diff.jsonDiff} for detailed change analysis when equality fails\n * @see {@link jsonThreeWayDiff} for actionable difference results\n *\n * @public\n */\nexport function jsonEquals(obj1: JsonValue, obj2: JsonValue): boolean {\n return deepEquals(obj1, obj2);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/diff/index.ts"],"names":[],"mappings":"AAsBA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/diff/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,iDAA+B;AAC/B,iDAA+B","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './detailedDiff';\nexport * from './threeWayDiff';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"threeWayDiff.d.ts","sourceRoot":"","sources":["../../../src/packlets/diff/threeWayDiff.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAW,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,SAAS,EAAgB,MAAM,mBAAmB,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;OAUG;IACH,OAAO,EAAE,SAAS,CAAC;IAEnB;;;;;;;;;;OAUG;IACH,SAAS,EAAE,SAAS,CAAC;IAErB;;;;;;;;;;OAUG;IACH,OAAO,EAAE,SAAS,CAAC;IAEnB;;;;;OAKG;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\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, succeed } from '@fgv/ts-utils';\nimport { JsonValue, isJsonObject } from '@fgv/ts-json-base';\nimport { deepEquals } from './utils';\n\n/**\n * Metadata about the differences found in a three-way diff.\n *\n * Provides summary statistics about the types and quantities of changes\n * detected between two JSON values, making it easy to understand the\n * overall scope of differences at a glance.\n *\n * @example\n * ```typescript\n * const metadata: IThreeWayDiffMetadata = {\n * removed: 2, // 2 properties only in first object\n * added: 1, // 1 property only in second object\n * modified: 3, // 3 properties changed between objects\n * unchanged: 5 // 5 properties identical in both objects\n * };\n *\n * console.log(`Total changes: ${metadata.added + metadata.removed + metadata.modified}`);\n * console.log(`Stability: ${metadata.unchanged / (metadata.unchanged + metadata.modified) * 100}%`);\n * ```\n *\n * @public\n */\nexport interface IThreeWayDiffMetadata {\n /**\n * Number of properties that exist only in the first object.\n *\n * These represent data that was removed when transitioning from\n * the first object to the second object.\n */\n removed: number;\n\n /**\n * Number of properties that exist only in the second object.\n *\n * These represent new data that was added when transitioning from\n * the first object to the second object.\n */\n added: number;\n\n /**\n * Number of properties that exist in both objects but have different values.\n *\n * These represent data that was modified during the transition between objects.\n * For arrays, this counts entire array replacements as single modifications.\n */\n modified: number;\n\n /**\n * Number of properties that exist in both objects with identical values.\n *\n * These represent stable data that remained consistent between the two objects.\n */\n unchanged: number;\n}\n\n/**\n * Result of a three-way JSON diff operation.\n *\n * This interface provides an actionable representation of differences between\n * two JSON values by separating them into three distinct objects. This approach\n * makes it easy to apply changes, display side-by-side comparisons, perform\n * merges, or programmatically work with the differences.\n *\n * **Key Benefits:**\n * - **Actionable Results**: Objects can be directly used for merging or applying changes\n * - **UI-Friendly**: Perfect for side-by-side diff displays with clear visual separation\n * - **Merge-Ready**: Simplified three-way merge operations\n * - **Structured Data**: Maintains original JSON structure rather than flattened paths\n *\n * @example Basic usage\n * ```typescript\n * const result: IThreeWayDiff = {\n * onlyInA: { name: \"John\", city: \"NYC\" }, // Original or removed data\n * unchanged: { age: 30 }, // Stable data\n * onlyInB: { name: \"Jane\", country: \"USA\" }, // New or modified data\n * metadata: { added: 1, removed: 1, modified: 1, unchanged: 1 },\n * identical: false\n * };\n *\n * // Apply changes: merge unchanged + onlyInB\n * const updated = { ...result.unchanged, ...result.onlyInB };\n * // Result: { age: 30, name: \"Jane\", country: \"USA\" }\n *\n * // Revert changes: merge unchanged + onlyInA\n * const reverted = { ...result.unchanged, ...result.onlyInA };\n * // Result: { age: 30, name: \"John\", city: \"NYC\" }\n * ```\n *\n * @see {@link IThreeWayDiffMetadata} for metadata structure details\n * @see {@link jsonThreeWayDiff} for the function that produces this result\n * @see {@link Diff.jsonDiff} for an alternative detailed change-list approach\n *\n * @public\n */\nexport interface IThreeWayDiff {\n /**\n * Contains properties that exist only in the first object, plus the first object's\n * version of any properties that exist in both but have different values.\n *\n * This object represents the \"old\" or \"source\" state and can be used for:\n * - Reverting changes by merging with `unchanged`\n * - Displaying what was removed or changed from the original\n * - Understanding the baseline state before modifications\n *\n * Will be `null` if no properties are unique to the first object.\n */\n onlyInA: JsonValue;\n\n /**\n * Contains properties that exist in both objects with identical values.\n *\n * This object represents the stable, consistent data between both inputs\n * and can be used for:\n * - The foundation for merging operations\n * - Identifying what remained constant during changes\n * - Building complete objects by combining with other parts\n *\n * Will be `null` if no properties are shared between the objects.\n */\n unchanged: JsonValue;\n\n /**\n * Contains properties that exist only in the second object, plus the second object's\n * version of any properties that exist in both but have different values.\n *\n * This object represents the \"new\" or \"target\" state and can be used for:\n * - Applying changes by merging with `unchanged`\n * - Displaying what was added or changed in the update\n * - Understanding the desired end state after modifications\n *\n * Will be `null` if no properties are unique to the second object.\n */\n onlyInB: JsonValue;\n\n /**\n * Summary metadata about the differences found.\n *\n * Provides counts of added, removed, modified, and unchanged properties\n * for quick assessment of the scope and nature of changes.\n */\n metadata: IThreeWayDiffMetadata;\n\n /**\n * True if the objects are identical, false otherwise.\n *\n * When `true`, both `onlyInA` and `onlyInB` will be `null`, and `unchanged`\n * will contain the complete shared structure. The metadata will show zero\n * added, removed, and modified properties.\n */\n identical: boolean;\n}\n\n/**\n * Internal function to build three-way diff for objects.\n */\nfunction buildThreeWayDiffForObjects(\n obj1: JsonValue,\n obj2: JsonValue,\n metadata: IThreeWayDiffMetadata\n): { onlyInA: JsonValue; unchanged: JsonValue; onlyInB: JsonValue } {\n if (!isJsonObject(obj1) || !isJsonObject(obj2)) {\n // Handle non-object cases\n if (deepEquals(obj1, obj2)) {\n metadata.unchanged++;\n return {\n onlyInA: null,\n unchanged: obj1,\n onlyInB: null\n };\n } else {\n metadata.modified++;\n return {\n onlyInA: obj1,\n unchanged: null,\n onlyInB: obj2\n };\n }\n }\n\n const keys1 = new Set(Object.keys(obj1));\n const keys2 = new Set(Object.keys(obj2));\n const allKeys = new Set([...keys1, ...keys2]);\n\n const onlyInA: Record<string, JsonValue> = {};\n const unchanged: Record<string, JsonValue> = {};\n const onlyInB: Record<string, JsonValue> = {};\n\n let hasOnlyInA = false;\n let hasUnchanged = false;\n let hasOnlyInB = false;\n\n for (const key of allKeys) {\n if (!keys1.has(key)) {\n // Property only exists in obj2\n metadata.added++;\n onlyInB[key] = obj2[key];\n hasOnlyInB = true;\n } else if (!keys2.has(key)) {\n // Property only exists in obj1\n metadata.removed++;\n onlyInA[key] = obj1[key];\n hasOnlyInA = true;\n } else {\n // Property exists in both\n const val1 = obj1[key];\n const val2 = obj2[key];\n\n if (deepEquals(val1, val2)) {\n // Values are identical\n if (isJsonObject(val1) && isJsonObject(val2)) {\n // For objects, we need to recurse to get proper metadata counts\n const childDiff = buildThreeWayDiffForObjects(val1, val2, metadata);\n if (childDiff.unchanged !== null) {\n unchanged[key] = childDiff.unchanged;\n hasUnchanged = true;\n }\n } else {\n metadata.unchanged++;\n unchanged[key] = val1;\n hasUnchanged = true;\n }\n } else {\n // Values are different\n if (isJsonObject(val1) && isJsonObject(val2)) {\n // For nested objects, recurse\n const childDiff = buildThreeWayDiffForObjects(val1, val2, metadata);\n\n if (childDiff.onlyInA !== null) {\n onlyInA[key] = childDiff.onlyInA;\n hasOnlyInA = true;\n }\n if (childDiff.unchanged !== null) {\n unchanged[key] = childDiff.unchanged;\n hasUnchanged = true;\n }\n if (childDiff.onlyInB !== null) {\n onlyInB[key] = childDiff.onlyInB;\n hasOnlyInB = true;\n }\n } else {\n // For primitives or arrays, treat as complete replacement\n metadata.modified++;\n onlyInA[key] = val1;\n onlyInB[key] = val2;\n hasOnlyInA = true;\n hasOnlyInB = true;\n }\n }\n }\n }\n\n return {\n onlyInA: hasOnlyInA ? onlyInA : null,\n unchanged: hasUnchanged ? unchanged : null,\n onlyInB: hasOnlyInB ? onlyInB : null\n };\n}\n\n/**\n * Performs a three-way diff comparison between two JSON values, returning separate\n * objects containing the differences and similarities.\n *\n * This function provides an alternative to {@link Diff.jsonDiff} that focuses on actionable\n * results rather than detailed change analysis. Instead of a list of individual changes,\n * it returns three objects that can be directly used for merging, UI display, or\n * programmatic manipulation.\n *\n * **Key Features:**\n * - **Actionable Results**: Returns objects ready for immediate use in merging operations\n * - **Simplified Array Handling**: Arrays are treated as atomic values for cleaner results\n * - **Structural Preservation**: Maintains original JSON structure rather than flattened paths\n * - **UI-Optimized**: Perfect for side-by-side diff displays and change visualization\n * - **Merge-Friendly**: Designed specifically for three-way merge scenarios\n *\n * **Array Handling:**\n * Unlike {@link Diff.jsonDiff}, this function treats arrays as complete units. If arrays differ,\n * the entire array appears in the appropriate result object rather than computing\n * element-by-element deltas. This approach is simpler and more predictable for most\n * use cases involving data updates and synchronization.\n *\n * **Use Cases:**\n * - Applying configuration updates while preserving unchanged settings\n * - Creating side-by-side diff displays in user interfaces\n * - Building three-way merge tools for data synchronization\n * - Implementing undo/redo functionality with granular control\n * - Generating patch objects for API updates\n *\n * @param obj1 - The first JSON value to compare (often the \"before\" or \"source\" state)\n * @param obj2 - The second JSON value to compare (often the \"after\" or \"target\" state)\n * @returns A Result containing the three-way diff with separate objects and metadata\n *\n * @example Basic usage for applying changes\n * ```typescript\n * const original = { name: \"John\", age: 30, city: \"NYC\", active: true };\n * const updated = { name: \"Jane\", age: 30, country: \"USA\", active: true };\n *\n * const result = jsonThreeWayDiff(original, updated);\n * if (result.success) {\n * const { onlyInA, unchanged, onlyInB } = result.value;\n *\n * // Apply changes: merge unchanged + onlyInB\n * const applied = { ...unchanged, ...onlyInB };\n * console.log(applied); // { age: 30, active: true, name: \"Jane\", country: \"USA\" }\n *\n * // Revert changes: merge unchanged + onlyInA\n * const reverted = { ...unchanged, ...onlyInA };\n * console.log(reverted); // { age: 30, active: true, name: \"John\", city: \"NYC\" }\n * }\n * ```\n *\n * @example UI-friendly diff display\n * ```typescript\n * const result = jsonThreeWayDiff(userBefore, userAfter);\n * if (result.success) {\n * const { onlyInA, unchanged, onlyInB, metadata } = result.value;\n *\n * // Display summary\n * console.log(`Changes: ${metadata.added} added, ${metadata.removed} removed, ${metadata.modified} modified`);\n *\n * // Show removed/old values in red\n * if (onlyInA) displayInColor(onlyInA, 'red');\n *\n * // Show unchanged values in gray\n * if (unchanged) displayInColor(unchanged, 'gray');\n *\n * // Show added/new values in green\n * if (onlyInB) displayInColor(onlyInB, 'green');\n * }\n * ```\n *\n * @example Nested objects and array handling\n * ```typescript\n * const config1 = {\n * database: { host: \"localhost\", port: 5432 },\n * features: [\"auth\", \"logging\"],\n * version: \"1.0\"\n * };\n * const config2 = {\n * database: { host: \"production.db\", port: 5432 },\n * features: [\"auth\", \"logging\", \"metrics\"], // Array treated as complete unit\n * version: \"1.1\"\n * };\n *\n * const result = jsonThreeWayDiff(config1, config2);\n * if (result.success) {\n * // result.value.onlyInA = { database: { host: \"localhost\" }, features: [\"auth\", \"logging\"], version: \"1.0\" }\n * // result.value.unchanged = { database: { port: 5432 } }\n * // result.value.onlyInB = { database: { host: \"production.db\" }, features: [\"auth\", \"logging\", \"metrics\"], version: \"1.1\" }\n * }\n * ```\n *\n * @example Conditional updates based on changes\n * ```typescript\n * const result = jsonThreeWayDiff(currentState, newState);\n * if (result.success && !result.value.identical) {\n * const { metadata } = result.value;\n *\n * if (metadata.modified > 0) {\n * console.log(\"Critical settings changed - requires restart\");\n * } else if (metadata.added > 0) {\n * console.log(\"New features enabled\");\n * } else if (metadata.removed > 0) {\n * console.log(\"Features disabled\");\n * }\n * }\n * ```\n *\n * @see {@link IThreeWayDiff} for the structure of returned results\n * @see {@link IThreeWayDiffMetadata} for metadata details\n * @see {@link Diff.jsonDiff} for detailed change-by-change analysis\n * @see {@link jsonEquals} for simple equality checking\n *\n * @public\n */\nexport function jsonThreeWayDiff(obj1: JsonValue, obj2: JsonValue): Result<IThreeWayDiff> {\n const metadata: IThreeWayDiffMetadata = {\n removed: 0,\n added: 0,\n modified: 0,\n unchanged: 0\n };\n\n const diff = buildThreeWayDiffForObjects(obj1, obj2, metadata);\n\n const result: IThreeWayDiff = {\n onlyInA: diff.onlyInA,\n unchanged: diff.unchanged,\n onlyInB: diff.onlyInB,\n metadata,\n identical: metadata.removed === 0 && metadata.added === 0 && metadata.modified === 0\n };\n\n return succeed(result);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/packlets/diff/utils.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,SAAS,EAA8C,MAAM,mBAAmB,CAAC;AAE1F;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,OAAO,CAsC9D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/packlets/diff/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAOH,gCAsCC;AA3CD,oDAA0F;AAE1F;;GAEG;AACH,SAAgB,UAAU,CAAC,CAAY,EAAE,CAAY;IACnD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,IAAA,8BAAe,EAAC,CAAC,CAAC,IAAI,IAAA,8BAAe,EAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,IAAI,IAAA,0BAAW,EAAC,CAAC,CAAC,IAAI,IAAA,0BAAW,EAAC,CAAC,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5B,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,IAAA,2BAAY,EAAC,CAAC,CAAC,IAAI,IAAA,2BAAY,EAAC,CAAC,CAAC,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAE7B,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC/C,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonValue, isJsonObject, isJsonArray, isJsonPrimitive } from '@fgv/ts-json-base';\n\n/**\n * Deep comparison function for JSON values that handles all JSON types.\n */\nexport function deepEquals(a: JsonValue, b: JsonValue): boolean {\n if (a === b) {\n return true;\n }\n\n if (isJsonPrimitive(a) || isJsonPrimitive(b)) {\n return a === b;\n }\n\n if (isJsonArray(a) && isJsonArray(b)) {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (!deepEquals(a[i], b[i])) {\n return false;\n }\n }\n return true;\n }\n\n if (isJsonObject(a) && isJsonObject(b)) {\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n for (const key of keysA) {\n if (!(key in b) || !deepEquals(a[key], b[key])) {\n return false;\n }\n }\n return true;\n }\n\n return false;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/packlets/editor/common.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,cAAc,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEnF;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,GAAG,UAAU,CAAC;AAE/E;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GACjC,qBAAqB,GACrB,sBAAsB,GACtB,wBAAwB,CAAC;AAE7B;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,kBAAkB,EAAE,kBAAkB,CAAC;IAEvC;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;;OAKG;IACH,qBAAqB,EAAE,OAAO,GAAG,QAAQ,CAAC;IAE1C;;;;;OAKG;IACH,sBAAsB,EAAE,OAAO,GAAG,QAAQ,CAAC;IAE3C;;;;;OAKG;IACH,wBAAwB,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,UAAU,EAAE,4BAA4B,CAAC;IACzC,KAAK,CAAC,EAAE,uBAAuB,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,cAAc,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;CACjG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/packlets/editor/common.ts"],"names":[],"mappings":"","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nimport { JsonValue } from '@fgv/ts-json-base';\nimport { DetailedResult } from '@fgv/ts-utils';\nimport { IJsonContext } from '../context';\n\n/**\n * Possible `DetailedResult` details for various editor operations.\n * @public\n */\nexport type JsonEditFailureReason = 'ignore' | 'inapplicable' | 'edited' | 'error';\n\n/**\n * Possible `DetailedResult` details for property edit operations.\n * @public\n */\nexport type JsonPropertyEditFailureReason = JsonEditFailureReason | 'deferred';\n\n/**\n * Possible validation rules for a {@link JsonEditor | JsonEditor}.\n * @public\n */\nexport type JsonEditorValidationRules =\n | 'invalidPropertyName'\n | 'invalidPropertyValue'\n | 'undefinedPropertyValue';\n\n/**\n * Array merge behavior options for a {@link JsonEditor | JsonEditor}.\n * @public\n */\nexport type ArrayMergeBehavior = 'append' | 'replace';\n\n/**\n * Merge options for a {@link JsonEditor | JsonEditor}.\n * @public\n */\nexport interface IJsonEditorMergeOptions {\n /**\n * Controls how arrays are merged when combining JSON values.\n * - `'append'` (default): Existing array elements are preserved and new elements are appended\n * - `'replace'`: Existing array is completely replaced with the new array\n */\n arrayMergeBehavior: ArrayMergeBehavior;\n\n /**\n * Controls whether null values should be treated as property deletion during merge operations.\n * - `false` (default): Null values are merged normally, setting the property to null\n * - `true`: Null values delete the property from the target object during merge\n */\n nullAsDelete?: boolean;\n}\n\n/**\n * Validation options for a {@link JsonEditor | JsonEditor}.\n * @public\n */\nexport interface IJsonEditorValidationOptions {\n /**\n * If `onInvalidPropertyName` is `'error'` (default) then any property name\n * that is invalid after template rendering causes an error and stops\n * conversion. If `onInvalidPropertyName` is `'ignore'`, then names which\n * are invalid after template rendering are passed through unchanged.\n */\n onInvalidPropertyName: 'error' | 'ignore';\n\n /**\n * If `onInvalidPropertyValue` is `'error'` (default) then any illegal\n * property value other than `undefined` causes an error and stops\n * conversion. If `onInvalidPropertyValue` is `'ignore'` then any\n * invalid property values are silently ignored.\n */\n onInvalidPropertyValue: 'error' | 'ignore';\n\n /**\n * If `onUndefinedPropertyValue` is `'error'`, then any property with\n * value `undefined` will cause an error and stop conversion. If\n * `onUndefinedPropertyValue` is `'ignore'` (default) then any\n * property with value `undefined` is silently ignored.\n */\n onUndefinedPropertyValue: 'error' | 'ignore';\n}\n\n/**\n * Initialization options for a {@link JsonEditor | JsonEditor}.\n * @public\n */\nexport interface IJsonEditorOptions {\n context?: IJsonContext;\n validation: IJsonEditorValidationOptions;\n merge?: IJsonEditorMergeOptions;\n}\n\n/**\n * A specialized JSON editor which does a deep clone of a supplied `JsonValue`.\n * @public\n */\nexport interface IJsonCloneEditor {\n /**\n * Returns a deep clone of a supplied `JsonValue`.\n * @param src - The `JsonValue` to be cloned.\n * @param context - An optional {@link IJsonContext | JSON context} used for clone\n * conversion operations.\n */\n clone(src: JsonValue, context?: IJsonContext): DetailedResult<JsonValue, JsonEditFailureReason>;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/editor/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,WAAW,MAAM,SAAS,CAAC;AAEvC,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,qCAAqC,EACrC,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,aAAa,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/editor/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qDAAuC;AAa9B,kCAAW;AAXpB,2CAAyB;AACzB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mDAAuE;AAA7C,oHAAA,kBAAkB,OAAA;AAC5C,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,uDAM4B;AAH1B,mHAAA,eAAe,OAAA;AACf,yHAAA,qBAAqB,OAAA;AACrB,iHAAA,aAAa,OAAA","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as EditorRules from './rules';\n\nexport * from './common';\nexport { JsonEditor } from './jsonEditor';\nexport { IJsonEditorRule, JsonEditorRuleBase } from './jsonEditorRule';\nexport { JsonEditorState } from './jsonEditorState';\nexport {\n IReferenceMapKeyPolicyValidateOptions,\n ISimpleJsonMapOptions,\n PrefixedJsonMap,\n ReferenceMapKeyPolicy,\n SimpleJsonMap\n} from './jsonReferenceMap';\nexport { EditorRules };\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonEditor.d.ts","sourceRoot":"","sources":["../../../src/packlets/editor/jsonEditor.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,cAAc,EACd,MAAM,EAQP,MAAM,eAAe,CAAC;AAQvB,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EAIV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EACL,gBAAgB,EAEhB,kBAAkB,EAElB,qBAAqB,EACrB,6BAA6B,EAC9B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;GAKG;AACH,qBAAa,UAAW,YAAW,gBAAgB;IACjD;;;OAGG;IACH,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IAEvC;;OAEG;IACI,OAAO,EAAE,kBAAkB,CAAC;IAEnC;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC;IAEpC;;;;;;;OAOG;IACH,SAAS,aAAa,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,KAAK,CAAC,EAAE,eAAe,EAAE;IAKtF;;;OAGG;IACH,WAAkB,OAAO,IAAI,UAAU,CAMtC;IAED;;;;;;OAMG;WACW,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAAE,KAAK,CAAC,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC;IAI1G;;;;;;;;OAQG;WACW,eAAe,CAAC,OA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B,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;gBAC5D,IAAI,UAAU,CAAC,SAAS,EAAE,EAAE,CAAC;oBAC3B,OAAO,IAAI,CAAC,8BAA8B,CACxC,KAAK,CAAC,OAAO,EACb,MAAM,EACN,UAAU,CAAC,KAAK,CACjB,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;gBAC/B,CAAC;qBAAM,IAAI,UAAU,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;oBAC1C,IAAA,4BAAiB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;gBACtC,CAAC;qBAAM,IAAI,UAAU,CAAC,MAAM,KAAK,cAAc,EAAE,CAAC;oBAChD,OAAO,IAAA,yBAAc,EAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;gBAC/D,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAA,4BAAiB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;CACF;AAvcD,gCAucC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport {\n DetailedResult,\n Result,\n captureResult,\n fail,\n failWithDetail,\n mapDetailedResults,\n mapResults,\n succeed,\n succeedWithDetail\n} from '@fgv/ts-utils';\nimport {\n ConditionalJsonEditorRule,\n MultiValueJsonEditorRule,\n ReferenceJsonEditorRule,\n TemplatedJsonEditorRule\n} from './rules';\n\nimport {\n JsonArray,\n JsonObject,\n JsonValue,\n isJsonArray,\n isJsonObject,\n isJsonPrimitive\n} from '@fgv/ts-json-base';\nimport { IJsonContext } from '../context';\nimport {\n IJsonCloneEditor,\n IJsonEditorMergeOptions,\n IJsonEditorOptions,\n IJsonEditorValidationOptions,\n JsonEditFailureReason,\n JsonPropertyEditFailureReason\n} from './common';\n\nimport { IJsonEditorRule } from './jsonEditorRule';\nimport { JsonEditorState } from './jsonEditorState';\n\n/**\n * A {@link JsonEditor | JsonEditor} can be used to edit JSON objects in place or to\n * clone any JSON value, applying a default context and optional set of editor rules that\n * were supplied at initialization.\n * @public\n */\nexport class JsonEditor implements IJsonCloneEditor {\n /**\n * Default singleton {@link JsonEditor | JsonEditor}.\n * @internal\n */\n protected static _default?: JsonEditor;\n\n /**\n * Full set of {@link IJsonEditorOptions | editor options} in effect for this editor.\n */\n public options: IJsonEditorOptions;\n\n /**\n * The set of {@link IJsonEditorRule | editor rules} applied by this editor.\n * @internal\n */\n protected _rules: IJsonEditorRule[];\n\n /**\n * Protected constructor for {@link JsonEditor | JsonEditor} and derived classes.\n * External consumers should instantiate via the {@link JsonEditor.create | create static method}.\n * @param options - Optional partial {@link IJsonEditorOptions | editor options} for the\n * constructed editor.\n * @param rules - Any {@link IJsonEditorRule | editor rules} to be applied by the editor.\n * @internal\n */\n protected constructor(options?: Partial<IJsonEditorOptions>, rules?: IJsonEditorRule[]) {\n this.options = JsonEditor._getDefaultOptions(options).orThrow();\n this._rules = rules || JsonEditor.getDefaultRules(this.options).orThrow();\n }\n\n /**\n * Default singleton {@link JsonEditor | JsonEditor} for simple use. Applies all rules\n * but with no default context.\n */\n public static get default(): JsonEditor {\n if (!JsonEditor._default) {\n const rules = this.getDefaultRules().orDefault();\n JsonEditor._default = new JsonEditor(undefined, rules);\n }\n return JsonEditor._default;\n }\n\n /**\n * Constructs a new {@link JsonEditor | JsonEditor}.\n * @param options - Optional partial {@link IJsonEditorOptions | editor options} for the\n * constructed editor.\n * @param rules - Optional set of {@link IJsonEditorRule | editor rules} to be applied by the editor.\n * @readonly A new {@link JsonEditor | JsonEditor}.\n */\n public static create(options?: Partial<IJsonEditorOptions>, rules?: IJsonEditorRule[]): Result<JsonEditor> {\n return captureResult(() => new JsonEditor(options, rules));\n }\n\n /**\n * Gets the default set of rules to be applied for a given set of options.\n * By default, all available rules (templates, conditionals, multi-value and references)\n * are applied.\n * @param options - Optional partial {@link IJsonEditorOptions | editor options} for\n * all rules.\n * @returns Default {@link IJsonEditorRule | editor rules} with any supplied options\n * applied.\n */\n public static getDefaultRules(options?: IJsonEditorOptions): Result<IJsonEditorRule[]> {\n return mapResults<IJsonEditorRule>([\n TemplatedJsonEditorRule.create(options),\n ConditionalJsonEditorRule.create(options),\n MultiValueJsonEditorRule.create(options),\n ReferenceJsonEditorRule.create(options)\n ]);\n }\n\n /**\n * Creates a complete IJsonEditorOptions object from partial options, filling in\n * default values for any missing properties. This ensures all editor instances\n * have consistent, complete configuration including validation rules and merge behavior.\n * @param options - Optional partial editor options to merge with defaults\n * @returns Success with complete editor options, or Failure if validation fails\n * @internal\n */\n protected static _getDefaultOptions(options?: Partial<IJsonEditorOptions>): Result<IJsonEditorOptions> {\n const context: IJsonContext | undefined = options?.context;\n let validation: IJsonEditorValidationOptions | undefined = options?.validation;\n if (validation === undefined) {\n validation = {\n onInvalidPropertyName: 'error',\n onInvalidPropertyValue: 'error',\n onUndefinedPropertyValue: 'ignore'\n };\n }\n let merge: IJsonEditorMergeOptions | undefined = options?.merge;\n if (merge === undefined) {\n merge = {\n arrayMergeBehavior: 'append',\n nullAsDelete: false\n };\n } else {\n merge = {\n arrayMergeBehavior: merge.arrayMergeBehavior,\n nullAsDelete: merge.nullAsDelete ?? false\n };\n }\n return succeed({ context, validation, merge });\n }\n\n /**\n * Merges a supplied source object into a supplied target, updating the target object.\n * @param target - The target `JsonObject` to be updated\n * @param src - The source `JsonObject` to be merged\n * @param runtimeContext - An optional {@link IJsonContext | IJsonContext} supplying variables\n * and references.\n * @returns `Success` with the original source `JsonObject` if merge was successful.\n * Returns `Failure` with details if an error occurs.\n */\n public mergeObjectInPlace(\n target: JsonObject,\n src: JsonObject,\n runtimeContext?: IJsonContext\n ): Result<JsonObject> {\n const state = new JsonEditorState(this, this.options, runtimeContext);\n return this._mergeObjectInPlace(target, src, state).onSuccess((merged) => {\n return this._finalizeAndMerge(merged, state);\n });\n }\n\n /**\n * Merges multiple supplied source objects into a supplied target, updating the target\n * object and using the default context supplied at creation time.\n * @param target - The target `JsonObject` to be updated\n * @param srcObjects - `JsonObject`s to be merged into the target object, in the order\n * supplied.\n * @returns `Success` with the original source `JsonObject` if merge was successful.\n * Returns `Failure` with details if an error occurs.\n */\n public mergeObjectsInPlace(target: JsonObject, srcObjects: JsonObject[]): Result<JsonObject> {\n return this.mergeObjectsInPlaceWithContext(this.options.context, target, srcObjects);\n }\n\n /**\n * Merges multiple supplied source objects into a supplied target, updating the target\n * object and using an optional {@link IJsonContext | context} supplied in the call.\n * @param context - An optional {@link IJsonContext | IJsonContext} supplying variables and\n * references.\n * @param base - The base `JsonObject` to be updated\n * @param srcObjects - Objects to be merged into the target object, in the order supplied.\n * @returns `Success` with the original source `JsonObject` if merge was successful.\n * Returns `Failure` with details if an error occurs.\n */\n public mergeObjectsInPlaceWithContext(\n context: IJsonContext | undefined,\n base: JsonObject,\n srcObjects: JsonObject[]\n ): Result<JsonObject> {\n for (const src of srcObjects) {\n const mergeResult = this.mergeObjectInPlace(base, src, context);\n if (mergeResult.isFailure()) {\n return mergeResult.withFailureDetail('error');\n }\n }\n return succeedWithDetail(base);\n }\n\n /**\n * Deep clones a supplied `JsonValue`, applying all editor rules and a default\n * or optionally supplied context\n * @param src - The `JsonValue` to be cloned.\n * @param context - An optional {@link IJsonContext | JSON context} supplying variables and references.\n */\n public clone(src: JsonValue, context?: IJsonContext): DetailedResult<JsonValue, JsonEditFailureReason> {\n const state = new JsonEditorState(this, this.options, context);\n let value = src;\n let valueResult = this._editValue(src, state);\n\n while (valueResult.isSuccess()) {\n value = valueResult.value;\n valueResult = this._editValue(value, state);\n }\n\n if (valueResult.detail === 'error' || valueResult.detail === 'ignore') {\n return valueResult;\n }\n\n if (isJsonPrimitive(value) || value === null) {\n return succeedWithDetail(value, 'edited');\n } else if (isJsonObject(value)) {\n return this._cloneObjectWithoutNullAsDelete({}, value, state);\n } else if (isJsonArray(value)) {\n return this._cloneArray(value, state.context);\n } else if (value === undefined) {\n return state.failValidation('undefinedPropertyValue');\n }\n return state.failValidation(\n 'invalidPropertyValue',\n `Cannot convert invalid JSON: \"${JSON.stringify(value)}\"`\n );\n }\n\n /**\n * Merges properties from a source object into a target object, applying editor rules and\n * null-as-delete logic. This is the core merge implementation that handles property-by-property\n * merging with rule processing and deferred property handling.\n * @param target - The target object to merge properties into\n * @param src - The source object containing properties to merge\n * @param state - The editor state containing options and context\n * @returns Success with the modified target object, or Failure with error details\n * @internal\n */\n protected _mergeObjectInPlace(\n target: JsonObject,\n src: JsonObject,\n state: JsonEditorState\n ): Result<JsonObject> {\n for (const key in src) {\n if (src.hasOwnProperty(key)) {\n // Skip dangerous property names to prevent prototype pollution\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n continue;\n }\n const propResult = this._editProperty(key, src[key], state);\n if (propResult.isSuccess()) {\n if (propResult.detail === 'deferred') {\n state.defer(propResult.value);\n } else {\n const mergeResult = this._mergeObjectInPlace(target, propResult.value, state);\n if (mergeResult.isFailure()) {\n return mergeResult;\n }\n }\n } else if (propResult.detail === 'inapplicable') {\n const valueResult = this.clone(src[key], state.context).onSuccess((cloned) => {\n return this._mergeClonedProperty(target, key, cloned, state);\n });\n\n if (valueResult.isFailure() && valueResult.detail === 'error') {\n return fail(`${key}: ${valueResult.message}`);\n }\n } else if (propResult.detail !== 'ignore') {\n return fail(`${key}: ${propResult.message}`);\n }\n } else {\n return fail(`${key}: Cannot merge inherited properties`);\n }\n }\n return succeed(target);\n }\n\n /**\n * Creates a deep clone of a JSON array by recursively cloning each element.\n * Each array element is cloned using the main clone method, preserving the\n * editor's rules and validation settings.\n * @param src - The source JSON array to clone\n * @param context - Optional JSON context for cloning operations\n * @returns Success with the cloned array, or Failure with error details\n * @internal\n */\n protected _cloneArray(\n src: JsonArray,\n context?: IJsonContext\n ): DetailedResult<JsonArray, JsonEditFailureReason> {\n const results = src.map((v) => {\n return this.clone(v, context);\n });\n\n return mapDetailedResults<JsonValue, JsonEditFailureReason>(results, ['ignore'])\n .onSuccess((converted) => {\n return succeed(converted);\n })\n .withFailureDetail('error');\n }\n\n /**\n * Merges a single cloned property value into a target object. This method handles\n * the core merge logic including null-as-delete behavior, array merging, and\n * recursive object merging. The null-as-delete check occurs before primitive\n * handling to ensure null values can signal property deletion.\n * @param target - The target object to merge the property into\n * @param key - The property key being merged\n * @param newValue - The cloned value to merge (from source object)\n * @param state - The editor state containing merge options and context\n * @returns Success with the merged value, or Failure with error details\n * @internal\n */\n protected _mergeClonedProperty(\n target: JsonObject,\n key: string,\n newValue: JsonValue,\n state: JsonEditorState\n ): DetailedResult<JsonValue, JsonEditFailureReason> {\n // Skip dangerous property names to prevent prototype pollution\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n return succeedWithDetail(newValue, 'edited');\n }\n\n const existing = target[key];\n\n // Handle null-as-delete behavior before primitive check\n /* c8 ignore next 1 - ? is defense in depth */\n if (newValue === null && state.options.merge?.nullAsDelete === true) {\n delete target[key];\n return succeedWithDetail(null, 'edited');\n }\n\n // merge is called right after clone so this should never happen\n // since clone itself will have failed\n\n if (isJsonPrimitive(newValue)) {\n target[key] = newValue;\n return succeedWithDetail(newValue, 'edited');\n }\n\n if (isJsonObject(newValue)) {\n if (isJsonObject(existing)) {\n return this.mergeObjectInPlace(existing, newValue, state.context).withFailureDetail('error');\n }\n target[key] = newValue;\n return succeedWithDetail(newValue, 'edited');\n }\n\n /* c8 ignore else */\n if (isJsonArray(newValue)) {\n if (isJsonArray(existing)) {\n /* c8 ignore next 1 - ?? is defense in depth */\n const arrayMergeBehavior = state.options.merge?.arrayMergeBehavior ?? 'append';\n switch (arrayMergeBehavior) {\n case 'append':\n target[key] = existing.concat(...newValue);\n break;\n case 'replace':\n target[key] = newValue;\n break;\n /* c8 ignore next 2 - exhaustive switch for ArrayMergeBehavior type */\n default:\n return failWithDetail(`Invalid array merge behavior: ${arrayMergeBehavior as string}`, 'error');\n }\n return succeedWithDetail(target[key], 'edited');\n }\n target[key] = newValue;\n return succeedWithDetail(newValue, 'edited');\n }\n /* c8 ignore start */\n return failWithDetail(`Invalid JSON: ${JSON.stringify(newValue)}`, 'error');\n } /* c8 ignore stop */\n\n /**\n * Applies editor rules to a single property during merge operations. This method\n * iterates through all configured editor rules to process the property, handling\n * templates, conditionals, multi-value properties, and references.\n * @param key - The property key to edit\n * @param value - The property value to edit\n * @param state - The editor state containing rules and context\n * @returns Success with transformed property object, or Failure if rules cannot process\n * @internal\n */\n protected _editProperty(\n key: string,\n value: JsonValue,\n state: JsonEditorState\n ): DetailedResult<JsonObject, JsonPropertyEditFailureReason> {\n for (const rule of this._rules) {\n const ruleResult = rule.editProperty(key, value, state);\n if (ruleResult.isSuccess() || ruleResult.detail !== 'inapplicable') {\n return ruleResult;\n }\n }\n return failWithDetail('inapplicable', 'inapplicable');\n }\n\n /**\n * Applies editor rules to a single JSON value during clone operations. This method\n * iterates through all configured editor rules to process the value, handling\n * templates, conditionals, multi-value expressions, and references.\n * @param value - The JSON value to edit and transform\n * @param state - The editor state containing rules and context\n * @returns Success with transformed value, or Failure if rules cannot process\n * @internal\n */\n protected _editValue(\n value: JsonValue,\n state: JsonEditorState\n ): DetailedResult<JsonValue, JsonEditFailureReason> {\n for (const rule of this._rules) {\n const ruleResult = rule.editValue(value, state);\n if (ruleResult.isSuccess() || ruleResult.detail !== 'inapplicable') {\n return ruleResult;\n }\n }\n return failWithDetail('inapplicable', 'inapplicable');\n }\n\n /**\n * Clone an object without applying null-as-delete behavior.\n * This preserves null values during cloning so they can be used for deletion signaling during merge.\n * @param target - The target object to clone into\n * @param src - The source object to clone\n * @param state - The editor state\n * @returns The cloned object\n * @internal\n */\n protected _cloneObjectWithoutNullAsDelete(\n target: JsonObject,\n src: JsonObject,\n state: JsonEditorState\n ): DetailedResult<JsonObject, JsonEditFailureReason> {\n // Temporarily disable null-as-delete during cloning\n const modifiedOptions: IJsonEditorOptions = {\n context: state.options.context,\n validation: state.options.validation,\n merge: {\n /* c8 ignore next 1 - ? is defense in depth */\n arrayMergeBehavior: state.options.merge?.arrayMergeBehavior ?? 'append',\n nullAsDelete: false\n }\n };\n const modifiedState = new JsonEditorState(state.editor, modifiedOptions, state.context);\n\n return this._mergeObjectInPlace(target, src, modifiedState)\n .onSuccess((merged) => {\n return this._finalizeAndMerge(merged, modifiedState);\n })\n .withFailureDetail('error');\n }\n\n /**\n * Finalizes the merge operation by processing any deferred properties and merging\n * them into the target object. Deferred properties are those that require special\n * processing after the initial merge phase, such as references that depend on\n * other properties being resolved first.\n * @param target - The target object that has been merged\n * @param state - The editor state containing deferred properties and rules\n * @returns Success with the finalized target object, or Failure with error details\n * @internal\n */\n protected _finalizeAndMerge(\n target: JsonObject,\n state: JsonEditorState\n ): DetailedResult<JsonObject, JsonEditFailureReason> {\n const deferred = state.deferred;\n if (deferred.length > 0) {\n for (const rule of this._rules) {\n const ruleResult = rule.finalizeProperties(deferred, state);\n if (ruleResult.isSuccess()) {\n return this.mergeObjectsInPlaceWithContext(\n state.context,\n target,\n ruleResult.value\n ).withFailureDetail('error');\n } else if (ruleResult.detail === 'ignore') {\n succeedWithDetail(target, 'edited');\n } else if (ruleResult.detail !== 'inapplicable') {\n return failWithDetail(ruleResult.message, ruleResult.detail);\n }\n }\n }\n return succeedWithDetail(target, 'edited');\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonEditorRule.d.ts","sourceRoot":"","sources":["../../../src/packlets/editor/jsonEditorRule.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAkB,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;;OAWG;IACH,YAAY,CACV,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,eAAe,GACrB,cAAc,CAAC,UAAU,EAAE,6BAA6B,CAAC,CAAC;IAE7D;;;;;;;OAOG;IACH,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,GAAG,cAAc,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;IAEtG;;;;;;;;;OASG;IACH,kBAAkB,CAChB,QAAQ,EAAE,UAAU,EAAE,EACtB,KAAK,EAAE,eAAe,GACrB,cAAc,CAAC,UAAU,EAAE,EAAE,qBAAqB,CAAC,CAAC;CACxD;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IACxD;;OAEG;IAEI,YAAY,CACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,eAAe,GACvB,cAAc,CAAC,UAAU,EAAE,6BAA6B,CAAC;IAK5D;;OAEG;IACI,SAAS,CACd,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,eAAe,GACvB,cAAc,CAAC,SAAS,EAAE,qBAAqB,CAAC;IAInD;;OAEG;IACI,kBAAkB,CACvB,UAAU,EAAE,UAAU,EAAE,EACxB,OAAO,EAAE,eAAe,GACvB,cAAc,CAAC,UAAU,EAAE,EAAE,qBAAqB,CAAC;CAGvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonEditorRule.js","sourceRoot":"","sources":["../../../src/packlets/editor/jsonEditorRule.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAGH,4CAA+D;AAuD/D;;;;GAIG;AACH,MAAa,kBAAkB;IAC7B;;OAEG;IACH,qBAAqB;IACd,YAAY,CACjB,KAAa,EACb,OAAkB,EAClB,OAAwB;QAExB,OAAO,IAAA,yBAAc,EAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IACxD,CAAC;IACD,oBAAoB;IAEpB;;OAEG;IACI,SAAS,CACd,OAAkB,EAClB,OAAwB;QAExB,OAAO,IAAA,yBAAc,EAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACI,kBAAkB,CACvB,UAAwB,EACxB,OAAwB;QAExB,OAAO,IAAA,yBAAc,EAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IACxD,CAAC;CACF;AAjCD,gDAiCC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonObject, JsonValue } from '@fgv/ts-json-base';\nimport { DetailedResult, failWithDetail } from '@fgv/ts-utils';\nimport { JsonEditFailureReason, JsonPropertyEditFailureReason } from './common';\n\nimport { JsonEditorState } from './jsonEditorState';\n\n/**\n * An {@link IJsonEditorRule | IJsonEditorRule} represents a single configurable\n * rule to be applied by a {@link JsonEditor | JsonEditor}.\n * @public\n */\nexport interface IJsonEditorRule {\n /**\n * Called by a {@link JsonEditor | JsonEditor} to possibly edit one of the properties being\n * merged into a target object.\n * @param key - The key of the property to be edited.\n * @param value - The `JsonValue` of the property to be edited.\n * @param state - {@link JsonEditorState | Editor state} which applies to the edit.\n * @returns If the property was edited, returns `Success` with a `JsonObject` containing\n * the edited results and with detail `'edited'`. If this property should be deferred for later consideration\n * or merge, `Success` with detail `'deferred'` and a `JsonObject` to be finalized. If\n * the rule does not affect this property, returns `Failure` with detail `'inapplicable'`. If an error occurred\n * while processing the error, returns `Failure` with detail `'error'`.\n */\n editProperty(\n key: string,\n value: JsonValue,\n state: JsonEditorState\n ): DetailedResult<JsonObject, JsonPropertyEditFailureReason>;\n\n /**\n * Called by a {@link JsonEditor | JsonEditor} to possibly edit a property value or array element.\n * @param value - The `JsonValue` of the property to be edited.\n * @param state - {@link JsonEditorState | Editor state} which applies to the edit.\n * @returns Returns `Success` with the `JsonValue` to be inserted, with detail `'edited'` if\n * the value was edited. Returns `Failure` with `'inapplicable'` if the rule does not affect this value.\n * Fails with detail `'ignore'` if the value is to be ignored, or with `'error'` if an error occurs.\n */\n editValue(value: JsonValue, state: JsonEditorState): DetailedResult<JsonValue, JsonEditFailureReason>;\n\n /**\n * Called for each rule after all properties have been merged. Any properties that were deferred\n * during the initial edit pass are supplied as input.\n * @param deferred - Any JSON objects that were deferred during the first edit pass.\n * @param state - {@link JsonEditorState | Editor state} which applies to the edit.\n * @returns On `Success` return, any returned objects are merged in order and finalization\n * is stopped. Finalization is also stopped on `Failure` with detail `'ignore'`. On `Failure`\n * with detail `'inapplicable'`, finalization continues with the next rule. Fails with an\n * error detail `'error'` and an informative message if an error occurs.\n */\n finalizeProperties(\n deferred: JsonObject[],\n state: JsonEditorState\n ): DetailedResult<JsonObject[], JsonEditFailureReason>;\n}\n\n/**\n * Default base implementation of {@link IJsonEditorRule | IJsonEditorRule} returns inapplicable for all operations so that\n * derived classes need only implement the operations they actually support.\n * @public\n */\nexport class JsonEditorRuleBase implements IJsonEditorRule {\n /**\n * {@inheritdoc IJsonEditorRule.editProperty}\n */\n /* c8 ignore start */\n public editProperty(\n __key: string,\n __value: JsonValue,\n __state: JsonEditorState\n ): DetailedResult<JsonObject, JsonPropertyEditFailureReason> {\n return failWithDetail('inapplicable', 'inapplicable');\n }\n /* c8 ignore stop */\n\n /**\n * {@inheritdoc IJsonEditorRule.editValue}\n */\n public editValue(\n __value: JsonValue,\n __state: JsonEditorState\n ): DetailedResult<JsonValue, JsonEditFailureReason> {\n return failWithDetail('inapplicable', 'inapplicable');\n }\n\n /**\n * {@inheritdoc IJsonEditorRule.finalizeProperties}\n */\n public finalizeProperties(\n __deferred: JsonObject[],\n __state: JsonEditorState\n ): DetailedResult<JsonObject[], JsonEditFailureReason> {\n return failWithDetail('inapplicable', 'inapplicable');\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonEditorState.d.ts","sourceRoot":"","sources":["../../../src/packlets/editor/jsonEditorState.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAA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AqC,EACrC,GAA2D;QAE3D,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC7C,OAAO,2BAAiB,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;;;OAQG;IACI,cAAc,CACnB,IAA+B,EAC/B,OAAgB,EAChB,UAAyC;QAEzC,IAAI,MAAM,GAAkC,OAAO,CAAC;QACpD,MAAM,SAAS,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxD,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,qBAAqB;gBACxB,MAAM,GAAG,SAAS,CAAC,qBAAqB,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC;gBACjF,MAAM;YACR,KAAK,sBAAsB;gBACzB,MAAM,GAAG,SAAS,CAAC,sBAAsB,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;gBAC5E,MAAM;YACR,KAAK,wBAAwB;gBAC3B,MAAM,GAAG,SAAS,CAAC,wBAAwB,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;gBAC7E,oBAAoB;gBACpB,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,kCAAkC,CAAC;gBACxD,MAAM;QACV,CAAC;QACD,oBAAoB;QACpB,OAAO,IAAA,yBAAc,EAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;;AAzLH,0CA0LC;AAzLC;;;;GAIG;AACc,uBAAO,GAAW,CAAC,AAAZ,CAAa","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonObject } from '@fgv/ts-json-base';\nimport { DetailedFailure, Result, failWithDetail, succeed } from '@fgv/ts-utils';\nimport { IJsonContext, IJsonReferenceMap, JsonContextHelper, TemplateVars, VariableValue } from '../context';\nimport {\n IJsonCloneEditor,\n IJsonEditorOptions,\n IJsonEditorValidationOptions,\n JsonEditFailureReason,\n JsonEditorValidationRules,\n JsonPropertyEditFailureReason\n} from './common';\n\n/**\n * Represents the internal state of a {@link JsonEditor | JsonEditor}.\n * @public\n */\nexport class JsonEditorState {\n /**\n * Static global counter used to assign each {@link JsonEditorState | JsonEditorState}\n * a unique identifier.\n * @internal\n */\n protected static _nextId: number = 0;\n\n /**\n * The {@link IJsonCloneEditor | editor} for which this state applies.\n */\n public readonly editor: IJsonCloneEditor;\n\n /**\n * Fully resolved {@link IJsonEditorOptions | editor options} that apply\n * to the operation for which this state applies.\n */\n public readonly options: IJsonEditorOptions;\n\n /**\n * Any deferred JSON objects to be merged during finalization.\n * @internal\n */\n protected readonly _deferred: JsonObject[] = [];\n\n /**\n * Unique global identifier for this {@link JsonEditorState | state object}.\n * @internal\n */\n protected readonly _id: number;\n\n /**\n * Constructs a new {@link JsonEditorState | JsonEditorState}.\n * @param editor - The {@link IJsonCloneEditor | editor} to which this state\n * applies.\n * @param baseOptions - The {@link IJsonEditorOptions | editor options} that\n * apply to this rule.\n * @param runtimeContext - An optional {@link IJsonContext | JSON context} to be used\n * for json value conversion.\n */\n public constructor(\n editor: IJsonCloneEditor,\n baseOptions: IJsonEditorOptions,\n runtimeContext?: IJsonContext\n ) {\n this.editor = editor;\n this.options = JsonEditorState._getEffectiveOptions(baseOptions, runtimeContext).orThrow();\n this._id = JsonEditorState._nextId++;\n }\n\n /**\n * The optional {@link IJsonContext | JSON context} for this state.\n */\n public get context(): IJsonContext | undefined {\n return this.options.context;\n }\n\n /**\n * An array of JSON objects that were deferred for merge during\n * finalization.\n */\n public get deferred(): JsonObject[] {\n return this._deferred;\n }\n\n /**\n * Merges an optional {@link IJsonContext | JSON context} into a supplied set\n * of {@link IJsonEditorOptions | JSON editor options}.\n * @param options - The {@link IJsonEditorOptions | IJsonEditorOptions} into\n * which the the new context is to be merged.\n * @param context - The {@link IJsonContext | JSON context} to be merged into the\n * editor options.\n * @returns `Success` with the supplied {@link IJsonEditorOptions | options} if\n * there was nothing to merge, or aa new {@link IJsonEditorOptions | IJsonEditorOptions}\n * constructed from the base options merged with the supplied context. Returns `Failure`\n * with more information if an error occurs.\n * @internal\n */\n protected static _getEffectiveOptions(\n options: IJsonEditorOptions,\n context?: IJsonContext\n ): Result<IJsonEditorOptions> {\n if (!context) {\n return succeed(options);\n }\n return JsonContextHelper.mergeContext(options.context, context).onSuccess((merged) => {\n return succeed({ context: merged, validation: options.validation, merge: options.merge });\n });\n }\n\n /**\n * Adds a supplied `JsonObject` to the deferred list.\n * @param obj - The `JsonObject` to be deferred.\n */\n public defer(obj: JsonObject): void {\n this._deferred.push(obj);\n }\n\n /**\n * Gets a {@link TemplateVars | TemplateVars} from the context of this {@link JsonEditorState | JsonEditorState},\n * or from an optional supplied {@link IJsonContext | IJsonContext} if the current state has no default\n * context.\n * @param defaultContext - An optional default {@link IJsonContext | IJsonContext} to use as `TemplateVars`\n * if the current state does not have context.\n * @returns A {@link TemplateVars | TemplateVars} reflecting the appropriate {@link IJsonContext | JSON context}, or\n * `undefined` if no vars are found.\n */\n public getVars(defaultContext?: IJsonContext): TemplateVars | undefined {\n /* c8 ignore next */ // c8 seems to be struggling atm\n return this.options.context?.vars ?? defaultContext?.vars;\n }\n\n /**\n * Gets an {@link IJsonReferenceMap | reference map} containing any other values\n * referenced during the operation.\n * @param defaultContext - An optional default {@link IJsonContext | IJsonContext} to use as\n * {@link TemplateVars | TemplateVars} if the current state does not have context.\n * @returns An {@link IJsonReferenceMap | IJsonReferenceMap} containing any values referenced\n * during this operation.\n */\n public getRefs(defaultContext?: IJsonContext): IJsonReferenceMap | undefined {\n /* c8 ignore next */ // c8 seems to be struggling atm\n return this.options.context?.refs ?? defaultContext?.refs;\n }\n\n /**\n * Gets the context of this {@link JsonEditorState | JsonEditorState} or an optionally\n * supplied default context if this state has no context.\n * @param defaultContext - The default {@link IJsonContext | JSON context} to use as default\n * if this state has no context.\n * @returns The appropriate {@link IJsonContext | IJsonContext} or `undefined` if no context\n * is available.\n */\n public getContext(defaultContext?: IJsonContext): IJsonContext | undefined {\n return JsonContextHelper.mergeContext(defaultContext, this.options.context).orDefault();\n }\n\n /**\n * Constructs a new {@link IJsonContext | IJsonContext} by merging supplied variables\n * and references into a supplied existing context.\n * @param baseContext - The {@link IJsonContext | IJsonContext} into which variables\n * and references are to be merged, or `undefined` to start with a default empty context.\n * @param add - The {@link VariableValue | variable values} and/or\n * {@link IJsonReferenceMap | JSON entity references} to be merged into the base context.\n * @returns A new {@link IJsonContext | IJsonContext} created by merging the supplied values.\n */\n public extendContext(\n baseContext: IJsonContext | undefined,\n add: { vars?: VariableValue[]; refs?: IJsonReferenceMap[] }\n ): Result<IJsonContext | undefined> {\n const context = this.getContext(baseContext);\n return JsonContextHelper.extendContext(context, add);\n }\n\n /**\n * Helper method to constructs `DetailedFailure` with appropriate details and messaging\n * for various validation failures.\n * @param rule - The {@link JsonEditorValidationRules | validation rule} that failed.\n * @param message - A string message describing the failed validation.\n * @param validation - The {@link IJsonEditorValidationOptions | validation options}\n * in effect.\n * @returns A `DetailedFailure` with appropriate detail and message.\n */\n public failValidation<T = JsonObject>(\n rule: JsonEditorValidationRules,\n message?: string,\n validation?: IJsonEditorValidationOptions\n ): DetailedFailure<T, JsonEditFailureReason> {\n let detail: JsonPropertyEditFailureReason = 'error';\n const effective = validation ?? this.options.validation;\n switch (rule) {\n case 'invalidPropertyName':\n detail = effective.onInvalidPropertyName !== 'ignore' ? 'error' : 'inapplicable';\n break;\n case 'invalidPropertyValue':\n detail = effective.onInvalidPropertyValue !== 'ignore' ? 'error' : 'ignore';\n break;\n case 'undefinedPropertyValue':\n detail = effective.onUndefinedPropertyValue !== 'error' ? 'ignore' : 'error';\n /* c8 ignore next */\n message = message ?? 'Cannot convert undefined to JSON';\n break;\n }\n /* c8 ignore next */\n return failWithDetail(message ?? rule, detail);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonReferenceMap.d.ts","sourceRoot":"","sources":["../../../src/packlets/editor/jsonReferenceMap.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,cAAc,EACd,MAAM,EAQP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAgB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,qCAAqC;IACpD;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,qBAAa,qBAAqB,CAAC,CAAC;IAClC;;OAEG;IACH,SAAS,CAAC,QAAQ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EAAE,EAAE,CAAC;gBACvB,OAAO,IAAA,yBAAc,EAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACjD,CAAC;YACD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;QAC9B,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACvE,CAAC;CACF;AA7ED,sCA6EC;AAkBD;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,aAAa;IAChD;;;;;;;OAOG;IACH,YACE,MAA+B,EAC/B,OAAsB,EACtB,OAA+B;QAE/B,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC;IAgCM,MAAM,CAAC,cAAc,CAC1B,aAAyC,EACzC,MAA+B,EAC/B,OAAsB,EACtB,MAAmB;QAEnB,OAAO,IAAA,wBAAa,EAClB,GAAG,EAAE,CAAC,IAAI,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC,CACjG,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACO,MAAM,CAAC,SAAS,CAAC,aAAyC;QAClE,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;YACtC,OAAO,IAAI,eAAe,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,IAAI,eAAe,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,aAAa,CAAC,SAAS,KAAK,KAAK,EAAE,CAAC,CAAC;IACrG,CAAC;CACF;AAzED,0CAyEC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport {\n DetailedResult,\n Result,\n captureResult,\n fail,\n failWithDetail,\n mapResults,\n recordToMap,\n succeed,\n succeedWithDetail\n} from '@fgv/ts-utils';\n\nimport { JsonObject, JsonValue, isJsonObject } from '@fgv/ts-json-base';\nimport { IJsonContext, IJsonReferenceMap, JsonReferenceMapFailureReason } from '../context';\nimport { JsonEditor } from './jsonEditor';\n\n/**\n * Options for creating a {@link ReferenceMapKeyPolicy | ReferenceMapKeyPolicy} object.\n * @public\n */\nexport interface IReferenceMapKeyPolicyValidateOptions {\n /**\n * If `true`, the validator coerces keys to some valid value.\n * If `false`, invalid keys cause an error.\n */\n makeValid?: boolean;\n}\n\n/**\n * Policy object responsible for validating or correcting\n * keys in a {@link IJsonReferenceMap | reference map}.\n * @public\n */\nexport class ReferenceMapKeyPolicy<T> {\n /**\n * @internal\n */\n protected readonly _defaultOptions?: IReferenceMapKeyPolicyValidateOptions;\n\n /**\n * @internal\n */\n protected readonly _isValid: (key: string, item?: T) => boolean;\n\n /**\n * Constructs a new {@link ReferenceMapKeyPolicy | ReferenceMapKeyPolicy}.\n * @param options - Optional {@link IReferenceMapKeyPolicyValidateOptions | options}\n * used to construct the {@link ReferenceMapKeyPolicy}.\n * @param isValid - An optional predicate to test a supplied key for validity.\n */\n public constructor(\n options?: IReferenceMapKeyPolicyValidateOptions,\n isValid?: (key: string, item?: T) => boolean\n ) {\n this._defaultOptions = options;\n this._isValid = isValid ?? ReferenceMapKeyPolicy.defaultKeyPredicate;\n }\n\n /**\n * The static default key name validation predicate rejects keys that contain\n * mustache templates or which start with the default conditional prefix\n * `'?'`.\n * @param key - The key to test.\n * @returns `true` if the key is valid, `false` otherwise.\n */\n public static defaultKeyPredicate(key: string): boolean {\n return key.length > 0 && !key.includes('{{') && !key.startsWith('?');\n }\n\n /**\n * Determines if a supplied key and item are valid according to the current policy.\n * @param key - The key to be tested.\n * @param item - The item to be tested.\n * @returns `true` if the key and value are valid, `false` otherwise.\n */\n public isValid(key: string, item?: T): boolean {\n return this._isValid(key, item);\n }\n\n /**\n * Determines if a supplied key and item are valid according to the current policy.\n * @param key - The key to be tested.\n * @param item - The item to be tested.\n * @returns `Success` with the key if valid, `Failure` with an error message if invalid.\n */\n public validate(key: string, item?: T, __options?: IReferenceMapKeyPolicyValidateOptions): Result<string> {\n return this.isValid(key, item) ? succeed(key) : fail(`${key}: invalid key`);\n }\n\n /**\n * Validates an array of entries using the validation rules for this policy.\n * @param items - The array of entries to be validated.\n * @param options - Optional {@link IReferenceMapKeyPolicyValidateOptions | options} to control\n * validation.\n * @returns `Success` with an array of validated entries, or `Failure` with an error message\n * if validation fails.\n */\n public validateItems(\n items: [string, T][],\n options?: IReferenceMapKeyPolicyValidateOptions\n ): Result<[string, T][]> {\n return mapResults(\n items.map((item) => {\n return this.validate(...item, options).onSuccess((valid) => {\n return succeed([valid, item[1]]);\n });\n })\n );\n }\n\n /**\n * Validates a `Map\\<string, T\\>` using the validation rules for this policy.\n * @param items - The `Map\\<string, T\\>` to be validated.\n * @param options - Optional {@link IReferenceMapKeyPolicyValidateOptions | options} to control\n * validation.\n * @returns `Success` with a new `Map\\<string, T\\>`, or `Failure` with an error message\n * if validation fails.\n */\n public validateMap(\n map: Map<string, T>,\n options?: IReferenceMapKeyPolicyValidateOptions\n ): Result<Map<string, T>> {\n return this.validateItems(Array.from(map.entries()), options).onSuccess((valid) => {\n return captureResult(() => new Map(valid));\n });\n }\n}\n\n/**\n * A {@link PrefixKeyPolicy | PrefixKeyPolicy} enforces that all keys start with a supplied\n * prefix, optionally adding the prefix as necessary.\n * @public\n */\nexport class PrefixKeyPolicy<T> extends ReferenceMapKeyPolicy<T> {\n /**\n * The string prefix to be enforced by this policy.\n */\n public readonly prefix: string;\n\n /**\n * Constructs a new {@link PrefixKeyPolicy | PrefixKeyPolicy}.\n * @param prefix - The string prefix to be enforced or applied.\n * @param options - Optional {@link IReferenceMapKeyPolicyValidateOptions | options} to\n * configure the policy.\n */\n public constructor(prefix: string, options?: IReferenceMapKeyPolicyValidateOptions) {\n super(options);\n this.prefix = prefix;\n }\n\n /**\n * Determines if a key is valid according to policy.\n * @param key - The key to be tested.\n * @param __item - The item to be tested.\n * @returns `true` if the key starts with the expected prefix, `false` otherwise.\n */\n public isValid(key: string, __item?: T): boolean {\n return (\n key.startsWith(this.prefix) && key !== this.prefix && ReferenceMapKeyPolicy.defaultKeyPredicate(key)\n );\n }\n\n /**\n * Determines if a key is valid according to policy, optionally coercing to a valid value by\n * adding the required prefix.\n * @param key - The key to be tested.\n * @param item - The item which corresponds to the key.\n * @param options - Optional {@link IReferenceMapKeyPolicyValidateOptions | options} to guide\n * validation.\n * @returns `Success` with a valid key name if the supplied key is valid or if `makeValid` is set\n * in the policy options. Returns `Failure` with an error message if an error occurs.\n */\n public validate(key: string, item?: T, options?: IReferenceMapKeyPolicyValidateOptions): Result<string> {\n /* c8 ignore next */\n const makeValid = (options ?? this._defaultOptions)?.makeValid === true;\n if (this.isValid(key, item)) {\n return succeed(key);\n } else if (makeValid && ReferenceMapKeyPolicy.defaultKeyPredicate(key)) {\n return succeed(`${this.prefix}${key}`);\n }\n return fail(`${key}: invalid key`);\n }\n}\n\n/**\n * Type representing either a `Map\\<string, T\\>` or a `Record\\<string, T\\>`.\n * @public\n */\nexport type MapOrRecord<T> = Map<string, T> | Record<string, T>;\n\n/**\n * Abstract base class with common functionality for simple\n * {@link IJsonReferenceMap | reference map} implementations.\n * @public\n */\nexport abstract class SimpleJsonMapBase<T> implements IJsonReferenceMap {\n /**\n * The {@link ReferenceMapKeyPolicy | key policy} in effect for this map.\n * @internal\n */\n protected readonly _keyPolicy: ReferenceMapKeyPolicy<T>;\n\n /**\n * A map containing keys and values already present in this map.\n * @internal\n */\n protected readonly _values: Map<string, T>;\n\n /**\n * An optional {@link IJsonContext | IJsonContext} used for any conversions\n * involving items in this map.\n * @internal\n */\n protected readonly _context?: IJsonContext;\n\n /**\n * Constructs a new {@link SimpleJsonMap | SimpleJsonMap}.\n * @param values - Initial values for the map.\n * @param context - An optional {@link IJsonContext | IJsonContext} used for any conversions\n * involving items in this map.\n * @param keyPolicy - The {@link ReferenceMapKeyPolicy | key policy} to use for this map.\n * @internal\n */\n protected constructor(\n values?: MapOrRecord<T>,\n context?: IJsonContext,\n keyPolicy?: ReferenceMapKeyPolicy<T>\n ) {\n values = SimpleJsonMapBase._toMap(values).orThrow();\n this._keyPolicy = keyPolicy ?? new ReferenceMapKeyPolicy();\n this._values = this._keyPolicy.validateMap(values).orThrow();\n this._context = context;\n }\n\n /**\n * Returns a `Map\\<string, T\\>` derived from a supplied {@link MapOrRecord | MapOrRecord}\n * @param values - The {@link MapOrRecord | MapOrRecord} to be returned as a map.\n * @returns `Success` with the corresponding `Map\\<string, T\\>` or `Failure` with a\n * message if an error occurs.\n * @internal\n */\n protected static _toMap<T>(values?: MapOrRecord<T>): Result<Map<string, T>> {\n if (values === undefined) {\n return captureResult(() => new Map<string, T>());\n } else if (!(values instanceof Map)) {\n return recordToMap(values, (__k, v) => succeed(v));\n }\n return succeed(values);\n }\n\n /**\n * Determine if a key might be valid for this map but does not determine if key actually\n * exists. Allows key range to be constrained.\n * @param key - key to be tested\n * @returns `true` if the key is in the valid range, `false` otherwise.\n */\n public keyIsInRange(key: string): boolean {\n return this._keyPolicy.isValid(key);\n }\n\n /**\n * Determines if an entry with the specified key actually exists in the map.\n * @param key - key to be tested\n * @returns `true` if an object with the specified key exists, `false` otherwise.\n */\n public has(key: string): boolean {\n return this._values.has(key);\n }\n\n /**\n * Gets a `JsonObject` specified by key.\n * @param key - key of the object to be retrieved\n * @param context - optional {@link IJsonContext | JSON context} used to format the\n * returned object.\n * @returns {@link ts-utils#Success | `Success`} with the formatted object if successful.\n * {@link ts-utils#Failure | `Failure`} with detail 'unknown' if no such object exists,\n * or {@link ts-utils#Failure | `Failure`} with detail 'error' if the object was found\n * but could not be formatted.\n */\n public getJsonObject(\n key: string,\n context?: IJsonContext\n ): DetailedResult<JsonObject, JsonReferenceMapFailureReason> {\n return this.getJsonValue(key, context).onSuccess((jv) => {\n if (!isJsonObject(jv)) {\n return failWithDetail(`${key}: not an object`, 'error');\n }\n return succeedWithDetail(jv);\n });\n }\n\n /**\n * Gets a `JsonValue` specified by key.\n * @param key - key of the value to be retrieved\n * @param context - Optional {@link IJsonContext | JSON context} used to format the value\n * @returns Success with the formatted object if successful. Failure with detail 'unknown'\n * if no such object exists, or failure with detail 'error' if the object was found but\n * could not be formatted.\n */\n // eslint-disable-next-line no-use-before-define\n public abstract getJsonValue(\n key: string,\n context?: IJsonContext\n ): DetailedResult<JsonValue, JsonReferenceMapFailureReason>;\n}\n\n/**\n * Initialization options for a {@link SimpleJsonMap | SimpleJsonMap}.\n * @public\n */\nexport interface ISimpleJsonMapOptions {\n keyPolicy?: ReferenceMapKeyPolicy<JsonValue>;\n editor?: JsonEditor;\n}\n\n/**\n * A {@link SimpleJsonMap | SimpleJsonMap } presents a view of a simple map\n * of JSON values.\n * @public\n */\nexport class SimpleJsonMap extends SimpleJsonMapBase<JsonValue> {\n /**\n * @internal\n */\n protected _editor?: JsonEditor;\n\n /**\n * Constructs a new {@link SimpleJsonMap | SimpleJsonMap} from the supplied objects\n * @param values - A string-keyed `Map` or `Record` of the `JsonValue`\n * to be returned.\n * @param context - Optional {@link IJsonContext | IJsonContext} used to format returned values.\n * @param options - Optional {@link ISimpleJsonMapOptions | ISimpleJsonMapOptions} for initialization.\n * @public\n */\n protected constructor(\n values?: MapOrRecord<JsonValue>,\n context?: IJsonContext,\n options?: ISimpleJsonMapOptions\n ) {\n super(values, context, options?.keyPolicy);\n this._editor = options?.editor;\n }\n\n /**\n * Creates a new {@link SimpleJsonMap | SimpleJsonMap} from the supplied objects\n * @param values - A string-keyed `Map` or `Record` of the `JsonValue`\n * to be returned.\n * @param context - Optional {@link IJsonContext | IJsonContext} used to format returned values.\n * @param options - Optional {@link ISimpleJsonMapOptions | ISimpleJsonMapOptions} for initialization.\n * @returns `Success` with a {@link SimpleJsonMap | SimpleJsonMap} or `Failure` with a message if\n * an error occurs.\n */\n public static createSimple(\n values?: MapOrRecord<JsonValue>,\n context?: IJsonContext,\n options?: ISimpleJsonMapOptions\n ): Result<SimpleJsonMap> {\n return captureResult(() => new SimpleJsonMap(values, context, options));\n }\n\n /**\n * Gets a `JsonValue` specified by key.\n * @param key - key of the value to be retrieved\n * @param context - Optional {@link IJsonContext | JSON context} used to format the value\n * @returns Success with the formatted object if successful. Failure with detail 'unknown'\n * if no such object exists, or failure with detail 'error' if the object was found but\n * could not be formatted.\n */\n public getJsonValue(\n key: string,\n context?: IJsonContext\n ): DetailedResult<JsonValue, JsonReferenceMapFailureReason> {\n context = context ?? this._context;\n const value = this._values.get(key);\n if (!value) {\n return failWithDetail(`${key}: JSON value not found`, 'unknown');\n }\n return this._clone(value, context);\n }\n\n /**\n * @internal\n */\n protected _clone(\n value: JsonValue,\n context?: IJsonContext\n ): DetailedResult<JsonValue, JsonReferenceMapFailureReason> {\n if (!this._editor) {\n const result = JsonEditor.create();\n /* c8 ignore next 3 - nearly impossible to reproduce */\n if (result.isFailure()) {\n return failWithDetail(result.message, 'error');\n }\n this._editor = result.value;\n }\n return this._editor.clone(value, context).withFailureDetail('error');\n }\n}\n\n/**\n * Initialization options for a {@link PrefixedJsonMap | PrefixedJsonMap}\n * @public\n */\nexport interface IKeyPrefixOptions {\n /**\n * Indicates whether the prefix should be added automatically as needed (default true)\n */\n addPrefix?: boolean;\n\n /**\n * The prefix to be enforced\n */\n prefix: string;\n}\n\n/**\n * A {@link PrefixedJsonMap | PrefixedJsonMap} enforces a supplied prefix for all contained values,\n * optionally adding the prefix as necessary (default `true`).\n * @public\n */\nexport class PrefixedJsonMap extends SimpleJsonMap {\n /**\n * Constructs a new {@link PrefixedJsonMap | PrefixedJsonMap} from the supplied values\n * @param prefix - A string prefix to be enforced for and added to key names as necessary\n * @param values - A string-keyed Map or Record of the `JsonValue` to be returned\n * @param context - Optional {@link IJsonContext | JSON Context} used to format returned values\n * @param editor - Optional {@link JsonEditor | JsonEditor} used to format returned values\n * @public\n */\n protected constructor(\n values?: MapOrRecord<JsonValue>,\n context?: IJsonContext,\n options?: ISimpleJsonMapOptions\n ) {\n super(values, context, options);\n }\n\n /**\n * Creates a new {@link PrefixedJsonMap | PrefixedJsonMap} from the supplied values\n * @param prefix - A string prefix to be enforced for and added to key names as necessary\n * @param values - A string-keyed Map or Record of the `JsonValue` to be returned\n * @param context - Optional {@link IJsonContext | JSON Context} used to format returned values\n * @param editor - Optional {@link JsonEditor | JsonEditor} used to format returned values\n * @returns `Success` with a {@link PrefixedJsonMap | PrefixedJsonMap} or `Failure` with a message\n * if an error occurs.\n */\n public static createPrefixed(\n prefix: string,\n values?: MapOrRecord<JsonValue>,\n context?: IJsonContext,\n editor?: JsonEditor\n ): Result<PrefixedJsonMap>;\n\n /**\n * Creates a new {@link PrefixedJsonMap | PrefixedJsonMap} from the supplied values\n * @param prefixOptions - A KeyPrefixOptions indicating the prefix to enforce and whether that prefix should\n * be added automatically if necessary (default true)\n * @param values - A string-keyed Map or record of the `JsonValue` to be returned\n * @param context - Optional {@link IJsonContext | JSON Context} used to format returned values\n * @param editor - Optional {@link JsonEditor | JsonEditor} used to format returned values\n */\n public static createPrefixed(\n prefixOptions: IKeyPrefixOptions,\n values?: MapOrRecord<JsonValue>,\n context?: IJsonContext,\n editor?: JsonEditor\n ): Result<PrefixedJsonMap>;\n public static createPrefixed(\n prefixOptions: string | IKeyPrefixOptions,\n values?: MapOrRecord<JsonValue>,\n context?: IJsonContext,\n editor?: JsonEditor\n ): Result<PrefixedJsonMap> {\n return captureResult(\n () => new PrefixedJsonMap(values, context, { keyPolicy: this._toPolicy(prefixOptions), editor })\n );\n }\n\n /**\n * Constructs a new {@link PrefixKeyPolicy | PrefixKeyPolicy} from a supplied prefix\n * or set of {@link IKeyPrefixOptions | prefix options}.\n * @param prefixOptions - The prefix or {@link IKeyPrefixOptions | prefix options} or options\n * for the new policy.\n * @returns A new {@link ReferenceMapKeyPolicy | ReferenceMapKeyPolicy} which enforces the\n * supplied prefix or options.\n * @internal\n */\n protected static _toPolicy(prefixOptions: string | IKeyPrefixOptions): ReferenceMapKeyPolicy<JsonValue> {\n if (typeof prefixOptions === 'string') {\n return new PrefixKeyPolicy(prefixOptions, { makeValid: true });\n }\n return new PrefixKeyPolicy(prefixOptions.prefix, { makeValid: prefixOptions.addPrefix !== false });\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditional.d.ts","sourceRoot":"","sources":["../../../../src/packlets/editor/rules/conditional.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAgB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAoD,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC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KAAK,KAAK,CAAC;YACxB,KAAK,GAAG;gBACN,OAAO,IAAI,GAAG,KAAK,CAAC;YACtB,KAAK,GAAG;gBACN,OAAO,IAAI,GAAG,KAAK,CAAC;YACtB,KAAK,IAAI;gBACP,OAAO,IAAI,IAAI,KAAK,CAAC;YACvB,KAAK,IAAI;gBACP,OAAO,IAAI,IAAI,KAAK,CAAC;YACvB,KAAK,IAAI;gBACP,OAAO,IAAI,KAAK,KAAK,CAAC;QAC1B,CAAC;QACD,oCAAoC;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAvJD,8DAuJC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonObject, JsonValue, isJsonObject } from '@fgv/ts-json-base';\nimport { DetailedResult, Result, captureResult, failWithDetail, succeedWithDetail } from '@fgv/ts-utils';\nimport { IJsonEditorOptions, JsonEditFailureReason, JsonPropertyEditFailureReason } from '../common';\nimport { JsonEditorRuleBase } from '../jsonEditorRule';\nimport { JsonEditorState } from '../jsonEditorState';\n\n/**\n * Returned by {@link EditorRules.ConditionalJsonEditorRule._tryParseCondition | ConditionalJsonEditorRule._tryParseCondition}\n * to indicate whether a successful match was due to a matching condition or a default value.\n * @public\n */\nexport interface IConditionalJsonKeyResult extends JsonObject {\n matchType: 'default' | 'match' | 'unconditional';\n}\n\n/**\n * On a successful match, the {@link EditorRules.ConditionalJsonEditorRule | ConditionalJsonEditorRule}\n * stores a {@link EditorRules.IConditionalJsonDeferredObject | IConditionalJsonDeferredObject} describing the\n * matching result, to be resolved at finalization time.\n * @public\n */\nexport interface IConditionalJsonDeferredObject extends IConditionalJsonKeyResult {\n value: JsonValue;\n}\n\n/**\n * Configuration options for the {@link EditorRules.ConditionalJsonEditorRule | ConditionalJsonEditorRule}.\n * @public\n */\nexport interface IConditionalJsonRuleOptions extends Partial<IJsonEditorOptions> {\n /**\n * If true (default) then properties with unconditional names\n * (which start with !) are flattened.\n */\n flattenUnconditionalValues?: boolean;\n}\n\n/**\n * The {@link EditorRules.ConditionalJsonEditorRule | ConditionalJsonEditorRule} evaluates\n * properties with conditional keys, omitting non-matching keys and merging keys that match,\n * or default keys only if no other keys match.\n *\n * The default syntax for a conditional key is:\n * \"?value1=value2\" - matches if value1 and value2 are the same, is ignored otherwise.\n * \"?value\" - matches if value is a non-empty, non-whitespace string. Is ignored otherwise.\n * \"?default\" - matches only if no other conditional blocks in the same object were matched.\n * @public\n */\nexport class ConditionalJsonEditorRule extends JsonEditorRuleBase {\n /**\n * Stored fully-resolved {@link EditorRules.IConditionalJsonRuleOptions | options} for this\n * rule.\n * @public\n */\n protected _options?: IConditionalJsonRuleOptions;\n\n /**\n * Creates a new {@link EditorRules.ConditionalJsonEditorRule | ConditionalJsonEditorRule}.\n * @param options - Optional {@link EditorRules.IConditionalJsonRuleOptions | configuration options}\n * used for this rule.\n */\n public constructor(options?: IConditionalJsonRuleOptions) {\n super();\n this._options = options;\n }\n\n /**\n * Creates a new {@link EditorRules.ConditionalJsonEditorRule | ConditionalJsonEditorRule}.\n * @param options - Optional {@link EditorRules.IConditionalJsonRuleOptions | configuration options}\n * used for this rule.\n */\n public static create(options?: IConditionalJsonRuleOptions): Result<ConditionalJsonEditorRule> {\n return captureResult(() => new ConditionalJsonEditorRule(options));\n }\n\n /**\n * Evaluates a property for conditional application.\n * @param key - The key of the property to be considered\n * @param value - The `JsonValue` of the property to be considered.\n * @param state - The {@link JsonEditorState | editor state} for the object being edited.\n * @returns Returns `Success` with detail `'deferred'` and a\n * {@link EditorRules.IConditionalJsonDeferredObject | IConditionalJsonDeferredObject}.\n * for a matching, default or unconditional key. Returns `Failure` with detail `'ignore'` for\n * a non-matching conditional, or with detail `'error'` if an error occurs. Otherwise\n * fails with detail `'inapplicable'`.\n */\n public editProperty(\n key: string,\n value: JsonValue,\n state: JsonEditorState\n ): DetailedResult<JsonObject, JsonPropertyEditFailureReason> {\n const result = this._tryParseCondition(key, state).onSuccess((deferred) => {\n if (isJsonObject(value)) {\n const rtrn: IConditionalJsonDeferredObject = { ...deferred, value };\n return succeedWithDetail(rtrn, 'deferred');\n }\n return failWithDetail<JsonObject, JsonPropertyEditFailureReason>(\n `${key}: conditional body must be object`,\n 'error'\n );\n });\n\n if (result.isFailure() && result.detail === 'error') {\n return state.failValidation('invalidPropertyName', result.message, this._options?.validation);\n }\n\n return result;\n }\n\n /**\n * Finalizes any deferred conditional properties. If the only deferred property is\n * default, that property is emitted. Otherwise all matching properties are emitted.\n * @param finalized - The deferred properties to be considered for merge.\n * @param __state - The {@link JsonEditorState | editor state} for the object\n * being edited.\n */\n public finalizeProperties(\n finalized: JsonObject[],\n __state: JsonEditorState\n ): DetailedResult<JsonObject[], JsonEditFailureReason> {\n let toMerge = finalized;\n if (finalized.length > 1) {\n if (finalized.find((o) => o.matchType === 'match') !== undefined) {\n toMerge = finalized.filter((o) => o.matchType === 'match' || o.matchType === 'unconditional');\n }\n }\n return succeedWithDetail(toMerge.map((o) => o.value).filter(isJsonObject), 'edited');\n }\n\n /**\n * Determines if a given property key is conditional. Derived classes can override this\n * method to use a different format for conditional properties.\n * @param value - The `JsonValue` of the property to be considered.\n * @param state - The {@link JsonEditorState | editor state} for the object being edited.\n * @returns `Success` with detail `'deferred'` and a\n * {@link EditorRules.IConditionalJsonKeyResult | IConditionalJsonKeyResult} describing the\n * match for a default or matching conditional property. Returns `Failure` with detail `'ignore'`\n * for a non-matching conditional property. Fails with detail `'error'` if an error occurs\n * or with detail `'inapplicable'` if the key does not represent a conditional property.\n * @public\n */\n protected _tryParseCondition(\n key: string,\n state: JsonEditorState\n ): DetailedResult<IConditionalJsonKeyResult, JsonPropertyEditFailureReason> {\n if (key.startsWith('?')) {\n // ignore everything after any #\n key = key.split('#')[0].trim();\n\n if (key === '?default') {\n return succeedWithDetail({ matchType: 'default' }, 'deferred');\n }\n\n const parts = key.substring(1).split(/(=|>=|<=|>|<|!=)/);\n if (parts.length === 3) {\n if (!this._compare(parts[0].trim(), parts[2].trim(), parts[1])) {\n return failWithDetail(`Condition ${key} does not match`, 'ignore');\n }\n return succeedWithDetail({ matchType: 'match' }, 'deferred');\n } else if (parts.length === 1) {\n if (parts[0].trim().length === 0) {\n return failWithDetail(`Condition ${key} does not match`, 'ignore');\n }\n return succeedWithDetail({ matchType: 'match' }, 'deferred');\n }\n const message = `Malformed condition token ${key}`;\n return state.failValidation('invalidPropertyName', message, this._options?.validation);\n } else if (this._options?.flattenUnconditionalValues !== false && key.startsWith('!')) {\n return succeedWithDetail({ matchType: 'unconditional' }, 'deferred');\n }\n return failWithDetail('inapplicable', 'inapplicable');\n }\n\n /**\n * Compares two strings using a supplied operator.\n * @param left - The first string to be compared.\n * @param right - The second string to be compared.\n * @param operator - The operator to be applied.\n * @returns `true` if the condition is met, `false` otherwise.\n * @internal\n */\n protected _compare(left: string, right: string, operator: string): boolean {\n switch (operator) {\n case '=':\n return left === right;\n case '>':\n return left > right;\n case '<':\n return left < right;\n case '>=':\n return left >= right;\n case '<=':\n return left <= right;\n case '!=':\n return left !== right;\n }\n /* c8 ignore next 2 - unreachable */\n return false;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/packlets/editor/rules/index.ts"],"names":[],"mappings":"AAqBA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/packlets/editor/rules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,gDAA8B;AAC9B,+CAA6B;AAC7B,+CAA6B;AAC7B,8CAA4B","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\nexport * from './conditional';\nexport * from './multivalue';\nexport * from './references';\nexport * from './templates';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"multivalue.d.ts","sourceRoot":"","sources":["../../../../src/packlets/editor/rules/multivalue.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACL,cAAc,EACd,MAAM,EAMP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAErG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAElC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,wBAAyB,SAAQ,kBAAkB;IAC9D;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAExC;;;OAGG;gBACgB,OAAO,CAAC,EAAE,kBAAkB;IAK/C;;;OAGG;WACW,MAAM,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAAC,wBAAwB,CAAC;IAIpF;;;;;;;;OAQG;IACI,YAAY,CACjB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,eAAe,GACrB,cAAc,CAAC,UAAU,EAAE,6BAA6B,CAAC;IA+B5D;;;;;;;OAOG;IACH,SAAS,CA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charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonObject, JsonValue } from '@fgv/ts-json-base';\nimport {\n DetailedResult,\n Result,\n allSucceed,\n captureResult,\n failWithDetail,\n succeed,\n succeedWithDetail\n} from '@fgv/ts-utils';\nimport { IJsonContext, VariableValue } from '../../context';\nimport { IJsonEditorOptions, JsonEditFailureReason, JsonPropertyEditFailureReason } from '../common';\n\nimport { JsonEditorRuleBase } from '../jsonEditorRule';\nimport { JsonEditorState } from '../jsonEditorState';\n\n/**\n * Represents the parts of a multi-value property key.\n * @public\n */\nexport interface IMultiValuePropertyParts {\n /**\n * The original matched token.\n */\n readonly token: string;\n\n /**\n * The name of the variable used to project each possible\n * property value into the child values or objects being\n * resolved.\n */\n readonly propertyVariable: string;\n\n /**\n * The set of property values to be expanded.\n */\n readonly propertyValues: string[];\n\n /**\n * If `true`, the resolved values are added as an array\n * with the name of the {@link EditorRules.IMultiValuePropertyParts.propertyVariable | propertyVariable}.\n * If false, values are added as individual properties with names that correspond the value.\n */\n readonly asArray: boolean;\n}\n\n/**\n * The {@link EditorRules.MultiValueJsonEditorRule | Multi-Value JSON editor rule}\n * expands matching keys multiple times, projecting the value into the template\n * context for any child objects rendered by the rule.\n *\n * The default syntax for a multi-value key is:\n * \"[[var]]=value1,value2,value3\"\n * Where \"var\" is the name of the variable that will be passed to\n * child template resolution, and \"value1,value2,value3\" is a\n * comma-separated list of values to be expanded.\n * @public\n */\nexport class MultiValueJsonEditorRule extends JsonEditorRuleBase {\n /**\n * Stored fully-resolved {@link IJsonEditorOptions | editor options}\n * for this rule.\n * @public\n */\n protected _options?: IJsonEditorOptions;\n\n /**\n * Creates a new {@link EditorRules.MultiValueJsonEditorRule | MultiValueJsonEditorRule}.\n * @param options - Optional {@link IJsonEditorOptions | configuration options}.\n */\n public constructor(options?: IJsonEditorOptions) {\n super();\n this._options = options;\n }\n\n /**\n * Creates a new {@link EditorRules.MultiValueJsonEditorRule | MultiValueJsonEditorRule}.\n * @param options - Optional {@link IJsonEditorOptions | configuration options}.\n */\n public static create(options?: IJsonEditorOptions): Result<MultiValueJsonEditorRule> {\n return captureResult(() => new MultiValueJsonEditorRule(options));\n }\n\n /**\n * Evaluates a property for multi-value expansion.\n * @param key - The key of the property to be considered\n * @param value - The `JsonValue` of the property to be considered.\n * @param state - The {@link JsonEditorState | editor state} for the object being edited.\n * @returns `Success` with an object containing the fully-resolved child values to be merged for\n * matching multi-value property. Returns `Failure` with detail `'error'` if an error occurs or\n * with detail `'inapplicable'` if the property key is not a conditional property.\n */\n public editProperty(\n key: string,\n value: JsonValue,\n state: JsonEditorState\n ): DetailedResult<JsonObject, JsonPropertyEditFailureReason> {\n const json: JsonObject = {};\n const result = this._tryParse(key, state).onSuccess((parts) => {\n return allSucceed(\n parts.propertyValues.map((pv) => {\n return this._deriveContext(state, [parts.propertyVariable, pv]).onSuccess((ctx) => {\n return state.editor.clone(value, ctx).onSuccess((cloned) => {\n json[pv] = cloned;\n return succeedWithDetail(cloned);\n });\n });\n }),\n json\n )\n .onSuccess(() => {\n if (parts.asArray) {\n const arrayRtrn: JsonObject = {};\n arrayRtrn[parts.propertyVariable] = Array.from(Object.values(json));\n return succeed(arrayRtrn);\n }\n return succeed(json);\n })\n .withFailureDetail('error');\n });\n\n if (result.isFailure() && result.detail === 'error') {\n return state.failValidation('invalidPropertyName', result.message);\n }\n return result;\n }\n\n /**\n * Extends the {@link IJsonContext | current context} with a supplied state and values.\n * @param state - The {@link JsonEditorState | editor state} for the object being edited.\n * @param values - An array of {@link VariableValue | VariableValue} to be added to the\n * context.\n * @returns The extended {@link IJsonContext | context}.\n * @public\n */\n protected _deriveContext(\n state: JsonEditorState,\n ...values: VariableValue[]\n ): Result<IJsonContext | undefined> {\n return state.extendContext(this._options?.context, { vars: values });\n }\n\n /**\n * Determines if a given property key is multi-value. Derived classes can override this\n * method to use a different format for multi-value properties.\n * @param value - The `JsonValue` of the property to be considered.\n * @param state - The {@link JsonEditorState | editor state} for the object being edited.\n * @returns `Success` with detail `'deferred'` and an\n * {@link EditorRules.IMultiValuePropertyParts | IMultiValuePropertyParts}\n * describing the match for matching multi-value property. Returns `Failure` with detail `'error'` if an error occurs\n * or with detail `'inapplicable'` if the key does not represent a multi-value property.\n * @public\n */\n protected _tryParse(\n token: string,\n state: JsonEditorState\n ): DetailedResult<IMultiValuePropertyParts, JsonEditFailureReason> {\n let parts: string[] = [];\n let asArray = false;\n\n if (token.startsWith('[[')) {\n parts = token.substring(2).split(']]=');\n asArray = true;\n } else if (token.startsWith('*')) {\n parts = token.substring(1).split('=');\n asArray = false;\n } else {\n return failWithDetail(token, 'inapplicable');\n }\n\n if (parts.length !== 2) {\n const message = `Malformed multi-value property: ${token}`;\n return state.failValidation('invalidPropertyName', message, this._options?.validation);\n }\n\n if (parts[1].includes('{{')) {\n return failWithDetail('unresolved template', 'inapplicable');\n }\n\n const propertyVariable = parts[0];\n const propertyValues = parts[1].split(',');\n return succeedWithDetail({ token, propertyVariable, propertyValues, asArray });\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../../../src/packlets/editor/rules/references.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAgC,MAAM,mBAAmB,CAAC;AACxF,OAAO,EACL,cAAc,EACd,MAAM,EAKP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,uBAAwB,SAAQ,kBAAkB;IAC7D;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAExC;;;OAGG;gBACgB,OAAO,CAAC,EAAE,kBAAkB;IAK/C;;;OAGG;WACW,MAAM,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,MAAM,CAAC,uBAAuB,CAAC;IAInF;;;;;;;;OAQG;IACI,YAAY,CACjB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,eAAe,GACrB,cAAc,CAAC,UAAU,EAAE,6BAA6B,CAAC;IAyC5D;;;;OAIG;IACI,SAAS,CACd,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,eAAe,GACrB,cAAc,CAAC,SAAS,EAAE,qBAAqB,CAAC;IAiBnD;;;;;;OAMG;IACH,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CAAC,YAAY,GAAG,SAAS,CAAC;CASxG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"references.js","sourceRoot":"","sources":["../../../../src/packlets/editor/rules/references.ts"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CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAC1D,CAAC;CACF;AAvHD,0DAuHC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonObject, JsonValue, isJsonObject, pickJsonObject } from '@fgv/ts-json-base';\nimport {\n DetailedResult,\n Result,\n captureResult,\n fail,\n failWithDetail,\n succeedWithDetail\n} from '@fgv/ts-utils';\nimport { IJsonContext } from '../../context';\nimport { IJsonEditorOptions, JsonEditFailureReason, JsonPropertyEditFailureReason } from '../common';\nimport { JsonEditorRuleBase } from '../jsonEditorRule';\nimport { JsonEditorState } from '../jsonEditorState';\n\n/**\n * The {@link EditorRules.ReferenceJsonEditorRule | Reference JSON editor rule} replaces property\n * keys or values that match some known object with a copy of that referenced object, formatted\n * according to the current context.\n *\n * A property key is matched if it matches any known referenced value.\n * - If the value of the matched key is `'default'`, then the entire object is formatted\n * with the current context, flattened and merged into the current object.\n * - If the value of the matched key is some other string, then the entire\n * object is formatted with the current context, and the child of the resulting\n * object at the specified path is flattened and merged into the current object.\n * - If the value of the matched key is an object, then the entire object is\n * formatted with the current context extended to include any properties of\n * that object, flattened, and merged into the current object.\n * - It is an error if the referenced value is not an object.\n *\n * Any property, array or literal value is matched if it matches any known\n * value reference. The referenced value is replaced by the referenced\n * value, formatted using the current editor context.\n * @public\n */\nexport class ReferenceJsonEditorRule extends JsonEditorRuleBase {\n /**\n * Stored fully-resolved {@link IJsonEditorOptions | editor options} for this rule.\n * @public\n */\n protected _options?: IJsonEditorOptions;\n\n /**\n * Creates a new {@link EditorRules.ReferenceJsonEditorRule | ReferenceJsonEditorRule}.\n * @param options - Optional {@link IJsonEditorOptions | configuration options} for this rule.\n */\n public constructor(options?: IJsonEditorOptions) {\n super();\n this._options = options;\n }\n\n /**\n * Creates a new {@link EditorRules.ReferenceJsonEditorRule | ReferenceJsonEditorRule}.\n * @param options - Optional {@link IJsonEditorOptions | configuration options} for this rule.\n */\n public static create(options?: IJsonEditorOptions): Result<ReferenceJsonEditorRule> {\n return captureResult(() => new ReferenceJsonEditorRule(options));\n }\n\n /**\n * Evaluates a property for reference expansion.\n * @param key - The key of the property to be considered.\n * @param value - The `JsonValue` of the property to be considered.\n * @param state - The {@link JsonEditorState | editor state} for the object being edited.\n * @returns If the reference is successful, returns `Success` with a `JsonObject`\n * to be flattened and merged into the current object. Returns `Failure` with detail `'inapplicable'`\n * for non-reference keys or with detail `'error'` if an error occurs.\n */\n public editProperty(\n key: string,\n value: JsonValue,\n state: JsonEditorState\n ): DetailedResult<JsonObject, JsonPropertyEditFailureReason> {\n /* c8 ignore next 2 */\n const validation = this._options?.validation;\n const refs = state.getRefs(this._options?.context);\n if (refs?.has(key)) {\n // need to apply any rules to the value before we evaluate it\n const cloneResult = state.editor.clone(value, state.context);\n if (cloneResult.isSuccess()) {\n value = cloneResult.value;\n } else {\n const message = `${key}: ${cloneResult.message}`;\n return state.failValidation('invalidPropertyName', message, validation);\n }\n\n const contextResult = this._extendContext(state, value);\n if (contextResult.isSuccess()) {\n const objResult = refs.getJsonObject(key, contextResult.value);\n // guarded by the has above so should never happen\n /* c8 ignore else */\n if (objResult.isSuccess()) {\n if (typeof value !== 'string' || value === 'default') {\n return succeedWithDetail<JsonObject, JsonEditFailureReason>(objResult.value, 'edited');\n }\n const pickResult = pickJsonObject(objResult.value, value);\n if (pickResult.isFailure()) {\n const message = `${key}: ${pickResult.message}`;\n return state.failValidation('invalidPropertyName', message, validation);\n }\n return pickResult.withDetail('edited');\n } else if (objResult.detail !== 'unknown') {\n const message = `${key}: ${objResult.message}`;\n return state.failValidation('invalidPropertyName', message, validation);\n }\n } else {\n const message = `${key}: ${contextResult.message}`;\n return state.failValidation('invalidPropertyName', message, validation);\n }\n }\n return failWithDetail('inapplicable', 'inapplicable');\n }\n\n /**\n * Evaluates a property, array or literal value for reference replacement.\n * @param value - The `JsonValue` of the property to be considered.\n * @param state - The {@link JsonEditorState | editor state} for the object being edited.\n */\n public editValue(\n value: JsonValue,\n state: JsonEditorState\n ): DetailedResult<JsonValue, JsonEditFailureReason> {\n /* c8 ignore next */\n const refs = state.getRefs(this._options?.context);\n\n if (refs && typeof value === 'string') {\n /* c8 ignore next */\n const context = state.getContext(this._options?.context);\n const result = refs.getJsonValue(value, context);\n if (result.isSuccess()) {\n return succeedWithDetail(result.value, 'edited');\n } else if (result.detail === 'error') {\n return state.failValidation('invalidPropertyValue', result.message, this._options?.validation);\n }\n }\n return failWithDetail('inapplicable', 'inapplicable');\n }\n\n /**\n * Gets the template variables to use given the value of some property whose name matched a\n * resource plus the base template context.\n * @param state - The {@link JsonEditorState | editor state} to be extended.\n * @param supplied - The string or object supplied in the source json.\n * @internal\n */\n protected _extendContext(state: JsonEditorState, supplied: JsonValue): Result<IJsonContext | undefined> {\n const add: Record<string, unknown> = {};\n if (isJsonObject(supplied)) {\n add.vars = Object.entries(supplied);\n } else if (typeof supplied !== 'string') {\n return fail(`Invalid template path or context: \"${JSON.stringify(supplied)}\"`);\n }\n return state.extendContext(this._options?.context, add);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/packlets/editor/rules/templates.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,EAAoD,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD;;;GAGG;AACH,MAAM,WAAW,yBAA0B,SAAQ,OAAO,CAAC,kBAAkB,CAAC;IAC5E;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,kBAAkB;IAC7D;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IAE/C;;;;OAIG;gBACgB,OAAO,CAAC,EAAE,yBAAyB;IAKtD;;;;OAIG;WACW,MAAM,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,MAAM,CAAC,uBAAuB,CAAC;IAI1F;;;;;;;;;OASG;IACI,YAAY,CACjB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,eAAe,GACrB,cAAc,CAAC,UAAU,EAAE,6BAA6B,CAAC;IAyB5D;;;;;;;OAOG;IACI,SAAS,CACd,KAAK,EAAE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AAc,CAAC,sBAAsB,EAAE,OAAO,EAAE,MAAA,IAAI,CAAC,QAAQ,0CAAE,UAAU,CAAC,CAAC;YAC1F,CAAC;YACD,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,OAAO,IAAA,yBAAc,EAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IACxD,CAAC;IAED;;;;;;;;OAQG;IACO,OAAO,CAAC,QAAgB,EAAE,KAAsB;;QACxD,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,CAAC,CAAC;QACnD,IAAI,IAAI,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACpC,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,kBAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC5F,CAAC;QACD,OAAO,IAAA,yBAAc,EAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IACxD,CAAC;CACF;AA5GD,0DA4GC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { JsonObject, JsonValue } from '@fgv/ts-json-base';\nimport { DetailedResult, Result, captureResult, failWithDetail, succeedWithDetail } from '@fgv/ts-utils';\nimport { IJsonEditorOptions, JsonEditFailureReason, JsonPropertyEditFailureReason } from '../common';\nimport { JsonEditorRuleBase } from '../jsonEditorRule';\nimport { JsonEditorState } from '../jsonEditorState';\n\nimport Mustache from 'mustache';\n\n/**\n * Configuration options for the {@link EditorRules.TemplatedJsonEditorRule | Templated JSON editor rule}.\n * @public\n */\nexport interface ITemplatedJsonRuleOptions extends Partial<IJsonEditorOptions> {\n /**\n * If `true` (default) then templates in property names are rendered\n */\n useNameTemplates?: boolean;\n /**\n * If `true` (default) then templates in property values are rendered\n */\n useValueTemplates?: boolean;\n}\n\n/**\n * The {@link EditorRules.TemplatedJsonEditorRule | Templated JSON editor rule} applies mustache rendering as\n * appropriate to any keys or values in the object being edited.\n * @public\n */\nexport class TemplatedJsonEditorRule extends JsonEditorRuleBase {\n /**\n * Fully-resolved {@link EditorRules.ITemplatedJsonRuleOptions | configuration options} for this rule.\n * @public\n */\n protected _options?: ITemplatedJsonRuleOptions;\n\n /**\n * Creates a new {@link EditorRules.TemplatedJsonEditorRule | TemplatedJsonEditorRule}.\n * @param options - Optional {@link EditorRules.ITemplatedJsonRuleOptions | configuration options}\n * for this rule.\n */\n public constructor(options?: ITemplatedJsonRuleOptions) {\n super();\n this._options = options;\n }\n\n /**\n * Creates a new {@link EditorRules.TemplatedJsonEditorRule | TemplatedJsonEditorRule}.\n * @param options - Optional {@link EditorRules.ITemplatedJsonRuleOptions | configuration options}\n * for this rule.\n */\n public static create(options?: ITemplatedJsonRuleOptions): Result<TemplatedJsonEditorRule> {\n return captureResult(() => new TemplatedJsonEditorRule(options));\n }\n\n /**\n * Evaluates a property name for template rendering.\n * @param key - The key of the property to be considered.\n * @param value - The `JsonValue` of the property to be considered.\n * @param state - The {@link JsonEditorState | editor state} for the object being edited.\n * @returns `Success` with detail `'edited'` and an `JsonObject` to\n * be flattened and merged if the key contained a template. Returns `Failure` with detail `'error'`\n * if an error occurred or with detail `'inapplicable'` if the property key does not contain\n * a template or if name rendering is disabled.\n */\n public editProperty(\n key: string,\n value: JsonValue,\n state: JsonEditorState\n ): DetailedResult<JsonObject, JsonPropertyEditFailureReason> {\n /* c8 ignore next 2 */\n const validation = this._options?.validation;\n const useNameTemplates = this._options?.useNameTemplates !== false;\n\n if (useNameTemplates !== false) {\n const result = this._render(key, state).onSuccess((newKey) => {\n if (newKey.length < 1) {\n return state.failValidation('invalidPropertyName', `Template \"${key}\" renders empty name.`);\n }\n\n const rtrn: JsonObject = {};\n rtrn[newKey] = value;\n return succeedWithDetail<JsonObject, JsonEditFailureReason>(rtrn, 'edited');\n });\n\n if (result.isFailure() && result.detail === 'error') {\n const message = `Cannot render name ${key}: ${result.message}`;\n return state.failValidation('invalidPropertyName', message, validation);\n }\n return result;\n }\n return failWithDetail('inapplicable', 'inapplicable');\n }\n\n /**\n * Evaluates a property, array or literal value for template rendering.\n * @param value - The `JsonValue` to be edited.\n * @param state - The {@link JsonEditorState | editor state} for the object being edited.\n * @returns `Success` with detail `'edited'` if the value contained a template and was edited.\n * Returns `Failure` with `'ignore'` if the rendered value should be ignored, with `'error'` if\n * an error occurs, or with `'inapplicable'` if the value was not a string with a template.\n */\n public editValue(\n value: JsonValue,\n state: JsonEditorState\n ): DetailedResult<JsonValue, JsonEditFailureReason> {\n if (this._options?.useValueTemplates !== false && typeof value === 'string' && value.includes('{{')) {\n const renderResult = this._render(value, state).onSuccess((newValue) => {\n return succeedWithDetail(newValue, 'edited');\n });\n\n if (renderResult.isFailure() && renderResult.detail === 'error') {\n const message = `Cannot render value: ${renderResult.message}`;\n /* c8 ignore next */\n return state.failValidation('invalidPropertyValue', message, this._options?.validation);\n }\n return renderResult;\n }\n return failWithDetail('inapplicable', 'inapplicable');\n }\n\n /**\n * Renders a single template string for a supplied {@link JsonEditorState | editor state}.\n * @param template - The mustache template to be rendered.\n * @param state - The {@link JsonEditorState | editor state} used to render the template.\n * @returns `Success` if the template is rendered. Returns `Failure` with detail `'error'` if the\n * template could not be rendered (e.g. due to syntax errors) or with detail `'inapplicable'` if the\n * string is not a template.\n * @internal\n */\n protected _render(template: string, state: JsonEditorState): DetailedResult<string, JsonEditFailureReason> {\n const vars = state.getVars(this._options?.context);\n if (vars && template.includes('{{')) {\n return captureResult(() => Mustache.render(template, vars)).withDetail('error', 'edited');\n }\n return failWithDetail('inapplicable', 'inapplicable');\n }\n}\n"]}
|