jtlt 0.2.0 → 0.3.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 +18 -0
- package/README.md +16 -87
- package/demo/calltemplate-params-demo.js +138 -0
- package/demo/index.html +31 -0
- package/demo/index.js +30 -0
- package/demo/xpath2-placeholder.js +1 -0
- package/dist/AbstractJoiningTransformer.d.ts +83 -9
- package/dist/AbstractJoiningTransformer.d.ts.map +1 -1
- package/dist/DOMJoiningTransformer.d.ts +85 -25
- package/dist/DOMJoiningTransformer.d.ts.map +1 -1
- package/dist/JSONJoiningTransformer.d.ts +159 -51
- package/dist/JSONJoiningTransformer.d.ts.map +1 -1
- package/dist/JSONPathTransformer.d.ts +37 -38
- package/dist/JSONPathTransformer.d.ts.map +1 -1
- package/dist/JSONPathTransformerContext.d.ts +247 -121
- package/dist/JSONPathTransformerContext.d.ts.map +1 -1
- package/dist/StringJoiningTransformer.d.ts +132 -41
- package/dist/StringJoiningTransformer.d.ts.map +1 -1
- package/dist/XPathTransformer.d.ts +35 -20
- package/dist/XPathTransformer.d.ts.map +1 -1
- package/dist/XPathTransformerContext.d.ts +191 -99
- package/dist/XPathTransformerContext.d.ts.map +1 -1
- package/dist/index-browser.d.ts +4 -0
- package/dist/index-browser.d.ts.map +1 -0
- package/dist/index-node.d.ts +4 -0
- package/dist/index-node.d.ts.map +1 -0
- package/dist/index.d.ts +330 -57
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +204 -0
- package/dist/types.d.ts.map +1 -0
- package/docs/API.expanded.md +167 -2
- package/docs/API.md +91 -1
- package/docs/TO-DO.md +144 -0
- package/docs/calltemplate-params.md +251 -0
- package/eslint.config.js +9 -5
- package/package.json +13 -7
- package/pnpm-workspace.yaml +1 -0
- package/src/AbstractJoiningTransformer.js +54 -15
- package/src/DOMJoiningTransformer.js +275 -28
- package/src/JSONJoiningTransformer.js +351 -70
- package/src/JSONPathTransformer.js +48 -30
- package/src/JSONPathTransformerContext.js +308 -104
- package/src/StringJoiningTransformer.js +311 -57
- package/src/XPathTransformer.js +27 -12
- package/src/XPathTransformerContext.js +467 -89
- package/src/index-browser.js +5 -0
- package/src/index-node.js +7 -0
- package/src/index.js +498 -97
- package/typings/xpath2-js.d.ts +40 -1
- package/src/types/xpath2-js.d.ts +0 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create and run a JTLT instance with the appropriate engine typing.
|
|
3
|
+
*
|
|
4
|
+
* Overloads help TypeScript select the correct constructor signature.
|
|
5
|
+
* @overload
|
|
6
|
+
* @param {Omit<JSONPathJTLTOptions<"json">, "success">} cfg
|
|
7
|
+
* @returns {Promise<ResultType<"json">>}
|
|
8
|
+
*/
|
|
9
|
+
export function jtlt(cfg: Omit<JSONPathJTLTOptions<"json">, "success">): Promise<ResultType<"json">>;
|
|
10
|
+
/**
|
|
11
|
+
* @overload
|
|
12
|
+
* @param {Omit<JSONPathJTLTOptions<"string">, "success">} cfg
|
|
13
|
+
* @returns {Promise<ResultType<"string">>}
|
|
14
|
+
*/
|
|
15
|
+
export function jtlt(cfg: Omit<JSONPathJTLTOptions<"string">, "success">): Promise<ResultType<"string">>;
|
|
16
|
+
/**
|
|
17
|
+
* @overload
|
|
18
|
+
* @param {Omit<JSONPathJTLTOptions<"dom">, "success">} cfg
|
|
19
|
+
* @returns {Promise<ResultType<"dom">>}
|
|
20
|
+
*/
|
|
21
|
+
export function jtlt(cfg: Omit<JSONPathJTLTOptions<"dom">, "success">): Promise<ResultType<"dom">>;
|
|
22
|
+
/**
|
|
23
|
+
* @overload
|
|
24
|
+
* @param {Omit<XPathJTLTOptions<"json">, "success">} cfg
|
|
25
|
+
* @returns {Promise<ResultType<"json">>}
|
|
26
|
+
*/
|
|
27
|
+
export function jtlt(cfg: Omit<XPathJTLTOptions<"json">, "success">): Promise<ResultType<"json">>;
|
|
28
|
+
/**
|
|
29
|
+
* @overload
|
|
30
|
+
* @param {Omit<XPathJTLTOptions<"dom">, "success">} cfg
|
|
31
|
+
* @returns {Promise<ResultType<"dom">>}
|
|
32
|
+
*/
|
|
33
|
+
export function jtlt(cfg: Omit<XPathJTLTOptions<"dom">, "success">): Promise<ResultType<"dom">>;
|
|
34
|
+
/**
|
|
35
|
+
* @overload
|
|
36
|
+
* @param {Omit<XPathJTLTOptions<"string">, "success">} cfg
|
|
37
|
+
* @returns {Promise<ResultType<"string">>}
|
|
38
|
+
*/
|
|
39
|
+
export function jtlt(cfg: Omit<XPathJTLTOptions<"string">, "success">): Promise<ResultType<"string">>;
|
|
40
|
+
export function setWindow(win: import("jsdom").DOMWindow | typeof globalThis): void;
|
|
1
41
|
export { default as AbstractJoiningTransformer } from "./AbstractJoiningTransformer.js";
|
|
2
42
|
export { default as StringJoiningTransformer } from "./StringJoiningTransformer.js";
|
|
3
43
|
export { default as DOMJoiningTransformer } from "./DOMJoiningTransformer.js";
|
|
@@ -8,35 +48,70 @@ export { default as JSONPathTransformer } from "./JSONPathTransformer.js";
|
|
|
8
48
|
export { default as XPathTransformerContext } from "./XPathTransformerContext.js";
|
|
9
49
|
export { default as XPathTransformer } from "./XPathTransformer.js";
|
|
10
50
|
export default JTLT;
|
|
11
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Internal options extension adding private runtime state flags.
|
|
53
|
+
* Not part of the public API surface but used for narrowing casts.
|
|
54
|
+
*/
|
|
55
|
+
export type InternalJTLTOptions = JTLTOptions & {
|
|
56
|
+
_customJoiningTransformer?: boolean;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* A template declaration whose `template` executes with `this` bound
|
|
60
|
+
* to the engine-specific context type `TCtx`.
|
|
61
|
+
* Either `path` must be provided (for pattern matching), or `name` must be
|
|
62
|
+
* provided (for named templates callable via callTemplate), or both.
|
|
63
|
+
*/
|
|
64
|
+
export type TemplateObject<T, U, TCtx> = {
|
|
12
65
|
/**
|
|
13
|
-
*
|
|
14
|
-
* argument that is the result of this instance's transform() method.
|
|
66
|
+
* - JSONPath or XPath selector for matching nodes
|
|
15
67
|
*/
|
|
16
|
-
|
|
68
|
+
path?: string | undefined;
|
|
17
69
|
/**
|
|
18
|
-
*
|
|
70
|
+
* - Optional name for calling via callTemplate
|
|
19
71
|
*/
|
|
20
|
-
|
|
72
|
+
name?: string | undefined;
|
|
21
73
|
/**
|
|
22
|
-
*
|
|
23
|
-
* root template or a single, complete template object
|
|
74
|
+
* - Optional mode for template matching
|
|
24
75
|
*/
|
|
25
|
-
|
|
76
|
+
mode?: string | undefined;
|
|
26
77
|
/**
|
|
27
|
-
*
|
|
78
|
+
* - Priority for template selection
|
|
28
79
|
*/
|
|
29
|
-
|
|
80
|
+
priority?: number | undefined;
|
|
30
81
|
/**
|
|
31
|
-
*
|
|
32
|
-
* to a single call to `forEach` (and which will serve as the root
|
|
33
|
-
* template)
|
|
82
|
+
* - Template function
|
|
34
83
|
*/
|
|
35
|
-
|
|
84
|
+
template: TemplateFunction<T, U, TCtx>;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* A callable template function with an engine-specific `this`.
|
|
88
|
+
*/
|
|
89
|
+
export type TemplateFunction<T, U, TCtx> = (this: TCtx, value: ResultType<U>, cfg?: {
|
|
90
|
+
mode?: string;
|
|
91
|
+
}) => ResultType<T> | void;
|
|
92
|
+
export type JSONPathTemplateObject<T> = TemplateObject<T, "json", import("./JSONPathTransformerContext.js").default<T>>;
|
|
93
|
+
export type XPathTemplateObject<T> = TemplateObject<T, "dom", import("./XPathTransformerContext.js").default>;
|
|
94
|
+
export type XPathTemplateArray<T> = (XPathTemplateObject<T> | [string, TemplateFunction<T, "dom", import("./XPathTransformerContext.js").default>])[];
|
|
95
|
+
export type JSONPathTemplateArray<T> = JSONPathTemplateObject<T> | [string, TemplateFunction<T, "json", import("./JSONPathTransformerContext.js").default>];
|
|
96
|
+
export type JoiningTransformer = (StringJoiningTransformer | DOMJoiningTransformer | JSONJoiningTransformer);
|
|
97
|
+
export type joiningTypes = "json" | "string" | "dom";
|
|
98
|
+
export type ResultType<T> = T extends "json" ? unknown : T extends "string" ? string : DocumentFragment | Element;
|
|
99
|
+
/**
|
|
100
|
+
* Options common to both engines.
|
|
101
|
+
*/
|
|
102
|
+
export type BaseJTLTOptions<T> = {
|
|
103
|
+
/**
|
|
104
|
+
* A callback supplied
|
|
105
|
+
* with a single argument that is the result of this instance's
|
|
106
|
+
* transform() method. When used in TypeScript, this can be made
|
|
107
|
+
* generic as `success<T>(result: T): void`.
|
|
108
|
+
*/
|
|
109
|
+
success: (result: ResultType<T>) => void;
|
|
36
110
|
/**
|
|
37
|
-
* A JSON
|
|
111
|
+
* A JSON
|
|
112
|
+
* object or DOM document (XPath)
|
|
38
113
|
*/
|
|
39
|
-
data?:
|
|
114
|
+
data?: string | number | boolean | object | null | undefined;
|
|
40
115
|
/**
|
|
41
116
|
* URL of a JSON file to retrieve for
|
|
42
117
|
* evaluation
|
|
@@ -64,60 +139,233 @@ export type JTLTOptions = {
|
|
|
64
139
|
*/
|
|
65
140
|
unwrapSingleResult?: boolean | undefined;
|
|
66
141
|
/**
|
|
67
|
-
*
|
|
142
|
+
* When true, joiners return an array
|
|
143
|
+
* of complete documents: XMLDocument[] for DOM, document wrapper objects[]
|
|
144
|
+
* for JSON, and string[] for string joiners. Each array element corresponds
|
|
145
|
+
* to a root element built during transformation.
|
|
68
146
|
*/
|
|
69
|
-
|
|
147
|
+
exposeDocuments?: boolean | undefined;
|
|
70
148
|
/**
|
|
71
|
-
*
|
|
149
|
+
* The mode in which to begin the transform.
|
|
72
150
|
*/
|
|
73
|
-
|
|
151
|
+
mode?: string | undefined;
|
|
74
152
|
/**
|
|
75
|
-
* Will be based the
|
|
153
|
+
* Will be based on the
|
|
76
154
|
* same config as passed to this instance. Defaults to a transforming
|
|
77
155
|
* function based on JSONPath and with its own set of priorities for
|
|
78
156
|
* processing templates.
|
|
79
157
|
*/
|
|
80
|
-
engine?:
|
|
81
|
-
/**
|
|
82
|
-
* Choose built-in engine.
|
|
83
|
-
* Defaults to 'jsonpath'. When 'xpath', `xpathVersion` may be used.
|
|
84
|
-
*/
|
|
85
|
-
engineType?: "jsonpath" | "xpath" | undefined;
|
|
86
|
-
/**
|
|
87
|
-
* XPath engine version: 1 (native) or 2
|
|
88
|
-
* (xpath2.js) when `engineType` is 'xpath'.
|
|
89
|
-
*/
|
|
90
|
-
xpathVersion?: 1 | 2 | undefined;
|
|
158
|
+
engine?: ((opts: JTLTOptions & Required<Pick<JTLTOptions, "joiningTransformer">>) => ResultType<T>) | undefined;
|
|
91
159
|
/**
|
|
92
160
|
* Callback for getting the priority by specificity
|
|
93
161
|
*/
|
|
94
|
-
specificityPriorityResolver?:
|
|
162
|
+
specificityPriorityResolver?: ((path: string) => 0 | 0.5 | -0.5) | undefined;
|
|
95
163
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
164
|
+
* A concrete joining transformer instance (or custom subclass) responsible
|
|
165
|
+
* for accumulating output. When omitted, one is created automatically based
|
|
166
|
+
* on `outputType`.
|
|
99
167
|
*/
|
|
100
|
-
joiningTransformer?:
|
|
101
|
-
get: Function;
|
|
102
|
-
append: Function;
|
|
103
|
-
string?: Function;
|
|
104
|
-
object?: Function;
|
|
105
|
-
array?: Function;
|
|
106
|
-
} | undefined;
|
|
168
|
+
joiningTransformer?: JoiningTransformer | undefined;
|
|
107
169
|
/**
|
|
108
|
-
* Config
|
|
109
|
-
* transformer
|
|
170
|
+
* Config for the joining
|
|
171
|
+
* transformer.
|
|
110
172
|
*/
|
|
111
|
-
joiningConfig?:
|
|
173
|
+
joiningConfig?: import("./AbstractJoiningTransformer.js").JoiningTransformerConfig<T> | undefined;
|
|
112
174
|
/**
|
|
113
175
|
* Parent object for context
|
|
114
176
|
*/
|
|
115
|
-
parent?:
|
|
177
|
+
parent?: object | undefined;
|
|
116
178
|
/**
|
|
117
179
|
* Parent property name for context
|
|
118
180
|
*/
|
|
119
181
|
parentProperty?: string | undefined;
|
|
120
182
|
};
|
|
183
|
+
/**
|
|
184
|
+
* JSONPath engine options with context-aware template typing.
|
|
185
|
+
*/
|
|
186
|
+
export type JSONPathJTLTOptions<T = "json"> = BaseJTLTOptions<T> & {
|
|
187
|
+
templates?: JSONPathTemplateArray<T>[];
|
|
188
|
+
template?: JSONPathTemplateObject<T> | TemplateFunction<T, "json", import("./JSONPathTransformerContext.js").default>;
|
|
189
|
+
query?: TemplateFunction<T, "json", import("./JSONPathTransformerContext.js").default>;
|
|
190
|
+
forQuery?: [string, TemplateFunction<T, "json", import("./XPathTransformerContext.js").default>];
|
|
191
|
+
engineType?: "jsonpath";
|
|
192
|
+
outputType?: T;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* XPath engine options with context-aware template typing.
|
|
196
|
+
*/
|
|
197
|
+
export type XPathJTLTOptions<T> = BaseJTLTOptions<T> & {
|
|
198
|
+
templates?: XPathTemplateArray<T>;
|
|
199
|
+
template?: XPathTemplateObject<T> | TemplateFunction<T, "dom", import("./XPathTransformerContext.js").default>;
|
|
200
|
+
query?: TemplateFunction<T, "dom", import("./XPathTransformerContext.js").default>;
|
|
201
|
+
forQuery?: [string, TemplateFunction<T, "dom", import("./JSONPathTransformerContext.js").default>];
|
|
202
|
+
engineType: "xpath";
|
|
203
|
+
xpathVersion?: 1 | 2;
|
|
204
|
+
outputType?: "string" | "dom" | "json";
|
|
205
|
+
};
|
|
206
|
+
export type JTLTOptions = JSONPathJTLTOptions | JSONPathJTLTOptions<"string"> | JSONPathJTLTOptions<"dom"> | XPathJTLTOptions<"json"> | XPathJTLTOptions<"string"> | XPathJTLTOptions<"dom">;
|
|
207
|
+
/**
|
|
208
|
+
* Internal options extension adding private runtime state flags.
|
|
209
|
+
* Not part of the public API surface but used for narrowing casts.
|
|
210
|
+
* @typedef {JTLTOptions & {
|
|
211
|
+
* _customJoiningTransformer?: boolean
|
|
212
|
+
* }} InternalJTLTOptions
|
|
213
|
+
*/
|
|
214
|
+
/**
|
|
215
|
+
* A template declaration whose `template` executes with `this` bound
|
|
216
|
+
* to the engine-specific context type `TCtx`.
|
|
217
|
+
* Either `path` must be provided (for pattern matching), or `name` must be
|
|
218
|
+
* provided (for named templates callable via callTemplate), or both.
|
|
219
|
+
* @template T
|
|
220
|
+
* @template U
|
|
221
|
+
* @template TCtx
|
|
222
|
+
* @typedef {object} TemplateObject
|
|
223
|
+
* @property {string} [path] - JSONPath or XPath selector for matching nodes
|
|
224
|
+
* @property {string} [name] - Optional name for calling via callTemplate
|
|
225
|
+
* @property {string} [mode] - Optional mode for template matching
|
|
226
|
+
* @property {number} [priority] - Priority for template selection
|
|
227
|
+
* @property {TemplateFunction<T, U, TCtx>} template - Template function
|
|
228
|
+
*/
|
|
229
|
+
/**
|
|
230
|
+
* A callable template function with an engine-specific `this`.
|
|
231
|
+
* @template T
|
|
232
|
+
* @template U
|
|
233
|
+
* @template TCtx
|
|
234
|
+
* @typedef {(this: TCtx,
|
|
235
|
+
* value: ResultType<U>,
|
|
236
|
+
* cfg?: {mode?: string}
|
|
237
|
+
* ) => ResultType<T>|void} TemplateFunction
|
|
238
|
+
*/
|
|
239
|
+
/**
|
|
240
|
+
* @template T
|
|
241
|
+
* @typedef {TemplateObject<T, "json",
|
|
242
|
+
* import('./JSONPathTransformerContext.js').default<T>
|
|
243
|
+
* >} JSONPathTemplateObject
|
|
244
|
+
*/
|
|
245
|
+
/**
|
|
246
|
+
* @template T
|
|
247
|
+
* @typedef {TemplateObject<T, "dom",
|
|
248
|
+
* import('./XPathTransformerContext.js').default
|
|
249
|
+
* >} XPathTemplateObject
|
|
250
|
+
*/
|
|
251
|
+
/**
|
|
252
|
+
* @template T
|
|
253
|
+
* @typedef {(XPathTemplateObject<T> | [string, TemplateFunction<T, "dom",
|
|
254
|
+
* import('./XPathTransformerContext.js').default
|
|
255
|
+
* >])[]} XPathTemplateArray
|
|
256
|
+
*/
|
|
257
|
+
/**
|
|
258
|
+
* @template T
|
|
259
|
+
* @typedef {JSONPathTemplateObject<T> | [string, TemplateFunction<T, "json",
|
|
260
|
+
* import('./JSONPathTransformerContext.js').default
|
|
261
|
+
* >]} JSONPathTemplateArray
|
|
262
|
+
*/
|
|
263
|
+
/**
|
|
264
|
+
* @typedef {(
|
|
265
|
+
* StringJoiningTransformer|
|
|
266
|
+
* DOMJoiningTransformer|
|
|
267
|
+
* JSONJoiningTransformer
|
|
268
|
+
* )} JoiningTransformer
|
|
269
|
+
*/
|
|
270
|
+
/**
|
|
271
|
+
* @typedef {"json"|"string"|"dom"} joiningTypes
|
|
272
|
+
*/
|
|
273
|
+
/**
|
|
274
|
+
* @template T
|
|
275
|
+
* @typedef {T extends "json" ? unknown : T extends "string" ? string :
|
|
276
|
+
* DocumentFragment|Element} ResultType
|
|
277
|
+
*/
|
|
278
|
+
/**
|
|
279
|
+
* Options common to both engines.
|
|
280
|
+
* @template T
|
|
281
|
+
* @typedef {object} BaseJTLTOptions
|
|
282
|
+
* @property {(
|
|
283
|
+
* result: ResultType<T>
|
|
284
|
+
* ) => void} success A callback supplied
|
|
285
|
+
* with a single argument that is the result of this instance's
|
|
286
|
+
* transform() method. When used in TypeScript, this can be made
|
|
287
|
+
* generic as `success<T>(result: T): void`.
|
|
288
|
+
* @property {null|boolean|number|string|object} [data] A JSON
|
|
289
|
+
* object or DOM document (XPath)
|
|
290
|
+
* @property {string} [ajaxData] URL of a JSON file to retrieve for
|
|
291
|
+
* evaluation
|
|
292
|
+
* @property {boolean} [errorOnEqualPriority] Whether or not to
|
|
293
|
+
* report an error when equal priority templates are found
|
|
294
|
+
* @property {boolean} [autostart] Whether to begin transform()
|
|
295
|
+
* immediately.
|
|
296
|
+
* @property {boolean} [preventEval] Whether to prevent
|
|
297
|
+
* parenthetical evaluations in JSONPath. Safer if relying on user
|
|
298
|
+
* input, but reduces capabilities of JSONPath.
|
|
299
|
+
* @property {boolean} [unwrapSingleResult] For JSON output, whether to
|
|
300
|
+
* unwrap single-element root arrays to return just the element
|
|
301
|
+
* @property {boolean} [exposeDocuments] When true, joiners return an array
|
|
302
|
+
* of complete documents: XMLDocument[] for DOM, document wrapper objects[]
|
|
303
|
+
* for JSON, and string[] for string joiners. Each array element corresponds
|
|
304
|
+
* to a root element built during transformation.
|
|
305
|
+
* @property {string} [mode] The mode in which to begin the transform.
|
|
306
|
+
* @property {(opts: JTLTOptions &
|
|
307
|
+
* Required<Pick<JTLTOptions, "joiningTransformer">>
|
|
308
|
+
* ) => ResultType<T>} [engine] Will be based on the
|
|
309
|
+
* same config as passed to this instance. Defaults to a transforming
|
|
310
|
+
* function based on JSONPath and with its own set of priorities for
|
|
311
|
+
* processing templates.
|
|
312
|
+
* @property {(path: string) => 0 | 0.5 | -0.5} [specificityPriorityResolver]
|
|
313
|
+
* Callback for getting the priority by specificity
|
|
314
|
+
* @property {JoiningTransformer} [joiningTransformer]
|
|
315
|
+
* A concrete joining transformer instance (or custom subclass) responsible
|
|
316
|
+
* for accumulating output. When omitted, one is created automatically based
|
|
317
|
+
* on `outputType`.
|
|
318
|
+
* @property {import('./AbstractJoiningTransformer.js').
|
|
319
|
+
* JoiningTransformerConfig<T>} [joiningConfig] Config for the joining
|
|
320
|
+
* transformer.
|
|
321
|
+
* @property {object} [parent] Parent object for context
|
|
322
|
+
* @property {string} [parentProperty] Parent property name for context
|
|
323
|
+
*/
|
|
324
|
+
/**
|
|
325
|
+
* JSONPath engine options with context-aware template typing.
|
|
326
|
+
* @template [T = "json"]
|
|
327
|
+
* @typedef {BaseJTLTOptions<T> & {
|
|
328
|
+
* templates?: JSONPathTemplateArray<T>[],
|
|
329
|
+
* template?: JSONPathTemplateObject<T> | TemplateFunction<T, "json",
|
|
330
|
+
* import('./JSONPathTransformerContext.js').default
|
|
331
|
+
* >,
|
|
332
|
+
* query?: TemplateFunction<T, "json",
|
|
333
|
+
* import('./JSONPathTransformerContext.js').default
|
|
334
|
+
* >,
|
|
335
|
+
* forQuery?: [string, TemplateFunction<T, "json",
|
|
336
|
+
* import('./XPathTransformerContext.js').default
|
|
337
|
+
* >],
|
|
338
|
+
* engineType?: 'jsonpath',
|
|
339
|
+
* outputType?: T
|
|
340
|
+
* }} JSONPathJTLTOptions
|
|
341
|
+
*/
|
|
342
|
+
/**
|
|
343
|
+
* XPath engine options with context-aware template typing.
|
|
344
|
+
* @template T
|
|
345
|
+
* @typedef {BaseJTLTOptions<T> & {
|
|
346
|
+
* templates?: XPathTemplateArray<T>,
|
|
347
|
+
* template?: XPathTemplateObject<T> | TemplateFunction<T, "dom",
|
|
348
|
+
* import('./XPathTransformerContext.js').default
|
|
349
|
+
* >,
|
|
350
|
+
* query?: TemplateFunction<T, "dom",
|
|
351
|
+
* import('./XPathTransformerContext.js').default
|
|
352
|
+
* >,
|
|
353
|
+
* forQuery?: [string, TemplateFunction<T, "dom",
|
|
354
|
+
* import('./JSONPathTransformerContext.js').default
|
|
355
|
+
* >],
|
|
356
|
+
* engineType: 'xpath',
|
|
357
|
+
* xpathVersion?: 1|2,
|
|
358
|
+
* outputType?: 'string'|'dom'|'json'
|
|
359
|
+
* }} XPathJTLTOptions
|
|
360
|
+
*/
|
|
361
|
+
/**
|
|
362
|
+
* @typedef {JSONPathJTLTOptions |
|
|
363
|
+
* JSONPathJTLTOptions<"string"> |
|
|
364
|
+
* JSONPathJTLTOptions<"dom"> |
|
|
365
|
+
* XPathJTLTOptions<"json">|
|
|
366
|
+
* XPathJTLTOptions<"string">|
|
|
367
|
+
* XPathJTLTOptions<"dom">} JTLTOptions
|
|
368
|
+
*/
|
|
121
369
|
/**
|
|
122
370
|
* High-level façade for running a JTLT transform.
|
|
123
371
|
*
|
|
@@ -132,10 +380,35 @@ declare class JTLT {
|
|
|
132
380
|
* config.template, or config.templates, but one must be
|
|
133
381
|
* present and of valid type. For the source json, one must use
|
|
134
382
|
* either a valid config.ajaxData or config.data parameter.
|
|
135
|
-
* @
|
|
136
|
-
* @
|
|
383
|
+
* @overload
|
|
384
|
+
* @param {JSONPathJTLTOptions} config Options for JSONPath engine
|
|
385
|
+
*/
|
|
386
|
+
constructor(config: JSONPathJTLTOptions);
|
|
387
|
+
/**
|
|
388
|
+
* @overload
|
|
389
|
+
* @param {JSONPathJTLTOptions<"string">} config Options for JSONPath engine
|
|
390
|
+
*/
|
|
391
|
+
constructor(config: JSONPathJTLTOptions<"string">);
|
|
392
|
+
/**
|
|
393
|
+
* @overload
|
|
394
|
+
* @param {JSONPathJTLTOptions<"dom">} config Options for JSONPath engine
|
|
395
|
+
*/
|
|
396
|
+
constructor(config: JSONPathJTLTOptions<"dom">);
|
|
397
|
+
/**
|
|
398
|
+
* @overload
|
|
399
|
+
* @param {XPathJTLTOptions<"json">} config Options for XPath engine
|
|
400
|
+
*/
|
|
401
|
+
constructor(config: XPathJTLTOptions<"json">);
|
|
402
|
+
/**
|
|
403
|
+
* @overload
|
|
404
|
+
* @param {XPathJTLTOptions<"string">} config Options for XPath engine
|
|
137
405
|
*/
|
|
138
|
-
constructor(config:
|
|
406
|
+
constructor(config: XPathJTLTOptions<"string">);
|
|
407
|
+
/**
|
|
408
|
+
* @overload
|
|
409
|
+
* @param {XPathJTLTOptions<"dom">} config Options for XPath engine
|
|
410
|
+
*/
|
|
411
|
+
constructor(config: XPathJTLTOptions<"dom">);
|
|
139
412
|
/** @type {JTLTOptions} */
|
|
140
413
|
config: JTLTOptions;
|
|
141
414
|
/**
|
|
@@ -144,25 +417,25 @@ declare class JTLT {
|
|
|
144
417
|
*/
|
|
145
418
|
_createJoiningTransformer(): DOMJoiningTransformer | JSONJoiningTransformer | StringJoiningTransformer;
|
|
146
419
|
/**
|
|
147
|
-
* @param {string} mode
|
|
420
|
+
* @param {string|undefined} mode
|
|
148
421
|
* @returns {void}
|
|
149
422
|
*/
|
|
150
|
-
_autoStart(mode: string): void;
|
|
423
|
+
_autoStart(mode: string | undefined): void;
|
|
151
424
|
/**
|
|
152
425
|
* @param {JTLTOptions} config
|
|
153
426
|
* @returns {JTLT}
|
|
154
427
|
*/
|
|
155
428
|
setDefaults(config: JTLTOptions): JTLT;
|
|
156
429
|
/**
|
|
157
|
-
* @param {string} mode The mode of the transformation
|
|
158
|
-
* @returns {
|
|
430
|
+
* @param {string} [mode] The mode of the transformation
|
|
431
|
+
* @returns {void}
|
|
159
432
|
* @todo Allow for a success callback in case the jsonpath code is modified
|
|
160
433
|
* to work asynchronously (as with queries to access remote JSON
|
|
161
434
|
* stores)
|
|
162
435
|
*/
|
|
163
|
-
transform(mode
|
|
436
|
+
transform(mode?: string): void;
|
|
164
437
|
}
|
|
438
|
+
import StringJoiningTransformer from './StringJoiningTransformer.js';
|
|
165
439
|
import DOMJoiningTransformer from './DOMJoiningTransformer.js';
|
|
166
440
|
import JSONJoiningTransformer from './JSONJoiningTransformer.js';
|
|
167
|
-
import StringJoiningTransformer from './StringJoiningTransformer.js';
|
|
168
441
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;AA4iBG,0BACQ,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,GAC1C,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CACvC;;;;;;AAEE,0BACQ,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,GAC5C,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CACzC;;;;;;AAEE,0BACQ,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,GACzC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CACtC;;;;;;AAEE,0BACQ,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,GACvC,OAAO,CAAC,UAAU,CAAC,MA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CAAC,MAAM,CAAC,EAClC;;;;;IAEE,oBACQ,gBAAgB,CAAC,QAAQ,CAAC,EACpC;;;;;IAEE,oBACQ,gBAAgB,CAAC,KAAK,CAAC,EACjC;IAMC,0BAA0B;IAC1B,QADW,WAAW,CACI;IA4B5B;;;OAGG;IACH,6BAHa,qBAAqB,GAAC,sBAAsB,GACpD,wBAAwB,CAuE5B;IAED;;;OAGG;IACH,iBAHW,MAAM,GAAC,SAAS,GACd,IAAI,CAYhB;IAED;;;OAGG;IACH,oBAHW,WAAW,GACT,IAAI,CAiJhB;IAED;;;;;;OAMG;IACH,iBANW,MAAM,GACJ,IAAI,CA6ChB;CACF;qCAhiBoC,+BAA+B;kCAJlC,4BAA4B;mCAC3B,6BAA6B"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public JSDoc typedef aggregates for jtlt. Migrated from `typings/jtlt.d.ts`
|
|
3
|
+
* into a runtime JS module so declaration emit will produce `dist/types.d.ts`.
|
|
4
|
+
* Consumers can import these types in TS projects; the runtime exports are
|
|
5
|
+
* re-exported for convenience.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import('./JSONPathTransformerContext.js').default}
|
|
9
|
+
* JSONPathTransformerContext
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {import('./XPathTransformerContext.js').default}
|
|
13
|
+
* XPathTransformerContext
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {import('./AbstractJoiningTransformer.js').default<"string">|
|
|
17
|
+
* import('./AbstractJoiningTransformer.js').default<"json">|
|
|
18
|
+
* import('./AbstractJoiningTransformer.js').default<"dom">}
|
|
19
|
+
* AbstractJoiningTransformer
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {import('./DOMJoiningTransformer.js').default}
|
|
23
|
+
* DOMJoiningTransformer
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {import('./JSONJoiningTransformer.js').default}
|
|
27
|
+
* JSONJoiningTransformer
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {import('./StringJoiningTransformer.js').default}
|
|
31
|
+
* StringJoiningTransformer
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* Generic template callable bound to a context type.
|
|
35
|
+
* @template TCtx
|
|
36
|
+
* @typedef {(this: TCtx, value?: unknown,
|
|
37
|
+
* cfg?: {mode?: string}
|
|
38
|
+
* ) => unknown} TemplateFunction
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Template object with metadata and bound template function.
|
|
42
|
+
* @template TCtx
|
|
43
|
+
* @typedef {object} TemplateObject
|
|
44
|
+
* @property {string} path
|
|
45
|
+
* @property {(
|
|
46
|
+
* 'root' |
|
|
47
|
+
* 'transformRoot' |
|
|
48
|
+
* 'transformElements' |
|
|
49
|
+
* 'transformTextNodes' |
|
|
50
|
+
* 'transformScalars' |
|
|
51
|
+
* 'transformPropertyNames' |
|
|
52
|
+
* 'transformArrays' |
|
|
53
|
+
* 'transformObjects' |
|
|
54
|
+
* 'transformFunctions' |
|
|
55
|
+
* string
|
|
56
|
+
* )} [name]
|
|
57
|
+
* @property {string} [mode]
|
|
58
|
+
* @property {number} [priority]
|
|
59
|
+
* @property {TemplateFunction<TCtx>} template
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* @typedef {TemplateObject<JSONPathTransformerContext>}
|
|
63
|
+
* JSONPathTemplateObject
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* @typedef {TemplateObject<XPathTransformerContext>}
|
|
67
|
+
* XPathTemplateObject
|
|
68
|
+
*/
|
|
69
|
+
/**
|
|
70
|
+
* Options common to both engines.
|
|
71
|
+
* @typedef {object} BaseJTLTOptions
|
|
72
|
+
* @property {(result: unknown) => void} success Callback receiving transform
|
|
73
|
+
* result
|
|
74
|
+
* @property {unknown} [data] JSON object or DOM Document/Element
|
|
75
|
+
* @property {string} [ajaxData] URL for JSON retrieval
|
|
76
|
+
* @property {boolean} [errorOnEqualPriority]
|
|
77
|
+
* @property {boolean} [autostart]
|
|
78
|
+
* @property {boolean} [preventEval]
|
|
79
|
+
* @property {boolean} [unwrapSingleResult]
|
|
80
|
+
* @property {string} [mode]
|
|
81
|
+
* @property {'string'|'dom'|'json'} [outputType]
|
|
82
|
+
* @property {(opts: JTLTOptions) => unknown} [engine]
|
|
83
|
+
* @property {(path: string) => 0|0.5|-0.5} [specificityPriorityResolver]
|
|
84
|
+
* @property {AbstractJoiningTransformer} [joiningTransformer]
|
|
85
|
+
* @property {Record<string, unknown>} [joiningConfig]
|
|
86
|
+
* @property {unknown} [parent]
|
|
87
|
+
* @property {string} [parentProperty]
|
|
88
|
+
* @property {unknown[]} [forQuery]
|
|
89
|
+
*/
|
|
90
|
+
/**
|
|
91
|
+
* JSONPath engine options.
|
|
92
|
+
* @typedef {BaseJTLTOptions & {
|
|
93
|
+
* templates?: JSONPathTemplateObject[] |
|
|
94
|
+
* TemplateFunction<JSONPathTransformerContext>,
|
|
95
|
+
* template?: JSONPathTemplateObject |
|
|
96
|
+
* TemplateFunction<JSONPathTransformerContext>,
|
|
97
|
+
* query?: TemplateFunction<JSONPathTransformerContext>,
|
|
98
|
+
* engineType?: 'jsonpath'
|
|
99
|
+
* }} JSONPathJTLTOptions
|
|
100
|
+
*/
|
|
101
|
+
/**
|
|
102
|
+
* XPath engine options.
|
|
103
|
+
* @typedef {BaseJTLTOptions & {
|
|
104
|
+
* templates?: XPathTemplateObject[] |
|
|
105
|
+
* TemplateFunction<XPathTransformerContext>,
|
|
106
|
+
* template?: XPathTemplateObject |
|
|
107
|
+
* TemplateFunction<XPathTransformerContext>,
|
|
108
|
+
* query?: TemplateFunction<XPathTransformerContext>,
|
|
109
|
+
* engineType: 'xpath',
|
|
110
|
+
* xpathVersion?: 1|2
|
|
111
|
+
* }} XPathJTLTOptions
|
|
112
|
+
*/
|
|
113
|
+
/** @typedef {JSONPathJTLTOptions | XPathJTLTOptions} JTLTOptions */
|
|
114
|
+
/**
|
|
115
|
+
* Internal options extension adding private runtime state flags.
|
|
116
|
+
* Not part of the public API surface but used for narrowing casts.
|
|
117
|
+
* @typedef {JTLTOptions & {
|
|
118
|
+
* _customJoiningTransformer?: boolean
|
|
119
|
+
* }} InternalJTLTOptions
|
|
120
|
+
*/
|
|
121
|
+
export const typesModuleMarker: true;
|
|
122
|
+
export type JSONPathTransformerContext = import("./JSONPathTransformerContext.js").default;
|
|
123
|
+
export type XPathTransformerContext = import("./XPathTransformerContext.js").default;
|
|
124
|
+
export type AbstractJoiningTransformer = import("./AbstractJoiningTransformer.js").default<"string"> | import("./AbstractJoiningTransformer.js").default<"json"> | import("./AbstractJoiningTransformer.js").default<"dom">;
|
|
125
|
+
export type DOMJoiningTransformer = import("./DOMJoiningTransformer.js").default;
|
|
126
|
+
export type JSONJoiningTransformer = import("./JSONJoiningTransformer.js").default;
|
|
127
|
+
export type StringJoiningTransformer = import("./StringJoiningTransformer.js").default;
|
|
128
|
+
/**
|
|
129
|
+
* Generic template callable bound to a context type.
|
|
130
|
+
*/
|
|
131
|
+
export type TemplateFunction<TCtx> = (this: TCtx, value?: unknown, cfg?: {
|
|
132
|
+
mode?: string;
|
|
133
|
+
}) => unknown;
|
|
134
|
+
/**
|
|
135
|
+
* Template object with metadata and bound template function.
|
|
136
|
+
*/
|
|
137
|
+
export type TemplateObject<TCtx> = {
|
|
138
|
+
path: string;
|
|
139
|
+
name?: string | undefined;
|
|
140
|
+
mode?: string | undefined;
|
|
141
|
+
priority?: number | undefined;
|
|
142
|
+
template: TemplateFunction<TCtx>;
|
|
143
|
+
};
|
|
144
|
+
export type JSONPathTemplateObject = TemplateObject<JSONPathTransformerContext>;
|
|
145
|
+
export type XPathTemplateObject = TemplateObject<XPathTransformerContext>;
|
|
146
|
+
/**
|
|
147
|
+
* Options common to both engines.
|
|
148
|
+
*/
|
|
149
|
+
export type BaseJTLTOptions = {
|
|
150
|
+
/**
|
|
151
|
+
* Callback receiving transform
|
|
152
|
+
* result
|
|
153
|
+
*/
|
|
154
|
+
success: (result: unknown) => void;
|
|
155
|
+
/**
|
|
156
|
+
* JSON object or DOM Document/Element
|
|
157
|
+
*/
|
|
158
|
+
data?: unknown;
|
|
159
|
+
/**
|
|
160
|
+
* URL for JSON retrieval
|
|
161
|
+
*/
|
|
162
|
+
ajaxData?: string | undefined;
|
|
163
|
+
errorOnEqualPriority?: boolean | undefined;
|
|
164
|
+
autostart?: boolean | undefined;
|
|
165
|
+
preventEval?: boolean | undefined;
|
|
166
|
+
unwrapSingleResult?: boolean | undefined;
|
|
167
|
+
mode?: string | undefined;
|
|
168
|
+
outputType?: "string" | "dom" | "json" | undefined;
|
|
169
|
+
engine?: ((opts: JTLTOptions) => unknown) | undefined;
|
|
170
|
+
specificityPriorityResolver?: ((path: string) => 0 | 0.5 | -0.5) | undefined;
|
|
171
|
+
joiningTransformer?: AbstractJoiningTransformer | undefined;
|
|
172
|
+
joiningConfig?: Record<string, unknown> | undefined;
|
|
173
|
+
parent?: unknown;
|
|
174
|
+
parentProperty?: string | undefined;
|
|
175
|
+
forQuery?: unknown[] | undefined;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* JSONPath engine options.
|
|
179
|
+
*/
|
|
180
|
+
export type JSONPathJTLTOptions = BaseJTLTOptions & {
|
|
181
|
+
templates?: JSONPathTemplateObject[] | TemplateFunction<JSONPathTransformerContext>;
|
|
182
|
+
template?: JSONPathTemplateObject | TemplateFunction<JSONPathTransformerContext>;
|
|
183
|
+
query?: TemplateFunction<JSONPathTransformerContext>;
|
|
184
|
+
engineType?: "jsonpath";
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* XPath engine options.
|
|
188
|
+
*/
|
|
189
|
+
export type XPathJTLTOptions = BaseJTLTOptions & {
|
|
190
|
+
templates?: XPathTemplateObject[] | TemplateFunction<XPathTransformerContext>;
|
|
191
|
+
template?: XPathTemplateObject | TemplateFunction<XPathTransformerContext>;
|
|
192
|
+
query?: TemplateFunction<XPathTransformerContext>;
|
|
193
|
+
engineType: "xpath";
|
|
194
|
+
xpathVersion?: 1 | 2;
|
|
195
|
+
};
|
|
196
|
+
export type JTLTOptions = JSONPathJTLTOptions | XPathJTLTOptions;
|
|
197
|
+
/**
|
|
198
|
+
* Internal options extension adding private runtime state flags.
|
|
199
|
+
* Not part of the public API surface but used for narrowing casts.
|
|
200
|
+
*/
|
|
201
|
+
export type InternalJTLTOptions = JTLTOptions & {
|
|
202
|
+
_customJoiningTransformer?: boolean;
|
|
203
|
+
};
|
|
204
|
+
//# sourceMappingURL=types.d.ts.map
|