@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.
- package/README.md +233 -2
- package/client.d.ts +36 -0
- package/contract/accounts/models.d.ts +726 -0
- package/contract/accounts/routes.d.ts +1318 -0
- package/contract/ai/models.d.ts +30 -0
- package/contract/ai/routes.d.ts +89 -0
- package/contract/audit-log/models.d.ts +107 -0
- package/contract/audit-log/routes.d.ts +72 -0
- package/contract/calendar/models.d.ts +837 -0
- package/contract/calendar/routes.d.ts +1299 -0
- package/contract/connect/models.d.ts +272 -0
- package/contract/connect/routes.d.ts +531 -0
- package/contract/contacts/models.d.ts +269 -0
- package/contract/contacts/routes.d.ts +634 -0
- package/contract/errors.d.ts +108 -0
- package/contract/events/models.d.ts +2364 -0
- package/contract/events/routes.d.ts +107 -0
- package/contract/exports/models.d.ts +67 -0
- package/contract/exports/routes.d.ts +196 -0
- package/contract/identities/models.d.ts +100 -0
- package/contract/identities/routes.d.ts +249 -0
- package/contract/limits.d.ts +170 -0
- package/contract/mail/models.d.ts +528 -0
- package/contract/mail/routes.d.ts +749 -0
- package/contract/meetings/models.d.ts +232 -0
- package/contract/meetings/routes.d.ts +386 -0
- package/contract/oauth-apps/models.d.ts +92 -0
- package/contract/oauth-apps/routes.d.ts +187 -0
- package/contract/org-connections/models.d.ts +383 -0
- package/contract/org-connections/routes.d.ts +830 -0
- package/contract/primitives.d.ts +140 -0
- package/contract/public.d.ts +26 -0
- package/contract/reasons.d.ts +711 -0
- package/contract/router.d.ts +9773 -0
- package/contract/send/models.d.ts +750 -0
- package/contract/send/routes.d.ts +1239 -0
- package/contract/settings/models.d.ts +103 -0
- package/contract/settings/routes.d.ts +110 -0
- package/contract/suppressions/models.d.ts +231 -0
- package/contract/suppressions/routes.d.ts +317 -0
- package/contract/templates/models.d.ts +169 -0
- package/contract/templates/routes.d.ts +281 -0
- package/contract/threads/models.d.ts +117 -0
- package/contract/threads/routes.d.ts +336 -0
- package/contract/usage/models.d.ts +213 -0
- package/contract/usage/routes.d.ts +81 -0
- package/contract/webhooks/models.d.ts +879 -0
- package/contract/webhooks/routes.d.ts +839 -0
- package/contract/webhooks/signing.d.ts +35 -0
- package/errors.d.ts +15 -0
- package/index.d.ts +6 -0
- package/index.js +4334 -0
- package/index.js.map +59 -0
- package/package.json +45 -4
- package/pagination.d.ts +40 -0
- package/webhooks.d.ts +28 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { type ErrorReason, type ReasonDataSchema, type ReasonStatus, type ReasonTable } from "./reasons.js";
|
|
2
|
+
/** A declared error: its reason's status and data schema, with the condition as its message. */
|
|
3
|
+
export type DeclaredError<R extends ErrorReason> = {
|
|
4
|
+
status: ReasonStatus<R>;
|
|
5
|
+
message: string;
|
|
6
|
+
} & (ReasonDataSchema<R> extends undefined ? unknown : {
|
|
7
|
+
data: ReasonDataSchema<R>;
|
|
8
|
+
});
|
|
9
|
+
export type DeclaredErrors<C> = {
|
|
10
|
+
[R in keyof C & ErrorReason]: DeclaredError<R>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The oRPC error map for `conditions` (reason -> when it is answered, one sentence), each with its
|
|
14
|
+
* reason's status and data schema from `table`. errors() below and the console's wrap it; they
|
|
15
|
+
* are declared functions with named return types so declarations reference the table by name
|
|
16
|
+
* instead of inlining it into every route.
|
|
17
|
+
*/
|
|
18
|
+
export declare function errorMap(table: ReasonTable, conditions: Record<string, string | undefined>): Record<string, {
|
|
19
|
+
status: number;
|
|
20
|
+
message: string;
|
|
21
|
+
data?: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
/** The error map of a /v1 route; console routes use console/reasons.ts's, which knows theirs. */
|
|
24
|
+
export declare function errors<const C extends {
|
|
25
|
+
[R in ErrorReason]?: string;
|
|
26
|
+
}>(conditions: C): DeclaredErrors<C>;
|
|
27
|
+
/** What any route can answer with, whoever calls it and whatever it does. */
|
|
28
|
+
export declare const GLOBAL_ERRORS: DeclaredErrors<{
|
|
29
|
+
readonly invalid_input: "The request does not match the operation's input schema (a malformed body included); data.issues names each problem.";
|
|
30
|
+
readonly unauthenticated: "No usable credential: none was sent, or it is malformed, unknown, revoked or an expired account token.";
|
|
31
|
+
readonly api_key_expired: "The API key is past its expiry (or the grace of the rotation that replaced it).";
|
|
32
|
+
readonly missing_scope: "The API key lacks the scope the operation needs.";
|
|
33
|
+
readonly role_forbidden: "The member's role does not allow the operation.";
|
|
34
|
+
readonly account_token_forbidden: "An account token called an operation account tokens cannot call.";
|
|
35
|
+
readonly rate_limited: "The tenant used up its plan's request rate; Retry-After says when the window ends.";
|
|
36
|
+
readonly too_many_requests: "The credential has too many requests in flight at once; retry after Retry-After.";
|
|
37
|
+
readonly overloaded: "The API is shedding load; retry after Retry-After.";
|
|
38
|
+
readonly payload_too_large: "The request body is larger than the API accepts.";
|
|
39
|
+
readonly internal_error: "An unexpected failure on our side.";
|
|
40
|
+
readonly invalid_idempotency_key: "POST only: the Idempotency-Key header is not 1 to 255 printable ASCII characters.";
|
|
41
|
+
readonly idempotency_key_reused: "POST only: the Idempotency-Key was used in the last 24 hours with another method, path or body.";
|
|
42
|
+
readonly idempotency_key_in_progress: "POST only: the request first sent with this Idempotency-Key has not been answered yet.";
|
|
43
|
+
}>;
|
|
44
|
+
/** The builder every route starts from: oc with GLOBAL_ERRORS declared. */
|
|
45
|
+
export declare const base: import("@orpc/contract").ContractBuilder<import("@orpc/contract").Schema<unknown, unknown>, import("@orpc/contract").Schema<unknown, unknown>, import("@orpc/contract").MergedErrorMap<Record<never, never>, DeclaredErrors<{
|
|
46
|
+
readonly invalid_input: "The request does not match the operation's input schema (a malformed body included); data.issues names each problem.";
|
|
47
|
+
readonly unauthenticated: "No usable credential: none was sent, or it is malformed, unknown, revoked or an expired account token.";
|
|
48
|
+
readonly api_key_expired: "The API key is past its expiry (or the grace of the rotation that replaced it).";
|
|
49
|
+
readonly missing_scope: "The API key lacks the scope the operation needs.";
|
|
50
|
+
readonly role_forbidden: "The member's role does not allow the operation.";
|
|
51
|
+
readonly account_token_forbidden: "An account token called an operation account tokens cannot call.";
|
|
52
|
+
readonly rate_limited: "The tenant used up its plan's request rate; Retry-After says when the window ends.";
|
|
53
|
+
readonly too_many_requests: "The credential has too many requests in flight at once; retry after Retry-After.";
|
|
54
|
+
readonly overloaded: "The API is shedding load; retry after Retry-After.";
|
|
55
|
+
readonly payload_too_large: "The request body is larger than the API accepts.";
|
|
56
|
+
readonly internal_error: "An unexpected failure on our side.";
|
|
57
|
+
readonly invalid_idempotency_key: "POST only: the Idempotency-Key header is not 1 to 255 printable ASCII characters.";
|
|
58
|
+
readonly idempotency_key_reused: "POST only: the Idempotency-Key was used in the last 24 hours with another method, path or body.";
|
|
59
|
+
readonly idempotency_key_in_progress: "POST only: the request first sent with this Idempotency-Key has not been answered yet.";
|
|
60
|
+
}>>, Record<never, never>>;
|
|
61
|
+
export declare const SESSION_ONLY: DeclaredErrors<{
|
|
62
|
+
readonly session_required: "The caller is not a board session (only board sessions may call this).";
|
|
63
|
+
}>;
|
|
64
|
+
export declare const OWNER_ONLY: DeclaredErrors<{
|
|
65
|
+
readonly session_required: "The caller is not a board session (only board sessions may call this).";
|
|
66
|
+
readonly owner_required: "The caller does not own the organization.";
|
|
67
|
+
}>;
|
|
68
|
+
export declare const PLATFORM_ONLY: DeclaredErrors<{
|
|
69
|
+
readonly session_required: "The caller is not a board session (only board sessions may call this).";
|
|
70
|
+
readonly platform_admin_required: "The caller is not a platform administrator.";
|
|
71
|
+
readonly email_verification_required: "The platform administrator has not verified their email address yet.";
|
|
72
|
+
}>;
|
|
73
|
+
/** The account a path names: missing, deleted, or another account than an account token's. */
|
|
74
|
+
export declare const ACCOUNT_NOT_FOUND: DeclaredErrors<{
|
|
75
|
+
readonly account_not_found: "The account does not exist, or the caller is an account token for another account.";
|
|
76
|
+
}>;
|
|
77
|
+
/** The account states that keep a route from reaching the provider; `account` names the account
|
|
78
|
+
* and may narrow when, e.g. "With source=provider, the account". */
|
|
79
|
+
export declare function accountState(account?: string): DeclaredErrors<{
|
|
80
|
+
readonly account_paused: `${string} is paused.`;
|
|
81
|
+
readonly account_disabled: `${string} is disabled.`;
|
|
82
|
+
readonly account_reauth_required: `${string} must be reconnected: its stored grant or login no longer works.`;
|
|
83
|
+
readonly account_misconfigured: `${string}'s stored grant cannot be used until an administrator fixes what it relies on (the tenant's OAuth app or organization connection is refused, missing or unreadable).`;
|
|
84
|
+
}>;
|
|
85
|
+
/** What any provider call answers when it fails. A route the provider can refuse adds
|
|
86
|
+
* `provider_forbidden` with its own condition, and one reading an item `provider_not_found`. */
|
|
87
|
+
export declare const PROVIDER_FAILURES: DeclaredErrors<{
|
|
88
|
+
readonly provider_throttled: "The provider asked us to slow down (with Retry-After when it named a wait).";
|
|
89
|
+
readonly provider_unavailable: "The provider could not be reached (with Retry-After when it named a wait).";
|
|
90
|
+
}>;
|
|
91
|
+
/** What asking for stored bodies through `field` refuses. */
|
|
92
|
+
export declare function bodyStorage(field: string): DeclaredErrors<{
|
|
93
|
+
readonly storage_unavailable: `${string} is cache or full and no object store is configured.`;
|
|
94
|
+
readonly plan_limit_storage: `${string} is cache or full and the tenant's plan does not include body storage.`;
|
|
95
|
+
}>;
|
|
96
|
+
/** A route of a module the tenant's plan may lack, e.g. planModule("calendar"). */
|
|
97
|
+
export declare function planModule(module: string): DeclaredErrors<{
|
|
98
|
+
readonly plan_module_unavailable: `The tenant's plan does not include ${string}.`;
|
|
99
|
+
}>;
|
|
100
|
+
export declare const PLAN_LIMIT_ACCOUNTS: DeclaredErrors<{
|
|
101
|
+
readonly plan_limit_accounts: "The tenant already has as many accounts as its plan allows.";
|
|
102
|
+
}>;
|
|
103
|
+
export declare const BILLING_PAST_DUE: DeclaredErrors<{
|
|
104
|
+
readonly billing_past_due: "The tenant's payment is past due beyond the grace period (sends already queued or scheduled still go out).";
|
|
105
|
+
}>;
|
|
106
|
+
export declare const INVALID_CURSOR: DeclaredErrors<{
|
|
107
|
+
readonly invalid_cursor: "The cursor is not one this list issued.";
|
|
108
|
+
}>;
|