@memberjunction/codegen-lib 4.4.0 → 5.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 +163 -0
- package/dist/Angular/angular-codegen.d.ts +12 -0
- package/dist/Angular/angular-codegen.d.ts.map +1 -1
- package/dist/Angular/angular-codegen.js +78 -12
- package/dist/Angular/angular-codegen.js.map +1 -1
- package/dist/Angular/related-entity-components.d.ts.map +1 -1
- package/dist/Angular/related-entity-components.js +10 -3
- package/dist/Angular/related-entity-components.js.map +1 -1
- package/dist/Database/manage-metadata.d.ts +40 -0
- package/dist/Database/manage-metadata.d.ts.map +1 -1
- package/dist/Database/manage-metadata.js +103 -13
- package/dist/Database/manage-metadata.js.map +1 -1
- package/dist/Database/sql_codegen.d.ts +10 -3
- package/dist/Database/sql_codegen.d.ts.map +1 -1
- package/dist/Database/sql_codegen.js +79 -15
- package/dist/Database/sql_codegen.js.map +1 -1
- package/dist/EntityNameScanner/EntityNameScanner.d.ts +166 -0
- package/dist/EntityNameScanner/EntityNameScanner.d.ts.map +1 -0
- package/dist/EntityNameScanner/EntityNameScanner.js +758 -0
- package/dist/EntityNameScanner/EntityNameScanner.js.map +1 -0
- package/dist/EntityNameScanner/HtmlEntityNameScanner.d.ts +86 -0
- package/dist/EntityNameScanner/HtmlEntityNameScanner.d.ts.map +1 -0
- package/dist/EntityNameScanner/HtmlEntityNameScanner.js +262 -0
- package/dist/EntityNameScanner/HtmlEntityNameScanner.js.map +1 -0
- package/dist/EntityNameScanner/MetadataNameScanner.d.ts +90 -0
- package/dist/EntityNameScanner/MetadataNameScanner.d.ts.map +1 -0
- package/dist/EntityNameScanner/MetadataNameScanner.js +426 -0
- package/dist/EntityNameScanner/MetadataNameScanner.js.map +1 -0
- package/dist/EntityNameScanner/entity-rename-map.d.ts +31 -0
- package/dist/EntityNameScanner/entity-rename-map.d.ts.map +1 -0
- package/dist/EntityNameScanner/entity-rename-map.js +3012 -0
- package/dist/EntityNameScanner/entity-rename-map.js.map +1 -0
- package/dist/Misc/action_subclasses_codegen.d.ts +2 -2
- package/dist/Misc/action_subclasses_codegen.d.ts.map +1 -1
- package/dist/Misc/action_subclasses_codegen.js.map +1 -1
- package/dist/Misc/createNewUser.js +6 -6
- package/dist/Misc/createNewUser.js.map +1 -1
- package/dist/Misc/entity_subclasses_codegen.js +2 -2
- package/dist/Misc/entity_subclasses_codegen.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/runCodeGen.d.ts.map +1 -1
- package/dist/runCodeGen.js +24 -3
- package/dist/runCodeGen.js.map +1 -1
- package/package.json +15 -15
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST-based scanner/fixer for hardcoded entity names AND class name references
|
|
3
|
+
* in TypeScript source code, for the MemberJunction v5.0 migration.
|
|
4
|
+
*
|
|
5
|
+
* Three replacement strategies (ported from tools/migrate-entity-refs.js):
|
|
6
|
+
*
|
|
7
|
+
* 1. **Class names** (regex with word boundaries):
|
|
8
|
+
* `ActionEntity` → `MJActionEntity`, `ActionSchema` → `MJActionSchema`,
|
|
9
|
+
* `ActionEntityType` → `MJActionEntityType`
|
|
10
|
+
*
|
|
11
|
+
* 2. **Multi-word entity names** (regex with quote boundaries):
|
|
12
|
+
* `'Action Categories'` → `'MJ: Action Categories'`
|
|
13
|
+
*
|
|
14
|
+
* 3. **Single-word entity names** (TypeScript AST):
|
|
15
|
+
* Only replaces string literals in confirmed entity-name contexts
|
|
16
|
+
* (EntityName properties, GetEntityObject args, RegisterClass decorators, etc.)
|
|
17
|
+
*
|
|
18
|
+
* Usage (via MJCLI):
|
|
19
|
+
* mj codegen 5-0-fix-entity-names --path packages/Angular
|
|
20
|
+
* mj codegen 5-0-fix-entity-names --path packages/Angular --fix
|
|
21
|
+
*
|
|
22
|
+
* Or programmatically:
|
|
23
|
+
* import { scanEntityNames } from '@memberjunction/codegen-lib';
|
|
24
|
+
* const result = await scanEntityNames({ TargetPath: './packages' });
|
|
25
|
+
*/
|
|
26
|
+
import { type EntityRenameEntry } from './entity-rename-map.js';
|
|
27
|
+
/** The kind of pattern where an old name was found. */
|
|
28
|
+
export type EntityNamePatternKind = 'GetEntityObject' | 'OpenEntityRecord' | 'EntityNameMethod' | 'EntityNameProperty' | 'RegisterClass' | 'NameComparison' | 'ClassName' | 'MultiWordEntityName';
|
|
29
|
+
/**
|
|
30
|
+
* A single finding: one string literal or identifier in source code that uses
|
|
31
|
+
* an old entity name or class name.
|
|
32
|
+
*/
|
|
33
|
+
export interface EntityNameFinding {
|
|
34
|
+
/** Absolute path to the source file */
|
|
35
|
+
FilePath: string;
|
|
36
|
+
/** 1-based line number */
|
|
37
|
+
Line: number;
|
|
38
|
+
/** 0-based character offset within the line */
|
|
39
|
+
Column: number;
|
|
40
|
+
/** The old name found */
|
|
41
|
+
OldName: string;
|
|
42
|
+
/** The corrected name */
|
|
43
|
+
NewName: string;
|
|
44
|
+
/** The quote character used (' or " or `) — empty string for class name references */
|
|
45
|
+
QuoteChar: string;
|
|
46
|
+
/** 0-based start position of the token in the file */
|
|
47
|
+
StartPos: number;
|
|
48
|
+
/** 0-based end position of the token in the file */
|
|
49
|
+
EndPos: number;
|
|
50
|
+
/** The kind of pattern matched */
|
|
51
|
+
PatternKind: EntityNamePatternKind;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Options for the entity name scanner.
|
|
55
|
+
*/
|
|
56
|
+
export interface EntityNameScanOptions {
|
|
57
|
+
/** File or directory to scan */
|
|
58
|
+
TargetPath: string;
|
|
59
|
+
/**
|
|
60
|
+
* Path to entity_subclasses.ts for building the rename map dynamically.
|
|
61
|
+
* If not provided, uses the embedded rename map compiled into this package.
|
|
62
|
+
*/
|
|
63
|
+
EntitySubclassesPath?: string;
|
|
64
|
+
/** Whether to apply fixes in place. Default: false (dry-run). */
|
|
65
|
+
Fix?: boolean;
|
|
66
|
+
/** Additional glob patterns to exclude from scanning. */
|
|
67
|
+
ExcludePatterns?: string[];
|
|
68
|
+
/** If true, logs progress to console. Default: true. */
|
|
69
|
+
Verbose?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Result of a scan (and optional fix) operation.
|
|
73
|
+
*/
|
|
74
|
+
export interface EntityNameScanResult {
|
|
75
|
+
Success: boolean;
|
|
76
|
+
/** All findings across all scanned files */
|
|
77
|
+
Findings: EntityNameFinding[];
|
|
78
|
+
/** Absolute paths of files that were modified (only in fix mode) */
|
|
79
|
+
FixedFiles: string[];
|
|
80
|
+
/** Number of files scanned */
|
|
81
|
+
FilesScanned: number;
|
|
82
|
+
/** Number of entries in the rename map */
|
|
83
|
+
RenameMapSize: number;
|
|
84
|
+
/** Errors encountered during scanning */
|
|
85
|
+
Errors: string[];
|
|
86
|
+
}
|
|
87
|
+
export type { EntityRenameEntry } from './entity-rename-map.js';
|
|
88
|
+
export { ENTITY_RENAME_MAP } from './entity-rename-map.js';
|
|
89
|
+
/** A precompiled regex rule for class name or multi-word entity name replacement. */
|
|
90
|
+
export interface RegexRule {
|
|
91
|
+
old: string;
|
|
92
|
+
new: string;
|
|
93
|
+
pattern: RegExp;
|
|
94
|
+
}
|
|
95
|
+
/** A multi-word entity name rule with patterns for each quote style. */
|
|
96
|
+
export interface MultiWordNameRule {
|
|
97
|
+
old: string;
|
|
98
|
+
new: string;
|
|
99
|
+
singleQuotePattern: RegExp;
|
|
100
|
+
doubleQuotePattern: RegExp;
|
|
101
|
+
backtickPattern: RegExp;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Builds class rename rules from the rename map entries.
|
|
105
|
+
* For each entry with classNameChanged=true, creates regex rules for:
|
|
106
|
+
* - OldClassNameEntityType → NewClassNameEntityType (zod inferred type)
|
|
107
|
+
* - OldClassNameSchema → NewClassNameSchema (zod schema constant)
|
|
108
|
+
* - OldClassNameEntity → NewClassNameEntity (class name itself)
|
|
109
|
+
*
|
|
110
|
+
* Uses negative lookbehind for / and . to avoid matching inside file paths
|
|
111
|
+
* (e.g., `import { Foo } from './custom/OldClassNameEntity'` should NOT rename the path).
|
|
112
|
+
*/
|
|
113
|
+
export declare function buildClassRenameRules(entries: EntityRenameEntry[]): RegexRule[];
|
|
114
|
+
/**
|
|
115
|
+
* Builds multi-word entity name regex rules.
|
|
116
|
+
* For each entry with nameChanged=true AND a multi-word old name,
|
|
117
|
+
* creates patterns that match the old name inside quotes.
|
|
118
|
+
*/
|
|
119
|
+
export declare function buildMultiWordNameRules(entries: EntityRenameEntry[]): MultiWordNameRule[];
|
|
120
|
+
/**
|
|
121
|
+
* Builds an entity name rename map (old → new) from the embedded data.
|
|
122
|
+
* This is the simple entity-name-only map used by the HTML and metadata scanners.
|
|
123
|
+
*/
|
|
124
|
+
export declare function loadEmbeddedRenameMap(): Map<string, string>;
|
|
125
|
+
/**
|
|
126
|
+
* Parses entity_subclasses.ts to build a map of old entity names to new
|
|
127
|
+
* (MJ:-prefixed) entity names.
|
|
128
|
+
*
|
|
129
|
+
* Scans for `@RegisterClass(BaseEntity, 'MJ: SomeName')` decorators and
|
|
130
|
+
* creates a mapping: `'SomeName' -> 'MJ: SomeName'`.
|
|
131
|
+
*/
|
|
132
|
+
export declare function buildEntityNameMap(entitySubclassesPath: string): Map<string, string>;
|
|
133
|
+
/**
|
|
134
|
+
* Builds the entity name rename map, trying entity_subclasses.ts first and
|
|
135
|
+
* falling back to the embedded rename map compiled into this package.
|
|
136
|
+
*/
|
|
137
|
+
export declare function resolveEntityNameMap(basePath: string, explicitPath: string | undefined, verbose: boolean): Map<string, string>;
|
|
138
|
+
/**
|
|
139
|
+
* Scans a single TypeScript file for entity name and class name references
|
|
140
|
+
* that need updating for the v5.0 migration.
|
|
141
|
+
*
|
|
142
|
+
* Applies all three strategies:
|
|
143
|
+
* 1. Regex-based class name scanning
|
|
144
|
+
* 2. Regex-based multi-word entity name scanning
|
|
145
|
+
* 3. AST-based single-word entity name scanning
|
|
146
|
+
*/
|
|
147
|
+
export declare function scanFile(filePath: string, sourceText: string, renameMap: Map<string, string>, classRules?: RegexRule[], multiWordRules?: MultiWordNameRule[]): EntityNameFinding[];
|
|
148
|
+
/**
|
|
149
|
+
* Applies fixes to a file by replacing old names with new names
|
|
150
|
+
* at the exact positions identified by the scanner.
|
|
151
|
+
*
|
|
152
|
+
* Processes findings from end to start to preserve byte offsets.
|
|
153
|
+
*/
|
|
154
|
+
export declare function fixFile(sourceText: string, findings: EntityNameFinding[]): string;
|
|
155
|
+
/**
|
|
156
|
+
* Scans TypeScript files for hardcoded entity names and class name references
|
|
157
|
+
* that need updating for the MemberJunction v5.0 migration, and optionally
|
|
158
|
+
* fixes them in place.
|
|
159
|
+
*
|
|
160
|
+
* Three strategies are applied:
|
|
161
|
+
* 1. Class name renames (regex): ActionEntity → MJActionEntity
|
|
162
|
+
* 2. Multi-word entity name renames (regex): 'AI Models' → 'MJ: AI Models'
|
|
163
|
+
* 3. Single-word entity name renames (AST): 'Actions' → 'MJ: Actions' (context-verified)
|
|
164
|
+
*/
|
|
165
|
+
export declare function scanEntityNames(options: EntityNameScanOptions): Promise<EntityNameScanResult>;
|
|
166
|
+
//# sourceMappingURL=EntityNameScanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityNameScanner.d.ts","sourceRoot":"","sources":["../../src/EntityNameScanner/EntityNameScanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAMH,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMhF,uDAAuD;AACvD,MAAM,MAAM,qBAAqB,GAC3B,iBAAiB,GACjB,kBAAkB,GAClB,kBAAkB,GAClB,oBAAoB,GACpB,eAAe,GACf,gBAAgB,GAChB,WAAW,GACX,qBAAqB,CAAC;AAE5B;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,uCAAuC;IACv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