From e6134af36ab25bafb6dc3d12db4f27b70d8299a0 Mon Sep 17 00:00:00 2001 From: Andrew Barba Date: Thu, 3 May 2018 15:41:19 -0400 Subject: [PATCH] Updated typescript definitions --- CHANGELOG.md | 4 +++ index.d.ts | 71 ++++++++++++++++++++++++++++++++++++++ lib/apns.d.ts | 95 --------------------------------------------------- package.json | 2 +- 4 files changed, 76 insertions(+), 96 deletions(-) create mode 100644 index.d.ts delete mode 100644 lib/apns.d.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a264c22..56efe492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ Change Log --- +## [4.0.1](https://github.com/AndrewBarba/apns2/releases/tag/4.0.1) + +1. Updated Typescript definitions for v4.0 + ## [4.0.0](https://github.com/AndrewBarba/apns2/releases/tag/4.0.0) 1. Remove support for Node versions less than v8.10 diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 00000000..8ec07547 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,71 @@ +import { EventEmitter } from "events" + +export class APNS extends EventEmitter { + constructor(options: APNSOptions) + send(notification: Notification): Promise + send(notifications: Notification[]): Promise +} + +export class Notification { + constructor(deviceToken: string, options?: NotificationOptions) + static readonly priority: NotificationPriority + readonly deviceToken: string + readonly priority: number + readonly expiration: number + readonly topic: string + readonly collapseId: string +} + +export class BasicNotification extends Notification { + constructor(deviceToken: string, message: string, options?: NotificationOptions) +} + +export class SilentNotification extends Notification { + constructor(deviceToken: string, options?: NotificationOptions) +} + +export const Errors: { + badCertificate: string + badCertificateEnvironment: string + badCollapseId: string + badDeviceToken: string + badExpirationDate: string + badMessageId: string + badPath: string + badPriority: string + badTopic: string + deviceTokenNotForTopic: string + duplicateHeaders: string + error: string + expiredProviderToken: string + forbidden: string + idleTimeout: string + internalServerError: string + invalidProviderToken: string + invalidSigningKey: string + methodNotAllowed: string + missingDeviceToken: string + missingTopic: string + payloadEmpty: string + payloadTooLarge: string + serviceUnavailable: string + shutdown: string + tooManyRequests: string + topicDisallowed: string + unknownError: string + unregistered: string +} + +declare interface APNSOptions { + team: string + keyId: string + signingKey: string + defaultTopic?: string + host?: string + port?: number +} + +declare interface NotificationPriority { + immediate: number + throttled: number +} diff --git a/lib/apns.d.ts b/lib/apns.d.ts deleted file mode 100644 index 34d7b5b7..00000000 --- a/lib/apns.d.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { EventEmitter } from "events" - -declare class APNS extends EventEmitter { - constructor(options: APNS.Options) - send(notification: APNS.Notification): Promise - send(notifications: APNS.Notification[]): Promise -} - -declare namespace APNS { - export interface Options { - team: string - keyId: string - signingKey: string - defaultTopic?: string - host?: string - port?: number - } - - export interface NotificationAlert { - title: string - body: string - } - - export interface NotificationOptions { - alert?: string | NotificationAlert - badge?: number - sound?: string - category?: string - data?: object - contentAvailable?: boolean - priority?: number - aps?: object - } - - export class Notification { - constructor(deviceToken: string, options?: NotificationOptions) - static readonly priority: Notification.Priority - readonly deviceToken: string - readonly priority: number - readonly expiration: number - readonly topic: string - readonly collapseId: string - } - - export namespace Notification { - export interface Priority { - immediate: number - throttled: number - } - } - - export class BasicNotification extends Notification { - constructor(deviceToken: string, message: string, options?: NotificationOptions) - } - - export class SilentNotification extends Notification { - constructor(deviceToken: string, options?: NotificationOptions) - } - - export interface Errors { - badCertificate: string - badCertificateEnvironment: string - badCollapseId: string - badDeviceToken: string - badExpirationDate: string - badMessageId: string - badPath: string - badPriority: string - badTopic: string - deviceTokenNotForTopic: string - duplicateHeaders: string - error: string - expiredProviderToken: string - forbidden: string - idleTimeout: string - internalServerError: string - invalidProviderToken: string - invalidSigningKey: string - methodNotAllowed: string - missingDeviceToken: string - missingTopic: string - payloadEmpty: string - payloadTooLarge: string - serviceUnavailable: string - shutdown: string - tooManyRequests: string - topicDisallowed: string - unknownError: string - unregistered: string - } - - export const errors: Errors -} - -export = APNS diff --git a/package.json b/package.json index 196f05f9..7aee6fe9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "apns2", - "version": "4.0.0", + "version": "4.0.1", "description": "Node client for connecting to Apple's Push Notification Service using the new HTTP/2 protocol with JSON web tokens.", "author": "Andrew Barba ", "main": "lib/apns.js",