@tsed/objection 7.79.4 → 7.80.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/lib/esm/utils/createColumns.js +4 -4
- package/lib/types-esm/components/createBooleanColumn.d.ts +6 -0
- package/lib/types-esm/components/createIdColumn.d.ts +6 -0
- package/lib/types-esm/components/createNumberColumn.d.ts +6 -0
- package/lib/types-esm/components/createStringColumn.d.ts +6 -0
- package/lib/types-esm/decorators/belongsToOne.d.ts +8 -0
- package/lib/types-esm/decorators/columnOptions.d.ts +8 -0
- package/lib/types-esm/decorators/decimal.d.ts +11 -0
- package/lib/types-esm/decorators/entity.d.ts +11 -0
- package/lib/types-esm/decorators/hasMany.d.ts +9 -0
- package/lib/types-esm/decorators/hasOne.d.ts +8 -0
- package/lib/types-esm/decorators/hasOneThroughRelation.d.ts +8 -0
- package/lib/types-esm/decorators/idColumn.d.ts +7 -0
- package/lib/types-esm/decorators/manyToMany.d.ts +9 -0
- package/lib/types-esm/decorators/relatesTo.d.ts +10 -0
- package/lib/types-esm/domain/ColumnOpts.d.ts +4 -0
- package/lib/types-esm/domain/RelationshipOpts.d.ts +8 -0
- package/lib/types-esm/domain/interfaces.d.ts +8 -0
- package/lib/types-esm/index.d.ts +29 -0
- package/lib/types-esm/services/ColumnTypesContainer.d.ts +6 -0
- package/lib/types-esm/services/ObjectionConnection.d.ts +3 -0
- package/lib/types-esm/utils/connect.d.ts +2 -0
- package/lib/types-esm/utils/createColumns.d.ts +18 -0
- package/lib/types-esm/utils/createJoinKeys.d.ts +14 -0
- package/lib/types-esm/utils/createRelationshipMapping.d.ts +24 -0
- package/lib/types-esm/utils/defineStaticGetter.d.ts +4 -0
- package/lib/types-esm/utils/getColumnCtx.d.ts +13 -0
- package/lib/types-esm/utils/getJsonEntityRelationships.d.ts +8 -0
- package/package.json +25 -21
- package/vitest.config.mts +21 -0
- package/jest.config.js +0 -20
- package/lib/cjs/package.json +0 -3
- package/lib/esm/package.json +0 -3
- package/tsconfig.esm.json +0 -45
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getProperties } from "@tsed/schema";
|
|
2
|
-
import "../components/createBooleanColumn
|
|
3
|
-
import "../components/createIdColumn
|
|
4
|
-
import "../components/createNumberColumn
|
|
5
|
-
import "../components/createStringColumn
|
|
2
|
+
import "../components/createBooleanColumn";
|
|
3
|
+
import "../components/createIdColumn";
|
|
4
|
+
import "../components/createNumberColumn";
|
|
5
|
+
import "../components/createStringColumn";
|
|
6
6
|
import { ColumnTypesContainer } from "../services/ColumnTypesContainer.js";
|
|
7
7
|
import { getColumnCtx } from "./getColumnCtx.js";
|
|
8
8
|
/**
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param tableName
|
|
5
|
+
* @decorator
|
|
6
|
+
* @objection
|
|
7
|
+
*/
|
|
8
|
+
export declare function Entity(tableName: string): ClassDecorator;
|
|
9
|
+
export interface EntityMethods<T> extends Type<T> {
|
|
10
|
+
readonly tableName: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ModelClassSpecifier } from "objection";
|
|
2
|
+
import { RelationshipOptsWithThrough } from "../domain/RelationshipOpts.js";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param opts
|
|
6
|
+
* @decorator
|
|
7
|
+
* @objection
|
|
8
|
+
*/
|
|
9
|
+
export declare function HasMany(type: ModelClassSpecifier, opts?: RelationshipOptsWithThrough): PropertyDecorator;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ModelClassSpecifier } from "objection";
|
|
2
|
+
import { RelationshipOptsWithThrough } from "../domain/RelationshipOpts.js";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param opts
|
|
6
|
+
* @decorator
|
|
7
|
+
* @objection
|
|
8
|
+
*/
|
|
9
|
+
export declare function ManyToMany(type: ModelClassSpecifier, opts?: RelationshipOptsWithThrough): PropertyDecorator;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RelationshipOpts } from "../domain/RelationshipOpts.js";
|
|
2
|
+
import { RelationType } from "objection";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param relation
|
|
6
|
+
* @param opts
|
|
7
|
+
* @decorator
|
|
8
|
+
* @objection
|
|
9
|
+
*/
|
|
10
|
+
export declare function RelatesTo(relation: RelationType, opts?: RelationshipOpts): PropertyDecorator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ModelClassFactory, ModelClassSpecifier, RelationJoin, RelationMapping } from "objection";
|
|
2
|
+
export type RelationshipOptsWithThrough = Partial<RelationJoin> & Omit<RelationMapping<any>, "relation" | "join" | "modelClass">;
|
|
3
|
+
export type RelationshipOptsWithoutThrough = Omit<RelationshipOptsWithThrough, "through">;
|
|
4
|
+
export type RelationshipOpts = (RelationshipOptsWithThrough | RelationshipOptsWithoutThrough) & {
|
|
5
|
+
type?: ModelClassSpecifier;
|
|
6
|
+
};
|
|
7
|
+
export declare const isRelationshipOptsWithThrough: (opts?: RelationshipOpts) => opts is RelationshipOptsWithThrough;
|
|
8
|
+
export declare const isModelClassFactory: (type?: ModelClassSpecifier) => type is ModelClassFactory;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by @tsed/barrels.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./components/createBooleanColumn.js";
|
|
5
|
+
export * from "./components/createIdColumn.js";
|
|
6
|
+
export * from "./components/createNumberColumn.js";
|
|
7
|
+
export * from "./components/createStringColumn.js";
|
|
8
|
+
export * from "./decorators/belongsToOne.js";
|
|
9
|
+
export * from "./decorators/columnOptions.js";
|
|
10
|
+
export * from "./decorators/decimal.js";
|
|
11
|
+
export * from "./decorators/entity.js";
|
|
12
|
+
export * from "./decorators/hasMany.js";
|
|
13
|
+
export * from "./decorators/hasOne.js";
|
|
14
|
+
export * from "./decorators/hasOneThroughRelation.js";
|
|
15
|
+
export * from "./decorators/idColumn.js";
|
|
16
|
+
export * from "./decorators/manyToMany.js";
|
|
17
|
+
export * from "./decorators/relatesTo.js";
|
|
18
|
+
export * from "./domain/ColumnOpts.js";
|
|
19
|
+
export * from "./domain/interfaces.js";
|
|
20
|
+
export * from "./domain/RelationshipOpts.js";
|
|
21
|
+
export * from "./services/ColumnTypesContainer.js";
|
|
22
|
+
export * from "./services/ObjectionConnection.js";
|
|
23
|
+
export * from "./utils/connect.js";
|
|
24
|
+
export * from "./utils/createColumns.js";
|
|
25
|
+
export * from "./utils/createJoinKeys.js";
|
|
26
|
+
export * from "./utils/createRelationshipMapping.js";
|
|
27
|
+
export * from "./utils/defineStaticGetter.js";
|
|
28
|
+
export * from "./utils/getColumnCtx.js";
|
|
29
|
+
export * from "./utils/getJsonEntityRelationships.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { JsonEntityStore } from "@tsed/schema";
|
|
2
|
+
import { Knex } from "knex";
|
|
3
|
+
import "../components/createBooleanColumn";
|
|
4
|
+
import "../components/createIdColumn";
|
|
5
|
+
import "../components/createNumberColumn";
|
|
6
|
+
import "../components/createStringColumn";
|
|
7
|
+
/**
|
|
8
|
+
* @ignore
|
|
9
|
+
*/
|
|
10
|
+
export declare function createColumn(table: Knex.TableBuilder, entity: JsonEntityStore): void;
|
|
11
|
+
/**
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
export declare function getColumns(model: any): import("@tsed/schema").JsonPropertyStore[];
|
|
15
|
+
/**
|
|
16
|
+
* @ignore
|
|
17
|
+
*/
|
|
18
|
+
export declare function createColumns(table: Knex.TableBuilder, model: any): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RelationType } from "objection";
|
|
2
|
+
import { RelationshipOpts } from "../domain/RelationshipOpts.js";
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export declare function createJoinKeys(targetClass: any, targetSuper: any, propertyKey: string, relation: RelationType, opts?: RelationshipOpts): {
|
|
7
|
+
from: string;
|
|
8
|
+
to: string;
|
|
9
|
+
through?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
from: string;
|
|
12
|
+
through: import("objection").RelationThrough<any>;
|
|
13
|
+
to: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DecoratorParameters } from "@tsed/core";
|
|
2
|
+
import { RelationType } from "objection";
|
|
3
|
+
import { RelationshipOpts } from "../domain/RelationshipOpts.js";
|
|
4
|
+
/**
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
7
|
+
export declare function createRelationshipMapping([target, propertyKey]: DecoratorParameters, relation: RelationType, opts?: RelationshipOpts): (targetClass: any) => {
|
|
8
|
+
[x: string]: {
|
|
9
|
+
relation: RelationType;
|
|
10
|
+
modelClass: any;
|
|
11
|
+
join: {
|
|
12
|
+
from: string;
|
|
13
|
+
to: string;
|
|
14
|
+
through?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
from: string;
|
|
17
|
+
through: import("objection").RelationThrough<any>;
|
|
18
|
+
to: string;
|
|
19
|
+
};
|
|
20
|
+
modify: import("objection").Modifier<any> | undefined;
|
|
21
|
+
filter: import("objection").Modifier<any> | undefined;
|
|
22
|
+
beforeInsert: import("objection").RelationMappingHook<any> | undefined;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JsonEntityStore } from "@tsed/schema";
|
|
2
|
+
import { ColumnOpts } from "../domain/ColumnOpts.js";
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export interface ColumnCtx extends ColumnOpts {
|
|
7
|
+
entity: JsonEntityStore;
|
|
8
|
+
schema: any;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @ignore
|
|
12
|
+
*/
|
|
13
|
+
export declare function getColumnCtx(entity: JsonEntityStore): ColumnCtx;
|
package/package.json
CHANGED
|
@@ -1,46 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/objection",
|
|
3
|
-
"version": "7.79.4",
|
|
4
3
|
"description": "Objection.js package for Ts.ED framework",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"version": "7.80.0",
|
|
5
6
|
"source": "./src/index.ts",
|
|
6
7
|
"main": "./lib/cjs/index.js",
|
|
7
8
|
"module": "./lib/esm/index.js",
|
|
8
9
|
"typings": "./lib/types/index.d.ts",
|
|
9
10
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./lib/types/index.d.ts",
|
|
13
|
+
"import": "./lib/esm/index.js",
|
|
14
|
+
"default": "./lib/cjs/index.js"
|
|
15
|
+
}
|
|
14
16
|
},
|
|
15
17
|
"scripts": {
|
|
16
18
|
"build": "yarn barrels && yarn build:ts",
|
|
17
19
|
"barrels": "barrels",
|
|
18
|
-
"test": "
|
|
19
|
-
"build:ts": "tsc --build tsconfig.json
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"build:ts": "tsc --build tsconfig.json",
|
|
22
|
+
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
|
|
20
23
|
},
|
|
21
24
|
"dependencies": {
|
|
22
25
|
"tslib": "2.6.1"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
|
-
"@tsed/ajv": "7.
|
|
26
|
-
"@tsed/barrels": "7.
|
|
27
|
-
"@tsed/core": "7.
|
|
28
|
-
"@tsed/di": "7.
|
|
29
|
-
"@tsed/json-mapper": "7.
|
|
30
|
-
"@tsed/schema": "7.
|
|
31
|
-
"@tsed/typescript": "7.
|
|
28
|
+
"@tsed/ajv": "7.80.0",
|
|
29
|
+
"@tsed/barrels": "7.80.0",
|
|
30
|
+
"@tsed/core": "7.80.0",
|
|
31
|
+
"@tsed/di": "7.80.0",
|
|
32
|
+
"@tsed/json-mapper": "7.80.0",
|
|
33
|
+
"@tsed/schema": "7.80.0",
|
|
34
|
+
"@tsed/typescript": "7.80.0",
|
|
32
35
|
"eslint": "^8.57.0",
|
|
33
|
-
"jest": "^29.7.0",
|
|
34
36
|
"knex": "^3.1.0",
|
|
35
37
|
"objection": "^2.2.18",
|
|
36
|
-
"sqlite3": "^5.1.7"
|
|
38
|
+
"sqlite3": "^5.1.7",
|
|
39
|
+
"typescript": "4.9.5",
|
|
40
|
+
"vitest": "2.0.4"
|
|
37
41
|
},
|
|
38
42
|
"peerDependencies": {
|
|
39
|
-
"@tsed/ajv": "7.
|
|
40
|
-
"@tsed/core": "7.
|
|
41
|
-
"@tsed/di": "7.
|
|
42
|
-
"@tsed/json-mapper": "7.
|
|
43
|
-
"@tsed/schema": "7.
|
|
43
|
+
"@tsed/ajv": "7.80.0",
|
|
44
|
+
"@tsed/core": "7.80.0",
|
|
45
|
+
"@tsed/di": "7.80.0",
|
|
46
|
+
"@tsed/json-mapper": "7.80.0",
|
|
47
|
+
"@tsed/schema": "7.80.0",
|
|
44
48
|
"knex": ">=0.94.0",
|
|
45
49
|
"objection": ">=2.0.0"
|
|
46
50
|
},
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import {presets} from "@tsed/vitest/presets";
|
|
3
|
+
import {defineConfig} from "vitest/config";
|
|
4
|
+
|
|
5
|
+
export default defineConfig(
|
|
6
|
+
{
|
|
7
|
+
...presets,
|
|
8
|
+
test: {
|
|
9
|
+
...presets.test,
|
|
10
|
+
coverage: {
|
|
11
|
+
...presets.test.coverage,
|
|
12
|
+
thresholds: {
|
|
13
|
+
statements: 0,
|
|
14
|
+
branches: 0,
|
|
15
|
+
functions: 0,
|
|
16
|
+
lines: 0
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
);
|
package/jest.config.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// For a detailed explanation regarding each configuration property, visit:
|
|
2
|
-
// https://jestjs.io/docs/en/configuration.html
|
|
3
|
-
const config = require("@tsed/jest-config");
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
...config,
|
|
7
|
-
roots: ["<rootDir>/src", "<rootDir>/test"],
|
|
8
|
-
moduleNameMapper: {
|
|
9
|
-
...config.moduleNameMapper,
|
|
10
|
-
"@tsed/objection": "<rootDir>/src/index.ts"
|
|
11
|
-
},
|
|
12
|
-
coverageThreshold: {
|
|
13
|
-
global: {
|
|
14
|
-
branches: 96.87,
|
|
15
|
-
functions: 91.48,
|
|
16
|
-
lines: 98.26,
|
|
17
|
-
statements: 98.26
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
};
|
package/lib/cjs/package.json
DELETED
package/lib/esm/package.json
DELETED
package/tsconfig.esm.json
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@tsed/typescript/tsconfig.node.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"baseUrl": ".",
|
|
5
|
-
"module": "ES2020",
|
|
6
|
-
"rootDir": "src",
|
|
7
|
-
"outDir": "./lib/esm",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"declarationDir": "./lib/types",
|
|
10
|
-
"composite": true,
|
|
11
|
-
"noEmit": false
|
|
12
|
-
},
|
|
13
|
-
"include": ["src", "src/**/*.json"],
|
|
14
|
-
"exclude": [
|
|
15
|
-
"node_modules",
|
|
16
|
-
"test",
|
|
17
|
-
"lib",
|
|
18
|
-
"benchmark",
|
|
19
|
-
"coverage",
|
|
20
|
-
"spec",
|
|
21
|
-
"**/*.benchmark.ts",
|
|
22
|
-
"**/*.spec.ts",
|
|
23
|
-
"keys",
|
|
24
|
-
"jest.config.js",
|
|
25
|
-
"**/__mock__/**",
|
|
26
|
-
"webpack.config.js"
|
|
27
|
-
],
|
|
28
|
-
"references": [
|
|
29
|
-
{
|
|
30
|
-
"path": "../../specs/ajv"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"path": "../../core"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"path": "../../di"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"path": "../../specs/json-mapper"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"path": "../../specs/schema"
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
}
|