@restura/core 0.1.0-alpha.31 → 0.1.0-alpha.32

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.mts CHANGED
@@ -2104,7 +2104,7 @@ declare const resturaSchema: z.ZodObject<{
2104
2104
  }>, "many">;
2105
2105
  globalParams: z.ZodArray<z.ZodString, "many">;
2106
2106
  roles: z.ZodArray<z.ZodString, "many">;
2107
- customTypes: z.ZodString;
2107
+ customTypes: z.ZodArray<z.ZodString, "many">;
2108
2108
  }, "strict", z.ZodTypeAny, {
2109
2109
  roles: string[];
2110
2110
  database: {
@@ -2251,7 +2251,7 @@ declare const resturaSchema: z.ZodObject<{
2251
2251
  })[];
2252
2252
  }[];
2253
2253
  globalParams: string[];
2254
- customTypes: string;
2254
+ customTypes: string[];
2255
2255
  }, {
2256
2256
  roles: string[];
2257
2257
  database: {
@@ -2398,7 +2398,7 @@ declare const resturaSchema: z.ZodObject<{
2398
2398
  })[];
2399
2399
  }[];
2400
2400
  globalParams: string[];
2401
- customTypes: string;
2401
+ customTypes: string[];
2402
2402
  }>;
2403
2403
  type ResturaSchema = z.infer<typeof resturaSchema>;
2404
2404
 
package/dist/index.d.ts CHANGED
@@ -2104,7 +2104,7 @@ declare const resturaSchema: z.ZodObject<{
2104
2104
  }>, "many">;
2105
2105
  globalParams: z.ZodArray<z.ZodString, "many">;
2106
2106
  roles: z.ZodArray<z.ZodString, "many">;
2107
- customTypes: z.ZodString;
2107
+ customTypes: z.ZodArray<z.ZodString, "many">;
2108
2108
  }, "strict", z.ZodTypeAny, {
2109
2109
  roles: string[];
2110
2110
  database: {
@@ -2251,7 +2251,7 @@ declare const resturaSchema: z.ZodObject<{
2251
2251
  })[];
2252
2252
  }[];
2253
2253
  globalParams: string[];
2254
- customTypes: string;
2254
+ customTypes: string[];
2255
2255
  }, {
2256
2256
  roles: string[];
2257
2257
  database: {
@@ -2398,7 +2398,7 @@ declare const resturaSchema: z.ZodObject<{
2398
2398
  })[];
2399
2399
  }[];
2400
2400
  globalParams: string[];
2401
- customTypes: string;
2401
+ customTypes: string[];
2402
2402
  }>;
2403
2403
  type ResturaSchema = z.infer<typeof resturaSchema>;
2404
2404
 
package/dist/index.js CHANGED
@@ -396,8 +396,14 @@ var CompareSchema = class {
396
396
  let commands = "";
397
397
  if (JSON.stringify(newSchema.database) !== JSON.stringify(latestSchema.database))
398
398
  commands = await psqlEngine.diffDatabaseToSchema(newSchema);
399
- const customTypes = newSchema.customTypes !== latestSchema.customTypes;
400
- const schemaPreview = { endPoints, globalParams, roles, commands, customTypes };
399
+ const hasCustomTypesChanged = JSON.stringify(newSchema.customTypes) !== JSON.stringify(latestSchema.customTypes);
400
+ const schemaPreview = {
401
+ endPoints,
402
+ globalParams,
403
+ roles,
404
+ commands,
405
+ customTypes: hasCustomTypesChanged
406
+ };
401
407
  return schemaPreview;
402
408
  }
403
409
  diffStringArray(newArray, originalArray) {
@@ -884,7 +890,7 @@ function apiGenerator(schema) {
884
890
  apiString += `
885
891
 
886
892
  declare namespace CustomTypes {
887
- ${schema.customTypes}
893
+ ${schema.customTypes.join("\n")}
888
894
  }`;
889
895
  }
890
896
  return import_prettier.default.format(apiString, __spreadValues({
@@ -906,10 +912,14 @@ var import_tmp = __toESM(require("tmp"));
906
912
  var TJS = __toESM(require("typescript-json-schema"));
907
913
  function customTypeValidationGenerator(currentSchema) {
908
914
  const schemaObject = {};
909
- const customInterfaceNames = currentSchema.customTypes.match(new RegExp("(?<=interface\\s)(\\w+)|(?<=type\\s)(\\w+)", "g"));
915
+ const customInterfaceNames = currentSchema.customTypes.map((customType) => {
916
+ const matches = customType.match(new RegExp("(?<=interface\\s)(\\w+)|(?<=type\\s)(\\w+)", "g"));
917
+ if (matches && matches.length > 0) return matches[0];
918
+ return "";
919
+ }).filter(Boolean);
910
920
  if (!customInterfaceNames) return {};
911
921
  const temporaryFile = import_tmp.default.fileSync({ mode: 420, prefix: "prefix-", postfix: ".ts" });
912
- import_fs2.default.writeFileSync(temporaryFile.name, currentSchema.customTypes);
922
+ import_fs2.default.writeFileSync(temporaryFile.name, currentSchema.customTypes.join("\n"));
913
923
  const compilerOptions = {
914
924
  strictNullChecks: true,
915
925
  skipLibCheck: true
@@ -1315,7 +1325,7 @@ var resturaSchema = import_zod3.z.object({
1315
1325
  endpoints: import_zod3.z.array(endpointDataSchema),
1316
1326
  globalParams: import_zod3.z.array(import_zod3.z.string()),
1317
1327
  roles: import_zod3.z.array(import_zod3.z.string()),
1318
- customTypes: import_zod3.z.string()
1328
+ customTypes: import_zod3.z.array(import_zod3.z.string())
1319
1329
  }).strict();
1320
1330
  async function isSchemaValid(schemaToCheck) {
1321
1331
  try {