oak-domain 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/README.md +5 -1
  2. package/es/actions/action.d.ts +1 -1
  3. package/es/base-app-domain/EntityDict.d.ts +27 -0
  4. package/es/base-app-domain/LocalizedContent/Schema.d.ts +19 -0
  5. package/es/base-app-domain/LocalizedContent/Schema.js +1 -0
  6. package/es/base-app-domain/LocalizedContent/Storage.d.ts +3 -0
  7. package/es/base-app-domain/LocalizedContent/Storage.js +75 -0
  8. package/es/base-app-domain/LocalizedContent/Style.d.ts +3 -0
  9. package/es/base-app-domain/LocalizedContent/Style.js +12 -0
  10. package/es/base-app-domain/LocalizedContent/_baseSchema.d.ts +58 -0
  11. package/es/base-app-domain/Storage.js +2 -0
  12. package/es/base-app-domain/StyleDict.js +2 -0
  13. package/es/compiler/customChecks/i18n.js +4 -1
  14. package/es/compiler/customChecks/runner.d.ts +1 -1
  15. package/es/compiler/customChecks/runner.js +1 -1
  16. package/es/compiler/customChecks/types.d.ts +2 -1
  17. package/es/compiler/dependencyBuilder.d.ts +11 -2
  18. package/es/compiler/dependencyBuilder.js +188 -199
  19. package/es/compiler/entityDescEnum.d.ts +5 -0
  20. package/es/compiler/entityDescEnum.js +443 -0
  21. package/es/compiler/entitySource.d.ts +28 -0
  22. package/es/compiler/entitySource.js +521 -0
  23. package/es/compiler/localeBuilder.d.ts +7 -2
  24. package/es/compiler/localeBuilder.js +52 -56
  25. package/es/compiler/routerBuilder.d.ts +32 -3
  26. package/es/compiler/routerBuilder.js +157 -45
  27. package/es/compiler/schemaBuilder.d.ts +12 -2
  28. package/es/compiler/schemaBuilder.js +653 -148
  29. package/es/compiler/tscBuilder.d.ts +20 -2
  30. package/es/compiler/tscBuilder.js +231 -45
  31. package/es/context/BackendRuntimeContext.d.ts +6 -4
  32. package/es/context/BackendRuntimeContext.js +9 -1
  33. package/es/context/ContextComposer.d.ts +93 -0
  34. package/es/context/ContextComposer.js +353 -0
  35. package/es/context/SerializedData.d.ts +2 -1
  36. package/es/data/i18n.d.ts +1 -1
  37. package/es/data/i18n.js +1 -86
  38. package/es/data/i18n.json +86 -0
  39. package/es/entities/ActionAuth.d.ts +3 -3
  40. package/es/entities/I18n.d.ts +2 -2
  41. package/es/entities/LocalizedContent.d.ts +22 -0
  42. package/es/entities/LocalizedContent.js +101 -0
  43. package/es/entities/Log.d.ts +3 -3
  44. package/es/entities/Modi.d.ts +2 -2
  45. package/es/entities/ModiEntity.d.ts +3 -3
  46. package/es/entities/Oper.d.ts +5 -5
  47. package/es/entities/OperEntity.d.ts +3 -3
  48. package/es/entities/Path.d.ts +2 -2
  49. package/es/entities/Relation.d.ts +2 -2
  50. package/es/entities/RelationAuth.d.ts +3 -3
  51. package/es/entities/User.d.ts +4 -4
  52. package/es/entities/UserEntityClaim.d.ts +6 -6
  53. package/es/entities/UserEntityGrant.d.ts +2 -2
  54. package/es/entities/UserRelation.d.ts +4 -4
  55. package/es/store/AsyncRowStore.d.ts +2 -2
  56. package/es/store/AsyncRowStore.js +2 -2
  57. package/es/store/CascadeStore.d.ts +5 -3
  58. package/es/store/CascadeStore.js +56 -24
  59. package/es/store/IntrinsicCheckers.d.ts +1 -1
  60. package/es/store/IntrinsicCheckers.js +2 -2
  61. package/es/store/IntrinsicLogics.d.ts +1 -1
  62. package/es/store/RelationAuth.js +3 -3
  63. package/es/store/SyncRowStore.d.ts +1 -1
  64. package/es/store/SyncRowStore.js +1 -1
  65. package/es/store/TriggerExecutor.d.ts +6 -4
  66. package/es/store/TriggerExecutor.js +16 -4
  67. package/es/store/checker.d.ts +2 -2
  68. package/es/store/checker.js +45 -9
  69. package/es/store/filter.d.ts +3 -3
  70. package/es/store/filter.js +4 -4
  71. package/es/store/modi.d.ts +5 -5
  72. package/es/store/modi.js +4 -4
  73. package/es/store/projection.d.ts +1 -1
  74. package/es/store/relation.js +1 -1
  75. package/es/store/triggers.d.ts +4 -4
  76. package/es/store/triggers.js +2 -2
  77. package/es/timers/oper.d.ts +3 -3
  78. package/es/timers/oper.js +1 -1
  79. package/es/timers/vaccum.d.ts +3 -3
  80. package/es/types/Action.d.ts +1 -1
  81. package/es/types/AppLoader.d.ts +1 -1
  82. package/es/types/Aspect.d.ts +1 -1
  83. package/es/types/Auth.d.ts +2 -2
  84. package/es/types/Configuration.d.ts +7 -6
  85. package/es/types/Connector.d.ts +47 -1
  86. package/es/types/DataType.d.ts +2 -2
  87. package/es/types/Demand.d.ts +40 -6
  88. package/es/types/Endpoint.d.ts +17 -1
  89. package/es/types/Entity.d.ts +21 -4
  90. package/es/types/Entity.js +23 -0
  91. package/es/types/EntityDesc.d.ts +9 -8
  92. package/es/types/Environment.d.ts +17 -0
  93. package/es/types/Exception.d.ts +1 -1
  94. package/es/types/Exception.js +1 -1
  95. package/es/types/Expression.d.ts +13 -2
  96. package/es/types/Expression.js +36 -1
  97. package/es/types/Locale.d.ts +14 -1
  98. package/es/types/Locale.js +13 -1
  99. package/es/types/OakPackage.d.ts +29 -0
  100. package/es/types/OakPackage.js +30 -0
  101. package/es/types/Port.d.ts +1 -1
  102. package/es/types/RowStore.d.ts +9 -7
  103. package/es/types/Storage.d.ts +11 -3
  104. package/es/types/Storage.js +12 -1
  105. package/es/types/Style.d.ts +2 -2
  106. package/es/types/Sync.d.ts +3 -3
  107. package/es/types/Timer.d.ts +14 -2
  108. package/es/types/Trigger.d.ts +1 -1
  109. package/es/types/Watcher.d.ts +1 -1
  110. package/es/types/index.d.ts +1 -0
  111. package/es/types/index.js +1 -0
  112. package/es/utils/SimpleConnector.d.ts +30 -4
  113. package/es/utils/SimpleConnector.js +294 -21
  114. package/es/utils/concurrent.js +1 -1
  115. package/es/utils/decimal.d.ts +26 -0
  116. package/es/utils/decimal.js +87 -0
  117. package/es/utils/fetch/index.d.ts +1 -0
  118. package/es/utils/fetch/index.js +3 -0
  119. package/es/utils/fetch/index.mp.d.ts +3 -0
  120. package/es/utils/fetch/index.mp.js +280 -0
  121. package/es/utils/fetch/index.native.d.ts +1 -0
  122. package/es/utils/fetch/index.native.js +3 -0
  123. package/es/utils/fetch/index.web.d.ts +1 -0
  124. package/es/utils/fetch/index.web.js +3 -0
  125. package/es/utils/fetch/shared.d.ts +6 -0
  126. package/es/utils/fetch/shared.js +23 -0
  127. package/es/utils/localizedContent.d.ts +11 -0
  128. package/es/utils/localizedContent.js +346 -0
  129. package/es/utils/lodash.d.ts +1 -35
  130. package/es/utils/lodash.js +1 -52
  131. package/es/utils/module/combine.common.d.ts +3 -3
  132. package/es/utils/module/combine.common.js +2 -2
  133. package/es/utils/module/combine.dev.d.ts +2 -2
  134. package/es/utils/module/combine.dev.js +2 -2
  135. package/es/utils/module/combine.prod.d.ts +1 -1
  136. package/es/utils/module/combine.server.d.ts +2 -2
  137. package/es/utils/module/combine.server.js +2 -2
  138. package/es/utils/money.d.ts +2 -2
  139. package/es/utils/money.js +2 -2
  140. package/es/utils/operationResult.js +1 -1
  141. package/es/utils/projection.d.ts +3 -3
  142. package/es/utils/projection.js +1 -1
  143. package/es/utils/relationPath.d.ts +1 -1
  144. package/es/utils/relationPath.js +1 -1
  145. package/es/utils/row.d.ts +3 -3
  146. package/es/utils/row.js +2 -2
  147. package/es/utils/sseEndpoint.d.ts +41 -0
  148. package/es/utils/sseEndpoint.js +151 -0
  149. package/es/utils/toolkit.d.ts +28 -0
  150. package/es/utils/toolkit.js +220 -0
  151. package/es/utils/url/index.d.ts +1 -3
  152. package/es/utils/url/index.js +1 -1
  153. package/es/utils/url/index.mp.d.ts +16 -3
  154. package/es/utils/url/index.mp.js +2 -2
  155. package/es/utils/url/index.native.d.ts +13 -1
  156. package/es/utils/url/index.native.js +3 -1
  157. package/es/utils/url/index.web.d.ts +13 -1
  158. package/es/utils/url/index.web.js +3 -1
  159. package/es/utils/url/lightweight.d.ts +65 -0
  160. package/es/utils/url/lightweight.js +530 -0
  161. package/es/utils/url/urlObject.d.ts +16 -0
  162. package/es/utils/validate/id.d.ts +5 -0
  163. package/es/utils/validate/id.js +28 -0
  164. package/es/utils/validate/index.d.ts +4 -0
  165. package/es/utils/validate/index.js +4 -0
  166. package/es/utils/validate/mobile.d.ts +6 -0
  167. package/es/utils/validate/mobile.js +49 -0
  168. package/es/utils/validate/nationality.d.ts +14 -0
  169. package/es/utils/validate/nationality.data.d.ts +9 -0
  170. package/es/utils/validate/nationality.data.js +257 -0
  171. package/es/utils/validate/nationality.js +64 -0
  172. package/es/utils/validate/passport.d.ts +3 -0
  173. package/es/utils/validate/passport.js +19 -0
  174. package/es/utils/validator.d.ts +10 -8
  175. package/es/utils/validator.js +24 -40
  176. package/lib/actions/action.d.ts +1 -1
  177. package/lib/base-app-domain/EntityDict.d.ts +27 -0
  178. package/lib/base-app-domain/LocalizedContent/Schema.d.ts +19 -0
  179. package/lib/base-app-domain/LocalizedContent/Schema.js +4 -0
  180. package/lib/base-app-domain/LocalizedContent/Storage.d.ts +3 -0
  181. package/lib/base-app-domain/LocalizedContent/Storage.js +78 -0
  182. package/lib/base-app-domain/LocalizedContent/Style.d.ts +3 -0
  183. package/lib/base-app-domain/LocalizedContent/Style.js +15 -0
  184. package/lib/base-app-domain/LocalizedContent/_baseSchema.d.ts +58 -0
  185. package/lib/base-app-domain/Storage.js +26 -24
  186. package/lib/base-app-domain/StyleDict.js +10 -8
  187. package/lib/compiler/customChecks/i18n.js +5 -2
  188. package/lib/compiler/customChecks/runner.d.ts +1 -1
  189. package/lib/compiler/customChecks/types.d.ts +2 -1
  190. package/lib/compiler/dependencyBuilder.d.ts +11 -2
  191. package/lib/compiler/dependencyBuilder.js +237 -243
  192. package/lib/compiler/entityDescEnum.d.ts +5 -0
  193. package/lib/compiler/entityDescEnum.js +450 -0
  194. package/lib/compiler/entitySource.d.ts +28 -0
  195. package/lib/compiler/entitySource.js +529 -0
  196. package/lib/compiler/localeBuilder.d.ts +7 -2
  197. package/lib/compiler/localeBuilder.js +52 -56
  198. package/lib/compiler/routerBuilder.d.ts +32 -3
  199. package/lib/compiler/routerBuilder.js +160 -48
  200. package/lib/compiler/schemaBuilder.d.ts +12 -2
  201. package/lib/compiler/schemaBuilder.js +855 -350
  202. package/lib/compiler/tscBuilder.d.ts +20 -2
  203. package/lib/compiler/tscBuilder.js +217 -37
  204. package/lib/context/BackendRuntimeContext.d.ts +6 -4
  205. package/lib/context/BackendRuntimeContext.js +10 -3
  206. package/lib/context/ContextComposer.d.ts +93 -0
  207. package/lib/context/ContextComposer.js +361 -0
  208. package/lib/context/SerializedData.d.ts +2 -1
  209. package/lib/data/i18n.d.ts +1 -1
  210. package/lib/data/i18n.js +1 -86
  211. package/lib/data/i18n.json +86 -0
  212. package/lib/entities/ActionAuth.d.ts +3 -3
  213. package/lib/entities/I18n.d.ts +2 -2
  214. package/lib/entities/LocalizedContent.d.ts +22 -0
  215. package/lib/entities/LocalizedContent.js +104 -0
  216. package/lib/entities/Log.d.ts +3 -3
  217. package/lib/entities/Modi.d.ts +2 -2
  218. package/lib/entities/ModiEntity.d.ts +3 -3
  219. package/lib/entities/Oper.d.ts +5 -5
  220. package/lib/entities/OperEntity.d.ts +3 -3
  221. package/lib/entities/Path.d.ts +2 -2
  222. package/lib/entities/Relation.d.ts +2 -2
  223. package/lib/entities/RelationAuth.d.ts +3 -3
  224. package/lib/entities/User.d.ts +4 -4
  225. package/lib/entities/UserEntityClaim.d.ts +6 -6
  226. package/lib/entities/UserEntityGrant.d.ts +2 -2
  227. package/lib/entities/UserRelation.d.ts +4 -4
  228. package/lib/store/AsyncRowStore.d.ts +2 -2
  229. package/lib/store/AsyncRowStore.js +6 -7
  230. package/lib/store/CascadeStore.d.ts +5 -3
  231. package/lib/store/CascadeStore.js +101 -70
  232. package/lib/store/IntrinsicCheckers.d.ts +1 -1
  233. package/lib/store/IntrinsicCheckers.js +12 -13
  234. package/lib/store/IntrinsicLogics.d.ts +1 -1
  235. package/lib/store/RelationAuth.js +42 -43
  236. package/lib/store/SyncRowStore.d.ts +1 -1
  237. package/lib/store/SyncRowStore.js +4 -5
  238. package/lib/store/TriggerExecutor.d.ts +6 -4
  239. package/lib/store/TriggerExecutor.js +39 -28
  240. package/lib/store/checker.d.ts +2 -2
  241. package/lib/store/checker.js +55 -20
  242. package/lib/store/filter.d.ts +3 -3
  243. package/lib/store/filter.js +47 -48
  244. package/lib/store/modi.d.ts +5 -5
  245. package/lib/store/modi.js +5 -6
  246. package/lib/store/projection.d.ts +1 -1
  247. package/lib/store/relation.js +4 -5
  248. package/lib/store/triggers.d.ts +4 -4
  249. package/lib/store/triggers.js +13 -14
  250. package/lib/timers/oper.d.ts +3 -3
  251. package/lib/timers/vaccum.d.ts +3 -3
  252. package/lib/types/Action.d.ts +1 -1
  253. package/lib/types/AppLoader.d.ts +1 -1
  254. package/lib/types/Aspect.d.ts +1 -1
  255. package/lib/types/Auth.d.ts +2 -2
  256. package/lib/types/Configuration.d.ts +7 -6
  257. package/lib/types/Connector.d.ts +47 -1
  258. package/lib/types/DataType.d.ts +2 -2
  259. package/lib/types/Demand.d.ts +40 -6
  260. package/lib/types/Endpoint.d.ts +17 -1
  261. package/lib/types/Entity.d.ts +21 -4
  262. package/lib/types/Entity.js +27 -0
  263. package/lib/types/EntityDesc.d.ts +9 -8
  264. package/lib/types/Environment.d.ts +17 -0
  265. package/lib/types/Exception.d.ts +1 -1
  266. package/lib/types/Exception.js +2 -2
  267. package/lib/types/Expression.d.ts +13 -2
  268. package/lib/types/Expression.js +40 -5
  269. package/lib/types/Locale.d.ts +14 -1
  270. package/lib/types/Locale.js +14 -0
  271. package/lib/types/OakPackage.d.ts +29 -0
  272. package/lib/types/OakPackage.js +36 -0
  273. package/lib/types/Port.d.ts +1 -1
  274. package/lib/types/RowStore.d.ts +9 -7
  275. package/lib/types/Storage.d.ts +11 -3
  276. package/lib/types/Storage.js +13 -0
  277. package/lib/types/Style.d.ts +2 -2
  278. package/lib/types/Sync.d.ts +3 -3
  279. package/lib/types/Timer.d.ts +14 -2
  280. package/lib/types/Trigger.d.ts +1 -1
  281. package/lib/types/Watcher.d.ts +1 -1
  282. package/lib/types/index.d.ts +1 -0
  283. package/lib/types/index.js +1 -0
  284. package/lib/utils/SimpleConnector.d.ts +30 -4
  285. package/lib/utils/SimpleConnector.js +297 -24
  286. package/lib/utils/concurrent.js +4 -5
  287. package/lib/utils/decimal.d.ts +26 -0
  288. package/lib/utils/decimal.js +112 -0
  289. package/lib/utils/fetch/index.d.ts +1 -0
  290. package/lib/utils/fetch/index.js +6 -0
  291. package/lib/utils/fetch/index.mp.d.ts +3 -0
  292. package/lib/utils/fetch/index.mp.js +285 -0
  293. package/lib/utils/fetch/index.native.d.ts +1 -0
  294. package/lib/utils/fetch/index.native.js +6 -0
  295. package/lib/utils/fetch/index.web.d.ts +1 -0
  296. package/lib/utils/fetch/index.web.js +6 -0
  297. package/lib/utils/fetch/shared.d.ts +6 -0
  298. package/lib/utils/fetch/shared.js +28 -0
  299. package/lib/utils/localizedContent.d.ts +11 -0
  300. package/lib/utils/localizedContent.js +352 -0
  301. package/lib/utils/lodash.d.ts +1 -35
  302. package/lib/utils/lodash.js +1 -76
  303. package/lib/utils/module/combine.common.d.ts +3 -3
  304. package/lib/utils/module/combine.common.js +6 -7
  305. package/lib/utils/module/combine.dev.d.ts +2 -2
  306. package/lib/utils/module/combine.dev.js +19 -19
  307. package/lib/utils/module/combine.prod.d.ts +1 -1
  308. package/lib/utils/module/combine.server.d.ts +2 -2
  309. package/lib/utils/module/combine.server.js +19 -19
  310. package/lib/utils/money.d.ts +2 -2
  311. package/lib/utils/money.js +2 -2
  312. package/lib/utils/operationResult.js +4 -4
  313. package/lib/utils/projection.d.ts +3 -3
  314. package/lib/utils/relationPath.d.ts +1 -1
  315. package/lib/utils/relationPath.js +10 -11
  316. package/lib/utils/row.d.ts +3 -3
  317. package/lib/utils/row.js +4 -5
  318. package/lib/utils/sseEndpoint.d.ts +41 -0
  319. package/lib/utils/sseEndpoint.js +156 -0
  320. package/lib/utils/toolkit.d.ts +28 -0
  321. package/lib/utils/toolkit.js +253 -0
  322. package/lib/utils/url/index.d.ts +1 -3
  323. package/lib/utils/url/index.js +3 -1
  324. package/lib/utils/url/index.mp.d.ts +16 -3
  325. package/lib/utils/url/index.mp.js +6 -4
  326. package/lib/utils/url/index.native.d.ts +13 -1
  327. package/lib/utils/url/index.native.js +5 -1
  328. package/lib/utils/url/index.web.d.ts +13 -1
  329. package/lib/utils/url/index.web.js +5 -1
  330. package/lib/utils/url/lightweight.d.ts +65 -0
  331. package/lib/utils/url/lightweight.js +535 -0
  332. package/lib/utils/url/urlObject.d.ts +16 -0
  333. package/lib/utils/url/urlObject.js +2 -0
  334. package/lib/utils/url/whatwg-url/lib/URL-impl.d.ts +8 -15
  335. package/lib/utils/url/whatwg-url/lib/infra.js +5 -4
  336. package/lib/utils/url/whatwg-url/lib/urlencoded.d.ts +3 -1
  337. package/lib/utils/url/whatwg-url/lib/utils.d.ts +1 -1
  338. package/lib/utils/validate/id.d.ts +5 -0
  339. package/lib/utils/validate/id.js +35 -0
  340. package/lib/utils/validate/index.d.ts +4 -0
  341. package/lib/utils/validate/index.js +7 -0
  342. package/lib/utils/validate/mobile.d.ts +6 -0
  343. package/lib/utils/validate/mobile.js +57 -0
  344. package/lib/utils/validate/nationality.d.ts +14 -0
  345. package/lib/utils/validate/nationality.data.d.ts +9 -0
  346. package/lib/utils/validate/nationality.data.js +260 -0
  347. package/lib/utils/validate/nationality.js +76 -0
  348. package/lib/utils/validate/passport.d.ts +3 -0
  349. package/lib/utils/validate/passport.js +24 -0
  350. package/lib/utils/validator.d.ts +10 -8
  351. package/lib/utils/validator.js +38 -42
  352. package/package.json +19 -9
  353. package/es/utils/url/whatwg-url/index.d.ts +0 -3
  354. package/es/utils/url/whatwg-url/index.js +0 -12
  355. package/es/utils/url/whatwg-url/lib/URL-impl.d.ts +0 -27
  356. package/es/utils/url/whatwg-url/lib/URL-impl.js +0 -172
  357. package/es/utils/url/whatwg-url/lib/URL.js +0 -295
  358. package/es/utils/url/whatwg-url/lib/URLSearchParams-impl.d.ts +0 -19
  359. package/es/utils/url/whatwg-url/lib/URLSearchParams-impl.js +0 -123
  360. package/es/utils/url/whatwg-url/lib/URLSearchParams.js +0 -423
  361. package/es/utils/url/whatwg-url/lib/infra.d.ts +0 -12
  362. package/es/utils/url/whatwg-url/lib/infra.js +0 -19
  363. package/es/utils/url/whatwg-url/lib/url-state-machine.d.ts +0 -24
  364. package/es/utils/url/whatwg-url/lib/url-state-machine.js +0 -1228
  365. package/es/utils/url/whatwg-url/lib/urlencoded.d.ts +0 -14
  366. package/es/utils/url/whatwg-url/lib/urlencoded.js +0 -160
  367. package/es/utils/url/whatwg-url/lib/utils.d.ts +0 -37
  368. package/es/utils/url/whatwg-url/lib/utils.js +0 -99
  369. package/lib/store/diffSchema.d.ts +0 -1
  370. package/lib/utils/url/whatwg-url/index.d.ts +0 -3
  371. package/lib/utils/url/whatwg-url/index.js +0 -16
  372. package/lib/utils/url/whatwg-url/lib/URL-impl.js +0 -175
  373. package/lib/utils/url/whatwg-url/lib/URL.d.ts +0 -1
  374. package/lib/utils/url/whatwg-url/lib/URL.js +0 -298
  375. package/lib/utils/url/whatwg-url/lib/URLSearchParams-impl.d.ts +0 -19
  376. package/lib/utils/url/whatwg-url/lib/URLSearchParams-impl.js +0 -126
  377. package/lib/utils/url/whatwg-url/lib/URLSearchParams.d.ts +0 -1
  378. package/lib/utils/url/whatwg-url/lib/URLSearchParams.js +0 -426
  379. package/lib/utils/url/whatwg-url/lib/infra.d.ts +0 -12
  380. package/lib/utils/url/whatwg-url/lib/url-state-machine.d.ts +0 -24
  381. package/lib/utils/url/whatwg-url/lib/url-state-machine.js +0 -1238
  382. package/lib/utils/url/whatwg-url/lib/urlencoded.js +0 -162
  383. package/lib/utils/url/whatwg-url/lib/utils.js +0 -101
  384. package/src/entities/ActionAuth.ts +0 -50
  385. package/src/entities/I18n.ts +0 -53
  386. package/src/entities/Log.ts +0 -62
  387. package/src/entities/Modi.ts +0 -107
  388. package/src/entities/ModiEntity.ts +0 -35
  389. package/src/entities/Oper.ts +0 -115
  390. package/src/entities/OperEntity.ts +0 -36
  391. package/src/entities/Path.ts +0 -56
  392. package/src/entities/Relation.ts +0 -53
  393. package/src/entities/RelationAuth.ts +0 -53
  394. package/src/entities/User.ts +0 -85
  395. package/src/entities/UserEntityClaim.ts +0 -41
  396. package/src/entities/UserEntityGrant.ts +0 -33
  397. package/src/entities/UserRelation.ts +0 -60
  398. /package/es/{utils/url/whatwg-url/lib/URL.d.ts → base-app-domain/LocalizedContent/_baseSchema.js} +0 -0
  399. /package/es/utils/url/{whatwg-url/lib/URLSearchParams.d.ts → urlObject.js} +0 -0
  400. /package/lib/{store/diffSchema.js → base-app-domain/LocalizedContent/_baseSchema.js} +0 -0
@@ -2,14 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RelationAuth = void 0;
4
4
  exports.getUserRelationsByActions = getUserRelationsByActions;
5
- const tslib_1 = require("tslib");
6
- const assert_1 = tslib_1.__importDefault(require("assert"));
5
+ const assert_1 = require("../utils/assert");
7
6
  const types_1 = require("../types");
8
7
  const AsyncRowStore_1 = require("./AsyncRowStore");
9
8
  const filter_1 = require("./filter");
10
9
  const relation_1 = require("./relation");
11
10
  const action_1 = require("../actions/action");
12
- const lodash_1 = require("../utils/lodash");
11
+ const toolkit_1 = require("../utils/toolkit");
13
12
  const entities_1 = require("../compiler/entities");
14
13
  const relationPath_1 = require("../utils/relationPath");
15
14
  class RelationAuth {
@@ -90,7 +89,7 @@ class RelationAuth {
90
89
  }, { dontCollect: true });
91
90
  const checkRelationAuth = (relationAuth) => {
92
91
  const { destRelation, sourceRelationId, path } = relationAuth;
93
- (0, assert_1.default)(entity === destRelation.entity);
92
+ (0, assert_1.assert)(entity === destRelation.entity);
94
93
  let destEntityFilter = this.makePathFilter(entity, path, this.schema, {
95
94
  userRelation$entity: {
96
95
  userId,
@@ -106,7 +105,7 @@ class RelationAuth {
106
105
  };
107
106
  if (relationAuths instanceof Promise) {
108
107
  return relationAuths.then((ras) => Promise.all(ras.map(ra => checkRelationAuth(ra)))).then((result) => !!result.find(ele => {
109
- (0, assert_1.default)(typeof ele === 'number');
108
+ (0, assert_1.assert)(typeof ele === 'number');
110
109
  return ele > 0;
111
110
  }));
112
111
  }
@@ -146,7 +145,7 @@ class RelationAuth {
146
145
  entity2 = rs[0]?.entity;
147
146
  }
148
147
  else {
149
- (0, assert_1.default)(entity2 === rs[0]?.entity);
148
+ (0, assert_1.assert)(entity2 === rs[0]?.entity);
150
149
  }
151
150
  return rs.map(ele => ele.id);
152
151
  });
@@ -155,14 +154,14 @@ class RelationAuth {
155
154
  entity2 = relations[0]?.entity;
156
155
  }
157
156
  else if (relations.length) {
158
- (0, assert_1.default)(entity2 === relations[0]?.entity);
157
+ (0, assert_1.assert)(entity2 === relations[0]?.entity);
159
158
  }
160
159
  return relations.map(ele => ele.id);
161
160
  };
162
161
  const relationIds = getRelationIds();
163
162
  if (relationIds instanceof Promise) {
164
163
  return relationIds.then((ids) => {
165
- (0, assert_1.default)(ids.length > 0);
164
+ (0, assert_1.assert)(ids.length > 0);
166
165
  return Promise.all(ids.map(ele => checkOnRelationId(entity2, ele, entityFilter))).then((value) => {
167
166
  if (intersection) {
168
167
  return !(value.includes(false));
@@ -184,7 +183,7 @@ class RelationAuth {
184
183
  };
185
184
  if (action === 'create') {
186
185
  const { entity, entityId, relationId } = filter;
187
- (0, assert_1.default)(typeof entity === 'string');
186
+ (0, assert_1.assert)(typeof entity === 'string');
188
187
  let entityFilter;
189
188
  if (entityId) {
190
189
  entityFilter = {
@@ -204,7 +203,7 @@ class RelationAuth {
204
203
  // 否则为测试“能否”有权限管理的资格,此时只要有一个就可以
205
204
  // 这是为上层的menu所有,真正的创建不可能走到这里
206
205
  // bug fixed,目前框架不支持entityId为null,所以这里暂时只支持entityId一种方式的测试
207
- (0, assert_1.default)(entityId);
206
+ (0, assert_1.assert)(entityId);
208
207
  return checkOnMultipleRelations({
209
208
  entity,
210
209
  $or: [
@@ -221,7 +220,7 @@ class RelationAuth {
221
220
  }
222
221
  }
223
222
  else {
224
- (0, assert_1.default)(action === 'remove');
223
+ (0, assert_1.assert)(action === 'remove');
225
224
  // 有可能是删除多个userRelation,这时必须检查每一个relation都有对应的权限(有一个不能删除那就不能删除)
226
225
  return checkOnMultipleRelations({
227
226
  userRelation$relation: filter,
@@ -233,7 +232,7 @@ class RelationAuth {
233
232
  checkOperateSpecialEntities2(entity2, action, filter, context) {
234
233
  switch (entity2) {
235
234
  case 'userRelation': {
236
- (0, assert_1.default)(!(filter instanceof Array));
235
+ (0, assert_1.assert)(!(filter instanceof Array));
237
236
  return this.checkUserRelation(context, action, filter);
238
237
  }
239
238
  case 'user': {
@@ -253,7 +252,7 @@ class RelationAuth {
253
252
  * 但是有些例外,如extraFile如果在modi中创建,上传成功之后需要显式生成一条modi,这时对modi的
254
253
  * 检查可以转化为对其父entity的update权限检查
255
254
  */
256
- (0, assert_1.default)(action === 'create');
255
+ (0, assert_1.assert)(action === 'create');
257
256
  const { entity, entityId } = filter;
258
257
  return this.checkOperation(entity, {
259
258
  action: 'update',
@@ -289,7 +288,7 @@ class RelationAuth {
289
288
  return true;
290
289
  }
291
290
  default: {
292
- (0, assert_1.default)(false, `对象${entity2}的权限控制没有加以控制`);
291
+ (0, assert_1.assert)(false, `对象${entity2}的权限控制没有加以控制`);
293
292
  }
294
293
  }
295
294
  }
@@ -302,7 +301,7 @@ class RelationAuth {
302
301
  }
303
302
  ];
304
303
  if (this.authDeduceRelationMap[entity]) {
305
- (0, assert_1.default)(this.authDeduceRelationMap[entity] === 'entity');
304
+ (0, assert_1.assert)(this.authDeduceRelationMap[entity] === 'entity');
306
305
  let { entity: deduceEntity, entityId: deduceEntityId } = filter;
307
306
  let deduceFilter = {};
308
307
  if (deduceEntity && deduceEntityId) {
@@ -311,7 +310,7 @@ class RelationAuth {
311
310
  else {
312
311
  // 也可能是用cascade方式进行查找,这里有时候filter上会带有两个不同的entity目标,尚未处理(todo!)
313
312
  const { ref } = this.schema[entity].attributes.entity;
314
- (0, assert_1.default)(ref instanceof Array);
313
+ (0, assert_1.assert)(ref instanceof Array);
315
314
  for (const refEntity of ref) {
316
315
  if (filter[refEntity]) {
317
316
  deduceEntity = refEntity;
@@ -458,7 +457,7 @@ class RelationAuth {
458
457
  const refineFilter = (entity, originFilter) => {
459
458
  let filter2 = {};
460
459
  for (const attr in originFilter) {
461
- if (['$and', '$or'].includes(attr)) {
460
+ if (['$and', '$or', '$xor'].includes(attr)) {
462
461
  const refined = originFilter[attr].map((f) => refineFilter(entity, f)).filter((ele) => !!ele);
463
462
  if (refined.length > 1) {
464
463
  filter2[attr] = refined;
@@ -519,7 +518,7 @@ class RelationAuth {
519
518
  if (rel instanceof Array) {
520
519
  const [e, foreignKey] = rel;
521
520
  if (foreignKey) {
522
- (0, assert_1.default)(!this.authDeduceRelationMap[e]);
521
+ (0, assert_1.assert)(!this.authDeduceRelationMap[e]);
523
522
  hasOneToMany = true;
524
523
  const { data: subProjection, filter: subFilter } = projection2[attr];
525
524
  const refinedSubFilter = subFilter && refineFilter(e, subFilter);
@@ -537,7 +536,7 @@ class RelationAuth {
537
536
  }]));
538
537
  }
539
538
  else {
540
- (0, assert_1.default)(this.authDeduceRelationMap[e] === 'entity');
539
+ (0, assert_1.assert)(this.authDeduceRelationMap[e] === 'entity');
541
540
  }
542
541
  }
543
542
  }
@@ -566,7 +565,7 @@ class RelationAuth {
566
565
  */
567
566
  const makeCreateFilter = (entity, operation) => {
568
567
  const { data, filter, bornAt } = operation;
569
- (0, assert_1.default)(!(data instanceof Array));
568
+ (0, assert_1.assert)(!(data instanceof Array));
570
569
  if (data) {
571
570
  return (0, filter_1.translateCreateDataToFilter)(this.schema, entity, data, !!bornAt);
572
571
  }
@@ -575,9 +574,9 @@ class RelationAuth {
575
574
  const addChild = (node, path, child) => {
576
575
  // 在这里要把可以被node deduce出来的child处理掉
577
576
  const paths = path.split('$');
578
- (0, assert_1.default)(paths.length >= 2);
577
+ (0, assert_1.assert)(paths.length >= 2);
579
578
  if (this.authDeduceRelationMap[child.entity] === paths[1]) {
580
- (0, assert_1.default)(paths[1] === 'entity', '当前只支持entity外键上的deduce');
579
+ (0, assert_1.assert)(paths[1] === 'entity', '当前只支持entity外键上的deduce');
581
580
  return false;
582
581
  }
583
582
  if (node.children[path]) {
@@ -599,8 +598,8 @@ class RelationAuth {
599
598
  // extraFilter?: ED[T2]['Filter'],
600
599
  path, child, hasParent, extraFilter) => {
601
600
  const { action, data, filter } = operation;
602
- const filter2 = action === 'create' ? makeCreateFilter(entity, operation) : filter ? (0, lodash_1.cloneDeep)(filter) : {};
603
- (0, assert_1.default)(filter2);
601
+ const filter2 = action === 'create' ? makeCreateFilter(entity, operation) : filter ? (0, toolkit_1.cloneDeep)(filter) : {};
602
+ (0, assert_1.assert)(filter2);
604
603
  if (extraFilter) {
605
604
  Object.assign(filter2, extraFilter);
606
605
  }
@@ -617,19 +616,19 @@ class RelationAuth {
617
616
  // 这里可能有问题,再思考思考 by Xc 20231111
618
617
  const isModiUpdate = this.schema[entity].toModi && action !== 'remove';
619
618
  if (child) {
620
- (0, assert_1.default)(path);
619
+ (0, assert_1.assert)(path);
621
620
  addChild(me, path, child);
622
621
  }
623
- (0, assert_1.default)(!(data instanceof Array));
622
+ (0, assert_1.assert)(!(data instanceof Array));
624
623
  for (const attr in data) {
625
624
  const rel = (0, relation_1.judgeRelation)(this.schema, entity, attr, !!operation.bornAt);
626
625
  if (rel === 2 && !isModiUpdate) {
627
- (0, assert_1.default)(root === me && !hasParent, 'cascadeUpdate必须是树结构,避免森林');
626
+ (0, assert_1.assert)(root === me && !hasParent, 'cascadeUpdate必须是树结构,避免森林');
628
627
  const mtoOperation = data[attr];
629
628
  root = destructInner(attr, mtoOperation, `${entity}$entity`, me);
630
629
  }
631
630
  else if (typeof rel === 'string' && !isModiUpdate) {
632
- (0, assert_1.default)(root === me && !hasParent, 'cascadeUpdate必须是树结构,避免森林');
631
+ (0, assert_1.assert)(root === me && !hasParent, 'cascadeUpdate必须是树结构,避免森林');
633
632
  root = destructInner(rel, data[attr], `${entity}$${attr}`, me);
634
633
  }
635
634
  else if (rel instanceof Array && !isModiUpdate) {
@@ -651,11 +650,11 @@ class RelationAuth {
651
650
  const { action, data } = userRelation;
652
651
  if (action === 'create') {
653
652
  const attrs = Object.keys(data);
654
- (0, assert_1.default)((0, lodash_1.difference)(attrs, Object.keys(this.schema.userRelation.attributes).concat('id')).length === 0);
653
+ (0, assert_1.assert)((0, toolkit_1.difference)(attrs, Object.keys(this.schema.userRelation.attributes).concat('id')).length === 0);
655
654
  if (data.userId === userId) {
656
655
  me.userRelations?.push(data);
657
656
  }
658
- (0, assert_1.default)(filter2.id);
657
+ (0, assert_1.assert)(filter2.id);
659
658
  }
660
659
  };
661
660
  if (otmOperations instanceof Array) {
@@ -684,7 +683,7 @@ class RelationAuth {
684
683
  makePathFilter(entity, path, schema, filter) {
685
684
  const { value, recursive } = path;
686
685
  if (value === '') {
687
- (0, assert_1.default)(!recursive);
686
+ (0, assert_1.assert)(!recursive);
688
687
  return filter;
689
688
  }
690
689
  const paths = value.split('.');
@@ -710,7 +709,7 @@ class RelationAuth {
710
709
  else {
711
710
  // 在最后一个对象上存在递归,用or连接处理
712
711
  const { recursiveDepth } = schema[e2];
713
- (0, assert_1.default)(recursiveDepth > 0);
712
+ (0, assert_1.assert)(recursiveDepth > 0);
714
713
  return makeRecursiveFilter(recursiveDepth);
715
714
  }
716
715
  }
@@ -724,7 +723,7 @@ class RelationAuth {
724
723
  e3 = rel;
725
724
  }
726
725
  else {
727
- (0, assert_1.default)(rel instanceof Array);
726
+ (0, assert_1.assert)(rel instanceof Array);
728
727
  e3 = rel[0];
729
728
  }
730
729
  const f = makeInner(idx + 1, e3);
@@ -751,7 +750,7 @@ class RelationAuth {
751
750
  if (relation) {
752
751
  const { userRelation$relation: userRelations } = relation;
753
752
  if (userRelations.length > 0) {
754
- const entityIds = (0, lodash_1.uniq)(userRelations.map(ele => ele.entityId));
753
+ const entityIds = (0, toolkit_1.uniq)(userRelations.map(ele => ele.entityId));
755
754
  const pathFilter = this.makePathFilter(entity, path, this.schema, {
756
755
  id: entityIds.length > 0 ? {
757
756
  $in: entityIds,
@@ -834,10 +833,10 @@ class RelationAuth {
834
833
  const dlSelections = dlSelections2.filter((ele) => {
835
834
  const entities = ele.map(ele2 => ele2.entity);
836
835
  // 同一个leaf的deducedSelections中只要有一个能通过就足够了
837
- if ((0, lodash_1.intersection)(this.selectFreeEntities, entities).length > 0) {
836
+ if ((0, toolkit_1.intersection)(this.selectFreeEntities, entities).length > 0) {
838
837
  return false;
839
838
  }
840
- if ((0, lodash_1.intersection)(RelationAuth.SPECIAL_ENTITIES, entities).length > 0) {
839
+ if ((0, toolkit_1.intersection)(RelationAuth.SPECIAL_ENTITIES, entities).length > 0) {
841
840
  // todo
842
841
  return false;
843
842
  }
@@ -899,7 +898,7 @@ class RelationAuth {
899
898
  return true;
900
899
  };
901
900
  if (actionAuths instanceof Promise) {
902
- (0, assert_1.default)(context instanceof AsyncRowStore_1.AsyncContext);
901
+ (0, assert_1.assert)(context instanceof AsyncRowStore_1.AsyncContext);
903
902
  return actionAuths.then((aas) => Promise.all(dlSelections.map((ele) => Promise.all(ele.map((ele2) => this.checkActionAuthInGroup(ele2.entity, ele2.filter, aas, context))))).then((result) => checkResult(result)));
904
903
  }
905
904
  return checkResult(dlSelections.map(ele => ele.map(
@@ -921,7 +920,7 @@ class RelationAuth {
921
920
  */
922
921
  findActionAuthsOnNode(node, context) {
923
922
  const { entity, filter, action, userRelations } = node;
924
- (0, assert_1.default)(filter);
923
+ (0, assert_1.assert)(filter);
925
924
  const deducedEntityFilters2 = this.getDeducedEntityFilters(entity, filter, [action], context);
926
925
  /**
927
926
  * 搜索判定是否允许自建对象,自建的条件是 path = '',destEntity === entity
@@ -949,7 +948,7 @@ class RelationAuth {
949
948
  }
950
949
  if (unspecicalEntities.length > 0) {
951
950
  const allEntities = unspecicalEntities.map(ele => ele.entity);
952
- const allActions = (0, lodash_1.uniq)(unspecicalEntities.map(ele => ele.actions).flat());
951
+ const allActions = (0, toolkit_1.uniq)(unspecicalEntities.map(ele => ele.actions).flat());
953
952
  // @oak-ignore
954
953
  const actionAuths2 = context.select('actionAuth', {
955
954
  data: {
@@ -1001,7 +1000,7 @@ class RelationAuth {
1001
1000
  return true;
1002
1001
  }
1003
1002
  const result = deducedEntityFilters.map((ele) => {
1004
- const ars2 = actionAuths.filter(ele2 => ele2.path.destEntity === ele.entity && (0, lodash_1.intersection)(ele2.deActions, ele.actions).length > 0 // 这里只要overlap就可以了
1003
+ const ars2 = actionAuths.filter(ele2 => ele2.path.destEntity === ele.entity && (0, toolkit_1.intersection)(ele2.deActions, ele.actions).length > 0 // 这里只要overlap就可以了
1005
1004
  );
1006
1005
  const ars3 = this.filterActionAuths(ele.entity, ele.filter, ars2, context);
1007
1006
  const checkFilteredArs = (actionAuths2) => {
@@ -1066,7 +1065,7 @@ class RelationAuth {
1066
1065
  const childEntity = child instanceof Array ? child[0].entity : child.entity;
1067
1066
  // 这里如果该子结点能deduce到父,则直接通过
1068
1067
  if (this.authDeduceRelationMap[childEntity]) {
1069
- (0, assert_1.default)(this.authDeduceRelationMap[childEntity] === 'entity');
1068
+ (0, assert_1.assert)(this.authDeduceRelationMap[childEntity] === 'entity');
1070
1069
  const rel = (0, relation_1.judgeRelation)(this.schema, childEntity, childPath);
1071
1070
  if (rel === 2) {
1072
1071
  return true;
@@ -1300,7 +1299,7 @@ async function getUserRelationsByActions(params, context) {
1300
1299
  urAuthDict2[value] = [[relationId], recursive];
1301
1300
  }
1302
1301
  else if (!urAuthDict2[value][0].includes(relationId)) {
1303
- (0, assert_1.default)(urAuthDict2[value][1] === recursive);
1302
+ (0, assert_1.assert)(urAuthDict2[value][1] === recursive);
1304
1303
  urAuthDict2[value][0].push(relationId);
1305
1304
  }
1306
1305
  });
@@ -1323,7 +1322,7 @@ async function getUserRelationsByActions(params, context) {
1323
1322
  const getDirectUserEntities = async (directAuths) => {
1324
1323
  const userEntities = await Promise.all(directAuths.map(async ({ path }) => {
1325
1324
  const { value, recursive } = path;
1326
- (0, assert_1.default)(!recursive);
1325
+ (0, assert_1.assert)(!recursive);
1327
1326
  const { getData, projection } = (0, relationPath_1.destructDirectUserPath)(context.getSchema(), entity, value);
1328
1327
  const rows = await context.select(entity, {
1329
1328
  data: projection,
@@ -1,5 +1,5 @@
1
1
  import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, TxnOption, Context, AggregationResult } from "../types";
2
- import { EntityDict as BaseEntityDict } from '../base-app-domain';
2
+ import { EntityDict as BaseEntityDict } from "../base-app-domain";
3
3
  export declare abstract class SyncContext<ED extends EntityDict & BaseEntityDict> implements Context {
4
4
  rowStore: SyncRowStore<ED, this>;
5
5
  private uuid?;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SyncContext = void 0;
4
- const tslib_1 = require("tslib");
5
- const assert_1 = tslib_1.__importDefault(require("assert"));
4
+ const assert_1 = require("../utils/assert");
6
5
  class SyncContext {
7
6
  rowStore;
8
7
  uuid;
@@ -10,16 +9,16 @@ class SyncContext {
10
9
  this.rowStore = rowStore;
11
10
  }
12
11
  begin(option) {
13
- (0, assert_1.default)(!this.uuid, '事务不允许嵌套');
12
+ (0, assert_1.assert)(!this.uuid, '事务不允许嵌套');
14
13
  this.uuid = this.rowStore.begin(option);
15
14
  }
16
15
  commit() {
17
- (0, assert_1.default)(this.uuid);
16
+ (0, assert_1.assert)(this.uuid);
18
17
  this.rowStore.commit(this.uuid);
19
18
  this.uuid = undefined;
20
19
  }
21
20
  rollback() {
22
- (0, assert_1.default)(this.uuid);
21
+ (0, assert_1.assert)(this.uuid);
23
22
  this.rowStore.rollback(this.uuid);
24
23
  this.uuid = undefined;
25
24
  }
@@ -1,10 +1,10 @@
1
1
  import { EntityDict, OperateOption, SelectOption } from "../types/Entity";
2
- import { EntityDict as BaseEntityDict } from '../base-app-domain';
2
+ import { EntityDict as BaseEntityDict } from "../base-app-domain";
3
3
  import { Logger } from "../types/Logger";
4
- import { Checker } from '../types/Auth';
4
+ import { Checker } from "../types/Auth";
5
5
  import { Trigger, VolatileTrigger } from "../types/Trigger";
6
- import { AsyncContext } from './AsyncRowStore';
7
- import { StorageSchema } from '../types';
6
+ import { AsyncContext } from "./AsyncRowStore";
7
+ import { StorageSchema } from "../types";
8
8
  /**
9
9
  * update可能会传入多种不同的action,此时都需要检查update trigger
10
10
  */
@@ -13,12 +13,14 @@ export declare class TriggerExecutor<ED extends EntityDict & BaseEntityDict, Cxt
13
13
  private triggerMap;
14
14
  private triggerNameMap;
15
15
  private volatileEntities;
16
+ private checkerTriggerMap;
16
17
  private logger;
17
18
  private contextBuilder;
18
19
  private onVolatileTrigger;
19
20
  constructor(contextBuilder: () => Cxt, logger?: Logger, onVolatileTrigger?: <T extends keyof ED>(entity: T, trigger: VolatileTrigger<ED, T, Cxt>, ids: string[], cxtStr: string, option: OperateOption) => Promise<void>);
20
21
  setOnVolatileTrigger(onVolatileTrigger: <T extends keyof ED>(entity: T, trigger: VolatileTrigger<ED, T, Cxt>, ids: string[], cxtStr: string, option: OperateOption) => Promise<void>): void;
21
22
  registerChecker<T extends keyof ED>(checker: Checker<ED, T, Cxt>, schema: StorageSchema<ED>): void;
23
+ unregisterChecker<T extends keyof ED>(checker: Checker<ED, T, Cxt>): boolean;
22
24
  registerTrigger<T extends keyof ED>(trigger: Trigger<ED, T, Cxt>): void;
23
25
  unregisterTrigger<T extends keyof ED>(trigger: Trigger<ED, T, Cxt>): void;
24
26
  private preCommitTrigger;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TriggerExecutor = void 0;
4
- const tslib_1 = require("tslib");
5
- const assert_1 = tslib_1.__importDefault(require("assert"));
6
- const lodash_1 = require("../utils/lodash");
4
+ const assert_1 = require("../utils/assert");
5
+ const toolkit_1 = require("../utils/toolkit");
7
6
  const filter_1 = require("../store/filter");
8
7
  const Entity_1 = require("../types/Entity");
9
8
  const Trigger_1 = require("../types/Trigger");
@@ -28,6 +27,7 @@ class TriggerExecutor {
28
27
  triggerMap;
29
28
  triggerNameMap;
30
29
  volatileEntities;
30
+ checkerTriggerMap;
31
31
  logger;
32
32
  contextBuilder;
33
33
  onVolatileTrigger;
@@ -37,6 +37,7 @@ class TriggerExecutor {
37
37
  this.triggerMap = {};
38
38
  this.triggerNameMap = {};
39
39
  this.volatileEntities = [];
40
+ this.checkerTriggerMap = new WeakMap();
40
41
  this.counter = 0;
41
42
  this.onVolatileTrigger = onVolatileTrigger || (async (entity, trigger, ids, cxtStr, option) => {
42
43
  const context = this.contextBuilder();
@@ -79,8 +80,18 @@ class TriggerExecutor {
79
80
  mt,
80
81
  filter: checker.conditionalFilter,
81
82
  };
83
+ this.checkerTriggerMap.set(checker, trigger);
82
84
  this.registerTrigger(trigger);
83
85
  }
86
+ unregisterChecker(checker) {
87
+ const trigger = this.checkerTriggerMap.get(checker);
88
+ if (!trigger) {
89
+ return false;
90
+ }
91
+ this.unregisterTrigger(trigger);
92
+ this.checkerTriggerMap.delete(checker);
93
+ return true;
94
+ }
84
95
  /* getCheckers<T extends keyof ED>(entity: T, action: ED[T]['Action'], checkerTypes?: CheckerType[]) {
85
96
  const triggers = this.triggerMap[entity] && this.triggerMap[entity]![action]?.filter(
86
97
  trigger => (typeof trigger.action === 'string' && trigger.action === action || trigger.action instanceof Array && trigger.action.includes(action as any)
@@ -97,12 +108,12 @@ class TriggerExecutor {
97
108
  trigger.priority = Trigger_1.TRIGGER_DEFAULT_PRIORITY; // 默认值
98
109
  }
99
110
  else {
100
- (0, assert_1.default)(trigger.priority <= Trigger_1.CHECKER_MAX_PRIORITY && trigger.priority >= Trigger_1.TRIGGER_MIN_PRIORITY, `trigger「${trigger.name}」的优先级定义越界,应该在${Trigger_1.TRIGGER_MIN_PRIORITY}到${Trigger_1.CHECKER_MAX_PRIORITY}之间`);
111
+ (0, assert_1.assert)(trigger.priority <= Trigger_1.CHECKER_MAX_PRIORITY && trigger.priority >= Trigger_1.TRIGGER_MIN_PRIORITY, `trigger「${trigger.name}」的优先级定义越界,应该在${Trigger_1.TRIGGER_MIN_PRIORITY}到${Trigger_1.CHECKER_MAX_PRIORITY}之间`);
101
112
  }
102
113
  if (trigger.filter) {
103
- (0, assert_1.default)(typeof trigger.action === 'string' && trigger.action !== 'create'
114
+ (0, assert_1.assert)(typeof trigger.action === 'string' && trigger.action !== 'create'
104
115
  || trigger.action instanceof Array && !trigger.action.includes('create'), `trigger【${trigger.name}】是create类型但却带有filter`);
105
- (0, assert_1.default)(trigger.when === 'before' || trigger.when === 'commit', `定义了filter的trigger【${trigger.name}】的when只能是before或者commit`);
116
+ (0, assert_1.assert)(trigger.when === 'before' || trigger.when === 'commit', `定义了filter的trigger【${trigger.name}】的when只能是before或者commit`);
106
117
  }
107
118
  if (Array.isArray(trigger.action)) {
108
119
  const actions = trigger.action;
@@ -113,7 +124,7 @@ class TriggerExecutor {
113
124
  seen.add(item);
114
125
  return false;
115
126
  });
116
- (0, assert_1.default)(!duplicate, `注册 trigger 「${trigger.name}」 时发现定义中出现了重复定义的action: 「${duplicate}」`);
127
+ (0, assert_1.assert)(!duplicate, `注册 trigger 「${trigger.name}」 时发现定义中出现了重复定义的action: 「${duplicate}」`);
117
128
  }
118
129
  Object.assign(this.triggerNameMap, {
119
130
  [trigger.name]: trigger,
@@ -156,12 +167,12 @@ class TriggerExecutor {
156
167
  }
157
168
  }
158
169
  unregisterTrigger(trigger) {
159
- (0, assert_1.default)(trigger.when !== 'commit' || trigger.strict !== 'makeSure', 'could not remove strict volatile triggers');
170
+ (0, assert_1.assert)(trigger.when !== 'commit' || trigger.strict !== 'makeSure', 'could not remove strict volatile triggers');
160
171
  const removeTrigger = (action) => {
161
172
  const triggers = this.triggerMap[trigger.entity] && this.triggerMap[trigger.entity][action];
162
173
  if (triggers) {
163
- (0, lodash_1.pull)(triggers, trigger);
164
- (0, lodash_1.unset)(this.triggerNameMap, trigger.name);
174
+ (0, toolkit_1.pull)(triggers, trigger);
175
+ delete this.triggerNameMap[trigger.name];
165
176
  }
166
177
  };
167
178
  if (typeof trigger.action === 'string') {
@@ -172,8 +183,8 @@ class TriggerExecutor {
172
183
  }
173
184
  }
174
185
  async preCommitTrigger(entity, operation, trigger, context, option) {
175
- (0, assert_1.default)(trigger.action !== 'select');
176
- (0, assert_1.default)(trigger.when === 'commit');
186
+ (0, assert_1.assert)(trigger.action !== 'select');
187
+ (0, assert_1.assert)(trigger.when === 'commit');
177
188
  if (trigger.strict === 'makeSure') {
178
189
  const uuid = await (0, uuid_1.generateNewIdAsync)();
179
190
  const cxtStr = await context.toString();
@@ -271,7 +282,7 @@ class TriggerExecutor {
271
282
  if (record) {
272
283
  // 目前框架在operation时,一定会将ids记录在operation当中(见CascadeStore中的doUpdateSingleRowAsync函数
273
284
  // 但也有一种可能,此operation没有更新任何一行。by Xc 20241022
274
- (0, assert_1.default)(record.a !== 'c');
285
+ (0, assert_1.assert)(record.a !== 'c');
275
286
  const { f } = record;
276
287
  ids = f.id.$in;
277
288
  }
@@ -297,16 +308,16 @@ class TriggerExecutor {
297
308
  continue;
298
309
  }
299
310
  // 如果有attributes限制,则判断当前operation中data是否包含这些属性,没有任何属性被包含在内则跳过
300
- if (trigger.attributes && (0, lodash_1.intersection)(trigger.attributes, Object.keys(operation.data)).length === 0) {
311
+ if (trigger.attributes && (0, toolkit_1.intersection)(trigger.attributes, Object.keys(operation.data)).length === 0) {
301
312
  process.env.NODE_ENV !== 'production' && this.logger.info(`前触发器「${trigger.name}」未包含任何属性,跳过执行`);
302
313
  continue; // 不包含所有属性,跳过
303
314
  }
304
315
  if (trigger.filter) {
305
316
  // trigger只对满足条件的前项进行判断,如果确定不满足可以pass
306
- (0, assert_1.default)(operation.action !== 'create');
317
+ (0, assert_1.assert)(operation.action !== 'create');
307
318
  const { filter } = trigger;
308
319
  const filterr = typeof filter === 'function' ? filter(operation, context, option) : filter;
309
- (0, assert_1.default)(!(filterr instanceof Promise));
320
+ (0, assert_1.assert)(!(filterr instanceof Promise));
310
321
  // @oak-ignore
311
322
  const filterRepelled = (0, filter_1.checkFilterRepel)(entity, context, filterr, operation.filter);
312
323
  if (filterRepelled) {
@@ -318,7 +329,7 @@ class TriggerExecutor {
318
329
  this.logger.info(`前触发器「${trigger.name}」成功触发了「${number}」行数据更改`);
319
330
  }
320
331
  }
321
- (0, assert_1.default)(commitTriggers.length === 0, `前台不应有commitTrigger`);
332
+ (0, assert_1.assert)(commitTriggers.length === 0, `前台不应有commitTrigger`);
322
333
  }
323
334
  else {
324
335
  // 异步context
@@ -332,12 +343,12 @@ class TriggerExecutor {
332
343
  return execPreTrigger(idx + 1);
333
344
  }
334
345
  // 如果有attributes限制,则判断当前operation中data是否包含这些属性,没有任何属性被包含在内则跳过
335
- if (trigger.attributes && (0, lodash_1.intersection)(trigger.attributes, Object.keys(operation.data)).length === 0) {
346
+ if (trigger.attributes && (0, toolkit_1.intersection)(trigger.attributes, Object.keys(operation.data)).length === 0) {
336
347
  process.env.NODE_ENV !== 'production' && this.logger.info(`前触发器「${trigger.name}」未包含任何属性,跳过执行`);
337
348
  return execPreTrigger(idx + 1);
338
349
  }
339
350
  if (trigger.filter) {
340
- (0, assert_1.default)(operation.action !== 'create');
351
+ (0, assert_1.assert)(operation.action !== 'create');
341
352
  const { filter } = trigger;
342
353
  const filterr = typeof filter === 'function' ? await filter(operation, context, option) : filter;
343
354
  const filterRepelled = await (0, filter_1.checkFilterRepel)(entity, context, filterr, operation.filter);
@@ -363,19 +374,19 @@ class TriggerExecutor {
363
374
  if (idx >= commitTriggers.length) {
364
375
  return;
365
376
  }
366
- (0, assert_1.default)(!action_1.readOnlyActions.includes(operation.action), '当前应该不支持select的跨事务trigger');
377
+ (0, assert_1.assert)(!action_1.readOnlyActions.includes(operation.action), '当前应该不支持select的跨事务trigger');
367
378
  const trigger = commitTriggers[idx];
368
379
  if (trigger.check && !trigger.check(operation)) {
369
380
  process.env.NODE_ENV !== 'production' && this.logger.info(`前触发器「${trigger.name}」未通过check检查,跳过执行`);
370
381
  return execCommitTrigger(idx + 1);
371
382
  }
372
383
  // 如果有attributes限制,则判断当前operation中data是否包含这些属性,没有任何属性被包含在内则跳过
373
- if (trigger.attributes && (0, lodash_1.intersection)(trigger.attributes, Object.keys(operation.data)).length === 0) {
384
+ if (trigger.attributes && (0, toolkit_1.intersection)(trigger.attributes, Object.keys(operation.data)).length === 0) {
374
385
  process.env.NODE_ENV !== 'production' && this.logger.info(`前触发器「${trigger.name}」未包含任何属性,跳过执行`);
375
386
  return execCommitTrigger(idx + 1);
376
387
  }
377
388
  if (trigger.filter) {
378
- (0, assert_1.default)(operation.action !== 'create');
389
+ (0, assert_1.assert)(operation.action !== 'create');
379
390
  const { filter } = trigger;
380
391
  const filterr = typeof filter === 'function' ? await filter(operation, context, option) : filter;
381
392
  const filterRepelled = await (0, filter_1.checkFilterRepel)(entity, context, filterr, operation.filter);
@@ -394,7 +405,7 @@ class TriggerExecutor {
394
405
  }
395
406
  async execVolatileTrigger(entity, name, ids, context, option) {
396
407
  const trigger = this.triggerNameMap[name];
397
- (0, assert_1.default)(trigger && trigger.when === 'commit');
408
+ (0, assert_1.assert)(trigger && trigger.when === 'commit');
398
409
  // assert(ids.length > 0);
399
410
  const { fn, cleanTriggerDataBySelf } = trigger;
400
411
  const closeRoot = trigger.asRoot && context.openRootMode();
@@ -473,7 +484,7 @@ class TriggerExecutor {
473
484
  if (triggers) {
474
485
  // when为after的trigger,并且check通过,attributes和operation.data有交集的trigger,都会被执行
475
486
  const postTriggers = triggers.filter(ele => ele.when === 'after' && (!ele.check || ele.check(operation))
476
- && (!ele.attributes || (0, lodash_1.intersection)(ele.attributes, Object.keys(operation.data)).length > 0));
487
+ && (!ele.attributes || (0, toolkit_1.intersection)(ele.attributes, Object.keys(operation.data)).length > 0));
477
488
  const commitTriggers = triggers.filter(ele => ele.when === 'commit' &&
478
489
  (!ele.check || ele.check(operation)));
479
490
  if (context instanceof SyncRowStore_1.SyncContext) {
@@ -515,10 +526,10 @@ class TriggerExecutor {
515
526
  if (idx >= commitTriggers.length) {
516
527
  return;
517
528
  }
518
- (0, assert_1.default)(!action_1.readOnlyActions.includes(operation.action), '当前应该不支持select的跨事务trigger');
529
+ (0, assert_1.assert)(!action_1.readOnlyActions.includes(operation.action), '当前应该不支持select的跨事务trigger');
519
530
  const trigger = commitTriggers[idx];
520
531
  if (trigger.filter) {
521
- (0, assert_1.default)(operation.action !== 'create');
532
+ (0, assert_1.assert)(operation.action !== 'create');
522
533
  const { filter } = trigger;
523
534
  const filterr = typeof filter === 'function' ? await filter(operation, context, option) : filter;
524
535
  const filterRepelled = await (0, filter_1.checkFilterRepel)(entity, context, filterr, operation.filter);
@@ -553,7 +564,7 @@ class TriggerExecutor {
553
564
  */
554
565
  async independentCheckPoint(name, timestamp, instanceCount, instanceId) {
555
566
  const trigger = this.triggerNameMap[name];
556
- (0, assert_1.default)(trigger && trigger.when === 'commit');
567
+ (0, assert_1.assert)(trigger && trigger.when === 'commit');
557
568
  const { fn, entity, grouped } = trigger;
558
569
  const filter = {
559
570
  [Entity_1.TriggerDataAttribute]: {
@@ -614,7 +625,7 @@ class TriggerExecutor {
614
625
  await this.execVolatileTrigger(entity, name, rows.map(ele => ele.id), context, {});
615
626
  }
616
627
  else {
617
- const groupedRowDict = (0, lodash_1.groupBy)(rows2, Entity_1.TriggerUuidAttribute);
628
+ const groupedRowDict = (0, toolkit_1.groupBy)(rows2, Entity_1.TriggerUuidAttribute);
618
629
  for (const uuid in groupedRowDict) {
619
630
  const rs = groupedRowDict[uuid];
620
631
  const { [Entity_1.TriggerDataAttribute]: triggerData } = rs[0];
@@ -1,7 +1,7 @@
1
1
  import { Checker, EntityDict, OperateOption, SelectOption, StorageSchema, Trigger } from "../types";
2
- import { EntityDict as BaseEntityDict } from '../base-app-domain';
2
+ import { EntityDict as BaseEntityDict } from "../base-app-domain";
3
3
  import { AsyncContext } from "./AsyncRowStore";
4
- import { SyncContext } from './SyncRowStore';
4
+ import { SyncContext } from "./SyncRowStore";
5
5
  /**
6
6
  *
7
7
  * @param checker 要翻译的checker