@distilled.cloud/core 1.0.0-rc.2 → 1.0.0-rc.21
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/LICENSE +201 -0
- package/README.md +33 -0
- package/lib/_bundle/aws.js +2 -0
- package/lib/_bundle/aws.js.map +1 -0
- package/lib/_bundle/base.js +5 -0
- package/lib/_bundle/base.js.map +1 -0
- package/lib/_bundle/graphql.js +3 -0
- package/lib/_bundle/graphql.js.map +1 -0
- package/lib/_bundle/grpc.js +3 -0
- package/lib/_bundle/grpc.js.map +1 -0
- package/lib/_bundle/rest.js +2 -0
- package/lib/_bundle/rest.js.map +1 -0
- package/lib/_bundle/xml.js +4 -0
- package/lib/_bundle/xml.js.map +1 -0
- package/lib/annotations.d.ts +17 -0
- package/lib/annotations.d.ts.map +1 -0
- package/lib/annotations.js +2 -0
- package/lib/annotations.js.map +1 -0
- package/lib/api.d.ts +220 -51
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +1 -178
- package/lib/category.d.ts +19 -16
- package/lib/category.d.ts.map +1 -1
- package/lib/category.js +1 -280
- package/lib/chunks.d.ts +3 -0
- package/lib/chunks.d.ts.map +1 -0
- package/lib/chunks.js +1 -0
- package/lib/config.d.ts +81 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +1 -0
- package/lib/crypto.d.ts +76 -0
- package/lib/crypto.d.ts.map +1 -0
- package/lib/crypto.js +1 -0
- package/lib/error-category.d.ts +1 -1
- package/lib/error-category.d.ts.map +1 -1
- package/lib/error-category.js +1 -46
- package/lib/errors.d.ts +99 -74
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -186
- package/lib/graphql.d.ts +420 -0
- package/lib/graphql.d.ts.map +1 -0
- package/lib/graphql.js +1 -0
- package/lib/graphql.types.d.ts +11 -0
- package/lib/graphql.types.d.ts.map +1 -0
- package/lib/graphql.types.js +1 -0
- package/lib/grpc-transport-cloudflare-http2.d.ts +7 -0
- package/lib/grpc-transport-cloudflare-http2.d.ts.map +1 -0
- package/lib/grpc-transport-cloudflare-http2.js +6 -0
- package/lib/grpc-transport-cloudflare-http2.js.map +1 -0
- package/lib/grpc-transport-cloudflare-sockets.d.ts +7 -0
- package/lib/grpc-transport-cloudflare-sockets.d.ts.map +1 -0
- package/lib/grpc-transport-cloudflare-sockets.js +5 -0
- package/lib/grpc-transport-cloudflare-sockets.js.map +1 -0
- package/lib/grpc-transport-node-http2.d.ts +19 -0
- package/lib/grpc-transport-node-http2.d.ts.map +1 -0
- package/lib/grpc-transport-node-http2.js +2 -0
- package/lib/grpc-transport-node-http2.js.map +1 -0
- package/lib/grpc-transport.d.ts +111 -0
- package/lib/grpc-transport.d.ts.map +1 -0
- package/lib/grpc-transport.js +1 -0
- package/lib/hpack.d.ts +34 -0
- package/lib/hpack.d.ts.map +1 -0
- package/lib/hpack.js +2 -0
- package/lib/hpack.js.map +1 -0
- package/lib/index.d.ts +32 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +17 -0
- package/lib/max-message-bytes.d.ts +42 -0
- package/lib/max-message-bytes.d.ts.map +1 -0
- package/lib/max-message-bytes.js +2 -0
- package/lib/max-message-bytes.js.map +1 -0
- package/lib/ndjson.d.ts +3 -0
- package/lib/ndjson.d.ts.map +1 -0
- package/lib/ndjson.js +2 -0
- package/lib/ndjson.js.map +1 -0
- package/lib/pagination.d.ts +105 -25
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +1 -182
- package/lib/plain-values.d.ts +21 -0
- package/lib/plain-values.d.ts.map +1 -0
- package/lib/plain-values.js +2 -0
- package/lib/plain-values.js.map +1 -0
- package/lib/protobuf.d.ts +85 -0
- package/lib/protobuf.d.ts.map +1 -0
- package/lib/protobuf.js +1 -0
- package/lib/protocol-grpc.d.ts +123 -0
- package/lib/protocol-grpc.d.ts.map +1 -0
- package/lib/protocol-grpc.js +1 -0
- package/lib/protocol-http.d.ts +206 -25
- package/lib/protocol-http.d.ts.map +1 -1
- package/lib/protocol-http.js +1 -554
- package/lib/protocol-rest.d.ts +258 -64
- package/lib/protocol-rest.d.ts.map +1 -1
- package/lib/protocol-rest.js +1 -242
- package/lib/protocol.d.ts +113 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +0 -0
- package/lib/query.d.ts +29 -0
- package/lib/query.d.ts.map +1 -0
- package/lib/query.js +1 -0
- package/lib/response-validation-strict.d.ts +48 -0
- package/lib/response-validation-strict.d.ts.map +1 -0
- package/lib/response-validation-strict.js +1 -0
- package/lib/response-validation.d.ts +86 -0
- package/lib/response-validation.d.ts.map +1 -0
- package/lib/response-validation.js +1 -0
- package/lib/retry-after.d.ts +4 -4
- package/lib/retry-after.d.ts.map +1 -1
- package/lib/retry-after.js +1 -112
- package/lib/retry-state.d.ts +26 -0
- package/lib/retry-state.d.ts.map +1 -0
- package/lib/retry-state.js +2 -0
- package/lib/retry-state.js.map +1 -0
- package/lib/retry.d.ts +141 -42
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -210
- package/lib/schema-lite-impl.d.ts +179 -0
- package/lib/schema-lite-impl.d.ts.map +1 -0
- package/lib/schema-lite-impl.js +1 -0
- package/lib/schema-lite-typed.d.ts +41 -0
- package/lib/schema-lite-typed.d.ts.map +1 -0
- package/lib/schema-lite-typed.js +1 -0
- package/lib/schema-lite.d.ts +41 -0
- package/lib/schema-lite.d.ts.map +1 -0
- package/lib/schema-lite.js +1 -0
- package/lib/schema.d.ts +21 -7
- package/lib/schema.d.ts.map +1 -1
- package/lib/schema.js +1 -48
- package/lib/sdk-error.d.ts +31 -0
- package/lib/sdk-error.d.ts.map +1 -0
- package/lib/sdk-error.js +1 -0
- package/lib/send.d.ts +37 -0
- package/lib/send.d.ts.map +1 -0
- package/lib/send.js +2 -0
- package/lib/send.js.map +1 -0
- package/lib/sensitive.d.ts +28 -0
- package/lib/sensitive.d.ts.map +1 -0
- package/lib/sensitive.js +2 -0
- package/lib/sensitive.js.map +1 -0
- package/lib/telemetry-debug.d.ts +6 -0
- package/lib/telemetry-debug.d.ts.map +1 -0
- package/lib/telemetry-debug.js +2 -0
- package/lib/telemetry-debug.js.map +1 -0
- package/lib/telemetry-hooks.d.ts +32 -0
- package/lib/telemetry-hooks.d.ts.map +1 -0
- package/lib/telemetry-hooks.js +2 -0
- package/lib/telemetry-hooks.js.map +1 -0
- package/lib/telemetry-host-rules.d.ts +23 -0
- package/lib/telemetry-host-rules.d.ts.map +1 -0
- package/lib/telemetry-host-rules.js +2 -0
- package/lib/telemetry-host-rules.js.map +1 -0
- package/lib/telemetry-lambda-context.d.ts +17 -0
- package/lib/telemetry-lambda-context.d.ts.map +1 -0
- package/lib/telemetry-lambda-context.js +2 -0
- package/lib/telemetry-lambda-context.js.map +1 -0
- package/lib/telemetry-message-context.d.ts +52 -0
- package/lib/telemetry-message-context.d.ts.map +1 -0
- package/lib/telemetry-message-context.js +2 -0
- package/lib/telemetry-message-context.js.map +1 -0
- package/lib/telemetry-metrics.d.ts +6 -0
- package/lib/telemetry-metrics.d.ts.map +1 -0
- package/lib/telemetry-metrics.js +2 -0
- package/lib/telemetry-metrics.js.map +1 -0
- package/lib/telemetry-name-template.d.ts +13 -0
- package/lib/telemetry-name-template.d.ts.map +1 -0
- package/lib/telemetry-name-template.js +2 -0
- package/lib/telemetry-name-template.js.map +1 -0
- package/lib/telemetry-stream.d.ts +11 -0
- package/lib/telemetry-stream.d.ts.map +1 -0
- package/lib/telemetry-stream.js +2 -0
- package/lib/telemetry-stream.js.map +1 -0
- package/lib/telemetry-xray.d.ts +28 -0
- package/lib/telemetry-xray.d.ts.map +1 -0
- package/lib/telemetry-xray.js +2 -0
- package/lib/telemetry-xray.js.map +1 -0
- package/lib/telemetry.d.ts +317 -0
- package/lib/telemetry.d.ts.map +1 -0
- package/lib/telemetry.js +3 -0
- package/lib/telemetry.js.map +1 -0
- package/lib/token-cache.d.ts +31 -0
- package/lib/token-cache.d.ts.map +1 -0
- package/lib/token-cache.js +2 -0
- package/lib/token-cache.js.map +1 -0
- package/lib/trait.d.ts +94 -20
- package/lib/trait.d.ts.map +1 -1
- package/lib/trait.js +1 -107
- package/lib/unknown-error.d.ts +18 -0
- package/lib/unknown-error.d.ts.map +1 -0
- package/lib/unknown-error.js +1 -0
- package/lib/xml.d.ts +44 -0
- package/lib/xml.d.ts.map +1 -0
- package/lib/xml.js +1 -0
- package/package.json +13 -13
- package/src/annotations.ts +53 -0
- package/src/api.ts +1597 -234
- package/src/category.ts +97 -134
- package/src/chunks.ts +30 -0
- package/src/config.ts +261 -0
- package/src/crypto.ts +202 -0
- package/src/error-category.ts +16 -29
- package/src/errors.ts +99 -77
- package/src/graphql.ts +1817 -0
- package/src/graphql.types.ts +120 -0
- package/src/grpc-transport-cloudflare-http2.ts +569 -0
- package/src/grpc-transport-cloudflare-sockets.ts +368 -0
- package/src/grpc-transport-node-http2.ts +307 -0
- package/src/grpc-transport.ts +287 -0
- package/src/hpack.ts +331 -0
- package/src/index.ts +31 -0
- package/src/max-message-bytes.ts +58 -0
- package/src/ndjson.ts +55 -0
- package/src/pagination.ts +379 -94
- package/src/plain-values.ts +70 -0
- package/src/protobuf.ts +1367 -0
- package/src/protocol-grpc.ts +811 -0
- package/src/protocol-http.ts +1045 -371
- package/src/protocol-rest.ts +908 -255
- package/src/protocol.ts +150 -0
- package/src/query.ts +39 -0
- package/src/response-validation-strict.ts +333 -0
- package/src/response-validation.ts +161 -0
- package/src/retry-after.ts +8 -14
- package/src/retry-state.ts +105 -0
- package/src/retry.ts +260 -145
- package/src/schema-lite-impl.ts +621 -0
- package/src/schema-lite-typed.ts +44 -0
- package/src/schema-lite.ts +45 -0
- package/src/schema.ts +259 -15
- package/src/sdk-error.ts +37 -0
- package/src/send.ts +156 -0
- package/src/sensitive.ts +188 -0
- package/src/telemetry-debug.ts +179 -0
- package/src/telemetry-hooks.ts +33 -0
- package/src/telemetry-host-rules.ts +39 -0
- package/src/telemetry-lambda-context.ts +46 -0
- package/src/telemetry-message-context.ts +170 -0
- package/src/telemetry-metrics.ts +69 -0
- package/src/telemetry-name-template.ts +26 -0
- package/src/telemetry-stream.ts +100 -0
- package/src/telemetry-xray.ts +66 -0
- package/src/telemetry.ts +800 -0
- package/src/token-cache.ts +117 -0
- package/src/trait.ts +139 -67
- package/src/unknown-error.ts +38 -0
- package/src/xml.ts +346 -0
- package/lib/api.js.map +0 -1
- package/lib/category.js.map +0 -1
- package/lib/codegen/cli.d.ts +0 -29
- package/lib/codegen/cli.d.ts.map +0 -1
- package/lib/codegen/cli.js +0 -165
- package/lib/codegen/cli.js.map +0 -1
- package/lib/codegen/emit.d.ts +0 -129
- package/lib/codegen/emit.d.ts.map +0 -1
- package/lib/codegen/emit.js +0 -105
- package/lib/codegen/emit.js.map +0 -1
- package/lib/codegen/format.d.ts +0 -23
- package/lib/codegen/format.d.ts.map +0 -1
- package/lib/codegen/format.js +0 -28
- package/lib/codegen/format.js.map +0 -1
- package/lib/codegen/generator.d.ts +0 -334
- package/lib/codegen/generator.d.ts.map +0 -1
- package/lib/codegen/generator.js +0 -691
- package/lib/codegen/generator.js.map +0 -1
- package/lib/codegen/graph.d.ts +0 -36
- package/lib/codegen/graph.d.ts.map +0 -1
- package/lib/codegen/graph.js +0 -136
- package/lib/codegen/graph.js.map +0 -1
- package/lib/codegen/members.d.ts +0 -25
- package/lib/codegen/members.d.ts.map +0 -1
- package/lib/codegen/members.js +0 -55
- package/lib/codegen/members.js.map +0 -1
- package/lib/codegen/naming.d.ts +0 -29
- package/lib/codegen/naming.d.ts.map +0 -1
- package/lib/codegen/naming.js +0 -74
- package/lib/codegen/naming.js.map +0 -1
- package/lib/codegen/openapi-cli.d.ts +0 -38
- package/lib/codegen/openapi-cli.d.ts.map +0 -1
- package/lib/codegen/openapi-cli.js +0 -107
- package/lib/codegen/openapi-cli.js.map +0 -1
- package/lib/codegen/openapi.d.ts +0 -115
- package/lib/codegen/openapi.d.ts.map +0 -1
- package/lib/codegen/openapi.js +0 -1220
- package/lib/codegen/openapi.js.map +0 -1
- package/lib/codegen/operations.d.ts +0 -24
- package/lib/codegen/operations.d.ts.map +0 -1
- package/lib/codegen/operations.js +0 -56
- package/lib/codegen/operations.js.map +0 -1
- package/lib/codegen/pagination.d.ts +0 -39
- package/lib/codegen/pagination.d.ts.map +0 -1
- package/lib/codegen/pagination.js +0 -33
- package/lib/codegen/pagination.js.map +0 -1
- package/lib/codegen/prelude.d.ts +0 -15
- package/lib/codegen/prelude.d.ts.map +0 -1
- package/lib/codegen/prelude.js +0 -60
- package/lib/codegen/prelude.js.map +0 -1
- package/lib/error-category.js.map +0 -1
- package/lib/errors.js.map +0 -1
- package/lib/json-patch.d.ts +0 -44
- package/lib/json-patch.d.ts.map +0 -1
- package/lib/json-patch.js +0 -174
- package/lib/json-patch.js.map +0 -1
- package/lib/pagination.js.map +0 -1
- package/lib/protocol-http.js.map +0 -1
- package/lib/protocol-rest.js.map +0 -1
- package/lib/retry-after.js.map +0 -1
- package/lib/retry.js.map +0 -1
- package/lib/schema.js.map +0 -1
- package/lib/trait.js.map +0 -1
- package/src/codegen/cli.ts +0 -268
- package/src/codegen/emit.ts +0 -207
- package/src/codegen/format.ts +0 -47
- package/src/codegen/generator.ts +0 -1153
- package/src/codegen/graph.ts +0 -151
- package/src/codegen/members.ts +0 -71
- package/src/codegen/naming.ts +0 -86
- package/src/codegen/openapi-cli.ts +0 -166
- package/src/codegen/openapi.ts +0 -1450
- package/src/codegen/operations.ts +0 -76
- package/src/codegen/pagination.ts +0 -71
- package/src/codegen/prelude.ts +0 -70
- package/src/json-patch.ts +0 -222
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{grpc_transport$hasNoBody as e,grpc_transport$isResponseStatus as t,grpc_transport$layer as n,grpc_transport$resetReply as r,grpc_transport$resetTrailers as i,grpc_transport$respond as a}from"./_bundle/grpc.js";import*as o from"effect/Cause";import*as s from"effect/Effect";import*as c from"effect/http/HttpClient";import*as l from"effect/Stream";import*as u from"effect/http/HttpClientError";import*as d from"effect/Deferred";import*as f from"effect/Queue";const builtin=e=>globalThis.process?.getBuiltinModule?.(e);const http2Module=()=>builtin(`node:http2`);const p=/* @__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=p.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(p.get(n)===i)p.delete(n)};i.session.on(`error`,drop);i.session.on(`close`,drop);i.session.on(`goaway`,drop);p.set(n,i);return i};const m=/* @__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 u.HttpClientError({reason:new u.TransportError({request:e,cause:t,description:`HTTP/2 request failed`})});const bodyOf=e=>e.body._tag===`Uint8Array`?e.body.body:void 0;const h=1048576;const g=h/4;const make=n=>c.make((c,u,p)=>s.gen(function*(){const _=yield*f.unbounded();const v=yield*d.make();return yield*s.callback(y=>{const b=http2Module();if(b===void 0){y(s.fail(transportError(c,/* @__PURE__ */ new Error(`node:http2 is not available in this runtime`))));return}let x;try{x=sessionFor(b,n===void 0?{origin:u.origin}:{socketPath:n})}catch(e){y(s.fail(transportError(c,e)));return}if(x.active++===0)x.session.ref();let S=false;const settle=()=>{if(S)return;S=true;if(--x.active===0&&!x.session.destroyed)x.session.unref()};const C={};for(const[e,t]of Object.entries(c.headers))if(!m.has(e))C[e]=t;const w=x.session.request({":method":c.method,":path":`${u.pathname}${u.search}`,...C});const onAbort=()=>w.close(b.constants.NGHTTP2_CANCEL);if(p.aborted)onAbort();else p.addEventListener(`abort`,onAbort,{once:true});let T={};let E=false;let D=false;let O=false;const failWith=e=>{f.failCauseUnsafe(_,o.fail(e));d.doneUnsafe(v,s.fail(e))};const fail=e=>{O=true;if(D)return failWith(e);y(s.fail(transportError(c,e)))};w.on(`trailers`,e=>T=plain(e));let k=0;w.on(`data`,e=>{k+=e.length;f.offerUnsafe(_,new Uint8Array(e));if(k>=h)w.pause()});w.on(`end`,()=>{E=true;f.endUnsafe(_);d.doneUnsafe(v,s.succeed(T))});w.on(`close`,()=>{settle();p.removeEventListener(`abort`,onAbort);if(O)return;if(x.session.destroyed){if(!D||!E)fail(/* @__PURE__ */ new Error(`the HTTP/2 connection closed before the response ended`));return}if(!D){D=true;y(a(c,r(w.rstCode)).pipe(s.mapError(e=>transportError(c,e))))}else if(!E){E=true;f.endUnsafe(_);d.doneUnsafe(v,s.succeed(i(w.rstCode)))}});w.on(`response`,n=>{D=true;const r=Number(n[`:status`]??0);if(!t(r)){w.close(b.constants.NGHTTP2_CANCEL);y(s.fail(transportError(c,/* @__PURE__ */ new Error(`invalid HTTP status ${r}`))));return}const i=l.fromQueue(_).pipe(l.tap(e=>s.sync(()=>{k-=e.length;if(k<=g&&w.isPaused())w.resume()})),l.ensuring(s.sync(()=>{if(!E)w.close(b.constants.NGHTTP2_CANCEL)})));if(e(r))w.close(b.constants.NGHTTP2_CANCEL);y(a(c,{status:r,headers:plain(n),body:i,trailers:d.await(v)}).pipe(s.mapError(e=>transportError(c,e)),s.tapError(()=>s.sync(()=>w.close(b.constants.NGHTTP2_CANCEL)))))});w.on(`error`,e=>{if(e.code===`ERR_HTTP2_STREAM_ERROR`)return;fail(e)});const A=bodyOf(c);w.end(A===void 0?void 0:A)})}));const _=/*@__PURE__*/ make(void 0);const unixSocket=e=>make(e);const v=/*@__PURE__*/ n(_);const unixLayer=e=>n(unixSocket(e));export{_ as client,v 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","hasNoBody","isResponseStatus","layer$1","resetReply","resetTrailers","respond","Cause","Effect","HttpClient","Stream","HttpClientError","Deferred","Queue","id","sessions","target","http2","net","key","existing","entry","CONNECTION_HEADERS","out","value","incoming","request","HIGH_WATER","LOW_WATER","chunks","trailers","resume","socketPath","url","error","settled","headers","stream","signal","received","ended","started","failed","cause","buffered","chunk","status","body","client","path","layer"],"sources":["../src/grpc-transport-node-http2.ts"],"mappings":"gdA+CA,MAAM,QAAc,GAEhB,WACA,SAAS,mBAAmBc,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,OAAQ,CAAE,EAC3DK,EAAM,QAAQ,MAAM,EACpB,MAAM,SAAa,CACjB,GAAIN,EAAS,IAAII,CAAG,IAAME,EAAON,EAAS,OAAOI,CAAG,CACtD,EACAE,EAAM,QAAQ,GAAG,QAAS,IAAI,EAC9BA,EAAM,QAAQ,GA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AI,CAACgC,EAAOH,EAAO,MAAMpB,EAAM,UAAU,cAAc,CACzD,CAAC,CACH,CACF,EACA,GAAIhB,EAAU6C,CAAM,EAAGT,EAAO,MAAMpB,EAAM,UAAU,cAAc,EAClEc,EACEzB,EAAQoB,EAAS,CACf,SACA,QAAS,MAAMD,CAAQ,EACvB,OACA,SAAUb,EAAS,MAAMkB,CAAQ,CACnC,CAAC,CAAC,CAAC,KACDtB,EAAO,SAAU,GAAU,eAAekB,EAASiB,CAAK,CAAC,EACzDnC,EAAO,aACLA,EAAO,SAAW6B,EAAO,MAAMpB,EAAM,UAAU,cAAc,CAAC,CAChE,CACF,CACF,CACF,CAAC,EACDoB,EAAO,GAAG,QAAU,GAAqC,CAEvD,GAAIH,EAAM,OAAS,yBAA0B,OAC7C,KAAKA,CAAK,CACZ,CAAC,EACD,MAAMa,EAAO,OAAOrB,CAAO,EAC3BW,EAAO,IAAIU,IAAS,IAAA,GAAY,IAAA,GAAYA,CAAI,CAClD,CAAC,CACH,CAAC,CACH,EAGF,MAAaC,EAA8C,mBAAK,IAAA,EAAS,EAWzE,MAAa,WAAc,GAAwC,KAAKC,CAAI,EAG5E,MAAaC,EAA0C,gBAAeF,CAAM,EAG5E,MAAa,UAAa,GAAqChD,EAAe,WAAWiD,CAAI,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
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. A transport built here is Effect code: the
|
|
14
|
+
* body is an Effect `Stream` read in the caller's fiber, and the trailers an
|
|
15
|
+
* `Effect` that fails when the transport can't read them, so no failure
|
|
16
|
+
* turns into an empty value on the way. Provide a different transport for one
|
|
17
|
+
* scope with {@link layer}:
|
|
18
|
+
*
|
|
19
|
+
* - `@distilled.cloud/core/grpc-transport-node-http2` speaks HTTP/2 with
|
|
20
|
+
* `node:http2`, for servers that offer nothing else;
|
|
21
|
+
* - `@distilled.cloud/core/grpc-transport-cloudflare-sockets` speaks HTTP/1.1
|
|
22
|
+
* over a `cloudflare:sockets` TLS socket, for a Cloudflare Worker calling a
|
|
23
|
+
* gRPC server that is itself behind Cloudflare (a Worker's `fetch` to such
|
|
24
|
+
* a site takes Cloudflare's internal path, which resets gRPC upstreams);
|
|
25
|
+
* - `@distilled.cloud/core/grpc-transport-cloudflare-http2` speaks HTTP/2
|
|
26
|
+
* over a `cloudflare:sockets` socket, for a Cloudflare Worker calling a
|
|
27
|
+
* server that offers nothing else (workerd has no working `node:http2`).
|
|
28
|
+
*
|
|
29
|
+
* None is imported by this module, so a bundle only carries the ones it
|
|
30
|
+
* provides.
|
|
31
|
+
*/
|
|
32
|
+
import * as Context from "effect/Context";
|
|
33
|
+
import * as Effect from "effect/Effect";
|
|
34
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
35
|
+
import * as HttpClientError from "effect/http/HttpClientError";
|
|
36
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
37
|
+
import * as HttpClientResponse from "effect/http/HttpClientResponse";
|
|
38
|
+
import * as Layer from "effect/Layer";
|
|
39
|
+
import * as Stream from "effect/Stream";
|
|
40
|
+
/**
|
|
41
|
+
* The `HttpClient` gRPC calls go through. `undefined` (the default) sends
|
|
42
|
+
* through the caller's `HttpClient`.
|
|
43
|
+
*/
|
|
44
|
+
export declare const GrpcTransport: Context.Reference<HttpClient.HttpClient | undefined>;
|
|
45
|
+
/** Send gRPC calls in this scope through `client`. */
|
|
46
|
+
export declare const layer: (client: HttpClient.HttpClient) => Layer.Layer<never>;
|
|
47
|
+
/** Header and trailer names are lowercase; values as received. */
|
|
48
|
+
export type Trailers = Readonly<Record<string, string>>;
|
|
49
|
+
/** What a transport hands over for a response. */
|
|
50
|
+
export interface Reply {
|
|
51
|
+
readonly status: number;
|
|
52
|
+
readonly headers: Trailers;
|
|
53
|
+
/**
|
|
54
|
+
* The body as it arrives. It runs in the fiber that reads the response, so
|
|
55
|
+
* that fiber's interruption and finalizers reach the connection.
|
|
56
|
+
*/
|
|
57
|
+
readonly body: Stream.Stream<Uint8Array, unknown>;
|
|
58
|
+
/** The trailers, once the body has ended. Fails when they can't be read. */
|
|
59
|
+
readonly trailers: Effect.Effect<Trailers, unknown>;
|
|
60
|
+
/**
|
|
61
|
+
* Whether the trailers always arrive. HTTP/2 delivers them end to end;
|
|
62
|
+
* over HTTP/1.1 a bridging proxy may drop them, so the protocol then
|
|
63
|
+
* treats a reply with messages and no status as OK.
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
readonly reliableTrailers?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Whether `status` is a final HTTP status a response can carry (200 to 599).
|
|
70
|
+
* A transport fails the call with a transport error for any other.
|
|
71
|
+
*/
|
|
72
|
+
export declare const isResponseStatus: (status: number) => boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Whether a response with `status` has no body (RFC 9110 sections 15.3.5,
|
|
75
|
+
* 15.3.6 and 15.4.5). Its transport lets the connection go at once.
|
|
76
|
+
*/
|
|
77
|
+
export declare const hasNoBody: (status: number) => boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The trailers of a stream the server reset with the HTTP/2 error `code`
|
|
80
|
+
* before it sent a status: the gRPC status the gRPC over HTTP/2 spec maps
|
|
81
|
+
* the code to (`PROTOCOL-HTTP2.md`, "Errors"), as grpc-js does. The call
|
|
82
|
+
* fails like any other gRPC error: `REFUSED_STREAM` (the server did no work)
|
|
83
|
+
* as `UNAVAILABLE`, which retries, `NO_ERROR` and unknown codes as
|
|
84
|
+
* `INTERNAL`, which doesn't.
|
|
85
|
+
*/
|
|
86
|
+
export declare const resetTrailers: (code: number) => Trailers;
|
|
87
|
+
/**
|
|
88
|
+
* The reply for a stream the server reset with the HTTP/2 error `code`
|
|
89
|
+
* before its response headers: a gRPC reply of trailers alone, carrying
|
|
90
|
+
* {@link resetTrailers}.
|
|
91
|
+
*/
|
|
92
|
+
export declare const resetReply: (code: number) => Reply;
|
|
93
|
+
/**
|
|
94
|
+
* Build a transport's response from its {@link Reply}. Fails with the
|
|
95
|
+
* `TypeError` of a head that is no valid HTTP head (a header name that is no
|
|
96
|
+
* token, a value with a line break), as `fetch` would. A response with
|
|
97
|
+
* {@link hasNoBody} has an empty body and no trailers.
|
|
98
|
+
*/
|
|
99
|
+
export declare const respond: (request: HttpClientRequest.HttpClientRequest, reply: Reply) => Effect.Effect<HttpClientResponse.HttpClientResponse, unknown>;
|
|
100
|
+
/**
|
|
101
|
+
* Whether `response` came from a transport whose trailers always arrive
|
|
102
|
+
* ({@link Reply.reliableTrailers}), so a missing status is an error.
|
|
103
|
+
*/
|
|
104
|
+
export declare const hasTrailers: (response: HttpClientResponse.HttpClientResponse) => boolean;
|
|
105
|
+
/**
|
|
106
|
+
* The trailers of a response a transport built with {@link respond}, read
|
|
107
|
+
* after its body; empty for any other response (`fetch` exposes none). A
|
|
108
|
+
* transport that can't read them fails with a `DecodeError`.
|
|
109
|
+
*/
|
|
110
|
+
export declare const trailersOf: (response: HttpClientResponse.HttpClientResponse) => Effect.Effect<Trailers, HttpClientError.HttpClientError>;
|
|
111
|
+
//# sourceMappingURL=grpc-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpc-transport.d.ts","sources":["../src/grpc-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;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,MAAM,aAAa,SAAU,MAAM,KAAG,QAG5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,KAKxC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,OAAO,YACT,iBAAiB,CAAC,iBAAiB,SACrC,KAAK,KACX,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,OAAO,CAY5D,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,WAAW,aAAc,kBAAkB,CAAC,kBAAkB,KAAG,OAG7E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,aACX,kBAAkB,CAAC,kBAAkB,KAC9C,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,eAAe,CAAC,eAAe,CAKzD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { grpc_transport$GrpcTransport as GrpcTransport, grpc_transport$hasNoBody as hasNoBody, grpc_transport$hasTrailers as hasTrailers, grpc_transport$isResponseStatus as isResponseStatus, grpc_transport$layer as layer, grpc_transport$resetReply as resetReply, grpc_transport$resetTrailers as resetTrailers, 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","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
|
package/lib/hpack.js.map
ADDED
|
@@ -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"],"s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IAAO,GAAI,EAC5B,EAAO,KAAK,MAAMA,EAAO,GAAG,CAC9B,CACA9B,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
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@distilled.cloud/core` -- the runtime shared by every distilled SDK.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { ResponseValidation, Retry } from "@distilled.cloud/core";
|
|
6
|
+
*
|
|
7
|
+
* program.pipe(Effect.provide(ResponseValidation.strict));
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* Each namespace is also importable on its own subpath
|
|
11
|
+
* (`@distilled.cloud/core/response-validation`, ...); generated SDKs use the
|
|
12
|
+
* subpaths. The code generator and test helpers live in the unpublished
|
|
13
|
+
* `@distilled.cloud/dev` package.
|
|
14
|
+
*/
|
|
15
|
+
export * as API from "./api.ts";
|
|
16
|
+
export * as Category from "./category.ts";
|
|
17
|
+
export * as Errors from "./errors.ts";
|
|
18
|
+
export * as GraphQL from "./graphql.ts";
|
|
19
|
+
export * as GrpcTransport from "./grpc-transport.ts";
|
|
20
|
+
export * as Pagination from "./pagination.ts";
|
|
21
|
+
export * as ProtocolGrpc from "./protocol-grpc.ts";
|
|
22
|
+
export * as ProtocolHttp from "./protocol-http.ts";
|
|
23
|
+
export * as ProtocolRest from "./protocol-rest.ts";
|
|
24
|
+
export { Query } from "./query.ts";
|
|
25
|
+
export * as Crypto from "./crypto.ts";
|
|
26
|
+
export * as ResponseValidation from "./response-validation.ts";
|
|
27
|
+
export * as Retry from "./retry.ts";
|
|
28
|
+
export * as RetryAfter from "./retry-after.ts";
|
|
29
|
+
export * as Sensitive from "./sensitive.ts";
|
|
30
|
+
export * as Telemetry from "./telemetry.ts";
|
|
31
|
+
export * as Trait from "./trait.ts";
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","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;AACtC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,kBAAkB,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * as API from "./api.js";
|
|
2
|
+
export * as Category from "./category.js";
|
|
3
|
+
export * as Errors from "./errors.js";
|
|
4
|
+
export * as GraphQL from "./graphql.js";
|
|
5
|
+
export * as GrpcTransport from "./grpc-transport.js";
|
|
6
|
+
export * as Pagination from "./pagination.js";
|
|
7
|
+
export * as ProtocolGrpc from "./protocol-grpc.js";
|
|
8
|
+
export * as ProtocolHttp from "./protocol-http.js";
|
|
9
|
+
export * as ProtocolRest from "./protocol-rest.js";
|
|
10
|
+
export { Query } from "./query.js";
|
|
11
|
+
export * as Crypto from "./crypto.js";
|
|
12
|
+
export * as ResponseValidation from "./response-validation.js";
|
|
13
|
+
export * as Retry from "./retry.js";
|
|
14
|
+
export * as RetryAfter from "./retry-after.js";
|
|
15
|
+
export * as Sensitive from "./sensitive.js";
|
|
16
|
+
export * as Telemetry from "./telemetry.js";
|
|
17
|
+
export * as Trait from "./trait.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The largest message a streaming protocol accepts from the server (a gRPC
|
|
3
|
+
* frame, an e2b envd envelope). A message whose header announces more fails
|
|
4
|
+
* the call before the SDK buffers it. The first of these wins:
|
|
5
|
+
*
|
|
6
|
+
* 1. The call's own `maxMessageBytes` ({@link MaxMessageBytesInput}):
|
|
7
|
+
* `Modal.functionGet({ ..., maxMessageBytes: 200 * 1024 * 1024 })`.
|
|
8
|
+
* 2. The {@link MaxMessageBytes} layer, for every call in a scope:
|
|
9
|
+
* `Effect.provide(MaxMessageBytes.of(200 * 1024 * 1024))`.
|
|
10
|
+
* 3. The protocol's own default (e.g. Modal's 100 MiB, as its official
|
|
11
|
+
* client), else {@link DEFAULT_MAX_MESSAGE_BYTES}.
|
|
12
|
+
*
|
|
13
|
+
* `MaxMessageBytes` is an optional service: operations do not list it in
|
|
14
|
+
* their requirements.
|
|
15
|
+
*/
|
|
16
|
+
import * as Context from "effect/Context";
|
|
17
|
+
import * as Layer from "effect/Layer";
|
|
18
|
+
/** 16 MiB. */
|
|
19
|
+
export declare const DEFAULT_MAX_MESSAGE_BYTES: number;
|
|
20
|
+
declare const MaxMessageBytes_base: Context.ServiceClass<MaxMessageBytes, "@distilled.cloud/core/MaxMessageBytes", number>;
|
|
21
|
+
export declare class MaxMessageBytes extends /*@__PURE__*/ MaxMessageBytes_base {
|
|
22
|
+
}
|
|
23
|
+
/** Accept messages up to `bytes` in a scope, e.g. `MaxMessageBytes.of(64 * 1024 * 1024)`. */
|
|
24
|
+
export declare const of: (bytes: number) => Layer.Layer<MaxMessageBytes>;
|
|
25
|
+
/**
|
|
26
|
+
* The optional `maxMessageBytes` an operation input accepts. It sets the
|
|
27
|
+
* limit for one call, over the {@link MaxMessageBytes} layer. It is not sent
|
|
28
|
+
* on the wire.
|
|
29
|
+
*/
|
|
30
|
+
export interface MaxMessageBytesInput {
|
|
31
|
+
readonly maxMessageBytes?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The limit for one call: the input's `maxMessageBytes`, else the layer in
|
|
35
|
+
* `context`, else `fallback`. A value that is not a positive whole number
|
|
36
|
+
* is returned as an error message.
|
|
37
|
+
*/
|
|
38
|
+
export declare const resolve: <R>(context: Context.Context<R>, input: unknown, fallback?: number) => number | {
|
|
39
|
+
readonly invalid: string;
|
|
40
|
+
};
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=max-message-bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"max-message-bytes.d.ts","sources":["../src/max-message-bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,cAAc;AACd,eAAO,MAAM,yBAAyB,QAAmB,CAAC;;AAE1D,qBAAa,eACX,SAAQ,aAAa,CAAC,oBAErB;CAAG;AAEN,6FAA6F;AAC7F,eAAO,MAAM,EAAE,UAAW,MAAM,KAAG,KAAK,CAAC,KAAK,CAAC,eAAe,CACvB,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,WACd,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SACpB,OAAO,aACJ,MAAM,KACf,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CASrC,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import*as e from"effect/Context";import*as t from"effect/Layer";const n=16777216;var MaxMessageBytes=class extends (/*@__PURE__*/ e.Service()(`@distilled.cloud/core/MaxMessageBytes`)){};const of=e=>t.succeed(MaxMessageBytes,e);const resolve=(t,r,i=n)=>{const a=(r!==null&&typeof r===`object`?r.maxMessageBytes:void 0)??e.getOrUndefined(t,MaxMessageBytes)??i;return Number.isSafeInteger(a)&&a>0?a:{invalid:`maxMessageBytes must be a positive whole number, got ${String(a)}`}};export{n as DEFAULT_MAX_MESSAGE_BYTES,MaxMessageBytes,of,resolve};
|
|
2
|
+
//# sourceMappingURL=max-message-bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"max-message-bytes.js","names":["Context","Layer","DEFAULT_MAX_MESSAGE_BYTES","bytes","input","context","fallback"],"sources":["../src/max-message-bytes.ts"],"mappings":"gEAmBA,MAAaE,EAA4B,SAEzC,IAAa,gBAAb,eACwB,gBAAQ,QAAiC,CAAC,CAC9D,uCACF,EAAA,AAAE,CAAC,EAGL,MAAa,GAAM,GACjBD,EAAM,QAAQ,gBAAiBE,CAAK,EAgBtC,MAAa,SACX,EACA,EACA,EAAmBD,IACuB,CAK1C,MAAMC,GAHJC,IAAU,MAAQ,OAAOA,IAAU,SAC9BA,EAA+B,gBAChC,IAAA,KACgBJ,EAAQ,eAAeK,EAAS,eAAe,GAAKC,EAC1E,OAAO,OAAO,cAAcH,CAAK,GAAKA,EAAQ,EAC1CA,EACA,CAAE,QAAS,wDAAwD,OAAOA,CAAK,GAAI,CACzF"}
|
package/lib/ndjson.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ndjson.d.ts","sources":["../src/ndjson.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAaxD,eAAO,MAAM,MAAM,EAAE,aA4BpB,CAAC"}
|
package/lib/ndjson.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import*as e from"effect/Effect";import*as t from"effect/Stream";const nonEmpty=e=>e.trim().length>0;const parse=e=>{try{return{json:JSON.parse(e)}}catch{return}};const n={collect:(e,t)=>{if(t?.split(`;`)[0].trim().toLowerCase()!==`application/x-ndjson`)return;const n=[];for(const t of e.split(/\r?\n/)){if(!nonEmpty(t))continue;const e=parse(t);if(e===void 0)return{json:void 0,nonJson:true};n.push(e.json)}return{json:{items:n},nonJson:false}},stream:n=>t.unwrap(e.map(n,({body:n,item:r,invalid:i})=>n.pipe(t.decodeText(),t.splitLines,t.filter(nonEmpty),t.mapEffect(t=>{const n=parse(t);return n===void 0?e.fail(i(t)):r(n.json,t)}))))};export{n as ndjson};
|
|
2
|
+
//# sourceMappingURL=ndjson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ndjson.js","names":["Effect","Stream","line","ndjson","contentType","items","text","parsed","open","body","invalid","item"],"sources":["../src/ndjson.ts"],"mappings":"gEAeA,MAAM,SAAY,GAA0BE,EAAK,KAAK,CAAC,CAAC,OAAS,EAGjE,MAAM,MAAS,GAAyD,CACtE,GAAI,CACF,MAAO,CAAE,KAAM,KAAK,MAAMA,CAAI,CAAE,CAClC,MAAQ,CACN,MACF,CACF,EAEA,MAAaC,EAAwB,CACnC,SAAU,EAAM,IAAgB,CAC9B,GAAIC,GAAa,MAAM,GAAG,CAAC,CAAC,EAAE,CAAE,KAAK,CAAC,CAAC,YAAY,IAAM,uBACvD,OAEF,MAAMC,EAAmB,CAAC,EAC1B,IAAK,MAAMH,KAAQI,EAAK,MAAM,OAAO,EAAG,CACtC,GAAI,CAAC,SAASJ,CAAI,EAAG,SACrB,MAAMK,EAAS,MAAML,CAAI,EACzB,GAAIK,IAAW,IAAA,GAAW,MAAO,CAAE,KAAM,IAAA,GAAW,QAAS,IAAK,EAClEF,EAAM,KAAKE,EAAO,IAAI,CACxB,CACA,MAAO,CAAE,KAAM,CAAE,OAAM,EAAG,QAAS,KAAM,CAC3C,EACA,OAAS,GACPN,EAAO,OACLD,EAAO,IAAIQ,GAAO,CAAE,OAAM,OAAM,aAC9BC,EAAK,KACHR,EAAO,WAAW,EAClBA,EAAO,WACPA,EAAO,OAAO,QAAQ,EACtBA,EAAO,UAAW,GAAS,CACzB,MAAMM,EAAS,MAAML,CAAI,EACzB,OAAOK,IAAW,IAAA,GAAYP,EAAO,KAAKU,EAAQR,CAAI,CAAC,EAAIS,EAAKJ,EAAO,KAAML,CAAI,CACnF,CAAC,CACH,CACF,CACF,CACJ"}
|
package/lib/pagination.d.ts
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Pagination utilities for streaming through paginated API responses.
|
|
3
|
-
*
|
|
4
|
-
* Supports multiple pagination styles:
|
|
5
|
-
* - Page-based: page/per_page with a page number that advances
|
|
6
|
-
* - Cursor-based: cursor/limit with an opaque next-cursor string
|
|
7
|
-
* - Token-based (AWS style): NextToken/MaxResults continuation tokens
|
|
8
|
-
* - Single: one-shot list endpoints that still expose the paginated surface
|
|
9
|
-
*
|
|
10
|
-
* Each SDK stores a {@link PaginatedTrait} on its operations (sourced from the
|
|
11
|
-
* `smithy.api#paginated` trait in its models) and picks a
|
|
12
|
-
* {@link PaginationStrategy}; these shared utilities handle the streaming.
|
|
13
|
-
* Ported from the distilled repo's `core/pagination`.
|
|
14
|
-
*/
|
|
1
|
+
import * as Context from "effect/Context";
|
|
15
2
|
import * as Effect from "effect/Effect";
|
|
16
3
|
import * as Stream from "effect/Stream";
|
|
17
4
|
/**
|
|
@@ -19,26 +6,64 @@ import * as Stream from "effect/Stream";
|
|
|
19
6
|
* `"resultInfo.page"`). Used for pagination traits and nested access.
|
|
20
7
|
*/
|
|
21
8
|
export declare const getPath: (obj: unknown, path: string) => unknown;
|
|
9
|
+
/**
|
|
10
|
+
* Collect the items a dot-separated path selects, flattening arrays as it
|
|
11
|
+
* goes. Unlike {@link getPath} (which walks a single value and is used for
|
|
12
|
+
* cursors/tokens), every segment here fans out over whatever the previous one
|
|
13
|
+
* produced, so a path may cross a list:
|
|
14
|
+
*
|
|
15
|
+
* - `"items"` on `{ items: [a, b] }` -> `[a, b]` (the common flat case)
|
|
16
|
+
* - `"edges.node"` on a Relay connection -> every edge's `node`
|
|
17
|
+
*
|
|
18
|
+
* `null`/`undefined` links are dropped rather than propagated, so a partially
|
|
19
|
+
* null page yields the items it does have instead of nothing.
|
|
20
|
+
*/
|
|
21
|
+
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" | "single";
|
|
26
|
-
/**
|
|
25
|
+
readonly mode?: "token" | "page" | "cursor" | "relay" | "link" | "keyset" | "single";
|
|
26
|
+
/**
|
|
27
|
+
* The name of the input member containing the page/cursor token. In link
|
|
28
|
+
* mode it is also the query parameter read from the `rel="next"` URL.
|
|
29
|
+
*/
|
|
27
30
|
readonly inputToken?: string;
|
|
28
|
-
/**
|
|
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
|
+
*/
|
|
29
36
|
readonly outputToken?: string;
|
|
30
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* The path to the output member containing the paginated items. Segments
|
|
39
|
+
* may cross arrays -- `"edges.node"` walks every edge and collects its
|
|
40
|
+
* `node` (see {@link getItems}).
|
|
41
|
+
*/
|
|
31
42
|
readonly items?: string;
|
|
32
43
|
/** The name of the input member that limits page size */
|
|
33
44
|
readonly pageSize?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Relay extension: the path to the boolean that says whether another page
|
|
47
|
+
* exists (`"pageInfo.hasNextPage"`). Relay connections keep returning the
|
|
48
|
+
* last page's `endCursor` after the end, so the cursor alone can't
|
|
49
|
+
* terminate traversal -- see {@link paginateRelay}.
|
|
50
|
+
*/
|
|
51
|
+
readonly hasNextPage?: string;
|
|
34
52
|
}
|
|
35
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>;
|
|
36
61
|
/**
|
|
37
62
|
* Whether a continuation token/cursor returned by a paginated operation
|
|
38
63
|
* means "no more pages".
|
|
39
64
|
*
|
|
40
65
|
* APIs mark the terminal page by omitting the output token, returning it
|
|
41
|
-
* as `null`, or
|
|
66
|
+
* as `null`, or -- for several services (e.g. SSM, CloudWatch Logs) -- as an
|
|
42
67
|
* empty string. Treating `""` as a live token re-requests the first page
|
|
43
68
|
* forever (or fails with a ValidationException). Object tokens (e.g.
|
|
44
69
|
* DynamoDB's `LastEvaluatedKey`) are always truthy and unaffected.
|
|
@@ -46,7 +71,7 @@ export type PaginationStrategy = <Input extends Record<string, unknown>, Output,
|
|
|
46
71
|
export declare const isTerminalToken: (token: unknown) => boolean;
|
|
47
72
|
/**
|
|
48
73
|
* Stream for single-shot list endpoints that still expose the paginated
|
|
49
|
-
* surface
|
|
74
|
+
* surface -- emits exactly one page.
|
|
50
75
|
*/
|
|
51
76
|
export declare const paginateSingle: PaginationStrategy;
|
|
52
77
|
/**
|
|
@@ -56,15 +81,64 @@ export declare const paginateSingle: PaginationStrategy;
|
|
|
56
81
|
*/
|
|
57
82
|
export declare const paginatePageNumber: <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>;
|
|
58
83
|
/**
|
|
59
|
-
* Stream of pages using cursor-based pagination
|
|
60
|
-
* cursors until one comes back absent.
|
|
84
|
+
* Stream of pages using cursor-based pagination -- follow `outputToken`
|
|
85
|
+
* cursors until one comes back absent or repeats a previously requested cursor.
|
|
86
|
+
* Empty pages still advance when they return a new cursor.
|
|
61
87
|
*/
|
|
62
88
|
export declare const paginateCursor: <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>;
|
|
63
89
|
/**
|
|
64
|
-
* Stream of pages using token-based pagination
|
|
65
|
-
* `inputToken` until it comes back absent.
|
|
90
|
+
* Stream of pages using token-based pagination -- pass `outputToken` back as
|
|
91
|
+
* `inputToken` until it comes back absent or repeats a token already sent.
|
|
92
|
+
* Some APIs never omit the token: CloudWatch Logs `GetLogEvents` marks the end
|
|
93
|
+
* of a stream by echoing the `nextToken` it was sent. Empty pages still
|
|
94
|
+
* advance when they return a new token.
|
|
66
95
|
*/
|
|
67
96
|
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>;
|
|
97
|
+
/**
|
|
98
|
+
* Stream of pages using keyset pagination: the next request starts after
|
|
99
|
+
* the key of the page's last item. `inputToken` is the input member the key
|
|
100
|
+
* goes to and `outputToken` the key's path within an item (both may be
|
|
101
|
+
* dot-separated: Modal's `List*` calls take `pagination.createdBefore` and
|
|
102
|
+
* key on each item's `createdAt`). Traversal ends on an empty page, a page
|
|
103
|
+
* smaller than the requested `pageSize`, or a key that doesn't advance.
|
|
104
|
+
*/
|
|
105
|
+
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>;
|
|
106
|
+
/**
|
|
107
|
+
* Stream of pages over a Relay connection -- pass `pageInfo.endCursor` back as
|
|
108
|
+
* `after` for as long as `pageInfo.hasNextPage` is true.
|
|
109
|
+
*
|
|
110
|
+
* Relay is cursor pagination with one twist that breaks
|
|
111
|
+
* {@link paginateCursor}: the terminal page still carries an `endCursor` (it
|
|
112
|
+
* points at the last edge, not at "nothing left"). Only `hasNextPage`
|
|
113
|
+
* distinguishes "more to fetch" from "that was everything", so this strategy
|
|
114
|
+
* reads the boolean and treats the cursor as a pure position marker. A
|
|
115
|
+
* connection that omits `pageInfo` entirely (or returns an empty page) also
|
|
116
|
+
* terminates, so a malformed response can't spin forever.
|
|
117
|
+
*/
|
|
118
|
+
export declare const paginateRelay: <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>;
|
|
119
|
+
/**
|
|
120
|
+
* Hand a response's headers to the link traversal running on this fiber, if
|
|
121
|
+
* any. Protocols call it for every response they decode; outside
|
|
122
|
+
* {@link paginateLink} it does nothing.
|
|
123
|
+
*/
|
|
124
|
+
export declare const recordPageHeaders: (context: Context.Context<never>, headers: Readonly<Record<string, string | undefined>>) => void;
|
|
125
|
+
/**
|
|
126
|
+
* The URL of the `rel="next"` link in a `Link` header value, e.g.
|
|
127
|
+
* `<https://api.github.com/repositories/1/issues?page=2>; rel="next", <...>; rel="last"`.
|
|
128
|
+
*/
|
|
129
|
+
export declare const nextLink: (header: string | undefined) => string | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Stream of pages that follows the `Link` response header: each request
|
|
132
|
+
* takes `inputToken` from the query of the previous response's `rel="next"`
|
|
133
|
+
* URL, and traversal ends when a response has no next link (or its token
|
|
134
|
+
* repeats the current one). The response body carries no token, so this
|
|
135
|
+
* works for APIs whose list responses are bare arrays.
|
|
136
|
+
*
|
|
137
|
+
* The protocol must report response headers through
|
|
138
|
+
* {@link recordPageHeaders} (the REST protocol does); otherwise traversal
|
|
139
|
+
* stops after the first page.
|
|
140
|
+
*/
|
|
141
|
+
export declare const paginateLink: <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>;
|
|
68
142
|
/**
|
|
69
143
|
* Shared default pagination dispatcher for SDKs that use generic
|
|
70
144
|
* token/cursor/page traversal.
|
|
@@ -74,8 +148,14 @@ export declare const paginateWithDefaults: PaginationStrategy;
|
|
|
74
148
|
* Extracts individual items from a page stream.
|
|
75
149
|
*
|
|
76
150
|
* @param pages - A stream of page responses
|
|
77
|
-
* @param itemsPath - Dot-separated path to the items
|
|
151
|
+
* @param itemsPath - Dot-separated path to the items in the page; segments may
|
|
152
|
+
* cross arrays (see {@link getItems})
|
|
78
153
|
* @returns A Stream of individual items
|
|
79
154
|
*/
|
|
80
155
|
export declare const extractItems: <Output, Item, E, R>(pages: Stream.Stream<Output, E, R>, itemsPath: string) => Stream.Stream<Item, E, R>;
|
|
156
|
+
/**
|
|
157
|
+
* The items of a stream of pages that are themselves the lists (bare-array
|
|
158
|
+
* responses).
|
|
159
|
+
*/
|
|
160
|
+
export declare const extractArrayItems: <Output, Item, E, R>(pages: Stream.Stream<Output, E, R>) => Stream.Stream<Item, E, R>;
|
|
81
161
|
//# sourceMappingURL=pagination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