remult 0.22.5 → 0.22.6-exp.2
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/esm/graphql.js +29 -28
- package/esm/internals.js +7 -0
- package/esm/migrations/compare-migration-snapshots.js +61 -0
- package/esm/migrations/generate-migrations.js +68 -0
- package/esm/migrations/index.js +2 -0
- package/esm/migrations/migrate.js +85 -0
- package/esm/migrations/migration-types.js +36 -0
- package/esm/migrations/update-migrations-ts-file.js +115 -0
- package/esm/package.json +3 -0
- package/esm/postgres/schema-builder.js +4 -4
- package/esm/remult-better-sqlite3.js +47 -0
- package/esm/remult-bun-sqlite.js +41 -0
- package/esm/remult-duckdb.js +111 -0
- package/esm/remult-hapi.js +114 -0
- package/esm/remult-hono.js +104 -0
- package/esm/remult-mongo.js +1 -1
- package/esm/remult-nuxt.js +54 -0
- package/esm/remult-solid-start.js +97 -0
- package/esm/remult-sql-js.js +41 -0
- package/esm/remult-sqlite-core.js +137 -0
- package/esm/remult-sqlite3.js +61 -0
- package/esm/remult-turso.js +59 -0
- package/esm/server/get-remult-admin-html.js +3 -0
- package/esm/server/initDataProviderOrJson.js +6 -0
- package/esm/server/remult-admin.js +95 -0
- package/esm/server/remult-api-server.js +1157 -0
- package/esm/src/CompoundIdField.js +62 -0
- package/esm/src/backend-tests/backend-database-test-setup.backend-spec.js +11 -10
- package/esm/src/data-api.js +4 -2
- package/esm/src/data-providers/json-entity-opfs-storage.js +26 -0
- package/esm/src/isOfType.js +9 -0
- package/esm/src/live-query/SubscriptionServer.js +2 -2
- package/esm/src/remult-static.js +43 -0
- package/esm/src/remult3/Fields.js +335 -0
- package/esm/src/remult3/IdEntity.js +10 -0
- package/esm/src/remult3/RepositoryImplementation.js +7 -4
- package/esm/src/remult3/__updateEntityBasedOnWhere.js +28 -0
- package/esm/src/remult3/addValidator.js +15 -0
- package/esm/{core/src/remult3/DecoratorReplacer.js → src/remult3/classDescribers.js} +18 -3
- package/esm/src/remult3/entity.js +70 -0
- package/esm/src/remult3/getEntityRef.js +36 -0
- package/esm/src/remult3/relation-loader.js +153 -0
- package/esm/src/remult3/relationInfoMember.js +116 -0
- package/esm/src/remult3/repository-internals.js +7 -0
- package/esm/src/server-action-info.js +1 -0
- package/esm/src/shared-tests/db-tests.db-tests.js +1 -1
- package/graphql.js +2 -1
- package/internals.d.ts +15 -0
- package/internals.js +18 -0
- package/migrations/compare-migration-snapshots.d.ts +27 -0
- package/migrations/compare-migration-snapshots.js +164 -0
- package/migrations/generate-migrations.d.ts +21 -0
- package/migrations/generate-migrations.js +103 -0
- package/migrations/index.d.ts +3 -0
- package/migrations/index.js +7 -0
- package/migrations/migrate.d.ts +27 -0
- package/migrations/migrate.js +170 -0
- package/migrations/migration-types.d.ts +48 -0
- package/migrations/migration-types.js +88 -0
- package/migrations/update-migrations-ts-file.d.ts +1 -0
- package/migrations/update-migrations-ts-file.js +140 -0
- package/package.json +1 -1
- package/remult-better-sqlite3.d.ts +12 -0
- package/remult-better-sqlite3.js +64 -0
- package/remult-bun-sqlite.d.ts +11 -0
- package/remult-bun-sqlite.js +56 -0
- package/remult-duckdb.d.ts +9 -0
- package/remult-duckdb.js +150 -0
- package/remult-hapi.d.ts +6 -0
- package/remult-hapi.js +127 -0
- package/remult-hono.d.ts +7 -0
- package/remult-hono.js +115 -0
- package/remult-mongo.js +1 -1
- package/remult-nuxt.d.ts +6 -0
- package/remult-nuxt.js +78 -0
- package/remult-solid-start.d.ts +12 -0
- package/remult-solid-start.js +133 -0
- package/remult-sql-js.d.ts +5 -0
- package/remult-sql-js.js +73 -0
- package/remult-sqlite-core.d.ts +25 -0
- package/remult-sqlite-core.js +314 -0
- package/remult-sqlite3.d.ts +5 -0
- package/remult-sqlite3.js +76 -0
- package/remult-turso.d.ts +8 -0
- package/remult-turso.js +100 -0
- package/server/get-remult-admin-html.d.ts +1 -0
- package/server/get-remult-admin-html.js +6 -0
- package/server/initDataProviderOrJson.d.ts +2 -0
- package/server/initDataProviderOrJson.js +16 -0
- package/server/remult-admin.d.ts +43 -0
- package/server/remult-admin.js +123 -0
- package/{esm/core/server/expressBridge.d.ts → server/remult-api-server.d.ts} +75 -77
- package/server/remult-api-server.js +1626 -0
- package/src/CompoundIdField.d.ts +27 -0
- package/src/CompoundIdField.js +72 -0
- package/src/backend-tests/backend-database-test-setup.backend-spec.js +11 -10
- package/src/data-api.js +4 -2
- package/src/data-providers/json-entity-opfs-storage.d.ts +5 -0
- package/src/data-providers/json-entity-opfs-storage.js +74 -0
- package/src/isOfType.d.ts +2 -0
- package/src/isOfType.js +13 -0
- package/src/live-query/SubscriptionServer.js +2 -2
- package/src/remult-static.d.ts +26 -0
- package/src/remult-static.js +50 -0
- package/src/remult3/Fields.d.ts +170 -0
- package/src/remult3/Fields.js +419 -0
- package/src/remult3/IdEntity.d.ts +4 -0
- package/src/remult3/IdEntity.js +18 -0
- package/src/remult3/RepositoryImplementation.js +24 -22
- package/src/remult3/__updateEntityBasedOnWhere.d.ts +2 -0
- package/src/remult3/__updateEntityBasedOnWhere.js +31 -0
- package/src/remult3/addValidator.d.ts +2 -0
- package/src/remult3/addValidator.js +19 -0
- package/src/remult3/classDescribers.d.ts +16 -0
- package/src/remult3/classDescribers.js +40 -0
- package/src/remult3/columnInfo.d.ts +6 -0
- package/src/remult3/columnInfo.js +2 -0
- package/src/remult3/entity.d.ts +28 -0
- package/src/remult3/entity.js +86 -0
- package/src/remult3/getEntityRef.d.ts +18 -0
- package/src/remult3/getEntityRef.js +45 -0
- package/src/remult3/relation-loader-types.d.ts +7 -0
- package/src/remult3/relation-loader-types.js +2 -0
- package/src/remult3/relation-loader.d.ts +40 -0
- package/src/remult3/relation-loader.js +245 -0
- package/src/remult3/relationInfoMember.d.ts +30 -0
- package/src/remult3/relationInfoMember.js +149 -0
- package/src/remult3/repository-internals.d.ts +20 -0
- package/src/remult3/repository-internals.js +11 -0
- package/src/server-action-info.d.ts +1 -0
- package/src/server-action-info.js +4 -0
- package/src/shared-tests/db-tests.db-tests.js +1 -1
- package/esm/angular/interfaces/index.d.ts +0 -1
- package/esm/angular/interfaces/index.js +0 -1
- package/esm/angular/interfaces/src/column-collection.d.ts +0 -70
- package/esm/angular/interfaces/src/column-collection.js +0 -341
- package/esm/angular/interfaces/src/data-area-settings.d.ts +0 -15
- package/esm/angular/interfaces/src/data-area-settings.js +0 -35
- package/esm/angular/interfaces/src/data-control-interfaces.d.ts +0 -36
- package/esm/angular/interfaces/src/data-control-interfaces.js +0 -57
- package/esm/angular/interfaces/src/dataList.d.ts +0 -13
- package/esm/angular/interfaces/src/dataList.js +0 -42
- package/esm/angular/interfaces/src/filter-helper.d.ts +0 -13
- package/esm/angular/interfaces/src/filter-helper.js +0 -59
- package/esm/angular/interfaces/src/grid-settings.d.ts +0 -145
- package/esm/angular/interfaces/src/grid-settings.js +0 -387
- package/esm/angular/interfaces/src/public_api.d.ts +0 -4
- package/esm/angular/interfaces/src/public_api.js +0 -4
- package/esm/angular/src/angular/RemultAngularPluginsService.d.ts +0 -4
- package/esm/angular/src/angular/RemultAngularPluginsService.js +0 -3
- package/esm/angular/src/angular/data-control/data-control2.component.d.ts +0 -49
- package/esm/angular/src/angular/data-control/data-control2.component.js +0 -138
- package/esm/core/SseSubscriptionServer.d.ts +0 -33
- package/esm/core/SseSubscriptionServer.js +0 -107
- package/esm/core/assign.d.ts +0 -1
- package/esm/core/assign.js +0 -5
- package/esm/core/classType.d.ts +0 -3
- package/esm/core/index.d.ts +0 -27
- package/esm/core/index.js +0 -25
- package/esm/core/inputTypes.d.ts +0 -9
- package/esm/core/inputTypes.js +0 -9
- package/esm/core/live-query/data-provider-live-query-storage.d.ts +0 -22
- package/esm/core/live-query/data-provider-live-query-storage.js +0 -71
- package/esm/core/postgres/index.d.ts +0 -2
- package/esm/core/postgres/index.js +0 -2
- package/esm/core/postgres/postgres-data-provider.d.ts +0 -36
- package/esm/core/postgres/postgres-data-provider.js +0 -120
- package/esm/core/postgres/schema-builder.d.ts +0 -17
- package/esm/core/postgres/schema-builder.js +0 -153
- package/esm/core/remult-fresh.d.ts +0 -17
- package/esm/core/remult-fresh.js +0 -29
- package/esm/core/remult-knex/index.d.ts +0 -30
- package/esm/core/remult-knex/index.js +0 -446
- package/esm/core/remult-mongo.d.ts +0 -24
- package/esm/core/remult-mongo.js +0 -254
- package/esm/core/server/JsonEntityFileStorage.d.ts +0 -10
- package/esm/core/server/JsonEntityFileStorage.js +0 -25
- package/esm/core/server/core.d.ts +0 -4
- package/esm/core/server/core.js +0 -4
- package/esm/core/server/expressBridge.js +0 -938
- package/esm/core/server/index.d.ts +0 -6
- package/esm/core/server/index.js +0 -9
- package/esm/core/server/initAsyncHooks.d.ts +0 -1
- package/esm/core/server/initAsyncHooks.js +0 -9
- package/esm/core/server/initDataProvider.d.ts +0 -2
- package/esm/core/server/initDataProvider.js +0 -14
- package/esm/core/src/__EntityValueProvider.d.ts +0 -11
- package/esm/core/src/__RowsOfDataForTesting.d.ts +0 -3
- package/esm/core/src/__RowsOfDataForTesting.js +0 -1
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +0 -6
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.js +0 -147
- package/esm/core/src/backend-tests/my-test.backend-spec.d.ts +0 -1
- package/esm/core/src/backend-tests/my-test.backend-spec.js +0 -197
- package/esm/core/src/backend-tests/test-http-server.backend-spec.d.ts +0 -1
- package/esm/core/src/backend-tests/test-http-server.backend-spec.js +0 -167
- package/esm/core/src/buildRestDataProvider.d.ts +0 -31
- package/esm/core/src/buildRestDataProvider.js +0 -113
- package/esm/core/src/column-interfaces.d.ts +0 -154
- package/esm/core/src/column-interfaces.js +0 -7
- package/esm/core/src/column.d.ts +0 -58
- package/esm/core/src/column.js +0 -174
- package/esm/core/src/context.d.ts +0 -134
- package/esm/core/src/context.js +0 -286
- package/esm/core/src/data-api.d.ts +0 -39
- package/esm/core/src/data-api.js +0 -279
- package/esm/core/src/data-interfaces.d.ts +0 -41
- package/esm/core/src/data-interfaces.js +0 -12
- package/esm/core/src/data-providers/array-entity-data-provider.d.ts +0 -22
- package/esm/core/src/data-providers/array-entity-data-provider.js +0 -252
- package/esm/core/src/data-providers/in-memory-database.d.ts +0 -9
- package/esm/core/src/data-providers/in-memory-database.js +0 -14
- package/esm/core/src/data-providers/json-data-provider.d.ts +0 -12
- package/esm/core/src/data-providers/json-data-provider.js +0 -55
- package/esm/core/src/data-providers/rest-data-provider.d.ts +0 -49
- package/esm/core/src/data-providers/rest-data-provider.js +0 -256
- package/esm/core/src/data-providers/sql-database.d.ts +0 -33
- package/esm/core/src/data-providers/sql-database.js +0 -384
- package/esm/core/src/data-providers/web-sql-data-provider.d.ts +0 -24
- package/esm/core/src/data-providers/web-sql-data-provider.js +0 -143
- package/esm/core/src/entity.d.ts +0 -91
- package/esm/core/src/entity.js +0 -1
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.d.ts +0 -50
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.js +0 -150
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.d.ts +0 -1
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.js +0 -1
- package/esm/core/src/filter/filter-interfaces.d.ts +0 -85
- package/esm/core/src/filter/filter-interfaces.js +0 -477
- package/esm/core/src/live-query/LiveQueryClient.d.ts +0 -20
- package/esm/core/src/live-query/LiveQueryClient.js +0 -188
- package/esm/core/src/live-query/SseSubscriptionClient.d.ts +0 -5
- package/esm/core/src/live-query/SseSubscriptionClient.js +0 -86
- package/esm/core/src/live-query/SubscriptionChannel.d.ts +0 -72
- package/esm/core/src/live-query/SubscriptionChannel.js +0 -123
- package/esm/core/src/live-query/SubscriptionServer.d.ts +0 -53
- package/esm/core/src/live-query/SubscriptionServer.js +0 -111
- package/esm/core/src/live-query/live-query-tests.spec.d.ts +0 -6
- package/esm/core/src/live-query/live-query-tests.spec.js +0 -952
- package/esm/core/src/remult-proxy.d.ts +0 -35
- package/esm/core/src/remult-proxy.js +0 -113
- package/esm/core/src/remult3/DecoratorReplacer.d.ts +0 -10
- package/esm/core/src/remult3/RepositoryImplementation.d.ts +0 -355
- package/esm/core/src/remult3/RepositoryImplementation.js +0 -2109
- package/esm/core/src/remult3/index.d.ts +0 -2
- package/esm/core/src/remult3/index.js +0 -2
- package/esm/core/src/remult3/remult3.d.ts +0 -395
- package/esm/core/src/remult3/remult3.js +0 -2
- package/esm/core/src/server-action.d.ts +0 -81
- package/esm/core/src/server-action.js +0 -394
- package/esm/core/src/shared-tests/db-tests-setup.d.ts +0 -32
- package/esm/core/src/shared-tests/db-tests-setup.js +0 -78
- package/esm/core/src/shared-tests/db-tests.db-tests.d.ts +0 -25
- package/esm/core/src/shared-tests/db-tests.db-tests.js +0 -810
- package/esm/core/src/shared-tests/deleteAll.d.ts +0 -2
- package/esm/core/src/shared-tests/deleteAll.js +0 -4
- package/esm/core/src/shared-tests/entityWithValidations.d.ts +0 -14
- package/esm/core/src/shared-tests/entityWithValidations.js +0 -43
- package/esm/core/src/shared-tests/index.d.ts +0 -4
- package/esm/core/src/shared-tests/index.js +0 -4
- package/esm/core/src/shared-tests/test-custom-id-column.spec.d.ts +0 -1
- package/esm/core/src/shared-tests/test-custom-id-column.spec.js +0 -67
- package/esm/core/src/shared-tests/test-special-value.spec.d.ts +0 -10
- package/esm/core/src/shared-tests/test-special-value.spec.js +0 -73
- package/esm/core/src/shared-tests/test-update-with-null.spec.d.ts +0 -1
- package/esm/core/src/shared-tests/test-update-with-null.spec.js +0 -31
- package/esm/core/src/sort.d.ts +0 -16
- package/esm/core/src/sort.js +0 -103
- package/esm/core/src/sql-command.d.ts +0 -19
- package/esm/core/src/sql-command.js +0 -1
- package/esm/core/src/test.d.ts +0 -3
- package/esm/core/src/test.js +0 -12
- package/esm/core/src/tests/Done.d.ts +0 -5
- package/esm/core/src/tests/Done.js +0 -9
- package/esm/core/src/tests/RowProvider.spec.d.ts +0 -16
- package/esm/core/src/tests/RowProvider.spec.js +0 -631
- package/esm/core/src/tests/TestDataApiResponse.d.ts +0 -10
- package/esm/core/src/tests/TestDataApiResponse.js +0 -22
- package/esm/core/src/tests/basicRowFunctionality.spec.d.ts +0 -8
- package/esm/core/src/tests/basicRowFunctionality.spec.js +0 -2103
- package/esm/core/src/tests/c.d.ts +0 -8
- package/esm/core/src/tests/c.js +0 -13
- package/esm/core/src/tests/createData.d.ts +0 -7
- package/esm/core/src/tests/createData.js +0 -22
- package/esm/core/src/tests/d.d.ts +0 -6
- package/esm/core/src/tests/d.js +0 -11
- package/esm/core/src/tests/dWithPrefilter.d.ts +0 -7
- package/esm/core/src/tests/dWithPrefilter.js +0 -18
- package/esm/core/src/tests/entityForCustomFilter.d.ts +0 -16
- package/esm/core/src/tests/entityForCustomFilter.js +0 -33
- package/esm/core/src/tests/entityWithValidationsOnColumn.d.ts +0 -5
- package/esm/core/src/tests/entityWithValidationsOnColumn.js +0 -13
- package/esm/core/src/tests/frontend-database-tests-setup.spec.d.ts +0 -4
- package/esm/core/src/tests/frontend-database-tests-setup.spec.js +0 -37
- package/esm/core/src/tests/h.d.ts +0 -6
- package/esm/core/src/tests/h.js +0 -24
- package/esm/core/src/tests/remult-3-basic-tests.spec.d.ts +0 -1
- package/esm/core/src/tests/remult-3-basic-tests.spec.js +0 -236
- package/esm/core/src/tests/remult-3-entities.d.ts +0 -23
- package/esm/core/src/tests/remult-3-entities.js +0 -39
- package/esm/core/src/tests/tasks.d.ts +0 -6
- package/esm/core/src/tests/tasks.js +0 -10
- 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 +0 -1
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.d.ts +0 -1
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.js +0 -389
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.d.ts +0 -5
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.js +0 -152
- package/esm/core/src/tests/test-decorator-precedence.spec.d.ts +0 -1
- package/esm/core/src/tests/test-decorator-precedence.spec.js +0 -38
- package/esm/core/src/tests/test-default-value.spec.d.ts +0 -1
- package/esm/core/src/tests/test-default-value.spec.js +0 -33
- package/esm/core/src/tests/test-entity-inheritance.spec.d.ts +0 -14
- package/esm/core/src/tests/test-entity-inheritance.spec.js +0 -82
- package/esm/core/src/tests/test-exceptions.spec.d.ts +0 -1
- package/esm/core/src/tests/test-exceptions.spec.js +0 -375
- package/esm/core/src/tests/test-json.spec.d.ts +0 -1
- package/esm/core/src/tests/test-json.spec.js +0 -115
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.d.ts +0 -9
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.js +0 -809
- package/esm/core/src/tests/test-non-active-record.spec.d.ts +0 -1
- package/esm/core/src/tests/test-non-active-record.spec.js +0 -66
- package/esm/core/src/tests/test-object-column.spec.d.ts +0 -1
- package/esm/core/src/tests/test-object-column.spec.js +0 -189
- package/esm/core/src/tests/test-paged-foreach.spec.d.ts +0 -1
- package/esm/core/src/tests/test-paged-foreach.spec.js +0 -328
- package/esm/core/src/tests/test-remult-angular.spec.d.ts +0 -1
- package/esm/core/src/tests/test-remult-angular.spec.js +0 -23
- package/esm/core/src/tests/test-server-controller.spec.d.ts +0 -7
- package/esm/core/src/tests/test-server-controller.spec.js +0 -489
- package/esm/core/src/tests/test-server-expressions.spec.d.ts +0 -1
- package/esm/core/src/tests/test-server-expressions.spec.js +0 -178
- package/esm/core/src/tests/test-server-method-on-entity.spec.d.ts +0 -1
- package/esm/core/src/tests/test-server-method-on-entity.spec.js +0 -306
- package/esm/core/src/tests/test-sql-expression.spec.d.ts +0 -5
- package/esm/core/src/tests/test-sql-expression.spec.js +0 -205
- package/esm/core/src/tests/test-sql.spec.d.ts +0 -1
- package/esm/core/src/tests/test-sql.spec.js +0 -170
- package/esm/core/src/tests/test-subscribe.spec.d.ts +0 -1
- package/esm/core/src/tests/test-subscribe.spec.js +0 -135
- package/esm/core/src/tests/test-type-recovery.spec.d.ts +0 -1
- package/esm/core/src/tests/test-type-recovery.spec.js +0 -49
- package/esm/core/src/tests/test-where-api.spec.d.ts +0 -1
- package/esm/core/src/tests/test-where-api.spec.js +0 -434
- package/esm/core/src/tests/testHelper.spec.d.ts +0 -36
- package/esm/core/src/tests/testHelper.spec.js +0 -226
- package/esm/core/src/tests/testModel/models.d.ts +0 -16
- package/esm/core/src/tests/testModel/models.js +0 -25
- package/esm/core/src/validators.d.ts +0 -14
- package/esm/core/src/validators.js +0 -33
- package/esm/core/src/valueConverters.d.ts +0 -13
- package/esm/core/src/valueConverters.js +0 -197
- package/esm/core/urlBuilder.d.ts +0 -6
- package/esm/core/urlBuilder.js +0 -20
- package/esm/test-servers/shared/Task.d.ts +0 -9
- package/esm/test-servers/shared/Task.js +0 -32
- package/esm/test.d.ts +0 -5
- package/esm/test.js +0 -6
- /package/esm/{core/classType.js → src/remult3/columnInfo.js} +0 -0
- /package/esm/{core/src/__EntityValueProvider.js → src/remult3/relation-loader-types.js} +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export class CompoundIdField {
|
|
2
|
+
fields;
|
|
3
|
+
constructor(...columns) {
|
|
4
|
+
this.fields = columns;
|
|
5
|
+
}
|
|
6
|
+
apiUpdateAllowed(item) {
|
|
7
|
+
throw new Error('Method not implemented.');
|
|
8
|
+
}
|
|
9
|
+
displayValue(item) {
|
|
10
|
+
throw new Error('Method not implemented.');
|
|
11
|
+
}
|
|
12
|
+
includedInApi(item) {
|
|
13
|
+
throw new Error('Method not implemented.');
|
|
14
|
+
}
|
|
15
|
+
toInput(value, inputType) {
|
|
16
|
+
throw new Error('Method not implemented.');
|
|
17
|
+
}
|
|
18
|
+
fromInput(inputValue, inputType) {
|
|
19
|
+
throw new Error('Method not implemented.');
|
|
20
|
+
}
|
|
21
|
+
getDbName() {
|
|
22
|
+
return Promise.resolve('');
|
|
23
|
+
}
|
|
24
|
+
getId(instance) {
|
|
25
|
+
let get = (field) => {
|
|
26
|
+
return instance[field.key];
|
|
27
|
+
};
|
|
28
|
+
if (typeof instance === 'function') {
|
|
29
|
+
get = instance;
|
|
30
|
+
}
|
|
31
|
+
let r = '';
|
|
32
|
+
this.fields.forEach((c) => {
|
|
33
|
+
if (r.length > 0)
|
|
34
|
+
r += ',';
|
|
35
|
+
r += c.valueConverter.toJson(get(c));
|
|
36
|
+
});
|
|
37
|
+
return r;
|
|
38
|
+
}
|
|
39
|
+
options = {};
|
|
40
|
+
get valueConverter() {
|
|
41
|
+
throw new Error('cant get value converter of compound id');
|
|
42
|
+
}
|
|
43
|
+
target;
|
|
44
|
+
readonly = true;
|
|
45
|
+
allowNull = false;
|
|
46
|
+
dbReadOnly = false;
|
|
47
|
+
isServerExpression = false;
|
|
48
|
+
key = '';
|
|
49
|
+
caption = '';
|
|
50
|
+
inputType = '';
|
|
51
|
+
dbName = '';
|
|
52
|
+
valueType;
|
|
53
|
+
isEqualTo(value) {
|
|
54
|
+
let result = {};
|
|
55
|
+
let val = value.toString();
|
|
56
|
+
let id = val.split(',');
|
|
57
|
+
this.fields.forEach((c, i) => {
|
|
58
|
+
result[c.key] = c.valueConverter.fromJson(id[i]);
|
|
59
|
+
});
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -64,16 +64,17 @@ export const mySqlTest = addDatabaseToTest(testKnexSqlImpl(Knex.default({
|
|
|
64
64
|
database: 'test',
|
|
65
65
|
},
|
|
66
66
|
}), 'mysql2'));
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
67
|
+
if (false)
|
|
68
|
+
addDatabaseToTest(testKnexSqlImpl(Knex.default({
|
|
69
|
+
client: 'mysql',
|
|
70
|
+
connection: {
|
|
71
|
+
user: 'root',
|
|
72
|
+
password: 'MASTERKEY',
|
|
73
|
+
host: '127.0.0.1',
|
|
74
|
+
database: 'test',
|
|
75
|
+
port: 3307,
|
|
76
|
+
},
|
|
77
|
+
}), 'mysql'));
|
|
77
78
|
let pg = createPostgresConnection();
|
|
78
79
|
export function testPostgresImplementation(key, what, focus = false) {
|
|
79
80
|
itWithFocus(key + ' - postgres', async () => {
|
package/esm/src/data-api.js
CHANGED
|
@@ -22,7 +22,7 @@ export class DataApi {
|
|
|
22
22
|
async httpPost(res, req, body, serializeContext) {
|
|
23
23
|
const action = req?.get('__action');
|
|
24
24
|
if (action?.startsWith(liveQueryAction))
|
|
25
|
-
return this.liveQuery(res, req,
|
|
25
|
+
return this.liveQuery(res, req, body, serializeContext, action.substring(liveQueryAction.length));
|
|
26
26
|
switch (action) {
|
|
27
27
|
case 'get':
|
|
28
28
|
return this.getArray(res, req, body);
|
|
@@ -159,7 +159,9 @@ export class DataApi {
|
|
|
159
159
|
where.push(buildFilterFromRequestParameters(this.repository.metadata, {
|
|
160
160
|
get: (key) => {
|
|
161
161
|
let result = request.get(key);
|
|
162
|
-
if (key.startsWith(customUrlToken) &&
|
|
162
|
+
if (key.startsWith(customUrlToken) &&
|
|
163
|
+
result &&
|
|
164
|
+
typeof result === 'string')
|
|
163
165
|
return JSON.parse(result);
|
|
164
166
|
return result;
|
|
165
167
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class JsonEntityOpfsStorage {
|
|
2
|
+
//@internal
|
|
3
|
+
opfsRoot;
|
|
4
|
+
async getItem(entityDbName) {
|
|
5
|
+
const opfsFile = await (await this.init()).getFileHandle(entityDbName + '.json', {
|
|
6
|
+
create: true,
|
|
7
|
+
});
|
|
8
|
+
const readable = await opfsFile.getFile();
|
|
9
|
+
return await readable.text();
|
|
10
|
+
}
|
|
11
|
+
//@internal
|
|
12
|
+
async init() {
|
|
13
|
+
if (!this.opfsRoot) {
|
|
14
|
+
this.opfsRoot = await navigator.storage.getDirectory();
|
|
15
|
+
}
|
|
16
|
+
return this.opfsRoot;
|
|
17
|
+
}
|
|
18
|
+
async setItem(entityDbName, json) {
|
|
19
|
+
const opfsFile = await await (await this.init()).getFileHandle(entityDbName + '.json', {
|
|
20
|
+
create: true,
|
|
21
|
+
});
|
|
22
|
+
const writable = await opfsFile.createWritable();
|
|
23
|
+
await writable.write(json);
|
|
24
|
+
await writable.close();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function isOfType(obj, checkMethod) {
|
|
2
|
+
return typeof obj[checkMethod] !== 'undefined';
|
|
3
|
+
}
|
|
4
|
+
export function cast(obj, checkMethod) {
|
|
5
|
+
if (isOfType(obj, checkMethod)) {
|
|
6
|
+
return obj;
|
|
7
|
+
}
|
|
8
|
+
throw new Error(`Object is not of type ${checkMethod.toString()}`);
|
|
9
|
+
}
|
|
@@ -10,7 +10,7 @@ export class LiveQueryPublisher {
|
|
|
10
10
|
runPromise(p) { }
|
|
11
11
|
async itemChanged(entityKey, changes) {
|
|
12
12
|
//TODO 2 - optimize so that the user will get their messages first. Based on user id
|
|
13
|
-
await this.liveQueryStorage().forEach(entityKey, async ({ query: q, setData }) => {
|
|
13
|
+
await this.runPromise(this.liveQueryStorage().forEach(entityKey, async ({ query: q, setData }) => {
|
|
14
14
|
let query = { ...q.data };
|
|
15
15
|
await this.performWithContext(query.requestJson, entityKey, async (repo) => {
|
|
16
16
|
const messages = [];
|
|
@@ -59,7 +59,7 @@ export class LiveQueryPublisher {
|
|
|
59
59
|
if (messages.length > 0)
|
|
60
60
|
this.subscriptionServer().publishMessage(q.id, messages);
|
|
61
61
|
});
|
|
62
|
-
});
|
|
62
|
+
}));
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
export class InMemoryLiveQueryStorage {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const remultStaticKey = Symbol.for('remult-static1');
|
|
2
|
+
let x = {
|
|
3
|
+
defaultRemultFactory: undefined,
|
|
4
|
+
remultFactory: undefined,
|
|
5
|
+
defaultRemult: undefined,
|
|
6
|
+
asyncContext: undefined,
|
|
7
|
+
columnsOfType: new Map(),
|
|
8
|
+
allEntities: [],
|
|
9
|
+
classHelpers: new Map(),
|
|
10
|
+
actionInfo: {
|
|
11
|
+
allActions: [],
|
|
12
|
+
runningOnServer: false,
|
|
13
|
+
runActionWithoutBlockingUI: (what) => {
|
|
14
|
+
return what();
|
|
15
|
+
},
|
|
16
|
+
startBusyWithProgress: () => ({
|
|
17
|
+
progress: (percent) => { },
|
|
18
|
+
close: () => { },
|
|
19
|
+
}),
|
|
20
|
+
},
|
|
21
|
+
captionTransformer: undefined,
|
|
22
|
+
defaultDataProvider: () => undefined,
|
|
23
|
+
};
|
|
24
|
+
if ((typeof process !== 'undefined' &&
|
|
25
|
+
process.env['IGNORE_GLOBAL_REMULT_IN_TESTS']) ||
|
|
26
|
+
typeof globalThis[remultStaticKey] === 'undefined') {
|
|
27
|
+
;
|
|
28
|
+
globalThis[remultStaticKey] = x;
|
|
29
|
+
x.remultFactory = () => defaultFactory();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
x = globalThis[remultStaticKey];
|
|
33
|
+
}
|
|
34
|
+
export const remultStatic = x;
|
|
35
|
+
export function defaultFactory() {
|
|
36
|
+
if (!remultStatic.defaultRemult) {
|
|
37
|
+
remultStatic.defaultRemult = remultStatic.defaultRemultFactory();
|
|
38
|
+
}
|
|
39
|
+
return remultStatic.defaultRemult;
|
|
40
|
+
}
|
|
41
|
+
export function resetFactory() {
|
|
42
|
+
remultStatic.remultFactory = () => defaultFactory();
|
|
43
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { createId } from '@paralleldrive/cuid2';
|
|
2
|
+
import { v4 as uuid } from 'uuid';
|
|
3
|
+
import { ValueConverters } from '../valueConverters.js';
|
|
4
|
+
import { buildOptions, fieldOptionalValuesFunctionKey, } from './RepositoryImplementation.js';
|
|
5
|
+
import { Validators, createValueValidator, getEnumValues, } from '../validators.js';
|
|
6
|
+
import { relationInfoMemberInOptions } from './relationInfoMember.js';
|
|
7
|
+
import { remultStatic } from '../remult-static.js';
|
|
8
|
+
import { addValidator } from './addValidator.js';
|
|
9
|
+
import { isOfType } from '../isOfType.js';
|
|
10
|
+
const validateNumber = createValueValidator((x) => {
|
|
11
|
+
return !isNaN(x) && isFinite(x);
|
|
12
|
+
});
|
|
13
|
+
export class Fields {
|
|
14
|
+
/**
|
|
15
|
+
* Stored as a JSON.stringify - to store as json use Fields.json
|
|
16
|
+
*/
|
|
17
|
+
static object(...options) {
|
|
18
|
+
return Field(undefined, ...options);
|
|
19
|
+
}
|
|
20
|
+
static json(...options) {
|
|
21
|
+
let op = options;
|
|
22
|
+
if (op.valueConverter && !op.valueConverter.fieldTypeInDb)
|
|
23
|
+
//@ts-ignore
|
|
24
|
+
op.valueConverter.fieldTypeInDb = 'json';
|
|
25
|
+
return Field(undefined, {
|
|
26
|
+
valueConverter: {
|
|
27
|
+
fieldTypeInDb: 'json',
|
|
28
|
+
},
|
|
29
|
+
}, ...options);
|
|
30
|
+
}
|
|
31
|
+
static dateOnly(...options) {
|
|
32
|
+
return Field(() => Date, {
|
|
33
|
+
valueConverter: ValueConverters.DateOnly,
|
|
34
|
+
}, ...options);
|
|
35
|
+
}
|
|
36
|
+
static date(...options) {
|
|
37
|
+
return Field(() => Date, ...options);
|
|
38
|
+
}
|
|
39
|
+
static integer(...options) {
|
|
40
|
+
return Field(() => Number, {
|
|
41
|
+
valueConverter: ValueConverters.Integer,
|
|
42
|
+
validate: validateNumber,
|
|
43
|
+
}, ...options);
|
|
44
|
+
}
|
|
45
|
+
static autoIncrement(...options) {
|
|
46
|
+
return Field(() => Number, {
|
|
47
|
+
allowApiUpdate: false,
|
|
48
|
+
dbReadOnly: true,
|
|
49
|
+
valueConverter: {
|
|
50
|
+
...ValueConverters.Integer,
|
|
51
|
+
fieldTypeInDb: 'autoincrement',
|
|
52
|
+
},
|
|
53
|
+
}, ...options);
|
|
54
|
+
}
|
|
55
|
+
static number(...options) {
|
|
56
|
+
return Field(() => Number, {
|
|
57
|
+
validate: validateNumber,
|
|
58
|
+
}, ...options);
|
|
59
|
+
}
|
|
60
|
+
static createdAt(...options) {
|
|
61
|
+
return Field(() => Date, {
|
|
62
|
+
allowApiUpdate: false,
|
|
63
|
+
saving: (_, ref, { isNew }) => {
|
|
64
|
+
if (isNew)
|
|
65
|
+
ref.value = new Date();
|
|
66
|
+
},
|
|
67
|
+
}, ...options);
|
|
68
|
+
}
|
|
69
|
+
static updatedAt(...options) {
|
|
70
|
+
return Field(() => Date, {
|
|
71
|
+
allowApiUpdate: false,
|
|
72
|
+
saving: (_, ref) => {
|
|
73
|
+
ref.value = new Date();
|
|
74
|
+
},
|
|
75
|
+
}, ...options);
|
|
76
|
+
}
|
|
77
|
+
static uuid(...options) {
|
|
78
|
+
return Field(() => String, {
|
|
79
|
+
allowApiUpdate: false,
|
|
80
|
+
defaultValue: () => uuid(),
|
|
81
|
+
saving: (_, r) => {
|
|
82
|
+
if (!r.value)
|
|
83
|
+
r.value = uuid();
|
|
84
|
+
},
|
|
85
|
+
}, ...options);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A CUID (Collision Resistant Unique Identifier) field.
|
|
89
|
+
* This id value is determined on the backend on insert, and can't be updated through the API.
|
|
90
|
+
* The CUID is generated using the `@paralleldrive/cuid2` npm package.
|
|
91
|
+
*/
|
|
92
|
+
static cuid(...options) {
|
|
93
|
+
return Field(() => String, {
|
|
94
|
+
allowApiUpdate: false,
|
|
95
|
+
defaultValue: () => createId(),
|
|
96
|
+
saving: (_, r) => {
|
|
97
|
+
if (!r.value)
|
|
98
|
+
r.value = createId();
|
|
99
|
+
},
|
|
100
|
+
}, ...options);
|
|
101
|
+
}
|
|
102
|
+
// static id<entityType = unknown>(
|
|
103
|
+
// options?: FieldOptions<entityType, string> & { idFactory?: () => string },
|
|
104
|
+
// ): ClassFieldDecorator<entityType, string | undefined> {
|
|
105
|
+
// let buildId = options?.idFactory ?? createId
|
|
106
|
+
// return Field(() => String, {
|
|
107
|
+
// allowApiUpdate: false,
|
|
108
|
+
// defaultValue: () => buildId(),
|
|
109
|
+
// saving: (_, r) => {
|
|
110
|
+
// if (!r.value) r.value = buildId()
|
|
111
|
+
// },
|
|
112
|
+
// })
|
|
113
|
+
// }
|
|
114
|
+
/**
|
|
115
|
+
* Defines a field that can hold a value from a specified set of string literals.
|
|
116
|
+
* @param {() => readonly valueType[]} optionalValues - A function that returns an array of allowed string literals.
|
|
117
|
+
* @returns {ClassFieldDecorator<entityType, valueType | undefined>} - A class field decorator.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
|
|
121
|
+
* class MyEntity {
|
|
122
|
+
* .@Fields.literal(() => ['open', 'closed', 'frozen', 'in progress'] as const)
|
|
123
|
+
* status: 'open' | 'closed' | 'frozen' | 'in progress' = 'open';
|
|
124
|
+
* }
|
|
125
|
+
|
|
126
|
+
*
|
|
127
|
+
* // This defines a field `status` in `MyEntity` that can only hold the values 'open', 'closed', 'frozen', or 'in progress'.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* // For better reusability and maintainability:
|
|
131
|
+
|
|
132
|
+
* const statuses = ['open', 'closed', 'frozen', 'in progress'] as const;
|
|
133
|
+
* type StatusType = typeof statuses[number];
|
|
134
|
+
*
|
|
135
|
+
* class MyEntity {
|
|
136
|
+
* .@Fields.literal(() => statuses)
|
|
137
|
+
* status: StatusType = 'open';
|
|
138
|
+
* }
|
|
139
|
+
|
|
140
|
+
*
|
|
141
|
+
* // This approach allows easy management and updates of the allowed values for the `status` field.
|
|
142
|
+
*/
|
|
143
|
+
static literal(optionalValues, ...options) {
|
|
144
|
+
return Fields.string({
|
|
145
|
+
validate: (entity, event) => Validators.in(optionalValues())(entity, event),
|
|
146
|
+
//@ts-expect-error as we are adding this to options without it being defined in options
|
|
147
|
+
[fieldOptionalValuesFunctionKey]: optionalValues,
|
|
148
|
+
}, ...options);
|
|
149
|
+
}
|
|
150
|
+
static enum(enumType, ...options) {
|
|
151
|
+
let valueConverter;
|
|
152
|
+
return Field(
|
|
153
|
+
//@ts-ignore
|
|
154
|
+
() => enumType(), {
|
|
155
|
+
validate: (entity, event) => Validators.enum(enumType())(entity, event),
|
|
156
|
+
[fieldOptionalValuesFunctionKey]: () => getEnumValues(enumType()),
|
|
157
|
+
}, ...options, (options) => {
|
|
158
|
+
;
|
|
159
|
+
options[fieldOptionalValuesFunctionKey] = () => getEnumValues(enumType());
|
|
160
|
+
if (valueConverter === undefined) {
|
|
161
|
+
let enumObj = enumType();
|
|
162
|
+
let enumValues = getEnumValues(enumObj);
|
|
163
|
+
valueConverter = enumValues.find((x) => typeof x === 'string')
|
|
164
|
+
? ValueConverters.String
|
|
165
|
+
: ValueConverters.Integer;
|
|
166
|
+
}
|
|
167
|
+
if (!options.valueConverter) {
|
|
168
|
+
options.valueConverter = valueConverter;
|
|
169
|
+
}
|
|
170
|
+
else if (!options.valueConverter.fieldTypeInDb) {
|
|
171
|
+
//@ts-ignore
|
|
172
|
+
options.valueConverter.fieldTypeInDb = valueConverter.fieldTypeInDb;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
static string(...options) {
|
|
177
|
+
return Field(() => String, ...options);
|
|
178
|
+
}
|
|
179
|
+
static boolean(...options) {
|
|
180
|
+
return Field(() => Boolean, ...options);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
export class Relations {
|
|
184
|
+
/**
|
|
185
|
+
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
186
|
+
* If no field or fields are provided, it will automatically create a field in the database
|
|
187
|
+
* to represent the relation.
|
|
188
|
+
*
|
|
189
|
+
* @param toEntityType A function that returns the target entity type.
|
|
190
|
+
* @param options (Optional): An object containing options for configuring the to-one relation.
|
|
191
|
+
* @returns A decorator function to apply the to-one relation to an entity field.
|
|
192
|
+
*
|
|
193
|
+
* Example usage:
|
|
194
|
+
* ```
|
|
195
|
+
* @Relations.toOne(() => Customer)
|
|
196
|
+
* customer?: Customer;
|
|
197
|
+
* ```
|
|
198
|
+
* ```
|
|
199
|
+
* Fields.string()
|
|
200
|
+
* customerId?: string;
|
|
201
|
+
*
|
|
202
|
+
* @Relations.toOne(() => Customer, "customerId")
|
|
203
|
+
* customer?: Customer;
|
|
204
|
+
* ```
|
|
205
|
+
* ```
|
|
206
|
+
* Fields.string()
|
|
207
|
+
* customerId?: string;
|
|
208
|
+
*
|
|
209
|
+
* @Relations.toOne(() => Customer, {
|
|
210
|
+
* field: "customerId",
|
|
211
|
+
* defaultIncluded: true
|
|
212
|
+
* })
|
|
213
|
+
* customer?: Customer;
|
|
214
|
+
* ```
|
|
215
|
+
* ```
|
|
216
|
+
* Fields.string()
|
|
217
|
+
* customerId?: string;
|
|
218
|
+
*
|
|
219
|
+
* @Relations.toOne(() => Customer, {
|
|
220
|
+
* fields: {
|
|
221
|
+
* customerId: "id",
|
|
222
|
+
* },
|
|
223
|
+
* })
|
|
224
|
+
* customer?: Customer;
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
static toOne(toEntityType, options) {
|
|
228
|
+
let op = (typeof options === 'string'
|
|
229
|
+
? { field: options }
|
|
230
|
+
: !options
|
|
231
|
+
? {}
|
|
232
|
+
: options);
|
|
233
|
+
if (!op.field && !op.fields && !op.findOptions)
|
|
234
|
+
//@ts-ignore
|
|
235
|
+
return Field(toEntityType, {
|
|
236
|
+
...op,
|
|
237
|
+
...relationInfoMemberInOptions(toEntityType, 'reference'),
|
|
238
|
+
});
|
|
239
|
+
return Field(() => undefined, {
|
|
240
|
+
...op,
|
|
241
|
+
serverExpression: () => undefined,
|
|
242
|
+
...relationInfoMemberInOptions(toEntityType, 'toOne'),
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
static toMany(toEntityType, options) {
|
|
246
|
+
let op = (typeof options === 'string'
|
|
247
|
+
? { field: options }
|
|
248
|
+
: options);
|
|
249
|
+
return Field(() => undefined, {
|
|
250
|
+
...op,
|
|
251
|
+
serverExpression: () => undefined,
|
|
252
|
+
...relationInfoMemberInOptions(toEntityType, 'toMany'),
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**Decorates fields that should be used as fields.
|
|
257
|
+
* for more info see: [Field Types](https://remult.dev/docs/field-types.html)
|
|
258
|
+
*
|
|
259
|
+
* FieldOptions can be set in two ways:
|
|
260
|
+
* @example
|
|
261
|
+
* // as an object
|
|
262
|
+
* @Fields.string({ includeInApi:false })
|
|
263
|
+
* title='';
|
|
264
|
+
* @example
|
|
265
|
+
* // as an arrow function that receives `remult` as a parameter
|
|
266
|
+
* @Fields.string((options,remult) => options.includeInApi = true)
|
|
267
|
+
* title='';
|
|
268
|
+
*/
|
|
269
|
+
export function Field(valueType, ...options) {
|
|
270
|
+
// import ANT!!!! if you call this in another decorator, make sure to set It's return type correctly with the | undefined
|
|
271
|
+
return (target, context, c) => {
|
|
272
|
+
const key = typeof context === 'string' ? context : context.name.toString();
|
|
273
|
+
let factory = (remult) => {
|
|
274
|
+
let r = buildOptions(options, remult);
|
|
275
|
+
if (r.required) {
|
|
276
|
+
r.validate = addValidator(r.validate, Validators.required, true);
|
|
277
|
+
}
|
|
278
|
+
if (isOfType(r, 'maxLength')) {
|
|
279
|
+
let z = r;
|
|
280
|
+
if (z.maxLength) {
|
|
281
|
+
z.validate = addValidator(z.validate, Validators.maxLength(z.maxLength));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (isOfType(r, 'minLength')) {
|
|
285
|
+
let z = r;
|
|
286
|
+
if (z.minLength) {
|
|
287
|
+
z.validate = addValidator(z.validate, Validators.minLength(z.minLength));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if (!r.valueType && valueType) {
|
|
291
|
+
r.valueType = valueType();
|
|
292
|
+
}
|
|
293
|
+
if (!r.key) {
|
|
294
|
+
r.key = key;
|
|
295
|
+
}
|
|
296
|
+
if (!r.dbName)
|
|
297
|
+
r.dbName = r.key;
|
|
298
|
+
let type = r.valueType;
|
|
299
|
+
if (!type) {
|
|
300
|
+
type =
|
|
301
|
+
typeof Reflect.getMetadata == 'function'
|
|
302
|
+
? Reflect.getMetadata('design:type', target, key)
|
|
303
|
+
: [];
|
|
304
|
+
r.valueType = type;
|
|
305
|
+
}
|
|
306
|
+
if (!r.target)
|
|
307
|
+
r.target = target;
|
|
308
|
+
return r;
|
|
309
|
+
};
|
|
310
|
+
checkTarget(target);
|
|
311
|
+
let names = remultStatic.columnsOfType.get(target.constructor);
|
|
312
|
+
if (!names) {
|
|
313
|
+
names = [];
|
|
314
|
+
remultStatic.columnsOfType.set(target.constructor, names);
|
|
315
|
+
}
|
|
316
|
+
let set = names.find((x) => x.key == key);
|
|
317
|
+
if (!set)
|
|
318
|
+
names.push({
|
|
319
|
+
key,
|
|
320
|
+
settings: factory,
|
|
321
|
+
});
|
|
322
|
+
else {
|
|
323
|
+
let prev = set.settings;
|
|
324
|
+
set.settings = (c) => {
|
|
325
|
+
let prevO = prev(c);
|
|
326
|
+
let curr = factory(c);
|
|
327
|
+
return Object.assign(prevO, curr);
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
export function checkTarget(target) {
|
|
333
|
+
if (!target)
|
|
334
|
+
throw new Error("Set the 'experimentalDecorators:true' option in your 'tsconfig' or 'jsconfig' (target undefined)");
|
|
335
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Fields } from './Fields.js';
|
|
3
|
+
import { EntityBase } from './RepositoryImplementation.js';
|
|
4
|
+
export class IdEntity extends EntityBase {
|
|
5
|
+
id;
|
|
6
|
+
}
|
|
7
|
+
__decorate([
|
|
8
|
+
Fields.uuid(),
|
|
9
|
+
__metadata("design:type", String)
|
|
10
|
+
], IdEntity.prototype, "id", void 0);
|
|
@@ -937,7 +937,9 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
937
937
|
if (this.wasDeleted())
|
|
938
938
|
throw new Error('cannot save a deleted row');
|
|
939
939
|
this.isLoading = true;
|
|
940
|
-
if (onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject ===
|
|
940
|
+
if (onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject ===
|
|
941
|
+
undefined)
|
|
942
|
+
// no need
|
|
941
943
|
await this.__validateEntity();
|
|
942
944
|
let doNotSave = false;
|
|
943
945
|
for (const col of this.fields) {
|
|
@@ -952,7 +954,8 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
952
954
|
let ignoreKeys = [];
|
|
953
955
|
for (const field of this.metadata.fields) {
|
|
954
956
|
if (field.dbReadOnly ||
|
|
955
|
-
(onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject !==
|
|
957
|
+
(onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject !==
|
|
958
|
+
undefined &&
|
|
956
959
|
!onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject.includes(field.key))) {
|
|
957
960
|
d[field.key] = undefined;
|
|
958
961
|
ignoreKeys.push(field.key);
|
|
@@ -998,7 +1001,7 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
998
1001
|
for (const listener of this.repository.listeners.filter((x) => x.saved)) {
|
|
999
1002
|
await listener.saved(this.instance, isNew);
|
|
1000
1003
|
}
|
|
1001
|
-
|
|
1004
|
+
this.repository.remult.liveQueryPublisher.itemChanged(this.repository.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: false }]);
|
|
1002
1005
|
this.saveOriginalData();
|
|
1003
1006
|
this._isNew = false;
|
|
1004
1007
|
return this.instance;
|
|
@@ -1029,7 +1032,7 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1029
1032
|
for (const listener of this.repository.listeners.filter((x) => x.deleted)) {
|
|
1030
1033
|
await listener.deleted(this.instance);
|
|
1031
1034
|
}
|
|
1032
|
-
|
|
1035
|
+
this.repository.remult.liveQueryPublisher.itemChanged(this.repository.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: true }]);
|
|
1033
1036
|
this._wasDeleted = true;
|
|
1034
1037
|
}
|
|
1035
1038
|
catch (err) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Filter } from '../filter/filter-interfaces.js';
|
|
2
|
+
export function __updateEntityBasedOnWhere(entityDefs, where, r) {
|
|
3
|
+
let w = Filter.fromEntityFilter(entityDefs, where);
|
|
4
|
+
const emptyFunction = () => { };
|
|
5
|
+
if (w) {
|
|
6
|
+
w.__applyToConsumer({
|
|
7
|
+
custom: emptyFunction,
|
|
8
|
+
databaseCustom: emptyFunction,
|
|
9
|
+
containsCaseInsensitive: emptyFunction,
|
|
10
|
+
notContainsCaseInsensitive: emptyFunction,
|
|
11
|
+
startsWithCaseInsensitive: emptyFunction,
|
|
12
|
+
endsWithCaseInsensitive: emptyFunction,
|
|
13
|
+
isDifferentFrom: emptyFunction,
|
|
14
|
+
isEqualTo: (col, val) => {
|
|
15
|
+
r[col.key] = val;
|
|
16
|
+
},
|
|
17
|
+
isGreaterOrEqualTo: emptyFunction,
|
|
18
|
+
isGreaterThan: emptyFunction,
|
|
19
|
+
isIn: emptyFunction,
|
|
20
|
+
isLessOrEqualTo: emptyFunction,
|
|
21
|
+
isLessThan: emptyFunction,
|
|
22
|
+
isNotNull: emptyFunction,
|
|
23
|
+
isNull: emptyFunction,
|
|
24
|
+
not: emptyFunction,
|
|
25
|
+
or: emptyFunction,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function addValidator(validators, newValidator, atStart = false) {
|
|
2
|
+
if (!newValidator)
|
|
3
|
+
return validators;
|
|
4
|
+
const newValidators = Array.isArray(newValidator)
|
|
5
|
+
? newValidator
|
|
6
|
+
: [newValidator];
|
|
7
|
+
const validatorsArray = Array.isArray(validators)
|
|
8
|
+
? validators
|
|
9
|
+
: validators
|
|
10
|
+
? [validators]
|
|
11
|
+
: [];
|
|
12
|
+
return atStart
|
|
13
|
+
? [...newValidators, ...validatorsArray]
|
|
14
|
+
: [...validatorsArray, ...newValidators];
|
|
15
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BackendMethod } from '../server-action.js';
|
|
2
|
+
import { Entity } from './entity.js';
|
|
3
|
+
export function describeClass(classType, classDescriber, members, staticMembers) {
|
|
4
|
+
if (classDescriber)
|
|
5
|
+
classDescriber(classType);
|
|
4
6
|
for (const fieldKey in members) {
|
|
5
7
|
if (Object.prototype.hasOwnProperty.call(members, fieldKey)) {
|
|
6
8
|
const element = members[fieldKey];
|
|
@@ -18,3 +20,16 @@ export function describeClass(classType, classDecorator, members, staticMembers)
|
|
|
18
20
|
Object.defineProperty(classType, staticFieldKey, prop);
|
|
19
21
|
}
|
|
20
22
|
}
|
|
23
|
+
export function describeBackendMethods(classType, backendMethods) {
|
|
24
|
+
let result = {};
|
|
25
|
+
for (const key in backendMethods) {
|
|
26
|
+
if (Object.prototype.hasOwnProperty.call(backendMethods, key)) {
|
|
27
|
+
const options = backendMethods[key];
|
|
28
|
+
result[key] = BackendMethod(options);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
describeClass(classType, undefined, undefined, result);
|
|
32
|
+
}
|
|
33
|
+
export function describeEntity(classType, key, fields, options) {
|
|
34
|
+
describeClass(classType, Entity(key, options), fields);
|
|
35
|
+
}
|