@tsed/objection 6.88.0 → 6.91.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.
Files changed (102) hide show
  1. package/lib/{components → cjs/components}/createBooleanColumn.d.ts +0 -0
  2. package/lib/cjs/components/createBooleanColumn.js +13 -0
  3. package/lib/cjs/components/createBooleanColumn.js.map +1 -0
  4. package/lib/{components → cjs/components}/createIdColumn.d.ts +0 -0
  5. package/lib/cjs/components/createIdColumn.js +18 -0
  6. package/lib/cjs/components/createIdColumn.js.map +1 -0
  7. package/lib/{components → cjs/components}/createNumberColumn.d.ts +0 -0
  8. package/lib/cjs/components/createNumberColumn.js +13 -0
  9. package/lib/cjs/components/createNumberColumn.js.map +1 -0
  10. package/lib/{components → cjs/components}/createStringColumn.d.ts +0 -0
  11. package/lib/cjs/components/createStringColumn.js +13 -0
  12. package/lib/cjs/components/createStringColumn.js.map +1 -0
  13. package/lib/{decorators → cjs/decorators}/columnOptions.d.ts +0 -0
  14. package/lib/cjs/decorators/columnOptions.js +15 -0
  15. package/lib/cjs/decorators/columnOptions.js.map +1 -0
  16. package/lib/{decorators → cjs/decorators}/decimal.d.ts +0 -0
  17. package/lib/cjs/decorators/decimal.js +29 -0
  18. package/lib/cjs/decorators/decimal.js.map +1 -0
  19. package/lib/{decorators → cjs/decorators}/entity.d.ts +0 -0
  20. package/lib/cjs/decorators/entity.js +23 -0
  21. package/lib/cjs/decorators/entity.js.map +1 -0
  22. package/lib/{decorators → cjs/decorators}/idColumn.d.ts +0 -0
  23. package/lib/cjs/decorators/idColumn.js +25 -0
  24. package/lib/cjs/decorators/idColumn.js.map +1 -0
  25. package/lib/{domain → cjs/domain}/ColumnOpts.d.ts +0 -0
  26. package/lib/cjs/domain/ColumnOpts.js +3 -0
  27. package/lib/cjs/domain/ColumnOpts.js.map +1 -0
  28. package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  29. package/lib/cjs/index.js +21 -0
  30. package/lib/cjs/index.js.map +1 -0
  31. package/lib/{services → cjs/services}/ColumnTypesContainer.d.ts +0 -0
  32. package/lib/cjs/services/ColumnTypesContainer.js +8 -0
  33. package/lib/cjs/services/ColumnTypesContainer.js.map +1 -0
  34. package/lib/{services → cjs/services}/ObjectionConnection.d.ts +0 -0
  35. package/lib/cjs/services/ObjectionConnection.js +24 -0
  36. package/lib/cjs/services/ObjectionConnection.js.map +1 -0
  37. package/lib/{utils → cjs/utils}/connect.d.ts +0 -0
  38. package/lib/cjs/utils/connect.js +13 -0
  39. package/lib/cjs/utils/connect.js.map +1 -0
  40. package/lib/{utils → cjs/utils}/createColumns.d.ts +0 -0
  41. package/lib/cjs/utils/createColumns.js +38 -0
  42. package/lib/cjs/utils/createColumns.js.map +1 -0
  43. package/lib/{utils → cjs/utils}/defineStaticGetter.d.ts +0 -0
  44. package/lib/cjs/utils/defineStaticGetter.js +14 -0
  45. package/lib/cjs/utils/defineStaticGetter.js.map +1 -0
  46. package/lib/{utils → cjs/utils}/getColumnCtx.d.ts +0 -0
  47. package/lib/cjs/utils/getColumnCtx.js +13 -0
  48. package/lib/cjs/utils/getColumnCtx.js.map +1 -0
  49. package/lib/esm/components/createBooleanColumn.js +9 -0
  50. package/lib/esm/components/createBooleanColumn.js.map +1 -0
  51. package/lib/esm/components/createIdColumn.js +14 -0
  52. package/lib/esm/components/createIdColumn.js.map +1 -0
  53. package/lib/esm/components/createNumberColumn.js +9 -0
  54. package/lib/esm/components/createNumberColumn.js.map +1 -0
  55. package/lib/esm/components/createStringColumn.js +9 -0
  56. package/lib/esm/components/createStringColumn.js.map +1 -0
  57. package/lib/esm/decorators/columnOptions.js +11 -0
  58. package/lib/esm/decorators/columnOptions.js.map +1 -0
  59. package/lib/esm/decorators/decimal.js +25 -0
  60. package/lib/esm/decorators/decimal.js.map +1 -0
  61. package/lib/esm/decorators/entity.js +19 -0
  62. package/lib/esm/decorators/entity.js.map +1 -0
  63. package/lib/esm/decorators/idColumn.js +21 -0
  64. package/lib/esm/decorators/idColumn.js.map +1 -0
  65. package/lib/esm/domain/ColumnOpts.js +2 -0
  66. package/lib/esm/domain/ColumnOpts.js.map +1 -0
  67. package/lib/esm/index.js +18 -0
  68. package/lib/esm/index.js.map +1 -0
  69. package/lib/esm/services/ColumnTypesContainer.js +5 -0
  70. package/lib/esm/services/ColumnTypesContainer.js.map +1 -0
  71. package/lib/esm/services/ObjectionConnection.js +21 -0
  72. package/lib/esm/services/ObjectionConnection.js.map +1 -0
  73. package/lib/esm/utils/connect.js +8 -0
  74. package/lib/esm/utils/connect.js.map +1 -0
  75. package/lib/esm/utils/createColumns.js +32 -0
  76. package/lib/esm/utils/createColumns.js.map +1 -0
  77. package/lib/esm/utils/defineStaticGetter.js +10 -0
  78. package/lib/esm/utils/defineStaticGetter.js.map +1 -0
  79. package/lib/esm/utils/getColumnCtx.js +9 -0
  80. package/lib/esm/utils/getColumnCtx.js.map +1 -0
  81. package/lib/types/components/createBooleanColumn.d.ts +6 -0
  82. package/lib/types/components/createIdColumn.d.ts +6 -0
  83. package/lib/types/components/createNumberColumn.d.ts +6 -0
  84. package/lib/types/components/createStringColumn.d.ts +6 -0
  85. package/lib/types/decorators/columnOptions.d.ts +8 -0
  86. package/lib/types/decorators/decimal.d.ts +11 -0
  87. package/lib/types/decorators/entity.d.ts +11 -0
  88. package/lib/types/decorators/idColumn.d.ts +7 -0
  89. package/lib/types/domain/ColumnOpts.d.ts +4 -0
  90. package/lib/types/index.d.ts +21 -0
  91. package/lib/types/services/ColumnTypesContainer.d.ts +6 -0
  92. package/lib/types/services/ObjectionConnection.d.ts +3 -0
  93. package/lib/types/utils/connect.d.ts +2 -0
  94. package/lib/types/utils/createColumns.d.ts +18 -0
  95. package/lib/types/utils/defineStaticGetter.d.ts +4 -0
  96. package/lib/types/utils/getColumnCtx.d.ts +13 -0
  97. package/package.json +20 -16
  98. package/tsconfig.compile.esm.json +23 -0
  99. package/lib/index.js +0 -257
  100. package/lib/index.js.map +0 -1
  101. package/lib/index.modern.js +0 -240
  102. package/lib/index.modern.js.map +0 -1
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBooleanColumn = void 0;
4
+ const ColumnTypesContainer_1 = require("../services/ColumnTypesContainer");
5
+ /**
6
+ * @ignore
7
+ */
8
+ function createBooleanColumn(table, { entity }) {
9
+ table.boolean(entity.propertyName);
10
+ }
11
+ exports.createBooleanColumn = createBooleanColumn;
12
+ ColumnTypesContainer_1.ColumnTypesContainer.set("boolean", createBooleanColumn);
13
+ //# sourceMappingURL=createBooleanColumn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBooleanColumn.js","sourceRoot":"","sources":["../../../src/components/createBooleanColumn.ts"],"names":[],"mappings":";;;AACA,2EAAsE;AAEtE;;GAEG;AACH,SAAgB,mBAAmB,CAAC,KAAwB,EAAE,EAAC,MAAM,EAAY;IAC/E,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACrC,CAAC;AAFD,kDAEC;AAED,2CAAoB,CAAC,GAAG,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import type {Knex} from \"knex\";\nimport {ColumnTypesContainer} from \"../services/ColumnTypesContainer\";\nimport {ColumnCtx} from \"../utils/getColumnCtx\";\n/**\n * @ignore\n */\nexport function createBooleanColumn(table: Knex.TableBuilder, {entity}: ColumnCtx) {\n table.boolean(entity.propertyName);\n}\n\nColumnTypesContainer.set(\"boolean\", createBooleanColumn);\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createIdColumn = void 0;
4
+ const ColumnTypesContainer_1 = require("../services/ColumnTypesContainer");
5
+ /**
6
+ * @ignore
7
+ */
8
+ 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();
14
+ }
15
+ }
16
+ exports.createIdColumn = createIdColumn;
17
+ ColumnTypesContainer_1.ColumnTypesContainer.set("idColumn", createIdColumn);
18
+ //# sourceMappingURL=createIdColumn.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNumberColumn = void 0;
4
+ const ColumnTypesContainer_1 = require("../services/ColumnTypesContainer");
5
+ /**
6
+ * @ignore
7
+ */
8
+ function createNumberColumn(table, { entity, options }) {
9
+ table.decimal(entity.propertyName, options.precision, options.scale);
10
+ }
11
+ exports.createNumberColumn = createNumberColumn;
12
+ ColumnTypesContainer_1.ColumnTypesContainer.set("number", createNumberColumn);
13
+ //# sourceMappingURL=createNumberColumn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createNumberColumn.js","sourceRoot":"","sources":["../../../src/components/createNumberColumn.ts"],"names":[],"mappings":";;;AACA,2EAAsE;AAGtE;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAAwB,EAAE,EAAC,MAAM,EAAE,OAAO,EAAY;IACvF,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAFD,gDAEC;AAED,2CAAoB,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,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 createNumberColumn(table: Knex.TableBuilder, {entity, options}: ColumnCtx) {\n table.decimal(entity.propertyName, options.precision, options.scale);\n}\n\nColumnTypesContainer.set(\"number\", createNumberColumn);\n"]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createStringColumn = void 0;
4
+ const ColumnTypesContainer_1 = require("../services/ColumnTypesContainer");
5
+ /**
6
+ * @ignore
7
+ */
8
+ function createStringColumn(table, { entity, schema }) {
9
+ table.string(entity.propertyName, schema.maxLength);
10
+ }
11
+ exports.createStringColumn = createStringColumn;
12
+ ColumnTypesContainer_1.ColumnTypesContainer.set("string", createStringColumn);
13
+ //# sourceMappingURL=createStringColumn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createStringColumn.js","sourceRoot":"","sources":["../../../src/components/createStringColumn.ts"],"names":[],"mappings":";;;AACA,2EAAsE;AAGtE;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAAwB,EAAE,EAAC,MAAM,EAAE,MAAM,EAAY;IACtF,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;AACtD,CAAC;AAFD,gDAEC;AAED,2CAAoB,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,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 createStringColumn(table: Knex.TableBuilder, {entity, schema}: ColumnCtx) {\n table.string(entity.propertyName, schema.maxLength);\n}\n\nColumnTypesContainer.set(\"string\", createStringColumn);\n"]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColumnOptions = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ /**
6
+ *
7
+ * @param options
8
+ * @decorator
9
+ * @objection
10
+ */
11
+ function ColumnOptions(options) {
12
+ return (0, core_1.StoreSet)("objection", options);
13
+ }
14
+ exports.ColumnOptions = ColumnOptions;
15
+ //# sourceMappingURL=columnOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columnOptions.js","sourceRoot":"","sources":["../../../src/decorators/columnOptions.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AAGpC;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,OAA4B;IACxD,OAAO,IAAA,eAAQ,EAAC,WAAW,EAAE,OAAO,CAAQ,CAAC;AAC/C,CAAC;AAFD,sCAEC","sourcesContent":["import {StoreSet} from \"@tsed/core\";\nimport type {ColumnOpts} from \"../domain/ColumnOpts\";\n\n/**\n *\n * @param options\n * @decorator\n * @objection\n */\nexport function ColumnOptions(options: Partial<ColumnOpts>): PropertyDecorator {\n return StoreSet(\"objection\", options) as any;\n}\n"]}
File without changes
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Decimal = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ const schema_1 = require("@tsed/schema");
6
+ const columnOptions_1 = require("./columnOptions");
7
+ /**
8
+ *
9
+ * @param options
10
+ * @decorator
11
+ * @objection
12
+ */
13
+ function Decimal(options = {}) {
14
+ return (0, core_1.useDecorators)((0, schema_1.Property)(), (0, columnOptions_1.ColumnOptions)({
15
+ columnType: "number",
16
+ options: {
17
+ type: "decimal",
18
+ ...options
19
+ }
20
+ }), (0, core_1.StoreSet)("objection", {
21
+ columnType: "number",
22
+ options: {
23
+ type: "decimal",
24
+ ...options
25
+ }
26
+ }));
27
+ }
28
+ exports.Decimal = Decimal;
29
+ //# sourceMappingURL=decimal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal.js","sourceRoot":"","sources":["../../../src/decorators/decimal.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AACnD,yCAAsC;AACtC,mDAA8C;AAO9C;;;;;GAKG;AACH,SAAgB,OAAO,CAAC,UAA0B,EAAE;IAClD,OAAO,IAAA,oBAAa,EAClB,IAAA,iBAAQ,GAAE,EACV,IAAA,6BAAa,EAAC;QACZ,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,GAAG,OAAO;SACX;KACF,CAAC,EACF,IAAA,eAAQ,EAAC,WAAW,EAAE;QACpB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,GAAG,OAAO;SACX;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAlBD,0BAkBC","sourcesContent":["import {StoreSet, useDecorators} from \"@tsed/core\";\nimport {Property} from \"@tsed/schema\";\nimport {ColumnOptions} from \"./columnOptions\";\n\nexport interface DecimalOptions {\n precision?: number | null;\n scale?: number;\n}\n\n/**\n *\n * @param options\n * @decorator\n * @objection\n */\nexport function Decimal(options: DecimalOptions = {}) {\n return useDecorators(\n Property(),\n ColumnOptions({\n columnType: \"number\",\n options: {\n type: \"decimal\",\n ...options\n }\n }),\n StoreSet(\"objection\", {\n columnType: \"number\",\n options: {\n type: \"decimal\",\n ...options\n }\n })\n );\n}\n"]}
File without changes
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Entity = void 0;
4
+ const schema_1 = require("@tsed/schema");
5
+ const defineStaticGetter_1 = require("../utils/defineStaticGetter");
6
+ /**
7
+ *
8
+ * @param tableName
9
+ * @decorator
10
+ * @objection
11
+ */
12
+ function Entity(tableName) {
13
+ if (!tableName) {
14
+ throw new Error("Please provide a table name");
15
+ }
16
+ return (target) => {
17
+ (0, defineStaticGetter_1.defineStaticGetter)(target, "tableName", () => tableName);
18
+ (0, defineStaticGetter_1.defineStaticGetter)(target, "jsonSchema", () => (0, schema_1.getJsonSchema)(target));
19
+ return target;
20
+ };
21
+ }
22
+ exports.Entity = Entity;
23
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../../src/decorators/entity.ts"],"names":[],"mappings":";;;AACA,yCAA2C;AAC3C,oEAA+D;AAE/D;;;;;GAKG;AACH,SAAgB,MAAM,CAAC,SAAiB;IACtC,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAED,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,uCAAkB,EAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACzD,IAAA,uCAAkB,EAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,IAAA,sBAAa,EAAC,MAAM,CAAC,CAAC,CAAC;QAEtE,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAXD,wBAWC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {getJsonSchema} from \"@tsed/schema\";\nimport {defineStaticGetter} from \"../utils/defineStaticGetter\";\n\n/**\n *\n * @param tableName\n * @decorator\n * @objection\n */\nexport function Entity(tableName: string): ClassDecorator {\n if (!tableName) {\n throw new Error(\"Please provide a table name\");\n }\n\n return (target: any) => {\n defineStaticGetter(target, \"tableName\", () => tableName);\n defineStaticGetter(target, \"jsonSchema\", () => getJsonSchema(target));\n\n return target;\n };\n}\n\nexport interface EntityMethods<T> extends Type<T> {\n readonly tableName: string;\n}\n"]}
File without changes
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdColumn = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ const schema_1 = require("@tsed/schema");
6
+ const defineStaticGetter_1 = require("../utils/defineStaticGetter");
7
+ const columnOptions_1 = require("./columnOptions");
8
+ /**
9
+ *
10
+ * @param type
11
+ * @decorator
12
+ * @objection
13
+ */
14
+ function IdColumn(type = "increments") {
15
+ return (0, core_1.useDecorators)((0, schema_1.Property)(), (0, columnOptions_1.ColumnOptions)({
16
+ columnType: "idColumn",
17
+ options: {
18
+ type
19
+ }
20
+ }), (target, propertyKey) => {
21
+ (0, defineStaticGetter_1.defineStaticGetter)(target, "idColumn", () => propertyKey);
22
+ });
23
+ }
24
+ exports.IdColumn = IdColumn;
25
+ //# sourceMappingURL=idColumn.js.map
@@ -0,0 +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"]}
File without changes
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ColumnOpts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColumnOpts.js","sourceRoot":"","sources":["../../../src/domain/ColumnOpts.ts"],"names":[],"mappings":"","sourcesContent":["export interface ColumnOpts {\n columnType: \"idColumn\" | \"string\" | \"number\" | \"boolean\";\n options: any;\n}\n"]}
File without changes
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ // components
5
+ (0, tslib_1.__exportStar)(require("./components/createStringColumn"), exports);
6
+ (0, tslib_1.__exportStar)(require("./components/createIdColumn"), exports);
7
+ (0, tslib_1.__exportStar)(require("./components/createBooleanColumn"), exports);
8
+ (0, tslib_1.__exportStar)(require("./components/createNumberColumn"), exports);
9
+ // decorators
10
+ (0, tslib_1.__exportStar)(require("./decorators/entity"), exports);
11
+ (0, tslib_1.__exportStar)(require("./decorators/decimal"), exports);
12
+ (0, tslib_1.__exportStar)(require("./decorators/idColumn"), exports);
13
+ (0, tslib_1.__exportStar)(require("./decorators/columnOptions"), exports);
14
+ (0, tslib_1.__exportStar)(require("./domain/ColumnOpts"), exports);
15
+ // services
16
+ (0, tslib_1.__exportStar)(require("./services/ObjectionConnection"), exports);
17
+ // utils
18
+ (0, tslib_1.__exportStar)(require("./utils/connect"), exports);
19
+ (0, tslib_1.__exportStar)(require("./utils/createColumns"), exports);
20
+ (0, tslib_1.__exportStar)(require("./utils/getColumnCtx"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAUA,aAAa;AACb,+EAAgD;AAChD,2EAA4C;AAC5C,gFAAiD;AACjD,+EAAgD;AAEhD,aAAa;AACb,mEAAoC;AACpC,oEAAqC;AACrC,qEAAsC;AACtC,0EAA2C;AAE3C,mEAAoC;AAEpC,WAAW;AACX,8EAA+C;AAE/C,QAAQ;AACR,+DAAgC;AAChC,qEAAsC;AACtC,oEAAqC","sourcesContent":["import {Knex} from \"knex\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n knex: Knex.Config;\n }\n }\n}\n\n// components\nexport * from \"./components/createStringColumn\";\nexport * from \"./components/createIdColumn\";\nexport * from \"./components/createBooleanColumn\";\nexport * from \"./components/createNumberColumn\";\n\n// decorators\nexport * from \"./decorators/entity\";\nexport * from \"./decorators/decimal\";\nexport * from \"./decorators/idColumn\";\nexport * from \"./decorators/columnOptions\";\n\nexport * from \"./domain/ColumnOpts\";\n\n// services\nexport * from \"./services/ObjectionConnection\";\n\n// utils\nexport * from \"./utils/connect\";\nexport * from \"./utils/createColumns\";\nexport * from \"./utils/getColumnCtx\";\n"]}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ColumnTypesContainer = void 0;
4
+ /**
5
+ * @ignore
6
+ */
7
+ exports.ColumnTypesContainer = new Map();
8
+ //# sourceMappingURL=ColumnTypesContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColumnTypesContainer.js","sourceRoot":"","sources":["../../../src/services/ColumnTypesContainer.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACU,QAAA,oBAAoB,GAAoE,IAAI,GAAG,EAAE,CAAC","sourcesContent":["import type {Knex} from \"knex\";\nimport {ColumnCtx} from \"../utils/getColumnCtx\";\n\n/**\n * @ignore\n */\nexport const ColumnTypesContainer: Map<string, (table: Knex.TableBuilder, ctx: ColumnCtx) => void> = new Map();\n"]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OBJECTION_CONNECTION = void 0;
4
+ const di_1 = require("@tsed/di");
5
+ const connect_1 = require("../utils/connect");
6
+ exports.OBJECTION_CONNECTION = Symbol.for("DEFAULT_CONNECTION");
7
+ (0, di_1.registerProvider)({
8
+ provide: exports.OBJECTION_CONNECTION,
9
+ deps: [di_1.Configuration],
10
+ async useAsyncFactory(configuration) {
11
+ const connectionOptions = configuration.get("knex");
12
+ if (connectionOptions) {
13
+ try {
14
+ return (0, connect_1.createConnection)(connectionOptions);
15
+ }
16
+ catch (er) {
17
+ // istanbul ignore next
18
+ console.error(er);
19
+ }
20
+ }
21
+ return {};
22
+ }
23
+ });
24
+ //# sourceMappingURL=ObjectionConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectionConnection.js","sourceRoot":"","sources":["../../../src/services/ObjectionConnection.ts"],"names":[],"mappings":";;;AAAA,iCAAyD;AAEzD,8CAAkD;AAErC,QAAA,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAGrE,IAAA,qBAAgB,EAAC;IACf,OAAO,EAAE,4BAAoB;IAC7B,IAAI,EAAE,CAAC,kBAAa,CAAC;IACrB,KAAK,CAAC,eAAe,CAAC,aAA4B;QAChD,MAAM,iBAAiB,GAAG,aAAa,CAAC,GAAG,CAAc,MAAM,CAAE,CAAC;QAElE,IAAI,iBAAiB,EAAE;YACrB,IAAI;gBACF,OAAO,IAAA,0BAAgB,EAAC,iBAAiB,CAAC,CAAC;aAC5C;YAAC,OAAO,EAAE,EAAE;gBACX,uBAAuB;gBACvB,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;aACnB;SACF;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {Configuration, registerProvider} from \"@tsed/di\";\nimport type {Knex} from \"knex\";\nimport {createConnection} from \"../utils/connect\";\n\nexport const OBJECTION_CONNECTION = Symbol.for(\"DEFAULT_CONNECTION\");\nexport type OBJECTION_CONNECTION = Knex<any, unknown[]>;\n\nregisterProvider({\n provide: OBJECTION_CONNECTION,\n deps: [Configuration],\n async useAsyncFactory(configuration: Configuration) {\n const connectionOptions = configuration.get<Knex.Config>(\"knex\")!;\n\n if (connectionOptions) {\n try {\n return createConnection(connectionOptions);\n } catch (er) {\n // istanbul ignore next\n console.error(er);\n }\n }\n\n return {};\n }\n});\n"]}
File without changes
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createConnection = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const knex_1 = (0, tslib_1.__importDefault)(require("knex"));
6
+ const objection_1 = require("objection");
7
+ function createConnection(connectionOptions) {
8
+ const connection = (0, knex_1.default)(connectionOptions);
9
+ objection_1.Model.knex(connection);
10
+ return connection;
11
+ }
12
+ exports.createConnection = createConnection;
13
+ //# sourceMappingURL=connect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.js","sourceRoot":"","sources":["../../../src/utils/connect.ts"],"names":[],"mappings":";;;;AAAA,6DAAgC;AAChC,yCAAgC;AAEhC,SAAgB,gBAAgB,CAAC,iBAA8B;IAC7D,MAAM,UAAU,GAAG,IAAA,cAAI,EAAC,iBAAiB,CAAC,CAAC;IAC3C,iBAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAEvB,OAAO,UAAU,CAAC;AACpB,CAAC;AALD,4CAKC","sourcesContent":["import knex, {Knex} from \"knex\";\nimport {Model} from \"objection\";\n\nexport function createConnection(connectionOptions: Knex.Config): Knex {\n const connection = knex(connectionOptions);\n Model.knex(connection);\n\n return connection;\n}\n"]}
File without changes
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createColumns = exports.getColumns = exports.createColumn = void 0;
4
+ const schema_1 = require("@tsed/schema");
5
+ require("../components/createBooleanColumn");
6
+ require("../components/createIdColumn");
7
+ require("../components/createNumberColumn");
8
+ require("../components/createStringColumn");
9
+ const ColumnTypesContainer_1 = require("../services/ColumnTypesContainer");
10
+ const getColumnCtx_1 = require("./getColumnCtx");
11
+ /**
12
+ * @ignore
13
+ */
14
+ function createColumn(table, entity) {
15
+ const ctx = (0, getColumnCtx_1.getColumnCtx)(entity);
16
+ if (!ColumnTypesContainer_1.ColumnTypesContainer.has(ctx.columnType)) {
17
+ throw `Column type ${ctx.columnType} isn't supported. Add function to ColumnTypesContainer to map the column with Knex`;
18
+ }
19
+ ColumnTypesContainer_1.ColumnTypesContainer.get(ctx.columnType)(table, ctx);
20
+ }
21
+ exports.createColumn = createColumn;
22
+ /**
23
+ * @ignore
24
+ */
25
+ function getColumns(model) {
26
+ return [...(0, schema_1.getProperties)(model, { withIgnoredProps: true, objection: true, groups: false }).values()];
27
+ }
28
+ exports.getColumns = getColumns;
29
+ /**
30
+ * @ignore
31
+ */
32
+ function createColumns(table, model) {
33
+ getColumns(model).map((entity) => {
34
+ createColumn(table, entity);
35
+ });
36
+ }
37
+ exports.createColumns = createColumns;
38
+ //# sourceMappingURL=createColumns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createColumns.js","sourceRoot":"","sources":["../../../src/utils/createColumns.ts"],"names":[],"mappings":";;;AAAA,yCAA4D;AAE5D,6CAA2C;AAC3C,wCAAsC;AACtC,4CAA0C;AAC1C,4CAA0C;AAC1C,2EAAsE;AACtE,iDAA4C;AAE5C;;GAEG;AACH,SAAgB,YAAY,CAAC,KAAwB,EAAE,MAAuB;IAC5E,MAAM,GAAG,GAAG,IAAA,2BAAY,EAAC,MAAM,CAAC,CAAC;IAEjC,IAAI,CAAC,2CAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;QAC7C,MAAM,eAAe,GAAG,CAAC,UAAU,oFAAoF,CAAC;KACzH;IAED,2CAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AARD,oCAQC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,KAAU;IACnC,OAAO,CAAC,GAAG,IAAA,sBAAa,EAAC,KAAK,EAAE,EAAC,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AACtG,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,KAAwB,EAAE,KAAU;IAChE,UAAU,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC/B,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,sCAIC","sourcesContent":["import {getProperties, JsonEntityStore} from \"@tsed/schema\";\nimport {Knex} from \"knex\";\nimport \"../components/createBooleanColumn\";\nimport \"../components/createIdColumn\";\nimport \"../components/createNumberColumn\";\nimport \"../components/createStringColumn\";\nimport {ColumnTypesContainer} from \"../services/ColumnTypesContainer\";\nimport {getColumnCtx} from \"./getColumnCtx\";\n\n/**\n * @ignore\n */\nexport function createColumn(table: Knex.TableBuilder, entity: JsonEntityStore) {\n const ctx = getColumnCtx(entity);\n\n if (!ColumnTypesContainer.has(ctx.columnType)) {\n throw `Column type ${ctx.columnType} isn't supported. Add function to ColumnTypesContainer to map the column with Knex`;\n }\n\n ColumnTypesContainer.get(ctx.columnType)!(table, ctx);\n}\n\n/**\n * @ignore\n */\nexport function getColumns(model: any) {\n return [...getProperties(model, {withIgnoredProps: true, objection: true, groups: false}).values()];\n}\n\n/**\n * @ignore\n */\nexport function createColumns(table: Knex.TableBuilder, model: any) {\n getColumns(model).map((entity) => {\n createColumn(table, entity);\n });\n}\n"]}
File without changes
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineStaticGetter = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ /**
6
+ * @ignore
7
+ */
8
+ function defineStaticGetter(target, propertyKey, fn) {
9
+ return Object.defineProperty((0, core_1.classOf)(target), propertyKey, {
10
+ get: fn
11
+ });
12
+ }
13
+ exports.defineStaticGetter = defineStaticGetter;
14
+ //# sourceMappingURL=defineStaticGetter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineStaticGetter.js","sourceRoot":"","sources":["../../../src/utils/defineStaticGetter.ts"],"names":[],"mappings":";;;AAAA,qCAAmC;AAEnC;;GAEG;AACH,SAAgB,kBAAkB,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAO;IAC1E,OAAO,MAAM,CAAC,cAAc,CAAC,IAAA,cAAO,EAAC,MAAM,CAAC,EAAE,WAAW,EAAE;QACzD,GAAG,EAAE,EAAE;KACR,CAAC,CAAC;AACL,CAAC;AAJD,gDAIC","sourcesContent":["import {classOf} from \"@tsed/core\";\n\n/**\n * @ignore\n */\nexport function defineStaticGetter(target: any, propertyKey: string, fn: any) {\n return Object.defineProperty(classOf(target), propertyKey, {\n get: fn\n });\n}\n"]}
File without changes
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getColumnCtx = void 0;
4
+ /**
5
+ * @ignore
6
+ */
7
+ function getColumnCtx(entity) {
8
+ const schema = entity.schema.toJSON();
9
+ const { columnType = schema.type, options = {} } = entity.store.get("objection", {});
10
+ return { entity, columnType, options, schema };
11
+ }
12
+ exports.getColumnCtx = getColumnCtx;
13
+ //# sourceMappingURL=getColumnCtx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getColumnCtx.js","sourceRoot":"","sources":["../../../src/utils/getColumnCtx.ts"],"names":[],"mappings":";;;AAWA;;GAEG;AACH,SAAgB,YAAY,CAAC,MAAuB;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACtC,MAAM,EAAC,UAAU,GAAG,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,EAAE,EAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAsB,WAAW,EAAE,EAAE,CAAC,CAAC;IAExG,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAC,CAAC;AAC/C,CAAC;AALD,oCAKC","sourcesContent":["import {JsonEntityStore} from \"@tsed/schema\";\nimport {ColumnOpts} from \"../domain/ColumnOpts\";\n\n/**\n * @ignore\n */\nexport interface ColumnCtx extends ColumnOpts {\n entity: JsonEntityStore;\n schema: any;\n}\n\n/**\n * @ignore\n */\nexport function getColumnCtx(entity: JsonEntityStore): ColumnCtx {\n const schema = entity.schema.toJSON();\n const {columnType = schema.type, options = {}} = entity.store.get<Partial<ColumnOpts>>(\"objection\", {});\n\n return {entity, columnType, options, schema};\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { ColumnTypesContainer } from "../services/ColumnTypesContainer";
2
+ /**
3
+ * @ignore
4
+ */
5
+ export function createBooleanColumn(table, { entity }) {
6
+ table.boolean(entity.propertyName);
7
+ }
8
+ ColumnTypesContainer.set("boolean", createBooleanColumn);
9
+ //# sourceMappingURL=createBooleanColumn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBooleanColumn.js","sourceRoot":"","sources":["../../../src/components/createBooleanColumn.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oBAAoB,EAAC,MAAM,kCAAkC,CAAC;AAEtE;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAwB,EAAE,EAAC,MAAM,EAAY;IAC/E,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACrC,CAAC;AAED,oBAAoB,CAAC,GAAG,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import type {Knex} from \"knex\";\nimport {ColumnTypesContainer} from \"../services/ColumnTypesContainer\";\nimport {ColumnCtx} from \"../utils/getColumnCtx\";\n/**\n * @ignore\n */\nexport function createBooleanColumn(table: Knex.TableBuilder, {entity}: ColumnCtx) {\n table.boolean(entity.propertyName);\n}\n\nColumnTypesContainer.set(\"boolean\", createBooleanColumn);\n"]}
@@ -0,0 +1,14 @@
1
+ import { ColumnTypesContainer } from "../services/ColumnTypesContainer";
2
+ /**
3
+ * @ignore
4
+ */
5
+ 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();
11
+ }
12
+ }
13
+ ColumnTypesContainer.set("idColumn", createIdColumn);
14
+ //# sourceMappingURL=createIdColumn.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,9 @@
1
+ import { ColumnTypesContainer } from "../services/ColumnTypesContainer";
2
+ /**
3
+ * @ignore
4
+ */
5
+ export function createNumberColumn(table, { entity, options }) {
6
+ table.decimal(entity.propertyName, options.precision, options.scale);
7
+ }
8
+ ColumnTypesContainer.set("number", createNumberColumn);
9
+ //# sourceMappingURL=createNumberColumn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createNumberColumn.js","sourceRoot":"","sources":["../../../src/components/createNumberColumn.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oBAAoB,EAAC,MAAM,kCAAkC,CAAC;AAGtE;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAwB,EAAE,EAAC,MAAM,EAAE,OAAO,EAAY;IACvF,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAED,oBAAoB,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,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 createNumberColumn(table: Knex.TableBuilder, {entity, options}: ColumnCtx) {\n table.decimal(entity.propertyName, options.precision, options.scale);\n}\n\nColumnTypesContainer.set(\"number\", createNumberColumn);\n"]}
@@ -0,0 +1,9 @@
1
+ import { ColumnTypesContainer } from "../services/ColumnTypesContainer";
2
+ /**
3
+ * @ignore
4
+ */
5
+ export function createStringColumn(table, { entity, schema }) {
6
+ table.string(entity.propertyName, schema.maxLength);
7
+ }
8
+ ColumnTypesContainer.set("string", createStringColumn);
9
+ //# sourceMappingURL=createStringColumn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createStringColumn.js","sourceRoot":"","sources":["../../../src/components/createStringColumn.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oBAAoB,EAAC,MAAM,kCAAkC,CAAC;AAGtE;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAwB,EAAE,EAAC,MAAM,EAAE,MAAM,EAAY;IACtF,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;AACtD,CAAC;AAED,oBAAoB,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,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 createStringColumn(table: Knex.TableBuilder, {entity, schema}: ColumnCtx) {\n table.string(entity.propertyName, schema.maxLength);\n}\n\nColumnTypesContainer.set(\"string\", createStringColumn);\n"]}
@@ -0,0 +1,11 @@
1
+ import { StoreSet } from "@tsed/core";
2
+ /**
3
+ *
4
+ * @param options
5
+ * @decorator
6
+ * @objection
7
+ */
8
+ export function ColumnOptions(options) {
9
+ return StoreSet("objection", options);
10
+ }
11
+ //# sourceMappingURL=columnOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columnOptions.js","sourceRoot":"","sources":["../../../src/decorators/columnOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAGpC;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,OAA4B;IACxD,OAAO,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAQ,CAAC;AAC/C,CAAC","sourcesContent":["import {StoreSet} from \"@tsed/core\";\nimport type {ColumnOpts} from \"../domain/ColumnOpts\";\n\n/**\n *\n * @param options\n * @decorator\n * @objection\n */\nexport function ColumnOptions(options: Partial<ColumnOpts>): PropertyDecorator {\n return StoreSet(\"objection\", options) as any;\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import { StoreSet, useDecorators } from "@tsed/core";
2
+ import { Property } from "@tsed/schema";
3
+ import { ColumnOptions } from "./columnOptions";
4
+ /**
5
+ *
6
+ * @param options
7
+ * @decorator
8
+ * @objection
9
+ */
10
+ export function Decimal(options = {}) {
11
+ return useDecorators(Property(), ColumnOptions({
12
+ columnType: "number",
13
+ options: {
14
+ type: "decimal",
15
+ ...options
16
+ }
17
+ }), StoreSet("objection", {
18
+ columnType: "number",
19
+ options: {
20
+ type: "decimal",
21
+ ...options
22
+ }
23
+ }));
24
+ }
25
+ //# sourceMappingURL=decimal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decimal.js","sourceRoot":"","sources":["../../../src/decorators/decimal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnD,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAO9C;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,UAA0B,EAAE;IAClD,OAAO,aAAa,CAClB,QAAQ,EAAE,EACV,aAAa,CAAC;QACZ,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,GAAG,OAAO;SACX;KACF,CAAC,EACF,QAAQ,CAAC,WAAW,EAAE;QACpB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,GAAG,OAAO;SACX;KACF,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import {StoreSet, useDecorators} from \"@tsed/core\";\nimport {Property} from \"@tsed/schema\";\nimport {ColumnOptions} from \"./columnOptions\";\n\nexport interface DecimalOptions {\n precision?: number | null;\n scale?: number;\n}\n\n/**\n *\n * @param options\n * @decorator\n * @objection\n */\nexport function Decimal(options: DecimalOptions = {}) {\n return useDecorators(\n Property(),\n ColumnOptions({\n columnType: \"number\",\n options: {\n type: \"decimal\",\n ...options\n }\n }),\n StoreSet(\"objection\", {\n columnType: \"number\",\n options: {\n type: \"decimal\",\n ...options\n }\n })\n );\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { getJsonSchema } from "@tsed/schema";
2
+ import { defineStaticGetter } from "../utils/defineStaticGetter";
3
+ /**
4
+ *
5
+ * @param tableName
6
+ * @decorator
7
+ * @objection
8
+ */
9
+ export function Entity(tableName) {
10
+ if (!tableName) {
11
+ throw new Error("Please provide a table name");
12
+ }
13
+ return (target) => {
14
+ defineStaticGetter(target, "tableName", () => tableName);
15
+ defineStaticGetter(target, "jsonSchema", () => getJsonSchema(target));
16
+ return target;
17
+ };
18
+ }
19
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../../src/decorators/entity.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,SAAiB;IACtC,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAED,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACzD,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;QAEtE,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {getJsonSchema} from \"@tsed/schema\";\nimport {defineStaticGetter} from \"../utils/defineStaticGetter\";\n\n/**\n *\n * @param tableName\n * @decorator\n * @objection\n */\nexport function Entity(tableName: string): ClassDecorator {\n if (!tableName) {\n throw new Error(\"Please provide a table name\");\n }\n\n return (target: any) => {\n defineStaticGetter(target, \"tableName\", () => tableName);\n defineStaticGetter(target, \"jsonSchema\", () => getJsonSchema(target));\n\n return target;\n };\n}\n\nexport interface EntityMethods<T> extends Type<T> {\n readonly tableName: string;\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import { useDecorators } from "@tsed/core";
2
+ import { Property } from "@tsed/schema";
3
+ import { defineStaticGetter } from "../utils/defineStaticGetter";
4
+ import { ColumnOptions } from "./columnOptions";
5
+ /**
6
+ *
7
+ * @param type
8
+ * @decorator
9
+ * @objection
10
+ */
11
+ export function IdColumn(type = "increments") {
12
+ return useDecorators(Property(), ColumnOptions({
13
+ columnType: "idColumn",
14
+ options: {
15
+ type
16
+ }
17
+ }), (target, propertyKey) => {
18
+ defineStaticGetter(target, "idColumn", () => propertyKey);
19
+ });
20
+ }
21
+ //# sourceMappingURL=idColumn.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ColumnOpts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColumnOpts.js","sourceRoot":"","sources":["../../../src/domain/ColumnOpts.ts"],"names":[],"mappings":"","sourcesContent":["export interface ColumnOpts {\n columnType: \"idColumn\" | \"string\" | \"number\" | \"boolean\";\n options: any;\n}\n"]}