@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.js CHANGED
@@ -13,6 +13,140 @@ var APIResource = class {
13
13
  this._b = bound;
14
14
  }
15
15
  };
16
+ var ApprovalsResource = class extends APIResource {
17
+ /**
18
+ * Cancel an approval request
19
+ *
20
+ * 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.
21
+ *
22
+ * Credential: `bearer`.
23
+ *
24
+ * @param approvalId - The approval request id.
25
+ * @param options - Per-request options.
26
+ * @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/…`).
27
+ * @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).
28
+ * @throws {NotFoundError} 404 NOT_FOUND, APPROVAL_NOT_FOUND: `APPROVAL_NOT_FOUND`: no approval request with this id in this workspace.
29
+ * @throws {ConflictError} 409 CONFLICT, APPROVAL_NOT_PENDING: `APPROVAL_NOT_PENDING`: it was already answered, expired or cancelled.
30
+ * @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.
31
+ * @see POST /v1/workspaces/{workspace_id}/approvals/{approval_id}/cancel
32
+ * @see https://productcraft.co/docs/notify/api-reference#post-v1-workspaces-workspace-id-approvals-approval-id-cancel
33
+ * @example
34
+ * ```ts
35
+ * const approval = await notify.approvals.cancel("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
36
+ * ```
37
+ */
38
+ cancel(approvalId, options) {
39
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/approvals/{approval_id}/cancel", pathParams: { approval_id: approvalId } }, options);
40
+ }
41
+ /**
42
+ * Request an approval
43
+ *
44
+ * 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.
45
+ *
46
+ * Credential: `bearer`.
47
+ *
48
+ * @param params - `Notify.ApprovalCreateParams`.
49
+ * @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
50
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, IDEMPOTENCY_KEY_REQUIRED: `IDEMPOTENCY_KEY_REQUIRED`; `VALIDATION_ERROR`: a field is invalid.
51
+ * @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/…`).
52
+ * @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).
53
+ * @throws {NotFoundError} 404 NOT_FOUND, NOTIFICATION_TYPE_NOT_FOUND: `NOTIFICATION_TYPE_NOT_FOUND`: no type with this key.
54
+ * @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).
55
+ * @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`).
56
+ * @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.
57
+ * @see POST /v1/workspaces/{workspace_id}/approvals
58
+ * @see https://productcraft.co/docs/notify/api-reference#post-v1-workspaces-workspace-id-approvals
59
+ * @example
60
+ * ```ts
61
+ * const approval = await notify.approvals.create({
62
+ * approvers: ["user_123"],
63
+ * title: "Deploy api v2.14 to production?",
64
+ * type: "deploy.approval",
65
+ * });
66
+ * ```
67
+ */
68
+ create(params, options) {
69
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/approvals", body: params, idempotent: true }, options);
70
+ }
71
+ /**
72
+ * List approval requests
73
+ *
74
+ * Newest first; filter by `status` and `type`. Pass `next_cursor` as `cursor` until `has_more` is false.
75
+ *
76
+ * Credential: `bearer`.
77
+ *
78
+ * @param params - `Notify.ApprovalListParams`.
79
+ * @param options - Per-request options.
80
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR` on a bad filter, or `BAD_REQUEST`: invalid cursor.
81
+ * @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/…`).
82
+ * @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).
83
+ * @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.
84
+ * @see GET /v1/workspaces/{workspace_id}/approvals
85
+ * @see https://productcraft.co/docs/notify/api-reference#get-v1-workspaces-workspace-id-approvals
86
+ * @example
87
+ * ```ts
88
+ * for await (const approval of notify.approvals.list()) {
89
+ * console.log(approval);
90
+ * }
91
+ * const page = await notify.approvals.list({}, { timeout: 5_000 });
92
+ * ```
93
+ */
94
+ list(params, options) {
95
+ return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/approvals", query: params }, options);
96
+ }
97
+ /**
98
+ * Record an approver's answer
99
+ *
100
+ * 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.
101
+ *
102
+ * Credential: `bearer`.
103
+ *
104
+ * @param approvalId - The approval request id.
105
+ * @param params - `Notify.ApprovalRecordDecisionParams`.
106
+ * @param options - Per-request options.
107
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a field is invalid.
108
+ * @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/…`).
109
+ * @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).
110
+ * @throws {NotFoundError} 404 NOT_FOUND, APPROVAL_NOT_FOUND, RECIPIENT_NOT_FOUND: `APPROVAL_NOT_FOUND`, or `RECIPIENT_NOT_FOUND`: no recipient with that external id.
111
+ * @throws {ConflictError} 409 CONFLICT, APPROVAL_NOT_PENDING: `APPROVAL_NOT_PENDING`: already answered, expired or cancelled.
112
+ * @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.
113
+ * @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.
114
+ * @see POST /v1/workspaces/{workspace_id}/approvals/{approval_id}/decision
115
+ * @see https://productcraft.co/docs/notify/api-reference#post-v1-workspaces-workspace-id-approvals-approval-id-decision
116
+ * @example
117
+ * ```ts
118
+ * const approval = await notify.approvals.recordDecision("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { approver: "user_123", decision: "approve" });
119
+ * ```
120
+ */
121
+ recordDecision(approvalId, params, options) {
122
+ return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/approvals/{approval_id}/decision", pathParams: { approval_id: approvalId }, body: params }, options);
123
+ }
124
+ /**
125
+ * Get an approval request
126
+ *
127
+ * 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.
128
+ *
129
+ * Credential: `bearer`.
130
+ *
131
+ * @param approvalId - The approval request id.
132
+ * @param params - `Notify.ApprovalRetrieveParams`.
133
+ * @param options - Per-request options.
134
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: `wait_seconds` out of range.
135
+ * @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/…`).
136
+ * @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).
137
+ * @throws {NotFoundError} 404 NOT_FOUND, APPROVAL_NOT_FOUND: `APPROVAL_NOT_FOUND`: no approval request with this id in this workspace.
138
+ * @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.
139
+ * @see GET /v1/workspaces/{workspace_id}/approvals/{approval_id}
140
+ * @see https://productcraft.co/docs/notify/api-reference#get-v1-workspaces-workspace-id-approvals-approval-id
141
+ * @example
142
+ * ```ts
143
+ * const approvalDetail = await notify.approvals.retrieve("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
144
+ * ```
145
+ */
146
+ retrieve(approvalId, params, options) {
147
+ return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/approvals/{approval_id}", pathParams: { approval_id: approvalId }, query: params }, options);
148
+ }
149
+ };
16
150
  var BatchesResource = class extends APIResource {
17
151
  /**
18
152
  * Close a batch now
@@ -807,16 +941,7 @@ var NotificationTypesResource = class extends APIResource {
807
941
  * @example
808
942
  * ```ts
809
943
  * const notificationType = await notify.notificationTypes.update("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", {
810
- * batch: {
811
- * inbox: "collapse",
812
- * key: "post_id",
813
- * max_items: 10,
814
- * max_window_seconds: 3600,
815
- * mode: "window",
816
- * schedule: { frequency: "daily", time: "09:00", weekday: "monday" },
817
- * sliding: false,
818
- * window_seconds: 300,
819
- * },
944
+ * approval: { default_expires_in_seconds: 86400, reason: "optional", timeout_outcome: "expired" },
820
945
  * });
821
946
  * ```
822
947
  */
@@ -958,7 +1083,7 @@ var NotificationsResource = class extends APIResource {
958
1083
  * @throws {NotFoundError} 404 NOT_FOUND, NOTIFICATION_TYPE_NOT_FOUND: `NOTIFICATION_TYPE_NOT_FOUND`: no type with this key.
959
1084
  * @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).
960
1085
  * @throws {APIError} 413 PAYLOAD_TOO_LARGE, DATA_TOO_LARGE: `DATA_TOO_LARGE`: `data` is over 16 KB.
961
- * @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.
1086
+ * @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.
962
1087
  * @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.
963
1088
  * @see POST /v1/workspaces/{workspace_id}/notifications
964
1089
  * @see https://productcraft.co/docs/notify/api-reference#post-v1-workspaces-workspace-id-notifications
@@ -1857,6 +1982,7 @@ var WebhooksResource = class extends APIResource {
1857
1982
  }
1858
1983
  };
1859
1984
  var NotifyResources = class extends APIResource {
1985
+ #approvals;
1860
1986
  #batches;
1861
1987
  #categories;
1862
1988
  #channels;
@@ -1870,6 +1996,9 @@ var NotifyResources = class extends APIResource {
1870
1996
  #setupStatus;
1871
1997
  #stats;
1872
1998
  #webhooks;
1999
+ get approvals() {
2000
+ return this.#approvals ??= new ApprovalsResource(this._client, this._b);
2001
+ }
1873
2002
  get batches() {
1874
2003
  return this.#batches ??= new BatchesResource(this._client, this._b);
1875
2004
  }
@@ -1910,6 +2039,60 @@ var NotifyResources = class extends APIResource {
1910
2039
  return this.#webhooks ??= new WebhooksResource(this._client, this._b);
1911
2040
  }
1912
2041
  };
2042
+ var ClientApprovalsResource = class extends APIResource {
2043
+ /**
2044
+ * Answer an approval request
2045
+ *
2046
+ * 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.
2047
+ *
2048
+ * Credential: `recipient_token`.
2049
+ * - `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.
2050
+ *
2051
+ * @param approvalId - Id of the approval.
2052
+ * @param params - `Notify.MeApprovalDecideParams`.
2053
+ * @param options - Per-request options.
2054
+ * @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: `decision` must be `approve` or `reject`.
2055
+ * @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).
2056
+ * @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.
2057
+ * @throws {NotFoundError} 404 NOT_FOUND, APPROVAL_NOT_FOUND: `APPROVAL_NOT_FOUND`: no such request for this recipient.
2058
+ * @throws {ConflictError} 409 CONFLICT, APPROVAL_NOT_PENDING: `APPROVAL_NOT_PENDING`: already answered, expired or cancelled.
2059
+ * @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, APPROVAL_REASON_REQUIRED: `APPROVAL_REASON_REQUIRED`: a reason is required.
2060
+ * @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.
2061
+ * @see POST /v1/client/approvals/{approval_id}/decision
2062
+ * @see https://productcraft.co/docs/notify/api-reference#post-v1-client-approvals-approval-id-decision
2063
+ * @example
2064
+ * ```ts
2065
+ * const approval = await notify.client({ token: "rt_example_recipient_token" }).approvals.decide("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { decision: "approve" });
2066
+ * ```
2067
+ */
2068
+ decide(approvalId, params, options) {
2069
+ return this._client.request({ method: "POST", path: "/v1/client/approvals/{approval_id}/decision", pathParams: { approval_id: approvalId }, body: params }, options);
2070
+ }
2071
+ /**
2072
+ * Get an approval request
2073
+ *
2074
+ * One request the recipient was asked to answer: the question, who asked, its status and, once decided, who answered and why.
2075
+ *
2076
+ * Credential: `recipient_token`.
2077
+ * - `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.
2078
+ *
2079
+ * @param approvalId - Id of the approval.
2080
+ * @param options - Per-request options.
2081
+ * @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).
2082
+ * @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.
2083
+ * @throws {NotFoundError} 404 NOT_FOUND, APPROVAL_NOT_FOUND: `APPROVAL_NOT_FOUND`: no such request for this recipient.
2084
+ * @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.
2085
+ * @see GET /v1/client/approvals/{approval_id}
2086
+ * @see https://productcraft.co/docs/notify/api-reference#get-v1-client-approvals-approval-id
2087
+ * @example
2088
+ * ```ts
2089
+ * const approval = await notify.client({ token: "rt_example_recipient_token" }).approvals.retrieve("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
2090
+ * ```
2091
+ */
2092
+ retrieve(approvalId, options) {
2093
+ return this._client.request({ method: "GET", path: "/v1/client/approvals/{approval_id}", pathParams: { approval_id: approvalId } }, options);
2094
+ }
2095
+ };
1913
2096
  var ClientDevicesResource = class extends APIResource {
1914
2097
  /**
1915
2098
  * Remove this device
@@ -2137,10 +2320,14 @@ var ClientWebpushResource = class extends APIResource {
2137
2320
  }
2138
2321
  };
2139
2322
  var NotifyClient = class extends APIResource {
2323
+ #approvals;
2140
2324
  #devices;
2141
2325
  #inbox;
2142
2326
  #preferences;
2143
2327
  #webpush;
2328
+ get approvals() {
2329
+ return this.#approvals ??= new ClientApprovalsResource(this._client, this._b);
2330
+ }
2144
2331
  get devices() {
2145
2332
  return this.#devices ??= new ClientDevicesResource(this._client, this._b);
2146
2333
  }
@@ -2174,17 +2361,26 @@ var DeviceState = { values: ["active", "invalid", "pruned"] };
2174
2361
  var InboxItemStatusFilter = { values: ["active", "archived", "all"] };
2175
2362
  var InboxMarkAction = { values: ["seen", "read", "unread", "archived", "unarchived"] };
2176
2363
  var NotificationStatus = { values: ["scheduled", "accepted", "planned", "cancelled"] };
2364
+ var NotifyApprovalDecidedVia = { values: ["inbox", "hosted_page", "api", "timeout"] };
2365
+ var NotifyApprovalDecision = { values: ["approve", "reject"] };
2366
+ var NotifyApprovalOutcome = { values: ["approved", "rejected", "expired", "cancelled"] };
2367
+ var NotifyApprovalOutcomeVia = { values: ["inbox", "hosted_page", "api", "timeout"] };
2368
+ var NotifyApprovalReasonPolicy = { values: ["optional", "required_on_reject", "required"] };
2369
+ var NotifyApprovalRequesterKind = { values: ["agent", "service", "user"] };
2370
+ var NotifyApprovalRequesterViewKind = { values: ["agent", "service", "user", "api_key"] };
2371
+ var NotifyApprovalStatus = { values: ["pending", "approved", "rejected", "expired", "cancelled"] };
2372
+ var NotifyApprovalTimeoutOutcome = { values: ["expired", "approved", "rejected"] };
2177
2373
  var NotifyBatchInboxMode = { values: ["collapse", "each"] };
2178
2374
  var NotifyBatchMode = { values: ["window", "digest"] };
2179
2375
  var NotifyBatchState = { values: ["open", "flushed", "cancelled"] };
2180
- var NotifyChannel = { values: ["inbox", "email", "push", "webpush"] };
2376
+ var NotifyChannel = { values: ["inbox", "email", "push", "webpush", "webhook"] };
2181
2377
  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"] };
2182
2378
  var NotifyDigestFrequency = { values: ["daily", "weekly"] };
2183
2379
  var NotifyEmailPauseReason = { values: ["complaints", "bounces"] };
2184
2380
  var NotifyQuietHoursSource = { values: ["recipient", "workspace"] };
2185
2381
  var NotifyRecipientDeletionCause = { values: ["api", "auth_user_deleted"] };
2186
2382
  var NotifyStatsChannel = { values: ["inbox", "email", "push", "webpush"] };
2187
- var NotifyWebhookChannel = { values: ["inbox", "email", "push", "webpush"] };
2383
+ var NotifyWebhookChannel = { values: ["inbox", "email", "push", "webpush", "webhook"] };
2188
2384
  var NotifyWebhookCredentialProvider = { values: ["apns", "fcm", "vapid"] };
2189
2385
  var NotifyWebhookDeliveryState = { values: ["sent", "delivered", "failed", "bounced", "skipped", "pruned"] };
2190
2386
  var NotifyWebhookDeviceChannel = { values: ["apns", "fcm", "webpush"] };
@@ -2201,10 +2397,10 @@ var WebhookAttemptTrigger = { values: ["automatic", "replay", "test"] };
2201
2397
  var WebhookEndpointDisabledReason = { values: ["manual", "failing"] };
2202
2398
  var WebhookEndpointStatus = { values: ["enabled", "disabled", "auto_disabled"] };
2203
2399
  var WebhookEventStatus = { values: ["pending", "delivered", "failed", "not_sent"] };
2204
- 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"] };
2400
+ 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"] };
2205
2401
 
2206
2402
  // src/_generated/client.ts
2207
- var VERSION = "0.3.0" ;
2403
+ var VERSION = "0.4.0" ;
2208
2404
  var Notify = class extends NotifyResources {
2209
2405
  /** The options this client was built with, for the token scopes' own clients. Never enumerable. */
2210
2406
  #options;
@@ -2256,6 +2452,15 @@ var Notify = class extends NotifyResources {
2256
2452
  Notify2.InboxItemStatusFilter = InboxItemStatusFilter;
2257
2453
  Notify2.InboxMarkAction = InboxMarkAction;
2258
2454
  Notify2.NotificationStatus = NotificationStatus;
2455
+ Notify2.NotifyApprovalDecidedVia = NotifyApprovalDecidedVia;
2456
+ Notify2.NotifyApprovalDecision = NotifyApprovalDecision;
2457
+ Notify2.NotifyApprovalOutcome = NotifyApprovalOutcome;
2458
+ Notify2.NotifyApprovalOutcomeVia = NotifyApprovalOutcomeVia;
2459
+ Notify2.NotifyApprovalReasonPolicy = NotifyApprovalReasonPolicy;
2460
+ Notify2.NotifyApprovalRequesterKind = NotifyApprovalRequesterKind;
2461
+ Notify2.NotifyApprovalRequesterViewKind = NotifyApprovalRequesterViewKind;
2462
+ Notify2.NotifyApprovalStatus = NotifyApprovalStatus;
2463
+ Notify2.NotifyApprovalTimeoutOutcome = NotifyApprovalTimeoutOutcome;
2259
2464
  Notify2.NotifyBatchInboxMode = NotifyBatchInboxMode;
2260
2465
  Notify2.NotifyBatchMode = NotifyBatchMode;
2261
2466
  Notify2.NotifyBatchState = NotifyBatchState;
@@ -2285,7 +2490,7 @@ var Notify = class extends NotifyResources {
2285
2490
  Notify2.WebhookEventStatus = WebhookEventStatus;
2286
2491
  Notify2.WebhookEventType = WebhookEventType;
2287
2492
  })(Notify || (Notify = {}));
2288
- 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"] };
2493
+ 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"] };
2289
2494
 
2290
2495
  export { Notify, NotifyErrorCode, Notify as default };
2291
2496
  //# sourceMappingURL=index.js.map