@holoscript/core 6.0.3 → 7.0.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 (244) hide show
  1. package/README.md +40 -40
  2. package/dist/codebase/index.d.ts +25 -0
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +4 -0
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/entries/interop.d.ts +9 -0
  7. package/dist/entries/scripting.d.ts +7 -0
  8. package/dist/index.d.ts +520 -19
  9. package/dist/paper-0c-spike/index.d.ts +29 -0
  10. package/dist/reconstruction/index.d.ts +78 -0
  11. package/dist/self-improvement/index.d.ts +0 -48
  12. package/dist/storage/index.d.ts +24 -0
  13. package/dist/tools/index.d.ts +33 -0
  14. package/dist/traitDocs/traitDocs.d.ts +69 -0
  15. package/dist/traits/index.d.ts +61 -0
  16. package/package.json +102 -19
  17. package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
  18. package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
  19. package/dist/HoloScriptPlusParser-BZR5DELQ.js +0 -692
  20. package/dist/HoloScriptPlusParser-SBMYDNXO.cjs +0 -697
  21. package/dist/USDZExporter-MHEHXZB4.cjs +0 -709
  22. package/dist/USDZExporter-YA55ZS35.js +0 -707
  23. package/dist/chunk-26TLYBFD.js +0 -309
  24. package/dist/chunk-27LWW5FU.cjs +0 -410
  25. package/dist/chunk-2UX5LRAP.cjs +0 -833
  26. package/dist/chunk-32TWR3HE.js +0 -70
  27. package/dist/chunk-3FXV5S25.cjs +0 -633
  28. package/dist/chunk-3FYZOR7S.cjs +0 -69
  29. package/dist/chunk-3KEU5QYY.cjs +0 -175
  30. package/dist/chunk-4FCZDTD5.js +0 -610
  31. package/dist/chunk-4KJ2R7VP.cjs +0 -507
  32. package/dist/chunk-4SMUJFHL.js +0 -1213
  33. package/dist/chunk-54FHG2MX.js +0 -655
  34. package/dist/chunk-56IF4NTA.js +0 -56
  35. package/dist/chunk-5GLCTO44.js +0 -161
  36. package/dist/chunk-5TOFIR6L.js +0 -407
  37. package/dist/chunk-65RFOWZI.js +0 -765
  38. package/dist/chunk-6OQBLABR.js +0 -5240
  39. package/dist/chunk-6WNCRE6F.js +0 -126
  40. package/dist/chunk-74YCHHTE.js +0 -1872
  41. package/dist/chunk-7H5UNJZD.cjs +0 -1973
  42. package/dist/chunk-7KPI4EKH.cjs +0 -701
  43. package/dist/chunk-7LCYLPW2.cjs +0 -663
  44. package/dist/chunk-7N3JIJMT.js +0 -1395
  45. package/dist/chunk-7X2IEJIE.cjs +0 -2526
  46. package/dist/chunk-A6GO3DPZ.cjs +0 -1002
  47. package/dist/chunk-AC4BSHFV.js +0 -765
  48. package/dist/chunk-AIUXRS74.cjs +0 -3681
  49. package/dist/chunk-ARNKA274.cjs +0 -130
  50. package/dist/chunk-AW7WAELW.js +0 -975
  51. package/dist/chunk-BKIGPPVM.js +0 -629
  52. package/dist/chunk-BO2OKHIY.js +0 -6055
  53. package/dist/chunk-BU5ZAFMC.js +0 -115
  54. package/dist/chunk-BY3B7ZYV.cjs +0 -457
  55. package/dist/chunk-C2QHVHZF.js +0 -4066
  56. package/dist/chunk-C7BNX4XJ.js +0 -1043
  57. package/dist/chunk-CLYEIWA5.cjs +0 -408
  58. package/dist/chunk-CMYAWUX3.js +0 -4455
  59. package/dist/chunk-CN4NOESF.cjs +0 -416
  60. package/dist/chunk-CNVM7J3M.js +0 -883
  61. package/dist/chunk-CO2VM2DK.js +0 -1965
  62. package/dist/chunk-CQDOF3G7.cjs +0 -1404
  63. package/dist/chunk-DH5G2JUA.cjs +0 -614
  64. package/dist/chunk-DIEDKX5B.cjs +0 -660
  65. package/dist/chunk-DN7UFU63.cjs +0 -172
  66. package/dist/chunk-DXVCEFZB.js +0 -2027
  67. package/dist/chunk-EGIZHYJP.cjs +0 -85
  68. package/dist/chunk-EJA7G2C4.cjs +0 -428
  69. package/dist/chunk-ELLQPFAF.js +0 -830
  70. package/dist/chunk-EMO7HAKJ.cjs +0 -1875
  71. package/dist/chunk-ENV7K6XA.js +0 -282
  72. package/dist/chunk-EPWRXL6S.js +0 -2522
  73. package/dist/chunk-EUFLX2PI.js +0 -56956
  74. package/dist/chunk-F5LVGHNT.js +0 -449
  75. package/dist/chunk-FEFHPUEM.cjs +0 -6122
  76. package/dist/chunk-FF3Q7ADR.js +0 -380
  77. package/dist/chunk-GC3YU46J.js +0 -762
  78. package/dist/chunk-H6WMMLQK.cjs +0 -4492
  79. package/dist/chunk-H7XMORZI.js +0 -2731
  80. package/dist/chunk-HAN4V3PF.cjs +0 -2037
  81. package/dist/chunk-HBZYCASG.js +0 -4208
  82. package/dist/chunk-HF4OFY25.cjs +0 -4097
  83. package/dist/chunk-HHS6FMOU.cjs +0 -3813
  84. package/dist/chunk-HJJLD366.js +0 -1169
  85. package/dist/chunk-HKCVM6OK.cjs +0 -2237
  86. package/dist/chunk-HUFNKFA6.js +0 -698
  87. package/dist/chunk-I3XGTIHM.cjs +0 -1505
  88. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  89. package/dist/chunk-IHOUYQIA.js +0 -406
  90. package/dist/chunk-ILRBGFVD.cjs +0 -72
  91. package/dist/chunk-KDB6BUMB.js +0 -3666
  92. package/dist/chunk-KUJRR4FJ.js +0 -657
  93. package/dist/chunk-KYM4XRFG.js +0 -421
  94. package/dist/chunk-L3Z2HIWJ.cjs +0 -793
  95. package/dist/chunk-LBPEZQAF.js +0 -2232
  96. package/dist/chunk-LER4WXW5.cjs +0 -286
  97. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  98. package/dist/chunk-M6FU6S22.js +0 -2911
  99. package/dist/chunk-MWEFR6YQ.js +0 -1857
  100. package/dist/chunk-N5FTS757.cjs +0 -415
  101. package/dist/chunk-NCUHGRTZ.js +0 -752
  102. package/dist/chunk-NKRKT6V2.js +0 -69
  103. package/dist/chunk-NLPSZT4C.js +0 -630
  104. package/dist/chunk-NRUB55IT.cjs +0 -771
  105. package/dist/chunk-NTMZSDXM.cjs +0 -633
  106. package/dist/chunk-ODGMVILH.js +0 -9662
  107. package/dist/chunk-PBA6NXCT.cjs +0 -1216
  108. package/dist/chunk-PHENW4MQ.js +0 -65
  109. package/dist/chunk-PJMOXFPR.cjs +0 -1861
  110. package/dist/chunk-PLMYCCA4.js +0 -504
  111. package/dist/chunk-PPULB4GG.cjs +0 -9728
  112. package/dist/chunk-PQLGZKMC.cjs +0 -755
  113. package/dist/chunk-Q56TT7IL.js +0 -483
  114. package/dist/chunk-QHVVVN47.cjs +0 -2033
  115. package/dist/chunk-QWKUKVRE.js +0 -2026
  116. package/dist/chunk-RE3OKSYF.cjs +0 -424
  117. package/dist/chunk-RT7LJRSF.cjs +0 -57378
  118. package/dist/chunk-SPDELRRV.cjs +0 -319
  119. package/dist/chunk-SUCBB66F.js +0 -229
  120. package/dist/chunk-TSWTWZ42.cjs +0 -4214
  121. package/dist/chunk-UITWA6DV.cjs +0 -2829
  122. package/dist/chunk-UQW6SLM5.js +0 -172
  123. package/dist/chunk-V2ILLPHK.cjs +0 -237
  124. package/dist/chunk-V42NTCFH.js +0 -3645
  125. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  126. package/dist/chunk-VJVCD5T5.cjs +0 -769
  127. package/dist/chunk-VK5AXKO3.js +0 -746
  128. package/dist/chunk-VSXOIUCF.cjs +0 -473
  129. package/dist/chunk-VZNKJZTT.cjs +0 -749
  130. package/dist/chunk-W76ETJTI.js +0 -678
  131. package/dist/chunk-WFJIDI2N.cjs +0 -424
  132. package/dist/chunk-WN3YF33G.cjs +0 -118
  133. package/dist/chunk-WUXIRGZP.cjs +0 -2915
  134. package/dist/chunk-WYH4GVZ5.js +0 -1488
  135. package/dist/chunk-X4YVN7H3.cjs +0 -888
  136. package/dist/chunk-X67XRI2T.js +0 -410
  137. package/dist/chunk-XDXZM3ZP.cjs +0 -1046
  138. package/dist/chunk-XH7SE4HH.cjs +0 -72
  139. package/dist/chunk-XNMEH2BI.js +0 -126
  140. package/dist/chunk-XSF76QRU.js +0 -468
  141. package/dist/chunk-XSUZMPVQ.cjs +0 -682
  142. package/dist/chunk-XUILI4KB.cjs +0 -430
  143. package/dist/chunk-Y5MUAYTO.js +0 -167
  144. package/dist/chunk-Y7VK5TH3.cjs +0 -129
  145. package/dist/chunk-YCMQQQ5U.cjs +0 -5244
  146. package/dist/chunk-YYXH45E2.js +0 -426
  147. package/dist/chunk-ZGTGVSTZ.js +0 -422
  148. package/dist/chunk-ZL6VJ6SN.js +0 -421
  149. package/dist/cli/holoscript-runner.cjs +0 -2258
  150. package/dist/cli/holoscript-runner.js +0 -2233
  151. package/dist/codebase/index.cjs +0 -336
  152. package/dist/codebase/index.js +0 -331
  153. package/dist/compiler/agent-inference.cjs +0 -29
  154. package/dist/compiler/agent-inference.js +0 -6
  155. package/dist/compiler/android-xr.cjs +0 -20
  156. package/dist/compiler/android-xr.js +0 -10
  157. package/dist/compiler/android.cjs +0 -21
  158. package/dist/compiler/android.js +0 -11
  159. package/dist/compiler/ar.cjs +0 -21
  160. package/dist/compiler/ar.js +0 -9
  161. package/dist/compiler/babylon.cjs +0 -18
  162. package/dist/compiler/babylon.js +0 -12
  163. package/dist/compiler/coco.cjs +0 -27
  164. package/dist/compiler/coco.js +0 -4
  165. package/dist/compiler/domain-block-utils.cjs +0 -595
  166. package/dist/compiler/domain-block-utils.js +0 -9
  167. package/dist/compiler/dtdl.cjs +0 -25
  168. package/dist/compiler/dtdl.js +0 -9
  169. package/dist/compiler/gltf-pipeline.cjs +0 -39
  170. package/dist/compiler/gltf-pipeline.js +0 -4
  171. package/dist/compiler/godot.cjs +0 -16
  172. package/dist/compiler/godot.js +0 -10
  173. package/dist/compiler/incremental.cjs +0 -30
  174. package/dist/compiler/incremental.js +0 -5
  175. package/dist/compiler/index.cjs +0 -1522
  176. package/dist/compiler/index.js +0 -1321
  177. package/dist/compiler/ios.cjs +0 -21
  178. package/dist/compiler/ios.js +0 -11
  179. package/dist/compiler/multi-layer.cjs +0 -27
  180. package/dist/compiler/multi-layer.js +0 -12
  181. package/dist/compiler/nodetoy.cjs +0 -23
  182. package/dist/compiler/nodetoy.js +0 -4
  183. package/dist/compiler/openxr.cjs +0 -16
  184. package/dist/compiler/openxr.js +0 -10
  185. package/dist/compiler/playcanvas.cjs +0 -17
  186. package/dist/compiler/playcanvas.js +0 -11
  187. package/dist/compiler/r3f.cjs +0 -35
  188. package/dist/compiler/r3f.js +0 -13
  189. package/dist/compiler/remotion.cjs +0 -23
  190. package/dist/compiler/remotion.js +0 -4
  191. package/dist/compiler/reproducibility.cjs +0 -39
  192. package/dist/compiler/reproducibility.js +0 -4
  193. package/dist/compiler/sdf.cjs +0 -22
  194. package/dist/compiler/sdf.js +0 -10
  195. package/dist/compiler/semantic-scene.cjs +0 -31
  196. package/dist/compiler/semantic-scene.js +0 -4
  197. package/dist/compiler/state.cjs +0 -18
  198. package/dist/compiler/state.js +0 -8
  199. package/dist/compiler/trait-composition.cjs +0 -27
  200. package/dist/compiler/trait-composition.js +0 -6
  201. package/dist/compiler/unity.cjs +0 -16
  202. package/dist/compiler/unity.js +0 -10
  203. package/dist/compiler/unreal.cjs +0 -20
  204. package/dist/compiler/unreal.js +0 -10
  205. package/dist/compiler/urdf.cjs +0 -46
  206. package/dist/compiler/urdf.js +0 -10
  207. package/dist/compiler/usd-physics.cjs +0 -24
  208. package/dist/compiler/usd-physics.js +0 -7
  209. package/dist/compiler/visionos.cjs +0 -16
  210. package/dist/compiler/visionos.js +0 -10
  211. package/dist/compiler/vrchat.cjs +0 -20
  212. package/dist/compiler/vrchat.js +0 -10
  213. package/dist/compiler/vrr.cjs +0 -22
  214. package/dist/compiler/vrr.js +0 -10
  215. package/dist/compiler/wasm.cjs +0 -34
  216. package/dist/compiler/wasm.js +0 -10
  217. package/dist/compiler/webgpu.cjs +0 -16
  218. package/dist/compiler/webgpu.js +0 -10
  219. package/dist/debugger.cjs +0 -21
  220. package/dist/debugger.js +0 -8
  221. package/dist/entries/interop.cjs +0 -62
  222. package/dist/entries/interop.js +0 -5
  223. package/dist/entries/scripting.cjs +0 -67
  224. package/dist/entries/scripting.js +0 -10
  225. package/dist/index.cjs +0 -61703
  226. package/dist/index.js +0 -58652
  227. package/dist/math/vec3.cjs +0 -57
  228. package/dist/math/vec3.js +0 -4
  229. package/dist/parser.cjs +0 -26
  230. package/dist/parser.js +0 -9
  231. package/dist/playwright-7DTEQCBD.cjs +0 -98673
  232. package/dist/playwright-BIZXMLD2.js +0 -98660
  233. package/dist/post-quantum-JTTAAGO3.cjs +0 -6
  234. package/dist/post-quantum-RVPVDEPI.js +0 -4
  235. package/dist/runtime.cjs +0 -16
  236. package/dist/runtime.js +0 -7
  237. package/dist/storage/index.cjs +0 -37
  238. package/dist/storage/index.js +0 -4
  239. package/dist/traits/index.cjs +0 -14331
  240. package/dist/traits/index.js +0 -12126
  241. package/dist/type-checker.cjs +0 -18
  242. package/dist/type-checker.js +0 -5
  243. package/dist/wot/index.cjs +0 -29
  244. package/dist/wot/index.js +0 -4
@@ -1,410 +0,0 @@
1
- // src/wot/ThingDescriptionGenerator.ts
2
- var ThingDescriptionGenerator = class {
3
- constructor(options = {}) {
4
- this.options = {
5
- baseUrl: options.baseUrl || "",
6
- contentType: options.contentType || "application/json",
7
- defaultObservable: options.defaultObservable ?? true,
8
- securityDefinitions: options.securityDefinitions
9
- };
10
- }
11
- /**
12
- * Generate a Thing Description from a HoloScript node with @wot_thing trait
13
- */
14
- generate(node) {
15
- const wotTrait = this.findWoTTrait(node);
16
- if (!wotTrait) {
17
- return null;
18
- }
19
- const config = this.parseWoTConfig(wotTrait);
20
- const stateProperties = this.extractStateProperties(node);
21
- const actions = this.extractActions(node);
22
- const events = this.extractEvents(node);
23
- const td = {
24
- "@context": "https://www.w3.org/2022/wot/td/v1.1",
25
- id: config.id || `urn:holoscript:${node.name || "thing"}`,
26
- title: config.title || node.name || "Unnamed Thing",
27
- security: "default",
28
- securityDefinitions: this.buildSecurityDefinitions(config.security)
29
- };
30
- if (config.description) {
31
- td.description = config.description;
32
- }
33
- if (config.base || this.options.baseUrl) {
34
- td.base = config.base || this.options.baseUrl;
35
- }
36
- if (config.version) {
37
- td.version = { instance: config.version };
38
- }
39
- if (Object.keys(stateProperties).length > 0) {
40
- td.properties = stateProperties;
41
- }
42
- if (Object.keys(actions).length > 0) {
43
- td.actions = actions;
44
- }
45
- if (Object.keys(events).length > 0) {
46
- td.events = events;
47
- }
48
- return td;
49
- }
50
- /**
51
- * Generate Thing Descriptions for all nodes with @wot_thing trait
52
- */
53
- generateAll(nodes) {
54
- const results = [];
55
- const processNode = (node) => {
56
- const td = this.generate(node);
57
- if (td) {
58
- results.push(td);
59
- }
60
- if (node.children) {
61
- for (const child of node.children) {
62
- processNode(child);
63
- }
64
- }
65
- };
66
- for (const node of nodes) {
67
- processNode(node);
68
- }
69
- return results;
70
- }
71
- /**
72
- * Find @wot_thing directive in node
73
- */
74
- findWoTTrait(node) {
75
- if (!node.directives) {
76
- return null;
77
- }
78
- return node.directives.find(
79
- (d) => d.type === "trait" && d.name === "wot_thing" || d.type === "directive" && d.name === "wot_thing"
80
- ) || null;
81
- }
82
- /**
83
- * Parse @wot_thing config from directive
84
- */
85
- parseWoTConfig(directive) {
86
- const dir = directive;
87
- const args = dir.args || dir.config || {};
88
- return {
89
- title: String(args.title || ""),
90
- description: args.description ? String(args.description) : void 0,
91
- security: args.security || "nosec",
92
- base: args.base ? String(args.base) : void 0,
93
- id: args.id ? String(args.id) : void 0,
94
- version: args.version ? String(args.version) : void 0
95
- };
96
- }
97
- /**
98
- * Extract TD properties from @state block
99
- */
100
- extractStateProperties(node) {
101
- const properties = {};
102
- if (!node.directives) {
103
- return properties;
104
- }
105
- const stateDirective = node.directives.find(
106
- (d) => d.type === "state" || d.type === "directive" && d.name === "state"
107
- );
108
- if (!stateDirective || !stateDirective.body) {
109
- if (node.properties?.state && typeof node.properties.state === "object") {
110
- return this.mapStateToProperties(node.properties.state);
111
- }
112
- return properties;
113
- }
114
- const rawBody = stateDirective.body;
115
- const stateBody = typeof rawBody === "object" && rawBody !== null ? rawBody : {};
116
- return this.mapStateToProperties(stateBody);
117
- }
118
- /**
119
- * Map state object to TD properties
120
- */
121
- mapStateToProperties(state) {
122
- const properties = {};
123
- for (const [key, value] of Object.entries(state)) {
124
- const property = {
125
- type: this.inferType(value),
126
- observable: this.options.defaultObservable,
127
- forms: [
128
- {
129
- href: `${this.options.baseUrl}/properties/${key}`,
130
- contentType: this.options.contentType,
131
- op: ["readproperty", "writeproperty"]
132
- }
133
- ]
134
- };
135
- if (value !== void 0 && value !== null) {
136
- property.default = value;
137
- }
138
- if (typeof value === "number") {
139
- if (Number.isInteger(value)) {
140
- property.type = "integer";
141
- }
142
- }
143
- if (Array.isArray(value)) {
144
- property.type = "array";
145
- if (value.length > 0) {
146
- property.items = { type: this.inferType(value[0]) };
147
- }
148
- }
149
- if (value !== null && typeof value === "object" && !Array.isArray(value)) {
150
- property.type = "object";
151
- property.properties = {};
152
- for (const [subKey, subValue] of Object.entries(value)) {
153
- property.properties[subKey] = { type: this.inferType(subValue) };
154
- }
155
- }
156
- properties[key] = property;
157
- }
158
- return properties;
159
- }
160
- /**
161
- * Extract TD actions from @on_* handlers
162
- */
163
- extractActions(node) {
164
- const actions = {};
165
- if (!node.directives) {
166
- return actions;
167
- }
168
- const actionPatterns = [
169
- /^on_click$/,
170
- /^on_grab$/,
171
- /^on_release$/,
172
- /^on_hover$/,
173
- /^on_action$/,
174
- /^on_command$/,
175
- /^on_invoke$/,
176
- /^on_call$/
177
- ];
178
- for (const directive of node.directives) {
179
- const d = directive;
180
- if (directive.type !== "lifecycle" && d.hook === void 0) {
181
- continue;
182
- }
183
- const hookName = d.hook || d.name;
184
- if (!hookName) continue;
185
- const isAction = actionPatterns.some((pattern) => pattern.test(hookName));
186
- if (!isAction) continue;
187
- const actionName = hookName.replace(/^on_/, "");
188
- actions[actionName] = {
189
- title: this.toTitleCase(actionName),
190
- description: `Invoke ${actionName} action`,
191
- safe: false,
192
- idempotent: false,
193
- forms: [
194
- {
195
- href: `${this.options.baseUrl}/actions/${actionName}`,
196
- contentType: this.options.contentType,
197
- op: "invokeaction"
198
- }
199
- ]
200
- };
201
- if (d.args && typeof d.args === "object") {
202
- actions[actionName].input = {
203
- type: "object",
204
- properties: this.extractInputSchema(d.args)
205
- };
206
- }
207
- }
208
- return actions;
209
- }
210
- /**
211
- * Extract TD events from emit() calls
212
- */
213
- extractEvents(node) {
214
- const events = {};
215
- if (!node.directives) {
216
- return events;
217
- }
218
- const observableDirectives = node.directives.filter(
219
- (d) => d.type === "directive" && (d.name === "observable" || d.name === "event" || d.name === "emit")
220
- );
221
- for (const directive of observableDirectives) {
222
- const dirExt = directive;
223
- const args = dirExt.args || dirExt.config || {};
224
- const eventName = args.name || args.event || "change";
225
- events[String(eventName)] = {
226
- title: this.toTitleCase(String(eventName)),
227
- description: `${eventName} event`,
228
- forms: [
229
- {
230
- href: `${this.options.baseUrl}/events/${eventName}`,
231
- contentType: this.options.contentType,
232
- subprotocol: "sse",
233
- op: "subscribeevent"
234
- }
235
- ]
236
- };
237
- if (args.data && typeof args.data === "object") {
238
- events[String(eventName)].data = {
239
- type: "object",
240
- properties: this.extractInputSchema(args.data)
241
- };
242
- }
243
- }
244
- const emitPattern = /emit\s*\(\s*['"]([^'"]+)['"]/g;
245
- for (const directive of node.directives) {
246
- const dirBody = directive.body;
247
- if (dirBody && typeof dirBody === "string") {
248
- let match;
249
- while ((match = emitPattern.exec(dirBody)) !== null) {
250
- const eventName = match[1];
251
- if (!events[eventName]) {
252
- events[eventName] = {
253
- title: this.toTitleCase(eventName),
254
- description: `${eventName} event`,
255
- forms: [
256
- {
257
- href: `${this.options.baseUrl}/events/${eventName}`,
258
- contentType: this.options.contentType,
259
- subprotocol: "sse",
260
- op: "subscribeevent"
261
- }
262
- ]
263
- };
264
- }
265
- }
266
- }
267
- }
268
- return events;
269
- }
270
- /**
271
- * Build security definitions based on config
272
- */
273
- buildSecurityDefinitions(security) {
274
- if (this.options.securityDefinitions) {
275
- return this.options.securityDefinitions;
276
- }
277
- const definitions = {};
278
- switch (security) {
279
- case "basic":
280
- definitions.default = {
281
- scheme: "basic",
282
- in: "header"
283
- };
284
- break;
285
- case "bearer":
286
- definitions.default = {
287
- scheme: "bearer",
288
- in: "header",
289
- format: "jwt"
290
- };
291
- break;
292
- case "oauth2":
293
- definitions.default = {
294
- scheme: "oauth2",
295
- flow: "code"
296
- };
297
- break;
298
- case "apikey":
299
- definitions.default = {
300
- scheme: "apikey",
301
- in: "header",
302
- name: "X-API-Key"
303
- };
304
- break;
305
- case "nosec":
306
- default:
307
- definitions.default = {
308
- scheme: "nosec"
309
- };
310
- break;
311
- }
312
- return definitions;
313
- }
314
- /**
315
- * Extract input schema from args object
316
- */
317
- extractInputSchema(args) {
318
- const schema = {};
319
- for (const [key, value] of Object.entries(args)) {
320
- schema[key] = { type: this.inferType(value) };
321
- }
322
- return schema;
323
- }
324
- /**
325
- * Infer JSON Schema type from value
326
- */
327
- inferType(value) {
328
- if (value === null) return "null";
329
- if (typeof value === "boolean") return "boolean";
330
- if (typeof value === "number") {
331
- return Number.isInteger(value) ? "integer" : "number";
332
- }
333
- if (typeof value === "string") return "string";
334
- if (Array.isArray(value)) return "array";
335
- if (typeof value === "object") return "object";
336
- return "string";
337
- }
338
- /**
339
- * Convert snake_case or camelCase to Title Case
340
- */
341
- toTitleCase(str) {
342
- return str.replace(/_/g, " ").replace(/([A-Z])/g, " $1").replace(/^\s+/, "").split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
343
- }
344
- };
345
- function generateThingDescription(node, options) {
346
- const generator = new ThingDescriptionGenerator(options);
347
- return generator.generate(node);
348
- }
349
- function generateAllThingDescriptions(nodes, options) {
350
- const generator = new ThingDescriptionGenerator(options);
351
- return generator.generateAll(nodes);
352
- }
353
- function serializeThingDescription(td, pretty = true) {
354
- return JSON.stringify(td, null, pretty ? 2 : 0);
355
- }
356
- function validateThingDescription(td) {
357
- const errors = [];
358
- if (!td["@context"]) {
359
- errors.push("Missing required field '@context'");
360
- }
361
- if (!td.title) {
362
- errors.push("Missing required field 'title'");
363
- }
364
- if (!td.security) {
365
- errors.push("Missing required field 'security'");
366
- }
367
- if (!td.securityDefinitions) {
368
- errors.push("Missing required field 'securityDefinitions'");
369
- }
370
- if (td.security && td.securityDefinitions) {
371
- const securityNames = Array.isArray(td.security) ? td.security : [td.security];
372
- for (const name of securityNames) {
373
- if (!td.securityDefinitions[name]) {
374
- errors.push(`Security definition '${name}' not found in securityDefinitions`);
375
- }
376
- }
377
- }
378
- const validateForms = (forms) => {
379
- if (forms) {
380
- for (const form of forms) {
381
- if (!form.href) {
382
- errors.push("Form missing required href");
383
- }
384
- }
385
- }
386
- };
387
- if (td.properties) {
388
- for (const prop of Object.values(td.properties)) {
389
- validateForms(prop.forms);
390
- }
391
- }
392
- if (td.actions) {
393
- for (const action of Object.values(td.actions)) {
394
- validateForms(action.forms);
395
- }
396
- }
397
- if (td.events) {
398
- for (const event of Object.values(td.events)) {
399
- validateForms(event.forms);
400
- }
401
- }
402
- return {
403
- valid: errors.length === 0,
404
- errors
405
- };
406
- }
407
-
408
- export { ThingDescriptionGenerator, generateAllThingDescriptions, generateThingDescription, serializeThingDescription, validateThingDescription };
409
- //# sourceMappingURL=chunk-X67XRI2T.js.map
410
- //# sourceMappingURL=chunk-X67XRI2T.js.map