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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { UrlBuilder } from '../../urlBuilder';
|
|
2
2
|
import { customUrlToken, Filter } from '../filter/filter-interfaces';
|
|
3
|
-
import { buildRestDataProvider, retry } from
|
|
3
|
+
import { buildRestDataProvider, retry } from '../buildRestDataProvider';
|
|
4
4
|
import { actionInfo } from '../server-action';
|
|
5
5
|
export class RestDataProvider {
|
|
6
6
|
constructor(apiProvider) {
|
|
7
7
|
this.apiProvider = apiProvider;
|
|
8
|
-
this.
|
|
8
|
+
this.isProxy = true;
|
|
9
9
|
}
|
|
10
10
|
getEntityDataProvider(entity) {
|
|
11
11
|
return new RestEntityDataProvider(() => {
|
|
@@ -18,7 +18,7 @@ export class RestDataProvider {
|
|
|
18
18
|
}, entity);
|
|
19
19
|
}
|
|
20
20
|
async transaction(action) {
|
|
21
|
-
throw new Error(
|
|
21
|
+
throw new Error('Method not implemented.');
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
//@internal
|
|
@@ -28,15 +28,15 @@ export function findOptionsToJson(options, meta) {
|
|
|
28
28
|
where: Filter.entityFilterToJson(meta, options.where),
|
|
29
29
|
};
|
|
30
30
|
if (options.load)
|
|
31
|
-
r.load = options.load(meta.fields).map(y => y.key);
|
|
31
|
+
r.load = options.load(meta.fields).map((y) => y.key);
|
|
32
32
|
return r;
|
|
33
33
|
}
|
|
34
34
|
//@internal
|
|
35
35
|
export function findOptionsFromJson(json, meta) {
|
|
36
36
|
let r = {};
|
|
37
|
-
for (const key of [
|
|
37
|
+
for (const key of ['limit', 'page', 'where', 'orderBy']) {
|
|
38
38
|
if (json[key] !== undefined) {
|
|
39
|
-
if (key ===
|
|
39
|
+
if (key === 'where') {
|
|
40
40
|
r[key] = Filter.entityFilterFromJson(meta, json.where);
|
|
41
41
|
}
|
|
42
42
|
else
|
|
@@ -44,7 +44,7 @@ export function findOptionsFromJson(json, meta) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
if (json.load) {
|
|
47
|
-
r.load = (z) => json.load.map(y => z.find(y));
|
|
47
|
+
r.load = (z) => json.load.map((y) => z.find(y));
|
|
48
48
|
}
|
|
49
49
|
return r;
|
|
50
50
|
}
|
|
@@ -70,11 +70,11 @@ export class RestEntityDataProvider {
|
|
|
70
70
|
}
|
|
71
71
|
async count(where) {
|
|
72
72
|
const { run } = this.buildFindRequest({ where });
|
|
73
|
-
return run(
|
|
73
|
+
return run('count').then((r) => +r.count);
|
|
74
74
|
}
|
|
75
75
|
find(options) {
|
|
76
76
|
let { run } = this.buildFindRequest(options);
|
|
77
|
-
return run().then(x => x.map(y => this.translateFromJson(y)));
|
|
77
|
+
return run().then((x) => x.map((y) => this.translateFromJson(y)));
|
|
78
78
|
}
|
|
79
79
|
//@internal
|
|
80
80
|
buildFindRequest(options) {
|
|
@@ -90,13 +90,13 @@ export class RestEntityDataProvider {
|
|
|
90
90
|
let sort = '';
|
|
91
91
|
let order = '';
|
|
92
92
|
let hasDescending = false;
|
|
93
|
-
options.orderBy.Segments.forEach(c => {
|
|
93
|
+
options.orderBy.Segments.forEach((c) => {
|
|
94
94
|
if (sort.length > 0) {
|
|
95
|
-
sort +=
|
|
96
|
-
order +=
|
|
95
|
+
sort += ',';
|
|
96
|
+
order += ',';
|
|
97
97
|
}
|
|
98
98
|
sort += c.field.key;
|
|
99
|
-
order += c.isDescending ?
|
|
99
|
+
order += c.isDescending ? 'desc' : 'asc';
|
|
100
100
|
if (c.isDescending)
|
|
101
101
|
hasDescending = true;
|
|
102
102
|
});
|
|
@@ -113,10 +113,10 @@ export class RestEntityDataProvider {
|
|
|
113
113
|
const run = (action) => {
|
|
114
114
|
let u = new UrlBuilder(url.url);
|
|
115
115
|
if (!action && filterObject) {
|
|
116
|
-
action =
|
|
116
|
+
action = 'get';
|
|
117
117
|
}
|
|
118
118
|
if (action)
|
|
119
|
-
u.add(
|
|
119
|
+
u.add('__action', action);
|
|
120
120
|
if (filterObject) {
|
|
121
121
|
return this.http().post(u.url, filterObject);
|
|
122
122
|
}
|
|
@@ -131,12 +131,12 @@ export class RestEntityDataProvider {
|
|
|
131
131
|
return {
|
|
132
132
|
result,
|
|
133
133
|
unsubscribe: async () => {
|
|
134
|
-
return actionInfo.runActionWithoutBlockingUI(() => this.http().post(this.url() +
|
|
135
|
-
id: queryId
|
|
134
|
+
return actionInfo.runActionWithoutBlockingUI(() => this.http().post(this.url() + '?__action=endLiveQuery', {
|
|
135
|
+
id: queryId,
|
|
136
136
|
}));
|
|
137
|
-
}
|
|
137
|
+
},
|
|
138
138
|
};
|
|
139
|
-
}
|
|
139
|
+
},
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
update(id, data) {
|
|
@@ -146,13 +146,17 @@ export class RestEntityDataProvider {
|
|
|
146
146
|
if (keys.includes(col.key))
|
|
147
147
|
result[col.key] = col.valueConverter.toJson(data[col.key]);
|
|
148
148
|
}
|
|
149
|
-
return this.http()
|
|
149
|
+
return this.http()
|
|
150
|
+
.put(this.url() + '/' + encodeURIComponent(id), result)
|
|
151
|
+
.then((y) => this.translateFromJson(y));
|
|
150
152
|
}
|
|
151
153
|
delete(id) {
|
|
152
154
|
return this.http().delete(this.url() + '/' + encodeURIComponent(id));
|
|
153
155
|
}
|
|
154
156
|
insert(data) {
|
|
155
|
-
return this.http()
|
|
157
|
+
return this.http()
|
|
158
|
+
.post(this.url(), this.translateToJson(data))
|
|
159
|
+
.then((y) => this.translateFromJson(y));
|
|
156
160
|
}
|
|
157
161
|
}
|
|
158
162
|
export class RestDataProviderHttpProviderUsingFetch {
|
|
@@ -160,14 +164,14 @@ export class RestDataProviderHttpProviderUsingFetch {
|
|
|
160
164
|
this.fetch = fetch;
|
|
161
165
|
}
|
|
162
166
|
async get(url) {
|
|
163
|
-
return await retry(async () => this.myFetch(url).then(r => {
|
|
167
|
+
return await retry(async () => this.myFetch(url).then((r) => {
|
|
164
168
|
return r;
|
|
165
169
|
}));
|
|
166
170
|
}
|
|
167
171
|
put(url, data) {
|
|
168
172
|
return this.myFetch(url, {
|
|
169
173
|
method: 'put',
|
|
170
|
-
body: JSON.stringify(data)
|
|
174
|
+
body: JSON.stringify(data),
|
|
171
175
|
});
|
|
172
176
|
}
|
|
173
177
|
delete(url) {
|
|
@@ -176,14 +180,16 @@ export class RestDataProviderHttpProviderUsingFetch {
|
|
|
176
180
|
async post(url, data) {
|
|
177
181
|
return await retry(() => this.myFetch(url, {
|
|
178
182
|
method: 'post',
|
|
179
|
-
body: JSON.stringify(data)
|
|
183
|
+
body: JSON.stringify(data),
|
|
180
184
|
}));
|
|
181
185
|
}
|
|
182
186
|
myFetch(url, options) {
|
|
183
187
|
const headers = {};
|
|
184
188
|
if (options?.body)
|
|
185
|
-
headers[
|
|
186
|
-
if (typeof window !== 'undefined' &&
|
|
189
|
+
headers['Content-type'] = 'application/json';
|
|
190
|
+
if (typeof window !== 'undefined' &&
|
|
191
|
+
typeof window.document !== 'undefined' &&
|
|
192
|
+
typeof (window.document.cookie !== 'undefined'))
|
|
187
193
|
for (const cookie of window.document.cookie.split(';')) {
|
|
188
194
|
if (cookie.trim().startsWith('XSRF-TOKEN=')) {
|
|
189
195
|
headers['X-XSRF-TOKEN'] = cookie.split('=')[1];
|
|
@@ -193,10 +199,12 @@ export class RestDataProviderHttpProviderUsingFetch {
|
|
|
193
199
|
credentials: 'include',
|
|
194
200
|
method: options?.method,
|
|
195
201
|
body: options?.body,
|
|
196
|
-
headers
|
|
197
|
-
})
|
|
202
|
+
headers,
|
|
203
|
+
})
|
|
204
|
+
.then((response) => {
|
|
198
205
|
return onSuccess(response);
|
|
199
|
-
})
|
|
206
|
+
})
|
|
207
|
+
.catch(async (error) => {
|
|
200
208
|
let r = await error;
|
|
201
209
|
throw r;
|
|
202
210
|
});
|
|
@@ -208,13 +216,21 @@ function onSuccess(response) {
|
|
|
208
216
|
if (response.status >= 200 && response.status < 300)
|
|
209
217
|
return response.json();
|
|
210
218
|
else {
|
|
211
|
-
throw response
|
|
212
|
-
|
|
213
|
-
|
|
219
|
+
throw response
|
|
220
|
+
.json()
|
|
221
|
+
.then((x) => {
|
|
222
|
+
return {
|
|
223
|
+
...x,
|
|
224
|
+
message: x.message || response.statusText,
|
|
225
|
+
url: response.url,
|
|
226
|
+
status: response.status,
|
|
227
|
+
};
|
|
228
|
+
})
|
|
229
|
+
.catch(() => {
|
|
214
230
|
throw {
|
|
215
231
|
message: response.statusText,
|
|
216
232
|
url: response.url,
|
|
217
|
-
status: response.status
|
|
233
|
+
status: response.status,
|
|
218
234
|
};
|
|
219
235
|
});
|
|
220
236
|
}
|
|
@@ -235,10 +251,10 @@ export function addFilterToUrlAndReturnTrueIfSuccessful(filter, url) {
|
|
|
235
251
|
if (Object.prototype.hasOwnProperty.call(filter, key)) {
|
|
236
252
|
const element = filter[key];
|
|
237
253
|
if (Array.isArray(element)) {
|
|
238
|
-
if (key.endsWith(
|
|
254
|
+
if (key.endsWith('.in'))
|
|
239
255
|
url.add(key, JSON.stringify(element));
|
|
240
256
|
else
|
|
241
|
-
element.forEach(e => url.add(key, e));
|
|
257
|
+
element.forEach((e) => url.add(key, e));
|
|
242
258
|
}
|
|
243
259
|
else if (key.startsWith(customUrlToken))
|
|
244
260
|
url.add(key, JSON.stringify(element));
|
|
@@ -248,4 +264,4 @@ export function addFilterToUrlAndReturnTrueIfSuccessful(filter, url) {
|
|
|
248
264
|
}
|
|
249
265
|
return true;
|
|
250
266
|
}
|
|
251
|
-
export const liveQueryAction =
|
|
267
|
+
export const liveQueryAction = 'liveQuery-';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EntityDataProvider, DataProvider } from
|
|
2
|
-
import { SqlCommand, SqlCommandWithParameters, SqlImplementation, SqlResult } from
|
|
3
|
-
import { CustomSqlFilterBuilderFunction } from
|
|
4
|
-
import { EntityMetadata, EntityFilter, RepositoryOverloads } from
|
|
5
|
-
import { Remult } from
|
|
1
|
+
import { EntityDataProvider, DataProvider } from '../data-interfaces';
|
|
2
|
+
import { SqlCommand, SqlCommandWithParameters, SqlImplementation, SqlResult } from '../sql-command';
|
|
3
|
+
import { CustomSqlFilterBuilderFunction } from '../filter/filter-consumer-bridge-to-sql-request';
|
|
4
|
+
import { EntityMetadata, EntityFilter, RepositoryOverloads } from '../remult3';
|
|
5
|
+
import { Remult } from '../context';
|
|
6
6
|
export declare class SqlDatabase implements DataProvider {
|
|
7
7
|
private sql;
|
|
8
8
|
static getDb(remult?: Remult): SqlDatabase;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CompoundIdField } from
|
|
2
|
-
import { dbNamesOf, FilterConsumerBridgeToSqlRequest, isDbReadonly } from
|
|
1
|
+
import { CompoundIdField } from '../column';
|
|
2
|
+
import { dbNamesOf, FilterConsumerBridgeToSqlRequest, isDbReadonly, } from '../filter/filter-consumer-bridge-to-sql-request';
|
|
3
3
|
import { customDatabaseFilterToken, Filter } from '../filter/filter-interfaces';
|
|
4
4
|
import { Sort } from '../sort';
|
|
5
|
-
import { getRepository } from
|
|
6
|
-
import {
|
|
7
|
-
import { ValueConverters } from
|
|
5
|
+
import { getRepository, } from '../remult3';
|
|
6
|
+
import { remult as defaultRemult } from '../remult-proxy';
|
|
7
|
+
import { ValueConverters } from '../valueConverters';
|
|
8
8
|
// @dynamic
|
|
9
9
|
export class SqlDatabase {
|
|
10
10
|
constructor(sql) {
|
|
@@ -12,9 +12,9 @@ export class SqlDatabase {
|
|
|
12
12
|
this.createdEntities = [];
|
|
13
13
|
}
|
|
14
14
|
static getDb(remult) {
|
|
15
|
-
const r = (remult ||
|
|
15
|
+
const r = (remult || defaultRemult).dataProvider;
|
|
16
16
|
if (!r.createCommand)
|
|
17
|
-
throw
|
|
17
|
+
throw 'the data provider is not an SqlDatabase';
|
|
18
18
|
return r;
|
|
19
19
|
}
|
|
20
20
|
createCommand() {
|
|
@@ -34,9 +34,13 @@ export class SqlDatabase {
|
|
|
34
34
|
getEntityDataProvider(entity) {
|
|
35
35
|
if (!this.sql.supportsJsonColumnType) {
|
|
36
36
|
for (const f of entity.fields.toArray()) {
|
|
37
|
-
if (f.valueConverter.fieldTypeInDb ===
|
|
37
|
+
if (f.valueConverter.fieldTypeInDb === 'json') {
|
|
38
38
|
//@ts-ignore
|
|
39
|
-
f.valueConverter = {
|
|
39
|
+
f.valueConverter = {
|
|
40
|
+
...f.valueConverter,
|
|
41
|
+
toDb: ValueConverters.JsonString.toDb,
|
|
42
|
+
fromDb: ValueConverters.JsonString.fromDb,
|
|
43
|
+
};
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
}
|
|
@@ -55,18 +59,18 @@ export class SqlDatabase {
|
|
|
55
59
|
createCommand: () => {
|
|
56
60
|
let c = x.createCommand();
|
|
57
61
|
return {
|
|
58
|
-
addParameterAndReturnSqlToken: x => c.addParameterAndReturnSqlToken(x),
|
|
62
|
+
addParameterAndReturnSqlToken: (x) => c.addParameterAndReturnSqlToken(x),
|
|
59
63
|
execute: async (sql) => {
|
|
60
64
|
if (completed)
|
|
61
65
|
throw "can't run a command after the transaction was completed";
|
|
62
66
|
return c.execute(sql);
|
|
63
|
-
}
|
|
67
|
+
},
|
|
64
68
|
};
|
|
65
69
|
},
|
|
66
70
|
getLimitSqlSyntax: this.sql.getLimitSqlSyntax,
|
|
67
|
-
entityIsUsedForTheFirstTime: y => x.entityIsUsedForTheFirstTime(y),
|
|
68
|
-
transaction: z => x.transaction(z),
|
|
69
|
-
supportsJsonColumnType: this.sql.supportsJsonColumnType
|
|
71
|
+
entityIsUsedForTheFirstTime: (y) => x.entityIsUsedForTheFirstTime(y),
|
|
72
|
+
transaction: (z) => x.transaction(z),
|
|
73
|
+
supportsJsonColumnType: this.sql.supportsJsonColumnType,
|
|
70
74
|
}));
|
|
71
75
|
}
|
|
72
76
|
finally {
|
|
@@ -77,8 +81,8 @@ export class SqlDatabase {
|
|
|
77
81
|
static rawFilter(build) {
|
|
78
82
|
return {
|
|
79
83
|
[customDatabaseFilterToken]: {
|
|
80
|
-
buildSql: build
|
|
81
|
-
}
|
|
84
|
+
buildSql: build,
|
|
85
|
+
},
|
|
82
86
|
};
|
|
83
87
|
}
|
|
84
88
|
static async filterToRaw(repo, condition, sqlCommand) {
|
|
@@ -88,7 +92,7 @@ export class SqlDatabase {
|
|
|
88
92
|
const r = getRepository(repo);
|
|
89
93
|
var b = new FilterConsumerBridgeToSqlRequest(sqlCommand, await dbNamesOf(r.metadata));
|
|
90
94
|
b._addWhere = false;
|
|
91
|
-
await (await
|
|
95
|
+
await (await r.translateWhereToFilter(condition)).__applyToConsumer(b);
|
|
92
96
|
return await b.resolveWhere();
|
|
93
97
|
}
|
|
94
98
|
}
|
|
@@ -139,12 +143,15 @@ class LogSQLCommand {
|
|
|
139
143
|
var d = new Date().valueOf() - start.valueOf();
|
|
140
144
|
if (d > SqlDatabase.durationThreshold) {
|
|
141
145
|
const duration = d / 1000;
|
|
142
|
-
if (this.logToConsole ===
|
|
143
|
-
const rawSql = sql
|
|
146
|
+
if (this.logToConsole === 'oneLiner') {
|
|
147
|
+
const rawSql = sql
|
|
148
|
+
.replace(/(\r\n|\n|\r|\t)/gm, ' ')
|
|
149
|
+
.replace(/ +/g, ' ')
|
|
150
|
+
.trim();
|
|
144
151
|
const first = rawSql.split(' ')[0].toUpperCase();
|
|
145
|
-
console.info(`${icons.get(first) || '💢'} (${
|
|
152
|
+
console.info(`${icons.get(first) || '💢'} (${duration.toFixed(3)}) ${rawSql} ${JSON.stringify(this.args)}`);
|
|
146
153
|
}
|
|
147
|
-
else if (typeof this.logToConsole ===
|
|
154
|
+
else if (typeof this.logToConsole === 'function') {
|
|
148
155
|
this.logToConsole(duration, sql, this.args);
|
|
149
156
|
}
|
|
150
157
|
else {
|
|
@@ -181,7 +188,7 @@ class ActualSQLServerDataProvider {
|
|
|
181
188
|
where.__applyToConsumer(wc);
|
|
182
189
|
select += await wc.resolveWhere();
|
|
183
190
|
}
|
|
184
|
-
return r.execute(select).then(r => {
|
|
191
|
+
return r.execute(select).then((r) => {
|
|
185
192
|
return Number(r.rows[0].count);
|
|
186
193
|
});
|
|
187
194
|
}
|
|
@@ -208,7 +215,10 @@ class ActualSQLServerDataProvider {
|
|
|
208
215
|
let segs = [];
|
|
209
216
|
for (const s of options.orderBy.Segments) {
|
|
210
217
|
if (s.field instanceof CompoundIdField) {
|
|
211
|
-
segs.push(...s.field.fields.map(c => ({
|
|
218
|
+
segs.push(...s.field.fields.map((c) => ({
|
|
219
|
+
field: c,
|
|
220
|
+
isDescending: s.isDescending,
|
|
221
|
+
})));
|
|
212
222
|
}
|
|
213
223
|
else
|
|
214
224
|
segs.push(s);
|
|
@@ -231,11 +241,13 @@ class ActualSQLServerDataProvider {
|
|
|
231
241
|
page = options.page;
|
|
232
242
|
if (page < 1)
|
|
233
243
|
page = 1;
|
|
234
|
-
select +=
|
|
244
|
+
select +=
|
|
245
|
+
' ' +
|
|
246
|
+
this.strategy.getLimitSqlSyntax(options.limit, (page - 1) * options.limit);
|
|
235
247
|
}
|
|
236
248
|
}
|
|
237
|
-
return r.execute(select).then(r => {
|
|
238
|
-
return r.rows.map(y => {
|
|
249
|
+
return r.execute(select).then((r) => {
|
|
250
|
+
return r.rows.map((y) => {
|
|
239
251
|
return this.buildResultRow(colKeys, y, r);
|
|
240
252
|
});
|
|
241
253
|
});
|
|
@@ -248,7 +260,7 @@ class ActualSQLServerDataProvider {
|
|
|
248
260
|
result[col.key] = col.valueConverter.fromDb(y[r.getColumnKeyInResultForIndexInSelect(index)]);
|
|
249
261
|
}
|
|
250
262
|
catch (err) {
|
|
251
|
-
throw new Error(
|
|
263
|
+
throw new Error('Failed to load from db:' + col.key + '\r\n' + err);
|
|
252
264
|
}
|
|
253
265
|
}
|
|
254
266
|
return result;
|
|
@@ -278,7 +290,8 @@ class ActualSQLServerDataProvider {
|
|
|
278
290
|
for (const x of this.entity.fields) {
|
|
279
291
|
if (x instanceof CompoundIdField) {
|
|
280
292
|
}
|
|
281
|
-
if (isDbReadonly(x, e)) {
|
|
293
|
+
if (isDbReadonly(x, e)) {
|
|
294
|
+
}
|
|
282
295
|
else if (data[x.key] !== undefined) {
|
|
283
296
|
let v = x.valueConverter.toDb(data[x.key]);
|
|
284
297
|
if (v !== undefined) {
|
|
@@ -286,14 +299,15 @@ class ActualSQLServerDataProvider {
|
|
|
286
299
|
added = true;
|
|
287
300
|
else
|
|
288
301
|
statement += ', ';
|
|
289
|
-
statement +=
|
|
302
|
+
statement +=
|
|
303
|
+
e.$dbNameOf(x) + ' = ' + r.addParameterAndReturnSqlToken(v);
|
|
290
304
|
}
|
|
291
305
|
}
|
|
292
306
|
}
|
|
293
307
|
statement += await f.resolveWhere();
|
|
294
308
|
let { colKeys, select } = this.buildSelect(e);
|
|
295
309
|
statement += ' returning ' + select;
|
|
296
|
-
return r.execute(statement).then(sqlResult => {
|
|
310
|
+
return r.execute(statement).then((sqlResult) => {
|
|
297
311
|
return this.buildResultRow(colKeys, sqlResult.rows[0], sqlResult);
|
|
298
312
|
});
|
|
299
313
|
}
|
|
@@ -313,7 +327,8 @@ class ActualSQLServerDataProvider {
|
|
|
313
327
|
let vals = '';
|
|
314
328
|
let added = false;
|
|
315
329
|
for (const x of this.entity.fields) {
|
|
316
|
-
if (isDbReadonly(x, e)) {
|
|
330
|
+
if (isDbReadonly(x, e)) {
|
|
331
|
+
}
|
|
317
332
|
else {
|
|
318
333
|
let v = x.valueConverter.toDb(data[x.key]);
|
|
319
334
|
if (v != undefined) {
|
|
@@ -331,23 +346,25 @@ class ActualSQLServerDataProvider {
|
|
|
331
346
|
let statement = `insert into ${e.$entityName} (${cols}) values (${vals})`;
|
|
332
347
|
let { colKeys, select } = this.buildSelect(e);
|
|
333
348
|
statement += ' returning ' + select;
|
|
334
|
-
return await r
|
|
349
|
+
return await r
|
|
350
|
+
.execute(statement)
|
|
351
|
+
.then((sql) => this.buildResultRow(colKeys, sql.rows[0], sql));
|
|
335
352
|
}
|
|
336
353
|
}
|
|
337
354
|
ActualSQLServerDataProvider.LogToConsole = false;
|
|
338
355
|
class myDummySQLCommand {
|
|
339
356
|
execute(sql) {
|
|
340
|
-
throw new Error(
|
|
357
|
+
throw new Error('Method not implemented.');
|
|
341
358
|
}
|
|
342
359
|
addParameterAndReturnSqlToken(val) {
|
|
343
360
|
if (val === null)
|
|
344
|
-
return
|
|
361
|
+
return 'null';
|
|
345
362
|
if (val instanceof Date)
|
|
346
363
|
val = val.toISOString();
|
|
347
|
-
if (typeof
|
|
364
|
+
if (typeof val == 'string') {
|
|
348
365
|
if (val == undefined)
|
|
349
366
|
val = '';
|
|
350
|
-
return '
|
|
367
|
+
return "'" + val.replace(/'/g, "''") + "'";
|
|
351
368
|
}
|
|
352
369
|
return val.toString();
|
|
353
370
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { __RowsOfDataForTesting } from
|
|
2
|
-
import { SqlCommand, SqlImplementation } from
|
|
3
|
-
import { EntityMetadata } from
|
|
4
|
-
import { Remult } from
|
|
1
|
+
import { __RowsOfDataForTesting } from '../__RowsOfDataForTesting';
|
|
2
|
+
import { SqlCommand, SqlImplementation } from '../sql-command';
|
|
3
|
+
import { EntityMetadata } from '../remult3';
|
|
4
|
+
import { Remult } from '../context';
|
|
5
5
|
export declare class WebSqlDataProvider implements SqlImplementation, __RowsOfDataForTesting {
|
|
6
6
|
private databaseName;
|
|
7
7
|
rows: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isAutoIncrement } from
|
|
2
|
-
import { SqlDatabase } from
|
|
3
|
-
import { dbNamesOf, isDbReadonly } from
|
|
1
|
+
import { isAutoIncrement } from '../remult3';
|
|
2
|
+
import { SqlDatabase } from './sql-database';
|
|
3
|
+
import { dbNamesOf, isDbReadonly, } from '../filter/filter-consumer-bridge-to-sql-request';
|
|
4
4
|
//SqlDatabase.LogToConsole = true;
|
|
5
5
|
export class WebSqlDataProvider {
|
|
6
6
|
constructor(databaseName, databaseSize = 2 * 1024 * 1024) {
|
|
@@ -13,7 +13,7 @@ export class WebSqlDataProvider {
|
|
|
13
13
|
const sql = SqlDatabase.getDb(remult);
|
|
14
14
|
const me = sql._getSourceSql();
|
|
15
15
|
if (!me.db) {
|
|
16
|
-
throw
|
|
16
|
+
throw 'the data provider is not a WebSqlDataProvider';
|
|
17
17
|
}
|
|
18
18
|
return me.db;
|
|
19
19
|
}
|
|
@@ -45,7 +45,7 @@ export class WebSqlDataProvider {
|
|
|
45
45
|
result += '\r\n ';
|
|
46
46
|
if (isAutoIncrement(x)) {
|
|
47
47
|
if (x.key != entity.idMetadata.field.key)
|
|
48
|
-
throw
|
|
48
|
+
throw 'in web sql, autoincrement is only allowed for primary key';
|
|
49
49
|
result += e.$dbNameOf(x) + ' integer primary key autoincrement';
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
@@ -65,15 +65,15 @@ export class WebSqlDataProvider {
|
|
|
65
65
|
return new WebSqlBridgeToSQLCommand(this.db);
|
|
66
66
|
}
|
|
67
67
|
async transaction(action) {
|
|
68
|
-
throw new Error(
|
|
68
|
+
throw new Error('Method not implemented.');
|
|
69
69
|
}
|
|
70
70
|
addColumnSqlSyntax(x, dbName) {
|
|
71
71
|
let result = dbName;
|
|
72
|
-
const nullNumber = x.allowNull ?
|
|
72
|
+
const nullNumber = x.allowNull ? '' : ' default 0 not null';
|
|
73
73
|
if (x.valueType == Date)
|
|
74
|
-
result +=
|
|
74
|
+
result += ' integer';
|
|
75
75
|
else if (x.valueType == Boolean)
|
|
76
|
-
result +=
|
|
76
|
+
result += ' integer ' + nullNumber;
|
|
77
77
|
else if (x.valueType == Number) {
|
|
78
78
|
if (!x.valueConverter.fieldTypeInDb)
|
|
79
79
|
result += ' real ' + nullNumber;
|
|
@@ -81,10 +81,12 @@ export class WebSqlDataProvider {
|
|
|
81
81
|
result += ' ' + x.valueConverter.fieldTypeInDb + ' ' + nullNumber;
|
|
82
82
|
}
|
|
83
83
|
else
|
|
84
|
-
result +=
|
|
84
|
+
result += ' text' + (x.allowNull ? ' ' : " default '' not null ");
|
|
85
85
|
return result;
|
|
86
86
|
}
|
|
87
|
-
toString() {
|
|
87
|
+
toString() {
|
|
88
|
+
return 'WebSqlDataProvider';
|
|
89
|
+
}
|
|
88
90
|
}
|
|
89
91
|
class WebSqlBridgeToSQLCommand {
|
|
90
92
|
//@ts-ignore
|
|
@@ -97,12 +99,12 @@ class WebSqlBridgeToSQLCommand {
|
|
|
97
99
|
return '~' + this.values.length + '~';
|
|
98
100
|
}
|
|
99
101
|
execute(sql) {
|
|
100
|
-
return new Promise((resolve, reject) => this.source.transaction(t => {
|
|
102
|
+
return new Promise((resolve, reject) => this.source.transaction((t) => {
|
|
101
103
|
let s = sql;
|
|
102
104
|
let v = [];
|
|
103
105
|
var m = s.match(/~\d+~/g);
|
|
104
106
|
if (m != null)
|
|
105
|
-
m.forEach(mr => {
|
|
107
|
+
m.forEach((mr) => {
|
|
106
108
|
s = s.replace(mr, '?');
|
|
107
109
|
v.push(this.values[Number.parseInt(mr.substring(1, mr.length - 1)) - 1]);
|
|
108
110
|
});
|
package/esm/src/entity.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Allowed, AllowedForInstance } from
|
|
1
|
+
import { Allowed, AllowedForInstance } from './context';
|
|
2
2
|
import { FieldMetadata } from './column-interfaces';
|
|
3
|
-
import { EntityOrderBy, FieldsMetadata, EntityFilter, EntityRef, EntityMetadata } from
|
|
3
|
+
import { EntityOrderBy, FieldsMetadata, EntityFilter, EntityRef, EntityMetadata } from './remult3';
|
|
4
4
|
export interface EntityOptions<entityType = any> {
|
|
5
5
|
/**A human readable name for the entity */
|
|
6
6
|
caption?: string;
|
|
@@ -27,14 +27,14 @@ export interface EntityOptions<entityType = any> {
|
|
|
27
27
|
/** A filter that determines which rows can be queries using the api.
|
|
28
28
|
* @description
|
|
29
29
|
* Use apiPrefilter in cases where you to restrict data based on user profile
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
* @example
|
|
31
|
+
* apiPrefilter: { archive:false }
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* apiPrefilter: ()=> remult.isAllowed("admin")?{}:{ archive:false }
|
|
35
|
+
* @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
38
|
apiPrefilter?: EntityFilter<entityType> | (() => EntityFilter<entityType> | Promise<EntityFilter<entityType>>);
|
|
39
39
|
/** A filter that will be used for all queries from this entity both from the API and from within the backend.
|
|
40
40
|
* @example
|
|
@@ -51,15 +51,15 @@ export interface EntityOptions<entityType = any> {
|
|
|
51
51
|
*/
|
|
52
52
|
defaultOrderBy?: EntityOrderBy<entityType>;
|
|
53
53
|
/** An event that will be fired before the Entity will be saved to the database.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
* If the `error` property of the entity's ref or any of its fields will be set, the save will be aborted and an exception will be thrown.
|
|
55
|
+
* this is the place to run logic that we want to run in any case before an entity is saved.
|
|
56
|
+
* @example
|
|
57
|
+
* @Entity<Task>("tasks", {
|
|
58
|
+
* saving: async task => {
|
|
59
|
+
* task.lastUpdated = new Date()
|
|
60
|
+
* }
|
|
61
|
+
*})
|
|
62
|
+
*/
|
|
63
63
|
saving?: (row: entityType, proceedWithoutSavingToDb: () => void) => Promise<any> | any;
|
|
64
64
|
/** will be called after the Entity was saved to the data source. */
|
|
65
65
|
saved?: (row: entityType) => Promise<any> | any;
|
|
@@ -70,10 +70,10 @@ export interface EntityOptions<entityType = any> {
|
|
|
70
70
|
/** Will be called when the entity is being validated, usually prior to the `saving` event */
|
|
71
71
|
validation?: (row: entityType, ref: EntityRef<entityType>) => Promise<any> | any;
|
|
72
72
|
/** The name of the table in the database that holds the data for this entity.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
* If no name is set, the `key` will be used instead.
|
|
74
|
+
* @example
|
|
75
|
+
* dbName:'myProducts'
|
|
76
|
+
*/
|
|
77
77
|
dbName?: string;
|
|
78
78
|
/** For entities that are based on SQL expressions instead of a physical table or view*/
|
|
79
79
|
sqlExpression?: string | ((entity: EntityMetadata<entityType>) => string | Promise<string>);
|
|
@@ -84,7 +84,7 @@ export interface EntityOptions<entityType = any> {
|
|
|
84
84
|
* @example
|
|
85
85
|
* //Multiple columns id
|
|
86
86
|
* @Entity<OrderDetails>("orderDetails", { id:od=> [od.orderId, od.productCode] })
|
|
87
|
-
|
|
87
|
+
*/
|
|
88
88
|
id?: (entity: FieldsMetadata<entityType>) => FieldMetadata | FieldMetadata[];
|
|
89
89
|
entityRefInit?: (ref: EntityRef<entityType>, row: entityType) => void;
|
|
90
90
|
apiRequireId?: Allowed;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SqlCommandWithParameters } from
|
|
1
|
+
import { SqlCommandWithParameters } from '../sql-command';
|
|
2
2
|
import { Filter, FilterConsumer } from './filter-interfaces';
|
|
3
|
-
import { FieldMetadata } from
|
|
4
|
-
import { EntityFilter, OmitEB } from
|
|
5
|
-
import { EntityMetadataOverloads, RepositoryOverloads } from
|
|
3
|
+
import { FieldMetadata } from '../column-interfaces';
|
|
4
|
+
import { EntityFilter, OmitEB } from '../remult3/remult3';
|
|
5
|
+
import { EntityMetadataOverloads, RepositoryOverloads } from '../remult3';
|
|
6
6
|
export declare class FilterConsumerBridgeToSqlRequest implements FilterConsumer {
|
|
7
7
|
private r;
|
|
8
8
|
private nameProvider;
|