@loopback/repository-json-schema 4.0.0-alpha.7 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +15 -10
  3. package/dist/build-schema.d.ts +137 -0
  4. package/dist/build-schema.js +445 -0
  5. package/dist/build-schema.js.map +1 -0
  6. package/dist/filter-json-schema.d.ts +54 -0
  7. package/dist/filter-json-schema.js +198 -0
  8. package/dist/filter-json-schema.js.map +1 -0
  9. package/dist/index.d.ts +36 -1
  10. package/dist/index.js +18 -7
  11. package/dist/index.js.map +1 -0
  12. package/dist/keys.d.ts +8 -0
  13. package/dist/keys.js +13 -0
  14. package/dist/keys.js.map +1 -0
  15. package/package.json +42 -33
  16. package/src/build-schema.ts +491 -79
  17. package/src/filter-json-schema.ts +237 -0
  18. package/src/index.ts +42 -1
  19. package/src/keys.ts +15 -0
  20. package/CHANGELOG.md +0 -75
  21. package/api-docs/apple-touch-icon-114x114-precomposed.png +0 -0
  22. package/api-docs/apple-touch-icon-144x144-precomposed.png +0 -0
  23. package/api-docs/apple-touch-icon-57x57-precomposed.png +0 -0
  24. package/api-docs/apple-touch-icon-72x72-precomposed.png +0 -0
  25. package/api-docs/apple-touch-icon-precomposed.png +0 -0
  26. package/api-docs/apple-touch-icon.png +0 -0
  27. package/api-docs/css/bootstrap.min.css +0 -9
  28. package/api-docs/css/code-themes/arta.css +0 -158
  29. package/api-docs/css/code-themes/ascetic.css +0 -50
  30. package/api-docs/css/code-themes/brown_paper.css +0 -104
  31. package/api-docs/css/code-themes/brown_papersq.png +0 -0
  32. package/api-docs/css/code-themes/dark.css +0 -103
  33. package/api-docs/css/code-themes/default.css +0 -135
  34. package/api-docs/css/code-themes/far.css +0 -111
  35. package/api-docs/css/code-themes/github.css +0 -127
  36. package/api-docs/css/code-themes/googlecode.css +0 -144
  37. package/api-docs/css/code-themes/idea.css +0 -121
  38. package/api-docs/css/code-themes/ir_black.css +0 -104
  39. package/api-docs/css/code-themes/magula.css +0 -121
  40. package/api-docs/css/code-themes/monokai.css +0 -114
  41. package/api-docs/css/code-themes/pojoaque.css +0 -104
  42. package/api-docs/css/code-themes/pojoaque.jpg +0 -0
  43. package/api-docs/css/code-themes/rainbow.css +0 -114
  44. package/api-docs/css/code-themes/school_book.css +0 -111
  45. package/api-docs/css/code-themes/school_book.png +0 -0
  46. package/api-docs/css/code-themes/sl-theme.css +0 -45
  47. package/api-docs/css/code-themes/solarized_dark.css +0 -88
  48. package/api-docs/css/code-themes/solarized_light.css +0 -88
  49. package/api-docs/css/code-themes/sunburst.css +0 -158
  50. package/api-docs/css/code-themes/tomorrow-night-blue.css +0 -52
  51. package/api-docs/css/code-themes/tomorrow-night-bright.css +0 -51
  52. package/api-docs/css/code-themes/tomorrow-night-eighties.css +0 -51
  53. package/api-docs/css/code-themes/tomorrow-night.css +0 -52
  54. package/api-docs/css/code-themes/tomorrow.css +0 -49
  55. package/api-docs/css/code-themes/vs.css +0 -86
  56. package/api-docs/css/code-themes/xcode.css +0 -154
  57. package/api-docs/css/code-themes/zenburn.css +0 -115
  58. package/api-docs/css/main.css +0 -139
  59. package/api-docs/favicon.ico +0 -0
  60. package/api-docs/fonts/0ihfXUL2emPh0ROJezvraLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
  61. package/api-docs/fonts/OsJ2DjdpjqFRVUSto6IffLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
  62. package/api-docs/fonts/_aijTyevf54tkVDLy-dlnLO3LdcAZYWl9Si6vvxL-qU.woff +0 -0
  63. package/api-docs/index.html +0 -53
  64. package/api-docs/js/main.js +0 -19
  65. package/api-docs/js/vendor/bootstrap.min.js +0 -6
  66. package/api-docs/js/vendor/jquery-1.10.1.min.js +0 -6
  67. package/api-docs/js/vendor/jquery.scrollTo-1.4.3.1.js +0 -218
  68. package/api-docs/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js +0 -11
  69. package/dist/src/build-schema.d.ts +0 -50
  70. package/dist/src/build-schema.js +0 -143
  71. package/dist/src/build-schema.js.map +0 -1
  72. package/dist/src/index.d.ts +0 -1
  73. package/dist/src/index.js +0 -11
  74. package/dist/src/index.js.map +0 -1
  75. package/index.d.ts +0 -6
  76. package/index.js +0 -6
@@ -0,0 +1,54 @@
1
+ import { Model } from '@loopback/repository';
2
+ import { JSONSchema7 as JsonSchema } from 'json-schema';
3
+ export interface FilterSchemaOptions {
4
+ /**
5
+ * Set this flag if you want the schema to set generated title property.
6
+ *
7
+ * By default the setting is enabled. (e.g. {setTitle: true})
8
+ *
9
+ */
10
+ setTitle?: boolean;
11
+ /**
12
+ * To exclude one or more property from `filter`
13
+ */
14
+ exclude?: string[] | string;
15
+ }
16
+ export declare const AnyScopeFilterSchema: JsonSchema;
17
+ /**
18
+ * Build a JSON schema describing the format of the "scope" object
19
+ * used to query model instances.
20
+ *
21
+ * Note we don't take the model properties into account yet and return
22
+ * a generic json schema allowing any "where" condition.
23
+ *
24
+ * @param modelCtor - The model constructor to build the filter schema for.
25
+ */
26
+ export declare function getScopeFilterJsonSchemaFor(modelCtor: typeof Model, options?: FilterSchemaOptions): JsonSchema;
27
+ /**
28
+ * Build a JSON schema describing the format of the "filter" object
29
+ * used to query model instances.
30
+ *
31
+ * Note we don't take the model properties into account yet and return
32
+ * a generic json schema allowing any "where" condition.
33
+ *
34
+ * @param modelCtor - The model constructor to build the filter schema for.
35
+ * @param options - Options to build the filter schema.
36
+ */
37
+ export declare function getFilterJsonSchemaFor(modelCtor: typeof Model, options?: FilterSchemaOptions): JsonSchema;
38
+ /**
39
+ * Build a JSON schema describing the format of the "where" object
40
+ * used to filter model instances to query, update or delete.
41
+ *
42
+ * Note we don't take the model properties into account yet and return
43
+ * a generic json schema allowing any "where" condition.
44
+ *
45
+ * @param modelCtor - The model constructor to build the filter schema for.
46
+ */
47
+ export declare function getWhereJsonSchemaFor(modelCtor: typeof Model, options?: FilterSchemaOptions): JsonSchema;
48
+ /**
49
+ * Build a JSON schema describing the format of the "fields" object
50
+ * used to include or exclude properties of model instances.
51
+ *
52
+ * @param modelCtor - The model constructor to build the filter schema for.
53
+ */
54
+ export declare function getFieldsJsonSchemaFor(modelCtor: typeof Model, options?: FilterSchemaOptions): JsonSchema;
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ // Copyright IBM Corp. 2018,2020. All Rights Reserved.
3
+ // Node module: @loopback/repository-json-schema
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.getFieldsJsonSchemaFor = exports.getWhereJsonSchemaFor = exports.getFilterJsonSchemaFor = exports.getScopeFilterJsonSchemaFor = exports.AnyScopeFilterSchema = void 0;
8
+ const tslib_1 = require("tslib");
9
+ const repository_1 = require("@loopback/repository");
10
+ exports.AnyScopeFilterSchema = {
11
+ type: 'array',
12
+ items: {
13
+ type: 'object',
14
+ properties: {},
15
+ additionalProperties: true,
16
+ },
17
+ };
18
+ /**
19
+ * Build a JSON schema describing the format of the "scope" object
20
+ * used to query model instances.
21
+ *
22
+ * Note we don't take the model properties into account yet and return
23
+ * a generic json schema allowing any "where" condition.
24
+ *
25
+ * @param modelCtor - The model constructor to build the filter schema for.
26
+ */
27
+ function getScopeFilterJsonSchemaFor(modelCtor, options = {}) {
28
+ let EmptyModel = class EmptyModel extends repository_1.Model {
29
+ };
30
+ EmptyModel = (0, tslib_1.__decorate)([
31
+ (0, repository_1.model)({ settings: { strict: false } })
32
+ ], EmptyModel);
33
+ const schema = {
34
+ type: 'object',
35
+ ...getFilterJsonSchemaFor(EmptyModel, {
36
+ setTitle: false,
37
+ }),
38
+ ...(options.setTitle !== false && {
39
+ title: `${modelCtor.modelName}.ScopeFilter`,
40
+ }),
41
+ };
42
+ // To include nested models, we need to hard-code the inclusion
43
+ // filter schema for EmptyModel to allow any object query.
44
+ schema.properties.include = { ...exports.AnyScopeFilterSchema };
45
+ return schema;
46
+ }
47
+ exports.getScopeFilterJsonSchemaFor = getScopeFilterJsonSchemaFor;
48
+ /**
49
+ * Build a JSON schema describing the format of the "filter" object
50
+ * used to query model instances.
51
+ *
52
+ * Note we don't take the model properties into account yet and return
53
+ * a generic json schema allowing any "where" condition.
54
+ *
55
+ * @param modelCtor - The model constructor to build the filter schema for.
56
+ * @param options - Options to build the filter schema.
57
+ */
58
+ function getFilterJsonSchemaFor(modelCtor, options = {}) {
59
+ var _a;
60
+ let excluded;
61
+ if (typeof options.exclude === 'string') {
62
+ excluded = [options.exclude];
63
+ }
64
+ else {
65
+ excluded = (_a = options.exclude) !== null && _a !== void 0 ? _a : [];
66
+ }
67
+ const properties = {
68
+ offset: {
69
+ type: 'integer',
70
+ minimum: 0,
71
+ },
72
+ limit: {
73
+ type: 'integer',
74
+ minimum: 1,
75
+ examples: [100],
76
+ },
77
+ skip: {
78
+ type: 'integer',
79
+ minimum: 0,
80
+ },
81
+ order: {
82
+ oneOf: [
83
+ {
84
+ type: 'string',
85
+ },
86
+ {
87
+ type: 'array',
88
+ items: {
89
+ type: 'string',
90
+ },
91
+ },
92
+ ],
93
+ },
94
+ };
95
+ if (!excluded.includes('where')) {
96
+ properties.where = getWhereJsonSchemaFor(modelCtor, options);
97
+ }
98
+ if (!excluded.includes('fields')) {
99
+ properties.fields = getFieldsJsonSchemaFor(modelCtor, options);
100
+ }
101
+ // Remove excluded properties
102
+ for (const p of excluded) {
103
+ delete properties[p];
104
+ }
105
+ const schema = {
106
+ type: 'object',
107
+ ...(options.setTitle !== false && {
108
+ title: `${modelCtor.modelName}.Filter`,
109
+ }),
110
+ properties,
111
+ additionalProperties: false,
112
+ };
113
+ const modelRelations = (0, repository_1.getModelRelations)(modelCtor);
114
+ const hasRelations = Object.keys(modelRelations).length > 0;
115
+ if (hasRelations && !excluded.includes('include')) {
116
+ schema.properties.include = {
117
+ ...(options.setTitle !== false && {
118
+ title: `${modelCtor.modelName}.IncludeFilter`,
119
+ }),
120
+ type: 'array',
121
+ items: {
122
+ anyOf: [
123
+ {
124
+ ...(options.setTitle !== false && {
125
+ title: `${modelCtor.modelName}.IncludeFilter.Items`,
126
+ }),
127
+ type: 'object',
128
+ properties: {
129
+ // TODO(bajtos) restrict values to relations defined by "model"
130
+ relation: { type: 'string' },
131
+ // TODO(bajtos) describe the filter for the relation target model
132
+ scope: getScopeFilterJsonSchemaFor(modelCtor, options),
133
+ },
134
+ },
135
+ {
136
+ type: 'string',
137
+ },
138
+ ],
139
+ },
140
+ };
141
+ }
142
+ return schema;
143
+ }
144
+ exports.getFilterJsonSchemaFor = getFilterJsonSchemaFor;
145
+ /**
146
+ * Build a JSON schema describing the format of the "where" object
147
+ * used to filter model instances to query, update or delete.
148
+ *
149
+ * Note we don't take the model properties into account yet and return
150
+ * a generic json schema allowing any "where" condition.
151
+ *
152
+ * @param modelCtor - The model constructor to build the filter schema for.
153
+ */
154
+ function getWhereJsonSchemaFor(modelCtor, options = {}) {
155
+ const schema = {
156
+ ...(options.setTitle !== false && {
157
+ title: `${modelCtor.modelName}.WhereFilter`,
158
+ }),
159
+ type: 'object',
160
+ // TODO(bajtos) enumerate "model" properties and operators like "and"
161
+ // See https://github.com/loopbackio/loopback-next/issues/1748
162
+ additionalProperties: true,
163
+ };
164
+ return schema;
165
+ }
166
+ exports.getWhereJsonSchemaFor = getWhereJsonSchemaFor;
167
+ /**
168
+ * Build a JSON schema describing the format of the "fields" object
169
+ * used to include or exclude properties of model instances.
170
+ *
171
+ * @param modelCtor - The model constructor to build the filter schema for.
172
+ */
173
+ function getFieldsJsonSchemaFor(modelCtor, options = {}) {
174
+ var _a, _b;
175
+ const schema = { oneOf: [] };
176
+ if (options.setTitle !== false) {
177
+ schema.title = `${modelCtor.modelName}.Fields`;
178
+ }
179
+ const properties = Object.keys(modelCtor.definition.properties);
180
+ const additionalProperties = modelCtor.definition.settings.strict === false;
181
+ (_a = schema.oneOf) === null || _a === void 0 ? void 0 : _a.push({
182
+ type: 'object',
183
+ properties: properties.reduce((prev, crr) => ({ ...prev, [crr]: { type: 'boolean' } }), {}),
184
+ additionalProperties,
185
+ });
186
+ (_b = schema.oneOf) === null || _b === void 0 ? void 0 : _b.push({
187
+ type: 'array',
188
+ items: {
189
+ type: 'string',
190
+ enum: properties.length && !additionalProperties ? properties : undefined,
191
+ examples: properties,
192
+ },
193
+ uniqueItems: true,
194
+ });
195
+ return schema;
196
+ }
197
+ exports.getFieldsJsonSchemaFor = getFieldsJsonSchemaFor;
198
+ //# sourceMappingURL=filter-json-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-json-schema.js","sourceRoot":"","sources":["../src/filter-json-schema.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,gDAAgD;AAChD,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,qDAAqE;AAkBxD,QAAA,oBAAoB,GAAe;IAC9C,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE;QACd,oBAAoB,EAAE,IAAI;KAC3B;CACF,CAAC;AAEF;;;;;;;;GAQG;AACH,SAAgB,2BAA2B,CACzC,SAAuB,EACvB,UAA+B,EAAE;IAGjC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,kBAAK;KAAG,CAAA;IAA3B,UAAU;QADf,IAAA,kBAAK,EAAC,EAAC,QAAQ,EAAE,EAAC,MAAM,EAAE,KAAK,EAAC,EAAC,CAAC;OAC7B,UAAU,CAAiB;IAEjC,MAAM,MAAM,GAAe;QACzB,IAAI,EAAE,QAAQ;QACd,GAAG,sBAAsB,CAAC,UAAU,EAAE;YACpC,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,KAAK,IAAI;YAChC,KAAK,EAAE,GAAG,SAAS,CAAC,SAAS,cAAc;SAC5C,CAAC;KACH,CAAC;IAEF,+DAA+D;IAC/D,0DAA0D;IAC1D,MAAM,CAAC,UAAW,CAAC,OAAO,G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AC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAhCD,wDAgCC"}
package/dist/index.d.ts CHANGED
@@ -1 +1,36 @@
1
- export * from './src';
1
+ /**
2
+ * Convert a TypeScript class/model to a JSON Schema for users, leveraging
3
+ * LoopBack4's decorators, metadata, and reflection system.
4
+ *
5
+ * @remarks
6
+ * Modules to easily convert LoopBack4 models that have been decorated with
7
+ * `@model` and `@property` to a matching JSON Schema Definition.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ export { JsonSchema, Model } from '@loopback/repository';
12
+ export * from './build-schema';
13
+ export * from './filter-json-schema';
14
+ export * from './keys';
15
+ /**
16
+ * Optional: From `T` make a set of properties by key `K` become optional
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * type Props = {
21
+ * name: string;
22
+ * age: number;
23
+ * visible: boolean;
24
+ * };
25
+ *
26
+ * // Expect: { name?: string; age?: number; visible?: boolean; }
27
+ * type Props = Optional<Props>;
28
+ *
29
+ * // Expect: { name: string; age?: number; visible?: boolean; }
30
+ * type Props = Optional<Props, 'age' | 'visible'>;
31
+ * ```
32
+ *
33
+ * @typeParam T - Type of the object
34
+ * @typeParam K - Keys of the object
35
+ */
36
+ export declare type Optional<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
package/dist/index.js CHANGED
@@ -1,13 +1,24 @@
1
1
  "use strict";
2
- // Copyright IBM Corp. 2018. All Rights Reserved.
2
+ // Copyright IBM Corp. 2018,2020. All Rights Reserved.
3
3
  // Node module: @loopback/repository-json-schema
4
4
  // This file is licensed under the MIT License.
5
5
  // License text available at https://opensource.org/licenses/MIT
6
- function __export(m) {
7
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
8
- }
9
6
  Object.defineProperty(exports, "__esModule", { value: true });
10
- // DO NOT EDIT THIS FILE
11
- // Add any aditional (re)exports to src/index.ts instead.
12
- __export(require("./src"));
7
+ exports.Model = void 0;
8
+ const tslib_1 = require("tslib");
9
+ /**
10
+ * Convert a TypeScript class/model to a JSON Schema for users, leveraging
11
+ * LoopBack4's decorators, metadata, and reflection system.
12
+ *
13
+ * @remarks
14
+ * Modules to easily convert LoopBack4 models that have been decorated with
15
+ * `@model` and `@property` to a matching JSON Schema Definition.
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ var repository_1 = require("@loopback/repository");
20
+ Object.defineProperty(exports, "Model", { enumerable: true, get: function () { return repository_1.Model; } });
21
+ (0, tslib_1.__exportStar)(require("./build-schema"), exports);
22
+ (0, tslib_1.__exportStar)(require("./filter-json-schema"), exports);
23
+ (0, tslib_1.__exportStar)(require("./keys"), exports);
13
24
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,gDAAgD;AAChD,+CAA+C;AAC/C,gEAAgE;;;;AAEhE;;;;;;;;;GASG;AAEH,mDAAuD;AAAnC,mGAAA,KAAK,OAAA;AACzB,8DAA+B;AAC/B,oEAAqC;AACrC,sDAAuB"}
package/dist/keys.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { MetadataAccessor } from '@loopback/core';
2
+ import { JsonSchema } from './index';
3
+ /**
4
+ * Metadata key used to set or retrieve repository JSON Schema
5
+ */
6
+ export declare const JSON_SCHEMA_KEY: MetadataAccessor<{
7
+ [key: string]: JsonSchema;
8
+ }, ClassDecorator>;
package/dist/keys.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ // Copyright IBM Corp. 2018,2020. All Rights Reserved.
3
+ // Node module: @loopback/repository-json-schema
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.JSON_SCHEMA_KEY = void 0;
8
+ const core_1 = require("@loopback/core");
9
+ /**
10
+ * Metadata key used to set or retrieve repository JSON Schema
11
+ */
12
+ exports.JSON_SCHEMA_KEY = core_1.MetadataAccessor.create('loopback:json-schema');
13
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,gDAAgD;AAChD,+CAA+C;AAC/C,gEAAgE;;;AAEhE,yCAAgD;AAGhD;;GAEG;AACU,QAAA,eAAe,GAAG,uBAAgB,CAAC,MAAM,CAGpD,sBAAsB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,50 +1,59 @@
1
1
  {
2
2
  "name": "@loopback/repository-json-schema",
3
- "version": "4.0.0-alpha.7",
4
3
  "description": "Converts TS classes into JSON Schemas using TypeScript's reflection API",
4
+ "version": "4.0.2",
5
+ "keywords": [
6
+ "LoopBack",
7
+ "TypeScript",
8
+ "JSON Schema"
9
+ ],
10
+ "license": "MIT",
11
+ "main": "dist/index.js",
12
+ "types": "dist/index.d.ts",
13
+ "author": "IBM Corp.",
14
+ "copyright.owner": "IBM Corp.",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/loopbackio/loopback-next.git",
18
+ "directory": "packages/repository-json-schema"
19
+ },
5
20
  "engines": {
6
- "node": ">=8"
21
+ "node": "^10.16 || 12 || 14 || 16"
7
22
  },
8
23
  "scripts": {
9
- "build": "lb-tsc es2017",
10
- "build:apidocs": "lb-apidocs",
11
- "clean": "lb-clean loopback-json-schema*.tgz dist package api-docs",
12
- "prepublishOnly": "npm run build && npm run build:apidocs",
24
+ "build": "lb-tsc",
25
+ "clean": "lb-clean loopback-json-schema*.tgz dist *.tsbuildinfo package",
13
26
  "pretest": "npm run build",
14
- "test": "lb-mocha \"DIST/test/unit/**/*.js\" \"DIST/test/integration/**/*.js\" \"DIST/test/acceptance/**/*.js\"",
27
+ "test": "lb-mocha \"dist/__tests__/**/*.js\"",
15
28
  "verify": "npm pack && tar xf loopback-json-schema*.tgz && tree package && npm run clean"
16
29
  },
17
- "author": "IBM",
18
- "license": "MIT",
19
- "keywords": [
20
- "LoopBack",
21
- "TypeScript",
22
- "JSON Schema"
23
- ],
24
30
  "publishConfig": {
25
31
  "access": "public"
26
32
  },
33
+ "files": [
34
+ "README.md",
35
+ "dist",
36
+ "src",
37
+ "!*/__tests__"
38
+ ],
39
+ "peerDependencies": {
40
+ "@loopback/core": "^2.18.0",
41
+ "@loopback/repository": "^3.7.3"
42
+ },
27
43
  "dependencies": {
28
- "@loopback/context": "^4.0.0-alpha.31",
29
- "@loopback/repository": "^4.0.0-alpha.29",
30
- "lodash": "^4.17.4",
31
- "typescript-json-schema": "^0.20.0"
44
+ "@types/json-schema": "^7.0.9",
45
+ "debug": "^4.3.2",
46
+ "tslib": "^2.3.1"
32
47
  },
33
48
  "devDependencies": {
34
- "@loopback/build": "^4.0.0-alpha.13",
35
- "@loopback/testlab": "^4.0.0-alpha.24",
36
- "@types/lodash": "^4.14.96"
49
+ "@loopback/build": "^7.0.2",
50
+ "@loopback/core": "^2.18.0",
51
+ "@loopback/eslint-config": "^11.0.2",
52
+ "@loopback/repository": "^3.7.3",
53
+ "@loopback/testlab": "^3.4.4",
54
+ "@types/debug": "^4.1.7",
55
+ "@types/node": "^10.17.60",
56
+ "ajv-formats": "^2.1.1"
37
57
  },
38
- "files": [
39
- "README.md",
40
- "index.js",
41
- "index.d.ts",
42
- "dist/src",
43
- "api-docs",
44
- "src"
45
- ],
46
- "repository": {
47
- "type": "git",
48
- "url": "https://github.com/strongloop/loopback-next.git"
49
- }
58
+ "gitHead": "d9a29c85dbe38f12ba219d8c495cf6038bbc3590"
50
59
  }