remult 0.21.1 → 0.22.1
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 +53 -39
- 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 +3 -2
- package/esm/src/backend-tests/backend-database-test-setup.backend-spec.js +121 -66
- 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 +10 -8
- package/esm/src/shared-tests/db-tests-setup.js +12 -10
- package/esm/src/shared-tests/db-tests.db-tests.d.ts +1 -1
- package/esm/src/shared-tests/db-tests.db-tests.js +319 -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 +15 -15
- 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 +51 -35
- 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 +3 -2
- package/src/backend-tests/backend-database-test-setup.backend-spec.js +214 -127
- 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 +10 -8
- package/src/shared-tests/db-tests-setup.js +8 -6
- package/src/shared-tests/db-tests.db-tests.d.ts +1 -1
- package/src/shared-tests/db-tests.db-tests.js +455 -165
- 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 +9 -9
- 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, 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,127 @@ 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 {
|
|
832
|
+
catch (err) {
|
|
833
|
+
expect(err).toBe('error');
|
|
765
834
|
}
|
|
766
835
|
expect(await r.count()).toBe(1);
|
|
767
836
|
expect(fail).toBe(true);
|
|
768
|
-
}, false, {
|
|
769
|
-
|
|
837
|
+
}, false, {
|
|
838
|
+
exclude: [
|
|
839
|
+
TestDbs.inMemory,
|
|
840
|
+
TestDbs.mongoNoTrans,
|
|
841
|
+
TestDbs.restDataProvider,
|
|
842
|
+
TestDbs.webSql,
|
|
843
|
+
],
|
|
844
|
+
});
|
|
845
|
+
testAll('transactions', async ({ db, createEntity }) => {
|
|
846
|
+
let x = await createEntity(Categories);
|
|
847
|
+
await db.transaction(async (db) => {
|
|
848
|
+
let remult = new Remult(db);
|
|
849
|
+
expect(await remult.repo(Categories).count()).toBe(0);
|
|
850
|
+
});
|
|
851
|
+
}, false, {
|
|
852
|
+
exclude: [TestDbs.mongoNoTrans, TestDbs.restDataProvider, TestDbs.webSql],
|
|
853
|
+
});
|
|
854
|
+
testAll('transactions 1', async ({ db, createEntity }) => {
|
|
855
|
+
let x = await createEntity(Categories);
|
|
856
|
+
try {
|
|
857
|
+
await db.transaction(async (db) => {
|
|
858
|
+
let remult = new Remult(db);
|
|
859
|
+
await remult.repo(Categories).insert({ categoryName: 'testing' });
|
|
860
|
+
expect(await remult.repo(Categories).count()).toBe(1);
|
|
861
|
+
throw 'Fail';
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
catch (err) {
|
|
865
|
+
expect(err).toBe('Fail');
|
|
866
|
+
}
|
|
867
|
+
expect(await x.count()).toBe(0);
|
|
868
|
+
}, false, {
|
|
869
|
+
exclude: [
|
|
870
|
+
TestDbs.inMemory,
|
|
871
|
+
TestDbs.mongoNoTrans,
|
|
872
|
+
TestDbs.restDataProvider,
|
|
873
|
+
TestDbs.webSql,
|
|
874
|
+
],
|
|
875
|
+
});
|
|
876
|
+
testAll('test date', async ({ createEntity }) => {
|
|
770
877
|
const e = class {
|
|
771
878
|
constructor() {
|
|
772
879
|
this.a = 0;
|
|
773
880
|
this.d = new Date();
|
|
774
881
|
}
|
|
775
882
|
};
|
|
776
|
-
describeClass(e, Entity(
|
|
883
|
+
describeClass(e, Entity('tdate', { allowApiCrud: true }), {
|
|
777
884
|
a: Fields.number(),
|
|
778
|
-
d: Fields.date()
|
|
885
|
+
d: Fields.date(),
|
|
779
886
|
});
|
|
780
887
|
const r = await createEntity(e);
|
|
781
888
|
await r.insert({ a: 1, d: new Date(1976, 5, 16) });
|
|
782
889
|
let item = await r.findFirst();
|
|
783
890
|
expect(item.d.getFullYear()).toBe(1976);
|
|
784
891
|
}, false);
|
|
785
|
-
testAll(
|
|
892
|
+
testAll('test live query storage', async ({ db, remult, createEntity }) => {
|
|
786
893
|
await createEntity(LiveQueryStorageEntity);
|
|
787
894
|
var x = new DataProviderLiveQueryStorage(db);
|
|
788
895
|
if (db.ensureSchema)
|
|
789
896
|
await x.ensureSchema();
|
|
790
897
|
const id = uuid();
|
|
791
|
-
await x.add({ id, entityKey: 'x', data:
|
|
792
|
-
await x.forEach(
|
|
793
|
-
expect(args.query.data).toBe(
|
|
898
|
+
await x.add({ id, entityKey: 'x', data: 'noam' });
|
|
899
|
+
await x.forEach('x', async (args) => {
|
|
900
|
+
expect(args.query.data).toBe('noam');
|
|
794
901
|
});
|
|
795
|
-
expect(
|
|
902
|
+
expect(await x.keepAliveAndReturnUnknownQueryIds([id])).toEqual([]);
|
|
796
903
|
}, false, {
|
|
797
|
-
exclude: [TestDbs.restDataProvider]
|
|
904
|
+
exclude: [TestDbs.restDataProvider],
|
|
798
905
|
});
|
|
799
|
-
testAll(
|
|
906
|
+
testAll('test contains with names with casing', async ({ createEntity }) => {
|
|
800
907
|
const e = class {
|
|
801
908
|
constructor() {
|
|
802
909
|
this.a = 0;
|
|
803
910
|
this.firstName = '';
|
|
804
911
|
}
|
|
805
912
|
};
|
|
806
|
-
describeClass(e, Entity(
|
|
913
|
+
describeClass(e, Entity('testNameContains', { allowApiCrud: true }), {
|
|
807
914
|
a: Fields.number(),
|
|
808
|
-
firstName: Fields.string()
|
|
915
|
+
firstName: Fields.string(),
|
|
809
916
|
});
|
|
810
917
|
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(
|
|
918
|
+
await r.insert({ a: 1, firstName: 'noam' });
|
|
919
|
+
let item = await r.findFirst({ firstName: { $contains: 'oa' } });
|
|
920
|
+
expect(item.firstName).toBe('noam');
|
|
814
921
|
}, false, {
|
|
815
|
-
exclude: [TestDbs.mongo]
|
|
922
|
+
exclude: [TestDbs.mongo, TestDbs.mongoNoTrans],
|
|
816
923
|
});
|
|
817
|
-
testAll(
|
|
924
|
+
testAll('test live query storage', async (x) => {
|
|
818
925
|
await x.createEntity(LiveQueryStorageEntity);
|
|
819
926
|
const s = new DataProviderLiveQueryStorage(x.db);
|
|
820
927
|
await s.ensureSchema();
|
|
821
|
-
const entityKey =
|
|
928
|
+
const entityKey = 'ek';
|
|
822
929
|
const id = 'id';
|
|
823
930
|
await s.add({ id, entityKey, data: {} });
|
|
824
931
|
await s.add({ id, entityKey, data: {} });
|
|
@@ -828,25 +935,25 @@ testAll("test live query storage", async (x) => {
|
|
|
828
935
|
await s.remove(id);
|
|
829
936
|
await s.remove(id);
|
|
830
937
|
}, false, { exclude: [TestDbs.restDataProvider] });
|
|
831
|
-
testAll(
|
|
938
|
+
testAll('test json structure using object', async ({ createEntity }) => {
|
|
832
939
|
const e = class {
|
|
833
940
|
constructor() {
|
|
834
941
|
this.a = 0;
|
|
835
942
|
}
|
|
836
943
|
};
|
|
837
|
-
describeClass(e, Entity(
|
|
944
|
+
describeClass(e, Entity('testJsonStructure', { allowApiCrud: true }), {
|
|
838
945
|
a: Fields.number(),
|
|
839
|
-
person: Fields.object()
|
|
946
|
+
person: Fields.object(),
|
|
840
947
|
});
|
|
841
948
|
const r = await createEntity(e);
|
|
842
|
-
await r.insert({ a: 1, person: { firstName:
|
|
949
|
+
await r.insert({ a: 1, person: { firstName: 'noam', lastName: 'honig' } });
|
|
843
950
|
let item = await r.findFirst();
|
|
844
|
-
expect(item.person).toEqual({ firstName:
|
|
951
|
+
expect(item.person).toEqual({ firstName: 'noam', lastName: 'honig' });
|
|
845
952
|
}, false);
|
|
846
953
|
let testObject = class testObject {
|
|
847
954
|
constructor() {
|
|
848
955
|
this.id = 0;
|
|
849
|
-
this.person = { firstName:
|
|
956
|
+
this.person = { firstName: 'noam', lastName: 'honig' };
|
|
850
957
|
}
|
|
851
958
|
};
|
|
852
959
|
__decorate([
|
|
@@ -858,18 +965,18 @@ __decorate([
|
|
|
858
965
|
__metadata("design:type", Object)
|
|
859
966
|
], testObject.prototype, "person", void 0);
|
|
860
967
|
testObject = __decorate([
|
|
861
|
-
Entity(
|
|
968
|
+
Entity('testObject', { allowApiCrud: true })
|
|
862
969
|
], testObject);
|
|
863
|
-
testAll(
|
|
970
|
+
testAll('test object entity', async ({ createEntity }) => {
|
|
864
971
|
const r = await createEntity(testObject);
|
|
865
|
-
await r.insert({ id: 1, person: { firstName:
|
|
972
|
+
await r.insert({ id: 1, person: { firstName: 'noam', lastName: 'honig' } });
|
|
866
973
|
let item = await r.findFirst();
|
|
867
|
-
expect(item.person).toEqual({ firstName:
|
|
974
|
+
expect(item.person).toEqual({ firstName: 'noam', lastName: 'honig' });
|
|
868
975
|
}, false);
|
|
869
976
|
let testObjectJson = class testObjectJson {
|
|
870
977
|
constructor() {
|
|
871
978
|
this.id = 0;
|
|
872
|
-
this.person = { firstName:
|
|
979
|
+
this.person = { firstName: 'noam', lastName: 'honig' };
|
|
873
980
|
}
|
|
874
981
|
};
|
|
875
982
|
__decorate([
|
|
@@ -881,62 +988,97 @@ __decorate([
|
|
|
881
988
|
__metadata("design:type", Object)
|
|
882
989
|
], testObjectJson.prototype, "person", void 0);
|
|
883
990
|
testObjectJson = __decorate([
|
|
884
|
-
Entity(
|
|
991
|
+
Entity('testObjectJson', { allowApiCrud: true })
|
|
885
992
|
], testObjectJson);
|
|
886
|
-
testAll(
|
|
993
|
+
testAll('test object entity', async ({ createEntity }) => {
|
|
887
994
|
const r = await createEntity(testObjectJson);
|
|
888
|
-
await r.insert({ id: 1, person: { firstName:
|
|
995
|
+
await r.insert({ id: 1, person: { firstName: 'noam', lastName: 'honig' } });
|
|
889
996
|
let item = await r.findFirst();
|
|
890
|
-
expect(item.person).toEqual({ firstName:
|
|
997
|
+
expect(item.person).toEqual({ firstName: 'noam', lastName: 'honig' });
|
|
891
998
|
}, false);
|
|
892
|
-
testAll(
|
|
999
|
+
testAll('test json structure', async ({ createEntity }) => {
|
|
893
1000
|
const e = class {
|
|
894
1001
|
constructor() {
|
|
895
1002
|
this.a = 0;
|
|
896
1003
|
}
|
|
897
1004
|
};
|
|
898
|
-
describeClass(e, Entity(
|
|
1005
|
+
describeClass(e, Entity('testJsonFieldType', { allowApiCrud: true }), {
|
|
899
1006
|
a: Fields.number(),
|
|
900
|
-
person: Fields.json()
|
|
1007
|
+
person: Fields.json(),
|
|
901
1008
|
});
|
|
902
1009
|
const r = await createEntity(e);
|
|
903
|
-
await r.insert({ a: 1, person: { firstName:
|
|
1010
|
+
await r.insert({ a: 1, person: { firstName: 'noam', lastName: 'honig' } });
|
|
904
1011
|
let item = await r.findFirst();
|
|
905
|
-
expect(item.person).toEqual({ firstName:
|
|
1012
|
+
expect(item.person).toEqual({ firstName: 'noam', lastName: 'honig' });
|
|
906
1013
|
}, false);
|
|
907
|
-
testAll(
|
|
1014
|
+
testAll('test json structure 2', async ({ createEntity }) => {
|
|
908
1015
|
const e = class {
|
|
909
1016
|
constructor() {
|
|
910
1017
|
this.a = 0;
|
|
911
1018
|
this.items = [];
|
|
912
1019
|
}
|
|
913
1020
|
};
|
|
914
|
-
describeClass(e, Entity(
|
|
1021
|
+
describeClass(e, Entity('testJsonFieldType2', { allowApiCrud: true }), {
|
|
915
1022
|
a: Fields.number(),
|
|
916
|
-
items: Fields.json()
|
|
1023
|
+
items: Fields.json(),
|
|
917
1024
|
});
|
|
918
1025
|
const r = await createEntity(e);
|
|
919
|
-
await r.insert({ a: 1, items: [
|
|
1026
|
+
await r.insert({ a: 1, items: ['a', 'b'] });
|
|
920
1027
|
let item = await r.findFirst();
|
|
921
|
-
expect(item.items).toEqual([
|
|
1028
|
+
expect(item.items).toEqual(['a', 'b']);
|
|
922
1029
|
//expect(await r.count({ items: { $contains: "b" } })).toBe(1)
|
|
923
|
-
}, false
|
|
924
|
-
testAll(
|
|
1030
|
+
}, false);
|
|
1031
|
+
testAll('test json structure 3', async ({ createEntity }) => {
|
|
925
1032
|
const e = class {
|
|
926
1033
|
constructor() {
|
|
927
1034
|
this.a = 0;
|
|
928
1035
|
this.items = [];
|
|
929
1036
|
}
|
|
930
1037
|
};
|
|
931
|
-
describeClass(e, Entity(
|
|
1038
|
+
describeClass(e, Entity('testJsonFieldType3', { allowApiCrud: true }), {
|
|
932
1039
|
a: Fields.number(),
|
|
933
|
-
items: Fields.object()
|
|
1040
|
+
items: Fields.object(),
|
|
934
1041
|
});
|
|
935
1042
|
const r = await createEntity(e);
|
|
936
|
-
await r.insert({ a: 1, items: [
|
|
1043
|
+
await r.insert({ a: 1, items: ['a', 'b'] });
|
|
937
1044
|
let item = await r.findFirst();
|
|
938
|
-
expect(item.items).toEqual([
|
|
939
|
-
expect(await r.count({ items: { $contains:
|
|
1045
|
+
expect(item.items).toEqual(['a', 'b']);
|
|
1046
|
+
expect(await r.count({ items: { $contains: 'b' } })).toBe(1);
|
|
940
1047
|
}, false, {
|
|
941
|
-
exclude: [TestDbs.mongo]
|
|
1048
|
+
exclude: [TestDbs.mongo, TestDbs.mongoNoTrans],
|
|
942
1049
|
});
|
|
1050
|
+
testAll('test relation to number id', async ({ createEntity }) => {
|
|
1051
|
+
const category = class {
|
|
1052
|
+
constructor() {
|
|
1053
|
+
this.id = 0;
|
|
1054
|
+
this.name = '';
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
describeClass(category, Entity('rel_ID_categories', { allowApiCrud: true }), {
|
|
1058
|
+
id: Fields.autoIncrement(),
|
|
1059
|
+
name: Fields.string(),
|
|
1060
|
+
});
|
|
1061
|
+
const task = class {
|
|
1062
|
+
constructor() {
|
|
1063
|
+
this.id = 0;
|
|
1064
|
+
this.title = '';
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
describeClass(task, Entity('rel_ID_task', { allowApiCrud: true }), {
|
|
1068
|
+
id: Fields.autoIncrement(),
|
|
1069
|
+
title: Fields.string(),
|
|
1070
|
+
category: Field(() => category),
|
|
1071
|
+
});
|
|
1072
|
+
const catRepo = await createEntity(category);
|
|
1073
|
+
const taskRepo = await createEntity(task);
|
|
1074
|
+
const cat = await catRepo.insert([{ name: 'cat0' }, { name: 'cat1' }]);
|
|
1075
|
+
await taskRepo.insert([
|
|
1076
|
+
{ title: 't1', category: cat[0] },
|
|
1077
|
+
{ title: 't2', category: cat[0] },
|
|
1078
|
+
{ title: 't3', category: cat[1] },
|
|
1079
|
+
]);
|
|
1080
|
+
expect(taskRepo.fields.category.valueConverter.fieldTypeInDb).toBe(ValueConverters.Integer.fieldTypeInDb);
|
|
1081
|
+
expect(await taskRepo.count({ category: cat[0] })).toBe(2);
|
|
1082
|
+
expect(await taskRepo.count({ category: cat[1] })).toBe(1);
|
|
1083
|
+
expect(await taskRepo.count({ category: { $id: cat[0].id } })).toBe(2);
|
|
1084
|
+
}, false, { exclude: [TestDbs.mongo, TestDbs.mongoNoTrans] });
|