cap-mock-generator 1.0.7 → 1.0.8
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.
|
@@ -57,14 +57,21 @@ class CdsParserService {
|
|
|
57
57
|
const property = propDef;
|
|
58
58
|
const isAssoc = property.type === 'cds.Association' ||
|
|
59
59
|
property.type === 'cds.Composition' ||
|
|
60
|
-
property.type === undefined
|
|
61
|
-
propName.startsWith('to');
|
|
60
|
+
(property.type === undefined && propName.startsWith('to'));
|
|
62
61
|
let finalType = property.type || 'Association';
|
|
62
|
+
let finalPropName = propName;
|
|
63
|
+
if (property.target === 'sap.common.Countries' || property.target === 'sap.common.Currencies') {
|
|
64
|
+
finalPropName = `${propName}_code`;
|
|
65
|
+
finalType = 'cds.String';
|
|
66
|
+
}
|
|
67
|
+
else if (property.type === 'cds.Association' && !isAssoc) {
|
|
68
|
+
finalPropName = `${propName}_ID`;
|
|
69
|
+
}
|
|
63
70
|
if (typeof property.target === 'string') {
|
|
64
71
|
finalType = `Association.${property.target}`;
|
|
65
72
|
}
|
|
66
73
|
properties.push({
|
|
67
|
-
name:
|
|
74
|
+
name: finalPropName,
|
|
68
75
|
type: finalType,
|
|
69
76
|
isAssociation: isAssoc
|
|
70
77
|
});
|
|
@@ -21,10 +21,16 @@ class FakerService {
|
|
|
21
21
|
if (lowerPropName.includes('receiver')) {
|
|
22
22
|
return faker_1.faker.internet.username();
|
|
23
23
|
}
|
|
24
|
-
if (lowerPropName.includes('createdby')) {
|
|
24
|
+
if (lowerPropName.includes('createdby') || lowerPropName.includes('modifiedby')) {
|
|
25
25
|
return faker_1.faker.internet.username();
|
|
26
26
|
}
|
|
27
|
+
if (lowerPropName.endsWith('currency') || lowerPropName.endsWith('code')) {
|
|
28
|
+
return faker_1.faker.string.alpha({ length: 3, casing: 'upper' });
|
|
29
|
+
}
|
|
27
30
|
switch (propType) {
|
|
31
|
+
case 'cds.Date': {
|
|
32
|
+
return faker_1.faker.date.anytime().toISOString().split('T')[0];
|
|
33
|
+
}
|
|
28
34
|
case 'cds.UUID': {
|
|
29
35
|
return faker_1.faker.string.uuid();
|
|
30
36
|
}
|
|
@@ -51,7 +57,8 @@ class FakerService {
|
|
|
51
57
|
for (let i = 0; i < count; i++) {
|
|
52
58
|
const row = {};
|
|
53
59
|
for (const prop of entity.properties) {
|
|
54
|
-
|
|
60
|
+
// to ile başlayan sanal ilişkiler veya many-to-many bağları temizce atlansın
|
|
61
|
+
if (prop.isAssociation)
|
|
55
62
|
continue;
|
|
56
63
|
row[prop.name] = this.generateValue(prop.name, prop.type, parentIds);
|
|
57
64
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cap-mock-generator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "An interactive mock data generation engine for SAP CAP applications, leveraging the official @sap/cds-compiler by SAP for schema parsing.",
|
|
5
5
|
"main": "dist/cli.js",
|
|
6
6
|
"bin": {
|