@malevich-studio/strapi-sdk-typescript 1.0.15 → 1.0.17
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 +40 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +40 -1
- 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
|
@@ -21621,6 +21621,43 @@ let Date$1 = class Date extends Base {
|
|
|
21621
21621
|
}
|
|
21622
21622
|
};
|
|
21623
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 => `{ '${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
|
+
|
|
21624
21661
|
const types = {
|
|
21625
21662
|
'string': String$1,
|
|
21626
21663
|
'text': String$1,
|
|
@@ -21637,11 +21674,13 @@ const types = {
|
|
|
21637
21674
|
'date': Date$1,
|
|
21638
21675
|
'datetime': DateTime,
|
|
21639
21676
|
'component': Component,
|
|
21677
|
+
'dynamiczone': Dynamiczone,
|
|
21640
21678
|
'blocks': Blocks,
|
|
21641
21679
|
'json': Json,
|
|
21642
21680
|
};
|
|
21643
21681
|
function getAttributeGenerator(name, attribute) {
|
|
21644
21682
|
if (!types[attribute.type]) {
|
|
21683
|
+
console.log(attribute);
|
|
21645
21684
|
throw new Error(`Attribute type "${attribute.type}" is not defined`);
|
|
21646
21685
|
}
|
|
21647
21686
|
return new types[attribute.type](name, attribute);
|
|
@@ -21794,7 +21833,7 @@ async function generateStrapiTypes(strapi) {
|
|
|
21794
21833
|
allInterfaces.push(generateInputTypeCode(modelName, attributes));
|
|
21795
21834
|
}
|
|
21796
21835
|
const output = [
|
|
21797
|
-
'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";',
|
|
21798
21837
|
'import {BlocksContent} from "@strapi/blocks-react-renderer";',
|
|
21799
21838
|
'',
|
|
21800
21839
|
'export default class Strapi extends StrapiBase {',
|