@oak-digital/types-4-strapi-2 1.0.2 → 1.0.3
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/.github/workflows/publish.yml +2 -0
- package/README.md +1 -3
- package/lib/attributes/Attributes.js +4 -2
- package/lib/interface/builtinInterfaces.d.ts +39 -0
- package/lib/program/InterfaceManager.d.ts +6 -0
- package/lib/readers/by-file.d.ts +6 -0
- package/lib/readers/load-strapi/index.d.ts +6 -0
- package/lib/readers/types/attributes.d.ts +37 -0
- package/lib/readers/types/attributes.js +8 -6
- package/lib/readers/types/component.d.ts +15 -0
- package/lib/readers/types/content-type.d.ts +15 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -58,7 +58,8 @@ class Attributes {
|
|
|
58
58
|
deps.forEach((dep) => dependencies.add(dep));
|
|
59
59
|
break;
|
|
60
60
|
case 'relation':
|
|
61
|
-
if (attr.relation === 'morphToMany'
|
|
61
|
+
if (attr.relation === 'morphToMany' ||
|
|
62
|
+
attr.relation === 'morphToOne') {
|
|
62
63
|
break;
|
|
63
64
|
}
|
|
64
65
|
dependencies.add(attr.target);
|
|
@@ -109,7 +110,8 @@ class Attributes {
|
|
|
109
110
|
str += newAttrs.toString() + nullableString;
|
|
110
111
|
break;
|
|
111
112
|
case 'relation':
|
|
112
|
-
if (attr.relation === 'morphToMany'
|
|
113
|
+
if (attr.relation === 'morphToMany' ||
|
|
114
|
+
attr.relation === 'morphToOne') {
|
|
113
115
|
str += 'any';
|
|
114
116
|
break;
|
|
115
117
|
}
|
|
@@ -407,6 +407,15 @@ export declare const nestedAttribute: z.ZodObject<{
|
|
|
407
407
|
}, {
|
|
408
408
|
type?: "relation";
|
|
409
409
|
relation?: "morphToMany";
|
|
410
|
+
}>, z.ZodObject<{
|
|
411
|
+
type: z.ZodLiteral<"relation">;
|
|
412
|
+
relation: z.ZodLiteral<"morphToOne">;
|
|
413
|
+
}, "strip", z.ZodTypeAny, {
|
|
414
|
+
type?: "relation";
|
|
415
|
+
relation?: "morphToOne";
|
|
416
|
+
}, {
|
|
417
|
+
type?: "relation";
|
|
418
|
+
relation?: "morphToOne";
|
|
410
419
|
}>]>, z.ZodObject<{
|
|
411
420
|
__t4s_required: z.ZodOptional<z.ZodBoolean>;
|
|
412
421
|
pluginOptions: z.ZodAny;
|
|
@@ -584,6 +593,9 @@ export declare const nestedAttribute: z.ZodObject<{
|
|
|
584
593
|
} | {
|
|
585
594
|
type?: "relation";
|
|
586
595
|
relation?: "morphToMany";
|
|
596
|
+
} | {
|
|
597
|
+
type?: "relation";
|
|
598
|
+
relation?: "morphToOne";
|
|
587
599
|
} | {
|
|
588
600
|
__t4s_required?: boolean;
|
|
589
601
|
pluginOptions?: any;
|
|
@@ -735,6 +747,9 @@ export declare const nestedAttribute: z.ZodObject<{
|
|
|
735
747
|
} | {
|
|
736
748
|
type?: "relation";
|
|
737
749
|
relation?: "morphToMany";
|
|
750
|
+
} | {
|
|
751
|
+
type?: "relation";
|
|
752
|
+
relation?: "morphToOne";
|
|
738
753
|
} | {
|
|
739
754
|
__t4s_required?: boolean;
|
|
740
755
|
pluginOptions?: any;
|
|
@@ -1152,6 +1167,15 @@ export declare const attributeWithNested: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.
|
|
|
1152
1167
|
}, {
|
|
1153
1168
|
type?: "relation";
|
|
1154
1169
|
relation?: "morphToMany";
|
|
1170
|
+
}>, z.ZodObject<{
|
|
1171
|
+
type: z.ZodLiteral<"relation">;
|
|
1172
|
+
relation: z.ZodLiteral<"morphToOne">;
|
|
1173
|
+
}, "strip", z.ZodTypeAny, {
|
|
1174
|
+
type?: "relation";
|
|
1175
|
+
relation?: "morphToOne";
|
|
1176
|
+
}, {
|
|
1177
|
+
type?: "relation";
|
|
1178
|
+
relation?: "morphToOne";
|
|
1155
1179
|
}>]>, z.ZodObject<{
|
|
1156
1180
|
__t4s_required: z.ZodOptional<z.ZodBoolean>;
|
|
1157
1181
|
pluginOptions: z.ZodAny;
|
|
@@ -1596,6 +1620,15 @@ export declare const attributeWithNested: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.
|
|
|
1596
1620
|
}, {
|
|
1597
1621
|
type?: "relation";
|
|
1598
1622
|
relation?: "morphToMany";
|
|
1623
|
+
}>, z.ZodObject<{
|
|
1624
|
+
type: z.ZodLiteral<"relation">;
|
|
1625
|
+
relation: z.ZodLiteral<"morphToOne">;
|
|
1626
|
+
}, "strip", z.ZodTypeAny, {
|
|
1627
|
+
type?: "relation";
|
|
1628
|
+
relation?: "morphToOne";
|
|
1629
|
+
}, {
|
|
1630
|
+
type?: "relation";
|
|
1631
|
+
relation?: "morphToOne";
|
|
1599
1632
|
}>]>, z.ZodObject<{
|
|
1600
1633
|
__t4s_required: z.ZodOptional<z.ZodBoolean>;
|
|
1601
1634
|
pluginOptions: z.ZodAny;
|
|
@@ -1773,6 +1806,9 @@ export declare const attributeWithNested: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.
|
|
|
1773
1806
|
} | {
|
|
1774
1807
|
type?: "relation";
|
|
1775
1808
|
relation?: "morphToMany";
|
|
1809
|
+
} | {
|
|
1810
|
+
type?: "relation";
|
|
1811
|
+
relation?: "morphToOne";
|
|
1776
1812
|
} | {
|
|
1777
1813
|
__t4s_required?: boolean;
|
|
1778
1814
|
pluginOptions?: any;
|
|
@@ -1924,6 +1960,9 @@ export declare const attributeWithNested: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.
|
|
|
1924
1960
|
} | {
|
|
1925
1961
|
type?: "relation";
|
|
1926
1962
|
relation?: "morphToMany";
|
|
1963
|
+
} | {
|
|
1964
|
+
type?: "relation";
|
|
1965
|
+
relation?: "morphToOne";
|
|
1927
1966
|
} | {
|
|
1928
1967
|
__t4s_required?: boolean;
|
|
1929
1968
|
pluginOptions?: any;
|
|
@@ -206,6 +206,9 @@ export default class InterfaceManager {
|
|
|
206
206
|
} | {
|
|
207
207
|
type?: "relation";
|
|
208
208
|
relation?: "morphToMany";
|
|
209
|
+
} | {
|
|
210
|
+
type?: "relation";
|
|
211
|
+
relation?: "morphToOne";
|
|
209
212
|
} | {
|
|
210
213
|
__t4s_required?: boolean;
|
|
211
214
|
pluginOptions?: any;
|
|
@@ -370,6 +373,9 @@ export default class InterfaceManager {
|
|
|
370
373
|
} | {
|
|
371
374
|
type?: "relation";
|
|
372
375
|
relation?: "morphToMany";
|
|
376
|
+
} | {
|
|
377
|
+
type?: "relation";
|
|
378
|
+
relation?: "morphToOne";
|
|
373
379
|
} | {
|
|
374
380
|
__t4s_required?: boolean;
|
|
375
381
|
pluginOptions?: any;
|
package/lib/readers/by-file.d.ts
CHANGED
|
@@ -138,6 +138,9 @@ export declare class ByFileContentTypeReader implements ContentTypeReader {
|
|
|
138
138
|
} | {
|
|
139
139
|
type?: "relation";
|
|
140
140
|
relation?: "morphToMany";
|
|
141
|
+
} | {
|
|
142
|
+
type?: "relation";
|
|
143
|
+
relation?: "morphToOne";
|
|
141
144
|
} | {
|
|
142
145
|
__t4s_required?: boolean;
|
|
143
146
|
pluginOptions?: any;
|
|
@@ -286,6 +289,9 @@ export declare class ByFileContentTypeReader implements ContentTypeReader {
|
|
|
286
289
|
} | {
|
|
287
290
|
type?: "relation";
|
|
288
291
|
relation?: "morphToMany";
|
|
292
|
+
} | {
|
|
293
|
+
type?: "relation";
|
|
294
|
+
relation?: "morphToOne";
|
|
289
295
|
} | {
|
|
290
296
|
__t4s_required?: boolean;
|
|
291
297
|
pluginOptions?: any;
|
|
@@ -140,6 +140,9 @@ export declare class LoadStrapiReader implements ContentTypeReader {
|
|
|
140
140
|
} | {
|
|
141
141
|
type?: "relation";
|
|
142
142
|
relation?: "morphToMany";
|
|
143
|
+
} | {
|
|
144
|
+
type?: "relation";
|
|
145
|
+
relation?: "morphToOne";
|
|
143
146
|
} | {
|
|
144
147
|
__t4s_required?: boolean;
|
|
145
148
|
pluginOptions?: any;
|
|
@@ -304,6 +307,9 @@ export declare class LoadStrapiReader implements ContentTypeReader {
|
|
|
304
307
|
} | {
|
|
305
308
|
type?: "relation";
|
|
306
309
|
relation?: "morphToMany";
|
|
310
|
+
} | {
|
|
311
|
+
type?: "relation";
|
|
312
|
+
relation?: "morphToOne";
|
|
307
313
|
} | {
|
|
308
314
|
__t4s_required?: boolean;
|
|
309
315
|
pluginOptions?: any;
|
|
@@ -574,6 +574,16 @@ export declare const morphToManyAttribute: z.ZodObject<{
|
|
|
574
574
|
type?: "relation";
|
|
575
575
|
relation?: "morphToMany";
|
|
576
576
|
}>;
|
|
577
|
+
export declare const morphOneAttribute: z.ZodObject<{
|
|
578
|
+
type: z.ZodLiteral<"relation">;
|
|
579
|
+
relation: z.ZodLiteral<"morphToOne">;
|
|
580
|
+
}, "strip", z.ZodTypeAny, {
|
|
581
|
+
type?: "relation";
|
|
582
|
+
relation?: "morphToOne";
|
|
583
|
+
}, {
|
|
584
|
+
type?: "relation";
|
|
585
|
+
relation?: "morphToOne";
|
|
586
|
+
}>;
|
|
577
587
|
export declare const relationAttribute: z.ZodUnion<[z.ZodObject<{
|
|
578
588
|
__t4s_required: z.ZodOptional<z.ZodBoolean>;
|
|
579
589
|
pluginOptions: z.ZodAny;
|
|
@@ -724,6 +734,15 @@ export declare const relationAttribute: z.ZodUnion<[z.ZodObject<{
|
|
|
724
734
|
}, {
|
|
725
735
|
type?: "relation";
|
|
726
736
|
relation?: "morphToMany";
|
|
737
|
+
}>, z.ZodObject<{
|
|
738
|
+
type: z.ZodLiteral<"relation">;
|
|
739
|
+
relation: z.ZodLiteral<"morphToOne">;
|
|
740
|
+
}, "strip", z.ZodTypeAny, {
|
|
741
|
+
type?: "relation";
|
|
742
|
+
relation?: "morphToOne";
|
|
743
|
+
}, {
|
|
744
|
+
type?: "relation";
|
|
745
|
+
relation?: "morphToOne";
|
|
727
746
|
}>]>;
|
|
728
747
|
export declare type RelationAttribute = z.infer<typeof relationAttribute>;
|
|
729
748
|
export declare const componentAttribute: z.ZodObject<{
|
|
@@ -1171,6 +1190,15 @@ export declare const attribute: z.ZodUnion<[z.ZodObject<{
|
|
|
1171
1190
|
}, {
|
|
1172
1191
|
type?: "relation";
|
|
1173
1192
|
relation?: "morphToMany";
|
|
1193
|
+
}>, z.ZodObject<{
|
|
1194
|
+
type: z.ZodLiteral<"relation">;
|
|
1195
|
+
relation: z.ZodLiteral<"morphToOne">;
|
|
1196
|
+
}, "strip", z.ZodTypeAny, {
|
|
1197
|
+
type?: "relation";
|
|
1198
|
+
relation?: "morphToOne";
|
|
1199
|
+
}, {
|
|
1200
|
+
type?: "relation";
|
|
1201
|
+
relation?: "morphToOne";
|
|
1174
1202
|
}>]>, z.ZodObject<{
|
|
1175
1203
|
__t4s_required: z.ZodOptional<z.ZodBoolean>;
|
|
1176
1204
|
pluginOptions: z.ZodAny;
|
|
@@ -1596,6 +1624,15 @@ export declare const contentTypeAttribute: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
|
|
|
1596
1624
|
}, {
|
|
1597
1625
|
type?: "relation";
|
|
1598
1626
|
relation?: "morphToMany";
|
|
1627
|
+
}>, z.ZodObject<{
|
|
1628
|
+
type: z.ZodLiteral<"relation">;
|
|
1629
|
+
relation: z.ZodLiteral<"morphToOne">;
|
|
1630
|
+
}, "strip", z.ZodTypeAny, {
|
|
1631
|
+
type?: "relation";
|
|
1632
|
+
relation?: "morphToOne";
|
|
1633
|
+
}, {
|
|
1634
|
+
type?: "relation";
|
|
1635
|
+
relation?: "morphToOne";
|
|
1599
1636
|
}>]>, z.ZodObject<{
|
|
1600
1637
|
__t4s_required: z.ZodOptional<z.ZodBoolean>;
|
|
1601
1638
|
pluginOptions: z.ZodAny;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
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;
|
|
3
|
+
exports.contentTypeAttribute = exports.attribute = 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.richTextAttribute = exports.uidAttribute = exports.emailAttribute = exports.textAttribute = exports.baseAttribute = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const constants_1 = require("../../constants");
|
|
6
6
|
exports.baseAttribute = zod_1.z.object({
|
|
@@ -9,7 +9,7 @@ exports.baseAttribute = zod_1.z.object({
|
|
|
9
9
|
[constants_1.CERTAINLY_REQUIRED_KEY]: zod_1.z.boolean().optional(),
|
|
10
10
|
});
|
|
11
11
|
exports.textAttribute = exports.baseAttribute.extend({
|
|
12
|
-
type: zod_1.z.enum(['text', 'string'])
|
|
12
|
+
type: zod_1.z.enum(['text', 'string']),
|
|
13
13
|
});
|
|
14
14
|
exports.emailAttribute = exports.baseAttribute.extend({
|
|
15
15
|
type: zod_1.z.literal('email'),
|
|
@@ -105,6 +105,10 @@ exports.morphToManyAttribute = zod_1.z.object({
|
|
|
105
105
|
type: zod_1.z.literal('relation'),
|
|
106
106
|
relation: zod_1.z.literal('morphToMany'),
|
|
107
107
|
});
|
|
108
|
+
exports.morphOneAttribute = zod_1.z.object({
|
|
109
|
+
type: zod_1.z.literal('relation'),
|
|
110
|
+
relation: zod_1.z.literal('morphToOne'),
|
|
111
|
+
});
|
|
108
112
|
exports.relationAttribute = zod_1.z.union([
|
|
109
113
|
exports.hasOneAttribute,
|
|
110
114
|
exports.oneToOneAttribute,
|
|
@@ -113,6 +117,7 @@ exports.relationAttribute = zod_1.z.union([
|
|
|
113
117
|
exports.manyToManyAttribute,
|
|
114
118
|
exports.hasManyAttribute,
|
|
115
119
|
exports.morphToManyAttribute,
|
|
120
|
+
exports.morphOneAttribute,
|
|
116
121
|
]);
|
|
117
122
|
exports.componentAttribute = exports.baseAttribute.extend({
|
|
118
123
|
type: zod_1.z.literal('component'),
|
|
@@ -138,7 +143,4 @@ exports.attribute = zod_1.z.union([
|
|
|
138
143
|
exports.relationAttribute,
|
|
139
144
|
exports.componentAttribute,
|
|
140
145
|
]);
|
|
141
|
-
exports.contentTypeAttribute = zod_1.z.union([
|
|
142
|
-
exports.attribute,
|
|
143
|
-
exports.dynamiczoneAttribute,
|
|
144
|
-
]);
|
|
146
|
+
exports.contentTypeAttribute = zod_1.z.union([exports.attribute, exports.dynamiczoneAttribute]);
|
|
@@ -403,6 +403,15 @@ export declare const strapiComponent: z.ZodObject<{
|
|
|
403
403
|
}, {
|
|
404
404
|
type?: "relation";
|
|
405
405
|
relation?: "morphToMany";
|
|
406
|
+
}>, z.ZodObject<{
|
|
407
|
+
type: z.ZodLiteral<"relation">;
|
|
408
|
+
relation: z.ZodLiteral<"morphToOne">;
|
|
409
|
+
}, "strip", z.ZodTypeAny, {
|
|
410
|
+
type?: "relation";
|
|
411
|
+
relation?: "morphToOne";
|
|
412
|
+
}, {
|
|
413
|
+
type?: "relation";
|
|
414
|
+
relation?: "morphToOne";
|
|
406
415
|
}>]>, z.ZodObject<{
|
|
407
416
|
__t4s_required: z.ZodOptional<z.ZodBoolean>;
|
|
408
417
|
pluginOptions: z.ZodAny;
|
|
@@ -563,6 +572,9 @@ export declare const strapiComponent: z.ZodObject<{
|
|
|
563
572
|
} | {
|
|
564
573
|
type?: "relation";
|
|
565
574
|
relation?: "morphToMany";
|
|
575
|
+
} | {
|
|
576
|
+
type?: "relation";
|
|
577
|
+
relation?: "morphToOne";
|
|
566
578
|
} | {
|
|
567
579
|
__t4s_required?: boolean;
|
|
568
580
|
pluginOptions?: any;
|
|
@@ -709,6 +721,9 @@ export declare const strapiComponent: z.ZodObject<{
|
|
|
709
721
|
} | {
|
|
710
722
|
type?: "relation";
|
|
711
723
|
relation?: "morphToMany";
|
|
724
|
+
} | {
|
|
725
|
+
type?: "relation";
|
|
726
|
+
relation?: "morphToOne";
|
|
712
727
|
} | {
|
|
713
728
|
__t4s_required?: boolean;
|
|
714
729
|
pluginOptions?: any;
|
|
@@ -402,6 +402,15 @@ export declare const strapiContentType: z.ZodObject<{
|
|
|
402
402
|
}, {
|
|
403
403
|
type?: "relation";
|
|
404
404
|
relation?: "morphToMany";
|
|
405
|
+
}>, z.ZodObject<{
|
|
406
|
+
type: z.ZodLiteral<"relation">;
|
|
407
|
+
relation: z.ZodLiteral<"morphToOne">;
|
|
408
|
+
}, "strip", z.ZodTypeAny, {
|
|
409
|
+
type?: "relation";
|
|
410
|
+
relation?: "morphToOne";
|
|
411
|
+
}, {
|
|
412
|
+
type?: "relation";
|
|
413
|
+
relation?: "morphToOne";
|
|
405
414
|
}>]>, z.ZodObject<{
|
|
406
415
|
__t4s_required: z.ZodOptional<z.ZodBoolean>;
|
|
407
416
|
pluginOptions: z.ZodAny;
|
|
@@ -587,6 +596,9 @@ export declare const strapiContentType: z.ZodObject<{
|
|
|
587
596
|
} | {
|
|
588
597
|
type?: "relation";
|
|
589
598
|
relation?: "morphToMany";
|
|
599
|
+
} | {
|
|
600
|
+
type?: "relation";
|
|
601
|
+
relation?: "morphToOne";
|
|
590
602
|
} | {
|
|
591
603
|
__t4s_required?: boolean;
|
|
592
604
|
pluginOptions?: any;
|
|
@@ -742,6 +754,9 @@ export declare const strapiContentType: z.ZodObject<{
|
|
|
742
754
|
} | {
|
|
743
755
|
type?: "relation";
|
|
744
756
|
relation?: "morphToMany";
|
|
757
|
+
} | {
|
|
758
|
+
type?: "relation";
|
|
759
|
+
relation?: "morphToOne";
|
|
745
760
|
} | {
|
|
746
761
|
__t4s_required?: boolean;
|
|
747
762
|
pluginOptions?: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oak-digital/types-4-strapi-2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Typescript interface generator for Strapi 4 models",
|
|
5
5
|
"bin": {
|
|
6
6
|
"t4s": "./bin/index.js"
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@types/prettier": "^2.7.0",
|
|
27
27
|
"@typescript-eslint/eslint-plugin": "^5.33.1",
|
|
28
28
|
"@typescript-eslint/parser": "^5.33.1",
|
|
29
|
+
"bumpp": "^9.3.0",
|
|
29
30
|
"eslint": "^8.22.0",
|
|
30
31
|
"rimraf": "^4.4.1",
|
|
31
32
|
"ts-node": "^10.9.1",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"lint": "eslint src/",
|
|
44
45
|
"prettier": "prettier --write \"src/**/*.ts\"",
|
|
45
46
|
"t4s": "node ./bin/index.js",
|
|
46
|
-
"testdev": "ts-node ./src/index.ts"
|
|
47
|
+
"testdev": "ts-node ./src/index.ts",
|
|
48
|
+
"release": "bumpp"
|
|
47
49
|
}
|
|
48
50
|
}
|