@lunora/bindings 1.0.0-alpha.20 → 1.0.0-alpha.22
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/dist/images/index.mjs +1 -1
- package/dist/kv/index.mjs +1 -1
- package/dist/packem_shared/buildImageDeliveryUrl-CMUkVJfB.mjs +1 -0
- package/dist/packem_shared/createKv-CKeFDFuG.mjs +1 -0
- package/package.json +2 -2
- package/dist/packem_shared/buildImageDeliveryUrl-eARoj3MG.mjs +0 -1
- package/dist/packem_shared/createKv-CspEaB58.mjs +0 -1
package/dist/images/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createImages as m}from"../packem_shared/createImages-TW6ircG2.mjs";import{buildImageDeliveryUrl as i}from"../packem_shared/buildImageDeliveryUrl-
|
|
1
|
+
import{createImages as m}from"../packem_shared/createImages-TW6ircG2.mjs";import{buildImageDeliveryUrl as i}from"../packem_shared/buildImageDeliveryUrl-CMUkVJfB.mjs";import{buildSignedImageUrl as o,verifySignedImageUrl as a}from"../packem_shared/buildSignedImageUrl-BzgCHIu6.mjs";export{i as buildImageDeliveryUrl,o as buildSignedImageUrl,m as createImages,a as verifySignedImageUrl};
|
package/dist/kv/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createKv as o,scopeKey as t}from"../packem_shared/createKv-
|
|
1
|
+
import{createKv as o,scopeKey as t}from"../packem_shared/createKv-CKeFDFuG.mjs";import{createKvIntrospector as p,createKvIntrospectorFromEnv as v}from"../packem_shared/createKvIntrospector-Bz0nqUjD.mjs";export{o as createKv,p as createKvIntrospector,v as createKvIntrospectorFromEnv,t as scopeKey};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as a}from"@lunora/errors";const s=/^[a-z][a-z\d+\-.]*:\/\//i,c=[",","=","#","?","/"],d=e=>e.endsWith("/")?e.slice(0,-1):e,m=e=>e.startsWith("/")?e.slice(1):e,g=e=>Object.entries(e).filter(([,r])=>r!==void 0&&(typeof r=="string"||typeof r=="number")).map(([r,n])=>{const i=String(n),o=c.find(t=>i.includes(t));if(o!==void 0)throw new a("INTERNAL",`@lunora/bindings/images: transform option \`${r}\` value \`${i}\` contains a \`${o}\`, which the /cdn-cgi/image/ option path cannot represent (\`,\`/\`=\` are the option/key-value separators; \`#\`/\`?\`/\`/\` are URL-structural). Percent-encode the value — for colors use \`%23RRGGBB\`, not \`#RRGGBB\` or \`rgb(r,g,b)\`.`);return`${r}=${i}`}).join(","),l=e=>e.split("/").map(r=>encodeURIComponent(r)).join("/"),p=e=>{const r=d(e.baseUrl);if(e.imageId!==void 0){const t=e.variant??"public";return`${r}/${encodeURIComponent(e.imageId)}/${encodeURIComponent(t)}`}if(e.key===void 0)throw new a("INTERNAL","@lunora/bindings/images: buildImageDeliveryUrl requires either `imageId` or `key`");const n=e.transform===void 0?"":g(e.transform),i=s.test(e.key)?e.key:l(m(e.key)),o=n===""?"/cdn-cgi/image":`/cdn-cgi/image/${n}`;return`${r}${o}/${i}`};export{p as buildImageDeliveryUrl};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as c}from"@lunora/errors";const d=512,g=1e3,w=new TextEncoder,m=t=>w.encode(t).length,v=(t,e)=>{if(m(t)>d)throw new c("INTERNAL",`@lunora/bindings/kv: ${e} exceeds ${String(d)}-byte limit`);if(t.includes("\0"))throw new c("INTERNAL",`@lunora/bindings/kv: ${e} contains NUL byte`);for(const a of t.split("/"))if(a==="."||a==="..")throw new c("INTERNAL",`@lunora/bindings/kv: ${e} contains a \`.\`/\`..\` path component`)},p=t=>{if(typeof t!="string"||t.length===0)throw new TypeError("@lunora/bindings/kv: key must be a non-empty string");v(t,"key")},u=t=>{t.length>0&&v(t,"prefix")},f=(t,e)=>{p(t),p(e);const a=`${t.endsWith("/")?t.slice(0,-1):t}/${e}`;if(m(a)>d)throw new c("INTERNAL",`@lunora/bindings/kv: scoped key exceeds ${String(d)}-byte limit`);return a},x=t=>{const e={};if(t.expiration!==void 0&&t.expirationTtl!==void 0)throw new c("INTERNAL","@lunora/bindings/kv: `expiration` and `expirationTtl` are mutually exclusive");return t.expiration!==void 0&&(e.expiration=t.expiration),t.expirationTtl!==void 0&&(e.expirationTtl=t.expirationTtl),t.metadata!==void 0&&(e.metadata=t.metadata),Object.keys(e).length>0?e:void 0},b=t=>{if(!t.namespace)throw new TypeError("@lunora/bindings/kv: `namespace` is required");const{keyPrefix:e,namespace:a}=t;e!==void 0&&p(e);const s=i=>e===void 0?(p(i),i):f(e,i),y=i=>{if(e===void 0)return i;const n=e.endsWith("/")?e:`${e}/`;return i.startsWith(n)?i.slice(n.length):i};return{delete:async i=>{await a.delete(s(i))},get:async(i,n={})=>await a.get(s(i),{cacheTtl:n.cacheTtl,type:"json"})??null,getRaw:async(i,n={})=>await a.get(s(i),{cacheTtl:n.cacheTtl,type:n.type??"text"})??null,getWithMetadata:async(i,n={})=>{const o=await a.getWithMetadata(s(i),{cacheTtl:n.cacheTtl,type:"json"});return{metadata:o.metadata??null,value:o.value??null}},list:async(i={})=>{if(i.limit!==void 0&&(!Number.isInteger(i.limit)||i.limit<=0))throw new TypeError("@lunora/bindings/kv: `limit` must be a positive integer");let{prefix:n}=i;if(n!==void 0&&u(n),e!==void 0){const l=e.endsWith("/")?e:`${e}/`;n=i.prefix===void 0?l:`${l}${i.prefix}`,u(n)}const o=i.limit===void 0?void 0:Math.min(i.limit,g),r=await a.list({cursor:i.cursor,limit:o,prefix:n}),h=r.keys.map(l=>({...l,name:y(l.name)}));return{cursor:r.list_complete?void 0:r.cursor,keys:h,listComplete:r.list_complete}},put:async(i,n,o={})=>{const r=o.raw?n:JSON.stringify(n);await a.put(s(i),r,x(o))}}};export{b as createKv,f as scopeKey};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/bindings",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.22",
|
|
4
4
|
"description": "Lightweight Cloudflare binding helpers for Lunora — ctx.kv, ctx.images, ctx.analytics, ctx.pipelines, ctx.vectors, ctx.r2sql — one install, per-binding subpaths",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analytics",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
67
|
+
"@lunora/errors": "1.0.0-alpha.16",
|
|
68
68
|
"@lunora/platform": "1.0.0-alpha.6"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as a}from"@lunora/errors";const s=/^[a-z][a-z\d+\-.]*:\/\//i,c=[",","=","#","?","/"],d=e=>e.endsWith("/")?e.slice(0,-1):e,m=e=>e.startsWith("/")?e.slice(1):e,l=e=>Object.entries(e).filter(([,r])=>r!==void 0&&(typeof r=="string"||typeof r=="number")).map(([r,i])=>{const t=String(i),n=c.find(o=>t.includes(o));if(n!==void 0)throw new a("INTERNAL",`@lunora/bindings/images: transform option \`${r}\` value \`${t}\` contains a \`${n}\`, which the /cdn-cgi/image/ option path cannot represent (\`,\`/\`=\` are the option/key-value separators; \`#\`/\`?\`/\`/\` are URL-structural). Percent-encode the value — for colors use \`%23RRGGBB\`, not \`#RRGGBB\` or \`rgb(r,g,b)\`.`);return`${r}=${t}`}).join(","),g=e=>e.split("/").map(r=>encodeURIComponent(r)).join("/"),p=e=>{const r=d(e.baseUrl);if(e.imageId!==void 0){const o=e.variant??"public";return`${r}/${encodeURIComponent(e.imageId)}/${encodeURIComponent(o)}`}if(e.key===void 0)throw new a("INTERNAL","@lunora/bindings/images: buildImageDeliveryUrl requires either `imageId` or `key`");const i=e.transform===void 0?"":l(e.transform),t=s.test(e.key)?e.key:`/${g(m(e.key))}`,n=i===""?"/cdn-cgi/image":`/cdn-cgi/image/${i}`;return`${r}${n}${t.startsWith("/")?t:`/${t}`}`};export{p as buildImageDeliveryUrl};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as r}from"@lunora/errors";const l=512,y=1e3,g=new TextEncoder,u=t=>g.encode(t).length,p=t=>{if(typeof t!="string"||t.length===0)throw new TypeError("@lunora/bindings/kv: key must be a non-empty string");if(u(t)>l)throw new r("INTERNAL",`@lunora/bindings/kv: key exceeds ${String(l)}-byte limit`);if(t.includes("\0"))throw new r("INTERNAL","@lunora/bindings/kv: key contains NUL byte");const n=t.split("/");for(const o of n)if(o==="."||o==="..")throw new r("INTERNAL","@lunora/bindings/kv: key contains a `.`/`..` path component")},m=t=>{if(t.length===0)return;if(u(t)>l)throw new r("INTERNAL",`@lunora/bindings/kv: prefix exceeds ${String(l)}-byte limit`);if(t.includes("\0"))throw new r("INTERNAL","@lunora/bindings/kv: prefix contains NUL byte");const n=t.split("/");for(const o of n)if(o==="."||o==="..")throw new r("INTERNAL","@lunora/bindings/kv: prefix contains a `.`/`..` path component")},h=(t,n)=>{p(t),p(n);const o=`${t.endsWith("/")?t.slice(0,-1):t}/${n}`;if(u(o)>l)throw new r("INTERNAL",`@lunora/bindings/kv: scoped key exceeds ${String(l)}-byte limit`);return o},f=t=>{const n={};if(t.expiration!==void 0&&t.expirationTtl!==void 0)throw new r("INTERNAL","@lunora/bindings/kv: `expiration` and `expirationTtl` are mutually exclusive");return t.expiration!==void 0&&(n.expiration=t.expiration),t.expirationTtl!==void 0&&(n.expirationTtl=t.expirationTtl),t.metadata!==void 0&&(n.metadata=t.metadata),Object.keys(n).length>0?n:void 0},T=t=>{if(!t.namespace)throw new TypeError("@lunora/bindings/kv: `namespace` is required");const{keyPrefix:n,namespace:o}=t;n!==void 0&&p(n);const c=i=>n===void 0?(p(i),i):h(n,i),v=i=>{if(n===void 0)return i;const e=n.endsWith("/")?n:`${n}/`;return i.startsWith(e)?i.slice(e.length):i};return{delete:async i=>{await o.delete(c(i))},get:async(i,e={})=>await o.get(c(i),{cacheTtl:e.cacheTtl,type:"json"})??null,getRaw:async(i,e={})=>await o.get(c(i),{cacheTtl:e.cacheTtl,type:e.type??"text"})??null,getWithMetadata:async(i,e={})=>{const a=await o.getWithMetadata(c(i),{cacheTtl:e.cacheTtl,type:"json"});return{metadata:a.metadata??null,value:a.value??null}},list:async(i={})=>{if(i.limit!==void 0&&(!Number.isInteger(i.limit)||i.limit<=0))throw new TypeError("@lunora/bindings/kv: `limit` must be a positive integer");let{prefix:e}=i;if(e!==void 0&&m(e),n!==void 0){const d=n.endsWith("/")?n:`${n}/`;e=i.prefix===void 0?d:`${d}${i.prefix}`,m(e)}const a=i.limit===void 0?void 0:Math.min(i.limit,y),s=await o.list({cursor:i.cursor,limit:a,prefix:e}),w=s.keys.map(d=>({...d,name:v(d.name)}));return{cursor:s.list_complete?void 0:s.cursor,keys:w,listComplete:s.list_complete}},put:async(i,e,a={})=>{const s=a.raw?e:JSON.stringify(e);await o.put(c(i),s,f(a))}}};export{T as createKv,h as scopeKey};
|