@tsed/objection 6.132.0 → 6.133.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.
@@ -2,15 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createIdColumn = void 0;
4
4
  const ColumnTypesContainer_1 = require("../services/ColumnTypesContainer");
5
+ const crypto_1 = require("crypto");
5
6
  /**
6
7
  * @ignore
7
8
  */
8
9
  function createIdColumn(table, { entity, options }) {
9
- if (options.type === "bigIncrements") {
10
- table.bigIncrements(entity.propertyName).primary();
11
- }
12
- else {
13
- table.increments(entity.propertyName).primary();
10
+ switch (options.type) {
11
+ case "bigIncrements":
12
+ table.bigIncrements(entity.propertyName).primary();
13
+ break;
14
+ case "increments":
15
+ table.increments(entity.propertyName).primary();
16
+ break;
17
+ case "uuid":
18
+ table.uuid(entity.propertyName).primary().defaultTo((0, crypto_1.randomUUID)());
14
19
  }
15
20
  }
16
21
  exports.createIdColumn = createIdColumn;
@@ -1 +1 @@
1
- {"version":3,"file":"createIdColumn.js","sourceRoot":"","sources":["../../../src/components/createIdColumn.ts"],"names":[],"mappings":";;;AACA,2EAAsE;AAGtE;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAwB,EAAE,EAAC,MAAM,EAAE,OAAO,EAAY;IACnF,IAAI,OAAO,CAAC,IAAI,KAAK,eAAe,EAAE;QACpC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;KACpD;SAAM;QACL,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;KACjD;AACH,CAAC;AAND,wCAMC;AAED,2CAAoB,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import type {Knex} from \"knex\";\nimport {ColumnTypesContainer} from \"../services/ColumnTypesContainer\";\nimport {ColumnCtx} from \"../utils/getColumnCtx\";\n\n/**\n * @ignore\n */\nexport function createIdColumn(table: Knex.TableBuilder, {entity, options}: ColumnCtx) {\n if (options.type === \"bigIncrements\") {\n table.bigIncrements(entity.propertyName).primary();\n } else {\n table.increments(entity.propertyName).primary();\n }\n}\n\nColumnTypesContainer.set(\"idColumn\", createIdColumn);\n"]}
1
+ {"version":3,"file":"createIdColumn.js","sourceRoot":"","sources":["../../../src/components/createIdColumn.ts"],"names":[],"mappings":";;;AACA,2EAAsE;AAEtE,mCAAkC;AAElC;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAwB,EAAE,EAAC,MAAM,EAAE,OAAO,EAAY;IACnF,QAAQ,OAAO,CAAC,IAAI,EAAE;QACpB,KAAK,eAAe;YAClB,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;YACnD,MAAM;QACR,KAAK,YAAY;YACf,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;YAChD,MAAM;QACR,KAAK,MAAM;YACT,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,IAAA,mBAAU,GAAE,CAAC,CAAC;KACrE;AACH,CAAC;AAXD,wCAWC;AAED,2CAAoB,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import {ColumnCtx} from \"../utils/getColumnCtx\";\nimport {ColumnTypesContainer} from \"../services/ColumnTypesContainer\";\nimport type {Knex} from \"knex\";\nimport {randomUUID} from \"crypto\";\n\n/**\n * @ignore\n */\nexport function createIdColumn(table: Knex.TableBuilder, {entity, options}: ColumnCtx) {\n switch (options.type) {\n case \"bigIncrements\":\n table.bigIncrements(entity.propertyName).primary();\n break;\n case \"increments\":\n table.increments(entity.propertyName).primary();\n break;\n case \"uuid\":\n table.uuid(entity.propertyName).primary().defaultTo(randomUUID());\n }\n}\n\nColumnTypesContainer.set(\"idColumn\", createIdColumn);\n"]}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IdColumn = void 0;
4
- const core_1 = require("@tsed/core");
4
+ const columnOptions_1 = require("./columnOptions");
5
5
  const schema_1 = require("@tsed/schema");
6
6
  const defineStaticGetter_1 = require("../utils/defineStaticGetter");
7
- const columnOptions_1 = require("./columnOptions");
7
+ const core_1 = require("@tsed/core");
8
8
  /**
9
9
  *
10
10
  * @param type
@@ -1 +1 @@
1
- {"version":3,"file":"idColumn.js","sourceRoot":"","sources":["../../../src/decorators/idColumn.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AACzC,yCAAsC;AACtC,oEAA+D;AAC/D,mDAA8C;AAE9C;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,OAAuC,YAAY;IAC1E,OAAO,IAAA,oBAAa,EAClB,IAAA,iBAAQ,GAAE,EACV,IAAA,6BAAa,EAAC;QACZ,UAAU,EAAE,UAAU;QACtB,OAAO,EAAE;YACP,IAAI;SACL;KACF,CAAC,EACF,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QACnC,IAAA,uCAAkB,EAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC;IAC5D,CAAC,CACF,CAAC;AACJ,CAAC;AAbD,4BAaC","sourcesContent":["import {useDecorators} from \"@tsed/core\";\nimport {Property} from \"@tsed/schema\";\nimport {defineStaticGetter} from \"../utils/defineStaticGetter\";\nimport {ColumnOptions} from \"./columnOptions\";\n\n/**\n *\n * @param type\n * @decorator\n * @objection\n */\nexport function IdColumn(type: \"increments\" | \"bigIncrements\" = \"increments\"): PropertyDecorator {\n return useDecorators(\n Property(),\n ColumnOptions({\n columnType: \"idColumn\",\n options: {\n type\n }\n }),\n (target: any, propertyKey: string) => {\n defineStaticGetter(target, \"idColumn\", () => propertyKey);\n }\n );\n}\n"]}
1
+ {"version":3,"file":"idColumn.js","sourceRoot":"","sources":["../../../src/decorators/idColumn.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAC9C,yCAAsC;AACtC,oEAA+D;AAC/D,qCAAyC;AAEzC;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,OAAgD,YAAY;IACnF,OAAO,IAAA,oBAAa,EAClB,IAAA,iBAAQ,GAAE,EACV,IAAA,6BAAa,EAAC;QACZ,UAAU,EAAE,UAAU;QACtB,OAAO,EAAE;YACP,IAAI;SACL;KACF,CAAC,EACF,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QACnC,IAAA,uCAAkB,EAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC;IAC5D,CAAC,CACF,CAAC;AACJ,CAAC;AAbD,4BAaC","sourcesContent":["import {ColumnOptions} from \"./columnOptions\";\nimport {Property} from \"@tsed/schema\";\nimport {defineStaticGetter} from \"../utils/defineStaticGetter\";\nimport {useDecorators} from \"@tsed/core\";\n\n/**\n *\n * @param type\n * @decorator\n * @objection\n */\nexport function IdColumn(type: \"uuid\" | \"increments\" | \"bigIncrements\" = \"increments\"): PropertyDecorator {\n return useDecorators(\n Property(),\n ColumnOptions({\n columnType: \"idColumn\",\n options: {\n type\n }\n }),\n (target: any, propertyKey: string) => {\n defineStaticGetter(target, \"idColumn\", () => propertyKey);\n }\n );\n}\n"]}
@@ -1,13 +1,18 @@
1
1
  import { ColumnTypesContainer } from "../services/ColumnTypesContainer.js";
2
+ import { randomUUID } from "crypto";
2
3
  /**
3
4
  * @ignore
4
5
  */
5
6
  export function createIdColumn(table, { entity, options }) {
6
- if (options.type === "bigIncrements") {
7
- table.bigIncrements(entity.propertyName).primary();
8
- }
9
- else {
10
- table.increments(entity.propertyName).primary();
7
+ switch (options.type) {
8
+ case "bigIncrements":
9
+ table.bigIncrements(entity.propertyName).primary();
10
+ break;
11
+ case "increments":
12
+ table.increments(entity.propertyName).primary();
13
+ break;
14
+ case "uuid":
15
+ table.uuid(entity.propertyName).primary().defaultTo(randomUUID());
11
16
  }
12
17
  }
13
18
  ColumnTypesContainer.set("idColumn", createIdColumn);
@@ -1 +1 @@
1
- {"version":3,"file":"createIdColumn.js","sourceRoot":"","sources":["../../../src/components/createIdColumn.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oBAAoB,EAAC,MAAM,kCAAkC,CAAC;AAGtE;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAwB,EAAE,EAAC,MAAM,EAAE,OAAO,EAAY;IACnF,IAAI,OAAO,CAAC,IAAI,KAAK,eAAe,EAAE;QACpC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;KACpD;SAAM;QACL,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;KACjD;AACH,CAAC;AAED,oBAAoB,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import type {Knex} from \"knex\";\nimport {ColumnTypesContainer} from \"../services/ColumnTypesContainer\";\nimport {ColumnCtx} from \"../utils/getColumnCtx\";\n\n/**\n * @ignore\n */\nexport function createIdColumn(table: Knex.TableBuilder, {entity, options}: ColumnCtx) {\n if (options.type === \"bigIncrements\") {\n table.bigIncrements(entity.propertyName).primary();\n } else {\n table.increments(entity.propertyName).primary();\n }\n}\n\nColumnTypesContainer.set(\"idColumn\", createIdColumn);\n"]}
1
+ {"version":3,"file":"createIdColumn.js","sourceRoot":"","sources":["../../../src/components/createIdColumn.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oBAAoB,EAAC,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAC;AAElC;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAwB,EAAE,EAAC,MAAM,EAAE,OAAO,EAAY;IACnF,QAAQ,OAAO,CAAC,IAAI,EAAE;QACpB,KAAK,eAAe;YAClB,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;YACnD,MAAM;QACR,KAAK,YAAY;YACf,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;YAChD,MAAM;QACR,KAAK,MAAM;YACT,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC;KACrE;AACH,CAAC;AAED,oBAAoB,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import {ColumnCtx} from \"../utils/getColumnCtx\";\nimport {ColumnTypesContainer} from \"../services/ColumnTypesContainer\";\nimport type {Knex} from \"knex\";\nimport {randomUUID} from \"crypto\";\n\n/**\n * @ignore\n */\nexport function createIdColumn(table: Knex.TableBuilder, {entity, options}: ColumnCtx) {\n switch (options.type) {\n case \"bigIncrements\":\n table.bigIncrements(entity.propertyName).primary();\n break;\n case \"increments\":\n table.increments(entity.propertyName).primary();\n break;\n case \"uuid\":\n table.uuid(entity.propertyName).primary().defaultTo(randomUUID());\n }\n}\n\nColumnTypesContainer.set(\"idColumn\", createIdColumn);\n"]}
@@ -1,7 +1,7 @@
1
- import { useDecorators } from "@tsed/core";
1
+ import { ColumnOptions } from "./columnOptions.js";
2
2
  import { Property } from "@tsed/schema";
3
3
  import { defineStaticGetter } from "../utils/defineStaticGetter.js";
4
- import { ColumnOptions } from "./columnOptions.js";
4
+ import { useDecorators } from "@tsed/core";
5
5
  /**
6
6
  *
7
7
  * @param type
@@ -1 +1 @@
1
- {"version":3,"file":"idColumn.js","sourceRoot":"","sources":["../../../src/decorators/idColumn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAuC,YAAY;IAC1E,OAAO,aAAa,CAClB,QAAQ,EAAE,EACV,aAAa,CAAC;QACZ,UAAU,EAAE,UAAU;QACtB,OAAO,EAAE;YACP,IAAI;SACL;KACF,CAAC,EACF,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QACnC,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC;IAC5D,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import {useDecorators} from \"@tsed/core\";\nimport {Property} from \"@tsed/schema\";\nimport {defineStaticGetter} from \"../utils/defineStaticGetter\";\nimport {ColumnOptions} from \"./columnOptions\";\n\n/**\n *\n * @param type\n * @decorator\n * @objection\n */\nexport function IdColumn(type: \"increments\" | \"bigIncrements\" = \"increments\"): PropertyDecorator {\n return useDecorators(\n Property(),\n ColumnOptions({\n columnType: \"idColumn\",\n options: {\n type\n }\n }),\n (target: any, propertyKey: string) => {\n defineStaticGetter(target, \"idColumn\", () => propertyKey);\n }\n );\n}\n"]}
1
+ {"version":3,"file":"idColumn.js","sourceRoot":"","sources":["../../../src/decorators/idColumn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAgD,YAAY;IACnF,OAAO,aAAa,CAClB,QAAQ,EAAE,EACV,aAAa,CAAC;QACZ,UAAU,EAAE,UAAU;QACtB,OAAO,EAAE;YACP,IAAI;SACL;KACF,CAAC,EACF,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QACnC,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC;IAC5D,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import {ColumnOptions} from \"./columnOptions\";\nimport {Property} from \"@tsed/schema\";\nimport {defineStaticGetter} from \"../utils/defineStaticGetter\";\nimport {useDecorators} from \"@tsed/core\";\n\n/**\n *\n * @param type\n * @decorator\n * @objection\n */\nexport function IdColumn(type: \"uuid\" | \"increments\" | \"bigIncrements\" = \"increments\"): PropertyDecorator {\n return useDecorators(\n Property(),\n ColumnOptions({\n columnType: \"idColumn\",\n options: {\n type\n }\n }),\n (target: any, propertyKey: string) => {\n defineStaticGetter(target, \"idColumn\", () => propertyKey);\n }\n );\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { Knex } from "knex";
2
1
  import { ColumnCtx } from "../utils/getColumnCtx";
2
+ import type { Knex } from "knex";
3
3
  /**
4
4
  * @ignore
5
5
  */
@@ -4,4 +4,4 @@
4
4
  * @decorator
5
5
  * @objection
6
6
  */
7
- export declare function IdColumn(type?: "increments" | "bigIncrements"): PropertyDecorator;
7
+ export declare function IdColumn(type?: "uuid" | "increments" | "bigIncrements"): PropertyDecorator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/objection",
3
- "version": "6.132.0",
3
+ "version": "6.133.0",
4
4
  "description": "Objection.js package for Ts.ED framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -24,21 +24,21 @@
24
24
  "tslib": "2.4.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@tsed/ajv": "6.132.0",
28
- "@tsed/core": "6.132.0",
29
- "@tsed/di": "6.132.0",
30
- "@tsed/json-mapper": "6.132.0",
31
- "@tsed/schema": "6.132.0",
27
+ "@tsed/ajv": "6.133.0",
28
+ "@tsed/core": "6.133.0",
29
+ "@tsed/di": "6.133.0",
30
+ "@tsed/json-mapper": "6.133.0",
31
+ "@tsed/schema": "6.133.0",
32
32
  "knex": "^0.95.11",
33
33
  "objection": "^2.2.15",
34
34
  "sqlite3": "^5.0.2"
35
35
  },
36
36
  "peerDependencies": {
37
- "@tsed/ajv": "^6.132.0",
38
- "@tsed/core": "^6.132.0",
39
- "@tsed/di": "^6.132.0",
40
- "@tsed/json-mapper": "^6.132.0",
41
- "@tsed/schema": "^6.132.0",
37
+ "@tsed/ajv": "^6.133.0",
38
+ "@tsed/core": "^6.133.0",
39
+ "@tsed/di": "^6.133.0",
40
+ "@tsed/json-mapper": "^6.133.0",
41
+ "@tsed/schema": "^6.133.0",
42
42
  "knex": ">=0.94.0",
43
43
  "objection": ">=2.0.0"
44
44
  },