@productcraft/notify 0.1.1 → 0.2.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/api.md +4 -4
- package/dist/index.cjs +8 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -28
- package/dist/index.d.ts +68 -28
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +5 -0
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +5 -0
- package/dist/testing.js.map +1 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
package/api.md
CHANGED
|
@@ -762,13 +762,13 @@ Cancels every live notification sent with this `cancellation_key`: deliveries st
|
|
|
762
762
|
|
|
763
763
|
| Status | Error class | Codes | When |
|
|
764
764
|
|---|---|---|---|
|
|
765
|
-
| 400 | `BadRequestError` | `BAD_REQUEST`, `VALIDATION_ERROR` | `VALIDATION_ERROR`: `cancellation_key` is missing. |
|
|
765
|
+
| 400 | `BadRequestError` | `BAD_REQUEST`, `VALIDATION_ERROR` | `VALIDATION_ERROR`: `cancellation_key` is missing or not 1-255 characters of `A-Z a-z 0-9 . _ : @ \| -`. |
|
|
766
766
|
| 401 | `AuthenticationError` | `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/…`). |
|
|
767
767
|
| 403 | `PermissionDeniedError` | `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). |
|
|
768
768
|
| 429 | `RateLimitError` | `RATE_LIMITED` | More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds. |
|
|
769
769
|
|
|
770
770
|
```ts
|
|
771
|
-
const cancelByKey = await notify.notifications.cancelByKey({ cancellation_key: "invite:inv_77" });
|
|
771
|
+
const cancelByKey = await notify.notifications.cancelByKey({ cancellation_key: "invite.sent:inv_77" });
|
|
772
772
|
```
|
|
773
773
|
|
|
774
774
|
[HTTP reference](https://productcraft.co/docs/notify/api-reference#post-v1-workspaces-workspace-id-notifications-cancel)
|
|
@@ -853,7 +853,7 @@ const notification = await notify.notifications.retrieve("0193a5f2-7c1e-7b3a-9f1
|
|
|
853
853
|
|
|
854
854
|
Send a notification.
|
|
855
855
|
|
|
856
|
-
Notifies up to 1,000 recipients with one notification type, across the type's channels (in-app inbox, email, push, web push), honouring each recipient's preferences. Returns 202 as soon as the send is stored; delivery happens in the background (see `GET /deliveries`). Unknown external ids do not fail the call: they are listed in `skipped` (`create_missing: true` creates them instead); the call fails only when no recipient can be notified. An `Idempotency-Key` is **required** (a deterministic one such as `invoice.paid:inv_123
|
|
856
|
+
Notifies up to 1,000 recipients with one notification type, across the type's channels (in-app inbox, email, push, web push), honouring each recipient's preferences. Returns 202 as soon as the send is stored; delivery happens in the background (see `GET /deliveries`). Unknown external ids do not fail the call: they are listed in `skipped` (`create_missing: true` creates them instead); the call fails only when no recipient can be notified. An `Idempotency-Key` is **required** (a deterministic one built from your event, such as `invoice.paid:inv_123`, is best; dots are fine): the same key and body return the same notification, even when retried much later; the same key with a different body is a 409. `dry_run: true` returns the plan per recipient and channel with the reason for every skip, and stores nothing (200, no key needed). Limits: 3,000 recipients per minute per workspace; 30 notifications per minute per recipient (critical types have a separate 30), beyond which deliveries are skipped as `rate_limited`.
|
|
857
857
|
|
|
858
858
|
- Params: `Notify.NotificationSendParams`
|
|
859
859
|
- Idempotent: an `Idempotency-Key` is sent automatically and reused on retries
|
|
@@ -861,7 +861,7 @@ Notifies up to 1,000 recipients with one notification type, across the type's ch
|
|
|
861
861
|
|
|
862
862
|
| Status | Error class | Codes | When |
|
|
863
863
|
|---|---|---|---|
|
|
864
|
-
| 400 | `BadRequestError` | `BAD_REQUEST`, `VALIDATION_ERROR`, `IDEMPOTENCY_KEY_REQUIRED`, `TOO_MANY_RECIPIENTS` | `IDEMPOTENCY_KEY_REQUIRED`: no `Idempotency-Key`; `TOO_MANY_RECIPIENTS`: over 1,000; `VALIDATION_ERROR`: a field is invalid. |
|
|
864
|
+
| 400 | `BadRequestError` | `BAD_REQUEST`, `VALIDATION_ERROR`, `IDEMPOTENCY_KEY_REQUIRED`, `TOO_MANY_RECIPIENTS` | `IDEMPOTENCY_KEY_REQUIRED`: no `Idempotency-Key`; `BAD_REQUEST`: the `Idempotency-Key` is over 256 characters or has a character outside `A-Z a-z 0-9 . _ : -` (the message names it); `TOO_MANY_RECIPIENTS`: over 1,000; `VALIDATION_ERROR`: a field is invalid (an invalid `cancellation_key` included). |
|
|
865
865
|
| 401 | `AuthenticationError` | `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/…`). |
|
|
866
866
|
| 403 | `PermissionDeniedError` | `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). |
|
|
867
867
|
| 404 | `NotFoundError` | `NOT_FOUND`, `NOTIFICATION_TYPE_NOT_FOUND` | `NOTIFICATION_TYPE_NOT_FOUND`: no type with this key. |
|
package/dist/index.cjs
CHANGED
|
@@ -774,7 +774,7 @@ var NotificationsResource = class extends APIResource {
|
|
|
774
774
|
*
|
|
775
775
|
* @param params - `Notify.NotificationCancelByKeyParams`.
|
|
776
776
|
* @param options - Per-request options.
|
|
777
|
-
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: `cancellation_key` is missing.
|
|
777
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: `cancellation_key` is missing or not 1-255 characters of `A-Z a-z 0-9 . _ : @ | -`.
|
|
778
778
|
* @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/…`).
|
|
779
779
|
* @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).
|
|
780
780
|
* @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.
|
|
@@ -782,7 +782,7 @@ var NotificationsResource = class extends APIResource {
|
|
|
782
782
|
* @see https://productcraft.co/docs/notify/api-reference#post-v1-workspaces-workspace-id-notifications-cancel
|
|
783
783
|
* @example
|
|
784
784
|
* ```ts
|
|
785
|
-
* const cancelByKey = await notify.notifications.cancelByKey({ cancellation_key: "invite:inv_77" });
|
|
785
|
+
* const cancelByKey = await notify.notifications.cancelByKey({ cancellation_key: "invite.sent:inv_77" });
|
|
786
786
|
* ```
|
|
787
787
|
*/
|
|
788
788
|
cancelByKey(params, options) {
|
|
@@ -863,13 +863,13 @@ var NotificationsResource = class extends APIResource {
|
|
|
863
863
|
/**
|
|
864
864
|
* Send a notification
|
|
865
865
|
*
|
|
866
|
-
* Notifies up to 1,000 recipients with one notification type, across the type's channels (in-app inbox, email, push, web push), honouring each recipient's preferences. Returns 202 as soon as the send is stored; delivery happens in the background (see `GET /deliveries`). Unknown external ids do not fail the call: they are listed in `skipped` (`create_missing: true` creates them instead); the call fails only when no recipient can be notified. An `Idempotency-Key` is **required** (a deterministic one such as `invoice.paid:inv_123
|
|
866
|
+
* Notifies up to 1,000 recipients with one notification type, across the type's channels (in-app inbox, email, push, web push), honouring each recipient's preferences. Returns 202 as soon as the send is stored; delivery happens in the background (see `GET /deliveries`). Unknown external ids do not fail the call: they are listed in `skipped` (`create_missing: true` creates them instead); the call fails only when no recipient can be notified. An `Idempotency-Key` is **required** (a deterministic one built from your event, such as `invoice.paid:inv_123`, is best; dots are fine): the same key and body return the same notification, even when retried much later; the same key with a different body is a 409. `dry_run: true` returns the plan per recipient and channel with the reason for every skip, and stores nothing (200, no key needed). Limits: 3,000 recipients per minute per workspace; 30 notifications per minute per recipient (critical types have a separate 30), beyond which deliveries are skipped as `rate_limited`.
|
|
867
867
|
*
|
|
868
868
|
* Credential: `bearer`.
|
|
869
869
|
*
|
|
870
870
|
* @param params - `Notify.NotificationSendParams`.
|
|
871
871
|
* @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
|
|
872
|
-
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, IDEMPOTENCY_KEY_REQUIRED, TOO_MANY_RECIPIENTS: `IDEMPOTENCY_KEY_REQUIRED`: no `Idempotency-Key`; `TOO_MANY_RECIPIENTS`: over 1,000; `VALIDATION_ERROR`: a field is invalid.
|
|
872
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR, IDEMPOTENCY_KEY_REQUIRED, TOO_MANY_RECIPIENTS: `IDEMPOTENCY_KEY_REQUIRED`: no `Idempotency-Key`; `BAD_REQUEST`: the `Idempotency-Key` is over 256 characters or has a character outside `A-Z a-z 0-9 . _ : -` (the message names it); `TOO_MANY_RECIPIENTS`: over 1,000; `VALIDATION_ERROR`: a field is invalid (an invalid `cancellation_key` included).
|
|
873
873
|
* @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/…`).
|
|
874
874
|
* @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).
|
|
875
875
|
* @throws {NotFoundError} 404 NOT_FOUND, NOTIFICATION_TYPE_NOT_FOUND: `NOTIFICATION_TYPE_NOT_FOUND`: no type with this key.
|
|
@@ -2055,8 +2055,9 @@ var InboxItemStatusFilter = { values: ["active", "archived", "all"] };
|
|
|
2055
2055
|
var InboxMarkAction = { values: ["seen", "read", "unread", "archived", "unarchived"] };
|
|
2056
2056
|
var NotificationStatus = { values: ["scheduled", "accepted", "planned", "cancelled"] };
|
|
2057
2057
|
var NotifyChannel = { values: ["inbox", "email", "push", "webpush"] };
|
|
2058
|
-
var NotifyDeliveryReason = { values: ["suppressed_preference", "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", "actor_excluded", "recipient_not_found", "recipient_erased", "mail_suppressed", "mail_refused", "pruned", "payload_too_large", "credential_error", "circuit_open", "expired", "cancelled", "provider_error"] };
|
|
2058
|
+
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", "actor_excluded", "recipient_not_found", "recipient_erased", "mail_suppressed", "mail_refused", "pruned", "payload_too_large", "credential_error", "circuit_open", "expired", "cancelled", "provider_error"] };
|
|
2059
2059
|
var NotifyEmailPauseReason = { values: ["complaints", "bounces"] };
|
|
2060
|
+
var NotifyQuietHoursSource = { values: ["recipient", "workspace"] };
|
|
2060
2061
|
var NotifyRecipientDeletionCause = { values: ["api", "auth_user_deleted"] };
|
|
2061
2062
|
var NotifyStatsChannel = { values: ["inbox", "email", "push", "webpush"] };
|
|
2062
2063
|
var NotifyWebhookChannel = { values: ["inbox", "email", "push", "webpush"] };
|
|
@@ -2078,7 +2079,7 @@ var WebhookEventStatus = { values: ["pending", "delivered", "failed", "not_sent"
|
|
|
2078
2079
|
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"] };
|
|
2079
2080
|
|
|
2080
2081
|
// src/_generated/client.ts
|
|
2081
|
-
var VERSION = "0.
|
|
2082
|
+
var VERSION = "0.2.0" ;
|
|
2082
2083
|
exports.default = class Notify extends NotifyResources {
|
|
2083
2084
|
/** The options this client was built with, for the token scopes' own clients. Never enumerable. */
|
|
2084
2085
|
#options;
|
|
@@ -2133,6 +2134,7 @@ exports.default = class Notify extends NotifyResources {
|
|
|
2133
2134
|
Notify2.NotifyChannel = NotifyChannel;
|
|
2134
2135
|
Notify2.NotifyDeliveryReason = NotifyDeliveryReason;
|
|
2135
2136
|
Notify2.NotifyEmailPauseReason = NotifyEmailPauseReason;
|
|
2137
|
+
Notify2.NotifyQuietHoursSource = NotifyQuietHoursSource;
|
|
2136
2138
|
Notify2.NotifyRecipientDeletionCause = NotifyRecipientDeletionCause;
|
|
2137
2139
|
Notify2.NotifyStatsChannel = NotifyStatsChannel;
|
|
2138
2140
|
Notify2.NotifyWebhookChannel = NotifyWebhookChannel;
|