@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.
@@ -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, _d;
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
- var requiredString = attr.required !== true ? orNull : '';
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 = (_d = attr.repeatable) !== null && _d !== void 0 ? _d : false;
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oak-digital/types-4-strapi-2",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Typescript interface generator for Strapi 4 models",
5
5
  "bin": {
6
6
  "t4s": "./bin/index.js"