@distilled.cloud/core 1.0.0-rc.18 → 1.0.0-rc.19

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 (112) hide show
  1. package/lib/_bundle/base.js +2 -2
  2. package/lib/_bundle/base.js.map +1 -1
  3. package/lib/_bundle/graphql.js +2 -2
  4. package/lib/_bundle/graphql.js.map +1 -1
  5. package/lib/_bundle/grpc.js +2 -0
  6. package/lib/_bundle/grpc.js.map +1 -0
  7. package/lib/_bundle/rest.js +1 -1
  8. package/lib/_bundle/rest.js.map +1 -1
  9. package/lib/_bundle/xml.js +1 -1
  10. package/lib/_bundle/xml.js.map +1 -1
  11. package/lib/annotations.d.ts +2 -0
  12. package/lib/annotations.d.ts.map +1 -1
  13. package/lib/annotations.js +1 -1
  14. package/lib/annotations.js.map +1 -1
  15. package/lib/api.d.ts +37 -1
  16. package/lib/api.d.ts.map +1 -1
  17. package/lib/api.js +1 -1
  18. package/lib/errors.d.ts +1 -0
  19. package/lib/errors.d.ts.map +1 -1
  20. package/lib/errors.js +1 -1
  21. package/lib/graphql.d.ts +12 -5
  22. package/lib/graphql.d.ts.map +1 -1
  23. package/lib/graphql.types.d.ts.map +1 -1
  24. package/lib/grpc-transport-cloudflare-http2.d.ts +7 -0
  25. package/lib/grpc-transport-cloudflare-http2.d.ts.map +1 -0
  26. package/lib/grpc-transport-cloudflare-http2.js +6 -0
  27. package/lib/grpc-transport-cloudflare-http2.js.map +1 -0
  28. package/lib/grpc-transport-cloudflare-sockets.d.ts +7 -0
  29. package/lib/grpc-transport-cloudflare-sockets.d.ts.map +1 -0
  30. package/lib/grpc-transport-cloudflare-sockets.js +5 -0
  31. package/lib/grpc-transport-cloudflare-sockets.js.map +1 -0
  32. package/lib/grpc-transport-node-http2.d.ts +19 -0
  33. package/lib/grpc-transport-node-http2.d.ts.map +1 -0
  34. package/lib/grpc-transport-node-http2.js +2 -0
  35. package/lib/grpc-transport-node-http2.js.map +1 -0
  36. package/lib/grpc-transport.d.ts +76 -0
  37. package/lib/grpc-transport.d.ts.map +1 -0
  38. package/lib/grpc-transport.js +1 -0
  39. package/lib/hpack.d.ts +34 -0
  40. package/lib/hpack.d.ts.map +1 -0
  41. package/lib/hpack.js +2 -0
  42. package/lib/hpack.js.map +1 -0
  43. package/lib/index.d.ts +3 -0
  44. package/lib/index.d.ts.map +1 -1
  45. package/lib/index.js +3 -0
  46. package/lib/pagination.d.ts +22 -2
  47. package/lib/pagination.d.ts.map +1 -1
  48. package/lib/pagination.js +1 -1
  49. package/lib/protobuf.d.ts +92 -0
  50. package/lib/protobuf.d.ts.map +1 -0
  51. package/lib/protobuf.js +1 -0
  52. package/lib/protocol-grpc.d.ts +86 -0
  53. package/lib/protocol-grpc.d.ts.map +1 -0
  54. package/lib/protocol-grpc.js +1 -0
  55. package/lib/protocol-http.d.ts +11 -6
  56. package/lib/protocol-http.d.ts.map +1 -1
  57. package/lib/protocol-rest.d.ts +12 -8
  58. package/lib/protocol-rest.d.ts.map +1 -1
  59. package/lib/response-validation.d.ts +1 -1
  60. package/lib/response-validation.d.ts.map +1 -1
  61. package/lib/sdk-error.d.ts +27 -0
  62. package/lib/sdk-error.d.ts.map +1 -0
  63. package/lib/sdk-error.js +1 -0
  64. package/lib/sensitive.d.ts +28 -0
  65. package/lib/sensitive.d.ts.map +1 -0
  66. package/lib/sensitive.js +2 -0
  67. package/lib/sensitive.js.map +1 -0
  68. package/lib/telemetry-debug.d.ts +2 -10
  69. package/lib/telemetry-debug.d.ts.map +1 -1
  70. package/lib/telemetry-debug.js +1 -1
  71. package/lib/telemetry-debug.js.map +1 -1
  72. package/lib/telemetry-stream.d.ts +3 -1
  73. package/lib/telemetry-stream.d.ts.map +1 -1
  74. package/lib/telemetry-stream.js +1 -1
  75. package/lib/telemetry-stream.js.map +1 -1
  76. package/lib/telemetry.d.ts +23 -4
  77. package/lib/telemetry.d.ts.map +1 -1
  78. package/lib/telemetry.js +2 -2
  79. package/lib/telemetry.js.map +1 -1
  80. package/lib/trait.d.ts +7 -0
  81. package/lib/trait.d.ts.map +1 -1
  82. package/lib/trait.js +1 -1
  83. package/lib/xml.d.ts.map +1 -1
  84. package/package.json +3 -3
  85. package/src/annotations.ts +16 -0
  86. package/src/api.ts +199 -25
  87. package/src/errors.ts +4 -0
  88. package/src/graphql.ts +68 -45
  89. package/src/graphql.types.ts +5 -1
  90. package/src/grpc-transport-cloudflare-http2.ts +494 -0
  91. package/src/grpc-transport-cloudflare-sockets.ts +299 -0
  92. package/src/grpc-transport-node-http2.ts +234 -0
  93. package/src/grpc-transport.ts +118 -0
  94. package/src/hpack.ts +331 -0
  95. package/src/index.ts +3 -0
  96. package/src/pagination.ts +75 -3
  97. package/src/protobuf.ts +1332 -0
  98. package/src/protocol-grpc.ts +641 -0
  99. package/src/protocol-http.ts +30 -30
  100. package/src/protocol-rest.ts +49 -118
  101. package/src/response-validation.ts +4 -2
  102. package/src/sdk-error.ts +33 -0
  103. package/src/sensitive.ts +154 -0
  104. package/src/telemetry-debug.ts +65 -21
  105. package/src/telemetry-stream.ts +16 -7
  106. package/src/telemetry.ts +91 -27
  107. package/src/trait.ts +10 -0
  108. package/src/xml.ts +10 -1
  109. package/lib/debug.d.ts +0 -2
  110. package/lib/debug.d.ts.map +0 -1
  111. package/lib/debug.js +0 -1
  112. package/src/debug.ts +0 -11
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc-transport-cloudflare-sockets.d.ts","sourceRoot":"","sources":["../src/grpc-transport-cloudflare-sockets.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAGrD,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAoQ3C,wFAAwF;AACxF,eAAO,MAAM,MAAM,EAAE,UAAU,CAAC,UAQ/B,CAAC;AAEF,+DAA+D;AAC/D,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAwC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import{grpc_transport$isResponseStatus as e,grpc_transport$layer as t,grpc_transport$respond as n}from"./_bundle/grpc.js";import*as r from"effect/Effect";import*as i from"effect/http/HttpClient";import*as a from"effect/http/HttpClientError";const o=`cloudflare:sockets`;let s;const connectFn=()=>s??=import(o).then(e=>e.connect);const c=/* @__PURE__ */ new Set([`host`,`connection`,`keep-alive`,`content-length`,`transfer-encoding`,`upgrade`]);const l=/*@__PURE__*/ new TextEncoder;const u=/*@__PURE__*/ new TextDecoder;const concat=(e,t)=>{if(e.length===0)return t;const n=new Uint8Array(e.length+t.length);n.set(e);n.set(t,e.length);return n};const indexOf=(e,t,n=0)=>{outer:for(let r=n;r+t.length<=e.length;r++){for(let n=0;n<t.length;n++)if(e[r+n]!==t[n])continue outer;return r}return-1};const d=[13,10];const f=[13,10,13,10];const parseHeaderLines=e=>{const t=/* @__PURE__ */ new Map;for(const n of e){const e=n.indexOf(`:`);if(e<=0)continue;const r=n.slice(0,e).trim().toLowerCase();const i=n.slice(e+1).trim();const a=t.get(r);t.set(r,a===void 0?i:`${a}, ${i}`)}return Object.fromEntries(t)};var ProtocolViolation=class extends Error{};const lengthDecoder=e=>{let t=e;return{trailers:{},feed(e){const n=e.subarray(0,t);t-=n.length;return{data:n.length>0?[n]:[],done:t===0}},end:()=>t===0}};const untilCloseDecoder=()=>({trailers:{},feed:e=>({data:e.length>0?[e]:[],done:false}),end:()=>true});const chunkedDecoder=()=>{let e=/* @__PURE__ */ new Uint8Array(0);let t=`size`;let n=0;let r={};return{get trailers(){return r},feed(i){e=concat(e,i);const a=[];for(;;)if(t===`size`){const r=indexOf(e,d);if(r<0)break;const i=Number.parseInt(u.decode(e.subarray(0,r)).split(`;`)[0],16);if(Number.isNaN(i))throw new ProtocolViolation(`invalid chunk size`);e=e.subarray(r+2);if(i===0)t=`trailers`;else{t=`data`;n=i}}else if(t===`data`){if(e.length<n+2){const t=e.subarray(0,Math.min(e.length,n));if(t.length>0)a.push(t.slice());n-=t.length;e=e.subarray(t.length);break}if(n>0)a.push(e.slice(0,n));e=e.subarray(n+2);n=0;t=`size`}else if(t===`trailers`){if(e[0]===13&&e[1]===10){t=`done`;break}const n=indexOf(e,f);if(n<0)break;r=parseHeaderLines(u.decode(e.subarray(0,n)).split(`\r
2
+ `));t=`done`;break}else break;return{data:a,done:t===`done`}},end:()=>t===`done`}};const decoderFor=e=>(e[`transfer-encoding`]??``).toLowerCase().includes(`chunked`)?chunkedDecoder():e[`content-length`]!==void 0?lengthDecoder(Number(e[`content-length`])):untilCloseDecoder();const transportError=(e,t)=>new a.HttpClientError({reason:new a.TransportError({request:e,cause:t,description:`request over cloudflare:sockets failed`})});const send=async(t,n,r)=>{const i=await connectFn();const a=n.protocol===`https:`;const o=i({hostname:n.hostname,port:Number(n.port||(a?443:80))},{secureTransport:a?`on`:`off`,allowHalfOpen:false});const close=()=>void o.close().catch(()=>void 0);r.addEventListener(`abort`,close,{once:true});const s=t.body._tag===`Uint8Array`?t.body.body:/* @__PURE__ */ new Uint8Array(0);const d=[`${t.method} ${n.pathname}${n.search} HTTP/1.1`,`host: ${n.host}`];for(const[e,n]of Object.entries(t.headers))if(!c.has(e))d.push(`${e}: ${n}`);d.push(`content-length: ${s.length}`,`connection: close`,``,``);const p=o.writable.getWriter();await p.write(concat(l.encode(d.join(`\r
3
+ `)),s));p.releaseLock();const m=o.readable.getReader();let h=/* @__PURE__ */ new Uint8Array(0);let g=-1;while((g=indexOf(h,f))<0){const{value:e,done:t}=await m.read();if(t)throw new ProtocolViolation(`connection closed before the response headers`);h=concat(h,e)}const[_=``,...v]=u.decode(h.subarray(0,g)).split(`\r
4
+ `);const y=Number(_.split(` `)[1]??0);if(!e(y))throw new ProtocolViolation(`invalid HTTP status ${y}`);const b=parseHeaderLines(v);const x=decoderFor(b);let S;const C=new Promise(e=>S=e);const finish=()=>{r.removeEventListener(`abort`,close);S(x.trailers);close()};let w=h.subarray(g+4);return{status:y,headers:b,body:new ReadableStream({async pull(e){for(;;){let t;if(w!==void 0){t=w;w=void 0}else{const{value:n,done:r}=await m.read();if(r){finish();if(x.end())e.close();else e.error(new ProtocolViolation(`connection closed mid-body`));return}t=n}const{data:n,done:r}=x.feed(t);for(const t of n)e.enqueue(t);if(r){finish();e.close();return}if(n.length>0)return}},cancel(){finish()}}),trailers:C,reliableTrailers:false}};const p=/*@__PURE__*/ i.make((e,t,i)=>r.map(r.tryPromise({try:()=>send(e,t,i),catch:t=>transportError(e,t)}),t=>n(e,t)));const m=/*@__PURE__*/ t(p);export{p as client,m as layer};
5
+ //# sourceMappingURL=grpc-transport-cloudflare-sockets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc-transport-cloudflare-sockets.js","names":["isResponseStatus","layer$1","respond","Effect","HttpClient","HttpClientError","SOCKETS_MODULE","sockets","module","FRAMING_HEADERS","encoder","decoder","a","b","out","i","from","pattern","bytes","j","CRLF","CRLFCRLF","joined","line","lines","colon","key","value","previous","left","length","take","input","buf","state","trailers","data","eol","size","end","headers","connect","tls","url","socket","signal","body","request","head","writer","reader","done","statusLine","status","framing","resolveTrailers","resolve","pending","controller","chunk","client","cause","reply","layer"],"sources":["../src/grpc-transport-cloudflare-sockets.ts"],"mappings":"iPA8CA,MAAMM,EAAiB,qBACvB,IAAIC,EACJ,MAAM,cACH,IAAa,OAAOD,EAAe,CAAmC,KACpE,GAAWE,EAAO,OACrB,EAGF,MAAMC,kBAAkB,IAAI,IAAI,CAC9B,OACA,aACA,aACA,iBACA,oBACA,SACF,CAAC,EAED,MAAMC,gBAAwB,IAAI,YAClC,MAAMC,gBAAwB,IAAI,YAElC,MAAM,QAAU,EAAe,IAA+C,CAC5E,GAAIC,EAAE,SAAW,EAAG,OAAOC,EAC3B,MAAMC,EAAM,IAAI,WAAWF,EAAE,OAASC,EAAE,MAAM,EAC9CC,EAAI,IAAIF,CAAC,EACTE,EAAI,IAAID,EAAGD,EAAE,MAAM,EACnB,OAAOE,CACT,EAEA,MAAM,SAAW,EAAmB,EA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,IAAA,GAAW,CACzB,EAAQA,EACR,EAAU,IAAA,EACZ,KAAO,CACL,KAAM,CAAE,QAAO,QAAS,MAAMP,EAAO,KAAK,EAC1C,GAAIC,EAAM,CACR,OAAO,EACP,GAAIG,EAAQ,IAAI,EAAGI,EAAW,MAAM,OAC/BA,EAAW,MAAM,IAAI,kBAAkB,4BAA4B,CAAC,EACzE,MACF,CACA,EAAQ/B,CACV,CACA,KAAM,CAAE,OAAM,QAAS2B,EAAQ,KAAKtB,CAAK,EACzC,IAAK,MAAM2B,KAASvB,EAAMsB,EAAW,QAAQC,CAAK,EAClD,GAAIR,EAAM,CACR,OAAO,EACPO,EAAW,MAAM,EACjB,MACF,CACA,GAAItB,EAAK,OAAS,EAAG,MACvB,CACF,EACA,QAAS,CACP,OAAO,CACT,CACF,CAEqC,EAAG,WAAU,iBAAkB,KAAM,CAC5E,EAGA,MAAawB,EAA8C,gBAAW,MAAM,EAAS,EAAK,IACxFzD,EAAO,IACLA,EAAO,WAAW,CAChB,QAAW,KAAK4C,EAASJ,EAAKE,CAAM,EACpC,MAAQ,GAAU,eAAeE,EAASc,CAAK,CACjD,CAAC,EACA,GAAU3D,EAAQ6C,EAASe,CAAK,CACnC,CACF,EAGA,MAAaC,EAA0C,gBAAeH,CAAM"}
@@ -0,0 +1,19 @@
1
+ import * as HttpClient from "effect/http/HttpClient";
2
+ import type * as Layer from "effect/Layer";
3
+ /** An `HttpClient` that sends each request as an HTTP/2 stream. */
4
+ export declare const client: HttpClient.HttpClient;
5
+ /**
6
+ * An `HttpClient` that sends each request as an HTTP/2 stream over the Unix
7
+ * domain socket at `path`, whatever the request's host. Requests share one
8
+ * session per socket.
9
+ *
10
+ * ```ts
11
+ * program.pipe(Effect.provide(NodeHttp2.unixLayer("/run/modal.sock")));
12
+ * ```
13
+ */
14
+ export declare const unixSocket: (path: string) => HttpClient.HttpClient;
15
+ /** Send gRPC calls over HTTP/2 in this scope. */
16
+ export declare const layer: Layer.Layer<never>;
17
+ /** Send gRPC calls over HTTP/2 on the Unix domain socket at `path` in this scope. */
18
+ export declare const unixLayer: (path: string) => Layer.Layer<never>;
19
+ //# sourceMappingURL=grpc-transport-node-http2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc-transport-node-http2.d.ts","sourceRoot":"","sources":["../src/grpc-transport-node-http2.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAIrD,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAiM3C,mEAAmE;AACnE,eAAO,MAAM,MAAM,EAAE,UAAU,CAAC,UAA0C,CAAC;AAE3E;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,UAAU,CAAC,UAAwB,CAAC;AAE9E,iDAAiD;AACjD,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAwC,CAAC;AAE9E,qFAAqF;AACrF,eAAO,MAAM,SAAS,SAAU,MAAM,KAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAqC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import{grpc_transport$isResponseStatus as e,grpc_transport$layer as t,grpc_transport$respond as n}from"./_bundle/grpc.js";import*as r from"effect/Effect";import*as i from"effect/http/HttpClient";import*as a from"effect/http/HttpClientError";const builtin=e=>globalThis.process?.getBuiltinModule?.(e);const http2Module=()=>builtin(`node:http2`);const o=/* @__PURE__ */ new Map;const keyOf=e=>`socketPath`in e?`unix:${e.socketPath}`:e.origin;const connect=(e,t)=>{if(!(`socketPath`in t))return e.connect(t.origin);const n=builtin(`node:net`);if(n===void 0)throw new Error(`node:net is not available in this runtime`);return e.connect(`http://localhost`,{createConnection:()=>n.connect(t.socketPath)})};const sessionFor=(e,t)=>{const n=keyOf(t);const r=o.get(n);if(r&&!r.session.closed&&!r.session.destroyed)return r;const i={session:connect(e,t),active:0};i.session.unref();const drop=()=>{if(o.get(n)===i)o.delete(n)};i.session.on(`error`,drop);i.session.on(`close`,drop);i.session.on(`goaway`,drop);o.set(n,i);return i};const s=/* @__PURE__ */ new Set([`host`,`connection`,`keep-alive`,`content-length`,`transfer-encoding`,`upgrade`]);const plain=e=>{const t={};for(const[n,r]of Object.entries(e)){if(n.startsWith(`:`)||r===void 0)continue;t[n]=Array.isArray(r)?r.join(`, `):String(r)}return t};const transportError=(e,t)=>new a.HttpClientError({reason:new a.TransportError({request:e,cause:t,description:`HTTP/2 request failed`})});const bodyOf=e=>e.body._tag===`Uint8Array`?e.body.body:void 0;const make=t=>i.make((i,a,o)=>r.callback(c=>{const l=http2Module();if(l===void 0){c(r.fail(transportError(i,/* @__PURE__ */ new Error(`node:http2 is not available in this runtime`))));return}let u;try{u=sessionFor(l,t===void 0?{origin:a.origin}:{socketPath:t})}catch(e){c(r.fail(transportError(i,e)));return}if(u.active++===0)u.session.ref();let d=false;const settle=()=>{if(d)return;d=true;if(--u.active===0&&!u.session.destroyed)u.session.unref()};const f={};for(const[e,t]of Object.entries(i.headers))if(!s.has(e))f[e]=t;const p=u.session.request({":method":i.method,":path":`${a.pathname}${a.search}`,...f});const onAbort=()=>p.close(l.constants.NGHTTP2_CANCEL);if(o.aborted)onAbort();else o.addEventListener(`abort`,onAbort,{once:true});let m={};let h;const g=new Promise(e=>h=e);p.on(`trailers`,e=>m=plain(e));let _=false;p.on(`response`,t=>{_=true;let a=true;const s=new ReadableStream({start(e){p.on(`data`,t=>{if(a)e.enqueue(new Uint8Array(t))});p.on(`end`,()=>{if(a)e.close();a=false;h(m)});p.on(`error`,t=>{if(a)e.error(t);a=false;h(m)});p.on(`close`,()=>{settle();o.removeEventListener(`abort`,onAbort);h(m)})},cancel(){a=false;p.close(l.constants.NGHTTP2_CANCEL)}});const u=Number(t[`:status`]??0);if(!e(u)){p.close(l.constants.NGHTTP2_CANCEL);c(r.fail(transportError(i,/* @__PURE__ */ new Error(`invalid HTTP status ${u}`))));return}c(r.succeed(n(i,{status:u,headers:plain(t),body:s,trailers:g})))});p.on(`error`,e=>{if(_)return;settle();o.removeEventListener(`abort`,onAbort);c(r.fail(transportError(i,e)))});const v=bodyOf(i);p.end(v===void 0?void 0:v)}));const c=/*@__PURE__*/ make(void 0);const unixSocket=e=>make(e);const l=/*@__PURE__*/ t(c);const unixLayer=e=>t(unixSocket(e));export{c as client,l as layer,unixLayer,unixSocket};
2
+ //# sourceMappingURL=grpc-transport-node-http2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc-transport-node-http2.js","names":["transportLayer","isResponseStatus","layer$1","respond","Effect","HttpClient","HttpClientError","id","sessions","target","http2","net","key","existing","entry","CONNECTION_HEADERS","out","value","incoming","request","resume","socketPath","url","error","settled","headers","stream","signal","trailers","resolveTrailers","trailersDone","resolve","started","open","body","controller","chunk","status","client","path","layer"],"sources":["../src/grpc-transport-node-http2.ts"],"mappings":"iPAmCA,MAAM,QAAc,GAEhB,WACA,SAAS,mBAAmBO,CAAE,EAElC,MAAM,gBAAuC,QAAe,YAAY,EAExE,MAAMC,kBAAW,IAAI,IAKrB,MAAM,MAAS,GACb,eAAgBC,EAAS,QAAQA,EAAO,aAAeA,EAAO,OAEhE,MAAM,SAAW,EAAc,IAA4B,CACzD,GAAI,EAAE,eAAgBA,GAAS,OAAOC,EAAM,QAAQD,EAAO,MAAM,EACjE,MAAME,EAAM,QAAa,UAAU,EACnC,GAAIA,IAAQ,IAAA,GAAW,MAAM,IAAI,MAAM,2CAA2C,EAElF,OAAOD,EAAM,QAAQ,mBAAoB,CACvC,qBAAwBC,EAAI,QAAQF,EAAO,UAAU,CACvD,CAAC,CACH,EAEA,MAAM,YAAc,EAAc,IAAmB,CACnD,MAAMG,EAAM,MAAMH,CAAM,EACxB,MAAMI,EAAWL,EAAS,IAAII,CAAG,EACjC,GAAIC,GAAY,CAACA,EAAS,QAAQ,QAAU,CAACA,EAAS,QAAQ,UAAW,OAAOA,EAChF,MAAMC,EAAQ,CAAE,QAAS,QAAQJ,EAAOD,CAAM,EAAG,OAA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EAChC,EAAO,MACPM,EAAgBD,CAAQ,CAC1B,CAAC,EACDF,EAAO,GAAG,YAAe,CACvB,OAAO,EACPC,EAAO,oBAAoB,QAAS,OAAO,EAC3CE,EAAgBD,CAAQ,CAC1B,CAAC,CACH,EACA,QAAS,CACP,EAAO,MACPF,EAAO,MAAMhB,EAAM,UAAU,cAAc,CAC7C,CACF,CAAC,EACD,MAAM2B,EAAS,OAAOnB,EAAS,YAAc,CAAC,EAC9C,GAAI,CAACjB,EAAiBoC,CAAM,EAAG,CAC7BX,EAAO,MAAMhB,EAAM,UAAU,cAAc,EAC3CU,EACEhB,EAAO,KAAK,eAAee,kBAAS,IAAI,MAAM,uBAAuBkB,GAAQ,CAAC,CAAC,CACjF,EACA,MACF,CACAjB,EACEhB,EAAO,QACLD,EAAQgB,EAAS,CAAE,SAAQ,QAAS,MAAMD,CAAQ,EAAG,OAAM,SAAUY,CAAa,CAAC,CACrF,CACF,CACF,CAAC,EACDJ,EAAO,GAAG,QAAU,GAAU,CAC5B,GAAIM,EAAS,OACb,OAAO,EACPL,EAAO,oBAAoB,QAAS,OAAO,EAC3CP,EAAOhB,EAAO,KAAK,eAAee,EAASI,CAAK,CAAC,CAAC,CACpD,CAAC,EACD,MAAMW,EAAO,OAAOf,CAAO,EAC3BO,EAAO,IAAIQ,IAAS,IAAA,GAAY,IAAA,GAAYA,CAAI,CAClD,CACF,CACF,EAGF,MAAaI,EAA8C,mBAAK,IAAA,EAAS,EAWzE,MAAa,WAAc,GAAwC,KAAKC,CAAI,EAG5E,MAAaC,EAA0C,gBAAeF,CAAM,EAG5E,MAAa,UAAa,GAAqCtC,EAAe,WAAWuC,CAAI,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * How gRPC calls reach a server.
3
+ *
4
+ * A transport is an Effect `HttpClient`: it sends the request
5
+ * `protocol-grpc` builds (`POST`, `application/grpc`, one frame) and returns
6
+ * the response with its body as a stream, so a server-streaming call reads
7
+ * each message as it arrives. gRPC puts the call's status in the trailers;
8
+ * a transport that can read them hands them over with {@link respond}, and
9
+ * the protocol reads them with {@link trailersOf} once the body has ended.
10
+ *
11
+ * By default `protocol-grpc` sends through the caller's `HttpClient`
12
+ * (`fetch`), which works where a proxy bridges HTTP/1.1 to gRPC (envoy) and
13
+ * puts the status in the headers. Provide a different transport for one
14
+ * scope with {@link layer}:
15
+ *
16
+ * - `@distilled.cloud/core/grpc-transport-node-http2` speaks HTTP/2 with
17
+ * `node:http2`, for servers that offer nothing else;
18
+ * - `@distilled.cloud/core/grpc-transport-cloudflare-sockets` speaks HTTP/1.1
19
+ * over a `cloudflare:sockets` TLS socket, for a Cloudflare Worker calling a
20
+ * gRPC server that is itself behind Cloudflare (a Worker's `fetch` to such
21
+ * a site takes Cloudflare's internal path, which resets gRPC upstreams);
22
+ * - `@distilled.cloud/core/grpc-transport-cloudflare-http2` speaks HTTP/2
23
+ * over a `cloudflare:sockets` socket, for a Cloudflare Worker calling a
24
+ * server that offers nothing else (workerd has no working `node:http2`).
25
+ *
26
+ * None is imported by this module, so a bundle only carries the ones it
27
+ * provides.
28
+ */
29
+ import * as Context from "effect/Context";
30
+ import * as Effect from "effect/Effect";
31
+ import type * as HttpClient from "effect/http/HttpClient";
32
+ import type * as HttpClientRequest from "effect/http/HttpClientRequest";
33
+ import * as HttpClientResponse from "effect/http/HttpClientResponse";
34
+ import * as Layer from "effect/Layer";
35
+ /**
36
+ * The `HttpClient` gRPC calls go through. `undefined` (the default) sends
37
+ * through the caller's `HttpClient`.
38
+ */
39
+ export declare const GrpcTransport: Context.Reference<HttpClient.HttpClient | undefined>;
40
+ /** Send gRPC calls in this scope through `client`. */
41
+ export declare const layer: (client: HttpClient.HttpClient) => Layer.Layer<never>;
42
+ /** Header and trailer names are lowercase; values as received. */
43
+ export type Trailers = Readonly<Record<string, string>>;
44
+ /**
45
+ * Whether `status` is a final HTTP status a response can carry (200 to 599).
46
+ * A transport fails the call with a transport error for any other.
47
+ */
48
+ export declare const isResponseStatus: (status: number) => boolean;
49
+ /**
50
+ * Build a transport's response: the status, the headers, the body as it
51
+ * arrives, and the trailers, which settle once the body has ended.
52
+ */
53
+ export declare const respond: (request: HttpClientRequest.HttpClientRequest, reply: {
54
+ readonly status: number;
55
+ readonly headers: Trailers;
56
+ readonly body: ReadableStream<Uint8Array>;
57
+ readonly trailers: Promise<Trailers>;
58
+ /**
59
+ * Whether the trailers always arrive. HTTP/2 delivers them end to end;
60
+ * over HTTP/1.1 a bridging proxy may drop them, so the protocol then
61
+ * treats a reply with messages and no status as OK.
62
+ * @default true
63
+ */
64
+ readonly reliableTrailers?: boolean;
65
+ }) => HttpClientResponse.HttpClientResponse;
66
+ /**
67
+ * Whether `response` came from a transport whose trailers always arrive
68
+ * ({@link respond} with `reliableTrailers`), so a missing status is an error.
69
+ */
70
+ export declare const hasTrailers: (response: HttpClientResponse.HttpClientResponse) => boolean;
71
+ /**
72
+ * The trailers of a response a transport built with {@link respond}, read
73
+ * after its body; empty for any other response (`fetch` exposes none).
74
+ */
75
+ export declare const trailersOf: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<Trailers>;
76
+ //# sourceMappingURL=grpc-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grpc-transport.d.ts","sourceRoot":"","sources":["../src/grpc-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,kBAAkB,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,aAAa,sDAGzB,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,KAAK,WAAY,UAAU,CAAC,UAAU,KAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CACjC,CAAC;AAEvC,kEAAkE;AAClE,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AASxD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,WAAY,MAAM,KAAG,OACU,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,OAAO,YACT,iBAAiB,CAAC,iBAAiB,SACrC;IACL,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IAC1C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACrC,KACA,kBAAkB,CAAC,kBAarB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,aAAc,kBAAkB,CAAC,kBAAkB,KAAG,OAClB,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,UAAU,aACX,kBAAkB,CAAC,kBAAkB,KAC9C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAKxB,CAAC"}
@@ -0,0 +1 @@
1
+ export { grpc_transport$GrpcTransport as GrpcTransport, grpc_transport$hasTrailers as hasTrailers, grpc_transport$isResponseStatus as isResponseStatus, grpc_transport$layer as layer, grpc_transport$respond as respond, grpc_transport$trailersOf as trailersOf } from "./_bundle/grpc.js";
package/lib/hpack.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * HPACK (RFC 7541), the header compression of HTTP/2, for a client that
3
+ * speaks HTTP/2 without a platform implementation
4
+ * (`grpc-transport-cloudflare-http2`).
5
+ *
6
+ * {@link makeDecoder} reads everything a server may send: the static and
7
+ * dynamic tables, every literal form, and Huffman-coded strings.
8
+ * {@link encode} writes the simplest valid form, each field as a literal
9
+ * with no indexing and no Huffman coding, so a connection keeps no encoder
10
+ * state.
11
+ */
12
+ /** A header block that breaks RFC 7541. HTTP/2 treats it as a connection error. */
13
+ export declare class HpackError extends Error {
14
+ }
15
+ /** A header field: a lowercase name and its value. */
16
+ export type HeaderField = readonly [name: string, value: string];
17
+ /** Decode a Huffman-coded string (RFC 7541 section 5.2). */
18
+ export declare const huffmanDecode: (bytes: Uint8Array) => Uint8Array;
19
+ /** Reads the header blocks of one connection, in the order they arrive. */
20
+ export interface HpackDecoder {
21
+ /** The fields of one complete header block. */
22
+ decode(block: Uint8Array): HeaderField[];
23
+ }
24
+ /**
25
+ * A decoder for one connection. `maxTableSize` is the dynamic table size
26
+ * this end allows (`SETTINGS_HEADER_TABLE_SIZE`, 4096 unless set).
27
+ */
28
+ export declare const makeDecoder: (maxTableSize?: number) => HpackDecoder;
29
+ /**
30
+ * A header block for `fields`, each a literal without indexing (RFC 7541
31
+ * section 6.2.2). Names must be lowercase, pseudo-headers first.
32
+ */
33
+ export declare const encode: (fields: ReadonlyArray<HeaderField>) => Uint8Array;
34
+ //# sourceMappingURL=hpack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hpack.d.ts","sourceRoot":"","sources":["../src/hpack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mFAAmF;AACnF,qBAAa,UAAW,SAAQ,KAAK;CAAG;AAExC,sDAAsD;AACtD,MAAM,MAAM,WAAW,GAAG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AA0HjE,4DAA4D;AAC5D,eAAO,MAAM,aAAa,UAAW,UAAU,KAAG,UA4BjD,CAAC;AAmBF,2EAA2E;AAC3E,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,EAAE,CAAC;CAC1C;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,6BAA0B,YAiGjD,CAAC;AAyBF;;;GAGG;AACH,eAAO,MAAM,MAAM,WAAY,aAAa,CAAC,WAAW,CAAC,KAAG,UAQ3D,CAAC"}
package/lib/hpack.js ADDED
@@ -0,0 +1,2 @@
1
+ var HpackError=class extends Error{};const e=[[`:authority`,``],[`:method`,`GET`],[`:method`,`POST`],[`:path`,`/`],[`:path`,`/index.html`],[`:scheme`,`http`],[`:scheme`,`https`],[`:status`,`200`],[`:status`,`204`],[`:status`,`206`],[`:status`,`304`],[`:status`,`400`],[`:status`,`404`],[`:status`,`500`],[`accept-charset`,``],[`accept-encoding`,`gzip, deflate`],[`accept-language`,``],[`accept-ranges`,``],[`accept`,``],[`access-control-allow-origin`,``],[`age`,``],[`allow`,``],[`authorization`,``],[`cache-control`,``],[`content-disposition`,``],[`content-encoding`,``],[`content-language`,``],[`content-length`,``],[`content-location`,``],[`content-range`,``],[`content-type`,``],[`cookie`,``],[`date`,``],[`etag`,``],[`expect`,``],[`expires`,``],[`from`,``],[`host`,``],[`if-match`,``],[`if-modified-since`,``],[`if-none-match`,``],[`if-range`,``],[`if-unmodified-since`,``],[`last-modified`,``],[`link`,``],[`location`,``],[`max-forwards`,``],[`proxy-authenticate`,``],[`proxy-authorization`,``],[`range`,``],[`referer`,``],[`refresh`,``],[`retry-after`,``],[`server`,``],[`set-cookie`,``],[`strict-transport-security`,``],[`transfer-encoding`,``],[`user-agent`,``],[`vary`,``],[`via`,``],[`www-authenticate`,``]];const t=[13,23,28,28,28,28,28,28,28,24,30,28,28,30,28,28,28,28,28,28,28,28,30,28,28,28,28,28,28,28,28,28,6,10,10,12,13,6,8,11,10,10,8,11,8,6,6,6,5,5,5,6,6,6,6,6,6,6,7,8,15,6,12,10,13,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,7,8,13,19,13,14,6,15,5,6,5,6,5,6,6,6,5,7,7,6,6,6,5,6,7,6,5,5,6,7,7,7,7,7,15,11,14,13,28,20,22,20,20,22,22,22,23,22,23,23,23,23,23,24,23,24,24,22,23,24,23,23,23,23,21,22,23,22,23,23,24,22,21,20,22,22,23,23,21,23,22,22,24,21,22,23,23,21,21,22,21,23,22,23,23,20,22,22,22,23,22,22,23,26,26,20,19,22,23,22,25,26,26,26,27,27,26,24,25,19,21,26,27,27,26,27,24,21,21,26,26,28,27,27,27,20,24,20,21,22,21,21,23,22,22,25,25,24,24,26,23,26,27,26,26,27,27,27,27,27,28,27,27,27,27,27,26,30];const n=256;const buildHuffmanTree=()=>{const e=t.map((e,t)=>({bits:e,symbol:t})).sort((e,t)=>e.bits-t.bits);const n=[0,0];let r=0;let i=0;for(const{bits:t,symbol:a}of e){r<<=t-i;i=t;let e=0;for(let i=t-1;i>=0;i--){const t=e*2+(r>>>i&1);if(i===0)n[t]=-(a+1);else{if(n[t]===0){n[t]=n.length/2;n.push(0,0)}e=n[t]}}r++}return n};let r;const huffmanDecode=e=>{const t=r??=buildHuffmanTree();const i=[];let a=0;let o=0;let s=true;for(const r of e)for(let e=7;e>=0;e--){const c=r>>>e&1;const l=t[a*2+c];if(l<0){const e=-l-1;if(e===n)throw new HpackError(`Huffman string contains EOS`);i.push(e);a=0;o=0;s=true}else{a=l;o++;if(c===0)s=false}}if(o>7||!s)throw new HpackError(`invalid Huffman padding`);return Uint8Array.from(i)};const textOf=e=>{let t=``;for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return t};const makeDecoder=(t=4096)=>{const n=[];let r=0;let i=t;const evict=()=>{while(r>i)r-=n.pop().size};const lookup=t=>{if(t>=1&&t<=e.length){const[n,r]=e[t-1];return{name:n,value:r}}const r=n[t-e.length-1];if(r===void 0)throw new HpackError(`no header at index ${t}`);return r};return{decode(e){const a=[];let o=0;const integer=t=>{const n=2**t-1;let r=e[o++]&n;if(r<n)return r;for(let t=0;;t+=7){if(o>=e.length)throw new HpackError(`header block ends inside an integer`);if(t>28)throw new HpackError(`integer is too large`);const n=e[o++];r+=(n&127)*2**t;if((n&128)===0)return r}};const string=()=>{const t=e[o];if(t===void 0)throw new HpackError(`header block ends inside a string`);const n=(t&128)!==0;const r=integer(7);if(o+r>e.length)throw new HpackError(`header block ends inside a string`);const i=e.subarray(o,o+r);o+=r;const a=n?huffmanDecode(i):i;return{text:textOf(a),octets:a.length}};const literal=(e,t)=>{const i=integer(e);let o;let s;if(i===0){const e=string();o=e.text;s=e.octets}else{o=lookup(i).name;s=o.length}const c=string();a.push([o,c.text]);if(t){const e={name:o,value:c.text,size:s+c.octets+32};n.unshift(e);r+=e.size;evict()}};while(o<e.length){const n=e[o];if((n&128)!==0){const{name:e,value:t}=lookup(integer(7));a.push([e,t])}else if((n&64)!==0)literal(6,true);else if((n&32)!==0){if(a.length>0)throw new HpackError(`dynamic table size update after a header field`);const e=integer(5);if(e>t)throw new HpackError(`dynamic table size exceeds the limit`);i=e;evict()}else literal(4,false)}return a}}};const i=/*@__PURE__*/ new TextEncoder;const pushInteger=(e,t,n,r)=>{const i=2**n-1;if(t<i){e.push(r|t);return}e.push(r|i);let a=t-i;while(a>=128){e.push(a%128|128);a=Math.floor(a/128)}e.push(a)};const pushString=(e,t)=>{const n=i.encode(t);pushInteger(e,n.length,7,0);for(const t of n)e.push(t)};const encode=e=>{const t=[];for(const[n,r]of e){t.push(0);pushString(t,n);pushString(t,r)}return Uint8Array.from(t)};export{HpackError,encode,huffmanDecode,makeDecoder};
2
+ //# sourceMappingURL=hpack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hpack.js","names":["STATIC_TABLE","HUFFMAN_BITS","EOS","symbols","a","b","tree","code","previous","bits","node","bit","slot","symbol","huffmanTree","out","pending","ones","byte","bytes","value","next","i","dynamic","size","limit","maxTableSize","index","name","entry","fields","at","max","prefix","block","shift","first","huffman","length","raw","nameIndex","nameOctets","read","encoder","flags","rest","text"],"sources":["../src/hpack.ts"],"mappings":"AAaA,IAAa,WAAb,cAAgC,KAAM,CAAC,E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B,EAAI,KAAK8B,CAAI,CACf,EAEA,MAAM,YAAc,EAAe,IAAiB,CAClD,MAAM1B,EAAQwB,EAAQ,OAAOG,CAAI,EACjC,YAAY/B,EAAKI,EAAM,OAAQ,EAAG,CAAC,EACnC,IAAK,MAAMD,KAAQC,EAAOJ,EAAI,KAAKG,CAAI,CACzC,EAMA,MAAa,OAAU,GAAmD,CACxE,MAAMH,EAAgB,CAAC,EACvB,IAAK,KAAM,CAACa,EAAMR,KAAUU,EAAQ,CAClCf,EAAI,KAAK,CAAC,EACV,WAAWA,EAAKa,CAAI,EACpB,WAAWb,EAAKK,CAAK,CACvB,CACA,OAAO,WAAW,KAAKL,CAAG,CAC5B"}
package/lib/index.d.ts CHANGED
@@ -16,7 +16,9 @@ export * as API from "./api.ts";
16
16
  export * as Category from "./category.ts";
17
17
  export * as Errors from "./errors.ts";
18
18
  export * as GraphQL from "./graphql.ts";
19
+ export * as GrpcTransport from "./grpc-transport.ts";
19
20
  export * as Pagination from "./pagination.ts";
21
+ export * as ProtocolGrpc from "./protocol-grpc.ts";
20
22
  export * as ProtocolHttp from "./protocol-http.ts";
21
23
  export * as ProtocolRest from "./protocol-rest.ts";
22
24
  export { Query } from "./query.ts";
@@ -24,6 +26,7 @@ export * as Crypto from "./crypto.ts";
24
26
  export * as ResponseValidation from "./response-validation.ts";
25
27
  export * as Retry from "./retry.ts";
26
28
  export * as RetryAfter from "./retry-after.ts";
29
+ export * as Sensitive from "./sensitive.ts";
27
30
  export * as Telemetry from "./telemetry.ts";
28
31
  export * as Trait from "./trait.ts";
29
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAC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gBAAgB,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC"}
package/lib/index.js CHANGED
@@ -2,7 +2,9 @@ export * as API from "./api.js";
2
2
  export * as Category from "./category.js";
3
3
  export * as Errors from "./errors.js";
4
4
  export * as GraphQL from "./graphql.js";
5
+ export * as GrpcTransport from "./grpc-transport.js";
5
6
  export * as Pagination from "./pagination.js";
7
+ export * as ProtocolGrpc from "./protocol-grpc.js";
6
8
  export * as ProtocolHttp from "./protocol-http.js";
7
9
  export * as ProtocolRest from "./protocol-rest.js";
8
10
  export { Query } from "./query.js";
@@ -10,5 +12,6 @@ export * as Crypto from "./crypto.js";
10
12
  export * as ResponseValidation from "./response-validation.js";
11
13
  export * as Retry from "./retry.js";
12
14
  export * as RetryAfter from "./retry-after.js";
15
+ export * as Sensitive from "./sensitive.js";
13
16
  export * as Telemetry from "./telemetry.js";
14
17
  export * as Trait from "./trait.js";
@@ -22,13 +22,17 @@ export declare const getItems: (obj: unknown, path: string) => readonly unknown[
22
22
  /** Pagination trait describing how to navigate between pages. */
23
23
  export interface PaginatedTrait {
24
24
  /** Pagination strategy */
25
- readonly mode?: "token" | "page" | "cursor" | "relay" | "link" | "single";
25
+ readonly mode?: "token" | "page" | "cursor" | "relay" | "link" | "keyset" | "single";
26
26
  /**
27
27
  * The name of the input member containing the page/cursor token. In link
28
28
  * mode it is also the query parameter read from the `rel="next"` URL.
29
29
  */
30
30
  readonly inputToken?: string;
31
- /** The path to the output member containing the next page/cursor token */
31
+ /**
32
+ * The path to the output member containing the next page/cursor token. In
33
+ * keyset mode it is a path within one item: the key the next page starts
34
+ * after.
35
+ */
32
36
  readonly outputToken?: string;
33
37
  /**
34
38
  * The path to the output member containing the paginated items. Segments
@@ -47,6 +51,13 @@ export interface PaginatedTrait {
47
51
  readonly hasNextPage?: string;
48
52
  }
49
53
  export type PaginationStrategy = <Input extends Record<string, unknown>, Output, E, R>(operation: (input: Input) => Effect.Effect<Output, E, R>, input: Input, pagination: PaginatedTrait) => Stream.Stream<Output, E, R>;
54
+ /**
55
+ * The stream of a paginated operation whose trait lacks a field its
56
+ * strategy reads: it fails with {@link SdkError} (part of every
57
+ * operation's error channel, so the strategy's `E` is cast to hold it).
58
+ * The generator refuses such traits.
59
+ */
60
+ export declare const missingPaginationConfig: (message: string) => Stream.Stream<never>;
50
61
  /**
51
62
  * Whether a continuation token/cursor returned by a paginated operation
52
63
  * means "no more pages".
@@ -80,6 +91,15 @@ export declare const paginateCursor: <Input extends Record<string, unknown>, Out
80
91
  * `inputToken` until it comes back absent.
81
92
  */
82
93
  export declare const paginateToken: <Input extends Record<string, unknown>, Output, E, R>(operation: (input: Input) => Effect.Effect<Output, E, R>, input: Input, pagination: PaginatedTrait) => Stream.Stream<Output, E, R>;
94
+ /**
95
+ * Stream of pages using keyset pagination: the next request starts after
96
+ * the key of the page's last item. `inputToken` is the input member the key
97
+ * goes to and `outputToken` the key's path within an item (both may be
98
+ * dot-separated: Modal's `List*` calls take `pagination.createdBefore` and
99
+ * key on each item's `createdAt`). Traversal ends on an empty page, a page
100
+ * smaller than the requested `pageSize`, or a key that doesn't advance.
101
+ */
102
+ export declare const paginateKeyset: <Input extends Record<string, unknown>, Output, E, R>(operation: (input: Input) => Effect.Effect<Output, E, R>, input: Input, pagination: PaginatedTrait) => Stream.Stream<Output, E, R>;
83
103
  /**
84
104
  * Stream of pages over a Relay connection -- pass `pageInfo.endCursor` back as
85
105
  * `after` for as long as `pageInfo.hasNextPage` is true.
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,OAAO,QAAS,OAAO,Q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,EAAE,CAAC,EAAE,CAAC,SACtC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,aACvB,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAA6D,CAAC;AAEzF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,SAC3C,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,KACjC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAqE,CAAC"}
package/lib/pagination.js CHANGED
@@ -1 +1 @@
1
- export { pagination$extractArrayItems as extractArrayItems, pagination$extractItems as extractItems, pagination$getItems as getItems, pagination$getPath as getPath, pagination$isTerminalToken as isTerminalToken, pagination$nextLink as nextLink, pagination$paginateCursor as paginateCursor, pagination$paginateLink as paginateLink, pagination$paginatePageNumber as paginatePageNumber, pagination$paginateRelay as paginateRelay, pagination$paginateSingle as paginateSingle, pagination$paginateToken as paginateToken, pagination$paginateWithDefaults as paginateWithDefaults, pagination$recordPageHeaders as recordPageHeaders } from "./_bundle/base.js";
1
+ export { pagination$extractArrayItems as extractArrayItems, pagination$extractItems as extractItems, pagination$getItems as getItems, pagination$getPath as getPath, pagination$isTerminalToken as isTerminalToken, pagination$missingPaginationConfig as missingPaginationConfig, pagination$nextLink as nextLink, pagination$paginateCursor as paginateCursor, pagination$paginateKeyset as paginateKeyset, pagination$paginateLink as paginateLink, pagination$paginatePageNumber as paginatePageNumber, pagination$paginateRelay as paginateRelay, pagination$paginateSingle as paginateSingle, pagination$paginateToken as paginateToken, pagination$paginateWithDefaults as paginateWithDefaults, pagination$recordPageHeaders as recordPageHeaders } from "./_bundle/base.js";
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Protobuf binary wire codec over generated descriptors.
3
+ *
4
+ * Proto-sourced SDKs keep their schemas in proto3 JSON shape (camelCase wire
5
+ * names, 64-bit integers as strings, bytes as base64, enums by name,
6
+ * `google.protobuf.Timestamp` as RFC 3339). Servers that only speak binary
7
+ * gRPC need the same values as protobuf bytes, so this module transcodes
8
+ * between the two using a descriptor table the converter emits next to the
9
+ * services (`src/descriptors.ts`): field numbers, scalar kinds, message and
10
+ * enum references.
11
+ *
12
+ * Decoding follows proto3: a field without presence (a plain scalar, enum,
13
+ * `repeated` or `map` field) reads as its default when the wire omits it
14
+ * (`""`, `0`, `"0"` for 64-bit integers, `false`, the enum's zero value,
15
+ * `[]`, `{}`), so the JSON always carries it. Fields with presence (marked
16
+ * `optional`, message fields and `oneof` members) are omitted when absent.
17
+ * Enum numbers map back to names, and unknown fields are skipped.
18
+ */
19
+ /** A scalar or composite field kind. */
20
+ export type FieldKind = "double" | "float" | "int32" | "int64" | "uint32" | "uint64" | "sint32" | "sint64" | "fixed32" | "fixed64" | "sfixed32" | "sfixed64" | "bool" | "string" | "bytes" | "enum" | "message" | "map";
21
+ /** `[keyKind, valueKind, valueRef?]` for a `map<K, V>` field. */
22
+ export type MapRef = readonly [key: FieldKind, value: FieldKind, ref?: string];
23
+ /**
24
+ * One field: `[number, jsonName, kind, ref?, repeated?, presence?]`. `ref`
25
+ * names the message or enum for `message`/`enum` kinds and is a
26
+ * {@link MapRef} for `map`; `repeated` is `1` for repeated fields. `presence`
27
+ * is set for a field whose absence is observable: `1` for a proto3
28
+ * `optional` field, and `n >= 2` for the members of the message's oneof `n`
29
+ * (setting one member clears the others). Message fields always have
30
+ * presence.
31
+ */
32
+ export type FieldDescriptor = readonly [
33
+ number: number,
34
+ jsonName: string,
35
+ kind: FieldKind,
36
+ ref?: string | MapRef | 0,
37
+ repeated?: 0 | 1,
38
+ presence?: number
39
+ ];
40
+ export interface ProtoDescriptors {
41
+ /** Message full name -> fields. */
42
+ readonly messages: Readonly<Record<string, ReadonlyArray<FieldDescriptor>>>;
43
+ /** Enum full name -> value name -> number. */
44
+ readonly enums: Readonly<Record<string, Readonly<Record<string, number>>>>;
45
+ /**
46
+ * gRPC method path (`/<package>.<Service>/<Method>`) ->
47
+ * `[requestMessage, responseMessage, serverStream?]`. A server-streaming
48
+ * method's JSON output is `{ items: [response, ...] }`.
49
+ */
50
+ readonly methods: Readonly<Record<string, readonly [request: string, response: string, serverStream?: 0 | 1]>>;
51
+ }
52
+ /** A value the descriptors can't encode (a wrong type for its field). */
53
+ export declare class ProtobufEncodeError extends Error {
54
+ readonly _tag = "ProtobufEncodeError";
55
+ }
56
+ /** Bytes that aren't valid protobuf for the expected message. */
57
+ export declare class ProtobufDecodeError extends Error {
58
+ readonly _tag: string;
59
+ }
60
+ /**
61
+ * Valid protobuf whose value proto3 JSON can't represent: a Timestamp
62
+ * outside years 0001 to 9999, or a Duration beyond 10,000 years.
63
+ */
64
+ export declare class ProtobufJsonRangeError extends ProtobufDecodeError {
65
+ readonly _tag = "ProtobufJsonRangeError";
66
+ }
67
+ /** Encode a proto3 JSON value of message `name` to protobuf bytes. */
68
+ export declare const encodeMessage: (d: ProtoDescriptors, name: string, value: unknown) => Uint8Array;
69
+ /**
70
+ * Decode protobuf bytes of message `name` to a proto3 JSON value. As in any
71
+ * proto3 parser, the last value of a singular field wins, a message field
72
+ * seen more than once is merged, setting a oneof member clears the others,
73
+ * a field whose wire type doesn't match its kind is skipped as unknown, and
74
+ * unknown fields are dropped.
75
+ */
76
+ export declare const decodeMessage: (d: ProtoDescriptors, name: string, bytes: Uint8Array) => unknown;
77
+ /** One gRPC message frame: `[flag=0][u32 length BE][payload]`. */
78
+ export declare const frame: (payload: Uint8Array) => Uint8Array;
79
+ /**
80
+ * Reads gRPC message frames from a body that arrives in chunks: `push` each
81
+ * chunk and get back the messages it completed. `rest` is the number of
82
+ * bytes held for an incomplete frame (`0` once a body ends cleanly).
83
+ * Compressed frames are rejected; gRPC-Web trailer frames are skipped.
84
+ */
85
+ export declare class FrameReader {
86
+ private buf;
87
+ get rest(): number;
88
+ push(chunk: Uint8Array): Uint8Array[];
89
+ }
90
+ /** Split a whole gRPC body into message payloads. */
91
+ export declare const unframe: (body: Uint8Array) => Uint8Array[];
92
+ //# sourceMappingURL=protobuf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protobuf.d.ts","sourceRoot":"","sources":["../src/protobuf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,wCAAwC;AACxC,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,UAAU,GACV,UAAU,GACV,MAAM,GACN,QAAQ,GACR,OAAO,GACP,MAAM,GACN,SAAS,GACT,KAAK,CAAC;AAEV,iEAAiE;AACjE,MAAM,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;AAE/E;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS;IACrC,MAAM,EAAE,MAAM;IACd,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,SAAS;IACf,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM;CAClB,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5E,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,QAAQ,CACxB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CACnF,CAAC;CACH;AAED,yEAAyE;AACzE,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,yBAAyB;CACvC;AAED,iEAAiE;AACjE,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAyB;CAC/C;AAED;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,SAAkB,IAAI,4BAA4B;CACnD;AAytBD,sEAAsE;AACtE,eAAO,MAAM,aAAa,MAAO,gBAAgB,QAAQ,MAAM,SAAS,OAAO,KAAG,UAOjF,CAAC;AAoUF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,MAAO,gBAAgB,QAAQ,MAAM,SAAS,UAAU,KAAG,OA0EpF,CAAC;AA4CF,kEAAkE;AAClE,eAAO,MAAM,KAAK,YAAa,UAAU,KAAG,UAK3C,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,GAAG,CAAkD;IAE7D,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,CAuBpC;CACF;AAED,qDAAqD;AACrD,eAAO,MAAM,OAAO,SAAU,UAAU,KAAG,UAAU,EAKpD,CAAC"}
@@ -0,0 +1 @@
1
+ export { protobuf$FrameReader as FrameReader, protobuf$ProtobufDecodeError as ProtobufDecodeError, protobuf$ProtobufEncodeError as ProtobufEncodeError, protobuf$ProtobufJsonRangeError as ProtobufJsonRangeError, protobuf$decodeMessage as decodeMessage, protobuf$encodeMessage as encodeMessage, protobuf$frame as frame, protobuf$unframe as unframe } from "./_bundle/grpc.js";
@@ -0,0 +1,86 @@
1
+ /**
2
+ * gRPC (binary protobuf) protocol for proto-sourced SDKs.
3
+ *
4
+ * Proto SDKs are generated as REST-shaped operations: each RPC is
5
+ * `POST /<package>.<Service>/<Method>` with a proto3 JSON body. Servers that
6
+ * accept JSON (Connect, grpc-gateway) use {@link makeRestProtocol} directly.
7
+ * Servers that only speak gRPC use this protocol, which builds the request
8
+ * with the REST protocol and speaks gRPC on the wire:
9
+ *
10
+ * - **Request**: the proto3 JSON body is transcoded to one protobuf message
11
+ * ({@link encodeMessage}) in one gRPC frame, sent as `application/grpc`.
12
+ * - **Transport**: the call goes through the `HttpClient` the
13
+ * `GrpcTransport` reference holds, or the caller's `HttpClient` when it
14
+ * holds none (see `@distilled.cloud/core/grpc-transport`). Plain `fetch`
15
+ * works where a proxy bridges HTTP/1.1 to gRPC (envoy).
16
+ * - **Status**: the call's `grpc-status` is read from the trailers, or from
17
+ * the headers of a trailers-only reply. A transport that can't see
18
+ * trailers (`fetch`) leaves only the headers; a reply with message frames
19
+ * and no status there is treated as OK.
20
+ * - **Errors**: a non-zero status becomes the operation's typed error. The
21
+ * REST decoder receives `{ code, status, message }` (`{ code: 5, status:
22
+ * "NOT_FOUND", ... }`) with the HTTP status grpc-gateway maps the code to
23
+ * (`NOT_FOUND` -> 404, `UNAVAILABLE` -> 503, ...), so error matchers key on
24
+ * the numeric gRPC `code`, and categories and retries follow the HTTP
25
+ * status.
26
+ * - **Response**: protobuf messages are transcoded back to proto3 JSON and
27
+ * decoded by the operation's output schema, so schemas, sensitive values
28
+ * and response validation behave exactly as for REST.
29
+ *
30
+ * A server-streaming method's output is `{ items: [message, ...] }`. Calling
31
+ * the operation collects the whole stream; its `.stream(input)` (see
32
+ * `API.makeStreaming`) emits each message as it arrives, and stopping the
33
+ * stream cancels the call.
34
+ *
35
+ * {@link Deadline} bounds calls in its scope: it is sent as `grpc-timeout`
36
+ * and enforced here, and a call that runs past it fails with
37
+ * `DEADLINE_EXCEEDED` (code 4).
38
+ */
39
+ import * as Context from "effect/Context";
40
+ import * as Duration from "effect/Duration";
41
+ import * as Layer from "effect/Layer";
42
+ import * as API from "./api.ts";
43
+ import { type ProtoDescriptors } from "./protobuf.ts";
44
+ import { type RestProtocolOptions } from "./protocol-rest.ts";
45
+ /** gRPC status code -> name. */
46
+ export declare const GRPC_STATUS_NAMES: Readonly<Record<number, string>>;
47
+ /** gRPC status code -> HTTP status (grpc-gateway's mapping). */
48
+ export declare const GRPC_HTTP_STATUS: Readonly<Record<number, number>>;
49
+ /**
50
+ * The deadline of gRPC calls in its scope, from when each call starts.
51
+ * `undefined` (the default) sets none.
52
+ *
53
+ * ```ts
54
+ * router.taskExecWait(input).pipe(Effect.provideService(Deadline, "30 seconds"));
55
+ * ```
56
+ */
57
+ export declare const Deadline: Context.Reference<Duration.Input | undefined>;
58
+ export interface GrpcProtocolOptions<C> extends RestProtocolOptions<C> {
59
+ /** The SDK's generated descriptors (`src/descriptors.ts`). */
60
+ readonly descriptors: ProtoDescriptors;
61
+ /**
62
+ * The error for a non-zero status no typed error matched, from its gRPC
63
+ * code. By default the REST decoder classifies it by the HTTP status the
64
+ * code maps to (`UNAVAILABLE` -> `ServiceUnavailable`, which retries), which
65
+ * keeps retries working but merges codes that share a status
66
+ * (`INVALID_ARGUMENT`, `FAILED_PRECONDITION` and `OUT_OF_RANGE` are all
67
+ * `BadRequest`).
68
+ */
69
+ readonly statusError?: (info: StatusInfo) => unknown;
70
+ }
71
+ /** A non-OK gRPC status, as `statusError` receives it. */
72
+ export interface StatusInfo {
73
+ readonly code: number;
74
+ readonly message: string;
75
+ /** `google.rpc.Status.details` from `grpc-status-details-bin`, as proto3 JSON `Any`s. */
76
+ readonly details: ReadonlyArray<unknown>;
77
+ readonly headers: Readonly<Record<string, string>>;
78
+ }
79
+ /** gRPC's mapping of an HTTP status, for a reply that carries no gRPC status. */
80
+ export declare const HTTP_GRPC_STATUS: Readonly<Record<number, number>>;
81
+ /**
82
+ * A gRPC protocol over the given REST protocol options. See the module
83
+ * documentation for the wire behavior.
84
+ */
85
+ export declare const makeGrpcProtocol: <C>(options: GrpcProtocolOptions<C>) => Layer.Layer<API.Protocol>;
86
+ //# sourceMappingURL=protocol-grpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-grpc.d.ts","sourceRoot":"","sources":["../src/protocol-grpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAM5C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAIhF,gCAAgC;AAChC,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB9D,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB7D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,+CAGpB,CAAC;AAEF,MAAM,WAAW,mBAAmB,CAAC,CAAC,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IACpE,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACvC;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC;CACtD;AAED,0DAA0D;AAC1D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yFAAyF;IACzF,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACzC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACpD;AAED,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAS7D,CAAC;AAiHF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,WAAW,mBAAmB,CAAC,CAAC,CAAC,KAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAsX5C,CAAC"}
@@ -0,0 +1 @@
1
+ export { protocol_grpc$Deadline as Deadline, protocol_grpc$GRPC_HTTP_STATUS as GRPC_HTTP_STATUS, protocol_grpc$GRPC_STATUS_NAMES as GRPC_STATUS_NAMES, protocol_grpc$HTTP_GRPC_STATUS as HTTP_GRPC_STATUS, protocol_grpc$makeGrpcProtocol as makeGrpcProtocol } from "./_bundle/grpc.js";
@@ -13,13 +13,12 @@ import * as HttpClientRequest from "effect/http/HttpClientRequest";
13
13
  import type * as AST from "effect/SchemaAST";
14
14
  import { isOpaqueValue } from "./plain-values.ts";
15
15
  import * as Schema from "./schema-lite-typed.ts";
16
+ import { SdkError } from "./sdk-error.ts";
16
17
  import { type ErrorMatcher, type HttpTrait, type KeyDictionaryEntries } from "./trait.ts";
17
- export { getAnn, getProps } from "./annotations.ts";
18
+ export { getAnn, getProps, resolveNode } from "./annotations.ts";
18
19
  export declare const getPropAnn: (prop: AST.PropertySignature, symbol: symbol) => unknown;
19
20
  export declare const hasPropAnn: (prop: AST.PropertySignature, symbol: symbol) => boolean;
20
21
  export declare const nameOf: (prop: AST.PropertySignature, symbol: symbol) => string;
21
- /** Resolve wrappers to the real node: Suspend, encoding, optional/null unions. */
22
- export declare const resolveNode: (ast: AST.AST) => AST.AST;
23
22
  /** An output member read from a response header (`T.Header`). */
24
23
  export interface ResponseHeaderMember {
25
24
  readonly key: string;
@@ -71,6 +70,12 @@ export interface BuildRequestOptions {
71
70
  * Defaults to the key verbatim.
72
71
  */
73
72
  readonly unknownKeyToWire?: (key: string) => string;
73
+ /**
74
+ * Send `{}` on a method that takes a body even when the input declares no
75
+ * body members. Connect unary RPCs (E2B's envd) POST JSON for every call,
76
+ * and refuse a bodyless one with 415.
77
+ */
78
+ readonly emptyJsonBody?: boolean;
74
79
  }
75
80
  /**
76
81
  * Encode a greedy `{name+}` label: the value may span several path
@@ -122,10 +127,10 @@ export declare const invalidLabel: (member: string, value: unknown, greedy?: boo
122
127
  *
123
128
  * Fails with {@link InvalidInput}, before anything is sent, when a label is
124
129
  * `.` or `..` (for a greedy `{name+}` label, when any of its segments is).
125
- * Throws when the input schema is missing the `Http()` trait -- a codegen
126
- * bug, which the calling protocol's Effect surfaces as a defect.
130
+ * Fails with {@link SdkError} when the input schema is missing the `Http()`
131
+ * trait (a codegen bug the generator refuses).
127
132
  */
128
- export declare const buildRequest: (options: BuildRequestOptions) => Effect.Effect<HttpClientRequest.HttpClientRequest, InvalidInput>;
133
+ export declare const buildRequest: (options: BuildRequestOptions) => Effect.Effect<HttpClientRequest.HttpClientRequest, InvalidInput | SdkError>;
129
134
  /** Parsed response metadata supplied by a protocol after it detects a failure. */
130
135
  export interface ErrorResponse {
131
136
  readonly body?: unknown;