@chirpie/sdk 1.0.7 → 1.0.9

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.d.mts CHANGED
@@ -96,7 +96,7 @@ interface ApiKeyInfo {
96
96
  key_prefix: string;
97
97
  last_used_at: string | null;
98
98
  created_at: string;
99
- revoked: boolean;
99
+ expires_at: string | null;
100
100
  }
101
101
  interface CreatePostInput {
102
102
  account_id: string;
@@ -183,6 +183,8 @@ declare class ChirpieClient {
183
183
  key: string;
184
184
  prefix: string;
185
185
  name: string;
186
+ expires_at: string;
187
+ message: string;
186
188
  }>;
187
189
  listKeys(): Promise<ApiKeyInfo[]>;
188
190
  revokeKey(id: string): Promise<{
package/dist/index.d.ts CHANGED
@@ -96,7 +96,7 @@ interface ApiKeyInfo {
96
96
  key_prefix: string;
97
97
  last_used_at: string | null;
98
98
  created_at: string;
99
- revoked: boolean;
99
+ expires_at: string | null;
100
100
  }
101
101
  interface CreatePostInput {
102
102
  account_id: string;
@@ -183,6 +183,8 @@ declare class ChirpieClient {
183
183
  key: string;
184
184
  prefix: string;
185
185
  name: string;
186
+ expires_at: string;
187
+ message: string;
186
188
  }>;
187
189
  listKeys(): Promise<ApiKeyInfo[]>;
188
190
  revokeKey(id: string): Promise<{
package/dist/index.js CHANGED
@@ -65,12 +65,24 @@ var ChirpieClient = class {
65
65
  Authorization: `Bearer ${this.apiKey}`,
66
66
  "Content-Type": "application/json"
67
67
  };
68
- const res = await fetch(url, {
69
- method,
70
- headers,
71
- body: body ? JSON.stringify(body) : void 0
72
- });
73
- const json = await res.json();
68
+ let res;
69
+ try {
70
+ res = await fetch(url, {
71
+ method,
72
+ headers,
73
+ body: body ? JSON.stringify(body) : void 0
74
+ });
75
+ } catch (err) {
76
+ throw new ChirpieError(
77
+ err instanceof Error ? `Network error: ${err.message}` : "Network error"
78
+ );
79
+ }
80
+ let json;
81
+ try {
82
+ json = await res.json();
83
+ } catch {
84
+ throw new ChirpieApiError("parse_error", "Invalid response from server", res.status);
85
+ }
74
86
  if (!res.ok) {
75
87
  const err = json.error ?? { code: "unknown", message: "Request failed" };
76
88
  throw new ChirpieApiError(err.code, err.message, res.status);
package/dist/index.mjs CHANGED
@@ -33,12 +33,24 @@ var ChirpieClient = class {
33
33
  Authorization: `Bearer ${this.apiKey}`,
34
34
  "Content-Type": "application/json"
35
35
  };
36
- const res = await fetch(url, {
37
- method,
38
- headers,
39
- body: body ? JSON.stringify(body) : void 0
40
- });
41
- const json = await res.json();
36
+ let res;
37
+ try {
38
+ res = await fetch(url, {
39
+ method,
40
+ headers,
41
+ body: body ? JSON.stringify(body) : void 0
42
+ });
43
+ } catch (err) {
44
+ throw new ChirpieError(
45
+ err instanceof Error ? `Network error: ${err.message}` : "Network error"
46
+ );
47
+ }
48
+ let json;
49
+ try {
50
+ json = await res.json();
51
+ } catch {
52
+ throw new ChirpieApiError("parse_error", "Invalid response from server", res.status);
53
+ }
42
54
  if (!res.ok) {
43
55
  const err = json.error ?? { code: "unknown", message: "Request failed" };
44
56
  throw new ChirpieApiError(err.code, err.message, res.status);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chirpie/sdk",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Chirpie SDK — TypeScript client for the Chirpie social media API",
5
5
  "repository": {
6
6
  "type": "git",