From 6e61ce7ca35b7fdec54a128ced5700974518f7f9 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Tue, 9 Jun 2020 23:24:17 -0700 Subject: [PATCH 1/8] Helper method to convert ISO-8601 time into Date type --- sdk/servicebus/service-bus/src/util/utils.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sdk/servicebus/service-bus/src/util/utils.ts b/sdk/servicebus/service-bus/src/util/utils.ts index 9d5ad7d5ab37..1345168f4e1d 100644 --- a/sdk/servicebus/service-bus/src/util/utils.ts +++ b/sdk/servicebus/service-bus/src/util/utils.ts @@ -242,6 +242,21 @@ export function getIntegerOrUndefined(value: any): number | undefined { return result == NaN ? undefined : result; } +/** + * @internal + * @ignore + * Helper utility to convert ISO-8601 time into Date type, + * or undefined for invalid values. + * @param value + */ +export function getDateOrUndefined(value: string): Date | undefined { + try { + return new Date(value); + } catch (error) { + return undefined; + } +} + /** * @internal * @ignore From 502d156a3061f177e844dabd0214edc5a8682662 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Tue, 9 Jun 2020 23:24:46 -0700 Subject: [PATCH 2/8] createdAt, accessedAt, updatedAt --- .../serializers/namespaceResourceSerializer.ts | 10 +++++----- .../src/serializers/queueResourceSerializer.ts | 15 ++++++++------- .../serializers/subscriptionResourceSerializer.ts | 15 ++++++++------- .../src/serializers/topicResourceSerializer.ts | 15 ++++++++------- 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts index 484819af0f93..6a25a97314cc 100644 --- a/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts @@ -7,7 +7,7 @@ import { deserializeAtomXmlResponse, serializeToAtomXmlRequest } from "../util/atomXmlHelper"; -import { getInteger, getString } from "../util/utils"; +import { getInteger, getString, getDateOrUndefined } from "../util/utils"; /** * Represents the metadata related to a service bus namespace. @@ -19,7 +19,7 @@ export interface NamespaceProperties { /** * The time at which the namespace was created. */ - createdOn: string; + createdAt?: Date; /** * The SKU/tier of the namespace. * "Basic", "Standard" and "Premium" @@ -28,7 +28,7 @@ export interface NamespaceProperties { /** * The last time at which the namespace was modified. */ - updatedOn: string; + updatedAt?: Date; /** * Name of the namespace. */ @@ -55,9 +55,9 @@ export interface NamespaceProperties { export function buildNamespace(rawNamespace: any): NamespaceProperties { const messagingSku = getString(rawNamespace["MessagingSKU"], "messagingSku"); return { - createdOn: getString(rawNamespace["CreatedTime"], "createdOn"), + createdAt: getDateOrUndefined(getString(rawNamespace["CreatedTime"], "createdOn")), messagingSku: messagingSku, - updatedOn: getString(rawNamespace["ModifiedTime"], "updatedOn"), + updatedAt: getDateOrUndefined(getString(rawNamespace["ModifiedTime"], "updatedOn")), name: getString(rawNamespace["Name"], "name"), namespaceType: getString(rawNamespace["NamespaceType"], "namespaceType"), messagingUnits: diff --git a/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts index b797c459e6c3..d327b6843273 100644 --- a/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts @@ -19,7 +19,8 @@ import { getRawAuthorizationRules, getString, getStringOrUndefined, - MessageCountDetails + MessageCountDetails, + getDateOrUndefined } from "../util/utils"; /** @@ -118,9 +119,9 @@ export function buildQueueRuntimeInfo(rawQueue: any): QueueRuntimeInfo { sizeInBytes: getIntegerOrUndefined(rawQueue[Constants.SIZE_IN_BYTES]), messageCount: getIntegerOrUndefined(rawQueue[Constants.MESSAGE_COUNT]), messageCountDetails: getCountDetailsOrUndefined(rawQueue[Constants.COUNT_DETAILS]), - createdOn: rawQueue[Constants.CREATED_AT], - updatedOn: rawQueue[Constants.UPDATED_AT], - accessedOn: rawQueue[Constants.ACCESSED_AT] + createdAt: getDateOrUndefined(rawQueue[Constants.CREATED_AT]), + updatedAt: getDateOrUndefined(rawQueue[Constants.UPDATED_AT]), + accessedAt: getDateOrUndefined(rawQueue[Constants.ACCESSED_AT]) }; } @@ -378,17 +379,17 @@ export interface QueueRuntimeInfo { /** * Created at timestamp */ - createdOn?: string; + createdAt?: Date; /** * Updated at timestamp */ - updatedOn?: string; + updatedAt?: Date; /** * Accessed at timestamp */ - accessedOn?: string; + accessedAt?: Date; /** * The entity's message count. diff --git a/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts index f45a47e00814..02295accf80a 100644 --- a/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts @@ -15,7 +15,8 @@ import { getInteger, getString, getStringOrUndefined, - MessageCountDetails + MessageCountDetails, + getDateOrUndefined } from "../util/utils"; /** @@ -108,9 +109,9 @@ export function buildSubscriptionRuntimeInfo(rawSubscription: any): Subscription topicName: getString(rawSubscription[Constants.TOPIC_NAME], "topicName"), messageCount: getInteger(rawSubscription[Constants.MESSAGE_COUNT], "messageCount"), messageCountDetails: getCountDetailsOrUndefined(rawSubscription[Constants.COUNT_DETAILS]), - createdOn: getString(rawSubscription[Constants.CREATED_AT], "createdOn"), - updatedOn: getString(rawSubscription[Constants.UPDATED_AT], "updatedOn"), - accessedOn: rawSubscription[Constants.ACCESSED_AT] + createdAt: getDateOrUndefined(getString(rawSubscription[Constants.CREATED_AT], "createdOn")), + updatedAt: getDateOrUndefined(getString(rawSubscription[Constants.UPDATED_AT], "updatedOn")), + accessedAt: getDateOrUndefined(rawSubscription[Constants.ACCESSED_AT]) }; } @@ -344,17 +345,17 @@ export interface SubscriptionRuntimeInfo { /** * Created at timestamp */ - createdOn: string; + createdAt?: Date; /** * Updated at timestamp */ - updatedOn: string; + updatedAt?: Date; /** * Accessed at timestamp */ - accessedOn?: string; + accessedAt?: Date; } /** diff --git a/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts index 7c0a77b7d43b..245a6ea7cefa 100644 --- a/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts @@ -17,7 +17,8 @@ import { getIntegerOrUndefined, getRawAuthorizationRules, getString, - getStringOrUndefined + getStringOrUndefined, + getDateOrUndefined } from "../util/utils"; /** @@ -97,9 +98,9 @@ export function buildTopicRuntimeInfo(rawTopic: any): TopicRuntimeInfo { name: getString(rawTopic[Constants.TOPIC_NAME], "topicName"), sizeInBytes: getIntegerOrUndefined(rawTopic[Constants.SIZE_IN_BYTES]), subscriptionCount: getIntegerOrUndefined(rawTopic[Constants.SUBSCRIPTION_COUNT]), - createdOn: rawTopic[Constants.CREATED_AT], - updatedOn: rawTopic[Constants.UPDATED_AT], - accessedOn: rawTopic[Constants.ACCESSED_AT] + createdAt: getDateOrUndefined(rawTopic[Constants.CREATED_AT]), + updatedAt: getDateOrUndefined(rawTopic[Constants.UPDATED_AT]), + accessedAt: getDateOrUndefined(rawTopic[Constants.ACCESSED_AT]) }; } @@ -292,17 +293,17 @@ export interface TopicRuntimeInfo { /** * Created at timestamp */ - createdOn?: string; + createdAt?: Date; /** * Updated at timestamp */ - updatedOn?: string; + updatedAt?: Date; /** * Accessed at timestamp */ - accessedOn?: string; + accessedAt?: Date; } /** From 85d9e14144b9421e56cd434d83cbc5fdd90d5216 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Tue, 9 Jun 2020 23:26:26 -0700 Subject: [PATCH 3/8] update Tests --- .../service-bus/test/atomManagement.spec.ts | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/sdk/servicebus/service-bus/test/atomManagement.spec.ts b/sdk/servicebus/service-bus/test/atomManagement.spec.ts index c96a0139e74b..a29e341effe3 100644 --- a/sdk/servicebus/service-bus/test/atomManagement.spec.ts +++ b/sdk/servicebus/service-bus/test/atomManagement.spec.ts @@ -60,7 +60,7 @@ describe("Atom management - Namespace", function(): void { assert.deepEqualExcluding( namespaceProperties, { messagingSku: "Standard", namespaceType: "Messaging", messagingUnits: undefined } as any, - ["_response", "createdOn", "updatedOn", "name"] + ["_response", "createdAt", "updatedAt", "name"] ); }); }); @@ -415,9 +415,9 @@ describe("Atom management - Authentication", function(): void { ); assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdOn", - "updatedOn", - "accessedOn" + "createdAt", + "updatedAt", + "accessedAt" ]); }); }); @@ -558,7 +558,7 @@ describe("Atom management - Authentication", function(): void { it(`Gets runtime info for existing ${testCase.entityType} entities(multiple) successfully`, async () => { const response = await getEntitiesRuntimeInfo(testCase.entityType, managementTopic1); const name = testCase.entityType === EntityType.SUBSCRIPTION ? "subscriptionName" : "name"; - const paramsToExclude = ["createdOn", "accessedOn", "updatedOn"]; + const paramsToExclude = ["createdAt", "accessedAt", "updatedAt"]; for (const info of response) { if (info[name] == testCase[1].alwaysBeExistingEntity) { assert.deepEqualExcluding(info, testCase[1].output, paramsToExclude); @@ -1101,9 +1101,9 @@ describe("Atom management - Authentication", function(): void { should.equal(response.name, managementTopic1, "Topic name mismatch"); assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdOn", - "updatedOn", - "accessedOn" + "createdAt", + "updatedAt", + "accessedAt" ]); }); }); @@ -1193,9 +1193,9 @@ describe("Atom management - Authentication", function(): void { ); assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdOn", - "updatedOn", - "accessedOn" + "createdAt", + "updatedAt", + "accessedAt" ]); }); }); @@ -1413,9 +1413,9 @@ describe("Atom management - Authentication", function(): void { assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdOn", - "updatedOn", - "accessedOn" + "createdAt", + "updatedAt", + "accessedAt" ]); }); }); @@ -1585,9 +1585,9 @@ describe("Atom management - Authentication", function(): void { should.equal(response.name, managementRule1, "Rule name mismatch"); assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdOn", - "updatedOn", - "accessedOn" + "createdAt", + "updatedAt", + "accessedAt" ]); }); }); @@ -1728,9 +1728,9 @@ describe("Atom management - Authentication", function(): void { assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdOn", - "updatedOn", - "accessedOn" + "createdAt", + "updatedAt", + "accessedAt" ]); } catch (err) { checkForValidErrorScenario(err, testCase.output); @@ -1899,9 +1899,9 @@ describe("Atom management - Authentication", function(): void { assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdOn", - "updatedOn", - "accessedOn" + "createdAt", + "updatedAt", + "accessedAt" ]); } catch (err) { checkForValidErrorScenario(err, testCase.output); @@ -1971,9 +1971,9 @@ describe("Atom management - Authentication", function(): void { assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdOn", - "updatedOn", - "accessedOn" + "createdAt", + "updatedAt", + "accessedAt" ]); } catch (err) { checkForValidErrorScenario(err, testCase.output); @@ -2135,9 +2135,9 @@ describe("Atom management - Authentication", function(): void { assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdOn", - "updatedOn", - "accessedOn" + "createdAt", + "updatedAt", + "accessedAt" ]); } catch (err) { checkForValidErrorScenario(err, testCase.output); From 0f2a1cfcd91d21723935304c2b5f320dd081cdd1 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Wed, 10 Jun 2020 01:08:22 -0700 Subject: [PATCH 4/8] API Report --- .../service-bus/review/service-bus.api.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sdk/servicebus/service-bus/review/service-bus.api.md b/sdk/servicebus/service-bus/review/service-bus.api.md index 79eb177b82c5..78a151bd22b6 100644 --- a/sdk/servicebus/service-bus/review/service-bus.api.md +++ b/sdk/servicebus/service-bus/review/service-bus.api.md @@ -200,12 +200,12 @@ export { MessagingError } // @public export interface NamespaceProperties { - createdOn: string; + createdAt?: Date; messagingSku: string; messagingUnits: number | undefined; name: string; namespaceType: string; - updatedOn: string; + updatedAt?: Date; } // @public @@ -253,13 +253,13 @@ export interface QueueResponse extends QueueDescription { // @public export interface QueueRuntimeInfo { - accessedOn?: string; - createdOn?: string; + accessedAt?: Date; + createdAt?: Date; messageCount?: number; messageCountDetails?: MessageCountDetails; name: string; sizeInBytes?: number; - updatedOn?: string; + updatedAt?: Date; } // @public @@ -513,13 +513,13 @@ export interface SubscriptionResponse extends SubscriptionDescription { // @public export interface SubscriptionRuntimeInfo { - accessedOn?: string; - createdOn: string; + accessedAt?: Date; + createdAt?: Date; messageCount: number; messageCountDetails?: MessageCountDetails; subscriptionName: string; topicName: string; - updatedOn: string; + updatedAt?: Date; } export { TokenCredential } @@ -549,12 +549,12 @@ export interface TopicResponse extends TopicDescription { // @public export interface TopicRuntimeInfo { - accessedOn?: string; - createdOn?: string; + accessedAt?: Date; + createdAt?: Date; name: string; sizeInBytes?: number; subscriptionCount?: number; - updatedOn?: string; + updatedAt?: Date; } // @public From ceb8a36787404f30928d90efcad726d87fe40577 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Wed, 10 Jun 2020 13:47:49 -0700 Subject: [PATCH 5/8] getDateOrUndefined -> getDate --- .../src/serializers/namespaceResourceSerializer.ts | 10 +++++----- .../src/serializers/queueResourceSerializer.ts | 14 +++++++------- .../serializers/subscriptionResourceSerializer.ts | 14 +++++++------- .../src/serializers/topicResourceSerializer.ts | 14 +++++++------- sdk/servicebus/service-bus/src/util/utils.ts | 11 +++-------- 5 files changed, 29 insertions(+), 34 deletions(-) diff --git a/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts index 6a25a97314cc..1b9b8013bbac 100644 --- a/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts @@ -7,7 +7,7 @@ import { deserializeAtomXmlResponse, serializeToAtomXmlRequest } from "../util/atomXmlHelper"; -import { getInteger, getString, getDateOrUndefined } from "../util/utils"; +import { getInteger, getString, getDate } from "../util/utils"; /** * Represents the metadata related to a service bus namespace. @@ -19,7 +19,7 @@ export interface NamespaceProperties { /** * The time at which the namespace was created. */ - createdAt?: Date; + createdAt: Date; /** * The SKU/tier of the namespace. * "Basic", "Standard" and "Premium" @@ -28,7 +28,7 @@ export interface NamespaceProperties { /** * The last time at which the namespace was modified. */ - updatedAt?: Date; + updatedAt: Date; /** * Name of the namespace. */ @@ -55,9 +55,9 @@ export interface NamespaceProperties { export function buildNamespace(rawNamespace: any): NamespaceProperties { const messagingSku = getString(rawNamespace["MessagingSKU"], "messagingSku"); return { - createdAt: getDateOrUndefined(getString(rawNamespace["CreatedTime"], "createdOn")), + createdAt: getDate(rawNamespace["CreatedTime"], "createdAt"), messagingSku: messagingSku, - updatedAt: getDateOrUndefined(getString(rawNamespace["ModifiedTime"], "updatedOn")), + updatedAt: getDate(rawNamespace["ModifiedTime"], "updatedAt"), name: getString(rawNamespace["Name"], "name"), namespaceType: getString(rawNamespace["NamespaceType"], "namespaceType"), messagingUnits: diff --git a/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts index d327b6843273..82db6f37d73b 100644 --- a/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts @@ -20,7 +20,7 @@ import { getString, getStringOrUndefined, MessageCountDetails, - getDateOrUndefined + getDate } from "../util/utils"; /** @@ -119,9 +119,9 @@ export function buildQueueRuntimeInfo(rawQueue: any): QueueRuntimeInfo { sizeInBytes: getIntegerOrUndefined(rawQueue[Constants.SIZE_IN_BYTES]), messageCount: getIntegerOrUndefined(rawQueue[Constants.MESSAGE_COUNT]), messageCountDetails: getCountDetailsOrUndefined(rawQueue[Constants.COUNT_DETAILS]), - createdAt: getDateOrUndefined(rawQueue[Constants.CREATED_AT]), - updatedAt: getDateOrUndefined(rawQueue[Constants.UPDATED_AT]), - accessedAt: getDateOrUndefined(rawQueue[Constants.ACCESSED_AT]) + createdAt: getDate(rawQueue[Constants.CREATED_AT], "createdAt"), + updatedAt: getDate(rawQueue[Constants.UPDATED_AT], "updatedAt"), + accessedAt: getDate(rawQueue[Constants.ACCESSED_AT], "accessedAt") }; } @@ -379,17 +379,17 @@ export interface QueueRuntimeInfo { /** * Created at timestamp */ - createdAt?: Date; + createdAt: Date; /** * Updated at timestamp */ - updatedAt?: Date; + updatedAt: Date; /** * Accessed at timestamp */ - accessedAt?: Date; + accessedAt: Date; /** * The entity's message count. diff --git a/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts index 02295accf80a..e24dccf75044 100644 --- a/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts @@ -16,7 +16,7 @@ import { getString, getStringOrUndefined, MessageCountDetails, - getDateOrUndefined + getDate } from "../util/utils"; /** @@ -109,9 +109,9 @@ export function buildSubscriptionRuntimeInfo(rawSubscription: any): Subscription topicName: getString(rawSubscription[Constants.TOPIC_NAME], "topicName"), messageCount: getInteger(rawSubscription[Constants.MESSAGE_COUNT], "messageCount"), messageCountDetails: getCountDetailsOrUndefined(rawSubscription[Constants.COUNT_DETAILS]), - createdAt: getDateOrUndefined(getString(rawSubscription[Constants.CREATED_AT], "createdOn")), - updatedAt: getDateOrUndefined(getString(rawSubscription[Constants.UPDATED_AT], "updatedOn")), - accessedAt: getDateOrUndefined(rawSubscription[Constants.ACCESSED_AT]) + createdAt: getDate(rawSubscription[Constants.CREATED_AT], "createdAt"), + updatedAt: getDate(rawSubscription[Constants.UPDATED_AT], "updatedAt"), + accessedAt: getDate(rawSubscription[Constants.ACCESSED_AT], "accessedAt") }; } @@ -345,17 +345,17 @@ export interface SubscriptionRuntimeInfo { /** * Created at timestamp */ - createdAt?: Date; + createdAt: Date; /** * Updated at timestamp */ - updatedAt?: Date; + updatedAt: Date; /** * Accessed at timestamp */ - accessedAt?: Date; + accessedAt: Date; } /** diff --git a/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts index 245a6ea7cefa..d840c7021c69 100644 --- a/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts @@ -18,7 +18,7 @@ import { getRawAuthorizationRules, getString, getStringOrUndefined, - getDateOrUndefined + getDate } from "../util/utils"; /** @@ -98,9 +98,9 @@ export function buildTopicRuntimeInfo(rawTopic: any): TopicRuntimeInfo { name: getString(rawTopic[Constants.TOPIC_NAME], "topicName"), sizeInBytes: getIntegerOrUndefined(rawTopic[Constants.SIZE_IN_BYTES]), subscriptionCount: getIntegerOrUndefined(rawTopic[Constants.SUBSCRIPTION_COUNT]), - createdAt: getDateOrUndefined(rawTopic[Constants.CREATED_AT]), - updatedAt: getDateOrUndefined(rawTopic[Constants.UPDATED_AT]), - accessedAt: getDateOrUndefined(rawTopic[Constants.ACCESSED_AT]) + createdAt: getDate(rawTopic[Constants.CREATED_AT], "createdAt"), + updatedAt: getDate(rawTopic[Constants.UPDATED_AT], "updatedAt"), + accessedAt: getDate(rawTopic[Constants.ACCESSED_AT], "accessedAt") }; } @@ -293,17 +293,17 @@ export interface TopicRuntimeInfo { /** * Created at timestamp */ - createdAt?: Date; + createdAt: Date; /** * Updated at timestamp */ - updatedAt?: Date; + updatedAt: Date; /** * Accessed at timestamp */ - accessedAt?: Date; + accessedAt: Date; } /** diff --git a/sdk/servicebus/service-bus/src/util/utils.ts b/sdk/servicebus/service-bus/src/util/utils.ts index 1345168f4e1d..218d97a408f8 100644 --- a/sdk/servicebus/service-bus/src/util/utils.ts +++ b/sdk/servicebus/service-bus/src/util/utils.ts @@ -245,16 +245,11 @@ export function getIntegerOrUndefined(value: any): number | undefined { /** * @internal * @ignore - * Helper utility to convert ISO-8601 time into Date type, - * or undefined for invalid values. + * Helper utility to convert ISO-8601 time into Date type. * @param value */ -export function getDateOrUndefined(value: string): Date | undefined { - try { - return new Date(value); - } catch (error) { - return undefined; - } +export function getDate(value: string, nameOfProperty: string): Date { + return new Date(getString(value, nameOfProperty)); } /** From cd7c057276c66b65a5196d28e531e7594f1393b9 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Wed, 10 Jun 2020 13:52:09 -0700 Subject: [PATCH 6/8] API report --- .../service-bus/review/service-bus.api.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sdk/servicebus/service-bus/review/service-bus.api.md b/sdk/servicebus/service-bus/review/service-bus.api.md index 78a151bd22b6..f1d1c2d30dd9 100644 --- a/sdk/servicebus/service-bus/review/service-bus.api.md +++ b/sdk/servicebus/service-bus/review/service-bus.api.md @@ -200,12 +200,12 @@ export { MessagingError } // @public export interface NamespaceProperties { - createdAt?: Date; + createdAt: Date; messagingSku: string; messagingUnits: number | undefined; name: string; namespaceType: string; - updatedAt?: Date; + updatedAt: Date; } // @public @@ -253,13 +253,13 @@ export interface QueueResponse extends QueueDescription { // @public export interface QueueRuntimeInfo { - accessedAt?: Date; - createdAt?: Date; + accessedAt: Date; + createdAt: Date; messageCount?: number; messageCountDetails?: MessageCountDetails; name: string; sizeInBytes?: number; - updatedAt?: Date; + updatedAt: Date; } // @public @@ -513,13 +513,13 @@ export interface SubscriptionResponse extends SubscriptionDescription { // @public export interface SubscriptionRuntimeInfo { - accessedAt?: Date; - createdAt?: Date; + accessedAt: Date; + createdAt: Date; messageCount: number; messageCountDetails?: MessageCountDetails; subscriptionName: string; topicName: string; - updatedAt?: Date; + updatedAt: Date; } export { TokenCredential } @@ -549,12 +549,12 @@ export interface TopicResponse extends TopicDescription { // @public export interface TopicRuntimeInfo { - accessedAt?: Date; - createdAt?: Date; + accessedAt: Date; + createdAt: Date; name: string; sizeInBytes?: number; subscriptionCount?: number; - updatedAt?: Date; + updatedAt: Date; } // @public From 0f852b050b8da5d5855d5b68be3d58e7f5beeee7 Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Thu, 18 Jun 2020 16:28:33 -0700 Subject: [PATCH 7/8] "At" -> "On" --- .../namespaceResourceSerializer.ts | 8 +-- .../serializers/queueResourceSerializer.ts | 12 ++-- .../subscriptionResourceSerializer.ts | 12 ++-- .../serializers/topicResourceSerializer.ts | 12 ++-- .../service-bus/test/atomManagement.spec.ts | 58 +++++++++---------- 5 files changed, 51 insertions(+), 51 deletions(-) diff --git a/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts index 1b9b8013bbac..add75c4bc129 100644 --- a/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/namespaceResourceSerializer.ts @@ -19,7 +19,7 @@ export interface NamespaceProperties { /** * The time at which the namespace was created. */ - createdAt: Date; + createdOn: Date; /** * The SKU/tier of the namespace. * "Basic", "Standard" and "Premium" @@ -28,7 +28,7 @@ export interface NamespaceProperties { /** * The last time at which the namespace was modified. */ - updatedAt: Date; + updatedOn: Date; /** * Name of the namespace. */ @@ -55,9 +55,9 @@ export interface NamespaceProperties { export function buildNamespace(rawNamespace: any): NamespaceProperties { const messagingSku = getString(rawNamespace["MessagingSKU"], "messagingSku"); return { - createdAt: getDate(rawNamespace["CreatedTime"], "createdAt"), + createdOn: getDate(rawNamespace["CreatedTime"], "createdOn"), messagingSku: messagingSku, - updatedAt: getDate(rawNamespace["ModifiedTime"], "updatedAt"), + updatedOn: getDate(rawNamespace["ModifiedTime"], "updatedOn"), name: getString(rawNamespace["Name"], "name"), namespaceType: getString(rawNamespace["NamespaceType"], "namespaceType"), messagingUnits: diff --git a/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts index 82db6f37d73b..31e24d7200f0 100644 --- a/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/queueResourceSerializer.ts @@ -119,9 +119,9 @@ export function buildQueueRuntimeInfo(rawQueue: any): QueueRuntimeInfo { sizeInBytes: getIntegerOrUndefined(rawQueue[Constants.SIZE_IN_BYTES]), messageCount: getIntegerOrUndefined(rawQueue[Constants.MESSAGE_COUNT]), messageCountDetails: getCountDetailsOrUndefined(rawQueue[Constants.COUNT_DETAILS]), - createdAt: getDate(rawQueue[Constants.CREATED_AT], "createdAt"), - updatedAt: getDate(rawQueue[Constants.UPDATED_AT], "updatedAt"), - accessedAt: getDate(rawQueue[Constants.ACCESSED_AT], "accessedAt") + createdOn: getDate(rawQueue[Constants.CREATED_AT], "createdOn"), + updatedOn: getDate(rawQueue[Constants.UPDATED_AT], "updatedOn"), + accessedOn: getDate(rawQueue[Constants.ACCESSED_AT], "accessedOn") }; } @@ -379,17 +379,17 @@ export interface QueueRuntimeInfo { /** * Created at timestamp */ - createdAt: Date; + createdOn: Date; /** * Updated at timestamp */ - updatedAt: Date; + updatedOn: Date; /** * Accessed at timestamp */ - accessedAt: Date; + accessedOn: Date; /** * The entity's message count. diff --git a/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts index e24dccf75044..4c14bf7ef836 100644 --- a/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/subscriptionResourceSerializer.ts @@ -109,9 +109,9 @@ export function buildSubscriptionRuntimeInfo(rawSubscription: any): Subscription topicName: getString(rawSubscription[Constants.TOPIC_NAME], "topicName"), messageCount: getInteger(rawSubscription[Constants.MESSAGE_COUNT], "messageCount"), messageCountDetails: getCountDetailsOrUndefined(rawSubscription[Constants.COUNT_DETAILS]), - createdAt: getDate(rawSubscription[Constants.CREATED_AT], "createdAt"), - updatedAt: getDate(rawSubscription[Constants.UPDATED_AT], "updatedAt"), - accessedAt: getDate(rawSubscription[Constants.ACCESSED_AT], "accessedAt") + createdOn: getDate(rawSubscription[Constants.CREATED_AT], "createdOn"), + updatedOn: getDate(rawSubscription[Constants.UPDATED_AT], "updatedOn"), + accessedOn: getDate(rawSubscription[Constants.ACCESSED_AT], "accessedOn") }; } @@ -345,17 +345,17 @@ export interface SubscriptionRuntimeInfo { /** * Created at timestamp */ - createdAt: Date; + createdOn: Date; /** * Updated at timestamp */ - updatedAt: Date; + updatedOn: Date; /** * Accessed at timestamp */ - accessedAt: Date; + accessedOn: Date; } /** diff --git a/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts b/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts index d840c7021c69..daaeb3513965 100644 --- a/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts +++ b/sdk/servicebus/service-bus/src/serializers/topicResourceSerializer.ts @@ -98,9 +98,9 @@ export function buildTopicRuntimeInfo(rawTopic: any): TopicRuntimeInfo { name: getString(rawTopic[Constants.TOPIC_NAME], "topicName"), sizeInBytes: getIntegerOrUndefined(rawTopic[Constants.SIZE_IN_BYTES]), subscriptionCount: getIntegerOrUndefined(rawTopic[Constants.SUBSCRIPTION_COUNT]), - createdAt: getDate(rawTopic[Constants.CREATED_AT], "createdAt"), - updatedAt: getDate(rawTopic[Constants.UPDATED_AT], "updatedAt"), - accessedAt: getDate(rawTopic[Constants.ACCESSED_AT], "accessedAt") + createdOn: getDate(rawTopic[Constants.CREATED_AT], "createdOn"), + updatedOn: getDate(rawTopic[Constants.UPDATED_AT], "updatedOn"), + accessedOn: getDate(rawTopic[Constants.ACCESSED_AT], "accessedOn") }; } @@ -293,17 +293,17 @@ export interface TopicRuntimeInfo { /** * Created at timestamp */ - createdAt: Date; + createdOn: Date; /** * Updated at timestamp */ - updatedAt: Date; + updatedOn: Date; /** * Accessed at timestamp */ - accessedAt: Date; + accessedOn: Date; } /** diff --git a/sdk/servicebus/service-bus/test/atomManagement.spec.ts b/sdk/servicebus/service-bus/test/atomManagement.spec.ts index a29e341effe3..c96a0139e74b 100644 --- a/sdk/servicebus/service-bus/test/atomManagement.spec.ts +++ b/sdk/servicebus/service-bus/test/atomManagement.spec.ts @@ -60,7 +60,7 @@ describe("Atom management - Namespace", function(): void { assert.deepEqualExcluding( namespaceProperties, { messagingSku: "Standard", namespaceType: "Messaging", messagingUnits: undefined } as any, - ["_response", "createdAt", "updatedAt", "name"] + ["_response", "createdOn", "updatedOn", "name"] ); }); }); @@ -415,9 +415,9 @@ describe("Atom management - Authentication", function(): void { ); assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdAt", - "updatedAt", - "accessedAt" + "createdOn", + "updatedOn", + "accessedOn" ]); }); }); @@ -558,7 +558,7 @@ describe("Atom management - Authentication", function(): void { it(`Gets runtime info for existing ${testCase.entityType} entities(multiple) successfully`, async () => { const response = await getEntitiesRuntimeInfo(testCase.entityType, managementTopic1); const name = testCase.entityType === EntityType.SUBSCRIPTION ? "subscriptionName" : "name"; - const paramsToExclude = ["createdAt", "accessedAt", "updatedAt"]; + const paramsToExclude = ["createdOn", "accessedOn", "updatedOn"]; for (const info of response) { if (info[name] == testCase[1].alwaysBeExistingEntity) { assert.deepEqualExcluding(info, testCase[1].output, paramsToExclude); @@ -1101,9 +1101,9 @@ describe("Atom management - Authentication", function(): void { should.equal(response.name, managementTopic1, "Topic name mismatch"); assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdAt", - "updatedAt", - "accessedAt" + "createdOn", + "updatedOn", + "accessedOn" ]); }); }); @@ -1193,9 +1193,9 @@ describe("Atom management - Authentication", function(): void { ); assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdAt", - "updatedAt", - "accessedAt" + "createdOn", + "updatedOn", + "accessedOn" ]); }); }); @@ -1413,9 +1413,9 @@ describe("Atom management - Authentication", function(): void { assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdAt", - "updatedAt", - "accessedAt" + "createdOn", + "updatedOn", + "accessedOn" ]); }); }); @@ -1585,9 +1585,9 @@ describe("Atom management - Authentication", function(): void { should.equal(response.name, managementRule1, "Rule name mismatch"); assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdAt", - "updatedAt", - "accessedAt" + "createdOn", + "updatedOn", + "accessedOn" ]); }); }); @@ -1728,9 +1728,9 @@ describe("Atom management - Authentication", function(): void { assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdAt", - "updatedAt", - "accessedAt" + "createdOn", + "updatedOn", + "accessedOn" ]); } catch (err) { checkForValidErrorScenario(err, testCase.output); @@ -1899,9 +1899,9 @@ describe("Atom management - Authentication", function(): void { assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdAt", - "updatedAt", - "accessedAt" + "createdOn", + "updatedOn", + "accessedOn" ]); } catch (err) { checkForValidErrorScenario(err, testCase.output); @@ -1971,9 +1971,9 @@ describe("Atom management - Authentication", function(): void { assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdAt", - "updatedAt", - "accessedAt" + "createdOn", + "updatedOn", + "accessedOn" ]); } catch (err) { checkForValidErrorScenario(err, testCase.output); @@ -2135,9 +2135,9 @@ describe("Atom management - Authentication", function(): void { assert.deepEqualExcluding(response, testCase.output, [ "_response", - "createdAt", - "updatedAt", - "accessedAt" + "createdOn", + "updatedOn", + "accessedOn" ]); } catch (err) { checkForValidErrorScenario(err, testCase.output); From b18fdc636166d0342a4a2c2c86c954500e29766e Mon Sep 17 00:00:00 2001 From: HarshaNalluru Date: Thu, 18 Jun 2020 16:33:28 -0700 Subject: [PATCH 8/8] API Report --- .../service-bus/review/service-bus.api.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sdk/servicebus/service-bus/review/service-bus.api.md b/sdk/servicebus/service-bus/review/service-bus.api.md index 165d9c2cee9b..dea722fbe1b7 100644 --- a/sdk/servicebus/service-bus/review/service-bus.api.md +++ b/sdk/servicebus/service-bus/review/service-bus.api.md @@ -103,12 +103,12 @@ export { MessagingError } // @public export interface NamespaceProperties { - createdAt: Date; + createdOn: Date; messagingSku: string; messagingUnits: number | undefined; name: string; namespaceType: string; - updatedAt: Date; + updatedOn: Date; } // @public @@ -154,13 +154,13 @@ export interface QueueResponse extends QueueDescription, Response { // @public export interface QueueRuntimeInfo { - accessedAt: Date; - createdAt: Date; + accessedOn: Date; + createdOn: Date; messageCount?: number; messageCountDetails?: MessageCountDetails; name: string; sizeInBytes?: number; - updatedAt: Date; + updatedOn: Date; } // @public @@ -433,13 +433,13 @@ export interface SubscriptionResponse extends SubscriptionDescription, Response // @public export interface SubscriptionRuntimeInfo { - accessedAt: Date; - createdAt: Date; + accessedOn: Date; + createdOn: Date; messageCount: number; messageCountDetails?: MessageCountDetails; subscriptionName: string; topicName: string; - updatedAt: Date; + updatedOn: Date; } // @public @@ -480,12 +480,12 @@ export interface TopicResponse extends TopicDescription, Response { // @public export interface TopicRuntimeInfo { - accessedAt: Date; - createdAt: Date; + accessedOn: Date; + createdOn: Date; name: string; sizeInBytes?: number; subscriptionCount?: number; - updatedAt: Date; + updatedOn: Date; } // @public