@hasura/promptql 2.0.0-alpha.29 → 2.0.0-alpha.30

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/biome.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.4.6/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.4.13/schema.json",
3
3
  "root": false,
4
4
  "files": {
5
5
  "includes": [
@@ -1,5 +1,5 @@
1
1
  import { GraphQLError } from 'graphql';
2
- import { E as EnrichTokenOutput } from '../graphql-B1rttH6Z.mjs';
2
+ import { E as EnrichTokenOutput } from '../graphql-DNHSh7_M.mjs';
3
3
 
4
4
  /**
5
5
  * Constructor options for a PromptQL authenticator.
@@ -1,5 +1,5 @@
1
1
  import { GraphQLError } from 'graphql';
2
- import { E as EnrichTokenOutput } from '../graphql-B1rttH6Z.js';
2
+ import { E as EnrichTokenOutput } from '../graphql-DNHSh7_M.js';
3
3
 
4
4
  /**
5
5
  * Constructor options for a PromptQL authenticator.
@@ -1 +1 @@
1
- "use strict";var c=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var y=(e,r)=>{for(var a in r)c(e,a,{get:r[a],enumerable:!0})},w=(e,r,a,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of T(r))!x.call(e,t)&&t!==a&&c(e,t,{get:()=>r[t],enumerable:!(o=k(r,t))||o.enumerable});return e};var g=e=>w(c({},"__esModule",{value:!0}),e);var P={};y(P,{createPromptQLAuthTokenGenerator:()=>L,enrichToken:()=>f,isEnrichTokenMutationResponse:()=>p,isLuxAuthPromptQLTokenFailedResponse:()=>u,isLuxAuthPromptQLTokenSuccessResponse:()=>h});module.exports=g(P);function m(e){return e=e?e.trim():"",e?e[e.length-1]==="/"?e.slice(0,e.length-1):e:""}function u(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="failure"}function h(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="success"&&"token"in e}function p(e){return e!=null&&typeof e=="object"&&("data"in e&&!!e.data&&typeof e.data=="object"&&"enrich_token"in e.data&&!!e.data.enrich_token&&typeof e.data.enrich_token=="object"&&"userDirectoryJWT"in e.data.enrich_token||"errors"in e&&Array.isArray(e.errors))}function L(e){let a=`${m(e.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,o={token:"",expiry:new Date(0)},t=e.fetch||fetch,i=async()=>{let n=await t(a,{method:"POST",headers:e.headers});switch(n.status){case 200:{let s=await n.json();if(h(s))return s;throw new Error("malformed token response")}case 401:{let s=await n.json();throw u(s)?new Error(s?.error||n.statusText):new Error(n.statusText)}default:{let s=await n.text();throw new Error(s)}}};return async()=>{if(o.expiry.getTime()<=Date.now()-1e3){let n=await i(),s=await f(e.promptqlGraphQLUrl,n.token,e.projectId,t);o.token=s;let d=new Date(n.expiry);if(Number.isNaN(d.getTime())){let l=new Date;l.setHours(1),o.expiry=l}else o.expiry=d}return o.token}}var f=async(e,r,a,o=fetch)=>{let t=await o(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:r,projectId:a},operationName:"EnrichToken"})});switch(t.status){case 200:{let i=await t.json();if(!p(i)||!i.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(i)}`);return i.data.enrich_token.userDirectoryJWT}default:{let i=await t.text();throw new Error(i)}}};0&&(module.exports={createPromptQLAuthTokenGenerator,enrichToken,isEnrichTokenMutationResponse,isLuxAuthPromptQLTokenFailedResponse,isLuxAuthPromptQLTokenSuccessResponse});
1
+ "use strict";var c=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var y=(e,r)=>{for(var a in r)c(e,a,{get:r[a],enumerable:!0})},w=(e,r,a,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of T(r))!x.call(e,t)&&t!==a&&c(e,t,{get:()=>r[t],enumerable:!(o=k(r,t))||o.enumerable});return e};var g=e=>w(c({},"__esModule",{value:!0}),e);var P={};y(P,{createPromptQLAuthTokenGenerator:()=>L,enrichToken:()=>f,isEnrichTokenMutationResponse:()=>p,isLuxAuthPromptQLTokenFailedResponse:()=>u,isLuxAuthPromptQLTokenSuccessResponse:()=>h});module.exports=g(P);function m(e){return e=e?e.trim():"",e?e[e.length-1]==="/"?e.slice(0,e.length-1):e:""}function u(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="failure"}function h(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="success"&&"token"in e}function p(e){return e!=null&&typeof e=="object"&&("data"in e&&!!e.data&&typeof e.data=="object"&&"enrich_token"in e.data&&!!e.data.enrich_token&&typeof e.data.enrich_token=="object"&&"userDirectoryJWT"in e.data.enrich_token||"errors"in e&&Array.isArray(e.errors))}function L(e){let a=`${m(e.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,o={token:"",expiry:new Date(0)},t=e.fetch||fetch,i=async()=>{let n=await t(a,{method:"POST",headers:e.headers});switch(n.status){case 200:{let s=await n.json();if(h(s))return s;throw new Error("malformed token response")}case 401:{let s=await n.json();throw u(s)?new Error(s?.error||n.statusText):new Error(n.statusText)}default:{let s=await n.text();throw new Error(s)}}};return async()=>{if(o.expiry.getTime()<=Date.now()+1e3){let n=await i(),s=await f(e.promptqlGraphQLUrl,n.token,e.projectId,t);o.token=s;let d=new Date(n.expiry);if(Number.isNaN(d.getTime())){let l=new Date;l.setHours(1),o.expiry=l}else o.expiry=d}return o.token}}var f=async(e,r,a,o=fetch)=>{let t=await o(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:r,projectId:a},operationName:"EnrichToken"})});switch(t.status){case 200:{let i=await t.json();if(!p(i)||!i.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(i)}`);return i.data.enrich_token.userDirectoryJWT}default:{let i=await t.text();throw new Error(i)}}};0&&(module.exports={createPromptQLAuthTokenGenerator,enrichToken,isEnrichTokenMutationResponse,isLuxAuthPromptQLTokenFailedResponse,isLuxAuthPromptQLTokenSuccessResponse});
@@ -1 +1 @@
1
- import{c as a,d as b,e as c,f as d,g as e}from"../chunk-B7XM4KRA.mjs";export{d as createPromptQLAuthTokenGenerator,e as enrichToken,c as isEnrichTokenMutationResponse,a as isLuxAuthPromptQLTokenFailedResponse,b as isLuxAuthPromptQLTokenSuccessResponse};
1
+ import{c as a,d as b,e as c,f as d,g as e}from"../chunk-YCHA4U67.mjs";export{d as createPromptQLAuthTokenGenerator,e as enrichToken,c as isEnrichTokenMutationResponse,a as isLuxAuthPromptQLTokenFailedResponse,b as isLuxAuthPromptQLTokenSuccessResponse};
@@ -1 +1 @@
1
- function h(e){return e=e?e.trim():"",e?e[e.length-1]==="/"?e.slice(0,e.length-1):e:""}function f(e){if(e==null)return null;try{Number.parseInt(e)}catch{throw new Error("invalid threadEventId")}return e}function p(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="failure"}function d(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="success"&&"token"in e}function l(e){return e!=null&&typeof e=="object"&&("data"in e&&!!e.data&&typeof e.data=="object"&&"enrich_token"in e.data&&!!e.data.enrich_token&&typeof e.data.enrich_token=="object"&&"userDirectoryJWT"in e.data.enrich_token||"errors"in e&&Array.isArray(e.errors))}function w(e){let a=`${h(e.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,n={token:"",expiry:new Date(0)},s=e.fetch||fetch,o=async()=>{let r=await s(a,{method:"POST",headers:e.headers});switch(r.status){case 200:{let t=await r.json();if(d(t))return t;throw new Error("malformed token response")}case 401:{let t=await r.json();throw p(t)?new Error(t?.error||r.statusText):new Error(r.statusText)}default:{let t=await r.text();throw new Error(t)}}};return async()=>{if(n.expiry.getTime()<=Date.now()-1e3){let r=await o(),t=await m(e.promptqlGraphQLUrl,r.token,e.projectId,s);n.token=t;let c=new Date(r.expiry);if(Number.isNaN(c.getTime())){let u=new Date;u.setHours(1),n.expiry=u}else n.expiry=c}return n.token}}var m=async(e,i,a,n=fetch)=>{let s=await n(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:i,projectId:a},operationName:"EnrichToken"})});switch(s.status){case 200:{let o=await s.json();if(!l(o)||!o.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(o)}`);return o.data.enrich_token.userDirectoryJWT}default:{let o=await s.text();throw new Error(o)}}};export{h as a,f as b,p as c,d,l as e,w as f,m as g};
1
+ function h(e){return e=e?e.trim():"",e?e[e.length-1]==="/"?e.slice(0,e.length-1):e:""}function f(e){if(e==null)return null;try{Number.parseInt(e)}catch{throw new Error("invalid threadEventId")}return e}function p(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="failure"}function d(e){return e!=null&&typeof e=="object"&&"status"in e&&e.status==="success"&&"token"in e}function l(e){return e!=null&&typeof e=="object"&&("data"in e&&!!e.data&&typeof e.data=="object"&&"enrich_token"in e.data&&!!e.data.enrich_token&&typeof e.data.enrich_token=="object"&&"userDirectoryJWT"in e.data.enrich_token||"errors"in e&&Array.isArray(e.errors))}function w(e){let a=`${h(e.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,n={token:"",expiry:new Date(0)},s=e.fetch||fetch,o=async()=>{let r=await s(a,{method:"POST",headers:e.headers});switch(r.status){case 200:{let t=await r.json();if(d(t))return t;throw new Error("malformed token response")}case 401:{let t=await r.json();throw p(t)?new Error(t?.error||r.statusText):new Error(r.statusText)}default:{let t=await r.text();throw new Error(t)}}};return async()=>{if(n.expiry.getTime()<=Date.now()+1e3){let r=await o(),t=await m(e.promptqlGraphQLUrl,r.token,e.projectId,s);n.token=t;let c=new Date(r.expiry);if(Number.isNaN(c.getTime())){let u=new Date;u.setHours(1),n.expiry=u}else n.expiry=c}return n.token}}var m=async(e,i,a,n=fetch)=>{let s=await n(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:i,projectId:a},operationName:"EnrichToken"})});switch(s.status){case 200:{let o=await s.json();if(!l(o)||!o.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(o)}`);return o.data.enrich_token.userDirectoryJWT}default:{let o=await s.text();throw new Error(o)}}};export{h as a,f as b,p as c,d,l as e,w as f,m as g};