@restura/core 1.0.8 → 1.0.10

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.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import winston from 'winston';
2
- import { z } from 'zod/v4';
2
+ import { z } from 'zod';
3
3
  import { UUID } from 'crypto';
4
4
  import * as express from 'express';
5
5
  import { IncomingHttpHeaders } from 'http2';
@@ -34,11 +34,12 @@ declare enum HtmlStatusCodes {
34
34
  METHOD_NOT_ALLOWED = 405,
35
35
  CONFLICT = 409,
36
36
  VERSION_OUT_OF_DATE = 418,// Technically this is the I'm a teapot code that was a joke.
37
+ UNPROCESSABLE_ENTITY = 422,
37
38
  SERVER_ERROR = 500,
38
39
  SERVICE_UNAVAILABLE = 503,
39
40
  NETWORK_CONNECT_TIMEOUT = 599
40
41
  }
41
- type ErrorCode = 'UNKNOWN_ERROR' | 'NOT_FOUND' | 'EMAIL_TAKEN' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'CONFLICT' | 'UPDATE_FORBIDDEN' | 'CREATE_FORBIDDEN' | 'DELETE_FORBIDDEN' | 'DELETE_FAILURE' | 'BAD_REQUEST' | 'INVALID_TOKEN' | 'INCORRECT_EMAIL_OR_PASSWORD' | 'DUPLICATE_TOKEN' | 'DUPLICATE_USERNAME' | 'DUPLICATE_EMAIL' | 'DUPLICATE' | 'EMAIL_NOT_VERIFIED' | 'UPDATE_WITHOUT_ID' | 'CONNECTION_ERROR' | 'INVALID_PAYMENT' | 'DECLINED_PAYMENT' | 'INTEGRATION_ERROR' | 'CANNOT_RESERVE' | 'REFUND_FAILURE' | 'INVALID_INVOICE' | 'INVALID_COUPON' | 'SERVICE_UNAVAILABLE' | 'METHOD_UNALLOWED' | 'LOGIN_EXPIRED' | 'THIRD_PARTY_ERROR' | 'ACCESS_DENIED' | 'DATABASE_ERROR' | 'SCHEMA_ERROR';
42
+ type ErrorCode = 'UNKNOWN_ERROR' | 'NOT_FOUND' | 'EMAIL_TAKEN' | 'UNAUTHORIZED' | 'FORBIDDEN' | 'CONFLICT' | 'UPDATE_FORBIDDEN' | 'CREATE_FORBIDDEN' | 'DELETE_FORBIDDEN' | 'DELETE_FAILURE' | 'BAD_REQUEST' | 'INVALID_TOKEN' | 'INCORRECT_EMAIL_OR_PASSWORD' | 'DUPLICATE_TOKEN' | 'DUPLICATE_USERNAME' | 'DUPLICATE_EMAIL' | 'DUPLICATE' | 'EMAIL_NOT_VERIFIED' | 'UPDATE_WITHOUT_ID' | 'CONNECTION_ERROR' | 'INVALID_PAYMENT' | 'DECLINED_PAYMENT' | 'INTEGRATION_ERROR' | 'CANNOT_RESERVE' | 'REFUND_FAILURE' | 'INVALID_INVOICE' | 'INVALID_COUPON' | 'SERVICE_UNAVAILABLE' | 'METHOD_UNALLOWED' | 'LOGIN_EXPIRED' | 'THIRD_PARTY_ERROR' | 'ACCESS_DENIED' | 'DATABASE_ERROR' | 'SCHEMA_ERROR' | 'DATA_INCOMPLETE';
42
43
  declare class RsError {
43
44
  err: ErrorCode;
44
45
  msg: string;
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import winston from "winston";
15
15
  import { format } from "logform";
16
16
 
17
17
  // src/logger/loggerConfigSchema.ts
18
- import { z } from "zod/v4";
18
+ import { z } from "zod";
19
19
  var loggerConfigSchema = z.object({
20
20
  level: z.enum(["info", "warn", "error", "debug", "silly"]).default("info")
21
21
  });
@@ -184,7 +184,8 @@ var SqlUtils = class _SqlUtils {
184
184
  static convertDatabaseTypeToTypescript(type, value) {
185
185
  type = type.toLocaleLowerCase();
186
186
  if (type.startsWith("tinyint") || type.startsWith("boolean")) return "boolean";
187
- if (type.indexOf("int") > -1 || type.startsWith("decimal") || type.startsWith("double") || type.startsWith("float") || type.indexOf("serial") > -1 || type.startsWith("decimal") || type.startsWith("real") || type.startsWith("double precision") || type.startsWith("numeric"))
187
+ if (type.startsWith("decimal") || type.startsWith("numeric")) return "string";
188
+ if (type.indexOf("int") > -1 || type.startsWith("double") || type.startsWith("float") || type.indexOf("serial") > -1 || type.startsWith("real") || type.startsWith("double precision"))
188
189
  return "number";
189
190
  if (type === "json") {
190
191
  if (!value) return "object";
@@ -214,6 +215,7 @@ var HtmlStatusCodes = /* @__PURE__ */ ((HtmlStatusCodes2) => {
214
215
  HtmlStatusCodes2[HtmlStatusCodes2["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
215
216
  HtmlStatusCodes2[HtmlStatusCodes2["CONFLICT"] = 409] = "CONFLICT";
216
217
  HtmlStatusCodes2[HtmlStatusCodes2["VERSION_OUT_OF_DATE"] = 418] = "VERSION_OUT_OF_DATE";
218
+ HtmlStatusCodes2[HtmlStatusCodes2["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
217
219
  HtmlStatusCodes2[HtmlStatusCodes2["SERVER_ERROR"] = 500] = "SERVER_ERROR";
218
220
  HtmlStatusCodes2[HtmlStatusCodes2["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
219
221
  HtmlStatusCodes2[HtmlStatusCodes2["NETWORK_CONNECT_TIMEOUT"] = 599] = "NETWORK_CONNECT_TIMEOUT";
@@ -271,7 +273,8 @@ var htmlStatusMap = {
271
273
  THIRD_PARTY_ERROR: 400 /* BAD_REQUEST */,
272
274
  ACCESS_DENIED: 403 /* FORBIDDEN */,
273
275
  DATABASE_ERROR: 500 /* SERVER_ERROR */,
274
- SCHEMA_ERROR: 500 /* SERVER_ERROR */
276
+ SCHEMA_ERROR: 500 /* SERVER_ERROR */,
277
+ DATA_INCOMPLETE: 422 /* UNPROCESSABLE_ENTITY */
275
278
  };
276
279
 
277
280
  // src/restura/validators/ResponseValidator.ts
@@ -1058,10 +1061,10 @@ var getMulterUpload = (directory) => {
1058
1061
  };
1059
1062
 
1060
1063
  // src/restura/schemas/resturaSchema.ts
1061
- import { z as z3 } from "zod/v4";
1064
+ import { z as z3 } from "zod";
1062
1065
 
1063
1066
  // src/restura/schemas/validatorDataSchema.ts
1064
- import { z as z2 } from "zod/v4";
1067
+ import { z as z2 } from "zod";
1065
1068
  var validatorDataSchemeValue = z2.union([z2.string(), z2.array(z2.string()), z2.number(), z2.array(z2.number())]);
1066
1069
  var validatorDataSchema = z2.object({
1067
1070
  type: z2.enum(["TYPE_CHECK", "MIN", "MAX", "ONE_OF"]),
@@ -1173,7 +1176,7 @@ var postgresColumnNumericTypesSchema = z3.enum([
1173
1176
  "BIGINT",
1174
1177
  // 8 bytes, -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
1175
1178
  "DECIMAL",
1176
- // user-specified precision, exact numeric
1179
+ // user-specified precision, exact numeric, this is returned as a string type because numbers are not accurate enough
1177
1180
  "NUMERIC",
1178
1181
  // same as DECIMAL
1179
1182
  "REAL",
@@ -1364,7 +1367,7 @@ async function isSchemaValid(schemaToCheck) {
1364
1367
  // src/restura/validators/requestValidator.ts
1365
1368
  import { ObjectUtils as ObjectUtils2 } from "@redskytech/core-utils";
1366
1369
  import jsonschema from "jsonschema";
1367
- import { z as z4 } from "zod/v4";
1370
+ import { z as z4 } from "zod";
1368
1371
 
1369
1372
  // src/restura/utils/utils.ts
1370
1373
  function addQuotesToStrings(variable) {
@@ -1591,7 +1594,7 @@ async function schemaValidation(req, res, next) {
1591
1594
  }
1592
1595
 
1593
1596
  // src/restura/schemas/resturaConfigSchema.ts
1594
- import { z as z5 } from "zod/v4";
1597
+ import { z as z5 } from "zod";
1595
1598
  var isTsx = process.argv[1]?.endsWith(".ts");
1596
1599
  var isTsNode = process.env.TS_NODE_DEV || process.env.TS_NODE_PROJECT;
1597
1600
  var customApiFolderPath = isTsx || isTsNode ? "/src/api" : "/dist/api";
@@ -1618,7 +1621,7 @@ import pg from "pg";
1618
1621
  import crypto from "crypto";
1619
1622
  import format3 from "pg-format";
1620
1623
  import { format as sqlFormat } from "sql-formatter";
1621
- import { z as z6 } from "zod/v4";
1624
+ import { z as z6 } from "zod";
1622
1625
 
1623
1626
  // src/restura/sql/PsqlUtils.ts
1624
1627
  import format2 from "pg-format";