@bite-ninja/zenu-sdk 0.11.4 → 0.12.1

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/client.d.ts CHANGED
@@ -12,6 +12,11 @@ export interface ZenuClientOptions {
12
12
  * Called before each request to get a fresh token.
13
13
  */
14
14
  getToken: () => Promise<string>;
15
+ /**
16
+ * Callback for general handling of errors (e.g., logging, reporting).
17
+ * Errors are still thrown and need to be handled by the caller, this is just for side effects.
18
+ */
19
+ onError?: (err: unknown) => void;
15
20
  }
16
21
  /**
17
22
  * Zenu SDK client providing typed access to all services.
@@ -57,6 +62,6 @@ interface ZenuClient {
57
62
  * console.log(`Server time: ${currentTime?.toISOString()}`);
58
63
  * ```
59
64
  */
60
- export declare function createZenuClient({ baseUrl, getToken, }: ZenuClientOptions): ZenuClient;
65
+ export declare function createZenuClient({ baseUrl, getToken, onError, }: ZenuClientOptions): ZenuClient;
61
66
  export {};
62
67
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,kBAAkB,EAEvB,KAAK,uBAAuB,EAE5B,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EAElC,MAAM,GAAG,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,UAAU,UAAU;IAClB;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAC;IAC1B,UAAU,EAAE,uBAAuB,CAAC;IACpC,cAAc,EAAE,2BAA2B,CAAC;IAC5C,eAAe,EAAE,4BAA4B,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,QAAQ,GACT,EAAE,iBAAiB,GAAG,UAAU,CA2BhC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,kBAAkB,EAEvB,KAAK,uBAAuB,EAE5B,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EAElC,MAAM,GAAG,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,UAAU,UAAU;IAClB;;OAEG;IACH,KAAK,EAAE,kBAAkB,CAAC;IAC1B,UAAU,EAAE,uBAAuB,CAAC;IACpC,cAAc,EAAE,2BAA2B,CAAC;IAC5C,eAAe,EAAE,4BAA4B,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,QAAQ,EACR,OAAO,GACR,EAAE,iBAAiB,GAAG,UAAU,CAgChC"}
@@ -0,0 +1,81 @@
1
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
+ import type { CallContext, CallOptions } from "nice-grpc-common";
3
+ /** Parameters for a user invitation notification. */
4
+ export interface UserInvitationNotification {
5
+ /** The email address of the user being invited. */
6
+ email: string;
7
+ /** The unique identifier for the invitation. */
8
+ invitationId: string;
9
+ /** The name of the organization the user is being invited to. */
10
+ organizationName: string;
11
+ /** The given (first) name of the person sending the invitation. */
12
+ senderGivenName: string;
13
+ }
14
+ /**
15
+ * A single notification to be sent.
16
+ *
17
+ * The oneof field determines both the type and parameters of the notification.
18
+ * To add a new notification type, define a new parameter message and add it as
19
+ * a variant here.
20
+ */
21
+ export interface Notification {
22
+ /** Notify a user that they have been invited to an organization. */
23
+ userInvitation?: UserInvitationNotification | undefined;
24
+ }
25
+ /** Request to send one or more notifications. */
26
+ export interface SendNotificationRequest {
27
+ /** The notifications to send. */
28
+ notifications: Notification[];
29
+ }
30
+ /** Response after sending notifications. */
31
+ export interface SendNotificationResponse {
32
+ }
33
+ export declare const UserInvitationNotification: MessageFns<UserInvitationNotification>;
34
+ export declare const Notification: MessageFns<Notification>;
35
+ export declare const SendNotificationRequest: MessageFns<SendNotificationRequest>;
36
+ export declare const SendNotificationResponse: MessageFns<SendNotificationResponse>;
37
+ /** Service for sending notifications to users. */
38
+ export type NotificationsServiceDefinition = typeof NotificationsServiceDefinition;
39
+ export declare const NotificationsServiceDefinition: {
40
+ readonly name: "NotificationsService";
41
+ readonly fullName: "zenu.notifications.v1.NotificationsService";
42
+ readonly methods: {
43
+ /** Sends one or more notifications. */
44
+ readonly sendNotification: {
45
+ readonly name: "SendNotification";
46
+ readonly requestType: MessageFns<SendNotificationRequest>;
47
+ readonly requestStream: false;
48
+ readonly responseType: MessageFns<SendNotificationResponse>;
49
+ readonly responseStream: false;
50
+ readonly options: {};
51
+ };
52
+ };
53
+ };
54
+ export interface NotificationsServiceImplementation<CallContextExt = {}> {
55
+ /** Sends one or more notifications. */
56
+ sendNotification(request: SendNotificationRequest, context: CallContext & CallContextExt): Promise<DeepPartial<SendNotificationResponse>>;
57
+ }
58
+ export interface NotificationsServiceClient<CallOptionsExt = {}> {
59
+ /** Sends one or more notifications. */
60
+ sendNotification(request: DeepPartial<SendNotificationRequest>, options?: CallOptions & CallOptionsExt): Promise<SendNotificationResponse>;
61
+ }
62
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
63
+ type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
64
+ [K in keyof T]?: DeepPartial<T[K]>;
65
+ } : Partial<T>;
66
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
67
+ type Exact<P, I extends P> = P extends Builtin ? P : P & {
68
+ [K in keyof P]: Exact<P[K], I[K]>;
69
+ } & {
70
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
71
+ };
72
+ interface MessageFns<T> {
73
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
74
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
75
+ fromJSON(object: any): T;
76
+ toJSON(message: T): unknown;
77
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
78
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
79
+ }
80
+ export {};
81
+ //# sourceMappingURL=notifications_service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifications_service.d.ts","sourceRoot":"","sources":["../../../../../src/gen/zenu/notifications/v1/notifications_service.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEjE,qDAAqD;AACrD,MAAM,WAAW,0BAA0B;IACzC,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,gBAAgB,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,cAAc,CAAC,EAAE,0BAA0B,GAAG,SAAS,CAAC;CACzD;AAED,iDAAiD;AACjD,MAAM,WAAW,uBAAuB;IACtC,iCAAiC;IACjC,aAAa,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED,4CAA4C;AAC5C,MAAM,WAAW,wBAAwB;CACxC;AAMD,eAA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M(require_lib3(), 1);
2378
2378
  function createZenuClient({
2379
2379
  baseUrl,
2380
- getToken
2380
+ getToken,
2381
+ onError
2381
2382
  }) {
2382
2383
  const channel = import_nice_grpc_web.createChannel(baseUrl);
2383
2384
  const clientFactory = import_nice_grpc_web.createClientFactory().use(async function* (call, options) {
2384
- const token = await getToken();
2385
- const metadata = import_nice_grpc_web.Metadata(options.metadata);
2386
- metadata.set("Authorization", `Bearer ${token}`);
2387
- return yield* call.next(call.request, {
2388
- ...options,
2389
- metadata
2390
- });
2385
+ try {
2386
+ const token = await getToken();
2387
+ const metadata = import_nice_grpc_web.Metadata(options.metadata);
2388
+ metadata.set("Authorization", `Bearer ${token}`);
2389
+ return yield* call.next(call.request, {
2390
+ ...options,
2391
+ metadata
2392
+ });
2393
+ } catch (err) {
2394
+ onError?.(err);
2395
+ throw err;
2396
+ }
2391
2397
  });
2392
2398
  return {
2393
2399
  users: clientFactory.create(UsersServiceDefinition, channel),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bite-ninja/zenu-sdk",
3
- "version": "0.11.4",
3
+ "version": "0.12.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "generate": "buf generate ../../protos",