@izara_project/izara-core-generate-service-code 1.0.59 → 1.0.60

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izara_project/izara-core-generate-service-code",
3
- "version": "1.0.59",
3
+ "version": "1.0.60",
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": {
@@ -23,6 +23,10 @@ import asyncFlowSharedLib from '@izara_project/izara-core-library-asynchronous-f
23
23
  import callingFlowSharedLib from '@izara_project/izara-core-library-calling-flow';
24
24
  import lambdaSharedLib from '@izara_project/izara-core-library-lambda';
25
25
 
26
+ <% if (typeof flow !== 'undefined' && flow.statusType === 'storedCache') { %>
27
+ import storedCacheSharedLib from '@izara_project/izara-core-library-stored-cache';
28
+ <% } %>
29
+
26
30
  //(<optionalImport>)
27
31
  import { getObjectSchema } from '@izara_project/izara-core-library-service-schemas';
28
32
  import {
@@ -65,6 +69,35 @@ export default async function Process<%- upperCaseFlowTag %>(
65
69
  _izContext.logger.debug("Process<%- upperCaseFlowTag %> requestParams", requestParams)
66
70
  _izContext.logger.debug("Process<%- upperCaseFlowTag %> callingFlowConfig", callingFlowConfig)
67
71
 
72
+ <% if (typeof flow !== 'undefined' && flow.statusType === 'storedCache') { %>
73
+ let [ cacheMainStatus, cacheMain, cacheExist ] = await storedCacheSharedLib.checkStoredCacheStatus(
74
+ _izContext,
75
+ "<%= tableName %>",
76
+ {
77
+ //(<keyValueStoredCacheTable>)
78
+ //(</keyValueStoredCacheTable>)
79
+ },
80
+ //(<additionalAttributesWhenCreateStoredCache>)
81
+ //(</additionalAttributesWhenCreateStoredCache>),
82
+ createFlowTypeConcat(_izContext, { flowTag: "<%= flowTag %>", serviceTag: process.env.iz_serviceTag }),
83
+ //(<storedCacheConfig>)
84
+ //(</storedCacheConfig>)
85
+ )
86
+
87
+ //(<afterCheckStoredCache>)
88
+ //(</afterCheckStoredCache>)
89
+
90
+ if (cacheMainStatus !== "process") {
91
+ if (cacheMainStatus === "error" || cacheMainStatus === "complete") {
92
+ //(<afterValidateStoredCacheStatus>)
93
+ //(</afterValidateStoredCacheStatus>)
94
+ }
95
+
96
+ //(<checkStoredCacheHook>)
97
+ //(</checkStoredCacheHook>)
98
+ }
99
+ <% } %>
100
+
68
101
  <% if (typeof flow !== 'undefined' && flow.isRbac) { %>
69
102
  const { checkRbacPermission } = await import('@izara_project/izara-authorization');
70
103
 
@@ -99,13 +99,27 @@ export async function generateFlowMainFunction(allSchemas, options) {
99
99
  }
100
100
  }
101
101
 
102
+ let tableName = null;
103
+ if (flow.statusType === 'storedCache' && flow.objType && flow.objType.objectType) {
104
+ const objectSchema = allSchemas.objects.find(obj => obj.objectType === flow.objType.objectType);
105
+ if (objectSchema && objectSchema.storageResources) {
106
+ for (const storageResource of Object.values(objectSchema.storageResources)) {
107
+ if (storageResource.storageType === 'dynamoDB') {
108
+ tableName = storageResource.tableName;
109
+ break;
110
+ }
111
+ }
112
+ }
113
+ }
114
+
102
115
  const mainContent = ejs.render(mainTemplateStr, {
103
116
  flowTag: flowTag,
104
117
  upperCaseFlowTag: upperCaseFlowTag,
105
118
  topicArn: topicArn,
106
119
  generateCode: generateCode,
107
120
  flow: flow,
108
- inTagConfig: inTagConfig
121
+ inTagConfig: inTagConfig,
122
+ tableName: tableName
109
123
  });
110
124
  await fs.writeFile(
111
125
  path.join(flowOutputDir, `${mainFileName}.js`),
@@ -124,7 +138,8 @@ export async function generateFlowMainFunction(allSchemas, options) {
124
138
  upperCaseFlowTag: upperCaseFlowTag,
125
139
  generateCode: generateCode,
126
140
  flow: flow,
127
- inTagConfig: inTagConfig
141
+ inTagConfig: inTagConfig,
142
+ tableName: tableName
128
143
  });
129
144
  await fs.writeFile(
130
145
  path.join(flowOutputDir, `${processMainFileName(flowTag)}.js`),
@@ -20,7 +20,7 @@ export async function generateTriggerCache(flowSchema, appPath, outputBaseDir) {
20
20
  const flowTag = flowSchema.flowTag;
21
21
  const upperFlowTag = upperCase(flowTag);
22
22
  const serviceTag = flowSchema.objType?.serviceTag || 'UnknownService';
23
- const templateDir = path.join(__dirname, '..', '_shared', 'triggerCache');
23
+ const templateDir = path.join(__dirname, '..', 'triggerCache');
24
24
 
25
25
  const subDir = getFlowOutputSubDir(flowTag);
26
26
 
@@ -2,7 +2,7 @@
2
2
  <%- tableName %>Table:
3
3
  Type: AWS::DynamoDB::Table
4
4
  Properties:
5
- TableName: ${self:custom.iz_serviceTag}_${self:custom.iz_stage}_<%- tableName %>
5
+ TableName: ${self:custom.iz_resourcePrefix}<%- tableName %>
6
6
  BillingMode: PAY_PER_REQUEST
7
7
  AttributeDefinitions:
8
8
  - AttributeName: "<%- pk %>"