jtlt 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +5 -0
- package/README.md +9 -5
- package/demo/calltemplate-params-demo.js +19 -15
- package/demo/codemirror.esm.js +140 -70
- package/demo/codemirror.js +9 -5
- package/demo/index.js +2 -1
- package/demo/vendor/fontoxpath/dist/fontoxpath.esm.js +508 -499
- package/demo/vendor/jamilih/dist/jml.mjs +516 -225
- package/demo/vendor/jsonpath-plus/dist/index-browser-esm.js +11 -5
- package/dist/AbstractJoiningTransformer.d.ts +12 -20
- package/dist/AbstractJoiningTransformer.d.ts.map +1 -1
- package/dist/DOMJoiningTransformer.d.ts +502 -19
- package/dist/DOMJoiningTransformer.d.ts.map +1 -1
- package/dist/JSONJoiningTransformer.d.ts +41 -25
- package/dist/JSONJoiningTransformer.d.ts.map +1 -1
- package/dist/JSONPathTransformer.d.ts +20 -20
- package/dist/JSONPathTransformer.d.ts.map +1 -1
- package/dist/JSONPathTransformerContext.d.ts +103 -80
- package/dist/JSONPathTransformerContext.d.ts.map +1 -1
- package/dist/StringJoiningTransformer.d.ts +42 -28
- package/dist/StringJoiningTransformer.d.ts.map +1 -1
- package/dist/XPathTransformer.d.ts +11 -11
- package/dist/XPathTransformer.d.ts.map +1 -1
- package/dist/XPathTransformerContext.d.ts +47 -45
- package/dist/XPathTransformerContext.d.ts.map +1 -1
- package/dist/XSLTStyleJSONPathResolver.d.ts +1 -1
- package/dist/XSLTStyleJSONPathResolver.d.ts.map +1 -1
- package/dist/index-browser.d.ts +2 -2
- package/dist/index-browser.d.ts.map +1 -1
- package/dist/index-node.d.ts +2 -2
- package/dist/index-node.d.ts.map +1 -1
- package/dist/index.d.ts +126 -167
- package/dist/index.d.ts.map +1 -1
- package/docs/API.expanded.md +6 -4
- package/docs/API.md +1 -1
- package/docs/TO-DO.md +4 -2
- package/eslint.config.js +17 -1
- package/package.json +23 -22
- package/pnpm-workspace.yaml +32 -4
- package/rollup.config.js +42 -0
- package/src/AbstractJoiningTransformer.js +8 -1
- package/src/DOMJoiningTransformer.js +56 -27
- package/src/JSONJoiningTransformer.js +64 -44
- package/src/JSONPathTransformer.js +86 -85
- package/src/JSONPathTransformerContext.js +95 -48
- package/src/StringJoiningTransformer.js +48 -23
- package/src/XPathTransformer.js +18 -14
- package/src/XPathTransformerContext.js +173 -123
- package/src/index-browser.js +1 -0
- package/src/index-node.js +2 -0
- package/src/index.js +125 -68
- package/test.html +17 -0
- package/test.js +45 -0
- package/tsconfig-prod.json +1 -0
- package/tsconfig.json +3 -2
- package/dist/types.d.ts +0 -204
- package/dist/types.d.ts.map +0 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export type ObjectCallback = (this
|
|
3
|
-
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
|
|
1
|
+
import AbstractJoiningTransformer from './AbstractJoiningTransformer.js';
|
|
2
|
+
export type ObjectCallback = (@this {JSONJoiningTransformer}
|
|
3
|
+
* : JSONJoiningTransformer, obj: Record<string, unknown>) => void;
|
|
4
|
+
export type ArrayCallback = (@this {JSONJoiningTransformer}
|
|
5
|
+
* : JSONJoiningTransformer, arr: any[]) => void;
|
|
6
|
+
export type SimpleCallback<T = "json"> = (@this {T extends "json" ? JSONJoiningTransformer :
|
|
7
|
+
* T extends "string" ? import('./StringJoiningTransformer.js').default
|
|
8
|
+
* : import('./DOMJoiningTransformer.js').default}
|
|
9
|
+
* : T extends "json" ? JSONJoiningTransformer : T extends "string" ? import('./StringJoiningTransformer.js').default : import('./DOMJoiningTransformer.js').default) => void;
|
|
9
10
|
export type ElementAttributes = Record<string, unknown> & {
|
|
10
11
|
dataset?: Record<string, string>;
|
|
11
12
|
$a?: [string, string][];
|
|
@@ -56,14 +57,9 @@ export type ElementInfo = {
|
|
|
56
57
|
* boolean/null add primitives accordingly. It does not perform HTML escaping
|
|
57
58
|
* or string serialization; it builds real JS values.
|
|
58
59
|
* @extends {AbstractJoiningTransformer<"json">}
|
|
60
|
+
* @template {import('./AbstractJoiningTransformer.js').JSONJoiningTransformerConfig} [TConfig=import('./AbstractJoiningTransformer.js').JSONJoiningTransformerConfig]
|
|
59
61
|
*/
|
|
60
|
-
declare class JSONJoiningTransformer extends AbstractJoiningTransformer<"json"> {
|
|
61
|
-
/**
|
|
62
|
-
* @param {any[]|Record<string, unknown>} [o] - Initial object or array
|
|
63
|
-
* @param {import('./AbstractJoiningTransformer.js').
|
|
64
|
-
* JSONJoiningTransformerConfig} [cfg] - Configuration object
|
|
65
|
-
*/
|
|
66
|
-
constructor(o?: any[] | Record<string, unknown>, cfg?: import("./AbstractJoiningTransformer.js").JSONJoiningTransformerConfig);
|
|
62
|
+
declare class JSONJoiningTransformer<TConfig extends import('./AbstractJoiningTransformer.js').JSONJoiningTransformerConfig = import('./AbstractJoiningTransformer.js').JSONJoiningTransformerConfig> extends AbstractJoiningTransformer<"json"> {
|
|
67
63
|
/** @type {any[]|Record<string, unknown>} */
|
|
68
64
|
_obj: any[] | Record<string, unknown>;
|
|
69
65
|
/** @type {any} */
|
|
@@ -84,6 +80,21 @@ declare class JSONJoiningTransformer extends AbstractJoiningTransformer<"json">
|
|
|
84
80
|
document: any;
|
|
85
81
|
format?: string;
|
|
86
82
|
}>;
|
|
83
|
+
root: any;
|
|
84
|
+
/** @type {any} */
|
|
85
|
+
_outputConfig: any;
|
|
86
|
+
/**
|
|
87
|
+
* @template {import('./AbstractJoiningTransformer.js').JSONJoiningTransformerConfig} T
|
|
88
|
+
* @param {any[]|Record<string, unknown>} [o] - Initial JSON object or array
|
|
89
|
+
* @param {T} [cfg] - Configuration options
|
|
90
|
+
* @returns {JSONJoiningTransformer<T>}
|
|
91
|
+
*/
|
|
92
|
+
static create<T extends import('./AbstractJoiningTransformer.js').JSONJoiningTransformerConfig>(o?: any[] | Record<string, unknown>, cfg?: T): JSONJoiningTransformer<T>;
|
|
93
|
+
/**
|
|
94
|
+
* @param {any[]|Record<string, unknown>} [o] - Initial JSON object or array
|
|
95
|
+
* @param {import('./AbstractJoiningTransformer.js').JSONJoiningTransformerConfig} [cfg] - Configuration options
|
|
96
|
+
*/
|
|
97
|
+
constructor(o?: any[] | Record<string, unknown>, cfg?: import('./AbstractJoiningTransformer.js').JSONJoiningTransformerConfig);
|
|
87
98
|
/**
|
|
88
99
|
* Directly appends an item to the internal array without checks.
|
|
89
100
|
* @param {any} item - Item to append
|
|
@@ -106,9 +117,9 @@ declare class JSONJoiningTransformer extends AbstractJoiningTransformer<"json">
|
|
|
106
117
|
* Gets the current object or array. If unwrapSingleResult config option is
|
|
107
118
|
* enabled and the root array contains exactly one element, returns that
|
|
108
119
|
* element directly (unwrapped).
|
|
109
|
-
* @returns {any[]|Record<string, unknown>|any}
|
|
120
|
+
* @returns {TConfig['exposeDocuments'] extends true ? any[] : any[]|Record<string, unknown>|any}
|
|
110
121
|
*/
|
|
111
|
-
get(): any[] | Record<string, unknown> | any;
|
|
122
|
+
get(): TConfig['exposeDocuments'] extends true ? any[] : any[] | Record<string, unknown> | any;
|
|
112
123
|
/**
|
|
113
124
|
* Sets a property value on the current object.
|
|
114
125
|
* @param {string} prop - Property name
|
|
@@ -124,7 +135,7 @@ declare class JSONJoiningTransformer extends AbstractJoiningTransformer<"json">
|
|
|
124
135
|
*/
|
|
125
136
|
mapEntry(prop: string, val: any): void;
|
|
126
137
|
/**
|
|
127
|
-
* @param {Record<string, unknown>|ObjectCallback} [objOrCb]
|
|
138
|
+
* @param {null|Record<string, unknown>|ObjectCallback} [objOrCb]
|
|
128
139
|
* Seed object or callback.
|
|
129
140
|
* @param {ObjectCallback|any[]} [cbOrUsePropertySets] Callback or sets.
|
|
130
141
|
* @param {any[]|Record<string, unknown>} [usePropertySetsOrPropSets]
|
|
@@ -132,7 +143,7 @@ declare class JSONJoiningTransformer extends AbstractJoiningTransformer<"json">
|
|
|
132
143
|
* @param {Record<string, unknown>} [propSets] Key-value pairs to add.
|
|
133
144
|
* @returns {JSONJoiningTransformer}
|
|
134
145
|
*/
|
|
135
|
-
object(objOrCb?: Record<string, unknown> | ObjectCallback, cbOrUsePropertySets?: ObjectCallback | any[], usePropertySetsOrPropSets?: any[] | Record<string, unknown>, propSets?: Record<string, unknown>): JSONJoiningTransformer;
|
|
146
|
+
object(objOrCb?: null | Record<string, unknown> | ObjectCallback, cbOrUsePropertySets?: ObjectCallback | any[], usePropertySetsOrPropSets?: any[] | Record<string, unknown>, propSets?: Record<string, unknown>): JSONJoiningTransformer;
|
|
136
147
|
/**
|
|
137
148
|
* Alias for object(). Build an object/map.
|
|
138
149
|
* @param {Record<string, unknown>|ObjectCallback} [objOrCb]
|
|
@@ -146,11 +157,11 @@ declare class JSONJoiningTransformer extends AbstractJoiningTransformer<"json">
|
|
|
146
157
|
map(objOrCb?: Record<string, unknown> | ObjectCallback, cbOrUsePropertySets?: ObjectCallback | any[], usePropertySetsOrPropSets?: any[] | Record<string, unknown>, propSets?: Record<string, unknown>): JSONJoiningTransformer;
|
|
147
158
|
/**
|
|
148
159
|
* Creates a new array and executes a callback in its context.
|
|
149
|
-
* @param {any[]|ArrayCallback} [arrOrCb] Seed array or callback.
|
|
160
|
+
* @param {any[]|ArrayCallback|null} [arrOrCb] Seed array or callback.
|
|
150
161
|
* @param {ArrayCallback} [cb] Callback when first arg was array.
|
|
151
162
|
* @returns {JSONJoiningTransformer}
|
|
152
163
|
*/
|
|
153
|
-
array(arrOrCb?: any[] | ArrayCallback, cb?: ArrayCallback): JSONJoiningTransformer;
|
|
164
|
+
array(arrOrCb?: any[] | ArrayCallback | null, cb?: ArrayCallback): JSONJoiningTransformer;
|
|
154
165
|
/**
|
|
155
166
|
* Appends a string value.
|
|
156
167
|
* @param {string} str String value.
|
|
@@ -206,13 +217,18 @@ declare class JSONJoiningTransformer extends AbstractJoiningTransformer<"json">
|
|
|
206
217
|
* @returns {JSONJoiningTransformer}
|
|
207
218
|
*/
|
|
208
219
|
element(elem: string | Element, atts?: ElementAttributes | any[] | SimpleCallback, childNodes?: any[] | SimpleCallback, cb?: SimpleCallback, useAttributeSets?: string[]): JSONJoiningTransformer;
|
|
209
|
-
root: any;
|
|
210
220
|
/**
|
|
211
221
|
* @param {string} prefix
|
|
212
222
|
* @param {string} namespaceURI
|
|
213
223
|
* @returns {JSONJoiningTransformer}
|
|
214
224
|
*/
|
|
215
225
|
namespace(prefix: string, namespaceURI: string): JSONJoiningTransformer;
|
|
226
|
+
/**
|
|
227
|
+
* @param {string} prefix
|
|
228
|
+
* @returns {void}
|
|
229
|
+
* @override
|
|
230
|
+
*/
|
|
231
|
+
_flushPendingNamespace(prefix: string): void;
|
|
216
232
|
/**
|
|
217
233
|
* Adds/updates an attribute for the most recently open element built via
|
|
218
234
|
* a callback-driven element(). When not in an element callback context,
|
|
@@ -266,7 +282,7 @@ declare class JSONJoiningTransformer extends AbstractJoiningTransformer<"json">
|
|
|
266
282
|
* Output configuration for the document (encoding, doctype, etc.)
|
|
267
283
|
* @returns {JSONJoiningTransformer}
|
|
268
284
|
*/
|
|
269
|
-
document(cb: (this: JSONJoiningTransformer) => void, cfg?: import(
|
|
285
|
+
document(cb: (this: JSONJoiningTransformer) => void, cfg?: import('./StringJoiningTransformer.js').OutputConfig): JSONJoiningTransformer;
|
|
270
286
|
/**
|
|
271
287
|
* Creates a new result document with metadata (href, format).
|
|
272
288
|
* Similar to XSLT's xsl:result-document, this allows templates to generate
|
|
@@ -280,7 +296,7 @@ declare class JSONJoiningTransformer extends AbstractJoiningTransformer<"json">
|
|
|
280
296
|
* Output configuration for the document (encoding, doctype, format, etc.)
|
|
281
297
|
* @returns {JSONJoiningTransformer}
|
|
282
298
|
*/
|
|
283
|
-
resultDocument(href: string, cb: (this: JSONJoiningTransformer) => void, cfg?: import(
|
|
299
|
+
resultDocument(href: string, cb: (this: JSONJoiningTransformer) => void, cfg?: import('./StringJoiningTransformer.js').OutputConfig): JSONJoiningTransformer;
|
|
284
300
|
/**
|
|
285
301
|
* Helper method to use property sets.
|
|
286
302
|
* @param {Record<string, unknown>} obj - Object to which to apply
|
|
@@ -290,5 +306,5 @@ declare class JSONJoiningTransformer extends AbstractJoiningTransformer<"json">
|
|
|
290
306
|
*/
|
|
291
307
|
_usePropertySets(obj: Record<string, unknown>, psName: string): Record<string, unknown>;
|
|
292
308
|
}
|
|
293
|
-
|
|
309
|
+
export default JSONJoiningTransformer;
|
|
294
310
|
//# sourceMappingURL=JSONJoiningTransformer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSONJoiningTransformer.d.ts","sourceRoot":"","sources":["../src/JSONJoiningTransformer.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"JSONJoiningTransformer.d.ts","sourceRoot":"","sources":["../src/JSONJoiningTransformer.js"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,MAAM,iCAAiC,CAAC;AAatE,YAAU,cAAc,GACxB,CAAA;GACA,EADO,sBACP,EAAiC,GAAG,EAA5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAC9B,KAAU,IACZ,CAAA;AAEE,YAAU,aAAa,GACvB,CAAA;GACA,EADO,sBACP,EAAe,GAAG,EAAV,GAAG,EACX,KAAU,IACZ,CAAA;AAGE,YAAU,cAAc,CADb,CAAC,GAAG,MAAO,IAEtB,CAAA;;;GAGA,EAHO,CAAC,SAAS,MAAM,GAAG,sBAAsB,GAC9C,CAAC,SAAS,QAAQ,GAAG,OAAO,+BAA+B,EAAE,OAAO,GAClE,OAAO,4BAA4B,EAAE,OACzC,KAAU,IACZ,CAAA;AAKE,YAGG,iBAAiB,GAHV,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;CACxB,CAAmB;AAIpB,YAGG,WAAW,GAHJ;I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ext.js';
|
|
2
2
|
/**
|
|
3
3
|
* Applies named JSONPath-driven templates to JSON data.
|
|
4
4
|
*
|
|
@@ -6,24 +6,23 @@ export default JSONPathTransformer;
|
|
|
6
6
|
* optional `mode`), sorts by priority, and invokes the winning template.
|
|
7
7
|
* If no template matches, built-in default rules emulate XSLT-like behavior
|
|
8
8
|
* for objects, arrays, scalars, etc.
|
|
9
|
-
* @template T
|
|
9
|
+
* @template {"json"|"string"|"dom"} [T="json"]
|
|
10
10
|
*/
|
|
11
|
-
declare class JSONPathTransformer<T> {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
static makeJSONPathAbsolute(select: string): string;
|
|
11
|
+
declare class JSONPathTransformer<T extends "json" | "string" | "dom" = "json"> {
|
|
12
|
+
_config: import("./JSONPathTransformerContext.js").JSONPathTransformerContextConfig<T>;
|
|
13
|
+
/** @type {import('./index.js').JSONPathTemplateObject<T>[]} */
|
|
14
|
+
rootTemplates: import('./index.js').JSONPathTemplateObject<T>[];
|
|
15
|
+
templates: import("./index.js").JSONPathTemplateObject<T>[];
|
|
17
16
|
static DefaultTemplateRules: {
|
|
18
17
|
transformRoot: {
|
|
19
18
|
/**
|
|
20
|
-
* @template U
|
|
19
|
+
* @template {"json"|"string"|"dom"} U
|
|
21
20
|
* @this {JSONPathTransformerContext<U>}
|
|
22
21
|
* @param {any} value - Value
|
|
23
22
|
* @param {{mode?: string}} cfg - Configuration
|
|
24
23
|
* @returns {void}
|
|
25
24
|
*/
|
|
26
|
-
template<U>(this: JSONPathTransformerContext<U>, value: any, cfg: {
|
|
25
|
+
template<U extends "json" | "string" | "dom">(this: JSONPathTransformerContext<U>, value: any, cfg: {
|
|
27
26
|
mode?: string;
|
|
28
27
|
}): void;
|
|
29
28
|
};
|
|
@@ -41,7 +40,7 @@ declare class JSONPathTransformer<T> {
|
|
|
41
40
|
* @param {{mode?: string}} cfg - Configuration
|
|
42
41
|
* @returns {void}
|
|
43
42
|
*/
|
|
44
|
-
template(this: JSONPathTransformerContext
|
|
43
|
+
template(this: JSONPathTransformerContext, value: any, cfg: {
|
|
45
44
|
mode?: string;
|
|
46
45
|
}): void;
|
|
47
46
|
};
|
|
@@ -52,7 +51,7 @@ declare class JSONPathTransformer<T> {
|
|
|
52
51
|
* @param {{mode?: string}} cfg - Configuration
|
|
53
52
|
* @returns {void}
|
|
54
53
|
*/
|
|
55
|
-
template(this: JSONPathTransformerContext
|
|
54
|
+
template(this: JSONPathTransformerContext, value: any, cfg: {
|
|
56
55
|
mode?: string;
|
|
57
56
|
}): void;
|
|
58
57
|
};
|
|
@@ -61,7 +60,7 @@ declare class JSONPathTransformer<T> {
|
|
|
61
60
|
* @this {JSONPathTransformerContext}
|
|
62
61
|
* @returns {JSONPathTransformerContext}
|
|
63
62
|
*/
|
|
64
|
-
template(this: JSONPathTransformerContext
|
|
63
|
+
template(this: JSONPathTransformerContext): JSONPathTransformerContext;
|
|
65
64
|
};
|
|
66
65
|
transformFunctions: {
|
|
67
66
|
/**
|
|
@@ -71,15 +70,16 @@ declare class JSONPathTransformer<T> {
|
|
|
71
70
|
template(value: (...args: any[]) => any): any;
|
|
72
71
|
};
|
|
73
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} select - JSONPath selector
|
|
75
|
+
* @returns {string} Absolute JSONPath
|
|
76
|
+
*/
|
|
77
|
+
static makeJSONPathAbsolute(select: string): string;
|
|
74
78
|
/**
|
|
75
79
|
* @param {import('./JSONPathTransformerContext.js').
|
|
76
80
|
* JSONPathTransformerContextConfig<T>} config - Configuration object
|
|
77
81
|
*/
|
|
78
|
-
constructor(config: import(
|
|
79
|
-
_config: import("./JSONPathTransformerContext.js").JSONPathTransformerContextConfig<T>;
|
|
80
|
-
/** @type {import('./index.js').JSONPathTemplateObject<T>[]} */
|
|
81
|
-
rootTemplates: import("./index.js").JSONPathTemplateObject<T>[];
|
|
82
|
-
templates: import("./index.js").JSONPathTemplateObject<T>[];
|
|
82
|
+
constructor(config: import('./JSONPathTransformerContext.js').JSONPathTransformerContextConfig<T>);
|
|
83
83
|
/**
|
|
84
84
|
* @returns {void}
|
|
85
85
|
*/
|
|
@@ -88,7 +88,7 @@ declare class JSONPathTransformer<T> {
|
|
|
88
88
|
* @param {string} [mode] - Transformation mode
|
|
89
89
|
* @returns {import('./index.js').ResultType<T>} The transformation result
|
|
90
90
|
*/
|
|
91
|
-
transform(mode?: string): import(
|
|
91
|
+
transform(mode?: string): import('./index.js').ResultType<T>;
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
export default JSONPathTransformer;
|
|
94
94
|
//# sourceMappingURL=JSONPathTransformer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSONPathTransformer.d.ts","sourceRoot":"","sources":["../src/JSONPathTransformer.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"JSONPathTransformer.d.ts","sourceRoot":"","sources":["../src/JSONPathTransformer.js"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,MAAM,iCAAiC,CAAC;AAEzE;;;;;;;;GAQG;AACH,cAAM,mBAAmB,CAFa,CAAC,SAAzB,MAAM,GAAC,QAAQ,GAAC,KAAK,GAAK,MAAO;IA2FtC,OAAO;IACZ,+DAA+D;IAC1D,aAAa,EADP,OAAO,YAAY,EAAE,sBAAsB,CAAC,CAAC,CAAC,EAAE;IAKtD,SAAS;IA7FhB,MAAM,CAAC,oBAAoB;QACzB,aAAa;YACX;;;;;;eAMG;YACH,QAAQ,CAN6B,CAAC,SAAxB,MAAM,GAAC,QAAQ,GAAC,KAAQ,QAC5B,0BAA0B,CAAC,CAAC,CAAC,SAC5B,GAAG,OACH;gBAAC,IAAI,CAAC,EAAE,MAAM,CAAA;aAAC,GACb,IAAI;;QAMnB,sBAAsB;YACpB;;;eAGG;YACH,QAAQ,QAHG,GAAG,GACD,GAAG;;QAUlB,gBAAgB;YACd;;;;;eAKG;YACH,QAAQ,OALE,0BAA0B,SACzB,GAAG,OACH;gBAAC,IAAI,CAAC,EAAE,MAAM,CAAA;aAAC,GACb,IAAI;;QAMnB,eAAe;YACb;;;;;eAKG;YACH,QAAQ,OALE,0BAA0B,SACzB,GAAG,OACH;gBAAC,IAAI,CAAC,EAAE,MAAM,CAAA;aAAC,GACb,IAAI;;QAMnB,gBAAgB;YACd;;;eAGG;YACH,QAAQ,OAHE,0BAA0B,GACvB,0BAA0B;;QAMzC,kBAAkB;YAChB;;;eAGG;YACH,QAAQ,QAHG,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GACtB,GAAG;;MAOlB;IAEF;;;OAGG;IACH,MAAM,CAAC,oBAAoB,CAAE,MAAM,EAHxB,MAGwB,GAFtB,MAAM,CAQlB;IAED;;;OAGG;IACH,YAAa,MAAM,EAHR,OAAO,iCAAiC,EAC9C,gCAAgC,CAAC,CAAC,CAEpB,EAoClB;IAED;;OAEG;IACH,0BAA0B,IAFb,IAAI,CAShB;IAED;;;OAGG;IACH,SAAS,CAAE,IAAI,AAHZ,CACA,EADQ,MAGI,GAFF,OAAO,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,CAiC9C;CACF;eAEc,mBAAmB"}
|
|
@@ -1,49 +1,45 @@
|
|
|
1
|
-
export default JSONPathTransformerContext;
|
|
2
|
-
/**
|
|
3
|
-
* Decimal format symbols for number formatting.
|
|
4
|
-
*/
|
|
5
1
|
export type DecimalFormatSymbols = {
|
|
6
2
|
/**
|
|
7
3
|
* - Character for decimal point
|
|
8
4
|
*/
|
|
9
|
-
decimalSeparator?: string
|
|
5
|
+
decimalSeparator?: string;
|
|
10
6
|
/**
|
|
11
7
|
* - Character for thousands
|
|
12
8
|
*/
|
|
13
|
-
groupingSeparator?: string
|
|
9
|
+
groupingSeparator?: string;
|
|
14
10
|
/**
|
|
15
11
|
* - Character for percent
|
|
16
12
|
*/
|
|
17
|
-
percent?: string
|
|
13
|
+
percent?: string;
|
|
18
14
|
/**
|
|
19
15
|
* - Character for per-mille
|
|
20
16
|
*/
|
|
21
|
-
perMille?: string
|
|
17
|
+
perMille?: string;
|
|
22
18
|
/**
|
|
23
19
|
* - Character for zero
|
|
24
20
|
*/
|
|
25
|
-
zeroDigit?: string
|
|
21
|
+
zeroDigit?: string;
|
|
26
22
|
/**
|
|
27
23
|
* - Character for digit placeholder
|
|
28
24
|
*/
|
|
29
|
-
digit?: string
|
|
25
|
+
digit?: string;
|
|
30
26
|
/**
|
|
31
27
|
* - Character separating
|
|
32
28
|
* positive/negative patterns
|
|
33
29
|
*/
|
|
34
|
-
patternSeparator?: string
|
|
30
|
+
patternSeparator?: string;
|
|
35
31
|
/**
|
|
36
32
|
* - Character for minus sign
|
|
37
33
|
*/
|
|
38
|
-
minusSign?: string
|
|
34
|
+
minusSign?: string;
|
|
39
35
|
/**
|
|
40
36
|
* - String for infinity
|
|
41
37
|
*/
|
|
42
|
-
infinity?: string
|
|
38
|
+
infinity?: string;
|
|
43
39
|
/**
|
|
44
40
|
* - String for NaN
|
|
45
41
|
*/
|
|
46
|
-
NaN?: string
|
|
42
|
+
NaN?: string;
|
|
47
43
|
};
|
|
48
44
|
export type NumberValue = number | string | {
|
|
49
45
|
value?: number | string;
|
|
@@ -55,25 +51,31 @@ export type NumberValue = number | string | {
|
|
|
55
51
|
lang?: string;
|
|
56
52
|
letterValue?: string;
|
|
57
53
|
};
|
|
58
|
-
|
|
59
|
-
* Sort spec types used by applyTemplates() and forEach().
|
|
60
|
-
*/
|
|
61
|
-
export type SortObject = {
|
|
54
|
+
export type SortObject<V = unknown> = {
|
|
62
55
|
select?: string;
|
|
63
|
-
order?:
|
|
64
|
-
type?:
|
|
56
|
+
order?: 'ascending' | 'descending';
|
|
57
|
+
type?: 'text' | 'number';
|
|
65
58
|
locale?: string;
|
|
66
59
|
localeOptions?: unknown;
|
|
67
60
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
export type
|
|
76
|
-
|
|
61
|
+
export type SortComparator<V = unknown> = (a: V, b: V, ctx: JSONPathTransformerContext) => number;
|
|
62
|
+
export type SortSpec<V = unknown> = string | SortObject | SortComparator | Array<string | SortObject>;
|
|
63
|
+
export type JoiningTransformerMap = {
|
|
64
|
+
json: import('./JSONJoiningTransformer.js').default;
|
|
65
|
+
string: import('./StringJoiningTransformer.js').default;
|
|
66
|
+
dom: import('./DOMJoiningTransformer.js').default;
|
|
67
|
+
};
|
|
68
|
+
export type AppendItemMap = {
|
|
69
|
+
json: unknown;
|
|
70
|
+
string: string | unknown;
|
|
71
|
+
dom: string | Node;
|
|
72
|
+
};
|
|
73
|
+
export type ElementAttsMap = {
|
|
74
|
+
json: import('./JSONJoiningTransformer.js').ElementAttributes;
|
|
75
|
+
string: import('./StringJoiningTransformer.js').ElementAttributes;
|
|
76
|
+
dom: Record<string, string>;
|
|
77
|
+
};
|
|
78
|
+
export type JSONPathTransformerContextConfig<T extends "json" | "string" | "dom" = "json"> = {
|
|
77
79
|
/**
|
|
78
80
|
* - Data to transform
|
|
79
81
|
*/
|
|
@@ -81,30 +83,34 @@ export type JSONPathTransformerContextConfig<T = "json"> = {
|
|
|
81
83
|
/**
|
|
82
84
|
* - Parent object
|
|
83
85
|
*/
|
|
84
|
-
parent?: object
|
|
86
|
+
parent?: object;
|
|
85
87
|
/**
|
|
86
88
|
* - Parent property name
|
|
87
89
|
*/
|
|
88
|
-
parentProperty?: string
|
|
90
|
+
parentProperty?: string;
|
|
89
91
|
/**
|
|
90
92
|
* - Whether to error on
|
|
91
93
|
* equal priority
|
|
92
94
|
*/
|
|
93
|
-
errorOnEqualPriority?: boolean
|
|
95
|
+
errorOnEqualPriority?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* - Output type
|
|
98
|
+
*/
|
|
99
|
+
outputType?: T;
|
|
94
100
|
/**
|
|
95
101
|
* - Joining transformer
|
|
96
102
|
*/
|
|
97
|
-
joiningTransformer: T
|
|
103
|
+
joiningTransformer: JoiningTransformerMap[T];
|
|
98
104
|
/**
|
|
99
105
|
* - Whether to prevent eval in
|
|
100
106
|
* JSONPath
|
|
101
107
|
*/
|
|
102
|
-
preventEval?: boolean
|
|
108
|
+
preventEval?: boolean;
|
|
103
109
|
/**
|
|
104
110
|
* Priority resolver function
|
|
105
111
|
*/
|
|
106
|
-
specificityPriorityResolver?: (
|
|
107
|
-
templates?: import(
|
|
112
|
+
specificityPriorityResolver?: (path: string) => number;
|
|
113
|
+
templates?: import('./index.js').JSONPathTemplateObject<T>[] | import('./index.js').JSONPathTemplateArray<T>[];
|
|
108
114
|
};
|
|
109
115
|
/**
|
|
110
116
|
* Decimal format symbols for number formatting.
|
|
@@ -142,29 +148,47 @@ export type JSONPathTransformerContextConfig<T = "json"> = {
|
|
|
142
148
|
* locale?: string,
|
|
143
149
|
* localeOptions?: unknown
|
|
144
150
|
* }} SortObject
|
|
145
|
-
* @
|
|
151
|
+
* @template [V=unknown]
|
|
152
|
+
* @typedef {(a: V, b: V,
|
|
146
153
|
* ctx: JSONPathTransformerContext
|
|
147
154
|
* ) => number} SortComparator
|
|
148
155
|
* @typedef {string | SortObject | SortComparator |
|
|
149
156
|
* Array<string|SortObject>} SortSpec
|
|
150
157
|
*/
|
|
151
158
|
/**
|
|
152
|
-
* @
|
|
159
|
+
* @typedef {object} JoiningTransformerMap
|
|
160
|
+
* @property {import('./JSONJoiningTransformer.js').default} json
|
|
161
|
+
* @property {import('./StringJoiningTransformer.js').default} string
|
|
162
|
+
* @property {import('./DOMJoiningTransformer.js').default} dom
|
|
163
|
+
*/
|
|
164
|
+
/**
|
|
165
|
+
* @typedef {object} AppendItemMap
|
|
166
|
+
* @property {unknown} json
|
|
167
|
+
* @property {string|unknown} string
|
|
168
|
+
* @property {string|Node} dom
|
|
169
|
+
*/
|
|
170
|
+
/**
|
|
171
|
+
* @typedef {object} ElementAttsMap
|
|
172
|
+
* @property {import('./JSONJoiningTransformer.js').ElementAttributes} json
|
|
173
|
+
* @property {import('./StringJoiningTransformer.js').ElementAttributes} string
|
|
174
|
+
* @property {Record<string, string>} dom
|
|
175
|
+
*/
|
|
176
|
+
/**
|
|
177
|
+
* @template {"json"|"string"|"dom"} [T="json"]
|
|
153
178
|
* @typedef {object} JSONPathTransformerContextConfig
|
|
154
179
|
* @property {null|boolean|number|string|object} data - Data to transform
|
|
155
180
|
* @property {object} [parent] - Parent object
|
|
156
181
|
* @property {string} [parentProperty] - Parent property name
|
|
157
182
|
* @property {boolean} [errorOnEqualPriority] - Whether to error on
|
|
158
183
|
* equal priority
|
|
159
|
-
* @property {T
|
|
160
|
-
*
|
|
161
|
-
* default : import('./DOMJoiningTransformer.js').
|
|
162
|
-
* default} joiningTransformer - Joining transformer
|
|
184
|
+
* @property {T} [outputType] - Output type
|
|
185
|
+
* @property {JoiningTransformerMap[T]} joiningTransformer - Joining transformer
|
|
163
186
|
* @property {boolean} [preventEval] - Whether to prevent eval in
|
|
164
187
|
* JSONPath
|
|
165
188
|
* @property {(path: string) => number} [specificityPriorityResolver]
|
|
166
189
|
* Priority resolver function
|
|
167
|
-
* @property {import('./index.js').JSONPathTemplateObject<T>[]
|
|
190
|
+
* @property {import('./index.js').JSONPathTemplateObject<T>[]|
|
|
191
|
+
* import('./index.js').JSONPathTemplateArray<T>[]} [templates]
|
|
168
192
|
*/
|
|
169
193
|
/**
|
|
170
194
|
* Execution context for JSONPath-driven template application.
|
|
@@ -173,22 +197,10 @@ export type JSONPathTransformerContextConfig<T = "json"> = {
|
|
|
173
197
|
* running templates. Exposes helper methods that mirror the underlying
|
|
174
198
|
* joining transformer (e.g., string(), object(), array()) so templates can
|
|
175
199
|
* emit results without referencing the joiner directly.
|
|
176
|
-
* @template [T
|
|
200
|
+
* @template {"json"|"string"|"dom"} [T="json"]
|
|
201
|
+
* @template [V=unknown]
|
|
177
202
|
*/
|
|
178
|
-
declare class JSONPathTransformerContext<T = "json"> {
|
|
179
|
-
/**
|
|
180
|
-
* @param {JSONPathTransformerContextConfig<T>} config
|
|
181
|
-
* @param {import('./index.js').JSONPathTemplateObject<T>[]} templates - Array
|
|
182
|
-
* of template objects
|
|
183
|
-
*/
|
|
184
|
-
constructor(config: JSONPathTransformerContextConfig<T>, templates: import("./index.js").JSONPathTemplateObject<T>[]);
|
|
185
|
-
/**
|
|
186
|
-
* Holds the current iteration state (for position calculations).
|
|
187
|
-
* @type {{ index?: number } | undefined}
|
|
188
|
-
*/
|
|
189
|
-
iterationState: {
|
|
190
|
-
index?: number;
|
|
191
|
-
} | undefined;
|
|
203
|
+
declare class JSONPathTransformerContext<T extends "json" | "string" | "dom" = "json", V = unknown> {
|
|
192
204
|
_config: JSONPathTransformerContextConfig<T>;
|
|
193
205
|
_templates: import("./index.js").JSONPathTemplateObject<T>[];
|
|
194
206
|
_contextObj: string | number | boolean | object | null;
|
|
@@ -216,6 +228,19 @@ declare class JSONPathTransformerContext<T = "json"> {
|
|
|
216
228
|
_preserveSpaceElements: string[];
|
|
217
229
|
/** @type {string[]} */
|
|
218
230
|
_stripSpaceElements: string[];
|
|
231
|
+
/**
|
|
232
|
+
* Holds the current iteration state (for position calculations).
|
|
233
|
+
* @type {{ index?: number } | undefined}
|
|
234
|
+
*/
|
|
235
|
+
iterationState: {
|
|
236
|
+
index?: number;
|
|
237
|
+
} | undefined;
|
|
238
|
+
/**
|
|
239
|
+
* @param {JSONPathTransformerContextConfig<T>} config
|
|
240
|
+
* @param {import('./index.js').JSONPathTemplateObject<T>[]} templates - Array
|
|
241
|
+
* of template objects
|
|
242
|
+
*/
|
|
243
|
+
constructor(config: JSONPathTransformerContextConfig<T>, templates: import('./index.js').JSONPathTemplateObject<T>[]);
|
|
219
244
|
/**
|
|
220
245
|
* Triggers an error if equal priority templates are found.
|
|
221
246
|
* @returns {void}
|
|
@@ -229,17 +254,14 @@ declare class JSONPathTransformerContext<T = "json"> {
|
|
|
229
254
|
_shouldStripSpace(elementName: string): boolean;
|
|
230
255
|
/**
|
|
231
256
|
* Gets the joining transformer from config.
|
|
232
|
-
* @returns {T
|
|
233
|
-
* default : T extends "string" ? import('./StringJoiningTransformer.js').
|
|
234
|
-
* default : import('./DOMJoiningTransformer.js').
|
|
235
|
-
* default} The joining transformer
|
|
257
|
+
* @returns {JoiningTransformerMap[T]} The joining transformer
|
|
236
258
|
*/
|
|
237
|
-
_getJoiningTransformer(): T
|
|
259
|
+
_getJoiningTransformer(): JoiningTransformerMap[T];
|
|
238
260
|
/**
|
|
239
|
-
* @param {
|
|
261
|
+
* @param {AppendItemMap[T]} item - Item to append to output
|
|
240
262
|
* @returns {this}
|
|
241
263
|
*/
|
|
242
|
-
appendOutput(item:
|
|
264
|
+
appendOutput(item: AppendItemMap[T]): this;
|
|
243
265
|
/**
|
|
244
266
|
* Gets the current output.
|
|
245
267
|
* @returns {any} The output from the joining transformer
|
|
@@ -273,13 +295,13 @@ declare class JSONPathTransformerContext<T = "json"> {
|
|
|
273
295
|
* {mode?: string, select?: string}
|
|
274
296
|
* } [select] - JSONPath selector or options object
|
|
275
297
|
* @param {string} [mode] - Mode to apply
|
|
276
|
-
* @param {SortSpec} [sort] - Sort spec
|
|
298
|
+
* @param {SortSpec<V>} [sort] - Sort spec
|
|
277
299
|
* @returns {this}
|
|
278
300
|
*/
|
|
279
301
|
applyTemplates(select?: string | null | {
|
|
280
302
|
mode?: string;
|
|
281
303
|
select?: string;
|
|
282
|
-
}, mode?: string, sort?: SortSpec): this;
|
|
304
|
+
}, mode?: string, sort?: SortSpec<V>): this;
|
|
283
305
|
/**
|
|
284
306
|
* @param {string|
|
|
285
307
|
* {name: string, withParam?: any[]}} name - Template name or
|
|
@@ -297,12 +319,12 @@ declare class JSONPathTransformerContext<T = "json"> {
|
|
|
297
319
|
* Sort parameter forms are the same as applyTemplates().
|
|
298
320
|
* @param {string} select - JSONPath selector
|
|
299
321
|
* @param {(this: JSONPathTransformerContext<T>,
|
|
300
|
-
* value:
|
|
322
|
+
* value: unknown
|
|
301
323
|
* ) => void} cb - Callback function
|
|
302
|
-
* @param {SortSpec} [sort] - Sort spec
|
|
324
|
+
* @param {SortSpec<V>} [sort] - Sort spec
|
|
303
325
|
* @returns {this}
|
|
304
326
|
*/
|
|
305
|
-
forEach(select: string, cb: (this: JSONPathTransformerContext<T>, value:
|
|
327
|
+
forEach(select: string, cb: (this: JSONPathTransformerContext<T>, value: unknown) => void, sort?: SortSpec<V>): this;
|
|
306
328
|
/**
|
|
307
329
|
* Groups items and executes callback for each group.
|
|
308
330
|
* Equivalent to XSLT's xsl:for-each-group.
|
|
@@ -322,10 +344,10 @@ declare class JSONPathTransformerContext<T = "json"> {
|
|
|
322
344
|
* @returns {this}
|
|
323
345
|
*/
|
|
324
346
|
forEachGroup(select: string, options: {
|
|
325
|
-
groupBy?: string
|
|
326
|
-
groupAdjacent?: string
|
|
327
|
-
groupStartingWith?: string
|
|
328
|
-
groupEndingWith?: string
|
|
347
|
+
groupBy?: string;
|
|
348
|
+
groupAdjacent?: string;
|
|
349
|
+
groupStartingWith?: string;
|
|
350
|
+
groupEndingWith?: string;
|
|
329
351
|
sort?: any;
|
|
330
352
|
}, cb: (this: JSONPathTransformerContext<T>, key: any, items: any[], ctx: any) => void): this;
|
|
331
353
|
/**
|
|
@@ -407,7 +429,7 @@ declare class JSONPathTransformerContext<T = "json"> {
|
|
|
407
429
|
* string content
|
|
408
430
|
* @returns {this}
|
|
409
431
|
*/
|
|
410
|
-
string(str: string, cb?: import(
|
|
432
|
+
string(str: string, cb?: import('./JSONJoiningTransformer.js').SimpleCallback<T>): this;
|
|
411
433
|
/**
|
|
412
434
|
* Append a number to JSON output with xsl:number-like formatting.
|
|
413
435
|
* @param {NumberValue} num - Number value, "position()" string, or
|
|
@@ -510,7 +532,7 @@ declare class JSONPathTransformerContext<T = "json"> {
|
|
|
510
532
|
* @param {import('./StringJoiningTransformer.js').OutputConfig} cfg Text
|
|
511
533
|
* @returns {this}
|
|
512
534
|
*/
|
|
513
|
-
output(cfg: import(
|
|
535
|
+
output(cfg: import('./StringJoiningTransformer.js').OutputConfig): this;
|
|
514
536
|
/**
|
|
515
537
|
* Configure mode behavior (similar to xsl:mode).
|
|
516
538
|
* @param {{
|
|
@@ -534,7 +556,7 @@ declare class JSONPathTransformerContext<T = "json"> {
|
|
|
534
556
|
* OutputCharacters} outputCharacters
|
|
535
557
|
* @returns {this}
|
|
536
558
|
*/
|
|
537
|
-
characterMap(name: string, outputCharacters: import(
|
|
559
|
+
characterMap(name: string, outputCharacters: import('./AbstractJoiningTransformer.js').OutputCharacters): this;
|
|
538
560
|
/**
|
|
539
561
|
* @param {string} name
|
|
540
562
|
* @param {Record<string, string>} attributes
|
|
@@ -600,8 +622,8 @@ declare class JSONPathTransformerContext<T = "json"> {
|
|
|
600
622
|
/**
|
|
601
623
|
* Create an element. Mirrors the joining transformer API so templates can
|
|
602
624
|
* call `this.element()`.
|
|
603
|
-
* @param {string} name - Element name
|
|
604
|
-
* @param {
|
|
625
|
+
* @param {string|Node} name - Element name or Node (if DOM)
|
|
626
|
+
* @param {ElementAttsMap[T]|any[]|
|
|
605
627
|
* ((this: JSONPathTransformerContext<T>) => void)} [atts] -
|
|
606
628
|
* Attributes object or children or callback
|
|
607
629
|
* @param {any[]|
|
|
@@ -612,7 +634,7 @@ declare class JSONPathTransformerContext<T = "json"> {
|
|
|
612
634
|
* @param {string[]} [useAttributeSets] - Attribute set names to apply
|
|
613
635
|
* @returns {this}
|
|
614
636
|
*/
|
|
615
|
-
element(name: string, atts?:
|
|
637
|
+
element(name: string | Node, atts?: ElementAttsMap[T] | any[] | ((this: JSONPathTransformerContext<T>) => void), children?: any[] | ((this: JSONPathTransformerContext<T>) => void), cb?: (this: JSONPathTransformerContext<T>) => void, useAttributeSets?: string[]): this;
|
|
616
638
|
/**
|
|
617
639
|
* Adds a prefixed namespace declaration to the most recently opened
|
|
618
640
|
* element. Mirrors the joining
|
|
@@ -738,4 +760,5 @@ declare class JSONPathTransformerContext<T = "json"> {
|
|
|
738
760
|
*/
|
|
739
761
|
assert(test: string, message?: string): this;
|
|
740
762
|
}
|
|
763
|
+
export default JSONPathTransformerContext;
|
|
741
764
|
//# sourceMappingURL=JSONPathTransformerContext.d.ts.map
|