Skip to content

fix(lib-dynamodb): input types conflicts with client-dynamodb #6683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,11 @@ private void writeStructureMemberOmitType(MemberShape member) {
String optionalSuffix = isRequiredMember(member) ? "" : "?";
writer.openBlock("${L}${L}: ", ";", symbolProvider.toMemberName(member),
optionalSuffix, () -> {
writeMemberOmitType(member);
writeMemberOmitType(member, true);
});
}

private void writeMemberOmitType(MemberShape member) {
private void writeMemberOmitType(MemberShape member, boolean allowUndefined) {
Shape memberTarget = model.expectShape(member.getTarget());
if (memberTarget.isStructureShape()) {
writeStructureOmitType((StructureShape) memberTarget);
Expand All @@ -413,16 +413,17 @@ private void writeMemberOmitType(MemberShape member) {
} else if (memberTarget.isMapShape()) {
MemberShape mapMember = ((MapShape) memberTarget).getValue();
writer.openBlock("Record<string, ", ">", () -> {
writeMemberOmitType(mapMember);
writeMemberOmitType(mapMember, false);
});
} else if (memberTarget instanceof CollectionShape) {
MemberShape collectionMember = ((CollectionShape) memberTarget).getMember();
writer.openBlock("(", ")[]", () -> {
writeMemberOmitType(collectionMember);
writeMemberOmitType(collectionMember, false);
});
}
String typeSuffix = isRequiredMember(member) ? " | undefined" : "";
writer.write("${L}", typeSuffix);
if (allowUndefined) {
writer.write(" | undefined");
}
}

private void writeNativeAttributeValue() {
Expand Down
18 changes: 11 additions & 7 deletions lib/lib-dynamodb/src/commands/BatchExecuteStatementCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export { DynamoDBDocumentClientCommand, $Command };
export type BatchExecuteStatementCommandInput = Omit<__BatchExecuteStatementCommandInput, "Statements"> & {
Statements:
| (Omit<BatchStatementRequest, "Parameters"> & {
Parameters?: NativeAttributeValue[];
Parameters?: NativeAttributeValue[] | undefined;
})[]
| undefined;
};
Expand All @@ -27,12 +27,16 @@ export type BatchExecuteStatementCommandInput = Omit<__BatchExecuteStatementComm
* @public
*/
export type BatchExecuteStatementCommandOutput = Omit<__BatchExecuteStatementCommandOutput, "Responses"> & {
Responses?: (Omit<BatchStatementResponse, "Error" | "Item"> & {
Error?: Omit<BatchStatementError, "Item"> & {
Item?: Record<string, NativeAttributeValue>;
};
Item?: Record<string, NativeAttributeValue>;
})[];
Responses?:
| (Omit<BatchStatementResponse, "Error" | "Item"> & {
Error?:
| (Omit<BatchStatementError, "Item"> & {
Item?: Record<string, NativeAttributeValue> | undefined;
})
| undefined;
Item?: Record<string, NativeAttributeValue> | undefined;
})[]
| undefined;
};

/**
Expand Down
16 changes: 9 additions & 7 deletions lib/lib-dynamodb/src/commands/BatchGetCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ export type BatchGetCommandInput = Omit<__BatchGetItemCommandInput, "RequestItem
* @public
*/
export type BatchGetCommandOutput = Omit<__BatchGetItemCommandOutput, "Responses" | "UnprocessedKeys"> & {
Responses?: Record<string, Record<string, NativeAttributeValue>[]>;
UnprocessedKeys?: Record<
string,
Omit<KeysAndAttributes, "Keys"> & {
Keys: Record<string, NativeAttributeValue>[] | undefined;
}
>;
Responses?: Record<string, Record<string, NativeAttributeValue>[]> | undefined;
UnprocessedKeys?:
| Record<
string,
Omit<KeysAndAttributes, "Keys"> & {
Keys: Record<string, NativeAttributeValue>[] | undefined;
}
>
| undefined;
};

/**
Expand Down
58 changes: 35 additions & 23 deletions lib/lib-dynamodb/src/commands/BatchWriteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ export type BatchWriteCommandInput = Omit<__BatchWriteItemCommandInput, "Request
| Record<
string,
(Omit<WriteRequest, "PutRequest" | "DeleteRequest"> & {
PutRequest?: Omit<PutRequest, "Item"> & {
Item: Record<string, NativeAttributeValue> | undefined;
};
DeleteRequest?: Omit<DeleteRequest, "Key"> & {
Key: Record<string, NativeAttributeValue> | undefined;
};
PutRequest?:
| (Omit<PutRequest, "Item"> & {
Item: Record<string, NativeAttributeValue> | undefined;
})
| undefined;
DeleteRequest?:
| (Omit<DeleteRequest, "Key"> & {
Key: Record<string, NativeAttributeValue> | undefined;
})
| undefined;
})[]
>
| undefined;
Expand All @@ -38,23 +42,31 @@ export type BatchWriteCommandOutput = Omit<
__BatchWriteItemCommandOutput,
"UnprocessedItems" | "ItemCollectionMetrics"
> & {
UnprocessedItems?: Record<
string,
(Omit<WriteRequest, "PutRequest" | "DeleteRequest"> & {
PutRequest?: Omit<PutRequest, "Item"> & {
Item: Record<string, NativeAttributeValue> | undefined;
};
DeleteRequest?: Omit<DeleteRequest, "Key"> & {
Key: Record<string, NativeAttributeValue> | undefined;
};
})[]
>;
ItemCollectionMetrics?: Record<
string,
(Omit<ItemCollectionMetrics, "ItemCollectionKey"> & {
ItemCollectionKey?: Record<string, NativeAttributeValue>;
})[]
>;
UnprocessedItems?:
| Record<
string,
(Omit<WriteRequest, "PutRequest" | "DeleteRequest"> & {
PutRequest?:
| (Omit<PutRequest, "Item"> & {
Item: Record<string, NativeAttributeValue> | undefined;
})
| undefined;
DeleteRequest?:
| (Omit<DeleteRequest, "Key"> & {
Key: Record<string, NativeAttributeValue> | undefined;
})
| undefined;
})[]
>
| undefined;
ItemCollectionMetrics?:
| Record<
string,
(Omit<ItemCollectionMetrics, "ItemCollectionKey"> & {
ItemCollectionKey?: Record<string, NativeAttributeValue> | undefined;
})[]
>
| undefined;
};

/**
Expand Down
28 changes: 16 additions & 12 deletions lib/lib-dynamodb/src/commands/DeleteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,28 @@ export { DynamoDBDocumentClientCommand, $Command };
*/
export type DeleteCommandInput = Omit<__DeleteItemCommandInput, "Key" | "Expected" | "ExpressionAttributeValues"> & {
Key: Record<string, NativeAttributeValue> | undefined;
Expected?: Record<
string,
Omit<ExpectedAttributeValue, "Value" | "AttributeValueList"> & {
Value?: NativeAttributeValue;
AttributeValueList?: NativeAttributeValue[];
}
>;
ExpressionAttributeValues?: Record<string, NativeAttributeValue>;
Expected?:
| Record<
string,
Omit<ExpectedAttributeValue, "Value" | "AttributeValueList"> & {
Value?: NativeAttributeValue | undefined;
AttributeValueList?: NativeAttributeValue[] | undefined;
}
>
| undefined;
ExpressionAttributeValues?: Record<string, NativeAttributeValue> | undefined;
};

/**
* @public
*/
export type DeleteCommandOutput = Omit<__DeleteItemCommandOutput, "Attributes" | "ItemCollectionMetrics"> & {
Attributes?: Record<string, NativeAttributeValue>;
ItemCollectionMetrics?: Omit<ItemCollectionMetrics, "ItemCollectionKey"> & {
ItemCollectionKey?: Record<string, NativeAttributeValue>;
};
Attributes?: Record<string, NativeAttributeValue> | undefined;
ItemCollectionMetrics?:
| (Omit<ItemCollectionMetrics, "ItemCollectionKey"> & {
ItemCollectionKey?: Record<string, NativeAttributeValue> | undefined;
})
| undefined;
};

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/lib-dynamodb/src/commands/ExecuteStatementCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export { DynamoDBDocumentClientCommand, $Command };
* @public
*/
export type ExecuteStatementCommandInput = Omit<__ExecuteStatementCommandInput, "Parameters"> & {
Parameters?: NativeAttributeValue[];
Parameters?: NativeAttributeValue[] | undefined;
};

/**
* @public
*/
export type ExecuteStatementCommandOutput = Omit<__ExecuteStatementCommandOutput, "Items" | "LastEvaluatedKey"> & {
Items?: Record<string, NativeAttributeValue>[];
LastEvaluatedKey?: Record<string, NativeAttributeValue>;
Items?: Record<string, NativeAttributeValue>[] | undefined;
LastEvaluatedKey?: Record<string, NativeAttributeValue> | undefined;
};

/**
Expand Down
10 changes: 6 additions & 4 deletions lib/lib-dynamodb/src/commands/ExecuteTransactionCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export { DynamoDBDocumentClientCommand, $Command };
export type ExecuteTransactionCommandInput = Omit<__ExecuteTransactionCommandInput, "TransactStatements"> & {
TransactStatements:
| (Omit<ParameterizedStatement, "Parameters"> & {
Parameters?: NativeAttributeValue[];
Parameters?: NativeAttributeValue[] | undefined;
})[]
| undefined;
};
Expand All @@ -27,9 +27,11 @@ export type ExecuteTransactionCommandInput = Omit<__ExecuteTransactionCommandInp
* @public
*/
export type ExecuteTransactionCommandOutput = Omit<__ExecuteTransactionCommandOutput, "Responses"> & {
Responses?: (Omit<ItemResponse, "Item"> & {
Item?: Record<string, NativeAttributeValue>;
})[];
Responses?:
| (Omit<ItemResponse, "Item"> & {
Item?: Record<string, NativeAttributeValue> | undefined;
})[]
| undefined;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/lib-dynamodb/src/commands/GetCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type GetCommandInput = Omit<__GetItemCommandInput, "Key"> & {
* @public
*/
export type GetCommandOutput = Omit<__GetItemCommandOutput, "Item"> & {
Item?: Record<string, NativeAttributeValue>;
Item?: Record<string, NativeAttributeValue> | undefined;
};

/**
Expand Down
28 changes: 16 additions & 12 deletions lib/lib-dynamodb/src/commands/PutCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,28 @@ export { DynamoDBDocumentClientCommand, $Command };
*/
export type PutCommandInput = Omit<__PutItemCommandInput, "Item" | "Expected" | "ExpressionAttributeValues"> & {
Item: Record<string, NativeAttributeValue> | undefined;
Expected?: Record<
string,
Omit<ExpectedAttributeValue, "Value" | "AttributeValueList"> & {
Value?: NativeAttributeValue;
AttributeValueList?: NativeAttributeValue[];
}
>;
ExpressionAttributeValues?: Record<string, NativeAttributeValue>;
Expected?:
| Record<
string,
Omit<ExpectedAttributeValue, "Value" | "AttributeValueList"> & {
Value?: NativeAttributeValue | undefined;
AttributeValueList?: NativeAttributeValue[] | undefined;
}
>
| undefined;
ExpressionAttributeValues?: Record<string, NativeAttributeValue> | undefined;
};

/**
* @public
*/
export type PutCommandOutput = Omit<__PutItemCommandOutput, "Attributes" | "ItemCollectionMetrics"> & {
Attributes?: Record<string, NativeAttributeValue>;
ItemCollectionMetrics?: Omit<ItemCollectionMetrics, "ItemCollectionKey"> & {
ItemCollectionKey?: Record<string, NativeAttributeValue>;
};
Attributes?: Record<string, NativeAttributeValue> | undefined;
ItemCollectionMetrics?:
| (Omit<ItemCollectionMetrics, "ItemCollectionKey"> & {
ItemCollectionKey?: Record<string, NativeAttributeValue> | undefined;
})
| undefined;
};

/**
Expand Down
36 changes: 20 additions & 16 deletions lib/lib-dynamodb/src/commands/QueryCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,32 @@ export type QueryCommandInput = Omit<
__QueryCommandInput,
"KeyConditions" | "QueryFilter" | "ExclusiveStartKey" | "ExpressionAttributeValues"
> & {
KeyConditions?: Record<
string,
Omit<Condition, "AttributeValueList"> & {
AttributeValueList?: NativeAttributeValue[];
}
>;
QueryFilter?: Record<
string,
Omit<Condition, "AttributeValueList"> & {
AttributeValueList?: NativeAttributeValue[];
}
>;
ExclusiveStartKey?: Record<string, NativeAttributeValue>;
ExpressionAttributeValues?: Record<string, NativeAttributeValue>;
KeyConditions?:
| Record<
string,
Omit<Condition, "AttributeValueList"> & {
AttributeValueList?: NativeAttributeValue[] | undefined;
}
>
| undefined;
QueryFilter?:
| Record<
string,
Omit<Condition, "AttributeValueList"> & {
AttributeValueList?: NativeAttributeValue[] | undefined;
}
>
| undefined;
ExclusiveStartKey?: Record<string, NativeAttributeValue> | undefined;
ExpressionAttributeValues?: Record<string, NativeAttributeValue> | undefined;
};

/**
* @public
*/
export type QueryCommandOutput = Omit<__QueryCommandOutput, "Items" | "LastEvaluatedKey"> & {
Items?: Record<string, NativeAttributeValue>[];
LastEvaluatedKey?: Record<string, NativeAttributeValue>;
Items?: Record<string, NativeAttributeValue>[] | undefined;
LastEvaluatedKey?: Record<string, NativeAttributeValue> | undefined;
};

/**
Expand Down
22 changes: 12 additions & 10 deletions lib/lib-dynamodb/src/commands/ScanCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@ export type ScanCommandInput = Omit<
__ScanCommandInput,
"ScanFilter" | "ExclusiveStartKey" | "ExpressionAttributeValues"
> & {
ScanFilter?: Record<
string,
Omit<Condition, "AttributeValueList"> & {
AttributeValueList?: NativeAttributeValue[];
}
>;
ExclusiveStartKey?: Record<string, NativeAttributeValue>;
ExpressionAttributeValues?: Record<string, NativeAttributeValue>;
ScanFilter?:
| Record<
string,
Omit<Condition, "AttributeValueList"> & {
AttributeValueList?: NativeAttributeValue[] | undefined;
}
>
| undefined;
ExclusiveStartKey?: Record<string, NativeAttributeValue> | undefined;
ExpressionAttributeValues?: Record<string, NativeAttributeValue> | undefined;
};

/**
* @public
*/
export type ScanCommandOutput = Omit<__ScanCommandOutput, "Items" | "LastEvaluatedKey"> & {
Items?: Record<string, NativeAttributeValue>[];
LastEvaluatedKey?: Record<string, NativeAttributeValue>;
Items?: Record<string, NativeAttributeValue>[] | undefined;
LastEvaluatedKey?: Record<string, NativeAttributeValue> | undefined;
};

/**
Expand Down
8 changes: 5 additions & 3 deletions lib/lib-dynamodb/src/commands/TransactGetCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ export type TransactGetCommandInput = Omit<__TransactGetItemsCommandInput, "Tran
* @public
*/
export type TransactGetCommandOutput = Omit<__TransactGetItemsCommandOutput, "Responses"> & {
Responses?: (Omit<ItemResponse, "Item"> & {
Item?: Record<string, NativeAttributeValue>;
})[];
Responses?:
| (Omit<ItemResponse, "Item"> & {
Item?: Record<string, NativeAttributeValue> | undefined;
})[]
| undefined;
};

/**
Expand Down
Loading
Loading