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,14 +1,12 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Action, actionInfo, classBackendMethodsArray, serverActionField } from '../src/server-action';
|
|
3
|
-
import { DataApi, serializeError } from '../src/data-api';
|
|
4
|
-
import { allEntities, Remult } from '../src/context';
|
|
5
|
-
import { Entity, Fields, getEntityKey, IdEntity } from '../src/remult3';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { liveQueryKeepAliveRoute, streamUrl } from '../src/live-query/SubscriptionChannel';
|
|
2
|
+
import { Action, actionInfo, classBackendMethodsArray, serverActionField, } from '../src/server-action';
|
|
3
|
+
import { DataApi, serializeError, } from '../src/data-api';
|
|
4
|
+
import { allEntities, Remult, RemultAsyncLocalStorage, } from '../src/context';
|
|
5
|
+
import { Entity, Fields, getEntityKey, IdEntity, } from '../src/remult3';
|
|
6
|
+
import { LiveQueryPublisher, InMemoryLiveQueryStorage, } from '../src/live-query/SubscriptionServer';
|
|
7
|
+
import { liveQueryKeepAliveRoute, streamUrl, } from '../src/live-query/SubscriptionChannel';
|
|
9
8
|
import { initDataProvider } from './initDataProvider';
|
|
10
|
-
import { SseSubscriptionServer } from
|
|
11
|
-
;
|
|
9
|
+
import { SseSubscriptionServer, } from '../SseSubscriptionServer';
|
|
12
10
|
export function createRemultServerCore(options, serverCoreOptions) {
|
|
13
11
|
if (!options) {
|
|
14
12
|
options = {};
|
|
@@ -40,21 +38,24 @@ export function createRemultServerCore(options, serverCoreOptions) {
|
|
|
40
38
|
if (started)
|
|
41
39
|
return;
|
|
42
40
|
started = true;
|
|
43
|
-
console.time(
|
|
41
|
+
console.time('Ensure Schema');
|
|
44
42
|
};
|
|
45
|
-
entitiesMetaData.push(...options.entities.map(e => remult.repo(e).metadata));
|
|
43
|
+
entitiesMetaData.push(...options.entities.map((e) => remult.repo(e).metadata));
|
|
46
44
|
if (dp.ensureSchema) {
|
|
47
45
|
startConsoleLog();
|
|
48
46
|
await dp.ensureSchema(entitiesMetaData);
|
|
49
47
|
}
|
|
50
|
-
for (const item of [
|
|
48
|
+
for (const item of [
|
|
49
|
+
options.liveQueryStorage,
|
|
50
|
+
options.queueStorage,
|
|
51
|
+
]) {
|
|
51
52
|
if (item?.ensureSchema) {
|
|
52
53
|
startConsoleLog();
|
|
53
54
|
await item.ensureSchema();
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
if (started)
|
|
57
|
-
console.timeEnd(
|
|
58
|
+
console.timeEnd('Ensure Schema');
|
|
58
59
|
}
|
|
59
60
|
if (options.initApi)
|
|
60
61
|
await options.initApi(remult);
|
|
@@ -79,37 +80,6 @@ export function createRemultServerCore(options, serverCoreOptions) {
|
|
|
79
80
|
let bridge = new RemultServerImplementation(new inProcessQueueHandler(options.queueStorage), options, dataProvider, serverCoreOptions, entitiesMetaData);
|
|
80
81
|
return bridge;
|
|
81
82
|
}
|
|
82
|
-
;
|
|
83
|
-
export class RemultAsyncLocalStorage {
|
|
84
|
-
constructor(remultObjectStorage) {
|
|
85
|
-
this.remultObjectStorage = remultObjectStorage;
|
|
86
|
-
}
|
|
87
|
-
static enable() {
|
|
88
|
-
remult.remultFactory = () => {
|
|
89
|
-
const r = RemultAsyncLocalStorage.instance.getRemult();
|
|
90
|
-
if (r)
|
|
91
|
-
return r;
|
|
92
|
-
else
|
|
93
|
-
throw new Error("remult object was requested outside of a valid context, try running it within initApi or a remult request cycle");
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
static disable() {
|
|
97
|
-
remult.resetFactory();
|
|
98
|
-
}
|
|
99
|
-
run(remult, callback) {
|
|
100
|
-
if (this.remultObjectStorage)
|
|
101
|
-
this.remultObjectStorage.run(remult, callback);
|
|
102
|
-
else
|
|
103
|
-
callback();
|
|
104
|
-
}
|
|
105
|
-
getRemult() {
|
|
106
|
-
if (!this.remultObjectStorage) {
|
|
107
|
-
throw new Error("can't use static remult in this environment, `async_hooks` were not initialized");
|
|
108
|
-
}
|
|
109
|
-
return this.remultObjectStorage.getStore();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
RemultAsyncLocalStorage.instance = new RemultAsyncLocalStorage(undefined);
|
|
113
83
|
/* @internal*/
|
|
114
84
|
export class RemultServerImplementation {
|
|
115
85
|
constructor(queue, options, dataProvider, coreOptions, entitiesMetaData) {
|
|
@@ -133,7 +103,7 @@ export class RemultServerImplementation {
|
|
|
133
103
|
},
|
|
134
104
|
set liveQueryStorage(value) {
|
|
135
105
|
remult.liveQueryStorage = value;
|
|
136
|
-
}
|
|
106
|
+
},
|
|
137
107
|
});
|
|
138
108
|
}
|
|
139
109
|
await what(remult.repo(e));
|
|
@@ -144,7 +114,9 @@ export class RemultServerImplementation {
|
|
|
144
114
|
throw new Error("Couldn't find entity " + entityKey);
|
|
145
115
|
};
|
|
146
116
|
this.withRemult = (req, res, next) => {
|
|
147
|
-
this.process(async () => {
|
|
117
|
+
this.process(async () => {
|
|
118
|
+
next();
|
|
119
|
+
})(req, res);
|
|
148
120
|
};
|
|
149
121
|
this.registeredRouter = false;
|
|
150
122
|
this.hasQueue = false;
|
|
@@ -170,9 +142,8 @@ export class RemultServerImplementation {
|
|
|
170
142
|
getEntities() {
|
|
171
143
|
//TODO - consider using entitiesMetaData - but it may require making it all awaitable
|
|
172
144
|
var r = new Remult();
|
|
173
|
-
return this.options.entities.map(x => r.repo(x).metadata);
|
|
145
|
+
return this.options.entities.map((x) => r.repo(x).metadata);
|
|
174
146
|
}
|
|
175
|
-
;
|
|
176
147
|
getRouteImpl() {
|
|
177
148
|
if (!this.routeImpl) {
|
|
178
149
|
this.routeImpl = new RouteImplementation(this.coreOptions);
|
|
@@ -185,7 +156,7 @@ export class RemultServerImplementation {
|
|
|
185
156
|
}
|
|
186
157
|
registerRouter(r) {
|
|
187
158
|
if (this.registeredRouter)
|
|
188
|
-
throw
|
|
159
|
+
throw 'Router already registered';
|
|
189
160
|
this.registeredRouter = true;
|
|
190
161
|
{
|
|
191
162
|
for (const c of this.options.controllers) {
|
|
@@ -201,7 +172,7 @@ export class RemultServerImplementation {
|
|
|
201
172
|
}
|
|
202
173
|
if (this.hasQueue)
|
|
203
174
|
this.addAction({
|
|
204
|
-
__register: x => {
|
|
175
|
+
__register: (x) => {
|
|
205
176
|
x(Action.apiUrlForJobStatus, false, () => true, async (data, req, res) => {
|
|
206
177
|
let job = await this.queue.getJobInfo(data.queuedJobId);
|
|
207
178
|
let userId = undefined;
|
|
@@ -215,17 +186,19 @@ export class RemultServerImplementation {
|
|
|
215
186
|
res.success(job.info);
|
|
216
187
|
});
|
|
217
188
|
},
|
|
218
|
-
doWork: undefined
|
|
189
|
+
doWork: undefined,
|
|
219
190
|
}, r);
|
|
220
191
|
if (this.options.subscriptionServer instanceof SseSubscriptionServer) {
|
|
221
192
|
const streamPath = this.options.rootPath + '/' + streamUrl;
|
|
222
193
|
r.route(streamPath).get(this.process(async (remult, req, res, origReq, origRes) => {
|
|
194
|
+
;
|
|
223
195
|
remult.subscriptionServer.openHttpServerStream(origReq, origRes);
|
|
224
196
|
}));
|
|
225
197
|
r.route(streamPath + '/subscribe').post(this.process(async (remult, req, res, reqInfo, origRes, origReq) => {
|
|
226
198
|
const body = remult.subscriptionServer.subscribeToChannel(await this.coreOptions.getRequestBody(origReq), res, remult);
|
|
227
199
|
}));
|
|
228
200
|
r.route(streamPath + '/unsubscribe').post(this.process(async (remult, req, res, reqInfo, origRes, origReq) => {
|
|
201
|
+
;
|
|
229
202
|
remult.subscriptionServer.subscribeToChannel(await this.coreOptions.getRequestBody(origReq), res, remult, true);
|
|
230
203
|
}));
|
|
231
204
|
}
|
|
@@ -233,10 +206,10 @@ export class RemultServerImplementation {
|
|
|
233
206
|
res.success(await remult.liveQueryStorage.keepAliveAndReturnUnknownQueryIds(await this.coreOptions.getRequestBody(origReq)));
|
|
234
207
|
}));
|
|
235
208
|
}
|
|
236
|
-
this.options.entities.forEach(e => {
|
|
209
|
+
this.options.entities.forEach((e) => {
|
|
237
210
|
let key = getEntityKey(e);
|
|
238
211
|
if (key != undefined)
|
|
239
|
-
this.add(key, c => {
|
|
212
|
+
this.add(key, (c) => {
|
|
240
213
|
return new DataApi(c.repo(e), c);
|
|
241
214
|
}, r);
|
|
242
215
|
});
|
|
@@ -244,7 +217,7 @@ export class RemultServerImplementation {
|
|
|
244
217
|
async serializeContext(remult) {
|
|
245
218
|
let result = {
|
|
246
219
|
user: remult.user,
|
|
247
|
-
context: undefined
|
|
220
|
+
context: undefined,
|
|
248
221
|
};
|
|
249
222
|
if (this.options.contextSerializer) {
|
|
250
223
|
result.context = await this.options.contextSerializer.serialize(remult);
|
|
@@ -254,9 +227,10 @@ export class RemultServerImplementation {
|
|
|
254
227
|
add(key, dataApiFactory, r) {
|
|
255
228
|
let myRoute = this.options.rootPath + '/' + key;
|
|
256
229
|
if (this.options.logApiEndPoints)
|
|
257
|
-
console.info(
|
|
230
|
+
console.info('[remult] ' + myRoute);
|
|
258
231
|
r.route(myRoute)
|
|
259
|
-
.get(this.process((c, req, res, orig) => dataApiFactory(c).httpGet(res, req, () => this.serializeContext(c))))
|
|
232
|
+
.get(this.process((c, req, res, orig) => dataApiFactory(c).httpGet(res, req, () => this.serializeContext(c))))
|
|
233
|
+
.put(this.process(async (c, req, res, _, __, orig) => dataApiFactory(c).put(res, '', await this.coreOptions.getRequestBody(orig))))
|
|
260
234
|
.delete(this.process(async (c, req, res, orig) => dataApiFactory(c).delete(res, '')))
|
|
261
235
|
.post(this.process(async (c, req, res, _, __, orig) => dataApiFactory(c).httpPost(res, req, await this.coreOptions.getRequestBody(orig), () => this.serializeContext(c))));
|
|
262
236
|
r.route(myRoute + '/:id')
|
|
@@ -271,10 +245,10 @@ export class RemultServerImplementation {
|
|
|
271
245
|
async runWithRemult(what) {
|
|
272
246
|
let remult = new Remult();
|
|
273
247
|
remult.liveQueryPublisher = new LiveQueryPublisher(() => remult.subscriptionServer, () => remult.liveQueryStorage, this.runWithSerializedJsonContextData);
|
|
274
|
-
remult.dataProvider =
|
|
248
|
+
remult.dataProvider = await this.dataProvider;
|
|
275
249
|
remult.subscriptionServer = this.subscriptionServer;
|
|
276
250
|
remult.liveQueryStorage = this.liveQueryStorage;
|
|
277
|
-
await new Promise(res => {
|
|
251
|
+
await new Promise((res) => {
|
|
278
252
|
RemultAsyncLocalStorage.instance.run(remult, async () => {
|
|
279
253
|
res(await what(remult));
|
|
280
254
|
});
|
|
@@ -284,10 +258,10 @@ export class RemultServerImplementation {
|
|
|
284
258
|
return async (req, origRes) => {
|
|
285
259
|
const genReq = this.coreOptions.buildGenericRequestInfo(req);
|
|
286
260
|
if (!genReq.query) {
|
|
287
|
-
genReq.query = req[
|
|
261
|
+
genReq.query = req['_tempQuery'];
|
|
288
262
|
}
|
|
289
263
|
if (!genReq.params)
|
|
290
|
-
genReq.params = req[
|
|
264
|
+
genReq.params = req['_tempParams'];
|
|
291
265
|
let myReq = new ExpressRequestBridgeToDataApiRequest(genReq);
|
|
292
266
|
let myRes = new ExpressResponseBridgeToDataApiResponse(origRes, req);
|
|
293
267
|
await this.runWithRemult(async (remult) => {
|
|
@@ -301,7 +275,7 @@ export class RemultServerImplementation {
|
|
|
301
275
|
user = req['auth'];
|
|
302
276
|
}
|
|
303
277
|
if (user)
|
|
304
|
-
remult.user =
|
|
278
|
+
remult.user = user;
|
|
305
279
|
if (this.options.initRequest) {
|
|
306
280
|
await this.options.initRequest(req, {
|
|
307
281
|
remult,
|
|
@@ -310,7 +284,7 @@ export class RemultServerImplementation {
|
|
|
310
284
|
},
|
|
311
285
|
set liveQueryStorage(value) {
|
|
312
286
|
remult.liveQueryStorage = value;
|
|
313
|
-
}
|
|
287
|
+
},
|
|
314
288
|
});
|
|
315
289
|
}
|
|
316
290
|
}
|
|
@@ -318,7 +292,6 @@ export class RemultServerImplementation {
|
|
|
318
292
|
});
|
|
319
293
|
};
|
|
320
294
|
}
|
|
321
|
-
;
|
|
322
295
|
async getRemult(req) {
|
|
323
296
|
let remult;
|
|
324
297
|
await this.process(async (c) => {
|
|
@@ -338,7 +311,7 @@ export class RemultServerImplementation {
|
|
|
338
311
|
})();
|
|
339
312
|
this.backendMethodsOpenApi.push({ path: myUrl, allowed, tag });
|
|
340
313
|
if (this.options.logApiEndPoints)
|
|
341
|
-
console.info(
|
|
314
|
+
console.info('[remult] ' + myUrl);
|
|
342
315
|
if (queue) {
|
|
343
316
|
this.hasQueue = true;
|
|
344
317
|
this.queue.mapQueuedAction(myUrl, what);
|
|
@@ -346,7 +319,7 @@ export class RemultServerImplementation {
|
|
|
346
319
|
r.route(myUrl).post(this.process(async (remult, req, res, _, __, orig) => {
|
|
347
320
|
if (queue) {
|
|
348
321
|
let r = {
|
|
349
|
-
queuedJobId: await this.queue.submitJob(myUrl, remult, await this.coreOptions.getRequestBody(orig))
|
|
322
|
+
queuedJobId: await this.queue.submitJob(myUrl, remult, await this.coreOptions.getRequestBody(orig)),
|
|
350
323
|
};
|
|
351
324
|
res.success(r);
|
|
352
325
|
}
|
|
@@ -357,41 +330,41 @@ export class RemultServerImplementation {
|
|
|
357
330
|
}
|
|
358
331
|
openApiDoc(options) {
|
|
359
332
|
if (!options.version)
|
|
360
|
-
options.version =
|
|
333
|
+
options.version = '1.0.0';
|
|
361
334
|
let spec = {
|
|
362
335
|
info: { title: options.title, version: options.version },
|
|
363
|
-
openapi:
|
|
336
|
+
openapi: '3.0.0',
|
|
364
337
|
//swagger: "2.0",
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
}
|
|
338
|
+
components: {
|
|
339
|
+
schemas: {},
|
|
340
|
+
securitySchemes: {
|
|
341
|
+
bearerAuth: {
|
|
342
|
+
scheme: 'bearer',
|
|
343
|
+
bearerFormat: 'JWT',
|
|
344
|
+
type: 'http',
|
|
345
|
+
},
|
|
346
|
+
},
|
|
374
347
|
},
|
|
375
|
-
paths: {}
|
|
348
|
+
paths: {},
|
|
376
349
|
};
|
|
377
350
|
let validationError = {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
351
|
+
'400': {
|
|
352
|
+
description: 'Error: Bad Request',
|
|
353
|
+
content: {
|
|
354
|
+
'application/json': {
|
|
355
|
+
schema: {
|
|
356
|
+
$ref: '#/components/schemas/InvalidResponse',
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
},
|
|
388
361
|
};
|
|
389
362
|
let security = {
|
|
390
|
-
|
|
363
|
+
security: [
|
|
391
364
|
{
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
]
|
|
365
|
+
bearerAuth: [],
|
|
366
|
+
},
|
|
367
|
+
],
|
|
395
368
|
};
|
|
396
369
|
let secureBase = (condition, def, item) => {
|
|
397
370
|
if (condition === undefined)
|
|
@@ -399,7 +372,7 @@ export class RemultServerImplementation {
|
|
|
399
372
|
if (condition != false) {
|
|
400
373
|
if (condition != true) {
|
|
401
374
|
item = { ...item, ...security };
|
|
402
|
-
item.responses[
|
|
375
|
+
item.responses['403'] = { description: 'forbidden' };
|
|
403
376
|
}
|
|
404
377
|
return item;
|
|
405
378
|
}
|
|
@@ -412,43 +385,49 @@ export class RemultServerImplementation {
|
|
|
412
385
|
let properties = {};
|
|
413
386
|
let mutationProperties = {};
|
|
414
387
|
for (const f of meta.fields) {
|
|
415
|
-
let type = f.valueType == String
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
388
|
+
let type = f.valueType == String
|
|
389
|
+
? 'string'
|
|
390
|
+
: f.valueType == Boolean
|
|
391
|
+
? 'boolean'
|
|
392
|
+
: f.valueType == Date
|
|
393
|
+
? 'string'
|
|
394
|
+
: f.valueType == Number
|
|
395
|
+
? 'number'
|
|
396
|
+
: 'object';
|
|
420
397
|
if (f.options.includeInApi !== false) {
|
|
421
398
|
properties[f.key] = {
|
|
422
|
-
type
|
|
399
|
+
type,
|
|
423
400
|
};
|
|
424
401
|
if (f.options.allowApiUpdate !== false) {
|
|
425
402
|
mutationProperties[f.key] = {
|
|
426
|
-
type
|
|
403
|
+
type,
|
|
427
404
|
};
|
|
428
405
|
}
|
|
429
406
|
parameters.push({
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
407
|
+
name: f.key,
|
|
408
|
+
in: 'query',
|
|
409
|
+
description: 'filter equal to ' +
|
|
410
|
+
f.key +
|
|
411
|
+
'. See [more filtering options](https://remult.dev/docs/rest-api.html#filter)',
|
|
412
|
+
required: false,
|
|
413
|
+
style: 'simple',
|
|
414
|
+
type,
|
|
436
415
|
});
|
|
437
416
|
}
|
|
438
417
|
}
|
|
439
418
|
spec.components.schemas[key] = {
|
|
440
|
-
type:
|
|
441
|
-
properties
|
|
419
|
+
type: 'object',
|
|
420
|
+
properties,
|
|
442
421
|
};
|
|
443
422
|
if (JSON.stringify(properties) !== JSON.stringify(mutationProperties)) {
|
|
444
423
|
mutationKey += 'Mutation';
|
|
445
424
|
spec.components.schemas[mutationKey] = {
|
|
446
|
-
type:
|
|
447
|
-
properties: mutationProperties
|
|
425
|
+
type: 'object',
|
|
426
|
+
properties: mutationProperties,
|
|
448
427
|
};
|
|
449
428
|
}
|
|
450
429
|
let definition = {
|
|
451
|
-
|
|
430
|
+
$ref: '#/components/schemas/' + key,
|
|
452
431
|
};
|
|
453
432
|
let secure = (condition, def, item) => {
|
|
454
433
|
item.tags = [meta.key];
|
|
@@ -456,195 +435,196 @@ export class RemultServerImplementation {
|
|
|
456
435
|
condition = meta.options.allowApiCrud;
|
|
457
436
|
return secureBase(condition, def, item);
|
|
458
437
|
};
|
|
459
|
-
let apiPath = spec.paths[this.options.rootPath + '/' + key] = {};
|
|
460
|
-
let apiPathWithId = spec.paths[this.options.rootPath + '/' + key +
|
|
438
|
+
let apiPath = (spec.paths[this.options.rootPath + '/' + key] = {});
|
|
439
|
+
let apiPathWithId = (spec.paths[this.options.rootPath + '/' + key + '/{id}'] = {});
|
|
461
440
|
//https://github.com/2fd/open-api.d.ts
|
|
462
441
|
apiPath.get = secure(meta.options.allowApiRead, true, {
|
|
463
|
-
description:
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
442
|
+
description: 'return an array of ' +
|
|
443
|
+
key +
|
|
444
|
+
'. supports filter operators. For more info on filtering [see this article](https://remult.dev/docs/rest-api.html#filter)',
|
|
445
|
+
parameters: [
|
|
446
|
+
{
|
|
447
|
+
name: '_limit',
|
|
448
|
+
in: 'query',
|
|
449
|
+
description: 'limit the number of returned rows, default 100',
|
|
450
|
+
required: false,
|
|
451
|
+
style: 'simple',
|
|
452
|
+
schema: { type: 'integer' },
|
|
471
453
|
},
|
|
472
454
|
{
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
455
|
+
name: '_page',
|
|
456
|
+
in: 'query',
|
|
457
|
+
description: 'to be used for paging',
|
|
458
|
+
required: false,
|
|
459
|
+
schema: { type: 'integer' },
|
|
478
460
|
},
|
|
479
461
|
{
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
462
|
+
name: '_sort',
|
|
463
|
+
in: 'query',
|
|
464
|
+
description: 'the columns to sort on',
|
|
465
|
+
required: false,
|
|
466
|
+
schema: { type: 'string' },
|
|
485
467
|
},
|
|
486
468
|
{
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
},
|
|
469
|
+
name: '_order',
|
|
470
|
+
in: 'query',
|
|
471
|
+
description: 'the sort order to user for the columns in `_sort`',
|
|
472
|
+
required: false,
|
|
473
|
+
schema: { type: 'string' },
|
|
474
|
+
},
|
|
475
|
+
...parameters,
|
|
476
|
+
],
|
|
493
477
|
responses: {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
}
|
|
478
|
+
'200': {
|
|
479
|
+
description: 'returns an array of ' + key,
|
|
480
|
+
content: {
|
|
481
|
+
'application/json': {
|
|
482
|
+
schema: {
|
|
483
|
+
type: 'array',
|
|
484
|
+
items: definition,
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
},
|
|
504
488
|
},
|
|
505
|
-
}
|
|
489
|
+
},
|
|
506
490
|
});
|
|
507
491
|
let idParameter = {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
492
|
+
name: 'id',
|
|
493
|
+
in: 'path',
|
|
494
|
+
description: 'id of ' + key,
|
|
495
|
+
required: true,
|
|
496
|
+
schema: { type: 'string' },
|
|
513
497
|
};
|
|
514
498
|
let itemInBody = {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
}
|
|
499
|
+
requestBody: {
|
|
500
|
+
content: {
|
|
501
|
+
'application/json': {
|
|
502
|
+
schema: {
|
|
503
|
+
$ref: '#/components/schemas/' + mutationKey,
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
},
|
|
524
508
|
};
|
|
525
509
|
apiPath.post = secure(meta.options.allowApiInsert, false, {
|
|
526
510
|
//"summary": "insert a " + key,
|
|
527
511
|
//"description": "insert a " + key,
|
|
528
|
-
|
|
512
|
+
produces: ['application/json'],
|
|
529
513
|
...itemInBody,
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
514
|
+
responses: {
|
|
515
|
+
'201': {
|
|
516
|
+
description: 'Created',
|
|
517
|
+
content: {
|
|
518
|
+
'application/json': {
|
|
519
|
+
schema: {
|
|
520
|
+
$ref: '#/components/schemas/' + key,
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
},
|
|
540
524
|
},
|
|
541
|
-
...validationError
|
|
542
|
-
}
|
|
525
|
+
...validationError,
|
|
526
|
+
},
|
|
543
527
|
});
|
|
544
528
|
apiPathWithId.get = secure(meta.options.allowApiRead, true, {
|
|
545
529
|
parameters: [idParameter],
|
|
546
530
|
responses: {
|
|
547
|
-
|
|
531
|
+
'200': {
|
|
548
532
|
// "description": "returns an item of " + key,
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}
|
|
533
|
+
content: {
|
|
534
|
+
'application/json': {
|
|
535
|
+
schema: {
|
|
536
|
+
$ref: '#/components/schemas/' + key,
|
|
537
|
+
},
|
|
538
|
+
},
|
|
539
|
+
},
|
|
556
540
|
},
|
|
557
|
-
}
|
|
541
|
+
},
|
|
558
542
|
});
|
|
559
543
|
apiPathWithId.put = secure(meta.options.allowApiUpdate, false, {
|
|
560
544
|
//"summary": "Update a " + key,
|
|
561
545
|
//"description": "Update a " + key,
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
idParameter
|
|
565
|
-
],
|
|
546
|
+
produces: ['application/json'],
|
|
547
|
+
parameters: [idParameter],
|
|
566
548
|
...itemInBody,
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
}
|
|
549
|
+
responses: {
|
|
550
|
+
'200': {
|
|
551
|
+
description: 'successful operation',
|
|
552
|
+
content: {
|
|
553
|
+
'application/json': {
|
|
554
|
+
schema: {
|
|
555
|
+
$ref: '#/components/schemas/' + key,
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
},
|
|
577
559
|
},
|
|
578
|
-
...validationError
|
|
579
|
-
}
|
|
560
|
+
...validationError,
|
|
561
|
+
},
|
|
580
562
|
});
|
|
581
563
|
apiPathWithId.delete = secure(meta.options.allowApiDelete, false, {
|
|
582
564
|
// "summary": "Delete a " + key,
|
|
583
565
|
// "description": "Delete a " + key,
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
"204": {
|
|
590
|
-
"description": "Deleted"
|
|
566
|
+
produces: ['application/json'],
|
|
567
|
+
parameters: [idParameter],
|
|
568
|
+
responses: {
|
|
569
|
+
'204': {
|
|
570
|
+
description: 'Deleted',
|
|
591
571
|
},
|
|
592
|
-
...validationError
|
|
593
|
-
}
|
|
572
|
+
...validationError,
|
|
573
|
+
},
|
|
594
574
|
});
|
|
595
575
|
}
|
|
596
576
|
}
|
|
597
577
|
for (const b of this.backendMethodsOpenApi) {
|
|
598
578
|
spec.paths[b.path] = {
|
|
599
579
|
post: secureBase(b.allowed, false, {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
580
|
+
produces: ['application/json'],
|
|
581
|
+
tags: [b.tag],
|
|
582
|
+
requestBody: {
|
|
583
|
+
content: {
|
|
584
|
+
'application/json': {
|
|
585
|
+
schema: {
|
|
586
|
+
type: 'object',
|
|
607
587
|
properties: {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
}
|
|
588
|
+
args: {
|
|
589
|
+
type: 'array',
|
|
590
|
+
items: { type: 'string' },
|
|
591
|
+
},
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
},
|
|
595
|
+
},
|
|
616
596
|
},
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
597
|
+
responses: {
|
|
598
|
+
'201': {
|
|
599
|
+
description: 'Created',
|
|
600
|
+
content: {
|
|
601
|
+
'application/json': {
|
|
602
|
+
schema: {
|
|
603
|
+
type: 'object',
|
|
624
604
|
properties: {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
}
|
|
605
|
+
data: {
|
|
606
|
+
type: 'object',
|
|
607
|
+
},
|
|
608
|
+
},
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
},
|
|
632
612
|
},
|
|
633
|
-
...validationError
|
|
634
|
-
}
|
|
635
|
-
})
|
|
613
|
+
...validationError,
|
|
614
|
+
},
|
|
615
|
+
}),
|
|
636
616
|
};
|
|
637
617
|
}
|
|
638
|
-
spec.components.schemas[
|
|
639
|
-
|
|
618
|
+
spec.components.schemas['InvalidResponse'] = {
|
|
619
|
+
type: 'object',
|
|
640
620
|
properties: {
|
|
641
|
-
|
|
642
|
-
|
|
621
|
+
message: {
|
|
622
|
+
type: 'string',
|
|
643
623
|
},
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
}
|
|
647
|
-
}
|
|
624
|
+
modelState: {
|
|
625
|
+
type: 'object',
|
|
626
|
+
},
|
|
627
|
+
},
|
|
648
628
|
};
|
|
649
629
|
return spec;
|
|
650
630
|
}
|
|
@@ -668,8 +648,7 @@ class ExpressResponseBridgeToDataApiResponse {
|
|
|
668
648
|
setStatus(status) {
|
|
669
649
|
return this.r.status(status);
|
|
670
650
|
}
|
|
671
|
-
progress(progress) {
|
|
672
|
-
}
|
|
651
|
+
progress(progress) { }
|
|
673
652
|
success(data) {
|
|
674
653
|
this.r.json(data);
|
|
675
654
|
}
|
|
@@ -688,14 +667,13 @@ class ExpressResponseBridgeToDataApiResponse {
|
|
|
688
667
|
message: data.message,
|
|
689
668
|
stack: data.stack?.split('\n'),
|
|
690
669
|
url: this.req.url,
|
|
691
|
-
method: this.req.method
|
|
670
|
+
method: this.req.method,
|
|
692
671
|
});
|
|
693
672
|
this.setStatus(400).json(data);
|
|
694
|
-
;
|
|
695
673
|
}
|
|
696
674
|
}
|
|
697
675
|
function throwError() {
|
|
698
|
-
throw
|
|
676
|
+
throw 'Invalid';
|
|
699
677
|
}
|
|
700
678
|
class inProcessQueueHandler {
|
|
701
679
|
constructor(storage) {
|
|
@@ -706,13 +684,19 @@ class inProcessQueueHandler {
|
|
|
706
684
|
let id = await this.storage.createJob(url, req.user ? req.user.id : undefined);
|
|
707
685
|
let job = await this.storage.getJobInfo(id);
|
|
708
686
|
this.actions.get(url)(body, req, {
|
|
709
|
-
error: error => job.setErrorResult(serializeError(error)),
|
|
710
|
-
success: result => job.setResult(result),
|
|
711
|
-
progress: progress => job.setProgress(progress),
|
|
712
|
-
created: () => {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
687
|
+
error: (error) => job.setErrorResult(serializeError(error)),
|
|
688
|
+
success: (result) => job.setResult(result),
|
|
689
|
+
progress: (progress) => job.setProgress(progress),
|
|
690
|
+
created: () => {
|
|
691
|
+
throw Error('Created response not expected for queue');
|
|
692
|
+
},
|
|
693
|
+
deleted: () => {
|
|
694
|
+
throw Error('deleted response not expected for queue');
|
|
695
|
+
},
|
|
696
|
+
notFound: () => {
|
|
697
|
+
throw Error('notFound response not expected for queue');
|
|
698
|
+
},
|
|
699
|
+
forbidden: () => job.setErrorResult('Forbidden'),
|
|
716
700
|
});
|
|
717
701
|
return id;
|
|
718
702
|
}
|
|
@@ -734,7 +718,7 @@ class InMemoryQueueStorage {
|
|
|
734
718
|
let id = this.jobs.size.toString();
|
|
735
719
|
this.jobs.set(id, {
|
|
736
720
|
info: {
|
|
737
|
-
done: false
|
|
721
|
+
done: false,
|
|
738
722
|
},
|
|
739
723
|
userId: userId,
|
|
740
724
|
setErrorResult: (error) => {
|
|
@@ -750,7 +734,7 @@ class InMemoryQueueStorage {
|
|
|
750
734
|
setProgress: (progress) => {
|
|
751
735
|
let job = this.jobs.get(id);
|
|
752
736
|
job.info.progress = progress;
|
|
753
|
-
}
|
|
737
|
+
},
|
|
754
738
|
});
|
|
755
739
|
return id;
|
|
756
740
|
}
|
|
@@ -762,7 +746,7 @@ export class EntityQueueStorage {
|
|
|
762
746
|
this.sync = Promise.resolve();
|
|
763
747
|
}
|
|
764
748
|
doSync(what) {
|
|
765
|
-
return this.sync = this.sync.then(() => what());
|
|
749
|
+
return (this.sync = this.sync.then(() => what()));
|
|
766
750
|
}
|
|
767
751
|
async getJobInfo(queuedJobId) {
|
|
768
752
|
let q = await this.repo.findId(queuedJobId, { useCache: false });
|
|
@@ -773,7 +757,7 @@ export class EntityQueueStorage {
|
|
|
773
757
|
done: q.done,
|
|
774
758
|
error: q.error ? JSON.parse(q.result) : undefined,
|
|
775
759
|
result: q.done && !q.error ? JSON.parse(q.result) : undefined,
|
|
776
|
-
progress: q.progress
|
|
760
|
+
progress: q.progress,
|
|
777
761
|
},
|
|
778
762
|
setErrorResult: async (error) => {
|
|
779
763
|
await this.sync;
|
|
@@ -801,7 +785,7 @@ export class EntityQueueStorage {
|
|
|
801
785
|
await this.sync;
|
|
802
786
|
q.progress = progress;
|
|
803
787
|
await this.doSync(() => q._.save());
|
|
804
|
-
}
|
|
788
|
+
},
|
|
805
789
|
};
|
|
806
790
|
}
|
|
807
791
|
async createJob(url, userId) {
|
|
@@ -827,34 +811,36 @@ class RouteImplementation {
|
|
|
827
811
|
this.map.set(r, m);
|
|
828
812
|
const route = {
|
|
829
813
|
get: (h) => {
|
|
830
|
-
m.set(
|
|
814
|
+
m.set('get', h);
|
|
831
815
|
return route;
|
|
832
816
|
},
|
|
833
817
|
put: (h) => {
|
|
834
|
-
m.set(
|
|
818
|
+
m.set('put', h);
|
|
835
819
|
return route;
|
|
836
820
|
},
|
|
837
821
|
post: (h) => {
|
|
838
|
-
m.set(
|
|
822
|
+
m.set('post', h);
|
|
839
823
|
return route;
|
|
840
824
|
},
|
|
841
825
|
delete: (h) => {
|
|
842
|
-
m.set(
|
|
826
|
+
m.set('delete', h);
|
|
843
827
|
return route;
|
|
844
|
-
}
|
|
828
|
+
},
|
|
845
829
|
};
|
|
846
830
|
return route;
|
|
847
831
|
}
|
|
848
832
|
async handle(req, gRes) {
|
|
849
|
-
return new Promise(res => {
|
|
850
|
-
const response = new class {
|
|
833
|
+
return new Promise((res) => {
|
|
834
|
+
const response = new (class {
|
|
851
835
|
constructor() {
|
|
852
836
|
this.statusCode = 200;
|
|
853
837
|
}
|
|
854
838
|
write(data) {
|
|
839
|
+
;
|
|
855
840
|
gRes.write(data);
|
|
856
841
|
}
|
|
857
842
|
writeHead(statusCode, headers) {
|
|
843
|
+
;
|
|
858
844
|
gRes.writeHead(statusCode, headers);
|
|
859
845
|
this.statusCode = statusCode;
|
|
860
846
|
res({ statusCode });
|
|
@@ -878,17 +864,18 @@ class RouteImplementation {
|
|
|
878
864
|
if (gRes !== undefined)
|
|
879
865
|
gRes.end();
|
|
880
866
|
res({
|
|
881
|
-
statusCode: this.statusCode
|
|
867
|
+
statusCode: this.statusCode,
|
|
882
868
|
});
|
|
883
869
|
}
|
|
884
|
-
};
|
|
870
|
+
})();
|
|
885
871
|
this.middleware(req, response, () => res(undefined));
|
|
886
872
|
});
|
|
887
873
|
}
|
|
888
874
|
middleware(origReq, res, next) {
|
|
889
875
|
const req = this.coreOptions.buildGenericRequestInfo(origReq);
|
|
890
876
|
let theUrl = req.url;
|
|
891
|
-
if (theUrl.startsWith('/'))
|
|
877
|
+
if (theUrl.startsWith('/'))
|
|
878
|
+
//next sends a partial url '/api/tasks' and not the full url
|
|
892
879
|
theUrl = 'http://stam' + theUrl;
|
|
893
880
|
const url = new URL(theUrl);
|
|
894
881
|
const path = url.pathname;
|
|
@@ -906,7 +893,7 @@ class RouteImplementation {
|
|
|
906
893
|
}
|
|
907
894
|
query[key] = [current, val];
|
|
908
895
|
});
|
|
909
|
-
origReq[
|
|
896
|
+
origReq['_tempQuery'] = query;
|
|
910
897
|
req.query = query;
|
|
911
898
|
}
|
|
912
899
|
let lowerPath = path.toLowerCase();
|
|
@@ -927,7 +914,7 @@ class RouteImplementation {
|
|
|
927
914
|
if (h) {
|
|
928
915
|
if (!req.params) {
|
|
929
916
|
req.params = {};
|
|
930
|
-
origReq[
|
|
917
|
+
origReq['_tempParams'] = req.params;
|
|
931
918
|
}
|
|
932
919
|
req.params.id = path.substring(idPosition + 1);
|
|
933
920
|
h(origReq, res, next);
|
|
@@ -974,7 +961,7 @@ __decorate([
|
|
|
974
961
|
], JobsInQueueEntity.prototype, "progress", void 0);
|
|
975
962
|
JobsInQueueEntity = __decorate([
|
|
976
963
|
Entity(undefined, {
|
|
977
|
-
dbName: 'jobsInQueue'
|
|
964
|
+
dbName: 'jobsInQueue',
|
|
978
965
|
})
|
|
979
966
|
], JobsInQueueEntity);
|
|
980
967
|
export { JobsInQueueEntity };
|