@restura/core 0.1.0-alpha.30 → 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 +51 -51
- package/dist/index.d.ts +51 -51
- package/dist/index.js +30 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
|
354
|
-
const schemaPreview = {
|
|
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.
|
|
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
|
|
@@ -1030,7 +1040,7 @@ var groupBySchema = z3.object({
|
|
|
1030
1040
|
var whereDataSchema = z3.object({
|
|
1031
1041
|
tableName: z3.string().optional(),
|
|
1032
1042
|
columnName: z3.string().optional(),
|
|
1033
|
-
operator: z3.enum(["=", "<", ">", "<=", ">=", "!=", "LIKE", "IN", "NOT IN", "STARTS WITH", "ENDS WITH"]).optional(),
|
|
1043
|
+
operator: z3.enum(["=", "<", ">", "<=", ">=", "!=", "LIKE", "IN", "NOT IN", "STARTS WITH", "ENDS WITH", "IS", "IS NOT"]).optional(),
|
|
1034
1044
|
value: z3.string().or(z3.number()).optional(),
|
|
1035
1045
|
custom: z3.string().optional(),
|
|
1036
1046
|
conjunction: z3.enum(["AND", "OR"]).optional()
|
|
@@ -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 {
|
|
@@ -1465,9 +1475,15 @@ function getRequestData(req) {
|
|
|
1465
1475
|
bodyData[attr] = attrList;
|
|
1466
1476
|
}
|
|
1467
1477
|
} else {
|
|
1468
|
-
bodyData[attr]
|
|
1469
|
-
|
|
1470
|
-
|
|
1478
|
+
if (bodyData[attr] === "true") {
|
|
1479
|
+
bodyData[attr] = true;
|
|
1480
|
+
} else if (bodyData[attr] === "false") {
|
|
1481
|
+
bodyData[attr] = false;
|
|
1482
|
+
} else {
|
|
1483
|
+
bodyData[attr] = ObjectUtils2.safeParse(bodyData[attr]);
|
|
1484
|
+
if (isNaN(Number(bodyData[attr]))) continue;
|
|
1485
|
+
bodyData[attr] = Number(bodyData[attr]);
|
|
1486
|
+
}
|
|
1471
1487
|
}
|
|
1472
1488
|
}
|
|
1473
1489
|
}
|
|
@@ -1582,8 +1598,8 @@ function SQL(strings, ...values) {
|
|
|
1582
1598
|
|
|
1583
1599
|
// src/restura/sql/PsqlConnection.ts
|
|
1584
1600
|
var PsqlConnection = class {
|
|
1585
|
-
constructor() {
|
|
1586
|
-
this.instanceId = crypto.randomUUID();
|
|
1601
|
+
constructor(instanceId) {
|
|
1602
|
+
this.instanceId = instanceId || crypto.randomUUID();
|
|
1587
1603
|
}
|
|
1588
1604
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1589
1605
|
async queryOne(query, options, requesterDetails) {
|
|
@@ -2813,8 +2829,8 @@ var restura = new ResturaEngine();
|
|
|
2813
2829
|
import pg3 from "pg";
|
|
2814
2830
|
var { Client: Client2 } = pg3;
|
|
2815
2831
|
var PsqlTransaction = class extends PsqlConnection {
|
|
2816
|
-
constructor(clientConfig) {
|
|
2817
|
-
super();
|
|
2832
|
+
constructor(clientConfig, instanceId) {
|
|
2833
|
+
super(instanceId);
|
|
2818
2834
|
this.clientConfig = clientConfig;
|
|
2819
2835
|
this.client = new Client2(clientConfig);
|
|
2820
2836
|
this.connectPromise = this.client.connect();
|