@izara_project/izara-core-generate-service-code 1.0.97 → 1.0.98

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.
Files changed (37) hide show
  1. package/package.json +1 -1
  2. package/src/compile/loadSchemas.js +29 -6
  3. package/src/emit/application/crud/templates/FlowEndpoint_HdrWbs.ejs +2 -2
  4. package/src/emit/application/crud/templates/FlowMain_Wbs.ejs +2 -2
  5. package/src/emit/application/custom/templates/s3/CreateObject_Main.ejs +5 -2
  6. package/src/emit/application/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +2 -2
  7. package/src/emit/application/relationship/templates/ChangeRelationship_Main.ejs +3 -2
  8. package/src/emit/application/relationship/templates/CreateRelationship_Main.ejs +3 -2
  9. package/src/emit/application/relationship/templates/DeleteRelationship_Main.ejs +3 -2
  10. package/src/emit/application/relationship/templates/GetRelationship_Main.ejs +3 -2
  11. package/src/emit/application/relationship/templates/MoveRelationship_Main.ejs +3 -2
  12. package/src/emit/application/relationship/templates/UpdateRelationship_Main.ejs +3 -2
  13. package/src/emit/application/system/templates/RegisterComplete_Main.ejs +6 -2
  14. package/src/emit/application/system/templates/Register_Main.ejs +6 -2
  15. package/src/emit/application/system/templates/WebSocketComplete_Main.ejs +3 -3
  16. package/src/emit/infrastructure/resources/iamResourceArtifacts.js +1 -1
  17. package/src/emit/schemas/attributeTree/emitAttributeTreeSchemas.js +14 -22
  18. package/src/emit/schemas/attributeTree/emitAttributeTreeTargetValueStandard.js +132 -0
  19. package/src/emit/schemas/ledger/emitLedgerSchemas.js +33 -11
  20. package/src/emit/schemas/ledger/templates/LedgerObjectSchema.ejs +3 -0
  21. package/src/emit/schemas/ledger/templates/LedgerRelationshipSchema.ejs +1 -0
  22. package/src/emit/schemas/propertyValue/emitPropertyValueSchemas.js +329 -0
  23. package/src/generate.js +16 -75
  24. package/src/output/mergeHooks.js +69 -15
  25. package/src/plan/domainRegistry.js +41 -5
  26. package/task.md +132 -0
  27. package/test/integration/publicApi.test.js +54 -1
  28. package/test/unit/application/customFlowApplicationArtifacts.test.js +9 -0
  29. package/test/unit/application/relationshipApplicationArtifacts.test.js +30 -0
  30. package/test/unit/infrastructure/resourceArtifacts.test.js +1 -0
  31. package/test/unit/output/mergeHooks.test.js +268 -0
  32. package/test/unit/schemas/attributeTreeDirectives.test.js +177 -0
  33. package/test/unit/schemas/attributeTreeSchemas.test.js +10 -61
  34. package/test/unit/schemas/ledgerSchemas.test.js +33 -7
  35. package/test/unit/schemas/propertyValueSchemas.test.js +265 -0
  36. package/src/emit/schemas/attributeTree/emitAttributeTreeTargetSchemas.js +0 -153
  37. package/src/emit/schemas/attributeTree/resolveTargetServicePath.js +0 -111
@@ -1,153 +0,0 @@
1
- import path from 'node:path';
2
-
3
- function _renderObjectSchema(schema) {
4
- return `export default [\n ${JSON.stringify(schema, null, 2).replace(/\n/g, '\n ')}\n];\n`;
5
- }
6
-
7
- /**
8
- * Emits standard schemas into target service folder for attributeTree.
9
- *
10
- * @param {Object} params
11
- * @param {string} params.attributeTag - e.g. 'sellOfferTerm'
12
- * @param {string} params.targetServiceRoot - Target service root directory
13
- * @param {Object} [params.graphStorageResources] - Graph storage resources
14
- * @returns {Array<{ path: string, content: string }>} Emitted target artifacts
15
- */
16
- export function emitAttributeTreeTargetSchemas({
17
- attributeTag,
18
- targetServiceRoot,
19
- graphStorageResources = {
20
- myGraph: {
21
- storageType: 'graph',
22
- graphServerTag: 'GraphHandler'
23
- }
24
- }
25
- } = {}) {
26
- if (!attributeTag || !targetServiceRoot) {
27
- return [];
28
- }
29
-
30
- const tag = attributeTag;
31
- const storageResourceTags = Object.keys(graphStorageResources);
32
-
33
- // 1. {tag}ValueStandardPropertyLabel.js
34
- const labelSchema = {
35
- objectType: `${tag}ValueStandardPropertyLabel`,
36
- canDelete: true,
37
- generatedBy: 'user',
38
- storageResources: graphStorageResources,
39
- fieldNames: {
40
- [`${tag}ValueStandardPropertyLabelId`]: {
41
- type: 'string',
42
- randomOnCreate: true,
43
- canUpdate: false,
44
- storageResourceTags
45
- },
46
- label: {
47
- type: 'string',
48
- requiredOnCreate: true,
49
- canUpdate: true,
50
- storageResourceTags
51
- }
52
- },
53
- identifiers: [
54
- {
55
- type: 'identifier',
56
- fieldName: `${tag}ValueStandardPropertyLabelId`
57
- }
58
- ]
59
- };
60
-
61
- // 2. {tag}ValueStandardPropertyValue.js
62
- const valueSchema = {
63
- objectType: `${tag}ValueStandardPropertyValue`,
64
- canDelete: true,
65
- generatedBy: 'user',
66
- storageResources: graphStorageResources,
67
- fieldNames: {
68
- [`${tag}ValueStandardPropertyValueId`]: {
69
- type: 'string',
70
- randomOnCreate: true,
71
- canUpdate: false,
72
- storageResourceTags
73
- },
74
- value: {
75
- type: 'string',
76
- requiredOnCreate: true,
77
- canUpdate: true,
78
- storageResourceTags
79
- }
80
- },
81
- identifiers: [
82
- {
83
- type: 'identifier',
84
- fieldName: `${tag}ValueStandardPropertyValueId`
85
- }
86
- ]
87
- };
88
-
89
- // 3. {tag}ValueStandard.js
90
- const standardValueSchema = {
91
- objectType: `${tag}ValueStandard`,
92
- canDelete: true,
93
- generatedBy: 'user',
94
- storageResources: graphStorageResources,
95
- fieldNames: {
96
- [`${tag}ValueStandardId`]: {
97
- type: 'string',
98
- randomOnCreate: true,
99
- canUpdate: false,
100
- storageResourceTags
101
- },
102
- value: {
103
- type: 'string',
104
- requiredOnCreate: true,
105
- canUpdate: true,
106
- storageResourceTags
107
- }
108
- },
109
- identifiers: [
110
- {
111
- type: 'identifier',
112
- fieldName: `${tag}ValueStandardId`
113
- }
114
- ]
115
- };
116
-
117
- const relDir = path.join(
118
- 'app',
119
- 'src',
120
- 'schemas',
121
- 'ObjectSchemas',
122
- 'generatedCode',
123
- 'attributeTree',
124
- 'propertyValue'
125
- );
126
-
127
- return [
128
- {
129
- path: path.join(
130
- targetServiceRoot,
131
- relDir,
132
- `${tag}ValueStandardPropertyLabel.js`
133
- ),
134
- content: _renderObjectSchema(labelSchema)
135
- },
136
- {
137
- path: path.join(
138
- targetServiceRoot,
139
- relDir,
140
- `${tag}ValueStandardPropertyValue.js`
141
- ),
142
- content: _renderObjectSchema(valueSchema)
143
- },
144
- {
145
- path: path.join(
146
- targetServiceRoot,
147
- relDir,
148
- `${tag}ValueStandard.js`
149
- ),
150
- content: _renderObjectSchema(standardValueSchema)
151
- }
152
- ];
153
- }
@@ -1,111 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
-
4
- /**
5
- * Resolves target service root path based on attributeTag and developer suffix.
6
- *
7
- * @param {Object} params
8
- * @param {string} params.currentServiceRoot - Root path of the current service
9
- * @param {string} params.attributeTag - The attribute tag, e.g. 'sellOfferTerm'
10
- * @param {string} [params.customOverridePath] - Optional custom path override
11
- * @returns {string|null} Resolved absolute path or null if not found
12
- */
13
- export function resolveTargetServicePath({
14
- currentServiceRoot,
15
- attributeTag,
16
- customOverridePath
17
- } = {}) {
18
- if (!currentServiceRoot || !attributeTag) {
19
- return null;
20
- }
21
-
22
- if (customOverridePath) {
23
- const resolvedCustom = path.resolve(
24
- currentServiceRoot,
25
- customOverridePath
26
- );
27
- if (fs.existsSync(resolvedCustom)) {
28
- return resolvedCustom;
29
- }
30
- }
31
-
32
- const currentFolderName = path.basename(currentServiceRoot);
33
- const parentDir = path.resolve(currentServiceRoot, '..');
34
-
35
- if (!fs.existsSync(parentDir)) {
36
- return null;
37
- }
38
-
39
- let entries = [];
40
- try {
41
- entries = fs.readdirSync(parentDir, { withFileTypes: true });
42
- } catch (err) {
43
- return null;
44
- }
45
-
46
- const suffixMatch = currentFolderName.match(/-([a-zA-Z0-9]+)$/);
47
- let devSuffix = '';
48
- if (suffixMatch && suffixMatch[1]) {
49
- devSuffix = suffixMatch[1].toLowerCase();
50
- }
51
-
52
- const normalizedTag = attributeTag.toLowerCase();
53
- const kebabTag = attributeTag
54
- .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
55
- .toLowerCase();
56
-
57
- const priority1Matches = [];
58
- const priority2Matches = [];
59
- const priority3Matches = [];
60
-
61
- for (const entry of entries) {
62
- if (!entry.isDirectory()) {
63
- continue;
64
- }
65
-
66
- if (entry.name === currentFolderName) {
67
- continue;
68
- }
69
-
70
- const folderNameLower = entry.name.toLowerCase();
71
- const hasTagMatch =
72
- folderNameLower.includes(normalizedTag) ||
73
- folderNameLower.includes(kebabTag);
74
-
75
- if (!hasTagMatch) {
76
- continue;
77
- }
78
-
79
- const fullPath = path.join(parentDir, entry.name);
80
- const hasStructure =
81
- fs.existsSync(path.join(fullPath, 'app', 'src')) ||
82
- fs.existsSync(path.join(fullPath, 'package.json'));
83
-
84
- if (!hasStructure) {
85
- continue;
86
- }
87
-
88
- if (devSuffix !== '' && folderNameLower.endsWith('-' + devSuffix)) {
89
- priority1Matches.push(fullPath);
90
- } else if (
91
- folderNameLower.endsWith(normalizedTag) ||
92
- folderNameLower.endsWith(kebabTag)
93
- ) {
94
- priority2Matches.push(fullPath);
95
- } else {
96
- priority3Matches.push(fullPath);
97
- }
98
- }
99
-
100
- if (priority1Matches.length > 0) {
101
- return priority1Matches[0];
102
- }
103
- if (priority2Matches.length > 0) {
104
- return priority2Matches[0];
105
- }
106
- if (priority3Matches.length > 0) {
107
- return priority3Matches[0];
108
- }
109
-
110
- return null;
111
- }