@unisource/sdk 0.2.0 → 0.3.1
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 +55 -23
- package/dist/index.d.mts +623 -21
- package/dist/index.mjs +438 -38
- package/package.json +8 -4
- package/src/client.ts +474 -233
- package/src/fileRecords.ts +99 -87
- package/src/folders.ts +97 -84
- package/src/index.ts +198 -106
- package/src/mainStorage.ts +51 -0
- package/src/primitives.ts +30 -25
- package/src/releases.ts +132 -0
- package/src/services.ts +137 -69
- package/src/shareLinks.ts +93 -0
- package/src/uploads.ts +99 -90
- package/dist/index.d.ts +0 -478
- package/src/uploadDestination.ts +0 -4
package/README.md
CHANGED
|
@@ -1,23 +1,55 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
# @unisource/sdk
|
|
2
|
+
|
|
3
|
+
Shared UniSource contracts and HTTP client used by both `apps/backend` and `apps/frontend`.
|
|
4
|
+
|
|
5
|
+
## What is included
|
|
6
|
+
|
|
7
|
+
- Zod schemas and TypeScript types for uploads, files, folders, services, audit log, and share links
|
|
8
|
+
- `UnisourceClient` for authenticated app and admin API calls
|
|
9
|
+
- Standalone public share helpers: `getPublicFileInfo()` and `unlockPublicFile()`
|
|
10
|
+
- Typed error classes: `UnisourceError` and `UnisourceNetworkError`
|
|
11
|
+
|
|
12
|
+
## Development
|
|
13
|
+
|
|
14
|
+
From the monorepo root:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm install
|
|
18
|
+
pnpm --filter @unisource/sdk build
|
|
19
|
+
pnpm --filter @unisource/sdk test
|
|
20
|
+
pnpm --filter @unisource/sdk typecheck
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { UnisourceClient } from '@unisource/sdk';
|
|
27
|
+
|
|
28
|
+
const client = new UnisourceClient({
|
|
29
|
+
baseUrl: 'https://api.example.com',
|
|
30
|
+
serviceId: 'usrc',
|
|
31
|
+
getToken: async () => 'jwt-or-api-key',
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const files = await client.myFiles.list({ folder_id: null, limit: 25 });
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Public share flows do not require service headers:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { getPublicFileInfo, unlockPublicFile } from '@unisource/sdk';
|
|
41
|
+
|
|
42
|
+
const info = await getPublicFileInfo('https://api.example.com', 'share-slug');
|
|
43
|
+
const unlocked = await unlockPublicFile('https://api.example.com', 'share-slug', 'secret');
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Release workflow
|
|
47
|
+
|
|
48
|
+
Because `@unisource/sdk` is public, changes should ship with a changeset:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pnpm changeset
|
|
52
|
+
pnpm changeset version
|
|
53
|
+
pnpm --filter @unisource/sdk build
|
|
54
|
+
pnpm changeset publish
|
|
55
|
+
```
|