@kiwano/core 2.2.0-beta.2 → 3.0.0-beta.2
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/LICENSE +21 -0
- package/dist/index.cjs +2250 -0
- package/dist/index.js +2118 -35
- package/dist/{Builder.d.ts → types/Builder.d.ts} +5 -5
- package/dist/{argument.d.ts → types/argument.d.ts} +3 -3
- package/dist/{common.d.ts → types/common.d.ts} +2 -2
- package/dist/{entity → types/entity}/createInputObjectType.d.ts +3 -3
- package/dist/{entity → types/entity}/entitySchema.d.ts +4 -4
- package/dist/{entity → types/entity}/updateInputObjectType.d.ts +3 -3
- package/dist/{enumType.d.ts → types/enumType.d.ts} +3 -3
- package/dist/{enumValue.d.ts → types/enumValue.d.ts} +3 -3
- package/dist/{field.d.ts → types/field.d.ts} +7 -7
- package/dist/{inputField.d.ts → types/inputField.d.ts} +3 -3
- package/dist/{inputObjectType.d.ts → types/inputObjectType.d.ts} +5 -5
- package/dist/{naming → types/naming}/common.d.ts +1 -2
- package/dist/{naming → types/naming}/compact.d.ts +1 -1
- package/dist/{naming → types/naming}/descriptive.d.ts +1 -1
- package/dist/{objectType.d.ts → types/objectType.d.ts} +4 -4
- package/dist/{plugin → types/plugin}/MultiPlugin.d.ts +14 -14
- package/dist/{plugin → types/plugin}/acl/acl.d.ts +5 -5
- package/dist/{plugin → types/plugin}/acl/middleware.d.ts +4 -4
- package/dist/{plugin → types/plugin}/common.d.ts +13 -13
- package/dist/{plugin → types/plugin}/filter/equals.d.ts +5 -5
- package/dist/{plugin → types/plugin}/filter/search.d.ts +3 -3
- package/dist/{plugin → types/plugin}/pagination/connection.d.ts +3 -3
- package/dist/{plugin → types/plugin}/pagination/firstAfter.d.ts +3 -3
- package/dist/{plugin → types/plugin}/pagination/items.d.ts +3 -3
- package/dist/{plugin → types/plugin}/pagination/offsetLimit.d.ts +3 -3
- package/dist/{plugin → types/plugin}/pagination/simple.d.ts +1 -1
- package/dist/{plugin → types/plugin}/sort/sort.d.ts +5 -5
- package/dist/{schema.d.ts → types/schema.d.ts} +9 -9
- package/dist/{unionType.d.ts → types/unionType.d.ts} +3 -3
- package/dist/{util.d.ts → types/util.d.ts} +4 -4
- package/package.json +43 -34
- package/dist/Builder.js +0 -113
- package/dist/argument.js +0 -100
- package/dist/common.js +0 -2
- package/dist/entity/createInputObjectType.js +0 -55
- package/dist/entity/entitySchema.js +0 -212
- package/dist/entity/index.js +0 -24
- package/dist/entity/updateInputObjectType.js +0 -55
- package/dist/enumType.js +0 -126
- package/dist/enumValue.js +0 -60
- package/dist/error/FrameworkError.js +0 -12
- package/dist/error/index.js +0 -18
- package/dist/error/resolver/DataError.js +0 -11
- package/dist/error/resolver/ForbiddenError.js +0 -11
- package/dist/error/resolver/InvalidInputError.js +0 -11
- package/dist/error/resolver/NotFoundError.js +0 -11
- package/dist/error/resolver/ResolverError.js +0 -11
- package/dist/error/resolver/index.js +0 -21
- package/dist/field.js +0 -193
- package/dist/inputField.js +0 -100
- package/dist/inputObjectType.js +0 -119
- package/dist/naming/common.js +0 -2
- package/dist/naming/compact.js +0 -54
- package/dist/naming/descriptive.js +0 -54
- package/dist/naming/index.js +0 -20
- package/dist/naming/util.js +0 -22
- package/dist/objectType.js +0 -140
- package/dist/plugin/MultiPlugin.js +0 -147
- package/dist/plugin/PluginError.js +0 -11
- package/dist/plugin/acl/acl.js +0 -205
- package/dist/plugin/acl/index.js +0 -18
- package/dist/plugin/acl/middleware.js +0 -48
- package/dist/plugin/common.js +0 -2
- package/dist/plugin/filter/equals.js +0 -124
- package/dist/plugin/filter/index.js +0 -18
- package/dist/plugin/filter/search.js +0 -24
- package/dist/plugin/index.js +0 -23
- package/dist/plugin/pagination/connection.js +0 -115
- package/dist/plugin/pagination/firstAfter.js +0 -19
- package/dist/plugin/pagination/index.js +0 -22
- package/dist/plugin/pagination/items.js +0 -78
- package/dist/plugin/pagination/offsetLimit.js +0 -19
- package/dist/plugin/pagination/relay.js +0 -26
- package/dist/plugin/pagination/simple.js +0 -20
- package/dist/plugin/sort/index.js +0 -22
- package/dist/plugin/sort/sort.js +0 -151
- package/dist/schema.js +0 -380
- package/dist/unionType.js +0 -75
- package/dist/util.js +0 -142
- /package/dist/{entity → types/entity}/index.d.ts +0 -0
- /package/dist/{error → types/error}/FrameworkError.d.ts +0 -0
- /package/dist/{error → types/error}/index.d.ts +0 -0
- /package/dist/{error → types/error}/resolver/DataError.d.ts +0 -0
- /package/dist/{error → types/error}/resolver/ForbiddenError.d.ts +0 -0
- /package/dist/{error → types/error}/resolver/InvalidInputError.d.ts +0 -0
- /package/dist/{error → types/error}/resolver/NotFoundError.d.ts +0 -0
- /package/dist/{error → types/error}/resolver/ResolverError.d.ts +0 -0
- /package/dist/{error → types/error}/resolver/index.d.ts +0 -0
- /package/dist/{index.d.ts → types/index.d.ts} +0 -0
- /package/dist/{naming → types/naming}/index.d.ts +0 -0
- /package/dist/{naming → types/naming}/util.d.ts +0 -0
- /package/dist/{plugin → types/plugin}/PluginError.d.ts +0 -0
- /package/dist/{plugin → types/plugin}/acl/index.d.ts +0 -0
- /package/dist/{plugin → types/plugin}/filter/index.d.ts +0 -0
- /package/dist/{plugin → types/plugin}/index.d.ts +0 -0
- /package/dist/{plugin → types/plugin}/pagination/index.d.ts +0 -0
- /package/dist/{plugin → types/plugin}/pagination/relay.d.ts +0 -0
- /package/dist/{plugin → types/plugin}/sort/index.d.ts +0 -0
package/dist/inputObjectType.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.InputObjectTypeBuilder = void 0;
|
|
37
|
-
exports.inputObjectType = inputObjectType;
|
|
38
|
-
const lodash_1 = require("lodash");
|
|
39
|
-
const graphql_1 = require("graphql");
|
|
40
|
-
const inputField_1 = require("./inputField");
|
|
41
|
-
const Builder_1 = __importStar(require("./Builder"));
|
|
42
|
-
class InputObjectTypeBuilder extends Builder_1.default {
|
|
43
|
-
constructor() {
|
|
44
|
-
super(...arguments);
|
|
45
|
-
this._fields = [];
|
|
46
|
-
this._extensions = new Map();
|
|
47
|
-
}
|
|
48
|
-
description(description) {
|
|
49
|
-
this._description = description;
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
extension(name, value) {
|
|
53
|
-
this._extensions.set(name, value);
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
field(fieldOrName, type = null, configurator = null) {
|
|
57
|
-
let field = null;
|
|
58
|
-
if (fieldOrName instanceof inputField_1.InputFieldBuilder) {
|
|
59
|
-
field = fieldOrName;
|
|
60
|
-
}
|
|
61
|
-
else if ((0, lodash_1.isString)(fieldOrName) && type) {
|
|
62
|
-
field = new inputField_1.InputFieldBuilder(fieldOrName, type);
|
|
63
|
-
if (configurator) {
|
|
64
|
-
configurator(field);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
throw new Builder_1.BuilderError('Invalid input field provided', fieldOrName);
|
|
69
|
-
}
|
|
70
|
-
this._fields.push(field);
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
async finalizeBuilder(context) {
|
|
74
|
-
const info = this.info();
|
|
75
|
-
await this._executePlugins('beforeFinalizeInputObjectType', plugin => plugin.beforeFinalizeInputObjectType(this, context, info));
|
|
76
|
-
await this.finalizeInputObjectType(context, info);
|
|
77
|
-
await this._executePlugins('afterFinalizeInputObjectType', plugin => plugin.afterFinalizeInputObjectType(this, context, info));
|
|
78
|
-
// Add plugins to fields
|
|
79
|
-
for (let field of this._fields) {
|
|
80
|
-
this._plugins.forEach(plugin => field.use(plugin));
|
|
81
|
-
}
|
|
82
|
-
for (let field of this._fields) {
|
|
83
|
-
await field.finalize(context);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async finalizeInputObjectType(context, info) { }
|
|
87
|
-
build(context) {
|
|
88
|
-
const info = this.info();
|
|
89
|
-
this._executePluginsSync('beforeBuildInputObjectType', plugin => plugin.beforeBuildInputObjectType(this, context, info));
|
|
90
|
-
const inputObjectType = new graphql_1.GraphQLInputObjectType({
|
|
91
|
-
name: this.name,
|
|
92
|
-
description: this._description,
|
|
93
|
-
extensions: Object.assign({}, Object.fromEntries(this._extensions)),
|
|
94
|
-
fields: () => {
|
|
95
|
-
let builtFields = {};
|
|
96
|
-
for (let field of this._fields) {
|
|
97
|
-
builtFields[field.name] = field.build(context);
|
|
98
|
-
}
|
|
99
|
-
return builtFields;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
this._executePluginsSync('afterBuildInputObjectType', plugin => plugin.afterBuildInputObjectType(this, context, info, inputObjectType));
|
|
103
|
-
return inputObjectType;
|
|
104
|
-
}
|
|
105
|
-
info() {
|
|
106
|
-
return {
|
|
107
|
-
name: this.name,
|
|
108
|
-
description: this._description,
|
|
109
|
-
fields: (0, lodash_1.clone)(this._fields),
|
|
110
|
-
extensions: new Map(this._extensions),
|
|
111
|
-
plugins: (0, lodash_1.clone)(this._plugins)
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
exports.InputObjectTypeBuilder = InputObjectTypeBuilder;
|
|
116
|
-
function inputObjectType(name) {
|
|
117
|
-
return new InputObjectTypeBuilder(name);
|
|
118
|
-
}
|
|
119
|
-
exports.default = inputObjectType;
|
package/dist/naming/common.js
DELETED
package/dist/naming/compact.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CompactNamingStrategy = void 0;
|
|
4
|
-
exports.compactNamingStrategy = compactNamingStrategy;
|
|
5
|
-
const util_1 = require("./util");
|
|
6
|
-
class CompactNamingStrategy {
|
|
7
|
-
entityObject(schemaName) {
|
|
8
|
-
return (0, util_1.ucFirst)(schemaName);
|
|
9
|
-
}
|
|
10
|
-
allField(schemaName) {
|
|
11
|
-
return (0, util_1.pluralize)((0, util_1.lcFirst)(schemaName));
|
|
12
|
-
}
|
|
13
|
-
findField(schemaName) {
|
|
14
|
-
return (0, util_1.lcFirst)(schemaName);
|
|
15
|
-
}
|
|
16
|
-
createField(schemaName) {
|
|
17
|
-
return `create${(0, util_1.ucFirst)(schemaName)}`;
|
|
18
|
-
}
|
|
19
|
-
updateField(schemaName) {
|
|
20
|
-
return `update${(0, util_1.ucFirst)(schemaName)}`;
|
|
21
|
-
}
|
|
22
|
-
deleteField(schemaName) {
|
|
23
|
-
return `delete${(0, util_1.ucFirst)(schemaName)}`;
|
|
24
|
-
}
|
|
25
|
-
restoreField(schemaName) {
|
|
26
|
-
return `restore${(0, util_1.ucFirst)(schemaName)}`;
|
|
27
|
-
}
|
|
28
|
-
findFieldIdArgument(schemaName) {
|
|
29
|
-
return 'id';
|
|
30
|
-
}
|
|
31
|
-
deleteFieldIdArgument(schemaName) {
|
|
32
|
-
return 'id';
|
|
33
|
-
}
|
|
34
|
-
restoreFieldIdArgument(schemaName) {
|
|
35
|
-
return 'id';
|
|
36
|
-
}
|
|
37
|
-
createInputObject(schemaName) {
|
|
38
|
-
return `Create${(0, util_1.ucFirst)(schemaName)}Input`;
|
|
39
|
-
}
|
|
40
|
-
createFieldInputArgument(schemaName) {
|
|
41
|
-
return 'input';
|
|
42
|
-
}
|
|
43
|
-
updateInputObject(schemaName) {
|
|
44
|
-
return `Update${(0, util_1.ucFirst)(schemaName)}Input`;
|
|
45
|
-
}
|
|
46
|
-
updateFieldInputArgument(schemaName) {
|
|
47
|
-
return 'input';
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.CompactNamingStrategy = CompactNamingStrategy;
|
|
51
|
-
function compactNamingStrategy() {
|
|
52
|
-
return new CompactNamingStrategy();
|
|
53
|
-
}
|
|
54
|
-
exports.default = compactNamingStrategy;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DescriptiveNamingStrategy = void 0;
|
|
4
|
-
exports.descriptiveNamingStrategy = descriptiveNamingStrategy;
|
|
5
|
-
const util_1 = require("./util");
|
|
6
|
-
class DescriptiveNamingStrategy {
|
|
7
|
-
entityObject(schemaName) {
|
|
8
|
-
return (0, util_1.ucFirst)(schemaName);
|
|
9
|
-
}
|
|
10
|
-
allField(schemaName) {
|
|
11
|
-
return `all${(0, util_1.pluralize)((0, util_1.ucFirst)(schemaName))}`;
|
|
12
|
-
}
|
|
13
|
-
findField(schemaName) {
|
|
14
|
-
return `find${(0, util_1.ucFirst)(schemaName)}`;
|
|
15
|
-
}
|
|
16
|
-
createField(schemaName) {
|
|
17
|
-
return `create${(0, util_1.ucFirst)(schemaName)}`;
|
|
18
|
-
}
|
|
19
|
-
updateField(schemaName) {
|
|
20
|
-
return `update${(0, util_1.ucFirst)(schemaName)}`;
|
|
21
|
-
}
|
|
22
|
-
deleteField(schemaName) {
|
|
23
|
-
return `delete${(0, util_1.ucFirst)(schemaName)}`;
|
|
24
|
-
}
|
|
25
|
-
restoreField(schemaName) {
|
|
26
|
-
return `restore${(0, util_1.ucFirst)(schemaName)}`;
|
|
27
|
-
}
|
|
28
|
-
findFieldIdArgument(schemaName) {
|
|
29
|
-
return 'id';
|
|
30
|
-
}
|
|
31
|
-
deleteFieldIdArgument(schemaName) {
|
|
32
|
-
return 'id';
|
|
33
|
-
}
|
|
34
|
-
restoreFieldIdArgument(schemaName) {
|
|
35
|
-
return 'id';
|
|
36
|
-
}
|
|
37
|
-
createInputObject(schemaName) {
|
|
38
|
-
return `Create${(0, util_1.ucFirst)(schemaName)}Input`;
|
|
39
|
-
}
|
|
40
|
-
createFieldInputArgument(schemaName) {
|
|
41
|
-
return 'input';
|
|
42
|
-
}
|
|
43
|
-
updateInputObject(schemaName) {
|
|
44
|
-
return `Update${(0, util_1.ucFirst)(schemaName)}Input`;
|
|
45
|
-
}
|
|
46
|
-
updateFieldInputArgument(schemaName) {
|
|
47
|
-
return 'input';
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.DescriptiveNamingStrategy = DescriptiveNamingStrategy;
|
|
51
|
-
function descriptiveNamingStrategy() {
|
|
52
|
-
return new DescriptiveNamingStrategy();
|
|
53
|
-
}
|
|
54
|
-
exports.default = descriptiveNamingStrategy;
|
package/dist/naming/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./compact"), exports);
|
|
18
|
-
__exportStar(require("./descriptive"), exports);
|
|
19
|
-
__exportStar(require("./util"), exports);
|
|
20
|
-
__exportStar(require("./common"), exports);
|
package/dist/naming/util.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.pluralize = void 0;
|
|
7
|
-
exports.ucFirst = ucFirst;
|
|
8
|
-
exports.lcFirst = lcFirst;
|
|
9
|
-
const pluralize_1 = __importDefault(require("pluralize"));
|
|
10
|
-
exports.pluralize = pluralize_1.default;
|
|
11
|
-
function ucFirst(input) {
|
|
12
|
-
if (input === null || input.length === 0) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
return input.charAt(0).toUpperCase() + input.slice(1);
|
|
16
|
-
}
|
|
17
|
-
function lcFirst(input) {
|
|
18
|
-
if (input === null || input.length === 0) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return input.charAt(0).toLowerCase() + input.slice(1);
|
|
22
|
-
}
|
package/dist/objectType.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ObjectTypeBuilder = void 0;
|
|
37
|
-
exports.objectType = objectType;
|
|
38
|
-
const lodash_1 = require("lodash");
|
|
39
|
-
const graphql_1 = require("graphql");
|
|
40
|
-
const field_1 = require("./field");
|
|
41
|
-
const Builder_1 = __importStar(require("./Builder"));
|
|
42
|
-
const util_1 = require("./util");
|
|
43
|
-
class ObjectTypeBuilder extends Builder_1.default {
|
|
44
|
-
constructor() {
|
|
45
|
-
super(...arguments);
|
|
46
|
-
this._fields = [];
|
|
47
|
-
this._extensions = new Map();
|
|
48
|
-
this._allowedRoles = new Set();
|
|
49
|
-
this._deniedRoles = new Set();
|
|
50
|
-
}
|
|
51
|
-
description(description) {
|
|
52
|
-
this._description = description;
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
extension(name, value) {
|
|
56
|
-
this._extensions.set(name, value);
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
resolvers(resolvers) {
|
|
60
|
-
this._resolvers = resolvers;
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
getResolvers() {
|
|
64
|
-
return this._resolvers;
|
|
65
|
-
}
|
|
66
|
-
field(fieldOrName, type = null, configurator = null) {
|
|
67
|
-
let field = null;
|
|
68
|
-
if (fieldOrName instanceof field_1.FieldBuilder) {
|
|
69
|
-
field = fieldOrName;
|
|
70
|
-
}
|
|
71
|
-
else if ((0, lodash_1.isString)(fieldOrName) && type) {
|
|
72
|
-
field = new field_1.FieldBuilder(fieldOrName, type);
|
|
73
|
-
if (configurator) {
|
|
74
|
-
configurator(field);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
throw new Builder_1.BuilderError('Invalid field provided', fieldOrName);
|
|
79
|
-
}
|
|
80
|
-
this._fields.push(field);
|
|
81
|
-
return this;
|
|
82
|
-
}
|
|
83
|
-
allow(...roles) {
|
|
84
|
-
roles.forEach(role => this._allowedRoles.add(role));
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
deny(...roles) {
|
|
88
|
-
roles.forEach(role => this._deniedRoles.add(role));
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
|
-
async finalizeBuilder(context) {
|
|
92
|
-
const info = this.info();
|
|
93
|
-
await this._executePlugins('beforeFinalizeObjectType', plugin => plugin.beforeFinalizeObjectType(this, context, info));
|
|
94
|
-
await this.finalizeObjectType(context, info);
|
|
95
|
-
await this._executePlugins('afterFinalizeObjectType', plugin => plugin.afterFinalizeObjectType(this, context, info));
|
|
96
|
-
// Add plugins to fields
|
|
97
|
-
for (let field of this._fields) {
|
|
98
|
-
this._plugins.forEach(plugin => field.use(plugin));
|
|
99
|
-
}
|
|
100
|
-
for (let field of this._fields) {
|
|
101
|
-
await field.finalize(context);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
async finalizeObjectType(context, info) { }
|
|
105
|
-
build(context) {
|
|
106
|
-
const info = this.info();
|
|
107
|
-
this._executePluginsSync('beforeBuildObjectType', plugin => plugin.beforeBuildObjectType(this, context, info));
|
|
108
|
-
const objectType = new graphql_1.GraphQLObjectType({
|
|
109
|
-
name: this.name,
|
|
110
|
-
description: this._description,
|
|
111
|
-
extensions: Object.assign(Object.assign({}, (0, util_1.getAclExtension)(this._allowedRoles, this._deniedRoles)), Object.fromEntries(this._extensions)),
|
|
112
|
-
fields: () => {
|
|
113
|
-
let builtFields = {};
|
|
114
|
-
for (let field of this._fields) {
|
|
115
|
-
builtFields[field.name] = field.build(context, this);
|
|
116
|
-
}
|
|
117
|
-
return builtFields;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
this._executePluginsSync('afterBuildObjectType', plugin => plugin.afterBuildObjectType(this, context, info, objectType));
|
|
121
|
-
return objectType;
|
|
122
|
-
}
|
|
123
|
-
info() {
|
|
124
|
-
return {
|
|
125
|
-
name: this.name,
|
|
126
|
-
description: this._description,
|
|
127
|
-
fields: (0, lodash_1.clone)(this._fields),
|
|
128
|
-
extensions: new Map(this._extensions),
|
|
129
|
-
allowedRoles: new Set(this._allowedRoles),
|
|
130
|
-
deniedRoles: new Set(this._deniedRoles),
|
|
131
|
-
resolvers: this._resolvers,
|
|
132
|
-
plugins: (0, lodash_1.clone)(this._plugins)
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
exports.ObjectTypeBuilder = ObjectTypeBuilder;
|
|
137
|
-
function objectType(name) {
|
|
138
|
-
return new ObjectTypeBuilder(name);
|
|
139
|
-
}
|
|
140
|
-
exports.default = objectType;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MultiPlugin = void 0;
|
|
4
|
-
class MultiPlugin {
|
|
5
|
-
constructor(plugins = null) {
|
|
6
|
-
this._plugins = plugins || this.getPlugins();
|
|
7
|
-
}
|
|
8
|
-
getPlugins() {
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
async execute(methodName, fn) {
|
|
12
|
-
let results = [];
|
|
13
|
-
for (let plugin of this._plugins) {
|
|
14
|
-
if (plugin[methodName]) {
|
|
15
|
-
const result = await fn(plugin);
|
|
16
|
-
results.push(result);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return results;
|
|
20
|
-
}
|
|
21
|
-
executeSync(methodName, fn) {
|
|
22
|
-
let results = [];
|
|
23
|
-
for (let plugin of this._plugins) {
|
|
24
|
-
if (plugin[methodName]) {
|
|
25
|
-
const result = fn(plugin);
|
|
26
|
-
results.push(result);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return results;
|
|
30
|
-
}
|
|
31
|
-
async beforeFinalizeSchema(builder) {
|
|
32
|
-
await this.execute('beforeFinalizeSchema', plugin => plugin.beforeFinalizeSchema(builder));
|
|
33
|
-
}
|
|
34
|
-
async afterFinalizeSchema(builder) {
|
|
35
|
-
await this.execute('afterFinalizeSchema', plugin => plugin.afterFinalizeSchema(builder));
|
|
36
|
-
}
|
|
37
|
-
async beforeFinalizeObjectType(builder, context, info) {
|
|
38
|
-
await this.execute('beforeFinalizeObjectType', plugin => plugin.beforeFinalizeObjectType(builder, context, info));
|
|
39
|
-
}
|
|
40
|
-
async afterFinalizeObjectType(builder, context, info) {
|
|
41
|
-
await this.execute('afterFinalizeObjectType', plugin => plugin.afterFinalizeObjectType(builder, context, info));
|
|
42
|
-
}
|
|
43
|
-
async beforeFinalizeInputObjectType(builder, context, info) {
|
|
44
|
-
await this.execute('beforeFinalizeInputObjectType', plugin => plugin.beforeFinalizeInputObjectType(builder, context, info));
|
|
45
|
-
}
|
|
46
|
-
async afterFinalizeInputObjectType(builder, context, info) {
|
|
47
|
-
await this.execute('afterFinalizeInputObjectType', plugin => plugin.afterFinalizeInputObjectType(builder, context, info));
|
|
48
|
-
}
|
|
49
|
-
async beforeFinalizeEnumType(builder, context, info) {
|
|
50
|
-
await this.execute('beforeFinalizeEnumType', plugin => plugin.beforeFinalizeEnumType(builder, context, info));
|
|
51
|
-
}
|
|
52
|
-
async afterFinalizeEnumType(builder, context, info) {
|
|
53
|
-
await this.execute('afterFinalizeEnumType', plugin => plugin.afterFinalizeEnumType(builder, context, info));
|
|
54
|
-
}
|
|
55
|
-
async beforeFinalizeEnumValue(builder, context, info) {
|
|
56
|
-
await this.execute('beforeFinalizeEnumValue', plugin => plugin.beforeFinalizeEnumValue(builder, context, info));
|
|
57
|
-
}
|
|
58
|
-
async afterFinalizeEnumValue(builder, context, info) {
|
|
59
|
-
await this.execute('afterFinalizeEnumValue', plugin => plugin.afterFinalizeEnumValue(builder, context, info));
|
|
60
|
-
}
|
|
61
|
-
async beforeFinalizeUnionType(builder, context, info) {
|
|
62
|
-
await this.execute('beforeFinalizeUnionType', plugin => plugin.beforeFinalizeUnionType(builder, context, info));
|
|
63
|
-
}
|
|
64
|
-
async afterFinalizeUnionType(builder, context, info) {
|
|
65
|
-
await this.execute('afterFinalizeUnionType', plugin => plugin.afterFinalizeUnionType(builder, context, info));
|
|
66
|
-
}
|
|
67
|
-
async beforeFinalizeField(builder, context, info) {
|
|
68
|
-
await this.execute('beforeFinalizeField', plugin => plugin.beforeFinalizeField(builder, context, info));
|
|
69
|
-
}
|
|
70
|
-
async afterFinalizeField(builder, context, info) {
|
|
71
|
-
await this.execute('afterFinalizeField', plugin => plugin.afterFinalizeField(builder, context, info));
|
|
72
|
-
}
|
|
73
|
-
async beforeFinalizeInputField(builder, context, info) {
|
|
74
|
-
await this.execute('beforeFinalizeInputField', plugin => plugin.beforeFinalizeInputField(builder, context, info));
|
|
75
|
-
}
|
|
76
|
-
async afterFinalizeInputField(builder, context, info) {
|
|
77
|
-
await this.execute('afterFinalizeInputField', plugin => plugin.afterFinalizeInputField(builder, context, info));
|
|
78
|
-
}
|
|
79
|
-
async beforeFinalizeArgument(builder, context, info) {
|
|
80
|
-
await this.execute('beforeFinalizeArgument', plugin => plugin.beforeFinalizeArgument(builder, context, info));
|
|
81
|
-
}
|
|
82
|
-
async afterFinalizeArgument(builder, context, info) {
|
|
83
|
-
await this.execute('afterFinalizeArgument', plugin => plugin.afterFinalizeArgument(builder, context, info));
|
|
84
|
-
}
|
|
85
|
-
beforeBuild(rootBuilder) {
|
|
86
|
-
this.executeSync('beforeBuild', plugin => plugin.beforeBuild(rootBuilder));
|
|
87
|
-
}
|
|
88
|
-
afterBuild(rootBuilder, schema) {
|
|
89
|
-
this.executeSync('afterBuild', plugin => plugin.afterBuild(rootBuilder, schema));
|
|
90
|
-
}
|
|
91
|
-
beforeBuildSchema(builder, rootBuilder) {
|
|
92
|
-
this.executeSync('beforeBuildSchema', plugin => plugin.beforeBuildSchema(builder, rootBuilder));
|
|
93
|
-
}
|
|
94
|
-
afterBuildSchema(builder, schema, rootBuilder) {
|
|
95
|
-
this.executeSync('afterBuildSchema', plugin => plugin.afterBuildSchema(builder, schema, rootBuilder));
|
|
96
|
-
}
|
|
97
|
-
beforeBuildObjectType(builder, context, info) {
|
|
98
|
-
this.executeSync('beforeBuildObjectType', plugin => plugin.beforeBuildObjectType(builder, context, info));
|
|
99
|
-
}
|
|
100
|
-
afterBuildObjectType(builder, context, info, objectType) {
|
|
101
|
-
this.executeSync('afterBuildObjectType', plugin => plugin.afterBuildObjectType(builder, context, info, objectType));
|
|
102
|
-
}
|
|
103
|
-
beforeBuildInputObjectType(builder, context, info) {
|
|
104
|
-
this.executeSync('beforeBuildInputObjectType', plugin => plugin.beforeBuildInputObjectType(builder, context, info));
|
|
105
|
-
}
|
|
106
|
-
afterBuildInputObjectType(builder, context, info, inputObjectType) {
|
|
107
|
-
this.executeSync('afterBuildInputObjectType', plugin => plugin.afterBuildInputObjectType(builder, context, info, inputObjectType));
|
|
108
|
-
}
|
|
109
|
-
beforeBuildEnumType(builder, context, info) {
|
|
110
|
-
this.executeSync('beforeBuildEnumType', plugin => plugin.beforeBuildEnumType(builder, context, info));
|
|
111
|
-
}
|
|
112
|
-
afterBuildEnumType(builder, context, info, enumType) {
|
|
113
|
-
this.executeSync('afterBuildEnumType', plugin => plugin.afterBuildEnumType(builder, context, info, enumType));
|
|
114
|
-
}
|
|
115
|
-
beforeBuildEnumValue(builder, context, info) {
|
|
116
|
-
this.executeSync('beforeBuildEnumValue', plugin => plugin.beforeBuildEnumValue(builder, context, info));
|
|
117
|
-
}
|
|
118
|
-
afterBuildEnumValue(builder, context, info, enumValue) {
|
|
119
|
-
this.executeSync('afterBuildEnumValue', plugin => plugin.afterBuildEnumValue(builder, context, info, enumValue));
|
|
120
|
-
}
|
|
121
|
-
beforeBuildUnionType(builder, context, info) {
|
|
122
|
-
this.executeSync('beforeBuildUnionType', plugin => plugin.beforeBuildUnionType(builder, context, info));
|
|
123
|
-
}
|
|
124
|
-
afterBuildUnionType(builder, context, info, unionType) {
|
|
125
|
-
this.executeSync('afterBuildUnionType', plugin => plugin.afterBuildUnionType(builder, context, info, unionType));
|
|
126
|
-
}
|
|
127
|
-
beforeBuildField(builder, context, info) {
|
|
128
|
-
this.executeSync('beforeBuildField', plugin => plugin.beforeBuildField(builder, context, info));
|
|
129
|
-
}
|
|
130
|
-
afterBuildField(builder, context, info, field) {
|
|
131
|
-
this.executeSync('afterBuildField', plugin => plugin.afterBuildField(builder, context, info, field));
|
|
132
|
-
}
|
|
133
|
-
beforeBuildInputField(builder, context, info) {
|
|
134
|
-
this.executeSync('beforeBuildInputField', plugin => plugin.beforeBuildInputField(builder, context, info));
|
|
135
|
-
}
|
|
136
|
-
afterBuildInputField(builder, context, info, inputField) {
|
|
137
|
-
this.executeSync('afterBuildInputField', plugin => plugin.afterBuildInputField(builder, context, info, inputField));
|
|
138
|
-
}
|
|
139
|
-
beforeBuildArgument(builder, context, info) {
|
|
140
|
-
this.executeSync('beforeBuildArgument', plugin => plugin.beforeBuildArgument(builder, context, info));
|
|
141
|
-
}
|
|
142
|
-
afterBuildArgument(builder, context, info, argument) {
|
|
143
|
-
this.executeSync('afterBuildArgument', plugin => plugin.afterBuildArgument(builder, context, info, argument));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
exports.MultiPlugin = MultiPlugin;
|
|
147
|
-
exports.default = MultiPlugin;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PluginError = void 0;
|
|
7
|
-
const FrameworkError_1 = __importDefault(require("../error/FrameworkError"));
|
|
8
|
-
class PluginError extends FrameworkError_1.default {
|
|
9
|
-
}
|
|
10
|
-
exports.PluginError = PluginError;
|
|
11
|
-
exports.default = PluginError;
|