Skip to content

Commit

Permalink
Merge pull request #19 from lifeomic/remove-type-fest
Browse files Browse the repository at this point in the history
fix: remove type-fest to improve compatibility
  • Loading branch information
swain authored Jan 18, 2024
2 parents 43d0e92 + 84c7128 commit 4f947a7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"@types/async-retry": "^1.4.5",
"async-retry": "^1.3.3",
"lodash": "^4.17.21",
"p-map": "^4.0.0",
"type-fest": "^4.3.1"
"p-map": "^4.0.0"
},
"devDependencies": {
"@aws-sdk/client-dynamodb": "^3.363.0",
Expand Down
21 changes: 10 additions & 11 deletions src/dynamo-expressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
QueryCommandInput,
UpdateCommandInput,
} from '@aws-sdk/lib-dynamodb';
import { SetRequired } from 'type-fest';

import { KeySchema } from './';

Expand Down Expand Up @@ -310,22 +309,22 @@ export type SerializeUpdateParams<Entity> = {
condition?: DynamoDBCondition<Entity>;
};

type SerializeUpdateReturn = Pick<
UpdateCommandInput,
| 'ConditionExpression'
| 'ExpressionAttributeNames'
| 'ExpressionAttributeValues'
> & {
UpdateExpression: string;
};

/**
* Returns DynamoDB client parameters describing the specified update.
*/
export const serializeUpdate = <Entity>({
update,
condition,
}: SerializeUpdateParams<Entity>): SetRequired<
Pick<
UpdateCommandInput,
| 'UpdateExpression'
| 'ConditionExpression'
| 'ExpressionAttributeNames'
| 'ExpressionAttributeValues'
>,
'UpdateExpression'
> => {
}: SerializeUpdateParams<Entity>): SerializeUpdateReturn => {
const {
getSubjectRef,
getObjectRef,
Expand Down
9 changes: 7 additions & 2 deletions src/transaction-manager.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
import { RequireExactlyOne } from 'type-fest';

type WriteTransactionItem = NonNullable<
Parameters<DynamoDBDocument['transactWrite']>[0]['TransactItems']
>[0];

export type TransactionItem =
| Pick<WriteTransactionItem, 'ConditionCheck'>
| Pick<WriteTransactionItem, 'Put'>
| Pick<WriteTransactionItem, 'Delete'>
| Pick<WriteTransactionItem, 'Update'>;

export interface Transaction {
addWrite(writeItem: RequireExactlyOne<WriteTransactionItem>): void;
addWrite(writeItem: TransactionItem): void;
}

/**
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6811,11 +6811,6 @@ type-fest@^3.0.0, type-fest@^3.12.0, type-fest@^3.8.0:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-3.12.0.tgz#4ce26edc1ccc59fc171e495887ef391fe1f5280e"
integrity sha512-qj9wWsnFvVEMUDbESiilKeXeHL7FwwiFcogfhfyjmvT968RXSvnl23f1JOClTHYItsi7o501C/7qVllscUP3oA==

type-fest@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.3.1.tgz#5cb58cdab5120f7ab0b40cfdc35073fb9adb651d"
integrity sha512-pphNW/msgOUSkJbH58x8sqpq8uQj6b0ZKGxEsLKMUnGorRcDjrUaLS+39+/ub41JNTwrrMyJcUB8+YZs3mbwqw==

typescript@^5.1.6:
version "5.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
Expand Down

0 comments on commit 4f947a7

Please sign in to comment.