@izara_project/izara-core-generate-service-code 1.0.95 → 1.0.97
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/index.js +2 -2
- package/package.json +2 -1
- package/src/compile/loadSchemas.js +17 -318
- package/src/compile/loadSchemasRemote.js +195 -0
- package/src/compile/schemaValidatorSetup.js +143 -0
- package/src/emit/{crud → application/crud}/emitCrudApplicationArtifacts.js +2 -2
- package/src/emit/{crud → application/crud}/generateCrudApplicationArtifacts.js +2 -2
- package/src/emit/{crud → application/crud}/generateDynamicCrudFlowSchemas.js +2 -2
- package/src/emit/{custom → application/custom}/customFlowS3.js +1 -1
- package/src/emit/{custom → application/custom}/customFlowSteps.js +34 -5
- package/src/emit/{custom → application/custom}/customFlowTemplates.js +1 -1
- package/src/emit/{custom → application/custom}/emitCustomFlowApplicationArtifacts.js +1 -1
- package/src/emit/{custom → application/custom}/generateCustomFlowApplicationArtifacts.js +2 -2
- package/src/emit/{custom → application/custom}/templates/FlowEndpoint_Main.ejs +66 -4
- package/src/emit/{custom → application/custom}/templates/FlowStep_Main.ejs +27 -0
- package/src/emit/{rbac → application/rbac}/emitRbacApplicationArtifacts.js +2 -2
- package/src/emit/{rbac → application/rbac}/generateCreateTargetRoleHandler.js +2 -2
- package/src/emit/{rbac → application/rbac}/generateDynamicRbacFlowSchemas.js +2 -2
- package/src/emit/{relationship → application/relationship}/emitRelationshipApplicationArtifacts.js +3 -3
- package/src/emit/{relationship → application/relationship}/generateDynamicRelationshipFlowSchemas.js +2 -2
- package/src/emit/{relationship → application/relationship}/generateRelationshipApplicationArtifacts.js +2 -2
- package/src/emit/{system → application/system}/emitSystemFindDataArtifacts.js +1 -1
- package/src/emit/{resource → infrastructure/resources}/generateResourceArtifacts.js +2 -2
- package/src/emit/{resource → infrastructure/resources}/iamResourceArtifacts.js +2 -2
- package/src/emit/{resource → infrastructure/resources}/resourceState.js +4 -4
- package/src/emit/{attributeTree → schemas/attributeTree}/emitAttributeTreeSchemas.js +29 -48
- package/src/emit/schemas/attributeTree/emitAttributeTreeTargetSchemas.js +153 -0
- package/src/emit/schemas/attributeTree/resolveTargetServicePath.js +111 -0
- package/src/emit/schemas/ledger/emitLedgerSchemas.js +370 -0
- package/src/emit/{systemText → schemas/systemText}/emitSystemTextSchemas.js +1 -1
- package/src/generate.js +81 -240
- package/src/{generateIntTest.js → intTest/generateIntTest.js} +2 -2
- package/src/{generateResourceIntTest.js → intTest/generateResourceIntTest.js} +2 -2
- package/src/plan/domainRegistry.js +271 -0
- package/test/helpers/testProject.js +127 -0
- package/test/helpers/testProject.test.js +57 -0
- package/test/{core.test.js → integration/core.test.js} +3 -3
- package/test/{graphDrivenFlowSchema.test.js → integration/graphDrivenFlowSchema.test.js} +1 -1
- package/test/{intTestApi.test.js → integration/intTestApi.test.js} +1 -1
- package/test/{publicApi.test.js → integration/publicApi.test.js} +1 -1
- package/test/{createTargetRoleHandler.test.js → unit/application/createTargetRoleHandler.test.js} +1 -1
- package/test/{crudApplicationArtifacts.test.js → unit/application/crudApplicationArtifacts.test.js} +1 -1
- package/test/{customFlowApplicationArtifacts.test.js → unit/application/customFlowApplicationArtifacts.test.js} +139 -9
- package/test/{relationshipApplicationArtifacts.test.js → unit/application/relationshipApplicationArtifacts.test.js} +1 -1
- package/test/{systemFindDataArtifacts.test.js → unit/application/systemFindDataArtifacts.test.js} +1 -1
- package/test/{functionYamlArtifact.test.js → unit/infrastructure/functionYamlArtifact.test.js} +1 -1
- package/test/{resourceArtifacts.test.js → unit/infrastructure/resourceArtifacts.test.js} +1 -1
- package/test/{attributeTreeSchemas.test.js → unit/schemas/attributeTreeSchemas.test.js} +127 -50
- package/test/{dynamicCrudFlowSchemas.test.js → unit/schemas/dynamicCrudFlowSchemas.test.js} +2 -2
- package/test/{dynamicRbacFlowSchemas.test.js → unit/schemas/dynamicRbacFlowSchemas.test.js} +1 -1
- package/test/{dynamicRelationshipFlowSchemas.test.js → unit/schemas/dynamicRelationshipFlowSchemas.test.js} +11 -1
- package/test/{errorSchemas.test.js → unit/schemas/errorSchemas.test.js} +2 -2
- package/test/unit/schemas/ledgerSchemas.test.js +263 -0
- package/test/{systemTextSchemas.test.js → unit/schemas/systemTextSchemas.test.js} +24 -36
- package/src/emit/crud/loadLocalSchemaArrays.js +0 -4
- /package/src/emit/{coreFunction → application/coreFunction}/emitCoreFunctionArtifacts.js +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/CoreFunction_Yaml.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/CoreResource_Yaml.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/GenerateSeedDataDynamo_HdrInv.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/GenerateSeedDataDynamo_Main.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/GenerateSeedDataGraphData_HdrInv.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/GenerateSeedDataGraphData_Main.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/GenerateSeedDataGraphSchema_HdrInv.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/GenerateSeedDataGraphSchema_Main.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/GeneratedGraphNodeSchemas.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/GeneratedGraphRelSchemas.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/GeneratedTableConfigs.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupConfig.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupRunner.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupRunner_initialSetup.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupRunner_seedDynamo.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupRunner_seedGraph.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupRunner_seedRemove.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetupRunner_uploadSchema.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetup_HdrInv.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/InitialSetup_Main.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/RemoveSeedDataDynamo_HdrInv.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/RemoveSeedDataDynamo_Main.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/UploadSchema_HdrInv.ejs +0 -0
- /package/src/emit/{coreFunction → application/coreFunction}/templates/UploadSchema_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/crudActionPlan.js +0 -0
- /package/src/emit/{crud → application/crud}/dynamicCrudFlowSchemaTemplate.js +0 -0
- /package/src/emit/{crud → application/crud}/emitDynamicCrudFlowSchemas.js +0 -0
- /package/src/emit/{crud → application/crud}/templates/CreateAfterHookCallback_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/CreateBeforeHookCallback_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/CreateComplete_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/CreateConfirmComplete_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/CreateEndpoint_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/CreateLogicalLib.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/CreateNodeCallback_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/DeleteAfterHookCallback_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/DeleteBeforeHookCallback_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/DeleteComplete_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/DeleteEndpoint_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/DeleteLogicalLib.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/FlowEndpointRbacCallback_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/FlowEndpoint_HdrWbs.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/FlowMain_Wbs.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/GetEndpoint_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/GetRangeEndpoint_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/UpdateAfterHookCallback_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/UpdateBeforeHookCallback_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/UpdateComplete_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/UpdateEndpoint_Main.ejs +0 -0
- /package/src/emit/{crud → application/crud}/templates/UpdateLogicalLib.ejs +0 -0
- /package/src/emit/{custom → application/custom}/customFlowPaths.js +0 -0
- /package/src/emit/{custom → application/custom}/customFlows.js +0 -0
- /package/src/emit/{custom → application/custom}/templates/FlowEndpointRbacCallback_Main.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/s3/ConfirmReserved_HdrSqs.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/s3/ConfirmReserved_Main.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/s3/CreateObject_HdrWbs.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/s3/CreateObject_Main.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/s3/CreatePreSignUrl_HdrSqs.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/s3/CreatePreSignUrl_Main.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/s3/FlowHandler_HdrS3.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/s3/ProcessS3File_Main.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/s3/ReservedLimit_HdrSqs.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/s3/ReservedLimit_Main.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/triggerCache/CheckTriggerCache_Main.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/triggerCache/TriggerCacheComplete_Main.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/triggerCache/TriggerCache_Main.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/emitDynamicRbacFlowSchemas.js +0 -0
- /package/src/emit/{rbac → application/rbac}/rbacFlowTag.js +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/CancelUsage_Main.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/ConfirmUsage_Main.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/CreateTargetRole_HdrSqs.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/CreateTargetRole_Main.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/DeleteTargetRole_Main.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/DynamicRbacFlowSchema.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/GetMyPermissions_Main.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/GetTargetRole_Main.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/ListRbac_HdrApi.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/ListRbac_HdrSqs.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/ListRbac_Main.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/RbacMutation_Main.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/ReservedDynamicUsage_Main.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/UpdateTargetRole_Main.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/UserRbacFlow_HdrSqs.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/UserRbacFlow_Main.ejs +0 -0
- /package/src/emit/{rbac → application/rbac}/templates/UserRoleMutation_Main.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/emitDynamicRelationshipFlowSchemas.js +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/ChangeRelationshipComplete_HdrSqs.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/ChangeRelationshipComplete_Main.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/ChangeRelationship_Main.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/CreateRelationshipComplete_HdrSqs.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/CreateRelationshipComplete_Main.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/CreateRelationship_Main.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/DeleteRelationshipComplete_HdrSqs.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/DeleteRelationshipComplete_Main.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/DeleteRelationship_Main.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/GetRelationshipComplete_HdrSqs.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/GetRelationshipComplete_Main.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/GetRelationship_Main.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/MoveRelationshipComplete_HdrSqs.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/MoveRelationshipComplete_Main.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/MoveRelationship_Main.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/UpdateRelationshipComplete_HdrSqs.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/UpdateRelationshipComplete_Main.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/UpdateRelationship_Main.ejs +0 -0
- /package/src/emit/{system → application/system}/emitSystemWebSocketArtifacts.js +0 -0
- /package/src/emit/{system → application/system}/templates/RegisterComplete_HdrSqs.ejs +0 -0
- /package/src/emit/{system → application/system}/templates/RegisterComplete_Main.ejs +0 -0
- /package/src/emit/{system → application/system}/templates/RegisterComplete_Yaml.ejs +0 -0
- /package/src/emit/{system → application/system}/templates/RegisterWbs_Yaml.ejs +0 -0
- /package/src/emit/{system → application/system}/templates/Register_HdrWbs.ejs +0 -0
- /package/src/emit/{system → application/system}/templates/Register_Main.ejs +0 -0
- /package/src/emit/{system → application/system}/templates/WebSocketComplete_HdrSqs.ejs +0 -0
- /package/src/emit/{system → application/system}/templates/WebSocketComplete_Main.ejs +0 -0
- /package/src/emit/{system → application/system}/templates/WebSocketComplete_Yaml.ejs +0 -0
- /package/src/emit/{system → application/system}/templates/WebSocketConnect.ejs +0 -0
- /package/src/emit/{system → application/system}/templates/WebSocketConnect_Yaml.ejs +0 -0
- /package/src/emit/{function → infrastructure/functions}/functionYamlArtifact.js +0 -0
- /package/src/emit/{function → infrastructure/functions}/templates/ApiFunction_Yaml.ejs +0 -0
- /package/src/emit/{function → infrastructure/functions}/templates/EventBridgeFunction_Yaml.ejs +0 -0
- /package/src/emit/{function → infrastructure/functions}/templates/InvFunction_Yaml.ejs +0 -0
- /package/src/emit/{function → infrastructure/functions}/templates/S3Function_Yaml.ejs +0 -0
- /package/src/emit/{function → infrastructure/functions}/templates/SqsFunction_Yaml.ejs +0 -0
- /package/src/emit/{function → infrastructure/functions}/templates/WbsFunction_Yaml.ejs +0 -0
- /package/src/emit/{resource → infrastructure/resources}/dynamoResourceArtifacts.js +0 -0
- /package/src/emit/{resource → infrastructure/resources}/emitResourceArtifacts.js +0 -0
- /package/src/emit/{resource → infrastructure/resources}/resourceTemplate.js +0 -0
- /package/src/emit/{resource → infrastructure/resources}/s3ResourceArtifacts.js +0 -0
- /package/src/emit/{resource → infrastructure/resources}/sqsResourceArtifacts.js +0 -0
- /package/src/emit/{resource → infrastructure/resources}/templates/DynamoDBTable_Yaml.ejs +0 -0
- /package/src/emit/{resource → infrastructure/resources}/templates/FlowOut_Yaml.ejs +0 -0
- /package/src/emit/{resource → infrastructure/resources}/templates/GeneratedLambdaRoleServiceConfig.ejs +0 -0
- /package/src/emit/{resource → infrastructure/resources}/templates/ResourceSqsYaml.ejs +0 -0
- /package/src/emit/{resource → infrastructure/resources}/templates/ResourceYaml.ejs +0 -0
- /package/src/emit/{resource → infrastructure/resources}/templates/S3Bucket_Yaml.ejs +0 -0
- /package/src/emit/{resource → infrastructure/resources}/templates/S3Subscription_Yaml.ejs +0 -0
- /package/src/emit/{resource → infrastructure/resources}/templates/SharedResource_Yaml.ejs +0 -0
- /package/src/emit/{resource → infrastructure/resources}/templates/SystemDynamoDB_Yaml.ejs +0 -0
- /package/src/emit/{resource → infrastructure/resources}/templates/WebSocketSubscription_Yaml.ejs +0 -0
- /package/src/emit/{error → schemas/error}/emitErrorSchemas.js +0 -0
- /package/src/emit/{error → schemas/error}/templates/errorSchema.ejs +0 -0
- /package/src/emit/{systemText → schemas/systemText}/templates/SystemTextSchemas.ejs +0 -0
- /package/src/{generateResources/IntTest → intTest/generators}/consts.js +0 -0
- /package/src/{generateResources/IntTest → intTest/generators}/generateResources/generateResources.js +0 -0
- /package/src/{generateResources/IntTest → intTest/generators}/generateResources/templateResources.ejs +0 -0
- /package/src/{generateResources/IntTest → intTest/generators}/generateTests/events/events.js +0 -0
- /package/src/{generateResources/IntTest → intTest/generators}/generateTests/events/templateEvents.ejs +0 -0
- /package/src/{generateResources/IntTest → intTest/generators}/generateTests/generateTemplate.js +0 -0
- /package/src/{generateResources/IntTest → intTest/generators}/generateTests/pathIntTest/pathIntTest.js +0 -0
- /package/src/{generateResources/IntTest → intTest/generators}/generateTests/pathIntTest/template.ejs +0 -0
- /package/src/{generateResources/IntTest → intTest/generators}/generateTests/tests/templateTests.ejs +0 -0
- /package/src/{generateResources/IntTest → intTest/generators}/generateTests/tests/tests.js +0 -0
- /package/src/{generateResources/IntTest → intTest/generators}/libs/IntTestGenerateLib.js +0 -0
- /package/src/{generateResources/IntTest → intTest/generators}/upload/uploadIntTest.js +0 -0
- /package/src/{intTestGeneratorShared.js → intTest/intTestGeneratorShared.js} +0 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Emits dynamic ObjectSchemas and RelationshipSchemas for ledger add-ons
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
function _capitalize(str) {
|
|
6
|
+
if (!str || typeof str !== 'string') {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function _createLedgerComponent(prefix) {
|
|
13
|
+
const cap = _capitalize(prefix);
|
|
14
|
+
return {
|
|
15
|
+
oldRelationshipTag: `old${cap}`,
|
|
16
|
+
newRelationshipTag: `current${cap}`,
|
|
17
|
+
objectType: `${prefix}Entry`
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _extractLedgers(objects = []) {
|
|
22
|
+
if (!Array.isArray(objects)) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
const results = [];
|
|
26
|
+
const seenPrefixes = new Set();
|
|
27
|
+
|
|
28
|
+
for (const object of objects) {
|
|
29
|
+
if (!Array.isArray(object?.addOnDataStructure)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
for (const addOn of object.addOnDataStructure) {
|
|
33
|
+
if (addOn?.type === 'ledger' && addOn?.prefix) {
|
|
34
|
+
if (seenPrefixes.has(addOn.prefix)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
seenPrefixes.add(addOn.prefix);
|
|
38
|
+
results.push({
|
|
39
|
+
parentObject: object,
|
|
40
|
+
addOn,
|
|
41
|
+
prefix: addOn.prefix,
|
|
42
|
+
component: _createLedgerComponent(addOn.prefix)
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return results;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function _extractGraphStorageResources(object, storageResourceTag) {
|
|
52
|
+
const result = {};
|
|
53
|
+
if (object?.storageResources) {
|
|
54
|
+
if (
|
|
55
|
+
storageResourceTag &&
|
|
56
|
+
object.storageResources[storageResourceTag]?.storageType === 'graph'
|
|
57
|
+
) {
|
|
58
|
+
let graphServerTag = 'GraphHandler';
|
|
59
|
+
if (object.storageResources[storageResourceTag].graphServerTag) {
|
|
60
|
+
graphServerTag =
|
|
61
|
+
object.storageResources[storageResourceTag].graphServerTag;
|
|
62
|
+
}
|
|
63
|
+
result[storageResourceTag] = {
|
|
64
|
+
storageType: 'graph',
|
|
65
|
+
graphServerTag
|
|
66
|
+
};
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
for (const [tag, res] of Object.entries(object.storageResources)) {
|
|
70
|
+
if (res?.storageType === 'graph') {
|
|
71
|
+
let graphServerTag = 'GraphHandler';
|
|
72
|
+
if (res.graphServerTag) {
|
|
73
|
+
graphServerTag = res.graphServerTag;
|
|
74
|
+
}
|
|
75
|
+
result[tag] = {
|
|
76
|
+
storageType: 'graph',
|
|
77
|
+
graphServerTag
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (Object.keys(result).length === 0) {
|
|
83
|
+
let defaultTag = 'graph';
|
|
84
|
+
if (storageResourceTag) {
|
|
85
|
+
defaultTag = storageResourceTag;
|
|
86
|
+
}
|
|
87
|
+
result[defaultTag] = {
|
|
88
|
+
storageType: 'graph',
|
|
89
|
+
graphServerTag: 'GraphHandler'
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _renderObjectSchema(schema) {
|
|
96
|
+
return `export default [\n ${JSON.stringify(schema, null, 2).replace(/\n/g, '\n ')}\n];\n`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function _renderRelationshipSchema(relationshipTag, content) {
|
|
100
|
+
const wrapper = [{ [relationshipTag]: content }];
|
|
101
|
+
return `export default ${JSON.stringify(wrapper, null, 2)};\n`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _buildParentToEntryLinks({
|
|
105
|
+
storageResourceTags,
|
|
106
|
+
effectiveServiceTag,
|
|
107
|
+
parentObjectType,
|
|
108
|
+
entryObjectType
|
|
109
|
+
}) {
|
|
110
|
+
return [
|
|
111
|
+
{
|
|
112
|
+
storageResourceTags,
|
|
113
|
+
canDelete: true,
|
|
114
|
+
from: {
|
|
115
|
+
objType: {
|
|
116
|
+
serviceTag: effectiveServiceTag,
|
|
117
|
+
objectType: parentObjectType
|
|
118
|
+
},
|
|
119
|
+
linkType: 'many',
|
|
120
|
+
requiredOnCreate: true,
|
|
121
|
+
belongTo: true
|
|
122
|
+
},
|
|
123
|
+
to: {
|
|
124
|
+
objType: {
|
|
125
|
+
serviceTag: effectiveServiceTag,
|
|
126
|
+
objectType: entryObjectType
|
|
127
|
+
},
|
|
128
|
+
linkType: 'one',
|
|
129
|
+
requiredOnCreate: false
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function ledgerObjectSchemaManagedPaths(objects = []) {
|
|
136
|
+
const ledgers = _extractLedgers(objects);
|
|
137
|
+
const paths = [];
|
|
138
|
+
|
|
139
|
+
for (const { component } of ledgers) {
|
|
140
|
+
paths.push(
|
|
141
|
+
`app/src/schemas/ObjectSchemas/generatedLedger/${component.objectType}.js`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return paths;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function ledgerRelationshipSchemaManagedPaths(objects = []) {
|
|
149
|
+
const ledgers = _extractLedgers(objects);
|
|
150
|
+
const paths = [];
|
|
151
|
+
|
|
152
|
+
for (const { component, addOn } of ledgers) {
|
|
153
|
+
paths.push(
|
|
154
|
+
`app/src/schemas/RelationshipSchemas/generatedLedger/${component.newRelationshipTag}.js`,
|
|
155
|
+
`app/src/schemas/RelationshipSchemas/generatedLedger/${component.oldRelationshipTag}.js`
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
let hasTargets = false;
|
|
159
|
+
if (addOn?.targetObjType) {
|
|
160
|
+
hasTargets = true;
|
|
161
|
+
} else if (
|
|
162
|
+
Array.isArray(addOn?.moveToTargetObjTypes) &&
|
|
163
|
+
addOn.moveToTargetObjTypes.length > 0
|
|
164
|
+
) {
|
|
165
|
+
hasTargets = true;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (hasTargets) {
|
|
169
|
+
const isRelTag = `is${_capitalize(component.objectType)}`;
|
|
170
|
+
paths.push(
|
|
171
|
+
`app/src/schemas/RelationshipSchemas/generatedLedger/${isRelTag}.js`
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return paths;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function emitLedgerObjectSchemas({ objects = [] } = {}) {
|
|
180
|
+
const ledgers = _extractLedgers(objects);
|
|
181
|
+
if (ledgers.length === 0) {
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const artifacts = [];
|
|
186
|
+
|
|
187
|
+
for (const { parentObject, addOn, component } of ledgers) {
|
|
188
|
+
const objectType = component.objectType;
|
|
189
|
+
const graphStorageResources = _extractGraphStorageResources(
|
|
190
|
+
parentObject,
|
|
191
|
+
addOn.storageResourceTag
|
|
192
|
+
);
|
|
193
|
+
const storageResourceTags = Object.keys(graphStorageResources);
|
|
194
|
+
|
|
195
|
+
const schema = {
|
|
196
|
+
objectType,
|
|
197
|
+
generatedBy: 'systemNoUser',
|
|
198
|
+
canDelete: false,
|
|
199
|
+
storageResources: graphStorageResources,
|
|
200
|
+
fieldNames: {
|
|
201
|
+
[`${objectType}Id`]: {
|
|
202
|
+
storageResourceTags,
|
|
203
|
+
type: 'string',
|
|
204
|
+
randomOnCreate: true,
|
|
205
|
+
canUpdate: false,
|
|
206
|
+
requiredOnCreate: false,
|
|
207
|
+
optionalOnCreate: false
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
identifiers: [
|
|
211
|
+
{
|
|
212
|
+
type: 'identifier',
|
|
213
|
+
fieldName: `${objectType}Id`
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
artifacts.push({
|
|
219
|
+
path: `app/src/schemas/ObjectSchemas/generatedLedger/${objectType}.js`,
|
|
220
|
+
content: _renderObjectSchema(schema)
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return artifacts;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export function emitLedgerRelationshipSchemas({
|
|
228
|
+
objects = [],
|
|
229
|
+
serviceTag = ''
|
|
230
|
+
} = {}) {
|
|
231
|
+
const ledgers = _extractLedgers(objects);
|
|
232
|
+
if (ledgers.length === 0) {
|
|
233
|
+
return [];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const artifacts = [];
|
|
237
|
+
|
|
238
|
+
for (const { parentObject, addOn, component } of ledgers) {
|
|
239
|
+
let effectiveServiceTag = 'CurrentService';
|
|
240
|
+
if (parentObject?.serviceTag) {
|
|
241
|
+
effectiveServiceTag = parentObject.serviceTag;
|
|
242
|
+
} else if (serviceTag) {
|
|
243
|
+
effectiveServiceTag = serviceTag;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const graphStorageResources = _extractGraphStorageResources(
|
|
247
|
+
parentObject,
|
|
248
|
+
addOn.storageResourceTag
|
|
249
|
+
);
|
|
250
|
+
const storageResourceTags = Object.keys(graphStorageResources);
|
|
251
|
+
|
|
252
|
+
const parentToEntryLinks = _buildParentToEntryLinks({
|
|
253
|
+
storageResourceTags,
|
|
254
|
+
effectiveServiceTag,
|
|
255
|
+
parentObjectType: parentObject.objectType,
|
|
256
|
+
entryObjectType: component.objectType
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// 1. current<Prefix>.js
|
|
260
|
+
const currentRel = {
|
|
261
|
+
generatedBy: 'user',
|
|
262
|
+
storageResources: graphStorageResources,
|
|
263
|
+
canChangeToRelTypes: [
|
|
264
|
+
{
|
|
265
|
+
relType: {
|
|
266
|
+
serviceTag: effectiveServiceTag,
|
|
267
|
+
relationshipTag: component.oldRelationshipTag
|
|
268
|
+
},
|
|
269
|
+
changeBy: 'systemWithUser'
|
|
270
|
+
}
|
|
271
|
+
],
|
|
272
|
+
fieldNames: {
|
|
273
|
+
fromTimestamp: {
|
|
274
|
+
type: 'number',
|
|
275
|
+
requiredOnCreate: true,
|
|
276
|
+
canUpdate: false
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
links: parentToEntryLinks
|
|
280
|
+
};
|
|
281
|
+
artifacts.push({
|
|
282
|
+
path: `app/src/schemas/RelationshipSchemas/generatedLedger/${component.newRelationshipTag}.js`,
|
|
283
|
+
content: _renderRelationshipSchema(
|
|
284
|
+
component.newRelationshipTag,
|
|
285
|
+
currentRel
|
|
286
|
+
)
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// 2. old<Prefix>.js
|
|
290
|
+
const oldRel = {
|
|
291
|
+
generatedBy: 'systemWithUser',
|
|
292
|
+
storageResources: graphStorageResources,
|
|
293
|
+
fieldNames: {
|
|
294
|
+
fromTimestamp: {
|
|
295
|
+
type: 'number',
|
|
296
|
+
requiredOnCreate: true,
|
|
297
|
+
canUpdate: false
|
|
298
|
+
},
|
|
299
|
+
toTimestamp: {
|
|
300
|
+
type: 'number',
|
|
301
|
+
requiredOnCreate: true,
|
|
302
|
+
canUpdate: false
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
links: parentToEntryLinks
|
|
306
|
+
};
|
|
307
|
+
artifacts.push({
|
|
308
|
+
path: `app/src/schemas/RelationshipSchemas/generatedLedger/${component.oldRelationshipTag}.js`,
|
|
309
|
+
content: _renderRelationshipSchema(component.oldRelationshipTag, oldRel)
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
// 3. is<Prefix>Entry.js (if targetObjType or moveToTargetObjTypes is present)
|
|
313
|
+
const targetObjTypes = [];
|
|
314
|
+
if (addOn.targetObjType?.objectType) {
|
|
315
|
+
targetObjTypes.push(addOn.targetObjType);
|
|
316
|
+
}
|
|
317
|
+
if (Array.isArray(addOn.moveToTargetObjTypes)) {
|
|
318
|
+
for (const target of addOn.moveToTargetObjTypes) {
|
|
319
|
+
if (target?.objectType) {
|
|
320
|
+
targetObjTypes.push(target);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (targetObjTypes.length > 0) {
|
|
326
|
+
const isRelTag = `is${_capitalize(component.objectType)}`;
|
|
327
|
+
const isLinks = [];
|
|
328
|
+
|
|
329
|
+
for (const target of targetObjTypes) {
|
|
330
|
+
let targetServiceTag = effectiveServiceTag;
|
|
331
|
+
if (target.serviceTag) {
|
|
332
|
+
targetServiceTag = target.serviceTag;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
isLinks.push({
|
|
336
|
+
storageResourceTags,
|
|
337
|
+
canDelete: true,
|
|
338
|
+
from: {
|
|
339
|
+
objType: {
|
|
340
|
+
serviceTag: effectiveServiceTag,
|
|
341
|
+
objectType: component.objectType
|
|
342
|
+
},
|
|
343
|
+
linkType: 'many',
|
|
344
|
+
requiredOnCreate: true
|
|
345
|
+
},
|
|
346
|
+
to: {
|
|
347
|
+
objType: {
|
|
348
|
+
serviceTag: targetServiceTag,
|
|
349
|
+
objectType: target.objectType
|
|
350
|
+
},
|
|
351
|
+
linkType: 'one',
|
|
352
|
+
requiredOnCreate: false
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const isRel = {
|
|
358
|
+
generatedBy: 'systemNoUser',
|
|
359
|
+
storageResources: graphStorageResources,
|
|
360
|
+
links: isLinks
|
|
361
|
+
};
|
|
362
|
+
artifacts.push({
|
|
363
|
+
path: `app/src/schemas/RelationshipSchemas/generatedLedger/${isRelTag}.js`,
|
|
364
|
+
content: _renderRelationshipSchema(isRelTag, isRel)
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return artifacts;
|
|
370
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import ejsLib from 'ejs';
|
|
3
|
-
import { rbacFlowTag } from '
|
|
3
|
+
import { rbacFlowTag } from '../../application/rbac/rbacFlowTag.js';
|
|
4
4
|
|
|
5
5
|
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
6
6
|
const SYSTEM_TEXT_SCHEMA_PATH =
|