@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.
- package/.eslintrc.json +2 -1
- package/CHANGELOG.md +7 -0
- package/README.md +21 -8
- package/lib/attributes/Attributes.d.ts +4 -3
- package/lib/attributes/Attributes.js +102 -78
- package/lib/content-types/reader.js +49 -145
- package/lib/extra-types/ExtraType.d.ts +2 -2
- package/lib/extra-types/ExtraType.js +19 -38
- package/lib/extra-types/createExtraTypes.d.ts +1 -1
- package/lib/extra-types/createExtraTypes.js +11 -12
- package/lib/file/File.d.ts +1 -1
- package/lib/file/File.js +44 -43
- package/lib/index.js +57 -19
- package/lib/interface/BuiltinComponentInterface.js +9 -27
- package/lib/interface/BuiltinInterface.d.ts +0 -1
- package/lib/interface/BuiltinInterface.js +5 -26
- package/lib/interface/ComponentInterface.d.ts +2 -1
- package/lib/interface/ComponentInterface.js +30 -48
- package/lib/interface/Interface.d.ts +6 -2
- package/lib/interface/Interface.js +69 -70
- package/lib/interface/builtinInterfaces.d.ts +1941 -2
- package/lib/interface/builtinInterfaces.js +56 -46
- package/lib/plugins/PluginManager.d.ts +8 -2
- package/lib/plugins/PluginManager.js +28 -35
- package/lib/plugins/draft-and-publish/index.d.ts +1 -1
- package/lib/plugins/draft-and-publish/index.js +17 -21
- package/lib/plugins/i18n/index.d.ts +1 -1
- package/lib/plugins/i18n/index.js +17 -22
- package/lib/plugins/index.js +4 -4
- package/lib/plugins/types.d.ts +1 -1
- package/lib/plugins/types.js +1 -4
- package/lib/plugins/url-alias/index.js +12 -15
- package/lib/plugins/url-alias/type.js +21 -32
- package/lib/program/InterfaceManager.d.ts +374 -24
- package/lib/program/InterfaceManager.js +128 -376
- package/lib/readers/by-file.d.ts +321 -0
- package/lib/readers/by-file.js +116 -0
- package/lib/readers/load-strapi/index.d.ts +319 -0
- package/lib/readers/load-strapi/index.js +106 -0
- package/lib/readers/types/attributes.d.ts +1639 -0
- package/lib/readers/types/attributes.js +144 -0
- package/lib/readers/types/component.d.ts +723 -0
- package/lib/readers/types/component.js +11 -0
- package/lib/readers/types/content-type-reader.d.ts +16 -0
- package/lib/readers/types/content-type-reader.js +2 -0
- package/lib/readers/types/content-type.d.ts +766 -0
- package/lib/readers/types/content-type.js +16 -0
- package/lib/utils/casing/index.js +2 -2
- package/lib/utils/index.js +5 -39
- package/lib/writers/basic-writer.d.ts +24 -0
- package/lib/writers/basic-writer.js +75 -0
- package/lib/writers/types/writer.d.ts +4 -0
- package/lib/writers/types/writer.js +2 -0
- package/package.json +12 -9
- package/tests/strapi-project/.editorconfig +16 -0
- package/tests/strapi-project/.env.example +6 -0
- package/tests/strapi-project/README.md +57 -0
- package/tests/strapi-project/config/admin.ts +13 -0
- package/tests/strapi-project/config/api.ts +7 -0
- package/tests/strapi-project/config/database.ts +93 -0
- package/tests/strapi-project/config/middlewares.ts +12 -0
- package/tests/strapi-project/config/server.ts +10 -0
- package/tests/strapi-project/favicon.png +0 -0
- package/tests/strapi-project/package-lock.json +16125 -0
- package/tests/strapi-project/package.json +30 -0
- package/tests/strapi-project/public/robots.txt +3 -0
- package/tests/strapi-project/public/uploads/.gitkeep +0 -0
- package/tests/strapi-project/src/admin/app.example.tsx +35 -0
- package/tests/strapi-project/src/admin/webpack.config.example.js +9 -0
- package/tests/strapi-project/src/api/.gitkeep +0 -0
- package/tests/strapi-project/src/api/collection-1/content-types/collection-1/schema.json +18 -0
- package/tests/strapi-project/src/api/collection-1/content-types/generated-type/schema.json +18 -0
- package/tests/strapi-project/src/api/collection-1/controllers/collection-1.ts +7 -0
- package/tests/strapi-project/src/api/collection-1/controllers/generated-type.ts +7 -0
- package/tests/strapi-project/src/api/collection-1/routes/collection-1.ts +7 -0
- package/tests/strapi-project/src/api/collection-1/routes/generated-type.ts +7 -0
- package/tests/strapi-project/src/api/collection-1/services/collection-1.ts +7 -0
- package/tests/strapi-project/src/api/collection-1/services/generated-type.ts +7 -0
- package/tests/strapi-project/src/api/standalone-controller/controllers/standalone-controller.ts +13 -0
- package/tests/strapi-project/src/components/my-category/all-types.json +88 -0
- package/tests/strapi-project/src/components/other-category/sub-component.json +12 -0
- package/tests/strapi-project/src/extensions/.gitkeep +0 -0
- package/tests/strapi-project/src/index.ts +18 -0
- package/lib/.prettierrc.json +0 -7
- package/lib/case/index.d.ts +0 -4
- package/lib/case/index.js +0 -47
- package/lib/interface/Attributes.d.ts +0 -11
- package/lib/interface/Attributes.js +0 -167
- package/lib/interface/InterfaceManager.d.ts +0 -39
- package/lib/interface/InterfaceManager.js +0 -396
- package/lib/interface/interfaceCreator.js +0 -7
- package/lib/interface/interfaceWriter.d.ts +0 -2
- package/lib/interface/interfaceWriter.js +0 -46
- package/lib/interface/schemaReader.d.ts +0 -14
- package/lib/interface/schemaReader.js +0 -177
- package/lib/src/index.d.ts +0 -1
- package/lib/src/index.js +0 -25
- package/lib/src/interface/Attributes.d.ts +0 -11
- package/lib/src/interface/Attributes.js +0 -148
- package/lib/src/interface/BuiltinComponentInterface.d.ts +0 -5
- package/lib/src/interface/BuiltinComponentInterface.js +0 -36
- package/lib/src/interface/BuiltinInterface.d.ts +0 -5
- package/lib/src/interface/BuiltinInterface.js +0 -33
- package/lib/src/interface/ComponentInterface.d.ts +0 -8
- package/lib/src/interface/ComponentInterface.js +0 -58
- package/lib/src/interface/Interface.d.ts +0 -31
- package/lib/src/interface/Interface.js +0 -112
- package/lib/src/interface/InterfaceManager.d.ts +0 -25
- package/lib/src/interface/InterfaceManager.js +0 -288
- package/lib/src/interface/builtinInterfaces.d.ts +0 -4
- package/lib/src/interface/builtinInterfaces.js +0 -81
- package/lib/src/interface/schemaReader.d.ts +0 -14
- package/lib/src/interface/schemaReader.js +0 -172
- package/lib/src/utils/index.d.ts +0 -3
- package/lib/src/utils/index.js +0 -67
- /package/{lib/interface/interfaceCreator.d.ts → tests/strapi-project/database/migrations/.gitkeep} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "strapi-project",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "A Strapi application",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"develop": "strapi develop",
|
|
8
|
+
"start": "strapi start",
|
|
9
|
+
"build": "strapi build",
|
|
10
|
+
"strapi": "strapi"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@strapi/strapi": "4.10.5",
|
|
15
|
+
"@strapi/plugin-users-permissions": "4.10.5",
|
|
16
|
+
"@strapi/plugin-i18n": "4.10.5",
|
|
17
|
+
"better-sqlite3": "8.0.1"
|
|
18
|
+
},
|
|
19
|
+
"author": {
|
|
20
|
+
"name": "A Strapi developer"
|
|
21
|
+
},
|
|
22
|
+
"strapi": {
|
|
23
|
+
"uuid": "06c55e27-9078-4e51-a92e-0f4c5b1fdea4"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=14.19.1 <=18.x.x",
|
|
27
|
+
"npm": ">=6.0.0"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT"
|
|
30
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
config: {
|
|
3
|
+
locales: [
|
|
4
|
+
// 'ar',
|
|
5
|
+
// 'fr',
|
|
6
|
+
// 'cs',
|
|
7
|
+
// 'de',
|
|
8
|
+
// 'dk',
|
|
9
|
+
// 'es',
|
|
10
|
+
// 'he',
|
|
11
|
+
// 'id',
|
|
12
|
+
// 'it',
|
|
13
|
+
// 'ja',
|
|
14
|
+
// 'ko',
|
|
15
|
+
// 'ms',
|
|
16
|
+
// 'nl',
|
|
17
|
+
// 'no',
|
|
18
|
+
// 'pl',
|
|
19
|
+
// 'pt-BR',
|
|
20
|
+
// 'pt',
|
|
21
|
+
// 'ru',
|
|
22
|
+
// 'sk',
|
|
23
|
+
// 'sv',
|
|
24
|
+
// 'th',
|
|
25
|
+
// 'tr',
|
|
26
|
+
// 'uk',
|
|
27
|
+
// 'vi',
|
|
28
|
+
// 'zh-Hans',
|
|
29
|
+
// 'zh',
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
bootstrap(app) {
|
|
33
|
+
console.log(app);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable no-unused-vars */
|
|
4
|
+
module.exports = (config, webpack) => {
|
|
5
|
+
// Note: we provide webpack above so you should not `require` it
|
|
6
|
+
// Perform customizations to webpack config
|
|
7
|
+
// Important: return the modified config
|
|
8
|
+
return config;
|
|
9
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "collectionType",
|
|
3
|
+
"collectionName": "collection_1s",
|
|
4
|
+
"info": {
|
|
5
|
+
"singularName": "collection-1",
|
|
6
|
+
"pluralName": "collection-1s",
|
|
7
|
+
"displayName": "Collection 1"
|
|
8
|
+
},
|
|
9
|
+
"options": {
|
|
10
|
+
"draftAndPublish": true
|
|
11
|
+
},
|
|
12
|
+
"pluginOptions": {},
|
|
13
|
+
"attributes": {
|
|
14
|
+
"text": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "collectionType",
|
|
3
|
+
"collectionName": "generated_types",
|
|
4
|
+
"info": {
|
|
5
|
+
"singularName": "generated-type",
|
|
6
|
+
"pluralName": "generated-types",
|
|
7
|
+
"displayName": "Generated type"
|
|
8
|
+
},
|
|
9
|
+
"options": {
|
|
10
|
+
"draftAndPublish": false,
|
|
11
|
+
"comment": ""
|
|
12
|
+
},
|
|
13
|
+
"attributes": {
|
|
14
|
+
"text": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"collectionName": "components_my_category_all_types",
|
|
3
|
+
"info": {
|
|
4
|
+
"displayName": "All types",
|
|
5
|
+
"description": ""
|
|
6
|
+
},
|
|
7
|
+
"options": {},
|
|
8
|
+
"attributes": {
|
|
9
|
+
"text": {
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"email": {
|
|
13
|
+
"type": "email"
|
|
14
|
+
},
|
|
15
|
+
"rich": {
|
|
16
|
+
"type": "richtext"
|
|
17
|
+
},
|
|
18
|
+
"pswd": {
|
|
19
|
+
"type": "password"
|
|
20
|
+
},
|
|
21
|
+
"int": {
|
|
22
|
+
"type": "integer"
|
|
23
|
+
},
|
|
24
|
+
"bigint": {
|
|
25
|
+
"type": "biginteger"
|
|
26
|
+
},
|
|
27
|
+
"decimal": {
|
|
28
|
+
"type": "decimal"
|
|
29
|
+
},
|
|
30
|
+
"float": {
|
|
31
|
+
"type": "float"
|
|
32
|
+
},
|
|
33
|
+
"enum": {
|
|
34
|
+
"type": "enumeration",
|
|
35
|
+
"enum": [
|
|
36
|
+
"a",
|
|
37
|
+
"b",
|
|
38
|
+
"c"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"date": {
|
|
42
|
+
"type": "date"
|
|
43
|
+
},
|
|
44
|
+
"datetime": {
|
|
45
|
+
"type": "datetime"
|
|
46
|
+
},
|
|
47
|
+
"time": {
|
|
48
|
+
"type": "time"
|
|
49
|
+
},
|
|
50
|
+
"multipleMedia": {
|
|
51
|
+
"type": "media",
|
|
52
|
+
"multiple": true,
|
|
53
|
+
"required": false,
|
|
54
|
+
"allowedTypes": [
|
|
55
|
+
"images",
|
|
56
|
+
"files",
|
|
57
|
+
"videos",
|
|
58
|
+
"audios"
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
"singleImage": {
|
|
62
|
+
"type": "media",
|
|
63
|
+
"multiple": false,
|
|
64
|
+
"required": false,
|
|
65
|
+
"allowedTypes": [
|
|
66
|
+
"images"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"bool": {
|
|
70
|
+
"type": "boolean",
|
|
71
|
+
"required": true
|
|
72
|
+
},
|
|
73
|
+
"json": {
|
|
74
|
+
"type": "json"
|
|
75
|
+
},
|
|
76
|
+
"repeatable": {
|
|
77
|
+
"displayName": "subComponent",
|
|
78
|
+
"type": "component",
|
|
79
|
+
"repeatable": true,
|
|
80
|
+
"component": "other-category.sub-component"
|
|
81
|
+
},
|
|
82
|
+
"component": {
|
|
83
|
+
"type": "component",
|
|
84
|
+
"repeatable": false,
|
|
85
|
+
"component": "other-category.sub-component"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
/**
|
|
3
|
+
* An asynchronous register function that runs before
|
|
4
|
+
* your application is initialized.
|
|
5
|
+
*
|
|
6
|
+
* This gives you an opportunity to extend code.
|
|
7
|
+
*/
|
|
8
|
+
register(/*{ strapi }*/) {},
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* An asynchronous bootstrap function that runs before
|
|
12
|
+
* your application gets started.
|
|
13
|
+
*
|
|
14
|
+
* This gives you an opportunity to set up your data model,
|
|
15
|
+
* run jobs, or perform some special logic.
|
|
16
|
+
*/
|
|
17
|
+
bootstrap(/*{ strapi }*/) {},
|
|
18
|
+
};
|
package/lib/.prettierrc.json
DELETED
package/lib/case/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const caseTypesArray: readonly ["camel", "capital", "dot", "snake", "pascal", "constant", "kebab"];
|
|
2
|
-
export declare type caseType = typeof caseTypesArray[number];
|
|
3
|
-
export declare function checkCaseType(caseName: caseType): caseName is caseType;
|
|
4
|
-
export declare function changeCase(text: string, caseName: caseType): string;
|
package/lib/case/index.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.changeCase = exports.checkCaseType = exports.caseTypesArray = void 0;
|
|
4
|
-
var change_case_1 = require("change-case");
|
|
5
|
-
exports.caseTypesArray = [
|
|
6
|
-
'camel',
|
|
7
|
-
'capital',
|
|
8
|
-
'dot',
|
|
9
|
-
'snake',
|
|
10
|
-
'pascal',
|
|
11
|
-
'constant',
|
|
12
|
-
'kebab',
|
|
13
|
-
];
|
|
14
|
-
function checkCaseType(caseName) {
|
|
15
|
-
return exports.caseTypesArray.includes(caseName);
|
|
16
|
-
}
|
|
17
|
-
exports.checkCaseType = checkCaseType;
|
|
18
|
-
function changeCase(text, caseName) {
|
|
19
|
-
var name = text;
|
|
20
|
-
switch (caseName) {
|
|
21
|
-
case 'dot':
|
|
22
|
-
name = (0, change_case_1.dotCase)(name);
|
|
23
|
-
break;
|
|
24
|
-
case 'camel':
|
|
25
|
-
name = (0, change_case_1.camelCase)(name);
|
|
26
|
-
break;
|
|
27
|
-
case 'snake':
|
|
28
|
-
name = (0, change_case_1.snakeCase)(name);
|
|
29
|
-
break;
|
|
30
|
-
case 'capital':
|
|
31
|
-
name = (0, change_case_1.capitalCase)(name);
|
|
32
|
-
break;
|
|
33
|
-
case 'constant':
|
|
34
|
-
name = (0, change_case_1.constantCase)(name);
|
|
35
|
-
break;
|
|
36
|
-
case 'kebab':
|
|
37
|
-
// paramcase is the same as kebab
|
|
38
|
-
name = (0, change_case_1.paramCase)(name);
|
|
39
|
-
break;
|
|
40
|
-
case 'pascal':
|
|
41
|
-
default:
|
|
42
|
-
name = (0, change_case_1.pascalCase)(name);
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
return name;
|
|
46
|
-
}
|
|
47
|
-
exports.changeCase = changeCase;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { RelationNames } from './Interface';
|
|
2
|
-
export default class Attributes {
|
|
3
|
-
Attrs: Record<string, Record<string, any>>;
|
|
4
|
-
private RelationNames;
|
|
5
|
-
constructor(attr: Record<string, Record<string, any>>, relationNames: RelationNames);
|
|
6
|
-
isAttributeOptional(attr: any): boolean;
|
|
7
|
-
getDependencies(): any[];
|
|
8
|
-
attributeToString(attrName: string, attr: any): string;
|
|
9
|
-
toFieldsString(): string;
|
|
10
|
-
toString(): string;
|
|
11
|
-
}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var Attributes = /** @class */ (function () {
|
|
4
|
-
function Attributes(attr, relationNames) {
|
|
5
|
-
this.RelationNames = {};
|
|
6
|
-
this.Attrs = attr;
|
|
7
|
-
this.RelationNames = relationNames;
|
|
8
|
-
}
|
|
9
|
-
Attributes.prototype.isAttributeOptional = function (attr) {
|
|
10
|
-
// If it is a component / relation / dynamiczone it is always optional due to population
|
|
11
|
-
switch (attr.type) {
|
|
12
|
-
case 'nested':
|
|
13
|
-
return attr.nullable === true;
|
|
14
|
-
case 'component':
|
|
15
|
-
case 'dynamiczone':
|
|
16
|
-
case 'relation':
|
|
17
|
-
return true;
|
|
18
|
-
default:
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
return false;
|
|
22
|
-
};
|
|
23
|
-
Attributes.prototype.getDependencies = function () {
|
|
24
|
-
var dependencies = [];
|
|
25
|
-
for (var attrName in this.Attrs) {
|
|
26
|
-
var attr = this.Attrs[attrName];
|
|
27
|
-
var dependencyNames = [];
|
|
28
|
-
switch (attr.type) {
|
|
29
|
-
case 'nested':
|
|
30
|
-
var attrs = new Attributes(attr.fields, this.RelationNames);
|
|
31
|
-
dependencyNames.push.apply(dependencyNames, attrs.getDependencies());
|
|
32
|
-
break;
|
|
33
|
-
case 'relation':
|
|
34
|
-
dependencyNames.push(attr.target);
|
|
35
|
-
break;
|
|
36
|
-
case 'component':
|
|
37
|
-
dependencyNames.push(attr.component);
|
|
38
|
-
break;
|
|
39
|
-
case 'media':
|
|
40
|
-
dependencyNames.push('builtins::Media');
|
|
41
|
-
break;
|
|
42
|
-
case 'dynamiczone':
|
|
43
|
-
dependencyNames.push.apply(dependencyNames, attr.components);
|
|
44
|
-
break;
|
|
45
|
-
default:
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
// // If the current dependency is the interface itself, do not report it as a dependency
|
|
49
|
-
// if (dependencyName === strapiName) {
|
|
50
|
-
// continue;
|
|
51
|
-
// }
|
|
52
|
-
dependencyNames.forEach(function (dependencyName) {
|
|
53
|
-
if (!dependencies.includes(dependencyName)) {
|
|
54
|
-
dependencies.push(dependencyName);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return dependencies;
|
|
59
|
-
};
|
|
60
|
-
Attributes.prototype.attributeToString = function (attrName, attr) {
|
|
61
|
-
var _this = this;
|
|
62
|
-
var _a, _b, _c, _d;
|
|
63
|
-
var optionalString = this.isAttributeOptional(attr) ? '?' : '';
|
|
64
|
-
var orNull = ' | null';
|
|
65
|
-
var requiredString = attr.required !== true ? orNull : '';
|
|
66
|
-
var str = " ".concat(attrName).concat(optionalString, ": ");
|
|
67
|
-
var isArray = false;
|
|
68
|
-
switch (attr.type) {
|
|
69
|
-
// types-4-strapi-2 specific, used for builtin types
|
|
70
|
-
case 'nested':
|
|
71
|
-
// Be careful with recursion
|
|
72
|
-
// console.log(attr);
|
|
73
|
-
var nullableString = ((_a = attr === null || attr === void 0 ? void 0 : attr.nullable) !== null && _a !== void 0 ? _a : false) ? ' | null' : '';
|
|
74
|
-
var newAttrs = new Attributes(attr.fields, this.RelationNames);
|
|
75
|
-
str += newAttrs.toString() + nullableString;
|
|
76
|
-
break;
|
|
77
|
-
case 'relation':
|
|
78
|
-
var apiName = attr.target;
|
|
79
|
-
// console.log(this.RelationNames, apiName)
|
|
80
|
-
var dependencyName = (_c = (_b = this.RelationNames[apiName]) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : 'any';
|
|
81
|
-
var relationMultipleString = attr.relation.endsWith('ToMany') ? '[]' : orNull;
|
|
82
|
-
str += "{ data: ".concat(dependencyName).concat(relationMultipleString, "; }");
|
|
83
|
-
break;
|
|
84
|
-
case 'component':
|
|
85
|
-
var componentName = attr.component;
|
|
86
|
-
var relationNameObj = this.RelationNames[componentName];
|
|
87
|
-
var dependencyComponentName = relationNameObj.name;
|
|
88
|
-
isArray = (_d = attr.repeatable) !== null && _d !== void 0 ? _d : false;
|
|
89
|
-
str += dependencyComponentName;
|
|
90
|
-
break;
|
|
91
|
-
case 'media':
|
|
92
|
-
var mediaMultipleString = attr.multiple ? '[]' : requiredString;
|
|
93
|
-
str += "{ data: ".concat(this.RelationNames['builtins::Media'].name).concat(mediaMultipleString, "; }");
|
|
94
|
-
break;
|
|
95
|
-
case 'password':
|
|
96
|
-
return null;
|
|
97
|
-
case 'enumeration':
|
|
98
|
-
var hasDefault = 'default' in attr;
|
|
99
|
-
var enums = attr.enum.map(function (en) { return "\"".concat(en, "\""); });
|
|
100
|
-
enums.push('null');
|
|
101
|
-
var typeString = enums.join(' | ');
|
|
102
|
-
str += typeString;
|
|
103
|
-
break;
|
|
104
|
-
case 'dynamiczone':
|
|
105
|
-
// console.log(attr.components);
|
|
106
|
-
var relations = attr.components
|
|
107
|
-
.map(function (componentName) { return _this.RelationNames[componentName].name; });
|
|
108
|
-
// console.log(relations);
|
|
109
|
-
var relationsString = relations.join(' | ');
|
|
110
|
-
// console.log(relationsString);
|
|
111
|
-
str += "Array<".concat(relationsString, ">");
|
|
112
|
-
break;
|
|
113
|
-
case 'string':
|
|
114
|
-
case 'text':
|
|
115
|
-
case 'richtext':
|
|
116
|
-
case 'email':
|
|
117
|
-
case 'uid':
|
|
118
|
-
str += 'string';
|
|
119
|
-
str += requiredString;
|
|
120
|
-
break;
|
|
121
|
-
case 'integer':
|
|
122
|
-
case 'biginteger':
|
|
123
|
-
case 'decimal':
|
|
124
|
-
case 'float':
|
|
125
|
-
str += 'number';
|
|
126
|
-
str += requiredString;
|
|
127
|
-
break;
|
|
128
|
-
case 'date':
|
|
129
|
-
case 'datetime':
|
|
130
|
-
case 'time':
|
|
131
|
-
str += 'string';
|
|
132
|
-
str += requiredString;
|
|
133
|
-
break;
|
|
134
|
-
case 'boolean':
|
|
135
|
-
str += attr.type;
|
|
136
|
-
str += requiredString;
|
|
137
|
-
break;
|
|
138
|
-
case 'json':
|
|
139
|
-
default:
|
|
140
|
-
str += 'any';
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
var isArrayString = isArray ? '[]' : '';
|
|
144
|
-
str += "".concat(isArrayString, ";");
|
|
145
|
-
return str;
|
|
146
|
-
};
|
|
147
|
-
Attributes.prototype.toFieldsString = function () {
|
|
148
|
-
var strings = [];
|
|
149
|
-
for (var attrName in this.Attrs) {
|
|
150
|
-
var attr = this.Attrs[attrName];
|
|
151
|
-
var attrString = this.attributeToString(attrName, attr);
|
|
152
|
-
if (attrString === null) {
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
strings.push(attrString);
|
|
156
|
-
}
|
|
157
|
-
return strings.map(function (s) { return "".concat(s, "\n"); }).join('');
|
|
158
|
-
};
|
|
159
|
-
Attributes.prototype.toString = function () {
|
|
160
|
-
var strings = ['{'];
|
|
161
|
-
strings.push(this.toFieldsString());
|
|
162
|
-
strings.push('}');
|
|
163
|
-
return strings.join('\n');
|
|
164
|
-
};
|
|
165
|
-
return Attributes;
|
|
166
|
-
}());
|
|
167
|
-
exports.default = Attributes;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import EventEmitter from 'events';
|
|
3
|
-
export default class InterfaceManager {
|
|
4
|
-
private Interfaces;
|
|
5
|
-
private OutRoot;
|
|
6
|
-
private StrapiSrcRoot;
|
|
7
|
-
private Options;
|
|
8
|
-
private PrettierOptions;
|
|
9
|
-
eventEmitter: EventEmitter;
|
|
10
|
-
static BaseOptions: {
|
|
11
|
-
prefix: string;
|
|
12
|
-
useCategoryPrefix: boolean;
|
|
13
|
-
componentPrefix: string;
|
|
14
|
-
componentPrefixOverridesPrefix: boolean;
|
|
15
|
-
builtinsPrefix: string;
|
|
16
|
-
builtinsPrefixOverridesPrefix: boolean;
|
|
17
|
-
deleteOld: boolean;
|
|
18
|
-
prettierFile: any;
|
|
19
|
-
fileCaseType: "pascal" | "camel" | "capital" | "dot" | "snake" | "constant" | "kebab";
|
|
20
|
-
folderCaseType: "pascal" | "camel" | "capital" | "dot" | "snake" | "constant" | "kebab";
|
|
21
|
-
enabledPlugins: "url-alias"[];
|
|
22
|
-
};
|
|
23
|
-
constructor(outRoot: string, strapiSrcRoot: string, options?: Partial<typeof InterfaceManager['BaseOptions']>);
|
|
24
|
-
registerPlugins(): void;
|
|
25
|
-
validateOptions(): void;
|
|
26
|
-
loadPrettierConfig(): Promise<void>;
|
|
27
|
-
readSchemas(): Promise<{
|
|
28
|
-
apiSchemas: any[];
|
|
29
|
-
componentSchemas: any[];
|
|
30
|
-
}>;
|
|
31
|
-
createInterfaces(): Promise<void>;
|
|
32
|
-
createBuiltinInterfaces(): void;
|
|
33
|
-
injectDependencies(): void;
|
|
34
|
-
deleteOldFolders(): Promise<void>;
|
|
35
|
-
makeFolders(): Promise<void>;
|
|
36
|
-
writeInterfaces(): Promise<void>;
|
|
37
|
-
writeIndexFile(): Promise<void>;
|
|
38
|
-
run(): Promise<void>;
|
|
39
|
-
}
|