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,66 +1,69 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { DataApi } from
|
|
3
|
-
import { Fields, Entity, EntityBase, Field, IdEntity } from
|
|
4
|
-
import { c } from
|
|
5
|
-
import { Done } from
|
|
6
|
-
import { h } from
|
|
7
|
-
import { Categories as newCategories } from
|
|
8
|
-
import { tasks } from
|
|
9
|
-
import { TestDataApiResponse } from
|
|
10
|
-
import { testAll, testAllDbs, TestDbs } from
|
|
11
|
-
import { entityWithValidations, testConfiguration } from
|
|
12
|
-
import { Remult } from
|
|
13
|
-
import { dWithPrefilter } from
|
|
14
|
-
import { entityFilterToJson, Filter } from
|
|
15
|
-
import { d } from
|
|
16
|
-
import { entityForrawFilter1 } from
|
|
17
|
-
import { entityWithValidationsOnColumn } from
|
|
18
|
-
import { Validators } from
|
|
19
|
-
import { Status } from
|
|
20
|
-
import { describeClass } from
|
|
21
|
-
import { DataProviderLiveQueryStorage, LiveQueryStorageEntity } from
|
|
2
|
+
import { DataApi } from '../data-api';
|
|
3
|
+
import { Fields, Entity, EntityBase, Field, IdEntity, } from '../remult3';
|
|
4
|
+
import { c } from '../tests/c';
|
|
5
|
+
import { Done } from '../tests/Done';
|
|
6
|
+
import { h } from '../tests/h';
|
|
7
|
+
import { Categories as newCategories } from '../tests/remult-3-entities';
|
|
8
|
+
import { tasks } from '../tests/tasks';
|
|
9
|
+
import { TestDataApiResponse } from '../tests/TestDataApiResponse';
|
|
10
|
+
import { testAll, testAllDbs, TestDbs } from './db-tests-setup';
|
|
11
|
+
import { entityWithValidations, testConfiguration, } from './entityWithValidations';
|
|
12
|
+
import { Remult } from '../context';
|
|
13
|
+
import { dWithPrefilter } from '../tests/dWithPrefilter';
|
|
14
|
+
import { entityFilterToJson, Filter } from '../filter/filter-interfaces';
|
|
15
|
+
import { d } from '../tests/d';
|
|
16
|
+
import { entityForrawFilter1 } from '../tests/entityForCustomFilter';
|
|
17
|
+
import { entityWithValidationsOnColumn } from '../tests/entityWithValidationsOnColumn';
|
|
18
|
+
import { Validators } from '../validators';
|
|
19
|
+
import { Status } from '../tests/testModel/models';
|
|
20
|
+
import { describeClass } from '../remult3/DecoratorReplacer';
|
|
21
|
+
import { DataProviderLiveQueryStorage, LiveQueryStorageEntity, } from '../../live-query/data-provider-live-query-storage';
|
|
22
22
|
import { v4 as uuid } from 'uuid';
|
|
23
|
-
|
|
23
|
+
import { ValueConverters } from '../valueConverters';
|
|
24
|
+
testAll('what', async ({ remult, createEntity }) => {
|
|
24
25
|
await (await createEntity(stam)).create({ id: 1, title: 'noam' }).save();
|
|
25
26
|
expect(await remult.repo(stam).count()).toBe(1);
|
|
26
27
|
}, false);
|
|
27
|
-
testAll(
|
|
28
|
-
let r = await (await createEntity(stam))
|
|
28
|
+
testAll('data types', async ({ remult, createEntity }) => {
|
|
29
|
+
let r = await (await createEntity(stam))
|
|
30
|
+
.create({
|
|
29
31
|
id: 1,
|
|
30
32
|
//@ts-ignore
|
|
31
|
-
title: 42
|
|
32
|
-
})
|
|
33
|
-
|
|
33
|
+
title: 42,
|
|
34
|
+
})
|
|
35
|
+
.save();
|
|
36
|
+
expect(r.title).toEqual('42');
|
|
34
37
|
}, false);
|
|
35
|
-
testAll(
|
|
38
|
+
testAll('filter works on all db', async ({ createEntity }) => {
|
|
36
39
|
let s = await entityWithValidations.create4RowsInDp(createEntity);
|
|
37
40
|
expect((await s.find({ where: { myId: [1, 3] } })).length).toBe(2);
|
|
38
41
|
}, false);
|
|
39
|
-
testAll(
|
|
42
|
+
testAll('test in statement and ', async ({ createEntity }) => {
|
|
40
43
|
const repo = await entityWithValidations.create4RowsInDp(createEntity);
|
|
41
44
|
expect(await repo.count({ myId: [1, 3], $and: [{ myId: [3] }] })).toBe(1);
|
|
42
45
|
}, false);
|
|
43
|
-
testAll(
|
|
46
|
+
testAll('filter with and', async ({ createEntity }) => {
|
|
44
47
|
let s = await entityWithValidations.create4RowsInDp(createEntity);
|
|
45
48
|
expect((await s.find({ where: { $and: [{ myId: 1 }, { myId: 3 }] } })).length).toBe(0);
|
|
46
49
|
}, false);
|
|
47
|
-
testAll(
|
|
50
|
+
testAll('test empty in', async ({ createEntity }) => {
|
|
48
51
|
let s = await entityWithValidations.create4RowsInDp(createEntity);
|
|
49
52
|
expect((await s.find({ where: { myId: [] } })).length).toBe(0);
|
|
50
53
|
}, false);
|
|
51
|
-
testAll(
|
|
54
|
+
testAll('filter works on all db or', async ({ createEntity }) => {
|
|
52
55
|
let s = await entityWithValidations.create4RowsInDp(createEntity);
|
|
53
56
|
expect((await s.find({ where: { $or: [{ myId: 1 }, { myId: 3 }] } })).length).toBe(2);
|
|
54
57
|
}, false);
|
|
55
|
-
testAll(
|
|
58
|
+
testAll('filter works on all db or_1', async ({ createEntity }) => {
|
|
56
59
|
let s = await entityWithValidations.create4RowsInDp(createEntity);
|
|
57
60
|
expect((await s.find({ where: { $or: [{}, {}] } })).length).toBe(4);
|
|
58
61
|
}, false);
|
|
59
|
-
testAll(
|
|
62
|
+
testAll('filter works on all db or_2', async ({ createEntity }) => {
|
|
60
63
|
let s = await entityWithValidations.create4RowsInDp(createEntity);
|
|
61
64
|
expect((await s.find({ where: { $or: [{}, { myId: 3 }] } })).length).toBe(4);
|
|
62
65
|
}, false);
|
|
63
|
-
testAll(
|
|
66
|
+
testAll('entity with different id column still works well', async ({ createEntity }) => {
|
|
64
67
|
let s = await createEntity(entityWithValidations);
|
|
65
68
|
let c = s.create();
|
|
66
69
|
c.myId = 1;
|
|
@@ -71,7 +74,7 @@ testAll("entity with different id column still works well", async ({ createEntit
|
|
|
71
74
|
expect(c.name).toBe('yael');
|
|
72
75
|
expect((await s.find()).length).toBe(1);
|
|
73
76
|
}, false);
|
|
74
|
-
testAll(
|
|
77
|
+
testAll('empty find works', async ({ remult, createEntity }) => {
|
|
75
78
|
let c = (await createEntity(newCategories)).create();
|
|
76
79
|
c.id = 5;
|
|
77
80
|
c.categoryName = 'test';
|
|
@@ -80,28 +83,33 @@ testAll("empty find works", async ({ remult, createEntity }) => {
|
|
|
80
83
|
expect(l.length).toBe(1);
|
|
81
84
|
expect(l[0].categoryName).toBe('test');
|
|
82
85
|
}, false);
|
|
83
|
-
testAll(
|
|
86
|
+
testAll('test descending', async ({ createEntity }) => {
|
|
84
87
|
const repo = await createEntity(newCategories);
|
|
85
88
|
await repo.create({ id: 1, categoryName: 'a' }).save();
|
|
86
89
|
await repo.create({ id: 2, categoryName: 'b' }).save();
|
|
87
90
|
const rows = await repo.find({
|
|
88
91
|
orderBy: { categoryName: 'desc' },
|
|
89
|
-
page: -1
|
|
92
|
+
page: -1,
|
|
90
93
|
});
|
|
91
94
|
expect(rows[0].id).toBe(2);
|
|
92
95
|
}, false);
|
|
93
|
-
testAll(
|
|
96
|
+
testAll('test descending 2', async ({ createEntity }) => {
|
|
94
97
|
const repo = await createEntity(newCategories);
|
|
95
|
-
await repo.insert([
|
|
98
|
+
await repo.insert([
|
|
99
|
+
{ id: 1, categoryName: 'a' },
|
|
100
|
+
{ id: 2, categoryName: 'b' },
|
|
101
|
+
]);
|
|
96
102
|
const rows = await repo.find({
|
|
97
103
|
orderBy: { categoryName: 'desc' },
|
|
98
|
-
page: -1
|
|
104
|
+
page: -1,
|
|
99
105
|
});
|
|
100
106
|
expect(rows[0].id).toBe(2);
|
|
101
107
|
}, false);
|
|
102
|
-
testAll(
|
|
108
|
+
testAll('partial updates', async ({ remult, createEntity }) => {
|
|
103
109
|
let c = (await createEntity(newCategories)).create({
|
|
104
|
-
id: 5,
|
|
110
|
+
id: 5,
|
|
111
|
+
categoryName: 'test',
|
|
112
|
+
description: 'desc',
|
|
105
113
|
});
|
|
106
114
|
await c._.save();
|
|
107
115
|
let l = await remult.repo(newCategories).findId(5);
|
|
@@ -112,7 +120,7 @@ testAll("partial updates", async ({ remult, createEntity }) => {
|
|
|
112
120
|
expect(l.categoryName).toBe('newname');
|
|
113
121
|
expect(l.description).toBe('new desc');
|
|
114
122
|
}, false);
|
|
115
|
-
testAll(
|
|
123
|
+
testAll('put with validations on entity fails', async ({ remult, createEntity }) => {
|
|
116
124
|
let s = await createEntity(entityWithValidations);
|
|
117
125
|
let c = s.create();
|
|
118
126
|
c.myId = 1;
|
|
@@ -126,7 +134,7 @@ testAll("put with validations on entity fails", async ({ remult, createEntity })
|
|
|
126
134
|
d.ok();
|
|
127
135
|
};
|
|
128
136
|
await api.put(t, 1, {
|
|
129
|
-
name: '1'
|
|
137
|
+
name: '1',
|
|
130
138
|
});
|
|
131
139
|
d.test();
|
|
132
140
|
var x = await s.find({ where: { myId: 1 } });
|
|
@@ -134,7 +142,7 @@ testAll("put with validations on entity fails", async ({ remult, createEntity })
|
|
|
134
142
|
x = await s.find({ where: { myId: 1 } });
|
|
135
143
|
expect(x[0].name).toBe('noam');
|
|
136
144
|
});
|
|
137
|
-
testAll(
|
|
145
|
+
testAll('test date only with null works', async ({ createEntity }) => {
|
|
138
146
|
let repo = await createEntity(testDateWithNull);
|
|
139
147
|
let r = repo.create({ id: 0 });
|
|
140
148
|
await r.save();
|
|
@@ -150,12 +158,12 @@ testAll("test date only with null works", async ({ createEntity }) => {
|
|
|
150
158
|
await r.save();
|
|
151
159
|
expect(r.d).toBeNull();
|
|
152
160
|
}, false);
|
|
153
|
-
testAll(
|
|
161
|
+
testAll('test date with null works', async ({ createEntity }) => {
|
|
154
162
|
let repo = await createEntity(testDateWithNull);
|
|
155
163
|
let r = repo.create({ id: 0 });
|
|
156
164
|
await r.save();
|
|
157
165
|
r = await repo.findFirst();
|
|
158
|
-
expect(r.fullDate).toBeNull(
|
|
166
|
+
expect(r.fullDate).toBeNull('expected null after');
|
|
159
167
|
expect(await repo.count({ fullDate: null })).toBe(1);
|
|
160
168
|
r.fullDate = new Date(1976, 5, 16);
|
|
161
169
|
await r.save();
|
|
@@ -166,8 +174,10 @@ testAll("test date with null works", async ({ createEntity }) => {
|
|
|
166
174
|
await r.save();
|
|
167
175
|
expect(r.fullDate).toBeNull();
|
|
168
176
|
}, false);
|
|
169
|
-
testAll(
|
|
170
|
-
let r = await (await createEntity(testDateWithNull))
|
|
177
|
+
testAll('test original value of date', async ({ createEntity }) => {
|
|
178
|
+
let r = await (await createEntity(testDateWithNull))
|
|
179
|
+
.create({ id: 1, d: new Date(1976, 6, 16) })
|
|
180
|
+
.save();
|
|
171
181
|
expect(r.$.d.originalValue.getFullYear()).toBe(1976);
|
|
172
182
|
});
|
|
173
183
|
let testDateWithNull = class testDateWithNull extends EntityBase {
|
|
@@ -192,14 +202,14 @@ __decorate([
|
|
|
192
202
|
testDateWithNull = __decorate([
|
|
193
203
|
Entity('testDateWithNull', { allowApiCrud: true })
|
|
194
204
|
], testDateWithNull);
|
|
195
|
-
testAll(
|
|
205
|
+
testAll('test string with null works', async ({ createEntity }) => {
|
|
196
206
|
let repo = await createEntity(testStringWithNull);
|
|
197
207
|
let r = repo.create({ id: 0 });
|
|
198
208
|
await r.save();
|
|
199
209
|
r = await repo.findFirst();
|
|
200
210
|
expect(r.d).toBeNull();
|
|
201
211
|
});
|
|
202
|
-
testAll(
|
|
212
|
+
testAll('test tasks', async ({ createEntity }) => {
|
|
203
213
|
let c = await createEntity(tasks);
|
|
204
214
|
let t = c.create();
|
|
205
215
|
t.id = 1;
|
|
@@ -223,9 +233,9 @@ testAll("test filtering of null/''", async ({ createEntity }) => {
|
|
|
223
233
|
let b = await repo.create({ id: 'b' }).save();
|
|
224
234
|
let c = await repo.create({ id: 'c', refH: b }).save();
|
|
225
235
|
expect(await repo.count({ refH: null })).toBe(2);
|
|
226
|
-
expect(await repo.count({ refH: {
|
|
236
|
+
expect(await repo.count({ refH: { '!=': null } })).toBe(1);
|
|
227
237
|
}, false);
|
|
228
|
-
testAll(
|
|
238
|
+
testAll('test paging with complex object', async ({ remult, createEntity }) => {
|
|
229
239
|
await createEntity(c);
|
|
230
240
|
await createEntity(p);
|
|
231
241
|
let c1 = await remult.repo(c).create({ id: 1, name: 'c1' }).save();
|
|
@@ -238,13 +248,13 @@ testAll("test paging with complex object", async ({ remult, createEntity }) => {
|
|
|
238
248
|
await remult.repo(p).create({ id: 5, name: 'p5', c: c3 }).save();
|
|
239
249
|
let i = 0;
|
|
240
250
|
for await (const x of remult.repo(p).query({
|
|
241
|
-
orderBy: { c:
|
|
251
|
+
orderBy: { c: 'asc', id: 'asc' },
|
|
242
252
|
})) {
|
|
243
253
|
i++;
|
|
244
254
|
}
|
|
245
255
|
expect(i).toBe(5);
|
|
246
256
|
}, false);
|
|
247
|
-
testAll(
|
|
257
|
+
testAll('test paging with complex object_2', async ({ remult, createEntity }) => {
|
|
248
258
|
let c1 = await (await createEntity(c)).create({ id: 1, name: 'c1' }).save();
|
|
249
259
|
await (await createEntity(p)).create({ id: 1, name: 'p1', c: c1 }).save();
|
|
250
260
|
expect((await remult.repo(p).findFirst({ c: c1 })).id).toBe(1);
|
|
@@ -275,16 +285,16 @@ testAll("test filter doesn't collapse", async ({ createEntity }) => {
|
|
|
275
285
|
expect(await repo.count(f)).toBe(2);
|
|
276
286
|
expect((await repo.find({ where: f })).length).toBe(2);
|
|
277
287
|
});
|
|
278
|
-
testAll(
|
|
288
|
+
testAll('test that it works with inheritance', async ({ createEntity }) => {
|
|
279
289
|
let c = await createEntity(entityForrawFilter1);
|
|
280
290
|
for (let id = 0; id < 5; id++) {
|
|
281
291
|
await c.create({ id }).save();
|
|
282
292
|
}
|
|
283
|
-
expect(await
|
|
284
|
-
expect((await
|
|
285
|
-
expect((await
|
|
293
|
+
expect(await c.count(entityForrawFilter1.oneAndThree())).toBe(2);
|
|
294
|
+
expect((await c.findFirst(entityForrawFilter1.testNumericValue(2))).id).toBe(2);
|
|
295
|
+
expect((await c.findFirst(entityForrawFilter1.testObjectValue({ val: 2 }))).id).toBe(2);
|
|
286
296
|
});
|
|
287
|
-
testAll(
|
|
297
|
+
testAll('put with validations on column fails', async ({ remult, createEntity }) => {
|
|
288
298
|
var s = await createEntity(entityWithValidationsOnColumn);
|
|
289
299
|
let c = s.create();
|
|
290
300
|
c.myId = 1;
|
|
@@ -298,13 +308,13 @@ testAll("put with validations on column fails", async ({ remult, createEntity })
|
|
|
298
308
|
d.ok();
|
|
299
309
|
};
|
|
300
310
|
await api.put(t, 1, {
|
|
301
|
-
name: '1'
|
|
311
|
+
name: '1',
|
|
302
312
|
});
|
|
303
313
|
d.test();
|
|
304
314
|
var x = await s.find({ where: { myId: 1 } });
|
|
305
315
|
expect(x[0].name).toBe('noam');
|
|
306
316
|
});
|
|
307
|
-
testAllDbs(
|
|
317
|
+
testAllDbs('Insert', async ({ createData }) => {
|
|
308
318
|
let forCat = await createData(async (x) => { });
|
|
309
319
|
let rows = await forCat.find();
|
|
310
320
|
expect(rows.length).toBe(0);
|
|
@@ -317,7 +327,7 @@ testAllDbs("Insert", async ({ createData }) => {
|
|
|
317
327
|
expect(rows[0].id).toBe(1);
|
|
318
328
|
expect(rows[0].categoryName).toBe('noam');
|
|
319
329
|
}, false);
|
|
320
|
-
testAllDbs(
|
|
330
|
+
testAllDbs('test delete', async ({ createData }) => {
|
|
321
331
|
let c = await createData(async (insert) => await insert(5, 'noam'));
|
|
322
332
|
let rows = await c.find();
|
|
323
333
|
expect(rows.length).toBe(1);
|
|
@@ -326,24 +336,33 @@ testAllDbs("test delete", async ({ createData }) => {
|
|
|
326
336
|
rows = await c.find();
|
|
327
337
|
expect(rows.length).toBe(0);
|
|
328
338
|
}, false);
|
|
329
|
-
testAllDbs(
|
|
339
|
+
testAllDbs('test filter packer', async ({ insertFourRows }) => {
|
|
330
340
|
let r = await insertFourRows();
|
|
331
341
|
let rows = await r.find();
|
|
332
342
|
expect(rows.length).toBe(4);
|
|
333
343
|
rows = await r.find({
|
|
334
|
-
where: Filter.entityFilterFromJson(r.metadata, entityFilterToJson(r.metadata, { description: 'x' }))
|
|
344
|
+
where: Filter.entityFilterFromJson(r.metadata, entityFilterToJson(r.metadata, { description: 'x' })),
|
|
335
345
|
});
|
|
336
346
|
expect(rows.length).toBe(2);
|
|
337
|
-
rows = await r.find({
|
|
347
|
+
rows = await r.find({
|
|
348
|
+
where: Filter.entityFilterFromJson(r.metadata, entityFilterToJson(r.metadata, { id: 4 })),
|
|
349
|
+
});
|
|
338
350
|
expect(rows.length).toBe(1);
|
|
339
351
|
expect(rows[0].categoryName).toBe('yael');
|
|
340
|
-
rows = await r.find({
|
|
352
|
+
rows = await r.find({
|
|
353
|
+
where: Filter.entityFilterFromJson(r.metadata, entityFilterToJson(r.metadata, {
|
|
354
|
+
description: 'y',
|
|
355
|
+
categoryName: 'yoni',
|
|
356
|
+
})),
|
|
357
|
+
});
|
|
341
358
|
expect(rows.length).toBe(1);
|
|
342
359
|
expect(rows[0].id).toBe(2);
|
|
343
|
-
rows = await r.find({
|
|
360
|
+
rows = await r.find({
|
|
361
|
+
where: Filter.entityFilterFromJson(r.metadata, entityFilterToJson(r.metadata, { id: { $ne: [2, 4] } })),
|
|
362
|
+
});
|
|
344
363
|
expect(rows.length).toBe(2);
|
|
345
364
|
}, false);
|
|
346
|
-
testAll(
|
|
365
|
+
testAll('Test unique Validation,', async ({ createEntity }) => {
|
|
347
366
|
let type = class extends newCategories {
|
|
348
367
|
};
|
|
349
368
|
Entity('categories')(type);
|
|
@@ -353,8 +372,8 @@ testAll("Test unique Validation,", async ({ createEntity }) => {
|
|
|
353
372
|
if (await c.count({ a: en.a }))
|
|
354
373
|
en._.fields.a.error = 'already exists';
|
|
355
374
|
}
|
|
356
|
-
}
|
|
357
|
-
})(type.prototype,
|
|
375
|
+
},
|
|
376
|
+
})(type.prototype, 'a');
|
|
358
377
|
var c = await createEntity(type);
|
|
359
378
|
var cat = c.create();
|
|
360
379
|
cat.a = '12';
|
|
@@ -368,17 +387,17 @@ testAll("Test unique Validation,", async ({ createEntity }) => {
|
|
|
368
387
|
saved = true;
|
|
369
388
|
}
|
|
370
389
|
catch (err) {
|
|
371
|
-
expect(cat._.fields.a.error).toEqual(
|
|
390
|
+
expect(cat._.fields.a.error).toEqual('already exists');
|
|
372
391
|
}
|
|
373
392
|
expect(saved).toBe(false);
|
|
374
393
|
});
|
|
375
|
-
testAll(
|
|
394
|
+
testAll('Test unique Validation 2', async ({ createEntity }) => {
|
|
376
395
|
let type = class extends newCategories {
|
|
377
396
|
};
|
|
378
397
|
Entity('sdfgds')(type);
|
|
379
398
|
Fields.string({
|
|
380
|
-
validate: Validators.unique
|
|
381
|
-
})(type.prototype,
|
|
399
|
+
validate: Validators.unique,
|
|
400
|
+
})(type.prototype, 'a');
|
|
382
401
|
var c = await createEntity(type);
|
|
383
402
|
var cat = c.create();
|
|
384
403
|
cat.a = '12';
|
|
@@ -391,7 +410,7 @@ testAll("Test unique Validation 2", async ({ createEntity }) => {
|
|
|
391
410
|
saved = true;
|
|
392
411
|
}
|
|
393
412
|
catch (err) {
|
|
394
|
-
expect(cat._.fields.a.error).toEqual(
|
|
413
|
+
expect(cat._.fields.a.error).toEqual('already exists');
|
|
395
414
|
}
|
|
396
415
|
expect(saved).toBe(false);
|
|
397
416
|
});
|
|
@@ -408,15 +427,17 @@ __decorate([
|
|
|
408
427
|
testNumbers = __decorate([
|
|
409
428
|
Entity('testNumbers', { allowApiCrud: true })
|
|
410
429
|
], testNumbers);
|
|
411
|
-
testAll(
|
|
412
|
-
let e = await (await createEntity(testNumbers))
|
|
430
|
+
testAll('test that integer and int work', async ({ createEntity }) => {
|
|
431
|
+
let e = await (await createEntity(testNumbers))
|
|
432
|
+
.create({
|
|
413
433
|
id: 1.5,
|
|
414
|
-
a: 1.5
|
|
415
|
-
})
|
|
434
|
+
a: 1.5,
|
|
435
|
+
})
|
|
436
|
+
.save();
|
|
416
437
|
expect(e.id).toBe(2);
|
|
417
438
|
expect(e.a).toBe(1.5);
|
|
418
439
|
});
|
|
419
|
-
testAll(
|
|
440
|
+
testAll('post with logic works and max in entity', async ({ remult, createEntity }) => {
|
|
420
441
|
let c = await createEntity(entityWithValidations);
|
|
421
442
|
var api = new DataApi(c, remult);
|
|
422
443
|
let t = new TestDataApiResponse();
|
|
@@ -431,7 +452,7 @@ testAll("post with logic works and max in entity", async ({ remult, createEntity
|
|
|
431
452
|
expect(entityWithValidations.savingRowCount).toBe(1);
|
|
432
453
|
d.test();
|
|
433
454
|
});
|
|
434
|
-
testAllDbs(
|
|
455
|
+
testAllDbs('get array works with filter in body', async ({ createData, remult }) => {
|
|
435
456
|
let c = await createData(async (i) => {
|
|
436
457
|
await i(1, 'noam', undefined, Status.open);
|
|
437
458
|
await i(2, 'yael', undefined, Status.closed);
|
|
@@ -440,31 +461,31 @@ testAllDbs("get array works with filter in body", async ({ createData, remult })
|
|
|
440
461
|
var api = new DataApi(c, remult);
|
|
441
462
|
let t = new TestDataApiResponse();
|
|
442
463
|
let d = new Done();
|
|
443
|
-
t.success = data => {
|
|
464
|
+
t.success = (data) => {
|
|
444
465
|
expect(data.length).toBe(2);
|
|
445
466
|
expect(data[0].id).toBe(2);
|
|
446
467
|
expect(data[1].id).toBe(3);
|
|
447
468
|
d.ok();
|
|
448
469
|
};
|
|
449
470
|
await api.getArray(t, {
|
|
450
|
-
get: x => {
|
|
471
|
+
get: (x) => {
|
|
451
472
|
return undefined;
|
|
452
|
-
}
|
|
473
|
+
},
|
|
453
474
|
}, {
|
|
454
|
-
|
|
475
|
+
'status.in': '[1, 2]',
|
|
455
476
|
});
|
|
456
477
|
d.test();
|
|
457
478
|
}, false);
|
|
458
|
-
testAllDbs(
|
|
479
|
+
testAllDbs('entity order by works', async ({ createData }) => {
|
|
459
480
|
let type = class extends newCategories {
|
|
460
481
|
};
|
|
461
482
|
Entity('', {
|
|
462
|
-
defaultOrderBy: { categoryName:
|
|
483
|
+
defaultOrderBy: { categoryName: 'asc' },
|
|
463
484
|
})(type);
|
|
464
485
|
let c = await createData(async (insert) => {
|
|
465
486
|
await insert(1, 'noam');
|
|
466
|
-
await insert(2,
|
|
467
|
-
await insert(3,
|
|
487
|
+
await insert(2, 'yoni');
|
|
488
|
+
await insert(3, 'yael');
|
|
468
489
|
}, type);
|
|
469
490
|
var x = await c.find();
|
|
470
491
|
expect(x[0].id).toBe(1);
|
|
@@ -479,7 +500,7 @@ testAllDbs("entity order by works", async ({ createData }) => {
|
|
|
479
500
|
expect(x[1].id).toBe(3);
|
|
480
501
|
expect(x[2].id).toBe(2);
|
|
481
502
|
}, false);
|
|
482
|
-
testAllDbs(
|
|
503
|
+
testAllDbs('put with validation works', async ({ createData, remult }) => {
|
|
483
504
|
let count = 0;
|
|
484
505
|
let type = class extends newCategories {
|
|
485
506
|
};
|
|
@@ -488,7 +509,7 @@ testAllDbs("put with validation works", async ({ createData, remult }) => {
|
|
|
488
509
|
saving: () => {
|
|
489
510
|
if (!testConfiguration.restDbRunningOnServer)
|
|
490
511
|
count++;
|
|
491
|
-
}
|
|
512
|
+
},
|
|
492
513
|
})(type);
|
|
493
514
|
let c = await createData(async (insert) => await insert(1, 'noam'), type);
|
|
494
515
|
var api = new DataApi(c, remult);
|
|
@@ -499,16 +520,16 @@ testAllDbs("put with validation works", async ({ createData, remult }) => {
|
|
|
499
520
|
};
|
|
500
521
|
count = 0;
|
|
501
522
|
await api.put(t, 1, {
|
|
502
|
-
categoryName: 'noam 1'
|
|
523
|
+
categoryName: 'noam 1',
|
|
503
524
|
});
|
|
504
525
|
d.test();
|
|
505
526
|
var x = await c.find({
|
|
506
|
-
where: { id: 1 }
|
|
527
|
+
where: { id: 1 },
|
|
507
528
|
});
|
|
508
529
|
expect(x[0].categoryName).toBe('noam 1');
|
|
509
530
|
expect(count).toBe(1);
|
|
510
531
|
});
|
|
511
|
-
testAll(
|
|
532
|
+
testAll('saves correctly to db', async ({ createEntity }) => {
|
|
512
533
|
let type = class extends EntityBase {
|
|
513
534
|
constructor() {
|
|
514
535
|
super(...arguments);
|
|
@@ -517,7 +538,7 @@ testAll("saves correctly to db", async ({ createEntity }) => {
|
|
|
517
538
|
};
|
|
518
539
|
Entity('asdf', { allowApiCrud: true })(type);
|
|
519
540
|
Fields.number()(type.prototype, 'id');
|
|
520
|
-
Fields.boolean()(type.prototype,
|
|
541
|
+
Fields.boolean()(type.prototype, 'ok');
|
|
521
542
|
let r = (await createEntity(type)).create();
|
|
522
543
|
r.id = 1;
|
|
523
544
|
r.ok = true;
|
|
@@ -538,7 +559,7 @@ __decorate([
|
|
|
538
559
|
__metadata("design:type", Number)
|
|
539
560
|
], autoIncrement.prototype, "stam", void 0);
|
|
540
561
|
autoIncrement = __decorate([
|
|
541
|
-
Entity(
|
|
562
|
+
Entity('autoi', { allowApiCrud: true })
|
|
542
563
|
], autoIncrement);
|
|
543
564
|
testAll("auto increment can't be affected by insert or update", async ({ createEntity }) => {
|
|
544
565
|
let repo = await createEntity(autoIncrement);
|
|
@@ -549,24 +570,58 @@ testAll("auto increment can't be affected by insert or update", async ({ createE
|
|
|
549
570
|
await r.save();
|
|
550
571
|
expect(r.id).toBe(x);
|
|
551
572
|
}, false);
|
|
552
|
-
testAll(
|
|
573
|
+
testAll('Paging', async ({ createEntity }) => {
|
|
553
574
|
let s = await entityWithValidations.create4RowsInDp(createEntity);
|
|
554
|
-
expect((await s.find({ limit: 3, orderBy: { myId:
|
|
555
|
-
expect((await s.find({ limit: 3, orderBy: { myId:
|
|
575
|
+
expect((await s.find({ limit: 3, orderBy: { myId: 'asc' } })).length).toBe(3);
|
|
576
|
+
expect((await s.find({ limit: 3, orderBy: { myId: 'asc' }, page: 2 })).length).toBe(1);
|
|
556
577
|
}, false);
|
|
557
|
-
testAll(
|
|
578
|
+
testAll('filter', async ({ createEntity }) => {
|
|
558
579
|
const s = await createEntity(testFilter);
|
|
559
580
|
await s.insert({ id: 1, a: 'a', b: 'b', c: 'c' });
|
|
560
581
|
expect(await s.count({
|
|
561
582
|
a: 'z',
|
|
562
|
-
$and: [testFilter.search('')]
|
|
583
|
+
$and: [testFilter.search('')],
|
|
563
584
|
})).toBe(0);
|
|
564
585
|
}, false);
|
|
565
|
-
testAll(
|
|
586
|
+
testAll('filter 2_1', async ({ createEntity }) => {
|
|
587
|
+
const s = await createEntity(testFilter);
|
|
588
|
+
await s.insert({ id: 1, a: 'a', b: 'b', c: 'c' });
|
|
589
|
+
expect(await s.count({
|
|
590
|
+
$and: [{ a: { '!=': 'b' } }, { a: { '!=': 'c' } }],
|
|
591
|
+
})).toBe(1);
|
|
592
|
+
}, false);
|
|
593
|
+
testAll('filter 2', async ({ createEntity }) => {
|
|
594
|
+
const s = await createEntity(testFilter);
|
|
595
|
+
await s.insert({ id: 1, a: 'a', b: 'b', c: 'c' });
|
|
596
|
+
expect(await s.count({
|
|
597
|
+
$and: [testFilter.differentFrom('b'), testFilter.differentFrom('c')],
|
|
598
|
+
})).toBe(1);
|
|
599
|
+
}, false);
|
|
600
|
+
testAll('filter 3', async ({ createEntity }) => {
|
|
601
|
+
const s = await createEntity(testFilter);
|
|
602
|
+
await s.insert({ id: 1, a: 'a', b: 'b', c: 'c' });
|
|
603
|
+
expect(await s.count({
|
|
604
|
+
$and: [
|
|
605
|
+
testFilter.differentFromArray(['x', 'b']),
|
|
606
|
+
testFilter.differentFromArray(['y', 'c']),
|
|
607
|
+
],
|
|
608
|
+
})).toBe(1);
|
|
609
|
+
}, false);
|
|
610
|
+
testAll('filter 4', async ({ createEntity }) => {
|
|
611
|
+
const s = await createEntity(testFilter);
|
|
612
|
+
await s.insert({ id: 1, a: 'a', b: 'b', c: 'c' });
|
|
613
|
+
expect(await s.count({
|
|
614
|
+
$and: [
|
|
615
|
+
testFilter.differentFromObj({ str: 'b' }),
|
|
616
|
+
testFilter.differentFromObj({ str: 'c' }),
|
|
617
|
+
],
|
|
618
|
+
})).toBe(1);
|
|
619
|
+
}, false);
|
|
620
|
+
testAll('large string field', async ({ createEntity }) => {
|
|
566
621
|
const s = await createEntity(stam);
|
|
567
|
-
await s.insert({ title:
|
|
622
|
+
await s.insert({ title: '1234567890'.repeat(100) });
|
|
568
623
|
const r = await s.findFirst();
|
|
569
|
-
expect(r.title).toBe(
|
|
624
|
+
expect(r.title).toBe('1234567890'.repeat(100));
|
|
570
625
|
}, false);
|
|
571
626
|
let testFilter = class testFilter {
|
|
572
627
|
constructor() {
|
|
@@ -577,14 +632,27 @@ let testFilter = class testFilter {
|
|
|
577
632
|
}
|
|
578
633
|
};
|
|
579
634
|
testFilter.search = Filter.createCustom((str, remult) => ({
|
|
580
|
-
$and: [
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
]
|
|
586
|
-
}]
|
|
635
|
+
$and: [
|
|
636
|
+
{
|
|
637
|
+
$or: [{ a: 'a' }, { b: 'a' }, { c: 'a' }],
|
|
638
|
+
},
|
|
639
|
+
],
|
|
587
640
|
}));
|
|
641
|
+
testFilter.differentFrom = Filter.createCustom((str) => {
|
|
642
|
+
return {
|
|
643
|
+
a: { '!=': str },
|
|
644
|
+
};
|
|
645
|
+
});
|
|
646
|
+
testFilter.differentFromObj = Filter.createCustom(({ str }) => {
|
|
647
|
+
return {
|
|
648
|
+
a: { '!=': str },
|
|
649
|
+
};
|
|
650
|
+
});
|
|
651
|
+
testFilter.differentFromArray = Filter.createCustom((str) => {
|
|
652
|
+
return {
|
|
653
|
+
a: { '!=': str },
|
|
654
|
+
};
|
|
655
|
+
});
|
|
588
656
|
__decorate([
|
|
589
657
|
Fields.integer(),
|
|
590
658
|
__metadata("design:type", Number)
|
|
@@ -602,7 +670,7 @@ __decorate([
|
|
|
602
670
|
__metadata("design:type", String)
|
|
603
671
|
], testFilter.prototype, "c", void 0);
|
|
604
672
|
testFilter = __decorate([
|
|
605
|
-
Entity(
|
|
673
|
+
Entity('testfilter', { allowApiCrud: true })
|
|
606
674
|
], testFilter);
|
|
607
675
|
let testStringWithNull = class testStringWithNull extends EntityBase {
|
|
608
676
|
constructor() {
|
|
@@ -637,7 +705,7 @@ __decorate([
|
|
|
637
705
|
__metadata("design:type", String)
|
|
638
706
|
], stam.prototype, "title", void 0);
|
|
639
707
|
stam = __decorate([
|
|
640
|
-
Entity(
|
|
708
|
+
Entity('a', { allowApiCrud: true })
|
|
641
709
|
], stam);
|
|
642
710
|
export { stam };
|
|
643
711
|
let p = class p extends EntityBase {
|
|
@@ -684,7 +752,7 @@ __decorate([
|
|
|
684
752
|
], tasksWithEnum.prototype, "priority", void 0);
|
|
685
753
|
tasksWithEnum = __decorate([
|
|
686
754
|
Entity('tasksWithEnum', {
|
|
687
|
-
allowApiCrud: true
|
|
755
|
+
allowApiCrud: true,
|
|
688
756
|
})
|
|
689
757
|
], tasksWithEnum);
|
|
690
758
|
export { tasksWithEnum };
|
|
@@ -694,11 +762,11 @@ export var Priority;
|
|
|
694
762
|
Priority[Priority["High"] = 1] = "High";
|
|
695
763
|
Priority[Priority["Critical"] = 2] = "Critical";
|
|
696
764
|
})(Priority || (Priority = {}));
|
|
697
|
-
testAll(
|
|
765
|
+
testAll('task with enum', async ({ createEntity }) => {
|
|
698
766
|
const r = await createEntity(tasksWithEnum);
|
|
699
767
|
await r.insert({
|
|
700
768
|
title: 'a',
|
|
701
|
-
priority: Priority.Critical
|
|
769
|
+
priority: Priority.Critical,
|
|
702
770
|
});
|
|
703
771
|
const item = await r.findFirst();
|
|
704
772
|
expect(item.priority).toBe(Priority.Critical);
|
|
@@ -727,7 +795,7 @@ __decorate([
|
|
|
727
795
|
], tasksWithStringEnum.prototype, "priority", void 0);
|
|
728
796
|
tasksWithStringEnum = __decorate([
|
|
729
797
|
Entity('tasksWithStringEnum', {
|
|
730
|
-
allowApiCrud: true
|
|
798
|
+
allowApiCrud: true,
|
|
731
799
|
})
|
|
732
800
|
], tasksWithStringEnum);
|
|
733
801
|
export { tasksWithStringEnum };
|
|
@@ -737,88 +805,87 @@ export var PriorityWithString;
|
|
|
737
805
|
PriorityWithString["High"] = "High";
|
|
738
806
|
PriorityWithString["Critical"] = "Critical";
|
|
739
807
|
})(PriorityWithString || (PriorityWithString = {}));
|
|
740
|
-
testAll(
|
|
808
|
+
testAll('task with enum string', async ({ createEntity }) => {
|
|
741
809
|
const r = await createEntity(tasksWithStringEnum);
|
|
742
810
|
await r.insert({
|
|
743
811
|
title: 'a',
|
|
744
|
-
priority: PriorityWithString.Critical
|
|
812
|
+
priority: PriorityWithString.Critical,
|
|
745
813
|
});
|
|
746
814
|
const item = await r.findFirst();
|
|
747
815
|
expect(item.priority).toBe(PriorityWithString.Critical);
|
|
748
816
|
expect(await r.count({ priority: PriorityWithString.Critical })).toBe(1);
|
|
749
817
|
expect(await r.count({ priority: PriorityWithString.Low })).toBe(0);
|
|
750
818
|
});
|
|
751
|
-
testAll(
|
|
819
|
+
testAll('test transaction rollback', async ({ db, createEntity }) => {
|
|
752
820
|
let fail = true;
|
|
753
821
|
const r = await createEntity(stam);
|
|
754
|
-
await r.insert({ title:
|
|
822
|
+
await r.insert({ title: 'task b', id: 1 });
|
|
755
823
|
try {
|
|
756
824
|
await db.transaction(async (db) => {
|
|
757
825
|
var remultWithTransaction = new Remult(db).repo(stam);
|
|
758
|
-
await remultWithTransaction.insert({ title:
|
|
826
|
+
await remultWithTransaction.insert({ title: 'task a', id: 2 });
|
|
759
827
|
expect(await remultWithTransaction.count()).toBe(2);
|
|
760
|
-
throw
|
|
828
|
+
throw 'error';
|
|
761
829
|
});
|
|
762
830
|
fail = false;
|
|
763
831
|
}
|
|
764
|
-
catch {
|
|
765
|
-
}
|
|
832
|
+
catch { }
|
|
766
833
|
expect(await r.count()).toBe(1);
|
|
767
834
|
expect(fail).toBe(true);
|
|
768
835
|
}, false, { exclude: [TestDbs.inMemory] });
|
|
769
|
-
testAll(
|
|
836
|
+
testAll('test date', async ({ createEntity }) => {
|
|
770
837
|
const e = class {
|
|
771
838
|
constructor() {
|
|
772
839
|
this.a = 0;
|
|
773
840
|
this.d = new Date();
|
|
774
841
|
}
|
|
775
842
|
};
|
|
776
|
-
describeClass(e, Entity(
|
|
843
|
+
describeClass(e, Entity('tdate', { allowApiCrud: true }), {
|
|
777
844
|
a: Fields.number(),
|
|
778
|
-
d: Fields.date()
|
|
845
|
+
d: Fields.date(),
|
|
779
846
|
});
|
|
780
847
|
const r = await createEntity(e);
|
|
781
848
|
await r.insert({ a: 1, d: new Date(1976, 5, 16) });
|
|
782
849
|
let item = await r.findFirst();
|
|
783
850
|
expect(item.d.getFullYear()).toBe(1976);
|
|
784
851
|
}, false);
|
|
785
|
-
testAll(
|
|
852
|
+
testAll('test live query storage', async ({ db, remult, createEntity }) => {
|
|
786
853
|
await createEntity(LiveQueryStorageEntity);
|
|
787
854
|
var x = new DataProviderLiveQueryStorage(db);
|
|
788
855
|
if (db.ensureSchema)
|
|
789
856
|
await x.ensureSchema();
|
|
790
857
|
const id = uuid();
|
|
791
|
-
await x.add({ id, entityKey: 'x', data:
|
|
792
|
-
await x.forEach(
|
|
793
|
-
expect(args.query.data).toBe(
|
|
858
|
+
await x.add({ id, entityKey: 'x', data: 'noam' });
|
|
859
|
+
await x.forEach('x', async (args) => {
|
|
860
|
+
expect(args.query.data).toBe('noam');
|
|
794
861
|
});
|
|
795
|
-
expect(
|
|
862
|
+
expect(await x.keepAliveAndReturnUnknownQueryIds([id])).toEqual([]);
|
|
796
863
|
}, false, {
|
|
797
|
-
exclude: [TestDbs.restDataProvider]
|
|
864
|
+
exclude: [TestDbs.restDataProvider],
|
|
798
865
|
});
|
|
799
|
-
testAll(
|
|
866
|
+
testAll('test contains with names with casing', async ({ createEntity }) => {
|
|
800
867
|
const e = class {
|
|
801
868
|
constructor() {
|
|
802
869
|
this.a = 0;
|
|
803
870
|
this.firstName = '';
|
|
804
871
|
}
|
|
805
872
|
};
|
|
806
|
-
describeClass(e, Entity(
|
|
873
|
+
describeClass(e, Entity('testNameContains', { allowApiCrud: true }), {
|
|
807
874
|
a: Fields.number(),
|
|
808
|
-
firstName: Fields.string()
|
|
875
|
+
firstName: Fields.string(),
|
|
809
876
|
});
|
|
810
877
|
const r = await createEntity(e);
|
|
811
|
-
await r.insert({ a: 1, firstName:
|
|
812
|
-
let item = await r.findFirst({ firstName: { $contains:
|
|
813
|
-
expect(item.firstName).toBe(
|
|
878
|
+
await r.insert({ a: 1, firstName: 'noam' });
|
|
879
|
+
let item = await r.findFirst({ firstName: { $contains: 'oa' } });
|
|
880
|
+
expect(item.firstName).toBe('noam');
|
|
814
881
|
}, false, {
|
|
815
|
-
exclude: [TestDbs.mongo]
|
|
882
|
+
exclude: [TestDbs.mongo],
|
|
816
883
|
});
|
|
817
|
-
testAll(
|
|
884
|
+
testAll('test live query storage', async (x) => {
|
|
818
885
|
await x.createEntity(LiveQueryStorageEntity);
|
|
819
886
|
const s = new DataProviderLiveQueryStorage(x.db);
|
|
820
887
|
await s.ensureSchema();
|
|
821
|
-
const entityKey =
|
|
888
|
+
const entityKey = 'ek';
|
|
822
889
|
const id = 'id';
|
|
823
890
|
await s.add({ id, entityKey, data: {} });
|
|
824
891
|
await s.add({ id, entityKey, data: {} });
|
|
@@ -828,25 +895,25 @@ testAll("test live query storage", async (x) => {
|
|
|
828
895
|
await s.remove(id);
|
|
829
896
|
await s.remove(id);
|
|
830
897
|
}, false, { exclude: [TestDbs.restDataProvider] });
|
|
831
|
-
testAll(
|
|
898
|
+
testAll('test json structure using object', async ({ createEntity }) => {
|
|
832
899
|
const e = class {
|
|
833
900
|
constructor() {
|
|
834
901
|
this.a = 0;
|
|
835
902
|
}
|
|
836
903
|
};
|
|
837
|
-
describeClass(e, Entity(
|
|
904
|
+
describeClass(e, Entity('testJsonStructure', { allowApiCrud: true }), {
|
|
838
905
|
a: Fields.number(),
|
|
839
|
-
person: Fields.object()
|
|
906
|
+
person: Fields.object(),
|
|
840
907
|
});
|
|
841
908
|
const r = await createEntity(e);
|
|
842
|
-
await r.insert({ a: 1, person: { firstName:
|
|
909
|
+
await r.insert({ a: 1, person: { firstName: 'noam', lastName: 'honig' } });
|
|
843
910
|
let item = await r.findFirst();
|
|
844
|
-
expect(item.person).toEqual({ firstName:
|
|
911
|
+
expect(item.person).toEqual({ firstName: 'noam', lastName: 'honig' });
|
|
845
912
|
}, false);
|
|
846
913
|
let testObject = class testObject {
|
|
847
914
|
constructor() {
|
|
848
915
|
this.id = 0;
|
|
849
|
-
this.person = { firstName:
|
|
916
|
+
this.person = { firstName: 'noam', lastName: 'honig' };
|
|
850
917
|
}
|
|
851
918
|
};
|
|
852
919
|
__decorate([
|
|
@@ -858,18 +925,18 @@ __decorate([
|
|
|
858
925
|
__metadata("design:type", Object)
|
|
859
926
|
], testObject.prototype, "person", void 0);
|
|
860
927
|
testObject = __decorate([
|
|
861
|
-
Entity(
|
|
928
|
+
Entity('testObject', { allowApiCrud: true })
|
|
862
929
|
], testObject);
|
|
863
|
-
testAll(
|
|
930
|
+
testAll('test object entity', async ({ createEntity }) => {
|
|
864
931
|
const r = await createEntity(testObject);
|
|
865
|
-
await r.insert({ id: 1, person: { firstName:
|
|
932
|
+
await r.insert({ id: 1, person: { firstName: 'noam', lastName: 'honig' } });
|
|
866
933
|
let item = await r.findFirst();
|
|
867
|
-
expect(item.person).toEqual({ firstName:
|
|
934
|
+
expect(item.person).toEqual({ firstName: 'noam', lastName: 'honig' });
|
|
868
935
|
}, false);
|
|
869
936
|
let testObjectJson = class testObjectJson {
|
|
870
937
|
constructor() {
|
|
871
938
|
this.id = 0;
|
|
872
|
-
this.person = { firstName:
|
|
939
|
+
this.person = { firstName: 'noam', lastName: 'honig' };
|
|
873
940
|
}
|
|
874
941
|
};
|
|
875
942
|
__decorate([
|
|
@@ -881,62 +948,97 @@ __decorate([
|
|
|
881
948
|
__metadata("design:type", Object)
|
|
882
949
|
], testObjectJson.prototype, "person", void 0);
|
|
883
950
|
testObjectJson = __decorate([
|
|
884
|
-
Entity(
|
|
951
|
+
Entity('testObjectJson', { allowApiCrud: true })
|
|
885
952
|
], testObjectJson);
|
|
886
|
-
testAll(
|
|
953
|
+
testAll('test object entity', async ({ createEntity }) => {
|
|
887
954
|
const r = await createEntity(testObjectJson);
|
|
888
|
-
await r.insert({ id: 1, person: { firstName:
|
|
955
|
+
await r.insert({ id: 1, person: { firstName: 'noam', lastName: 'honig' } });
|
|
889
956
|
let item = await r.findFirst();
|
|
890
|
-
expect(item.person).toEqual({ firstName:
|
|
957
|
+
expect(item.person).toEqual({ firstName: 'noam', lastName: 'honig' });
|
|
891
958
|
}, false);
|
|
892
|
-
testAll(
|
|
959
|
+
testAll('test json structure', async ({ createEntity }) => {
|
|
893
960
|
const e = class {
|
|
894
961
|
constructor() {
|
|
895
962
|
this.a = 0;
|
|
896
963
|
}
|
|
897
964
|
};
|
|
898
|
-
describeClass(e, Entity(
|
|
965
|
+
describeClass(e, Entity('testJsonFieldType', { allowApiCrud: true }), {
|
|
899
966
|
a: Fields.number(),
|
|
900
|
-
person: Fields.json()
|
|
967
|
+
person: Fields.json(),
|
|
901
968
|
});
|
|
902
969
|
const r = await createEntity(e);
|
|
903
|
-
await r.insert({ a: 1, person: { firstName:
|
|
970
|
+
await r.insert({ a: 1, person: { firstName: 'noam', lastName: 'honig' } });
|
|
904
971
|
let item = await r.findFirst();
|
|
905
|
-
expect(item.person).toEqual({ firstName:
|
|
972
|
+
expect(item.person).toEqual({ firstName: 'noam', lastName: 'honig' });
|
|
906
973
|
}, false);
|
|
907
|
-
testAll(
|
|
974
|
+
testAll('test json structure 2', async ({ createEntity }) => {
|
|
908
975
|
const e = class {
|
|
909
976
|
constructor() {
|
|
910
977
|
this.a = 0;
|
|
911
978
|
this.items = [];
|
|
912
979
|
}
|
|
913
980
|
};
|
|
914
|
-
describeClass(e, Entity(
|
|
981
|
+
describeClass(e, Entity('testJsonFieldType2', { allowApiCrud: true }), {
|
|
915
982
|
a: Fields.number(),
|
|
916
|
-
items: Fields.json()
|
|
983
|
+
items: Fields.json(),
|
|
917
984
|
});
|
|
918
985
|
const r = await createEntity(e);
|
|
919
|
-
await r.insert({ a: 1, items: [
|
|
986
|
+
await r.insert({ a: 1, items: ['a', 'b'] });
|
|
920
987
|
let item = await r.findFirst();
|
|
921
|
-
expect(item.items).toEqual([
|
|
988
|
+
expect(item.items).toEqual(['a', 'b']);
|
|
922
989
|
//expect(await r.count({ items: { $contains: "b" } })).toBe(1)
|
|
923
|
-
}, false
|
|
924
|
-
testAll(
|
|
990
|
+
}, false);
|
|
991
|
+
testAll('test json structure 3', async ({ createEntity }) => {
|
|
925
992
|
const e = class {
|
|
926
993
|
constructor() {
|
|
927
994
|
this.a = 0;
|
|
928
995
|
this.items = [];
|
|
929
996
|
}
|
|
930
997
|
};
|
|
931
|
-
describeClass(e, Entity(
|
|
998
|
+
describeClass(e, Entity('testJsonFieldType3', { allowApiCrud: true }), {
|
|
932
999
|
a: Fields.number(),
|
|
933
|
-
items: Fields.object()
|
|
1000
|
+
items: Fields.object(),
|
|
934
1001
|
});
|
|
935
1002
|
const r = await createEntity(e);
|
|
936
|
-
await r.insert({ a: 1, items: [
|
|
1003
|
+
await r.insert({ a: 1, items: ['a', 'b'] });
|
|
937
1004
|
let item = await r.findFirst();
|
|
938
|
-
expect(item.items).toEqual([
|
|
939
|
-
expect(await r.count({ items: { $contains:
|
|
1005
|
+
expect(item.items).toEqual(['a', 'b']);
|
|
1006
|
+
expect(await r.count({ items: { $contains: 'b' } })).toBe(1);
|
|
940
1007
|
}, false, {
|
|
941
|
-
exclude: [TestDbs.mongo]
|
|
1008
|
+
exclude: [TestDbs.mongo],
|
|
942
1009
|
});
|
|
1010
|
+
testAll('test relation to number id', async ({ createEntity }) => {
|
|
1011
|
+
const category = class {
|
|
1012
|
+
constructor() {
|
|
1013
|
+
this.id = 0;
|
|
1014
|
+
this.name = '';
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
describeClass(category, Entity('rel_ID_categories', { allowApiCrud: true }), {
|
|
1018
|
+
id: Fields.autoIncrement(),
|
|
1019
|
+
name: Fields.string(),
|
|
1020
|
+
});
|
|
1021
|
+
const task = class {
|
|
1022
|
+
constructor() {
|
|
1023
|
+
this.id = 0;
|
|
1024
|
+
this.title = '';
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
describeClass(task, Entity('rel_ID_task', { allowApiCrud: true }), {
|
|
1028
|
+
id: Fields.autoIncrement(),
|
|
1029
|
+
title: Fields.string(),
|
|
1030
|
+
category: Field(() => category),
|
|
1031
|
+
});
|
|
1032
|
+
const catRepo = await createEntity(category);
|
|
1033
|
+
const taskRepo = await createEntity(task);
|
|
1034
|
+
const cat = await catRepo.insert([{ name: 'cat0' }, { name: 'cat1' }]);
|
|
1035
|
+
await taskRepo.insert([
|
|
1036
|
+
{ title: 't1', category: cat[0] },
|
|
1037
|
+
{ title: 't2', category: cat[0] },
|
|
1038
|
+
{ title: 't3', category: cat[1] },
|
|
1039
|
+
]);
|
|
1040
|
+
expect(taskRepo.fields.category.valueConverter.fieldTypeInDb).toBe(ValueConverters.Integer.fieldTypeInDb);
|
|
1041
|
+
expect(await taskRepo.count({ category: cat[0] })).toBe(2);
|
|
1042
|
+
expect(await taskRepo.count({ category: cat[1] })).toBe(1);
|
|
1043
|
+
expect(await taskRepo.count({ category: { $id: cat[0].id } })).toBe(2);
|
|
1044
|
+
}, false, { exclude: [TestDbs.mongo] });
|