@walkeros/server-source-gcp 4.7.0-next-1790245733116 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Source, WalkerOS, Credential, ServiceAccount, SetupFn as SetupFn$1 } from '@walkeros/core';
2
2
  import { z } from '@walkeros/core/dev';
3
- import { PubSub, Subscription } from '@google-cloud/pubsub';
3
+ import { SubscriptionOptions, Message, ClientConfig, TopicMetadata, CreateSubscriptionOptions, protos, PubSub, Subscription } from '@google-cloud/pubsub';
4
4
 
5
5
  /**
6
6
  * CORS options schema
@@ -147,8 +147,41 @@ declare module '@walkeros/core' {
147
147
  };
148
148
  }
149
149
  }
150
+ /** The part of a Pub/Sub subscription the pull source drives. */
151
+ interface PullSubscription {
152
+ on(event: 'message', listener: (message: Message) => void): unknown;
153
+ on(event: 'error', listener: (error: Error) => void): unknown;
154
+ close(): Promise<void>;
155
+ }
156
+ /**
157
+ * The part of a Pub/Sub client the pull source calls at runtime. `PubSub` from
158
+ * `@google-cloud/pubsub` satisfies it, and so does an injected mock (tests,
159
+ * simulate) without a cast. Setup needs a `PubSubAdminClient`.
160
+ */
161
+ interface PubSubPullClient {
162
+ subscription(name: string, options?: SubscriptionOptions): PullSubscription;
163
+ close(): Promise<void>;
164
+ }
165
+ /**
166
+ * The part of a Pub/Sub client `walkeros setup` calls (topic and subscription
167
+ * provisioning, drift check). `PubSub` from `@google-cloud/pubsub` satisfies
168
+ * it, from any copy of the SDK; a pull-only client does not.
169
+ */
170
+ interface PubSubAdminClient {
171
+ topic(name: string): {
172
+ exists(): Promise<[boolean, ...unknown[]]>;
173
+ };
174
+ createTopic(metadata: TopicMetadata): Promise<unknown>;
175
+ createSubscription(topic: string, name: string, options?: CreateSubscriptionOptions): Promise<unknown>;
176
+ subscription(name: string): {
177
+ getMetadata(): Promise<[
178
+ protos.google.pubsub.v1.ISubscription,
179
+ ...unknown[]
180
+ ]>;
181
+ };
182
+ }
150
183
  interface Settings$1 {
151
- client: PubSub;
184
+ client: PubSubPullClient;
152
185
  projectId: string;
153
186
  subscription: string;
154
187
  topic?: string;
@@ -163,13 +196,13 @@ interface Settings$1 {
163
196
  ackDeadline?: number;
164
197
  shutdownTimeoutMs?: number;
165
198
  onPushError?: 'nack' | 'ack';
166
- subscriptionHandle?: Subscription;
199
+ subscriptionHandle?: PullSubscription;
167
200
  }
168
201
  interface InitSettings$1 {
169
202
  projectId: string;
170
203
  subscription: string;
171
204
  topic?: string;
172
- client?: PubSub;
205
+ client?: PubSubPullClient;
173
206
  /** @deprecated Use `config.credentials` instead. Kept for back-compat. */
174
207
  credentials?: string | ServiceAccountCredentials;
175
208
  apiEndpoint?: string;
@@ -205,7 +238,7 @@ interface SyntheticPushResult {
205
238
  }
206
239
  type Push$1 = (content?: SyntheticMessage) => Promise<SyntheticPushResult | void>;
207
240
  interface Env$1 extends Source.Env {
208
- PubSub?: typeof PubSub;
241
+ PubSub?: new (options?: ClientConfig) => PubSubPullClient;
209
242
  }
210
243
  /**
211
244
  * Provisioning options for `walkeros setup source.<id>`.
@@ -257,6 +290,9 @@ type SetupFn = SetupFn$1<Config$1, Env$1>;
257
290
 
258
291
  type types$1_Decoder = Decoder;
259
292
  declare const types$1_PubSub: typeof PubSub;
293
+ type types$1_PubSubAdminClient = PubSubAdminClient;
294
+ type types$1_PubSubPullClient = PubSubPullClient;
295
+ type types$1_PullSubscription = PullSubscription;
260
296
  type types$1_ServiceAccountCredentials = ServiceAccountCredentials;
261
297
  type types$1_Setup = Setup;
262
298
  type types$1_SetupFn = SetupFn;
@@ -264,7 +300,7 @@ declare const types$1_Subscription: typeof Subscription;
264
300
  type types$1_SyntheticMessage = SyntheticMessage;
265
301
  type types$1_SyntheticPushResult = SyntheticPushResult;
266
302
  declare namespace types$1 {
267
- export { type Config$1 as Config, type types$1_Decoder as Decoder, type Env$1 as Env, type InitSettings$1 as InitSettings, type Mapping$1 as Mapping, type PartialConfig$1 as PartialConfig, types$1_PubSub as PubSub, type Push$1 as Push, type types$1_ServiceAccountCredentials as ServiceAccountCredentials, type Settings$1 as Settings, type types$1_Setup as Setup, type types$1_SetupFn as SetupFn, types$1_Subscription as Subscription, type types$1_SyntheticMessage as SyntheticMessage, type types$1_SyntheticPushResult as SyntheticPushResult, type Types$1 as Types };
303
+ export { type Config$1 as Config, type types$1_Decoder as Decoder, type Env$1 as Env, type InitSettings$1 as InitSettings, type Mapping$1 as Mapping, type PartialConfig$1 as PartialConfig, types$1_PubSub as PubSub, type types$1_PubSubAdminClient as PubSubAdminClient, type types$1_PubSubPullClient as PubSubPullClient, type types$1_PullSubscription as PullSubscription, type Push$1 as Push, type types$1_ServiceAccountCredentials as ServiceAccountCredentials, type Settings$1 as Settings, type types$1_Setup as Setup, type types$1_SetupFn as SetupFn, types$1_Subscription as Subscription, type types$1_SyntheticMessage as SyntheticMessage, type types$1_SyntheticPushResult as SyntheticPushResult, type Types$1 as Types };
268
304
  }
269
305
 
270
306
  /**
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Source, WalkerOS, Credential, ServiceAccount, SetupFn as SetupFn$1 } from '@walkeros/core';
2
2
  import { z } from '@walkeros/core/dev';
3
- import { PubSub, Subscription } from '@google-cloud/pubsub';
3
+ import { SubscriptionOptions, Message, ClientConfig, TopicMetadata, CreateSubscriptionOptions, protos, PubSub, Subscription } from '@google-cloud/pubsub';
4
4
 
5
5
  /**
6
6
  * CORS options schema
@@ -147,8 +147,41 @@ declare module '@walkeros/core' {
147
147
  };
148
148
  }
149
149
  }
150
+ /** The part of a Pub/Sub subscription the pull source drives. */
151
+ interface PullSubscription {
152
+ on(event: 'message', listener: (message: Message) => void): unknown;
153
+ on(event: 'error', listener: (error: Error) => void): unknown;
154
+ close(): Promise<void>;
155
+ }
156
+ /**
157
+ * The part of a Pub/Sub client the pull source calls at runtime. `PubSub` from
158
+ * `@google-cloud/pubsub` satisfies it, and so does an injected mock (tests,
159
+ * simulate) without a cast. Setup needs a `PubSubAdminClient`.
160
+ */
161
+ interface PubSubPullClient {
162
+ subscription(name: string, options?: SubscriptionOptions): PullSubscription;
163
+ close(): Promise<void>;
164
+ }
165
+ /**
166
+ * The part of a Pub/Sub client `walkeros setup` calls (topic and subscription
167
+ * provisioning, drift check). `PubSub` from `@google-cloud/pubsub` satisfies
168
+ * it, from any copy of the SDK; a pull-only client does not.
169
+ */
170
+ interface PubSubAdminClient {
171
+ topic(name: string): {
172
+ exists(): Promise<[boolean, ...unknown[]]>;
173
+ };
174
+ createTopic(metadata: TopicMetadata): Promise<unknown>;
175
+ createSubscription(topic: string, name: string, options?: CreateSubscriptionOptions): Promise<unknown>;
176
+ subscription(name: string): {
177
+ getMetadata(): Promise<[
178
+ protos.google.pubsub.v1.ISubscription,
179
+ ...unknown[]
180
+ ]>;
181
+ };
182
+ }
150
183
  interface Settings$1 {
151
- client: PubSub;
184
+ client: PubSubPullClient;
152
185
  projectId: string;
153
186
  subscription: string;
154
187
  topic?: string;
@@ -163,13 +196,13 @@ interface Settings$1 {
163
196
  ackDeadline?: number;
164
197
  shutdownTimeoutMs?: number;
165
198
  onPushError?: 'nack' | 'ack';
166
- subscriptionHandle?: Subscription;
199
+ subscriptionHandle?: PullSubscription;
167
200
  }
168
201
  interface InitSettings$1 {
169
202
  projectId: string;
170
203
  subscription: string;
171
204
  topic?: string;
172
- client?: PubSub;
205
+ client?: PubSubPullClient;
173
206
  /** @deprecated Use `config.credentials` instead. Kept for back-compat. */
174
207
  credentials?: string | ServiceAccountCredentials;
175
208
  apiEndpoint?: string;
@@ -205,7 +238,7 @@ interface SyntheticPushResult {
205
238
  }
206
239
  type Push$1 = (content?: SyntheticMessage) => Promise<SyntheticPushResult | void>;
207
240
  interface Env$1 extends Source.Env {
208
- PubSub?: typeof PubSub;
241
+ PubSub?: new (options?: ClientConfig) => PubSubPullClient;
209
242
  }
210
243
  /**
211
244
  * Provisioning options for `walkeros setup source.<id>`.
@@ -257,6 +290,9 @@ type SetupFn = SetupFn$1<Config$1, Env$1>;
257
290
 
258
291
  type types$1_Decoder = Decoder;
259
292
  declare const types$1_PubSub: typeof PubSub;
293
+ type types$1_PubSubAdminClient = PubSubAdminClient;
294
+ type types$1_PubSubPullClient = PubSubPullClient;
295
+ type types$1_PullSubscription = PullSubscription;
260
296
  type types$1_ServiceAccountCredentials = ServiceAccountCredentials;
261
297
  type types$1_Setup = Setup;
262
298
  type types$1_SetupFn = SetupFn;
@@ -264,7 +300,7 @@ declare const types$1_Subscription: typeof Subscription;
264
300
  type types$1_SyntheticMessage = SyntheticMessage;
265
301
  type types$1_SyntheticPushResult = SyntheticPushResult;
266
302
  declare namespace types$1 {
267
- export { type Config$1 as Config, type types$1_Decoder as Decoder, type Env$1 as Env, type InitSettings$1 as InitSettings, type Mapping$1 as Mapping, type PartialConfig$1 as PartialConfig, types$1_PubSub as PubSub, type Push$1 as Push, type types$1_ServiceAccountCredentials as ServiceAccountCredentials, type Settings$1 as Settings, type types$1_Setup as Setup, type types$1_SetupFn as SetupFn, types$1_Subscription as Subscription, type types$1_SyntheticMessage as SyntheticMessage, type types$1_SyntheticPushResult as SyntheticPushResult, type Types$1 as Types };
303
+ export { type Config$1 as Config, type types$1_Decoder as Decoder, type Env$1 as Env, type InitSettings$1 as InitSettings, type Mapping$1 as Mapping, type PartialConfig$1 as PartialConfig, types$1_PubSub as PubSub, type types$1_PubSubAdminClient as PubSubAdminClient, type types$1_PubSubPullClient as PubSubPullClient, type types$1_PullSubscription as PullSubscription, type Push$1 as Push, type types$1_ServiceAccountCredentials as ServiceAccountCredentials, type Settings$1 as Settings, type types$1_Setup as Setup, type types$1_SetupFn as SetupFn, types$1_Subscription as Subscription, type types$1_SyntheticMessage as SyntheticMessage, type types$1_SyntheticPushResult as SyntheticPushResult, type Types$1 as Types };
268
304
  }
269
305
 
270
306
  /**