@pwrdrvr/microapps-datalib 0.0.18 → 0.0.22

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/src/index.ts CHANGED
@@ -1,64 +1,6 @@
1
- import { DynamoDB } from '@aws-sdk/client-dynamodb';
2
- import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
1
+ import { DBManager } from './manager';
2
+ import { Application, IVersionsAndRules } from './models/application';
3
+ import { Rules } from './models/rules';
4
+ import { Version } from './models/version';
3
5
 
4
- import { Config } from './config';
5
- import Application from './models/application';
6
- import Rules from './models/rules';
7
- import Version from './models/version';
8
-
9
- export { Application, Version, Rules };
10
-
11
- export interface IVersionsAndRules {
12
- Versions: Version[];
13
- Rules: Rules;
14
- }
15
-
16
- export default class Manager {
17
- public static async UpdateDefaultRule(appName: string, semVer: string): Promise<void> {
18
- const rules = await Rules.LoadAsync(Manager._ddbDocClient, appName);
19
-
20
- const defaultRule = rules.RuleSet.default;
21
- defaultRule.SemVer = semVer;
22
-
23
- await rules.SaveAsync(this._ddbDocClient);
24
- }
25
-
26
- public static async GetVersionsAndRules(appName: string): Promise<IVersionsAndRules> {
27
- // Get all versions and rules for an app
28
- // Note: versions are moved out of this key as they become inactive
29
- // There should be less than, say, 100 versions per app
30
-
31
- const versionTask = Version.LoadVersionsAsync(Manager._ddbDocClient, appName);
32
- const rulesTask = Rules.LoadAsync(Manager._ddbDocClient, appName);
33
-
34
- await Promise.all([versionTask, rulesTask]);
35
-
36
- return {
37
- Versions: await versionTask,
38
- Rules: await rulesTask,
39
- };
40
- }
41
-
42
- private static _client: DynamoDB;
43
- private static _ddbDocClient: DynamoDBDocument;
44
-
45
- public constructor(args: { dynamoDB: DynamoDB; tableName: string }) {
46
- const { dynamoDB, tableName } = args;
47
- if (Manager._client === undefined) {
48
- Config.TableName = tableName;
49
- Manager._client = dynamoDB;
50
- Manager._ddbDocClient = DynamoDBDocument.from(Manager._client);
51
- }
52
- }
53
-
54
- public static get TableName(): string {
55
- return Config.TableName;
56
- }
57
-
58
- public static get DBClient(): DynamoDB {
59
- return Manager._client;
60
- }
61
- public static get DBDocClient(): DynamoDBDocument {
62
- return Manager._ddbDocClient;
63
- }
64
- }
6
+ export { Application, DBManager, Version, Rules, IVersionsAndRules };
package/src/manager.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
2
+ import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
3
+
4
+ export interface IDBManager {
5
+ readonly client: DynamoDBClient;
6
+ readonly ddbDocClient: DynamoDBDocument;
7
+ }
8
+
9
+ export class DBManager implements IDBManager {
10
+ private _client: DynamoDBClient;
11
+ private _ddbDocClient: DynamoDBDocument;
12
+ private _tableName: string;
13
+
14
+ public get client(): DynamoDBClient {
15
+ return this._client;
16
+ }
17
+
18
+ public get ddbDocClient(): DynamoDBDocument {
19
+ return this._ddbDocClient;
20
+ }
21
+
22
+ public constructor(args: { dynamoClient: DynamoDBClient; tableName: string }) {
23
+ const { dynamoClient, tableName } = args;
24
+ this._tableName = tableName;
25
+ this._client = dynamoClient;
26
+ this._ddbDocClient = DynamoDBDocument.from(this._client);
27
+ }
28
+
29
+ public get tableName(): string {
30
+ return this._tableName;
31
+ }
32
+ public set tableName(value: string) {
33
+ this._tableName = value;
34
+ }
35
+ }
@@ -1,51 +1,61 @@
1
- import { expect } from 'chai';
2
- import { describe, it } from 'mocha';
3
- import { dynamoClient, DropTable, InitializeTable, TEST_TABLE_NAME } from '../../../../fixtures';
4
- import Manager from '../index';
5
- import Application from './application';
1
+ import 'jest-dynalite/withDb';
2
+ import * as dynamodb from '@aws-sdk/client-dynamodb';
3
+ import { DBManager } from '../manager';
4
+ import { Application } from './application';
5
+ import { Version } from './version';
6
+ import { Rules } from './rules';
7
+
8
+ let dynamoClient: dynamodb.DynamoDBClient;
9
+ let dbManager: DBManager;
10
+
11
+ const TEST_TABLE_NAME = 'microapps';
6
12
 
7
13
  describe('application records', () => {
8
- before(async () => {
9
- new Manager({ dynamoDB: dynamoClient.client, tableName: TEST_TABLE_NAME });
10
- });
14
+ beforeAll(() => {
15
+ dynamoClient = new dynamodb.DynamoDBClient({
16
+ endpoint: process.env.MOCK_DYNAMODB_ENDPOINT,
17
+ tls: false,
18
+ region: 'local',
19
+ });
11
20
 
12
- beforeEach(async () => {
13
- // Create the table
14
- await InitializeTable();
21
+ // Init the DB manager to point it at the right table
22
+ dbManager = new DBManager({ dynamoClient, tableName: TEST_TABLE_NAME });
15
23
  });
16
24
 
17
- afterEach(async () => {
18
- await DropTable();
19
- });
25
+ afterAll(() => {
26
+ dynamoClient.destroy();
27
+ }, 20000);
20
28
 
21
29
  it('saving an application should create two records', async () => {
22
30
  const application = new Application();
23
31
  application.AppName = 'Cat';
24
32
  application.DisplayName = 'Dog';
25
33
 
26
- await application.SaveAsync(dynamoClient.ddbDocClient);
34
+ await application.Save(dbManager);
27
35
 
28
36
  {
29
- const { Item } = await dynamoClient.ddbDocClient.get({
30
- TableName: Manager.TableName,
37
+ const { Item } = await dbManager.ddbDocClient.get({
38
+ TableName: TEST_TABLE_NAME,
31
39
  Key: { PK: 'appname#cat', SK: 'application' },
32
40
  });
33
- expect(Item.PK).equal('appname#cat');
34
- expect(Item.SK).equal('application');
35
- expect(Item.AppName).equal('cat');
36
- expect(Item.DisplayName).equal('Dog');
41
+ expect(Item).toBeDefined();
42
+ expect(Item?.PK).toBe('appname#cat');
43
+ expect(Item?.SK).toBe('application');
44
+ expect(Item?.AppName).toBe('cat');
45
+ expect(Item?.DisplayName).toBe('Dog');
37
46
  }
38
47
 
39
48
  {
40
- const { Item } = await dynamoClient.ddbDocClient.get({
41
- TableName: Manager.TableName,
49
+ const { Item } = await dbManager.ddbDocClient.get({
50
+ TableName: TEST_TABLE_NAME,
42
51
  Key: { PK: 'applications', SK: 'appname#cat' },
43
52
  // ProjectionExpression: 'PK,SK,AppName,DisplayName',
44
53
  });
45
- expect(Item.PK).equal('applications');
46
- expect(Item.SK).equal('appname#cat');
47
- expect(Item.AppName).equal('cat');
48
- expect(Item.DisplayName).equal('Dog');
54
+ expect(Item).toBeDefined();
55
+ expect(Item?.PK).toBe('applications');
56
+ expect(Item?.SK).toBe('appname#cat');
57
+ expect(Item?.AppName).toBe('cat');
58
+ expect(Item?.DisplayName).toBe('Dog');
49
59
  }
50
60
  });
51
61
 
@@ -53,64 +63,140 @@ describe('application records', () => {
53
63
  let application = new Application();
54
64
  application.AppName = 'App1';
55
65
  application.DisplayName = 'Application One';
56
- await application.SaveAsync(dynamoClient.ddbDocClient);
66
+ await application.Save(dbManager);
57
67
 
58
68
  application = new Application();
59
69
  application.AppName = 'App2';
60
70
  application.DisplayName = 'Application Two';
61
- await application.SaveAsync(dynamoClient.ddbDocClient);
71
+ await application.Save(dbManager);
62
72
 
63
73
  {
64
- const record = await Application.LoadAsync(dynamoClient.ddbDocClient, 'App1');
74
+ const record = await Application.Load({ dbManager, key: { AppName: 'App1' } });
65
75
 
66
- expect(record.PK).equal('appname#app1');
67
- expect(record.SK).equal('application');
68
- expect(record.AppName).equal('app1');
69
- expect(record.DisplayName).equal('Application One');
76
+ expect(record.PK).toBe('appname#app1');
77
+ expect(record.SK).toBe('application');
78
+ expect(record.AppName).toBe('app1');
79
+ expect(record.DisplayName).toBe('Application One');
70
80
  }
71
81
 
72
82
  {
73
- const record = await Application.LoadAsync(dynamoClient.ddbDocClient, 'App2');
83
+ const record = await Application.Load({ dbManager, key: { AppName: 'App2' } });
74
84
 
75
- expect(record.PK).equal('appname#app2');
76
- expect(record.SK).equal('application');
77
- expect(record.AppName).equal('app2');
78
- expect(record.DisplayName).equal('Application Two');
85
+ expect(record.PK).toBe('appname#app2');
86
+ expect(record.SK).toBe('application');
87
+ expect(record.AppName).toBe('app2');
88
+ expect(record.DisplayName).toBe('Application Two');
79
89
  }
80
90
  });
81
91
 
82
- it('LoadAsync should handle missing records', async () => {
83
- const record = await Application.LoadAsync(dynamoClient.ddbDocClient, 'App1');
84
- expect(record).to.be.equal(undefined);
92
+ it('Load should handle missing records', async () => {
93
+ const record = await Application.Load({ dbManager, key: { AppName: 'App1' } });
94
+ expect(record).toBeUndefined();
85
95
  });
86
96
 
87
97
  it('LoadAllAppsAsync should return all applications', async () => {
88
98
  let application = new Application();
89
99
  application.AppName = 'Bpp1';
90
100
  application.DisplayName = 'Bpplication One';
91
- await application.SaveAsync(dynamoClient.ddbDocClient);
101
+ await application.Save(dbManager);
92
102
 
93
103
  application = new Application();
94
104
  application.AppName = 'Bpp2';
95
105
  application.DisplayName = 'Bpplication Two';
96
- await application.SaveAsync(dynamoClient.ddbDocClient);
106
+ await application.Save(dbManager);
97
107
 
98
- const applications = await Application.LoadAllAppsAsync(dynamoClient.ddbDocClient);
99
- expect(applications).to.exist;
108
+ const applications = await Application.LoadAllApps(dbManager);
109
+ expect(applications).toBeDefined();
100
110
  const appOne = applications.find((value) => {
101
111
  return value.AppName === 'bpp1';
102
112
  });
103
- expect(appOne).to.exist;
104
- expect(appOne).to.have.property('AppName');
105
- expect(appOne.AppName).to.equal('bpp1');
106
- expect(appOne.DisplayName).to.equal('Bpplication One');
113
+ expect(appOne).toBeDefined();
114
+ expect(appOne).toHaveProperty('AppName');
115
+ expect(appOne?.AppName).toBe('bpp1');
116
+ expect(appOne?.DisplayName).toBe('Bpplication One');
107
117
 
108
118
  const appTwo = applications.find((value) => {
109
119
  return value.AppName === 'bpp2';
110
120
  });
111
- expect(appTwo).to.exist;
112
- expect(appTwo).to.have.property('AppName');
113
- expect(appTwo.AppName).to.equal('bpp2');
114
- expect(appTwo.DisplayName).to.equal('Bpplication Two');
121
+ expect(appTwo).toBeDefined();
122
+ expect(appTwo).toHaveProperty('AppName');
123
+ expect(appTwo?.AppName).toBe('bpp2');
124
+ expect(appTwo?.DisplayName).toBe('Bpplication Two');
125
+ });
126
+
127
+ it('should get versions and rules when asked', async () => {
128
+ const app = new Application({
129
+ AppName: 'Bat',
130
+ DisplayName: 'Bat App',
131
+ });
132
+ await app.Save(dbManager);
133
+
134
+ const version = new Version({
135
+ AppName: 'Bat',
136
+ DefaultFile: 'bat.html',
137
+ IntegrationID: 'abcd',
138
+ SemVer: '3.2.1-beta0',
139
+ Status: 'deployed',
140
+ Type: 'next.js',
141
+ });
142
+ await version.Save(dbManager);
143
+
144
+ const rules = new Rules({
145
+ AppName: 'Bat',
146
+ Version: 0,
147
+ RuleSet: { default: { SemVer: '3.2.1-beta0', AttributeName: '', AttributeValue: '' } },
148
+ });
149
+ await rules.Save(dbManager);
150
+
151
+ const versAndRules = await Application.GetVersionsAndRules({
152
+ dbManager,
153
+ key: { AppName: 'bat' },
154
+ });
155
+
156
+ expect(versAndRules).toHaveProperty('Versions');
157
+ expect(versAndRules).toHaveProperty('Rules');
158
+ expect(versAndRules.Rules).toHaveProperty('RuleSet');
159
+ expect(versAndRules.Rules.RuleSet).toHaveProperty('default');
160
+ expect(versAndRules.Rules.RuleSet.default).toHaveProperty('SemVer');
161
+ expect(versAndRules.Rules.RuleSet.default.SemVer).toBe('3.2.1-beta0');
162
+ expect(versAndRules.Versions.length).toBe(1);
163
+ expect(versAndRules.Versions[0].SemVer).toBe('3.2.1-beta0');
164
+ });
165
+
166
+ it('should update default rule', async () => {
167
+ const app = new Application({
168
+ AppName: 'Bat2',
169
+ DisplayName: 'Bat App',
170
+ });
171
+ await app.Save(dbManager);
172
+
173
+ const version = new Version({
174
+ AppName: 'Bat2',
175
+ DefaultFile: 'bat.html',
176
+ IntegrationID: 'abcd',
177
+ SemVer: '3.2.1-beta0',
178
+ Status: 'deployed',
179
+ Type: 'next.js',
180
+ });
181
+ await version.Save(dbManager);
182
+
183
+ const rules = new Rules({
184
+ AppName: 'Bat2',
185
+ Version: 0,
186
+ RuleSet: { default: { SemVer: '3.2.1-beta0', AttributeName: '', AttributeValue: '' } },
187
+ });
188
+ await rules.Save(dbManager);
189
+
190
+ // Check version before update
191
+ let versAndRules = await Application.GetVersionsAndRules({
192
+ dbManager,
193
+ key: { AppName: 'bat2' },
194
+ });
195
+ expect(versAndRules.Rules.RuleSet.default.SemVer).toBe('3.2.1-beta0');
196
+
197
+ // Update default version
198
+ await Application.UpdateDefaultRule({ dbManager, key: { AppName: 'bat2', SemVer: '3.2.2' } });
199
+ versAndRules = await Application.GetVersionsAndRules({ dbManager, key: { AppName: 'bat2' } });
200
+ expect(versAndRules.Rules.RuleSet.default.SemVer).toBe('3.2.2');
115
201
  });
116
202
  });
@@ -1,12 +1,18 @@
1
- import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
2
1
  import { plainToClass } from 'class-transformer';
3
- import { Config } from '../config';
2
+ import { DBManager } from '../manager';
3
+ import { Rules } from './rules';
4
+ import { Version, IVersionRecord } from './version';
4
5
 
5
6
  enum SaveBy {
6
7
  AppName,
7
8
  Applications,
8
9
  }
9
10
 
11
+ export interface IVersionsAndRules {
12
+ Versions: Version[];
13
+ Rules: Rules;
14
+ }
15
+
10
16
  interface IApplicationRecord {
11
17
  PK: string;
12
18
  SK: string;
@@ -14,22 +20,59 @@ interface IApplicationRecord {
14
20
  DisplayName: string;
15
21
  }
16
22
 
17
- export default class Application implements IApplicationRecord {
18
- public static async LoadAsync(
19
- ddbDocClient: DynamoDBDocument,
20
- appName: string,
21
- ): Promise<Application> {
22
- const { Item } = await ddbDocClient.get({
23
- TableName: Config.TableName,
24
- Key: { PK: `appName#${appName}`.toLowerCase(), SK: 'application' },
23
+ export class Application implements IApplicationRecord {
24
+ public static async UpdateDefaultRule(opts: {
25
+ dbManager: DBManager;
26
+ key: Pick<IVersionRecord, 'AppName' | 'SemVer'>;
27
+ }): Promise<void> {
28
+ const { dbManager, key } = opts;
29
+
30
+ const rules = await Rules.Load({ dbManager, key });
31
+
32
+ const defaultRule = rules.RuleSet.default;
33
+ defaultRule.SemVer = key.SemVer;
34
+
35
+ await rules.Save(dbManager);
36
+ }
37
+
38
+ public static async GetVersionsAndRules(opts: {
39
+ dbManager: DBManager;
40
+ key: Pick<IApplicationRecord, 'AppName'>;
41
+ }): Promise<IVersionsAndRules> {
42
+ const { key, dbManager } = opts;
43
+
44
+ // Get all versions and rules for an app
45
+ // Note: versions are moved out of this key as they become inactive
46
+ // There should be less than, say, 100 versions per app
47
+
48
+ const versionTask = Version.LoadVersions({ dbManager, key });
49
+ const rulesTask = Rules.Load({ dbManager, key });
50
+
51
+ await Promise.all([versionTask, rulesTask]);
52
+
53
+ return {
54
+ Versions: await versionTask,
55
+ Rules: await rulesTask,
56
+ };
57
+ }
58
+
59
+ public static async Load(opts: {
60
+ dbManager: DBManager;
61
+ key: Pick<IApplicationRecord, 'AppName'>;
62
+ }): Promise<Application> {
63
+ const { key, dbManager } = opts;
64
+
65
+ const { Item } = await dbManager.ddbDocClient.get({
66
+ TableName: dbManager.tableName,
67
+ Key: { PK: `appName#${key.AppName}`.toLowerCase(), SK: 'application' },
25
68
  });
26
69
  const record = plainToClass<Application, unknown>(Application, Item);
27
70
  return record;
28
71
  }
29
72
 
30
- public static async LoadAllAppsAsync(ddbDocClient: DynamoDBDocument): Promise<Application[]> {
31
- const { Items } = await ddbDocClient.query({
32
- TableName: Config.TableName,
73
+ public static async LoadAllApps(dbManager: DBManager): Promise<Application[]> {
74
+ const { Items } = await dbManager.ddbDocClient.query({
75
+ TableName: dbManager.tableName,
33
76
  KeyConditionExpression: 'PK = :pkval',
34
77
  ExpressionAttributeValues: {
35
78
  ':pkval': 'applications',
@@ -65,20 +108,20 @@ export default class Application implements IApplicationRecord {
65
108
  };
66
109
  }
67
110
 
68
- public async SaveAsync(ddbDocClient: DynamoDBDocument): Promise<void> {
111
+ public async Save(dbManager: DBManager): Promise<void> {
69
112
  // TODO: Validate that all the fields needed are present
70
113
 
71
114
  // Save under specific AppName key
72
115
  this._keyBy = SaveBy.AppName;
73
- const taskByName = ddbDocClient.put({
74
- TableName: Config.TableName,
116
+ const taskByName = dbManager.ddbDocClient.put({
117
+ TableName: dbManager.tableName,
75
118
  Item: this.DbStruct,
76
119
  });
77
120
 
78
121
  // Save under all Applications key
79
122
  this._keyBy = SaveBy.Applications;
80
- const taskByApplications = ddbDocClient.put({
81
- TableName: Config.TableName,
123
+ const taskByApplications = dbManager.ddbDocClient.put({
124
+ TableName: dbManager.tableName,
82
125
  Item: this.DbStruct,
83
126
  });
84
127
 
@@ -1,22 +1,28 @@
1
- import { expect } from 'chai';
2
- import { describe, it } from 'mocha';
3
- import { dynamoClient, InitializeTable, DropTable, TEST_TABLE_NAME } from '../../../../fixtures';
4
- import Manager from '../index';
5
- import Rules from './rules';
1
+ import 'jest-dynalite/withDb';
2
+ import * as dynamodb from '@aws-sdk/client-dynamodb';
3
+ import { DBManager } from '../manager';
4
+ import { Rules } from './rules';
5
+
6
+ let dynamoClient: dynamodb.DynamoDBClient;
7
+ let dbManager: DBManager;
8
+
9
+ const TEST_TABLE_NAME = 'microapps';
6
10
 
7
11
  describe('rules records', () => {
8
- before(async () => {
9
- new Manager({ dynamoDB: dynamoClient.client, tableName: TEST_TABLE_NAME });
10
- });
12
+ beforeAll(() => {
13
+ dynamoClient = new dynamodb.DynamoDBClient({
14
+ endpoint: process.env.MOCK_DYNAMODB_ENDPOINT,
15
+ tls: false,
16
+ region: 'local',
17
+ });
11
18
 
12
- beforeEach(async () => {
13
- // Create the table
14
- await InitializeTable();
19
+ // Init the DB manager to point it at the right table
20
+ dbManager = new DBManager({ dynamoClient, tableName: TEST_TABLE_NAME });
15
21
  });
16
22
 
17
- afterEach(async () => {
18
- await DropTable();
19
- });
23
+ afterAll(() => {
24
+ dynamoClient.destroy();
25
+ }, 20000);
20
26
 
21
27
  it('saving rules should create 1 record', async () => {
22
28
  const rules = new Rules();
@@ -24,19 +30,20 @@ describe('rules records', () => {
24
30
  rules.Version = 0;
25
31
  rules.RuleSet.default = { SemVer: '1.2.3', AttributeName: '', AttributeValue: '' };
26
32
 
27
- await rules.SaveAsync(dynamoClient.ddbDocClient);
33
+ await rules.Save(dbManager);
28
34
 
29
35
  {
30
- const record = await Rules.LoadAsync(dynamoClient.ddbDocClient, 'Cat');
31
-
32
- expect(record.PK).equal('appname#cat');
33
- expect(record.SK).equal('rules');
34
- expect(record.AppName).equal('cat');
35
- expect(record.Version).equal(0);
36
- expect(record).to.have.property('RuleSet');
37
- expect(record.RuleSet).to.have.property('default');
38
- expect(record.RuleSet.default).to.have.property('SemVer');
39
- expect(record.RuleSet.default.SemVer).to.equal('1.2.3');
36
+ const record = await Rules.Load({ dbManager, key: { AppName: 'Cat' } });
37
+
38
+ expect(record).toBeDefined();
39
+ expect(record.PK).toBe('appname#cat');
40
+ expect(record.SK).toBe('rules');
41
+ expect(record.AppName).toBe('cat');
42
+ expect(record.Version).toBe(0);
43
+ expect(record).toHaveProperty('RuleSet');
44
+ expect(record.RuleSet).toHaveProperty('default');
45
+ expect(record.RuleSet.default).toHaveProperty('SemVer');
46
+ expect(record.RuleSet.default.SemVer).toBe('1.2.3');
40
47
  }
41
48
  });
42
49
  });
@@ -1,6 +1,6 @@
1
- import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
2
1
  import { plainToClass } from 'class-transformer';
3
- import { Config } from '../config';
2
+ import { DBManager } from '..';
3
+ import { IVersionRecord } from './version';
4
4
 
5
5
  export interface IRule {
6
6
  SemVer: string;
@@ -18,11 +18,16 @@ export interface IRulesRecord {
18
18
  Version: number;
19
19
  }
20
20
 
21
- export default class Rules implements IRulesRecord {
22
- public static async LoadAsync(ddbDocClient: DynamoDBDocument, appName: string): Promise<Rules> {
23
- const { Item } = await ddbDocClient.get({
24
- TableName: Config.TableName,
25
- Key: { PK: `appName#${appName}`.toLowerCase(), SK: 'rules' },
21
+ export class Rules implements IRulesRecord {
22
+ public static async Load(opts: {
23
+ dbManager: DBManager;
24
+ key: Pick<IVersionRecord, 'AppName'>;
25
+ }): Promise<Rules> {
26
+ const { dbManager, key } = opts;
27
+
28
+ const { Item } = await dbManager.ddbDocClient.get({
29
+ TableName: dbManager.tableName,
30
+ Key: { PK: `appName#${key.AppName}`.toLowerCase(), SK: 'rules' },
26
31
  });
27
32
  const record = plainToClass<Rules, unknown>(Rules, Item);
28
33
  return record;
@@ -49,18 +54,18 @@ export default class Rules implements IRulesRecord {
49
54
  };
50
55
  }
51
56
 
52
- public async SaveAsync(ddbDocClient: DynamoDBDocument): Promise<void> {
57
+ public async Save(dbManager: DBManager): Promise<void> {
53
58
  // TODO: Validate that all the fields needed are present
54
59
 
55
60
  // Save under specific AppName key
56
- const taskByName = ddbDocClient.put({
57
- TableName: Config.TableName,
61
+ const taskByName = dbManager.ddbDocClient.put({
62
+ TableName: dbManager.tableName,
58
63
  Item: this.DbStruct,
59
64
  });
60
65
 
61
66
  // Save under all Applications key
62
- const taskByApplications = ddbDocClient.put({
63
- TableName: Config.TableName,
67
+ const taskByApplications = dbManager.ddbDocClient.put({
68
+ TableName: dbManager.tableName,
64
69
  Item: this.DbStruct,
65
70
  });
66
71