@krak-stack/registry 0.10.0 → 0.10.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.
@@ -0,0 +1,947 @@
1
+ // @bun
2
+ // ../../src/lib/docs.server.ts
3
+ import { Schema as Schema4 } from "effect";
4
+
5
+ // ../../src/lib/docs.tsx
6
+ import { createIsomorphicFn } from "@tanstack/react-start";
7
+ import { getCookie } from "@tanstack/react-start/server";
8
+ import { Option as Option2, Schema as Schema3 } from "effect";
9
+ import { Cookies as Cookies2 } from "effect/http";
10
+ import {
11
+ forwardRef,
12
+ useDeferredValue,
13
+ useEffect as useEffect4,
14
+ useState as useState5
15
+ } from "react";
16
+
17
+ // ../../src/components/ui/app-brand.tsx
18
+ import { Link } from "@tanstack/react-router";
19
+
20
+ // ../../src/components/ui/badge.tsx
21
+ import { mergeProps } from "@base-ui/react/merge-props";
22
+ import { useRender } from "@base-ui/react/use-render";
23
+ import { cva } from "class-variance-authority";
24
+
25
+ // ../../src/lib/utils.ts
26
+ import { cn } from "cn";
27
+
28
+ // ../../src/components/ui/badge.tsx
29
+ var badgeVariants = cva("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", {
30
+ variants: {
31
+ variant: {
32
+ default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
33
+ secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
34
+ destructive: "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
35
+ outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
36
+ ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
37
+ link: "text-primary underline-offset-4 hover:underline"
38
+ }
39
+ },
40
+ defaultVariants: {
41
+ variant: "default"
42
+ }
43
+ });
44
+
45
+ // ../../src/components/ui/button.tsx
46
+ import { Button as ButtonPrimitive } from "@base-ui/react/button";
47
+ import { cva as cva2 } from "class-variance-authority";
48
+ var buttonVariants = cva2("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
49
+ variants: {
50
+ variant: {
51
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
52
+ outline: "border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
53
+ secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
54
+ ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
55
+ destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
56
+ link: "text-primary underline-offset-4 hover:underline"
57
+ },
58
+ size: {
59
+ default: "h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
60
+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
61
+ sm: "h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
62
+ lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
63
+ icon: "size-9",
64
+ "icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
65
+ "icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
66
+ "icon-lg": "size-10"
67
+ }
68
+ },
69
+ defaultVariants: {
70
+ variant: "default",
71
+ size: "default"
72
+ }
73
+ });
74
+
75
+ // ../../src/components/ui/copy-button.tsx
76
+ import { Check, Copy, TriangleAlert } from "lucide-react";
77
+ import { useEffect, useRef, useState } from "react";
78
+ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
79
+
80
+ // ../../src/components/ui/code-block.tsx
81
+ import { highlight } from "@tanstack/highlight";
82
+ import { createThemeCss } from "@tanstack/highlight/theme";
83
+ import { githubDarkTheme } from "@tanstack/highlight/themes/github-dark";
84
+ import { githubLightTheme } from "@tanstack/highlight/themes/github-light";
85
+ import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
86
+ var themeCss = `${createThemeCss({
87
+ light: githubLightTheme,
88
+ dark: githubDarkTheme,
89
+ lightSelector: "[data-code-theme]",
90
+ darkSelector: ".dark [data-code-theme]",
91
+ codeBlockSelector: "[data-code-theme] pre.th-code",
92
+ lineNumbersSelector: "[data-code-theme] .th-code--line-numbers"
93
+ })}
94
+ [data-code-theme] pre.th-code {
95
+ margin: 0;
96
+ overflow: visible;
97
+ background: transparent;
98
+ font: inherit;
99
+ color: inherit;
100
+ }
101
+ [data-code-theme] pre.th-code code { font: inherit; }`;
102
+
103
+ // ../../src/components/ui/collapsible.tsx
104
+ import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible";
105
+
106
+ // ../../src/components/ui/search-menu.tsx
107
+ import { SearchIcon as SearchIcon2 } from "lucide-react";
108
+ import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
109
+
110
+ // ../../src/components/ui/command.tsx
111
+ import { Command as CommandPrimitive } from "cmdk";
112
+ import { SearchIcon } from "lucide-react";
113
+
114
+ // ../../src/components/ui/dialog.tsx
115
+ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
116
+ import { XIcon } from "lucide-react";
117
+
118
+ // ../../src/components/ui/search-menu.tsx
119
+ import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
120
+
121
+ // ../../src/components/ui/sidebar-layout.tsx
122
+ import { Link as Link2, Outlet } from "@tanstack/react-router";
123
+ import { Option, Schema as Schema2 } from "effect";
124
+ import { Cookies } from "effect/http";
125
+ import { useState as useState4 } from "react";
126
+
127
+ // ../../src/components/ui/sidebar.tsx
128
+ import * as React2 from "react";
129
+ import { mergeProps as mergeProps2 } from "@base-ui/react/merge-props";
130
+ import { useRender as useRender2 } from "@base-ui/react/use-render";
131
+ import { cva as cva3 } from "class-variance-authority";
132
+
133
+ // ../../src/hooks/use-mobile.ts
134
+ import * as React from "react";
135
+
136
+ // ../../src/components/ui/input.tsx
137
+ import { Input as InputPrimitive } from "@base-ui/react/input";
138
+
139
+ // ../../src/components/ui/separator.tsx
140
+ import { Separator as SeparatorPrimitive } from "@base-ui/react/separator";
141
+
142
+ // ../../src/components/ui/sheet.tsx
143
+ import { Dialog as SheetPrimitive } from "@base-ui/react/dialog";
144
+ import { XIcon as XIcon2 } from "lucide-react";
145
+ "use client";
146
+
147
+ // ../../src/components/ui/tooltip.tsx
148
+ import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
149
+ "use client";
150
+
151
+ // ../../src/components/ui/sidebar.tsx
152
+ import { PanelLeftIcon } from "lucide-react";
153
+ import { Schema } from "effect";
154
+ var SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
155
+ var SidebarContext = React2.createContext(null);
156
+ var sidebarMenuButtonVariants = cva3("peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate", {
157
+ variants: {
158
+ variant: {
159
+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
160
+ outline: "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"
161
+ },
162
+ size: {
163
+ default: "h-8 text-sm",
164
+ sm: "h-7 text-xs",
165
+ lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
166
+ }
167
+ },
168
+ defaultVariants: {
169
+ variant: "default",
170
+ size: "default"
171
+ }
172
+ });
173
+
174
+ // ../../src/components/ui/sidebar-layout.tsx
175
+ var SidebarOpenCookie = Schema2.Literals(["true", "false"]).annotate({
176
+ identifier: "SidebarOpenCookie"
177
+ });
178
+
179
+ // ../../src/lib/docs.tsx
180
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
181
+ var SIDEBAR_COOKIE_NAME = "sidebar_state";
182
+ var SidebarOpenCookie2 = Schema3.Literals(["true", "false"]).annotate({
183
+ identifier: "SidebarOpenCookie"
184
+ });
185
+ var getSidebarOpenCookie = createIsomorphicFn().server(() => getCookie(SIDEBAR_COOKIE_NAME)).client(() => Cookies2.parseHeader(globalThis.document?.cookie ?? "")[SIDEBAR_COOKIE_NAME]);
186
+ var makeIcon = (name, paths) => {
187
+ const Icon = forwardRef(({ absoluteStrokeWidth: _absoluteStrokeWidth, size = 24, ...props }, ref) => /* @__PURE__ */ jsx("svg", {
188
+ "aria-hidden": "true",
189
+ fill: "none",
190
+ height: size,
191
+ ref,
192
+ stroke: "currentColor",
193
+ strokeLinecap: "round",
194
+ strokeLinejoin: "round",
195
+ strokeWidth: "2",
196
+ viewBox: "0 0 24 24",
197
+ width: size,
198
+ ...props,
199
+ children: paths
200
+ }));
201
+ Icon.displayName = name;
202
+ return Icon;
203
+ };
204
+ var ArrowLeft = makeIcon("ArrowLeft", /* @__PURE__ */ jsxs(Fragment, {
205
+ children: [
206
+ /* @__PURE__ */ jsx("path", {
207
+ d: "m12 19-7-7 7-7"
208
+ }),
209
+ /* @__PURE__ */ jsx("path", {
210
+ d: "M19 12H5"
211
+ })
212
+ ]
213
+ }));
214
+ var ArrowRight = makeIcon("ArrowRight", /* @__PURE__ */ jsxs(Fragment, {
215
+ children: [
216
+ /* @__PURE__ */ jsx("path", {
217
+ d: "M5 12h14"
218
+ }),
219
+ /* @__PURE__ */ jsx("path", {
220
+ d: "m12 5 7 7-7 7"
221
+ })
222
+ ]
223
+ }));
224
+ var BookOpen = makeIcon("BookOpen", /* @__PURE__ */ jsxs(Fragment, {
225
+ children: [
226
+ /* @__PURE__ */ jsx("path", {
227
+ d: "M12 7v14"
228
+ }),
229
+ /* @__PURE__ */ jsx("path", {
230
+ d: "M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4Z"
231
+ })
232
+ ]
233
+ }));
234
+ var ChevronDown = makeIcon("ChevronDown", /* @__PURE__ */ jsx("path", {
235
+ d: "m6 9 6 6 6-6"
236
+ }));
237
+ var ExternalLink = makeIcon("ExternalLink", /* @__PURE__ */ jsxs(Fragment, {
238
+ children: [
239
+ /* @__PURE__ */ jsx("path", {
240
+ d: "M15 3h6v6"
241
+ }),
242
+ /* @__PURE__ */ jsx("path", {
243
+ d: "M10 14 21 3"
244
+ }),
245
+ /* @__PURE__ */ jsx("path", {
246
+ d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"
247
+ })
248
+ ]
249
+ }));
250
+ var DocsSection = Schema3.String.annotate({
251
+ identifier: "DocsSection"
252
+ });
253
+ var DocsPageType = Schema3.Literals([
254
+ "concept",
255
+ "tutorial",
256
+ "how-to",
257
+ "reference",
258
+ "runbook"
259
+ ]).annotate({ identifier: "DocsPageType" });
260
+ var DocsDate = Schema3.String.pipe(Schema3.check(Schema3.makeFilter((date) => Number.isNaN(new Date(date).getTime()) ? "Expected a valid date" : undefined)));
261
+ var DocsFrontmatter = Schema3.Struct({
262
+ slug: Schema3.String,
263
+ path: Schema3.String,
264
+ title: Schema3.String,
265
+ description: Schema3.String,
266
+ icon: Schema3.optional(Schema3.String),
267
+ order: Schema3.Finite,
268
+ locale: Schema3.String,
269
+ section: DocsSection,
270
+ type: DocsPageType,
271
+ createdAt: Schema3.optional(DocsDate),
272
+ updatedAt: Schema3.optional(DocsDate),
273
+ legacySlugs: Schema3.optional(Schema3.Array(Schema3.String)),
274
+ tags: Schema3.optional(Schema3.Array(Schema3.NonEmptyString))
275
+ }).annotate({ identifier: "DocsFrontmatter" });
276
+ var DocsHeadingSchema = Schema3.Struct({
277
+ depth: Schema3.Literals([2, 3]),
278
+ id: Schema3.String,
279
+ title: Schema3.String
280
+ }).annotate({ identifier: "DocsHeading" });
281
+ var DocsCodeBlockSchema = Schema3.Struct({
282
+ code: Schema3.String,
283
+ language: Schema3.String
284
+ }).annotate({ identifier: "DocsCodeBlock" });
285
+ var DocsPageSchema = Schema3.Struct({
286
+ ...DocsFrontmatter.fields,
287
+ codeBlocks: Schema3.Array(DocsCodeBlockSchema),
288
+ headings: Schema3.Array(DocsHeadingSchema),
289
+ html: Schema3.String,
290
+ searchText: Schema3.String,
291
+ sourceFile: Schema3.String,
292
+ source: Schema3.String
293
+ }).annotate({ identifier: "DocsPage" });
294
+
295
+ // ../../src/lib/markdown/server.ts
296
+ var escapeHtml = (value) => value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("'", "&#39;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
297
+ var decodeMarkdownCode = (value) => value.replaceAll("&quot;", '"').replaceAll("&#39;", "'").replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
298
+ var safeUrl = (value, image = false) => {
299
+ if (value.startsWith("/") || value.startsWith("#") || value.startsWith("https://") || value.startsWith("http://") || !image && value.startsWith("mailto:")) {
300
+ return value;
301
+ }
302
+ return image ? "" : "#";
303
+ };
304
+ var markdownOptions = {
305
+ autolinks: true,
306
+ headings: { ids: true },
307
+ noHtmlBlocks: true,
308
+ noHtmlSpans: true,
309
+ tagFilter: true
310
+ };
311
+ var markdownPlainText = (source, includeCode = false) => Bun.markdown.render(source, {
312
+ blockquote: (children) => `${children} `,
313
+ code: (children) => includeCode ? `${children} ` : " ",
314
+ codespan: (children) => `${children} `,
315
+ heading: (children) => `${children} `,
316
+ html: () => " ",
317
+ image: (children) => `${children} `,
318
+ list: (children) => `${children} `,
319
+ listItem: (children) => `${children} `,
320
+ paragraph: (children) => `${children} `,
321
+ table: (children) => `${children} `,
322
+ td: (children) => `${children} `,
323
+ th: (children) => `${children} `,
324
+ tr: (children) => `${children} `
325
+ }, markdownOptions).replace(/\s+/g, " ").trim();
326
+ var compileMarkdown = (source) => {
327
+ const codeBlocks = [];
328
+ const html = Bun.markdown.render(source, {
329
+ blockquote: (children) => `<blockquote>${children}</blockquote>`,
330
+ code: (children, meta) => {
331
+ const index = codeBlocks.length;
332
+ const code = decodeMarkdownCode(children.replace(/\n$/, ""));
333
+ const language = meta?.language ?? "text";
334
+ codeBlocks.push({ code, language });
335
+ return `<markdown-code-block data-index="${index}"></markdown-code-block>`;
336
+ },
337
+ codespan: (children) => `<code data-inline-code>${children}</code>`,
338
+ emphasis: (children) => `<em>${children}</em>`,
339
+ heading: (children, { id, level }) => {
340
+ const headingId = escapeHtml(id ?? "");
341
+ const anchor = level === 2 || level === 3 ? `<a href="#${headingId}" aria-hidden="true">#</a>` : "";
342
+ return `<h${level} id="${headingId}">${children}${anchor}</h${level}>`;
343
+ },
344
+ hr: () => "<hr>",
345
+ html: (children) => escapeHtml(children),
346
+ image: (children, { src, title }) => {
347
+ const resolvedSrc = safeUrl(src, true);
348
+ if (!resolvedSrc)
349
+ return children;
350
+ const titleAttribute = title ? ` title="${escapeHtml(title)}"` : "";
351
+ return `<img src="${escapeHtml(resolvedSrc)}" alt="${escapeHtml(children)}"${titleAttribute}>`;
352
+ },
353
+ link: (children, { href, title }) => {
354
+ const resolvedHref = safeUrl(href);
355
+ const external = /^https?:\/\//.test(resolvedHref);
356
+ const titleAttribute = title ? ` title="${escapeHtml(title)}"` : "";
357
+ const externalAttributes = external ? ' target="_blank" rel="noreferrer"' : "";
358
+ return `<a href="${escapeHtml(resolvedHref)}"${titleAttribute}${externalAttributes}>${children}</a>`;
359
+ },
360
+ list: (children, { ordered, start }) => ordered ? `<ol${start && start !== 1 ? ` start="${start}"` : ""}>${children}</ol>` : `<ul>${children}</ul>`,
361
+ listItem: (children, { checked }) => {
362
+ const checkbox = checked === undefined ? "" : `<input type="checkbox" disabled${checked ? " checked" : ""}>`;
363
+ return `<li>${checkbox}${children}</li>`;
364
+ },
365
+ paragraph: (children) => `<p>${children}</p>`,
366
+ strikethrough: (children) => `<del>${children}</del>`,
367
+ strong: (children) => `<strong>${children}</strong>`,
368
+ table: (children) => `<div data-markdown-table><table>${children}</table></div>`,
369
+ tbody: (children) => `<tbody>${children}</tbody>`,
370
+ td: (children, meta) => `<td${meta?.align ? ` align="${meta.align}"` : ""}>${children}</td>`,
371
+ text: escapeHtml,
372
+ th: (children, meta) => `<th${meta?.align ? ` align="${meta.align}"` : ""}>${children}</th>`,
373
+ thead: (children) => `<thead>${children}</thead>`,
374
+ tr: (children) => `<tr>${children}</tr>`
375
+ }, markdownOptions);
376
+ return { codeBlocks, html, source };
377
+ };
378
+
379
+ // ../../src/lib/docs.server.ts
380
+ var compileDocsMarkdown = (source) => {
381
+ const headings = [];
382
+ const seen = new Set;
383
+ Bun.markdown.render(source, {
384
+ heading: (children, { id, level }) => {
385
+ if ((level === 2 || level === 3) && id) {
386
+ if (seen.has(id))
387
+ throw new Error(`Duplicate heading ${id}`);
388
+ seen.add(id);
389
+ headings.push({ depth: level, id, title: children });
390
+ }
391
+ return "";
392
+ }
393
+ }, markdownOptions);
394
+ const compiled = compileMarkdown(source);
395
+ return {
396
+ ...compiled,
397
+ headings,
398
+ searchText: markdownPlainText(source)
399
+ };
400
+ };
401
+
402
+ // ../../src/lib/docs.webhook-reference.server.ts
403
+ import { Option as Option3, Schema as Schema5 } from "effect";
404
+ var ReferenceNode = Schema5.Struct({
405
+ $ref: Schema5.optional(Schema5.String),
406
+ type: Schema5.optional(Schema5.Union([Schema5.String, Schema5.Array(Schema5.String)])),
407
+ description: Schema5.optional(Schema5.String),
408
+ format: Schema5.optional(Schema5.String),
409
+ enum: Schema5.optional(Schema5.Array(Schema5.Json)),
410
+ const: Schema5.optional(Schema5.Json),
411
+ properties: Schema5.optional(Schema5.Record(Schema5.String, Schema5.Json)),
412
+ required: Schema5.optional(Schema5.Array(Schema5.String)),
413
+ items: Schema5.optional(Schema5.Json),
414
+ additionalProperties: Schema5.optional(Schema5.Json),
415
+ anyOf: Schema5.optional(Schema5.Array(Schema5.Json)),
416
+ oneOf: Schema5.optional(Schema5.Array(Schema5.Json)),
417
+ allOf: Schema5.optional(Schema5.Array(Schema5.Json))
418
+ }).annotate({ identifier: "WebhookReferenceNode" });
419
+ var readNode = (value) => Schema5.decodeUnknownOption(ReferenceNode)(value).pipe(Option3.getOrElse(() => ({})));
420
+ var referenceKey = (node) => node.$ref?.startsWith("#/$defs/") ? decodeURIComponent(node.$ref.slice(8)).replace(/~1/g, "/").replace(/~0/g, "~") : undefined;
421
+ var resolve = (value, definitions, seen = new Set) => {
422
+ const node = readNode(value);
423
+ const key = referenceKey(node);
424
+ if (!key || seen.has(key) || definitions[key] === undefined)
425
+ return node;
426
+ return {
427
+ ...resolve(definitions[key], definitions, new Set([...seen, key])),
428
+ ...node
429
+ };
430
+ };
431
+ var variants = (value, definitions, seen = new Set) => {
432
+ const key = referenceKey(readNode(value));
433
+ if (key && seen.has(key))
434
+ return [];
435
+ const next = new Set([...seen, ...key ? [key] : []]);
436
+ const node = resolve(value, definitions);
437
+ const union = node.anyOf ?? node.oneOf;
438
+ if (union)
439
+ return union.flatMap((part) => variants(part, definitions, next));
440
+ if (node.allOf) {
441
+ const parts = node.allOf.map((part) => resolve(part, definitions));
442
+ return [
443
+ {
444
+ ...node,
445
+ properties: Object.assign({}, ...parts.map((part) => part.properties), node.properties),
446
+ required: [
447
+ ...new Set([
448
+ ...parts.flatMap((part) => part.required ?? []),
449
+ ...node.required ?? []
450
+ ])
451
+ ]
452
+ }
453
+ ];
454
+ }
455
+ return [node];
456
+ };
457
+ var typeLabel = (value, definitions, seen = new Set) => {
458
+ if (value === false)
459
+ return "never";
460
+ const node = readNode(value);
461
+ const key = referenceKey(node);
462
+ if (key && seen.has(key))
463
+ return "object (recursive)";
464
+ const next = new Set([...seen, ...key ? [key] : []]);
465
+ const resolved = resolve(value, definitions);
466
+ const union = resolved.anyOf ?? resolved.oneOf;
467
+ if (union) {
468
+ const types = [
469
+ ...new Set(union.map((part) => typeLabel(part, definitions, next)))
470
+ ];
471
+ return types.includes("unknown") ? "unknown" : types.join(" | ");
472
+ }
473
+ if (resolved.enum)
474
+ return resolved.enum.map((entry) => JSON.stringify(entry)).join(" | ");
475
+ if (resolved.const !== undefined)
476
+ return JSON.stringify(resolved.const);
477
+ if (resolved.type && Schema5.is(Schema5.Array(Schema5.String))(resolved.type))
478
+ return resolved.type.join(" | ");
479
+ if (resolved.type === "array")
480
+ return `Array<${typeLabel(resolved.items, definitions, next)}>`;
481
+ if (resolved.type === "object" && resolved.additionalProperties && !resolved.properties) {
482
+ return `Record<string, ${typeLabel(resolved.additionalProperties, definitions, next)}>`;
483
+ }
484
+ const type = resolved.type ?? (resolved.properties ? "object" : "unknown");
485
+ return `${type}${resolved.format ? ` (${resolved.format})` : ""}`;
486
+ };
487
+ var webhookReferenceFields = (schema, definitions, prefix = "") => {
488
+ const fields = [];
489
+ const visit = (value, path, ancestors) => {
490
+ const key = referenceKey(readNode(value));
491
+ if (key && ancestors.has(key))
492
+ return;
493
+ const nodes = variants(value, definitions, new Set(ancestors));
494
+ const next = new Set([
495
+ ...ancestors,
496
+ ...key ? [key] : [],
497
+ ...nodes.flatMap((node) => {
498
+ const ref = referenceKey(node);
499
+ return ref ? [ref] : [];
500
+ })
501
+ ]);
502
+ const objects = nodes.filter((node) => node.properties !== undefined);
503
+ const names = [
504
+ ...new Set(objects.flatMap((node) => Object.keys(node.properties ?? {})))
505
+ ];
506
+ for (const name of names) {
507
+ const members = objects.filter((node) => node.properties?.[name] !== undefined);
508
+ const choices = members.map((node) => node.properties?.[name]);
509
+ const fieldPath = path ? `${path}.${name}` : name;
510
+ const required = members.length < objects.length ? "conditional" : members.every((node) => node.required?.includes(name)) ? "yes" : "no";
511
+ const descriptions = [
512
+ ...new Set(choices.map((choice) => resolve(choice, definitions).description).filter((description) => description !== undefined))
513
+ ];
514
+ fields.push({
515
+ path: fieldPath,
516
+ type: [
517
+ ...new Set(choices.map((choice) => typeLabel(choice, definitions)))
518
+ ].join(" | "),
519
+ required,
520
+ description: descriptions.join(" ")
521
+ });
522
+ visit({ anyOf: choices }, fieldPath, next);
523
+ }
524
+ for (const node of nodes) {
525
+ if (node.items !== undefined)
526
+ visit(node.items, `${path}[]`, next);
527
+ if (node.additionalProperties !== undefined && node.additionalProperties !== true && node.additionalProperties !== false) {
528
+ fields.push({
529
+ path: path ? `${path}.*` : "*",
530
+ type: typeLabel(node.additionalProperties, definitions),
531
+ required: "no",
532
+ description: ""
533
+ });
534
+ visit(node.additionalProperties, path ? `${path}.*` : "*", next);
535
+ }
536
+ }
537
+ };
538
+ visit(schema, prefix, new Set);
539
+ if (fields.length === 0)
540
+ fields.push({
541
+ path: prefix || "$",
542
+ type: typeLabel(schema, definitions),
543
+ required: "yes",
544
+ description: resolve(schema, definitions).description ?? ""
545
+ });
546
+ return fields;
547
+ };
548
+ var cell = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\|/g, "\\|").replace(/[\r\n]+/g, " ").replace(/`/g, "&#96;");
549
+ var code = (value) => {
550
+ const text = value.replace(/\|/g, "\\|").replace(/[\r\n]+/g, " ");
551
+ const fence = "`".repeat(Math.max(1, ...Array.from(text.matchAll(/`+/g), (match) => match[0].length + 1)));
552
+ return fence.length === 1 ? `${fence}${text}${fence}` : `${fence} ${text} ${fence}`;
553
+ };
554
+ var fingerprint = (schema, definitions) => {
555
+ const reachable = new Map;
556
+ const visit = (value) => {
557
+ const node = readNode(value);
558
+ const key = referenceKey(node);
559
+ if (key && !reachable.has(key) && definitions[key] !== undefined) {
560
+ reachable.set(key, definitions[key]);
561
+ visit(definitions[key]);
562
+ }
563
+ for (const child of [
564
+ ...Object.values(node.properties ?? {}),
565
+ ...node.anyOf ?? [],
566
+ ...node.oneOf ?? [],
567
+ ...node.allOf ?? [],
568
+ node.items,
569
+ node.additionalProperties
570
+ ])
571
+ visitChild(child);
572
+ };
573
+ const visitChild = (value) => {
574
+ if (value !== undefined)
575
+ visit(value);
576
+ };
577
+ visit(schema);
578
+ return JSON.stringify([
579
+ schema,
580
+ [...reachable.entries()].sort(([a], [b]) => a.localeCompare(b))
581
+ ]);
582
+ };
583
+ var formatWebhookReference = (locale, events) => {
584
+ const records = events.map((event) => {
585
+ const document2 = Schema5.toJsonSchemaDocument(event.payload);
586
+ const body = resolve(document2.schema, document2.definitions);
587
+ const eventNode = resolve(body.properties?.event, document2.definitions);
588
+ const envelope = Object.keys(body.properties ?? {}).length === 2 && body.required?.includes("event") && body.required.includes("data") && (eventNode.const === event.name || eventNode.enum?.length === 1 && eventNode.enum[0] === event.name);
589
+ return {
590
+ event,
591
+ document: document2,
592
+ schema: envelope ? body.properties?.data ?? document2.schema : document2.schema,
593
+ envelope
594
+ };
595
+ });
596
+ const grouped = new Map;
597
+ for (const record of records) {
598
+ const key = fingerprint(record.schema, record.document.definitions);
599
+ const group = grouped.get(key);
600
+ if (group)
601
+ group.push(record);
602
+ else
603
+ grouped.set(key, [record]);
604
+ }
605
+ const groups = [...grouped.values()];
606
+ const payloadLabel = locale === "fr" ? "Charge utile" : "Payload";
607
+ const summary = records.map((record) => {
608
+ const index = groups.findIndex((group) => group.includes(record)) + 1;
609
+ const anchor = locale === "fr" ? `charge-utile-${index}` : `payload-${index}`;
610
+ return `| ${code(record.event.name)} | ${cell(record.event.description[locale])} | [${payloadLabel} ${index}](#${anchor}) |`;
611
+ });
612
+ const tables = groups.map((group, index) => {
613
+ const record = group[0];
614
+ if (!record)
615
+ return "";
616
+ const fields = webhookReferenceFields(record.schema, record.document.definitions, record.envelope ? "data" : "");
617
+ const hasDescriptions = fields.some((field) => field.description.length > 0);
618
+ const rows = fields.map((field) => `| ${code(field.path)} | ${code(field.type)} | ${locale === "fr" ? { yes: "Oui", no: "Non", conditional: "Selon le cas" }[field.required] : { yes: "Yes", no: "No", conditional: "Conditional" }[field.required]} |${hasDescriptions ? ` ${cell(field.description) || "\u2014"} |` : ""}`);
619
+ const header = locale === "fr" ? "| Champ | Type | Obligatoire |" : "| Field | Type | Required |";
620
+ return `### ${payloadLabel} ${index + 1}
621
+
622
+ ${group.map(({ event }) => code(event.name)).join(", ")}
623
+
624
+ ${header}${hasDescriptions ? " Description |" : ""}
625
+ | --- | --- | --- |${hasDescriptions ? " --- |" : ""}
626
+ ${rows.join(`
627
+ `)}`;
628
+ });
629
+ const envelopeNote = records.every((record) => record.envelope) ? locale === "fr" ? "Le corps contient `event` (le nom de l\u2019\xE9v\xE9nement ci-dessous) et `data` (la charge utile correspondante)." : "The body contains `event` (the event name below) and `data` (the corresponding payload)." : "";
630
+ return `${envelopeNote}
631
+
632
+ ${locale === "fr" ? "| \xC9v\xE9nement | Description | Charge utile |" : "| Event | Description | Payload |"}
633
+ | --- | --- | --- |
634
+ ${summary.join(`
635
+ `)}
636
+
637
+ ${locale === "fr" ? "Les \xE9v\xE9nements partageant la m\xEAme structure sont regroup\xE9s. \xAB Obligatoire \xBB s\u2019applique \xE0 l\u2019objet contenant le champ ; les champs imbriqu\xE9s s\u2019appliquent uniquement si leur parent est pr\xE9sent et non nul. \xAB Selon le cas \xBB indique un champ propre \xE0 une variante. `[]` d\xE9signe un \xE9l\xE9ment de tableau et `*` une cl\xE9 libre." : "Events with the same payload share one reference. Required applies within the containing object; nested fields apply only when their parent is present and non-null. Conditional fields belong to a particular variant. `[]` denotes an array item and `*` an arbitrary key."}
638
+
639
+ ${tables.join(`
640
+
641
+ `)}`;
642
+ };
643
+
644
+ // ../../src/lib/docs.integrations.server.ts
645
+ var krakStackWebhookDocs = {
646
+ verification: {
647
+ en: `The KrakStack Webhooks sender includes \`Content-Type: application/json\`, \`webhook-id\`, \`webhook-timestamp\` (ISO 8601), and \`webhook-signature\` (hex-encoded HMAC-SHA256). These headers are reserved and cannot be overridden by custom headers.
648
+
649
+ Using the endpoint's signing secret, compute the HMAC-SHA256 digest of the exact UTF-8 bytes of:
650
+
651
+ \`\`\`text
652
+ webhook-id + "." + webhook-timestamp + "." + raw_request_body
653
+ \`\`\`
654
+
655
+ Compare it with the decoded signature using a constant-time comparison. Reject invalid or stale timestamps to limit replay attacks. The \`webhook-id\` is the delivery identifier and remains stable across retries; scope your idempotency key to the endpoint. Do not use the timestamp or signature as an idempotency key, since they change for each attempt.
656
+
657
+ The delivered JSON body is \`{ "event": string, "data": object }\`. Ignore additional fields your handler does not use.`,
658
+ fr: `L\u2019\xE9metteur KrakStack Webhooks inclut \`Content-Type: application/json\`, \`webhook-id\`, \`webhook-timestamp\` (ISO 8601) et \`webhook-signature\` (HMAC-SHA256 encod\xE9 en hexad\xE9cimal). Ces en-t\xEAtes sont r\xE9serv\xE9s et ne peuvent pas \xEAtre remplac\xE9s par des en-t\xEAtes personnalis\xE9s.
659
+
660
+ Avec le secret de signature du point de terminaison, calculez le condensat HMAC-SHA256 des octets UTF-8 exacts de :
661
+
662
+ \`\`\`text
663
+ webhook-id + "." + webhook-timestamp + "." + raw_request_body
664
+ \`\`\`
665
+
666
+ Comparez-le \xE0 la signature d\xE9cod\xE9e avec une comparaison en temps constant. Refusez les horodatages invalides ou trop anciens pour limiter les attaques par rejeu. \`webhook-id\` est l\u2019identifiant de livraison et reste stable lors des nouvelles tentatives ; limitez la cl\xE9 d\u2019idempotence au point de terminaison. N\u2019utilisez pas l\u2019horodatage ni la signature comme cl\xE9 d\u2019idempotence, car ils changent \xE0 chaque tentative.
667
+
668
+ Le corps JSON livr\xE9 est \`{ "event": string, "data": object }\`. Ignorez les champs suppl\xE9mentaires inutilis\xE9s.`
669
+ },
670
+ delivery: {
671
+ en: `The KrakStack Webhooks sender treats a \`2xx\` response as success. Each HTTP attempt has a 30-second timeout. Other responses and network errors are retried, up to eight total attempts, with increasing delays. Use \`webhook-id\` to deduplicate retries. Delivery order is not guaranteed. Check the delivery log for errors and pending retries.
672
+
673
+ Disabling an endpoint prevents delivery; pending deliveries processed while it is disabled are marked failed. Completed delivery records become eligible for cleanup after seven days.`,
674
+ fr: `L\u2019\xE9metteur KrakStack Webhooks consid\xE8re une r\xE9ponse \`2xx\` comme un succ\xE8s. Chaque tentative HTTP a un d\xE9lai maximal de 30 secondes. Les autres r\xE9ponses et les erreurs r\xE9seau sont r\xE9essay\xE9es, jusqu\u2019\xE0 huit tentatives au total, avec des d\xE9lais croissants. Utilisez \`webhook-id\` pour d\xE9dupliquer les nouvelles tentatives. L\u2019ordre de livraison n\u2019est pas garanti. Consultez le journal de livraison pour les erreurs et les nouvelles tentatives en attente.
675
+
676
+ La d\xE9sactivation d\u2019un point de terminaison emp\xEAche la livraison ; les livraisons en attente trait\xE9es pendant sa d\xE9sactivation sont marqu\xE9es en \xE9chec. Les livraisons termin\xE9es deviennent admissibles au nettoyage apr\xE8s sept jours.`
677
+ }
678
+ };
679
+ var apiContent = (locale, appName, reference) => locale === "fr" ? {
680
+ title: "API REST",
681
+ description: `Int\xE9grez ${appName} \xE0 vos applications avec l\u2019API REST.`,
682
+ body: `Utilisez l\u2019API REST de ${appName} pour cr\xE9er des int\xE9grations avec vos applications.
683
+
684
+ ## Consulter la r\xE9f\xE9rence
685
+
686
+ Ouvrez la [r\xE9f\xE9rence de l\u2019API](${reference}) pour consulter les op\xE9rations disponibles, les param\xE8tres, les sch\xE9mas et les r\xE9ponses.
687
+
688
+ ## Authentification
689
+
690
+ Suivez les exigences de s\xE9curit\xE9 indiqu\xE9es pour chaque op\xE9ration dans la r\xE9f\xE9rence. Les m\xE9thodes d\u2019authentification et les identifiants disponibles d\xE9pendent de l\u2019application. Ne supposez pas qu\u2019une session de navigateur ou une cl\xE9 d\u2019API est accept\xE9e par toutes les op\xE9rations.
691
+
692
+ Conservez les identifiants c\xF4t\xE9 serveur ou dans un gestionnaire de secrets, jamais dans du code public, une URL ou une conversation avec un assistant.
693
+
694
+ ## Envoyer une premi\xE8re requ\xEAte
695
+
696
+ 1. Choisissez une op\xE9ration de lecture dans la r\xE9f\xE9rence.
697
+ 2. Configurez l\u2019authentification requise avec votre propre compte.
698
+ 3. Utilisez l\u2019URL, la m\xE9thode et les param\xE8tres indiqu\xE9s pour cette op\xE9ration.
699
+ 4. V\xE9rifiez la r\xE9ponse avant d\u2019autoriser des op\xE9rations qui modifient des donn\xE9es.
700
+
701
+ ## Autorisations et erreurs
702
+
703
+ Une int\xE9gration n\u2019accorde pas de droits suppl\xE9mentaires. L\u2019acc\xE8s d\xE9pend du compte, de l\u2019organisation et de l\u2019op\xE9ration.
704
+
705
+ - **401 :** v\xE9rifiez les identifiants et leur expiration.
706
+ - **403 :** v\xE9rifiez les autorisations du compte et l\u2019organisation s\xE9lectionn\xE9e.
707
+ - **429 :** respectez les instructions de nouvelle tentative et l\u2019en-t\xEAte Retry-After, s\u2019il est pr\xE9sent.
708
+
709
+ Consultez la r\xE9f\xE9rence pour les erreurs propres \xE0 chaque op\xE9ration.`
710
+ } : {
711
+ title: "REST API",
712
+ description: `Integrate ${appName} with your applications using the REST API.`,
713
+ body: `Use the ${appName} REST API to build integrations with your applications.
714
+
715
+ ## Open the reference
716
+
717
+ Open the [API reference](${reference}) for available operations, parameters, schemas, and responses.
718
+
719
+ ## Authentication
720
+
721
+ Follow the security requirements documented for each operation in the reference. Available authentication methods and credentials depend on the application. Do not assume a browser session or API key is accepted by every operation.
722
+
723
+ Keep credentials on your server or in a secrets manager, never in public code, a URL, or an assistant conversation.
724
+
725
+ ## Send a first request
726
+
727
+ 1. Choose a read operation in the reference.
728
+ 2. Configure its required authentication using your own account.
729
+ 3. Use the URL, method, and parameters documented for that operation.
730
+ 4. Check the response before allowing operations that change data.
731
+
732
+ ## Permissions and errors
733
+
734
+ An integration does not grant additional permissions. Access depends on the account, organization, and operation.
735
+
736
+ - **401:** check your credentials and their expiry.
737
+ - **403:** check the account permissions and selected organization.
738
+ - **429:** follow retry guidance and the Retry-After header, if present.
739
+
740
+ See the reference for errors specific to each operation.`
741
+ };
742
+ var mcpContent = (locale, appName, url) => locale === "fr" ? {
743
+ title: "MCP",
744
+ description: `Connectez un assistant IA \xE0 ${appName} avec MCP et OAuth.`,
745
+ body: `Connectez votre assistant IA \xE0 ${appName} avec le protocole MCP (Model Context Protocol).
746
+
747
+ ## Connecter votre assistant
748
+
749
+ Vous avez besoin d\u2019un client compatible avec les serveurs MCP distants, Streamable HTTP et OAuth. La disponibilit\xE9 d\xE9pend de votre abonnement et des r\xE8gles de votre espace de travail.
750
+
751
+ Utilisez cette URL de serveur MCP :
752
+
753
+ \`\`\`text
754
+ ${url}
755
+ \`\`\`
756
+
757
+ 1. Dans les param\xE8tres des connecteurs ou serveurs MCP de votre client, ajoutez un serveur distant.
758
+ 2. Nommez-le **${appName}** et collez l\u2019URL compl\xE8te ci-dessus.
759
+ 3. S\xE9lectionnez **Streamable HTTP** et **OAuth** si le client le demande. Ne collez pas de jeton et ne configurez pas d\u2019en-t\xEAtes personnalis\xE9s.
760
+ 4. Connectez-vous avec votre propre compte, v\xE9rifiez les autorisations demand\xE9es et approuvez uniquement les clients de confiance.
761
+ 5. Revenez dans votre client et activez la connexion dans une conversation.
762
+
763
+ Autorisez chaque client s\xE9par\xE9ment. Demandez d\u2019abord \xE0 votre assistant de pr\xE9senter les outils disponibles. V\xE9rifiez les actions propos\xE9es avant d\u2019autoriser une modification de donn\xE9es.
764
+
765
+ ## Autorisations et confidentialit\xE9
766
+
767
+ OAuth n\u2019accorde pas de droits suppl\xE9mentaires \xE0 votre compte. Les outils et les autorisations disponibles d\xE9pendent de l\u2019application et de votre organisation.
768
+
769
+ Les r\xE9sultats des outils sont transmis \xE0 votre fournisseur d\u2019IA. Respectez les r\xE8gles de votre organisation et ne partagez jamais de mots de passe ni de jetons dans une conversation. Pour interrompre l\u2019acc\xE8s, r\xE9voquez l\u2019autorisation dans les param\xE8tres de votre compte, si cette option est disponible, ou contactez votre administrateur. Supprimer le connecteur du client ne r\xE9voque pas n\xE9cessairement les jetons d\xE9j\xE0 \xE9mis.
770
+
771
+ ## D\xE9pannage
772
+
773
+ - **Impossible d\u2019ajouter un serveur :** v\xE9rifiez la compatibilit\xE9 MCP distant avec OAuth et les r\xE8gles de votre espace de travail.
774
+ - **Serveur inaccessible :** utilisez l\u2019URL publique compl\xE8te ci-dessus. Un client h\xE9berg\xE9 ne peut pas joindre une adresse localhost sur votre ordinateur.
775
+ - **Session expir\xE9e :** reconnectez le client depuis ses param\xE8tres.
776
+ - **Acc\xE8s refus\xE9 :** v\xE9rifiez le compte et ses autorisations. Une reconnexion n\u2019accorde pas de droits suppl\xE9mentaires.`
777
+ } : {
778
+ title: "MCP",
779
+ description: `Connect an AI assistant to ${appName} with MCP and OAuth.`,
780
+ body: `Connect your AI assistant to ${appName} using the Model Context Protocol (MCP).
781
+
782
+ ## Connect your assistant
783
+
784
+ You need a client supporting remote MCP servers, Streamable HTTP, and OAuth. Availability depends on your plan and workspace policy.
785
+
786
+ Use this MCP server URL:
787
+
788
+ \`\`\`text
789
+ ${url}
790
+ \`\`\`
791
+
792
+ 1. In your client\u2019s connector or MCP settings, add a remote server.
793
+ 2. Name it **${appName}** and paste the full URL above.
794
+ 3. Select **Streamable HTTP** and **OAuth** if prompted. Do not paste a token or configure custom headers.
795
+ 4. Sign in using your own account, review the requested permissions, and approve only trusted clients.
796
+ 5. Return to your client and enable the connection in a conversation.
797
+
798
+ Authorize each client separately. First ask your assistant to describe the available tools. Review proposed actions before allowing changes to data.
799
+
800
+ ## Permissions and privacy
801
+
802
+ OAuth does not grant more access than your account already has. Available tools and permissions depend on the application and your organization.
803
+
804
+ Tool results are shared with your AI provider. Follow your organization\u2019s policies and never share passwords or tokens in a conversation. To stop access, revoke authorization in your account settings, if available, or contact your administrator. Removing the connector from the client does not necessarily revoke tokens already issued.
805
+
806
+ ## Troubleshooting
807
+
808
+ - **Cannot add a server:** check support for remote MCP with OAuth and your workspace policy.
809
+ - **Cannot reach the server:** use the full public URL above. A cloud-hosted client cannot reach localhost on your computer.
810
+ - **Session expired:** reconnect from your client\u2019s settings.
811
+ - **Access denied:** check the account and its permissions. Reconnecting does not grant additional access.`
812
+ };
813
+ var webhooksContent = (locale, appName, reference) => locale === "fr" ? {
814
+ title: "Webhooks",
815
+ description: `Recevez les \xE9v\xE9nements de ${appName} dans votre application.`,
816
+ body: `Utilisez les webhooks de ${appName} pour recevoir des \xE9v\xE9nements sur un point de terminaison HTTPS que vous contr\xF4lez.
817
+
818
+ ## Configurer un abonnement
819
+
820
+ Demandez \xE0 votre administrateur comment g\xE9rer les abonnements aux webhooks de cette application.
821
+
822
+ 1. Cr\xE9ez un point de terminaison HTTPS public capable de recevoir les requ\xEAtes document\xE9es.
823
+ 2. Enregistrez son URL et s\xE9lectionnez uniquement les \xE9v\xE9nements n\xE9cessaires.
824
+ 3. Si un secret de signature est fourni, conservez-le dans un gestionnaire de secrets, jamais dans du code public ou une URL.
825
+ 4. Utilisez un \xE9v\xE9nement de test, si cette fonction est disponible, et v\xE9rifiez sa r\xE9ception avant de traiter des \xE9v\xE9nements r\xE9els.
826
+
827
+ ## \xC9v\xE9nements et r\xE9f\xE9rence
828
+
829
+ ${reference.events.length > 0 ? formatWebhookReference(locale, reference.events) : "Aucune d\xE9finition d\u2019\xE9v\xE9nement n\u2019a \xE9t\xE9 fournie pour ce guide. Contactez votre administrateur pour obtenir les types d\u2019\xE9v\xE9nements et leurs sch\xE9mas."}
830
+
831
+ Ne supposez pas que toutes les applications utilisent les m\xEAmes noms d\u2019\xE9v\xE9nements, champs, versions ou identifiants de livraison. Validez les donn\xE9es re\xE7ues avec le sch\xE9ma de l\u2019\xE9v\xE9nement avant de les utiliser.
832
+
833
+ ## V\xE9rifier les requ\xEAtes
834
+
835
+ ${reference.verification?.[locale] ?? "Les param\xE8tres de v\xE9rification propres \xE0 cette application n\u2019ont pas \xE9t\xE9 fournis pour ce guide. Obtenez-les aupr\xE8s de votre administrateur avant de traiter des \xE9v\xE9nements."}
836
+
837
+ V\xE9rifiez l\u2019authenticit\xE9 avant de traiter un \xE9v\xE9nement. Utilisez la m\xE9thode de v\xE9rification document\xE9e par l\u2019application ; HTTPS seul ne prouve pas l\u2019identit\xE9 de l\u2019\xE9metteur.
838
+
839
+ Pour les signatures calcul\xE9es sur le corps brut, conservez les octets re\xE7us avant toute analyse JSON. Utilisez les en-t\xEAtes, l\u2019algorithme et le secret document\xE9s, une comparaison en temps constant et les r\xE8gles de validit\xE9 temporelle pr\xE9vues par le protocole. Rejetez les signatures absentes, invalides ou expir\xE9es lorsque la signature est requise. N\u2019inventez pas de noms d\u2019en-t\xEAtes ni d\u2019algorithme.
840
+
841
+ Ne journalisez pas les secrets ni les charges utiles sensibles. Suivez la proc\xE9dure de rotation des secrets propre \xE0 l\u2019application.
842
+
843
+ ## Nouvelles tentatives et doublons
844
+
845
+ ${reference.delivery?.[locale] ?? "Les param\xE8tres de livraison propres \xE0 cette application n\u2019ont pas \xE9t\xE9 fournis pour ce guide. Contactez votre administrateur pour conna\xEEtre la politique de livraison."}
846
+
847
+ Concevez le traitement pour tol\xE9rer les doublons. Utilisez l\u2019identifiant d\u2019\xE9v\xE9nement ou de livraison document\xE9 comme cl\xE9 d\u2019idempotence, dans le p\xE9rim\xE8tre de l\u2019abonnement ou de l\u2019organisation concern\xE9e. Enregistrez durablement l\u2019\xE9tat du traitement et emp\xEAchez les traitements concurrents de r\xE9p\xE9ter les effets de bord.
848
+
849
+ Lorsque le protocole le permet, validez la requ\xEAte puis enregistrez-la durablement ou placez-la dans une file avant de r\xE9pondre avec le statut de succ\xE8s attendu. Ex\xE9cutez les traitements longs en arri\xE8re-plan. N\u2019accusez pas r\xE9ception avant de pouvoir reprendre le traitement apr\xE8s une interruption.
850
+
851
+ Les statuts de succ\xE8s, d\xE9lais, calendriers de nouvelle tentative, dur\xE9es de conservation et possibilit\xE9s de relivraison d\xE9pendent de l\u2019application. Ne supposez ni une livraison exactement une fois ni un ordre de livraison garanti sans engagement explicite dans la r\xE9f\xE9rence.
852
+
853
+ ## D\xE9pannage
854
+
855
+ - **Aucun \xE9v\xE9nement re\xE7u :** v\xE9rifiez l\u2019abonnement, les \xE9v\xE9nements s\xE9lectionn\xE9s et l\u2019accessibilit\xE9 HTTPS du point de terminaison.
856
+ - **Signature invalide :** v\xE9rifiez le secret actif, les en-t\xEAtes document\xE9s, le corps brut et l\u2019horloge de votre serveur si le protocole utilise un horodatage.
857
+ - **Livraison en \xE9chec :** consultez les journaux disponibles et v\xE9rifiez le statut HTTP et le d\xE9lai de r\xE9ponse de votre serveur. Suivez la proc\xE9dure de relivraison de l\u2019application, si elle existe.
858
+ - **Effets r\xE9p\xE9t\xE9s :** v\xE9rifiez la persistance et le p\xE9rim\xE8tre de votre cl\xE9 d\u2019idempotence, y compris lors de traitements concurrents.`
859
+ } : {
860
+ title: "Webhooks",
861
+ description: `Receive ${appName} events in your application.`,
862
+ body: `Use ${appName} webhooks to receive events at an HTTPS endpoint you control.
863
+
864
+ ## Configure a subscription
865
+
866
+ Ask your administrator how to manage webhook subscriptions for this application.
867
+
868
+ 1. Create a public HTTPS endpoint that accepts the documented requests.
869
+ 2. Register its URL and select only the events you need.
870
+ 3. If a signing secret is provided, store it in a secrets manager, never in public code or a URL.
871
+ 4. Use a test event, if available, and verify receipt before processing live events.
872
+
873
+ ## Events and reference
874
+
875
+ ${reference.events.length > 0 ? formatWebhookReference(locale, reference.events) : "No event definitions were supplied for this guide. Contact your administrator for event types and their schemas."}
876
+
877
+ Do not assume every application uses the same event names, fields, versions, or delivery identifiers. Validate incoming data against the event schema before using it.
878
+
879
+ ## Verify requests
880
+
881
+ ${reference.verification?.[locale] ?? "Application-specific verification settings were not supplied for this guide. Obtain them from your administrator before processing events."}
882
+
883
+ Verify authenticity before processing an event. Use the application's documented verification method; HTTPS alone does not prove the sender's identity.
884
+
885
+ For signatures computed over the raw body, preserve the received bytes before parsing JSON. Use the documented headers, algorithm, and secret, a constant-time comparison, and any protocol-defined timestamp validity checks. Reject missing, invalid, or expired signatures when signing is required. Do not invent header names or an algorithm.
886
+
887
+ Do not log secrets or sensitive payloads. Follow the application's secret rotation procedure.
888
+
889
+ ## Retries and duplicates
890
+
891
+ ${reference.delivery?.[locale] ?? "Application-specific delivery settings were not supplied for this guide. Contact your administrator for the delivery policy."}
892
+
893
+ Design processing to tolerate duplicates. Use the documented event or delivery identifier as an idempotency key, scoped to the relevant subscription or organization. Persist processing state durably and prevent concurrent handlers from repeating side effects.
894
+
895
+ Where the protocol allows, validate the request and persist or enqueue it durably before returning the expected success status. Run long tasks in the background. Do not acknowledge receipt before you can resume processing after an interruption.
896
+
897
+ Success statuses, timeouts, retry schedules, retention periods, and redelivery options depend on the application. Do not assume exactly-once delivery or guaranteed ordering unless the reference explicitly promises them.
898
+
899
+ ## Troubleshooting
900
+
901
+ - **No events received:** check the subscription, selected events, and endpoint's public HTTPS accessibility.
902
+ - **Invalid signature:** check the active secret, documented headers, raw body, and your server clock if the protocol uses a timestamp.
903
+ - **Failed delivery:** inspect available delivery logs and check your server's HTTP status and response time. Follow the application's redelivery procedure, if available.
904
+ - **Repeated effects:** check your idempotency key's persistence and scope, including concurrent processing.`
905
+ };
906
+ var createIntegrationDocs = (config) => {
907
+ const basePath = (config.basePath ?? "/docs").replace(/\/$/, "");
908
+ const pages = [];
909
+ for (const locale of config.locales ?? ["en", "fr"]) {
910
+ const add = (slug, order, icon, content) => {
911
+ pages.push({
912
+ slug,
913
+ path: `${basePath}/${slug}`,
914
+ locale,
915
+ order,
916
+ icon,
917
+ section: config.section ?? "integration",
918
+ type: "how-to",
919
+ title: content.title,
920
+ description: content.description,
921
+ sourceFile: `integrations/${locale}/${slug}.mdx`,
922
+ ...compileDocsMarkdown(content.body)
923
+ });
924
+ };
925
+ if (config.api) {
926
+ const reference = new URL(config.api === true ? "/api/docs" : config.api.referenceUrl ?? "/api/docs", config.origin).href;
927
+ add("api-access", config.order ?? 1000, "lucide:braces", apiContent(locale, config.appName, reference));
928
+ }
929
+ if (config.mcp) {
930
+ const url = new URL(config.mcp === true ? "/api/mcp" : config.mcp.url ?? "/api/mcp", config.origin).href;
931
+ add("mcp", (config.order ?? 1000) + 1, "lucide:bot", mcpContent(locale, config.appName, url));
932
+ }
933
+ if (config.webhooks) {
934
+ const settings = config.webhooks === true ? { events: [] } : config.webhooks;
935
+ add("webhooks", (config.order ?? 1000) + 2, "lucide:webhook", webhooksContent(locale, config.appName, settings));
936
+ }
937
+ }
938
+ const local = config.pages ?? [];
939
+ return [
940
+ ...pages.filter((page) => !local.some((override) => override.slug === page.slug && override.locale === page.locale)),
941
+ ...local
942
+ ];
943
+ };
944
+ export {
945
+ createIntegrationDocs,
946
+ krakStackWebhookDocs
947
+ };