Skip to content

Commit 3fe5a22

Browse files
Fix existing database access
1 parent 3b638c2 commit 3fe5a22

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

internal/datastore/src/__test__/db.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ const createSupplierConfigTableCommand = new CreateTableCommand({
151151
TableName: "supplier-config",
152152
BillingMode: "PAY_PER_REQUEST",
153153
KeySchema: [
154-
{ AttributeName: "PK", KeyType: "HASH" }, // Partition key
155-
{ AttributeName: "SK", KeyType: "RANGE" }, // Sort key
154+
{ AttributeName: "pk", KeyType: "HASH" }, // Partition key
155+
{ AttributeName: "sk", KeyType: "RANGE" }, // Sort key
156156
],
157157
GlobalSecondaryIndexes: [
158158
{
159159
IndexName: "volumeGroup-index",
160160
KeySchema: [
161-
{ AttributeName: "PK", KeyType: "HASH" }, // Partition key for GSI
161+
{ AttributeName: "pk", KeyType: "HASH" }, // Partition key for GSI
162162
{ AttributeName: "volumeGroup", KeyType: "RANGE" }, // Sort key for GSI
163163
],
164164
Projection: {
@@ -167,8 +167,8 @@ const createSupplierConfigTableCommand = new CreateTableCommand({
167167
},
168168
],
169169
AttributeDefinitions: [
170-
{ AttributeName: "PK", AttributeType: "S" },
171-
{ AttributeName: "SK", AttributeType: "S" },
170+
{ AttributeName: "pk", AttributeType: "S" },
171+
{ AttributeName: "sk", AttributeType: "S" },
172172
{ AttributeName: "volumeGroup", AttributeType: "S" },
173173
],
174174
});

internal/datastore/src/__test__/supplier-config-repository.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { SupplierConfigRepository } from "../supplier-config-repository";
99

1010
function createLetterVariantItem(variantId: string) {
1111
return {
12-
PK: "LETTER_VARIANT",
13-
SK: variantId,
12+
pk: "ENTITY#letter-variant",
13+
sk: `ID#${variantId}`,
1414
id: variantId,
1515
name: `Variant ${variantId}`,
1616
description: `Description for variant ${variantId}`,
@@ -29,8 +29,8 @@ function createVolumeGroupItem(groupId: string, status = "PROD") {
2929
.toISOString()
3030
.split("T")[0]; // Ends in a day to ensure it's active based on end date. Tests can override this if needed.
3131
return {
32-
PK: "VOLUME_GROUP",
33-
SK: groupId,
32+
pk: "ENTITY#volume-group",
33+
sk: `ID#${groupId}`,
3434
id: groupId,
3535
name: `Volume Group ${groupId}`,
3636
description: `Description for volume group ${groupId}`,
@@ -46,8 +46,8 @@ function createSupplierAllocationItem(
4646
supplier: string,
4747
) {
4848
return {
49-
PK: `SUPPLIER_ALLOCATION`,
50-
SK: allocationId,
49+
pk: "ENTITY#supplier-allocation",
50+
sk: `ID#${allocationId}`,
5151
id: allocationId,
5252
status: "PROD",
5353
volumeGroup: groupId,
@@ -58,8 +58,8 @@ function createSupplierAllocationItem(
5858

5959
function createSupplierItem(supplierId: string) {
6060
return {
61-
PK: "SUPPLIER",
62-
SK: supplierId,
61+
pk: "ENTITY#supplier",
62+
sk: `ID#${supplierId}`,
6363
id: supplierId,
6464
name: `Supplier ${supplierId}`,
6565
channelType: "LETTER",

internal/datastore/src/supplier-config-repository.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class SupplierConfigRepository {
2828
const result = await this.ddbClient.send(
2929
new GetCommand({
3030
TableName: this.config.supplierConfigTableName,
31-
Key: { PK: "LETTER_VARIANT", SK: variantId },
31+
Key: { pk: "ENTITY#letter-variant", sk: `ID#${variantId}` },
3232
}),
3333
);
3434
if (!result.Item) {
@@ -42,7 +42,7 @@ export class SupplierConfigRepository {
4242
const result = await this.ddbClient.send(
4343
new GetCommand({
4444
TableName: this.config.supplierConfigTableName,
45-
Key: { PK: "VOLUME_GROUP", SK: groupId },
45+
Key: { pk: "ENTITY#volume-group", sk: `ID#${groupId}` },
4646
}),
4747
);
4848
if (!result.Item) {
@@ -61,12 +61,12 @@ export class SupplierConfigRepository {
6161
KeyConditionExpression: "#pk = :pk AND #group = :groupId",
6262
FilterExpression: "#status = :status ",
6363
ExpressionAttributeNames: {
64-
"#pk": "PK",
64+
"#pk": "pk",
6565
"#group": "volumeGroup",
6666
"#status": "status",
6767
},
6868
ExpressionAttributeValues: {
69-
":pk": "SUPPLIER_ALLOCATION",
69+
":pk": "ENTITY#supplier-allocation",
7070
":groupId": groupId,
7171
":status": "PROD",
7272
},
@@ -87,7 +87,7 @@ export class SupplierConfigRepository {
8787
const result = await this.ddbClient.send(
8888
new GetCommand({
8989
TableName: this.config.supplierConfigTableName,
90-
Key: { PK: "SUPPLIER", SK: supplierId },
90+
Key: { pk: "ENTITY#supplier", sk: `ID#${supplierId}` },
9191
}),
9292
);
9393
if (!result.Item) {

0 commit comments

Comments
 (0)