@sfdxy/anypoint-connect 0.16.3 → 0.17.0

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 (138) hide show
  1. package/README.md +17 -6
  2. package/dist/analysis/audit-actors.d.ts +36 -0
  3. package/dist/analysis/audit-actors.d.ts.map +1 -0
  4. package/dist/analysis/audit-actors.js +93 -0
  5. package/dist/analysis/audit-actors.js.map +1 -0
  6. package/dist/analysis/credentials.d.ts +49 -0
  7. package/dist/analysis/credentials.d.ts.map +1 -0
  8. package/dist/analysis/credentials.js +118 -0
  9. package/dist/analysis/credentials.js.map +1 -0
  10. package/dist/analysis/parser.d.ts +5 -0
  11. package/dist/analysis/parser.d.ts.map +1 -1
  12. package/dist/analysis/parser.js +10 -1
  13. package/dist/analysis/parser.js.map +1 -1
  14. package/dist/api/AlertsApi.d.ts +138 -0
  15. package/dist/api/AlertsApi.d.ts.map +1 -0
  16. package/dist/api/AlertsApi.js +168 -0
  17. package/dist/api/AlertsApi.js.map +1 -0
  18. package/dist/api/LogsApi.d.ts +14 -2
  19. package/dist/api/LogsApi.d.ts.map +1 -1
  20. package/dist/api/LogsApi.js +23 -12
  21. package/dist/api/LogsApi.js.map +1 -1
  22. package/dist/cli.js +2 -0
  23. package/dist/cli.js.map +1 -1
  24. package/dist/client/AnypointClient.d.ts +2 -0
  25. package/dist/client/AnypointClient.d.ts.map +1 -1
  26. package/dist/client/AnypointClient.js +3 -0
  27. package/dist/client/AnypointClient.js.map +1 -1
  28. package/dist/commands/alerts.d.ts +16 -0
  29. package/dist/commands/alerts.d.ts.map +1 -0
  30. package/dist/commands/alerts.js +358 -0
  31. package/dist/commands/alerts.js.map +1 -0
  32. package/dist/commands/api.d.ts.map +1 -1
  33. package/dist/commands/api.js +8 -3
  34. package/dist/commands/api.js.map +1 -1
  35. package/dist/commands/app-change-cli.d.ts +5 -2
  36. package/dist/commands/app-change-cli.d.ts.map +1 -1
  37. package/dist/commands/app-change-cli.js +19 -5
  38. package/dist/commands/app-change-cli.js.map +1 -1
  39. package/dist/commands/apps.d.ts.map +1 -1
  40. package/dist/commands/apps.js +26 -21
  41. package/dist/commands/apps.js.map +1 -1
  42. package/dist/commands/deploy.d.ts.map +1 -1
  43. package/dist/commands/deploy.js +17 -6
  44. package/dist/commands/deploy.js.map +1 -1
  45. package/dist/commands/index.d.ts +1 -0
  46. package/dist/commands/index.d.ts.map +1 -1
  47. package/dist/commands/index.js +1 -0
  48. package/dist/commands/index.js.map +1 -1
  49. package/dist/commands/logs.d.ts +1 -0
  50. package/dist/commands/logs.d.ts.map +1 -1
  51. package/dist/commands/logs.js +45 -0
  52. package/dist/commands/logs.js.map +1 -1
  53. package/dist/config/profiles.d.ts +10 -2
  54. package/dist/config/profiles.d.ts.map +1 -1
  55. package/dist/config/profiles.js +52 -21
  56. package/dist/config/profiles.js.map +1 -1
  57. package/dist/index.d.ts +8 -1
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +7 -0
  60. package/dist/index.js.map +1 -1
  61. package/dist/mcp/server.d.ts.map +1 -1
  62. package/dist/mcp/server.js +3 -2
  63. package/dist/mcp/server.js.map +1 -1
  64. package/dist/mcp/tools/alerts.d.ts +82 -0
  65. package/dist/mcp/tools/alerts.d.ts.map +1 -0
  66. package/dist/mcp/tools/alerts.js +409 -0
  67. package/dist/mcp/tools/alerts.js.map +1 -0
  68. package/dist/mcp/tools/api-manager.d.ts.map +1 -1
  69. package/dist/mcp/tools/api-manager.js +6 -1
  70. package/dist/mcp/tools/api-manager.js.map +1 -1
  71. package/dist/mcp/tools/app-inputs.d.ts +4 -2
  72. package/dist/mcp/tools/app-inputs.d.ts.map +1 -1
  73. package/dist/mcp/tools/app-inputs.js +14 -2
  74. package/dist/mcp/tools/app-inputs.js.map +1 -1
  75. package/dist/mcp/tools/apps-deploy.d.ts.map +1 -1
  76. package/dist/mcp/tools/apps-deploy.js +48 -12
  77. package/dist/mcp/tools/apps-deploy.js.map +1 -1
  78. package/dist/mcp/tools/apps-lifecycle.d.ts.map +1 -1
  79. package/dist/mcp/tools/apps-lifecycle.js +27 -12
  80. package/dist/mcp/tools/apps-lifecycle.js.map +1 -1
  81. package/dist/mcp/tools/audit.d.ts.map +1 -1
  82. package/dist/mcp/tools/audit.js +17 -4
  83. package/dist/mcp/tools/audit.js.map +1 -1
  84. package/dist/mcp/tools/exchange.d.ts.map +1 -1
  85. package/dist/mcp/tools/exchange.js +38 -18
  86. package/dist/mcp/tools/exchange.js.map +1 -1
  87. package/dist/mcp/tools/identity.d.ts.map +1 -1
  88. package/dist/mcp/tools/identity.js +4 -1
  89. package/dist/mcp/tools/identity.js.map +1 -1
  90. package/dist/mcp/tools/index.d.ts +1 -0
  91. package/dist/mcp/tools/index.d.ts.map +1 -1
  92. package/dist/mcp/tools/index.js +1 -0
  93. package/dist/mcp/tools/index.js.map +1 -1
  94. package/dist/mcp/tools/logs.d.ts +1 -1
  95. package/dist/mcp/tools/logs.d.ts.map +1 -1
  96. package/dist/mcp/tools/logs.js +34 -1
  97. package/dist/mcp/tools/logs.js.map +1 -1
  98. package/dist/mcp/tools/profile.d.ts +17 -3
  99. package/dist/mcp/tools/profile.d.ts.map +1 -1
  100. package/dist/mcp/tools/profile.js +122 -10
  101. package/dist/mcp/tools/profile.js.map +1 -1
  102. package/dist/mcp/tools/shared.d.ts +22 -2
  103. package/dist/mcp/tools/shared.d.ts.map +1 -1
  104. package/dist/mcp/tools/shared.js +29 -4
  105. package/dist/mcp/tools/shared.js.map +1 -1
  106. package/dist/safety/artifact.d.ts +45 -0
  107. package/dist/safety/artifact.d.ts.map +1 -1
  108. package/dist/safety/artifact.js +109 -0
  109. package/dist/safety/artifact.js.map +1 -1
  110. package/dist/safety/guards.d.ts +10 -0
  111. package/dist/safety/guards.d.ts.map +1 -1
  112. package/dist/safety/guards.js +16 -0
  113. package/dist/safety/guards.js.map +1 -1
  114. package/dist/safety/preapproval.d.ts +102 -0
  115. package/dist/safety/preapproval.d.ts.map +1 -0
  116. package/dist/safety/preapproval.js +251 -0
  117. package/dist/safety/preapproval.js.map +1 -0
  118. package/dist/safety/secrets.d.ts +7 -0
  119. package/dist/safety/secrets.d.ts.map +1 -1
  120. package/dist/safety/secrets.js +16 -0
  121. package/dist/safety/secrets.js.map +1 -1
  122. package/dist/workflows/alerts.d.ts +299 -0
  123. package/dist/workflows/alerts.d.ts.map +1 -0
  124. package/dist/workflows/alerts.js +595 -0
  125. package/dist/workflows/alerts.js.map +1 -0
  126. package/dist/workflows/app-change.d.ts +25 -1
  127. package/dist/workflows/app-change.d.ts.map +1 -1
  128. package/dist/workflows/app-change.js +22 -1
  129. package/dist/workflows/app-change.js.map +1 -1
  130. package/dist/workflows/artifact-verification.d.ts +52 -0
  131. package/dist/workflows/artifact-verification.d.ts.map +1 -0
  132. package/dist/workflows/artifact-verification.js +85 -0
  133. package/dist/workflows/artifact-verification.js.map +1 -0
  134. package/dist/workflows/jar-deployment.d.ts +36 -10
  135. package/dist/workflows/jar-deployment.d.ts.map +1 -1
  136. package/dist/workflows/jar-deployment.js +40 -12
  137. package/dist/workflows/jar-deployment.js.map +1 -1
  138. package/package.json +1 -1
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Production policy: pre-approvals and unmarked-artifact allowances
3
+ *
4
+ * Both live only in the user-level store, ~/.anypoint-connect/production-approvals.json, outside any
5
+ * repository, so a branch cannot plant or widen one. Every entry is bound to a resolved organization
6
+ * ID and environment ID; names are kept for display only and never matched. A `productionPreapproval`
7
+ * found in a project's .anypoint-connect.json is ignored and reported.
8
+ *
9
+ * {
10
+ * "productionPreapprovals": [
11
+ * { "orgId": "...", "environmentId": "...", "environmentName": "Production",
12
+ * "tools": ["update_app"] | "all-mutating", "expires": "2026-12-31T00:00:00Z", "projectPath": "/abs/repo" }
13
+ * ],
14
+ * "unmarkedArtifactAllowances": [
15
+ * { "orgId": "...", "environmentId": "...", "environmentName": "Production", "expires": "...", "projectPath": "..." }
16
+ * ]
17
+ * }
18
+ *
19
+ * A pre-approval stands in for confirmProduction (MCP) and the typed phrase (CLI). An allowance lets
20
+ * jars without a build marker go to that environment. Neither waives confirm: true, bound IDs,
21
+ * digests, or the refusal of a jar marked not production deployable.
22
+ */
23
+ import * as fs from 'node:fs';
24
+ import * as path from 'node:path';
25
+ import { discoverProjectConfig, findProjectConfigFile, getConfigDir } from '../config/profiles.js';
26
+ import { resolveProjectRoot } from './paths.js';
27
+ /** Tools whose production confirmation can be pre-approved. The CLI uses the same names. */
28
+ export const PREAPPROVABLE_TOOLS = [
29
+ 'deploy_jar',
30
+ 'deploy_app',
31
+ 'update_app',
32
+ 'update_app_artifact',
33
+ 'rollback_app',
34
+ 'update_app_settings',
35
+ 'restart_app',
36
+ 'scale_app',
37
+ 'stop_app',
38
+ 'start_app',
39
+ 'smoke_test_api',
40
+ 'delete_app',
41
+ 'create_alert',
42
+ 'update_alert',
43
+ 'set_alert_enabled',
44
+ 'delete_alert',
45
+ ];
46
+ export const ALL_MUTATING = 'all-mutating';
47
+ /** Tools that "all-mutating" does not cover; they are pre-approved only when named. */
48
+ export const NAMED_ONLY_TOOLS = ['delete_app', 'delete_alert'];
49
+ export const APPROVALS_FILE_NAME = 'production-approvals.json';
50
+ /** The user-level store path. */
51
+ export function approvalsFile() {
52
+ return path.join(getConfigDir(), APPROVALS_FILE_NAME);
53
+ }
54
+ function validateScope(input, errors) {
55
+ const { orgId, environmentId, environmentName, expires, projectPath } = input;
56
+ for (const [name, value] of [
57
+ ['orgId', orgId],
58
+ ['environmentId', environmentId],
59
+ ]) {
60
+ if (typeof value !== 'string' || !value.trim())
61
+ errors.push(`${name} must be a non-empty ID`);
62
+ else if (/[*?]/.test(value))
63
+ errors.push(`${name}: wildcards are not allowed`);
64
+ }
65
+ if (environmentName !== undefined && typeof environmentName !== 'string')
66
+ errors.push('environmentName must be a string');
67
+ if (expires !== undefined && (typeof expires !== 'string' || Number.isNaN(Date.parse(expires)))) {
68
+ errors.push('expires must be an ISO 8601 date-time');
69
+ }
70
+ if (projectPath !== undefined && (typeof projectPath !== 'string' || !path.isAbsolute(projectPath))) {
71
+ errors.push('projectPath must be an absolute path');
72
+ }
73
+ return {
74
+ orgId: orgId,
75
+ environmentId: environmentId,
76
+ ...(environmentName !== undefined ? { environmentName: environmentName } : {}),
77
+ ...(expires !== undefined ? { expires: expires } : {}),
78
+ ...(projectPath !== undefined ? { projectPath: projectPath } : {}),
79
+ };
80
+ }
81
+ function asObject(input, what) {
82
+ if (!input || typeof input !== 'object' || Array.isArray(input))
83
+ throw new Error(`${what} must be an object`);
84
+ return input;
85
+ }
86
+ function rejectUnknown(input, allowed, errors) {
87
+ const unknown = Object.keys(input).filter((key) => !allowed.includes(key));
88
+ if (unknown.length)
89
+ errors.push(`unknown fields: ${unknown.join(', ')}`);
90
+ }
91
+ const SCOPE_FIELDS = ['orgId', 'environmentId', 'environmentName', 'expires', 'projectPath'];
92
+ /** Validate one pre-approval entry. Throws with every problem found. */
93
+ export function validatePreapproval(input) {
94
+ const object = asObject(input, 'A production pre-approval');
95
+ const errors = [];
96
+ rejectUnknown(object, [...SCOPE_FIELDS, 'tools'], errors);
97
+ const scope = validateScope(object, errors);
98
+ const { tools } = object;
99
+ if (tools !== ALL_MUTATING) {
100
+ if (!Array.isArray(tools) || tools.length === 0) {
101
+ errors.push(`tools must be "${ALL_MUTATING}" or a non-empty list of tool names`);
102
+ }
103
+ else {
104
+ for (const tool of tools) {
105
+ if (!PREAPPROVABLE_TOOLS.includes(tool)) {
106
+ errors.push(`"${String(tool)}" is not a pre-approvable tool (${PREAPPROVABLE_TOOLS.join(', ')})`);
107
+ }
108
+ }
109
+ }
110
+ }
111
+ if (errors.length)
112
+ throw new Error(`Invalid production pre-approval:\n- ${errors.join('\n- ')}`);
113
+ return { ...scope, tools: tools === ALL_MUTATING ? ALL_MUTATING : [...new Set(tools)] };
114
+ }
115
+ /** Validate one unmarked-artifact allowance. Throws with every problem found. */
116
+ export function validateUnmarkedAllowance(input) {
117
+ const object = asObject(input, 'An unmarked-artifact allowance');
118
+ const errors = [];
119
+ rejectUnknown(object, SCOPE_FIELDS, errors);
120
+ const scope = validateScope(object, errors);
121
+ if (errors.length)
122
+ throw new Error(`Invalid unmarked-artifact allowance:\n- ${errors.join('\n- ')}`);
123
+ return scope;
124
+ }
125
+ function readRawStore(file) {
126
+ if (!fs.existsSync(file))
127
+ return { store: {}, invalid: [] };
128
+ try {
129
+ const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
130
+ return { store: asObject(parsed, file), invalid: [] };
131
+ }
132
+ catch (error) {
133
+ return { store: {}, invalid: [`${file} is unreadable: ${error.message}`] };
134
+ }
135
+ }
136
+ /** Read and validate the user-level store. */
137
+ export function readApprovalState(options = {}) {
138
+ const source = approvalsFile();
139
+ const { store, invalid } = readRawStore(source);
140
+ const now = options.now ?? Date.now();
141
+ const expired = (expires) => expires !== undefined && Date.parse(expires) <= now;
142
+ const state = { source, productionPreapprovals: [], unmarkedArtifactAllowances: [], invalid };
143
+ for (const item of Array.isArray(store.productionPreapprovals) ? store.productionPreapprovals : []) {
144
+ try {
145
+ const entry = validatePreapproval(item);
146
+ state.productionPreapprovals.push({ ...entry, expired: expired(entry.expires) });
147
+ }
148
+ catch (error) {
149
+ state.invalid.push(error.message);
150
+ }
151
+ }
152
+ for (const item of Array.isArray(store.unmarkedArtifactAllowances) ? store.unmarkedArtifactAllowances : []) {
153
+ try {
154
+ const entry = validateUnmarkedAllowance(item);
155
+ state.unmarkedArtifactAllowances.push({ ...entry, expired: expired(entry.expires) });
156
+ }
157
+ catch (error) {
158
+ state.invalid.push(error.message);
159
+ }
160
+ }
161
+ return state;
162
+ }
163
+ function sameScope(a, b) {
164
+ return a.orgId === b.orgId && a.environmentId === b.environmentId && a.projectPath === b.projectPath;
165
+ }
166
+ /** Replace (or, with `entry` null, remove) the entry with the same org, environment and project. */
167
+ function upsert(list, scope, entry) {
168
+ const rest = (list ?? []).filter((item) => !sameScope(item, scope));
169
+ return entry ? [...rest, entry] : rest;
170
+ }
171
+ function writeStore(update) {
172
+ const file = approvalsFile();
173
+ const { store, invalid } = readRawStore(file);
174
+ if (invalid.length)
175
+ throw new Error(`${invalid[0]}; fix or remove it first`);
176
+ fs.writeFileSync(file, JSON.stringify(update(store), null, 2) + '\n', { mode: 0o600 });
177
+ fs.chmodSync(file, 0o600);
178
+ return file;
179
+ }
180
+ /** Store a pre-approval (replacing one with the same scope), or remove it when `entry` is null. */
181
+ export function savePreapproval(scope, entry) {
182
+ const valid = entry ? validatePreapproval(entry) : null;
183
+ return writeStore((store) => ({
184
+ ...store,
185
+ productionPreapprovals: upsert(store.productionPreapprovals, scope, valid),
186
+ }));
187
+ }
188
+ /** Store an unmarked-artifact allowance (replacing one with the same scope), or remove it. */
189
+ export function saveUnmarkedAllowance(scope, entry) {
190
+ const valid = entry ? validateUnmarkedAllowance(entry) : null;
191
+ return writeStore((store) => ({
192
+ ...store,
193
+ unmarkedArtifactAllowances: upsert(store.unmarkedArtifactAllowances, scope, valid),
194
+ }));
195
+ }
196
+ function coversTool(entry, tool) {
197
+ if (entry.tools === ALL_MUTATING) {
198
+ return (PREAPPROVABLE_TOOLS.includes(tool) &&
199
+ !NAMED_ONLY_TOOLS.includes(tool));
200
+ }
201
+ return entry.tools.includes(tool);
202
+ }
203
+ function matcher(target, options) {
204
+ let root = options.projectRoot;
205
+ const projectMatches = (projectPath) => {
206
+ if (!projectPath)
207
+ return true;
208
+ root ??= resolveProjectRoot();
209
+ return path.resolve(projectPath) === path.resolve(root);
210
+ };
211
+ return (entry) => !entry.expired &&
212
+ entry.orgId === target.orgId &&
213
+ entry.environmentId === target.env.id &&
214
+ projectMatches(entry.projectPath);
215
+ }
216
+ /** Whether a production write by `tool` to the target org and environment is pre-approved. */
217
+ export function checkPreapproval(target, tool, options = {}) {
218
+ const state = options.state ?? readApprovalState(options);
219
+ const inScope = matcher(target, options);
220
+ const match = state.productionPreapprovals.find((e) => inScope(e) && coversTool(e, tool));
221
+ if (!match)
222
+ return { productionPreapproved: false };
223
+ return {
224
+ productionPreapproved: true,
225
+ preapprovalSource: `${state.source} productionPreapprovals`,
226
+ ...(match.expires ? { preapprovalExpires: match.expires } : {}),
227
+ };
228
+ }
229
+ /** Whether jars without a build marker may go to the target org and environment. */
230
+ export function checkUnmarkedAllowance(target, options = {}) {
231
+ const state = options.state ?? readApprovalState(options);
232
+ const match = state.unmarkedArtifactAllowances.find(matcher(target, options));
233
+ if (!match)
234
+ return { unmarkedAllowed: false };
235
+ return {
236
+ unmarkedAllowed: true,
237
+ source: `${state.source} unmarkedArtifactAllowances`,
238
+ ...(match.expires ? { expires: match.expires } : {}),
239
+ };
240
+ }
241
+ /** A warning when the project's .anypoint-connect.json carries an approval, which is never honored. */
242
+ export function ignoredProjectApprovalWarning(startDir) {
243
+ const config = discoverProjectConfig(startDir);
244
+ if (!config)
245
+ return undefined;
246
+ const keys = ['productionPreapproval', 'productionPreapprovals', 'unmarkedArtifactAllowances'].filter((key) => config[key] !== undefined);
247
+ if (!keys.length)
248
+ return undefined;
249
+ return `${findProjectConfigFile(startDir)} contains ${keys.join(', ')}, which is ignored: production approvals are read only from ${approvalsFile()}`;
250
+ }
251
+ //# sourceMappingURL=preapproval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preapproval.js","sourceRoot":"","sources":["../../src/safety/preapproval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,4FAA4F;AAC5F,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,qBAAqB;IACrB,cAAc;IACd,qBAAqB;IACrB,aAA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;AACN,CAAC;AAQD,oFAAoF;AACpF,MAAM,UAAU,sBAAsB,CAAC,MAAoB,EAAE,UAAwB,EAAE;IACnF,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,KAAK,CAAC,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9E,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;IAC9C,OAAO;QACH,eAAe,EAAE,IAAI;QACrB,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,6BAA6B;QACpD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvD,CAAC;AACN,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,6BAA6B,CAAC,QAAiB;IAC3D,MAAM,MAAM,GAAG,qBAAqB,CAAC,QAAQ,CAAmC,CAAC;IACjF,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,MAAM,IAAI,GAAG,CAAC,uBAAuB,EAAE,wBAAwB,EAAE,4BAA4B,CAAC,CAAC,MAAM,CACjG,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,CACrC,CAAC;IACF,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IACnC,OAAO,GAAG,qBAAqB,CAAC,QAAQ,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,+DAA+D,aAAa,EAAE,EAAE,CAAC;AAC1J,CAAC"}
@@ -29,4 +29,11 @@ export declare function redactDeep(value: unknown, depth?: number): unknown;
29
29
  * characters are skipped because they would match ordinary text.
30
30
  */
31
31
  export declare function redactText(text: string, knownSecrets: Iterable<string>): string;
32
+ /**
33
+ * Sanitize free text a platform echoed back (an error message), when its secrets are not known in
34
+ * advance: email addresses keep only their domain, and credential-looking values are masked (JWTs,
35
+ * bearer tokens, Salesforce session IDs, `secret=value` pairs, and long opaque strings). UUIDs, which
36
+ * identify resources, are kept.
37
+ */
38
+ export declare function sanitizePlatformText(text: string): string;
32
39
  //# sourceMappingURL=secrets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/safety/secrets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8EAA8E;AAC9E,eAAO,MAAM,MAAM,WAAW,CAAC;AAuB/B;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAWhD;AAED,sGAAsG;AACtG,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;CAAO,GAO7F,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAC9B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CAY7D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,CAM/E"}
1
+ {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/safety/secrets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8EAA8E;AAC9E,eAAO,MAAM,MAAM,WAAW,CAAC;AAuB/B;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAWhD;AAED,sGAAsG;AACtG,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;CAAO,GAO7F,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAC9B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CAY7D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,CAM/E;AAID;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWzD"}
@@ -88,4 +88,20 @@ export function redactText(text, knownSecrets) {
88
88
  result = result.split(value).join(MASKED);
89
89
  return result;
90
90
  }
91
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
92
+ /**
93
+ * Sanitize free text a platform echoed back (an error message), when its secrets are not known in
94
+ * advance: email addresses keep only their domain, and credential-looking values are masked (JWTs,
95
+ * bearer tokens, Salesforce session IDs, `secret=value` pairs, and long opaque strings). UUIDs, which
96
+ * identify resources, are kept.
97
+ */
98
+ export function sanitizePlatformText(text) {
99
+ return text
100
+ .replace(/[A-Za-z0-9._%+-]+@([A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+)/g, '***@$1')
101
+ .replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/g, MASKED)
102
+ .replace(/\b(bearer)\s+[A-Za-z0-9._~+/=-]+/gi, `$1 ${MASKED}`)
103
+ .replace(/\b00D[A-Za-z0-9]{12,15}![A-Za-z0-9._]+/g, MASKED)
104
+ .replace(/\b((?:password|passwd|secret|token|api[_-]?key|access[_-]?key|client[_-]?secret|credential)s?["']?\s*[:=]\s*["']?)[^\s"',;&]+/gi, `$1${MASKED}`)
105
+ .replace(/[A-Za-z0-9+/_=-]{32,}/g, (match) => (UUID.test(match) ? match : MASKED));
106
+ }
91
107
  //# sourceMappingURL=secrets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/safety/secrets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAE/B,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC5B,UAAU;IACV,QAAQ;IACR,KAAK;IACL,QAAQ;IACR,OAAO;IACP,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,QAAQ;IACR,YAAY;IACZ,cAAc;CACjB,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG;IACjB,CAAC,SAAS,EAAE,KAAK,CAAC;IAClB,CAAC,KAAK,EAAE,KAAK,CAAC;IACd,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,QAAQ,EAAE,KAAK,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACnC,MAAM,QAAQ,GAAG,GAAG;SACf,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,WAAW,EAAE;SACb,KAAK,CAAC,aAAa,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC,CAAC;IACrB,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC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,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3F,CAAC"}
@@ -0,0 +1,299 @@
1
+ /**
2
+ * Alert workflows
3
+ * Shared by the alert MCP tools and `anc alerts`: normalizing alerts for display (recipients masked by
4
+ * default), turning human inputs (percent thresholds, minutes, explicit notifications) into the
5
+ * platform's payload, resolving the target from CloudHub 2.0 or API Manager, duplicate detection,
6
+ * and the get-merge-replace update the platform requires.
7
+ */
8
+ import type { AnypointClient } from '../client/AnypointClient.js';
9
+ import type { Environment } from '../api/AccessManagementApi.js';
10
+ import { type AlertEntity, type AlertMetricId, type AlertNotification, type AlertOperator, type AlertWriteBody, type MonitoringAlert, type RuntimeManagerAlert } from '../api/AlertsApi.js';
11
+ export type MetricUnit = 'percent' | 'count' | 'ms';
12
+ export interface MetricInfo {
13
+ unit: MetricUnit;
14
+ entityType: 'application' | 'api';
15
+ aggregation: 'AVG' | 'SUM';
16
+ /** An API filter this metric needs. */
17
+ requires?: 'RESPONSE_CODE' | 'POLICY';
18
+ }
19
+ /** Every metric an alert can watch, in one table. */
20
+ export declare const ALERT_METRICS: Record<AlertMetricId, MetricInfo>;
21
+ export declare const MAX_DURATION_MINUTES = 60;
22
+ export interface RecipientSummary {
23
+ recipientCount: number;
24
+ /** Email domains only, never addresses. */
25
+ recipientDomains: string[];
26
+ slackChannels: number;
27
+ }
28
+ export declare function summarizeRecipients(notifications?: AlertNotification[]): RecipientSummary;
29
+ /**
30
+ * Notifications as written back: the read side (`notificationTemplates`) under the write name, with
31
+ * every field the platform returned kept, including ones this tool does not know.
32
+ */
33
+ export declare function notificationsOf(alert: MonitoringAlert): AlertNotification[];
34
+ /** Which aspects of the notifications differ, by name only, so a masked diff still says what changed. */
35
+ export declare function notificationDifferences(before: AlertNotification[], after: AlertNotification[]): string[];
36
+ /**
37
+ * A recipient summary for display. Domains can identify clients, so they are shown only with `reveal`;
38
+ * otherwise only the counts.
39
+ */
40
+ export declare function displayRecipients(notifications: AlertNotification[], reveal?: boolean): {
41
+ recipientCount: number;
42
+ slackChannels: number;
43
+ } | {
44
+ recipientDomains: string[];
45
+ recipientCount: number;
46
+ slackChannels: number;
47
+ };
48
+ /** Notifications for display: masked to counts unless `reveal`. */
49
+ export declare function describeNotifications(notifications: AlertNotification[], reveal?: boolean): AlertNotification[];
50
+ /** The Monitoring UI's levels: the stored number is the index. */
51
+ export declare const SEVERITY_LABELS: readonly ["LOW", "MEDIUM", "HIGH", "CRITICAL"];
52
+ export type SeverityLabel = (typeof SEVERITY_LABELS)[number];
53
+ /** A severity given as 0-3 or a label (LOW, MEDIUM, HIGH, CRITICAL), as the stored number. */
54
+ export declare function parseSeverity(input: number | string): number;
55
+ /** One label for any family's severity: a Monitoring number, or a word such as INFO or warning. */
56
+ export declare function severityLabel(value: unknown): string | undefined;
57
+ export declare function windowMinutes(interval: string | undefined): number | undefined;
58
+ export declare function metricInfo(metric: string): MetricInfo | undefined;
59
+ /** A stored threshold in the unit people use: percent metrics are stored as fractions. */
60
+ export declare function displayThreshold(metric: string, stored: number): number;
61
+ export type AlertSource = 'monitoring' | 'runtime-manager';
62
+ export declare function normalizeAlert(alert: MonitoringAlert, options?: {
63
+ reveal?: boolean;
64
+ }): {
65
+ notifications?: AlertNotification[] | undefined;
66
+ recipientCount: number;
67
+ slackChannels: number;
68
+ id: string;
69
+ source: AlertSource;
70
+ name: string;
71
+ enabled: boolean;
72
+ severity: string | undefined;
73
+ severityLevel: number;
74
+ status: import("../api/AlertsApi.js").AlertStatus | undefined;
75
+ state: string | undefined;
76
+ entity: {
77
+ deploymentType: import("../api/AlertsApi.js").AlertDeploymentType | undefined;
78
+ environment: string;
79
+ environmentId: string;
80
+ apiInstanceId?: string | undefined;
81
+ type: import("../api/AlertsApi.js").AlertEntityType;
82
+ name: string | undefined;
83
+ };
84
+ condition: {
85
+ metric: string;
86
+ operator: "GREATER_THAN" | "LESS_THAN" | "GREATER_THAN_EQUAL_TO" | "LESS_THAN_EQUAL_TO" | "EQUALS";
87
+ threshold: number | undefined;
88
+ unit: MetricUnit | undefined;
89
+ windowMinutes: number | undefined;
90
+ };
91
+ } | {
92
+ notifications?: AlertNotification[] | undefined;
93
+ recipientDomains: string[];
94
+ recipientCount: number;
95
+ slackChannels: number;
96
+ id: string;
97
+ source: AlertSource;
98
+ name: string;
99
+ enabled: boolean;
100
+ severity: string | undefined;
101
+ severityLevel: number;
102
+ status: import("../api/AlertsApi.js").AlertStatus | undefined;
103
+ state: string | undefined;
104
+ entity: {
105
+ deploymentType: import("../api/AlertsApi.js").AlertDeploymentType | undefined;
106
+ environment: string;
107
+ environmentId: string;
108
+ apiInstanceId?: string | undefined;
109
+ type: import("../api/AlertsApi.js").AlertEntityType;
110
+ name: string | undefined;
111
+ };
112
+ condition: {
113
+ metric: string;
114
+ operator: "GREATER_THAN" | "LESS_THAN" | "GREATER_THAN_EQUAL_TO" | "LESS_THAN_EQUAL_TO" | "EQUALS";
115
+ threshold: number | undefined;
116
+ unit: MetricUnit | undefined;
117
+ windowMinutes: number | undefined;
118
+ };
119
+ };
120
+ /** Whether a Runtime Manager alert targets an app: membership in its resources, case-insensitive. */
121
+ export declare function targetsApp(resources: readonly string[] | undefined, app: string): boolean;
122
+ /**
123
+ * View of a Runtime Manager event alert (deployment failed and similar). Observed shape:
124
+ * condition{type, resourceType, resources[]}, actions[]{type, userIds[], emails[], subject, content},
125
+ * plus conditionType, isSystem and productName.
126
+ */
127
+ export declare function normalizeRuntimeManagerAlert(alert: RuntimeManagerAlert, options?: {
128
+ reveal?: boolean;
129
+ }): {
130
+ recipientDomains?: string[] | undefined;
131
+ actions?: {
132
+ type: unknown;
133
+ emails: string[];
134
+ userIds: string[];
135
+ }[] | undefined;
136
+ recipientCount: number;
137
+ productName?: string | number | undefined;
138
+ isSystem?: boolean | undefined;
139
+ conditionType?: string | number | undefined;
140
+ id: string | number | undefined;
141
+ source: AlertSource;
142
+ name: string | number | undefined;
143
+ enabled: boolean | undefined;
144
+ severity: string | undefined;
145
+ status: string | number | undefined;
146
+ state: string | number | undefined;
147
+ entity: {
148
+ type: string | number | undefined;
149
+ name: string | undefined;
150
+ /** Every target, for filtering by membership. */
151
+ resources: string[];
152
+ };
153
+ condition: {
154
+ event: string | number | undefined;
155
+ };
156
+ };
157
+ export type NotificationInput = {
158
+ type: 'EMAIL';
159
+ recipients: string[];
160
+ subject: string;
161
+ message: string;
162
+ } | {
163
+ type: 'SLACK';
164
+ channelId: string;
165
+ carrierId?: string;
166
+ message: string;
167
+ };
168
+ /** Turn explicit notification inputs into the platform shape. At least one is required; there are no defaults. */
169
+ export declare function buildNotifications(inputs: NotificationInput[] | undefined): AlertNotification[];
170
+ /** Convert and validate a threshold given in the metric's unit (percent for % metrics). */
171
+ export declare function storedThreshold(metric: AlertMetricId, value: number): number;
172
+ export declare function evaluationInterval(durationMinutes: number): string;
173
+ export declare const checkSeverity: typeof parseSeverity;
174
+ export interface ApiFilterInput {
175
+ responseCodes?: string[];
176
+ policies?: string[];
177
+ }
178
+ export type AlertTarget = {
179
+ app: string;
180
+ } | {
181
+ apiInstanceId: string;
182
+ };
183
+ export interface CreateAlertInput {
184
+ environment: string;
185
+ name: string;
186
+ target: AlertTarget;
187
+ metric: AlertMetricId;
188
+ operator: AlertOperator;
189
+ /** In the metric's unit: percent (0-100] for cpu and memory, a count, or milliseconds. */
190
+ threshold: number;
191
+ durationMinutes: number;
192
+ /** 0-3, or LOW, MEDIUM, HIGH, CRITICAL. */
193
+ severity: number | string;
194
+ enabled?: boolean;
195
+ notifications: NotificationInput[];
196
+ apiFilters?: ApiFilterInput;
197
+ allowDuplicate?: boolean;
198
+ }
199
+ /** Resolve the alert entity from CloudHub 2.0 (an app) or API Manager (an API instance). */
200
+ export declare function resolveAlertEntity(client: AnypointClient, orgId: string, env: Pick<Environment, 'id' | 'name'>, target: AlertTarget, metric: AlertMetricId, filters?: ApiFilterInput): Promise<AlertEntity>;
201
+ export declare function sameEntity(a: AlertEntity | undefined, b: AlertEntity): boolean;
202
+ /** Recipients outside the user's own email domain, as domains. The user's address is never returned. */
203
+ export declare function outsideDomains(notifications: AlertNotification[], userEmail: string | undefined): string[];
204
+ export interface CreateAlertPlan {
205
+ orgId: string;
206
+ env: Environment;
207
+ body: AlertWriteBody;
208
+ warnings: string[];
209
+ /** An existing alert with the same name on the same entity. */
210
+ duplicate?: {
211
+ id: string;
212
+ name: string;
213
+ status?: string;
214
+ };
215
+ }
216
+ /**
217
+ * The create payload for a preview. For an API target only the instance ID the caller passed is shown;
218
+ * the API name and endpoint resolved from API Manager are sent but not printed.
219
+ */
220
+ export declare function previewPayload(body: AlertWriteBody): AlertWriteBody;
221
+ export declare function planCreateAlert(client: AnypointClient, input: CreateAlertInput, options?: {
222
+ enableHint?: string;
223
+ }): Promise<CreateAlertPlan>;
224
+ export interface AlertPatch {
225
+ name?: string;
226
+ /** 0-3, or LOW, MEDIUM, HIGH, CRITICAL. */
227
+ severity?: number | string;
228
+ enabled?: boolean;
229
+ operator?: AlertOperator;
230
+ /** In the metric's unit, as for create. */
231
+ threshold?: number;
232
+ durationMinutes?: number;
233
+ /** Replaces every notification. */
234
+ notifications?: NotificationInput[];
235
+ }
236
+ export interface AlertChange {
237
+ field: string;
238
+ from: unknown;
239
+ to: unknown;
240
+ /** For notifications: which parts differ (recipients, subject, messageTemplate, channelId, ...). */
241
+ differs?: string[];
242
+ }
243
+ export interface UpdateAlertPlan {
244
+ orgId: string;
245
+ env: Environment;
246
+ existing: MonitoringAlert;
247
+ body: AlertWriteBody;
248
+ changes: AlertChange[];
249
+ noop: boolean;
250
+ }
251
+ export declare function loadAlert(client: AnypointClient, orgId: string, id: string): Promise<MonitoringAlert>;
252
+ /** The environment an alert belongs to, for production checks. */
253
+ export declare function alertEnvironment(client: AnypointClient, orgId: string, alert: MonitoringAlert): Promise<Environment>;
254
+ /** Read the alert, merge the patch, and build the full replacement body the platform needs. */
255
+ export declare function planUpdateAlert(client: AnypointClient, id: string, patch: AlertPatch): Promise<UpdateAlertPlan>;
256
+ /**
257
+ * Find an alert in the list, narrowed by environment and name so the listing stays small. `complete`
258
+ * is false when the listing hit its page cap; absence from an incomplete listing proves nothing.
259
+ */
260
+ export declare function findListedAlert(client: AnypointClient, orgId: string, alert: {
261
+ id: string;
262
+ name?: string;
263
+ environmentId?: string;
264
+ }): Promise<{
265
+ alert?: MonitoringAlert;
266
+ complete: boolean;
267
+ }>;
268
+ export interface UpdateAlertResult {
269
+ accepted: true;
270
+ /** True only when the listed alert is ACTIVE and carries the new values. */
271
+ verified: boolean;
272
+ status: 'ACTIVE' | 'PENDING' | 'UNVERIFIED';
273
+ message: string;
274
+ }
275
+ /**
276
+ * Send the full replacement, then re-read the alert from the list once. The platform answers 202 and
277
+ * applies the change asynchronously, so "updated" is claimed only when the list shows it applied.
278
+ */
279
+ export declare function executeUpdateAlert(client: AnypointClient, plan: Pick<UpdateAlertPlan, 'orgId' | 'existing' | 'body'>): Promise<UpdateAlertResult>;
280
+ export interface DeleteAlertResult {
281
+ accepted: boolean;
282
+ /** PENDING while the platform deletes it; GONE once the complete list no longer shows it. */
283
+ status: 'PENDING' | 'ACTIVE' | 'DELETED' | 'GONE' | 'UNVERIFIED';
284
+ verifiedAbsent: boolean;
285
+ message: string;
286
+ }
287
+ export declare const CHANGE_IN_PROGRESS = "A change to this alert is in progress (PENDING); the platform refuses changes and deletion until it finishes. Retry later.";
288
+ /**
289
+ * Read an alert for deletion. The list is fresher than GET right after a change (GET can keep
290
+ * answering ACTIVE, or 404 while the list still shows PENDING), so the listed entry wins.
291
+ */
292
+ export declare function readAlertForDelete(client: AnypointClient, orgId: string, id: string): Promise<MonitoringAlert | null>;
293
+ /**
294
+ * Request deletion, then verify it from the list. Never claims deleted while the list still shows the
295
+ * alert, or when the listing was cut off. A 404 on DELETE with the alert absent from a complete
296
+ * listing means it is already gone.
297
+ */
298
+ export declare function executeDeleteAlert(client: AnypointClient, orgId: string, alert: Pick<MonitoringAlert, 'id' | 'name' | 'entity'>): Promise<DeleteAlertResult>;
299
+ //# sourceMappingURL=alerts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alerts.d.ts","sourceRoot":"","sources":["../../src/workflows/alerts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAEH,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAC3B,MAAM,qBAAqB,CAAC;AAE7B,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,IAAI,CAAC;AAEpD,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,aAAa,GAAG,KAAK,CAAC;IAClC,WAAW,EAAE,KAAK,GAAG,KAAK,CAAC;IAC3B,uCAAuC;IACvC,QAAQ,CAAC,EAAE,eAAe,GAAG,QAAQ,CAAC;CACzC;AAED,qDAAqD;AACrD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,UAAU,CAW3D,CAAC;AAEF,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAIvC,MAAM,WAAW,gBAAgB;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,2CAA2C;IAC3C,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;CACzB;AAOD,wBAAgB,mBAAmB,CAAC,aAAa,GAAE,iBAAiB,EAAO,GAAG,gBAAgB,CAO7F;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,iBAAiB,EAAE,CAK3E;AAcD,yGAAyG;AACzG,wB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