@relyio/sdk 0.2.0 โ 0.2.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/CHANGELOG.md +10 -0
- package/README.md +5 -310
- package/package.json +5 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @relyio/sdk
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5b58217: Republish so the npm page carries the pre-launch notice.
|
|
8
|
+
|
|
9
|
+
npm serves whatever was inside the published tarball, so replacing the README and the package description in the repository changed nothing for anyone looking at the live pages. Only a new version can carry them.
|
|
10
|
+
|
|
11
|
+
No source change in any of the four โ the whole content of this release is the README and the `description` and `keywords` fields.
|
|
12
|
+
|
|
3
13
|
## 0.2.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,314 +1,9 @@
|
|
|
1
1
|
# @relyio/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**RelyIO is coming soon.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This package is on npm so its name is reserved and the release pipeline stays exercised end to
|
|
6
|
+
end. It is not ready for general use yet, and its documentation is deliberately not published
|
|
7
|
+
here.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
npm install @relyio/sdk
|
|
9
|
-
# or
|
|
10
|
-
pnpm add @relyio/sdk
|
|
11
|
-
# or
|
|
12
|
-
yarn add @relyio/sdk
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
import { createClient, defineSchema, defineContentType, fields } from '@relyio/sdk'
|
|
17
|
-
|
|
18
|
-
// Define your schema (or import from generated file)
|
|
19
|
-
const product = defineContentType('product', {
|
|
20
|
-
displayName: 'Product',
|
|
21
|
-
fields: [
|
|
22
|
-
fields.shortText('title', { config: { required: true } }),
|
|
23
|
-
fields.currency('price', { config: { currencyCode: 'USD' } }),
|
|
24
|
-
fields.select('status', {
|
|
25
|
-
config: {
|
|
26
|
-
options: [
|
|
27
|
-
{ value: 'draft', label: 'Draft' },
|
|
28
|
-
{ value: 'active', label: 'Active' },
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
],
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const schema = defineSchema({ contentTypes: { product } })
|
|
36
|
-
|
|
37
|
-
// Create the client
|
|
38
|
-
const client = createClient({
|
|
39
|
-
apiKey: process.env.RELYIO_API_KEY!,
|
|
40
|
-
schema,
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
// Full autocomplete and type safety!
|
|
44
|
-
const products = await client
|
|
45
|
-
.content('product') // โ
'product' autocompletes
|
|
46
|
-
.query()
|
|
47
|
-
.where({ status: 'active' }) // โ
fields autocomplete
|
|
48
|
-
.limit(10)
|
|
49
|
-
.execute()
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## โจ Features
|
|
53
|
-
|
|
54
|
-
- **๐ 100% Type Safe**: Auto-generated types from your schema
|
|
55
|
-
- **โก High Performance**: Intelligent caching and request optimization
|
|
56
|
-
- **๐ Powerful Search**: Full-text, semantic, hybrid, and autocomplete
|
|
57
|
-
- **๐ฆ Batch Operations**: Execute multiple operations in one request
|
|
58
|
-
- **๐ฏ Developer Friendly**: Fluent APIs with excellent IntelliSense
|
|
59
|
-
- **๐ฆ Tree Shakeable**: Only bundle what you use
|
|
60
|
-
|
|
61
|
-
## ๐ Usage
|
|
62
|
-
|
|
63
|
-
### With Schema (Recommended)
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
import { createClient, defineSchema, defineContentType, fields } from '@relyio/sdk'
|
|
67
|
-
|
|
68
|
-
const product = defineContentType('product', {
|
|
69
|
-
displayName: 'Product',
|
|
70
|
-
fields: [fields.shortText('title'), fields.currency('price'), fields.tags('tags')],
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
const schema = defineSchema({ contentTypes: { product } })
|
|
74
|
-
|
|
75
|
-
const client = createClient({
|
|
76
|
-
apiKey: 'your-api-key',
|
|
77
|
-
schema, // Enables full type safety
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
// All methods have full autocomplete!
|
|
81
|
-
await client.content('product').create({
|
|
82
|
-
title: 'Amazing Widget',
|
|
83
|
-
price: 49.99,
|
|
84
|
-
tags: ['new', 'featured'],
|
|
85
|
-
})
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Without Schema (Dynamic)
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
import { createClient } from '@relyio/sdk'
|
|
92
|
-
|
|
93
|
-
const client = createClient({
|
|
94
|
-
apiKey: 'your-api-key',
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
// Works dynamically without type checking
|
|
98
|
-
const products = await client.content('product').query().where({ status: 'active' }).execute()
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
## ๐ API Reference
|
|
102
|
-
|
|
103
|
-
### Content Operations
|
|
104
|
-
|
|
105
|
-
```typescript
|
|
106
|
-
const products = client.content('product')
|
|
107
|
-
|
|
108
|
-
// Query with fluent API
|
|
109
|
-
const items = await products
|
|
110
|
-
.query()
|
|
111
|
-
.where({ status: 'active', price: { $gte: 50 } })
|
|
112
|
-
.sort('title', 'asc')
|
|
113
|
-
.limit(20)
|
|
114
|
-
.offset(0)
|
|
115
|
-
.execute()
|
|
116
|
-
|
|
117
|
-
// Get single item
|
|
118
|
-
const product = await products.fetchOne('product-id')
|
|
119
|
-
|
|
120
|
-
// Create
|
|
121
|
-
const newProduct = await products.create({
|
|
122
|
-
title: 'New Product',
|
|
123
|
-
price: 99.99,
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
// Update
|
|
127
|
-
const updated = await products.update('product-id', {
|
|
128
|
-
price: 79.99,
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
// Delete
|
|
132
|
-
await products.delete('product-id')
|
|
133
|
-
|
|
134
|
-
// Pagination: the entry list is the cursor dialect, so the body is
|
|
135
|
-
// `{ data, page: { nextCursor, hasMore } }` โ there is no total here.
|
|
136
|
-
const page = await products.query().page(1).pageSize(10).executeWithMeta()
|
|
137
|
-
|
|
138
|
-
console.log(page.data, page.page.hasMore, page.page.nextCursor)
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### Search
|
|
142
|
-
|
|
143
|
-
```typescript
|
|
144
|
-
// Full-text search
|
|
145
|
-
const results = await client
|
|
146
|
-
.search('wireless headphones')
|
|
147
|
-
.in('product')
|
|
148
|
-
.limit(10)
|
|
149
|
-
.includeScore()
|
|
150
|
-
.execute()
|
|
151
|
-
|
|
152
|
-
// Autocomplete suggestions
|
|
153
|
-
const suggestions = await client
|
|
154
|
-
.autocomplete('wire')
|
|
155
|
-
.in('product')
|
|
156
|
-
.field('title')
|
|
157
|
-
.fuzzy()
|
|
158
|
-
.limit(5)
|
|
159
|
-
.execute()
|
|
160
|
-
|
|
161
|
-
// Find similar items
|
|
162
|
-
const similar = await client.similar('product-id').in('product').locale('fr-FR').limit(5).execute()
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### Batch Operations
|
|
166
|
-
|
|
167
|
-
```typescript
|
|
168
|
-
// Execute multiple operations atomically
|
|
169
|
-
const result = await client
|
|
170
|
-
.batch()
|
|
171
|
-
.create('product', { content: { title: 'Product 1', price: 29.99 } })
|
|
172
|
-
.create('product', { content: { title: 'Product 2', price: 39.99 } })
|
|
173
|
-
.update('product', 'existing-id', { content: { price: 24.99 } })
|
|
174
|
-
.delete('product', 'old-id')
|
|
175
|
-
.execute({ atomic: true })
|
|
176
|
-
|
|
177
|
-
console.log(result.summary) // { total: 4, succeeded: 4, failed: 0 }
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### Singletons
|
|
181
|
-
|
|
182
|
-
```typescript
|
|
183
|
-
// Fetch singleton
|
|
184
|
-
const homepage = await client.singleton('homepage').fetch()
|
|
185
|
-
|
|
186
|
-
// Update singleton
|
|
187
|
-
await client.singleton('homepage').update({
|
|
188
|
-
heroTitle: 'Welcome',
|
|
189
|
-
heroSubtitle: 'Discover amazing products',
|
|
190
|
-
})
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Settings
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
// Fetch settings
|
|
197
|
-
const config = await client.settings('site-config').fetch()
|
|
198
|
-
|
|
199
|
-
// Update settings
|
|
200
|
-
await client.settings('site-config').update({
|
|
201
|
-
siteName: 'My Store',
|
|
202
|
-
timezone: 'UTC',
|
|
203
|
-
})
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### Ad-hoc Queries
|
|
207
|
-
|
|
208
|
-
```typescript
|
|
209
|
-
// Build dynamic queries
|
|
210
|
-
const result = await client
|
|
211
|
-
.adhoc()
|
|
212
|
-
.from('product')
|
|
213
|
-
.where({ status: 'active' })
|
|
214
|
-
.include(['brand', 'categories'])
|
|
215
|
-
.select({
|
|
216
|
-
id: '_metadata.id',
|
|
217
|
-
name: 'title',
|
|
218
|
-
cost: 'price',
|
|
219
|
-
})
|
|
220
|
-
.sort('title', 'asc')
|
|
221
|
-
.limit(20)
|
|
222
|
-
.execute()
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
## ๐ง Configuration
|
|
226
|
-
|
|
227
|
-
```typescript
|
|
228
|
-
const client = createClient({
|
|
229
|
-
apiKey: 'your-api-key',
|
|
230
|
-
|
|
231
|
-
// API endpoint (defaults to production)
|
|
232
|
-
baseUrl: 'https://api.relyio.com',
|
|
233
|
-
|
|
234
|
-
// Dataset/environment
|
|
235
|
-
dataset: 'production',
|
|
236
|
-
environment: 'production',
|
|
237
|
-
|
|
238
|
-
// Request settings
|
|
239
|
-
timeout: 30000,
|
|
240
|
-
retryAttempts: 3,
|
|
241
|
-
|
|
242
|
-
// Debug logging
|
|
243
|
-
debug: {
|
|
244
|
-
enabled: true,
|
|
245
|
-
logger: (level, message, data) => {
|
|
246
|
-
console.log(`[${level}] ${message}`, data)
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
|
|
250
|
-
// Schema for type safety (optional)
|
|
251
|
-
schema: mySchema,
|
|
252
|
-
})
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
## ๐ Error Handling
|
|
256
|
-
|
|
257
|
-
```typescript
|
|
258
|
-
import { RelyIONotFoundError, RelyIOValidationError } from '@relyio/sdk'
|
|
259
|
-
|
|
260
|
-
try {
|
|
261
|
-
await client.content('product').fetchOne('invalid-id')
|
|
262
|
-
} catch (error) {
|
|
263
|
-
if (error instanceof RelyIONotFoundError) {
|
|
264
|
-
console.log('Product not found')
|
|
265
|
-
} else if (error instanceof RelyIOValidationError) {
|
|
266
|
-
console.log('Validation errors:', error.validationErrors)
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
## ๐งช Testing
|
|
272
|
-
|
|
273
|
-
```typescript
|
|
274
|
-
// Create a client pointing to your test API
|
|
275
|
-
const testClient = createClient({
|
|
276
|
-
apiKey: 'test-api-key',
|
|
277
|
-
baseUrl: 'http://localhost:3200',
|
|
278
|
-
dataset: 'test',
|
|
279
|
-
})
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
## ๐ Performance
|
|
283
|
-
|
|
284
|
-
- **Bundle Size**: < 50KB gzipped
|
|
285
|
-
- **Tree Shaking**: Only bundle features you use
|
|
286
|
-
- **Request Deduplication**: Automatic deduplication of identical requests
|
|
287
|
-
- **Intelligent Caching**: Multi-level caching support
|
|
288
|
-
|
|
289
|
-
## ๐ TypeScript Support
|
|
290
|
-
|
|
291
|
-
The SDK is written in TypeScript and provides full type safety:
|
|
292
|
-
|
|
293
|
-
- Content type names autocomplete from your schema
|
|
294
|
-
- Field names autocomplete in where clauses
|
|
295
|
-
- Create/update data is type-checked against your schema
|
|
296
|
-
- Query results are fully typed
|
|
297
|
-
|
|
298
|
-
## ๐ค Contributing
|
|
299
|
-
|
|
300
|
-
We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details.
|
|
301
|
-
|
|
302
|
-
## ๐ License
|
|
303
|
-
|
|
304
|
-
MIT License - see [LICENSE](./LICENSE) file for details.
|
|
305
|
-
|
|
306
|
-
## ๐ Support
|
|
307
|
-
|
|
308
|
-
- ๐ง Email: [support@relyio.com](mailto:support@relyio.com)
|
|
309
|
-
- ๐ Documentation: [docs.relyio.com](https://docs.relyio.com)
|
|
310
|
-
- ๐ Issues: [GitHub Issues](https://github.com/relyio/relyio/issues)
|
|
311
|
-
|
|
312
|
-
---
|
|
313
|
-
|
|
314
|
-
Built with โค๏ธ by the RelyIO Team
|
|
9
|
+
There is nothing to follow yet โ watch [relyio.com](https://relyio.com) for the launch.
|
package/package.json
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relyio/sdk",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "RelyIO is coming soon โ this package is not ready for general use yet.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"relyio"
|
|
7
|
-
"cms",
|
|
8
|
-
"headless",
|
|
9
|
-
"typescript",
|
|
10
|
-
"sdk",
|
|
11
|
-
"content-management",
|
|
12
|
-
"api-client",
|
|
13
|
-
"real-time",
|
|
14
|
-
"offline-first"
|
|
6
|
+
"relyio"
|
|
15
7
|
],
|
|
16
8
|
"author": "RelyIO Team <team@relyio.com>",
|
|
17
9
|
"license": "Apache-2.0",
|
|
@@ -93,8 +85,8 @@
|
|
|
93
85
|
"typedoc": "^0.27.5",
|
|
94
86
|
"typescript": "5.9.3",
|
|
95
87
|
"vitest": "4.1.11",
|
|
96
|
-
"@relyio/
|
|
97
|
-
"@relyio/
|
|
88
|
+
"@relyio/api-contract": "0.1.0",
|
|
89
|
+
"@relyio/eslint-config": "0.0.0"
|
|
98
90
|
},
|
|
99
91
|
"peerDependencies": {
|
|
100
92
|
"typescript": ">=4.9.0",
|