@izara_project/izara-core-generate-service-code 1.0.68 → 1.0.70
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 +36 -32
- package/src/compile/compileProject.js +26 -10
- package/src/compile/loadSchemas.js +122 -59
- 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 +194 -41
- package/src/emit/crud/emitDynamicCrudFlowSchemas.js +34 -17
- package/src/emit/crud/generateCrudApplicationArtifacts.js +14 -6
- package/src/emit/crud/generateDynamicCrudFlowSchemas.js +4 -1
- 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 +2 -2
- package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +1 -1
- package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +1 -1
- package/src/emit/custom/customFlows.js +23 -13
- package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +535 -114
- package/src/emit/custom/generateCustomFlowApplicationArtifacts.js +28 -8
- 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/FlowHandler_HdrS3.ejs +2 -2
- package/src/emit/custom/templates/s3/ReservedLimit_HdrSqs.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 +273 -97
- package/src/emit/function/templates/ApiFunction_Yaml.ejs +7 -0
- package/src/emit/function/templates/EventBridgeFunction_Yaml.ejs +6 -0
- package/src/emit/function/templates/InvFunction_Yaml.ejs +5 -0
- package/src/emit/function/templates/S3Function_Yaml.ejs +16 -0
- package/src/emit/function/templates/SqsFunction_Yaml.ejs +10 -0
- package/src/emit/function/templates/WbsFunction_Yaml.ejs +10 -0
- package/src/emit/rbac/emitDynamicRbacFlowSchemas.js +28 -30
- package/src/emit/rbac/emitRbacApplicationArtifacts.js +6 -6
- package/src/emit/rbac/generateCreateTargetRoleHandler.js +6 -4
- package/src/emit/rbac/generateDynamicRbacFlowSchemas.js +8 -2
- package/src/emit/rbac/rbacFlowTag.js +3 -1
- package/src/emit/rbac/templates/UserRbacFlow_Main.ejs +1 -1
- package/src/emit/relationship/emitDynamicRelationshipFlowSchemas.js +26 -10
- package/src/emit/relationship/emitRelationshipApplicationArtifacts.js +189 -37
- package/src/emit/relationship/generateDynamicRelationshipFlowSchemas.js +8 -2
- package/src/emit/relationship/generateRelationshipApplicationArtifacts.js +15 -6
- 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 +249 -123
- package/src/emit/resource/generateResourceArtifacts.js +15 -6
- package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
- package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
- package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +10 -9
- package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
- package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
- package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
- package/src/emit/resource/templates/S3Subscription_Yaml.ejs +7 -0
- package/src/emit/resource/templates/SharedResource_Yaml.ejs +11 -11
- package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +122 -105
- package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +7 -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/emitSystemWebSocketArtifacts.js +61 -165
- package/src/emit/system/templates/WebSocketComplete_HdrSqs.ejs +48 -0
- package/src/emit/system/templates/WebSocketComplete_Main.ejs +91 -0
- package/src/emit/system/templates/WebSocketComplete_Yaml.ejs +19 -0
- package/src/emit/system/templates/WebSocketConnect.ejs +45 -0
- package/src/emit/system/templates/WebSocketConnect_Yaml.ejs +11 -0
- package/src/generate.js +166 -36
- package/src/generateIntTest.js +76 -28
- package/src/generateResourceIntTest.js +35 -12
- package/src/generateResources/IntTest/generateResources/generateResources.js +5 -2
- package/src/generateResources/IntTest/generateResources/templateResources.ejs +18 -30
- package/src/generateResources/IntTest/generateTests/events/events.js +1 -1
- package/src/generateResources/IntTest/generateTests/events/templateEvents.ejs +13 -10
- package/src/generateResources/IntTest/generateTests/generateTemplate.js +2 -2
- package/src/generateResources/IntTest/generateTests/pathIntTest/pathIntTest.js +2 -1
- package/src/generateResources/IntTest/generateTests/pathIntTest/template.ejs +1 -3
- package/src/generateResources/IntTest/generateTests/tests/templateTests.ejs +1 -1
- package/src/generateResources/IntTest/generateTests/tests/tests.js +7 -3
- package/src/generateResources/IntTest/libs/{libs.js → IntTestGenerateLib.js} +34 -23
- package/src/generateResources/IntTest/upload/uploadIntTest.js +33 -19
- package/src/intTestGeneratorShared.js +15 -10
- package/src/output/commitArtifacts.js +99 -39
- package/src/output/mergeHooks.js +34 -21
- package/src/output/validateArtifacts.js +37 -27
- package/src/plan/buildGenerationPlan.js +24 -13
- package/test/core.test.js +117 -58
- package/test/createTargetRoleHandler.test.js +1 -1
- package/test/crudApplicationArtifacts.test.js +132 -31
- package/test/customFlowApplicationArtifacts.test.js +353 -71
- package/test/dynamicCrudFlowSchemas.test.js +74 -26
- package/test/dynamicRbacFlowSchemas.test.js +61 -14
- package/test/dynamicRelationshipFlowSchemas.test.js +65 -18
- package/test/functionYamlArtifact.test.js +67 -10
- package/test/intTestApi.test.js +9 -10
- package/test/publicApi.test.js +178 -36
- package/test/relationshipApplicationArtifacts.test.js +90 -19
- package/test/resourceArtifacts.test.js +173 -33
- package/src/emit/relationship/dynamicRelationshipFlowSchemaTemplate.js +0 -11
- package/src/emit/relationship/templates/FlowHandler_HdrApi.ejs +0 -59
- package/src/emit/relationship/templates/FlowHandler_HdrInv.ejs +0 -47
package/src/generate.js
CHANGED
|
@@ -1,16 +1,55 @@
|
|
|
1
1
|
import { buildGenerationPlan } from './plan/buildGenerationPlan.js';
|
|
2
2
|
import { commitArtifacts } from './output/commitArtifacts.js';
|
|
3
3
|
import { compileProject } from './compile/compileProject.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
4
|
+
import {
|
|
5
|
+
crudApplicationManagedPaths,
|
|
6
|
+
emitCrudApplicationArtifacts
|
|
7
|
+
} from './emit/crud/emitCrudApplicationArtifacts.js';
|
|
8
|
+
import {
|
|
9
|
+
dynamicCrudFlowSchemaPaths,
|
|
10
|
+
emitDynamicCrudFlowSchemas
|
|
11
|
+
} from './emit/crud/emitDynamicCrudFlowSchemas.js';
|
|
12
|
+
import {
|
|
13
|
+
customFlowApplicationManagedPaths,
|
|
14
|
+
emitCustomFlowApplicationArtifacts
|
|
15
|
+
} from './emit/custom/emitCustomFlowApplicationArtifacts.js';
|
|
16
|
+
import {
|
|
17
|
+
emitDynamicRbacFlowSchemas,
|
|
18
|
+
rbacFlowSchemaManagedPaths
|
|
19
|
+
} from './emit/rbac/emitDynamicRbacFlowSchemas.js';
|
|
20
|
+
import {
|
|
21
|
+
emitRbacApplicationArtifacts,
|
|
22
|
+
rbacApplicationManagedPaths
|
|
23
|
+
} from './emit/rbac/emitRbacApplicationArtifacts.js';
|
|
24
|
+
import {
|
|
25
|
+
dynamicRelationshipFlowSchemaPaths,
|
|
26
|
+
emitDynamicRelationshipFlowSchemas
|
|
27
|
+
} from './emit/relationship/emitDynamicRelationshipFlowSchemas.js';
|
|
28
|
+
import {
|
|
29
|
+
emitRelationshipApplicationArtifacts,
|
|
30
|
+
relationshipApplicationManagedPaths
|
|
31
|
+
} from './emit/relationship/emitRelationshipApplicationArtifacts.js';
|
|
32
|
+
import {
|
|
33
|
+
emitResourceArtifacts,
|
|
34
|
+
resourceArtifactPaths
|
|
35
|
+
} from './emit/resource/emitResourceArtifacts.js';
|
|
36
|
+
import {
|
|
37
|
+
loadLocalSchemaDirectory,
|
|
38
|
+
resolveExtendedObjectSchemas
|
|
39
|
+
} from './compile/loadSchemas.js';
|
|
40
|
+
import {
|
|
41
|
+
emitSystemWebSocketArtifacts,
|
|
42
|
+
hasSystemWebSocket,
|
|
43
|
+
systemWebSocketManagedPaths
|
|
44
|
+
} from './emit/system/emitSystemWebSocketArtifacts.js';
|
|
45
|
+
import {
|
|
46
|
+
emitSystemFindDataArtifacts,
|
|
47
|
+
findDataManagedPaths
|
|
48
|
+
} from './emit/system/emitSystemFindDataArtifacts.js';
|
|
49
|
+
import {
|
|
50
|
+
emitCoreFunctionArtifacts,
|
|
51
|
+
coreFunctionManagedPaths
|
|
52
|
+
} from './emit/coreFunction/emitCoreFunctionArtifacts.js';
|
|
14
53
|
|
|
15
54
|
export async function generate(rootPath, options = {}) {
|
|
16
55
|
const startedAt = Date.now();
|
|
@@ -23,46 +62,137 @@ export async function generate(rootPath, options = {}) {
|
|
|
23
62
|
loadLocalSchemaDirectory(project, 'RelationshipSchemas'),
|
|
24
63
|
loadLocalSchemaDirectory(project, 'FlowSchemas')
|
|
25
64
|
]);
|
|
65
|
+
const schemaBucketName =
|
|
66
|
+
options.schemaBucketName || process.env.iz_serviceSchemaBucketName;
|
|
26
67
|
const objects = await resolveExtendedObjectSchemas(
|
|
27
68
|
rawObjects,
|
|
28
|
-
|
|
69
|
+
schemaBucketName
|
|
29
70
|
);
|
|
30
|
-
logger?.debug?.(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
71
|
+
logger?.debug?.(
|
|
72
|
+
`[DEBUG] [Generate] STATUS=SCHEMAS_LOADED | objects=${objects.length} relationships=${relationships.length} flows=${flows.length}`
|
|
73
|
+
);
|
|
74
|
+
const groups = await _emitGroups({
|
|
75
|
+
project,
|
|
76
|
+
objects,
|
|
77
|
+
relationships,
|
|
78
|
+
flows
|
|
79
|
+
});
|
|
80
|
+
logger?.debug?.(
|
|
81
|
+
`[DEBUG] [Generate] STATUS=ARTIFACTS_EMITTED | ${groups.map((group) => `${group.scope}=${group.artifacts.length}`).join(' ')}`
|
|
82
|
+
);
|
|
83
|
+
let files = [];
|
|
84
|
+
if (groups.length > 0) {
|
|
85
|
+
files = await commitArtifacts(
|
|
86
|
+
buildGenerationPlan(
|
|
87
|
+
project,
|
|
88
|
+
groups.flatMap((group) => group.artifacts),
|
|
89
|
+
{
|
|
90
|
+
managedScopes: Object.fromEntries(
|
|
91
|
+
groups.map((group) => [group.scope, group.managedPaths])
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
38
97
|
const durationMs = Date.now() - startedAt;
|
|
39
|
-
logger?.info?.(
|
|
98
|
+
logger?.info?.(
|
|
99
|
+
`[INFO] [Generate] STATUS=FINISHED | files=${files.length} durationMs=${durationMs}`
|
|
100
|
+
);
|
|
40
101
|
|
|
41
102
|
return { project, durationMs, files };
|
|
42
103
|
} catch (error) {
|
|
43
|
-
logger?.error?.(
|
|
104
|
+
logger?.error?.(
|
|
105
|
+
`[ERROR] [Generate] STATUS=FAILED | durationMs=${Date.now() - startedAt}`,
|
|
106
|
+
error
|
|
107
|
+
);
|
|
44
108
|
throw error;
|
|
45
109
|
}
|
|
46
110
|
}
|
|
47
111
|
|
|
48
|
-
async function
|
|
49
|
-
const [crud, relationship, rbac, system, resource] = await Promise.all([
|
|
50
|
-
emitCrudApplicationArtifacts({
|
|
51
|
-
|
|
112
|
+
async function _emitGroups({ project, objects, relationships, flows }) {
|
|
113
|
+
const [crud, relationship, rbac, system, findData, resource, coreFunction] = await Promise.all([
|
|
114
|
+
emitCrudApplicationArtifacts({
|
|
115
|
+
objects,
|
|
116
|
+
flows,
|
|
117
|
+
serviceTag: project.serviceTag
|
|
118
|
+
}),
|
|
119
|
+
emitRelationshipApplicationArtifacts({
|
|
120
|
+
relationships,
|
|
121
|
+
flows,
|
|
122
|
+
serviceTag: project.serviceTag
|
|
123
|
+
}),
|
|
52
124
|
emitRbacApplicationArtifacts(objects),
|
|
53
125
|
emitSystemWebSocketArtifacts(flows, { includeRelationshipOwnTopic: true }),
|
|
54
|
-
|
|
126
|
+
emitSystemFindDataArtifacts(objects),
|
|
127
|
+
emitResourceArtifacts({ objects, relationships, flows }),
|
|
128
|
+
emitCoreFunctionArtifacts({ project, objects, relationships })
|
|
55
129
|
]);
|
|
56
|
-
const custom = await emitCustomFlowApplicationArtifacts(flows, {
|
|
130
|
+
const custom = await emitCustomFlowApplicationArtifacts(flows, {
|
|
131
|
+
systemFunctions: system.functions,
|
|
132
|
+
objects
|
|
133
|
+
});
|
|
57
134
|
return [
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
135
|
+
{
|
|
136
|
+
scope: 'crud-flow-schemas',
|
|
137
|
+
managedPaths: dynamicCrudFlowSchemaPaths,
|
|
138
|
+
artifacts: emitDynamicCrudFlowSchemas({ objects, flows })
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
scope: 'relationship-flow-schemas',
|
|
142
|
+
managedPaths: dynamicRelationshipFlowSchemaPaths,
|
|
143
|
+
artifacts: emitDynamicRelationshipFlowSchemas()
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
scope: 'rbac-flow-schemas',
|
|
147
|
+
managedPaths: rbacFlowSchemaManagedPaths(objects),
|
|
148
|
+
artifacts: await emitDynamicRbacFlowSchemas({
|
|
149
|
+
objects,
|
|
150
|
+
serviceTag: project.serviceTag
|
|
151
|
+
})
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
scope: 'crud-application',
|
|
155
|
+
managedPaths: crudApplicationManagedPaths(),
|
|
156
|
+
artifacts: crud
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
scope: 'relationship-application',
|
|
160
|
+
managedPaths: relationshipApplicationManagedPaths(),
|
|
161
|
+
artifacts: relationship
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
scope: 'rbac-application',
|
|
165
|
+
managedPaths: rbacApplicationManagedPaths(objects),
|
|
166
|
+
artifacts: rbac
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
scope: 'system-websocket',
|
|
170
|
+
managedPaths: systemWebSocketManagedPaths(),
|
|
171
|
+
artifacts: system.artifacts
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
scope: 'system-find-data',
|
|
175
|
+
managedPaths: findDataManagedPaths(),
|
|
176
|
+
artifacts: findData
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
scope: 'custom-flow-application',
|
|
180
|
+
managedPaths: customFlowApplicationManagedPaths(flows, {
|
|
181
|
+
includeYaml: hasSystemWebSocket(flows, {
|
|
182
|
+
includeRelationshipOwnTopic: true
|
|
183
|
+
})
|
|
184
|
+
}),
|
|
185
|
+
artifacts: custom
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
scope: 'shared-resources',
|
|
189
|
+
managedPaths: resourceArtifactPaths,
|
|
190
|
+
artifacts: resource
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
scope: 'core-function',
|
|
194
|
+
managedPaths: coreFunctionManagedPaths,
|
|
195
|
+
artifacts: coreFunction
|
|
196
|
+
}
|
|
67
197
|
];
|
|
68
198
|
}
|
package/src/generateIntTest.js
CHANGED
|
@@ -14,14 +14,27 @@ You should have received a copy of the GNU Affero General Public License
|
|
|
14
14
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
appendFileSync,
|
|
19
|
+
existsSync,
|
|
20
|
+
mkdirSync,
|
|
21
|
+
readFileSync,
|
|
22
|
+
writeFileSync
|
|
23
|
+
} from 'fs';
|
|
18
24
|
import { join } from 'path';
|
|
19
|
-
import
|
|
25
|
+
import ejsLib from 'ejs';
|
|
20
26
|
import beautify from 'js-beautify/js/index.js';
|
|
21
27
|
|
|
22
28
|
import generateTestTemplate from './generateResources/IntTest/generateTests/generateTemplate.js';
|
|
23
|
-
import {
|
|
24
|
-
|
|
29
|
+
import {
|
|
30
|
+
DEFAULT_BUCKET,
|
|
31
|
+
uploadToS3
|
|
32
|
+
} from './generateResources/IntTest/upload/uploadIntTest.js';
|
|
33
|
+
import {
|
|
34
|
+
getIntTestOutputPath,
|
|
35
|
+
getServiceTag,
|
|
36
|
+
runTemplateItems
|
|
37
|
+
} from './intTestGeneratorShared.js';
|
|
25
38
|
|
|
26
39
|
const BEAUTIFY_SETTING = {
|
|
27
40
|
indent_size: '2',
|
|
@@ -33,9 +46,14 @@ const BEAUTIFY_SETTING = {
|
|
|
33
46
|
space_before_conditional: true
|
|
34
47
|
};
|
|
35
48
|
|
|
36
|
-
async function
|
|
49
|
+
async function _writeSource(
|
|
50
|
+
{ templatePath, templateData, setting },
|
|
51
|
+
{ checkCreateSourcePass = false } = {}
|
|
52
|
+
) {
|
|
37
53
|
if (!templatePath || !templateData || !setting) {
|
|
38
|
-
throw new Error(
|
|
54
|
+
throw new Error(
|
|
55
|
+
'Invalid IntTest source item: missing templatePath/templateData/setting'
|
|
56
|
+
);
|
|
39
57
|
}
|
|
40
58
|
|
|
41
59
|
const {
|
|
@@ -50,7 +68,7 @@ async function writeSource({ templatePath, templateData, setting }, { checkCreat
|
|
|
50
68
|
|
|
51
69
|
if (checkCreateSourcePass) {
|
|
52
70
|
try {
|
|
53
|
-
|
|
71
|
+
ejsLib.compile(readFileSync(templatePath, 'utf8'))(templateData);
|
|
54
72
|
return [true, {}];
|
|
55
73
|
} catch (error) {
|
|
56
74
|
return [false, error];
|
|
@@ -63,36 +81,60 @@ async function writeSource({ templatePath, templateData, setting }, { checkCreat
|
|
|
63
81
|
const filePath = `${savePath}${saveFileName}${fileExtension}`.trim();
|
|
64
82
|
const hookFilePath = `${hookDataPath}${saveFileName}${fileExtension}`.trim();
|
|
65
83
|
|
|
66
|
-
if (!existsSync(savePath))
|
|
67
|
-
|
|
84
|
+
if (!existsSync(savePath)) {
|
|
85
|
+
mkdirSync(savePath, { recursive: true });
|
|
86
|
+
}
|
|
87
|
+
if (generateHookFile && !existsSync(hookDataPath)) {
|
|
88
|
+
mkdirSync(hookDataPath, { recursive: true });
|
|
89
|
+
}
|
|
68
90
|
|
|
69
|
-
let dataToSave =
|
|
91
|
+
let dataToSave = ejsLib.compile(readFileSync(templatePath, 'utf8'))(
|
|
92
|
+
templateData
|
|
93
|
+
);
|
|
70
94
|
|
|
71
95
|
if (existsSync(hookFilePath)) {
|
|
72
96
|
const hookData = readFileSync(hookFilePath, 'utf8');
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
97
|
+
let anyDoubleTag = null;
|
|
98
|
+
let doubleTag = null;
|
|
99
|
+
|
|
100
|
+
if (isJs) {
|
|
101
|
+
anyDoubleTag = new RegExp(
|
|
102
|
+
'\\/\\/\\(<(\\w+)>\\)([\\s\\S]*?)\\/\\/\\(<\\/\\1>\\)',
|
|
103
|
+
'gm'
|
|
104
|
+
);
|
|
105
|
+
doubleTag = (name) =>
|
|
106
|
+
new RegExp(
|
|
107
|
+
`\\/\\/\\(<${name}>\\)([\\s\\S]*?)\\/\\/\\(<\\/${name}>\\)`,
|
|
108
|
+
'gm'
|
|
109
|
+
);
|
|
110
|
+
} else if (isYml) {
|
|
111
|
+
anyDoubleTag = new RegExp(
|
|
112
|
+
'\\#<#(\\w+)#>([\\s\\S]*?)\\#<#\\/\\1#>',
|
|
113
|
+
'gm'
|
|
114
|
+
);
|
|
115
|
+
doubleTag = (name) =>
|
|
116
|
+
new RegExp(`\\#<#${name}#>([\\s\\S]*?)\\#<#\\/${name}#>`, 'gm');
|
|
117
|
+
}
|
|
83
118
|
|
|
84
119
|
if (anyDoubleTag && doubleTag) {
|
|
85
|
-
dataToSave = dataToSave.replace(
|
|
86
|
-
|
|
87
|
-
|
|
120
|
+
dataToSave = dataToSave.replace(
|
|
121
|
+
anyDoubleTag,
|
|
122
|
+
(match, tagName) => hookData.match(doubleTag(tagName)) ?? match
|
|
123
|
+
);
|
|
88
124
|
}
|
|
89
125
|
}
|
|
90
126
|
|
|
91
|
-
if (isJs)
|
|
127
|
+
if (isJs) {
|
|
128
|
+
dataToSave = beautify(dataToSave, BEAUTIFY_SETTING);
|
|
129
|
+
}
|
|
92
130
|
|
|
93
131
|
if (isAppend) {
|
|
94
132
|
const shouldWriteWithInitial = !existsSync(filePath) && initialData;
|
|
95
|
-
|
|
133
|
+
let initialPrefix = '';
|
|
134
|
+
if (shouldWriteWithInitial) {
|
|
135
|
+
initialPrefix = initialData;
|
|
136
|
+
}
|
|
137
|
+
const content = `${initialPrefix}${dataToSave}\n\n`;
|
|
96
138
|
|
|
97
139
|
if (shouldWriteWithInitial) {
|
|
98
140
|
writeFileSync(filePath, content, 'utf8');
|
|
@@ -139,7 +181,9 @@ export async function generateIntTest(rootPath, options = {}) {
|
|
|
139
181
|
const startTime = Date.now();
|
|
140
182
|
const serviceTag = getServiceTag(rootPath);
|
|
141
183
|
if (!serviceTag) {
|
|
142
|
-
throw new Error(
|
|
184
|
+
throw new Error(
|
|
185
|
+
'Missing iz_serviceTag in serverless.config.yml — required IntTest generation'
|
|
186
|
+
);
|
|
143
187
|
}
|
|
144
188
|
|
|
145
189
|
const savePath = getIntTestOutputPath(outputPath, rootPath);
|
|
@@ -150,7 +194,7 @@ export async function generateIntTest(rootPath, options = {}) {
|
|
|
150
194
|
});
|
|
151
195
|
|
|
152
196
|
await runTemplateItems(items, {
|
|
153
|
-
writeSource,
|
|
197
|
+
writeSource: _writeSource,
|
|
154
198
|
errorPrefix: 'IntTest source'
|
|
155
199
|
});
|
|
156
200
|
|
|
@@ -164,11 +208,15 @@ export async function generateIntTest(rootPath, options = {}) {
|
|
|
164
208
|
}
|
|
165
209
|
|
|
166
210
|
const durationMs = Date.now() - startTime;
|
|
211
|
+
let targetBucket = null;
|
|
212
|
+
if (shouldUploadToS3) {
|
|
213
|
+
targetBucket = s3Bucket;
|
|
214
|
+
}
|
|
167
215
|
return {
|
|
168
216
|
serviceTag,
|
|
169
217
|
count: items.length,
|
|
170
218
|
durationMs,
|
|
171
219
|
uploadedCount: uploadedKeys.length,
|
|
172
|
-
s3Bucket:
|
|
220
|
+
s3Bucket: targetBucket
|
|
173
221
|
};
|
|
174
222
|
}
|
|
@@ -16,22 +16,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16
16
|
|
|
17
17
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
18
18
|
import { join } from 'path';
|
|
19
|
-
import
|
|
19
|
+
import ejsLib from 'ejs';
|
|
20
20
|
|
|
21
21
|
import generateResourceTemplate from './generateResources/IntTest/generateResources/generateResources.js';
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
import {
|
|
23
|
+
DEFAULT_BUCKET,
|
|
24
|
+
uploadToS3
|
|
25
|
+
} from './generateResources/IntTest/upload/uploadIntTest.js';
|
|
26
|
+
import {
|
|
27
|
+
getIntTestOutputPath,
|
|
28
|
+
getServiceTag,
|
|
29
|
+
runTemplateItems
|
|
30
|
+
} from './intTestGeneratorShared.js';
|
|
31
|
+
|
|
32
|
+
function _writeSource(
|
|
33
|
+
{ templatePath, templateData, setting },
|
|
34
|
+
{ checkCreateSourcePass = false } = {}
|
|
35
|
+
) {
|
|
26
36
|
if (!templatePath || !templateData || !setting) {
|
|
27
|
-
throw new Error(
|
|
37
|
+
throw new Error(
|
|
38
|
+
'Invalid IntTest resource item: missing templatePath/templateData/setting'
|
|
39
|
+
);
|
|
28
40
|
}
|
|
29
41
|
|
|
30
42
|
const { savePath, saveFileName, fileExtension } = setting;
|
|
31
43
|
|
|
32
44
|
if (checkCreateSourcePass) {
|
|
33
45
|
try {
|
|
34
|
-
|
|
46
|
+
ejsLib.compile(readFileSync(templatePath, 'utf8'))(templateData);
|
|
35
47
|
return [true, {}];
|
|
36
48
|
} catch (error) {
|
|
37
49
|
return [false, error];
|
|
@@ -41,7 +53,9 @@ function writeSource({ templatePath, templateData, setting }, { checkCreateSourc
|
|
|
41
53
|
const filePath = `${savePath}${saveFileName}${fileExtension}`.trim();
|
|
42
54
|
if (!existsSync(savePath)) mkdirSync(savePath, { recursive: true });
|
|
43
55
|
|
|
44
|
-
const dataToSave =
|
|
56
|
+
const dataToSave = ejsLib.compile(readFileSync(templatePath, 'utf8'))(
|
|
57
|
+
templateData
|
|
58
|
+
);
|
|
45
59
|
writeFileSync(filePath, dataToSave, 'utf8');
|
|
46
60
|
return [true, {}];
|
|
47
61
|
}
|
|
@@ -78,14 +92,18 @@ export async function generateResourceIntTest(rootPath, options = {}) {
|
|
|
78
92
|
const startTime = Date.now();
|
|
79
93
|
const serviceTag = getServiceTag(rootPath);
|
|
80
94
|
if (!serviceTag) {
|
|
81
|
-
throw new Error(
|
|
95
|
+
throw new Error(
|
|
96
|
+
'Missing iz_serviceTag in serverless.config.yml — required IntTest resource generation'
|
|
97
|
+
);
|
|
82
98
|
}
|
|
83
99
|
|
|
84
100
|
const savePath = getIntTestOutputPath(outputPath, rootPath);
|
|
85
|
-
const items = await generateResourceTemplate(_izContext, savePath, {
|
|
101
|
+
const items = await generateResourceTemplate(_izContext, savePath, {
|
|
102
|
+
serviceTag
|
|
103
|
+
});
|
|
86
104
|
|
|
87
105
|
await runTemplateItems(items, {
|
|
88
|
-
writeSource,
|
|
106
|
+
writeSource: _writeSource,
|
|
89
107
|
errorPrefix: 'IntTest resource'
|
|
90
108
|
});
|
|
91
109
|
|
|
@@ -98,12 +116,17 @@ export async function generateResourceIntTest(rootPath, options = {}) {
|
|
|
98
116
|
});
|
|
99
117
|
}
|
|
100
118
|
|
|
119
|
+
let resultBucket = null;
|
|
120
|
+
if (shouldUploadToS3) {
|
|
121
|
+
resultBucket = s3Bucket;
|
|
122
|
+
}
|
|
123
|
+
|
|
101
124
|
const durationMs = Date.now() - startTime;
|
|
102
125
|
return {
|
|
103
126
|
serviceTag,
|
|
104
127
|
count: items.length,
|
|
105
128
|
durationMs,
|
|
106
129
|
uploadedCount: uploadedKeys.length,
|
|
107
|
-
s3Bucket:
|
|
130
|
+
s3Bucket: resultBucket
|
|
108
131
|
};
|
|
109
132
|
}
|
|
@@ -20,8 +20,11 @@ import { fileURLToPath } from 'url';
|
|
|
20
20
|
const __filename = fileURLToPath(import.meta.url);
|
|
21
21
|
const __dirname = path.dirname(__filename);
|
|
22
22
|
|
|
23
|
-
import {
|
|
24
|
-
|
|
23
|
+
import {
|
|
24
|
+
getObjectSchema,
|
|
25
|
+
consts as coreConsts
|
|
26
|
+
} from '@izara_project/izara-core-library-service-schemas';
|
|
27
|
+
import libs from '../libs/IntTestGenerateLib.js';
|
|
25
28
|
const { directoryPath } = libs;
|
|
26
29
|
const { STORAGE_TYPES } = coreConsts;
|
|
27
30
|
const templatePath = path.join(__dirname, './templateResources.ejs');
|
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"localHandler": "main",
|
|
7
|
-
"functionName": "<%= funcName %>"
|
|
8
|
-
}<%= index < array.length - 1 ? "," : "" %>
|
|
9
|
-
<% }) %>
|
|
10
|
-
}<%= Object.keys(s3Component).length || Object.keys(tableNames).length ? "," : "" %>
|
|
1
|
+
{ "Lambda": { <% Object.entries(functionComponent).forEach(([funcName,
|
|
2
|
+
filePath], index, array) => { %> "<%= funcName %>": { "localLocation": "/<%= filePath %>.js",
|
|
3
|
+
"localHandler": "main", "functionName": "<%= funcName %>" }<%= index < array.length - 1 ? "," : "" %>
|
|
4
|
+
<% }) %>
|
|
5
|
+
}<%= Object.keys(s3Component).length || Object.keys(tableNames).length ? "," : "" %>
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}<%= index < array.length - 1 ? "," : "" %>
|
|
20
|
-
<% }) %>
|
|
21
|
-
}<%= Object.keys(tableNames).length ? "," : "" %>
|
|
22
|
-
<% } %>
|
|
7
|
+
<% if (Object.keys(s3Component).length) { %>
|
|
8
|
+
"S3": { <% Object.entries(s3Component).forEach(([functionName, filePath], index,
|
|
9
|
+
array) => { %> "<%= functionName %>": { "localLocation": "/<%= filePath %>",
|
|
10
|
+
"localHandler": "main", "functionName": "<%= functionName %>" }<%= index < array.length - 1 ? "," : "" %>
|
|
11
|
+
<% }) %>
|
|
12
|
+
}<%= Object.keys(tableNames).length ? "," : "" %>
|
|
13
|
+
<% } %>
|
|
23
14
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<% }) %>
|
|
31
|
-
}
|
|
32
|
-
<% } %>
|
|
15
|
+
<% if (Object.keys(tableNames).length) { %>
|
|
16
|
+
"Dynamodb": { <% tableNames.forEach((tableName, index) => { %> "<%= tableName %>":
|
|
17
|
+
{ "tableName": "<%= tableName %>" }<%= index < tableNames.length - 1 ? "," : "" %>
|
|
18
|
+
<% }) %>
|
|
19
|
+
}
|
|
20
|
+
<% } %>
|
|
33
21
|
}
|
|
@@ -21,7 +21,7 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
21
21
|
const __dirname = path.dirname(__filename);
|
|
22
22
|
const templatePath = path.join(__dirname, './templateEvents.ejs');
|
|
23
23
|
|
|
24
|
-
import libs from '../../libs/
|
|
24
|
+
import libs from '../../libs/IntTestGenerateLib.js';
|
|
25
25
|
const {
|
|
26
26
|
setEvent,
|
|
27
27
|
createEventCaseByHandler,
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
{ "<%- inputEventTag %>":
|
|
2
|
+
<%- JSON.stringify(inputConfig, null, 2) %>, "<%- outputEventTag %>":
|
|
3
|
+
<%- JSON.stringify(outputConfig, null, 2) %>
|
|
4
|
+
<%- eventDynamos.length ? "," : "" -%>
|
|
5
|
+
<% eventDynamos.forEach((eventDynamo,idx) => { %> "<%- eventDynamo.eventTag %>":
|
|
6
|
+
<%- JSON.stringify(eventDynamo.event,null,2) %>
|
|
7
|
+
<%- idx < eventDynamos.length - 1 ? ",": "" -%>
|
|
8
|
+
<% }) %>
|
|
9
|
+
<%- eventInvokes.length ? "," : "" -%>
|
|
10
|
+
<% eventInvokes.forEach((invokeEventComponent,index) => { %> "<%- invokeEventComponent.inputInvokeName %>":
|
|
11
|
+
<%- JSON.stringify(invokeEventComponent.inputInvoke,null,2) %>, "<%- invokeEventComponent.outputInvokeName %>":
|
|
12
|
+
<%- JSON.stringify(invokeEventComponent.outputInvoke,null,2) %><%- index < eventInvokes.length - 1 ? ",": "" -%>
|
|
13
|
+
<% }) %>
|
|
11
14
|
}
|
|
@@ -20,7 +20,7 @@ import generateEvent from './events/events.js';
|
|
|
20
20
|
import generateTest from './tests/tests.js';
|
|
21
21
|
import generatePathIntTest from './pathIntTest/pathIntTest.js';
|
|
22
22
|
// import generateBashScript from './bashScript/data.js'
|
|
23
|
-
import libs from '../libs/
|
|
23
|
+
import libs from '../libs/IntTestGenerateLib.js';
|
|
24
24
|
const { getIntTestConfig } = libs;
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -66,7 +66,7 @@ async function generateCodeWithTemplate(_izContext, savePath, settings) {
|
|
|
66
66
|
allCreateSource.push(
|
|
67
67
|
...[event, test, intTestBucketPath]
|
|
68
68
|
.flat()
|
|
69
|
-
.filter(item => !(Array.isArray(item) && item.length === 0))
|
|
69
|
+
.filter((item) => !(Array.isArray(item) && item.length === 0))
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
return allCreateSource;
|
|
@@ -21,7 +21,8 @@ import { bucketPathForUpload } from '../../upload/uploadIntTest.js';
|
|
|
21
21
|
const __filename = fileURLToPath(import.meta.url);
|
|
22
22
|
const __dirname = path.dirname(__filename);
|
|
23
23
|
const templatePath = path.join(__dirname, './template.ejs');
|
|
24
|
-
const INT_TEST_SUFFIX_PATTERN =
|
|
24
|
+
const INT_TEST_SUFFIX_PATTERN =
|
|
25
|
+
/(events|tests|resources|dynamoDBSeedDataTags|graphSeedDataTags)\.json$/;
|
|
25
26
|
|
|
26
27
|
async function data(_izContext, srcPath, settings) {
|
|
27
28
|
const pathIntTestInBuckets = await bucketPathForUpload(
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
let intTestPath = [
|
|
2
|
-
<% intTestPaths.forEach((intTestPath,index) => { -%>
|
|
3
|
-
"<%- intTestPath %>"<%= index < intTestPaths.length - 1 ? "," : "" %>
|
|
1
|
+
let intTestPath = [ <% intTestPaths.forEach((intTestPath,index) => { -%> "<%- intTestPath %>"<%= index < intTestPaths.length - 1 ? "," : "" %>
|
|
4
2
|
<% }) -%>
|
|
5
3
|
]
|