@zenstackhq/sdk 3.3.0-beta.2 → 3.3.0-beta.3

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 CHANGED
@@ -1371,6 +1371,7 @@ var TsSchemaGenerator = class {
1371
1371
  }
1372
1372
  createEnumObject(e) {
1373
1373
  return ts.factory.createObjectLiteralExpression([
1374
+ ts.factory.createPropertyAssignment("name", ts.factory.createStringLiteral(e.name)),
1374
1375
  ts.factory.createPropertyAssignment("values", ts.factory.createObjectLiteralExpression(e.fields.map((f) => ts.factory.createPropertyAssignment(f.name, ts.factory.createStringLiteral(f.name))), true)),
1375
1376
  // only generate `fields` if there are attributes on the fields
1376
1377
  ...e.fields.some((f) => f.attributes.length > 0) ? [
@@ -1486,11 +1487,15 @@ var TsSchemaGenerator = class {
1486
1487
  return this.createExpressionUtilsCall("_null");
1487
1488
  }
1488
1489
  createBinaryExpression(expr) {
1489
- return this.createExpressionUtilsCall("binary", [
1490
+ const args = [
1490
1491
  this.createExpression(expr.left),
1491
1492
  this.createLiteralNode(expr.operator),
1492
1493
  this.createExpression(expr.right)
1493
- ]);
1494
+ ];
1495
+ if (expr.binding) {
1496
+ args.push(this.createLiteralNode(expr.binding.name));
1497
+ }
1498
+ return this.createExpressionUtilsCall("binary", args);
1494
1499
  }
1495
1500
  createUnaryExpression(expr) {
1496
1501
  return this.createExpressionUtilsCall("unary", [
@@ -1504,15 +1509,14 @@ var TsSchemaGenerator = class {
1504
1509
  ]);
1505
1510
  }
1506
1511
  createRefExpression(expr) {
1507
- if ((0, import_ast3.isDataField)(expr.target.ref)) {
1508
- return this.createExpressionUtilsCall("field", [
1509
- this.createLiteralNode(expr.target.$refText)
1510
- ]);
1511
- } else if ((0, import_ast3.isEnumField)(expr.target.ref)) {
1512
- return this.createLiteralExpression("StringLiteral", expr.target.$refText);
1513
- } else {
1514
- throw new Error(`Unsupported reference type: ${expr.target.$refText}`);
1515
- }
1512
+ const target = expr.target.ref;
1513
+ return (0, import_ts_pattern2.match)(target).when(import_ast3.isDataField, () => this.createExpressionUtilsCall("field", [
1514
+ this.createLiteralNode(expr.target.$refText)
1515
+ ])).when(import_ast3.isEnumField, () => this.createLiteralExpression("StringLiteral", expr.target.$refText)).when(import_ast3.isCollectionPredicateBinding, () => this.createExpressionUtilsCall("binding", [
1516
+ this.createLiteralNode(expr.target.$refText)
1517
+ ])).otherwise(() => {
1518
+ throw Error(`Unsupported reference type: ${expr.target.$refText}`);
1519
+ });
1516
1520
  }
1517
1521
  createCallExpression(expr) {
1518
1522
  return this.createExpressionUtilsCall("call", [