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.
Files changed (57) hide show
  1. package/CHANGES.md +5 -0
  2. package/README.md +9 -5
  3. package/demo/calltemplate-params-demo.js +19 -15
  4. package/demo/codemirror.esm.js +140 -70
  5. package/demo/codemirror.js +9 -5
  6. package/demo/index.js +2 -1
  7. package/demo/vendor/fontoxpath/dist/fontoxpath.esm.js +508 -499
  8. package/demo/vendor/jamilih/dist/jml.mjs +516 -225
  9. package/demo/vendor/jsonpath-plus/dist/index-browser-esm.js +11 -5
  10. package/dist/AbstractJoiningTransformer.d.ts +12 -20
  11. package/dist/AbstractJoiningTransformer.d.ts.map +1 -1
  12. package/dist/DOMJoiningTransformer.d.ts +502 -19
  13. package/dist/DOMJoiningTransformer.d.ts.map +1 -1
  14. package/dist/JSONJoiningTransformer.d.ts +41 -25
  15. package/dist/JSONJoiningTransformer.d.ts.map +1 -1
  16. package/dist/JSONPathTransformer.d.ts +20 -20
  17. package/dist/JSONPathTransformer.d.ts.map +1 -1
  18. package/dist/JSONPathTransformerContext.d.ts +103 -80
  19. package/dist/JSONPathTransformerContext.d.ts.map +1 -1
  20. package/dist/StringJoiningTransformer.d.ts +42 -28
  21. package/dist/StringJoiningTransformer.d.ts.map +1 -1
  22. package/dist/XPathTransformer.d.ts +11 -11
  23. package/dist/XPathTransformer.d.ts.map +1 -1
  24. package/dist/XPathTransformerContext.d.ts +47 -45
  25. package/dist/XPathTransformerContext.d.ts.map +1 -1
  26. package/dist/XSLTStyleJSONPathResolver.d.ts +1 -1
  27. package/dist/XSLTStyleJSONPathResolver.d.ts.map +1 -1
  28. package/dist/index-browser.d.ts +2 -2
  29. package/dist/index-browser.d.ts.map +1 -1
  30. package/dist/index-node.d.ts +2 -2
  31. package/dist/index-node.d.ts.map +1 -1
  32. package/dist/index.d.ts +126 -167
  33. package/dist/index.d.ts.map +1 -1
  34. package/docs/API.expanded.md +6 -4
  35. package/docs/API.md +1 -1
  36. package/docs/TO-DO.md +4 -2
  37. package/eslint.config.js +17 -1
  38. package/package.json +23 -22
  39. package/pnpm-workspace.yaml +32 -4
  40. package/rollup.config.js +42 -0
  41. package/src/AbstractJoiningTransformer.js +8 -1
  42. package/src/DOMJoiningTransformer.js +56 -27
  43. package/src/JSONJoiningTransformer.js +64 -44
  44. package/src/JSONPathTransformer.js +86 -85
  45. package/src/JSONPathTransformerContext.js +95 -48
  46. package/src/StringJoiningTransformer.js +48 -23
  47. package/src/XPathTransformer.js +18 -14
  48. package/src/XPathTransformerContext.js +173 -123
  49. package/src/index-browser.js +1 -0
  50. package/src/index-node.js +2 -0
  51. package/src/index.js +125 -68
  52. package/test.html +17 -0
  53. package/test.js +45 -0
  54. package/tsconfig-prod.json +1 -0
  55. package/tsconfig.json +3 -2
  56. package/dist/types.d.ts +0 -204
  57. package/dist/types.d.ts.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,213 +1,156 @@
1
+ import DOMJoiningTransformer from './DOMJoiningTransformer.js';
2
+ import JSONJoiningTransformer from './JSONJoiningTransformer.js';
3
+ import StringJoiningTransformer from './StringJoiningTransformer.js';
1
4
  /**
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;
41
- export { default as AbstractJoiningTransformer } from "./AbstractJoiningTransformer.js";
42
- export { default as StringJoiningTransformer } from "./StringJoiningTransformer.js";
43
- export { default as DOMJoiningTransformer } from "./DOMJoiningTransformer.js";
44
- export { default as JSONJoiningTransformer } from "./JSONJoiningTransformer.js";
45
- export { default as XSLTStyleJSONPathResolver } from "./XSLTStyleJSONPathResolver.js";
46
- export { default as JSONPathTransformerContext } from "./JSONPathTransformerContext.js";
47
- export { default as JSONPathTransformer } from "./JSONPathTransformer.js";
48
- export { default as XPathTransformerContext } from "./XPathTransformerContext.js";
49
- export { default as XPathTransformer } from "./XPathTransformer.js";
50
- export default JTLT;
51
- /**
52
- * Internal options extension adding private runtime state flags.
53
- * Not part of the public API surface but used for narrowing casts.
5
+ * @param {import('jsdom').DOMWindow | typeof globalThis} win
54
6
  */
7
+ export declare const setWindow: (win: import('jsdom').DOMWindow | typeof globalThis) => void;
55
8
  export type InternalJTLTOptions = JTLTOptions & {
56
9
  _customJoiningTransformer?: boolean;
57
10
  };
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
11
  export type TemplateObject<T, U, TCtx> = {
65
12
  /**
66
13
  * - JSONPath or XPath selector for matching nodes
67
14
  */
68
- path?: string | undefined;
15
+ path?: string;
69
16
  /**
70
17
  * - Alias for 'path' (XSLT compatibility)
71
18
  */
72
- match?: string | undefined;
19
+ match?: string;
73
20
  /**
74
21
  * - Optional name for calling via callTemplate
75
22
  */
76
- name?: string | undefined;
23
+ name?: string;
77
24
  /**
78
25
  * - Optional mode for template matching
79
26
  */
80
- mode?: string | undefined;
27
+ mode?: string;
81
28
  /**
82
29
  * - Priority for template selection
83
30
  */
84
- priority?: number | undefined;
31
+ priority?: number;
85
32
  /**
86
33
  * - Template function
87
34
  */
88
35
  template: TemplateFunction<T, U, TCtx>;
89
36
  };
90
- /**
91
- * A callable template function with an engine-specific `this`.
92
- */
93
37
  export type TemplateFunction<T, U, TCtx> = (this: TCtx, value: ResultType<U>, cfg?: {
94
38
  mode?: string;
95
39
  }) => ResultType<T> | void;
96
- export type JSONPathTemplateObject<T> = TemplateObject<T, "json", import("./JSONPathTransformerContext.js").default<T>>;
97
- export type XPathTemplateObject<T> = TemplateObject<T, "dom", import("./XPathTransformerContext.js").default>;
98
- export type XPathTemplateArray<T> = (XPathTemplateObject<T> | [string, TemplateFunction<T, "dom", import("./XPathTransformerContext.js").default>])[];
99
- export type JSONPathTemplateArray<T> = JSONPathTemplateObject<T> | [string, TemplateFunction<T, "json", import("./JSONPathTransformerContext.js").default>];
40
+ export type JSONPathTemplateObject<T extends "json" | "string" | "dom"> = TemplateObject<T, "json", import('./JSONPathTransformerContext.js').default<T>>;
41
+ export type XPathTemplateObject<T> = TemplateObject<T, "dom", import('./XPathTransformerContext.js').default>;
42
+ export type XPathTemplateArray<T> = (XPathTemplateObject<T> | [
43
+ string,
44
+ TemplateFunction<T, "dom", import('./XPathTransformerContext.js').default>
45
+ ])[];
46
+ export type JSONPathTemplateArray<T extends "json" | "string" | "dom"> = JSONPathTemplateObject<T> | [
47
+ string,
48
+ TemplateFunction<T, "json", import('./JSONPathTransformerContext.js').default>
49
+ ];
100
50
  export type JoiningTransformer = (StringJoiningTransformer | DOMJoiningTransformer | JSONJoiningTransformer);
101
51
  export type joiningTypes = "json" | "string" | "dom";
102
- export type ResultType<T> = T extends "json" ? unknown : T extends "string" ? string : DocumentFragment | Element;
103
- /**
104
- * Options common to both engines.
105
- */
106
- export type BaseJTLTOptions<T> = {
52
+ export type ResultType<T, E extends boolean | undefined = false> = T extends "json" ? (E extends true ? any[] : unknown) : T extends "string" ? (E extends true ? string[] : string) : (E extends true ? XMLDocument[] : DocumentFragment | Element);
53
+ export type BaseJTLTOptions<T, E extends boolean | undefined = false> = {
107
54
  /**
108
55
  * A callback supplied
109
56
  * with a single argument that is the result of this instance's
110
57
  * transform() method. When used in TypeScript, this can be made
111
58
  * generic as `success<T>(result: T): void`.
112
59
  */
113
- success: (result: ResultType<T>) => void;
60
+ success: (result: ResultType<T, E>) => ResultType<T, E> | void;
114
61
  /**
115
62
  * A JSON
116
63
  * object or DOM document (XPath)
117
64
  */
118
- data?: string | number | boolean | object | null | undefined;
65
+ data?: null | boolean | number | string | object;
119
66
  /**
120
67
  * URL of a JSON file to retrieve for
121
68
  * evaluation
122
69
  */
123
- ajaxData?: string | undefined;
70
+ ajaxData?: string;
124
71
  /**
125
72
  * Whether or not to
126
73
  * report an error when equal priority templates are found
127
74
  */
128
- errorOnEqualPriority?: boolean | undefined;
75
+ errorOnEqualPriority?: boolean;
129
76
  /**
130
77
  * Whether to begin transform()
131
78
  * immediately.
132
79
  */
133
- autostart?: boolean | undefined;
80
+ autostart?: boolean;
134
81
  /**
135
82
  * Whether to prevent
136
83
  * parenthetical evaluations in JSONPath. Safer if relying on user
137
84
  * input, but reduces capabilities of JSONPath.
138
85
  */
139
- preventEval?: boolean | undefined;
86
+ preventEval?: boolean;
140
87
  /**
141
88
  * For JSON output, whether to
142
89
  * unwrap single-element root arrays to return just the element
143
90
  */
144
- unwrapSingleResult?: boolean | undefined;
91
+ unwrapSingleResult?: boolean;
145
92
  /**
146
93
  * When true, joiners return an array
147
94
  * of complete documents: XMLDocument[] for DOM, document wrapper objects[]
148
95
  * for JSON, and string[] for string joiners. Each array element corresponds
149
96
  * to a root element built during transformation.
150
97
  */
151
- exposeDocuments?: boolean | undefined;
98
+ exposeDocuments?: E;
152
99
  /**
153
100
  * The mode in which to begin the transform.
154
101
  */
155
- mode?: string | undefined;
102
+ mode?: string;
156
103
  /**
157
104
  * Will be based on the
158
105
  * same config as passed to this instance. Defaults to a transforming
159
106
  * function based on JSONPath and with its own set of priorities for
160
107
  * processing templates.
161
108
  */
162
- engine?: ((opts: JTLTOptions & Required<Pick<JTLTOptions, "joiningTransformer">>) => ResultType<T>) | undefined;
109
+ engine?: (opts: JTLTOptions & Required<Pick<JTLTOptions, "joiningTransformer">>) => ResultType<T, E>;
163
110
  /**
164
111
  * Callback for getting the priority by specificity
165
112
  */
166
- specificityPriorityResolver?: ((path: string) => 0 | 0.5 | -0.5) | undefined;
113
+ specificityPriorityResolver?: null | ((path: string) => 0 | 0.5 | -0.5);
167
114
  /**
168
115
  * A concrete joining transformer instance (or custom subclass) responsible
169
116
  * for accumulating output. When omitted, one is created automatically based
170
117
  * on `outputType`.
171
118
  */
172
- joiningTransformer?: JoiningTransformer | undefined;
119
+ joiningTransformer?: JoiningTransformer;
173
120
  /**
174
121
  * Config for the joining
175
122
  * transformer.
176
123
  */
177
- joiningConfig?: import("./AbstractJoiningTransformer.js").JoiningTransformerConfig<T> | undefined;
124
+ joiningConfig?: import('./AbstractJoiningTransformer.js').JoiningTransformerConfig<T> & {
125
+ exposeDocuments?: E;
126
+ };
178
127
  /**
179
128
  * Parent object for context
180
129
  */
181
- parent?: object | undefined;
130
+ parent?: object;
182
131
  /**
183
132
  * Parent property name for context
184
133
  */
185
- parentProperty?: string | undefined;
134
+ parentProperty?: string;
186
135
  };
187
- /**
188
- * JSONPath engine options with context-aware template typing.
189
- */
190
- export type JSONPathJTLTOptions<T = "json"> = BaseJTLTOptions<T> & {
191
- templates?: JSONPathTemplateArray<T>[];
192
- template?: JSONPathTemplateObject<T> | TemplateFunction<T, "json", import("./JSONPathTransformerContext.js").default>;
193
- query?: TemplateFunction<T, "json", import("./JSONPathTransformerContext.js").default>;
194
- forQuery?: [string, TemplateFunction<T, "json", import("./XPathTransformerContext.js").default>];
195
- engineType?: "jsonpath";
136
+ export type JSONPathJTLTOptions<T extends "json" | "string" | "dom" = "json", E extends boolean | undefined = false> = BaseJTLTOptions<T, E> & {
137
+ templates?: JSONPathTemplateArray<T>[] | TemplateFunction<T, "json", import('./JSONPathTransformerContext.js').default<T>>;
138
+ template?: JSONPathTemplateObject<T> | TemplateFunction<T, "json", import('./JSONPathTransformerContext.js').default>;
139
+ query?: TemplateFunction<T, "json", import('./JSONPathTransformerContext.js').default>;
140
+ forQuery?: [string, TemplateFunction<T, "json", import('./XPathTransformerContext.js').default>];
141
+ engineType?: 'jsonpath';
196
142
  outputType?: T;
197
143
  };
198
- /**
199
- * XPath engine options with context-aware template typing.
200
- */
201
- export type XPathJTLTOptions<T> = BaseJTLTOptions<T> & {
202
- templates?: XPathTemplateArray<T>;
203
- template?: XPathTemplateObject<T> | TemplateFunction<T, "dom", import("./XPathTransformerContext.js").default>;
204
- query?: TemplateFunction<T, "dom", import("./XPathTransformerContext.js").default>;
205
- forQuery?: [string, TemplateFunction<T, "dom", import("./JSONPathTransformerContext.js").default>];
206
- engineType: "xpath";
144
+ export type XPathJTLTOptions<T extends "json" | "string" | "dom", E extends boolean | undefined = false> = BaseJTLTOptions<T, E> & {
145
+ templates?: XPathTemplateArray<T> | TemplateFunction<T, "dom", import('./XPathTransformerContext.js').default<T>>;
146
+ template?: XPathTemplateObject<T> | TemplateFunction<T, "dom", import('./XPathTransformerContext.js').default>;
147
+ query?: TemplateFunction<T, "dom", import('./XPathTransformerContext.js').default>;
148
+ forQuery?: [string, TemplateFunction<T, "dom", import('./JSONPathTransformerContext.js').default>];
149
+ engineType: 'xpath';
207
150
  xpathVersion?: 1 | 2 | 3.1;
208
151
  outputType?: T;
209
152
  };
210
- export type JTLTOptions = JSONPathJTLTOptions | JSONPathJTLTOptions<"string"> | JSONPathJTLTOptions<"dom"> | XPathJTLTOptions<"json"> | XPathJTLTOptions<"string"> | XPathJTLTOptions<"dom">;
153
+ export type JTLTOptions<E extends boolean | undefined = any> = JSONPathJTLTOptions<"json", E> | JSONPathJTLTOptions<"string", E> | JSONPathJTLTOptions<"dom", E> | XPathJTLTOptions<"json", E> | XPathJTLTOptions<"string", E> | XPathJTLTOptions<"dom", E>;
211
154
  /**
212
155
  * Internal options extension adding private runtime state flags.
213
156
  * Not part of the public API surface but used for narrowing casts.
@@ -242,7 +185,7 @@ export type JTLTOptions = JSONPathJTLTOptions | JSONPathJTLTOptions<"string"> |
242
185
  * ) => ResultType<T>|void} TemplateFunction
243
186
  */
244
187
  /**
245
- * @template T
188
+ * @template {"json"|"string"|"dom"} T
246
189
  * @typedef {TemplateObject<T, "json",
247
190
  * import('./JSONPathTransformerContext.js').default<T>
248
191
  * >} JSONPathTemplateObject
@@ -260,7 +203,7 @@ export type JTLTOptions = JSONPathJTLTOptions | JSONPathJTLTOptions<"string"> |
260
203
  * >])[]} XPathTemplateArray
261
204
  */
262
205
  /**
263
- * @template T
206
+ * @template {"json"|"string"|"dom"} T
264
207
  * @typedef {JSONPathTemplateObject<T> | [string, TemplateFunction<T, "json",
265
208
  * import('./JSONPathTransformerContext.js').default
266
209
  * >]} JSONPathTemplateArray
@@ -277,16 +220,22 @@ export type JTLTOptions = JSONPathJTLTOptions | JSONPathJTLTOptions<"string"> |
277
220
  */
278
221
  /**
279
222
  * @template T
280
- * @typedef {T extends "json" ? unknown : T extends "string" ? string :
281
- * DocumentFragment|Element} ResultType
223
+ * @template {boolean|undefined} [E=false]
224
+ * @typedef {T extends "json" ?
225
+ * (E extends true ? any[] : unknown) :
226
+ * T extends "string" ?
227
+ * (E extends true ? string[] : string) :
228
+ * (E extends true ? XMLDocument[] :
229
+ * DocumentFragment|Element)} ResultType
282
230
  */
283
231
  /**
284
232
  * Options common to both engines.
285
233
  * @template T
234
+ * @template {boolean|undefined} [E=false]
286
235
  * @typedef {object} BaseJTLTOptions
287
236
  * @property {(
288
- * result: ResultType<T>
289
- * ) => void} success A callback supplied
237
+ * result: ResultType<T, E>
238
+ * ) => ResultType<T, E>|void} success A callback supplied
290
239
  * with a single argument that is the result of this instance's
291
240
  * transform() method. When used in TypeScript, this can be made
292
241
  * generic as `success<T>(result: T): void`.
@@ -303,34 +252,40 @@ export type JTLTOptions = JSONPathJTLTOptions | JSONPathJTLTOptions<"string"> |
303
252
  * input, but reduces capabilities of JSONPath.
304
253
  * @property {boolean} [unwrapSingleResult] For JSON output, whether to
305
254
  * unwrap single-element root arrays to return just the element
306
- * @property {boolean} [exposeDocuments] When true, joiners return an array
255
+ * @property {E} [exposeDocuments] When true, joiners return an array
307
256
  * of complete documents: XMLDocument[] for DOM, document wrapper objects[]
308
257
  * for JSON, and string[] for string joiners. Each array element corresponds
309
258
  * to a root element built during transformation.
310
259
  * @property {string} [mode] The mode in which to begin the transform.
311
260
  * @property {(opts: JTLTOptions &
312
261
  * Required<Pick<JTLTOptions, "joiningTransformer">>
313
- * ) => ResultType<T>} [engine] Will be based on the
262
+ * ) => ResultType<T, E>} [engine] Will be based on the
314
263
  * same config as passed to this instance. Defaults to a transforming
315
264
  * function based on JSONPath and with its own set of priorities for
316
265
  * processing templates.
317
- * @property {(path: string) => 0 | 0.5 | -0.5} [specificityPriorityResolver]
266
+ * @property {null|(
267
+ * (path: string) => 0 | 0.5 | -0.5
268
+ * )} [specificityPriorityResolver]
318
269
  * Callback for getting the priority by specificity
319
270
  * @property {JoiningTransformer} [joiningTransformer]
320
271
  * A concrete joining transformer instance (or custom subclass) responsible
321
272
  * for accumulating output. When omitted, one is created automatically based
322
273
  * on `outputType`.
323
274
  * @property {import('./AbstractJoiningTransformer.js').
324
- * JoiningTransformerConfig<T>} [joiningConfig] Config for the joining
275
+ * JoiningTransformerConfig<T> &
276
+ * {exposeDocuments?: E}} [joiningConfig] Config for the joining
325
277
  * transformer.
326
278
  * @property {object} [parent] Parent object for context
327
279
  * @property {string} [parentProperty] Parent property name for context
328
280
  */
329
281
  /**
330
282
  * JSONPath engine options with context-aware template typing.
331
- * @template [T = "json"]
332
- * @typedef {BaseJTLTOptions<T> & {
333
- * templates?: JSONPathTemplateArray<T>[],
283
+ * @template {"json"|"string"|"dom"} [T = "json"]
284
+ * @template {boolean|undefined} [E=false]
285
+ * @typedef {BaseJTLTOptions<T, E> & {
286
+ * templates?: JSONPathTemplateArray<T>[] |
287
+ * TemplateFunction<T, "json",
288
+ * import('./JSONPathTransformerContext.js').default<T>>,
334
289
  * template?: JSONPathTemplateObject<T> | TemplateFunction<T, "json",
335
290
  * import('./JSONPathTransformerContext.js').default
336
291
  * >,
@@ -346,9 +301,12 @@ export type JTLTOptions = JSONPathJTLTOptions | JSONPathJTLTOptions<"string"> |
346
301
  */
347
302
  /**
348
303
  * XPath engine options with context-aware template typing.
349
- * @template T
350
- * @typedef {BaseJTLTOptions<T> & {
351
- * templates?: XPathTemplateArray<T>,
304
+ * @template {"json"|"string"|"dom"} T
305
+ * @template {boolean|undefined} [E=false]
306
+ * @typedef {BaseJTLTOptions<T, E> & {
307
+ * templates?: XPathTemplateArray<T> |
308
+ * TemplateFunction<T, "dom",
309
+ * import('./XPathTransformerContext.js').default<T>>,
352
310
  * template?: XPathTemplateObject<T> | TemplateFunction<T, "dom",
353
311
  * import('./XPathTransformerContext.js').default
354
312
  * >,
@@ -364,12 +322,13 @@ export type JTLTOptions = JSONPathJTLTOptions | JSONPathJTLTOptions<"string"> |
364
322
  * }} XPathJTLTOptions
365
323
  */
366
324
  /**
367
- * @typedef {JSONPathJTLTOptions |
368
- * JSONPathJTLTOptions<"string"> |
369
- * JSONPathJTLTOptions<"dom"> |
370
- * XPathJTLTOptions<"json">|
371
- * XPathJTLTOptions<"string">|
372
- * XPathJTLTOptions<"dom">} JTLTOptions
325
+ * @template {boolean|undefined} [E=any]
326
+ * @typedef {JSONPathJTLTOptions<"json", E> |
327
+ * JSONPathJTLTOptions<"string", E> |
328
+ * JSONPathJTLTOptions<"dom", E> |
329
+ * XPathJTLTOptions<"json", E>|
330
+ * XPathJTLTOptions<"string", E>|
331
+ * XPathJTLTOptions<"dom", E>} JTLTOptions
373
332
  */
374
333
  /**
375
334
  * High-level façade for running a JTLT transform.
@@ -378,44 +337,25 @@ export type JTLTOptions = JSONPathJTLTOptions | JSONPathJTLTOptions<"string"> |
378
337
  * transformer based on `outputType`, and invokes the JSONPath-based engine.
379
338
  * The result is returned to the required `success` callback and also returned
380
339
  * from transform().
340
+ * @template {"json"|"string"|"dom"} [T="json"]
341
+ * @template {boolean|undefined} [E=false]
381
342
  */
382
- declare class JTLT {
343
+ declare class JTLT<T extends "json" | "string" | "dom" = "json", E extends boolean | undefined = false> {
344
+ /** @type {any} */
345
+ config: any;
383
346
  /**
384
- * For templates/queries, one may choose among config.query,
385
- * config.template, or config.templates, but one must be
386
- * present and of valid type. For the source json, one must use
387
- * either a valid config.ajaxData or config.data parameter.
388
- * @overload
389
- * @param {JSONPathJTLTOptions} config Options for JSONPath engine
347
+ * @template {"json"|"string"|"dom"} [T="json"]
348
+ * @template {boolean|undefined} [E=false]
349
+ * @param {JSONPathJTLTOptions<T, E> | XPathJTLTOptions<T, E>} config
350
+ * @returns {JTLT<T, E>}
390
351
  */
352
+ static create<T extends "json" | "string" | "dom" = "json", E extends boolean | undefined = false>(config: JSONPathJTLTOptions<T, E> | XPathJTLTOptions<T, E>): JTLT<T, E>;
391
353
  constructor(config: JSONPathJTLTOptions);
392
- /**
393
- * @overload
394
- * @param {JSONPathJTLTOptions<"string">} config Options for JSONPath engine
395
- */
396
354
  constructor(config: JSONPathJTLTOptions<"string">);
397
- /**
398
- * @overload
399
- * @param {JSONPathJTLTOptions<"dom">} config Options for JSONPath engine
400
- */
401
355
  constructor(config: JSONPathJTLTOptions<"dom">);
402
- /**
403
- * @overload
404
- * @param {XPathJTLTOptions<"json">} config Options for XPath engine
405
- */
406
356
  constructor(config: XPathJTLTOptions<"json">);
407
- /**
408
- * @overload
409
- * @param {XPathJTLTOptions<"string">} config Options for XPath engine
410
- */
411
357
  constructor(config: XPathJTLTOptions<"string">);
412
- /**
413
- * @overload
414
- * @param {XPathJTLTOptions<"dom">} config Options for XPath engine
415
- */
416
358
  constructor(config: XPathJTLTOptions<"dom">);
417
- /** @type {JTLTOptions} */
418
- config: JTLTOptions;
419
359
  /**
420
360
  * @returns {DOMJoiningTransformer|JSONJoiningTransformer|
421
361
  * StringJoiningTransformer}
@@ -427,20 +367,39 @@ declare class JTLT {
427
367
  */
428
368
  _autoStart(mode: string | undefined): void;
429
369
  /**
430
- * @param {JTLTOptions} config
370
+ * @param {null|JTLTOptions} config
431
371
  * @returns {JTLT}
432
372
  */
433
- setDefaults(config: JTLTOptions): JTLT;
373
+ setDefaults(config: null | JTLTOptions): JTLT;
434
374
  /**
435
375
  * @param {string} [mode] The mode of the transformation
436
- * @returns {void}
376
+ * @returns {ResultType<T, E>}
437
377
  * @todo Allow for a success callback in case the jsonpath code is modified
438
378
  * to work asynchronously (as with queries to access remote JSON
439
379
  * stores)
440
380
  */
441
- transform(mode?: string): void;
381
+ transform(mode?: string): ResultType<T, E>;
442
382
  }
443
- import StringJoiningTransformer from './StringJoiningTransformer.js';
444
- import DOMJoiningTransformer from './DOMJoiningTransformer.js';
445
- import JSONJoiningTransformer from './JSONJoiningTransformer.js';
383
+ export declare function jtlt(cfg: Omit<JSONPathJTLTOptions<"json", false>, "success">): Promise<ResultType<"json", false>>;
384
+ export declare function jtlt(cfg: Omit<JSONPathJTLTOptions<"json", true>, "success">): Promise<ResultType<"json", true>>;
385
+ export declare function jtlt(cfg: Omit<JSONPathJTLTOptions<"string", false>, "success">): Promise<ResultType<"string", false>>;
386
+ export declare function jtlt(cfg: Omit<JSONPathJTLTOptions<"string", true>, "success">): Promise<ResultType<"string", true>>;
387
+ export declare function jtlt(cfg: Omit<JSONPathJTLTOptions<"dom", false>, "success">): Promise<ResultType<"dom", false>>;
388
+ export declare function jtlt(cfg: Omit<JSONPathJTLTOptions<"dom", true>, "success">): Promise<ResultType<"dom", true>>;
389
+ export declare function jtlt(cfg: Omit<XPathJTLTOptions<"json", false>, "success">): Promise<ResultType<"json", false>>;
390
+ export declare function jtlt(cfg: Omit<XPathJTLTOptions<"json", true>, "success">): Promise<ResultType<"json", true>>;
391
+ export declare function jtlt(cfg: Omit<XPathJTLTOptions<"dom", false>, "success">): Promise<ResultType<"dom", false>>;
392
+ export declare function jtlt(cfg: Omit<XPathJTLTOptions<"dom", true>, "success">): Promise<ResultType<"dom", true>>;
393
+ export declare function jtlt(cfg: Omit<XPathJTLTOptions<"string", false>, "success">): Promise<ResultType<"string", false>>;
394
+ export declare function jtlt(cfg: Omit<XPathJTLTOptions<"string", true>, "success">): Promise<ResultType<"string", true>>;
395
+ export { default as AbstractJoiningTransformer } from './AbstractJoiningTransformer.js';
396
+ export { default as StringJoiningTransformer } from './StringJoiningTransformer.js';
397
+ export { default as DOMJoiningTransformer } from './DOMJoiningTransformer.js';
398
+ export { default as JSONJoiningTransformer } from './JSONJoiningTransformer.js';
399
+ export { default as XSLTStyleJSONPathResolver } from './XSLTStyleJSONPathResolver.js';
400
+ export { default as JSONPathTransformerContext } from './JSONPathTransformerContext.js';
401
+ export { default as JSONPathTransformer } from './JSONPathTransformer.js';
402
+ export { default as XPathTransformerContext } from './XPathTransformerContext.js';
403
+ export { default as XPathTransformer } from './XPathTransformer.js';
404
+ export default JTLT;
446
405
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;AAsjBG,0BACQ,IAAI,CAAC,mBAAmB,CAAC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FrC;AAKR,wBAQY,IAAI,CAP0C,GAAG,EAAtD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,SAAS,CACxD,GAAU,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAFpC;AAqFZ,OAAO,EACL,OAAO,IAAI,0BAA0B,EACtC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,OAAO,IAAI,wBAAwB,EACpC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,OAAO,IAAI,qBAAqB,EACjC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,OAAO,IAAI,sBAAsB,EAClC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,OAAO,IAAI,yBAAyB,EACrC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,OAAO,IAAI,0BAA0B,EACtC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,OAAO,IAAI,mBAAmB,EAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,OAAO,IAAI,uBAAuB,EACnC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,OAAO,IAAI,gBAAgB,EAC5B,MAAM,uBAAuB,CAAC;eAEhB,IAAI"}
@@ -11,7 +11,7 @@ High-level entry point for running a transform over JSON data using JSONPath.
11
11
  ```js
12
12
  import JTLT from 'jtlt';
13
13
 
14
- const out = new JTLT({
14
+ const out = JTLT.create({
15
15
  data: {title: 'Hello'},
16
16
  outputType: 'string',
17
17
  templates: [
@@ -27,7 +27,7 @@ const out = new JTLT({
27
27
  }).transform('');
28
28
  ```
29
29
 
30
- ### `new JTLT(config)` options
30
+ ### `new JTLT(config)` or `JTLT.create(config)` options
31
31
 
32
32
  | Option | Type | Description |
33
33
  | ------ | ---- | ----------- |
@@ -57,7 +57,7 @@ interface TemplateObject {
57
57
  path?: string; // JSONPath or XPath expression (required for pattern-matching)
58
58
  mode?: string; // Optional mode segregation
59
59
  priority?: number; // Numeric priority (higher wins); fallback uses specificity resolver
60
- template(nodeValue, cfg): any; // Executed with `this` bound to context
60
+ template(nodeValue: any, cfg?: {mode?: string}): any; // Executed with `this` bound to context
61
61
  }
62
62
  ```
63
63
 
@@ -96,7 +96,7 @@ Config additions:
96
96
  ```js
97
97
  import {XPathTransformer, StringJoiningTransformer} from 'jtlt';
98
98
  // Assume `doc` is an XML Document
99
- const joiner = new StringJoiningTransformer('');
99
+ const joiner = StringJoiningTransformer.create('');
100
100
  const templates = [
101
101
  {
102
102
  name: 'root',
@@ -283,6 +283,7 @@ joiner.document(() => {
283
283
  version: '1.0',
284
284
  encoding: 'utf8',
285
285
  doctypePublic: '-//W3C//DTD XHTML 1.0//EN',
286
+ // eslint-disable-next-line unicorn/prefer-https -- Early namespace
286
287
  doctypeSystem: 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
287
288
  });
288
289
  joiner.element('html', {xmlns: 'http://www.w3.org/1999/xhtml'}, () => {
@@ -351,6 +352,7 @@ pages.forEach((page) => {
351
352
  joiner.output({
352
353
  method: 'html',
353
354
  doctypePublic: '-//W3C//DTD XHTML 1.0 Strict//EN',
355
+ // eslint-disable-next-line unicorn/prefer-https -- Early namespace
354
356
  doctypeSystem: 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
355
357
  });
356
358
  joiner.element('html', {xmlns: 'http://www.w3.org/1999/xhtml'}, () => {
package/docs/API.md CHANGED
@@ -7,7 +7,7 @@ property sets, defaults, roadmap), see `docs/API.expanded.md`.
7
7
 
8
8
  ```js
9
9
  import JTLT from 'jtlt';
10
- new JTLT({
10
+ JTLT.create({
11
11
  data: {title: 'Hi'},
12
12
  templates: [
13
13
  {path: '$.title', template (v) {
package/docs/TO-DO.md CHANGED
@@ -55,7 +55,9 @@
55
55
  JSON file in full, but also for providing schema paths or other identifiers
56
56
  so that a transformed/queried subset of a file (or joining of multiple
57
57
  files) could point the way for edited contents to be saved back to the
58
- correct JSON file and position in the JSON file.
58
+ correct JSON file and position in the JSON file. Also work with zodexy
59
+ and extend path expressions in jsonpath-plus to include its types like
60
+ `@bigint()`.
59
61
 
60
62
  2. ~~Add a [non-eval PR for JSONPath](https://github.com/s3u/JSONPath/pull/4).~~
61
63
  The OR condition (outside of filters) is another important feature as
@@ -84,7 +86,7 @@
84
86
 
85
87
  7. See code for other possible to-dos
86
88
 
87
- 8. Promise-based templates
89
+ 8. Promise-based templates; jtlt as templating engine (including zodexy-aware path expressions like @blob() for jsonpath-plus with `copyOf`/`valueOf` `document(...url...)` or our own indexeddb path db/store/key equivalent); work on **schema-driven** search forms too
88
90
 
89
91
  9. Consider implementing the following elements from <https://www.w3.org/TR/xslt-30/>
90
92
  which are not yet implemented.