@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
|
@@ -112,26 +112,26 @@ test('emits CRUD handlers and function YAML from schema data without reading gen
|
|
|
112
112
|
|
|
113
113
|
test('preserves function-setting hooks across CRUD regeneration', async () => {
|
|
114
114
|
const rootPath = await createProject(true);
|
|
115
|
-
const
|
|
115
|
+
const yamlPath = join(
|
|
116
116
|
rootPath,
|
|
117
|
-
'app/sls_yaml/generatedCode/
|
|
118
|
-
);
|
|
119
|
-
await mkdir(join(rootPath, 'app/sls_yaml/generatedCode/hook'), {
|
|
120
|
-
recursive: true
|
|
121
|
-
});
|
|
122
|
-
await writeFile(
|
|
123
|
-
hookPath,
|
|
124
|
-
' #<#CreateCompleteHdrSqsFunctionSetting#>\n memorySize: 512\n #<#/CreateCompleteHdrSqsFunctionSetting#>\n'
|
|
117
|
+
'app/sls_yaml/generatedCode/source/flow-objects.yml'
|
|
125
118
|
);
|
|
126
119
|
|
|
127
120
|
await generateCrudApplicationArtifacts(rootPath, { serviceTag: 'orders' });
|
|
121
|
+
|
|
122
|
+
const hookCode =
|
|
123
|
+
' #<#CreateCompleteHdrSqsFunctionSetting#>\n memorySize: 512\n #<#/CreateCompleteHdrSqsFunctionSetting#>\n';
|
|
124
|
+
let yaml = await readFile(yamlPath, 'utf8');
|
|
125
|
+
const withHook = yaml.replace(
|
|
126
|
+
/ #<#CreateCompleteHdrSqsFunctionSetting#>[\s\S]*?#<#\/CreateCompleteHdrSqsFunctionSetting#>/,
|
|
127
|
+
hookCode.trim()
|
|
128
|
+
);
|
|
129
|
+
assert.notEqual(yaml, withHook, 'hook placeholder must exist in generated YAML');
|
|
130
|
+
await writeFile(yamlPath, withHook);
|
|
131
|
+
|
|
128
132
|
await generateCrudApplicationArtifacts(rootPath, { serviceTag: 'orders' });
|
|
129
133
|
|
|
130
|
-
|
|
131
|
-
rootPath,
|
|
132
|
-
'app/sls_yaml/generatedCode/source/flow-objects.yml'
|
|
133
|
-
);
|
|
134
|
-
const yaml = await readFile(yamlPath, 'utf8');
|
|
134
|
+
yaml = await readFile(yamlPath, 'utf8');
|
|
135
135
|
assert.match(
|
|
136
136
|
yaml,
|
|
137
137
|
/#<#CreateCompleteHdrSqsFunctionSetting#>\n memorySize: 512\n #<#\/CreateCompleteHdrSqsFunctionSetting#>/
|
|
@@ -149,10 +149,6 @@ test('preserves function-setting hooks across CRUD regeneration', async () => {
|
|
|
149
149
|
/not a file/
|
|
150
150
|
);
|
|
151
151
|
assert.equal(await readFile(yamlPath, 'utf8'), yaml);
|
|
152
|
-
assert.equal(
|
|
153
|
-
await readFile(hookPath, 'utf8'),
|
|
154
|
-
' #<#CreateCompleteHdrSqsFunctionSetting#>\n memorySize: 512\n #<#/CreateCompleteHdrSqsFunctionSetting#>\n'
|
|
155
|
-
);
|
|
156
152
|
});
|
|
157
153
|
|
|
158
154
|
test('removes managed CRUD artifacts when no applicable object remains', async () => {
|
package/test/publicApi.test.js
CHANGED
|
@@ -23,7 +23,7 @@ test('generate commits schemas, application artifacts, and resources in one publ
|
|
|
23
23
|
const rootPath = await createCrudProject();
|
|
24
24
|
const result = await generate(rootPath);
|
|
25
25
|
|
|
26
|
-
assert.strictEqual(result.files.length,
|
|
26
|
+
assert.strictEqual(result.files.length, 41);
|
|
27
27
|
assert.equal(result.project.rootPath, rootPath);
|
|
28
28
|
assert.match(
|
|
29
29
|
await readFile(
|
|
@@ -267,7 +267,7 @@ test('generate removes stale CRUD schemas and application artifacts', async () =
|
|
|
267
267
|
|
|
268
268
|
const result = await generate(rootPath);
|
|
269
269
|
|
|
270
|
-
assert.equal(result.files.length,
|
|
270
|
+
assert.equal(result.files.length, 12);
|
|
271
271
|
await assert.rejects(
|
|
272
272
|
readFile(
|
|
273
273
|
join(
|
|
@@ -19,7 +19,7 @@ test('emits queues, topics, tables, and IAM roles from schema data', async () =>
|
|
|
19
19
|
const rootPath = await createProject();
|
|
20
20
|
const result = await generateResourceArtifacts(rootPath);
|
|
21
21
|
|
|
22
|
-
assert.equal(result.files.length,
|
|
22
|
+
assert.equal(result.files.length, 7);
|
|
23
23
|
const resources = await readFile(
|
|
24
24
|
join(
|
|
25
25
|
rootPath,
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
middlewareHandler as middleware,
|
|
3
|
-
response
|
|
4
|
-
} from '@izara_project/izara-middleware';
|
|
5
|
-
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
6
|
-
|
|
7
|
-
import <%= functionName %> from './<%= mainFileName %>.js';
|
|
8
|
-
|
|
9
|
-
const validatorSchema = {
|
|
10
|
-
//(<validatorSchema>)
|
|
11
|
-
<% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
<% startConfig.properties.forEach(prop => { -%>
|
|
15
|
-
<%- prop.propertyName %>: { type: '<%- prop.type || 'string' %>' }
|
|
16
|
-
<% }) -%>
|
|
17
|
-
},
|
|
18
|
-
required: [<%- startConfig.properties.filter(p => p.required !== false).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
19
|
-
<% } -%>
|
|
20
|
-
//(</validatorSchema>)
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
middleware.setValidatorSchema(validatorSchema, { noAuthorizer: true });
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* GENERATED HANDLER: <%= flowStepName %> (Flow: <%= flowTag %>)
|
|
27
|
-
* Triggered by: API Gateway
|
|
28
|
-
*/
|
|
29
|
-
export const main = middleware.wrap(async (event, context) => {
|
|
30
|
-
event._izContext?.logger?.debug(
|
|
31
|
-
`[${context.awsRequestId}] Received API request in <%= flowStepName %>`
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
const passOnProperties = [
|
|
36
|
-
event.body,
|
|
37
|
-
//(<additionalParams>)
|
|
38
|
-
//(</additionalParams>)
|
|
39
|
-
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
const lambdaFunctionResponse = await <%= functionName %>(
|
|
43
|
-
event._izContext,
|
|
44
|
-
...passOnProperties
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
if (lambdaFunctionResponse instanceof Error) {
|
|
48
|
-
return response.failure(lambdaFunctionResponse);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return response.success(lambdaFunctionResponse);
|
|
52
|
-
} catch (err) {
|
|
53
|
-
event._izContext?.logger?.error(
|
|
54
|
-
'Unhandled Error in <%= flowStepName %> API:',
|
|
55
|
-
err
|
|
56
|
-
);
|
|
57
|
-
return response.failure(err);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
|
|
2
|
-
import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
|
|
3
|
-
|
|
4
|
-
import <%= functionName %> from './<%= mainFileName %>.js';
|
|
5
|
-
|
|
6
|
-
const validatorSchema = {
|
|
7
|
-
//(<validatorSchema>)
|
|
8
|
-
<% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
|
|
9
|
-
type: 'object',
|
|
10
|
-
properties: {
|
|
11
|
-
<% startConfig.properties.forEach(prop => { -%>
|
|
12
|
-
<%- prop.propertyName %>: { type: '<%- prop.type || 'string' %>' }
|
|
13
|
-
<% }) -%>
|
|
14
|
-
},
|
|
15
|
-
required: [<%- startConfig.properties.filter(p => p.required !== false).map(p => `'${p.propertyName}'`).join(', ') %>]
|
|
16
|
-
<% } -%>
|
|
17
|
-
//(</validatorSchema>)
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
middleware.setValidatorSchema(validatorSchema);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* GENERATED HANDLER: <%= flowStepName %> (Flow: <%= flowTag %>)
|
|
24
|
-
* Triggered by: Lambda Invocation
|
|
25
|
-
*/
|
|
26
|
-
export const main = middleware.wrap(async (event, context) => {
|
|
27
|
-
event._izContext?.logger?.debug(
|
|
28
|
-
`[${context.awsRequestId}] Received Invocation in <%= flowStepName %>`
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const passOnProperties = [
|
|
33
|
-
event,
|
|
34
|
-
//(<additionalParams>)
|
|
35
|
-
//(</additionalParams>)
|
|
36
|
-
callingFlowSharedLib.addCallingFlowToPassOnProperties(event)
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
return await <%= functionName %>(event._izContext, ...passOnProperties);
|
|
40
|
-
} catch (err) {
|
|
41
|
-
event._izContext?.logger?.error(
|
|
42
|
-
'Unhandled Error in <%= flowStepName %> Invocation:',
|
|
43
|
-
err
|
|
44
|
-
);
|
|
45
|
-
throw err;
|
|
46
|
-
}
|
|
47
|
-
});
|