aws-classify-server 0.1.6 → 0.1.7

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.
@@ -83,13 +83,16 @@ class ClassifyServerless {
83
83
  // Instantiate the class
84
84
  const obj = new classDef.serverClass();
85
85
  // Retrieve session data from DynamoDB base on sessionId in request
86
+ let orignalSessionData = "";
86
87
  const result = yield getSessionData(sessionId, request.interfaceName);
87
88
  if (!result)
88
89
  sessionId = context.awsRequestId;
89
90
  else {
90
91
  const sessionData = result[`interface_${request.interfaceName}`];
91
- if (sessionData) // Enrich it with session data
92
- Object.assign(obj, (0, js_freeze_dry_1.deserialize)(sessionData, classes));
92
+ if (sessionData) { // Enrich it with session data
93
+ orignalSessionData = (0, js_freeze_dry_1.deserialize)(sessionData, classes);
94
+ Object.assign(obj, orignalSessionData);
95
+ }
93
96
  }
94
97
  obj.__sessionId__ = sessionId;
95
98
  obj.__connectionId__ = result === null || result === void 0 ? void 0 : result.connectionId;
@@ -110,7 +113,7 @@ class ClassifyServerless {
110
113
  return (0, js_freeze_dry_1.serialize)(lambdaResponse, classes);
111
114
  }
112
115
  const updatedSessionData = (0, js_freeze_dry_1.serialize)(obj, classes);
113
- if (!result || updatedSessionData !== result.sessionData || (Date.now() > (result.updated + updateDebounceInterval)))
116
+ if (!result || updatedSessionData !== orignalSessionData || (Date.now() > (result.updated + updateDebounceInterval)))
114
117
  sessionId = yield saveSessionData(sessionId, request.interfaceName, updatedSessionData, undefined, obj.__userId__, this.expirationMinutes);
115
118
  // Formulate response
116
119
  const lambdaResponse = {
@@ -243,7 +246,7 @@ class ClassifyServerless {
243
246
  this.log(`creating response for ${interfaceName} with sessionId=${sessionId} connectionId= ${obj.__connectionId__} sessionData=${sessionData}`);
244
247
  const ret = yield callback(obj);
245
248
  const updatedSessionData = (0, js_freeze_dry_1.serialize)(obj, classes);
246
- if (updatedSessionData !== result.sessionData || (Date.now() > (result.updated + updateDebounceInterval))) {
249
+ if (updatedSessionData !== sessionData || (Date.now() > (result.updated + updateDebounceInterval))) {
247
250
  if (this.logLevel.calls)
248
251
  this.log(`saving session data for ${interfaceName} with sessionId=${sessionId} connectionId= ${obj.__connectionId__} sessionData=${updatedSessionData}`);
249
252
  yield saveSessionData(sessionId, interfaceName, updatedSessionData, undefined, undefined, this.expirationMinutes);
@@ -80,13 +80,16 @@ export class ClassifyServerless {
80
80
  // Instantiate the class
81
81
  const obj = new classDef.serverClass();
82
82
  // Retrieve session data from DynamoDB base on sessionId in request
83
+ let orignalSessionData = "";
83
84
  const result = yield getSessionData(sessionId, request.interfaceName);
84
85
  if (!result)
85
86
  sessionId = context.awsRequestId;
86
87
  else {
87
88
  const sessionData = result[`interface_${request.interfaceName}`];
88
- if (sessionData) // Enrich it with session data
89
- Object.assign(obj, deserialize(sessionData, classes));
89
+ if (sessionData) { // Enrich it with session data
90
+ orignalSessionData = deserialize(sessionData, classes);
91
+ Object.assign(obj, orignalSessionData);
92
+ }
90
93
  }
91
94
  obj.__sessionId__ = sessionId;
92
95
  obj.__connectionId__ = result === null || result === void 0 ? void 0 : result.connectionId;
@@ -107,7 +110,7 @@ export class ClassifyServerless {
107
110
  return serialize(lambdaResponse, classes);
108
111
  }
109
112
  const updatedSessionData = serialize(obj, classes);
110
- if (!result || updatedSessionData !== result.sessionData || (Date.now() > (result.updated + updateDebounceInterval)))
113
+ if (!result || updatedSessionData !== orignalSessionData || (Date.now() > (result.updated + updateDebounceInterval)))
111
114
  sessionId = yield saveSessionData(sessionId, request.interfaceName, updatedSessionData, undefined, obj.__userId__, this.expirationMinutes);
112
115
  // Formulate response
113
116
  const lambdaResponse = {
@@ -240,7 +243,7 @@ export class ClassifyServerless {
240
243
  this.log(`creating response for ${interfaceName} with sessionId=${sessionId} connectionId= ${obj.__connectionId__} sessionData=${sessionData}`);
241
244
  const ret = yield callback(obj);
242
245
  const updatedSessionData = serialize(obj, classes);
243
- if (updatedSessionData !== result.sessionData || (Date.now() > (result.updated + updateDebounceInterval))) {
246
+ if (updatedSessionData !== sessionData || (Date.now() > (result.updated + updateDebounceInterval))) {
244
247
  if (this.logLevel.calls)
245
248
  this.log(`saving session data for ${interfaceName} with sessionId=${sessionId} connectionId= ${obj.__connectionId__} sessionData=${updatedSessionData}`);
246
249
  yield saveSessionData(sessionId, interfaceName, updatedSessionData, undefined, undefined, this.expirationMinutes);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-classify-server",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "main": "./lib/cjs/index.js",
5
5
  "module": "./lib/esm/index.js",
6
6
  "types": "./lib/esm/index.d.ts",
@@ -0,0 +1,24 @@
1
+ Resources:
2
+ AWSClassifySessionTable:
3
+ Type: AWS::DynamoDB::Table
4
+ Properties:
5
+ TableName: classifySessionStore.${self:custom.domainName}
6
+ BillingMode: PAY_PER_REQUEST
7
+ AttributeDefinitions:
8
+ - AttributeName: sessionId
9
+ AttributeType: S
10
+ - AttributeName: userId
11
+ AttributeType: S
12
+ KeySchema:
13
+ - AttributeName: sessionId
14
+ KeyType: HASH
15
+ TimeToLiveSpecification:
16
+ AttributeName: expires
17
+ Enabled: true
18
+ GlobalSecondaryIndexes:
19
+ - IndexName: userId
20
+ KeySchema:
21
+ - AttributeName: userId
22
+ KeyType: HASH
23
+ Projection:
24
+ ProjectionType: KEYS_ONLY
@@ -23,4 +23,4 @@ Resources:
23
23
  Projection:
24
24
  ProjectionType: KEYS_ONLY
25
25
  StreamSpecification:
26
- StreamViewType: ${self:custom.SessionStreamViewType, 'NEW_IMAGE'}
26
+ StreamViewType: ${self:custom.SessionStreamViewType, 'NEW_AND_OLD_IMAGES'}