jtlt 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/.editorconfig +16 -0
  2. package/CHANGES.md +5 -0
  3. package/LICENSE-MIT.txt +21 -0
  4. package/README.md +534 -0
  5. package/dist/AbstractJoiningTransformer.d.ts +42 -0
  6. package/dist/AbstractJoiningTransformer.d.ts.map +1 -0
  7. package/dist/DOMJoiningTransformer.d.ts +113 -0
  8. package/dist/DOMJoiningTransformer.d.ts.map +1 -0
  9. package/dist/JSONJoiningTransformer.d.ts +160 -0
  10. package/dist/JSONJoiningTransformer.d.ts.map +1 -0
  11. package/dist/JSONPathTransformer.d.ts +95 -0
  12. package/dist/JSONPathTransformer.d.ts.map +1 -0
  13. package/dist/JSONPathTransformerContext.d.ts +263 -0
  14. package/dist/JSONPathTransformerContext.d.ts.map +1 -0
  15. package/dist/StringJoiningTransformer.d.ts +168 -0
  16. package/dist/StringJoiningTransformer.d.ts.map +1 -0
  17. package/dist/XPathTransformer.d.ts +51 -0
  18. package/dist/XPathTransformer.d.ts.map +1 -0
  19. package/dist/XPathTransformerContext.d.ts +260 -0
  20. package/dist/XPathTransformerContext.d.ts.map +1 -0
  21. package/dist/XSLTStyleJSONPathResolver.d.ts +16 -0
  22. package/dist/XSLTStyleJSONPathResolver.d.ts.map +1 -0
  23. package/dist/index.d.ts +168 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/docs/API.expanded.md +263 -0
  26. package/docs/API.md +69 -0
  27. package/eslint.config.js +30 -0
  28. package/package.json +53 -0
  29. package/pnpm-workspace.yaml +3 -0
  30. package/src/AbstractJoiningTransformer.js +73 -0
  31. package/src/DOMJoiningTransformer.js +237 -0
  32. package/src/JSONJoiningTransformer.js +472 -0
  33. package/src/JSONPathTransformer.js +159 -0
  34. package/src/JSONPathTransformerContext.js +807 -0
  35. package/src/StringJoiningTransformer.js +589 -0
  36. package/src/XPathTransformer.js +94 -0
  37. package/src/XPathTransformerContext.js +496 -0
  38. package/src/XSLTStyleJSONPathResolver.js +39 -0
  39. package/src/index.js +299 -0
  40. package/src/types/xpath2-js.d.ts +2 -0
  41. package/tsconfig-prod.json +19 -0
  42. package/tsconfig.json +14 -0
  43. package/typings/xpath2-js.d.ts +2 -0
@@ -0,0 +1,113 @@
1
+ export default DOMJoiningTransformer;
2
+ /**
3
+ * Joining transformer that accumulates into a DOM tree.
4
+ *
5
+ * This transformer appends strings and nodes to a DocumentFragment/Element.
6
+ * It expects templates to build DOM nodes explicitly (e.g., via element(),
7
+ * attribute(), and text()), though string/number/boolean will append text
8
+ * nodes for convenience.
9
+ */
10
+ declare class DOMJoiningTransformer extends AbstractJoiningTransformer {
11
+ /**
12
+ * @param {DocumentFragment|Element} o - Initial DOM node
13
+ * @param {object} cfg - Configuration object
14
+ * @param {object} [cfg.document] - Document object
15
+ */
16
+ constructor(o: DocumentFragment | Element, cfg: {
17
+ document?: object | undefined;
18
+ });
19
+ _dom: DocumentFragment | Element;
20
+ /**
21
+ * @param {Node} item
22
+ * @returns {void}
23
+ */
24
+ rawAppend(item: Node): void;
25
+ /**
26
+ * @param {string|Node} item - Item to append
27
+ * @returns {void}
28
+ */
29
+ append(item: string | Node): void;
30
+ /**
31
+ * @returns {DocumentFragment|Element}
32
+ */
33
+ get(): DocumentFragment | Element;
34
+ /**
35
+ * @param {string} prop - Property name
36
+ * @param {*} val - Property value
37
+ * @returns {void}
38
+ */
39
+ propValue(prop: string, val: any): void;
40
+ /**
41
+ * @param {object} obj - Object to serialize
42
+ * @param {Function} [cb] - Callback function.
43
+ * @param {any[]} [usePropertySets] - Property sets to use
44
+ * @param {object} [propSets] - Additional property sets
45
+ * @returns {DOMJoiningTransformer}
46
+ */
47
+ object(obj: object, cb?: Function, usePropertySets?: any[], propSets?: object): DOMJoiningTransformer;
48
+ /**
49
+ * @param {any[]|Element} arr
50
+ * @param {Function} [cb] - Callback function
51
+ * @returns {DOMJoiningTransformer}
52
+ */
53
+ array(arr: any[] | Element, cb?: Function): DOMJoiningTransformer;
54
+ /**
55
+ * @param {string} str - String value
56
+ * @param {Function} cb - Callback function (unused)
57
+ * @returns {DOMJoiningTransformer}
58
+ */
59
+ string(str: string, cb: Function): DOMJoiningTransformer;
60
+ /**
61
+ * @param {number} num - Number value
62
+ * @returns {DOMJoiningTransformer}
63
+ */
64
+ number(num: number): DOMJoiningTransformer;
65
+ /**
66
+ * @param {boolean} bool
67
+ * @returns {DOMJoiningTransformer}
68
+ */
69
+ boolean(bool: boolean): DOMJoiningTransformer;
70
+ /**
71
+ * @returns {DOMJoiningTransformer}
72
+ */
73
+ null(): DOMJoiningTransformer;
74
+ /**
75
+ * @returns {DOMJoiningTransformer}
76
+ */
77
+ undefined(): DOMJoiningTransformer;
78
+ /**
79
+ * @param {number} num - Non-finite number (NaN, Infinity, -Infinity)
80
+ * @returns {DOMJoiningTransformer}
81
+ */
82
+ nonfiniteNumber(num: number): DOMJoiningTransformer;
83
+ /**
84
+ * @param {Function} func - Function to stringify
85
+ * @returns {DOMJoiningTransformer}
86
+ */
87
+ function(func: Function): DOMJoiningTransformer;
88
+ /**
89
+ * @param {string} elName - Element name
90
+ * @param {object} [atts] - Attributes object
91
+ * @param {Function} [cb] - Callback function
92
+ * @returns {DOMJoiningTransformer}
93
+ */
94
+ element(elName: string, atts?: object, cb?: Function): DOMJoiningTransformer;
95
+ /**
96
+ * @param {string} name
97
+ * @param {string} val
98
+ * @returns {DOMJoiningTransformer}
99
+ */
100
+ attribute(name: string, val: string): DOMJoiningTransformer;
101
+ /**
102
+ * @param {string} txt - Text content
103
+ * @returns {DOMJoiningTransformer}
104
+ */
105
+ text(txt: string): DOMJoiningTransformer;
106
+ /**
107
+ * @param {string} str
108
+ * @returns {DOMJoiningTransformer}
109
+ */
110
+ plainText(str: string): DOMJoiningTransformer;
111
+ }
112
+ import AbstractJoiningTransformer from './AbstractJoiningTransformer.js';
113
+ //# sourceMappingURL=DOMJoiningTransformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DOMJoiningTransformer.d.ts","sourceRoot":"","sources":["../src/DOMJoiningTransformer.js"],"names":[],"mappings":";AAGA;;;;;;;GAOG;AACH;IACE;;;;OAIG;IACH,eAJW,gBAAgB,GAAC,OAAO,OAEhC;QAAqB,QAAQ;KAC/B,EAKA;IAFC,iCAC0D;IAG5D;;;OAGG;IACH,gBAHW,IAAI,GACF,IAAI,CAIhB;IAED;;;OAGG;IACH,aAHW,MAAM,GAAC,IAAI,GACT,IAAI,CAIhB;IAED;;OAEG;IACH,OAFa,gBAAgB,GAAC,OAAO,CAIpC;IAED;;;;OAIG;IAEH,gBALW,MAAM,OACN,GAAC,GACC,IAAI,CAKhB;IAED;;;;;;OAMG;IACH,YANW,MAAM,mCAEN,GAAG,EAAE,aACL,MAAM,GACJ,qBAAqB,CAWjC;IAED;;;;OAIG;IACH,WAJW,GAAG,EAAE,GAAC,OAAO,kBAEX,qBAAqB,CAWjC;IAED;;;;OAIG;IACH,YAJW,MAAM,iBAEJ,qBAAqB,CAMjC;IAED;;;OAGG;IACH,YAHW,MAAM,GACJ,qBAAqB,CAKjC;IAED;;;OAGG;IACH,cAHW,OAAO,GACL,qBAAqB,CAKjC;IAED;;OAEG;IACH,QAFa,qBAAqB,CAKjC;IAED;;OAEG;IACH,aAFa,qBAAqB,CAUjC;IAED;;;OAGG;IACH,qBAHW,MAAM,GACJ,qBAAqB,CAUjC;IAED;;;OAGG;IACH,0BAFa,qBAAqB,CAUjC;IAED;;;;;OAKG;IACH,gBALW,MAAM,SACN,MAAM,kBAEJ,qBAAqB,CA6BjC;IAED;;;;OAIG;IACH,gBAJW,MAAM,OACN,MAAM,GACJ,qBAAqB,CASjC;IAED;;;OAGG;IACH,UAHW,MAAM,GACJ,qBAAqB,CAKjC;IAED;;;OAGG;IACH,eAHW,MAAM,GACJ,qBAAqB,CAKjC;CACF;uCAzOsC,iCAAiC"}
@@ -0,0 +1,160 @@
1
+ export default JSONJoiningTransformer;
2
+ /**
3
+ * JSON-based joining transformer for building JSON/JavaScript objects.
4
+ *
5
+ * This joiner accumulates into an in-memory JSON value (object or array).
6
+ * append() will push to arrays or shallow-merge into objects; string/number/
7
+ * boolean/null add primitives accordingly. It does not perform HTML escaping
8
+ * or string serialization; it builds real JS values.
9
+ */
10
+ declare class JSONJoiningTransformer extends AbstractJoiningTransformer {
11
+ /**
12
+ * @param {any[]|object} [o] - Initial object or array
13
+ * @param {object} [cfg] - Configuration object
14
+ */
15
+ constructor(o?: any[] | object, cfg?: object);
16
+ /** @type {any[]|object} */
17
+ _obj: any[] | object;
18
+ /** @type {boolean | undefined} */
19
+ _objPropState: boolean | undefined;
20
+ /** @type {boolean | undefined} */
21
+ _arrItemState: boolean | undefined;
22
+ /** @type {{attsObj: Record<string, any>, jmlChildren: any[]}[]} */
23
+ _elementStack: {
24
+ attsObj: Record<string, any>;
25
+ jmlChildren: any[];
26
+ }[];
27
+ /**
28
+ * Directly appends an item to the internal array without checks.
29
+ * @param {*} item - Item to append
30
+ * @returns {void}
31
+ */
32
+ rawAppend(item: any): void;
33
+ /**
34
+ * Appends an item to the current object or array.
35
+ * @param {*} item - Item to append
36
+ * @returns {JSONJoiningTransformer}
37
+ */
38
+ append(item: any): JSONJoiningTransformer;
39
+ /**
40
+ * Gets the current object or array. If unwrapSingleResult config option is
41
+ * enabled and the root array contains exactly one element, returns that
42
+ * element directly (unwrapped).
43
+ * @returns {any[]|object|any}
44
+ */
45
+ get(): any[] | object | any;
46
+ /**
47
+ * Sets a property value on the current object.
48
+ * @param {string} prop - Property name
49
+ * @param {*} val - Property value
50
+ * @returns {void}
51
+ */
52
+ propValue(prop: string, val: any): void;
53
+ /**
54
+ * @param {object|Function} [objOrCb] - Seed object to start with, or
55
+ * callback if no seed provided
56
+ * @param {Function|any[]} [cbOrUsePropertySets] - Callback to be executed
57
+ * on this transformer but with a context nested within the newly created
58
+ * object, or array of property set names if first arg was an object
59
+ * @param {any[]|object} [usePropertySetsOrPropSets] - Array of string
60
+ * property set names to copy onto the new object, or propSets if second
61
+ * arg was a callback
62
+ * @param {object} [propSets] - An object of key-value pairs to copy onto
63
+ * the new object
64
+ * @returns {JSONJoiningTransformer}
65
+ */
66
+ object(objOrCb?: object | Function, cbOrUsePropertySets?: Function | any[], usePropertySetsOrPropSets?: any[] | object, propSets?: object): JSONJoiningTransformer;
67
+ /**
68
+ * Creates a new array and executes a callback in its context.
69
+ * @param {any[]|Function} [arrOrCb] - Seed array to start with, or callback
70
+ * if no seed provided
71
+ * @param {Function} [cb] - Callback function (if first arg was a seed array)
72
+ * @returns {JSONJoiningTransformer}
73
+ */
74
+ array(arrOrCb?: any[] | Function, cb?: Function): JSONJoiningTransformer;
75
+ /**
76
+ * Appends a string value.
77
+ * @param {string} str - String value
78
+ * @param {Function} [cb] - Callback function (unused)
79
+ * @returns {JSONJoiningTransformer}
80
+ */
81
+ string(str: string, cb?: Function): JSONJoiningTransformer;
82
+ /**
83
+ * Appends a number value.
84
+ * @param {number} num - Number value
85
+ * @returns {JSONJoiningTransformer}
86
+ */
87
+ number(num: number): JSONJoiningTransformer;
88
+ /**
89
+ * Appends a boolean value.
90
+ * @param {boolean} bool - Boolean value
91
+ * @returns {JSONJoiningTransformer}
92
+ */
93
+ boolean(bool: boolean): JSONJoiningTransformer;
94
+ /**
95
+ * Appends a null value.
96
+ * @returns {JSONJoiningTransformer}
97
+ */
98
+ null(): JSONJoiningTransformer;
99
+ /**
100
+ * Appends an undefined value (JavaScript mode only).
101
+ * @returns {JSONJoiningTransformer}
102
+ */
103
+ undefined(): JSONJoiningTransformer;
104
+ /**
105
+ * Appends a non-finite number (JavaScript mode only).
106
+ * @param {number} num - Non-finite number (NaN, Infinity, -Infinity)
107
+ * @returns {JSONJoiningTransformer}
108
+ */
109
+ nonfiniteNumber(num: number): JSONJoiningTransformer;
110
+ /**
111
+ * Appends a function value (JavaScript mode only).
112
+ * @param {Function} func - Function to append
113
+ * @returns {JSONJoiningTransformer}
114
+ */
115
+ function(func: Function): JSONJoiningTransformer;
116
+ /**
117
+ * Build a Jamilih-style element JSON array and append to current container.
118
+ * Result form: ['tag', {attr: 'val'}, child1, child2, ...]
119
+ * Helpers: dataset -> data-*; $a -> ordered attributes.
120
+ * Supported signatures mirror StringJoiningTransformer.element.
121
+ * @param {string|Element|object} elName - Element name or Element-like
122
+ * @param {object|any[]|Function} [atts] - Attributes object or children or cb
123
+ * @param {any[]|Function} [childNodes] - Child nodes array or callback
124
+ * @param {Function} [cb] - Callback for building children/attributes
125
+ * @returns {JSONJoiningTransformer}
126
+ */
127
+ element(elName: string | Element | object, atts?: object | any[] | Function, childNodes?: any[] | Function, cb?: Function): JSONJoiningTransformer;
128
+ /**
129
+ * Adds/updates an attribute for the most recently open element built via
130
+ * a callback-driven element(). When not in an element callback context,
131
+ * throws. Supports the same dataset/$a helpers as string joiner.
132
+ * @param {string} name - Attribute name (or helper: dataset, $a)
133
+ * @param {string|object|any[]} val - Attribute value or helper object
134
+ * @returns {JSONJoiningTransformer}
135
+ */
136
+ attribute(name: string, val: string | object | any[]): JSONJoiningTransformer;
137
+ /**
138
+ * Adds a text node (string) as a child within the current element() callback
139
+ * context. Outside of an element callback, simply appends the text to the
140
+ * current array/object like string().
141
+ * @param {string} txt - Text content
142
+ * @returns {JSONJoiningTransformer}
143
+ */
144
+ text(txt: string): JSONJoiningTransformer;
145
+ /**
146
+ * Appends plain text as a string.
147
+ * @param {string} str - Plain text string
148
+ * @returns {JSONJoiningTransformer}
149
+ */
150
+ plainText(str: string): JSONJoiningTransformer;
151
+ /**
152
+ * Helper method to use property sets (to be implemented).
153
+ * @param {object} obj - Object to apply property set to
154
+ * @param {string} psName - Property set name
155
+ * @returns {object}
156
+ */
157
+ _usePropertySets(obj: object, psName: string): object;
158
+ }
159
+ import AbstractJoiningTransformer from './AbstractJoiningTransformer.js';
160
+ //# sourceMappingURL=JSONJoiningTransformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JSONJoiningTransform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AED;;;;;;;;;;OAUG;IACH,gBANW,MAAM,GAAC,OAAO,GAAC,MAAM,SACrB,MAAM,GAAC,GAAG,EAAE,WAAS,eACrB,GAAG,EAAE,WAAS,kBAEZ,sBAAsB,CA2FlC;IAED;;;;;;;OAOG;IACH,gBAJW,MAAM,OACN,MAAM,GAAC,MAAM,GAAC,GAAG,EAAE,GACjB,sBAAsB,CA8BlC;IAED;;;;;;OAMG;IACH,UAHW,MAAM,GACJ,sBAAsB,CAWlC;IAED;;;;OAIG;IACH,eAHW,MAAM,GACJ,sBAAsB,CAKlC;IAED;;;;;OAKG;IACH,sBAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAUlB;CACF;uCApdsC,iCAAiC"}
@@ -0,0 +1,95 @@
1
+ export default JSONPathTransformer;
2
+ /**
3
+ * Applies named JSONPath-driven templates to JSON data.
4
+ *
5
+ * This engine finds templates whose `path` match the current node (plus an
6
+ * optional `mode`), sorts by priority, and invokes the winning template.
7
+ * If no template matches, built-in default rules emulate XSLT-like behavior
8
+ * for objects, arrays, scalars, etc.
9
+ */
10
+ declare class JSONPathTransformer {
11
+ /**
12
+ * @param {string} select - JSONPath selector
13
+ * @returns {string} Absolute JSONPath
14
+ */
15
+ static makeJSONPathAbsolute(select: string): string;
16
+ static DefaultTemplateRules: {
17
+ transformRoot: {
18
+ /**
19
+ * @param {*} value - Value
20
+ * @param {{mode: string}} cfg - Configuration
21
+ * @returns {void}
22
+ */
23
+ template(value: any, cfg: {
24
+ mode: string;
25
+ }): void;
26
+ };
27
+ transformPropertyNames: {
28
+ /**
29
+ * @param {*} value - Current context value
30
+ * @returns {*}
31
+ */
32
+ template(value: any): any;
33
+ };
34
+ transformObjects: {
35
+ /**
36
+ * @param {*} value - Value
37
+ * @param {{mode: string}} cfg - Configuration
38
+ * @returns {void}
39
+ */
40
+ template(value: any, cfg: {
41
+ mode: string;
42
+ }): void;
43
+ };
44
+ transformArrays: {
45
+ /**
46
+ * @param {*} value - Value
47
+ * @param {{mode: string}} cfg - Configuration
48
+ * @returns {void}
49
+ */
50
+ template(value: any, cfg: {
51
+ mode: string;
52
+ }): void;
53
+ };
54
+ transformScalars: {
55
+ /**
56
+ * @returns {*}
57
+ */
58
+ template(): any;
59
+ };
60
+ transformFunctions: {
61
+ /**
62
+ * @param {Function} value - Function at current context
63
+ * @returns {*}
64
+ */
65
+ template(value: Function): any;
66
+ };
67
+ };
68
+ /**
69
+ * @param {object} config - Configuration object
70
+ * @param {boolean} [config.errorOnEqualPriority] - Whether to error on
71
+ * equal priority templates
72
+ * @param {any[]} config.templates - Array of template objects
73
+ */
74
+ constructor(config: {
75
+ errorOnEqualPriority?: boolean | undefined;
76
+ templates: any[];
77
+ });
78
+ _config: {
79
+ errorOnEqualPriority?: boolean | undefined;
80
+ templates: any[];
81
+ };
82
+ /** @type {any[]} */
83
+ rootTemplates: any[];
84
+ templates: any[];
85
+ /**
86
+ * @returns {void}
87
+ */
88
+ _triggerEqualPriorityError(): void;
89
+ /**
90
+ * @param {string} mode - Transformation mode
91
+ * @returns {*} The transformation result
92
+ */
93
+ transform(mode: string): any;
94
+ }
95
+ //# sourceMappingURL=JSONPathTransformer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JSONPathTransformer.d.ts","sourceRoot":"","sources":["../src/JSONPathTransformer.js"],"names":[],"mappings":";AAEA;;;;;;;GAOG;AACH;IAsEE;;;OAGG;IACH,oCAHW,MAAM,GACJ,MAAM,CAQlB;IAGD;;YAEI;;;;eAIG;4BAHQ,GAAC,OACD;gBAAC,IAAI,EAAE,MAAM,CAAA;aAAC,GACZ,IAAI;;;YAOjB;;;eAGG;4BAFQ,GAAC,GACC,GAAC;;;YAWd;;;;eAIG;4BAHQ,GAAC,OACD;gBAAC,IAAI,EAAE,MAAM,CAAA;aAAC,GACZ,IAAI;;;YAOjB;;;;eAIG;4BAHQ,GAAC,OACD;gBAAC,IAAI,EAAE,MAAM,CAAA;aAAC,GACZ,IAAI;;;YAOjB;;eAEG;wBADU,GAAC;;;YAOd;;;eAGG;uCADU,GAAC;;MAOhB;IAhJF;;;;;OAKG;IACH,oBAJG;QAAyB,oBAAoB;QAEvB,SAAS,EAAvB,GAAG,EAAE;KACf,EA0BA;IAvBC;;mBAJS,GAAG,EAAE;MAIO;IACrB,oBAAoB;IACpB,eADW,GAAG,EAAE,CACO;IACvB,iBAAiC;IAsBnC;;OAEG;IACH,8BAFa,IAAI,CAShB;IAED;;;OAGG;IACH,gBAHW,MAAM,GACJ,GAAC,CAoBb;CA8EF"}
@@ -0,0 +1,263 @@
1
+ export default JSONPathTransformerContext;
2
+ /**
3
+ * Execution context for JSONPath-driven template application.
4
+ *
5
+ * Holds the current node, parent, path, variables, and property sets while
6
+ * running templates. Exposes helper methods that mirror the underlying
7
+ * joining transformer (e.g., string(), object(), array()) so templates can
8
+ * emit results without referencing the joiner directly.
9
+ */
10
+ declare class JSONPathTransformerContext {
11
+ /**
12
+ * @param {object} config - Configuration object
13
+ * @param {object} config.data - Data to transform
14
+ * @param {object} [config.parent] - Parent object
15
+ * @param {string} [config.parentProperty] - Parent property name
16
+ * @param {boolean} [config.errorOnEqualPriority] - Whether to error on
17
+ * equal priority
18
+ * @param {{append: Function, get: Function, string: Function,
19
+ * object: Function, array: Function}} config.joiningTransformer -
20
+ * Joining transformer
21
+ * @param {boolean} [config.preventEval] - Whether to prevent eval in
22
+ * JSONPath
23
+ * @param {Function} [config.specificityPriorityResolver] - Function to
24
+ * resolve priority
25
+ * @param {any[]} templates - Array of template objects
26
+ */
27
+ constructor(config: {
28
+ data: object;
29
+ parent?: object | undefined;
30
+ parentProperty?: string | undefined;
31
+ errorOnEqualPriority?: boolean | undefined;
32
+ joiningTransformer: {
33
+ append: Function;
34
+ get: Function;
35
+ string: Function;
36
+ object: Function;
37
+ array: Function;
38
+ };
39
+ preventEval?: boolean | undefined;
40
+ specificityPriorityResolver?: Function | undefined;
41
+ }, templates: any[]);
42
+ _config: {
43
+ data: object;
44
+ parent?: object | undefined;
45
+ parentProperty?: string | undefined;
46
+ errorOnEqualPriority?: boolean | undefined;
47
+ joiningTransformer: {
48
+ append: Function;
49
+ get: Function;
50
+ string: Function;
51
+ object: Function;
52
+ array: Function;
53
+ };
54
+ preventEval?: boolean | undefined;
55
+ specificityPriorityResolver?: Function | undefined;
56
+ };
57
+ _templates: any[];
58
+ _contextObj: object;
59
+ _origObj: object;
60
+ _parent: object;
61
+ _parentProperty: string;
62
+ /** @type {Record<string, any>} */
63
+ vars: Record<string, any>;
64
+ /** @type {Record<string, any>} */
65
+ propertySets: Record<string, any>;
66
+ /** @type {Record<string, any>} */
67
+ keys: Record<string, any>;
68
+ /** @type {boolean | undefined} */
69
+ _initialized: boolean | undefined;
70
+ /** @type {string | undefined} */
71
+ _currPath: string | undefined;
72
+ /**
73
+ * Triggers an error if equal priority templates are found.
74
+ * @returns {void}
75
+ */
76
+ _triggerEqualPriorityError(): void;
77
+ /**
78
+ * Gets the joining transformer from config.
79
+ * @returns {any} The joining transformer
80
+ */
81
+ _getJoiningTransformer(): any;
82
+ /**
83
+ * @param {*} item - Item to append to output
84
+ * @returns {JSONPathTransformerContext}
85
+ */
86
+ appendOutput(item: any): JSONPathTransformerContext;
87
+ /**
88
+ * Gets the current output.
89
+ * @returns {*} The output from the joining transformer
90
+ */
91
+ getOutput(): any;
92
+ /**
93
+ * Get() and set() are provided as a convenience method for templates, but
94
+ * it should typically not be used (use valueOf or the copy methods to add
95
+ * to the result tree instead).
96
+ * @param {string} select - JSONPath selector
97
+ * @param {boolean} wrap - Whether to wrap results
98
+ * @returns {*} The selected value(s)
99
+ */
100
+ get(select: string, wrap: boolean): any;
101
+ /**
102
+ * @param {*} v - Value to set
103
+ * @returns {JSONPathTransformerContext}
104
+ */
105
+ set(v: any): JSONPathTransformerContext;
106
+ /**
107
+ * Apply matching templates to nodes selected by JSONPath, optionally sorted.
108
+ *
109
+ * Sort parameter forms:
110
+ * - string: JSONPath relative to each match (e.g., '$.name' or '@')
111
+ * - function: comparator (aValue, bValue, ctx) => number
112
+ * - object: { select, order='ascending'|'descending', type='text'|'number',
113
+ * locale, localeOptions }
114
+ * - array: multiple key objects/strings in priority order.
115
+ *
116
+ * @param {string|object} select - JSONPath selector or options object
117
+ * @param {string} [mode] - Mode to apply
118
+ * @param {string|Function|object|Array<string|object>} [sort] - Sort spec
119
+ * @returns {JSONPathTransformerContext}
120
+ */
121
+ applyTemplates(select: string | object, mode?: string, sort?: string | Function | object | Array<string | object>): JSONPathTransformerContext;
122
+ /**
123
+ * @param {string|object} name - Template name or options object
124
+ * @param {any[]} [withParams] - Parameters to pass to template
125
+ * @returns {JSONPathTransformerContext}
126
+ */
127
+ callTemplate(name: string | object, withParams?: any[]): JSONPathTransformerContext;
128
+ /**
129
+ * Iterate over values selected by JSONPath, optionally sorted.
130
+ *
131
+ * Sort parameter forms are the same as applyTemplates().
132
+ * @param {string} select - JSONPath selector
133
+ * @param {Function} cb - Callback function
134
+ * @param {string|Function|object|Array<string|object>} [sort] - Sort spec
135
+ * @returns {JSONPathTransformerContext}
136
+ */
137
+ forEach(select: string, cb: Function, sort?: string | Function | object | Array<string | object>): JSONPathTransformerContext;
138
+ /**
139
+ * @param {string|object} [select] - JSONPath selector
140
+ * @returns {JSONPathTransformerContext}
141
+ */
142
+ valueOf(select?: string | object): JSONPathTransformerContext;
143
+ /**
144
+ * Deep copy selection or current context when omitted.
145
+ * @param {string} [select] - JSONPath selector
146
+ * @returns {JSONPathTransformerContext}
147
+ */
148
+ copyOf(select?: string): JSONPathTransformerContext;
149
+ /**
150
+ * Shallow copy current context; optionally merge property set names.
151
+ * @param {string[]} [propertySets] - Property sets to merge
152
+ * @returns {JSONPathTransformerContext}
153
+ */
154
+ copy(propertySets?: string[]): JSONPathTransformerContext;
155
+ /**
156
+ * @param {string} name - Variable name
157
+ * @param {string} select - JSONPath selector
158
+ * @returns {JSONPathTransformerContext}
159
+ */
160
+ variable(name: string, select: string): JSONPathTransformerContext;
161
+ /**
162
+ * @param {*} json - JSON data to log
163
+ * @returns {void}
164
+ */
165
+ message(json: any): void;
166
+ /**
167
+ * @param {string} str - String value
168
+ * @param {Function} cb - Callback function
169
+ * @returns {JSONPathTransformerContext}
170
+ */
171
+ string(str: string, cb: Function): JSONPathTransformerContext;
172
+ /**
173
+ * Append a number to JSON output. Mirrors the joining transformer API so
174
+ * templates can call `this.number()`.
175
+ * @param {number} num - Number value to append
176
+ * @returns {JSONPathTransformerContext}
177
+ */
178
+ number(num: number): JSONPathTransformerContext;
179
+ /**
180
+ * Append plain text directly to the output without escaping or JSON
181
+ * stringification. Mirrors the joining transformer API so templates can
182
+ * call `this.plainText()`.
183
+ * @param {string} str - Plain text to append
184
+ * @returns {JSONPathTransformerContext}
185
+ */
186
+ plainText(str: string): JSONPathTransformerContext;
187
+ /**
188
+ * Set a property value on the current object (JSON joiner). Mirrors the
189
+ * joining transformer API so templates can call `this.propValue()`.
190
+ * @param {string} prop - Property name
191
+ * @param {*} val - Property value
192
+ * @returns {JSONPathTransformerContext}
193
+ */
194
+ propValue(prop: string, val: any): JSONPathTransformerContext;
195
+ /**
196
+ * Build an object. Mirrors the joining transformer API. All joiners now
197
+ * support both signatures: (obj, cb, usePropertySets, propSets) with seed
198
+ * object or (cb, usePropertySets, propSets) without.
199
+ * @param {...any} args - Arguments to pass to joiner
200
+ * @returns {JSONPathTransformerContext}
201
+ */
202
+ object(...args: any[]): JSONPathTransformerContext;
203
+ /**
204
+ * Build an array. Mirrors the joining transformer API. All joiners now
205
+ * support both signatures: (arr, cb) with seed array or (cb) without.
206
+ * @param {...any} args - Arguments to pass to joiner
207
+ * @returns {JSONPathTransformerContext}
208
+ */
209
+ array(...args: any[]): JSONPathTransformerContext;
210
+ /**
211
+ * Create an element. Mirrors the joining transformer API so templates can
212
+ * call `this.element()`.
213
+ * @param {string} name - Element name
214
+ * @param {object} [atts] - Attributes object
215
+ * @param {any[]} [children] - Child nodes
216
+ * @param {Function} [cb] - Callback function
217
+ * @returns {JSONPathTransformerContext}
218
+ */
219
+ element(name: string, atts?: object, children?: any[], cb?: Function): JSONPathTransformerContext;
220
+ /**
221
+ * Add an attribute to the most recently opened element. Mirrors the joining
222
+ * transformer API so templates can call `this.attribute()`.
223
+ * @param {string} name - Attribute name
224
+ * @param {string|object} val - Attribute value
225
+ * @param {boolean} [avoidAttEscape] - Whether to avoid escaping
226
+ * @returns {JSONPathTransformerContext}
227
+ */
228
+ attribute(name: string, val: string | object, avoidAttEscape?: boolean): JSONPathTransformerContext;
229
+ /**
230
+ * Append text content. Mirrors the joining transformer API so templates can
231
+ * call `this.text()`.
232
+ * @param {string} txt - Text content
233
+ * @returns {JSONPathTransformerContext}
234
+ */
235
+ text(txt: string): JSONPathTransformerContext;
236
+ /**
237
+ * @param {string} name - Property set name
238
+ * @param {object} propertySetObj - Property set object
239
+ * @param {any[]} [usePropertySets] - Property sets to use
240
+ * @returns {JSONPathTransformerContext}
241
+ */
242
+ propertySet(name: string, propertySetObj: object, usePropertySets?: any[]): JSONPathTransformerContext;
243
+ /**
244
+ * @param {object} obj - Object to assign properties to
245
+ * @param {string} name - Property set name
246
+ * @returns {object}
247
+ */
248
+ _usePropertySets(obj: object, name: string): object;
249
+ /**
250
+ * @param {string} name - Key name
251
+ * @param {*} value - Value to match
252
+ * @returns {*}
253
+ */
254
+ getKey(name: string, value: any): any;
255
+ /**
256
+ * @param {string} name - Key name
257
+ * @param {string} match - Match expression
258
+ * @param {string} use - Use expression
259
+ * @returns {JSONPathTransformerContext}
260
+ */
261
+ key(name: string, match: string, use: string): JSONPathTransformerContext;
262
+ }
263
+ //# sourceMappingURL=JSONPathTransformerContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JSONPathTransformerContext.d.ts","sourceRoot":"","sources":["../src/JSONPathTransformerContext.js"],"names":[],"mappings":";AAGA;;;;;;;GAOG;AACH;IACE;;;;;;;;;;;;;;;OAeG;IACH,oBAdG;QAAuB,IAAI,EAAnB,MAAM;QACU,MAAM;QACN,cAAc;QACb,oBAAoB;Q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