@izara_project/izara-market-library-service-schemas 1.0.34 → 1.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/GenerateCodeLibs/src/Consts.js +2 -1
- package/src/GenerateCodeLibs/src/GenerateCodeLibs.js +5 -5
- package/src/MainLibs/src/Consts.js +43 -10
- package/src/TemplateManager/src/attributeTree/relationshipSchema/data.js +1 -1
- package/src/reStructure/GenerateCode.js +1 -0
- package/src/reStructure/SchemaConfig.js +1 -0
- package/src/reStructure/TemplateData/EndpointPerService/handler/api/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/handler/inv/template.ejs +2 -2
- package/src/reStructure/TemplateData/EndpointPerService/mainFunction/create/template.ejs +3 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/generateTemplateData.js +28 -44
- package/src/reStructure/TemplateData/attributeTreeSchema/{mainAttributeTreeSchema → mainAttributeTree}/attributeLinkTemplate.ejs +3 -7
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTree/data.js +134 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/relationshipSchema/data.js +172 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/relationshipSchema/template.ejs +7 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/data.js +123 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/data.js +57 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/handler/template.ejs +85 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/data.js +68 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/mainFunction/template.ejs +96 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/data.js +77 -0
- package/src/reStructure/TemplateData/flowSchema/CreateRecordComplete/queue/template.ejs +49 -0
- package/src/reStructure/TemplateData/flowSchema/components/websocket/connect/handler/template.ejs +4 -4
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/data.js +138 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/functionYaml/template.ejs +20 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/data.js +55 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/handler/template.ejs +83 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/data.js +55 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/complete/mainFunction/template.ejs +133 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/data.js +64 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/sns-in/template.ejs +12 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/statusFieldTemplate.ejs +19 -6
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/storedCacheTemplate.ejs +19 -2
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/data.js +76 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/subscriptionOutAll/template.ejs +13 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/data.js +142 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/functionYaml/template.ejs +18 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/data.js +64 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/handler/template.ejs +89 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/data.js +55 -0
- package/src/reStructure/TemplateData/flowSchema/createRecordByStatusType/wbs/mainFunction/template.ejs +120 -0
- package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/data.js +26 -59
- package/src/reStructure/TemplateData/flowSchema/eventBridge/functionYaml/template.ejs +3 -3
- package/src/reStructure/TemplateData/flowSchema/eventBridge/handler/inv/data.js +8 -8
- package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/data.js +11 -9
- package/src/reStructure/TemplateData/flowSchema/eventBridge/mainFunction/template.ejs +3 -3
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sns-in-sqs/data.js +3 -6
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/data.js +7 -9
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/functionYaml/template.ejs +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/sqs/mainFunction/data.js +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/data.js +8 -43
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/functionYaml/template.ejs +1 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/data.js +2 -2
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/handler/template.ejs +1 -0
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/data.js +7 -1
- package/src/reStructure/TemplateData/flowSchema/externalTopic/websocket/mainFunction/template.ejs +18 -7
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComplete/mainFunction/data.js +3 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/data.js +7 -1
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/EndpointComponent/mainFunction/template.ejs +52 -13
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaCompleteComponent/functionYaml/template.ejs +2 -0
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/data.js +1 -6
- package/src/reStructure/TemplateData/flowSchema/flowSchemaOwnTopic/FlowSchemaComponent/mainFunction/template.ejs +1 -29
- package/src/reStructure/TemplateData/flowSchema/generateTemplateData.js +67 -6
- package/src/reStructure/TemplateData/generateRole/createSharedResource.js +20 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/generateTemplateData.js +66 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/data.js +151 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/objectPropertyNodeSchema/templateObjectPropertyNodeSchema.ejs +16 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/data.js +179 -0
- package/src/reStructure/TemplateData/propertyNodeSchema/relationshipPropertyNodeSchema/templateRelationshipPropertyNodeSchema.ejs +7 -0
- package/src/reStructure/libs/ValidateAddOnDataStructure.js +62 -0
- package/src/reStructure/TemplateData/attributeTreeSchema/mainAttributeTreeSchema/data.js +0 -188
- /package/src/reStructure/TemplateData/attributeTreeSchema/{mainAttributeTreeSchema → mainAttributeTree}/request.json +0 -0
package/package.json
CHANGED
|
@@ -78,7 +78,8 @@ const TOPIC_NAME_GENERATE_CODE = {
|
|
|
78
78
|
reservedLimitComplete: "ReservedLimitComplete",
|
|
79
79
|
createPresignUrl: "CreatePresignUrl",
|
|
80
80
|
flowSchemaOwnTopicComplete: "FlowSchemaOwnTopicComplete",
|
|
81
|
-
flowSchemaOwnTopicEndpointComplete: "
|
|
81
|
+
flowSchemaOwnTopicEndpointComplete: "FlowSchemaOwnTopicEndpointComplete",
|
|
82
|
+
createRecordComplete: "CreateRecordComplete"
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
const GRAPH_HANDLER_SERVICE_NAME = {
|
|
@@ -82,11 +82,11 @@ function validateSchemaMiddleware(
|
|
|
82
82
|
middleware.setServiceSchema(
|
|
83
83
|
schemaFunctionPerAction[action],
|
|
84
84
|
explodeDataPerAction[action],
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
{
|
|
86
|
+
// objectType: objectType,
|
|
87
|
+
// specificFieldNames: setting?.specificFieldNames ? setting.specificFieldNames : [],
|
|
88
|
+
action: action
|
|
89
|
+
},
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -28,7 +28,7 @@ const { firstLetterUpperCase: upperCase } = require("./Utils")
|
|
|
28
28
|
const { getGraphServiceNameFromGraphServerTagWithCache, getGraphServiceTagWithCache } = require('@izara_project/izara-core-library-service-schemas/src/ServiceConfig');
|
|
29
29
|
|
|
30
30
|
const DEFAULT_HANDLER_PER_ACTION = {
|
|
31
|
-
[ACTIONS.create]: [HANDLER.hdrApi, HANDLER.hdrSqs],
|
|
31
|
+
[ACTIONS.create]: [HANDLER.hdrApi, HANDLER.hdrSqs, HANDLER.hdrInv],
|
|
32
32
|
[ACTIONS.update]: [HANDLER.hdrApi, HANDLER.hdrSqs],
|
|
33
33
|
[ACTIONS.get]: [HANDLER.hdrApi, HANDLER.hdrInv],
|
|
34
34
|
[ACTIONS.delete]: [HANDLER.hdrApi, HANDLER.hdrSqs]
|
|
@@ -116,22 +116,31 @@ const SOURCE_PATH = {
|
|
|
116
116
|
resourceLocationRelationshipPerAction: 'src/generatedCode/RelationshipPerAction/source/',
|
|
117
117
|
resourceLocationTranslateId: 'src/generatedCode/TranslateId/source/',
|
|
118
118
|
resourceLocationProcessLogical: "src/generatedCode/ProcessLogical/source/",
|
|
119
|
+
// ** FlowSchema
|
|
119
120
|
webSocket: "../src/generatedCode/FlowSchema/UploadS3/",
|
|
120
121
|
resourceLocationWebSocket: "src/generatedCode/FlowSchema/UploadS3/",
|
|
122
|
+
// * FlowSchema event
|
|
121
123
|
flowSchemaOwnTopic: "../src/generatedCode/FlowSchema/FlowSchemaOwnTopic/",
|
|
122
124
|
resourceLocationFlowSchemaOwnTopic: "src/generatedCode/flowSchemaOwnTopic/",
|
|
123
125
|
flowSchemaExternalTopic: "../src/generatedCode/FlowSchema/FlowSchemaExternalTopic/",
|
|
124
126
|
resourceLocationFlowSchemaExternalTopic: "src/generatedCode/flowSchemaExternalTopic/",
|
|
125
127
|
flowSchemaEventBridge: "../src/generatedCode/FlowSchema/EventBridge/",
|
|
126
128
|
resourceLocationFlowSchemaEventBridge: "src/generatedCode/FlowSchema/EventBridge/",
|
|
129
|
+
// * FlowSchema Register
|
|
130
|
+
flowSchemaRegister: "../src/generatedCode/FlowSchema/Register/",
|
|
131
|
+
resourceLocationFlowSchemaRegister: "src/generatedCode/FlowSchema/Register/",
|
|
132
|
+
|
|
127
133
|
generateCodeLib: "../src/generatedCode/libs/source/",
|
|
128
134
|
logicalFunctionHook: "../src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source/",
|
|
129
135
|
resourceLocationLogicalFunctionHook: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookLogicFunction/source",
|
|
130
136
|
generatedCodeHookFunction: "../src/generatedCode/WebSocket/source/FlowSchemaHook/HookFunctionGeneratedCode/source/",
|
|
131
137
|
resourceLocationGeneratedCodeHookFunction: "src/generatedCode/WebSocket/source/FlowSchemaHook/HookFunctionGeneratedCode/source/",
|
|
132
|
-
generatedAttributeTree: "../src/schemas/generatedCode/
|
|
138
|
+
generatedAttributeTree: "../src/schemas/generatedCode/attributeTree/",
|
|
139
|
+
generatedPropertyNode: "../src/schemas/generatedCode/propertyNode/",
|
|
133
140
|
endpointPerService: "../src/generatedCode/ActionEndpoint/source/",
|
|
134
|
-
resourceLocationHandlerEndpointPerService: "src/generatedCode/ActionEndpoint/source/"
|
|
141
|
+
resourceLocationHandlerEndpointPerService: "src/generatedCode/ActionEndpoint/source/",
|
|
142
|
+
createRecordComplete: "../src/generatedCode/CreateRecordComplete/",
|
|
143
|
+
resourceLocationCreateRecordComplete: "src/generatedCode/CreateRerordComplete/"
|
|
135
144
|
};
|
|
136
145
|
|
|
137
146
|
const DEFAULT_LAMBDA_ROLE_PER_ACTION = {
|
|
@@ -228,9 +237,11 @@ const SAVE_FILE_NAME = {
|
|
|
228
237
|
flowSchema: "flowSchema",
|
|
229
238
|
S3Bucket: "generated-s3-bucket",
|
|
230
239
|
sharedResourceYaml: "generate-SharedResource",
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
240
|
+
objectRelationship: "ObjectRelationships",
|
|
241
|
+
refObjectRelationship: "RefObjectRelationships",
|
|
242
|
+
objectSchema: "ObjectFieldSchema",
|
|
243
|
+
|
|
244
|
+
|
|
234
245
|
};
|
|
235
246
|
|
|
236
247
|
const FUNCTION_NAME = {
|
|
@@ -263,6 +274,9 @@ const FUNCTION_NAME = {
|
|
|
263
274
|
flowSchemaOwnTopicEndpoint: "flowSchemaOwnTopicEndpoint",
|
|
264
275
|
flowSchemaOwnTopicEndpointComplete: "flowSchemaOwnTopicEndpointComplete",
|
|
265
276
|
flowSchemaExternalTopic: "externalTopic",
|
|
277
|
+
flowSchemaEventBridge: "flowSchemaEventBridge",
|
|
278
|
+
createRecordComplete: "createRecordComplete",
|
|
279
|
+
flowSchemaRegister: "register",
|
|
266
280
|
};
|
|
267
281
|
|
|
268
282
|
const SHORT_FUNCTION_NAME = {
|
|
@@ -382,11 +396,16 @@ const SOURCE_GENERATE_IAM_ROLE = {
|
|
|
382
396
|
PerActionEndpoint: "PerActionEndpoint",
|
|
383
397
|
ExternalTopicRole: "ExternalTopic",
|
|
384
398
|
EventBridge: "EventBridge",
|
|
399
|
+
CreateRecordComplete: "CreateRecordComplete",
|
|
400
|
+
RegisterRole: "Register",
|
|
385
401
|
};
|
|
386
402
|
|
|
387
403
|
const ADD_ON_DATA_STRUCTURE_TYPE = {
|
|
388
404
|
versionedData: "versionedData",
|
|
389
|
-
attributeTree: "attributeTree"
|
|
405
|
+
attributeTree: "attributeTree",
|
|
406
|
+
propertyNode: "propertyNode",
|
|
407
|
+
translation: "translation",
|
|
408
|
+
|
|
390
409
|
};
|
|
391
410
|
|
|
392
411
|
const ATTRIBUTE_TAG = {
|
|
@@ -396,6 +415,11 @@ const ATTRIBUTE_TAG = {
|
|
|
396
415
|
attributeTagPropertyLabel: "PropertyLabel",
|
|
397
416
|
};
|
|
398
417
|
|
|
418
|
+
const PROPERTYNODE_TAG = {
|
|
419
|
+
property: "Property",
|
|
420
|
+
propertyLabel: "PropertyLabel",
|
|
421
|
+
};
|
|
422
|
+
|
|
399
423
|
const FIELD_NAME_TPYE = {
|
|
400
424
|
identifiers: "identifiers",
|
|
401
425
|
nonIdentifiers: "nonIdentifiers",
|
|
@@ -439,10 +463,10 @@ function fieldNameSetting(fieldNameType) {
|
|
|
439
463
|
},
|
|
440
464
|
[FIELD_NAME_TPYE.randomOnCreateFieldName]: {
|
|
441
465
|
type: "string",
|
|
442
|
-
requiredOnCreate:
|
|
466
|
+
requiredOnCreate: false,
|
|
443
467
|
optionalOnCreate: false,
|
|
444
468
|
canUpdate: false,
|
|
445
|
-
randomOnCreate:
|
|
469
|
+
randomOnCreate: true,
|
|
446
470
|
validation: {
|
|
447
471
|
pattern: stringValidation
|
|
448
472
|
}
|
|
@@ -525,6 +549,13 @@ async function getStorageResourceFromObjectSchemas(_izContext, allObjSchemas) {
|
|
|
525
549
|
return { resourceGraphServiceTag: [...resourceGraphServiceTag], resourceDynamoTableName: [...resourceDynamoTableName] }
|
|
526
550
|
}
|
|
527
551
|
|
|
552
|
+
const FLOW_SCHEMA_EVENT_TYPE = {
|
|
553
|
+
s3: "s3",
|
|
554
|
+
ownTopic: "ownTopic",
|
|
555
|
+
extTopic: "extTopic",
|
|
556
|
+
eventBridge: "eventBridge",
|
|
557
|
+
}
|
|
558
|
+
|
|
528
559
|
module.exports = {
|
|
529
560
|
ACTIONS,
|
|
530
561
|
DEFAULT_HANDLER_PER_ACTION,
|
|
@@ -554,8 +585,10 @@ module.exports = {
|
|
|
554
585
|
FIELD_NAME_TPYE,
|
|
555
586
|
ADD_ON_DATA_STRUCTURE_TYPE,
|
|
556
587
|
ATTRIBUTE_TAG,
|
|
588
|
+
PROPERTYNODE_TAG,
|
|
557
589
|
PREFIX_RELATIONSHIP,
|
|
558
590
|
checkDynamoTypeRelationship,
|
|
559
591
|
createDynamoDbComponentByLinks,
|
|
560
|
-
getStorageResourceFromObjectSchemas
|
|
592
|
+
getStorageResourceFromObjectSchemas,
|
|
593
|
+
FLOW_SCHEMA_EVENT_TYPE
|
|
561
594
|
}
|
|
@@ -21,6 +21,7 @@ module.exports = {
|
|
|
21
21
|
TemplateAndData: {
|
|
22
22
|
// ** mock schema config **
|
|
23
23
|
mainAttributeTree: './TemplateData/attributeTreeSchema/generateTemplateData.js',
|
|
24
|
+
propertyNode: './TemplateData/propertyNodeSchema/generateTemplateData.js',
|
|
24
25
|
test: './TemplateData/testTemplate/data.js',
|
|
25
26
|
},
|
|
26
27
|
Plugin: {
|
|
@@ -20,7 +20,7 @@ const izara = require("@izara_project/izara-middleware");
|
|
|
20
20
|
const middleware = izara.middlewareHandler;
|
|
21
21
|
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
22
22
|
const {
|
|
23
|
-
|
|
23
|
+
validateSchemaMiddleware
|
|
24
24
|
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
25
25
|
|
|
26
26
|
const { <%- action %>Main } =require('./<%- firstLetterUpperCase(action) %>_Main.js')
|
|
@@ -29,7 +29,7 @@ const { <%- action %>Main } =require('./<%- firstLetterUpperCase(action) %>_Main
|
|
|
29
29
|
//</globalVarible>)
|
|
30
30
|
|
|
31
31
|
//validate event params in middleware before into main function
|
|
32
|
-
|
|
32
|
+
validateSchemaMiddleware(
|
|
33
33
|
middleware,
|
|
34
34
|
"<%- action %>"
|
|
35
35
|
//(<validateSchemaSetting>
|
|
@@ -21,7 +21,7 @@ const middleware = require("@izara_project/izara-middleware/src/MiddlewareCore/M
|
|
|
21
21
|
|
|
22
22
|
const callingFlowSharedLib = require('@izara_project/izara-core-library-calling-flow');
|
|
23
23
|
const {
|
|
24
|
-
|
|
24
|
+
validateSchemaMiddleware
|
|
25
25
|
} = require('@izara_project/izara-market-library-service-schemas/src/GenerateCodeLibs/src/GenerateCodeLibs');
|
|
26
26
|
|
|
27
27
|
const { <%- action %>Main } =require('./<%- firstLetterUpperCase(action) %>_Main.js')
|
|
@@ -31,7 +31,7 @@ const { <%- action %>Main } =require('./<%- firstLetterUpperCase(action) %>_Main
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
//validate event params in middleware before into main function
|
|
34
|
-
|
|
34
|
+
validateSchemaMiddleware(
|
|
35
35
|
middleware,
|
|
36
36
|
"<%- action %>"
|
|
37
37
|
//(<validateSchemaSetting>
|
|
@@ -22,17 +22,18 @@ console.log("generate main attri ");
|
|
|
22
22
|
const { join } = require('path');
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
const { data: mainAttributeData } = require('./
|
|
25
|
+
// const { data: mainAttributeData } = require('./mainAttributeTree/data');
|
|
26
26
|
|
|
27
|
-
const serviceSchemaCore = require("@izara_project/izara-core-library-service-schemas");
|
|
28
|
-
const getObjectSchema = serviceSchemaCore.getObjectSchema;
|
|
27
|
+
// const serviceSchemaCore = require("@izara_project/izara-core-library-service-schemas");
|
|
28
|
+
// const getObjectSchema = serviceSchemaCore.getObjectSchema;
|
|
29
29
|
|
|
30
30
|
const serviceSchemaShared = require('@izara_project/izara-shared-service-schemas');
|
|
31
31
|
const { validateObjType } = serviceSchemaShared.validateObjType
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
const modules = {
|
|
35
|
-
mainAttributeTreeSchema: require('./
|
|
35
|
+
mainAttributeTreeSchema: require('./mainAttributeTree/data'),
|
|
36
|
+
relaAttributeTreeSchema: require('./relationshipSchema/data')
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* Generates code with templates for different actions
|
|
@@ -40,63 +41,46 @@ const modules = {
|
|
|
40
41
|
* @param {string} objSchemaPath - Path to the schema
|
|
41
42
|
* @returns {Array} Array of generated code parameters
|
|
42
43
|
*/
|
|
43
|
-
async function generateCodeWithTemplate(
|
|
44
|
+
async function generateCodeWithTemplate(
|
|
45
|
+
_izContext,
|
|
46
|
+
objSchemaPath,
|
|
47
|
+
settings
|
|
48
|
+
) {
|
|
44
49
|
try {
|
|
45
50
|
let allCreateSource = [];
|
|
46
51
|
const srcPath = join(objSchemaPath, '../');
|
|
47
52
|
|
|
48
|
-
// {
|
|
49
|
-
// generateName: "mainAttributeTree",
|
|
50
|
-
// objType: {
|
|
51
|
-
// serviceTag: "GenerateCodeTemplate",
|
|
52
|
-
// objectType: "person"
|
|
53
|
-
// },
|
|
54
|
-
// attributeTag: "productAttribute"
|
|
55
|
-
// }
|
|
56
|
-
|
|
57
53
|
if (!settings || !settings.generateName || !settings.objType || !settings.attributeTag) {
|
|
58
54
|
validateObjType(settings.objType);
|
|
59
55
|
throw new Error("Invalid settings object. Must contain objType and attributeTag properties.");
|
|
60
56
|
}
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
if (settings.generateName === "mainAttributeTree") {
|
|
58
|
+
let objSchemaAttributeTree = await modules.mainAttributeTreeSchema(
|
|
59
|
+
_izContext,
|
|
60
|
+
settings,
|
|
61
|
+
srcPath
|
|
62
|
+
);
|
|
63
|
+
allCreateSource.push(...objSchemaAttributeTree);
|
|
64
|
+
console.log("objSchemaAttributeTree finish");
|
|
63
65
|
|
|
64
|
-
// const objectSchema = await getObjectSchema.getObjSchemaS3WithHierarchy(_izContext, settings.objType)
|
|
65
|
-
// console.log("allObjectSchema: ", allObjectSchema);
|
|
66
|
-
// console.log("settings: ", settings);
|
|
67
|
-
/*
|
|
68
|
-
use settings to get main objType
|
|
69
|
-
then check if addOnDataStructure is exist
|
|
70
|
-
if exist, check if type is attributeTree and match with attributeTreeTag
|
|
71
|
-
if match, start generate schema of attributeTree
|
|
72
|
-
*/
|
|
73
66
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
let relaSchemaAttributeTree = await modules.relaAttributeTreeSchema(
|
|
68
|
+
_izContext,
|
|
69
|
+
settings,
|
|
70
|
+
srcPath
|
|
71
|
+
);
|
|
72
|
+
allCreateSource.push(relaSchemaAttributeTree);
|
|
73
|
+
console.log("relaSchemaAttributeTree finish");
|
|
77
74
|
|
|
78
75
|
|
|
79
|
-
}
|
|
80
|
-
*/
|
|
81
|
-
if (settings.generateName === "mainAttributeTree") {
|
|
82
|
-
let objSchemaAttributeTree = await modules.mainAttributeTreeSchema(_izContext, settings, srcPath);
|
|
83
|
-
console.log("objSchemaAttributeTree: ", objSchemaAttributeTree);
|
|
84
|
-
allCreateSource.push(...objSchemaAttributeTree);
|
|
85
|
-
|
|
86
76
|
} else {
|
|
87
77
|
throw Error(`Generate attribute tree schema Invalid generateName:${settings.generateName} `);
|
|
88
78
|
}
|
|
89
79
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// then data function will return params for createSource
|
|
93
|
-
|
|
94
|
-
// (template, data, { savePath, hookPath, saveFileName, fileExtension, initialData, isAppend = false, checkCreateSourcePass = false })
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return allCreateSource;
|
|
80
|
+
_izContext.logger.debug("allCreateSource is", allCreateSource);
|
|
81
|
+
return [...allCreateSource];
|
|
98
82
|
} catch (error) {
|
|
99
|
-
_izContext.logger.error('Error generating code with template
|
|
83
|
+
_izContext.logger.error('Error generating code with template attribute tree schema:', error);
|
|
100
84
|
return [];
|
|
101
85
|
}
|
|
102
86
|
}
|
|
@@ -4,13 +4,9 @@ let { pattern } = izara.validatorSchema.stringNotEmpty(); // should not be empty
|
|
|
4
4
|
module.exports = [
|
|
5
5
|
{
|
|
6
6
|
objectType: "<%- objectType %>",
|
|
7
|
-
|
|
8
|
-
//(<
|
|
9
|
-
//(</
|
|
10
|
-
},
|
|
11
|
-
overwriteGeneratedMainFunction: [
|
|
12
|
-
//(<overwriteGeneratedMainFunction<%- objectType %>>)
|
|
13
|
-
//(</overwriteGeneratedMainFunction<%- objectType %>>)
|
|
7
|
+
addOnDataStructure: [ // optional, add for additional setting to objectType
|
|
8
|
+
//(<addOnDataStructure<%- objectType %>>)
|
|
9
|
+
//(</addOnDataStructure<%- objectType %>>)
|
|
14
10
|
],
|
|
15
11
|
canDelete: true,
|
|
16
12
|
storageResources: <%- storageResources %>,
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 Sven Mason <http://izara.io>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU Affero General Public License as
|
|
6
|
+
published by the Free Software Foundation, either version 3 of the
|
|
7
|
+
License, or (at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU Affero General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
'use strict';
|
|
19
|
+
|
|
20
|
+
console.log("=== attribute tree schemas ===");
|
|
21
|
+
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
|
|
25
|
+
const getObjectSchema = require('@izara_project/izara-core-library-service-schemas/src/GetObjectSchema')
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
SOURCE_PATH,
|
|
29
|
+
ADD_ON_DATA_STRUCTURE_TYPE,
|
|
30
|
+
ATTRIBUTE_TAG,
|
|
31
|
+
fieldNameSetting,
|
|
32
|
+
FIELD_NAME_TPYE,
|
|
33
|
+
SAVE_FILE_NAME
|
|
34
|
+
} = require('@izara_project/izara-market-library-service-schemas/src/MainLibs/src/Consts');
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
const modules = {
|
|
38
|
+
validateAddOnDataStructure: require('../../../libs/ValidateAddOnDataStructure')
|
|
39
|
+
}
|
|
40
|
+
const templatePath = path.join(__dirname, "./attributeLinkTemplate.ejs");
|
|
41
|
+
|
|
42
|
+
async function data(_izContext, settings, srcPath) {
|
|
43
|
+
|
|
44
|
+
let [returnValue, errorFounds] = await modules.validateAddOnDataStructure(_izContext, settings);
|
|
45
|
+
|
|
46
|
+
if (returnValue.hasOwnProperty("addOnAttributeTree") && errorFounds.length > 0) {
|
|
47
|
+
errorFounds.push(`Not have data addOnAttributeTree and have error:${errorFounds}`)
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
if (errorFounds.length > 0) {
|
|
51
|
+
throw Error(errorFounds)
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const addOnAttributeTree = returnValue.addOnAttributeTree;
|
|
55
|
+
const storageResources = returnValue.objectSchema.storageResources; // storageResource from main objectType
|
|
56
|
+
const storageResourceTag = Object.keys(storageResources); // storage ResourceTag from main objectType
|
|
57
|
+
const compositeKeyDeliminator = returnValue.objectSchema.compositeKeyDeliminator;
|
|
58
|
+
|
|
59
|
+
let attributeTreeObjSchemas = [];
|
|
60
|
+
let createSources = [];
|
|
61
|
+
|
|
62
|
+
attributeTreeObjSchemas.push(
|
|
63
|
+
{ // {subject}
|
|
64
|
+
objectType: addOnAttributeTree.attributeTreeTag,
|
|
65
|
+
fieldNames: {
|
|
66
|
+
[addOnAttributeTree.attributeTreeTag + "Id"]: fieldNameSetting(FIELD_NAME_TPYE.randomOnCreateFieldName),
|
|
67
|
+
},
|
|
68
|
+
identifiers: [
|
|
69
|
+
{
|
|
70
|
+
type: "identifier",
|
|
71
|
+
fieldName: addOnAttributeTree.attributeTreeTag + "Id"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{ // {subject}Link
|
|
76
|
+
objectType: addOnAttributeTree.attributeTreeTag + ATTRIBUTE_TAG.attributeTagLink,
|
|
77
|
+
fieldNames: {
|
|
78
|
+
[addOnAttributeTree.attributeTreeTag + ATTRIBUTE_TAG.attributeTagLink + "Id"]: fieldNameSetting(FIELD_NAME_TPYE.randomOnCreateFieldName)
|
|
79
|
+
},
|
|
80
|
+
identifiers: [
|
|
81
|
+
{
|
|
82
|
+
type: "identifier",
|
|
83
|
+
fieldName: addOnAttributeTree.attributeTreeTag + ATTRIBUTE_TAG.attributeTagLink + "Id"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
{ //{subject}Label
|
|
88
|
+
objectType: addOnAttributeTree.attributeTreeTag + ATTRIBUTE_TAG.attributeTagLabel,
|
|
89
|
+
fieldNames: {
|
|
90
|
+
[addOnAttributeTree.attributeTreeTag + ATTRIBUTE_TAG.attributeTagLabel + "Id"]: fieldNameSetting(FIELD_NAME_TPYE.randomOnCreateFieldName)
|
|
91
|
+
},
|
|
92
|
+
identifiers: [
|
|
93
|
+
{
|
|
94
|
+
type: "identifier",
|
|
95
|
+
fieldName: `${addOnAttributeTree.attributeTreeTag + ATTRIBUTE_TAG.attributeTagLabel}Id`
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
)
|
|
101
|
+
for (let attributeTreeObjSchema of attributeTreeObjSchemas) {
|
|
102
|
+
Object.assign(attributeTreeObjSchema, {
|
|
103
|
+
storageResources: storageResources, // add storageResources
|
|
104
|
+
compositeKeyDeliminator: compositeKeyDeliminator
|
|
105
|
+
})
|
|
106
|
+
for (let attributeTreeFieldName of Object.values(attributeTreeObjSchema.fieldNames)) {
|
|
107
|
+
Object.assign(attributeTreeFieldName, { storageResourceTags: storageResourceTag }) // add storageResourceTags for each fieldName
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
_izContext.logger.debug("check is attributeTreeObjSchemas", attributeTreeObjSchemas)
|
|
111
|
+
for (const attributeTreeObjSchema of attributeTreeObjSchemas) {
|
|
112
|
+
createSources.push({
|
|
113
|
+
templatePath: templatePath,
|
|
114
|
+
templateData: {
|
|
115
|
+
fieldNames: JSON.stringify(attributeTreeObjSchema.fieldNames, null, 2),
|
|
116
|
+
identifiers: JSON.stringify(attributeTreeObjSchema.identifiers, null, 2),
|
|
117
|
+
objectType: attributeTreeObjSchema.objectType,
|
|
118
|
+
storageResources: JSON.stringify(attributeTreeObjSchema.storageResources, null, 2),
|
|
119
|
+
compositeKeyDeliminator: attributeTreeObjSchema.compositeKeyDeliminator
|
|
120
|
+
},
|
|
121
|
+
setting: {
|
|
122
|
+
savePath: path.join(srcPath, SOURCE_PATH.generatedAttributeTree, attributeTreeObjSchema.objectType + "/"),
|
|
123
|
+
hookPath: path.join(srcPath, "schemaHook", "attributeTree", attributeTreeObjSchema.objectType, "/"),
|
|
124
|
+
saveFileName: SAVE_FILE_NAME.objectSchema,
|
|
125
|
+
fileExtension: ".js",
|
|
126
|
+
isAppend: false
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return createSources;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
module.exports = data
|