@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
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.71",
|
|
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": {
|
package/scripts/format-ejs.js
CHANGED
|
@@ -57,38 +57,42 @@ export async function formatEjsFiles(targetDir = 'src/emit') {
|
|
|
57
57
|
return replacement;
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
try {
|
|
61
|
+
const parser = isYaml ? 'yaml' : 'babel';
|
|
62
|
+
let formatted = await prettier.format(masked, {
|
|
63
|
+
parser,
|
|
64
|
+
singleQuote: true,
|
|
65
|
+
semi: true,
|
|
66
|
+
tabWidth: 2,
|
|
67
|
+
useTabs: false,
|
|
68
|
+
trailingComma: 'none',
|
|
69
|
+
printWidth: 80,
|
|
70
|
+
endOfLine: 'lf'
|
|
71
|
+
});
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
for (const item of placeholders) {
|
|
74
|
+
if (item.isConditionalComma) {
|
|
75
|
+
formatted = formatted.replace(item.replacement, item.original);
|
|
76
|
+
formatted = formatted.replace(
|
|
77
|
+
`, /*__EJS_COMMA_${item.id}__*/`,
|
|
78
|
+
item.original
|
|
79
|
+
);
|
|
80
|
+
} else {
|
|
81
|
+
formatted = formatted.replace(item.replacement, item.original);
|
|
82
|
+
}
|
|
81
83
|
}
|
|
82
|
-
}
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
// Ensure unix newline at EOF
|
|
86
|
+
if (!formatted.endsWith('\n')) {
|
|
87
|
+
formatted += '\n';
|
|
88
|
+
}
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
if (formatted !== content) {
|
|
91
|
+
fs.writeFileSync(filePath, formatted, 'utf8');
|
|
92
|
+
updatedCount++;
|
|
93
|
+
}
|
|
94
|
+
} catch (err) {
|
|
95
|
+
console.warn(`[WARN] Skipping ${filePath}: prettier error: ${err.message}`);
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
|
|
@@ -96,9 +100,10 @@ export async function formatEjsFiles(targetDir = 'src/emit') {
|
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
if (process.argv[1] === new URL(import.meta.url).pathname) {
|
|
99
|
-
|
|
103
|
+
const targetDir = process.argv[2] || 'src/emit';
|
|
104
|
+
formatEjsFiles(targetDir).then(({ total, updated }) => {
|
|
100
105
|
console.log(
|
|
101
|
-
`Successfully formatted ${updated} / ${total} EJS template files in
|
|
106
|
+
`Successfully formatted ${updated} / ${total} EJS template files in ${targetDir}.`
|
|
102
107
|
);
|
|
103
108
|
});
|
|
104
109
|
}
|
|
@@ -97,63 +97,102 @@ export async function loadLocalSchemaDirectory(project, directoryName) {
|
|
|
97
97
|
* @returns {Promise<Object[]>} The same array with extended storageResources
|
|
98
98
|
* merged in.
|
|
99
99
|
*/
|
|
100
|
-
export async function resolveExtendedObjectSchemas(
|
|
100
|
+
export async function resolveExtendedObjectSchemas(
|
|
101
|
+
objectSchemas,
|
|
102
|
+
bucketName = process.env.iz_serviceSchemaBucketName
|
|
103
|
+
) {
|
|
101
104
|
if (!Array.isArray(objectSchemas)) {
|
|
102
105
|
throw new TypeError('objectSchemas must be an array');
|
|
103
106
|
}
|
|
104
107
|
const resolvedSchemas = [];
|
|
105
108
|
for (const schema of objectSchemas) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
let currentSchema = schema;
|
|
110
|
+
if (currentSchema.hasOwnProperty('extendObjType')) {
|
|
111
|
+
try {
|
|
112
|
+
Logger.debug(
|
|
113
|
+
`[DEBUG] [resolveExtendedObjectSchemas] Merging extendObjType for objectType=${currentSchema.objectType}`,
|
|
114
|
+
{ extendObjType: currentSchema.extendObjType }
|
|
115
|
+
);
|
|
116
|
+
const initialResources = currentSchema.storageResources || {};
|
|
117
|
+
const childStorageResourceKeys = new Set(Object.keys(initialResources));
|
|
118
|
+
const parentServiceTag = currentSchema.extendObjType.serviceTag;
|
|
115
119
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
const mergedSchema = await getObjectSchema.mergeExtendObjSchema(
|
|
121
|
+
{ logger: Logger },
|
|
122
|
+
currentSchema,
|
|
123
|
+
bucketName
|
|
124
|
+
);
|
|
121
125
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
ownStorageResources[key] = resource;
|
|
126
|
+
const externalDynamoResources = [];
|
|
127
|
+
const ownStorageResources = {};
|
|
128
|
+
const mergedStorageResources = mergedSchema.storageResources || {};
|
|
129
|
+
for (const [key, resource] of Object.entries(mergedStorageResources)) {
|
|
130
|
+
if (
|
|
131
|
+
resource &&
|
|
132
|
+
resource.storageType === 'dynamoDB' &&
|
|
133
|
+
!childStorageResourceKeys.has(key)
|
|
134
|
+
) {
|
|
135
|
+
externalDynamoResources.push({
|
|
136
|
+
serviceTag: parentServiceTag,
|
|
137
|
+
tableName: resource.tableName
|
|
138
|
+
});
|
|
139
|
+
} else {
|
|
140
|
+
ownStorageResources[key] = resource;
|
|
141
|
+
}
|
|
140
142
|
}
|
|
141
|
-
}
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
mergedSchema.storageResources = ownStorageResources;
|
|
145
|
+
if (externalDynamoResources.length > 0) {
|
|
146
|
+
mergedSchema.externalDynamoResources = externalDynamoResources;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
currentSchema = mergedSchema;
|
|
150
|
+
} catch (error) {
|
|
151
|
+
Logger.error(
|
|
152
|
+
`[ERROR] [resolveExtendedObjectSchemas] Failed to merge extendObjType for objectType=${currentSchema.objectType}`,
|
|
153
|
+
{ error }
|
|
154
|
+
);
|
|
155
|
+
throw error;
|
|
146
156
|
}
|
|
157
|
+
}
|
|
147
158
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
159
|
+
/*
|
|
160
|
+
if (
|
|
161
|
+
currentSchema.hasOwnProperty('belongTo') &&
|
|
162
|
+
currentSchema.belongTo &&
|
|
163
|
+
currentSchema.belongTo.serviceTag &&
|
|
164
|
+
currentSchema.belongTo.objectType
|
|
165
|
+
) {
|
|
166
|
+
try {
|
|
167
|
+
Logger.debug(
|
|
168
|
+
`[DEBUG] [resolveExtendedObjectSchemas] Fetching belongTo schema for objectType=${currentSchema.objectType}`,
|
|
169
|
+
{ belongTo: currentSchema.belongTo }
|
|
170
|
+
);
|
|
171
|
+
const belongToObjType = {
|
|
172
|
+
serviceTag: currentSchema.belongTo.serviceTag,
|
|
173
|
+
objectType: currentSchema.belongTo.objectType
|
|
174
|
+
};
|
|
175
|
+
const belongToSchema = await getObjectSchema.getObjSchemaS3(
|
|
176
|
+
{ logger: Logger },
|
|
177
|
+
belongToObjType,
|
|
178
|
+
false,
|
|
179
|
+
bucketName
|
|
180
|
+
);
|
|
181
|
+
currentSchema.belongToSchema = belongToSchema;
|
|
182
|
+
Logger.debug(
|
|
183
|
+
`[DEBUG] [resolveExtendedObjectSchemas] Successfully fetched belongTo schema for objectType=${currentSchema.objectType}`,
|
|
184
|
+
{ belongToObjectType: belongToSchema?.objectType }
|
|
185
|
+
);
|
|
186
|
+
} catch (error) {
|
|
187
|
+
Logger.warn(
|
|
188
|
+
`[WARN] [resolveExtendedObjectSchemas] Failed to fetch belongTo schema for objectType=${currentSchema.objectType}`,
|
|
189
|
+
{ error }
|
|
190
|
+
);
|
|
191
|
+
}
|
|
156
192
|
}
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
resolvedSchemas.push(currentSchema);
|
|
157
196
|
}
|
|
158
197
|
return resolvedSchemas;
|
|
159
198
|
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import ejsLib from 'ejs';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
|
|
4
|
+
const TEMPLATE_URL = new URL('./templates/', import.meta.url);
|
|
5
|
+
const APP_ROOT = 'app/sls_yaml/generatedCode/source';
|
|
6
|
+
const SRC_ROOT = 'app/src/generatedCode/CoreFunctions';
|
|
7
|
+
|
|
8
|
+
export const coreFunctionManagedPaths = [
|
|
9
|
+
`${APP_ROOT}/core-function.yml`,
|
|
10
|
+
`${APP_ROOT}/core-resource.yml`,
|
|
11
|
+
`${SRC_ROOT}/UploadSchema_HdrInv.js`,
|
|
12
|
+
`${SRC_ROOT}/UploadSchema_Main.js`,
|
|
13
|
+
`${SRC_ROOT}/GenerateSeedDataDynamo_HdrInv.js`,
|
|
14
|
+
`${SRC_ROOT}/GenerateSeedDataDynamo_Main.js`,
|
|
15
|
+
`${SRC_ROOT}/RemoveSeedDataDynamo_HdrInv.js`,
|
|
16
|
+
`${SRC_ROOT}/RemoveSeedDataDynamo_Main.js`,
|
|
17
|
+
`${SRC_ROOT}/GenerateSeedDataGraphData_HdrInv.js`,
|
|
18
|
+
`${SRC_ROOT}/GenerateSeedDataGraphData_Main.js`,
|
|
19
|
+
`${SRC_ROOT}/GenerateSeedDataGraphSchema_HdrInv.js`,
|
|
20
|
+
`${SRC_ROOT}/GenerateSeedDataGraphSchema_Main.js`,
|
|
21
|
+
`${SRC_ROOT}/InitialSetup_HdrInv.js`,
|
|
22
|
+
`${SRC_ROOT}/InitialSetup_Main.js`,
|
|
23
|
+
`${SRC_ROOT}/generated/GeneratedTableConfigs.js`,
|
|
24
|
+
`${SRC_ROOT}/generated/GeneratedGraphNodeSchemas.js`,
|
|
25
|
+
`${SRC_ROOT}/generated/GeneratedGraphRelSchemas.js`,
|
|
26
|
+
`${SRC_ROOT}/InitialSetupConfig.js`
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
export async function emitCoreFunctionArtifacts({ project, objects = [], relationships = [] }) {
|
|
30
|
+
const state = {
|
|
31
|
+
project,
|
|
32
|
+
objects,
|
|
33
|
+
relationships,
|
|
34
|
+
hasGenerateGraph: objects.length > 0 || relationships.length > 0
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const [
|
|
38
|
+
coreFunctionYaml,
|
|
39
|
+
coreResourceYaml,
|
|
40
|
+
uploadSchemaHdrInv,
|
|
41
|
+
uploadSchemaMain,
|
|
42
|
+
generateSeedDataDynamoHdrInv,
|
|
43
|
+
generateSeedDataDynamoMain,
|
|
44
|
+
removeSeedDataDynamoHdrInv,
|
|
45
|
+
removeSeedDataDynamoMain,
|
|
46
|
+
generateSeedDataGraphDataHdrInv,
|
|
47
|
+
generateSeedDataGraphDataMain,
|
|
48
|
+
generateSeedDataGraphSchemaHdrInv,
|
|
49
|
+
generateSeedDataGraphSchemaMain,
|
|
50
|
+
generatedTableConfigs,
|
|
51
|
+
generatedGraphNodeSchemas,
|
|
52
|
+
generatedGraphRelSchemas,
|
|
53
|
+
initialSetupConfig,
|
|
54
|
+
initialSetupHdrInv,
|
|
55
|
+
initialSetupMain
|
|
56
|
+
] = await Promise.all([
|
|
57
|
+
render('CoreFunction_Yaml.ejs', state),
|
|
58
|
+
render('CoreResource_Yaml.ejs', state),
|
|
59
|
+
render('UploadSchema_HdrInv.ejs', state),
|
|
60
|
+
render('UploadSchema_Main.ejs', state),
|
|
61
|
+
render('GenerateSeedDataDynamo_HdrInv.ejs', state),
|
|
62
|
+
render('GenerateSeedDataDynamo_Main.ejs', state),
|
|
63
|
+
render('RemoveSeedDataDynamo_HdrInv.ejs', state),
|
|
64
|
+
render('RemoveSeedDataDynamo_Main.ejs', state),
|
|
65
|
+
render('GenerateSeedDataGraphData_HdrInv.ejs', state),
|
|
66
|
+
render('GenerateSeedDataGraphData_Main.ejs', state),
|
|
67
|
+
render('GenerateSeedDataGraphSchema_HdrInv.ejs', state),
|
|
68
|
+
render('GenerateSeedDataGraphSchema_Main.ejs', state),
|
|
69
|
+
render('GeneratedTableConfigs.ejs', state),
|
|
70
|
+
render('GeneratedGraphNodeSchemas.ejs', state),
|
|
71
|
+
render('GeneratedGraphRelSchemas.ejs', state),
|
|
72
|
+
render('InitialSetupConfig.ejs', state),
|
|
73
|
+
render('InitialSetup_HdrInv.ejs', state),
|
|
74
|
+
render('InitialSetup_Main.ejs', state)
|
|
75
|
+
]);
|
|
76
|
+
|
|
77
|
+
return [
|
|
78
|
+
{
|
|
79
|
+
path: `${APP_ROOT}/core-function.yml`,
|
|
80
|
+
content: normalizeYaml(coreFunctionYaml)
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
path: `${APP_ROOT}/core-resource.yml`,
|
|
84
|
+
content: normalizeYaml(coreResourceYaml)
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
path: `${SRC_ROOT}/UploadSchema_HdrInv.js`,
|
|
88
|
+
content: uploadSchemaHdrInv
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
path: `${SRC_ROOT}/UploadSchema_Main.js`,
|
|
92
|
+
content: uploadSchemaMain
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
path: `${SRC_ROOT}/GenerateSeedDataDynamo_HdrInv.js`,
|
|
96
|
+
content: generateSeedDataDynamoHdrInv
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
path: `${SRC_ROOT}/GenerateSeedDataDynamo_Main.js`,
|
|
100
|
+
content: generateSeedDataDynamoMain
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
path: `${SRC_ROOT}/RemoveSeedDataDynamo_HdrInv.js`,
|
|
104
|
+
content: removeSeedDataDynamoHdrInv
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
path: `${SRC_ROOT}/RemoveSeedDataDynamo_Main.js`,
|
|
108
|
+
content: removeSeedDataDynamoMain
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
path: `${SRC_ROOT}/GenerateSeedDataGraphData_HdrInv.js`,
|
|
112
|
+
content: generateSeedDataGraphDataHdrInv
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
path: `${SRC_ROOT}/GenerateSeedDataGraphData_Main.js`,
|
|
116
|
+
content: generateSeedDataGraphDataMain
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
path: `${SRC_ROOT}/GenerateSeedDataGraphSchema_HdrInv.js`,
|
|
120
|
+
content: generateSeedDataGraphSchemaHdrInv
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
path: `${SRC_ROOT}/GenerateSeedDataGraphSchema_Main.js`,
|
|
124
|
+
content: generateSeedDataGraphSchemaMain
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
path: `${SRC_ROOT}/generated/GeneratedTableConfigs.js`,
|
|
128
|
+
content: generatedTableConfigs
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
path: `${SRC_ROOT}/generated/GeneratedGraphNodeSchemas.js`,
|
|
132
|
+
content: generatedGraphNodeSchemas
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
path: `${SRC_ROOT}/generated/GeneratedGraphRelSchemas.js`,
|
|
136
|
+
content: generatedGraphRelSchemas
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
path: `${SRC_ROOT}/InitialSetupConfig.js`,
|
|
140
|
+
content: initialSetupConfig,
|
|
141
|
+
writeWhenFileExist: false // Don't overwrite the file that dev modifies
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
path: `${SRC_ROOT}/InitialSetup_HdrInv.js`,
|
|
145
|
+
content: initialSetupHdrInv
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
path: `${SRC_ROOT}/InitialSetup_Main.js`,
|
|
149
|
+
content: initialSetupMain
|
|
150
|
+
}
|
|
151
|
+
];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function normalizeYaml(content) {
|
|
155
|
+
return `${content.trimEnd()}\n`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function render(templateName, data) {
|
|
159
|
+
return ejsLib.render(
|
|
160
|
+
await readFile(new URL(templateName, TEMPLATE_URL), 'utf8'),
|
|
161
|
+
data
|
|
162
|
+
);
|
|
163
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# --- FOR PROD STAGE
|
|
2
|
+
UploadSchemaHdrInv:
|
|
3
|
+
handler: src/generatedCode/CoreFunctions/UploadSchema_HdrInv.main
|
|
4
|
+
name: ${self:custom.iz_resourcePrefix}UploadSchemaHdrInv
|
|
5
|
+
role: UploadSchemaRole
|
|
6
|
+
timeout: 30
|
|
7
|
+
#<#UploadSchemaHdrInvHookCode#>
|
|
8
|
+
#<#/UploadSchemaHdrInvHookCode#>
|
|
9
|
+
|
|
10
|
+
# --- FOR TEST STAGE
|
|
11
|
+
GenerateSeedGraph: # --- FOR TEST STAGE
|
|
12
|
+
handler: src/generatedCode/CoreFunctions/GenerateSeedDataGraphData_HdrInv.main
|
|
13
|
+
name: ${self:custom.iz_resourcePrefix}GenerateSeedDataGraphDataTestEnv
|
|
14
|
+
role: GenerateSeedGraphRole
|
|
15
|
+
#<#GenerateSeedGraphHookCode#>
|
|
16
|
+
#<#/GenerateSeedGraphHookCode#>
|
|
17
|
+
|
|
18
|
+
GenerateGraphSchema:
|
|
19
|
+
handler: src/generatedCode/CoreFunctions/GenerateSeedDataGraphSchema_HdrInv.main
|
|
20
|
+
name: ${self:custom.iz_resourcePrefix}GenerateSeedDataGraphSchemaTestEnv
|
|
21
|
+
role: GenerateGraphSchemaRole
|
|
22
|
+
#<#GenerateGraphSchemaHookCode#>
|
|
23
|
+
#<#/GenerateGraphSchemaHookCode#>
|
|
24
|
+
|
|
25
|
+
RemoveSeedDataDynamo:
|
|
26
|
+
handler: src/generatedCode/CoreFunctions/RemoveSeedDataDynamo_HdrInv.main
|
|
27
|
+
name: ${self:custom.iz_resourcePrefix}RemoveSeedDataDynamo
|
|
28
|
+
role: RemoveSeedDataDynamoRole
|
|
29
|
+
#<#RemoveSeedDataDynamoHookCode#>
|
|
30
|
+
#<#/RemoveSeedDataDynamoHookCode#>
|
|
31
|
+
|
|
32
|
+
InitialSetup:
|
|
33
|
+
handler: src/generatedCode/CoreFunctions/InitialSetup_HdrInv.main
|
|
34
|
+
name: ${self:custom.iz_resourcePrefix}InitialSetup
|
|
35
|
+
role: InitialSetupRole
|
|
36
|
+
timeout: 300
|
|
37
|
+
#<#InitialSetupHookCode#>
|
|
38
|
+
#<#/InitialSetupHookCode#>
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Resources:
|
|
2
|
+
UploadSchemaRole:
|
|
3
|
+
Type: AWS::IAM::Role
|
|
4
|
+
Properties:
|
|
5
|
+
RoleName: ${self:custom.iz_resourcePrefix}UploadSchemaRole
|
|
6
|
+
AssumeRolePolicyDocument:
|
|
7
|
+
Version: '2012-10-17'
|
|
8
|
+
Statement:
|
|
9
|
+
- Effect: Allow
|
|
10
|
+
Principal:
|
|
11
|
+
Service: 'lambda.amazonaws.com'
|
|
12
|
+
Action: sts:AssumeRole
|
|
13
|
+
#<#UploadSchemaRoleAssumeRoleStatementHookCode#>
|
|
14
|
+
#<#/UploadSchemaRoleAssumeRoleStatementHookCode#>
|
|
15
|
+
ManagedPolicyArns:
|
|
16
|
+
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
|
|
17
|
+
#<#UploadSchemaRoleManagedPolicyArns#>
|
|
18
|
+
#<#/UploadSchemaRoleManagedPolicyArns#>
|
|
19
|
+
Policies:
|
|
20
|
+
- PolicyName: ${self:custom.iz_resourcePrefix}UploadSchemaPolicy
|
|
21
|
+
PolicyDocument:
|
|
22
|
+
Version: '2012-10-17'
|
|
23
|
+
Statement:
|
|
24
|
+
- Effect: Allow
|
|
25
|
+
Action:
|
|
26
|
+
- s3:PutObject
|
|
27
|
+
- s3:GetObject
|
|
28
|
+
- s3:ListBucket
|
|
29
|
+
- s3:DeleteObject
|
|
30
|
+
Resource:
|
|
31
|
+
- arn:aws:s3:::${self:custom.iz_serviceSchemaBucketName}
|
|
32
|
+
- arn:aws:s3:::${self:custom.iz_serviceSchemaBucketName}/*
|
|
33
|
+
- arn:aws:s3:::${self:custom.iz_serviceSchemaBucketName}/perServiceSchemas/${self:custom.iz_serviceTag}/*
|
|
34
|
+
- Effect: Allow
|
|
35
|
+
Action:
|
|
36
|
+
- apigateway:GET
|
|
37
|
+
Resource:
|
|
38
|
+
- arn:aws:apigateway:${self:custom.iz_region}::/*
|
|
39
|
+
- Effect: Allow
|
|
40
|
+
Action:
|
|
41
|
+
- lambda:InvokeFunction
|
|
42
|
+
Resource:
|
|
43
|
+
- arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:${self:custom.iz_resourcePrefix}AddLinkCreateByRelHdrInv
|
|
44
|
+
- arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:${self:custom.iz_resourcePrefix}AddLinkBelongToHdrInv
|
|
45
|
+
- arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:GraphHandler${self:custom.iz_stage}CreateAllIndexSchemasHdrInv
|
|
46
|
+
- arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:TranslateIds${self:custom.iz_stage}CreatePermissionHdrInv
|
|
47
|
+
- arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:Translations${self:custom.iz_stage}AddLinkToTranslationLinksHdrInv
|
|
48
|
+
- Effect: Allow
|
|
49
|
+
Action:
|
|
50
|
+
- sns:Publish
|
|
51
|
+
Resource:
|
|
52
|
+
- arn:aws:sns:${self:custom.iz_region}:${self:custom.iz_accountId}:Translations_${self:custom.iz_stage}_RegisterSystemTag_In
|
|
53
|
+
#<#UploadSchemaRoleStatementHookCode#>
|
|
54
|
+
#<#/UploadSchemaRoleStatementHookCode#>
|
|
55
|
+
|
|
56
|
+
GenerateSeedDynamoRole:
|
|
57
|
+
Type: AWS::IAM::Role
|
|
58
|
+
Properties:
|
|
59
|
+
RoleName: ${self:custom.iz_resourcePrefix}GenerateSeedDynamoRole
|
|
60
|
+
AssumeRolePolicyDocument:
|
|
61
|
+
Version: '2012-10-17'
|
|
62
|
+
Statement:
|
|
63
|
+
- Effect: Allow
|
|
64
|
+
Principal:
|
|
65
|
+
Service: lambda.amazonaws.com
|
|
66
|
+
Action: sts:AssumeRole
|
|
67
|
+
#<#GenerateSeedDynamoRoleAssumeRoleStatementHookCode#>
|
|
68
|
+
#<#/GenerateSeedDynamoRoleAssumeRoleStatementHookCode#>
|
|
69
|
+
ManagedPolicyArns:
|
|
70
|
+
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
|
|
71
|
+
#<#GenerateSeedDynamoRoleManagedPolicyArns#>
|
|
72
|
+
#<#/GenerateSeedDynamoRoleManagedPolicyArns#>
|
|
73
|
+
Policies:
|
|
74
|
+
- PolicyName: ${self:custom.iz_resourcePrefix}GenerateSeedDynamoPolicy
|
|
75
|
+
PolicyDocument:
|
|
76
|
+
Version: '2012-10-17'
|
|
77
|
+
Statement:
|
|
78
|
+
- Effect: Allow
|
|
79
|
+
Action:
|
|
80
|
+
- dynamodb:PutItem
|
|
81
|
+
Resource:
|
|
82
|
+
- arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/${self:custom.iz_resourcePrefix}Config
|
|
83
|
+
#<#GenerateSeedDynamoRoleStatementHookCode#>
|
|
84
|
+
#<#/GenerateSeedDynamoRoleStatementHookCode#>
|
|
85
|
+
|
|
86
|
+
GenerateSeedGraphRole:
|
|
87
|
+
Type: AWS::IAM::Role
|
|
88
|
+
Properties:
|
|
89
|
+
RoleName: ${self:custom.iz_resourcePrefix}GenerateSeedGraphRole
|
|
90
|
+
AssumeRolePolicyDocument:
|
|
91
|
+
Version: '2012-10-17'
|
|
92
|
+
Statement:
|
|
93
|
+
- Effect: Allow
|
|
94
|
+
Principal:
|
|
95
|
+
Service: lambda.amazonaws.com
|
|
96
|
+
Action: sts:AssumeRole
|
|
97
|
+
#<#GenerateSeedGraphRoleAssumeRoleStatementHookCode#>
|
|
98
|
+
#<#/GenerateSeedGraphRoleAssumeRoleStatementHookCode#>
|
|
99
|
+
ManagedPolicyArns:
|
|
100
|
+
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
|
|
101
|
+
#<#GenerateSeedGraphRoleManagedPolicyArns#>
|
|
102
|
+
#<#/GenerateSeedGraphRoleManagedPolicyArns#>
|
|
103
|
+
Policies:
|
|
104
|
+
- PolicyName: ${self:custom.iz_resourcePrefix}GenerateSeedGraphPolicy
|
|
105
|
+
PolicyDocument:
|
|
106
|
+
Version: '2012-10-17'
|
|
107
|
+
Statement:
|
|
108
|
+
- Effect: Allow
|
|
109
|
+
Action:
|
|
110
|
+
- dynamodb:GetItem
|
|
111
|
+
Resource:
|
|
112
|
+
- arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/${self:custom.iz_resourcePrefix}Config
|
|
113
|
+
- Effect: Allow
|
|
114
|
+
Action:
|
|
115
|
+
- SNS:Publish
|
|
116
|
+
Resource:
|
|
117
|
+
- arn:aws:sns:${self:custom.iz_region}:${self:custom.iz_accountId}:GraphHandler_${self:custom.iz_stage}_CreateNode_In
|
|
118
|
+
- arn:aws:sns:${self:custom.iz_region}:${self:custom.iz_accountId}:GraphHandler_${self:custom.iz_stage}_UpdateNode_In
|
|
119
|
+
- arn:aws:sns:${self:custom.iz_region}:${self:custom.iz_accountId}:GraphHandler_${self:custom.iz_stage}_CreateRelationship_In
|
|
120
|
+
#<#GenerateSeedGraphRoleStatementHookCode#>
|
|
121
|
+
#<#/GenerateSeedGraphRoleStatementHookCode#>
|
|
122
|
+
|
|
123
|
+
GenerateGraphSchemaRole:
|
|
124
|
+
Type: AWS::IAM::Role
|
|
125
|
+
Properties:
|
|
126
|
+
RoleName: ${self:custom.iz_resourcePrefix}GenerateGraphSchemaRole
|
|
127
|
+
AssumeRolePolicyDocument:
|
|
128
|
+
Version: '2012-10-17'
|
|
129
|
+
Statement:
|
|
130
|
+
- Effect: Allow
|
|
131
|
+
Principal:
|
|
132
|
+
Service: lambda.amazonaws.com
|
|
133
|
+
Action: sts:AssumeRole
|
|
134
|
+
#<#GenerateGraphSchemaRoleAssumeRoleStatementHookCode#>
|
|
135
|
+
#<#/GenerateGraphSchemaRoleAssumeRoleStatementHookCode#>
|
|
136
|
+
ManagedPolicyArns:
|
|
137
|
+
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
|
|
138
|
+
#<#GenerateGraphSchemaRoleManagedPolicyArns#>
|
|
139
|
+
#<#/GenerateGraphSchemaRoleManagedPolicyArns#>
|
|
140
|
+
Policies:
|
|
141
|
+
- PolicyName: ${self:custom.iz_resourcePrefix}GenerateGraphSchemaPolicy
|
|
142
|
+
PolicyDocument:
|
|
143
|
+
Version: '2012-10-17'
|
|
144
|
+
Statement:
|
|
145
|
+
- Effect: Allow
|
|
146
|
+
Action:
|
|
147
|
+
- lambda:InvokeFunction
|
|
148
|
+
- dynamodb:GetItem
|
|
149
|
+
Resource:
|
|
150
|
+
- arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/*NodeSchema
|
|
151
|
+
- arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/*RelationshipSchema
|
|
152
|
+
- arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:*AddNodeSchemasHdrInv
|
|
153
|
+
- arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:*AddRelationshipSchemasHdrInv
|
|
154
|
+
#<#GenerateGraphSchemaRoleStatementHookCode#>
|
|
155
|
+
#<#/GenerateGraphSchemaRoleStatementHookCode#>
|
|
156
|
+
|
|
157
|
+
RemoveSeedDataDynamoRole:
|
|
158
|
+
Type: AWS::IAM::Role
|
|
159
|
+
Properties:
|
|
160
|
+
RoleName: ${self:custom.iz_resourcePrefix}RemoveSeedDataDynamoRole
|
|
161
|
+
AssumeRolePolicyDocument:
|
|
162
|
+
Version: '2012-10-17'
|
|
163
|
+
Statement:
|
|
164
|
+
- Effect: Allow
|
|
165
|
+
Principal:
|
|
166
|
+
Service: lambda.amazonaws.com
|
|
167
|
+
Action: sts:AssumeRole
|
|
168
|
+
#<#RemoveSeedDataDynamoRoleAssumeRoleStatementHookCode#>
|
|
169
|
+
#<#/RemoveSeedDataDynamoRoleAssumeRoleStatementHookCode#>
|
|
170
|
+
ManagedPolicyArns:
|
|
171
|
+
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
|
|
172
|
+
#<#RemoveSeedDataDynamoRoleManagedPolicyArns#>
|
|
173
|
+
#<#/RemoveSeedDataDynamoRoleManagedPolicyArns#>
|
|
174
|
+
Policies:
|
|
175
|
+
- PolicyName: ${self:custom.iz_resourcePrefix}RemoveSeedDataDynamoPolicy
|
|
176
|
+
PolicyDocument:
|
|
177
|
+
Version: '2012-10-17'
|
|
178
|
+
Statement:
|
|
179
|
+
- Effect: Allow
|
|
180
|
+
Action:
|
|
181
|
+
- dynamodb:Scan
|
|
182
|
+
- dynamodb:DescribeTable
|
|
183
|
+
- dynamodb:GetItem
|
|
184
|
+
- dynamodb:PutItem
|
|
185
|
+
- dynamodb:DeleteItem
|
|
186
|
+
Resource:
|
|
187
|
+
- arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/${self:custom.iz_resourcePrefix}Config
|
|
188
|
+
#<#RemoveSeedDataDynamoRoleStatementHookCode#>
|
|
189
|
+
#<#/RemoveSeedDataDynamoRoleStatementHookCode#>
|
|
190
|
+
|
|
191
|
+
InitialSetupRole:
|
|
192
|
+
Type: AWS::IAM::Role
|
|
193
|
+
Properties:
|
|
194
|
+
RoleName: ${self:custom.iz_resourcePrefix}InitialSetupRole
|
|
195
|
+
AssumeRolePolicyDocument:
|
|
196
|
+
Version: '2012-10-17'
|
|
197
|
+
Statement:
|
|
198
|
+
- Effect: Allow
|
|
199
|
+
Principal:
|
|
200
|
+
Service: lambda.amazonaws.com
|
|
201
|
+
Action: sts:AssumeRole
|
|
202
|
+
#<#InitialSetupRoleAssumeRoleStatementHookCode#>
|
|
203
|
+
#<#/InitialSetupRoleAssumeRoleStatementHookCode#>
|
|
204
|
+
ManagedPolicyArns:
|
|
205
|
+
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
|
|
206
|
+
- arn:aws:iam::aws:policy/IAMFullAccess
|
|
207
|
+
#<#InitialSetupRoleManagedPolicyArns#>
|
|
208
|
+
#<#/InitialSetupRoleManagedPolicyArns#>
|
|
209
|
+
Policies:
|
|
210
|
+
- PolicyName: ${self:custom.iz_resourcePrefix}InitialSetupPolicy
|
|
211
|
+
PolicyDocument:
|
|
212
|
+
Version: '2012-10-17'
|
|
213
|
+
Statement:
|
|
214
|
+
- Effect: Allow
|
|
215
|
+
Action:
|
|
216
|
+
- dynamodb:PutItem
|
|
217
|
+
- dynamodb:GetItem
|
|
218
|
+
Resource:
|
|
219
|
+
- arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/${self:custom.iz_resourcePrefix}Config
|
|
220
|
+
- Effect: Allow
|
|
221
|
+
Action:
|
|
222
|
+
- lambda:InvokeFunction
|
|
223
|
+
- dynamodb:GetItem
|
|
224
|
+
Resource:
|
|
225
|
+
- arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/*NodeSchema
|
|
226
|
+
- arn:aws:dynamodb:${self:custom.iz_region}:${self:custom.iz_accountId}:table/*RelationshipSchema
|
|
227
|
+
- arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:*AddNodeSchemasHdrInv
|
|
228
|
+
- arn:aws:lambda:${self:custom.iz_region}:${self:custom.iz_accountId}:function:*AddRelationshipSchemasHdrInv
|
|
229
|
+
- Effect: Allow
|
|
230
|
+
Action:
|
|
231
|
+
- sns:Publish
|
|
232
|
+
Resource:
|
|
233
|
+
- arn:aws:sns:${self:custom.iz_region}:${self:custom.iz_accountId}:*
|
|
234
|
+
#<#InitialSetupRoleStatementHookCode#>
|
|
235
|
+
#<#/InitialSetupRoleStatementHookCode#>
|