@trayio/tray-schema 0.34.0 → 1.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/dist/schema/TJSTraySchemaGenerator.d.ts +9 -0
- package/dist/schema/TJSTraySchemaGenerator.d.ts.map +1 -0
- package/dist/schema/{TJSTraySchemaTypeTransformer.js → TJSTraySchemaGenerator.js} +25 -6
- package/dist/schema/TJSTraySchemaGenerator.unit.test.d.ts +2 -0
- package/dist/schema/TJSTraySchemaGenerator.unit.test.d.ts.map +1 -0
- package/dist/schema/{TJSTraySchemaTypeTransformer.test.js → TJSTraySchemaGenerator.unit.test.js} +88 -15
- package/dist/schema/TraySchemaGenerator.d.ts +6 -0
- package/dist/schema/TraySchemaGenerator.d.ts.map +1 -0
- package/dist/schema/advanced.test.data.d.ts +14 -0
- package/dist/schema/advanced.test.data.d.ts.map +1 -0
- package/dist/schema/advanced.test.data.js +2 -0
- package/dist/schema/dataTypes.test.data.d.ts +1 -1
- package/dist/schema/dataTypes.test.data.d.ts.map +1 -1
- package/dist/schema/ddl.test.data.d.ts +1 -1
- package/dist/schema/ddl.test.data.d.ts.map +1 -1
- package/dist/schema/default.test.data.d.ts +1 -1
- package/dist/schema/default.test.data.d.ts.map +1 -1
- package/dist/schema/enum.test.data.d.ts +2 -2
- package/dist/schema/enum.test.data.d.ts.map +1 -1
- package/dist/schema/format.test.data.d.ts +1 -1
- package/dist/schema/format.test.data.d.ts.map +1 -1
- package/dist/schema/importsReusable.test.data.d.ts +2 -2
- package/dist/schema/importsReusable.test.data.d.ts.map +1 -1
- package/dist/schema/oneOf.test.data.d.ts +7 -7
- package/dist/schema/oneOf.test.data.d.ts.map +1 -1
- package/dist/schema/required.test.data.d.ts +1 -1
- package/dist/schema/required.test.data.d.ts.map +1 -1
- package/dist/schema/reusableField.test.data.d.ts +1 -1
- package/dist/schema/reusableField.test.data.d.ts.map +1 -1
- package/dist/schema/reusableSchema.test.data.d.ts +1 -1
- package/dist/schema/reusableSchema.test.data.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/schema/TJSTraySchemaTypeTransformer.d.ts +0 -9
- package/dist/schema/TJSTraySchemaTypeTransformer.d.ts.map +0 -1
- package/dist/schema/TJSTraySchemaTypeTransformer.test.d.ts +0 -2
- package/dist/schema/TJSTraySchemaTypeTransformer.test.d.ts.map +0 -1
- package/dist/schema/TraySchemaTypeTransformer.d.ts +0 -6
- package/dist/schema/TraySchemaTypeTransformer.d.ts.map +0 -1
- /package/dist/schema/{TraySchemaTypeTransformer.js → TraySchemaGenerator.js} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as TJS from 'typescript-json-schema';
|
|
2
|
+
import { Either } from 'fp-ts/Either';
|
|
3
|
+
import { DynamicObject } from '@trayio/commons/dynamictype/DynamicType';
|
|
4
|
+
import { TraySchemaGenerator } from './TraySchemaGenerator';
|
|
5
|
+
export declare class TJSTraySchemaGenerator implements TraySchemaGenerator {
|
|
6
|
+
generateFromType(type: string, path: string): Either<Error, DynamicObject>;
|
|
7
|
+
jsonSchemaToTraySchema(schema: TJS.Definition): TJS.Definition;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=TJSTraySchemaGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TJSTraySchemaGenerator.d.ts","sourceRoot":"","sources":["../../src/schema/TJSTraySchemaGenerator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAe,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,qBAAa,sBAAuB,YAAW,mBAAmB;IACjE,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC;IAgC1E,sBAAsB,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU;CAqG9D"}
|
|
@@ -23,20 +23,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.TJSTraySchemaGenerator = void 0;
|
|
27
27
|
const path_1 = require("path");
|
|
28
28
|
const TJS = __importStar(require("typescript-json-schema"));
|
|
29
29
|
const Either_1 = require("fp-ts/Either");
|
|
30
30
|
const lodash_1 = require("lodash");
|
|
31
|
-
class
|
|
32
|
-
|
|
31
|
+
class TJSTraySchemaGenerator {
|
|
32
|
+
generateFromType(type, path) {
|
|
33
33
|
const settings = {
|
|
34
34
|
// this will prevent creating references in the schema when references are used in the types
|
|
35
35
|
ref: false,
|
|
36
36
|
// adds support for DDLs and more in the JSdoc annotations
|
|
37
|
-
validationKeywords: [
|
|
37
|
+
validationKeywords: [
|
|
38
|
+
'lookupInput',
|
|
39
|
+
'lookupOperation',
|
|
40
|
+
'enumLabels',
|
|
41
|
+
'advanced',
|
|
42
|
+
],
|
|
38
43
|
// adds a required array to every entitiy in the schema which describes which children are required
|
|
39
44
|
required: true,
|
|
45
|
+
// adds "additionalProperties: false" to the schemas
|
|
46
|
+
noExtraProps: true,
|
|
40
47
|
};
|
|
41
48
|
const compilerOptions = {
|
|
42
49
|
strictNullChecks: true,
|
|
@@ -117,9 +124,21 @@ class TJSTraySchemaTypeTransformer {
|
|
|
117
124
|
delete object.allOf;
|
|
118
125
|
}
|
|
119
126
|
};
|
|
127
|
+
const transformAdvanced = (object) => {
|
|
128
|
+
if (Object.prototype.hasOwnProperty.call(object, 'properties') &&
|
|
129
|
+
object.properties !== null) {
|
|
130
|
+
object.advanced = [];
|
|
131
|
+
for (const [key, value] of Object.entries(object.properties)) {
|
|
132
|
+
if (value.advanced === true) {
|
|
133
|
+
object.advanced.push(key);
|
|
134
|
+
}
|
|
135
|
+
delete value.advanced;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
120
139
|
const recursiveObjectSearch = (object) => {
|
|
121
140
|
transformAllOf(object);
|
|
122
|
-
|
|
141
|
+
transformAdvanced(object);
|
|
123
142
|
for (const [key, value] of Object.entries(object)) {
|
|
124
143
|
if (typeof value === 'object' && value !== null) {
|
|
125
144
|
transformLookup(value);
|
|
@@ -133,4 +152,4 @@ class TJSTraySchemaTypeTransformer {
|
|
|
133
152
|
return schema;
|
|
134
153
|
}
|
|
135
154
|
}
|
|
136
|
-
exports.
|
|
155
|
+
exports.TJSTraySchemaGenerator = TJSTraySchemaGenerator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TJSTraySchemaGenerator.unit.test.d.ts","sourceRoot":"","sources":["../../src/schema/TJSTraySchemaGenerator.unit.test.ts"],"names":[],"mappings":""}
|
package/dist/schema/{TJSTraySchemaTypeTransformer.test.js → TJSTraySchemaGenerator.unit.test.js}
RENAMED
|
@@ -25,13 +25,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const E = __importStar(require("fp-ts/Either"));
|
|
27
27
|
const path_1 = require("path");
|
|
28
|
-
const
|
|
29
|
-
describe('
|
|
28
|
+
const TJSTraySchemaGenerator_1 = require("./TJSTraySchemaGenerator");
|
|
29
|
+
describe('TJSTraySchemaGenerator', () => {
|
|
30
30
|
it('Generates data types', () => {
|
|
31
31
|
const type = 'Input';
|
|
32
32
|
const dirPath = __dirname;
|
|
33
|
-
const path = (0, path_1.join)(dirPath, '
|
|
34
|
-
const result = new
|
|
33
|
+
const path = (0, path_1.join)(dirPath, 'dataTypes.test.data.ts');
|
|
34
|
+
const result = new TJSTraySchemaGenerator_1.TJSTraySchemaGenerator().generateFromType(type, path);
|
|
35
35
|
const actual = E.getOrElse((error) => {
|
|
36
36
|
console.warn(error);
|
|
37
37
|
throw new Error(`Failed to generate JSON schema from type`);
|
|
@@ -43,13 +43,25 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
43
43
|
num: { type: 'number' },
|
|
44
44
|
int: { type: 'integer' },
|
|
45
45
|
bool: { type: 'boolean' },
|
|
46
|
-
obj: {
|
|
46
|
+
obj: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {},
|
|
49
|
+
advanced: [],
|
|
50
|
+
additionalProperties: true,
|
|
51
|
+
},
|
|
47
52
|
arr: {
|
|
48
53
|
type: 'array',
|
|
49
|
-
items: {
|
|
54
|
+
items: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: {},
|
|
57
|
+
advanced: [],
|
|
58
|
+
additionalProperties: true,
|
|
59
|
+
},
|
|
50
60
|
},
|
|
51
61
|
},
|
|
62
|
+
advanced: [],
|
|
52
63
|
required: ['arr', 'bool', 'int', 'num', 'obj', 'str'],
|
|
64
|
+
additionalProperties: false,
|
|
53
65
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
54
66
|
};
|
|
55
67
|
expect(actual).toEqual(expected);
|
|
@@ -58,7 +70,7 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
58
70
|
const type = 'Input';
|
|
59
71
|
const dirPath = __dirname;
|
|
60
72
|
const path = (0, path_1.join)(dirPath, 'importsReusable.test.data.ts');
|
|
61
|
-
const result = new
|
|
73
|
+
const result = new TJSTraySchemaGenerator_1.TJSTraySchemaGenerator().generateFromType(type, path);
|
|
62
74
|
const actual = E.getOrElse((error) => {
|
|
63
75
|
console.warn(error);
|
|
64
76
|
throw new Error(`Failed to generate JSON schema from type`);
|
|
@@ -73,17 +85,21 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
73
85
|
reusableFieldA: { type: 'number' },
|
|
74
86
|
reusableFieldB: { type: 'string' },
|
|
75
87
|
},
|
|
88
|
+
advanced: [],
|
|
76
89
|
required: ['reusableFieldA', 'reusableFieldB'],
|
|
90
|
+
additionalProperties: false,
|
|
77
91
|
},
|
|
78
92
|
reusableSchemaA: { type: 'number' },
|
|
79
93
|
reusableSchemaB: { type: 'string' },
|
|
80
94
|
},
|
|
95
|
+
advanced: [],
|
|
81
96
|
required: [
|
|
82
97
|
'reusableFields',
|
|
83
|
-
'specificField',
|
|
84
98
|
'reusableSchemaA',
|
|
85
99
|
'reusableSchemaB',
|
|
100
|
+
'specificField',
|
|
86
101
|
],
|
|
102
|
+
additionalProperties: false,
|
|
87
103
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
88
104
|
};
|
|
89
105
|
expect(actual).toEqual(expected);
|
|
@@ -92,7 +108,7 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
92
108
|
const type = 'Input';
|
|
93
109
|
const dirPath = __dirname;
|
|
94
110
|
const path = (0, path_1.join)(dirPath, 'oneOf.test.data.ts');
|
|
95
|
-
const result = new
|
|
111
|
+
const result = new TJSTraySchemaGenerator_1.TJSTraySchemaGenerator().generateFromType(type, path);
|
|
96
112
|
const actual = E.getOrElse((error) => {
|
|
97
113
|
console.warn(error);
|
|
98
114
|
throw new Error(`Failed to generate JSON schema from type`);
|
|
@@ -117,17 +133,23 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
117
133
|
path: { type: 'string' },
|
|
118
134
|
metadata: { type: 'string' },
|
|
119
135
|
},
|
|
136
|
+
advanced: [],
|
|
120
137
|
required: ['metadata', 'path'],
|
|
138
|
+
additionalProperties: false,
|
|
121
139
|
},
|
|
122
140
|
{
|
|
123
141
|
type: 'object',
|
|
124
142
|
properties: { imgId: { type: 'number' } },
|
|
143
|
+
advanced: [],
|
|
125
144
|
required: ['imgId'],
|
|
145
|
+
additionalProperties: false,
|
|
126
146
|
},
|
|
127
147
|
],
|
|
128
148
|
},
|
|
129
149
|
},
|
|
150
|
+
advanced: [],
|
|
130
151
|
required: ['src'],
|
|
152
|
+
additionalProperties: false,
|
|
131
153
|
},
|
|
132
154
|
{
|
|
133
155
|
type: 'object',
|
|
@@ -138,13 +160,17 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
138
160
|
type: 'string',
|
|
139
161
|
},
|
|
140
162
|
},
|
|
163
|
+
advanced: [],
|
|
141
164
|
required: ['msg'],
|
|
165
|
+
additionalProperties: false,
|
|
142
166
|
},
|
|
143
167
|
],
|
|
144
168
|
},
|
|
145
169
|
},
|
|
146
170
|
},
|
|
171
|
+
advanced: [],
|
|
147
172
|
required: ['elements'],
|
|
173
|
+
additionalProperties: false,
|
|
148
174
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
149
175
|
};
|
|
150
176
|
expect(actual).toEqual(expected);
|
|
@@ -153,7 +179,7 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
153
179
|
const type = 'Input';
|
|
154
180
|
const dirPath = __dirname;
|
|
155
181
|
const path = (0, path_1.join)(dirPath, 'enum.test.data.ts');
|
|
156
|
-
const result = new
|
|
182
|
+
const result = new TJSTraySchemaGenerator_1.TJSTraySchemaGenerator().generateFromType(type, path);
|
|
157
183
|
const actual = E.getOrElse((error) => {
|
|
158
184
|
console.warn(error);
|
|
159
185
|
throw new Error(`Failed to generate JSON schema from type`);
|
|
@@ -174,11 +200,15 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
174
200
|
type: 'string',
|
|
175
201
|
},
|
|
176
202
|
},
|
|
203
|
+
advanced: [],
|
|
177
204
|
required: ['text', 'type'],
|
|
205
|
+
additionalProperties: false,
|
|
178
206
|
},
|
|
179
207
|
},
|
|
180
208
|
},
|
|
209
|
+
advanced: [],
|
|
181
210
|
required: ['actions'],
|
|
211
|
+
additionalProperties: false,
|
|
182
212
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
183
213
|
};
|
|
184
214
|
expect(actual).toEqual(expected);
|
|
@@ -187,7 +217,7 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
187
217
|
const type = 'Input';
|
|
188
218
|
const dirPath = __dirname;
|
|
189
219
|
const path = (0, path_1.join)(dirPath, 'ddl.test.data.ts');
|
|
190
|
-
const result = new
|
|
220
|
+
const result = new TJSTraySchemaGenerator_1.TJSTraySchemaGenerator().generateFromType(type, path);
|
|
191
221
|
const actual = E.getOrElse((error) => {
|
|
192
222
|
console.warn(error);
|
|
193
223
|
throw new Error(`Failed to generate JSON schema from type`);
|
|
@@ -206,7 +236,9 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
206
236
|
},
|
|
207
237
|
},
|
|
208
238
|
},
|
|
239
|
+
advanced: [],
|
|
209
240
|
required: ['emails'],
|
|
241
|
+
additionalProperties: false,
|
|
210
242
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
211
243
|
};
|
|
212
244
|
expect(actual).toEqual(expected);
|
|
@@ -215,7 +247,7 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
215
247
|
const type = 'Input';
|
|
216
248
|
const dirPath = __dirname;
|
|
217
249
|
const path = (0, path_1.join)(dirPath, 'required.test.data.ts');
|
|
218
|
-
const result = new
|
|
250
|
+
const result = new TJSTraySchemaGenerator_1.TJSTraySchemaGenerator().generateFromType(type, path);
|
|
219
251
|
const actual = E.getOrElse((error) => {
|
|
220
252
|
console.warn(error);
|
|
221
253
|
throw new Error(`Failed to generate JSON schema from type`);
|
|
@@ -226,7 +258,9 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
226
258
|
mandatoryField: { type: 'string' },
|
|
227
259
|
optionalField: { type: 'string' },
|
|
228
260
|
},
|
|
261
|
+
advanced: [],
|
|
229
262
|
required: ['mandatoryField'],
|
|
263
|
+
additionalProperties: false,
|
|
230
264
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
231
265
|
};
|
|
232
266
|
expect(actual).toEqual(expected);
|
|
@@ -235,7 +269,7 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
235
269
|
const type = 'Input';
|
|
236
270
|
const dirPath = __dirname;
|
|
237
271
|
const path = (0, path_1.join)(dirPath, 'format.test.data.ts');
|
|
238
|
-
const result = new
|
|
272
|
+
const result = new TJSTraySchemaGenerator_1.TJSTraySchemaGenerator().generateFromType(type, path);
|
|
239
273
|
const actual = E.getOrElse((error) => {
|
|
240
274
|
console.warn(error);
|
|
241
275
|
throw new Error(`Failed to generate JSON schema from type`);
|
|
@@ -249,7 +283,9 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
249
283
|
password: { format: 'password', type: 'string' },
|
|
250
284
|
file: { format: 'file', type: 'string' },
|
|
251
285
|
},
|
|
286
|
+
advanced: [],
|
|
252
287
|
required: ['file', 'html', 'longNotes', 'password', 'timestamp'],
|
|
288
|
+
additionalProperties: false,
|
|
253
289
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
254
290
|
};
|
|
255
291
|
expect(actual).toEqual(expected);
|
|
@@ -258,7 +294,7 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
258
294
|
const type = 'Input';
|
|
259
295
|
const dirPath = __dirname;
|
|
260
296
|
const path = (0, path_1.join)(dirPath, 'default.test.data.ts');
|
|
261
|
-
const result = new
|
|
297
|
+
const result = new TJSTraySchemaGenerator_1.TJSTraySchemaGenerator().generateFromType(type, path);
|
|
262
298
|
const actual = E.getOrElse((error) => {
|
|
263
299
|
console.warn(error);
|
|
264
300
|
throw new Error(`Failed to generate JSON schema from type`);
|
|
@@ -274,15 +310,52 @@ describe('TJSTraySchemaTypeTransformer', () => {
|
|
|
274
310
|
default: { default: true },
|
|
275
311
|
type: 'object',
|
|
276
312
|
properties: {},
|
|
313
|
+
advanced: [],
|
|
277
314
|
additionalProperties: true,
|
|
278
315
|
},
|
|
279
316
|
arr: {
|
|
280
317
|
default: ['default'],
|
|
281
318
|
type: 'array',
|
|
282
|
-
items: {
|
|
319
|
+
items: {
|
|
320
|
+
type: 'object',
|
|
321
|
+
properties: {},
|
|
322
|
+
advanced: [],
|
|
323
|
+
additionalProperties: true,
|
|
324
|
+
},
|
|
283
325
|
},
|
|
284
326
|
},
|
|
327
|
+
advanced: [],
|
|
285
328
|
required: ['arr', 'bool', 'int', 'num', 'obj', 'str'],
|
|
329
|
+
additionalProperties: false,
|
|
330
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
331
|
+
};
|
|
332
|
+
expect(actual).toEqual(expected);
|
|
333
|
+
});
|
|
334
|
+
it('Generates advanced fields array', () => {
|
|
335
|
+
const type = 'Input';
|
|
336
|
+
const dirPath = __dirname;
|
|
337
|
+
const path = (0, path_1.join)(dirPath, 'advanced.test.data.ts');
|
|
338
|
+
const result = new TJSTraySchemaGenerator_1.TJSTraySchemaGenerator().generateFromType(type, path);
|
|
339
|
+
const actual = E.getOrElse((error) => {
|
|
340
|
+
console.warn(error);
|
|
341
|
+
throw new Error(`Failed to generate JSON schema from type`);
|
|
342
|
+
})(result);
|
|
343
|
+
const expected = {
|
|
344
|
+
type: 'object',
|
|
345
|
+
properties: {
|
|
346
|
+
advancedField: { type: 'string' },
|
|
347
|
+
normalField: {
|
|
348
|
+
type: 'object',
|
|
349
|
+
properties: {
|
|
350
|
+
normalField: { type: 'string' },
|
|
351
|
+
advancedField: { type: 'string' },
|
|
352
|
+
},
|
|
353
|
+
advanced: ['advancedField'],
|
|
354
|
+
additionalProperties: false,
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
advanced: ['advancedField'],
|
|
358
|
+
additionalProperties: false,
|
|
286
359
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
287
360
|
};
|
|
288
361
|
expect(actual).toEqual(expected);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Either } from 'fp-ts/lib/Either';
|
|
2
|
+
import { DynamicObject } from '@trayio/commons/dynamictype/DynamicType';
|
|
3
|
+
export interface TraySchemaGenerator {
|
|
4
|
+
generateFromType(type: string, path: string): Either<Error, DynamicObject>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=TraySchemaGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TraySchemaGenerator.d.ts","sourceRoot":"","sources":["../../src/schema/TraySchemaGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,MAAM,WAAW,mBAAmB;IACnC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;CAC3E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/advanced.test.data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE;QACb;;WAEG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataTypes.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/dataTypes.test.data.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"dataTypes.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/dataTypes.test.data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,EAAE,CAAC;CACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ddl.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/ddl.test.data.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"ddl.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/ddl.test.data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IACnB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/default.test.data.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"default.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/default.test.data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IACnB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,EAAE,CAAC;CACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/enum.test.data.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"enum.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/enum.test.data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IACnB;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,KAAK,MAAM,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;CACjB,CAAC;AAEF,aAAK,UAAU;IACd,OAAO,mBAAmB;IAC1B,MAAM,eAAe;IACrB,OAAO,gBAAgB;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/format.test.data.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"format.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/format.test.data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IACnB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACb,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReusableField } from './reusableField.test.data';
|
|
2
2
|
import { ReusableSchema } from './reusableSchema.test.data';
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export type Input = SpecificSchema & ReusableSchema;
|
|
4
|
+
type SpecificSchema = {
|
|
5
5
|
specificField: string;
|
|
6
6
|
reusableFields: ReusableField;
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importsReusable.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/importsReusable.test.data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,
|
|
1
|
+
{"version":3,"file":"importsReusable.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/importsReusable.test.data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,MAAM,MAAM,KAAK,GAAG,cAAc,GAAG,cAAc,CAAC;AAEpD,KAAK,cAAc,GAAG;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,aAAa,CAAC;CAC9B,CAAC"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
type Src = {
|
|
2
2
|
path: string;
|
|
3
3
|
metadata: string;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
type Id = {
|
|
6
6
|
imgId: number;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
type SrcOrId = Src | Id;
|
|
9
|
+
type Image = {
|
|
10
10
|
src: SrcOrId;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
type Text = {
|
|
13
13
|
/**
|
|
14
14
|
* @title myText
|
|
15
15
|
* @description the text.
|
|
16
16
|
*/
|
|
17
17
|
msg: string;
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
export
|
|
19
|
+
type ImageOrText = Image | Text;
|
|
20
|
+
export type Input = {
|
|
21
21
|
/**
|
|
22
22
|
* @title Elements
|
|
23
23
|
* @description Add images or text to the context. Maximum number of items is 10.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oneOf.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/oneOf.test.data.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"oneOf.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/oneOf.test.data.ts"],"names":[],"mappings":"AAAA,KAAK,GAAG,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,EAAE,GAAG;IACT,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,OAAO,GAAG,GAAG,GAAG,EAAE,CAAC;AAExB,KAAK,KAAK,GAAG;IACZ,GAAG,EAAE,OAAO,CAAC;CACb,CAAC;AAEF,KAAK,IAAI,GAAG;IACX;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,KAAK,WAAW,GAAG,KAAK,GAAG,IAAI,CAAC;AAEhC,MAAM,MAAM,KAAK,GAAG;IACnB;;;OAGG;IACH,QAAQ,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"required.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/required.test.data.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"required.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/required.test.data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reusableField.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/reusableField.test.data.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"reusableField.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/reusableField.test.data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reusableSchema.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/reusableSchema.test.data.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"reusableSchema.test.data.d.ts","sourceRoot":"","sources":["../../src/schema/reusableSchema.test.data.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/tray-schema",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Schema for Tray connectors and authentications",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
7
7
|
},
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@trayio/
|
|
15
|
-
"@types/node": "18.
|
|
14
|
+
"@trayio/commons": "1.0.0",
|
|
15
|
+
"@types/node": "18.11.9",
|
|
16
16
|
"lodash": "4.17.5",
|
|
17
17
|
"typescript-json-schema": "0.61.0"
|
|
18
18
|
},
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as TJS from 'typescript-json-schema';
|
|
2
|
-
import { Either } from 'fp-ts/Either';
|
|
3
|
-
import { DynamicObject } from '@trayio/tray-commons/dynamictype/DynamicType';
|
|
4
|
-
import { TraySchemaTypeTransformer } from './TraySchemaTypeTransformer';
|
|
5
|
-
export declare class TJSTraySchemaTypeTransformer implements TraySchemaTypeTransformer {
|
|
6
|
-
generateFromTypes(type: string, path: string): Either<Error, DynamicObject>;
|
|
7
|
-
jsonSchemaToTraySchema(schema: TJS.Definition): TJS.Definition;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=TJSTraySchemaTypeTransformer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TJSTraySchemaTypeTransformer.d.ts","sourceRoot":"","sources":["../../src/schema/TJSTraySchemaTypeTransformer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAe,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,qBAAa,4BAA6B,YAAW,yBAAyB;IAC7E,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC;IAyB3E,sBAAsB,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU;CAsF9D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TJSTraySchemaTypeTransformer.test.d.ts","sourceRoot":"","sources":["../../src/schema/TJSTraySchemaTypeTransformer.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Either } from 'fp-ts/lib/Either';
|
|
2
|
-
import { DynamicObject } from '@trayio/tray-commons/dynamictype/DynamicType';
|
|
3
|
-
export interface TraySchemaTypeTransformer {
|
|
4
|
-
generateFromTypes(type: string, path: string): Either<Error, DynamicObject>;
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=TraySchemaTypeTransformer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TraySchemaTypeTransformer.d.ts","sourceRoot":"","sources":["../../src/schema/TraySchemaTypeTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAE7E,MAAM,WAAW,yBAAyB;IACzC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;CAC5E"}
|
|
File without changes
|