@izara_project/izara-core-generate-service-code 1.0.71 → 1.0.73

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.
Files changed (67) hide show
  1. package/package.json +4 -3
  2. package/src/compile/loadSchemas.js +69 -1
  3. package/src/emit/coreFunction/emitCoreFunctionArtifacts.js +171 -44
  4. package/src/emit/coreFunction/templates/GenerateSeedDataDynamo_HdrInv.ejs +4 -1
  5. package/src/emit/coreFunction/templates/GenerateSeedDataGraphData_HdrInv.ejs +4 -1
  6. package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_HdrInv.ejs +4 -1
  7. package/src/emit/coreFunction/templates/GenerateSeedDataGraphSchema_Main.ejs +10 -2
  8. package/src/emit/coreFunction/templates/GeneratedGraphNodeSchemas.ejs +17 -17
  9. package/src/emit/coreFunction/templates/GeneratedGraphRelSchemas.ejs +6 -6
  10. package/src/emit/coreFunction/templates/GeneratedTableConfigs.ejs +12 -12
  11. package/src/emit/coreFunction/templates/InitialSetupConfig.ejs +195 -58
  12. package/src/emit/coreFunction/templates/InitialSetupRunner.ejs +177 -0
  13. package/src/emit/coreFunction/templates/InitialSetupRunner_initialSetup.ejs +9 -0
  14. package/src/emit/coreFunction/templates/InitialSetupRunner_seedDynamo.ejs +22 -0
  15. package/src/emit/coreFunction/templates/InitialSetupRunner_seedGraph.ejs +8 -0
  16. package/src/emit/coreFunction/templates/InitialSetupRunner_seedRemove.ejs +5 -0
  17. package/src/emit/coreFunction/templates/InitialSetupRunner_uploadSchema.ejs +33 -0
  18. package/src/emit/coreFunction/templates/InitialSetup_Main.ejs +9 -11
  19. package/src/emit/coreFunction/templates/UploadSchema_HdrInv.ejs +1 -3
  20. package/src/emit/coreFunction/templates/UploadSchema_Main.ejs +1 -1
  21. package/src/emit/crud/templates/CreateEndpoint_Main.ejs +1 -1
  22. package/src/emit/crud/templates/DeleteEndpoint_Main.ejs +1 -1
  23. package/src/emit/crud/templates/FlowMain_Wbs.ejs +1 -2
  24. package/src/emit/crud/templates/GetEndpoint_Main.ejs +1 -1
  25. package/src/emit/crud/templates/GetRangeEndpoint_Main.ejs +1 -1
  26. package/src/emit/crud/templates/UpdateEndpoint_Main.ejs +1 -1
  27. package/src/emit/custom/emitCustomFlowApplicationArtifacts.js +26 -6
  28. package/src/emit/custom/templates/FlowEndpoint_Main.ejs +2 -2
  29. package/src/emit/custom/templates/FlowStep_Main.ejs +1 -1
  30. package/src/emit/custom/templates/s3/CreateObject_Main.ejs +1 -1
  31. package/src/emit/custom/templates/s3/ReservedLimit_Main.ejs +1 -1
  32. package/src/emit/custom/templates/triggerCache/CheckTriggerCache_HdrSqs.ejs +13 -9
  33. package/src/emit/relationship/templates/ChangeRelationship_Main.ejs +1 -1
  34. package/src/emit/relationship/templates/CreateRelationship_Main.ejs +1 -1
  35. package/src/emit/relationship/templates/DeleteRelationship_Main.ejs +1 -1
  36. package/src/emit/relationship/templates/GetRelationship_Main.ejs +53 -32
  37. package/src/emit/relationship/templates/MoveRelationship_Main.ejs +1 -1
  38. package/src/emit/relationship/templates/UpdateRelationship_Main.ejs +1 -1
  39. package/src/emit/resource/emitResourceArtifacts.js +58 -17
  40. package/src/emit/resource/templates/DynamoDBTable_Yaml.ejs +18 -18
  41. package/src/emit/resource/templates/FlowOut_Yaml.ejs +5 -5
  42. package/src/emit/resource/templates/GeneratedLambdaRoleServiceConfig.ejs +9 -10
  43. package/src/emit/resource/templates/ResourceBeforeLogicalYaml.ejs +44 -44
  44. package/src/emit/resource/templates/ResourceSqsYaml.ejs +36 -36
  45. package/src/emit/resource/templates/ResourceYaml.ejs +48 -48
  46. package/src/emit/resource/templates/S3Bucket_Yaml.ejs +0 -1
  47. package/src/emit/resource/templates/S3Subscription_Yaml.ejs +6 -6
  48. package/src/emit/resource/templates/SharedResource_Yaml.ejs +4 -4
  49. package/src/emit/resource/templates/SystemDynamoDB_Yaml.ejs +115 -115
  50. package/src/emit/resource/templates/WebSocketSubscription_Yaml.ejs +6 -6
  51. package/src/emit/shared/templates/FindData_HdrSqs.ejs +1 -1
  52. package/src/emit/shared/templates/FlowHandler_HdrApi.ejs +9 -7
  53. package/src/emit/shared/templates/FlowHandler_HdrDsq.ejs +19 -12
  54. package/src/emit/shared/templates/FlowHandler_HdrInv.ejs +9 -7
  55. package/src/emit/shared/templates/FlowHandler_HdrSqs.ejs +19 -12
  56. package/src/emit/shared/templates/PaginateProcessLogical_HdrDsq.ejs +1 -1
  57. package/src/emit/shared/templates/PaginateProcessLogical_HdrSqs.ejs +1 -1
  58. package/src/emit/shared/templates/PaginateProcessLogical_Main.ejs +2 -2
  59. package/src/emit/shared/templates/ProcessLogical_HdrSqs.ejs +1 -1
  60. package/src/generate.js +26 -5
  61. package/src/output/mergeHooks.js +13 -13
  62. package/src/output/validateArtifacts.js +10 -1
  63. package/test/customFlowApplicationArtifacts.test.js +71 -0
  64. package/test/publicApi.test.js +2 -2
  65. package/test/resourceArtifacts.test.js +8 -18
  66. package/docs/TriggeredCache Flow.drawio +0 -193
  67. package/docs/TriggeredCacheFlow.mmd +0 -47
@@ -1,219 +1,219 @@
1
1
  Resources:
2
2
  WebSocketTaskTable:
3
- Type: "AWS::DynamoDB::Table"
3
+ Type: 'AWS::DynamoDB::Table'
4
4
  Properties:
5
5
  TableName: ${self:custom.iz_resourcePrefix}WebSocketTask
6
6
  BillingMode: PAY_PER_REQUEST
7
7
  AttributeDefinitions:
8
- - AttributeName: taskKey
9
- AttributeType: S
10
- - AttributeName: connectionId
11
- AttributeType: S
8
+ - AttributeName: taskKey
9
+ AttributeType: S
10
+ - AttributeName: connectionId
11
+ AttributeType: S
12
12
  KeySchema:
13
- - AttributeName: taskKey
14
- KeyType: HASH
15
- - AttributeName: connectionId
16
- KeyType: RANGE
13
+ - AttributeName: taskKey
14
+ KeyType: HASH
15
+ - AttributeName: connectionId
16
+ KeyType: RANGE
17
17
  TimeToLiveSpecification:
18
18
  AttributeName: expirationTime
19
19
  Enabled: true
20
20
 
21
21
  UserUploadRecordsTable:
22
- Type: "AWS::DynamoDB::Table"
22
+ Type: 'AWS::DynamoDB::Table'
23
23
  Properties:
24
24
  TableName: ${self:custom.iz_resourcePrefix}UserUploadRecords
25
25
  BillingMode: PAY_PER_REQUEST
26
26
  AttributeDefinitions:
27
- - AttributeName: connectionId
28
- AttributeType: S
27
+ - AttributeName: connectionId
28
+ AttributeType: S
29
29
  KeySchema:
30
- - AttributeName: connectionId
31
- KeyType: HASH
30
+ - AttributeName: connectionId
31
+ KeyType: HASH
32
32
  TimeToLiveSpecification:
33
33
  AttributeName: expirationTime
34
34
  Enabled: true
35
35
 
36
36
  RegisterRecordsTable:
37
- Type: "AWS::DynamoDB::Table"
37
+ Type: 'AWS::DynamoDB::Table'
38
38
  Properties:
39
39
  TableName: ${self:custom.iz_resourcePrefix}RegisterRecords
40
40
  BillingMode: PAY_PER_REQUEST
41
41
  AttributeDefinitions:
42
- - AttributeName: identifiersTask
43
- AttributeType: S
44
- - AttributeName: connectionId
45
- AttributeType: S
42
+ - AttributeName: identifiersTask
43
+ AttributeType: S
44
+ - AttributeName: connectionId
45
+ AttributeType: S
46
46
  KeySchema:
47
- - AttributeName: identifiersTask
48
- KeyType: HASH
49
- - AttributeName: connectionId
50
- KeyType: RANGE
47
+ - AttributeName: identifiersTask
48
+ KeyType: HASH
49
+ - AttributeName: connectionId
50
+ KeyType: RANGE
51
51
 
52
52
  AwaitingMultipleStepsTable:
53
- Type: "AWS::DynamoDB::Table"
53
+ Type: 'AWS::DynamoDB::Table'
54
54
  Properties:
55
55
  TableName: ${self:custom.iz_resourcePrefix}AwaitingMultipleSteps
56
56
  BillingMode: PAY_PER_REQUEST
57
57
  AttributeDefinitions:
58
- - AttributeName: awaitingStepId
59
- AttributeType: S
60
- - AttributeName: pendingStepId
61
- AttributeType: S
58
+ - AttributeName: awaitingStepId
59
+ AttributeType: S
60
+ - AttributeName: pendingStepId
61
+ AttributeType: S
62
62
  KeySchema:
63
- - AttributeName: awaitingStepId
64
- KeyType: HASH
65
- - AttributeName: pendingStepId
66
- KeyType: RANGE
63
+ - AttributeName: awaitingStepId
64
+ KeyType: HASH
65
+ - AttributeName: pendingStepId
66
+ KeyType: RANGE
67
67
 
68
68
  AwaitingMultipleStepByPendingTable:
69
- Type: "AWS::DynamoDB::Table"
69
+ Type: 'AWS::DynamoDB::Table'
70
70
  Properties:
71
71
  TableName: ${self:custom.iz_resourcePrefix}AwaitingMultipleStepByPending
72
72
  BillingMode: PAY_PER_REQUEST
73
73
  AttributeDefinitions:
74
- - AttributeName: pendingStepId
75
- AttributeType: S
76
- - AttributeName: awaitingStepId
77
- AttributeType: S
74
+ - AttributeName: pendingStepId
75
+ AttributeType: S
76
+ - AttributeName: awaitingStepId
77
+ AttributeType: S
78
78
  KeySchema:
79
- - AttributeName: pendingStepId
80
- KeyType: HASH
81
- - AttributeName: awaitingStepId
82
- KeyType: RANGE
79
+ - AttributeName: pendingStepId
80
+ KeyType: HASH
81
+ - AttributeName: awaitingStepId
82
+ KeyType: RANGE
83
83
 
84
84
  FindDataMainTable:
85
- Type: "AWS::DynamoDB::Table"
85
+ Type: 'AWS::DynamoDB::Table'
86
86
  Properties:
87
87
  TableName: ${self:custom.iz_resourcePrefix}FindDataMain
88
88
  BillingMode: PAY_PER_REQUEST
89
89
  AttributeDefinitions:
90
- - AttributeName: findDataId
91
- AttributeType: S
90
+ - AttributeName: findDataId
91
+ AttributeType: S
92
92
  KeySchema:
93
- - AttributeName: findDataId
94
- KeyType: HASH
93
+ - AttributeName: findDataId
94
+ KeyType: HASH
95
95
 
96
96
  LogicalResultsMainTable:
97
- Type: "AWS::DynamoDB::Table"
97
+ Type: 'AWS::DynamoDB::Table'
98
98
  Properties:
99
99
  TableName: ${self:custom.iz_resourcePrefix}LogicalResultsMain
100
100
  BillingMode: PAY_PER_REQUEST
101
101
  AttributeDefinitions:
102
- - AttributeName: logicalResultId
103
- AttributeType: S
102
+ - AttributeName: logicalResultId
103
+ AttributeType: S
104
104
  KeySchema:
105
- - AttributeName: logicalResultId
106
- KeyType: HASH
105
+ - AttributeName: logicalResultId
106
+ KeyType: HASH
107
107
 
108
108
  LogicalResultsDataTable:
109
- Type: "AWS::DynamoDB::Table"
109
+ Type: 'AWS::DynamoDB::Table'
110
110
  Properties:
111
111
  TableName: ${self:custom.iz_resourcePrefix}LogicalResultsData
112
112
  BillingMode: PAY_PER_REQUEST
113
113
  AttributeDefinitions:
114
- - AttributeName: logicalResultId
115
- AttributeType: S
116
- - AttributeName: identifiersId
117
- AttributeType: S
114
+ - AttributeName: logicalResultId
115
+ AttributeType: S
116
+ - AttributeName: identifiersId
117
+ AttributeType: S
118
118
  KeySchema:
119
- - AttributeName: logicalResultId
120
- KeyType: HASH
121
- - AttributeName: identifiersId
122
- KeyType: RANGE
119
+ - AttributeName: logicalResultId
120
+ KeyType: HASH
121
+ - AttributeName: identifiersId
122
+ KeyType: RANGE
123
123
 
124
124
  AwaitingStepTable:
125
- Type: "AWS::DynamoDB::Table"
125
+ Type: 'AWS::DynamoDB::Table'
126
126
  Properties:
127
127
  TableName: ${self:custom.iz_resourcePrefix}AwaitingStep
128
128
  BillingMode: PAY_PER_REQUEST
129
129
  AttributeDefinitions:
130
- - AttributeName: awaitingStepId
131
- AttributeType: S
132
- - AttributeName: pendingStepId
133
- AttributeType: S
130
+ - AttributeName: awaitingStepId
131
+ AttributeType: S
132
+ - AttributeName: pendingStepId
133
+ AttributeType: S
134
134
  KeySchema:
135
- - AttributeName: awaitingStepId
136
- KeyType: HASH
137
- - AttributeName: pendingStepId
138
- KeyType: RANGE
135
+ - AttributeName: awaitingStepId
136
+ KeyType: HASH
137
+ - AttributeName: pendingStepId
138
+ KeyType: RANGE
139
139
 
140
140
  TargetRolesTable:
141
- Type: "AWS::DynamoDB::Table"
141
+ Type: 'AWS::DynamoDB::Table'
142
142
  Properties:
143
143
  TableName: ${self:custom.iz_resourcePrefix}TargetRoles
144
144
  BillingMode: PAY_PER_REQUEST
145
145
  AttributeDefinitions:
146
- - AttributeName: targetId
147
- AttributeType: S
148
- - AttributeName: roleIdKey
149
- AttributeType: S
146
+ - AttributeName: targetId
147
+ AttributeType: S
148
+ - AttributeName: roleIdKey
149
+ AttributeType: S
150
150
  KeySchema:
151
- - AttributeName: targetId
152
- KeyType: HASH
153
- - AttributeName: roleIdKey
154
- KeyType: RANGE
151
+ - AttributeName: targetId
152
+ KeyType: HASH
153
+ - AttributeName: roleIdKey
154
+ KeyType: RANGE
155
155
 
156
156
  RolePermissionsTable:
157
- Type: "AWS::DynamoDB::Table"
157
+ Type: 'AWS::DynamoDB::Table'
158
158
  Properties:
159
159
  TableName: ${self:custom.iz_resourcePrefix}RolePermissions
160
160
  BillingMode: PAY_PER_REQUEST
161
161
  AttributeDefinitions:
162
- - AttributeName: roleIdKey
163
- AttributeType: S
164
- - AttributeName: flowTypeConcat
165
- AttributeType: S
162
+ - AttributeName: roleIdKey
163
+ AttributeType: S
164
+ - AttributeName: flowTypeConcat
165
+ AttributeType: S
166
166
  KeySchema:
167
- - AttributeName: roleIdKey
168
- KeyType: HASH
169
- - AttributeName: flowTypeConcat
170
- KeyType: RANGE
167
+ - AttributeName: roleIdKey
168
+ KeyType: HASH
169
+ - AttributeName: flowTypeConcat
170
+ KeyType: RANGE
171
171
 
172
172
  RoleUsersTable:
173
- Type: "AWS::DynamoDB::Table"
173
+ Type: 'AWS::DynamoDB::Table'
174
174
  Properties:
175
175
  TableName: ${self:custom.iz_resourcePrefix}RoleUsers
176
176
  BillingMode: PAY_PER_REQUEST
177
177
  AttributeDefinitions:
178
- - AttributeName: roleIdKey
179
- AttributeType: S
180
- - AttributeName: userId
181
- AttributeType: S
178
+ - AttributeName: roleIdKey
179
+ AttributeType: S
180
+ - AttributeName: userId
181
+ AttributeType: S
182
182
  KeySchema:
183
- - AttributeName: roleIdKey
184
- KeyType: HASH
185
- - AttributeName: userId
186
- KeyType: RANGE
183
+ - AttributeName: roleIdKey
184
+ KeyType: HASH
185
+ - AttributeName: userId
186
+ KeyType: RANGE
187
187
 
188
188
  UserRolesTable:
189
- Type: "AWS::DynamoDB::Table"
189
+ Type: 'AWS::DynamoDB::Table'
190
190
  Properties:
191
191
  TableName: ${self:custom.iz_resourcePrefix}UserRoles
192
192
  BillingMode: PAY_PER_REQUEST
193
193
  AttributeDefinitions:
194
- - AttributeName: userId
195
- AttributeType: S
196
- - AttributeName: roleIdKey
197
- AttributeType: S
194
+ - AttributeName: userId
195
+ AttributeType: S
196
+ - AttributeName: roleIdKey
197
+ AttributeType: S
198
198
  KeySchema:
199
- - AttributeName: userId
200
- KeyType: HASH
201
- - AttributeName: roleIdKey
202
- KeyType: RANGE
203
- <% if (hasS3) { %>
199
+ - AttributeName: userId
200
+ KeyType: HASH
201
+ - AttributeName: roleIdKey
202
+ KeyType: RANGE
203
+ <% if (hasS3) { %>
204
204
  ReservedDataMainTable:
205
- Type: "AWS::DynamoDB::Table"
205
+ Type: 'AWS::DynamoDB::Table'
206
206
  Properties:
207
207
  TableName: ${self:custom.iz_resourcePrefix}ReservedDataMain
208
208
  BillingMode: PAY_PER_REQUEST
209
209
  AttributeDefinitions:
210
- - AttributeName: servicePendingId
211
- AttributeType: S
212
- - AttributeName: reservedDataId
213
- AttributeType: S
210
+ - AttributeName: servicePendingId
211
+ AttributeType: S
212
+ - AttributeName: reservedDataId
213
+ AttributeType: S
214
214
  KeySchema:
215
- - AttributeName: servicePendingId
216
- KeyType: HASH
217
- - AttributeName: reservedDataId
218
- KeyType: RANGE
215
+ - AttributeName: servicePendingId
216
+ KeyType: HASH
217
+ - AttributeName: reservedDataId
218
+ KeyType: RANGE
219
219
  <% } %>
@@ -1,7 +1,7 @@
1
1
  ##===== WebSocket completion subscription
2
- SubscriptionToOut<%= topicName %>WebSocketComplete:
3
- Type: AWS::SNS::Subscription
4
- Properties:
5
- TopicArn: !Ref Out<%= topicName %>
6
- Endpoint: "arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}WebSocketCompleteHdrSqs"
7
- Protocol: "sqs"
2
+ SubscriptionToOut<%= topicName %>WebSocketComplete:
3
+ Type: AWS::SNS::Subscription
4
+ Properties:
5
+ TopicArn: !Ref Out<%= topicName %>
6
+ Endpoint: 'arn:aws:sqs:${self:custom.iz_region}:${self:custom.iz_accountId}:${self:custom.iz_resourcePrefix}WebSocketCompleteHdrSqs'
7
+ Protocol: 'sqs'
@@ -65,7 +65,7 @@ export const main = middleware.wrap(async (event, context) => {
65
65
 
66
66
  // loop each record and send to mainFunction
67
67
  await Promise.all(
68
- event.Records.map(async record => {
68
+ event.Records.map(async (record) => {
69
69
  // promise.all for map() function
70
70
 
71
71
  let passOnProperties = [];
@@ -3,20 +3,22 @@ import {
3
3
  response
4
4
  } from '@izara_project/izara-middleware';
5
5
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
6
-
7
6
  import <%= functionName %> from './<%= mainFileName %>.js';
8
7
 
8
+ //(<optionalRequire>)
9
+ //(</optionalRequire>)
10
+
9
11
  const validatorSchema = {
10
- //(<validatorSchema>)
11
- <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
12
+ <%_ if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { _%>
12
13
  type: 'object',
13
14
  properties: {
14
- <% startConfig.properties.forEach(prop => { -%>
15
- <%- prop.propertyName %>: { type: '<%- prop.type || 'string' %>' }
16
- <% }) -%>
15
+ <%_ startConfig.properties.forEach((prop, index) => { _%>
16
+ <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: { type: '<%- prop.type || 'string' %>' }<%- index < startConfig.properties.length - 1 ? ',' : '' %>
17
+ <%_ }) _%>
17
18
  },
18
19
  required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
19
- <% } -%>
20
+ <%_ } _%>
21
+ //(<validatorSchema>)
20
22
  //(</validatorSchema>)
21
23
  };
22
24
 
@@ -21,41 +21,48 @@ import Logger from '@izara_project/izara-core-library-logger';
21
21
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
22
22
  import <%= functionName %> from './<%= mainFileName %>.js';
23
23
 
24
+ //(<optionalRequire>)
25
+ //(</optionalRequire>)
26
+
24
27
  // validate event properties in body.Message of sqs event
25
28
  let perRecordsValidatorSchema = {
26
- //(<validatorSchema>)
27
- <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
29
+ <%_ if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { _%>
28
30
  type: 'object',
29
31
  properties: {
30
- <% startConfig.properties.forEach((prop, index) => { %> <%- prop.propertyName %>: {
32
+ <%_ startConfig.properties.forEach((prop, index) => { _%>
33
+ <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: {
31
34
  type: '<%- prop.type || 'string' %>'
32
- },
33
- <% }) %>
35
+ }<%- index < startConfig.properties.length - 1 ? ',' : '' %>
36
+ <%_ }) _%>
34
37
  },
35
38
  required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
36
- <% } -%>
39
+ <%_ } _%>
40
+ //(<validatorSchema>)
37
41
  //(</validatorSchema>)
38
42
  };
39
43
 
40
- <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.messageAttributes && startConfig.messageAttributes.length > 0) { -%>
44
+ <%_ if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.messageAttributes && startConfig.messageAttributes.length > 0) { _%>
41
45
  let messageAttributeValidatorSchema = {
42
46
  type: 'object',
43
47
  properties: {
44
- <% startConfig.messageAttributes.forEach((prop, index) => { %> <%- prop.propertyName %>: {
48
+ <%_ startConfig.messageAttributes.forEach((prop, index) => { _%>
49
+ <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: {
45
50
  type: 'object',
46
51
  properties: {
47
52
  Type: { type: 'string' },
48
53
  Value: { type: '<%- prop.type || 'string' %>' }
49
54
  },
50
55
  required: ['Type', 'Value']
51
- },
52
- <% }) %>
56
+ }<%- index < startConfig.messageAttributes.length - 1 ? ',' : '' %>
57
+ <%_ }) _%>
53
58
  },
54
59
  required: [<%- startConfig.messageAttributes.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
60
+ //(<messageAttributeValidatorSchema>)
61
+ //(</messageAttributeValidatorSchema>)
55
62
  };
56
- <% } else { -%>
63
+ <%_ } else { _%>
57
64
  let messageAttributeValidatorSchema = null;
58
- <% } -%>
65
+ <%_ } _%>
59
66
 
60
67
  middleware.setValidatorSchema(
61
68
  recordHandlerSharedLib.baseValidatorSchema({
@@ -1,19 +1,21 @@
1
1
  import { middlewareHandler as middleware } from '@izara_project/izara-middleware';
2
2
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
3
-
4
3
  import <%= functionName %> from './<%= mainFileName %>.js';
5
4
 
5
+ //(<optionalRequire>)
6
+ //(</optionalRequire>)
7
+
6
8
  const validatorSchema = {
7
- //(<validatorSchema>)
8
- <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
9
+ <%_ if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { _%>
9
10
  type: 'object',
10
11
  properties: {
11
- <% startConfig.properties.forEach(prop => { -%>
12
- <%- prop.propertyName %>: { type: '<%- prop.type || 'string' %>' }
13
- <% }) -%>
12
+ <%_ startConfig.properties.forEach((prop, index) => { _%>
13
+ <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: { type: '<%- prop.type || 'string' %>' }<%- index < startConfig.properties.length - 1 ? ',' : '' %>
14
+ <%_ }) _%>
14
15
  },
15
16
  required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
16
- <% } -%>
17
+ <%_ } _%>
18
+ //(<validatorSchema>)
17
19
  //(</validatorSchema>)
18
20
  };
19
21
 
@@ -21,41 +21,48 @@ import Logger from '@izara_project/izara-core-library-logger';
21
21
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
22
22
  import <%= functionName %> from './<%= mainFileName %>.js';
23
23
 
24
+ //(<optionalRequire>)
25
+ //(</optionalRequire>)
26
+
24
27
  // validate event properties in body.Message of sqs event
25
28
  let perRecordsValidatorSchema = {
26
- //(<validatorSchema>)
27
- <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { -%>
29
+ <%_ if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.properties && startConfig.properties.length > 0) { _%>
28
30
  type: 'object',
29
31
  properties: {
30
- <% startConfig.properties.forEach((prop, index) => { %> <%- prop.propertyName %>: {
32
+ <%_ startConfig.properties.forEach((prop, index) => { _%>
33
+ <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: {
31
34
  type: '<%- prop.type || 'string' %>'
32
- },
33
- <% }) %>
35
+ }<%- index < startConfig.properties.length - 1 ? ',' : '' %>
36
+ <%_ }) _%>
34
37
  },
35
38
  required: [<%- startConfig.properties.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
36
- <% } -%>
39
+ <%_ } _%>
40
+ //(<validatorSchema>)
37
41
  //(</validatorSchema>)
38
42
  };
39
43
 
40
- <% if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.messageAttributes && startConfig.messageAttributes.length > 0) { -%>
44
+ <%_ if (typeof startConfig !== 'undefined' && startConfig !== null && startConfig.messageAttributes && startConfig.messageAttributes.length > 0) { _%>
41
45
  let messageAttributeValidatorSchema = {
42
46
  type: 'object',
43
47
  properties: {
44
- <% startConfig.messageAttributes.forEach((prop, index) => { %> <%- prop.propertyName %>: {
48
+ <%_ startConfig.messageAttributes.forEach((prop, index) => { _%>
49
+ <%- /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(prop.propertyName) ? prop.propertyName : `'${prop.propertyName}'` %>: {
45
50
  type: 'object',
46
51
  properties: {
47
52
  Type: { type: 'string' },
48
53
  Value: { type: '<%- prop.type || 'string' %>' }
49
54
  },
50
55
  required: ['Type', 'Value']
51
- },
52
- <% }) %>
56
+ }<%- index < startConfig.messageAttributes.length - 1 ? ',' : '' %>
57
+ <%_ }) _%>
53
58
  },
54
59
  required: [<%- startConfig.messageAttributes.filter(p => p.required === true).map(p => `'${p.propertyName}'`).join(', ') %>]
60
+ //(<messageAttributeValidatorSchema>)
61
+ //(</messageAttributeValidatorSchema>)
55
62
  };
56
- <% } else { -%>
63
+ <%_ } else { _%>
57
64
  let messageAttributeValidatorSchema = null;
58
- <% } -%>
65
+ <%_ } _%>
59
66
  middleware.setValidatorSchema(recordHandlerSharedLib.baseValidatorSchema());
60
67
 
61
68
  export const main = middleware.wrap(async (event, context) => {
@@ -93,7 +93,7 @@ export const main = middleware.wrap(async (event, context) => {
93
93
 
94
94
  // loop each record and send to mainFunction
95
95
  await Promise.all(
96
- event.Records.map(async record => {
96
+ event.Records.map(async (record) => {
97
97
  // promise.all for map() function
98
98
 
99
99
  // --- reforming record.body for Dsq request
@@ -80,7 +80,7 @@ export const main = middleware.wrap(async (event, context) => {
80
80
 
81
81
  // loop each record and send to mainFunction
82
82
  await Promise.all(
83
- event.Records.map(async record => {
83
+ event.Records.map(async (record) => {
84
84
  // promise.all for map() function
85
85
 
86
86
  let passOnProperties = [];
@@ -183,7 +183,7 @@ export default async function paginateProcessLogical(
183
183
  if (conditionalFieldValue.hasOwnProperty('includeValues')) {
184
184
  let includeValues = conditionalFieldValue.includeValues; // array
185
185
 
186
- objInstanceBases = objInstanceBases.filter(objInstanceBase => {
186
+ objInstanceBases = objInstanceBases.filter((objInstanceBase) => {
187
187
  return includeValues.includes(
188
188
  objInstanceBase[conditionalFieldName]
189
189
  );
@@ -191,7 +191,7 @@ export default async function paginateProcessLogical(
191
191
  } else if (conditionalFieldValue.hasOwnProperty('excludeValues')) {
192
192
  let excludeValues = conditionalFieldValue.excludeValues; // array
193
193
 
194
- objInstanceBases = objInstanceBases.filter(objInstanceBase => {
194
+ objInstanceBases = objInstanceBases.filter((objInstanceBase) => {
195
195
  return !excludeValues.includes(
196
196
  objInstanceBase[conditionalFieldName]
197
197
  );
@@ -62,7 +62,7 @@ export const main = middleware.wrap(async (event, context) => {
62
62
 
63
63
  // loop each record and send to mainFunction
64
64
  await Promise.all(
65
- event.Records.map(async record => {
65
+ event.Records.map(async (record) => {
66
66
  // promise.all for map() function
67
67
 
68
68
  let passOnProperties = [];