From b6ab68929c785f304d62dcd4a63f0e490e1e5ddf Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Mon, 24 Jun 2024 14:51:11 -0400 Subject: [PATCH 1/3] unify datetime spelling --- .../typespec-client-generator-core/doc/types.tsp | 2 +- .../src/interfaces.ts | 16 ++++++++-------- .../typespec-client-generator-core/src/types.ts | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/typespec-client-generator-core/doc/types.tsp b/packages/typespec-client-generator-core/doc/types.tsp index 8a4b18b7a7..d936eeac44 100644 --- a/packages/typespec-client-generator-core/doc/types.tsp +++ b/packages/typespec-client-generator-core/doc/types.tsp @@ -84,7 +84,7 @@ model SdkBuiltInType extends SdkType { * @property encode: How to encode the datetime and represent to users * @property wireType: What type we end up sending over the wire for a datetime. Can be a string or an int type. */ -model SdkDatetimeType extends SdkType { +model SdkDateTimeType extends SdkType { kind: "datetime"; encode: DateTimeKnownEncoding; wireType: SdkType; diff --git a/packages/typespec-client-generator-core/src/interfaces.ts b/packages/typespec-client-generator-core/src/interfaces.ts index d3fa82fb26..60d2d7ad50 100644 --- a/packages/typespec-client-generator-core/src/interfaces.ts +++ b/packages/typespec-client-generator-core/src/interfaces.ts @@ -86,7 +86,7 @@ interface SdkTypeBase { export type SdkType = | SdkBuiltInType - | SdkDatetimeType + | SdkDateTimeType | SdkDurationType | SdkArrayType | SdkTupleType @@ -197,26 +197,26 @@ export function isSdkFloatKind(kind: string): kind is keyof typeof SdkFloatKinds return kind in SdkFloatKindsEnum; } -const SdkDatetimeEncodingsConst = ["rfc3339", "rfc7231", "unixTimestamp"] as const; +const SdkDateTimeEncodingsConst = ["rfc3339", "rfc7231", "unixTimestamp"] as const; -export function isSdkDatetimeEncodings(encoding: string): encoding is DateTimeKnownEncoding { - return SdkDatetimeEncodingsConst.includes(encoding as DateTimeKnownEncoding); +export function isSdkDateTimeEncodings(encoding: string): encoding is DateTimeKnownEncoding { + return SdkDateTimeEncodingsConst.includes(encoding as DateTimeKnownEncoding); } -interface SdkDatetimeTypeBase extends SdkTypeBase { +interface SdkDateTimeTypeBase extends SdkTypeBase { encode: DateTimeKnownEncoding; wireType: SdkBuiltInType; } -interface SdkUtcDatetimeType extends SdkDatetimeTypeBase { +interface SdkUtcDateTimeType extends SdkDateTimeTypeBase { kind: "utcDateTime"; } -interface SdkOffsetDatetimeType extends SdkDatetimeTypeBase { +interface SdkOffsetDateTimeType extends SdkDateTimeTypeBase { kind: "offsetDateTime"; } -export type SdkDatetimeType = SdkUtcDatetimeType | SdkOffsetDatetimeType; +export type SdkDateTimeType = SdkUtcDateTimeType | SdkOffsetDateTimeType; export interface SdkDurationType extends SdkTypeBase { kind: "duration"; diff --git a/packages/typespec-client-generator-core/src/types.ts b/packages/typespec-client-generator-core/src/types.ts index 76489d382e..a601ee4632 100644 --- a/packages/typespec-client-generator-core/src/types.ts +++ b/packages/typespec-client-generator-core/src/types.ts @@ -59,7 +59,7 @@ import { SdkConstantType, SdkCredentialParameter, SdkCredentialType, - SdkDatetimeType, + SdkDateTimeType, SdkDictionaryType, SdkDurationType, SdkEnumType, @@ -841,7 +841,7 @@ export function getClientTypeWithDiagnostics( ...getSdkTypeBaseHelper(context, type, type.name), encode: "rfc3339", wireType: { ...getSdkTypeBaseHelper(context, type, "string"), encode: "string" }, - } as SdkDatetimeType; + } as SdkDateTimeType; break; } if (type.name === "duration") { From 71b30ce6aa14669a28065938530bd1e6b2bf2d52 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Mon, 24 Jun 2024 14:52:27 -0400 Subject: [PATCH 2/3] add changeset --- .../changes/rename_datetime_type-2024-5-24-14-52-19.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/rename_datetime_type-2024-5-24-14-52-19.md diff --git a/.chronus/changes/rename_datetime_type-2024-5-24-14-52-19.md b/.chronus/changes/rename_datetime_type-2024-5-24-14-52-19.md new file mode 100644 index 0000000000..28b8ca8895 --- /dev/null +++ b/.chronus/changes/rename_datetime_type-2024-5-24-14-52-19.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@azure-tools/typespec-client-generator-core" +--- + +Unify casing of datetime spelling to `DateTime`. Change interface names to `SdkDateTimeType`, `SdkUtcDateTimeType`, and `SdkOffsetDateTimeType` \ No newline at end of file From ff1044838ed60192c48c3d7a23279c3ec8a2f430 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Tue, 25 Jun 2024 16:47:17 -0400 Subject: [PATCH 3/3] add backcompat types for SdkDateTime type renames --- .../src/interfaces.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/typespec-client-generator-core/src/interfaces.ts b/packages/typespec-client-generator-core/src/interfaces.ts index 9b72facf84..45525cfacf 100644 --- a/packages/typespec-client-generator-core/src/interfaces.ts +++ b/packages/typespec-client-generator-core/src/interfaces.ts @@ -218,6 +218,21 @@ interface SdkOffsetDateTimeType extends SdkDateTimeTypeBase { export type SdkDateTimeType = SdkUtcDateTimeType | SdkOffsetDateTimeType; +/** + * @deprecated: Use SdkDateTimeType instead. + */ +export type SdkDatetimeType = SdkDateTimeType; + +/** + * @deprecated: Use SdkUtcDateTimeType instead. + */ +export type SdkUtcDatetimeType = SdkUtcDateTimeType; + +/** + * @deprecated Use SdkOffsetDateTimeType instead. + */ +export type SdkOffsetDatetimeType = SdkOffsetDateTimeType; + export interface SdkDurationType extends SdkTypeBase { kind: "duration"; encode: DurationKnownEncoding;