Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mrnafisia/type-query

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mrnafisia/type-query - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

dist/cast.d.ts

3

dist/entity.js

@@ -386,3 +386,4 @@ "use strict";

var by = order.by, direction = order.direction;
ordersTextArray.push("\"".concat(by, "\" ").concat(direction));
var _c = getTableDataOfJoinSelectColumn(allTables, by), table = _c.table, alias = _c.alias;
ordersTextArray.push("".concat(resolveColumn(table, by.substring((alias + '_').length), true, alias), " ").concat((0, dictionary_1.toOrderDirection)(direction)));
}

@@ -389,0 +390,0 @@ tokens.push('ORDER BY', ordersTextArray.join(', '));

@@ -17,4 +17,4 @@ export { U } from './U';

export { createTables, dropTables, resolveTablesDependency, createSequencesSQL, dropSequencesSQL, createTableSQL, dropTableSQL, getSequenceName } from './schema';
export * as Parser from './parser';
export { Cast } from './cast';
export type { JoinType, Param, QueryData, TableWithAlias, JoinData, Mode, CustomColumn, ExpressionTypes, Expression, ValueExpression, QueryExpression, InsertValue, UpdateSets, Query, QueryResult, QueryResultRow, PartialQuery } from './types/Entity';
//# sourceMappingURL=index.d.ts.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Parser = exports.getSequenceName = exports.dropTableSQL = exports.createTableSQL = exports.dropSequencesSQL = exports.createSequencesSQL = exports.resolveTablesDependency = exports.dropTables = exports.createTables = exports.resolveExpression = exports.resolveReturning = exports.resolveResult = exports.createEntity = exports.createTestTableData = exports.testTransaction = exports.removeHook = exports.addHook = exports.createPool = exports.createModelUtils = exports.createContext = exports.PostgresErrors = exports.U = void 0;
exports.Cast = exports.getSequenceName = exports.dropTableSQL = exports.createTableSQL = exports.dropSequencesSQL = exports.createSequencesSQL = exports.resolveTablesDependency = exports.dropTables = exports.createTables = exports.resolveExpression = exports.resolveReturning = exports.resolveResult = exports.createEntity = exports.createTestTableData = exports.testTransaction = exports.removeHook = exports.addHook = exports.createPool = exports.createModelUtils = exports.createContext = exports.PostgresErrors = exports.U = void 0;
var U_1 = require("./U");

@@ -56,3 +33,4 @@ Object.defineProperty(exports, "U", { enumerable: true, get: function () { return U_1.U; } });

Object.defineProperty(exports, "getSequenceName", { enumerable: true, get: function () { return schema_1.getSequenceName; } });
exports.Parser = __importStar(require("./parser"));
var cast_1 = require("./cast");
Object.defineProperty(exports, "Cast", { enumerable: true, get: function () { return cast_1.Cast; } });
//# sourceMappingURL=index.js.map

@@ -962,3 +962,3 @@ import Decimal from 'decimal.js';

}>(columns: Columns, custom?: {
parse?: { [key in keyof Columns]?: (v: unknown | undefined) => import("./types/postgres").PostgresTypeMapper<Columns[key]["type"], Columns[key]["nullable"]> | undefined; };
cast?: { [key in keyof Columns]?: (v: unknown | undefined) => import("./types/postgres").PostgresTypeMapper<Columns[key]["type"], Columns[key]["nullable"]> | undefined; };
validate?: { [key_1 in keyof Columns]?: (v: import("./types/postgres").PostgresTypeMapper<Columns[key_1]["type"], Columns[key_1]["nullable"]>) => boolean; };

@@ -965,0 +965,0 @@ } | undefined) => ModelUtils<Columns>;

@@ -13,28 +13,5 @@ "use strict";

};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateStringGenerator = exports.validateDecimalGenerator = exports.validateNumberGenerator = exports.createModelUtils = void 0;
var Parser = __importStar(require("./parser"));
var cast_1 = require("./cast");
var never_catch_1 = require("never-catch");

@@ -128,24 +105,24 @@ var smallIntRange = { min: -32768, max: 32767 };

var createModelUtils = function (columns, custom) {
var columnsParseAndValidate = Object.fromEntries(Object.entries(columns).map(function (_a) {
var columnsParser = Object.fromEntries(Object.entries(columns).map(function (_a) {
var _b, _c, _d, _e, _f, _g, _h, _j;
var key = _a[0], val = _a[1];
var parseFun = (_b = custom === null || custom === void 0 ? void 0 : custom.parse) === null || _b === void 0 ? void 0 : _b[key];
if (parseFun === undefined) {
var castFun = (_b = custom === null || custom === void 0 ? void 0 : custom.cast) === null || _b === void 0 ? void 0 : _b[key];
if (castFun === undefined) {
switch (val.type) {
case 'boolean':
parseFun = Parser.boolean;
castFun = cast_1.Cast.boolean;
break;
case 'smallint':
case 'integer':
parseFun = Parser.integer;
castFun = cast_1.Cast.integer;
break;
case 'real':
case 'double precision':
parseFun = Parser.number;
castFun = cast_1.Cast.number;
break;
case 'bigint':
parseFun = Parser.bigInt;
castFun = cast_1.Cast.bigInt;
break;
case 'numeric':
parseFun = Parser.decimal;
castFun = cast_1.Cast.decimal;
break;

@@ -156,3 +133,3 @@ case 'character':

case 'uuid':
parseFun = Parser.string;
castFun = cast_1.Cast.string;
break;

@@ -162,7 +139,7 @@ case 'date':

case 'timestamp with time zone':
parseFun = Parser.date;
castFun = cast_1.Cast.date;
break;
case 'json':
case 'jsonb':
parseFun = Parser.json;
castFun = cast_1.Cast.json;
break;

@@ -172,76 +149,72 @@ }

var validateFun = (_c = custom === null || custom === void 0 ? void 0 : custom.validate) === null || _c === void 0 ? void 0 : _c[key];
if (validateFun === undefined) {
switch (val.type) {
case 'smallint':
validateFun = validateNumberGenerator({
min: (_d = val.min) !== null && _d !== void 0 ? _d : smallIntRange.min,
max: (_e = val.max) !== null && _e !== void 0 ? _e : smallIntRange.max
switch (val.type) {
case 'smallint':
validateFun = validateNumberGenerator({
min: (_d = val.min) !== null && _d !== void 0 ? _d : smallIntRange.min,
max: (_e = val.max) !== null && _e !== void 0 ? _e : smallIntRange.max
});
break;
case 'integer':
validateFun = validateNumberGenerator({
min: (_f = val.min) !== null && _f !== void 0 ? _f : integerRange.min,
max: (_g = val.max) !== null && _g !== void 0 ? _g : integerRange.max
});
break;
case 'bigint':
validateFun = validateNumberGenerator({
min: (_h = val.min) !== null && _h !== void 0 ? _h : bigIntRange.min,
max: (_j = val.max) !== null && _j !== void 0 ? _j : bigIntRange.max
});
break;
case 'real':
case 'double precision':
if (val.min !== undefined || val.max !== undefined) {
validateFun = validateNumberGenerator({ min: val.min, max: val.max });
}
else {
validateFun = function () { return true; };
}
break;
case 'numeric':
if (val.min !== undefined || val.max !== undefined) {
validateFun = validateDecimalGenerator({ min: val.min, max: val.max });
}
else {
validateFun = function () { return true; };
}
break;
case 'character':
case 'character varying':
if (val.minLength !== undefined || val.maxLength !== undefined || val.regex !== undefined) {
validateFun = validateStringGenerator({
regex: val.regex,
min: val.minLength,
max: val.maxLength
});
break;
case 'integer':
validateFun = validateNumberGenerator({
min: (_f = val.min) !== null && _f !== void 0 ? _f : integerRange.min,
max: (_g = val.max) !== null && _g !== void 0 ? _g : integerRange.max
});
break;
case 'bigint':
validateFun = validateNumberGenerator({
min: (_h = val.min) !== null && _h !== void 0 ? _h : bigIntRange.min,
max: (_j = val.max) !== null && _j !== void 0 ? _j : bigIntRange.max
});
break;
case 'real':
case 'double precision':
if (val.min !== undefined || val.max !== undefined) {
validateFun = validateNumberGenerator({ min: val.min, max: val.max });
}
else {
validateFun = function () { return true; };
}
break;
case 'numeric':
if (val.min !== undefined || val.max !== undefined) {
validateFun = validateDecimalGenerator({ min: val.min, max: val.max });
}
else {
validateFun = function () { return true; };
}
break;
case 'character':
case 'character varying':
if (val.minLength !== undefined || val.maxLength !== undefined || val.regex !== undefined) {
validateFun = validateStringGenerator({
regex: val.regex,
min: val.minLength,
max: val.maxLength
});
}
else {
validateFun = function () { return true; };
}
break;
case 'boolean':
case 'text':
case 'uuid':
case 'date':
case 'timestamp without time zone':
case 'timestamp with time zone':
case 'json':
case 'jsonb':
}
else {
validateFun = function () { return true; };
break;
}
}
break;
case 'boolean':
case 'text':
case 'uuid':
case 'date':
case 'timestamp without time zone':
case 'timestamp with time zone':
case 'json':
case 'jsonb':
validateFun = function () { return true; };
break;
}
var parseWithValidate = function (v, validate) {
if (validate === void 0) { validate = false; }
var parsedValue = parseFun(v);
if (validate && parsedValue !== undefined && !validateFun(parsedValue)) {
var parse = function (v) {
var castedValue = castFun(v);
if (castedValue !== undefined && !validateFun(castedValue)) {
return undefined;
}
return parsedValue;
return castedValue;
};
return [key, { Parse: parseWithValidate, Validate: validateFun }];
return [key, { Parse: parse }];
}));
return __assign({ Parse: function (data, requires, optionals, validate) {
if (validate === void 0) { validate = false; }
return __assign({ Parse: function (data, requires, optionals) {
var result = {};

@@ -254,9 +227,6 @@ var require;

}
result[require] = columnsParseAndValidate[require].Parse(data[require]);
result[require] = columnsParser[require].Parse(data[require]);
if (result[require] === undefined) {
return (0, never_catch_1.err)(require);
}
if (validate && !columnsParseAndValidate[require].Validate(result[require])) {
return (0, never_catch_1.err)(require);
}
}

@@ -269,22 +239,11 @@ var optional;

}
result[optional] = columnsParseAndValidate[optional].Parse(data[optional]);
result[optional] = columnsParser[optional].Parse(data[optional]);
if (result[optional] === undefined) {
return (0, never_catch_1.err)(optional);
}
if (validate && !columnsParseAndValidate[optional].Validate(result[optional])) {
return (0, never_catch_1.err)(optional);
}
}
return (0, never_catch_1.ok)(result);
}, Validate: function (data) {
var dataKey;
for (dataKey in data) {
if (!columnsParseAndValidate[dataKey].Validate(data[dataKey])) {
return (0, never_catch_1.err)(dataKey);
}
}
return (0, never_catch_1.ok)(undefined);
} }, columnsParseAndValidate);
} }, columnsParser);
};
exports.createModelUtils = createModelUtils;
//# sourceMappingURL=model.js.map

@@ -100,3 +100,5 @@ "use strict";

// callback
return [4 /*yield*/, callback(client)];
return [4 /*yield*/, callback(client).catch(function (e) {
error = e;
})];
case 6:

@@ -181,3 +183,3 @@ // callback

key: key,
message: "->".concat(JSON.stringify(dbRow[key]), "<- did not accepted by match function")
message: "match function rejected (".concat(JSON.stringify(dbRow[key]), ")")
});

@@ -193,3 +195,3 @@ found = false;

key: key,
message: "->".concat(JSON.stringify(dbRow[key]), "<- is not equal to ->").concat(JSON.stringify(value), "<-")
message: "expected(".concat(JSON.stringify(value), ") received(").concat(JSON.stringify(dbRow[key]), ")")
});

@@ -331,3 +333,3 @@ found = false;

else {
throw error;
throw JSON.stringify(error, null, 4);
}

@@ -334,0 +336,0 @@ return [2 /*return*/];

@@ -15,8 +15,6 @@ import type { Table } from './Table';

[key: string]: unknown;
}, requires: Requires, optional: Optionals, validate?: boolean) => Result<Model<Columns, Requires, Optionals>, Requires[Exclude<keyof Requires, keyof unknown[]>] | Optionals[Exclude<keyof Optionals, keyof unknown[]>]>;
Validate: <D extends Partial<SimpleModel<Columns>>>(data: D) => Result<undefined, keyof D>;
}, requires: Requires, optional: Optionals) => Result<Model<Columns, Requires, Optionals>, Requires[Exclude<keyof Requires, keyof unknown[]>] | Optionals[Exclude<keyof Optionals, keyof unknown[]>]>;
} & {
[key in keyof Columns]: {
Parse: (v: unknown, validate?: boolean) => ColumnTypeByColumns<Columns, key> | undefined;
Validate: (v: ColumnTypeByColumns<Columns, key>) => boolean;
Parse: (v: unknown) => ColumnTypeByColumns<Columns, key> | undefined;
};

@@ -23,0 +21,0 @@ };

@@ -24,5 +24,5 @@ import { Table } from './Table';

};
type TestTransaction = (data: TestTableData<any>[], callback: (client: PoolClient) => void, pool: Pool, isolationLevel?: TransactionIsolationLevel, rollback?: boolean) => Promise<undefined>;
type TestTransaction = (data: TestTableData<any>[], callback: (client: PoolClient) => Promise<void>, pool: Pool, isolationLevel?: TransactionIsolationLevel, rollback?: boolean) => Promise<undefined>;
type CreateTestTableData = <T extends Table>(table: T, startData: TestTableData<T>['startData'], finalData: TestTableData<T>['finalData'], skipIt?: TestTableData<T>['skipIt'], lengthCheck?: TestTableData<T>['lengthCheck']) => TestTableData<T>;
export type { TestTableData, TestTransaction, CreateTestTableData };
//# sourceMappingURL=testUtil.d.ts.map
{
"name": "@mrnafisia/type-query",
"version": "1.2.2",
"version": "1.2.3",
"description": "mini-orm with full type support for postgres.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc