@arke-institute/sdk 0.1.2 → 2.0.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 +126 -184
- package/dist/generated/index.cjs +19 -0
- package/dist/generated/index.cjs.map +1 -0
- package/dist/generated/index.d.cts +6192 -0
- package/dist/generated/index.d.ts +6192 -0
- package/dist/generated/index.js +1 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/index-BrXke2kI.d.ts +302 -0
- package/dist/index-FHcLPBSV.d.cts +302 -0
- package/dist/index.cjs +188 -3654
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -7
- package/dist/index.d.ts +62 -7
- package/dist/index.js +168 -3626
- package/dist/index.js.map +1 -1
- package/dist/operations/index.cjs +113 -0
- package/dist/operations/index.cjs.map +1 -0
- package/dist/operations/index.d.cts +3 -0
- package/dist/operations/index.d.ts +3 -0
- package/dist/operations/index.js +84 -0
- package/dist/operations/index.js.map +1 -0
- package/package.json +44 -53
- package/dist/client-dAk3E64p.d.cts +0 -183
- package/dist/client-dAk3E64p.d.ts +0 -183
- package/dist/collections/index.cjs +0 -233
- package/dist/collections/index.cjs.map +0 -1
- package/dist/collections/index.d.cts +0 -9
- package/dist/collections/index.d.ts +0 -9
- package/dist/collections/index.js +0 -205
- package/dist/collections/index.js.map +0 -1
- package/dist/content/index.cjs +0 -506
- package/dist/content/index.cjs.map +0 -1
- package/dist/content/index.d.cts +0 -403
- package/dist/content/index.d.ts +0 -403
- package/dist/content/index.js +0 -473
- package/dist/content/index.js.map +0 -1
- package/dist/edit/index.cjs +0 -1029
- package/dist/edit/index.cjs.map +0 -1
- package/dist/edit/index.d.cts +0 -78
- package/dist/edit/index.d.ts +0 -78
- package/dist/edit/index.js +0 -983
- package/dist/edit/index.js.map +0 -1
- package/dist/errors-3L7IiHcr.d.cts +0 -480
- package/dist/errors-B82BMmRP.d.cts +0 -343
- package/dist/errors-B82BMmRP.d.ts +0 -343
- package/dist/errors-BTe8GKRQ.d.ts +0 -480
- package/dist/graph/index.cjs +0 -433
- package/dist/graph/index.cjs.map +0 -1
- package/dist/graph/index.d.cts +0 -456
- package/dist/graph/index.d.ts +0 -456
- package/dist/graph/index.js +0 -402
- package/dist/graph/index.js.map +0 -1
- package/dist/query/index.cjs +0 -289
- package/dist/query/index.cjs.map +0 -1
- package/dist/query/index.d.cts +0 -541
- package/dist/query/index.d.ts +0 -541
- package/dist/query/index.js +0 -261
- package/dist/query/index.js.map +0 -1
- package/dist/upload/index.cjs +0 -1634
- package/dist/upload/index.cjs.map +0 -1
- package/dist/upload/index.d.cts +0 -150
- package/dist/upload/index.d.ts +0 -150
- package/dist/upload/index.js +0 -1597
- package/dist/upload/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,258 +1,200 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @arke-institute/sdk
|
|
2
2
|
|
|
3
|
-
TypeScript SDK for
|
|
3
|
+
TypeScript SDK for the Arke API - auto-generated from OpenAPI spec.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @arke/sdk
|
|
8
|
+
npm install @arke-institute/sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import {
|
|
14
|
+
import { ArkeClient } from '@arke-institute/sdk';
|
|
15
15
|
|
|
16
|
-
const arke =
|
|
16
|
+
const arke = new ArkeClient({
|
|
17
17
|
authToken: 'your-jwt-token',
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
// Create
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// Upload files to create a new collection
|
|
27
|
-
const result = await arke.upload.createCollection({
|
|
28
|
-
files: './photos',
|
|
29
|
-
collectionMetadata: {
|
|
30
|
-
title: 'Photo Archive',
|
|
31
|
-
slug: 'photos',
|
|
20
|
+
// Create an entity
|
|
21
|
+
const { data, error } = await arke.api.POST('/entities', {
|
|
22
|
+
body: {
|
|
23
|
+
collection_id: '01ABC...',
|
|
24
|
+
type: 'document',
|
|
25
|
+
properties: { title: 'My Document' },
|
|
32
26
|
},
|
|
33
27
|
});
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
);
|
|
29
|
+
if (error) {
|
|
30
|
+
console.error('Failed:', error);
|
|
31
|
+
} else {
|
|
32
|
+
console.log('Created:', data.id);
|
|
33
|
+
}
|
|
39
34
|
```
|
|
40
35
|
|
|
41
|
-
##
|
|
36
|
+
## Configuration
|
|
42
37
|
|
|
43
|
-
|
|
38
|
+
```typescript
|
|
39
|
+
const arke = new ArkeClient({
|
|
40
|
+
// Base URL (default: 'https://arke-v1.arke.institute')
|
|
41
|
+
baseUrl: 'https://arke-v1.arke.institute',
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
| **collections** | Create/manage collections, members, invitations | Yes |
|
|
48
|
-
| **upload** | Upload files, create/add to collections | Yes |
|
|
49
|
-
| **edit** | Edit entities, trigger AI regeneration | Yes |
|
|
50
|
-
| **query** | Search and traverse the knowledge graph | No (public) |
|
|
51
|
-
| **content** | Read entities, download content | No (public) |
|
|
43
|
+
// JWT or API key
|
|
44
|
+
authToken: 'your-token',
|
|
52
45
|
|
|
53
|
-
|
|
46
|
+
// Network: 'main' or 'test' (default: 'main')
|
|
47
|
+
network: 'test',
|
|
54
48
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
│ │
|
|
61
|
-
upload edit
|
|
62
|
-
|
|
63
|
-
query (independent)
|
|
64
|
-
content (independent)
|
|
49
|
+
// Custom headers
|
|
50
|
+
headers: {
|
|
51
|
+
'X-Custom-Header': 'value',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
65
54
|
```
|
|
66
55
|
|
|
67
|
-
##
|
|
56
|
+
## API Access
|
|
68
57
|
|
|
69
|
-
|
|
58
|
+
All API calls are made through the `arke.api` property, which provides full type safety:
|
|
70
59
|
|
|
71
60
|
```typescript
|
|
72
|
-
//
|
|
73
|
-
await arke.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const collections = await arke.collections.list({ page: 1 });
|
|
77
|
-
|
|
78
|
-
// Manage members
|
|
79
|
-
await arke.members.updateRole(collectionId, userId, 'editor');
|
|
80
|
-
|
|
81
|
-
// Invitations
|
|
82
|
-
await arke.invitations.create(collectionId, { email, role: 'editor' });
|
|
83
|
-
await arke.invitations.accept(invitationId);
|
|
84
|
-
```
|
|
61
|
+
// GET request
|
|
62
|
+
const { data } = await arke.api.GET('/entities/{id}', {
|
|
63
|
+
params: { path: { id: '01XYZ...' } },
|
|
64
|
+
});
|
|
85
65
|
|
|
86
|
-
|
|
66
|
+
// POST request
|
|
67
|
+
const { data } = await arke.api.POST('/entities', {
|
|
68
|
+
body: { collection_id: '...', type: 'document', properties: {} },
|
|
69
|
+
});
|
|
87
70
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
collectionMetadata: { title: 'My Archive', slug: 'my-archive' },
|
|
71
|
+
// PUT request (update)
|
|
72
|
+
const { data } = await arke.api.PUT('/entities/{id}', {
|
|
73
|
+
params: { path: { id: '01XYZ...' } },
|
|
74
|
+
body: { expect_tip: 'bafyrei...', properties_merge: { status: 'active' } },
|
|
93
75
|
});
|
|
94
76
|
|
|
95
|
-
//
|
|
96
|
-
await arke.
|
|
97
|
-
|
|
98
|
-
parentPi: 'pi:existing-root',
|
|
77
|
+
// DELETE request
|
|
78
|
+
await arke.api.DELETE('/relationships', {
|
|
79
|
+
body: { source_id: '...', target_id: '...', predicate: 'contains' },
|
|
99
80
|
});
|
|
100
81
|
```
|
|
101
82
|
|
|
102
|
-
|
|
83
|
+
## Available Endpoints
|
|
103
84
|
|
|
104
|
-
|
|
105
|
-
// Edit entity
|
|
106
|
-
const session = await arke.edit.createSession('pi:abc123');
|
|
107
|
-
session.setPrompt('Update the description');
|
|
108
|
-
const result = await session.submit();
|
|
85
|
+
The SDK provides typed access to all Arke API endpoints:
|
|
109
86
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
87
|
+
| Endpoint Group | Description |
|
|
88
|
+
|----------------|-------------|
|
|
89
|
+
| `/auth/*` | Authentication and registration |
|
|
90
|
+
| `/users/*` | User profile and API keys |
|
|
91
|
+
| `/collections/*` | Collection CRUD, roles, members |
|
|
92
|
+
| `/entities/*` | Entity CRUD |
|
|
93
|
+
| `/relationships` | Relationship management |
|
|
94
|
+
| `/files/*` | File storage and downloads |
|
|
95
|
+
| `/folders/*` | Folder hierarchy |
|
|
96
|
+
| `/versions/*` | Version history |
|
|
97
|
+
| `/agents/*` | Agent management |
|
|
98
|
+
| `/permissions/*` | Permission introspection |
|
|
113
99
|
|
|
114
|
-
|
|
100
|
+
## Error Handling
|
|
115
101
|
|
|
116
102
|
```typescript
|
|
117
|
-
|
|
118
|
-
|
|
103
|
+
import {
|
|
104
|
+
ArkeError,
|
|
105
|
+
CASConflictError,
|
|
106
|
+
NotFoundError,
|
|
107
|
+
parseApiError
|
|
108
|
+
} from '@arke-institute/sdk';
|
|
109
|
+
|
|
110
|
+
const { data, error, response } = await arke.api.GET('/entities/{id}', {
|
|
111
|
+
params: { path: { id: 'invalid-id' } },
|
|
112
|
+
});
|
|
119
113
|
|
|
120
|
-
|
|
121
|
-
|
|
114
|
+
if (error) {
|
|
115
|
+
// Parse into typed error
|
|
116
|
+
const arkeError = parseApiError(response.status, error);
|
|
122
117
|
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
if (arkeError instanceof CASConflictError) {
|
|
119
|
+
console.log('Concurrent modification - expected:', arkeError.expectedTip);
|
|
120
|
+
} else if (arkeError instanceof NotFoundError) {
|
|
121
|
+
console.log('Entity not found');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
125
124
|
```
|
|
126
125
|
|
|
127
|
-
|
|
126
|
+
## Authentication Management
|
|
128
127
|
|
|
129
128
|
```typescript
|
|
130
|
-
|
|
131
|
-
const entity = await arke.content.get('pi:abc123');
|
|
129
|
+
const arke = new ArkeClient();
|
|
132
130
|
|
|
133
|
-
//
|
|
134
|
-
|
|
131
|
+
// Set token after login
|
|
132
|
+
arke.setAuthToken('new-token');
|
|
135
133
|
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
// Check auth status
|
|
135
|
+
if (arke.isAuthenticated) {
|
|
136
|
+
// Make authenticated requests
|
|
137
|
+
}
|
|
139
138
|
|
|
140
|
-
|
|
139
|
+
// Clear token on logout
|
|
140
|
+
arke.clearAuthToken();
|
|
141
|
+
```
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
- [collections package](./packages/collections/PLAN.md)
|
|
144
|
-
- [upload package](./packages/upload/PLAN.md)
|
|
145
|
-
- [edit package](./packages/edit/PLAN.md)
|
|
146
|
-
- [query package](./packages/query/PLAN.md)
|
|
147
|
-
- [content package](./packages/content/PLAN.md)
|
|
143
|
+
## Test Network
|
|
148
144
|
|
|
149
|
-
|
|
145
|
+
Use the test network for development (uses 'II' prefixed IDs):
|
|
150
146
|
|
|
151
|
-
```
|
|
152
|
-
arke
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
│ └── types.ts # Shared types
|
|
157
|
-
├── packages/
|
|
158
|
-
│ ├── collections/
|
|
159
|
-
│ │ ├── index.ts # Package entry
|
|
160
|
-
│ │ ├── collections.ts # Collection CRUD
|
|
161
|
-
│ │ ├── members.ts # Membership operations
|
|
162
|
-
│ │ ├── invitations.ts # Invitation operations
|
|
163
|
-
│ │ └── types.ts
|
|
164
|
-
│ ├── upload/
|
|
165
|
-
│ │ ├── index.ts
|
|
166
|
-
│ │ ├── uploader.ts # Main uploader class
|
|
167
|
-
│ │ ├── create-collection.ts
|
|
168
|
-
│ │ ├── add-to-collection.ts
|
|
169
|
-
│ │ └── types.ts
|
|
170
|
-
│ ├── edit/
|
|
171
|
-
│ │ ├── index.ts
|
|
172
|
-
│ │ ├── session.ts # Edit session
|
|
173
|
-
│ │ ├── diff.ts # Diff engine
|
|
174
|
-
│ │ └── types.ts
|
|
175
|
-
│ ├── query/
|
|
176
|
-
│ │ ├── index.ts
|
|
177
|
-
│ │ ├── path-query.ts # Direct path queries
|
|
178
|
-
│ │ ├── natural-query.ts # NL queries
|
|
179
|
-
│ │ ├── collection-search.ts
|
|
180
|
-
│ │ └── types.ts
|
|
181
|
-
│ └── content/
|
|
182
|
-
│ ├── index.ts
|
|
183
|
-
│ ├── entities.ts # Entity operations
|
|
184
|
-
│ ├── download.ts # Content download
|
|
185
|
-
│ └── types.ts
|
|
186
|
-
├── package.json
|
|
187
|
-
├── tsconfig.json
|
|
188
|
-
└── README.md
|
|
147
|
+
```typescript
|
|
148
|
+
const arke = new ArkeClient({
|
|
149
|
+
authToken: 'your-token',
|
|
150
|
+
network: 'test',
|
|
151
|
+
});
|
|
189
152
|
```
|
|
190
153
|
|
|
191
|
-
##
|
|
154
|
+
## Development
|
|
192
155
|
|
|
193
|
-
|
|
156
|
+
### Regenerate Types
|
|
194
157
|
|
|
195
|
-
|
|
158
|
+
When the API changes, regenerate the types:
|
|
196
159
|
|
|
197
160
|
```bash
|
|
198
|
-
|
|
161
|
+
# From production API
|
|
162
|
+
npm run generate
|
|
163
|
+
|
|
164
|
+
# From local dev server
|
|
165
|
+
npm run generate:local
|
|
199
166
|
```
|
|
200
167
|
|
|
201
|
-
###
|
|
168
|
+
### Build
|
|
202
169
|
|
|
203
170
|
```bash
|
|
204
|
-
npm
|
|
205
|
-
npm publish
|
|
171
|
+
npm run build
|
|
206
172
|
```
|
|
207
173
|
|
|
208
|
-
###
|
|
209
|
-
|
|
210
|
-
Users can import the full SDK or specific packages:
|
|
174
|
+
### Test
|
|
211
175
|
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
import { createClient } from '@arke/sdk';
|
|
215
|
-
const arke = createClient({ authToken });
|
|
216
|
-
arke.collections.create(...);
|
|
217
|
-
|
|
218
|
-
// Specific packages (tree-shakeable)
|
|
219
|
-
import { CollectionsClient } from '@arke/sdk/collections';
|
|
220
|
-
import { UploadClient } from '@arke/sdk/upload';
|
|
176
|
+
```bash
|
|
177
|
+
npm test
|
|
221
178
|
```
|
|
222
179
|
|
|
223
|
-
|
|
180
|
+
### Publish
|
|
224
181
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
3. **Collections Worker** (new) - Manages collections in Supabase
|
|
229
|
-
|
|
230
|
-
### SDK (This Repo)
|
|
231
|
-
4. collections package
|
|
232
|
-
5. content package
|
|
233
|
-
6. upload package (refactor existing)
|
|
234
|
-
7. edit package (refactor existing)
|
|
235
|
-
8. query package
|
|
182
|
+
```bash
|
|
183
|
+
# Dry run
|
|
184
|
+
npm run publish-all:dry
|
|
236
185
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
186
|
+
# Actual publish
|
|
187
|
+
npm run publish-all
|
|
188
|
+
```
|
|
240
189
|
|
|
241
|
-
##
|
|
190
|
+
## Future Operations (TODO)
|
|
242
191
|
|
|
243
|
-
The SDK
|
|
192
|
+
The SDK includes placeholder modules for high-level operations:
|
|
244
193
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
| `/ingest/*` | Ingest Worker |
|
|
249
|
-
| `/api/*` | IPFS Wrapper |
|
|
250
|
-
| `/reprocess/*` | Reprocess API |
|
|
251
|
-
| `/query/*` | Query Links |
|
|
252
|
-
| `/translate/*` | Query Translator |
|
|
194
|
+
- **FolderOperations**: Recursive directory upload
|
|
195
|
+
- **BatchOperations**: Bulk entity/relationship creation
|
|
196
|
+
- **CryptoOperations**: Ed25519 key generation, CID computation
|
|
253
197
|
|
|
254
|
-
##
|
|
198
|
+
## License
|
|
255
199
|
|
|
256
|
-
|
|
257
|
-
- **Arke CLI** (`arke-cli/`) - Command-line interface using this SDK
|
|
258
|
-
- **Arke Gateway** (`arke-gateway/`) - API gateway routing
|
|
200
|
+
MIT
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/generated/index.ts
|
|
17
|
+
var generated_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(generated_exports);
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/generated/index.ts"],"sourcesContent":["/**\n * Auto-generated types from OpenAPI spec\n *\n * Run `npm run generate` to regenerate these types from the API spec.\n */\n\nexport type { paths, components, operations } from './types.js';\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|