@lunora/bindings 1.0.0-alpha.25 → 1.0.0-alpha.27

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/kv/index.mjs CHANGED
@@ -1 +1 @@
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};
1
+ import{createKv as o,scopeKey as t}from"../packem_shared/createKv-C05fokXt.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 o}from"@lunora/errors";const d=512,w=1e3,m=1024,f=new TextEncoder,u=t=>f.encode(t).length,y=(t,e)=>{if(u(t)>d)throw new o("INTERNAL",`@lunora/bindings/kv: ${e} exceeds ${String(d)}-byte limit`);if(t.includes("\0"))throw new o("INTERNAL",`@lunora/bindings/kv: ${e} contains NUL byte`);for(const a of t.split("/"))if(a==="."||a==="..")throw new o("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");y(t,"key")},v=t=>{t.length>0&&y(t,"prefix")},x=(t,e)=>{p(t),p(e);const a=`${t.endsWith("/")?t.slice(0,-1):t}/${e}`;if(u(a)>d)throw new o("INTERNAL",`@lunora/bindings/kv: scoped key exceeds ${String(d)}-byte limit`);return a},T=t=>{const e={};if(t.expiration!==void 0&&t.expirationTtl!==void 0)throw new o("INTERNAL","@lunora/bindings/kv: `expiration` and `expirationTtl` are mutually exclusive");if(t.expiration!==void 0&&(e.expiration=t.expiration),t.expirationTtl!==void 0&&(e.expirationTtl=t.expirationTtl),t.metadata!==void 0){let a;try{a=JSON.stringify(t.metadata)}catch{throw new o("INTERNAL","@lunora/bindings/kv: metadata is not JSON-serializable (cyclic value, bigint, or similar)")}if(u(a)>m)throw new o("INTERNAL",`@lunora/bindings/kv: metadata exceeds ${String(m)}-byte limit`);e.metadata=t.metadata}return Object.keys(e).length>0?e:void 0},N=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 l=i=>e===void 0?(p(i),i):x(e,i),g=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(l(i))},get:async(i,n={})=>await a.get(l(i),{cacheTtl:n.cacheTtl,type:"json"})??null,getRaw:async(i,n={})=>await a.get(l(i),{cacheTtl:n.cacheTtl,type:n.type??"text"})??null,getWithMetadata:async(i,n={})=>{const r=await a.getWithMetadata(l(i),{cacheTtl:n.cacheTtl,type:"json"});return{metadata:r.metadata??null,value:r.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&&v(n),e!==void 0){const c=e.endsWith("/")?e:`${e}/`;n=i.prefix===void 0?c:`${c}${i.prefix}`,v(n)}const r=i.limit===void 0?void 0:Math.min(i.limit,w),s=await a.list({cursor:i.cursor,limit:r,prefix:n}),h=s.keys.map(c=>({...c,name:g(c.name)}));return{cursor:s.list_complete?void 0:s.cursor,keys:h,listComplete:s.list_complete}},put:async(i,n,r={})=>{const s=r.raw?n:JSON.stringify(n);await a.put(l(i),s,T(r))}}};export{N as createKv,x as scopeKey};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/bindings",
3
- "version": "1.0.0-alpha.25",
3
+ "version": "1.0.0-alpha.27",
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,8 +64,8 @@
64
64
  "access": "public"
65
65
  },
66
66
  "dependencies": {
67
- "@lunora/errors": "1.0.0-alpha.18",
68
- "@lunora/platform": "1.0.0-alpha.8"
67
+ "@lunora/errors": "1.0.0-alpha.20",
68
+ "@lunora/platform": "1.0.0-alpha.9"
69
69
  },
70
70
  "engines": {
71
71
  "node": "^22.15.0 || >=24.11.0"
@@ -1 +0,0 @@
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};