Repository navigation
Releases: rtorcato/cf-common
Releases · rtorcato/cf-common
Release list
@rtorcato/cf-common@1.9.0
Minor Changes
- 0fb24e1: Add the
@rtorcato/cf-common/accessmodule withverifyAccessJwt, which checks the Cloudflare Access JWT against the team JWKS (signature, issuer, audience, expiry) and returns the typed identity, andaccessJwt, which reads theCf-Access-Jwt-Assertionheader. A bad token throws a401with codeACCESS_JWT_INVALID. - 99bb1db: Add the
@rtorcato/cf-common/ai-gatewaymodule:createAiGatewaysends provider calls through an AI Gateway endpoint (fetchreturns the response,jsonposts and parses JSON),gatewayUrlbuilds the endpoint URL, andgatewayHeadersturns typed cache, metadata, logging and retry options intocf-aig-*headers. Failures throw a non-exposed502with codeAI_GATEWAY_FAILED; a bad id, provider or path segment throws a non-exposed500AI_GATEWAY_INVALID. - 6467fca: Add the
analyticssubpath:writeDataPoint(dataset, point)writes to an Analytics Engine dataset and maps a rejected point to a non-exposed 500CloudflareErrorwith codeANALYTICS_WRITE_FAILED, andcreateDataset(dataset, schema)names the blob, double and index columns so you write by name and get the SQL API column for each. - 0f9c81e: Add the
@rtorcato/cf-common/browsermodule over the Browser Rendering binding:withBrowserlaunches a browser, runs your callback and always closes it, andscreenshotandpdfrender a URL or HTML string in one call.@cloudflare/puppeteeris an optional peer dependency, needed only if you import this subpath. A failed launch or render throws a non-exposed502(BROWSER_LAUNCH_FAILED/BROWSER_RENDER_FAILED); a non-http(s) URL throws an exposed400BROWSER_INVALID_URL. - 85ea871: Add
@rtorcato/cf-common/do:BaseDurableObjectextends the runtime'sDurableObjectand adds a typedthis.storage, andtypedStoragewraps anyDurableObjectStoragesoget(with an optional fallback),putanddeleteare checked against a key → value schema. - b0264ba: Add the
emailsubpath:sendEmail(binding, message)sends over asend_emailbinding, from fields or a raw-MIMEEmailMessage, and maps a failed send to a non-exposed 502CloudflareErrorwith codeEMAIL_SEND_FAILED. - 79ab9f4: Add the
@rtorcato/cf-common/hyperdrivemodule withwithHyperdrive, which opens a per-request client over a Hyperdrive binding and always closes it. The driver is yours to pass in throughconnectandclose, so no driver is bundled. A failed connect throws a non-exposed502with codeHYPERDRIVE_CONNECT_FAILED. - e28b067: Add the
@rtorcato/cf-common/imagesmodule for Cloudflare Images:createImagesApiuploads a file or URL and reserves direct creator upload URLs,imageUrlandtransformUrlbuild named-variant, flexible-variant and/cdn-cgi/image/URLs from typed options, andsignImageUrlsigns a delivery URL withexpand an HMACsig. API failures throw a non-exposed502with codeIMAGES_API_ERROR; a bad id throws an exposed400IMAGES_INVALID_ID. - 18af2fe: Add the
pipelinessubpath:createPipelineProducer<T>(pipeline)wraps a Pipeline binding sosend(record)andsendBatch(records, { chunkSize? })take typed records (batches go out in order in chunks of 100 by default), and a rejected send becomes a non-exposed 502CloudflareErrorwith codePIPELINE_SEND_FAILED. - c57e688: Add the
@rtorcato/cf-common/apimodule withcreateCloudflareApi, a small client for Cloudflare's v4 REST API. It covers zones, DNS records and cache purge, and its rawrequest/requestPagereach any other endpoint. It adds no dependencies, and any failure throws a non-exposed502with codeCF_API_ERROR. - a8f4181: Add the
@rtorcato/cf-common/rpcmodule withgetService, a typed accessor for Service Bindings to aWorkerEntrypoint, andcallService, which maps a failed RPC call to a non-exposed502with codeRPC_CALL_FAILED. - 4de9fe5: Add the
@rtorcato/cf-common/secretsmodule withgetSecret, typed access to a Secrets Store binding by name: a missing binding is a non-exposed500, and a failed read becomes a non-exposed500with codeSECRET_GET_FAILED. - bed7bc4: Add the
@rtorcato/cf-common/assetsmodule over the Static Assets binding:serveAssetsserves a request with an optional SPA fallback (for page navigations) and 404 page, andfetchAssetfetches the asset at another path with the request's headers. - e5ff16a: Add the
@rtorcato/cf-common/vectorizemodule withcreateVectorStore<M>, a typed store over one Vectorize index. It adds caller-typed metadata,upsertsplit into chunks of 1000 with onemutationIdper chunk, and failures mapped to a non-exposed502with codeVECTORIZE_FAILED. - 6b9a389: Add the
@rtorcato/cf-common/workflowsmodule withcreateWorkflow, a typed client over a Workflow binding:createtakes typed params,statusreturns a typedoutput, and any failure becomes a non-exposed502with codeWORKFLOW_FAILED. - 071a62b: Add the
@rtorcato/cf-common/wsmodule for Hibernatable WebSockets on a Durable Object:acceptWebSocketupgrades withctx.acceptWebSocket(an exposed426WS_UPGRADE_REQUIREDwithout anUpgrade: websocketheader),getAttachment/setAttachmenttype the per-socket state,parseMessagevalidates a JSON message (an exposed400WS_INVALID_MESSAGEon failure), andsendMessage/broadcastsend JSON to one socket or to every socket, optionally by tag.
@rtorcato/cf-common@1.8.0
Minor Changes
- 597d6b9: Add
@rtorcato/cf-common/r2-presign:presignR2Urlsigns presignedGET/PUTURLs for an R2 object over the S3-compatible API with an R2 API token (AWS SigV4 via Web Crypto, no dependency). - dc5f548: Add
@rtorcato/cf-common/queues:createProducerwraps aQueuebinding (typedsend,sendBatchsplit into chunks of 100, failures asQUEUE_SEND_FAILED), anddefineQueuebuilds aqueuehandler that acks or retries each message individually, with an optionalretryDelaybackoff. - 5feadcd: Add the
@rtorcato/cf-common/aimodule withrunAi, a typed wrapper over the Workers AI binding'srun(). The input and output types follow the model name, and a failed call throws a non-exposed502with codeAI_RUN_FAILED.
Patch Changes
- 51791ef: Add the
cache,ratelimitandaimodules to the bundledAGENTS.md(the subpath list and module map left them out).