@adobe/aio-cli-plugin-api-mesh 4.1.0 → 5.0.0-alpha

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 (39) hide show
  1. package/oclif.manifest.json +1 -1
  2. package/package.json +3 -7
  3. package/src/commands/api-mesh/__tests__/create.test.js +217 -293
  4. package/src/commands/api-mesh/__tests__/delete.test.js +6 -6
  5. package/src/commands/api-mesh/__tests__/describe.test.js +2 -17
  6. package/src/commands/api-mesh/__tests__/get.test.js +9 -78
  7. package/src/commands/api-mesh/__tests__/log-get-bulk.test.js +1 -1
  8. package/src/commands/api-mesh/__tests__/run.test.js +22 -25
  9. package/src/commands/api-mesh/__tests__/status.test.js +1 -1
  10. package/src/commands/api-mesh/__tests__/update.test.js +8 -9
  11. package/src/commands/api-mesh/create.js +6 -9
  12. package/src/commands/api-mesh/delete.js +5 -5
  13. package/src/commands/api-mesh/describe.js +3 -3
  14. package/src/commands/api-mesh/get.js +8 -11
  15. package/src/commands/api-mesh/init.js +0 -2
  16. package/src/commands/api-mesh/log-get-bulk.js +2 -2
  17. package/src/commands/api-mesh/log-get.js +2 -2
  18. package/src/commands/api-mesh/log-list.js +1 -1
  19. package/src/commands/api-mesh/run.js +9 -35
  20. package/src/commands/api-mesh/source/install.js +3 -2
  21. package/src/commands/api-mesh/status.js +4 -6
  22. package/src/commands/api-mesh/update.js +7 -9
  23. package/src/constants.js +2 -0
  24. package/src/lib/devConsole.js +38 -32
  25. package/src/server.js +198 -36
  26. package/src/serverUtils.js +3 -3
  27. package/src/cors.js +0 -28
  28. package/src/fixPlugins.js +0 -28
  29. package/src/index.js +0 -44
  30. package/src/plugins/complianceHeaders/complianceHeaders.js +0 -55
  31. package/src/plugins/complianceHeaders/index.js +0 -2
  32. package/src/plugins/httpDetailsExtensions/LICENSE +0 -21
  33. package/src/plugins/httpDetailsExtensions/index.js +0 -81
  34. package/src/secrets.js +0 -34
  35. package/src/served.js +0 -22
  36. package/src/templates/wrangler.toml +0 -14
  37. package/src/utils/logger.js +0 -42
  38. package/src/utils/requestId.js +0 -26
  39. package/src/wranglerServer.js +0 -80
@@ -1,80 +0,0 @@
1
- import { getMesh } from '@graphql-mesh/runtime';
2
-
3
- const { getCorsOptions } = require('./cors');
4
- const { createYoga } = require('graphql-yoga');
5
- const { GraphQLError } = require('graphql/error');
6
-
7
- const { loadMeshSecrets, getSecretsHandler } = require('./secrets');
8
- const useComplianceHeaders = require('./plugins/complianceHeaders');
9
- const UseHttpDetailsExtensions = require('./plugins/httpDetailsExtensions');
10
- const useSourceHeaders = require('@adobe/plugin-source-headers');
11
- const { useDisableIntrospection } = require('@envelop/disable-introspection');
12
-
13
- let meshInstance$;
14
-
15
- async function buildMeshInstance(meshArtifacts, meshConfig) {
16
- const { getMeshOptions } = meshArtifacts;
17
- const options = await getMeshOptions();
18
-
19
- options.additionalEnvelopPlugins = (options.additionalEnvelopPlugins || []).concat(
20
- useComplianceHeaders(),
21
- UseHttpDetailsExtensions({
22
- // Get the details of responseConfig.includeHTTPDetails and store in Cache
23
- if: meshConfig.responseConfig?.includeHTTPDetails || false,
24
- }),
25
- useSourceHeaders(meshConfig),
26
- );
27
-
28
- if (meshConfig.disableIntrospection) {
29
- options.additionalEnvelopPlugins.push(useDisableIntrospection());
30
- }
31
-
32
- return getMesh(options).then(mesh => {
33
- const id = mesh.pubsub.subscribe('destroy', () => {
34
- meshInstance$ = undefined;
35
- mesh.pubsub.unsubscribe(id);
36
- });
37
- return mesh;
38
- });
39
- }
40
-
41
- async function getBuiltMesh(meshArtifacts, meshConfig) {
42
- if (meshInstance$ == null) {
43
- meshInstance$ = buildMeshInstance(meshArtifacts, meshConfig);
44
- }
45
- return meshInstance$;
46
- }
47
-
48
- const buildServer = async (loggerInstance, env, meshArtifacts, meshConfig) => {
49
- const { Secret: secret } = env;
50
- const tenantMesh = await getBuiltMesh(meshArtifacts, meshConfig);
51
- const meshSecrets = loadMeshSecrets(loggerInstance, secret);
52
- return await buildYogaServer(env, tenantMesh, meshConfig, meshSecrets);
53
- };
54
-
55
- async function buildYogaServer(env, tenantMesh, meshConfig, meshSecrets) {
56
- const secretsProxy = new Proxy(meshSecrets, getSecretsHandler);
57
- return createYoga({
58
- plugins: tenantMesh.plugins,
59
- graphqlEndpoint: `/graphql`,
60
- cors: getCorsOptions(env, meshConfig),
61
- context: initialContext => ({
62
- ...initialContext,
63
- secrets: secretsProxy,
64
- }),
65
- maskedErrors: {
66
- maskError: maskError,
67
- },
68
- logging: 'debug',
69
- });
70
- }
71
-
72
- const maskError = error => {
73
- if (error instanceof GraphQLError && error.extensions?.http?.headers) {
74
- delete error.extensions.http.headers;
75
- }
76
-
77
- return error;
78
- };
79
-
80
- module.exports = { buildServer };