@oak-digital/types-4-strapi-2 0.5.4 → 1.0.0-beta.1

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 (116) hide show
  1. package/.eslintrc.json +2 -1
  2. package/CHANGELOG.md +7 -0
  3. package/README.md +21 -8
  4. package/lib/attributes/Attributes.d.ts +4 -3
  5. package/lib/attributes/Attributes.js +102 -78
  6. package/lib/content-types/reader.js +49 -145
  7. package/lib/extra-types/ExtraType.d.ts +2 -2
  8. package/lib/extra-types/ExtraType.js +19 -38
  9. package/lib/extra-types/createExtraTypes.d.ts +1 -1
  10. package/lib/extra-types/createExtraTypes.js +11 -12
  11. package/lib/file/File.d.ts +1 -1
  12. package/lib/file/File.js +44 -43
  13. package/lib/index.js +57 -19
  14. package/lib/interface/BuiltinComponentInterface.js +9 -27
  15. package/lib/interface/BuiltinInterface.d.ts +0 -1
  16. package/lib/interface/BuiltinInterface.js +5 -26
  17. package/lib/interface/ComponentInterface.d.ts +2 -1
  18. package/lib/interface/ComponentInterface.js +30 -48
  19. package/lib/interface/Interface.d.ts +6 -2
  20. package/lib/interface/Interface.js +69 -70
  21. package/lib/interface/builtinInterfaces.d.ts +1941 -2
  22. package/lib/interface/builtinInterfaces.js +56 -46
  23. package/lib/plugins/PluginManager.d.ts +8 -2
  24. package/lib/plugins/PluginManager.js +28 -35
  25. package/lib/plugins/draft-and-publish/index.d.ts +1 -1
  26. package/lib/plugins/draft-and-publish/index.js +17 -21
  27. package/lib/plugins/i18n/index.d.ts +1 -1
  28. package/lib/plugins/i18n/index.js +17 -22
  29. package/lib/plugins/index.js +4 -4
  30. package/lib/plugins/types.d.ts +1 -1
  31. package/lib/plugins/types.js +1 -4
  32. package/lib/plugins/url-alias/index.js +12 -15
  33. package/lib/plugins/url-alias/type.js +21 -32
  34. package/lib/program/InterfaceManager.d.ts +374 -24
  35. package/lib/program/InterfaceManager.js +128 -376
  36. package/lib/readers/by-file.d.ts +321 -0
  37. package/lib/readers/by-file.js +116 -0
  38. package/lib/readers/load-strapi/index.d.ts +319 -0
  39. package/lib/readers/load-strapi/index.js +106 -0
  40. package/lib/readers/types/attributes.d.ts +1639 -0
  41. package/lib/readers/types/attributes.js +144 -0
  42. package/lib/readers/types/component.d.ts +723 -0
  43. package/lib/readers/types/component.js +11 -0
  44. package/lib/readers/types/content-type-reader.d.ts +16 -0
  45. package/lib/readers/types/content-type-reader.js +2 -0
  46. package/lib/readers/types/content-type.d.ts +766 -0
  47. package/lib/readers/types/content-type.js +16 -0
  48. package/lib/utils/casing/index.js +2 -2
  49. package/lib/utils/index.js +5 -39
  50. package/lib/writers/basic-writer.d.ts +24 -0
  51. package/lib/writers/basic-writer.js +75 -0
  52. package/lib/writers/types/writer.d.ts +4 -0
  53. package/lib/writers/types/writer.js +2 -0
  54. package/package.json +12 -9
  55. package/tests/strapi-project/.editorconfig +16 -0
  56. package/tests/strapi-project/.env.example +6 -0
  57. package/tests/strapi-project/README.md +57 -0
  58. package/tests/strapi-project/config/admin.ts +13 -0
  59. package/tests/strapi-project/config/api.ts +7 -0
  60. package/tests/strapi-project/config/database.ts +93 -0
  61. package/tests/strapi-project/config/middlewares.ts +12 -0
  62. package/tests/strapi-project/config/server.ts +10 -0
  63. package/tests/strapi-project/favicon.png +0 -0
  64. package/tests/strapi-project/package-lock.json +16125 -0
  65. package/tests/strapi-project/package.json +30 -0
  66. package/tests/strapi-project/public/robots.txt +3 -0
  67. package/tests/strapi-project/public/uploads/.gitkeep +0 -0
  68. package/tests/strapi-project/src/admin/app.example.tsx +35 -0
  69. package/tests/strapi-project/src/admin/webpack.config.example.js +9 -0
  70. package/tests/strapi-project/src/api/.gitkeep +0 -0
  71. package/tests/strapi-project/src/api/collection-1/content-types/collection-1/schema.json +18 -0
  72. package/tests/strapi-project/src/api/collection-1/content-types/generated-type/schema.json +18 -0
  73. package/tests/strapi-project/src/api/collection-1/controllers/collection-1.ts +7 -0
  74. package/tests/strapi-project/src/api/collection-1/controllers/generated-type.ts +7 -0
  75. package/tests/strapi-project/src/api/collection-1/routes/collection-1.ts +7 -0
  76. package/tests/strapi-project/src/api/collection-1/routes/generated-type.ts +7 -0
  77. package/tests/strapi-project/src/api/collection-1/services/collection-1.ts +7 -0
  78. package/tests/strapi-project/src/api/collection-1/services/generated-type.ts +7 -0
  79. package/tests/strapi-project/src/api/standalone-controller/controllers/standalone-controller.ts +13 -0
  80. package/tests/strapi-project/src/components/my-category/all-types.json +88 -0
  81. package/tests/strapi-project/src/components/other-category/sub-component.json +12 -0
  82. package/tests/strapi-project/src/extensions/.gitkeep +0 -0
  83. package/tests/strapi-project/src/index.ts +18 -0
  84. package/lib/.prettierrc.json +0 -7
  85. package/lib/case/index.d.ts +0 -4
  86. package/lib/case/index.js +0 -47
  87. package/lib/interface/Attributes.d.ts +0 -11
  88. package/lib/interface/Attributes.js +0 -167
  89. package/lib/interface/InterfaceManager.d.ts +0 -39
  90. package/lib/interface/InterfaceManager.js +0 -396
  91. package/lib/interface/interfaceCreator.js +0 -7
  92. package/lib/interface/interfaceWriter.d.ts +0 -2
  93. package/lib/interface/interfaceWriter.js +0 -46
  94. package/lib/interface/schemaReader.d.ts +0 -14
  95. package/lib/interface/schemaReader.js +0 -177
  96. package/lib/src/index.d.ts +0 -1
  97. package/lib/src/index.js +0 -25
  98. package/lib/src/interface/Attributes.d.ts +0 -11
  99. package/lib/src/interface/Attributes.js +0 -148
  100. package/lib/src/interface/BuiltinComponentInterface.d.ts +0 -5
  101. package/lib/src/interface/BuiltinComponentInterface.js +0 -36
  102. package/lib/src/interface/BuiltinInterface.d.ts +0 -5
  103. package/lib/src/interface/BuiltinInterface.js +0 -33
  104. package/lib/src/interface/ComponentInterface.d.ts +0 -8
  105. package/lib/src/interface/ComponentInterface.js +0 -58
  106. package/lib/src/interface/Interface.d.ts +0 -31
  107. package/lib/src/interface/Interface.js +0 -112
  108. package/lib/src/interface/InterfaceManager.d.ts +0 -25
  109. package/lib/src/interface/InterfaceManager.js +0 -288
  110. package/lib/src/interface/builtinInterfaces.d.ts +0 -4
  111. package/lib/src/interface/builtinInterfaces.js +0 -81
  112. package/lib/src/interface/schemaReader.d.ts +0 -14
  113. package/lib/src/interface/schemaReader.js +0 -172
  114. package/lib/src/utils/index.d.ts +0 -3
  115. package/lib/src/utils/index.js +0 -67
  116. /package/{lib/interface/interfaceCreator.d.ts → tests/strapi-project/database/migrations/.gitkeep} +0 -0
@@ -3,12 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createMediaFormatInterface = exports.createMediaInterface = void 0;
7
- var constants_1 = require("../constants");
8
- var BuiltinComponentInterface_1 = __importDefault(require("./BuiltinComponentInterface"));
9
- var BuiltinInterface_1 = __importDefault(require("./BuiltinInterface"));
10
- function createMediaInterface(directory, caseTypeName, prefix) {
11
- var stringRequiredFields = [
6
+ exports.createMediaFormatInterface = exports.createMediaInterface = exports.attributeWithNested = exports.nestedAttribute = void 0;
7
+ const zod_1 = require("zod");
8
+ const constants_1 = require("../constants");
9
+ const attributes_1 = require("../readers/types/attributes");
10
+ const BuiltinComponentInterface_1 = __importDefault(require("./BuiltinComponentInterface"));
11
+ const BuiltinInterface_1 = __importDefault(require("./BuiltinInterface"));
12
+ exports.nestedAttribute = zod_1.z.object({
13
+ type: zod_1.z.literal('nested'),
14
+ nullable: zod_1.z.boolean().optional(),
15
+ fields: zod_1.z.record(attributes_1.contentTypeAttribute),
16
+ });
17
+ exports.attributeWithNested = zod_1.z.union([attributes_1.contentTypeAttribute, exports.nestedAttribute]);
18
+ function createMediaInterface(caseTypeName, prefix) {
19
+ const stringRequiredFields = [
12
20
  'name',
13
21
  'hash',
14
22
  'ext',
@@ -16,21 +24,21 @@ function createMediaInterface(directory, caseTypeName, prefix) {
16
24
  'url',
17
25
  'provider',
18
26
  ];
19
- var stringFields = [
27
+ const stringFields = [
20
28
  'previewUrl',
21
29
  'provider_metadata',
22
30
  'alternativeText',
23
31
  'caption', // nullable in plain text
24
32
  ];
25
- var numberRequiredFields = ['size'];
33
+ const numberRequiredFields = ['size'];
26
34
  // Nullable if you have a plain text file
27
- var numberFields = ['width', 'height'];
28
- var mediaFormat = {
35
+ const numberFields = ['width', 'height'];
36
+ const mediaFormat = {
29
37
  type: 'component',
30
38
  repeatable: false,
31
39
  component: 'builtins::MediaFormat',
32
40
  };
33
- var mediaAttrs = {
41
+ const mediaAttrs = {
34
42
  formats: {
35
43
  // types-4-strapi-2 specific
36
44
  type: 'nested',
@@ -43,29 +51,25 @@ function createMediaInterface(directory, caseTypeName, prefix) {
43
51
  },
44
52
  },
45
53
  };
46
- stringRequiredFields.forEach(function (s) {
47
- var _a;
48
- mediaAttrs[s] = (_a = {
49
- type: 'string',
50
- required: true
51
- },
52
- _a[constants_1.CERTAINLY_REQUIRED_KEY] = true,
53
- _a);
54
+ stringRequiredFields.forEach((s) => {
55
+ mediaAttrs[s] = {
56
+ type: 'text',
57
+ required: true,
58
+ [constants_1.CERTAINLY_REQUIRED_KEY]: true,
59
+ };
54
60
  });
55
- stringFields.forEach(function (s) {
56
- mediaAttrs[s] = { type: 'string' };
61
+ stringFields.forEach((s) => {
62
+ mediaAttrs[s] = { type: 'text' };
57
63
  });
58
- numberFields.forEach(function (s) {
64
+ numberFields.forEach((s) => {
59
65
  mediaAttrs[s] = { type: 'integer' };
60
66
  });
61
- numberRequiredFields.forEach(function (s) {
62
- var _a;
63
- mediaAttrs[s] = (_a = {
64
- type: 'integer',
65
- required: true
66
- },
67
- _a[constants_1.CERTAINLY_REQUIRED_KEY] = true,
68
- _a);
67
+ numberRequiredFields.forEach((s) => {
68
+ mediaAttrs[s] = {
69
+ type: 'integer',
70
+ required: true,
71
+ [constants_1.CERTAINLY_REQUIRED_KEY]: true,
72
+ };
69
73
  });
70
74
  // const dataAttrs = {
71
75
  // data: {
@@ -74,29 +78,35 @@ function createMediaInterface(directory, caseTypeName, prefix) {
74
78
  // nullable: true,
75
79
  // },
76
80
  // };
77
- return new BuiltinInterface_1.default('Media', mediaAttrs, directory, caseTypeName, prefix);
81
+ return new BuiltinInterface_1.default('Media', mediaAttrs, '', caseTypeName, prefix);
78
82
  }
79
83
  exports.createMediaInterface = createMediaInterface;
80
- function createMediaFormatInterface(directory, caseTypeName, prefix) {
81
- var stringRequiredFields = ['name', 'hash', 'ext', 'mime', 'url'];
82
- var stringFields = ['path'];
83
- var numberRequiredFields = ['size', 'width', 'height']; // TODO: not sure if this is corrext
84
- var numberFields = [];
85
- var mediaAttrs = {};
86
- stringRequiredFields.forEach(function (s) {
87
- var _a;
88
- mediaAttrs[s] = (_a = { type: 'string', required: true }, _a[constants_1.CERTAINLY_REQUIRED_KEY] = true, _a);
84
+ function createMediaFormatInterface(caseTypeName, prefix) {
85
+ const stringRequiredFields = ['name', 'hash', 'ext', 'mime', 'url'];
86
+ const stringFields = ['path'];
87
+ const numberRequiredFields = ['size', 'width', 'height']; // TODO: not sure if this is corrext
88
+ const numberFields = [];
89
+ const mediaAttrs = {};
90
+ stringRequiredFields.forEach((s) => {
91
+ mediaAttrs[s] = {
92
+ type: 'string',
93
+ required: true,
94
+ [constants_1.CERTAINLY_REQUIRED_KEY]: true,
95
+ };
89
96
  });
90
- stringFields.forEach(function (s) {
97
+ stringFields.forEach((s) => {
91
98
  mediaAttrs[s] = { type: 'string' };
92
99
  });
93
- numberRequiredFields.forEach(function (s) {
94
- var _a;
95
- mediaAttrs[s] = (_a = { type: 'integer', required: true }, _a[constants_1.CERTAINLY_REQUIRED_KEY] = true, _a);
100
+ numberRequiredFields.forEach((s) => {
101
+ mediaAttrs[s] = {
102
+ type: 'integer',
103
+ required: true,
104
+ [constants_1.CERTAINLY_REQUIRED_KEY]: true,
105
+ };
96
106
  });
97
- numberFields.forEach(function (s) {
107
+ numberFields.forEach((s) => {
98
108
  mediaAttrs[s] = { type: 'integer' };
99
109
  });
100
- return new BuiltinComponentInterface_1.default('MediaFormat', mediaAttrs, directory, caseTypeName, prefix);
110
+ return new BuiltinComponentInterface_1.default('MediaFormat', mediaAttrs, '', caseTypeName, prefix);
101
111
  }
102
112
  exports.createMediaFormatInterface = createMediaFormatInterface;
@@ -1,8 +1,13 @@
1
1
  import { Events } from '../events';
2
2
  import InterfaceManager from '../program/InterfaceManager';
3
+ import { ContentTypeReader } from '../readers/types/content-type-reader';
4
+ declare type Schemas = {
5
+ apiSchemas: Awaited<ReturnType<ContentTypeReader['readContentTypes']>>;
6
+ componentSchemas: Awaited<ReturnType<ContentTypeReader['readComponents']>>;
7
+ };
3
8
  export declare type HookTypes = {
4
- [Events.BeforeReadSchema]: (state: InterfaceManager, schema: any) => void;
5
- [Events.AfterReadSchema]: (state: InterfaceManager, schema: any) => void;
9
+ [Events.BeforeReadSchema]: (state: InterfaceManager, schema: Schemas) => void;
10
+ [Events.AfterReadSchema]: (state: InterfaceManager, schema: Schemas) => void;
6
11
  [Events.BeforeReadSchemas]: (state: InterfaceManager) => void;
7
12
  [Events.AfterReadSchemas]: (state: InterfaceManager) => void;
8
13
  [Events.ModifySchemas]: (state: InterfaceManager) => void;
@@ -22,3 +27,4 @@ export declare class PluginManager {
22
27
  sortHooks(): void;
23
28
  invoke<Hook extends keyof HookTypes>(hook: Hook, ...args: Parameters<HookTypes[Hook]>): void;
24
29
  }
30
+ export {};
@@ -1,46 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PluginManager = void 0;
4
- var events_1 = require("../events");
5
- var PluginManager = /** @class */ (function () {
6
- function PluginManager() {
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);
4
+ const events_1 = require("../events");
5
+ class PluginManager {
6
+ constructor() {
7
+ this.hooks = {
8
+ [events_1.Events.BeforeReadSchema]: [],
9
+ [events_1.Events.BeforeReadSchemas]: [],
10
+ [events_1.Events.AfterReadSchema]: [],
11
+ [events_1.Events.AfterReadSchemas]: [],
12
+ [events_1.Events.ModifySchemas]: [],
13
+ [events_1.Events.BeforeInjectDependencies]: [],
14
+ [events_1.Events.AfterInjectDependencies]: [],
15
+ };
17
16
  }
18
- PluginManager.prototype.registerPlugin = function (hooks) {
19
- var _a;
20
- for (var hook in hooks) {
17
+ registerPlugin(hooks) {
18
+ for (const hook in hooks) {
21
19
  if (hooks[hook]) {
22
- (_a = this.hooks[hook]).push.apply(_a, hooks[hook]);
20
+ this.hooks[hook].push(...hooks[hook]);
23
21
  }
24
22
  }
25
- };
26
- PluginManager.prototype.registerHook = function (hook, fn, priority) {
27
- this.hooks[hook].push({ fn: fn, priority: priority });
28
- };
29
- PluginManager.prototype.sortHooks = function () {
30
- for (var hook in this.hooks) {
31
- this.hooks[hook].sort(function (a, b) { return a.priority - b.priority; });
32
- }
33
- };
34
- PluginManager.prototype.invoke = function (hook) {
35
- var args = [];
36
- for (var _i = 1; _i < arguments.length; _i++) {
37
- args[_i - 1] = arguments[_i];
23
+ }
24
+ registerHook(hook, fn, priority) {
25
+ this.hooks[hook].push({ fn, priority });
26
+ }
27
+ sortHooks() {
28
+ for (const hook in this.hooks) {
29
+ this.hooks[hook].sort((a, b) => a.priority - b.priority);
38
30
  }
39
- this.hooks[hook].forEach(function (hook) {
31
+ }
32
+ invoke(hook, ...args) {
33
+ this.hooks[hook].forEach((hook) => {
40
34
  // @ts-ignore we know that it is the correct type, sunce HooksType is built from HookTypes
41
- hook.fn.apply(hook, args);
35
+ hook.fn(...args);
42
36
  });
43
- };
44
- return PluginManager;
45
- }());
37
+ }
38
+ }
46
39
  exports.PluginManager = PluginManager;
@@ -1,3 +1,3 @@
1
- import { PluginRegister } from "../types";
1
+ import { PluginRegister } from '../types';
2
2
  declare const register: PluginRegister;
3
3
  export default register;
@@ -1,36 +1,32 @@
1
1
  "use strict";
2
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;
3
+ const constants_1 = require("../../constants");
4
+ const events_1 = require("../../events");
5
+ const addFieldsToContentTypes = (state, schema) => {
6
+ const { apiSchemas } = schema;
7
+ Object.entries(apiSchemas).forEach(([strapiName, schema]) => {
8
+ const { attributes, options = {} } = schema.contentType;
10
9
  if ((options === null || options === void 0 ? void 0 : options.draftAndPublish) !== true) {
11
10
  return;
12
11
  }
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);
12
+ const fieldNames = ['publishedAt', 'createdAt', 'updatedAt'];
13
+ fieldNames.forEach((fieldName) => {
14
+ attributes[fieldName] = {
15
+ type: 'string',
16
+ required: true,
17
+ [constants_1.CERTAINLY_REQUIRED_KEY]: true,
18
+ };
22
19
  });
23
20
  });
24
21
  };
25
- var register = function () {
26
- var _a;
27
- return _a = {},
28
- _a[events_1.Events.AfterReadSchema] = [
22
+ const register = () => {
23
+ return {
24
+ [events_1.Events.AfterReadSchema]: [
29
25
  {
30
26
  fn: addFieldsToContentTypes,
31
27
  priority: 10,
32
28
  },
33
29
  ],
34
- _a;
30
+ };
35
31
  };
36
32
  exports.default = register;
@@ -1,3 +1,3 @@
1
- import { PluginRegister } from "../types";
1
+ import { PluginRegister } from '../types';
2
2
  declare const register: PluginRegister;
3
3
  export default register;
@@ -1,41 +1,36 @@
1
1
  "use strict";
2
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) {
3
+ const constants_1 = require("../../constants");
4
+ const events_1 = require("../../events");
5
+ const addLocaleToLocalizedContentTypes = (state, { apiSchemas }) => {
6
+ Object.entries(apiSchemas).forEach(([strapiName, schema]) => {
7
+ var _a, _b, _c;
8
+ const { attributes } = schema.contentType;
9
+ if (((_c = (_b = (_a = schema.contentType) === null || _a === void 0 ? void 0 : _a.pluginOptions) === null || _b === void 0 ? void 0 : _b.i18n) === null || _c === void 0 ? void 0 : _c.localized) !== true) {
13
10
  return;
14
11
  }
15
12
  // 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);
13
+ attributes.locale = {
14
+ type: 'string',
15
+ required: true,
16
+ [constants_1.CERTAINLY_REQUIRED_KEY]: true,
17
+ };
22
18
  // Add populatable field for localizations
23
19
  attributes.localizations = {
24
20
  type: 'relation',
25
21
  relation: 'oneToMany',
26
- target: "api::".concat(name, ".").concat(name), // TODO: make this more complete
22
+ target: strapiName
27
23
  };
28
24
  });
29
25
  };
30
- var register = function () {
31
- var _a;
32
- return _a = {},
33
- _a[events_1.Events.AfterReadSchema] = [
26
+ const register = () => {
27
+ return {
28
+ [events_1.Events.AfterReadSchema]: [
34
29
  {
35
30
  fn: addLocaleToLocalizedContentTypes,
36
31
  priority: 10,
37
32
  },
38
33
  ],
39
- _a;
34
+ };
40
35
  };
41
36
  exports.default = register;
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.registerBuiltinPlugins = void 0;
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"));
10
- var registerBuiltinPlugins = function (pluginManager, pluginNames) {
7
+ const url_alias_1 = __importDefault(require("./url-alias"));
8
+ const draft_and_publish_1 = __importDefault(require("./draft-and-publish"));
9
+ const i18n_1 = __importDefault(require("./i18n"));
10
+ const registerBuiltinPlugins = (pluginManager, pluginNames) => {
11
11
  // Draft and publish is always registered since it is built into Strapi
12
12
  pluginManager.registerPlugin((0, draft_and_publish_1.default)());
13
13
  if (pluginNames.has('url-alias')) {
@@ -1,4 +1,4 @@
1
- import { HooksType } from "./PluginManager";
1
+ import { HooksType } from './PluginManager';
2
2
  export declare const supportedPluginNames: readonly ["url-alias", "i18n"];
3
3
  export declare type SupportedPluginNamesType = typeof supportedPluginNames[number];
4
4
  export declare type PluginRegister = () => Partial<HooksType>;
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.supportedPluginNames = void 0;
4
- exports.supportedPluginNames = [
5
- 'url-alias',
6
- 'i18n',
7
- ];
4
+ exports.supportedPluginNames = ['url-alias', 'i18n'];
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var events_1 = require("../../events");
4
- var type_1 = require("./type");
5
- var addUrlAliasToAllContentTypes = function (state, _a) {
6
- var apiSchemas = _a.apiSchemas;
7
- apiSchemas.forEach(function (_a) {
8
- var name = _a.name, schema = _a.schema;
9
- var attributes = schema.attributes;
3
+ const events_1 = require("../../events");
4
+ const type_1 = require("./type");
5
+ const addUrlAliasToAllContentTypes = (state, { apiSchemas }) => {
6
+ Object.entries(apiSchemas).forEach(([strapiName, schema]) => {
7
+ const { attributes } = schema.contentType;
10
8
  // TODO: write comment here if it is intentional that it it can be null
11
9
  attributes.url_path = {
12
10
  type: 'string',
@@ -19,25 +17,24 @@ var addUrlAliasToAllContentTypes = function (state, _a) {
19
17
  // };
20
18
  });
21
19
  };
22
- var addUrlAliasGetType = function (state) {
23
- var urlAliasGet = new type_1.UrlAliasGet();
20
+ const addUrlAliasGetType = (state) => {
21
+ const urlAliasGet = new type_1.UrlAliasGet();
24
22
  state.addType(urlAliasGet.getStrapiName(), urlAliasGet);
25
23
  };
26
- var register = function () {
27
- var _a;
28
- return _a = {},
29
- _a[events_1.Events.AfterReadSchema] = [
24
+ const register = () => {
25
+ return {
26
+ [events_1.Events.AfterReadSchema]: [
30
27
  {
31
28
  fn: addUrlAliasToAllContentTypes,
32
29
  priority: 10,
33
30
  },
34
31
  ],
35
- _a[events_1.Events.AfterReadSchemas] = [
32
+ [events_1.Events.AfterReadSchemas]: [
36
33
  {
37
34
  fn: addUrlAliasGetType,
38
35
  priority: 10,
39
36
  },
40
37
  ],
41
- _a;
38
+ };
42
39
  };
43
40
  exports.default = register;
@@ -1,41 +1,30 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.UrlAliasGet = void 0;
19
- var File_1 = require("../../file/File");
4
+ const File_1 = require("../../file/File");
20
5
  /* 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;
6
+ class UrlAliasGet extends File_1.File {
7
+ constructor() {
8
+ const baseName = 'url-alias';
9
+ super(baseName, 'plugins/url-alias', 'pascal'); // TODO: figure out how to change the casing
26
10
  }
27
- UrlAliasGet.prototype.getStrapiName = function () {
11
+ getStrapiName() {
28
12
  return 'plugins::url-alias.get';
29
- };
30
- UrlAliasGet.prototype.getFullName = function () {
13
+ }
14
+ getFullName() {
31
15
  return 'UrlAliasGet';
32
- };
33
- UrlAliasGet.prototype.getDependencies = function () {
16
+ }
17
+ getDependencies() {
34
18
  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));
19
+ }
20
+ toString() {
21
+ return `
22
+ export type ${this.getFullName()}<ContentType extends { attributes: {} }> = ContentType & {
23
+ attributes: {
24
+ contentType: string;
25
+ },
26
+ }
27
+ `;
28
+ }
29
+ }
41
30
  exports.UrlAliasGet = UrlAliasGet;