为什么dynamoDB类型为`returnValue`包含字符串'

发布于 2025-02-06 12:58:19 字数 476 浏览 0 评论 0原文

export type ReturnValue = "NONE"|"ALL_OLD"|"UPDATED_OLD"|"ALL_NEW"|"UPDATED_NEW"|string;      
export type ReturnConsumedCapacity = "INDEXES"|"TOTAL"|"NONE"|string;
export type ReturnItemCollectionMetrics = "SIZE"|"NONE"|string;
export type ReturnValuesOnConditionCheckFailure = "ALL_OLD"|"NONE"|string;

这些类型的定义是从AWS-SDK复制的。为什么这些类型的定义包含字符串。它与仅编写的不同是什么不同

export type ReturnValue = string;

,因为它包含字符串类型,因为它没有任何自动完成。

export type ReturnValue = "NONE"|"ALL_OLD"|"UPDATED_OLD"|"ALL_NEW"|"UPDATED_NEW"|string;      
export type ReturnConsumedCapacity = "INDEXES"|"TOTAL"|"NONE"|string;
export type ReturnItemCollectionMetrics = "SIZE"|"NONE"|string;
export type ReturnValuesOnConditionCheckFailure = "ALL_OLD"|"NONE"|string;

These type definitions are copied from aws-sdk. Why these type definitions contain string. How it is different from just writing

export type ReturnValue = string;

I don't get any auto-completion because it contains string type.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戏蝶舞 2025-02-13 12:58:19

AWS SDK V3的构建方式允许亚马逊在不使用较旧的SDK破坏客户的情况下对API进行更新。通过添加|字符串在最后,亚马逊保留了服务在将来添加其他枚举项目以获取命令输出的能力。

同样,为所需属性生成的打字稿附加了|未定义的到类型定义的末尾,而不需要的属性纯粹是可选的对象。这样做是为了允许亚马逊以后从模型中删除所需的属性而不会破坏客户。当操作被超载以处理其他配置选项时,Amazon的API操作经常删除所需的属性。

这些是亚马逊所陈述的原因,但它们似乎比输入命令更多地应用于输出命令类型。亚马逊不认为输入和输出模型应具有不同级别的灵活性。确实有意义的是,命令输出可以为服务提供最大的灵活性,但是命令输入必须同样灵活并不是很有意义。他们似乎只考虑了鲁棒性原则的一半。

The AWS SDK v3 is built in a way that allows Amazon to make updates to APIs without breaking customers using an older SDK. By adding | string at the end, Amazon preserves the ability of a service to add additional enum items in the future for command outputs.

Similarly, the TypeScript generated for required properties appends an | undefined to the end of the type definition, while non-required properties are purely optional objects. This is done to allow Amazon to later remove required properties from the model without breaking customers. Amazon's API operations frequently drop required properties when the operation gets overloaded to handle additional configuration options.

These are Amazon's stated reasons, but they seem to apply more to output command types than input commands. Amazon does not consider that input and output models should have different levels of flexibility. It does make sense that a command output would preserve maximum flexibility for the service to make updates, but it makes less sense that command inputs must be equally flexible. They seem to only be considering one half of the robustness principle.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文