persian-data-grid 0.5.0 → 0.7.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 (282) hide show
  1. package/OFL.txt +93 -0
  2. package/README.md +179 -22
  3. package/dist/ERPTableGroupRow-E5Q6FYDS.js +125 -0
  4. package/dist/ERPTableGroupRow-E5Q6FYDS.js.map +1 -0
  5. package/dist/ERPTableGroupRow-F2IPDYL5.cjs +131 -0
  6. package/dist/ERPTableGroupRow-F2IPDYL5.cjs.map +1 -0
  7. package/dist/GridPlugin-Bewn0X51.d.ts +57 -0
  8. package/dist/GridPlugin-DewWufGZ.d.cts +57 -0
  9. package/dist/GridPresenceService-GEH6535Q.js +3 -0
  10. package/dist/GridPresenceService-GEH6535Q.js.map +1 -0
  11. package/dist/GridPresenceService-RDN5FXHQ.cjs +12 -0
  12. package/dist/GridPresenceService-RDN5FXHQ.cjs.map +1 -0
  13. package/dist/GridSession-CeIfVFck.d.ts +2625 -0
  14. package/dist/GridSession-CmQn2RnL.d.cts +2625 -0
  15. package/dist/GridSyncService-3JQLEY65.cjs +12 -0
  16. package/dist/GridSyncService-3JQLEY65.cjs.map +1 -0
  17. package/dist/GridSyncService-GECXGEKL.js +3 -0
  18. package/dist/GridSyncService-GECXGEKL.js.map +1 -0
  19. package/dist/PdfRenderer-B9FJaCo_.d.cts +22 -0
  20. package/dist/PdfRenderer-bN7ca_Aj.d.ts +22 -0
  21. package/dist/RemoteApi-CCQxiSf1.d.cts +28 -0
  22. package/dist/RemoteApi-CCQxiSf1.d.ts +28 -0
  23. package/dist/SelectImpl-NM4O4IGW.js +447 -0
  24. package/dist/SelectImpl-NM4O4IGW.js.map +1 -0
  25. package/dist/SelectImpl-W2EI4T7O.cjs +453 -0
  26. package/dist/SelectImpl-W2EI4T7O.cjs.map +1 -0
  27. package/dist/UITableController-C71LXBiX.d.ts +678 -0
  28. package/dist/UITableController-CIwnHIw8.d.cts +678 -0
  29. package/dist/VazirmatnPdfRenderer-CpCqA-Wh.d.cts +96 -0
  30. package/dist/VazirmatnPdfRenderer-D46smncn.d.ts +96 -0
  31. package/dist/adapters/arian-erp.cjs +89 -0
  32. package/dist/adapters/arian-erp.cjs.map +1 -0
  33. package/dist/adapters/arian-erp.d.cts +62 -0
  34. package/dist/adapters/arian-erp.d.ts +62 -0
  35. package/dist/adapters/arian-erp.js +79 -0
  36. package/dist/adapters/arian-erp.js.map +1 -0
  37. package/dist/appendAtEnd-RHIQRG2W.cjs +35 -0
  38. package/dist/appendAtEnd-RHIQRG2W.cjs.map +1 -0
  39. package/dist/appendAtEnd-TJEABLGD.js +33 -0
  40. package/dist/appendAtEnd-TJEABLGD.js.map +1 -0
  41. package/dist/applyImportedRows-C2fWYoPy.d.cts +135 -0
  42. package/dist/applyImportedRows-Cqh_N_0k.d.ts +135 -0
  43. package/dist/applyRowVisibilityHandler-Q64ZFC7A.cjs +86 -0
  44. package/dist/applyRowVisibilityHandler-Q64ZFC7A.cjs.map +1 -0
  45. package/dist/applyRowVisibilityHandler-ZLZXQEGY.js +84 -0
  46. package/dist/applyRowVisibilityHandler-ZLZXQEGY.js.map +1 -0
  47. package/dist/broadcastChannelTransport-FHUMV76O.cjs +12 -0
  48. package/dist/broadcastChannelTransport-FHUMV76O.cjs.map +1 -0
  49. package/dist/broadcastChannelTransport-MIH53VNZ.js +3 -0
  50. package/dist/broadcastChannelTransport-MIH53VNZ.js.map +1 -0
  51. package/dist/callbackRemoteApi-BYLjmSI6.d.ts +51 -0
  52. package/dist/callbackRemoteApi-Cv26MmSD.d.cts +51 -0
  53. package/dist/cellRenderContext-BaNh4qn_.d.ts +42 -0
  54. package/dist/cellRenderContext-DvngkptV.d.cts +42 -0
  55. package/dist/chunk-27ALJSZP.js +12187 -0
  56. package/dist/chunk-27ALJSZP.js.map +1 -0
  57. package/dist/chunk-3HP3HQCW.cjs +688 -0
  58. package/dist/chunk-3HP3HQCW.cjs.map +1 -0
  59. package/dist/chunk-3Y3KKGEC.js +3 -0
  60. package/dist/chunk-3Y3KKGEC.js.map +1 -0
  61. package/dist/chunk-52LFOPXD.cjs +588 -0
  62. package/dist/chunk-52LFOPXD.cjs.map +1 -0
  63. package/dist/chunk-5ALMNLUR.cjs +1408 -0
  64. package/dist/chunk-5ALMNLUR.cjs.map +1 -0
  65. package/dist/chunk-5HKVMPBD.js +937 -0
  66. package/dist/chunk-5HKVMPBD.js.map +1 -0
  67. package/dist/chunk-72IVAOTK.cjs +38 -0
  68. package/dist/chunk-72IVAOTK.cjs.map +1 -0
  69. package/dist/chunk-77UXAJII.js +112 -0
  70. package/dist/chunk-77UXAJII.js.map +1 -0
  71. package/dist/chunk-7GWV5HGO.js +36 -0
  72. package/dist/chunk-7GWV5HGO.js.map +1 -0
  73. package/dist/chunk-7T6AWRPU.js +581 -0
  74. package/dist/chunk-7T6AWRPU.js.map +1 -0
  75. package/dist/chunk-AU3RDJYQ.js +243 -0
  76. package/dist/chunk-AU3RDJYQ.js.map +1 -0
  77. package/dist/chunk-CILNIWYW.cjs +100 -0
  78. package/dist/chunk-CILNIWYW.cjs.map +1 -0
  79. package/dist/chunk-CMQ4VLCW.cjs +840 -0
  80. package/dist/chunk-CMQ4VLCW.cjs.map +1 -0
  81. package/dist/chunk-DFFP7SJ6.cjs +257 -0
  82. package/dist/chunk-DFFP7SJ6.cjs.map +1 -0
  83. package/dist/chunk-E2J533UH.cjs +53 -0
  84. package/dist/chunk-E2J533UH.cjs.map +1 -0
  85. package/dist/chunk-EBV6HGZB.cjs +33 -0
  86. package/dist/chunk-EBV6HGZB.cjs.map +1 -0
  87. package/dist/chunk-F4PYOYHR.js +112 -0
  88. package/dist/chunk-F4PYOYHR.js.map +1 -0
  89. package/dist/chunk-F6EMC75A.cjs +34 -0
  90. package/dist/chunk-F6EMC75A.cjs.map +1 -0
  91. package/dist/chunk-GKE33FOJ.js +32 -0
  92. package/dist/chunk-GKE33FOJ.js.map +1 -0
  93. package/dist/chunk-GQEDLUMB.js +168 -0
  94. package/dist/chunk-GQEDLUMB.js.map +1 -0
  95. package/dist/chunk-HLOHWFOA.js +645 -0
  96. package/dist/chunk-HLOHWFOA.js.map +1 -0
  97. package/dist/chunk-IMPCRWYP.cjs +251 -0
  98. package/dist/chunk-IMPCRWYP.cjs.map +1 -0
  99. package/dist/chunk-IPPIXOVQ.js +317 -0
  100. package/dist/chunk-IPPIXOVQ.js.map +1 -0
  101. package/dist/chunk-J4XJ4UBC.js +1404 -0
  102. package/dist/chunk-J4XJ4UBC.js.map +1 -0
  103. package/dist/chunk-J7CPPFXT.cjs +89 -0
  104. package/dist/chunk-J7CPPFXT.cjs.map +1 -0
  105. package/dist/chunk-JOICD47Q.cjs +41 -0
  106. package/dist/chunk-JOICD47Q.cjs.map +1 -0
  107. package/dist/chunk-KCNTKYUY.js +206 -0
  108. package/dist/chunk-KCNTKYUY.js.map +1 -0
  109. package/dist/chunk-KHMG6EI2.js +13 -0
  110. package/dist/chunk-KHMG6EI2.js.map +1 -0
  111. package/dist/chunk-KMRURD5J.cjs +15 -0
  112. package/dist/chunk-KMRURD5J.cjs.map +1 -0
  113. package/dist/chunk-KRJG3KMP.cjs +174 -0
  114. package/dist/chunk-KRJG3KMP.cjs.map +1 -0
  115. package/dist/chunk-LY27YAXE.cjs +208 -0
  116. package/dist/chunk-LY27YAXE.cjs.map +1 -0
  117. package/dist/chunk-MT3KLB2Q.cjs +944 -0
  118. package/dist/chunk-MT3KLB2Q.cjs.map +1 -0
  119. package/dist/chunk-MUQQKPWR.js +84 -0
  120. package/dist/chunk-MUQQKPWR.js.map +1 -0
  121. package/dist/chunk-N7SJTINL.cjs +4 -0
  122. package/dist/chunk-N7SJTINL.cjs.map +1 -0
  123. package/dist/chunk-NB5GCGHL.js +833 -0
  124. package/dist/chunk-NB5GCGHL.js.map +1 -0
  125. package/dist/chunk-NQUVAJQA.js +298 -0
  126. package/dist/chunk-NQUVAJQA.js.map +1 -0
  127. package/dist/chunk-NTV2UUAJ.cjs +149 -0
  128. package/dist/chunk-NTV2UUAJ.cjs.map +1 -0
  129. package/dist/chunk-PJQWHF6T.js +31 -0
  130. package/dist/chunk-PJQWHF6T.js.map +1 -0
  131. package/dist/chunk-PQY54EL5.js +248 -0
  132. package/dist/chunk-PQY54EL5.js.map +1 -0
  133. package/dist/chunk-Q7TBBUTX.cjs +110 -0
  134. package/dist/chunk-Q7TBBUTX.cjs.map +1 -0
  135. package/dist/chunk-QZN7R2WP.cjs +114 -0
  136. package/dist/chunk-QZN7R2WP.cjs.map +1 -0
  137. package/dist/chunk-RKVSJU46.js +35 -0
  138. package/dist/chunk-RKVSJU46.js.map +1 -0
  139. package/dist/chunk-SVO62ZV2.js +50 -0
  140. package/dist/chunk-SVO62ZV2.js.map +1 -0
  141. package/dist/chunk-SX4VQXAA.cjs +114 -0
  142. package/dist/chunk-SX4VQXAA.cjs.map +1 -0
  143. package/dist/chunk-SZ7BLAY3.js +92 -0
  144. package/dist/chunk-SZ7BLAY3.js.map +1 -0
  145. package/dist/chunk-TN4MG6FY.js +112 -0
  146. package/dist/chunk-TN4MG6FY.js.map +1 -0
  147. package/dist/chunk-UC7PHDM6.cjs +331 -0
  148. package/dist/chunk-UC7PHDM6.cjs.map +1 -0
  149. package/dist/chunk-UXVLYUUW.js +108 -0
  150. package/dist/chunk-UXVLYUUW.js.map +1 -0
  151. package/dist/chunk-VBAZ77Q4.js +932 -0
  152. package/dist/chunk-VBAZ77Q4.js.map +1 -0
  153. package/dist/chunk-VSAFQTW5.cjs +319 -0
  154. package/dist/chunk-VSAFQTW5.cjs.map +1 -0
  155. package/dist/chunk-VYJQ2HTA.cjs +936 -0
  156. package/dist/chunk-VYJQ2HTA.cjs.map +1 -0
  157. package/dist/chunk-W5256BJ4.js +56 -0
  158. package/dist/chunk-W5256BJ4.js.map +1 -0
  159. package/dist/chunk-WTHTVKVI.cjs +12299 -0
  160. package/dist/chunk-WTHTVKVI.cjs.map +1 -0
  161. package/dist/chunk-WUMOSOEK.cjs +62 -0
  162. package/dist/chunk-WUMOSOEK.cjs.map +1 -0
  163. package/dist/chunk-XLRE2J25.js +140 -0
  164. package/dist/chunk-XLRE2J25.js.map +1 -0
  165. package/dist/chunk-Z4QPZ3Z3.cjs +114 -0
  166. package/dist/chunk-Z4QPZ3Z3.cjs.map +1 -0
  167. package/dist/createEngineGridQuery-BBkud5oE.d.ts +939 -0
  168. package/dist/createEngineGridQuery-D-fgO_jg.d.cts +939 -0
  169. package/dist/date-picker-jalali.cjs +263 -0
  170. package/dist/date-picker-jalali.cjs.map +1 -0
  171. package/dist/date-picker-jalali.d.cts +62 -0
  172. package/dist/date-picker-jalali.d.ts +62 -0
  173. package/dist/date-picker-jalali.js +256 -0
  174. package/dist/date-picker-jalali.js.map +1 -0
  175. package/dist/finance.cjs +205 -0
  176. package/dist/finance.cjs.map +1 -0
  177. package/dist/finance.d.cts +90 -0
  178. package/dist/finance.d.ts +90 -0
  179. package/dist/finance.js +157 -0
  180. package/dist/finance.js.map +1 -0
  181. package/dist/foldedColumn-IHDT4ARZ.cjs +66 -0
  182. package/dist/foldedColumn-IHDT4ARZ.cjs.map +1 -0
  183. package/dist/foldedColumn-TFURUKFG.js +64 -0
  184. package/dist/foldedColumn-TFURUKFG.js.map +1 -0
  185. package/dist/headless.cjs +729 -0
  186. package/dist/headless.cjs.map +1 -0
  187. package/dist/headless.d.cts +508 -0
  188. package/dist/headless.d.ts +508 -0
  189. package/dist/headless.js +226 -0
  190. package/dist/headless.js.map +1 -0
  191. package/dist/index-DN8M8Jkq.d.cts +14 -0
  192. package/dist/index-DmzL-F_o.d.ts +14 -0
  193. package/dist/index.cjs +8060 -11409
  194. package/dist/index.cjs.map +1 -1
  195. package/dist/index.d.cts +457 -2305
  196. package/dist/index.d.ts +457 -2305
  197. package/dist/index.js +7302 -11084
  198. package/dist/index.js.map +1 -1
  199. package/dist/locales/ar.cjs +12 -0
  200. package/dist/locales/ar.cjs.map +1 -0
  201. package/dist/locales/ar.d.cts +6 -0
  202. package/dist/locales/ar.d.ts +6 -0
  203. package/dist/locales/ar.js +3 -0
  204. package/dist/locales/ar.js.map +1 -0
  205. package/dist/locales/en.cjs +12 -0
  206. package/dist/locales/en.cjs.map +1 -0
  207. package/dist/locales/en.d.cts +6 -0
  208. package/dist/locales/en.d.ts +6 -0
  209. package/dist/locales/en.js +3 -0
  210. package/dist/locales/en.js.map +1 -0
  211. package/dist/locales/fa.cjs +12 -0
  212. package/dist/locales/fa.cjs.map +1 -0
  213. package/dist/locales/fa.d.cts +6 -0
  214. package/dist/locales/fa.d.ts +6 -0
  215. package/dist/locales/fa.js +3 -0
  216. package/dist/locales/fa.js.map +1 -0
  217. package/dist/locales/index.cjs +51 -0
  218. package/dist/locales/index.cjs.map +1 -0
  219. package/dist/locales/index.d.cts +5 -0
  220. package/dist/locales/index.d.ts +5 -0
  221. package/dist/locales/index.js +6 -0
  222. package/dist/locales/index.js.map +1 -0
  223. package/dist/memoryRecords-AWDKUJ2F.cjs +50 -0
  224. package/dist/memoryRecords-AWDKUJ2F.cjs.map +1 -0
  225. package/dist/memoryRecords-OJTGXLRH.js +47 -0
  226. package/dist/memoryRecords-OJTGXLRH.js.map +1 -0
  227. package/dist/pagedFooterTotals-DXCGDO6F.cjs +27 -0
  228. package/dist/pagedFooterTotals-DXCGDO6F.cjs.map +1 -0
  229. package/dist/pagedFooterTotals-ORWKUNE7.js +25 -0
  230. package/dist/pagedFooterTotals-ORWKUNE7.js.map +1 -0
  231. package/dist/pagedKit-MFGAJFSK.cjs +134 -0
  232. package/dist/pagedKit-MFGAJFSK.cjs.map +1 -0
  233. package/dist/pagedKit-WYWY4LRV.js +127 -0
  234. package/dist/pagedKit-WYWY4LRV.js.map +1 -0
  235. package/dist/pagedSearch-HCPJW7VM.js +38 -0
  236. package/dist/pagedSearch-HCPJW7VM.js.map +1 -0
  237. package/dist/pagedSearch-U3WCG4GN.cjs +42 -0
  238. package/dist/pagedSearch-U3WCG4GN.cjs.map +1 -0
  239. package/dist/plugins/csv.cjs +124 -0
  240. package/dist/plugins/csv.cjs.map +1 -0
  241. package/dist/plugins/csv.d.cts +44 -0
  242. package/dist/plugins/csv.d.ts +44 -0
  243. package/dist/plugins/csv.js +120 -0
  244. package/dist/plugins/csv.js.map +1 -0
  245. package/dist/plugins/excel.cjs +52 -0
  246. package/dist/plugins/excel.cjs.map +1 -0
  247. package/dist/plugins/excel.d.cts +14 -0
  248. package/dist/plugins/excel.d.ts +14 -0
  249. package/dist/plugins/excel.js +7 -0
  250. package/dist/plugins/excel.js.map +1 -0
  251. package/dist/plugins/pdf/fonts/vazirmatn.cjs +50 -0
  252. package/dist/plugins/pdf/fonts/vazirmatn.cjs.map +1 -0
  253. package/dist/plugins/pdf/fonts/vazirmatn.d.cts +24 -0
  254. package/dist/plugins/pdf/fonts/vazirmatn.d.ts +24 -0
  255. package/dist/plugins/pdf/fonts/vazirmatn.js +39 -0
  256. package/dist/plugins/pdf/fonts/vazirmatn.js.map +1 -0
  257. package/dist/plugins/pdf.cjs +24 -0
  258. package/dist/plugins/pdf.cjs.map +1 -0
  259. package/dist/plugins/pdf.d.cts +21 -0
  260. package/dist/plugins/pdf.d.ts +21 -0
  261. package/dist/plugins/pdf.js +7 -0
  262. package/dist/plugins/pdf.js.map +1 -0
  263. package/dist/presence.cjs +56 -0
  264. package/dist/presence.cjs.map +1 -0
  265. package/dist/presence.d.cts +17 -0
  266. package/dist/presence.d.ts +17 -0
  267. package/dist/presence.js +54 -0
  268. package/dist/presence.js.map +1 -0
  269. package/dist/rebuildRowVisibility-66EAZ356.cjs +21 -0
  270. package/dist/rebuildRowVisibility-66EAZ356.cjs.map +1 -0
  271. package/dist/rebuildRowVisibility-6TYM5BP2.js +19 -0
  272. package/dist/rebuildRowVisibility-6TYM5BP2.js.map +1 -0
  273. package/dist/styles.css +1440 -0
  274. package/dist/sync.cjs +148 -0
  275. package/dist/sync.cjs.map +1 -0
  276. package/dist/sync.d.cts +17 -0
  277. package/dist/sync.d.ts +17 -0
  278. package/dist/sync.js +146 -0
  279. package/dist/sync.js.map +1 -0
  280. package/dist/types-D__47BKv.d.cts +23 -0
  281. package/dist/types-D__47BKv.d.ts +23 -0
  282. package/package.json +185 -29
@@ -0,0 +1,588 @@
1
+ 'use strict';
2
+
3
+ var chunkKMRURD5J_cjs = require('./chunk-KMRURD5J.cjs');
4
+ var chunkNTV2UUAJ_cjs = require('./chunk-NTV2UUAJ.cjs');
5
+
6
+ // application/handlers/cellCommandsHandler.ts
7
+ function logError(audit, error, context) {
8
+ if (error instanceof chunkKMRURD5J_cjs.DomainError) {
9
+ audit.log({
10
+ type: error.code,
11
+ message: error.message,
12
+ payload: { details: error.details, context }
13
+ });
14
+ } else if (error instanceof Error) {
15
+ audit.log({
16
+ type: "INVARIANT_VIOLATION",
17
+ message: error.message,
18
+ payload: { stack: error.stack, context }
19
+ });
20
+ } else {
21
+ audit.log({
22
+ type: "INVARIANT_VIOLATION",
23
+ message: "Unexpected error",
24
+ payload: { error, context }
25
+ });
26
+ }
27
+ }
28
+ async function applyRemoteVisibilityRules(dynamic, input, audit) {
29
+ const {
30
+ table,
31
+ rowId,
32
+ changedColumnId,
33
+ newValue,
34
+ clearDependents = true
35
+ } = input;
36
+ const meta = dynamic?.columnMeta;
37
+ if (!meta) return true;
38
+ const colKey = `${table.getActiveCollectionName() ?? "default"}_${changedColumnId.value}`;
39
+ const changedMeta = meta.get(colKey) ?? meta.get(changedColumnId.value);
40
+ const resolveOn = changedMeta?.resolveOn;
41
+ if (!resolveOn) return true;
42
+ if (resolveOn.fieldName !== changedColumnId.value) return true;
43
+ const row = table.getRows().find((r) => r.id.value === rowId.value);
44
+ if (!row) return true;
45
+ const rowValues = {};
46
+ for (const [colId, cell] of row.getCells().entries()) {
47
+ rowValues[colId] = cell.getValue();
48
+ }
49
+ if (newValue == null || newValue === "") return true;
50
+ const params = typeof resolveOn.buildParams === "function" ? resolveOn.buildParams(rowValues) : { value: newValue };
51
+ let response;
52
+ let failed = false;
53
+ try {
54
+ response = await dynamic.remoteApi.request({
55
+ endpoint: resolveOn.endpoint,
56
+ params,
57
+ method: "POST"
58
+ });
59
+ } catch (error) {
60
+ failed = true;
61
+ if (audit) logError(audit, error, `resolveOn[${resolveOn.endpoint}]`);
62
+ }
63
+ if (!failed) resolveOn.getResponse?.(response, row);
64
+ const flags = failed ? {} : resolveOn.mapFlags?.(response) ?? {};
65
+ const toShow = [];
66
+ const visibilityCondition = {};
67
+ const activeCollection = table.getActiveCollectionName() ?? "default";
68
+ meta.forEach((colCfg) => {
69
+ if ((colCfg.fieldCollection ?? "default") !== activeCollection) return;
70
+ const v = colCfg.visibility;
71
+ if (!failed && v?.kind === "whenRemoteFlag" && v.sourceFieldName === changedColumnId.value) {
72
+ const colId = new chunkNTV2UUAJ_cjs.ColumnId(colCfg.fieldName);
73
+ const schema = table.getColumnSchema(colId);
74
+ const flagValue = flags[v.flag] ?? false;
75
+ visibilityCondition[colCfg.fieldName] = flagValue;
76
+ if (flagValue && schema) {
77
+ toShow.push({ ...schema, hidden: false });
78
+ }
79
+ }
80
+ const dependency = colCfg.dynamicSource?.dependsOn;
81
+ if (clearDependents && dependency && dependency.includes(changedColumnId.value) && !Object.hasOwn(visibilityCondition, colCfg.fieldName) && colCfg.visibility?.kind !== "whenTableType" && colCfg.visibility?.kind !== "whenCollection") {
82
+ const cell = row.getCell(colCfg.fieldName);
83
+ cell?.changeValue(null);
84
+ cell?.changeDisplay(null);
85
+ }
86
+ });
87
+ if (toShow.length > 0) {
88
+ table.addColumns(toShow);
89
+ }
90
+ if (!failed) row.setVisibilityCondition(visibilityCondition);
91
+ return !failed;
92
+ }
93
+ var ChangeCellValueHandler = class {
94
+ constructor(repo, audit, permissionPolicy, dynamic) {
95
+ this.repo = repo;
96
+ this.audit = audit;
97
+ this.permissionPolicy = permissionPolicy;
98
+ this.dynamic = dynamic;
99
+ }
100
+ async execute(command, actor) {
101
+ const table = await this.repo.getById(command.store, command.tableKey);
102
+ try {
103
+ const rowId = new chunkNTV2UUAJ_cjs.RowId(command.rowId);
104
+ const columnId = new chunkNTV2UUAJ_cjs.ColumnId(command.columnId);
105
+ const schema = table.getColumnSchema(columnId);
106
+ if (!schema) {
107
+ throw new chunkKMRURD5J_cjs.DomainError("COLUMN_NOT_FOUND", "Column does not exist", {
108
+ columnId: columnId.value
109
+ });
110
+ }
111
+ if (schema.editable === false) {
112
+ throw new chunkKMRURD5J_cjs.DomainError("NOT_EDITABLE", "Cell is not editable", {
113
+ rowId: rowId.value,
114
+ columnId: columnId.value
115
+ });
116
+ }
117
+ if (!this.permissionPolicy.canChangeCell({
118
+ actor,
119
+ rowId: command.rowId,
120
+ columnId: command.columnId
121
+ })) {
122
+ throw new chunkKMRURD5J_cjs.DomainError(
123
+ "FORBIDDEN",
124
+ "Actor is not allowed to change this cell",
125
+ { actor, rowId: rowId.value, columnId: columnId.value }
126
+ );
127
+ }
128
+ const validated = this.validateCellValue(schema.fieldType, command.newValue);
129
+ const domainEvent = table.changeCell(rowId, columnId, validated.value);
130
+ if (!domainEvent) {
131
+ throw new chunkKMRURD5J_cjs.DomainError(
132
+ "CELL_NOT_FOUND",
133
+ "Cell not found or value not changed",
134
+ { rowId: rowId.value, columnId: columnId.value }
135
+ );
136
+ }
137
+ if (this.dynamic) {
138
+ await this.applyComputedColumns({
139
+ table,
140
+ rowId,
141
+ changedColumnId: columnId,
142
+ remoteApi: this.dynamic.remoteApi
143
+ });
144
+ await this.applyRemoteVisibilityRules({
145
+ table,
146
+ rowId,
147
+ changedColumnId: columnId,
148
+ newValue: command.newValue
149
+ });
150
+ this.applyDynamicProjection({
151
+ table,
152
+ rowId,
153
+ changedColumnId: columnId,
154
+ validatedValue: command.newValue
155
+ });
156
+ }
157
+ const state = table.getRows().find((r) => r.id.value === rowId.value)?.getCells().get("RowState")?.getValue();
158
+ if (state === "None" /* Unchanged */) {
159
+ table.changeCell(rowId, new chunkNTV2UUAJ_cjs.ColumnId("RowState"), "Update" /* Modified */);
160
+ table.changeDisplay(rowId, new chunkNTV2UUAJ_cjs.ColumnId("RowState"), "Update" /* Modified */);
161
+ }
162
+ await this.repo.save(command.store, table);
163
+ const out = {
164
+ type: "CELL_CHANGED",
165
+ tableId: command.tableKey,
166
+ rowId: domainEvent.rowId.value,
167
+ columnId: domainEvent.columnId.value,
168
+ newValue: domainEvent.newValue,
169
+ previousValue: domainEvent.previousValue
170
+ };
171
+ this.audit.log({ type: "CELL_CHANGED", message: out.type, payload: out });
172
+ return [out];
173
+ } catch (e) {
174
+ logError(this.audit, e, `ChangeCellValueHandler[${command.tableKey}:${command.rowId}:${command.columnId}]`);
175
+ return [];
176
+ }
177
+ }
178
+ /* ── helpers ─────────────────────────────────────────────────────── */
179
+ applyRemoteVisibilityRules(input) {
180
+ return applyRemoteVisibilityRules(this.dynamic, input, this.audit);
181
+ }
182
+ async applyComputedColumns(input) {
183
+ const { table, rowId, changedColumnId, remoteApi } = input;
184
+ const meta = this.dynamic.columnMeta;
185
+ const computedColumns = Array.from(meta.values()).filter(
186
+ (c) => c.computed != null
187
+ );
188
+ if (computedColumns.length === 0) return;
189
+ const row = table.getRows().find((r) => r.id.value === rowId.value);
190
+ if (!row) return;
191
+ const rowValues = {};
192
+ for (const [colId, cell] of row.getCells().entries()) {
193
+ rowValues[colId] = cell.getValue();
194
+ }
195
+ const dependents = /* @__PURE__ */ new Map();
196
+ for (const col of computedColumns) {
197
+ for (const dep of col.computed.dependsOn ?? []) {
198
+ if (!dependents.has(dep)) dependents.set(dep, []);
199
+ dependents.get(dep).push(col);
200
+ }
201
+ }
202
+ const queue = [changedColumnId.value];
203
+ const visited = /* @__PURE__ */ new Set();
204
+ let safetyCounter = 0;
205
+ const MAX = computedColumns.length + 1;
206
+ while (queue.length > 0) {
207
+ if (safetyCounter++ > MAX) {
208
+ throw new Error("Computed cycle detected");
209
+ }
210
+ const source = queue.shift();
211
+ const targets = dependents.get(source) ?? [];
212
+ for (const colCfg of targets) {
213
+ const targetField = colCfg.fieldName;
214
+ const targetColId = new chunkNTV2UUAJ_cjs.ColumnId(targetField);
215
+ const schema = table.getColumnSchema(targetColId);
216
+ if (!schema || !colCfg.computed) continue;
217
+ let newValue;
218
+ try {
219
+ const rawValue = colCfg.computed.compute(rowValues, remoteApi);
220
+ newValue = rawValue instanceof Promise ? await rawValue : rawValue;
221
+ } catch (error) {
222
+ logError(this.audit, error, `computed[${targetField}]`);
223
+ continue;
224
+ }
225
+ const validated = this.validateCellValue(schema.fieldType, newValue);
226
+ if (validated.value instanceof Promise) {
227
+ throw new Error(
228
+ `Computed column "${targetField}" returned a Promise after validation`
229
+ );
230
+ }
231
+ const prev = rowValues[targetField];
232
+ if (Object.is(prev, validated.value)) continue;
233
+ table.changeCell(rowId, targetColId, validated.value);
234
+ if (schema.displayFormat) {
235
+ const validatedDisplay = this.validateCellValue(
236
+ schema.fieldType,
237
+ schema.displayFormat(newValue)
238
+ );
239
+ table.changeDisplay(rowId, targetColId, validatedDisplay.value);
240
+ } else {
241
+ table.changeDisplay(rowId, targetColId, validated.value);
242
+ }
243
+ rowValues[targetField] = validated.value;
244
+ queue.push(targetField);
245
+ visited.add(targetField);
246
+ }
247
+ }
248
+ }
249
+ validateCellValue(type, value) {
250
+ switch (type) {
251
+ case "text":
252
+ case "textArea":
253
+ case "description":
254
+ case "date":
255
+ return typeof value === "string" ? { ok: true, value } : { ok: false, error: { message: "Expected string", details: { value } }, value };
256
+ case "static":
257
+ return { ok: true, value };
258
+ case "checkbox":
259
+ return typeof value === "boolean" ? { ok: true, value } : { ok: false, error: { message: "Expected boolean", details: { value } }, value };
260
+ case "number":
261
+ case "price":
262
+ case "select":
263
+ case "selectOption": {
264
+ if (value === "" || value === void 0) {
265
+ return { ok: true, value };
266
+ }
267
+ const n = typeof value === "number" ? value : Number(value);
268
+ return Number.isFinite(n) ? { ok: true, value: n } : { ok: false, error: { message: "Expected number", details: { value } }, value };
269
+ }
270
+ default:
271
+ return { ok: false, error: { message: "Unsupported type", details: { type, value } }, value };
272
+ }
273
+ }
274
+ applyDynamicProjection(input) {
275
+ const { table, changedColumnId, validatedValue } = input;
276
+ const activeCollection = table.getActiveCollectionName() ?? "default";
277
+ this.dynamic.columnMeta.forEach((colMeta, key) => {
278
+ if ((colMeta.fieldCollection ?? "default") !== activeCollection) return;
279
+ const col = table.getColumnSchema(new chunkNTV2UUAJ_cjs.ColumnId(colMeta.fieldName));
280
+ const depends = colMeta.dynamicSource?.dependsOn;
281
+ if (depends?.includes(changedColumnId.value)) {
282
+ const { dynamicSource } = colMeta;
283
+ const { endpoint, dependsOn, ...restDynamic } = dynamicSource ?? {};
284
+ const base = col ?? colMeta;
285
+ table.setColumnSchema(new chunkNTV2UUAJ_cjs.ColumnId(base.fieldName), {
286
+ ...base,
287
+ dynamicSelectFilterOption: base.dynamicSelectFilterOption ?? (() => true),
288
+ dynamicSource: {
289
+ endpoint: endpoint ?? "",
290
+ ...restDynamic,
291
+ dependOn: {
292
+ fieldName: changedColumnId.value,
293
+ value: validatedValue
294
+ }
295
+ }
296
+ });
297
+ }
298
+ if (colMeta.visibility?.kind === "whenFieldTruthy" && colMeta.visibility.fieldName === changedColumnId.value && col) {
299
+ table.setColumnSchema(new chunkNTV2UUAJ_cjs.ColumnId(colMeta.fieldName), col);
300
+ }
301
+ });
302
+ }
303
+ };
304
+ var ChangeCellDisplayValueHandler = class {
305
+ constructor(repo, audit, permissionPolicy) {
306
+ this.repo = repo;
307
+ this.audit = audit;
308
+ this.permissionPolicy = permissionPolicy;
309
+ }
310
+ async execute(command, actor) {
311
+ const table = await this.repo.getById(command.store, command.tableKey);
312
+ try {
313
+ const rowId = new chunkNTV2UUAJ_cjs.RowId(command.rowId);
314
+ const columnId = new chunkNTV2UUAJ_cjs.ColumnId(command.columnId);
315
+ const schema = table.getColumnSchema(columnId);
316
+ if (!schema) {
317
+ throw new chunkKMRURD5J_cjs.DomainError("COLUMN_NOT_FOUND", "Column does not exist", {
318
+ columnId: columnId.value
319
+ });
320
+ }
321
+ if (schema.editable === false) {
322
+ throw new chunkKMRURD5J_cjs.DomainError("NOT_EDITABLE", "Cell is not editable", {
323
+ rowId: rowId.value,
324
+ columnId: columnId.value
325
+ });
326
+ }
327
+ if (!this.permissionPolicy.canChangeCell({
328
+ actor,
329
+ rowId: command.rowId,
330
+ columnId: command.columnId
331
+ })) {
332
+ throw new chunkKMRURD5J_cjs.DomainError(
333
+ "FORBIDDEN",
334
+ "Actor is not allowed to change this cell",
335
+ { actor, rowId: rowId.value, columnId: columnId.value }
336
+ );
337
+ }
338
+ const domainEvent = table.changeDisplay(rowId, columnId, command.newValue);
339
+ if (!domainEvent) {
340
+ throw new chunkKMRURD5J_cjs.DomainError(
341
+ "CELL_NOT_FOUND",
342
+ "Cell not found or value not changed",
343
+ { rowId: rowId.value, columnId: columnId.value }
344
+ );
345
+ }
346
+ await this.repo.save(command.store, table);
347
+ const out = {
348
+ type: "CELL_DISPLAY_CHANGED",
349
+ tableId: command.tableKey,
350
+ rowId: domainEvent.rowId.value,
351
+ columnId: domainEvent.columnId.value,
352
+ newValue: domainEvent.newValue
353
+ };
354
+ this.audit.log({ type: "CELL_DISPLAY_CHANGED", message: out.type, payload: out });
355
+ return [out];
356
+ } catch (e) {
357
+ logError(this.audit, e, `ChangeCellDisplayValueHandler[${command.tableKey}:${command.rowId}:${command.columnId}]`);
358
+ return [];
359
+ }
360
+ }
361
+ };
362
+ var SaveDescriptionHandler = class {
363
+ constructor(repo, audit, permissionPolicy) {
364
+ this.repo = repo;
365
+ this.audit = audit;
366
+ this.permissionPolicy = permissionPolicy;
367
+ }
368
+ async execute(command, actor) {
369
+ const table = await this.repo.getById(command.store, command.tableKey);
370
+ try {
371
+ const rowId = new chunkNTV2UUAJ_cjs.RowId(command.rowId);
372
+ const domainEvent = table.saveDescription(rowId, command.flag);
373
+ if (!domainEvent) {
374
+ throw new chunkKMRURD5J_cjs.DomainError(
375
+ "CELL_NOT_FOUND",
376
+ "Cell not found or value not changed",
377
+ { rowId: rowId.value, flag: command.flag }
378
+ );
379
+ }
380
+ await this.repo.save(command.store, table);
381
+ const out = {
382
+ type: "ROW_DESCRIPTION_SAVED",
383
+ tableId: command.tableKey,
384
+ rowId: domainEvent.rowId.value,
385
+ description: command.flag
386
+ };
387
+ this.audit.log({ type: "INFORMATION", message: out.type, payload: out });
388
+ return [out];
389
+ } catch (e) {
390
+ logError(this.audit, e, `SaveDescriptionHandler[${command.tableKey}:${command.rowId}]`);
391
+ return [];
392
+ }
393
+ }
394
+ };
395
+ var ApplyDynamicProjectionHandler = class {
396
+ constructor(repo, audit, permissionPolicy, dynamic) {
397
+ this.repo = repo;
398
+ this.audit = audit;
399
+ this.permissionPolicy = permissionPolicy;
400
+ this.dynamic = dynamic;
401
+ }
402
+ async execute(command, actor) {
403
+ const { store, tableKey, rowId, columnId } = command;
404
+ const table = await this.repo.getById(store, tableKey);
405
+ try {
406
+ const row = table.getRow(rowId);
407
+ if (!row) {
408
+ throw new chunkKMRURD5J_cjs.DomainError("ROW_NOT_FOUND", `Row ${rowId} not found`, { rowId });
409
+ }
410
+ const cell = row.getCell(columnId);
411
+ if (!cell) {
412
+ throw new chunkKMRURD5J_cjs.DomainError("CELL_NOT_FOUND", `Cell ${columnId} not found`, { columnId });
413
+ }
414
+ const colValue = cell.getValue();
415
+ const previousValue = colValue;
416
+ const newRowId = new chunkNTV2UUAJ_cjs.RowId(rowId);
417
+ const newColumnId = new chunkNTV2UUAJ_cjs.ColumnId(columnId);
418
+ if (this.dynamic) {
419
+ await this.applyComputedColumns({
420
+ table,
421
+ rowId: newRowId,
422
+ changedColumnId: newColumnId,
423
+ remoteApi: this.dynamic.remoteApi
424
+ });
425
+ await this.applyRemoteVisibilityRules({
426
+ table,
427
+ rowId: newRowId,
428
+ changedColumnId: newColumnId,
429
+ newValue: colValue,
430
+ clearDependents: false
431
+ });
432
+ this.applyDynamicProjection({
433
+ table,
434
+ rowId: newRowId,
435
+ changedColumnId: newColumnId,
436
+ validatedValue: colValue
437
+ });
438
+ }
439
+ const state = table.getRows().find((r) => r.id.value === newRowId.value)?.getCells().get("RowState")?.getValue();
440
+ if (state === "None" /* Unchanged */) {
441
+ table.changeCell(newRowId, new chunkNTV2UUAJ_cjs.ColumnId("RowState"), "Update" /* Modified */);
442
+ table.changeDisplay(newRowId, new chunkNTV2UUAJ_cjs.ColumnId("RowState"), "Update" /* Modified */);
443
+ }
444
+ await this.repo.save(store, table);
445
+ const out = {
446
+ type: "CELL_CHANGED",
447
+ tableId: tableKey,
448
+ rowId: newRowId.value,
449
+ columnId: newColumnId.value,
450
+ newValue: colValue,
451
+ previousValue
452
+ };
453
+ this.audit.log({ type: "CELL_CHANGED", message: out.type, payload: out });
454
+ return [out];
455
+ } catch (e) {
456
+ logError(this.audit, e, `ApplyDynamicProjectionHandler[${tableKey}:${rowId}:${columnId}]`);
457
+ return [];
458
+ }
459
+ }
460
+ /* ── helpers (identical to ChangeCellValueHandler) ───────────────── */
461
+ applyRemoteVisibilityRules(input) {
462
+ return applyRemoteVisibilityRules(this.dynamic, input, this.audit);
463
+ }
464
+ async applyComputedColumns(input) {
465
+ const { table, rowId, changedColumnId, remoteApi } = input;
466
+ const meta = this.dynamic.columnMeta;
467
+ const computedColumns = Array.from(meta.values()).filter(
468
+ (c) => c.computed != null
469
+ );
470
+ if (computedColumns.length === 0) return;
471
+ const row = table.getRows().find((r) => r.id.value === rowId.value);
472
+ if (!row) return;
473
+ const rowValues = {};
474
+ for (const [colId, cell] of row.getCells().entries()) {
475
+ rowValues[colId] = cell.getValue();
476
+ }
477
+ const dependents = /* @__PURE__ */ new Map();
478
+ for (const col of computedColumns) {
479
+ for (const dep of col.computed.dependsOn ?? []) {
480
+ if (!dependents.has(dep)) dependents.set(dep, []);
481
+ dependents.get(dep).push(col);
482
+ }
483
+ }
484
+ const queue = [changedColumnId.value];
485
+ const visited = /* @__PURE__ */ new Set();
486
+ let safetyCounter = 0;
487
+ const MAX = computedColumns.length + 1;
488
+ while (queue.length > 0) {
489
+ if (safetyCounter++ > MAX) throw new Error("Computed cycle detected");
490
+ const source = queue.shift();
491
+ const targets = dependents.get(source) ?? [];
492
+ for (const colCfg of targets) {
493
+ const targetField = colCfg.fieldName;
494
+ const targetColId = new chunkNTV2UUAJ_cjs.ColumnId(targetField);
495
+ const schema = table.getColumnSchema(targetColId);
496
+ if (!schema || !colCfg.computed) continue;
497
+ let newValue;
498
+ try {
499
+ const rawValue = colCfg.computed.compute(rowValues, remoteApi);
500
+ newValue = rawValue instanceof Promise ? await rawValue : rawValue;
501
+ } catch (error) {
502
+ logError(this.audit, error, `computed[${targetField}]`);
503
+ continue;
504
+ }
505
+ const validated = this.validateCellValue(schema.fieldType, newValue);
506
+ if (validated.value instanceof Promise) {
507
+ throw new Error(`Computed column "${targetField}" returned a Promise after validation`);
508
+ }
509
+ const prev = rowValues[targetField];
510
+ if (Object.is(prev, validated.value)) continue;
511
+ table.changeCell(rowId, targetColId, validated.value);
512
+ if (schema.displayFormat) {
513
+ const validatedDisplay = this.validateCellValue(
514
+ schema.fieldType,
515
+ schema.displayFormat(newValue)
516
+ );
517
+ table.changeDisplay(rowId, targetColId, validatedDisplay.value);
518
+ } else {
519
+ table.changeDisplay(rowId, targetColId, validated.value);
520
+ }
521
+ rowValues[targetField] = validated.value;
522
+ queue.push(targetField);
523
+ visited.add(targetField);
524
+ }
525
+ }
526
+ }
527
+ validateCellValue(type, value) {
528
+ switch (type) {
529
+ case "text":
530
+ case "textArea":
531
+ case "description":
532
+ case "date":
533
+ return typeof value === "string" ? { ok: true, value } : { ok: false, error: { message: "Expected string", details: { value } }, value };
534
+ case "static":
535
+ return { ok: true, value };
536
+ case "checkbox":
537
+ return typeof value === "boolean" ? { ok: true, value } : { ok: false, error: { message: "Expected boolean", details: { value } }, value };
538
+ case "number":
539
+ case "price":
540
+ case "select":
541
+ case "selectOption": {
542
+ if (value === "" || value === void 0) return { ok: true, value };
543
+ const n = typeof value === "number" ? value : Number(value);
544
+ return Number.isFinite(n) ? { ok: true, value: n } : { ok: false, error: { message: "Expected number", details: { value } }, value };
545
+ }
546
+ default:
547
+ return { ok: false, error: { message: "Unsupported type", details: { type, value } }, value };
548
+ }
549
+ }
550
+ applyDynamicProjection(input) {
551
+ const { table, changedColumnId, validatedValue } = input;
552
+ const activeCollection = table.getActiveCollectionName() ?? "default";
553
+ this.dynamic.columnMeta.forEach((colMeta, key) => {
554
+ if ((colMeta.fieldCollection ?? "default") !== activeCollection) return;
555
+ const col = table.getColumnSchema(new chunkNTV2UUAJ_cjs.ColumnId(colMeta.fieldName));
556
+ const depends = colMeta.dynamicSource?.dependsOn;
557
+ if (depends?.includes(changedColumnId.value)) {
558
+ const { dynamicSource } = colMeta;
559
+ const { endpoint, dependsOn, ...restDynamic } = dynamicSource ?? {};
560
+ const base = col ?? colMeta;
561
+ table.setColumnSchema(new chunkNTV2UUAJ_cjs.ColumnId(base.fieldName), {
562
+ ...base,
563
+ dynamicSelectFilterOption: base.dynamicSelectFilterOption ?? (() => true),
564
+ dynamicSource: {
565
+ endpoint: endpoint ?? "",
566
+ ...restDynamic,
567
+ dependOn: {
568
+ fieldName: changedColumnId.value,
569
+ value: validatedValue
570
+ }
571
+ }
572
+ });
573
+ }
574
+ if (colMeta.visibility?.kind === "whenFieldTruthy" && colMeta.visibility.fieldName === changedColumnId.value && col) {
575
+ table.setColumnSchema(new chunkNTV2UUAJ_cjs.ColumnId(colMeta.fieldName), col);
576
+ }
577
+ });
578
+ }
579
+ };
580
+
581
+ exports.ApplyDynamicProjectionHandler = ApplyDynamicProjectionHandler;
582
+ exports.ChangeCellDisplayValueHandler = ChangeCellDisplayValueHandler;
583
+ exports.ChangeCellValueHandler = ChangeCellValueHandler;
584
+ exports.SaveDescriptionHandler = SaveDescriptionHandler;
585
+ exports.applyRemoteVisibilityRules = applyRemoteVisibilityRules;
586
+ exports.logError = logError;
587
+ //# sourceMappingURL=chunk-52LFOPXD.cjs.map
588
+ //# sourceMappingURL=chunk-52LFOPXD.cjs.map