@atribu/node 0.1.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE +21 -0
  3. package/README.md +423 -0
  4. package/dist/admin/index.cjs +326 -0
  5. package/dist/admin/index.cjs.map +1 -0
  6. package/dist/admin/index.d.cts +46 -0
  7. package/dist/admin/index.d.ts +46 -0
  8. package/dist/admin/index.js +323 -0
  9. package/dist/admin/index.js.map +1 -0
  10. package/dist/api.d-BXINTQo6.d.cts +3547 -0
  11. package/dist/api.d-BXINTQo6.d.ts +3547 -0
  12. package/dist/errors-D3ApBz8J.d.cts +86 -0
  13. package/dist/errors-D3ApBz8J.d.ts +86 -0
  14. package/dist/index.cjs +549 -0
  15. package/dist/index.cjs.map +1 -0
  16. package/dist/index.d.cts +198 -0
  17. package/dist/index.d.ts +198 -0
  18. package/dist/index.js +536 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/next/index.cjs +153 -0
  21. package/dist/next/index.cjs.map +1 -0
  22. package/dist/next/index.d.cts +43 -0
  23. package/dist/next/index.d.ts +43 -0
  24. package/dist/next/index.js +151 -0
  25. package/dist/next/index.js.map +1 -0
  26. package/dist/oauth/index.cjs +299 -0
  27. package/dist/oauth/index.cjs.map +1 -0
  28. package/dist/oauth/index.d.cts +117 -0
  29. package/dist/oauth/index.d.ts +117 -0
  30. package/dist/oauth/index.js +291 -0
  31. package/dist/oauth/index.js.map +1 -0
  32. package/dist/test/index.cjs +443 -0
  33. package/dist/test/index.cjs.map +1 -0
  34. package/dist/test/index.d.cts +321 -0
  35. package/dist/test/index.d.ts +321 -0
  36. package/dist/test/index.js +437 -0
  37. package/dist/test/index.js.map +1 -0
  38. package/dist/types-Dc6tIN_V.d.cts +101 -0
  39. package/dist/types-Dc6tIN_V.d.ts +101 -0
  40. package/dist/webhooks/index.cjs +97 -0
  41. package/dist/webhooks/index.cjs.map +1 -0
  42. package/dist/webhooks/index.d.cts +35 -0
  43. package/dist/webhooks/index.d.ts +35 -0
  44. package/dist/webhooks/index.js +94 -0
  45. package/dist/webhooks/index.js.map +1 -0
  46. package/package.json +101 -0
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Retry hints derived from HTTP status + headers.
3
+ *
4
+ * The SDK never retries automatically. It derives a hint and surfaces it on
5
+ * AtribuApiError.retry so consumers' queue systems can decide. Hiding retry
6
+ * logic in the SDK hides backpressure signals.
7
+ */
8
+ type RetryHint = {
9
+ action: "retry";
10
+ } | {
11
+ action: "retry_after";
12
+ retryAfterMs: number;
13
+ } | {
14
+ action: "refresh_token";
15
+ } | {
16
+ action: "fix_and_retry";
17
+ } | {
18
+ action: "do_not_retry";
19
+ };
20
+
21
+ /**
22
+ * Atribu error class hierarchy.
23
+ *
24
+ * Why typed errors: consumers need to branch on auth-failure vs rate-limit vs
25
+ * server-error vs validation-error to decide whether to retry, refresh
26
+ * credentials, or surface to the user. A single `Error` with a status code
27
+ * forces every consumer to write the same `if (err.status === 401)` ladder.
28
+ *
29
+ * Why no automatic retries: the SDK derives a `retry` hint from status +
30
+ * Retry-After + error code, but consumers' queue/job systems decide whether
31
+ * to act on it. Auto-retry inside the SDK hides backpressure signals and
32
+ * makes error budgets opaque.
33
+ */
34
+
35
+ type ApiErrorCode = "unauthorized" | "forbidden" | "insufficient_scope" | "not_found" | "invalid_parameter" | "invalid_request" | "validation_error" | "invalid_content" | "invalid_date_range" | "rate_limit_exceeded" | "connection_not_ready" | "provider_error" | "service_unavailable" | "internal_error" | string;
36
+ declare class AtribuError extends Error {
37
+ constructor(message: string);
38
+ }
39
+ declare class AtribuConfigError extends AtribuError {
40
+ }
41
+ declare class AtribuTransportError extends AtribuError {
42
+ readonly cause: unknown;
43
+ constructor(message: string, cause: unknown);
44
+ }
45
+ interface ApiErrorBody {
46
+ code: ApiErrorCode;
47
+ message: string;
48
+ status: number;
49
+ request_id?: string;
50
+ }
51
+ declare class AtribuApiError extends AtribuError {
52
+ readonly code: ApiErrorCode;
53
+ readonly status: number;
54
+ readonly requestId: string | null;
55
+ readonly retry: RetryHint;
56
+ readonly responseBody: unknown;
57
+ constructor(args: {
58
+ code: ApiErrorCode;
59
+ message: string;
60
+ status: number;
61
+ requestId: string | null;
62
+ retry: RetryHint;
63
+ responseBody: unknown;
64
+ });
65
+ isRetryable(): boolean;
66
+ isAuthFailure(): boolean;
67
+ isRateLimit(): boolean;
68
+ }
69
+ type OauthErrorCode = "invalid_request" | "invalid_client" | "invalid_grant" | "unauthorized_client" | "unsupported_grant_type" | "invalid_scope" | "server_error" | "unsupported_token_type" | string;
70
+ declare class AtribuOauthError extends AtribuError {
71
+ readonly code: OauthErrorCode;
72
+ readonly status: number;
73
+ readonly description: string | null;
74
+ constructor(args: {
75
+ code: OauthErrorCode;
76
+ description: string | null;
77
+ status: number;
78
+ });
79
+ }
80
+ type WebhookErrorCode = "missing_signature" | "malformed_header" | "expired_timestamp" | "invalid_signature";
81
+ declare class AtribuWebhookError extends AtribuError {
82
+ readonly code: WebhookErrorCode;
83
+ constructor(code: WebhookErrorCode, message: string);
84
+ }
85
+
86
+ export { AtribuError as A, type OauthErrorCode as O, type RetryHint as R, type WebhookErrorCode as W, type ApiErrorBody as a, type ApiErrorCode as b, AtribuApiError as c, AtribuConfigError as d, AtribuOauthError as e, AtribuTransportError as f, AtribuWebhookError as g };
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Retry hints derived from HTTP status + headers.
3
+ *
4
+ * The SDK never retries automatically. It derives a hint and surfaces it on
5
+ * AtribuApiError.retry so consumers' queue systems can decide. Hiding retry
6
+ * logic in the SDK hides backpressure signals.
7
+ */
8
+ type RetryHint = {
9
+ action: "retry";
10
+ } | {
11
+ action: "retry_after";
12
+ retryAfterMs: number;
13
+ } | {
14
+ action: "refresh_token";
15
+ } | {
16
+ action: "fix_and_retry";
17
+ } | {
18
+ action: "do_not_retry";
19
+ };
20
+
21
+ /**
22
+ * Atribu error class hierarchy.
23
+ *
24
+ * Why typed errors: consumers need to branch on auth-failure vs rate-limit vs
25
+ * server-error vs validation-error to decide whether to retry, refresh
26
+ * credentials, or surface to the user. A single `Error` with a status code
27
+ * forces every consumer to write the same `if (err.status === 401)` ladder.
28
+ *
29
+ * Why no automatic retries: the SDK derives a `retry` hint from status +
30
+ * Retry-After + error code, but consumers' queue/job systems decide whether
31
+ * to act on it. Auto-retry inside the SDK hides backpressure signals and
32
+ * makes error budgets opaque.
33
+ */
34
+
35
+ type ApiErrorCode = "unauthorized" | "forbidden" | "insufficient_scope" | "not_found" | "invalid_parameter" | "invalid_request" | "validation_error" | "invalid_content" | "invalid_date_range" | "rate_limit_exceeded" | "connection_not_ready" | "provider_error" | "service_unavailable" | "internal_error" | string;
36
+ declare class AtribuError extends Error {
37
+ constructor(message: string);
38
+ }
39
+ declare class AtribuConfigError extends AtribuError {
40
+ }
41
+ declare class AtribuTransportError extends AtribuError {
42
+ readonly cause: unknown;
43
+ constructor(message: string, cause: unknown);
44
+ }
45
+ interface ApiErrorBody {
46
+ code: ApiErrorCode;
47
+ message: string;
48
+ status: number;
49
+ request_id?: string;
50
+ }
51
+ declare class AtribuApiError extends AtribuError {
52
+ readonly code: ApiErrorCode;
53
+ readonly status: number;
54
+ readonly requestId: string | null;
55
+ readonly retry: RetryHint;
56
+ readonly responseBody: unknown;
57
+ constructor(args: {
58
+ code: ApiErrorCode;
59
+ message: string;
60
+ status: number;
61
+ requestId: string | null;
62
+ retry: RetryHint;
63
+ responseBody: unknown;
64
+ });
65
+ isRetryable(): boolean;
66
+ isAuthFailure(): boolean;
67
+ isRateLimit(): boolean;
68
+ }
69
+ type OauthErrorCode = "invalid_request" | "invalid_client" | "invalid_grant" | "unauthorized_client" | "unsupported_grant_type" | "invalid_scope" | "server_error" | "unsupported_token_type" | string;
70
+ declare class AtribuOauthError extends AtribuError {
71
+ readonly code: OauthErrorCode;
72
+ readonly status: number;
73
+ readonly description: string | null;
74
+ constructor(args: {
75
+ code: OauthErrorCode;
76
+ description: string | null;
77
+ status: number;
78
+ });
79
+ }
80
+ type WebhookErrorCode = "missing_signature" | "malformed_header" | "expired_timestamp" | "invalid_signature";
81
+ declare class AtribuWebhookError extends AtribuError {
82
+ readonly code: WebhookErrorCode;
83
+ constructor(code: WebhookErrorCode, message: string);
84
+ }
85
+
86
+ export { AtribuError as A, type OauthErrorCode as O, type RetryHint as R, type WebhookErrorCode as W, type ApiErrorBody as a, type ApiErrorCode as b, AtribuApiError as c, AtribuConfigError as d, AtribuOauthError as e, AtribuTransportError as f, AtribuWebhookError as g };