@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.js CHANGED
@@ -1066,7 +1066,9 @@ var TsSchemaGenerator = class {
1066
1066
  }
1067
1067
  const defaultValue = this.getFieldMappedDefault(field);
1068
1068
  if (defaultValue !== void 0) {
1069
- if (typeof defaultValue === "object" && !Array.isArray(defaultValue)) {
1069
+ if (defaultValue === null) {
1070
+ objectFields.push(ts.factory.createPropertyAssignment("default", this.createExpressionUtilsCall("_null")));
1071
+ } else if (typeof defaultValue === "object" && !Array.isArray(defaultValue)) {
1070
1072
  if ("call" in defaultValue) {
1071
1073
  objectFields.push(ts.factory.createPropertyAssignment("default", this.createExpressionUtilsCall("call", [
1072
1074
  ts.factory.createStringLiteral(defaultValue.call),
@@ -1158,8 +1160,10 @@ var TsSchemaGenerator = class {
1158
1160
  return {
1159
1161
  authMember: this.getMemberAccessChain(expr)
1160
1162
  };
1163
+ } else if (isNullExpr2(expr)) {
1164
+ return null;
1161
1165
  } else {
1162
- throw new Error(`Unsupported default value type for ${expr.$type}`);
1166
+ throw new Error(`Unsupported expression type: ${expr.$type}`);
1163
1167
  }
1164
1168
  }
1165
1169
  getMemberAccessChain(expr) {
@@ -1374,25 +1378,22 @@ var TsSchemaGenerator = class {
1374
1378
  return ts.factory.createObjectLiteralExpression(procedures.map((proc) => ts.factory.createPropertyAssignment(proc.name, this.createProcedureObject(proc))), true);
1375
1379
  }
1376
1380
  createProcedureObject(proc) {
1377
- const params = ts.factory.createArrayLiteralExpression(proc.params.map((param) => ts.factory.createObjectLiteralExpression([
1381
+ const params = ts.factory.createObjectLiteralExpression(proc.params.map((param) => ts.factory.createPropertyAssignment(param.name, ts.factory.createObjectLiteralExpression([
1378
1382
  ts.factory.createPropertyAssignment("name", ts.factory.createStringLiteral(param.name)),
1379
1383
  ...param.optional ? [
1380
1384
  ts.factory.createPropertyAssignment("optional", ts.factory.createTrue())
1381
1385
  ] : [],
1386
+ ...param.type.array ? [
1387
+ ts.factory.createPropertyAssignment("array", ts.factory.createTrue())
1388
+ ] : [],
1382
1389
  ts.factory.createPropertyAssignment("type", ts.factory.createStringLiteral(param.type.type ?? param.type.reference.$refText))
1383
- ])), true);
1384
- const paramsType = ts.factory.createTupleTypeNode([
1385
- ...proc.params.map((param) => ts.factory.createNamedTupleMember(void 0, ts.factory.createIdentifier(param.name), void 0, ts.factory.createTypeLiteralNode([
1386
- ts.factory.createPropertySignature(void 0, ts.factory.createStringLiteral("name"), void 0, ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(param.name))),
1387
- ts.factory.createPropertySignature(void 0, ts.factory.createStringLiteral("type"), void 0, ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(param.type.type ?? param.type.reference.$refText))),
1388
- ...param.optional ? [
1389
- ts.factory.createPropertySignature(void 0, ts.factory.createStringLiteral("optional"), void 0, ts.factory.createLiteralTypeNode(ts.factory.createTrue()))
1390
- ] : []
1391
- ])))
1392
- ]);
1390
+ ]))), true);
1393
1391
  return ts.factory.createObjectLiteralExpression([
1394
- ts.factory.createPropertyAssignment("params", ts.factory.createAsExpression(params, paramsType)),
1392
+ ts.factory.createPropertyAssignment("params", params),
1395
1393
  ts.factory.createPropertyAssignment("returnType", ts.factory.createStringLiteral(proc.returnType.type ?? proc.returnType.reference.$refText)),
1394
+ ...proc.returnType.array ? [
1395
+ ts.factory.createPropertyAssignment("returnArray", ts.factory.createTrue())
1396
+ ] : [],
1396
1397
  ...proc.mutation ? [
1397
1398
  ts.factory.createPropertyAssignment("mutation", ts.factory.createTrue())
1398
1399
  ] : []
@@ -1590,6 +1591,7 @@ var TsSchemaGenerator = class {
1590
1591
  "FindManyArgs",
1591
1592
  "FindUniqueArgs",
1592
1593
  "FindFirstArgs",
1594
+ "ExistsArgs",
1593
1595
  "CreateArgs",
1594
1596
  "CreateManyArgs",
1595
1597
  "CreateManyAndReturnArgs",