diff --git a/types/azure-sb/index.d.ts b/types/azure-sb/index.d.ts index bd62e100ab..ef81007c91 100644 --- a/types/azure-sb/index.d.ts +++ b/types/azure-sb/index.d.ts @@ -4,316 +4,361 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 -export import ServiceBusService = require('./lib/servicebusservice'); -export import NotificationHubService = require('./lib/notificationhubservice'); -export import WrapService = require('./lib/wrapservice'); +export import ServiceBusService = require("./lib/servicebusservice"); +export import NotificationHubService = require("./lib/notificationhubservice"); +export import WrapService = require("./lib/wrapservice"); -export function createServiceBusService(namespaceOrConnectionString?: string, - accessKey?: string, - issuer?: string, - acsNamespace?: string, - host?: string, - authenticationProvider?: object): ServiceBusService; +export function createServiceBusService( + namespaceOrConnectionString?: string, + accessKey?: string, + issuer?: string, + acsNamespace?: string, + host?: string, + authenticationProvider?: object +): ServiceBusService; -export function createNotificationHubService(hubName: string, - endpointOrConnectionString?: string, - sharedAccessKeyName?: string, - sharedAccessKeyValue?: string): NotificationHubService; +export function createNotificationHubService( + hubName: string, + endpointOrConnectionString?: string, + sharedAccessKeyName?: string, + sharedAccessKeyValue?: string +): NotificationHubService; -export function createWrapService(acsHost: string, - issuer?: string, - accessKey?: string): WrapService; +export function createWrapService( + acsHost: string, + issuer?: string, + accessKey?: string +): WrapService; export namespace Azure.ServiceBus { - export type Duration = string; - export type DateString = string; + export type Duration = string; + export type DateString = string; - export interface Dictionary { - [k: string]: T; - } + export interface Dictionary { + [k: string]: T; + } - export interface ReceiveQueueMessageOptions { - timeoutIntervalInS?: number; - } + export interface ReceiveQueueMessageOptions { + timeoutIntervalInS?: number; + } - export interface ReceiveSubscriptionMessageOptions extends ReceiveQueueMessageOptions { - isPeekLock?: boolean; - } + export interface ReceiveSubscriptionMessageOptions + extends ReceiveQueueMessageOptions { + isPeekLock?: boolean; + } - interface IBrokerPropertiesResponse { - readonly DeliveryCount: number; - readonly LockedUntil: DateString; - readonly LockToken: string; - readonly SequenceNumber: number; - } + interface IBrokerPropertiesResponse { + readonly DeliveryCount: number; + readonly LockedUntil: DateString; + readonly LockToken: string; + readonly SequenceNumber: number; + } - interface IBrokerProperties { - CorrelationId: string; - Label: string; - MessageId: string; - PartitionKey: string; - ReplyTo: string; - ReplyToSessionId: string; - ScheduledEnqueueTimeUtc: string; - SessionId: string; - TimeToLive: string; - To: string; - } + interface IBrokerProperties { + CorrelationId: string; + Label: string; + MessageId: string; + PartitionKey: string; + ReplyTo: string; + ReplyToSessionId: string; + ScheduledEnqueueTimeUtc: string; + SessionId: string; + TimeToLive: string; + To: string; + } - export interface Message { + export interface Message { + body: string; + brokerProperties?: BrokerProperties; + contentType?: string; + customProperties?: Dictionary; + } + + /* + * Options interfaces + */ + + interface CreateOptions { + DefaultMessageTimeToLive: string; + DuplicateDetectionHistoryTimeWindow: string; + EnablePartitioning: boolean; + MaxSizeInMegabytes: number; + RequiresDuplicateDetection: boolean; + } + + interface IQueueOptions extends CreateOptions { + AutoDeleteOnIdle: string; + DeadLetteringOnMessageExpiration: boolean; + LockDuration: string; + RequiresSession: boolean; + } + + interface ICreateTopicOptions extends CreateOptions { + EnableBatchedOperations: boolean; + SizeInBytes: boolean; + SupportOrdering: boolean; + } + + interface ICreateTopicIfNotExistsOptions extends ICreateTopicOptions { + EnableDeadLetteringOnFilterEvaluationExceptions: boolean; + EnableDeadLetteringOnMessageExpiration: boolean; + MaxCorrelationFiltersPerTopic: number; + MaxSqlFiltersPerTopic: number; + MaxSubscriptionsPerTopic: number; + } + + interface ICreateSubscriptionOptions { + DefaultMessageTimeToLive: string; + EnableDeadLetteringOnFilterEvaluationExceptions: boolean; + EnableDeadLetteringOnMessageExpiration: boolean; + LockDuration: string; + RequiresSession: boolean; + } + + interface PaginationOptions { + top: number; + skip: number; + } + + interface ICreateRuleOptions { + trueFilter: string; + falseFilter: string; + sqlExpressionFilter: string; + correlationIdFilter: string; + sqlRuleAction: string; + } + + interface ICreateNotificationHubOptions { + apns: Dictionary; + gcm: Dictionary; + mpns: Dictionary; + wns: Dictionary; + } + + export interface NotificationHubRegistration { + BodyTemplate?: any; + ChannelUri?: string; + DeviceToken?: string; + Expiry?: Date; + gcmRegistrationId?: string; + MpnsHeaders?: any; + RegistrationId: string; + Tags?: string; + WnsHeaders?: any; + } + export interface NotificationHubInstallation { + installationId: string; + readonly lastActiveOn?: string; + readonly expirationTime?: string; + readonly lastUpdate?: string; + platform: "apns" | "wns" | "mpns" | "adm" | "gcm"; + pushChannel: string; + readonly expiredPushChannel?: string; + tags?: Array; + templates?: { + [name: string]: { body: string; - brokerProperties?: BrokerProperties; - contentType?: string; - customProperties?: Dictionary; + headers?: any; + expiry?: string; + tags?: Array; + }; + }; + secondaryTile?: { + [titleId: string]: { + pushChannel: string; + tags?: Array; + templates?: any; + }; + }; + } + + export interface Response { + body: Dictionary; + headers: Dictionary; + isSuccessful: boolean; + md5?: string; + statusCode: number; + } + + export interface ErrorResponse extends Response { + body: { + Error: { + Code: string; + Detail: string; + }; + }; + } + + export namespace Results.Models { + export enum EntityStatus { + Active = "Active", + Creating = "Creating", + Deleting = "Deleting", + Disabled = "Disabled", + ReceiveDisabled = "ReceiveDisabled", + Renaming = "Renaming", + Restoring = "Restoring", + SendDisabled = "SendDisabled", + Unknown = "Unknown" } - /* - * Options interfaces - */ - - interface CreateOptions { - DefaultMessageTimeToLive: string; - DuplicateDetectionHistoryTimeWindow: string; - EnablePartitioning: boolean; - MaxSizeInMegabytes: number; - RequiresDuplicateDetection: boolean; + export enum EntityAvailabilityStatus { + Available = "Available", + Limited = "Limited", + Renaming = "Renaming", + Restoring = "Restoring", + Unknown = "Unknown" } - interface IQueueOptions extends CreateOptions { - AutoDeleteOnIdle: string; - DeadLetteringOnMessageExpiration: boolean; - LockDuration: string; - RequiresSession: boolean; - } - - interface ICreateTopicOptions extends CreateOptions { - EnableBatchedOperations: boolean; - SizeInBytes: boolean; - SupportOrdering: boolean; - } - - interface ICreateTopicIfNotExistsOptions extends ICreateTopicOptions { - EnableDeadLetteringOnFilterEvaluationExceptions: boolean; - EnableDeadLetteringOnMessageExpiration: boolean; - MaxCorrelationFiltersPerTopic: number; - MaxSqlFiltersPerTopic: number; - MaxSubscriptionsPerTopic: number; - } - - interface ICreateSubscriptionOptions { - DefaultMessageTimeToLive: string; - EnableDeadLetteringOnFilterEvaluationExceptions: boolean; - EnableDeadLetteringOnMessageExpiration: boolean; - LockDuration: string; - RequiresSession: boolean; - } - - interface PaginationOptions { - top: number; - skip: number; - } - - interface ICreateRuleOptions { - trueFilter: string; - falseFilter: string; - sqlExpressionFilter: string; - correlationIdFilter: string; - sqlRuleAction: string; - } - - interface ICreateNotificationHubOptions { - apns: Dictionary; - gcm: Dictionary; - mpns: Dictionary; - wns: Dictionary; - } - - export interface NotificationHubRegistration { - BodyTemplate?: any; - ChannelUri?: string; - DeviceToken?: string; - Expiry?: Date; - gcmRegistrationId?: string; - MpnsHeaders?: any; - RegistrationId: string; - Tags?: string; - WnsHeaders?: any; - } - - export interface Response { - body: Dictionary; - headers: Dictionary; - isSuccessful: boolean; - md5?: string; - statusCode: number; - } - - export interface ErrorResponse extends Response { - body: { - Error: { - Code: string; - Detail: string; - }; + interface Base { + _: { + ContentRootElement: string; + id: string; + title: string; + published: DateString; + updated: DateString; + author?: { + name: string; }; + link: string; + }; + CreatedAt: DateString; } - export namespace Results.Models { - export enum EntityStatus { - Active = 'Active', - Creating = 'Creating', - Deleting = 'Deleting', - Disabled = 'Disabled', - ReceiveDisabled = 'ReceiveDisabled', - Renaming = 'Renaming', - Restoring = 'Restoring', - SendDisabled = 'SendDisabled', - Unknown = 'Unknown' - } - - export enum EntityAvailabilityStatus { - Available = 'Available', - Limited = 'Limited', - Renaming = 'Renaming', - Restoring = 'Restoring', - Unknown = 'Unknown' - } - - interface Base { - _: { - ContentRootElement: string; - id: string; - title: string; - published: DateString; - updated: DateString; - author?: { - name: string; - }; - link: string; - }; - CreatedAt: DateString; - } - - interface ExtendedBase extends Base { - AuthorizationRules: string; - AutoDeleteOnIdle: string; - DefaultMessageTimeToLive: string; - DuplicateDetectionHistoryTimeWindow: Duration; - EnableBatchedOperations: string; - EnableExpress: string; - EnablePartitioning: string; - EntityAvailabilityStatus: string; - IsAnonymousAccessible: string; - MaxSizeInMegabytes: string; - RequiresDuplicateDetection: string; - SizeInBytes: string; - Status: EntityStatus; - UpdatedAt: DateString; - } - - // export interface Generic extends Base { - // [x: string]: string | Dictionary; - // } - - export const ActiveMessageCount = 'd2p1:ActiveMessageCount'; - export const DeadLetterMessageCount = 'd2p1:DeadLetterMessageCount'; - export const ScheduledMessageCount = 'd2p1:ScheduledMessageCount'; - export const TransferMessageCount = 'd2p1:TransferMessageCount'; - export const TransferDeadLetterMessageCount = 'd2p1:TransferDeadLetterMessageCount'; - - export interface Topic extends ExtendedBase { - AccessedAt: DateString; - CountDetails: { [key: string]: string }; - EnableSubscriptionPartitioning: string; - FilteringMessagesBeforePublishing: string; - IsExpress: string; - SubscriptionCount: string; - SupportOrdering: string; - TopicName: string; - } - - export interface Queue extends ExtendedBase { - DeadLetteringOnMessageExpiration: string; - LockDuration: Duration; - MaxDeliveryCount: string; - MessageCount: string; - QueueName: string; - RequiresSession: string; - SupportOrdering: string; - } - - export interface Subscription extends ExtendedBase { - CountDetails: { [key: string]: string }; - DeadLetteringOnFilterEvaluationExceptions: string; - DeadLetteringOnMessageExpiration: string; - LockDuration: string; - MaxDeliveryCount: string; - MessageCount: string; - RequiresSession: string; - SubscriptionName: string; - TopicName: string; - } - - /** - * @see https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-sql-filter - */ - interface SqlFilter { - readonly CompatibilityLevel: string; - Parameters?: Dictionary; - RequiresPreprocessing?: string; - SqlExpression: string; - } - - type CorrelationFilter = Partial<{ - ContentType: string; - CorrelationId: string; - Label: string; - Properties: string; - ReplyTo: string; - ReplyToSessionId: string; - RequiresPreprocessing: string; - SessionId: string; - To: string; - }>; - - export interface Rule extends Base { - Action: string | SqlFilter; - Filter: SqlFilter | CorrelationFilter; - Name: string; - TopicName: string; - SubscriptionName: string; - RuleName: string; - } + interface ExtendedBase extends Base { + AuthorizationRules: string; + AutoDeleteOnIdle: string; + DefaultMessageTimeToLive: string; + DuplicateDetectionHistoryTimeWindow: Duration; + EnableBatchedOperations: string; + EnableExpress: string; + EnablePartitioning: string; + EntityAvailabilityStatus: string; + IsAnonymousAccessible: string; + MaxSizeInMegabytes: string; + RequiresDuplicateDetection: string; + SizeInBytes: string; + Status: EntityStatus; + UpdatedAt: DateString; } - /* - * Callbacks + // export interface Generic extends Base { + // [x: string]: string | Dictionary; + // } + + export const ActiveMessageCount = "d2p1:ActiveMessageCount"; + export const DeadLetterMessageCount = "d2p1:DeadLetterMessageCount"; + export const ScheduledMessageCount = "d2p1:ScheduledMessageCount"; + export const TransferMessageCount = "d2p1:TransferMessageCount"; + export const TransferDeadLetterMessageCount = + "d2p1:TransferDeadLetterMessageCount"; + + export interface Topic extends ExtendedBase { + AccessedAt: DateString; + CountDetails: { [key: string]: string }; + EnableSubscriptionPartitioning: string; + FilteringMessagesBeforePublishing: string; + IsExpress: string; + SubscriptionCount: string; + SupportOrdering: string; + TopicName: string; + } + + export interface Queue extends ExtendedBase { + DeadLetteringOnMessageExpiration: string; + LockDuration: Duration; + MaxDeliveryCount: string; + MessageCount: string; + QueueName: string; + RequiresSession: string; + SupportOrdering: string; + } + + export interface Subscription extends ExtendedBase { + CountDetails: { [key: string]: string }; + DeadLetteringOnFilterEvaluationExceptions: string; + DeadLetteringOnMessageExpiration: string; + LockDuration: string; + MaxDeliveryCount: string; + MessageCount: string; + RequiresSession: string; + SubscriptionName: string; + TopicName: string; + } + + /** + * @see https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-sql-filter */ - export type ResponseCallback = (error: Error | null, response: Response) => void; + interface SqlFilter { + readonly CompatibilityLevel: string; + Parameters?: Dictionary; + RequiresPreprocessing?: string; + SqlExpression: string; + } - export type ResultAndResponseCallback = (error: Error | null, - result: boolean | Results.Models.Base | Results.Models.Base[], - response: Response) => void; + type CorrelationFilter = Partial<{ + ContentType: string; + CorrelationId: string; + Label: string; + Properties: string; + ReplyTo: string; + ReplyToSessionId: string; + RequiresPreprocessing: string; + SessionId: string; + To: string; + }>; - export type TypedResultAndResponseCallback = (error: Error | null, - result: T, - response: Response) => void; + export interface Rule extends Base { + Action: string | SqlFilter; + Filter: SqlFilter | CorrelationFilter; + Name: string; + TopicName: string; + SubscriptionName: string; + RuleName: string; + } + } - /* - * Options interfaces with all properties as optional - */ - export type BrokerProperties = Partial; - export type BrokerPropertiesResponse = IBrokerPropertiesResponse & Partial; - export type CreateQueueOptions = Partial; - export type CreateTopicOptions = Partial; - export type CreateTopicIfNotExistsOptions = Partial; - export type CreateSubscriptionOptions = Partial; - export type ListSubscriptionsOptions = Partial; - export type ListRulesOptions = Partial; - export type ListTopicsOptions = Partial; - export type ListQueuesOptions = Partial; - export type CreateRuleOptions = Partial; - export type CreateNotificationHubOptions = Partial; - export type ListNotificationHubsOptions = Partial; + /* + * Callbacks + */ + export type ResponseCallback = ( + error: Error | null, + response: Response + ) => void; - export type MessageOrName = Message | string; + export type ResultAndResponseCallback = ( + error: Error | null, + result: boolean | Results.Models.Base | Results.Models.Base[], + response: Response + ) => void; + + export type TypedResultAndResponseCallback = ( + error: Error | null, + result: T, + response: Response + ) => void; + + /* + * Options interfaces with all properties as optional + */ + export type BrokerProperties = Partial; + export type BrokerPropertiesResponse = IBrokerPropertiesResponse & + Partial; + export type CreateQueueOptions = Partial; + export type CreateTopicOptions = Partial; + export type CreateTopicIfNotExistsOptions = Partial< + ICreateTopicIfNotExistsOptions + >; + export type CreateSubscriptionOptions = Partial; + export type ListSubscriptionsOptions = Partial; + export type ListRulesOptions = Partial; + export type ListTopicsOptions = Partial; + export type ListQueuesOptions = Partial; + export type CreateRuleOptions = Partial; + export type CreateNotificationHubOptions = Partial< + ICreateNotificationHubOptions + >; + export type ListNotificationHubsOptions = Partial; + + export type MessageOrName = Message | string; }