@loopback/repository 4.0.0-alpha.9 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +25 -0
- package/README.md +93 -389
- package/dist/common-types.d.ts +96 -0
- package/dist/common-types.js +24 -0
- package/dist/common-types.js.map +1 -0
- package/dist/connectors/connector.d.ts +48 -0
- package/{lib → dist/connectors}/connector.js +1 -1
- package/dist/connectors/connector.js.map +1 -0
- package/{lib/crud-connector.d.ts → dist/connectors/crud.connector.d.ts} +51 -51
- package/{lib/common-types.js → dist/connectors/crud.connector.js} +2 -2
- package/dist/connectors/crud.connector.js.map +1 -0
- package/dist/connectors/index.d.ts +3 -0
- package/dist/connectors/index.js +11 -0
- package/dist/connectors/index.js.map +1 -0
- package/{lib6/kv-connector.d.ts → dist/connectors/kv.connector.d.ts} +28 -28
- package/{lib/datasource.js → dist/connectors/kv.connector.js} +2 -2
- package/dist/connectors/kv.connector.js.map +1 -0
- package/dist/datasource.d.ts +27 -0
- package/{lib6 → dist}/datasource.js +1 -1
- package/dist/datasource.js.map +1 -0
- package/dist/decorators/index.d.ts +3 -0
- package/dist/decorators/index.js +11 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/metadata.d.ts +12 -0
- package/dist/decorators/metadata.js +51 -0
- package/dist/decorators/metadata.js.map +1 -0
- package/dist/decorators/model.decorator.d.ts +40 -0
- package/dist/decorators/model.decorator.js +112 -0
- package/dist/decorators/model.decorator.js.map +1 -0
- package/dist/decorators/repository.decorator.d.ts +106 -0
- package/dist/decorators/repository.decorator.js +114 -0
- package/dist/decorators/repository.decorator.js.map +1 -0
- package/dist/define-model-class.d.ts +55 -0
- package/dist/define-model-class.js +57 -0
- package/dist/define-model-class.js.map +1 -0
- package/dist/define-repository-class.d.ts +119 -0
- package/dist/define-repository-class.js +98 -0
- package/dist/define-repository-class.js.map +1 -0
- package/dist/errors/entity-not-found.error.d.ts +8 -0
- package/dist/errors/entity-not-found.error.js +28 -0
- package/dist/errors/entity-not-found.error.js.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +10 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/invalid-relation.error.d.ts +10 -0
- package/dist/errors/invalid-relation.error.js +28 -0
- package/dist/errors/invalid-relation.error.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/keys.d.ts +34 -0
- package/dist/keys.js +44 -0
- package/dist/keys.js.map +1 -0
- package/dist/mixins/index.d.ts +1 -0
- package/dist/mixins/index.js +9 -0
- package/dist/mixins/index.js.map +1 -0
- package/dist/mixins/repository.mixin.d.ts +377 -0
- package/dist/mixins/repository.mixin.js +405 -0
- package/dist/mixins/repository.mixin.js.map +1 -0
- package/dist/model.d.ts +232 -0
- package/dist/model.js +367 -0
- package/dist/model.js.map +1 -0
- package/dist/relations/belongs-to/belongs-to.accessor.d.ts +17 -0
- package/dist/relations/belongs-to/belongs-to.accessor.js +40 -0
- package/dist/relations/belongs-to/belongs-to.accessor.js.map +1 -0
- package/dist/relations/belongs-to/belongs-to.decorator.d.ts +11 -0
- package/dist/relations/belongs-to/belongs-to.decorator.js +64 -0
- package/dist/relations/belongs-to/belongs-to.decorator.js.map +1 -0
- package/dist/relations/belongs-to/belongs-to.helpers.d.ts +17 -0
- package/dist/relations/belongs-to/belongs-to.helpers.js +63 -0
- package/dist/relations/belongs-to/belongs-to.helpers.js.map +1 -0
- package/dist/relations/belongs-to/belongs-to.inclusion-resolver.d.ts +14 -0
- package/dist/relations/belongs-to/belongs-to.inclusion-resolver.js +36 -0
- package/dist/relations/belongs-to/belongs-to.inclusion-resolver.js.map +1 -0
- package/dist/relations/belongs-to/belongs-to.repository.d.ts +28 -0
- package/dist/relations/belongs-to/belongs-to.repository.js +33 -0
- package/dist/relations/belongs-to/belongs-to.repository.js.map +1 -0
- package/dist/relations/belongs-to/index.d.ts +4 -0
- package/dist/relations/belongs-to/index.js +12 -0
- package/dist/relations/belongs-to/index.js.map +1 -0
- package/dist/relations/has-many/has-many-through.helpers.d.ts +182 -0
- package/dist/relations/has-many/has-many-through.helpers.js +282 -0
- package/dist/relations/has-many/has-many-through.helpers.js.map +1 -0
- package/dist/relations/has-many/has-many-through.inclusion-resolver.d.ts +16 -0
- package/dist/relations/has-many/has-many-through.inclusion-resolver.js +78 -0
- package/dist/relations/has-many/has-many-through.inclusion-resolver.js.map +1 -0
- package/dist/relations/has-many/has-many-through.repository-factory.d.ts +17 -0
- package/dist/relations/has-many/has-many-through.repository-factory.js +37 -0
- package/dist/relations/has-many/has-many-through.repository-factory.js.map +1 -0
- package/dist/relations/has-many/has-many-through.repository.d.ts +114 -0
- package/dist/relations/has-many/has-many-through.repository.js +103 -0
- package/dist/relations/has-many/has-many-through.repository.js.map +1 -0
- package/dist/relations/has-many/has-many.decorator.d.ts +11 -0
- package/dist/relations/has-many/has-many.decorator.js +36 -0
- package/dist/relations/has-many/has-many.decorator.js.map +1 -0
- package/dist/relations/has-many/has-many.helpers.d.ts +26 -0
- package/dist/relations/has-many/has-many.helpers.js +78 -0
- package/dist/relations/has-many/has-many.helpers.js.map +1 -0
- package/dist/relations/has-many/has-many.inclusion-resolver.d.ts +14 -0
- package/dist/relations/has-many/has-many.inclusion-resolver.js +45 -0
- package/dist/relations/has-many/has-many.inclusion-resolver.js.map +1 -0
- package/dist/relations/has-many/has-many.repository-factory.d.ts +28 -0
- package/dist/relations/has-many/has-many.repository-factory.js +39 -0
- package/dist/relations/has-many/has-many.repository-factory.js.map +1 -0
- package/dist/relations/has-many/has-many.repository.d.ts +54 -0
- package/dist/relations/has-many/has-many.repository.js +38 -0
- package/dist/relations/has-many/has-many.repository.js.map +1 -0
- package/dist/relations/has-many/index.d.ts +6 -0
- package/dist/relations/has-many/index.js +14 -0
- package/dist/relations/has-many/index.js.map +1 -0
- package/dist/relations/has-one/has-one.decorator.d.ts +3 -0
- package/dist/relations/has-one/has-one.decorator.js +37 -0
- package/dist/relations/has-one/has-one.decorator.js.map +1 -0
- package/dist/relations/has-one/has-one.helpers.d.ts +17 -0
- package/dist/relations/has-one/has-one.helpers.js +64 -0
- package/dist/relations/has-one/has-one.helpers.js.map +1 -0
- package/dist/relations/has-one/has-one.inclusion-resolver.d.ts +14 -0
- package/dist/relations/has-one/has-one.inclusion-resolver.js +35 -0
- package/dist/relations/has-one/has-one.inclusion-resolver.js.map +1 -0
- package/dist/relations/has-one/has-one.repository-factory.d.ts +28 -0
- package/dist/relations/has-one/has-one.repository-factory.js +39 -0
- package/dist/relations/has-one/has-one.repository-factory.js.map +1 -0
- package/dist/relations/has-one/has-one.repository.d.ts +53 -0
- package/dist/relations/has-one/has-one.repository.js +45 -0
- package/dist/relations/has-one/has-one.repository.js.map +1 -0
- package/dist/relations/has-one/index.d.ts +3 -0
- package/dist/relations/has-one/index.js +11 -0
- package/dist/relations/has-one/index.js.map +1 -0
- package/dist/relations/index.d.ts +6 -0
- package/dist/relations/index.js +14 -0
- package/dist/relations/index.js.map +1 -0
- package/dist/relations/relation.decorator.d.ts +39 -0
- package/dist/relations/relation.decorator.js +88 -0
- package/dist/relations/relation.decorator.js.map +1 -0
- package/dist/relations/relation.helpers.d.ts +105 -0
- package/dist/relations/relation.helpers.js +298 -0
- package/dist/relations/relation.helpers.js.map +1 -0
- package/dist/relations/relation.types.d.ts +142 -0
- package/dist/relations/relation.types.js +21 -0
- package/dist/relations/relation.types.js.map +1 -0
- package/dist/repositories/constraint-utils.d.ts +49 -0
- package/dist/repositories/constraint-utils.js +87 -0
- package/dist/repositories/constraint-utils.js.map +1 -0
- package/dist/repositories/index.d.ts +5 -0
- package/dist/repositories/index.js +13 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/repositories/kv.repository.bridge.d.ts +30 -0
- package/dist/repositories/kv.repository.bridge.js +76 -0
- package/dist/repositories/kv.repository.bridge.js.map +1 -0
- package/dist/repositories/kv.repository.d.ts +74 -0
- package/{lib/crud-connector.js → dist/repositories/kv.repository.js} +2 -2
- package/dist/repositories/kv.repository.js.map +1 -0
- package/dist/repositories/legacy-juggler-bridge.d.ts +305 -0
- package/dist/repositories/legacy-juggler-bridge.js +452 -0
- package/dist/repositories/legacy-juggler-bridge.js.map +1 -0
- package/dist/repositories/repository.d.ts +223 -0
- package/dist/repositories/repository.js +157 -0
- package/dist/repositories/repository.js.map +1 -0
- package/dist/transaction.d.ts +30 -0
- package/dist/transaction.js +18 -0
- package/dist/transaction.js.map +1 -0
- package/dist/type-resolver.d.ts +42 -0
- package/dist/type-resolver.js +61 -0
- package/dist/type-resolver.js.map +1 -0
- package/{lib → dist}/types/any.d.ts +1 -1
- package/{lib6 → dist}/types/any.js +3 -2
- package/dist/types/any.js.map +1 -0
- package/{lib6 → dist}/types/array.d.ts +4 -4
- package/{lib → dist}/types/array.js +6 -4
- package/dist/types/array.js.map +1 -0
- package/{lib → dist}/types/boolean.d.ts +1 -1
- package/{lib6 → dist}/types/boolean.js +3 -2
- package/dist/types/boolean.js.map +1 -0
- package/{lib6 → dist}/types/buffer.d.ts +2 -2
- package/{lib → dist}/types/buffer.js +8 -6
- package/dist/types/buffer.js.map +1 -0
- package/{lib → dist}/types/date.d.ts +1 -1
- package/{lib → dist}/types/date.js +6 -4
- package/dist/types/date.js.map +1 -0
- package/{lib → dist}/types/index.d.ts +11 -9
- package/dist/types/index.js +49 -0
- package/dist/types/index.js.map +1 -0
- package/{lib6 → dist}/types/model.d.ts +2 -1
- package/{lib6 → dist}/types/model.js +2 -2
- package/dist/types/model.js.map +1 -0
- package/dist/types/null.d.ts +12 -0
- package/{lib/types/boolean.js → dist/types/null.js} +12 -11
- package/dist/types/null.js.map +1 -0
- package/{lib6 → dist}/types/number.d.ts +1 -1
- package/{lib → dist}/types/number.js +6 -4
- package/dist/types/number.js.map +1 -0
- package/{lib → dist}/types/object.d.ts +1 -1
- package/{lib → dist}/types/object.js +7 -6
- package/dist/types/object.js.map +1 -0
- package/{lib → dist}/types/string.d.ts +1 -1
- package/{lib → dist}/types/string.js +3 -2
- package/dist/types/string.js.map +1 -0
- package/{lib6 → dist}/types/type.d.ts +7 -7
- package/{lib6 → dist}/types/type.js +1 -1
- package/dist/types/type.js.map +1 -0
- package/{lib → dist}/types/union.d.ts +1 -1
- package/{lib → dist}/types/union.js +6 -4
- package/dist/types/union.js.map +1 -0
- package/package.json +49 -33
- package/src/common-types.ts +123 -0
- package/src/connectors/connector.ts +70 -0
- package/src/connectors/crud.connector.ts +208 -0
- package/src/connectors/index.ts +8 -0
- package/src/connectors/kv.connector.ts +113 -0
- package/src/datasource.ts +37 -0
- package/src/decorators/index.ts +8 -0
- package/src/decorators/metadata.ts +84 -0
- package/src/decorators/model.decorator.ts +166 -0
- package/src/decorators/repository.decorator.ts +223 -0
- package/src/define-model-class.ts +90 -0
- package/src/define-repository-class.ts +170 -0
- package/src/errors/entity-not-found.error.ts +40 -0
- package/src/errors/index.ts +7 -0
- package/src/errors/invalid-relation.error.ts +39 -0
- package/src/index.ts +36 -0
- package/src/keys.ts +40 -0
- package/{index.d.ts → src/mixins/index.ts} +2 -2
- package/src/mixins/repository.mixin.ts +499 -0
- package/src/model.ts +539 -0
- package/src/relations/belongs-to/belongs-to.accessor.ts +74 -0
- package/src/relations/belongs-to/belongs-to.decorator.ts +81 -0
- package/src/relations/belongs-to/belongs-to.helpers.ts +78 -0
- package/src/relations/belongs-to/belongs-to.inclusion-resolver.ts +71 -0
- package/src/relations/belongs-to/belongs-to.repository.ts +55 -0
- package/src/relations/belongs-to/index.ts +9 -0
- package/src/relations/has-many/has-many-through.helpers.ts +361 -0
- package/src/relations/has-many/has-many-through.inclusion-resolver.ts +135 -0
- package/src/relations/has-many/has-many-through.repository-factory.ts +121 -0
- package/src/relations/has-many/has-many-through.repository.ts +318 -0
- package/src/relations/has-many/has-many.decorator.ts +38 -0
- package/src/relations/has-many/has-many.helpers.ts +100 -0
- package/src/relations/has-many/has-many.inclusion-resolver.ts +88 -0
- package/src/relations/has-many/has-many.repository-factory.ts +76 -0
- package/src/relations/has-many/has-many.repository.ts +118 -0
- package/src/relations/has-many/index.ts +11 -0
- package/src/relations/has-one/has-one.decorator.ts +40 -0
- package/src/relations/has-one/has-one.helpers.ts +84 -0
- package/src/relations/has-one/has-one.inclusion-resolver.ts +65 -0
- package/src/relations/has-one/has-one.repository-factory.ts +72 -0
- package/src/relations/has-one/has-one.repository.ts +127 -0
- package/src/relations/has-one/index.ts +8 -0
- package/src/relations/index.ts +11 -0
- package/src/relations/relation.decorator.ts +90 -0
- package/src/relations/relation.helpers.ts +364 -0
- package/src/relations/relation.types.ts +180 -0
- package/src/repositories/constraint-utils.ts +98 -0
- package/src/repositories/index.ts +10 -0
- package/src/repositories/kv.repository.bridge.ts +97 -0
- package/src/repositories/kv.repository.ts +87 -0
- package/src/repositories/legacy-juggler-bridge.ts +788 -0
- package/src/repositories/repository.ts +441 -0
- package/src/transaction.ts +39 -0
- package/src/type-resolver.ts +98 -0
- package/src/types/any.ts +38 -0
- package/src/types/array.ts +53 -0
- package/src/types/boolean.ts +35 -0
- package/src/types/buffer.ts +53 -0
- package/src/types/date.ts +61 -0
- package/src/types/index.ts +52 -0
- package/src/types/model.ts +24 -0
- package/src/types/null.ts +35 -0
- package/src/types/number.ts +42 -0
- package/src/types/object.ts +53 -0
- package/src/types/string.ts +42 -0
- package/src/types/type.ts +51 -0
- package/src/types/union.ts +55 -0
- package/api-docs/apple-touch-icon-114x114-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-144x144-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-57x57-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-72x72-precomposed.png +0 -0
- package/api-docs/apple-touch-icon-precomposed.png +0 -0
- package/api-docs/apple-touch-icon.png +0 -0
- package/api-docs/css/bootstrap.min.css +0 -9
- package/api-docs/css/code-themes/arta.css +0 -158
- package/api-docs/css/code-themes/ascetic.css +0 -50
- package/api-docs/css/code-themes/brown_paper.css +0 -104
- package/api-docs/css/code-themes/brown_papersq.png +0 -0
- package/api-docs/css/code-themes/dark.css +0 -103
- package/api-docs/css/code-themes/default.css +0 -135
- package/api-docs/css/code-themes/far.css +0 -111
- package/api-docs/css/code-themes/github.css +0 -127
- package/api-docs/css/code-themes/googlecode.css +0 -144
- package/api-docs/css/code-themes/idea.css +0 -121
- package/api-docs/css/code-themes/ir_black.css +0 -104
- package/api-docs/css/code-themes/magula.css +0 -121
- package/api-docs/css/code-themes/monokai.css +0 -114
- package/api-docs/css/code-themes/pojoaque.css +0 -104
- package/api-docs/css/code-themes/pojoaque.jpg +0 -0
- package/api-docs/css/code-themes/rainbow.css +0 -114
- package/api-docs/css/code-themes/school_book.css +0 -111
- package/api-docs/css/code-themes/school_book.png +0 -0
- package/api-docs/css/code-themes/sl-theme.css +0 -45
- package/api-docs/css/code-themes/solarized_dark.css +0 -88
- package/api-docs/css/code-themes/solarized_light.css +0 -88
- package/api-docs/css/code-themes/sunburst.css +0 -158
- package/api-docs/css/code-themes/tomorrow-night-blue.css +0 -52
- package/api-docs/css/code-themes/tomorrow-night-bright.css +0 -51
- package/api-docs/css/code-themes/tomorrow-night-eighties.css +0 -51
- package/api-docs/css/code-themes/tomorrow-night.css +0 -52
- package/api-docs/css/code-themes/tomorrow.css +0 -49
- package/api-docs/css/code-themes/vs.css +0 -86
- package/api-docs/css/code-themes/xcode.css +0 -154
- package/api-docs/css/code-themes/zenburn.css +0 -115
- package/api-docs/css/main.css +0 -139
- package/api-docs/favicon.ico +0 -0
- package/api-docs/fonts/0ihfXUL2emPh0ROJezvraLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
- package/api-docs/fonts/OsJ2DjdpjqFRVUSto6IffLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
- package/api-docs/fonts/_aijTyevf54tkVDLy-dlnLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
- package/api-docs/index.html +0 -18017
- package/api-docs/js/main.js +0 -19
- package/api-docs/js/vendor/bootstrap.min.js +0 -6
- package/api-docs/js/vendor/jquery-1.10.1.min.js +0 -6
- package/api-docs/js/vendor/jquery.scrollTo-1.4.3.1.js +0 -218
- package/api-docs/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js +0 -11
- package/index.js +0 -9
- package/lib/common-types.d.ts +0 -44
- package/lib/common-types.js.map +0 -1
- package/lib/connector.d.ts +0 -12
- package/lib/connector.js.map +0 -1
- package/lib/crud-connector.js.map +0 -1
- package/lib/datasource.d.ts +0 -11
- package/lib/datasource.js.map +0 -1
- package/lib/decorators/model.d.ts +0 -17
- package/lib/decorators/model.js +0 -55
- package/lib/decorators/model.js.map +0 -1
- package/lib/decorators/relation.d.ts +0 -65
- package/lib/decorators/relation.js +0 -126
- package/lib/decorators/relation.js.map +0 -1
- package/lib/decorators/repository.d.ts +0 -61
- package/lib/decorators/repository.js +0 -107
- package/lib/decorators/repository.js.map +0 -1
- package/lib/index.d.ts +0 -17
- package/lib/index.js +0 -21
- package/lib/index.js.map +0 -1
- package/lib/kv-connector.d.ts +0 -77
- package/lib/kv-connector.js +0 -7
- package/lib/kv-connector.js.map +0 -1
- package/lib/kv-repository.d.ts +0 -78
- package/lib/kv-repository.js +0 -7
- package/lib/kv-repository.js.map +0 -1
- package/lib/legacy-juggler-bridge.d.ts +0 -53
- package/lib/legacy-juggler-bridge.js +0 -142
- package/lib/legacy-juggler-bridge.js.map +0 -1
- package/lib/loopback-datasource-juggler.d.ts +0 -666
- package/lib/loopback-datasource-juggler.js +0 -8
- package/lib/loopback-datasource-juggler.js.map +0 -1
- package/lib/mixin.d.ts +0 -43
- package/lib/mixin.js +0 -34
- package/lib/mixin.js.map +0 -1
- package/lib/model.d.ts +0 -137
- package/lib/model.js +0 -182
- package/lib/model.js.map +0 -1
- package/lib/query.d.ts +0 -112
- package/lib/query.js +0 -25
- package/lib/query.js.map +0 -1
- package/lib/repository-mixin.d.ts +0 -20
- package/lib/repository-mixin.js +0 -111
- package/lib/repository-mixin.js.map +0 -1
- package/lib/repository.d.ts +0 -172
- package/lib/repository.js +0 -128
- package/lib/repository.js.map +0 -1
- package/lib/types/any.js +0 -35
- package/lib/types/any.js.map +0 -1
- package/lib/types/array.d.ts +0 -14
- package/lib/types/array.js.map +0 -1
- package/lib/types/boolean.js.map +0 -1
- package/lib/types/buffer.d.ts +0 -14
- package/lib/types/buffer.js.map +0 -1
- package/lib/types/date.js.map +0 -1
- package/lib/types/index.js +0 -33
- package/lib/types/index.js.map +0 -1
- package/lib/types/model.d.ts +0 -11
- package/lib/types/model.js +0 -25
- package/lib/types/model.js.map +0 -1
- package/lib/types/number.d.ts +0 -12
- package/lib/types/number.js.map +0 -1
- package/lib/types/object.js.map +0 -1
- package/lib/types/string.js.map +0 -1
- package/lib/types/type.d.ts +0 -38
- package/lib/types/type.js +0 -7
- package/lib/types/type.js.map +0 -1
- package/lib/types/union.js.map +0 -1
- package/lib6/common-types.d.ts +0 -44
- package/lib6/common-types.js +0 -7
- package/lib6/common-types.js.map +0 -1
- package/lib6/connector.d.ts +0 -12
- package/lib6/connector.js +0 -7
- package/lib6/connector.js.map +0 -1
- package/lib6/crud-connector.d.ts +0 -130
- package/lib6/crud-connector.js +0 -7
- package/lib6/crud-connector.js.map +0 -1
- package/lib6/datasource.d.ts +0 -11
- package/lib6/datasource.js.map +0 -1
- package/lib6/decorators/model.d.ts +0 -17
- package/lib6/decorators/model.js +0 -55
- package/lib6/decorators/model.js.map +0 -1
- package/lib6/decorators/relation.d.ts +0 -65
- package/lib6/decorators/relation.js +0 -126
- package/lib6/decorators/relation.js.map +0 -1
- package/lib6/decorators/repository.d.ts +0 -61
- package/lib6/decorators/repository.js +0 -117
- package/lib6/decorators/repository.js.map +0 -1
- package/lib6/index.d.ts +0 -17
- package/lib6/index.js +0 -21
- package/lib6/index.js.map +0 -1
- package/lib6/kv-connector.js +0 -7
- package/lib6/kv-connector.js.map +0 -1
- package/lib6/kv-repository.d.ts +0 -78
- package/lib6/kv-repository.js +0 -7
- package/lib6/kv-repository.js.map +0 -1
- package/lib6/legacy-juggler-bridge.d.ts +0 -53
- package/lib6/legacy-juggler-bridge.js +0 -158
- package/lib6/legacy-juggler-bridge.js.map +0 -1
- package/lib6/loopback-datasource-juggler.d.ts +0 -666
- package/lib6/loopback-datasource-juggler.js +0 -8
- package/lib6/loopback-datasource-juggler.js.map +0 -1
- package/lib6/mixin.d.ts +0 -43
- package/lib6/mixin.js +0 -34
- package/lib6/mixin.js.map +0 -1
- package/lib6/model.d.ts +0 -137
- package/lib6/model.js +0 -182
- package/lib6/model.js.map +0 -1
- package/lib6/query.d.ts +0 -112
- package/lib6/query.js +0 -25
- package/lib6/query.js.map +0 -1
- package/lib6/repository-mixin.d.ts +0 -20
- package/lib6/repository-mixin.js +0 -111
- package/lib6/repository-mixin.js.map +0 -1
- package/lib6/repository.d.ts +0 -172
- package/lib6/repository.js +0 -128
- package/lib6/repository.js.map +0 -1
- package/lib6/types/any.d.ts +0 -12
- package/lib6/types/any.js.map +0 -1
- package/lib6/types/array.js +0 -53
- package/lib6/types/array.js.map +0 -1
- package/lib6/types/boolean.d.ts +0 -12
- package/lib6/types/boolean.js.map +0 -1
- package/lib6/types/buffer.js +0 -57
- package/lib6/types/buffer.js.map +0 -1
- package/lib6/types/date.d.ts +0 -12
- package/lib6/types/date.js +0 -60
- package/lib6/types/date.js.map +0 -1
- package/lib6/types/index.d.ts +0 -30
- package/lib6/types/index.js +0 -33
- package/lib6/types/index.js.map +0 -1
- package/lib6/types/model.js.map +0 -1
- package/lib6/types/number.js +0 -40
- package/lib6/types/number.js.map +0 -1
- package/lib6/types/object.d.ts +0 -15
- package/lib6/types/object.js +0 -49
- package/lib6/types/object.js.map +0 -1
- package/lib6/types/string.d.ts +0 -12
- package/lib6/types/string.js +0 -40
- package/lib6/types/string.js.map +0 -1
- package/lib6/types/type.js.map +0 -1
- package/lib6/types/union.d.ts +0 -14
- package/lib6/types/union.js +0 -51
- package/lib6/types/union.js.map +0 -1
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/repository
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createModelClassBinding = exports.RepositoryMixinDoc = exports.RepositoryMixin = void 0;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
const core_1 = require("@loopback/core");
|
|
10
|
+
const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
|
|
11
|
+
const keys_1 = require("../keys");
|
|
12
|
+
const repositories_1 = require("../repositories");
|
|
13
|
+
const debug = (0, debug_1.default)('loopback:repository:mixin');
|
|
14
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
15
|
+
/**
|
|
16
|
+
* A mixin class for Application that creates a .repository()
|
|
17
|
+
* function to register a repository automatically. Also overrides
|
|
18
|
+
* component function to allow it to register repositories automatically.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* class MyApplication extends RepositoryMixin(Application) {}
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Please note: the members in the mixin function are documented in a dummy class
|
|
26
|
+
* called <a href="#RepositoryMixinDoc">RepositoryMixinDoc</a>
|
|
27
|
+
*
|
|
28
|
+
* @param superClass - Application class
|
|
29
|
+
* @returns A new class that extends the super class with repository related
|
|
30
|
+
* methods
|
|
31
|
+
*
|
|
32
|
+
* @typeParam T - Type of the application class as the target for the mixin
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
function RepositoryMixin(superClass) {
|
|
36
|
+
return class extends superClass {
|
|
37
|
+
/**
|
|
38
|
+
* Add a repository to this application.
|
|
39
|
+
*
|
|
40
|
+
* @param repoClass - The repository to add.
|
|
41
|
+
* @param nameOrOptions - Name or options for the binding
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
*
|
|
46
|
+
* class NoteRepo {
|
|
47
|
+
* model: any;
|
|
48
|
+
*
|
|
49
|
+
* constructor() {
|
|
50
|
+
* const ds: juggler.DataSource = new juggler.DataSource({
|
|
51
|
+
* name: 'db',
|
|
52
|
+
* connector: 'memory',
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* this.model = ds.createModel(
|
|
56
|
+
* 'note',
|
|
57
|
+
* {title: 'string', content: 'string'},
|
|
58
|
+
* {}
|
|
59
|
+
* );
|
|
60
|
+
* }
|
|
61
|
+
* };
|
|
62
|
+
*
|
|
63
|
+
* app.repository(NoteRepo);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
repository(repoClass, nameOrOptions) {
|
|
68
|
+
const binding = (0, core_1.createBindingFromClass)(repoClass, {
|
|
69
|
+
namespace: keys_1.RepositoryBindings.REPOSITORIES,
|
|
70
|
+
type: keys_1.RepositoryTags.REPOSITORY,
|
|
71
|
+
defaultScope: core_1.BindingScope.TRANSIENT,
|
|
72
|
+
...toOptions(nameOrOptions),
|
|
73
|
+
}).tag(keys_1.RepositoryTags.REPOSITORY);
|
|
74
|
+
this.add(binding);
|
|
75
|
+
return binding;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Retrieve the repository instance from the given Repository class
|
|
79
|
+
*
|
|
80
|
+
* @param repo - The repository class to retrieve the instance of
|
|
81
|
+
*/
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
|
+
async getRepository(repo) {
|
|
84
|
+
return this.get(`repositories.${repo.name}`);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Add the dataSource to this application.
|
|
88
|
+
*
|
|
89
|
+
* @param dataSource - The dataSource to add.
|
|
90
|
+
* @param nameOrOptions - The binding name or options of the datasource;
|
|
91
|
+
* defaults to dataSource.name
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
*
|
|
96
|
+
* const ds: juggler.DataSource = new juggler.DataSource({
|
|
97
|
+
* name: 'db',
|
|
98
|
+
* connector: 'memory',
|
|
99
|
+
* });
|
|
100
|
+
*
|
|
101
|
+
* app.dataSource(ds);
|
|
102
|
+
*
|
|
103
|
+
* // The datasource can be injected with
|
|
104
|
+
* constructor(@inject('datasources.db') dataSource: DataSourceType) {
|
|
105
|
+
*
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
dataSource(dataSource, nameOrOptions) {
|
|
110
|
+
var _a;
|
|
111
|
+
const options = toOptions(nameOrOptions);
|
|
112
|
+
// We have an instance of
|
|
113
|
+
if (dataSource instanceof repositories_1.juggler.DataSource) {
|
|
114
|
+
const name = options.name || dataSource.name;
|
|
115
|
+
const namespace = (_a = options.namespace) !== null && _a !== void 0 ? _a : keys_1.RepositoryBindings.DATASOURCES;
|
|
116
|
+
const key = `${namespace}.${name}`;
|
|
117
|
+
return this.bind(key).to(dataSource).tag(keys_1.RepositoryTags.DATASOURCE);
|
|
118
|
+
}
|
|
119
|
+
else if (typeof dataSource === 'function') {
|
|
120
|
+
options.name = options.name || dataSource.dataSourceName;
|
|
121
|
+
const binding = (0, core_1.createBindingFromClass)(dataSource, {
|
|
122
|
+
namespace: keys_1.RepositoryBindings.DATASOURCES,
|
|
123
|
+
type: keys_1.RepositoryTags.DATASOURCE,
|
|
124
|
+
defaultScope: core_1.BindingScope.SINGLETON,
|
|
125
|
+
...options,
|
|
126
|
+
});
|
|
127
|
+
this.add(binding);
|
|
128
|
+
return binding;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
throw new Error('not a valid DataSource.');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Register a model class as a binding in the target context
|
|
136
|
+
* @param modelClass - Model class
|
|
137
|
+
*/
|
|
138
|
+
model(modelClass) {
|
|
139
|
+
const binding = createModelClassBinding(modelClass);
|
|
140
|
+
this.add(binding);
|
|
141
|
+
return binding;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Add a component to this application. Also mounts
|
|
145
|
+
* all the components repositories.
|
|
146
|
+
*
|
|
147
|
+
* @param component - The component to add.
|
|
148
|
+
* @param nameOrOptions - Name or options for the binding.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
*
|
|
153
|
+
* export class ProductComponent {
|
|
154
|
+
* controllers = [ProductController];
|
|
155
|
+
* repositories = [ProductRepo, UserRepo];
|
|
156
|
+
* providers = {
|
|
157
|
+
* [AUTHENTICATION_STRATEGY]: AuthStrategy,
|
|
158
|
+
* [AUTHORIZATION_ROLE]: Role,
|
|
159
|
+
* };
|
|
160
|
+
* };
|
|
161
|
+
*
|
|
162
|
+
* app.component(ProductComponent);
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
// Unfortunately, TypeScript does not allow overriding methods inherited
|
|
166
|
+
// from mapped types. https://github.com/microsoft/TypeScript/issues/38496
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
168
|
+
// @ts-ignore
|
|
169
|
+
component(componentCtor, nameOrOptions) {
|
|
170
|
+
const binding = super.component(componentCtor, nameOrOptions);
|
|
171
|
+
const instance = this.getSync(binding.key);
|
|
172
|
+
this.mountComponentRepositories(instance);
|
|
173
|
+
this.mountComponentModels(instance);
|
|
174
|
+
return binding;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get an instance of a component and mount all it's
|
|
178
|
+
* repositories. This function is intended to be used internally
|
|
179
|
+
* by `component()`.
|
|
180
|
+
*
|
|
181
|
+
* NOTE: Calling `mountComponentRepositories` with a component class
|
|
182
|
+
* constructor is deprecated. You should instantiate the component
|
|
183
|
+
* yourself and provide the component instance instead.
|
|
184
|
+
*
|
|
185
|
+
* @param componentInstanceOrClass - The component to mount repositories of
|
|
186
|
+
* @internal
|
|
187
|
+
*/
|
|
188
|
+
mountComponentRepositories(
|
|
189
|
+
// accept also component class to preserve backwards compatibility
|
|
190
|
+
// TODO(semver-major) Remove support for component class constructor
|
|
191
|
+
componentInstanceOrClass) {
|
|
192
|
+
const component = resolveComponentInstance(this);
|
|
193
|
+
if (component.repositories) {
|
|
194
|
+
for (const repo of component.repositories) {
|
|
195
|
+
this.repository(repo);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// `Readonly<Application>` is a hack to remove protected members
|
|
199
|
+
// and thus allow `this` to be passed as a value for `ctx`
|
|
200
|
+
function resolveComponentInstance(ctx) {
|
|
201
|
+
if (typeof componentInstanceOrClass !== 'function')
|
|
202
|
+
return componentInstanceOrClass;
|
|
203
|
+
const componentName = componentInstanceOrClass.name;
|
|
204
|
+
const componentKey = `${core_1.CoreBindings.COMPONENTS}.${componentName}`;
|
|
205
|
+
return ctx.getSync(componentKey);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Bind all model classes provided by a component.
|
|
210
|
+
* @param component
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
mountComponentModels(component) {
|
|
214
|
+
if (!component.models)
|
|
215
|
+
return;
|
|
216
|
+
for (const m of component.models) {
|
|
217
|
+
this.model(m);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Update or recreate the database schema for all repositories.
|
|
222
|
+
*
|
|
223
|
+
* **WARNING**: By default, `migrateSchema()` will attempt to preserve data
|
|
224
|
+
* while updating the schema in your target database, but this is not
|
|
225
|
+
* guaranteed to be safe.
|
|
226
|
+
*
|
|
227
|
+
* Please check the documentation for your specific connector(s) for
|
|
228
|
+
* a detailed breakdown of behaviors for automigrate!
|
|
229
|
+
*
|
|
230
|
+
* @param options - Migration options, e.g. whether to update tables
|
|
231
|
+
* preserving data or rebuild everything from scratch.
|
|
232
|
+
*/
|
|
233
|
+
async migrateSchema(options = {}) {
|
|
234
|
+
var _a;
|
|
235
|
+
const operation = options.existingSchema === 'drop' ? 'automigrate' : 'autoupdate';
|
|
236
|
+
// Instantiate all repositories to ensure models are registered & attached
|
|
237
|
+
// to their datasources
|
|
238
|
+
const repoBindings = this.findByTag('repository');
|
|
239
|
+
await Promise.all(repoBindings.map(b => this.get(b.key)));
|
|
240
|
+
// Look up all datasources and update/migrate schemas one by one
|
|
241
|
+
const dsBindings = this.findByTag(keys_1.RepositoryTags.DATASOURCE);
|
|
242
|
+
for (const b of dsBindings) {
|
|
243
|
+
const ds = await this.get(b.key);
|
|
244
|
+
const disableMigration = (_a = ds.settings.disableMigration) !== null && _a !== void 0 ? _a : false;
|
|
245
|
+
if (operation in ds &&
|
|
246
|
+
typeof ds[operation] === 'function' &&
|
|
247
|
+
!disableMigration) {
|
|
248
|
+
debug('Migrating dataSource %s', b.key);
|
|
249
|
+
await ds[operation](options.models);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
debug('Skipping migration of dataSource %s', b.key);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
exports.RepositoryMixin = RepositoryMixin;
|
|
259
|
+
/**
|
|
260
|
+
* Normalize name or options to `BindingFromClassOptions`
|
|
261
|
+
* @param nameOrOptions - Name or options for binding from class
|
|
262
|
+
*/
|
|
263
|
+
function toOptions(nameOrOptions) {
|
|
264
|
+
if (typeof nameOrOptions === 'string') {
|
|
265
|
+
return { name: nameOrOptions };
|
|
266
|
+
}
|
|
267
|
+
return nameOrOptions !== null && nameOrOptions !== void 0 ? nameOrOptions : {};
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* A dummy class created to generate the tsdoc for the members in repository
|
|
271
|
+
* mixin. Please don't use it.
|
|
272
|
+
*
|
|
273
|
+
* The members are implemented in function
|
|
274
|
+
* <a href="#RepositoryMixin">RepositoryMixin</a>
|
|
275
|
+
*/
|
|
276
|
+
class RepositoryMixinDoc {
|
|
277
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
278
|
+
constructor(...args) {
|
|
279
|
+
throw new Error('This is a dummy class created for apidoc!' + 'Please do not use it!');
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Add a repository to this application.
|
|
283
|
+
*
|
|
284
|
+
* @param repo - The repository to add.
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```ts
|
|
288
|
+
*
|
|
289
|
+
* class NoteRepo {
|
|
290
|
+
* model: any;
|
|
291
|
+
*
|
|
292
|
+
* constructor() {
|
|
293
|
+
* const ds: juggler.DataSource = new juggler.DataSource({
|
|
294
|
+
* name: 'db',
|
|
295
|
+
* connector: 'memory',
|
|
296
|
+
* });
|
|
297
|
+
*
|
|
298
|
+
* this.model = ds.createModel(
|
|
299
|
+
* 'note',
|
|
300
|
+
* {title: 'string', content: 'string'},
|
|
301
|
+
* {}
|
|
302
|
+
* );
|
|
303
|
+
* }
|
|
304
|
+
* };
|
|
305
|
+
*
|
|
306
|
+
* app.repository(NoteRepo);
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
310
|
+
repository(repo) {
|
|
311
|
+
throw new Error();
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Retrieve the repository instance from the given Repository class
|
|
315
|
+
*
|
|
316
|
+
* @param repo - The repository class to retrieve the instance of
|
|
317
|
+
*/
|
|
318
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
319
|
+
async getRepository(repo) {
|
|
320
|
+
return new repo();
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Add the dataSource to this application.
|
|
324
|
+
*
|
|
325
|
+
* @param dataSource - The dataSource to add.
|
|
326
|
+
* @param name - The binding name of the datasource; defaults to dataSource.name
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
*
|
|
331
|
+
* const ds: juggler.DataSource = new juggler.DataSource({
|
|
332
|
+
* name: 'db',
|
|
333
|
+
* connector: 'memory',
|
|
334
|
+
* });
|
|
335
|
+
*
|
|
336
|
+
* app.dataSource(ds);
|
|
337
|
+
*
|
|
338
|
+
* // The datasource can be injected with
|
|
339
|
+
* constructor(@inject('datasources.db') dataSource: DataSourceType) {
|
|
340
|
+
*
|
|
341
|
+
* }
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
dataSource(dataSource, name) {
|
|
345
|
+
throw new Error();
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Add a component to this application. Also mounts
|
|
349
|
+
* all the components repositories.
|
|
350
|
+
*
|
|
351
|
+
* @param component - The component to add.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```ts
|
|
355
|
+
*
|
|
356
|
+
* export class ProductComponent {
|
|
357
|
+
* controllers = [ProductController];
|
|
358
|
+
* repositories = [ProductRepo, UserRepo];
|
|
359
|
+
* providers = {
|
|
360
|
+
* [AUTHENTICATION_STRATEGY]: AuthStrategy,
|
|
361
|
+
* [AUTHORIZATION_ROLE]: Role,
|
|
362
|
+
* };
|
|
363
|
+
* };
|
|
364
|
+
*
|
|
365
|
+
* app.component(ProductComponent);
|
|
366
|
+
* ```
|
|
367
|
+
*/
|
|
368
|
+
component(component) {
|
|
369
|
+
throw new Error();
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Get an instance of a component and mount all it's
|
|
373
|
+
* repositories. This function is intended to be used internally
|
|
374
|
+
* by component()
|
|
375
|
+
*
|
|
376
|
+
* @param component - The component to mount repositories of
|
|
377
|
+
*/
|
|
378
|
+
mountComponentRepository(component) { }
|
|
379
|
+
/**
|
|
380
|
+
* Update or recreate the database schema for all repositories.
|
|
381
|
+
*
|
|
382
|
+
* **WARNING**: By default, `migrateSchema()` will attempt to preserve data
|
|
383
|
+
* while updating the schema in your target database, but this is not
|
|
384
|
+
* guaranteed to be safe.
|
|
385
|
+
*
|
|
386
|
+
* Please check the documentation for your specific connector(s) for
|
|
387
|
+
* a detailed breakdown of behaviors for automigrate!
|
|
388
|
+
*
|
|
389
|
+
* @param options - Migration options, e.g. whether to update tables
|
|
390
|
+
* preserving data or rebuild everything from scratch.
|
|
391
|
+
*/
|
|
392
|
+
async migrateSchema(options) { }
|
|
393
|
+
}
|
|
394
|
+
exports.RepositoryMixinDoc = RepositoryMixinDoc;
|
|
395
|
+
/**
|
|
396
|
+
* Create a binding for the given model class
|
|
397
|
+
* @param modelClass - Model class
|
|
398
|
+
*/
|
|
399
|
+
function createModelClassBinding(modelClass) {
|
|
400
|
+
return core_1.Binding.bind(`${keys_1.RepositoryBindings.MODELS}.${modelClass.name}`)
|
|
401
|
+
.to(modelClass)
|
|
402
|
+
.tag(keys_1.RepositoryTags.MODEL);
|
|
403
|
+
}
|
|
404
|
+
exports.createModelClassBinding = createModelClassBinding;
|
|
405
|
+
//# sourceMappingURL=repository.mixin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.mixin.js","sourceRoot":"","sources":["../../src/mixins/repository.mixin.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAUwB;AACxB,+DAAiC;AAGjC,kCAA2D;AAE3D,kDAAoD;AAEpD,MAAM,KAAK,GAAG,IAAA,eAAY,EAAC,2BAA2B,CAAC,CAAC;AAOxD,qDAAqD;AAErD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,eAAe,CAC7B,UAAa;IAEb,OAAO,KAAM,SAAQ,UAAU;QAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA4BG;QACH,8DAA8D;QAC9D,UAAU,CACR,SAAmB,EACnB,aAAgD;YAEhD,MAAM,OAAO,GAAG,IAAA,6BAAsB,EAAC,SAAS,EAAE;gBAChD,SAAS,EAAE,yBAAkB,CAAC,YAAY;gBAC1C,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IAEjD;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,aAAa,CAAC,OAAgC,IAAkB,CAAC;CACxE;AAhID,gDAgIC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,UAAa;IAEb,OAAO,cAAO,CAAC,IAAI,CAAI,GAAG,yBAAkB,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;SACtE,EAAE,CAAC,UAAU,CAAC;SACd,GAAG,CAAC,qBAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAND,0DAMC"}
|
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { AnyObject, DataObject, Options, PrototypeOf } from './common-types';
|
|
2
|
+
import { BelongsToDefinition, HasManyDefinition, HasOneDefinition, JsonSchema, RelationMetadata } from './index';
|
|
3
|
+
import { TypeResolver } from './type-resolver';
|
|
4
|
+
import { Type } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* This module defines the key classes representing building blocks for Domain
|
|
7
|
+
* Driven Design.
|
|
8
|
+
* See https://en.wikipedia.org/wiki/Domain-driven_design#Building_blocks
|
|
9
|
+
*/
|
|
10
|
+
export interface JsonSchemaWithExtensions extends JsonSchema {
|
|
11
|
+
[attributes: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export declare type PropertyType = string | Function | object | Type<any> | TypeResolver<Model>;
|
|
14
|
+
/**
|
|
15
|
+
* Property definition for a model
|
|
16
|
+
*/
|
|
17
|
+
export interface PropertyDefinition {
|
|
18
|
+
type: PropertyType;
|
|
19
|
+
id?: boolean | number;
|
|
20
|
+
/**
|
|
21
|
+
* Used to hide this property from the response body,
|
|
22
|
+
* adding this property to the hiddenProperties array
|
|
23
|
+
*/
|
|
24
|
+
hidden?: boolean;
|
|
25
|
+
json?: PropertyForm;
|
|
26
|
+
jsonSchema?: JsonSchemaWithExtensions;
|
|
27
|
+
store?: PropertyForm;
|
|
28
|
+
itemType?: PropertyType;
|
|
29
|
+
[attribute: string]: any;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Defining the settings for a model
|
|
33
|
+
* See https://loopback.io/doc/en/lb4/Model.html#supported-entries-of-model-definition
|
|
34
|
+
*/
|
|
35
|
+
export interface ModelSettings {
|
|
36
|
+
/**
|
|
37
|
+
* Description of the model
|
|
38
|
+
*/
|
|
39
|
+
description?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Prevent clients from setting the auto-generated ID value manually
|
|
42
|
+
*/
|
|
43
|
+
forceId?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Hides properties from response bodies
|
|
46
|
+
*/
|
|
47
|
+
hiddenProperties?: string[];
|
|
48
|
+
/**
|
|
49
|
+
* Scope enables you to set a scope that will apply to every query made by the model's repository
|
|
50
|
+
*/
|
|
51
|
+
scope?: object;
|
|
52
|
+
/**
|
|
53
|
+
* Specifies whether the model accepts only predefined properties or not
|
|
54
|
+
*/
|
|
55
|
+
strict?: boolean | 'filter';
|
|
56
|
+
[name: string]: any;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* See https://github.com/loopbackio/loopback-datasource-juggler/issues/432
|
|
60
|
+
*/
|
|
61
|
+
export interface PropertyForm {
|
|
62
|
+
in?: boolean;
|
|
63
|
+
out?: boolean;
|
|
64
|
+
name?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A key-value map describing model relations.
|
|
68
|
+
* A relation name is used as the key, a relation definition is the value.
|
|
69
|
+
*/
|
|
70
|
+
export declare type RelationDefinitionMap = {
|
|
71
|
+
[relationName: string]: RelationMetadata;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* DSL for building a model definition.
|
|
75
|
+
*/
|
|
76
|
+
export interface ModelDefinitionSyntax {
|
|
77
|
+
name: string;
|
|
78
|
+
properties?: {
|
|
79
|
+
[name: string]: PropertyDefinition | PropertyType;
|
|
80
|
+
};
|
|
81
|
+
settings?: ModelSettings;
|
|
82
|
+
relations?: RelationDefinitionMap;
|
|
83
|
+
jsonSchema?: JsonSchemaWithExtensions;
|
|
84
|
+
[attribute: string]: any;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Definition for a model
|
|
88
|
+
*/
|
|
89
|
+
export declare class ModelDefinition {
|
|
90
|
+
readonly name: string;
|
|
91
|
+
properties: {
|
|
92
|
+
[name: string]: PropertyDefinition;
|
|
93
|
+
};
|
|
94
|
+
settings: ModelSettings;
|
|
95
|
+
relations: RelationDefinitionMap;
|
|
96
|
+
[attribute: string]: any;
|
|
97
|
+
constructor(nameOrDef: string | ModelDefinitionSyntax);
|
|
98
|
+
/**
|
|
99
|
+
* Add a property
|
|
100
|
+
* @param name - Property definition or name (string)
|
|
101
|
+
* @param definitionOrType - Definition or property type
|
|
102
|
+
*/
|
|
103
|
+
addProperty(name: string, definitionOrType: PropertyDefinition | PropertyType): this;
|
|
104
|
+
/**
|
|
105
|
+
* Add a setting
|
|
106
|
+
* @param name - Setting name
|
|
107
|
+
* @param value - Setting value
|
|
108
|
+
*/
|
|
109
|
+
addSetting(name: string, value: any): this;
|
|
110
|
+
/**
|
|
111
|
+
* Define a new relation.
|
|
112
|
+
* @param definition - The definition of the new relation.
|
|
113
|
+
*/
|
|
114
|
+
addRelation(definition: RelationMetadata): this;
|
|
115
|
+
/**
|
|
116
|
+
* Define a new belongsTo relation.
|
|
117
|
+
* @param name - The name of the belongsTo relation.
|
|
118
|
+
* @param definition - The definition of the belongsTo relation.
|
|
119
|
+
*/
|
|
120
|
+
belongsTo(name: string, definition: Omit<BelongsToDefinition, 'name' | 'type' | 'targetsMany'>): this;
|
|
121
|
+
/**
|
|
122
|
+
* Define a new hasOne relation.
|
|
123
|
+
* @param name - The name of the hasOne relation.
|
|
124
|
+
* @param definition - The definition of the hasOne relation.
|
|
125
|
+
*/
|
|
126
|
+
hasOne(name: string, definition: Omit<HasOneDefinition, 'name' | 'type' | 'targetsMany'>): this;
|
|
127
|
+
/**
|
|
128
|
+
* Define a new hasMany relation.
|
|
129
|
+
* @param name - The name of the hasMany relation.
|
|
130
|
+
* @param definition - The definition of the hasMany relation.
|
|
131
|
+
*/
|
|
132
|
+
hasMany(name: string, definition: Omit<HasManyDefinition, 'name' | 'type' | 'targetsMany'>): this;
|
|
133
|
+
/**
|
|
134
|
+
* Get an array of names of ID properties, which are specified in
|
|
135
|
+
* the model settings or properties with `id` attribute.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* {
|
|
140
|
+
* settings: {
|
|
141
|
+
* id: ['id']
|
|
142
|
+
* }
|
|
143
|
+
* properties: {
|
|
144
|
+
* id: {
|
|
145
|
+
* type: 'string',
|
|
146
|
+
* id: true
|
|
147
|
+
* }
|
|
148
|
+
* }
|
|
149
|
+
* }
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
idProperties(): string[];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Base class for models
|
|
156
|
+
*/
|
|
157
|
+
export declare class Model {
|
|
158
|
+
static get modelName(): string;
|
|
159
|
+
static definition: ModelDefinition;
|
|
160
|
+
/**
|
|
161
|
+
* Serialize into a plain JSON object
|
|
162
|
+
*/
|
|
163
|
+
toJSON(): Object;
|
|
164
|
+
/**
|
|
165
|
+
* Convert to a plain object as DTO
|
|
166
|
+
*
|
|
167
|
+
* If `ignoreUnknownProperty` is set to false, convert all properties in the
|
|
168
|
+
* model instance, otherwise only convert the ones defined in the model
|
|
169
|
+
* definitions.
|
|
170
|
+
*
|
|
171
|
+
* See function `asObject` for each property's conversion rules.
|
|
172
|
+
*/
|
|
173
|
+
toObject(options?: Options): Object;
|
|
174
|
+
constructor(data?: DataObject<Model>);
|
|
175
|
+
}
|
|
176
|
+
export interface Persistable {
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Base class for value objects - An object that contains attributes but has no
|
|
180
|
+
* conceptual identity. They should be treated as immutable.
|
|
181
|
+
*/
|
|
182
|
+
export declare abstract class ValueObject extends Model implements Persistable {
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Base class for entities which have unique ids
|
|
186
|
+
*/
|
|
187
|
+
export declare class Entity extends Model implements Persistable {
|
|
188
|
+
/**
|
|
189
|
+
* Get the names of identity properties (primary keys).
|
|
190
|
+
*/
|
|
191
|
+
static getIdProperties(): string[];
|
|
192
|
+
/**
|
|
193
|
+
* Get the identity value for a given entity instance or entity data object.
|
|
194
|
+
*
|
|
195
|
+
* @param entityOrData - The data object for which to determine the identity
|
|
196
|
+
* value.
|
|
197
|
+
*/
|
|
198
|
+
static getIdOf(entityOrData: AnyObject): any;
|
|
199
|
+
/**
|
|
200
|
+
* Get the identity value. If the identity is a composite key, returns
|
|
201
|
+
* an object.
|
|
202
|
+
*/
|
|
203
|
+
getId(): any;
|
|
204
|
+
/**
|
|
205
|
+
* Get the identity as an object, such as `{id: 1}` or
|
|
206
|
+
* `{schoolId: 1, studentId: 2}`
|
|
207
|
+
*/
|
|
208
|
+
getIdObject(): Object;
|
|
209
|
+
/**
|
|
210
|
+
* Build the where object for the given id
|
|
211
|
+
* @param id - The id value
|
|
212
|
+
*/
|
|
213
|
+
static buildWhereForId(id: any): any;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Domain events
|
|
217
|
+
*/
|
|
218
|
+
export declare class Event {
|
|
219
|
+
source: any;
|
|
220
|
+
type: string;
|
|
221
|
+
}
|
|
222
|
+
export declare type EntityData = DataObject<Entity>;
|
|
223
|
+
export declare type EntityResolver<T extends Entity> = TypeResolver<T, typeof Entity>;
|
|
224
|
+
/**
|
|
225
|
+
* Check model data for navigational properties linking to related models.
|
|
226
|
+
* Throw a descriptive error if any such property is found.
|
|
227
|
+
*
|
|
228
|
+
* @param modelClass Model constructor, e.g. `Product`.
|
|
229
|
+
* @param entityData Model instance or a plain-data object,
|
|
230
|
+
* e.g. `{name: 'pen'}`.
|
|
231
|
+
*/
|
|
232
|
+
export declare function rejectNavigationalPropertiesInData<M extends typeof Entity>(modelClass: M, data: DataObject<PrototypeOf<M>>): void;
|