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
|
@@ -9,7 +9,7 @@ var server_action_1 = require("../server-action");
|
|
|
9
9
|
var RestDataProvider = /** @class */ (function () {
|
|
10
10
|
function RestDataProvider(apiProvider) {
|
|
11
11
|
this.apiProvider = apiProvider;
|
|
12
|
-
this.
|
|
12
|
+
this.isProxy = true;
|
|
13
13
|
}
|
|
14
14
|
RestDataProvider.prototype.getEntityDataProvider = function (entity) {
|
|
15
15
|
var _this = this;
|
|
@@ -26,7 +26,7 @@ var RestDataProvider = /** @class */ (function () {
|
|
|
26
26
|
RestDataProvider.prototype.transaction = function (action) {
|
|
27
27
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
28
28
|
return tslib_1.__generator(this, function (_a) {
|
|
29
|
-
throw new Error(
|
|
29
|
+
throw new Error('Method not implemented.');
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
};
|
|
@@ -46,10 +46,10 @@ function findOptionsFromJson(json, meta) {
|
|
|
46
46
|
var e_1, _a;
|
|
47
47
|
var r = {};
|
|
48
48
|
try {
|
|
49
|
-
for (var _b = tslib_1.__values([
|
|
49
|
+
for (var _b = tslib_1.__values(['limit', 'page', 'where', 'orderBy']), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
50
50
|
var key = _c.value;
|
|
51
51
|
if (json[key] !== undefined) {
|
|
52
|
-
if (key ===
|
|
52
|
+
if (key === 'where') {
|
|
53
53
|
r[key] = filter_interfaces_1.Filter.entityFilterFromJson(meta, json.where);
|
|
54
54
|
}
|
|
55
55
|
else
|
|
@@ -117,7 +117,7 @@ var RestEntityDataProvider = /** @class */ (function () {
|
|
|
117
117
|
var run;
|
|
118
118
|
return tslib_1.__generator(this, function (_a) {
|
|
119
119
|
run = this.buildFindRequest({ where: where }).run;
|
|
120
|
-
return [2 /*return*/, run(
|
|
120
|
+
return [2 /*return*/, run('count').then(function (r) { return +r.count; })];
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
123
|
};
|
|
@@ -143,11 +143,11 @@ var RestEntityDataProvider = /** @class */ (function () {
|
|
|
143
143
|
var hasDescending_1 = false;
|
|
144
144
|
options.orderBy.Segments.forEach(function (c) {
|
|
145
145
|
if (sort_1.length > 0) {
|
|
146
|
-
sort_1 +=
|
|
147
|
-
order_1 +=
|
|
146
|
+
sort_1 += ',';
|
|
147
|
+
order_1 += ',';
|
|
148
148
|
}
|
|
149
149
|
sort_1 += c.field.key;
|
|
150
|
-
order_1 += c.isDescending ?
|
|
150
|
+
order_1 += c.isDescending ? 'desc' : 'asc';
|
|
151
151
|
if (c.isDescending)
|
|
152
152
|
hasDescending_1 = true;
|
|
153
153
|
});
|
|
@@ -164,10 +164,10 @@ var RestEntityDataProvider = /** @class */ (function () {
|
|
|
164
164
|
var run = function (action) {
|
|
165
165
|
var u = new urlBuilder_1.UrlBuilder(url.url);
|
|
166
166
|
if (!action && filterObject) {
|
|
167
|
-
action =
|
|
167
|
+
action = 'get';
|
|
168
168
|
}
|
|
169
169
|
if (action)
|
|
170
|
-
u.add(
|
|
170
|
+
u.add('__action', action);
|
|
171
171
|
if (filterObject) {
|
|
172
172
|
return _this.http().post(u.url, filterObject);
|
|
173
173
|
}
|
|
@@ -190,15 +190,17 @@ var RestEntityDataProvider = /** @class */ (function () {
|
|
|
190
190
|
unsubscribe: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
191
191
|
var _this = this;
|
|
192
192
|
return tslib_1.__generator(this, function (_a) {
|
|
193
|
-
return [2 /*return*/, server_action_1.actionInfo.runActionWithoutBlockingUI(function () {
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
return [2 /*return*/, server_action_1.actionInfo.runActionWithoutBlockingUI(function () {
|
|
194
|
+
return _this.http().post(_this.url() + '?__action=endLiveQuery', {
|
|
195
|
+
id: queryId,
|
|
196
|
+
});
|
|
197
|
+
})];
|
|
196
198
|
});
|
|
197
|
-
}); }
|
|
199
|
+
}); },
|
|
198
200
|
}];
|
|
199
201
|
}
|
|
200
202
|
});
|
|
201
|
-
}); }
|
|
203
|
+
}); },
|
|
202
204
|
};
|
|
203
205
|
};
|
|
204
206
|
RestEntityDataProvider.prototype.update = function (id, data) {
|
|
@@ -220,14 +222,18 @@ var RestEntityDataProvider = /** @class */ (function () {
|
|
|
220
222
|
}
|
|
221
223
|
finally { if (e_4) throw e_4.error; }
|
|
222
224
|
}
|
|
223
|
-
return this.http()
|
|
225
|
+
return this.http()
|
|
226
|
+
.put(this.url() + '/' + encodeURIComponent(id), result)
|
|
227
|
+
.then(function (y) { return _this.translateFromJson(y); });
|
|
224
228
|
};
|
|
225
229
|
RestEntityDataProvider.prototype.delete = function (id) {
|
|
226
230
|
return this.http().delete(this.url() + '/' + encodeURIComponent(id));
|
|
227
231
|
};
|
|
228
232
|
RestEntityDataProvider.prototype.insert = function (data) {
|
|
229
233
|
var _this = this;
|
|
230
|
-
return this.http()
|
|
234
|
+
return this.http()
|
|
235
|
+
.post(this.url(), this.translateToJson(data))
|
|
236
|
+
.then(function (y) { return _this.translateFromJson(y); });
|
|
231
237
|
};
|
|
232
238
|
return RestEntityDataProvider;
|
|
233
239
|
}());
|
|
@@ -256,7 +262,7 @@ var RestDataProviderHttpProviderUsingFetch = /** @class */ (function () {
|
|
|
256
262
|
RestDataProviderHttpProviderUsingFetch.prototype.put = function (url, data) {
|
|
257
263
|
return this.myFetch(url, {
|
|
258
264
|
method: 'put',
|
|
259
|
-
body: JSON.stringify(data)
|
|
265
|
+
body: JSON.stringify(data),
|
|
260
266
|
});
|
|
261
267
|
};
|
|
262
268
|
RestDataProviderHttpProviderUsingFetch.prototype.delete = function (url) {
|
|
@@ -267,10 +273,12 @@ var RestDataProviderHttpProviderUsingFetch = /** @class */ (function () {
|
|
|
267
273
|
var _this = this;
|
|
268
274
|
return tslib_1.__generator(this, function (_a) {
|
|
269
275
|
switch (_a.label) {
|
|
270
|
-
case 0: return [4 /*yield*/, buildRestDataProvider_1.retry(function () {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
276
|
+
case 0: return [4 /*yield*/, buildRestDataProvider_1.retry(function () {
|
|
277
|
+
return _this.myFetch(url, {
|
|
278
|
+
method: 'post',
|
|
279
|
+
body: JSON.stringify(data),
|
|
280
|
+
});
|
|
281
|
+
})];
|
|
274
282
|
case 1: return [2 /*return*/, _a.sent()];
|
|
275
283
|
}
|
|
276
284
|
});
|
|
@@ -281,8 +289,10 @@ var RestDataProviderHttpProviderUsingFetch = /** @class */ (function () {
|
|
|
281
289
|
var _this = this;
|
|
282
290
|
var headers = {};
|
|
283
291
|
if (options === null || options === void 0 ? void 0 : options.body)
|
|
284
|
-
headers[
|
|
285
|
-
if (typeof window !== 'undefined' &&
|
|
292
|
+
headers['Content-type'] = 'application/json';
|
|
293
|
+
if (typeof window !== 'undefined' &&
|
|
294
|
+
typeof window.document !== 'undefined' &&
|
|
295
|
+
typeof (window.document.cookie !== 'undefined'))
|
|
286
296
|
try {
|
|
287
297
|
for (var _b = tslib_1.__values(window.document.cookie.split(';')), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
288
298
|
var cookie = _c.value;
|
|
@@ -302,10 +312,12 @@ var RestDataProviderHttpProviderUsingFetch = /** @class */ (function () {
|
|
|
302
312
|
credentials: 'include',
|
|
303
313
|
method: options === null || options === void 0 ? void 0 : options.method,
|
|
304
314
|
body: options === null || options === void 0 ? void 0 : options.body,
|
|
305
|
-
headers: headers
|
|
306
|
-
})
|
|
315
|
+
headers: headers,
|
|
316
|
+
})
|
|
317
|
+
.then(function (response) {
|
|
307
318
|
return onSuccess(response);
|
|
308
|
-
})
|
|
319
|
+
})
|
|
320
|
+
.catch(function (error) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
309
321
|
var r;
|
|
310
322
|
return tslib_1.__generator(this, function (_a) {
|
|
311
323
|
switch (_a.label) {
|
|
@@ -326,13 +338,16 @@ function onSuccess(response) {
|
|
|
326
338
|
if (response.status >= 200 && response.status < 300)
|
|
327
339
|
return response.json();
|
|
328
340
|
else {
|
|
329
|
-
throw response
|
|
341
|
+
throw response
|
|
342
|
+
.json()
|
|
343
|
+
.then(function (x) {
|
|
330
344
|
return tslib_1.__assign(tslib_1.__assign({}, x), { message: x.message || response.statusText, url: response.url, status: response.status });
|
|
331
|
-
})
|
|
345
|
+
})
|
|
346
|
+
.catch(function () {
|
|
332
347
|
throw {
|
|
333
348
|
message: response.statusText,
|
|
334
349
|
url: response.url,
|
|
335
|
-
status: response.status
|
|
350
|
+
status: response.status,
|
|
336
351
|
};
|
|
337
352
|
});
|
|
338
353
|
}
|
|
@@ -353,7 +368,7 @@ function addFilterToUrlAndReturnTrueIfSuccessful(filter, url) {
|
|
|
353
368
|
if (Object.prototype.hasOwnProperty.call(filter, key)) {
|
|
354
369
|
var element = filter[key];
|
|
355
370
|
if (Array.isArray(element)) {
|
|
356
|
-
if (key.endsWith(
|
|
371
|
+
if (key.endsWith('.in'))
|
|
357
372
|
url.add(key, JSON.stringify(element));
|
|
358
373
|
else
|
|
359
374
|
element.forEach(function (e) { return url.add(key, e); });
|
|
@@ -370,4 +385,4 @@ function addFilterToUrlAndReturnTrueIfSuccessful(filter, url) {
|
|
|
370
385
|
return true;
|
|
371
386
|
}
|
|
372
387
|
exports.addFilterToUrlAndReturnTrueIfSuccessful = addFilterToUrlAndReturnTrueIfSuccessful;
|
|
373
|
-
exports.liveQueryAction =
|
|
388
|
+
exports.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;
|
|
@@ -16,9 +16,9 @@ var SqlDatabase = /** @class */ (function () {
|
|
|
16
16
|
this.createdEntities = [];
|
|
17
17
|
}
|
|
18
18
|
SqlDatabase.getDb = function (remult) {
|
|
19
|
-
var r = (remult || remult_proxy_1.
|
|
19
|
+
var r = (remult || remult_proxy_1.remult).dataProvider;
|
|
20
20
|
if (!r.createCommand)
|
|
21
|
-
throw
|
|
21
|
+
throw 'the data provider is not an SqlDatabase';
|
|
22
22
|
return r;
|
|
23
23
|
};
|
|
24
24
|
SqlDatabase.prototype.createCommand = function () {
|
|
@@ -60,7 +60,7 @@ var SqlDatabase = /** @class */ (function () {
|
|
|
60
60
|
try {
|
|
61
61
|
for (var _b = tslib_1.__values(entity.fields.toArray()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
62
62
|
var f = _c.value;
|
|
63
|
-
if (f.valueConverter.fieldTypeInDb ===
|
|
63
|
+
if (f.valueConverter.fieldTypeInDb === 'json') {
|
|
64
64
|
//@ts-ignore
|
|
65
65
|
f.valueConverter = tslib_1.__assign(tslib_1.__assign({}, f.valueConverter), { toDb: valueConverters_1.ValueConverters.JsonString.toDb, fromDb: valueConverters_1.ValueConverters.JsonString.fromDb });
|
|
66
66
|
}
|
|
@@ -105,20 +105,24 @@ var SqlDatabase = /** @class */ (function () {
|
|
|
105
105
|
createCommand: function () {
|
|
106
106
|
var c = x.createCommand();
|
|
107
107
|
return {
|
|
108
|
-
addParameterAndReturnSqlToken: function (x) {
|
|
108
|
+
addParameterAndReturnSqlToken: function (x) {
|
|
109
|
+
return c.addParameterAndReturnSqlToken(x);
|
|
110
|
+
},
|
|
109
111
|
execute: function (sql) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
110
112
|
return tslib_1.__generator(this, function (_a) {
|
|
111
113
|
if (completed)
|
|
112
114
|
throw "can't run a command after the transaction was completed";
|
|
113
115
|
return [2 /*return*/, c.execute(sql)];
|
|
114
116
|
});
|
|
115
|
-
}); }
|
|
117
|
+
}); },
|
|
116
118
|
};
|
|
117
119
|
},
|
|
118
120
|
getLimitSqlSyntax: this.sql.getLimitSqlSyntax,
|
|
119
|
-
entityIsUsedForTheFirstTime: function (y) {
|
|
121
|
+
entityIsUsedForTheFirstTime: function (y) {
|
|
122
|
+
return x.entityIsUsedForTheFirstTime(y);
|
|
123
|
+
},
|
|
120
124
|
transaction: function (z) { return x.transaction(z); },
|
|
121
|
-
supportsJsonColumnType: this.sql.supportsJsonColumnType
|
|
125
|
+
supportsJsonColumnType: this.sql.supportsJsonColumnType,
|
|
122
126
|
}))];
|
|
123
127
|
case 2:
|
|
124
128
|
_a.sent();
|
|
@@ -135,7 +139,7 @@ var SqlDatabase = /** @class */ (function () {
|
|
|
135
139
|
var _a;
|
|
136
140
|
return _a = {},
|
|
137
141
|
_a[filter_interfaces_1.customDatabaseFilterToken] = {
|
|
138
|
-
buildSql: build
|
|
142
|
+
buildSql: build,
|
|
139
143
|
},
|
|
140
144
|
_a;
|
|
141
145
|
};
|
|
@@ -155,7 +159,7 @@ var SqlDatabase = /** @class */ (function () {
|
|
|
155
159
|
case 1:
|
|
156
160
|
b = new (_a.apply(filter_consumer_bridge_to_sql_request_1.FilterConsumerBridgeToSqlRequest, _b.concat([_c.sent()])))();
|
|
157
161
|
b._addWhere = false;
|
|
158
|
-
return [4 /*yield*/,
|
|
162
|
+
return [4 /*yield*/, r.translateWhereToFilter(condition)];
|
|
159
163
|
case 2: return [4 /*yield*/, (_c.sent()).__applyToConsumer(b)];
|
|
160
164
|
case 3:
|
|
161
165
|
_c.sent();
|
|
@@ -222,12 +226,15 @@ var LogSQLCommand = /** @class */ (function () {
|
|
|
222
226
|
d = new Date().valueOf() - start.valueOf();
|
|
223
227
|
if (d > SqlDatabase.durationThreshold) {
|
|
224
228
|
duration = d / 1000;
|
|
225
|
-
if (this.logToConsole ===
|
|
226
|
-
rawSql = sql
|
|
229
|
+
if (this.logToConsole === 'oneLiner') {
|
|
230
|
+
rawSql = sql
|
|
231
|
+
.replace(/(\r\n|\n|\r|\t)/gm, ' ')
|
|
232
|
+
.replace(/ +/g, ' ')
|
|
233
|
+
.trim();
|
|
227
234
|
first = rawSql.split(' ')[0].toUpperCase();
|
|
228
|
-
console.info((icons.get(first) || '💢') + " (" +
|
|
235
|
+
console.info((icons.get(first) || '💢') + " (" + duration.toFixed(3) + ") " + rawSql + " " + JSON.stringify(this.args));
|
|
229
236
|
}
|
|
230
|
-
else if (typeof this.logToConsole ===
|
|
237
|
+
else if (typeof this.logToConsole === 'function') {
|
|
231
238
|
this.logToConsole(duration, sql, this.args);
|
|
232
239
|
}
|
|
233
240
|
else {
|
|
@@ -330,7 +337,10 @@ var ActualSQLServerDataProvider = /** @class */ (function () {
|
|
|
330
337
|
segs = [];
|
|
331
338
|
_loop_1 = function (s) {
|
|
332
339
|
if (s.field instanceof column_1.CompoundIdField) {
|
|
333
|
-
segs.push.apply(segs, tslib_1.__spread(s.field.fields.map(function (c) { return ({
|
|
340
|
+
segs.push.apply(segs, tslib_1.__spread(s.field.fields.map(function (c) { return ({
|
|
341
|
+
field: c,
|
|
342
|
+
isDescending: s.isDescending,
|
|
343
|
+
}); })));
|
|
334
344
|
}
|
|
335
345
|
else
|
|
336
346
|
segs.push(s);
|
|
@@ -376,7 +386,9 @@ var ActualSQLServerDataProvider = /** @class */ (function () {
|
|
|
376
386
|
page = options.page;
|
|
377
387
|
if (page < 1)
|
|
378
388
|
page = 1;
|
|
379
|
-
select +=
|
|
389
|
+
select +=
|
|
390
|
+
' ' +
|
|
391
|
+
this.strategy.getLimitSqlSyntax(options.limit, (page - 1) * options.limit);
|
|
380
392
|
}
|
|
381
393
|
_g.label = 4;
|
|
382
394
|
case 4: return [2 /*return*/, r.execute(select).then(function (r) {
|
|
@@ -396,7 +408,7 @@ var ActualSQLServerDataProvider = /** @class */ (function () {
|
|
|
396
408
|
result[col.key] = col.valueConverter.fromDb(y[r.getColumnKeyInResultForIndexInSelect(index)]);
|
|
397
409
|
}
|
|
398
410
|
catch (err) {
|
|
399
|
-
throw new Error(
|
|
411
|
+
throw new Error('Failed to load from db:' + col.key + '\r\n' + err);
|
|
400
412
|
}
|
|
401
413
|
}
|
|
402
414
|
return result;
|
|
@@ -447,7 +459,8 @@ var ActualSQLServerDataProvider = /** @class */ (function () {
|
|
|
447
459
|
x = _b.value;
|
|
448
460
|
if (x instanceof column_1.CompoundIdField) {
|
|
449
461
|
}
|
|
450
|
-
if (filter_consumer_bridge_to_sql_request_1.isDbReadonly(x, e)) {
|
|
462
|
+
if (filter_consumer_bridge_to_sql_request_1.isDbReadonly(x, e)) {
|
|
463
|
+
}
|
|
451
464
|
else if (data[x.key] !== undefined) {
|
|
452
465
|
v = x.valueConverter.toDb(data[x.key]);
|
|
453
466
|
if (v !== undefined) {
|
|
@@ -455,7 +468,8 @@ var ActualSQLServerDataProvider = /** @class */ (function () {
|
|
|
455
468
|
added = true;
|
|
456
469
|
else
|
|
457
470
|
statement += ', ';
|
|
458
|
-
statement +=
|
|
471
|
+
statement +=
|
|
472
|
+
e.$dbNameOf(x) + ' = ' + r.addParameterAndReturnSqlToken(v);
|
|
459
473
|
}
|
|
460
474
|
}
|
|
461
475
|
}
|
|
@@ -518,7 +532,8 @@ var ActualSQLServerDataProvider = /** @class */ (function () {
|
|
|
518
532
|
try {
|
|
519
533
|
for (_a = tslib_1.__values(this.entity.fields), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
520
534
|
x = _b.value;
|
|
521
|
-
if (filter_consumer_bridge_to_sql_request_1.isDbReadonly(x, e)) {
|
|
535
|
+
if (filter_consumer_bridge_to_sql_request_1.isDbReadonly(x, e)) {
|
|
536
|
+
}
|
|
522
537
|
else {
|
|
523
538
|
v = x.valueConverter.toDb(data[x.key]);
|
|
524
539
|
if (v != undefined) {
|
|
@@ -544,7 +559,9 @@ var ActualSQLServerDataProvider = /** @class */ (function () {
|
|
|
544
559
|
statement = "insert into " + e.$entityName + " (" + cols + ") values (" + vals + ")";
|
|
545
560
|
_c = this.buildSelect(e), colKeys = _c.colKeys, select = _c.select;
|
|
546
561
|
statement += ' returning ' + select;
|
|
547
|
-
return [4 /*yield*/, r
|
|
562
|
+
return [4 /*yield*/, r
|
|
563
|
+
.execute(statement)
|
|
564
|
+
.then(function (sql) { return _this.buildResultRow(colKeys, sql.rows[0], sql); })];
|
|
548
565
|
case 2: return [2 /*return*/, _e.sent()];
|
|
549
566
|
}
|
|
550
567
|
});
|
|
@@ -557,17 +574,17 @@ var myDummySQLCommand = /** @class */ (function () {
|
|
|
557
574
|
function myDummySQLCommand() {
|
|
558
575
|
}
|
|
559
576
|
myDummySQLCommand.prototype.execute = function (sql) {
|
|
560
|
-
throw new Error(
|
|
577
|
+
throw new Error('Method not implemented.');
|
|
561
578
|
};
|
|
562
579
|
myDummySQLCommand.prototype.addParameterAndReturnSqlToken = function (val) {
|
|
563
580
|
if (val === null)
|
|
564
|
-
return
|
|
581
|
+
return 'null';
|
|
565
582
|
if (val instanceof Date)
|
|
566
583
|
val = val.toISOString();
|
|
567
|
-
if (typeof
|
|
584
|
+
if (typeof val == 'string') {
|
|
568
585
|
if (val == undefined)
|
|
569
586
|
val = '';
|
|
570
|
-
return '
|
|
587
|
+
return "'" + val.replace(/'/g, "''") + "'";
|
|
571
588
|
}
|
|
572
589
|
return val.toString();
|
|
573
590
|
};
|
|
@@ -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: {
|
|
@@ -18,7 +18,7 @@ var WebSqlDataProvider = /** @class */ (function () {
|
|
|
18
18
|
var sql = sql_database_1.SqlDatabase.getDb(remult);
|
|
19
19
|
var me = sql._getSourceSql();
|
|
20
20
|
if (!me.db) {
|
|
21
|
-
throw
|
|
21
|
+
throw 'the data provider is not a WebSqlDataProvider';
|
|
22
22
|
}
|
|
23
23
|
return me.db;
|
|
24
24
|
};
|
|
@@ -112,7 +112,7 @@ var WebSqlDataProvider = /** @class */ (function () {
|
|
|
112
112
|
result += '\r\n ';
|
|
113
113
|
if (remult3_1.isAutoIncrement(x)) {
|
|
114
114
|
if (x.key != entity.idMetadata.field.key)
|
|
115
|
-
throw
|
|
115
|
+
throw 'in web sql, autoincrement is only allowed for primary key';
|
|
116
116
|
result += e.$dbNameOf(x) + ' integer primary key autoincrement';
|
|
117
117
|
}
|
|
118
118
|
else {
|
|
@@ -148,17 +148,17 @@ var WebSqlDataProvider = /** @class */ (function () {
|
|
|
148
148
|
WebSqlDataProvider.prototype.transaction = function (action) {
|
|
149
149
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
150
150
|
return tslib_1.__generator(this, function (_a) {
|
|
151
|
-
throw new Error(
|
|
151
|
+
throw new Error('Method not implemented.');
|
|
152
152
|
});
|
|
153
153
|
});
|
|
154
154
|
};
|
|
155
155
|
WebSqlDataProvider.prototype.addColumnSqlSyntax = function (x, dbName) {
|
|
156
156
|
var result = dbName;
|
|
157
|
-
var nullNumber = x.allowNull ?
|
|
157
|
+
var nullNumber = x.allowNull ? '' : ' default 0 not null';
|
|
158
158
|
if (x.valueType == Date)
|
|
159
|
-
result +=
|
|
159
|
+
result += ' integer';
|
|
160
160
|
else if (x.valueType == Boolean)
|
|
161
|
-
result +=
|
|
161
|
+
result += ' integer ' + nullNumber;
|
|
162
162
|
else if (x.valueType == Number) {
|
|
163
163
|
if (!x.valueConverter.fieldTypeInDb)
|
|
164
164
|
result += ' real ' + nullNumber;
|
|
@@ -166,10 +166,12 @@ var WebSqlDataProvider = /** @class */ (function () {
|
|
|
166
166
|
result += ' ' + x.valueConverter.fieldTypeInDb + ' ' + nullNumber;
|
|
167
167
|
}
|
|
168
168
|
else
|
|
169
|
-
result +=
|
|
169
|
+
result += ' text' + (x.allowNull ? ' ' : " default '' not null ");
|
|
170
170
|
return result;
|
|
171
171
|
};
|
|
172
|
-
WebSqlDataProvider.prototype.toString = function () {
|
|
172
|
+
WebSqlDataProvider.prototype.toString = function () {
|
|
173
|
+
return 'WebSqlDataProvider';
|
|
174
|
+
};
|
|
173
175
|
return WebSqlDataProvider;
|
|
174
176
|
}());
|
|
175
177
|
exports.WebSqlDataProvider = WebSqlDataProvider;
|
package/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;
|