@synapsestudios/eslint-plugin-data-boundaries 1.0.0 → 1.2.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 +176 -11
- package/dist/rules/no-cross-domain-prisma-access.d.ts +1 -1
- package/dist/rules/no-cross-domain-prisma-access.d.ts.map +1 -1
- package/dist/rules/no-cross-domain-prisma-access.js +6 -10
- 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`
|
|
@@ -73,24 +79,28 @@ class AuthService {
|
|
|
73
79
|
async getUser(id: string) {
|
|
74
80
|
return this.prisma.user.findUnique({ where: { id } }); // ✅ Valid: User belongs to auth domain
|
|
75
81
|
}
|
|
76
|
-
|
|
77
|
-
async logAction(action: string) {
|
|
78
|
-
return this.prisma.auditLog.create({ data: { action } }); // ✅ Valid: AuditLog is a shared model
|
|
79
|
-
}
|
|
80
82
|
}
|
|
81
83
|
```
|
|
82
84
|
|
|
83
85
|
## Configuration
|
|
84
86
|
|
|
85
|
-
### Basic Setup
|
|
87
|
+
### Basic Setup (Legacy Config)
|
|
86
88
|
|
|
87
89
|
Add the plugin to your `.eslintrc.js`:
|
|
88
90
|
|
|
89
91
|
```javascript
|
|
90
92
|
module.exports = {
|
|
93
|
+
// Base parser configuration for TypeScript
|
|
94
|
+
parser: '@typescript-eslint/parser',
|
|
95
|
+
parserOptions: {
|
|
96
|
+
ecmaVersion: 2020,
|
|
97
|
+
sourceType: 'module',
|
|
98
|
+
project: './tsconfig.json',
|
|
99
|
+
// DO NOT add .prisma to extraFileExtensions - our custom parser handles these
|
|
100
|
+
},
|
|
91
101
|
plugins: ['@synapsestudios/data-boundaries'],
|
|
92
102
|
overrides: [
|
|
93
|
-
// For Prisma schema files
|
|
103
|
+
// For Prisma schema files - uses our custom parser
|
|
94
104
|
{
|
|
95
105
|
files: ['**/*.prisma'],
|
|
96
106
|
parser: '@synapsestudios/data-boundaries/dist/parsers/prisma-parser',
|
|
@@ -104,7 +114,7 @@ module.exports = {
|
|
|
104
114
|
rules: {
|
|
105
115
|
'@synapsestudios/data-boundaries/no-cross-domain-prisma-access': ['error', {
|
|
106
116
|
schemaDir: 'prisma/schema',
|
|
107
|
-
|
|
117
|
+
modulePath: '/modules/' // Default - change to '/src/' for NestJS projects
|
|
108
118
|
}]
|
|
109
119
|
}
|
|
110
120
|
}
|
|
@@ -112,6 +122,67 @@ module.exports = {
|
|
|
112
122
|
};
|
|
113
123
|
```
|
|
114
124
|
|
|
125
|
+
### Flat Config Setup (Recommended for New Projects)
|
|
126
|
+
|
|
127
|
+
For projects using ESLint's flat config (ESM), add to your `eslint.config.mjs`:
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
import eslintPluginDataBoundaries from '@synapsestudios/eslint-plugin-data-boundaries';
|
|
131
|
+
import prismaParser from '@synapsestudios/eslint-plugin-data-boundaries/dist/parsers/prisma-parser.js';
|
|
132
|
+
|
|
133
|
+
export default [
|
|
134
|
+
// 1. Global ignores first
|
|
135
|
+
{
|
|
136
|
+
ignores: ['eslint.config.mjs', '**/*.prisma']
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
// 2. Prisma config - isolated and first
|
|
140
|
+
{
|
|
141
|
+
files: ['**/*.prisma'],
|
|
142
|
+
ignores: [], // Override global ignore
|
|
143
|
+
languageOptions: {
|
|
144
|
+
parser: prismaParser
|
|
145
|
+
},
|
|
146
|
+
plugins: {
|
|
147
|
+
'@synapsestudios/data-boundaries': eslintPluginDataBoundaries
|
|
148
|
+
},
|
|
149
|
+
rules: {
|
|
150
|
+
'@synapsestudios/data-boundaries/no-cross-file-model-references': 'error',
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
// 3. Your existing TypeScript config here...
|
|
155
|
+
|
|
156
|
+
// 4. TypeScript files rule config
|
|
157
|
+
{
|
|
158
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
159
|
+
plugins: {
|
|
160
|
+
'@synapsestudios/data-boundaries': eslintPluginDataBoundaries
|
|
161
|
+
},
|
|
162
|
+
rules: {
|
|
163
|
+
'@synapsestudios/data-boundaries/no-cross-domain-prisma-access': [
|
|
164
|
+
'error',
|
|
165
|
+
{
|
|
166
|
+
schemaDir: 'prisma/schema',
|
|
167
|
+
modulePath: '/src/' // Use '/src/' for NestJS, '/modules/' for other structures
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**⚠️ Flat Config Important Notes:**
|
|
176
|
+
|
|
177
|
+
1. **Parser isolation is critical** - Prisma config must be completely separate from TypeScript config
|
|
178
|
+
2. **Configuration order matters** - Place Prisma config before TypeScript config
|
|
179
|
+
3. **ESM imports require .js extension** - Use `prisma-parser.js` not `prisma-parser`
|
|
180
|
+
4. **Global ignores + overrides** - Use global ignore for `.prisma` then override in Prisma-specific config
|
|
181
|
+
|
|
182
|
+
**⚠️ Important Configuration Note**:
|
|
183
|
+
|
|
184
|
+
**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.
|
|
185
|
+
|
|
115
186
|
### Using the Recommended Configuration
|
|
116
187
|
|
|
117
188
|
```javascript
|
|
@@ -125,22 +196,22 @@ module.exports = {
|
|
|
125
196
|
#### `no-cross-domain-prisma-access`
|
|
126
197
|
|
|
127
198
|
- **`schemaDir`** (string): Directory containing Prisma schema files, relative to project root. Default: `'prisma/schema'`
|
|
128
|
-
- **`
|
|
199
|
+
- **`modulePath`** (string): Path pattern to match module directories. Default: `'/modules/'`. Use `'/src/'` for NestJS projects or other domain-based structures.
|
|
129
200
|
|
|
130
201
|
```javascript
|
|
131
202
|
{
|
|
132
203
|
'@synapsestudios/data-boundaries/no-cross-domain-prisma-access': ['error', {
|
|
133
204
|
schemaDir: 'database/schemas',
|
|
134
|
-
|
|
205
|
+
modulePath: '/src/' // For NestJS-style projects
|
|
135
206
|
}]
|
|
136
207
|
}
|
|
137
208
|
```
|
|
138
209
|
|
|
139
210
|
## Directory Structure
|
|
140
211
|
|
|
141
|
-
This plugin
|
|
212
|
+
This plugin supports multiple project structures:
|
|
142
213
|
|
|
143
|
-
### Module Structure
|
|
214
|
+
### Default Module Structure
|
|
144
215
|
```
|
|
145
216
|
src/
|
|
146
217
|
modules/
|
|
@@ -154,6 +225,21 @@ src/
|
|
|
154
225
|
service.ts
|
|
155
226
|
```
|
|
156
227
|
|
|
228
|
+
### NestJS/Domain-Based Structure
|
|
229
|
+
```
|
|
230
|
+
src/
|
|
231
|
+
auth/ # auth domain
|
|
232
|
+
auth.service.ts
|
|
233
|
+
auth.controller.ts
|
|
234
|
+
organization/ # organization domain
|
|
235
|
+
organization.service.ts
|
|
236
|
+
organization.controller.ts
|
|
237
|
+
user-profile/ # user-profile domain
|
|
238
|
+
user-profile.service.ts
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Note**: For NestJS projects, set `modulePath: '/src/'` in your rule configuration.
|
|
242
|
+
|
|
157
243
|
### Schema Structure
|
|
158
244
|
```
|
|
159
245
|
prisma/
|
|
@@ -206,6 +292,85 @@ Cross-file model references are not allowed.
|
|
|
206
292
|
3. **Add application boundaries**: Enable `no-cross-domain-prisma-access` to prevent cross-domain access in application code
|
|
207
293
|
4. **Refactor violations**: Create shared services or move logic to appropriate domains
|
|
208
294
|
|
|
295
|
+
## Troubleshooting
|
|
296
|
+
|
|
297
|
+
### Common Issues
|
|
298
|
+
|
|
299
|
+
**Error: "extension for the file (.prisma) is non-standard"**
|
|
300
|
+
|
|
301
|
+
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:
|
|
302
|
+
|
|
303
|
+
```javascript
|
|
304
|
+
// .eslintrc.js
|
|
305
|
+
module.exports = {
|
|
306
|
+
parser: '@typescript-eslint/parser',
|
|
307
|
+
parserOptions: {
|
|
308
|
+
project: './tsconfig.json',
|
|
309
|
+
// DO NOT add extraFileExtensions: ['.prisma'] here
|
|
310
|
+
},
|
|
311
|
+
plugins: ['@synapsestudios/data-boundaries'],
|
|
312
|
+
overrides: [
|
|
313
|
+
{
|
|
314
|
+
files: ['**/*.prisma'],
|
|
315
|
+
parser: '@synapsestudios/data-boundaries/dist/parsers/prisma-parser', // This handles .prisma files
|
|
316
|
+
rules: {
|
|
317
|
+
'@synapsestudios/data-boundaries/no-cross-file-model-references': 'error'
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
};
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Error: "Could not determine schema directory"**
|
|
325
|
+
|
|
326
|
+
Make sure your `schemaDir` option points to the correct directory containing your Prisma schema files:
|
|
327
|
+
|
|
328
|
+
```javascript
|
|
329
|
+
{
|
|
330
|
+
'@synapsestudios/data-boundaries/no-cross-domain-prisma-access': ['error', {
|
|
331
|
+
schemaDir: 'prisma/schema', // Adjust this path as needed
|
|
332
|
+
}]
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**Rule not working on certain files**
|
|
337
|
+
|
|
338
|
+
The `no-cross-domain-prisma-access` rule only applies to files in directories that match the `modulePath` option. By default, this is `/modules/`.
|
|
339
|
+
|
|
340
|
+
For **NestJS projects** or other domain-based structures, configure `modulePath: '/src/'`:
|
|
341
|
+
|
|
342
|
+
```javascript
|
|
343
|
+
{
|
|
344
|
+
'@synapsestudios/data-boundaries/no-cross-domain-prisma-access': ['error', {
|
|
345
|
+
schemaDir: 'prisma/schema',
|
|
346
|
+
modulePath: '/src/', // ← Add this for NestJS projects
|
|
347
|
+
}]
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**Default structure** (`modulePath: '/modules/'`):
|
|
352
|
+
```
|
|
353
|
+
src/
|
|
354
|
+
modules/
|
|
355
|
+
auth/ # ✅ Will be checked
|
|
356
|
+
service.ts
|
|
357
|
+
organization/ # ✅ Will be checked
|
|
358
|
+
service.ts
|
|
359
|
+
utils/ # ❌ Will be ignored
|
|
360
|
+
helper.ts
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**NestJS structure** (`modulePath: '/src/'`):
|
|
364
|
+
```
|
|
365
|
+
src/
|
|
366
|
+
auth/ # ✅ Will be checked
|
|
367
|
+
auth.service.ts
|
|
368
|
+
organization/ # ✅ Will be checked
|
|
369
|
+
org.service.ts
|
|
370
|
+
utils/ # ❌ Will be ignored
|
|
371
|
+
helper.ts
|
|
372
|
+
```
|
|
373
|
+
|
|
209
374
|
## Contributing
|
|
210
375
|
|
|
211
376
|
Issues and pull requests are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
2
|
interface RuleOptions {
|
|
3
3
|
schemaDir: string;
|
|
4
|
-
|
|
4
|
+
modulePath: string;
|
|
5
5
|
}
|
|
6
6
|
declare const rule: ESLintUtils.RuleModule<"crossDomainAccess" | "modelNotFound" | "configError", [RuleOptions], unknown, ESLintUtils.RuleListener>;
|
|
7
7
|
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,
|
|
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,UAAU,EAAE,MAAM,CAAC;CACpB;AAyDD,QAAA,MAAM,IAAI,iIA8HR,CAAC;AAEH,SAAS,IAAI,CAAC"}
|
|
@@ -95,9 +95,9 @@ const rule = createRule({
|
|
|
95
95
|
type: 'string',
|
|
96
96
|
description: 'Directory containing Prisma schema files (relative to project root)',
|
|
97
97
|
},
|
|
98
|
-
|
|
99
|
-
type: '
|
|
100
|
-
description: '
|
|
98
|
+
modulePath: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
description: 'Path pattern to match module directories (e.g., "/modules/", "/src/")',
|
|
101
101
|
},
|
|
102
102
|
},
|
|
103
103
|
additionalProperties: false,
|
|
@@ -112,17 +112,17 @@ const rule = createRule({
|
|
|
112
112
|
defaultOptions: [
|
|
113
113
|
{
|
|
114
114
|
schemaDir: 'prisma/schema',
|
|
115
|
-
|
|
115
|
+
modulePath: '/modules/',
|
|
116
116
|
},
|
|
117
117
|
],
|
|
118
118
|
create(context, [options]) {
|
|
119
119
|
const filename = context.getFilename();
|
|
120
120
|
// Only process TypeScript files in modules
|
|
121
|
-
if (!filename.includes(
|
|
121
|
+
if (!filename.includes(options.modulePath) || !filename.match(/\.(ts|tsx)$/)) {
|
|
122
122
|
return {};
|
|
123
123
|
}
|
|
124
124
|
// Extract current module from file path
|
|
125
|
-
const currentModule = (0, schema_parser_1.extractModuleFromPath)(filename);
|
|
125
|
+
const currentModule = (0, schema_parser_1.extractModuleFromPath)(filename, options.modulePath);
|
|
126
126
|
if (!currentModule) {
|
|
127
127
|
return {};
|
|
128
128
|
}
|
|
@@ -180,10 +180,6 @@ const rule = createRule({
|
|
|
180
180
|
});
|
|
181
181
|
return;
|
|
182
182
|
}
|
|
183
|
-
// Allow access to shared models if configured
|
|
184
|
-
if (options.allowSharedModels && modelDomain === 'shared') {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
183
|
// Check if current module matches model domain
|
|
188
184
|
if (currentModule !== modelDomain) {
|
|
189
185
|
context.report({
|
|
@@ -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;AAOhC;;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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AI,CAAC,SAAS,IAAI,CAAC,IAAA,iCAAiB,EAAC,SAAS,CAAC,EAAE,CAAC;oBAChD,OAAO;gBACT,CAAC;gBAED,oDAAoD;gBACpD,MAAM,eAAe,GAAG,IAAA,iCAAiB,EAAC,SAAS,CAAC,CAAC;gBAErD,wCAAwC;gBACxC,MAAM,WAAW,GAAG,aAAa,CAAC,eAAe,CAAC,CAAC;gBACnD,IAAI,CAAC,WAAW,EAAE,CAAC;oBACjB,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,eAAe;wBAC1B,IAAI,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE;qBACrC,CAAC,CAAC;oBACH,OAAO;gBACT,CAAC;gBAED,+CAA+C;gBAC/C,IAAI,aAAa,KAAK,WAAW,EAAE,CAAC;oBAClC,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,mBAAmB;wBAC9B,IAAI,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;;GAEG;AACH,SAAgB,yBAAyB,CAAC,SAAiB;IACzD,MAAM,aAAa,GAAyB,EAAE,CAAC;IAE/C,IAAI,CAAC;QACH,iDAAiD;QACjD,MAAM,WAAW,GAAG,WAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;QAEnE,KAAK,MAAM,QAAQ,IAAI,WAAW,EAAE,CAAC;YACnC,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAClD,MAAM,MAAM,GAAG,IAAA,sBAAS,EAAC,OAAO,CAAC,CAAC;YAElC,gEAAgE;YAChE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YACpD,MAAM,UAAU,GAAG,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;YAEtF,uCAAuC;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