@izara_project/izara-core-generate-service-code 1.0.81 → 1.0.82

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.81",
3
+ "version": "1.0.82",
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": {
@@ -116,7 +116,7 @@ export const main = middleware.wrap(async (event, context) => {
116
116
  } else {
117
117
  const connId = event.connId;
118
118
  // await postMessage({ message: event.message }, connId);
119
- await postToConnection({ message: event.message }, connId);
119
+ await postToConnection(event._izContext, { message: event.message }, connId);
120
120
  }
121
121
 
122
122
  return response.webSocketSuccess();
@@ -124,7 +124,7 @@ export const main = middleware.wrap(async (event, context) => {
124
124
  const connId = event.requestContext.connectionId;
125
125
  event._izContext.logger.error('Error, WebSocket: ', err);
126
126
  // await sendErrorMessage({ message: err.message }, connId);
127
- await postToConnection({ message: err.message }, connId);
127
+ await postToConnection(event._izContext, { message: err.message }, connId);
128
128
  return response.failure(err);
129
129
  }
130
130
  });
@@ -78,6 +78,7 @@ export default async function <%- typeof functionName !== 'undefined' ? function
78
78
 
79
79
  if (!flowSchema) {
80
80
  await postToConnection(
81
+ _izContext,
81
82
  {
82
83
  message: {
83
84
  error: `flowTag not found ${requestParams.action}`
@@ -99,7 +100,7 @@ export default async function <%- typeof functionName !== 'undefined' ? function
99
100
  callingFlowSharedLib.createCallingFlowConfig(
100
101
  await lambdaSharedLib.lambdaFunctionName(
101
102
  _izContext,
102
- 'WebSocketComplete'
103
+ 'WebSocketCompleteHdrSqs'
103
104
  ),
104
105
  {}
105
106
  )
@@ -77,7 +77,7 @@ export const main = middleware.wrap(async (event, context) => {
77
77
  } else {
78
78
  const connId = event.connId;
79
79
  // await postMessage({ message: event.message }, connId);
80
- await postToConnection({ message: event.message }, connId);
80
+ await postToConnection(event._izContext, { message: event.message }, connId);
81
81
  }
82
82
 
83
83
  return response.webSocketSuccess();
@@ -85,7 +85,7 @@ export const main = middleware.wrap(async (event, context) => {
85
85
  const connId = event.requestContext.connectionId;
86
86
  event._izContext.logger.error('Error, WebSocket: ', err);
87
87
  // await sendErrorMessage({ message: err.message }, connId);
88
- await postToConnection({ message: err.message }, connId);
88
+ await postToConnection(event._izContext, { message: err.message }, connId);
89
89
  return response.failure(err);
90
90
  }
91
91
  });
@@ -171,6 +171,7 @@ export default async function createPreSignUrl(
171
171
  await sns.publishAsync(_izContext, sendMessageToCancelReserved);
172
172
 
173
173
  await postToConnection(
174
+ _izContext,
174
175
  { message: 'reserved has reach limit' },
175
176
  connectionId
176
177
  );
@@ -254,7 +255,7 @@ export default async function createPreSignUrl(
254
255
  // calling flow own service
255
256
  await lambdaSharedLib.lambdaFunctionName(
256
257
  _izContext,
257
- `WebSocketComplete`
258
+ `WebSocketCompleteHdrSqs`
258
259
  ),
259
260
  {}
260
261
  )
@@ -89,7 +89,7 @@ export default async function reservedLimit(
89
89
  _izContext.logger.debug('res::', res);
90
90
 
91
91
  if (res.passStatus === false) {
92
- postToConnection({ message: 'static limit over' }, connectionId);
92
+ await postToConnection(_izContext, { message: 'static limit over' }, connectionId);
93
93
  let identifiers = hash({
94
94
  //(<hashIdentifiers>)
95
95
  //(</hashIdentifiers>)
@@ -93,9 +93,9 @@ export default async function registerCompleteMain(
93
93
  await Promise.all(
94
94
  tasks.Items.map(async (task) => {
95
95
  if (!result) {
96
- await postToConnection({ message: 'not have record' }, task.connectionId);
96
+ await postToConnection(_izContext, { message: 'not have record' }, task.connectionId);
97
97
  } else {
98
- await postToConnection({ message: result }, task.connectionId);
98
+ await postToConnection(_izContext, { message: result }, task.connectionId);
99
99
  }
100
100
  })
101
101
  );
@@ -138,7 +138,7 @@ export default async function registerCompleteMain(
138
138
  if (tasks.Items && tasks.Items.length > 0) {
139
139
  await Promise.all(
140
140
  tasks.Items.map(async (task) => {
141
- await postToConnection({ message: task }, task.connectionId);
141
+ await postToConnection(_izContext, { message: task }, task.connectionId);
142
142
  })
143
143
  );
144
144
  }
@@ -42,14 +42,14 @@ export const main = middleware.wrap(async (event, context) => {
42
42
  }
43
43
  } else {
44
44
  const connId = event.connId;
45
- await postToConnection({ message: event.message }, connId);
45
+ await postToConnection(event._izContext, { message: event.message }, connId);
46
46
  }
47
47
  return response.webSocketSuccess();
48
48
  } catch (err) {
49
49
  const connId = event.requestContext?.connectionId;
50
50
  event._izContext.logger.error('Error, WebSocket: ', err);
51
51
  if (connId) {
52
- await postToConnection({ message: err.message }, connId);
52
+ await postToConnection(event._izContext, { message: err.message }, connId);
53
53
  }
54
54
  return response.failure(err);
55
55
  }
@@ -55,7 +55,7 @@ export default async function registerMain(
55
55
  );
56
56
 
57
57
  if (!result) {
58
- await postToConnection({ message: 'not have record' }, connectionId);
58
+ await postToConnection(_izContext, { message: 'not have record' }, connectionId);
59
59
  } else {
60
60
  for (const [fieldName, fieldNameSetting] of Object.entries(
61
61
  objectSchema.fieldNames
@@ -77,7 +77,7 @@ export default async function registerMain(
77
77
  }
78
78
  );
79
79
  } else {
80
- await postToConnection({ message: result }, connectionId);
80
+ await postToConnection(_izContext, { message: result }, connectionId);
81
81
  }
82
82
  }
83
83
  }
@@ -121,10 +121,10 @@ export default async function registerMain(
121
121
  if (tasks.Items && tasks.Items.length > 0) {
122
122
  await Promise.all(
123
123
  tasks.Items.map(async (task) => {
124
- await postToConnection({ message: task }, task.connectionId);
124
+ await postToConnection(_izContext, { message: task }, task.connectionId);
125
125
  })
126
126
  );
127
- await postToConnection({ message: tasks.Items[0] }, connectionId);
127
+ await postToConnection(_izContext, { message: tasks.Items[0] }, connectionId);
128
128
  return tasks.Items[0];
129
129
  } else {
130
130
  await dynamodbSharedLib.putItem(
@@ -76,7 +76,7 @@ export default async function WebSocketComplete(
76
76
  (tasks.Items ?? []).map(async (task) => {
77
77
  //(<beforePostMessage>)
78
78
  //(</beforePostMessage>)
79
- await postToConnection({ message: requestParams }, task.connectionId);
79
+ await postToConnection(_izContext, { message: requestParams }, task.connectionId);
80
80
  await dynamodbSharedLib.deleteItem(
81
81
  _izContext,
82
82
  await dynamodbSharedLib.tableName(_izContext, 'WebSocketTask'),
@@ -84,8 +84,8 @@ export async function emitSystemTextSchemas({
84
84
  }
85
85
 
86
86
  for (const fieldName of fieldNames) {
87
- const nameSpace = `${objectType}_${objServiceTag}_description`;
88
- const systemTextTag = `${fieldName}_${objectType}_${objServiceTag}`;
87
+ const nameSpace = `${objectType}|${objServiceTag}|description`;
88
+ const systemTextTag = `${fieldName}|${objectType}|${objServiceTag}`;
89
89
  const openHook = `//(<${objectType}_${objServiceTag}${fieldName}Hook>)`;
90
90
  const closeHook = `//(</${objectType}_${objServiceTag}${fieldName}Hook>)`;
91
91
  datas.push({
@@ -100,7 +100,7 @@ export async function emitSystemTextSchemas({
100
100
  // 2. Process Notifications
101
101
  for (const notification of safeNotifications) {
102
102
  if (notification?.notificationGrouping && notification?.notificationTag) {
103
- const nameSpace = `sysNotification_${notification.notificationGrouping}`;
103
+ const nameSpace = `sysNotification|${notification.notificationGrouping}`;
104
104
  const systemTextTag = notification.notificationTag;
105
105
  const openHook = `//(<${notification.notificationTag}Hook>)`;
106
106
  const closeHook = `//(</${notification.notificationTag}Hook>)`;
@@ -127,8 +127,8 @@ export async function emitSystemTextSchemas({
127
127
 
128
128
  if (relData?.fieldNames && Object.keys(relData.fieldNames).length > 0) {
129
129
  for (const fieldName of Object.keys(relData.fieldNames)) {
130
- const nameSpace = `${relTag}_${relServiceTag}_description`;
131
- const systemTextTag = `${fieldName}_${relTag}_${relServiceTag}`;
130
+ const nameSpace = `${relTag}|${relServiceTag}|description`;
131
+ const systemTextTag = `${fieldName}|${relTag}|${relServiceTag}`;
132
132
  const openHook = `//(<${relTag}_${relServiceTag}${fieldName}Hook>)`;
133
133
  const closeHook = `//(</${relTag}_${relServiceTag}${fieldName}Hook>)`;
134
134
  datas.push({
@@ -208,8 +208,8 @@ export async function emitSystemTextSchemas({
208
208
  }
209
209
 
210
210
  for (const flowTag of flowTags) {
211
- const nameSpace = `${flowTag}_${serviceTag}`;
212
- const systemTextTag = `errors_${flowTag}_${serviceTag}`;
211
+ const nameSpace = `${flowTag}|${serviceTag}`;
212
+ const systemTextTag = `errors|${flowTag}|${serviceTag}`;
213
213
  const openHook = `//(<${flowTag}_${serviceTag}Hook>)`;
214
214
  const closeHook = `//(</${flowTag}_${serviceTag}Hook>)`;
215
215
  datas.push({
@@ -67,16 +67,27 @@ test('emits CRUD handlers and function YAML from schema data without reading gen
67
67
  ),
68
68
  /checkAllAwaitingStepsFinishedWithReturnParams/
69
69
  );
70
- assert.doesNotMatch(
71
- await readFile(
72
- join(
73
- rootPath,
74
- 'app/src/generatedCode/FlowObjects/Create/source/Create_WbsMain.js'
75
- ),
76
- 'utf8'
70
+ const createWbsMain = await readFile(
71
+ join(
72
+ rootPath,
73
+ 'app/src/generatedCode/FlowObjects/Create/source/Create_WbsMain.js'
77
74
  ),
75
+ 'utf8'
76
+ );
77
+ assert.doesNotMatch(
78
+ createWbsMain,
78
79
  /from '@izara_project\/izara-core-generate-service-code'/
79
80
  );
81
+ assert.match(createWbsMain, /'WebSocketCompleteHdrSqs'/);
82
+ assert.match(createWbsMain, /postToConnection\(\s*_izContext,/);
83
+ const createHdrWbs = await readFile(
84
+ join(
85
+ rootPath,
86
+ 'app/src/generatedCode/FlowObjects/Create/source/Create_HdrWbs.js'
87
+ ),
88
+ 'utf8'
89
+ );
90
+ assert.match(createHdrWbs, /postToConnection\(event\._izContext,/);
80
91
  await assert.rejects(
81
92
  readFile(
82
93
  join(
@@ -239,6 +239,14 @@ test('emits handlers, function YAML, and IAM roles for supported custom flow eve
239
239
  assert.ok(helperPath, `${path} imports GenerateCodeLibs`);
240
240
  await access(resolve(dirname(filePath), helperPath));
241
241
  }
242
+ const presignMain = await readFile(
243
+ join(
244
+ rootPath,
245
+ 'app/src/generatedCode/FlowSchemas/Upload/source/UploadCreatePreSignUrl_Main.js'
246
+ ),
247
+ 'utf8'
248
+ );
249
+ assert.match(presignMain, /`WebSocketCompleteHdrSqs`/);
242
250
  });
243
251
 
244
252
  test('removes only V2-owned custom-flow application artifacts when supported events are removed', async () => {
@@ -33,7 +33,7 @@ test('generate commits schemas, application artifacts, and resources in one publ
33
33
  ),
34
34
  'utf8'
35
35
  ),
36
- /nameSpace:\s*"Create_/
36
+ /nameSpace:\s*"Create\|/
37
37
  );
38
38
  assert.match(
39
39
  await readFile(
@@ -203,6 +203,7 @@ test('generate commits the system WebSocket completion path for own-topic flows'
203
203
  );
204
204
  assert.match(webSocketComplete, /\(\<createIdentifiersFlow\>\)/);
205
205
  assert.match(webSocketComplete, /\(\<beforePostMessage\>\)/);
206
+ assert.match(webSocketComplete, /postToConnection\(_izContext,/);
206
207
  const webSocketHandler = await readFile(
207
208
  join(
208
209
  rootPath,
@@ -63,32 +63,32 @@ test('emitSystemTextSchemas produces expected structure for objects, flows, rela
63
63
 
64
64
  const content = artifacts[0].content;
65
65
  // Object fields
66
- assert.match(content, /nameSpace:\s*"product_MyService_description"/);
66
+ assert.match(content, /nameSpace:\s*"product\|MyService\|description"/);
67
67
  assert.match(
68
68
  content,
69
- /systemTextTag:\s*"productId_product_MyService"/
69
+ /systemTextTag:\s*"productId\|product\|MyService"/
70
70
  );
71
71
  assert.match(content, /\/\/\(<product_MyServiceproductIdHook>\)/);
72
72
  assert.match(
73
73
  content,
74
- /systemTextTag:\s*"version_product_MyService"/
74
+ /systemTextTag:\s*"version\|product\|MyService"/
75
75
  );
76
76
 
77
77
  // Notification
78
- assert.match(content, /nameSpace:\s*"sysNotification_OrderEvents"/);
78
+ assert.match(content, /nameSpace:\s*"sysNotification\|OrderEvents"/);
79
79
  assert.match(content, /systemTextTag:\s*"OrderPlaced"/);
80
80
  assert.match(content, /\/\/\(<OrderPlacedHook>\)/);
81
81
 
82
82
  // Relationship
83
- assert.match(content, /nameSpace:\s*"hasCategory_MyService_description"/);
83
+ assert.match(content, /nameSpace:\s*"hasCategory\|MyService\|description"/);
84
84
  assert.match(
85
85
  content,
86
- /systemTextTag:\s*"originTimestamp_hasCategory_MyService"/
86
+ /systemTextTag:\s*"originTimestamp\|hasCategory\|MyService"/
87
87
  );
88
88
 
89
89
  // Custom Flow
90
- assert.match(content, /nameSpace:\s*"ProcessOrder_MyService"/);
91
- assert.match(content, /systemTextTag:\s*"errors_ProcessOrder_MyService"/);
90
+ assert.match(content, /nameSpace:\s*"ProcessOrder\|MyService"/);
91
+ assert.match(content, /systemTextTag:\s*"errors\|ProcessOrder\|MyService"/);
92
92
  });
93
93
 
94
94
  test('emitSystemTextSchemas returns empty array when no inputs provided', async () => {