Skip to content

Commit 488e571

Browse files
authored
Merge pull request #109 from amazon-ospo/AddTargetType
feat: Adding TargetType field to installations table
2 parents 5817bc8 + 73ba1da commit 488e571

File tree

7 files changed

+283
-41
lines changed

7 files changed

+283
-41
lines changed

src/packages/app-framework/src/credential-manager/installation-tracker/index.handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export const handlerImpl: Handler = async ({
103103
installationId: installation.id,
104104
appId: appId,
105105
nodeId: installation.account ? installation.account.node_id : '',
106+
targetType: installation.target_type,
106107
};
107108
}),
108109
);

src/packages/app-framework/src/credential-manager/refresh/refreshCachedData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const refreshCachedDataImpl: RefreshCachedData = async ({
8686
installationId: installation.id,
8787
appId: appId,
8888
nodeId: installation.account ? installation.account.node_id : '',
89+
targetType: installation.target_type,
8990
};
9091
}),
9192
);

src/packages/app-framework/src/data.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type InstallationRecord = {
1313
appId: number;
1414
installationId: number;
1515
nodeId: string;
16+
targetType: string;
1617
};
1718

1819
type AppInstallations = {
@@ -115,12 +116,14 @@ export type PutInstallation = ({
115116
appId,
116117
nodeId,
117118
installationId,
119+
targetType,
118120
lastRefreshed,
119121
}: {
120122
tableName: string;
121123
appId: number;
122124
nodeId: string;
123125
installationId: number;
126+
targetType: string;
124127
lastRefreshed?: string;
125128
}) => Promise<void>;
126129

@@ -129,6 +132,7 @@ export const putInstallationImpl: PutInstallation = async ({
129132
appId,
130133
nodeId,
131134
installationId,
135+
targetType,
132136
lastRefreshed,
133137
}): Promise<void> => {
134138
const tableOperations = new TableOperations({
@@ -139,6 +143,7 @@ export const putInstallationImpl: PutInstallation = async ({
139143
AppId: { N: appId.toString() },
140144
NodeId: { S: nodeId },
141145
InstallationId: { N: installationId.toString() },
146+
TargetType: { S: targetType },
142147
LastRefreshed: { S: lastRefreshed || '' },
143148
};
144149

@@ -241,11 +246,13 @@ export const getInstallationsImpl: GetInstallations = async ({ tableName }) => {
241246
itemList.map((item) => {
242247
const appId: number = item.AppId;
243248
const installationId: number = item.InstallationId;
249+
const targetType: string = item.targetType;
244250
const nodeId: string = item.NodeId ?? '';
245251
result.push({
246252
appId,
247253
nodeId,
248254
installationId,
255+
targetType,
249256
});
250257
});
251258
return result;
@@ -278,10 +285,12 @@ export const getInstallationsDataByNodeId: GetInstallationsByNodeId = async ({
278285
const appId: number = item.AppId;
279286
const itemNodeId: string = item.NodeId;
280287
const installationId: number = item.InstallationId;
288+
const targetType: string = item.targetType;
281289
result.push({
282290
appId,
283291
nodeId: itemNodeId,
284292
installationId,
293+
targetType,
285294
});
286295
});
287296

src/packages/app-framework/test/data.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const mockAppId = 12345;
2424
const mockTableName = 'validAppTableName';
2525
const mockNodeId = 'foo';
2626
const mockInstallationId = 123456;
27+
const mockTargetType = 'Organization';
2728
const mockArn = 'arn:aws:kms:region:account:key/mock-key-id';
2829
describe('getKeyArnByID', () => {
2930
it('should successfully retrieve KMS ARN from DynamoDB', async () => {
@@ -224,6 +225,7 @@ describe('getInstallationId', () => {
224225
appId: mockAppId,
225226
installationId: mockInstallationId,
226227
nodeId: mockNodeId,
228+
targetType: mockTargetType,
227229
});
228230

229231
expect(TableOperations).toHaveBeenCalledWith({
@@ -234,6 +236,7 @@ describe('getInstallationId', () => {
234236
InstallationId: { N: mockInstallationId.toString() },
235237
LastRefreshed: { S: '' },
236238
NodeId: { S: mockNodeId },
239+
TargetType: { S: mockTargetType },
237240
});
238241
});
239242

@@ -248,6 +251,7 @@ describe('getInstallationId', () => {
248251
lastRefreshed: '',
249252
installationId: mockInstallationId,
250253
nodeId: mockNodeId,
254+
targetType: mockTargetType,
251255
}),
252256
).rejects.toThrow('DynamoDB service error');
253257
});

src/packages/app-framework/test/get-installation-data/getInstallationData.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ describe('getInstallationsDataImpl', () => {
1414
appId: 12345,
1515
installationId: 67890,
1616
nodeId: mockNodeId,
17+
targetType: 'Organization',
1718
},
1819
{
1920
appId: 54321,
2021
installationId: 98765,
2122
nodeId: mockNodeId,
23+
targetType: 'Organization',
2224
},
2325
];
2426

@@ -94,16 +96,19 @@ describe('getInstallationsDataImpl', () => {
9496
appId: 12345,
9597
installationId: 67890,
9698
nodeId: mockNodeId,
99+
targetType: 'Organization',
97100
},
98101
{
99102
appId: 54321,
100103
installationId: 98765,
101104
nodeId: mockNodeId,
105+
targetType: 'Organization',
102106
},
103107
{
104108
appId: 11111,
105109
installationId: 22222,
106110
nodeId: mockNodeId,
111+
targetType: 'Organization',
107112
},
108113
];
109114
const mockGetInstallationsDataByNodeId = jest

0 commit comments

Comments
 (0)