@oak-digital/types-4-strapi-2 1.0.5 → 1.0.7
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/lib/attributes/Attributes.js +3 -0
- package/lib/content-types/reader.js +5 -6
- package/lib/interface/builtinInterfaces.d.ts +389 -212
- package/lib/interface/builtinInterfaces.js +3 -3
- package/lib/program/InterfaceManager.d.ts +18 -181
- package/lib/readers/by-file.d.ts +18 -181
- package/lib/readers/load-strapi/index.d.ts +19 -181
- package/lib/utils/casing/index.js +3 -3
- package/lib/utils/index.js +2 -3
- package/package.json +50 -49
- package/lib/readers/types/attributes.d.ts +0 -2569
- package/lib/readers/types/attributes.js +0 -158
- package/lib/readers/types/component.d.ts +0 -793
- package/lib/readers/types/component.js +0 -11
- package/lib/readers/types/content-type-reader.d.ts +0 -16
- package/lib/readers/types/content-type-reader.js +0 -2
- package/lib/readers/types/content-type.d.ts +0 -836
- package/lib/readers/types/content-type.js +0 -16
- package/lib/writers/types/writer.d.ts +0 -4
- package/lib/writers/types/writer.js +0 -2
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.contentTypeAttribute = exports.isKnownAttribute = exports.attribute = exports.anyAttribute = exports.knownAttribute = exports.dynamiczoneAttribute = exports.componentAttribute = exports.relationAttribute = exports.morphOneAttribute = 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.blocksAttribute = 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().optional(),
|
|
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.blocksAttribute = exports.baseAttribute.extend({
|
|
25
|
-
type: zod_1.z.literal('blocks'),
|
|
26
|
-
// TODO: fill out the rest of the fields
|
|
27
|
-
});
|
|
28
|
-
exports.jsonAttribute = exports.baseAttribute.extend({
|
|
29
|
-
type: zod_1.z.literal('json'),
|
|
30
|
-
});
|
|
31
|
-
exports.passwordAttribute = exports.baseAttribute.extend({
|
|
32
|
-
type: zod_1.z.literal('password'),
|
|
33
|
-
});
|
|
34
|
-
exports.integerAttribute = exports.baseAttribute.extend({
|
|
35
|
-
type: zod_1.z.literal('integer'),
|
|
36
|
-
});
|
|
37
|
-
exports.floatAttribute = exports.baseAttribute.extend({
|
|
38
|
-
type: zod_1.z.literal('float'),
|
|
39
|
-
});
|
|
40
|
-
exports.bigIntAttribute = exports.baseAttribute.extend({
|
|
41
|
-
type: zod_1.z.literal('biginteger'),
|
|
42
|
-
});
|
|
43
|
-
exports.decimalAttribute = exports.baseAttribute.extend({
|
|
44
|
-
type: zod_1.z.literal('decimal'),
|
|
45
|
-
});
|
|
46
|
-
exports.numberAttribute = zod_1.z.discriminatedUnion('type', [
|
|
47
|
-
exports.integerAttribute,
|
|
48
|
-
exports.floatAttribute,
|
|
49
|
-
exports.bigIntAttribute,
|
|
50
|
-
exports.decimalAttribute,
|
|
51
|
-
]);
|
|
52
|
-
exports.enumAttribute = exports.baseAttribute.extend({
|
|
53
|
-
type: zod_1.z.literal('enumeration'),
|
|
54
|
-
enum: zod_1.z.array(zod_1.z.string()),
|
|
55
|
-
});
|
|
56
|
-
exports.dateOnlyAttribute = exports.baseAttribute.extend({
|
|
57
|
-
type: zod_1.z.literal('date'),
|
|
58
|
-
});
|
|
59
|
-
exports.dateTimeAttribute = exports.baseAttribute.extend({
|
|
60
|
-
type: zod_1.z.literal('datetime'),
|
|
61
|
-
});
|
|
62
|
-
exports.timeAttribute = exports.baseAttribute.extend({
|
|
63
|
-
type: zod_1.z.literal('time'),
|
|
64
|
-
});
|
|
65
|
-
exports.dateAttribute = zod_1.z.discriminatedUnion('type', [
|
|
66
|
-
exports.dateOnlyAttribute,
|
|
67
|
-
exports.dateTimeAttribute,
|
|
68
|
-
exports.timeAttribute,
|
|
69
|
-
]);
|
|
70
|
-
exports.mediaAttribute = exports.baseAttribute.extend({
|
|
71
|
-
type: zod_1.z.literal('media'),
|
|
72
|
-
multiple: zod_1.z.boolean().optional(),
|
|
73
|
-
allowedTypes: zod_1.z
|
|
74
|
-
.array(zod_1.z.enum(['images', 'videos', 'audios', 'files']))
|
|
75
|
-
.optional()
|
|
76
|
-
.default(['images', 'videos', 'audios', 'files']),
|
|
77
|
-
});
|
|
78
|
-
exports.booleanAttribute = exports.baseAttribute.extend({
|
|
79
|
-
type: zod_1.z.literal('boolean'),
|
|
80
|
-
});
|
|
81
|
-
exports.baseRelationAttribute = exports.baseAttribute.extend({
|
|
82
|
-
type: zod_1.z.literal('relation'),
|
|
83
|
-
target: zod_1.z.string(),
|
|
84
|
-
});
|
|
85
|
-
exports.hasOneAttribute = exports.baseRelationAttribute.extend({
|
|
86
|
-
relation: zod_1.z.literal('oneToOne'),
|
|
87
|
-
});
|
|
88
|
-
exports.oneToOneAttribute = exports.baseRelationAttribute.extend({
|
|
89
|
-
relation: zod_1.z.literal('oneToOne'),
|
|
90
|
-
inversedBy: zod_1.z.string(),
|
|
91
|
-
});
|
|
92
|
-
exports.belongsToManyAttribute = exports.baseRelationAttribute.extend({
|
|
93
|
-
mappedBy: zod_1.z.string(),
|
|
94
|
-
relation: zod_1.z.literal('oneToMany'),
|
|
95
|
-
});
|
|
96
|
-
exports.manyToOneAttribute = exports.baseRelationAttribute.extend({
|
|
97
|
-
relation: zod_1.z.literal('manyToOne'),
|
|
98
|
-
inversedBy: zod_1.z.string(),
|
|
99
|
-
});
|
|
100
|
-
exports.manyToManyAttribute = exports.baseRelationAttribute.extend({
|
|
101
|
-
relation: zod_1.z.literal('manyToMany'),
|
|
102
|
-
inversedBy: zod_1.z.string().optional(),
|
|
103
|
-
mappedBy: zod_1.z.string().optional(),
|
|
104
|
-
});
|
|
105
|
-
exports.hasManyAttribute = exports.baseRelationAttribute.extend({
|
|
106
|
-
relation: zod_1.z.literal('oneToMany'),
|
|
107
|
-
});
|
|
108
|
-
exports.morphToManyAttribute = exports.baseAttribute.extend({
|
|
109
|
-
type: zod_1.z.literal('relation'),
|
|
110
|
-
relation: zod_1.z.literal('morphToMany'),
|
|
111
|
-
});
|
|
112
|
-
exports.morphOneAttribute = exports.baseAttribute.extend({
|
|
113
|
-
type: zod_1.z.literal('relation'),
|
|
114
|
-
relation: zod_1.z.literal('morphToOne'),
|
|
115
|
-
});
|
|
116
|
-
exports.relationAttribute = zod_1.z.union([
|
|
117
|
-
exports.hasOneAttribute,
|
|
118
|
-
exports.oneToOneAttribute,
|
|
119
|
-
exports.belongsToManyAttribute,
|
|
120
|
-
exports.manyToOneAttribute,
|
|
121
|
-
exports.manyToManyAttribute,
|
|
122
|
-
exports.hasManyAttribute,
|
|
123
|
-
exports.morphToManyAttribute,
|
|
124
|
-
exports.morphOneAttribute,
|
|
125
|
-
]);
|
|
126
|
-
exports.componentAttribute = exports.baseAttribute.extend({
|
|
127
|
-
type: zod_1.z.literal('component'),
|
|
128
|
-
repeatable: zod_1.z.boolean().optional(),
|
|
129
|
-
component: zod_1.z.string(),
|
|
130
|
-
});
|
|
131
|
-
exports.dynamiczoneAttribute = exports.baseAttribute.extend({
|
|
132
|
-
type: zod_1.z.literal('dynamiczone'),
|
|
133
|
-
components: zod_1.z.array(zod_1.z.string()),
|
|
134
|
-
});
|
|
135
|
-
exports.knownAttribute = zod_1.z.union([
|
|
136
|
-
exports.textAttribute,
|
|
137
|
-
exports.emailAttribute,
|
|
138
|
-
exports.uidAttribute,
|
|
139
|
-
exports.richTextAttribute,
|
|
140
|
-
exports.jsonAttribute,
|
|
141
|
-
exports.passwordAttribute,
|
|
142
|
-
...exports.numberAttribute.options,
|
|
143
|
-
exports.enumAttribute,
|
|
144
|
-
...exports.dateAttribute.options,
|
|
145
|
-
exports.mediaAttribute,
|
|
146
|
-
exports.booleanAttribute,
|
|
147
|
-
...exports.relationAttribute.options,
|
|
148
|
-
exports.componentAttribute,
|
|
149
|
-
]);
|
|
150
|
-
exports.anyAttribute = exports.baseAttribute.extend({
|
|
151
|
-
type: zod_1.z.custom(val => !exports.knownAttribute.options.some(schema => schema.shape.type.safeParse(val).success)).transform(() => 'any'),
|
|
152
|
-
}).passthrough();
|
|
153
|
-
exports.attribute = zod_1.z.union([...exports.knownAttribute.options, exports.anyAttribute]);
|
|
154
|
-
const isKnownAttribute = (attributeObject) => {
|
|
155
|
-
return exports.attribute.safeParse(attributeObject).success;
|
|
156
|
-
};
|
|
157
|
-
exports.isKnownAttribute = isKnownAttribute;
|
|
158
|
-
exports.contentTypeAttribute = zod_1.z.union([exports.attribute, exports.dynamiczoneAttribute]);
|