@walkeros/server-store-fs 0.2.0-next-1772811722420
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/README.md +113 -0
- package/dist/dev.d.mts +27 -0
- package/dist/dev.d.ts +27 -0
- package/dist/dev.js +1 -0
- package/dist/dev.js.map +1 -0
- package/dist/dev.mjs +1 -0
- package/dist/dev.mjs.map +1 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/dist/walkerOS.json +32 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# @walkeros/server-store-fs
|
|
2
|
+
|
|
3
|
+
Local filesystem store for walkerOS server flows. Reads and writes files
|
|
4
|
+
relative to a base directory with path traversal protection.
|
|
5
|
+
|
|
6
|
+
[Source Code](https://github.com/elbwalker/walkerOS/tree/main/packages/server/stores/fs)
|
|
7
|
+
| [NPM](https://www.npmjs.com/package/@walkeros/server-store-fs) |
|
|
8
|
+
[Documentation](https://www.walkeros.io/docs/stores/server/fs)
|
|
9
|
+
|
|
10
|
+
## Quick start (bundled mode)
|
|
11
|
+
|
|
12
|
+
```json
|
|
13
|
+
{
|
|
14
|
+
"version": 1,
|
|
15
|
+
"flows": {
|
|
16
|
+
"default": {
|
|
17
|
+
"server": {},
|
|
18
|
+
"stores": {
|
|
19
|
+
"assets": {
|
|
20
|
+
"package": "@walkeros/server-store-fs",
|
|
21
|
+
"config": {
|
|
22
|
+
"settings": {
|
|
23
|
+
"basePath": "./public"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"transformers": {
|
|
29
|
+
"file": {
|
|
30
|
+
"package": "@walkeros/server-transformer-file",
|
|
31
|
+
"config": { "settings": { "prefix": "/static" } },
|
|
32
|
+
"env": { "store": "$store:assets" }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Integrated mode
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { startFlow } from '@walkeros/collector';
|
|
44
|
+
import { storeFsInit } from '@walkeros/server-store-fs';
|
|
45
|
+
|
|
46
|
+
await startFlow({
|
|
47
|
+
stores: {
|
|
48
|
+
assets: {
|
|
49
|
+
code: storeFsInit,
|
|
50
|
+
config: {
|
|
51
|
+
settings: {
|
|
52
|
+
basePath: './public',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Features
|
|
61
|
+
|
|
62
|
+
- **Path traversal protection**: Rejects `..`, absolute paths, and backslash
|
|
63
|
+
traversal
|
|
64
|
+
- **Base path scoping**: All operations restricted to the configured directory
|
|
65
|
+
- **Auto-create directories**: `set()` creates intermediate directories
|
|
66
|
+
automatically
|
|
67
|
+
- **Buffer output**: `get()` returns `Buffer` for file transformer compatibility
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm install @walkeros/server-store-fs
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Configuration
|
|
76
|
+
|
|
77
|
+
| Setting | Type | Required | Default | Description |
|
|
78
|
+
| ---------- | -------- | -------- | ------- | ---------------------------------- |
|
|
79
|
+
| `basePath` | `string` | Yes | — | Root directory for file operations |
|
|
80
|
+
|
|
81
|
+
## API
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
const file = await store.get('walker.js'); // Buffer | undefined
|
|
85
|
+
await store.set('data.json', Buffer.from('{}')); // void
|
|
86
|
+
await store.delete('old-file.txt'); // void
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Security
|
|
90
|
+
|
|
91
|
+
All keys are validated against path traversal attacks:
|
|
92
|
+
|
|
93
|
+
- `..` segments are rejected
|
|
94
|
+
- Absolute paths (`/etc/passwd`) are rejected
|
|
95
|
+
- Backslash traversal (`..\\`) is rejected
|
|
96
|
+
- Resolved paths must stay within `basePath`
|
|
97
|
+
|
|
98
|
+
Rejected operations log a warning and return `undefined` (get) or no-op
|
|
99
|
+
(set/delete).
|
|
100
|
+
|
|
101
|
+
## Behavior notes
|
|
102
|
+
|
|
103
|
+
- **Async operations** — all methods return Promises (filesystem I/O)
|
|
104
|
+
- **Auto-creates directories** — `set` creates intermediate dirs via `mkdir -p`
|
|
105
|
+
- **Missing files** — `get` returns `undefined`, `delete` is a no-op
|
|
106
|
+
- **Buffer values** — `get` returns `Buffer`, `set` expects `Buffer`
|
|
107
|
+
|
|
108
|
+
## Related
|
|
109
|
+
|
|
110
|
+
- [Documentation](https://www.walkeros.io/docs/stores/server/fs)
|
|
111
|
+
- [Stores overview](https://www.walkeros.io/docs/stores)
|
|
112
|
+
- [S3 store](https://www.walkeros.io/docs/stores/server/s3) — for cloud
|
|
113
|
+
deployments
|
package/dist/dev.d.mts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
2
|
+
import { z } from '@walkeros/core/dev';
|
|
3
|
+
import { Store } from '@walkeros/core';
|
|
4
|
+
|
|
5
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
6
|
+
basePath: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
type Settings = z.infer<typeof SettingsSchema>;
|
|
9
|
+
|
|
10
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
11
|
+
|
|
12
|
+
type index$1_Settings = Settings;
|
|
13
|
+
declare const index$1_SettingsSchema: typeof SettingsSchema;
|
|
14
|
+
declare const index$1_settings: typeof settings;
|
|
15
|
+
declare namespace index$1 {
|
|
16
|
+
export { type index$1_Settings as Settings, index$1_SettingsSchema as SettingsSchema, index$1_settings as settings };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Serve static files from a local directory */
|
|
20
|
+
declare const staticAssets: Store.Config;
|
|
21
|
+
|
|
22
|
+
declare const index_staticAssets: typeof staticAssets;
|
|
23
|
+
declare namespace index {
|
|
24
|
+
export { index_staticAssets as staticAssets };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { index as examples, index$1 as schemas };
|
package/dist/dev.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
2
|
+
import { z } from '@walkeros/core/dev';
|
|
3
|
+
import { Store } from '@walkeros/core';
|
|
4
|
+
|
|
5
|
+
declare const SettingsSchema: z.ZodObject<{
|
|
6
|
+
basePath: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
type Settings = z.infer<typeof SettingsSchema>;
|
|
9
|
+
|
|
10
|
+
declare const settings: _walkeros_core_dev.JSONSchema;
|
|
11
|
+
|
|
12
|
+
type index$1_Settings = Settings;
|
|
13
|
+
declare const index$1_SettingsSchema: typeof SettingsSchema;
|
|
14
|
+
declare const index$1_settings: typeof settings;
|
|
15
|
+
declare namespace index$1 {
|
|
16
|
+
export { type index$1_Settings as Settings, index$1_SettingsSchema as SettingsSchema, index$1_settings as settings };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Serve static files from a local directory */
|
|
20
|
+
declare const staticAssets: Store.Config;
|
|
21
|
+
|
|
22
|
+
declare const index_staticAssets: typeof staticAssets;
|
|
23
|
+
declare namespace index {
|
|
24
|
+
export { index_staticAssets as staticAssets };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { index as examples, index$1 as schemas };
|
package/dist/dev.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,a=(e,r)=>{for(var o in r)t(e,o,{get:r[o],enumerable:!0})},i={};a(i,{examples:()=>u,schemas:()=>c}),module.exports=(e=i,((e,a,i,c)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let l of o(a))s.call(e,l)||l===i||t(e,l,{get:()=>a[l],enumerable:!(c=r(a,l))||c.enumerable});return e})(t({},"__esModule",{value:!0}),e));var c={};a(c,{SettingsSchema:()=>p,settings:()=>b});var l=require("@walkeros/core/dev"),n=require("@walkeros/core/dev"),p=n.z.object({basePath:n.z.string().min(1).describe("Root directory for file operations. All keys are resolved relative to this path.")}),b=(0,l.zodToSchema)(p),u={};a(u,{staticAssets:()=>f});var f={settings:{basePath:"./public"}};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/examples/index.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport { SettingsSchema, type Settings } from './settings';\n\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n basePath: z\n .string()\n .min(1)\n .describe(\n 'Root directory for file operations. All keys are resolved relative to this path.',\n ),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import type { Store } from '@walkeros/core';\n\n/** Serve static files from a local directory */\nexport const staticAssets: Store.Config = {\n settings: {\n basePath: './public',\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACrC,UAAU,aACP,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AACJ,CAAC;;;ADJM,IAAM,eAAW,yBAAY,cAAc;;;AELlD;AAAA;AAAA;AAAA;AAGO,IAAM,eAA6B;AAAA,EACxC,UAAU;AAAA,IACR,UAAU;AAAA,EACZ;AACF;","names":["import_dev"]}
|
package/dist/dev.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,r=(r,t)=>{for(var s in t)e(r,s,{get:t[s],enumerable:!0})},t={};r(t,{SettingsSchema:()=>o,settings:()=>i});import{zodToSchema as s}from"@walkeros/core/dev";import{z as a}from"@walkeros/core/dev";var o=a.object({basePath:a.string().min(1).describe("Root directory for file operations. All keys are resolved relative to this path.")}),i=s(o),c={};r(c,{staticAssets:()=>l});var l={settings:{basePath:"./public"}};export{c as examples,t as schemas};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/examples/index.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\n\nexport { SettingsSchema, type Settings } from './settings';\n\nexport const settings = zodToSchema(SettingsSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n basePath: z\n .string()\n .min(1)\n .describe(\n 'Root directory for file operations. All keys are resolved relative to this path.',\n ),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import type { Store } from '@walkeros/core';\n\n/** Serve static files from a local directory */\nexport const staticAssets: Store.Config = {\n settings: {\n basePath: './public',\n },\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,UAAU,EACP,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AACJ,CAAC;;;ADJM,IAAM,WAAW,YAAY,cAAc;;;AELlD;AAAA;AAAA;AAAA;AAGO,IAAM,eAA6B;AAAA,EACxC,UAAU;AAAA,IACR,UAAU;AAAA,EACZ;AACF;","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Store } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
interface FsStoreSettings {
|
|
4
|
+
/** Root directory for file lookups. All keys resolved relative to this. */
|
|
5
|
+
basePath: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare const storeFsInit: Store.Init<Store.Types<FsStoreSettings>>;
|
|
9
|
+
|
|
10
|
+
export { type FsStoreSettings, storeFsInit as default, storeFsInit };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Store } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
interface FsStoreSettings {
|
|
4
|
+
/** Root directory for file lookups. All keys resolved relative to this. */
|
|
5
|
+
basePath: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare const storeFsInit: Store.Init<Store.Types<FsStoreSettings>>;
|
|
9
|
+
|
|
10
|
+
export { type FsStoreSettings, storeFsInit as default, storeFsInit };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t=Object.create,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,o=(e,t,i,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of a(t))s.call(e,c)||c===i||r(e,c,{get:()=>t[c],enumerable:!(o=n(t,c))||o.enumerable});return e},c=(e,n,a)=>(a=null!=e?t(i(e)):{},o(!n&&e&&e.__esModule?a:r(a,"default",{value:e,enumerable:!0}),e)),u={};((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(u,{default:()=>p,storeFsInit:()=>p}),module.exports=(e=u,o(r({},"__esModule",{value:!0}),e));var l=c(require("fs/promises")),f=c(require("path"));var p=e=>{const t=e.config.settings,r=f.resolve(t.basePath);function n(t){if(!function(e){return!(!e||e.startsWith("/")||e.startsWith("\\")||e.split(/[/\\]/).includes(".."))}(t))return void e.logger.warn("Path traversal rejected",{key:t});const n=f.join(r,t);return n.startsWith(r+f.sep)||n===r?n:void 0}return{type:"fs",config:e.config,async get(e){const t=n(e);if(t)try{return await l.readFile(t)}catch(e){return}},async set(e,t){const r=n(e);r&&(await l.mkdir(f.dirname(r),{recursive:!0}),await l.writeFile(r,t))},async delete(e){const t=n(e);if(t)try{await l.unlink(t)}catch(e){}}}};//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/store.ts"],"sourcesContent":["export { storeFsInit } from './store';\nexport type { FsStoreSettings } from './types';\nexport { storeFsInit as default } from './store';\n","import * as fs from 'fs/promises';\nimport * as path from 'path';\nimport type { Store } from '@walkeros/core';\nimport type { FsStoreSettings } from './types';\n\nfunction isValidKey(key: string): boolean {\n if (!key || key.startsWith('/') || key.startsWith('\\\\')) return false;\n return !key.split(/[/\\\\]/).includes('..');\n}\n\nexport const storeFsInit: Store.Init<Store.Types<FsStoreSettings>> = (\n context,\n) => {\n const settings = context.config.settings as FsStoreSettings;\n const basePath = path.resolve(settings.basePath);\n\n function resolvePath(key: string): string | undefined {\n if (!isValidKey(key)) {\n context.logger.warn('Path traversal rejected', { key });\n return undefined;\n }\n const resolved = path.join(basePath, key);\n if (!resolved.startsWith(basePath + path.sep) && resolved !== basePath)\n return undefined;\n return resolved;\n }\n\n return {\n type: 'fs',\n config: context.config as Store.Config<Store.Types<FsStoreSettings>>,\n\n async get(key: string): Promise<Buffer | undefined> {\n const filePath = resolvePath(key);\n if (!filePath) return undefined;\n try {\n return await fs.readFile(filePath);\n } catch {\n return undefined;\n }\n },\n\n async set(key: string, value: unknown): Promise<void> {\n const filePath = resolvePath(key);\n if (!filePath) return;\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, value as Buffer);\n },\n\n async delete(key: string): Promise<void> {\n const filePath = resolvePath(key);\n if (!filePath) return;\n try {\n await fs.unlink(filePath);\n } catch {\n /* ignore */\n }\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,SAAoB;AACpB,WAAsB;AAItB,SAAS,WAAW,KAAsB;AACxC,MAAI,CAAC,OAAO,IAAI,WAAW,GAAG,KAAK,IAAI,WAAW,IAAI,EAAG,QAAO;AAChE,SAAO,CAAC,IAAI,MAAM,OAAO,EAAE,SAAS,IAAI;AAC1C;AAEO,IAAM,cAAwD,CACnE,YACG;AACH,QAAM,WAAW,QAAQ,OAAO;AAChC,QAAM,WAAgB,aAAQ,SAAS,QAAQ;AAE/C,WAAS,YAAY,KAAiC;AACpD,QAAI,CAAC,WAAW,GAAG,GAAG;AACpB,cAAQ,OAAO,KAAK,2BAA2B,EAAE,IAAI,CAAC;AACtD,aAAO;AAAA,IACT;AACA,UAAM,WAAgB,UAAK,UAAU,GAAG;AACxC,QAAI,CAAC,SAAS,WAAW,WAAgB,QAAG,KAAK,aAAa;AAC5D,aAAO;AACT,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,QAAQ;AAAA,IAEhB,MAAM,IAAI,KAA0C;AAClD,YAAM,WAAW,YAAY,GAAG;AAChC,UAAI,CAAC,SAAU,QAAO;AACtB,UAAI;AACF,eAAO,MAAS,YAAS,QAAQ;AAAA,MACnC,SAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IAEA,MAAM,IAAI,KAAa,OAA+B;AACpD,YAAM,WAAW,YAAY,GAAG;AAChC,UAAI,CAAC,SAAU;AACf,YAAS,SAAW,aAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;AAC1D,YAAS,aAAU,UAAU,KAAe;AAAA,IAC9C;AAAA,IAEA,MAAM,OAAO,KAA4B;AACvC,YAAM,WAAW,YAAY,GAAG;AAChC,UAAI,CAAC,SAAU;AACf,UAAI;AACF,cAAS,UAAO,QAAQ;AAAA,MAC1B,SAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as t from"fs/promises";import*as r from"path";var e=e=>{const i=e.config.settings,s=r.resolve(i.basePath);function a(t){if(!function(t){return!(!t||t.startsWith("/")||t.startsWith("\\")||t.split(/[/\\]/).includes(".."))}(t))return void e.logger.warn("Path traversal rejected",{key:t});const i=r.join(s,t);return i.startsWith(s+r.sep)||i===s?i:void 0}return{type:"fs",config:e.config,async get(r){const e=a(r);if(e)try{return await t.readFile(e)}catch(t){return}},async set(e,i){const s=a(e);s&&(await t.mkdir(r.dirname(s),{recursive:!0}),await t.writeFile(s,i))},async delete(r){const e=a(r);if(e)try{await t.unlink(e)}catch(t){}}}};export{e as default,e as storeFsInit};//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/store.ts"],"sourcesContent":["import * as fs from 'fs/promises';\nimport * as path from 'path';\nimport type { Store } from '@walkeros/core';\nimport type { FsStoreSettings } from './types';\n\nfunction isValidKey(key: string): boolean {\n if (!key || key.startsWith('/') || key.startsWith('\\\\')) return false;\n return !key.split(/[/\\\\]/).includes('..');\n}\n\nexport const storeFsInit: Store.Init<Store.Types<FsStoreSettings>> = (\n context,\n) => {\n const settings = context.config.settings as FsStoreSettings;\n const basePath = path.resolve(settings.basePath);\n\n function resolvePath(key: string): string | undefined {\n if (!isValidKey(key)) {\n context.logger.warn('Path traversal rejected', { key });\n return undefined;\n }\n const resolved = path.join(basePath, key);\n if (!resolved.startsWith(basePath + path.sep) && resolved !== basePath)\n return undefined;\n return resolved;\n }\n\n return {\n type: 'fs',\n config: context.config as Store.Config<Store.Types<FsStoreSettings>>,\n\n async get(key: string): Promise<Buffer | undefined> {\n const filePath = resolvePath(key);\n if (!filePath) return undefined;\n try {\n return await fs.readFile(filePath);\n } catch {\n return undefined;\n }\n },\n\n async set(key: string, value: unknown): Promise<void> {\n const filePath = resolvePath(key);\n if (!filePath) return;\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n await fs.writeFile(filePath, value as Buffer);\n },\n\n async delete(key: string): Promise<void> {\n const filePath = resolvePath(key);\n if (!filePath) return;\n try {\n await fs.unlink(filePath);\n } catch {\n /* ignore */\n }\n },\n };\n};\n"],"mappings":";AAAA,YAAY,QAAQ;AACpB,YAAY,UAAU;AAItB,SAAS,WAAW,KAAsB;AACxC,MAAI,CAAC,OAAO,IAAI,WAAW,GAAG,KAAK,IAAI,WAAW,IAAI,EAAG,QAAO;AAChE,SAAO,CAAC,IAAI,MAAM,OAAO,EAAE,SAAS,IAAI;AAC1C;AAEO,IAAM,cAAwD,CACnE,YACG;AACH,QAAM,WAAW,QAAQ,OAAO;AAChC,QAAM,WAAgB,aAAQ,SAAS,QAAQ;AAE/C,WAAS,YAAY,KAAiC;AACpD,QAAI,CAAC,WAAW,GAAG,GAAG;AACpB,cAAQ,OAAO,KAAK,2BAA2B,EAAE,IAAI,CAAC;AACtD,aAAO;AAAA,IACT;AACA,UAAM,WAAgB,UAAK,UAAU,GAAG;AACxC,QAAI,CAAC,SAAS,WAAW,WAAgB,QAAG,KAAK,aAAa;AAC5D,aAAO;AACT,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,QAAQ;AAAA,IAEhB,MAAM,IAAI,KAA0C;AAClD,YAAM,WAAW,YAAY,GAAG;AAChC,UAAI,CAAC,SAAU,QAAO;AACtB,UAAI;AACF,eAAO,MAAS,YAAS,QAAQ;AAAA,MACnC,SAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IAEA,MAAM,IAAI,KAAa,OAA+B;AACpD,YAAM,WAAW,YAAY,GAAG;AAChC,UAAI,CAAC,SAAU;AACf,YAAS,SAAW,aAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;AAC1D,YAAS,aAAU,UAAU,KAAe;AAAA,IAC9C;AAAA,IAEA,MAAM,OAAO,KAA4B;AACvC,YAAM,WAAW,YAAY,GAAG;AAChC,UAAI,CAAC,SAAU;AACf,UAAI;AACF,cAAS,UAAO,QAAQ;AAAA,MAC1B,SAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$meta": {
|
|
3
|
+
"package": "@walkeros/server-store-fs",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "store",
|
|
6
|
+
"platform": "server"
|
|
7
|
+
},
|
|
8
|
+
"schemas": {
|
|
9
|
+
"settings": {
|
|
10
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"basePath": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"minLength": 1,
|
|
16
|
+
"description": "Root directory for file operations. All keys are resolved relative to this path."
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": [
|
|
20
|
+
"basePath"
|
|
21
|
+
],
|
|
22
|
+
"additionalProperties": false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"examples": {
|
|
26
|
+
"staticAssets": {
|
|
27
|
+
"settings": {
|
|
28
|
+
"basePath": "./public"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@walkeros/server-store-fs",
|
|
3
|
+
"description": "Filesystem store for walkerOS server - reads and writes files via the Store interface",
|
|
4
|
+
"version": "0.2.0-next-1772811722420",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./dev": {
|
|
16
|
+
"types": "./dist/dev.d.ts",
|
|
17
|
+
"import": "./dist/dev.mjs",
|
|
18
|
+
"require": "./dist/dev.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist/**"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup --silent",
|
|
26
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
27
|
+
"dev": "jest --watchAll --colors",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"lint": "eslint \"**/*.ts*\"",
|
|
30
|
+
"test": "jest",
|
|
31
|
+
"update": "npx npm-check-updates -u && npm update"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@walkeros/core": "2.2.0-next-1772811722420"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@walkeros/core": "2.2.0-next-1772811722420"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"url": "git+https://github.com/elbwalker/walkerOS.git",
|
|
41
|
+
"directory": "packages/server/stores/fs"
|
|
42
|
+
},
|
|
43
|
+
"author": "elbwalker <hello@elbwalker.com>",
|
|
44
|
+
"homepage": "https://github.com/elbwalker/walkerOS#readme",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/elbwalker/walkerOS/issues"
|
|
47
|
+
},
|
|
48
|
+
"walkerOS": {
|
|
49
|
+
"type": "store",
|
|
50
|
+
"platform": "server"
|
|
51
|
+
},
|
|
52
|
+
"keywords": [
|
|
53
|
+
"walkerOS",
|
|
54
|
+
"store",
|
|
55
|
+
"filesystem",
|
|
56
|
+
"server"
|
|
57
|
+
],
|
|
58
|
+
"funding": [
|
|
59
|
+
{
|
|
60
|
+
"type": "GitHub Sponsors",
|
|
61
|
+
"url": "https://github.com/sponsors/elbwalker"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|