@openclaw/fs-safe 0.8.2 → 0.8.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.
Files changed (200) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +1 -1
  3. package/dist/absolute-path.d.ts.map +1 -1
  4. package/dist/absolute-path.js +8 -7
  5. package/dist/advanced.d.ts +2 -2
  6. package/dist/advanced.d.ts.map +1 -1
  7. package/dist/advanced.js +2 -2
  8. package/dist/archive-kind.d.ts +1 -0
  9. package/dist/archive-kind.d.ts.map +1 -1
  10. package/dist/archive-kind.js +6 -0
  11. package/dist/archive-limits.d.ts +0 -1
  12. package/dist/archive-limits.d.ts.map +1 -1
  13. package/dist/archive-limits.js +0 -3
  14. package/dist/archive-native.d.ts +1 -0
  15. package/dist/archive-native.d.ts.map +1 -1
  16. package/dist/archive-native.js +20 -76
  17. package/dist/archive-parser-errors.d.ts +2 -0
  18. package/dist/archive-parser-errors.d.ts.map +1 -0
  19. package/dist/archive-parser-errors.js +12 -0
  20. package/dist/archive-plan.d.ts +20 -0
  21. package/dist/archive-plan.d.ts.map +1 -0
  22. package/dist/archive-plan.js +55 -0
  23. package/dist/archive-read.d.ts.map +1 -1
  24. package/dist/archive-read.js +7 -13
  25. package/dist/archive-tar-inspect.d.ts +7 -0
  26. package/dist/archive-tar-inspect.d.ts.map +1 -0
  27. package/dist/archive-tar-inspect.js +59 -0
  28. package/dist/archive-tar-wasm.d.ts +1 -1
  29. package/dist/archive-tar-wasm.d.ts.map +1 -1
  30. package/dist/archive-tar-wasm.js +5 -8
  31. package/dist/archive-tar.d.ts +3 -1
  32. package/dist/archive-tar.d.ts.map +1 -1
  33. package/dist/archive-tar.js +12 -49
  34. package/dist/archive.d.ts +1 -0
  35. package/dist/archive.d.ts.map +1 -1
  36. package/dist/archive.js +54 -33
  37. package/dist/atomic.d.ts +1 -1
  38. package/dist/atomic.d.ts.map +1 -1
  39. package/dist/atomic.js +1 -1
  40. package/dist/bounded-read-stream.d.ts +1 -5
  41. package/dist/bounded-read-stream.d.ts.map +1 -1
  42. package/dist/bounded-read-stream.js +5 -13
  43. package/dist/bounded-read.d.ts.map +1 -1
  44. package/dist/bounded-read.js +31 -4
  45. package/dist/byte-budget.d.ts +0 -1
  46. package/dist/byte-budget.d.ts.map +1 -1
  47. package/dist/byte-budget.js +1 -1
  48. package/dist/directory-durability.js +5 -5
  49. package/dist/directory-guard.d.ts.map +1 -1
  50. package/dist/directory-guard.js +5 -6
  51. package/dist/directory-mode-owner.d.ts.map +1 -1
  52. package/dist/directory-mode-owner.js +2 -0
  53. package/dist/error-detail.d.ts +1 -0
  54. package/dist/error-detail.d.ts.map +1 -1
  55. package/dist/error-detail.js +6 -0
  56. package/dist/file-store-boundary.d.ts +1 -1
  57. package/dist/file-store-boundary.d.ts.map +1 -1
  58. package/dist/file-store-boundary.js +3 -14
  59. package/dist/file-store-prune.js +17 -8
  60. package/dist/file-store.js +3 -3
  61. package/dist/file-sync.d.ts +5 -0
  62. package/dist/file-sync.d.ts.map +1 -0
  63. package/dist/file-sync.js +19 -0
  64. package/dist/guarded-mkdir.d.ts.map +1 -1
  65. package/dist/guarded-mkdir.js +5 -4
  66. package/dist/guarded-mutation.d.ts +3 -0
  67. package/dist/guarded-mutation.d.ts.map +1 -1
  68. package/dist/guarded-mutation.js +5 -1
  69. package/dist/home-dir.d.ts +0 -10
  70. package/dist/home-dir.d.ts.map +1 -1
  71. package/dist/home-dir.js +0 -28
  72. package/dist/json-durable-queue-ownership.d.ts +1 -0
  73. package/dist/json-durable-queue-ownership.d.ts.map +1 -1
  74. package/dist/json-durable-queue-ownership.js +139 -18
  75. package/dist/json-durable-queue.d.ts.map +1 -1
  76. package/dist/json-durable-queue.js +5 -10
  77. package/dist/json-store.d.ts.map +1 -1
  78. package/dist/json-store.js +1 -1
  79. package/dist/local-roots.d.ts.map +1 -1
  80. package/dist/local-roots.js +2 -3
  81. package/dist/move-path-cleanup.d.ts +1 -1
  82. package/dist/move-path-cleanup.d.ts.map +1 -1
  83. package/dist/move-path-cleanup.js +4 -2
  84. package/dist/move-path.d.ts +9 -0
  85. package/dist/move-path.d.ts.map +1 -1
  86. package/dist/move-path.js +53 -16
  87. package/dist/native-binding.d.ts +2 -1
  88. package/dist/native-binding.d.ts.map +1 -1
  89. package/dist/native-operations.d.ts +0 -1
  90. package/dist/native-operations.d.ts.map +1 -1
  91. package/dist/native-operations.js +0 -10
  92. package/dist/native-pinned-write-windows.d.ts.map +1 -1
  93. package/dist/native-pinned-write-windows.js +8 -4
  94. package/dist/native-pinned-write.js +3 -3
  95. package/dist/native-staged-file.d.ts +10 -3
  96. package/dist/native-staged-file.d.ts.map +1 -1
  97. package/dist/native-staged-file.js +38 -13
  98. package/dist/opened-realpath.d.ts +12 -1
  99. package/dist/opened-realpath.d.ts.map +1 -1
  100. package/dist/opened-realpath.js +16 -14
  101. package/dist/output.d.ts.map +1 -1
  102. package/dist/output.js +26 -2
  103. package/dist/path-policy.js +3 -3
  104. package/dist/permissions.d.ts +1 -0
  105. package/dist/permissions.d.ts.map +1 -1
  106. package/dist/permissions.js +3 -0
  107. package/dist/pinned-write.d.ts +2 -2
  108. package/dist/pinned-write.d.ts.map +1 -1
  109. package/dist/pinned-write.js +17 -22
  110. package/dist/private-temp-workspace.js +1 -1
  111. package/dist/publish-file.js +2 -2
  112. package/dist/regular-file.js +8 -8
  113. package/dist/replace-file-copy-source.d.ts.map +1 -1
  114. package/dist/replace-file-copy-source.js +2 -7
  115. package/dist/replace-file-descriptor.d.ts.map +1 -1
  116. package/dist/replace-file-descriptor.js +11 -20
  117. package/dist/replace-file-temp-owner.d.ts.map +1 -1
  118. package/dist/replace-file-temp-owner.js +15 -14
  119. package/dist/replace-file.d.ts.map +1 -1
  120. package/dist/replace-file.js +21 -8
  121. package/dist/root-context.js +5 -5
  122. package/dist/root-errors.d.ts +1 -0
  123. package/dist/root-errors.d.ts.map +1 -1
  124. package/dist/root-errors.js +9 -0
  125. package/dist/root-file.d.ts.map +1 -1
  126. package/dist/root-file.js +17 -28
  127. package/dist/root-impl.d.ts +2 -1
  128. package/dist/root-impl.d.ts.map +1 -1
  129. package/dist/root-impl.js +46 -58
  130. package/dist/root-path-existing.d.ts.map +1 -1
  131. package/dist/root-path-existing.js +2 -3
  132. package/dist/root-path-symlink.d.ts.map +1 -1
  133. package/dist/root-path-symlink.js +2 -3
  134. package/dist/root-path.d.ts.map +1 -1
  135. package/dist/root-path.js +51 -97
  136. package/dist/root-paths.d.ts.map +1 -1
  137. package/dist/root-paths.js +16 -15
  138. package/dist/root-write-mode.d.ts +6 -0
  139. package/dist/root-write-mode.d.ts.map +1 -0
  140. package/dist/root-write-mode.js +61 -0
  141. package/dist/root-write-verification.js +8 -8
  142. package/dist/safe-path-segment.d.ts +1 -0
  143. package/dist/safe-path-segment.d.ts.map +1 -1
  144. package/dist/safe-path-segment.js +1 -1
  145. package/dist/secret-file.d.ts.map +1 -1
  146. package/dist/secret-file.js +4 -11
  147. package/dist/secret-read-async.d.ts.map +1 -1
  148. package/dist/secret-read-async.js +2 -10
  149. package/dist/secret-read-policy.d.ts +4 -0
  150. package/dist/secret-read-policy.d.ts.map +1 -1
  151. package/dist/secret-read-policy.js +12 -0
  152. package/dist/sibling-staged-file.d.ts.map +1 -1
  153. package/dist/sibling-staged-file.js +2 -7
  154. package/dist/sidecar-lock-policy.d.ts +0 -1
  155. package/dist/sidecar-lock-policy.d.ts.map +1 -1
  156. package/dist/sidecar-lock-policy.js +0 -4
  157. package/dist/strict-file-identity.d.ts +1 -1
  158. package/dist/strict-file-identity.d.ts.map +1 -1
  159. package/dist/string-coerce.d.ts +0 -9
  160. package/dist/string-coerce.d.ts.map +1 -1
  161. package/dist/string-coerce.js +0 -56
  162. package/dist/symlink-parents.d.ts.map +1 -1
  163. package/dist/symlink-parents.js +1 -2
  164. package/dist/temp-target.d.ts.map +1 -1
  165. package/dist/temp-target.js +1 -12
  166. package/docs/archive.md +57 -0
  167. package/docs/atomic.md +53 -19
  168. package/docs/reading.md +2 -0
  169. package/docs/root.md +10 -1
  170. package/docs/staged-file.md +6 -2
  171. package/docs/types.md +2 -1
  172. package/docs/writing.md +30 -2
  173. package/package.json +8 -8
  174. package/dist/archive-tar-extract.d.ts +0 -11
  175. package/dist/archive-tar-extract.d.ts.map +0 -1
  176. package/dist/archive-tar-extract.js +0 -49
  177. package/dist/fsync.d.ts +0 -2
  178. package/dist/fsync.d.ts.map +0 -1
  179. package/dist/fsync.js +0 -1
  180. package/dist/json-durable-queue-retirement.d.ts +0 -9
  181. package/dist/json-durable-queue-retirement.d.ts.map +0 -1
  182. package/dist/json-durable-queue-retirement.js +0 -126
  183. package/dist/json-durable-queue-transfer-lock.d.ts +0 -2
  184. package/dist/json-durable-queue-transfer-lock.d.ts.map +0 -1
  185. package/dist/json-durable-queue-transfer-lock.js +0 -19
  186. package/dist/mode.d.ts +0 -2
  187. package/dist/mode.d.ts.map +0 -1
  188. package/dist/mode.js +0 -3
  189. package/dist/output-sibling.d.ts +0 -8
  190. package/dist/output-sibling.d.ts.map +0 -1
  191. package/dist/output-sibling.js +0 -30
  192. package/dist/read-error.d.ts +0 -2
  193. package/dist/read-error.d.ts.map +0 -1
  194. package/dist/read-error.js +0 -11
  195. package/dist/short-path.d.ts +0 -2
  196. package/dist/short-path.d.ts.map +0 -1
  197. package/dist/short-path.js +0 -7
  198. package/dist/staged-file.d.ts +0 -10
  199. package/dist/staged-file.d.ts.map +0 -1
  200. package/dist/staged-file.js +0 -15
@@ -1 +0,0 @@
1
- {"version":3,"file":"json-durable-queue-retirement.d.ts","sourceRoot":"","sources":["../src/json-durable-queue-retirement.ts"],"names":[],"mappings":"AAgFA,wBAAsB,6BAA6B,CAAC,MAAM,EAAE;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmChB;AAED,wBAAsB,wBAAwB,CAAC,MAAM,EAAE;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBhB"}
@@ -1,126 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- import { syncDirectory } from "./directory-durability.js";
4
- import { FsSafeError } from "./errors.js";
5
- import { sameFileIdentityForCleanup } from "./file-identity.js";
6
- const RETIREMENT_ROOT_NAME = ".fs-safe-retirements";
7
- const RETIREMENT_ENTRY_NAME = "entry";
8
- function getErrorCode(error) {
9
- return error && typeof error === "object" && "code" in error
10
- ? String(error.code)
11
- : null;
12
- }
13
- async function lstatOrNull(filePath) {
14
- try {
15
- return await fs.lstat(filePath, { bigint: true });
16
- }
17
- catch (error) {
18
- if (getErrorCode(error) === "ENOENT")
19
- return null;
20
- throw error;
21
- }
22
- }
23
- function assertDirectory(identity, label) {
24
- if (identity.isSymbolicLink() || !identity.isDirectory()) {
25
- throw new FsSafeError("path-mismatch", `${label} is not an owned directory`);
26
- }
27
- }
28
- async function regularFileIdentity(filePath) {
29
- const identity = await lstatOrNull(filePath);
30
- if (!identity)
31
- return null;
32
- if (identity.isSymbolicLink() || !identity.isFile()) {
33
- throw new FsSafeError("path-mismatch", "queue retirement path is not a regular file");
34
- }
35
- return identity;
36
- }
37
- function retirementPaths(jsonPath) {
38
- const rootPath = path.join(path.dirname(jsonPath), RETIREMENT_ROOT_NAME);
39
- const dirPath = path.join(rootPath, path.basename(jsonPath));
40
- return { dirPath, entryPath: path.join(dirPath, RETIREMENT_ENTRY_NAME), rootPath };
41
- }
42
- async function inspectRetirementRoot(jsonPath) {
43
- const rootPath = retirementPaths(jsonPath).rootPath;
44
- const root = await lstatOrNull(rootPath);
45
- if (!root)
46
- return null;
47
- assertDirectory(root, "queue retirement root");
48
- return rootPath;
49
- }
50
- async function ensureRetirementRoot(jsonPath) {
51
- const parentPath = path.dirname(jsonPath);
52
- const rootPath = retirementPaths(jsonPath).rootPath;
53
- await fs.mkdir(rootPath, { mode: 0o700 }).catch((error) => {
54
- if (getErrorCode(error) !== "EEXIST")
55
- throw error;
56
- });
57
- const root = await fs.lstat(rootPath, { bigint: true });
58
- assertDirectory(root, "queue retirement root");
59
- await syncDirectory(parentPath);
60
- return rootPath;
61
- }
62
- async function removeRetirementRecord(params) {
63
- await fs.rmdir(params.dirPath).catch((error) => {
64
- if (getErrorCode(error) !== "ENOENT")
65
- throw error;
66
- });
67
- await syncDirectory(params.rootPath);
68
- }
69
- export async function recoverDurableQueueRetirement(params) {
70
- const rootPath = await inspectRetirementRoot(params.jsonPath);
71
- if (!rootPath)
72
- return;
73
- const { dirPath, entryPath } = retirementPaths(params.jsonPath);
74
- const dir = await lstatOrNull(dirPath);
75
- if (!dir)
76
- return;
77
- assertDirectory(dir, "queue retirement record");
78
- const names = await fs.readdir(dirPath);
79
- if (names.length === 0) {
80
- await removeRetirementRecord({ dirPath, rootPath });
81
- return;
82
- }
83
- if (names.length !== 1 || names[0] !== RETIREMENT_ENTRY_NAME) {
84
- throw new FsSafeError("path-mismatch", "queue retirement record is ambiguous");
85
- }
86
- const entry = await regularFileIdentity(entryPath);
87
- const processing = await regularFileIdentity(params.processingPath);
88
- if (!entry || !processing) {
89
- throw new FsSafeError("path-mismatch", "queue retirement ownership is incomplete");
90
- }
91
- if (!sameFileIdentityForCleanup(entry, processing)) {
92
- const pending = await regularFileIdentity(params.jsonPath);
93
- if (!pending) {
94
- await fs.link(entryPath, params.jsonPath);
95
- await syncDirectory(path.dirname(params.jsonPath));
96
- }
97
- else if (sameFileIdentityForCleanup(pending, entry)) {
98
- await syncDirectory(path.dirname(params.jsonPath));
99
- }
100
- else if (pending.nlink > 1n) {
101
- throw new FsSafeError("path-mismatch", "queue replacement identity is ambiguous");
102
- }
103
- }
104
- await fs.unlink(entryPath);
105
- await syncDirectory(dirPath);
106
- await removeRetirementRecord({ dirPath, rootPath });
107
- }
108
- export async function retireDurableQueueSource(params) {
109
- await recoverDurableQueueRetirement(params);
110
- const rootPath = await ensureRetirementRoot(params.jsonPath);
111
- const { dirPath, entryPath } = retirementPaths(params.jsonPath);
112
- await fs.mkdir(dirPath, { mode: 0o700 });
113
- await syncDirectory(rootPath);
114
- try {
115
- await fs.rename(params.jsonPath, entryPath);
116
- }
117
- catch (error) {
118
- if (getErrorCode(error) !== "ENOENT")
119
- throw error;
120
- await removeRetirementRecord({ dirPath, rootPath });
121
- return;
122
- }
123
- await syncDirectory(dirPath);
124
- await syncDirectory(path.dirname(params.jsonPath));
125
- await recoverDurableQueueRetirement(params);
126
- }
@@ -1,2 +0,0 @@
1
- export declare function withQueueTransferLock<T>(filePath: string, run: () => Promise<T>): Promise<T>;
2
- //# sourceMappingURL=json-durable-queue-transfer-lock.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"json-durable-queue-transfer-lock.d.ts","sourceRoot":"","sources":["../src/json-durable-queue-transfer-lock.ts"],"names":[],"mappings":"AAKA,wBAAsB,qBAAqB,CAAC,CAAC,EAC3C,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACpB,OAAO,CAAC,CAAC,CAAC,CAqBZ"}
@@ -1,19 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import path from "node:path";
3
- import { sha256Hex } from "./file-identity.js";
4
- import { withSidecarLock } from "./sidecar-lock.js";
5
- export async function withQueueTransferLock(filePath, run) {
6
- const lockPath = path.join(path.dirname(filePath), `.fs-safe-transfer-${sha256Hex(path.basename(filePath)).slice(0, 32)}.lock`);
7
- return await withSidecarLock(filePath, {
8
- managerKey: "fs-safe.queue-transfer",
9
- lockPath,
10
- staleMs: 30_000,
11
- staleRecovery: "fail-closed",
12
- timeoutMs: 45_000,
13
- payload: () => ({
14
- ownerToken: randomUUID(),
15
- createdAt: new Date().toISOString(),
16
- }),
17
- retry: { retries: 180, minTimeout: 25, maxTimeout: 250, factor: 1.1 },
18
- }, run);
19
- }
package/dist/mode.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare function formatPosixMode(mode: number): string;
2
- //# sourceMappingURL=mode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mode.d.ts","sourceRoot":"","sources":["../src/mode.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
package/dist/mode.js DELETED
@@ -1,3 +0,0 @@
1
- export function formatPosixMode(mode) {
2
- return (mode & 0o777).toString(8).padStart(3, "0");
3
- }
@@ -1,8 +0,0 @@
1
- export declare function writeExternalFileViaSibling<T>(params: {
2
- finalPath: string;
3
- write: (filePath: string) => Promise<T>;
4
- fallbackFileName?: string;
5
- maxBytes?: number;
6
- mode?: number;
7
- }): Promise<T>;
8
- //# sourceMappingURL=output-sibling.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"output-sibling.d.ts","sourceRoot":"","sources":["../src/output-sibling.ts"],"names":[],"mappings":"AAuBA,wBAAsB,2BAA2B,CAAC,CAAC,EAAE,MAAM,EAAE;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,CAAC,CAAC,CAYb"}
@@ -1,30 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import path from "node:path";
3
- import { fitFileNameToPortableComponent, sanitizeUntrustedFileName } from "./filename.js";
4
- import { writeCallbackSibling } from "./sibling-staged-file.js";
5
- function safeFallbackFileName(fallbackFileName) {
6
- return sanitizeUntrustedFileName(fallbackFileName ?? "output.bin", "output.bin");
7
- }
8
- function buildSiblingTempPath(targetPath, fallbackFileName) {
9
- const prefix = `.fs-safe-output-${process.pid}-${randomUUID()}-`;
10
- const suffix = ".part";
11
- const safeTail = fitFileNameToPortableComponent({
12
- prefix,
13
- fileName: sanitizeUntrustedFileName(path.basename(targetPath), safeFallbackFileName(fallbackFileName)),
14
- suffix,
15
- });
16
- return path.join(path.dirname(targetPath), `${prefix}${safeTail}${suffix}`);
17
- }
18
- export async function writeExternalFileViaSibling(params) {
19
- const finalPath = path.resolve(params.finalPath);
20
- const { result } = await writeCallbackSibling({
21
- tempPath: buildSiblingTempPath(finalPath, params.fallbackFileName),
22
- write: params.write,
23
- resolveFinalPath: () => finalPath,
24
- mode: params.mode,
25
- maxBytes: params.maxBytes,
26
- syncTempFile: true,
27
- syncParentDir: true,
28
- });
29
- return result;
30
- }
@@ -1,2 +0,0 @@
1
- export declare function throwFsSafeReadError(error: unknown, label: string): never;
2
- //# sourceMappingURL=read-error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"read-error.d.ts","sourceRoot":"","sources":["../src/read-error.ts"],"names":[],"mappings":"AAGA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAQzE"}
@@ -1,11 +0,0 @@
1
- import { FsSafeError } from "./errors.js";
2
- import { isNodeError } from "./path.js";
3
- export function throwFsSafeReadError(error, label) {
4
- if (error instanceof FsSafeError) {
5
- throw error;
6
- }
7
- if (isNodeError(error)) {
8
- throw new FsSafeError("read-failed", `${label} target could not be read`, { cause: error });
9
- }
10
- throw error;
11
- }
@@ -1,2 +0,0 @@
1
- export declare function shortPath(value: string): string;
2
- //# sourceMappingURL=short-path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"short-path.d.ts","sourceRoot":"","sources":["../src/short-path.ts"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI/C"}
@@ -1,7 +0,0 @@
1
- import os from "node:os";
2
- import { formatErrorDetail } from "./error-detail.js";
3
- export function shortPath(value) {
4
- const home = os.homedir();
5
- const shortened = value.startsWith(home) ? `~${value.slice(home.length)}` : value;
6
- return formatErrorDetail(shortened);
7
- }
@@ -1,10 +0,0 @@
1
- import type { DirectoryReceipt } from "./directory-durability.js";
2
- import type { StagedFile } from "./staged-file-types.js";
3
- export type { PublishedFileReceipt, StagedFile, StagedFileCleanupReceipt, StagedFileFailureDetails, StagedFilePublication, StagedFileReceipt, } from "./staged-file-types.js";
4
- export declare function stageFileInDirectory(options: {
5
- directory: string | DirectoryReceipt;
6
- content: string | Uint8Array;
7
- /** Published mode; the unpublished stage stays at 0600. Defaults to 0600. */
8
- mode?: number;
9
- }): Promise<StagedFile>;
10
- //# sourceMappingURL=staged-file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"staged-file.d.ts","sourceRoot":"","sources":["../src/staged-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAKlE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,YAAY,EACV,oBAAoB,EAAE,UAAU,EAAE,wBAAwB,EAAE,wBAAwB,EACpF,qBAAqB,EAAE,iBAAiB,GACzC,MAAM,wBAAwB,CAAC;AAEhC,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAAC;IACrC,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,UAAU,CAAC,CAUtB"}
@@ -1,15 +0,0 @@
1
- import { FsSafeError } from "./errors.js";
2
- import { assertNativeStaging, createNativeStage } from "./native-staged-file.js";
3
- import { requireNativeBinding } from "./native.js";
4
- import { openStagedDirectory } from "./staged-directory.js";
5
- export async function stageFileInDirectory(options) {
6
- if (process.platform !== "linux" && process.platform !== "darwin") {
7
- throw new FsSafeError("unsupported-platform", "retained-directory staging requires Linux or macOS");
8
- }
9
- const binding = requireNativeBinding();
10
- assertNativeStaging(binding);
11
- const input = { kind: "buffer", data: Buffer.from(options.content) };
12
- const mode = options.mode ?? 0o600;
13
- const parent = openStagedDirectory(options.directory);
14
- return await createNativeStage(binding, parent.fd, parent.receipt, input, mode);
15
- }