@relyio/sdk 0.2.0 → 0.3.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/CHANGELOG.md +40 -0
- package/README.md +5 -310
- package/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-7W4MJXQ4.cjs → chunk-54WP2PWG.cjs} +215 -96
- package/dist/chunk-BBUB7C2Z.js +81 -0
- package/dist/{chunk-FJK7ZWKK.cjs → chunk-HMVGXUGR.cjs} +156 -221
- package/dist/chunk-LSRPMNPT.cjs +89 -0
- package/dist/{chunk-2QUK2ZGD.js → chunk-LYRYCIX5.js} +157 -219
- package/dist/{chunk-RJBIJ2ZK.js → chunk-QIZOBT5F.js} +215 -96
- package/dist/client/index.cjs +4 -3
- package/dist/client/index.d.cts +4 -3
- package/dist/client/index.d.ts +4 -3
- package/dist/client/index.js +2 -1
- package/dist/define-content-type-CBfnTWSS.d.cts +716 -0
- package/dist/define-content-type-CBfnTWSS.d.ts +716 -0
- package/dist/{define-schema-DHvUCKwj.d.cts → define-schema-BD6HSPnG.d.ts} +55 -722
- package/dist/{define-schema-DHvUCKwj.d.ts → define-schema-BfXeR6K8.d.cts} +55 -722
- package/dist/dev-handshake/index.cjs +37 -0
- package/dist/dev-handshake/index.d.cts +144 -0
- package/dist/dev-handshake/index.d.ts +144 -0
- package/dist/dev-handshake/index.js +4 -0
- package/dist/{index-DGWaawHt.d.cts → index-BDpar3FO.d.cts} +22 -6
- package/dist/{index-BsUqCAu8.d.cts → index-DuEhsGdE.d.ts} +516 -2155
- package/dist/{index-B-KiFHbx.d.ts → index-Dx01iwaf.d.ts} +22 -6
- package/dist/{index-BsUqCAu8.d.ts → index-ulOrcfPa.d.cts} +516 -2155
- package/dist/index.cjs +67 -70
- package/dist/index.d.cts +28 -13
- package/dist/index.d.ts +28 -13
- package/dist/index.js +3 -2
- package/dist/schema/index.cjs +35 -47
- package/dist/schema/index.d.cts +3 -2
- package/dist/schema/index.d.ts +3 -2
- package/dist/schema/index.js +1 -1
- package/dist/types/index.d.cts +2 -1
- package/dist/types/index.d.ts +2 -1
- package/package.json +15 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @relyio/sdk
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a8ae363: **Breaking:** `schemaToJSON`, `viewToJSON` and `workflowToJSON` are removed from `@relyio/sdk` and `@relyio/sdk/schema`.
|
|
8
|
+
|
|
9
|
+
These converted a schema definition to JSON by stripping the internal `_tag` markers the `define*` helpers attach. Their docstrings described them as being "for the CLI", but the CLI never called them — it has always done the conversion itself, and the two implementations had drifted: the SDK's stripped a single level where the CLI's recurses. A nested content type, component or field kept its `_tag`, so anything built on these functions produced a payload `relyio deploy` would not have produced.
|
|
10
|
+
|
|
11
|
+
**If you were calling one of them:** you almost certainly do not need a replacement. `relyio deploy` and `relyio diff` read your schema module and perform the conversion themselves, so passing them a `defineSchema(...)` value is all that is required — as it was before.
|
|
12
|
+
|
|
13
|
+
If you need the JSON for something else, such as committing a snapshot or sending it to your own tooling, strip `_tag` **recursively**:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
function stripTags(value: unknown): unknown {
|
|
17
|
+
if (Array.isArray(value)) return value.map(stripTags)
|
|
18
|
+
if (value && typeof value === 'object') {
|
|
19
|
+
return Object.fromEntries(
|
|
20
|
+
Object.entries(value)
|
|
21
|
+
.filter(([key]) => key !== '_tag')
|
|
22
|
+
.map(([key, entry]) => [key, stripTags(entry)]),
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
return value
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
That mirrors what the CLI does, so its output matches the payload `relyio deploy` sends. Note that it is a plain recursive walk: values that are not JSON to begin with, such as a `Date`, become `{}` — as they do on the deploy path today.
|
|
30
|
+
|
|
31
|
+
Everything you author with is unchanged. `defineSchema`, `defineContentType`, `defineSingleton`, `defineComponent`, `defineSettingsGroup`, `defineQuery`, `defineAssetType`, `defineLocale`, `defineRole`, `defineWorkflow` and `defineView` keep their signatures and their inferred types, and each now has a fixture asserted against the same validator the platform applies at deploy — so an authoring shape the platform would reject fails when we build the SDK rather than when you run `relyio deploy`.
|
|
32
|
+
|
|
33
|
+
## 0.2.1
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- 5b58217: Republish so the npm page carries the pre-launch notice.
|
|
38
|
+
|
|
39
|
+
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.
|
|
40
|
+
|
|
41
|
+
No source change in any of the four — the whole content of this release is the README and the `description` and `keywords` fields.
|
|
42
|
+
|
|
3
43
|
## 0.2.0
|
|
4
44
|
|
|
5
45
|
### 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.
|