@webiny/api-headless-cms 5.43.0-beta.0 → 5.43.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/graphql/handleRequest.js
CHANGED
|
@@ -72,7 +72,14 @@ const handleRequest = async params => {
|
|
|
72
72
|
throw ex;
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
|
-
|
|
75
|
+
/**
|
|
76
|
+
* IMPORTANT! Do not send anything if reply was already sent.
|
|
77
|
+
*/
|
|
78
|
+
if (reply.sent) {
|
|
79
|
+
console.warn("Reply already sent, cannot send the result (api-headless-cms).");
|
|
80
|
+
return reply;
|
|
81
|
+
}
|
|
82
|
+
return reply.send(result);
|
|
76
83
|
};
|
|
77
84
|
exports.handleRequest = handleRequest;
|
|
78
85
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_checkEndpointAccess","require","_createRequestBody","_formatErrorPayload","_getSchema","_handlerGraphql","handleRequest","params","context","request","reply","checkEndpointAccess","ex","code","send","data","error","message","stack","getTenant","tenancy","getCurrentTenant","getLocale","cms","schema","benchmark","measure","getSchema","type","console","formatErrorPayload","body","createRequestBody","result","processRequestBody","exports"],"sources":["handleRequest.ts"],"sourcesContent":["import { ApiEndpoint, CmsContext } from \"~/types\";\nimport { checkEndpointAccess } from \"./checkEndpointAccess\";\nimport { createRequestBody } from \"./createRequestBody\";\nimport { formatErrorPayload } from \"./formatErrorPayload\";\nimport { getSchema } from \"./getSchema\";\nimport { Reply, Request } from \"@webiny/handler/types\";\nimport { processRequestBody } from \"@webiny/handler-graphql\";\nimport { ExecutionResult } from \"graphql\";\n\nexport interface HandleRequestParams {\n context: CmsContext;\n request: Request;\n reply: Reply;\n}\n\nexport interface HandleRequest {\n (params: HandleRequestParams): Promise<Reply>;\n}\n\nexport const handleRequest: HandleRequest = async params => {\n const { context, request, reply } = params;\n try {\n await checkEndpointAccess(context);\n } catch (ex) {\n return reply.code(401).send({\n data: null,\n error: {\n message: ex.message || \"Not authorized!\",\n code: ex.code || \"SECURITY_NOT_AUTHORIZED\",\n data: ex.data || null,\n stack: null\n }\n });\n }\n\n const getTenant = () => {\n return context.tenancy.getCurrentTenant();\n };\n\n const getLocale = () => {\n return context.cms.getLocale();\n };\n\n const schema = await context.benchmark.measure(\"headlessCms.graphql.getSchema\", async () => {\n try {\n return await getSchema({\n context,\n getTenant,\n getLocale,\n type: context.cms.type as ApiEndpoint\n });\n } catch (ex) {\n console.error(`Error while generating the schema.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n });\n\n const body = await context.benchmark.measure(\n \"headlessCms.graphql.createRequestBody\",\n async () => {\n try {\n return createRequestBody(request.body);\n } catch (ex) {\n console.error(`Error while creating the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n }\n );\n\n /**\n * We need to store the processRequestBody result in a variable and output it after the measurement.\n * Otherwise, the measurement will not be shown in the output.\n */\n let result: ExecutionResult[] | ExecutionResult | null = null;\n\n await context.benchmark.measure(\"headlessCms.graphql.processRequestBody\", async () => {\n try {\n result = await processRequestBody(body, schema, context);\n } catch (ex) {\n console.error(`Error while processing the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n });\n
|
|
1
|
+
{"version":3,"names":["_checkEndpointAccess","require","_createRequestBody","_formatErrorPayload","_getSchema","_handlerGraphql","handleRequest","params","context","request","reply","checkEndpointAccess","ex","code","send","data","error","message","stack","getTenant","tenancy","getCurrentTenant","getLocale","cms","schema","benchmark","measure","getSchema","type","console","formatErrorPayload","body","createRequestBody","result","processRequestBody","sent","warn","exports"],"sources":["handleRequest.ts"],"sourcesContent":["import { ApiEndpoint, CmsContext } from \"~/types\";\nimport { checkEndpointAccess } from \"./checkEndpointAccess\";\nimport { createRequestBody } from \"./createRequestBody\";\nimport { formatErrorPayload } from \"./formatErrorPayload\";\nimport { getSchema } from \"./getSchema\";\nimport { Reply, Request } from \"@webiny/handler/types\";\nimport { processRequestBody } from \"@webiny/handler-graphql\";\nimport { ExecutionResult } from \"graphql\";\n\nexport interface HandleRequestParams {\n context: CmsContext;\n request: Request;\n reply: Reply;\n}\n\nexport interface HandleRequest {\n (params: HandleRequestParams): Promise<Reply>;\n}\n\nexport const handleRequest: HandleRequest = async params => {\n const { context, request, reply } = params;\n try {\n await checkEndpointAccess(context);\n } catch (ex) {\n return reply.code(401).send({\n data: null,\n error: {\n message: ex.message || \"Not authorized!\",\n code: ex.code || \"SECURITY_NOT_AUTHORIZED\",\n data: ex.data || null,\n stack: null\n }\n });\n }\n\n const getTenant = () => {\n return context.tenancy.getCurrentTenant();\n };\n\n const getLocale = () => {\n return context.cms.getLocale();\n };\n\n const schema = await context.benchmark.measure(\"headlessCms.graphql.getSchema\", async () => {\n try {\n return await getSchema({\n context,\n getTenant,\n getLocale,\n type: context.cms.type as ApiEndpoint\n });\n } catch (ex) {\n console.error(`Error while generating the schema.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n });\n\n const body = await context.benchmark.measure(\n \"headlessCms.graphql.createRequestBody\",\n async () => {\n try {\n return createRequestBody(request.body);\n } catch (ex) {\n console.error(`Error while creating the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n }\n );\n\n /**\n * We need to store the processRequestBody result in a variable and output it after the measurement.\n * Otherwise, the measurement will not be shown in the output.\n */\n let result: ExecutionResult[] | ExecutionResult | null = null;\n\n await context.benchmark.measure(\"headlessCms.graphql.processRequestBody\", async () => {\n try {\n result = await processRequestBody(body, schema, context);\n } catch (ex) {\n console.error(`Error while processing the body request.`);\n console.error(formatErrorPayload(ex));\n throw ex;\n }\n });\n /**\n * IMPORTANT! Do not send anything if reply was already sent.\n */\n if (reply.sent) {\n console.warn(\"Reply already sent, cannot send the result (api-headless-cms).\");\n return reply;\n }\n\n return reply.send(result);\n};\n"],"mappings":";;;;;;AACA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;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AC,CAAC;EAEF,MAAMmB,IAAI,GAAG,MAAMvB,OAAO,CAACiB,SAAS,CAACC,OAAO,CACxC,uCAAuC,EACvC,YAAY;IACR,IAAI;MACA,OAAO,IAAAM,oCAAiB,EAACvB,OAAO,CAACsB,IAAI,CAAC;IAC1C,CAAC,CAAC,OAAOnB,EAAE,EAAE;MACTiB,OAAO,CAACb,KAAK,CAAC,wCAAwC,CAAC;MACvDa,OAAO,CAACb,KAAK,CAAC,IAAAc,sCAAkB,EAAClB,EAAE,CAAC,CAAC;MACrC,MAAMA,EAAE;IACZ;EACJ,CACJ,CAAC;;EAED;AACJ;AACA;AACA;EACI,IAAIqB,MAAkD,GAAG,IAAI;EAE7D,MAAMzB,OAAO,CAACiB,SAAS,CAACC,OAAO,CAAC,wCAAwC,EAAE,YAAY;IAClF,IAAI;MACAO,MAAM,GAAG,MAAM,IAAAC,kCAAkB,EAACH,IAAI,EAAEP,MAAM,EAAEhB,OAAO,CAAC;IAC5D,CAAC,CAAC,OAAOI,EAAE,EAAE;MACTiB,OAAO,CAACb,KAAK,CAAC,0CAA0C,CAAC;MACzDa,OAAO,CAACb,KAAK,CAAC,IAAAc,sCAAkB,EAAClB,EAAE,CAAC,CAAC;MACrC,MAAMA,EAAE;IACZ;EACJ,CAAC,CAAC;EACF;AACJ;AACA;EACI,IAAIF,KAAK,CAACyB,IAAI,EAAE;IACZN,OAAO,CAACO,IAAI,CAAC,gEAAgE,CAAC;IAC9E,OAAO1B,KAAK;EAChB;EAEA,OAAOA,KAAK,CAACI,IAAI,CAACmB,MAAM,CAAC;AAC7B,CAAC;AAACI,OAAA,CAAA/B,aAAA,GAAAA,aAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms",
|
|
3
|
-
"version": "5.43.0-beta.
|
|
3
|
+
"version": "5.43.0-beta.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms:base"
|
|
@@ -21,20 +21,20 @@
|
|
|
21
21
|
"@babel/code-frame": "7.26.2",
|
|
22
22
|
"@graphql-tools/merge": "9.0.8",
|
|
23
23
|
"@graphql-tools/schema": "10.0.7",
|
|
24
|
-
"@webiny/api": "5.43.0-beta.
|
|
25
|
-
"@webiny/api-i18n": "5.43.0-beta.
|
|
26
|
-
"@webiny/api-security": "5.43.0-beta.
|
|
27
|
-
"@webiny/api-tenancy": "5.43.0-beta.
|
|
28
|
-
"@webiny/error": "5.43.0-beta.
|
|
29
|
-
"@webiny/handler": "5.43.0-beta.
|
|
30
|
-
"@webiny/handler-aws": "5.43.0-beta.
|
|
31
|
-
"@webiny/handler-db": "5.43.0-beta.
|
|
32
|
-
"@webiny/handler-graphql": "5.43.0-beta.
|
|
33
|
-
"@webiny/lexical-converter": "5.43.0-beta.
|
|
34
|
-
"@webiny/plugins": "5.43.0-beta.
|
|
35
|
-
"@webiny/pubsub": "5.43.0-beta.
|
|
36
|
-
"@webiny/utils": "5.43.0-beta.
|
|
37
|
-
"@webiny/validation": "5.43.0-beta.
|
|
24
|
+
"@webiny/api": "5.43.0-beta.2",
|
|
25
|
+
"@webiny/api-i18n": "5.43.0-beta.2",
|
|
26
|
+
"@webiny/api-security": "5.43.0-beta.2",
|
|
27
|
+
"@webiny/api-tenancy": "5.43.0-beta.2",
|
|
28
|
+
"@webiny/error": "5.43.0-beta.2",
|
|
29
|
+
"@webiny/handler": "5.43.0-beta.2",
|
|
30
|
+
"@webiny/handler-aws": "5.43.0-beta.2",
|
|
31
|
+
"@webiny/handler-db": "5.43.0-beta.2",
|
|
32
|
+
"@webiny/handler-graphql": "5.43.0-beta.2",
|
|
33
|
+
"@webiny/lexical-converter": "5.43.0-beta.2",
|
|
34
|
+
"@webiny/plugins": "5.43.0-beta.2",
|
|
35
|
+
"@webiny/pubsub": "5.43.0-beta.2",
|
|
36
|
+
"@webiny/utils": "5.43.0-beta.2",
|
|
37
|
+
"@webiny/validation": "5.43.0-beta.2",
|
|
38
38
|
"dot-prop": "6.0.1",
|
|
39
39
|
"graphql": "15.9.0",
|
|
40
40
|
"graphql-tag": "2.12.6",
|
|
@@ -49,19 +49,18 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/babel__code-frame": "7.0.6",
|
|
52
|
-
"@webiny/api-wcp": "5.43.0-beta.
|
|
53
|
-
"@webiny/aws-sdk": "5.43.0-beta.
|
|
54
|
-
"@webiny/cli": "5.43.0-beta.
|
|
55
|
-
"@webiny/db-dynamodb": "5.43.0-beta.
|
|
52
|
+
"@webiny/api-wcp": "5.43.0-beta.2",
|
|
53
|
+
"@webiny/aws-sdk": "5.43.0-beta.2",
|
|
54
|
+
"@webiny/cli": "5.43.0-beta.2",
|
|
55
|
+
"@webiny/db-dynamodb": "5.43.0-beta.2",
|
|
56
56
|
"@webiny/handler-db": "0.0.0",
|
|
57
|
-
"@webiny/project-utils": "5.43.0-beta.
|
|
57
|
+
"@webiny/project-utils": "5.43.0-beta.2",
|
|
58
58
|
"apollo-graphql": "0.9.7",
|
|
59
59
|
"graphql": "15.9.0",
|
|
60
60
|
"jest": "29.7.0",
|
|
61
61
|
"prettier": "2.8.8",
|
|
62
62
|
"rimraf": "6.0.1",
|
|
63
|
-
"
|
|
64
|
-
"typescript": "4.9.5",
|
|
63
|
+
"typescript": "5.3.3",
|
|
65
64
|
"write-json-file": "4.3.0"
|
|
66
65
|
},
|
|
67
66
|
"publishConfig": {
|
|
@@ -72,5 +71,5 @@
|
|
|
72
71
|
"build": "node ../cli/bin.js run build",
|
|
73
72
|
"watch": "node ../cli/bin.js run watch"
|
|
74
73
|
},
|
|
75
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "dbed8c263df662358aca18c3cf452cd280f2dfd9"
|
|
76
75
|
}
|
|
@@ -16,5 +16,5 @@ interface Params {
|
|
|
16
16
|
type: ApiEndpoint;
|
|
17
17
|
createPlugin?: CreatePluginCallable;
|
|
18
18
|
}
|
|
19
|
-
export declare const createGraphQLSchemaPluginFromFieldPlugins: (params: Params) => ICmsGraphQLSchemaPlugin
|
|
19
|
+
export declare const createGraphQLSchemaPluginFromFieldPlugins: (params: Params) => ICmsGraphQLSchemaPlugin[];
|
|
20
20
|
export {};
|