bigal 10.0.0-beta2 → 10.0.0
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/CHANGELOG.md +1 -1
- package/package.json +4 -3
- package/query/WhereQuery.d.ts +9 -10
- package/types/CreateUpdateParams.d.ts +1 -4
- package/types/EntityPrimitiveOrId.d.ts +1 -1
- package/types/QueryResultOptionalPopulated.d.ts +9 -0
- package/types/QueryResultOptionalPopulated.js +3 -0
- package/types/QueryResultOptionalPopulated.js.map +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/index.js.map +1 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bigal",
|
|
3
|
-
"version": "10.0.0
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "A fast and lightweight orm for postgres and node.js, written in typescript.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"eslint-plugin-security": "^1.4.0",
|
|
46
46
|
"faker": "^5.5.3",
|
|
47
47
|
"husky": "^7.0.4",
|
|
48
|
-
"lint-staged": "^12.1.
|
|
48
|
+
"lint-staged": "^12.1.7",
|
|
49
49
|
"markdownlint-cli": "^0.30.0",
|
|
50
50
|
"mocha": "^9.1.3",
|
|
51
51
|
"npm-run-all": "^4.1.5",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"typescript": "^4.5.4"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
|
+
"check:types": "tsc -p tsconfig.lint.json --noEmit",
|
|
61
62
|
"prebuild": "rimraf dist",
|
|
62
63
|
"build": "tsc",
|
|
63
64
|
"test": "mocha -r ts-node/register tests/**/*.tests.ts",
|
|
@@ -65,7 +66,7 @@
|
|
|
65
66
|
"lint:code": "eslint --fix --ext .ts src tests",
|
|
66
67
|
"lint": "run-p lint:*",
|
|
67
68
|
"lint-staged": "lint-staged",
|
|
68
|
-
"dist": "if [ -d \"src\" ]; then rm -rf dist && npm run build && npm run lint && npm run test && cp package.json dist && cp package-lock.json dist && cp *.md dist && cp LICENSE dist && cp .npmignore dist && cd dist && npm publish
|
|
69
|
+
"dist": "if [ -d \"src\" ]; then rm -rf dist && npm run build && npm run lint && npm run test && cp package.json dist && cp package-lock.json dist && cp *.md dist && cp LICENSE dist && cp .npmignore dist && cd dist && npm publish; fi",
|
|
69
70
|
"prepublishOnly": "if [ -d \"src\" ]; then echo \"Please use: npm run dist\" && exit 125; fi && pinst --disable",
|
|
70
71
|
"_postinstall": "husky install",
|
|
71
72
|
"postpublish": "pinst --enable"
|
package/query/WhereQuery.d.ts
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import type { Entity, NotEntityBrand } from '../Entity';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
id: unknown;
|
|
7
|
-
} | null : Exclude<(TValue | null)[] | TValue, undefined> | null;
|
|
2
|
+
import type { ExcludeEntityCollections, ExcludeFunctions } from '../types';
|
|
3
|
+
declare type ExcludeUndefined<T> = Exclude<T, undefined>;
|
|
4
|
+
export declare type LiteralValues<TValue> = (ExcludeUndefined<TValue> | null)[] | ExcludeUndefined<TValue> | null;
|
|
5
|
+
export declare type WhereClauseValue<TValue> = TValue extends NotEntityBrand | undefined ? Exclude<TValue, NotEntityBrand | undefined> : Extract<TValue, Entity> extends undefined ? LiteralValues<TValue> : (ExcludeUndefined<Exclude<TValue, Entity>> | null)[] | (Pick<Extract<ExcludeUndefined<TValue>, Entity>, 'id'> | null)[] | ExcludeUndefined<Exclude<TValue, Entity>> | Pick<Extract<ExcludeUndefined<TValue>, Entity>, 'id'> | null;
|
|
8
6
|
export declare type StringConstraint<TValue extends string> = {
|
|
9
|
-
[P in 'contains' | 'endsWith' | 'like' | 'startsWith']?:
|
|
7
|
+
[P in 'contains' | 'endsWith' | 'like' | 'startsWith']?: LiteralValues<TValue>;
|
|
10
8
|
};
|
|
11
9
|
export declare type NumberOrDateConstraint<TValue extends Date | number> = {
|
|
12
|
-
[P in '<' | '<=' | '>' | '>=']?:
|
|
10
|
+
[P in '<' | '<=' | '>' | '>=']?: LiteralValues<TValue>;
|
|
13
11
|
};
|
|
14
12
|
export declare type NegatableConstraint<TValue> = TValue | {
|
|
15
13
|
'!': TValue;
|
|
16
14
|
};
|
|
17
15
|
export declare type WhereQueryStatement<TValue> = TValue extends string ? NegatableConstraint<StringConstraint<TValue> | WhereClauseValue<TValue>> : TValue extends Date | number ? NegatableConstraint<NumberOrDateConstraint<TValue> | WhereClauseValue<TValue>> : NegatableConstraint<WhereClauseValue<TValue>>;
|
|
18
16
|
export declare type WhereQuery<T extends Entity> = {
|
|
19
|
-
[K in keyof T as ExcludeEntityCollections<T[K], ExcludeFunctions<T[K], K>>]?: K extends 'id' ? WhereQueryStatement<T | T[K]> : T[K] extends (infer U)[] | undefined ? WhereQueryStatement<U> :
|
|
20
|
-
'!':
|
|
17
|
+
[K in keyof T as ExcludeEntityCollections<T[K], ExcludeFunctions<T[K], K>>]?: K extends 'id' ? WhereQueryStatement<T | T[K]> : T[K] extends (infer U)[] | undefined ? WhereQueryStatement<U> : (ExcludeUndefined<T[K]> | null)[] | T[K] | WhereQueryStatement<T[K]> | {
|
|
18
|
+
'!': LiteralValues<T[K]>;
|
|
21
19
|
};
|
|
22
20
|
} & {
|
|
23
21
|
or?: WhereQuery<T>[];
|
|
24
22
|
};
|
|
23
|
+
export {};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import type { Entity, NotEntityBrand } from '../Entity';
|
|
2
|
-
import type { EntityPrimitiveOrId } from './EntityPrimitiveOrId';
|
|
3
2
|
import type { ExcludeEntityCollections } from './ExcludeEntityCollections';
|
|
4
3
|
import type { ExcludeFunctions } from './ExcludeFunctions';
|
|
5
4
|
/**
|
|
6
5
|
* Changes all Entity value properties to Primitive (string|number) | Pick<Entity, 'id'>
|
|
7
6
|
*/
|
|
8
7
|
export declare type CreateUpdateParams<T extends Entity> = {
|
|
9
|
-
[K in keyof T as ExcludeEntityCollections<NonNullable<T[K]>, ExcludeFunctions<T[K], K>>]?: T[K] extends NotEntityBrand | undefined ? T[K] : T[K] extends
|
|
10
|
-
id: unknown;
|
|
11
|
-
} : T[K];
|
|
8
|
+
[K in keyof T as ExcludeEntityCollections<NonNullable<T[K]>, ExcludeFunctions<T[K], K>>]?: T[K] extends NotEntityBrand | undefined ? T[K] : Extract<T[K], Entity> extends undefined ? T[K] : Exclude<T[K], Entity> | Pick<Extract<T[K], Entity>, 'id'>;
|
|
12
9
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Entity } from '../Entity';
|
|
2
|
-
export declare type EntityPrimitiveOrId<T extends
|
|
2
|
+
export declare type EntityPrimitiveOrId<T> = T extends [] ? T extends (infer U)[] ? EntityPrimitiveOrId<U>[] : T : Extract<NonNullable<T>, Entity> extends undefined ? T : Exclude<NonNullable<T>, Entity> | Pick<Extract<NonNullable<T>, Entity>, 'id'>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Entity } from '../Entity';
|
|
2
|
+
import type { QueryResult } from './QueryResult';
|
|
3
|
+
import { EntityPrimitiveOrId } from "./EntityPrimitiveOrId";
|
|
4
|
+
/**
|
|
5
|
+
* Allows a QueryResult type with specific properties optionally populated. If the property is populated, only the id property is needed
|
|
6
|
+
*/
|
|
7
|
+
export declare type QueryResultOptionalPopulated<T extends Entity, K extends keyof T> = Omit<QueryResult<T>, K> & {
|
|
8
|
+
[P in K]-?: T[P] extends [] ? undefined extends T[P] ? EntityPrimitiveOrId<T[P]> | null : EntityPrimitiveOrId<T[P]> : EntityPrimitiveOrId<T[P]>;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryResultOptionalPopulated.js","sourceRoot":"./","sources":["types/QueryResultOptionalPopulated.ts"],"names":[],"mappings":""}
|
package/types/index.d.ts
CHANGED
package/types/index.js
CHANGED
|
@@ -25,4 +25,5 @@ __exportStar(require("./PickFunctions"), exports);
|
|
|
25
25
|
__exportStar(require("./Populated"), exports);
|
|
26
26
|
__exportStar(require("./QueryResult"), exports);
|
|
27
27
|
__exportStar(require("./QueryResultPopulated"), exports);
|
|
28
|
+
__exportStar(require("./QueryResultOptionalPopulated"), exports);
|
|
28
29
|
//# sourceMappingURL=index.js.map
|
package/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"./","sources":["types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqC;AACrC,wDAAsC;AACtC,6DAA2C;AAC3C,qDAAmC;AACnC,iDAA+B;AAC/B,qDAAmC;AACnC,kDAAgC;AAChC,0DAAwC;AACxC,kDAAgC;AAChC,+CAA6B;AAC7B,oDAAkC;AAClC,kDAAgC;AAChC,8CAA4B;AAC5B,gDAA8B;AAC9B,yDAAuC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./","sources":["types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqC;AACrC,wDAAsC;AACtC,6DAA2C;AAC3C,qDAAmC;AACnC,iDAA+B;AAC/B,qDAAmC;AACnC,kDAAgC;AAChC,0DAAwC;AACxC,kDAAgC;AAChC,+CAA6B;AAC7B,oDAAkC;AAClC,kDAAgC;AAChC,8CAA4B;AAC5B,gDAA8B;AAC9B,yDAAuC;AACvC,iEAA8C"}
|