@zenstackhq/sdk 3.9.3 → 3.9.4
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/dist/index.cjs +0 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -3
- package/dist/index.d.mts +0 -3
- package/dist/index.mjs +0 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -156,11 +156,8 @@ declare class TsSchemaGenerator {
|
|
|
156
156
|
private getDelegateMapValue;
|
|
157
157
|
private getSubModels;
|
|
158
158
|
private createTypeDefObject;
|
|
159
|
-
private createComputedFieldsObject;
|
|
160
159
|
private createFieldParamsObject;
|
|
161
|
-
private mapFunctionParamTypeToTSType;
|
|
162
160
|
private createUpdatedAtObject;
|
|
163
|
-
private mapFieldTypeToTSType;
|
|
164
161
|
private createDataFieldObject;
|
|
165
162
|
private isDiscriminatorField;
|
|
166
163
|
private getDataSourceProvider;
|
package/dist/index.d.mts
CHANGED
|
@@ -156,11 +156,8 @@ declare class TsSchemaGenerator {
|
|
|
156
156
|
private getDelegateMapValue;
|
|
157
157
|
private getSubModels;
|
|
158
158
|
private createTypeDefObject;
|
|
159
|
-
private createComputedFieldsObject;
|
|
160
159
|
private createFieldParamsObject;
|
|
161
|
-
private mapFunctionParamTypeToTSType;
|
|
162
160
|
private createUpdatedAtObject;
|
|
163
|
-
private mapFieldTypeToTSType;
|
|
164
161
|
private createDataFieldObject;
|
|
165
162
|
private isDiscriminatorField;
|
|
166
163
|
private getDataSourceProvider;
|
package/dist/index.mjs
CHANGED
|
@@ -729,8 +729,6 @@ var TsSchemaGenerator = class {
|
|
|
729
729
|
...subModels.length > 0 ? [ts.factory.createPropertyAssignment("subModels", ts.factory.createArrayLiteralExpression(subModels.map((subModel) => ts.factory.createStringLiteral(subModel))))] : [],
|
|
730
730
|
...dm.isView ? [ts.factory.createPropertyAssignment("isView", ts.factory.createTrue())] : []
|
|
731
731
|
];
|
|
732
|
-
const computedFields = allFields.filter((f) => hasAttribute(f, "@computed") && !getDelegateOriginModel(f, dm));
|
|
733
|
-
if (computedFields.length > 0) fields.push(ts.factory.createPropertyAssignment("computedFields", this.createComputedFieldsObject(computedFields)));
|
|
734
732
|
return ts.factory.createObjectLiteralExpression(fields, true);
|
|
735
733
|
}
|
|
736
734
|
getDelegateMapValue(dm) {
|
|
@@ -758,13 +756,6 @@ var TsSchemaGenerator = class {
|
|
|
758
756
|
if (getAllAttributes(td).some((attr) => attr.decl.$refText === "@@strict")) fields.push(ts.factory.createPropertyAssignment("strict", ts.factory.createTrue()));
|
|
759
757
|
return ts.factory.createObjectLiteralExpression(fields, true);
|
|
760
758
|
}
|
|
761
|
-
createComputedFieldsObject(fields) {
|
|
762
|
-
return ts.factory.createObjectLiteralExpression(fields.map((field) => {
|
|
763
|
-
const params = [ts.factory.createParameterDeclaration(void 0, void 0, "_context", void 0, ts.factory.createTypeLiteralNode([ts.factory.createPropertySignature(void 0, "modelAlias", void 0, ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword))]), void 0)];
|
|
764
|
-
if (field.params.length > 0) params.push(ts.factory.createParameterDeclaration(void 0, void 0, "args", void 0, ts.factory.createTypeLiteralNode(field.params.map((param) => ts.factory.createPropertySignature(void 0, param.name, param.optional ? ts.factory.createToken(ts.SyntaxKind.QuestionToken) : void 0, ts.factory.createTypeReferenceNode(this.mapFunctionParamTypeToTSType(param.type))))), void 0));
|
|
765
|
-
return ts.factory.createMethodDeclaration(void 0, void 0, field.name, void 0, void 0, params, ts.factory.createTypeReferenceNode(this.mapFieldTypeToTSType(field.type)), ts.factory.createBlock([ts.factory.createThrowStatement(ts.factory.createNewExpression(ts.factory.createIdentifier("Error"), void 0, [ts.factory.createStringLiteral("This is a stub for computed field")]))], true));
|
|
766
|
-
}), true);
|
|
767
|
-
}
|
|
768
759
|
createFieldParamsObject(params) {
|
|
769
760
|
return ts.factory.createObjectLiteralExpression(params.map((param) => ts.factory.createPropertyAssignment(param.name, ts.factory.createObjectLiteralExpression([
|
|
770
761
|
ts.factory.createPropertyAssignment("name", ts.factory.createStringLiteral(param.name)),
|
|
@@ -773,20 +764,9 @@ var TsSchemaGenerator = class {
|
|
|
773
764
|
ts.factory.createPropertyAssignment("type", ts.factory.createStringLiteral(param.type.type ?? param.type.reference.$refText))
|
|
774
765
|
]))), true);
|
|
775
766
|
}
|
|
776
|
-
mapFunctionParamTypeToTSType(type) {
|
|
777
|
-
let result = match(type.type).with("String", () => "string").with("Boolean", () => "boolean").with("Int", () => "number").with("Float", () => "number").with("BigInt", () => "bigint").with("Decimal", () => "number").with("DateTime", () => "Date").otherwise(() => "unknown");
|
|
778
|
-
if (type.array) result = `${result}[]`;
|
|
779
|
-
return result;
|
|
780
|
-
}
|
|
781
767
|
createUpdatedAtObject(ignoreArg) {
|
|
782
768
|
return ts.factory.createObjectLiteralExpression([ts.factory.createPropertyAssignment("ignore", ts.factory.createArrayLiteralExpression(ignoreArg.value.items.map((item) => ts.factory.createStringLiteral(item.target.$refText))))]);
|
|
783
769
|
}
|
|
784
|
-
mapFieldTypeToTSType(type) {
|
|
785
|
-
let result = match(type.type).with("String", () => "string").with("Boolean", () => "boolean").with("Int", () => "number").with("Float", () => "number").with("BigInt", () => "bigint").with("Decimal", () => "number").otherwise(() => "unknown");
|
|
786
|
-
if (type.array) result = `${result}[]`;
|
|
787
|
-
if (type.optional) result = `${result} | null`;
|
|
788
|
-
return result;
|
|
789
|
-
}
|
|
790
770
|
createDataFieldObject(field, contextModel, lite) {
|
|
791
771
|
const objectFields = [ts.factory.createPropertyAssignment("name", ts.factory.createStringLiteral(field.name)), ts.factory.createPropertyAssignment("type", this.generateFieldTypeLiteral(field))];
|
|
792
772
|
if (contextModel && isIdField(field, contextModel)) objectFields.push(ts.factory.createPropertyAssignment("id", ts.factory.createTrue()));
|