@izara_project/izara-core-generate-service-code 1.0.96 → 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.
- package/index.js +2 -2
- package/package.json +2 -1
- package/src/compile/loadSchemas.js +44 -322
- 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/{crud → application/crud}/templates/FlowEndpoint_HdrWbs.ejs +2 -2
- package/src/emit/{crud → application/crud}/templates/FlowMain_Wbs.ejs +2 -2
- package/src/emit/{custom → application/custom}/customFlowS3.js +1 -1
- package/src/emit/{custom → application/custom}/customFlowSteps.js +1 -1
- 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/s3/CreateObject_Main.ejs +5 -2
- package/src/emit/{custom → application/custom}/templates/triggerCache/CheckTriggerCache_Main.ejs +2 -2
- 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/{relationship → application/relationship}/templates/ChangeRelationship_Main.ejs +3 -2
- package/src/emit/{relationship → application/relationship}/templates/CreateRelationship_Main.ejs +3 -2
- package/src/emit/{relationship → application/relationship}/templates/DeleteRelationship_Main.ejs +3 -2
- package/src/emit/{relationship → application/relationship}/templates/GetRelationship_Main.ejs +3 -2
- package/src/emit/{relationship → application/relationship}/templates/MoveRelationship_Main.ejs +3 -2
- package/src/emit/{relationship → application/relationship}/templates/UpdateRelationship_Main.ejs +3 -2
- package/src/emit/{system → application/system}/emitSystemFindDataArtifacts.js +1 -1
- package/src/emit/{system → application/system}/templates/RegisterComplete_Main.ejs +6 -2
- package/src/emit/{system → application/system}/templates/Register_Main.ejs +6 -2
- package/src/emit/{system → application/system}/templates/WebSocketComplete_Main.ejs +3 -3
- package/src/emit/{resource → infrastructure/resources}/generateResourceArtifacts.js +2 -2
- package/src/emit/{resource → infrastructure/resources}/iamResourceArtifacts.js +3 -3
- package/src/emit/{resource → infrastructure/resources}/resourceState.js +4 -4
- package/src/emit/{attributeTree → schemas/attributeTree}/emitAttributeTreeSchemas.js +14 -22
- package/src/emit/schemas/attributeTree/emitAttributeTreeTargetValueStandard.js +132 -0
- package/src/emit/schemas/ledger/emitLedgerSchemas.js +392 -0
- 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/emit/{systemText → schemas/systemText}/emitSystemTextSchemas.js +1 -1
- package/src/generate.js +34 -308
- package/src/{generateIntTest.js → intTest/generateIntTest.js} +2 -2
- package/src/{generateResourceIntTest.js → intTest/generateResourceIntTest.js} +2 -2
- package/src/output/mergeHooks.js +69 -15
- package/src/plan/domainRegistry.js +307 -0
- package/task.md +132 -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} +55 -2
- 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} +18 -9
- package/test/{relationshipApplicationArtifacts.test.js → unit/application/relationshipApplicationArtifacts.test.js} +31 -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} +2 -1
- package/test/unit/output/mergeHooks.test.js +268 -0
- package/test/unit/schemas/attributeTreeDirectives.test.js +177 -0
- package/test/{attributeTreeSchemas.test.js → unit/schemas/attributeTreeSchemas.test.js} +46 -102
- 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 +289 -0
- package/test/unit/schemas/propertyValueSchemas.test.js +265 -0
- package/test/{systemTextSchemas.test.js → unit/schemas/systemTextSchemas.test.js} +24 -36
- package/src/emit/attributeTree/emitAttributeTreeTargetSchemas.js +0 -153
- package/src/emit/attributeTree/resolveTargetServicePath.js +0 -111
- 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/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/FlowEndpoint_Main.ejs +0 -0
- /package/src/emit/{custom → application/custom}/templates/FlowStep_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/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/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/CreateRelationshipComplete_HdrSqs.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/CreateRelationshipComplete_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/GetRelationshipComplete_HdrSqs.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/GetRelationshipComplete_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/UpdateRelationshipComplete_HdrSqs.ejs +0 -0
- /package/src/emit/{relationship → application/relationship}/templates/UpdateRelationshipComplete_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_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/WebSocketComplete_HdrSqs.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,289 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test, { after } from 'node:test';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
emitLedgerObjectSchemas,
|
|
6
|
+
emitLedgerRelationshipSchemas,
|
|
7
|
+
ledgerObjectSchemaManagedPaths,
|
|
8
|
+
ledgerRelationshipSchemaManagedPaths
|
|
9
|
+
} from '../../../src/emit/schemas/ledger/emitLedgerSchemas.js';
|
|
10
|
+
import { generate } from '../../../src/generate.js';
|
|
11
|
+
import {
|
|
12
|
+
createTestProject,
|
|
13
|
+
readProjectFile,
|
|
14
|
+
writeProjectFile,
|
|
15
|
+
cleanupTestProjects
|
|
16
|
+
} from '../../helpers/testProject.js';
|
|
17
|
+
|
|
18
|
+
after(async () => {
|
|
19
|
+
await cleanupTestProjects();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('emitLedgerObjectSchemas returns 1 object schema per ledger addOn', async () => {
|
|
23
|
+
const objects = [
|
|
24
|
+
{
|
|
25
|
+
objectType: 'unitStandard',
|
|
26
|
+
serviceTag: 'UnitStandard',
|
|
27
|
+
storageResources: {
|
|
28
|
+
graph: {
|
|
29
|
+
storageType: 'graph',
|
|
30
|
+
graphServerTag: 'GraphHandler'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
addOnDataStructure: [
|
|
34
|
+
{
|
|
35
|
+
type: 'ledger',
|
|
36
|
+
prefix: 'unitStandardSupplyLocation',
|
|
37
|
+
storageResourceTag: 'graph',
|
|
38
|
+
ledgerType: 'movable',
|
|
39
|
+
targetObjType: {
|
|
40
|
+
serviceTag: 'SupplyLocationStandard',
|
|
41
|
+
objectType: 'supplyLocation'
|
|
42
|
+
},
|
|
43
|
+
moveToTargetObjTypes: [
|
|
44
|
+
{
|
|
45
|
+
serviceTag: 'UnitPacking',
|
|
46
|
+
objectType: 'unitPacking'
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'ledger',
|
|
52
|
+
prefix: 'unitStandardUnitPacking',
|
|
53
|
+
storageResourceTag: 'graph',
|
|
54
|
+
ledgerType: 'movable',
|
|
55
|
+
targetObjType: {
|
|
56
|
+
serviceTag: 'SupplyLocationStandard',
|
|
57
|
+
objectType: 'supplyLocation'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
const artifacts = await emitLedgerObjectSchemas({ objects });
|
|
65
|
+
assert.equal(artifacts.length, 2);
|
|
66
|
+
|
|
67
|
+
const paths = artifacts.map((a) => a.path);
|
|
68
|
+
assert.deepEqual(paths, [
|
|
69
|
+
'app/src/schemas/ObjectSchemas/generatedLedger/unitStandardSupplyLocationEntry.js',
|
|
70
|
+
'app/src/schemas/ObjectSchemas/generatedLedger/unitStandardUnitPackingEntry.js'
|
|
71
|
+
]);
|
|
72
|
+
|
|
73
|
+
const entryArtifact = artifacts[0];
|
|
74
|
+
assert.match(
|
|
75
|
+
entryArtifact.content,
|
|
76
|
+
/"objectType": "unitStandardSupplyLocationEntry"/
|
|
77
|
+
);
|
|
78
|
+
assert.match(entryArtifact.content, /"unitStandardSupplyLocationEntryId"/);
|
|
79
|
+
assert.match(entryArtifact.content, /"generatedBy": "systemNoUser"/);
|
|
80
|
+
assert.match(entryArtifact.content, /"canDelete": false/);
|
|
81
|
+
assert.match(entryArtifact.content, /GraphHandler/);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('emitLedgerRelationshipSchemas returns current, old, and is relationship schemas per ledger addOn', async () => {
|
|
85
|
+
const objects = [
|
|
86
|
+
{
|
|
87
|
+
objectType: 'unitStandard',
|
|
88
|
+
serviceTag: 'UnitStandard',
|
|
89
|
+
storageResources: {
|
|
90
|
+
graph: {
|
|
91
|
+
storageType: 'graph',
|
|
92
|
+
graphServerTag: 'GraphHandler'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
addOnDataStructure: [
|
|
96
|
+
{
|
|
97
|
+
type: 'ledger',
|
|
98
|
+
prefix: 'unitStandardSupplyLocation',
|
|
99
|
+
storageResourceTag: 'graph',
|
|
100
|
+
ledgerType: 'movable',
|
|
101
|
+
targetObjType: {
|
|
102
|
+
serviceTag: 'SupplyLocationStandard',
|
|
103
|
+
objectType: 'supplyLocation'
|
|
104
|
+
},
|
|
105
|
+
moveToTargetObjTypes: [
|
|
106
|
+
{
|
|
107
|
+
serviceTag: 'UnitPacking',
|
|
108
|
+
objectType: 'unitPacking'
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
const artifacts = await emitLedgerRelationshipSchemas({
|
|
117
|
+
objects,
|
|
118
|
+
serviceTag: 'UnitStandard'
|
|
119
|
+
});
|
|
120
|
+
assert.equal(artifacts.length, 3);
|
|
121
|
+
|
|
122
|
+
const paths = artifacts.map((a) => a.path);
|
|
123
|
+
assert.deepEqual(paths, [
|
|
124
|
+
'app/src/schemas/RelationshipSchemas/generatedLedger/currentUnitStandardSupplyLocation.js',
|
|
125
|
+
'app/src/schemas/RelationshipSchemas/generatedLedger/oldUnitStandardSupplyLocation.js',
|
|
126
|
+
'app/src/schemas/RelationshipSchemas/generatedLedger/isUnitStandardSupplyLocationEntry.js'
|
|
127
|
+
]);
|
|
128
|
+
|
|
129
|
+
// 1. Current relationship
|
|
130
|
+
const currentRel = artifacts.find((a) =>
|
|
131
|
+
a.path.endsWith('currentUnitStandardSupplyLocation.js')
|
|
132
|
+
);
|
|
133
|
+
assert.match(currentRel.content, /"currentUnitStandardSupplyLocation"/);
|
|
134
|
+
assert.match(currentRel.content, /"generatedBy": "user"/);
|
|
135
|
+
assert.match(currentRel.content, /"fromTimestamp"/);
|
|
136
|
+
assert.match(
|
|
137
|
+
currentRel.content,
|
|
138
|
+
/"relationshipTag": "oldUnitStandardSupplyLocation"/
|
|
139
|
+
);
|
|
140
|
+
assert.match(currentRel.content, /"belongTo": true/);
|
|
141
|
+
|
|
142
|
+
// 2. Old relationship
|
|
143
|
+
const oldRel = artifacts.find((a) =>
|
|
144
|
+
a.path.endsWith('oldUnitStandardSupplyLocation.js')
|
|
145
|
+
);
|
|
146
|
+
assert.match(oldRel.content, /"oldUnitStandardSupplyLocation"/);
|
|
147
|
+
assert.match(oldRel.content, /"generatedBy": "systemWithUser"/);
|
|
148
|
+
assert.match(oldRel.content, /"fromTimestamp"/);
|
|
149
|
+
assert.match(oldRel.content, /"toTimestamp"/);
|
|
150
|
+
|
|
151
|
+
// 3. IsEntry relationship
|
|
152
|
+
const isRel = artifacts.find((a) =>
|
|
153
|
+
a.path.endsWith('isUnitStandardSupplyLocationEntry.js')
|
|
154
|
+
);
|
|
155
|
+
assert.match(isRel.content, /"isUnitStandardSupplyLocationEntry"/);
|
|
156
|
+
assert.match(isRel.content, /"generatedBy": "systemNoUser"/);
|
|
157
|
+
assert.match(isRel.content, /"supplyLocation"/);
|
|
158
|
+
assert.match(isRel.content, /"unitPacking"/);
|
|
159
|
+
|
|
160
|
+
// 4. Verify requiredOnCreate is false in links
|
|
161
|
+
const _parseRel = (content) => {
|
|
162
|
+
const raw = content
|
|
163
|
+
.replace(/^export default\s+/, '')
|
|
164
|
+
.replace(/;\s*$/, '');
|
|
165
|
+
return JSON.parse(raw)[0];
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const currentRelData = Object.values(_parseRel(currentRel.content))[0];
|
|
169
|
+
for (const link of currentRelData.links) {
|
|
170
|
+
assert.equal(link.from.requiredOnCreate, false);
|
|
171
|
+
assert.equal(link.to.requiredOnCreate, false);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const oldRelData = Object.values(_parseRel(oldRel.content))[0];
|
|
175
|
+
for (const link of oldRelData.links) {
|
|
176
|
+
assert.equal(link.from.requiredOnCreate, false);
|
|
177
|
+
assert.equal(link.to.requiredOnCreate, false);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const isRelData = Object.values(_parseRel(isRel.content))[0];
|
|
181
|
+
for (const link of isRelData.links) {
|
|
182
|
+
assert.equal(link.from.requiredOnCreate, false);
|
|
183
|
+
assert.equal(link.to.requiredOnCreate, false);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test('managed paths return empty array when no ledger is present', async () => {
|
|
188
|
+
const objects = [{ objectType: 'user', addOnDataStructure: [] }];
|
|
189
|
+
assert.deepEqual(ledgerObjectSchemaManagedPaths(objects), []);
|
|
190
|
+
assert.deepEqual(ledgerRelationshipSchemaManagedPaths(objects), []);
|
|
191
|
+
assert.deepEqual(await emitLedgerObjectSchemas({ objects }), []);
|
|
192
|
+
assert.deepEqual(await emitLedgerRelationshipSchemas({ objects }), []);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test('generate commits and cleans up ledger dynamic schemas', async () => {
|
|
196
|
+
const rootPath = await createProjectWithLedger({ hasAddOn: true });
|
|
197
|
+
await generate(rootPath);
|
|
198
|
+
|
|
199
|
+
const objectRelPath =
|
|
200
|
+
'app/src/schemas/ObjectSchemas/generatedLedger/unitStandardSupplyLocationEntry.js';
|
|
201
|
+
const relRelPath =
|
|
202
|
+
'app/src/schemas/RelationshipSchemas/generatedLedger/currentUnitStandardSupplyLocation.js';
|
|
203
|
+
|
|
204
|
+
const objectContent = await readProjectFile(rootPath, objectRelPath);
|
|
205
|
+
assert.match(objectContent, /unitStandardSupplyLocationEntry/);
|
|
206
|
+
assert.match(objectContent, /GraphHandler/);
|
|
207
|
+
|
|
208
|
+
const relContent = await readProjectFile(rootPath, relRelPath);
|
|
209
|
+
assert.match(relContent, /currentUnitStandardSupplyLocation/);
|
|
210
|
+
assert.match(relContent, /oldUnitStandardSupplyLocation/);
|
|
211
|
+
|
|
212
|
+
// Re-run without addOn to verify stale file cleanup
|
|
213
|
+
await createProjectWithLedger({ rootPath, hasAddOn: false });
|
|
214
|
+
await generate(rootPath);
|
|
215
|
+
|
|
216
|
+
await assert.rejects(readProjectFile(rootPath, objectRelPath), {
|
|
217
|
+
code: 'ENOENT'
|
|
218
|
+
});
|
|
219
|
+
await assert.rejects(readProjectFile(rootPath, relRelPath), {
|
|
220
|
+
code: 'ENOENT'
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
async function createProjectWithLedger({
|
|
225
|
+
rootPath: existingRoot,
|
|
226
|
+
hasAddOn = true
|
|
227
|
+
} = {}) {
|
|
228
|
+
const addOnContent = hasAddOn
|
|
229
|
+
? `
|
|
230
|
+
addOnDataStructure: [
|
|
231
|
+
{
|
|
232
|
+
type: 'ledger',
|
|
233
|
+
prefix: 'unitStandardSupplyLocation',
|
|
234
|
+
storageResourceTag: 'graph',
|
|
235
|
+
ledgerType: 'movable',
|
|
236
|
+
targetObjType: {
|
|
237
|
+
serviceTag: 'SupplyLocationStandard',
|
|
238
|
+
objectType: 'supplyLocation'
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
],`
|
|
242
|
+
: ' addOnDataStructure: [],';
|
|
243
|
+
|
|
244
|
+
const schemaContent = `export default [
|
|
245
|
+
{
|
|
246
|
+
objectType: 'unitStandard',
|
|
247
|
+
canDelete: false,
|
|
248
|
+
generatedBy: 'user',${addOnContent}
|
|
249
|
+
storageResources: {
|
|
250
|
+
graph: {
|
|
251
|
+
storageType: 'graph',
|
|
252
|
+
graphServerTag: 'GraphHandler'
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
fieldNames: {
|
|
256
|
+
unitId: {
|
|
257
|
+
type: 'string',
|
|
258
|
+
randomOnCreate: true,
|
|
259
|
+
canUpdate: false,
|
|
260
|
+
storageResourceTags: ['graph']
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
identifiers: [
|
|
264
|
+
{
|
|
265
|
+
type: 'partitionKey',
|
|
266
|
+
fieldName: 'unitId'
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
];
|
|
271
|
+
`;
|
|
272
|
+
|
|
273
|
+
if (existingRoot) {
|
|
274
|
+
await writeProjectFile(
|
|
275
|
+
existingRoot,
|
|
276
|
+
'app/src/schemas/ObjectSchemas/UnitStandard.js',
|
|
277
|
+
schemaContent
|
|
278
|
+
);
|
|
279
|
+
return existingRoot;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return await createTestProject({
|
|
283
|
+
prefix: 'izara-ledger-test-',
|
|
284
|
+
serviceTag: 'UnitStandard',
|
|
285
|
+
schemas: {
|
|
286
|
+
'ObjectSchemas/UnitStandard.js': schemaContent
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test, { after } from 'node:test';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
emitPropertyValueObjectSchemas,
|
|
6
|
+
emitPropertyValueRelationshipSchemas,
|
|
7
|
+
propertyValueObjectSchemaManagedPaths,
|
|
8
|
+
propertyValueRelationshipSchemaManagedPaths
|
|
9
|
+
} from '../../../src/emit/schemas/propertyValue/emitPropertyValueSchemas.js';
|
|
10
|
+
import { generate } from '../../../src/generate.js';
|
|
11
|
+
import {
|
|
12
|
+
createTestProject,
|
|
13
|
+
readProjectFile,
|
|
14
|
+
writeProjectFile,
|
|
15
|
+
cleanupTestProjects
|
|
16
|
+
} from '../../helpers/testProject.js';
|
|
17
|
+
|
|
18
|
+
after(async () => {
|
|
19
|
+
await cleanupTestProjects();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('emitPropertyValueObjectSchemas returns 2 object schemas per propertyValue addOn', () => {
|
|
23
|
+
const objects = [
|
|
24
|
+
{
|
|
25
|
+
objectType: 'item',
|
|
26
|
+
serviceTag: 'ItemService',
|
|
27
|
+
storageResources: {
|
|
28
|
+
dynamoDB: {
|
|
29
|
+
storageType: 'dynamoDB',
|
|
30
|
+
tableName: 'ItemRecords'
|
|
31
|
+
},
|
|
32
|
+
myGraph: {
|
|
33
|
+
storageType: 'graph',
|
|
34
|
+
graphServerTag: 'GraphHandler'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
addOnDataStructure: [
|
|
38
|
+
{
|
|
39
|
+
type: 'propertyValue',
|
|
40
|
+
propertyValuePrefix: 'itemProperty'
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
objectType: 'supplyNetwork',
|
|
46
|
+
serviceTag: 'SupplyService',
|
|
47
|
+
storageResources: {
|
|
48
|
+
myGraph: {
|
|
49
|
+
storageType: 'graph',
|
|
50
|
+
graphServerTag: 'GraphHandler'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
addOnDataStructure: [
|
|
54
|
+
{
|
|
55
|
+
type: 'propertyValue'
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
const artifacts = emitPropertyValueObjectSchemas({ objects });
|
|
62
|
+
assert.equal(artifacts.length, 4);
|
|
63
|
+
|
|
64
|
+
const paths = artifacts.map((a) => a.path);
|
|
65
|
+
assert.deepEqual(paths, [
|
|
66
|
+
'app/src/schemas/ObjectSchemas/generatedCode/propertyValue/itemPropertyPropertyLabel.js',
|
|
67
|
+
'app/src/schemas/ObjectSchemas/generatedCode/propertyValue/itemPropertyPropertyValue.js',
|
|
68
|
+
'app/src/schemas/ObjectSchemas/generatedCode/propertyValue/supplyNetworkPropertyLabel.js',
|
|
69
|
+
'app/src/schemas/ObjectSchemas/generatedCode/propertyValue/supplyNetworkPropertyValue.js'
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
const labelArtifact = artifacts[0];
|
|
73
|
+
assert.match(
|
|
74
|
+
labelArtifact.content,
|
|
75
|
+
/"objectType": "itemPropertyPropertyLabel"/
|
|
76
|
+
);
|
|
77
|
+
assert.match(labelArtifact.content, /"itemPropertyPropertyLabelId"/);
|
|
78
|
+
assert.match(labelArtifact.content, /"generatedBy": "user"/);
|
|
79
|
+
assert.match(labelArtifact.content, /"canDelete": true/);
|
|
80
|
+
assert.doesNotMatch(labelArtifact.content, /dynamoDB/);
|
|
81
|
+
assert.match(labelArtifact.content, /GraphHandler/);
|
|
82
|
+
|
|
83
|
+
const valueArtifact = artifacts[1];
|
|
84
|
+
assert.match(
|
|
85
|
+
valueArtifact.content,
|
|
86
|
+
/"objectType": "itemPropertyPropertyValue"/
|
|
87
|
+
);
|
|
88
|
+
assert.match(valueArtifact.content, /"itemPropertyPropertyValueId"/);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('emitPropertyValueRelationshipSchemas returns 3 relationship schemas per propertyValue addOn', () => {
|
|
92
|
+
const objects = [
|
|
93
|
+
{
|
|
94
|
+
objectType: 'item',
|
|
95
|
+
serviceTag: 'ItemService',
|
|
96
|
+
storageResources: {
|
|
97
|
+
myGraph: {
|
|
98
|
+
storageType: 'graph',
|
|
99
|
+
graphServerTag: 'GraphHandler'
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
addOnDataStructure: [
|
|
103
|
+
{
|
|
104
|
+
type: 'propertyValue',
|
|
105
|
+
propertyValuePrefix: 'item'
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
const artifacts = emitPropertyValueRelationshipSchemas({
|
|
112
|
+
objects,
|
|
113
|
+
serviceTag: 'ItemService'
|
|
114
|
+
});
|
|
115
|
+
assert.equal(artifacts.length, 3);
|
|
116
|
+
|
|
117
|
+
const paths = artifacts.map((a) => a.path);
|
|
118
|
+
assert.deepEqual(paths, [
|
|
119
|
+
'app/src/schemas/RelationshipSchemas/generatedCode/propertyValue/hasItemPropertyValue.js',
|
|
120
|
+
'app/src/schemas/RelationshipSchemas/generatedCode/propertyValue/disabledItemPropertyValue.js',
|
|
121
|
+
'app/src/schemas/RelationshipSchemas/generatedCode/propertyValue/isItemPropertyLabel.js'
|
|
122
|
+
]);
|
|
123
|
+
|
|
124
|
+
// 1. hasItemPropertyValue
|
|
125
|
+
const hasRel = artifacts[0];
|
|
126
|
+
assert.match(hasRel.content, /"hasItemPropertyValue"/);
|
|
127
|
+
assert.match(hasRel.content, /"generatedBy": "user"/);
|
|
128
|
+
assert.match(hasRel.content, /"objectType": "item"/);
|
|
129
|
+
assert.match(hasRel.content, /"objectType": "itemPropertyValue"/);
|
|
130
|
+
assert.match(hasRel.content, /"linkType": "one"/);
|
|
131
|
+
assert.match(hasRel.content, /"linkType": "many"/);
|
|
132
|
+
|
|
133
|
+
// 2. disabledItemPropertyValue
|
|
134
|
+
const disabledRel = artifacts[1];
|
|
135
|
+
assert.match(disabledRel.content, /"disabledItemPropertyValue"/);
|
|
136
|
+
assert.match(disabledRel.content, /"generatedBy": "user"/);
|
|
137
|
+
|
|
138
|
+
// 3. isItemPropertyLabel
|
|
139
|
+
const isRel = artifacts[2];
|
|
140
|
+
assert.match(isRel.content, /"isItemPropertyLabel"/);
|
|
141
|
+
assert.match(isRel.content, /"generatedBy": "systemNoUser"/);
|
|
142
|
+
assert.match(isRel.content, /"objectType": "itemPropertyLabel"/);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('managed paths return empty array when no propertyValue is present', () => {
|
|
146
|
+
const objects = [{ objectType: 'user', addOnDataStructure: [] }];
|
|
147
|
+
assert.deepEqual(propertyValueObjectSchemaManagedPaths(objects), []);
|
|
148
|
+
assert.deepEqual(propertyValueRelationshipSchemaManagedPaths(objects), []);
|
|
149
|
+
assert.deepEqual(emitPropertyValueObjectSchemas({ objects }), []);
|
|
150
|
+
assert.deepEqual(emitPropertyValueRelationshipSchemas({ objects }), []);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('generate commits and cleans up propertyValue dynamic schemas', async () => {
|
|
154
|
+
const rootPath = await createProjectWithPropertyValue({ hasAddOn: true });
|
|
155
|
+
await generate(rootPath);
|
|
156
|
+
|
|
157
|
+
const labelPath =
|
|
158
|
+
'app/src/schemas/ObjectSchemas/generatedCode/propertyValue/itemPropertyLabel.js';
|
|
159
|
+
const valuePath =
|
|
160
|
+
'app/src/schemas/ObjectSchemas/generatedCode/propertyValue/itemPropertyValue.js';
|
|
161
|
+
const hasRelPath =
|
|
162
|
+
'app/src/schemas/RelationshipSchemas/generatedCode/propertyValue/hasItemPropertyValue.js';
|
|
163
|
+
const disabledRelPath =
|
|
164
|
+
'app/src/schemas/RelationshipSchemas/generatedCode/propertyValue/disabledItemPropertyValue.js';
|
|
165
|
+
const isRelPath =
|
|
166
|
+
'app/src/schemas/RelationshipSchemas/generatedCode/propertyValue/isItemPropertyLabel.js';
|
|
167
|
+
|
|
168
|
+
const labelContent = await readProjectFile(rootPath, labelPath);
|
|
169
|
+
assert.match(labelContent, /itemPropertyLabel/);
|
|
170
|
+
assert.match(labelContent, /GraphHandler/);
|
|
171
|
+
|
|
172
|
+
const valueContent = await readProjectFile(rootPath, valuePath);
|
|
173
|
+
assert.match(valueContent, /itemPropertyValue/);
|
|
174
|
+
|
|
175
|
+
const hasRelContent = await readProjectFile(rootPath, hasRelPath);
|
|
176
|
+
assert.match(hasRelContent, /hasItemPropertyValue/);
|
|
177
|
+
|
|
178
|
+
const disabledRelContent = await readProjectFile(rootPath, disabledRelPath);
|
|
179
|
+
assert.match(disabledRelContent, /disabledItemPropertyValue/);
|
|
180
|
+
|
|
181
|
+
const isRelContent = await readProjectFile(rootPath, isRelPath);
|
|
182
|
+
assert.match(isRelContent, /isItemPropertyLabel/);
|
|
183
|
+
|
|
184
|
+
// Re-run without addOn to verify stale file cleanup
|
|
185
|
+
await createProjectWithPropertyValue({ rootPath, hasAddOn: false });
|
|
186
|
+
await generate(rootPath);
|
|
187
|
+
|
|
188
|
+
await assert.rejects(readProjectFile(rootPath, labelPath), {
|
|
189
|
+
code: 'ENOENT'
|
|
190
|
+
});
|
|
191
|
+
await assert.rejects(readProjectFile(rootPath, valuePath), {
|
|
192
|
+
code: 'ENOENT'
|
|
193
|
+
});
|
|
194
|
+
await assert.rejects(readProjectFile(rootPath, hasRelPath), {
|
|
195
|
+
code: 'ENOENT'
|
|
196
|
+
});
|
|
197
|
+
await assert.rejects(readProjectFile(rootPath, disabledRelPath), {
|
|
198
|
+
code: 'ENOENT'
|
|
199
|
+
});
|
|
200
|
+
await assert.rejects(readProjectFile(rootPath, isRelPath), {
|
|
201
|
+
code: 'ENOENT'
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
async function createProjectWithPropertyValue({
|
|
206
|
+
rootPath: existingRoot,
|
|
207
|
+
hasAddOn = true
|
|
208
|
+
} = {}) {
|
|
209
|
+
let addOnContent = ' addOnDataStructure: [],';
|
|
210
|
+
if (hasAddOn) {
|
|
211
|
+
addOnContent = `
|
|
212
|
+
addOnDataStructure: [
|
|
213
|
+
{
|
|
214
|
+
type: 'propertyValue',
|
|
215
|
+
propertyValuePrefix: 'item'
|
|
216
|
+
}
|
|
217
|
+
],`;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const schemaContent = `export default [
|
|
221
|
+
{
|
|
222
|
+
objectType: 'item',
|
|
223
|
+
canDelete: false,
|
|
224
|
+
generatedBy: 'user',${addOnContent}
|
|
225
|
+
storageResources: {
|
|
226
|
+
graph: {
|
|
227
|
+
storageType: 'graph',
|
|
228
|
+
graphServerTag: 'GraphHandler'
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
fieldNames: {
|
|
232
|
+
itemId: {
|
|
233
|
+
type: 'string',
|
|
234
|
+
randomOnCreate: true,
|
|
235
|
+
canUpdate: false,
|
|
236
|
+
storageResourceTags: ['graph']
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
identifiers: [
|
|
240
|
+
{
|
|
241
|
+
type: 'partitionKey',
|
|
242
|
+
fieldName: 'itemId'
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
];
|
|
247
|
+
`;
|
|
248
|
+
|
|
249
|
+
if (existingRoot) {
|
|
250
|
+
await writeProjectFile(
|
|
251
|
+
existingRoot,
|
|
252
|
+
'app/src/schemas/ObjectSchemas/Item.js',
|
|
253
|
+
schemaContent
|
|
254
|
+
);
|
|
255
|
+
return existingRoot;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return await createTestProject({
|
|
259
|
+
prefix: 'izara-property-value-test-',
|
|
260
|
+
serviceTag: 'ItemService',
|
|
261
|
+
schemas: {
|
|
262
|
+
'ObjectSchemas/Item.js': schemaContent
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import assert from 'node:assert/strict';
|
|
2
|
-
import { readFile, rm, writeFile, mkdir } from 'node:fs/promises';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
5
2
|
import test, { after } from 'node:test';
|
|
6
3
|
|
|
7
4
|
import {
|
|
8
5
|
emitSystemTextSchemas,
|
|
9
6
|
systemTextSchemaManagedPaths
|
|
10
|
-
} from '
|
|
11
|
-
import { generate } from '
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
} from '../../../src/emit/schemas/systemText/emitSystemTextSchemas.js';
|
|
8
|
+
import { generate } from '../../../src/generate.js';
|
|
9
|
+
import {
|
|
10
|
+
createTestProject,
|
|
11
|
+
readProjectFile,
|
|
12
|
+
writeProjectFile,
|
|
13
|
+
cleanupTestProjects
|
|
14
|
+
} from '../../helpers/testProject.js';
|
|
15
|
+
|
|
16
|
+
after(async () => {
|
|
17
|
+
await cleanupTestProjects();
|
|
18
|
+
});
|
|
19
19
|
|
|
20
20
|
test('emitSystemTextSchemas produces expected structure for objects, flows, relationships, and notifications', async () => {
|
|
21
21
|
const artifacts = await emitSystemTextSchemas({
|
|
@@ -107,33 +107,21 @@ test('emitSystemTextSchemas returns empty array when no inputs provided', async
|
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
test('generate preserves user hooks inside SystemTextSchemas.js across regeneration', async () => {
|
|
110
|
-
const rootPath =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
110
|
+
const rootPath = await createTestProject({
|
|
111
|
+
prefix: 'system-text-hook-test-',
|
|
112
|
+
serverlessConfig: 'main_config:\n iz_serviceTag: TestService\n',
|
|
113
|
+
schemas: {
|
|
114
|
+
'ObjectSchemas/Item.js':
|
|
115
|
+
"export default { objectType: 'item', fieldNames: { itemId: { type: 'string' } }, generatedBy: 'user' };\n"
|
|
116
|
+
}
|
|
117
117
|
});
|
|
118
|
-
await mkdir(join(rootPath, 'config'), { recursive: true });
|
|
119
|
-
|
|
120
|
-
await writeFile(
|
|
121
|
-
join(rootPath, 'config/serverless.config.yml'),
|
|
122
|
-
'main_config:\n iz_serviceTag: TestService\n'
|
|
123
|
-
);
|
|
124
|
-
await writeFile(
|
|
125
|
-
join(rootPath, 'app/src/schemas/ObjectSchemas/Item.js'),
|
|
126
|
-
"export default { objectType: 'item', fieldNames: { itemId: { type: 'string' } }, generatedBy: 'user' };\n"
|
|
127
|
-
);
|
|
128
118
|
|
|
129
119
|
// First generate
|
|
130
120
|
await generate(rootPath);
|
|
131
121
|
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
);
|
|
136
|
-
const initialContent = await readFile(targetFile, 'utf8');
|
|
122
|
+
const targetRelPath =
|
|
123
|
+
'app/src/schemas/SystemTextSchemas/generatedCode/SystemTextSchemas.js';
|
|
124
|
+
const initialContent = await readProjectFile(rootPath, targetRelPath);
|
|
137
125
|
assert.match(initialContent, /\/\/\(<item_TestServiceitemIdHook>\)/);
|
|
138
126
|
|
|
139
127
|
// User edits inside hook
|
|
@@ -141,12 +129,12 @@ test('generate preserves user hooks inside SystemTextSchemas.js across regenerat
|
|
|
141
129
|
'//(<item_TestServiceitemIdHook>)\n //(</item_TestServiceitemIdHook>)',
|
|
142
130
|
'//(<item_TestServiceitemIdHook>)\n customTranslation: "Item ID Value",\n //(</item_TestServiceitemIdHook>)'
|
|
143
131
|
);
|
|
144
|
-
await
|
|
132
|
+
await writeProjectFile(rootPath, targetRelPath, modifiedContent);
|
|
145
133
|
|
|
146
134
|
// Second generate (regeneration)
|
|
147
135
|
await generate(rootPath);
|
|
148
136
|
|
|
149
|
-
const regeneratedContent = await
|
|
137
|
+
const regeneratedContent = await readProjectFile(rootPath, targetRelPath);
|
|
150
138
|
assert.match(
|
|
151
139
|
regeneratedContent,
|
|
152
140
|
/customTranslation:\s*"Item ID Value"/
|