@uploadista/kv-store-filesystem 1.0.0-beta.2 → 1.0.0-beta.4

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/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`node:fs/promises`);c=s(c);let l=require(`node:path`);l=s(l);let u=require(`@uploadista/core/errors`),d=require(`@uploadista/core/types`),f=require(`effect`);function p({directory:e}){let t=t=>l.default.resolve(e,`${t}.json`);return{get:e=>f.Effect.tryPromise({try:()=>c.default.readFile(t(e),`utf8`),catch:e=>u.UploadistaError.fromCode(`FILE_NOT_FOUND`,{cause:e})}),set:(e,n)=>f.Effect.tryPromise({try:()=>c.default.writeFile(t(e),n),catch:e=>u.UploadistaError.fromCode(`FILE_WRITE_ERROR`,{cause:e})}),delete:e=>f.Effect.tryPromise({try:()=>c.default.rm(t(e)),catch:e=>u.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:e})}),list:t=>f.Effect.tryPromise({try:()=>c.default.readdir(e),catch:e=>u.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:e})}).pipe(f.Effect.map(e=>e.filter(e=>e.endsWith(`.json`)&&e.startsWith(t)).map(e=>l.default.basename(e,`.json`)).sort((e,t)=>e.localeCompare(t))))}}const m=e=>f.Layer.succeed(d.BaseKvStoreService,p(e));exports.fileKvStore=m,exports.makeFileBaseKvStore=p;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("node:fs/promises");c=s(c,1);let l=require("node:path");l=s(l,1);let u=require("@uploadista/core/errors"),d=require("@uploadista/core/types"),f=require("effect");function p({directory:e}){let t=t=>l.default.resolve(e,`${t}.json`);return{get:e=>f.Effect.tryPromise({try:()=>c.default.readFile(t(e),`utf8`),catch:e=>u.UploadistaError.fromCode(`FILE_NOT_FOUND`,{cause:e})}),set:(e,n)=>f.Effect.tryPromise({try:()=>c.default.writeFile(t(e),n),catch:e=>u.UploadistaError.fromCode(`FILE_WRITE_ERROR`,{cause:e})}),delete:e=>f.Effect.tryPromise({try:()=>c.default.rm(t(e)),catch:e=>u.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:e})}),list:t=>f.Effect.tryPromise({try:()=>c.default.readdir(e),catch:e=>u.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:e})}).pipe(f.Effect.map(e=>e.filter(e=>e.endsWith(`.json`)&&e.startsWith(t)).map(e=>l.default.basename(e,`.json`)).sort((e,t)=>e.localeCompare(t))))}}const m=e=>f.Layer.succeed(d.BaseKvStoreService,p(e));exports.fileKvStore=m,exports.makeFileBaseKvStore=p;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/file-kv-store.ts"],"mappings":";;;;KAMY,kBAAA;EACV,SAAA;AAAA;AAAA,iBAIc,mBAAA,CAAA;EACd;AAAA,GACC,kBAAA,GAAqB,WAAA;AAAA,cA2CX,WAAA,GAAe,MAAA,EAAQ,kBAAA,KAAkB,KAAA,CAAA,KAAA,CAAA,kBAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/file-kv-store.ts"],"mappings":";;;;KAMY,kBAAA;EACV,SAAS;AAAA;AAAA,iBAIK,mBAAA;EACd;AAAA,GACC,kBAAA,GAAqB,WAAA;AAAA,cA2CX,WAAA,GAAe,MAAA,EAAQ,kBAAA,KAAkB,KAAA,CAAA,KAAA,CAAA,kBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/file-kv-store.ts"],"mappings":";;;;KAMY,kBAAA;EACV,SAAA;AAAA;AAAA,iBAIc,mBAAA,CAAA;EACd;AAAA,GACC,kBAAA,GAAqB,WAAA;AAAA,cA2CX,WAAA,GAAe,MAAA,EAAQ,kBAAA,KAAkB,KAAA,CAAA,KAAA,CAAA,kBAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/file-kv-store.ts"],"mappings":";;;;KAMY,kBAAA;EACV,SAAS;AAAA;AAAA,iBAIK,mBAAA;EACd;AAAA,GACC,kBAAA,GAAqB,WAAA;AAAA,cA2CX,WAAA,GAAe,MAAA,EAAQ,kBAAA,KAAkB,KAAA,CAAA,KAAA,CAAA,kBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/file-kv-store.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { UploadistaError } from \"@uploadista/core/errors\";\nimport { type BaseKvStore, BaseKvStoreService } from \"@uploadista/core/types\";\nimport { Effect, Layer } from \"effect\";\n\nexport type FileKvStoreOptions = {\n directory: string;\n};\n\n// Base Filesystem KV store that stores raw strings\nexport function makeFileBaseKvStore({\n directory,\n}: FileKvStoreOptions): BaseKvStore {\n const resolve = (key: string): string => {\n return path.resolve(directory, `${key}.json`);\n };\n\n return {\n get: (key: string) =>\n Effect.tryPromise({\n try: () => fs.readFile(resolve(key), \"utf8\"),\n catch: (cause) => UploadistaError.fromCode(\"FILE_NOT_FOUND\", { cause }),\n }),\n\n set: (key: string, value: string) =>\n Effect.tryPromise({\n try: () => fs.writeFile(resolve(key), value),\n catch: (cause) =>\n UploadistaError.fromCode(\"FILE_WRITE_ERROR\", { cause }),\n }),\n\n delete: (key: string) =>\n Effect.tryPromise({\n try: () => fs.rm(resolve(key)),\n catch: (cause) => UploadistaError.fromCode(\"UNKNOWN_ERROR\", { cause }),\n }),\n\n list: (keyPrefix: string) =>\n Effect.tryPromise({\n try: () => fs.readdir(directory),\n catch: (cause) => UploadistaError.fromCode(\"UNKNOWN_ERROR\", { cause }),\n }).pipe(\n Effect.map((files) => {\n return files\n .filter(\n (file) => file.endsWith(\".json\") && file.startsWith(keyPrefix),\n )\n .map((file) => path.basename(file, \".json\"))\n .sort((a, b) => a.localeCompare(b));\n }),\n ),\n };\n}\n\n// Base store layer\nexport const fileKvStore = (config: FileKvStoreOptions) =>\n Layer.succeed(BaseKvStoreService, makeFileBaseKvStore(config));\n"],"mappings":"0NAWA,SAAgB,EAAoB,CAClC,aACkC,CAClC,IAAM,EAAW,GACR,EAAK,QAAQ,EAAW,GAAG,EAAI,OAAO,CAG/C,MAAO,CACL,IAAM,GACJ,EAAO,WAAW,CAChB,QAAW,EAAG,SAAS,EAAQ,EAAI,CAAE,OAAO,CAC5C,MAAQ,GAAU,EAAgB,SAAS,iBAAkB,CAAE,QAAO,CAAC,CACxE,CAAC,CAEJ,KAAM,EAAa,IACjB,EAAO,WAAW,CAChB,QAAW,EAAG,UAAU,EAAQ,EAAI,CAAE,EAAM,CAC5C,MAAQ,GACN,EAAgB,SAAS,mBAAoB,CAAE,QAAO,CAAC,CAC1D,CAAC,CAEJ,OAAS,GACP,EAAO,WAAW,CAChB,QAAW,EAAG,GAAG,EAAQ,EAAI,CAAC,CAC9B,MAAQ,GAAU,EAAgB,SAAS,gBAAiB,CAAE,QAAO,CAAC,CACvE,CAAC,CAEJ,KAAO,GACL,EAAO,WAAW,CAChB,QAAW,EAAG,QAAQ,EAAU,CAChC,MAAQ,GAAU,EAAgB,SAAS,gBAAiB,CAAE,QAAO,CAAC,CACvE,CAAC,CAAC,KACD,EAAO,IAAK,GACH,EACJ,OACE,GAAS,EAAK,SAAS,QAAQ,EAAI,EAAK,WAAW,EAAU,CAC/D,CACA,IAAK,GAAS,EAAK,SAAS,EAAM,QAAQ,CAAC,CAC3C,MAAM,EAAG,IAAM,EAAE,cAAc,EAAE,CAAC,CACrC,CACH,CACJ,CAIH,MAAa,EAAe,GAC1B,EAAM,QAAQ,EAAoB,EAAoB,EAAO,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/file-kv-store.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { UploadistaError } from \"@uploadista/core/errors\";\nimport { type BaseKvStore, BaseKvStoreService } from \"@uploadista/core/types\";\nimport { Effect, Layer } from \"effect\";\n\nexport type FileKvStoreOptions = {\n directory: string;\n};\n\n// Base Filesystem KV store that stores raw strings\nexport function makeFileBaseKvStore({\n directory,\n}: FileKvStoreOptions): BaseKvStore {\n const resolve = (key: string): string => {\n return path.resolve(directory, `${key}.json`);\n };\n\n return {\n get: (key: string) =>\n Effect.tryPromise({\n try: () => fs.readFile(resolve(key), \"utf8\"),\n catch: (cause) => UploadistaError.fromCode(\"FILE_NOT_FOUND\", { cause }),\n }),\n\n set: (key: string, value: string) =>\n Effect.tryPromise({\n try: () => fs.writeFile(resolve(key), value),\n catch: (cause) =>\n UploadistaError.fromCode(\"FILE_WRITE_ERROR\", { cause }),\n }),\n\n delete: (key: string) =>\n Effect.tryPromise({\n try: () => fs.rm(resolve(key)),\n catch: (cause) => UploadistaError.fromCode(\"UNKNOWN_ERROR\", { cause }),\n }),\n\n list: (keyPrefix: string) =>\n Effect.tryPromise({\n try: () => fs.readdir(directory),\n catch: (cause) => UploadistaError.fromCode(\"UNKNOWN_ERROR\", { cause }),\n }).pipe(\n Effect.map((files) => {\n return files\n .filter(\n (file) => file.endsWith(\".json\") && file.startsWith(keyPrefix),\n )\n .map((file) => path.basename(file, \".json\"))\n .sort((a, b) => a.localeCompare(b));\n }),\n ),\n };\n}\n\n// Base store layer\nexport const fileKvStore = (config: FileKvStoreOptions) =>\n Layer.succeed(BaseKvStoreService, makeFileBaseKvStore(config));\n"],"mappings":"0NAWA,SAAgB,EAAoB,CAClC,aACkC,CAClC,IAAM,EAAW,GACR,EAAK,QAAQ,EAAW,GAAG,EAAI,MAAM,EAG9C,MAAO,CACL,IAAM,GACJ,EAAO,WAAW,CAChB,QAAW,EAAG,SAAS,EAAQ,CAAG,EAAG,MAAM,EAC3C,MAAQ,GAAU,EAAgB,SAAS,iBAAkB,CAAE,OAAM,CAAC,CACxE,CAAC,EAEH,KAAM,EAAa,IACjB,EAAO,WAAW,CAChB,QAAW,EAAG,UAAU,EAAQ,CAAG,EAAG,CAAK,EAC3C,MAAQ,GACN,EAAgB,SAAS,mBAAoB,CAAE,OAAM,CAAC,CAC1D,CAAC,EAEH,OAAS,GACP,EAAO,WAAW,CAChB,QAAW,EAAG,GAAG,EAAQ,CAAG,CAAC,EAC7B,MAAQ,GAAU,EAAgB,SAAS,gBAAiB,CAAE,OAAM,CAAC,CACvE,CAAC,EAEH,KAAO,GACL,EAAO,WAAW,CAChB,QAAW,EAAG,QAAQ,CAAS,EAC/B,MAAQ,GAAU,EAAgB,SAAS,gBAAiB,CAAE,OAAM,CAAC,CACvE,CAAC,CAAC,CAAC,KACD,EAAO,IAAK,GACH,EACJ,OACE,GAAS,EAAK,SAAS,OAAO,GAAK,EAAK,WAAW,CAAS,CAC/D,CAAC,CACA,IAAK,GAAS,EAAK,SAAS,EAAM,OAAO,CAAC,CAAC,CAC3C,MAAM,EAAG,IAAM,EAAE,cAAc,CAAC,CAAC,CACrC,CACH,CACJ,CACF,CAGA,MAAa,EAAe,GAC1B,EAAM,QAAQ,EAAoB,EAAoB,CAAM,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uploadista/kv-store-filesystem",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.2",
4
+ "version": "1.0.0-beta.4",
5
5
  "description": "File system KV store for Uploadista",
6
6
  "license": "MIT",
7
7
  "author": "Uploadista",
@@ -14,18 +14,18 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@uploadista/core": "1.0.0-beta.2"
17
+ "@uploadista/core": "1.0.0-beta.4"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "effect": "^3.0.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@effect/vitest": "0.27.0",
23
+ "@effect/vitest": "0.29.0",
24
24
  "@types/node": "24.10.9",
25
- "effect": "3.19.19",
26
- "tsdown": "0.20.3",
25
+ "effect": "3.21.4",
26
+ "tsdown": "0.22.3",
27
27
  "vitest": "4.0.18",
28
- "@uploadista/typescript-config": "1.0.0-beta.2"
28
+ "@uploadista/typescript-config": "1.0.0-beta.4"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "tsc --noEmit && tsdown",
package/tsconfig.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "extends": "@uploadista/typescript-config/server.json",
3
3
  "compilerOptions": {
4
- "baseUrl": "./",
5
4
  "paths": {
6
5
  "@/*": ["./src/*"]
7
6
  },