@productcraft/notify 0.3.0 → 0.4.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.cjs CHANGED
@@ -16,6 +16,140 @@ var APIResource = class {
16
16
  this._b = bound;
17
17
  }
18
18
  };
19
+ var ApprovalsResource = class extends APIResource {
20
+ /**
21
+ * Cancel an approval request
22
+ *
23
+ * Withdraws a pending request: approvers see it as cancelled, nothing more is sent, and `approval.resolved` fires with `status: cancelled`. Takes no Idempotency-Key: cancelling twice is a 409 the second time.
24
+ *
25
+ * Credential: `bearer`.
26
+ *
27
+ * @param approvalId - The approval request id.
28
+ * @param options - Per-request options.
29
+ * @throws {AuthenticationError} 401 UNAUTHORIZED, RECIPIENT_TOKEN_INVALID: Missing, expired, revoked or invalid bearer token (`UNAUTHORIZED`): send a workspace API key or a console session as `Authorization: Bearer <token>`. A recipient token is refused here with `RECIPIENT_TOKEN_INVALID`: it works only on the client API (`/v1/client/…`).
30
+ * @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action, or the workspace has not enabled Notify (`SERVICE_NOT_ENABLED`). Also `FORBIDDEN` when the credential belongs to another workspace than the URL names, or the URL uses the workspace slug instead of its id (a UUID).
31
+ * @throws {NotFoundError} 404 NOT_FOUND, APPROVAL_NOT_FOUND: `APPROVAL_NOT_FOUND`: no approval request with this id in this workspace.
32
+ * @throws {ConflictError} 409 CONFLICT, APPROVAL_NOT_PENDING: `APPROVAL_NOT_PENDING`: it was already answered, expired or cancelled.
33
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
34
+ * @see POST /v1/workspaces/{workspace_id}/approvals/{approval_id}/cancel
35
+ * @see https://productcraft.co/docs/notify/api-reference#post-v1-workspaces-workspace-id-approvals-approval-id-cancel
36
+ * @example
37
+ * ```ts
38
+ * const approval = await notify.approvals.cancel("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
39
+ * ```
40
+ */
41
+ cancel(approvalId, options) {
42
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/approvals/{approval_id}/cancel", pathParams: { approval_id: approvalId } }, options);
43
+ }
44
+ /**
45
+ * Request an approval
46
+ *
47
+ * Asks one or more people a yes/no question on the type's channels and records the first answer. In the inbox the item gets Approve and Reject buttons (or render it with `<NotifyApproval/>`); emails and pushes carry a signed link per approver (`approval.url`, `approval.approve_url`, `approval.reject_url`) to a hosted page that needs no sign-in. The answer arrives as the signed `approval.resolved` webhook and on `GET /approvals/{approval_id}`. Nobody answered by `expires_at`: the type's `timeout_outcome` applies (default `expired`). Pass `wait_seconds` (up to 15) to wait for the answer in this call. The type must have `approval` set; its notifications can only be sent here. An `Idempotency-Key` is required: the same key and body return the same request (200), a different body is a 409.
48
+ *
49
+ * Credential: `bearer`.
50
+ *
51
+ * @param params - `Notify.ApprovalCreateParams`.
52
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
53
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, IDEMPOTENCY_KEY_REQUIRED: `IDEMPOTENCY_KEY_REQUIRED`; `VALIDATION_ERROR`: a field is invalid.
54
+ * @throws {AuthenticationError} 401 UNAUTHORIZED, RECIPIENT_TOKEN_INVALID: Missing, expired, revoked or invalid bearer token (`UNAUTHORIZED`): send a workspace API key or a console session as `Authorization: Bearer <token>`. A recipient token is refused here with `RECIPIENT_TOKEN_INVALID`: it works only on the client API (`/v1/client/…`).
55
+ * @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action, or the workspace has not enabled Notify (`SERVICE_NOT_ENABLED`). Also `FORBIDDEN` when the credential belongs to another workspace than the URL names, or the URL uses the workspace slug instead of its id (a UUID).
56
+ * @throws {NotFoundError} 404 NOT_FOUND, NOTIFICATION_TYPE_NOT_FOUND: `NOTIFICATION_TYPE_NOT_FOUND`: no type with this key.
57
+ * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the key was used with a different body. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
58
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, NOT_AN_APPROVAL_TYPE, NOTIFICATION_TYPE_ARCHIVED, RECIPIENT_NOT_FOUND: `NOT_AN_APPROVAL_TYPE`: the type has no `approval`; `NOTIFICATION_TYPE_ARCHIVED`; `RECIPIENT_NOT_FOUND`: an approver is not a recipient (`details.missing`).
59
+ * @throws {RateLimitError} 429 RATE_LIMITED: `RATE_LIMITED`: over the workspace send limit; see `Retry-After`. Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
60
+ * @see POST /v1/workspaces/{workspace_id}/approvals
61
+ * @see https://productcraft.co/docs/notify/api-reference#post-v1-workspaces-workspace-id-approvals
62
+ * @example
63
+ * ```ts
64
+ * const approval = await notify.approvals.create({
65
+ * approvers: ["user_123"],
66
+ * title: "Deploy api v2.14 to production?",
67
+ * type: "deploy.approval",
68
+ * });
69
+ * ```
70
+ */
71
+ create(params, options) {
72
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/approvals", body: params, idempotent: true }, options);
73
+ }
74
+ /**
75
+ * List approval requests
76
+ *
77
+ * Newest first; filter by `status` and `type`. Pass `next_cursor` as `cursor` until `has_more` is false.
78
+ *
79
+ * Credential: `bearer`.
80
+ *
81
+ * @param params - `Notify.ApprovalListParams`.
82
+ * @param options - Per-request options.
83
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR` on a bad filter, or `BAD_REQUEST`: invalid cursor.
84
+ * @throws {AuthenticationError} 401 UNAUTHORIZED, RECIPIENT_TOKEN_INVALID: Missing, expired, revoked or invalid bearer token (`UNAUTHORIZED`): send a workspace API key or a console session as `Authorization: Bearer <token>`. A recipient token is refused here with `RECIPIENT_TOKEN_INVALID`: it works only on the client API (`/v1/client/…`).
85
+ * @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action, or the workspace has not enabled Notify (`SERVICE_NOT_ENABLED`). Also `FORBIDDEN` when the credential belongs to another workspace than the URL names, or the URL uses the workspace slug instead of its id (a UUID).
86
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
87
+ * @see GET /v1/workspaces/{workspace_id}/approvals
88
+ * @see https://productcraft.co/docs/notify/api-reference#get-v1-workspaces-workspace-id-approvals
89
+ * @example
90
+ * ```ts
91
+ * for await (const approval of notify.approvals.list()) {
92
+ * console.log(approval);
93
+ * }
94
+ * const page = await notify.approvals.list({}, { timeout: 5_000 });
95
+ * ```
96
+ */
97
+ list(params, options) {
98
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/approvals", query: params }, options);
99
+ }
100
+ /**
101
+ * Record an approver's answer
102
+ *
103
+ * For answers you collected yourself (your own UI, a phone call): records `approve` or `reject` for one of the approvers, exactly as if they had pressed the button (`decided_via: api`). Never give this to the agent that made the request: it is how a human's answer gets in, so it is not an MCP tool.
104
+ *
105
+ * Credential: `bearer`.
106
+ *
107
+ * @param approvalId - The approval request id.
108
+ * @param params - `Notify.ApprovalRecordDecisionParams`.
109
+ * @param options - Per-request options.
110
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a field is invalid.
111
+ * @throws {AuthenticationError} 401 UNAUTHORIZED, RECIPIENT_TOKEN_INVALID: Missing, expired, revoked or invalid bearer token (`UNAUTHORIZED`): send a workspace API key or a console session as `Authorization: Bearer <token>`. A recipient token is refused here with `RECIPIENT_TOKEN_INVALID`: it works only on the client API (`/v1/client/…`).
112
+ * @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action, or the workspace has not enabled Notify (`SERVICE_NOT_ENABLED`). Also `FORBIDDEN` when the credential belongs to another workspace than the URL names, or the URL uses the workspace slug instead of its id (a UUID).
113
+ * @throws {NotFoundError} 404 NOT_FOUND, APPROVAL_NOT_FOUND, RECIPIENT_NOT_FOUND: `APPROVAL_NOT_FOUND`, or `RECIPIENT_NOT_FOUND`: no recipient with that external id.
114
+ * @throws {ConflictError} 409 CONFLICT, APPROVAL_NOT_PENDING: `APPROVAL_NOT_PENDING`: already answered, expired or cancelled.
115
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, NOT_AN_APPROVER, APPROVAL_REASON_REQUIRED: `NOT_AN_APPROVER`: that recipient was not asked; `APPROVAL_REASON_REQUIRED`: the type needs a reason.
116
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
117
+ * @see POST /v1/workspaces/{workspace_id}/approvals/{approval_id}/decision
118
+ * @see https://productcraft.co/docs/notify/api-reference#post-v1-workspaces-workspace-id-approvals-approval-id-decision
119
+ * @example
120
+ * ```ts
121
+ * const approval = await notify.approvals.recordDecision("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { approver: "user_123", decision: "approve" });
122
+ * ```
123
+ */
124
+ recordDecision(approvalId, params, options) {
125
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/approvals/{approval_id}/decision", pathParams: { approval_id: approvalId }, body: params }, options);
126
+ }
127
+ /**
128
+ * Get an approval request
129
+ *
130
+ * Its status, the answer (who, when, why, from where) and its trail. With `wait_seconds` (up to 15) a pending request is long-polled: the call returns as soon as someone answers, or after that many seconds.
131
+ *
132
+ * Credential: `bearer`.
133
+ *
134
+ * @param approvalId - The approval request id.
135
+ * @param params - `Notify.ApprovalRetrieveParams`.
136
+ * @param options - Per-request options.
137
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: `wait_seconds` out of range.
138
+ * @throws {AuthenticationError} 401 UNAUTHORIZED, RECIPIENT_TOKEN_INVALID: Missing, expired, revoked or invalid bearer token (`UNAUTHORIZED`): send a workspace API key or a console session as `Authorization: Bearer <token>`. A recipient token is refused here with `RECIPIENT_TOKEN_INVALID`: it works only on the client API (`/v1/client/…`).
139
+ * @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action, or the workspace has not enabled Notify (`SERVICE_NOT_ENABLED`). Also `FORBIDDEN` when the credential belongs to another workspace than the URL names, or the URL uses the workspace slug instead of its id (a UUID).
140
+ * @throws {NotFoundError} 404 NOT_FOUND, APPROVAL_NOT_FOUND: `APPROVAL_NOT_FOUND`: no approval request with this id in this workspace.
141
+ * @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
142
+ * @see GET /v1/workspaces/{workspace_id}/approvals/{approval_id}
143
+ * @see https://productcraft.co/docs/notify/api-reference#get-v1-workspaces-workspace-id-approvals-approval-id
144
+ * @example
145
+ * ```ts
146
+ * const approvalDetail = await notify.approvals.retrieve("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
147
+ * ```
148
+ */
149
+ retrieve(approvalId, params, options) {
150
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/approvals/{approval_id}", pathParams: { approval_id: approvalId }, query: params }, options);
151
+ }
152
+ };
19
153
  var BatchesResource = class extends APIResource {
20
154
  /**
21
155
  * Close a batch now
@@ -810,16 +944,7 @@ var NotificationTypesResource = class extends APIResource {
810
944
  * @example
811
945
  * ```ts
812
946
  * const notificationType = await notify.notificationTypes.update("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", {
813
- * batch: {
814
- * inbox: "collapse",
815
- * key: "post_id",
816
- * max_items: 10,
817
- * max_window_seconds: 3600,
818
- * mode: "window",
819
- * schedule: { frequency: "daily", time: "09:00", weekday: "monday" },
820
- * sliding: false,
821
- * window_seconds: 300,
822
- * },
947
+ * approval: { default_expires_in_seconds: 86400, reason: "optional", timeout_outcome: "expired" },
823
948
  * });
824
949
  * ```
825
950
  */
@@ -961,7 +1086,7 @@ var NotificationsResource = class extends APIResource {
961
1086
  * @throws {NotFoundError} 404 NOT_FOUND, NOTIFICATION_TYPE_NOT_FOUND: `NOTIFICATION_TYPE_NOT_FOUND`: no type with this key.
962
1087
  * @throws {ConflictError} 409 CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `IDEMPOTENCY_KEY_REUSE`: the key was used with a different body. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
963
1088
  * @throws {APIError} 413 PAYLOAD_TOO_LARGE, DATA_TOO_LARGE: `DATA_TOO_LARGE`: `data` is over 16 KB.
964
- * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, RECIPIENT_NOT_FOUND, NOTIFICATION_TYPE_ARCHIVED, TEMPLATE_MISSING, SEND_AT_OUT_OF_RANGE, BATCHED_TYPE_NOT_SCHEDULABLE, UNSAFE_URL, VALIDATION_ERROR: `RECIPIENT_NOT_FOUND`: no recipient can be notified (`details.skipped` lists why); `NOTIFICATION_TYPE_ARCHIVED`; `TEMPLATE_MISSING`: no template for any requested channel; `SEND_AT_OUT_OF_RANGE`; `BATCHED_TYPE_NOT_SCHEDULABLE`: the type batches (send it now); `UNSAFE_URL`; `VALIDATION_ERROR`: a channel outside the type's routing.
1089
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, RECIPIENT_NOT_FOUND, NOTIFICATION_TYPE_ARCHIVED, TEMPLATE_MISSING, SEND_AT_OUT_OF_RANGE, BATCHED_TYPE_NOT_SCHEDULABLE, APPROVAL_TYPE_SEND_REFUSED, UNSAFE_URL, VALIDATION_ERROR: `RECIPIENT_NOT_FOUND`: no recipient can be notified (`details.skipped` lists why); `NOTIFICATION_TYPE_ARCHIVED`; `TEMPLATE_MISSING`: no template for any requested channel; `SEND_AT_OUT_OF_RANGE`; `BATCHED_TYPE_NOT_SCHEDULABLE`: the type batches (send it now); `APPROVAL_TYPE_SEND_REFUSED`: an approval type, sent with `POST /approvals`; `UNSAFE_URL`; `VALIDATION_ERROR`: a channel outside the type's routing.
965
1090
  * @throws {RateLimitError} 429 RATE_LIMITED: `RATE_LIMITED`: over 3,000 recipients a minute in this workspace; see `Retry-After`. Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
966
1091
  * @see POST /v1/workspaces/{workspace_id}/notifications
967
1092
  * @see https://productcraft.co/docs/notify/api-reference#post-v1-workspaces-workspace-id-notifications
@@ -1860,6 +1985,7 @@ var WebhooksResource = class extends APIResource {
1860
1985
  }
1861
1986
  };
1862
1987
  var NotifyResources = class extends APIResource {
1988
+ #approvals;
1863
1989
  #batches;
1864
1990
  #categories;
1865
1991
  #channels;
@@ -1873,6 +1999,9 @@ var NotifyResources = class extends APIResource {
1873
1999
  #setupStatus;
1874
2000
  #stats;
1875
2001
  #webhooks;
2002
+ get approvals() {
2003
+ return this.#approvals ??= new ApprovalsResource(this._client, this._b);
2004
+ }
1876
2005
  get batches() {
1877
2006
  return this.#batches ??= new BatchesResource(this._client, this._b);
1878
2007
  }
@@ -1913,6 +2042,60 @@ var NotifyResources = class extends APIResource {
1913
2042
  return this.#webhooks ??= new WebhooksResource(this._client, this._b);
1914
2043
  }
1915
2044
  };
2045
+ var ClientApprovalsResource = class extends APIResource {
2046
+ /**
2047
+ * Answer an approval request
2048
+ *
2049
+ * Approve or reject, with an optional reason (required when the type says so). The first answer of any approver decides; the requester gets the signed `approval.resolved` webhook. Answering again, or after the request expired, is a 409.
2050
+ *
2051
+ * Credential: `recipient_token`.
2052
+ * - `recipient_token`: A recipient token minted by your backend with `POST /v1/workspaces/{workspace_id}/recipient-tokens`. Only the client API (`/v1/client/…`) accepts it.
2053
+ *
2054
+ * @param approvalId - Id of the approval.
2055
+ * @param params - `Notify.MeApprovalDecideParams`.
2056
+ * @param options - Per-request options.
2057
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: `decision` must be `approve` or `reject`.
2058
+ * @throws {AuthenticationError} 401 UNAUTHORIZED, RECIPIENT_TOKEN_INVALID, RECIPIENT_TOKEN_EXPIRED: `RECIPIENT_TOKEN_INVALID`: no recipient token, a malformed or forged one, an API key, or a revoked token (mint a new one); `RECIPIENT_TOKEN_EXPIRED`: the token expired (mint a new one).
2059
+ * @throws {PermissionDeniedError} 403 FORBIDDEN, RECIPIENT_TOKEN_SCOPE, ORIGIN_NOT_ALLOWED, SERVICE_NOT_ENABLED: `RECIPIENT_TOKEN_SCOPE`: the token lacks the `inbox:write` scope; `ORIGIN_NOT_ALLOWED`: the browser origin is not in the workspace client origins; `SERVICE_NOT_ENABLED`: Notify is turned off for the workspace.
2060
+ * @throws {NotFoundError} 404 NOT_FOUND, APPROVAL_NOT_FOUND: `APPROVAL_NOT_FOUND`: no such request for this recipient.
2061
+ * @throws {ConflictError} 409 CONFLICT, APPROVAL_NOT_PENDING: `APPROVAL_NOT_PENDING`: already answered, expired or cancelled.
2062
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, APPROVAL_REASON_REQUIRED: `APPROVAL_REASON_REQUIRED`: a reason is required.
2063
+ * @throws {RateLimitError} 429 RATE_LIMITED: `RATE_LIMITED`: over 60 client calls per minute for this recipient; `Retry-After` gives the seconds to wait. Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2064
+ * @see POST /v1/client/approvals/{approval_id}/decision
2065
+ * @see https://productcraft.co/docs/notify/api-reference#post-v1-client-approvals-approval-id-decision
2066
+ * @example
2067
+ * ```ts
2068
+ * const approval = await notify.client({ token: "rt_example_recipient_token" }).approvals.decide("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { decision: "approve" });
2069
+ * ```
2070
+ */
2071
+ decide(approvalId, params, options) {
2072
+ return this._client.request({ method: "POST", path: "/v1/client/approvals/{approval_id}/decision", pathParams: { approval_id: approvalId }, body: params }, options);
2073
+ }
2074
+ /**
2075
+ * Get an approval request
2076
+ *
2077
+ * One request the recipient was asked to answer: the question, who asked, its status and, once decided, who answered and why.
2078
+ *
2079
+ * Credential: `recipient_token`.
2080
+ * - `recipient_token`: A recipient token minted by your backend with `POST /v1/workspaces/{workspace_id}/recipient-tokens`. Only the client API (`/v1/client/…`) accepts it.
2081
+ *
2082
+ * @param approvalId - Id of the approval.
2083
+ * @param options - Per-request options.
2084
+ * @throws {AuthenticationError} 401 UNAUTHORIZED, RECIPIENT_TOKEN_INVALID, RECIPIENT_TOKEN_EXPIRED: `RECIPIENT_TOKEN_INVALID`: no recipient token, a malformed or forged one, an API key, or a revoked token (mint a new one); `RECIPIENT_TOKEN_EXPIRED`: the token expired (mint a new one).
2085
+ * @throws {PermissionDeniedError} 403 FORBIDDEN, RECIPIENT_TOKEN_SCOPE, ORIGIN_NOT_ALLOWED, SERVICE_NOT_ENABLED: `RECIPIENT_TOKEN_SCOPE`: the token lacks the `inbox:read` scope; `ORIGIN_NOT_ALLOWED`: the browser origin is not in the workspace client origins; `SERVICE_NOT_ENABLED`: Notify is turned off for the workspace.
2086
+ * @throws {NotFoundError} 404 NOT_FOUND, APPROVAL_NOT_FOUND: `APPROVAL_NOT_FOUND`: no such request for this recipient.
2087
+ * @throws {RateLimitError} 429 RATE_LIMITED: `RATE_LIMITED`: over 60 client calls per minute for this recipient; `Retry-After` gives the seconds to wait. Per-IP limit: more than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
2088
+ * @see GET /v1/client/approvals/{approval_id}
2089
+ * @see https://productcraft.co/docs/notify/api-reference#get-v1-client-approvals-approval-id
2090
+ * @example
2091
+ * ```ts
2092
+ * const approval = await notify.client({ token: "rt_example_recipient_token" }).approvals.retrieve("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
2093
+ * ```
2094
+ */
2095
+ retrieve(approvalId, options) {
2096
+ return this._client.request({ method: "GET", path: "/v1/client/approvals/{approval_id}", pathParams: { approval_id: approvalId } }, options);
2097
+ }
2098
+ };
1916
2099
  var ClientDevicesResource = class extends APIResource {
1917
2100
  /**
1918
2101
  * Remove this device
@@ -2140,10 +2323,14 @@ var ClientWebpushResource = class extends APIResource {
2140
2323
  }
2141
2324
  };
2142
2325
  var NotifyClient = class extends APIResource {
2326
+ #approvals;
2143
2327
  #devices;
2144
2328
  #inbox;
2145
2329
  #preferences;
2146
2330
  #webpush;
2331
+ get approvals() {
2332
+ return this.#approvals ??= new ClientApprovalsResource(this._client, this._b);
2333
+ }
2147
2334
  get devices() {
2148
2335
  return this.#devices ??= new ClientDevicesResource(this._client, this._b);
2149
2336
  }
@@ -2177,17 +2364,26 @@ var DeviceState = { values: ["active", "invalid", "pruned"] };
2177
2364
  var InboxItemStatusFilter = { values: ["active", "archived", "all"] };
2178
2365
  var InboxMarkAction = { values: ["seen", "read", "unread", "archived", "unarchived"] };
2179
2366
  var NotificationStatus = { values: ["scheduled", "accepted", "planned", "cancelled"] };
2367
+ var NotifyApprovalDecidedVia = { values: ["inbox", "hosted_page", "api", "timeout"] };
2368
+ var NotifyApprovalDecision = { values: ["approve", "reject"] };
2369
+ var NotifyApprovalOutcome = { values: ["approved", "rejected", "expired", "cancelled"] };
2370
+ var NotifyApprovalOutcomeVia = { values: ["inbox", "hosted_page", "api", "timeout"] };
2371
+ var NotifyApprovalReasonPolicy = { values: ["optional", "required_on_reject", "required"] };
2372
+ var NotifyApprovalRequesterKind = { values: ["agent", "service", "user"] };
2373
+ var NotifyApprovalRequesterViewKind = { values: ["agent", "service", "user", "api_key"] };
2374
+ var NotifyApprovalStatus = { values: ["pending", "approved", "rejected", "expired", "cancelled"] };
2375
+ var NotifyApprovalTimeoutOutcome = { values: ["expired", "approved", "rejected"] };
2180
2376
  var NotifyBatchInboxMode = { values: ["collapse", "each"] };
2181
2377
  var NotifyBatchMode = { values: ["window", "digest"] };
2182
2378
  var NotifyBatchState = { values: ["open", "flushed", "cancelled"] };
2183
- var NotifyChannel = { values: ["inbox", "email", "push", "webpush"] };
2379
+ var NotifyChannel = { values: ["inbox", "email", "push", "webpush", "webhook"] };
2184
2380
  var NotifyDeliveryReason = { values: ["suppressed_preference", "default_off", "unsubscribed_all", "held_quiet_hours", "scheduled_send", "no_device", "no_address", "email_invalid", "email_complained", "email_paused", "email_budget", "email_backlog_full", "channel_not_configured", "channel_restricted", "type_archived", "credential_invalid", "template_missing", "rate_limited", "throttled", "read_in_inbox", "awaiting_unread", "batched", "batched_into", "actor_excluded", "recipient_not_found", "recipient_erased", "mail_suppressed", "mail_refused", "pruned", "payload_too_large", "credential_error", "circuit_open", "expired", "cancelled", "provider_error"] };
2185
2381
  var NotifyDigestFrequency = { values: ["daily", "weekly"] };
2186
2382
  var NotifyEmailPauseReason = { values: ["complaints", "bounces"] };
2187
2383
  var NotifyQuietHoursSource = { values: ["recipient", "workspace"] };
2188
2384
  var NotifyRecipientDeletionCause = { values: ["api", "auth_user_deleted"] };
2189
2385
  var NotifyStatsChannel = { values: ["inbox", "email", "push", "webpush"] };
2190
- var NotifyWebhookChannel = { values: ["inbox", "email", "push", "webpush"] };
2386
+ var NotifyWebhookChannel = { values: ["inbox", "email", "push", "webpush", "webhook"] };
2191
2387
  var NotifyWebhookCredentialProvider = { values: ["apns", "fcm", "vapid"] };
2192
2388
  var NotifyWebhookDeliveryState = { values: ["sent", "delivered", "failed", "bounced", "skipped", "pruned"] };
2193
2389
  var NotifyWebhookDeviceChannel = { values: ["apns", "fcm", "webpush"] };
@@ -2204,10 +2400,10 @@ var WebhookAttemptTrigger = { values: ["automatic", "replay", "test"] };
2204
2400
  var WebhookEndpointDisabledReason = { values: ["manual", "failing"] };
2205
2401
  var WebhookEndpointStatus = { values: ["enabled", "disabled", "auto_disabled"] };
2206
2402
  var WebhookEventStatus = { values: ["pending", "delivered", "failed", "not_sent"] };
2207
- var WebhookEventType = { values: ["notification.accepted", "delivery.sent", "delivery.delivered", "delivery.failed", "delivery.bounced", "delivery.skipped", "inbox_item.read", "inbox_item.archived", "inbox_item.interacted", "device.pruned", "device.moved", "credential.invalid", "email.auto_paused", "recipient.deleted"] };
2403
+ var WebhookEventType = { values: ["notification.accepted", "delivery.sent", "delivery.delivered", "delivery.failed", "delivery.bounced", "delivery.skipped", "inbox_item.read", "inbox_item.archived", "inbox_item.interacted", "device.pruned", "device.moved", "credential.invalid", "email.auto_paused", "recipient.deleted", "notification.webhook", "approval.resolved"] };
2208
2404
 
2209
2405
  // src/_generated/client.ts
2210
- var VERSION = "0.3.0" ;
2406
+ var VERSION = "0.4.0" ;
2211
2407
  exports.default = class Notify extends NotifyResources {
2212
2408
  /** The options this client was built with, for the token scopes' own clients. Never enumerable. */
2213
2409
  #options;
@@ -2259,6 +2455,15 @@ exports.default = class Notify extends NotifyResources {
2259
2455
  Notify2.InboxItemStatusFilter = InboxItemStatusFilter;
2260
2456
  Notify2.InboxMarkAction = InboxMarkAction;
2261
2457
  Notify2.NotificationStatus = NotificationStatus;
2458
+ Notify2.NotifyApprovalDecidedVia = NotifyApprovalDecidedVia;
2459
+ Notify2.NotifyApprovalDecision = NotifyApprovalDecision;
2460
+ Notify2.NotifyApprovalOutcome = NotifyApprovalOutcome;
2461
+ Notify2.NotifyApprovalOutcomeVia = NotifyApprovalOutcomeVia;
2462
+ Notify2.NotifyApprovalReasonPolicy = NotifyApprovalReasonPolicy;
2463
+ Notify2.NotifyApprovalRequesterKind = NotifyApprovalRequesterKind;
2464
+ Notify2.NotifyApprovalRequesterViewKind = NotifyApprovalRequesterViewKind;
2465
+ Notify2.NotifyApprovalStatus = NotifyApprovalStatus;
2466
+ Notify2.NotifyApprovalTimeoutOutcome = NotifyApprovalTimeoutOutcome;
2262
2467
  Notify2.NotifyBatchInboxMode = NotifyBatchInboxMode;
2263
2468
  Notify2.NotifyBatchMode = NotifyBatchMode;
2264
2469
  Notify2.NotifyBatchState = NotifyBatchState;
@@ -2288,7 +2493,7 @@ exports.default = class Notify extends NotifyResources {
2288
2493
  Notify2.WebhookEventStatus = WebhookEventStatus;
2289
2494
  Notify2.WebhookEventType = WebhookEventType;
2290
2495
  })(exports.default || (exports.default = {}));
2291
- var NotifyErrorCode = { values: ["BAD_REQUEST", "VALIDATION_ERROR", "UNAUTHORIZED", "PAYMENT_REQUIRED", "FORBIDDEN", "NOT_FOUND", "METHOD_NOT_ALLOWED", "NOT_ACCEPTABLE", "REQUEST_TIMEOUT", "CONFLICT", "GONE", "PRECONDITION_FAILED", "PAYLOAD_TOO_LARGE", "UNSUPPORTED_MEDIA_TYPE", "UNPROCESSABLE_ENTITY", "PRECONDITION_REQUIRED", "RATE_LIMITED", "INTERNAL_SERVER_ERROR", "NOT_IMPLEMENTED", "BAD_GATEWAY", "SERVICE_UNAVAILABLE", "GATEWAY_TIMEOUT", "SERVICE_NOT_ENABLED", "INVALID_CREDENTIALS", "SESSION_REVOKED", "MCP_NOT_PERMITTED", "MCP_WORKSPACE_MISMATCH", "PAK_NOT_PERMITTED", "ACTIONS_NOT_GRANTABLE", "IDEMPOTENCY_KEY_REUSE", "IDEMPOTENCY_KEY_REQUIRED", "IDEMPOTENCY_IN_PROGRESS", "WEBHOOK_ENDPOINT_LIMIT", "WEBHOOK_ENDPOINT_NOT_FOUND", "WEBHOOK_ENDPOINT_NOT_SUBSCRIBED", "WEBHOOK_EVENT_NOT_FOUND", "WEBHOOK_EVENT_TYPE_UNKNOWN", "NOTIFICATION_TYPE_NOT_FOUND", "NOTIFICATION_TYPE_ARCHIVED", "RECIPIENT_NOT_FOUND", "TOO_MANY_RECIPIENTS", "DATA_TOO_LARGE", "TEMPLATE_MISSING", "TEMPLATE_INVALID", "CHANNEL_NOT_CONFIGURED", "CREDENTIAL_INVALID", "CREDENTIAL_NOT_FOUND", "CREDENTIAL_MISMATCH", "DEVICE_TOKEN_INVALID", "WEBPUSH_ENDPOINT_NOT_ALLOWED", "RECIPIENT_TOKEN_INVALID", "RECIPIENT_TOKEN_EXPIRED", "RECIPIENT_TOKEN_SCOPE", "ORIGIN_NOT_ALLOWED", "STREAM_LIMIT", "LIMIT_EXCEEDED", "BATCHED_TYPE_NOT_SCHEDULABLE", "BATCH_NOT_FOUND", "BATCH_NOT_OPEN", "SEND_AT_OUT_OF_RANGE", "UNSAFE_URL", "AUTH_USER_ALREADY_LINKED", "DEVICE_NOT_FOUND", "CATEGORY_NOT_FOUND", "CATEGORY_KEY_TAKEN", "CATEGORY_IN_USE", "NOTIFICATION_TYPE_KEY_TAKEN", "TEMPLATE_NOT_FOUND", "TEMPLATE_VERSION_NOT_FOUND", "PREFERENCE_LOCKED", "NOTIFICATION_NOT_FOUND", "DELIVERY_NOT_FOUND", "CONFIRMATION_REQUIRED", "INBOX_ITEM_NOT_FOUND", "RECIPIENT_ERASED", "DEVICE_MOVE_LIMIT"] };
2496
+ var NotifyErrorCode = { values: ["BAD_REQUEST", "VALIDATION_ERROR", "UNAUTHORIZED", "PAYMENT_REQUIRED", "FORBIDDEN", "NOT_FOUND", "METHOD_NOT_ALLOWED", "NOT_ACCEPTABLE", "REQUEST_TIMEOUT", "CONFLICT", "GONE", "PRECONDITION_FAILED", "PAYLOAD_TOO_LARGE", "UNSUPPORTED_MEDIA_TYPE", "UNPROCESSABLE_ENTITY", "PRECONDITION_REQUIRED", "RATE_LIMITED", "INTERNAL_SERVER_ERROR", "NOT_IMPLEMENTED", "BAD_GATEWAY", "SERVICE_UNAVAILABLE", "GATEWAY_TIMEOUT", "SERVICE_NOT_ENABLED", "INVALID_CREDENTIALS", "SESSION_REVOKED", "MCP_NOT_PERMITTED", "MCP_WORKSPACE_MISMATCH", "PAK_NOT_PERMITTED", "ACTIONS_NOT_GRANTABLE", "IDEMPOTENCY_KEY_REUSE", "IDEMPOTENCY_KEY_REQUIRED", "IDEMPOTENCY_IN_PROGRESS", "WEBHOOK_ENDPOINT_LIMIT", "WEBHOOK_ENDPOINT_NOT_FOUND", "WEBHOOK_ENDPOINT_NOT_SUBSCRIBED", "WEBHOOK_EVENT_NOT_FOUND", "WEBHOOK_EVENT_TYPE_UNKNOWN", "NOTIFICATION_TYPE_NOT_FOUND", "NOTIFICATION_TYPE_ARCHIVED", "RECIPIENT_NOT_FOUND", "TOO_MANY_RECIPIENTS", "DATA_TOO_LARGE", "TEMPLATE_MISSING", "TEMPLATE_INVALID", "CHANNEL_NOT_CONFIGURED", "CREDENTIAL_INVALID", "CREDENTIAL_NOT_FOUND", "CREDENTIAL_MISMATCH", "DEVICE_TOKEN_INVALID", "WEBPUSH_ENDPOINT_NOT_ALLOWED", "RECIPIENT_TOKEN_INVALID", "RECIPIENT_TOKEN_EXPIRED", "RECIPIENT_TOKEN_SCOPE", "ORIGIN_NOT_ALLOWED", "STREAM_LIMIT", "LIMIT_EXCEEDED", "BATCHED_TYPE_NOT_SCHEDULABLE", "APPROVAL_NOT_FOUND", "APPROVAL_NOT_PENDING", "APPROVAL_REASON_REQUIRED", "APPROVAL_TYPE_SEND_REFUSED", "NOT_AN_APPROVAL_TYPE", "NOT_AN_APPROVER", "BATCH_NOT_FOUND", "BATCH_NOT_OPEN", "SEND_AT_OUT_OF_RANGE", "UNSAFE_URL", "AUTH_USER_ALREADY_LINKED", "DEVICE_NOT_FOUND", "CATEGORY_NOT_FOUND", "CATEGORY_KEY_TAKEN", "CATEGORY_IN_USE", "NOTIFICATION_TYPE_KEY_TAKEN", "TEMPLATE_NOT_FOUND", "TEMPLATE_VERSION_NOT_FOUND", "PREFERENCE_LOCKED", "NOTIFICATION_NOT_FOUND", "DELIVERY_NOT_FOUND", "CONFIRMATION_REQUIRED", "INBOX_ITEM_NOT_FOUND", "RECIPIENT_ERASED", "DEVICE_MOVE_LIMIT"] };
2292
2497
 
2293
2498
  Object.defineProperty(exports, "APIConnectionError", {
2294
2499
  enumerable: true,