@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
package/index.js
CHANGED
|
@@ -16,8 +16,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { generate } from './src/generate.js';
|
|
19
|
-
import { generateIntTest } from './src/generateIntTest.js';
|
|
20
|
-
import { generateResourceIntTest } from './src/generateResourceIntTest.js';
|
|
19
|
+
import { generateIntTest } from './src/intTest/generateIntTest.js';
|
|
20
|
+
import { generateResourceIntTest } from './src/intTest/generateResourceIntTest.js';
|
|
21
21
|
|
|
22
22
|
export {
|
|
23
23
|
// High-level API (recommended for consumers) — wires legacy Logger+validateLocalSchema
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-generate-service-code",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.98",
|
|
4
4
|
"description": "Code for locally generating per service files",
|
|
5
5
|
"homepage": "https://bitbucket.org/izara-core-support-services/izara-core-support-services-generate-service-code#readme",
|
|
6
6
|
"repository": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@izara_project/izara-attribute-tree": "^1.0.15",
|
|
21
21
|
"@izara_project/izara-core-library-core": "^1.0.37",
|
|
22
|
+
"@izara_project/izara-core-library-ledger": "^1.0.2",
|
|
22
23
|
"@izara_project/izara-core-library-s3": "^1.0.12",
|
|
23
24
|
"@izara_project/izara-property-nodes": "^1.0.16",
|
|
24
25
|
"@izara_project/izara-shared-core": "^1.0.13",
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { readdir, stat } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
|
-
import {
|
|
5
|
-
getObjectSchema,
|
|
6
|
-
utils
|
|
7
|
-
} from '@izara_project/izara-core-library-service-schemas';
|
|
8
|
-
import { basicValidatorSchema } from '@izara_project/izara-shared-service-schemas';
|
|
9
|
-
import { s3 } from '@izara_project/izara-core-library-s3';
|
|
4
|
+
import { utils } from '@izara_project/izara-core-library-service-schemas';
|
|
10
5
|
import { validateFlowSchema } from './flowValidator.js';
|
|
6
|
+
import {
|
|
7
|
+
ensureBasicValidatorConfigured,
|
|
8
|
+
VALID_INITIATE_BY_ENUM,
|
|
9
|
+
VALID_EVENT_ENUM,
|
|
10
|
+
VALID_CODE_HOOK_TAG_ENUM,
|
|
11
|
+
VALID_GENERATE_CODE_TAG_ENUM,
|
|
12
|
+
VALID_INVOCATION_TYPE_ENUM,
|
|
13
|
+
VALID_GENERATED_BY_ENUM
|
|
14
|
+
} from './schemaValidatorSetup.js';
|
|
15
|
+
import {
|
|
16
|
+
resolveExtendedObjectSchemas,
|
|
17
|
+
resolveGraphServiceTags
|
|
18
|
+
} from './loadSchemasRemote.js';
|
|
19
|
+
|
|
20
|
+
ensureBasicValidatorConfigured();
|
|
11
21
|
|
|
12
22
|
const consoleLogger = {
|
|
13
23
|
debug: console.log,
|
|
@@ -16,130 +26,10 @@ const consoleLogger = {
|
|
|
16
26
|
error: console.error
|
|
17
27
|
};
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
const VALID_EVENT_ENUM = [
|
|
21
|
-
'ownTopic',
|
|
22
|
-
'extTopic',
|
|
23
|
-
's3',
|
|
24
|
-
'eventBridge',
|
|
25
|
-
'lambdaSyncInv',
|
|
26
|
-
'lambdaSyncApi',
|
|
27
|
-
'dsq',
|
|
28
|
-
'generateCode'
|
|
29
|
-
];
|
|
30
|
-
const VALID_CODE_HOOK_TAG_ENUM = ['before', 'after'];
|
|
31
|
-
const VALID_GENERATE_CODE_TAG_ENUM = ['create', 'update', 'delete'];
|
|
32
|
-
const VALID_INVOCATION_TYPE_ENUM = ['ownTopic', 'lambdaSyncInv'];
|
|
33
|
-
|
|
34
|
-
if (basicValidatorSchema?.basicFlowSchema?.properties?.initiateBy) {
|
|
35
|
-
basicValidatorSchema.basicFlowSchema.properties.initiateBy.enum =
|
|
36
|
-
VALID_INITIATE_BY_ENUM;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (basicValidatorSchema?.basicFlowSchema?.properties?.event?.items) {
|
|
40
|
-
basicValidatorSchema.basicFlowSchema.properties.event.items.enum =
|
|
41
|
-
VALID_EVENT_ENUM;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
basicValidatorSchema?.basicFlowSchema?.properties?.generatedCodeConfig
|
|
46
|
-
?.properties?.codeHookTag
|
|
47
|
-
) {
|
|
48
|
-
basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.codeHookTag.enum =
|
|
49
|
-
VALID_CODE_HOOK_TAG_ENUM;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
basicValidatorSchema?.basicFlowSchema?.properties?.generatedCodeConfig
|
|
54
|
-
?.properties?.invocationType
|
|
55
|
-
) {
|
|
56
|
-
basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.invocationType.enum =
|
|
57
|
-
VALID_INVOCATION_TYPE_ENUM;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
basicValidatorSchema?.basicFlowSchema?.properties?.generatedCodeConfig
|
|
62
|
-
?.properties?.generateCodeTag
|
|
63
|
-
) {
|
|
64
|
-
basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.generateCodeTag =
|
|
65
|
-
{
|
|
66
|
-
anyOf: [
|
|
67
|
-
{
|
|
68
|
-
type: 'array',
|
|
69
|
-
items: {
|
|
70
|
-
type: 'string',
|
|
71
|
-
enum: VALID_GENERATE_CODE_TAG_ENUM
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
type: 'string',
|
|
76
|
-
enum: VALID_GENERATE_CODE_TAG_ENUM
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
basicValidatorSchema?.basicFlowSchema?.properties?.generatedCodeConfig
|
|
84
|
-
?.properties
|
|
85
|
-
) {
|
|
86
|
-
basicValidatorSchema.basicFlowSchema.properties.generatedCodeConfig.properties.objType =
|
|
87
|
-
{
|
|
88
|
-
anyOf: [
|
|
89
|
-
{ type: 'string' },
|
|
90
|
-
{
|
|
91
|
-
type: 'array',
|
|
92
|
-
items: { type: 'string' }
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
type: 'object',
|
|
96
|
-
properties: {
|
|
97
|
-
objectType: { type: 'string' },
|
|
98
|
-
serviceTag: { type: 'string' }
|
|
99
|
-
},
|
|
100
|
-
required: ['objectType']
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const VALID_GENERATED_BY_ENUM = [
|
|
107
|
-
'user',
|
|
108
|
-
'systemWithUser',
|
|
109
|
-
'systemNoUser',
|
|
110
|
-
'searchResultGenerated'
|
|
111
|
-
];
|
|
112
|
-
|
|
113
|
-
if (basicValidatorSchema?.basicObjectSchema?.properties?.generatedBy) {
|
|
114
|
-
basicValidatorSchema.basicObjectSchema.properties.generatedBy.enum =
|
|
115
|
-
VALID_GENERATED_BY_ENUM;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (basicValidatorSchema?.basicExtendObjectSchema?.properties?.generatedBy) {
|
|
119
|
-
basicValidatorSchema.basicExtendObjectSchema.properties.generatedBy.enum =
|
|
120
|
-
VALID_GENERATED_BY_ENUM;
|
|
121
|
-
}
|
|
29
|
+
export { resolveExtendedObjectSchemas, resolveGraphServiceTags };
|
|
122
30
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
basicValidatorSchema?.basicExtendObjectSchema
|
|
126
|
-
];
|
|
127
|
-
|
|
128
|
-
for (const objSchema of objectSchemasToPatch) {
|
|
129
|
-
const addOnItems = objSchema?.properties?.addOnDataStructure?.items?.anyOf;
|
|
130
|
-
if (Array.isArray(addOnItems)) {
|
|
131
|
-
for (const item of addOnItems) {
|
|
132
|
-
if (item?.properties?.type?.enum?.includes('rbac')) {
|
|
133
|
-
if (item.properties.billalble) {
|
|
134
|
-
delete item.properties.billalble;
|
|
135
|
-
}
|
|
136
|
-
item.properties.billable = { type: 'boolean' };
|
|
137
|
-
if (Array.isArray(item.required)) {
|
|
138
|
-
item.required = item.required.filter((r) => r !== 'billalble');
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
31
|
+
export async function loadGenerateDirectives(project, options = {}) {
|
|
32
|
+
return loadLocalSchemaDirectory(project, 'GenerateDirectives', options);
|
|
143
33
|
}
|
|
144
34
|
|
|
145
35
|
export async function loadLocalSchemaDirectory(
|
|
@@ -151,7 +41,10 @@ export async function loadLocalSchemaDirectory(
|
|
|
151
41
|
const logger = options.logger || consoleLogger;
|
|
152
42
|
let entries;
|
|
153
43
|
try {
|
|
154
|
-
entries = await readdir(directoryPath, {
|
|
44
|
+
entries = await readdir(directoryPath, {
|
|
45
|
+
recursive: true,
|
|
46
|
+
withFileTypes: true
|
|
47
|
+
});
|
|
155
48
|
} catch (error) {
|
|
156
49
|
if (error.code === 'ENOENT') {
|
|
157
50
|
return [];
|
|
@@ -159,14 +52,30 @@ export async function loadLocalSchemaDirectory(
|
|
|
159
52
|
throw error;
|
|
160
53
|
}
|
|
161
54
|
|
|
162
|
-
const validEntries = entries.filter(
|
|
163
|
-
(entry
|
|
164
|
-
|
|
165
|
-
|
|
55
|
+
const validEntries = entries.filter((entry) => {
|
|
56
|
+
if (!entry.isFile() || !entry.name.endsWith('.js')) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (directoryName === 'FlowSchemas') {
|
|
60
|
+
const parentDir = entry.parentPath || entry.path || '';
|
|
61
|
+
if (parentDir.includes('generateCode')) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
});
|
|
67
|
+
validEntries.sort((a, b) => {
|
|
68
|
+
const aParent = a.parentPath || a.path || directoryPath;
|
|
69
|
+
const bParent = b.parentPath || b.path || directoryPath;
|
|
70
|
+
const aPath = join(aParent, a.name);
|
|
71
|
+
const bPath = join(bParent, b.name);
|
|
72
|
+
return aPath.localeCompare(bPath);
|
|
73
|
+
});
|
|
166
74
|
|
|
167
75
|
const schemas = [];
|
|
168
76
|
for (const entry of validEntries) {
|
|
169
|
-
const
|
|
77
|
+
const parentDir = entry.parentPath || entry.path || directoryPath;
|
|
78
|
+
const filePath = join(parentDir, entry.name);
|
|
170
79
|
const details = await stat(filePath);
|
|
171
80
|
const module = await import(
|
|
172
81
|
`${pathToFileURL(filePath).href}?schemaVersion=${details.mtimeMs}-${details.size}`
|
|
@@ -654,194 +563,7 @@ export async function loadLocalSchemaArrays(project, options = {}) {
|
|
|
654
563
|
return { objects, flows };
|
|
655
564
|
}
|
|
656
565
|
|
|
657
|
-
/**
|
|
658
|
-
* Resolves extendObjType for ObjectSchemas by fetching the parent schema
|
|
659
|
-
* from S3 and merging its storageResources into the child schema.
|
|
660
|
-
*
|
|
661
|
-
* Only schemas with `extendObjType` are processed; others are returned as-is.
|
|
662
|
-
* If `bucketName` is not provided, falls back to the
|
|
663
|
-
* `iz_serviceSchemaBucketName` environment variable.
|
|
664
|
-
*
|
|
665
|
-
* @param {Object[]} objectSchemas - Array of local ObjectSchemas from
|
|
666
|
-
* loadLocalSchemaDirectory.
|
|
667
|
-
* @param {string} [bucketName] - S3 bucket name for fetching parent schemas.
|
|
668
|
-
* @returns {Promise<Object[]>} The same array with extended storageResources
|
|
669
|
-
* merged in.
|
|
670
|
-
*/
|
|
671
|
-
export async function resolveExtendedObjectSchemas(
|
|
672
|
-
objectSchemas,
|
|
673
|
-
bucketName = process.env.iz_serviceSchemaBucketName
|
|
674
|
-
) {
|
|
675
|
-
if (!Array.isArray(objectSchemas)) {
|
|
676
|
-
throw new TypeError('objectSchemas must be an array');
|
|
677
|
-
}
|
|
678
|
-
const resolvedSchemas = [];
|
|
679
|
-
for (const schema of objectSchemas) {
|
|
680
|
-
let currentSchema = schema;
|
|
681
|
-
if (currentSchema.hasOwnProperty('extendObjType')) {
|
|
682
|
-
try {
|
|
683
|
-
console.log(
|
|
684
|
-
`[DEBUG] [resolveExtendedObjectSchemas] Merging extendObjType ` +
|
|
685
|
-
`for objectType=${currentSchema.objectType}`,
|
|
686
|
-
{ extendObjType: currentSchema.extendObjType }
|
|
687
|
-
);
|
|
688
|
-
const initialResources = currentSchema.storageResources || {};
|
|
689
|
-
const childStorageResourceKeys = new Set(Object.keys(initialResources));
|
|
690
|
-
const parentServiceTag = currentSchema.extendObjType.serviceTag;
|
|
691
|
-
|
|
692
|
-
const mergedSchema = await getObjectSchema.mergeExtendObjSchema(
|
|
693
|
-
{ logger: consoleLogger },
|
|
694
|
-
currentSchema,
|
|
695
|
-
bucketName
|
|
696
|
-
);
|
|
697
566
|
|
|
698
|
-
const externalDynamoResources = [];
|
|
699
|
-
const ownStorageResources = {};
|
|
700
|
-
const mergedStorageResources = mergedSchema.storageResources || {};
|
|
701
|
-
for (const [key, resource] of Object.entries(mergedStorageResources)) {
|
|
702
|
-
if (
|
|
703
|
-
resource &&
|
|
704
|
-
(resource.storageType === 'dynamo' ||
|
|
705
|
-
resource.storageType === 'dynamoDB' ||
|
|
706
|
-
!resource.storageType) &&
|
|
707
|
-
!childStorageResourceKeys.has(key)
|
|
708
|
-
) {
|
|
709
|
-
externalDynamoResources.push({
|
|
710
|
-
serviceTag: parentServiceTag,
|
|
711
|
-
tableName: resource.tableName
|
|
712
|
-
});
|
|
713
|
-
} else {
|
|
714
|
-
ownStorageResources[key] = resource;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
mergedSchema.storageResources = ownStorageResources;
|
|
719
|
-
if (externalDynamoResources.length > 0) {
|
|
720
|
-
mergedSchema.externalDynamoResources = externalDynamoResources;
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
currentSchema = mergedSchema;
|
|
724
|
-
} catch (error) {
|
|
725
|
-
console.log(
|
|
726
|
-
`[ERROR] [resolveExtendedObjectSchemas] Failed to merge ` +
|
|
727
|
-
`extendObjType for objectType=${currentSchema.objectType}`,
|
|
728
|
-
{ error }
|
|
729
|
-
);
|
|
730
|
-
throw error;
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
if (currentSchema.hasOwnProperty('belongTo') && currentSchema.belongTo) {
|
|
735
|
-
const belongToTarget = Array.isArray(currentSchema.belongTo)
|
|
736
|
-
? currentSchema.belongTo[0]
|
|
737
|
-
: currentSchema.belongTo;
|
|
738
|
-
|
|
739
|
-
if (
|
|
740
|
-
belongToTarget &&
|
|
741
|
-
belongToTarget.serviceTag &&
|
|
742
|
-
belongToTarget.objectType
|
|
743
|
-
) {
|
|
744
|
-
try {
|
|
745
|
-
console.log(
|
|
746
|
-
`[DEBUG] [resolveExtendedObjectSchemas] Fetching belongTo ` +
|
|
747
|
-
`schema for objectType=${currentSchema.objectType}`,
|
|
748
|
-
{ belongTo: belongToTarget }
|
|
749
|
-
);
|
|
750
|
-
const belongToObjType = {
|
|
751
|
-
serviceTag: belongToTarget.serviceTag,
|
|
752
|
-
objectType: belongToTarget.objectType
|
|
753
|
-
};
|
|
754
|
-
const belongToSchema = await getObjectSchema.getObjSchemaS3(
|
|
755
|
-
{ logger: consoleLogger },
|
|
756
|
-
belongToObjType,
|
|
757
|
-
false,
|
|
758
|
-
bucketName
|
|
759
|
-
);
|
|
760
|
-
currentSchema.belongToSchema = belongToSchema;
|
|
761
|
-
console.log(
|
|
762
|
-
`[DEBUG] [resolveExtendedObjectSchemas] Successfully fetched ` +
|
|
763
|
-
`belongTo schema for objectType=${currentSchema.objectType}`,
|
|
764
|
-
{ belongToObjectType: belongToSchema?.objectType }
|
|
765
|
-
);
|
|
766
|
-
} catch (error) {
|
|
767
|
-
console.log(
|
|
768
|
-
`[WARN] [resolveExtendedObjectSchemas] Failed to fetch ` +
|
|
769
|
-
`belongTo schema for objectType=${currentSchema.objectType}`,
|
|
770
|
-
{ error }
|
|
771
|
-
);
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
resolvedSchemas.push(currentSchema);
|
|
777
|
-
}
|
|
778
|
-
return resolvedSchemas;
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
export async function resolveGraphServiceTags(
|
|
782
|
-
schemas,
|
|
783
|
-
bucketName = process.env.iz_serviceSchemaBucketName
|
|
784
|
-
) {
|
|
785
|
-
if (!Array.isArray(schemas) || schemas.length === 0) {
|
|
786
|
-
return [];
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
const graphServerTags = new Set();
|
|
790
|
-
for (const schema of schemas) {
|
|
791
|
-
if (!schema || typeof schema !== 'object') continue;
|
|
792
|
-
let targetObjs = [];
|
|
793
|
-
if (schema.storageResources) {
|
|
794
|
-
targetObjs = [schema];
|
|
795
|
-
} else {
|
|
796
|
-
targetObjs = Object.values(schema).filter(
|
|
797
|
-
(val) => val && typeof val === 'object' && val.storageResources
|
|
798
|
-
);
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
for (const targetObj of targetObjs) {
|
|
802
|
-
const resources = targetObj.storageResources;
|
|
803
|
-
if (resources && typeof resources === 'object') {
|
|
804
|
-
for (const res of Object.values(resources)) {
|
|
805
|
-
if (res?.storageType === 'graph' && res.graphServerTag) {
|
|
806
|
-
graphServerTags.add(res.graphServerTag);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
if (graphServerTags.size === 0) {
|
|
814
|
-
return [];
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
let graphServerTagsMap = {};
|
|
818
|
-
if (bucketName) {
|
|
819
|
-
try {
|
|
820
|
-
const _izContext = { logger: consoleLogger };
|
|
821
|
-
const s3Data = await s3.getObjectS3(_izContext, {
|
|
822
|
-
Bucket: bucketName,
|
|
823
|
-
Key: 'serviceConfig/GraphServerTags.json'
|
|
824
|
-
});
|
|
825
|
-
if (s3Data && typeof s3Data === 'object') {
|
|
826
|
-
graphServerTagsMap = s3Data;
|
|
827
|
-
}
|
|
828
|
-
} catch (error) {
|
|
829
|
-
console.log(
|
|
830
|
-
`[DEBUG] [resolveGraphServiceTags] Could not fetch ` +
|
|
831
|
-
`GraphServerTags.json from bucket=${bucketName}`,
|
|
832
|
-
error
|
|
833
|
-
);
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
const resolvedTags = new Set();
|
|
838
|
-
for (const tag of graphServerTags) {
|
|
839
|
-
const serviceTag = graphServerTagsMap[tag] || tag || 'GraphHandler';
|
|
840
|
-
resolvedTags.add(serviceTag);
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
return Array.from(resolvedTags);
|
|
844
|
-
}
|
|
845
567
|
|
|
846
568
|
function _isTestEnvironment() {
|
|
847
569
|
return (
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getObjectSchema
|
|
3
|
+
} from '@izara_project/izara-core-library-service-schemas';
|
|
4
|
+
import { s3 } from '@izara_project/izara-core-library-s3';
|
|
5
|
+
|
|
6
|
+
const consoleLogger = {
|
|
7
|
+
debug: console.log,
|
|
8
|
+
info: console.log,
|
|
9
|
+
warn: console.log,
|
|
10
|
+
error: console.error
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Resolves extendObjType for ObjectSchemas by fetching the parent schema
|
|
15
|
+
* from S3 and merging its storageResources into the child schema.
|
|
16
|
+
*
|
|
17
|
+
* @param {Object[]} objectSchemas - Array of local ObjectSchemas.
|
|
18
|
+
* @param {string} [bucketName] - S3 bucket name for fetching parent schemas.
|
|
19
|
+
* @returns {Promise<Object[]>} The same array with extended storageResources.
|
|
20
|
+
*/
|
|
21
|
+
export async function resolveExtendedObjectSchemas(
|
|
22
|
+
objectSchemas,
|
|
23
|
+
bucketName = process.env.iz_serviceSchemaBucketName
|
|
24
|
+
) {
|
|
25
|
+
if (!Array.isArray(objectSchemas)) {
|
|
26
|
+
throw new TypeError('objectSchemas must be an array');
|
|
27
|
+
}
|
|
28
|
+
const resolvedSchemas = [];
|
|
29
|
+
for (const schema of objectSchemas) {
|
|
30
|
+
let currentSchema = schema;
|
|
31
|
+
if (currentSchema.hasOwnProperty('extendObjType')) {
|
|
32
|
+
try {
|
|
33
|
+
console.log(
|
|
34
|
+
`[DEBUG] [resolveExtendedObjectSchemas] Merging extendObjType ` +
|
|
35
|
+
`for objectType=${currentSchema.objectType}`,
|
|
36
|
+
{ extendObjType: currentSchema.extendObjType }
|
|
37
|
+
);
|
|
38
|
+
const initialResources = currentSchema.storageResources || {};
|
|
39
|
+
const childStorageResourceKeys = new Set(Object.keys(initialResources));
|
|
40
|
+
const parentServiceTag = currentSchema.extendObjType.serviceTag;
|
|
41
|
+
|
|
42
|
+
const mergedSchema = await getObjectSchema.mergeExtendObjSchema(
|
|
43
|
+
{ logger: consoleLogger },
|
|
44
|
+
currentSchema,
|
|
45
|
+
bucketName
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const externalDynamoResources = [];
|
|
49
|
+
const ownStorageResources = {};
|
|
50
|
+
const mergedStorageResources = mergedSchema.storageResources || {};
|
|
51
|
+
for (const [key, resource] of Object.entries(mergedStorageResources)) {
|
|
52
|
+
if (
|
|
53
|
+
resource &&
|
|
54
|
+
(resource.storageType === 'dynamo' ||
|
|
55
|
+
resource.storageType === 'dynamoDB' ||
|
|
56
|
+
!resource.storageType) &&
|
|
57
|
+
!childStorageResourceKeys.has(key)
|
|
58
|
+
) {
|
|
59
|
+
externalDynamoResources.push({
|
|
60
|
+
serviceTag: parentServiceTag,
|
|
61
|
+
tableName: resource.tableName
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
ownStorageResources[key] = resource;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
mergedSchema.storageResources = ownStorageResources;
|
|
69
|
+
if (externalDynamoResources.length > 0) {
|
|
70
|
+
mergedSchema.externalDynamoResources = externalDynamoResources;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
currentSchema = mergedSchema;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.log(
|
|
76
|
+
`[ERROR] [resolveExtendedObjectSchemas] Failed to merge ` +
|
|
77
|
+
`extendObjType for objectType=${currentSchema.objectType}`,
|
|
78
|
+
{ error }
|
|
79
|
+
);
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (currentSchema.hasOwnProperty('belongTo') && currentSchema.belongTo) {
|
|
85
|
+
let belongToTarget = currentSchema.belongTo;
|
|
86
|
+
if (Array.isArray(currentSchema.belongTo)) {
|
|
87
|
+
belongToTarget = currentSchema.belongTo[0];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (
|
|
91
|
+
belongToTarget &&
|
|
92
|
+
belongToTarget.serviceTag &&
|
|
93
|
+
belongToTarget.objectType
|
|
94
|
+
) {
|
|
95
|
+
try {
|
|
96
|
+
console.log(
|
|
97
|
+
`[DEBUG] [resolveExtendedObjectSchemas] Fetching belongTo ` +
|
|
98
|
+
`schema for objectType=${currentSchema.objectType}`,
|
|
99
|
+
{ belongTo: belongToTarget }
|
|
100
|
+
);
|
|
101
|
+
const belongToObjType = {
|
|
102
|
+
serviceTag: belongToTarget.serviceTag,
|
|
103
|
+
objectType: belongToTarget.objectType
|
|
104
|
+
};
|
|
105
|
+
const belongToSchema = await getObjectSchema.getObjSchemaS3(
|
|
106
|
+
{ logger: consoleLogger },
|
|
107
|
+
belongToObjType,
|
|
108
|
+
false,
|
|
109
|
+
bucketName
|
|
110
|
+
);
|
|
111
|
+
currentSchema.belongToSchema = belongToSchema;
|
|
112
|
+
console.log(
|
|
113
|
+
`[DEBUG] [resolveExtendedObjectSchemas] Successfully fetched ` +
|
|
114
|
+
`belongTo schema for objectType=${currentSchema.objectType}`,
|
|
115
|
+
{ belongToObjectType: belongToSchema?.objectType }
|
|
116
|
+
);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.log(
|
|
119
|
+
`[WARN] [resolveExtendedObjectSchemas] Failed to fetch ` +
|
|
120
|
+
`belongTo schema for objectType=${currentSchema.objectType}`,
|
|
121
|
+
{ error }
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
resolvedSchemas.push(currentSchema);
|
|
128
|
+
}
|
|
129
|
+
return resolvedSchemas;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export async function resolveGraphServiceTags(
|
|
133
|
+
schemas,
|
|
134
|
+
bucketName = process.env.iz_serviceSchemaBucketName
|
|
135
|
+
) {
|
|
136
|
+
if (!Array.isArray(schemas) || schemas.length === 0) {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const graphServerTags = new Set();
|
|
141
|
+
for (const schema of schemas) {
|
|
142
|
+
if (!schema || typeof schema !== 'object') continue;
|
|
143
|
+
let targetObjs = [];
|
|
144
|
+
if (schema.storageResources) {
|
|
145
|
+
targetObjs = [schema];
|
|
146
|
+
} else {
|
|
147
|
+
targetObjs = Object.values(schema).filter(
|
|
148
|
+
(val) => val && typeof val === 'object' && val.storageResources
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
for (const targetObj of targetObjs) {
|
|
153
|
+
const resources = targetObj.storageResources;
|
|
154
|
+
if (resources && typeof resources === 'object') {
|
|
155
|
+
for (const res of Object.values(resources)) {
|
|
156
|
+
if (res?.storageType === 'graph' && res.graphServerTag) {
|
|
157
|
+
graphServerTags.add(res.graphServerTag);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (graphServerTags.size === 0) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let graphServerTagsMap = {};
|
|
169
|
+
if (bucketName) {
|
|
170
|
+
try {
|
|
171
|
+
const _izContext = { logger: consoleLogger };
|
|
172
|
+
const s3Data = await s3.getObjectS3(_izContext, {
|
|
173
|
+
Bucket: bucketName,
|
|
174
|
+
Key: 'serviceConfig/GraphServerTags.json'
|
|
175
|
+
});
|
|
176
|
+
if (s3Data && typeof s3Data === 'object') {
|
|
177
|
+
graphServerTagsMap = s3Data;
|
|
178
|
+
}
|
|
179
|
+
} catch (error) {
|
|
180
|
+
console.log(
|
|
181
|
+
`[DEBUG] [resolveGraphServiceTags] Could not fetch ` +
|
|
182
|
+
`GraphServerTags.json from bucket=${bucketName}`,
|
|
183
|
+
error
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const resolvedTags = new Set();
|
|
189
|
+
for (const tag of graphServerTags) {
|
|
190
|
+
const serviceTag = graphServerTagsMap[tag] || tag || 'GraphHandler';
|
|
191
|
+
resolvedTags.add(serviceTag);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return Array.from(resolvedTags);
|
|
195
|
+
}
|