@izara_project/izara-core-generate-service-code 1.0.69 → 1.0.71
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/scripts/format-ejs.js +35 -30
- package/src/compile/loadSchemas.js +84 -45
- package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +163 -0
- package/src/emit/coreFunction/templates/CoreFunction_Yaml.ejs +38 -0
- package/src/emit/coreFunction/templates/CoreResource_Yaml.ejs +235 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_Main.ejs +38 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_Main.ejs +32 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_Main.ejs +71 -0
- package/src/emit/coreFunction/templates/GeneratedGraphNodeSchemas.ejs +47 -0
- package/src/emit/coreFunction/templates/GeneratedGraphRelSchemas.ejs +27 -0
- package/src/emit/coreFunction/templates/GeneratedTableConfigs.ejs +34 -0
- package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +108 -0
- package/src/emit/coreFunction/templates/InitialSetup_HdrInv.ejs +12 -0
- package/src/emit/coreFunction/templates/InitialSetup_Main.ejs +51 -0
- package/src/emit/coreFunction/templates/RemoveSeedDataDynamo_HdrInv.ejs +16 -0
- package/src/emit/coreFunction/templates/RemoveSeedDataDynamo_Main.ejs +31 -0
- package/src/emit/coreFunction/templates/UploadSchema_HdrInv.ejs +37 -0
- package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +52 -0
- package/src/emit/crud/emitCrudApplicationArtifacts.js +12 -6
- package/src/emit/crud/templates/CreateEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/GetEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +1 -1
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +30 -11
- package/src/emit/custom/templates/FlowEndpoint_Main.ejs +2 -2
- package/src/emit/custom/templates/FlowStep_Main.ejs +1 -1
- package/src/emit/custom/templates/s3/CreateObject_Main.ejs +1 -1
- package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +1 -1
- package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +4 -4
- package/src/emit/function/functionYamlArtifact.js +5 -2
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +13 -3
- package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/CreateRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/GetRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/MoveRelationship_Main.ejs +1 -1
- package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +1 -1
- package/src/emit/resource/emitResourceArtifacts.js +71 -15
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +17 -0
- package/src/emit/shared/templates/FindData_HdrSqs.ejs +120 -0
- package/src/emit/shared/templates/FindData_Main.ejs +345 -0
- package/src/emit/{crud → shared}/templates/FlowHandler_HdrApi.ejs +1 -1
- package/src/emit/{relationship → shared}/templates/FlowHandler_HdrDsq.ejs +4 -4
- package/src/emit/{crud → shared}/templates/FlowHandler_HdrInv.ejs +1 -1
- package/src/emit/{crud → shared}/templates/FlowHandler_HdrSqs.ejs +4 -4
- package/src/emit/shared/templates/PaginateProcessLogical_HdrDsq.ejs +162 -0
- package/src/emit/shared/templates/PaginateProcessLogical_HdrSqs.ejs +140 -0
- package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +268 -0
- package/src/emit/{relationship/templates/FlowHandler_HdrSqs.ejs → shared/templates/ProcessLogical_HdrSqs.ejs} +40 -55
- package/src/emit/shared/templates/ProcessLogical_Main.ejs +448 -0
- package/src/emit/system/emitSystemFindDataArtifacts.js +266 -0
- package/src/emit/system/templates/WebSocketComplete_HdrSqs.ejs +27 -11
- package/src/emit/system/templates/WebSocketComplete_Main.ejs +63 -18
- package/src/emit/system/templates/WebSocketConnect.ejs +26 -6
- package/src/generate.js +31 -4
- package/src/output/mergeHooks.js +18 -19
- package/test/core.test.js +4 -12
- package/test/crudApplicationArtifacts.test.js +14 -18
- package/test/publicApi.test.js +2 -2
- package/test/resourceArtifacts.test.js +1 -1
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +0 -59
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +0 -47
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
import {
|
|
19
|
+
middlewareHandler as middleware,
|
|
20
|
+
validatorSchema
|
|
21
|
+
} from '@izara_project/izara-middleware';
|
|
22
|
+
import { recordHandlerSharedLib } from '@izara_project/izara-core-library-record-handler';
|
|
23
|
+
import Logger from '@izara_project/izara-core-library-logger';
|
|
24
|
+
|
|
25
|
+
import findData from './FindData_Main.js';
|
|
26
|
+
|
|
27
|
+
// validate event properties in body.Message of sqs event
|
|
28
|
+
middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
|
|
29
|
+
|
|
30
|
+
// set schema for record.body.Message
|
|
31
|
+
const perRecordsValidatorSchema = {
|
|
32
|
+
type: 'object',
|
|
33
|
+
required: ['fieldName', 'objType', 'identifiers', 'overWriteCache'],
|
|
34
|
+
properties: {
|
|
35
|
+
fieldName: {
|
|
36
|
+
type: 'object'
|
|
37
|
+
},
|
|
38
|
+
objType: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
required: ['serviceTag', 'objectType'],
|
|
41
|
+
properties: {
|
|
42
|
+
serviceTag: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
enum: [process.env.iz_serviceTag]
|
|
45
|
+
},
|
|
46
|
+
objectType: validatorSchema.stringNotEmpty()
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
identifiers: {
|
|
50
|
+
type: 'object'
|
|
51
|
+
},
|
|
52
|
+
overWriteCache: {
|
|
53
|
+
type: 'boolean'
|
|
54
|
+
},
|
|
55
|
+
callingFlow: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
default: ''
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const main = middleware.wrap(async (event, context) => {
|
|
63
|
+
try {
|
|
64
|
+
let recordPromises = [];
|
|
65
|
+
|
|
66
|
+
// loop each record and send to mainFunction
|
|
67
|
+
await Promise.all(
|
|
68
|
+
event.Records.map(async record => {
|
|
69
|
+
// promise.all for map() function
|
|
70
|
+
|
|
71
|
+
let passOnProperties = [];
|
|
72
|
+
record._izContext.logger.debug('record ReceiveMsgOutHdrSqs', record);
|
|
73
|
+
|
|
74
|
+
// validate message (and MessageAttributes)
|
|
75
|
+
await recordHandlerSharedLib.validateRecord(
|
|
76
|
+
record, // one record will send to mainFunction
|
|
77
|
+
'FindDataHdrSqs', // queue name that need to retry or send to dlq
|
|
78
|
+
perRecordsValidatorSchema // schema for record.Message
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
// add argument (to invoke lambda) to passOnProperties[]
|
|
82
|
+
passOnProperties.push(record.body.Message.fieldName);
|
|
83
|
+
passOnProperties.push(record.body.Message.objType);
|
|
84
|
+
passOnProperties.push(record.body.Message.identifiers);
|
|
85
|
+
passOnProperties.push(record.body.Message.overWriteCache);
|
|
86
|
+
passOnProperties.push(record.body.Message.callingFlow);
|
|
87
|
+
record._izContext.logger.debug(
|
|
88
|
+
'passOnProperties in handler',
|
|
89
|
+
passOnProperties
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// call recordHandlerSharedLib.recordHandler with 3 parameters and return promise(resolve)
|
|
93
|
+
let recordPromise = recordHandlerSharedLib.recordHandler(
|
|
94
|
+
record, // one record will send to mainFunction
|
|
95
|
+
findData, // mainFunction that need to invoke.
|
|
96
|
+
'FindDataHdrSqs', // queue name that need to retry or send to dlq
|
|
97
|
+
passOnProperties // all parameters that mainFunction needed.
|
|
98
|
+
);
|
|
99
|
+
record._izContext.logger.debug('after recordPromise in handler');
|
|
100
|
+
recordPromises.push(recordPromise); // push promise to recordPromises
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
Logger.debug('before Promise.all(recordPromises) in handler');
|
|
105
|
+
try {
|
|
106
|
+
// --- main await all promises
|
|
107
|
+
await Promise.all(recordPromises); // await all promises
|
|
108
|
+
|
|
109
|
+
return event.Records; // return all for local testing
|
|
110
|
+
} catch {
|
|
111
|
+
Logger.debug(
|
|
112
|
+
'Promise.all(recordPromises) in handler threw error (at least one record did no resolve)'
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
Logger.debug('after Promise.all(recordPromises) in handler');
|
|
116
|
+
} catch (err) {
|
|
117
|
+
Logger.error('Unhandled Error, LambdaFunctionHdrSqs: ', err);
|
|
118
|
+
throw err;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
@@ -0,0 +1,345 @@
|
|
|
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
|
+
import findDataSharedLib from '@izara_project/izara-core-library-find-data';
|
|
19
|
+
import graphSharedLib from '@izara_project/izara-core-library-graph-service';
|
|
20
|
+
import dynamodbSharedLib from '@izara_project/izara-core-library-dynamodb'
|
|
21
|
+
|
|
22
|
+
import { serviceConfig, identifiersObject as identifierObj } from '@izara_project/izara-core-library-service-schemas';
|
|
23
|
+
|
|
24
|
+
//(<additionalModule>)
|
|
25
|
+
//(</additionalModule>)
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* triggered from searchResult for each requiredData field per one identifiers
|
|
29
|
+
* @param {Object} _izContext
|
|
30
|
+
* @param {string} fieldName
|
|
31
|
+
* @param {Object} objType
|
|
32
|
+
* @param {Object} identifiers
|
|
33
|
+
* @param {Boolean} overWriteCache
|
|
34
|
+
*
|
|
35
|
+
* @returns {object} description of return value
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
export default async function findData(
|
|
39
|
+
_izContext,
|
|
40
|
+
fieldName,
|
|
41
|
+
objType,
|
|
42
|
+
identifiers,
|
|
43
|
+
overWriteCache,
|
|
44
|
+
callingFlow,
|
|
45
|
+
|
|
46
|
+
//(<additionalParams>)
|
|
47
|
+
//(</additionalParams>)
|
|
48
|
+
) {
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
|
|
52
|
+
_izContext.logger.debug('----- findData event params -----', {
|
|
53
|
+
fieldName: fieldName,
|
|
54
|
+
objType: objType,
|
|
55
|
+
identifiers: identifiers,
|
|
56
|
+
overWriteCache: overWriteCache,
|
|
57
|
+
callingFlow: callingFlow
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// removeAttributes on expired
|
|
61
|
+
let removeAttributes = [];
|
|
62
|
+
//(<removeAttributes>)
|
|
63
|
+
//(</removeAttributes>)
|
|
64
|
+
|
|
65
|
+
let deleteDataTableOnExpired = [];
|
|
66
|
+
|
|
67
|
+
// Check/create FindDataMain status
|
|
68
|
+
let [findDataMainStatus, findDataId, findDataMain] = await findDataSharedLib.checkFindDataMainStatus(
|
|
69
|
+
_izContext,
|
|
70
|
+
fieldName,
|
|
71
|
+
objType,
|
|
72
|
+
identifiers,
|
|
73
|
+
callingFlow,
|
|
74
|
+
removeAttributes,
|
|
75
|
+
overWriteCache
|
|
76
|
+
);
|
|
77
|
+
_izContext.logger.debug('result after checkFindDataMainStatus is', {
|
|
78
|
+
findDataMainStatus: findDataMainStatus,
|
|
79
|
+
findDataId: findDataId,
|
|
80
|
+
findDataMain: findDataMain
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
if (findDataMainStatus != 'process') {
|
|
84
|
+
_izContext.logger.debug(`findDataMainStatus status isn't process :${findDataMainStatus}`)
|
|
85
|
+
return {
|
|
86
|
+
returnResponse: 'Function FindData not process'
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
let errorsFound = [];
|
|
91
|
+
|
|
92
|
+
let standardErrorParams = [
|
|
93
|
+
_izContext,
|
|
94
|
+
fieldName,
|
|
95
|
+
objType,
|
|
96
|
+
identifiers,
|
|
97
|
+
null,
|
|
98
|
+
overWriteCache,
|
|
99
|
+
callingFlow,
|
|
100
|
+
'error'
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
<% for (let dataIndex = 0; dataIndex < datas.length; dataIndex++) {
|
|
104
|
+
const dataItem = datas[dataIndex];
|
|
105
|
+
const objectType = dataItem.objectType;
|
|
106
|
+
const fieldNames = dataItem.fieldNames; %>
|
|
107
|
+
if (objType.objectType === <%- JSON.stringify(objectType) %>) {
|
|
108
|
+
_izContext.logger.debug('objectType: ', objType.objectType)
|
|
109
|
+
|
|
110
|
+
<% for (let fieldIndex = 0; fieldIndex < fieldNames.length; fieldIndex++) {
|
|
111
|
+
const storageEntry = fieldNames[fieldIndex];
|
|
112
|
+
const field = Object.keys(storageEntry)[0];
|
|
113
|
+
const storageDetails = Object.values(storageEntry)[0];
|
|
114
|
+
const hasDynamo = storageDetails.dynamoDB !== undefined;
|
|
115
|
+
const hasGraph = storageDetails.graph !== undefined;
|
|
116
|
+
const graphDetail = storageDetails.graph || {};
|
|
117
|
+
const dynamoDetail = storageDetails.dynamoDB || {};
|
|
118
|
+
|
|
119
|
+
if (hasDynamo && hasGraph) {
|
|
120
|
+
// dynamoDB takes priority over graph when both exist %>
|
|
121
|
+
if (fieldName.fieldName === <%- JSON.stringify(field) %>) {
|
|
122
|
+
_izContext.logger.debug('fieldName: ', fieldName.fieldName)
|
|
123
|
+
|
|
124
|
+
//(<beforeGetItem<%- objectType %><%- field %>>)
|
|
125
|
+
//(</beforeGetItem<%- objectType %><%- field %>>)
|
|
126
|
+
|
|
127
|
+
let identifiersBase = await identifierObj.identifiersBaseFromIdentifiers(
|
|
128
|
+
_izContext,
|
|
129
|
+
objType,
|
|
130
|
+
identifiers,
|
|
131
|
+
);
|
|
132
|
+
_izContext.logger.debug('create identifiersBase from identifiers: ', identifiersBase)
|
|
133
|
+
|
|
134
|
+
let objInstanceBase = await dynamodbSharedLib.getItem(
|
|
135
|
+
_izContext,
|
|
136
|
+
await dynamodbSharedLib.tableName(_izContext, <%- JSON.stringify(dynamoDetail.tableName) %>),
|
|
137
|
+
identifiersBase
|
|
138
|
+
);
|
|
139
|
+
_izContext.logger.debug('objInstanceBase: ', objInstanceBase)
|
|
140
|
+
|
|
141
|
+
if (!objInstanceBase) {
|
|
142
|
+
errorsFound.push(`can't get data in dynamo by ${identifiersBase}`)
|
|
143
|
+
standardErrorParams.push(errorsFound)
|
|
144
|
+
await findDataSharedLib.completeFindDataMain(...standardErrorParams);
|
|
145
|
+
return {
|
|
146
|
+
returnResponse: 'FindData cannot get data in dynamo'
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (!objInstanceBase.hasOwnProperty(fieldName.fieldName)) {
|
|
151
|
+
errorsFound.push(`data in dynamoDB have no ${fieldName.fieldName}`)
|
|
152
|
+
standardErrorParams.push(errorsFound)
|
|
153
|
+
await findDataSharedLib.completeFindDataMain(...standardErrorParams);
|
|
154
|
+
return {
|
|
155
|
+
returnResponse: 'Data have no fieldName'
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
//(<afterGetItem<%- objectType %><%- field %>>)
|
|
160
|
+
//(</afterGetItem<%- objectType %><%- field %>>)
|
|
161
|
+
|
|
162
|
+
let dataValue = objInstanceBase[fieldName.fieldName];
|
|
163
|
+
_izContext.logger.debug('dataValue: ', dataValue)
|
|
164
|
+
|
|
165
|
+
await findDataSharedLib.completeFindDataMain(
|
|
166
|
+
_izContext,
|
|
167
|
+
findDataMain.fieldName,
|
|
168
|
+
findDataMain.objType,
|
|
169
|
+
findDataMain.identifiers,
|
|
170
|
+
dataValue,
|
|
171
|
+
overWriteCache,
|
|
172
|
+
callingFlow,
|
|
173
|
+
'complete'
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
<% } else if (hasDynamo) { %>
|
|
177
|
+
if (fieldName.fieldName === <%- JSON.stringify(field) %>) {
|
|
178
|
+
_izContext.logger.debug('fieldName: ', fieldName.fieldName)
|
|
179
|
+
|
|
180
|
+
//(<beforeGetItem<%- objectType %><%- field %>>)
|
|
181
|
+
//(</beforeGetItem<%- objectType %><%- field %>>)
|
|
182
|
+
|
|
183
|
+
let identifiersBase = await identifierObj.identifiersBaseFromIdentifiers(
|
|
184
|
+
_izContext,
|
|
185
|
+
objType,
|
|
186
|
+
identifiers,
|
|
187
|
+
);
|
|
188
|
+
_izContext.logger.debug('create identifiersBase from identifiers: ', identifiersBase)
|
|
189
|
+
|
|
190
|
+
let objInstanceBase = await dynamodbSharedLib.getItem(
|
|
191
|
+
_izContext,
|
|
192
|
+
await dynamodbSharedLib.tableName(_izContext, <%- JSON.stringify(dynamoDetail.tableName) %>),
|
|
193
|
+
identifiersBase
|
|
194
|
+
);
|
|
195
|
+
_izContext.logger.debug('objInstanceBase: ', objInstanceBase)
|
|
196
|
+
|
|
197
|
+
if (!objInstanceBase) {
|
|
198
|
+
errorsFound.push(`can't get data in dynamo by ${identifiersBase}`)
|
|
199
|
+
standardErrorParams.push(errorsFound)
|
|
200
|
+
await findDataSharedLib.completeFindDataMain(...standardErrorParams);
|
|
201
|
+
return {
|
|
202
|
+
returnResponse: 'FindData cannot get data in dynamo'
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (!objInstanceBase.hasOwnProperty(fieldName.fieldName)) {
|
|
207
|
+
errorsFound.push(`data in dynamoDB have no ${fieldName.fieldName}`)
|
|
208
|
+
standardErrorParams.push(errorsFound)
|
|
209
|
+
await findDataSharedLib.completeFindDataMain(...standardErrorParams);
|
|
210
|
+
return {
|
|
211
|
+
returnResponse: 'Data have no fieldName'
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
//(<afterGetItem<%- objectType %><%- field %>>)
|
|
216
|
+
//(</afterGetItem<%- objectType %><%- field %>>)
|
|
217
|
+
|
|
218
|
+
let dataValue = objInstanceBase[fieldName.fieldName];
|
|
219
|
+
_izContext.logger.debug('dataValue: ', dataValue)
|
|
220
|
+
|
|
221
|
+
await findDataSharedLib.completeFindDataMain(
|
|
222
|
+
_izContext,
|
|
223
|
+
findDataMain.fieldName,
|
|
224
|
+
findDataMain.objType,
|
|
225
|
+
findDataMain.identifiers,
|
|
226
|
+
dataValue,
|
|
227
|
+
overWriteCache,
|
|
228
|
+
callingFlow,
|
|
229
|
+
'complete'
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
<% } else if (hasGraph) { %>
|
|
233
|
+
if (fieldName.fieldName === <%- JSON.stringify(field) %>) {
|
|
234
|
+
_izContext.logger.debug('fieldName: ', fieldName.fieldName)
|
|
235
|
+
|
|
236
|
+
//(<beforeGetNode<%- objectType %><%- field %>>)
|
|
237
|
+
//(</beforeGetNode<%- objectType %><%- field %>>)
|
|
238
|
+
|
|
239
|
+
const graphHandlerServiceTag = await serviceConfig.getGraphServiceTagWithCache(
|
|
240
|
+
_izContext,
|
|
241
|
+
<%- JSON.stringify(graphDetail.graphServerTag) %>,
|
|
242
|
+
);
|
|
243
|
+
_izContext.logger.debug('graphHandlerServiceTag: ', graphHandlerServiceTag)
|
|
244
|
+
|
|
245
|
+
let getDataByGraph = await graphSharedLib.getNode(
|
|
246
|
+
_izContext,
|
|
247
|
+
graphHandlerServiceTag,
|
|
248
|
+
objType,
|
|
249
|
+
{
|
|
250
|
+
identifiers:identifiers
|
|
251
|
+
},
|
|
252
|
+
<%- JSON.stringify(graphDetail.versionedDataLabel || undefined) %>
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
_izContext.logger.debug('getDataByGraph: ', getDataByGraph)
|
|
256
|
+
|
|
257
|
+
if (!getDataByGraph) {
|
|
258
|
+
errorsFound.push(`can't get data of ${objType.objectType} in graph`)
|
|
259
|
+
standardErrorParams.push(errorsFound)
|
|
260
|
+
await findDataSharedLib.completeFindDataMain(...standardErrorParams);
|
|
261
|
+
return {
|
|
262
|
+
returnResponse: 'FindData cannot get data in graph'
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
//(<afterGetNode<%- objectType %><%- field %>>)
|
|
267
|
+
//(</afterGetNode<%- objectType %><%- field %>>)
|
|
268
|
+
|
|
269
|
+
let objInstanceFull = getDataByGraph.returnValue.queryResults.refactoredNodes.objInstanceFull;
|
|
270
|
+
_izContext.logger.debug('objInstanceFull: ', objInstanceFull)
|
|
271
|
+
|
|
272
|
+
<% if (graphDetail.getInIdentifiers) { %>
|
|
273
|
+
if (!objInstanceFull.identifiers.hasOwnProperty(fieldName.fieldName)) {
|
|
274
|
+
errorsFound.push(`nodeProperties have no this ${fieldName.fieldName}`)
|
|
275
|
+
standardErrorParams.push(errorsFound)
|
|
276
|
+
await findDataSharedLib.completeFindDataMain(...standardErrorParams);
|
|
277
|
+
return {
|
|
278
|
+
returnResponse: 'Data have no fieldName'
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
let dataValue = objInstanceFull.identifiers[fieldName.fieldName];
|
|
283
|
+
_izContext.logger.debug('this fieldName is identifier, get dataValue in identifiers: ', dataValue)
|
|
284
|
+
<% } else { %>
|
|
285
|
+
if (!objInstanceFull.fields.hasOwnProperty(fieldName.fieldName)) {
|
|
286
|
+
errorsFound.push(`nodeProperties have no this ${fieldName.fieldName}`)
|
|
287
|
+
standardErrorParams.push(errorsFound)
|
|
288
|
+
await findDataSharedLib.completeFindDataMain(...standardErrorParams);
|
|
289
|
+
return {
|
|
290
|
+
returnResponse: 'Data have no fieldName'
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
let dataValue = objInstanceFull.fields[fieldName.fieldName];
|
|
295
|
+
_izContext.logger.debug('this fieldName is not identifier, get dataValue in fields: ', dataValue)
|
|
296
|
+
<% } %>
|
|
297
|
+
|
|
298
|
+
await findDataSharedLib.completeFindDataMain(
|
|
299
|
+
_izContext,
|
|
300
|
+
findDataMain.fieldName,
|
|
301
|
+
findDataMain.objType,
|
|
302
|
+
findDataMain.identifiers,
|
|
303
|
+
dataValue,
|
|
304
|
+
overWriteCache,
|
|
305
|
+
callingFlow,
|
|
306
|
+
'complete'
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
<% } %>
|
|
310
|
+
}<% if (fieldIndex + 1 === fieldNames.length) { %>
|
|
311
|
+
//(<additional<%- objectType %>FieldNames>)
|
|
312
|
+
//(</additional<%- objectType %>FieldNames>)
|
|
313
|
+
<% } %>
|
|
314
|
+
else
|
|
315
|
+
|
|
316
|
+
<% } %> {
|
|
317
|
+
errorsFound.push('unrecognized fieldName')
|
|
318
|
+
standardErrorParams.push(errorsFound)
|
|
319
|
+
await findDataSharedLib.completeFindDataMain(...standardErrorParams);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
}<% if (dataIndex + 1 === datas.length) { %>
|
|
323
|
+
//(<additionalObjectType>)
|
|
324
|
+
//(</additionalObjectType>)
|
|
325
|
+
<% } %>
|
|
326
|
+
else
|
|
327
|
+
|
|
328
|
+
<% } %> {
|
|
329
|
+
errorsFound.push('unrecognized objectType')
|
|
330
|
+
standardErrorParams.push(errorsFound)
|
|
331
|
+
await findDataSharedLib.completeFindDataMain(...standardErrorParams);
|
|
332
|
+
return {
|
|
333
|
+
returnResponse: 'Function FindData Error'
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return {
|
|
338
|
+
returnResponse: 'Function FindData Finish'
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
} catch (err) {
|
|
342
|
+
_izContext.logger.error('error FindDataMain: ', err)
|
|
343
|
+
throw (err)
|
|
344
|
+
}
|
|
345
|
+
}
|
|
@@ -15,7 +15,7 @@ const validatorSchema = {
|
|
|
15
15
|
<%- prop.propertyName %>: { type: '<%- prop.type || 'string' %>' }
|
|
16
16
|
<% }) -%>
|
|
17
17
|
},
|
|
18
|
-
required: [<%- startConfig.properties.filter(p => p.required
|
|
18
|
+
required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
19
19
|
<% } -%>
|
|
20
20
|
//(</validatorSchema>)
|
|
21
21
|
};
|
|
@@ -29,10 +29,10 @@ let perRecordsValidatorSchema = {
|
|
|
29
29
|
properties: {
|
|
30
30
|
<% startConfig.properties.forEach((prop, index) => { %> <%- prop.propertyName %>: {
|
|
31
31
|
type: '<%- prop.type || 'string' %>'
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
33
|
<% }) %>
|
|
34
34
|
},
|
|
35
|
-
required: [<%- startConfig.properties.filter(p => p.required
|
|
35
|
+
required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
36
36
|
<% } -%>
|
|
37
37
|
//(</validatorSchema>)
|
|
38
38
|
};
|
|
@@ -48,10 +48,10 @@ let messageAttributeValidatorSchema = {
|
|
|
48
48
|
Value: { type: '<%- prop.type || 'string' %>' }
|
|
49
49
|
},
|
|
50
50
|
required: ['Type', 'Value']
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
52
|
<% }) %>
|
|
53
53
|
},
|
|
54
|
-
required: [<%- startConfig.messageAttributes.filter(p => p.required
|
|
54
|
+
required: [<%- startConfig.messageAttributes.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
55
55
|
};
|
|
56
56
|
<% } else { -%>
|
|
57
57
|
let messageAttributeValidatorSchema = null;
|
|
@@ -12,7 +12,7 @@ const validatorSchema = {
|
|
|
12
12
|
<%- prop.propertyName %>: { type: '<%- prop.type || 'string' %>' }
|
|
13
13
|
<% }) -%>
|
|
14
14
|
},
|
|
15
|
-
required: [<%- startConfig.properties.filter(p => p.required
|
|
15
|
+
required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
16
16
|
<% } -%>
|
|
17
17
|
//(</validatorSchema>)
|
|
18
18
|
};
|
|
@@ -29,10 +29,10 @@ let perRecordsValidatorSchema = {
|
|
|
29
29
|
properties: {
|
|
30
30
|
<% startConfig.properties.forEach((prop, index) => { %> <%- prop.propertyName %>: {
|
|
31
31
|
type: '<%- prop.type || 'string' %>'
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
33
|
<% }) %>
|
|
34
34
|
},
|
|
35
|
-
required: [<%- startConfig.properties.filter(p => p.required
|
|
35
|
+
required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
36
36
|
<% } -%>
|
|
37
37
|
//(</validatorSchema>)
|
|
38
38
|
};
|
|
@@ -48,10 +48,10 @@ let messageAttributeValidatorSchema = {
|
|
|
48
48
|
Value: { type: '<%- prop.type || 'string' %>' }
|
|
49
49
|
},
|
|
50
50
|
required: ['Type', 'Value']
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
52
|
<% }) %>
|
|
53
53
|
},
|
|
54
|
-
required: [<%- startConfig.messageAttributes.filter(p => p.required
|
|
54
|
+
required: [<%- startConfig.messageAttributes.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
55
55
|
};
|
|
56
56
|
<% } else { -%>
|
|
57
57
|
let messageAttributeValidatorSchema = null;
|