@zenstackhq/sdk 3.0.0-beta.23 → 3.0.0-beta.25
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 +12 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12 -5
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1399,7 +1399,10 @@ var TsSchemaGenerator = class {
|
|
|
1399
1399
|
}
|
|
1400
1400
|
}
|
|
1401
1401
|
createLiteralNode(arg) {
|
|
1402
|
-
return arg === null ? ts.factory.createNull() : typeof arg === "string" ? ts.factory.createStringLiteral(arg) : typeof arg === "number" ?
|
|
1402
|
+
return arg === null ? ts.factory.createNull() : typeof arg === "string" ? ts.factory.createStringLiteral(arg) : typeof arg === "number" ? this.createNumberLiteral(arg) : arg === true ? ts.factory.createTrue() : arg === false ? ts.factory.createFalse() : void 0;
|
|
1403
|
+
}
|
|
1404
|
+
createNumberLiteral(arg) {
|
|
1405
|
+
return arg < 0 ? ts.factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, ts.factory.createNumericLiteral(-arg)) : ts.factory.createNumericLiteral(arg);
|
|
1403
1406
|
}
|
|
1404
1407
|
createProceduresObject(procedures) {
|
|
1405
1408
|
return ts.factory.createObjectLiteralExpression(procedures.map((proc) => ts.factory.createPropertyAssignment(proc.name, this.createProcedureObject(proc))), true);
|
|
@@ -1533,7 +1536,7 @@ var TsSchemaGenerator = class {
|
|
|
1533
1536
|
}
|
|
1534
1537
|
generateModelsAndTypeDefs(model, options) {
|
|
1535
1538
|
const statements = [];
|
|
1536
|
-
statements.push(this.generateSchemaImport(model, true, true, !!(options.lite || options.liteOnly)));
|
|
1539
|
+
statements.push(this.generateSchemaImport(model, true, true, !!(options.lite || options.liteOnly), options.importWithFileExtension));
|
|
1537
1540
|
statements.push(ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, void 0, ts.factory.createNamedImports([
|
|
1538
1541
|
ts.factory.createImportSpecifier(true, void 0, ts.factory.createIdentifier(`ModelResult as $ModelResult`)),
|
|
1539
1542
|
...model.declarations.some(import_ast3.isTypeDef) ? [
|
|
@@ -1592,7 +1595,7 @@ var TsSchemaGenerator = class {
|
|
|
1592
1595
|
const result = printer.printList(ts.ListFormat.MultiLine, ts.factory.createNodeArray(statements), sourceFile);
|
|
1593
1596
|
import_node_fs.default.writeFileSync(outputFile, result);
|
|
1594
1597
|
}
|
|
1595
|
-
generateSchemaImport(model, schemaObject, schemaType, useLite) {
|
|
1598
|
+
generateSchemaImport(model, schemaObject, schemaType, useLite, importWithFileExtension) {
|
|
1596
1599
|
const importSpecifiers = [];
|
|
1597
1600
|
if (schemaObject) {
|
|
1598
1601
|
if (model.declarations.some(import_ast3.isEnum)) {
|
|
@@ -1602,7 +1605,11 @@ var TsSchemaGenerator = class {
|
|
|
1602
1605
|
if (schemaType) {
|
|
1603
1606
|
importSpecifiers.push(ts.factory.createImportSpecifier(true, ts.factory.createIdentifier("SchemaType"), ts.factory.createIdentifier("$Schema")));
|
|
1604
1607
|
}
|
|
1605
|
-
|
|
1608
|
+
let importFrom = useLite ? "./schema-lite" : "./schema";
|
|
1609
|
+
if (importWithFileExtension) {
|
|
1610
|
+
importFrom += importWithFileExtension.startsWith(".") ? importWithFileExtension : `.${importWithFileExtension}`;
|
|
1611
|
+
}
|
|
1612
|
+
return ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, void 0, ts.factory.createNamedImports(importSpecifiers)), ts.factory.createStringLiteral(importFrom));
|
|
1606
1613
|
}
|
|
1607
1614
|
generateDocs(tsDecl, decl) {
|
|
1608
1615
|
return ts.addSyntheticLeadingComment(tsDecl, ts.SyntaxKind.MultiLineCommentTrivia, `*
|
|
@@ -1612,7 +1619,7 @@ var TsSchemaGenerator = class {
|
|
|
1612
1619
|
generateInputTypes(model, options) {
|
|
1613
1620
|
const dataModels = model.declarations.filter(import_ast3.isDataModel);
|
|
1614
1621
|
const statements = [];
|
|
1615
|
-
statements.push(this.generateSchemaImport(model, false, true, !!(options.lite || options.liteOnly)));
|
|
1622
|
+
statements.push(this.generateSchemaImport(model, false, true, !!(options.lite || options.liteOnly), options.importWithFileExtension));
|
|
1616
1623
|
const inputTypes = [
|
|
1617
1624
|
"FindManyArgs",
|
|
1618
1625
|
"FindUniqueArgs",
|