@tstdl/base 0.81.35 → 0.82.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/client/client.d.ts +3 -3
- package/api/default-error-handlers.d.ts +1 -1
- package/api/response.d.ts +8 -8
- package/api/server/api-controller.d.ts +1 -1
- package/api/server/gateway.d.ts +9 -9
- package/api/server/middlewares/cors.middleware.d.ts +1 -1
- package/api/server/module.d.ts +1 -1
- package/api/types.d.ts +30 -30
- package/api/utils.d.ts +1 -1
- package/api/utils.js +3 -1
- package/api/utils.js.map +1 -1
- package/authentication/authentication-credentials.service.d.ts +6 -0
- package/authentication/authentication-credentials.service.js +17 -0
- package/authentication/authentication-credentials.service.js.map +1 -0
- package/authentication/authentication-session.repository.d.ts +6 -0
- package/authentication/authentication-session.repository.js +18 -0
- package/authentication/authentication-session.repository.js.map +1 -0
- package/authentication/authentication-token-payload.provider.d.ts +3 -0
- package/authentication/authentication-token-payload.provider.js +17 -0
- package/authentication/authentication-token-payload.provider.js.map +1 -0
- package/authentication/authentication.service.d.ts +42 -0
- package/authentication/authentication.service.js +133 -0
- package/authentication/authentication.service.js.map +1 -0
- package/authentication/models/authentication-credentials.model.d.ts +11 -0
- package/authentication/models/authentication-credentials.model.js +44 -0
- package/authentication/models/authentication-credentials.model.js.map +1 -0
- package/authentication/models/authentication-session.model.d.ts +14 -0
- package/authentication/models/authentication-session.model.js +59 -0
- package/authentication/models/authentication-session.model.js.map +1 -0
- package/authentication/models/index.d.ts +2 -0
- package/authentication/models/index.js +19 -0
- package/authentication/models/index.js.map +1 -0
- package/authentication/tokens.d.ts +2 -0
- package/authentication/tokens.js +6 -0
- package/authentication/tokens.js.map +1 -0
- package/collections/keyed-set.d.ts +1 -1
- package/collections/observable/observable-collection.d.ts +1 -1
- package/collections/observable/observable-list.d.ts +2 -2
- package/container/container.d.ts +3 -3
- package/container/container.js +3 -3
- package/container/container.js.map +1 -1
- package/container/decorators.d.ts +3 -3
- package/container/decorators.js +0 -1
- package/container/decorators.js.map +1 -1
- package/container/interfaces.d.ts +1 -1
- package/container/provider.d.ts +6 -6
- package/container/resolve-chain.d.ts +2 -2
- package/container/resolve-chain.js +1 -1
- package/container/resolve-chain.js.map +1 -1
- package/container/token.d.ts +3 -3
- package/container/type-info.d.ts +1 -1
- package/container/types.d.ts +4 -4
- package/core.d.ts +1 -1
- package/data-structures/linked-list.d.ts +1 -1
- package/data-structures/multi-key-map.d.ts +2 -2
- package/data-structures/sorted-array-list.d.ts +1 -1
- package/database/entity-repository.d.ts +2 -2
- package/database/entity.d.ts +3 -3
- package/database/module.d.ts +1 -1
- package/database/mongo/classes.d.ts +3 -3
- package/database/mongo/model/document.d.ts +3 -3
- package/database/mongo/module.d.ts +1 -1
- package/database/mongo/mongo-base.repository.d.ts +11 -11
- package/database/mongo/mongo-bulk.d.ts +1 -1
- package/database/mongo/mongo-entity-repository.d.ts +7 -7
- package/database/mongo/types.d.ts +16 -16
- package/database/query.d.ts +38 -38
- package/disposable/async-disposer.d.ts +3 -3
- package/distributed-loop/distributed-loop.d.ts +2 -2
- package/error/custom.error.d.ts +1 -1
- package/http/client/adapters/undici-http-client.adapter.d.ts +1 -1
- package/http/client/http-client-request.d.ts +5 -5
- package/http/client/http-client-response.d.ts +2 -2
- package/http/client/http-client.d.ts +5 -5
- package/http/http-body.d.ts +3 -1
- package/http/http-body.js +18 -12
- package/http/http-body.js.map +1 -1
- package/http/http-form.d.ts +2 -2
- package/http/http-headers.d.ts +3 -3
- package/http/http-query.d.ts +2 -2
- package/http/http-url-parameters.d.ts +2 -2
- package/http/http-value-map.d.ts +1 -1
- package/http/server/http-server-request.d.ts +1 -1
- package/http/server/http-server-response.d.ts +1 -1
- package/http/server/http-server.d.ts +1 -1
- package/http/server/node/node-http-server.d.ts +1 -1
- package/http/types.d.ts +5 -5
- package/http/utils.d.ts +3 -3
- package/image-service/imgproxy/imgproxy-image-service.d.ts +1 -1
- package/json-path/json-path.d.ts +4 -4
- package/key-value-store/key-value.store.d.ts +1 -1
- package/key-value-store/mongo/module.d.ts +1 -1
- package/key-value-store/mongo/mongo-key-value.model.d.ts +1 -1
- package/lock/lock.d.ts +4 -4
- package/lock/mongo/model.d.ts +1 -1
- package/lock/mongo/module.d.ts +1 -1
- package/lock/provider.d.ts +1 -1
- package/logger/logger.d.ts +6 -6
- package/mail/mail.client.d.ts +1 -1
- package/mail/mail.service.d.ts +3 -1
- package/mail/mail.service.js +11 -6
- package/mail/mail.service.js.map +1 -1
- package/mail/models/mail-address.model.d.ts +1 -1
- package/mail/models/mail-content.model.d.ts +1 -1
- package/mail/models/mail-data.model.d.ts +2 -1
- package/mail/models/mail-log.model.d.ts +2 -2
- package/mail/models/mail-send-result.model.d.ts +1 -1
- package/mail/models/mail-template.model.d.ts +1 -1
- package/mail/module.d.ts +4 -2
- package/mail/module.js +6 -2
- package/mail/module.js.map +1 -1
- package/mail/repositories/mongo-mail-log.repository.d.ts +2 -2
- package/mail/tokens.d.ts +1 -0
- package/mail/tokens.js +2 -1
- package/mail/tokens.js.map +1 -1
- package/message-bus/local/types.d.ts +1 -1
- package/message-bus/message-bus.d.ts +1 -1
- package/migration/migration-state.d.ts +2 -2
- package/migration/migrator.d.ts +4 -4
- package/migration/mongo/module.d.ts +1 -1
- package/module/module-metric-reporter.d.ts +2 -2
- package/module/module.d.ts +1 -1
- package/module/modules/function.module.d.ts +1 -1
- package/module/modules/web-server.module.d.ts +1 -1
- package/notification/api.d.ts +3 -6
- package/notification/api.js +2 -5
- package/notification/api.js.map +1 -1
- package/notification/models/index.d.ts +2 -0
- package/notification/models/index.js +19 -0
- package/notification/models/index.js.map +1 -0
- package/notification/models/notification-channel-job.model.d.ts +3 -0
- package/notification/models/notification-channel-job.model.js +3 -0
- package/notification/models/notification-channel-job.model.js.map +1 -0
- package/notification/models/notification.model.d.ts +27 -0
- package/notification/{model.js → models/notification.model.js} +28 -16
- package/notification/models/notification.model.js.map +1 -0
- package/notification/module.d.ts +1 -1
- package/notification/notification-channel.service.d.ts +5 -0
- package/notification/notification-channel.service.js +7 -0
- package/notification/notification-channel.service.js.map +1 -0
- package/notification/notification.service.d.ts +8 -0
- package/notification/notification.service.js +40 -0
- package/notification/notification.service.js.map +1 -0
- package/object-storage/object-storage.d.ts +2 -2
- package/object-storage/object.d.ts +1 -1
- package/object-storage/s3/s3.object-storage-provider.d.ts +1 -1
- package/openid-connect/mongo-oidc-state.repository.d.ts +1 -1
- package/openid-connect/oidc-configuration.service.d.ts +1 -1
- package/openid-connect/oidc-state.model.d.ts +2 -2
- package/openid-connect/oidc.service-model.d.ts +8 -8
- package/orm/decorators.d.ts +26 -0
- package/orm/decorators.js +170 -0
- package/orm/decorators.js.map +1 -1
- package/orm/entity-definition.model.d.ts +51 -0
- package/orm/entity-definition.model.js +27 -0
- package/orm/entity-definition.model.js.map +1 -0
- package/orm/index.d.ts +1 -0
- package/orm/index.js +18 -0
- package/orm/index.js.map +1 -0
- package/orm/models/entity.d.ts +22 -0
- package/orm/models/entity.js +87 -0
- package/orm/models/entity.js.map +1 -0
- package/orm/models/index.d.ts +1 -0
- package/orm/models/index.js +18 -0
- package/orm/models/index.js.map +1 -0
- package/orm/repository/mongo/classes.d.ts +25 -0
- package/orm/repository/mongo/classes.js +33 -0
- package/orm/repository/mongo/classes.js.map +1 -0
- package/orm/repository/mongo/module.d.ts +8 -0
- package/orm/repository/mongo/module.js +88 -0
- package/orm/repository/mongo/module.js.map +1 -0
- package/orm/repository/mongo/mongo-repository.d.ts +11 -0
- package/orm/repository/mongo/mongo-repository.js +55 -0
- package/orm/repository/mongo/mongo-repository.js.map +1 -0
- package/orm/repository/mongo/mongo-transaction.d.ts +10 -0
- package/orm/repository/mongo/mongo-transaction.js +28 -0
- package/orm/repository/mongo/mongo-transaction.js.map +1 -0
- package/orm/repository/repository.d.ts +75 -0
- package/orm/repository/repository.js +182 -0
- package/orm/repository/repository.js.map +1 -0
- package/orm/repository/transaction.d.ts +26 -0
- package/orm/repository/transaction.js +65 -0
- package/orm/repository/transaction.js.map +1 -0
- package/orm/{types.d.ts → types/definition.d.ts} +5 -5
- package/orm/{types.js → types/definition.js} +8 -8
- package/orm/types/definition.js.map +1 -0
- package/orm/types/index.d.ts +3 -0
- package/orm/types/index.js +20 -0
- package/orm/types/index.js.map +1 -0
- package/orm/types/options.d.ts +36 -0
- package/orm/types/options.js +5 -0
- package/orm/types/options.js.map +1 -0
- package/orm/types/query.d.ts +110 -0
- package/orm/types/query.js +10 -0
- package/orm/types/query.js.map +1 -0
- package/package.json +5 -5
- package/pdf/pdf.service.d.ts +3 -3
- package/pool/pool.d.ts +4 -4
- package/promise/cancelable-promise.d.ts +1 -1
- package/promise/lazy-promise.d.ts +1 -1
- package/queue/mongo/job.d.ts +2 -2
- package/queue/mongo/queue.js +2 -2
- package/queue/mongo/queue.js.map +1 -1
- package/queue/queue.d.ts +11 -6
- package/queue/queue.js +2 -1
- package/queue/queue.js.map +1 -1
- package/reflection/decorator-data.js +2 -1
- package/reflection/decorator-data.js.map +1 -1
- package/reflection/registry.d.ts +18 -17
- package/reflection/registry.js +25 -10
- package/reflection/registry.js.map +1 -1
- package/reflection/types.d.ts +34 -34
- package/reflection/utils.d.ts +8 -8
- package/reflection/utils.js +6 -6
- package/reflection/utils.js.map +1 -1
- package/rpc/endpoints/message-port.rpc-endpoint.d.ts +3 -3
- package/rpc/model.d.ts +22 -22
- package/rpc/rpc.d.ts +1 -1
- package/rxjs/intersection-observer.d.ts +1 -1
- package/rxjs/mutation-observer.d.ts +1 -1
- package/rxjs/performance-observer.d.ts +1 -1
- package/rxjs/resize-observer.d.ts +1 -1
- package/rxjs/slow-array.d.ts +1 -1
- package/rxjs/touch.d.ts +1 -1
- package/schema/array-constraints/maximum-length.d.ts +2 -2
- package/schema/array-constraints/maximum-length.js +2 -2
- package/schema/array-constraints/maximum-length.js.map +1 -1
- package/schema/array-constraints/minimum-length.d.ts +2 -2
- package/schema/array-constraints/minimum-length.js +2 -2
- package/schema/array-constraints/minimum-length.js.map +1 -1
- package/schema/constraints/enumeration.d.ts +4 -4
- package/schema/constraints/enumeration.js +5 -5
- package/schema/constraints/enumeration.js.map +1 -1
- package/schema/constraints/generic.d.ts +4 -4
- package/schema/constraints/generic.js +2 -2
- package/schema/constraints/generic.js.map +1 -1
- package/schema/constraints/integer.d.ts +2 -2
- package/schema/constraints/integer.js +3 -2
- package/schema/constraints/integer.js.map +1 -1
- package/schema/constraints/length.d.ts +1 -1
- package/schema/constraints/literal.d.ts +2 -2
- package/schema/constraints/literal.js +2 -2
- package/schema/constraints/literal.js.map +1 -1
- package/schema/constraints/maximum-date.d.ts +2 -2
- package/schema/constraints/maximum-date.js +3 -2
- package/schema/constraints/maximum-date.js.map +1 -1
- package/schema/constraints/maximum-length.d.ts +2 -2
- package/schema/constraints/maximum-length.js +2 -2
- package/schema/constraints/maximum-length.js.map +1 -1
- package/schema/constraints/maximum.d.ts +2 -2
- package/schema/constraints/maximum.js +3 -2
- package/schema/constraints/maximum.js.map +1 -1
- package/schema/constraints/minimum-date.d.ts +2 -2
- package/schema/constraints/minimum-date.js +3 -2
- package/schema/constraints/minimum-date.js.map +1 -1
- package/schema/constraints/minimum-length.d.ts +2 -2
- package/schema/constraints/minimum-length.js +2 -2
- package/schema/constraints/minimum-length.js.map +1 -1
- package/schema/constraints/minimum.d.ts +2 -2
- package/schema/constraints/minimum.js +3 -2
- package/schema/constraints/minimum.js.map +1 -1
- package/schema/constraints/pattern.d.ts +2 -2
- package/schema/constraints/pattern.js +3 -2
- package/schema/constraints/pattern.js.map +1 -1
- package/schema/decorators/types.d.ts +3 -3
- package/schema/decorators/utils.d.ts +4 -1
- package/schema/decorators/utils.js +1 -1
- package/schema/decorators/utils.js.map +1 -1
- package/schema/schema.d.ts +4 -4
- package/schema/schema.error.d.ts +1 -1
- package/schema/schema.js +10 -13
- package/schema/schema.js.map +1 -1
- package/schema/schemas/any.d.ts +1 -1
- package/schema/schemas/array.d.ts +2 -2
- package/schema/schemas/array.js +2 -2
- package/schema/schemas/array.js.map +1 -1
- package/schema/schemas/boolean.d.ts +1 -1
- package/schema/schemas/date.d.ts +2 -2
- package/schema/schemas/date.js +2 -2
- package/schema/schemas/date.js.map +1 -1
- package/schema/schemas/enumeration.d.ts +2 -2
- package/schema/schemas/enumeration.js +2 -2
- package/schema/schemas/enumeration.js.map +1 -1
- package/schema/schemas/instance.d.ts +1 -1
- package/schema/schemas/literal.d.ts +2 -2
- package/schema/schemas/literal.js +2 -2
- package/schema/schemas/literal.js.map +1 -1
- package/schema/schemas/nullable.d.ts +1 -1
- package/schema/schemas/number.d.ts +2 -2
- package/schema/schemas/number.js +2 -2
- package/schema/schemas/number.js.map +1 -1
- package/schema/schemas/object.d.ts +1 -1
- package/schema/schemas/omit.d.ts +2 -2
- package/schema/schemas/omit.js.map +1 -1
- package/schema/schemas/one-or-many.d.ts +2 -2
- package/schema/schemas/optional.d.ts +1 -1
- package/schema/schemas/readable-stream.d.ts +1 -1
- package/schema/schemas/record.d.ts +1 -1
- package/schema/schemas/regexp.d.ts +1 -1
- package/schema/schemas/string.d.ts +2 -2
- package/schema/schemas/string.js +3 -3
- package/schema/schemas/string.js.map +1 -1
- package/schema/schemas/uint8-array.d.ts +2 -2
- package/schema/schemas/uint8-array.js +3 -3
- package/schema/schemas/uint8-array.js.map +1 -1
- package/schema/schemas/union.d.ts +1 -1
- package/schema/schemas/unknown.d.ts +1 -1
- package/schema/transformers/generic.d.ts +1 -1
- package/schema/types/index.d.ts +5 -0
- package/schema/types/index.js +22 -0
- package/schema/types/index.js.map +1 -0
- package/schema/types/schema-array-constraint.d.ts +5 -0
- package/schema/types/schema-array-constraint.js +7 -0
- package/schema/types/schema-array-constraint.js.map +1 -0
- package/schema/types/schema-value-coercer.d.ts +8 -0
- package/schema/types/schema-value-coercer.js +7 -0
- package/schema/types/schema-value-coercer.js.map +1 -0
- package/schema/types/schema-value-constraint.d.ts +8 -0
- package/schema/types/schema-value-constraint.js +7 -0
- package/schema/types/schema-value-constraint.js.map +1 -0
- package/schema/types/schema-value-transformer.d.ts +7 -0
- package/schema/types/schema-value-transformer.js +7 -0
- package/schema/types/schema-value-transformer.js.map +1 -0
- package/schema/{types.d.ts → types/types.d.ts} +47 -57
- package/schema/types/types.js +174 -0
- package/schema/types/types.js.map +1 -0
- package/schema/utils/schema.js +1 -1
- package/schema/utils/schema.js.map +1 -1
- package/schema/utils/value-type.d.ts +1 -1
- package/schema/utils/value-type.js +1 -1
- package/schema/utils/value-type.js.map +1 -1
- package/search-index/elastic/config.d.ts +1 -1
- package/search-index/elastic/model/elastic-query.d.ts +15 -15
- package/search-index/elastic/model/index-mapping.d.ts +14 -14
- package/search-index/elastic/model/sort.d.ts +3 -3
- package/search-index/elastic/module.d.ts +1 -1
- package/search-index/search-index.d.ts +1 -1
- package/search-index/search-result.d.ts +2 -2
- package/serializer/handlers/error.d.ts +1 -1
- package/serializer/handlers/map.d.ts +1 -1
- package/serializer/handlers/regex.d.ts +1 -1
- package/serializer/handlers/set.d.ts +1 -1
- package/serializer/serializable.d.ts +6 -6
- package/serializer/serializer.d.ts +1 -1
- package/serializer/types.d.ts +15 -15
- package/sse/server-sent-events.d.ts +3 -3
- package/tailwind/theme-adapter.d.ts +1 -1
- package/templates/module.d.ts +1 -1
- package/templates/providers/file.provider-template.d.ts +2 -2
- package/templates/providers/file.provider-template.js +2 -1
- package/templates/providers/file.provider-template.js.map +1 -1
- package/templates/renderers/handlebars.template-renderer.d.ts +9 -9
- package/templates/renderers/mjml.template-renderer.d.ts +3 -3
- package/templates/renderers/string.template-renderer.d.ts +1 -1
- package/templates/resolvers/file.template-resolver.d.ts +2 -2
- package/templates/template.model.d.ts +1 -1
- package/templates/template.renderer.d.ts +4 -4
- package/templates/template.service.d.ts +1 -1
- package/text/dynamic-text.model.d.ts +1 -1
- package/text/localizable-text.model.d.ts +1 -1
- package/text/localization.service.d.ts +11 -11
- package/theme/theme-service.d.ts +6 -6
- package/threading/thread-pool.d.ts +1 -1
- package/threading/thread-worker.d.ts +1 -1
- package/types/geo-json.d.ts +12 -12
- package/types.d.ts +91 -91
- package/utils/any-iterable-iterator.d.ts +3 -3
- package/utils/array/array.d.ts +14 -1
- package/utils/array/array.js +16 -2
- package/utils/array/array.js.map +1 -1
- package/utils/async-iterable-helpers/parallel/types.d.ts +2 -2
- package/utils/async-iterable-helpers/types.d.ts +7 -7
- package/utils/backoff.d.ts +5 -5
- package/utils/benchmark.d.ts +1 -1
- package/utils/binary-search.d.ts +1 -1
- package/utils/binary.js.map +1 -1
- package/utils/cancellation-token.d.ts +1 -1
- package/utils/compression.d.ts +1 -1
- package/utils/cryptography.d.ts +11 -11
- package/utils/date-time.d.ts +8 -7
- package/utils/date-time.js +6 -2
- package/utils/date-time.js.map +1 -1
- package/utils/equals.d.ts +3 -3
- package/utils/factory-map.d.ts +1 -1
- package/utils/format-error.d.ts +1 -1
- package/utils/function/memoize.d.ts +1 -1
- package/utils/helpers.d.ts +1 -1
- package/utils/iterable-helpers/types.d.ts +6 -6
- package/utils/jwt.d.ts +4 -4
- package/utils/math.d.ts +1 -1
- package/utils/merge.d.ts +1 -1
- package/utils/middleware.d.ts +9 -9
- package/utils/moving-metric.d.ts +1 -1
- package/utils/object/decycle.d.ts +1 -1
- package/utils/object/dereference.d.ts +1 -1
- package/utils/object/forward-ref.d.ts +2 -2
- package/utils/object/lazy-property.d.ts +5 -5
- package/utils/object/merge.d.ts +1 -1
- package/utils/object/object.js +1 -2
- package/utils/object/object.js.map +1 -1
- package/utils/object/property-name.d.ts +5 -5
- package/utils/patch-worker.d.ts +1 -1
- package/utils/periodic-sampler.d.ts +1 -1
- package/utils/provider-function-iterable.d.ts +2 -2
- package/utils/proxy.d.ts +1 -1
- package/utils/singleton.d.ts +2 -2
- package/utils/sort.d.ts +2 -2
- package/utils/stream/stream-helper-types.d.ts +5 -5
- package/utils/type-guards.d.ts +3 -3
- package/utils/url-builder.d.ts +4 -4
- package/web-types.d.ts +4 -4
- package/notification/model.d.ts +0 -18
- package/notification/model.js.map +0 -1
- package/orm/mongo/mongo-repository.d.ts +0 -2
- package/orm/mongo/mongo-repository.js +0 -7
- package/orm/mongo/mongo-repository.js.map +0 -1
- package/orm/types.js.map +0 -1
- package/schema/types.js +0 -102
- package/schema/types.js.map +0 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/member-ordering */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Repository = void 0;
|
|
5
|
+
const container_1 = require("../../container");
|
|
6
|
+
const error_1 = require("../../error");
|
|
7
|
+
const not_found_error_1 = require("../../error/not-found.error");
|
|
8
|
+
const date_time_1 = require("../../utils/date-time");
|
|
9
|
+
const type_guards_1 = require("../../utils/type-guards");
|
|
10
|
+
const decorators_1 = require("../decorators");
|
|
11
|
+
const entity_definition_model_1 = require("../entity-definition.model");
|
|
12
|
+
const models_1 = require("../models");
|
|
13
|
+
const transaction_1 = require("./transaction");
|
|
14
|
+
class Repository {
|
|
15
|
+
transaction;
|
|
16
|
+
options;
|
|
17
|
+
type;
|
|
18
|
+
definition;
|
|
19
|
+
normalizedDefinition;
|
|
20
|
+
notFoundErrorMessage;
|
|
21
|
+
[container_1.resolveArgumentType];
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this.options = options;
|
|
24
|
+
this.type = (0, type_guards_1.isFunction)(options) ? options : options.type;
|
|
25
|
+
this.definition = ((0, type_guards_1.isNotFunction)(options) ? options.definition : undefined) ?? (0, decorators_1.getEntityDefinition)((0, type_guards_1.assertDefinedPass)(this.type, 'Neither definition nor type provided.'));
|
|
26
|
+
this.normalizedDefinition = (0, entity_definition_model_1.normalizeEntityDefinition)(this.definition);
|
|
27
|
+
this.notFoundErrorMessage = `Entity in ${this.definition.name} not found.`;
|
|
28
|
+
}
|
|
29
|
+
/* transaction */
|
|
30
|
+
async startTransaction(isolationLevel = transaction_1.IsolationLevel.RepeatableRead) {
|
|
31
|
+
return this.initializeTransaction(isolationLevel);
|
|
32
|
+
}
|
|
33
|
+
async withTransaction(transactionOrIsolationLevel) {
|
|
34
|
+
const instance = await this.duplicateInstance();
|
|
35
|
+
instance.transaction = (transactionOrIsolationLevel instanceof transaction_1.Transaction) ? transactionOrIsolationLevel : await this.startTransaction(transactionOrIsolationLevel);
|
|
36
|
+
return instance;
|
|
37
|
+
}
|
|
38
|
+
async useTransaction(handlerOrTransaction, handlerOrIsolationLevel) {
|
|
39
|
+
const handler = (0, type_guards_1.isFunction)(handlerOrTransaction) ? handlerOrTransaction : (0, type_guards_1.assertFunctionPass)(handlerOrIsolationLevel);
|
|
40
|
+
const isolationLevel = (0, type_guards_1.isFunction)(handlerOrTransaction) ? handlerOrIsolationLevel : undefined;
|
|
41
|
+
const transaction = (0, type_guards_1.isFunction)(handlerOrTransaction) ? await this.startTransaction(isolationLevel) : handlerOrTransaction;
|
|
42
|
+
return transaction.use(async () => handler(transaction, this));
|
|
43
|
+
}
|
|
44
|
+
/* save */
|
|
45
|
+
async save(_entities, _options) {
|
|
46
|
+
throw new error_1.NotImplementedError();
|
|
47
|
+
}
|
|
48
|
+
async saveAndLoad(_entities, _options) {
|
|
49
|
+
throw new error_1.NotImplementedError();
|
|
50
|
+
}
|
|
51
|
+
/* insert */
|
|
52
|
+
async insert(entities, options) {
|
|
53
|
+
const actualOptions = this.getOptions(options);
|
|
54
|
+
if (!(0, type_guards_1.isArray)(entities)) {
|
|
55
|
+
const obj = {};
|
|
56
|
+
for (const [field, definition] of this.normalizedDefinition.fieldsEntries) {
|
|
57
|
+
if (definition.type == 'created') {
|
|
58
|
+
obj[definition.name] = entities[field] ?? (0, date_time_1.currentTimestamp)();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return this.insert(entities, actualOptions);
|
|
63
|
+
}
|
|
64
|
+
/* patch */
|
|
65
|
+
async patch(idOrQuery, patch, options) {
|
|
66
|
+
const patched = await this.tryPatch(idOrQuery, patch, options);
|
|
67
|
+
if (!patched) {
|
|
68
|
+
throw new not_found_error_1.NotFoundError(this.notFoundErrorMessage);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async tryPatch(idOrQuery, patch, options) {
|
|
72
|
+
const query = this.getQuery(idOrQuery);
|
|
73
|
+
const actualOptions = this.getOptions(options);
|
|
74
|
+
return this.tryPatchByQuery(query, patch, actualOptions);
|
|
75
|
+
}
|
|
76
|
+
async patchMany(idOrQuery, patch, options) {
|
|
77
|
+
const query = this.getQuery(idOrQuery);
|
|
78
|
+
const actualOptions = this.getOptions(options);
|
|
79
|
+
return this.patchManyByQuery(query, patch, actualOptions);
|
|
80
|
+
}
|
|
81
|
+
async patchAndLoad(idOrQuery, patch, options) {
|
|
82
|
+
const entity = await this.tryPatchAndLoad(idOrQuery, patch, options);
|
|
83
|
+
return this.throwNotFoundIfUndefinedPass(entity);
|
|
84
|
+
}
|
|
85
|
+
async tryPatchAndLoad(idOrQuery, patch, options) {
|
|
86
|
+
const query = this.getQuery(idOrQuery);
|
|
87
|
+
const actualOptions = this.getOptions(options);
|
|
88
|
+
return this.tryPatchAndLoadByQuery(query, patch, actualOptions);
|
|
89
|
+
}
|
|
90
|
+
async patchAndLoadMany(idOrQuery, patch, options) {
|
|
91
|
+
const query = this.getQuery(idOrQuery);
|
|
92
|
+
const actualOptions = this.getOptions(options);
|
|
93
|
+
return this.patchAndLoadManyByQuery(query, patch, actualOptions);
|
|
94
|
+
}
|
|
95
|
+
/* has */
|
|
96
|
+
async has(idOrQuery, options) {
|
|
97
|
+
const query = this.getQuery(idOrQuery);
|
|
98
|
+
const actualOptions = this.getOptions(options);
|
|
99
|
+
return this.hasByQuery(query, actualOptions);
|
|
100
|
+
}
|
|
101
|
+
/* load */
|
|
102
|
+
async load(idOrQuery, options) {
|
|
103
|
+
const entity = await this.tryLoad(idOrQuery, options);
|
|
104
|
+
return this.throwNotFoundIfUndefinedPass(entity);
|
|
105
|
+
}
|
|
106
|
+
async tryLoad(idOrQuery, options) {
|
|
107
|
+
const query = this.getQuery(idOrQuery);
|
|
108
|
+
const actualOptions = this.getOptions(options);
|
|
109
|
+
return this.tryLoadByQuery(query, actualOptions);
|
|
110
|
+
}
|
|
111
|
+
async loadAll(options) {
|
|
112
|
+
return this.loadMany({}, options);
|
|
113
|
+
}
|
|
114
|
+
async loadMany(idsOrQuery, options) {
|
|
115
|
+
const query = this.getQuery(idsOrQuery);
|
|
116
|
+
const actualOptions = this.getOptions(options);
|
|
117
|
+
return this.loadManyByQuery(query, actualOptions);
|
|
118
|
+
}
|
|
119
|
+
loadManyCursor(idsOrQuery, options) {
|
|
120
|
+
const query = this.getQuery(idsOrQuery);
|
|
121
|
+
const actualOptions = this.getOptions(options);
|
|
122
|
+
return this.loadManyByQueryCursor(query, actualOptions);
|
|
123
|
+
}
|
|
124
|
+
loadAllCursor(options) {
|
|
125
|
+
return this.loadManyCursor({}, options);
|
|
126
|
+
}
|
|
127
|
+
/* delete */
|
|
128
|
+
async delete(idOrQuery, options) {
|
|
129
|
+
const deleted = await this.tryDelete(idOrQuery, options);
|
|
130
|
+
if (!deleted) {
|
|
131
|
+
throw new not_found_error_1.NotFoundError(this.notFoundErrorMessage);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async tryDelete(idOrQuery, options) {
|
|
135
|
+
const query = this.getQuery(idOrQuery);
|
|
136
|
+
const actualOptions = this.getOptions(options);
|
|
137
|
+
return this.tryDeleteByQuery(query, actualOptions);
|
|
138
|
+
}
|
|
139
|
+
async deleteMany(idsOrQuery, options) {
|
|
140
|
+
const query = this.getQuery(idsOrQuery);
|
|
141
|
+
const actualOptions = this.getOptions(options);
|
|
142
|
+
return this.deleteManyByQuery(query, actualOptions);
|
|
143
|
+
}
|
|
144
|
+
async deleteAndLoad(idOrQuery, options) {
|
|
145
|
+
const query = this.getQuery(idOrQuery);
|
|
146
|
+
const entity = await this.tryDeleteAndLoad(query, options);
|
|
147
|
+
return this.throwNotFoundIfUndefinedPass(entity);
|
|
148
|
+
}
|
|
149
|
+
async tryDeleteAndLoad(idOrQuery, options) {
|
|
150
|
+
const query = this.getQuery(idOrQuery);
|
|
151
|
+
const actualOptions = this.getOptions(options);
|
|
152
|
+
return this.tryDeleteAndLoadByQuery(query, actualOptions);
|
|
153
|
+
}
|
|
154
|
+
async deleteAndLoadMany(idsOrQuery, options) {
|
|
155
|
+
const query = this.getQuery(idsOrQuery);
|
|
156
|
+
const actualOptions = this.getOptions(options);
|
|
157
|
+
return this.deleteAndLoadManyByQuery(query, actualOptions);
|
|
158
|
+
}
|
|
159
|
+
getQuery(idOrQuery) {
|
|
160
|
+
const query = (0, models_1.isId)(idOrQuery) ? { id: idOrQuery }
|
|
161
|
+
: (0, type_guards_1.isArray)(idOrQuery) ? { id: { $in: idOrQuery } }
|
|
162
|
+
: idOrQuery;
|
|
163
|
+
return query;
|
|
164
|
+
}
|
|
165
|
+
getOptions(options) {
|
|
166
|
+
if ((0, type_guards_1.isDefined)(this.transaction)) {
|
|
167
|
+
return {
|
|
168
|
+
...options,
|
|
169
|
+
transaction: options?.transaction ?? this.transaction
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return options ?? {};
|
|
173
|
+
}
|
|
174
|
+
throwNotFoundIfUndefinedPass(entity) {
|
|
175
|
+
if ((0, type_guards_1.isUndefined)(entity)) {
|
|
176
|
+
throw new not_found_error_1.NotFoundError(this.notFoundErrorMessage);
|
|
177
|
+
}
|
|
178
|
+
return entity;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.Repository = Repository;
|
|
182
|
+
//# sourceMappingURL=repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../source/orm/repository/repository.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;AAGvD,+CAAkD;AAClD,uCAA8C;AAC9C,iEAAwD;AAExD,qDAAqD;AACrD,yDAAwI;AACxI,8CAAoD;AAEpD,wEAAuE;AAEvE,sCAA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,aAAa,CAAC,CAAC;IAC7D,CAAC;IASS,QAAQ,CAAI,SAA+B;QACnD,MAAM,KAAK,GAAG,IAAA,aAAI,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAkB;YAC/D,CAAC,CAAC,IAAA,qBAAO,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAA8B,EAAkB;gBAC3F,CAAC,CAAC,SAAS,CAAC;QAEhB,OAAO,KAAiB,CAAC;IAC3B,CAAC;IAES,UAAU,CAAwB,OAAW;QACrD,IAAI,IAAA,uBAAS,EAAC,IAAI,CAAC,WAAW,CAAC,EAAE;YAC/B,OAAO;gBACL,GAAG,OAAO;gBACV,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,IAAI,CAAC,WAAW;aACjD,CAAC;SACR;QAED,OAAO,OAAO,IAAI,EAAO,CAAC;IAC5B,CAAC;IAEO,4BAA4B,CAAI,MAAqB;QAC3D,IAAI,IAAA,yBAAW,EAAC,MAAM,CAAC,EAAE;YACvB,MAAM,IAAI,+BAAa,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;SACpD;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAtRD,gCAsRC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Observable } from 'rxjs';
|
|
2
|
+
export declare enum IsolationLevel {
|
|
3
|
+
ReadUncommitted = 0,
|
|
4
|
+
ReadCommitted = 1,
|
|
5
|
+
RepeatableRead = 2,
|
|
6
|
+
Serializable = 3
|
|
7
|
+
}
|
|
8
|
+
export declare abstract class Transaction {
|
|
9
|
+
private readonly afterCommitSubject;
|
|
10
|
+
protected useCounter: number;
|
|
11
|
+
protected done: boolean;
|
|
12
|
+
readonly isolationLevel: IsolationLevel;
|
|
13
|
+
manualCommit: boolean;
|
|
14
|
+
readonly afterCommit$: Observable<void>;
|
|
15
|
+
constructor(isolationLevel: IsolationLevel);
|
|
16
|
+
withManualCommit(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Enters automatic transaction handling. Transaction will be commited when all use-calls are done or rolled back when one throws.
|
|
19
|
+
*/
|
|
20
|
+
use<T>(handler: () => Promise<T>): Promise<T>;
|
|
21
|
+
commit(): Promise<void>;
|
|
22
|
+
rollback(): Promise<void>;
|
|
23
|
+
protected abstract _commit(): void | Promise<void>;
|
|
24
|
+
protected abstract _rollback(): void | Promise<void>;
|
|
25
|
+
protected abstract _release(): void | Promise<void>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Transaction = exports.IsolationLevel = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
var IsolationLevel;
|
|
6
|
+
(function (IsolationLevel) {
|
|
7
|
+
IsolationLevel[IsolationLevel["ReadUncommitted"] = 0] = "ReadUncommitted";
|
|
8
|
+
IsolationLevel[IsolationLevel["ReadCommitted"] = 1] = "ReadCommitted";
|
|
9
|
+
IsolationLevel[IsolationLevel["RepeatableRead"] = 2] = "RepeatableRead";
|
|
10
|
+
IsolationLevel[IsolationLevel["Serializable"] = 3] = "Serializable";
|
|
11
|
+
})(IsolationLevel = exports.IsolationLevel || (exports.IsolationLevel = {}));
|
|
12
|
+
class Transaction {
|
|
13
|
+
afterCommitSubject;
|
|
14
|
+
useCounter;
|
|
15
|
+
done;
|
|
16
|
+
isolationLevel;
|
|
17
|
+
manualCommit;
|
|
18
|
+
afterCommit$;
|
|
19
|
+
constructor(isolationLevel) {
|
|
20
|
+
this.isolationLevel = isolationLevel;
|
|
21
|
+
this.useCounter = 0;
|
|
22
|
+
this.done = false;
|
|
23
|
+
this.manualCommit = false;
|
|
24
|
+
this.afterCommitSubject = new rxjs_1.Subject();
|
|
25
|
+
this.afterCommit$ = this.afterCommitSubject.asObservable();
|
|
26
|
+
}
|
|
27
|
+
withManualCommit() {
|
|
28
|
+
this.manualCommit = true;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Enters automatic transaction handling. Transaction will be commited when all use-calls are done or rolled back when one throws.
|
|
32
|
+
*/
|
|
33
|
+
async use(handler) {
|
|
34
|
+
this.useCounter++;
|
|
35
|
+
try {
|
|
36
|
+
const result = await handler();
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (!this.done) {
|
|
41
|
+
await this.rollback();
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
this.useCounter--;
|
|
47
|
+
if ((this.useCounter == 0) && !this.done && !this.manualCommit) {
|
|
48
|
+
await this.commit();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async commit() {
|
|
53
|
+
this.done = true;
|
|
54
|
+
await this._commit();
|
|
55
|
+
await this._release();
|
|
56
|
+
this.afterCommitSubject.next();
|
|
57
|
+
}
|
|
58
|
+
async rollback() {
|
|
59
|
+
this.done = true;
|
|
60
|
+
await this._rollback();
|
|
61
|
+
await this._release();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.Transaction = Transaction;
|
|
65
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../source/orm/repository/transaction.ts"],"names":[],"mappings":";;;AACA,+BAA+B;AAE/B,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,yEAAmB,CAAA;IACnB,qEAAiB,CAAA;IACjB,uEAAkB,CAAA;IAClB,mEAAgB,CAAA;AAClB,CAAC,EALW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAKzB;AAED,MAAsB,WAAW;IACd,kBAAkB,CAAgB;IAEzC,UAAU,CAAS;IACnB,IAAI,CAAU;IAEf,cAAc,CAAiB;IAExC,YAAY,CAAU;I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AI,CAAC;QAEjB,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;CAKF;AAvED,kCAuEC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { OneOrMany, Record, Type } from "
|
|
2
|
-
export
|
|
1
|
+
import type { OneOrMany, Record, Type } from "../../types";
|
|
2
|
+
export type EntityDefinition = {
|
|
3
3
|
name: string;
|
|
4
4
|
tableName?: string;
|
|
5
5
|
properties: Record;
|
|
6
6
|
indexes?: IndexDefinition[];
|
|
7
7
|
};
|
|
8
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export type EntityPropertyType = 'any' | 'string' | 'number' | 'boolean';
|
|
9
|
+
export type PropertyDefinition = {
|
|
10
10
|
type: OneOrMany<EntityPropertyType>;
|
|
11
11
|
array?: boolean;
|
|
12
12
|
nullable?: boolean;
|
|
13
13
|
unique?: boolean;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type IndexDefinition = {
|
|
16
16
|
properties: string[];
|
|
17
17
|
unique?: boolean;
|
|
18
18
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getEntityDefinitionFromSchema = void 0;
|
|
4
|
-
const not_supported_error_1 = require("
|
|
5
|
-
const reflection_1 = require("
|
|
6
|
-
const schema_1 = require("
|
|
7
|
-
const array_1 = require("
|
|
8
|
-
const object_1 = require("
|
|
9
|
-
const type_guards_1 = require("
|
|
4
|
+
const not_supported_error_1 = require("../../error/not-supported.error");
|
|
5
|
+
const reflection_1 = require("../../reflection");
|
|
6
|
+
const schema_1 = require("../../schema");
|
|
7
|
+
const array_1 = require("../../utils/array");
|
|
8
|
+
const object_1 = require("../../utils/object/object");
|
|
9
|
+
const type_guards_1 = require("../../utils/type-guards");
|
|
10
10
|
function getEntityDefinitionFromSchema(type) {
|
|
11
11
|
const metadata = reflection_1.reflectionRegistry.getMetadata(type);
|
|
12
|
-
if (
|
|
12
|
+
if ((0, type_guards_1.isUndefined)(metadata)) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
const properties = {};
|
|
@@ -52,4 +52,4 @@ function schemaValueTypeToEntityPropertyType(valueType) {
|
|
|
52
52
|
}
|
|
53
53
|
throw new not_supported_error_1.NotSupportedError(`ValueType ${(0, schema_1.getValueTypeName)(valueType)} not supported.`);
|
|
54
54
|
}
|
|
55
|
-
//# sourceMappingURL=
|
|
55
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../source/orm/types/definition.ts"],"names":[],"mappings":";;;AAAA,yEAAgE;AAChE,iDAAkD;AAElD,yCAAkH;AAElH,6CAAwC;AACxC,sDAAsD;AACtD,yDAA6D;AAuB7D,SAAgB,6BAA6B,CAAC,IAAU;IACtD,MAAM,QAAQ,GAAG,+BAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEtD,IAAI,IAAA,yBAAW,EAAC,QAAQ,CAAC,EAAE;QACzB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,UAAU,GAA4C,EAAE,CAAC;IAE/D,MAAM,MAAM,GAAG,IAAA,yCAAgC,EAAC,IAAI,CAAC,CAAC;IAEtD,IAAI,IAAA,uBAAS,EAAC,MAAM,CAAC,EAAE;QACrB,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,IAAA,sBAAa,EAAC,MAAM,CAAC,UAAU,CAAC,EAAE;YAC9D,MAAM,UAAU,GAAG,IAAA,4BAAmB,EAAC,QAAQ,CAAC,CAAC;YACjD,MAAM,iCAAiC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,WAAW,CAAC,CAAC,CAAC;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AAO,KAAK,CAAC;KACd;IAED,MAAM,IAAI,uCAAiB,CAAC,aAAa,IAAA,yBAAgB,EAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./definition"), exports);
|
|
18
|
+
__exportStar(require("./options"), exports);
|
|
19
|
+
__exportStar(require("./query"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/orm/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Paths, TypedOmit } from "../../types";
|
|
2
|
+
import type { Transaction } from '../repository/transaction';
|
|
3
|
+
import type { Query } from './query';
|
|
4
|
+
export type Order = 'asc' | 'desc';
|
|
5
|
+
export declare const allOrders: Order[];
|
|
6
|
+
export type Sort<T = unknown> = {
|
|
7
|
+
field: (Extract<keyof T, string> | '$score');
|
|
8
|
+
order?: Order;
|
|
9
|
+
};
|
|
10
|
+
export type SortOptions<T = unknown> = {
|
|
11
|
+
sort?: Sort<T>[];
|
|
12
|
+
};
|
|
13
|
+
export type SkipOptions = {
|
|
14
|
+
skip?: number;
|
|
15
|
+
};
|
|
16
|
+
export type LimitOptions = {
|
|
17
|
+
limit?: number;
|
|
18
|
+
};
|
|
19
|
+
export type BaseOptions = {
|
|
20
|
+
transaction?: Transaction;
|
|
21
|
+
};
|
|
22
|
+
export type HasOptions = BaseOptions;
|
|
23
|
+
export type LoadOptions<T> = BaseOptions & SkipOptions & SortOptions<T> & {
|
|
24
|
+
/** include deleted */
|
|
25
|
+
deleted?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export type LoadManyOptions<T> = LoadOptions<T> & LimitOptions;
|
|
28
|
+
export type SaveOptions<T> = BaseOptions & {
|
|
29
|
+
/** update existing */
|
|
30
|
+
upsert?: Paths<T> | Query<T>;
|
|
31
|
+
};
|
|
32
|
+
export type InsertOptions = BaseOptions;
|
|
33
|
+
export type PatchOptions<T> = BaseOptions & SkipOptions & SortOptions<T>;
|
|
34
|
+
export type PatchManyOptions<T> = PatchOptions<T> & LimitOptions;
|
|
35
|
+
export type DeleteOptions<T> = TypedOmit<LoadOptions<T>, 'deleted'>;
|
|
36
|
+
export type DeleteManyOptions<T> = TypedOmit<LoadManyOptions<T>, 'deleted'>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../source/orm/types/options.ts"],"names":[],"mappings":";;;AAKa,QAAA,SAAS,GAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { Flatten, StringMap } from "../../types";
|
|
2
|
+
import type { Geometry } from "../../types/geo-json";
|
|
3
|
+
export type LogicalQuery<T = unknown> = LogicalAndQuery<T> | LogicalOrQuery<T> | LogicalNorQuery<T>;
|
|
4
|
+
export type LogicalQueryTypes = keyof (LogicalAndQuery & LogicalOrQuery & LogicalNorQuery);
|
|
5
|
+
export declare const allLogicalQueryTypes: LogicalQueryTypes[];
|
|
6
|
+
export type ComparisonQueryBody<T = unknown> = {
|
|
7
|
+
[P in keyof T]?: ComparisonQueryOrValue<T[P]>;
|
|
8
|
+
} & StringMap<ComparisonQueryOrValue>;
|
|
9
|
+
export type ComparisonQueryOrValue<T = unknown> = T | ComparisonQuery<T> | Flatten<T>;
|
|
10
|
+
export type ComparisonQuery<T = unknown> = Partial<ComparisonNotQuery<T> & ComparisonEqualsQuery<T> & ComparisonNotEqualsQuery<T> & ComparisonExistsQuery & ComparisonItemQuery<T> & ComparisonInQuery<T> & ComparisonNotInQuery<T> & ComparisonAllQuery<T> & ComparisonGreaterThanQuery<T> & ComparisonGreaterThanOrEqualsQuery<T> & ComparisonLessThanQuery<T> & ComparisonLessThanOrEqualsQuery<T> & ComparisonRegexQuery & ComparisonTextQuery & ComparisonGeoShapeQuery & ComparisonGeoDistanceQuery>;
|
|
11
|
+
export type ComparisonQueryTypes = keyof ComparisonQuery;
|
|
12
|
+
export declare const allComparisonQueryTypes: ComparisonQueryTypes[];
|
|
13
|
+
export type SpecialQuery<T = unknown> = Partial<TextSpanQuery<T>>;
|
|
14
|
+
export type SpecialQueryTypes = keyof SpecialQuery;
|
|
15
|
+
export declare const allSpecialQueryTypes: SpecialQueryTypes[];
|
|
16
|
+
export type Query<T = unknown> = LogicalQuery<T> | (ComparisonQueryBody<T> & SpecialQuery<T>);
|
|
17
|
+
export type QueryTypes = LogicalQueryTypes | ComparisonQueryTypes | SpecialQueryTypes;
|
|
18
|
+
export declare const allQueryTypes: ("$and" | "$or" | "$nor" | "$not" | "$eq" | "$neq" | "$exists" | "$item" | "$in" | "$nin" | "$all" | "$gt" | "$gte" | "$lt" | "$lte" | "$regex" | "$text" | "$geoShape" | "$geoDistance" | "$textSpan")[];
|
|
19
|
+
export type Operator = 'and' | 'or';
|
|
20
|
+
export declare const allOperators: Operator[];
|
|
21
|
+
export type LogicalAndQuery<T = unknown> = {
|
|
22
|
+
$and: Query<T>[];
|
|
23
|
+
};
|
|
24
|
+
export type LogicalOrQuery<T = unknown> = {
|
|
25
|
+
$or: Query<T>[];
|
|
26
|
+
};
|
|
27
|
+
export type LogicalNorQuery<T = unknown> = {
|
|
28
|
+
$nor: Query<T>[];
|
|
29
|
+
};
|
|
30
|
+
export type ComparisonValue<T> = T | Flatten<T>;
|
|
31
|
+
export type ComparisonValueWithRegex<T> = T extends string ? ComparisonValue<T | RegExp> : T extends string[] ? ComparisonValue<(Flatten<T> | RegExp)[]> : (T | Flatten<T>);
|
|
32
|
+
export type ComparisonNotQuery<T = unknown> = {
|
|
33
|
+
$not: ComparisonQuery<T>;
|
|
34
|
+
};
|
|
35
|
+
export type ComparisonEqualsQuery<T = unknown> = {
|
|
36
|
+
$eq: ComparisonValueWithRegex<T>;
|
|
37
|
+
};
|
|
38
|
+
export type ComparisonNotEqualsQuery<T = unknown> = {
|
|
39
|
+
$neq: ComparisonValueWithRegex<T>;
|
|
40
|
+
};
|
|
41
|
+
export type ComparisonExistsQuery = {
|
|
42
|
+
$exists: ComparisonValue<boolean>;
|
|
43
|
+
};
|
|
44
|
+
export type ComparisonItemQuery<T = unknown> = {
|
|
45
|
+
$item: T extends (infer U)[] ? U extends Record<string | number, unknown> ? Query<U> : ComparisonQuery<U> : never;
|
|
46
|
+
};
|
|
47
|
+
export type ComparisonInQuery<T = unknown> = {
|
|
48
|
+
$in: ComparisonValueWithRegex<T>[];
|
|
49
|
+
};
|
|
50
|
+
export type ComparisonNotInQuery<T = unknown> = {
|
|
51
|
+
$nin: ComparisonValueWithRegex<T>[];
|
|
52
|
+
};
|
|
53
|
+
export type ComparisonAllQuery<T = unknown> = {
|
|
54
|
+
$all: ComparisonValueWithRegex<T>[];
|
|
55
|
+
};
|
|
56
|
+
export type ComparisonGreaterThanQuery<T = unknown> = {
|
|
57
|
+
$gt: ComparisonValue<T>;
|
|
58
|
+
};
|
|
59
|
+
export type ComparisonGreaterThanOrEqualsQuery<T = unknown> = {
|
|
60
|
+
$gte: ComparisonValue<T>;
|
|
61
|
+
};
|
|
62
|
+
export type ComparisonLessThanQuery<T = unknown> = {
|
|
63
|
+
$lt: ComparisonValue<T>;
|
|
64
|
+
};
|
|
65
|
+
export type ComparisonLessThanOrEqualsQuery<T = unknown> = {
|
|
66
|
+
$lte: ComparisonValue<T>;
|
|
67
|
+
};
|
|
68
|
+
export type ComparisonRegexQuery = {
|
|
69
|
+
$regex: string | RegExp | {
|
|
70
|
+
pattern: string;
|
|
71
|
+
flags: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export type ComparisonTextQuery = {
|
|
75
|
+
$text: string | {
|
|
76
|
+
text: string;
|
|
77
|
+
operator?: Operator;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export type GeoShapeRelation = 'intersects' | 'within' | 'disjoint' | 'contains';
|
|
81
|
+
export type ComparisonGeoShapeQuery = {
|
|
82
|
+
$geoShape: {
|
|
83
|
+
geometry: Geometry;
|
|
84
|
+
relation: GeoShapeRelation;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
export type ComparisonGeoDistanceQuery = {
|
|
88
|
+
$geoDistance: {
|
|
89
|
+
longitude: number;
|
|
90
|
+
latitude: number;
|
|
91
|
+
/**
|
|
92
|
+
* maximum distance in meters
|
|
93
|
+
*/
|
|
94
|
+
maxDistance?: number;
|
|
95
|
+
/**
|
|
96
|
+
* minimum distance in meters
|
|
97
|
+
*/
|
|
98
|
+
minDistance?: number;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export type TextSpanQueryMode = 'best' | 'most' | 'cross';
|
|
102
|
+
export declare const allTextSpanQueryModes: TextSpanQueryMode[];
|
|
103
|
+
export type TextSpanQuery<T = unknown> = {
|
|
104
|
+
$textSpan: {
|
|
105
|
+
fields: (Extract<keyof T, string>)[];
|
|
106
|
+
text: string;
|
|
107
|
+
mode?: TextSpanQueryMode;
|
|
108
|
+
operator?: Operator;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allTextSpanQueryModes = exports.allOperators = exports.allQueryTypes = exports.allSpecialQueryTypes = exports.allComparisonQueryTypes = exports.allLogicalQueryTypes = void 0;
|
|
4
|
+
exports.allLogicalQueryTypes = ['$and', '$or', '$nor'];
|
|
5
|
+
exports.allComparisonQueryTypes = ['$all', '$not', '$eq', '$exists', '$gt', '$gte', '$in', '$item', '$lt', '$lte', '$neq', '$nin', '$regex', '$text', '$geoDistance', '$geoShape'];
|
|
6
|
+
exports.allSpecialQueryTypes = ['$textSpan'];
|
|
7
|
+
exports.allQueryTypes = [...exports.allLogicalQueryTypes, ...exports.allComparisonQueryTypes, ...exports.allSpecialQueryTypes];
|
|
8
|
+
exports.allOperators = ['and', 'or'];
|
|
9
|
+
exports.allTextSpanQueryModes = ['best', 'most', 'cross'];
|
|
10
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../source/orm/types/query.ts"],"names":[],"mappings":";;;AAKa,QAAA,oBAAoB,GAAwB,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAyBpE,QAAA,uBAAuB,GAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;AAInM,QAAA,oBAAoB,GAAwB,CAAC,WAAW,CAAC,CAAC;AAI1D,QAAA,aAAa,GAAG,CAAC,GAAG,4BAAoB,EAAE,GAAG,+BAAuB,EAAE,GAAG,4BAAoB,CAAC,CAAC;AAG/F,QAAA,YAAY,GAAe,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AA0GzC,QAAA,qBAAqB,GAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.1",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"eslint": "8",
|
|
34
34
|
"ttypescript": "1.5",
|
|
35
35
|
"typedoc": "0.23",
|
|
36
|
-
"typescript": "4.
|
|
36
|
+
"typescript": "4.9",
|
|
37
37
|
"typescript-transform-paths": "3.4"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@elastic/elasticsearch": "^8.6",
|
|
41
41
|
"@koa/router": "^12.0",
|
|
42
|
-
"@tstdl/angular": "^0.
|
|
42
|
+
"@tstdl/angular": "^0.82.0",
|
|
43
43
|
"chroma-js": "^2.4",
|
|
44
44
|
"got": "^12.5",
|
|
45
45
|
"handlebars": "^4.7",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"mjml": "^4.13",
|
|
50
50
|
"mongodb": "4.13",
|
|
51
51
|
"nodemailer": "^6.9",
|
|
52
|
-
"puppeteer": "^19.
|
|
53
|
-
"undici": "^5.
|
|
52
|
+
"puppeteer": "^19.6",
|
|
53
|
+
"undici": "^5.16",
|
|
54
54
|
"urlpattern-polyfill": "^6.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependenciesMeta": {
|
package/pdf/pdf.service.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare class PdfRenderOptions {
|
|
|
43
43
|
*/
|
|
44
44
|
timeout?: number;
|
|
45
45
|
}
|
|
46
|
-
export
|
|
46
|
+
export type PdfTemplateOptions = PdfRenderOptions;
|
|
47
47
|
export declare class PdfTemplate extends Template<{
|
|
48
48
|
header: false;
|
|
49
49
|
body: true;
|
|
@@ -51,10 +51,10 @@ export declare class PdfTemplate extends Template<{
|
|
|
51
51
|
}, PdfRenderOptions> {
|
|
52
52
|
options?: PdfTemplateOptions;
|
|
53
53
|
}
|
|
54
|
-
export
|
|
54
|
+
export type PdfServiceOptions = {
|
|
55
55
|
language?: string;
|
|
56
56
|
};
|
|
57
|
-
export
|
|
57
|
+
export type PdfServiceArgument = PdfServiceOptions;
|
|
58
58
|
export declare class PdfService implements AsyncDisposable, AfterResolve, Injectable<PdfServiceArgument> {
|
|
59
59
|
private readonly templateService;
|
|
60
60
|
private readonly logger;
|
package/pool/pool.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import type { AsyncDisposable } from "../disposable/disposable";
|
|
2
2
|
import { disposeAsync } from "../disposable/disposable";
|
|
3
3
|
import type { Logger } from "../logger";
|
|
4
|
-
export
|
|
4
|
+
export type PoolOptions = {
|
|
5
5
|
/**
|
|
6
6
|
* maximum number of instances
|
|
7
7
|
* @default number of cpu cores
|
|
8
8
|
*/
|
|
9
9
|
size?: number;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type PoolUseOptions = {
|
|
12
12
|
/**
|
|
13
13
|
* Dipose used instance on error instead of reusing it.
|
|
14
14
|
* @default false
|
|
15
15
|
*/
|
|
16
16
|
disposeOnError?: boolean;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
19
|
-
export
|
|
18
|
+
export type PoolInstanceFactory<T> = () => T | Promise<T>;
|
|
19
|
+
export type PoolInstanceDisposer<T> = (instance: T) => any | Promise<any>;
|
|
20
20
|
export declare class Pool<T extends object> implements AsyncDisposable {
|
|
21
21
|
private readonly size;
|
|
22
22
|
private readonly disposeOnError;
|