@zenstackhq/sdk 3.3.0-beta.2 → 3.3.0-beta.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 +19 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -12
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
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
|
-
|
|
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", [
|
|
@@ -1499,20 +1504,23 @@ var TsSchemaGenerator = class {
|
|
|
1499
1504
|
]);
|
|
1500
1505
|
}
|
|
1501
1506
|
createArrayExpression(expr) {
|
|
1507
|
+
const arrayResolved = expr.$resolvedType?.decl;
|
|
1508
|
+
const arrayType = typeof arrayResolved === "string" ? arrayResolved : arrayResolved?.name;
|
|
1509
|
+
(0, import_common_helpers2.invariant)(arrayType, "Array type must be resolved to a string or declaration");
|
|
1502
1510
|
return this.createExpressionUtilsCall("array", [
|
|
1511
|
+
this.createLiteralNode(arrayType),
|
|
1503
1512
|
ts.factory.createArrayLiteralExpression(expr.items.map((item) => this.createExpression(item)))
|
|
1504
1513
|
]);
|
|
1505
1514
|
}
|
|
1506
1515
|
createRefExpression(expr) {
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
}
|
|
1516
|
+
const target = expr.target.ref;
|
|
1517
|
+
return (0, import_ts_pattern2.match)(target).when(import_ast3.isDataField, () => this.createExpressionUtilsCall("field", [
|
|
1518
|
+
this.createLiteralNode(expr.target.$refText)
|
|
1519
|
+
])).when(import_ast3.isEnumField, () => this.createLiteralExpression("StringLiteral", expr.target.$refText)).when(import_ast3.isCollectionPredicateBinding, () => this.createExpressionUtilsCall("binding", [
|
|
1520
|
+
this.createLiteralNode(expr.target.$refText)
|
|
1521
|
+
])).otherwise(() => {
|
|
1522
|
+
throw Error(`Unsupported reference type: ${expr.target.$refText}`);
|
|
1523
|
+
});
|
|
1516
1524
|
}
|
|
1517
1525
|
createCallExpression(expr) {
|
|
1518
1526
|
return this.createExpressionUtilsCall("call", [
|