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
@@ -1,8 +1,8 @@
1
- import assert from 'assert';
1
+ import { assert } from '../utils/assert';
2
2
  import * as ts from 'typescript';
3
3
  const { factory } = ts;
4
4
  import { join } from 'path';
5
- import { createHash } from 'crypto';
5
+ import { createHash } from "crypto";
6
6
  import fs from 'fs';
7
7
  import { firstLetterLowerCase, unescapeUnicode } from '../utils/string';
8
8
  import { analyzeDepedency } from './dependencyBuilder';
@@ -79,20 +79,6 @@ function collectOakPackages(nodeModulesPath) {
79
79
  oakPackageCache.set(normalizedNodeModulesPath, packages);
80
80
  return packages;
81
81
  }
82
- /**
83
- * 将一个object展开编译为一棵语法树,只有string和object两种键值对象
84
- * @param data
85
- */
86
- function transferObjectToObjectLiteral(data) {
87
- return factory.createObjectLiteralExpression(Object.keys(data).map((k) => {
88
- const type = typeof data[k];
89
- if (type === 'string') {
90
- return factory.createPropertyAssignment(factory.createStringLiteral(k), factory.createStringLiteral(data[k]));
91
- }
92
- assert(type === 'object');
93
- return factory.createPropertyAssignment(factory.createStringLiteral(k), transferObjectToObjectLiteral(data[k]));
94
- }), true);
95
- }
96
82
  /**
97
83
  * 这个类的作用是把项目和所有相关的模块下的locales编译成为src/data/i18n中的数据
98
84
  */
@@ -104,21 +90,17 @@ export default class LocaleBuilder {
104
90
  locales; // key: namespace+language, value: [namespace, module, position, language, data]
105
91
  hash;
106
92
  projectName;
107
- constructor(asLib) {
93
+ localeWorkspaces;
94
+ constructor(asLib, localeWorkspaces) {
108
95
  const pwd = process.cwd();
109
96
  this.pwd = pwd;
110
97
  this.asLib = !!asLib;
111
- const dependencyConfigureFile = join(pwd, 'src', 'configuration', 'dependency.ts');
112
- if (fs.existsSync(dependencyConfigureFile)) {
113
- const depGraph = analyzeDepedency(pwd);
114
- this.dependencies = depGraph.ascOrder;
115
- }
116
- else {
117
- this.dependencies = [];
118
- }
98
+ const depGraph = analyzeDepedency(pwd);
99
+ this.dependencies = depGraph.ascOrder;
119
100
  this.oakPackages = collectOakPackages(join(pwd, 'node_modules'));
120
101
  this.locales = {};
121
102
  this.hash = createHash('md5');
103
+ this.localeWorkspaces = localeWorkspaces;
122
104
  }
123
105
  /**
124
106
  * 将locales输出成为data/i18n.ts中的数据
@@ -126,28 +108,34 @@ export default class LocaleBuilder {
126
108
  */
127
109
  outputDataFile() {
128
110
  const appDomainDir = this.projectName === 'oak-domain' ? 'base-app-domain' : 'oak-app-domain';
111
+ const rows = Object.keys(this.locales).map((k) => {
112
+ const [namespace, module, position, language, data] = this.locales[k];
113
+ // 用哈希计算来保证id唯一性
114
+ const h = this.hash.copy();
115
+ h.update(`${namespace}-${language}`);
116
+ const id = h.digest('hex');
117
+ assert(id.length <= 36);
118
+ return {
119
+ id,
120
+ namespace,
121
+ language,
122
+ module,
123
+ position,
124
+ data,
125
+ };
126
+ });
129
127
  const statements = [
130
- factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
128
+ factory.createImportDeclaration(undefined, factory.createImportClause(true, undefined, factory.createNamedImports([
131
129
  factory.createImportSpecifier(false, factory.createIdentifier('CreateOperationData'), factory.createIdentifier('I18n')),
132
130
  ])), factory.createStringLiteral(`../${appDomainDir}/I18n/Schema`), undefined),
131
+ factory.createVariableStatement([factory.createModifier(ts.SyntaxKind.DeclareKeyword)], factory.createVariableDeclarationList([
132
+ factory.createVariableDeclaration(factory.createIdentifier('require'), undefined, factory.createFunctionTypeNode(undefined, [
133
+ factory.createParameterDeclaration(undefined, undefined, factory.createIdentifier('path'), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), undefined),
134
+ ], factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword)), undefined),
135
+ ], ts.NodeFlags.Const)),
133
136
  ];
134
137
  statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
135
- factory.createVariableDeclaration(factory.createIdentifier('i18ns'), undefined, factory.createArrayTypeNode(factory.createTypeReferenceNode(factory.createIdentifier('I18n'), undefined)), factory.createArrayLiteralExpression(Object.keys(this.locales).map((k) => {
136
- const [namespace, module, position, language, data] = this.locales[k];
137
- // 用哈希计算来保证id唯一性
138
- const h = this.hash.copy();
139
- h.update(`${namespace}-${language}`);
140
- const id = h.digest('hex');
141
- assert(id.length <= 36);
142
- return factory.createObjectLiteralExpression([
143
- factory.createPropertyAssignment(factory.createIdentifier('id'), factory.createStringLiteral(id)),
144
- factory.createPropertyAssignment(factory.createIdentifier('namespace'), factory.createStringLiteral(namespace)),
145
- factory.createPropertyAssignment(factory.createIdentifier('language'), factory.createStringLiteral(language)),
146
- factory.createPropertyAssignment(factory.createIdentifier('module'), factory.createStringLiteral(module)),
147
- factory.createPropertyAssignment(factory.createIdentifier('position'), factory.createStringLiteral(position)),
148
- factory.createPropertyAssignment(factory.createIdentifier('data'), transferObjectToObjectLiteral(data)),
149
- ], true);
150
- }), true)),
138
+ factory.createVariableDeclaration(factory.createIdentifier('i18ns'), undefined, undefined, factory.createAsExpression(factory.createCallExpression(factory.createIdentifier('require'), undefined, [factory.createStringLiteral('./i18n.json')]), factory.createArrayTypeNode(factory.createTypeReferenceNode(factory.createIdentifier('I18n'), undefined)))),
151
139
  ], ts.NodeFlags.Const)));
152
140
  statements.push(factory.createExportAssignment(undefined, undefined, factory.createIdentifier('i18ns')));
153
141
  const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
@@ -157,8 +145,11 @@ export default class LocaleBuilder {
157
145
  fs.mkdirSync(dataDir);
158
146
  }
159
147
  const filename = join(dataDir, 'i18n.ts');
148
+ const jsonFilename = join(dataDir, 'i18n.json');
160
149
  const result2 = unescapeUnicode(`// 本文件为自动编译产生,请勿直接修改\n\n${result}`);
150
+ const jsonResult = unescapeUnicode(`${JSON.stringify(rows, null, 4)}\n`);
161
151
  fs.writeFileSync(filename, result2, { flag: 'w' });
152
+ fs.writeFileSync(jsonFilename, jsonResult, { flag: 'w' });
162
153
  }
163
154
  /**
164
155
  * 这里不能直接用require, webpack貌似有缓存
@@ -245,23 +236,28 @@ export default class LocaleBuilder {
245
236
  if (fs.existsSync(domainPath)) {
246
237
  this.traverse('', '', 'oak-app-domain', domainPath, false, 'locales', watch);
247
238
  }
248
- // 还有web和wechatMp的目录
249
- const webSrcPath = join('web', 'src');
250
- this.traverse(name, 'w', webSrcPath, join(root, webSrcPath), false, 'locales', watch);
251
- // 小程序可能有多于一个,按规范用wechatMp, wechatMp2这样命名
252
- const wechatMpSrcPath = join('wechatMp', 'src');
253
- this.traverse(name, 'wmp', wechatMpSrcPath, join(root, webSrcPath), false, 'locales', watch);
254
- let iter = 1;
255
- while (true) {
256
- const mpSrcPath = `${wechatMpSrcPath}${iter}`;
257
- if (fs.existsSync(join(root, mpSrcPath))) {
258
- this.traverse(name, `wmp${iter}`, mpSrcPath, join(root, mpSrcPath), false, 'locales', watch);
239
+ const localeWorkspaces = this.localeWorkspaces || (() => {
240
+ const legacyWorkspaces = [
241
+ { namespacePrefix: 'w', relativePath: 'web' },
242
+ { namespacePrefix: 'wmp', relativePath: 'wechatMp' },
243
+ ];
244
+ let iter = 1;
245
+ while (fs.existsSync(join(root, `wechatMp${iter}`, 'src'))) {
246
+ legacyWorkspaces.push({
247
+ namespacePrefix: `wmp${iter}`,
248
+ relativePath: `wechatMp${iter}`,
249
+ });
259
250
  iter++;
260
251
  }
261
- else {
262
- break;
252
+ return legacyWorkspaces;
253
+ })();
254
+ localeWorkspaces.forEach(({ namespacePrefix, relativePath }) => {
255
+ const workspaceSrcPath = join(relativePath, 'src');
256
+ const workspaceSrcAbsolutePath = join(root, workspaceSrcPath);
257
+ if (fs.existsSync(workspaceSrcAbsolutePath)) {
258
+ this.traverse(name, namespacePrefix, workspaceSrcPath, workspaceSrcAbsolutePath, false, 'locales', watch);
263
259
  }
264
- }
260
+ });
265
261
  }
266
262
  }
267
263
  build(watch) {
@@ -1,8 +1,37 @@
1
- declare function closeCurrentWatchSession(): void;
2
- export declare function buildRouter(projectDir: string, startupDir: string, watch?: boolean, options?: {
1
+ type PageConfig = {
2
+ enablePullDownRefresh?: boolean;
3
+ route?: {
4
+ path?: string;
5
+ /** Web document title literal. */
6
+ title?: string;
7
+ /** Web document title i18n key. Defaults to the page locale pageTitle key. */
8
+ titleI18nKey?: string;
9
+ /** Web route pull-down refresh behavior. Falls back to top-level enablePullDownRefresh. */
10
+ enablePullDownRefresh?: boolean;
11
+ access?: unknown;
12
+ };
13
+ menu?: unknown;
14
+ mp?: {
15
+ /** Mini-program page pull-down refresh behavior; not used by web router generation. */
16
+ enablePullDownRefresh?: boolean;
17
+ };
18
+ };
19
+ type NamespaceConfig = {
20
+ route?: {
21
+ path?: string;
22
+ notFound?: string;
23
+ first?: string;
24
+ params?: Record<string, string>;
25
+ };
26
+ };
27
+ type BuildRouterOptions = {
3
28
  useOutlet?: boolean;
4
29
  onWarning?: (message: string) => void;
5
- }): {
30
+ getPageConfig?: (pageDirectoryPath: string) => PageConfig | undefined;
31
+ getNamespaceConfig?: (namespaceDirectoryPath: string, namespace: string) => NamespaceConfig | undefined;
32
+ };
33
+ declare function closeCurrentWatchSession(): void;
34
+ export declare function buildRouter(projectDir: string, startupDir: string, watch?: boolean, options?: BuildRouterOptions): {
6
35
  close: typeof closeCurrentWatchSession;
7
36
  } | undefined;
8
37
  export {};
@@ -1,14 +1,28 @@
1
1
  import { join, relative, dirname } from 'path';
2
2
  import { readdirSync, statSync, existsSync, writeFileSync, readFileSync, removeSync } from 'fs-extra';
3
- import assert from 'assert';
3
+ import { assert } from '../utils/assert';
4
4
  import * as ts from 'typescript';
5
5
  import NodeWatch from 'node-watch';
6
6
  import { OAK_CLI_MODULE_NAME } from './env';
7
7
  const { factory } = ts;
8
8
  const NameSpaceDescDict = {};
9
- const PAGE_RENDER_FILES = ['web.tsx', 'web.pc.tsx', 'render.native.tsx', 'render.ios.tsx', 'render.android.tsx', 'index.xml'];
10
- const PAGE_WATCH_FILTER = /(?:^|[\\/])(?:web\.tsx|web\.pc\.tsx|index\.json|index\.xml|render\.(?:native|ios|android)\.tsx)$/;
11
- const NAMESPACE_WATCH_FILTER = /(?:^|[\\/])index\.json$/;
9
+ const WEB_PAGE_RENDER_FILES = ['web.tsx', 'web.pc.tsx', 'web.mobile.tsx'];
10
+ const DESKTOP_PAGE_RENDER_FILES = [
11
+ 'render.desktop.tsx',
12
+ 'render.windows.tsx',
13
+ 'render.macos.tsx',
14
+ 'render.linux.tsx',
15
+ ];
16
+ const PAGE_RENDER_FILES = [
17
+ ...WEB_PAGE_RENDER_FILES,
18
+ ...DESKTOP_PAGE_RENDER_FILES,
19
+ 'render.native.tsx',
20
+ 'render.ios.tsx',
21
+ 'render.android.tsx',
22
+ 'index.xml',
23
+ ];
24
+ const PAGE_WATCH_FILTER = /(?:^|[\\/])(?:web\.tsx|web\.pc\.tsx|web\.mobile\.tsx|index\.json|index\.config\.(?:ts|mts|cts|js|mjs|cjs)|index\.xml|render\.(?:desktop|windows|macos|linux|native|ios|android)\.tsx)$/;
25
+ const NAMESPACE_WATCH_FILTER = /(?:^|[\\/])(?:index\.json|index\.config\.(?:ts|mts|cts|js|mjs|cjs))$/;
12
26
  const VALID_PAGE_DIR_NAME = /^[A-Za-z0-9_-]+$/;
13
27
  function normalizePath(path) {
14
28
  return path.replace(/\\/g, '/');
@@ -27,6 +41,13 @@ function normalizeRoutePath(path) {
27
41
  function isValidPageDirName(name) {
28
42
  return VALID_PAGE_DIR_NAME.test(name);
29
43
  }
44
+ function isDesktopRenderProfile() {
45
+ return process.env.OAK_RENDER === 'tauri'
46
+ || process.env.OAK_RENDER === 'electron';
47
+ }
48
+ function isWebStartupDir(startupDir) {
49
+ return startupDir.startsWith('web') || isDesktopRenderProfile();
50
+ }
30
51
  function getInvalidPageDirPath(relativePath) {
31
52
  const segments = normalizeRelativePath(relativePath).split('/').filter(Boolean);
32
53
  const validSegments = [];
@@ -40,16 +61,28 @@ function getInvalidPageDirPath(relativePath) {
40
61
  function readJsonFresh(filename) {
41
62
  return JSON.parse(readFileSync(filename, 'utf-8'));
42
63
  }
64
+ function getProjectPackageName(projectDir) {
65
+ const packageJson = readJsonFresh(join(projectDir, 'package.json'));
66
+ assert(typeof packageJson.name === 'string' && packageJson.name, `${projectDir}下的package.json缺少name字段`);
67
+ return packageJson.name;
68
+ }
69
+ function createPageTitleI18nKey(packageName, namespaceKey, fullPath) {
70
+ const pagePath = normalizeRoutePath(fullPath).replace(/\//g, '-');
71
+ return `${packageName}-p-${namespaceKey}-${pagePath}.pageTitle`;
72
+ }
43
73
  function hasPageDescChanged(prev, next) {
44
74
  if (!prev || !next) {
45
75
  return prev !== next;
46
76
  }
47
77
  return prev.path !== next.path
48
78
  || prev.routePath !== next.routePath
79
+ || prev.routeTitle !== next.routeTitle
80
+ || prev.routeTitleI18nKey !== next.routeTitleI18nKey
49
81
  || prev.oakDisablePulldownRefresh !== next.oakDisablePulldownRefresh
50
82
  || prev.hasWeb !== next.hasWeb
51
83
  || prev.hasNative !== next.hasNative
52
- || prev.hasWechatMp !== next.hasWechatMp;
84
+ || prev.hasWechatMp !== next.hasWechatMp
85
+ || JSON.stringify(prev.access) !== JSON.stringify(next.access);
53
86
  }
54
87
  function getNamespaceFromFilepath(rootDir, filepath) {
55
88
  const normalizedRelativePath = normalizeRelativePath(relative(rootDir, filepath));
@@ -87,7 +120,9 @@ function checkPageDir(dir, relativePath, ns, type) {
87
120
  if (['render.native.tsx', 'render.ios.tsx', 'render.android.tsx'].includes(file)) {
88
121
  hasNative = true;
89
122
  }
90
- else if (['web.tsx', 'web.pc.tsx'].includes(file)) {
123
+ else if (WEB_PAGE_RENDER_FILES.includes(file)
124
+ || (isDesktopRenderProfile()
125
+ && DESKTOP_PAGE_RENDER_FILES.includes(file))) {
91
126
  hasWeb = true;
92
127
  }
93
128
  else if (file === 'index.xml') {
@@ -108,20 +143,37 @@ function checkPageDir(dir, relativePath, ns, type) {
108
143
  const indexJsonFile = join(dir, 'index.json');
109
144
  let oakDisablePulldownRefresh = false;
110
145
  let routePath;
146
+ let routeTitle;
147
+ let routeTitleI18nKey;
148
+ let access;
149
+ let indexJson = {};
111
150
  if (existsSync(indexJsonFile)) {
112
- const { enablePullDownRefresh = true, path: routePath2, } = readJsonFresh(indexJsonFile);
113
- oakDisablePulldownRefresh = !enablePullDownRefresh;
114
- if (typeof routePath2 === 'string') {
115
- routePath = normalizeRoutePath(routePath2);
116
- }
151
+ indexJson = readJsonFresh(indexJsonFile);
152
+ }
153
+ const pageConfig = BuildRouterContext.options?.getPageConfig?.(dir);
154
+ const enablePullDownRefresh = pageConfig?.route?.enablePullDownRefresh ?? pageConfig?.enablePullDownRefresh ?? indexJson.enablePullDownRefresh ?? true;
155
+ const routePath2 = pageConfig?.route?.path ?? indexJson.path;
156
+ oakDisablePulldownRefresh = !enablePullDownRefresh;
157
+ if (typeof routePath2 === 'string') {
158
+ routePath = normalizeRoutePath(routePath2);
159
+ }
160
+ if (typeof pageConfig?.route?.title === 'string') {
161
+ routeTitle = pageConfig.route.title;
162
+ }
163
+ if (typeof pageConfig?.route?.titleI18nKey === 'string') {
164
+ routeTitleI18nKey = pageConfig.route.titleI18nKey;
117
165
  }
166
+ access = pageConfig?.route?.access;
118
167
  nextPageDesc = {
119
168
  path: normalizeRelativePath(relativePath),
120
169
  routePath,
170
+ routeTitle,
171
+ routeTitleI18nKey,
121
172
  oakDisablePulldownRefresh,
122
173
  hasNative,
123
174
  hasWeb,
124
175
  hasWechatMp,
176
+ access,
125
177
  };
126
178
  }
127
179
  if (hasPageDescChanged(pages[dir], nextPageDesc)) {
@@ -201,6 +253,44 @@ function createLazyImportExpression(importPath) {
201
253
  factory.createStringLiteral(importPath)
202
254
  ]))]);
203
255
  }
256
+ function createLiteralExpressionFromValue(value) {
257
+ if (value === null) {
258
+ return factory.createNull();
259
+ }
260
+ if (typeof value === 'string') {
261
+ return factory.createStringLiteral(value);
262
+ }
263
+ if (typeof value === 'number') {
264
+ return factory.createNumericLiteral(value);
265
+ }
266
+ if (typeof value === 'boolean') {
267
+ return value ? factory.createTrue() : factory.createFalse();
268
+ }
269
+ if (Array.isArray(value)) {
270
+ return factory.createArrayLiteralExpression(value.map((item) => createLiteralExpressionFromValue(item)));
271
+ }
272
+ if (value && typeof value === 'object') {
273
+ return factory.createObjectLiteralExpression(Object.entries(value)
274
+ .filter(([, currentValue]) => currentValue !== undefined)
275
+ .map(([key, currentValue]) => factory.createPropertyAssignment(/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key)
276
+ ? factory.createIdentifier(key)
277
+ : factory.createStringLiteral(key), createLiteralExpressionFromValue(currentValue))), true);
278
+ }
279
+ return factory.createIdentifier('undefined');
280
+ }
281
+ function createWebRouteMetaExpression(page, titleI18nKey) {
282
+ const properties = [
283
+ factory.createPropertyAssignment('oakDisablePulldownRefresh', page.oakDisablePulldownRefresh ? factory.createTrue() : factory.createFalse())
284
+ ];
285
+ if (page.routeTitle !== undefined) {
286
+ properties.push(factory.createPropertyAssignment('title', factory.createStringLiteral(page.routeTitle)));
287
+ }
288
+ properties.push(factory.createPropertyAssignment('titleI18nKey', factory.createStringLiteral(page.routeTitleI18nKey || titleI18nKey)));
289
+ if (page.access !== undefined) {
290
+ properties.push(factory.createPropertyAssignment('access', createLiteralExpressionFromValue(page.access)));
291
+ }
292
+ return factory.createObjectLiteralExpression(properties, true);
293
+ }
204
294
  function appendRouteParam(path, paramName) {
205
295
  if (!paramName) {
206
296
  return path;
@@ -338,15 +428,13 @@ function getValidWebRouteChildren(parentNode, ns, params) {
338
428
  });
339
429
  return candidates.filter((candidate) => !ignoredNodePaths.has(candidate.node.fullPath)).map((candidate) => candidate.node);
340
430
  }
341
- function createWebPageRouteExpression(ns, page, projectDir, routerFileDir, path, fullPath, options) {
431
+ function createWebPageRouteExpression(ns, namespacePath, packageName, page, projectDir, routerFileDir, path, fullPath, options) {
342
432
  const properties = [];
343
433
  properties.push(factory.createPropertyAssignment('path', factory.createStringLiteral(options?.isFirst ? '' : path)), factory.createPropertyAssignment('fullPath', factory.createStringLiteral(fullPath)));
344
434
  if (options?.isFirst) {
345
435
  properties.push(factory.createPropertyAssignment('isFirst', factory.createTrue()));
346
436
  }
347
- properties.push(factory.createPropertyAssignment('namespace', factory.createStringLiteral(ns)), factory.createPropertyAssignment('meta', factory.createObjectLiteralExpression([
348
- factory.createPropertyAssignment('oakDisablePulldownRefresh', page.oakDisablePulldownRefresh ? factory.createTrue() : factory.createFalse())
349
- ])), factory.createPropertyAssignment(factory.createIdentifier('Component'), createLazyImportExpression(normalizePath(relative(routerFileDir, join(projectDir, 'src', 'pages', ns, page.path))))));
437
+ properties.push(factory.createPropertyAssignment('namespace', factory.createStringLiteral(ns)), factory.createPropertyAssignment('namespaceKey', factory.createStringLiteral(ns)), factory.createPropertyAssignment('namespacePath', factory.createStringLiteral(namespacePath)), factory.createPropertyAssignment('meta', createWebRouteMetaExpression(page, createPageTitleI18nKey(packageName, ns, fullPath))), factory.createPropertyAssignment(factory.createIdentifier('Component'), createLazyImportExpression(normalizePath(relative(routerFileDir, join(projectDir, 'src', 'pages', ns, page.path))))));
350
438
  if (options?.children?.length) {
351
439
  properties.push(factory.createPropertyAssignment('children', factory.createArrayLiteralExpression(options.children)));
352
440
  }
@@ -358,22 +446,22 @@ function createWebGroupRouteExpression(path, children) {
358
446
  factory.createPropertyAssignment('children', factory.createArrayLiteralExpression(children))
359
447
  ], true);
360
448
  }
361
- function makeWebRoutesFromTreeNode(node, ns, params, projectDir, routerFileDir, useOutlet) {
362
- const children = getValidWebRouteChildren(node, ns, params).map((child) => makeWebRoutesFromTreeNode(child, ns, params, projectDir, routerFileDir, useOutlet));
449
+ function makeWebRoutesFromTreeNode(node, ns, namespacePath, packageName, params, projectDir, routerFileDir, useOutlet) {
450
+ const children = getValidWebRouteChildren(node, ns, params).map((child) => makeWebRoutesFromTreeNode(child, ns, namespacePath, packageName, params, projectDir, routerFileDir, useOutlet));
363
451
  const groupPath = getGroupRoutePath(node, params);
364
452
  if (node.page) {
365
453
  const path = getPageRoutePath(node, node.page, params);
366
454
  const fullPath = node.page.path;
367
455
  if (children.length === 0) {
368
- return createWebPageRouteExpression(ns, node.page, projectDir, routerFileDir, path, fullPath);
456
+ return createWebPageRouteExpression(ns, namespacePath, packageName, node.page, projectDir, routerFileDir, path, fullPath);
369
457
  }
370
458
  if (useOutlet) {
371
- return createWebPageRouteExpression(ns, node.page, projectDir, routerFileDir, path, fullPath, {
459
+ return createWebPageRouteExpression(ns, namespacePath, packageName, node.page, projectDir, routerFileDir, path, fullPath, {
372
460
  children,
373
461
  });
374
462
  }
375
463
  return createWebGroupRouteExpression(path, [
376
- createWebPageRouteExpression(ns, node.page, projectDir, routerFileDir, path, fullPath, {
464
+ createWebPageRouteExpression(ns, namespacePath, packageName, node.page, projectDir, routerFileDir, path, fullPath, {
377
465
  isFirst: true,
378
466
  }),
379
467
  ...children,
@@ -382,7 +470,11 @@ function makeWebRoutesFromTreeNode(node, ns, params, projectDir, routerFileDir,
382
470
  return createWebGroupRouteExpression(groupPath, children);
383
471
  }
384
472
  function makeWebAllRouters(namespaceDir, projectDir, routerFileDir, options) {
473
+ const packageName = getProjectPackageName(projectDir);
385
474
  const nss = readdirSync(namespaceDir).filter((ns) => {
475
+ if (!statSync(join(namespaceDir, ns)).isDirectory()) {
476
+ return false;
477
+ }
386
478
  if (isValidPageDirName(ns)) {
387
479
  return true;
388
480
  }
@@ -392,67 +484,87 @@ function makeWebAllRouters(namespaceDir, projectDir, routerFileDir, options) {
392
484
  return factory.createArrayLiteralExpression(nss.map((ns) => {
393
485
  assert(NameSpaceDescDict[ns], `${ns}在pages下没有对应的目录`);
394
486
  const { pages } = NameSpaceDescDict[ns];
395
- const nsIndexJsonFile = join(namespaceDir, ns, 'index.json');
487
+ const nsDirectory = join(namespaceDir, ns);
488
+ const nsIndexJsonFile = join(nsDirectory, 'index.json');
396
489
  let path2 = `/${ns}`;
397
490
  let notFound2 = '', first2 = '';
398
491
  let params2 = {};
492
+ let namespaceIndexJson = {};
399
493
  if (existsSync(nsIndexJsonFile)) {
400
- const { path, notFound, first, params } = readJsonFresh(nsIndexJsonFile);
401
- if (path) {
402
- path2 = normalizePath(path);
403
- }
404
- if (notFound) {
405
- notFound2 = normalizePath(notFound);
406
- }
407
- if (first) {
408
- first2 = normalizePath(first);
409
- if (first2.startsWith('/')) {
410
- first2 = first2.slice(1);
411
- }
412
- }
413
- if (params) {
414
- params2 = params;
494
+ namespaceIndexJson = readJsonFresh(nsIndexJsonFile);
495
+ }
496
+ const namespaceRouteConfig = BuildRouterContext.options?.getNamespaceConfig?.(nsDirectory, ns)?.route;
497
+ const namespacePath = namespaceRouteConfig?.path ?? namespaceIndexJson.path;
498
+ const notFound = namespaceRouteConfig?.notFound ?? namespaceIndexJson.notFound;
499
+ const first = namespaceRouteConfig?.first ?? namespaceIndexJson.first;
500
+ const params = namespaceRouteConfig?.params ?? namespaceIndexJson.params;
501
+ if (typeof namespacePath === 'string' && namespacePath) {
502
+ path2 = normalizePath(namespacePath);
503
+ }
504
+ if (typeof notFound === 'string' && notFound) {
505
+ notFound2 = normalizePath(notFound);
506
+ }
507
+ if (typeof first === 'string' && first) {
508
+ first2 = normalizePath(first);
509
+ if (first2.startsWith('/')) {
510
+ first2 = first2.slice(1);
415
511
  }
416
512
  }
513
+ if (params) {
514
+ params2 = params;
515
+ }
417
516
  const routeTree = buildWebRouteTree(pages);
418
- const pageChildren = getValidWebRouteChildren(routeTree, ns, params2).map((child) => makeWebRoutesFromTreeNode(child, ns, params2, projectDir, routerFileDir, options?.useOutlet));
517
+ const pageChildren = getValidWebRouteChildren(routeTree, ns, params2).map((child) => makeWebRoutesFromTreeNode(child, ns, path2, packageName, params2, projectDir, routerFileDir, options?.useOutlet));
419
518
  const children = [...pageChildren];
420
519
  if (routeTree.page) {
421
520
  const rootPagePath = getPageRoutePath(routeTree, routeTree.page, params2);
422
521
  const rootFullPath = routeTree.page.path;
423
522
  if (options?.useOutlet && pageChildren.length > 0) {
424
523
  children.length = 0;
425
- children.push(createWebPageRouteExpression(ns, routeTree.page, projectDir, routerFileDir, rootPagePath, rootFullPath, {
524
+ children.push(createWebPageRouteExpression(ns, path2, packageName, routeTree.page, projectDir, routerFileDir, rootPagePath, rootFullPath, {
426
525
  children: pageChildren,
427
526
  }));
428
527
  }
429
528
  else if (!rootPagePath) {
430
- children.unshift(createWebPageRouteExpression(ns, routeTree.page, projectDir, routerFileDir, rootPagePath, rootFullPath, {
529
+ children.unshift(createWebPageRouteExpression(ns, path2, packageName, routeTree.page, projectDir, routerFileDir, rootPagePath, rootFullPath, {
431
530
  isFirst: true,
432
531
  }));
433
532
  }
434
533
  else {
435
- children.unshift(createWebPageRouteExpression(ns, routeTree.page, projectDir, routerFileDir, rootPagePath, rootFullPath));
534
+ children.unshift(createWebPageRouteExpression(ns, path2, packageName, routeTree.page, projectDir, routerFileDir, rootPagePath, rootFullPath));
436
535
  }
437
536
  }
438
537
  const firstPage = Object.values(pages).find((page) => page.hasWeb && page.path === first2);
439
538
  if (firstPage) {
440
- children.push(createWebPageRouteExpression(ns, firstPage, projectDir, routerFileDir, '', firstPage.path, {
539
+ children.push(createWebPageRouteExpression(ns, path2, packageName, firstPage, projectDir, routerFileDir, '', firstPage.path, {
441
540
  isFirst: true,
442
541
  }));
443
542
  }
444
543
  if (notFound2) {
544
+ const notFoundPage = pages[notFound2];
545
+ const notFoundMetaPage = notFoundPage || {
546
+ path: notFound2,
547
+ oakDisablePulldownRefresh: false,
548
+ hasWeb: true,
549
+ hasNative: false,
550
+ hasWechatMp: false,
551
+ };
445
552
  children.push(factory.createObjectLiteralExpression([
446
553
  factory.createPropertyAssignment('path', factory.createStringLiteral('*')),
447
554
  factory.createPropertyAssignment('namespace', factory.createStringLiteral(ns)),
555
+ factory.createPropertyAssignment('namespaceKey', factory.createStringLiteral(ns)),
556
+ factory.createPropertyAssignment('namespacePath', factory.createStringLiteral(path2)),
448
557
  factory.createPropertyAssignment('fullPath', factory.createStringLiteral(notFound2)),
558
+ factory.createPropertyAssignment('meta', createWebRouteMetaExpression(notFoundMetaPage, createPageTitleI18nKey(packageName, ns, notFound2))),
449
559
  factory.createPropertyAssignment(factory.createIdentifier("Component"), createLazyImportExpression(normalizePath(relative(routerFileDir, join(projectDir, 'src', 'pages', ns, notFound2)))))
450
560
  ], true));
451
561
  }
452
562
  return factory.createObjectLiteralExpression([
453
563
  factory.createPropertyAssignment('path', factory.createStringLiteral(path2)),
454
564
  factory.createPropertyAssignment('namespace', factory.createStringLiteral(path2)),
455
- factory.createPropertyAssignment(factory.createIdentifier("Component"), createLazyImportExpression(normalizePath(relative(routerFileDir, join(namespaceDir, ns))))),
565
+ factory.createPropertyAssignment('namespaceKey', factory.createStringLiteral(ns)),
566
+ factory.createPropertyAssignment('namespacePath', factory.createStringLiteral(path2)),
567
+ factory.createPropertyAssignment(factory.createIdentifier("Component"), createLazyImportExpression(normalizePath(relative(routerFileDir, nsDirectory)))),
456
568
  factory.createPropertyAssignment('children', factory.createArrayLiteralExpression(children))
457
569
  ], true);
458
570
  }), true);
@@ -632,7 +744,7 @@ function watchDir(projectDir, startupDir, type) {
632
744
  BuildRouterContext.watchHandles.push(handle);
633
745
  }
634
746
  };
635
- if (startupDir.startsWith('web')) {
747
+ if (isWebStartupDir(startupDir)) {
636
748
  const srcAppDir = join(projectDir, startupDir, 'src', 'app');
637
749
  const namespaceDir = join(srcAppDir, 'namespaces');
638
750
  const tryOutputAppDir = (ns) => {
@@ -715,11 +827,11 @@ export function buildRouter(projectDir, startupDir, watch, options) {
715
827
  BuildRouterContext.options = options;
716
828
  BuildRouterContext.warnedInvalidDirs = new Set();
717
829
  BuildRouterContext.warnedRouteConflicts = new Set();
718
- const type = startupDir.startsWith('web') ? 'web' : (startupDir.startsWith('native') ? 'native' : 'wechatMp');
830
+ const type = isWebStartupDir(startupDir) ? 'web' : (startupDir.startsWith('native') ? 'native' : 'wechatMp');
719
831
  traversePageDir(projectDir, type);
720
832
  const subDir = readdirSync(projectDir);
721
833
  assert(subDir.includes(startupDir));
722
- if (startupDir.startsWith('web')) {
834
+ if (isWebStartupDir(startupDir)) {
723
835
  outputInWebDir(join(projectDir, startupDir));
724
836
  }
725
837
  // todo native
@@ -1,5 +1,9 @@
1
1
  import * as ts from 'typescript';
2
- import { CompilerOutputOptions } from './env';
2
+ import { CompilerOutputOptions } from "./env";
3
+ export type SchemaBuilderProjectOptions = {
4
+ pwd: string;
5
+ configFile?: string;
6
+ };
3
7
  declare const Schema: Record<string, {
4
8
  schemaAttrs: Array<ts.PropertySignature>;
5
9
  fulltextIndex?: true;
@@ -13,6 +17,7 @@ declare const Schema: Record<string, {
13
17
  static: boolean;
14
18
  recursiveDepth?: number;
15
19
  style?: StaticLiteralObject;
20
+ localizedContent?: ParsedLocalizedContentConfig;
16
21
  inModi: boolean;
17
22
  relations: false | string[];
18
23
  extendsFrom: string[];
@@ -43,6 +48,7 @@ type ParsedIndexConfig = {
43
48
  parser?: string;
44
49
  tsConfig?: string | string[];
45
50
  chineseParser?: string;
51
+ include?: string[];
46
52
  };
47
53
  type ParsedIndex = {
48
54
  name: string;
@@ -53,6 +59,10 @@ type ParsedIndex = {
53
59
  attributeKey: string;
54
60
  origin: MetadataOrigin;
55
61
  };
62
+ type ParsedLocalizedContentConfig = {
63
+ attributes: string[];
64
+ sourceLanguage?: string;
65
+ };
56
66
  export declare function constructAttributes(entity: string): ts.PropertyAssignment[];
57
67
  export declare function translateLocaleObject(locale: ts.ObjectLiteralExpression): LocaleObject;
58
68
  /**
@@ -81,7 +91,7 @@ export declare function registerFixedDestinationPathMap(map: Record<string, stri
81
91
  */
82
92
  export declare function registerDeducedRelationMap(map: Record<string, string>): void;
83
93
  export declare const getAnalizedSchema: () => typeof Schema;
84
- export declare function analyzeEntities(inputDir: string, relativePath?: string, options?: CompilerOutputOptions): void;
94
+ export declare function analyzeEntities(inputDir: string, relativePath?: string, options?: CompilerOutputOptions, projectOptions?: SchemaBuilderProjectOptions): void;
85
95
  export declare function getProjectionKeys(entity: string): string[];
86
96
  export declare function buildSchema(outputDir: string, options?: CompilerOutputOptions): void;
87
97
  export {};