remult 0.22.5 → 0.22.6-exp.2

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 (358) hide show
  1. package/esm/graphql.js +29 -28
  2. package/esm/internals.js +7 -0
  3. package/esm/migrations/compare-migration-snapshots.js +61 -0
  4. package/esm/migrations/generate-migrations.js +68 -0
  5. package/esm/migrations/index.js +2 -0
  6. package/esm/migrations/migrate.js +85 -0
  7. package/esm/migrations/migration-types.js +36 -0
  8. package/esm/migrations/update-migrations-ts-file.js +115 -0
  9. package/esm/package.json +3 -0
  10. package/esm/postgres/schema-builder.js +4 -4
  11. package/esm/remult-better-sqlite3.js +47 -0
  12. package/esm/remult-bun-sqlite.js +41 -0
  13. package/esm/remult-duckdb.js +111 -0
  14. package/esm/remult-hapi.js +114 -0
  15. package/esm/remult-hono.js +104 -0
  16. package/esm/remult-mongo.js +1 -1
  17. package/esm/remult-nuxt.js +54 -0
  18. package/esm/remult-solid-start.js +97 -0
  19. package/esm/remult-sql-js.js +41 -0
  20. package/esm/remult-sqlite-core.js +137 -0
  21. package/esm/remult-sqlite3.js +61 -0
  22. package/esm/remult-turso.js +59 -0
  23. package/esm/server/get-remult-admin-html.js +3 -0
  24. package/esm/server/initDataProviderOrJson.js +6 -0
  25. package/esm/server/remult-admin.js +95 -0
  26. package/esm/server/remult-api-server.js +1157 -0
  27. package/esm/src/CompoundIdField.js +62 -0
  28. package/esm/src/backend-tests/backend-database-test-setup.backend-spec.js +11 -10
  29. package/esm/src/data-api.js +4 -2
  30. package/esm/src/data-providers/json-entity-opfs-storage.js +26 -0
  31. package/esm/src/isOfType.js +9 -0
  32. package/esm/src/live-query/SubscriptionServer.js +2 -2
  33. package/esm/src/remult-static.js +43 -0
  34. package/esm/src/remult3/Fields.js +335 -0
  35. package/esm/src/remult3/IdEntity.js +10 -0
  36. package/esm/src/remult3/RepositoryImplementation.js +7 -4
  37. package/esm/src/remult3/__updateEntityBasedOnWhere.js +28 -0
  38. package/esm/src/remult3/addValidator.js +15 -0
  39. package/esm/{core/src/remult3/DecoratorReplacer.js → src/remult3/classDescribers.js} +18 -3
  40. package/esm/src/remult3/entity.js +70 -0
  41. package/esm/src/remult3/getEntityRef.js +36 -0
  42. package/esm/src/remult3/relation-loader.js +153 -0
  43. package/esm/src/remult3/relationInfoMember.js +116 -0
  44. package/esm/src/remult3/repository-internals.js +7 -0
  45. package/esm/src/server-action-info.js +1 -0
  46. package/esm/src/shared-tests/db-tests.db-tests.js +1 -1
  47. package/graphql.js +2 -1
  48. package/internals.d.ts +15 -0
  49. package/internals.js +18 -0
  50. package/migrations/compare-migration-snapshots.d.ts +27 -0
  51. package/migrations/compare-migration-snapshots.js +164 -0
  52. package/migrations/generate-migrations.d.ts +21 -0
  53. package/migrations/generate-migrations.js +103 -0
  54. package/migrations/index.d.ts +3 -0
  55. package/migrations/index.js +7 -0
  56. package/migrations/migrate.d.ts +27 -0
  57. package/migrations/migrate.js +170 -0
  58. package/migrations/migration-types.d.ts +48 -0
  59. package/migrations/migration-types.js +88 -0
  60. package/migrations/update-migrations-ts-file.d.ts +1 -0
  61. package/migrations/update-migrations-ts-file.js +140 -0
  62. package/package.json +1 -1
  63. package/remult-better-sqlite3.d.ts +12 -0
  64. package/remult-better-sqlite3.js +64 -0
  65. package/remult-bun-sqlite.d.ts +11 -0
  66. package/remult-bun-sqlite.js +56 -0
  67. package/remult-duckdb.d.ts +9 -0
  68. package/remult-duckdb.js +150 -0
  69. package/remult-hapi.d.ts +6 -0
  70. package/remult-hapi.js +127 -0
  71. package/remult-hono.d.ts +7 -0
  72. package/remult-hono.js +115 -0
  73. package/remult-mongo.js +1 -1
  74. package/remult-nuxt.d.ts +6 -0
  75. package/remult-nuxt.js +78 -0
  76. package/remult-solid-start.d.ts +12 -0
  77. package/remult-solid-start.js +133 -0
  78. package/remult-sql-js.d.ts +5 -0
  79. package/remult-sql-js.js +73 -0
  80. package/remult-sqlite-core.d.ts +25 -0
  81. package/remult-sqlite-core.js +314 -0
  82. package/remult-sqlite3.d.ts +5 -0
  83. package/remult-sqlite3.js +76 -0
  84. package/remult-turso.d.ts +8 -0
  85. package/remult-turso.js +100 -0
  86. package/server/get-remult-admin-html.d.ts +1 -0
  87. package/server/get-remult-admin-html.js +6 -0
  88. package/server/initDataProviderOrJson.d.ts +2 -0
  89. package/server/initDataProviderOrJson.js +16 -0
  90. package/server/remult-admin.d.ts +43 -0
  91. package/server/remult-admin.js +123 -0
  92. package/{esm/core/server/expressBridge.d.ts → server/remult-api-server.d.ts} +75 -77
  93. package/server/remult-api-server.js +1626 -0
  94. package/src/CompoundIdField.d.ts +27 -0
  95. package/src/CompoundIdField.js +72 -0
  96. package/src/backend-tests/backend-database-test-setup.backend-spec.js +11 -10
  97. package/src/data-api.js +4 -2
  98. package/src/data-providers/json-entity-opfs-storage.d.ts +5 -0
  99. package/src/data-providers/json-entity-opfs-storage.js +74 -0
  100. package/src/isOfType.d.ts +2 -0
  101. package/src/isOfType.js +13 -0
  102. package/src/live-query/SubscriptionServer.js +2 -2
  103. package/src/remult-static.d.ts +26 -0
  104. package/src/remult-static.js +50 -0
  105. package/src/remult3/Fields.d.ts +170 -0
  106. package/src/remult3/Fields.js +419 -0
  107. package/src/remult3/IdEntity.d.ts +4 -0
  108. package/src/remult3/IdEntity.js +18 -0
  109. package/src/remult3/RepositoryImplementation.js +24 -22
  110. package/src/remult3/__updateEntityBasedOnWhere.d.ts +2 -0
  111. package/src/remult3/__updateEntityBasedOnWhere.js +31 -0
  112. package/src/remult3/addValidator.d.ts +2 -0
  113. package/src/remult3/addValidator.js +19 -0
  114. package/src/remult3/classDescribers.d.ts +16 -0
  115. package/src/remult3/classDescribers.js +40 -0
  116. package/src/remult3/columnInfo.d.ts +6 -0
  117. package/src/remult3/columnInfo.js +2 -0
  118. package/src/remult3/entity.d.ts +28 -0
  119. package/src/remult3/entity.js +86 -0
  120. package/src/remult3/getEntityRef.d.ts +18 -0
  121. package/src/remult3/getEntityRef.js +45 -0
  122. package/src/remult3/relation-loader-types.d.ts +7 -0
  123. package/src/remult3/relation-loader-types.js +2 -0
  124. package/src/remult3/relation-loader.d.ts +40 -0
  125. package/src/remult3/relation-loader.js +245 -0
  126. package/src/remult3/relationInfoMember.d.ts +30 -0
  127. package/src/remult3/relationInfoMember.js +149 -0
  128. package/src/remult3/repository-internals.d.ts +20 -0
  129. package/src/remult3/repository-internals.js +11 -0
  130. package/src/server-action-info.d.ts +1 -0
  131. package/src/server-action-info.js +4 -0
  132. package/src/shared-tests/db-tests.db-tests.js +1 -1
  133. package/esm/angular/interfaces/index.d.ts +0 -1
  134. package/esm/angular/interfaces/index.js +0 -1
  135. package/esm/angular/interfaces/src/column-collection.d.ts +0 -70
  136. package/esm/angular/interfaces/src/column-collection.js +0 -341
  137. package/esm/angular/interfaces/src/data-area-settings.d.ts +0 -15
  138. package/esm/angular/interfaces/src/data-area-settings.js +0 -35
  139. package/esm/angular/interfaces/src/data-control-interfaces.d.ts +0 -36
  140. package/esm/angular/interfaces/src/data-control-interfaces.js +0 -57
  141. package/esm/angular/interfaces/src/dataList.d.ts +0 -13
  142. package/esm/angular/interfaces/src/dataList.js +0 -42
  143. package/esm/angular/interfaces/src/filter-helper.d.ts +0 -13
  144. package/esm/angular/interfaces/src/filter-helper.js +0 -59
  145. package/esm/angular/interfaces/src/grid-settings.d.ts +0 -145
  146. package/esm/angular/interfaces/src/grid-settings.js +0 -387
  147. package/esm/angular/interfaces/src/public_api.d.ts +0 -4
  148. package/esm/angular/interfaces/src/public_api.js +0 -4
  149. package/esm/angular/src/angular/RemultAngularPluginsService.d.ts +0 -4
  150. package/esm/angular/src/angular/RemultAngularPluginsService.js +0 -3
  151. package/esm/angular/src/angular/data-control/data-control2.component.d.ts +0 -49
  152. package/esm/angular/src/angular/data-control/data-control2.component.js +0 -138
  153. package/esm/core/SseSubscriptionServer.d.ts +0 -33
  154. package/esm/core/SseSubscriptionServer.js +0 -107
  155. package/esm/core/assign.d.ts +0 -1
  156. package/esm/core/assign.js +0 -5
  157. package/esm/core/classType.d.ts +0 -3
  158. package/esm/core/index.d.ts +0 -27
  159. package/esm/core/index.js +0 -25
  160. package/esm/core/inputTypes.d.ts +0 -9
  161. package/esm/core/inputTypes.js +0 -9
  162. package/esm/core/live-query/data-provider-live-query-storage.d.ts +0 -22
  163. package/esm/core/live-query/data-provider-live-query-storage.js +0 -71
  164. package/esm/core/postgres/index.d.ts +0 -2
  165. package/esm/core/postgres/index.js +0 -2
  166. package/esm/core/postgres/postgres-data-provider.d.ts +0 -36
  167. package/esm/core/postgres/postgres-data-provider.js +0 -120
  168. package/esm/core/postgres/schema-builder.d.ts +0 -17
  169. package/esm/core/postgres/schema-builder.js +0 -153
  170. package/esm/core/remult-fresh.d.ts +0 -17
  171. package/esm/core/remult-fresh.js +0 -29
  172. package/esm/core/remult-knex/index.d.ts +0 -30
  173. package/esm/core/remult-knex/index.js +0 -446
  174. package/esm/core/remult-mongo.d.ts +0 -24
  175. package/esm/core/remult-mongo.js +0 -254
  176. package/esm/core/server/JsonEntityFileStorage.d.ts +0 -10
  177. package/esm/core/server/JsonEntityFileStorage.js +0 -25
  178. package/esm/core/server/core.d.ts +0 -4
  179. package/esm/core/server/core.js +0 -4
  180. package/esm/core/server/expressBridge.js +0 -938
  181. package/esm/core/server/index.d.ts +0 -6
  182. package/esm/core/server/index.js +0 -9
  183. package/esm/core/server/initAsyncHooks.d.ts +0 -1
  184. package/esm/core/server/initAsyncHooks.js +0 -9
  185. package/esm/core/server/initDataProvider.d.ts +0 -2
  186. package/esm/core/server/initDataProvider.js +0 -14
  187. package/esm/core/src/__EntityValueProvider.d.ts +0 -11
  188. package/esm/core/src/__RowsOfDataForTesting.d.ts +0 -3
  189. package/esm/core/src/__RowsOfDataForTesting.js +0 -1
  190. package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +0 -6
  191. package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.js +0 -147
  192. package/esm/core/src/backend-tests/my-test.backend-spec.d.ts +0 -1
  193. package/esm/core/src/backend-tests/my-test.backend-spec.js +0 -197
  194. package/esm/core/src/backend-tests/test-http-server.backend-spec.d.ts +0 -1
  195. package/esm/core/src/backend-tests/test-http-server.backend-spec.js +0 -167
  196. package/esm/core/src/buildRestDataProvider.d.ts +0 -31
  197. package/esm/core/src/buildRestDataProvider.js +0 -113
  198. package/esm/core/src/column-interfaces.d.ts +0 -154
  199. package/esm/core/src/column-interfaces.js +0 -7
  200. package/esm/core/src/column.d.ts +0 -58
  201. package/esm/core/src/column.js +0 -174
  202. package/esm/core/src/context.d.ts +0 -134
  203. package/esm/core/src/context.js +0 -286
  204. package/esm/core/src/data-api.d.ts +0 -39
  205. package/esm/core/src/data-api.js +0 -279
  206. package/esm/core/src/data-interfaces.d.ts +0 -41
  207. package/esm/core/src/data-interfaces.js +0 -12
  208. package/esm/core/src/data-providers/array-entity-data-provider.d.ts +0 -22
  209. package/esm/core/src/data-providers/array-entity-data-provider.js +0 -252
  210. package/esm/core/src/data-providers/in-memory-database.d.ts +0 -9
  211. package/esm/core/src/data-providers/in-memory-database.js +0 -14
  212. package/esm/core/src/data-providers/json-data-provider.d.ts +0 -12
  213. package/esm/core/src/data-providers/json-data-provider.js +0 -55
  214. package/esm/core/src/data-providers/rest-data-provider.d.ts +0 -49
  215. package/esm/core/src/data-providers/rest-data-provider.js +0 -256
  216. package/esm/core/src/data-providers/sql-database.d.ts +0 -33
  217. package/esm/core/src/data-providers/sql-database.js +0 -384
  218. package/esm/core/src/data-providers/web-sql-data-provider.d.ts +0 -24
  219. package/esm/core/src/data-providers/web-sql-data-provider.js +0 -143
  220. package/esm/core/src/entity.d.ts +0 -91
  221. package/esm/core/src/entity.js +0 -1
  222. package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.d.ts +0 -50
  223. package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.js +0 -150
  224. package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.d.ts +0 -1
  225. package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.js +0 -1
  226. package/esm/core/src/filter/filter-interfaces.d.ts +0 -85
  227. package/esm/core/src/filter/filter-interfaces.js +0 -477
  228. package/esm/core/src/live-query/LiveQueryClient.d.ts +0 -20
  229. package/esm/core/src/live-query/LiveQueryClient.js +0 -188
  230. package/esm/core/src/live-query/SseSubscriptionClient.d.ts +0 -5
  231. package/esm/core/src/live-query/SseSubscriptionClient.js +0 -86
  232. package/esm/core/src/live-query/SubscriptionChannel.d.ts +0 -72
  233. package/esm/core/src/live-query/SubscriptionChannel.js +0 -123
  234. package/esm/core/src/live-query/SubscriptionServer.d.ts +0 -53
  235. package/esm/core/src/live-query/SubscriptionServer.js +0 -111
  236. package/esm/core/src/live-query/live-query-tests.spec.d.ts +0 -6
  237. package/esm/core/src/live-query/live-query-tests.spec.js +0 -952
  238. package/esm/core/src/remult-proxy.d.ts +0 -35
  239. package/esm/core/src/remult-proxy.js +0 -113
  240. package/esm/core/src/remult3/DecoratorReplacer.d.ts +0 -10
  241. package/esm/core/src/remult3/RepositoryImplementation.d.ts +0 -355
  242. package/esm/core/src/remult3/RepositoryImplementation.js +0 -2109
  243. package/esm/core/src/remult3/index.d.ts +0 -2
  244. package/esm/core/src/remult3/index.js +0 -2
  245. package/esm/core/src/remult3/remult3.d.ts +0 -395
  246. package/esm/core/src/remult3/remult3.js +0 -2
  247. package/esm/core/src/server-action.d.ts +0 -81
  248. package/esm/core/src/server-action.js +0 -394
  249. package/esm/core/src/shared-tests/db-tests-setup.d.ts +0 -32
  250. package/esm/core/src/shared-tests/db-tests-setup.js +0 -78
  251. package/esm/core/src/shared-tests/db-tests.db-tests.d.ts +0 -25
  252. package/esm/core/src/shared-tests/db-tests.db-tests.js +0 -810
  253. package/esm/core/src/shared-tests/deleteAll.d.ts +0 -2
  254. package/esm/core/src/shared-tests/deleteAll.js +0 -4
  255. package/esm/core/src/shared-tests/entityWithValidations.d.ts +0 -14
  256. package/esm/core/src/shared-tests/entityWithValidations.js +0 -43
  257. package/esm/core/src/shared-tests/index.d.ts +0 -4
  258. package/esm/core/src/shared-tests/index.js +0 -4
  259. package/esm/core/src/shared-tests/test-custom-id-column.spec.d.ts +0 -1
  260. package/esm/core/src/shared-tests/test-custom-id-column.spec.js +0 -67
  261. package/esm/core/src/shared-tests/test-special-value.spec.d.ts +0 -10
  262. package/esm/core/src/shared-tests/test-special-value.spec.js +0 -73
  263. package/esm/core/src/shared-tests/test-update-with-null.spec.d.ts +0 -1
  264. package/esm/core/src/shared-tests/test-update-with-null.spec.js +0 -31
  265. package/esm/core/src/sort.d.ts +0 -16
  266. package/esm/core/src/sort.js +0 -103
  267. package/esm/core/src/sql-command.d.ts +0 -19
  268. package/esm/core/src/sql-command.js +0 -1
  269. package/esm/core/src/test.d.ts +0 -3
  270. package/esm/core/src/test.js +0 -12
  271. package/esm/core/src/tests/Done.d.ts +0 -5
  272. package/esm/core/src/tests/Done.js +0 -9
  273. package/esm/core/src/tests/RowProvider.spec.d.ts +0 -16
  274. package/esm/core/src/tests/RowProvider.spec.js +0 -631
  275. package/esm/core/src/tests/TestDataApiResponse.d.ts +0 -10
  276. package/esm/core/src/tests/TestDataApiResponse.js +0 -22
  277. package/esm/core/src/tests/basicRowFunctionality.spec.d.ts +0 -8
  278. package/esm/core/src/tests/basicRowFunctionality.spec.js +0 -2103
  279. package/esm/core/src/tests/c.d.ts +0 -8
  280. package/esm/core/src/tests/c.js +0 -13
  281. package/esm/core/src/tests/createData.d.ts +0 -7
  282. package/esm/core/src/tests/createData.js +0 -22
  283. package/esm/core/src/tests/d.d.ts +0 -6
  284. package/esm/core/src/tests/d.js +0 -11
  285. package/esm/core/src/tests/dWithPrefilter.d.ts +0 -7
  286. package/esm/core/src/tests/dWithPrefilter.js +0 -18
  287. package/esm/core/src/tests/entityForCustomFilter.d.ts +0 -16
  288. package/esm/core/src/tests/entityForCustomFilter.js +0 -33
  289. package/esm/core/src/tests/entityWithValidationsOnColumn.d.ts +0 -5
  290. package/esm/core/src/tests/entityWithValidationsOnColumn.js +0 -13
  291. package/esm/core/src/tests/frontend-database-tests-setup.spec.d.ts +0 -4
  292. package/esm/core/src/tests/frontend-database-tests-setup.spec.js +0 -37
  293. package/esm/core/src/tests/h.d.ts +0 -6
  294. package/esm/core/src/tests/h.js +0 -24
  295. package/esm/core/src/tests/remult-3-basic-tests.spec.d.ts +0 -1
  296. package/esm/core/src/tests/remult-3-basic-tests.spec.js +0 -236
  297. package/esm/core/src/tests/remult-3-entities.d.ts +0 -23
  298. package/esm/core/src/tests/remult-3-entities.js +0 -39
  299. package/esm/core/src/tests/tasks.d.ts +0 -6
  300. package/esm/core/src/tests/tasks.js +0 -10
  301. package/esm/core/src/tests/test-context-as-storage.spec.d.ts +0 -0
  302. package/esm/core/src/tests/test-context-as-storage.spec.js +0 -1
  303. package/esm/core/src/tests/test-data-api/predefined-filter.spec.d.ts +0 -1
  304. package/esm/core/src/tests/test-data-api/predefined-filter.spec.js +0 -389
  305. package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.d.ts +0 -5
  306. package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.js +0 -152
  307. package/esm/core/src/tests/test-decorator-precedence.spec.d.ts +0 -1
  308. package/esm/core/src/tests/test-decorator-precedence.spec.js +0 -38
  309. package/esm/core/src/tests/test-default-value.spec.d.ts +0 -1
  310. package/esm/core/src/tests/test-default-value.spec.js +0 -33
  311. package/esm/core/src/tests/test-entity-inheritance.spec.d.ts +0 -14
  312. package/esm/core/src/tests/test-entity-inheritance.spec.js +0 -82
  313. package/esm/core/src/tests/test-exceptions.spec.d.ts +0 -1
  314. package/esm/core/src/tests/test-exceptions.spec.js +0 -375
  315. package/esm/core/src/tests/test-json.spec.d.ts +0 -1
  316. package/esm/core/src/tests/test-json.spec.js +0 -115
  317. package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.d.ts +0 -9
  318. package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.js +0 -809
  319. package/esm/core/src/tests/test-non-active-record.spec.d.ts +0 -1
  320. package/esm/core/src/tests/test-non-active-record.spec.js +0 -66
  321. package/esm/core/src/tests/test-object-column.spec.d.ts +0 -1
  322. package/esm/core/src/tests/test-object-column.spec.js +0 -189
  323. package/esm/core/src/tests/test-paged-foreach.spec.d.ts +0 -1
  324. package/esm/core/src/tests/test-paged-foreach.spec.js +0 -328
  325. package/esm/core/src/tests/test-remult-angular.spec.d.ts +0 -1
  326. package/esm/core/src/tests/test-remult-angular.spec.js +0 -23
  327. package/esm/core/src/tests/test-server-controller.spec.d.ts +0 -7
  328. package/esm/core/src/tests/test-server-controller.spec.js +0 -489
  329. package/esm/core/src/tests/test-server-expressions.spec.d.ts +0 -1
  330. package/esm/core/src/tests/test-server-expressions.spec.js +0 -178
  331. package/esm/core/src/tests/test-server-method-on-entity.spec.d.ts +0 -1
  332. package/esm/core/src/tests/test-server-method-on-entity.spec.js +0 -306
  333. package/esm/core/src/tests/test-sql-expression.spec.d.ts +0 -5
  334. package/esm/core/src/tests/test-sql-expression.spec.js +0 -205
  335. package/esm/core/src/tests/test-sql.spec.d.ts +0 -1
  336. package/esm/core/src/tests/test-sql.spec.js +0 -170
  337. package/esm/core/src/tests/test-subscribe.spec.d.ts +0 -1
  338. package/esm/core/src/tests/test-subscribe.spec.js +0 -135
  339. package/esm/core/src/tests/test-type-recovery.spec.d.ts +0 -1
  340. package/esm/core/src/tests/test-type-recovery.spec.js +0 -49
  341. package/esm/core/src/tests/test-where-api.spec.d.ts +0 -1
  342. package/esm/core/src/tests/test-where-api.spec.js +0 -434
  343. package/esm/core/src/tests/testHelper.spec.d.ts +0 -36
  344. package/esm/core/src/tests/testHelper.spec.js +0 -226
  345. package/esm/core/src/tests/testModel/models.d.ts +0 -16
  346. package/esm/core/src/tests/testModel/models.js +0 -25
  347. package/esm/core/src/validators.d.ts +0 -14
  348. package/esm/core/src/validators.js +0 -33
  349. package/esm/core/src/valueConverters.d.ts +0 -13
  350. package/esm/core/src/valueConverters.js +0 -197
  351. package/esm/core/urlBuilder.d.ts +0 -6
  352. package/esm/core/urlBuilder.js +0 -20
  353. package/esm/test-servers/shared/Task.d.ts +0 -9
  354. package/esm/test-servers/shared/Task.js +0 -32
  355. package/esm/test.d.ts +0 -5
  356. package/esm/test.js +0 -6
  357. /package/esm/{core/classType.js → src/remult3/columnInfo.js} +0 -0
  358. /package/esm/{core/src/__EntityValueProvider.js → src/remult3/relation-loader-types.js} +0 -0
@@ -0,0 +1,62 @@
1
+ export class CompoundIdField {
2
+ fields;
3
+ constructor(...columns) {
4
+ this.fields = columns;
5
+ }
6
+ apiUpdateAllowed(item) {
7
+ throw new Error('Method not implemented.');
8
+ }
9
+ displayValue(item) {
10
+ throw new Error('Method not implemented.');
11
+ }
12
+ includedInApi(item) {
13
+ throw new Error('Method not implemented.');
14
+ }
15
+ toInput(value, inputType) {
16
+ throw new Error('Method not implemented.');
17
+ }
18
+ fromInput(inputValue, inputType) {
19
+ throw new Error('Method not implemented.');
20
+ }
21
+ getDbName() {
22
+ return Promise.resolve('');
23
+ }
24
+ getId(instance) {
25
+ let get = (field) => {
26
+ return instance[field.key];
27
+ };
28
+ if (typeof instance === 'function') {
29
+ get = instance;
30
+ }
31
+ let r = '';
32
+ this.fields.forEach((c) => {
33
+ if (r.length > 0)
34
+ r += ',';
35
+ r += c.valueConverter.toJson(get(c));
36
+ });
37
+ return r;
38
+ }
39
+ options = {};
40
+ get valueConverter() {
41
+ throw new Error('cant get value converter of compound id');
42
+ }
43
+ target;
44
+ readonly = true;
45
+ allowNull = false;
46
+ dbReadOnly = false;
47
+ isServerExpression = false;
48
+ key = '';
49
+ caption = '';
50
+ inputType = '';
51
+ dbName = '';
52
+ valueType;
53
+ isEqualTo(value) {
54
+ let result = {};
55
+ let val = value.toString();
56
+ let id = val.split(',');
57
+ this.fields.forEach((c, i) => {
58
+ result[c.key] = c.valueConverter.fromJson(id[i]);
59
+ });
60
+ return result;
61
+ }
62
+ }
@@ -64,16 +64,17 @@ export const mySqlTest = addDatabaseToTest(testKnexSqlImpl(Knex.default({
64
64
  database: 'test',
65
65
  },
66
66
  }), 'mysql2'));
67
- addDatabaseToTest(testKnexSqlImpl(Knex.default({
68
- client: 'mysql',
69
- connection: {
70
- user: 'root',
71
- password: 'MASTERKEY',
72
- host: '127.0.0.1',
73
- database: 'test',
74
- port: 3307
75
- },
76
- }), 'mysql'));
67
+ if (false)
68
+ addDatabaseToTest(testKnexSqlImpl(Knex.default({
69
+ client: 'mysql',
70
+ connection: {
71
+ user: 'root',
72
+ password: 'MASTERKEY',
73
+ host: '127.0.0.1',
74
+ database: 'test',
75
+ port: 3307,
76
+ },
77
+ }), 'mysql'));
77
78
  let pg = createPostgresConnection();
78
79
  export function testPostgresImplementation(key, what, focus = false) {
79
80
  itWithFocus(key + ' - postgres', async () => {
@@ -22,7 +22,7 @@ export class DataApi {
22
22
  async httpPost(res, req, body, serializeContext) {
23
23
  const action = req?.get('__action');
24
24
  if (action?.startsWith(liveQueryAction))
25
- return this.liveQuery(res, req, undefined, serializeContext, action.substring(liveQueryAction.length));
25
+ return this.liveQuery(res, req, body, serializeContext, action.substring(liveQueryAction.length));
26
26
  switch (action) {
27
27
  case 'get':
28
28
  return this.getArray(res, req, body);
@@ -159,7 +159,9 @@ export class DataApi {
159
159
  where.push(buildFilterFromRequestParameters(this.repository.metadata, {
160
160
  get: (key) => {
161
161
  let result = request.get(key);
162
- if (key.startsWith(customUrlToken) && result && typeof result === "string")
162
+ if (key.startsWith(customUrlToken) &&
163
+ result &&
164
+ typeof result === 'string')
163
165
  return JSON.parse(result);
164
166
  return result;
165
167
  },
@@ -0,0 +1,26 @@
1
+ export class JsonEntityOpfsStorage {
2
+ //@internal
3
+ opfsRoot;
4
+ async getItem(entityDbName) {
5
+ const opfsFile = await (await this.init()).getFileHandle(entityDbName + '.json', {
6
+ create: true,
7
+ });
8
+ const readable = await opfsFile.getFile();
9
+ return await readable.text();
10
+ }
11
+ //@internal
12
+ async init() {
13
+ if (!this.opfsRoot) {
14
+ this.opfsRoot = await navigator.storage.getDirectory();
15
+ }
16
+ return this.opfsRoot;
17
+ }
18
+ async setItem(entityDbName, json) {
19
+ const opfsFile = await await (await this.init()).getFileHandle(entityDbName + '.json', {
20
+ create: true,
21
+ });
22
+ const writable = await opfsFile.createWritable();
23
+ await writable.write(json);
24
+ await writable.close();
25
+ }
26
+ }
@@ -0,0 +1,9 @@
1
+ export function isOfType(obj, checkMethod) {
2
+ return typeof obj[checkMethod] !== 'undefined';
3
+ }
4
+ export function cast(obj, checkMethod) {
5
+ if (isOfType(obj, checkMethod)) {
6
+ return obj;
7
+ }
8
+ throw new Error(`Object is not of type ${checkMethod.toString()}`);
9
+ }
@@ -10,7 +10,7 @@ export class LiveQueryPublisher {
10
10
  runPromise(p) { }
11
11
  async itemChanged(entityKey, changes) {
12
12
  //TODO 2 - optimize so that the user will get their messages first. Based on user id
13
- await this.liveQueryStorage().forEach(entityKey, async ({ query: q, setData }) => {
13
+ await this.runPromise(this.liveQueryStorage().forEach(entityKey, async ({ query: q, setData }) => {
14
14
  let query = { ...q.data };
15
15
  await this.performWithContext(query.requestJson, entityKey, async (repo) => {
16
16
  const messages = [];
@@ -59,7 +59,7 @@ export class LiveQueryPublisher {
59
59
  if (messages.length > 0)
60
60
  this.subscriptionServer().publishMessage(q.id, messages);
61
61
  });
62
- });
62
+ }));
63
63
  }
64
64
  }
65
65
  export class InMemoryLiveQueryStorage {
@@ -0,0 +1,43 @@
1
+ const remultStaticKey = Symbol.for('remult-static1');
2
+ let x = {
3
+ defaultRemultFactory: undefined,
4
+ remultFactory: undefined,
5
+ defaultRemult: undefined,
6
+ asyncContext: undefined,
7
+ columnsOfType: new Map(),
8
+ allEntities: [],
9
+ classHelpers: new Map(),
10
+ actionInfo: {
11
+ allActions: [],
12
+ runningOnServer: false,
13
+ runActionWithoutBlockingUI: (what) => {
14
+ return what();
15
+ },
16
+ startBusyWithProgress: () => ({
17
+ progress: (percent) => { },
18
+ close: () => { },
19
+ }),
20
+ },
21
+ captionTransformer: undefined,
22
+ defaultDataProvider: () => undefined,
23
+ };
24
+ if ((typeof process !== 'undefined' &&
25
+ process.env['IGNORE_GLOBAL_REMULT_IN_TESTS']) ||
26
+ typeof globalThis[remultStaticKey] === 'undefined') {
27
+ ;
28
+ globalThis[remultStaticKey] = x;
29
+ x.remultFactory = () => defaultFactory();
30
+ }
31
+ else {
32
+ x = globalThis[remultStaticKey];
33
+ }
34
+ export const remultStatic = x;
35
+ export function defaultFactory() {
36
+ if (!remultStatic.defaultRemult) {
37
+ remultStatic.defaultRemult = remultStatic.defaultRemultFactory();
38
+ }
39
+ return remultStatic.defaultRemult;
40
+ }
41
+ export function resetFactory() {
42
+ remultStatic.remultFactory = () => defaultFactory();
43
+ }
@@ -0,0 +1,335 @@
1
+ import { createId } from '@paralleldrive/cuid2';
2
+ import { v4 as uuid } from 'uuid';
3
+ import { ValueConverters } from '../valueConverters.js';
4
+ import { buildOptions, fieldOptionalValuesFunctionKey, } from './RepositoryImplementation.js';
5
+ import { Validators, createValueValidator, getEnumValues, } from '../validators.js';
6
+ import { relationInfoMemberInOptions } from './relationInfoMember.js';
7
+ import { remultStatic } from '../remult-static.js';
8
+ import { addValidator } from './addValidator.js';
9
+ import { isOfType } from '../isOfType.js';
10
+ const validateNumber = createValueValidator((x) => {
11
+ return !isNaN(x) && isFinite(x);
12
+ });
13
+ export class Fields {
14
+ /**
15
+ * Stored as a JSON.stringify - to store as json use Fields.json
16
+ */
17
+ static object(...options) {
18
+ return Field(undefined, ...options);
19
+ }
20
+ static json(...options) {
21
+ let op = options;
22
+ if (op.valueConverter && !op.valueConverter.fieldTypeInDb)
23
+ //@ts-ignore
24
+ op.valueConverter.fieldTypeInDb = 'json';
25
+ return Field(undefined, {
26
+ valueConverter: {
27
+ fieldTypeInDb: 'json',
28
+ },
29
+ }, ...options);
30
+ }
31
+ static dateOnly(...options) {
32
+ return Field(() => Date, {
33
+ valueConverter: ValueConverters.DateOnly,
34
+ }, ...options);
35
+ }
36
+ static date(...options) {
37
+ return Field(() => Date, ...options);
38
+ }
39
+ static integer(...options) {
40
+ return Field(() => Number, {
41
+ valueConverter: ValueConverters.Integer,
42
+ validate: validateNumber,
43
+ }, ...options);
44
+ }
45
+ static autoIncrement(...options) {
46
+ return Field(() => Number, {
47
+ allowApiUpdate: false,
48
+ dbReadOnly: true,
49
+ valueConverter: {
50
+ ...ValueConverters.Integer,
51
+ fieldTypeInDb: 'autoincrement',
52
+ },
53
+ }, ...options);
54
+ }
55
+ static number(...options) {
56
+ return Field(() => Number, {
57
+ validate: validateNumber,
58
+ }, ...options);
59
+ }
60
+ static createdAt(...options) {
61
+ return Field(() => Date, {
62
+ allowApiUpdate: false,
63
+ saving: (_, ref, { isNew }) => {
64
+ if (isNew)
65
+ ref.value = new Date();
66
+ },
67
+ }, ...options);
68
+ }
69
+ static updatedAt(...options) {
70
+ return Field(() => Date, {
71
+ allowApiUpdate: false,
72
+ saving: (_, ref) => {
73
+ ref.value = new Date();
74
+ },
75
+ }, ...options);
76
+ }
77
+ static uuid(...options) {
78
+ return Field(() => String, {
79
+ allowApiUpdate: false,
80
+ defaultValue: () => uuid(),
81
+ saving: (_, r) => {
82
+ if (!r.value)
83
+ r.value = uuid();
84
+ },
85
+ }, ...options);
86
+ }
87
+ /**
88
+ * A CUID (Collision Resistant Unique Identifier) field.
89
+ * This id value is determined on the backend on insert, and can't be updated through the API.
90
+ * The CUID is generated using the `@paralleldrive/cuid2` npm package.
91
+ */
92
+ static cuid(...options) {
93
+ return Field(() => String, {
94
+ allowApiUpdate: false,
95
+ defaultValue: () => createId(),
96
+ saving: (_, r) => {
97
+ if (!r.value)
98
+ r.value = createId();
99
+ },
100
+ }, ...options);
101
+ }
102
+ // static id<entityType = unknown>(
103
+ // options?: FieldOptions<entityType, string> & { idFactory?: () => string },
104
+ // ): ClassFieldDecorator<entityType, string | undefined> {
105
+ // let buildId = options?.idFactory ?? createId
106
+ // return Field(() => String, {
107
+ // allowApiUpdate: false,
108
+ // defaultValue: () => buildId(),
109
+ // saving: (_, r) => {
110
+ // if (!r.value) r.value = buildId()
111
+ // },
112
+ // })
113
+ // }
114
+ /**
115
+ * Defines a field that can hold a value from a specified set of string literals.
116
+ * @param {() => readonly valueType[]} optionalValues - A function that returns an array of allowed string literals.
117
+ * @returns {ClassFieldDecorator<entityType, valueType | undefined>} - A class field decorator.
118
+ *
119
+ * @example
120
+
121
+ * class MyEntity {
122
+ * .@Fields.literal(() => ['open', 'closed', 'frozen', 'in progress'] as const)
123
+ * status: 'open' | 'closed' | 'frozen' | 'in progress' = 'open';
124
+ * }
125
+
126
+ *
127
+ * // This defines a field `status` in `MyEntity` that can only hold the values 'open', 'closed', 'frozen', or 'in progress'.
128
+ *
129
+ * @example
130
+ * // For better reusability and maintainability:
131
+
132
+ * const statuses = ['open', 'closed', 'frozen', 'in progress'] as const;
133
+ * type StatusType = typeof statuses[number];
134
+ *
135
+ * class MyEntity {
136
+ * .@Fields.literal(() => statuses)
137
+ * status: StatusType = 'open';
138
+ * }
139
+
140
+ *
141
+ * // This approach allows easy management and updates of the allowed values for the `status` field.
142
+ */
143
+ static literal(optionalValues, ...options) {
144
+ return Fields.string({
145
+ validate: (entity, event) => Validators.in(optionalValues())(entity, event),
146
+ //@ts-expect-error as we are adding this to options without it being defined in options
147
+ [fieldOptionalValuesFunctionKey]: optionalValues,
148
+ }, ...options);
149
+ }
150
+ static enum(enumType, ...options) {
151
+ let valueConverter;
152
+ return Field(
153
+ //@ts-ignore
154
+ () => enumType(), {
155
+ validate: (entity, event) => Validators.enum(enumType())(entity, event),
156
+ [fieldOptionalValuesFunctionKey]: () => getEnumValues(enumType()),
157
+ }, ...options, (options) => {
158
+ ;
159
+ options[fieldOptionalValuesFunctionKey] = () => getEnumValues(enumType());
160
+ if (valueConverter === undefined) {
161
+ let enumObj = enumType();
162
+ let enumValues = getEnumValues(enumObj);
163
+ valueConverter = enumValues.find((x) => typeof x === 'string')
164
+ ? ValueConverters.String
165
+ : ValueConverters.Integer;
166
+ }
167
+ if (!options.valueConverter) {
168
+ options.valueConverter = valueConverter;
169
+ }
170
+ else if (!options.valueConverter.fieldTypeInDb) {
171
+ //@ts-ignore
172
+ options.valueConverter.fieldTypeInDb = valueConverter.fieldTypeInDb;
173
+ }
174
+ });
175
+ }
176
+ static string(...options) {
177
+ return Field(() => String, ...options);
178
+ }
179
+ static boolean(...options) {
180
+ return Field(() => Boolean, ...options);
181
+ }
182
+ }
183
+ export class Relations {
184
+ /**
185
+ * Define a to-one relation between entities, indicating a one-to-one relationship.
186
+ * If no field or fields are provided, it will automatically create a field in the database
187
+ * to represent the relation.
188
+ *
189
+ * @param toEntityType A function that returns the target entity type.
190
+ * @param options (Optional): An object containing options for configuring the to-one relation.
191
+ * @returns A decorator function to apply the to-one relation to an entity field.
192
+ *
193
+ * Example usage:
194
+ * ```
195
+ * @Relations.toOne(() => Customer)
196
+ * customer?: Customer;
197
+ * ```
198
+ * ```
199
+ * Fields.string()
200
+ * customerId?: string;
201
+ *
202
+ * @Relations.toOne(() => Customer, "customerId")
203
+ * customer?: Customer;
204
+ * ```
205
+ * ```
206
+ * Fields.string()
207
+ * customerId?: string;
208
+ *
209
+ * @Relations.toOne(() => Customer, {
210
+ * field: "customerId",
211
+ * defaultIncluded: true
212
+ * })
213
+ * customer?: Customer;
214
+ * ```
215
+ * ```
216
+ * Fields.string()
217
+ * customerId?: string;
218
+ *
219
+ * @Relations.toOne(() => Customer, {
220
+ * fields: {
221
+ * customerId: "id",
222
+ * },
223
+ * })
224
+ * customer?: Customer;
225
+ * ```
226
+ */
227
+ static toOne(toEntityType, options) {
228
+ let op = (typeof options === 'string'
229
+ ? { field: options }
230
+ : !options
231
+ ? {}
232
+ : options);
233
+ if (!op.field && !op.fields && !op.findOptions)
234
+ //@ts-ignore
235
+ return Field(toEntityType, {
236
+ ...op,
237
+ ...relationInfoMemberInOptions(toEntityType, 'reference'),
238
+ });
239
+ return Field(() => undefined, {
240
+ ...op,
241
+ serverExpression: () => undefined,
242
+ ...relationInfoMemberInOptions(toEntityType, 'toOne'),
243
+ });
244
+ }
245
+ static toMany(toEntityType, options) {
246
+ let op = (typeof options === 'string'
247
+ ? { field: options }
248
+ : options);
249
+ return Field(() => undefined, {
250
+ ...op,
251
+ serverExpression: () => undefined,
252
+ ...relationInfoMemberInOptions(toEntityType, 'toMany'),
253
+ });
254
+ }
255
+ }
256
+ /**Decorates fields that should be used as fields.
257
+ * for more info see: [Field Types](https://remult.dev/docs/field-types.html)
258
+ *
259
+ * FieldOptions can be set in two ways:
260
+ * @example
261
+ * // as an object
262
+ * @Fields.string({ includeInApi:false })
263
+ * title='';
264
+ * @example
265
+ * // as an arrow function that receives `remult` as a parameter
266
+ * @Fields.string((options,remult) => options.includeInApi = true)
267
+ * title='';
268
+ */
269
+ export function Field(valueType, ...options) {
270
+ // import ANT!!!! if you call this in another decorator, make sure to set It's return type correctly with the | undefined
271
+ return (target, context, c) => {
272
+ const key = typeof context === 'string' ? context : context.name.toString();
273
+ let factory = (remult) => {
274
+ let r = buildOptions(options, remult);
275
+ if (r.required) {
276
+ r.validate = addValidator(r.validate, Validators.required, true);
277
+ }
278
+ if (isOfType(r, 'maxLength')) {
279
+ let z = r;
280
+ if (z.maxLength) {
281
+ z.validate = addValidator(z.validate, Validators.maxLength(z.maxLength));
282
+ }
283
+ }
284
+ if (isOfType(r, 'minLength')) {
285
+ let z = r;
286
+ if (z.minLength) {
287
+ z.validate = addValidator(z.validate, Validators.minLength(z.minLength));
288
+ }
289
+ }
290
+ if (!r.valueType && valueType) {
291
+ r.valueType = valueType();
292
+ }
293
+ if (!r.key) {
294
+ r.key = key;
295
+ }
296
+ if (!r.dbName)
297
+ r.dbName = r.key;
298
+ let type = r.valueType;
299
+ if (!type) {
300
+ type =
301
+ typeof Reflect.getMetadata == 'function'
302
+ ? Reflect.getMetadata('design:type', target, key)
303
+ : [];
304
+ r.valueType = type;
305
+ }
306
+ if (!r.target)
307
+ r.target = target;
308
+ return r;
309
+ };
310
+ checkTarget(target);
311
+ let names = remultStatic.columnsOfType.get(target.constructor);
312
+ if (!names) {
313
+ names = [];
314
+ remultStatic.columnsOfType.set(target.constructor, names);
315
+ }
316
+ let set = names.find((x) => x.key == key);
317
+ if (!set)
318
+ names.push({
319
+ key,
320
+ settings: factory,
321
+ });
322
+ else {
323
+ let prev = set.settings;
324
+ set.settings = (c) => {
325
+ let prevO = prev(c);
326
+ let curr = factory(c);
327
+ return Object.assign(prevO, curr);
328
+ };
329
+ }
330
+ };
331
+ }
332
+ export function checkTarget(target) {
333
+ if (!target)
334
+ throw new Error("Set the 'experimentalDecorators:true' option in your 'tsconfig' or 'jsconfig' (target undefined)");
335
+ }
@@ -0,0 +1,10 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Fields } from './Fields.js';
3
+ import { EntityBase } from './RepositoryImplementation.js';
4
+ export class IdEntity extends EntityBase {
5
+ id;
6
+ }
7
+ __decorate([
8
+ Fields.uuid(),
9
+ __metadata("design:type", String)
10
+ ], IdEntity.prototype, "id", void 0);
@@ -937,7 +937,9 @@ export class rowHelperImplementation extends rowHelperBase {
937
937
  if (this.wasDeleted())
938
938
  throw new Error('cannot save a deleted row');
939
939
  this.isLoading = true;
940
- if (onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject === undefined) // no need
940
+ if (onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject ===
941
+ undefined)
942
+ // no need
941
943
  await this.__validateEntity();
942
944
  let doNotSave = false;
943
945
  for (const col of this.fields) {
@@ -952,7 +954,8 @@ export class rowHelperImplementation extends rowHelperBase {
952
954
  let ignoreKeys = [];
953
955
  for (const field of this.metadata.fields) {
954
956
  if (field.dbReadOnly ||
955
- (onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject !== undefined &&
957
+ (onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject !==
958
+ undefined &&
956
959
  !onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject.includes(field.key))) {
957
960
  d[field.key] = undefined;
958
961
  ignoreKeys.push(field.key);
@@ -998,7 +1001,7 @@ export class rowHelperImplementation extends rowHelperBase {
998
1001
  for (const listener of this.repository.listeners.filter((x) => x.saved)) {
999
1002
  await listener.saved(this.instance, isNew);
1000
1003
  }
1001
- await this.repository.remult.liveQueryPublisher.itemChanged(this.repository.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: false }]);
1004
+ this.repository.remult.liveQueryPublisher.itemChanged(this.repository.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: false }]);
1002
1005
  this.saveOriginalData();
1003
1006
  this._isNew = false;
1004
1007
  return this.instance;
@@ -1029,7 +1032,7 @@ export class rowHelperImplementation extends rowHelperBase {
1029
1032
  for (const listener of this.repository.listeners.filter((x) => x.deleted)) {
1030
1033
  await listener.deleted(this.instance);
1031
1034
  }
1032
- await this.repository.remult.liveQueryPublisher.itemChanged(this.repository.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: true }]);
1035
+ this.repository.remult.liveQueryPublisher.itemChanged(this.repository.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: true }]);
1033
1036
  this._wasDeleted = true;
1034
1037
  }
1035
1038
  catch (err) {
@@ -0,0 +1,28 @@
1
+ import { Filter } from '../filter/filter-interfaces.js';
2
+ export function __updateEntityBasedOnWhere(entityDefs, where, r) {
3
+ let w = Filter.fromEntityFilter(entityDefs, where);
4
+ const emptyFunction = () => { };
5
+ if (w) {
6
+ w.__applyToConsumer({
7
+ custom: emptyFunction,
8
+ databaseCustom: emptyFunction,
9
+ containsCaseInsensitive: emptyFunction,
10
+ notContainsCaseInsensitive: emptyFunction,
11
+ startsWithCaseInsensitive: emptyFunction,
12
+ endsWithCaseInsensitive: emptyFunction,
13
+ isDifferentFrom: emptyFunction,
14
+ isEqualTo: (col, val) => {
15
+ r[col.key] = val;
16
+ },
17
+ isGreaterOrEqualTo: emptyFunction,
18
+ isGreaterThan: emptyFunction,
19
+ isIn: emptyFunction,
20
+ isLessOrEqualTo: emptyFunction,
21
+ isLessThan: emptyFunction,
22
+ isNotNull: emptyFunction,
23
+ isNull: emptyFunction,
24
+ not: emptyFunction,
25
+ or: emptyFunction,
26
+ });
27
+ }
28
+ }
@@ -0,0 +1,15 @@
1
+ export function addValidator(validators, newValidator, atStart = false) {
2
+ if (!newValidator)
3
+ return validators;
4
+ const newValidators = Array.isArray(newValidator)
5
+ ? newValidator
6
+ : [newValidator];
7
+ const validatorsArray = Array.isArray(validators)
8
+ ? validators
9
+ : validators
10
+ ? [validators]
11
+ : [];
12
+ return atStart
13
+ ? [...newValidators, ...validatorsArray]
14
+ : [...validatorsArray, ...newValidators];
15
+ }
@@ -1,6 +1,8 @@
1
- export function describeClass(classType, classDecorator, members, staticMembers) {
2
- if (classDecorator)
3
- classDecorator(classType);
1
+ import { BackendMethod } from '../server-action.js';
2
+ import { Entity } from './entity.js';
3
+ export function describeClass(classType, classDescriber, members, staticMembers) {
4
+ if (classDescriber)
5
+ classDescriber(classType);
4
6
  for (const fieldKey in members) {
5
7
  if (Object.prototype.hasOwnProperty.call(members, fieldKey)) {
6
8
  const element = members[fieldKey];
@@ -18,3 +20,16 @@ export function describeClass(classType, classDecorator, members, staticMembers)
18
20
  Object.defineProperty(classType, staticFieldKey, prop);
19
21
  }
20
22
  }
23
+ export function describeBackendMethods(classType, backendMethods) {
24
+ let result = {};
25
+ for (const key in backendMethods) {
26
+ if (Object.prototype.hasOwnProperty.call(backendMethods, key)) {
27
+ const options = backendMethods[key];
28
+ result[key] = BackendMethod(options);
29
+ }
30
+ }
31
+ describeClass(classType, undefined, undefined, result);
32
+ }
33
+ export function describeEntity(classType, key, fields, options) {
34
+ describeClass(classType, Entity(key, options), fields);
35
+ }