1 | "use strict";
|
2 | var __assign = (this && this.__assign) || function () {
|
3 | __assign = Object.assign || function(t) {
|
4 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5 | s = arguments[i];
|
6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7 | t[p] = s[p];
|
8 | }
|
9 | return t;
|
10 | };
|
11 | return __assign.apply(this, arguments);
|
12 | };
|
13 | Object.defineProperty(exports, "__esModule", { value: true });
|
14 | exports.EnumField = void 0;
|
15 | var caller = require('caller');
|
16 | var path = require("path");
|
17 | var type_graphql_1 = require("type-graphql");
|
18 | var typeorm_1 = require("typeorm");
|
19 | var metadata_1 = require("../metadata");
|
20 | var utils_1 = require("../utils");
|
21 | function EnumField(name, enumeration, options) {
|
22 | if (options === void 0) { options = {}; }
|
23 |
|
24 | type_graphql_1.registerEnumType(enumeration, { name: name });
|
25 |
|
26 |
|
27 | var decoratorSourceFile = caller();
|
28 |
|
29 | var relativeFilePath = path.relative(utils_1.generatedFolderPath(), decoratorSourceFile);
|
30 | var registerWithWarthog = function (target, propertyKey) {
|
31 | metadata_1.getMetadataStorage().addEnum(target.constructor.name, propertyKey, name, enumeration, relativeFilePath, options);
|
32 | };
|
33 | var factories = [
|
34 | registerWithWarthog,
|
35 | type_graphql_1.Field(function () { return enumeration; }, options),
|
36 | typeorm_1.Column(__assign({ enum: enumeration }, options))
|
37 | ];
|
38 | return utils_1.composeMethodDecorators.apply(void 0, factories);
|
39 | }
|
40 | exports.EnumField = EnumField;
|
41 |
|
\ | No newline at end of file |