@adaptive-ai/sdk 0.1.0 → 0.1.3
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/dist/client/index.d.ts +31 -102
- package/dist/client/index.js +126 -7
- package/dist/server/index.d.ts +4894 -376
- package/dist/server/index.js +2 -2
- package/package.json +7 -4
package/dist/server/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {createTRPCProxyClient,httpLink}from'@trpc/client';import {AsyncLocalStorage}from'async_hooks';import
|
|
2
|
-
export{
|
|
1
|
+
import {createTRPCProxyClient,httpLink}from'@trpc/client';import {AsyncLocalStorage}from'async_hooks';import y from'superjson';function v(e){let r=Object.create(null);for(let t in e){let n=e[t];r[n]=t;}return r}var w={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,UNAUTHORIZED:-32001,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNPROCESSABLE_CONTENT:-32022,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099};v(w);v(w);typeof window>"u"||"Deno"in window||globalThis.process?.env?.NODE_ENV==="test"||!!globalThis.process?.env?.JEST_WORKER_ID||!!globalThis.process?.env?.VITEST_WORKER_ID;var _=class e extends Error{static prefix="__MISSING AUTH FOR SCOPE";static jsonRpcCode=-32001;constructor({provider:r,scope:t,accountId:n,popup:o=false}){let s=btoa(JSON.stringify({provider:r,scope:t,accountId:n}));super(`${e.prefix}: ${s}${o?" --popup":" end"}`);}jsonRpcError(){return {code:e.jsonRpcCode,message:this.message}}static check(r){return r?.message?.startsWith(e.prefix)}};var z=createTRPCProxyClient({transformer:y,links:[]});function je({baseUrl:e,realtimeDomain:r,guestServicesUrl:t}){globalThis.env||(globalThis.env={},globalThis.env.BASE_URL=e,globalThis.env.REALTIME_DOMAIN=r,globalThis.env.GUEST_SERVICES_URL=t,z=createTRPCProxyClient({transformer:y,links:[httpLink({url:t,transformer:y,headers:()=>{let n=C();if(!n)throw new Error("Missing request context");return {"x-request-id":n.requestId}}})]}),console.log("Adaptive SDK server environment initialized"));}var G=new AsyncLocalStorage,fe=new Proxy({},{get(e,r){return async t=>{if(globalThis.env===void 0)throw new Error("Adaptive SDK server environment is not initialized. Please call initializeServerEnvironment first.");let o=z[r];if(!o||typeof o.mutate!="function")throw new Error(`Property "${String(r)}" is not a mutation procedure`);return o.mutate(t)}}});function C(){return G.getStore()}function Le(e){let r=C();r&&Object.assign(r,e);}async function $e(e,r){return G.run(e,r)}function Be(){return globalThis.env.BASE_URL}var A=null;function Ve(){return A}function Ye({channelId:e,onUpdate:r}){let t=new WebSocket(`wss://${globalThis.env.REALTIME_DOMAIN}/${e}`),n=-1;function o(s){r&&(A=Date.now());try{let i=JSON.parse(s.data.toString());if(i?.id&&i.id>n){let d=y.parse(i.payload);r?.(d),n=i.id;}}catch{}}return t.addEventListener("message",o),{destroy(){t.close(),t.removeEventListener("message",o);}}}async function Y({channelId:e,data:r}){A=Date.now(),await fetch(`https://${globalThis.env.REALTIME_DOMAIN}/${e}`,{method:"POST",body:y.stringify(r)}).catch(console.error);}async function Ke(){let e,r=C()?.channelId;if(!r)throw new Error("API's using `startRealtimeResponse` must be called via `useRealtimeMutation`.");return {next(t){e=t,Y({channelId:r,data:t});},end(){return Y({channelId:r,data:e}),e}}}function K(e){throw new _({provider:e?.provider??"AC1",popup:true})}async function He(e){let r=await fe.getCurrentUser();if(r?.error==="SEED")throw new Error('Call to "getAuth" in seed function is not allowed. Seed functions should not depend on user data.');if(r.userId)return {userId:r.userId,status:"authenticated",signIn:K,providers:r.providers};if(e?.required)throw new _({provider:"AC1"});return {userId:null,status:"unauthenticated",signIn:K,providers:[]}}
|
|
2
|
+
export{He as getAuth,Be as getBaseUrl,Ve as getLastStreamTime,Ye as getRealtimeStore,C as getRequestContext,je as initializeServerEnvironment,fe as mcp,$e as runWithContext,Y as setRealtimeStore,Le as setRequestContext,Ke as startRealtimeResponse};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptive-ai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -19,14 +19,16 @@
|
|
|
19
19
|
"LICENSE"
|
|
20
20
|
],
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@tanstack/react-query": ">=
|
|
22
|
+
"@tanstack/react-query": ">=5",
|
|
23
23
|
"@trpc/client": ">=10",
|
|
24
|
+
"@trpc/server": ">=10",
|
|
25
|
+
"typed-rpc": ">=5",
|
|
24
26
|
"lodash": ">=4",
|
|
25
27
|
"nanoid": ">=4",
|
|
26
28
|
"openai": ">=4",
|
|
27
29
|
"react": ">=18",
|
|
28
30
|
"superjson": ">=1",
|
|
29
|
-
"zod": ">=
|
|
31
|
+
"zod": ">=3"
|
|
30
32
|
},
|
|
31
33
|
"peerDependenciesMeta": {
|
|
32
34
|
"@tanstack/react-query": {
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
"browser-image-compression": "^2.0.2",
|
|
55
57
|
"dom-to-image-more": "^3.7.2",
|
|
56
58
|
"eslint": "^8.47.0",
|
|
57
|
-
"eslint-config-next": "15.
|
|
59
|
+
"eslint-config-next": "15.5.6",
|
|
58
60
|
"eslint-config-prettier": "^9.0.0",
|
|
59
61
|
"eslint-formatter-codeframe": "^7.32.1",
|
|
60
62
|
"eslint-plugin-prettier": "^5.0.1",
|
|
@@ -79,6 +81,7 @@
|
|
|
79
81
|
"lint": "NODE_OPTIONS='--max-old-space-size=8192' eslint --cache .",
|
|
80
82
|
"lint:fix": "eslint --cache --fix .",
|
|
81
83
|
"check": "NODE_OPTIONS='--max-old-space-size=8192' tsc --noEmit",
|
|
84
|
+
"bundle": "./bundle.sh",
|
|
82
85
|
"build": "tsup",
|
|
83
86
|
"clean": "rimraf dist"
|
|
84
87
|
}
|