@statezero/core 0.2.38 → 0.2.39

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 (294) hide show
  1. package/dist/actions/backend1/django_app/calculate-hash.d.ts +57 -0
  2. package/dist/actions/backend1/django_app/calculate-hash.js +80 -0
  3. package/dist/actions/backend1/django_app/calculate-hash.schema.json +148 -0
  4. package/dist/actions/backend1/django_app/get-current-username.d.ts +29 -0
  5. package/dist/actions/backend1/django_app/get-current-username.js +65 -0
  6. package/dist/actions/backend1/django_app/get-current-username.schema.json +47 -0
  7. package/dist/actions/backend1/django_app/get-server-status.d.ts +38 -0
  8. package/dist/actions/backend1/django_app/get-server-status.js +68 -0
  9. package/dist/actions/backend1/django_app/get-server-status.schema.json +93 -0
  10. package/dist/actions/backend1/django_app/get-user-info.d.ts +44 -0
  11. package/dist/actions/backend1/django_app/get-user-info.js +70 -0
  12. package/dist/actions/backend1/django_app/get-user-info.schema.json +127 -0
  13. package/dist/actions/backend1/django_app/index.d.ts +1 -0
  14. package/dist/actions/backend1/django_app/index.js +6 -0
  15. package/dist/actions/backend1/django_app/process-data.d.ts +51 -0
  16. package/dist/actions/backend1/django_app/process-data.js +78 -0
  17. package/dist/actions/backend1/django_app/process-data.schema.json +117 -0
  18. package/dist/actions/backend1/django_app/send-notification.d.ts +55 -0
  19. package/dist/actions/backend1/django_app/send-notification.js +81 -0
  20. package/dist/actions/backend1/django_app/send-notification.schema.json +175 -0
  21. package/dist/actions/backend1/index.d.ts +1 -0
  22. package/dist/actions/backend1/index.js +1 -0
  23. package/dist/actions/default/django_app/calculate-hash.d.ts +57 -0
  24. package/dist/actions/default/django_app/calculate-hash.js +80 -0
  25. package/dist/actions/default/django_app/calculate-hash.schema.json +148 -0
  26. package/dist/actions/default/django_app/get-current-username.d.ts +29 -0
  27. package/dist/actions/default/django_app/get-current-username.js +65 -0
  28. package/dist/actions/default/django_app/get-current-username.schema.json +47 -0
  29. package/dist/actions/default/django_app/get-server-status.d.ts +38 -0
  30. package/dist/actions/default/django_app/get-server-status.js +68 -0
  31. package/dist/actions/default/django_app/get-server-status.schema.json +93 -0
  32. package/dist/actions/default/django_app/get-user-info.d.ts +44 -0
  33. package/dist/actions/default/django_app/get-user-info.js +70 -0
  34. package/dist/actions/default/django_app/get-user-info.schema.json +127 -0
  35. package/dist/actions/default/django_app/index.d.ts +1 -0
  36. package/dist/actions/default/django_app/index.js +6 -0
  37. package/dist/actions/default/django_app/process-data.d.ts +51 -0
  38. package/dist/actions/default/django_app/process-data.js +78 -0
  39. package/dist/actions/default/django_app/process-data.schema.json +117 -0
  40. package/dist/actions/default/django_app/send-notification.d.ts +55 -0
  41. package/dist/actions/default/django_app/send-notification.js +81 -0
  42. package/dist/actions/default/django_app/send-notification.schema.json +175 -0
  43. package/dist/actions/default/index.d.ts +1 -0
  44. package/dist/actions/default/index.js +1 -0
  45. package/dist/actions/index.d.ts +1 -0
  46. package/dist/actions/index.js +5 -0
  47. package/dist/adaptors/react/composables.d.ts +1 -0
  48. package/dist/adaptors/react/composables.js +4 -0
  49. package/dist/adaptors/react/index.d.ts +1 -0
  50. package/dist/adaptors/react/index.js +1 -0
  51. package/dist/adaptors/vue/components/LayoutRenderer.js +46 -49
  52. package/dist/adaptors/vue/components/defaults/index.d.ts +7 -0
  53. package/dist/adaptors/vue/components/defaults/index.js +31 -0
  54. package/dist/adaptors/vue/components/index.d.ts +1 -0
  55. package/dist/adaptors/vue/components/index.js +7 -0
  56. package/dist/adaptors/vue/composables.d.ts +2 -0
  57. package/dist/adaptors/vue/composables.js +44 -0
  58. package/dist/adaptors/vue/index.d.ts +3 -0
  59. package/dist/adaptors/vue/index.js +4 -0
  60. package/dist/adaptors/vue/reactivity.d.ts +18 -0
  61. package/dist/adaptors/vue/reactivity.js +132 -0
  62. package/dist/cli/commands/sync.d.ts +6 -0
  63. package/dist/cli/commands/sync.js +30 -0
  64. package/dist/cli/commands/syncActions.d.ts +46 -0
  65. package/dist/cli/commands/syncActions.js +717 -0
  66. package/dist/cli/commands/syncModels.d.ts +132 -0
  67. package/dist/cli/commands/syncModels.js +1120 -0
  68. package/dist/cli/configFileLoader.d.ts +10 -0
  69. package/dist/cli/configFileLoader.js +85 -0
  70. package/dist/cli/index.d.ts +2 -0
  71. package/dist/cli/index.js +22 -0
  72. package/dist/config.d.ts +57 -0
  73. package/dist/config.js +273 -0
  74. package/dist/core/eventReceivers.d.ts +185 -0
  75. package/dist/core/eventReceivers.js +266 -0
  76. package/dist/core/utils.d.ts +8 -0
  77. package/dist/core/utils.js +62 -0
  78. package/dist/errorHandler.d.ts +21 -0
  79. package/dist/errorHandler.js +27 -0
  80. package/dist/filtering/localFiltering.d.ts +110 -0
  81. package/dist/filtering/localFiltering.js +1080 -0
  82. package/dist/flavours/django/dates.d.ts +34 -0
  83. package/dist/flavours/django/dates.js +113 -0
  84. package/dist/flavours/django/errors.d.ts +138 -0
  85. package/dist/flavours/django/errors.js +195 -0
  86. package/dist/flavours/django/f.d.ts +6 -0
  87. package/dist/flavours/django/f.js +91 -0
  88. package/dist/flavours/django/files.d.ts +62 -0
  89. package/dist/flavours/django/files.js +355 -0
  90. package/dist/flavours/django/makeApiCall.d.ts +36 -0
  91. package/dist/flavours/django/makeApiCall.js +169 -0
  92. package/dist/flavours/django/manager.d.ts +204 -0
  93. package/dist/flavours/django/manager.js +222 -0
  94. package/dist/flavours/django/model.d.ts +137 -0
  95. package/dist/flavours/django/model.js +366 -0
  96. package/dist/flavours/django/operationFactory.d.ts +73 -0
  97. package/dist/flavours/django/operationFactory.js +248 -0
  98. package/dist/flavours/django/q.d.ts +70 -0
  99. package/dist/flavours/django/q.js +43 -0
  100. package/dist/flavours/django/queryExecutor.d.ts +149 -0
  101. package/dist/flavours/django/queryExecutor.js +590 -0
  102. package/dist/flavours/django/querySet.d.ts +301 -0
  103. package/dist/flavours/django/querySet.js +736 -0
  104. package/dist/flavours/django/serializers.d.ts +39 -0
  105. package/dist/flavours/django/serializers.js +296 -0
  106. package/dist/flavours/django/tempPk.d.ts +31 -0
  107. package/dist/flavours/django/tempPk.js +92 -0
  108. package/dist/flavours/django/utils.d.ts +19 -0
  109. package/dist/flavours/django/utils.js +29 -0
  110. package/dist/index.d.ts +46 -0
  111. package/dist/index.js +48 -0
  112. package/dist/models/backend1/django_app/comprehensivemodel.d.ts +894 -0
  113. package/dist/models/backend1/django_app/comprehensivemodel.js +71 -0
  114. package/dist/models/backend1/django_app/comprehensivemodel.schema.json +870 -0
  115. package/dist/models/backend1/django_app/custompkmodel.d.ts +92 -0
  116. package/dist/models/backend1/django_app/custompkmodel.js +69 -0
  117. package/dist/models/backend1/django_app/custompkmodel.schema.json +71 -0
  118. package/dist/models/backend1/django_app/dailyrate.d.ts +230 -0
  119. package/dist/models/backend1/django_app/dailyrate.js +71 -0
  120. package/dist/models/backend1/django_app/dailyrate.schema.json +212 -0
  121. package/dist/models/backend1/django_app/deepmodellevel1.d.ts +140 -0
  122. package/dist/models/backend1/django_app/deepmodellevel1.js +72 -0
  123. package/dist/models/backend1/django_app/deepmodellevel1.schema.json +114 -0
  124. package/dist/models/backend1/django_app/deepmodellevel2.d.ts +118 -0
  125. package/dist/models/backend1/django_app/deepmodellevel2.js +71 -0
  126. package/dist/models/backend1/django_app/deepmodellevel2.schema.json +92 -0
  127. package/dist/models/backend1/django_app/deepmodellevel3.d.ts +92 -0
  128. package/dist/models/backend1/django_app/deepmodellevel3.js +69 -0
  129. package/dist/models/backend1/django_app/deepmodellevel3.schema.json +69 -0
  130. package/dist/models/backend1/django_app/dummymodel.d.ts +134 -0
  131. package/dist/models/backend1/django_app/dummymodel.js +71 -0
  132. package/dist/models/backend1/django_app/dummymodel.schema.json +109 -0
  133. package/dist/models/backend1/django_app/dummyrelatedmodel.d.ts +92 -0
  134. package/dist/models/backend1/django_app/dummyrelatedmodel.js +69 -0
  135. package/dist/models/backend1/django_app/dummyrelatedmodel.schema.json +69 -0
  136. package/dist/models/backend1/django_app/filetest.d.ts +140 -0
  137. package/dist/models/backend1/django_app/filetest.js +69 -0
  138. package/dist/models/backend1/django_app/filetest.schema.json +111 -0
  139. package/dist/models/backend1/django_app/index.d.ts +1 -0
  140. package/dist/models/backend1/django_app/index.js +21 -0
  141. package/dist/models/backend1/django_app/m2mdepthtestlevel1.d.ts +118 -0
  142. package/dist/models/backend1/django_app/m2mdepthtestlevel1.js +71 -0
  143. package/dist/models/backend1/django_app/m2mdepthtestlevel1.schema.json +94 -0
  144. package/dist/models/backend1/django_app/m2mdepthtestlevel2.d.ts +118 -0
  145. package/dist/models/backend1/django_app/m2mdepthtestlevel2.js +71 -0
  146. package/dist/models/backend1/django_app/m2mdepthtestlevel2.schema.json +94 -0
  147. package/dist/models/backend1/django_app/m2mdepthtestlevel3.d.ts +134 -0
  148. package/dist/models/backend1/django_app/m2mdepthtestlevel3.js +71 -0
  149. package/dist/models/backend1/django_app/m2mdepthtestlevel3.schema.json +112 -0
  150. package/dist/models/backend1/django_app/modelwithcustompkrelation.d.ts +118 -0
  151. package/dist/models/backend1/django_app/modelwithcustompkrelation.js +71 -0
  152. package/dist/models/backend1/django_app/modelwithcustompkrelation.schema.json +93 -0
  153. package/dist/models/backend1/django_app/modelwithrestrictedfields.d.ts +134 -0
  154. package/dist/models/backend1/django_app/modelwithrestrictedfields.js +71 -0
  155. package/dist/models/backend1/django_app/modelwithrestrictedfields.schema.json +111 -0
  156. package/dist/models/backend1/django_app/namefiltercustompkmodel.d.ts +92 -0
  157. package/dist/models/backend1/django_app/namefiltercustompkmodel.js +69 -0
  158. package/dist/models/backend1/django_app/namefiltercustompkmodel.schema.json +71 -0
  159. package/dist/models/backend1/django_app/order.d.ts +220 -0
  160. package/dist/models/backend1/django_app/order.js +71 -0
  161. package/dist/models/backend1/django_app/order.schema.json +203 -0
  162. package/dist/models/backend1/django_app/orderitem.d.ts +172 -0
  163. package/dist/models/backend1/django_app/orderitem.js +72 -0
  164. package/dist/models/backend1/django_app/orderitem.schema.json +149 -0
  165. package/dist/models/backend1/django_app/product.d.ts +254 -0
  166. package/dist/models/backend1/django_app/product.js +71 -0
  167. package/dist/models/backend1/django_app/product.schema.json +277 -0
  168. package/dist/models/backend1/django_app/productcategory.d.ts +92 -0
  169. package/dist/models/backend1/django_app/productcategory.js +69 -0
  170. package/dist/models/backend1/django_app/productcategory.schema.json +70 -0
  171. package/dist/models/backend1/django_app/rateplan.d.ts +92 -0
  172. package/dist/models/backend1/django_app/rateplan.js +69 -0
  173. package/dist/models/backend1/django_app/rateplan.schema.json +70 -0
  174. package/dist/models/backend1/django_app/restrictedfieldrelatedmodel.d.ts +108 -0
  175. package/dist/models/backend1/django_app/restrictedfieldrelatedmodel.js +69 -0
  176. package/dist/models/backend1/django_app/restrictedfieldrelatedmodel.schema.json +87 -0
  177. package/dist/models/backend1/fileobject.d.ts +4 -0
  178. package/dist/models/backend1/fileobject.js +9 -0
  179. package/dist/models/backend1/index.d.ts +2 -0
  180. package/dist/models/backend1/index.js +2 -0
  181. package/dist/models/default/django_app/comprehensivemodel.d.ts +894 -0
  182. package/dist/models/default/django_app/comprehensivemodel.js +71 -0
  183. package/dist/models/default/django_app/comprehensivemodel.schema.json +870 -0
  184. package/dist/models/default/django_app/custompkmodel.d.ts +92 -0
  185. package/dist/models/default/django_app/custompkmodel.js +69 -0
  186. package/dist/models/default/django_app/custompkmodel.schema.json +71 -0
  187. package/dist/models/default/django_app/dailyrate.d.ts +230 -0
  188. package/dist/models/default/django_app/dailyrate.js +71 -0
  189. package/dist/models/default/django_app/dailyrate.schema.json +212 -0
  190. package/dist/models/default/django_app/deepmodellevel1.d.ts +128 -0
  191. package/dist/models/default/django_app/deepmodellevel1.js +72 -0
  192. package/dist/models/default/django_app/deepmodellevel1.schema.json +102 -0
  193. package/dist/models/default/django_app/deepmodellevel2.d.ts +106 -0
  194. package/dist/models/default/django_app/deepmodellevel2.js +71 -0
  195. package/dist/models/default/django_app/deepmodellevel2.schema.json +80 -0
  196. package/dist/models/default/django_app/deepmodellevel3.d.ts +80 -0
  197. package/dist/models/default/django_app/deepmodellevel3.js +69 -0
  198. package/dist/models/default/django_app/deepmodellevel3.schema.json +57 -0
  199. package/dist/models/default/django_app/dummymodel.d.ts +122 -0
  200. package/dist/models/default/django_app/dummymodel.js +71 -0
  201. package/dist/models/default/django_app/dummymodel.schema.json +97 -0
  202. package/dist/models/default/django_app/dummyrelatedmodel.d.ts +80 -0
  203. package/dist/models/default/django_app/dummyrelatedmodel.js +69 -0
  204. package/dist/models/default/django_app/dummyrelatedmodel.schema.json +57 -0
  205. package/dist/models/default/django_app/filetest.d.ts +128 -0
  206. package/dist/models/default/django_app/filetest.js +69 -0
  207. package/dist/models/default/django_app/filetest.schema.json +99 -0
  208. package/dist/models/default/django_app/index.d.ts +1 -0
  209. package/dist/models/default/django_app/index.js +21 -0
  210. package/dist/models/default/django_app/m2mdepthtestlevel1.d.ts +118 -0
  211. package/dist/models/default/django_app/m2mdepthtestlevel1.js +71 -0
  212. package/dist/models/default/django_app/m2mdepthtestlevel1.schema.json +94 -0
  213. package/dist/models/default/django_app/m2mdepthtestlevel2.d.ts +118 -0
  214. package/dist/models/default/django_app/m2mdepthtestlevel2.js +71 -0
  215. package/dist/models/default/django_app/m2mdepthtestlevel2.schema.json +94 -0
  216. package/dist/models/default/django_app/m2mdepthtestlevel3.d.ts +134 -0
  217. package/dist/models/default/django_app/m2mdepthtestlevel3.js +71 -0
  218. package/dist/models/default/django_app/m2mdepthtestlevel3.schema.json +112 -0
  219. package/dist/models/default/django_app/modelwithcustompkrelation.d.ts +118 -0
  220. package/dist/models/default/django_app/modelwithcustompkrelation.js +71 -0
  221. package/dist/models/default/django_app/modelwithcustompkrelation.schema.json +93 -0
  222. package/dist/models/default/django_app/modelwithrestrictedfields.d.ts +134 -0
  223. package/dist/models/default/django_app/modelwithrestrictedfields.js +71 -0
  224. package/dist/models/default/django_app/modelwithrestrictedfields.schema.json +111 -0
  225. package/dist/models/default/django_app/namefiltercustompkmodel.d.ts +92 -0
  226. package/dist/models/default/django_app/namefiltercustompkmodel.js +69 -0
  227. package/dist/models/default/django_app/namefiltercustompkmodel.schema.json +71 -0
  228. package/dist/models/default/django_app/order.d.ts +220 -0
  229. package/dist/models/default/django_app/order.js +71 -0
  230. package/dist/models/default/django_app/order.schema.json +203 -0
  231. package/dist/models/default/django_app/orderitem.d.ts +172 -0
  232. package/dist/models/default/django_app/orderitem.js +72 -0
  233. package/dist/models/default/django_app/orderitem.schema.json +149 -0
  234. package/dist/models/default/django_app/product.d.ts +254 -0
  235. package/dist/models/default/django_app/product.js +71 -0
  236. package/dist/models/default/django_app/product.schema.json +277 -0
  237. package/dist/models/default/django_app/productcategory.d.ts +92 -0
  238. package/dist/models/default/django_app/productcategory.js +69 -0
  239. package/dist/models/default/django_app/productcategory.schema.json +70 -0
  240. package/dist/models/default/django_app/rateplan.d.ts +92 -0
  241. package/dist/models/default/django_app/rateplan.js +69 -0
  242. package/dist/models/default/django_app/rateplan.schema.json +70 -0
  243. package/dist/models/default/django_app/restrictedfieldrelatedmodel.d.ts +108 -0
  244. package/dist/models/default/django_app/restrictedfieldrelatedmodel.js +69 -0
  245. package/dist/models/default/django_app/restrictedfieldrelatedmodel.schema.json +87 -0
  246. package/dist/models/default/fileobject.d.ts +4 -0
  247. package/dist/models/default/fileobject.js +9 -0
  248. package/dist/models/default/index.d.ts +2 -0
  249. package/dist/models/default/index.js +2 -0
  250. package/dist/models/index.d.ts +1 -0
  251. package/dist/models/index.js +5 -0
  252. package/dist/react-entry.d.ts +2 -0
  253. package/dist/react-entry.js +2 -0
  254. package/dist/reactiveAdaptor.d.ts +24 -0
  255. package/dist/reactiveAdaptor.js +38 -0
  256. package/dist/reset.d.ts +15 -0
  257. package/dist/reset.js +97 -0
  258. package/dist/setup.d.ts +15 -0
  259. package/dist/setup.js +33 -0
  260. package/dist/syncEngine/cache/cache.d.ts +75 -0
  261. package/dist/syncEngine/cache/cache.js +355 -0
  262. package/dist/syncEngine/metrics/metricOptCalcs.d.ts +79 -0
  263. package/dist/syncEngine/metrics/metricOptCalcs.js +284 -0
  264. package/dist/syncEngine/registries/metricRegistry.d.ts +58 -0
  265. package/dist/syncEngine/registries/metricRegistry.js +171 -0
  266. package/dist/syncEngine/registries/modelStoreRegistry.d.ts +11 -0
  267. package/dist/syncEngine/registries/modelStoreRegistry.js +63 -0
  268. package/dist/syncEngine/registries/querysetStoreGraph.d.ts +41 -0
  269. package/dist/syncEngine/registries/querysetStoreGraph.js +174 -0
  270. package/dist/syncEngine/registries/querysetStoreRegistry.d.ts +72 -0
  271. package/dist/syncEngine/registries/querysetStoreRegistry.js +335 -0
  272. package/dist/syncEngine/stores/metricStore.d.ts +55 -0
  273. package/dist/syncEngine/stores/metricStore.js +222 -0
  274. package/dist/syncEngine/stores/modelStore.d.ts +53 -0
  275. package/dist/syncEngine/stores/modelStore.js +565 -0
  276. package/dist/syncEngine/stores/operation.d.ts +139 -0
  277. package/dist/syncEngine/stores/operation.js +291 -0
  278. package/dist/syncEngine/stores/operationEventHandlers.d.ts +8 -0
  279. package/dist/syncEngine/stores/operationEventHandlers.js +322 -0
  280. package/dist/syncEngine/stores/querysetStore.d.ts +60 -0
  281. package/dist/syncEngine/stores/querysetStore.js +294 -0
  282. package/dist/syncEngine/stores/reactivity.d.ts +3 -0
  283. package/dist/syncEngine/stores/reactivity.js +4 -0
  284. package/dist/syncEngine/stores/utils.d.ts +14 -0
  285. package/dist/syncEngine/stores/utils.js +32 -0
  286. package/dist/syncEngine/sync.d.ts +46 -0
  287. package/dist/syncEngine/sync.js +389 -0
  288. package/dist/testing.d.ts +63 -0
  289. package/dist/testing.js +175 -0
  290. package/dist/vue-entry.d.ts +15 -0
  291. package/dist/vue-entry.js +7 -0
  292. package/package.json +6 -7
  293. package/dist/adaptors/vue/components/layout.tailwind.css +0 -51
  294. /package/{dist → src}/adaptors/vue/components/layout.css +0 -0
@@ -0,0 +1,139 @@
1
+ export const operationEvents: any;
2
+ export namespace Status {
3
+ let CREATED: string;
4
+ let UPDATED: string;
5
+ let CONFIRMED: string;
6
+ let REJECTED: string;
7
+ let CLEAR: string;
8
+ let MUTATED: string;
9
+ }
10
+ export namespace Type {
11
+ let CREATE: string;
12
+ let BULK_CREATE: string;
13
+ let UPDATE: string;
14
+ let DELETE: string;
15
+ let UPDATE_INSTANCE: string;
16
+ let DELETE_INSTANCE: string;
17
+ let GET_OR_CREATE: string;
18
+ let UPDATE_OR_CREATE: string;
19
+ let CHECKPOINT: string;
20
+ let COUNT: string;
21
+ let MIN: string;
22
+ let MAX: string;
23
+ let AVG: string;
24
+ let SUM: string;
25
+ let AGGREGATE: string;
26
+ }
27
+ export namespace OperationMembership {
28
+ let DEFINITELY_YES: string;
29
+ let DEFINITELY_NO: string;
30
+ let MAYBE: string;
31
+ }
32
+ export class Operation {
33
+ constructor(data: any, restore?: boolean);
34
+ operationId: any;
35
+ type: any;
36
+ status: any;
37
+ queryset: any;
38
+ args: any;
39
+ timestamp: any;
40
+ doNotPropagate: any;
41
+ localOnly: any;
42
+ /**
43
+ * Setter for instances
44
+ */
45
+ set instances(value: any);
46
+ /**
47
+ * Getter for instances that replaces any temporary PKs with real PKs
48
+ */
49
+ get instances(): any;
50
+ /**
51
+ * Setter for frozenInstances
52
+ */
53
+ set frozenInstances(value: any);
54
+ /**
55
+ * Getter for frozenInstances that replaces any temporary PKs with real PKs
56
+ */
57
+ get frozenInstances(): any;
58
+ /**
59
+ * Get primary keys of all instances in this operation
60
+ * Returns primary keys as simple values (not objects)
61
+ */
62
+ get instancePks(): any;
63
+ /**
64
+ * Update this operation's status and emit an event
65
+ * @param {string} status - New status ('confirmed', 'rejected', etc.)
66
+ * @param {Array|Object|null} [instances=null] - New instances for the operation
67
+ */
68
+ updateStatus(status: string, instances?: any[] | Object | null): void;
69
+ /**
70
+ * Updates this operation with new data and emits the appropriate event
71
+ * @param {Object} newData - New data to update the operation with
72
+ * @returns {Operation} - Returns this operation instance for chaining
73
+ */
74
+ mutate(newData: Object): Operation;
75
+ #private;
76
+ }
77
+ export const operationRegistry: OperationRegistry;
78
+ declare class OperationRegistry {
79
+ _operations: Map<any, any>;
80
+ _querysetStates: Map<any, any>;
81
+ /**
82
+ * Registers a pre-constructed Operation instance in the registry.
83
+ * Ensures the operationId is unique within the registry.
84
+ * Throws an Error if the operationId already exists.
85
+ *
86
+ * @param {Operation} operation - The fully instantiated Operation object to register.
87
+ * @throws {Error} If the input is not a valid operation object or if an operation with the same operationId already exists.
88
+ */
89
+ register(operation: Operation): void;
90
+ /**
91
+ * Retrieves an operation by its ID.
92
+ * @param {string} operationId - The ID of the operation.
93
+ * @returns {Operation | undefined} The operation instance or undefined if not found.
94
+ */
95
+ get(operationId: string): Operation | undefined;
96
+ /**
97
+ * Checks if an operation with the given ID exists in the registry.
98
+ * @param {string} operationId - The ID of the operation to check.
99
+ * @returns {boolean} True if the operation exists, false otherwise.
100
+ */
101
+ has(operationId: string): boolean;
102
+ /**
103
+ * Sets the membership state for a queryset with respect to an operation.
104
+ * @param {string} operationId - The operation ID
105
+ * @param {string} semanticKey - The queryset's semantic key
106
+ * @param {string} state - One of OperationMembership values
107
+ */
108
+ setQuerysetState(operationId: string, semanticKey: string, state: string): void;
109
+ /**
110
+ * Gets the membership state for a queryset with respect to an operation.
111
+ * @param {string} operationId - The operation ID
112
+ * @param {string} semanticKey - The queryset's semantic key
113
+ * @returns {string|undefined} The membership state, or undefined if not set
114
+ */
115
+ getQuerysetState(operationId: string, semanticKey: string): string | undefined;
116
+ /**
117
+ * Gets all queryset states for an operation.
118
+ * @param {string} operationId - The operation ID
119
+ * @returns {Map<string, string>|undefined} Map of semanticKey -> state, or undefined
120
+ */
121
+ getQuerysetStates(operationId: string): Map<string, string> | undefined;
122
+ /**
123
+ * Clears all operations from the registry.
124
+ */
125
+ clear(): void;
126
+ /**
127
+ * Gets the most recently registered operation.
128
+ * Useful for testing when you need to find the operation created by the last action.
129
+ * @returns {Operation | undefined} The most recent operation or undefined if empty.
130
+ */
131
+ getLatest(): Operation | undefined;
132
+ /**
133
+ * Gets the most recently registered operation of a specific type.
134
+ * @param {string} type - The operation type (e.g., Type.CREATE, Type.UPDATE)
135
+ * @returns {Operation | undefined} The most recent operation of that type or undefined.
136
+ */
137
+ getLatestByType(type: string): Operation | undefined;
138
+ }
139
+ export {};
@@ -0,0 +1,291 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _Operation__instances, _Operation__frozenInstances;
13
+ import { MAX, v7 as uuidv7 } from "uuid";
14
+ import { isNil } from 'lodash-es';
15
+ import mitt from 'mitt';
16
+ import { tempPkMap } from "../../flavours/django/tempPk.js";
17
+ import { modelStoreRegistry } from "../registries/modelStoreRegistry.js";
18
+ export const operationEvents = mitt();
19
+ export const Status = {
20
+ CREATED: 'operation:created',
21
+ UPDATED: 'operation:updated',
22
+ CONFIRMED: 'operation:confirmed',
23
+ REJECTED: 'operation:rejected',
24
+ CLEAR: 'clear:all',
25
+ MUTATED: 'operation:mutated'
26
+ };
27
+ export const Type = {
28
+ CREATE: 'create',
29
+ BULK_CREATE: 'bulk_create',
30
+ UPDATE: 'update',
31
+ DELETE: 'delete',
32
+ UPDATE_INSTANCE: 'update_instance',
33
+ DELETE_INSTANCE: 'delete_instance',
34
+ GET_OR_CREATE: 'get_or_create',
35
+ UPDATE_OR_CREATE: 'update_or_create',
36
+ CHECKPOINT: 'checkpoint',
37
+ // Aggregation operations
38
+ COUNT: 'count',
39
+ MIN: 'min',
40
+ MAX: 'max',
41
+ AVG: 'avg',
42
+ SUM: 'sum',
43
+ AGGREGATE: 'aggregate',
44
+ };
45
+ /**
46
+ * Membership state for a queryset with respect to an operation.
47
+ * Used to track whether a queryset was evaluated for an operation and the result.
48
+ */
49
+ export const OperationMembership = {
50
+ DEFINITELY_YES: 'definitely_yes', // Item matches filter, included in queryset
51
+ DEFINITELY_NO: 'definitely_no', // Item doesn't match filter, excluded from queryset
52
+ MAYBE: 'maybe', // Impossible to know based on slicing, needs server sync
53
+ };
54
+ export class Operation {
55
+ constructor(data, restore = false) {
56
+ _Operation__instances.set(this, void 0);
57
+ _Operation__frozenInstances.set(this, void 0);
58
+ if (!data || typeof data !== 'object') {
59
+ throw new Error("Operation constructor requires a data object.");
60
+ }
61
+ if (!data.type) {
62
+ throw new Error("Operation data must include a 'type'.");
63
+ }
64
+ if (!data.instances) {
65
+ throw new Error("Operation data must include 'instances'.");
66
+ }
67
+ this.operationId = data.operationId || `op_${uuidv7()}`;
68
+ this.type = data.type;
69
+ this.status = data.status || Status.CREATED;
70
+ this.queryset = data.queryset;
71
+ this.args = data.args;
72
+ this.doNotPropagate = data.doNotPropagate || false;
73
+ this.localOnly = data.localOnly || false;
74
+ let ModelClass = this.queryset.ModelClass;
75
+ let instances = data.instances;
76
+ // guarantee instances is an array
77
+ if (!isNil(instances)) {
78
+ instances = Array.isArray(data.instances) ? data.instances : [data.instances];
79
+ }
80
+ // coerce to object format if its not already
81
+ let pkField = ModelClass.primaryKeyField;
82
+ if (instances.some(instance => isNil(instance) || typeof instance !== 'object' || !(pkField in instance))) {
83
+ throw new Error(`All operation instances must be objects with the '${pkField}' field`);
84
+ }
85
+ __classPrivateFieldSet(this, _Operation__instances, instances, "f");
86
+ // Batch render to warm the cache, then serialize each instance to get plain objects
87
+ const pks = instances.map(i => i[pkField]);
88
+ const store = modelStoreRegistry.getStore(ModelClass);
89
+ store.render(pks, true, false);
90
+ __classPrivateFieldSet(this, _Operation__frozenInstances, instances.map(i => ModelClass.fromPk(i[pkField]).serialize()), "f");
91
+ this.timestamp = data.timestamp || Date.now();
92
+ if (restore)
93
+ return;
94
+ operationRegistry.register(this);
95
+ // Emit operation created event with the entire operation
96
+ operationEvents.emit(Status.CREATED, this);
97
+ }
98
+ /**
99
+ * Getter for instances that replaces any temporary PKs with real PKs
100
+ */
101
+ get instances() {
102
+ if (tempPkMap.size === 0)
103
+ return __classPrivateFieldGet(this, _Operation__instances, "f");
104
+ const ModelClass = this.queryset.ModelClass;
105
+ const pkField = ModelClass.primaryKeyField;
106
+ return __classPrivateFieldGet(this, _Operation__instances, "f").map(instance => {
107
+ const pk = instance[pkField];
108
+ if (typeof pk === 'string' && tempPkMap.has(pk.replace(/[{}]/g, ''))) {
109
+ // Return a new instance with the real PK
110
+ return {
111
+ ...instance,
112
+ [pkField]: tempPkMap.get(pk.replace(/[{}]/g, ''))
113
+ };
114
+ }
115
+ return instance;
116
+ });
117
+ }
118
+ /**
119
+ * Setter for instances
120
+ */
121
+ set instances(value) {
122
+ __classPrivateFieldSet(this, _Operation__instances, Array.isArray(value) ? value : [value], "f");
123
+ }
124
+ /**
125
+ * Getter for frozenInstances that replaces any temporary PKs with real PKs
126
+ */
127
+ get frozenInstances() {
128
+ if (tempPkMap.size === 0)
129
+ return __classPrivateFieldGet(this, _Operation__frozenInstances, "f");
130
+ const ModelClass = this.queryset.ModelClass;
131
+ const pkField = ModelClass.primaryKeyField;
132
+ return __classPrivateFieldGet(this, _Operation__frozenInstances, "f").map(instance => {
133
+ const pk = instance[pkField];
134
+ if (typeof pk === 'string' && tempPkMap.has(pk.replace(/[{}]/g, ''))) {
135
+ // Return a new instance with the real PK
136
+ return {
137
+ ...instance,
138
+ [pkField]: tempPkMap.get(pk.replace(/[{}]/g, ''))
139
+ };
140
+ }
141
+ return instance;
142
+ });
143
+ }
144
+ /**
145
+ * Setter for frozenInstances
146
+ */
147
+ set frozenInstances(value) {
148
+ __classPrivateFieldSet(this, _Operation__frozenInstances, Array.isArray(value) ? value : [value], "f");
149
+ }
150
+ /**
151
+ * Get primary keys of all instances in this operation
152
+ * Returns primary keys as simple values (not objects)
153
+ */
154
+ get instancePks() {
155
+ const pkField = this.queryset.ModelClass.primaryKeyField;
156
+ return this.instances.map(instance => instance[pkField]);
157
+ }
158
+ /**
159
+ * Update this operation's status and emit an event
160
+ * @param {string} status - New status ('confirmed', 'rejected', etc.)
161
+ * @param {Array|Object|null} [instances=null] - New instances for the operation
162
+ */
163
+ updateStatus(status, instances = null) {
164
+ this.status = status;
165
+ this.timestamp = Date.now();
166
+ if (instances !== null) {
167
+ this.instances = Array.isArray(instances) ? instances : [instances];
168
+ }
169
+ operationEvents.emit(status, this);
170
+ }
171
+ /**
172
+ * Updates this operation with new data and emits the appropriate event
173
+ * @param {Object} newData - New data to update the operation with
174
+ * @returns {Operation} - Returns this operation instance for chaining
175
+ */
176
+ mutate(newData) {
177
+ // Ensure instances is always an array
178
+ if (newData.instances && !Array.isArray(newData.instances)) {
179
+ newData.instances = [newData.instances];
180
+ }
181
+ // Use Object.assign to update all properties at once
182
+ Object.assign(this, newData);
183
+ // Update timestamp
184
+ this.timestamp = Date.now();
185
+ // Emit the mutated event with the updated operation
186
+ operationEvents.emit(Status.MUTATED, this);
187
+ return this;
188
+ }
189
+ }
190
+ _Operation__instances = new WeakMap(), _Operation__frozenInstances = new WeakMap();
191
+ class OperationRegistry {
192
+ constructor() {
193
+ this._operations = new Map();
194
+ // Map<operationId, Map<semanticKey, OperationMembership>>
195
+ this._querysetStates = new Map();
196
+ }
197
+ /**
198
+ * Registers a pre-constructed Operation instance in the registry.
199
+ * Ensures the operationId is unique within the registry.
200
+ * Throws an Error if the operationId already exists.
201
+ *
202
+ * @param {Operation} operation - The fully instantiated Operation object to register.
203
+ * @throws {Error} If the input is not a valid operation object or if an operation with the same operationId already exists.
204
+ */
205
+ register(operation) {
206
+ if (!(operation instanceof Operation)) {
207
+ throw new Error("OperationRegistry.register requires an Operation object.");
208
+ }
209
+ // Ensure the ID is unique before registering
210
+ if (this._operations.has(operation.operationId)) {
211
+ // Throw an error if the ID is already used.
212
+ console.warn(`OperationId ${operation.operationId} is already used, overriding existing operation!`);
213
+ }
214
+ // Register the provided operation object
215
+ this._operations.set(operation.operationId, operation);
216
+ }
217
+ /**
218
+ * Retrieves an operation by its ID.
219
+ * @param {string} operationId - The ID of the operation.
220
+ * @returns {Operation | undefined} The operation instance or undefined if not found.
221
+ */
222
+ get(operationId) {
223
+ return this._operations.get(operationId);
224
+ }
225
+ /**
226
+ * Checks if an operation with the given ID exists in the registry.
227
+ * @param {string} operationId - The ID of the operation to check.
228
+ * @returns {boolean} True if the operation exists, false otherwise.
229
+ */
230
+ has(operationId) {
231
+ return this._operations.has(operationId);
232
+ }
233
+ /**
234
+ * Sets the membership state for a queryset with respect to an operation.
235
+ * @param {string} operationId - The operation ID
236
+ * @param {string} semanticKey - The queryset's semantic key
237
+ * @param {string} state - One of OperationMembership values
238
+ */
239
+ setQuerysetState(operationId, semanticKey, state) {
240
+ if (!this._querysetStates.has(operationId)) {
241
+ this._querysetStates.set(operationId, new Map());
242
+ }
243
+ this._querysetStates.get(operationId).set(semanticKey, state);
244
+ }
245
+ /**
246
+ * Gets the membership state for a queryset with respect to an operation.
247
+ * @param {string} operationId - The operation ID
248
+ * @param {string} semanticKey - The queryset's semantic key
249
+ * @returns {string|undefined} The membership state, or undefined if not set
250
+ */
251
+ getQuerysetState(operationId, semanticKey) {
252
+ const states = this._querysetStates.get(operationId);
253
+ return states ? states.get(semanticKey) : undefined;
254
+ }
255
+ /**
256
+ * Gets all queryset states for an operation.
257
+ * @param {string} operationId - The operation ID
258
+ * @returns {Map<string, string>|undefined} Map of semanticKey -> state, or undefined
259
+ */
260
+ getQuerysetStates(operationId) {
261
+ return this._querysetStates.get(operationId);
262
+ }
263
+ /**
264
+ * Clears all operations from the registry.
265
+ */
266
+ clear() {
267
+ console.log("OperationRegistry: Clearing all operations.");
268
+ this._operations.clear();
269
+ this._querysetStates.clear();
270
+ operationEvents.emit(Status.CLEAR);
271
+ }
272
+ /**
273
+ * Gets the most recently registered operation.
274
+ * Useful for testing when you need to find the operation created by the last action.
275
+ * @returns {Operation | undefined} The most recent operation or undefined if empty.
276
+ */
277
+ getLatest() {
278
+ const ops = Array.from(this._operations.values());
279
+ return ops.length > 0 ? ops[ops.length - 1] : undefined;
280
+ }
281
+ /**
282
+ * Gets the most recently registered operation of a specific type.
283
+ * @param {string} type - The operation type (e.g., Type.CREATE, Type.UPDATE)
284
+ * @returns {Operation | undefined} The most recent operation of that type or undefined.
285
+ */
286
+ getLatestByType(type) {
287
+ const ops = Array.from(this._operations.values()).filter(op => op.type === type);
288
+ return ops.length > 0 ? ops[ops.length - 1] : undefined;
289
+ }
290
+ }
291
+ export const operationRegistry = new OperationRegistry();
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Initialize the operation event handler system by setting up event listeners
3
+ */
4
+ export function initEventHandler(): void;
5
+ /**
6
+ * Clean up by removing all event listeners
7
+ */
8
+ export function cleanupEventHandler(): void;