@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/README.md +50 -7
- package/dist/index.d.ts +144 -121
- package/dist/index.js +138 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/skills/spoke-hub-client/SKILL.md +2 -0
- package/skills/spoke-hub-client/references/workflows.md +22 -4
package/README.md
CHANGED
|
@@ -23,6 +23,21 @@ The generated client takes a single request object. Depending on the endpoint, t
|
|
|
23
23
|
- `urlParams`: Query-string parameters.
|
|
24
24
|
- `headers`: Per-call headers. Most callers should set auth at client creation time instead.
|
|
25
25
|
|
|
26
|
+
Promise client request methods return a result tuple:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
const [data, error] = await client.members.list({ organizationId: "org_123" });
|
|
30
|
+
|
|
31
|
+
if (error !== null) {
|
|
32
|
+
console.error(error.kind, error.code, error.message);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
console.log(data.items);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`error` is `null` on success. API failures include `kind: "api"`, `code`, and the response `body`; local signing, credential format, network, and unexpected failures are returned as structured client errors instead of thrown Effect fiber failures.
|
|
40
|
+
|
|
26
41
|
## Recommended Usage
|
|
27
42
|
|
|
28
43
|
```ts
|
|
@@ -34,23 +49,35 @@ const { client } = await makePromiseSpokeClient({
|
|
|
34
49
|
privateKey: process.env.SPOKE_PRIVATE_KEY!,
|
|
35
50
|
});
|
|
36
51
|
|
|
37
|
-
const members = await client.members.list({
|
|
52
|
+
const [members, membersError] = await client.members.list({
|
|
38
53
|
organizationId: "org_123",
|
|
39
54
|
responseMode: "med",
|
|
40
55
|
page: 1,
|
|
41
56
|
pageSize: 25,
|
|
42
57
|
});
|
|
43
58
|
|
|
44
|
-
|
|
59
|
+
if (membersError !== null) {
|
|
60
|
+
throw membersError;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const [member, memberError] = await client.members.get({
|
|
45
64
|
organizationId: "org_123",
|
|
46
65
|
memberId: "mem_123",
|
|
47
66
|
responseMode: "full",
|
|
48
67
|
});
|
|
49
68
|
|
|
50
|
-
|
|
69
|
+
if (memberError !== null) {
|
|
70
|
+
throw memberError;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const [guests, guestsError] = await client.guests.list({
|
|
51
74
|
organizationId: "org_123",
|
|
52
75
|
name: "Jane",
|
|
53
76
|
});
|
|
77
|
+
|
|
78
|
+
if (guestsError !== null) {
|
|
79
|
+
throw guestsError;
|
|
80
|
+
}
|
|
54
81
|
```
|
|
55
82
|
|
|
56
83
|
## Live Onsite Resource Calls
|
|
@@ -66,18 +93,22 @@ const { client } = await makePromiseOnsiteResourceClient({
|
|
|
66
93
|
privateKey: process.env.SPOKE_PRIVATE_KEY!,
|
|
67
94
|
});
|
|
68
95
|
|
|
69
|
-
const lookup = await client.members.lookup({
|
|
96
|
+
const [lookup, lookupError] = await client.members.lookup({
|
|
70
97
|
organizationId: "org_123",
|
|
71
98
|
lookupBy: "member_id",
|
|
72
99
|
lookupValue: "12345",
|
|
73
100
|
waitMs: 10_000,
|
|
74
101
|
});
|
|
75
102
|
|
|
103
|
+
if (lookupError !== null) {
|
|
104
|
+
throw lookupError;
|
|
105
|
+
}
|
|
106
|
+
|
|
76
107
|
if (lookup.settled && lookup.command.status === "completed") {
|
|
77
108
|
console.log(lookup.command.result);
|
|
78
109
|
}
|
|
79
110
|
|
|
80
|
-
const voucher = await client.vouchers.issue({
|
|
111
|
+
const [voucher, voucherError] = await client.vouchers.issue({
|
|
81
112
|
organizationId: "org_123",
|
|
82
113
|
waitMs: 10_000,
|
|
83
114
|
payload: {
|
|
@@ -86,6 +117,10 @@ const voucher = await client.vouchers.issue({
|
|
|
86
117
|
quantity: 1,
|
|
87
118
|
},
|
|
88
119
|
});
|
|
120
|
+
|
|
121
|
+
if (voucherError !== null) {
|
|
122
|
+
throw voucherError;
|
|
123
|
+
}
|
|
89
124
|
```
|
|
90
125
|
|
|
91
126
|
The full Spoke client exposes the same live onsite wrapper under `client.onsite`:
|
|
@@ -93,12 +128,16 @@ The full Spoke client exposes the same live onsite wrapper under `client.onsite`
|
|
|
93
128
|
```ts
|
|
94
129
|
const { client } = await makePromiseSpokeClient(options);
|
|
95
130
|
|
|
96
|
-
const lookup = await client.onsite.members.lookup({
|
|
131
|
+
const [lookup, lookupError] = await client.onsite.members.lookup({
|
|
97
132
|
organizationId: "org_123",
|
|
98
133
|
lookupBy: "member_id",
|
|
99
134
|
lookupValue: "12345",
|
|
100
135
|
waitMs: 10_000,
|
|
101
136
|
});
|
|
137
|
+
|
|
138
|
+
if (lookupError !== null) {
|
|
139
|
+
throw lookupError;
|
|
140
|
+
}
|
|
102
141
|
```
|
|
103
142
|
|
|
104
143
|
## Service Client Authentication
|
|
@@ -112,9 +151,13 @@ const { client } = await makePromiseServiceHubApiClient({
|
|
|
112
151
|
privateKey: process.env.SPOKE_PRIVATE_KEY!,
|
|
113
152
|
});
|
|
114
153
|
|
|
115
|
-
const organizations = await client.organizations.listOrganizations({
|
|
154
|
+
const [organizations, organizationsError] = await client.organizations.listOrganizations({
|
|
116
155
|
urlParams: { page: "1", pageSize: "25", name: "Spoke" },
|
|
117
156
|
});
|
|
157
|
+
|
|
158
|
+
if (organizationsError !== null) {
|
|
159
|
+
throw organizationsError;
|
|
160
|
+
}
|
|
118
161
|
```
|
|
119
162
|
|
|
120
163
|
`baseUrl` should usually be the site origin. The client appends `/api` by default, so requests target `/api/v1/...`. Override `apiBasePath` if your deployment exposes the API somewhere else.
|