@izara_project/izara-core-generate-service-code 1.0.97 → 1.0.99
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/package.json +1 -1
- package/src/compile/flowValidator.js +45 -8
- package/src/compile/loadSchemas.js +26 -6
- package/src/emit/application/coreFunction/emitCoreFunctionArtifacts.js +15 -1
- package/src/emit/application/coreFunction/templates/InitialSetupConfig.ejs +8 -4
- package/src/emit/application/crud/templates/CreateEndpoint_Main.ejs +4 -4
- package/src/emit/application/crud/templates/CreateLogicalLib.ejs +60 -8
- package/src/emit/application/crud/templates/DeleteEndpoint_Main.ejs +4 -4
- package/src/emit/application/crud/templates/FlowEndpoint_HdrWbs.ejs +2 -2
- package/src/emit/application/crud/templates/FlowMain_Wbs.ejs +2 -2
- package/src/emit/application/crud/templates/UpdateEndpoint_Main.ejs +4 -4
- package/src/emit/application/custom/customFlowS3.js +4 -4
- package/src/emit/application/custom/templates/FlowEndpoint_Main.ejs +2 -2
- package/src/emit/application/custom/templates/s3/CreateObject_Main.ejs +5 -2
- package/src/emit/application/custom/templates/triggerCache/CheckTriggerCache_Main.ejs +2 -2
- package/src/emit/application/rbac/emitDynamicRbacFlowSchemas.js +4 -1
- package/src/emit/application/rbac/emitRbacApplicationArtifacts.js +76 -1
- package/src/emit/application/rbac/templates/ReservedDynamicUsage_Main.ejs +2 -0
- package/src/emit/application/rbac/templates/ReservedUsageTtlExpired_HdrDss.ejs +176 -0
- package/src/emit/application/relationship/templates/ChangeRelationship_Main.ejs +3 -2
- package/src/emit/application/relationship/templates/CreateRelationship_Main.ejs +3 -2
- package/src/emit/application/relationship/templates/DeleteRelationship_Main.ejs +3 -2
- package/src/emit/application/relationship/templates/GetRelationship_Main.ejs +3 -2
- package/src/emit/application/relationship/templates/MoveRelationship_Main.ejs +3 -2
- package/src/emit/application/relationship/templates/UpdateRelationship_Main.ejs +3 -2
- package/src/emit/application/system/templates/RegisterComplete_Main.ejs +6 -2
- package/src/emit/application/system/templates/Register_Main.ejs +6 -2
- package/src/emit/application/system/templates/WebSocketComplete_Main.ejs +3 -3
- package/src/emit/infrastructure/functions/functionYamlArtifact.js +28 -0
- package/src/emit/infrastructure/functions/templates/DssFunction_Yaml.ejs +21 -0
- package/src/emit/infrastructure/resources/iamResourceArtifacts.js +46 -6
- package/src/emit/infrastructure/resources/templates/GeneratedLambdaRoleServiceConfig.ejs +5 -3
- package/src/emit/schemas/attributeTree/emitAttributeTreeSchemas.js +75 -22
- package/src/emit/schemas/ledger/emitLedgerSchemas.js +33 -11
- package/src/emit/schemas/ledger/templates/LedgerObjectSchema.ejs +3 -0
- package/src/emit/schemas/ledger/templates/LedgerRelationshipSchema.ejs +1 -0
- package/src/emit/schemas/propertyValue/emitPropertyValueSchemas.js +329 -0
- package/src/generate.js +10 -73
- package/src/output/mergeHooks.js +169 -15
- package/src/plan/domainRegistry.js +31 -5
- package/task.md +76 -0
- package/test/integration/graphDrivenFlowSchema.test.js +58 -0
- package/test/integration/publicApi.test.js +54 -1
- package/test/unit/application/createTargetRoleHandler.test.js +70 -1
- package/test/unit/application/crudApplicationArtifacts.test.js +4 -0
- package/test/unit/application/customFlowApplicationArtifacts.test.js +9 -0
- package/test/unit/application/relationshipApplicationArtifacts.test.js +30 -0
- package/test/unit/infrastructure/resourceArtifacts.test.js +53 -0
- package/test/unit/output/mergeHooks.test.js +405 -0
- package/test/unit/schemas/attributeTreeSchemas.test.js +41 -63
- package/test/unit/schemas/attributeTreeSingleService.test.js +175 -0
- package/test/unit/schemas/ledgerSchemas.test.js +33 -7
- package/test/unit/schemas/propertyValueSchemas.test.js +265 -0
- package/test/unit/templates/hookTagsValidation.test.js +83 -0
- package/src/emit/schemas/attributeTree/emitAttributeTreeTargetSchemas.js +0 -153
- package/src/emit/schemas/attributeTree/resolveTargetServicePath.js +0 -111
|
@@ -60,7 +60,9 @@ export function generatedLambdaRole() {
|
|
|
60
60
|
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ConfirmUsage_In', 'Rbac')}`,
|
|
61
61
|
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'CancelUsage_In', 'Rbac')}`<% if (rbac) { %>,
|
|
62
62
|
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ValidatorRbac_In')}`<% } %><% (rbacValidatorServiceTags || []).forEach(function(tag) { %>,
|
|
63
|
-
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ValidatorRbac_In', '<%= tag %>')}
|
|
63
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ValidatorRbac_In', '<%= tag %>')}`,
|
|
64
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ConfirmUsage_In', '<%= tag %>')}`,
|
|
65
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'CancelUsage_In', '<%= tag %>')}`<% }); %>
|
|
64
66
|
]
|
|
65
67
|
}<% } %>
|
|
66
68
|
//(<createFlowObjectsRole>)
|
|
@@ -144,7 +146,7 @@ export function generatedLambdaRole() {
|
|
|
144
146
|
Effect: 'Allow',
|
|
145
147
|
Action: ['sns:Publish'],
|
|
146
148
|
Resource: [
|
|
147
|
-
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ReservedDynamicUsage_In', '
|
|
149
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ReservedDynamicUsage_In', '<%= flow.quotaServiceTag || 'Rbac' %>')}`
|
|
148
150
|
]
|
|
149
151
|
},
|
|
150
152
|
|
|
@@ -153,7 +155,7 @@ export function generatedLambdaRole() {
|
|
|
153
155
|
Effect: 'Allow',
|
|
154
156
|
Action: ['sns:Publish'],
|
|
155
157
|
Resource: [
|
|
156
|
-
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ConfirmDynamicAfterUpload_In', '
|
|
158
|
+
`arn:aws:sns:${process.env.iz_region}:${process.env.iz_accountId}:${snsSharedLib.snsTopicNameByFlowSchema(_izContext, 'ConfirmDynamicAfterUpload_In', '<%= flow.quotaServiceTag || 'Rbac' %>')}`
|
|
157
159
|
]
|
|
158
160
|
}
|
|
159
161
|
//(<create<%= flow.roleName %>Role>)
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { resolveTargetServicePath } from './resolveTargetServicePath.js';
|
|
2
|
-
import { emitAttributeTreeTargetSchemas } from './emitAttributeTreeTargetSchemas.js';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Emits dynamic ObjectSchemas and RelationshipSchemas for attributeTree add-ons
|
|
6
3
|
*/
|
|
@@ -65,6 +62,60 @@ function _renderRelationshipSchema(relationshipTag, content) {
|
|
|
65
62
|
return `export default ${JSON.stringify(wrapper, null, 2)};\n`;
|
|
66
63
|
}
|
|
67
64
|
|
|
65
|
+
function _renderValueStandardSchema(tag, storageResources) {
|
|
66
|
+
const storageResourceTags = Object.keys(storageResources);
|
|
67
|
+
if (storageResourceTags.length === 0) {
|
|
68
|
+
storageResourceTags.push('myGraph');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const storageJson = JSON.stringify(storageResources, null, 2)
|
|
72
|
+
.replace(/\n/g, '\n ');
|
|
73
|
+
const tagsJson = JSON.stringify(storageResourceTags);
|
|
74
|
+
|
|
75
|
+
return `export default [
|
|
76
|
+
{
|
|
77
|
+
objectType: '${tag}ValueStandard',
|
|
78
|
+
canDelete: true,
|
|
79
|
+
generatedBy: 'user',
|
|
80
|
+
storageResources: ${storageJson},
|
|
81
|
+
addOnDataStructure: [
|
|
82
|
+
//(<addOnDataStructure${tag}ValueStandard>)
|
|
83
|
+
// {
|
|
84
|
+
// type: 'propertyValue',
|
|
85
|
+
// propertyValuePrefix: '${tag}ValueStandard'
|
|
86
|
+
// }
|
|
87
|
+
//(</addOnDataStructure${tag}ValueStandard>)
|
|
88
|
+
],
|
|
89
|
+
fieldNames: {
|
|
90
|
+
${tag}ValueStandardId: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
randomOnCreate: true,
|
|
93
|
+
canUpdate: false,
|
|
94
|
+
storageResourceTags: ${tagsJson}
|
|
95
|
+
},
|
|
96
|
+
label: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
canUpdate: true,
|
|
99
|
+
storageResourceTags: ${tagsJson}
|
|
100
|
+
},
|
|
101
|
+
value: {
|
|
102
|
+
type: 'string',
|
|
103
|
+
requiredOnCreate: true,
|
|
104
|
+
canUpdate: true,
|
|
105
|
+
storageResourceTags: ${tagsJson}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
identifiers: [
|
|
109
|
+
{
|
|
110
|
+
type: 'identifier',
|
|
111
|
+
fieldName: '${tag}ValueStandardId'
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
|
|
68
119
|
export function attributeTreeObjectSchemaManagedPaths(objects = []) {
|
|
69
120
|
const trees = _extractAttributeTrees(objects);
|
|
70
121
|
const paths = [];
|
|
@@ -72,9 +123,10 @@ export function attributeTreeObjectSchemaManagedPaths(objects = []) {
|
|
|
72
123
|
for (const { attributeTreeTag } of trees) {
|
|
73
124
|
const tag = attributeTreeTag;
|
|
74
125
|
paths.push(
|
|
75
|
-
`app/src/schemas/ObjectSchemas/
|
|
76
|
-
`app/src/schemas/ObjectSchemas/
|
|
77
|
-
`app/src/schemas/ObjectSchemas/
|
|
126
|
+
`app/src/schemas/ObjectSchemas/generatedCode/attributeTree/${tag}Link.js`,
|
|
127
|
+
`app/src/schemas/ObjectSchemas/generatedCode/attributeTree/${tag}Value.js`,
|
|
128
|
+
`app/src/schemas/ObjectSchemas/generatedCode/attributeTree/${tag}Label.js`,
|
|
129
|
+
`app/src/schemas/ObjectSchemas/generatedCode/attributeTree/${tag}ValueStandard.js`
|
|
78
130
|
);
|
|
79
131
|
}
|
|
80
132
|
|
|
@@ -89,10 +141,10 @@ export function attributeTreeRelationshipSchemaManagedPaths(objects = []) {
|
|
|
89
141
|
const tag = attributeTreeTag;
|
|
90
142
|
const tagCap = _capitalize(tag);
|
|
91
143
|
paths.push(
|
|
92
|
-
`app/src/schemas/RelationshipSchemas/
|
|
93
|
-
`app/src/schemas/RelationshipSchemas/
|
|
94
|
-
`app/src/schemas/RelationshipSchemas/
|
|
95
|
-
`app/src/schemas/RelationshipSchemas/
|
|
144
|
+
`app/src/schemas/RelationshipSchemas/generatedCode/attributeTree/has${tagCap}Link.js`,
|
|
145
|
+
`app/src/schemas/RelationshipSchemas/generatedCode/attributeTree/disabled${tagCap}Link.js`,
|
|
146
|
+
`app/src/schemas/RelationshipSchemas/generatedCode/attributeTree/is${tagCap}.js`,
|
|
147
|
+
`app/src/schemas/RelationshipSchemas/generatedCode/attributeTree/is${tagCap}Label.js`
|
|
96
148
|
);
|
|
97
149
|
}
|
|
98
150
|
|
|
@@ -141,7 +193,7 @@ export function emitAttributeTreeObjectSchemas({ objects = [] } = {}) {
|
|
|
141
193
|
]
|
|
142
194
|
};
|
|
143
195
|
artifacts.push({
|
|
144
|
-
path: `app/src/schemas/ObjectSchemas/
|
|
196
|
+
path: `app/src/schemas/ObjectSchemas/generatedCode/attributeTree/${tag}Link.js`,
|
|
145
197
|
content: _renderObjectSchema(linkSchema)
|
|
146
198
|
});
|
|
147
199
|
|
|
@@ -173,7 +225,7 @@ export function emitAttributeTreeObjectSchemas({ objects = [] } = {}) {
|
|
|
173
225
|
]
|
|
174
226
|
};
|
|
175
227
|
artifacts.push({
|
|
176
|
-
path: `app/src/schemas/ObjectSchemas/
|
|
228
|
+
path: `app/src/schemas/ObjectSchemas/generatedCode/attributeTree/${tag}Value.js`,
|
|
177
229
|
content: _renderObjectSchema(valueSchema)
|
|
178
230
|
});
|
|
179
231
|
|
|
@@ -205,9 +257,15 @@ export function emitAttributeTreeObjectSchemas({ objects = [] } = {}) {
|
|
|
205
257
|
]
|
|
206
258
|
};
|
|
207
259
|
artifacts.push({
|
|
208
|
-
path: `app/src/schemas/ObjectSchemas/
|
|
260
|
+
path: `app/src/schemas/ObjectSchemas/generatedCode/attributeTree/${tag}Label.js`,
|
|
209
261
|
content: _renderObjectSchema(labelSchema)
|
|
210
262
|
});
|
|
263
|
+
|
|
264
|
+
// 4. {tag}ValueStandard.js
|
|
265
|
+
artifacts.push({
|
|
266
|
+
path: `app/src/schemas/ObjectSchemas/generatedCode/attributeTree/${tag}ValueStandard.js`,
|
|
267
|
+
content: _renderValueStandardSchema(tag, graphStorageResources)
|
|
268
|
+
});
|
|
211
269
|
}
|
|
212
270
|
|
|
213
271
|
return artifacts;
|
|
@@ -260,7 +318,7 @@ export function emitAttributeTreeRelationshipSchemas({
|
|
|
260
318
|
]
|
|
261
319
|
};
|
|
262
320
|
artifacts.push({
|
|
263
|
-
path: `app/src/schemas/RelationshipSchemas/
|
|
321
|
+
path: `app/src/schemas/RelationshipSchemas/generatedCode/attributeTree/has${tagCap}Link.js`,
|
|
264
322
|
content: _renderRelationshipSchema(`has${tagCap}Link`, hasLinkRel)
|
|
265
323
|
});
|
|
266
324
|
|
|
@@ -290,7 +348,7 @@ export function emitAttributeTreeRelationshipSchemas({
|
|
|
290
348
|
]
|
|
291
349
|
};
|
|
292
350
|
artifacts.push({
|
|
293
|
-
path: `app/src/schemas/RelationshipSchemas/
|
|
351
|
+
path: `app/src/schemas/RelationshipSchemas/generatedCode/attributeTree/disabled${tagCap}Link.js`,
|
|
294
352
|
content: _renderRelationshipSchema(
|
|
295
353
|
`disabled${tagCap}Link`,
|
|
296
354
|
disabledLinkRel
|
|
@@ -324,7 +382,7 @@ export function emitAttributeTreeRelationshipSchemas({
|
|
|
324
382
|
]
|
|
325
383
|
};
|
|
326
384
|
artifacts.push({
|
|
327
|
-
path: `app/src/schemas/RelationshipSchemas/
|
|
385
|
+
path: `app/src/schemas/RelationshipSchemas/generatedCode/attributeTree/is${tagCap}.js`,
|
|
328
386
|
content: _renderRelationshipSchema(`is${tagCap}`, isRel)
|
|
329
387
|
});
|
|
330
388
|
|
|
@@ -355,15 +413,10 @@ export function emitAttributeTreeRelationshipSchemas({
|
|
|
355
413
|
]
|
|
356
414
|
};
|
|
357
415
|
artifacts.push({
|
|
358
|
-
path: `app/src/schemas/RelationshipSchemas/
|
|
416
|
+
path: `app/src/schemas/RelationshipSchemas/generatedCode/attributeTree/is${tagCap}Label.js`,
|
|
359
417
|
content: _renderRelationshipSchema(`is${tagCap}Label`, isLabelRel)
|
|
360
418
|
});
|
|
361
419
|
}
|
|
362
420
|
|
|
363
421
|
return artifacts;
|
|
364
422
|
}
|
|
365
|
-
|
|
366
|
-
export {
|
|
367
|
-
resolveTargetServicePath,
|
|
368
|
-
emitAttributeTreeTargetSchemas
|
|
369
|
-
};
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import ejsLib from 'ejs';
|
|
3
|
+
|
|
4
|
+
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Emits dynamic ObjectSchemas and RelationshipSchemas for ledger add-ons
|
|
3
8
|
*/
|
|
@@ -92,13 +97,17 @@ function _extractGraphStorageResources(object, storageResourceTag) {
|
|
|
92
97
|
return result;
|
|
93
98
|
}
|
|
94
99
|
|
|
95
|
-
function _renderObjectSchema(schema) {
|
|
96
|
-
return
|
|
100
|
+
function _renderObjectSchema(template, schema) {
|
|
101
|
+
return ejsLib.render(template, { schema });
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
function _renderRelationshipSchema(relationshipTag, content) {
|
|
104
|
+
function _renderRelationshipSchema(template, relationshipTag, content) {
|
|
100
105
|
const wrapper = [{ [relationshipTag]: content }];
|
|
101
|
-
return
|
|
106
|
+
return ejsLib.render(template, {
|
|
107
|
+
relationshipTag,
|
|
108
|
+
content,
|
|
109
|
+
wrapper
|
|
110
|
+
});
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
function _buildParentToEntryLinks({
|
|
@@ -117,7 +126,7 @@ function _buildParentToEntryLinks({
|
|
|
117
126
|
objectType: parentObjectType
|
|
118
127
|
},
|
|
119
128
|
linkType: 'many',
|
|
120
|
-
requiredOnCreate:
|
|
129
|
+
requiredOnCreate: false,
|
|
121
130
|
belongTo: true
|
|
122
131
|
},
|
|
123
132
|
to: {
|
|
@@ -176,12 +185,16 @@ export function ledgerRelationshipSchemaManagedPaths(objects = []) {
|
|
|
176
185
|
return paths;
|
|
177
186
|
}
|
|
178
187
|
|
|
179
|
-
export function emitLedgerObjectSchemas({ objects = [] } = {}) {
|
|
188
|
+
export async function emitLedgerObjectSchemas({ objects = [] } = {}) {
|
|
180
189
|
const ledgers = _extractLedgers(objects);
|
|
181
190
|
if (ledgers.length === 0) {
|
|
182
191
|
return [];
|
|
183
192
|
}
|
|
184
193
|
|
|
194
|
+
const template = await readFile(
|
|
195
|
+
new URL('LedgerObjectSchema.ejs', TEMPLATE_URL),
|
|
196
|
+
'utf8'
|
|
197
|
+
);
|
|
185
198
|
const artifacts = [];
|
|
186
199
|
|
|
187
200
|
for (const { parentObject, addOn, component } of ledgers) {
|
|
@@ -217,14 +230,14 @@ export function emitLedgerObjectSchemas({ objects = [] } = {}) {
|
|
|
217
230
|
|
|
218
231
|
artifacts.push({
|
|
219
232
|
path: `app/src/schemas/ObjectSchemas/generatedLedger/${objectType}.js`,
|
|
220
|
-
content: _renderObjectSchema(schema)
|
|
233
|
+
content: _renderObjectSchema(template, schema)
|
|
221
234
|
});
|
|
222
235
|
}
|
|
223
236
|
|
|
224
237
|
return artifacts;
|
|
225
238
|
}
|
|
226
239
|
|
|
227
|
-
export function emitLedgerRelationshipSchemas({
|
|
240
|
+
export async function emitLedgerRelationshipSchemas({
|
|
228
241
|
objects = [],
|
|
229
242
|
serviceTag = ''
|
|
230
243
|
} = {}) {
|
|
@@ -233,6 +246,10 @@ export function emitLedgerRelationshipSchemas({
|
|
|
233
246
|
return [];
|
|
234
247
|
}
|
|
235
248
|
|
|
249
|
+
const template = await readFile(
|
|
250
|
+
new URL('LedgerRelationshipSchema.ejs', TEMPLATE_URL),
|
|
251
|
+
'utf8'
|
|
252
|
+
);
|
|
236
253
|
const artifacts = [];
|
|
237
254
|
|
|
238
255
|
for (const { parentObject, addOn, component } of ledgers) {
|
|
@@ -281,6 +298,7 @@ export function emitLedgerRelationshipSchemas({
|
|
|
281
298
|
artifacts.push({
|
|
282
299
|
path: `app/src/schemas/RelationshipSchemas/generatedLedger/${component.newRelationshipTag}.js`,
|
|
283
300
|
content: _renderRelationshipSchema(
|
|
301
|
+
template,
|
|
284
302
|
component.newRelationshipTag,
|
|
285
303
|
currentRel
|
|
286
304
|
)
|
|
@@ -306,7 +324,11 @@ export function emitLedgerRelationshipSchemas({
|
|
|
306
324
|
};
|
|
307
325
|
artifacts.push({
|
|
308
326
|
path: `app/src/schemas/RelationshipSchemas/generatedLedger/${component.oldRelationshipTag}.js`,
|
|
309
|
-
content: _renderRelationshipSchema(
|
|
327
|
+
content: _renderRelationshipSchema(
|
|
328
|
+
template,
|
|
329
|
+
component.oldRelationshipTag,
|
|
330
|
+
oldRel
|
|
331
|
+
)
|
|
310
332
|
});
|
|
311
333
|
|
|
312
334
|
// 3. is<Prefix>Entry.js (if targetObjType or moveToTargetObjTypes is present)
|
|
@@ -341,7 +363,7 @@ export function emitLedgerRelationshipSchemas({
|
|
|
341
363
|
objectType: component.objectType
|
|
342
364
|
},
|
|
343
365
|
linkType: 'many',
|
|
344
|
-
requiredOnCreate:
|
|
366
|
+
requiredOnCreate: false
|
|
345
367
|
},
|
|
346
368
|
to: {
|
|
347
369
|
objType: {
|
|
@@ -361,7 +383,7 @@ export function emitLedgerRelationshipSchemas({
|
|
|
361
383
|
};
|
|
362
384
|
artifacts.push({
|
|
363
385
|
path: `app/src/schemas/RelationshipSchemas/generatedLedger/${isRelTag}.js`,
|
|
364
|
-
content: _renderRelationshipSchema(isRelTag, isRel)
|
|
386
|
+
content: _renderRelationshipSchema(template, isRelTag, isRel)
|
|
365
387
|
});
|
|
366
388
|
}
|
|
367
389
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default <%- JSON.stringify(wrapper, null, 2) %>;
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import propertyNode from '@izara_project/izara-property-nodes';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Emits dynamic ObjectSchemas and RelationshipSchemas for propertyValue add-ons
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
function _capitalize(str) {
|
|
8
|
+
if (!str) {
|
|
9
|
+
return '';
|
|
10
|
+
}
|
|
11
|
+
if (typeof str !== 'string') {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function _extractPropertyValues(objects = []) {
|
|
18
|
+
if (!Array.isArray(objects)) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
const results = [];
|
|
22
|
+
const seenTags = new Set();
|
|
23
|
+
|
|
24
|
+
for (const object of objects) {
|
|
25
|
+
if (!Array.isArray(object?.addOnDataStructure)) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
for (const addOn of object.addOnDataStructure) {
|
|
29
|
+
if (addOn?.type === 'propertyValue') {
|
|
30
|
+
let tag = object.objectType;
|
|
31
|
+
if (addOn.propertyValuePrefix) {
|
|
32
|
+
tag = addOn.propertyValuePrefix;
|
|
33
|
+
}
|
|
34
|
+
if (!tag) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (seenTags.has(tag)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
seenTags.add(tag);
|
|
41
|
+
results.push({
|
|
42
|
+
parentObject: object,
|
|
43
|
+
addOn,
|
|
44
|
+
tag
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return results;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function _extractGraphStorageResources(object) {
|
|
54
|
+
const result = {};
|
|
55
|
+
if (object?.storageResources) {
|
|
56
|
+
for (const [tag, res] of Object.entries(object.storageResources)) {
|
|
57
|
+
if (res?.storageType === 'graph') {
|
|
58
|
+
let graphServerTag = 'GraphHandler';
|
|
59
|
+
if (res.graphServerTag) {
|
|
60
|
+
graphServerTag = res.graphServerTag;
|
|
61
|
+
}
|
|
62
|
+
result[tag] = {
|
|
63
|
+
storageType: 'graph',
|
|
64
|
+
graphServerTag
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (Object.keys(result).length === 0) {
|
|
70
|
+
result.myGraph = {
|
|
71
|
+
storageType: 'graph',
|
|
72
|
+
graphServerTag: 'GraphHandler'
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function _renderObjectSchema(schema) {
|
|
79
|
+
const json = JSON.stringify(schema, null, 2).replace(/\n/g, '\n ');
|
|
80
|
+
return `export default [\n ${json}\n];\n`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function _renderRelationshipSchema(relationshipTag, content) {
|
|
84
|
+
const wrapper = [{ [relationshipTag]: content }];
|
|
85
|
+
return `export default ${JSON.stringify(wrapper, null, 2)};\n`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function propertyValueObjectSchemaManagedPaths(objects = []) {
|
|
89
|
+
const items = _extractPropertyValues(objects);
|
|
90
|
+
const paths = [];
|
|
91
|
+
|
|
92
|
+
for (const { tag } of items) {
|
|
93
|
+
const labelType = propertyNode.createPropertyLabelGraphNodeLabel(tag);
|
|
94
|
+
const valueType = propertyNode.createPropertyValueGraphNodeLabel(tag);
|
|
95
|
+
paths.push(
|
|
96
|
+
`app/src/schemas/ObjectSchemas/generatedCode/propertyValue/${labelType}.js`,
|
|
97
|
+
`app/src/schemas/ObjectSchemas/generatedCode/propertyValue/${valueType}.js`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return paths;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function propertyValueRelationshipSchemaManagedPaths(objects = []) {
|
|
105
|
+
const items = _extractPropertyValues(objects);
|
|
106
|
+
const paths = [];
|
|
107
|
+
|
|
108
|
+
for (const { tag } of items) {
|
|
109
|
+
const tagCap = _capitalize(tag);
|
|
110
|
+
const hasRel = propertyNode.createHasPropertyGraphRelationshipType(tagCap);
|
|
111
|
+
const disabledRel =
|
|
112
|
+
propertyNode.createDisabledPropertyGraphRelationshipType(tagCap);
|
|
113
|
+
const isRel =
|
|
114
|
+
propertyNode.createIsPropertyLabelGraphRelationshipType(tagCap);
|
|
115
|
+
paths.push(
|
|
116
|
+
`app/src/schemas/RelationshipSchemas/generatedCode/propertyValue/${hasRel}.js`,
|
|
117
|
+
`app/src/schemas/RelationshipSchemas/generatedCode/propertyValue/${disabledRel}.js`,
|
|
118
|
+
`app/src/schemas/RelationshipSchemas/generatedCode/propertyValue/${isRel}.js`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return paths;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function emitPropertyValueObjectSchemas({ objects = [] } = {}) {
|
|
126
|
+
const items = _extractPropertyValues(objects);
|
|
127
|
+
if (items.length === 0) {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const artifacts = [];
|
|
132
|
+
|
|
133
|
+
for (const { parentObject, tag } of items) {
|
|
134
|
+
const graphStorageResources = _extractGraphStorageResources(parentObject);
|
|
135
|
+
const storageResourceTags = Object.keys(graphStorageResources);
|
|
136
|
+
|
|
137
|
+
const labelIdSuffix = _capitalize(
|
|
138
|
+
propertyNode.consts.PROPERTY_LABEL_GRAPH_IDENTIFIER_ID
|
|
139
|
+
);
|
|
140
|
+
const labelType = propertyNode.createPropertyLabelGraphNodeLabel(tag);
|
|
141
|
+
const labelIdField = `${tag}${labelIdSuffix}`;
|
|
142
|
+
|
|
143
|
+
const labelSchema = {
|
|
144
|
+
objectType: labelType,
|
|
145
|
+
canDelete: true,
|
|
146
|
+
generatedBy: 'user',
|
|
147
|
+
storageResources: graphStorageResources,
|
|
148
|
+
fieldNames: {
|
|
149
|
+
[labelIdField]: {
|
|
150
|
+
type: 'string',
|
|
151
|
+
randomOnCreate: true,
|
|
152
|
+
canUpdate: false,
|
|
153
|
+
storageResourceTags
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
identifiers: [
|
|
157
|
+
{
|
|
158
|
+
type: 'identifier',
|
|
159
|
+
fieldName: labelIdField
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
artifacts.push({
|
|
165
|
+
path: `app/src/schemas/ObjectSchemas/generatedCode/propertyValue/${labelType}.js`,
|
|
166
|
+
content: _renderObjectSchema(labelSchema)
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const valueIdSuffix = _capitalize(
|
|
170
|
+
propertyNode.consts.PROPERTY_VALUE_GRAPH_IDENTIFIERS_ID
|
|
171
|
+
);
|
|
172
|
+
const valueType = propertyNode.createPropertyValueGraphNodeLabel(tag);
|
|
173
|
+
const valueIdField = `${tag}${valueIdSuffix}`;
|
|
174
|
+
|
|
175
|
+
const valueSchema = {
|
|
176
|
+
objectType: valueType,
|
|
177
|
+
canDelete: true,
|
|
178
|
+
generatedBy: 'user',
|
|
179
|
+
storageResources: graphStorageResources,
|
|
180
|
+
fieldNames: {
|
|
181
|
+
[valueIdField]: {
|
|
182
|
+
type: 'string',
|
|
183
|
+
randomOnCreate: true,
|
|
184
|
+
canUpdate: false,
|
|
185
|
+
storageResourceTags
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
identifiers: [
|
|
189
|
+
{
|
|
190
|
+
type: 'identifier',
|
|
191
|
+
fieldName: valueIdField
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
artifacts.push({
|
|
197
|
+
path: `app/src/schemas/ObjectSchemas/generatedCode/propertyValue/${valueType}.js`,
|
|
198
|
+
content: _renderObjectSchema(valueSchema)
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return artifacts;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function emitPropertyValueRelationshipSchemas({
|
|
206
|
+
objects = [],
|
|
207
|
+
serviceTag = ''
|
|
208
|
+
} = {}) {
|
|
209
|
+
const items = _extractPropertyValues(objects);
|
|
210
|
+
if (items.length === 0) {
|
|
211
|
+
return [];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const artifacts = [];
|
|
215
|
+
|
|
216
|
+
for (const { parentObject, tag } of items) {
|
|
217
|
+
const tagCap = _capitalize(tag);
|
|
218
|
+
const parentObjectType = parentObject.objectType;
|
|
219
|
+
let effectiveServiceTag = 'CurrentService';
|
|
220
|
+
if (parentObject?.serviceTag) {
|
|
221
|
+
effectiveServiceTag = parentObject.serviceTag;
|
|
222
|
+
} else if (serviceTag) {
|
|
223
|
+
effectiveServiceTag = serviceTag;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const graphStorageResources = _extractGraphStorageResources(parentObject);
|
|
227
|
+
const storageResourceTags = Object.keys(graphStorageResources);
|
|
228
|
+
|
|
229
|
+
const labelType = propertyNode.createPropertyLabelGraphNodeLabel(tag);
|
|
230
|
+
const valueType = propertyNode.createPropertyValueGraphNodeLabel(tag);
|
|
231
|
+
|
|
232
|
+
const hasRelTag =
|
|
233
|
+
propertyNode.createHasPropertyGraphRelationshipType(tagCap);
|
|
234
|
+
const hasRel = {
|
|
235
|
+
fieldNames: {},
|
|
236
|
+
storageResources: graphStorageResources,
|
|
237
|
+
generatedBy: 'user',
|
|
238
|
+
links: [
|
|
239
|
+
{
|
|
240
|
+
storageResourceTags,
|
|
241
|
+
from: {
|
|
242
|
+
objType: {
|
|
243
|
+
serviceTag: effectiveServiceTag,
|
|
244
|
+
objectType: parentObjectType
|
|
245
|
+
},
|
|
246
|
+
linkType: 'one'
|
|
247
|
+
},
|
|
248
|
+
to: {
|
|
249
|
+
objType: {
|
|
250
|
+
serviceTag: effectiveServiceTag,
|
|
251
|
+
objectType: valueType
|
|
252
|
+
},
|
|
253
|
+
linkType: 'many',
|
|
254
|
+
requiredOnCreate: true
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
};
|
|
259
|
+
artifacts.push({
|
|
260
|
+
path: `app/src/schemas/RelationshipSchemas/generatedCode/propertyValue/${hasRelTag}.js`,
|
|
261
|
+
content: _renderRelationshipSchema(hasRelTag, hasRel)
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const disabledRelTag =
|
|
265
|
+
propertyNode.createDisabledPropertyGraphRelationshipType(tagCap);
|
|
266
|
+
const disabledRel = {
|
|
267
|
+
fieldNames: {},
|
|
268
|
+
storageResources: graphStorageResources,
|
|
269
|
+
generatedBy: 'user',
|
|
270
|
+
links: [
|
|
271
|
+
{
|
|
272
|
+
storageResourceTags,
|
|
273
|
+
from: {
|
|
274
|
+
objType: {
|
|
275
|
+
serviceTag: effectiveServiceTag,
|
|
276
|
+
objectType: parentObjectType
|
|
277
|
+
},
|
|
278
|
+
linkType: 'one'
|
|
279
|
+
},
|
|
280
|
+
to: {
|
|
281
|
+
objType: {
|
|
282
|
+
serviceTag: effectiveServiceTag,
|
|
283
|
+
objectType: valueType
|
|
284
|
+
},
|
|
285
|
+
linkType: 'many'
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
};
|
|
290
|
+
artifacts.push({
|
|
291
|
+
path: `app/src/schemas/RelationshipSchemas/generatedCode/propertyValue/${disabledRelTag}.js`,
|
|
292
|
+
content: _renderRelationshipSchema(disabledRelTag, disabledRel)
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
const isRelTag =
|
|
296
|
+
propertyNode.createIsPropertyLabelGraphRelationshipType(tagCap);
|
|
297
|
+
const isRel = {
|
|
298
|
+
fieldNames: {},
|
|
299
|
+
storageResources: graphStorageResources,
|
|
300
|
+
generatedBy: 'systemNoUser',
|
|
301
|
+
links: [
|
|
302
|
+
{
|
|
303
|
+
storageResourceTags,
|
|
304
|
+
from: {
|
|
305
|
+
objType: {
|
|
306
|
+
serviceTag: effectiveServiceTag,
|
|
307
|
+
objectType: valueType
|
|
308
|
+
},
|
|
309
|
+
linkType: 'many',
|
|
310
|
+
requiredOnCreate: true
|
|
311
|
+
},
|
|
312
|
+
to: {
|
|
313
|
+
objType: {
|
|
314
|
+
serviceTag: effectiveServiceTag,
|
|
315
|
+
objectType: labelType
|
|
316
|
+
},
|
|
317
|
+
linkType: 'one'
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
};
|
|
322
|
+
artifacts.push({
|
|
323
|
+
path: `app/src/schemas/RelationshipSchemas/generatedCode/propertyValue/${isRelTag}.js`,
|
|
324
|
+
content: _renderRelationshipSchema(isRelTag, isRel)
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return artifacts;
|
|
329
|
+
}
|