remult 0.21.1 → 0.22.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.
- package/README.md +47 -46
- package/SseSubscriptionServer.js +9 -9
- package/ably.js +1 -1
- package/esm/SseSubscriptionServer.js +11 -11
- package/esm/ably.js +2 -2
- package/esm/angular/interfaces/index.d.ts +1 -0
- package/esm/angular/interfaces/index.js +1 -0
- package/esm/angular/interfaces/src/column-collection.d.ts +70 -0
- package/esm/angular/interfaces/src/column-collection.js +341 -0
- package/esm/angular/interfaces/src/data-area-settings.d.ts +15 -0
- package/esm/angular/interfaces/src/data-area-settings.js +35 -0
- package/esm/angular/interfaces/src/data-control-interfaces.d.ts +36 -0
- package/esm/angular/interfaces/src/data-control-interfaces.js +57 -0
- package/esm/angular/interfaces/src/dataList.d.ts +13 -0
- package/esm/angular/interfaces/src/dataList.js +42 -0
- package/esm/angular/interfaces/src/filter-helper.d.ts +13 -0
- package/esm/angular/interfaces/src/filter-helper.js +59 -0
- package/esm/angular/interfaces/src/grid-settings.d.ts +145 -0
- package/esm/angular/interfaces/src/grid-settings.js +387 -0
- package/esm/angular/interfaces/src/public_api.d.ts +4 -0
- package/esm/angular/interfaces/src/public_api.js +4 -0
- package/esm/angular/src/angular/RemultAngularPluginsService.d.ts +4 -0
- package/esm/angular/src/angular/RemultAngularPluginsService.js +3 -0
- package/esm/angular/src/angular/data-control/data-control2.component.d.ts +49 -0
- package/esm/angular/src/angular/data-control/data-control2.component.js +138 -0
- package/esm/core/SseSubscriptionServer.d.ts +33 -0
- package/esm/core/SseSubscriptionServer.js +107 -0
- package/esm/core/assign.d.ts +1 -0
- package/esm/core/assign.js +5 -0
- package/esm/core/classType.d.ts +3 -0
- package/esm/core/classType.js +1 -0
- package/esm/core/index.d.ts +27 -0
- package/esm/core/index.js +25 -0
- package/esm/core/inputTypes.d.ts +9 -0
- package/esm/core/inputTypes.js +9 -0
- package/esm/core/live-query/data-provider-live-query-storage.d.ts +22 -0
- package/esm/core/live-query/data-provider-live-query-storage.js +71 -0
- package/esm/core/postgres/index.d.ts +2 -0
- package/esm/core/postgres/index.js +2 -0
- package/esm/core/postgres/postgres-data-provider.d.ts +36 -0
- package/esm/core/postgres/postgres-data-provider.js +120 -0
- package/esm/core/postgres/schema-builder.d.ts +17 -0
- package/esm/core/postgres/schema-builder.js +153 -0
- package/esm/core/remult-fresh.d.ts +17 -0
- package/esm/core/remult-fresh.js +29 -0
- package/esm/core/remult-knex/index.d.ts +30 -0
- package/esm/core/remult-knex/index.js +446 -0
- package/esm/core/remult-mongo.d.ts +24 -0
- package/esm/core/remult-mongo.js +254 -0
- package/esm/core/server/JsonEntityFileStorage.d.ts +10 -0
- package/esm/core/server/JsonEntityFileStorage.js +25 -0
- package/esm/core/server/core.d.ts +4 -0
- package/esm/core/server/core.js +4 -0
- package/esm/core/server/expressBridge.d.ts +182 -0
- package/esm/core/server/expressBridge.js +938 -0
- package/esm/core/server/index.d.ts +6 -0
- package/esm/core/server/index.js +9 -0
- package/esm/core/server/initAsyncHooks.d.ts +1 -0
- package/esm/core/server/initAsyncHooks.js +9 -0
- package/esm/core/server/initDataProvider.d.ts +2 -0
- package/esm/core/server/initDataProvider.js +14 -0
- package/esm/core/src/__EntityValueProvider.d.ts +11 -0
- package/esm/core/src/__EntityValueProvider.js +1 -0
- package/esm/core/src/__RowsOfDataForTesting.d.ts +3 -0
- package/esm/core/src/__RowsOfDataForTesting.js +1 -0
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +6 -0
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.js +147 -0
- package/esm/core/src/backend-tests/my-test.backend-spec.d.ts +1 -0
- package/esm/core/src/backend-tests/my-test.backend-spec.js +197 -0
- package/esm/core/src/backend-tests/test-http-server.backend-spec.d.ts +1 -0
- package/esm/core/src/backend-tests/test-http-server.backend-spec.js +167 -0
- package/esm/core/src/buildRestDataProvider.d.ts +31 -0
- package/esm/core/src/buildRestDataProvider.js +113 -0
- package/esm/core/src/column-interfaces.d.ts +154 -0
- package/esm/core/src/column-interfaces.js +7 -0
- package/esm/core/src/column.d.ts +58 -0
- package/esm/core/src/column.js +174 -0
- package/esm/core/src/context.d.ts +134 -0
- package/esm/core/src/context.js +286 -0
- package/esm/core/src/data-api.d.ts +39 -0
- package/esm/core/src/data-api.js +279 -0
- package/esm/core/src/data-interfaces.d.ts +41 -0
- package/esm/core/src/data-interfaces.js +12 -0
- package/esm/core/src/data-providers/array-entity-data-provider.d.ts +22 -0
- package/esm/core/src/data-providers/array-entity-data-provider.js +252 -0
- package/esm/core/src/data-providers/in-memory-database.d.ts +9 -0
- package/esm/core/src/data-providers/in-memory-database.js +14 -0
- package/esm/core/src/data-providers/json-data-provider.d.ts +12 -0
- package/esm/core/src/data-providers/json-data-provider.js +55 -0
- package/esm/core/src/data-providers/rest-data-provider.d.ts +49 -0
- package/esm/core/src/data-providers/rest-data-provider.js +256 -0
- package/esm/core/src/data-providers/sql-database.d.ts +33 -0
- package/esm/core/src/data-providers/sql-database.js +384 -0
- package/esm/core/src/data-providers/web-sql-data-provider.d.ts +24 -0
- package/esm/core/src/data-providers/web-sql-data-provider.js +143 -0
- package/esm/core/src/entity.d.ts +91 -0
- package/esm/core/src/entity.js +1 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.d.ts +50 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.js +150 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.d.ts +1 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.js +1 -0
- package/esm/core/src/filter/filter-interfaces.d.ts +85 -0
- package/esm/core/src/filter/filter-interfaces.js +477 -0
- package/esm/core/src/live-query/LiveQueryClient.d.ts +20 -0
- package/esm/core/src/live-query/LiveQueryClient.js +188 -0
- package/esm/core/src/live-query/SseSubscriptionClient.d.ts +5 -0
- package/esm/core/src/live-query/SseSubscriptionClient.js +86 -0
- package/esm/core/src/live-query/SubscriptionChannel.d.ts +72 -0
- package/esm/core/src/live-query/SubscriptionChannel.js +123 -0
- package/esm/core/src/live-query/SubscriptionServer.d.ts +53 -0
- package/esm/core/src/live-query/SubscriptionServer.js +111 -0
- package/esm/core/src/live-query/live-query-tests.spec.d.ts +6 -0
- package/esm/core/src/live-query/live-query-tests.spec.js +952 -0
- package/esm/core/src/remult-proxy.d.ts +35 -0
- package/esm/core/src/remult-proxy.js +113 -0
- package/esm/core/src/remult3/DecoratorReplacer.d.ts +10 -0
- package/esm/core/src/remult3/DecoratorReplacer.js +20 -0
- package/esm/core/src/remult3/RepositoryImplementation.d.ts +355 -0
- package/esm/core/src/remult3/RepositoryImplementation.js +2109 -0
- package/esm/core/src/remult3/index.d.ts +2 -0
- package/esm/core/src/remult3/index.js +2 -0
- package/esm/core/src/remult3/remult3.d.ts +395 -0
- package/esm/core/src/remult3/remult3.js +2 -0
- package/esm/core/src/server-action.d.ts +81 -0
- package/esm/core/src/server-action.js +394 -0
- package/esm/core/src/shared-tests/db-tests-setup.d.ts +32 -0
- package/esm/core/src/shared-tests/db-tests-setup.js +78 -0
- package/esm/core/src/shared-tests/db-tests.db-tests.d.ts +25 -0
- package/esm/core/src/shared-tests/db-tests.db-tests.js +810 -0
- package/esm/core/src/shared-tests/deleteAll.d.ts +2 -0
- package/esm/core/src/shared-tests/deleteAll.js +4 -0
- package/esm/core/src/shared-tests/entityWithValidations.d.ts +14 -0
- package/esm/core/src/shared-tests/entityWithValidations.js +43 -0
- package/esm/core/src/shared-tests/index.d.ts +4 -0
- package/esm/core/src/shared-tests/index.js +4 -0
- package/esm/core/src/shared-tests/test-custom-id-column.spec.d.ts +1 -0
- package/esm/core/src/shared-tests/test-custom-id-column.spec.js +67 -0
- package/esm/core/src/shared-tests/test-special-value.spec.d.ts +10 -0
- package/esm/core/src/shared-tests/test-special-value.spec.js +73 -0
- package/esm/core/src/shared-tests/test-update-with-null.spec.d.ts +1 -0
- package/esm/core/src/shared-tests/test-update-with-null.spec.js +31 -0
- package/esm/core/src/sort.d.ts +16 -0
- package/esm/core/src/sort.js +103 -0
- package/esm/core/src/sql-command.d.ts +19 -0
- package/esm/core/src/sql-command.js +1 -0
- package/esm/core/src/test.d.ts +3 -0
- package/esm/core/src/test.js +12 -0
- package/esm/core/src/tests/Done.d.ts +5 -0
- package/esm/core/src/tests/Done.js +9 -0
- package/esm/core/src/tests/RowProvider.spec.d.ts +16 -0
- package/esm/core/src/tests/RowProvider.spec.js +631 -0
- package/esm/core/src/tests/TestDataApiResponse.d.ts +10 -0
- package/esm/core/src/tests/TestDataApiResponse.js +22 -0
- package/esm/core/src/tests/basicRowFunctionality.spec.d.ts +8 -0
- package/esm/core/src/tests/basicRowFunctionality.spec.js +2103 -0
- package/esm/core/src/tests/c.d.ts +8 -0
- package/esm/core/src/tests/c.js +13 -0
- package/esm/core/src/tests/createData.d.ts +7 -0
- package/esm/core/src/tests/createData.js +22 -0
- package/esm/core/src/tests/d.d.ts +6 -0
- package/esm/core/src/tests/d.js +11 -0
- package/esm/core/src/tests/dWithPrefilter.d.ts +7 -0
- package/esm/core/src/tests/dWithPrefilter.js +18 -0
- package/esm/core/src/tests/entityForCustomFilter.d.ts +16 -0
- package/esm/core/src/tests/entityForCustomFilter.js +33 -0
- package/esm/core/src/tests/entityWithValidationsOnColumn.d.ts +5 -0
- package/esm/core/src/tests/entityWithValidationsOnColumn.js +13 -0
- package/esm/core/src/tests/frontend-database-tests-setup.spec.d.ts +4 -0
- package/esm/core/src/tests/frontend-database-tests-setup.spec.js +37 -0
- package/esm/core/src/tests/h.d.ts +6 -0
- package/esm/core/src/tests/h.js +24 -0
- package/esm/core/src/tests/remult-3-basic-tests.spec.d.ts +1 -0
- package/esm/core/src/tests/remult-3-basic-tests.spec.js +236 -0
- package/esm/core/src/tests/remult-3-entities.d.ts +23 -0
- package/esm/core/src/tests/remult-3-entities.js +39 -0
- package/esm/core/src/tests/tasks.d.ts +6 -0
- package/esm/core/src/tests/tasks.js +10 -0
- package/esm/core/src/tests/test-context-as-storage.spec.d.ts +0 -0
- package/esm/core/src/tests/test-context-as-storage.spec.js +1 -0
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.d.ts +1 -0
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.js +389 -0
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.d.ts +5 -0
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.js +152 -0
- package/esm/core/src/tests/test-decorator-precedence.spec.d.ts +1 -0
- package/esm/core/src/tests/test-decorator-precedence.spec.js +38 -0
- package/esm/core/src/tests/test-default-value.spec.d.ts +1 -0
- package/esm/core/src/tests/test-default-value.spec.js +33 -0
- package/esm/core/src/tests/test-entity-inheritance.spec.d.ts +14 -0
- package/esm/core/src/tests/test-entity-inheritance.spec.js +82 -0
- package/esm/core/src/tests/test-exceptions.spec.d.ts +1 -0
- package/esm/core/src/tests/test-exceptions.spec.js +375 -0
- package/esm/core/src/tests/test-json.spec.d.ts +1 -0
- package/esm/core/src/tests/test-json.spec.js +115 -0
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.d.ts +9 -0
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.js +809 -0
- package/esm/core/src/tests/test-non-active-record.spec.d.ts +1 -0
- package/esm/core/src/tests/test-non-active-record.spec.js +66 -0
- package/esm/core/src/tests/test-object-column.spec.d.ts +1 -0
- package/esm/core/src/tests/test-object-column.spec.js +189 -0
- package/esm/core/src/tests/test-paged-foreach.spec.d.ts +1 -0
- package/esm/core/src/tests/test-paged-foreach.spec.js +328 -0
- package/esm/core/src/tests/test-remult-angular.spec.d.ts +1 -0
- package/esm/core/src/tests/test-remult-angular.spec.js +23 -0
- package/esm/core/src/tests/test-server-controller.spec.d.ts +7 -0
- package/esm/core/src/tests/test-server-controller.spec.js +489 -0
- package/esm/core/src/tests/test-server-expressions.spec.d.ts +1 -0
- package/esm/core/src/tests/test-server-expressions.spec.js +178 -0
- package/esm/core/src/tests/test-server-method-on-entity.spec.d.ts +1 -0
- package/esm/core/src/tests/test-server-method-on-entity.spec.js +306 -0
- package/esm/core/src/tests/test-sql-expression.spec.d.ts +5 -0
- package/esm/core/src/tests/test-sql-expression.spec.js +205 -0
- package/esm/core/src/tests/test-sql.spec.d.ts +1 -0
- package/esm/core/src/tests/test-sql.spec.js +170 -0
- package/esm/core/src/tests/test-subscribe.spec.d.ts +1 -0
- package/esm/core/src/tests/test-subscribe.spec.js +135 -0
- package/esm/core/src/tests/test-type-recovery.spec.d.ts +1 -0
- package/esm/core/src/tests/test-type-recovery.spec.js +49 -0
- package/esm/core/src/tests/test-where-api.spec.d.ts +1 -0
- package/esm/core/src/tests/test-where-api.spec.js +434 -0
- package/esm/core/src/tests/testHelper.spec.d.ts +36 -0
- package/esm/core/src/tests/testHelper.spec.js +226 -0
- package/esm/core/src/tests/testModel/models.d.ts +16 -0
- package/esm/core/src/tests/testModel/models.js +25 -0
- package/esm/core/src/validators.d.ts +14 -0
- package/esm/core/src/validators.js +33 -0
- package/esm/core/src/valueConverters.d.ts +13 -0
- package/esm/core/src/valueConverters.js +197 -0
- package/esm/core/urlBuilder.d.ts +6 -0
- package/esm/core/urlBuilder.js +20 -0
- package/esm/graphql.js +194 -73
- package/esm/index.d.ts +10 -10
- package/esm/index.js +8 -8
- package/esm/inputTypes.js +1 -1
- package/esm/live-query/data-provider-live-query-storage.d.ts +3 -3
- package/esm/live-query/data-provider-live-query-storage.js +12 -9
- package/esm/myLog.js +2 -2
- package/esm/postgres/postgres-data-provider.d.ts +2 -2
- package/esm/postgres/postgres-data-provider.js +20 -14
- package/esm/postgres/schema-builder.d.ts +1 -1
- package/esm/postgres/schema-builder.js +28 -21
- package/esm/remult-express.js +2 -2
- package/esm/remult-fastify.js +9 -7
- package/esm/remult-fresh.d.ts +1 -1
- package/esm/remult-fresh.js +5 -8
- package/esm/remult-knex/index.d.ts +4 -4
- package/esm/remult-knex/index.js +75 -59
- package/esm/remult-mongo.js +36 -27
- package/esm/remult-next.d.ts +3 -3
- package/esm/remult-next.js +17 -11
- package/esm/remult-sveltekit.js +10 -10
- package/esm/server/JsonEntityFileStorage.js +3 -1
- package/esm/server/core.d.ts +2 -2
- package/esm/server/core.js +2 -2
- package/esm/server/expressBridge.d.ts +3 -12
- package/esm/server/expressBridge.js +265 -278
- package/esm/server/index.d.ts +2 -2
- package/esm/server/index.js +5 -2
- package/esm/server/initAsyncHooks.js +1 -1
- package/esm/server/initDataProvider.js +1 -1
- package/esm/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +1 -1
- package/esm/src/backend-tests/backend-database-test-setup.backend-spec.js +47 -38
- package/esm/src/buildRestDataProvider.d.ts +1 -1
- package/esm/src/buildRestDataProvider.js +21 -13
- package/esm/src/column-interfaces.d.ts +9 -9
- package/esm/src/column.d.ts +4 -0
- package/esm/src/column.js +23 -11
- package/esm/src/context.d.ts +20 -8
- package/esm/src/context.js +65 -24
- package/esm/src/data-api.d.ts +0 -1
- package/esm/src/data-api.js +38 -37
- package/esm/src/data-interfaces.d.ts +1 -1
- package/esm/src/data-interfaces.js +1 -1
- package/esm/src/data-providers/array-entity-data-provider.js +9 -9
- package/esm/src/data-providers/in-memory-database.d.ts +1 -1
- package/esm/src/data-providers/in-memory-database.js +3 -1
- package/esm/src/data-providers/json-data-provider.js +8 -8
- package/esm/src/data-providers/rest-data-provider.d.ts +1 -1
- package/esm/src/data-providers/rest-data-provider.js +52 -36
- package/esm/src/data-providers/sql-database.d.ts +5 -5
- package/esm/src/data-providers/sql-database.js +53 -36
- package/esm/src/data-providers/web-sql-data-provider.d.ts +4 -4
- package/esm/src/data-providers/web-sql-data-provider.js +15 -13
- package/esm/src/entity.d.ts +24 -24
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.d.ts +4 -4
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +35 -20
- package/esm/src/filter/filter-interfaces.d.ts +7 -7
- package/esm/src/filter/filter-interfaces.js +108 -88
- package/esm/src/live-query/LiveQueryClient.js +37 -29
- package/esm/src/live-query/SseSubscriptionClient.d.ts +1 -1
- package/esm/src/live-query/SseSubscriptionClient.js +14 -14
- package/esm/src/live-query/SubscriptionChannel.d.ts +3 -3
- package/esm/src/live-query/SubscriptionChannel.js +27 -25
- package/esm/src/live-query/SubscriptionServer.js +24 -20
- package/esm/src/remult-proxy.d.ts +1 -1
- package/esm/src/remult-proxy.js +87 -29
- package/esm/src/remult3/DecoratorReplacer.d.ts +2 -2
- package/esm/src/remult3/RepositoryImplementation.d.ts +51 -41
- package/esm/src/remult3/RepositoryImplementation.js +336 -206
- package/esm/src/remult3/remult3.d.ts +56 -51
- package/esm/src/remult3/remult3.js +0 -1
- package/esm/src/server-action.d.ts +12 -5
- package/esm/src/server-action.js +79 -53
- package/esm/src/shared-tests/db-tests-setup.d.ts +8 -8
- package/esm/src/shared-tests/db-tests-setup.js +10 -10
- package/esm/src/shared-tests/db-tests.db-tests.d.ts +1 -1
- package/esm/src/shared-tests/db-tests.db-tests.js +279 -177
- package/esm/src/shared-tests/deleteAll.d.ts +1 -1
- package/esm/src/shared-tests/deleteAll.js +1 -1
- package/esm/src/shared-tests/entityWithValidations.js +1 -1
- package/esm/src/shared-tests/test-custom-id-column.spec.js +4 -4
- package/esm/src/shared-tests/test-special-value.spec.js +12 -12
- package/esm/src/shared-tests/test-update-with-null.spec.js +10 -6
- package/esm/src/sort.d.ts +2 -2
- package/esm/src/sort.js +12 -10
- package/esm/src/tests/TestDataApiResponse.d.ts +1 -1
- package/esm/src/tests/TestDataApiResponse.js +3 -4
- package/esm/src/tests/createData.js +2 -2
- package/esm/src/tests/d.js +1 -1
- package/esm/src/tests/dWithPrefilter.js +1 -1
- package/esm/src/tests/entityForCustomFilter.d.ts +4 -4
- package/esm/src/tests/entityForCustomFilter.js +12 -4
- package/esm/src/tests/entityWithValidationsOnColumn.js +1 -1
- package/esm/src/tests/frontend-database-tests-setup.spec.d.ts +1 -1
- package/esm/src/tests/frontend-database-tests-setup.spec.js +14 -14
- package/esm/src/tests/h.js +4 -4
- package/esm/src/tests/remult-3-entities.d.ts +2 -2
- package/esm/src/tests/remult-3-entities.js +6 -6
- package/esm/src/tests/testHelper.spec.d.ts +7 -7
- package/esm/src/tests/testHelper.spec.js +50 -39
- package/esm/src/tests/testModel/models.js +4 -4
- package/esm/src/validators.d.ts +1 -1
- package/esm/src/validators.js +10 -7
- package/esm/src/valueConverters.d.ts +1 -1
- package/esm/src/valueConverters.js +68 -55
- package/esm/test-servers/shared/Task.d.ts +9 -0
- package/esm/test-servers/shared/Task.js +32 -0
- package/esm/test.d.ts +5 -0
- package/esm/test.js +6 -0
- package/graphql.js +157 -45
- package/index.d.ts +10 -10
- package/inputTypes.js +1 -1
- package/live-query/data-provider-live-query-storage.d.ts +3 -3
- package/live-query/data-provider-live-query-storage.js +7 -4
- package/myLog.js +2 -2
- package/package.json +2 -2
- package/postgres/postgres-data-provider.d.ts +2 -2
- package/postgres/postgres-data-provider.js +21 -16
- package/postgres/schema-builder.d.ts +1 -1
- package/postgres/schema-builder.js +22 -15
- package/remult-express.js +1 -1
- package/remult-fastify.js +7 -7
- package/remult-fresh.d.ts +1 -1
- package/remult-fresh.js +1 -4
- package/remult-knex/index.d.ts +4 -4
- package/remult-knex/index.js +50 -35
- package/remult-mongo.js +33 -23
- package/remult-next.d.ts +3 -3
- package/remult-next.js +15 -11
- package/remult-sveltekit.js +14 -15
- package/server/core.d.ts +2 -2
- package/server/expressBridge.d.ts +3 -12
- package/server/expressBridge.js +278 -279
- package/server/index.d.ts +2 -2
- package/server/index.js +5 -2
- package/server/initAsyncHooks.js +2 -2
- package/server/initDataProvider.js +1 -1
- package/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +1 -1
- package/src/backend-tests/backend-database-test-setup.backend-spec.js +40 -31
- package/src/buildRestDataProvider.d.ts +1 -1
- package/src/buildRestDataProvider.js +18 -10
- package/src/column-interfaces.d.ts +9 -9
- package/src/column.d.ts +4 -0
- package/src/column.js +20 -8
- package/src/context.d.ts +20 -8
- package/src/context.js +61 -18
- package/src/data-api.d.ts +0 -1
- package/src/data-api.js +40 -43
- package/src/data-interfaces.d.ts +1 -1
- package/src/data-providers/array-entity-data-provider.js +2 -2
- package/src/data-providers/in-memory-database.d.ts +1 -1
- package/src/data-providers/in-memory-database.js +3 -1
- package/src/data-providers/json-data-provider.js +33 -15
- package/src/data-providers/rest-data-provider.d.ts +1 -1
- package/src/data-providers/rest-data-provider.js +47 -32
- package/src/data-providers/sql-database.d.ts +5 -5
- package/src/data-providers/sql-database.js +41 -24
- package/src/data-providers/web-sql-data-provider.d.ts +4 -4
- package/src/data-providers/web-sql-data-provider.js +10 -8
- package/src/entity.d.ts +24 -24
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +4 -4
- package/src/filter/filter-consumer-bridge-to-sql-request.js +34 -17
- package/src/filter/filter-interfaces.d.ts +7 -7
- package/src/filter/filter-interfaces.js +73 -47
- package/src/live-query/LiveQueryClient.js +35 -25
- package/src/live-query/SseSubscriptionClient.d.ts +1 -1
- package/src/live-query/SseSubscriptionClient.js +80 -76
- package/src/live-query/SubscriptionChannel.d.ts +3 -3
- package/src/live-query/SubscriptionChannel.js +26 -18
- package/src/live-query/SubscriptionServer.js +23 -17
- package/src/remult-proxy.d.ts +1 -1
- package/src/remult-proxy.js +84 -35
- package/src/remult3/DecoratorReplacer.d.ts +2 -2
- package/src/remult3/RepositoryImplementation.d.ts +51 -41
- package/src/remult3/RepositoryImplementation.js +402 -257
- package/src/remult3/remult3.d.ts +56 -51
- package/src/remult3/remult3.js +0 -1
- package/src/server-action.d.ts +12 -5
- package/src/server-action.js +78 -48
- package/src/shared-tests/db-tests-setup.d.ts +8 -8
- package/src/shared-tests/db-tests-setup.js +6 -6
- package/src/shared-tests/db-tests.db-tests.d.ts +1 -1
- package/src/shared-tests/db-tests.db-tests.js +350 -153
- package/src/shared-tests/deleteAll.d.ts +1 -1
- package/src/shared-tests/entityWithValidations.js +1 -1
- package/src/shared-tests/test-custom-id-column.spec.js +4 -4
- package/src/shared-tests/test-special-value.spec.js +9 -9
- package/src/shared-tests/test-update-with-null.spec.js +8 -4
- package/src/sort.d.ts +2 -2
- package/src/sort.js +9 -7
- package/src/tests/TestDataApiResponse.d.ts +1 -1
- package/src/tests/TestDataApiResponse.js +3 -4
- package/src/tests/createData.js +1 -1
- package/src/tests/d.js +1 -1
- package/src/tests/dWithPrefilter.js +1 -1
- package/src/tests/entityForCustomFilter.d.ts +4 -4
- package/src/tests/entityForCustomFilter.js +16 -6
- package/src/tests/entityWithValidationsOnColumn.js +1 -1
- package/src/tests/frontend-database-tests-setup.spec.d.ts +1 -1
- package/src/tests/frontend-database-tests-setup.spec.js +8 -8
- package/src/tests/h.js +3 -3
- package/src/tests/remult-3-entities.d.ts +2 -2
- package/src/tests/remult-3-entities.js +8 -4
- package/src/tests/testHelper.spec.d.ts +7 -7
- package/src/tests/testHelper.spec.js +38 -27
- package/src/tests/testModel/models.js +3 -3
- package/src/validators.d.ts +1 -1
- package/src/validators.js +18 -9
- package/src/valueConverters.d.ts +1 -1
- package/src/valueConverters.js +38 -21
- package/esm/remult-svletekit.d.ts +0 -3
- package/esm/remult-svletekit.js +0 -83
- package/esm/src/id-entity.d.ts +0 -4
- package/esm/src/id-entity.js +0 -8
- package/esm/src/remult3/getId.d.ts +0 -2
- package/esm/src/remult3/getId.js +0 -7
- package/postgres/getEntityTypescriptPostgres.d.ts +0 -1
- package/postgres/getEntityTypescriptPostgres.js +0 -125
- package/src/id-entity.d.ts +0 -4
- package/src/id-entity.js +0 -17
- package/src/remult3/getId.d.ts +0 -2
- package/src/remult3/getId.js +0 -11
package/src/remult3/remult3.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ClassType } from
|
|
2
|
-
import { FieldMetadata } from
|
|
3
|
-
import { LiveQueryChange, SubscriptionListener, Unsubscribe } from
|
|
4
|
-
import { EntityOptions } from
|
|
5
|
-
import { SortSegment } from
|
|
6
|
-
import { entityEventListener } from
|
|
7
|
-
import { ErrorInfo } from
|
|
1
|
+
import { ClassType } from '../../classType';
|
|
2
|
+
import { FieldMetadata } from '../column-interfaces';
|
|
3
|
+
import { LiveQueryChange, SubscriptionListener, Unsubscribe } from '../live-query/SubscriptionChannel';
|
|
4
|
+
import { EntityOptions } from '../entity';
|
|
5
|
+
import { SortSegment } from '../sort';
|
|
6
|
+
import { entityEventListener } from '../__EntityValueProvider';
|
|
7
|
+
import { ErrorInfo } from '../..';
|
|
8
8
|
export interface EntityRef<entityType> extends Subscribable {
|
|
9
9
|
hasErrors(): boolean;
|
|
10
10
|
undoChanges(): any;
|
|
@@ -44,7 +44,7 @@ export interface Subscribable {
|
|
|
44
44
|
}
|
|
45
45
|
export declare type FieldsRef<entityType> = {
|
|
46
46
|
[Properties in keyof OmitEB<entityType>]: entityType[Properties] extends {
|
|
47
|
-
id?:
|
|
47
|
+
id?: number | string;
|
|
48
48
|
} ? IdFieldRef<entityType, entityType[Properties]> : FieldRef<entityType, entityType[Properties]>;
|
|
49
49
|
} & {
|
|
50
50
|
find(fieldMetadataOrKey: FieldMetadata | string): FieldRef<entityType, any>;
|
|
@@ -68,12 +68,12 @@ export interface IdFieldRef<entityType, valueType> extends FieldRef<entityType,
|
|
|
68
68
|
id?: number;
|
|
69
69
|
} ? number : valueType extends {
|
|
70
70
|
id?: string;
|
|
71
|
-
} ? string :
|
|
72
|
-
getId():
|
|
71
|
+
} ? string : string | number): any;
|
|
72
|
+
getId(): valueType extends {
|
|
73
73
|
id?: number;
|
|
74
74
|
} ? number : valueType extends {
|
|
75
75
|
id?: string;
|
|
76
|
-
} ? string :
|
|
76
|
+
} ? string : string | number;
|
|
77
77
|
}
|
|
78
78
|
export interface FieldRef<entityType = any, valueType = any> extends Subscribable {
|
|
79
79
|
error: string;
|
|
@@ -110,7 +110,7 @@ export interface EntityMetadata<entityType = any> {
|
|
|
110
110
|
/** A human readable caption for the entity. Can be used to achieve a consistent caption for a field throughout the app
|
|
111
111
|
* @example
|
|
112
112
|
* <h1>Create a new item in {taskRepo.metadata.caption}</h1>
|
|
113
|
-
|
|
113
|
+
*/
|
|
114
114
|
readonly caption: string;
|
|
115
115
|
/** The options send to the `Entity`'s decorator */
|
|
116
116
|
readonly options: EntityOptions;
|
|
@@ -122,7 +122,7 @@ export interface EntityMetadata<entityType = any> {
|
|
|
122
122
|
* if (taskRepo.metadata.apiUpdateAllowed(task)){
|
|
123
123
|
* // Allow user to edit the entity
|
|
124
124
|
* }
|
|
125
|
-
|
|
125
|
+
*/
|
|
126
126
|
apiUpdateAllowed(item?: entityType): boolean;
|
|
127
127
|
/** true if the current user is allowed to read from entity
|
|
128
128
|
* @example
|
|
@@ -138,7 +138,7 @@ export interface EntityMetadata<entityType = any> {
|
|
|
138
138
|
* if (taskRepo.metadata.apiDeleteAllowed(task)){
|
|
139
139
|
* // display delete button
|
|
140
140
|
* }
|
|
141
|
-
|
|
141
|
+
*/
|
|
142
142
|
apiDeleteAllowed(item?: entityType): boolean;
|
|
143
143
|
/** true if the current user is allowed to create an entity instance
|
|
144
144
|
* @example
|
|
@@ -146,7 +146,7 @@ export interface EntityMetadata<entityType = any> {
|
|
|
146
146
|
* if (taskRepo.metadata.apiInsertAllowed(task)){
|
|
147
147
|
* // display insert button
|
|
148
148
|
* }
|
|
149
|
-
|
|
149
|
+
*/
|
|
150
150
|
apiInsertAllowed(item?: entityType): boolean;
|
|
151
151
|
/** Returns the dbName - based on it's `dbName` option and it's `sqlExpression` option */
|
|
152
152
|
getDbName(): Promise<string>;
|
|
@@ -158,7 +158,7 @@ export declare type idType<entityType> = entityType extends {
|
|
|
158
158
|
id?: number;
|
|
159
159
|
} ? number : entityType extends {
|
|
160
160
|
id?: string;
|
|
161
|
-
} ? string :
|
|
161
|
+
} ? string : string | number;
|
|
162
162
|
/**used to perform CRUD operations on an `entityType` */
|
|
163
163
|
export interface Repository<entityType> {
|
|
164
164
|
/** returns a result array based on the provided options */
|
|
@@ -190,7 +190,7 @@ export interface Repository<entityType> {
|
|
|
190
190
|
* @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
|
|
191
191
|
* @example
|
|
192
192
|
* await taskRepo.count({ completed:false })
|
|
193
|
-
|
|
193
|
+
*/
|
|
194
194
|
count(where?: EntityFilter<entityType>): Promise<number>;
|
|
195
195
|
/**Validates an item
|
|
196
196
|
* @example
|
|
@@ -202,11 +202,11 @@ export interface Repository<entityType> {
|
|
|
202
202
|
* // Can also be used to validate specific fields
|
|
203
203
|
* const error = repo.validate(task,"title")
|
|
204
204
|
*/
|
|
205
|
-
validate(item: Partial<entityType>, ...fields:
|
|
205
|
+
validate(item: Partial<entityType>, ...fields: Extract<keyof OmitEB<entityType>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
|
|
206
206
|
/** saves an item or item[] to the data source. It assumes that if an `id` value exists, it's an existing row - otherwise it's a new row
|
|
207
207
|
* @example
|
|
208
208
|
* await taskRepo.save({...task, completed:true })
|
|
209
|
-
|
|
209
|
+
*/
|
|
210
210
|
save(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
|
|
211
211
|
save(item: Partial<OmitEB<entityType>>): Promise<entityType>;
|
|
212
212
|
/**Insert an item or item[] to the data source
|
|
@@ -214,41 +214,46 @@ export interface Repository<entityType> {
|
|
|
214
214
|
* await taskRepo.insert({title:"task a"})
|
|
215
215
|
* @example
|
|
216
216
|
* await taskRepo.insert([{title:"task a"}, {title:"task b", completed:true }])
|
|
217
|
-
|
|
217
|
+
*/
|
|
218
218
|
insert(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
|
|
219
219
|
insert(item: Partial<OmitEB<entityType>>): Promise<entityType>;
|
|
220
220
|
/** Updates an item, based on its `id`
|
|
221
221
|
* @example
|
|
222
222
|
* taskRepo.update(task.id,{...task,completed:true})
|
|
223
|
-
|
|
224
|
-
update(id:
|
|
223
|
+
*/
|
|
224
|
+
update(id: entityType extends {
|
|
225
225
|
id?: number;
|
|
226
226
|
} ? number : entityType extends {
|
|
227
227
|
id?: string;
|
|
228
|
-
} ? string :
|
|
228
|
+
} ? string : string | number, item: Partial<OmitEB<entityType>>): Promise<entityType>;
|
|
229
229
|
update(id: Partial<OmitEB<entityType>>, item: Partial<OmitEB<entityType>>): Promise<entityType>;
|
|
230
230
|
/** Deletes an Item*/
|
|
231
|
-
delete(id:
|
|
231
|
+
delete(id: entityType extends {
|
|
232
232
|
id?: number;
|
|
233
233
|
} ? number : entityType extends {
|
|
234
234
|
id?: string;
|
|
235
|
-
} ? string :
|
|
235
|
+
} ? string : string | number): Promise<void>;
|
|
236
236
|
delete(item: Partial<OmitEB<entityType>>): Promise<void>;
|
|
237
237
|
/** Creates an instance of an item. It'll not be saved to the data source unless `save` or `insert` will be called for that item */
|
|
238
238
|
create(item?: Partial<OmitEB<entityType>>): entityType;
|
|
239
|
+
toJson(item: Promise<entityType[]>): Promise<any[]>;
|
|
240
|
+
toJson(item: entityType[]): any[];
|
|
241
|
+
toJson(item: Promise<entityType>): Promise<any>;
|
|
242
|
+
toJson(item: entityType): any;
|
|
239
243
|
/** Translates a json object to an item instance */
|
|
240
|
-
fromJson(x: any, isNew?: boolean):
|
|
244
|
+
fromJson(x: any[], isNew?: boolean): entityType[];
|
|
245
|
+
fromJson(x: any, isNew?: boolean): entityType;
|
|
241
246
|
/** returns an `entityRef` for an item returned by `create`, `find` etc... */
|
|
242
247
|
getEntityRef(item: entityType): EntityRef<entityType>;
|
|
243
248
|
/** Provides information about the fields of the Repository's entity
|
|
244
249
|
* @example
|
|
245
250
|
* console.log(repo.fields.title.caption) // displays the caption of a specific field
|
|
246
251
|
* console.log(repo.fields.title.options)// writes the options that were defined for this field
|
|
247
|
-
|
|
252
|
+
*/
|
|
248
253
|
fields: FieldsMetadata<entityType>;
|
|
249
254
|
/**The metadata for the `entity`
|
|
250
255
|
* @See [EntityMetadata](https://remult.dev/docs/ref_entitymetadata.html)
|
|
251
|
-
|
|
256
|
+
*/
|
|
252
257
|
metadata: EntityMetadata<entityType>;
|
|
253
258
|
addEventListener(listener: entityEventListener<entityType>): Unsubscribe;
|
|
254
259
|
}
|
|
@@ -259,7 +264,7 @@ export interface LiveQuery<entityType> {
|
|
|
259
264
|
export interface LiveQueryChangeInfo<entityType> {
|
|
260
265
|
items: entityType[];
|
|
261
266
|
changes: LiveQueryChange[];
|
|
262
|
-
applyChanges(prevState: entityType[]): entityType[];
|
|
267
|
+
applyChanges(prevState: entityType[] | undefined): entityType[];
|
|
263
268
|
}
|
|
264
269
|
export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
|
|
265
270
|
/** Determines the number of rows returned by the request, on the browser the default is 100 rows
|
|
@@ -268,7 +273,7 @@ export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
|
|
|
268
273
|
* limit:10,
|
|
269
274
|
* page:2
|
|
270
275
|
* })
|
|
271
|
-
|
|
276
|
+
*/
|
|
272
277
|
limit?: number;
|
|
273
278
|
/** Determines the page number that will be used to extract the data
|
|
274
279
|
* @example
|
|
@@ -276,7 +281,7 @@ export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
|
|
|
276
281
|
* limit:10,
|
|
277
282
|
* page:2
|
|
278
283
|
* })
|
|
279
|
-
|
|
284
|
+
*/
|
|
280
285
|
page?: number;
|
|
281
286
|
}
|
|
282
287
|
/** Determines the order of items returned .
|
|
@@ -286,34 +291,34 @@ export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
|
|
|
286
291
|
* await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
|
|
287
292
|
*/
|
|
288
293
|
export declare type EntityOrderBy<entityType> = {
|
|
289
|
-
[Properties in keyof Partial<OmitEB<entityType>>]?:
|
|
294
|
+
[Properties in keyof Partial<OmitEB<entityType>>]?: 'asc' | 'desc';
|
|
290
295
|
};
|
|
291
296
|
/**Used to filter the desired result set
|
|
292
297
|
* @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
|
|
293
298
|
*/
|
|
294
299
|
export declare type EntityFilter<entityType> = {
|
|
295
|
-
[Properties in keyof Partial<OmitEB<entityType>>]?: (Partial<OmitEB<entityType>>[Properties] extends
|
|
296
|
-
id?:
|
|
297
|
-
} | undefined
|
|
300
|
+
[Properties in keyof Partial<OmitEB<entityType>>]?: (Partial<OmitEB<entityType>>[Properties] extends number | Date | undefined ? ComparisonValueFilter<Partial<OmitEB<entityType>>[Properties]> : Partial<OmitEB<entityType>>[Properties] extends string | undefined ? ContainsStringValueFilter & ComparisonValueFilter<string> : Partial<OmitEB<entityType>>[Properties] extends boolean | undefined ? ValueFilter<boolean> : Partial<OmitEB<entityType>>[Properties] extends {
|
|
301
|
+
id?: string | number;
|
|
302
|
+
} | undefined ? IdFilter<Partial<OmitEB<entityType>>[Properties]> : ValueFilter<Partial<OmitEB<entityType>>[Properties]>) & ContainsStringValueFilter;
|
|
298
303
|
} & {
|
|
299
304
|
$or?: EntityFilter<entityType>[];
|
|
300
305
|
$and?: EntityFilter<entityType>[];
|
|
301
306
|
};
|
|
302
307
|
export declare type ValueFilter<valueType> = valueType | valueType[] | {
|
|
303
308
|
$ne?: valueType | valueType[];
|
|
304
|
-
|
|
309
|
+
'!='?: valueType | valueType[];
|
|
305
310
|
$in?: valueType[];
|
|
306
311
|
$nin?: valueType[];
|
|
307
312
|
};
|
|
308
313
|
export declare type ComparisonValueFilter<valueType> = ValueFilter<valueType> & {
|
|
309
314
|
$gt?: valueType;
|
|
310
|
-
|
|
315
|
+
'>'?: valueType;
|
|
311
316
|
$gte?: valueType;
|
|
312
|
-
|
|
317
|
+
'>='?: valueType;
|
|
313
318
|
$lt?: valueType;
|
|
314
|
-
|
|
319
|
+
'<'?: valueType;
|
|
315
320
|
$lte?: valueType;
|
|
316
|
-
|
|
321
|
+
'<='?: valueType;
|
|
317
322
|
};
|
|
318
323
|
export interface ContainsStringValueFilter {
|
|
319
324
|
$contains?: string;
|
|
@@ -328,24 +333,24 @@ export interface LoadOptions<entityType> {
|
|
|
328
333
|
}
|
|
329
334
|
export interface FindOptionsBase<entityType> extends LoadOptions<entityType> {
|
|
330
335
|
/** filters the data
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
336
|
+
* @example
|
|
337
|
+
* await taskRepo.find({where: { completed:false }})
|
|
338
|
+
* @see For more usage examples see [EntityFilter](https://remult.dev/docs/entityFilter.html)
|
|
339
|
+
*/
|
|
335
340
|
where?: EntityFilter<entityType>;
|
|
336
341
|
/** Determines the order of items returned .
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
+
* @example
|
|
343
|
+
* await this.remult.repo(Products).find({ orderBy: { name: "asc" }})
|
|
344
|
+
* @example
|
|
345
|
+
* await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
|
|
346
|
+
*/
|
|
342
347
|
orderBy?: EntityOrderBy<entityType>;
|
|
343
348
|
}
|
|
344
349
|
export interface FindFirstOptions<entityType> extends FindOptionsBase<entityType>, FindFirstOptionsBase<entityType> {
|
|
345
350
|
}
|
|
346
351
|
export interface FindFirstOptionsBase<entityType> extends LoadOptions<entityType> {
|
|
347
352
|
/** determines if to cache the result, and return the results from cache.
|
|
348
|
-
|
|
353
|
+
*/
|
|
349
354
|
useCache?: boolean;
|
|
350
355
|
/** If set to true and an item is not found, it's created and returned*/
|
|
351
356
|
createIfNotFound?: boolean;
|
|
@@ -366,7 +371,7 @@ export interface QueryResult<entityType> {
|
|
|
366
371
|
* for await (const task of taskRepo.query()) {
|
|
367
372
|
* await taskRepo.save({ ...task, completed });
|
|
368
373
|
* }
|
|
369
|
-
|
|
374
|
+
*/
|
|
370
375
|
[Symbol.asyncIterator](): {
|
|
371
376
|
next: () => Promise<IteratorResult<entityType, entityType>>;
|
|
372
377
|
};
|
package/src/remult3/remult3.js
CHANGED
package/src/server-action.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare abstract class Action<inParam, outParam> implements ActionInterfa
|
|
|
17
17
|
run(pIn: inParam, baseUrl?: string, http?: RestDataProviderHttpProvider): Promise<outParam>;
|
|
18
18
|
doWork: (args: any[], self: any, baseUrl?: string, http?: RestDataProviderHttpProvider) => Promise<any>;
|
|
19
19
|
protected abstract execute(info: inParam, req: Remult, res: DataApiResponse): Promise<outParam>;
|
|
20
|
-
__register(reg: (url: string, queue: boolean, allowed: AllowedForInstance<any>, what: (
|
|
20
|
+
__register(reg: (url: string, queue: boolean, allowed: AllowedForInstance<any>, what: (data: any, req: Remult, res: DataApiResponse) => void) => void): void;
|
|
21
21
|
}
|
|
22
22
|
export declare class ForbiddenError extends Error {
|
|
23
23
|
constructor();
|
|
@@ -26,7 +26,7 @@ export declare class ForbiddenError extends Error {
|
|
|
26
26
|
export declare class myServerAction extends Action<inArgs, result> {
|
|
27
27
|
private types;
|
|
28
28
|
private options;
|
|
29
|
-
|
|
29
|
+
originalMethod: (args: any[]) => any;
|
|
30
30
|
constructor(name: string, types: any[], options: BackendMethodOptions<any>, originalMethod: (args: any[]) => any);
|
|
31
31
|
protected execute(info: inArgs, remult: Remult, res: DataApiResponse): Promise<result>;
|
|
32
32
|
}
|
|
@@ -54,9 +54,16 @@ export declare const actionInfo: {
|
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
export declare const serverActionField: unique symbol;
|
|
57
|
-
export declare function Controller(key: string): (target: any) => any;
|
|
57
|
+
export declare function Controller(key: string): (target: any, context?: any) => any;
|
|
58
|
+
export interface ClassMethodDecoratorContextStub<This = unknown, Value extends (this: This, ...args: any) => any = (this: This, ...args: any) => any> {
|
|
59
|
+
readonly kind: 'method';
|
|
60
|
+
readonly name: string | symbol;
|
|
61
|
+
readonly access: {
|
|
62
|
+
has(object: This): boolean;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
58
65
|
/** Indicates that the decorated methods runs on the backend. See: [Backend Methods](https://remult.dev/docs/backendMethods.html) */
|
|
59
|
-
export declare function BackendMethod<type = any>(options: BackendMethodOptions<type>): (target: any,
|
|
66
|
+
export declare function BackendMethod<type = any>(options: BackendMethodOptions<type>): (target: any, context: ClassMethodDecoratorContextStub<type> | string, descriptor?: any) => any;
|
|
60
67
|
export interface jobWasQueuedResult {
|
|
61
68
|
queuedJobId?: string;
|
|
62
69
|
}
|
|
@@ -76,6 +83,6 @@ export declare function prepareReceivedArgs(types: any[], args: any[], remult: R
|
|
|
76
83
|
export declare const classBackendMethodsArray: unique symbol;
|
|
77
84
|
export interface ActionInterface {
|
|
78
85
|
doWork: (args: any[], self: any, baseUrl?: string, http?: RestDataProviderHttpProvider) => Promise<any>;
|
|
79
|
-
__register(reg: (url: string, queue: boolean, allowed: AllowedForInstance<any>, what: (
|
|
86
|
+
__register(reg: (url: string, queue: boolean, allowed: AllowedForInstance<any>, what: (data: any, req: Remult, res: DataApiResponse) => void) => void): any;
|
|
80
87
|
}
|
|
81
88
|
export {};
|
package/src/server-action.js
CHANGED
|
@@ -40,9 +40,11 @@ var Action = /** @class */ (function () {
|
|
|
40
40
|
case 0:
|
|
41
41
|
if (!(!runningJob_1 || !runningJob_1.done)) return [3 /*break*/, 4];
|
|
42
42
|
if (!runningJob_1) return [3 /*break*/, 2];
|
|
43
|
-
return [4 /*yield*/, new Promise(function (res) {
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
return [4 /*yield*/, new Promise(function (res) {
|
|
44
|
+
return setTimeout(function () {
|
|
45
|
+
res(undefined);
|
|
46
|
+
}, 200);
|
|
47
|
+
})];
|
|
46
48
|
case 1:
|
|
47
49
|
_a.sent();
|
|
48
50
|
_a.label = 2;
|
|
@@ -88,7 +90,8 @@ var Action = /** @class */ (function () {
|
|
|
88
90
|
return [3 /*break*/, 3];
|
|
89
91
|
case 2:
|
|
90
92
|
err_1 = _a.sent();
|
|
91
|
-
if (err_1.isForbiddenError)
|
|
93
|
+
if (err_1.isForbiddenError)
|
|
94
|
+
// got a problem in next with instance of ForbiddenError - so replaced it with this bool
|
|
92
95
|
res.forbidden();
|
|
93
96
|
else
|
|
94
97
|
res.error(err_1);
|
|
@@ -105,7 +108,7 @@ exports.Action = Action;
|
|
|
105
108
|
var ForbiddenError = /** @class */ (function (_super) {
|
|
106
109
|
tslib_1.__extends(ForbiddenError, _super);
|
|
107
110
|
function ForbiddenError() {
|
|
108
|
-
var _this = _super.call(this,
|
|
111
|
+
var _this = _super.call(this, 'Forbidden') || this;
|
|
109
112
|
_this.isForbiddenError = true;
|
|
110
113
|
return _this;
|
|
111
114
|
}
|
|
@@ -169,16 +172,18 @@ exports.myServerAction = myServerAction;
|
|
|
169
172
|
exports.actionInfo = {
|
|
170
173
|
allActions: [],
|
|
171
174
|
runningOnServer: false,
|
|
172
|
-
runActionWithoutBlockingUI: function (what) {
|
|
175
|
+
runActionWithoutBlockingUI: function (what) {
|
|
176
|
+
return what();
|
|
177
|
+
},
|
|
173
178
|
startBusyWithProgress: function () { return ({
|
|
174
179
|
progress: function (percent) { },
|
|
175
|
-
close: function () { }
|
|
176
|
-
}); }
|
|
180
|
+
close: function () { },
|
|
181
|
+
}); },
|
|
177
182
|
};
|
|
178
183
|
exports.serverActionField = Symbol('serverActionField');
|
|
179
184
|
var classOptions = new Map();
|
|
180
185
|
function Controller(key) {
|
|
181
|
-
return function (target) {
|
|
186
|
+
return function (target, context) {
|
|
182
187
|
var r = target;
|
|
183
188
|
classOptions.set(r, { key: key });
|
|
184
189
|
context_1.setControllerSettings(target, { key: key });
|
|
@@ -189,14 +194,17 @@ exports.Controller = Controller;
|
|
|
189
194
|
/** Indicates that the decorated methods runs on the backend. See: [Backend Methods](https://remult.dev/docs/backendMethods.html) */
|
|
190
195
|
function BackendMethod(options) {
|
|
191
196
|
var _this = this;
|
|
192
|
-
return function (target,
|
|
197
|
+
return function (target, context, descriptor) {
|
|
198
|
+
var key = typeof context === 'string' ? context : context.name.toString();
|
|
199
|
+
var originalMethod = descriptor ? descriptor.value : target;
|
|
200
|
+
var result = originalMethod;
|
|
201
|
+
remult3_1.checkTarget(target);
|
|
193
202
|
if (target.prototype !== undefined) {
|
|
194
|
-
var
|
|
195
|
-
var types = Reflect.getMetadata("design:paramtypes", target, key);
|
|
203
|
+
var types = Reflect.getMetadata('design:paramtypes', target, key);
|
|
196
204
|
if (options.paramTypes)
|
|
197
205
|
types = options.paramTypes;
|
|
198
206
|
// if types are undefined - you've forgot to set: "emitDecoratorMetadata":true
|
|
199
|
-
var serverAction_1 = new myServerAction(((options === null || options === void 0 ? void 0 : options.apiPrefix) ?
|
|
207
|
+
var serverAction_1 = new myServerAction(((options === null || options === void 0 ? void 0 : options.apiPrefix) ? options.apiPrefix + '/' : '') + key, types, options, function (args) { return originalMethod.apply(undefined, args); });
|
|
200
208
|
serverAction_1.doWork = function (args, self, url, http) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
201
209
|
var _this = this;
|
|
202
210
|
return tslib_1.__generator(this, function (_a) {
|
|
@@ -216,7 +224,7 @@ function BackendMethod(options) {
|
|
|
216
224
|
}
|
|
217
225
|
});
|
|
218
226
|
}); };
|
|
219
|
-
|
|
227
|
+
result = function () {
|
|
220
228
|
var args = [];
|
|
221
229
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
222
230
|
args[_i] = arguments[_i];
|
|
@@ -225,20 +233,25 @@ function BackendMethod(options) {
|
|
|
225
233
|
return tslib_1.__generator(this, function (_a) {
|
|
226
234
|
switch (_a.label) {
|
|
227
235
|
case 0:
|
|
228
|
-
if (!!
|
|
236
|
+
if (!!context_1.isBackend()) return [3 /*break*/, 2];
|
|
229
237
|
return [4 /*yield*/, serverAction_1.doWork(args, undefined)];
|
|
230
238
|
case 1: return [2 /*return*/, _a.sent()];
|
|
231
|
-
case 2: return [4 /*yield*/, originalMethod.apply(
|
|
232
|
-
case 3: return [2 /*return*/,
|
|
239
|
+
case 2: return [4 /*yield*/, originalMethod.apply(this, args)];
|
|
240
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
233
241
|
}
|
|
234
242
|
});
|
|
235
243
|
});
|
|
236
244
|
};
|
|
237
|
-
registerAction(target,
|
|
238
|
-
|
|
239
|
-
|
|
245
|
+
registerAction(target, result);
|
|
246
|
+
result[exports.serverActionField] = serverAction_1;
|
|
247
|
+
if (descriptor) {
|
|
248
|
+
descriptor.value = result;
|
|
249
|
+
return descriptor;
|
|
250
|
+
}
|
|
251
|
+
else
|
|
252
|
+
return result;
|
|
240
253
|
}
|
|
241
|
-
var types = Reflect.getMetadata(
|
|
254
|
+
var types = Reflect.getMetadata('design:paramtypes', target, key);
|
|
242
255
|
if (options.paramTypes)
|
|
243
256
|
types = options.paramTypes;
|
|
244
257
|
var x = context_1.classHelpers.get(target.constructor);
|
|
@@ -246,7 +259,6 @@ function BackendMethod(options) {
|
|
|
246
259
|
x = new context_1.ClassHelper();
|
|
247
260
|
context_1.classHelpers.set(target.constructor, x);
|
|
248
261
|
}
|
|
249
|
-
var originalMethod = descriptor.value;
|
|
250
262
|
var serverAction = {
|
|
251
263
|
__register: function (reg) {
|
|
252
264
|
var e_1, _a;
|
|
@@ -257,13 +269,16 @@ function BackendMethod(options) {
|
|
|
257
269
|
if (!controllerOptions.key) {
|
|
258
270
|
controllerOptions.key = c.repo(constructor).metadata.key;
|
|
259
271
|
}
|
|
260
|
-
reg(controllerOptions.key +
|
|
272
|
+
reg(controllerOptions.key +
|
|
273
|
+
'/' +
|
|
274
|
+
((options === null || options === void 0 ? void 0 : options.apiPrefix) ? options.apiPrefix + '/' : '') +
|
|
275
|
+
key, options ? options.queue : false, options.allowed, function (d, req, res) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
261
276
|
var allowed, remult_1, r_1, err_3;
|
|
262
277
|
var _this = this;
|
|
263
278
|
return tslib_1.__generator(this, function (_a) {
|
|
264
279
|
switch (_a.label) {
|
|
265
280
|
case 0:
|
|
266
|
-
d.args = d.args.map(function (x) { return isCustomUndefined(x) ? undefined : x; });
|
|
281
|
+
d.args = d.args.map(function (x) { return (isCustomUndefined(x) ? undefined : x); });
|
|
267
282
|
allowed = options.allowed;
|
|
268
283
|
_a.label = 1;
|
|
269
284
|
case 1:
|
|
@@ -290,12 +305,12 @@ function BackendMethod(options) {
|
|
|
290
305
|
_e.sent();
|
|
291
306
|
return [3 /*break*/, 6];
|
|
292
307
|
case 3: return [4 /*yield*/, repo.find({
|
|
293
|
-
where: tslib_1.__assign(tslib_1.__assign({}, repo.metadata.idMetadata.getIdFilter(d.rowInfo.id)), { $and: [repo.metadata.options.apiPrefilter] })
|
|
308
|
+
where: tslib_1.__assign(tslib_1.__assign({}, repo.metadata.idMetadata.getIdFilter(d.rowInfo.id)), { $and: [repo.metadata.options.apiPrefilter] }),
|
|
294
309
|
})];
|
|
295
310
|
case 4:
|
|
296
311
|
rows = _e.sent();
|
|
297
312
|
if (rows.length != 1)
|
|
298
|
-
throw new Error(
|
|
313
|
+
throw new Error('not found or too many matches');
|
|
299
314
|
y = rows[0];
|
|
300
315
|
return [4 /*yield*/, repo.getEntityRef(y)._updateEntityBasedOnApi(d.rowInfo.data)];
|
|
301
316
|
case 5:
|
|
@@ -365,7 +380,8 @@ function BackendMethod(options) {
|
|
|
365
380
|
return [3 /*break*/, 4];
|
|
366
381
|
case 3:
|
|
367
382
|
err_3 = _a.sent();
|
|
368
|
-
if (err_3.isForbiddenError)
|
|
383
|
+
if (err_3.isForbiddenError)
|
|
384
|
+
// got a problem in next with instance of ForbiddenError - so replaced it with this bool
|
|
369
385
|
res.forbidden();
|
|
370
386
|
else
|
|
371
387
|
res.error(err_3);
|
|
@@ -404,29 +420,33 @@ function BackendMethod(options) {
|
|
|
404
420
|
_h.sent();
|
|
405
421
|
classOptions_1 = x.classes.get(self.constructor);
|
|
406
422
|
if (!classOptions_1.key) {
|
|
407
|
-
classOptions_1.key = defs.repository.metadata.key +
|
|
423
|
+
classOptions_1.key = defs.repository.metadata.key + '_methods';
|
|
408
424
|
}
|
|
409
425
|
_h.label = 2;
|
|
410
426
|
case 2:
|
|
411
427
|
_h.trys.push([2, 6, , 7]);
|
|
412
|
-
_b = (_a = new /** @class */ (function (_super) {
|
|
428
|
+
_b = (_a = new (/** @class */ (function (_super) {
|
|
413
429
|
tslib_1.__extends(class_1, _super);
|
|
414
430
|
function class_1() {
|
|
415
431
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
416
432
|
}
|
|
417
433
|
return class_1;
|
|
418
|
-
}(Action))(classOptions_1.key +
|
|
434
|
+
}(Action)))(classOptions_1.key +
|
|
435
|
+
'/' +
|
|
436
|
+
((options === null || options === void 0 ? void 0 : options.apiPrefix) ? options.apiPrefix + '/' : '') +
|
|
437
|
+
key, options ? options.queue : false, options.allowed)).run;
|
|
419
438
|
_e = {
|
|
420
439
|
args: args
|
|
421
440
|
};
|
|
422
441
|
_f = {};
|
|
423
442
|
return [4 /*yield*/, defs.toApiJson()];
|
|
424
|
-
case 3: return [4 /*yield*/,
|
|
443
|
+
case 3: return [4 /*yield*/, _b.apply(_a, [(_e.rowInfo = (_f.data = _h.sent(),
|
|
425
444
|
_f.isNewRow = defs.isNew(),
|
|
426
445
|
_f.wasChanged = defs.wasChanged(),
|
|
427
446
|
_f.id = defs.getOriginalId(),
|
|
428
447
|
_f),
|
|
429
|
-
_e), baseUrl,
|
|
448
|
+
_e), baseUrl,
|
|
449
|
+
http])];
|
|
430
450
|
case 4:
|
|
431
451
|
r = _h.sent();
|
|
432
452
|
return [4 /*yield*/, defs._updateEntityBasedOnApi(r.rowInfo.data)];
|
|
@@ -445,19 +465,23 @@ function BackendMethod(options) {
|
|
|
445
465
|
return [4 /*yield*/, defs.__validateEntity()];
|
|
446
466
|
case 10:
|
|
447
467
|
_h.sent();
|
|
448
|
-
_d = (_c = new /** @class */ (function (_super) {
|
|
468
|
+
_d = (_c = new (/** @class */ (function (_super) {
|
|
449
469
|
tslib_1.__extends(class_2, _super);
|
|
450
470
|
function class_2() {
|
|
451
471
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
452
472
|
}
|
|
453
473
|
return class_2;
|
|
454
|
-
}(Action))(x.classes.get(self.constructor).key +
|
|
474
|
+
}(Action)))(x.classes.get(self.constructor).key +
|
|
475
|
+
'/' +
|
|
476
|
+
((options === null || options === void 0 ? void 0 : options.apiPrefix) ? options.apiPrefix + '/' : '') +
|
|
477
|
+
key, options ? options.queue : false, options.allowed)).run;
|
|
455
478
|
_g = {
|
|
456
479
|
args: args
|
|
457
480
|
};
|
|
458
481
|
return [4 /*yield*/, defs.toApiJson()];
|
|
459
|
-
case 11: return [4 /*yield*/,
|
|
460
|
-
_g), baseUrl,
|
|
482
|
+
case 11: return [4 /*yield*/, _d.apply(_c, [(_g.fields = _h.sent(),
|
|
483
|
+
_g), baseUrl,
|
|
484
|
+
http])];
|
|
461
485
|
case 12:
|
|
462
486
|
r = _h.sent();
|
|
463
487
|
return [4 /*yield*/, defs._updateEntityBasedOnApi(r.fields)];
|
|
@@ -471,9 +495,9 @@ function BackendMethod(options) {
|
|
|
471
495
|
}
|
|
472
496
|
});
|
|
473
497
|
});
|
|
474
|
-
}
|
|
498
|
+
},
|
|
475
499
|
};
|
|
476
|
-
|
|
500
|
+
result = function () {
|
|
477
501
|
var args = [];
|
|
478
502
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
479
503
|
args[_i] = arguments[_i];
|
|
@@ -483,27 +507,33 @@ function BackendMethod(options) {
|
|
|
483
507
|
return tslib_1.__generator(this, function (_a) {
|
|
484
508
|
switch (_a.label) {
|
|
485
509
|
case 0:
|
|
486
|
-
if (!!
|
|
510
|
+
if (!!context_1.isBackend()) return [3 /*break*/, 1];
|
|
487
511
|
self_1 = this;
|
|
488
512
|
return [2 /*return*/, serverAction.doWork(args, self_1)];
|
|
489
513
|
case 1: return [4 /*yield*/, originalMethod.apply(this, args)];
|
|
490
|
-
case 2: return [2 /*return*/,
|
|
514
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
491
515
|
}
|
|
492
516
|
});
|
|
493
517
|
});
|
|
494
518
|
};
|
|
495
|
-
registerAction(target.constructor,
|
|
496
|
-
|
|
497
|
-
|
|
519
|
+
registerAction(target.constructor, result);
|
|
520
|
+
result[exports.serverActionField] = serverAction;
|
|
521
|
+
if (descriptor) {
|
|
522
|
+
descriptor.value = result;
|
|
523
|
+
return descriptor;
|
|
524
|
+
}
|
|
525
|
+
else
|
|
526
|
+
return result;
|
|
498
527
|
};
|
|
499
528
|
}
|
|
500
529
|
exports.BackendMethod = BackendMethod;
|
|
501
530
|
var customUndefined = {
|
|
502
|
-
_isUndefined: true
|
|
531
|
+
_isUndefined: true,
|
|
503
532
|
};
|
|
504
|
-
function registerAction(target,
|
|
505
|
-
|
|
506
|
-
exports.
|
|
533
|
+
function registerAction(target, resultMethod) {
|
|
534
|
+
;
|
|
535
|
+
(target[exports.classBackendMethodsArray] || (target[exports.classBackendMethodsArray] = [])).push(resultMethod);
|
|
536
|
+
exports.actionInfo.allActions.push(resultMethod);
|
|
507
537
|
}
|
|
508
538
|
function isCustomUndefined(x) {
|
|
509
539
|
return x && x._isUndefined;
|
|
@@ -553,7 +583,7 @@ function prepareArgsToSend(types, args) {
|
|
|
553
583
|
}
|
|
554
584
|
}
|
|
555
585
|
}
|
|
556
|
-
return args.map(function (x) { return x !== undefined ? x : customUndefined; });
|
|
586
|
+
return args.map(function (x) { return (x !== undefined ? x : customUndefined); });
|
|
557
587
|
}
|
|
558
588
|
exports.prepareArgsToSend = prepareArgsToSend;
|
|
559
589
|
function prepareReceivedArgs(types, args, remult, ds, res) {
|