rawsql-ts 0.25.0 → 0.26.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.
@@ -77,6 +77,8 @@ export * from './transformers/FilterableItemCollector';
77
77
  export { FixtureCteBuilder, FixtureTableDefinition, FixtureColumnDefinition } from './transformers/FixtureCteBuilder';
78
78
  export * from './transformers/DynamicQueryBuilder';
79
79
  export * from './transformers/SSSQLFilterBuilder';
80
+ export * from './transformers/ConditionOptimization';
81
+ export * from './transformers/ParameterConditionPlacementOptimizer';
80
82
  export * from './transformers/PruneOptionalConditionBranches';
81
83
  export { SchemaInfo, optimizeUnusedLeftJoins, optimizeUnusedLeftJoinsToFixedPoint, optimizeUnusedCtes, optimizeUnusedCtesToFixedPoint } from './transformers/OptimizeUnusedLeftJoins';
82
84
  export * from './transformers/TableColumnResolver';
@@ -0,0 +1,66 @@
1
+ import { SelectQuery, SimpleSelectQuery } from "../models/SelectQuery";
2
+ import { ParameterConditionMove, ParameterConditionOptimizationError, ParameterConditionOptimizationOptions, ParameterConditionOptimizationWarning, ParameterConditionSkipped } from "./ParameterConditionPlacementOptimizer";
3
+ import { OptionalConditionPruningParameters } from "./PruneOptionalConditionBranches";
4
+ export type ConditionOptimizationInput = string | SelectQuery | SimpleSelectQuery;
5
+ export type ConditionOptimizationPhaseKind = "sssql_optional_condition" | "parameter_condition_placement";
6
+ export interface ConditionOptimizationOptions extends ParameterConditionOptimizationOptions {
7
+ /**
8
+ * Explicit opt-in values for SSSQL optional branch pruning.
9
+ * Only listed parameter names are considered, and only null/undefined values
10
+ * are pruned by the safe-only SSSQL phase.
11
+ */
12
+ optionalConditionParameters?: OptionalConditionPruningParameters;
13
+ }
14
+ export interface ConditionOptimizationPhaseSummary {
15
+ kind: ConditionOptimizationPhaseKind;
16
+ appliedCount: number;
17
+ skippedCount: number;
18
+ warningCount: number;
19
+ errorCount: number;
20
+ }
21
+ export interface SssqlOptionalConditionApplied {
22
+ phaseKind: "sssql_optional_condition";
23
+ kind: "prune_optional_branch" | "refresh_optional_branch";
24
+ conditionSql: string;
25
+ parameterName: string;
26
+ reason: string;
27
+ previousConditionSql?: string;
28
+ }
29
+ export interface SssqlOptionalConditionSkipped {
30
+ phaseKind: "sssql_optional_condition";
31
+ kind: "optional_branch_skipped";
32
+ conditionSql: string;
33
+ parameterName: string;
34
+ code: string;
35
+ reason: string;
36
+ }
37
+ export type ConditionOptimizationApplied = SssqlOptionalConditionApplied | (ParameterConditionMove & {
38
+ phaseKind: "parameter_condition_placement";
39
+ });
40
+ export type ConditionOptimizationSkipped = SssqlOptionalConditionSkipped | (ParameterConditionSkipped & {
41
+ phaseKind: "parameter_condition_placement";
42
+ });
43
+ export type ConditionOptimizationWarning = (ParameterConditionOptimizationWarning & {
44
+ phaseKind: ConditionOptimizationPhaseKind;
45
+ });
46
+ export type ConditionOptimizationError = (ParameterConditionOptimizationError & {
47
+ phaseKind: ConditionOptimizationPhaseKind;
48
+ });
49
+ export interface ConditionOptimizationSafety {
50
+ mode: "safe_only";
51
+ unsafeRewriteApplied: false;
52
+ dryRun: boolean;
53
+ formatterGeneratedSource: boolean;
54
+ }
55
+ export interface ConditionOptimizationResult {
56
+ ok: boolean;
57
+ sql: string;
58
+ phases: readonly ConditionOptimizationPhaseSummary[];
59
+ applied: readonly ConditionOptimizationApplied[];
60
+ skipped: readonly ConditionOptimizationSkipped[];
61
+ warnings: readonly ConditionOptimizationWarning[];
62
+ errors: readonly ConditionOptimizationError[];
63
+ safety: ConditionOptimizationSafety;
64
+ }
65
+ export declare const planConditionOptimization: (input: ConditionOptimizationInput, options?: ConditionOptimizationOptions) => ConditionOptimizationResult;
66
+ export declare const optimizeConditions: (input: ConditionOptimizationInput, options?: ConditionOptimizationOptions) => ConditionOptimizationResult;
@@ -0,0 +1,85 @@
1
+ import { SelectQuery, SimpleSelectQuery } from "../models/SelectQuery";
2
+ export type ParameterConditionOptimizationInput = string | SelectQuery | SimpleSelectQuery;
3
+ /**
4
+ * First-phase safe-only placement for ordinary parameter predicates.
5
+ *
6
+ * The optimizer intentionally handles only root top-level AND predicates and one
7
+ * CTE/derived-table hop where the destination output is a direct column reference.
8
+ * Unsupported boundaries such as OR, UNION, DISTINCT, GROUP BY, WINDOW, OUTER
9
+ * JOIN, expression outputs, and function predicates are reported as skipped.
10
+ */
11
+ export interface ParameterConditionOptimizationOptions {
12
+ dryRun?: boolean;
13
+ }
14
+ export interface ParameterConditionOptimizationWarning {
15
+ code: string;
16
+ message: string;
17
+ detail?: unknown;
18
+ }
19
+ export interface ParameterConditionOptimizationError {
20
+ code: string;
21
+ message: string;
22
+ detail?: unknown;
23
+ }
24
+ export interface ParameterConditionMove {
25
+ kind: "move_condition";
26
+ conditionSql: string;
27
+ fromScopeId: string;
28
+ toScopeId: string;
29
+ reason: string;
30
+ parameterNames: readonly string[];
31
+ columnReferences: readonly string[];
32
+ }
33
+ export interface ParameterConditionSkipped {
34
+ conditionSql: string;
35
+ scopeId: string;
36
+ reason: string;
37
+ code: string;
38
+ }
39
+ export interface ParameterConditionOptimizationSafety {
40
+ mode: "safe_only";
41
+ unsafeRewriteApplied: false;
42
+ dryRun: boolean;
43
+ formatterGeneratedSource: boolean;
44
+ }
45
+ export interface ParameterConditionOptimizationResult {
46
+ ok: boolean;
47
+ sql: string;
48
+ applied: readonly ParameterConditionMove[];
49
+ skipped: readonly ParameterConditionSkipped[];
50
+ warnings: readonly ParameterConditionOptimizationWarning[];
51
+ errors: readonly ParameterConditionOptimizationError[];
52
+ safety: ParameterConditionOptimizationSafety;
53
+ conditionMoves: readonly ParameterConditionMove[];
54
+ }
55
+ export declare class ParameterConditionPlacementOptimizer {
56
+ plan(input: ParameterConditionOptimizationInput, options?: ParameterConditionOptimizationOptions): ParameterConditionOptimizationResult;
57
+ optimize(input: ParameterConditionOptimizationInput, options?: ParameterConditionOptimizationOptions): ParameterConditionOptimizationResult;
58
+ private parseInput;
59
+ private analyzeCandidate;
60
+ private findUnsupportedExpression;
61
+ private isSupportedInPredicate;
62
+ private resolveTarget;
63
+ private findCurrentQueryBoundary;
64
+ private findTargetQueryBoundary;
65
+ private resolveSourceBinding;
66
+ private resolveUpstreamQuery;
67
+ private resolveTargetColumn;
68
+ private verifyColumnResolvableInQuery;
69
+ private rebaseCondition;
70
+ private getSourceBindings;
71
+ private findNullableSideBoundary;
72
+ private hasOuterJoin;
73
+ private getOutputColumnMatchCount;
74
+ private resolveSourceQueryForColumns;
75
+ private getSelectItemOutputName;
76
+ private findCte;
77
+ private countTableSourceReferences;
78
+ private hasWindowUsage;
79
+ private collectColumnReferences;
80
+ private collectParameterNames;
81
+ private makeSkipped;
82
+ private buildResult;
83
+ }
84
+ export declare const planParameterConditionOptimization: (input: ParameterConditionOptimizationInput, options?: ParameterConditionOptimizationOptions) => ParameterConditionOptimizationResult;
85
+ export declare const optimizeParameterConditionPlacement: (input: ParameterConditionOptimizationInput, options?: ParameterConditionOptimizationOptions) => ParameterConditionOptimizationResult;
@@ -0,0 +1,311 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.optimizeConditions = exports.planConditionOptimization = void 0;
4
+ const SelectQueryParser_1 = require("../parsers/SelectQueryParser");
5
+ const ParameterConditionPlacementOptimizer_1 = require("./ParameterConditionPlacementOptimizer");
6
+ const PruneOptionalConditionBranches_1 = require("./PruneOptionalConditionBranches");
7
+ const SSSQLFilterBuilder_1 = require("./SSSQLFilterBuilder");
8
+ const SqlFormatter_1 = require("./SqlFormatter");
9
+ const formatSqlComponent = (component) => {
10
+ return new SqlFormatter_1.SqlFormatter().format(component).formattedSql;
11
+ };
12
+ const hasOwnParameter = (parameters, parameterName) => Object.prototype.hasOwnProperty.call(parameters, parameterName);
13
+ const isAbsentOptionalValue = (parameters, parameterName) => parameters[parameterName] === null || parameters[parameterName] === undefined;
14
+ const parseConditionOptimizationInput = (input) => {
15
+ const warnings = [];
16
+ const errors = [];
17
+ const sourceSql = typeof input === "string" ? input : formatSqlComponent(input);
18
+ const formatterGeneratedSource = typeof input !== "string";
19
+ if (formatterGeneratedSource) {
20
+ warnings.push({
21
+ phaseKind: "sssql_optional_condition",
22
+ code: "AST_INPUT_FORMATTED",
23
+ message: "AST input is cloned through formatter output so the caller-owned query is not mutated."
24
+ });
25
+ }
26
+ try {
27
+ return {
28
+ query: SelectQueryParser_1.SelectQueryParser.parse(sourceSql),
29
+ sql: sourceSql,
30
+ formatterGeneratedSource,
31
+ warnings,
32
+ errors
33
+ };
34
+ }
35
+ catch (error) {
36
+ errors.push({
37
+ phaseKind: "sssql_optional_condition",
38
+ code: "PARSE_FAILED",
39
+ message: "SSSQL optional condition optimization could not parse the input SQL.",
40
+ detail: error instanceof Error ? error.message : String(error)
41
+ });
42
+ return {
43
+ query: null,
44
+ sql: sourceSql,
45
+ formatterGeneratedSource,
46
+ warnings,
47
+ errors
48
+ };
49
+ }
50
+ };
51
+ const buildSssqlApplied = (branch) => {
52
+ return {
53
+ phaseKind: "sssql_optional_condition",
54
+ kind: "prune_optional_branch",
55
+ conditionSql: formatSqlComponent(branch.expression),
56
+ parameterName: branch.parameterName,
57
+ reason: "The optional branch parameter is explicitly absent, so the safe-only SSSQL phase pruned the branch."
58
+ };
59
+ };
60
+ const buildSssqlRefreshApplied = (branch, previousConditionSql) => {
61
+ return {
62
+ phaseKind: "sssql_optional_condition",
63
+ kind: "refresh_optional_branch",
64
+ conditionSql: formatSqlComponent(branch.expression),
65
+ previousConditionSql,
66
+ parameterName: branch.parameterName,
67
+ reason: "The safe-only SSSQL phase refreshed the optional branch placement before ordinary parameter placement."
68
+ };
69
+ };
70
+ const buildSssqlSkipped = (branch, parameters) => {
71
+ const parameterProvided = hasOwnParameter(parameters, branch.parameterName);
72
+ return {
73
+ phaseKind: "sssql_optional_condition",
74
+ kind: "optional_branch_skipped",
75
+ conditionSql: formatSqlComponent(branch.expression),
76
+ parameterName: branch.parameterName,
77
+ code: parameterProvided
78
+ ? "SSSQL_OPTIONAL_PARAMETER_PRESENT"
79
+ : "SSSQL_OPTIONAL_PARAMETER_NOT_PROVIDED",
80
+ reason: parameterProvided
81
+ ? "The optional branch parameter is present, so the branch remains active."
82
+ : "No optional branch parameter value was provided, so the branch remains unchanged."
83
+ };
84
+ };
85
+ const buildSssqlRefreshSkipped = (branch, code, reason) => {
86
+ return {
87
+ phaseKind: "sssql_optional_condition",
88
+ kind: "optional_branch_skipped",
89
+ conditionSql: formatSqlComponent(branch.expression),
90
+ parameterName: branch.parameterName,
91
+ code,
92
+ reason
93
+ };
94
+ };
95
+ const buildSssqlRefreshFilters = (branches, parameters) => {
96
+ const filters = {};
97
+ for (const branch of branches) {
98
+ filters[branch.parameterName] = hasOwnParameter(parameters, branch.parameterName)
99
+ ? parameters[branch.parameterName]
100
+ : null;
101
+ }
102
+ return filters;
103
+ };
104
+ const refreshRemainingSssqlBranches = (sql, parameters) => {
105
+ const parsed = parseConditionOptimizationInput(sql);
106
+ const applied = [];
107
+ const skipped = [];
108
+ if (!parsed.query) {
109
+ return {
110
+ sql: parsed.sql,
111
+ applied,
112
+ skipped,
113
+ warnings: parsed.warnings,
114
+ errors: parsed.errors,
115
+ formatterGeneratedSource: parsed.formatterGeneratedSource
116
+ };
117
+ }
118
+ const beforeBranches = (0, PruneOptionalConditionBranches_1.collectSupportedOptionalConditionBranches)(parsed.query);
119
+ if (beforeBranches.length === 0) {
120
+ return {
121
+ sql: parsed.sql,
122
+ applied,
123
+ skipped,
124
+ warnings: parsed.warnings,
125
+ errors: parsed.errors,
126
+ formatterGeneratedSource: parsed.formatterGeneratedSource
127
+ };
128
+ }
129
+ const beforeBranchSql = new WeakMap();
130
+ const beforeBranchQuery = new WeakMap();
131
+ for (const branch of beforeBranches) {
132
+ beforeBranchSql.set(branch.expression, formatSqlComponent(branch.expression));
133
+ beforeBranchQuery.set(branch.expression, branch.query);
134
+ }
135
+ try {
136
+ new SSSQLFilterBuilder_1.SSSQLFilterBuilder().refresh(parsed.query, buildSssqlRefreshFilters(beforeBranches, parameters));
137
+ }
138
+ catch (error) {
139
+ const detail = error instanceof Error ? error.message : String(error);
140
+ return {
141
+ sql,
142
+ applied,
143
+ skipped: beforeBranches.map(branch => buildSssqlRefreshSkipped(branch, "SSSQL_OPTIONAL_REFRESH_UNSUPPORTED", `SSSQL optional branch refresh was skipped because safe refresh could not be proven: ${detail}`)),
144
+ warnings: parsed.warnings,
145
+ errors: parsed.errors,
146
+ formatterGeneratedSource: parsed.formatterGeneratedSource
147
+ };
148
+ }
149
+ const afterBranches = (0, PruneOptionalConditionBranches_1.collectSupportedOptionalConditionBranches)(parsed.query);
150
+ for (const branch of afterBranches) {
151
+ const previousSql = beforeBranchSql.get(branch.expression);
152
+ const previousQuery = beforeBranchQuery.get(branch.expression);
153
+ if (!previousSql || !previousQuery) {
154
+ skipped.push(buildSssqlRefreshSkipped(branch, "SSSQL_OPTIONAL_REFRESH_UNSUPPORTED", "SSSQL optional branch refresh left an untracked branch unchanged."));
155
+ continue;
156
+ }
157
+ const refreshedSql = formatSqlComponent(branch.expression);
158
+ if (previousQuery !== branch.query || previousSql !== refreshedSql) {
159
+ applied.push(buildSssqlRefreshApplied(branch, previousSql));
160
+ continue;
161
+ }
162
+ skipped.push(buildSssqlRefreshSkipped(branch, "SSSQL_OPTIONAL_REFRESH_NOOP", "SSSQL optional branch refresh found no safe placement change to apply."));
163
+ }
164
+ return {
165
+ sql: applied.length > 0 ? formatSqlComponent(parsed.query) : sql,
166
+ applied,
167
+ skipped,
168
+ warnings: parsed.warnings,
169
+ errors: parsed.errors,
170
+ formatterGeneratedSource: parsed.formatterGeneratedSource
171
+ };
172
+ };
173
+ const runSssqlOptionalConditionPhase = (input, options) => {
174
+ var _a;
175
+ const parsed = parseConditionOptimizationInput(input);
176
+ const warnings = [...parsed.warnings];
177
+ let errors = [...parsed.errors];
178
+ const applied = [];
179
+ const skipped = [];
180
+ const optionalConditionParameters = (_a = options.optionalConditionParameters) !== null && _a !== void 0 ? _a : {};
181
+ if (!parsed.query) {
182
+ return {
183
+ sql: parsed.sql,
184
+ applied,
185
+ skipped,
186
+ warnings,
187
+ errors,
188
+ formatterGeneratedSource: parsed.formatterGeneratedSource
189
+ };
190
+ }
191
+ let currentSql = parsed.sql;
192
+ const branches = (0, PruneOptionalConditionBranches_1.collectSupportedOptionalConditionBranches)(parsed.query);
193
+ const pruneBranches = branches.filter(branch => hasOwnParameter(optionalConditionParameters, branch.parameterName)
194
+ && isAbsentOptionalValue(optionalConditionParameters, branch.parameterName));
195
+ if (pruneBranches.length > 0) {
196
+ try {
197
+ (0, PruneOptionalConditionBranches_1.pruneOptionalConditionBranches)(parsed.query, optionalConditionParameters);
198
+ currentSql = formatSqlComponent(parsed.query);
199
+ applied.push(...pruneBranches.map(buildSssqlApplied));
200
+ }
201
+ catch (error) {
202
+ errors = [...errors, {
203
+ phaseKind: "sssql_optional_condition",
204
+ code: "SSSQL_PRUNE_FAILED",
205
+ message: "SSSQL optional condition optimization could not prune optional branches.",
206
+ detail: error instanceof Error ? error.message : String(error)
207
+ }];
208
+ }
209
+ }
210
+ if (errors.length === 0) {
211
+ const refreshPhase = refreshRemainingSssqlBranches(currentSql, optionalConditionParameters);
212
+ applied.push(...refreshPhase.applied);
213
+ skipped.push(...refreshPhase.skipped);
214
+ warnings.push(...refreshPhase.warnings);
215
+ errors.push(...refreshPhase.errors);
216
+ currentSql = refreshPhase.sql;
217
+ }
218
+ else {
219
+ for (const branch of branches) {
220
+ if (pruneBranches.includes(branch)) {
221
+ continue;
222
+ }
223
+ skipped.push(buildSssqlSkipped(branch, optionalConditionParameters));
224
+ }
225
+ }
226
+ return {
227
+ sql: errors.length === 0 ? currentSql : parsed.sql,
228
+ applied,
229
+ skipped,
230
+ warnings,
231
+ errors,
232
+ formatterGeneratedSource: parsed.formatterGeneratedSource
233
+ };
234
+ };
235
+ const mapParameterWarnings = (warnings) => warnings.map(warning => ({
236
+ phaseKind: "parameter_condition_placement",
237
+ ...warning
238
+ }));
239
+ const mapParameterErrors = (errors) => errors.map(error => ({
240
+ phaseKind: "parameter_condition_placement",
241
+ ...error
242
+ }));
243
+ const mapParameterApplied = (applied) => applied.map(item => ({
244
+ phaseKind: "parameter_condition_placement",
245
+ ...item
246
+ }));
247
+ const mapParameterSkipped = (skipped) => skipped.map(item => ({
248
+ phaseKind: "parameter_condition_placement",
249
+ ...item
250
+ }));
251
+ const makePhaseSummary = (kind, counts) => ({
252
+ kind,
253
+ appliedCount: counts.appliedCount,
254
+ skippedCount: counts.skippedCount,
255
+ warningCount: counts.warningCount,
256
+ errorCount: counts.errorCount
257
+ });
258
+ const runConditionOptimization = (input, options, defaultDryRun) => {
259
+ var _a;
260
+ const dryRun = (_a = options.dryRun) !== null && _a !== void 0 ? _a : defaultDryRun;
261
+ // Run the semantic SSSQL phase before the generic placement phase so
262
+ // optional branches remain owned by SSSQL even if parameter placement grows
263
+ // broader OR-predicate support later.
264
+ const sssqlPhase = runSssqlOptionalConditionPhase(input, { ...options, dryRun });
265
+ const parameterPhase = dryRun
266
+ ? (0, ParameterConditionPlacementOptimizer_1.planParameterConditionOptimization)(sssqlPhase.sql, { dryRun })
267
+ : (0, ParameterConditionPlacementOptimizer_1.optimizeParameterConditionPlacement)(sssqlPhase.sql, { dryRun });
268
+ const parameterWarnings = mapParameterWarnings(parameterPhase.warnings);
269
+ const parameterErrors = mapParameterErrors(parameterPhase.errors);
270
+ const parameterApplied = mapParameterApplied(parameterPhase.applied);
271
+ const parameterSkipped = mapParameterSkipped(parameterPhase.skipped);
272
+ const warnings = [...sssqlPhase.warnings, ...parameterWarnings];
273
+ const errors = [...sssqlPhase.errors, ...parameterErrors];
274
+ return {
275
+ ok: errors.length === 0,
276
+ sql: parameterPhase.sql,
277
+ phases: [
278
+ makePhaseSummary("sssql_optional_condition", {
279
+ appliedCount: sssqlPhase.applied.length,
280
+ skippedCount: sssqlPhase.skipped.length,
281
+ warningCount: sssqlPhase.warnings.length,
282
+ errorCount: sssqlPhase.errors.length
283
+ }),
284
+ makePhaseSummary("parameter_condition_placement", {
285
+ appliedCount: parameterApplied.length,
286
+ skippedCount: parameterSkipped.length,
287
+ warningCount: parameterWarnings.length,
288
+ errorCount: parameterErrors.length
289
+ })
290
+ ],
291
+ applied: [...sssqlPhase.applied, ...parameterApplied],
292
+ skipped: [...sssqlPhase.skipped, ...parameterSkipped],
293
+ warnings,
294
+ errors,
295
+ safety: {
296
+ mode: "safe_only",
297
+ unsafeRewriteApplied: false,
298
+ dryRun,
299
+ formatterGeneratedSource: sssqlPhase.formatterGeneratedSource || parameterPhase.safety.formatterGeneratedSource
300
+ }
301
+ };
302
+ };
303
+ const planConditionOptimization = (input, options = {}) => {
304
+ return runConditionOptimization(input, options, true);
305
+ };
306
+ exports.planConditionOptimization = planConditionOptimization;
307
+ const optimizeConditions = (input, options = {}) => {
308
+ return runConditionOptimization(input, options, false);
309
+ };
310
+ exports.optimizeConditions = optimizeConditions;
311
+ //# sourceMappingURL=ConditionOptimization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConditionOptimization.js","sourceRoot":"","sources":["../../src/transformers/ConditionOptimization.ts"],"names":[],"mappings":";;;AAEA,oEAAiE;AACjE,iGAQgD;AAChD,qFAK0C;AAC1C,6DAA0D;AAC1D,iDAA8C;AAyF9C,MAAM,kBAAkB,GAAG,CAAC,SAA2D,EAAU,EAAE;IAC/F,OAAO,IAAI,2BAAY,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC;AAC7D,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CACpB,UAA8C,EAC9C,aAAqB,EACd,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAE9E,MAAM,qBAAqB,GAAG,CAC1B,UAA8C,EAC9C,aAAqB,EACd,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,IAAI,UAAU,CAAC,aAAa,CAAC,KAAK,SAAS,CAAC;AAE5F,MAAM,+BAA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