@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from 'node:assert/strict';
|
|
2
|
-
import { mkdir, mkdtemp
|
|
2
|
+
import { mkdir, mkdtemp } from 'node:fs/promises';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import test, { after } from 'node:test';
|
|
@@ -8,21 +8,24 @@ import {
|
|
|
8
8
|
emitAttributeTreeObjectSchemas,
|
|
9
9
|
emitAttributeTreeRelationshipSchemas,
|
|
10
10
|
attributeTreeObjectSchemaManagedPaths,
|
|
11
|
-
attributeTreeRelationshipSchemaManagedPaths
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
attributeTreeRelationshipSchemaManagedPaths,
|
|
12
|
+
resolveTargetServicePath,
|
|
13
|
+
emitAttributeTreeTargetSchemas
|
|
14
|
+
} from '../../../src/emit/schemas/attributeTree/emitAttributeTreeSchemas.js';
|
|
15
|
+
import { generate } from '../../../src/generate.js';
|
|
16
|
+
import {
|
|
17
|
+
createTestProject,
|
|
18
|
+
readProjectFile,
|
|
19
|
+
writeProjectFile,
|
|
20
|
+
cleanupTestProjects,
|
|
21
|
+
trackTestProject
|
|
22
|
+
} from '../../helpers/testProject.js';
|
|
16
23
|
|
|
17
24
|
after(async () => {
|
|
18
|
-
await
|
|
19
|
-
[...projectRoots].map((rootPath) =>
|
|
20
|
-
rm(rootPath, { recursive: true, force: true })
|
|
21
|
-
)
|
|
22
|
-
);
|
|
25
|
+
await cleanupTestProjects();
|
|
23
26
|
});
|
|
24
27
|
|
|
25
|
-
test('emitAttributeTreeObjectSchemas returns
|
|
28
|
+
test('emitAttributeTreeObjectSchemas returns 3 object schemas per attributeTree tag', () => {
|
|
26
29
|
const objects = [
|
|
27
30
|
{
|
|
28
31
|
objectType: 'sellOffer',
|
|
@@ -47,16 +50,21 @@ test('emitAttributeTreeObjectSchemas returns 4 object schemas per attributeTree
|
|
|
47
50
|
];
|
|
48
51
|
|
|
49
52
|
const artifacts = emitAttributeTreeObjectSchemas({ objects });
|
|
50
|
-
assert.equal(artifacts.length,
|
|
53
|
+
assert.equal(artifacts.length, 3);
|
|
51
54
|
|
|
52
55
|
const paths = artifacts.map((a) => a.path);
|
|
53
56
|
assert.deepEqual(paths, [
|
|
54
57
|
'app/src/schemas/ObjectSchemas/generatedAttributeTree/sellOfferTermLink.js',
|
|
55
|
-
'app/src/schemas/ObjectSchemas/generatedAttributeTree/
|
|
56
|
-
'app/src/schemas/ObjectSchemas/generatedAttributeTree/sellOfferTermLabel.js'
|
|
57
|
-
'app/src/schemas/ObjectSchemas/generatedAttributeTree/sellOfferTermValueStandard.js'
|
|
58
|
+
'app/src/schemas/ObjectSchemas/generatedAttributeTree/sellOfferTermValue.js',
|
|
59
|
+
'app/src/schemas/ObjectSchemas/generatedAttributeTree/sellOfferTermLabel.js'
|
|
58
60
|
]);
|
|
59
61
|
|
|
62
|
+
const valueArtifact = artifacts.find((a) =>
|
|
63
|
+
a.path.endsWith('sellOfferTermValue.js')
|
|
64
|
+
);
|
|
65
|
+
assert.match(valueArtifact.content, /"objectType": "sellOfferTermValue"/);
|
|
66
|
+
assert.match(valueArtifact.content, /"sellOfferTermValueId"/);
|
|
67
|
+
|
|
60
68
|
for (const artifact of artifacts) {
|
|
61
69
|
assert.doesNotMatch(artifact.content, /dynamoDB/);
|
|
62
70
|
assert.match(artifact.content, /GraphHandler/);
|
|
@@ -101,6 +109,31 @@ test('emitAttributeTreeRelationshipSchemas returns 4 relationship schemas per at
|
|
|
101
109
|
'app/src/schemas/RelationshipSchemas/generatedAttributeTree/isSellOfferTermLabel.js'
|
|
102
110
|
]);
|
|
103
111
|
|
|
112
|
+
const hasRel = artifacts.find((a) => a.path.endsWith('hasSellOfferTermLink.js'));
|
|
113
|
+
assert.match(hasRel.content, /"generatedBy": "user"/);
|
|
114
|
+
assert.match(hasRel.content, /"requiredOnCreate": true/);
|
|
115
|
+
|
|
116
|
+
const disabledRel = artifacts.find((a) =>
|
|
117
|
+
a.path.endsWith('disabledSellOfferTermLink.js')
|
|
118
|
+
);
|
|
119
|
+
assert.match(disabledRel.content, /"generatedBy": "user"/);
|
|
120
|
+
|
|
121
|
+
const isRel = artifacts.find((a) => a.path.endsWith('isSellOfferTerm.js'));
|
|
122
|
+
assert.match(isRel.content, /"generatedBy": "systemNoUser"/);
|
|
123
|
+
assert.match(isRel.content, /"objectType": "sellOfferTermValue"/);
|
|
124
|
+
assert.match(isRel.content, /"requiredOnCreate": true/);
|
|
125
|
+
|
|
126
|
+
const isLabelRel = artifacts.find((a) =>
|
|
127
|
+
a.path.endsWith('isSellOfferTermLabel.js')
|
|
128
|
+
);
|
|
129
|
+
assert.match(isLabelRel.content, /"generatedBy": "systemNoUser"/);
|
|
130
|
+
assert.match(isLabelRel.content, /"requiredOnCreate": true/);
|
|
131
|
+
// from objType should be sellOfferTermValue
|
|
132
|
+
assert.match(
|
|
133
|
+
isLabelRel.content,
|
|
134
|
+
/"from":\s*\{\s*"objType":\s*\{[^}]*"objectType": "sellOfferTermValue"/
|
|
135
|
+
);
|
|
136
|
+
|
|
104
137
|
for (const artifact of artifacts) {
|
|
105
138
|
assert.doesNotMatch(artifact.content, /dynamoDB/);
|
|
106
139
|
assert.match(artifact.content, /GraphHandler/);
|
|
@@ -117,23 +150,19 @@ test('managed paths return empty array when no attributeTree is present', () =>
|
|
|
117
150
|
|
|
118
151
|
test('generate commits and cleans up attributeTree dynamic schemas', async () => {
|
|
119
152
|
const rootPath = await createProjectWithAttributeTree({ hasAddOn: true });
|
|
120
|
-
|
|
153
|
+
await generate(rootPath);
|
|
121
154
|
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const expectedRelPath = join(
|
|
127
|
-
rootPath,
|
|
128
|
-
'app/src/schemas/RelationshipSchemas/generatedAttributeTree/hasSellOfferTermLink.js'
|
|
129
|
-
);
|
|
155
|
+
const objectRelPath =
|
|
156
|
+
'app/src/schemas/ObjectSchemas/generatedAttributeTree/sellOfferTermLink.js';
|
|
157
|
+
const relRelPath =
|
|
158
|
+
'app/src/schemas/RelationshipSchemas/generatedAttributeTree/hasSellOfferTermLink.js';
|
|
130
159
|
|
|
131
|
-
const objectContent = await
|
|
160
|
+
const objectContent = await readProjectFile(rootPath, objectRelPath);
|
|
132
161
|
assert.match(objectContent, /sellOfferTermLink/);
|
|
133
162
|
assert.match(objectContent, /GraphHandler/);
|
|
134
163
|
assert.doesNotMatch(objectContent, /dynamoDB/);
|
|
135
164
|
|
|
136
|
-
const relContent = await
|
|
165
|
+
const relContent = await readProjectFile(rootPath, relRelPath);
|
|
137
166
|
assert.match(relContent, /hasSellOfferTermLink/);
|
|
138
167
|
assert.match(relContent, /sellOfferTermLink/);
|
|
139
168
|
|
|
@@ -141,10 +170,10 @@ test('generate commits and cleans up attributeTree dynamic schemas', async () =>
|
|
|
141
170
|
await createProjectWithAttributeTree({ rootPath, hasAddOn: false });
|
|
142
171
|
await generate(rootPath);
|
|
143
172
|
|
|
144
|
-
await assert.rejects(
|
|
173
|
+
await assert.rejects(readProjectFile(rootPath, objectRelPath), {
|
|
145
174
|
code: 'ENOENT'
|
|
146
175
|
});
|
|
147
|
-
await assert.rejects(
|
|
176
|
+
await assert.rejects(readProjectFile(rootPath, relRelPath), {
|
|
148
177
|
code: 'ENOENT'
|
|
149
178
|
});
|
|
150
179
|
});
|
|
@@ -153,21 +182,6 @@ async function createProjectWithAttributeTree({
|
|
|
153
182
|
rootPath: existingRoot,
|
|
154
183
|
hasAddOn = true
|
|
155
184
|
} = {}) {
|
|
156
|
-
const rootPath =
|
|
157
|
-
existingRoot || (await mkdtemp(join(tmpdir(), 'izara-attr-tree-test-')));
|
|
158
|
-
projectRoots.add(rootPath);
|
|
159
|
-
|
|
160
|
-
const schemaRoot = join(rootPath, 'app/src/schemas');
|
|
161
|
-
await mkdir(join(schemaRoot, 'ObjectSchemas'), { recursive: true });
|
|
162
|
-
await mkdir(join(schemaRoot, 'RelationshipSchemas'), { recursive: true });
|
|
163
|
-
await mkdir(join(schemaRoot, 'FlowSchemas'), { recursive: true });
|
|
164
|
-
await mkdir(join(rootPath, 'config'), { recursive: true });
|
|
165
|
-
|
|
166
|
-
await writeFile(
|
|
167
|
-
join(rootPath, 'config/serverless.config.yml'),
|
|
168
|
-
'service: SellOfferManager\ncustom:\n serviceTag: SellOfferManager\n'
|
|
169
|
-
);
|
|
170
|
-
|
|
171
185
|
const addOnContent = hasAddOn
|
|
172
186
|
? `
|
|
173
187
|
addOnDataStructure: [
|
|
@@ -178,9 +192,7 @@ async function createProjectWithAttributeTree({
|
|
|
178
192
|
],`
|
|
179
193
|
: ' addOnDataStructure: [],';
|
|
180
194
|
|
|
181
|
-
|
|
182
|
-
join(schemaRoot, 'ObjectSchemas/SellOffer.js'),
|
|
183
|
-
`export default [
|
|
195
|
+
const schemaContent = `export default [
|
|
184
196
|
{
|
|
185
197
|
objectType: 'sellOffer',
|
|
186
198
|
canDelete: false,
|
|
@@ -212,8 +224,73 @@ async function createProjectWithAttributeTree({
|
|
|
212
224
|
]
|
|
213
225
|
}
|
|
214
226
|
];
|
|
215
|
-
|
|
216
|
-
|
|
227
|
+
`;
|
|
228
|
+
|
|
229
|
+
if (existingRoot) {
|
|
230
|
+
await writeProjectFile(
|
|
231
|
+
existingRoot,
|
|
232
|
+
'app/src/schemas/ObjectSchemas/SellOffer.js',
|
|
233
|
+
schemaContent
|
|
234
|
+
);
|
|
235
|
+
return existingRoot;
|
|
236
|
+
}
|
|
217
237
|
|
|
218
|
-
return
|
|
238
|
+
return await createTestProject({
|
|
239
|
+
prefix: 'izara-attr-tree-test-',
|
|
240
|
+
serviceTag: 'SellOfferManager',
|
|
241
|
+
schemas: {
|
|
242
|
+
'ObjectSchemas/SellOffer.js': schemaContent
|
|
243
|
+
}
|
|
244
|
+
});
|
|
219
245
|
}
|
|
246
|
+
|
|
247
|
+
test('resolveTargetServicePath prioritizes dev suffix and matches attributeTag', async () => {
|
|
248
|
+
const tmpRoot = trackTestProject(
|
|
249
|
+
await mkdtemp(join(tmpdir(), 'izara-services-test-'))
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
const currentServiceDir = join(
|
|
253
|
+
tmpRoot,
|
|
254
|
+
'izara-market-products-sell-offer-manager-pong'
|
|
255
|
+
);
|
|
256
|
+
const targetWithSuffix = join(
|
|
257
|
+
tmpRoot,
|
|
258
|
+
'izara-market-products-sell-offer-term-pong'
|
|
259
|
+
);
|
|
260
|
+
const targetOtherDev = join(
|
|
261
|
+
tmpRoot,
|
|
262
|
+
'izara-market-products-sell-offer-term-alice'
|
|
263
|
+
);
|
|
264
|
+
const unrelatedService = join(
|
|
265
|
+
tmpRoot,
|
|
266
|
+
'izara-market-products-cart-pong'
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
await mkdir(join(currentServiceDir, 'app/src'), { recursive: true });
|
|
270
|
+
await mkdir(join(targetWithSuffix, 'app/src'), { recursive: true });
|
|
271
|
+
await mkdir(join(targetOtherDev, 'app/src'), { recursive: true });
|
|
272
|
+
await mkdir(join(unrelatedService, 'app/src'), { recursive: true });
|
|
273
|
+
|
|
274
|
+
const resolved = resolveTargetServicePath({
|
|
275
|
+
currentServiceRoot: currentServiceDir,
|
|
276
|
+
attributeTag: 'sellOfferTerm'
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
assert.equal(resolved, targetWithSuffix);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test('emitAttributeTreeTargetSchemas produces expected standard schemas', () => {
|
|
283
|
+
const targetDir = '/dummy/path/izara-market-products-sellOfferTerm';
|
|
284
|
+
const artifacts = emitAttributeTreeTargetSchemas({
|
|
285
|
+
attributeTag: 'sellOfferTerm',
|
|
286
|
+
targetServiceRoot: targetDir
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
assert.equal(artifacts.length, 3);
|
|
290
|
+
const paths = artifacts.map((a) => a.path);
|
|
291
|
+
|
|
292
|
+
assert.ok(paths.some((p) => p.endsWith('sellOfferTermValueStandardPropertyLabel.js')));
|
|
293
|
+
assert.ok(paths.some((p) => p.endsWith('sellOfferTermValueStandardPropertyValue.js')));
|
|
294
|
+
assert.ok(paths.some((p) => p.endsWith('sellOfferTermValueStandard.js')));
|
|
295
|
+
});
|
|
296
|
+
|
|
@@ -5,8 +5,8 @@ import { join } from 'node:path';
|
|
|
5
5
|
import test from 'node:test';
|
|
6
6
|
import { pathToFileURL } from 'node:url';
|
|
7
7
|
|
|
8
|
-
import { generateDynamicCrudFlowSchemas } from '
|
|
9
|
-
import { createCrudActionPlans } from '
|
|
8
|
+
import { generateDynamicCrudFlowSchemas } from '../../../src/emit/application/crud/generateDynamicCrudFlowSchemas.js';
|
|
9
|
+
import { createCrudActionPlans } from '../../../src/emit/application/crud/crudActionPlan.js';
|
|
10
10
|
|
|
11
11
|
test('generates dynamic CRUD schemas from local schema modules', async () => {
|
|
12
12
|
const rootPath = await createProject({
|
|
@@ -5,7 +5,7 @@ import { join } from 'node:path';
|
|
|
5
5
|
import test, { after } from 'node:test';
|
|
6
6
|
import { pathToFileURL } from 'node:url';
|
|
7
7
|
|
|
8
|
-
import { generateDynamicRbacFlowSchemas } from '
|
|
8
|
+
import { generateDynamicRbacFlowSchemas } from '../../../src/emit/application/rbac/generateDynamicRbacFlowSchemas.js';
|
|
9
9
|
|
|
10
10
|
const projectRoots = new Set();
|
|
11
11
|
const STATIC_RBAC_ACTIONS = [
|
|
@@ -5,7 +5,7 @@ import { join } from 'node:path';
|
|
|
5
5
|
import test, { after } from 'node:test';
|
|
6
6
|
import { pathToFileURL } from 'node:url';
|
|
7
7
|
|
|
8
|
-
import { generateDynamicRelationshipFlowSchemas } from '
|
|
8
|
+
import { generateDynamicRelationshipFlowSchemas } from '../../../src/emit/application/relationship/generateDynamicRelationshipFlowSchemas.js';
|
|
9
9
|
|
|
10
10
|
const RELATIONSHIP_ACTIONS = [
|
|
11
11
|
'CreateRelationship',
|
|
@@ -60,6 +60,16 @@ test('generates dynamic relationship schemas when declared relationships exist',
|
|
|
60
60
|
'userId',
|
|
61
61
|
'correlationId'
|
|
62
62
|
]);
|
|
63
|
+
const completeStep = create.flowSteps.find(
|
|
64
|
+
(step) => step.stepName === 'Complete'
|
|
65
|
+
);
|
|
66
|
+
assert.deepEqual(completeStep.properties, [
|
|
67
|
+
'returnValue',
|
|
68
|
+
'parentFlowId',
|
|
69
|
+
'status',
|
|
70
|
+
'foundErrors',
|
|
71
|
+
'graphServiceTag'
|
|
72
|
+
]);
|
|
63
73
|
assert.deepEqual(get.event, [
|
|
64
74
|
'lambdaSyncInv',
|
|
65
75
|
'lambdaSyncApi',
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
emitErrorSchemas,
|
|
9
9
|
errorSchemaManagedPaths,
|
|
10
10
|
ERROR_SCHEMA_PATH
|
|
11
|
-
} from '
|
|
12
|
-
import { generate } from '
|
|
11
|
+
} from '../../../src/emit/schemas/error/emitErrorSchemas.js';
|
|
12
|
+
import { generate } from '../../../src/generate.js';
|
|
13
13
|
|
|
14
14
|
const roots = new Set();
|
|
15
15
|
after(() =>
|
|
@@ -0,0 +1,263 @@
|
|
|
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', () => {
|
|
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 = 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', () => {
|
|
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 = 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
|
+
|
|
161
|
+
test('managed paths return empty array when no ledger is present', () => {
|
|
162
|
+
const objects = [{ objectType: 'user', addOnDataStructure: [] }];
|
|
163
|
+
assert.deepEqual(ledgerObjectSchemaManagedPaths(objects), []);
|
|
164
|
+
assert.deepEqual(ledgerRelationshipSchemaManagedPaths(objects), []);
|
|
165
|
+
assert.deepEqual(emitLedgerObjectSchemas({ objects }), []);
|
|
166
|
+
assert.deepEqual(emitLedgerRelationshipSchemas({ objects }), []);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test('generate commits and cleans up ledger dynamic schemas', async () => {
|
|
170
|
+
const rootPath = await createProjectWithLedger({ hasAddOn: true });
|
|
171
|
+
await generate(rootPath);
|
|
172
|
+
|
|
173
|
+
const objectRelPath =
|
|
174
|
+
'app/src/schemas/ObjectSchemas/generatedLedger/unitStandardSupplyLocationEntry.js';
|
|
175
|
+
const relRelPath =
|
|
176
|
+
'app/src/schemas/RelationshipSchemas/generatedLedger/currentUnitStandardSupplyLocation.js';
|
|
177
|
+
|
|
178
|
+
const objectContent = await readProjectFile(rootPath, objectRelPath);
|
|
179
|
+
assert.match(objectContent, /unitStandardSupplyLocationEntry/);
|
|
180
|
+
assert.match(objectContent, /GraphHandler/);
|
|
181
|
+
|
|
182
|
+
const relContent = await readProjectFile(rootPath, relRelPath);
|
|
183
|
+
assert.match(relContent, /currentUnitStandardSupplyLocation/);
|
|
184
|
+
assert.match(relContent, /oldUnitStandardSupplyLocation/);
|
|
185
|
+
|
|
186
|
+
// Re-run without addOn to verify stale file cleanup
|
|
187
|
+
await createProjectWithLedger({ rootPath, hasAddOn: false });
|
|
188
|
+
await generate(rootPath);
|
|
189
|
+
|
|
190
|
+
await assert.rejects(readProjectFile(rootPath, objectRelPath), {
|
|
191
|
+
code: 'ENOENT'
|
|
192
|
+
});
|
|
193
|
+
await assert.rejects(readProjectFile(rootPath, relRelPath), {
|
|
194
|
+
code: 'ENOENT'
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
async function createProjectWithLedger({
|
|
199
|
+
rootPath: existingRoot,
|
|
200
|
+
hasAddOn = true
|
|
201
|
+
} = {}) {
|
|
202
|
+
const addOnContent = hasAddOn
|
|
203
|
+
? `
|
|
204
|
+
addOnDataStructure: [
|
|
205
|
+
{
|
|
206
|
+
type: 'ledger',
|
|
207
|
+
prefix: 'unitStandardSupplyLocation',
|
|
208
|
+
storageResourceTag: 'graph',
|
|
209
|
+
ledgerType: 'movable',
|
|
210
|
+
targetObjType: {
|
|
211
|
+
serviceTag: 'SupplyLocationStandard',
|
|
212
|
+
objectType: 'supplyLocation'
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
],`
|
|
216
|
+
: ' addOnDataStructure: [],';
|
|
217
|
+
|
|
218
|
+
const schemaContent = `export default [
|
|
219
|
+
{
|
|
220
|
+
objectType: 'unitStandard',
|
|
221
|
+
canDelete: false,
|
|
222
|
+
generatedBy: 'user',${addOnContent}
|
|
223
|
+
storageResources: {
|
|
224
|
+
graph: {
|
|
225
|
+
storageType: 'graph',
|
|
226
|
+
graphServerTag: 'GraphHandler'
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
fieldNames: {
|
|
230
|
+
unitId: {
|
|
231
|
+
type: 'string',
|
|
232
|
+
randomOnCreate: true,
|
|
233
|
+
canUpdate: false,
|
|
234
|
+
storageResourceTags: ['graph']
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
identifiers: [
|
|
238
|
+
{
|
|
239
|
+
type: 'partitionKey',
|
|
240
|
+
fieldName: 'unitId'
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
];
|
|
245
|
+
`;
|
|
246
|
+
|
|
247
|
+
if (existingRoot) {
|
|
248
|
+
await writeProjectFile(
|
|
249
|
+
existingRoot,
|
|
250
|
+
'app/src/schemas/ObjectSchemas/UnitStandard.js',
|
|
251
|
+
schemaContent
|
|
252
|
+
);
|
|
253
|
+
return existingRoot;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return await createTestProject({
|
|
257
|
+
prefix: 'izara-ledger-test-',
|
|
258
|
+
serviceTag: 'UnitStandard',
|
|
259
|
+
schemas: {
|
|
260
|
+
'ObjectSchemas/UnitStandard.js': schemaContent
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
@@ -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"/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|