From 0e36cea9433e892a41e2b757effb7cb1c21b6ab7 Mon Sep 17 00:00:00 2001 From: Dave Gramlich Date: Fri, 1 Mar 2019 14:58:05 -0500 Subject: [PATCH 1/2] fix(docs): ensure docs are not removed by typescript --- src/iam.ts | 71 +++++++++++----------- src/index.ts | 58 +++++++----------- src/snapshot.ts | 17 +++--- src/subscription.ts | 141 +++++++++++++++++++++++--------------------- src/topic.ts | 82 +++++++++++++++----------- 5 files changed, 187 insertions(+), 182 deletions(-) diff --git a/src/iam.ts b/src/iam.ts index 335e58bdd..561994a08 100644 --- a/src/iam.ts +++ b/src/iam.ts @@ -23,46 +23,22 @@ import * as arrify from 'arrify'; import {CallOptions} from 'google-gax'; import {PubSub} from '.'; -/** - * @callback GetPolicyCallback - * @param {?Error} err Request error, if any. - * @param {object} acl The policy. - */ + export interface GetPolicyCallback { (err?: Error|null, acl?: Policy|null): void; } -/** - * @callback SetPolicyCallback - * @param {?Error} err Request error, if any. - * @param {object} acl The policy. - */ export interface SetPolicyCallback { (err?: Error|null, acl?: Policy|null): void; } -/** - * @typedef {array} SetPolicyResponse - * @property {object} 0 The policy. - */ export type SetPolicyResponse = [Policy]; - -/** - * @typedef {array} GetPolicyResponse - * @property {object} 0 The policy. - */ export type GetPolicyResponse = [Policy]; -/** - * @typedef {string[]} PermissionsResponse - * A subset of TestPermissionsRequest.permissions that the caller is allowed. - * @see https://cloud.google.com/pubsub/docs/reference/rpc/google.iam.v1#google.iam.v1.TestIamPermissionsRequest - */ export interface PermissionsResponse { permissions: string|string[]; } - /** * Shows which IAM permissions is allowed. * The key to this object are the IAM permissions (string) and the values are @@ -72,19 +48,8 @@ export type IamPermissionsMap = { [key: string]: boolean }; -/** - * @typedef {array} TestIamPermissionsResponse - * @property {object[]} 0 A subset of permissions that the caller is allowed. - * @property {PermissionsResponse} 1 The full API response. - */ export type TestIamPermissionsResponse = [PermissionsResponse]; -/** - * @callback TestIamPermissionsCallback - * @param {?Error} err Request error, if any. - * @param {TestIamPermissionsAPIResponse} permissions A subset of permissions that the caller is allowed. - * @param {PermissionsResponse} apiResponse The full API response. - */ export interface TestIamPermissionsCallback { (err?: Error|null, permissions?: IamPermissionsMap|null, apiResponse?: PermissionsResponse): void; @@ -179,6 +144,15 @@ export class IAM { getPolicy(gaxOpts?: CallOptions): Promise; getPolicy(callback: GetPolicyCallback): void; getPolicy(gaxOpts: CallOptions, callback: GetPolicyCallback): void; + /** + * @typedef {array} GetPolicyResponse + * @property {object} 0 The policy. + */ + /** + * @callback GetPolicyCallback + * @param {?Error} err Request error, if any. + * @param {object} acl The policy. + */ /** * Get the IAM policy * @@ -235,6 +209,15 @@ export class IAM { setPolicy(policy: Policy, gaxOpts: CallOptions, callback: SetPolicyCallback): void; setPolicy(policy: Policy, callback: SetPolicyCallback): void; + /** + * @typedef {array} SetPolicyResponse + * @property {object} 0 The policy. + */ + /** + * @callback SetPolicyCallback + * @param {?Error} err Request error, if any. + * @param {object} acl The policy. + */ /** * Set the IAM policy * @@ -317,6 +300,22 @@ export class IAM { callback: TestIamPermissionsCallback): void; testPermissions( permissions: string|string[], callback: TestIamPermissionsCallback): void; + /** + * @callback TestIamPermissionsCallback + * @param {?Error} err Request error, if any. + * @param {TestIamPermissionsAPIResponse} permissions A subset of permissions that the caller is allowed. + * @param {PermissionsResponse} apiResponse The full API response. + */ + /** + * @typedef {array} TestIamPermissionsResponse + * @property {object[]} 0 A subset of permissions that the caller is allowed. + * @property {PermissionsResponse} 1 The full API response. + */ + /** + * @typedef {string[]} PermissionsResponse + * A subset of TestPermissionsRequest.permissions that the caller is allowed. + * @see https://cloud.google.com/pubsub/docs/reference/rpc/google.iam.v1#google.iam.v1.TestIamPermissionsRequest + */ /** * Test a set of permissions for a resource. * diff --git a/src/index.ts b/src/index.ts index 20d79d14d..3a60e1173 100644 --- a/src/index.ts +++ b/src/index.ts @@ -109,7 +109,6 @@ export interface Attributes { [key: string]: string; } - export interface SubscriptionCallOptions { flowControl?: FlowControlOptions; maxConnections?: number; @@ -120,24 +119,11 @@ export interface SubscriptionCallOptions { batching?: BatchPublishOptions; } - - -/** - * @callback CreateSnapshotCallback - * @param {?Error} err Request error, if any. - * @param {Snapshot} snapshot - * @param {object} apiResponse The full API response. - */ export interface CreateSnapshotCallback { (err: Error|null, snapshot?: Snapshot|null, apiResponse?: google.pubsub.v1.ISnapshot): void; } -/** - * @typedef {array} CreateSnapshotResponse - * @property {Snapshot}. - * @property {object} 1 The full API response. - */ export type CreateSnapshotResponse = [Snapshot, google.pubsub.v1.ISnapshot]; /** @@ -150,30 +136,13 @@ const PROJECT_ID_PLACEHOLDER = '{{projectId}}'; // tslint:disable-next-line:no-any export type Metadata = any; -/** - * @typedef {array} CreateTopicResponse - * @property {Topic} 0 The new {@link Topic}. - * @property {object} 1 The full API response. - */ export type CreateTopicResponse = [Topic, google.pubsub.v1.ITopic]; -/** - * @callback CreateTopicCallback - * @param {?Error} err Request error, if any. - * @param {Topic} topic The new {@link Topic}. - * @param {object} apiResponse The full API response. - */ export interface CreateTopicCallback { (err?: Error|null, topic?: Topic|null, apiResponse?: google.pubsub.v1.ITopic): void; } -/** - * @callback CreateSubscriptionCallback - * @param {?Error} err Request error, if any. - * @param {Subscription} Subscription - * @param {object} apiResponse The full API response. - */ export interface CreateSubscriptionCallback { (err?: Error|null, subscription?: Subscription|null, apiResponse?: google.pubsub.v1.ISubscription): void; @@ -197,11 +166,6 @@ export interface RequestCallback { (err?: Error|null, res?: TResponse|null): void; } -/** - * @typedef {array} CreateSubscriptionResponse - * @property {Subscription} 0 The new {@link Subscription}. - * @property {object} 1 The full API response. - */ export type CreateSubscriptionResponse = [Subscription, google.pubsub.v1.ISubscription]; @@ -345,6 +309,17 @@ export class PubSub { createSubscription( topic: Topic|string, name: string, callback: CreateSubscriptionCallback): void; + /** + * @typedef {array} CreateSubscriptionResponse + * @property {Subscription} 0 The new {@link Subscription}. + * @property {object} 1 The full API response. + */ + /** + * @callback CreateSubscriptionCallback + * @param {?Error} err Request error, if any. + * @param {Subscription} Subscription + * @param {object} apiResponse The full API response. + */ /** * Options for creating a subscription. * @@ -470,6 +445,17 @@ export class PubSub { createTopic( name: string, gaxOpts: CallOptions, callback?: CreateTopicCallback): void; createTopic(name: string, callback: CreateTopicCallback): void; + /** + * @typedef {array} CreateTopicResponse + * @property {Topic} 0 The new {@link Topic}. + * @property {object} 1 The full API response. + */ + /** + * @callback CreateTopicCallback + * @param {?Error} err Request error, if any. + * @param {Topic} topic The new {@link Topic}. + * @param {object} apiResponse The full API response. + */ /** * Create a topic with the given name. * diff --git a/src/snapshot.ts b/src/snapshot.ts index b5940397c..275ee2dca 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -101,6 +101,8 @@ export class Snapshot { this.name = Snapshot.formatName_(parent.projectId, name); } + delete(): Promise; + delete(callback: RequestCallback): void; /** * Delete the snapshot. * @@ -120,8 +122,6 @@ export class Snapshot { * const apiResponse = data[0]; * }); */ - delete(): Promise; - delete(callback: RequestCallback): void; delete(callback?: RequestCallback): void|Promise { const reqOpts = { @@ -136,6 +136,7 @@ export class Snapshot { }, callback); } + /*@ * Format the name of a snapshot. A snapshot's full name is in the format of * projects/{projectId}/snapshots/{snapshotName} @@ -146,6 +147,9 @@ export class Snapshot { return 'projects/' + projectId + '/snapshots/' + name.split('/').pop(); } + create(gaxOpts?: CallOptions): Promise; + create(callback: CreateSnapshotCallback): void; + create(gaxOpts: CallOptions, callback: CreateSnapshotCallback): void; /** * Create a snapshot with the given name. * @@ -181,9 +185,6 @@ export class Snapshot { * const apiResponse = data[1]; * }); */ - create(gaxOpts?: CallOptions): Promise; - create(callback: CreateSnapshotCallback): void; - create(gaxOpts: CallOptions, callback: CreateSnapshotCallback): void; create( gaxOpts?: CallOptions|CreateSnapshotCallback, callback?: CreateSnapshotCallback): void|Promise { @@ -195,6 +196,9 @@ export class Snapshot { .createSnapshot(this.name, gaxOpts! as CallOptions, callback!); } + seek(gaxOpts?: CallOptions): Promise; + seek(callback: SeekCallback): void; + seek(gaxOpts: CallOptions, callback: SeekCallback): void; /** * Seeks an existing subscription to the snapshot. * @@ -220,9 +224,6 @@ export class Snapshot { * const apiResponse = data[0]; * }); */ - seek(gaxOpts?: CallOptions): Promise; - seek(callback: SeekCallback): void; - seek(gaxOpts: CallOptions, callback: SeekCallback): void; seek(gaxOpts?: CallOptions|SeekCallback, callback?: SeekCallback): void|Promise { if (!(this.parent instanceof Subscription)) { diff --git a/src/subscription.ts b/src/subscription.ts index 5cbcc397e..8fb1e2e8a 100644 --- a/src/subscription.ts +++ b/src/subscription.ts @@ -29,27 +29,6 @@ import {Snapshot} from './snapshot'; import {Subscriber, SubscriberOptions} from './subscriber'; import {noop} from './util'; - -/** - * @typedef {object} ExpirationPolicy - * A policy that specifies the conditions for this subscription's expiration. A - * subscription is considered active as long as any connected subscriber is - * successfully consuming messages from the subscription or is issuing - * operations on the subscription. If expirationPolicy is not set, a default - * policy with ttl of 31 days will be used. The minimum allowed value for - * expirationPolicy.ttl is 1 day. BETA: This feature is part of a beta release. - * This API might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * @property {string} ttl Specifies the "time-to-live" duration for an associated - * resource. The resource expires if it is not active for a period of ttl. The - * eeedefinition of "activity" depends on the type of the associated resource. - * The minimum and maximum allowed values for ttl depend on the type of the - * associated resource, as well. If ttl is not set, the associated resource - * never expires. A duration in seconds with up to nine fractional digits, - * terminated by 's'. Example: "3.5s". - */ - /** * @see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Duration */ @@ -83,6 +62,25 @@ export interface SubscriptionMetadata extends TSubscriptionMetadata { messageRetentionDuration?: Duration; } +/** + * @typedef {object} ExpirationPolicy + * A policy that specifies the conditions for this subscription's expiration. A + * subscription is considered active as long as any connected subscriber is + * successfully consuming messages from the subscription or is issuing + * operations on the subscription. If expirationPolicy is not set, a default + * policy with ttl of 31 days will be used. The minimum allowed value for + * expirationPolicy.ttl is 1 day. BETA: This feature is part of a beta release. + * This API might be changed in backward-incompatible ways and is not + * recommended for production use. It is not subject to any SLA or deprecation + * policy. + * @property {string} ttl Specifies the "time-to-live" duration for an associated + * resource. The resource expires if it is not active for a period of ttl. The + * eeedefinition of "activity" depends on the type of the associated resource. + * The minimum and maximum allowed values for ttl depend on the type of the + * associated resource, as well. If ttl is not set, the associated resource + * never expires. A duration in seconds with up to nine fractional digits, + * terminated by 's'. Example: "3.5s". + */ /** * A Subscription object will give you access to your Cloud Pub/Sub * subscription. @@ -256,6 +254,7 @@ export class Subscription extends EventEmitter { this._listen(); } + /** * Indicates if the Subscription is open and receiving messages. * @@ -264,12 +263,16 @@ export class Subscription extends EventEmitter { get isOpen(): boolean { return !!(this._subscriber && this._subscriber.isOpen); } + /** * @type {string} */ get projectId(): string { return this.pubsub && this.pubsub.projectId || '{{projectId}}'; } + + close(): Promise; + close(callback: RequestCallback): void; /** * Closes the Subscription, once this is called you will no longer receive * message events unless you call {Subscription#open} or add new message @@ -289,12 +292,16 @@ export class Subscription extends EventEmitter { * // If the callback is omitted a Promise will be returned. * subscription.close().then(() => {}); */ - - close(): Promise; - close(callback: RequestCallback): void; close(callback?: RequestCallback): void|Promise { this._subscriber.close().then(() => callback!(), callback); } + + createSnapshot(name: string, callback: CreateSnapshotCallback): void; + createSnapshot(name: string, gaxOpts?: CallOptions): + Promise; + createSnapshot( + name: string, gaxOpts: CallOptions, + callback: CreateSnapshotCallback): void; /** * @typedef {array} CreateSnapshotResponse * @property {Snapshot} 0 The new {@link Snapshot}. @@ -338,12 +345,6 @@ export class Subscription extends EventEmitter { * const apiResponse = data[1]; * }); */ - createSnapshot(name: string, callback: CreateSnapshotCallback): void; - createSnapshot(name: string, gaxOpts?: CallOptions): - Promise; - createSnapshot( - name: string, gaxOpts: CallOptions, - callback: CreateSnapshotCallback): void; createSnapshot( name: string, gaxOptsOrCallback?: CallOptions|CreateSnapshotCallback, callback?: CreateSnapshotCallback): void|Promise { @@ -376,6 +377,12 @@ export class Subscription extends EventEmitter { callback!(null, snapshot, resp!); }); } + + delete(callback: RequestCallback): void; + delete(gaxOpts?: CallOptions): Promise; + delete( + gaxOpts: CallOptions, + callback: RequestCallback): void; /** * Delete the subscription. Pull requests from the current subscription will * be errored once unsubscription is complete. @@ -405,13 +412,6 @@ export class Subscription extends EventEmitter { * const apiResponse = data[0]; * }); */ - - - delete(callback: RequestCallback): void; - delete(gaxOpts?: CallOptions): Promise; - delete( - gaxOpts: CallOptions, - callback: RequestCallback): void; delete( gaxOptsOrCallback?: CallOptions|RequestCallback, callback?: RequestCallback): @@ -440,6 +440,9 @@ export class Subscription extends EventEmitter { }, callback); } + + exists(): Promise; + exists(callback: ExistsCallback): void; /** * @typedef {array} SubscriptionExistsResponse * @property {boolean} 0 Whether the subscription exists @@ -471,8 +474,6 @@ export class Subscription extends EventEmitter { * const exists = data[0]; * }); */ - exists(): Promise; - exists(callback: ExistsCallback): void; exists(callback?: ExistsCallback): void|Promise { this.getMetadata(err => { if (!err) { @@ -487,6 +488,10 @@ export class Subscription extends EventEmitter { callback!(err); }); } + + get(callback: CreateSubscriptionCallback): void; + get(gaxOpts?: GetCallOptions): Promise; + get(gaxOpts: GetCallOptions, callback: CreateSubscriptionCallback): void; /** * @typedef {array} GetSubscriptionResponse * @property {Subscription} 0 The {@link Subscription}. @@ -527,9 +532,6 @@ export class Subscription extends EventEmitter { * const apiResponse = data[1]; * }); */ - get(callback: CreateSubscriptionCallback): void; - get(gaxOpts?: GetCallOptions): Promise; - get(gaxOpts: GetCallOptions, callback: CreateSubscriptionCallback): void; get(gaxOptsOrCallback?: GetCallOptions|CreateSubscriptionCallback, callback?: CreateSubscriptionCallback): void|Promise { @@ -553,6 +555,11 @@ export class Subscription extends EventEmitter { this.create(gaxOpts, callback); }); } + + getMetadata(gaxOpts?: CallOptions): Promise; + getMetadata(callback: GetSubscriptionMetadataCallback): void; + getMetadata(gaxOpts: CallOptions, callback: GetSubscriptionMetadataCallback): + void; /** * @typedef {array} GetSubscriptionMetadataResponse * @property {object} 0 The full API response. @@ -590,10 +597,6 @@ export class Subscription extends EventEmitter { * const apiResponse = data[0]; * }); */ - getMetadata(gaxOpts?: CallOptions): Promise; - getMetadata(callback: GetSubscriptionMetadataCallback): void; - getMetadata(gaxOpts: CallOptions, callback: GetSubscriptionMetadataCallback): - void; getMetadata( gaxOptsOrCallback?: CallOptions|GetSubscriptionMetadataCallback, callback?: GetSubscriptionMetadataCallback): @@ -619,6 +622,15 @@ export class Subscription extends EventEmitter { callback!(err!, apiResponse); }); } + + modifyPushConfig(config: google.pubsub.v1.IPushConfig, gaxOpts?: CallOptions): + Promise; + modifyPushConfig( + config: google.pubsub.v1.IPushConfig, + callback: RequestCallback): void; + modifyPushConfig( + config: google.pubsub.v1.IPushConfig, gaxOpts: CallOptions, + callback: RequestCallback): void; /** * @typedef {array} ModifyPushConfigResponse * @property {object} 0 The full API response. @@ -667,14 +679,6 @@ export class Subscription extends EventEmitter { * const apiResponse = data[0]; * }); */ - modifyPushConfig(config: google.pubsub.v1.IPushConfig, gaxOpts?: CallOptions): - Promise; - modifyPushConfig( - config: google.pubsub.v1.IPushConfig, - callback: RequestCallback): void; - modifyPushConfig( - config: google.pubsub.v1.IPushConfig, gaxOpts: CallOptions, - callback: RequestCallback): void; modifyPushConfig( config: google.pubsub.v1.IPushConfig, gaxOptsOrCallback?: CallOptions|RequestCallback, @@ -697,6 +701,7 @@ export class Subscription extends EventEmitter { }, callback!); } + /** * Opens the Subscription to receive messages. In general this method * shouldn't need to be called, unless you wish to receive messages after @@ -723,6 +728,12 @@ export class Subscription extends EventEmitter { this._subscriber.open(); } } + + seek(snapshot: string|Date, gaxOpts?: CallOptions): + Promise; + seek(snapshot: string|Date, callback: SeekCallback): void; + seek(snapshot: string|Date, gaxOpts: CallOptions, callback: SeekCallback): + void; /** * @typedef {array} SeekResponse * @property {object} 0 The full API response. @@ -760,11 +771,6 @@ export class Subscription extends EventEmitter { * * subscription.seek(date, callback); */ - seek(snapshot: string|Date, gaxOpts?: CallOptions): - Promise; - seek(snapshot: string|Date, callback: SeekCallback): void; - seek(snapshot: string|Date, gaxOpts: CallOptions, callback: SeekCallback): - void; seek( snapshot: string|Date, gaxOptsOrCallback?: CallOptions|SeekCallback, callback?: SeekCallback): void|Promise { @@ -801,6 +807,15 @@ export class Subscription extends EventEmitter { }, callback!); } + + setMetadata(metadata: Metadata, gaxOpts?: CallOptions): + Promise; + setMetadata( + metadata: Metadata, + callback: RequestCallback): void; + setMetadata( + metadata: Metadata, gaxOpts: CallOptions, + callback: RequestCallback): void; /** * @typedef {array} SetSubscriptionMetadataResponse * @property {object} 0 The full API response. @@ -837,14 +852,6 @@ export class Subscription extends EventEmitter { * const apiResponse = data[0]; * }); */ - setMetadata(metadata: Metadata, gaxOpts?: CallOptions): - Promise; - setMetadata( - metadata: Metadata, - callback: RequestCallback): void; - setMetadata( - metadata: Metadata, gaxOpts: CallOptions, - callback: RequestCallback): void; setMetadata( metadata: Metadata, gaxOptsOrCallback?: CallOptions| diff --git a/src/topic.ts b/src/topic.ts index a0eedd6e3..5ace35589 100644 --- a/src/topic.ts +++ b/src/topic.ts @@ -121,6 +121,10 @@ export class Topic { */ this.iam = new IAM(pubsub, this.name); } + + create(gaxOpts?: CallOptions): Promise; + create(callback: CreateTopicCallback): void; + create(gaxOpts: CallOptions, callback: CreateTopicCallback): void; /** * Create a topic. * @@ -149,9 +153,6 @@ export class Topic { * const apiResponse = data[1]; * }); */ - create(gaxOpts?: CallOptions): Promise; - create(callback: CreateTopicCallback): void; - create(gaxOpts: CallOptions, callback: CreateTopicCallback): void; create( gaxOptsOrCallback?: CallOptions|CreateTopicCallback, callback?: CreateTopicCallback): Promise|void { @@ -162,6 +163,13 @@ export class Topic { this.pubsub.createTopic(this.name, gaxOpts, callback); } + + createSubscription(name: string, callback: CreateSubscriptionCallback): void; + createSubscription(name: string, options?: CreateSubscriptionOptions): + Promise; + createSubscription( + name: string, options: CreateSubscriptionOptions, + callback: CreateSubscriptionCallback): void; /** * Create a subscription to this topic. * @@ -199,12 +207,6 @@ export class Topic { * const apiResponse = data[1]; * }); */ - createSubscription(name: string, callback: CreateSubscriptionCallback): void; - createSubscription(name: string, options?: CreateSubscriptionOptions): - Promise; - createSubscription( - name: string, options: CreateSubscriptionOptions, - callback: CreateSubscriptionCallback): void; createSubscription( name: string, optionsOrCallback?: CreateSubscriptionOptions|CreateSubscriptionCallback, @@ -218,6 +220,12 @@ export class Topic { this.pubsub.createSubscription( this, name, options as CreateSubscriptionOptions, callback!); } + + delete(callback: RequestCallback): void; + delete(gaxOpts?: CallOptions): Promise; + delete( + gaxOpts: CallOptions, + callback: RequestCallback): void; /** * Delete the topic. This will not delete subscriptions to this topic. * @@ -245,11 +253,6 @@ export class Topic { * const apiResponse = data[0]; * }); */ - delete(callback: RequestCallback): void; - delete(gaxOpts?: CallOptions): Promise; - delete( - gaxOpts: CallOptions, - callback: RequestCallback): void; delete( gaxOptsOrCallback?: CallOptions|RequestCallback, callback?: RequestCallback): @@ -272,6 +275,7 @@ export class Topic { }, callback); } + /** * @typedef {array} TopicExistsResponse * @property {boolean} 0 Whether the topic exists @@ -321,6 +325,10 @@ export class Topic { callback(err); }); } + + get(callback: CreateTopicCallback): void; + get(gaxOpts?: GetCallOptions): Promise; + get(gaxOpts: GetCallOptions, callback: CreateTopicCallback): void; /** * @typedef {array} GetTopicResponse * @property {Topic} 0 The {@link Topic}. @@ -360,9 +368,6 @@ export class Topic { * const apiResponse = data[1]; * }); */ - get(callback: CreateTopicCallback): void; - get(gaxOpts?: GetCallOptions): Promise; - get(gaxOpts: GetCallOptions, callback: CreateTopicCallback): void; get(gaxOptsOrCallback?: GetCallOptions|CreateTopicCallback, callback?: CreateTopicCallback): void|Promise { const gaxOpts = @@ -389,6 +394,10 @@ export class Topic { this.create(gaxOpts, callback!); }); } + + getMetadata(callback: GetTopicMetadataCallback): void; + getMetadata(gaxOpts: CallOptions, callback: GetTopicMetadataCallback): void; + getMetadata(gaxOpts?: CallOptions): Promise; /** * @typedef {array} GetTopicMetadataResponse * @property {object} 0 The full API response. @@ -423,9 +432,6 @@ export class Topic { * const apiResponse = data[0]; * }); */ - getMetadata(callback: GetTopicMetadataCallback): void; - getMetadata(gaxOpts: CallOptions, callback: GetTopicMetadataCallback): void; - getMetadata(gaxOpts?: CallOptions): Promise; getMetadata( gaxOptsOrCallback?: CallOptions|GetTopicMetadataCallback, callback?: GetTopicMetadataCallback): @@ -451,6 +457,14 @@ export class Topic { callback!(err, apiResponse); }); } + + getSubscriptions(callback: RequestCallback): void; + getSubscriptions( + options: SubscriptionCallOptions, + callback: RequestCallback): void; + getSubscriptions( + options?: SubscriptionCallOptions, + ): Promise; /** * Get a list of the subscriptions registered to this topic. You may * optionally provide a query object as the first argument to customize the @@ -487,13 +501,6 @@ export class Topic { * const subscriptions = data[0]; * }); */ - getSubscriptions(callback: RequestCallback): void; - getSubscriptions( - options: SubscriptionCallOptions, - callback: RequestCallback): void; - getSubscriptions( - options?: SubscriptionCallOptions, - ): Promise; getSubscriptions( optionsOrCallback?: SubscriptionCallOptions| RequestCallback, @@ -536,6 +543,11 @@ export class Topic { callback!(...args); }); } + + publish(data: Buffer, attributes?: Attributes): Promise; + publish(data: Buffer, callback: PublishCallback): void; + publish(data: Buffer, attributes: Attributes, callback: PublishCallback): + void; /** * Publish the provided message. * @@ -578,10 +590,6 @@ export class Topic { * //- * topic.publish(data).then((messageId) => {}); */ - publish(data: Buffer, attributes?: Attributes): Promise; - publish(data: Buffer, callback: PublishCallback): void; - publish(data: Buffer, attributes: Attributes, callback: PublishCallback): - void; publish( data: Buffer, attributesOrCallback?: Attributes|PublishCallback, callback?: PublishCallback): Promise|void { @@ -592,6 +600,11 @@ export class Topic { callback; return this.publisher.publish(data, attributes, callback!); } + + publishJSON(json: object, attributes?: Attributes): Promise; + publishJSON(json: object, callback: PublishCallback): void; + publishJSON(json: object, attributes: Attributes, callback: PublishCallback): + void; /** * Publish the provided JSON. It should be noted that all messages published * are done so in the form of a Buffer. This is simply a convenience method @@ -640,10 +653,6 @@ export class Topic { * //- * topic.publishJSON(data).then((messageId) => {}); */ - publishJSON(json: object, attributes?: Attributes): Promise; - publishJSON(json: object, callback: PublishCallback): void; - publishJSON(json: object, attributes: Attributes, callback: PublishCallback): - void; publishJSON( json: object, attributesOrCallback?: Attributes|PublishCallback, callback?: PublishCallback): Promise|void { @@ -659,6 +668,7 @@ export class Topic { const data = Buffer.from(JSON.stringify(json)); return this.publish(data, attributes, callback!); } + /** * Set the publisher options. * @@ -679,6 +689,7 @@ export class Topic { setPublishOptions(options: PublishOptions): void { this.publisher.setOptions(options); } + /** * Create a Subscription object. This command by itself will not run any API * requests. You will receive a {module:pubsub/subscription} object, @@ -723,6 +734,7 @@ export class Topic { options.topic = this; return this.pubsub.subscription(name, options); } + /** * Format the name of a topic. A Topic's full name is in the format of * 'projects/{projectId}/topics/{topicName}'. From 16488153c775652f367838da99d260c56ef3b056 Mon Sep 17 00:00:00 2001 From: Dave Gramlich Date: Fri, 1 Mar 2019 14:59:34 -0500 Subject: [PATCH 2/2] how did you get there --- src/iam.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/iam.ts b/src/iam.ts index 561994a08..94d887496 100644 --- a/src/iam.ts +++ b/src/iam.ts @@ -23,7 +23,6 @@ import * as arrify from 'arrify'; import {CallOptions} from 'google-gax'; import {PubSub} from '.'; - export interface GetPolicyCallback { (err?: Error|null, acl?: Policy|null): void; }