@spoketech/hub-client 0.1.5 → 0.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spoketech/hub-client",
3
- "version": "0.1.5",
3
+ "version": "0.1.8",
4
4
  "description": "Effect-native client for the Spoke Hub API",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  }
24
24
  },
25
25
  "publishConfig": {
26
- "access": "public"
26
+ "access": "restricted"
27
27
  },
28
28
  "scripts": {
29
29
  "build": "tsup",
@@ -24,10 +24,12 @@ Use this skill for application code that consumes `@spoketech/hub-client`. Prefe
24
24
  `urlParams` for query-string fields.
25
25
  `headers` only for unusual per-request overrides.
26
26
  6. Reuse the exported contract types instead of inventing inline request shapes.
27
+ 7. Promise request methods return `[data, error]`; branch on `if (error !== null)` before using `data`.
27
28
 
28
29
  ## Guidance
29
30
 
30
31
  - Prefer the promise wrappers in examples unless the user explicitly wants Effect.
32
+ - Handle errors from promise clients as returned values. API errors have `kind: "api"`, `code`, `message`, and `body`; other failures use structured client errors.
31
33
  - Keep `baseUrl` at the site origin; the client adds `/api` and targets `/api/v1/...` by default.
32
34
  - Do not invent endpoint names. Use the exact group and method names from the README endpoint tables.
33
35
  - For member list queries, keep query params in the contract format. Some filters are strings even when they represent page numbers or IDs.
@@ -19,6 +19,8 @@ const { client } = await makePromiseServiceHubApiClient({
19
19
  });
20
20
  ```
21
21
 
22
+ Promise request methods return `[data, error]`. Check `error !== null` before using `data`.
23
+
22
24
  ## Request Shapes
23
25
 
24
26
  - Use `path` for route params:
@@ -33,16 +35,20 @@ const { client } = await makePromiseServiceHubApiClient({
33
35
  - List members:
34
36
 
35
37
  ```ts
36
- const members = await client.members.listOrganizationMembers({
38
+ const [members, error] = await client.members.listOrganizationMembers({
37
39
  path: { organizationId: "org_123" },
38
40
  urlParams: { responseMode: "med", page: "1", pageSize: "25" },
39
41
  });
42
+
43
+ if (error !== null) {
44
+ throw error;
45
+ }
40
46
  ```
41
47
 
42
48
  - Create a member:
43
49
 
44
50
  ```ts
45
- const member = await client.members.createOrganizationMember({
51
+ const [member, error] = await client.members.createOrganizationMember({
46
52
  path: { organizationId: "org_123" },
47
53
  payload: {
48
54
  firstName: "Jane",
@@ -50,24 +56,36 @@ const member = await client.members.createOrganizationMember({
50
56
  email: "jane@example.com",
51
57
  },
52
58
  });
59
+
60
+ if (error !== null) {
61
+ throw error;
62
+ }
53
63
  ```
54
64
 
55
65
  - Trigger a sync:
56
66
 
57
67
  ```ts
58
- const run = await client.memberSources.triggerOrganizationMemberSync({
68
+ const [run, error] = await client.memberSources.triggerOrganizationMemberSync({
59
69
  path: { organizationId: "org_123" },
60
70
  payload: { mode: "delta" },
61
71
  });
72
+
73
+ if (error !== null) {
74
+ throw error;
75
+ }
62
76
  ```
63
77
 
64
78
  - Archive a guest:
65
79
 
66
80
  ```ts
67
- await client.guests.deleteGuest({
81
+ const [, error] = await client.guests.deleteGuest({
68
82
  path: { organizationId: "org_123", guestId: "gst_123" },
69
83
  payload: { expectedUpdatedAt: guest.updatedAt },
70
84
  });
85
+
86
+ if (error !== null) {
87
+ throw error;
88
+ }
71
89
  ```
72
90
 
73
91
  ## Find the Right Endpoint