@fenglimg/fabric-shared 2.0.0 → 2.1.0-rc.2
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/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/chunk-MDWTGOAY.js +101 -0
- package/dist/chunk-R2J7DAED.js +2043 -0
- package/dist/chunk-WVPDH4BF.js +952 -0
- package/dist/i18n/index.d.ts +22 -2
- package/dist/i18n/index.js +3 -1
- package/dist/index-GQpaWTm-.d.ts +328 -0
- package/dist/index.d.ts +4922 -1998
- package/dist/index.js +2114 -372
- package/dist/node/atomic-write.d.ts +16 -0
- package/dist/node/atomic-write.js +19 -10
- package/dist/node/mcp-payload-guard.d.ts +3 -1
- package/dist/node/mcp-payload-guard.js +6 -2
- package/dist/schemas/api-contracts.d.ts +1562 -815
- package/dist/schemas/api-contracts.js +23 -7
- package/dist/templates/bootstrap-canonical.d.ts +56 -0
- package/dist/templates/bootstrap-canonical.js +18 -0
- package/dist/types/index.d.ts +2 -123
- package/package.json +32 -4
- package/dist/chunk-U2SR2M4L.js +0 -958
- package/dist/chunk-VQDCDCJA.js +0 -555
|
@@ -8,6 +8,22 @@ declare function atomicWriteText(path: string, content: string, opts?: AtomicWri
|
|
|
8
8
|
declare function atomicWriteJson(path: string, value: unknown, opts?: AtomicWriteJsonOptions): Promise<void>;
|
|
9
9
|
interface LedgerWriteQueue {
|
|
10
10
|
append(path: string, line: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Run `fn` with exclusive access to `path` against all other queue operations
|
|
13
|
+
* (other `runExclusive` calls and `append` calls) on the same path within
|
|
14
|
+
* this LedgerWriteQueue instance.
|
|
15
|
+
*
|
|
16
|
+
* Scope: per-path, in-process (same Node process, same queue instance).
|
|
17
|
+
* Does NOT provide cross-process locking — separate concern.
|
|
18
|
+
*
|
|
19
|
+
* Error semantics: a rejection from `fn` is propagated to the returned
|
|
20
|
+
* Promise but does NOT poison the chain — subsequent `runExclusive` /
|
|
21
|
+
* `append` calls on the same path will still acquire and run.
|
|
22
|
+
*
|
|
23
|
+
* Ordering: submission-order FIFO. Calls on different paths run independently
|
|
24
|
+
* (in parallel where possible).
|
|
25
|
+
*/
|
|
26
|
+
runExclusive<T>(path: string, fn: () => Promise<T>): Promise<T>;
|
|
11
27
|
}
|
|
12
28
|
declare function createLedgerWriteQueue(): LedgerWriteQueue;
|
|
13
29
|
|
|
@@ -38,18 +38,27 @@ function createLedgerWriteQueue() {
|
|
|
38
38
|
const normalized = line.endsWith("\n") ? line : line + "\n";
|
|
39
39
|
await appendFile(path, normalized, "utf8");
|
|
40
40
|
}
|
|
41
|
+
function enqueue(path, work) {
|
|
42
|
+
const prev = chains.get(path) ?? Promise.resolve();
|
|
43
|
+
const result = prev.catch(() => void 0).then(() => work());
|
|
44
|
+
const chainSlot = result.then(
|
|
45
|
+
() => void 0,
|
|
46
|
+
() => void 0
|
|
47
|
+
);
|
|
48
|
+
chains.set(path, chainSlot);
|
|
49
|
+
chainSlot.finally(() => {
|
|
50
|
+
if (chains.get(path) === chainSlot) {
|
|
51
|
+
chains.delete(path);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
41
56
|
return {
|
|
42
57
|
append(path, line) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
guarded.finally(() => {
|
|
48
|
-
if (chains.get(path) === next) {
|
|
49
|
-
chains.delete(path);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return next;
|
|
58
|
+
return enqueue(path, () => doAppend(path, line));
|
|
59
|
+
},
|
|
60
|
+
runExclusive(path, fn) {
|
|
61
|
+
return enqueue(path, fn);
|
|
53
62
|
}
|
|
54
63
|
};
|
|
55
64
|
}
|
|
@@ -11,6 +11,8 @@ interface PayloadGuardResult {
|
|
|
11
11
|
threshold: number;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
+
declare const PAYLOAD_LIMIT_DEFAULT_WARN_BYTES = 16384;
|
|
15
|
+
declare const PAYLOAD_LIMIT_DEFAULT_HARD_BYTES = 65536;
|
|
14
16
|
declare function enforcePayloadLimit(serializedPayload: string, opts?: PayloadGuardOptions): PayloadGuardResult;
|
|
15
17
|
|
|
16
|
-
export { type PayloadGuardOptions, type PayloadGuardResult, enforcePayloadLimit };
|
|
18
|
+
export { PAYLOAD_LIMIT_DEFAULT_HARD_BYTES, PAYLOAD_LIMIT_DEFAULT_WARN_BYTES, type PayloadGuardOptions, type PayloadGuardResult, enforcePayloadLimit };
|
|
@@ -7,8 +7,10 @@ var McpPayloadTooLargeError = class extends MCPError {
|
|
|
7
7
|
code = "MCP_PAYLOAD_TOO_LARGE";
|
|
8
8
|
httpStatus = 413;
|
|
9
9
|
};
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var PAYLOAD_LIMIT_DEFAULT_WARN_BYTES = 16384;
|
|
11
|
+
var PAYLOAD_LIMIT_DEFAULT_HARD_BYTES = 65536;
|
|
12
|
+
var DEFAULT_WARN = PAYLOAD_LIMIT_DEFAULT_WARN_BYTES;
|
|
13
|
+
var DEFAULT_HARD = PAYLOAD_LIMIT_DEFAULT_HARD_BYTES;
|
|
12
14
|
function enforcePayloadLimit(serializedPayload, opts) {
|
|
13
15
|
const warnAt = opts?.warnBytes ?? DEFAULT_WARN;
|
|
14
16
|
const hardAt = opts?.hardBytes ?? DEFAULT_HARD;
|
|
@@ -36,5 +38,7 @@ function enforcePayloadLimit(serializedPayload, opts) {
|
|
|
36
38
|
return { bytes };
|
|
37
39
|
}
|
|
38
40
|
export {
|
|
41
|
+
PAYLOAD_LIMIT_DEFAULT_HARD_BYTES,
|
|
42
|
+
PAYLOAD_LIMIT_DEFAULT_WARN_BYTES,
|
|
39
43
|
enforcePayloadLimit
|
|
40
44
|
};
|