@jini-ai/integrations 0.7.3-next.2 → 0.7.3-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/README.md +1 -0
  2. package/dist/api-connections/bundled-client-namespace.d.ts +24 -0
  3. package/dist/api-connections/bundled-client-namespace.js +22 -0
  4. package/dist/api-connections/connect.d.ts +2 -10
  5. package/dist/api-connections/contribution.d.ts +71 -0
  6. package/dist/api-connections/contribution.js +69 -0
  7. package/dist/api-connections/form-delivery-connection.d.ts +68 -0
  8. package/dist/api-connections/form-delivery-connection.js +73 -0
  9. package/dist/api-connections/hosted-mcp/contracts.d.ts +4 -171
  10. package/dist/api-connections/hosted-mcp/index.d.ts +2 -0
  11. package/dist/api-connections/hosted-mcp/oauth-row-writes.d.ts +3 -1
  12. package/dist/api-connections/hosted-mcp/oauth-row-writes.js +6 -3
  13. package/dist/api-connections/hosted-mcp/shared-sign-in.d.ts +2 -1
  14. package/dist/api-connections/hosted-mcp/sign-in-configuration.js +1 -1
  15. package/dist/api-connections/hosted-mcp/sign-in-discovery.js +1 -1
  16. package/dist/api-connections/hosted-mcp/sign-in-flow.d.ts +9 -3
  17. package/dist/api-connections/hosted-mcp/sign-in-flow.js +6 -6
  18. package/dist/api-connections/hosted-mcp/sign-in-provider.d.ts +16 -4
  19. package/dist/api-connections/hosted-mcp/sign-in-provider.js +3 -3
  20. package/dist/api-connections/hosted-mcp/sign-in-status.d.ts +13 -2
  21. package/dist/api-connections/hosted-mcp/sign-in-status.js +17 -4
  22. package/dist/api-connections/hosted-mcp/sign-in.d.ts +1 -1
  23. package/dist/api-connections/hosted-mcp/sign-in.js +28 -30
  24. package/dist/api-connections/shared-api.d.ts +87 -0
  25. package/dist/api-connections/shared-api.js +135 -0
  26. package/dist/api-connections/shared-oauth-disconnect.d.ts +73 -0
  27. package/dist/api-connections/shared-oauth-disconnect.js +41 -0
  28. package/dist/api-connections/shared-owner.d.ts +107 -0
  29. package/dist/api-connections/shared-owner.js +79 -0
  30. package/dist/api-connections/vault-stores.d.ts +110 -0
  31. package/dist/api-connections/vault-stores.js +202 -0
  32. package/dist/credentialed-http/auth-schemes.d.ts +2 -9
  33. package/dist/credentialed-http/tools/index.d.ts +30 -0
  34. package/dist/credentialed-http/tools/index.js +19 -0
  35. package/dist/credentialed-http/tools/tool-registrations.js +0 -1
  36. package/dist/custom-credentials/agent-tools.d.ts +79 -0
  37. package/dist/custom-credentials/agent-tools.js +98 -0
  38. package/dist/custom-credentials/card-token.d.ts +15 -0
  39. package/dist/custom-credentials/card-token.js +35 -0
  40. package/dist/custom-credentials/credential-ports.d.ts +70 -0
  41. package/dist/custom-credentials/credential-ports.js +41 -0
  42. package/dist/custom-credentials/credential-recovery.d.ts +20 -0
  43. package/dist/custom-credentials/credential-recovery.js +22 -0
  44. package/dist/custom-credentials/credentialed-request.d.ts +83 -0
  45. package/dist/custom-credentials/credentialed-request.js +93 -0
  46. package/dist/custom-credentials/custom-credential-create-ui.d.ts +106 -0
  47. package/dist/custom-credentials/custom-credential-create-ui.js +136 -0
  48. package/dist/custom-credentials/custom-credential-set-token-ui.d.ts +84 -0
  49. package/dist/custom-credentials/custom-credential-set-token-ui.js +104 -0
  50. package/dist/custom-credentials/delete-request-confirmation-ui.d.ts +33 -0
  51. package/dist/custom-credentials/delete-request-confirmation-ui.js +35 -0
  52. package/dist/custom-credentials/provider-settings-card.d.ts +109 -0
  53. package/dist/custom-credentials/provider-settings-card.js +166 -0
  54. package/dist/custom-credentials/write-files-validation.d.ts +102 -0
  55. package/dist/custom-credentials/write-files-validation.js +202 -0
  56. package/dist/media-providers/catalog-projection.d.ts +29 -0
  57. package/dist/media-providers/catalog-projection.js +45 -0
  58. package/dist/media-providers/catalog.d.ts +6 -3
  59. package/dist/media-providers/catalog.js +4 -3
  60. package/dist/media-providers/configurable-catalog.d.ts +9 -0
  61. package/dist/media-providers/configurable-catalog.js +70 -0
  62. package/dist/media-providers/dispatch/builtin-vendors.js +0 -2
  63. package/dist/media-providers/dispatch/credentials.d.ts +4 -1
  64. package/dist/media-providers/dispatch/credentials.js +3 -2
  65. package/dist/media-providers/dispatch/engine.d.ts +1 -1
  66. package/dist/media-providers/dispatch/engine.js +17 -5
  67. package/dist/media-providers/dispatch/index.d.ts +3 -2
  68. package/dist/media-providers/dispatch/index.js +2 -2
  69. package/dist/media-providers/dispatch/media-provider-registry.d.ts +23 -4
  70. package/dist/media-providers/dispatch/media-provider-registry.js +26 -11
  71. package/dist/media-providers/dispatch/media-wire.d.ts +14 -0
  72. package/dist/media-providers/dispatch/media-wire.js +22 -0
  73. package/dist/media-providers/dispatch/node.d.ts +5 -0
  74. package/dist/media-providers/dispatch/node.js +5 -1
  75. package/dist/media-providers/dispatch/openai-compatible.d.ts +3 -1
  76. package/dist/media-providers/dispatch/openai-compatible.js +1 -1
  77. package/dist/media-providers/dispatch/operation-runtime.js +5 -4
  78. package/dist/media-providers/dispatch/outbound.d.ts +28 -3
  79. package/dist/media-providers/dispatch/outbound.js +10 -3
  80. package/dist/media-providers/dispatch/providers/custom-image.js +1 -1
  81. package/dist/media-providers/dispatch/providers/imagerouter.js +1 -1
  82. package/dist/media-providers/dispatch/providers/nanobanana.js +1 -1
  83. package/dist/media-providers/dispatch/providers/openrouter.js +1 -1
  84. package/dist/media-providers/dispatch/ssrf-guard.js +2 -2
  85. package/dist/media-providers/dispatch/types.d.ts +13 -4
  86. package/dist/media-providers/dispatch/vendor-adapter.js +2 -2
  87. package/dist/media-providers/index.d.ts +2 -0
  88. package/dist/media-providers/providers.d.ts +9 -5
  89. package/dist/media-providers/providers.js +9 -12
  90. package/dist/media-providers/sqlite-task-store.d.ts +4 -4
  91. package/dist/media-providers/task-store.d.ts +1 -1
  92. package/dist/media-providers/task-store.js +1 -1
  93. package/dist/media-providers/types.d.ts +0 -36
  94. package/dist/media-providers/ui-defaults.js +0 -4
  95. package/dist/react/admin-credentials/AdminByokKeyPanel.d.ts +130 -0
  96. package/dist/react/admin-credentials/AdminByokKeyPanel.js +115 -0
  97. package/dist/react/admin-credentials/byok-footer-status.d.ts +37 -0
  98. package/dist/react/admin-credentials/byok-footer-status.js +25 -0
  99. package/dist/react/credentials/OtherCredentialsSection.d.ts +36 -0
  100. package/dist/react/credentials/OtherCredentialsSection.hooks.d.ts +55 -0
  101. package/dist/react/credentials/OtherCredentialsSection.hooks.js +26 -0
  102. package/dist/react/credentials/OtherCredentialsSection.js +120 -0
  103. package/dist/react/credentials/access-token-forms.d.ts +219 -0
  104. package/dist/react/credentials/access-token-forms.js +114 -0
  105. package/dist/react/credentials/credential-copy.d.ts +17 -0
  106. package/dist/react/credentials/credential-copy.js +7 -0
  107. package/dist/react/credentials/other-credential-stores.d.ts +115 -0
  108. package/dist/react/credentials/other-credential-stores.js +76 -0
  109. package/dist/react/site-key/SiteKeyRecoveryCard.d.ts +16 -0
  110. package/dist/react/site-key/SiteKeyRecoveryCard.js +36 -0
  111. package/dist/react/site-key/SiteKeyTab.d.ts +100 -0
  112. package/dist/react/site-key/SiteKeyTab.js +127 -0
  113. package/dist/react/site-key/hooks/use-site-key-recovery.hooks.d.ts +77 -0
  114. package/dist/react/site-key/hooks/use-site-key-recovery.hooks.js +126 -0
  115. package/dist/react/site-key/hooks/use-site-key.hooks.d.ts +120 -0
  116. package/dist/react/site-key/hooks/use-site-key.hooks.js +95 -0
  117. package/dist/react/webhooks/IntegrationDeliveries.d.ts +41 -0
  118. package/dist/react/webhooks/IntegrationDeliveries.js +24 -0
  119. package/dist/react/webhooks/Integrations.d.ts +73 -0
  120. package/dist/react/webhooks/Integrations.js +97 -0
  121. package/dist/react/webhooks/hooks/use-integration-deliveries.hooks.d.ts +59 -0
  122. package/dist/react/webhooks/hooks/use-integration-deliveries.hooks.js +11 -0
  123. package/dist/react/webhooks/hooks/use-integrations.hooks.d.ts +119 -0
  124. package/dist/react/webhooks/hooks/use-integrations.hooks.js +129 -0
  125. package/dist/react/webhooks/rules.d.ts +118 -0
  126. package/dist/react/webhooks/rules.js +103 -0
  127. package/dist/saved-requests/execute.js +2 -3
  128. package/dist/saved-requests/types.d.ts +4 -1
  129. package/dist/secrets/index.d.ts +3 -0
  130. package/dist/secrets/index.js +3 -0
  131. package/dist/secrets/ports.d.ts +25 -0
  132. package/dist/secrets/ports.js +2 -0
  133. package/dist/secrets/types.d.ts +10 -0
  134. package/dist/secrets/types.js +2 -0
  135. package/dist/vendor-credentials/abort-guarded-repo.d.ts +14 -0
  136. package/dist/vendor-credentials/abort-guarded-repo.js +41 -0
  137. package/dist/vendor-credentials/project-scope.d.ts +43 -0
  138. package/dist/vendor-credentials/project-scope.js +32 -0
  139. package/dist/vendor-credentials/vault-adapter.d.ts +147 -0
  140. package/dist/vendor-credentials/vault-adapter.js +195 -0
  141. package/dist/web-screenshot/capture-files.d.ts +44 -0
  142. package/dist/web-screenshot/capture-files.js +62 -0
  143. package/dist/web-screenshot/capture-retention.d.ts +157 -0
  144. package/dist/web-screenshot/capture-retention.js +134 -0
  145. package/dist/web-screenshot/capture-root-file-lock.d.ts +20 -0
  146. package/dist/web-screenshot/capture-root-file-lock.js +15 -0
  147. package/dist/web-screenshot/desktop-page-capture.d.ts +37 -0
  148. package/dist/web-screenshot/desktop-page-capture.js +62 -0
  149. package/dist/web-screenshot/own-site-opener.d.ts +40 -0
  150. package/dist/web-screenshot/own-site-opener.js +27 -0
  151. package/dist/web-screenshot/screenshot-image.d.ts +11 -0
  152. package/dist/web-screenshot/screenshot-image.js +12 -0
  153. package/dist/web-screenshot/web-screenshot.d.ts +188 -0
  154. package/dist/web-screenshot/web-screenshot.js +329 -0
  155. package/dist/webhooks/delivery.d.ts +16 -0
  156. package/dist/webhooks/delivery.js +41 -1
  157. package/dist/webhooks/ports.d.ts +1 -29
  158. package/dist/webhooks/signing.keyring.d.ts +1 -1
  159. package/dist/webhooks/site/delivery.d.ts +60 -0
  160. package/dist/webhooks/site/delivery.js +45 -0
  161. package/dist/webhooks/site/http.memory.d.ts +51 -0
  162. package/dist/webhooks/site/http.memory.js +28 -0
  163. package/dist/webhooks/site/repo.memory.d.ts +136 -0
  164. package/dist/webhooks/site/repo.memory.js +215 -0
  165. package/dist/webhooks/site/seal-aad-invariant.d.ts +26 -0
  166. package/dist/webhooks/site/seal-aad-invariant.js +61 -0
  167. package/dist/webhooks/site/seal-aad-invariant.node.d.ts +42 -0
  168. package/dist/webhooks/site/seal-aad-invariant.node.js +52 -0
  169. package/dist/webhooks/site/signing.d.ts +28 -0
  170. package/dist/webhooks/site/signing.js +27 -0
  171. package/dist/webhooks/site/signing.keyring.d.ts +29 -0
  172. package/dist/webhooks/site/signing.keyring.js +30 -0
  173. package/dist/webhooks/site/subscriptions.d.ts +118 -0
  174. package/dist/webhooks/site/subscriptions.js +98 -0
  175. package/dist/webhooks/sql/index.d.ts +4 -0
  176. package/dist/webhooks/sql/index.js +2 -0
  177. package/dist/webhooks/sql/repo.rows.d.ts +47 -0
  178. package/dist/webhooks/sql/repo.rows.js +2 -0
  179. package/dist/webhooks/sql/webhook-repo.d.ts +152 -0
  180. package/dist/webhooks/sql/webhook-repo.js +308 -0
  181. package/dist/webhooks/subscriptions.d.ts +3 -1
  182. package/dist/webhooks/subscriptions.js +4 -1
  183. package/dist/webhooks/tools/tool-handlers.js +2 -1
  184. package/dist/webhooks/types.d.ts +6 -10
  185. package/package.json +517 -12
  186. package/dist/media-providers/dispatch/providers/grok.d.ts +0 -55
  187. package/dist/media-providers/dispatch/providers/grok.js +0 -116
@@ -0,0 +1,97 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { agentHandle, buildAgentListHandles } from "@jini-ai/core/agent-handles";
3
+ import { integrationRowMenuItems } from "./rules.js";
4
+ /** The "Add webhook" form — only rendered while `formOpen`. Top-level rather than an inline
5
+ * ternary block in `Integrations`'s own body.
6
+ *
7
+ * Cancel lives here now (2026-09-13, owner: it "floats above the create form" as the header
8
+ * toggle's other label) — next to Create, at the bottom, the pairing every other admin form on
9
+ * this build uses (`Collections.tsx`'s `NewContentTypeDialog`, `FormEditor.tsx`'s field-attrs
10
+ * form). The header toggle above still opens the form and still closes it on click — `onCancel`
11
+ * calls the exact same setter, just from a second, better-placed control — but while the form is
12
+ * open the header button is a redundant "Cancel" with no form context floating over an empty
13
+ * intro line, so `Integrations` below stops rendering it for that state. */
14
+ function IntegrationCreateForm(props) {
15
+ const { locale, translate: t } = props;
16
+ return (_jsxs("form", { onSubmit: props.onSubmit, className: "notice integrations-form form-measure", children: [props.formError ? _jsx("span", { className: "save-error", children: props.formError }) : null, _jsxs("label", { children: [t({ locale: locale, key: "Label" }), _jsx("input", { value: props.label, onChange: (e) => props.onLabelChange(e.target.value), required: true, ...agentHandle({ handle: "integrations-create-label" }, { role: "field", label: "New webhook's label" }) })] }), _jsxs("label", { children: [t({ locale: locale, key: "Target URL" }), _jsx("input", { value: props.targetUrl, onChange: (e) => props.onTargetUrlChange(e.target.value), placeholder: "https://example.com/hooks", required: true, ...agentHandle({ handle: "integrations-create-target-url" }, { role: "field", label: "New webhook's target URL" }) })] }), _jsxs("label", { children: [t({ locale: locale, key: "Topics (comma-separated, e.g. post.published, post.*)" }), _jsx("input", { value: props.topics, onChange: (e) => props.onTopicsChange(e.target.value), required: true, ...agentHandle({ handle: "integrations-create-topics" }, { role: "field", label: "New webhook's comma-separated event topics" }) })] }), _jsxs("span", { className: "editor-actions", children: [_jsx("button", { type: "submit", disabled: props.saving, ...agentHandle({ handle: "integrations-create-submit" }, { role: "button", label: "Create this webhook" }), children: props.saving ? t({ locale: locale, key: "Saving…" }) : t({ locale: locale, key: "Create" }) }), _jsx("button", { type: "button", className: "btn-secondary", onClick: props.onCancel, ...agentHandle({ handle: "integrations-create-cancel" }, { role: "button", label: "Close this form without creating a webhook" }), children: t({ locale: locale, key: "Cancel" }) })] })] }));
17
+ }
18
+ /** The delete-webhook confirm dialog. Stays mounted unconditionally (driven by `open`), matching
19
+ * the `ConfirmDialog` convention `@jini-ai/admin/comments/react`'s `QueuePurgeDialog` also follows. */
20
+ function IntegrationDeleteDialog(props) {
21
+ const { locale, translate: t, kit: { ConfirmDialog }, deleteWebhookBody } = props;
22
+ return (_jsx(ConfirmDialog, { open: props.pendingDelete !== null, agentHandle: "integrations-delete-webhook", title: t({ locale: locale, key: "Delete webhook?" }), body: props.pendingDelete ? deleteWebhookBody({ locale: locale, label: props.pendingDelete.label }) : null, confirmLabel: t({ locale: locale, key: "Delete" }), destructive: true, pending: props.deleting, onConfirm: props.onConfirm, onCancel: props.onCancel }));
23
+ }
24
+ export function Integrations({ useIntegrationsHook, kit, ServerLabel, translate, actionsForWebhookLabel, deleteWebhookBody }) {
25
+ const { subscriptions, error, formOpen, setFormOpen, label, setLabel, targetUrl, setTargetUrl, topics, setTopics, saving, formError, pendingDelete, setPendingDelete, deleting, onCreate, onTogglePause, onDelete, t, locale, } = useIntegrationsHook();
26
+ if (error)
27
+ return _jsx("div", { className: "notice error", children: error });
28
+ if (!subscriptions)
29
+ return _jsx("div", { className: "notice", children: t({ key: "Loading integrations…" }) });
30
+ // Subscription ids are stable and unique, so they disambiguate one row's menu from another's —
31
+ // same reasoning as every other list on this workstream.
32
+ const rowMenuHandles = buildAgentListHandles({ prefix: "integrations-row", ids: subscriptions.map((subscription) => subscription.id) });
33
+ return (_jsxs("div", { className: "integrations-tab-body", children: [renderIntegrationsIntro({ t, formOpen, setFormOpen }), formOpen ? (_jsx(IntegrationCreateForm, { translate: translate, locale: locale, onSubmit: onCreate, onCancel: () => setFormOpen(false), formError: formError, label: label, onLabelChange: setLabel, targetUrl: targetUrl, onTargetUrlChange: setTargetUrl, topics: topics, onTopicsChange: setTopics, saving: saving })) : null, renderIntegrationsTable({ subscriptions, t, rowMenuHandles, locale, onTogglePause, setPendingDelete, kit, ServerLabel, translate, actionsForWebhookLabel }), _jsx(IntegrationDeleteDialog, { translate: translate, kit: kit, deleteWebhookBody: deleteWebhookBody, locale: locale, pendingDelete: pendingDelete, deleting: deleting, onConfirm: onDelete, onCancel: () => setPendingDelete(null) })] }));
34
+ }
35
+ function renderIntegrationsTable({ subscriptions, t, rowMenuHandles, locale, onTogglePause, setPendingDelete, kit, ServerLabel, translate, actionsForWebhookLabel }) {
36
+ const { DataTable } = kit;
37
+ return (_jsx(DataTable, { rows: subscriptions, rowKey: (subscription) => subscription.id, empty: renderIntegrationsEmpty({ t }), columns: [
38
+ {
39
+ key: "label",
40
+ header: t({ key: "Label" }),
41
+ cell: (subscription, index) => renderIntegrationLink({ subscription, rowMenuHandles, index }),
42
+ },
43
+ { key: "target-url", header: t({ key: "Target URL" }), cell: (subscription) => subscription.targetUrl },
44
+ {
45
+ key: "status",
46
+ header: t({ key: "Status" }),
47
+ cell: (subscription) => (_jsx("span", { className: `status status-sub-${subscription.status}`, children: _jsx(ServerLabel, { value: subscription.status }) })),
48
+ },
49
+ {
50
+ key: "last-delivery",
51
+ header: t({ key: "Last delivery" }),
52
+ cell: (subscription) => subscription.lastDelivery ? (_jsx("span", { className: `status status-delivery-${subscription.lastDelivery.status}`, children: _jsx(ServerLabel, { value: subscription.lastDelivery.status }) })) : (_jsx("span", { className: "muted-cell", children: t({ key: "never" }) })),
53
+ },
54
+ {
55
+ key: "actions",
56
+ headerLabel: t({ key: "Actions" }),
57
+ cell: (subscription, index) => renderIntegrationActions({ subscription, locale, rowMenuHandles, index, onTogglePause, setPendingDelete, kit, translate, actionsForWebhookLabel }),
58
+ },
59
+ ] }));
60
+ }
61
+ function renderIntegrationsEmpty({ t }) {
62
+ return (
63
+ // `form-measure` (2026-09-13, owner: this text read off-center and clipped): the card had
64
+ // no width of its own, so on a wide viewport it stretched edge to edge and centered its
65
+ // two sentences around the middle of that whole span instead of around a column a reader
66
+ // could actually see at once. Same cap the create form right above it already uses, so
67
+ // the empty state now reads as that form's own column, just without any webhooks in it.
68
+ //
69
+ // Reopened same day (owner: "sure as hell doesn't look fixed"): `page-description` on the
70
+ // second line was carrying the raw UA `<p>` margin (1em, unscoped — that class only gets
71
+ // rules under `.page-header`, so a bare use here got nothing) on top of `.empty-state`'s
72
+ // own flex gap, which is what put visible daylight between the two lines. `empty-state-
73
+ // title`/`empty-state-hint` below zero that out and give the two lines the hierarchy every
74
+ // other `.empty-state` on this admin gets for free by only ever having ONE line.
75
+ _jsx("div", { className: "card form-measure", children: _jsxs("div", { className: "empty-state", children: [_jsx("p", { className: "empty-state-title", children: t({ key: "No webhooks yet." }) }), _jsx("p", { className: "empty-state-hint", children: t({ key: "Add one above to start sending event notifications." }) })] }) }));
76
+ }
77
+ function renderIntegrationLink({ subscription, rowMenuHandles, index }) {
78
+ return (_jsx("a", { href: `/admin/addons/integrations/${subscription.id}`, ...agentHandle({ handle: `${rowMenuHandles[index]}-label` }, { role: "link", label: `Open the "${subscription.label}" webhook's deliveries` }), children: subscription.label }));
79
+ }
80
+ function renderIntegrationActions({ subscription, locale, rowMenuHandles, index, onTogglePause, setPendingDelete, kit, translate, actionsForWebhookLabel }) {
81
+ const { RowMenu } = kit;
82
+ return (subscription.status === "disabled" ? (
83
+ // `disabled` on both old inline buttons for a `status === "disabled"` row — a
84
+ // built-in-row-style "nothing to do here" case, `RowMenu` has no equivalent
85
+ // per-item `disabled`, so the whole trigger is withheld instead, matching
86
+ // `Roles.tsx`'s built-in-row `—` idiom rather than an unusably empty dropdown.
87
+ _jsx("span", { className: "muted-cell", children: "\u2014" })) : (_jsx(RowMenu, { triggerLabel: actionsForWebhookLabel({ locale: locale, label: subscription.label }), agentHandle: `${rowMenuHandles[index]}-menu`, items: integrationRowMenuItems({ subscription: subscription,
88
+ handlers: {
89
+ onTogglePause,
90
+ onDelete: setPendingDelete,
91
+ },
92
+ locale: locale, translate }) })));
93
+ }
94
+ function renderIntegrationsIntro({ t, formOpen, setFormOpen }) {
95
+ return (_jsxs("div", { className: "integrations-tab-intro form-measure", children: [_jsx("p", { className: "page-description", children: t({ key: "Send webhook notifications to external services when content on this site changes." }) }), formOpen ? null : (_jsx("div", { className: "page-actions", children: _jsx("button", { onClick: () => setFormOpen(true), ...agentHandle({ handle: "integrations-toggle-create-form" }, { role: "button", label: "Open the add-webhook form" }), children: t({ key: "Add webhook" }) }) }))] }));
96
+ }
97
+ //# sourceMappingURL=Integrations.js.map
@@ -0,0 +1,59 @@
1
+ import type { AdminWebhookDeliveryResponse } from "@jini-ai/core/contracts/site/cms-integrations";
2
+ import type { FetchQueryAdapter } from "@jini-ai/core/fetch";
3
+ type Empty = Record<string, never>;
4
+ export interface IntegrationDeliveriesPort {
5
+ listIntegrationDeliveries(required: {
6
+ subscriptionId: string;
7
+ }, optional?: Record<string, never>): Promise<{
8
+ deliveries: AdminWebhookDeliveryResponse[];
9
+ }>;
10
+ }
11
+ /**
12
+ * @file Everything the delivery-log screen does, so `IntegrationDeliveries.tsx` is only markup.
13
+ *
14
+ * Extracted verbatim — same error strings. A second hook file rather than folding into
15
+ * `use-integrations.hooks.ts`: `IntegrationDeliveries` is a distinct component with its own
16
+ * lifecycle (re-fetches whenever `subscriptionId` changes), per this feature's "one hook file per
17
+ * component" convention.
18
+ *
19
+ * `port` is injected — see `integration-deliveries-port.hooks.ts` — rather than importing
20
+ * `lib/api` directly, so a test can describe a subscription's delivery log against
21
+ * `createFakeIntegrationDeliveriesPort` instead of stubbing global `fetch`.
22
+ * The host `useWiredIntegrationDeliveries` binds the port and translator for the subscription
23
+ * that `IntegrationDeliveries.tsx` mounts.
24
+ *
25
+ * `t` (2026-08-11, standing i18n rule — see `use-integrations.hooks.ts`'s own file header for the
26
+ * full rationale): injected in the required arguments. UNLIKE `useIntegrations`, no raw
27
+ * `locale` is threaded — `IntegrationDeliveries.tsx` calls `t({ key })` bound-style,
28
+ * it never passes `locale` to a helper that needs it directly.
29
+ *
30
+ * `@jini-ai/ui/fetch-query` migration (2026-08-12): the load is one `useFetchQuery` keyed on
31
+ * `KEYS.deliveries({ subscriptionId })` — a query cannot commit a response belonging to a prior key,
32
+ * which eliminates the load race an external audit flagged at this file's old line 46 (a plain
33
+ * `.then()`/`.catch()` effect with no cancellation guard, so a `subscriptionId` change mid-flight
34
+ * could commit a stale response) by construction.
35
+ */
36
+ export interface IntegrationDeliveriesController {
37
+ deliveries: AdminWebhookDeliveryResponse[] | null;
38
+ error: string | null;
39
+ /** Bound translator — `key` already resolved against the caller's locale, so
40
+ * `IntegrationDeliveries.tsx` never imports `useAdminLocale`/`integrations-i18n` itself. See
41
+ * this file's header. */
42
+ t: (required: {
43
+ key: string;
44
+ }, optional?: Record<string, never>) => string;
45
+ }
46
+ export declare function useIntegrationDeliveries({ subscriptionId, port, t, queryHooks: { useFetchQuery }, describeApiError }: {
47
+ subscriptionId: string;
48
+ port: IntegrationDeliveriesPort;
49
+ queryHooks: Pick<FetchQueryAdapter, "useFetchQuery">;
50
+ describeApiError: (required: {
51
+ e: unknown;
52
+ fallback: string;
53
+ }, options?: Empty) => string;
54
+ t: (required: {
55
+ key: string;
56
+ }, optional?: Record<string, never>) => string;
57
+ }, _optional?: {}): IntegrationDeliveriesController;
58
+ export {};
59
+ //# sourceMappingURL=use-integration-deliveries.hooks.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { KEYS } from "../rules.js";
2
+ export function useIntegrationDeliveries({ subscriptionId, port, t, queryHooks: { useFetchQuery }, describeApiError }, _optional = {}) {
3
+ const list = useFetchQuery({
4
+ key: KEYS.deliveries({ subscriptionId }),
5
+ fetch: () => port.listIntegrationDeliveries({ subscriptionId }),
6
+ });
7
+ const deliveries = list.data?.deliveries ?? null;
8
+ const error = list.error ? describeApiError({ e: list.error, fallback: "failed to load deliveries" }) : null;
9
+ return { deliveries, error, t };
10
+ }
11
+ //# sourceMappingURL=use-integration-deliveries.hooks.js.map
@@ -0,0 +1,119 @@
1
+ import type { AdminWebhookSubscriptionResponse } from "@jini-ai/core/contracts/site/cms-integrations";
2
+ import type { FetchQueryAdapter } from "@jini-ai/core/fetch";
3
+ type Empty = Record<string, never>;
4
+ export interface IntegrationsPort {
5
+ listIntegrationSubscriptions(): Promise<{
6
+ subscriptions: AdminWebhookSubscriptionResponse[];
7
+ }>;
8
+ createIntegrationSubscription(input: {
9
+ label: string;
10
+ targetUrl: string;
11
+ topics: string[];
12
+ }, optional?: Record<string, never>): Promise<{
13
+ subscription: AdminWebhookSubscriptionResponse;
14
+ }>;
15
+ pauseIntegrationSubscription(target: {
16
+ id: string;
17
+ paused: boolean;
18
+ }): Promise<{
19
+ subscription: AdminWebhookSubscriptionResponse;
20
+ }>;
21
+ deleteIntegrationSubscription(required: {
22
+ id: string;
23
+ }, optional?: Record<string, never>): Promise<{
24
+ subscription: AdminWebhookSubscriptionResponse;
25
+ }>;
26
+ }
27
+ /**
28
+ * @file Everything the Integrations LIST screen does, so `Integrations.tsx` is only markup.
29
+ *
30
+ * Extracted verbatim — same state, same order, same effect, same error strings. Naming follows
31
+ * `hooks/use-settings-slice.hooks.ts` and `features/posts/hooks/use-posts.hooks.ts`:
32
+ * `use-<thing>.hooks.ts`. Feature-local because nothing outside `features/integrations` needs it.
33
+ *
34
+ * `port` is injected — see `integrations-port.hooks.ts` — rather than importing `lib/api`
35
+ * directly, so a test can describe list/write outcomes against `createFakeIntegrationsPort`
36
+ * instead of stubbing global `fetch`. The host `useWiredIntegrations` binding is the zero-argument pair
37
+ * `Integrations.tsx` actually mounts.
38
+ *
39
+ * `t`/`locale` (2026-08-11, standing i18n rule — a component with a hook gets a BOUND `t` from
40
+ * that hook, not its own `useAdminLocale()`/dictionary import): injected as required arguments.
41
+ * Unlike `use-analytics.hooks.ts`'s `t`-only case, `locale` is ALSO threaded
42
+ * through here — `Integrations.tsx` passes raw `locale` (not just `t`) into `integrationRowMenuItems`
43
+ * (`rules.ts`) and `actionsForWebhookLabel`/`deleteWebhookBody` (`integrations-i18n.tsx`), all three
44
+ * of which take `locale` directly rather than a bound translator, so the component still
45
+ * needs the raw value — see `wired-hooks-convention.md`'s own "locale only where genuinely needed"
46
+ * phrasing. `useIntegrations` itself never calls `t`/reads `locale` internally — both exist solely
47
+ * to hand through to the component, same as the port.
48
+ *
49
+ * `@jini-ai/ui/fetch-query` migration (2026-08-12): the list read is `useFetchQuery({ key: KEYS.list, ...
50
+ * })`; `create`/`togglePause`/`delete` are three independent `useFetchMutation`s that each
51
+ * `invalidates: [KEYS.list]` — same three-independent-writes shape `Jini packages/admin/src/redirects/react/hooks/use-
52
+ * redirects.hooks.ts` (the pilot) established. `formError` (the create form's own inline error) is
53
+ * a direct read of `createMutation.error` — it needs no `clearOtherWriteErrors` treatment since it
54
+ * has no sibling on that channel and a mutation's own `.error` clears itself the next time `mutate`
55
+ * is called. `error` (the page-level banner) DOES need it, mirroring `Jini redirects/SOURCE-RATIONALE.md`'s
56
+ * `clearOtherWriteErrors`: toggle/delete are two independent mutations sharing that one channel, so
57
+ * a stale failure from one must not survive past the start of the other.
58
+ *
59
+ * `useContentRefreshSubscription` (staleness-bug generalization pass — see that hook's own header):
60
+ * re-invalidates `KEYS.list` on an out-of-band content-refresh notification — today an assistant
61
+ * run that called `webhooks_create_subscription`/`webhooks_pause_subscription`/
62
+ * `webhooks_delete_subscription` (the host's `features/webhooks/agent-tools.ts`) — the same
63
+ * one-line adoption `use-media.hooks.ts` uses. The create form's `label`/`targetUrl`/`topics` local
64
+ * state is untouched by an invalidate (it only replaces `list.data`), so an in-progress "new
65
+ * subscription" draft survives a background refresh.
66
+ */
67
+ export interface IntegrationsController {
68
+ subscriptions: AdminWebhookSubscriptionResponse[] | null;
69
+ error: string | null;
70
+ formOpen: boolean;
71
+ setFormOpen: (open: boolean | ((prev: boolean) => boolean)) => void;
72
+ label: string;
73
+ setLabel: (label: string) => void;
74
+ targetUrl: string;
75
+ setTargetUrl: (targetUrl: string) => void;
76
+ topics: string;
77
+ setTopics: (topics: string) => void;
78
+ saving: boolean;
79
+ formError: string | null;
80
+ /** The subscription a `RowMenu` "Delete" selection is asking to confirm; `null` when the dialog
81
+ * is shut. */
82
+ pendingDelete: AdminWebhookSubscriptionResponse | null;
83
+ setPendingDelete: (subscription: AdminWebhookSubscriptionResponse | null) => void;
84
+ deleting: boolean;
85
+ onCreate: (e: React.FormEvent) => Promise<void>;
86
+ onTogglePause: (subscription: AdminWebhookSubscriptionResponse) => Promise<void>;
87
+ onDelete: () => Promise<void>;
88
+ /** Bound translator — `key` already resolved against the caller's locale, so `Integrations.tsx`
89
+ * never imports `useAdminLocale`/`integrations-i18n` itself. See this file's header. */
90
+ t: (required: {
91
+ key: string;
92
+ }, optional?: Record<string, never>) => string;
93
+ /** Raw resolved locale — needed alongside `t` because `rules.ts`/`integrations-i18n.tsx` expose
94
+ * a few helpers that take `(locale, ...)` directly rather than a bound translator. See this
95
+ * file's header. */
96
+ locale: string;
97
+ }
98
+ export declare function useIntegrations({ port, t, locale, queryHooks, useContentRefreshSubscriptionHook, describeApiError, translate }: {
99
+ port: IntegrationsPort;
100
+ queryHooks: Pick<FetchQueryAdapter, "useFetchQuery" | "useFetchMutation" | "useInvalidate">;
101
+ useContentRefreshSubscriptionHook: (required: {
102
+ resource: string;
103
+ onRefresh: () => void;
104
+ }, options?: Empty) => void;
105
+ describeApiError: (required: {
106
+ e: unknown;
107
+ fallback: string;
108
+ }, options?: Empty) => string;
109
+ translate: (required: {
110
+ locale: string;
111
+ key: string;
112
+ }, options?: Empty) => string;
113
+ t: (required: {
114
+ key: string;
115
+ }, optional?: Record<string, never>) => string;
116
+ locale: string;
117
+ }, _optional?: {}): IntegrationsController;
118
+ export {};
119
+ //# sourceMappingURL=use-integrations.hooks.d.ts.map
@@ -0,0 +1,129 @@
1
+ import { useCallback, useState } from "react";
2
+ import { KEYS, WEBHOOKS_RESOURCE, parseTopics, visibleIntegrationsError } from "../rules.js";
3
+ export function useIntegrations({ port, t, locale, queryHooks, useContentRefreshSubscriptionHook, describeApiError, translate }, _optional = {}) {
4
+ const { list, formOpen, setFormOpen, label, setLabel, targetUrl, setTargetUrl, topics, setTopics, pendingDelete, setPendingDelete, createMutation, toggleMutation, deleteMutation, } = useIntegrationsState({ port, queryHooks, useContentRefreshSubscriptionHook });
5
+ const { onCreate, onTogglePause, onDelete } = createIntegrationActions({
6
+ toggleMutation, deleteMutation, createMutation, label, targetUrl, topics, setLabel, setTargetUrl, setTopics, setFormOpen, pendingDelete, setPendingDelete,
7
+ });
8
+ const subscriptions = list.data?.subscriptions ?? null;
9
+ const formError = createMutation.error ? describeApiError({ e: createMutation.error, fallback: "failed to create subscription" }) : null;
10
+ const error = visibleIntegrationsError({
11
+ toggleError: toggleMutation.error,
12
+ deleteError: deleteMutation.error,
13
+ listError: list.error,
14
+ hasSubscriptions: subscriptions !== null,
15
+ locale,
16
+ translate,
17
+ describeApiError,
18
+ });
19
+ return {
20
+ subscriptions,
21
+ error,
22
+ formOpen,
23
+ setFormOpen,
24
+ label,
25
+ setLabel,
26
+ targetUrl,
27
+ setTargetUrl,
28
+ topics,
29
+ setTopics,
30
+ saving: createMutation.status === "pending",
31
+ formError,
32
+ pendingDelete,
33
+ setPendingDelete,
34
+ deleting: deleteMutation.status === "pending",
35
+ onCreate,
36
+ onTogglePause,
37
+ onDelete,
38
+ t,
39
+ locale,
40
+ };
41
+ }
42
+ function createIntegrationActions({ toggleMutation, deleteMutation, createMutation, label, targetUrl, topics, setLabel, setTargetUrl, setTopics, setFormOpen, pendingDelete, setPendingDelete }) {
43
+ // Only toggle/delete share the page-level `error` banner below — see this file's own header for
44
+ // why `createMutation`'s failure has no sibling to clear here (it drives `formError` alone).
45
+ function clearOtherPageErrors(active) {
46
+ for (const write of [toggleMutation, deleteMutation])
47
+ if (write !== active)
48
+ write.reset();
49
+ }
50
+ async function onCreate(e) {
51
+ e.preventDefault();
52
+ try {
53
+ await createMutation.mutate({ input: { label, targetUrl, topics: parseTopics({ raw: topics }) } });
54
+ setLabel("");
55
+ setTargetUrl("");
56
+ setTopics("");
57
+ setFormOpen(false);
58
+ }
59
+ catch {
60
+ // already surfaced through createMutation.error -> formError below
61
+ }
62
+ }
63
+ async function onTogglePause(subscription) {
64
+ clearOtherPageErrors(toggleMutation);
65
+ try {
66
+ await toggleMutation.mutate({ input: subscription });
67
+ }
68
+ catch {
69
+ // already surfaced through toggleMutation.error -> error below
70
+ }
71
+ }
72
+ /** Confirmation now gates via a `ConfirmDialog` modal, reached through `RowMenu`'s "Delete" item
73
+ * (`setPendingDelete` below), rather than `window.confirm` — see `Roles.tsx`'s `onDeleteRole`
74
+ * comment for why a `RowMenu` item needs `ConfirmDialog`, not a blocking browser prompt, to hold
75
+ * the confirm step. Copy is the exact previous sentence, unchanged. */
76
+ async function onDelete() {
77
+ if (!pendingDelete)
78
+ return;
79
+ const subscription = pendingDelete;
80
+ clearOtherPageErrors(deleteMutation);
81
+ try {
82
+ await deleteMutation.mutate({ input: subscription.id });
83
+ }
84
+ catch {
85
+ // already surfaced through deleteMutation.error -> error below
86
+ }
87
+ finally {
88
+ setPendingDelete(null);
89
+ }
90
+ }
91
+ return { onCreate, onTogglePause, onDelete };
92
+ }
93
+ function useIntegrationsState({ port, queryHooks: { useFetchQuery, useFetchMutation, useInvalidate }, useContentRefreshSubscriptionHook }) {
94
+ const list = useFetchQuery({ key: KEYS.list, fetch: () => port.listIntegrationSubscriptions() });
95
+ // Stable identity (not an inline arrow) so `useContentRefreshSubscription`'s own effect does not
96
+ // unsubscribe/resubscribe on every render — see `use-media.hooks.ts`'s identical `invalidateList`
97
+ // note.
98
+ const invalidate = useInvalidate();
99
+ const invalidateList = useCallback(() => invalidate({ key: KEYS.list }), [invalidate]);
100
+ useContentRefreshSubscriptionHook({ resource: WEBHOOKS_RESOURCE, onRefresh: invalidateList });
101
+ const [formOpen, setFormOpen] = useState(false);
102
+ const [label, setLabel] = useState("");
103
+ const [targetUrl, setTargetUrl] = useState("");
104
+ const [topics, setTopics] = useState("");
105
+ // The subscription a `RowMenu` "Delete" selection is asking to confirm — `null` when the dialog
106
+ // is closed. `ConfirmDialog` stays mounted unconditionally in the view (see its own doc comment
107
+ // on why); this is what drives its `open` prop.
108
+ const [pendingDelete, setPendingDelete] = useState(null);
109
+ const createMutation = useFetchMutation({
110
+ run: ({ input }) => port.createIntegrationSubscription(input),
111
+ }, {
112
+ invalidates: [KEYS.list],
113
+ });
114
+ const toggleMutation = useFetchMutation({
115
+ run: ({ input: subscription }) => port.pauseIntegrationSubscription({ id: subscription.id, paused: subscription.status !== "paused" }),
116
+ }, {
117
+ invalidates: [KEYS.list],
118
+ });
119
+ const deleteMutation = useFetchMutation({
120
+ run: ({ input: id }) => port.deleteIntegrationSubscription({ id }),
121
+ }, {
122
+ invalidates: [KEYS.list],
123
+ });
124
+ return {
125
+ list, formOpen, setFormOpen, label, setLabel, targetUrl, setTargetUrl, topics, setTopics, pendingDelete, setPendingDelete, createMutation, toggleMutation,
126
+ deleteMutation,
127
+ };
128
+ }
129
+ //# sourceMappingURL=use-integrations.hooks.js.map
@@ -0,0 +1,118 @@
1
+ import type { AdminWebhookDeliveryResponse, AdminWebhookSubscriptionResponse } from "@jini-ai/core/contracts/site/cms-integrations";
2
+ import type { QueryKey } from "@jini-ai/core/fetch";
3
+ type Empty = Record<string, never>;
4
+ /**
5
+ * @file Pure logic for the `integrations` feature — everything that computes a value rather than
6
+ * rendering one.
7
+ *
8
+ * Follows the same convention `features/posts/rules.ts` establishes for this app: the bar for
9
+ * landing here is "does it compute something", not "is it rendered". The row-action menu below
10
+ * used to be an array literal built inline inside a `DataTable` cell — logic reachable only by
11
+ * rendering a table and opening a popover, which is how its `status === "paused"` label branch
12
+ * ended up untested.
13
+ *
14
+ * `KEYS` (fetch-query migration, 2026-08-12): two entirely separate top-level namespaces, not a
15
+ * shared grandparent — `use-integration-deliveries.hooks.ts`'s delivery log is a distinct,
16
+ * read-only sub-resource with no method overlap with subscription CRUD (same split
17
+ * `integrations-port.hooks.ts` already makes with its own two ports), and no subscription write
18
+ * (create/pause/delete) needs to invalidate a delivery log. Same "separate namespaces, no shared
19
+ * prefix" shape `@jini-ai/admin/forms` rules.ts's `KEYS` uses for `forms` vs `form-submissions`.
20
+ */
21
+ export declare const KEYS: {
22
+ list: QueryKey;
23
+ deliveries: ({ subscriptionId }: {
24
+ subscriptionId: string;
25
+ }, _optional?: {}) => QueryKey;
26
+ };
27
+ /** This screen's name on `lib/content-refresh-bus.ts` — see `taxonomy/rules.ts`'s
28
+ * `TAXONOMY_RESOURCE` for why this is a plain colocated constant rather than a shared registry.
29
+ * Agent-writable via `webhooks_create_subscription`/`webhooks_pause_subscription`/
30
+ * `webhooks_delete_subscription` (the host's `features/webhooks/agent-tools.ts` — the
31
+ * website domain is named "webhooks", this admin feature is named "integrations"; both name the
32
+ * same `WebhookSubscriptionRecord` resource). No sibling constant for the deliveries log
33
+ * (`use-integration-deliveries.hooks.ts`): no Webhooks agent tool writes a delivery row — deliveries
34
+ * are recorded only by the outbound delivery worker itself, which nothing in this catalog drives. */
35
+ export declare const WEBHOOKS_RESOURCE = "webhooks";
36
+ /** Parses the comma-separated topics field into a trimmed, blank-free list.
37
+ *
38
+ * @complexity Time: O(n) in the length of `raw`; space: O(k) for the k resulting topics.
39
+ * @overallScore 100
40
+ */
41
+ export declare function parseTopics({ raw }: {
42
+ raw: string;
43
+ }, _optional?: {}): string[];
44
+ /** The callbacks a webhook subscription's row menu needs. Passed in rather than imported so this
45
+ * module stays free of state and navigation, and so a test can assert exactly which one a given
46
+ * row wires up — same shape as `posts/rules.ts`'s `PostRowMenuHandlers`. */
47
+ export interface IntegrationRowMenuHandlers {
48
+ onTogglePause: (subscription: AdminWebhookSubscriptionResponse) => void;
49
+ onDelete: (subscription: AdminWebhookSubscriptionResponse) => void;
50
+ }
51
+ /**
52
+ * The row-action menu for one webhook subscription.
53
+ *
54
+ * The branch is the reason this is exported: the "Pause"/"Resume" label depends on
55
+ * `subscription.status`, and that was previously only reachable by rendering the table and
56
+ * opening the menu. "Delete" is marked `destructive` and only OPENS the confirmation; the delete
57
+ * itself is `useIntegrations().onDelete`, gated on `ConfirmDialog`.
58
+ *
59
+ * Withholding the menu entirely for a `disabled` subscription (rendering `—` instead) stays in
60
+ * `Integrations.tsx` — that decision is made before this function is ever called, not inside it.
61
+ *
62
+ * @complexity Time/space: O(1) — exactly two entries, no iteration.
63
+ * @overallScore 100
64
+ */
65
+ export declare function integrationRowMenuItems({ subscription, handlers, locale, translate: t }: {
66
+ subscription: AdminWebhookSubscriptionResponse;
67
+ handlers: IntegrationRowMenuHandlers;
68
+ locale: string;
69
+ translate: (required: {
70
+ locale: string;
71
+ key: string;
72
+ }, options?: Empty) => string;
73
+ }, _optional?: {}): {
74
+ key: string;
75
+ label: string;
76
+ onSelect: () => void;
77
+ destructive?: boolean;
78
+ }[];
79
+ /** Best available timestamp for the delivery log's "Timestamp" column: delivered time, else
80
+ * created time.
81
+ *
82
+ * @complexity Time/space: O(1).
83
+ * @overallScore 100
84
+ */
85
+ export declare function displayTimestamp({ delivery, viewerTimeZone }: {
86
+ delivery: AdminWebhookDeliveryResponse;
87
+ viewerTimeZone: string;
88
+ }, _optional?: Empty): string;
89
+ /**
90
+ * `useIntegrations`'s page-level error banner — deliberately excludes the CREATE write's own
91
+ * failure, which shows inside the create form itself (`formError`, derived directly from
92
+ * `createMutation.error` in the hook) rather than this page-level channel, matching the
93
+ * pre-migration `onCreate`/`onTogglePause`/`onDelete` catch blocks' own separate `setFormError`
94
+ * vs `setError` split.
95
+ *
96
+ * Precedence: an active toggle/delete failure outranks a background list-refresh failure, same
97
+ * shape as `Jini redirects/rules.ts`'s `visibleRedirectsError`. The list error only surfaces before
98
+ * `subscriptions` has ever loaded.
99
+ *
100
+ * @complexity Time/space: O(1) — three fixed checks, no iteration.
101
+ */
102
+ export declare function visibleIntegrationsError(params: {
103
+ toggleError: Error | null;
104
+ deleteError: Error | null;
105
+ listError: Error | null;
106
+ hasSubscriptions: boolean;
107
+ locale: string;
108
+ translate: (required: {
109
+ locale: string;
110
+ key: string;
111
+ }, options?: Empty) => string;
112
+ describeApiError: (required: {
113
+ e: unknown;
114
+ fallback: string;
115
+ }, options?: Empty) => string;
116
+ }, _optional?: Empty): string | null;
117
+ export {};
118
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1,103 @@
1
+ import { formatTimestamp } from "@jini-ai/core/text";
2
+ /**
3
+ * @file Pure logic for the `integrations` feature — everything that computes a value rather than
4
+ * rendering one.
5
+ *
6
+ * Follows the same convention `features/posts/rules.ts` establishes for this app: the bar for
7
+ * landing here is "does it compute something", not "is it rendered". The row-action menu below
8
+ * used to be an array literal built inline inside a `DataTable` cell — logic reachable only by
9
+ * rendering a table and opening a popover, which is how its `status === "paused"` label branch
10
+ * ended up untested.
11
+ *
12
+ * `KEYS` (fetch-query migration, 2026-08-12): two entirely separate top-level namespaces, not a
13
+ * shared grandparent — `use-integration-deliveries.hooks.ts`'s delivery log is a distinct,
14
+ * read-only sub-resource with no method overlap with subscription CRUD (same split
15
+ * `integrations-port.hooks.ts` already makes with its own two ports), and no subscription write
16
+ * (create/pause/delete) needs to invalidate a delivery log. Same "separate namespaces, no shared
17
+ * prefix" shape `@jini-ai/admin/forms` rules.ts's `KEYS` uses for `forms` vs `form-submissions`.
18
+ */
19
+ export const KEYS = {
20
+ list: ["integrations", "list"],
21
+ deliveries: ({ subscriptionId }, _optional = {}) => ["integration-deliveries", subscriptionId],
22
+ };
23
+ /** This screen's name on `lib/content-refresh-bus.ts` — see `taxonomy/rules.ts`'s
24
+ * `TAXONOMY_RESOURCE` for why this is a plain colocated constant rather than a shared registry.
25
+ * Agent-writable via `webhooks_create_subscription`/`webhooks_pause_subscription`/
26
+ * `webhooks_delete_subscription` (the host's `features/webhooks/agent-tools.ts` — the
27
+ * website domain is named "webhooks", this admin feature is named "integrations"; both name the
28
+ * same `WebhookSubscriptionRecord` resource). No sibling constant for the deliveries log
29
+ * (`use-integration-deliveries.hooks.ts`): no Webhooks agent tool writes a delivery row — deliveries
30
+ * are recorded only by the outbound delivery worker itself, which nothing in this catalog drives. */
31
+ export const WEBHOOKS_RESOURCE = "webhooks";
32
+ /** Parses the comma-separated topics field into a trimmed, blank-free list.
33
+ *
34
+ * @complexity Time: O(n) in the length of `raw`; space: O(k) for the k resulting topics.
35
+ * @overallScore 100
36
+ */
37
+ export function parseTopics({ raw }, _optional = {}) {
38
+ return raw
39
+ .split(",")
40
+ .map((topic) => topic.trim())
41
+ .filter(Boolean);
42
+ }
43
+ /**
44
+ * The row-action menu for one webhook subscription.
45
+ *
46
+ * The branch is the reason this is exported: the "Pause"/"Resume" label depends on
47
+ * `subscription.status`, and that was previously only reachable by rendering the table and
48
+ * opening the menu. "Delete" is marked `destructive` and only OPENS the confirmation; the delete
49
+ * itself is `useIntegrations().onDelete`, gated on `ConfirmDialog`.
50
+ *
51
+ * Withholding the menu entirely for a `disabled` subscription (rendering `—` instead) stays in
52
+ * `Integrations.tsx` — that decision is made before this function is ever called, not inside it.
53
+ *
54
+ * @complexity Time/space: O(1) — exactly two entries, no iteration.
55
+ * @overallScore 100
56
+ */
57
+ export function integrationRowMenuItems({ subscription, handlers, locale, translate: t }, _optional = {}) {
58
+ return [
59
+ {
60
+ key: "pause",
61
+ label: subscription.status === "paused" ? t({ locale: locale, key: "Resume" }) : t({ locale: locale, key: "Pause" }),
62
+ onSelect: () => handlers.onTogglePause(subscription),
63
+ },
64
+ {
65
+ key: "delete",
66
+ label: t({ locale: locale, key: "Delete" }),
67
+ destructive: true,
68
+ onSelect: () => handlers.onDelete(subscription),
69
+ },
70
+ ];
71
+ }
72
+ /** Best available timestamp for the delivery log's "Timestamp" column: delivered time, else
73
+ * created time.
74
+ *
75
+ * @complexity Time/space: O(1).
76
+ * @overallScore 100
77
+ */
78
+ export function displayTimestamp({ delivery, viewerTimeZone }, _optional = {}) {
79
+ return formatTimestamp({ iso: delivery.deliveredAt ?? delivery.createdAt }, { viewerTimeZone: viewerTimeZone });
80
+ }
81
+ /**
82
+ * `useIntegrations`'s page-level error banner — deliberately excludes the CREATE write's own
83
+ * failure, which shows inside the create form itself (`formError`, derived directly from
84
+ * `createMutation.error` in the hook) rather than this page-level channel, matching the
85
+ * pre-migration `onCreate`/`onTogglePause`/`onDelete` catch blocks' own separate `setFormError`
86
+ * vs `setError` split.
87
+ *
88
+ * Precedence: an active toggle/delete failure outranks a background list-refresh failure, same
89
+ * shape as `Jini redirects/rules.ts`'s `visibleRedirectsError`. The list error only surfaces before
90
+ * `subscriptions` has ever loaded.
91
+ *
92
+ * @complexity Time/space: O(1) — three fixed checks, no iteration.
93
+ */
94
+ export function visibleIntegrationsError(params, _optional = {}) {
95
+ if (params.toggleError)
96
+ return params.describeApiError({ e: params.toggleError, fallback: params.translate({ locale: params.locale, key: "failed to update subscription" }) });
97
+ if (params.deleteError)
98
+ return params.describeApiError({ e: params.deleteError, fallback: params.translate({ locale: params.locale, key: "failed to delete subscription" }) });
99
+ if (params.hasSubscriptions)
100
+ return null;
101
+ return params.listError ? params.describeApiError({ e: params.listError, fallback: params.translate({ locale: params.locale, key: "failed to load integrations" }) }) : null;
102
+ }
103
+ //# sourceMappingURL=rules.js.map