@tinkerlandai/indiana-sdk 0.8.0 → 0.8.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/CHANGELOG.md +14 -0
- package/README.md +67 -20
- package/README.zh-CN.md +66 -19
- package/dist/ai-usage-BV-FlgWr.d.ts +247 -0
- package/dist/{ai-usage-Bigjb8MS.d.ts → api-B3FIE41b.d.ts} +554 -423
- package/dist/chunk-2QPETWDX.js +1 -0
- package/dist/chunk-ANOOBDW5.js +350 -0
- package/dist/chunk-BNU6IG3F.js +1 -0
- package/dist/chunk-GRLMT5PR.js +1 -0
- package/dist/chunk-LMR2TM3X.js +1 -0
- package/dist/chunk-OBYJWIRB.js +1 -0
- package/dist/{chunk-G2R56FKU.js → chunk-SHSNIJJM.js} +1 -1
- package/dist/{chunk-OVMNCZYC.js → chunk-SOQO2RDZ.js} +1 -1
- package/dist/chunk-VVV3JNS3.js +1 -0
- package/dist/{chunk-YAFMBXIE.js → chunk-X747SY26.js} +1 -1
- package/dist/chunk-Y32NPIYY.js +1 -0
- package/dist/chunk-ZT66RIFU.js +10 -0
- package/dist/{configuration-sync-VFbY1pCN.d.ts → configuration-sync-DNvKXHk-.d.ts} +25 -25
- package/dist/{content-K2HCZVC2.js → content-J3FKZTGT.js} +1 -1
- package/dist/{errors-BpCmukJr.d.ts → errors-C8lRYZ0n.d.ts} +49 -2
- package/dist/{funnel-runtime-start-DKcTCRrd.d.ts → funnel-local-client-wbz-4gFx.d.ts} +701 -6055
- package/dist/funnel-runtime-host-C5P5JTV3.js +1 -0
- package/dist/index.d.ts +1831 -1901
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +4 -3
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +7 -7
- package/dist/page.js +1 -1
- package/dist/paywall-3GIRKSHN.js +1 -0
- package/dist/popup.d.ts +2 -2
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +97 -4
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-5FPYVSPW.js +1 -0
- package/dist/server.d.ts +4648 -8
- package/dist/server.js +1 -1
- package/dist/src-BMJCIMIF.js +1 -0
- package/dist/visual.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-2A6UYUFA.js +0 -1
- package/dist/chunk-3BQFJANQ.js +0 -1
- package/dist/chunk-3ENVRJE6.js +0 -350
- package/dist/chunk-A3N4ZZTM.js +0 -7
- package/dist/chunk-AE4CUTUE.js +0 -1
- package/dist/chunk-CXYOZSOF.js +0 -1
- package/dist/funnel-runtime-host-HNZ47TZW.js +0 -1
- package/dist/paywall-PD62B2AY.js +0 -1
- package/dist/src-4MRSESVS.js +0 -1
- package/dist/{chunk-6X42DWOM.js → chunk-DSPLGTQI.js} +0 -0
- package/dist/{chunk-S5TVMQRC.js → chunk-EXCPE2XH.js} +0 -0
- package/dist/{customer-page-BrCZxcaQ.d.ts → customer-page-WUQVK_tp.d.ts} +4 -4
- package/dist/{screen-BazUOjwM.d.ts → screen-BpAejkn0.d.ts} +267 -267
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as v,p as k,s as S}from"./chunk-ZT66RIFU.js";import{a as e}from"./chunk-SOQO2RDZ.js";import{a as C,j,m as _,p as P}from"./chunk-LMR2TM3X.js";import{b}from"./chunk-OBYJWIRB.js";import{a as L}from"./chunk-EXCPE2XH.js";var M={name:"@tinkerlandai/indiana-sdk",version:"0.8.3",description:"Framework-independent Indiana SDK for customer identity, entitlements, credits, offers and growth surfaces.",license:"UNLICENSED",repository:{type:"git",url:"git+https://github.com/tinkerlandai/Indiana.git",directory:"packages/sdk"},engines:{node:">=22"},publishConfig:{access:"public",tag:"beta"},type:"module",sideEffects:!1,files:["dist","README.md","README.zh-CN.md","CHANGELOG.md","THIRD_PARTY_NOTICES.md"],exports:{"./react-native":{types:"./dist/react-native.d.ts","react-native":"./dist/react-native.js",import:"./dist/react-native.js",default:"./dist/react-native.js"},".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./popup":{types:"./dist/popup.d.ts",import:"./dist/popup.js"},"./server":{types:"./dist/server.d.ts",import:"./dist/server.js"},"./openrouter":{types:"./dist/openrouter.d.ts",import:"./dist/openrouter.js"},"./native-shell":{types:"./dist/native-shell.d.ts",import:"./dist/native-shell.js"},"./page":{types:"./dist/page.d.ts",import:"./dist/page.js"},"./visual":{types:"./dist/visual.d.ts",import:"./dist/visual.js"}},scripts:{build:"tsup",prepack:"pnpm run build",typecheck:"tsc --noEmit",lint:"node ../../scripts/ci/lint.mjs --workspace packages/sdk"},dependencies:{"@ai-sdk/provider":"4.0.26","@types/json-schema":"7.0.15","css-tree":"^3.2.1","dom-mutator":"0.7.0",dompurify:"^3.4.15",zod:"4.6.6"},devDependencies:{"@indiana/contracts":"workspace:*","@openrouter/sdk":"^1.4.25","@types/css-tree":"^3.2.0",ai:"7.0.136",tsup:"^8.5.1",typescript:"^5.9.3","whatwg-url-minimum":"0.2.0"},peerDependencies:{"@openrouter/sdk":"^1.4.25"},peerDependenciesMeta:{"@openrouter/sdk":{optional:!0}}};var U=Symbol("IndianaNoContent");function Z(p,H,q=URL){let l=p.configuration?.scope,R=p.scope??(l&&{projectId:l.projectId,environment:l.environment}),s=R?b.parse(R):void 0;if(s&&l&&(s.projectId!==l.projectId||s.environment!==l.environment))throw new e("SCOPE_MISMATCH","Configuration belongs to another App/environment");let a=new q(p.baseUrl??L);if(a.username||a.password||a.search||a.hash)throw new e("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(a.protocol!=="https:"&&!(a.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(a.hostname)))throw new e("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let V=p.fetch??globalThis.fetch.bind(globalThis),f=p.timeoutMs??1e4;if(!Number.isFinite(f)||f<1||f>12e4)throw new e("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let h=null,u=0,m=null,g=new Set;function A(){u+=1,h=null,m=null;for(let i of g)i.abort();g.clear()}async function x(i,K={},I="POST",D={}){let d=D.installationDetach===!0;if(d&&(i!=="push/installations/detach"||I!=="POST"))throw new e("INVALID_REQUEST","Installation authority only detaches this installation");if(!h&&!d)throw new e("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let E=u,o=new AbortController;d||g.add(o);let w=()=>!d&&E!==u?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new e("TIMEOUT","Indiana request timed out"),T,F=new Promise((n,r)=>{T=()=>r(w()),o.signal.addEventListener("abort",T,{once:!0})}),G=setTimeout(()=>o.abort(),f),X=async()=>{let n=await V(`${a.href.replace(/\/$/,"")}/api/v1/${i}`,{method:I,headers:{"Content-Type":"application/json",...d?{}:{Authorization:`Bearer ${h}`},[v]:S.current,[k]:M.version,...s?{"X-Indiana-Project":s.projectId,"X-Indiana-Environment":s.environment}:{}},body:I==="POST"?JSON.stringify(K):void 0,signal:o.signal,credentials:"omit",cache:"no-store",redirect:"error",...D.keepalive?{keepalive:!0}:{}});if(o.signal.aborted)throw w();let r;try{r=n.status===204?U:await n.json()}catch{throw o.signal.aborted?w():new e(n.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",n.status,n.headers.get("X-Request-Id")??void 0)}if(o.signal.aborted)throw w();if(!d&&E!==u)throw new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!n.ok){let t=_.safeParse(r),c=t.success&&(!C.safeParse(t.data.error.code).success||j(t.data.error.code,n.status)),N=c?t.data.error.code:"HTTP_ERROR",O=P(N,n.status,{retryAfter:n.headers.get("Retry-After"),recovery:c?t.data.error.recovery:void 0,reason:c?t.data.error.reason:void 0});throw new e(N,c?t.data.error.message:"Indiana request failed",n.status,n.headers.get("X-Request-Id")??(t.success?t.data.requestId:void 0),{...O,...t.success&&t.data.error.retryable===!1?{retryable:!1}:{},...O.retryAfterSeconds===void 0&&t.success&&t.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:t.data.error.retryAfterSeconds}:{}})}if(n.headers.get(v)!==S.current)throw new e("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(s&&r!==U){let t=r&&typeof r=="object"&&"scope"in r?r:r&&typeof r=="object"&&"configuration"in r?r.configuration:null;if(!t||typeof t!="object"||!("scope"in t))throw new e("INVALID_RESPONSE","Response is missing its App/environment scope");let c=b.safeParse(t.scope);if(!c.success||c.data.projectId!==s.projectId||c.data.environment!==s.environment)throw new e("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let y=n.headers.get("X-Indiana-Telemetry-Subject");if(y){if(!/^[a-f0-9]{64}$/.test(y))throw new e("INVALID_RESPONSE","Invalid telemetry identity");m!==y&&(m=y,H?.(m))}return r};try{return await Promise.race([X(),F])}catch(n){throw!d&&E!==u?new e("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):n instanceof e?n:new e(o.signal.aborted?"TIMEOUT":"NETWORK_ERROR",o.signal.aborted?"Indiana request timed out":"Unable to read the Indiana response")}finally{clearTimeout(G),o.signal.removeEventListener("abort",T),g.delete(o)}}return{subjectKey:()=>m,identify(i){if(!i.trim()||/\s/.test(i)||i.length>4096)throw new e("INVALID_TOKEN","A nonempty server-issued token is required");A(),h=i},reset:A,request:x}}export{Z as a};
|