@oak-digital/types-4-strapi-2 0.4.0 → 0.5.0
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 +11 -3
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ var Attributes = /** @class */ (function () {
|
|
|
13
13
|
case 'nested':
|
|
14
14
|
// we need to check equality since it could be undefined
|
|
15
15
|
return attr.nullable === true;
|
|
16
|
+
case 'media': // media is also always populatable
|
|
16
17
|
case 'component':
|
|
17
18
|
case 'dynamiczone':
|
|
18
19
|
case 'relation':
|
|
@@ -82,12 +83,14 @@ var Attributes = /** @class */ (function () {
|
|
|
82
83
|
};
|
|
83
84
|
Attributes.prototype.attributeToString = function (attrName, attr) {
|
|
84
85
|
var _this = this;
|
|
85
|
-
var _a, _b, _c
|
|
86
|
+
var _a, _b, _c;
|
|
86
87
|
var isPopulatable = this.isAttributePopulatable(attr);
|
|
87
88
|
var isOptional = isPopulatable;
|
|
88
89
|
var optionalString = isOptional ? '?' : '';
|
|
89
90
|
var orNull = ' | null';
|
|
90
|
-
|
|
91
|
+
// TODO: only add this in non paranoid mode
|
|
92
|
+
/* const requiredString = attr.required !== true ? orNull : ''; */
|
|
93
|
+
var requiredString = orNull;
|
|
91
94
|
var str = " ".concat(attrName).concat(optionalString, ": ");
|
|
92
95
|
var isArray = false;
|
|
93
96
|
switch (attr.type) {
|
|
@@ -123,8 +126,13 @@ var Attributes = /** @class */ (function () {
|
|
|
123
126
|
var relationNameObj = this.RelationNames[componentName];
|
|
124
127
|
/* console.log(this.RelationNames); */
|
|
125
128
|
var dependencyComponentName = relationNameObj.name;
|
|
126
|
-
isArray =
|
|
129
|
+
/* isArray = attr.repeatable ?? false; */
|
|
130
|
+
isArray = false; // we already handle this here.
|
|
127
131
|
str += dependencyComponentName;
|
|
132
|
+
if (attr.repeatable) {
|
|
133
|
+
str += '[]';
|
|
134
|
+
}
|
|
135
|
+
str += requiredString; // resolves #20. components can be null.
|
|
128
136
|
break;
|
|
129
137
|
case 'media':
|
|
130
138
|
var mediaMultipleString = attr.multiple
|