@synapsestudios/eslint-plugin-data-boundaries 1.0.0 → 1.1.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.
- package/README.md +181 -6
- package/dist/rules/no-cross-domain-prisma-access.d.ts +1 -0
- package/dist/rules/no-cross-domain-prisma-access.d.ts.map +1 -1
- package/dist/rules/no-cross-domain-prisma-access.js +7 -2
- package/dist/rules/no-cross-domain-prisma-access.js.map +1 -1
- package/dist/utils/schema-parser.d.ts +1 -1
- package/dist/utils/schema-parser.d.ts.map +1 -1
- package/dist/utils/schema-parser.js +12 -4
- package/dist/utils/schema-parser.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,12 @@ This ESLint plugin provides two complementary rules to prevent such violations:
|
|
|
17
17
|
npm install --save-dev @synapsestudios/eslint-plugin-data-boundaries
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
**Prerequisites**: If you're using TypeScript, you'll also need the TypeScript ESLint parser:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install --save-dev @typescript-eslint/parser @typescript-eslint/eslint-plugin
|
|
24
|
+
```
|
|
25
|
+
|
|
20
26
|
## Rules
|
|
21
27
|
|
|
22
28
|
### `no-cross-file-model-references`
|
|
@@ -82,15 +88,23 @@ class AuthService {
|
|
|
82
88
|
|
|
83
89
|
## Configuration
|
|
84
90
|
|
|
85
|
-
### Basic Setup
|
|
91
|
+
### Basic Setup (Legacy Config)
|
|
86
92
|
|
|
87
93
|
Add the plugin to your `.eslintrc.js`:
|
|
88
94
|
|
|
89
95
|
```javascript
|
|
90
96
|
module.exports = {
|
|
97
|
+
// Base parser configuration for TypeScript
|
|
98
|
+
parser: '@typescript-eslint/parser',
|
|
99
|
+
parserOptions: {
|
|
100
|
+
ecmaVersion: 2020,
|
|
101
|
+
sourceType: 'module',
|
|
102
|
+
project: './tsconfig.json',
|
|
103
|
+
// DO NOT add .prisma to extraFileExtensions - our custom parser handles these
|
|
104
|
+
},
|
|
91
105
|
plugins: ['@synapsestudios/data-boundaries'],
|
|
92
106
|
overrides: [
|
|
93
|
-
// For Prisma schema files
|
|
107
|
+
// For Prisma schema files - uses our custom parser
|
|
94
108
|
{
|
|
95
109
|
files: ['**/*.prisma'],
|
|
96
110
|
parser: '@synapsestudios/data-boundaries/dist/parsers/prisma-parser',
|
|
@@ -104,7 +118,8 @@ module.exports = {
|
|
|
104
118
|
rules: {
|
|
105
119
|
'@synapsestudios/data-boundaries/no-cross-domain-prisma-access': ['error', {
|
|
106
120
|
schemaDir: 'prisma/schema',
|
|
107
|
-
allowSharedModels: true
|
|
121
|
+
allowSharedModels: true,
|
|
122
|
+
modulePath: '/modules/' // Default - change to '/src/' for NestJS projects
|
|
108
123
|
}]
|
|
109
124
|
}
|
|
110
125
|
}
|
|
@@ -112,6 +127,68 @@ module.exports = {
|
|
|
112
127
|
};
|
|
113
128
|
```
|
|
114
129
|
|
|
130
|
+
### Flat Config Setup (Recommended for New Projects)
|
|
131
|
+
|
|
132
|
+
For projects using ESLint's flat config (ESM), add to your `eslint.config.mjs`:
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
import eslintPluginDataBoundaries from '@synapsestudios/eslint-plugin-data-boundaries';
|
|
136
|
+
import prismaParser from '@synapsestudios/eslint-plugin-data-boundaries/dist/parsers/prisma-parser.js';
|
|
137
|
+
|
|
138
|
+
export default [
|
|
139
|
+
// 1. Global ignores first
|
|
140
|
+
{
|
|
141
|
+
ignores: ['eslint.config.mjs', '**/*.prisma']
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
// 2. Prisma config - isolated and first
|
|
145
|
+
{
|
|
146
|
+
files: ['**/*.prisma'],
|
|
147
|
+
ignores: [], // Override global ignore
|
|
148
|
+
languageOptions: {
|
|
149
|
+
parser: prismaParser
|
|
150
|
+
},
|
|
151
|
+
plugins: {
|
|
152
|
+
'@synapsestudios/data-boundaries': eslintPluginDataBoundaries
|
|
153
|
+
},
|
|
154
|
+
rules: {
|
|
155
|
+
'@synapsestudios/data-boundaries/no-cross-file-model-references': 'error',
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
// 3. Your existing TypeScript config here...
|
|
160
|
+
|
|
161
|
+
// 4. TypeScript files rule config
|
|
162
|
+
{
|
|
163
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
164
|
+
plugins: {
|
|
165
|
+
'@synapsestudios/data-boundaries': eslintPluginDataBoundaries
|
|
166
|
+
},
|
|
167
|
+
rules: {
|
|
168
|
+
'@synapsestudios/data-boundaries/no-cross-domain-prisma-access': [
|
|
169
|
+
'error',
|
|
170
|
+
{
|
|
171
|
+
schemaDir: 'prisma/schema',
|
|
172
|
+
allowSharedModels: true,
|
|
173
|
+
modulePath: '/src/' // Use '/src/' for NestJS, '/modules/' for other structures
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
];
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**⚠️ Flat Config Important Notes:**
|
|
182
|
+
|
|
183
|
+
1. **Parser isolation is critical** - Prisma config must be completely separate from TypeScript config
|
|
184
|
+
2. **Configuration order matters** - Place Prisma config before TypeScript config
|
|
185
|
+
3. **ESM imports require .js extension** - Use `prisma-parser.js` not `prisma-parser`
|
|
186
|
+
4. **Global ignores + overrides** - Use global ignore for `.prisma` then override in Prisma-specific config
|
|
187
|
+
|
|
188
|
+
**⚠️ Important Configuration Note**:
|
|
189
|
+
|
|
190
|
+
**Do NOT** add `.prisma` to `extraFileExtensions` in your main parser options. The plugin includes a custom parser specifically for `.prisma` files that handles Prisma schema syntax correctly. Adding `.prisma` to `extraFileExtensions` will cause the TypeScript parser to try parsing Prisma files, which will fail.
|
|
191
|
+
|
|
115
192
|
### Using the Recommended Configuration
|
|
116
193
|
|
|
117
194
|
```javascript
|
|
@@ -126,21 +203,23 @@ module.exports = {
|
|
|
126
203
|
|
|
127
204
|
- **`schemaDir`** (string): Directory containing Prisma schema files, relative to project root. Default: `'prisma/schema'`
|
|
128
205
|
- **`allowSharedModels`** (boolean): Whether to allow access to models in shared/main schema files. Default: `true`
|
|
206
|
+
- **`modulePath`** (string): Path pattern to match module directories. Default: `'/modules/'`. Use `'/src/'` for NestJS projects or other domain-based structures.
|
|
129
207
|
|
|
130
208
|
```javascript
|
|
131
209
|
{
|
|
132
210
|
'@synapsestudios/data-boundaries/no-cross-domain-prisma-access': ['error', {
|
|
133
211
|
schemaDir: 'database/schemas',
|
|
134
|
-
allowSharedModels: false
|
|
212
|
+
allowSharedModels: false,
|
|
213
|
+
modulePath: '/src/' // For NestJS-style projects
|
|
135
214
|
}]
|
|
136
215
|
}
|
|
137
216
|
```
|
|
138
217
|
|
|
139
218
|
## Directory Structure
|
|
140
219
|
|
|
141
|
-
This plugin
|
|
220
|
+
This plugin supports multiple project structures:
|
|
142
221
|
|
|
143
|
-
### Module Structure
|
|
222
|
+
### Default Module Structure
|
|
144
223
|
```
|
|
145
224
|
src/
|
|
146
225
|
modules/
|
|
@@ -154,6 +233,21 @@ src/
|
|
|
154
233
|
service.ts
|
|
155
234
|
```
|
|
156
235
|
|
|
236
|
+
### NestJS/Domain-Based Structure
|
|
237
|
+
```
|
|
238
|
+
src/
|
|
239
|
+
auth/ # auth domain
|
|
240
|
+
auth.service.ts
|
|
241
|
+
auth.controller.ts
|
|
242
|
+
organization/ # organization domain
|
|
243
|
+
organization.service.ts
|
|
244
|
+
organization.controller.ts
|
|
245
|
+
user-profile/ # user-profile domain
|
|
246
|
+
user-profile.service.ts
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**Note**: For NestJS projects, set `modulePath: '/src/'` in your rule configuration.
|
|
250
|
+
|
|
157
251
|
### Schema Structure
|
|
158
252
|
```
|
|
159
253
|
prisma/
|
|
@@ -206,6 +300,87 @@ Cross-file model references are not allowed.
|
|
|
206
300
|
3. **Add application boundaries**: Enable `no-cross-domain-prisma-access` to prevent cross-domain access in application code
|
|
207
301
|
4. **Refactor violations**: Create shared services or move logic to appropriate domains
|
|
208
302
|
|
|
303
|
+
## Troubleshooting
|
|
304
|
+
|
|
305
|
+
### Common Issues
|
|
306
|
+
|
|
307
|
+
**Error: "extension for the file (.prisma) is non-standard"**
|
|
308
|
+
|
|
309
|
+
This happens when the TypeScript parser tries to parse `.prisma` files. **Do NOT add `.prisma` to `extraFileExtensions`**. Instead, make sure your configuration uses our custom parser for `.prisma` files:
|
|
310
|
+
|
|
311
|
+
```javascript
|
|
312
|
+
// .eslintrc.js
|
|
313
|
+
module.exports = {
|
|
314
|
+
parser: '@typescript-eslint/parser',
|
|
315
|
+
parserOptions: {
|
|
316
|
+
project: './tsconfig.json',
|
|
317
|
+
// DO NOT add extraFileExtensions: ['.prisma'] here
|
|
318
|
+
},
|
|
319
|
+
plugins: ['@synapsestudios/data-boundaries'],
|
|
320
|
+
overrides: [
|
|
321
|
+
{
|
|
322
|
+
files: ['**/*.prisma'],
|
|
323
|
+
parser: '@synapsestudios/data-boundaries/dist/parsers/prisma-parser', // This handles .prisma files
|
|
324
|
+
rules: {
|
|
325
|
+
'@synapsestudios/data-boundaries/no-cross-file-model-references': 'error'
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
]
|
|
329
|
+
};
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Error: "Could not determine schema directory"**
|
|
333
|
+
|
|
334
|
+
Make sure your `schemaDir` option points to the correct directory containing your Prisma schema files:
|
|
335
|
+
|
|
336
|
+
```javascript
|
|
337
|
+
{
|
|
338
|
+
'@synapsestudios/data-boundaries/no-cross-domain-prisma-access': ['error', {
|
|
339
|
+
schemaDir: 'prisma/schema', // Adjust this path as needed
|
|
340
|
+
allowSharedModels: true
|
|
341
|
+
}]
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**Rule not working on certain files**
|
|
346
|
+
|
|
347
|
+
The `no-cross-domain-prisma-access` rule only applies to files in directories that match the `modulePath` option. By default, this is `/modules/`.
|
|
348
|
+
|
|
349
|
+
For **NestJS projects** or other domain-based structures, configure `modulePath: '/src/'`:
|
|
350
|
+
|
|
351
|
+
```javascript
|
|
352
|
+
{
|
|
353
|
+
'@synapsestudios/data-boundaries/no-cross-domain-prisma-access': ['error', {
|
|
354
|
+
schemaDir: 'prisma/schema',
|
|
355
|
+
modulePath: '/src/', // ← Add this for NestJS projects
|
|
356
|
+
allowSharedModels: true
|
|
357
|
+
}]
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**Default structure** (`modulePath: '/modules/'`):
|
|
362
|
+
```
|
|
363
|
+
src/
|
|
364
|
+
modules/
|
|
365
|
+
auth/ # ✅ Will be checked
|
|
366
|
+
service.ts
|
|
367
|
+
organization/ # ✅ Will be checked
|
|
368
|
+
service.ts
|
|
369
|
+
utils/ # ❌ Will be ignored
|
|
370
|
+
helper.ts
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**NestJS structure** (`modulePath: '/src/'`):
|
|
374
|
+
```
|
|
375
|
+
src/
|
|
376
|
+
auth/ # ✅ Will be checked
|
|
377
|
+
auth.service.ts
|
|
378
|
+
organization/ # ✅ Will be checked
|
|
379
|
+
org.service.ts
|
|
380
|
+
utils/ # ❌ Will be ignored
|
|
381
|
+
helper.ts
|
|
382
|
+
```
|
|
383
|
+
|
|
209
384
|
## Contributing
|
|
210
385
|
|
|
211
386
|
Issues and pull requests are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
@@ -2,6 +2,7 @@ import { ESLintUtils } from '@typescript-eslint/utils';
|
|
|
2
2
|
interface RuleOptions {
|
|
3
3
|
schemaDir: string;
|
|
4
4
|
allowSharedModels: boolean;
|
|
5
|
+
modulePath: string;
|
|
5
6
|
}
|
|
6
7
|
declare const rule: ESLintUtils.RuleModule<"crossDomainAccess" | "modelNotFound" | "configError", [RuleOptions], unknown, ESLintUtils.RuleListener>;
|
|
7
8
|
export = rule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-cross-domain-prisma-access.d.ts","sourceRoot":"","sources":["../../src/rules/no-cross-domain-prisma-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,0BAA0B,CAAC;AAWjE,UAAU,WAAW;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"no-cross-domain-prisma-access.d.ts","sourceRoot":"","sources":["../../src/rules/no-cross-domain-prisma-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,0BAA0B,CAAC;AAWjE,UAAU,WAAW;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB;AAyDD,QAAA,MAAM,IAAI,iIAwIR,CAAC;AAEH,SAAS,IAAI,CAAC"}
|
|
@@ -99,6 +99,10 @@ const rule = createRule({
|
|
|
99
99
|
type: 'boolean',
|
|
100
100
|
description: 'Allow access to models in shared/main schema files',
|
|
101
101
|
},
|
|
102
|
+
modulePath: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
description: 'Path pattern to match module directories (e.g., "/modules/", "/src/")',
|
|
105
|
+
},
|
|
102
106
|
},
|
|
103
107
|
additionalProperties: false,
|
|
104
108
|
},
|
|
@@ -113,16 +117,17 @@ const rule = createRule({
|
|
|
113
117
|
{
|
|
114
118
|
schemaDir: 'prisma/schema',
|
|
115
119
|
allowSharedModels: true,
|
|
120
|
+
modulePath: '/modules/',
|
|
116
121
|
},
|
|
117
122
|
],
|
|
118
123
|
create(context, [options]) {
|
|
119
124
|
const filename = context.getFilename();
|
|
120
125
|
// Only process TypeScript files in modules
|
|
121
|
-
if (!filename.includes(
|
|
126
|
+
if (!filename.includes(options.modulePath) || !filename.match(/\.(ts|tsx)$/)) {
|
|
122
127
|
return {};
|
|
123
128
|
}
|
|
124
129
|
// Extract current module from file path
|
|
125
|
-
const currentModule = (0, schema_parser_1.extractModuleFromPath)(filename);
|
|
130
|
+
const currentModule = (0, schema_parser_1.extractModuleFromPath)(filename, options.modulePath);
|
|
126
131
|
if (!currentModule) {
|
|
127
132
|
return {};
|
|
128
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-cross-domain-prisma-access.js","sourceRoot":"","sources":["../../src/rules/no-cross-domain-prisma-access.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAiE;AACjE,2CAA6B;AAC7B,uCAAyB;AACzB,0DAMgC;
|
|
1
|
+
{"version":3,"file":"no-cross-domain-prisma-access.js","sourceRoot":"","sources":["../../src/rules/no-cross-domain-prisma-access.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAiE;AACjE,2CAA6B;AAC7B,uCAAyB;AACzB,0DAMgC;AAQhC;;GAEG;AACH,SAAS,oBAAoB,CAAC,IAA+B;IAC3D,6BAA6B;IAC7B,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,yDAAyD;IACzD,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QAC3D,OAAO,CACL,IAAI,CAAC,MAAM,CAAC,QAAQ;YACpB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;YAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,CACvC,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,SAAS,gCAAgC,CAAC,IAA+B;IACv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AAI,EAAE;4BACJ,aAAa;4BACb,SAAS,EAAE,eAAe;4BAC1B,WAAW;yBACZ;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,iBAAS,IAAI,CAAC"}
|
|
@@ -8,7 +8,7 @@ export declare function buildModelToDomainMapping(schemaDir: string): ModelToDom
|
|
|
8
8
|
/**
|
|
9
9
|
* Extract module name from file path
|
|
10
10
|
*/
|
|
11
|
-
export declare function extractModuleFromPath(filePath: string): string | null;
|
|
11
|
+
export declare function extractModuleFromPath(filePath: string, modulePath?: string): string | null;
|
|
12
12
|
/**
|
|
13
13
|
* Check if a string looks like a Prisma model name (either camelCase or PascalCase)
|
|
14
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-parser.d.ts","sourceRoot":"","sources":["../../src/utils/schema-parser.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,oBAAoB;IACnC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,oBAAoB,CA6BjF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"schema-parser.d.ts","sourceRoot":"","sources":["../../src/utils/schema-parser.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,oBAAoB;IACnC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,oBAAoB,CA6BjF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,UAAU,GAAE,MAAoB,GAC/B,MAAM,GAAG,IAAI,CAiBf;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAkCvD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE3D"}
|
|
@@ -73,12 +73,20 @@ function buildModelToDomainMapping(schemaDir) {
|
|
|
73
73
|
/**
|
|
74
74
|
* Extract module name from file path
|
|
75
75
|
*/
|
|
76
|
-
function extractModuleFromPath(filePath) {
|
|
76
|
+
function extractModuleFromPath(filePath, modulePath = '/modules/') {
|
|
77
77
|
// Normalize path separators for cross-platform compatibility
|
|
78
78
|
const normalizedPath = filePath.replace(/\\/g, '/');
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const normalizedModulePath = modulePath.replace(/\\/g, '/');
|
|
80
|
+
// Find the index of the module path
|
|
81
|
+
const moduleIndex = normalizedPath.indexOf(normalizedModulePath);
|
|
82
|
+
if (moduleIndex === -1) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
// Extract everything after the module path
|
|
86
|
+
const afterModulePath = normalizedPath.substring(moduleIndex + normalizedModulePath.length);
|
|
87
|
+
// Get the first directory name after the module path
|
|
88
|
+
const parts = afterModulePath.split('/').filter((part) => part.length > 0);
|
|
89
|
+
return parts.length > 0 ? parts[0] : null;
|
|
82
90
|
}
|
|
83
91
|
/**
|
|
84
92
|
* Check if a string looks like a Prisma model name (either camelCase or PascalCase)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-parser.js","sourceRoot":"","sources":["../../src/utils/schema-parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,8DA6BC;AAKD,
|
|
1
|
+
{"version":3,"file":"schema-parser.js","sourceRoot":"","sources":["../../src/utils/schema-parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,8DA6BC;AAKD,sDAoBC;AAKD,8CAkCC;AAKD,8CAEC;AAhHD,oDAAgD;AAChD,uCAAyB;AACzB,2CAA6B;AAC7B,+BAA4B;AAM5B;;G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