@ax-hub/sdk 1.0.1 → 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 +12 -11
- package/dist/cli/doctor.cjs +2 -1
- package/dist/cli/doctor.js +2 -1
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +278 -71
- package/dist/index.d.ts +278 -71
- package/dist/index.js +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -104,8 +104,8 @@ Prefer scoped clients in examples:
|
|
|
104
104
|
|
|
105
105
|
```ts
|
|
106
106
|
const acme = sdk.tenant('acme')
|
|
107
|
-
await acme.apps.create({ slug: 'crm', name: 'CRM' })
|
|
108
|
-
await
|
|
107
|
+
const app = await acme.apps.create({ slug: 'crm', name: 'CRM' })
|
|
108
|
+
await sdk.apps.tables.inspect(app.id, 'orders')
|
|
109
109
|
await acme.app('crm').data.table('orders').list()
|
|
110
110
|
```
|
|
111
111
|
|
|
@@ -207,24 +207,25 @@ const minimal = await ordersProjection.list({ select: ['id', 'total'] as const }
|
|
|
207
207
|
minimal.items[0].total // number
|
|
208
208
|
```
|
|
209
209
|
|
|
210
|
-
###
|
|
210
|
+
### Offset pagination
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
Backend-main data routes are offset/page based. Use `pageSize` with the numeric string `cursor` returned by the previous page. `after`, `before`, `direction`, and `v1:`/`v2:` keyset tokens are rejected with `LegacyCursorError` because the backend does not support keyset cursors.
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
`total` is optional: use `items` and `nextCursor` for iteration, or call `count()` when you need a backend count for the same pushable `where` filter.
|
|
215
215
|
|
|
216
216
|
```ts
|
|
217
217
|
const OrdersCursor = defineSchema({ table: 'orders', columns: { id: 'uuid' } })
|
|
218
218
|
const ordersCursor = sdk.tenant('acme').app('crm').data.table(OrdersCursor)
|
|
219
|
-
const first = await ordersCursor.list({
|
|
220
|
-
const next =
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
const first = await ordersCursor.list({ pageSize: 50 })
|
|
220
|
+
const next = first.nextCursor
|
|
221
|
+
? await ordersCursor.list({ cursor: first.nextCursor, pageSize: 50 })
|
|
222
|
+
: null
|
|
223
|
+
void next
|
|
223
224
|
```
|
|
224
225
|
|
|
225
226
|
### Mock mode
|
|
226
227
|
|
|
227
|
-
Use mock mode for backend-free unit tests, examples, and agent CI. Fixtures are isolated per client and still exercise where/projection/
|
|
228
|
+
Use mock mode for backend-free unit tests, examples, and agent CI. Fixtures are isolated per client and still exercise where/projection/offset pagination/Zod behavior. Keep fixture sets small enough for in-memory tests (recommended ≤10K rows per process); use the real backend for load/perf scenarios.
|
|
228
229
|
|
|
229
230
|
```ts
|
|
230
231
|
const sdk = new AxHubClient({
|
|
@@ -372,7 +373,7 @@ Target was < 10ms p99 — 100x+ headroom in every path.
|
|
|
372
373
|
|
|
373
374
|
## Backend dependency
|
|
374
375
|
|
|
375
|
-
Pinned against backend `main` (
|
|
376
|
+
Pinned against backend `main` (189 routes, 43 error codes). Re-generate types via `npm run generate` + `npm run extract-codes` after backend swagger updates.
|
|
376
377
|
|
|
377
378
|
## License
|
|
378
379
|
|
package/dist/cli/doctor.cjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var fs=require('fs'),path=require('path');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function t(e=process.cwd()){let r=[{name:"package.json",ok:fs.existsSync(path.resolve(e,"package.json"))},{name:"codegen/swagger.json",ok:fs.existsSync(path.resolve(e,"codegen/swagger.json"))},{name:"packages/sdk/src/index.ts",ok:fs.existsSync(path.resolve(e,"packages/sdk/src/index.ts"))}];return {ok:r.every(n=>n.ok),checks:r}}if((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('doctor.cjs', document.baseURI).href))===`file://${process.argv[1]}`){let e=t();process.stdout.write(`${JSON.stringify(e,null,2)}
|
|
3
|
+
`),process.exit(e.ok?0:1);}exports.runDoctor=t;
|
package/dist/cli/doctor.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import {existsSync}from'fs';import {resolve}from'path';function t(e=process.cwd()){let r=[{name:"package.json",ok:existsSync(resolve(e,"package.json"))},{name:"codegen/swagger.json",ok:existsSync(resolve(e,"codegen/swagger.json"))},{name:"packages/sdk/src/index.ts",ok:existsSync(resolve(e,"packages/sdk/src/index.ts"))}];return {ok:r.every(n=>n.ok),checks:r}}if(import.meta.url===`file://${process.argv[1]}`){let e=t();process.stdout.write(`${JSON.stringify(e,null,2)}
|
|
3
|
+
`),process.exit(e.ok?0:1);}export{t as runDoctor};
|