@spoketech/hub-client 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.
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@spoketech/hub-client",
3
+ "version": "0.1.0",
4
+ "description": "Effect-native client for the Spoke Hub API",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Spoke-Technologies/spoke-hub.git",
8
+ "directory": "packages/client"
9
+ },
10
+ "type": "module",
11
+ "sideEffects": false,
12
+ "files": [
13
+ "dist",
14
+ "README.md",
15
+ "skills"
16
+ ],
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ }
22
+ },
23
+ "types": "./dist/index.d.ts",
24
+ "main": "./dist/index.js",
25
+ "scripts": {
26
+ "build": "tsup",
27
+ "prepack": "npm run build",
28
+ "check-types": "tsc --noEmit"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "dependencies": {
34
+ "@effect/platform": "^0.96.0",
35
+ "effect": "^3.21.0"
36
+ },
37
+ "devDependencies": {
38
+ "@spoke-hub/config": "workspace:*",
39
+ "@types/node": "^22.13.14",
40
+ "tsup": "^8.5.1",
41
+ "typescript": "^5"
42
+ }
43
+ }
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: spoke-hub-client
3
+ description: Use when Codex needs to integrate with, explain, troubleshoot, or update code that uses the `@spoketech/hub-client` npm package, including promise-based usage, Effect-based usage, service-client authentication, endpoint selection, request object shapes, or mapping business actions to client methods.
4
+ ---
5
+
6
+ # Spoke Hub Client
7
+
8
+ ## Overview
9
+
10
+ Use this skill for application code that consumes `@spoketech/hub-client`. Prefer the promise-based client for normal async code and use the raw Effect client only when the surrounding code already uses Effect.
11
+
12
+ ## Workflow
13
+
14
+ 1. Read `../../README.md` for the current install instructions, auth patterns, and full endpoint reference.
15
+ 2. If you need the exact helper signatures, inspect `../../dist/client.d.ts`.
16
+ 3. If you need the exact contract or type names, inspect `../../dist/contracts.d.ts`.
17
+ 4. Match the user to the right entrypoint:
18
+ `makePromiseHubApiClient` for unsigned or separately-authenticated access.
19
+ `makePromiseServiceHubApiClient` for `clientId` plus `privateKey`.
20
+ `makeHubApiClient` or `makeServiceHubApiClient` only when the caller is already Effect-native.
21
+ 5. Build calls with the standard request object shape:
22
+ `path` for route params.
23
+ `payload` for JSON bodies.
24
+ `urlParams` for query-string fields.
25
+ `headers` only for unusual per-request overrides.
26
+ 6. Reuse the exported contract types instead of inventing inline request shapes.
27
+
28
+ ## Guidance
29
+
30
+ - Prefer the promise wrappers in examples unless the user explicitly wants Effect.
31
+ - Keep `baseUrl` at the site origin; the client adds `/api` and targets `/api/v1/...` by default.
32
+ - Do not invent endpoint names. Use the exact group and method names from the README endpoint tables.
33
+ - For member list queries, keep query params in the contract format. Some filters are strings even when they represent page numbers or IDs.
34
+ - For delete/archive operations, remember the API expects `DeletePayload` with `expectedUpdatedAt`.
35
+
36
+ ## References
37
+
38
+ - Load `../../README.md` for the full endpoint-by-endpoint client reference.
39
+ - Load `references/workflows.md` for common usage patterns and code templates.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Spoke Hub Client"
3
+ short_description: "Guide Spoke Hub client usage and workflows"
4
+ default_prompt: "Use $spoke-hub-client to integrate with @spoketech/hub-client in this workspace."
@@ -0,0 +1,83 @@
1
+ # Spoke Hub Client Workflows
2
+
3
+ ## Choose the Right Client
4
+
5
+ - Use `makePromiseHubApiClient` when the caller is handling auth outside the package.
6
+ - Use `makePromiseServiceHubApiClient` when the caller has `clientId` and `privateKey`.
7
+ - Use `makePromiseServiceHubApiClient` for server-to-server integrations that should sign every request automatically.
8
+ - Use `makeHubApiClient` or `makeServiceHubApiClient` only when the surrounding application already uses Effect.
9
+
10
+ ## Common Template
11
+
12
+ ```ts
13
+ import { makePromiseHubApiClient } from "@spoketech/hub-client";
14
+
15
+ const { client } = await makePromiseServiceHubApiClient({
16
+ baseUrl: "https://hub.example.com",
17
+ clientId: process.env.SPOKE_CLIENT_ID!,
18
+ privateKey: process.env.SPOKE_PRIVATE_KEY!,
19
+ });
20
+ ```
21
+
22
+ ## Request Shapes
23
+
24
+ - Use `path` for route params:
25
+ `path: { organizationId: "org_123", memberId: "mem_123" }`
26
+ - Use `payload` for bodies:
27
+ `payload: { firstName: "Jane", lastName: "Smith" }`
28
+ - Use `urlParams` for query strings:
29
+ `urlParams: { responseMode: "med", page: "1", pageSize: "25" }`
30
+
31
+ ## Common Tasks
32
+
33
+ - List members:
34
+
35
+ ```ts
36
+ const members = await client.members.listOrganizationMembers({
37
+ path: { organizationId: "org_123" },
38
+ urlParams: { responseMode: "med", page: "1", pageSize: "25" },
39
+ });
40
+ ```
41
+
42
+ - Create a member:
43
+
44
+ ```ts
45
+ const member = await client.members.createOrganizationMember({
46
+ path: { organizationId: "org_123" },
47
+ payload: {
48
+ firstName: "Jane",
49
+ lastName: "Smith",
50
+ email: "jane@example.com",
51
+ },
52
+ });
53
+ ```
54
+
55
+ - Trigger a sync:
56
+
57
+ ```ts
58
+ const run = await client.memberSources.triggerOrganizationMemberSync({
59
+ path: { organizationId: "org_123" },
60
+ payload: { mode: "delta" },
61
+ });
62
+ ```
63
+
64
+ - Archive a guest:
65
+
66
+ ```ts
67
+ await client.guests.deleteGuest({
68
+ path: { organizationId: "org_123", guestId: "gst_123" },
69
+ payload: { expectedUpdatedAt: guest.updatedAt },
70
+ });
71
+ ```
72
+
73
+ ## Find the Right Endpoint
74
+
75
+ Read `../../README.md` and use the Endpoint Reference sections:
76
+
77
+ - `Auth`
78
+ - `Organizations`
79
+ - `Members`
80
+ - `Member Sources`
81
+ - `Onsite Agents`
82
+ - `Guests`
83
+ - `Service Clients`