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,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRepository = exports.getEntityMetadata = exports.ControllerBase = exports.IdEntity = exports.EntityBase = exports.Entity = exports.decorateColumnSettings = exports.storableMember = exports.Field = exports.getValueList = exports.ValueListInfo = exports.ValueListFieldType = exports.isAutoIncrement = exports.Fields = exports.FieldType = exports.columnDefsImpl = exports.buildCaption = exports.CaptionTransformer = exports.getEntityRef = exports.FieldRefImplementation = exports.controllerRefImpl = exports.getControllerRef = exports.getFields = exports.rowHelperImplementation = exports.createOldEntity = exports.columnsOfType = exports.getEntityKey = exports.getEntitySettings = exports.entityInfo_key = exports.entityInfo = exports.__updateEntityBasedOnWhere = exports.RepositoryImplementation = void 0;
|
|
3
|
+
exports.checkTarget = exports.getRepository = exports.getEntityMetadata = exports.ControllerBase = exports.IdEntity = exports.EntityBase = exports.Entity = exports.decorateColumnSettings = exports.storableMember = exports.Field = exports.getValueList = exports.ValueListInfo = exports.ValueListFieldType = exports.isAutoIncrement = exports.Fields = exports.FieldType = exports.columnDefsImpl = exports.buildCaption = exports.CaptionTransformer = exports.getEntityRef = exports.FieldRefImplementation = exports.controllerRefImpl = exports.getControllerRef = exports.getFields = exports.rowHelperImplementation = exports.createOldEntity = exports.columnsOfType = exports.getEntityKey = exports.getEntitySettings = exports.entityInfo_key = exports.entityInfo = exports.__updateEntityBasedOnWhere = exports.RepositoryImplementation = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var column_1 = require("../column");
|
|
6
6
|
var context_1 = require("../context");
|
|
7
7
|
var filter_interfaces_1 = require("../filter/filter-interfaces");
|
|
8
8
|
var sort_1 = require("../sort");
|
|
9
9
|
var uuid_1 = require("uuid");
|
|
10
|
-
var
|
|
10
|
+
var cuid2_1 = require("@paralleldrive/cuid2");
|
|
11
11
|
var valueConverters_1 = require("../valueConverters");
|
|
12
12
|
var filter_interfaces_2 = require("../filter/filter-interfaces");
|
|
13
13
|
var assign_1 = require("../../assign");
|
|
14
14
|
var remult_proxy_1 = require("../remult-proxy");
|
|
15
|
+
var rest_data_provider_1 = require("../data-providers/rest-data-provider");
|
|
15
16
|
//import { remult } from "../remult-proxy";
|
|
16
17
|
var classValidatorValidate = undefined;
|
|
17
18
|
// import("class-validator".toString())
|
|
@@ -47,7 +48,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
47
48
|
return tslib_1.__generator(this, function (_h) {
|
|
48
49
|
values = new Map();
|
|
49
50
|
try {
|
|
50
|
-
for (_a = tslib_1.__values(sort_1.Sort.translateOrderByToSort(this.metadata, orderBy)
|
|
51
|
+
for (_a = tslib_1.__values(sort_1.Sort.translateOrderByToSort(this.metadata, orderBy)
|
|
52
|
+
.Segments), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
51
53
|
s = _b.value;
|
|
52
54
|
existingVal = lastRow[s.field.key];
|
|
53
55
|
// if (typeof existingVal !== "string" && typeof existingVal !== "number") {
|
|
@@ -71,7 +73,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
71
73
|
r = { $or: [] };
|
|
72
74
|
equalToColumn = [];
|
|
73
75
|
try {
|
|
74
|
-
for (_c = tslib_1.__values(sort_1.Sort.translateOrderByToSort(this.metadata, orderBy)
|
|
76
|
+
for (_c = tslib_1.__values(sort_1.Sort.translateOrderByToSort(this.metadata, orderBy)
|
|
77
|
+
.Segments), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
75
78
|
s = _d.value;
|
|
76
79
|
ff = new filter_interfaces_2.filterHelper(s.field);
|
|
77
80
|
f = {};
|
|
@@ -110,7 +113,9 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
110
113
|
};
|
|
111
114
|
Object.defineProperty(RepositoryImplementation.prototype, "edp", {
|
|
112
115
|
get: function () {
|
|
113
|
-
return this.__edp
|
|
116
|
+
return this.__edp
|
|
117
|
+
? this.__edp
|
|
118
|
+
: (this.__edp = this.dataProvider.getEntityDataProvider(this.metadata));
|
|
114
119
|
},
|
|
115
120
|
enumerable: false,
|
|
116
121
|
configurable: true
|
|
@@ -162,11 +167,12 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
162
167
|
this.idCache.set(this.getEntityRef(item).getId() + '', item);
|
|
163
168
|
};
|
|
164
169
|
Object.defineProperty(RepositoryImplementation.prototype, "metadata", {
|
|
165
|
-
get: function () {
|
|
170
|
+
get: function () {
|
|
171
|
+
return this._info;
|
|
172
|
+
},
|
|
166
173
|
enumerable: false,
|
|
167
174
|
configurable: true
|
|
168
175
|
});
|
|
169
|
-
;
|
|
170
176
|
RepositoryImplementation.prototype.addEventListener = function (listener) {
|
|
171
177
|
var _this = this;
|
|
172
178
|
if (!this.listeners)
|
|
@@ -185,7 +191,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
185
191
|
this.fixTypes(entity);
|
|
186
192
|
x = new rowHelperImplementation(this._info, entity, this, this.edp, this.remult, true);
|
|
187
193
|
Object.defineProperty(entity, entityMember, {
|
|
188
|
-
|
|
194
|
+
//I've used define property to hide this member from console.lo g
|
|
195
|
+
get: function () { return x; },
|
|
189
196
|
});
|
|
190
197
|
x.saveOriginalData();
|
|
191
198
|
}
|
|
@@ -194,7 +201,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
194
201
|
RepositoryImplementation.prototype.delete = function (item) {
|
|
195
202
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
196
203
|
return tslib_1.__generator(this, function (_a) {
|
|
197
|
-
if (typeof item ===
|
|
204
|
+
if (typeof item === 'string' || typeof item === 'number')
|
|
198
205
|
return [2 /*return*/, this.edp.delete(item)];
|
|
199
206
|
else {
|
|
200
207
|
return [2 /*return*/, this.getRefForExistingRow(item, undefined).delete()];
|
|
@@ -244,7 +251,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
244
251
|
ref = getEntityRef(entity, false);
|
|
245
252
|
if (!ref) return [3 /*break*/, 11];
|
|
246
253
|
if (!ref.isNew())
|
|
247
|
-
throw
|
|
254
|
+
throw 'Item is not new';
|
|
248
255
|
return [4 /*yield*/, ref.save()];
|
|
249
256
|
case 10: return [2 /*return*/, _d.sent()];
|
|
250
257
|
case 11: return [4 /*yield*/, this.getEntityRef(this.create(entity)).save()];
|
|
@@ -271,7 +278,9 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
271
278
|
return tslib_1.__generator(this, function (_b) {
|
|
272
279
|
switch (_b.label) {
|
|
273
280
|
case 0:
|
|
274
|
-
ref =
|
|
281
|
+
ref = getEntityRef(entity, false);
|
|
282
|
+
if (!ref)
|
|
283
|
+
ref = this.getEntityRef(tslib_1.__assign({}, entity));
|
|
275
284
|
if (!(!fields || fields.length === 0)) return [3 /*break*/, 2];
|
|
276
285
|
return [4 /*yield*/, ref.validate()];
|
|
277
286
|
case 1: return [2 /*return*/, _b.sent()];
|
|
@@ -346,7 +355,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
346
355
|
}
|
|
347
356
|
this.fixTypes(instance);
|
|
348
357
|
var row_1 = new rowHelperImplementation(this._info, instance, this, this.edp, this.remult, false);
|
|
349
|
-
if (typeof
|
|
358
|
+
if (typeof id === 'object')
|
|
350
359
|
id = this.metadata.idMetadata.getId(id);
|
|
351
360
|
if (id) {
|
|
352
361
|
row_1.id = id;
|
|
@@ -356,7 +365,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
356
365
|
row_1.id = row_1.getId();
|
|
357
366
|
ref = row_1;
|
|
358
367
|
Object.defineProperty(instance, entityMember, {
|
|
359
|
-
get: function () { return row_1; }
|
|
368
|
+
get: function () { return row_1; },
|
|
360
369
|
});
|
|
361
370
|
}
|
|
362
371
|
return ref;
|
|
@@ -396,17 +405,17 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
396
405
|
subscribe: function (l) {
|
|
397
406
|
var _a, _b;
|
|
398
407
|
var listener = l;
|
|
399
|
-
if (typeof l ===
|
|
408
|
+
if (typeof l === 'function') {
|
|
400
409
|
listener = {
|
|
401
410
|
next: l,
|
|
402
411
|
complete: function () { },
|
|
403
|
-
error: function () { }
|
|
412
|
+
error: function () { },
|
|
404
413
|
};
|
|
405
414
|
}
|
|
406
415
|
(_a = listener.error) !== null && _a !== void 0 ? _a : (listener.error = function () { });
|
|
407
416
|
(_b = listener.complete) !== null && _b !== void 0 ? _b : (listener.complete = function () { });
|
|
408
417
|
return _this.remult.liveQuerySubscriber.subscribe(_this, options, listener);
|
|
409
|
-
}
|
|
418
|
+
},
|
|
410
419
|
};
|
|
411
420
|
};
|
|
412
421
|
RepositoryImplementation.prototype.find = function (options, skipOrderByAndLimit) {
|
|
@@ -543,7 +552,10 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
543
552
|
for (rawRows_1 = (e_9 = void 0, tslib_1.__values(rawRows)), rawRows_1_1 = rawRows_1.next(); !rawRows_1_1.done; rawRows_1_1 = rawRows_1.next()) {
|
|
544
553
|
r = rawRows_1_1.value;
|
|
545
554
|
val = r[col.key];
|
|
546
|
-
if (val !== undefined &&
|
|
555
|
+
if (val !== undefined &&
|
|
556
|
+
val !== null &&
|
|
557
|
+
!toLoad.includes(val) &&
|
|
558
|
+
!repo.idCache.has(val)) {
|
|
547
559
|
toLoad.push(val);
|
|
548
560
|
}
|
|
549
561
|
}
|
|
@@ -598,7 +610,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
598
610
|
x = new this.entity(this.remult);
|
|
599
611
|
helper = new rowHelperImplementation(this._info, x, this, this.edp, this.remult, false);
|
|
600
612
|
Object.defineProperty(x, entityMember, {
|
|
601
|
-
|
|
613
|
+
//I've used define property to hide this member from console.lo g
|
|
614
|
+
get: function () { return helper; },
|
|
602
615
|
});
|
|
603
616
|
return [4 /*yield*/, helper.loadDataFrom(r, loadFields)];
|
|
604
617
|
case 1:
|
|
@@ -609,41 +622,60 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
609
622
|
});
|
|
610
623
|
});
|
|
611
624
|
};
|
|
612
|
-
|
|
625
|
+
RepositoryImplementation.prototype.toJson = function (item) {
|
|
626
|
+
var _this = this;
|
|
627
|
+
if (item === undefined || item === null)
|
|
628
|
+
return item;
|
|
629
|
+
if (Array.isArray(item))
|
|
630
|
+
return item.map(function (x) { return _this.toJson(x); });
|
|
631
|
+
if (typeof item.then === 'function')
|
|
632
|
+
return item.then(function (x) { return _this.toJson(x); });
|
|
633
|
+
return this.getEntityRef(item).toApiJson(true);
|
|
634
|
+
};
|
|
613
635
|
RepositoryImplementation.prototype.fromJson = function (json, newRow) {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
return
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
finally { if (e_11) throw e_11.error; }
|
|
635
|
-
}
|
|
636
|
-
if (!newRow) return [3 /*break*/, 2];
|
|
637
|
-
r = this.create();
|
|
638
|
-
helper = this.getEntityRef(r);
|
|
639
|
-
return [4 /*yield*/, helper.loadDataFrom(obj)];
|
|
640
|
-
case 1:
|
|
641
|
-
_d.sent();
|
|
642
|
-
return [2 /*return*/, r];
|
|
643
|
-
case 2: return [2 /*return*/, this.mapRawDataToResult(obj, undefined)];
|
|
636
|
+
var e_11, _a;
|
|
637
|
+
var _this = this;
|
|
638
|
+
if (json === null || json === undefined)
|
|
639
|
+
return json;
|
|
640
|
+
if (Array.isArray(json))
|
|
641
|
+
return json.map(function (item) { return _this.fromJson(item, newRow); });
|
|
642
|
+
var result = new this.entity(this.remult);
|
|
643
|
+
try {
|
|
644
|
+
for (var _b = tslib_1.__values(this.fieldsOf(json)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
645
|
+
var col = _c.value;
|
|
646
|
+
var ei = getEntitySettings(col.valueType, false);
|
|
647
|
+
if (ei) {
|
|
648
|
+
result[col.key] = this.remult
|
|
649
|
+
.repo(col.valueType)
|
|
650
|
+
.fromJson(json[col.key]);
|
|
651
|
+
}
|
|
652
|
+
else {
|
|
653
|
+
if (json[col.key] !== undefined) {
|
|
654
|
+
result[col.key] = col.valueConverter.fromJson(json[col.key]);
|
|
655
|
+
}
|
|
644
656
|
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
660
|
+
finally {
|
|
661
|
+
try {
|
|
662
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
663
|
+
}
|
|
664
|
+
finally { if (e_11) throw e_11.error; }
|
|
665
|
+
}
|
|
666
|
+
this.fixTypes(result);
|
|
667
|
+
if (newRow) {
|
|
668
|
+
return this.create(result);
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
var row_2 = new rowHelperImplementation(this._info, result, this, this.edp, this.remult, false);
|
|
672
|
+
Object.defineProperty(result, entityMember, {
|
|
673
|
+
//I've used define property to hide this member from console.lo g
|
|
674
|
+
get: function () { return row_2; },
|
|
645
675
|
});
|
|
646
|
-
|
|
676
|
+
row_2.saveOriginalData();
|
|
677
|
+
return result;
|
|
678
|
+
}
|
|
647
679
|
};
|
|
648
680
|
RepositoryImplementation.prototype.count = function (where) {
|
|
649
681
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
@@ -664,73 +696,65 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
664
696
|
var w, r, cacheInfo, f, key;
|
|
665
697
|
var _this = this;
|
|
666
698
|
return tslib_1.__generator(this, function (_a) {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
if (
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
key = JSON.stringify(f);
|
|
689
|
-
cacheInfo = this.cache.get(key);
|
|
690
|
-
if (cacheInfo !== undefined) {
|
|
691
|
-
if (cacheInfo.value && this.getEntityRef(cacheInfo.value).wasDeleted()) {
|
|
692
|
-
cacheInfo = undefined;
|
|
693
|
-
this.cache.delete(key);
|
|
694
|
-
}
|
|
695
|
-
else
|
|
696
|
-
return [2 /*return*/, this.cache.get(key).promise];
|
|
697
|
-
}
|
|
698
|
-
else {
|
|
699
|
-
cacheInfo = {
|
|
700
|
-
value: undefined,
|
|
701
|
-
promise: undefined
|
|
702
|
-
};
|
|
703
|
-
this.cache.set(key, cacheInfo);
|
|
699
|
+
if (!options)
|
|
700
|
+
options = {};
|
|
701
|
+
if (where) {
|
|
702
|
+
if (options.where) {
|
|
703
|
+
w = options.where;
|
|
704
|
+
options.where = {
|
|
705
|
+
$and: [w, where],
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
else
|
|
709
|
+
options.where = where;
|
|
710
|
+
}
|
|
711
|
+
if (options.useCache) {
|
|
712
|
+
f = rest_data_provider_1.findOptionsToJson(options, this.metadata);
|
|
713
|
+
key = JSON.stringify(f);
|
|
714
|
+
cacheInfo = this.cache.get(key);
|
|
715
|
+
if (cacheInfo !== undefined) {
|
|
716
|
+
if (cacheInfo.value &&
|
|
717
|
+
this.getEntityRef(cacheInfo.value).wasDeleted()) {
|
|
718
|
+
cacheInfo = undefined;
|
|
719
|
+
this.cache.delete(key);
|
|
704
720
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
721
|
+
else
|
|
722
|
+
return [2 /*return*/, this.cache.get(key).promise];
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
cacheInfo = {
|
|
726
|
+
value: undefined,
|
|
727
|
+
promise: undefined,
|
|
728
|
+
};
|
|
729
|
+
this.cache.set(key, cacheInfo);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
r = this.find(tslib_1.__assign(tslib_1.__assign({}, options), { limit: 1 }), skipOrderByAndLimit).then(function (items) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
733
|
+
var r;
|
|
734
|
+
return tslib_1.__generator(this, function (_a) {
|
|
735
|
+
switch (_a.label) {
|
|
736
|
+
case 0:
|
|
737
|
+
r = undefined;
|
|
738
|
+
if (items.length > 0)
|
|
739
|
+
r = items[0];
|
|
740
|
+
if (!(!r && options.createIfNotFound)) return [3 /*break*/, 2];
|
|
741
|
+
r = this.create();
|
|
742
|
+
if (!options.where) return [3 /*break*/, 2];
|
|
743
|
+
return [4 /*yield*/, __updateEntityBasedOnWhere(this.metadata, options.where, r)];
|
|
744
|
+
case 1:
|
|
745
|
+
_a.sent();
|
|
746
|
+
_a.label = 2;
|
|
747
|
+
case 2: return [2 /*return*/, r];
|
|
731
748
|
}
|
|
732
|
-
|
|
749
|
+
});
|
|
750
|
+
}); });
|
|
751
|
+
if (cacheInfo) {
|
|
752
|
+
cacheInfo.promise = r = r.then(function (r) {
|
|
753
|
+
cacheInfo.value = r;
|
|
754
|
+
return r;
|
|
755
|
+
});
|
|
733
756
|
}
|
|
757
|
+
return [2 /*return*/, r];
|
|
734
758
|
});
|
|
735
759
|
});
|
|
736
760
|
};
|
|
@@ -774,7 +798,11 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
774
798
|
item[field.key] = field.valueConverter.fromJson(field.valueConverter.toJson(val));
|
|
775
799
|
else
|
|
776
800
|
try {
|
|
777
|
-
for (_c = (e_14 = void 0, tslib_1.__values([
|
|
801
|
+
for (_c = (e_14 = void 0, tslib_1.__values([
|
|
802
|
+
[String, 'string'],
|
|
803
|
+
[Number, 'number'],
|
|
804
|
+
[Boolean, 'boolean'],
|
|
805
|
+
])), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
778
806
|
_e = tslib_1.__read(_d.value, 2), type = _e[0], typeName = _e[1];
|
|
779
807
|
if (field.valueType === type && typeof val !== typeName)
|
|
780
808
|
item[field.key] = field.valueConverter.fromJson(field.valueConverter.toJson(val));
|
|
@@ -804,8 +832,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
804
832
|
RepositoryImplementation.prototype.findId = function (id, options) {
|
|
805
833
|
if (id === null || id === undefined)
|
|
806
834
|
return null;
|
|
807
|
-
if (typeof id !==
|
|
808
|
-
throw new Error(
|
|
835
|
+
if (typeof id !== 'string' && typeof id !== 'number')
|
|
836
|
+
throw new Error('id can be either number or string, but got: ' + typeof id);
|
|
809
837
|
return this.findFirst({}, tslib_1.__assign(tslib_1.__assign({ useCache: true }, options), { where: this.metadata.idMetadata.getIdFilter(id) }), true);
|
|
810
838
|
};
|
|
811
839
|
/* @internal*/
|
|
@@ -822,15 +850,13 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
822
850
|
_a = [z];
|
|
823
851
|
return [4 /*yield*/, filter_interfaces_1.Filter.resolve(this.metadata.options.backendPrefilter)];
|
|
824
852
|
case 1:
|
|
825
|
-
where = (_b.$and = _a.concat([
|
|
826
|
-
_c.sent()
|
|
827
|
-
]),
|
|
853
|
+
where = (_b.$and = _a.concat([_c.sent()]),
|
|
828
854
|
_b);
|
|
829
855
|
_c.label = 2;
|
|
830
856
|
case 2: return [4 /*yield*/, filter_interfaces_1.Filter.fromEntityFilter(this.metadata, where)];
|
|
831
857
|
case 3:
|
|
832
858
|
r = _c.sent();
|
|
833
|
-
if (!(r && !this.dataProvider.
|
|
859
|
+
if (!(r && !this.dataProvider.isProxy)) return [3 /*break*/, 5];
|
|
834
860
|
return [4 /*yield*/, filter_interfaces_1.Filter.translateCustomWhere(r, this.metadata, this.remult)];
|
|
835
861
|
case 4:
|
|
836
862
|
r = _c.sent();
|
|
@@ -862,25 +888,26 @@ function __updateEntityBasedOnWhere(entityDefs, where, r) {
|
|
|
862
888
|
isLessThan: emptyFunction,
|
|
863
889
|
isNotNull: emptyFunction,
|
|
864
890
|
isNull: emptyFunction,
|
|
865
|
-
or: emptyFunction
|
|
891
|
+
or: emptyFunction,
|
|
866
892
|
});
|
|
867
893
|
}
|
|
868
894
|
}
|
|
869
895
|
exports.__updateEntityBasedOnWhere = __updateEntityBasedOnWhere;
|
|
870
|
-
exports.entityInfo = Symbol(
|
|
871
|
-
exports.entityInfo_key = Symbol(
|
|
872
|
-
var entityMember = Symbol(
|
|
896
|
+
exports.entityInfo = Symbol('entityInfo');
|
|
897
|
+
exports.entityInfo_key = Symbol('entityInfo_key');
|
|
898
|
+
var entityMember = Symbol('entityMember');
|
|
873
899
|
function getEntitySettings(entity, throwError) {
|
|
874
900
|
if (throwError === void 0) { throwError = true; }
|
|
875
901
|
if (entity === undefined)
|
|
876
902
|
if (throwError) {
|
|
877
|
-
throw new Error(
|
|
903
|
+
throw new Error('Undefined is not an entity :)');
|
|
878
904
|
}
|
|
879
905
|
else
|
|
880
906
|
return undefined;
|
|
881
907
|
var info = Reflect.getMetadata(exports.entityInfo, entity);
|
|
882
908
|
if (!info && throwError)
|
|
883
|
-
throw new Error(entity.prototype.constructor.name +
|
|
909
|
+
throw new Error(entity.prototype.constructor.name +
|
|
910
|
+
" is not a known entity, did you forget to set @Entity() or did you forget to add the '@' before the call to Entity?");
|
|
884
911
|
return info;
|
|
885
912
|
}
|
|
886
913
|
exports.getEntitySettings = getEntitySettings;
|
|
@@ -893,7 +920,7 @@ function createOldEntity(entity, remult) {
|
|
|
893
920
|
var _this = this;
|
|
894
921
|
var r = exports.columnsOfType.get(entity);
|
|
895
922
|
if (!r)
|
|
896
|
-
exports.columnsOfType.set(entity, r = []);
|
|
923
|
+
exports.columnsOfType.set(entity, (r = []));
|
|
897
924
|
var info = getEntitySettings(entity)(remult);
|
|
898
925
|
var key = getEntityKey(entity);
|
|
899
926
|
var base = Object.getPrototypeOf(entity);
|
|
@@ -907,7 +934,13 @@ function createOldEntity(entity, remult) {
|
|
|
907
934
|
if (baseSettingsFactory) {
|
|
908
935
|
var baseSettings_1 = baseSettingsFactory(remult);
|
|
909
936
|
info = tslib_1.__assign(tslib_1.__assign({}, baseSettings_1), info);
|
|
910
|
-
var functions = [
|
|
937
|
+
var functions = [
|
|
938
|
+
'saving',
|
|
939
|
+
'saved',
|
|
940
|
+
'deleting',
|
|
941
|
+
'deleted',
|
|
942
|
+
'validation',
|
|
943
|
+
];
|
|
911
944
|
var _loop_2 = function (key_1) {
|
|
912
945
|
if (baseSettings_1[key_1] && baseSettings_1[key_1] !== info[key_1]) {
|
|
913
946
|
var x_1 = info[key_1];
|
|
@@ -997,7 +1030,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
997
1030
|
}
|
|
998
1031
|
refImpl_1._subscribers.reportChanged();
|
|
999
1032
|
},
|
|
1000
|
-
enumerable: true
|
|
1033
|
+
enumerable: true,
|
|
1001
1034
|
});
|
|
1002
1035
|
lookup_1.set(val);
|
|
1003
1036
|
}
|
|
@@ -1042,7 +1075,6 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1042
1075
|
var _this = this;
|
|
1043
1076
|
if (!this._subscribers) {
|
|
1044
1077
|
this._subscribers = new SubscribableImp();
|
|
1045
|
-
;
|
|
1046
1078
|
var _loop_4 = function (col) {
|
|
1047
1079
|
var ei = getEntitySettings(col.valueType, false);
|
|
1048
1080
|
var refImpl = this_2.fields.find(col.key);
|
|
@@ -1062,7 +1094,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1062
1094
|
_this._subscribers.reportChanged();
|
|
1063
1095
|
refImpl._subscribers.reportChanged();
|
|
1064
1096
|
},
|
|
1065
|
-
enumerable: true
|
|
1097
|
+
enumerable: true,
|
|
1066
1098
|
});
|
|
1067
1099
|
}
|
|
1068
1100
|
};
|
|
@@ -1116,14 +1148,15 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1116
1148
|
var e_18, _a;
|
|
1117
1149
|
var error = {
|
|
1118
1150
|
modelState: Object.assign({}, this.errors),
|
|
1119
|
-
message: this.error
|
|
1151
|
+
message: this.error,
|
|
1120
1152
|
};
|
|
1121
1153
|
if (!error.message) {
|
|
1122
1154
|
try {
|
|
1123
1155
|
for (var _b = tslib_1.__values(this.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1124
1156
|
var col = _c.value;
|
|
1125
1157
|
if (this.errors[col.key]) {
|
|
1126
|
-
error.message =
|
|
1158
|
+
error.message =
|
|
1159
|
+
this.fields[col.key].metadata.caption + ': ' + this.errors[col.key];
|
|
1127
1160
|
this.error = error.message;
|
|
1128
1161
|
break;
|
|
1129
1162
|
}
|
|
@@ -1225,8 +1258,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1225
1258
|
this.originalValues = this.copyDataToObject();
|
|
1226
1259
|
this.saveMoreOriginalData();
|
|
1227
1260
|
};
|
|
1228
|
-
rowHelperBase.prototype.saveMoreOriginalData = function () {
|
|
1229
|
-
};
|
|
1261
|
+
rowHelperBase.prototype.saveMoreOriginalData = function () { };
|
|
1230
1262
|
rowHelperBase.prototype.validate = function () {
|
|
1231
1263
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1232
1264
|
var r;
|
|
@@ -1273,23 +1305,27 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1273
1305
|
});
|
|
1274
1306
|
};
|
|
1275
1307
|
rowHelperBase.prototype.__performColumnAndEntityValidations = function () {
|
|
1276
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1277
|
-
return
|
|
1278
|
-
|
|
1279
|
-
});
|
|
1280
|
-
});
|
|
1308
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
1309
|
+
return [2 /*return*/];
|
|
1310
|
+
}); });
|
|
1281
1311
|
};
|
|
1282
|
-
rowHelperBase.prototype.toApiJson = function () {
|
|
1312
|
+
rowHelperBase.prototype.toApiJson = function (includeRelatedEntities) {
|
|
1283
1313
|
var e_21, _a;
|
|
1314
|
+
if (includeRelatedEntities === void 0) { includeRelatedEntities = false; }
|
|
1284
1315
|
var result = {};
|
|
1285
1316
|
try {
|
|
1286
1317
|
for (var _b = tslib_1.__values(this.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1287
1318
|
var col = _c.value;
|
|
1288
|
-
if (!this.remult ||
|
|
1319
|
+
if (!this.remult ||
|
|
1320
|
+
col.includeInApi === undefined ||
|
|
1321
|
+
this.remult.isAllowed(col.includeInApi)) {
|
|
1289
1322
|
var val = void 0;
|
|
1290
1323
|
var lu = this.lookups.get(col.key);
|
|
1291
1324
|
if (lu)
|
|
1292
|
-
|
|
1325
|
+
if (includeRelatedEntities)
|
|
1326
|
+
val = lu.toJson();
|
|
1327
|
+
else
|
|
1328
|
+
val = lu.id;
|
|
1293
1329
|
else {
|
|
1294
1330
|
val = this.instance[col.key];
|
|
1295
1331
|
if (!this.remult) {
|
|
@@ -1326,8 +1362,11 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1326
1362
|
for (_a = tslib_1.__values(this.columnsInfo), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
1327
1363
|
col = _b.value;
|
|
1328
1364
|
if (keys.includes(col.key))
|
|
1329
|
-
if (col.includeInApi === undefined ||
|
|
1330
|
-
|
|
1365
|
+
if (col.includeInApi === undefined ||
|
|
1366
|
+
this.remult.isAllowed(col.includeInApi)) {
|
|
1367
|
+
if (!this.remult ||
|
|
1368
|
+
col.allowApiUpdate === undefined ||
|
|
1369
|
+
this.remult.isAllowedForInstance(this.instance, col.allowApiUpdate)) {
|
|
1331
1370
|
lu = this.lookups.get(col.key);
|
|
1332
1371
|
if (lu)
|
|
1333
1372
|
lu.id = body[col.key];
|
|
@@ -1371,7 +1410,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1371
1410
|
for (var _b = tslib_1.__values(info.columnsInfo), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1372
1411
|
var col = _c.value;
|
|
1373
1412
|
if (col.defaultValue && instance[col.key] === undefined) {
|
|
1374
|
-
if (typeof col.defaultValue ===
|
|
1413
|
+
if (typeof col.defaultValue === 'function') {
|
|
1375
1414
|
instance[col.key] = col.defaultValue(instance);
|
|
1376
1415
|
}
|
|
1377
1416
|
else if (!instance[col.key])
|
|
@@ -1394,17 +1433,23 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1394
1433
|
return _this;
|
|
1395
1434
|
}
|
|
1396
1435
|
Object.defineProperty(rowHelperImplementation.prototype, "apiUpdateAllowed", {
|
|
1397
|
-
get: function () {
|
|
1436
|
+
get: function () {
|
|
1437
|
+
return this.remult.isAllowedForInstance(this.instance, this.metadata.options.allowApiUpdate);
|
|
1438
|
+
},
|
|
1398
1439
|
enumerable: false,
|
|
1399
1440
|
configurable: true
|
|
1400
1441
|
});
|
|
1401
1442
|
Object.defineProperty(rowHelperImplementation.prototype, "apiDeleteAllowed", {
|
|
1402
|
-
get: function () {
|
|
1443
|
+
get: function () {
|
|
1444
|
+
return this.remult.isAllowedForInstance(this.instance, this.metadata.options.allowApiDelete);
|
|
1445
|
+
},
|
|
1403
1446
|
enumerable: false,
|
|
1404
1447
|
configurable: true
|
|
1405
1448
|
});
|
|
1406
1449
|
Object.defineProperty(rowHelperImplementation.prototype, "apiInsertAllowed", {
|
|
1407
|
-
get: function () {
|
|
1450
|
+
get: function () {
|
|
1451
|
+
return this.remult.isAllowedForInstance(this.instance, this.metadata.options.allowApiInsert);
|
|
1452
|
+
},
|
|
1408
1453
|
enumerable: false,
|
|
1409
1454
|
configurable: true
|
|
1410
1455
|
});
|
|
@@ -1453,7 +1498,9 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1453
1498
|
if (!this._columns) {
|
|
1454
1499
|
var _items_1 = [];
|
|
1455
1500
|
var r_1 = (_a = {
|
|
1456
|
-
find: function (c) {
|
|
1501
|
+
find: function (c) {
|
|
1502
|
+
return r_1[typeof c === 'string' ? c : c.key];
|
|
1503
|
+
}
|
|
1457
1504
|
},
|
|
1458
1505
|
_a[Symbol.iterator] = function () { return _items_1[Symbol.iterator](); },
|
|
1459
1506
|
_a.toArray = function () { return _items_1; },
|
|
@@ -1461,7 +1508,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1461
1508
|
try {
|
|
1462
1509
|
for (var _c = tslib_1.__values(this.info.columnsInfo), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1463
1510
|
var c = _d.value;
|
|
1464
|
-
_items_1.push(r_1[c.key] = new FieldRefImplementation(c, this.info.fields[c.key], this.instance, this, this));
|
|
1511
|
+
_items_1.push((r_1[c.key] = new FieldRefImplementation(c, this.info.fields[c.key], this.instance, this, this)));
|
|
1465
1512
|
}
|
|
1466
1513
|
}
|
|
1467
1514
|
catch (e_24_1) { e_24 = { error: e_24_1 }; }
|
|
@@ -1488,10 +1535,10 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1488
1535
|
case 0:
|
|
1489
1536
|
_l.trys.push([0, , 34, 35]);
|
|
1490
1537
|
if (this._saving)
|
|
1491
|
-
throw new Error(
|
|
1538
|
+
throw new Error('cannot save while entity is already saving');
|
|
1492
1539
|
this._saving = true;
|
|
1493
1540
|
if (this.wasDeleted())
|
|
1494
|
-
throw new Error(
|
|
1541
|
+
throw new Error('cannot save a deleted row');
|
|
1495
1542
|
this.isLoading = true;
|
|
1496
1543
|
return [4 /*yield*/, this.__validateEntity()];
|
|
1497
1544
|
case 1:
|
|
@@ -1526,7 +1573,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1526
1573
|
return [7 /*endfinally*/];
|
|
1527
1574
|
case 9:
|
|
1528
1575
|
if (!this.info.entityInfo.saving) return [3 /*break*/, 11];
|
|
1529
|
-
return [4 /*yield*/, this.info.entityInfo.saving(this.instance, function () { return doNotSave_1 = true; })];
|
|
1576
|
+
return [4 /*yield*/, this.info.entityInfo.saving(this.instance, function () { return (doNotSave_1 = true); })];
|
|
1530
1577
|
case 10:
|
|
1531
1578
|
_l.sent();
|
|
1532
1579
|
_l.label = 11;
|
|
@@ -1553,7 +1600,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1553
1600
|
finally { if (e_27) throw e_27.error; }
|
|
1554
1601
|
}
|
|
1555
1602
|
if (this.info.idMetadata.field instanceof column_1.CompoundIdField)
|
|
1556
|
-
delete
|
|
1603
|
+
delete d.id;
|
|
1557
1604
|
updatedRow = void 0;
|
|
1558
1605
|
isNew = this.isNew();
|
|
1559
1606
|
_l.label = 12;
|
|
@@ -1571,7 +1618,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1571
1618
|
for (key in d) {
|
|
1572
1619
|
if (Object.prototype.hasOwnProperty.call(d, key)) {
|
|
1573
1620
|
element = d[key];
|
|
1574
|
-
if (this.fields.find(key).valueChanged() &&
|
|
1621
|
+
if (this.fields.find(key).valueChanged() &&
|
|
1622
|
+
!ignoreKeys.includes(key)) {
|
|
1575
1623
|
changesOnly[key] = element;
|
|
1576
1624
|
wasChanged = true;
|
|
1577
1625
|
}
|
|
@@ -1921,7 +1969,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1921
1969
|
return rowHelperImplementation;
|
|
1922
1970
|
}(rowHelperBase));
|
|
1923
1971
|
exports.rowHelperImplementation = rowHelperImplementation;
|
|
1924
|
-
var controllerColumns = Symbol(
|
|
1972
|
+
var controllerColumns = Symbol('controllerColumns');
|
|
1925
1973
|
function prepareColumnInfo(r, remult) {
|
|
1926
1974
|
return r.map(function (x) { return decorateColumnSettings(x.settings(remult), remult); });
|
|
1927
1975
|
}
|
|
@@ -1937,7 +1985,7 @@ function getControllerRef(container, remultArg) {
|
|
|
1937
1985
|
if (!result) {
|
|
1938
1986
|
var columnSettings_1 = exports.columnsOfType.get(container.constructor);
|
|
1939
1987
|
if (!columnSettings_1)
|
|
1940
|
-
exports.columnsOfType.set(container.constructor, columnSettings_1 = []);
|
|
1988
|
+
exports.columnsOfType.set(container.constructor, (columnSettings_1 = []));
|
|
1941
1989
|
var base = Object.getPrototypeOf(container.constructor);
|
|
1942
1990
|
while (base != null) {
|
|
1943
1991
|
var baseCols = exports.columnsOfType.get(base);
|
|
@@ -1958,7 +2006,9 @@ var controllerRefImpl = /** @class */ (function (_super) {
|
|
|
1958
2006
|
var _this = _super.call(this, columnsInfo, instance, remult) || this;
|
|
1959
2007
|
var _items = [];
|
|
1960
2008
|
var r = (_a = {
|
|
1961
|
-
find: function (c) {
|
|
2009
|
+
find: function (c) {
|
|
2010
|
+
return r[typeof c === 'string' ? c : c.key];
|
|
2011
|
+
}
|
|
1962
2012
|
},
|
|
1963
2013
|
_a[Symbol.iterator] = function () { return _items[Symbol.iterator](); },
|
|
1964
2014
|
_a.toArray = function () { return _items; },
|
|
@@ -1966,7 +2016,7 @@ var controllerRefImpl = /** @class */ (function (_super) {
|
|
|
1966
2016
|
try {
|
|
1967
2017
|
for (var columnsInfo_2 = tslib_1.__values(columnsInfo), columnsInfo_2_1 = columnsInfo_2.next(); !columnsInfo_2_1.done; columnsInfo_2_1 = columnsInfo_2.next()) {
|
|
1968
2018
|
var col = columnsInfo_2_1.value;
|
|
1969
|
-
_items.push(r[col.key] = new FieldRefImplementation(col, new columnDefsImpl(col, undefined, remult), instance, undefined, _this));
|
|
2019
|
+
_items.push((r[col.key] = new FieldRefImplementation(col, new columnDefsImpl(col, undefined, remult), instance, undefined, _this)));
|
|
1970
2020
|
}
|
|
1971
2021
|
}
|
|
1972
2022
|
catch (e_34_1) { e_34 = { error: e_34_1 }; }
|
|
@@ -2105,20 +2155,21 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2105
2155
|
else
|
|
2106
2156
|
return this.value.toString();
|
|
2107
2157
|
}
|
|
2108
|
-
return
|
|
2158
|
+
return '';
|
|
2109
2159
|
},
|
|
2110
2160
|
enumerable: false,
|
|
2111
2161
|
configurable: true
|
|
2112
2162
|
});
|
|
2113
|
-
;
|
|
2114
2163
|
Object.defineProperty(FieldRefImplementation.prototype, "value", {
|
|
2115
|
-
get: function () {
|
|
2116
|
-
|
|
2164
|
+
get: function () {
|
|
2165
|
+
return this.container[this.metadata.key];
|
|
2166
|
+
},
|
|
2167
|
+
set: function (value) {
|
|
2168
|
+
this.container[this.metadata.key] = value;
|
|
2169
|
+
},
|
|
2117
2170
|
enumerable: false,
|
|
2118
2171
|
configurable: true
|
|
2119
2172
|
});
|
|
2120
|
-
;
|
|
2121
|
-
;
|
|
2122
2173
|
Object.defineProperty(FieldRefImplementation.prototype, "originalValue", {
|
|
2123
2174
|
get: function () {
|
|
2124
2175
|
this.reportObserved();
|
|
@@ -2130,7 +2181,6 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2130
2181
|
enumerable: false,
|
|
2131
2182
|
configurable: true
|
|
2132
2183
|
});
|
|
2133
|
-
;
|
|
2134
2184
|
FieldRefImplementation.prototype.rawOriginalValue = function () {
|
|
2135
2185
|
return this.rowBase.originalValues[this.metadata.key];
|
|
2136
2186
|
};
|
|
@@ -2162,7 +2212,6 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2162
2212
|
enumerable: false,
|
|
2163
2213
|
configurable: true
|
|
2164
2214
|
});
|
|
2165
|
-
;
|
|
2166
2215
|
FieldRefImplementation.prototype.valueChanged = function () {
|
|
2167
2216
|
this.reportObserved();
|
|
2168
2217
|
var val = this.value;
|
|
@@ -2170,7 +2219,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2170
2219
|
if (lu) {
|
|
2171
2220
|
val = lu.id;
|
|
2172
2221
|
}
|
|
2173
|
-
return JSON.stringify(this.metadata.valueConverter.toJson(this.rowBase.originalValues[this.metadata.key])) != JSON.stringify(this.metadata.valueConverter.toJson(val));
|
|
2222
|
+
return (JSON.stringify(this.metadata.valueConverter.toJson(this.rowBase.originalValues[this.metadata.key])) != JSON.stringify(this.metadata.valueConverter.toJson(val)));
|
|
2174
2223
|
};
|
|
2175
2224
|
FieldRefImplementation.prototype.__performValidation = function () {
|
|
2176
2225
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
@@ -2180,7 +2229,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2180
2229
|
switch (_d.label) {
|
|
2181
2230
|
case 0:
|
|
2182
2231
|
_d.trys.push([0, 12, , 13]);
|
|
2183
|
-
x = typeof
|
|
2232
|
+
x = typeof this.settings.validate;
|
|
2184
2233
|
if (!Array.isArray(this.settings.validate)) return [3 /*break*/, 9];
|
|
2185
2234
|
_d.label = 1;
|
|
2186
2235
|
case 1:
|
|
@@ -2218,7 +2267,7 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2218
2267
|
case 11: return [3 /*break*/, 13];
|
|
2219
2268
|
case 12:
|
|
2220
2269
|
error_1 = _d.sent();
|
|
2221
|
-
if (typeof error_1 ===
|
|
2270
|
+
if (typeof error_1 === 'string')
|
|
2222
2271
|
this.error = error_1;
|
|
2223
2272
|
else
|
|
2224
2273
|
this.error = error_1.message;
|
|
@@ -2247,16 +2296,18 @@ function getEntityRef(entity, throwException) {
|
|
|
2247
2296
|
if (throwException === void 0) { throwException = true; }
|
|
2248
2297
|
var x = entity[entityMember];
|
|
2249
2298
|
if (!x && throwException)
|
|
2250
|
-
throw new Error(
|
|
2299
|
+
throw new Error('item ' +
|
|
2300
|
+
entity.constructor.name +
|
|
2301
|
+
' was not initialized using a context');
|
|
2251
2302
|
return x;
|
|
2252
2303
|
}
|
|
2253
2304
|
exports.getEntityRef = getEntityRef;
|
|
2254
2305
|
exports.CaptionTransformer = {
|
|
2255
|
-
transformCaption: function (remult, key, caption) { return caption; }
|
|
2306
|
+
transformCaption: function (remult, key, caption) { return caption; },
|
|
2256
2307
|
};
|
|
2257
2308
|
function buildCaption(caption, key, remult) {
|
|
2258
2309
|
var result;
|
|
2259
|
-
if (typeof
|
|
2310
|
+
if (typeof caption === 'function') {
|
|
2260
2311
|
if (remult)
|
|
2261
2312
|
result = caption(remult);
|
|
2262
2313
|
}
|
|
@@ -2279,12 +2330,12 @@ var columnDefsImpl = /** @class */ (function () {
|
|
|
2279
2330
|
this.target = this.settings.target;
|
|
2280
2331
|
this.valueConverter = this.settings.valueConverter;
|
|
2281
2332
|
this.allowNull = !!this.settings.allowNull;
|
|
2282
|
-
this.inputType = this.settings.inputType;
|
|
2283
|
-
this.key = this.settings.key;
|
|
2284
2333
|
this.valueType = this.settings.valueType;
|
|
2334
|
+
this.key = this.settings.key;
|
|
2335
|
+
this.inputType = this.settings.inputType;
|
|
2285
2336
|
if (settings.serverExpression)
|
|
2286
2337
|
this.isServerExpression = true;
|
|
2287
|
-
if (typeof
|
|
2338
|
+
if (typeof this.settings.allowApiUpdate === 'boolean')
|
|
2288
2339
|
this.readonly = this.settings.allowApiUpdate;
|
|
2289
2340
|
if (!this.inputType)
|
|
2290
2341
|
this.inputType = this.valueConverter.inputType;
|
|
@@ -2296,7 +2347,9 @@ var columnDefsImpl = /** @class */ (function () {
|
|
|
2296
2347
|
return this.remult.isAllowedForInstance(item, this.options.allowApiUpdate);
|
|
2297
2348
|
};
|
|
2298
2349
|
columnDefsImpl.prototype.displayValue = function (item) {
|
|
2299
|
-
return this.
|
|
2350
|
+
return this.entityDefs
|
|
2351
|
+
.getEntityMetadataWithoutBreakingTheEntity(item)
|
|
2352
|
+
.fields.find(this.key).displayValue;
|
|
2300
2353
|
};
|
|
2301
2354
|
Object.defineProperty(columnDefsImpl.prototype, "includedInApi", {
|
|
2302
2355
|
get: function () {
|
|
@@ -2322,7 +2375,7 @@ var columnDefsImpl = /** @class */ (function () {
|
|
|
2322
2375
|
_a.trys.push([0, , 5, 6]);
|
|
2323
2376
|
if (!this.settings.sqlExpression) return [3 /*break*/, 4];
|
|
2324
2377
|
result = void 0;
|
|
2325
|
-
if (!(typeof this.settings.sqlExpression ===
|
|
2378
|
+
if (!(typeof this.settings.sqlExpression === 'function')) return [3 /*break*/, 2];
|
|
2326
2379
|
return [4 /*yield*/, this.settings.sqlExpression(this.entityDefs)];
|
|
2327
2380
|
case 1:
|
|
2328
2381
|
result = _a.sent();
|
|
@@ -2345,7 +2398,7 @@ var columnDefsImpl = /** @class */ (function () {
|
|
|
2345
2398
|
get: function () {
|
|
2346
2399
|
var result;
|
|
2347
2400
|
if (this.settings.sqlExpression) {
|
|
2348
|
-
if (typeof this.settings.sqlExpression ===
|
|
2401
|
+
if (typeof this.settings.sqlExpression === 'function') {
|
|
2349
2402
|
result = this.settings.sqlExpression(this.entityDefs);
|
|
2350
2403
|
}
|
|
2351
2404
|
else
|
|
@@ -2365,7 +2418,6 @@ var columnDefsImpl = /** @class */ (function () {
|
|
|
2365
2418
|
enumerable: false,
|
|
2366
2419
|
configurable: true
|
|
2367
2420
|
});
|
|
2368
|
-
;
|
|
2369
2421
|
return columnDefsImpl;
|
|
2370
2422
|
}());
|
|
2371
2423
|
exports.columnDefsImpl = columnDefsImpl;
|
|
@@ -2378,7 +2430,6 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
2378
2430
|
this.remult = remult;
|
|
2379
2431
|
this.entityType = entityType;
|
|
2380
2432
|
this.key = key;
|
|
2381
|
-
this.options = this.entityInfo;
|
|
2382
2433
|
this.idMetadata = {
|
|
2383
2434
|
getId: function (item) {
|
|
2384
2435
|
if (_this.idMetadata.field instanceof column_1.CompoundIdField)
|
|
@@ -2390,7 +2441,9 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
2390
2441
|
createIdInFilter: function (items) {
|
|
2391
2442
|
if (items.length > 0)
|
|
2392
2443
|
return {
|
|
2393
|
-
$or: items.map(function (x) {
|
|
2444
|
+
$or: items.map(function (x) {
|
|
2445
|
+
return _this.idMetadata.getIdFilter(getEntityRef(x).getId());
|
|
2446
|
+
}),
|
|
2394
2447
|
};
|
|
2395
2448
|
},
|
|
2396
2449
|
isIdField: function (col) {
|
|
@@ -2405,7 +2458,7 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
2405
2458
|
if (_this.idMetadata.field instanceof column_1.CompoundIdField) {
|
|
2406
2459
|
var field_1 = _this.idMetadata.field;
|
|
2407
2460
|
return {
|
|
2408
|
-
$or: ids.map(function (x) { return field_1.isEqualTo(x); })
|
|
2461
|
+
$or: ids.map(function (x) { return field_1.isEqualTo(x); }),
|
|
2409
2462
|
};
|
|
2410
2463
|
}
|
|
2411
2464
|
if (ids.length == 1)
|
|
@@ -2416,15 +2469,21 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
2416
2469
|
return _b = {},
|
|
2417
2470
|
_b[_this.idMetadata.field.key] = ids,
|
|
2418
2471
|
_b;
|
|
2419
|
-
}
|
|
2472
|
+
},
|
|
2420
2473
|
};
|
|
2474
|
+
this.options = entityInfo;
|
|
2421
2475
|
if (this.options.allowApiCrud !== undefined) {
|
|
2476
|
+
var crud = void 0;
|
|
2477
|
+
if (typeof this.options.allowApiCrud === 'function')
|
|
2478
|
+
crud = function (_, remult) { return _this.options.allowApiCrud(remult); };
|
|
2479
|
+
else
|
|
2480
|
+
crud = this.options.allowApiCrud;
|
|
2422
2481
|
if (this.options.allowApiDelete === undefined)
|
|
2423
|
-
this.options.allowApiDelete =
|
|
2482
|
+
this.options.allowApiDelete = crud;
|
|
2424
2483
|
if (this.options.allowApiInsert === undefined)
|
|
2425
|
-
this.options.allowApiInsert =
|
|
2484
|
+
this.options.allowApiInsert = crud;
|
|
2426
2485
|
if (this.options.allowApiUpdate === undefined)
|
|
2427
|
-
this.options.allowApiUpdate =
|
|
2486
|
+
this.options.allowApiUpdate = crud;
|
|
2428
2487
|
if (this.options.allowApiRead === undefined)
|
|
2429
2488
|
this.options.allowApiRead = this.options.allowApiCrud;
|
|
2430
2489
|
}
|
|
@@ -2436,7 +2495,9 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
2436
2495
|
entityInfo.dbName = this.key;
|
|
2437
2496
|
var _items = [];
|
|
2438
2497
|
var r = (_a = {
|
|
2439
|
-
find: function (c) {
|
|
2498
|
+
find: function (c) {
|
|
2499
|
+
return r[typeof c === 'string' ? c : c.key];
|
|
2500
|
+
}
|
|
2440
2501
|
},
|
|
2441
2502
|
_a[Symbol.iterator] = function () { return _items[Symbol.iterator](); },
|
|
2442
2503
|
_a.toArray = function () { return _items; },
|
|
@@ -2444,7 +2505,7 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
2444
2505
|
try {
|
|
2445
2506
|
for (var columnsInfo_3 = tslib_1.__values(columnsInfo), columnsInfo_3_1 = columnsInfo_3.next(); !columnsInfo_3_1.done; columnsInfo_3_1 = columnsInfo_3.next()) {
|
|
2446
2507
|
var x = columnsInfo_3_1.value;
|
|
2447
|
-
_items.push(r[x.key] = new columnDefsImpl(x, this, remult));
|
|
2508
|
+
_items.push((r[x.key] = new columnDefsImpl(x, this, remult)));
|
|
2448
2509
|
}
|
|
2449
2510
|
}
|
|
2450
2511
|
catch (e_37_1) { e_37 = { error: e_37_1 }; }
|
|
@@ -2468,8 +2529,8 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
2468
2529
|
this.idMetadata.field = r_2;
|
|
2469
2530
|
}
|
|
2470
2531
|
else {
|
|
2471
|
-
if (this.fields[
|
|
2472
|
-
this.idMetadata.field = this.fields[
|
|
2532
|
+
if (this.fields['id'])
|
|
2533
|
+
this.idMetadata.field = this.fields['id'];
|
|
2473
2534
|
else
|
|
2474
2535
|
this.idMetadata.field = tslib_1.__spread(this.fields)[0];
|
|
2475
2536
|
}
|
|
@@ -2477,7 +2538,9 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
2477
2538
|
EntityFullInfo.prototype.apiUpdateAllowed = function (item) {
|
|
2478
2539
|
if (this.options.allowApiUpdate === undefined)
|
|
2479
2540
|
return false;
|
|
2480
|
-
return !item
|
|
2541
|
+
return !item
|
|
2542
|
+
? this.remult.isAllowedForInstance(undefined, this.options.allowApiUpdate)
|
|
2543
|
+
: this.getEntityMetadataWithoutBreakingTheEntity(item).apiUpdateAllowed;
|
|
2481
2544
|
};
|
|
2482
2545
|
Object.defineProperty(EntityFullInfo.prototype, "apiReadAllowed", {
|
|
2483
2546
|
get: function () {
|
|
@@ -2491,12 +2554,22 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
2491
2554
|
EntityFullInfo.prototype.apiDeleteAllowed = function (item) {
|
|
2492
2555
|
if (this.options.allowApiDelete === undefined)
|
|
2493
2556
|
return false;
|
|
2494
|
-
return !item
|
|
2557
|
+
return !item
|
|
2558
|
+
? this.remult.isAllowedForInstance(undefined, this.options.allowApiDelete)
|
|
2559
|
+
: this.getEntityMetadataWithoutBreakingTheEntity(item).apiDeleteAllowed;
|
|
2495
2560
|
};
|
|
2496
2561
|
EntityFullInfo.prototype.apiInsertAllowed = function (item) {
|
|
2497
2562
|
if (this.options.allowApiUpdate === undefined)
|
|
2498
2563
|
return false;
|
|
2499
|
-
return !item
|
|
2564
|
+
return !item
|
|
2565
|
+
? this.remult.isAllowedForInstance(undefined, this.options.allowApiInsert)
|
|
2566
|
+
: this.getEntityMetadataWithoutBreakingTheEntity(item).apiInsertAllowed;
|
|
2567
|
+
};
|
|
2568
|
+
EntityFullInfo.prototype.getEntityMetadataWithoutBreakingTheEntity = function (item) {
|
|
2569
|
+
var result = getEntityRef(item, false);
|
|
2570
|
+
if (result)
|
|
2571
|
+
return result;
|
|
2572
|
+
return this.remult.repo(this.entityType).getEntityRef(tslib_1.__assign({}, item));
|
|
2500
2573
|
};
|
|
2501
2574
|
EntityFullInfo.prototype.getDbName = function () {
|
|
2502
2575
|
var _this = this;
|
|
@@ -2505,9 +2578,9 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
2505
2578
|
if (!this.options.sqlExpression) {
|
|
2506
2579
|
this.dbNamePromise = Promise.resolve(this.options.dbName);
|
|
2507
2580
|
}
|
|
2508
|
-
if (typeof this.options.sqlExpression ===
|
|
2581
|
+
if (typeof this.options.sqlExpression === 'string')
|
|
2509
2582
|
this.dbNamePromise = Promise.resolve(this.options.sqlExpression);
|
|
2510
|
-
else if (typeof this.options.sqlExpression ===
|
|
2583
|
+
else if (typeof this.options.sqlExpression === 'function') {
|
|
2511
2584
|
var r = this.options.sqlExpression(this);
|
|
2512
2585
|
if (r instanceof Promise)
|
|
2513
2586
|
this.dbNamePromise = r;
|
|
@@ -2528,7 +2601,7 @@ function FieldType() {
|
|
|
2528
2601
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2529
2602
|
options[_i] = arguments[_i];
|
|
2530
2603
|
}
|
|
2531
|
-
return function (target) {
|
|
2604
|
+
return function (target, context) {
|
|
2532
2605
|
if (!options) {
|
|
2533
2606
|
options = [];
|
|
2534
2607
|
}
|
|
@@ -2543,7 +2616,7 @@ var Fields = /** @class */ (function () {
|
|
|
2543
2616
|
}
|
|
2544
2617
|
/**
|
|
2545
2618
|
* Stored as a JSON.stringify - to store as json use Fields.json
|
|
2546
|
-
|
|
2619
|
+
*/
|
|
2547
2620
|
Fields.object = function () {
|
|
2548
2621
|
var options = [];
|
|
2549
2622
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -2556,10 +2629,11 @@ var Fields = /** @class */ (function () {
|
|
|
2556
2629
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2557
2630
|
options[_i] = arguments[_i];
|
|
2558
2631
|
}
|
|
2559
|
-
return Field.apply(void 0, tslib_1.__spread([undefined,
|
|
2632
|
+
return Field.apply(void 0, tslib_1.__spread([undefined,
|
|
2633
|
+
{
|
|
2560
2634
|
valueConverter: {
|
|
2561
|
-
fieldTypeInDb:
|
|
2562
|
-
}
|
|
2635
|
+
fieldTypeInDb: 'json',
|
|
2636
|
+
},
|
|
2563
2637
|
}], options));
|
|
2564
2638
|
};
|
|
2565
2639
|
Fields.dateOnly = function () {
|
|
@@ -2568,7 +2642,7 @@ var Fields = /** @class */ (function () {
|
|
|
2568
2642
|
options[_i] = arguments[_i];
|
|
2569
2643
|
}
|
|
2570
2644
|
return Field.apply(void 0, tslib_1.__spread([function () { return Date; }, {
|
|
2571
|
-
valueConverter: valueConverters_1.ValueConverters.DateOnly
|
|
2645
|
+
valueConverter: valueConverters_1.ValueConverters.DateOnly,
|
|
2572
2646
|
}], options));
|
|
2573
2647
|
};
|
|
2574
2648
|
Fields.date = function () {
|
|
@@ -2584,7 +2658,7 @@ var Fields = /** @class */ (function () {
|
|
|
2584
2658
|
options[_i] = arguments[_i];
|
|
2585
2659
|
}
|
|
2586
2660
|
return Field.apply(void 0, tslib_1.__spread([function () { return Number; }, {
|
|
2587
|
-
valueConverter: valueConverters_1.ValueConverters.Integer
|
|
2661
|
+
valueConverter: valueConverters_1.ValueConverters.Integer,
|
|
2588
2662
|
}], options));
|
|
2589
2663
|
};
|
|
2590
2664
|
Fields.autoIncrement = function () {
|
|
@@ -2592,10 +2666,11 @@ var Fields = /** @class */ (function () {
|
|
|
2592
2666
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2593
2667
|
options[_i] = arguments[_i];
|
|
2594
2668
|
}
|
|
2595
|
-
return Field.apply(void 0, tslib_1.__spread([function () { return Number; },
|
|
2669
|
+
return Field.apply(void 0, tslib_1.__spread([function () { return Number; },
|
|
2670
|
+
{
|
|
2596
2671
|
allowApiUpdate: false,
|
|
2597
2672
|
dbReadOnly: true,
|
|
2598
|
-
valueConverter: tslib_1.__assign(tslib_1.__assign({}, valueConverters_1.ValueConverters.Integer), { fieldTypeInDb: 'autoincrement' })
|
|
2673
|
+
valueConverter: tslib_1.__assign(tslib_1.__assign({}, valueConverters_1.ValueConverters.Integer), { fieldTypeInDb: 'autoincrement' }),
|
|
2599
2674
|
}], options));
|
|
2600
2675
|
};
|
|
2601
2676
|
Fields.number = function () {
|
|
@@ -2610,12 +2685,13 @@ var Fields = /** @class */ (function () {
|
|
|
2610
2685
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2611
2686
|
options[_i] = arguments[_i];
|
|
2612
2687
|
}
|
|
2613
|
-
return Field.apply(void 0, tslib_1.__spread([function () { return Date; },
|
|
2688
|
+
return Field.apply(void 0, tslib_1.__spread([function () { return Date; },
|
|
2689
|
+
{
|
|
2614
2690
|
allowApiUpdate: false,
|
|
2615
2691
|
saving: function (_, ref) {
|
|
2616
2692
|
if (getEntityRef(_).isNew())
|
|
2617
2693
|
ref.value = new Date();
|
|
2618
|
-
}
|
|
2694
|
+
},
|
|
2619
2695
|
}], options));
|
|
2620
2696
|
};
|
|
2621
2697
|
Fields.updatedAt = function () {
|
|
@@ -2623,11 +2699,12 @@ var Fields = /** @class */ (function () {
|
|
|
2623
2699
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2624
2700
|
options[_i] = arguments[_i];
|
|
2625
2701
|
}
|
|
2626
|
-
return Field.apply(void 0, tslib_1.__spread([function () { return Date; },
|
|
2702
|
+
return Field.apply(void 0, tslib_1.__spread([function () { return Date; },
|
|
2703
|
+
{
|
|
2627
2704
|
allowApiUpdate: false,
|
|
2628
2705
|
saving: function (_, ref) {
|
|
2629
2706
|
ref.value = new Date();
|
|
2630
|
-
}
|
|
2707
|
+
},
|
|
2631
2708
|
}], options));
|
|
2632
2709
|
};
|
|
2633
2710
|
Fields.uuid = function () {
|
|
@@ -2635,13 +2712,14 @@ var Fields = /** @class */ (function () {
|
|
|
2635
2712
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2636
2713
|
options[_i] = arguments[_i];
|
|
2637
2714
|
}
|
|
2638
|
-
return Field.apply(void 0, tslib_1.__spread([function () { return String; },
|
|
2715
|
+
return Field.apply(void 0, tslib_1.__spread([function () { return String; },
|
|
2716
|
+
{
|
|
2639
2717
|
allowApiUpdate: false,
|
|
2640
2718
|
defaultValue: function () { return uuid_1.v4(); },
|
|
2641
2719
|
saving: function (_, r) {
|
|
2642
2720
|
if (!r.value)
|
|
2643
2721
|
r.value = uuid_1.v4();
|
|
2644
|
-
}
|
|
2722
|
+
},
|
|
2645
2723
|
}], options));
|
|
2646
2724
|
};
|
|
2647
2725
|
Fields.cuid = function () {
|
|
@@ -2649,13 +2727,14 @@ var Fields = /** @class */ (function () {
|
|
|
2649
2727
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2650
2728
|
options[_i] = arguments[_i];
|
|
2651
2729
|
}
|
|
2652
|
-
return Field.apply(void 0, tslib_1.__spread([function () { return String; },
|
|
2730
|
+
return Field.apply(void 0, tslib_1.__spread([function () { return String; },
|
|
2731
|
+
{
|
|
2653
2732
|
allowApiUpdate: false,
|
|
2654
|
-
defaultValue: function () { return
|
|
2733
|
+
defaultValue: function () { return cuid2_1.createId(); },
|
|
2655
2734
|
saving: function (_, r) {
|
|
2656
2735
|
if (!r.value)
|
|
2657
|
-
r.value =
|
|
2658
|
-
}
|
|
2736
|
+
r.value = cuid2_1.createId();
|
|
2737
|
+
},
|
|
2659
2738
|
}], options));
|
|
2660
2739
|
};
|
|
2661
2740
|
Fields.string = function () {
|
|
@@ -2685,11 +2764,12 @@ function ValueListFieldType() {
|
|
|
2685
2764
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2686
2765
|
options[_i] = arguments[_i];
|
|
2687
2766
|
}
|
|
2688
|
-
return function (type) {
|
|
2767
|
+
return function (type, context) {
|
|
2689
2768
|
FieldType.apply(void 0, tslib_1.__spread([function (o) {
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2769
|
+
;
|
|
2770
|
+
(o.valueConverter = ValueListInfo.get(type)),
|
|
2771
|
+
(o.displayValue = function (item, val) { return val === null || val === void 0 ? void 0 : val.caption; });
|
|
2772
|
+
}], options))(type, context);
|
|
2693
2773
|
};
|
|
2694
2774
|
}
|
|
2695
2775
|
exports.ValueListFieldType = ValueListFieldType;
|
|
@@ -2744,7 +2824,8 @@ var ValueListInfo = /** @class */ (function () {
|
|
|
2744
2824
|
throw new Error("ValueType " + this.valueListType + " has values without an id");
|
|
2745
2825
|
}
|
|
2746
2826
|
else
|
|
2747
|
-
throw new Error("ValueType not yet initialized, did you forget to call @ValueListFieldType on " +
|
|
2827
|
+
throw new Error("ValueType not yet initialized, did you forget to call @ValueListFieldType on " +
|
|
2828
|
+
valueListType);
|
|
2748
2829
|
}
|
|
2749
2830
|
ValueListInfo.get = function (type) {
|
|
2750
2831
|
var r = typeCache.get(type);
|
|
@@ -2820,11 +2901,13 @@ exports.getValueList = getValueList;
|
|
|
2820
2901
|
* title='';
|
|
2821
2902
|
*/
|
|
2822
2903
|
function Field(valueType) {
|
|
2904
|
+
// IMPORTANT!!!! if you call this in another decorator, make sure to set It's return type correctly with the | undefined
|
|
2823
2905
|
var options = [];
|
|
2824
2906
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2825
2907
|
options[_i - 1] = arguments[_i];
|
|
2826
2908
|
}
|
|
2827
|
-
return function (target,
|
|
2909
|
+
return function (target, context, c) {
|
|
2910
|
+
var key = typeof context === 'string' ? context : context.name.toString();
|
|
2828
2911
|
var factory = function (remult) {
|
|
2829
2912
|
var r = buildOptions(options, remult);
|
|
2830
2913
|
if (!r.valueType && valueType) {
|
|
@@ -2837,13 +2920,14 @@ function Field(valueType) {
|
|
|
2837
2920
|
r.dbName = r.key;
|
|
2838
2921
|
var type = r.valueType;
|
|
2839
2922
|
if (!type) {
|
|
2840
|
-
type = Reflect.getMetadata(
|
|
2923
|
+
type = Reflect.getMetadata('design:type', target, key);
|
|
2841
2924
|
r.valueType = type;
|
|
2842
2925
|
}
|
|
2843
2926
|
if (!r.target)
|
|
2844
2927
|
r.target = target;
|
|
2845
2928
|
return r;
|
|
2846
2929
|
};
|
|
2930
|
+
checkTarget(target);
|
|
2847
2931
|
var names = exports.columnsOfType.get(target.constructor);
|
|
2848
2932
|
if (!names) {
|
|
2849
2933
|
names = [];
|
|
@@ -2866,7 +2950,7 @@ function Field(valueType) {
|
|
|
2866
2950
|
};
|
|
2867
2951
|
}
|
|
2868
2952
|
exports.Field = Field;
|
|
2869
|
-
exports.storableMember = Symbol(
|
|
2953
|
+
exports.storableMember = Symbol('storableMember');
|
|
2870
2954
|
function buildOptions(options, remult) {
|
|
2871
2955
|
var e_39, _a;
|
|
2872
2956
|
var r = {};
|
|
@@ -2874,7 +2958,7 @@ function buildOptions(options, remult) {
|
|
|
2874
2958
|
for (var options_2 = tslib_1.__values(options), options_2_1 = options_2.next(); !options_2_1.done; options_2_1 = options_2.next()) {
|
|
2875
2959
|
var o = options_2_1.value;
|
|
2876
2960
|
if (o) {
|
|
2877
|
-
if (typeof o ===
|
|
2961
|
+
if (typeof o === 'function')
|
|
2878
2962
|
o(r, remult);
|
|
2879
2963
|
else
|
|
2880
2964
|
Object.assign(r, o);
|
|
@@ -2921,10 +3005,44 @@ function decorateColumnSettings(settings, remult) {
|
|
|
2921
3005
|
if (!settings.valueConverter) {
|
|
2922
3006
|
var ei = getEntitySettings(settings.valueType, false);
|
|
2923
3007
|
if (ei) {
|
|
3008
|
+
var isIdNumeric_1 = undefined;
|
|
2924
3009
|
settings.valueConverter = {
|
|
2925
3010
|
toDb: function (x) { return x; },
|
|
2926
|
-
fromDb: function (x) { return x; }
|
|
3011
|
+
fromDb: function (x) { return x; },
|
|
2927
3012
|
};
|
|
3013
|
+
settings.valueConverter = new Proxy(settings.valueConverter, {
|
|
3014
|
+
get: function (target, property) {
|
|
3015
|
+
var e_40, _a;
|
|
3016
|
+
if (target[property] === undefined) {
|
|
3017
|
+
if (isIdNumeric_1 === undefined) {
|
|
3018
|
+
isIdNumeric_1 =
|
|
3019
|
+
remult.repo(settings.valueType).metadata.idMetadata.field
|
|
3020
|
+
.valueType === Number;
|
|
3021
|
+
try {
|
|
3022
|
+
for (var _b = tslib_1.__values([
|
|
3023
|
+
'fieldTypeInDb',
|
|
3024
|
+
]), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3025
|
+
var key = _c.value;
|
|
3026
|
+
//@ts-ignore
|
|
3027
|
+
target[key] = valueConverters_1.ValueConverters.Integer[key];
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
catch (e_40_1) { e_40 = { error: e_40_1 }; }
|
|
3031
|
+
finally {
|
|
3032
|
+
try {
|
|
3033
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3034
|
+
}
|
|
3035
|
+
finally { if (e_40) throw e_40.error; }
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
return target[property];
|
|
3040
|
+
},
|
|
3041
|
+
set: function (target, property, value, receiver) {
|
|
3042
|
+
target[property] = value;
|
|
3043
|
+
return true;
|
|
3044
|
+
},
|
|
3045
|
+
});
|
|
2928
3046
|
}
|
|
2929
3047
|
else
|
|
2930
3048
|
settings.valueConverter = valueConverters_1.ValueConverters.Default;
|
|
@@ -2945,11 +3063,14 @@ function decorateColumnSettings(settings, remult) {
|
|
|
2945
3063
|
settings.valueConverter.toInput = function (x) { return settings.valueConverter.toJson(x); };
|
|
2946
3064
|
}
|
|
2947
3065
|
if (!settings.valueConverter.fromInput) {
|
|
2948
|
-
settings.valueConverter.fromInput = function (x) {
|
|
3066
|
+
settings.valueConverter.fromInput = function (x) {
|
|
3067
|
+
return settings.valueConverter.fromJson(x);
|
|
3068
|
+
};
|
|
2949
3069
|
}
|
|
2950
3070
|
return settings;
|
|
2951
3071
|
}
|
|
2952
3072
|
exports.decorateColumnSettings = decorateColumnSettings;
|
|
3073
|
+
//[ ] YONI - in Typescript 5 I do get the name of the class, what would we like to change because of that?
|
|
2953
3074
|
/**Decorates classes that should be used as entities.
|
|
2954
3075
|
* Receives a key and an array of EntityOptions.
|
|
2955
3076
|
* @example
|
|
@@ -2979,7 +3100,7 @@ function Entity(key) {
|
|
|
2979
3100
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2980
3101
|
options[_i - 1] = arguments[_i];
|
|
2981
3102
|
}
|
|
2982
|
-
return function (target) {
|
|
3103
|
+
return function (target, info) {
|
|
2983
3104
|
var _a;
|
|
2984
3105
|
for (var rawFilterMember in target) {
|
|
2985
3106
|
if (Object.prototype.hasOwnProperty.call(target, rawFilterMember)) {
|
|
@@ -2991,25 +3112,25 @@ function Entity(key) {
|
|
|
2991
3112
|
}
|
|
2992
3113
|
}
|
|
2993
3114
|
var factory = function (remult) {
|
|
2994
|
-
var
|
|
3115
|
+
var e_41, _a;
|
|
2995
3116
|
var r = {};
|
|
2996
3117
|
try {
|
|
2997
3118
|
for (var options_3 = tslib_1.__values(options), options_3_1 = options_3.next(); !options_3_1.done; options_3_1 = options_3.next()) {
|
|
2998
3119
|
var o = options_3_1.value;
|
|
2999
3120
|
if (o) {
|
|
3000
|
-
if (typeof o ===
|
|
3121
|
+
if (typeof o === 'function')
|
|
3001
3122
|
o(r, remult);
|
|
3002
3123
|
else
|
|
3003
3124
|
Object.assign(r, o);
|
|
3004
3125
|
}
|
|
3005
3126
|
}
|
|
3006
3127
|
}
|
|
3007
|
-
catch (
|
|
3128
|
+
catch (e_41_1) { e_41 = { error: e_41_1 }; }
|
|
3008
3129
|
finally {
|
|
3009
3130
|
try {
|
|
3010
3131
|
if (options_3_1 && !options_3_1.done && (_a = options_3.return)) _a.call(options_3);
|
|
3011
3132
|
}
|
|
3012
|
-
finally { if (
|
|
3133
|
+
finally { if (e_41) throw e_41.error; }
|
|
3013
3134
|
}
|
|
3014
3135
|
var base = Object.getPrototypeOf(target);
|
|
3015
3136
|
if (base) {
|
|
@@ -3035,19 +3156,29 @@ var EntityBase = /** @class */ (function () {
|
|
|
3035
3156
|
function EntityBase() {
|
|
3036
3157
|
}
|
|
3037
3158
|
Object.defineProperty(EntityBase.prototype, "_", {
|
|
3038
|
-
get: function () {
|
|
3159
|
+
get: function () {
|
|
3160
|
+
return getEntityRef(this);
|
|
3161
|
+
},
|
|
3039
3162
|
enumerable: false,
|
|
3040
3163
|
configurable: true
|
|
3041
3164
|
});
|
|
3042
|
-
EntityBase.prototype.save = function () {
|
|
3165
|
+
EntityBase.prototype.save = function () {
|
|
3166
|
+
return this._.save();
|
|
3167
|
+
};
|
|
3043
3168
|
EntityBase.prototype.assign = function (values) {
|
|
3044
3169
|
assign_1.assign(this, values);
|
|
3045
3170
|
return this;
|
|
3046
3171
|
};
|
|
3047
|
-
EntityBase.prototype.delete = function () {
|
|
3048
|
-
|
|
3172
|
+
EntityBase.prototype.delete = function () {
|
|
3173
|
+
return this._.delete();
|
|
3174
|
+
};
|
|
3175
|
+
EntityBase.prototype.isNew = function () {
|
|
3176
|
+
return this._.isNew();
|
|
3177
|
+
};
|
|
3049
3178
|
Object.defineProperty(EntityBase.prototype, "$", {
|
|
3050
|
-
get: function () {
|
|
3179
|
+
get: function () {
|
|
3180
|
+
return this._.fields;
|
|
3181
|
+
},
|
|
3051
3182
|
enumerable: false,
|
|
3052
3183
|
configurable: true
|
|
3053
3184
|
});
|
|
@@ -3075,12 +3206,16 @@ var ControllerBase = /** @class */ (function () {
|
|
|
3075
3206
|
return this;
|
|
3076
3207
|
};
|
|
3077
3208
|
Object.defineProperty(ControllerBase.prototype, "$", {
|
|
3078
|
-
get: function () {
|
|
3209
|
+
get: function () {
|
|
3210
|
+
return getFields(this, this.remult);
|
|
3211
|
+
},
|
|
3079
3212
|
enumerable: false,
|
|
3080
3213
|
configurable: true
|
|
3081
3214
|
});
|
|
3082
3215
|
Object.defineProperty(ControllerBase.prototype, "_", {
|
|
3083
|
-
get: function () {
|
|
3216
|
+
get: function () {
|
|
3217
|
+
return getControllerRef(this, this.remult);
|
|
3218
|
+
},
|
|
3084
3219
|
enumerable: false,
|
|
3085
3220
|
configurable: true
|
|
3086
3221
|
});
|
|
@@ -3108,7 +3243,7 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3108
3243
|
orderBy: this.options.orderBy,
|
|
3109
3244
|
limit: this.options.pageSize,
|
|
3110
3245
|
page: page,
|
|
3111
|
-
load: this.options.load
|
|
3246
|
+
load: this.options.load,
|
|
3112
3247
|
})];
|
|
3113
3248
|
});
|
|
3114
3249
|
});
|
|
@@ -3131,9 +3266,9 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3131
3266
|
});
|
|
3132
3267
|
};
|
|
3133
3268
|
QueryResultImpl.prototype.forEach = function (what) {
|
|
3134
|
-
var
|
|
3269
|
+
var e_42, _a;
|
|
3135
3270
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
3136
|
-
var i, _b, _c, x,
|
|
3271
|
+
var i, _b, _c, x, e_42_1;
|
|
3137
3272
|
return tslib_1.__generator(this, function (_d) {
|
|
3138
3273
|
switch (_d.label) {
|
|
3139
3274
|
case 0:
|
|
@@ -3155,8 +3290,8 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3155
3290
|
case 5: return [3 /*break*/, 2];
|
|
3156
3291
|
case 6: return [3 /*break*/, 13];
|
|
3157
3292
|
case 7:
|
|
3158
|
-
|
|
3159
|
-
|
|
3293
|
+
e_42_1 = _d.sent();
|
|
3294
|
+
e_42 = { error: e_42_1 };
|
|
3160
3295
|
return [3 /*break*/, 13];
|
|
3161
3296
|
case 8:
|
|
3162
3297
|
_d.trys.push([8, , 11, 12]);
|
|
@@ -3167,7 +3302,7 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3167
3302
|
_d.label = 10;
|
|
3168
3303
|
case 10: return [3 /*break*/, 12];
|
|
3169
3304
|
case 11:
|
|
3170
|
-
if (
|
|
3305
|
+
if (e_42) throw e_42.error;
|
|
3171
3306
|
return [7 /*endfinally*/];
|
|
3172
3307
|
case 12: return [7 /*endfinally*/];
|
|
3173
3308
|
case 13: return [2 /*return*/, i];
|
|
@@ -3184,10 +3319,12 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3184
3319
|
case 0:
|
|
3185
3320
|
this.options.orderBy = sort_1.Sort.createUniqueEntityOrderBy(this.repo.metadata, this.options.orderBy);
|
|
3186
3321
|
return [4 /*yield*/, this.repo.find({
|
|
3187
|
-
where: {
|
|
3322
|
+
where: {
|
|
3323
|
+
$and: [this.options.where, pNextPageFilter],
|
|
3324
|
+
},
|
|
3188
3325
|
orderBy: this.options.orderBy,
|
|
3189
3326
|
limit: this.options.pageSize,
|
|
3190
|
-
load: this.options.load
|
|
3327
|
+
load: this.options.load,
|
|
3191
3328
|
})];
|
|
3192
3329
|
case 1:
|
|
3193
3330
|
items = _a.sent();
|
|
@@ -3203,7 +3340,7 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3203
3340
|
count: function () { return _this.count(); },
|
|
3204
3341
|
hasNextPage: hasNextPage,
|
|
3205
3342
|
items: items,
|
|
3206
|
-
nextPage: nextPage
|
|
3343
|
+
nextPage: nextPage,
|
|
3207
3344
|
}];
|
|
3208
3345
|
}
|
|
3209
3346
|
});
|
|
@@ -3253,8 +3390,9 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3253
3390
|
}
|
|
3254
3391
|
else {
|
|
3255
3392
|
if ((prev === null || prev === void 0 ? void 0 : prev.items.length) > 0) {
|
|
3256
|
-
if (this.repo.getEntityRef(prev.items[0]).getId() ==
|
|
3257
|
-
|
|
3393
|
+
if (this.repo.getEntityRef(prev.items[0]).getId() ==
|
|
3394
|
+
this.repo.getEntityRef(currentPage.items[0]).getId())
|
|
3395
|
+
throw new Error('pagination failure, returned same first row');
|
|
3258
3396
|
}
|
|
3259
3397
|
}
|
|
3260
3398
|
_d.label = 7;
|
|
@@ -3272,7 +3410,7 @@ var QueryResultImpl = /** @class */ (function () {
|
|
|
3272
3410
|
r = itStrategy();
|
|
3273
3411
|
return [2 /*return*/, r];
|
|
3274
3412
|
});
|
|
3275
|
-
}); }
|
|
3413
|
+
}); },
|
|
3276
3414
|
};
|
|
3277
3415
|
};
|
|
3278
3416
|
return QueryResultImpl;
|
|
@@ -3297,10 +3435,10 @@ var SubscribableImp = /** @class */ (function () {
|
|
|
3297
3435
|
SubscribableImp.prototype.subscribe = function (listener) {
|
|
3298
3436
|
var _this = this;
|
|
3299
3437
|
var list;
|
|
3300
|
-
if (typeof listener ===
|
|
3438
|
+
if (typeof listener === 'function')
|
|
3301
3439
|
list = {
|
|
3302
3440
|
reportChanged: function () { return listener(); },
|
|
3303
|
-
reportObserved: function () { }
|
|
3441
|
+
reportObserved: function () { },
|
|
3304
3442
|
};
|
|
3305
3443
|
else
|
|
3306
3444
|
list = listener;
|
|
@@ -3308,7 +3446,9 @@ var SubscribableImp = /** @class */ (function () {
|
|
|
3308
3446
|
this._subscribers = [];
|
|
3309
3447
|
}
|
|
3310
3448
|
this._subscribers.push(list);
|
|
3311
|
-
return function () {
|
|
3449
|
+
return function () {
|
|
3450
|
+
return (_this._subscribers = _this._subscribers.filter(function (x) { return x != list; }));
|
|
3451
|
+
};
|
|
3312
3452
|
};
|
|
3313
3453
|
return SubscribableImp;
|
|
3314
3454
|
}());
|
|
@@ -3317,7 +3457,7 @@ function getEntityMetadata(entity) {
|
|
|
3317
3457
|
return entity.metadata;
|
|
3318
3458
|
var settings = getEntitySettings(entity, false);
|
|
3319
3459
|
if (settings) {
|
|
3320
|
-
return remult_proxy_1.
|
|
3460
|
+
return remult_proxy_1.remult.repo(entity).metadata;
|
|
3321
3461
|
}
|
|
3322
3462
|
return entity;
|
|
3323
3463
|
}
|
|
@@ -3325,8 +3465,13 @@ exports.getEntityMetadata = getEntityMetadata;
|
|
|
3325
3465
|
function getRepository(entity) {
|
|
3326
3466
|
var settings = getEntitySettings(entity, false);
|
|
3327
3467
|
if (settings) {
|
|
3328
|
-
return remult_proxy_1.
|
|
3468
|
+
return remult_proxy_1.remult.repo(entity);
|
|
3329
3469
|
}
|
|
3330
3470
|
return entity;
|
|
3331
3471
|
}
|
|
3332
3472
|
exports.getRepository = getRepository;
|
|
3473
|
+
function checkTarget(target) {
|
|
3474
|
+
if (!target)
|
|
3475
|
+
throw new Error("Set the 'experimentalDecorators:true' option in your 'tsconfig' or 'jsconfig' (target undefined)");
|
|
3476
|
+
}
|
|
3477
|
+
exports.checkTarget = checkTarget;
|