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

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.
@@ -5,10 +5,10 @@ export declare function getComponentSchemas(strapiSrcRoot: string): Promise<{
5
5
  category: string;
6
6
  schemas: {
7
7
  name: string;
8
- attributes: any;
8
+ schema: any;
9
9
  }[];
10
10
  }[]>;
11
11
  export declare function getApiSchemas(strapiSrcRoot: string): Promise<{
12
12
  name: string;
13
- attributes: any;
13
+ schema: any;
14
14
  }[]>;
@@ -51,7 +51,7 @@ function readSchema(schemaPath) {
51
51
  return [4 /*yield*/, (0, promises_1.readFile)(schemaPath)];
52
52
  case 1:
53
53
  schemaData = _a.sent();
54
- return [2 /*return*/, JSON.parse(schemaData.toString()).attributes];
54
+ return [2 /*return*/, JSON.parse(schemaData.toString())];
55
55
  case 2:
56
56
  e_1 = _a.sent();
57
57
  return [2 /*return*/, null];
@@ -117,16 +117,16 @@ function getComponentSchemas(strapiSrcRoot) {
117
117
  case 1:
118
118
  schemaFiles = _a.sent();
119
119
  schemaNamesWithAttributesPromises = schemaFiles.map(function (file) { return __awaiter(_this, void 0, void 0, function () {
120
- var schemaPath, attributes, name;
120
+ var schemaPath, schema, name;
121
121
  return __generator(this, function (_a) {
122
122
  switch (_a.label) {
123
123
  case 0:
124
124
  schemaPath = (0, posix_1.join)(schemaFilesPath, file);
125
125
  return [4 /*yield*/, readSchema(schemaPath)];
126
126
  case 1:
127
- attributes = _a.sent();
127
+ schema = _a.sent();
128
128
  name = file.split('.')[0];
129
- return [2 /*return*/, { name: name, attributes: attributes }];
129
+ return [2 /*return*/, { name: name, schema: schema }];
130
130
  }
131
131
  });
132
132
  }); });
@@ -156,15 +156,15 @@ function getApiSchemas(strapiSrcRoot) {
156
156
  case 1:
157
157
  apiFolders = _a.sent();
158
158
  schemasWithAttributesPromises = apiFolders.map(function (folder) { return __awaiter(_this, void 0, void 0, function () {
159
- var schemaPath, attributes;
159
+ var schemaPath, schema;
160
160
  return __generator(this, function (_a) {
161
161
  switch (_a.label) {
162
162
  case 0:
163
163
  schemaPath = (0, posix_1.join)(strapiSrcRoot, 'api', folder, 'content-types', folder, 'schema.json');
164
164
  return [4 /*yield*/, readSchema(schemaPath)];
165
165
  case 1:
166
- attributes = _a.sent();
167
- return [2 /*return*/, { name: folder, attributes: attributes }];
166
+ schema = _a.sent();
167
+ return [2 /*return*/, { name: folder, schema: schema }];
168
168
  }
169
169
  });
170
170
  }); });
@@ -1,6 +1,11 @@
1
1
  export declare enum Events {
2
2
  BeforeReadSchema = "BeforeReadSchema",
3
- AfterReadSchema = "AfterReadSchema"
3
+ AfterReadSchema = "AfterReadSchema",
4
+ BeforeReadSchemas = "BeforeReadSchemas",
5
+ AfterReadSchemas = "AfterReadSchemas",
6
+ ModifySchemas = "ModifySchemas",
7
+ BeforeInjectDependencies = "BeforeInjectDependencies",
8
+ AfterInjectDependencies = "AfterInjectDependencies"
4
9
  }
5
10
  export declare type SchemasType = {
6
11
  apiSchemas: Record<string, any>[];
@@ -5,4 +5,9 @@ var Events;
5
5
  (function (Events) {
6
6
  Events["BeforeReadSchema"] = "BeforeReadSchema";
7
7
  Events["AfterReadSchema"] = "AfterReadSchema";
8
+ Events["BeforeReadSchemas"] = "BeforeReadSchemas";
9
+ Events["AfterReadSchemas"] = "AfterReadSchemas";
10
+ Events["ModifySchemas"] = "ModifySchemas";
11
+ Events["BeforeInjectDependencies"] = "BeforeInjectDependencies";
12
+ Events["AfterInjectDependencies"] = "AfterInjectDependencies";
8
13
  })(Events = exports.Events || (exports.Events = {}));
@@ -32,9 +32,13 @@ var Interface = /** @class */ (function (_super) {
32
32
  _this.updateStrapiName();
33
33
  _this.NamePrefix = prefix;
34
34
  _this.Attributes = attributes;
35
+ if (!attributes) {
36
+ console.warn("Warning: attributes for ".concat(_this.getStrapiName(), " is empty!"));
37
+ }
35
38
  return _this;
36
39
  }
37
40
  Interface.prototype.updateStrapiName = function () {
41
+ // TODO: add support for api name
38
42
  this.StrapiName = "api::".concat(this.BaseName, ".").concat(this.BaseName);
39
43
  };
40
44
  Interface.prototype.getStrapiName = function () {
@@ -44,6 +48,7 @@ var Interface = /** @class */ (function (_super) {
44
48
  return this.getAttributes().getDependencies();
45
49
  };
46
50
  Interface.prototype.getFullName = function () {
51
+ // TODO: use correct casing from options
47
52
  var pascalName = (0, change_case_1.pascalCase)(this.BaseName);
48
53
  return "".concat(this.NamePrefix).concat(pascalName);
49
54
  };
@@ -1,9 +1,13 @@
1
+ import { Events } from '../events';
1
2
  import InterfaceManager from '../program/InterfaceManager';
2
3
  export declare type HookTypes = {
3
- BeforeReadSchema: (state: InterfaceManager, schema: any) => void;
4
- AfterReadSchema: (state: InterfaceManager, schema: any) => void;
5
- BeforeReadSchemas: (state: InterfaceManager) => void;
6
- AfterReadSchemas: (state: InterfaceManager) => void;
4
+ [Events.BeforeReadSchema]: (state: InterfaceManager, schema: any) => void;
5
+ [Events.AfterReadSchema]: (state: InterfaceManager, schema: any) => void;
6
+ [Events.BeforeReadSchemas]: (state: InterfaceManager) => void;
7
+ [Events.AfterReadSchemas]: (state: InterfaceManager) => void;
8
+ [Events.ModifySchemas]: (state: InterfaceManager) => void;
9
+ [Events.BeforeInjectDependencies]: (state: InterfaceManager) => void;
10
+ [Events.AfterInjectDependencies]: (state: InterfaceManager) => void;
7
11
  };
8
12
  export declare type HooksType = {
9
13
  [HookType in keyof HookTypes]: {
@@ -1,14 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PluginManager = void 0;
4
+ var events_1 = require("../events");
4
5
  var PluginManager = /** @class */ (function () {
5
6
  function PluginManager() {
6
- this.hooks = {
7
- BeforeReadSchema: [],
8
- BeforeReadSchemas: [],
9
- AfterReadSchema: [],
10
- AfterReadSchemas: [],
11
- };
7
+ var _a;
8
+ this.hooks = (_a = {},
9
+ _a[events_1.Events.BeforeReadSchema] = [],
10
+ _a[events_1.Events.BeforeReadSchemas] = [],
11
+ _a[events_1.Events.AfterReadSchema] = [],
12
+ _a[events_1.Events.AfterReadSchemas] = [],
13
+ _a[events_1.Events.ModifySchemas] = [],
14
+ _a[events_1.Events.BeforeInjectDependencies] = [],
15
+ _a[events_1.Events.AfterInjectDependencies] = [],
16
+ _a);
12
17
  }
13
18
  PluginManager.prototype.registerPlugin = function (hooks) {
14
19
  var _a;
@@ -0,0 +1,3 @@
1
+ import { PluginRegister } from "../types";
2
+ declare const register: PluginRegister;
3
+ export default register;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var constants_1 = require("../../constants");
4
+ var events_1 = require("../../events");
5
+ var addFieldsToContentTypes = function (state, schema) {
6
+ var apiSchemas = schema.apiSchemas;
7
+ apiSchemas.forEach(function (_a) {
8
+ var name = _a.name, schema = _a.schema;
9
+ var attributes = schema.attributes, _b = schema.options, options = _b === void 0 ? {} : _b;
10
+ if ((options === null || options === void 0 ? void 0 : options.draftAndPublish) !== true) {
11
+ return;
12
+ }
13
+ var fieldNames = ['publishedAt', 'createdAt', 'updatedAt'];
14
+ fieldNames.forEach(function (fieldName) {
15
+ var _a;
16
+ attributes[fieldName] = (_a = {
17
+ type: 'string',
18
+ required: true
19
+ },
20
+ _a[constants_1.CERTAINLY_REQUIRED_KEY] = true,
21
+ _a);
22
+ });
23
+ });
24
+ };
25
+ var register = function () {
26
+ var _a;
27
+ return _a = {},
28
+ _a[events_1.Events.AfterReadSchema] = [
29
+ {
30
+ fn: addFieldsToContentTypes,
31
+ priority: 10,
32
+ },
33
+ ],
34
+ _a;
35
+ };
36
+ exports.default = register;
@@ -0,0 +1,3 @@
1
+ import { PluginRegister } from "../types";
2
+ declare const register: PluginRegister;
3
+ export default register;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var constants_1 = require("../../constants");
4
+ var events_1 = require("../../events");
5
+ var addLocaleToLocalizedContentTypes = function (state, _a) {
6
+ var apiSchemas = _a.apiSchemas;
7
+ apiSchemas.forEach(function (_a) {
8
+ var _b;
9
+ var _c, _d;
10
+ var name = _a.name, schema = _a.schema;
11
+ var attributes = schema.attributes;
12
+ if (((_d = (_c = schema === null || schema === void 0 ? void 0 : schema.pluginOptions) === null || _c === void 0 ? void 0 : _c.i18n) === null || _d === void 0 ? void 0 : _d.localized) !== true) {
13
+ return;
14
+ }
15
+ // Add locale to all localized content types
16
+ attributes.locale = (_b = {
17
+ type: 'string',
18
+ required: true
19
+ },
20
+ _b[constants_1.CERTAINLY_REQUIRED_KEY] = true,
21
+ _b);
22
+ // Add populatable field for localizations
23
+ attributes.localizations = {
24
+ type: 'relation',
25
+ relation: 'oneToMany',
26
+ target: "api::".concat(name, ".").concat(name), // TODO: make this more complete
27
+ };
28
+ });
29
+ };
30
+ var register = function () {
31
+ var _a;
32
+ return _a = {},
33
+ _a[events_1.Events.AfterReadSchema] = [
34
+ {
35
+ fn: addLocaleToLocalizedContentTypes,
36
+ priority: 10,
37
+ },
38
+ ],
39
+ _a;
40
+ };
41
+ exports.default = register;
@@ -5,9 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.registerBuiltinPlugins = void 0;
7
7
  var url_alias_1 = __importDefault(require("./url-alias"));
8
+ var draft_and_publish_1 = __importDefault(require("./draft-and-publish"));
9
+ var i18n_1 = __importDefault(require("./i18n"));
8
10
  var registerBuiltinPlugins = function (pluginManager, pluginNames) {
11
+ // Draft and publish is always registered since it is built into Strapi
12
+ pluginManager.registerPlugin((0, draft_and_publish_1.default)());
9
13
  if (pluginNames.has('url-alias')) {
10
14
  pluginManager.registerPlugin((0, url_alias_1.default)());
11
15
  }
16
+ if (pluginNames.has('i18n')) {
17
+ pluginManager.registerPlugin((0, i18n_1.default)());
18
+ }
12
19
  };
13
20
  exports.registerBuiltinPlugins = registerBuiltinPlugins;
@@ -1,2 +1,4 @@
1
- export declare const supportedPluginNames: readonly ["url-alias"];
1
+ import { HooksType } from "./PluginManager";
2
+ export declare const supportedPluginNames: readonly ["url-alias", "i18n"];
2
3
  export declare type SupportedPluginNamesType = typeof supportedPluginNames[number];
4
+ export declare type PluginRegister = () => Partial<HooksType>;
@@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.supportedPluginNames = void 0;
4
4
  exports.supportedPluginNames = [
5
5
  'url-alias',
6
+ 'i18n',
6
7
  ];
@@ -1,3 +1,3 @@
1
- import { HooksType } from '../PluginManager';
2
- declare const register: () => Partial<HooksType>;
1
+ import { PluginRegister } from '../types';
2
+ declare const register: PluginRegister;
3
3
  export default register;
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var events_1 = require("../../events");
4
+ var type_1 = require("./type");
4
5
  var addUrlAliasToAllContentTypes = function (state, _a) {
5
6
  var apiSchemas = _a.apiSchemas;
6
- apiSchemas.forEach(function (schema) {
7
+ apiSchemas.forEach(function (_a) {
8
+ var name = _a.name, schema = _a.schema;
7
9
  var attributes = schema.attributes;
10
+ // TODO: write comment here if it is intentional that it it can be null
8
11
  attributes.url_path = {
9
12
  type: 'string',
10
13
  required: true,
@@ -16,6 +19,10 @@ var addUrlAliasToAllContentTypes = function (state, _a) {
16
19
  // };
17
20
  });
18
21
  };
22
+ var addUrlAliasGetType = function (state) {
23
+ var urlAliasGet = new type_1.UrlAliasGet();
24
+ state.addType(urlAliasGet.getStrapiName(), urlAliasGet);
25
+ };
19
26
  var register = function () {
20
27
  var _a;
21
28
  return _a = {},
@@ -25,6 +32,12 @@ var register = function () {
25
32
  priority: 10,
26
33
  },
27
34
  ],
35
+ _a[events_1.Events.AfterReadSchemas] = [
36
+ {
37
+ fn: addUrlAliasGetType,
38
+ priority: 10,
39
+ },
40
+ ],
28
41
  _a;
29
42
  };
30
43
  exports.default = register;
@@ -0,0 +1,8 @@
1
+ import { File } from '../../file/File';
2
+ export declare class UrlAliasGet extends File {
3
+ constructor();
4
+ getStrapiName(): string;
5
+ getFullName(): string;
6
+ getDependencies(): any[];
7
+ toString(): string;
8
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.UrlAliasGet = void 0;
19
+ var File_1 = require("../../file/File");
20
+ /* import Interface from "../../interface/Interface"; */
21
+ var UrlAliasGet = /** @class */ (function (_super) {
22
+ __extends(UrlAliasGet, _super);
23
+ function UrlAliasGet() {
24
+ var baseName = 'url-alias';
25
+ return _super.call(this, baseName, 'plugins/url-alias', 'pascal') || this;
26
+ }
27
+ UrlAliasGet.prototype.getStrapiName = function () {
28
+ return 'plugins::url-alias.get';
29
+ };
30
+ UrlAliasGet.prototype.getFullName = function () {
31
+ return 'UrlAliasGet';
32
+ };
33
+ UrlAliasGet.prototype.getDependencies = function () {
34
+ return [];
35
+ };
36
+ UrlAliasGet.prototype.toString = function () {
37
+ return "\n export type ".concat(this.getFullName(), "<ContentType extends { attributes: {} }> = ContentType & {\n attributes: {\n contentType: string;\n },\n }\n ");
38
+ };
39
+ return UrlAliasGet;
40
+ }(File_1.File));
41
+ exports.UrlAliasGet = UrlAliasGet;
@@ -1,11 +1,12 @@
1
+ import { File } from '../file/File';
1
2
  export default class InterfaceManager {
2
- private Interfaces;
3
3
  private Files;
4
4
  private OutRoot;
5
5
  private StrapiSrcRoot;
6
6
  private Options;
7
7
  private PrettierOptions;
8
8
  private PluginManager;
9
+ private dependenciesInjected;
9
10
  static BaseOptions: {
10
11
  prefix: string;
11
12
  useCategoryPrefix: boolean;
@@ -17,7 +18,7 @@ export default class InterfaceManager {
17
18
  prettierFile: any;
18
19
  fileCaseType: "camel" | "capital" | "dot" | "snake" | "pascal" | "constant" | "kebab";
19
20
  folderCaseType: "camel" | "capital" | "dot" | "snake" | "pascal" | "constant" | "kebab";
20
- enabledPlugins: "url-alias"[];
21
+ enabledPlugins: ("url-alias" | "i18n")[];
21
22
  };
22
23
  constructor(outRoot: string, strapiSrcRoot: string, options?: Partial<typeof InterfaceManager['BaseOptions']>);
23
24
  registerBuiltinPlugins(): void;
@@ -28,6 +29,7 @@ export default class InterfaceManager {
28
29
  apiSchemas: any[];
29
30
  componentSchemas: any[];
30
31
  }>;
32
+ addType(name: string, file: File, force?: boolean): boolean;
31
33
  createInterfaces(): Promise<void>;
32
34
  createBuiltinInterfaces(): void;
33
35
  injectDependencies(): void;
@@ -78,9 +78,8 @@ var InterfaceManager = /** @class */ (function () {
78
78
  function InterfaceManager(outRoot, strapiSrcRoot, options) {
79
79
  if (options === void 0) { options = {}; }
80
80
  var _this = this;
81
- // TODO: remove Interfaces
82
- this.Interfaces = {}; // string = strapi name
83
81
  this.Files = {}; // string = strapi name
82
+ this.dependenciesInjected = false;
84
83
  this.OutRoot = outRoot;
85
84
  this.StrapiSrcRoot = strapiSrcRoot;
86
85
  this.Options = __assign(__assign({}, InterfaceManager.BaseOptions), options);
@@ -170,6 +169,17 @@ var InterfaceManager = /** @class */ (function () {
170
169
  });
171
170
  });
172
171
  };
172
+ InterfaceManager.prototype.addType = function (name, file, force) {
173
+ if (force === void 0) { force = false; }
174
+ if (this.dependenciesInjected) {
175
+ console.warn('You should not add types after dependencies have been injected');
176
+ }
177
+ if (this.Files[name] && !force) {
178
+ return false;
179
+ }
180
+ this.Files[name] = file;
181
+ return true;
182
+ };
173
183
  InterfaceManager.prototype.createInterfaces = function () {
174
184
  return __awaiter(this, void 0, void 0, function () {
175
185
  var _a, apiSchemas, componentSchemas;
@@ -179,18 +189,19 @@ var InterfaceManager = /** @class */ (function () {
179
189
  case 0: return [4 /*yield*/, this.readSchemas()];
180
190
  case 1:
181
191
  _a = _b.sent(), apiSchemas = _a.apiSchemas, componentSchemas = _a.componentSchemas;
192
+ this.PluginManager.invoke(events_1.Events.BeforeReadSchemas, this);
182
193
  apiSchemas.forEach(function (schema) {
183
- var name = schema.name, attributes = schema.attributes;
194
+ var name = schema.name, attributes = schema.schema.attributes;
184
195
  var strapiName = "api::".concat(name, ".").concat(name);
185
196
  var inter = new Interface_1.default(name, attributes, './', _this.Options.fileCaseType, _this.Options.prefix);
186
- _this.Interfaces[strapiName] = inter;
187
- _this.Files[strapiName] = inter;
197
+ _this.addType(strapiName, inter);
188
198
  });
189
199
  componentSchemas.forEach(function (category) {
190
200
  var categoryName = category.category;
191
- category.schemas.forEach(function (schema) {
192
- var componentName = schema.name;
193
- var strapiName = "".concat(categoryName, ".").concat(schema.name);
201
+ category.schemas.forEach(function (_a) {
202
+ var name = _a.name, schema = _a.schema;
203
+ var componentName = name;
204
+ var strapiName = "".concat(categoryName, ".").concat(name);
194
205
  var componentPrefix = "".concat(_this.Options.componentPrefix).concat(_this.Options.useCategoryPrefix
195
206
  ? (0, pascal_case_1.pascalCase)(categoryName)
196
207
  : '');
@@ -200,10 +211,10 @@ var InterfaceManager = /** @class */ (function () {
200
211
  var categoryFolderName = (0, casing_1.changeCase)(categoryName, _this.Options.folderCaseType);
201
212
  // make component interface
202
213
  var inter = new ComponentInterface_1.default(componentName, schema.attributes, "./".concat(categoryFolderName), categoryName, _this.Options.fileCaseType, prefix);
203
- _this.Interfaces[strapiName] = inter;
204
- _this.Files[strapiName] = inter;
214
+ _this.addType(strapiName, inter);
205
215
  });
206
216
  });
217
+ this.PluginManager.invoke(events_1.Events.AfterReadSchemas, this);
207
218
  return [2 /*return*/];
208
219
  }
209
220
  });
@@ -218,20 +229,19 @@ var InterfaceManager = /** @class */ (function () {
218
229
  builtinInterfaces.push((0, builtinInterfaces_1.createMediaInterface)(outDir, this.Options.fileCaseType, this.Options.prefix));
219
230
  builtinInterfaces.push((0, builtinInterfaces_1.createMediaFormatInterface)(outDir, this.Options.fileCaseType, this.Options.prefix));
220
231
  builtinInterfaces.forEach(function (inter) {
221
- _this.Interfaces[inter.getStrapiName()] = inter;
222
- _this.Files[inter.getStrapiName()] = inter;
232
+ _this.addType(inter.getStrapiName(), inter);
223
233
  });
224
234
  // Types
225
235
  var types = [];
226
236
  types.push.apply(types, (0, createExtraTypes_1.createExtraTypes)());
227
237
  types.forEach(function (t) {
228
- _this.Files[t.getStrapiName()] = t;
238
+ _this.addType(t.getStrapiName(), t);
229
239
  });
230
240
  };
231
241
  // Inject dependencies into all interfaces
232
242
  InterfaceManager.prototype.injectDependencies = function () {
233
243
  var _this = this;
234
- // console.log("Injecting dependencies")
244
+ this.PluginManager.invoke(events_1.Events.BeforeInjectDependencies, this);
235
245
  Object.keys(this.Files).forEach(function (strapiName) {
236
246
  var file = _this.Files[strapiName];
237
247
  var dependencies = file.getDependencies();
@@ -243,6 +253,8 @@ var InterfaceManager = /** @class */ (function () {
243
253
  .filter(function (inter) { return inter; });
244
254
  file.setRelations(interfacesToInject);
245
255
  });
256
+ this.dependenciesInjected = true;
257
+ this.PluginManager.invoke(events_1.Events.AfterInjectDependencies, this);
246
258
  };
247
259
  InterfaceManager.prototype.deleteOldFolders = function () {
248
260
  return __awaiter(this, void 0, void 0, function () {
@@ -330,8 +342,13 @@ var InterfaceManager = /** @class */ (function () {
330
342
  fileData = file.toString();
331
343
  formattedFileData = prettier_1.default.format(fileData, this.PrettierOptions);
332
344
  filePath = (0, posix_1.join)(this.OutRoot, file.getRelativeRootPathFile());
333
- return [4 /*yield*/, (0, promises_1.writeFile)(filePath, formattedFileData)];
345
+ return [4 /*yield*/, (0, promises_1.mkdir)((0, posix_1.dirname)(filePath), {
346
+ recursive: true,
347
+ })];
334
348
  case 1:
349
+ _a.sent();
350
+ return [4 /*yield*/, (0, promises_1.writeFile)(filePath, formattedFileData)];
351
+ case 2:
335
352
  _a.sent();
336
353
  return [2 /*return*/];
337
354
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oak-digital/types-4-strapi-2",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Typescript interface generator for Strapi 4 models",
5
5
  "bin": {
6
6
  "t4s": "./bin/index.js"