Skip to content

Commit

Permalink
Merge pull request #557 from architect/tbeseda/update-aws-lite-types
Browse files Browse the repository at this point in the history
tables and ws types inherit from aws-lite _plugins_
  • Loading branch information
tbeseda authored Feb 16, 2024
2 parents 2c23fc3 + ce954f6 commit 7d218ac
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"license": "Apache-2.0",
"dependencies": {
"@aws-lite/apigatewaymanagementapi": "^0.0.8",
"@aws-lite/client": "^0.17.1",
"@aws-lite/client": "^0.17.2",
"@aws-lite/dynamodb": "^0.3.4",
"@aws-lite/sns": "^0.0.5",
"@aws-lite/sqs": "^0.2.1",
Expand All @@ -41,13 +41,13 @@
},
"devDependencies": {
"@architect/asap": "^7.0.7",
"@architect/eslint-config": "2.1.1",
"@architect/eslint-config": "2.1.2",
"@architect/req-res-fixtures": "git+https://github.com/architect/req-res-fixtures.git",
"@architect/sandbox": "^6.0.1",
"@aws-lite/apigatewaymanagementapi-types": "^0.0.10",
"@aws-lite/dynamodb-types": "^0.3.5",
"@aws-lite/sns-types": "^0.0.6",
"@aws-lite/sqs-types": "^0.2.2",
"@architect/sandbox": "^6.0.2",
"@aws-lite/apigatewaymanagementapi-types": "^0.0.11",
"@aws-lite/dynamodb-types": "^0.3.6",
"@aws-lite/sns-types": "^0.0.7",
"@aws-lite/sqs-types": "^0.2.3",
"@types/aws-lambda": "^8.10.133",
"@types/node": "18",
"cross-env": "~7.0.3",
Expand All @@ -56,7 +56,7 @@
"proxyquire": "~2.1.3",
"sinon": "^17.0.1",
"tap-arc": "^1.2.2",
"tape": "^5.7.4",
"tape": "^5.7.5",
"tiny-json-http": "^7.5.1",
"tsd": "^0.30.4"
},
Expand Down
32 changes: 17 additions & 15 deletions types/tables.d.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
import type { AwsLiteClient } from "@aws-lite/client"
import type { QueryResponse, ScanResponse, UpdateItemResponse } from "@aws-lite/dynamodb-types"
import type {
AwsLiteDynamoDB,
QueryResponse,
ScanResponse,
UpdateItemResponse,
} from "@aws-lite/dynamodb-types"
import { Callback } from "./util";

// Turn off automatic exporting
export { };

// TableName not needed as the library sets it
type Params<InputType> = Omit<InputType, "TableName">;
type TablesParams<InputType> = Omit<InputType, "TableName">;

// As above but also overriding the Key field
type ParamsWithKey<InputType, Item> = Omit<Params<InputType>, "Key"> & {
Key: Key<Item>;
};
type TablesParamsWithKey<InputType, Item> = Omit<TablesParams<InputType>, "Key">
& { Key: Key<Item>};

// Just overriding the Items field
type ItemsOutput<OutputType, Item> = Omit<OutputType, "Items"> & {
Items: Item[];
};
type ItemsOutput<OutputType, Item> = Omit<OutputType, "Items">
& { Items: Item[] };

type QueryParams = Params<Parameters<AwsLiteClient["DynamoDB"]["Query"]>[0]>;
type QueryParams = TablesParams<Parameters<AwsLiteDynamoDB["Query"]>[0]>;
type QueryOutput<Item> = ItemsOutput<QueryResponse, Item>;

type ScanParams = Params<Parameters<AwsLiteClient["DynamoDB"]["Scan"]>[0]>;
type ScanParams = TablesParams<Parameters<AwsLiteDynamoDB["Scan"]>[0]>;
type ScanOutput<Item> = ItemsOutput<ScanResponse, Item>;

type UpdateParams<Item> = ParamsWithKey<
Parameters<AwsLiteClient["DynamoDB"]["UpdateItem"]>[0],
type UpdateParams<Item> = TablesParamsWithKey<
Parameters<AwsLiteDynamoDB["UpdateItem"]>[0],
Item
>;

Expand All @@ -51,7 +53,7 @@ export interface ArcTable<Item = unknown> {

scanAll(params: ScanParams): Promise<Item[]>;

update(params: UpdateParams<Item>): Promise<UpdateItemResponse>;
update(params: UpdateParams<Item>): AwsLiteDynamoDB["UpdateItem"];
update(params: UpdateParams<Item>, callback: Callback<UpdateItemResponse>): void;
}

Expand All @@ -64,7 +66,7 @@ export type ArcDB<Tables> = ArcDBWith<Tables> & {
reflect(): {
[tableName in keyof Tables]: string;
};
_client: AwsLiteClient["DynamoDB"];
_client: AwsLiteDynamoDB;
// _db: DynamoDB;
// _doc: DynamoDB.DocumentClient;
};
Expand Down
10 changes: 6 additions & 4 deletions types/ws.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { AwsLiteClient } from "@aws-lite/client"
import type { GetConnectionResponse } from "@aws-lite/apigatewaymanagementapi-types";
import type {
AwsLiteApiGatewayManagementApi,
GetConnectionResponse,
} from "@aws-lite/apigatewaymanagementapi-types";
import { Callback } from "./util";

// Turn off automatic exporting
Expand All @@ -10,8 +12,8 @@ type CloseParams = { id: string };
type InfoParams = { id: string };

export interface ArcWebSocket {
_api(): Promise<AwsLiteClient["ApiGatewayManagementApi"]>;
_api(callback: Callback<AwsLiteClient["ApiGatewayManagementApi"]>): void;
_api(): Promise<AwsLiteApiGatewayManagementApi>;
_api(callback: Callback<AwsLiteApiGatewayManagementApi>): void;

send(params: SendParams): Promise<void>;
send(params: SendParams, callback: Callback<void>): void;
Expand Down

0 comments on commit 7d218ac

Please sign in to comment.