@shuffl/sdk 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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +23 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shuffl LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Shuffl TypeScript SDK
|
|
2
|
+
|
|
3
|
+
Use the Shuffl workspace API from Node.js 22+, Bun, or an agent runtime.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @shuffl/sdk
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The package is ESM-only and ships its own types. It installs `@shuffl/api-contracts`, which carries the input and output types for every method. The SDK, [CLI](https://www.npmjs.com/package/@shuffl/cli) and contracts are released together under one version.
|
|
10
|
+
|
|
11
|
+
Create an API key in **Settings → API keys**. The key is bound to one workspace and the issuing user's current permissions, and expires within 30 days. There is one kind of API key: the same key works for the SDK, CLI, HTTP API and, when it carries the `mcp.knowledge` permission, the MCP server.
|
|
12
|
+
|
|
13
|
+
Choose exact endpoint permissions such as `users.list` and `units.save`, grouped by resource and Read/Write. Discover them with `shuffl.permissions.list()`. A write grant does not imply reads or sibling operations. See [endpoint permissions and delegation](https://shuffl-rebuild.vercel.app/docs/api-permissions).
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createShuffl } from '@shuffl/sdk';
|
|
17
|
+
|
|
18
|
+
const shuffl = createShuffl({
|
|
19
|
+
baseUrl: process.env.SHUFFL_BASE_URL!, // Application origin, without /api/v1/rpc
|
|
20
|
+
token: process.env.SHUFFL_TOKEN!,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const page = await shuffl.users.list({ limit: 25 });
|
|
24
|
+
const next = page.nextCursor
|
|
25
|
+
? await shuffl.users.list({ cursor: page.nextCursor, limit: 25 })
|
|
26
|
+
: null;
|
|
27
|
+
|
|
28
|
+
const preview = await shuffl.programs.preview({
|
|
29
|
+
id: 'program-id',
|
|
30
|
+
seed: 'mentoring-preview-2026-09',
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`users` means people in the workspace directory, including people who have no web login. IDs are Shuffl person IDs, not Slack IDs or authentication account IDs.
|
|
35
|
+
|
|
36
|
+
The client includes people, teams, access, identity links, programs, runs, knowledge, invitations, provisioning, HR, support, billing, reports, exports, credentials and assistant conversations. See the [permission reference](https://shuffl-rebuild.vercel.app/docs/api-permissions) for every method. Input and output types come directly from the portable public oRPC contract.
|
|
37
|
+
|
|
38
|
+
Program creation requires a stable `requestKey`. Repeating the same creation request returns the existing program; using that key with different settings returns `CONFLICT`. Programs start paused unless `draft: false` is explicitly supplied. Updates require `expectedRevision`. Run requests require a preview and request key and return a durable run ID; poll `runs.get` for status. The application scheduler owns execution and delivery.
|
|
39
|
+
|
|
40
|
+
Dates in the public API are ISO strings. Directory lists use an opaque cursor and a limit of 1–100; other methods retain their documented pagination shapes. The SDK does not automatically retry writes. Supply a token getter if credentials rotate:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
createShuffl({ baseUrl, token: async () => credentialStore.read() });
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Use `ORPCError.code` for errors (`UNAUTHORIZED`, `FORBIDDEN`, `BAD_REQUEST`, `NOT_FOUND`, `CONFLICT`, and others). Calls accept oRPC's second options argument, including an abort signal. HTTPS is required except on loopback; redirects are refused to avoid forwarding credentials to another origin. The public API currently allows same-origin browser calls and server/CLI clients; cross-origin browser CORS is not enabled.
|
|
47
|
+
|
|
48
|
+
## Management commands
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
const saved = await shuffl.units.save({
|
|
52
|
+
id: crypto.randomUUID(), kind: 'team', name: 'Mentors',
|
|
53
|
+
expectedRevision: 0, requestKey: 'create-mentors-2026-09',
|
|
54
|
+
});
|
|
55
|
+
const receipt = await shuffl.commands.get({ id: saved.receipt.id });
|
|
56
|
+
const teams = await shuffl.units.list({}); // Same persisted teams the web app reads.
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Management writes return `{receipt, result}`. A duplicate request returns the same receipt with `result: null`; it never replays an action or a private result. Reusing a key with changed input fails. Read the resource after replay and reconcile an `unknown` receipt before issuing a new command. Sensitive actions require `confirm` equal to the method name (for example `knowledge.sources.publish`). Initial program/run methods retain the shapes described above.
|
|
60
|
+
|
|
61
|
+
Credentials with `credentials:write` can delegate only their own scopes, with bounded expiry and inherited revocation. Account sign-in, switching to another workspace, provider consent and payment confirmation remain explicit browser/account flows.
|
|
62
|
+
|
|
63
|
+
Full guide: [Use the SDK and HTTP API](https://shuffl-rebuild.vercel.app/docs/sdk).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ContractRouterClient } from '@orpc/contract';
|
|
2
|
+
import type { ShufflContract } from '@shuffl/api-contracts';
|
|
3
|
+
export { ORPCError } from '@orpc/client';
|
|
4
|
+
export type { Permission, PermissionDefinition, Scope, } from '@shuffl/api-contracts';
|
|
5
|
+
export type ShufflClient = ContractRouterClient<ShufflContract>;
|
|
6
|
+
export interface ShufflOptions {
|
|
7
|
+
token: string | (() => string | Promise<string>);
|
|
8
|
+
/** Shuffl application origin, without /api/v1/rpc. */
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
fetch?: typeof globalThis.fetch;
|
|
11
|
+
}
|
|
12
|
+
export declare function createShuffl(options: ShufflOptions): ShufflClient;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createORPCClient } from '@orpc/client';
|
|
2
|
+
import { RPCLink } from '@orpc/client/fetch';
|
|
3
|
+
export { ORPCError } from '@orpc/client';
|
|
4
|
+
export function createShuffl(options) {
|
|
5
|
+
const base = new URL(options.baseUrl);
|
|
6
|
+
if (base.username ||
|
|
7
|
+
base.password ||
|
|
8
|
+
(base.protocol !== 'https:' &&
|
|
9
|
+
!(base.protocol === 'http:' &&
|
|
10
|
+
['localhost', '127.0.0.1', '[::1]'].includes(base.hostname))))
|
|
11
|
+
throw new Error('Use HTTPS, or HTTP on localhost for development.');
|
|
12
|
+
return createORPCClient(new RPCLink({
|
|
13
|
+
// Writes are not automatically retried. Callers own stable request keys.
|
|
14
|
+
fetch: async (request, init) => (options.fetch ?? globalThis.fetch)(request, {
|
|
15
|
+
...init,
|
|
16
|
+
redirect: 'error',
|
|
17
|
+
}),
|
|
18
|
+
headers: async () => ({
|
|
19
|
+
authorization: `Bearer ${typeof options.token === 'function' ? await options.token() : options.token}`,
|
|
20
|
+
}),
|
|
21
|
+
url: new URL('/api/v1/rpc', base).toString(),
|
|
22
|
+
}));
|
|
23
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@orpc/client": "1.15.3",
|
|
4
|
+
"@orpc/contract": "1.15.3",
|
|
5
|
+
"@shuffl/api-contracts": "0.1.0"
|
|
6
|
+
},
|
|
7
|
+
"description": "TypeScript client for the Shuffl API: people, teams, knowledge, programs and management commands.",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"homepage": "https://shuffl-rebuild.vercel.app/docs/sdk",
|
|
23
|
+
"keywords": [
|
|
24
|
+
"shuffl",
|
|
25
|
+
"sdk",
|
|
26
|
+
"hr",
|
|
27
|
+
"api-client"
|
|
28
|
+
],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"name": "@shuffl/sdk",
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"type": "module",
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"version": "0.1.0"
|
|
38
|
+
}
|