@oak-digital/types-4-strapi-2 0.5.3 → 0.5.5

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 (55) hide show
  1. package/README.md +4 -3
  2. package/lib/content-types/reader.d.ts +2 -2
  3. package/lib/content-types/reader.js +7 -7
  4. package/lib/events/index.d.ts +6 -1
  5. package/lib/events/index.js +5 -0
  6. package/lib/interface/Interface.js +5 -0
  7. package/lib/plugins/PluginManager.d.ts +8 -4
  8. package/lib/plugins/PluginManager.js +11 -6
  9. package/lib/plugins/draft-and-publish/index.d.ts +3 -0
  10. package/lib/plugins/draft-and-publish/index.js +36 -0
  11. package/lib/plugins/i18n/index.d.ts +3 -0
  12. package/lib/plugins/i18n/index.js +41 -0
  13. package/lib/plugins/index.js +7 -0
  14. package/lib/plugins/types.d.ts +3 -1
  15. package/lib/plugins/types.js +1 -0
  16. package/lib/plugins/url-alias/index.d.ts +2 -2
  17. package/lib/plugins/url-alias/index.js +14 -1
  18. package/lib/plugins/url-alias/type.d.ts +8 -0
  19. package/lib/plugins/url-alias/type.js +41 -0
  20. package/lib/program/InterfaceManager.d.ts +4 -2
  21. package/lib/program/InterfaceManager.js +34 -17
  22. package/package.json +9 -8
  23. package/lib/.prettierrc.json +0 -7
  24. package/lib/case/index.d.ts +0 -4
  25. package/lib/case/index.js +0 -47
  26. package/lib/interface/Attributes.d.ts +0 -11
  27. package/lib/interface/Attributes.js +0 -167
  28. package/lib/interface/InterfaceManager.d.ts +0 -39
  29. package/lib/interface/InterfaceManager.js +0 -396
  30. package/lib/interface/interfaceCreator.d.ts +0 -0
  31. package/lib/interface/interfaceCreator.js +0 -7
  32. package/lib/interface/interfaceWriter.d.ts +0 -2
  33. package/lib/interface/interfaceWriter.js +0 -46
  34. package/lib/interface/schemaReader.d.ts +0 -14
  35. package/lib/interface/schemaReader.js +0 -177
  36. package/lib/src/index.d.ts +0 -1
  37. package/lib/src/index.js +0 -25
  38. package/lib/src/interface/Attributes.d.ts +0 -11
  39. package/lib/src/interface/Attributes.js +0 -148
  40. package/lib/src/interface/BuiltinComponentInterface.d.ts +0 -5
  41. package/lib/src/interface/BuiltinComponentInterface.js +0 -36
  42. package/lib/src/interface/BuiltinInterface.d.ts +0 -5
  43. package/lib/src/interface/BuiltinInterface.js +0 -33
  44. package/lib/src/interface/ComponentInterface.d.ts +0 -8
  45. package/lib/src/interface/ComponentInterface.js +0 -58
  46. package/lib/src/interface/Interface.d.ts +0 -31
  47. package/lib/src/interface/Interface.js +0 -112
  48. package/lib/src/interface/InterfaceManager.d.ts +0 -25
  49. package/lib/src/interface/InterfaceManager.js +0 -288
  50. package/lib/src/interface/builtinInterfaces.d.ts +0 -4
  51. package/lib/src/interface/builtinInterfaces.js +0 -81
  52. package/lib/src/interface/schemaReader.d.ts +0 -14
  53. package/lib/src/interface/schemaReader.js +0 -172
  54. package/lib/src/utils/index.d.ts +0 -3
  55. package/lib/src/utils/index.js +0 -67
@@ -1,112 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var path_1 = require("path");
7
- var utils_1 = require("../utils");
8
- var Attributes_1 = __importDefault(require("./Attributes"));
9
- var Interface = /** @class */ (function () {
10
- function Interface(baseName, attributes, relativeDirectoryPath, prefix) {
11
- if (prefix === void 0) { prefix = ''; }
12
- this.Relations = []; // Components and relations
13
- this.RelationNames = {};
14
- this.RelationNamesCounter = {};
15
- this.NamePrefix = '';
16
- this.BaseName = baseName;
17
- this.updateStrapiName();
18
- this.NamePrefix = prefix;
19
- this.Attributes = attributes;
20
- this.RelativeDirectoryPath = relativeDirectoryPath;
21
- }
22
- Interface.prototype.updateStrapiName = function () {
23
- this.StrapiName = "api::".concat(this.BaseName, ".").concat(this.BaseName);
24
- };
25
- Interface.prototype.getBaseName = function () {
26
- return this.BaseName;
27
- };
28
- Interface.prototype.getStrapiName = function () {
29
- return this.StrapiName;
30
- };
31
- Interface.prototype.getDependencies = function () {
32
- var attrs = new Attributes_1.default(this.Attributes, this.RelationNames);
33
- return attrs.getDependencies();
34
- };
35
- Interface.prototype.getFullInterfaceName = function () {
36
- var pascalName = (0, utils_1.pascalCase)(this.BaseName);
37
- return "".concat(this.NamePrefix).concat(pascalName);
38
- };
39
- // For typescript import from index file
40
- Interface.prototype.getRelativeRootPath = function () {
41
- var path = (0, path_1.join)(this.RelativeDirectoryPath, this.getBaseName());
42
- return (0, utils_1.prefixDotSlash)(path);
43
- };
44
- Interface.prototype.getRelativeRootDir = function () {
45
- var path = (0, path_1.dirname)(this.getRelativeRootPathFile());
46
- return path;
47
- };
48
- Interface.prototype.getRelativeRootPathFile = function () {
49
- return "".concat(this.getRelativeRootPath(), ".ts");
50
- };
51
- Interface.prototype.setRelations = function (relations) {
52
- var _this = this;
53
- this.Relations = relations;
54
- this.RelationNames = {};
55
- this.Relations.forEach(function (inter) {
56
- var name = inter.getFullInterfaceName();
57
- // FIXME: clean up this mess...
58
- if (inter.getStrapiName() !== _this.getStrapiName()) {
59
- // Avoid duplicate names
60
- if (name in _this.RelationNamesCounter) {
61
- name += ++_this.RelationNamesCounter[name];
62
- }
63
- else {
64
- _this.RelationNamesCounter[name] = 0;
65
- }
66
- }
67
- _this.RelationNames[inter.getStrapiName()] = { name: name, inter: inter };
68
- });
69
- };
70
- Interface.prototype.getTsImports = function () {
71
- var _this = this;
72
- return Object.keys(this.RelationNames).map(function (strapiName) {
73
- if (strapiName === _this.getStrapiName()) {
74
- return '';
75
- }
76
- var relationName = _this.RelationNames[strapiName].name;
77
- var inter = _this.RelationNames[strapiName].inter;
78
- var importPath = (0, utils_1.prefixDotSlash)((0, path_1.relative)(_this.getRelativeRootDir(), inter.getRelativeRootPath()));
79
- var fullName = inter.getFullInterfaceName();
80
- var importNameString = fullName === relationName ? fullName : "".concat(fullName, " as ").concat(relationName);
81
- return "import { ".concat(importNameString, " } from '").concat(importPath, "';");
82
- }).filter(function (s) { return s; }).join('\n');
83
- };
84
- Interface.prototype.getAttributes = function () {
85
- return new Attributes_1.default(this.Attributes, this.RelationNames);
86
- };
87
- Interface.prototype.attributesToString = function () {
88
- var attrs = this.getAttributes();
89
- return attrs.toString();
90
- };
91
- Interface.prototype.getInerfaceString = function () {
92
- var str = "export interface ".concat(this.getFullInterfaceName(), " {\n");
93
- str += this.getInterfaceFieldsString();
94
- str += '}';
95
- return str;
96
- };
97
- Interface.prototype.getInterfaceFieldsString = function () {
98
- var str = '';
99
- str += 'id: number;\n';
100
- str += "attributes: ".concat(this.attributesToString(), "\n");
101
- return str;
102
- };
103
- Interface.prototype.toString = function () {
104
- var strings = [
105
- this.getTsImports(),
106
- this.getInerfaceString()
107
- ];
108
- return strings.join('\n');
109
- };
110
- return Interface;
111
- }());
112
- exports.default = Interface;
@@ -1,25 +0,0 @@
1
- export default class InterfaceManager {
2
- private Interfaces;
3
- private OutRoot;
4
- private StrapiSrcRoot;
5
- private Options;
6
- private PrettierOptions;
7
- static BaseOptions: {
8
- prefix: string;
9
- useCategoryPrefix: boolean;
10
- componentPrefix: string;
11
- componentPrefixOverridesPrefix: boolean;
12
- builtinsPrefix: string;
13
- builtinsPrefixOverridesPrefix: boolean;
14
- prettierFile: any;
15
- };
16
- constructor(outRoot: string, strapiSrcRoot: string, options?: any);
17
- loadPrettierConfig(): Promise<void>;
18
- createInterfaces(): Promise<void>;
19
- createBuiltinInterfaces(): void;
20
- injectDependencies(): void;
21
- makeFolders(): Promise<void>;
22
- writeInterfaces(): Promise<void>;
23
- writeIndexFile(): Promise<void>;
24
- run(): Promise<void>;
25
- }
@@ -1,288 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- var fs_1 = require("fs");
43
- var promises_1 = require("fs/promises");
44
- var path_1 = require("path");
45
- var utils_1 = require("../utils");
46
- var builtinInterfaces_1 = require("./builtinInterfaces");
47
- var ComponentInterface_1 = __importDefault(require("./ComponentInterface"));
48
- var Interface_1 = __importDefault(require("./Interface"));
49
- var schemaReader_1 = require("./schemaReader");
50
- var prettier_1 = __importDefault(require("prettier"));
51
- var _prettierrc_json_1 = __importDefault(require("../../.prettierrc.json"));
52
- var InterfaceManager = /** @class */ (function () {
53
- function InterfaceManager(outRoot, strapiSrcRoot, options) {
54
- if (options === void 0) { options = {}; }
55
- this.Interfaces = {}; // string = strapi name
56
- this.OutRoot = outRoot;
57
- this.StrapiSrcRoot = strapiSrcRoot;
58
- this.Options = Object.assign({}, InterfaceManager.BaseOptions, options);
59
- }
60
- InterfaceManager.prototype.loadPrettierConfig = function () {
61
- return __awaiter(this, void 0, void 0, function () {
62
- var defaultOptions, resolved;
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0:
66
- defaultOptions = _prettierrc_json_1.default;
67
- if (!this.Options.prettierFile) {
68
- this.PrettierOptions = defaultOptions;
69
- return [2 /*return*/];
70
- }
71
- return [4 /*yield*/, prettier_1.default.resolveConfig(this.Options.prettierFile)];
72
- case 1:
73
- resolved = _a.sent();
74
- this.PrettierOptions = Object.assign({}, defaultOptions, resolved);
75
- return [2 /*return*/];
76
- }
77
- });
78
- });
79
- };
80
- InterfaceManager.prototype.createInterfaces = function () {
81
- return __awaiter(this, void 0, void 0, function () {
82
- var apiSchemasPromise, componentSchemasPromise, apiSchemas, componentSchemas;
83
- var _this = this;
84
- return __generator(this, function (_a) {
85
- switch (_a.label) {
86
- case 0:
87
- apiSchemasPromise = (0, schemaReader_1.getApiSchemas)(this.StrapiSrcRoot);
88
- componentSchemasPromise = (0, schemaReader_1.getComponentSchemas)(this.StrapiSrcRoot);
89
- return [4 /*yield*/, apiSchemasPromise];
90
- case 1:
91
- apiSchemas = _a.sent();
92
- apiSchemas.forEach(function (schema) {
93
- var name = schema.name, attributes = schema.attributes;
94
- var strapiName = "api::".concat(name, ".").concat(name);
95
- var inter = new Interface_1.default(name, attributes, './', _this.Options.prefix);
96
- _this.Interfaces[strapiName] = inter;
97
- });
98
- return [4 /*yield*/, componentSchemasPromise];
99
- case 2:
100
- componentSchemas = _a.sent();
101
- componentSchemas.forEach(function (category) {
102
- var categoryName = category.category;
103
- category.schemas.forEach(function (schema) {
104
- var componentName = schema.name;
105
- var strapiName = "".concat(categoryName, ".").concat(schema.name);
106
- var componentPrefix = "".concat(_this.Options.componentPrefix).concat(_this.Options.useCategoryPrefix ? (0, utils_1.pascalCase)(categoryName) : '');
107
- var prefix = _this.Options.componentPrefixOverridesPrefix ? componentPrefix : _this.Options.prefix + componentPrefix;
108
- // TODO: make component interface
109
- var inter = new ComponentInterface_1.default(componentName, schema.attributes, "./".concat(categoryName), categoryName, prefix);
110
- _this.Interfaces[strapiName] = inter;
111
- });
112
- });
113
- return [2 /*return*/];
114
- }
115
- });
116
- });
117
- };
118
- InterfaceManager.prototype.createBuiltinInterfaces = function () {
119
- var _this = this;
120
- var outDir = './builtins';
121
- var builtinInterfaces = [];
122
- builtinInterfaces.push((0, builtinInterfaces_1.createMediaInterface)(outDir, this.Options.prefix));
123
- builtinInterfaces.push((0, builtinInterfaces_1.createMediaFormatInterface)(outDir, this.Options.prefix));
124
- builtinInterfaces.forEach(function (inter) {
125
- _this.Interfaces[inter.getStrapiName()] = inter;
126
- });
127
- };
128
- // Inject dependencies into all interfaces
129
- InterfaceManager.prototype.injectDependencies = function () {
130
- var _this = this;
131
- // console.log("Injecting dependencies")
132
- Object.keys(this.Interfaces).forEach(function (strapiName) {
133
- var inter = _this.Interfaces[strapiName];
134
- var dependencies = inter.getDependencies();
135
- // console.log(`Interfaces for ${inter.getStrapiName()} are`)
136
- var interfacesToInject = dependencies.map(function (dependencyStrapiName) {
137
- return _this.Interfaces[dependencyStrapiName];
138
- }).filter(function (inter) { return inter; });
139
- inter.setRelations(interfacesToInject);
140
- });
141
- };
142
- InterfaceManager.prototype.makeFolders = function () {
143
- return __awaiter(this, void 0, void 0, function () {
144
- var componentCategories, promises, componentCategoriesPromises, builtinsPath;
145
- var _this = this;
146
- return __generator(this, function (_a) {
147
- switch (_a.label) {
148
- case 0: return [4 /*yield*/, (0, schemaReader_1.getComponentCategoryFolders)(this.StrapiSrcRoot)];
149
- case 1:
150
- componentCategories = _a.sent();
151
- if (!!(0, fs_1.existsSync)(this.OutRoot)) return [3 /*break*/, 3];
152
- return [4 /*yield*/, (0, promises_1.mkdir)(this.OutRoot, {
153
- recursive: true,
154
- })];
155
- case 2:
156
- _a.sent();
157
- _a.label = 3;
158
- case 3:
159
- promises = [];
160
- componentCategoriesPromises = componentCategories.map(function (category) { return __awaiter(_this, void 0, void 0, function () {
161
- var path;
162
- return __generator(this, function (_a) {
163
- switch (_a.label) {
164
- case 0:
165
- path = (0, path_1.join)(this.OutRoot, category);
166
- if ((0, fs_1.existsSync)(path)) {
167
- return [2 /*return*/];
168
- }
169
- return [4 /*yield*/, (0, promises_1.mkdir)(path)];
170
- case 1:
171
- _a.sent();
172
- return [2 /*return*/];
173
- }
174
- });
175
- }); });
176
- promises.push.apply(promises, componentCategoriesPromises);
177
- builtinsPath = (0, path_1.join)(this.OutRoot, 'builtins');
178
- if (!(0, fs_1.existsSync)(builtinsPath)) {
179
- promises.push((0, promises_1.mkdir)((0, path_1.join)(this.OutRoot, 'builtins')));
180
- }
181
- return [4 /*yield*/, Promise.all(promises)];
182
- case 4:
183
- _a.sent();
184
- return [2 /*return*/];
185
- }
186
- });
187
- });
188
- };
189
- InterfaceManager.prototype.writeInterfaces = function () {
190
- return __awaiter(this, void 0, void 0, function () {
191
- var writePromises;
192
- var _this = this;
193
- return __generator(this, function (_a) {
194
- switch (_a.label) {
195
- case 0:
196
- writePromises = Object.keys(this.Interfaces).map(function (strapiName) { return __awaiter(_this, void 0, void 0, function () {
197
- var inter, fileData, formattedFileData, filePath;
198
- return __generator(this, function (_a) {
199
- switch (_a.label) {
200
- case 0:
201
- inter = this.Interfaces[strapiName];
202
- fileData = inter.toString();
203
- formattedFileData = prettier_1.default.format(fileData, this.PrettierOptions);
204
- filePath = (0, path_1.join)(this.OutRoot, inter.getRelativeRootPathFile());
205
- return [4 /*yield*/, (0, promises_1.writeFile)(filePath, formattedFileData)];
206
- case 1:
207
- _a.sent();
208
- return [2 /*return*/];
209
- }
210
- });
211
- }); });
212
- return [4 /*yield*/, Promise.all(writePromises)];
213
- case 1:
214
- _a.sent();
215
- return [2 /*return*/];
216
- }
217
- });
218
- });
219
- };
220
- InterfaceManager.prototype.writeIndexFile = function () {
221
- return __awaiter(this, void 0, void 0, function () {
222
- var strings, fileData, formattedFileData, filePath;
223
- var _this = this;
224
- return __generator(this, function (_a) {
225
- switch (_a.label) {
226
- case 0:
227
- strings = Object.keys(this.Interfaces).map(function (strapiName) {
228
- var inter = _this.Interfaces[strapiName];
229
- return "export * from '".concat(inter.getRelativeRootPath(), "'");
230
- });
231
- fileData = strings.join('\n');
232
- formattedFileData = prettier_1.default.format(fileData, this.PrettierOptions);
233
- filePath = (0, path_1.join)(this.OutRoot, 'index.ts');
234
- return [4 /*yield*/, (0, promises_1.writeFile)(filePath, formattedFileData)];
235
- case 1:
236
- _a.sent();
237
- return [2 /*return*/];
238
- }
239
- });
240
- });
241
- };
242
- InterfaceManager.prototype.run = function () {
243
- return __awaiter(this, void 0, void 0, function () {
244
- var createInterfacesPromise, makeFoldersPromise, loadPrettierPromise, err_1;
245
- return __generator(this, function (_a) {
246
- switch (_a.label) {
247
- case 0:
248
- _a.trys.push([0, 5, , 6]);
249
- createInterfacesPromise = this.createInterfaces();
250
- makeFoldersPromise = this.makeFolders();
251
- loadPrettierPromise = this.loadPrettierConfig();
252
- return [4 /*yield*/, loadPrettierPromise];
253
- case 1:
254
- _a.sent();
255
- this.createBuiltinInterfaces();
256
- return [4 /*yield*/, createInterfacesPromise];
257
- case 2:
258
- _a.sent();
259
- // Create all interfaces before injecting
260
- this.injectDependencies();
261
- return [4 /*yield*/, Promise.all([makeFoldersPromise,])];
262
- case 3:
263
- _a.sent();
264
- return [4 /*yield*/, Promise.all([this.writeInterfaces(), this.writeIndexFile()])];
265
- case 4:
266
- _a.sent();
267
- return [3 /*break*/, 6];
268
- case 5:
269
- err_1 = _a.sent();
270
- console.error(err_1);
271
- return [3 /*break*/, 6];
272
- case 6: return [2 /*return*/];
273
- }
274
- });
275
- });
276
- };
277
- InterfaceManager.BaseOptions = {
278
- prefix: 'I',
279
- useCategoryPrefix: true,
280
- componentPrefix: '',
281
- componentPrefixOverridesPrefix: false,
282
- builtinsPrefix: '',
283
- builtinsPrefixOverridesPrefix: false,
284
- prettierFile: null,
285
- };
286
- return InterfaceManager;
287
- }());
288
- exports.default = InterfaceManager;
@@ -1,4 +0,0 @@
1
- import BuiltinComponentInterface from './BuiltinComponentInterface';
2
- import BuiltinInterface from './BuiltinInterface';
3
- export declare function createMediaInterface(directory: string, prefix: string): BuiltinInterface;
4
- export declare function createMediaFormatInterface(directory: string, prefix: string): BuiltinComponentInterface;
@@ -1,81 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createMediaFormatInterface = exports.createMediaInterface = void 0;
7
- var BuiltinComponentInterface_1 = __importDefault(require("./BuiltinComponentInterface"));
8
- var BuiltinInterface_1 = __importDefault(require("./BuiltinInterface"));
9
- function createMediaInterface(directory, prefix) {
10
- var stringFields = [
11
- 'name',
12
- 'alternativeText',
13
- 'caption',
14
- 'hash',
15
- 'ext',
16
- 'mime',
17
- 'url',
18
- 'previewUrl',
19
- 'provider',
20
- ];
21
- var numberFields = [
22
- 'width',
23
- 'height',
24
- 'size',
25
- ];
26
- var mediaFormat = {
27
- type: 'component',
28
- repeatable: false,
29
- component: 'builtins::MediaFormat',
30
- };
31
- var mediaAttrs = {
32
- formats: {
33
- // types-4-strapi-2 specific
34
- type: 'nested',
35
- fields: {
36
- thumbnail: mediaFormat,
37
- medium: mediaFormat,
38
- small: mediaFormat,
39
- },
40
- },
41
- };
42
- stringFields.forEach(function (s) {
43
- mediaAttrs[s] = { type: 'string' };
44
- });
45
- numberFields.forEach(function (s) {
46
- mediaAttrs[s] = { type: 'integer' };
47
- });
48
- // const dataAttrs = {
49
- // data: {
50
- // type: "nested",
51
- // fields: mediaAttrs,
52
- // nullable: true,
53
- // },
54
- // };
55
- return new BuiltinInterface_1.default('Media', mediaAttrs, directory, prefix);
56
- }
57
- exports.createMediaInterface = createMediaInterface;
58
- function createMediaFormatInterface(directory, prefix) {
59
- var stringFields = [
60
- 'name',
61
- 'hash',
62
- 'ext',
63
- 'mime',
64
- 'path',
65
- 'url',
66
- ];
67
- var numberFields = [
68
- 'width',
69
- 'height',
70
- 'size',
71
- ];
72
- var mediaAttrs = {};
73
- stringFields.forEach(function (s) {
74
- mediaAttrs[s] = { type: 'string' };
75
- });
76
- numberFields.forEach(function (s) {
77
- mediaAttrs[s] = { type: 'integer' };
78
- });
79
- return new BuiltinComponentInterface_1.default('MediaFormat', mediaAttrs, directory, prefix);
80
- }
81
- exports.createMediaFormatInterface = createMediaFormatInterface;
@@ -1,14 +0,0 @@
1
- export declare function readSchema(schemaPath: string): Promise<any>;
2
- export declare function getApiFolders(strapiSrcRoot: string): Promise<string[]>;
3
- export declare function getComponentCategoryFolders(strapiSrcRoot: string): Promise<string[]>;
4
- export declare function getComponentSchemas(strapiSrcRoot: string): Promise<{
5
- category: string;
6
- schemas: {
7
- name: string;
8
- attributes: any;
9
- }[];
10
- }[]>;
11
- export declare function getApiSchemas(strapiSrcRoot: string): Promise<{
12
- name: string;
13
- attributes: any;
14
- }[]>;