@zenstackhq/sdk 3.0.0-alpha.2 → 3.0.0-alpha.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.d.cts CHANGED
@@ -109,7 +109,6 @@ declare class TsSchemaGenerator {
109
109
  private createEnumObject;
110
110
  private getLiteral;
111
111
  private createLiteralNode;
112
- private createDialectConfigProvider;
113
112
  private createProceduresObject;
114
113
  private createProcedureObject;
115
114
  private generateBannerComments;
package/dist/index.d.ts CHANGED
@@ -109,7 +109,6 @@ declare class TsSchemaGenerator {
109
109
  private createEnumObject;
110
110
  private getLiteral;
111
111
  private createLiteralNode;
112
- private createDialectConfigProvider;
113
112
  private createProceduresObject;
114
113
  private createProcedureObject;
115
114
  private generateBannerComments;
package/dist/index.js CHANGED
@@ -819,27 +819,6 @@ var TsSchemaGenerator = class {
819
819
  ts.factory.createImportSpecifier(false, void 0, ts.factory.createIdentifier("ExpressionUtils"))
820
820
  ])), ts.factory.createStringLiteral("@zenstackhq/runtime/schema"));
821
821
  statements.push(runtimeImportDecl);
822
- const { type: providerType } = this.getDataSourceProvider(model);
823
- switch (providerType) {
824
- case "sqlite": {
825
- const pathImportDecl = ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, ts.factory.createIdentifier("path"), void 0), ts.factory.createStringLiteral("node:path"));
826
- statements.push(pathImportDecl);
827
- const urlImportDecl = ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, ts.factory.createIdentifier("url"), void 0), ts.factory.createStringLiteral("node:url"));
828
- statements.push(urlImportDecl);
829
- const dialectConfigImportDecl = ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, void 0, ts.factory.createNamedImports([
830
- ts.factory.createImportSpecifier(false, void 0, ts.factory.createIdentifier("toDialectConfig"))
831
- ])), ts.factory.createStringLiteral("@zenstackhq/runtime/utils/sqlite-utils"));
832
- statements.push(dialectConfigImportDecl);
833
- break;
834
- }
835
- case "postgresql": {
836
- const dialectConfigImportDecl = ts.factory.createImportDeclaration(void 0, ts.factory.createImportClause(false, void 0, ts.factory.createNamedImports([
837
- ts.factory.createImportSpecifier(false, void 0, ts.factory.createIdentifier("toDialectConfig"))
838
- ])), ts.factory.createStringLiteral("@zenstackhq/runtime/utils/pg-utils"));
839
- statements.push(dialectConfigImportDecl);
840
- break;
841
- }
842
- }
843
822
  const declaration = ts.factory.createVariableStatement([
844
823
  ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)
845
824
  ], ts.factory.createVariableDeclarationList([
@@ -876,8 +855,7 @@ var TsSchemaGenerator = class {
876
855
  createProviderObject(model) {
877
856
  const dsProvider = this.getDataSourceProvider(model);
878
857
  return ts.factory.createObjectLiteralExpression([
879
- ts.factory.createPropertyAssignment("type", ts.factory.createStringLiteral(dsProvider.type)),
880
- ts.factory.createPropertyAssignment("dialectConfigProvider", this.createDialectConfigProvider(dsProvider))
858
+ ts.factory.createPropertyAssignment("type", ts.factory.createStringLiteral(dsProvider.type))
881
859
  ], true);
882
860
  }
883
861
  createModelsObject(model) {
@@ -1185,44 +1163,6 @@ var TsSchemaGenerator = class {
1185
1163
  createLiteralNode(arg) {
1186
1164
  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;
1187
1165
  }
1188
- createDialectConfigProvider(dsProvider) {
1189
- const type = dsProvider.type;
1190
- let urlExpr;
1191
- if (dsProvider.env !== void 0) {
1192
- urlExpr = ts.factory.createIdentifier(`process.env['${dsProvider.env}']`);
1193
- } else {
1194
- urlExpr = ts.factory.createStringLiteral(dsProvider.url);
1195
- if (type === "sqlite") {
1196
- let parsedUrl;
1197
- try {
1198
- parsedUrl = new URL(dsProvider.url);
1199
- } catch {
1200
- }
1201
- if (parsedUrl) {
1202
- if (parsedUrl.protocol !== "file:") {
1203
- throw new Error("Invalid SQLite URL: only file protocol is supported");
1204
- }
1205
- urlExpr = ts.factory.createStringLiteral(dsProvider.url.replace(/^file:/, ""));
1206
- }
1207
- }
1208
- }
1209
- return match2(type).with("sqlite", () => {
1210
- return ts.factory.createFunctionExpression(void 0, void 0, void 0, void 0, void 0, void 0, ts.factory.createBlock([
1211
- ts.factory.createReturnStatement(ts.factory.createCallExpression(ts.factory.createIdentifier("toDialectConfig"), void 0, [
1212
- urlExpr,
1213
- ts.factory.createIdentifier(`typeof __dirname !== 'undefined' ? __dirname : path.dirname(url.fileURLToPath(import.meta.url))`)
1214
- ]))
1215
- ], true));
1216
- }).with("postgresql", () => {
1217
- return ts.factory.createFunctionExpression(void 0, void 0, void 0, void 0, void 0, void 0, ts.factory.createBlock([
1218
- ts.factory.createReturnStatement(ts.factory.createCallExpression(ts.factory.createIdentifier("toDialectConfig"), void 0, [
1219
- urlExpr
1220
- ]))
1221
- ], true));
1222
- }).otherwise(() => {
1223
- throw new Error(`Unsupported provider: ${type}`);
1224
- });
1225
- }
1226
1166
  createProceduresObject(procedures) {
1227
1167
  return ts.factory.createObjectLiteralExpression(procedures.map((proc) => ts.factory.createPropertyAssignment(proc.name, this.createProcedureObject(proc))), true);
1228
1168
  }