@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 +4 -0
- package/dist/cli.cjs +42 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +42 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/generator/attributes/dynamiczone.d.ts +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -21521,7 +21521,8 @@ class Component extends BaseRelation {
|
|
|
21521
21521
|
return this.attribute.repeatable ? `${componentName}[]` : componentName;
|
|
21522
21522
|
}
|
|
21523
21523
|
getInputType() {
|
|
21524
|
-
|
|
21524
|
+
const typeName = `${getComponentName(this.attribute.component)}Input`;
|
|
21525
|
+
return this.attribute.repeatable ? `${typeName}[]` : typeName;
|
|
21525
21526
|
}
|
|
21526
21527
|
getPopulates() {
|
|
21527
21528
|
return [{
|
|
@@ -21620,6 +21621,43 @@ let Date$1 = class Date extends Base {
|
|
|
21620
21621
|
}
|
|
21621
21622
|
};
|
|
21622
21623
|
|
|
21624
|
+
class Dynamiczone extends BaseRelation {
|
|
21625
|
+
constructor(name, attribute) {
|
|
21626
|
+
super(name, attribute);
|
|
21627
|
+
this.name = name;
|
|
21628
|
+
this.attribute = attribute;
|
|
21629
|
+
}
|
|
21630
|
+
getType() {
|
|
21631
|
+
const types = this.attribute.components
|
|
21632
|
+
.map(componentItem => getComponentName(componentItem))
|
|
21633
|
+
.join(' | ');
|
|
21634
|
+
return `(${types})[]`;
|
|
21635
|
+
}
|
|
21636
|
+
getInputType() {
|
|
21637
|
+
const types = this.attribute.components
|
|
21638
|
+
.map(componentItem => `DynamiczoneInput<'${componentItem}', ${getComponentName(componentItem)}Input>`)
|
|
21639
|
+
.join(' | ');
|
|
21640
|
+
return `(${types})[]`;
|
|
21641
|
+
}
|
|
21642
|
+
getPopulates() {
|
|
21643
|
+
const types = this.attribute.components
|
|
21644
|
+
.map(componentItem => `${getComponentName(componentItem)}Query`)
|
|
21645
|
+
.join(' & ');
|
|
21646
|
+
return [{
|
|
21647
|
+
name: this.name,
|
|
21648
|
+
type: `DynamiczonePopulate<${types}>`,
|
|
21649
|
+
}];
|
|
21650
|
+
}
|
|
21651
|
+
getFilters() {
|
|
21652
|
+
return [
|
|
21653
|
+
// {
|
|
21654
|
+
// name: this.name,
|
|
21655
|
+
// type: `${getComponentName(this.attribute.component)}Filters`,
|
|
21656
|
+
// }
|
|
21657
|
+
];
|
|
21658
|
+
}
|
|
21659
|
+
}
|
|
21660
|
+
|
|
21623
21661
|
const types = {
|
|
21624
21662
|
'string': String$1,
|
|
21625
21663
|
'text': String$1,
|
|
@@ -21636,11 +21674,13 @@ const types = {
|
|
|
21636
21674
|
'date': Date$1,
|
|
21637
21675
|
'datetime': DateTime,
|
|
21638
21676
|
'component': Component,
|
|
21677
|
+
'dynamiczone': Dynamiczone,
|
|
21639
21678
|
'blocks': Blocks,
|
|
21640
21679
|
'json': Json,
|
|
21641
21680
|
};
|
|
21642
21681
|
function getAttributeGenerator(name, attribute) {
|
|
21643
21682
|
if (!types[attribute.type]) {
|
|
21683
|
+
console.log(attribute);
|
|
21644
21684
|
throw new Error(`Attribute type "${attribute.type}" is not defined`);
|
|
21645
21685
|
}
|
|
21646
21686
|
return new types[attribute.type](name, attribute);
|
|
@@ -21793,7 +21833,7 @@ async function generateStrapiTypes(strapi) {
|
|
|
21793
21833
|
allInterfaces.push(generateInputTypeCode(modelName, attributes));
|
|
21794
21834
|
}
|
|
21795
21835
|
const output = [
|
|
21796
|
-
'import {Strapi as StrapiBase, Query, Filters, FilterValue, RelationInput} from "@malevich-studio/strapi-sdk-typescript";',
|
|
21836
|
+
'import {Strapi as StrapiBase, Query, Filters, FilterValue, RelationInput, DynamiczonePopulate, DynamiczoneInput} from "@malevich-studio/strapi-sdk-typescript";',
|
|
21797
21837
|
'import {BlocksContent} from "@strapi/blocks-react-renderer";',
|
|
21798
21838
|
'',
|
|
21799
21839
|
'export default class Strapi extends StrapiBase {',
|