@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.mjs CHANGED
@@ -350,8 +350,14 @@ var CompareSchema = class {
350
350
  let commands = "";
351
351
  if (JSON.stringify(newSchema.database) !== JSON.stringify(latestSchema.database))
352
352
  commands = await psqlEngine.diffDatabaseToSchema(newSchema);
353
- const customTypes = newSchema.customTypes !== latestSchema.customTypes;
354
- const schemaPreview = { endPoints, globalParams, roles, commands, customTypes };
353
+ const hasCustomTypesChanged = JSON.stringify(newSchema.customTypes) !== JSON.stringify(latestSchema.customTypes);
354
+ const schemaPreview = {
355
+ endPoints,
356
+ globalParams,
357
+ roles,
358
+ commands,
359
+ customTypes: hasCustomTypesChanged
360
+ };
355
361
  return schemaPreview;
356
362
  }
357
363
  diffStringArray(newArray, originalArray) {
@@ -838,7 +844,7 @@ function apiGenerator(schema) {
838
844
  apiString += `
839
845
 
840
846
  declare namespace CustomTypes {
841
- ${schema.customTypes}
847
+ ${schema.customTypes.join("\n")}
842
848
  }`;
843
849
  }
844
850
  return prettier.format(apiString, __spreadValues({
@@ -860,10 +866,14 @@ import tmp from "tmp";
860
866
  import * as TJS from "typescript-json-schema";
861
867
  function customTypeValidationGenerator(currentSchema) {
862
868
  const schemaObject = {};
863
- const customInterfaceNames = currentSchema.customTypes.match(new RegExp("(?<=interface\\s)(\\w+)|(?<=type\\s)(\\w+)", "g"));
869
+ const customInterfaceNames = currentSchema.customTypes.map((customType) => {
870
+ const matches = customType.match(new RegExp("(?<=interface\\s)(\\w+)|(?<=type\\s)(\\w+)", "g"));
871
+ if (matches && matches.length > 0) return matches[0];
872
+ return "";
873
+ }).filter(Boolean);
864
874
  if (!customInterfaceNames) return {};
865
875
  const temporaryFile = tmp.fileSync({ mode: 420, prefix: "prefix-", postfix: ".ts" });
866
- fs2.writeFileSync(temporaryFile.name, currentSchema.customTypes);
876
+ fs2.writeFileSync(temporaryFile.name, currentSchema.customTypes.join("\n"));
867
877
  const compilerOptions = {
868
878
  strictNullChecks: true,
869
879
  skipLibCheck: true
@@ -1269,7 +1279,7 @@ var resturaSchema = z3.object({
1269
1279
  endpoints: z3.array(endpointDataSchema),
1270
1280
  globalParams: z3.array(z3.string()),
1271
1281
  roles: z3.array(z3.string()),
1272
- customTypes: z3.string()
1282
+ customTypes: z3.array(z3.string())
1273
1283
  }).strict();
1274
1284
  async function isSchemaValid(schemaToCheck) {
1275
1285
  try {