@stagware/nocodb-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/README.md +95 -0
- package/dist/index.d.ts +2118 -0
- package/dist/index.js +1640 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# @stagware/nocodb-sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the NocoDB v2 API — typed clients for metadata, data, and admin operations.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @stagware/nocodb-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { NocoClient, MetaApi } from '@stagware/nocodb-sdk';
|
|
15
|
+
|
|
16
|
+
const client = new NocoClient({
|
|
17
|
+
baseUrl: 'https://app.nocodb.com',
|
|
18
|
+
headers: { 'xc-token': 'your-api-token' },
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const meta = new MetaApi(client);
|
|
22
|
+
|
|
23
|
+
// List all bases
|
|
24
|
+
const bases = await meta.listBases();
|
|
25
|
+
console.log(bases.list);
|
|
26
|
+
|
|
27
|
+
// Create a table
|
|
28
|
+
const table = await meta.createTable('base_id', {
|
|
29
|
+
title: 'Users',
|
|
30
|
+
table_name: 'users',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// CRUD on records
|
|
34
|
+
const rows = await client.request('GET', '/api/v2/tables/tbl_id/records');
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
- **50+ typed API methods** — bases, tables, views, columns, filters, sorts, hooks, sources, tokens, users, comments, shared views/base, visibility rules, duplicates, app info, cloud workspaces
|
|
40
|
+
- **Auto-pagination** — `fetchAllPages()` fetches all pages of any paginated endpoint
|
|
41
|
+
- **Typed errors** — `AuthenticationError`, `NotFoundError`, `ValidationError`, `ConflictError`, `NetworkError`
|
|
42
|
+
- **Retry & timeout** — configurable via `RetryOptions` and `timeoutMs`
|
|
43
|
+
- **Tree-shakeable** — ESM-only, all types exported
|
|
44
|
+
|
|
45
|
+
## API Classes
|
|
46
|
+
|
|
47
|
+
### `NocoClient`
|
|
48
|
+
|
|
49
|
+
Low-level HTTP client with error mapping, retry, and timeout.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const client = new NocoClient({
|
|
53
|
+
baseUrl: 'https://app.nocodb.com',
|
|
54
|
+
headers: { 'xc-token': 'token' },
|
|
55
|
+
timeoutMs: 30000,
|
|
56
|
+
retry: { retry: 3, retryDelay: 1000, retryStatusCodes: [429, 500, 502, 503] },
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const result = await client.request<MyType>('GET', '/api/v2/meta/bases');
|
|
60
|
+
const allRows = await client.fetchAllPages<Row>('GET', '/api/v2/tables/tbl_id/records');
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### `MetaApi`
|
|
64
|
+
|
|
65
|
+
Typed methods for all metadata CRUD operations.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const meta = new MetaApi(client);
|
|
69
|
+
|
|
70
|
+
await meta.listBases();
|
|
71
|
+
await meta.createTable(baseId, { title: 'Tasks' });
|
|
72
|
+
await meta.listViews(tableId);
|
|
73
|
+
await meta.createViewFilter(viewId, { fk_column_id: 'col_id', comparison_op: 'eq', value: 'active' });
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### `DataApi`
|
|
77
|
+
|
|
78
|
+
Record and link operations.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
const data = new DataApi(client);
|
|
82
|
+
|
|
83
|
+
await data.listRecords(tableId);
|
|
84
|
+
await data.linkRecords(tableId, linkFieldId, recordId, [{ Id: 100 }]);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Types
|
|
88
|
+
|
|
89
|
+
All entity types are exported: `Base`, `Table`, `View`, `Column`, `Filter`, `Sort`, `Row`, `Hook`, `ApiToken`, `BaseUser`, `Comment`, `SharedView`, `SharedBase`, `ViewColumn`, `FormView`, `GalleryView`, `KanbanView`, `GridView`, `AppInfo`, `VisibilityRule`, `DuplicateOptions`, `NcWorkspace`, `NcWorkspaceUser`.
|
|
90
|
+
|
|
91
|
+
Response types: `ListResponse<T>`, `PageInfo`, `BulkCreateResponse`, `BulkUpdateResponse`, `BulkDeleteResponse`, `ErrorResponse`.
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MIT
|