kassza 0.1.0

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -0
  3. package/agents/README.md +59 -0
  4. package/agents/api.md +206 -0
  5. package/agents/pitfalls.md +52 -0
  6. package/agents/recipes.md +217 -0
  7. package/agents/skills/kassza/SKILL.md +29 -0
  8. package/assets/logo-wordmark.svg +25 -0
  9. package/assets/logo.svg +19 -0
  10. package/dist/binary-B89HM03_.cjs +63 -0
  11. package/dist/binary-D0M9U2MD.js +34 -0
  12. package/dist/client-B9kbKKBf.d.cts +748 -0
  13. package/dist/client-zv4enyq7.d.ts +748 -0
  14. package/dist/cookie-stores/index.cjs +153 -0
  15. package/dist/cookie-stores/index.d.cts +63 -0
  16. package/dist/cookie-stores/index.d.ts +63 -0
  17. package/dist/cookie-stores/index.js +144 -0
  18. package/dist/create-BZd6CUO7.cjs +1160 -0
  19. package/dist/create-DDZaNlOz.js +939 -0
  20. package/dist/dates-D2XebOIg.js +34 -0
  21. package/dist/dates-DtHzwNU6.d.cts +7 -0
  22. package/dist/dates-DtHzwNU6.d.ts +7 -0
  23. package/dist/dates-PPxH0n5H.cjs +57 -0
  24. package/dist/errors-B0QJhUW1.cjs +302 -0
  25. package/dist/errors-DapdV5DK.js +273 -0
  26. package/dist/index-CYAGCdKJ.d.cts +56 -0
  27. package/dist/index-CYAGCdKJ.d.ts +56 -0
  28. package/dist/index.cjs +1406 -0
  29. package/dist/index.d.cts +8 -0
  30. package/dist/index.d.ts +8 -0
  31. package/dist/index.js +1394 -0
  32. package/dist/ipn/index.cjs +108 -0
  33. package/dist/ipn/index.d.cts +32 -0
  34. package/dist/ipn/index.d.ts +32 -0
  35. package/dist/ipn/index.js +101 -0
  36. package/dist/money/index.cjs +15 -0
  37. package/dist/money/index.d.cts +2 -0
  38. package/dist/money/index.d.ts +2 -0
  39. package/dist/money/index.js +2 -0
  40. package/dist/money-C9j7nBNP.js +258 -0
  41. package/dist/money-DkiGukAw.cjs +335 -0
  42. package/dist/session-CRGOuz-R.cjs +100 -0
  43. package/dist/session-Dm_45x8K.d.cts +11 -0
  44. package/dist/session-Dm_45x8K.d.ts +11 -0
  45. package/dist/session-OJMLGufT.js +77 -0
  46. package/dist/shared-CrxlxI8n.cjs +207 -0
  47. package/dist/shared-D6DLa4b7.js +100 -0
  48. package/dist/storage/fs.cjs +88 -0
  49. package/dist/storage/fs.d.cts +13 -0
  50. package/dist/storage/fs.d.ts +13 -0
  51. package/dist/storage/fs.js +87 -0
  52. package/dist/storage/index.cjs +643 -0
  53. package/dist/storage/index.d.cts +288 -0
  54. package/dist/storage/index.d.ts +288 -0
  55. package/dist/storage/index.js +619 -0
  56. package/dist/testing/index.cjs +409 -0
  57. package/dist/testing/index.d.cts +35 -0
  58. package/dist/testing/index.d.ts +35 -0
  59. package/dist/testing/index.js +407 -0
  60. package/dist/types-DVRgwcqg.d.cts +26 -0
  61. package/dist/types-DVRgwcqg.d.ts +26 -0
  62. package/dist/validators/index.cjs +296 -0
  63. package/dist/validators/index.d.cts +51 -0
  64. package/dist/validators/index.d.ts +51 -0
  65. package/dist/validators/index.js +278 -0
  66. package/llms.txt +16 -0
  67. package/package.json +151 -0
@@ -0,0 +1,207 @@
1
+ //#region src/storage/errors.ts
2
+ var StorageError = class extends Error {
3
+ name = "StorageError";
4
+ operation;
5
+ key;
6
+ status;
7
+ constructor(message, options) {
8
+ super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
9
+ this.operation = options.operation;
10
+ this.key = options.key;
11
+ this.status = options.status;
12
+ }
13
+ };
14
+ function isStorageError(error) {
15
+ return error instanceof StorageError;
16
+ }
17
+ function describeError(error) {
18
+ if (error instanceof Error) return error.message;
19
+ if (typeof error === "object" && error !== null && "message" in error) return String(error.message);
20
+ return String(error);
21
+ }
22
+ async function guardStorageCall(service, operation, key, call) {
23
+ try {
24
+ return await call();
25
+ } catch (error) {
26
+ throw new StorageError(`${service} hiba (${operation}): ${describeError(error)}`, {
27
+ operation,
28
+ key,
29
+ cause: error
30
+ });
31
+ }
32
+ }
33
+ //#endregion
34
+ //#region src/storage/shared.ts
35
+ const PDF_CONTENT_TYPE = "application/pdf";
36
+ const DEFAULT_URL_EXPIRES_SECONDS = 3600;
37
+ const S3_MAX_PRESIGN_SECONDS = 604800;
38
+ const MAX_KEY_LENGTH = 1024;
39
+ const CONTROL_CHARACTERS = /[\p{Cc}]/u;
40
+ function assertStorageKey(key) {
41
+ const invalid = (reason) => new StorageError(`Érvénytelen tárhelykulcs (${reason}): ${JSON.stringify(key)}`, {
42
+ operation: "key",
43
+ key
44
+ });
45
+ if (typeof key !== "string" || key.length === 0) throw invalid("üres");
46
+ if (key.length > MAX_KEY_LENGTH) throw invalid(`legfeljebb ${MAX_KEY_LENGTH} karakter lehet`);
47
+ if (key.startsWith("/")) throw invalid("nem kezdődhet perjellel");
48
+ if (key.includes("\\")) throw invalid("visszaperjel nem lehet benne");
49
+ if (CONTROL_CHARACTERS.test(key)) throw invalid("vezérlőkaraktert tartalmaz");
50
+ for (const segment of key.split("/")) if (segment === "" || segment === "." || segment === "..") throw invalid("üres, \".\" vagy \"..\" útvonalszakaszt tartalmaz");
51
+ return key;
52
+ }
53
+ function normalizePrefix(prefix) {
54
+ if (!prefix) return "";
55
+ const trimmed = prefix.replace(/^\/+|\/+$/g, "");
56
+ if (trimmed === "") return "";
57
+ assertStorageKey(trimmed);
58
+ return `${trimmed}/`;
59
+ }
60
+ function resolveKey(prefix, key) {
61
+ return `${prefix}${assertStorageKey(key)}`;
62
+ }
63
+ function encodeRfc3986(value) {
64
+ return encodeURIComponent(value).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
65
+ }
66
+ function encodeKeyPath(key) {
67
+ return key.split("/").map(encodeRfc3986).join("/");
68
+ }
69
+ function joinPublicUrl(baseUrl, key) {
70
+ return `${baseUrl.replace(/\/+$/, "")}/${encodeKeyPath(key)}`;
71
+ }
72
+ function assertExpires(expiresInSeconds, maximum, key) {
73
+ if (!Number.isInteger(expiresInSeconds) || expiresInSeconds < 1 || expiresInSeconds > maximum) throw new StorageError(`Az expiresInSeconds 1 és ${maximum} közötti egész szám legyen, kapott: ${expiresInSeconds}`, {
74
+ operation: "getUrl",
75
+ key
76
+ });
77
+ return expiresInSeconds;
78
+ }
79
+ function unsupportedSignedUrl(adapter, key) {
80
+ return new StorageError(`A(z) ${adapter} adapter nem tud lejáró (aláírt) URL-t készíteni. Hagyd el az expiresInSeconds opciót, vagy használj másik adaptert.`, {
81
+ operation: "getUrl",
82
+ key
83
+ });
84
+ }
85
+ function missingPublicBaseUrl(adapter, key) {
86
+ return new StorageError(`A(z) ${adapter} adapterrel URL készítéséhez add meg a publicBaseUrl opciót.`, {
87
+ operation: "getUrl",
88
+ key
89
+ });
90
+ }
91
+ function toArrayBuffer(bytes) {
92
+ const copy = new ArrayBuffer(bytes.byteLength);
93
+ new Uint8Array(copy).set(bytes);
94
+ return copy;
95
+ }
96
+ function basename(key) {
97
+ return key.slice(key.lastIndexOf("/") + 1);
98
+ }
99
+ //#endregion
100
+ Object.defineProperty(exports, "DEFAULT_URL_EXPIRES_SECONDS", {
101
+ enumerable: true,
102
+ get: function() {
103
+ return DEFAULT_URL_EXPIRES_SECONDS;
104
+ }
105
+ });
106
+ Object.defineProperty(exports, "PDF_CONTENT_TYPE", {
107
+ enumerable: true,
108
+ get: function() {
109
+ return PDF_CONTENT_TYPE;
110
+ }
111
+ });
112
+ Object.defineProperty(exports, "S3_MAX_PRESIGN_SECONDS", {
113
+ enumerable: true,
114
+ get: function() {
115
+ return S3_MAX_PRESIGN_SECONDS;
116
+ }
117
+ });
118
+ Object.defineProperty(exports, "StorageError", {
119
+ enumerable: true,
120
+ get: function() {
121
+ return StorageError;
122
+ }
123
+ });
124
+ Object.defineProperty(exports, "assertExpires", {
125
+ enumerable: true,
126
+ get: function() {
127
+ return assertExpires;
128
+ }
129
+ });
130
+ Object.defineProperty(exports, "assertStorageKey", {
131
+ enumerable: true,
132
+ get: function() {
133
+ return assertStorageKey;
134
+ }
135
+ });
136
+ Object.defineProperty(exports, "basename", {
137
+ enumerable: true,
138
+ get: function() {
139
+ return basename;
140
+ }
141
+ });
142
+ Object.defineProperty(exports, "describeError", {
143
+ enumerable: true,
144
+ get: function() {
145
+ return describeError;
146
+ }
147
+ });
148
+ Object.defineProperty(exports, "encodeKeyPath", {
149
+ enumerable: true,
150
+ get: function() {
151
+ return encodeKeyPath;
152
+ }
153
+ });
154
+ Object.defineProperty(exports, "encodeRfc3986", {
155
+ enumerable: true,
156
+ get: function() {
157
+ return encodeRfc3986;
158
+ }
159
+ });
160
+ Object.defineProperty(exports, "guardStorageCall", {
161
+ enumerable: true,
162
+ get: function() {
163
+ return guardStorageCall;
164
+ }
165
+ });
166
+ Object.defineProperty(exports, "isStorageError", {
167
+ enumerable: true,
168
+ get: function() {
169
+ return isStorageError;
170
+ }
171
+ });
172
+ Object.defineProperty(exports, "joinPublicUrl", {
173
+ enumerable: true,
174
+ get: function() {
175
+ return joinPublicUrl;
176
+ }
177
+ });
178
+ Object.defineProperty(exports, "missingPublicBaseUrl", {
179
+ enumerable: true,
180
+ get: function() {
181
+ return missingPublicBaseUrl;
182
+ }
183
+ });
184
+ Object.defineProperty(exports, "normalizePrefix", {
185
+ enumerable: true,
186
+ get: function() {
187
+ return normalizePrefix;
188
+ }
189
+ });
190
+ Object.defineProperty(exports, "resolveKey", {
191
+ enumerable: true,
192
+ get: function() {
193
+ return resolveKey;
194
+ }
195
+ });
196
+ Object.defineProperty(exports, "toArrayBuffer", {
197
+ enumerable: true,
198
+ get: function() {
199
+ return toArrayBuffer;
200
+ }
201
+ });
202
+ Object.defineProperty(exports, "unsupportedSignedUrl", {
203
+ enumerable: true,
204
+ get: function() {
205
+ return unsupportedSignedUrl;
206
+ }
207
+ });
@@ -0,0 +1,100 @@
1
+ //#region src/storage/errors.ts
2
+ var StorageError = class extends Error {
3
+ name = "StorageError";
4
+ operation;
5
+ key;
6
+ status;
7
+ constructor(message, options) {
8
+ super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
9
+ this.operation = options.operation;
10
+ this.key = options.key;
11
+ this.status = options.status;
12
+ }
13
+ };
14
+ function isStorageError(error) {
15
+ return error instanceof StorageError;
16
+ }
17
+ function describeError(error) {
18
+ if (error instanceof Error) return error.message;
19
+ if (typeof error === "object" && error !== null && "message" in error) return String(error.message);
20
+ return String(error);
21
+ }
22
+ async function guardStorageCall(service, operation, key, call) {
23
+ try {
24
+ return await call();
25
+ } catch (error) {
26
+ throw new StorageError(`${service} hiba (${operation}): ${describeError(error)}`, {
27
+ operation,
28
+ key,
29
+ cause: error
30
+ });
31
+ }
32
+ }
33
+ //#endregion
34
+ //#region src/storage/shared.ts
35
+ const PDF_CONTENT_TYPE = "application/pdf";
36
+ const DEFAULT_URL_EXPIRES_SECONDS = 3600;
37
+ const S3_MAX_PRESIGN_SECONDS = 604800;
38
+ const MAX_KEY_LENGTH = 1024;
39
+ const CONTROL_CHARACTERS = /[\p{Cc}]/u;
40
+ function assertStorageKey(key) {
41
+ const invalid = (reason) => new StorageError(`Érvénytelen tárhelykulcs (${reason}): ${JSON.stringify(key)}`, {
42
+ operation: "key",
43
+ key
44
+ });
45
+ if (typeof key !== "string" || key.length === 0) throw invalid("üres");
46
+ if (key.length > MAX_KEY_LENGTH) throw invalid(`legfeljebb ${MAX_KEY_LENGTH} karakter lehet`);
47
+ if (key.startsWith("/")) throw invalid("nem kezdődhet perjellel");
48
+ if (key.includes("\\")) throw invalid("visszaperjel nem lehet benne");
49
+ if (CONTROL_CHARACTERS.test(key)) throw invalid("vezérlőkaraktert tartalmaz");
50
+ for (const segment of key.split("/")) if (segment === "" || segment === "." || segment === "..") throw invalid("üres, \".\" vagy \"..\" útvonalszakaszt tartalmaz");
51
+ return key;
52
+ }
53
+ function normalizePrefix(prefix) {
54
+ if (!prefix) return "";
55
+ const trimmed = prefix.replace(/^\/+|\/+$/g, "");
56
+ if (trimmed === "") return "";
57
+ assertStorageKey(trimmed);
58
+ return `${trimmed}/`;
59
+ }
60
+ function resolveKey(prefix, key) {
61
+ return `${prefix}${assertStorageKey(key)}`;
62
+ }
63
+ function encodeRfc3986(value) {
64
+ return encodeURIComponent(value).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
65
+ }
66
+ function encodeKeyPath(key) {
67
+ return key.split("/").map(encodeRfc3986).join("/");
68
+ }
69
+ function joinPublicUrl(baseUrl, key) {
70
+ return `${baseUrl.replace(/\/+$/, "")}/${encodeKeyPath(key)}`;
71
+ }
72
+ function assertExpires(expiresInSeconds, maximum, key) {
73
+ if (!Number.isInteger(expiresInSeconds) || expiresInSeconds < 1 || expiresInSeconds > maximum) throw new StorageError(`Az expiresInSeconds 1 és ${maximum} közötti egész szám legyen, kapott: ${expiresInSeconds}`, {
74
+ operation: "getUrl",
75
+ key
76
+ });
77
+ return expiresInSeconds;
78
+ }
79
+ function unsupportedSignedUrl(adapter, key) {
80
+ return new StorageError(`A(z) ${adapter} adapter nem tud lejáró (aláírt) URL-t készíteni. Hagyd el az expiresInSeconds opciót, vagy használj másik adaptert.`, {
81
+ operation: "getUrl",
82
+ key
83
+ });
84
+ }
85
+ function missingPublicBaseUrl(adapter, key) {
86
+ return new StorageError(`A(z) ${adapter} adapterrel URL készítéséhez add meg a publicBaseUrl opciót.`, {
87
+ operation: "getUrl",
88
+ key
89
+ });
90
+ }
91
+ function toArrayBuffer(bytes) {
92
+ const copy = new ArrayBuffer(bytes.byteLength);
93
+ new Uint8Array(copy).set(bytes);
94
+ return copy;
95
+ }
96
+ function basename(key) {
97
+ return key.slice(key.lastIndexOf("/") + 1);
98
+ }
99
+ //#endregion
100
+ export { guardStorageCall as _, assertStorageKey as a, encodeRfc3986 as c, normalizePrefix as d, resolveKey as f, describeError as g, StorageError as h, assertExpires as i, joinPublicUrl as l, unsupportedSignedUrl as m, PDF_CONTENT_TYPE as n, basename as o, toArrayBuffer as p, S3_MAX_PRESIGN_SECONDS as r, encodeKeyPath as s, DEFAULT_URL_EXPIRES_SECONDS as t, missingPublicBaseUrl as u, isStorageError as v };
@@ -0,0 +1,88 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_errors = require("../errors-B0QJhUW1.cjs");
3
+ const require_shared = require("../shared-CrxlxI8n.cjs");
4
+ let node_fs_promises = require("node:fs/promises");
5
+ let node_path = require("node:path");
6
+ //#region src/storage/fs.ts
7
+ function isInside(root, target) {
8
+ const path = (0, node_path.relative)(root, target);
9
+ return path !== "" && !path.startsWith("..") && !(0, node_path.isAbsolute)(path);
10
+ }
11
+ function hasCode(error, code) {
12
+ return error?.code === code;
13
+ }
14
+ function traversal(operation, key) {
15
+ return new require_shared.StorageError(`A kulcs a tárhely könyvtárán kívülre mutat: ${JSON.stringify(key)}`, {
16
+ operation,
17
+ key
18
+ });
19
+ }
20
+ function fsStorage(options) {
21
+ if (typeof options.directory !== "string" || options.directory.trim() === "") throw new require_errors.SzamlazzError("Az fsStorage directory opciója kötelező.", { category: "configuration" });
22
+ const root = (0, node_path.resolve)(options.directory);
23
+ const prefix = require_shared.normalizePrefix(options.prefix);
24
+ function pathFor(key, operation = "key") {
25
+ const target = (0, node_path.resolve)(root, require_shared.resolveKey(prefix, key));
26
+ if (!isInside(root, target)) throw traversal(operation, key);
27
+ return target;
28
+ }
29
+ async function assertRealPathInside(path, operation, key) {
30
+ const [realRoot, realTarget] = await Promise.all([(0, node_fs_promises.realpath)(root), (0, node_fs_promises.realpath)(path)]);
31
+ if (realTarget !== realRoot && !isInside(realRoot, realTarget)) throw traversal(operation, key);
32
+ }
33
+ return {
34
+ directory: root,
35
+ pathFor: (key) => pathFor(key),
36
+ async put(key, body, putOptions) {
37
+ const target = pathFor(key, "put");
38
+ const directory = (0, node_path.dirname)(target);
39
+ await require_shared.guardStorageCall("Fájlrendszer", "put", key, () => (0, node_fs_promises.mkdir)(directory, { recursive: true }));
40
+ await assertRealPathInside(directory, "put", key);
41
+ const temporary = `${target}.${crypto.randomUUID()}.tmp`;
42
+ try {
43
+ await (0, node_fs_promises.writeFile)(temporary, body);
44
+ await (0, node_fs_promises.rename)(temporary, target);
45
+ } catch (error) {
46
+ await (0, node_fs_promises.rm)(temporary, { force: true }).catch(() => void 0);
47
+ throw new require_shared.StorageError(`Fájlrendszer hiba (put): ${String(error)}`, {
48
+ operation: "put",
49
+ key,
50
+ cause: error
51
+ });
52
+ }
53
+ return {
54
+ key,
55
+ url: options.publicBaseUrl ? require_shared.joinPublicUrl(options.publicBaseUrl, require_shared.resolveKey(prefix, key)) : void 0,
56
+ size: body.byteLength,
57
+ contentType: putOptions.contentType
58
+ };
59
+ },
60
+ async get(key) {
61
+ const target = pathFor(key, "get");
62
+ try {
63
+ await assertRealPathInside(target, "get", key);
64
+ return new Uint8Array(await (0, node_fs_promises.readFile)(target));
65
+ } catch (error) {
66
+ if (hasCode(error, "ENOENT")) return void 0;
67
+ if (error instanceof require_shared.StorageError) throw error;
68
+ throw new require_shared.StorageError(`Fájlrendszer hiba (get): ${String(error)}`, {
69
+ operation: "get",
70
+ key,
71
+ cause: error
72
+ });
73
+ }
74
+ },
75
+ async delete(key) {
76
+ const target = pathFor(key, "delete");
77
+ await require_shared.guardStorageCall("Fájlrendszer", "delete", key, () => (0, node_fs_promises.rm)(target, { force: true }));
78
+ },
79
+ async getUrl(key, urlOptions = {}) {
80
+ const fullKey = require_shared.resolveKey(prefix, key);
81
+ if (urlOptions.expiresInSeconds !== void 0) throw require_shared.unsupportedSignedUrl("fsStorage", key);
82
+ if (!options.publicBaseUrl) throw require_shared.missingPublicBaseUrl("fsStorage", key);
83
+ return require_shared.joinPublicUrl(options.publicBaseUrl, fullKey);
84
+ }
85
+ };
86
+ }
87
+ //#endregion
88
+ exports.fsStorage = fsStorage;
@@ -0,0 +1,13 @@
1
+ import { t as CompleteStorageAdapter } from "../types-DVRgwcqg.cjs";
2
+ //#region src/storage/fs.d.ts
3
+ export interface FsStorageOptions {
4
+ readonly directory: string;
5
+ readonly publicBaseUrl?: string | undefined;
6
+ readonly prefix?: string | undefined;
7
+ }
8
+ export interface FsStorage extends CompleteStorageAdapter {
9
+ readonly directory: string;
10
+ pathFor(key: string): string;
11
+ }
12
+ export declare function fsStorage(options: FsStorageOptions): FsStorage;
13
+ //#endregion
@@ -0,0 +1,13 @@
1
+ import { t as CompleteStorageAdapter } from "../types-DVRgwcqg.js";
2
+ //#region src/storage/fs.d.ts
3
+ export interface FsStorageOptions {
4
+ readonly directory: string;
5
+ readonly publicBaseUrl?: string | undefined;
6
+ readonly prefix?: string | undefined;
7
+ }
8
+ export interface FsStorage extends CompleteStorageAdapter {
9
+ readonly directory: string;
10
+ pathFor(key: string): string;
11
+ }
12
+ export declare function fsStorage(options: FsStorageOptions): FsStorage;
13
+ //#endregion
@@ -0,0 +1,87 @@
1
+ import { n as SzamlazzError } from "../errors-DapdV5DK.js";
2
+ import { _ as guardStorageCall, d as normalizePrefix, f as resolveKey, h as StorageError, l as joinPublicUrl, m as unsupportedSignedUrl, u as missingPublicBaseUrl } from "../shared-D6DLa4b7.js";
3
+ import { mkdir, readFile, realpath, rename, rm, writeFile } from "node:fs/promises";
4
+ import { dirname, isAbsolute, relative, resolve } from "node:path";
5
+ //#region src/storage/fs.ts
6
+ function isInside(root, target) {
7
+ const path = relative(root, target);
8
+ return path !== "" && !path.startsWith("..") && !isAbsolute(path);
9
+ }
10
+ function hasCode(error, code) {
11
+ return error?.code === code;
12
+ }
13
+ function traversal(operation, key) {
14
+ return new StorageError(`A kulcs a tárhely könyvtárán kívülre mutat: ${JSON.stringify(key)}`, {
15
+ operation,
16
+ key
17
+ });
18
+ }
19
+ function fsStorage(options) {
20
+ if (typeof options.directory !== "string" || options.directory.trim() === "") throw new SzamlazzError("Az fsStorage directory opciója kötelező.", { category: "configuration" });
21
+ const root = resolve(options.directory);
22
+ const prefix = normalizePrefix(options.prefix);
23
+ function pathFor(key, operation = "key") {
24
+ const target = resolve(root, resolveKey(prefix, key));
25
+ if (!isInside(root, target)) throw traversal(operation, key);
26
+ return target;
27
+ }
28
+ async function assertRealPathInside(path, operation, key) {
29
+ const [realRoot, realTarget] = await Promise.all([realpath(root), realpath(path)]);
30
+ if (realTarget !== realRoot && !isInside(realRoot, realTarget)) throw traversal(operation, key);
31
+ }
32
+ return {
33
+ directory: root,
34
+ pathFor: (key) => pathFor(key),
35
+ async put(key, body, putOptions) {
36
+ const target = pathFor(key, "put");
37
+ const directory = dirname(target);
38
+ await guardStorageCall("Fájlrendszer", "put", key, () => mkdir(directory, { recursive: true }));
39
+ await assertRealPathInside(directory, "put", key);
40
+ const temporary = `${target}.${crypto.randomUUID()}.tmp`;
41
+ try {
42
+ await writeFile(temporary, body);
43
+ await rename(temporary, target);
44
+ } catch (error) {
45
+ await rm(temporary, { force: true }).catch(() => void 0);
46
+ throw new StorageError(`Fájlrendszer hiba (put): ${String(error)}`, {
47
+ operation: "put",
48
+ key,
49
+ cause: error
50
+ });
51
+ }
52
+ return {
53
+ key,
54
+ url: options.publicBaseUrl ? joinPublicUrl(options.publicBaseUrl, resolveKey(prefix, key)) : void 0,
55
+ size: body.byteLength,
56
+ contentType: putOptions.contentType
57
+ };
58
+ },
59
+ async get(key) {
60
+ const target = pathFor(key, "get");
61
+ try {
62
+ await assertRealPathInside(target, "get", key);
63
+ return new Uint8Array(await readFile(target));
64
+ } catch (error) {
65
+ if (hasCode(error, "ENOENT")) return void 0;
66
+ if (error instanceof StorageError) throw error;
67
+ throw new StorageError(`Fájlrendszer hiba (get): ${String(error)}`, {
68
+ operation: "get",
69
+ key,
70
+ cause: error
71
+ });
72
+ }
73
+ },
74
+ async delete(key) {
75
+ const target = pathFor(key, "delete");
76
+ await guardStorageCall("Fájlrendszer", "delete", key, () => rm(target, { force: true }));
77
+ },
78
+ async getUrl(key, urlOptions = {}) {
79
+ const fullKey = resolveKey(prefix, key);
80
+ if (urlOptions.expiresInSeconds !== void 0) throw unsupportedSignedUrl("fsStorage", key);
81
+ if (!options.publicBaseUrl) throw missingPublicBaseUrl("fsStorage", key);
82
+ return joinPublicUrl(options.publicBaseUrl, fullKey);
83
+ }
84
+ };
85
+ }
86
+ //#endregion
87
+ export { fsStorage };