@goboost/scanner-typescript 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controller-extractor.d.ts +40 -0
- package/dist/controller-extractor.d.ts.map +1 -0
- package/dist/controller-extractor.js +288 -0
- package/dist/controller-extractor.js.map +1 -0
- package/dist/dto-extractor.d.ts +30 -0
- package/dist/dto-extractor.d.ts.map +1 -0
- package/dist/dto-extractor.js +294 -0
- package/dist/dto-extractor.js.map +1 -0
- package/dist/guard-extractor.d.ts +15 -0
- package/dist/guard-extractor.d.ts.map +1 -0
- package/dist/guard-extractor.js +158 -0
- package/dist/guard-extractor.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +232 -0
- package/dist/index.js.map +1 -0
- package/dist/prisma-schema-extractor.d.ts +47 -0
- package/dist/prisma-schema-extractor.d.ts.map +1 -0
- package/dist/prisma-schema-extractor.js +298 -0
- package/dist/prisma-schema-extractor.js.map +1 -0
- package/dist/unsupported-detector.d.ts +31 -0
- package/dist/unsupported-detector.d.ts.map +1 -0
- package/dist/unsupported-detector.js +204 -0
- package/dist/unsupported-detector.js.map +1 -0
- package/package.json +11 -1
- package/tsconfig.json +0 -20
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.extractPrismaSchema = extractPrismaSchema;
|
|
37
|
+
/**
|
|
38
|
+
* Prisma Schema Extractor — parses schema.prisma via @prisma/internals getDMMF()
|
|
39
|
+
* and produces goboost.db.json (DB IR v1.0.0) matching internal/ir/db_types.go.
|
|
40
|
+
*
|
|
41
|
+
* Constitution v1.2.0 Principle V: Single Shared Database — schema migrations
|
|
42
|
+
* managed from Prisma as the single source of truth. Performance Boosters use Gorm models
|
|
43
|
+
* generated from the canonical schema.
|
|
44
|
+
*/
|
|
45
|
+
const internals_1 = require("@prisma/internals");
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
// ---- Prisma type → Go type mapping ----
|
|
49
|
+
const PRISMA_TO_GO_TYPE = {
|
|
50
|
+
'String': 'string',
|
|
51
|
+
'Int': 'int64',
|
|
52
|
+
'BigInt': 'int64',
|
|
53
|
+
'Float': 'float64',
|
|
54
|
+
'Decimal': 'float64',
|
|
55
|
+
'Boolean': 'bool',
|
|
56
|
+
'DateTime': 'time.Time',
|
|
57
|
+
'Json': 'datatypes.JSON',
|
|
58
|
+
'Bytes': '[]byte',
|
|
59
|
+
};
|
|
60
|
+
const PRISMA_TO_DB_TYPE = {
|
|
61
|
+
'String': 'VARCHAR(255)',
|
|
62
|
+
'Int': 'INTEGER',
|
|
63
|
+
'BigInt': 'BIGINT',
|
|
64
|
+
'Float': 'DOUBLE PRECISION',
|
|
65
|
+
'Decimal': 'DECIMAL',
|
|
66
|
+
'Boolean': 'BOOLEAN',
|
|
67
|
+
'DateTime': 'TIMESTAMP',
|
|
68
|
+
'Json': 'JSONB',
|
|
69
|
+
'Bytes': 'BYTEA',
|
|
70
|
+
};
|
|
71
|
+
// ---- Relation type mapping ----
|
|
72
|
+
function mapRelationType(kind, isList) {
|
|
73
|
+
if (isList) {
|
|
74
|
+
return 'one-to-many';
|
|
75
|
+
}
|
|
76
|
+
// A non-list relation field on the side with the FK is many-to-one
|
|
77
|
+
return 'many-to-one';
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Detect the database provider from the schema.prisma datasource block.
|
|
81
|
+
*/
|
|
82
|
+
function detectDatabaseType(schemaContent) {
|
|
83
|
+
const providerMatch = schemaContent.match(/datasource\s+\w+\s*\{[^}]*provider\s*=\s*"(\w+)"/s);
|
|
84
|
+
if (providerMatch) {
|
|
85
|
+
const provider = providerMatch[1].toLowerCase();
|
|
86
|
+
switch (provider) {
|
|
87
|
+
case 'postgresql': return 'postgresql';
|
|
88
|
+
case 'mysql': return 'mysql';
|
|
89
|
+
case 'sqlite': return 'sqlite';
|
|
90
|
+
case 'sqlserver': return 'sqlserver';
|
|
91
|
+
case 'mongodb': return 'mongodb';
|
|
92
|
+
case 'cockroachdb': return 'cockroachdb';
|
|
93
|
+
default: return provider;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return 'postgresql'; // Default per Constitution (Principle V)
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Extract DB IR from a Prisma schema file using @prisma/internals getDMMF().
|
|
100
|
+
* Output format matches internal/ir/db_types.go (DBRoot).
|
|
101
|
+
*/
|
|
102
|
+
async function extractPrismaSchema(options) {
|
|
103
|
+
const { projectPath } = options;
|
|
104
|
+
// 1. Locate schema.prisma
|
|
105
|
+
const schemaPath = options.schemaPath || findPrismaSchema(projectPath);
|
|
106
|
+
if (!schemaPath) {
|
|
107
|
+
// No schema.prisma found — return empty DB IR (per contract: source="none")
|
|
108
|
+
return {
|
|
109
|
+
version: '1.0.0',
|
|
110
|
+
source: 'none',
|
|
111
|
+
databaseType: 'postgresql',
|
|
112
|
+
schemaName: 'public',
|
|
113
|
+
extractedAt: new Date().toISOString(),
|
|
114
|
+
tables: [],
|
|
115
|
+
enums: [],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// 2. Read schema content
|
|
119
|
+
const schemaContent = fs.readFileSync(schemaPath, 'utf-8');
|
|
120
|
+
const databaseType = detectDatabaseType(schemaContent);
|
|
121
|
+
// 3. Parse via getDMMF (offline — no database connection required)
|
|
122
|
+
const dmmf = await (0, internals_1.getDMMF)({ datamodel: schemaContent });
|
|
123
|
+
// 4. Map DMMF models → TableSpec[]
|
|
124
|
+
const tables = dmmf.datamodel.models.map((model) => {
|
|
125
|
+
const columns = [];
|
|
126
|
+
const relations = [];
|
|
127
|
+
for (const field of model.fields) {
|
|
128
|
+
if (field.kind === 'scalar' || field.kind === 'enum') {
|
|
129
|
+
columns.push(mapFieldToColumn(field, model));
|
|
130
|
+
}
|
|
131
|
+
else if (field.kind === 'object') {
|
|
132
|
+
relations.push(mapFieldToRelation(field, model));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
name: model.name,
|
|
137
|
+
schema: 'public',
|
|
138
|
+
columns,
|
|
139
|
+
relations: relations.length > 0 ? relations : [],
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
// 5. Map DMMF enums → EnumSpec[]
|
|
143
|
+
const enums = dmmf.datamodel.enums.map((e) => ({
|
|
144
|
+
name: e.name,
|
|
145
|
+
values: e.values.map((v) => v.name),
|
|
146
|
+
}));
|
|
147
|
+
// 6. Sort for determinism
|
|
148
|
+
tables.sort((a, b) => a.name.localeCompare(b.name));
|
|
149
|
+
for (const table of tables) {
|
|
150
|
+
table.columns.sort((a, b) => {
|
|
151
|
+
// Primary keys first, then alphabetical
|
|
152
|
+
if (a.isPrimary !== b.isPrimary)
|
|
153
|
+
return a.isPrimary ? -1 : 1;
|
|
154
|
+
return a.name.localeCompare(b.name);
|
|
155
|
+
});
|
|
156
|
+
table.relations.sort((a, b) => a.name.localeCompare(b.name));
|
|
157
|
+
}
|
|
158
|
+
enums.sort((a, b) => a.name.localeCompare(b.name));
|
|
159
|
+
return {
|
|
160
|
+
version: '1.0.0',
|
|
161
|
+
source: 'prisma',
|
|
162
|
+
databaseType,
|
|
163
|
+
schemaName: 'public',
|
|
164
|
+
extractedAt: new Date().toISOString(),
|
|
165
|
+
tables,
|
|
166
|
+
enums,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
// ---- Field mappers ----
|
|
170
|
+
function mapFieldToColumn(field, model) {
|
|
171
|
+
const isPrimary = field.isId || false;
|
|
172
|
+
const isAutoIncrement = hasDefaultAutoincrement(field);
|
|
173
|
+
const goType = field.kind === 'enum'
|
|
174
|
+
? 'string'
|
|
175
|
+
: (PRISMA_TO_GO_TYPE[field.type] || 'string');
|
|
176
|
+
const dbType = field.kind === 'enum'
|
|
177
|
+
? `VARCHAR(255)`
|
|
178
|
+
: (PRISMA_TO_DB_TYPE[field.type] || 'VARCHAR(255)');
|
|
179
|
+
// Apply @db.* native type overrides if present
|
|
180
|
+
const nativeType = field.nativeType;
|
|
181
|
+
let resolvedDbType = dbType;
|
|
182
|
+
if (nativeType) {
|
|
183
|
+
resolvedDbType = formatNativeType(nativeType);
|
|
184
|
+
}
|
|
185
|
+
const col = {
|
|
186
|
+
name: field.name,
|
|
187
|
+
goType,
|
|
188
|
+
dbType: resolvedDbType,
|
|
189
|
+
isPrimary,
|
|
190
|
+
isAutoIncrement,
|
|
191
|
+
isNullable: !field.isRequired,
|
|
192
|
+
isUnique: field.isUnique || false,
|
|
193
|
+
};
|
|
194
|
+
// Default value
|
|
195
|
+
const defaultVal = extractDefaultValue(field);
|
|
196
|
+
if (defaultVal) {
|
|
197
|
+
col.defaultValue = defaultVal;
|
|
198
|
+
}
|
|
199
|
+
// Build GORM tag
|
|
200
|
+
const gormTag = buildGormTag(col, field);
|
|
201
|
+
if (gormTag) {
|
|
202
|
+
col.gormTag = gormTag;
|
|
203
|
+
}
|
|
204
|
+
return col;
|
|
205
|
+
}
|
|
206
|
+
function mapFieldToRelation(field, model) {
|
|
207
|
+
const isList = field.isList;
|
|
208
|
+
const relationType = mapRelationType(field.relationName || '', isList);
|
|
209
|
+
const rel = {
|
|
210
|
+
name: field.name,
|
|
211
|
+
type: relationType,
|
|
212
|
+
fromTable: model.name,
|
|
213
|
+
toTable: field.type,
|
|
214
|
+
};
|
|
215
|
+
// Determine FK columns from the relation's fromFields
|
|
216
|
+
if (field.relationFromFields && field.relationFromFields.length > 0) {
|
|
217
|
+
rel.fromColumns = field.relationFromFields;
|
|
218
|
+
}
|
|
219
|
+
return rel;
|
|
220
|
+
}
|
|
221
|
+
// ---- Helpers ----
|
|
222
|
+
function hasDefaultAutoincrement(field) {
|
|
223
|
+
if (!field.default)
|
|
224
|
+
return false;
|
|
225
|
+
if (typeof field.default === 'object' && field.default.name === 'autoincrement') {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
function extractDefaultValue(field) {
|
|
231
|
+
if (!field.default)
|
|
232
|
+
return undefined;
|
|
233
|
+
if (typeof field.default === 'object') {
|
|
234
|
+
// Prisma function defaults: autoincrement(), now(), uuid(), cuid(), etc.
|
|
235
|
+
const name = field.default.name;
|
|
236
|
+
if (name === 'autoincrement')
|
|
237
|
+
return undefined; // Handled by isAutoIncrement
|
|
238
|
+
if (name === 'now')
|
|
239
|
+
return 'CURRENT_TIMESTAMP';
|
|
240
|
+
if (name === 'uuid')
|
|
241
|
+
return 'gen_random_uuid()';
|
|
242
|
+
if (name === 'cuid')
|
|
243
|
+
return 'gen_random_uuid()'; // Approximate
|
|
244
|
+
if (name === 'dbgenerated') {
|
|
245
|
+
const args = field.default.args;
|
|
246
|
+
return args && args.length > 0 ? String(args[0]) : undefined;
|
|
247
|
+
}
|
|
248
|
+
return name + '()';
|
|
249
|
+
}
|
|
250
|
+
// Scalar defaults
|
|
251
|
+
return String(field.default);
|
|
252
|
+
}
|
|
253
|
+
function formatNativeType(nativeType) {
|
|
254
|
+
if (!nativeType)
|
|
255
|
+
return 'VARCHAR(255)';
|
|
256
|
+
// nativeType is [typeName, args[]]
|
|
257
|
+
const [typeName, args] = nativeType;
|
|
258
|
+
if (args && args.length > 0) {
|
|
259
|
+
return `${typeName.toUpperCase()}(${args.join(', ')})`;
|
|
260
|
+
}
|
|
261
|
+
return typeName.toUpperCase();
|
|
262
|
+
}
|
|
263
|
+
function buildGormTag(col, field) {
|
|
264
|
+
const parts = [];
|
|
265
|
+
parts.push(`column:${col.name}`);
|
|
266
|
+
parts.push(`type:${col.dbType}`);
|
|
267
|
+
if (col.isPrimary) {
|
|
268
|
+
parts.push('primaryKey');
|
|
269
|
+
}
|
|
270
|
+
if (col.isAutoIncrement) {
|
|
271
|
+
parts.push('autoIncrement');
|
|
272
|
+
}
|
|
273
|
+
if (!col.isNullable) {
|
|
274
|
+
parts.push('not null');
|
|
275
|
+
}
|
|
276
|
+
if (col.isUnique) {
|
|
277
|
+
parts.push('uniqueIndex');
|
|
278
|
+
}
|
|
279
|
+
if (col.defaultValue) {
|
|
280
|
+
parts.push(`default:${col.defaultValue}`);
|
|
281
|
+
}
|
|
282
|
+
return parts.join(';');
|
|
283
|
+
}
|
|
284
|
+
function findPrismaSchema(projectPath) {
|
|
285
|
+
// Standard Prisma schema locations
|
|
286
|
+
const candidates = [
|
|
287
|
+
path.join(projectPath, 'prisma', 'schema.prisma'),
|
|
288
|
+
path.join(projectPath, 'schema.prisma'),
|
|
289
|
+
path.join(projectPath, 'prisma', 'schema'),
|
|
290
|
+
];
|
|
291
|
+
for (const candidate of candidates) {
|
|
292
|
+
if (fs.existsSync(candidate)) {
|
|
293
|
+
return candidate;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=prisma-schema-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma-schema-extractor.js","sourceRoot":"","sources":["../src/prisma-schema-extractor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6HA,kDAyEC;AAtMD;;;;;;;GAOG;AACH,iDAA4C;AAC5C,uCAAyB;AACzB,2CAA6B;AA8C7B,0CAA0C;AAE1C,MAAM,iBAAiB,GAA2B;IAChD,QAAQ,EAAI,QAAQ;IACpB,KAAK,EAAO,OAAO;IACnB,QAAQ,EAAI,OAAO;IACnB,OAAO,EAAK,SAAS;IACrB,SAAS,EAAG,SAAS;IACrB,SAAS,EAAG,MAAM;IAClB,UAAU,EAAE,WAAW;IACvB,MAAM,EAAM,gBAAgB;IAC5B,OAAO,EAAK,QAAQ;CACrB,CAAC;AAEF,MAAM,iBAAiB,GAA2B;IAChD,QAAQ,EAAI,cAAc;IAC1B,KAAK,EAAO,SAAS;IACrB,QAAQ,EAAI,QAAQ;IACpB,OAAO,EAAK,kBAAkB;IAC9B,SAAS,EAAG,SAAS;IACrB,SAAS,EAAG,SAAS;IACrB,UAAU,EAAE,WAAW;IACvB,MAAM,EAAM,OAAO;IACnB,OAAO,EAAK,OAAO;CACpB,CAAC;A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,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3B,CAAC;IACD,IAAI,GAAG,CAAC,eAAe,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;QACpB,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC5B,CAAC;IACD,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC;QACrB,KAAK,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,gBAAgB,CAAC,WAAmB;IAC3C,mCAAmC;IACnC,MAAM,UAAU,GAAG;QACjB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,eAAe,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC;KAC3C,CAAC;IAEF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7B,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unsupported feature detector - flags routes using V2 features
|
|
3
|
+
* Scans for @UseInterceptors, @UsePipes, @UseFilters, custom decorators
|
|
4
|
+
*/
|
|
5
|
+
import { Project, ClassDeclaration } from 'ts-morph';
|
|
6
|
+
interface RouteMapping {
|
|
7
|
+
handlerName: string;
|
|
8
|
+
unsupportedFeatures: string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Detect unsupported features for a specific route
|
|
12
|
+
*/
|
|
13
|
+
export declare function detectUnsupported(project: Project, route: RouteMapping): string[];
|
|
14
|
+
/**
|
|
15
|
+
* Detect unsupported features for all routes in a controller class
|
|
16
|
+
*/
|
|
17
|
+
export declare function detectUnsupportedForController(classDecl: ClassDeclaration): Map<string, string[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a class has any controller-level unsupported features
|
|
20
|
+
*/
|
|
21
|
+
export declare function detectClassLevelUnsupported(classDecl: ClassDeclaration): string[];
|
|
22
|
+
/**
|
|
23
|
+
* Check if a route can be generated (no unsupported features)
|
|
24
|
+
*/
|
|
25
|
+
export declare function canGenerate(unsupportedFeatures: string[]): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Get a human-readable summary of unsupported features
|
|
28
|
+
*/
|
|
29
|
+
export declare function getUnsupportedSummary(unsupportedFeatures: string[]): string;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=unsupported-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsupported-detector.d.ts","sourceRoot":"","sources":["../src/unsupported-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAc,gBAAgB,EAAgC,MAAM,UAAU,CAAC;AAE/F,UAAU,YAAY;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAiCD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,YAAY,GAClB,MAAM,EAAE,CAiBV;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,gBAAgB,GAC1B,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAyBvB;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAWjF;AA2HD;;GAEG;AACH,wBAAgB,WAAW,CAAC,mBAAmB,EAAE,MAAM,EAAE,GAAG,OAAO,CAElE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,mBAAmB,EAAE,MAAM,EAAE,GAAG,MAAM,CAM3E"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectUnsupported = detectUnsupported;
|
|
4
|
+
exports.detectUnsupportedForController = detectUnsupportedForController;
|
|
5
|
+
exports.detectClassLevelUnsupported = detectClassLevelUnsupported;
|
|
6
|
+
exports.canGenerate = canGenerate;
|
|
7
|
+
exports.getUnsupportedSummary = getUnsupportedSummary;
|
|
8
|
+
// V1 unsupported decorators
|
|
9
|
+
const UNSUPPORTED_DECORATORS = [
|
|
10
|
+
'UseInterceptors',
|
|
11
|
+
'UsePipes',
|
|
12
|
+
'UseFilters',
|
|
13
|
+
'SetMetadata',
|
|
14
|
+
'Redirect',
|
|
15
|
+
'Render',
|
|
16
|
+
];
|
|
17
|
+
// Parameter decorators that are not supported
|
|
18
|
+
const UNSUPPORTED_PARAM_DECORATORS = [
|
|
19
|
+
'Req',
|
|
20
|
+
'Res',
|
|
21
|
+
'Next',
|
|
22
|
+
'Session',
|
|
23
|
+
'Headers',
|
|
24
|
+
'Ip',
|
|
25
|
+
'HostParam',
|
|
26
|
+
];
|
|
27
|
+
// Patterns that indicate complex async behavior
|
|
28
|
+
const UNSUPPORTED_PATTERNS = [
|
|
29
|
+
'EventEmitter',
|
|
30
|
+
'Observable',
|
|
31
|
+
'MessagePattern',
|
|
32
|
+
'EventPattern',
|
|
33
|
+
'WebSocket',
|
|
34
|
+
'WsGateway',
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* Detect unsupported features for a specific route
|
|
38
|
+
*/
|
|
39
|
+
function detectUnsupported(project, route) {
|
|
40
|
+
const unsupported = [];
|
|
41
|
+
// Find the method in the project
|
|
42
|
+
for (const sourceFile of project.getSourceFiles()) {
|
|
43
|
+
for (const classDecl of sourceFile.getClasses()) {
|
|
44
|
+
const method = classDecl.getMethod(route.handlerName);
|
|
45
|
+
if (method) {
|
|
46
|
+
collectUnsupportedDecorators(method, unsupported);
|
|
47
|
+
collectUnsupportedParamDecorators(method, unsupported);
|
|
48
|
+
collectUnsupportedPatterns(method, unsupported);
|
|
49
|
+
return unsupported;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return unsupported;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Detect unsupported features for all routes in a controller class
|
|
57
|
+
*/
|
|
58
|
+
function detectUnsupportedForController(classDecl) {
|
|
59
|
+
const routeUnsupported = new Map();
|
|
60
|
+
for (const method of classDecl.getMethods()) {
|
|
61
|
+
const methodName = method.getName();
|
|
62
|
+
// Only check methods that are route handlers (have HTTP method decorators)
|
|
63
|
+
const httpDecorators = ['Get', 'Post', 'Put', 'Delete', 'Patch'];
|
|
64
|
+
const hasHttpDecorator = method.getDecorators().some(d => httpDecorators.includes(d.getName()));
|
|
65
|
+
if (hasHttpDecorator) {
|
|
66
|
+
const unsupported = [];
|
|
67
|
+
collectUnsupportedDecorators(method, unsupported);
|
|
68
|
+
collectUnsupportedParamDecorators(method, unsupported);
|
|
69
|
+
collectUnsupportedPatterns(method, unsupported);
|
|
70
|
+
if (unsupported.length > 0) {
|
|
71
|
+
routeUnsupported.set(methodName, unsupported);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return routeUnsupported;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Check if a class has any controller-level unsupported features
|
|
79
|
+
*/
|
|
80
|
+
function detectClassLevelUnsupported(classDecl) {
|
|
81
|
+
const unsupported = [];
|
|
82
|
+
for (const decorator of classDecl.getDecorators()) {
|
|
83
|
+
const name = decorator.getName();
|
|
84
|
+
if (UNSUPPORTED_DECORATORS.includes(name)) {
|
|
85
|
+
unsupported.push(`${name} decorator at class level`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return unsupported;
|
|
89
|
+
}
|
|
90
|
+
function collectUnsupportedDecorators(method, unsupported) {
|
|
91
|
+
const decorators = method.getDecorators();
|
|
92
|
+
for (const decorator of decorators) {
|
|
93
|
+
const name = decorator.getName();
|
|
94
|
+
// Check for unsupported method decorators
|
|
95
|
+
if (UNSUPPORTED_DECORATORS.includes(name)) {
|
|
96
|
+
const feature = getFeatureName(name);
|
|
97
|
+
if (!unsupported.includes(feature)) {
|
|
98
|
+
unsupported.push(feature);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Check for custom decorators (not standard NestJS)
|
|
102
|
+
if (isCustomDecorator(decorator)) {
|
|
103
|
+
const customFeature = `custom decorator: ${name}`;
|
|
104
|
+
if (!unsupported.includes(customFeature)) {
|
|
105
|
+
unsupported.push(customFeature);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function collectUnsupportedParamDecorators(method, unsupported) {
|
|
111
|
+
for (const param of method.getParameters()) {
|
|
112
|
+
for (const decorator of param.getDecorators()) {
|
|
113
|
+
const name = decorator.getName();
|
|
114
|
+
if (UNSUPPORTED_PARAM_DECORATORS.includes(name)) {
|
|
115
|
+
const feature = `${name}() parameter`;
|
|
116
|
+
if (!unsupported.includes(feature)) {
|
|
117
|
+
unsupported.push(feature);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function collectUnsupportedPatterns(method, unsupported) {
|
|
124
|
+
const bodyText = method.getBodyText();
|
|
125
|
+
if (!bodyText)
|
|
126
|
+
return;
|
|
127
|
+
for (const pattern of UNSUPPORTED_PATTERNS) {
|
|
128
|
+
if (bodyText.includes(pattern)) {
|
|
129
|
+
const feature = `complex pattern: ${pattern}`;
|
|
130
|
+
if (!unsupported.includes(feature)) {
|
|
131
|
+
unsupported.push(feature);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Check for file upload patterns
|
|
136
|
+
if (bodyText.includes('FileInterceptor') || bodyText.includes('FilesInterceptor') ||
|
|
137
|
+
bodyText.includes('UploadedFile') || bodyText.includes('UploadedFiles')) {
|
|
138
|
+
const feature = 'file upload';
|
|
139
|
+
if (!unsupported.includes(feature)) {
|
|
140
|
+
unsupported.push(feature);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Check for SSE/WebSocket patterns
|
|
144
|
+
if (bodyText.includes('Sse') || bodyText.includes('MessageEvent')) {
|
|
145
|
+
const feature = 'Server-Sent Events';
|
|
146
|
+
if (!unsupported.includes(feature)) {
|
|
147
|
+
unsupported.push(feature);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function getFeatureName(decoratorName) {
|
|
152
|
+
const featureMap = {
|
|
153
|
+
'UseInterceptors': 'interceptor',
|
|
154
|
+
'UsePipes': 'pipe',
|
|
155
|
+
'UseFilters': 'exception filter',
|
|
156
|
+
'SetMetadata': 'custom metadata',
|
|
157
|
+
'Redirect': 'redirect',
|
|
158
|
+
'Render': 'view rendering',
|
|
159
|
+
};
|
|
160
|
+
return featureMap[decoratorName] || decoratorName.toLowerCase();
|
|
161
|
+
}
|
|
162
|
+
function isCustomDecorator(decorator) {
|
|
163
|
+
const knownDecorators = [
|
|
164
|
+
// HTTP methods
|
|
165
|
+
'Get', 'Post', 'Put', 'Delete', 'Patch', 'Options', 'Head', 'All',
|
|
166
|
+
// Parameters
|
|
167
|
+
'Body', 'Query', 'Param', 'Headers', 'Ip', 'HostParam',
|
|
168
|
+
// Guards
|
|
169
|
+
'UseGuards',
|
|
170
|
+
// Common
|
|
171
|
+
'HttpCode', 'Header', 'Redirect', 'Render',
|
|
172
|
+
// NestJS core
|
|
173
|
+
'Injectable', 'Controller', 'Module', 'Inject',
|
|
174
|
+
// Hybrid
|
|
175
|
+
'HybridRoute',
|
|
176
|
+
// Validation
|
|
177
|
+
...getValidationDecorators(),
|
|
178
|
+
];
|
|
179
|
+
return !knownDecorators.includes(decorator.getName());
|
|
180
|
+
}
|
|
181
|
+
function getValidationDecorators() {
|
|
182
|
+
return [
|
|
183
|
+
'IsString', 'IsNumber', 'IsEmail', 'IsInt', 'IsBoolean',
|
|
184
|
+
'Min', 'Max', 'MinLength', 'MaxLength', 'IsOptional',
|
|
185
|
+
'IsDate', 'IsArray', 'IsEnum', 'IsUUID', 'IsUrl',
|
|
186
|
+
'Matches', 'IsNotEmpty', 'IsDefined', 'IsPositive',
|
|
187
|
+
];
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Check if a route can be generated (no unsupported features)
|
|
191
|
+
*/
|
|
192
|
+
function canGenerate(unsupportedFeatures) {
|
|
193
|
+
return unsupportedFeatures.length === 0;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get a human-readable summary of unsupported features
|
|
197
|
+
*/
|
|
198
|
+
function getUnsupportedSummary(unsupportedFeatures) {
|
|
199
|
+
if (unsupportedFeatures.length === 0) {
|
|
200
|
+
return 'All features supported';
|
|
201
|
+
}
|
|
202
|
+
return `Unsupported features: ${unsupportedFeatures.join(', ')}`;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=unsupported-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unsupported-detector.js","sourceRoot":"","sources":["../src/unsupported-detector.ts"],"names":[],"mappings":";;AA6CA,8CAoBC;AAKD,wEA2BC;AAKD,kEAWC;AA8HD,kCAEC;AAKD,sDAMC;AAjPD,4BAA4B;AAC5B,MAAM,sBAAsB,GAAG;IAC7B,iBAAiB;IACjB,UAAU;IACV,YAAY;IACZ,aAAa;IACb,UAAU;IACV,QAAQ;CACT,CAA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": "@goboost/scanner-typescript",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "TypeScript AST scanner for source-framework-to-Go migration",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
7
11
|
"scripts": {
|
|
8
12
|
"build": "tsc",
|
|
13
|
+
"prepublishOnly": "npm run build",
|
|
9
14
|
"scan": "node dist/index.js"
|
|
10
15
|
},
|
|
11
16
|
"dependencies": {
|
|
@@ -15,5 +20,10 @@
|
|
|
15
20
|
"devDependencies": {
|
|
16
21
|
"@types/node": "^20.10.0",
|
|
17
22
|
"typescript": "^5.3.0"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/abdullahal39/GoBoost.git"
|
|
18
28
|
}
|
|
19
29
|
}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"lib": ["ES2020"],
|
|
6
|
-
"outDir": "./dist",
|
|
7
|
-
"rootDir": "./src",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"declaration": true,
|
|
13
|
-
"declarationMap": true,
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"moduleResolution": "node"
|
|
17
|
-
},
|
|
18
|
-
"include": ["src/**/*"],
|
|
19
|
-
"exclude": ["node_modules", "dist"]
|
|
20
|
-
}
|