@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 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 acme.app('crm').tables.inspect('orders')
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
- ### Bidirectional cursor pagination
210
+ ### Offset pagination
211
211
 
212
- `list({ after, before, orderBy, limit })` supports v2 keyset cursor tokens, first-row cursors for "previous page", and order fingerprint validation. Numeric `cursor` remains as a legacy page alias for Phase-D callers.
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
- Cursor format: SDK-generated tokens use `v2:<base64-url>` and carry an order-fingerprint + table-scope binding. The SDK rejects `v1:` tokens with `LegacyCursorError`, malformed/oversized (> 4096 chars) tokens with `InvalidCursorError`, and a cursor minted on table A replayed against table B with `InvalidCursorError` (`code: cursor_context_mismatch`). When the SDK applies a `where` clause client-side, `PaginatedList.totalIsExact` is `false` and `total` reflects the backend's unfiltered total — iterate or wait for backend filter pushdown before relying on `total`.
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({ limit: 50, orderBy: [{ field: 'id', dir: 'asc' }] })
220
- const next = await ordersCursor.list({ after: first.nextCursor!, orderBy: [{ field: 'id', dir: 'asc' }] })
221
- const prev = await ordersCursor.list({ before: next.firstCursor!, orderBy: [{ field: 'id', dir: 'asc' }] })
222
- void prev
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/cursor/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
+ 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` (177 routes, 42 error codes). Re-generate types via `npm run generate` + `npm run extract-codes` after backend swagger updates.
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
 
@@ -1,2 +1,3 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';var j=f;(function(b,H){var G=f,D=b();while(!![]){try{var a=-parseInt(G(0x19a))/(-0x81d*-0x3+-0x1ce9+0x493)*(parseInt(G(0x18a))/(0x15d+0x28d+-0x3e8))+-parseInt(G(0x18b))/(0xd*0x6b+-0xf6+0x1*-0x476)*(-parseInt(G(0x19c))/(0xa73+0x1b5a+-0x25c9))+parseInt(G(0x194))/(0x7ba+-0x10f+-0x2e*0x25)*(parseInt(G(0x1b3))/(-0x2*-0xf51+0xbc1+0x5*-0x879))+parseInt(G(0x199))/(0x116e+-0x1dc1+-0x22*-0x5d)+parseInt(G(0x1af))/(-0x1*-0x19cf+-0x8f6+-0x10d1)*(-parseInt(G(0x1ae))/(0x10*-0x2+0x88d+-0xc*0xb3))+parseInt(G(0x1b0))/(0x1c8f+-0x18c*0x17+0x1*0x70f)*(-parseInt(G(0x1a9))/(0x1437+0xc*-0x263+0x878))+-parseInt(G(0x1b2))/(0x1356+-0x175d+0x7*0x95)*(-parseInt(G(0x1b5))/(0x3*-0xa3e+0x4*0x3da+0x313*0x5));if(a===H)break;else D['push'](D['shift']());}catch(l){D['push'](D['shift']());}}}(X,-0x98a9a+-0xf*0x8f5+0x1010bd));var fs=require('fs'),path=require(j(0x19f)),_documentCurrentScript=typeof document!==j(0x1a2)+'ined'?document[j(0x197)+j(0x1be)+j(0x195)]:null;function t(D=process[j(0x1a1)]()){var i=j,a={'rQPuy':i(0x1a5)+i(0x19d)+'+$','NICfl':function(p){return p();},'WnPLj':i(0x1b7)+i(0x1b6)+'on','XbpBD':i(0x1b7)+i(0x1aa)+i(0x189)+i(0x192)+i(0x191)},l=(function(){var p=!![];return function(N,Y){var Q=p?function(){var O=f;if(Y){var R=Y[O(0x188)](N,arguments);return Y=null,R;}}:function(){};return p=![],Q;};}()),g=l(this,function(){var x=i;return g[x(0x1bc)+'ing']()[x(0x186)+'h'](a['rQPuy'])['toStr'+'ing']()[x(0x18d)+x(0x1b9)+'r'](g)['searc'+'h'](a['rQPuy']);});a[i(0x187)](g);let u=[{'name':i(0x1b7)+i(0x1b6)+'on','ok':fs[i(0x1ba)+i(0x198)](path[i(0x1ad)+'ve'](D,a[i(0x1bd)]))},{'name':'codeg'+i(0x1a6)+i(0x190)+i(0x19e),'ok':fs['exist'+i(0x198)](path[i(0x1ad)+'ve'](D,i(0x1a7)+i(0x1a6)+i(0x190)+'.json'))},{'name':a['XbpBD'],'ok':fs['exist'+i(0x198)](path[i(0x1ad)+'ve'](D,a[i(0x1b8)]))}];return{'ok':u['every'](p=>p['ok']),'checks':u};}if((typeof document===j(0x1a2)+'ined'?require('u'+'rl')[j(0x1ab)+j(0x1a3)+j(0x1a8)](__filename)['href']:_documentCurrentScript&&_documentCurrentScript[j(0x193)+'me'][j(0x196)+'erCas'+'e']()===j(0x1b4)+'T'&&_documentCurrentScript[j(0x1a4)]||new URL(j(0x1a0)+'r.cjs',document['baseU'+'RI'])['href'])===j(0x18c)+'//'+process[j(0x1bf)][-0x3d6*0x2+0x1d85+-0x15d8]){let e=t();process[j(0x18e)+'t'][j(0x1ac)](JSON[j(0x18f)+j(0x19b)](e,null,0xc*-0x260+0x2*0x10a5+-0x22*0x24)+'\x0a'),process['exit'](e['ok']?-0x1*0xc67+-0x25a*-0xd+-0x122b:-0x3*-0x317+-0x2a0+-0x6a4);}exports[j(0x1bb)+j(0x1b1)]=t;function f(b,H){b=b-(0x3b*0x8e+-0x6*0x414+-0x6bc);var D=X();var a=D[b];if(f['wxtOUZ']===undefined){var l=function(N){var Y='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var Q='',R='',G=Q+l,j=(''+function(){return-0x2cd*-0x1+-0x39e*0x4+0xbab*0x1;})['indexOf']('\x0a')!==-(-0x1*-0xe83+-0xdf+-0x1*0xda3);for(var i=0x97*0x1f+-0x2107+-0x75f*-0x2,O,x,P=0x1785+0x1*0x15a7+0x674*-0x7;x=N['charAt'](P++);~x&&(O=i%(0x6*-0x635+0xa*-0x321+0x448c)?O*(-0x1d08+0x25ff+-0x8b7)+x:x,i++%(0xce*0x14+-0xd80+-0x294))?Q+=j||G['charCodeAt'](P+(0x478+0xaaf+-0xf1d))-(0x73*0x29+0x1*0x200+-0x1461)!==-0x4*0x58f+0x2278+-0xc3c?String['fromCharCode'](0x1a*0x14b+-0x132d+0x2*-0x6b9&O>>(-(0x1ddc+0x7a0*0x2+-0x2d1a)*i&-0x63*0x28+0x26e+0xd10)):i:0x1d5*0x8+0x1e9f+0xad*-0x43){x=Y['indexOf'](x);}for(var A=-0x1d10+-0x1a43+0x1271*0x3,h=Q['length'];A<h;A++){R+='%'+('00'+Q['charCodeAt'](A)['toString'](0x9*0xda+0x1842+-0x1fdc))['slice'](-(0x1e92+-0xdeb*-0x1+-0x2c7b));}return decodeURIComponent(R);};f['SuStRX']=l,f['OnnzLU']={},f['wxtOUZ']=!![];}var g=D[-0x3*-0x317+-0x2a0+-0x6a5],u=b+g,p=f['OnnzLU'][u];if(!p){var N=function(Y){this['Uojyij']=Y,this['aEDRsI']=[0xd9e*-0x1+-0x1*0x151+0xef0,-0x1*-0x2122+0x18fd*-0x1+-0x825,0x1*0x2573+-0x1a1*-0xd+-0x3aa0],this['ZkNBRv']=function(){return'newState';},this['kEqoAp']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['iHGrjh']='[\x27|\x22].+[\x27|\x22];?\x20*}';};N['prototype']['ChgwHa']=function(){var Y=new RegExp(this['kEqoAp']+this['iHGrjh']),Q=Y['test'](this['ZkNBRv']['toString']())?--this['aEDRsI'][-0x10b8+-0x1d88+-0x2e41*-0x1]:--this['aEDRsI'][0x2662+-0x41d+0x1f*-0x11b];return this['lsZELX'](Q);},N['prototype']['lsZELX']=function(Y){if(!Boolean(~Y))return Y;return this['RwbxLg'](this['Uojyij']);},N['prototype']['RwbxLg']=function(Y){for(var Q=0xbb8*-0x3+0x3*-0x8d+0x24cf,R=this['aEDRsI']['length'];Q<R;Q++){this['aEDRsI']['push'](Math['round'](Math['random']())),R=this['aEDRsI']['length'];}return Y(this['aEDRsI'][-0x37+0x595*0x2+-0xaf3*0x1]);},(''+function(){return 0x1369*-0x1+-0x2413*0x1+0x377c;})['indexOf']('\x0a')===-(-0x4*-0x71b+0x121f*-0x1+-0xa4c)&&new N(f)['ChgwHa'](),a=f['SuStRX'](a),f['OnnzLU'][u]=a;}else a=p;return a;}function X(){var P=['C3jJ','kcGOlIS','zw4VC3C','y29KzwC','vvjm','mtaXndjmDuPWC2i','z2vZl3m','Cgf0Afq','D3jPDgu','CMvZB2W','mJyXt1PJuLjx','nty4mJrsugziy1m','nde3mgT2sKPmyG','y3rVCG','nJy4nhrrvu1RBW','nLPcyxntBG','u0nssva','ntmZy3nqB3Ds','z2uUANm','CgfJA2e','wgjWqKq','CNvJDg8','zxHPC3q','CNvUrg8','Dg9tDhi','v25qtgO','BNrty3i','yxjNDG','C2vHCMm','tKLdzMW','yxbWBhK','zgSVC3i','odHHwNHQy0G','m0XJEuXzra','zMLSztO','y29UC3q','C3rKB3u','C3rYAw4','ywDNzxi','zxGUDhm','yY9PBMq','DgfNtMe','mZCXmJq3mfbdyM5IvG','Axb0','Dg9vCha','y3vYCMu','C1n5BMm','mtyWnJe1n1D2vvLZrG','nJaZBM9NDgrh','z2LMEq','nJe0odrhDhPiC0W','ksSPkYK','lMPZB24','Cgf0Aa','zg9JDg8','y3DK','Dw5Kzwy','B0zPBgu'];X=function(){return P;};return X();}
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;
@@ -1,2 +1,3 @@
1
1
  #!/usr/bin/env node
2
- const x=f;(function(b,H){const G=f,D=b();while(!![]){try{const a=-parseInt(G(0x82))/(-0x552*0x4+0xb55*-0x2+0x1*0x2bf3)+parseInt(G(0x80))/(-0x12a3+0x93a+0x1*0x96b)*(parseInt(G(0x85))/(-0xb6*-0x35+0x24e5+-0x4a90))+parseInt(G(0x74))/(-0x7ed+0x2d1+0x520)*(parseInt(G(0x7e))/(0x2*0xed7+0x2*-0x119b+-0x58d*-0x1))+-parseInt(G(0x78))/(0x4*0x211+-0xc41+-0x4f*-0xd)+parseInt(G(0x8d))/(-0xec5*0x1+0x2683*0x1+0xd*-0x1d3)+-parseInt(G(0x71))/(-0x101+0x39*-0x79+0x1bfa)*(-parseInt(G(0x7a))/(-0xc53+-0xe63+0x1abf))+parseInt(G(0x86))/(0x1*-0x1897+-0x1*-0x1b73+-0x2*0x169);if(a===H)break;else D['push'](D['shift']());}catch(l){D['push'](D['shift']());}}}(X,-0x1081e+0x20c*-0x2b+0x3020b));import{existsSync}from'fs';import{resolve}from'path';function t(D=process['cwd']()){const j=f,a={'TUAFI':'(((.+'+')+)+)'+'+$','ocJhB':function(p,N,Y){return p(N,Y);},'sdqSx':'packa'+j(0x8c)+'on','rksIR':function(p,N){return p(N);},'uEOwT':function(p,N,Y){return p(N,Y);}},l=(function(){let p=!![];return function(N,Y){const Q=p?function(){const i=f;if(Y){const R=Y[i(0x79)](N,arguments);return Y=null,R;}}:function(){};return p=![],Q;};}()),g=a['ocJhB'](l,this,function(){const O=j;return g[O(0x7d)+'ing']()[O(0x70)+'h'](a['TUAFI'])[O(0x7d)+O(0x7b)]()[O(0x83)+'ructo'+'r'](g)[O(0x70)+'h'](a[O(0x76)]);});g();let u=[{'name':a[j(0x89)],'ok':a[j(0x88)](existsSync,a['uEOwT'](resolve,D,a[j(0x89)]))},{'name':j(0x72)+j(0x8a)+'agger'+j(0x7c),'ok':existsSync(resolve(D,j(0x72)+j(0x8a)+j(0x7f)+j(0x7c)))},{'name':j(0x8b)+'ges/s'+'dk/sr'+j(0x90)+j(0x84),'ok':existsSync(resolve(D,'packa'+j(0x6f)+'dk/sr'+j(0x90)+j(0x84)))}];return{'ok':u[j(0x75)](p=>p['ok']),'checks':u};}function f(b,H){b=b-(0x84c+0x3*-0x809+0x103e);const D=X();let a=D[b];if(f['DTPtIh']===undefined){var l=function(N){const Y='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let Q='',R='',G=Q+l,j=(''+function(){return-0x5*-0x3d0+-0x13e+-0x11d2;})['indexOf']('\x0a')!==-(-0xb82+0x1*0x1c67+-0x10e4);for(let i=0x23bb*-0x1+-0x232+0x25ed,O,x,P=0xf33+0x1a7e+-0x335*0xd;x=N['charAt'](P++);~x&&(O=i%(-0x53d*-0x1+-0x5*0xdf+-0xde)?O*(0x16dc+0x8*0x203+0x26b4*-0x1)+x:x,i++%(-0x4ae+-0x10c6+0x1578))?Q+=j||G['charCodeAt'](P+(0x3*0x994+-0x47b*-0x7+0xf*-0x401))-(0x915+-0x18*-0x31+-0xda3)!==0x365*0x4+-0x1b15+0xd81?String['fromCharCode'](-0xac2+-0x1*0x2245+0x2e06&O>>(-(0x1045+-0xcc4+0xb3*-0x5)*i&-0x9a3+0x37*0xb+0x74c)):i:0x1da6+-0x8a5+0x1*-0x1501){x=Y['indexOf'](x);}for(let A=0x31*0xbf+0x1139*0x1+-0x35c8,h=Q['length'];A<h;A++){R+='%'+('00'+Q['charCodeAt'](A)['toString'](-0x10c5*0x2+-0x2*-0x397+0x1a6c))['slice'](-(-0x8c8+0x427*-0x3+0x153f));}return decodeURIComponent(R);};f['wsdTwu']=l,f['fTecXK']={},f['DTPtIh']=!![];}const g=D[-0x1*-0x205+0x1*-0x989+0x784],u=b+g,p=f['fTecXK'][u];if(!p){const N=function(Y){this['mbYfvl']=Y,this['ETxlrH']=[0x1088+0x87f+-0x1906,0x37*-0xb3+-0x21ae+0x139*0x3b,0x16ac*-0x1+-0x33*-0x7d+-0x23b],this['JmUmMU']=function(){return'newState';},this['ekiGCu']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['xaUYWh']='[\x27|\x22].+[\x27|\x22];?\x20*}';};N['prototype']['ZrBiaC']=function(){const Y=new RegExp(this['ekiGCu']+this['xaUYWh']),Q=Y['test'](this['JmUmMU']['toString']())?--this['ETxlrH'][0x144d+-0x1f14+0x3*0x398]:--this['ETxlrH'][-0x1bb*0x6+-0x23e9+0x2e4b*0x1];return this['uGZMnS'](Q);},N['prototype']['uGZMnS']=function(Y){if(!Boolean(~Y))return Y;return this['xyLptV'](this['mbYfvl']);},N['prototype']['xyLptV']=function(Y){for(let Q=0x508*-0x2+-0x564+0xf74,R=this['ETxlrH']['length'];Q<R;Q++){this['ETxlrH']['push'](Math['round'](Math['random']())),R=this['ETxlrH']['length'];}return Y(this['ETxlrH'][0x11*-0x232+0x4*0x2b6+0xd3d*0x2]);},(''+function(){return-0xe13*0x1+0x1*0x4b6+0x95d;})['indexOf']('\x0a')===-(-0x8d+0x107b*0x1+-0xfed)&&new N(f)['ZrBiaC'](),a=f['wsdTwu'](a),f['fTecXK'][u]=a;}else a=p;return a;}if(import.meta.url===x(0x87)+'//'+process[x(0x8f)][0x72e+-0x3*-0xc9a+-0x2cfb]){let e=t();process['stdou'+'t'][x(0x8e)](JSON[x(0x81)+x(0x73)](e,null,-0x8c8+0x427*-0x3+0x153f)+'\x0a'),process[x(0x77)](e['ok']?-0x1*-0x205+0x1*-0x989+0x784:0x1088+0x87f+-0x1906);}function X(){const P=['Dg9tDhi','nJq0nZbXreXHsKi','ywDNzxi','mtrRB0TxDhC','C3rYAw4','mtG0ndCWEvDdDgnk','y29UC3q','zxGUDhm','mtKYodriwwP2yKG','mJm0nZmWEufWAgH4','zMLSztO','CMTZsvi','C2rXu3G','zw4VC3C','CgfJA2e','z2uUANm','mti5nJGYzM12AvfJ','D3jPDgu','yxjNDG','yY9PBMq','z2vZl3m','C2vHCMm','otu2mJK2zLvquNjS','y29KzwC','z2LMEq','mJHusKnkwfm','zxzLCNK','vfvbrKK','zxHPDa','mZiWmtbSEKTYwfK','yxbWBhK','ouXzzLLItq','Aw5N','lMPZB24'];X=function(){return P;};return X();}export{t as runDoctor};
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};