@loopback/model-api-builder 2.3.3

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 ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) IBM Corp. 2019.
2
+ Node module: @loopback/model-api-builder
3
+ This project is licensed under the MIT License, full text below.
4
+
5
+ --------
6
+
7
+ MIT license
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in
17
+ all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # @loopback/model-api-builder
2
+
3
+ Types and helpers for packages contributing Model API builders.
4
+
5
+ ## Overview
6
+
7
+ The `@loopback/model-api-builder` package provides a contract for extensions
8
+ that contribute builders for repositories and controllers. Users provide both
9
+ the model class and an extension. The extension is then used to build their
10
+ repository and controller based on the model class.
11
+
12
+ ## Installation
13
+
14
+ ```sh
15
+ npm install --save @loopback/model-api-builder
16
+ ```
17
+
18
+ ## Basic use
19
+
20
+ An extension that contributes the repository and controller builders can be made
21
+ by implementing `ModelApiBuilder`:
22
+
23
+ ```ts
24
+ import {
25
+ asModelApiBuilder,
26
+ ModelApiBuilder,
27
+ ModelApiConfig,
28
+ } from '@loopback/model-api-builder';
29
+
30
+ @injectable(asModelApiBuilder)
31
+ export class SampleApiBuilder implements ModelApiBuilder {
32
+ readonly pattern: string = 'Sample';
33
+
34
+ build(
35
+ application: ApplicationWithRepositories,
36
+ modelClass: typeof Model & {prototype: Model},
37
+ config: ModelApiConfig,
38
+ ): Promise<void> {
39
+ // define repository setup here
40
+ // ...
41
+ // define controller setup here
42
+ // ...
43
+ }
44
+ }
45
+ ```
46
+
47
+ ## Contributions
48
+
49
+ - [Guidelines](https://github.com/loopbackio/loopback-next/blob/master/docs/CONTRIBUTING.md)
50
+ - [Join the team](https://github.com/loopbackio/loopback-next/issues/110)
51
+
52
+ ## Contributors
53
+
54
+ See
55
+ [all contributors](https://github.com/loopbackio/loopback-next/graphs/contributors).
56
+
57
+ ## License
58
+
59
+ MIT
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A packge with types and helpers for packages contributing Model API builders.
3
+ *
4
+ * @remarks
5
+ * Provides a contract for extensions that contribute builders for repositories
6
+ * and controllers. Users provide both the model class and an extension. The
7
+ * extension is then used to build their repository and controller based on the
8
+ * model class.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ export * from './model-api-builder';
13
+ export * from './model-api-config';
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ // Copyright IBM Corp. 2019,2020. All Rights Reserved.
3
+ // Node module: @loopback/model-api-builder
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
+ const tslib_1 = require("tslib");
8
+ /**
9
+ * A packge with types and helpers for packages contributing Model API builders.
10
+ *
11
+ * @remarks
12
+ * Provides a contract for extensions that contribute builders for repositories
13
+ * and controllers. Users provide both the model class and an extension. The
14
+ * extension is then used to build their repository and controller based on the
15
+ * model class.
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ tslib_1.__exportStar(require("./model-api-builder"), exports);
20
+ tslib_1.__exportStar(require("./model-api-config"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,2CAA2C;AAC3C,+CAA+C;AAC/C,gEAAgE;;;AAEhE;;;;;;;;;;GAUG;AAEH,8DAAoC;AACpC,6DAAmC"}
@@ -0,0 +1,20 @@
1
+ import { BindingTemplate } from '@loopback/core';
2
+ import { ApplicationWithRepositories, Model } from '@loopback/repository';
3
+ import { ModelApiConfig } from './model-api-config';
4
+ /**
5
+ * Extension Point name for Model API builders.
6
+ */
7
+ export declare const MODEL_API_BUILDER_PLUGINS = "model-api-builders";
8
+ /**
9
+ * Interface for extensions contributing custom API flavors.
10
+ */
11
+ export interface ModelApiBuilder {
12
+ readonly pattern: string;
13
+ build(application: ApplicationWithRepositories, modelClass: typeof Model & {
14
+ prototype: Model;
15
+ }, config: ModelApiConfig): Promise<void>;
16
+ }
17
+ /**
18
+ * A binding template for model API extensions
19
+ */
20
+ export declare const asModelApiBuilder: BindingTemplate;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ // Copyright IBM Corp. 2019. All Rights Reserved.
3
+ // Node module: @loopback/model-api-builder
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.asModelApiBuilder = exports.MODEL_API_BUILDER_PLUGINS = void 0;
8
+ const core_1 = require("@loopback/core");
9
+ /**
10
+ * Extension Point name for Model API builders.
11
+ */
12
+ exports.MODEL_API_BUILDER_PLUGINS = 'model-api-builders';
13
+ /**
14
+ * A binding template for model API extensions
15
+ */
16
+ const asModelApiBuilder = binding => {
17
+ core_1.extensionFor(exports.MODEL_API_BUILDER_PLUGINS)(binding);
18
+ binding.tag({ namespace: 'model-api-builders' });
19
+ };
20
+ exports.asModelApiBuilder = asModelApiBuilder;
21
+ //# sourceMappingURL=model-api-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-api-builder.js","sourceRoot":"","sources":["../src/model-api-builder.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,2CAA2C;AAC3C,+CAA+C;AAC/C,gEAAgE;;;AAEhE,yCAA6D;AAI7D;;GAEG;AACU,QAAA,yBAAyB,GAAG,oBAAoB,CAAC;AAc9D;;GAEG;AACI,MAAM,iBAAiB,GAAoB,OAAO,CAAC,EAAE;IAC1D,mBAAY,CAAC,iCAAyB,CAAC,CAAC,OAAO,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,EAAC,SAAS,EAAE,oBAAoB,EAAC,CAAC,CAAC;AACjD,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B"}
@@ -0,0 +1,26 @@
1
+ import { Model } from '@loopback/repository';
2
+ /**
3
+ * Configuration settings for individual model files. This type describes
4
+ * content of `public-models/{model-name}.config.json` files.
5
+ */
6
+ export declare type ModelApiConfig = {
7
+ /**
8
+ * The model class that the repository and controller are to be built from.
9
+ * e.g. Product (a Model class)
10
+ */
11
+ model: typeof Model & {
12
+ prototype: Model;
13
+ };
14
+ /**
15
+ * Name of data-access pattern describing the API builder. Users can
16
+ * customize and use a unique pattern name.
17
+ * e.g. 'RestCrud'
18
+ */
19
+ pattern: string;
20
+ /**
21
+ * The dataSource the model uses under the hood.
22
+ * e.g. 'db'
23
+ */
24
+ dataSource: string;
25
+ [patternSpecificSetting: string]: unknown;
26
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ // Copyright IBM Corp. 2019. All Rights Reserved.
3
+ // Node module: @loopback/model-api-builder
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
+ //# sourceMappingURL=model-api-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-api-config.js","sourceRoot":"","sources":["../src/model-api-config.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,2CAA2C;AAC3C,+CAA+C;AAC/C,gEAAgE"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@loopback/model-api-builder",
3
+ "description": "Types and helpers for packages contributing Model API builders.",
4
+ "version": "2.3.3",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "author": "IBM Corp.",
9
+ "copyright.owner": "IBM Corp.",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/loopbackio/loopback-next.git",
13
+ "directory": "packages/model-api-builder"
14
+ },
15
+ "engines": {
16
+ "node": "^10.16 || 12 || 14 || 16"
17
+ },
18
+ "scripts": {
19
+ "build": "lb-tsc",
20
+ "clean": "lb-clean loopback-model-api-builder*.tgz dist *.tsbuildinfo package",
21
+ "pretest": "npm run build",
22
+ "test": "",
23
+ "verify": "npm pack && tar xf loopback-model-api-builder*.tgz && tree package && npm run clean"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "files": [
29
+ "README.md",
30
+ "dist",
31
+ "src",
32
+ "!*/__tests__"
33
+ ],
34
+ "peerDependencies": {
35
+ "@loopback/core": "^2.17.0",
36
+ "@loopback/repository": "^3.7.2"
37
+ },
38
+ "dependencies": {
39
+ "tslib": "^2.3.1"
40
+ },
41
+ "devDependencies": {
42
+ "@loopback/build": "^7.0.1",
43
+ "@loopback/core": "^2.17.0",
44
+ "@loopback/repository": "^3.7.2",
45
+ "@types/node": "^10.17.60"
46
+ },
47
+ "gitHead": "1df36bb1ee2e513d9e197bd6010c4cfb296d50b8"
48
+ }
package/src/index.ts ADDED
@@ -0,0 +1,19 @@
1
+ // Copyright IBM Corp. 2019,2020. All Rights Reserved.
2
+ // Node module: @loopback/model-api-builder
3
+ // This file is licensed under the MIT License.
4
+ // License text available at https://opensource.org/licenses/MIT
5
+
6
+ /**
7
+ * A packge with types and helpers for packages contributing Model API builders.
8
+ *
9
+ * @remarks
10
+ * Provides a contract for extensions that contribute builders for repositories
11
+ * and controllers. Users provide both the model class and an extension. The
12
+ * extension is then used to build their repository and controller based on the
13
+ * model class.
14
+ *
15
+ * @packageDocumentation
16
+ */
17
+
18
+ export * from './model-api-builder';
19
+ export * from './model-api-config';
@@ -0,0 +1,33 @@
1
+ // Copyright IBM Corp. 2019. All Rights Reserved.
2
+ // Node module: @loopback/model-api-builder
3
+ // This file is licensed under the MIT License.
4
+ // License text available at https://opensource.org/licenses/MIT
5
+
6
+ import {BindingTemplate, extensionFor} from '@loopback/core';
7
+ import {ApplicationWithRepositories, Model} from '@loopback/repository';
8
+ import {ModelApiConfig} from './model-api-config';
9
+
10
+ /**
11
+ * Extension Point name for Model API builders.
12
+ */
13
+ export const MODEL_API_BUILDER_PLUGINS = 'model-api-builders';
14
+
15
+ /**
16
+ * Interface for extensions contributing custom API flavors.
17
+ */
18
+ export interface ModelApiBuilder {
19
+ readonly pattern: string; // e.g. CrudRest
20
+ build(
21
+ application: ApplicationWithRepositories,
22
+ modelClass: typeof Model & {prototype: Model},
23
+ config: ModelApiConfig,
24
+ ): Promise<void>;
25
+ }
26
+
27
+ /**
28
+ * A binding template for model API extensions
29
+ */
30
+ export const asModelApiBuilder: BindingTemplate = binding => {
31
+ extensionFor(MODEL_API_BUILDER_PLUGINS)(binding);
32
+ binding.tag({namespace: 'model-api-builders'});
33
+ };
@@ -0,0 +1,33 @@
1
+ // Copyright IBM Corp. 2019. All Rights Reserved.
2
+ // Node module: @loopback/model-api-builder
3
+ // This file is licensed under the MIT License.
4
+ // License text available at https://opensource.org/licenses/MIT
5
+
6
+ import {Model} from '@loopback/repository';
7
+
8
+ /**
9
+ * Configuration settings for individual model files. This type describes
10
+ * content of `public-models/{model-name}.config.json` files.
11
+ */
12
+ export type ModelApiConfig = {
13
+ /**
14
+ * The model class that the repository and controller are to be built from.
15
+ * e.g. Product (a Model class)
16
+ */
17
+ model: typeof Model & {prototype: Model};
18
+
19
+ /**
20
+ * Name of data-access pattern describing the API builder. Users can
21
+ * customize and use a unique pattern name.
22
+ * e.g. 'RestCrud'
23
+ */
24
+ pattern: string;
25
+
26
+ /**
27
+ * The dataSource the model uses under the hood.
28
+ * e.g. 'db'
29
+ */
30
+ dataSource: string;
31
+
32
+ [patternSpecificSetting: string]: unknown;
33
+ };