palbase 0.77.0 → 0.78.1

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.
Files changed (60) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/ai-sdk/index.js +2 -2
  3. package/dist/backend/engine.js +2 -2
  4. package/dist/backend/env.js +1 -1
  5. package/dist/backend/index.js +3 -3
  6. package/dist/backend/stack.js +1 -1
  7. package/dist/backend/test.js +2 -2
  8. package/dist/chunks/{34HGL5FX.js → 25KG2TVU.js} +1 -1
  9. package/dist/chunks/{GFBWGJW3.js → 2T3EX52E.js} +1 -1
  10. package/dist/chunks/{VOLGPAPR.js → 35KQJQ77.js} +2 -2
  11. package/dist/chunks/{ES24JS2D.js → 3TJFV35H.js} +2 -2
  12. package/dist/chunks/{FN5763FR.js → 3XF644A5.js} +2 -2
  13. package/dist/chunks/426QPZNS.js +13 -0
  14. package/dist/chunks/{U4VX7NKX.js → 4XE4HLPK.js} +2 -2
  15. package/dist/chunks/{WXT24CE5.js → 5KGMQFET.js} +1 -1
  16. package/dist/chunks/6Y4ICGZ7.js +2 -0
  17. package/dist/chunks/{G3PH5T6N.js → EUMY6SCM.js} +1 -1
  18. package/dist/chunks/{IZVBCAKH.js → FCCX2OTM.js} +2 -2
  19. package/dist/chunks/{RQJ4MX2H.js → IO5HB5B6.js} +2 -2
  20. package/dist/chunks/{AUOFL6RB.js → JY7YG3BO.js} +2 -2
  21. package/dist/chunks/{RRS7TQKX.js → L63FWRZX.js} +2 -2
  22. package/dist/chunks/{ONLXIZ6E.js → LONPNPNX.js} +2 -2
  23. package/dist/chunks/{DENZSXKJ.js → LXS7JHPJ.js} +2 -2
  24. package/dist/chunks/{QWXF6KWI.js → QWKOKJKM.js} +1 -1
  25. package/dist/chunks/{7RTPVUIH.js → RB4JQXKZ.js} +2 -2
  26. package/dist/chunks/{BDHVYVWT.js → ROV6TJZK.js} +1 -1
  27. package/dist/chunks/{KLK7HZZ7.js → TFPVJ3C3.js} +3 -3
  28. package/dist/chunks/{JOVXELK5.js → UUDOMSKW.js} +2 -2
  29. package/dist/chunks/{FE7ZBADH.js → VNUCKM7H.js} +1 -1
  30. package/dist/chunks/{ZZNNCI6A.js → WTFMJKDB.js} +2 -2
  31. package/dist/chunks/{F6OGRDZB.js → ZBTOHVML.js} +2 -2
  32. package/dist/chunks/{CYNLRAAW.js → ZIHVYOXE.js} +2 -2
  33. package/dist/cli.js +7 -3
  34. package/dist/cloud/index.js +2 -2
  35. package/dist/refuse/ai-sdk.js +1 -1
  36. package/dist/refuse/ai.js +1 -1
  37. package/dist/refuse/backend.js +1 -1
  38. package/dist/refuse/cloud.js +1 -1
  39. package/dist/refuse/server.js +1 -1
  40. package/dist/server/index.js +2 -2
  41. package/dist/server/testing.js +2 -2
  42. package/dist/web/index.js +2 -2
  43. package/dist/web/message.js +2 -2
  44. package/dist/web/palbe.js +2 -2
  45. package/dist/web/payments-ui.js +2 -2
  46. package/dist/web/paywall.js +2 -2
  47. package/dist/web/push-sw.js +1 -1
  48. package/dist/web/ssr.js +2 -2
  49. package/dist/web/vite.js +2 -2
  50. package/package.json +2 -2
  51. package/types/ai/src/chats.d.ts +7 -0
  52. package/types/backend/src/gateways.d.ts +2 -1
  53. package/types/cloud/src/generated/project.d.ts +1 -1
  54. package/types/internal/src/chat.d.ts +28 -0
  55. package/types/internal/src/modules/ai.d.ts +11 -7
  56. package/types/internal/src/modules/payments.d.ts +366 -24
  57. package/types/web/src/chat.d.ts +20 -0
  58. package/types/web/src/index.d.ts +1 -1
  59. package/dist/chunks/4M4GEXJS.js +0 -13
  60. package/dist/chunks/6WCN7VAZ.js +0 -2
@@ -1,2 +1,2 @@
1
- /*! palbase 0.77.0 — Palbase SDK License (see LICENSE) */
2
- import{b}from"./QWXF6KWI.js";import{a as k,b as A}from"./GFBWGJW3.js";import{randomBytes as _}from"node:crypto";async function N(){let n={keys:[{id:"k1",key:_(32).toString("base64url"),activates_at:new Date(0).toISOString()}],lookup:_(32).toString("base64url")},e=new b({fetch:async()=>n});return await e.load(),e.close(),e}var f=class extends Error{status;error;data;body;constructor(e,a,l,d){let u=d!==null&&typeof d=="object"?d:{},o=u.error??String(l);super(`${e} ${a} \u2192 ${l} ${o}${u.error_description?`: ${u.error_description}`:""}`),this.name="TestApiError",this.status=l,this.error=o,this.data=u.data,this.body=u}};function x(n,e){if(!n)throw new Error(`${e} is not set: the test client has nowhere to send its requests \u2014 \`palbase test\` sets it, as the platform's test run does`);return n}function B(n){let e=n.split(".")[1];if(!e)return null;try{let a=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return typeof a.exp=="number"?a.exp-Math.floor(Date.now()/1e3):null}catch{return null}}function L(n){try{return JSON.parse(n)}catch{return n}}function $(n){let e=x(n.baseUrl,"PALBASE_TEST_BASE_URL").replace(/\/+$/,""),a=n.apiKey||void 0,l=(n.authUrl??e).replace(/\/+$/,""),d=n.fetch??fetch,u=[],o=null;async function c(r,t,s,i,T={},O=!0){let g={...T.headers},m=h=>Object.keys(g).some(R=>R.toLowerCase()===h);a!==void 0&&!m("apikey")&&(g.apikey=a),o&&O&&!m("authorization")&&(g.authorization=`Bearer ${o}`),i!==void 0&&!m("content-type")&&(g["content-type"]="application/json");let I=Date.now(),p=await d(`${r}${s}`,{method:t,headers:g,body:i===void 0?void 0:JSON.stringify(i)}),E=await p.text(),S=E?L(E):void 0;if(u.push({method:t,path:s,status:p.status,ms:Date.now()-I}),!p.ok){let h=p.status===401&&o?B(o):null;throw h!==null&&h<=0?new f(t,s,p.status,{error:"access_token_expired",error_description:`this run's access token expired ${-h}s ago: a test user's token is made for one run \u2014 run the tests again (\`palbase test\` makes new ones)`}):new f(t,s,p.status,S)}return S}let y={requests:u,get:(r,t)=>c(e,"GET",r,void 0,t),post:(r,t,s)=>c(e,"POST",r,t,s),patch:(r,t,s)=>c(e,"PATCH",r,t,s),put:(r,t,s)=>c(e,"PUT",r,t,s),delete:(r,t)=>c(e,"DELETE",r,void 0,t),query:(r,t,s)=>c(e,"QUERY",r,t,s),async signInAs(r){let t=n.identities?.[r];if(!t){let s=Object.keys(n.identities??{});throw s.length===0?new Error(`no test user named ${JSON.stringify(r)}: this run has no test users \u2014 none were named (the machine's test users, or \`palbase test --users <names>\`), or they could not be made: the run's log says which`):new Error(`no test user named ${JSON.stringify(r)} \u2014 this run has: ${s.join(", ")}. A run makes the test users its machine names (palbase machines:update <machine> --test-users <names>) or \`palbase test --users <names>\` names`)}return t.accessToken?(o=t.accessToken,{id:t.id??"",email:t.email}):y.signIn(t)},async signIn(r){if(a===void 0)throw new Error("PALBASE_TEST_API_KEY is not set: a sign-in at the project's auth is made with a publishable key of the project's (palbase apps:sdkconfig shows one) \u2014 a run's test users come with their tokens: api.signInAs(name)");let t=i=>c(l,"POST","/auth/login",r,i?{headers:i}:{},!1),s;try{s=await t()}catch(i){let T=i instanceof f&&i.status===403?k(i.body):null;if(!T)throw i;s=await t(await A(T))}return o=s.access_token,s.user??{id:""}},async signOut(){await c(l,"POST","/auth/logout",void 0),o=null},asAnonymous(){o=null}};return y}function P(n){if(!n)return{};let e;try{e=JSON.parse(n)}catch{throw new Error("PALBASE_TEST_IDENTITIES is set but is not JSON: the run that started these tests handed over a broken set of test users")}if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("PALBASE_TEST_IDENTITIES is not an object of test users by name");return e}var j={get stack(){return!!process.env.PALBASE_TEST_BASE_URL},minted(n){return Object.prototype.hasOwnProperty.call(P(process.env.PALBASE_TEST_IDENTITIES),n)}},w,q=new Proxy({},{get(n,e){return w??=$({baseUrl:process.env.PALBASE_TEST_BASE_URL??"",apiKey:process.env.PALBASE_TEST_API_KEY??"",authUrl:process.env.PALBASE_TEST_AUTH_URL,identities:P(process.env.PALBASE_TEST_IDENTITIES)}),Reflect.get(w,e,w)}});export{N as a,f as b,$ as c,j as d,q as e};
1
+ /*! palbase 0.78.1 — Palbase SDK License (see LICENSE) */
2
+ import{b}from"./QWKOKJKM.js";import{a as k,b as A}from"./2T3EX52E.js";import{randomBytes as _}from"node:crypto";async function N(){let n={keys:[{id:"k1",key:_(32).toString("base64url"),activates_at:new Date(0).toISOString()}],lookup:_(32).toString("base64url")},e=new b({fetch:async()=>n});return await e.load(),e.close(),e}var f=class extends Error{status;error;data;body;constructor(e,a,l,d){let u=d!==null&&typeof d=="object"?d:{},o=u.error??String(l);super(`${e} ${a} \u2192 ${l} ${o}${u.error_description?`: ${u.error_description}`:""}`),this.name="TestApiError",this.status=l,this.error=o,this.data=u.data,this.body=u}};function x(n,e){if(!n)throw new Error(`${e} is not set: the test client has nowhere to send its requests \u2014 \`palbase test\` sets it, as the platform's test run does`);return n}function B(n){let e=n.split(".")[1];if(!e)return null;try{let a=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return typeof a.exp=="number"?a.exp-Math.floor(Date.now()/1e3):null}catch{return null}}function L(n){try{return JSON.parse(n)}catch{return n}}function $(n){let e=x(n.baseUrl,"PALBASE_TEST_BASE_URL").replace(/\/+$/,""),a=n.apiKey||void 0,l=(n.authUrl??e).replace(/\/+$/,""),d=n.fetch??fetch,u=[],o=null;async function c(r,t,s,i,T={},O=!0){let g={...T.headers},m=h=>Object.keys(g).some(R=>R.toLowerCase()===h);a!==void 0&&!m("apikey")&&(g.apikey=a),o&&O&&!m("authorization")&&(g.authorization=`Bearer ${o}`),i!==void 0&&!m("content-type")&&(g["content-type"]="application/json");let I=Date.now(),p=await d(`${r}${s}`,{method:t,headers:g,body:i===void 0?void 0:JSON.stringify(i)}),E=await p.text(),S=E?L(E):void 0;if(u.push({method:t,path:s,status:p.status,ms:Date.now()-I}),!p.ok){let h=p.status===401&&o?B(o):null;throw h!==null&&h<=0?new f(t,s,p.status,{error:"access_token_expired",error_description:`this run's access token expired ${-h}s ago: a test user's token is made for one run \u2014 run the tests again (\`palbase test\` makes new ones)`}):new f(t,s,p.status,S)}return S}let y={requests:u,get:(r,t)=>c(e,"GET",r,void 0,t),post:(r,t,s)=>c(e,"POST",r,t,s),patch:(r,t,s)=>c(e,"PATCH",r,t,s),put:(r,t,s)=>c(e,"PUT",r,t,s),delete:(r,t)=>c(e,"DELETE",r,void 0,t),query:(r,t,s)=>c(e,"QUERY",r,t,s),async signInAs(r){let t=n.identities?.[r];if(!t){let s=Object.keys(n.identities??{});throw s.length===0?new Error(`no test user named ${JSON.stringify(r)}: this run has no test users \u2014 none were named (the machine's test users, or \`palbase test --users <names>\`), or they could not be made: the run's log says which`):new Error(`no test user named ${JSON.stringify(r)} \u2014 this run has: ${s.join(", ")}. A run makes the test users its machine names (palbase machines:update <machine> --test-users <names>) or \`palbase test --users <names>\` names`)}return t.accessToken?(o=t.accessToken,{id:t.id??"",email:t.email}):y.signIn(t)},async signIn(r){if(a===void 0)throw new Error("PALBASE_TEST_API_KEY is not set: a sign-in at the project's auth is made with a publishable key of the project's (palbase apps:sdkconfig shows one) \u2014 a run's test users come with their tokens: api.signInAs(name)");let t=i=>c(l,"POST","/auth/login",r,i?{headers:i}:{},!1),s;try{s=await t()}catch(i){let T=i instanceof f&&i.status===403?k(i.body):null;if(!T)throw i;s=await t(await A(T))}return o=s.access_token,s.user??{id:""}},async signOut(){await c(l,"POST","/auth/logout",void 0),o=null},asAnonymous(){o=null}};return y}function P(n){if(!n)return{};let e;try{e=JSON.parse(n)}catch{throw new Error("PALBASE_TEST_IDENTITIES is set but is not JSON: the run that started these tests handed over a broken set of test users")}if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("PALBASE_TEST_IDENTITIES is not an object of test users by name");return e}var j={get stack(){return!!process.env.PALBASE_TEST_BASE_URL},minted(n){return Object.prototype.hasOwnProperty.call(P(process.env.PALBASE_TEST_IDENTITIES),n)}},w,q=new Proxy({},{get(n,e){return w??=$({baseUrl:process.env.PALBASE_TEST_BASE_URL??"",apiKey:process.env.PALBASE_TEST_API_KEY??"",authUrl:process.env.PALBASE_TEST_AUTH_URL,identities:P(process.env.PALBASE_TEST_IDENTITIES)}),Reflect.get(w,e,w)}});export{N as a,f as b,$ as c,j as d,q as e};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.77.0 — Palbase SDK License (see LICENSE) */
2
- import{b as l}from"./VOLGPAPR.js";var g=/^[A-Za-z0-9_.:-]{1,160}$/,y=/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\p{Cs}]/u,p="128 bytes at most, no control, format (bidi, zero-width) or line-separator character";function o(e,t,i){if(typeof e!="string"||!g.test(e))throw new TypeError(`${t}: ${i} (got ${JSON.stringify(e)})`);return e}var f="the machine is one of the person's machines, by its id (machines.list)",c="owner is the user's id";function m(e){return{name:e.name,...e.acp_version!==void 0?{acpVersion:e.acp_version}:{},...e.cli_version!==void 0?{cliVersion:e.cli_version}:{},status:e.status}}function w(e){return{url:e.url,...e.server_name?{serverName:e.server_name}:{},...e.ca_certificate?{caCertificate:e.ca_certificate}:{}}}function h(e){return{id:e.id,name:e.name,owner:e.owner??null,...e.pool_id?{poolId:e.pool_id}:{},...e.os?{os:e.os}:{},...e.arch?{arch:e.arch}:{},state:e.state,lastSeenAt:e.last_seen_at??null,registeredAt:e.registered_at??null,...e.harnesses!==void 0?{harnesses:e.harnesses.map(m)}:{}}}function M(e){if(typeof e.key!="string"||e.key==="")throw new l({op:"createMachineKey",status:502,code:"no_key",message:`the machine key ${e.id} was minted but not said: mint another (it enrols nothing unused in 15 minutes)`});return{id:e.id,key:e.key,owner:e.owner,poolId:e.pool_id,...e.label?{label:e.label}:{},...e.created_at!==void 0?{createdAt:e.created_at}:{},enroll:w(e.enroll)}}function _(e,t){return e.length===t.length&&e.every((i,s)=>d(i,t[s]))}function d(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let i=Object.keys(e),s=Object.keys(t);return i.length===s.length&&i.every(a=>Object.prototype.hasOwnProperty.call(t,a)&&d(e[a],t[a]))}function A(e,t,i=f){let s=t==="server",a=i;return{keys:{async create(n){if(typeof n!="object"||n===null)throw new TypeError("machines.keys.create: { os, arch, owner, label }");if(n.os!=="macos"&&n.os!=="linux")throw new TypeError("machines.keys.create: os is the machine's operating system, macos or linux");if(n.arch!=="arm64"&&n.arch!=="amd64")throw new TypeError("machines.keys.create: arch is the machine's architecture, arm64 or amd64");let r={os:n.os,arch:n.arch};if((n.owner!==void 0||s)&&(r.owner=o(n.owner,"machines.keys.create",s?`${c} the machine will belong to: the project's server names one`:c)),n.label!==void 0){if(typeof n.label!="string"||new TextEncoder().encode(n.label).byteLength>128||y.test(n.label))throw new TypeError(`machines.keys.create: label is what the key is for, ${p}`);r.label=n.label}return M((await e.createMachineKey({body:r,signal:n.signal})).data)}},async list(n={}){let r=n.owner!==void 0||s?o(n.owner,"machines.list",s?`${c} whose machines to list: the project's server names one`:c):void 0;return(await e.listMachines({...r!==void 0?{query:{owner:r}}:{},signal:n.signal})).data.machines.map(h)},async get(n,r={}){return h((await e.getMachine({path:{machine:o(n,"machines.get",a)},signal:r.signal})).data)},async cordon(n,r={}){await e.cordonMachine({path:{machine:o(n,"machines.cordon",a)},signal:r.signal})},async resume(n,r={}){await e.resumeMachine({path:{machine:o(n,"machines.resume",a)},signal:r.signal})},async delete(n,r={}){let u=o(n,"machines.delete",a);if(r.now!==void 0&&typeof r.now!="boolean")throw new TypeError("machines.delete: now is true (delete it whatever it does) or false");await e.deleteMachine({path:{machine:u},...r.now!==void 0?{query:{now:r.now}}:{},signal:r.signal})}}}export{m as a,h as b,_ as c,A as d};
1
+ /*! palbase 0.78.1 — Palbase SDK License (see LICENSE) */
2
+ import{b as l}from"./35KQJQ77.js";var g=/^[A-Za-z0-9_.:-]{1,160}$/,y=/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\p{Cs}]/u,p="128 bytes at most, no control, format (bidi, zero-width) or line-separator character";function o(e,t,i){if(typeof e!="string"||!g.test(e))throw new TypeError(`${t}: ${i} (got ${JSON.stringify(e)})`);return e}var f="the machine is one of the person's machines, by its id (machines.list)",c="owner is the user's id";function m(e){return{name:e.name,...e.acp_version!==void 0?{acpVersion:e.acp_version}:{},...e.cli_version!==void 0?{cliVersion:e.cli_version}:{},status:e.status}}function w(e){return{url:e.url,...e.server_name?{serverName:e.server_name}:{},...e.ca_certificate?{caCertificate:e.ca_certificate}:{}}}function h(e){return{id:e.id,name:e.name,owner:e.owner??null,...e.pool_id?{poolId:e.pool_id}:{},...e.os?{os:e.os}:{},...e.arch?{arch:e.arch}:{},state:e.state,lastSeenAt:e.last_seen_at??null,registeredAt:e.registered_at??null,...e.harnesses!==void 0?{harnesses:e.harnesses.map(m)}:{}}}function M(e){if(typeof e.key!="string"||e.key==="")throw new l({op:"createMachineKey",status:502,code:"no_key",message:`the machine key ${e.id} was minted but not said: mint another (it enrols nothing unused in 15 minutes)`});return{id:e.id,key:e.key,owner:e.owner,poolId:e.pool_id,...e.label?{label:e.label}:{},...e.created_at!==void 0?{createdAt:e.created_at}:{},enroll:w(e.enroll)}}function _(e,t){return e.length===t.length&&e.every((i,s)=>d(i,t[s]))}function d(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let i=Object.keys(e),s=Object.keys(t);return i.length===s.length&&i.every(a=>Object.prototype.hasOwnProperty.call(t,a)&&d(e[a],t[a]))}function A(e,t,i=f){let s=t==="server",a=i;return{keys:{async create(n){if(typeof n!="object"||n===null)throw new TypeError("machines.keys.create: { os, arch, owner, label }");if(n.os!=="macos"&&n.os!=="linux")throw new TypeError("machines.keys.create: os is the machine's operating system, macos or linux");if(n.arch!=="arm64"&&n.arch!=="amd64")throw new TypeError("machines.keys.create: arch is the machine's architecture, arm64 or amd64");let r={os:n.os,arch:n.arch};if((n.owner!==void 0||s)&&(r.owner=o(n.owner,"machines.keys.create",s?`${c} the machine will belong to: the project's server names one`:c)),n.label!==void 0){if(typeof n.label!="string"||new TextEncoder().encode(n.label).byteLength>128||y.test(n.label))throw new TypeError(`machines.keys.create: label is what the key is for, ${p}`);r.label=n.label}return M((await e.createMachineKey({body:r,signal:n.signal})).data)}},async list(n={}){let r=n.owner!==void 0||s?o(n.owner,"machines.list",s?`${c} whose machines to list: the project's server names one`:c):void 0;return(await e.listMachines({...r!==void 0?{query:{owner:r}}:{},signal:n.signal})).data.machines.map(h)},async get(n,r={}){return h((await e.getMachine({path:{machine:o(n,"machines.get",a)},signal:r.signal})).data)},async cordon(n,r={}){await e.cordonMachine({path:{machine:o(n,"machines.cordon",a)},signal:r.signal})},async resume(n,r={}){await e.resumeMachine({path:{machine:o(n,"machines.resume",a)},signal:r.signal})},async delete(n,r={}){let u=o(n,"machines.delete",a);if(r.now!==void 0&&typeof r.now!="boolean")throw new TypeError("machines.delete: now is true (delete it whatever it does) or false");await e.deleteMachine({path:{machine:u},...r.now!==void 0?{query:{now:r.now}}:{},signal:r.signal})}}}export{m as a,h as b,_ as c,A as d};