@zenstackhq/sdk 3.1.1 → 3.2.1
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 +16 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -14
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1098,7 +1098,9 @@ var TsSchemaGenerator = class {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
const defaultValue = this.getFieldMappedDefault(field);
|
|
1100
1100
|
if (defaultValue !== void 0) {
|
|
1101
|
-
if (
|
|
1101
|
+
if (defaultValue === null) {
|
|
1102
|
+
objectFields.push(ts.factory.createPropertyAssignment("default", this.createExpressionUtilsCall("_null")));
|
|
1103
|
+
} else if (typeof defaultValue === "object" && !Array.isArray(defaultValue)) {
|
|
1102
1104
|
if ("call" in defaultValue) {
|
|
1103
1105
|
objectFields.push(ts.factory.createPropertyAssignment("default", this.createExpressionUtilsCall("call", [
|
|
1104
1106
|
ts.factory.createStringLiteral(defaultValue.call),
|
|
@@ -1190,8 +1192,10 @@ var TsSchemaGenerator = class {
|
|
|
1190
1192
|
return {
|
|
1191
1193
|
authMember: this.getMemberAccessChain(expr)
|
|
1192
1194
|
};
|
|
1195
|
+
} else if ((0, import_ast3.isNullExpr)(expr)) {
|
|
1196
|
+
return null;
|
|
1193
1197
|
} else {
|
|
1194
|
-
throw new Error(`Unsupported
|
|
1198
|
+
throw new Error(`Unsupported expression type: ${expr.$type}`);
|
|
1195
1199
|
}
|
|
1196
1200
|
}
|
|
1197
1201
|
getMemberAccessChain(expr) {
|
|
@@ -1406,25 +1410,22 @@ var TsSchemaGenerator = class {
|
|
|
1406
1410
|
return ts.factory.createObjectLiteralExpression(procedures.map((proc) => ts.factory.createPropertyAssignment(proc.name, this.createProcedureObject(proc))), true);
|
|
1407
1411
|
}
|
|
1408
1412
|
createProcedureObject(proc) {
|
|
1409
|
-
const params = ts.factory.
|
|
1413
|
+
const params = ts.factory.createObjectLiteralExpression(proc.params.map((param) => ts.factory.createPropertyAssignment(param.name, ts.factory.createObjectLiteralExpression([
|
|
1410
1414
|
ts.factory.createPropertyAssignment("name", ts.factory.createStringLiteral(param.name)),
|
|
1411
1415
|
...param.optional ? [
|
|
1412
1416
|
ts.factory.createPropertyAssignment("optional", ts.factory.createTrue())
|
|
1413
1417
|
] : [],
|
|
1418
|
+
...param.type.array ? [
|
|
1419
|
+
ts.factory.createPropertyAssignment("array", ts.factory.createTrue())
|
|
1420
|
+
] : [],
|
|
1414
1421
|
ts.factory.createPropertyAssignment("type", ts.factory.createStringLiteral(param.type.type ?? param.type.reference.$refText))
|
|
1415
|
-
])), true);
|
|
1416
|
-
const paramsType = ts.factory.createTupleTypeNode([
|
|
1417
|
-
...proc.params.map((param) => ts.factory.createNamedTupleMember(void 0, ts.factory.createIdentifier(param.name), void 0, ts.factory.createTypeLiteralNode([
|
|
1418
|
-
ts.factory.createPropertySignature(void 0, ts.factory.createStringLiteral("name"), void 0, ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(param.name))),
|
|
1419
|
-
ts.factory.createPropertySignature(void 0, ts.factory.createStringLiteral("type"), void 0, ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(param.type.type ?? param.type.reference.$refText))),
|
|
1420
|
-
...param.optional ? [
|
|
1421
|
-
ts.factory.createPropertySignature(void 0, ts.factory.createStringLiteral("optional"), void 0, ts.factory.createLiteralTypeNode(ts.factory.createTrue()))
|
|
1422
|
-
] : []
|
|
1423
|
-
])))
|
|
1424
|
-
]);
|
|
1422
|
+
]))), true);
|
|
1425
1423
|
return ts.factory.createObjectLiteralExpression([
|
|
1426
|
-
ts.factory.createPropertyAssignment("params",
|
|
1424
|
+
ts.factory.createPropertyAssignment("params", params),
|
|
1427
1425
|
ts.factory.createPropertyAssignment("returnType", ts.factory.createStringLiteral(proc.returnType.type ?? proc.returnType.reference.$refText)),
|
|
1426
|
+
...proc.returnType.array ? [
|
|
1427
|
+
ts.factory.createPropertyAssignment("returnArray", ts.factory.createTrue())
|
|
1428
|
+
] : [],
|
|
1428
1429
|
...proc.mutation ? [
|
|
1429
1430
|
ts.factory.createPropertyAssignment("mutation", ts.factory.createTrue())
|
|
1430
1431
|
] : []
|
|
@@ -1622,6 +1623,7 @@ var TsSchemaGenerator = class {
|
|
|
1622
1623
|
"FindManyArgs",
|
|
1623
1624
|
"FindUniqueArgs",
|
|
1624
1625
|
"FindFirstArgs",
|
|
1626
|
+
"ExistsArgs",
|
|
1625
1627
|
"CreateArgs",
|
|
1626
1628
|
"CreateManyArgs",
|
|
1627
1629
|
"CreateManyAndReturnArgs",
|