@workwae/sdk 0.0.0-stage → 0.1.0-alpha.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.
Files changed (56) hide show
  1. package/README.md +233 -2
  2. package/client.d.ts +36 -0
  3. package/contract/accounts/models.d.ts +726 -0
  4. package/contract/accounts/routes.d.ts +1318 -0
  5. package/contract/ai/models.d.ts +30 -0
  6. package/contract/ai/routes.d.ts +89 -0
  7. package/contract/audit-log/models.d.ts +107 -0
  8. package/contract/audit-log/routes.d.ts +72 -0
  9. package/contract/calendar/models.d.ts +837 -0
  10. package/contract/calendar/routes.d.ts +1299 -0
  11. package/contract/connect/models.d.ts +272 -0
  12. package/contract/connect/routes.d.ts +531 -0
  13. package/contract/contacts/models.d.ts +269 -0
  14. package/contract/contacts/routes.d.ts +634 -0
  15. package/contract/errors.d.ts +108 -0
  16. package/contract/events/models.d.ts +2364 -0
  17. package/contract/events/routes.d.ts +107 -0
  18. package/contract/exports/models.d.ts +67 -0
  19. package/contract/exports/routes.d.ts +196 -0
  20. package/contract/identities/models.d.ts +100 -0
  21. package/contract/identities/routes.d.ts +249 -0
  22. package/contract/limits.d.ts +170 -0
  23. package/contract/mail/models.d.ts +528 -0
  24. package/contract/mail/routes.d.ts +749 -0
  25. package/contract/meetings/models.d.ts +232 -0
  26. package/contract/meetings/routes.d.ts +386 -0
  27. package/contract/oauth-apps/models.d.ts +92 -0
  28. package/contract/oauth-apps/routes.d.ts +187 -0
  29. package/contract/org-connections/models.d.ts +383 -0
  30. package/contract/org-connections/routes.d.ts +830 -0
  31. package/contract/primitives.d.ts +140 -0
  32. package/contract/public.d.ts +26 -0
  33. package/contract/reasons.d.ts +711 -0
  34. package/contract/router.d.ts +9773 -0
  35. package/contract/send/models.d.ts +750 -0
  36. package/contract/send/routes.d.ts +1239 -0
  37. package/contract/settings/models.d.ts +103 -0
  38. package/contract/settings/routes.d.ts +110 -0
  39. package/contract/suppressions/models.d.ts +231 -0
  40. package/contract/suppressions/routes.d.ts +317 -0
  41. package/contract/templates/models.d.ts +169 -0
  42. package/contract/templates/routes.d.ts +281 -0
  43. package/contract/threads/models.d.ts +117 -0
  44. package/contract/threads/routes.d.ts +336 -0
  45. package/contract/usage/models.d.ts +213 -0
  46. package/contract/usage/routes.d.ts +81 -0
  47. package/contract/webhooks/models.d.ts +879 -0
  48. package/contract/webhooks/routes.d.ts +839 -0
  49. package/contract/webhooks/signing.d.ts +35 -0
  50. package/errors.d.ts +15 -0
  51. package/index.d.ts +6 -0
  52. package/index.js +4334 -0
  53. package/index.js.map +59 -0
  54. package/package.json +45 -4
  55. package/pagination.d.ts +40 -0
  56. package/webhooks.d.ts +28 -0
@@ -0,0 +1,35 @@
1
+ /** Allowed clock skew between the platform and a receiver, per the specification. */
2
+ export declare const WEBHOOK_TOLERANCE_SECONDS = 300;
3
+ /** A fetch `Headers`, or a plain record such as Node's `req.headers` (any key case). */
4
+ export type WebhookHeaders = Headers | Record<string, string | string[] | undefined>;
5
+ export interface VerifyWebhookOptions {
6
+ /** Default WEBHOOK_TOLERANCE_SECONDS. */
7
+ toleranceSeconds?: number;
8
+ /** The receiver's clock; default the current time. */
9
+ now?: Date;
10
+ }
11
+ /** Why a delivery was refused: payload is a signed body that is not an event. */
12
+ export type WebhookVerificationFailure = "missing_headers" | "timestamp" | "signature" | "payload";
13
+ /** What each failure says, as WebhookVerificationError's message. */
14
+ export declare const WEBHOOK_VERIFICATION_MESSAGES: Record<WebhookVerificationFailure, string>;
15
+ export declare class WebhookVerificationError extends Error {
16
+ readonly failure: WebhookVerificationFailure;
17
+ constructor(failure: WebhookVerificationFailure, message?: string);
18
+ }
19
+ /** The webhook-signature header value for a delivery: `v1,<base64 HMAC>`. */
20
+ export declare function signWebhook(secret: string, msg: {
21
+ id: string;
22
+ timestamp: number;
23
+ body: string;
24
+ }): Promise<string>;
25
+ /**
26
+ * Why the delivery's signature does not verify, or null when it does: it is signed with `secret`
27
+ * and its timestamp is within the tolerance. Pass the raw request body exactly as received:
28
+ * re-serialized JSON does not verify. The body itself is not looked at.
29
+ */
30
+ export declare function checkWebhookSignature(secret: string, headers: WebhookHeaders, body: string | Uint8Array | ArrayBuffer, options?: VerifyWebhookOptions): Promise<Exclude<WebhookVerificationFailure, "payload"> | null>;
31
+ /**
32
+ * True when the delivery is signed with `secret` and its timestamp is within the tolerance.
33
+ * Pass the raw request body exactly as received: re-serialized JSON does not verify.
34
+ */
35
+ export declare function verifyWebhook(secret: string, headers: WebhookHeaders, body: string | Uint8Array | ArrayBuffer, options?: VerifyWebhookOptions): Promise<boolean>;
package/errors.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { ORPCError, type ORPCErrorCode } from "@orpc/client";
2
+ import { type ErrorReason, type ReasonData } from "./contract/public.js";
3
+ export { isDefinedError, ORPCError, safe } from "@orpc/client";
4
+ export type { ErrorReason } from "./contract/public.js";
5
+ declare module "@orpc/client" {
6
+ interface ORPCError<TCode extends ORPCErrorCode, TData> {
7
+ /** The X-Request-Id of the answer the error came in; undefined when no answer named one. */
8
+ requestId?: string;
9
+ }
10
+ }
11
+ /** An API error with reason `R`; over a union of reasons, the union of each one's error, so
12
+ * checking `code` narrows `data` to that reason's. */
13
+ type ApiError<R extends ErrorReason> = R extends ErrorReason ? ORPCError<R, ReasonData<R>> : never;
14
+ /** True for an API error carrying a reason, and with `reason`, only for that reason. */
15
+ export declare function isApiError<R extends ErrorReason = ErrorReason>(error: unknown, reason?: R): error is ApiError<R>;
package/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export type * from "./contract/public.js";
2
+ export { EVENT_TYPES, MAX_TEMPLATE_BODY_LENGTH, MAX_TEMPLATE_DESCRIPTION_LENGTH, MAX_TEMPLATE_NAME_LENGTH, MAX_TEMPLATE_PREVIEW_TEXT_LENGTH, MAX_TEMPLATE_SUBJECT_LENGTH, } from "./contract/public.js";
3
+ export { type CallContext, type ClientOptions, createClient, type RetryOptions, type WorkwaeClient, } from "./client.js";
4
+ export * from "./errors.js";
5
+ export { type CallOptions, ChangeFeed, type CursorCall, changes, pages, paginate, } from "./pagination.js";
6
+ export * from "./webhooks.js";