@mrnafisia/type-query 1.0.28 → 1.0.29

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/README.md CHANGED
@@ -1,2 +1,2 @@
1
- # type-query
2
- SQL Query Builder written in TypeScript
1
+ # type-query
2
+ SQL Query Builder written in TypeScript
package/dist/U.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import * as U from './utils';
2
- export default U;
1
+ import * as U from './utils';
2
+ export default U;
3
3
  //# sourceMappingURL=U.d.ts.map
package/dist/U.js CHANGED
@@ -1,28 +1,28 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- var U = __importStar(require("./utils"));
27
- exports.default = U;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ var U = __importStar(require("./utils"));
27
+ exports.default = U;
28
28
  //# sourceMappingURL=U.js.map
package/dist/context.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import Table from './types/table';
2
- import { Context, ContextScope } from './types/context';
3
- declare const createContext: <T extends Table>(table: T, alias?: string) => Context<T["columns"]>;
4
- declare const createContextScopeHelper: <T extends Table>(table: T) => (rules: T["columns"] extends infer T_1 ? { [columnKey in keyof T_1]?: [op: null extends import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> ? import("./types/context").NullOperator : never] | [op: import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> extends boolean ? import("./types/context").BooleanOperator : never] | [op: import("./types/context").CompareOperatorCompatible<import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>, import("./types/context").CompareOperator, never>, v: import("./types/entity").Expression<import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>>] | [op: import("./types/context").ListOperatorCompatible<import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>, import("./types/context").ListOperator, never>, v: import("./types/entity").Expression<import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>>[] | undefined] | [op: "like", v: import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> extends string ? import("./types/entity").Expression<string & import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>> : never] | [op: "like all" | "like some", v: import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> extends string ? import("./types/entity").Expression<string & import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>>[] | undefined : never] | [op: "@>" | "<@", v: import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> extends import("./types/json").JSON ? import("./types/entity").Expression<import("./types/json").JSON & import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>> : never] | [op: "?", v: import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> extends import("./types/json").JSON ? import("./types/entity").Expression<string> : never] | [op: "?|" | "?&", v: import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> extends import("./types/json").JSON ? import("./types/entity").Expression<string>[] | undefined : never]; } : never, alias: string) => import("./types/entity").ValueExpression<boolean>[];
5
- export { createContext, createContextScopeHelper };
1
+ import Table from './types/table';
2
+ import { Context, ContextScope } from './types/context';
3
+ declare const createContext: <T extends Table>(table: T, alias?: string) => Context<T["columns"]>;
4
+ declare const createContextScopeHelper: <T extends Table>(table: T) => (rules: T["columns"] extends infer T_1 ? { [columnKey in keyof T_1]?: [op: null extends import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> ? import("./types/context").NullOperator : never] | [op: import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> extends boolean ? import("./types/context").BooleanOperator : never] | [op: import("./types/context").CompareOperatorCompatible<import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>, import("./types/context").CompareOperator, never>, v: import("./types/entity").Expression<import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>>] | [op: import("./types/context").ListOperatorCompatible<import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>, import("./types/context").ListOperator, never>, v: import("./types/entity").Expression<import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>>[] | undefined] | [op: "like", v: import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> extends string ? import("./types/entity").Expression<string & import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>> : never] | [op: "like all" | "like some", v: import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> extends string ? import("./types/entity").Expression<string & import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>>[] | undefined : never] | [op: "@>" | "<@", v: import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> extends import("./types/json").JSON ? import("./types/entity").Expression<import("./types/json").JSON & import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]>> : never] | [op: "?", v: import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> extends import("./types/json").JSON ? import("./types/entity").Expression<string> : never] | [op: "?|" | "?&", v: import("./types/postgres").PostgresTypeMapper<T["columns"][columnKey]["type"], T["columns"][columnKey]["nullable"]> extends import("./types/json").JSON ? import("./types/entity").Expression<string>[] | undefined : never]; } : never, alias: string) => import("./types/entity").ValueExpression<boolean>[];
5
+ export { createContext, createContextScopeHelper };
6
6
  //# sourceMappingURL=context.d.ts.map
package/dist/context.js CHANGED
@@ -1,86 +1,86 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createContextScopeHelper = exports.createContext = void 0;
7
- var U_1 = __importDefault(require("./U"));
8
- var createContext = function (table, alias) {
9
- if (alias === void 0) { alias = ''; }
10
- var contextScopeHelper = createContextScopeHelper(table);
11
- return {
12
- col: function (column, _alias) {
13
- if (_alias === void 0) { _alias = alias; }
14
- return U_1.default.col(table, column, !!_alias, _alias);
15
- },
16
- colNull: function (column, op, _alias) {
17
- if (_alias === void 0) { _alias = alias; }
18
- return U_1.default.nullOp(U_1.default.col(table, column, !!_alias, _alias), op);
19
- },
20
- colBool: function (column, op, _alias) {
21
- if (_alias === void 0) { _alias = alias; }
22
- return U_1.default.boolOp(U_1.default.col(table, column, !!_alias, _alias), op);
23
- },
24
- colCmp: function (column, op, v, _alias) {
25
- if (_alias === void 0) { _alias = alias; }
26
- return U_1.default.cmpOp(U_1.default.col(table, column, !!_alias, _alias), op, v);
27
- },
28
- colList: function (column, op, v, _alias) {
29
- if (_alias === void 0) { _alias = alias; }
30
- return U_1.default.listOp(U_1.default.col(table, column, !!_alias, _alias), op, v);
31
- },
32
- colLike: function (column, op, v, _alias) {
33
- if (_alias === void 0) { _alias = alias; }
34
- return U_1.default.likeOp(U_1.default.col(table, column, !!_alias, _alias), op, v);
35
- },
36
- colJson: function (column, op, v, _alias) {
37
- if (_alias === void 0) { _alias = alias; }
38
- return U_1.default.jsonOp(U_1.default.col(table, column, !!_alias, _alias), op, v);
39
- },
40
- colsAnd: function (rules, _alias) {
41
- if (_alias === void 0) { _alias = alias; }
42
- return U_1.default.andAllOp(contextScopeHelper(rules, _alias));
43
- },
44
- colsOr: function (rules, _alias) {
45
- if (_alias === void 0) { _alias = alias; }
46
- return U_1.default.orAllOp(contextScopeHelper(rules, _alias));
47
- }
48
- };
49
- };
50
- exports.createContext = createContext;
51
- var createContextScopeHelper = function (table) {
52
- return function (rules, alias) { return Object.entries(rules).map(function (_a) {
53
- var key = _a[0], value = _a[1];
54
- switch (value[0]) {
55
- case '= null':
56
- case '!= null':
57
- return U_1.default.nullOp(U_1.default.col(table, key, !!alias, alias), value[0]);
58
- case '= true':
59
- case '= false':
60
- return U_1.default.boolOp(U_1.default.col(table, key, !!alias, alias), value[0]);
61
- case '=':
62
- case '!=':
63
- case '>':
64
- case '>=':
65
- case '<':
66
- case '<=':
67
- return U_1.default.cmpOp(U_1.default.col(table, key, !!alias, alias), value[0], value[1]);
68
- case 'in':
69
- case 'not in':
70
- return U_1.default.listOp(U_1.default.col(table, key, !!alias, alias), value[0], value[1]);
71
- case 'like':
72
- case 'like all':
73
- case 'like some':
74
- return U_1.default.likeOp(U_1.default.col(table, key, !!alias, alias), value[0], value[1]);
75
- case '@>':
76
- case '<@':
77
- case '?':
78
- case '?&':
79
- case '?|':
80
- return U_1.default.jsonOp(U_1.default.col(table, key, !!alias, alias), value[0], value[1]);
81
- }
82
- throw "do not except this. first element must be a reserved key. ".concat(JSON.stringify(value));
83
- }); };
84
- };
85
- exports.createContextScopeHelper = createContextScopeHelper;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createContextScopeHelper = exports.createContext = void 0;
7
+ var U_1 = __importDefault(require("./U"));
8
+ var createContext = function (table, alias) {
9
+ if (alias === void 0) { alias = ''; }
10
+ var contextScopeHelper = createContextScopeHelper(table);
11
+ return {
12
+ col: function (column, _alias) {
13
+ if (_alias === void 0) { _alias = alias; }
14
+ return U_1.default.col(table, column, !!_alias, _alias);
15
+ },
16
+ colNull: function (column, op, _alias) {
17
+ if (_alias === void 0) { _alias = alias; }
18
+ return U_1.default.nullOp(U_1.default.col(table, column, !!_alias, _alias), op);
19
+ },
20
+ colBool: function (column, op, _alias) {
21
+ if (_alias === void 0) { _alias = alias; }
22
+ return U_1.default.boolOp(U_1.default.col(table, column, !!_alias, _alias), op);
23
+ },
24
+ colCmp: function (column, op, v, _alias) {
25
+ if (_alias === void 0) { _alias = alias; }
26
+ return U_1.default.cmpOp(U_1.default.col(table, column, !!_alias, _alias), op, v);
27
+ },
28
+ colList: function (column, op, v, _alias) {
29
+ if (_alias === void 0) { _alias = alias; }
30
+ return U_1.default.listOp(U_1.default.col(table, column, !!_alias, _alias), op, v);
31
+ },
32
+ colLike: function (column, op, v, _alias) {
33
+ if (_alias === void 0) { _alias = alias; }
34
+ return U_1.default.likeOp(U_1.default.col(table, column, !!_alias, _alias), op, v);
35
+ },
36
+ colJson: function (column, op, v, _alias) {
37
+ if (_alias === void 0) { _alias = alias; }
38
+ return U_1.default.jsonOp(U_1.default.col(table, column, !!_alias, _alias), op, v);
39
+ },
40
+ colsAnd: function (rules, _alias) {
41
+ if (_alias === void 0) { _alias = alias; }
42
+ return U_1.default.andAllOp(contextScopeHelper(rules, _alias));
43
+ },
44
+ colsOr: function (rules, _alias) {
45
+ if (_alias === void 0) { _alias = alias; }
46
+ return U_1.default.orAllOp(contextScopeHelper(rules, _alias));
47
+ }
48
+ };
49
+ };
50
+ exports.createContext = createContext;
51
+ var createContextScopeHelper = function (table) {
52
+ return function (rules, alias) { return Object.entries(rules).map(function (_a) {
53
+ var key = _a[0], value = _a[1];
54
+ switch (value[0]) {
55
+ case '= null':
56
+ case '!= null':
57
+ return U_1.default.nullOp(U_1.default.col(table, key, !!alias, alias), value[0]);
58
+ case '= true':
59
+ case '= false':
60
+ return U_1.default.boolOp(U_1.default.col(table, key, !!alias, alias), value[0]);
61
+ case '=':
62
+ case '!=':
63
+ case '>':
64
+ case '>=':
65
+ case '<':
66
+ case '<=':
67
+ return U_1.default.cmpOp(U_1.default.col(table, key, !!alias, alias), value[0], value[1]);
68
+ case 'in':
69
+ case 'not in':
70
+ return U_1.default.listOp(U_1.default.col(table, key, !!alias, alias), value[0], value[1]);
71
+ case 'like':
72
+ case 'like all':
73
+ case 'like some':
74
+ return U_1.default.likeOp(U_1.default.col(table, key, !!alias, alias), value[0], value[1]);
75
+ case '@>':
76
+ case '<@':
77
+ case '?':
78
+ case '?&':
79
+ case '?|':
80
+ return U_1.default.jsonOp(U_1.default.col(table, key, !!alias, alias), value[0], value[1]);
81
+ }
82
+ throw "do not except this. first element must be a reserved key. ".concat(JSON.stringify(value));
83
+ }); };
84
+ };
85
+ exports.createContextScopeHelper = createContextScopeHelper;
86
86
  //# sourceMappingURL=context.js.map
@@ -1,13 +1,13 @@
1
- import type { JoinType } from './types/entity';
2
- import { ReservedExpressionKeys } from './entity';
3
- import type { OrderDirection, PostgresType } from './types/postgres';
4
- import type { ReferenceActions } from './types/table';
5
- import type { TransactionIsolationLevel } from './types/pool';
6
- declare const toTransactionIsolationLevel: (v: TransactionIsolationLevel) => "READ COMMITTED" | "READ UNCOMMITTED" | "REPEATABLE READ" | "SERIALIZABLE";
7
- declare const toOrderDirection: (v: OrderDirection) => "ASC" | "DESC";
8
- declare const toJoinType: (v: JoinType) => "INNER JOIN" | "LEFT OUTER JOIN" | "RIGHT OUTER JOIN" | "FULL OUTER JOIN";
9
- declare const toPostgresType: (v: PostgresType) => "boolean" | "smallint" | "integer" | "bigint" | "real" | "double precision" | "numeric" | "character" | "character varying" | "text" | "uuid" | "date" | "timestamp without time zone" | "timestamp with time zone" | "json" | "jsonb";
10
- declare const toReferenceAction: (v: ReferenceActions) => "NO ACTION" | "RESTRICT" | "SET NULL" | "SET DEFAULT" | "CASCADE";
11
- declare const toReservedExpressionKeyDescription: (v: (typeof ReservedExpressionKeys)[Exclude<keyof typeof ReservedExpressionKeys, keyof unknown[]>]) => "wrapped value" | "is null" | "is not null" | "is true" | "is false" | "not of" | "sum" | "minus" | "multiply" | "divide" | "concat" | "logical and" | "logical or" | "power" | "function" | "switch statement" | "column" | "raw statement" | "is equal" | "is not equal" | "is greater than" | "is greater-equal than" | "is less than" | "is less-equal than" | "does like" | "json-contain (@>)" | "json-contain (<@)" | "json-exist (?)" | "json-subtract (-)" | "is inside of" | "is not inside of" | "does like all" | "does like some" | "json-does some exist (?|)" | "json-does all exist (?&)" | "json-subtract all (-)" | "is between" | "sub-query" | "row exists in sub-query";
12
- export { toTransactionIsolationLevel, toOrderDirection, toJoinType, toPostgresType, toReferenceAction, toReservedExpressionKeyDescription };
1
+ import type { JoinType } from './types/entity';
2
+ import { ReservedExpressionKeys } from './entity';
3
+ import type { OrderDirection, PostgresType } from './types/postgres';
4
+ import type { ReferenceActions } from './types/table';
5
+ import type { TransactionIsolationLevel } from './types/pool';
6
+ declare const toTransactionIsolationLevel: (v: TransactionIsolationLevel) => "READ COMMITTED" | "READ UNCOMMITTED" | "REPEATABLE READ" | "SERIALIZABLE";
7
+ declare const toOrderDirection: (v: OrderDirection) => "ASC" | "DESC";
8
+ declare const toJoinType: (v: JoinType) => "INNER JOIN" | "LEFT OUTER JOIN" | "RIGHT OUTER JOIN" | "FULL OUTER JOIN";
9
+ declare const toPostgresType: (v: PostgresType) => "boolean" | "smallint" | "integer" | "bigint" | "real" | "double precision" | "numeric" | "character" | "character varying" | "text" | "uuid" | "date" | "timestamp without time zone" | "timestamp with time zone" | "json" | "jsonb";
10
+ declare const toReferenceAction: (v: ReferenceActions) => "NO ACTION" | "RESTRICT" | "SET NULL" | "SET DEFAULT" | "CASCADE";
11
+ declare const toReservedExpressionKeyDescription: (v: (typeof ReservedExpressionKeys)[Exclude<keyof typeof ReservedExpressionKeys, keyof unknown[]>]) => "wrapped value" | "is null" | "is not null" | "is true" | "is false" | "not of" | "sum" | "minus" | "multiply" | "divide" | "concat" | "logical and" | "logical or" | "power" | "function" | "switch statement" | "column" | "raw statement" | "is equal" | "is not equal" | "is greater than" | "is greater-equal than" | "is less than" | "is less-equal than" | "does like" | "json-contain (@>)" | "json-contain (<@)" | "json-exist (?)" | "json-subtract (-)" | "is inside of" | "is not inside of" | "does like all" | "does like some" | "json-does some exist (?|)" | "json-does all exist (?&)" | "json-subtract all (-)" | "is between" | "sub-query" | "row exists in sub-query";
12
+ export { toTransactionIsolationLevel, toOrderDirection, toJoinType, toPostgresType, toReferenceAction, toReservedExpressionKeyDescription };
13
13
  //# sourceMappingURL=dictionary.d.ts.map