@tiangong-lca/tidas-sdk 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 (227) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +0 -0
  3. package/dist/core/base/TidasEntity.d.ts +97 -0
  4. package/dist/core/base/TidasEntity.d.ts.map +1 -0
  5. package/dist/core/base/TidasEntity.js +241 -0
  6. package/dist/core/base/TidasEntity.js.map +1 -0
  7. package/dist/core/config/GlobalConfig.d.ts +60 -0
  8. package/dist/core/config/GlobalConfig.d.ts.map +1 -0
  9. package/dist/core/config/GlobalConfig.js +110 -0
  10. package/dist/core/config/GlobalConfig.js.map +1 -0
  11. package/dist/core/config/ValidationConfig.d.ts +70 -0
  12. package/dist/core/config/ValidationConfig.d.ts.map +1 -0
  13. package/dist/core/config/ValidationConfig.js +159 -0
  14. package/dist/core/config/ValidationConfig.js.map +1 -0
  15. package/dist/core/entities/TidasContact.d.ts +14 -0
  16. package/dist/core/entities/TidasContact.d.ts.map +1 -0
  17. package/dist/core/entities/TidasContact.js +87 -0
  18. package/dist/core/entities/TidasContact.js.map +1 -0
  19. package/dist/core/entities/TidasFlow.d.ts +14 -0
  20. package/dist/core/entities/TidasFlow.d.ts.map +1 -0
  21. package/dist/core/entities/TidasFlow.js +105 -0
  22. package/dist/core/entities/TidasFlow.js.map +1 -0
  23. package/dist/core/entities/TidasFlowProperty.d.ts +14 -0
  24. package/dist/core/entities/TidasFlowProperty.d.ts.map +1 -0
  25. package/dist/core/entities/TidasFlowProperty.js +111 -0
  26. package/dist/core/entities/TidasFlowProperty.js.map +1 -0
  27. package/dist/core/entities/TidasLCIAMethod.d.ts +14 -0
  28. package/dist/core/entities/TidasLCIAMethod.d.ts.map +1 -0
  29. package/dist/core/entities/TidasLCIAMethod.js +125 -0
  30. package/dist/core/entities/TidasLCIAMethod.js.map +1 -0
  31. package/dist/core/entities/TidasLifeCycleModel.d.ts +14 -0
  32. package/dist/core/entities/TidasLifeCycleModel.d.ts.map +1 -0
  33. package/dist/core/entities/TidasLifeCycleModel.js +117 -0
  34. package/dist/core/entities/TidasLifeCycleModel.js.map +1 -0
  35. package/dist/core/entities/TidasProcess.d.ts +14 -0
  36. package/dist/core/entities/TidasProcess.d.ts.map +1 -0
  37. package/dist/core/entities/TidasProcess.js +129 -0
  38. package/dist/core/entities/TidasProcess.js.map +1 -0
  39. package/dist/core/entities/TidasSource.d.ts +14 -0
  40. package/dist/core/entities/TidasSource.d.ts.map +1 -0
  41. package/dist/core/entities/TidasSource.js +101 -0
  42. package/dist/core/entities/TidasSource.js.map +1 -0
  43. package/dist/core/entities/TidasUnitGroup.d.ts +14 -0
  44. package/dist/core/entities/TidasUnitGroup.d.ts.map +1 -0
  45. package/dist/core/entities/TidasUnitGroup.js +121 -0
  46. package/dist/core/entities/TidasUnitGroup.js.map +1 -0
  47. package/dist/core/factories/index.d.ts +49 -0
  48. package/dist/core/factories/index.d.ts.map +1 -0
  49. package/dist/core/factories/index.js +171 -0
  50. package/dist/core/factories/index.js.map +1 -0
  51. package/dist/core/index.d.ts +11 -0
  52. package/dist/core/index.d.ts.map +1 -0
  53. package/dist/core/index.js +47 -0
  54. package/dist/core/index.js.map +1 -0
  55. package/dist/core/zod-factories.d.ts +71 -0
  56. package/dist/core/zod-factories.d.ts.map +1 -0
  57. package/dist/core/zod-factories.js +169 -0
  58. package/dist/core/zod-factories.js.map +1 -0
  59. package/dist/core/zod-proxy.d.ts +108 -0
  60. package/dist/core/zod-proxy.d.ts.map +1 -0
  61. package/dist/core/zod-proxy.js +382 -0
  62. package/dist/core/zod-proxy.js.map +1 -0
  63. package/dist/index.d.ts +32 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +64 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/schemas/index.d.ts +48 -0
  68. package/dist/schemas/index.d.ts.map +1 -0
  69. package/dist/schemas/index.js +111 -0
  70. package/dist/schemas/index.js.map +1 -0
  71. package/dist/schemas/tidas_contacts.schema.d.ts +2340 -0
  72. package/dist/schemas/tidas_contacts.schema.d.ts.map +1 -0
  73. package/dist/schemas/tidas_contacts.schema.js +75 -0
  74. package/dist/schemas/tidas_contacts.schema.js.map +1 -0
  75. package/dist/schemas/tidas_contacts_category.schema.d.ts +3 -0
  76. package/dist/schemas/tidas_contacts_category.schema.d.ts.map +1 -0
  77. package/dist/schemas/tidas_contacts_category.schema.js +53 -0
  78. package/dist/schemas/tidas_contacts_category.schema.js.map +1 -0
  79. package/dist/schemas/tidas_data_types.schema.d.ts +172 -0
  80. package/dist/schemas/tidas_data_types.schema.d.ts.map +1 -0
  81. package/dist/schemas/tidas_data_types.schema.js +74 -0
  82. package/dist/schemas/tidas_data_types.schema.js.map +1 -0
  83. package/dist/schemas/tidas_flowproperties.schema.d.ts +2505 -0
  84. package/dist/schemas/tidas_flowproperties.schema.d.ts.map +1 -0
  85. package/dist/schemas/tidas_flowproperties.schema.js +78 -0
  86. package/dist/schemas/tidas_flowproperties.schema.js.map +1 -0
  87. package/dist/schemas/tidas_flowproperties_category.schema.d.ts +3 -0
  88. package/dist/schemas/tidas_flowproperties_category.schema.d.ts.map +1 -0
  89. package/dist/schemas/tidas_flowproperties_category.schema.js +28 -0
  90. package/dist/schemas/tidas_flowproperties_category.schema.js.map +1 -0
  91. package/dist/schemas/tidas_flows.schema.d.ts +3366 -0
  92. package/dist/schemas/tidas_flows.schema.d.ts.map +1 -0
  93. package/dist/schemas/tidas_flows.schema.js +125 -0
  94. package/dist/schemas/tidas_flows.schema.js.map +1 -0
  95. package/dist/schemas/tidas_flows_elementary_category.schema.d.ts +3 -0
  96. package/dist/schemas/tidas_flows_elementary_category.schema.d.ts.map +1 -0
  97. package/dist/schemas/tidas_flows_elementary_category.schema.js +309 -0
  98. package/dist/schemas/tidas_flows_elementary_category.schema.js.map +1 -0
  99. package/dist/schemas/tidas_flows_product_category.schema.d.ts +3 -0
  100. package/dist/schemas/tidas_flows_product_category.schema.d.ts.map +1 -0
  101. package/dist/schemas/tidas_flows_product_category.schema.js +28508 -0
  102. package/dist/schemas/tidas_flows_product_category.schema.js.map +1 -0
  103. package/dist/schemas/tidas_lciamethods.schema.d.ts +11025 -0
  104. package/dist/schemas/tidas_lciamethods.schema.d.ts.map +1 -0
  105. package/dist/schemas/tidas_lciamethods.schema.js +439 -0
  106. package/dist/schemas/tidas_lciamethods.schema.js.map +1 -0
  107. package/dist/schemas/tidas_lciamethods_category.schema.d.ts +3 -0
  108. package/dist/schemas/tidas_lciamethods_category.schema.d.ts.map +1 -0
  109. package/dist/schemas/tidas_lciamethods_category.schema.js +278 -0
  110. package/dist/schemas/tidas_lciamethods_category.schema.js.map +1 -0
  111. package/dist/schemas/tidas_lifecyclemodels.schema.d.ts +9362 -0
  112. package/dist/schemas/tidas_lifecyclemodels.schema.d.ts.map +1 -0
  113. package/dist/schemas/tidas_lifecyclemodels.schema.js +384 -0
  114. package/dist/schemas/tidas_lifecyclemodels.schema.js.map +1 -0
  115. package/dist/schemas/tidas_locations_category.schema.d.ts +3 -0
  116. package/dist/schemas/tidas_locations_category.schema.d.ts.map +1 -0
  117. package/dist/schemas/tidas_locations_category.schema.js +655 -0
  118. package/dist/schemas/tidas_locations_category.schema.js.map +1 -0
  119. package/dist/schemas/tidas_processes.schema.d.ts +12861 -0
  120. package/dist/schemas/tidas_processes.schema.d.ts.map +1 -0
  121. package/dist/schemas/tidas_processes.schema.js +547 -0
  122. package/dist/schemas/tidas_processes.schema.js.map +1 -0
  123. package/dist/schemas/tidas_processes_category.schema.d.ts +3 -0
  124. package/dist/schemas/tidas_processes_category.schema.d.ts.map +1 -0
  125. package/dist/schemas/tidas_processes_category.schema.js +4480 -0
  126. package/dist/schemas/tidas_processes_category.schema.js.map +1 -0
  127. package/dist/schemas/tidas_sources.schema.d.ts +2007 -0
  128. package/dist/schemas/tidas_sources.schema.d.ts.map +1 -0
  129. package/dist/schemas/tidas_sources.schema.js +73 -0
  130. package/dist/schemas/tidas_sources.schema.js.map +1 -0
  131. package/dist/schemas/tidas_sources_category.schema.d.ts +3 -0
  132. package/dist/schemas/tidas_sources_category.schema.d.ts.map +1 -0
  133. package/dist/schemas/tidas_sources_category.schema.js +43 -0
  134. package/dist/schemas/tidas_sources_category.schema.js.map +1 -0
  135. package/dist/schemas/tidas_unitgroups.schema.d.ts +2088 -0
  136. package/dist/schemas/tidas_unitgroups.schema.d.ts.map +1 -0
  137. package/dist/schemas/tidas_unitgroups.schema.js +92 -0
  138. package/dist/schemas/tidas_unitgroups.schema.js.map +1 -0
  139. package/dist/schemas/tidas_unitgroups_category.schema.d.ts +3 -0
  140. package/dist/schemas/tidas_unitgroups_category.schema.d.ts.map +1 -0
  141. package/dist/schemas/tidas_unitgroups_category.schema.js +28 -0
  142. package/dist/schemas/tidas_unitgroups_category.schema.js.map +1 -0
  143. package/dist/types/index.d.ts +21 -0
  144. package/dist/types/index.d.ts.map +1 -0
  145. package/dist/types/index.js +6 -0
  146. package/dist/types/index.js.map +1 -0
  147. package/dist/types/tidas_contacts.d.ts +72 -0
  148. package/dist/types/tidas_contacts.d.ts.map +1 -0
  149. package/dist/types/tidas_contacts.js +8 -0
  150. package/dist/types/tidas_contacts.js.map +1 -0
  151. package/dist/types/tidas_contacts_category.d.ts +43 -0
  152. package/dist/types/tidas_contacts_category.d.ts.map +1 -0
  153. package/dist/types/tidas_contacts_category.js +8 -0
  154. package/dist/types/tidas_contacts_category.js.map +1 -0
  155. package/dist/types/tidas_data_types.d.ts +145 -0
  156. package/dist/types/tidas_data_types.d.ts.map +1 -0
  157. package/dist/types/tidas_data_types.js +8 -0
  158. package/dist/types/tidas_data_types.js.map +1 -0
  159. package/dist/types/tidas_flowproperties.d.ts +70 -0
  160. package/dist/types/tidas_flowproperties.d.ts.map +1 -0
  161. package/dist/types/tidas_flowproperties.js +8 -0
  162. package/dist/types/tidas_flowproperties.js.map +1 -0
  163. package/dist/types/tidas_flowproperties_category.d.ts +23 -0
  164. package/dist/types/tidas_flowproperties_category.d.ts.map +1 -0
  165. package/dist/types/tidas_flowproperties_category.js +8 -0
  166. package/dist/types/tidas_flowproperties_category.js.map +1 -0
  167. package/dist/types/tidas_flows.d.ts +98 -0
  168. package/dist/types/tidas_flows.d.ts.map +1 -0
  169. package/dist/types/tidas_flows.js +8 -0
  170. package/dist/types/tidas_flows.js.map +1 -0
  171. package/dist/types/tidas_flows_elementary_category.d.ts +227 -0
  172. package/dist/types/tidas_flows_elementary_category.d.ts.map +1 -0
  173. package/dist/types/tidas_flows_elementary_category.js +8 -0
  174. package/dist/types/tidas_flows_elementary_category.js.map +1 -0
  175. package/dist/types/tidas_flows_product_category.d.ts +18391 -0
  176. package/dist/types/tidas_flows_product_category.d.ts.map +1 -0
  177. package/dist/types/tidas_flows_product_category.js +8 -0
  178. package/dist/types/tidas_flows_product_category.js.map +1 -0
  179. package/dist/types/tidas_lciamethods.d.ts +218 -0
  180. package/dist/types/tidas_lciamethods.d.ts.map +1 -0
  181. package/dist/types/tidas_lciamethods.js +8 -0
  182. package/dist/types/tidas_lciamethods.js.map +1 -0
  183. package/dist/types/tidas_lciamethods_category.d.ts +215 -0
  184. package/dist/types/tidas_lciamethods_category.d.ts.map +1 -0
  185. package/dist/types/tidas_lciamethods_category.js +8 -0
  186. package/dist/types/tidas_lciamethods_category.js.map +1 -0
  187. package/dist/types/tidas_lifecyclemodels.d.ts +250 -0
  188. package/dist/types/tidas_lifecyclemodels.d.ts.map +1 -0
  189. package/dist/types/tidas_lifecyclemodels.js +8 -0
  190. package/dist/types/tidas_lifecyclemodels.js.map +1 -0
  191. package/dist/types/tidas_locations_category.d.ts +7 -0
  192. package/dist/types/tidas_locations_category.d.ts.map +1 -0
  193. package/dist/types/tidas_locations_category.js +8 -0
  194. package/dist/types/tidas_locations_category.js.map +1 -0
  195. package/dist/types/tidas_processes.d.ts +278 -0
  196. package/dist/types/tidas_processes.d.ts.map +1 -0
  197. package/dist/types/tidas_processes.js +8 -0
  198. package/dist/types/tidas_processes.js.map +1 -0
  199. package/dist/types/tidas_processes_category.d.ts +3071 -0
  200. package/dist/types/tidas_processes_category.d.ts.map +1 -0
  201. package/dist/types/tidas_processes_category.js +8 -0
  202. package/dist/types/tidas_processes_category.js.map +1 -0
  203. package/dist/types/tidas_sources.d.ts +58 -0
  204. package/dist/types/tidas_sources.d.ts.map +1 -0
  205. package/dist/types/tidas_sources.js +8 -0
  206. package/dist/types/tidas_sources.js.map +1 -0
  207. package/dist/types/tidas_sources_category.d.ts +35 -0
  208. package/dist/types/tidas_sources_category.d.ts.map +1 -0
  209. package/dist/types/tidas_sources_category.js +8 -0
  210. package/dist/types/tidas_sources_category.js.map +1 -0
  211. package/dist/types/tidas_unitgroups.d.ts +81 -0
  212. package/dist/types/tidas_unitgroups.d.ts.map +1 -0
  213. package/dist/types/tidas_unitgroups.js +8 -0
  214. package/dist/types/tidas_unitgroups.js.map +1 -0
  215. package/dist/types/tidas_unitgroups_category.d.ts +23 -0
  216. package/dist/types/tidas_unitgroups_category.d.ts.map +1 -0
  217. package/dist/types/tidas_unitgroups_category.js +8 -0
  218. package/dist/types/tidas_unitgroups_category.js.map +1 -0
  219. package/dist/utils/index.d.ts +7 -0
  220. package/dist/utils/index.d.ts.map +1 -0
  221. package/dist/utils/index.js +31 -0
  222. package/dist/utils/index.js.map +1 -0
  223. package/dist/utils/object-utils.d.ts +29 -0
  224. package/dist/utils/object-utils.d.ts.map +1 -0
  225. package/dist/utils/object-utils.js +156 -0
  226. package/dist/utils/object-utils.js.map +1 -0
  227. package/package.json +90 -0
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ /**
3
+ * TIDAS-specific factory functions using ZodProxy for true property access
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ProcessSchema = exports.FlowSchema = exports.ContactSchema = void 0;
7
+ exports.createZodContact = createZodContact;
8
+ exports.createZodFlow = createZodFlow;
9
+ exports.createZodProcess = createZodProcess;
10
+ exports.createZodSource = createZodSource;
11
+ exports.createZodFlowProperty = createZodFlowProperty;
12
+ exports.createZodUnitGroup = createZodUnitGroup;
13
+ exports.createZodLCIAMethod = createZodLCIAMethod;
14
+ exports.createZodLifeCycleModel = createZodLifeCycleModel;
15
+ exports.createZodTidasProxy = createZodTidasProxy;
16
+ const zod_proxy_1 = require("./zod-proxy");
17
+ // Import existing Zod schemas (we'll need to check what's available)
18
+ // For now, let's create basic schemas as examples
19
+ /**
20
+ * Basic Contact schema for demonstration
21
+ */
22
+ const index_1 = require("../schemas/index");
23
+ Object.defineProperty(exports, "ContactSchema", { enumerable: true, get: function () { return index_1.ContactSchema; } });
24
+ Object.defineProperty(exports, "FlowSchema", { enumerable: true, get: function () { return index_1.FlowSchema; } });
25
+ Object.defineProperty(exports, "ProcessSchema", { enumerable: true, get: function () { return index_1.ProcessSchema; } });
26
+ /**
27
+ * Create enhanced proxy with TIDAS-specific functionality
28
+ */
29
+ function createTidasProxy(schema, options = {}) {
30
+ const defaultOptions = {
31
+ enableLogging: true,
32
+ throwOnValidationError: false,
33
+ autoCreateArrays: true,
34
+ autoGenerateUUID: false,
35
+ autoGenerateTimestamp: false,
36
+ defaultLanguage: 'en',
37
+ ...options,
38
+ };
39
+ const zodProxy = (0, zod_proxy_1.createZodProxy)(schema, defaultOptions);
40
+ // Helper function to generate UUID
41
+ const generateUUID = () => {
42
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
43
+ const r = (Math.random() * 16) | 0;
44
+ const v = c === 'x' ? r : (r & 0x3) | 0x8;
45
+ return v.toString(16);
46
+ });
47
+ };
48
+ // Helper function to get current timestamp
49
+ const getCurrentTimestamp = () => {
50
+ return new Date().toISOString();
51
+ };
52
+ // Helper function to set multi-language text
53
+ const setMultiLangText = (path, text, lang = defaultOptions.defaultLanguage || 'en') => {
54
+ const multiLangValue = {
55
+ '@xml:lang': lang,
56
+ '#text': text,
57
+ };
58
+ // Access the proxy through the path and set the value
59
+ const pathParts = path.split('.');
60
+ let current = zodProxy.proxy;
61
+ for (let i = 0; i < pathParts.length - 1; i++) {
62
+ const part = pathParts[i];
63
+ if (!current[part]) {
64
+ current[part] = {};
65
+ }
66
+ current = current[part];
67
+ }
68
+ const lastPart = pathParts[pathParts.length - 1];
69
+ current[lastPart] = multiLangValue;
70
+ };
71
+ // Helper function to get multi-language text
72
+ const getMultiLangText = (path, lang = defaultOptions.defaultLanguage || 'en') => {
73
+ const pathParts = path.split('.');
74
+ let current = zodProxy.proxy;
75
+ try {
76
+ for (const part of pathParts) {
77
+ current = current[part];
78
+ if (!current)
79
+ return '';
80
+ }
81
+ if (Array.isArray(current)) {
82
+ const found = current.find((item) => item['@xml:lang'] === lang);
83
+ return found ? found['#text'] : '';
84
+ }
85
+ else if (current && typeof current === 'object') {
86
+ return current['@xml:lang'] === lang ? current['#text'] || '' : '';
87
+ }
88
+ return String(current || '');
89
+ }
90
+ catch {
91
+ return '';
92
+ }
93
+ };
94
+ // Helper function to generate UUID at path
95
+ const generateUUIDAtPath = (path) => {
96
+ const pathParts = path.split('.');
97
+ let current = zodProxy.proxy;
98
+ for (let i = 0; i < pathParts.length - 1; i++) {
99
+ const part = pathParts[i];
100
+ if (!current[part]) {
101
+ current[part] = {};
102
+ }
103
+ current = current[part];
104
+ }
105
+ const lastPart = pathParts[pathParts.length - 1];
106
+ current[lastPart] = generateUUID();
107
+ };
108
+ // Helper function to set current timestamp at path
109
+ const setCurrentTimestampAtPath = (path) => {
110
+ const pathParts = path.split('.');
111
+ let current = zodProxy.proxy;
112
+ for (let i = 0; i < pathParts.length - 1; i++) {
113
+ const part = pathParts[i];
114
+ if (!current[part]) {
115
+ current[part] = {};
116
+ }
117
+ current = current[part];
118
+ }
119
+ const lastPart = pathParts[pathParts.length - 1];
120
+ current[lastPart] = getCurrentTimestamp();
121
+ };
122
+ return {
123
+ ...zodProxy,
124
+ setMultiLangText,
125
+ getMultiLangText,
126
+ generateUUID: generateUUIDAtPath,
127
+ setCurrentTimestamp: setCurrentTimestampAtPath,
128
+ };
129
+ }
130
+ /**
131
+ * Create a Contact proxy with type-safe property access
132
+ */
133
+ function createZodContact(options = {}) {
134
+ return createTidasProxy(index_1.ContactSchema, options);
135
+ }
136
+ /**
137
+ * Create a Flow proxy with type-safe property access
138
+ */
139
+ function createZodFlow(options = {}) {
140
+ return createTidasProxy(index_1.FlowSchema, options);
141
+ }
142
+ /**
143
+ * Create a Process proxy with type-safe property access
144
+ */
145
+ function createZodProcess(options = {}) {
146
+ return createTidasProxy(index_1.ProcessSchema, options);
147
+ }
148
+ function createZodSource(options = {}) {
149
+ return createTidasProxy(index_1.SourceSchema, options);
150
+ }
151
+ function createZodFlowProperty(options = {}) {
152
+ return createTidasProxy(index_1.FlowPropertySchema, options);
153
+ }
154
+ function createZodUnitGroup(options = {}) {
155
+ return createTidasProxy(index_1.UnitGroupSchema, options);
156
+ }
157
+ function createZodLCIAMethod(options = {}) {
158
+ return createTidasProxy(index_1.LCIAMethodSchema, options);
159
+ }
160
+ function createZodLifeCycleModel(options = {}) {
161
+ return createTidasProxy(index_1.LifeCycleModelSchema, options);
162
+ }
163
+ /**
164
+ * Utility function to create a proxy from any schema
165
+ */
166
+ function createZodTidasProxy(schema, options = {}) {
167
+ return createTidasProxy(schema, options);
168
+ }
169
+ //# sourceMappingURL=zod-factories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-factories.js","sourceRoot":"","sources":["../../src/core/zod-factories.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA4cH,4CAIC;AAKD,sCAIC;AAKD,4CAIC;AAED,0CAIC;AAED,sDAIC;AAED,gDAIC;AAED,kDAIC;AAED,0DAIC;AAMD,kDAKC;AAxgBD,2CAA8D;AAE9D,qEAAqE;AACrE,kDAAkD;AAElD;;GAEG;AACH,4CAS0B;AA0fjB,8FAlgBP,qBAAa,OAkgBO;AAAE,2FAhgBtB,kBAAU,OAggBsB;AAAE,8FA/flC,qBAAa,OA+fkC;AA1MjD;;GAEG;AACH,SAAS,gBAA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AAC,CAAC;AACpD,CAAC;AAED,SAAgB,mBAAmB,CACjC,UAA6B,EAAE;IAE/B,OAAO,gBAAgB,CAAC,wBAAgB,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,uBAAuB,CACrC,UAA6B,EAAE;IAE/B,OAAO,gBAAgB,CAAC,4BAAoB,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC;AAGD;;GAEG;AACH,SAAgB,mBAAmB,CACjC,MAAS,EACT,UAA6B,EAAE;IAE/B,OAAO,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Zod Proxy implementation for true property access with Schema validation
3
+ * Based on the advanced Zod Proxy approach from docs/zod-proxy.md
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Path information for complex path parsing
8
+ */
9
+ export interface PathInfo {
10
+ segments: string[];
11
+ arrayIndices: number[];
12
+ fullPath: string;
13
+ isArrayAccess: boolean;
14
+ }
15
+ /**
16
+ * Access log entry for debugging and tracking
17
+ */
18
+ export interface AccessLogEntry {
19
+ type: 'get' | 'set' | 'push' | 'delete';
20
+ path: string;
21
+ value?: any;
22
+ timestamp: number;
23
+ }
24
+ /**
25
+ * Configuration options for ZodProxy
26
+ */
27
+ export interface ZodProxyOptions {
28
+ enableLogging?: boolean;
29
+ throwOnValidationError?: boolean;
30
+ autoCreateArrays?: boolean;
31
+ }
32
+ /**
33
+ * Result of ZodProxy validation
34
+ */
35
+ export interface ZodProxyValidationResult<T> {
36
+ success: boolean;
37
+ data?: T;
38
+ error?: z.ZodError;
39
+ }
40
+ /**
41
+ * Main ZodProxy class for creating proxies with Schema validation
42
+ */
43
+ export declare class ZodProxy<T extends z.ZodSchema> {
44
+ private schema;
45
+ private options;
46
+ private accessLog;
47
+ private values;
48
+ private arrayLengths;
49
+ constructor(schema: T, options?: ZodProxyOptions);
50
+ /**
51
+ * Log access for debugging
52
+ */
53
+ private log;
54
+ /**
55
+ * Validate value against schema at specific path
56
+ */
57
+ private validateValue;
58
+ /**
59
+ * Ensure array path has correct length
60
+ */
61
+ private ensureArrayPath;
62
+ /**
63
+ * Create the main proxy object
64
+ */
65
+ createProxy(currentPath?: string[]): any;
66
+ /**
67
+ * Build final object from all set values
68
+ */
69
+ buildObject(): any;
70
+ /**
71
+ * Validate the complete object against schema
72
+ */
73
+ validate(): ZodProxyValidationResult<z.infer<T>>;
74
+ /**
75
+ * Get access log for debugging
76
+ */
77
+ getAccessLog(): AccessLogEntry[];
78
+ /**
79
+ * Get all stored values
80
+ */
81
+ getValues(): Record<string, any>;
82
+ /**
83
+ * Get array lengths
84
+ */
85
+ getArrayLengths(): Record<string, number>;
86
+ /**
87
+ * Debug information
88
+ */
89
+ debug(): {
90
+ values: Record<string, any>;
91
+ arrayLengths: Record<string, number>;
92
+ accessLog: AccessLogEntry[];
93
+ builtObject: any;
94
+ };
95
+ }
96
+ /**
97
+ * Factory function to create a ZodProxy with convenient API
98
+ */
99
+ export declare function createZodProxy<T extends z.ZodSchema>(schema: T, options?: ZodProxyOptions): {
100
+ proxy: z.infer<T>;
101
+ getAccessLog: () => AccessLogEntry[];
102
+ getValues: () => Record<string, any>;
103
+ getArrayLengths: () => Record<string, number>;
104
+ buildObject: () => any;
105
+ validate: () => ZodProxyValidationResult<z.infer<T>>;
106
+ debug: () => any;
107
+ };
108
+ //# sourceMappingURL=zod-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-proxy.d.ts","sourceRoot":"","sources":["../../src/core/zod-proxy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;CACxB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OAEG;IACH,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIzC;;OAEG;IACH,KAAK,IAAI;QACP,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC5B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACrC,SAAS,EAAE,cAAc,EAAE,CAAC;QAC5B,WAAW,EAAE,GAAG,CAAC;KAClB;CAQF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,EAClD,MAAM,EAAE,CAAC,EACT,OAAO,GAAE,eAAoB,GAC5B;IACD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,YAAY,EAAE,MAAM,cAAc,EAAE,CAAC;IACrC,SAAS,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,eAAe,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,WAAW,EAAE,MAAM,GAAG,CAAC;IACvB,QAAQ,EAAE,MAAM,wBAAwB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,KAAK,EAAE,MAAM,GAAG,CAAC;CAClB,CAaA"}
@@ -0,0 +1,382 @@
1
+ "use strict";
2
+ /**
3
+ * Zod Proxy implementation for true property access with Schema validation
4
+ * Based on the advanced Zod Proxy approach from docs/zod-proxy.md
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ZodProxy = void 0;
8
+ exports.createZodProxy = createZodProxy;
9
+ const zod_1 = require("zod");
10
+ /**
11
+ * Parse array path like "posts[0].comments[1].text"
12
+ */
13
+ function parseArrayPath(path) {
14
+ const segments = [];
15
+ const arrayIndices = [];
16
+ let isArrayAccess = false;
17
+ // Parse path, e.g., "posts[0].comments[1].replies[2].text"
18
+ const parts = path.split(/[.[\]]/).filter((part) => part !== '');
19
+ for (let i = 0; i < parts.length; i++) {
20
+ const part = parts[i];
21
+ if (/^\d+$/.test(part)) {
22
+ // This is an array index
23
+ arrayIndices.push(parseInt(part));
24
+ isArrayAccess = true;
25
+ }
26
+ else {
27
+ // This is a property name
28
+ segments.push(part);
29
+ }
30
+ }
31
+ return {
32
+ segments,
33
+ arrayIndices,
34
+ fullPath: path,
35
+ isArrayAccess,
36
+ };
37
+ }
38
+ /**
39
+ * Get schema at a specific path within the main schema
40
+ */
41
+ function getSchemaAtPath(currentSchema, pathSegments) {
42
+ let schema = currentSchema;
43
+ for (const segment of pathSegments) {
44
+ if (schema instanceof zod_1.z.ZodObject) {
45
+ const shape = schema.shape;
46
+ if (shape[segment]) {
47
+ schema = shape[segment];
48
+ }
49
+ else {
50
+ return null;
51
+ }
52
+ }
53
+ else if (schema instanceof zod_1.z.ZodArray) {
54
+ // If it's an array, get element type
55
+ schema = schema.element;
56
+ // Continue processing remaining path after array access
57
+ continue;
58
+ }
59
+ else {
60
+ return null;
61
+ }
62
+ }
63
+ return schema;
64
+ }
65
+ /**
66
+ * Set nested property in an object using path segments
67
+ */
68
+ function setNestedProperty(obj, path, value) {
69
+ let current = obj;
70
+ for (let i = 0; i < path.length - 1; i++) {
71
+ const key = path[i];
72
+ if (!(key in current)) {
73
+ current[key] = {};
74
+ }
75
+ current = current[key];
76
+ }
77
+ current[path[path.length - 1]] = value;
78
+ }
79
+ /**
80
+ * Set nested array property using complex path like "posts[0].comments[1].text"
81
+ */
82
+ function setNestedArrayProperty(obj, fullPath, value) {
83
+ // Parse complex path like "posts[0].comments[1].text"
84
+ const parts = fullPath.split(/[.[\]]/).filter((part) => part !== '');
85
+ let current = obj;
86
+ for (let i = 0; i < parts.length - 1; i++) {
87
+ const part = parts[i];
88
+ if (/^\d+$/.test(part)) {
89
+ // Array index
90
+ const index = parseInt(part);
91
+ if (!Array.isArray(current)) {
92
+ current = [];
93
+ }
94
+ if (!current[index]) {
95
+ current[index] = {};
96
+ }
97
+ current = current[index];
98
+ }
99
+ else {
100
+ // Property name
101
+ if (!(part in current)) {
102
+ // Check if next part is array index
103
+ const nextPart = parts[i + 1];
104
+ if (nextPart && /^\d+$/.test(nextPart)) {
105
+ current[part] = [];
106
+ }
107
+ else {
108
+ current[part] = {};
109
+ }
110
+ }
111
+ current = current[part];
112
+ }
113
+ }
114
+ const lastPart = parts[parts.length - 1];
115
+ if (/^\d+$/.test(lastPart)) {
116
+ const index = parseInt(lastPart);
117
+ if (!Array.isArray(current)) {
118
+ current = [];
119
+ }
120
+ current[index] = value;
121
+ }
122
+ else {
123
+ current[lastPart] = value;
124
+ }
125
+ }
126
+ /**
127
+ * Main ZodProxy class for creating proxies with Schema validation
128
+ */
129
+ class ZodProxy {
130
+ constructor(schema, options = {}) {
131
+ this.accessLog = [];
132
+ this.values = new Map();
133
+ this.arrayLengths = new Map();
134
+ this.schema = schema;
135
+ this.options = {
136
+ enableLogging: true,
137
+ throwOnValidationError: false,
138
+ autoCreateArrays: true,
139
+ ...options,
140
+ };
141
+ }
142
+ /**
143
+ * Log access for debugging
144
+ */
145
+ log(type, path, value) {
146
+ if (this.options.enableLogging) {
147
+ this.accessLog.push({
148
+ type,
149
+ path,
150
+ value,
151
+ timestamp: Date.now(),
152
+ });
153
+ }
154
+ }
155
+ /**
156
+ * Validate value against schema at specific path
157
+ */
158
+ validateValue(path, value) {
159
+ const pathInfo = parseArrayPath(path);
160
+ try {
161
+ // Get schema for this path
162
+ const targetSchema = getSchemaAtPath(this.schema, pathInfo.segments);
163
+ if (targetSchema) {
164
+ targetSchema.parse(value);
165
+ return true;
166
+ }
167
+ return false;
168
+ }
169
+ catch (error) {
170
+ if (this.options.throwOnValidationError) {
171
+ throw error;
172
+ }
173
+ console.error(`Validation failed for ${path}:`, error);
174
+ return false;
175
+ }
176
+ }
177
+ /**
178
+ * Ensure array path has correct length
179
+ */
180
+ ensureArrayPath(path, index) {
181
+ const arrayPath = path;
182
+ const currentLength = this.arrayLengths.get(arrayPath) || 0;
183
+ if (index >= currentLength) {
184
+ this.arrayLengths.set(arrayPath, index + 1);
185
+ }
186
+ }
187
+ /**
188
+ * Create the main proxy object
189
+ */
190
+ createProxy(currentPath = []) {
191
+ return new Proxy({}, {
192
+ get: (_target, prop) => {
193
+ if (typeof prop === 'symbol') {
194
+ return undefined;
195
+ }
196
+ const newPath = [...currentPath, prop];
197
+ const pathStr = newPath.join('.');
198
+ // Handle special array properties
199
+ if (prop === 'length' && currentPath.length > 0) {
200
+ const arrayPath = currentPath.join('.');
201
+ const length = this.arrayLengths.get(arrayPath) || 0;
202
+ this.log('get', `${arrayPath}.length`, length);
203
+ return length;
204
+ }
205
+ if (prop === 'push') {
206
+ return (...items) => {
207
+ const arrayPath = currentPath.join('.');
208
+ const currentLength = this.arrayLengths.get(arrayPath) || 0;
209
+ items.forEach((item, index) => {
210
+ const itemPath = `${arrayPath}[${currentLength + index}]`;
211
+ if (this.validateValue(itemPath, item)) {
212
+ this.values.set(itemPath, item);
213
+ this.log('push', itemPath, item);
214
+ }
215
+ });
216
+ const newLength = currentLength + items.length;
217
+ this.arrayLengths.set(arrayPath, newLength);
218
+ return newLength;
219
+ };
220
+ }
221
+ if (prop === 'pop') {
222
+ return () => {
223
+ const arrayPath = currentPath.join('.');
224
+ const currentLength = this.arrayLengths.get(arrayPath) || 0;
225
+ if (currentLength > 0) {
226
+ const lastIndex = currentLength - 1;
227
+ const itemPath = `${arrayPath}[${lastIndex}]`;
228
+ const value = this.values.get(itemPath);
229
+ this.values.delete(itemPath);
230
+ this.arrayLengths.set(arrayPath, lastIndex);
231
+ this.log('delete', itemPath, value);
232
+ return value;
233
+ }
234
+ return undefined;
235
+ };
236
+ }
237
+ // Handle array index access
238
+ if (/^\d+$/.test(prop)) {
239
+ const index = parseInt(prop);
240
+ const arrayPath = currentPath.join('.');
241
+ const itemPath = `${arrayPath}[${index}]`;
242
+ this.ensureArrayPath(arrayPath, index);
243
+ this.log('get', itemPath);
244
+ if (this.values.has(itemPath)) {
245
+ const value = this.values.get(itemPath);
246
+ // If value is object, return proxy
247
+ if (typeof value === 'object' && value !== null) {
248
+ return this.createProxy([...currentPath, prop]);
249
+ }
250
+ return value;
251
+ }
252
+ return this.createProxy([...currentPath, prop]);
253
+ }
254
+ this.log('get', pathStr);
255
+ if (this.values.has(pathStr)) {
256
+ return this.values.get(pathStr);
257
+ }
258
+ return this.createProxy(newPath);
259
+ },
260
+ set: (_target, prop, value) => {
261
+ if (typeof prop !== 'string') {
262
+ return false;
263
+ }
264
+ const newPath = [...currentPath, prop];
265
+ const pathStr = newPath.join('.');
266
+ // Handle array index assignment
267
+ if (/^\d+$/.test(prop)) {
268
+ const index = parseInt(prop);
269
+ const arrayPath = currentPath.join('.');
270
+ const itemPath = `${arrayPath}[${index}]`;
271
+ if (this.validateValue(itemPath, value)) {
272
+ this.values.set(itemPath, value);
273
+ this.ensureArrayPath(arrayPath, index);
274
+ this.log('set', itemPath, value);
275
+ return true;
276
+ }
277
+ return false;
278
+ }
279
+ if (this.validateValue(pathStr, value)) {
280
+ this.values.set(pathStr, value);
281
+ this.log('set', pathStr, value);
282
+ return true;
283
+ }
284
+ return false;
285
+ },
286
+ has: (_target, prop) => {
287
+ const newPath = [...currentPath, prop];
288
+ const pathStr = newPath.join('.');
289
+ return this.values.has(pathStr);
290
+ },
291
+ deleteProperty: (_target, prop) => {
292
+ const newPath = [...currentPath, prop];
293
+ const pathStr = newPath.join('.');
294
+ const existed = this.values.has(pathStr);
295
+ this.values.delete(pathStr);
296
+ if (existed) {
297
+ this.log('delete', pathStr);
298
+ }
299
+ return true;
300
+ },
301
+ });
302
+ }
303
+ /**
304
+ * Build final object from all set values
305
+ */
306
+ buildObject() {
307
+ const result = {};
308
+ // Process all values
309
+ for (const [path, value] of this.values.entries()) {
310
+ const pathInfo = parseArrayPath(path);
311
+ if (!pathInfo.isArrayAccess) {
312
+ // Simple property path
313
+ setNestedProperty(result, pathInfo.segments, value);
314
+ }
315
+ else {
316
+ // Array path
317
+ setNestedArrayProperty(result, path, value);
318
+ }
319
+ }
320
+ return result;
321
+ }
322
+ /**
323
+ * Validate the complete object against schema
324
+ */
325
+ validate() {
326
+ try {
327
+ const obj = this.buildObject();
328
+ const result = this.schema.parse(obj);
329
+ return { success: true, data: result };
330
+ }
331
+ catch (error) {
332
+ return { success: false, error: error };
333
+ }
334
+ }
335
+ /**
336
+ * Get access log for debugging
337
+ */
338
+ getAccessLog() {
339
+ return [...this.accessLog];
340
+ }
341
+ /**
342
+ * Get all stored values
343
+ */
344
+ getValues() {
345
+ return Object.fromEntries(this.values.entries());
346
+ }
347
+ /**
348
+ * Get array lengths
349
+ */
350
+ getArrayLengths() {
351
+ return Object.fromEntries(this.arrayLengths.entries());
352
+ }
353
+ /**
354
+ * Debug information
355
+ */
356
+ debug() {
357
+ return {
358
+ values: this.getValues(),
359
+ arrayLengths: this.getArrayLengths(),
360
+ accessLog: this.accessLog.slice(-10), // Last 10 entries
361
+ builtObject: this.buildObject(),
362
+ };
363
+ }
364
+ }
365
+ exports.ZodProxy = ZodProxy;
366
+ /**
367
+ * Factory function to create a ZodProxy with convenient API
368
+ */
369
+ function createZodProxy(schema, options = {}) {
370
+ const zodProxy = new ZodProxy(schema, options);
371
+ const proxy = zodProxy.createProxy();
372
+ return {
373
+ proxy,
374
+ getAccessLog: () => zodProxy.getAccessLog(),
375
+ getValues: () => zodProxy.getValues(),
376
+ getArrayLengths: () => zodProxy.getArrayLengths(),
377
+ buildObject: () => zodProxy.buildObject(),
378
+ validate: () => zodProxy.validate(),
379
+ debug: () => zodProxy.debug(),
380
+ };
381
+ }
382
+ //# sourceMappingURL=zod-proxy.js.map