@openclaw/clickclack 2026.10.10 → 2026.11.5-beta.1
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/.setup/{channel-CaLQ1zSw.mjs → channel-ByAANbh8.mjs} +363 -504
- package/dist/.setup/{resolve-C2XmZanM.mjs → resolve-CRj6QjdF.mjs} +27 -41
- package/dist/.setup/{rolldown-runtime-nwUcYXjP.mjs → rolldown-runtime-782esTHO.mjs} +0 -1
- package/dist/.setup/{runtime-api-HO9-jJAP.mjs → runtime-api-BsRK-sfA.mjs} +324 -368
- package/dist/.setup/{setup-claim-D50o9egr.mjs → setup-claim-BAKxfObl.mjs} +4 -9
- package/dist/.setup/{setup-plugin-api-COv8knUv.mjs → setup-plugin-api-BTqE973B.mjs} +1 -1
- package/dist/.setup/setup-plugin-api-CfuhJJvK.mjs +1 -0
- package/dist/.setup/{setup-surface-BuNtdRQY.mjs → setup-surface-5wSYr6p2.mjs} +5 -5
- package/dist/.setup/{setup-verify-CSI-GwUA.mjs → setup-verify-IayKkFWq.mjs} +12 -24
- package/dist/.source-module-urls/aa673c321fe9be084b8926cbe5388ff5e2a41371389e19ca60a1983f2b634030.json +1 -1
- package/dist/api.js +3 -3
- package/dist/channel-plugin-api.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime-api.js +4 -4
- package/dist/setup-entry.js +1 -1
- package/dist/setup-plugin-api.js +1 -1
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/package.json +5 -7
- package/dist/.setup/setup-plugin-api-wzfSSaGz.mjs +0 -1
- package/node_modules/ws/LICENSE +0 -20
- package/node_modules/ws/README.md +0 -548
- package/node_modules/ws/browser.js +0 -8
- package/node_modules/ws/index.js +0 -22
- package/node_modules/ws/lib/buffer-util.js +0 -131
- package/node_modules/ws/lib/constants.js +0 -19
- package/node_modules/ws/lib/event-target.js +0 -292
- package/node_modules/ws/lib/extension.js +0 -203
- package/node_modules/ws/lib/limiter.js +0 -55
- package/node_modules/ws/lib/permessage-deflate.js +0 -530
- package/node_modules/ws/lib/receiver.js +0 -743
- package/node_modules/ws/lib/sender.js +0 -607
- package/node_modules/ws/lib/stream.js +0 -161
- package/node_modules/ws/lib/subprotocol.js +0 -62
- package/node_modules/ws/lib/validation.js +0 -152
- package/node_modules/ws/lib/websocket-server.js +0 -562
- package/node_modules/ws/lib/websocket.js +0 -1421
- package/node_modules/ws/package.json +0 -74
- package/node_modules/ws/wrapper.mjs +0 -21
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { a as isClickClackSetupLoopbackHost, i as buildClickClackSetupClaimUrl, o as requireClickClackSetupApiBaseUrl } from "./setup-surface-
|
|
1
|
+
import { a as isClickClackSetupLoopbackHost, i as buildClickClackSetupClaimUrl, o as requireClickClackSetupApiBaseUrl } from "./setup-surface-5wSYr6p2.mjs";
|
|
2
2
|
import { withTimeout } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
3
3
|
import { createProviderOperationDeadline, readProviderJsonResponse, readResponseTextLimited, resolveProviderOperationTimeoutMs } from "openclaw/plugin-sdk/provider-http";
|
|
4
|
+
import { isStringArray } from "openclaw/plugin-sdk/collection-input-runtime";
|
|
4
5
|
import { fetchWithSsrFGuard, resolvePinnedHostnameWithPolicy, ssrfPolicyFromHttpBaseUrlAllowedHostname } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
5
6
|
// extensions/clickclack/src/setup-claim.ts
|
|
6
7
|
const CLICKCLACK_ERROR_BODY_LIMIT_BYTES = 8192;
|
|
7
8
|
const CLICKCLACK_SETUP_CODE_CLAIM_JSON_LIMIT_BYTES = 65536;
|
|
8
9
|
const CLICKCLACK_SETUP_CODE_CLAIM_TIMEOUT_MS = 3e4;
|
|
9
|
-
var ClickClackSetupCodeClaimError = class extends Error {
|
|
10
|
-
constructor(status, detail) {
|
|
11
|
-
super(`ClickClack setup code claim failed (${status}): ${detail}`);
|
|
12
|
-
this.status = status;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
10
|
function requireRecord(value, label) {
|
|
16
11
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`ClickClack setup code claim returned invalid ${label}`);
|
|
17
12
|
return value;
|
|
@@ -30,7 +25,7 @@ function parseClickClackSetupCodeClaim(value, expectedClaimUrl) {
|
|
|
30
25
|
const allowFrom = defaults.allowFrom;
|
|
31
26
|
const agentActivity = defaults.agentActivity;
|
|
32
27
|
if (defaultTo !== void 0 && typeof defaultTo !== "string") throw new Error("ClickClack setup code claim returned invalid defaults.defaultTo");
|
|
33
|
-
if (allowFrom !== void 0 &&
|
|
28
|
+
if (allowFrom !== void 0 && !isStringArray(allowFrom)) throw new Error("ClickClack setup code claim returned invalid defaults.allowFrom");
|
|
34
29
|
if (agentActivity !== void 0 && typeof agentActivity !== "boolean") throw new Error("ClickClack setup code claim returned invalid defaults.agentActivity");
|
|
35
30
|
const contractVersion = claim.contract_version;
|
|
36
31
|
const apiBaseUrlValue = claim.api_base_url;
|
|
@@ -120,7 +115,7 @@ async function claimClickClackSetupCode(params) {
|
|
|
120
115
|
try {
|
|
121
116
|
if (!response.ok) {
|
|
122
117
|
const detail = await readResponseTextLimited(response, CLICKCLACK_ERROR_BODY_LIMIT_BYTES);
|
|
123
|
-
throw new
|
|
118
|
+
throw Object.assign(/* @__PURE__ */ new Error(`ClickClack setup code claim failed (${response.status}): ${detail}`), { status: response.status });
|
|
124
119
|
}
|
|
125
120
|
return parseClickClackSetupCodeClaim(await readProviderJsonResponse(response, "ClickClack setup code claim", { maxBytes: CLICKCLACK_SETUP_CODE_CLAIM_JSON_LIMIT_BYTES }), params.expectedClaimUrl);
|
|
126
121
|
} finally {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as clickClackConfigAdapter, n as clickClackSetupContract, s as clickClackConfigSchema, t as clickClackSetupWizard, u as clickClackMeta } from "./setup-surface-
|
|
1
|
+
import { l as clickClackConfigAdapter, n as clickClackSetupContract, s as clickClackConfigSchema, t as clickClackSetupWizard, u as clickClackMeta } from "./setup-surface-5wSYr6p2.mjs";
|
|
2
2
|
// extensions/clickclack/src/channel.setup.ts
|
|
3
3
|
const clickClackSetupPlugin = {
|
|
4
4
|
id: "clickclack",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as clickClackSetupPlugin } from "./setup-plugin-api-BTqE973B.mjs";
|
|
@@ -446,7 +446,7 @@ const clickClackSetupAdapter = {
|
|
|
446
446
|
const claimUrl = setup.exactClaimUrl && !privateApiBaseUrl ? setup.exactClaimUrl : buildClickClackSetupClaimUrl(privateApiBaseUrl ?? setup.baseUrl);
|
|
447
447
|
let claim;
|
|
448
448
|
try {
|
|
449
|
-
const { claimClickClackSetupCode } = await import("./setup-claim-
|
|
449
|
+
const { claimClickClackSetupCode } = await import("./setup-claim-BAKxfObl.mjs");
|
|
450
450
|
claim = await claimClickClackSetupCode({
|
|
451
451
|
claimUrl,
|
|
452
452
|
code: setup.code,
|
|
@@ -462,7 +462,7 @@ const clickClackSetupAdapter = {
|
|
|
462
462
|
token: claim.token,
|
|
463
463
|
workspace: claim.workspace.id,
|
|
464
464
|
...claim.defaults.defaultTo !== void 0 ? { defaultTo: claim.defaults.defaultTo } : {},
|
|
465
|
-
...claim.defaults.allowFrom !== void 0 ? { allowFrom:
|
|
465
|
+
...claim.defaults.allowFrom !== void 0 ? { allowFrom: claim.defaults.allowFrom } : {},
|
|
466
466
|
...claim.defaults.agentActivity !== void 0 ? { agentActivity: claim.defaults.agentActivity } : {}
|
|
467
467
|
};
|
|
468
468
|
},
|
|
@@ -515,7 +515,7 @@ const clickClackSetupAdapter = {
|
|
|
515
515
|
...baseUrl ? { baseUrl } : {},
|
|
516
516
|
...workspace ? { workspace } : {},
|
|
517
517
|
...setupInput.defaultTo?.trim() ? { defaultTo: setupInput.defaultTo.trim() } : {},
|
|
518
|
-
...setupInput.allowFrom ? { allowFrom:
|
|
518
|
+
...setupInput.allowFrom ? { allowFrom: setupInput.allowFrom } : {},
|
|
519
519
|
...setupInput.agentActivity !== void 0 ? { agentActivity: setupInput.agentActivity } : {}
|
|
520
520
|
}
|
|
521
521
|
}),
|
|
@@ -526,7 +526,7 @@ const clickClackSetupAdapter = {
|
|
|
526
526
|
});
|
|
527
527
|
},
|
|
528
528
|
afterAccountConfigWritten: async ({ cfg, accountId, runtime }) => {
|
|
529
|
-
const { verifyClickClackAccountAfterSetup } = await import("./setup-verify-
|
|
529
|
+
const { verifyClickClackAccountAfterSetup } = await import("./setup-verify-IayKkFWq.mjs");
|
|
530
530
|
await verifyClickClackAccountAfterSetup({
|
|
531
531
|
cfg,
|
|
532
532
|
accountId,
|
|
@@ -707,7 +707,7 @@ const clickClackSetupWizard = {
|
|
|
707
707
|
})
|
|
708
708
|
}],
|
|
709
709
|
finalize: async ({ cfg, accountId, credentialValues, prompter }) => {
|
|
710
|
-
const { checkClickClackSetupConnection } = await import("./setup-verify-
|
|
710
|
+
const { checkClickClackSetupConnection } = await import("./setup-verify-IayKkFWq.mjs");
|
|
711
711
|
const result = await checkClickClackSetupConnection({
|
|
712
712
|
cfg,
|
|
713
713
|
accountId,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as resolveClickClackAccount } from "./setup-surface-
|
|
2
|
-
import { a as createClickClackClient, t as findClickClackWorkspace } from "./resolve-
|
|
1
|
+
import { h as resolveClickClackAccount } from "./setup-surface-5wSYr6p2.mjs";
|
|
2
|
+
import { a as createClickClackClient, i as ClickClackHttpError, t as findClickClackWorkspace } from "./resolve-CRj6QjdF.mjs";
|
|
3
3
|
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
4
4
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
5
5
|
import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/setup";
|
|
@@ -7,23 +7,15 @@ import { hasConfiguredSecretInput } from "openclaw/plugin-sdk/setup";
|
|
|
7
7
|
const GATEWAY_RUNNING_MESSAGE = "OpenClaw is running — ClickClack will connect automatically.";
|
|
8
8
|
const GATEWAY_NOT_RUNNING_MESSAGE = "Start OpenClaw to connect: openclaw gateway";
|
|
9
9
|
const GATEWAY_UNKNOWN_MESSAGE = "If OpenClaw is running it connects automatically; otherwise start it with: openclaw gateway";
|
|
10
|
-
function isHttpStatus(error, status) {
|
|
11
|
-
return typeof error === "object" && error !== null && "status" in error && error.status === status;
|
|
12
|
-
}
|
|
13
|
-
function isWorkspaceNotFound(error) {
|
|
14
|
-
return error instanceof Error && error.message.startsWith("ClickClack workspace not found:");
|
|
15
|
-
}
|
|
16
10
|
function usesUnavailableImplicitEnvToken(account, tokenOverride) {
|
|
17
11
|
return account.accountId === DEFAULT_ACCOUNT_ID && Boolean(account.baseUrl && account.workspace) && !tokenOverride && !account.token && !hasConfiguredSecretInput(account.config.token) && !account.config.tokenFile?.trim();
|
|
18
12
|
}
|
|
19
13
|
async function checkClickClackSetupConnection(params) {
|
|
20
|
-
let workspaceInput = "";
|
|
21
14
|
try {
|
|
22
15
|
const account = resolveClickClackAccount({
|
|
23
16
|
cfg: params.cfg,
|
|
24
17
|
accountId: params.accountId
|
|
25
18
|
});
|
|
26
|
-
workspaceInput = account.workspace;
|
|
27
19
|
const token = params.token?.trim() || account.token;
|
|
28
20
|
if (usesUnavailableImplicitEnvToken(account, token)) return { status: "skipped-env-token" };
|
|
29
21
|
if (!account.baseUrl || !account.workspace || !token) return { status: "skipped-unconfigured" };
|
|
@@ -34,33 +26,28 @@ async function checkClickClackSetupConnection(params) {
|
|
|
34
26
|
const me = await client.me();
|
|
35
27
|
const workspaces = await client.workspaces();
|
|
36
28
|
const workspace = account.workspace.startsWith("wsp_") ? workspaces.find((candidate) => candidate.id === account.workspace) : findClickClackWorkspace(workspaces, account.workspace);
|
|
37
|
-
if (!workspace)
|
|
29
|
+
if (!workspace) return {
|
|
30
|
+
status: "workspace-not-found",
|
|
31
|
+
workspace: account.workspace
|
|
32
|
+
};
|
|
38
33
|
return {
|
|
39
34
|
status: "connected",
|
|
40
35
|
handle: me.handle,
|
|
41
36
|
workspaceName: workspace.name
|
|
42
37
|
};
|
|
43
38
|
} catch (error) {
|
|
44
|
-
if (
|
|
45
|
-
if (isWorkspaceNotFound(error)) return {
|
|
46
|
-
status: "workspace-not-found",
|
|
47
|
-
workspace: workspaceInput
|
|
48
|
-
};
|
|
39
|
+
if (error instanceof ClickClackHttpError && error.status === 401) return { status: "invalid-token" };
|
|
49
40
|
return {
|
|
50
41
|
status: "failed",
|
|
51
42
|
error: formatErrorMessage(error)
|
|
52
43
|
};
|
|
53
44
|
}
|
|
54
45
|
}
|
|
55
|
-
function isGatewayNotRunningError(error) {
|
|
56
|
-
if (typeof error === "object" && error !== null && "name" in error && "kind" in error && "code" in error && error.name === "GatewayTransportError" && error.kind === "closed" && error.code === 1006) return true;
|
|
57
|
-
const message = formatErrorMessage(error).toLowerCase();
|
|
58
|
-
return message.includes("econnrefused") || message.includes("connection refused");
|
|
59
|
-
}
|
|
60
46
|
async function probeClickClackGatewayStatus() {
|
|
47
|
+
let gateway;
|
|
61
48
|
try {
|
|
62
|
-
|
|
63
|
-
await callGatewayFromCli("health", {
|
|
49
|
+
gateway = await import("openclaw/plugin-sdk/gateway-runtime");
|
|
50
|
+
await gateway.callGatewayFromCli("health", {
|
|
64
51
|
timeout: "1000",
|
|
65
52
|
json: true
|
|
66
53
|
}, void 0, {
|
|
@@ -69,7 +56,8 @@ async function probeClickClackGatewayStatus() {
|
|
|
69
56
|
});
|
|
70
57
|
return GATEWAY_RUNNING_MESSAGE;
|
|
71
58
|
} catch (error) {
|
|
72
|
-
|
|
59
|
+
const message = formatErrorMessage(error).toLowerCase();
|
|
60
|
+
return gateway && gateway.isGatewayTransportError(error) && error.kind === "closed" && error.code === 1006 || message.includes("econnrefused") || message.includes("connection refused") ? GATEWAY_NOT_RUNNING_MESSAGE : GATEWAY_UNKNOWN_MESSAGE;
|
|
73
61
|
}
|
|
74
62
|
}
|
|
75
63
|
function formatClickClackConnectionLog(result) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"entries":[{"output":"api.js","source":"extensions/clickclack/api.ts"},{"output":"channel-plugin-api.js","source":"extensions/clickclack/channel-plugin-api.ts"},{"output":"doctor-contract-api.js","source":"extensions/clickclack/doctor-contract-api.ts"},{"output":"index.js","source":"extensions/clickclack/index.ts"},{"output":"runtime-api.js","source":"extensions/clickclack/runtime-api.ts"},{"output":"secret-contract-api.js","source":"extensions/clickclack/secret-contract-api.ts"},{"output":"setup-entry.js","source":"extensions/clickclack/setup-entry.ts"},{"output":"setup-plugin-api.js","source":"extensions/clickclack/setup-plugin-api.ts"}],"chunks":[{"output":".setup/channel-
|
|
1
|
+
{"version":3,"entries":[{"output":"api.js","source":"extensions/clickclack/api.ts"},{"output":"channel-plugin-api.js","source":"extensions/clickclack/channel-plugin-api.ts"},{"output":"doctor-contract-api.js","source":"extensions/clickclack/doctor-contract-api.ts"},{"output":"index.js","source":"extensions/clickclack/index.ts"},{"output":"runtime-api.js","source":"extensions/clickclack/runtime-api.ts"},{"output":"secret-contract-api.js","source":"extensions/clickclack/secret-contract-api.ts"},{"output":"setup-entry.js","source":"extensions/clickclack/setup-entry.ts"},{"output":"setup-plugin-api.js","source":"extensions/clickclack/setup-plugin-api.ts"}],"chunks":[{"output":".setup/channel-ByAANbh8.mjs","sha256":"450c1c4f77efbc6a4fe7dfe184221b6f25da321f5144b8dc53c452fdff1f0a7c","facadeSource":null,"sources":["extensions/clickclack/src/access.ts","extensions/clickclack/src/activity.ts","extensions/clickclack/src/channel.ts","extensions/clickclack/src/discussions/binding-generation.ts","extensions/clickclack/src/discussions/binding-store.ts","extensions/clickclack/src/discussions/eligibility.ts","extensions/clickclack/src/discussions/naming.ts","extensions/clickclack/src/discussions/revoked-channel-store.ts","extensions/clickclack/src/discussions/routing.ts","extensions/clickclack/src/discussions/session-authority.ts","extensions/clickclack/src/gateway.ts","extensions/clickclack/src/group-policy.ts","extensions/clickclack/src/inbound.ts","extensions/clickclack/src/outbound.ts","extensions/clickclack/src/progress.ts","extensions/clickclack/src/runtime.ts","extensions/clickclack/src/target.ts","src/channels/mention-gating.ts"]},{"output":".setup/resolve-CRj6QjdF.mjs","sha256":"70188c223d195aaa2d36e4dcc5d7cf006e6568f9d06423a62e9453487f81bfa2","facadeSource":null,"sources":["extensions/clickclack/src/http-client.ts","extensions/clickclack/src/resolve.ts"]},{"output":".setup/rolldown-runtime-782esTHO.mjs","sha256":"5ee95aea427a7c3b63d18f4d901f7c824b836077e85aee06ae7d598c1974e2a6","facadeSource":null,"sources":[]},{"output":".setup/runtime-api-BsRK-sfA.mjs","sha256":"64dd234dd1bc81d34cd7ace25ce4f2e5787cbaa77693b428cd0f48493b66f4bd","facadeSource":null,"sources":["extensions/clickclack/src/discussions/binding-retention.ts","extensions/clickclack/src/discussions/control-session-url.ts","extensions/clickclack/src/discussions/installation.ts","extensions/clickclack/src/discussions/register.ts","extensions/clickclack/src/discussions/service-history.ts","extensions/clickclack/src/discussions/service-open.ts","extensions/clickclack/src/discussions/service.ts"]},{"output":".setup/secret-contract-api-DS3Vv0Gu.mjs","sha256":"1f4fbfb7031408f8896ccf43ddb8548914c3262c87011904190d9b28c40ebb80","facadeSource":"extensions/clickclack/secret-contract-api.ts","sources":[]},{"output":".setup/secret-contract-Dj8nibUr.mjs","sha256":"2c29e39e3a80ffa74c2141f7a8b2a0beb63b1094f030860bd26bda2319d04d9b","facadeSource":null,"sources":["extensions/clickclack/src/secret-contract.ts"]},{"output":".setup/setup-claim-BAKxfObl.mjs","sha256":"5338c71680bfaae4274e8af80ef35cd61dfb3e1881f8a7979b2d1ef5191f0d77","facadeSource":"extensions/clickclack/src/setup-claim.ts","sources":["extensions/clickclack/src/setup-claim.ts"]},{"output":".setup/setup-plugin-api-BTqE973B.mjs","sha256":"5740b952578d7242249506eb563c876aec52798c5225d54ad6fb4abb46e25659","facadeSource":null,"sources":["extensions/clickclack/src/channel.setup.ts"]},{"output":".setup/setup-plugin-api-CfuhJJvK.mjs","sha256":"743fa1f54c66ac71fb9f659b7ff47c47b379225bd14c7d87b374f9301518a610","facadeSource":"extensions/clickclack/setup-plugin-api.ts","sources":[]},{"output":".setup/setup-surface-5wSYr6p2.mjs","sha256":"e277541cd9c2e34678dc5464e347aa473e25cb307465a875a9c368e445a62071","facadeSource":null,"sources":["extensions/clickclack/src/accounts.ts","extensions/clickclack/src/channel-config.ts","extensions/clickclack/src/config-schema.ts","extensions/clickclack/src/setup-contract.ts","extensions/clickclack/src/setup-core.ts","extensions/clickclack/src/setup-surface.ts"]},{"output":".setup/setup-verify-IayKkFWq.mjs","sha256":"dcbb56ce503e43a6b54e0fd73a999fbbfe4b029afeb996e0a5dd5366c4814edd","facadeSource":"extensions/clickclack/src/setup-verify.ts","sources":["extensions/clickclack/src/setup-verify.ts"]},{"output":"api.js","sha256":"547bd75f58aacd4185112aa77faae24a51dbbe088b1a1c10257be78f5a21672a","facadeSource":"extensions/clickclack/api.ts","sources":[]},{"output":"channel-plugin-api.js","sha256":"dc60b1cf86c86ea358020490a24a821aabe924966500ba04360a0d2c156cd430","facadeSource":"extensions/clickclack/channel-plugin-api.ts","sources":[]},{"output":"doctor-contract-api.js","sha256":"90e35955fee235ef5fde4467214d6fc892a5eca1ec736c65a0f6295c3372daa0","facadeSource":"extensions/clickclack/doctor-contract-api.ts","sources":["extensions/clickclack/src/doctor-contract.ts","packages/normalization-core/src/record-coerce.ts","src/config/channel-config-normalization.ts","src/plugin-sdk/legacy-webhook-listener-migration.ts"]},{"output":"index.js","sha256":"22200462363615fc6e30194e2f1d82464856157dac0c0231daa81987af0ad877","facadeSource":"extensions/clickclack/index.ts","sources":["extensions/clickclack/index.ts"]},{"output":"runtime-api.js","sha256":"495e79c4025920ad6daa2afb3b35e06e5e15ca87b89d8d01e9fb4992c3b9baff","facadeSource":"extensions/clickclack/runtime-api.ts","sources":[]},{"output":"secret-contract-api.js","sha256":"cff9cd4ef5118483a955a1375f95db91532f9f9755b43e54e4b04561b9ee7810","facadeSource":"extensions/clickclack/secret-contract-api.ts","sources":[]},{"output":"setup-entry.js","sha256":"58b9cd63bfefea2acb45f8ba94ed64ad7911824d1ceadb2819d0b1434dce3500","facadeSource":"extensions/clickclack/setup-entry.ts","sources":["extensions/clickclack/setup-entry.ts"]},{"output":"setup-plugin-api.js","sha256":"33a5a0bd1cb00ee06b9125ab5db5dd78c62a6648cec7b78c954c0947b0048274","facadeSource":"extensions/clickclack/setup-plugin-api.ts","sources":[]}],"unrenderedSources":["extensions/clickclack/api.ts","extensions/clickclack/channel-plugin-api.ts","extensions/clickclack/config-doctor-api.ts","extensions/clickclack/doctor-contract-api.ts","extensions/clickclack/runtime-api.ts","extensions/clickclack/secret-contract-api.ts","extensions/clickclack/setup-plugin-api.ts"]}
|
package/dist/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as resolveDefaultClickClackAccountId, d as DEFAULT_ACCOUNT_ID, h as resolveClickClackAccount, m as listEnabledClickClackAccounts, p as listClickClackAccountIds, s as clickClackConfigSchema } from "./.setup/setup-surface-
|
|
2
|
-
import { a as setClickClackRuntime, i as getClickClackRuntime, n as buildClickClackTarget, r as parseClickClackTarget, t as clickClackPlugin } from "./.setup/channel-
|
|
3
|
-
import { a as createClickClackClient } from "./.setup/resolve-
|
|
1
|
+
import { _ as resolveDefaultClickClackAccountId, d as DEFAULT_ACCOUNT_ID, h as resolveClickClackAccount, m as listEnabledClickClackAccounts, p as listClickClackAccountIds, s as clickClackConfigSchema } from "./.setup/setup-surface-5wSYr6p2.mjs";
|
|
2
|
+
import { a as setClickClackRuntime, i as getClickClackRuntime, n as buildClickClackTarget, r as parseClickClackTarget, t as clickClackPlugin } from "./.setup/channel-ByAANbh8.mjs";
|
|
3
|
+
import { a as createClickClackClient } from "./.setup/resolve-CRj6QjdF.mjs";
|
|
4
4
|
export { DEFAULT_ACCOUNT_ID, buildClickClackTarget, clickClackConfigSchema, clickClackPlugin, createClickClackClient, getClickClackRuntime, listClickClackAccountIds, listEnabledClickClackAccounts, parseClickClackTarget, resolveClickClackAccount, resolveDefaultClickClackAccountId, setClickClackRuntime };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as clickClackPlugin } from "./.setup/channel-
|
|
1
|
+
export { t as clickClackPlugin } from "./.setup/channel-ByAANbh8.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as __reExport, t as __exportAll } from "./.setup/rolldown-runtime-
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./.setup/rolldown-runtime-782esTHO.mjs";
|
|
2
2
|
// packages/normalization-core/src/record-coerce.ts
|
|
3
3
|
/** Type guard for non-array object records at browser-safe boundaries. */
|
|
4
4
|
function isRecord(value) {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as registerClickClackDiscussions } from "./.setup/runtime-api-
|
|
1
|
+
import { t as registerClickClackDiscussions } from "./.setup/runtime-api-BsRK-sfA.mjs";
|
|
2
2
|
import { defineBundledChannelEntry } from "openclaw/plugin-sdk/channel-entry-contract";
|
|
3
3
|
// extensions/clickclack/index.ts
|
|
4
4
|
var clickclack_default = defineBundledChannelEntry({
|
package/dist/runtime-api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as resolveClickClackAccount } from "./.setup/setup-surface-
|
|
2
|
-
import { a as setClickClackRuntime, r as parseClickClackTarget } from "./.setup/channel-
|
|
3
|
-
import { a as createClickClackClient } from "./.setup/resolve-
|
|
4
|
-
import { t as registerClickClackDiscussions } from "./.setup/runtime-api-
|
|
1
|
+
import { h as resolveClickClackAccount } from "./.setup/setup-surface-5wSYr6p2.mjs";
|
|
2
|
+
import { a as setClickClackRuntime, r as parseClickClackTarget } from "./.setup/channel-ByAANbh8.mjs";
|
|
3
|
+
import { a as createClickClackClient } from "./.setup/resolve-CRj6QjdF.mjs";
|
|
4
|
+
import { t as registerClickClackDiscussions } from "./.setup/runtime-api-BsRK-sfA.mjs";
|
|
5
5
|
export { createClickClackClient, parseClickClackTarget, registerClickClackDiscussions, resolveClickClackAccount, setClickClackRuntime };
|
package/dist/setup-entry.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
var setup_entry_default = defineBundledChannelSetupEntry({
|
|
5
5
|
importMetaUrl: import.meta.url,
|
|
6
6
|
plugin: {
|
|
7
|
-
specifier: fileURLToPath(new URL(".setup/setup-plugin-api-
|
|
7
|
+
specifier: fileURLToPath(new URL(".setup/setup-plugin-api-CfuhJJvK.mjs", import.meta.url).href),
|
|
8
8
|
exportName: "clickClackSetupPlugin"
|
|
9
9
|
},
|
|
10
10
|
secrets: {
|
package/dist/setup-plugin-api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as clickClackSetupPlugin } from "./.setup/setup-plugin-api-
|
|
1
|
+
export { t as clickClackSetupPlugin } from "./.setup/setup-plugin-api-BTqE973B.mjs";
|
|
@@ -140,6 +140,33 @@ test("continue parsing despite array size error", () => {
|
|
|
140
140
|
`);
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
+
test("an upper size bound fails before any element is parsed", () => {
|
|
144
|
+
let parsed = 0;
|
|
145
|
+
const el = z.string().refine(() => ++parsed);
|
|
146
|
+
let refined = 0;
|
|
147
|
+
const schema = z
|
|
148
|
+
.array(el)
|
|
149
|
+
.max(2, "too many")
|
|
150
|
+
.refine(() => ++refined);
|
|
151
|
+
expect(schema.safeParse([1, 2, 3]).error!.issues).toMatchObject([{ code: "too_big", path: [], message: "too many" }]);
|
|
152
|
+
expect(z.array(el).length(2).safeParse(["a", "b", "c"]).error!.issues).toMatchObject([
|
|
153
|
+
{ code: "too_big", exact: true },
|
|
154
|
+
]);
|
|
155
|
+
expect(z.object({ a: z.array(el).max(1) }).safeParse({ a: [1, 2] }).error!.issues).toMatchObject([
|
|
156
|
+
{ code: "too_big", path: ["a"] },
|
|
157
|
+
]);
|
|
158
|
+
expect([parsed, refined]).toEqual([0, 0]);
|
|
159
|
+
|
|
160
|
+
// a check that may rewrite the value ends the gate
|
|
161
|
+
expect(
|
|
162
|
+
z
|
|
163
|
+
.array(z.number())
|
|
164
|
+
.overwrite((a) => a.slice(0, 2))
|
|
165
|
+
.max(2)
|
|
166
|
+
.parse([1, 2, 3])
|
|
167
|
+
).toEqual([1, 2]);
|
|
168
|
+
});
|
|
169
|
+
|
|
143
170
|
test("parse should fail given sparse array", () => {
|
|
144
171
|
const schema = z.array(z.string()).nonempty().min(1).max(3);
|
|
145
172
|
const result = schema.safeParse(new Array(3));
|
|
@@ -97,6 +97,13 @@ test("failing when map is bigger than max() ", () => {
|
|
|
97
97
|
expect(result.success).toEqual(false);
|
|
98
98
|
expect(result.error!.issues.length).toEqual(1);
|
|
99
99
|
expect(result.error!.issues[0].code).toEqual("too_big");
|
|
100
|
+
const bad = new Map([
|
|
101
|
+
[1, 1],
|
|
102
|
+
[2, 2],
|
|
103
|
+
]);
|
|
104
|
+
const capped = z.map(z.string(), z.string()).max(1);
|
|
105
|
+
expect(capped.safeParse(bad).error!.issues).toMatchObject([{ code: "too_big" }]);
|
|
106
|
+
expect(capped.safeParse(new Set([1, 2])).error!.issues[0]).toMatchObject({ code: "invalid_type", expected: "map" });
|
|
100
107
|
});
|
|
101
108
|
|
|
102
109
|
test("failing when map does not match size() ", () => {
|
|
@@ -83,6 +83,12 @@ test("failing when set is bigger than max() ", () => {
|
|
|
83
83
|
expect(result.success).toEqual(false);
|
|
84
84
|
expect(result.error!.issues.length).toEqual(1);
|
|
85
85
|
expect(result.error!.issues[0].code).toEqual("too_big");
|
|
86
|
+
expect(
|
|
87
|
+
z
|
|
88
|
+
.set(z.string())
|
|
89
|
+
.max(1)
|
|
90
|
+
.safeParse(new Set([1, 2])).error!.issues
|
|
91
|
+
).toMatchObject([{ code: "too_big" }]);
|
|
86
92
|
});
|
|
87
93
|
|
|
88
94
|
test("failing when set does not match size() ", () => {
|
|
@@ -1551,6 +1551,12 @@ function generateNullableCheck(
|
|
|
1551
1551
|
return outputVar;
|
|
1552
1552
|
}
|
|
1553
1553
|
|
|
1554
|
+
function generateSizeGate(doc: Doc, schema: SomeType, size: string): void {
|
|
1555
|
+
for (const [max, check] of util.sizeCaps(schema._zod.def.checks)) {
|
|
1556
|
+
doc.write(`if (${size} > ${numericOperand(max, check._zod.def.check)}) return INVALID;`);
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1554
1560
|
function generateArrayCheck(
|
|
1555
1561
|
doc: Doc,
|
|
1556
1562
|
ctx: CompileContext,
|
|
@@ -1560,6 +1566,7 @@ function generateArrayCheck(
|
|
|
1560
1566
|
): string | null {
|
|
1561
1567
|
const def = schema._zod.def as unknown as { element: SomeType };
|
|
1562
1568
|
doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
|
|
1569
|
+
generateSizeGate(doc, schema, `${accessor}.length`);
|
|
1563
1570
|
|
|
1564
1571
|
// Build a new array with validated/transformed elements.
|
|
1565
1572
|
const outputVar = buildsValue ? newVar(ctx) : null;
|
|
@@ -2094,6 +2101,7 @@ function generateMapCheck(doc: Doc, ctx: CompileContext, schema: SomeType, acces
|
|
|
2094
2101
|
const def = schema._zod.def as unknown as { keyType: SomeType; valueType: SomeType };
|
|
2095
2102
|
|
|
2096
2103
|
doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
|
|
2104
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
2097
2105
|
|
|
2098
2106
|
const outputVar = newVar(ctx);
|
|
2099
2107
|
const kVar = newVar(ctx);
|
|
@@ -2115,6 +2123,7 @@ function generateSetCheck(doc: Doc, ctx: CompileContext, schema: SomeType, acces
|
|
|
2115
2123
|
const def = schema._zod.def as unknown as { valueType: SomeType };
|
|
2116
2124
|
|
|
2117
2125
|
doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
|
|
2126
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
2118
2127
|
|
|
2119
2128
|
const outputVar = newVar(ctx);
|
|
2120
2129
|
const valVar = newVar(ctx);
|
|
@@ -1844,6 +1844,34 @@ export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$Zod
|
|
|
1844
1844
|
|
|
1845
1845
|
export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {}
|
|
1846
1846
|
|
|
1847
|
+
// an oversized container fails its leading size checks before any element is parsed
|
|
1848
|
+
function capSize(inst: $ZodType, size: (input: any) => number): void {
|
|
1849
|
+
const caps = util.sizeCaps(inst._zod.def.checks);
|
|
1850
|
+
if (!caps.length) return;
|
|
1851
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
1852
|
+
const parse = inst._zod.parse;
|
|
1853
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1854
|
+
const n = size(payload.value);
|
|
1855
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
1856
|
+
for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
|
|
1857
|
+
if (n > max && ch._zod.def.when!(payload)) {
|
|
1858
|
+
const start = payload.issues.length;
|
|
1859
|
+
ch._zod.check(payload as ParsePayload<never>);
|
|
1860
|
+
// the value is still the raw input, so no later check may read it
|
|
1861
|
+
(payload.issues[start] as { continue?: boolean }).continue = false;
|
|
1862
|
+
util.attachSchema(payload.issues, start, inst);
|
|
1863
|
+
return payload;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
return parse(payload, ctx);
|
|
1868
|
+
};
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
const arraySize = (input: unknown): number => (Array.isArray(input) ? input.length : -1);
|
|
1872
|
+
const mapSize = (input: unknown): number => (input instanceof Map ? input.size : -1);
|
|
1873
|
+
const setSize = (input: unknown): number => (input instanceof Set ? input.size : -1);
|
|
1874
|
+
|
|
1847
1875
|
function handleArrayResult(result: ParsePayload<any>, final: ParsePayload<any[]>, index: number) {
|
|
1848
1876
|
if (result.issues.length) {
|
|
1849
1877
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -1899,6 +1927,7 @@ export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$const
|
|
|
1899
1927
|
|
|
1900
1928
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
1901
1929
|
};
|
|
1930
|
+
capSize(inst, arraySize);
|
|
1902
1931
|
});
|
|
1903
1932
|
|
|
1904
1933
|
//////////////////////////////////////////
|
|
@@ -3218,8 +3247,11 @@ export type $InferZodRecordInput<
|
|
|
3218
3247
|
: Record<core.input<Key> & PropertyKey, core.input<Value>>;
|
|
3219
3248
|
|
|
3220
3249
|
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
|
|
3221
|
-
extends $ZodTypeInternals
|
|
3250
|
+
extends $ZodTypeInternals {
|
|
3222
3251
|
def: $ZodRecordDef<Key, Value>;
|
|
3252
|
+
// members rather than base type arguments, which TypeScript 7.1 reports as circular for `z.json()`
|
|
3253
|
+
output: $InferZodRecordOutput<Key, Value>;
|
|
3254
|
+
input: $InferZodRecordInput<Key, Value>;
|
|
3223
3255
|
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
|
3224
3256
|
optin?: "optional" | undefined;
|
|
3225
3257
|
optout?: "optional" | undefined;
|
|
@@ -3480,6 +3512,7 @@ export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$construct
|
|
|
3480
3512
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
3481
3513
|
return payload;
|
|
3482
3514
|
};
|
|
3515
|
+
capSize(inst, mapSize);
|
|
3483
3516
|
});
|
|
3484
3517
|
|
|
3485
3518
|
function handleMapResult(
|
|
@@ -3582,6 +3615,7 @@ export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$construct
|
|
|
3582
3615
|
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
3583
3616
|
return payload;
|
|
3584
3617
|
};
|
|
3618
|
+
capSize(inst, setSize);
|
|
3585
3619
|
});
|
|
3586
3620
|
|
|
3587
3621
|
function handleSetResult(result: ParsePayload, final: ParsePayload<Set<any>>) {
|
|
@@ -935,6 +935,19 @@ export function unwrapMessage(message: string | { message: string } | undefined
|
|
|
935
935
|
}
|
|
936
936
|
|
|
937
937
|
/* A check holds no link back to the schema it is attached to — the same check instance is shared by every clone of that schema — so the owner is stamped onto the issues a check just raised, at the only point where both are in scope. Runs on the failure path only; `start` is the issue count from before the check ran. */
|
|
938
|
+
/** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
|
|
939
|
+
export function sizeCaps(defChecks: checks.$ZodCheck<never>[] | undefined): [number, checks.$ZodCheck<never>][] {
|
|
940
|
+
const caps: [number, checks.$ZodCheck<never>][] = [];
|
|
941
|
+
for (const ch of defChecks ?? []) {
|
|
942
|
+
const d = ch._zod.def as any;
|
|
943
|
+
// a later check may rewrite the value
|
|
944
|
+
if (!/_(length|size)$|_equals$/.test(d.check)) break;
|
|
945
|
+
const max = d.maximum ?? d.length ?? d.size;
|
|
946
|
+
if (max >= 0) caps.push([max, ch]);
|
|
947
|
+
}
|
|
948
|
+
return caps;
|
|
949
|
+
}
|
|
950
|
+
|
|
938
951
|
export function attachSchema(issues: errors.$ZodRawIssue[], start: number, inst: schemas.$ZodType): void {
|
|
939
952
|
for (let i = start; i < issues.length; i++) {
|
|
940
953
|
(issues[i] as any).schema ??= inst;
|
|
@@ -1241,9 +1241,15 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
1241
1241
|
doc.write(`}`);
|
|
1242
1242
|
return outputVar;
|
|
1243
1243
|
}
|
|
1244
|
+
function generateSizeGate(doc, schema, size) {
|
|
1245
|
+
for (const [max, check] of util.sizeCaps(schema._zod.def.checks)) {
|
|
1246
|
+
doc.write(`if (${size} > ${numericOperand(max, check._zod.def.check)}) return INVALID;`);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1244
1249
|
function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
1245
1250
|
const def = schema._zod.def;
|
|
1246
1251
|
doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
|
|
1252
|
+
generateSizeGate(doc, schema, `${accessor}.length`);
|
|
1247
1253
|
// Build a new array with validated/transformed elements.
|
|
1248
1254
|
const outputVar = buildsValue ? newVar(ctx) : null;
|
|
1249
1255
|
const iVar = newVar(ctx);
|
|
@@ -1707,6 +1713,7 @@ function literalPropertyKey(ctx, key) {
|
|
|
1707
1713
|
function generateMapCheck(doc, ctx, schema, accessor) {
|
|
1708
1714
|
const def = schema._zod.def;
|
|
1709
1715
|
doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
|
|
1716
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
1710
1717
|
const outputVar = newVar(ctx);
|
|
1711
1718
|
const kVar = newVar(ctx);
|
|
1712
1719
|
const valVar = newVar(ctx);
|
|
@@ -1723,6 +1730,7 @@ function generateMapCheck(doc, ctx, schema, accessor) {
|
|
|
1723
1730
|
function generateSetCheck(doc, ctx, schema, accessor) {
|
|
1724
1731
|
const def = schema._zod.def;
|
|
1725
1732
|
doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
|
|
1733
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
1726
1734
|
const outputVar = newVar(ctx);
|
|
1727
1735
|
const valVar = newVar(ctx);
|
|
1728
1736
|
doc.write(`const ${outputVar} = new Set();`);
|
|
@@ -1210,9 +1210,15 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
1210
1210
|
doc.write(`}`);
|
|
1211
1211
|
return outputVar;
|
|
1212
1212
|
}
|
|
1213
|
+
function generateSizeGate(doc, schema, size) {
|
|
1214
|
+
for (const [max, check] of util.sizeCaps(schema._zod.def.checks)) {
|
|
1215
|
+
doc.write(`if (${size} > ${numericOperand(max, check._zod.def.check)}) return INVALID;`);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1213
1218
|
function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
1214
1219
|
const def = schema._zod.def;
|
|
1215
1220
|
doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
|
|
1221
|
+
generateSizeGate(doc, schema, `${accessor}.length`);
|
|
1216
1222
|
// Build a new array with validated/transformed elements.
|
|
1217
1223
|
const outputVar = buildsValue ? newVar(ctx) : null;
|
|
1218
1224
|
const iVar = newVar(ctx);
|
|
@@ -1676,6 +1682,7 @@ function literalPropertyKey(ctx, key) {
|
|
|
1676
1682
|
function generateMapCheck(doc, ctx, schema, accessor) {
|
|
1677
1683
|
const def = schema._zod.def;
|
|
1678
1684
|
doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
|
|
1685
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
1679
1686
|
const outputVar = newVar(ctx);
|
|
1680
1687
|
const kVar = newVar(ctx);
|
|
1681
1688
|
const valVar = newVar(ctx);
|
|
@@ -1692,6 +1699,7 @@ function generateMapCheck(doc, ctx, schema, accessor) {
|
|
|
1692
1699
|
function generateSetCheck(doc, ctx, schema, accessor) {
|
|
1693
1700
|
const def = schema._zod.def;
|
|
1694
1701
|
doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
|
|
1702
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
1695
1703
|
const outputVar = newVar(ctx);
|
|
1696
1704
|
const valVar = newVar(ctx);
|
|
1697
1705
|
doc.write(`const ${outputVar} = new Set();`);
|
|
@@ -860,6 +860,33 @@ exports.$ZodDate = core.$constructor("$ZodDate", (inst, def) => {
|
|
|
860
860
|
return payload;
|
|
861
861
|
};
|
|
862
862
|
});
|
|
863
|
+
// an oversized container fails its leading size checks before any element is parsed
|
|
864
|
+
function capSize(inst, size) {
|
|
865
|
+
const caps = util.sizeCaps(inst._zod.def.checks);
|
|
866
|
+
if (!caps.length)
|
|
867
|
+
return;
|
|
868
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
869
|
+
const parse = inst._zod.parse;
|
|
870
|
+
inst._zod.parse = (payload, ctx) => {
|
|
871
|
+
const n = size(payload.value);
|
|
872
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
873
|
+
for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
|
|
874
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
875
|
+
const start = payload.issues.length;
|
|
876
|
+
ch._zod.check(payload);
|
|
877
|
+
// the value is still the raw input, so no later check may read it
|
|
878
|
+
payload.issues[start].continue = false;
|
|
879
|
+
util.attachSchema(payload.issues, start, inst);
|
|
880
|
+
return payload;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
return parse(payload, ctx);
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
|
|
888
|
+
const mapSize = (input) => (input instanceof Map ? input.size : -1);
|
|
889
|
+
const setSize = (input) => (input instanceof Set ? input.size : -1);
|
|
863
890
|
function handleArrayResult(result, final, index) {
|
|
864
891
|
if (result.issues.length) {
|
|
865
892
|
final.issues.push(...util.prefixIssues(index, result.issues));
|
|
@@ -905,6 +932,7 @@ exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
|
|
|
905
932
|
}
|
|
906
933
|
return payload; //handleArrayResultsAsync(parseResults, final);
|
|
907
934
|
};
|
|
935
|
+
capSize(inst, arraySize);
|
|
908
936
|
});
|
|
909
937
|
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
910
938
|
const isPresent = key in input;
|
|
@@ -1942,6 +1970,7 @@ exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
|
|
|
1942
1970
|
return Promise.all(proms).then(() => payload);
|
|
1943
1971
|
return payload;
|
|
1944
1972
|
};
|
|
1973
|
+
capSize(inst, mapSize);
|
|
1945
1974
|
});
|
|
1946
1975
|
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
1947
1976
|
if (keyResult.issues.length) {
|
|
@@ -2011,6 +2040,7 @@ exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
|
|
|
2011
2040
|
return Promise.all(proms).then(() => payload);
|
|
2012
2041
|
return payload;
|
|
2013
2042
|
};
|
|
2043
|
+
capSize(inst, setSize);
|
|
2014
2044
|
});
|
|
2015
2045
|
function handleSetResult(result, final) {
|
|
2016
2046
|
if (result.issues.length) {
|
|
@@ -834,8 +834,10 @@ export type $InferZodRecordOutput<Key extends $ZodRecordKey = $ZodRecordKey, Val
|
|
|
834
834
|
export type $InferZodRecordInput<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> = Key extends $partial ? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>> : [
|
|
835
835
|
Value
|
|
836
836
|
] extends [OptionalInSchema] ? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>> : Record<core.input<Key> & PropertyKey, core.input<Value>>;
|
|
837
|
-
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals
|
|
837
|
+
export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType> extends $ZodTypeInternals {
|
|
838
838
|
def: $ZodRecordDef<Key, Value>;
|
|
839
|
+
output: $InferZodRecordOutput<Key, Value>;
|
|
840
|
+
input: $InferZodRecordInput<Key, Value>;
|
|
839
841
|
isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
|
|
840
842
|
optin?: "optional" | undefined;
|
|
841
843
|
optout?: "optional" | undefined;
|