@zenstackhq/sdk 3.0.0-beta.23 → 3.0.0-beta.24

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.d.cts CHANGED
@@ -128,6 +128,7 @@ type TsSchemaGeneratorOptions = {
128
128
  outDir: string;
129
129
  lite?: boolean;
130
130
  liteOnly?: boolean;
131
+ importWithFileExtension?: string;
131
132
  };
132
133
  declare class TsSchemaGenerator {
133
134
  private usedExpressionUtils;
@@ -164,6 +165,7 @@ declare class TsSchemaGenerator {
164
165
  private createEnumObject;
165
166
  private getLiteral;
166
167
  private createLiteralNode;
168
+ private createNumberLiteral;
167
169
  private createProceduresObject;
168
170
  private createProcedureObject;
169
171
  private generateBannerComments;
package/dist/index.d.ts CHANGED
@@ -128,6 +128,7 @@ type TsSchemaGeneratorOptions = {
128
128
  outDir: string;
129
129
  lite?: boolean;
130
130
  liteOnly?: boolean;
131
+ importWithFileExtension?: string;
131
132
  };
132
133
  declare class TsSchemaGenerator {
133
134
  private usedExpressionUtils;
@@ -164,6 +165,7 @@ declare class TsSchemaGenerator {
164
165
  private createEnumObject;
165
166
  private getLiteral;
166
167
  private createLiteralNode;
168
+ private createNumberLiteral;
167
169
  private createProceduresObject;
168
170
  private createProcedureObject;
169
171
  private generateBannerComments;
package/dist/index.js CHANGED
@@ -1367,7 +1367,10 @@ var TsSchemaGenerator = class {
1367
1367
  }
1368
1368
  }
1369
1369
  createLiteralNode(arg) {
1370
- return arg === null ? ts.factory.createNull() : typeof arg === "string" ? ts.factory.createStringLiteral(arg) : typeof arg === "number" ? ts.factory.createNumericLiteral(arg) : arg === true ? ts.factory.createTrue() : arg === false ? ts.factory.createFalse() : void 0;
1370
+ 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;
1371
+ }
1372
+ createNumberLiteral(arg) {
1373
+ return arg < 0 ? ts.factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, ts.factory.createNumericLiteral(-arg)) : ts.factory.createNumericLiteral(arg);
1371
1374
  }
1372
1375
  createProceduresObject(procedures) {
1373
1376
  return ts.factory.createObjectLiteralExpression(procedures.map((proc) => ts.factory.createPropertyAssignment(proc.name, this.createProcedureObject(proc))), true);
@@ -1501,7 +1504,7 @@ var TsSchemaGenerator = class {
1501
1504
  }
1502
1505
  generateModelsAndTypeDefs(model, options) {
1503
1506
  const statements = [];
1504
- statements.push(this.generateSchemaImport(model, true, true, !!(options.lite || options.liteOnly)));
1507
+ statements.push(this.generateSchemaImport(model, true, true, !!(options.lite || options.liteOnly), options.importWithFileExtension));
1505
1508
  statements.push(ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, void 0, ts.factory.createNamedImports([
1506
1509
  ts.factory.createImportSpecifier(true, void 0, ts.factory.createIdentifier(`ModelResult as $ModelResult`)),
1507
1510
  ...model.declarations.some(isTypeDef3) ? [
@@ -1560,7 +1563,7 @@ var TsSchemaGenerator = class {
1560
1563
  const result = printer.printList(ts.ListFormat.MultiLine, ts.factory.createNodeArray(statements), sourceFile);
1561
1564
  fs.writeFileSync(outputFile, result);
1562
1565
  }
1563
- generateSchemaImport(model, schemaObject, schemaType, useLite) {
1566
+ generateSchemaImport(model, schemaObject, schemaType, useLite, importWithFileExtension) {
1564
1567
  const importSpecifiers = [];
1565
1568
  if (schemaObject) {
1566
1569
  if (model.declarations.some(isEnum)) {
@@ -1570,7 +1573,11 @@ var TsSchemaGenerator = class {
1570
1573
  if (schemaType) {
1571
1574
  importSpecifiers.push(ts.factory.createImportSpecifier(true, ts.factory.createIdentifier("SchemaType"), ts.factory.createIdentifier("$Schema")));
1572
1575
  }
1573
- return ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, void 0, ts.factory.createNamedImports(importSpecifiers)), ts.factory.createStringLiteral(useLite ? "./schema-lite" : "./schema"));
1576
+ let importFrom = useLite ? "./schema-lite" : "./schema";
1577
+ if (importWithFileExtension) {
1578
+ importFrom += importWithFileExtension.startsWith(".") ? importWithFileExtension : `.${importWithFileExtension}`;
1579
+ }
1580
+ return ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, void 0, ts.factory.createNamedImports(importSpecifiers)), ts.factory.createStringLiteral(importFrom));
1574
1581
  }
1575
1582
  generateDocs(tsDecl, decl) {
1576
1583
  return ts.addSyntheticLeadingComment(tsDecl, ts.SyntaxKind.MultiLineCommentTrivia, `*
@@ -1580,7 +1587,7 @@ var TsSchemaGenerator = class {
1580
1587
  generateInputTypes(model, options) {
1581
1588
  const dataModels = model.declarations.filter(isDataModel3);
1582
1589
  const statements = [];
1583
- statements.push(this.generateSchemaImport(model, false, true, !!(options.lite || options.liteOnly)));
1590
+ statements.push(this.generateSchemaImport(model, false, true, !!(options.lite || options.liteOnly), options.importWithFileExtension));
1584
1591
  const inputTypes = [
1585
1592
  "FindManyArgs",
1586
1593
  "FindUniqueArgs",