@statezero/core 0.2.36 → 0.2.38

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 (301) hide show
  1. package/dist/adaptors/vue/components/LayoutRenderer.js +166 -0
  2. package/dist/adaptors/vue/components/defaults/AlertElement.js +31 -0
  3. package/dist/adaptors/vue/components/defaults/DisplayElement.js +44 -0
  4. package/dist/adaptors/vue/components/defaults/DividerElement.js +10 -0
  5. package/dist/adaptors/vue/components/defaults/ErrorBlock.js +24 -0
  6. package/dist/adaptors/vue/components/defaults/GroupElement.js +41 -0
  7. package/dist/adaptors/vue/components/defaults/LabelElement.js +21 -0
  8. package/dist/adaptors/vue/components/defaults/TabsElement.js +38 -0
  9. package/package.json +7 -6
  10. package/dist/actions/backend1/django_app/calculate-hash.d.ts +0 -57
  11. package/dist/actions/backend1/django_app/calculate-hash.js +0 -80
  12. package/dist/actions/backend1/django_app/calculate-hash.schema.json +0 -148
  13. package/dist/actions/backend1/django_app/get-current-username.d.ts +0 -29
  14. package/dist/actions/backend1/django_app/get-current-username.js +0 -65
  15. package/dist/actions/backend1/django_app/get-current-username.schema.json +0 -47
  16. package/dist/actions/backend1/django_app/get-server-status.d.ts +0 -38
  17. package/dist/actions/backend1/django_app/get-server-status.js +0 -68
  18. package/dist/actions/backend1/django_app/get-server-status.schema.json +0 -93
  19. package/dist/actions/backend1/django_app/get-user-info.d.ts +0 -44
  20. package/dist/actions/backend1/django_app/get-user-info.js +0 -70
  21. package/dist/actions/backend1/django_app/get-user-info.schema.json +0 -127
  22. package/dist/actions/backend1/django_app/index.d.ts +0 -1
  23. package/dist/actions/backend1/django_app/index.js +0 -6
  24. package/dist/actions/backend1/django_app/process-data.d.ts +0 -51
  25. package/dist/actions/backend1/django_app/process-data.js +0 -78
  26. package/dist/actions/backend1/django_app/process-data.schema.json +0 -117
  27. package/dist/actions/backend1/django_app/send-notification.d.ts +0 -55
  28. package/dist/actions/backend1/django_app/send-notification.js +0 -81
  29. package/dist/actions/backend1/django_app/send-notification.schema.json +0 -175
  30. package/dist/actions/backend1/index.d.ts +0 -1
  31. package/dist/actions/backend1/index.js +0 -1
  32. package/dist/actions/default/django_app/calculate-hash.d.ts +0 -57
  33. package/dist/actions/default/django_app/calculate-hash.js +0 -80
  34. package/dist/actions/default/django_app/calculate-hash.schema.json +0 -148
  35. package/dist/actions/default/django_app/get-current-username.d.ts +0 -29
  36. package/dist/actions/default/django_app/get-current-username.js +0 -65
  37. package/dist/actions/default/django_app/get-current-username.schema.json +0 -47
  38. package/dist/actions/default/django_app/get-server-status.d.ts +0 -38
  39. package/dist/actions/default/django_app/get-server-status.js +0 -68
  40. package/dist/actions/default/django_app/get-server-status.schema.json +0 -93
  41. package/dist/actions/default/django_app/get-user-info.d.ts +0 -44
  42. package/dist/actions/default/django_app/get-user-info.js +0 -70
  43. package/dist/actions/default/django_app/get-user-info.schema.json +0 -127
  44. package/dist/actions/default/django_app/index.d.ts +0 -1
  45. package/dist/actions/default/django_app/index.js +0 -6
  46. package/dist/actions/default/django_app/process-data.d.ts +0 -51
  47. package/dist/actions/default/django_app/process-data.js +0 -78
  48. package/dist/actions/default/django_app/process-data.schema.json +0 -117
  49. package/dist/actions/default/django_app/send-notification.d.ts +0 -55
  50. package/dist/actions/default/django_app/send-notification.js +0 -81
  51. package/dist/actions/default/django_app/send-notification.schema.json +0 -175
  52. package/dist/actions/default/index.d.ts +0 -1
  53. package/dist/actions/default/index.js +0 -1
  54. package/dist/actions/index.d.ts +0 -1
  55. package/dist/actions/index.js +0 -5
  56. package/dist/adaptors/react/composables.d.ts +0 -1
  57. package/dist/adaptors/react/composables.js +0 -4
  58. package/dist/adaptors/react/index.d.ts +0 -1
  59. package/dist/adaptors/react/index.js +0 -1
  60. package/dist/adaptors/vue/components/defaults/index.d.ts +0 -7
  61. package/dist/adaptors/vue/components/defaults/index.js +0 -31
  62. package/dist/adaptors/vue/components/index.d.ts +0 -1
  63. package/dist/adaptors/vue/components/index.js +0 -7
  64. package/dist/adaptors/vue/composables.d.ts +0 -2
  65. package/dist/adaptors/vue/composables.js +0 -44
  66. package/dist/adaptors/vue/index.d.ts +0 -3
  67. package/dist/adaptors/vue/index.js +0 -4
  68. package/dist/adaptors/vue/reactivity.d.ts +0 -18
  69. package/dist/adaptors/vue/reactivity.js +0 -132
  70. package/dist/cli/commands/sync.d.ts +0 -6
  71. package/dist/cli/commands/sync.js +0 -30
  72. package/dist/cli/commands/syncActions.d.ts +0 -46
  73. package/dist/cli/commands/syncActions.js +0 -717
  74. package/dist/cli/commands/syncModels.d.ts +0 -132
  75. package/dist/cli/commands/syncModels.js +0 -1120
  76. package/dist/cli/configFileLoader.d.ts +0 -10
  77. package/dist/cli/configFileLoader.js +0 -85
  78. package/dist/cli/index.d.ts +0 -2
  79. package/dist/cli/index.js +0 -22
  80. package/dist/config.d.ts +0 -57
  81. package/dist/config.js +0 -273
  82. package/dist/core/eventReceivers.d.ts +0 -185
  83. package/dist/core/eventReceivers.js +0 -266
  84. package/dist/core/utils.d.ts +0 -8
  85. package/dist/core/utils.js +0 -62
  86. package/dist/errorHandler.d.ts +0 -21
  87. package/dist/errorHandler.js +0 -27
  88. package/dist/filtering/localFiltering.d.ts +0 -110
  89. package/dist/filtering/localFiltering.js +0 -1080
  90. package/dist/flavours/django/dates.d.ts +0 -34
  91. package/dist/flavours/django/dates.js +0 -113
  92. package/dist/flavours/django/errors.d.ts +0 -138
  93. package/dist/flavours/django/errors.js +0 -195
  94. package/dist/flavours/django/f.d.ts +0 -6
  95. package/dist/flavours/django/f.js +0 -91
  96. package/dist/flavours/django/files.d.ts +0 -62
  97. package/dist/flavours/django/files.js +0 -355
  98. package/dist/flavours/django/makeApiCall.d.ts +0 -36
  99. package/dist/flavours/django/makeApiCall.js +0 -169
  100. package/dist/flavours/django/manager.d.ts +0 -204
  101. package/dist/flavours/django/manager.js +0 -222
  102. package/dist/flavours/django/model.d.ts +0 -137
  103. package/dist/flavours/django/model.js +0 -366
  104. package/dist/flavours/django/operationFactory.d.ts +0 -73
  105. package/dist/flavours/django/operationFactory.js +0 -248
  106. package/dist/flavours/django/q.d.ts +0 -70
  107. package/dist/flavours/django/q.js +0 -43
  108. package/dist/flavours/django/queryExecutor.d.ts +0 -149
  109. package/dist/flavours/django/queryExecutor.js +0 -590
  110. package/dist/flavours/django/querySet.d.ts +0 -301
  111. package/dist/flavours/django/querySet.js +0 -736
  112. package/dist/flavours/django/serializers.d.ts +0 -39
  113. package/dist/flavours/django/serializers.js +0 -296
  114. package/dist/flavours/django/tempPk.d.ts +0 -31
  115. package/dist/flavours/django/tempPk.js +0 -92
  116. package/dist/flavours/django/utils.d.ts +0 -19
  117. package/dist/flavours/django/utils.js +0 -29
  118. package/dist/index.d.ts +0 -46
  119. package/dist/index.js +0 -48
  120. package/dist/models/backend1/django_app/comprehensivemodel.d.ts +0 -894
  121. package/dist/models/backend1/django_app/comprehensivemodel.js +0 -71
  122. package/dist/models/backend1/django_app/comprehensivemodel.schema.json +0 -870
  123. package/dist/models/backend1/django_app/custompkmodel.d.ts +0 -92
  124. package/dist/models/backend1/django_app/custompkmodel.js +0 -69
  125. package/dist/models/backend1/django_app/custompkmodel.schema.json +0 -71
  126. package/dist/models/backend1/django_app/dailyrate.d.ts +0 -230
  127. package/dist/models/backend1/django_app/dailyrate.js +0 -71
  128. package/dist/models/backend1/django_app/dailyrate.schema.json +0 -212
  129. package/dist/models/backend1/django_app/deepmodellevel1.d.ts +0 -140
  130. package/dist/models/backend1/django_app/deepmodellevel1.js +0 -72
  131. package/dist/models/backend1/django_app/deepmodellevel1.schema.json +0 -114
  132. package/dist/models/backend1/django_app/deepmodellevel2.d.ts +0 -118
  133. package/dist/models/backend1/django_app/deepmodellevel2.js +0 -71
  134. package/dist/models/backend1/django_app/deepmodellevel2.schema.json +0 -92
  135. package/dist/models/backend1/django_app/deepmodellevel3.d.ts +0 -92
  136. package/dist/models/backend1/django_app/deepmodellevel3.js +0 -69
  137. package/dist/models/backend1/django_app/deepmodellevel3.schema.json +0 -69
  138. package/dist/models/backend1/django_app/dummymodel.d.ts +0 -134
  139. package/dist/models/backend1/django_app/dummymodel.js +0 -71
  140. package/dist/models/backend1/django_app/dummymodel.schema.json +0 -109
  141. package/dist/models/backend1/django_app/dummyrelatedmodel.d.ts +0 -92
  142. package/dist/models/backend1/django_app/dummyrelatedmodel.js +0 -69
  143. package/dist/models/backend1/django_app/dummyrelatedmodel.schema.json +0 -69
  144. package/dist/models/backend1/django_app/filetest.d.ts +0 -140
  145. package/dist/models/backend1/django_app/filetest.js +0 -69
  146. package/dist/models/backend1/django_app/filetest.schema.json +0 -111
  147. package/dist/models/backend1/django_app/index.d.ts +0 -1
  148. package/dist/models/backend1/django_app/index.js +0 -21
  149. package/dist/models/backend1/django_app/m2mdepthtestlevel1.d.ts +0 -118
  150. package/dist/models/backend1/django_app/m2mdepthtestlevel1.js +0 -71
  151. package/dist/models/backend1/django_app/m2mdepthtestlevel1.schema.json +0 -94
  152. package/dist/models/backend1/django_app/m2mdepthtestlevel2.d.ts +0 -118
  153. package/dist/models/backend1/django_app/m2mdepthtestlevel2.js +0 -71
  154. package/dist/models/backend1/django_app/m2mdepthtestlevel2.schema.json +0 -94
  155. package/dist/models/backend1/django_app/m2mdepthtestlevel3.d.ts +0 -134
  156. package/dist/models/backend1/django_app/m2mdepthtestlevel3.js +0 -71
  157. package/dist/models/backend1/django_app/m2mdepthtestlevel3.schema.json +0 -112
  158. package/dist/models/backend1/django_app/modelwithcustompkrelation.d.ts +0 -118
  159. package/dist/models/backend1/django_app/modelwithcustompkrelation.js +0 -71
  160. package/dist/models/backend1/django_app/modelwithcustompkrelation.schema.json +0 -93
  161. package/dist/models/backend1/django_app/modelwithrestrictedfields.d.ts +0 -134
  162. package/dist/models/backend1/django_app/modelwithrestrictedfields.js +0 -71
  163. package/dist/models/backend1/django_app/modelwithrestrictedfields.schema.json +0 -111
  164. package/dist/models/backend1/django_app/namefiltercustompkmodel.d.ts +0 -92
  165. package/dist/models/backend1/django_app/namefiltercustompkmodel.js +0 -69
  166. package/dist/models/backend1/django_app/namefiltercustompkmodel.schema.json +0 -71
  167. package/dist/models/backend1/django_app/order.d.ts +0 -220
  168. package/dist/models/backend1/django_app/order.js +0 -71
  169. package/dist/models/backend1/django_app/order.schema.json +0 -203
  170. package/dist/models/backend1/django_app/orderitem.d.ts +0 -172
  171. package/dist/models/backend1/django_app/orderitem.js +0 -72
  172. package/dist/models/backend1/django_app/orderitem.schema.json +0 -149
  173. package/dist/models/backend1/django_app/product.d.ts +0 -254
  174. package/dist/models/backend1/django_app/product.js +0 -71
  175. package/dist/models/backend1/django_app/product.schema.json +0 -277
  176. package/dist/models/backend1/django_app/productcategory.d.ts +0 -92
  177. package/dist/models/backend1/django_app/productcategory.js +0 -69
  178. package/dist/models/backend1/django_app/productcategory.schema.json +0 -70
  179. package/dist/models/backend1/django_app/rateplan.d.ts +0 -92
  180. package/dist/models/backend1/django_app/rateplan.js +0 -69
  181. package/dist/models/backend1/django_app/rateplan.schema.json +0 -70
  182. package/dist/models/backend1/django_app/restrictedfieldrelatedmodel.d.ts +0 -108
  183. package/dist/models/backend1/django_app/restrictedfieldrelatedmodel.js +0 -69
  184. package/dist/models/backend1/django_app/restrictedfieldrelatedmodel.schema.json +0 -87
  185. package/dist/models/backend1/fileobject.d.ts +0 -4
  186. package/dist/models/backend1/fileobject.js +0 -9
  187. package/dist/models/backend1/index.d.ts +0 -2
  188. package/dist/models/backend1/index.js +0 -2
  189. package/dist/models/default/django_app/comprehensivemodel.d.ts +0 -894
  190. package/dist/models/default/django_app/comprehensivemodel.js +0 -71
  191. package/dist/models/default/django_app/comprehensivemodel.schema.json +0 -870
  192. package/dist/models/default/django_app/custompkmodel.d.ts +0 -92
  193. package/dist/models/default/django_app/custompkmodel.js +0 -69
  194. package/dist/models/default/django_app/custompkmodel.schema.json +0 -71
  195. package/dist/models/default/django_app/dailyrate.d.ts +0 -230
  196. package/dist/models/default/django_app/dailyrate.js +0 -71
  197. package/dist/models/default/django_app/dailyrate.schema.json +0 -212
  198. package/dist/models/default/django_app/deepmodellevel1.d.ts +0 -128
  199. package/dist/models/default/django_app/deepmodellevel1.js +0 -72
  200. package/dist/models/default/django_app/deepmodellevel1.schema.json +0 -102
  201. package/dist/models/default/django_app/deepmodellevel2.d.ts +0 -106
  202. package/dist/models/default/django_app/deepmodellevel2.js +0 -71
  203. package/dist/models/default/django_app/deepmodellevel2.schema.json +0 -80
  204. package/dist/models/default/django_app/deepmodellevel3.d.ts +0 -80
  205. package/dist/models/default/django_app/deepmodellevel3.js +0 -69
  206. package/dist/models/default/django_app/deepmodellevel3.schema.json +0 -57
  207. package/dist/models/default/django_app/dummymodel.d.ts +0 -122
  208. package/dist/models/default/django_app/dummymodel.js +0 -71
  209. package/dist/models/default/django_app/dummymodel.schema.json +0 -97
  210. package/dist/models/default/django_app/dummyrelatedmodel.d.ts +0 -80
  211. package/dist/models/default/django_app/dummyrelatedmodel.js +0 -69
  212. package/dist/models/default/django_app/dummyrelatedmodel.schema.json +0 -57
  213. package/dist/models/default/django_app/filetest.d.ts +0 -128
  214. package/dist/models/default/django_app/filetest.js +0 -69
  215. package/dist/models/default/django_app/filetest.schema.json +0 -99
  216. package/dist/models/default/django_app/index.d.ts +0 -1
  217. package/dist/models/default/django_app/index.js +0 -21
  218. package/dist/models/default/django_app/m2mdepthtestlevel1.d.ts +0 -118
  219. package/dist/models/default/django_app/m2mdepthtestlevel1.js +0 -71
  220. package/dist/models/default/django_app/m2mdepthtestlevel1.schema.json +0 -94
  221. package/dist/models/default/django_app/m2mdepthtestlevel2.d.ts +0 -118
  222. package/dist/models/default/django_app/m2mdepthtestlevel2.js +0 -71
  223. package/dist/models/default/django_app/m2mdepthtestlevel2.schema.json +0 -94
  224. package/dist/models/default/django_app/m2mdepthtestlevel3.d.ts +0 -134
  225. package/dist/models/default/django_app/m2mdepthtestlevel3.js +0 -71
  226. package/dist/models/default/django_app/m2mdepthtestlevel3.schema.json +0 -112
  227. package/dist/models/default/django_app/modelwithcustompkrelation.d.ts +0 -118
  228. package/dist/models/default/django_app/modelwithcustompkrelation.js +0 -71
  229. package/dist/models/default/django_app/modelwithcustompkrelation.schema.json +0 -93
  230. package/dist/models/default/django_app/modelwithrestrictedfields.d.ts +0 -134
  231. package/dist/models/default/django_app/modelwithrestrictedfields.js +0 -71
  232. package/dist/models/default/django_app/modelwithrestrictedfields.schema.json +0 -111
  233. package/dist/models/default/django_app/namefiltercustompkmodel.d.ts +0 -92
  234. package/dist/models/default/django_app/namefiltercustompkmodel.js +0 -69
  235. package/dist/models/default/django_app/namefiltercustompkmodel.schema.json +0 -71
  236. package/dist/models/default/django_app/order.d.ts +0 -220
  237. package/dist/models/default/django_app/order.js +0 -71
  238. package/dist/models/default/django_app/order.schema.json +0 -203
  239. package/dist/models/default/django_app/orderitem.d.ts +0 -172
  240. package/dist/models/default/django_app/orderitem.js +0 -72
  241. package/dist/models/default/django_app/orderitem.schema.json +0 -149
  242. package/dist/models/default/django_app/product.d.ts +0 -254
  243. package/dist/models/default/django_app/product.js +0 -71
  244. package/dist/models/default/django_app/product.schema.json +0 -277
  245. package/dist/models/default/django_app/productcategory.d.ts +0 -92
  246. package/dist/models/default/django_app/productcategory.js +0 -69
  247. package/dist/models/default/django_app/productcategory.schema.json +0 -70
  248. package/dist/models/default/django_app/rateplan.d.ts +0 -92
  249. package/dist/models/default/django_app/rateplan.js +0 -69
  250. package/dist/models/default/django_app/rateplan.schema.json +0 -70
  251. package/dist/models/default/django_app/restrictedfieldrelatedmodel.d.ts +0 -108
  252. package/dist/models/default/django_app/restrictedfieldrelatedmodel.js +0 -69
  253. package/dist/models/default/django_app/restrictedfieldrelatedmodel.schema.json +0 -87
  254. package/dist/models/default/fileobject.d.ts +0 -4
  255. package/dist/models/default/fileobject.js +0 -9
  256. package/dist/models/default/index.d.ts +0 -2
  257. package/dist/models/default/index.js +0 -2
  258. package/dist/models/index.d.ts +0 -1
  259. package/dist/models/index.js +0 -5
  260. package/dist/react-entry.d.ts +0 -2
  261. package/dist/react-entry.js +0 -2
  262. package/dist/reactiveAdaptor.d.ts +0 -24
  263. package/dist/reactiveAdaptor.js +0 -38
  264. package/dist/reset.d.ts +0 -15
  265. package/dist/reset.js +0 -97
  266. package/dist/setup.d.ts +0 -15
  267. package/dist/setup.js +0 -33
  268. package/dist/syncEngine/cache/cache.d.ts +0 -75
  269. package/dist/syncEngine/cache/cache.js +0 -355
  270. package/dist/syncEngine/metrics/metricOptCalcs.d.ts +0 -79
  271. package/dist/syncEngine/metrics/metricOptCalcs.js +0 -284
  272. package/dist/syncEngine/registries/metricRegistry.d.ts +0 -58
  273. package/dist/syncEngine/registries/metricRegistry.js +0 -171
  274. package/dist/syncEngine/registries/modelStoreRegistry.d.ts +0 -11
  275. package/dist/syncEngine/registries/modelStoreRegistry.js +0 -63
  276. package/dist/syncEngine/registries/querysetStoreGraph.d.ts +0 -41
  277. package/dist/syncEngine/registries/querysetStoreGraph.js +0 -174
  278. package/dist/syncEngine/registries/querysetStoreRegistry.d.ts +0 -72
  279. package/dist/syncEngine/registries/querysetStoreRegistry.js +0 -335
  280. package/dist/syncEngine/stores/metricStore.d.ts +0 -55
  281. package/dist/syncEngine/stores/metricStore.js +0 -222
  282. package/dist/syncEngine/stores/modelStore.d.ts +0 -53
  283. package/dist/syncEngine/stores/modelStore.js +0 -565
  284. package/dist/syncEngine/stores/operation.d.ts +0 -139
  285. package/dist/syncEngine/stores/operation.js +0 -291
  286. package/dist/syncEngine/stores/operationEventHandlers.d.ts +0 -8
  287. package/dist/syncEngine/stores/operationEventHandlers.js +0 -322
  288. package/dist/syncEngine/stores/querysetStore.d.ts +0 -60
  289. package/dist/syncEngine/stores/querysetStore.js +0 -294
  290. package/dist/syncEngine/stores/reactivity.d.ts +0 -3
  291. package/dist/syncEngine/stores/reactivity.js +0 -4
  292. package/dist/syncEngine/stores/utils.d.ts +0 -14
  293. package/dist/syncEngine/stores/utils.js +0 -32
  294. package/dist/syncEngine/sync.d.ts +0 -46
  295. package/dist/syncEngine/sync.js +0 -389
  296. package/dist/testing.d.ts +0 -63
  297. package/dist/testing.js +0 -175
  298. package/dist/vue-entry.d.ts +0 -15
  299. package/dist/vue-entry.js +0 -7
  300. /package/{src → dist}/adaptors/vue/components/layout.css +0 -0
  301. /package/{src → dist}/adaptors/vue/components/layout.tailwind.css +0 -0
@@ -1,284 +0,0 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- 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");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _a, _MetricStrategyFactory_customStrategies, _MetricStrategyFactory_defaultStrategies, _MetricStrategyFactory_generateStrategyKey;
7
- import { Status, Type } from '../stores/operation.js';
8
- import { isNil } from 'lodash-es';
9
- /**
10
- * Base class for metric calculation strategies with operations
11
- */
12
- export class MetricCalculationStrategy {
13
- /**
14
- * Calculate metric based on ground truth and operations
15
- */
16
- calculateWithOperations(baseValue, operations, field, ModelClass) {
17
- // Initialize the current value based on the metric type
18
- let currentValue = baseValue === null ? this.getInitialValue() : baseValue;
19
- // Process operations sequentially
20
- for (const op of operations) {
21
- // Skip rejected operations
22
- if (op.status === Status.REJECTED)
23
- continue;
24
- // Process each instance in the operation
25
- op.frozenInstances.forEach((originalData, index) => {
26
- let pk = originalData[ModelClass.primaryKeyField];
27
- // Get the updated data for this instance (for UPDATE operations)
28
- const updatedData = op.instances[index] || null;
29
- // Create operation data object for the reducer
30
- const singleOp = {
31
- originalData, // Pre-operation state
32
- updatedData, // Post-operation state (for updates)
33
- type: op.type,
34
- status: op.status
35
- };
36
- // Apply this single operation using the strategy-specific reducer
37
- currentValue = this.reduceOperation(currentValue, singleOp, field);
38
- });
39
- }
40
- return currentValue;
41
- }
42
- /**
43
- * Get initial value for the metric type
44
- * Override in subclasses if needed
45
- */
46
- getInitialValue() {
47
- return 0; // Default for count and sum
48
- }
49
- /**
50
- * Process a single operation - implement in subclasses
51
- */
52
- reduceOperation(currentValue, operation, field) {
53
- throw new Error('reduceOperation must be implemented by subclass');
54
- }
55
- /**
56
- * Safely get a numeric value from an object
57
- */
58
- safeGetValue(obj, field) {
59
- if (!obj || !field)
60
- return 0;
61
- const value = obj[field];
62
- if (isNil(value))
63
- return 0;
64
- const numValue = parseFloat(value);
65
- return isNaN(numValue) ? 0 : numValue;
66
- }
67
- }
68
- /**
69
- * Count strategy implementation
70
- */
71
- export class CountStrategy extends MetricCalculationStrategy {
72
- reduceOperation(currentCount, operation, field) {
73
- // Skip rejected operations
74
- if (operation.status === Status.REJECTED) {
75
- return currentCount;
76
- }
77
- const { type } = operation;
78
- // Handle operation types
79
- if (type === Type.CREATE) {
80
- return currentCount + 1;
81
- }
82
- else if ([Type.DELETE, Type.DELETE_INSTANCE].includes(type)) {
83
- return Math.max(0, currentCount - 1);
84
- }
85
- // Other operation types don't affect the count
86
- return currentCount;
87
- }
88
- }
89
- /**
90
- * Sum strategy implementation
91
- */
92
- export class SumStrategy extends MetricCalculationStrategy {
93
- reduceOperation(currentSum, operation, field) {
94
- // Skip rejected operations
95
- if (operation.status === Status.REJECTED) {
96
- return currentSum;
97
- }
98
- if (!field) {
99
- throw new Error('SumStrategy requires a field parameter');
100
- }
101
- const { type, originalData, updatedData } = operation;
102
- switch (type) {
103
- case Type.CREATE:
104
- // For CREATE, add the value to the sum
105
- return currentSum + this.safeGetValue(originalData, field);
106
- case Type.CHECKPOINT:
107
- case Type.UPDATE:
108
- // For UPDATE, subtract old value and add new value
109
- if (updatedData) {
110
- const oldValue = this.safeGetValue(originalData, field);
111
- const newValue = this.safeGetValue(updatedData, field);
112
- return currentSum - oldValue + newValue;
113
- }
114
- return currentSum;
115
- case Type.DELETE:
116
- case Type.DELETE_INSTANCE:
117
- // For DELETE, subtract the value from the sum
118
- return currentSum - this.safeGetValue(originalData, field);
119
- default:
120
- return currentSum;
121
- }
122
- }
123
- }
124
- /**
125
- * Min strategy implementation
126
- */
127
- export class MinStrategy extends MetricCalculationStrategy {
128
- getInitialValue() {
129
- return Infinity;
130
- }
131
- reduceOperation(currentMin, operation, field) {
132
- // Skip rejected operations
133
- if (operation.status === Status.REJECTED) {
134
- return currentMin;
135
- }
136
- if (!field) {
137
- throw new Error('MinStrategy requires a field parameter');
138
- }
139
- const { type, originalData, updatedData } = operation;
140
- if (type === Type.CREATE) {
141
- // For CREATE, check if the new value is smaller than current min
142
- const value = this.safeGetValue(originalData, field);
143
- return Math.min(currentMin, value);
144
- }
145
- else if ((type === Type.UPDATE || type.CHECKPOINT) && updatedData) {
146
- // For UPDATE, first check if we're updating the minimum value
147
- const oldValue = this.safeGetValue(originalData, field);
148
- const newValue = this.safeGetValue(updatedData, field);
149
- if (oldValue === currentMin) {
150
- // We're updating the current minimum, need to find the new minimum
151
- if (newValue <= oldValue) {
152
- // Simple case: new value is still the minimum
153
- return newValue;
154
- }
155
- else {
156
- // Harder case: need to recalculate minimum
157
- // For now, conservatively use the new value
158
- return newValue;
159
- }
160
- }
161
- else if (newValue < currentMin) {
162
- // The updated value is a new minimum
163
- return newValue;
164
- }
165
- }
166
- // For other cases, maintain current min
167
- return currentMin;
168
- }
169
- }
170
- /**
171
- * Max strategy implementation
172
- */
173
- export class MaxStrategy extends MetricCalculationStrategy {
174
- getInitialValue() {
175
- return -Infinity;
176
- }
177
- reduceOperation(currentMax, operation, field) {
178
- // Skip rejected operations
179
- if (operation.status === Status.REJECTED) {
180
- return currentMax;
181
- }
182
- if (!field) {
183
- throw new Error('MaxStrategy requires a field parameter');
184
- }
185
- const { type, originalData, updatedData } = operation;
186
- if (type === Type.CREATE) {
187
- // For CREATE, check if the new value is larger than current max
188
- const value = this.safeGetValue(originalData, field);
189
- return Math.max(currentMax, value);
190
- }
191
- else if ((type === Type.UPDATE || type === Type.CHECKPOINT) && updatedData) {
192
- // For UPDATE, first check if we're updating the maximum value
193
- const oldValue = this.safeGetValue(originalData, field);
194
- const newValue = this.safeGetValue(updatedData, field);
195
- if (oldValue === currentMax) {
196
- // We're updating the current maximum, need to find the new maximum
197
- if (newValue >= oldValue) {
198
- // Simple case: new value is still the maximum
199
- return newValue;
200
- }
201
- else {
202
- // Harder case: need to recalculate maximum
203
- // For now, conservatively use the new value
204
- return newValue;
205
- }
206
- }
207
- else if (newValue > currentMax) {
208
- // The updated value is a new maximum
209
- return newValue;
210
- }
211
- }
212
- // For other cases, maintain current max
213
- return currentMax;
214
- }
215
- }
216
- /**
217
- * Factory class for creating the appropriate strategy
218
- */
219
- export class MetricStrategyFactory {
220
- /**
221
- * Clear all custom strategy overrides
222
- */
223
- static clearCustomStrategies() {
224
- __classPrivateFieldGet(this, _a, "f", _MetricStrategyFactory_customStrategies).clear();
225
- }
226
- /**
227
- * Override a strategy for a specific metric type and model class
228
- * @param {string} metricType - The type of metric (count, sum, min, max)
229
- * @param {Function|null} ModelClass - The model class or null for a generic override
230
- * @param {MetricCalculationStrategy} strategy - The strategy to use
231
- */
232
- static overrideStrategy(metricType, ModelClass, strategy) {
233
- if (!metricType || !strategy) {
234
- throw new Error('overrideStrategy requires metricType and strategy');
235
- }
236
- if (!(strategy instanceof MetricCalculationStrategy)) {
237
- throw new Error('strategy must be an instance of MetricCalculationStrategy');
238
- }
239
- let key;
240
- if (ModelClass) {
241
- // Model-specific override
242
- key = __classPrivateFieldGet(this, _a, "m", _MetricStrategyFactory_generateStrategyKey).call(this, metricType, ModelClass);
243
- }
244
- else {
245
- // Generic override for all models
246
- key = `${metricType}::*::*`;
247
- }
248
- __classPrivateFieldGet(this, _a, "f", _MetricStrategyFactory_customStrategies).set(key, strategy);
249
- }
250
- /**
251
- * Get the appropriate strategy for a model class and metric type
252
- * @param {string} metricType - The type of metric (count, sum, min, max)
253
- * @param {Function} ModelClass - The model class
254
- * @returns {MetricCalculationStrategy} The appropriate strategy
255
- */
256
- static getStrategy(metricType, ModelClass) {
257
- const normalizedMetricType = metricType.toLowerCase();
258
- // Check for model-specific override first
259
- const specificKey = __classPrivateFieldGet(this, _a, "m", _MetricStrategyFactory_generateStrategyKey).call(this, normalizedMetricType, ModelClass);
260
- if (__classPrivateFieldGet(this, _a, "f", _MetricStrategyFactory_customStrategies).has(specificKey)) {
261
- return __classPrivateFieldGet(this, _a, "f", _MetricStrategyFactory_customStrategies).get(specificKey);
262
- }
263
- // Check for metric-only override (works across all models)
264
- const genericKey = `${normalizedMetricType}::*::*`;
265
- if (__classPrivateFieldGet(this, _a, "f", _MetricStrategyFactory_customStrategies).has(genericKey)) {
266
- return __classPrivateFieldGet(this, _a, "f", _MetricStrategyFactory_customStrategies).get(genericKey);
267
- }
268
- // Otherwise, return the default strategy based on the metric type
269
- const strategyCreator = __classPrivateFieldGet(this, _a, "f", _MetricStrategyFactory_defaultStrategies).get(normalizedMetricType) || __classPrivateFieldGet(this, _a, "f", _MetricStrategyFactory_defaultStrategies).get('count');
270
- return strategyCreator();
271
- }
272
- }
273
- _a = MetricStrategyFactory, _MetricStrategyFactory_generateStrategyKey = function _MetricStrategyFactory_generateStrategyKey(metricType, ModelClass) {
274
- return `${metricType}::${ModelClass.configKey}::${ModelClass.modelName}`;
275
- };
276
- // Collection of custom strategy overrides
277
- _MetricStrategyFactory_customStrategies = { value: new Map() };
278
- // Default strategy map
279
- _MetricStrategyFactory_defaultStrategies = { value: new Map([
280
- ['count', () => new CountStrategy()],
281
- ['sum', () => new SumStrategy()],
282
- ['min', () => new MinStrategy()],
283
- ['max', () => new MaxStrategy()]
284
- ]) };
@@ -1,58 +0,0 @@
1
- /**
2
- * LiveMetric, a simple wrapper that always returns the latest metric value
3
- * using a getter for the value property
4
- */
5
- export class LiveMetric {
6
- constructor(queryset: any, metricType: any, field?: null);
7
- queryset: any;
8
- metricType: any;
9
- field: any;
10
- get lqs(): import("./querysetStoreRegistry.js").LiveQueryset;
11
- /**
12
- * Refresh the metric data from the database
13
- * Delegates to the underlying store's sync method
14
- */
15
- refreshFromDb(): any;
16
- /**
17
- * Getter that always returns the current value from the store
18
- */
19
- get value(): any;
20
- }
21
- /**
22
- * Registry to manage metric stores
23
- */
24
- export class MetricRegistry {
25
- _stores: Map<any, any>;
26
- syncManager: any;
27
- clear(): void;
28
- setSyncManager(syncManager: any): void;
29
- /**
30
- * Get all metric stores that match a specific queryset
31
- * @param {Queryset} queryset - The queryset to match
32
- * @returns {Array} Array of metric stores
33
- */
34
- getAllStoresForQueryset(queryset: Queryset): any[];
35
- _makeKey(metricType: any, queryset: any, field?: null): string;
36
- /**
37
- * Get a metric store for a specific queryset and metric type
38
- */
39
- getStore(metricType: any, queryset: any, field?: null): any;
40
- /**
41
- * Get a metric value for a specific queryset
42
- */
43
- getEntity(metricType: any, queryset: any, field?: null): Object | null;
44
- /**
45
- * Set metric ground truth value
46
- */
47
- setEntity(metricType: any, queryset: any, field: any, value: any): any;
48
- /**
49
- * Sync a specific metric with the server
50
- */
51
- syncMetric(metricType: any, queryset: any, field?: null): any;
52
- /**
53
- * Get the queryset for a specific key
54
- * Useful for debugging or auditing
55
- */
56
- getQuerysetForKey(key: any): any;
57
- }
58
- export const metricRegistry: MetricRegistry;
@@ -1,171 +0,0 @@
1
- import { MetricStore } from '../stores/metricStore.js';
2
- import { isNil, isEmpty } from 'lodash-es';
3
- import { querysetStoreRegistry } from './querysetStoreRegistry.js';
4
- import { QueryExecutor } from '../../flavours/django/queryExecutor.js';
5
- import { wrapReactiveMetric } from '../../reactiveAdaptor.js';
6
- import hash from 'object-hash';
7
- /**
8
- * LiveMetric, a simple wrapper that always returns the latest metric value
9
- * using a getter for the value property
10
- */
11
- export class LiveMetric {
12
- constructor(queryset, metricType, field = null) {
13
- this.queryset = queryset;
14
- this.metricType = metricType;
15
- this.field = field;
16
- }
17
- get lqs() {
18
- return querysetStoreRegistry.getEntity(this.queryset);
19
- }
20
- /**
21
- * Refresh the metric data from the database
22
- * Delegates to the underlying store's sync method
23
- */
24
- refreshFromDb() {
25
- const store = metricRegistry.getStore(this.metricType, this.queryset, this.field);
26
- return store.sync(true);
27
- }
28
- /**
29
- * Getter that always returns the current value from the store
30
- */
31
- get value() {
32
- // Get the latest store from the registry
33
- const store = metricRegistry.getStore(this.metricType, this.queryset, this.field);
34
- if (!store) {
35
- return null;
36
- }
37
- // Render the current value
38
- return store.render();
39
- }
40
- }
41
- /**
42
- * Registry to manage metric stores
43
- */
44
- export class MetricRegistry {
45
- constructor() {
46
- // Store both the store and a reference to the queryset as a tuple
47
- this._stores = new Map();
48
- this.syncManager = null;
49
- }
50
- clear() {
51
- for (const entry of this._stores.values()) {
52
- this.syncManager.unfollowModel(this, entry.store.modelClass);
53
- }
54
- this._stores = new Map();
55
- }
56
- setSyncManager(syncManager) {
57
- this.syncManager = syncManager;
58
- }
59
- /**
60
- * Get all metric stores that match a specific queryset
61
- * @param {Queryset} queryset - The queryset to match
62
- * @returns {Array} Array of metric stores
63
- */
64
- getAllStoresForQueryset(queryset) {
65
- if (isNil(queryset) || isNil(queryset.ModelClass)) {
66
- return [];
67
- }
68
- const stores = [];
69
- const modelClass = queryset.ModelClass;
70
- for (const [key, entry] of this._stores.entries()) {
71
- const store = entry.store;
72
- // First check if model class matches
73
- if (store.modelClass !== modelClass) {
74
- continue;
75
- }
76
- if (store.queryset.semanticKey != queryset.semanticKey) {
77
- continue;
78
- }
79
- stores.push(store);
80
- }
81
- return stores;
82
- }
83
- _makeKey(metricType, queryset, field = null) {
84
- const modelClass = queryset.ModelClass;
85
- const ast = queryset.build();
86
- return `${metricType}::${modelClass.configKey}::${modelClass.modelName}::${field || 'null'}::${hash(ast)}`;
87
- }
88
- /**
89
- * Get a metric store for a specific queryset and metric type
90
- */
91
- getStore(metricType, queryset, field = null) {
92
- if (isNil(metricType) || isNil(queryset) || isNil(queryset.ModelClass)) {
93
- return null;
94
- }
95
- const modelClass = queryset.ModelClass;
96
- const ast = queryset.build();
97
- const key = this._makeKey(metricType, queryset, field);
98
- if (!this._stores.has(key)) {
99
- // Create fetch function for this metric
100
- const fetchMetricFn = async ({ metricType, modelClass, field, ast }) => {
101
- const qs = queryset.clone();
102
- return await QueryExecutor.executeAgg(qs, metricType, { field });
103
- };
104
- // Create new store
105
- const store = new MetricStore(metricType, modelClass, queryset, field, ast, fetchMetricFn);
106
- // Store both the store and a reference to the queryset
107
- this._stores.set(key, {
108
- store,
109
- queryset // This keeps the queryset alive
110
- });
111
- this.syncManager.followModel(this, store.modelClass);
112
- }
113
- return this._stores.get(key).store;
114
- }
115
- /**
116
- * Get a metric value for a specific queryset
117
- */
118
- getEntity(metricType, queryset, field = null) {
119
- // defensive checks
120
- if (isNil(metricType) || isNil(queryset) || isNil(queryset.ModelClass)) {
121
- return null;
122
- }
123
- // Get the store (creates if doesn't exist)
124
- const store = this.getStore(metricType, queryset, field);
125
- // Create a LiveMetric that will always get the latest store and value
126
- const liveMetric = new LiveMetric(queryset, metricType, field);
127
- // If we're in a reactive environment, wrap the metric
128
- return wrapReactiveMetric(liveMetric);
129
- }
130
- /**
131
- * Set metric ground truth value
132
- */
133
- setEntity(metricType, queryset, field, value) {
134
- // defensive checks
135
- if (isNil(metricType) || isNil(queryset) || isNil(queryset.ModelClass)) {
136
- return null;
137
- }
138
- const store = this.getStore(metricType, queryset, field);
139
- if (!store) {
140
- return null;
141
- }
142
- // check if the store already has a ground truth or operations
143
- if (!isNil(store.groundTruthValue) || !isEmpty(store.operations)) {
144
- store.reset();
145
- }
146
- store.setGroundTruth(value);
147
- return value;
148
- }
149
- /**
150
- * Sync a specific metric with the server
151
- */
152
- syncMetric(metricType, queryset, field = null) {
153
- const store = this.getStore(metricType, queryset, field);
154
- if (store) {
155
- return store.sync();
156
- }
157
- return null;
158
- }
159
- /**
160
- * Get the queryset for a specific key
161
- * Useful for debugging or auditing
162
- */
163
- getQuerysetForKey(key) {
164
- if (this._stores.has(key)) {
165
- return this._stores.get(key).queryset;
166
- }
167
- return null;
168
- }
169
- }
170
- // Export singleton instance
171
- export const metricRegistry = new MetricRegistry();
@@ -1,11 +0,0 @@
1
- export class ModelStoreRegistry {
2
- _stores: Map<any, any>;
3
- syncManager: () => void;
4
- clear(): void;
5
- setSyncManager(syncManager: any): void;
6
- getStore(modelClass: any): any;
7
- getEntity(modelClass: any, pk: any): any;
8
- setEntity(modelClass: any, pk: any, data: any): any;
9
- setEntities(modelClass: any, entities: any): void;
10
- }
11
- export const modelStoreRegistry: ModelStoreRegistry;
@@ -1,63 +0,0 @@
1
- import { ModelStore } from '../stores/modelStore.js';
2
- import { isNil } from 'lodash-es';
3
- export class ModelStoreRegistry {
4
- constructor() {
5
- this._stores = new Map();
6
- this.syncManager = () => { console.warn("SyncManager not set for ModelStoreRegistry"); };
7
- }
8
- clear() {
9
- for (const modelClass of this._stores.keys()) {
10
- this.syncManager.unfollowModel(this, modelClass);
11
- }
12
- this._stores = new Map();
13
- }
14
- setSyncManager(syncManager) {
15
- this.syncManager = syncManager;
16
- }
17
- getStore(modelClass) {
18
- if (!this._stores.has(modelClass)) {
19
- // Create a new ModelStore on demand
20
- const fetchModels = async ({ pks, modelClass }) => {
21
- return await modelClass.objects.filter({
22
- [`${modelClass.primaryKeyField}__in`]: pks
23
- }).fetch().serialize();
24
- };
25
- this._stores.set(modelClass, new ModelStore(modelClass, fetchModels, null, null));
26
- this.syncManager.followModel(this, modelClass);
27
- }
28
- return this._stores.get(modelClass);
29
- }
30
- // Get a single entity from the store
31
- getEntity(modelClass, pk) {
32
- // defensive checks for this nested func
33
- if (isNil(modelClass) || isNil(pk))
34
- return;
35
- if (pk[modelClass.primaryKeyField])
36
- throw new Error("getEntity should be called with a pk not an object");
37
- // logic
38
- const store = this.getStore(modelClass);
39
- const renderedData = store.render([pk]);
40
- return renderedData[0] || null;
41
- }
42
- // Add or update an entity ground truth in the store, not for operations!
43
- setEntity(modelClass, pk, data) {
44
- // defensive checks for this nested func
45
- if (isNil(modelClass) || isNil(pk))
46
- return;
47
- if (pk[modelClass.primaryKeyField])
48
- throw new Error("getEntity should be called with a pk not an object");
49
- // logic
50
- const store = this.getStore(modelClass);
51
- store.addToGroundTruth([data]);
52
- return data;
53
- }
54
- // Batch add or update entities in the store ground truth
55
- setEntities(modelClass, entities) {
56
- if (isNil(modelClass) || !entities?.length)
57
- return;
58
- const store = this.getStore(modelClass);
59
- store.addToGroundTruth(entities);
60
- }
61
- }
62
- // Export singleton instance
63
- export const modelStoreRegistry = new ModelStoreRegistry();
@@ -1,41 +0,0 @@
1
- /**
2
- * Simple graph for tracking queryset store ancestry
3
- */
4
- export class QuerysetStoreGraph {
5
- graph: any;
6
- processedQuerysets: Set<any>;
7
- /**
8
- * Add a queryset and its parent relationship to the graph
9
- */
10
- addQueryset(queryset: any): void;
11
- /**
12
- * Find the root (topmost ancestor) of a queryset chain within a subset.
13
- * Traverses up the graph but only considers nodes that are in the subset.
14
- * Uses the graph to "jump" through nodes not in subset to find connections.
15
- *
16
- * @param {Object} queryset - The queryset to analyze
17
- * @param {Set|null} subset - Set of semanticKeys to consider. If null, considers all nodes in graph.
18
- * @returns {Object} { isRoot: boolean, root: semanticKey|null }
19
- */
20
- findRoot(queryset: Object, subset?: Set<any> | null): Object;
21
- /**
22
- * Check if parent queryset is a valid data source for creating an edge.
23
- * Parent must have data that is a superset of what child needs.
24
- * Child with offset must sync independently (can't derive window from parent).
25
- *
26
- * @param {Object} parentOpts - Parent's serializerOptions
27
- * @param {Object} childOpts - Child's serializerOptions
28
- * @param {Array|undefined} parentOrderBy - Parent's ordering
29
- * @param {Array|undefined} childOrderBy - Child's ordering
30
- * @returns {boolean} - True if parent is valid for edge creation
31
- */
32
- _isValidParentForEdge(parentOpts: Object | undefined, childOpts: Object | undefined, parentOrderBy: any[] | undefined, childOrderBy: any[] | undefined): boolean;
33
- /**
34
- * Check if two orderings are equivalent.
35
- * @param {Array|undefined} orderBy1
36
- * @param {Array|undefined} orderBy2
37
- * @returns {boolean}
38
- */
39
- _orderingsMatch(orderBy1: any[] | undefined, orderBy2: any[] | undefined): boolean;
40
- clear(): void;
41
- }