@webiny/handler-graphql 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d
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/ResolverDecoration.d.ts +6 -0
- package/ResolverDecoration.js +26 -0
- package/ResolverDecoration.js.map +1 -0
- package/builtInTypes/AnyScalar.js +3 -5
- package/builtInTypes/AnyScalar.js.map +1 -1
- package/builtInTypes/DateScalar.js +5 -12
- package/builtInTypes/DateScalar.js.map +1 -1
- package/builtInTypes/DateTimeScalar.js +5 -12
- package/builtInTypes/DateTimeScalar.js.map +1 -1
- package/builtInTypes/DateTimeZScalar.js +3 -15
- package/builtInTypes/DateTimeZScalar.js.map +1 -1
- package/builtInTypes/JsonScalar.js +2 -3
- package/builtInTypes/JsonScalar.js.map +1 -1
- package/builtInTypes/LongScalar.d.ts +2 -1
- package/builtInTypes/LongScalar.js +49 -4
- package/builtInTypes/LongScalar.js.map +1 -1
- package/builtInTypes/NumberScalar.js +6 -15
- package/builtInTypes/NumberScalar.js.map +1 -1
- package/builtInTypes/RefInputScalar.d.ts +1 -1
- package/builtInTypes/RefInputScalar.js +34 -23
- package/builtInTypes/RefInputScalar.js.map +1 -1
- package/builtInTypes/TimeScalar.js +3 -14
- package/builtInTypes/TimeScalar.js.map +1 -1
- package/builtInTypes/index.js +3 -19
- package/builtInTypes/index.js.map +1 -1
- package/createGraphQLHandler.d.ts +3 -3
- package/createGraphQLHandler.js +72 -22
- package/createGraphQLHandler.js.map +1 -1
- package/createGraphQLSchema.d.ts +3 -1
- package/createGraphQLSchema.js +55 -30
- package/createGraphQLSchema.js.map +1 -1
- package/createResolverDecorator.d.ts +2 -0
- package/createResolverDecorator.js +12 -0
- package/createResolverDecorator.js.map +1 -0
- package/debugPlugins.d.ts +2 -2
- package/debugPlugins.js +2 -9
- package/debugPlugins.js.map +1 -1
- package/errors.js +2 -5
- package/errors.js.map +1 -1
- package/index.d.ts +7 -2
- package/index.js +53 -11
- package/index.js.map +1 -1
- package/interceptConsole.js +9 -13
- package/interceptConsole.js.map +1 -1
- package/package.json +19 -21
- package/plugins/GraphQLSchemaPlugin.d.ts +13 -5
- package/plugins/GraphQLSchemaPlugin.js +16 -13
- package/plugins/GraphQLSchemaPlugin.js.map +1 -1
- package/plugins/index.js +3 -3
- package/plugins/index.js.map +1 -1
- package/processRequestBody.d.ts +4 -5
- package/processRequestBody.js +20 -17
- package/processRequestBody.js.map +1 -1
- package/responses.js +6 -36
- package/responses.js.map +1 -1
- package/types.d.ts +17 -10
- package/types.js +3 -1
- package/types.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +18 -0
- package/utils/index.js.map +1 -0
- package/utils/resolve.d.ts +21 -0
- package/utils/resolve.js +28 -0
- package/utils/resolve.js.map +1 -0
package/index.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
var _exportNames = {};
|
|
9
8
|
exports.default = void 0;
|
|
10
|
-
|
|
11
9
|
var _createGraphQLHandler = _interopRequireDefault(require("./createGraphQLHandler"));
|
|
12
|
-
|
|
13
10
|
var _errors = require("./errors");
|
|
14
|
-
|
|
15
11
|
Object.keys(_errors).forEach(function (key) {
|
|
16
12
|
if (key === "default" || key === "__esModule") return;
|
|
17
13
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -23,9 +19,7 @@ Object.keys(_errors).forEach(function (key) {
|
|
|
23
19
|
}
|
|
24
20
|
});
|
|
25
21
|
});
|
|
26
|
-
|
|
27
22
|
var _responses = require("./responses");
|
|
28
|
-
|
|
29
23
|
Object.keys(_responses).forEach(function (key) {
|
|
30
24
|
if (key === "default" || key === "__esModule") return;
|
|
31
25
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -37,9 +31,19 @@ Object.keys(_responses).forEach(function (key) {
|
|
|
37
31
|
}
|
|
38
32
|
});
|
|
39
33
|
});
|
|
40
|
-
|
|
34
|
+
var _utils = require("./utils");
|
|
35
|
+
Object.keys(_utils).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
38
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
39
|
+
Object.defineProperty(exports, key, {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () {
|
|
42
|
+
return _utils[key];
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
41
46
|
var _plugins = require("./plugins");
|
|
42
|
-
|
|
43
47
|
Object.keys(_plugins).forEach(function (key) {
|
|
44
48
|
if (key === "default" || key === "__esModule") return;
|
|
45
49
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -51,7 +55,45 @@ Object.keys(_plugins).forEach(function (key) {
|
|
|
51
55
|
}
|
|
52
56
|
});
|
|
53
57
|
});
|
|
58
|
+
var _processRequestBody = require("./processRequestBody");
|
|
59
|
+
Object.keys(_processRequestBody).forEach(function (key) {
|
|
60
|
+
if (key === "default" || key === "__esModule") return;
|
|
61
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
62
|
+
if (key in exports && exports[key] === _processRequestBody[key]) return;
|
|
63
|
+
Object.defineProperty(exports, key, {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () {
|
|
66
|
+
return _processRequestBody[key];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
var _createResolverDecorator = require("./createResolverDecorator");
|
|
71
|
+
Object.keys(_createResolverDecorator).forEach(function (key) {
|
|
72
|
+
if (key === "default" || key === "__esModule") return;
|
|
73
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
74
|
+
if (key in exports && exports[key] === _createResolverDecorator[key]) return;
|
|
75
|
+
Object.defineProperty(exports, key, {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function () {
|
|
78
|
+
return _createResolverDecorator[key];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
var _ResolverDecoration = require("./ResolverDecoration");
|
|
83
|
+
Object.keys(_ResolverDecoration).forEach(function (key) {
|
|
84
|
+
if (key === "default" || key === "__esModule") return;
|
|
85
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
86
|
+
if (key in exports && exports[key] === _ResolverDecoration[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _ResolverDecoration[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _default = (options = {}) => {
|
|
95
|
+
return (0, _createGraphQLHandler.default)(options);
|
|
96
|
+
};
|
|
97
|
+
exports.default = _default;
|
|
54
98
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
exports.default = _default;
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["options","createGraphQLHandler"],"sources":["index.ts"],"sourcesContent":["import { HandlerGraphQLOptions } from \"./types\";\nimport createGraphQLHandler from \"./createGraphQLHandler\";\n\nexport * from \"./errors\";\nexport * from \"./responses\";\nexport * from \"./plugins\";\n\nexport default (options: HandlerGraphQLOptions = {}) =>
|
|
1
|
+
{"version":3,"names":["_createGraphQLHandler","_interopRequireDefault","require","_errors","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_responses","_utils","_plugins","_processRequestBody","_createResolverDecorator","_ResolverDecoration","_default","options","createGraphQLHandler","default"],"sources":["index.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types\";\nimport type { HandlerGraphQLOptions } from \"./types\";\nimport createGraphQLHandler from \"./createGraphQLHandler\";\n\nexport * from \"./errors\";\nexport * from \"./responses\";\nexport * from \"./utils\";\nexport * from \"./plugins\";\nexport * from \"./processRequestBody\";\nexport * from \"./createResolverDecorator\";\nexport * from \"./ResolverDecoration\";\n\nexport default (options: HandlerGraphQLOptions = {}): Plugin[] => {\n return createGraphQLHandler(options);\n};\n"],"mappings":";;;;;;;;AAEA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,UAAA,GAAAd,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAW,UAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,UAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAT,GAAA;IAA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HANGED
|
@@ -7,37 +7,33 @@ exports.interceptConsole = void 0;
|
|
|
7
7
|
const consoleMethods = ["assert", "debug", "dir", "error", "group", "groupCollapsed", "groupEnd", "info", "log", "table", "warn"];
|
|
8
8
|
const originalMethods = {};
|
|
9
9
|
const skipOriginal = ["table"];
|
|
10
|
-
|
|
11
10
|
const restoreOriginalMethods = () => {
|
|
12
11
|
for (const method of consoleMethods) {
|
|
13
|
-
// @ts-
|
|
12
|
+
// @ts-expect-error
|
|
14
13
|
console[method] = originalMethods[method];
|
|
15
14
|
}
|
|
16
15
|
};
|
|
17
|
-
|
|
18
16
|
const interceptConsole = callback => {
|
|
19
|
-
// @ts-
|
|
17
|
+
// @ts-expect-error
|
|
20
18
|
if (console["__WEBINY__"] === true) {
|
|
21
19
|
restoreOriginalMethods();
|
|
22
|
-
}
|
|
23
|
-
|
|
20
|
+
}
|
|
24
21
|
|
|
22
|
+
// @ts-expect-error
|
|
25
23
|
console["__WEBINY__"] = true;
|
|
26
|
-
|
|
27
24
|
for (const method of consoleMethods) {
|
|
28
|
-
// @ts-
|
|
29
|
-
originalMethods[method] = console[method];
|
|
30
|
-
|
|
25
|
+
// @ts-expect-error
|
|
26
|
+
originalMethods[method] = console[method];
|
|
27
|
+
// @ts-expect-error
|
|
31
28
|
console[method] = (...args) => {
|
|
32
29
|
callback(method, args);
|
|
33
|
-
|
|
34
30
|
if (skipOriginal.includes(method)) {
|
|
35
31
|
return;
|
|
36
32
|
}
|
|
37
|
-
|
|
38
33
|
originalMethods[method](...args);
|
|
39
34
|
};
|
|
40
35
|
}
|
|
41
36
|
};
|
|
37
|
+
exports.interceptConsole = interceptConsole;
|
|
42
38
|
|
|
43
|
-
|
|
39
|
+
//# sourceMappingURL=interceptConsole.js.map
|
package/interceptConsole.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["consoleMethods","originalMethods","skipOriginal","restoreOriginalMethods","method","console","interceptConsole","callback","args","includes"],"sources":["interceptConsole.ts"],"sourcesContent":["const consoleMethods = [\n \"assert\",\n \"debug\",\n \"dir\",\n \"error\",\n \"group\",\n \"groupCollapsed\",\n \"groupEnd\",\n \"info\",\n \"log\",\n \"table\",\n \"warn\"\n];\n\nconst originalMethods: Record<string, any> = {};\nconst skipOriginal: string[] = [\"table\"];\n\nconst restoreOriginalMethods = () => {\n for (const method of consoleMethods) {\n // @ts-
|
|
1
|
+
{"version":3,"names":["consoleMethods","originalMethods","skipOriginal","restoreOriginalMethods","method","console","interceptConsole","callback","args","includes","exports"],"sources":["interceptConsole.ts"],"sourcesContent":["const consoleMethods = [\n \"assert\",\n \"debug\",\n \"dir\",\n \"error\",\n \"group\",\n \"groupCollapsed\",\n \"groupEnd\",\n \"info\",\n \"log\",\n \"table\",\n \"warn\"\n];\n\nconst originalMethods: Record<string, any> = {};\nconst skipOriginal: string[] = [\"table\"];\n\nconst restoreOriginalMethods = () => {\n for (const method of consoleMethods) {\n // @ts-expect-error\n console[method] = originalMethods[method];\n }\n};\n\ninterface InterceptConsoleCallable {\n (method: string, args: any[]): void;\n}\n\nexport const interceptConsole = (callback: InterceptConsoleCallable) => {\n // @ts-expect-error\n if (console[\"__WEBINY__\"] === true) {\n restoreOriginalMethods();\n }\n\n // @ts-expect-error\n console[\"__WEBINY__\"] = true;\n\n for (const method of consoleMethods) {\n // @ts-expect-error\n originalMethods[method] = console[method];\n // @ts-expect-error\n console[method] = (...args) => {\n callback(method, args);\n if (skipOriginal.includes(method)) {\n return;\n }\n originalMethods[method](...args);\n };\n }\n};\n"],"mappings":";;;;;;AAAA,MAAMA,cAAc,GAAG,CACnB,QAAQ,EACR,OAAO,EACP,KAAK,EACL,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM,CACT;AAED,MAAMC,eAAoC,GAAG,CAAC,CAAC;AAC/C,MAAMC,YAAsB,GAAG,CAAC,OAAO,CAAC;AAExC,MAAMC,sBAAsB,GAAGA,CAAA,KAAM;EACjC,KAAK,MAAMC,MAAM,IAAIJ,cAAc,EAAE;IACjC;IACAK,OAAO,CAACD,MAAM,CAAC,GAAGH,eAAe,CAACG,MAAM,CAAC;EAC7C;AACJ,CAAC;AAMM,MAAME,gBAAgB,GAAIC,QAAkC,IAAK;EACpE;EACA,IAAIF,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,EAAE;IAChCF,sBAAsB,CAAC,CAAC;EAC5B;;EAEA;EACAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;EAE5B,KAAK,MAAMD,MAAM,IAAIJ,cAAc,EAAE;IACjC;IACAC,eAAe,CAACG,MAAM,CAAC,GAAGC,OAAO,CAACD,MAAM,CAAC;IACzC;IACAC,OAAO,CAACD,MAAM,CAAC,GAAG,CAAC,GAAGI,IAAI,KAAK;MAC3BD,QAAQ,CAACH,MAAM,EAAEI,IAAI,CAAC;MACtB,IAAIN,YAAY,CAACO,QAAQ,CAACL,MAAM,CAAC,EAAE;QAC/B;MACJ;MACAH,eAAe,CAACG,MAAM,CAAC,CAAC,GAAGI,IAAI,CAAC;IACpC,CAAC;EACL;AACJ,CAAC;AAACE,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/handler-graphql",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.fdd9228b5d",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,36 +14,34 @@
|
|
|
14
14
|
"Adrian Smijulj <adrian@webiny.com>"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@graphql-tools/
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/
|
|
17
|
+
"@graphql-tools/merge": "9.0.8",
|
|
18
|
+
"@graphql-tools/resolvers-composition": "7.0.2",
|
|
19
|
+
"@graphql-tools/schema": "10.0.7",
|
|
20
|
+
"@graphql-tools/utils": "10.5.5",
|
|
21
|
+
"@webiny/api": "0.0.0-unstable.fdd9228b5d",
|
|
22
|
+
"@webiny/error": "0.0.0-unstable.fdd9228b5d",
|
|
23
|
+
"@webiny/handler": "0.0.0-unstable.fdd9228b5d",
|
|
24
|
+
"@webiny/plugins": "0.0.0-unstable.fdd9228b5d",
|
|
23
25
|
"boolean": "3.2.0",
|
|
24
|
-
"graphql": "15.
|
|
26
|
+
"graphql": "15.9.0",
|
|
25
27
|
"graphql-scalars": "1.12.0",
|
|
26
28
|
"graphql-tag": "2.12.6"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"jest": "^28.1.0",
|
|
36
|
-
"jest-mock-console": "^1.0.0",
|
|
37
|
-
"rimraf": "^3.0.2",
|
|
38
|
-
"typescript": "4.7.4"
|
|
31
|
+
"@webiny/handler-aws": "0.0.0-unstable.fdd9228b5d",
|
|
32
|
+
"@webiny/project-utils": "0.0.0-unstable.fdd9228b5d",
|
|
33
|
+
"jest": "29.7.0",
|
|
34
|
+
"jest-mock-console": "2.0.0",
|
|
35
|
+
"rimraf": "6.0.1",
|
|
36
|
+
"typescript": "5.3.3"
|
|
39
37
|
},
|
|
40
38
|
"publishConfig": {
|
|
41
39
|
"access": "public",
|
|
42
40
|
"directory": "dist"
|
|
43
41
|
},
|
|
44
42
|
"scripts": {
|
|
45
|
-
"build": "
|
|
46
|
-
"watch": "
|
|
43
|
+
"build": "node ../cli/bin.js run build",
|
|
44
|
+
"watch": "node ../cli/bin.js run watch"
|
|
47
45
|
},
|
|
48
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "fdd9228b5d2636463e8a34b6e0d26eea1e29c01d"
|
|
49
47
|
}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import type { Context } from "@webiny/api/types";
|
|
1
2
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import { GraphQLSchemaDefinition, Resolvers,
|
|
3
|
-
|
|
3
|
+
import type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from "../types";
|
|
4
|
+
export interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {
|
|
5
|
+
schema: GraphQLSchemaDefinition<TContext>;
|
|
6
|
+
isApplicable: (context: TContext) => boolean;
|
|
7
|
+
}
|
|
4
8
|
export interface GraphQLSchemaPluginConfig<TContext> {
|
|
5
|
-
typeDefs?:
|
|
9
|
+
typeDefs?: TypeDefs;
|
|
6
10
|
resolvers?: Resolvers<TContext>;
|
|
11
|
+
resolverDecorators?: ResolverDecorators;
|
|
12
|
+
isApplicable?: (context: TContext) => boolean;
|
|
7
13
|
}
|
|
8
|
-
export declare class GraphQLSchemaPlugin<TContext = Context> extends Plugin {
|
|
14
|
+
export declare class GraphQLSchemaPlugin<TContext = Context> extends Plugin implements IGraphQLSchemaPlugin<TContext> {
|
|
9
15
|
static readonly type: string;
|
|
10
|
-
|
|
16
|
+
protected config: GraphQLSchemaPluginConfig<TContext>;
|
|
11
17
|
constructor(config: GraphQLSchemaPluginConfig<TContext>);
|
|
12
18
|
get schema(): GraphQLSchemaDefinition<TContext>;
|
|
19
|
+
isApplicable(context: TContext): boolean;
|
|
13
20
|
}
|
|
21
|
+
export declare const createGraphQLSchemaPlugin: <T = Context>(config: GraphQLSchemaPluginConfig<T>) => GraphQLSchemaPlugin<T>;
|
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
exports.GraphQLSchemaPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
6
|
+
exports.createGraphQLSchemaPlugin = exports.GraphQLSchemaPlugin = void 0;
|
|
12
7
|
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
8
|
class GraphQLSchemaPlugin extends _plugins.Plugin {
|
|
9
|
+
static type = "graphql-schema";
|
|
15
10
|
constructor(config) {
|
|
16
11
|
super();
|
|
17
|
-
(0, _defineProperty2.default)(this, "config", void 0);
|
|
18
12
|
this.config = config;
|
|
19
13
|
}
|
|
20
|
-
|
|
21
14
|
get schema() {
|
|
22
15
|
return {
|
|
23
16
|
typeDefs: this.config.typeDefs || "",
|
|
24
|
-
resolvers: this.config.resolvers
|
|
17
|
+
resolvers: this.config.resolvers,
|
|
18
|
+
resolverDecorators: this.config.resolverDecorators
|
|
25
19
|
};
|
|
26
20
|
}
|
|
27
|
-
|
|
21
|
+
isApplicable(context) {
|
|
22
|
+
if (this.config.isApplicable) {
|
|
23
|
+
return this.config.isApplicable(context);
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
28
27
|
}
|
|
29
|
-
|
|
30
28
|
exports.GraphQLSchemaPlugin = GraphQLSchemaPlugin;
|
|
31
|
-
|
|
29
|
+
const createGraphQLSchemaPlugin = config => {
|
|
30
|
+
return new GraphQLSchemaPlugin(config);
|
|
31
|
+
};
|
|
32
|
+
exports.createGraphQLSchemaPlugin = createGraphQLSchemaPlugin;
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=GraphQLSchemaPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GraphQLSchemaPlugin","Plugin","constructor","config","schema","typeDefs","resolvers"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { GraphQLSchemaDefinition, Resolvers,
|
|
1
|
+
{"version":3,"names":["_plugins","require","GraphQLSchemaPlugin","Plugin","type","constructor","config","schema","typeDefs","resolvers","resolverDecorators","isApplicable","context","exports","createGraphQLSchemaPlugin"],"sources":["GraphQLSchemaPlugin.ts"],"sourcesContent":["import type { Context } from \"@webiny/api/types\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { GraphQLSchemaDefinition, ResolverDecorators, Resolvers, TypeDefs } from \"~/types\";\n\nexport interface IGraphQLSchemaPlugin<TContext = Context> extends Plugin {\n schema: GraphQLSchemaDefinition<TContext>;\n isApplicable: (context: TContext) => boolean;\n}\n\nexport interface GraphQLSchemaPluginConfig<TContext> {\n typeDefs?: TypeDefs;\n resolvers?: Resolvers<TContext>;\n resolverDecorators?: ResolverDecorators;\n isApplicable?: (context: TContext) => boolean;\n}\n\nexport class GraphQLSchemaPlugin<TContext = Context>\n extends Plugin\n implements IGraphQLSchemaPlugin<TContext>\n{\n public static override readonly type: string = \"graphql-schema\";\n protected config: GraphQLSchemaPluginConfig<TContext>;\n\n constructor(config: GraphQLSchemaPluginConfig<TContext>) {\n super();\n this.config = config;\n }\n\n get schema(): GraphQLSchemaDefinition<TContext> {\n return {\n typeDefs: this.config.typeDefs || \"\",\n resolvers: this.config.resolvers,\n resolverDecorators: this.config.resolverDecorators\n };\n }\n\n isApplicable(context: TContext): boolean {\n if (this.config.isApplicable) {\n return this.config.isApplicable(context);\n }\n return true;\n }\n}\n\nexport const createGraphQLSchemaPlugin = <T = Context>(config: GraphQLSchemaPluginConfig<T>) => {\n return new GraphQLSchemaPlugin<T>(config);\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAeO,MAAMC,mBAAmB,SACpBC,eAAM,CAElB;EACI,OAAgCC,IAAI,GAAW,gBAAgB;EAG/DC,WAAWA,CAACC,MAA2C,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,IAAIC,MAAMA,CAAA,EAAsC;IAC5C,OAAO;MACHC,QAAQ,EAAE,IAAI,CAACF,MAAM,CAACE,QAAQ,IAAI,EAAE;MACpCC,SAAS,EAAE,IAAI,CAACH,MAAM,CAACG,SAAS;MAChCC,kBAAkB,EAAE,IAAI,CAACJ,MAAM,CAACI;IACpC,CAAC;EACL;EAEAC,YAAYA,CAACC,OAAiB,EAAW;IACrC,IAAI,IAAI,CAACN,MAAM,CAACK,YAAY,EAAE;MAC1B,OAAO,IAAI,CAACL,MAAM,CAACK,YAAY,CAACC,OAAO,CAAC;IAC5C;IACA,OAAO,IAAI;EACf;AACJ;AAACC,OAAA,CAAAX,mBAAA,GAAAA,mBAAA;AAEM,MAAMY,yBAAyB,GAAiBR,MAAoC,IAAK;EAC5F,OAAO,IAAIJ,mBAAmB,CAAII,MAAM,CAAC;AAC7C,CAAC;AAACO,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
package/plugins/index.js
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _GraphQLSchemaPlugin = require("./GraphQLSchemaPlugin");
|
|
8
|
-
|
|
9
7
|
Object.keys(_GraphQLSchemaPlugin).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _GraphQLSchemaPlugin[key]) return;
|
|
@@ -15,4 +13,6 @@ Object.keys(_GraphQLSchemaPlugin).forEach(function (key) {
|
|
|
15
13
|
return _GraphQLSchemaPlugin[key];
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
|
-
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./GraphQLSchemaPlugin\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_GraphQLSchemaPlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./GraphQLSchemaPlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,oBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,oBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,oBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/processRequestBody.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ExecutionResult, GraphQLSchema } from "graphql";
|
|
2
|
-
import { GraphQLRequestBody } from "./types";
|
|
3
|
-
import { Context } from "@webiny/api/types";
|
|
4
|
-
declare const
|
|
5
|
-
export default _default;
|
|
1
|
+
import type { ExecutionResult, GraphQLSchema } from "graphql";
|
|
2
|
+
import type { GraphQLRequestBody } from "./types";
|
|
3
|
+
import type { Context } from "@webiny/api/types";
|
|
4
|
+
export declare const processRequestBody: <TData = Record<string, any>, TExtensions = Record<string, any>>(requestBody: GraphQLRequestBody | GraphQLRequestBody[], schema: GraphQLSchema, context: Context) => Promise<ExecutionResult<TData, TExtensions> | ExecutionResult<TData, TExtensions>[]>;
|
package/processRequestBody.js
CHANGED
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.processRequestBody = void 0;
|
|
8
7
|
var _graphql = require("graphql");
|
|
9
|
-
|
|
10
|
-
const processRequestBody = async (body, schema, context) => {
|
|
8
|
+
const executeGraphQl = async (body, schema, context) => {
|
|
11
9
|
const {
|
|
12
10
|
query,
|
|
13
11
|
variables,
|
|
@@ -18,7 +16,14 @@ const processRequestBody = async (body, schema, context) => {
|
|
|
18
16
|
schema,
|
|
19
17
|
context
|
|
20
18
|
}));
|
|
21
|
-
const result = await (0, _graphql.graphql)(
|
|
19
|
+
const result = await (0, _graphql.graphql)({
|
|
20
|
+
schema,
|
|
21
|
+
source: query,
|
|
22
|
+
rootValue: {},
|
|
23
|
+
contextValue: context,
|
|
24
|
+
variableValues: variables,
|
|
25
|
+
operationName
|
|
26
|
+
});
|
|
22
27
|
context.plugins.byType("graphql-after-query").forEach(pl => {
|
|
23
28
|
pl.apply({
|
|
24
29
|
result,
|
|
@@ -29,19 +34,17 @@ const processRequestBody = async (body, schema, context) => {
|
|
|
29
34
|
});
|
|
30
35
|
return result;
|
|
31
36
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
result.push(await processRequestBody(requestBody[i], schema, context));
|
|
37
|
+
const processRequestBody = async (requestBody, schema, context) => {
|
|
38
|
+
if (Array.isArray(requestBody)) {
|
|
39
|
+
const results = [];
|
|
40
|
+
for (const body of requestBody) {
|
|
41
|
+
const result = await executeGraphQl(body, schema, context);
|
|
42
|
+
results.push(result);
|
|
39
43
|
}
|
|
40
|
-
|
|
41
|
-
return result;
|
|
44
|
+
return results;
|
|
42
45
|
}
|
|
43
|
-
|
|
44
|
-
return await processRequestBody(requestBody, schema, context);
|
|
46
|
+
return await executeGraphQl(requestBody, schema, context);
|
|
45
47
|
};
|
|
48
|
+
exports.processRequestBody = processRequestBody;
|
|
46
49
|
|
|
47
|
-
|
|
50
|
+
//# sourceMappingURL=processRequestBody.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_graphql","require","executeGraphQl","body","schema","context","query","variables","operationName","plugins","byType","forEach","pl","apply","result","graphql","source","rootValue","contextValue","variableValues","processRequestBody","requestBody","Array","isArray","results","push","exports"],"sources":["processRequestBody.ts"],"sourcesContent":["import type { ExecutionResult, GraphQLSchema } from \"graphql\";\nimport { graphql } from \"graphql\";\nimport type {\n GraphQLAfterQueryPlugin,\n GraphQLBeforeQueryPlugin,\n GraphQLRequestBody\n} from \"~/types\";\nimport type { Context } from \"@webiny/api/types\";\n\nconst executeGraphQl = async <TData = Record<string, any>, TExtensions = Record<string, any>>(\n body: GraphQLRequestBody,\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult<TData, TExtensions>> => {\n const { query, variables, operationName } = body;\n\n context.plugins\n .byType<GraphQLBeforeQueryPlugin>(\"graphql-before-query\")\n .forEach(pl => pl.apply({ body, schema, context }));\n\n const result = await graphql({\n schema,\n source: query,\n rootValue: {},\n contextValue: context,\n variableValues: variables,\n operationName\n });\n\n context.plugins.byType<GraphQLAfterQueryPlugin>(\"graphql-after-query\").forEach(pl => {\n pl.apply({ result, body, schema, context });\n });\n\n return result as ExecutionResult<TData, TExtensions>;\n};\n\nexport const processRequestBody = async <\n TData = Record<string, any>,\n TExtensions = Record<string, any>\n>(\n requestBody: GraphQLRequestBody | GraphQLRequestBody[],\n schema: GraphQLSchema,\n context: Context\n): Promise<ExecutionResult<TData, TExtensions>[] | ExecutionResult<TData, TExtensions>> => {\n if (Array.isArray(requestBody)) {\n const results: ExecutionResult<TData, TExtensions>[] = [];\n for (const body of requestBody) {\n const result = await executeGraphQl<TData, TExtensions>(body, schema, context);\n results.push(result);\n }\n return results;\n }\n return await executeGraphQl<TData, TExtensions>(requestBody, schema, context);\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAQA,MAAMC,cAAc,GAAG,MAAAA,CACnBC,IAAwB,EACxBC,MAAqB,EACrBC,OAAgB,KAC+B;EAC/C,MAAM;IAAEC,KAAK;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGL,IA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interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.Response = exports.NotFoundResponse = exports.ListResponse = exports.ListErrorResponse = exports.ErrorResponse = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
7
|
const defaultParams = {
|
|
13
8
|
code: "",
|
|
14
9
|
message: "",
|
|
15
10
|
data: null,
|
|
16
11
|
stack: null
|
|
17
12
|
};
|
|
18
|
-
|
|
19
13
|
class ErrorResponse {
|
|
20
14
|
constructor(params) {
|
|
21
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
22
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
23
15
|
this.data = null;
|
|
24
|
-
const debug = process.env.DEBUG === "true";
|
|
16
|
+
const debug = process.env.DEBUG === "true";
|
|
25
17
|
|
|
18
|
+
// Ensure `stack` is either `string` or `null`.
|
|
26
19
|
let stack = defaultParams.stack;
|
|
27
|
-
|
|
28
20
|
if (debug && params.stack) {
|
|
29
21
|
stack = params.stack;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
this.error = {
|
|
33
24
|
code: params.code || defaultParams.code,
|
|
34
25
|
message: params.message || defaultParams.message,
|
|
@@ -36,11 +27,8 @@ class ErrorResponse {
|
|
|
36
27
|
stack: stack
|
|
37
28
|
};
|
|
38
29
|
}
|
|
39
|
-
|
|
40
30
|
}
|
|
41
|
-
|
|
42
31
|
exports.ErrorResponse = ErrorResponse;
|
|
43
|
-
|
|
44
32
|
class NotFoundResponse extends ErrorResponse {
|
|
45
33
|
constructor(message) {
|
|
46
34
|
super({
|
|
@@ -48,26 +36,19 @@ class NotFoundResponse extends ErrorResponse {
|
|
|
48
36
|
message
|
|
49
37
|
});
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
}
|
|
53
|
-
|
|
54
40
|
exports.NotFoundResponse = NotFoundResponse;
|
|
55
|
-
|
|
56
41
|
class ListErrorResponse {
|
|
57
42
|
constructor(params) {
|
|
58
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
59
|
-
(0, _defineProperty2.default)(this, "meta", void 0);
|
|
60
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
61
43
|
this.meta = null;
|
|
62
44
|
this.data = null;
|
|
63
|
-
const debug = process.env.DEBUG === "true";
|
|
45
|
+
const debug = process.env.DEBUG === "true";
|
|
64
46
|
|
|
47
|
+
// Ensure `stack` is either `string` or `null`.
|
|
65
48
|
let stack = defaultParams.stack;
|
|
66
|
-
|
|
67
49
|
if (debug && params.stack) {
|
|
68
50
|
stack = params.stack;
|
|
69
51
|
}
|
|
70
|
-
|
|
71
52
|
this.error = {
|
|
72
53
|
code: params.code || defaultParams.code,
|
|
73
54
|
message: params.message || defaultParams.message,
|
|
@@ -75,33 +56,22 @@ class ListErrorResponse {
|
|
|
75
56
|
stack: stack
|
|
76
57
|
};
|
|
77
58
|
}
|
|
78
|
-
|
|
79
59
|
}
|
|
80
|
-
|
|
81
60
|
exports.ListErrorResponse = ListErrorResponse;
|
|
82
|
-
|
|
83
61
|
class Response {
|
|
84
62
|
constructor(data) {
|
|
85
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
86
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
87
63
|
this.data = data;
|
|
88
64
|
this.error = null;
|
|
89
65
|
}
|
|
90
|
-
|
|
91
66
|
}
|
|
92
|
-
|
|
93
67
|
exports.Response = Response;
|
|
94
|
-
|
|
95
68
|
class ListResponse {
|
|
96
69
|
constructor(data, meta) {
|
|
97
|
-
(0, _defineProperty2.default)(this, "data", void 0);
|
|
98
|
-
(0, _defineProperty2.default)(this, "meta", void 0);
|
|
99
|
-
(0, _defineProperty2.default)(this, "error", void 0);
|
|
100
70
|
this.data = Array.isArray(data) ? data : [];
|
|
101
71
|
this.meta = meta || {};
|
|
102
72
|
this.error = null;
|
|
103
73
|
}
|
|
104
|
-
|
|
105
74
|
}
|
|
75
|
+
exports.ListResponse = ListResponse;
|
|
106
76
|
|
|
107
|
-
|
|
77
|
+
//# sourceMappingURL=responses.js.map
|
package/responses.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultParams","code","message","data","stack","ErrorResponse","constructor","params","debug","process","env","DEBUG","error","NotFoundResponse","ListErrorResponse","meta","Response","ListResponse","Array","isArray"],"sources":["responses.ts"],"sourcesContent":["export interface ErrorResponseParams {\n message: string;\n code?: string;\n data?: any;\n stack?: string | null;\n}\n\nconst defaultParams: Required<ErrorResponseParams> = {\n code: \"\",\n message: \"\",\n data: null,\n stack: null\n};\n\nexport class ErrorResponse {\n public readonly data: null;\n public readonly error: {\n code: string;\n message: string;\n data: any;\n stack: string | null;\n };\n\n constructor(params: ErrorResponseParams) {\n this.data = null;\n\n const debug = process.env.DEBUG === \"true\";\n\n // Ensure `stack` is either `string` or `null`.\n let stack = defaultParams.stack;\n if (debug && params.stack) {\n stack = params.stack;\n }\n\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data,\n stack: stack\n };\n }\n}\n\nexport class NotFoundResponse extends ErrorResponse {\n constructor(message: string) {\n super({\n code: \"NOT_FOUND\",\n message\n });\n }\n}\n\nexport class ListErrorResponse {\n public readonly data: null;\n public readonly meta: null;\n public readonly error: {\n code: string;\n message: string;\n data: any;\n stack: string | null;\n };\n\n constructor(params: ErrorResponseParams) {\n this.meta = null;\n this.data = null;\n\n const debug = process.env.DEBUG === \"true\";\n\n // Ensure `stack` is either `string` or `null`.\n let stack = defaultParams.stack;\n if (debug && params.stack) {\n stack = params.stack;\n }\n\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data,\n stack: stack\n };\n }\n}\n\nexport class Response<T = any> {\n public readonly data: T;\n public readonly error: null;\n\n constructor(data: T) {\n this.data = data;\n this.error = null;\n }\n}\n\nexport class ListResponse<T, M> {\n public readonly data: Array<T>;\n public readonly meta: M;\n public readonly error: null;\n\n constructor(data: Array<T>, meta?: M) {\n this.data = Array.isArray(data) ? data : [];\n this.meta = meta || ({} as M);\n this.error = null;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["defaultParams","code","message","data","stack","ErrorResponse","constructor","params","debug","process","env","DEBUG","error","exports","NotFoundResponse","ListErrorResponse","meta","Response","ListResponse","Array","isArray"],"sources":["responses.ts"],"sourcesContent":["export interface ErrorResponseParams {\n message: string;\n code?: string;\n data?: any;\n stack?: string | null;\n}\n\nconst defaultParams: Required<ErrorResponseParams> = {\n code: \"\",\n message: \"\",\n data: null,\n stack: null\n};\n\nexport class ErrorResponse {\n public readonly data: null;\n public readonly error: {\n code: string;\n message: string;\n data: any;\n stack: string | null;\n };\n\n constructor(params: ErrorResponseParams) {\n this.data = null;\n\n const debug = process.env.DEBUG === \"true\";\n\n // Ensure `stack` is either `string` or `null`.\n let stack = defaultParams.stack;\n if (debug && params.stack) {\n stack = params.stack;\n }\n\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data,\n stack: stack\n };\n }\n}\n\nexport class NotFoundResponse extends ErrorResponse {\n constructor(message: string) {\n super({\n code: \"NOT_FOUND\",\n message\n });\n }\n}\n\nexport class ListErrorResponse {\n public readonly data: null;\n public readonly meta: null;\n public readonly error: {\n code: string;\n message: string;\n data: any;\n stack: string | null;\n };\n\n constructor(params: ErrorResponseParams) {\n this.meta = null;\n this.data = null;\n\n const debug = process.env.DEBUG === \"true\";\n\n // Ensure `stack` is either `string` or `null`.\n let stack = defaultParams.stack;\n if (debug && params.stack) {\n stack = params.stack;\n }\n\n this.error = {\n code: params.code || defaultParams.code,\n message: params.message || defaultParams.message,\n data: params.data || defaultParams.data,\n stack: stack\n };\n }\n}\n\nexport class Response<T = any> {\n public readonly data: T;\n public readonly error: null;\n\n constructor(data: T) {\n this.data = data;\n this.error = null;\n }\n}\n\nexport class ListResponse<T, M> {\n public readonly data: Array<T>;\n public readonly meta: M;\n public readonly error: null;\n\n constructor(data: Array<T>, meta?: M) {\n this.data = Array.isArray(data) ? data : [];\n this.meta = meta || ({} as M);\n this.error = null;\n }\n}\n"],"mappings":";;;;;;AAOA,MAAMA,aAA4C,GAAG;EACjDC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,EAAE;EACXC,IAAI,EAAE,IAAI;EACVC,KAAK,EAAE;AACX,CAAC;AAEM,MAAMC,aAAa,CAAC;EASvBC,WAAWA,CAACC,MAA2B,EAAE;IACrC,IAAI,CAACJ,IAAI,GAAG,IAAI;IAEhB,MAAMK,KAAK,GAAGC,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,MAAM;;IAE1C;IACA,IAAIP,KAAK,GAAGJ,aAAa,CAACI,KAAK;IAC/B,IAAII,KAAK,IAAID,MAAM,CAACH,KAAK,EAAE;MACvBA,KAAK,GAAGG,MAAM,CAACH,KAAK;IACxB;IAEA,IAAI,CAACQ,KAAK,GAAG;MACTX,IAAI,EAAEM,MAAM,CAACN,IAAI,IAAID,aAAa,CAACC,IAAI;MACvCC,OAAO,EAAEK,MAAM,CAACL,OAAO,IAAIF,aAAa,CAACE,OAAO;MAChDC,IAAI,EAAEI,MAAM,CAACJ,IAAI,IAAIH,aAAa,CAACG,IAAI;MACvCC,KAAK,EAAEA;IACX,CAAC;EACL;AACJ;AAACS,OAAA,CAAAR,aAAA,GAAAA,aAAA;AAEM,MAAMS,gBAAgB,SAAST,aAAa,CAAC;EAChDC,WAAWA,CAACJ,OAAe,EAAE;IACzB,KAAK,CAAC;MACFD,IAAI,EAAE,WAAW;MACjBC;IACJ,CAAC,CAAC;EACN;AACJ;AAACW,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAEM,MAAMC,iBAAiB,CAAC;EAU3BT,WAAWA,CAACC,MAA2B,EAAE;IAC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