@malevich-studio/strapi-sdk-typescript 1.0.14 → 1.0.16

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/README.md CHANGED
@@ -114,6 +114,7 @@ const articles = api.articles(
114
114
  - [ ] Log In functionality
115
115
  - [ ] User Registration
116
116
  - [ ] User privileges check
117
+ - [ ] Add localization features
117
118
  - [ ] Refactor `src/generator/index.ts` for better maintainability
118
119
  - [ ] Enable passing Strapi credentials via CLI parameters
119
120
  - [ ] Allow customization of API class path
@@ -125,3 +126,6 @@ const articles = api.articles(
125
126
  ---
126
127
 
127
128
  📌 **Contributions are welcome!** If you encounter issues or have feature requests, feel free to open a pull request or an issue. 🚀
129
+
130
+ 📦 [View on NPM](https://www.npmjs.com/package/@malevich-studio/strapi-sdk-typescript)
131
+ 🔗 [GitHub Repository](https://github.com/malevich-studio/strapi-sdk-typescript)
package/dist/cli.cjs CHANGED
@@ -21541,7 +21541,8 @@ class Component extends BaseRelation {
21541
21541
  return this.attribute.repeatable ? `${componentName}[]` : componentName;
21542
21542
  }
21543
21543
  getInputType() {
21544
- return `${getComponentName(this.attribute.component)}Input`;
21544
+ const typeName = `${getComponentName(this.attribute.component)}Input`;
21545
+ return this.attribute.repeatable ? `${typeName}[]` : typeName;
21545
21546
  }
21546
21547
  getPopulates() {
21547
21548
  return [{
@@ -21640,6 +21641,43 @@ let Date$1 = class Date extends Base {
21640
21641
  }
21641
21642
  };
21642
21643
 
21644
+ class Dynamiczone extends BaseRelation {
21645
+ constructor(name, attribute) {
21646
+ super(name, attribute);
21647
+ this.name = name;
21648
+ this.attribute = attribute;
21649
+ }
21650
+ getType() {
21651
+ const types = this.attribute.components
21652
+ .map(componentItem => getComponentName(componentItem))
21653
+ .join(' | ');
21654
+ return `(${types})[]`;
21655
+ }
21656
+ getInputType() {
21657
+ const types = this.attribute.components
21658
+ .map(componentItem => `DynamiczoneInput<'${componentItem}', ${getComponentName(componentItem)}Input>`)
21659
+ .join(' | ');
21660
+ return `(${types})[]`;
21661
+ }
21662
+ getPopulates() {
21663
+ const types = this.attribute.components
21664
+ .map(componentItem => `${getComponentName(componentItem)}Query`)
21665
+ .join(' & ');
21666
+ return [{
21667
+ name: this.name,
21668
+ type: `DynamiczonePopulate<${types}>`,
21669
+ }];
21670
+ }
21671
+ getFilters() {
21672
+ return [
21673
+ // {
21674
+ // name: this.name,
21675
+ // type: `${getComponentName(this.attribute.component)}Filters`,
21676
+ // }
21677
+ ];
21678
+ }
21679
+ }
21680
+
21643
21681
  const types = {
21644
21682
  'string': String$1,
21645
21683
  'text': String$1,
@@ -21656,11 +21694,13 @@ const types = {
21656
21694
  'date': Date$1,
21657
21695
  'datetime': DateTime,
21658
21696
  'component': Component,
21697
+ 'dynamiczone': Dynamiczone,
21659
21698
  'blocks': Blocks,
21660
21699
  'json': Json,
21661
21700
  };
21662
21701
  function getAttributeGenerator(name, attribute) {
21663
21702
  if (!types[attribute.type]) {
21703
+ console.log(attribute);
21664
21704
  throw new Error(`Attribute type "${attribute.type}" is not defined`);
21665
21705
  }
21666
21706
  return new types[attribute.type](name, attribute);
@@ -21813,7 +21853,7 @@ async function generateStrapiTypes(strapi) {
21813
21853
  allInterfaces.push(generateInputTypeCode(modelName, attributes));
21814
21854
  }
21815
21855
  const output = [
21816
- 'import {Strapi as StrapiBase, Query, Filters, FilterValue, RelationInput} from "@malevich-studio/strapi-sdk-typescript";',
21856
+ 'import {Strapi as StrapiBase, Query, Filters, FilterValue, RelationInput, DynamiczonePopulate, DynamiczoneInput} from "@malevich-studio/strapi-sdk-typescript";',
21817
21857
  'import {BlocksContent} from "@strapi/blocks-react-renderer";',
21818
21858
  '',
21819
21859
  'export default class Strapi extends StrapiBase {',