masterrecord 0.2.36 → 0.3.1
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/.claude/settings.local.json +20 -1
- package/Entity/entityModel.js +6 -0
- package/Entity/entityTrackerModel.js +20 -3
- package/Entity/fieldTransformer.js +266 -0
- package/Migrations/migrationMySQLQuery.js +145 -1
- package/Migrations/migrationPostgresQuery.js +402 -0
- package/Migrations/migrationSQLiteQuery.js +145 -1
- package/Migrations/schema.js +131 -28
- package/QueryLanguage/queryMethods.js +193 -15
- package/QueryLanguage/queryParameters.js +136 -0
- package/QueryLanguage/queryScript.js +13 -4
- package/SQLLiteEngine.js +331 -20
- package/context.js +91 -14
- package/docs/INCLUDES_CLARIFICATION.md +202 -0
- package/docs/METHODS_REFERENCE.md +184 -0
- package/docs/MIGRATIONS_GUIDE.md +699 -0
- package/docs/POSTGRESQL_SETUP.md +415 -0
- package/examples/jsonArrayTransformer.js +215 -0
- package/mySQLEngine.js +273 -17
- package/package.json +3 -3
- package/postgresEngine.js +600 -483
- package/postgresSyncConnect.js +209 -0
- package/readme.md +1046 -416
- package/test/anyCommaStringTest.js +237 -0
- package/test/anyMethodTest.js +176 -0
- package/test/findByIdTest.js +227 -0
- package/test/includesFeatureTest.js +183 -0
- package/test/includesTransformTest.js +110 -0
- package/test/newMethodTest.js +330 -0
- package/test/newMethodUnitTest.js +320 -0
- package/test/parameterizedPlaceholderTest.js +159 -0
- package/test/postgresEngineTest.js +463 -0
- package/test/postgresIntegrationTest.js +381 -0
- package/test/securityTest.js +268 -0
- package/test/singleDollarPlaceholderTest.js +238 -0
- package/test/transformerTest.js +287 -0
- package/test/verifyFindById.js +169 -0
- package/test/verifyNewMethod.js +191 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verify .new() Method Implementation
|
|
3
|
+
*
|
|
4
|
+
* Simple verification that the .new() method exists in queryMethods.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
console.log("╔════════════════════════════════════════════════════════════════╗");
|
|
11
|
+
console.log("║ Verify .new() Method Implementation ║");
|
|
12
|
+
console.log("╚════════════════════════════════════════════════════════════════╝\n");
|
|
13
|
+
|
|
14
|
+
let passed = 0;
|
|
15
|
+
let failed = 0;
|
|
16
|
+
|
|
17
|
+
// Test 1: Check file exists
|
|
18
|
+
console.log("📝 Test 1: Check queryMethods.js exists");
|
|
19
|
+
console.log("──────────────────────────────────────────────────");
|
|
20
|
+
|
|
21
|
+
const queryMethodsPath = path.join(__dirname, '../QueryLanguage/queryMethods.js');
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
if(fs.existsSync(queryMethodsPath)) {
|
|
25
|
+
console.log(" ✓ queryMethods.js found");
|
|
26
|
+
passed++;
|
|
27
|
+
} else {
|
|
28
|
+
console.log(" ✗ queryMethods.js not found");
|
|
29
|
+
failed++;
|
|
30
|
+
}
|
|
31
|
+
} catch(err) {
|
|
32
|
+
console.log(` ✗ Error: ${err.message}`);
|
|
33
|
+
failed++;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Test 2: Check .new() method exists in file
|
|
37
|
+
console.log("\n📝 Test 2: Check .new() method is implemented");
|
|
38
|
+
console.log("──────────────────────────────────────────────────");
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const content = fs.readFileSync(queryMethodsPath, 'utf8');
|
|
42
|
+
|
|
43
|
+
// Check for method definition
|
|
44
|
+
const hasNewMethod = /new\s*\(\s*\)\s*\{/.test(content);
|
|
45
|
+
const hasComment = /Creates a new empty entity instance/i.test(content);
|
|
46
|
+
const hasTracking = /this\.__context\.__track\(newEntity\)/.test(content);
|
|
47
|
+
const hasPropertySetup = /Object\.defineProperty\(newEntity/.test(content);
|
|
48
|
+
|
|
49
|
+
if(hasNewMethod) {
|
|
50
|
+
console.log(" ✓ new() method definition found");
|
|
51
|
+
|
|
52
|
+
if(hasComment) {
|
|
53
|
+
console.log(" ✓ Method documentation present");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if(hasTracking) {
|
|
57
|
+
console.log(" ✓ Entity tracking code present");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if(hasPropertySetup) {
|
|
61
|
+
console.log(" ✓ Property definition code present");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
passed++;
|
|
65
|
+
} else {
|
|
66
|
+
console.log(" ✗ new() method not found in queryMethods.js");
|
|
67
|
+
failed++;
|
|
68
|
+
}
|
|
69
|
+
} catch(err) {
|
|
70
|
+
console.log(` ✗ Error: ${err.message}`);
|
|
71
|
+
failed++;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Test 3: Verify method structure
|
|
75
|
+
console.log("\n📝 Test 3: Verify method implementation structure");
|
|
76
|
+
console.log("──────────────────────────────────────────────────");
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
const content = fs.readFileSync(queryMethodsPath, 'utf8');
|
|
80
|
+
|
|
81
|
+
// Extract the new() method
|
|
82
|
+
const methodMatch = content.match(/new\s*\(\s*\)\s*\{[\s\S]*?^\s{4}\}/m);
|
|
83
|
+
|
|
84
|
+
if(methodMatch) {
|
|
85
|
+
const methodCode = methodMatch[0];
|
|
86
|
+
|
|
87
|
+
const checks = [
|
|
88
|
+
{ name: '__state = "insert"', pattern: /__state\s*:\s*"insert"/ },
|
|
89
|
+
{ name: '__entity reference', pattern: /__entity\s*:\s*this\.__entity/ },
|
|
90
|
+
{ name: '__context reference', pattern: /__context\s*:\s*this\.__context/ },
|
|
91
|
+
{ name: '__dirtyFields array', pattern: /__dirtyFields\s*:\s*\[/ },
|
|
92
|
+
{ name: 'Property loop', pattern: /for\s*\(\s*var\s+fieldName\s+in\s+this\.__entity\s*\)/ },
|
|
93
|
+
{ name: 'Skip navigational', pattern: /isNavigational/ },
|
|
94
|
+
{ name: 'defineProperty', pattern: /Object\.defineProperty/ },
|
|
95
|
+
{ name: 'Track entity', pattern: /this\.__context\.__track/ },
|
|
96
|
+
{ name: 'Return entity', pattern: /return\s+newEntity/ }
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
let allChecksPass = true;
|
|
100
|
+
|
|
101
|
+
checks.forEach(check => {
|
|
102
|
+
if(check.pattern.test(methodCode)) {
|
|
103
|
+
console.log(` ✓ ${check.name}`);
|
|
104
|
+
} else {
|
|
105
|
+
console.log(` ✗ Missing: ${check.name}`);
|
|
106
|
+
allChecksPass = false;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if(allChecksPass) {
|
|
111
|
+
passed++;
|
|
112
|
+
} else {
|
|
113
|
+
failed++;
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
console.log(" ✗ Could not extract new() method code");
|
|
117
|
+
failed++;
|
|
118
|
+
}
|
|
119
|
+
} catch(err) {
|
|
120
|
+
console.log(` ✗ Error: ${err.message}`);
|
|
121
|
+
failed++;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Test 4: Check method placement
|
|
125
|
+
console.log("\n📝 Test 4: Verify method placement in file");
|
|
126
|
+
console.log("──────────────────────────────────────────────────");
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
const content = fs.readFileSync(queryMethodsPath, 'utf8');
|
|
130
|
+
|
|
131
|
+
// Check that new() comes before add()
|
|
132
|
+
const newIndex = content.indexOf('new()');
|
|
133
|
+
const addIndex = content.indexOf('add(entityValue)');
|
|
134
|
+
|
|
135
|
+
if(newIndex > 0 && addIndex > 0 && newIndex < addIndex) {
|
|
136
|
+
console.log(" ✓ new() method placed before add()");
|
|
137
|
+
console.log(" ✓ Correct location in class structure");
|
|
138
|
+
passed++;
|
|
139
|
+
} else if(newIndex > 0 && addIndex > 0) {
|
|
140
|
+
console.log(" ⚠ new() method exists but not in expected location");
|
|
141
|
+
console.log(` ℹ new() at position ${newIndex}, add() at ${addIndex}`);
|
|
142
|
+
passed++;
|
|
143
|
+
} else {
|
|
144
|
+
console.log(" ✗ Could not verify method placement");
|
|
145
|
+
failed++;
|
|
146
|
+
}
|
|
147
|
+
} catch(err) {
|
|
148
|
+
console.log(` ✗ Error: ${err.message}`);
|
|
149
|
+
failed++;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Summary
|
|
153
|
+
console.log("\n\n╔════════════════════════════════════════════════════════════════╗");
|
|
154
|
+
console.log("║ Verification Summary ║");
|
|
155
|
+
console.log("╚════════════════════════════════════════════════════════════════╝");
|
|
156
|
+
|
|
157
|
+
const total = passed + failed;
|
|
158
|
+
const successRate = total > 0 ? Math.round((passed/total)*100) : 0;
|
|
159
|
+
|
|
160
|
+
console.log(`\n Total Checks: ${total}`);
|
|
161
|
+
console.log(` ✅ Passed: ${passed}`);
|
|
162
|
+
console.log(` ❌ Failed: ${failed}`);
|
|
163
|
+
console.log(` Success Rate: ${successRate}%\n`);
|
|
164
|
+
|
|
165
|
+
if(failed === 0){
|
|
166
|
+
console.log("🎉 All verification checks passed!");
|
|
167
|
+
console.log("\n✨ .new() Method Successfully Implemented!");
|
|
168
|
+
console.log("\n📖 Implementation Details:");
|
|
169
|
+
console.log(" File: QueryLanguage/queryMethods.js");
|
|
170
|
+
console.log(" Method: new()");
|
|
171
|
+
console.log(" Purpose: Create empty entity instances for INSERT operations");
|
|
172
|
+
console.log("\n📖 Features:");
|
|
173
|
+
console.log(" ✓ Creates entity with __state = 'insert'");
|
|
174
|
+
console.log(" ✓ Sets up property getters/setters for all fields");
|
|
175
|
+
console.log(" ✓ Tracks dirty fields automatically");
|
|
176
|
+
console.log(" ✓ Skips navigational properties (relationships)");
|
|
177
|
+
console.log(" ✓ Automatically tracks entity in context");
|
|
178
|
+
console.log("\n📖 Usage Example:");
|
|
179
|
+
console.log(" const job = context.QaIntelligenceJob.new();");
|
|
180
|
+
console.log(" job.annotation_id = 123;");
|
|
181
|
+
console.log(" job.job_type = 'auto_rewrite';");
|
|
182
|
+
console.log(" job.status = 'queued';");
|
|
183
|
+
console.log(" job.created_at = Date.now().toString();");
|
|
184
|
+
console.log(" context.saveChanges(); // INSERT INTO QaIntelligenceJob...");
|
|
185
|
+
console.log("\n✅ Bug Fixed: context.QaIntelligenceJob.new() now works!\n");
|
|
186
|
+
process.exit(0);
|
|
187
|
+
} else {
|
|
188
|
+
console.log("⚠️ Some verification checks failed.");
|
|
189
|
+
console.log(" Review the implementation in queryMethods.js");
|
|
190
|
+
process.exit(1);
|
|
191
|
+
}
|