@oak-digital/types-4-strapi-2 0.5.5 → 1.0.0-beta.2
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 +17 -5
- 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/load-strapi/remote.d.ts +1 -0
- package/lib/readers/load-strapi/remote.js +29 -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 +4 -2
- 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/database/migrations/.gitkeep +0 -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
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contentTypeAttribute = exports.attribute = exports.dynamiczoneAttribute = exports.componentAttribute = exports.relationAttribute = exports.morphToManyAttribute = exports.hasManyAttribute = exports.manyToManyAttribute = exports.manyToOneAttribute = exports.belongsToManyAttribute = exports.oneToOneAttribute = exports.hasOneAttribute = exports.baseRelationAttribute = exports.booleanAttribute = exports.mediaAttribute = exports.dateAttribute = exports.timeAttribute = exports.dateTimeAttribute = exports.dateOnlyAttribute = exports.enumAttribute = exports.numberAttribute = exports.decimalAttribute = exports.bigIntAttribute = exports.floatAttribute = exports.integerAttribute = exports.passwordAttribute = exports.jsonAttribute = exports.richTextAttribute = exports.uidAttribute = exports.emailAttribute = exports.textAttribute = exports.baseAttribute = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
exports.baseAttribute = zod_1.z.object({
|
|
7
|
+
pluginOptions: zod_1.z.any(),
|
|
8
|
+
required: zod_1.z.boolean().optional(),
|
|
9
|
+
[constants_1.CERTAINLY_REQUIRED_KEY]: zod_1.z.boolean().optional(),
|
|
10
|
+
});
|
|
11
|
+
exports.textAttribute = exports.baseAttribute.extend({
|
|
12
|
+
type: zod_1.z.enum(['text', 'string'])
|
|
13
|
+
});
|
|
14
|
+
exports.emailAttribute = exports.baseAttribute.extend({
|
|
15
|
+
type: zod_1.z.literal('email'),
|
|
16
|
+
});
|
|
17
|
+
exports.uidAttribute = exports.baseAttribute.extend({
|
|
18
|
+
type: zod_1.z.literal('uid'),
|
|
19
|
+
targetField: zod_1.z.string().optional(),
|
|
20
|
+
});
|
|
21
|
+
exports.richTextAttribute = exports.baseAttribute.extend({
|
|
22
|
+
type: zod_1.z.literal('richtext'),
|
|
23
|
+
});
|
|
24
|
+
exports.jsonAttribute = exports.baseAttribute.extend({
|
|
25
|
+
type: zod_1.z.literal('json'),
|
|
26
|
+
});
|
|
27
|
+
exports.passwordAttribute = exports.baseAttribute.extend({
|
|
28
|
+
type: zod_1.z.literal('password'),
|
|
29
|
+
});
|
|
30
|
+
exports.integerAttribute = exports.baseAttribute.extend({
|
|
31
|
+
type: zod_1.z.literal('integer'),
|
|
32
|
+
});
|
|
33
|
+
exports.floatAttribute = exports.baseAttribute.extend({
|
|
34
|
+
type: zod_1.z.literal('float'),
|
|
35
|
+
});
|
|
36
|
+
exports.bigIntAttribute = exports.baseAttribute.extend({
|
|
37
|
+
type: zod_1.z.literal('biginteger'),
|
|
38
|
+
});
|
|
39
|
+
exports.decimalAttribute = exports.baseAttribute.extend({
|
|
40
|
+
type: zod_1.z.literal('decimal'),
|
|
41
|
+
});
|
|
42
|
+
exports.numberAttribute = zod_1.z.union([
|
|
43
|
+
exports.integerAttribute,
|
|
44
|
+
exports.floatAttribute,
|
|
45
|
+
exports.bigIntAttribute,
|
|
46
|
+
exports.decimalAttribute,
|
|
47
|
+
]);
|
|
48
|
+
exports.enumAttribute = exports.baseAttribute.extend({
|
|
49
|
+
type: zod_1.z.literal('enumeration'),
|
|
50
|
+
enum: zod_1.z.array(zod_1.z.string()),
|
|
51
|
+
});
|
|
52
|
+
exports.dateOnlyAttribute = exports.baseAttribute.extend({
|
|
53
|
+
type: zod_1.z.literal('date'),
|
|
54
|
+
});
|
|
55
|
+
exports.dateTimeAttribute = exports.baseAttribute.extend({
|
|
56
|
+
type: zod_1.z.literal('datetime'),
|
|
57
|
+
});
|
|
58
|
+
exports.timeAttribute = exports.baseAttribute.extend({
|
|
59
|
+
type: zod_1.z.literal('time'),
|
|
60
|
+
});
|
|
61
|
+
exports.dateAttribute = zod_1.z.union([
|
|
62
|
+
exports.dateOnlyAttribute,
|
|
63
|
+
exports.dateTimeAttribute,
|
|
64
|
+
exports.timeAttribute,
|
|
65
|
+
]);
|
|
66
|
+
exports.mediaAttribute = exports.baseAttribute.extend({
|
|
67
|
+
type: zod_1.z.literal('media'),
|
|
68
|
+
multiple: zod_1.z.boolean().optional(),
|
|
69
|
+
allowedTypes: zod_1.z
|
|
70
|
+
.array(zod_1.z.enum(['images', 'videos', 'audios', 'files']))
|
|
71
|
+
.optional()
|
|
72
|
+
.default(['images', 'videos', 'audios', 'files']),
|
|
73
|
+
});
|
|
74
|
+
exports.booleanAttribute = exports.baseAttribute.extend({
|
|
75
|
+
type: zod_1.z.literal('boolean'),
|
|
76
|
+
});
|
|
77
|
+
exports.baseRelationAttribute = exports.baseAttribute.extend({
|
|
78
|
+
type: zod_1.z.literal('relation'),
|
|
79
|
+
target: zod_1.z.string(),
|
|
80
|
+
});
|
|
81
|
+
exports.hasOneAttribute = exports.baseRelationAttribute.extend({
|
|
82
|
+
relation: zod_1.z.literal('oneToOne'),
|
|
83
|
+
});
|
|
84
|
+
exports.oneToOneAttribute = exports.baseRelationAttribute.extend({
|
|
85
|
+
relation: zod_1.z.literal('oneToOne'),
|
|
86
|
+
inversedBy: zod_1.z.string(),
|
|
87
|
+
});
|
|
88
|
+
exports.belongsToManyAttribute = exports.baseRelationAttribute.extend({
|
|
89
|
+
mappedBy: zod_1.z.string(),
|
|
90
|
+
relation: zod_1.z.literal('oneToMany'),
|
|
91
|
+
});
|
|
92
|
+
exports.manyToOneAttribute = exports.baseRelationAttribute.extend({
|
|
93
|
+
relation: zod_1.z.literal('manyToOne'),
|
|
94
|
+
inversedBy: zod_1.z.string(),
|
|
95
|
+
});
|
|
96
|
+
exports.manyToManyAttribute = exports.baseRelationAttribute.extend({
|
|
97
|
+
relation: zod_1.z.literal('manyToMany'),
|
|
98
|
+
inversedBy: zod_1.z.string().optional(),
|
|
99
|
+
mappedBy: zod_1.z.string().optional(),
|
|
100
|
+
});
|
|
101
|
+
exports.hasManyAttribute = exports.baseRelationAttribute.extend({
|
|
102
|
+
relation: zod_1.z.literal('oneToMany'),
|
|
103
|
+
});
|
|
104
|
+
exports.morphToManyAttribute = zod_1.z.object({
|
|
105
|
+
type: zod_1.z.literal('relation'),
|
|
106
|
+
relation: zod_1.z.literal('morphToMany'),
|
|
107
|
+
});
|
|
108
|
+
exports.relationAttribute = zod_1.z.union([
|
|
109
|
+
exports.hasOneAttribute,
|
|
110
|
+
exports.oneToOneAttribute,
|
|
111
|
+
exports.belongsToManyAttribute,
|
|
112
|
+
exports.manyToOneAttribute,
|
|
113
|
+
exports.manyToManyAttribute,
|
|
114
|
+
exports.hasManyAttribute,
|
|
115
|
+
exports.morphToManyAttribute,
|
|
116
|
+
]);
|
|
117
|
+
exports.componentAttribute = exports.baseAttribute.extend({
|
|
118
|
+
type: zod_1.z.literal('component'),
|
|
119
|
+
repeatable: zod_1.z.boolean().optional(),
|
|
120
|
+
component: zod_1.z.string(),
|
|
121
|
+
});
|
|
122
|
+
exports.dynamiczoneAttribute = exports.baseAttribute.extend({
|
|
123
|
+
type: zod_1.z.literal('dynamiczone'),
|
|
124
|
+
components: zod_1.z.array(zod_1.z.string()),
|
|
125
|
+
});
|
|
126
|
+
exports.attribute = zod_1.z.union([
|
|
127
|
+
exports.textAttribute,
|
|
128
|
+
exports.emailAttribute,
|
|
129
|
+
exports.uidAttribute,
|
|
130
|
+
exports.richTextAttribute,
|
|
131
|
+
exports.jsonAttribute,
|
|
132
|
+
exports.passwordAttribute,
|
|
133
|
+
exports.numberAttribute,
|
|
134
|
+
exports.enumAttribute,
|
|
135
|
+
exports.dateAttribute,
|
|
136
|
+
exports.mediaAttribute,
|
|
137
|
+
exports.booleanAttribute,
|
|
138
|
+
exports.relationAttribute,
|
|
139
|
+
exports.componentAttribute,
|
|
140
|
+
]);
|
|
141
|
+
exports.contentTypeAttribute = zod_1.z.union([
|
|
142
|
+
exports.attribute,
|
|
143
|
+
exports.dynamiczoneAttribute,
|
|
144
|
+
]);
|