tally-xml-tdl 1.27.3 → 1.31.1

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 (180) hide show
  1. package/package.json +3 -3
  2. package/src/index.js +2 -2
  3. package/src/v28/apiTree/blueprint/api.json +13 -0
  4. package/src/v28/apiTree/blueprint/source.json +228 -0
  5. package/src/v28/apiTree/engine/caller/index.js +65 -0
  6. package/src/v28/apiTree/engine/guards/index.js +23 -0
  7. package/src/v28/apiTree/engine/guards/isFunction.js +9 -0
  8. package/src/v28/apiTree/engine/guards/isObject.js +9 -0
  9. package/src/v28/apiTree/engine/guards/isStringArray.js +15 -0
  10. package/src/v28/apiTree/engine/run.js +16 -0
  11. package/src/v28/apiTree/engine/toTransformRecipe.js +53 -0
  12. package/src/v28/apiTree/engine/traversal/ifTransformFound/index.js +49 -0
  13. package/src/v28/apiTree/engine/traversal/index.js +34 -0
  14. package/src/v28/apiTree/engine/traversal/traverseArray/index.js +21 -0
  15. package/src/v28/apiTree/engine/traversal/traverseObject/index.js +50 -0
  16. package/src/v28/apiTree/index.js +32 -0
  17. package/src/v28/apiTreeV1/blueprint/api.json +13 -0
  18. package/src/v28/apiTreeV1/blueprint/source.json +228 -0
  19. package/src/v28/apiTreeV1/engine/caller/index.js +65 -0
  20. package/src/v28/apiTreeV1/engine/guards/index.js +23 -0
  21. package/src/v28/apiTreeV1/engine/guards/isFunction.js +9 -0
  22. package/src/v28/apiTreeV1/engine/guards/isObject.js +9 -0
  23. package/src/v28/apiTreeV1/engine/guards/isStringArray.js +15 -0
  24. package/src/v28/apiTreeV1/engine/run.js +16 -0
  25. package/src/v28/apiTreeV1/engine/toTransformRecipe.js +53 -0
  26. package/src/v28/apiTreeV1/engine/traversal/ifTransformFound/index.js +49 -0
  27. package/src/v28/apiTreeV1/engine/traversal/index.js +34 -0
  28. package/src/v28/apiTreeV1/engine/traversal/traverseArray/index.js +21 -0
  29. package/src/v28/apiTreeV1/engine/traversal/traverseObject/index.js +50 -0
  30. package/src/v28/apiTreeV1/index.js +32 -0
  31. package/src/{v24/engine/execution → v28/engine/dispatchTally/buildXml}/buildXml.js +3 -12
  32. package/src/v28/engine/dispatchTally/index.js +20 -0
  33. package/src/{v24/engine/execution → v28/engine/dispatchTally}/transport.js +2 -2
  34. package/src/{v24/engine/execution → v28/engine}/index.js +6 -8
  35. package/src/v28/index.js +13 -0
  36. package/src/v28/tallySpec/recipe.json +92 -0
  37. package/src/v28/tallySpec/source.json +228 -0
  38. package/src/v29/apiTree/blueprint/api.json +13 -0
  39. package/src/v29/apiTree/blueprint/source.json +228 -0
  40. package/src/v29/apiTree/engine/caller/index.js +65 -0
  41. package/src/v29/apiTree/engine/guards/index.js +23 -0
  42. package/src/v29/apiTree/engine/guards/isFunction.js +9 -0
  43. package/src/v29/apiTree/engine/guards/isObject.js +9 -0
  44. package/src/v29/apiTree/engine/guards/isStringArray.js +15 -0
  45. package/src/v29/apiTree/engine/run.js +16 -0
  46. package/src/v29/apiTree/engine/toTransformRecipe.js +53 -0
  47. package/src/v29/apiTree/engine/traversal/ifTransformFound/index.js +49 -0
  48. package/src/v29/apiTree/engine/traversal/index.js +34 -0
  49. package/src/v29/apiTree/engine/traversal/traverseArray/index.js +21 -0
  50. package/src/v29/apiTree/engine/traversal/traverseObject/index.js +50 -0
  51. package/src/v29/apiTree/index.js +32 -0
  52. package/src/v29/apiTreeV1/blueprint/api.json +13 -0
  53. package/src/v29/apiTreeV1/blueprint/source.json +228 -0
  54. package/src/v29/apiTreeV1/engine/caller/index.js +65 -0
  55. package/src/v29/apiTreeV1/engine/guards/index.js +23 -0
  56. package/src/v29/apiTreeV1/engine/guards/isFunction.js +9 -0
  57. package/src/v29/apiTreeV1/engine/guards/isObject.js +9 -0
  58. package/src/v29/apiTreeV1/engine/guards/isStringArray.js +15 -0
  59. package/src/v29/apiTreeV1/engine/run.js +16 -0
  60. package/src/v29/apiTreeV1/engine/toTransformRecipe.js +53 -0
  61. package/src/v29/apiTreeV1/engine/traversal/ifTransformFound/index.js +49 -0
  62. package/src/v29/apiTreeV1/engine/traversal/index.js +34 -0
  63. package/src/v29/apiTreeV1/engine/traversal/traverseArray/index.js +21 -0
  64. package/src/v29/apiTreeV1/engine/traversal/traverseObject/index.js +50 -0
  65. package/src/v29/apiTreeV1/index.js +32 -0
  66. package/src/v29/engine/dispatchTally/buildXml/buildXml.js +45 -0
  67. package/src/v29/engine/dispatchTally/buildXml/templates.js +42 -0
  68. package/src/v29/engine/dispatchTally/index.js +20 -0
  69. package/src/v29/engine/dispatchTally/transport.js +16 -0
  70. package/src/v29/engine/getEndpointSpec/index.js +12 -0
  71. package/src/v29/engine/index.js +25 -0
  72. package/src/v29/engine/validateInput/index.js +19 -0
  73. package/src/v29/index.js +31 -0
  74. package/src/v29/tallySpec/recipe.json +92 -0
  75. package/src/v29/tallySpec/source.json +228 -0
  76. package/src/v30/index.js +41 -0
  77. package/src/v31/company/index.js +15 -0
  78. package/src/{v21 → v31}/index.js +6 -6
  79. package/src/v31/masters/index.js +16 -0
  80. package/src/v31/vouchers/index.js +25 -0
  81. package/src/v20/company/body.xml +0 -25
  82. package/src/v20/company/index.js +0 -29
  83. package/src/v20/company/tdl.json +0 -4
  84. package/src/v20/core/buildXml.js +0 -9
  85. package/src/v20/core/execute/executeXml.js +0 -16
  86. package/src/v20/core/execute/index.js +0 -4
  87. package/src/v20/core/index.js +0 -22
  88. package/src/v20/core/response/index.js +0 -2
  89. package/src/v20/core/response/xmlToJson.js +0 -18
  90. package/src/v20/core/transport/http.js +0 -40
  91. package/src/v20/core/transport/index.js +0 -1
  92. package/src/v20/index.js +0 -6
  93. package/src/v20/masters/body.xml +0 -25
  94. package/src/v20/masters/index.js +0 -39
  95. package/src/v20/masters/masters.json +0 -86
  96. package/src/v20/vouchers/body.xml +0 -25
  97. package/src/v20/vouchers/createVoucherApi.js +0 -38
  98. package/src/v20/vouchers/index.js +0 -5
  99. package/src/v20/vouchers/purchases/index.js +0 -7
  100. package/src/v20/vouchers/sales/index.js +0 -7
  101. package/src/v20/vouchers/tdlMessage.json +0 -4
  102. package/src/v21/body.xml +0 -25
  103. package/src/v21/company/index.js +0 -7
  104. package/src/v21/core/buildXml.js +0 -9
  105. package/src/v21/core/execute/executeXml.js +0 -16
  106. package/src/v21/core/execute/index.js +0 -4
  107. package/src/v21/core/index.js +0 -22
  108. package/src/v21/core/response/index.js +0 -2
  109. package/src/v21/core/response/xmlToJson.js +0 -18
  110. package/src/v21/core/transport/http.js +0 -40
  111. package/src/v21/core/transport/index.js +0 -1
  112. package/src/v21/createApi.js +0 -74
  113. package/src/v21/masters/index.js +0 -30
  114. package/src/v21/tdlMessage.json +0 -18
  115. package/src/v21/vouchers/index.js +0 -5
  116. package/src/v21/vouchers/purchases/index.js +0 -7
  117. package/src/v21/vouchers/sales/index.js +0 -7
  118. package/src/v22/body.xml +0 -25
  119. package/src/v22/bodyAsData.xml +0 -16
  120. package/src/v22/company/index.js +0 -7
  121. package/src/v22/core/buildXml.js +0 -9
  122. package/src/v22/core/execute/executeXml.js +0 -16
  123. package/src/v22/core/execute/index.js +0 -4
  124. package/src/v22/core/index.js +0 -22
  125. package/src/v22/core/response/index.js +0 -2
  126. package/src/v22/core/response/xmlToJson.js +0 -18
  127. package/src/v22/core/transport/http.js +0 -40
  128. package/src/v22/core/transport/index.js +0 -1
  129. package/src/v22/createApi.js +0 -106
  130. package/src/v22/index.js +0 -7
  131. package/src/v22/masters/Godown/index.js +0 -20
  132. package/src/v22/masters/Ledger/index.js +0 -22
  133. package/src/v22/masters/StockGroup/index.js +0 -18
  134. package/src/v22/masters/StockItem/index.js +0 -20
  135. package/src/v22/masters/Unit/index.js +0 -16
  136. package/src/v22/masters/index.js +0 -64
  137. package/src/v22/reports/index.js +0 -11
  138. package/src/v22/reports/stockSummary/index.js +0 -10
  139. package/src/v22/reports.json +0 -6
  140. package/src/v22/tdlMessage.json +0 -37
  141. package/src/v22/vouchers/index.js +0 -5
  142. package/src/v22/vouchers/purchases/index.js +0 -7
  143. package/src/v22/vouchers/sales/index.js +0 -7
  144. package/src/v23/body.xml +0 -25
  145. package/src/v23/bodyAsData.xml +0 -16
  146. package/src/v23/company/index.js +0 -7
  147. package/src/v23/core/buildXml.js +0 -9
  148. package/src/v23/core/execute/executeXml.js +0 -16
  149. package/src/v23/core/execute/index.js +0 -4
  150. package/src/v23/core/index.js +0 -22
  151. package/src/v23/core/response/index.js +0 -2
  152. package/src/v23/core/response/xmlToJson.js +0 -18
  153. package/src/v23/core/transport/http.js +0 -40
  154. package/src/v23/core/transport/index.js +0 -1
  155. package/src/v23/createApi.js +0 -106
  156. package/src/v23/index.js +0 -7
  157. package/src/v23/masters/Godown/index.js +0 -20
  158. package/src/v23/masters/Ledger/index.js +0 -22
  159. package/src/v23/masters/StockGroup/index.js +0 -18
  160. package/src/v23/masters/StockItem/index.js +0 -20
  161. package/src/v23/masters/Unit/index.js +0 -16
  162. package/src/v23/masters/index.js +0 -64
  163. package/src/v23/reports/index.js +0 -11
  164. package/src/v23/reports/stockSummary/index.js +0 -10
  165. package/src/v23/reports.json +0 -6
  166. package/src/v23/tdlMessage.json +0 -37
  167. package/src/v23/vouchers/index.js +0 -5
  168. package/src/v23/vouchers/purchases/index.js +0 -7
  169. package/src/v23/vouchers/sales/index.js +0 -7
  170. package/src/v24/api.json +0 -17
  171. package/src/v24/engine/execution/dispatchTally.js +0 -29
  172. package/src/v24/engine/execution/parseResponse.js +0 -13
  173. package/src/v24/engine/route/attachPath.js +0 -25
  174. package/src/v24/engine/route/createLeafHandler.js +0 -19
  175. package/src/v24/engine/route/index.js +0 -24
  176. package/src/v24/index.js +0 -12
  177. package/src/v24/source.json +0 -119
  178. /package/src/{v24/engine/execution → v28/engine/dispatchTally/buildXml}/templates.js +0 -0
  179. /package/src/{v24/engine/execution/getEndpointSpec.js → v28/engine/getEndpointSpec/index.js} +0 -0
  180. /package/src/{v24/engine/execution/validateInput.js → v28/engine/validateInput/index.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tally-xml-tdl",
3
- "version": "1.27.3",
3
+ "version": "1.31.1",
4
4
  "description": "Simple, clean TDL and XML extraction and manipulation tools for Tally",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -37,7 +37,7 @@
37
37
  "create-intellisense": "^1.2.1"
38
38
  },
39
39
  "dependencies": {
40
- "@keshavsoft/api-tree": "^11.1.1",
41
- "tally-spec": "^1.2.2"
40
+ "tally-extract": "^1.10.2",
41
+ "tally-spec": "^1.2.4"
42
42
  }
43
43
  }
package/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { default } from "./v27/index.js";
2
- export * from "./v27/index.js";
1
+ export { company, masters, vouchers } from "./v31/index.js";
2
+ export { default } from "./v31/index.js";
@@ -0,0 +1,13 @@
1
+ [
2
+ "app.ecosystem.architecture.philosophy.fetch",
3
+ "app.ecosystem.architecture.layers.fetch",
4
+ "app.ecosystem.tools.blueprint.fetch",
5
+ "app.ecosystem.tools.scaffolder.fetch",
6
+ "app.ecosystem.tools.intellisense.fetch",
7
+ "app.ecosystem.workflow.steps.fetch",
8
+ "app.ecosystem.workflow.principles.fetch",
9
+ "app.founder.profile.fetch",
10
+ "app.founder.links.fetch",
11
+ "app.company.info.fetch",
12
+ "app.company.packages.fetch"
13
+ ]
@@ -0,0 +1,228 @@
1
+ {
2
+ "app": {
3
+ "ecosystem": {
4
+ "architecture": {
5
+ "philosophy": {
6
+ "fetch": {
7
+ "action": "fetch",
8
+ "resource": "philosophy",
9
+ "description": "Explains why endpoints as structured data eliminates conventional folder sprawl.",
10
+ "data": {
11
+ "concept": "Endpoints as Data",
12
+ "problem": "In conventional client libraries, adding 50 endpoints requires creating 50 directories and 50 repetitive boilerplate files, causing maintenance drag and import fragility.",
13
+ "solution": "Define endpoints declaratively in JSON contracts (source.json + api.json) and assemble the callable object tree in memory at startup.",
14
+ "benefits": [
15
+ "Zero directory sprawl across packages",
16
+ "Single point of query customization in engine/execution",
17
+ "Instant in-memory object tree generation without code duplication",
18
+ "Deterministic compile-time TypeScript typing directly from JSON"
19
+ ]
20
+ }
21
+ }
22
+ },
23
+ "layers": {
24
+ "fetch": {
25
+ "action": "fetch",
26
+ "resource": "layers",
27
+ "description": "Details the three clean architectural layers of a JSON-driven NPM package.",
28
+ "data": {
29
+ "layers": [
30
+ {
31
+ "name": "1. Public Contract (api.json)",
32
+ "role": "Explicit array of allowed dot-separated paths controlling the public perimeter."
33
+ },
34
+ {
35
+ "name": "2. Domain Specification (source.json)",
36
+ "role": "Single source of truth for resources, actions, schemas, JSDocs, and mock or real payloads."
37
+ },
38
+ {
39
+ "name": "3. Engine (engine/)",
40
+ "role": "In-memory route tree assembly (engine/route/) and story-driven execution pipeline (engine/execution/)."
41
+ }
42
+ ]
43
+ }
44
+ }
45
+ }
46
+ },
47
+ "tools": {
48
+ "blueprint": {
49
+ "fetch": {
50
+ "action": "fetch",
51
+ "resource": "blueprint",
52
+ "description": "Specification for json-driven-npm: The Architectural Source of Truth.",
53
+ "data": {
54
+ "package": "json-driven-npm",
55
+ "role": "Architectural Source of Truth & Reference Specification",
56
+ "repository": "https://github.com/keshavsoft/json-driven-npm",
57
+ "npm": "https://www.npmjs.com/package/json-driven-npm",
58
+ "responsibilities": [
59
+ "Maintains reference versions (v1, v2, v3, v4)",
60
+ "Provides the in-memory route mounting engine",
61
+ "Provides the narrative execution coordinator",
62
+ "Exposes live CLI terminal inspector via npx json-driven-npm"
63
+ ],
64
+ "rule": "Never transports code itself; acts as the authoritative template source."
65
+ }
66
+ }
67
+ },
68
+ "scaffolder": {
69
+ "fetch": {
70
+ "action": "fetch",
71
+ "resource": "scaffolder",
72
+ "description": "Specification for create-json-driven-npm: The Zero-Dependency Code Transporter.",
73
+ "data": {
74
+ "package": "create-json-driven-npm",
75
+ "role": "The Scaffolder & Code Transporter",
76
+ "repository": "https://github.com/keshavsoft/create-json-driven-npm",
77
+ "npm": "https://www.npmjs.com/package/create-json-driven-npm",
78
+ "usage": "npm create json-driven-npm [target-directory] or npx create-json-driven-npm [target-directory]",
79
+ "mechanism": "Dynamically inspects node_modules/json-driven-npm/src, resolves the highest active version, and transports the clean skeleton into the target directory.",
80
+ "features": [
81
+ "Zero hardcoded templates (reads from json-driven-npm)",
82
+ "Built-in safety guards preventing overwrites",
83
+ "Instant scaffolding in 1 second"
84
+ ]
85
+ }
86
+ }
87
+ },
88
+ "intellisense": {
89
+ "fetch": {
90
+ "action": "fetch",
91
+ "resource": "intellisense",
92
+ "description": "Specification for create-intellisense: The Automated TypeScript Generator.",
93
+ "data": {
94
+ "package": "create-intellisense",
95
+ "role": "Zero-Dependency TypeScript Type & JSDoc Generator",
96
+ "repository": "https://github.com/keshavsoft/create-intellisense",
97
+ "npm": "https://www.npmjs.com/package/create-intellisense",
98
+ "usage": "npx create-intellisense",
99
+ "mechanism": "Scans api.json and source.json in the project root or active version folder and emits index.d.ts with full IDE autocomplete and hover tooltips.",
100
+ "features": [
101
+ "Zero external dependencies (pure Node.js builtins)",
102
+ "Flexible path discovery (supports flattened and nested layouts)",
103
+ "Auto-infers types from package.json and active exports"
104
+ ]
105
+ }
106
+ }
107
+ }
108
+ },
109
+ "workflow": {
110
+ "steps": {
111
+ "fetch": {
112
+ "action": "fetch",
113
+ "resource": "workflow",
114
+ "description": "The 3-step development guide for creating a new JSON-driven NPM package.",
115
+ "data": {
116
+ "steps": [
117
+ {
118
+ "step": 1,
119
+ "name": "Scaffold",
120
+ "command": "npm create json-driven-npm ./my-api-client",
121
+ "description": "create-json-driven-npm transports the clean v4 skeleton into your project directory with zero dependencies."
122
+ },
123
+ {
124
+ "step": 2,
125
+ "name": "Customize",
126
+ "command": "Edit api.json & source.json",
127
+ "description": "Define your public routes in api.json and endpoint metadata in source.json. Implement your custom query/fetch logic in engine/execution/index.js."
128
+ },
129
+ {
130
+ "step": 3,
131
+ "name": "Generate Types",
132
+ "command": "npx create-intellisense",
133
+ "description": "create-intellisense scans your JSON contracts and emits index.d.ts, giving your users instant autocomplete and type safety."
134
+ }
135
+ ]
136
+ }
137
+ }
138
+ },
139
+ "principles": {
140
+ "fetch": {
141
+ "action": "fetch",
142
+ "resource": "principles",
143
+ "description": "Core KeshavSoft engineering standards and design conventions.",
144
+ "data": {
145
+ "standards": [
146
+ {
147
+ "rule": "Strictly One Default Export",
148
+ "syntax": "export default startFunc;",
149
+ "rationale": "Eliminates named export clutter and namespace ambiguity."
150
+ },
151
+ {
152
+ "rule": "Standardized Parameter Unwrapping",
153
+ "syntax": "const startFunc = ({ inParam }) => { const localParam = inParam; ... };",
154
+ "rationale": "Prevents mutation of input objects and makes parameter origins explicit."
155
+ },
156
+ {
157
+ "rule": "Pure Domain Decoupling",
158
+ "syntax": "source.json contains business metadata only",
159
+ "rationale": "Keeps domain specifications independent from network protocols, headers, or runtime environments."
160
+ }
161
+ ]
162
+ }
163
+ }
164
+ }
165
+ }
166
+ },
167
+ "founder": {
168
+ "profile": {
169
+ "fetch": {
170
+ "action": "fetch",
171
+ "resource": "profile",
172
+ "description": "Fetches founder and software architect profile.",
173
+ "data": {
174
+ "name": "Keshav Nalam",
175
+ "role": "Software Architect & Developer",
176
+ "company": "KeshavSoft",
177
+ "location": "India",
178
+ "bio": "Creator of zero-dependency, declarative, JSON-driven NPM architectures."
179
+ }
180
+ }
181
+ },
182
+ "links": {
183
+ "fetch": {
184
+ "action": "fetch",
185
+ "resource": "links",
186
+ "description": "Fetches official website, GitHub, NPM, and LinkedIn profile links.",
187
+ "data": {
188
+ "website": "https://keshavsoft.com/",
189
+ "github": "https://github.com/keshavsoft",
190
+ "npm": "https://www.npmjs.com/~keshavsoft",
191
+ "linkedin": "https://www.linkedin.com/in/keshav-nalam"
192
+ }
193
+ }
194
+ }
195
+ },
196
+ "company": {
197
+ "info": {
198
+ "fetch": {
199
+ "action": "fetch",
200
+ "resource": "info",
201
+ "description": "Fetches KeshavSoft organization information and engineering philosophy.",
202
+ "data": {
203
+ "name": "KeshavSoft",
204
+ "tagline": "Pure, declarative, and config-driven software engineering",
205
+ "website": "https://keshavsoft.com/",
206
+ "philosophy": "Zero-dependency architectures, declarative pipelines, and zero folder sprawl"
207
+ }
208
+ }
209
+ },
210
+ "packages": {
211
+ "fetch": {
212
+ "action": "fetch",
213
+ "resource": "packages",
214
+ "description": "Lists flagship packages in the KeshavSoft ecosystem.",
215
+ "data": [
216
+ { "name": "tally-simple", "description": "Raw TDL transport client & CLI for Tally ERP/Prime" },
217
+ { "name": "tally-simple-json", "description": "Fast XML-to-JSON parsing client for Tally" },
218
+ { "name": "create-intellisense", "description": "Zero-dependency TypeScript declaration generator for JSON-driven architectures" },
219
+ { "name": "create-json-driven-npm", "description": "Official scaffolding tool to transport JSON-driven client architectures" },
220
+ { "name": "json-renderers", "description": "Browser DOM mounting runtime for declarative UI specifications" },
221
+ { "name": "json-renderers-build", "description": "Headless UI component specification compiler" },
222
+ { "name": "json-driven-npm", "description": "Architectural reference implementation and CLI runner for declarative, JSON-driven NPM packages" }
223
+ ]
224
+ }
225
+ }
226
+ }
227
+ }
228
+ }
@@ -0,0 +1,65 @@
1
+ const createCallable = ({ inRoutePath, inLeafSpec, inExecutor, inSource }) => {
2
+ const localRoutePath = inRoutePath;
3
+ const localLeafSpec = inLeafSpec;
4
+ const localExecutor = inExecutor;
5
+ const localSource = inSource;
6
+
7
+ return async (param, ...args) => {
8
+ const localParam = param;
9
+ const localArgs = args;
10
+
11
+ return await localExecutor({
12
+ inRoutePath: localRoutePath,
13
+ inLeafSpec: localLeafSpec,
14
+ inParam: localParam,
15
+ inArgs: localArgs,
16
+ inSource: localSource
17
+ });
18
+ };
19
+ };
20
+
21
+ const createCaller = (source, executor) => {
22
+ const localSource = source?.inSource ?? source;
23
+ const localExecutor = source?.inExecutor ?? executor;
24
+
25
+ return async (inRoutePath, inParam, ...inArgs) => {
26
+ const localRoutePath = inRoutePath;
27
+ const localParam = inParam;
28
+ const localArgs = inArgs;
29
+
30
+ const localLeafSpec = localRoutePath
31
+ ?.split(".")
32
+ .reduce((curr, key) => curr?.[key], localSource);
33
+
34
+ return await localExecutor({
35
+ inRoutePath: localRoutePath,
36
+ inLeafSpec: localLeafSpec,
37
+ inParam: localParam,
38
+ inArgs: localArgs,
39
+ inSource: localSource
40
+ });
41
+ };
42
+ };
43
+
44
+ const callRoute = async ({ inSource, inRoutePath, inExecutor, inParam, inArgs, inLeafSpec }) => {
45
+ const localSource = inSource;
46
+ const localRoutePath = inRoutePath;
47
+ const localExecutor = inExecutor;
48
+ const localParam = inParam;
49
+ const localArgs = inArgs ?? [];
50
+
51
+ const localLeafSpec = inLeafSpec ?? localRoutePath
52
+ ?.split(".")
53
+ .reduce((curr, key) => curr?.[key], localSource);
54
+
55
+ return await localExecutor({
56
+ inRoutePath: localRoutePath,
57
+ inLeafSpec: localLeafSpec,
58
+ inParam: localParam,
59
+ inArgs: localArgs,
60
+ inSource: localSource
61
+ });
62
+ };
63
+
64
+ export default createCallable;
65
+ export { createCallable, createCaller, callRoute };
@@ -0,0 +1,23 @@
1
+ import isObject from "./isObject.js";
2
+ import isStringArray from "./isStringArray.js";
3
+ import isFunction from "./isFunction.js";
4
+
5
+ const startFunc = ({ inSource, inRecipe, inExecutor }) => {
6
+ const localSource = inSource;
7
+ const localRecipe = inRecipe;
8
+ const localExecutor = inExecutor;
9
+
10
+ isObject({ inSource: localSource });
11
+
12
+ if (localRecipe !== undefined) {
13
+ if (Array.isArray(localRecipe)) {
14
+ isStringArray({ inApiPaths: localRecipe });
15
+ } else if (localRecipe === null || typeof localRecipe !== "object") {
16
+ isStringArray({ inApiPaths: localRecipe });
17
+ }
18
+ }
19
+
20
+ isFunction({ inExecutor: localExecutor });
21
+ };
22
+
23
+ export default startFunc;
@@ -0,0 +1,9 @@
1
+ const startFunc = ({ inExecutor }) => {
2
+ const localExecutor = inExecutor;
3
+
4
+ if (typeof localExecutor !== "function") {
5
+ throw new TypeError("executor must be a function.");
6
+ }
7
+ };
8
+
9
+ export default startFunc;
@@ -0,0 +1,9 @@
1
+ const startFunc = ({ inSource }) => {
2
+ const localSource = inSource;
3
+
4
+ if (!localSource || typeof localSource !== "object" || Array.isArray(localSource)) {
5
+ throw new TypeError("source must be a JSON object.");
6
+ }
7
+ };
8
+
9
+ export default startFunc;
@@ -0,0 +1,15 @@
1
+ const startFunc = ({ inApiPaths }) => {
2
+ const localApiPaths = inApiPaths;
3
+
4
+ if (!Array.isArray(localApiPaths)) {
5
+ throw new TypeError("apiPaths must be an array of strings.");
6
+ }
7
+
8
+ for (let i = 0; i < localApiPaths.length; i++) {
9
+ if (typeof localApiPaths[i] !== "string") {
10
+ throw new TypeError(`apiPaths must be an array of strings. apiPaths[${i}] must be a string.`);
11
+ }
12
+ }
13
+ };
14
+
15
+ export default startFunc;
@@ -0,0 +1,16 @@
1
+ import traverse from "./traversal/index.js";
2
+ import toTransformRecipe from "./toTransformRecipe.js";
3
+
4
+ const startFunc = ({ inSource, inRecipe, inExecutor }) => {
5
+ const localSource = inSource;
6
+ const localRecipe = toTransformRecipe({ inRecipe: inRecipe || inSource });
7
+ const localExecutor = inExecutor;
8
+
9
+ return traverse({
10
+ inSource: localSource,
11
+ inRecipe: localRecipe,
12
+ inExecutor: localExecutor
13
+ });
14
+ };
15
+
16
+ export default startFunc;
@@ -0,0 +1,53 @@
1
+ const startFunc = ({ inRecipe }) => {
2
+ const localRecipe = inRecipe;
3
+
4
+ if (Array.isArray(localRecipe)) {
5
+ const root = {};
6
+
7
+ for (const path of localRecipe) {
8
+ const parts = path.split(".");
9
+ let curr = root;
10
+
11
+ for (let i = 0; i < parts.length; i++) {
12
+ const part = parts[i];
13
+ curr.transform ??= {};
14
+ curr.transform[part] ??= {};
15
+
16
+ if (i < parts.length - 1) {
17
+ curr = curr.transform[part];
18
+ }
19
+ }
20
+ }
21
+
22
+ return root;
23
+ }
24
+
25
+ if (localRecipe && typeof localRecipe === "object") {
26
+ if ("transform" in localRecipe) {
27
+ return localRecipe;
28
+ }
29
+
30
+ const buildTransform = (node) => {
31
+ if (!node || typeof node !== "object" || Array.isArray(node)) {
32
+ return {};
33
+ }
34
+
35
+ if ("action" in node) {
36
+ return {};
37
+ }
38
+
39
+ const transform = {};
40
+ for (const [key, value] of Object.entries(node)) {
41
+ transform[key] = buildTransform(value);
42
+ }
43
+
44
+ return { transform };
45
+ };
46
+
47
+ return buildTransform(localRecipe);
48
+ }
49
+
50
+ return undefined;
51
+ };
52
+
53
+ export default startFunc;
@@ -0,0 +1,49 @@
1
+ import traverse from "../index.js";
2
+ import createCallable from "../../caller/index.js";
3
+
4
+ const startFunc = ({ inSource, inTransform, inRecipe, inExecutor, inPath, inRootSource }) => {
5
+ const localSource = inSource;
6
+ const localTransform = inTransform;
7
+ const localRecipe = inRecipe;
8
+ const localExecutor = inExecutor;
9
+ const localPath = inPath ?? [];
10
+ const localRootSource = inRootSource ?? inSource;
11
+
12
+ const newElement = {};
13
+
14
+ for (const [key, value] of Object.entries(localSource)) {
15
+ if (!(key in localTransform)) {
16
+ continue;
17
+ }
18
+
19
+ const directive = localTransform[key];
20
+ const newKey = directive?.alterKey || key;
21
+ const currentPath = [...localPath, key];
22
+
23
+ const hasNestedTransform = directive && typeof directive === "object" && "transform" in directive;
24
+ const hasSiblingRecipe = localRecipe && typeof localRecipe === "object" && newKey in localRecipe;
25
+
26
+ if (hasNestedTransform) {
27
+ newElement[newKey] = traverse({
28
+ inSource: value,
29
+ inRecipe: directive,
30
+ inExecutor: localExecutor,
31
+ inPath: currentPath,
32
+ inRootSource: localRootSource
33
+ });
34
+ } else if (hasSiblingRecipe) {
35
+ newElement[newKey] = value;
36
+ } else {
37
+ newElement[newKey] = createCallable({
38
+ inRoutePath: currentPath.join("."),
39
+ inLeafSpec: value,
40
+ inExecutor: localExecutor,
41
+ inSource: localRootSource
42
+ });
43
+ }
44
+ }
45
+
46
+ return newElement;
47
+ };
48
+
49
+ export default startFunc;
@@ -0,0 +1,34 @@
1
+ import traverseObject from "./traverseObject/index.js";
2
+ import traverseArray from "./traverseArray/index.js";
3
+
4
+ const startFunc = ({ inSource, inRecipe, inExecutor, inPath, inRootSource }) => {
5
+ const localSource = inSource;
6
+ const localRecipe = inRecipe;
7
+ const localExecutor = inExecutor;
8
+ const localPath = inPath ?? [];
9
+ const localRootSource = inRootSource ?? inSource;
10
+
11
+ if (Array.isArray(localSource)) {
12
+ return traverseArray({
13
+ inItems: localSource,
14
+ inRecipe: localRecipe,
15
+ inExecutor: localExecutor,
16
+ inPath: localPath,
17
+ inRootSource: localRootSource
18
+ });
19
+ }
20
+
21
+ if (typeof localSource === "object" && localSource !== null) {
22
+ return traverseObject({
23
+ inSource: localSource,
24
+ inRecipe: localRecipe,
25
+ inExecutor: localExecutor,
26
+ inPath: localPath,
27
+ inRootSource: localRootSource
28
+ });
29
+ }
30
+
31
+ return localSource;
32
+ };
33
+
34
+ export default startFunc;
@@ -0,0 +1,21 @@
1
+ import traverse from "../index.js";
2
+
3
+ const startFunc = ({ inItems, inRecipe, inExecutor, inPath, inRootSource }) => {
4
+ const localItems = inItems;
5
+ const localRecipe = inRecipe;
6
+ const localExecutor = inExecutor;
7
+ const localPath = inPath ?? [];
8
+ const localRootSource = inRootSource;
9
+
10
+ return localItems.map((item, index) =>
11
+ traverse({
12
+ inSource: item,
13
+ inRecipe: localRecipe,
14
+ inExecutor: localExecutor,
15
+ inPath: [...localPath, index],
16
+ inRootSource: localRootSource
17
+ })
18
+ );
19
+ };
20
+
21
+ export default startFunc;
@@ -0,0 +1,50 @@
1
+ import ifTransformFound from "../ifTransformFound/index.js";
2
+ import traverse from "../index.js";
3
+ import traverseArray from "../traverseArray/index.js";
4
+
5
+ const startFunc = ({ inSource, inRecipe, inExecutor, inPath, inRootSource }) => {
6
+ const localSource = inSource;
7
+ const localRecipe = inRecipe;
8
+ const localExecutor = inExecutor;
9
+ const localPath = inPath ?? [];
10
+ const localRootSource = inRootSource ?? inSource;
11
+
12
+ let newElement = {};
13
+
14
+ if (localRecipe && typeof localRecipe === "object" && "transform" in localRecipe) {
15
+ newElement = ifTransformFound({
16
+ inSource: localSource,
17
+ inTransform: localRecipe.transform,
18
+ inRecipe: localRecipe,
19
+ inExecutor: localExecutor,
20
+ inPath: localPath,
21
+ inRootSource: localRootSource
22
+ });
23
+ }
24
+
25
+ for (const [key, value] of Object.entries(newElement)) {
26
+ if (localRecipe && typeof localRecipe === "object" && key in localRecipe) {
27
+ if (Array.isArray(value)) {
28
+ newElement[key] = traverseArray({
29
+ inItems: value,
30
+ inRecipe: localRecipe[key],
31
+ inExecutor: localExecutor,
32
+ inPath: [...localPath, key],
33
+ inRootSource: localRootSource
34
+ });
35
+ } else if (typeof value === "object" && value !== null) {
36
+ newElement[key] = traverse({
37
+ inSource: value,
38
+ inRecipe: localRecipe[key],
39
+ inExecutor: localExecutor,
40
+ inPath: [...localPath, key],
41
+ inRootSource: localRootSource
42
+ });
43
+ }
44
+ }
45
+ }
46
+
47
+ return newElement;
48
+ };
49
+
50
+ export default startFunc;
@@ -0,0 +1,32 @@
1
+ import guards from "./engine/guards/index.js";
2
+ import run from "./engine/run.js";
3
+ import { createCaller, callRoute } from "./engine/caller/index.js";
4
+
5
+ const apiTree = (source, recipe, executor) => {
6
+ let localSource = source?.inSource ?? source;
7
+ let localRecipe = source?.inRecipe ?? source?.inInstruction ?? source?.inApiPaths ?? recipe;
8
+ let localExecutor = source?.inExecutor ?? executor;
9
+
10
+ if (executor === undefined && typeof recipe === "function") {
11
+ localRecipe = undefined;
12
+ localExecutor = recipe;
13
+ }
14
+
15
+ guards({
16
+ inSource: localSource,
17
+ inRecipe: localRecipe,
18
+ inExecutor: localExecutor
19
+ });
20
+
21
+ return run({
22
+ inSource: localSource,
23
+ inRecipe: localRecipe,
24
+ inExecutor: localExecutor
25
+ });
26
+ };
27
+
28
+ apiTree.createCaller = createCaller;
29
+ apiTree.callRoute = callRoute;
30
+
31
+ export default apiTree;
32
+ export { apiTree, apiTree as start, createCaller, callRoute };