@uploadista/kv-store-filesystem 0.0.7 → 0.0.9

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
- 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`);u=s(u);let d=require(`@uploadista/core/types`);d=s(d);let f=require(`effect`);f=s(f);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
+ 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;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseKvStore, BaseKvStoreService } from "@uploadista/core/types";
1
+ import { BaseKvStore } from "@uploadista/core/types";
2
2
  import { Layer } from "effect";
3
3
 
4
4
  //#region src/file-kv-store.d.ts
@@ -8,7 +8,7 @@ type FileKvStoreOptions = {
8
8
  declare function makeFileBaseKvStore({
9
9
  directory
10
10
  }: FileKvStoreOptions): BaseKvStore;
11
- declare const fileKvStore: (config: FileKvStoreOptions) => Layer.Layer<BaseKvStoreService, never, never>;
11
+ declare const fileKvStore: (config: FileKvStoreOptions) => Layer.Layer<unknown, never, never>;
12
12
  //#endregion
13
13
  export { FileKvStoreOptions, fileKvStore, makeFileBaseKvStore };
14
14
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/file-kv-store.ts"],"sourcesContent":[],"mappings":";;;;KAMY,kBAAA;;AAAZ,CAAA;AAKgB,iBAAA,mBAAA,CAAmB;EAAA;AAAA,CAAA,EAEhC,kBAFgC,CAAA,EAEX,WAFW;AACjC,cA4CW,WA5CX,EAAA,CAAA,MAAA,EA4CkC,kBA5ClC,EAAA,GA4CoD,KAAA,CAAA,KA5CpD,CA4CoD,kBA5CpD,EAAA,KAAA,EAAA,KAAA,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/file-kv-store.ts"],"sourcesContent":[],"mappings":";;;;KAMY,kBAAA;;AAAZ,CAAA;AAKgB,iBAAA,mBAAA,CAAmB;EAAA;AAAA,CAAA,EAEhC,kBAFgC,CAAA,EAEX,WAFW;AACjC,cA4CW,WA5CX,EAAA,CAAA,MAAA,EA4CkC,kBA5ClC,EAAA,GA4CoD,KAAA,CAAA,KA5CpD,CAAA,OAAA,EAAA,KAAA,EAAA,KAAA,CAAA"}
@@ -1,4 +1,4 @@
1
- import { BaseKvStore, BaseKvStoreService } from "@uploadista/core/types";
1
+ import { BaseKvStore } from "@uploadista/core/types";
2
2
  import { Layer } from "effect";
3
3
 
4
4
  //#region src/file-kv-store.d.ts
@@ -8,7 +8,7 @@ type FileKvStoreOptions = {
8
8
  declare function makeFileBaseKvStore({
9
9
  directory
10
10
  }: FileKvStoreOptions): BaseKvStore;
11
- declare const fileKvStore: (config: FileKvStoreOptions) => Layer.Layer<BaseKvStoreService, never, never>;
11
+ declare const fileKvStore: (config: FileKvStoreOptions) => Layer.Layer<unknown, never, never>;
12
12
  //#endregion
13
13
  export { FileKvStoreOptions, fileKvStore, makeFileBaseKvStore };
14
- //# sourceMappingURL=index.d.ts.map
14
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/file-kv-store.ts"],"sourcesContent":[],"mappings":";;;;KAMY,kBAAA;;AAAZ,CAAA;AAKgB,iBAAA,mBAAA,CAAmB;EAAA;AAAA,CAAA,EAEhC,kBAFgC,CAAA,EAEX,WAFW;AACjC,cA4CW,WA5CX,EAAA,CAAA,MAAA,EA4CkC,kBA5ClC,EAAA,GA4CoD,KAAA,CAAA,KA5CpD,CAAA,OAAA,EAAA,KAAA,EAAA,KAAA,CAAA"}
@@ -1,2 +1,2 @@
1
1
  import e from"node:fs/promises";import t from"node:path";import{UploadistaError as n}from"@uploadista/core/errors";import{BaseKvStoreService as r}from"@uploadista/core/types";import{Effect as i,Layer as a}from"effect";function o({directory:r}){let a=e=>t.resolve(r,`${e}.json`);return{get:t=>i.tryPromise({try:()=>e.readFile(a(t),`utf8`),catch:e=>n.fromCode(`FILE_NOT_FOUND`,{cause:e})}),set:(t,r)=>i.tryPromise({try:()=>e.writeFile(a(t),r),catch:e=>n.fromCode(`FILE_WRITE_ERROR`,{cause:e})}),delete:t=>i.tryPromise({try:()=>e.rm(a(t)),catch:e=>n.fromCode(`UNKNOWN_ERROR`,{cause:e})}),list:a=>i.tryPromise({try:()=>e.readdir(r),catch:e=>n.fromCode(`UNKNOWN_ERROR`,{cause:e})}).pipe(i.map(e=>e.filter(e=>e.endsWith(`.json`)&&e.startsWith(a)).map(e=>t.basename(e,`.json`)).sort((e,t)=>e.localeCompare(t))))}}const s=e=>a.succeed(r,o(e));export{s as fileKvStore,o as makeFileBaseKvStore};
2
- //# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uploadista/kv-store-filesystem",
3
3
  "type": "module",
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
5
5
  "description": "File system KV store for Uploadista",
6
6
  "license": "MIT",
7
7
  "author": "Uploadista",
@@ -13,13 +13,13 @@
13
13
  }
14
14
  },
15
15
  "dependencies": {
16
- "effect": "3.18.4",
17
- "@uploadista/core": "0.0.7"
16
+ "effect": "3.19.0",
17
+ "@uploadista/core": "0.0.9"
18
18
  },
19
19
  "devDependencies": {
20
- "@types/node": "24.9.1",
21
- "tsdown": "0.15.9",
22
- "@uploadista/typescript-config": "0.0.7"
20
+ "@types/node": "24.10.0",
21
+ "tsdown": "0.16.0",
22
+ "@uploadista/typescript-config": "0.0.9"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsdown",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/file-kv-store.ts"],"sourcesContent":[],"mappings":";;;;KAMY,kBAAA;;AAAZ,CAAA;AAKgB,iBAAA,mBAAA,CAAmB;EAAA;AAAA,CAAA,EAEhC,kBAFgC,CAAA,EAEX,WAFW;AACjC,cA4CW,WA5CX,EAAA,CAAA,MAAA,EA4CkC,kBA5ClC,EAAA,GA4CoD,KAAA,CAAA,KA5CpD,CA4CoD,kBA5CpD,EAAA,KAAA,EAAA,KAAA,CAAA"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","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"}