@fgv/ts-json 5.0.0-12 → 5.0.0-15

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.
Files changed (88) hide show
  1. package/.vscode/launch.json +16 -0
  2. package/.vscode/settings.json +32 -0
  3. package/config/api-extractor.json +343 -0
  4. package/config/rig.json +16 -0
  5. package/dist/tsdoc-metadata.json +1 -1
  6. package/lib/test/legacy/jsonConverter.conditional.test.d.ts +2 -0
  7. package/lib/test/legacy/jsonEditor/rules/conditional.test.d.ts +2 -0
  8. package/lib/test/legacy/jsonEditor/rules/multivalue.test.d.ts +2 -0
  9. package/lib/test/legacy/jsonEditor/rules/references.test.d.ts +2 -0
  10. package/lib/test/legacy/jsonEditor/rules/templates.test.d.ts +2 -0
  11. package/lib/test/unit/contextHelpers.test.d.ts +2 -0
  12. package/lib/test/unit/converters.test.d.ts +2 -0
  13. package/lib/test/unit/diff/jsonDiff.test.d.ts +2 -0
  14. package/lib/test/unit/jsonConverter.test.d.ts +2 -0
  15. package/lib/test/unit/jsonEditor/jsonEditor.test.d.ts +2 -0
  16. package/lib/test/unit/jsonEditor/templateContext.test.d.ts +2 -0
  17. package/lib/test/unit/jsonReferenceMap.test.d.ts +2 -0
  18. package/package.json +11 -11
  19. package/src/index.ts +29 -0
  20. package/src/packlets/context/compositeJsonMap.ts +120 -0
  21. package/src/packlets/context/contextHelpers.ts +221 -0
  22. package/src/packlets/context/index.ts +33 -0
  23. package/src/packlets/context/jsonContext.ts +133 -0
  24. package/src/packlets/converters/converters.ts +117 -0
  25. package/src/packlets/converters/index.ts +26 -0
  26. package/src/packlets/converters/jsonConverter.ts +476 -0
  27. package/src/packlets/diff/detailedDiff.ts +585 -0
  28. package/src/packlets/diff/index.ts +24 -0
  29. package/src/packlets/diff/threeWayDiff.ts +420 -0
  30. package/src/packlets/diff/utils.ts +66 -0
  31. package/src/packlets/editor/common.ts +125 -0
  32. package/src/packlets/editor/index.ts +36 -0
  33. package/src/packlets/editor/jsonEditor.ts +523 -0
  34. package/src/packlets/editor/jsonEditorRule.ts +117 -0
  35. package/src/packlets/editor/jsonEditorState.ts +225 -0
  36. package/src/packlets/editor/jsonReferenceMap.ts +516 -0
  37. package/src/packlets/editor/rules/conditional.ts +222 -0
  38. package/src/packlets/editor/rules/index.ts +25 -0
  39. package/src/packlets/editor/rules/multivalue.ts +206 -0
  40. package/src/packlets/editor/rules/references.ts +177 -0
  41. package/src/packlets/editor/rules/templates.ts +159 -0
  42. package/CHANGELOG.md +0 -115
  43. package/lib/index.d.ts.map +0 -1
  44. package/lib/index.js.map +0 -1
  45. package/lib/packlets/context/compositeJsonMap.d.ts.map +0 -1
  46. package/lib/packlets/context/compositeJsonMap.js.map +0 -1
  47. package/lib/packlets/context/contextHelpers.d.ts.map +0 -1
  48. package/lib/packlets/context/contextHelpers.js.map +0 -1
  49. package/lib/packlets/context/index.d.ts.map +0 -1
  50. package/lib/packlets/context/index.js.map +0 -1
  51. package/lib/packlets/context/jsonContext.d.ts.map +0 -1
  52. package/lib/packlets/context/jsonContext.js.map +0 -1
  53. package/lib/packlets/converters/converters.d.ts.map +0 -1
  54. package/lib/packlets/converters/converters.js.map +0 -1
  55. package/lib/packlets/converters/index.d.ts.map +0 -1
  56. package/lib/packlets/converters/index.js.map +0 -1
  57. package/lib/packlets/converters/jsonConverter.d.ts.map +0 -1
  58. package/lib/packlets/converters/jsonConverter.js.map +0 -1
  59. package/lib/packlets/diff/detailedDiff.d.ts.map +0 -1
  60. package/lib/packlets/diff/detailedDiff.js.map +0 -1
  61. package/lib/packlets/diff/index.d.ts.map +0 -1
  62. package/lib/packlets/diff/index.js.map +0 -1
  63. package/lib/packlets/diff/threeWayDiff.d.ts.map +0 -1
  64. package/lib/packlets/diff/threeWayDiff.js.map +0 -1
  65. package/lib/packlets/diff/utils.d.ts.map +0 -1
  66. package/lib/packlets/diff/utils.js.map +0 -1
  67. package/lib/packlets/editor/common.d.ts.map +0 -1
  68. package/lib/packlets/editor/common.js.map +0 -1
  69. package/lib/packlets/editor/index.d.ts.map +0 -1
  70. package/lib/packlets/editor/index.js.map +0 -1
  71. package/lib/packlets/editor/jsonEditor.d.ts.map +0 -1
  72. package/lib/packlets/editor/jsonEditor.js.map +0 -1
  73. package/lib/packlets/editor/jsonEditorRule.d.ts.map +0 -1
  74. package/lib/packlets/editor/jsonEditorRule.js.map +0 -1
  75. package/lib/packlets/editor/jsonEditorState.d.ts.map +0 -1
  76. package/lib/packlets/editor/jsonEditorState.js.map +0 -1
  77. package/lib/packlets/editor/jsonReferenceMap.d.ts.map +0 -1
  78. package/lib/packlets/editor/jsonReferenceMap.js.map +0 -1
  79. package/lib/packlets/editor/rules/conditional.d.ts.map +0 -1
  80. package/lib/packlets/editor/rules/conditional.js.map +0 -1
  81. package/lib/packlets/editor/rules/index.d.ts.map +0 -1
  82. package/lib/packlets/editor/rules/index.js.map +0 -1
  83. package/lib/packlets/editor/rules/multivalue.d.ts.map +0 -1
  84. package/lib/packlets/editor/rules/multivalue.js.map +0 -1
  85. package/lib/packlets/editor/rules/references.d.ts.map +0 -1
  86. package/lib/packlets/editor/rules/references.js.map +0 -1
  87. package/lib/packlets/editor/rules/templates.d.ts.map +0 -1
  88. package/lib/packlets/editor/rules/templates.js.map +0 -1
@@ -0,0 +1,159 @@
1
+ /*
2
+ * Copyright (c) 2020 Erik Fortune
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in all
12
+ * copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+ import { JsonObject, JsonValue } from '@fgv/ts-json-base';
24
+ import { DetailedResult, Result, captureResult, failWithDetail, succeedWithDetail } from '@fgv/ts-utils';
25
+ import { IJsonEditorOptions, JsonEditFailureReason, JsonPropertyEditFailureReason } from '../common';
26
+ import { JsonEditorRuleBase } from '../jsonEditorRule';
27
+ import { JsonEditorState } from '../jsonEditorState';
28
+
29
+ import Mustache from 'mustache';
30
+
31
+ /**
32
+ * Configuration options for the {@link EditorRules.TemplatedJsonEditorRule | Templated JSON editor rule}.
33
+ * @public
34
+ */
35
+ export interface ITemplatedJsonRuleOptions extends Partial<IJsonEditorOptions> {
36
+ /**
37
+ * If `true` (default) then templates in property names are rendered
38
+ */
39
+ useNameTemplates?: boolean;
40
+ /**
41
+ * If `true` (default) then templates in property values are rendered
42
+ */
43
+ useValueTemplates?: boolean;
44
+ }
45
+
46
+ /**
47
+ * The {@link EditorRules.TemplatedJsonEditorRule | Templated JSON editor rule} applies mustache rendering as
48
+ * appropriate to any keys or values in the object being edited.
49
+ * @public
50
+ */
51
+ export class TemplatedJsonEditorRule extends JsonEditorRuleBase {
52
+ /**
53
+ * Fully-resolved {@link EditorRules.ITemplatedJsonRuleOptions | configuration options} for this rule.
54
+ * @public
55
+ */
56
+ protected _options?: ITemplatedJsonRuleOptions;
57
+
58
+ /**
59
+ * Creates a new {@link EditorRules.TemplatedJsonEditorRule | TemplatedJsonEditorRule}.
60
+ * @param options - Optional {@link EditorRules.ITemplatedJsonRuleOptions | configuration options}
61
+ * for this rule.
62
+ */
63
+ public constructor(options?: ITemplatedJsonRuleOptions) {
64
+ super();
65
+ this._options = options;
66
+ }
67
+
68
+ /**
69
+ * Creates a new {@link EditorRules.TemplatedJsonEditorRule | TemplatedJsonEditorRule}.
70
+ * @param options - Optional {@link EditorRules.ITemplatedJsonRuleOptions | configuration options}
71
+ * for this rule.
72
+ */
73
+ public static create(options?: ITemplatedJsonRuleOptions): Result<TemplatedJsonEditorRule> {
74
+ return captureResult(() => new TemplatedJsonEditorRule(options));
75
+ }
76
+
77
+ /**
78
+ * Evaluates a property name for template rendering.
79
+ * @param key - The key of the property to be considered.
80
+ * @param value - The `JsonValue` of the property to be considered.
81
+ * @param state - The {@link JsonEditorState | editor state} for the object being edited.
82
+ * @returns `Success` with detail `'edited'` and an `JsonObject` to
83
+ * be flattened and merged if the key contained a template. Returns `Failure` with detail `'error'`
84
+ * if an error occurred or with detail `'inapplicable'` if the property key does not contain
85
+ * a template or if name rendering is disabled.
86
+ */
87
+ public editProperty(
88
+ key: string,
89
+ value: JsonValue,
90
+ state: JsonEditorState
91
+ ): DetailedResult<JsonObject, JsonPropertyEditFailureReason> {
92
+ /* c8 ignore next 2 */
93
+ const validation = this._options?.validation;
94
+ const useNameTemplates = this._options?.useNameTemplates !== false;
95
+
96
+ if (useNameTemplates !== false) {
97
+ const result = this._render(key, state).onSuccess((newKey) => {
98
+ if (newKey.length < 1) {
99
+ return state.failValidation('invalidPropertyName', `Template "${key}" renders empty name.`);
100
+ }
101
+
102
+ const rtrn: JsonObject = {};
103
+ rtrn[newKey] = value;
104
+ return succeedWithDetail<JsonObject, JsonEditFailureReason>(rtrn, 'edited');
105
+ });
106
+
107
+ if (result.isFailure() && result.detail === 'error') {
108
+ const message = `Cannot render name ${key}: ${result.message}`;
109
+ return state.failValidation('invalidPropertyName', message, validation);
110
+ }
111
+ return result;
112
+ }
113
+ return failWithDetail('inapplicable', 'inapplicable');
114
+ }
115
+
116
+ /**
117
+ * Evaluates a property, array or literal value for template rendering.
118
+ * @param value - The `JsonValue` to be edited.
119
+ * @param state - The {@link JsonEditorState | editor state} for the object being edited.
120
+ * @returns `Success` with detail `'edited'` if the value contained a template and was edited.
121
+ * Returns `Failure` with `'ignore'` if the rendered value should be ignored, with `'error'` if
122
+ * an error occurs, or with `'inapplicable'` if the value was not a string with a template.
123
+ */
124
+ public editValue(
125
+ value: JsonValue,
126
+ state: JsonEditorState
127
+ ): DetailedResult<JsonValue, JsonEditFailureReason> {
128
+ if (this._options?.useValueTemplates !== false && typeof value === 'string' && value.includes('{{')) {
129
+ const renderResult = this._render(value, state).onSuccess((newValue) => {
130
+ return succeedWithDetail(newValue, 'edited');
131
+ });
132
+
133
+ if (renderResult.isFailure() && renderResult.detail === 'error') {
134
+ const message = `Cannot render value: ${renderResult.message}`;
135
+ /* c8 ignore next */
136
+ return state.failValidation('invalidPropertyValue', message, this._options?.validation);
137
+ }
138
+ return renderResult;
139
+ }
140
+ return failWithDetail('inapplicable', 'inapplicable');
141
+ }
142
+
143
+ /**
144
+ * Renders a single template string for a supplied {@link JsonEditorState | editor state}.
145
+ * @param template - The mustache template to be rendered.
146
+ * @param state - The {@link JsonEditorState | editor state} used to render the template.
147
+ * @returns `Success` if the template is rendered. Returns `Failure` with detail `'error'` if the
148
+ * template could not be rendered (e.g. due to syntax errors) or with detail `'inapplicable'` if the
149
+ * string is not a template.
150
+ * @internal
151
+ */
152
+ protected _render(template: string, state: JsonEditorState): DetailedResult<string, JsonEditFailureReason> {
153
+ const vars = state.getVars(this._options?.context);
154
+ if (vars && template.includes('{{')) {
155
+ return captureResult(() => Mustache.render(template, vars)).withDetail('error', 'edited');
156
+ }
157
+ return failWithDetail('inapplicable', 'inapplicable');
158
+ }
159
+ }
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
-
@@ -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,YAAY,GACrB,cAAc,CAAC,SAAS,EAAE,6BAA6B,CAAC;CAW5D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"compositeJsonMap.js","sourceRoot":"","sources":["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sB;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,aAAa,EAAE,GACrB,MAAM,CAAC,YAAY,GAAG,SAAS,CAAC;IAQnC;;;;;;;;;OASG;WACW,iBAAiB,CAC7B,WAAW,EAAE,YAAY,GAAG,SAAS,EACrC,IAAI,CAAC,EAAE,iB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I;iBACnC,CAAC;gBACF,IAAI,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,CAAC;oBACrC,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;gBACnC,CAAC;qBAAM,IAAI,WAAW,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,CAAC;oBACpD,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC;gBAC3C,CAAC;gBACD,OAAO,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC;YACvB,CAAC;YACD,OAAO,IAAA,kBAAO,EAAC,WAAW,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IAED;;;;;;;OAOG;IACI,UAAU,CAAC,IAAsB;QACtC,OAAO,iBAAiB,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;OAOG;IACI,UAAU,CAAC,IAA0B;QAC1C,OAAO,iBAAiB,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;;OAQG;IACI,aAAa,CAAC,GAGpB;QACC,OAAO,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;;OAQG;IACI,YAAY,CAAC,KAAoB;QACtC,OAAO,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;CACF;AAxLD,8CAwLC","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 { 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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AAiB,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,MAAM,YAAY,CAAC;AAC1C,OAAO,EAEL,+BAA+B,EAC/B,aAAa,EAEb,wBAAwB,EAExB,6BAA6B,EAC9B,MAAM,iBAAiB,CAAC;AAEzB;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,aAAmC,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,CAAC,UAAU,EAAE,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B,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;;;;;;OAMG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAE7B;;;OAGG;IACH,0BAA0B,EAAE,OAAO,CAAC;IAEpC;;;;;;;;OAQG;IACH,0BAA0B,EAAE,OAAO,CAAC;IAEpC;;;;OAIG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,0BAA0B,CAAC;IAExC;;;;;;;OAOG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;;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AAG,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC;AAE5E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;;;OAQG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,IAAI,EAAE,cAAc,CAAC;IAErB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;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AAQ,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;IACH,QAAQ,EAAE,qBAAqB,CAAC;IAEhC;;;;;;OAMG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AA4GD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmHG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC,aAAa,CAAC,CAmBxF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"threeWayDiff.js","sourceRoot":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,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmHG;AACH,SAAgB,gBAAgB,CAAC,IAAe,EAAE,IAAe;IAC/D,MAAM,QAAQ,GAA0B;QACtC,OAAO,EAAE,CAAC;QACV,KAAK,EAAE,CAAC;QACR,QAAQ,EAAE,CAAC;QACX,SAAS,EAAE,CAAC;KACb,CAAC;IAEF,MAAM,IAAI,GAAG,2BAA2B,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAE/D,MAAM,MAAM,GAAkB;QAC5B,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,QAAQ;QACR,SAAS,EAAE,QAAQ,CAAC,OAAO,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,KAAK,CAAC,IAAI,QAAQ,CAAC,QAAQ,KAAK,CAAC;KACrF,CAAC;IAEF,OAAO,IAAA,kBAAO,EAAC,MAAM,CAAC,CAAC;AACzB,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 { 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"]}