wgc 0.75.5 → 0.75.6
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/dist/package.json +2 -2
- package/dist/src/commands/feature-subgraph/commands/publish.js +28 -115
- package/dist/src/commands/feature-subgraph/commands/publish.js.map +1 -1
- package/dist/src/core/types/types.d.ts +2 -1
- package/dist/src/handle-composition-result.d.ts +5 -1
- package/dist/src/handle-composition-result.js +22 -2
- package/dist/src/handle-composition-result.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wgc",
|
|
3
|
-
"version": "0.75.
|
|
3
|
+
"version": "0.75.6",
|
|
4
4
|
"description": "The official CLI tool to manage the GraphQL Federation Platform Cosmo",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"prettier": "^3.5.2",
|
|
83
83
|
"tsx": "^4.17.0",
|
|
84
84
|
"typescript": "5.5.2",
|
|
85
|
-
"vitest": "^2.1.
|
|
85
|
+
"vitest": "^2.1.9"
|
|
86
86
|
},
|
|
87
87
|
"gitHead": "c37aed755e1b19ed91d30f9b5f7041e15c56901a"
|
|
88
88
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
|
-
import Table from 'cli-table3';
|
|
4
3
|
import { Command, program } from 'commander';
|
|
5
4
|
import ora from 'ora';
|
|
6
5
|
import { resolve } from 'pathe';
|
|
7
6
|
import pc from 'picocolors';
|
|
8
|
-
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
|
|
9
7
|
import { parseGraphQLSubscriptionProtocol, parseGraphQLWebsocketSubprotocol } from '@wundergraph/cosmo-shared';
|
|
10
8
|
import { getBaseHeaders } from '../../../core/config.js';
|
|
11
9
|
import { validateSubscriptionProtocols } from '../../../utils.js';
|
|
12
10
|
import { websocketSubprotocolDescription } from '../../../constants.js';
|
|
11
|
+
import { handleCompositionResult } from '../../../handle-composition-result.js';
|
|
13
12
|
export default (opts) => {
|
|
14
13
|
const command = new Command('publish');
|
|
15
14
|
command.description("Publishes a feature subgraph on the control plane. If the feature subgraph doesn't exists, it will be created.\nIf the publication leads to composition errors, the errors will be visible in the Studio.\nThe router will continue to work with the latest valid schema.");
|
|
@@ -30,8 +29,9 @@ export default (opts) => {
|
|
|
30
29
|
' This parameter is always ignored if the feature subgraph has already been created.');
|
|
31
30
|
command.option('-r, --raw', 'Prints to the console in json format instead of table');
|
|
32
31
|
command.option('-j, --json', 'Prints to the console in json format instead of table');
|
|
32
|
+
command.option('--suppress-warnings', 'This flag suppresses any warnings produced by composition.');
|
|
33
33
|
command.action(async (name, options) => {
|
|
34
|
-
var _a, _b
|
|
34
|
+
var _a, _b;
|
|
35
35
|
const schemaFile = resolve(options.schema);
|
|
36
36
|
const shouldOutputJson = options.json || options.raw;
|
|
37
37
|
if (!existsSync(schemaFile)) {
|
|
@@ -70,118 +70,31 @@ export default (opts) => {
|
|
|
70
70
|
}, {
|
|
71
71
|
headers: getBaseHeaders(),
|
|
72
72
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
spinner.warn('Feature subgraph published but with composition errors.');
|
|
101
|
-
const compositionErrorsTable = new Table({
|
|
102
|
-
head: [
|
|
103
|
-
pc.bold(pc.white('FEDERATED_GRAPH_NAME')),
|
|
104
|
-
pc.bold(pc.white('NAMESPACE')),
|
|
105
|
-
pc.bold(pc.white('FEATURE_FLAG')),
|
|
106
|
-
pc.bold(pc.white('ERROR_MESSAGE')),
|
|
107
|
-
],
|
|
108
|
-
colWidths: [30, 30, 30, 120],
|
|
109
|
-
wordWrap: true,
|
|
110
|
-
});
|
|
111
|
-
console.log(pc.red(`We found composition errors, while composing the federated graph.\nThe router will continue to work with the latest valid schema.\n${pc.bold('Please check the errors below:')}`));
|
|
112
|
-
for (const compositionError of resp.compositionErrors) {
|
|
113
|
-
compositionErrorsTable.push([
|
|
114
|
-
compositionError.federatedGraphName,
|
|
115
|
-
compositionError.namespace,
|
|
116
|
-
compositionError.featureFlag || '-',
|
|
117
|
-
compositionError.message,
|
|
118
|
-
]);
|
|
119
|
-
}
|
|
120
|
-
// Don't exit here with 1 because the change was still applied
|
|
121
|
-
console.log(compositionErrorsTable.toString());
|
|
122
|
-
if (options.failOnCompositionError) {
|
|
123
|
-
program.error(pc.red(pc.bold('The command failed due to composition errors.')));
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
case EnumStatusCode.ERR_DEPLOYMENT_FAILED: {
|
|
129
|
-
if (shouldOutputJson) {
|
|
130
|
-
const deploymentFailedMessageJson = {
|
|
131
|
-
status: 'error',
|
|
132
|
-
message: `Feature subgraph was published, but the updated composition hasn't been deployed, so it's not accessible to the router. Check the errors listed below for details.`,
|
|
133
|
-
compositionErrors: resp.compositionErrors,
|
|
134
|
-
deploymentErrors: resp.deploymentErrors,
|
|
135
|
-
};
|
|
136
|
-
console.log(JSON.stringify(deploymentFailedMessageJson));
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
spinner.warn("Feature subgraph was published, but the updated composition hasn't been deployed, so it's not accessible to the router. Check the errors listed below for details.");
|
|
140
|
-
const deploymentErrorsTable = new Table({
|
|
141
|
-
head: [
|
|
142
|
-
pc.bold(pc.white('FEDERATED_GRAPH_NAME')),
|
|
143
|
-
pc.bold(pc.white('NAMESPACE')),
|
|
144
|
-
pc.bold(pc.white('ERROR_MESSAGE')),
|
|
145
|
-
],
|
|
146
|
-
colWidths: [30, 30, 120],
|
|
147
|
-
wordWrap: true,
|
|
148
|
-
});
|
|
149
|
-
for (const deploymentError of resp.deploymentErrors) {
|
|
150
|
-
deploymentErrorsTable.push([
|
|
151
|
-
deploymentError.federatedGraphName,
|
|
152
|
-
deploymentError.namespace,
|
|
153
|
-
deploymentError.message,
|
|
154
|
-
]);
|
|
155
|
-
}
|
|
156
|
-
// Don't exit here with 1 because the change was still applied
|
|
157
|
-
console.log(deploymentErrorsTable.toString());
|
|
158
|
-
if (options.failOnAdmissionWebhookError) {
|
|
159
|
-
program.error(pc.red(pc.bold('The command failed due to admission webhook errors.')));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
default: {
|
|
165
|
-
if (shouldOutputJson) {
|
|
166
|
-
const defaultErrorMessageJson = {
|
|
167
|
-
status: 'error',
|
|
168
|
-
message: `Failed to publish feature subgraph "${name}".`,
|
|
169
|
-
compositionErrors: resp.compositionErrors,
|
|
170
|
-
deploymentErrors: resp.deploymentErrors,
|
|
171
|
-
details: (_b = resp.response) === null || _b === void 0 ? void 0 : _b.details,
|
|
172
|
-
};
|
|
173
|
-
console.log(JSON.stringify(defaultErrorMessageJson));
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
spinner.fail(`Failed to publish feature subgraph "${name}".`);
|
|
177
|
-
if ((_c = resp.response) === null || _c === void 0 ? void 0 : _c.details) {
|
|
178
|
-
program.error(pc.red(pc.bold((_d = resp.response) === null || _d === void 0 ? void 0 : _d.details)));
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
process.exitCode = 1;
|
|
182
|
-
// eslint-disable-next-line no-useless-return
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
73
|
+
try {
|
|
74
|
+
handleCompositionResult({
|
|
75
|
+
responseCode: (_a = resp.response) === null || _a === void 0 ? void 0 : _a.code,
|
|
76
|
+
responseDetails: (_b = resp.response) === null || _b === void 0 ? void 0 : _b.details,
|
|
77
|
+
compositionErrors: resp.compositionErrors,
|
|
78
|
+
compositionWarnings: resp.compositionWarnings,
|
|
79
|
+
deploymentErrors: resp.deploymentErrors,
|
|
80
|
+
spinner,
|
|
81
|
+
successMessage: (resp === null || resp === void 0 ? void 0 : resp.hasChanged) === false ? 'No new changes to publish.' : 'Feature subgraph published successfully.',
|
|
82
|
+
subgraphCompositionBaseErrorMessage: 'Feature subgraph published but with composition errors.',
|
|
83
|
+
subgraphCompositionDetailedErrorMessage: `We found composition errors, while composing the federated graph.\nThe router will continue to work with the latest valid schema.\n${pc.bold('Please check the errors below:')}`,
|
|
84
|
+
deploymentErrorMessage: `Feature subgraph was published, but the updated composition hasn't been deployed, so it's not accessible to the router. Check the errors listed below for details.`,
|
|
85
|
+
defaultErrorMessage: `Failed to publish feature subgraph "${name}".`,
|
|
86
|
+
shouldOutputJson: options.json,
|
|
87
|
+
suppressWarnings: options.suppressWarnings,
|
|
88
|
+
failOnCompositionError: options.failOnCompositionError,
|
|
89
|
+
failOnAdmissionWebhookError: options.failOnAdmissionWebhookError,
|
|
90
|
+
failOnCompositionErrorMessage: `The command failed due to composition errors.`,
|
|
91
|
+
failOnAdmissionWebhookErrorMessage: `The command failed due to admission webhook errors.`,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
process.exitCode = 1;
|
|
96
|
+
// eslint-disable-next-line no-useless-return
|
|
97
|
+
return;
|
|
185
98
|
}
|
|
186
99
|
});
|
|
187
100
|
return command;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../../../src/commands/feature-subgraph/commands/publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ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BAAiB,EAAE,IAAI,CAAC,iBAAiB;gBACzC,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;gBAC7C,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;gBACvC,OAAO;gBACP,cAAc,EACZ,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,MAAK,KAAK,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,0CAA0C;gBACxG,mCAAmC,EAAE,yDAAyD;gBAC9F,uCAAuC,EAAE,sIAAsI,EAAE,CAAC,IAAI,CACpL,gCAAgC,CACjC,EAAE;gBACH,sBAAsB,EAAE,oKAAoK;gBAC5L,mBAAmB,EAAE,uCAAuC,IAAI,IAAI;gBACpE,gBAAgB,EAAE,OAAO,CAAC,IAAI;gBAC9B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;gBAC1C,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;gBACtD,2BAA2B,EAAE,OAAO,CAAC,2BAA2B;gBAChE,6BAA6B,EAAE,+CAA+C;gBAC9E,kCAAkC,EAAE,qDAAqD;aAC1F,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,6CAA6C;YAC7C,OAAO;QACT,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CompositionError, DeploymentError } from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb.js';
|
|
1
|
+
import { CompositionError, CompositionWarning, DeploymentError } from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb.js';
|
|
2
2
|
import { Client } from '../client/client.js';
|
|
3
3
|
export interface BaseCommandOptions {
|
|
4
4
|
client: Client;
|
|
@@ -10,6 +10,7 @@ export type SubgraphCommandJsonOutput = {
|
|
|
10
10
|
status: 'success' | 'error';
|
|
11
11
|
compositionErrors: CompositionError[];
|
|
12
12
|
deploymentErrors: DeploymentError[];
|
|
13
|
+
compositionWarnings?: CompositionWarning[];
|
|
13
14
|
message: string;
|
|
14
15
|
details?: string;
|
|
15
16
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
|
|
2
2
|
import { Ora } from 'ora';
|
|
3
3
|
import { CompositionError, CompositionWarning, DeploymentError } from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
|
|
4
|
-
export declare const handleCompositionResult: ({ responseCode, responseDetails, compositionErrors, compositionWarnings, deploymentErrors, spinner, successMessage, subgraphCompositionBaseErrorMessage, subgraphCompositionDetailedErrorMessage, deploymentErrorMessage, defaultErrorMessage, shouldOutputJson, suppressWarnings, }: {
|
|
4
|
+
export declare const handleCompositionResult: ({ responseCode, responseDetails, compositionErrors, compositionWarnings, deploymentErrors, spinner, successMessage, subgraphCompositionBaseErrorMessage, subgraphCompositionDetailedErrorMessage, deploymentErrorMessage, defaultErrorMessage, shouldOutputJson, suppressWarnings, failOnCompositionError, failOnCompositionErrorMessage, failOnAdmissionWebhookError, failOnAdmissionWebhookErrorMessage, }: {
|
|
5
5
|
responseCode: EnumStatusCode | undefined;
|
|
6
6
|
responseDetails: string | undefined;
|
|
7
7
|
compositionErrors: CompositionError[];
|
|
@@ -15,4 +15,8 @@ export declare const handleCompositionResult: ({ responseCode, responseDetails,
|
|
|
15
15
|
defaultErrorMessage: string;
|
|
16
16
|
shouldOutputJson?: boolean;
|
|
17
17
|
suppressWarnings?: boolean;
|
|
18
|
+
failOnCompositionError?: boolean;
|
|
19
|
+
failOnCompositionErrorMessage?: string;
|
|
20
|
+
failOnAdmissionWebhookError?: boolean;
|
|
21
|
+
failOnAdmissionWebhookErrorMessage?: string;
|
|
18
22
|
}) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
|
|
2
2
|
import Table from 'cli-table3';
|
|
3
3
|
import pc from 'picocolors';
|
|
4
|
-
export const handleCompositionResult = ({ responseCode, responseDetails, compositionErrors, compositionWarnings, deploymentErrors, spinner, successMessage, subgraphCompositionBaseErrorMessage, subgraphCompositionDetailedErrorMessage, deploymentErrorMessage, defaultErrorMessage, shouldOutputJson, suppressWarnings, }) => {
|
|
4
|
+
export const handleCompositionResult = ({ responseCode, responseDetails, compositionErrors, compositionWarnings, deploymentErrors, spinner, successMessage, subgraphCompositionBaseErrorMessage, subgraphCompositionDetailedErrorMessage, deploymentErrorMessage, defaultErrorMessage, shouldOutputJson, suppressWarnings, failOnCompositionError, failOnCompositionErrorMessage, failOnAdmissionWebhookError, failOnAdmissionWebhookErrorMessage, }) => {
|
|
5
5
|
switch (responseCode) {
|
|
6
6
|
case EnumStatusCode.OK: {
|
|
7
7
|
if (shouldOutputJson) {
|
|
@@ -11,6 +11,9 @@ export const handleCompositionResult = ({ responseCode, responseDetails, composi
|
|
|
11
11
|
compositionErrors,
|
|
12
12
|
deploymentErrors,
|
|
13
13
|
};
|
|
14
|
+
if (!suppressWarnings) {
|
|
15
|
+
successMessageJson.compositionWarnings = compositionWarnings;
|
|
16
|
+
}
|
|
14
17
|
console.log(JSON.stringify(successMessageJson));
|
|
15
18
|
}
|
|
16
19
|
else {
|
|
@@ -26,6 +29,9 @@ export const handleCompositionResult = ({ responseCode, responseDetails, composi
|
|
|
26
29
|
compositionErrors,
|
|
27
30
|
deploymentErrors,
|
|
28
31
|
};
|
|
32
|
+
if (!suppressWarnings) {
|
|
33
|
+
compositionFailedMessageJson.compositionWarnings = compositionWarnings;
|
|
34
|
+
}
|
|
29
35
|
console.log(JSON.stringify(compositionFailedMessageJson));
|
|
30
36
|
}
|
|
31
37
|
else {
|
|
@@ -52,6 +58,10 @@ export const handleCompositionResult = ({ responseCode, responseDetails, composi
|
|
|
52
58
|
// Don't exit here with 1 because the change was still applied
|
|
53
59
|
console.log(compositionErrorsTable.toString());
|
|
54
60
|
}
|
|
61
|
+
if (failOnCompositionError) {
|
|
62
|
+
console.log(pc.red(pc.bold(failOnCompositionErrorMessage || 'The command failed due to composition errors.')));
|
|
63
|
+
throw new Error(failOnCompositionErrorMessage || 'The command failed due to composition errors.');
|
|
64
|
+
}
|
|
55
65
|
break;
|
|
56
66
|
}
|
|
57
67
|
case EnumStatusCode.ERR_DEPLOYMENT_FAILED: {
|
|
@@ -62,6 +72,9 @@ export const handleCompositionResult = ({ responseCode, responseDetails, composi
|
|
|
62
72
|
compositionErrors,
|
|
63
73
|
deploymentErrors,
|
|
64
74
|
};
|
|
75
|
+
if (!suppressWarnings) {
|
|
76
|
+
deploymentFailedMessageJson.compositionWarnings = compositionWarnings;
|
|
77
|
+
}
|
|
65
78
|
console.log(JSON.stringify(deploymentFailedMessageJson));
|
|
66
79
|
}
|
|
67
80
|
else {
|
|
@@ -85,6 +98,10 @@ export const handleCompositionResult = ({ responseCode, responseDetails, composi
|
|
|
85
98
|
// Don't exit here with 1 because the change was still applied
|
|
86
99
|
console.log(deploymentErrorsTable.toString());
|
|
87
100
|
}
|
|
101
|
+
if (failOnAdmissionWebhookError) {
|
|
102
|
+
console.log(pc.red(pc.bold(failOnAdmissionWebhookErrorMessage || 'The command failed due to admission webhook errors.')));
|
|
103
|
+
throw new Error(failOnAdmissionWebhookErrorMessage || 'The command failed due to admission webhook errors.');
|
|
104
|
+
}
|
|
88
105
|
break;
|
|
89
106
|
}
|
|
90
107
|
default: {
|
|
@@ -96,6 +113,9 @@ export const handleCompositionResult = ({ responseCode, responseDetails, composi
|
|
|
96
113
|
deploymentErrors,
|
|
97
114
|
details: responseDetails,
|
|
98
115
|
};
|
|
116
|
+
if (!suppressWarnings) {
|
|
117
|
+
defaultErrorMessageJson.compositionWarnings = compositionWarnings;
|
|
118
|
+
}
|
|
99
119
|
console.log(JSON.stringify(defaultErrorMessageJson));
|
|
100
120
|
}
|
|
101
121
|
else {
|
|
@@ -107,7 +127,7 @@ export const handleCompositionResult = ({ responseCode, responseDetails, composi
|
|
|
107
127
|
throw new Error(defaultErrorMessage);
|
|
108
128
|
}
|
|
109
129
|
}
|
|
110
|
-
if (!suppressWarnings && compositionWarnings.length > 0) {
|
|
130
|
+
if (!shouldOutputJson && !suppressWarnings && compositionWarnings.length > 0) {
|
|
111
131
|
const compositionWarningsTable = new Table({
|
|
112
132
|
head: [
|
|
113
133
|
pc.bold(pc.white('FEDERATED_GRAPH_NAME')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-composition-result.js","sourceRoot":"","sources":["../../src/handle-composition-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAGlF,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,MAAM,YAAY,CAAC;AAQ5B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EACtC,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,mCAAmC,EACnC,uCAAuC,EACvC,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"handle-composition-result.js","sourceRoot":"","sources":["../../src/handle-composition-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAGlF,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,MAAM,YAAY,CAAC;AAQ5B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EACtC,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,mCAAmC,EACnC,uCAAuC,EACvC,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,EAC3B,kCAAkC,GAmBnC,EA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