@ekanos/sdk 0.23.0 → 0.24.0

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 (42) hide show
  1. package/README.md +15 -13
  2. package/api-report.md +10 -3
  3. package/dist/components/base-activation-dialog.js +2 -2
  4. package/dist/components/base-activation-dialog.js.map +1 -1
  5. package/dist/components/base-activation-form.js +2 -2
  6. package/dist/components/base-activation-form.js.map +1 -1
  7. package/dist/components/base-marketplace-tile.js +2 -2
  8. package/dist/components/base-marketplace-tile.js.map +1 -1
  9. package/dist/components/index.d.ts +1 -0
  10. package/dist/components/index.js +1 -0
  11. package/dist/components/index.js.map +1 -1
  12. package/dist/components/widgets/ai-prompt-chip.js +2 -2
  13. package/dist/components/widgets/ai-prompt-chip.js.map +1 -1
  14. package/dist/components/widgets/widget-ask-bar.js +1 -1
  15. package/dist/components/widgets/widget-ask-bar.js.map +1 -1
  16. package/dist/components/widgets/widget-query-state.d.ts +57 -0
  17. package/dist/components/widgets/widget-query-state.js +44 -0
  18. package/dist/components/widgets/widget-query-state.js.map +1 -0
  19. package/dist/components/widgets/widget-state-components.js +4 -4
  20. package/dist/components/widgets/widget-state-components.js.map +1 -1
  21. package/dist/components/widgets/widget.d.ts +18 -23
  22. package/dist/components/widgets/widget.js +31 -32
  23. package/dist/components/widgets/widget.js.map +1 -1
  24. package/dist/experience/client.d.ts +7 -5
  25. package/dist/experience/client.js +7 -5
  26. package/dist/experience/client.js.map +1 -1
  27. package/dist/experience/define-experience.d.ts +13 -1
  28. package/dist/experience/define-experience.js +13 -1
  29. package/dist/experience/define-experience.js.map +1 -1
  30. package/dist/experience/runtime.d.ts +15 -8
  31. package/dist/experience/runtime.js.map +1 -1
  32. package/dist/experience/server.d.ts +3 -2
  33. package/dist/experience/server.js +3 -2
  34. package/dist/experience/server.js.map +1 -1
  35. package/dist/hooks/use-oauth-connection-status.js +3 -1
  36. package/dist/hooks/use-oauth-connection-status.js.map +1 -1
  37. package/dist/integration/index.d.ts +1 -1
  38. package/dist/integration/index.js.map +1 -1
  39. package/dist/integration/types.d.ts +1 -1
  40. package/dist/integration/types.js.map +1 -1
  41. package/eslint.design-rules.mjs +35 -160
  42. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/experience/runtime.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,yBAAyB,GAI1B,MAAM,SAAS,CAAC","sourcesContent":["/**\n * `@ekanos/sdk/experience/runtime` — the ONE seam between an experience and\n * an integration.\n *\n * An experience calls operations through an {@link ExperienceRuntime} and\n * through nothing else: no import of integration code, no `fetch` to an\n * integration route. The local harness implements it over its own\n * `/__ekanos/api/ops/run`; the host implements it over its experience route,\n * `/api/experiences/<experience>/slots/…?account=<team>`, with the team's own\n * connection to each integration (no install). Both answer with the same {@link OperationResult} and the same\n * refusal reasons, so an experience behaves identically in either.\n *\n * Isomorphic and dependency-free: types only (plus the re-exports below).\n */\nimport type { OperationResult } from '@ekanos/integration-schema';\n\nexport {\n OPERATION_REFUSAL_REASONS,\n type OperationError,\n type OperationRefusalReason,\n type OperationResult,\n} from './types';\n\n/** The channel a call arrives on; writes are judged by it (see `write_refused_on_channel`). */\nexport type OperationChannel = 'http' | 'rsc' | 'workflow';\n\n/**\n * Proof that a person approved one write. Opaque to the experience: the\n * runtime mints it (the harness approvals tray; the host approval gate) and\n * checks it. An experience may carry one back into `mutate(input, { approval })`.\n */\nexport interface ApprovalToken {\n readonly id: string;\n}\n\nexport interface OperationCallRequest {\n /** The integration name from `ekanos.json` `integrations` (its slug). */\n integration: string;\n /** `tool/<name>` or `action/<name>`. The version is the one `ekanos.json` pins. */\n op: string;\n input: unknown;\n channel: OperationChannel;\n approval?: ApprovalToken;\n}\n\nexport type IntegrationProvenance = 'registry' | 'local';\n\n/** What a runtime can say about an integration (for UI badges, never for widgets' logic). */\nexport interface IntegrationInfo {\n name: string;\n version: string;\n provenance: IntegrationProvenance;\n bindingMode?: string;\n runMode?: 'fixtures' | 'live';\n}\n\nexport interface ExperienceRuntime {\n /**\n * Run one operation. May take as long as a person takes to decide: a write\n * on an approval-gated channel resolves only once the approval tray has\n * answered (`write_not_approved` when it was rejected). Never throws for a\n * refusal: those are `{ ok: false, reason }`. A rejected promise means the\n * runtime itself is broken.\n */\n call(request: OperationCallRequest): Promise<OperationResult<unknown>>;\n integrations(): IntegrationInfo[];\n}\n"]}
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/experience/runtime.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,yBAAyB,GAI1B,MAAM,SAAS,CAAC","sourcesContent":["/**\n * `@ekanos/sdk/experience/runtime` — the ONE seam between an experience and\n * an integration.\n *\n * An experience calls operations through an {@link ExperienceRuntime} and\n * through nothing else: no import of integration code, no `fetch` to an\n * integration route. The local harness implements it over its own\n * `/__ekanos/api/ops/run`; the host implements it over its experience route,\n * `/api/experiences/<experience>/slots/…?account=<team>`, with the team's own\n * connection to each integration (no install). Both answer with the same {@link OperationResult} and the same\n * refusal reasons, so an experience behaves identically in either.\n *\n * Isomorphic and dependency-free: types only (plus the re-exports below).\n */\nimport type { OperationResult } from '@ekanos/integration-schema';\n\nexport {\n OPERATION_REFUSAL_REASONS,\n type OperationError,\n type OperationRefusalReason,\n type OperationResult,\n} from './types';\n\n/**\n * The channel a call arrives on; writes are judged by it. `http` and `rsc` are\n * reads (a write there is `write_refused_on_channel`). `interactive` is a\n * person's own click in a widget or page: `useOperationMutation` uses it, and\n * the write runs directly. `workflow` writes sit behind the workflow's\n * approval step.\n */\nexport type OperationChannel = 'http' | 'rsc' | 'workflow' | 'interactive';\n\n/**\n * Proof that a person approved one write. Opaque to the experience. A widget\n * or page write does not need one: the person's click is the authorization.\n * Kept for runtimes that mint a token for a held write.\n */\nexport interface ApprovalToken {\n readonly id: string;\n}\n\nexport interface OperationCallRequest {\n /** The integration name from `ekanos.json` `integrations` (its slug). */\n integration: string;\n /** `tool/<name>` or `action/<name>`. The version is the one `ekanos.json` pins. */\n op: string;\n input: unknown;\n channel: OperationChannel;\n approval?: ApprovalToken;\n}\n\nexport type IntegrationProvenance = 'registry' | 'local';\n\n/** What a runtime can say about an integration (for UI badges, never for widgets' logic). */\nexport interface IntegrationInfo {\n name: string;\n version: string;\n provenance: IntegrationProvenance;\n bindingMode?: string;\n runMode?: 'fixtures' | 'live';\n}\n\nexport interface ExperienceRuntime {\n /**\n * Run one operation. A write on `interactive` runs directly; if the\n * operation requires `confirmed: z.literal(true)` in its input, the runtime\n * asks the person first, so the call may take as long as they take to answer\n * (`write_not_approved` when they cancel). Never throws for a\n * refusal: those are `{ ok: false, reason }`. A rejected promise means the\n * runtime itself is broken.\n */\n call(request: OperationCallRequest): Promise<OperationResult<unknown>>;\n integrations(): IntegrationInfo[];\n}\n"]}
@@ -5,7 +5,8 @@ export declare function runWithExperienceRuntime<T>(runtime: ExperienceRuntime,
5
5
  /** Register a process-wide runtime (the harness, which has no per-request wrapper). */
6
6
  export declare function configureExperienceRuntime(runtime: ExperienceRuntime): void;
7
7
  /**
8
- * Call one operation on the server. Writes are judged by the `rsc` channel:
9
- * the runtime refuses them unless it holds an approval (`write_refused_on_channel`).
8
+ * Call one operation on the server, to read. The `rsc` channel is read-only:
9
+ * a write is refused (`write_refused_on_channel`). Writes belong to a person's
10
+ * click in a widget or page (`useOperationMutation`) or to a workflow step.
10
11
  */
11
12
  export declare function operation<S extends IntegrationName, K extends OperationKey<S>>(integration: S, op: K, ...args: InputArgs<OperationInput<S, K>>): Promise<OperationResult<OperationOutput<S, K>>>;
@@ -31,8 +31,9 @@ function currentRuntime() {
31
31
  return runtime;
32
32
  }
33
33
  /**
34
- * Call one operation on the server. Writes are judged by the `rsc` channel:
35
- * the runtime refuses them unless it holds an approval (`write_refused_on_channel`).
34
+ * Call one operation on the server, to read. The `rsc` channel is read-only:
35
+ * a write is refused (`write_refused_on_channel`). Writes belong to a person's
36
+ * click in a widget or page (`useOperationMutation`) or to a workflow step.
36
37
  */
37
38
  export async function operation(integration, op, ...args) {
38
39
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/experience/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAYrD,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAqB,CAAC;AAE3D,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAMhE,wEAAwE;AACxE,MAAM,UAAU,wBAAwB,CACtC,OAA0B,EAC1B,EAAW;IAEX,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,0BAA0B,CAAC,OAA0B;IAClE,UAAgC,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC;AAC1D,CAAC;AAED,SAAS,cAAc;;IACrB,MAAM,OAAO,SACX,OAAO,CAAC,QAAQ,EAAE,mCAAK,UAAgC,CAAC,UAAU,CAAC,CAAC;IACtE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,6IAA6I,CAC9I,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAI7B,WAAc,EACd,EAAK,EACL,GAAG,IAAqC;;IAExC,MAAM,MAAM,GAAG,MAAM,cAAc,EAAE,CAAC,IAAI,CAAC;QACzC,WAAW;QACX,EAAE;QACF,KAAK,QAAE,IAAI,CAAC,CAAC,CAAC,mCAAI,EAAE;QACpB,OAAO,EAAE,KAAK;KACf,CAAC,CAAC;IAEH,OAAO,MAAgD,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * `@ekanos/sdk/experience/server` — call an integration operation from a server\n * component, server action or route.\n *\n * ```ts\n * const res = await operation('cms', 'tool/list_posts', { limit: 20 });\n * if (res.ok) res.data; // typed from the pinned contract\n * ```\n *\n * The runtime comes from `AsyncLocalStorage` (set by the host or the harness\n * around the request with {@link runWithExperienceRuntime}), falling back to\n * one registered with {@link configureExperienceRuntime}.\n */\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ExperienceRuntime } from './runtime';\nimport type {\n InputArgs,\n OperationInput,\n OperationKey,\n OperationOutput,\n OperationResult,\n IntegrationName,\n} from './types';\n\nconst storage = new AsyncLocalStorage<ExperienceRuntime>();\n\nconst GLOBAL_KEY = Symbol.for('@ekanos/sdk/experience/runtime');\n\ntype GlobalWithRuntime = typeof globalThis & {\n [GLOBAL_KEY]?: ExperienceRuntime;\n};\n\n/** Run `fn` with `runtime` as the one `operation()` calls inside it. */\nexport function runWithExperienceRuntime<T>(\n runtime: ExperienceRuntime,\n fn: () => T,\n): T {\n return storage.run(runtime, fn);\n}\n\n/** Register a process-wide runtime (the harness, which has no per-request wrapper). */\nexport function configureExperienceRuntime(runtime: ExperienceRuntime): void {\n (globalThis as GlobalWithRuntime)[GLOBAL_KEY] = runtime;\n}\n\nfunction currentRuntime(): ExperienceRuntime {\n const runtime =\n storage.getStore() ?? (globalThis as GlobalWithRuntime)[GLOBAL_KEY];\n if (!runtime) {\n throw new Error(\n 'operation() has no ExperienceRuntime. The host and `ekanos dev` set one per request; in a test call runWithExperienceRuntime(runtime, ...).',\n );\n }\n\n return runtime;\n}\n\n/**\n * Call one operation on the server. Writes are judged by the `rsc` channel:\n * the runtime refuses them unless it holds an approval (`write_refused_on_channel`).\n */\nexport async function operation<\n S extends IntegrationName,\n K extends OperationKey<S>,\n>(\n integration: S,\n op: K,\n ...args: InputArgs<OperationInput<S, K>>\n): Promise<OperationResult<OperationOutput<S, K>>> {\n const result = await currentRuntime().call({\n integration,\n op,\n input: args[0] ?? {},\n channel: 'rsc',\n });\n\n return result as OperationResult<OperationOutput<S, K>>;\n}\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/experience/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAYrD,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAqB,CAAC;AAE3D,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAMhE,wEAAwE;AACxE,MAAM,UAAU,wBAAwB,CACtC,OAA0B,EAC1B,EAAW;IAEX,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,0BAA0B,CAAC,OAA0B;IAClE,UAAgC,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC;AAC1D,CAAC;AAED,SAAS,cAAc;;IACrB,MAAM,OAAO,SACX,OAAO,CAAC,QAAQ,EAAE,mCAAK,UAAgC,CAAC,UAAU,CAAC,CAAC;IACtE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,6IAA6I,CAC9I,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAI7B,WAAc,EACd,EAAK,EACL,GAAG,IAAqC;;IAExC,MAAM,MAAM,GAAG,MAAM,cAAc,EAAE,CAAC,IAAI,CAAC;QACzC,WAAW;QACX,EAAE;QACF,KAAK,QAAE,IAAI,CAAC,CAAC,CAAC,mCAAI,EAAE;QACpB,OAAO,EAAE,KAAK;KACf,CAAC,CAAC;IAEH,OAAO,MAAgD,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * `@ekanos/sdk/experience/server` — call an integration operation from a server\n * component, server action or route.\n *\n * ```ts\n * const res = await operation('cms', 'tool/list_posts', { limit: 20 });\n * if (res.ok) res.data; // typed from the pinned contract\n * ```\n *\n * The runtime comes from `AsyncLocalStorage` (set by the host or the harness\n * around the request with {@link runWithExperienceRuntime}), falling back to\n * one registered with {@link configureExperienceRuntime}.\n */\nimport { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { ExperienceRuntime } from './runtime';\nimport type {\n InputArgs,\n OperationInput,\n OperationKey,\n OperationOutput,\n OperationResult,\n IntegrationName,\n} from './types';\n\nconst storage = new AsyncLocalStorage<ExperienceRuntime>();\n\nconst GLOBAL_KEY = Symbol.for('@ekanos/sdk/experience/runtime');\n\ntype GlobalWithRuntime = typeof globalThis & {\n [GLOBAL_KEY]?: ExperienceRuntime;\n};\n\n/** Run `fn` with `runtime` as the one `operation()` calls inside it. */\nexport function runWithExperienceRuntime<T>(\n runtime: ExperienceRuntime,\n fn: () => T,\n): T {\n return storage.run(runtime, fn);\n}\n\n/** Register a process-wide runtime (the harness, which has no per-request wrapper). */\nexport function configureExperienceRuntime(runtime: ExperienceRuntime): void {\n (globalThis as GlobalWithRuntime)[GLOBAL_KEY] = runtime;\n}\n\nfunction currentRuntime(): ExperienceRuntime {\n const runtime =\n storage.getStore() ?? (globalThis as GlobalWithRuntime)[GLOBAL_KEY];\n if (!runtime) {\n throw new Error(\n 'operation() has no ExperienceRuntime. The host and `ekanos dev` set one per request; in a test call runWithExperienceRuntime(runtime, ...).',\n );\n }\n\n return runtime;\n}\n\n/**\n * Call one operation on the server, to read. The `rsc` channel is read-only:\n * a write is refused (`write_refused_on_channel`). Writes belong to a person's\n * click in a widget or page (`useOperationMutation`) or to a workflow step.\n */\nexport async function operation<\n S extends IntegrationName,\n K extends OperationKey<S>,\n>(\n integration: S,\n op: K,\n ...args: InputArgs<OperationInput<S, K>>\n): Promise<OperationResult<OperationOutput<S, K>>> {\n const result = await currentRuntime().call({\n integration,\n op,\n input: args[0] ?? {},\n channel: 'rsc',\n });\n\n return result as OperationResult<OperationOutput<S, K>>;\n}\n"]}
@@ -108,7 +108,9 @@ export function useOAuthWidgetGate(accountId, integrationActive, options) {
108
108
  : options;
109
109
  const query = useOAuthConnectionStatus(accountId !== null && accountId !== void 0 ? accountId : '', Object.assign(Object.assign({}, resolved), { enabled }));
110
110
  const connectionPending = enabled && query.isPending;
111
- const connectionError = enabled && query.isError;
111
+ // A failed RE-check keeps the last answer: only a check that never
112
+ // answered is an error. (TanStack keeps `data` after a failed refetch.)
113
+ const connectionError = enabled && query.isError && query.data === undefined;
112
114
  const isConnected = ((_a = query.data) === null || _a === void 0 ? void 0 : _a.isConnected) === true;
113
115
  const dataEnabled = enabled && isConnected;
114
116
  // Only treat as "not connected" when the check resolved successfully with
@@ -1 +1 @@
1
- {"version":3,"file":"use-oauth-connection-status.js","sourceRoot":"","sources":["../../src/hooks/use-oauth-connection-status.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAuC/D;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,SAAiB,EACjB,OAAwC;IAExC,MAAM,EACJ,aAAa,EACb,eAAe,EACf,OAAO,GAAG,IAAI,EACd,UAAU,GACX,GAAG,OAAO,CAAC;IACZ,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IAErC,yEAAyE;IACzE,0EAA0E;IAC1E,MAAM,CAAC,kBAAkB,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE;QACzC,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO,KAAK,CAAC;QAChD,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,MAAM,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAgB,GAAG,EAAE;QAChD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CACvC,IAAY;IAEZ,OAAO;QACL,aAAa,EAAE,GAAG,IAAI,aAAa;QACnC,eAAe,EAAE,4BAA4B,CAAC,IAAI,CAAC;KACpD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,SAA6B,EAC7B,iBAA0B,EAC1B,OAA+B;;IAE/B,MAAM,OAAO,GAAG,iBAAiB,IAAI,CAAC,CAAC,SAAS,CAAC;IACjD,MAAM,QAAQ,GACZ,OAAO,CAAC,IAAI,KAAK,SAAS;QACxB,CAAC,CAAC,yBAAyB,CAAC,OAAO,CAAC,IAAI,CAAC;QACzC,CAAC,CAAC,OAAO,CAAC;IACd,MAAM,KAAK,GAAG,wBAAwB,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,kCACjD,QAAQ,KACX,OAAO,IACP,CAAC;IAEH,MAAM,iBAAiB,GAAG,OAAO,IAAI,KAAK,CAAC,SAAS,CAAC;IACrD,MAAM,eAAe,GAAG,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC;IACjD,MAAM,WAAW,GAAG,CAAA,MAAA,KAAK,CAAC,IAAI,0CAAE,WAAW,MAAK,IAAI,CAAC;IACrD,MAAM,WAAW,GAAG,OAAO,IAAI,WAAW,CAAC;IAC3C,0EAA0E;IAC1E,0EAA0E;IAC1E,MAAM,YAAY,GAChB,OAAO,IAAI,CAAC,iBAAiB,IAAI,CAAC,eAAe,IAAI,CAAC,WAAW,CAAC;IAEpE,OAAO;QACL,OAAO;QACP,WAAW;QACX,iBAAiB;QACjB,eAAe;QACf,WAAW;QACX,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\nimport { useQuery, useQueryClient } from '@tanstack/react-query';\n\nimport { createPartnerConnectionCheck } from './partner-oauth';\n\n/**\n * Result shape of an integration's check-connection server action\n * (the standard server-action envelope).\n */\nexport interface ConnectionCheckResult {\n success: boolean;\n data?: { obtainedAt?: string | null } | null;\n error?: string;\n}\n\nexport type ConnectionCheckAction = (input: {\n accountId: string;\n}) => Promise<ConnectionCheckResult>;\n\n/**\n * Optional OAuth failure query param an integration's connect route may\n * append on redirect (e.g. dropbox_error=credentials_not_configured).\n */\nexport interface OAuthErrorParam {\n name: string;\n /** Map the raw param value to a user-facing message; return null to ignore. */\n toMessage: (value: string) => string | null;\n}\n\nexport interface UseOAuthConnectionStatusOptions {\n /**\n * Cache key segment, by convention `<slug>-connection`. The full query key\n * is ['integration-data', accountId, connectionKey] so all widgets and the\n * activation form share one deduped request per dashboard load.\n */\n connectionKey: string;\n checkConnection: ConnectionCheckAction;\n /** Gate the query (e.g. on integration-active state). Defaults to true. */\n enabled?: boolean;\n errorParam?: OAuthErrorParam;\n}\n\n/**\n * Shared OAuth connection-status hook. Detects the `oauth_success=true`\n * return from an integration's connect route, strips the transient params\n * from the URL, and invalidates the cached status so dependent UI flips to\n * connected without a manual refresh.\n */\nexport function useOAuthConnectionStatus(\n accountId: string,\n options: UseOAuthConnectionStatusOptions,\n) {\n const {\n connectionKey,\n checkConnection,\n enabled = true,\n errorParam,\n } = options;\n const queryClient = useQueryClient();\n\n // Read the OAuth return params synchronously on mount (not in an effect)\n // so the first render already knows whether we just came back from OAuth.\n const [oauthJustCompleted] = useState(() => {\n if (typeof window === 'undefined') return false;\n const params = new URLSearchParams(window.location.search);\n return params.get('oauth_success') === 'true';\n });\n\n const [oauthError] = useState<string | null>(() => {\n if (!errorParam || typeof window === 'undefined') return null;\n const value = new URLSearchParams(window.location.search).get(\n errorParam.name,\n );\n return value ? errorParam.toMessage(value) : null;\n });\n\n const query = useQuery({\n queryKey: ['integration-data', accountId, connectionKey],\n queryFn: async () => {\n const result = await checkConnection({ accountId });\n\n if (!result.success) {\n return { isConnected: false, error: result.error };\n }\n\n return {\n isConnected: true,\n obtainedAt: result.data?.obtainedAt,\n };\n },\n enabled: enabled && !!accountId,\n staleTime: 5 * 60 * 1000,\n refetchOnWindowFocus: false,\n });\n\n const errorParamName = errorParam?.name;\n\n const returnedWithError = oauthError !== null;\n\n // Justified useEffect: after the OAuth redirect lands back on this page —\n // with `?oauth_success=true` OR with the integration's error param — we\n // must (1) strip the transient query params from the URL, so a reload does\n // not re-announce a stale success or re-show a stale error, and (2) on\n // success invalidate the cached connection status so widgets flip to\n // connected without a manual refresh. Both are post-render side effects\n // on external systems (history API + query cache), not derivable during\n // render. The error itself stays in state for this render, so the alert\n // still shows once.\n useEffect(() => {\n if (!oauthJustCompleted && !returnedWithError) return;\n\n const url = new URL(window.location.href);\n url.searchParams.delete('oauth_success');\n\n if (errorParamName) {\n url.searchParams.delete(errorParamName);\n }\n\n window.history.replaceState({}, '', url.pathname + url.search);\n\n if (oauthJustCompleted) {\n queryClient.invalidateQueries({\n queryKey: ['integration-data', accountId, connectionKey],\n });\n }\n }, [\n oauthJustCompleted,\n returnedWithError,\n accountId,\n connectionKey,\n errorParamName,\n queryClient,\n ]);\n\n // Named, not spread: spreading a query result reads every field, so\n // the component re-renders on all of them (TanStack render optimizations).\n return {\n data: query.data,\n error: query.error,\n status: query.status,\n isPending: query.isPending,\n isLoading: query.isLoading,\n isError: query.isError,\n isSuccess: query.isSuccess,\n isFetching: query.isFetching,\n isRefetching: query.isRefetching,\n dataUpdatedAt: query.dataUpdatedAt,\n refetch: query.refetch,\n oauthJustCompleted,\n oauthError,\n };\n}\n\n/**\n * Resolves the gating booleans every OAuth-backed dashboard widget needs:\n *\n * - `enabled` — the integration is active and an account id is present.\n * - `isConnected` — a live OAuth connection exists (access token).\n * - `dataEnabled` — safe to fire the widget's data query (active + connected).\n * - `connectionPending` — still resolving the connection status.\n * - `connectionError` — the connection check itself failed (network/5xx).\n * Distinct from `notConnected`: a transient failure should surface as an\n * error, not as a misleading \"connect X\" prompt.\n * - `notConnected` — activated, resolved without error, but no OAuth\n * connection. The widget should render its \"connect X\" inactive state.\n *\n * The underlying connection check shares one query key across all widgets,\n * so react-query dedupes it to a single request per dashboard load.\n */\nexport type OAuthWidgetGateOptions =\n | (Pick<\n UseOAuthConnectionStatusOptions,\n 'connectionKey' | 'checkConnection'\n > & {\n slug?: never;\n })\n /**\n * The hosted-transport shorthand: for an integration whose connection is\n * checked at `GET /api/integrations/<slug>/oauth/status`, the slug is the\n * only fact the gate needs — the key is `<slug>-connection` by convention\n * and the check is `createPartnerConnectionCheck(slug)`.\n */\n | { slug: string; connectionKey?: never; checkConnection?: never };\n\n/** Pure: the gate options a slug implies. Exported for tests and for widgets that need the key. */\nexport function oauthWidgetGateOptionsFor(\n slug: string,\n): Pick<UseOAuthConnectionStatusOptions, 'connectionKey' | 'checkConnection'> {\n return {\n connectionKey: `${slug}-connection`,\n checkConnection: createPartnerConnectionCheck(slug),\n };\n}\n\nexport function useOAuthWidgetGate(\n accountId: string | undefined,\n integrationActive: boolean,\n options: OAuthWidgetGateOptions,\n) {\n const enabled = integrationActive && !!accountId;\n const resolved =\n options.slug !== undefined\n ? oauthWidgetGateOptionsFor(options.slug)\n : options;\n const query = useOAuthConnectionStatus(accountId ?? '', {\n ...resolved,\n enabled,\n });\n\n const connectionPending = enabled && query.isPending;\n const connectionError = enabled && query.isError;\n const isConnected = query.data?.isConnected === true;\n const dataEnabled = enabled && isConnected;\n // Only treat as \"not connected\" when the check resolved successfully with\n // no token — a query error is an error state, not a disconnected account.\n const notConnected =\n enabled && !connectionPending && !connectionError && !isConnected;\n\n return {\n enabled,\n isConnected,\n connectionPending,\n connectionError,\n dataEnabled,\n notConnected,\n };\n}\n"]}
1
+ {"version":3,"file":"use-oauth-connection-status.js","sourceRoot":"","sources":["../../src/hooks/use-oauth-connection-status.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAuC/D;;;;;GAKG;AACH,MAAM,UAA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O,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC;IAC7E,MAAM,WAAW,GAAG,CAAA,MAAA,KAAK,CAAC,IAAI,0CAAE,WAAW,MAAK,IAAI,CAAC;IACrD,MAAM,WAAW,GAAG,OAAO,IAAI,WAAW,CAAC;IAC3C,0EAA0E;IAC1E,0EAA0E;IAC1E,MAAM,YAAY,GAChB,OAAO,IAAI,CAAC,iBAAiB,IAAI,CAAC,eAAe,IAAI,CAAC,WAAW,CAAC;IAEpE,OAAO;QACL,OAAO;QACP,WAAW;QACX,iBAAiB;QACjB,eAAe;QACf,WAAW;QACX,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\nimport { useQuery, useQueryClient } from '@tanstack/react-query';\n\nimport { createPartnerConnectionCheck } from './partner-oauth';\n\n/**\n * Result shape of an integration's check-connection server action\n * (the standard server-action envelope).\n */\nexport interface ConnectionCheckResult {\n success: boolean;\n data?: { obtainedAt?: string | null } | null;\n error?: string;\n}\n\nexport type ConnectionCheckAction = (input: {\n accountId: string;\n}) => Promise<ConnectionCheckResult>;\n\n/**\n * Optional OAuth failure query param an integration's connect route may\n * append on redirect (e.g. dropbox_error=credentials_not_configured).\n */\nexport interface OAuthErrorParam {\n name: string;\n /** Map the raw param value to a user-facing message; return null to ignore. */\n toMessage: (value: string) => string | null;\n}\n\nexport interface UseOAuthConnectionStatusOptions {\n /**\n * Cache key segment, by convention `<slug>-connection`. The full query key\n * is ['integration-data', accountId, connectionKey] so all widgets and the\n * activation form share one deduped request per dashboard load.\n */\n connectionKey: string;\n checkConnection: ConnectionCheckAction;\n /** Gate the query (e.g. on integration-active state). Defaults to true. */\n enabled?: boolean;\n errorParam?: OAuthErrorParam;\n}\n\n/**\n * Shared OAuth connection-status hook. Detects the `oauth_success=true`\n * return from an integration's connect route, strips the transient params\n * from the URL, and invalidates the cached status so dependent UI flips to\n * connected without a manual refresh.\n */\nexport function useOAuthConnectionStatus(\n accountId: string,\n options: UseOAuthConnectionStatusOptions,\n) {\n const {\n connectionKey,\n checkConnection,\n enabled = true,\n errorParam,\n } = options;\n const queryClient = useQueryClient();\n\n // Read the OAuth return params synchronously on mount (not in an effect)\n // so the first render already knows whether we just came back from OAuth.\n const [oauthJustCompleted] = useState(() => {\n if (typeof window === 'undefined') return false;\n const params = new URLSearchParams(window.location.search);\n return params.get('oauth_success') === 'true';\n });\n\n const [oauthError] = useState<string | null>(() => {\n if (!errorParam || typeof window === 'undefined') return null;\n const value = new URLSearchParams(window.location.search).get(\n errorParam.name,\n );\n return value ? errorParam.toMessage(value) : null;\n });\n\n const query = useQuery({\n queryKey: ['integration-data', accountId, connectionKey],\n queryFn: async () => {\n const result = await checkConnection({ accountId });\n\n if (!result.success) {\n return { isConnected: false, error: result.error };\n }\n\n return {\n isConnected: true,\n obtainedAt: result.data?.obtainedAt,\n };\n },\n enabled: enabled && !!accountId,\n staleTime: 5 * 60 * 1000,\n refetchOnWindowFocus: false,\n });\n\n const errorParamName = errorParam?.name;\n\n const returnedWithError = oauthError !== null;\n\n // Justified useEffect: after the OAuth redirect lands back on this page —\n // with `?oauth_success=true` OR with the integration's error param — we\n // must (1) strip the transient query params from the URL, so a reload does\n // not re-announce a stale success or re-show a stale error, and (2) on\n // success invalidate the cached connection status so widgets flip to\n // connected without a manual refresh. Both are post-render side effects\n // on external systems (history API + query cache), not derivable during\n // render. The error itself stays in state for this render, so the alert\n // still shows once.\n useEffect(() => {\n if (!oauthJustCompleted && !returnedWithError) return;\n\n const url = new URL(window.location.href);\n url.searchParams.delete('oauth_success');\n\n if (errorParamName) {\n url.searchParams.delete(errorParamName);\n }\n\n window.history.replaceState({}, '', url.pathname + url.search);\n\n if (oauthJustCompleted) {\n queryClient.invalidateQueries({\n queryKey: ['integration-data', accountId, connectionKey],\n });\n }\n }, [\n oauthJustCompleted,\n returnedWithError,\n accountId,\n connectionKey,\n errorParamName,\n queryClient,\n ]);\n\n // Named, not spread: spreading a query result reads every field, so\n // the component re-renders on all of them (TanStack render optimizations).\n return {\n data: query.data,\n error: query.error,\n status: query.status,\n isPending: query.isPending,\n isLoading: query.isLoading,\n isError: query.isError,\n isSuccess: query.isSuccess,\n isFetching: query.isFetching,\n isRefetching: query.isRefetching,\n dataUpdatedAt: query.dataUpdatedAt,\n refetch: query.refetch,\n oauthJustCompleted,\n oauthError,\n };\n}\n\n/**\n * Resolves the gating booleans every OAuth-backed dashboard widget needs:\n *\n * - `enabled` — the integration is active and an account id is present.\n * - `isConnected` — a live OAuth connection exists (access token).\n * - `dataEnabled` — safe to fire the widget's data query (active + connected).\n * - `connectionPending` — still resolving the connection status.\n * - `connectionError` — the connection check itself failed (network/5xx).\n * Distinct from `notConnected`: a transient failure should surface as an\n * error, not as a misleading \"connect X\" prompt.\n * - `notConnected` — activated, resolved without error, but no OAuth\n * connection. The widget should render its \"connect X\" inactive state.\n *\n * The underlying connection check shares one query key across all widgets,\n * so react-query dedupes it to a single request per dashboard load.\n */\nexport type OAuthWidgetGateOptions =\n | (Pick<\n UseOAuthConnectionStatusOptions,\n 'connectionKey' | 'checkConnection'\n > & {\n slug?: never;\n })\n /**\n * The hosted-transport shorthand: for an integration whose connection is\n * checked at `GET /api/integrations/<slug>/oauth/status`, the slug is the\n * only fact the gate needs — the key is `<slug>-connection` by convention\n * and the check is `createPartnerConnectionCheck(slug)`.\n */\n | { slug: string; connectionKey?: never; checkConnection?: never };\n\n/** Pure: the gate options a slug implies. Exported for tests and for widgets that need the key. */\nexport function oauthWidgetGateOptionsFor(\n slug: string,\n): Pick<UseOAuthConnectionStatusOptions, 'connectionKey' | 'checkConnection'> {\n return {\n connectionKey: `${slug}-connection`,\n checkConnection: createPartnerConnectionCheck(slug),\n };\n}\n\nexport function useOAuthWidgetGate(\n accountId: string | undefined,\n integrationActive: boolean,\n options: OAuthWidgetGateOptions,\n) {\n const enabled = integrationActive && !!accountId;\n const resolved =\n options.slug !== undefined\n ? oauthWidgetGateOptionsFor(options.slug)\n : options;\n const query = useOAuthConnectionStatus(accountId ?? '', {\n ...resolved,\n enabled,\n });\n\n const connectionPending = enabled && query.isPending;\n // A failed RE-check keeps the last answer: only a check that never\n // answered is an error. (TanStack keeps `data` after a failed refetch.)\n const connectionError = enabled && query.isError && query.data === undefined;\n const isConnected = query.data?.isConnected === true;\n const dataEnabled = enabled && isConnected;\n // Only treat as \"not connected\" when the check resolved successfully with\n // no token — a query error is an error state, not a disconnected account.\n const notConnected =\n enabled && !connectionPending && !connectionError && !isConnected;\n\n return {\n enabled,\n isConnected,\n connectionPending,\n connectionError,\n dataEnabled,\n notConnected,\n };\n}\n"]}
@@ -23,4 +23,4 @@ export { DEFAULT_UNTRUSTED_TEXT_MAX_CHARS, untrustedText, untrustedTextNote, } f
23
23
  export { DEFAULT_OAUTH_CONNECTION_ID, DEFAULT_SIGNATURE_TOLERANCE_SECONDS, IntegrationDefinitionSchema, MAX_AGENT_EVENT_DEDUPE_KEY_LENGTH, MAX_RAISED_AGENT_EVENTS, MAX_ROUTE_VALUE_LENGTH, MAX_ROUTING_KEYS, PARTNER_STORAGE_LIMITS, RESERVED_OAUTH_AUTHORIZATION_PARAMS, validateIntegrationDefinitions, } from '@ekanos/integration-schema';
24
24
  export { normalizeOAuthUrlValue, oauthProviderPlaceholders, resolveOAuthProvider, resolveOAuthUrl, } from '@ekanos/integration-schema';
25
25
  export type { ResolveOAuthProviderResult, ResolveOAuthUrlResult, } from '@ekanos/integration-schema';
26
- export type { IntegrationDefinition, IntegrationComponentDeclarations, IntegrationProposals, IntegrationCapabilityDeclaration, IntegrationPermissionDeclaration, PartnerWidgetDeclaration, PartnerToolModule, PartnerToolParameters, PartnerActionDeclaration, ToolClassificationProposal, DefinitionCollisionInput, FirstPartyInventory, PartnerWebhookDeclaration, WebhookSignatureDeclaration, WebhookSignatureScheme, WebhookEvent, WebhookResult, RaisedAgentEvent, PartnerAgentChannelDeclaration, AgentChannelRun, AgentEventDeclaration, AgentConversation, AgentTriggerFilter, AgentTriggerFilterField, AgentChannelReply, AgentChannelDeliveryResult, AgentChannelRunOutcome, AgentChannelHandoff, AgentRouteValue, AgentUnroutedEvent, RoutingDeclaration, RoutingKeyDeclaration, RouteKeyOption, SourceConnectionDeclaration, PartnerScheduleDeclaration, ScheduleInvocation, ScheduleResult, PartnerOAuthDeclaration, PartnerOAuthConnectionDeclaration, TeamAppDeclaration, OAuthProviderDeclaration, OAuthSetupDeclaration, OAuthTokens, OnActivateHandler, AttentionHandler, AttentionSignal, WidgetVerdict, WidgetVerdictTone, } from '@ekanos/integration-schema';
26
+ export type { IntegrationDefinition, IntegrationComponentDeclarations, ActivationDeclaration, ActivationFieldDeclaration, IntegrationProposals, IntegrationCapabilityDeclaration, IntegrationPermissionDeclaration, PartnerWidgetDeclaration, PartnerToolModule, PartnerToolParameters, PartnerActionDeclaration, ToolClassificationProposal, DefinitionCollisionInput, FirstPartyInventory, PartnerWebhookDeclaration, WebhookSignatureDeclaration, WebhookSignatureScheme, WebhookEvent, WebhookResult, RaisedAgentEvent, PartnerAgentChannelDeclaration, AgentChannelRun, AgentEventDeclaration, AgentConversation, AgentTriggerFilter, AgentTriggerFilterField, AgentChannelReply, AgentChannelDeliveryResult, AgentChannelRunOutcome, AgentChannelHandoff, AgentRouteValue, AgentUnroutedEvent, RoutingDeclaration, RoutingKeyDeclaration, RouteKeyOption, SourceConnectionDeclaration, PartnerScheduleDeclaration, ScheduleInvocation, ScheduleResult, PartnerOAuthDeclaration, PartnerOAuthConnectionDeclaration, TeamAppDeclaration, OAuthProviderDeclaration, OAuthSetupDeclaration, OAuthTokens, OnActivateHandler, AttentionHandler, AttentionSignal, WidgetVerdict, WidgetVerdictTone, } from '@ekanos/integration-schema';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/integration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,6EAA6E;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,mEAAmE;AACnE,0EAA0E;AAC1E,0EAA0E;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE7C,oEAAoE;AACpE,+CAA+C;AAC/C,8CAA8C;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,8EAA8E;AAC9E,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,+EAA+E;AAC/E,OAAO,EACL,gCAAgC,EAChC,aAAa,EACb,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,2BAA2B,EAC3B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EACjC,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,mCAAmC,EACnC,8BAA8B,GAC/B,MAAM,4BAA4B,CAAC;AAEpC,sEAAsE;AACtE,4EAA4E;AAC5E,4EAA4E;AAC5E,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,GAChB,MAAM,4BAA4B,CAAC","sourcesContent":["/**\n * @ekanos/sdk/integration — the partner authoring contract.\n *\n * `defineIntegration()` is THE way a partner declares an integration\n * Partners never extend a base class.\n * The host adapts the returned definition internally via\n * `registerPartnerIntegration` in `@kit/integrations-core`, which re-parses\n * against the SAME canonical schema (`@ekanos/integration-schema`) at the\n * trust boundary — one contract, no structural twin (F3/F9).\n *\n * Dependency-pure and isomorphic: zod plus the schema package, no `@kit/*`,\n * no `server-only`.\n *\n * Surface discipline: additions require an entry in\n * api-report.md, regenerated by `pnpm --filter @ekanos/sdk api-report`.\n */\n\nexport { defineIntegration } from './define-integration';\n\n// Agent events (plan 222): types an event's functions by its payload schema.\nexport { defineAgentEvent } from './define-agent-event';\n\n// Event-surface validation values: the 5-field cron parser backing\n// `defineIntegration()`'s schedule validation, exported so validators and\n// the harness can check/describe an expression the same way the SDK does.\nexport { parseCronExpression } from './cron';\n\n// The one escape hatch from the actions host route's opaque-failure\n// discipline — see the class's own doc comment\n// (the widget-actions opaque-failure ruling).\nexport { PublicActionError } from '../errors/public-action-error';\n\n// Gate a write action on the caller's role (the host fills `ctx.actor.role`).\nexport {\n ADMIN_HIERARCHY_LEVEL,\n OWNER_HIERARCHY_LEVEL,\n actorIsAtLeast,\n} from './actor-role';\n\n// Vendor/user-authored text in tool output: one name (`untrusted*`), one clip.\nexport {\n DEFAULT_UNTRUSTED_TEXT_MAX_CHARS,\n untrustedText,\n untrustedTextNote,\n} from './untrusted-text';\n\nexport {\n DEFAULT_OAUTH_CONNECTION_ID,\n DEFAULT_SIGNATURE_TOLERANCE_SECONDS,\n IntegrationDefinitionSchema,\n MAX_AGENT_EVENT_DEDUPE_KEY_LENGTH,\n MAX_RAISED_AGENT_EVENTS,\n MAX_ROUTE_VALUE_LENGTH,\n MAX_ROUTING_KEYS,\n PARTNER_STORAGE_LIMITS,\n RESERVED_OAUTH_AUTHORIZATION_PARAMS,\n validateIntegrationDefinitions,\n} from '@ekanos/integration-schema';\n\n// OAuth endpoint templates (`https://{subdomain}.zendesk.com/…`): the\n// resolver the host transport and the harness fill them with, exported so a\n// partner refreshing its own tokens builds the token URL by the same rules.\nexport {\n normalizeOAuthUrlValue,\n oauthProviderPlaceholders,\n resolveOAuthProvider,\n resolveOAuthUrl,\n} from '@ekanos/integration-schema';\nexport type {\n ResolveOAuthProviderResult,\n ResolveOAuthUrlResult,\n} from '@ekanos/integration-schema';\n\nexport type {\n IntegrationDefinition,\n IntegrationComponentDeclarations,\n IntegrationProposals,\n IntegrationCapabilityDeclaration,\n IntegrationPermissionDeclaration,\n PartnerWidgetDeclaration,\n PartnerToolModule,\n PartnerToolParameters,\n // Widget-invoked server handlers (`actions`): the declaration type a\n // partner needs to export a handler shared between an action and a tool.\n PartnerActionDeclaration,\n ToolClassificationProposal,\n DefinitionCollisionInput,\n FirstPartyInventory,\n // Event surfaces (webhooks, schedules, OAuth): declared in the definition,\n // executed locally by the harness/testing helpers today; the host's real\n // transports (public ingress, scheduler, hosted OAuth callback) bind to\n // these exact declarations later with no partner code change.\n PartnerWebhookDeclaration,\n WebhookSignatureDeclaration,\n WebhookSignatureScheme,\n WebhookEvent,\n WebhookResult,\n // Agent events and channel (plan 222): events a webhook raises to start\n // agents, and the channel a run answers in.\n RaisedAgentEvent,\n PartnerAgentChannelDeclaration,\n AgentChannelRun,\n AgentEventDeclaration,\n AgentConversation,\n AgentTriggerFilter,\n AgentTriggerFilterField,\n AgentChannelReply,\n AgentChannelDeliveryResult,\n AgentChannelRunOutcome,\n AgentChannelHandoff,\n // Routing and Source connections (plan 241): one connection for a whole\n // Source, its events routed to teams by a key such as the organization.\n AgentRouteValue,\n AgentUnroutedEvent,\n RoutingDeclaration,\n RoutingKeyDeclaration,\n RouteKeyOption,\n SourceConnectionDeclaration,\n PartnerScheduleDeclaration,\n ScheduleInvocation,\n ScheduleResult,\n PartnerOAuthDeclaration,\n PartnerOAuthConnectionDeclaration,\n TeamAppDeclaration,\n OAuthProviderDeclaration,\n OAuthSetupDeclaration,\n OAuthTokens,\n // Activation lifecycle hook: cache seeding / eager validation at connect\n // time. Runs after first persist and after every activationData update;\n // v1 errors are non-fatal (logged as a warning, activation stays active).\n OnActivateHandler,\n // Each widget's verdict, computed on the server for home's Needs you.\n AttentionHandler,\n AttentionSignal,\n WidgetVerdict,\n WidgetVerdictTone,\n} from '@ekanos/integration-schema';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/integration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,6EAA6E;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,mEAAmE;AACnE,0EAA0E;AAC1E,0EAA0E;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE7C,oEAAoE;AACpE,+CAA+C;AAC/C,8CAA8C;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,8EAA8E;AAC9E,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,+EAA+E;AAC/E,OAAO,EACL,gCAAgC,EAChC,aAAa,EACb,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,2BAA2B,EAC3B,mCAAmC,EACnC,2BAA2B,EAC3B,iCAAiC,EACjC,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,mCAAmC,EACnC,8BAA8B,GAC/B,MAAM,4BAA4B,CAAC;AAEpC,sEAAsE;AACtE,4EAA4E;AAC5E,4EAA4E;AAC5E,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,GAChB,MAAM,4BAA4B,CAAC","sourcesContent":["/**\n * @ekanos/sdk/integration — the partner authoring contract.\n *\n * `defineIntegration()` is THE way a partner declares an integration\n * Partners never extend a base class.\n * The host adapts the returned definition internally via\n * `registerPartnerIntegration` in `@kit/integrations-core`, which re-parses\n * against the SAME canonical schema (`@ekanos/integration-schema`) at the\n * trust boundary — one contract, no structural twin (F3/F9).\n *\n * Dependency-pure and isomorphic: zod plus the schema package, no `@kit/*`,\n * no `server-only`.\n *\n * Surface discipline: additions require an entry in\n * api-report.md, regenerated by `pnpm --filter @ekanos/sdk api-report`.\n */\n\nexport { defineIntegration } from './define-integration';\n\n// Agent events (plan 222): types an event's functions by its payload schema.\nexport { defineAgentEvent } from './define-agent-event';\n\n// Event-surface validation values: the 5-field cron parser backing\n// `defineIntegration()`'s schedule validation, exported so validators and\n// the harness can check/describe an expression the same way the SDK does.\nexport { parseCronExpression } from './cron';\n\n// The one escape hatch from the actions host route's opaque-failure\n// discipline — see the class's own doc comment\n// (the widget-actions opaque-failure ruling).\nexport { PublicActionError } from '../errors/public-action-error';\n\n// Gate a write action on the caller's role (the host fills `ctx.actor.role`).\nexport {\n ADMIN_HIERARCHY_LEVEL,\n OWNER_HIERARCHY_LEVEL,\n actorIsAtLeast,\n} from './actor-role';\n\n// Vendor/user-authored text in tool output: one name (`untrusted*`), one clip.\nexport {\n DEFAULT_UNTRUSTED_TEXT_MAX_CHARS,\n untrustedText,\n untrustedTextNote,\n} from './untrusted-text';\n\nexport {\n DEFAULT_OAUTH_CONNECTION_ID,\n DEFAULT_SIGNATURE_TOLERANCE_SECONDS,\n IntegrationDefinitionSchema,\n MAX_AGENT_EVENT_DEDUPE_KEY_LENGTH,\n MAX_RAISED_AGENT_EVENTS,\n MAX_ROUTE_VALUE_LENGTH,\n MAX_ROUTING_KEYS,\n PARTNER_STORAGE_LIMITS,\n RESERVED_OAUTH_AUTHORIZATION_PARAMS,\n validateIntegrationDefinitions,\n} from '@ekanos/integration-schema';\n\n// OAuth endpoint templates (`https://{subdomain}.zendesk.com/…`): the\n// resolver the host transport and the harness fill them with, exported so a\n// partner refreshing its own tokens builds the token URL by the same rules.\nexport {\n normalizeOAuthUrlValue,\n oauthProviderPlaceholders,\n resolveOAuthProvider,\n resolveOAuthUrl,\n} from '@ekanos/integration-schema';\nexport type {\n ResolveOAuthProviderResult,\n ResolveOAuthUrlResult,\n} from '@ekanos/integration-schema';\n\nexport type {\n IntegrationDefinition,\n IntegrationComponentDeclarations,\n ActivationDeclaration,\n ActivationFieldDeclaration,\n IntegrationProposals,\n IntegrationCapabilityDeclaration,\n IntegrationPermissionDeclaration,\n PartnerWidgetDeclaration,\n PartnerToolModule,\n PartnerToolParameters,\n // Widget-invoked server handlers (`actions`): the declaration type a\n // partner needs to export a handler shared between an action and a tool.\n PartnerActionDeclaration,\n ToolClassificationProposal,\n DefinitionCollisionInput,\n FirstPartyInventory,\n // Event surfaces (webhooks, schedules, OAuth): declared in the definition,\n // executed locally by the harness/testing helpers today; the host's real\n // transports (public ingress, scheduler, hosted OAuth callback) bind to\n // these exact declarations later with no partner code change.\n PartnerWebhookDeclaration,\n WebhookSignatureDeclaration,\n WebhookSignatureScheme,\n WebhookEvent,\n WebhookResult,\n // Agent events and channel (plan 222): events a webhook raises to start\n // agents, and the channel a run answers in.\n RaisedAgentEvent,\n PartnerAgentChannelDeclaration,\n AgentChannelRun,\n AgentEventDeclaration,\n AgentConversation,\n AgentTriggerFilter,\n AgentTriggerFilterField,\n AgentChannelReply,\n AgentChannelDeliveryResult,\n AgentChannelRunOutcome,\n AgentChannelHandoff,\n // Routing and Source connections (plan 241): one connection for a whole\n // Source, its events routed to teams by a key such as the organization.\n AgentRouteValue,\n AgentUnroutedEvent,\n RoutingDeclaration,\n RoutingKeyDeclaration,\n RouteKeyOption,\n SourceConnectionDeclaration,\n PartnerScheduleDeclaration,\n ScheduleInvocation,\n ScheduleResult,\n PartnerOAuthDeclaration,\n PartnerOAuthConnectionDeclaration,\n TeamAppDeclaration,\n OAuthProviderDeclaration,\n OAuthSetupDeclaration,\n OAuthTokens,\n // Activation lifecycle hook: cache seeding / eager validation at connect\n // time. Runs after first persist and after every activationData update;\n // v1 errors are non-fatal (logged as a warning, activation stays active).\n OnActivateHandler,\n // Each widget's verdict, computed on the server for home's Needs you.\n AttentionHandler,\n AttentionSignal,\n WidgetVerdict,\n WidgetVerdictTone,\n} from '@ekanos/integration-schema';\n"]}
@@ -4,4 +4,4 @@
4
4
  * one contract and no structural twin — F9). This file re-exports them under
5
5
  * `@ekanos/sdk/integration`.
6
6
  */
7
- export type { IntegrationDefinition, IntegrationComponentDeclarations, IntegrationProposals, IntegrationCapabilityDeclaration, IntegrationPermissionDeclaration, PartnerWidgetDeclaration, PartnerToolModule, PartnerToolParameters, ToolClassificationProposal, PartnerWebhookDeclaration, WebhookSignatureDeclaration, WebhookEvent, WebhookResult, PartnerScheduleDeclaration, ScheduleInvocation, ScheduleResult, PartnerOAuthDeclaration, OAuthProviderDeclaration, OAuthTokens, OnActivateHandler, AttentionHandler, } from '@ekanos/integration-schema';
7
+ export type { IntegrationDefinition, IntegrationComponentDeclarations, ActivationDeclaration, ActivationFieldDeclaration, IntegrationProposals, IntegrationCapabilityDeclaration, IntegrationPermissionDeclaration, PartnerWidgetDeclaration, PartnerToolModule, PartnerToolParameters, ToolClassificationProposal, PartnerWebhookDeclaration, WebhookSignatureDeclaration, WebhookEvent, WebhookResult, PartnerScheduleDeclaration, ScheduleInvocation, ScheduleResult, PartnerOAuthDeclaration, OAuthProviderDeclaration, OAuthTokens, OnActivateHandler, AttentionHandler, } from '@ekanos/integration-schema';
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/integration/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The partner authoring types are owned by `@ekanos/integration-schema` (the\n * dependency-pure package `@kit/integrations-core` also imports, so there is\n * one contract and no structural twin — F9). This file re-exports them under\n * `@ekanos/sdk/integration`.\n */\nexport type {\n IntegrationDefinition,\n IntegrationComponentDeclarations,\n IntegrationProposals,\n IntegrationCapabilityDeclaration,\n IntegrationPermissionDeclaration,\n PartnerWidgetDeclaration,\n PartnerToolModule,\n PartnerToolParameters,\n ToolClassificationProposal,\n PartnerWebhookDeclaration,\n WebhookSignatureDeclaration,\n WebhookEvent,\n WebhookResult,\n PartnerScheduleDeclaration,\n ScheduleInvocation,\n ScheduleResult,\n PartnerOAuthDeclaration,\n OAuthProviderDeclaration,\n OAuthTokens,\n OnActivateHandler,\n AttentionHandler,\n} from '@ekanos/integration-schema';\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/integration/types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The partner authoring types are owned by `@ekanos/integration-schema` (the\n * dependency-pure package `@kit/integrations-core` also imports, so there is\n * one contract and no structural twin — F9). This file re-exports them under\n * `@ekanos/sdk/integration`.\n */\nexport type {\n IntegrationDefinition,\n IntegrationComponentDeclarations,\n ActivationDeclaration,\n ActivationFieldDeclaration,\n IntegrationProposals,\n IntegrationCapabilityDeclaration,\n IntegrationPermissionDeclaration,\n PartnerWidgetDeclaration,\n PartnerToolModule,\n PartnerToolParameters,\n ToolClassificationProposal,\n PartnerWebhookDeclaration,\n WebhookSignatureDeclaration,\n WebhookEvent,\n WebhookResult,\n PartnerScheduleDeclaration,\n ScheduleInvocation,\n ScheduleResult,\n PartnerOAuthDeclaration,\n OAuthProviderDeclaration,\n OAuthTokens,\n OnActivateHandler,\n AttentionHandler,\n} from '@ekanos/integration-schema';\n"]}
@@ -68,11 +68,6 @@
68
68
 
69
69
  const FADED_MUTED = /(?:^|[\s:'"`])(?:[\w-]+:)*text-muted-foreground\/\d+/;
70
70
 
71
- /** `text-primary`, with any variant prefix or opacity step, but not
72
- * `text-primary-strong` or `text-primary-foreground`. */
73
- const BASE_PRIMARY_TEXT =
74
- /(?:^|[\s'"`])(?:\S*:)?text-primary(?:\/\d+)?(?=$|[\s'"`])/;
75
-
76
71
  /** `bg-white`, `text-black/50`, `dark:border-white`… — @shadcn/lint's
77
72
  * no-raw-colors covers the palette scales but not these two. */
78
73
  const ABSOLUTE_COLOR =
@@ -109,7 +104,8 @@ function stringVisitors(test, message) {
109
104
  * written family-less (`fa-gear`) so the theme's icon style reaches every one;
110
105
  * `fa-solid` / `fa-duotone` emphasis and `fa-brands` are deliberate and allowed.
111
106
  */
112
- const DEFAULT_ICON_FAMILY = /(?:^|[\s'"`])fa-(?:light|regular)\s+fa-[a-z0-9]/;
107
+ const DEFAULT_ICON_FAMILY =
108
+ /(?:^|[\s'"`])(?:fa-(?:light|regular|thin|duotone)\s+fa-[a-z0-9]|fa-solid\s+fa-(?!(?:circle|star|square|thumbtack)(?![a-z0-9-]))[a-z0-9])/;
113
109
 
114
110
  const BADGE_TONES = new Set(['success', 'warning', 'info']);
115
111
 
@@ -214,33 +210,6 @@ function isRoundedRowHover(value) {
214
210
  return !(height && width && height[1] === width[1]);
215
211
  }
216
212
 
217
- const CHIP_TONES = ['success', 'primary', 'warning', 'destructive', 'info'];
218
-
219
- // The two raw steps PLUS the three tiers that replaced them (the type scale:
220
- // `text-fine` and `text-eyebrow` are 12px, `text-meta` and `text-body-sm`
221
- // 14px/400, `text-label` 14px/500). Without
222
- // the tiers this rule went silently blind the moment the type-scale sweep
223
- // landed — five weak tinted chips stopped matching while looking identical.
224
- // Any rule keyed on a raw step has the same failure mode; check for it.
225
- //
226
- // `subhead-lg` (20px) and `headline-lg` (30px) are deliberately NOT here:
227
- // this is the SMALL-text set, and a chip at 20px is not a weak chip, it is a
228
- // mis-sized one. Re-check this list whenever a tier is added at 12 or 14px.
229
- const CHIP_SMALL_TEXT =
230
- /(?:^|\s)(?:[\w-]+:)*text-(?:xs|sm|fine|eyebrow|meta|body-sm|label)(?=$|\s)/;
231
-
232
- /** Base-tone small text on a tint of the same tone. */
233
- /** @param {string} value */
234
- function isWeakTintedChip(value) {
235
- if (!CHIP_SMALL_TEXT.test(value)) return false;
236
-
237
- return CHIP_TONES.some(
238
- (tone) =>
239
- new RegExp(`(?:^|\\s)(?:[\\w-]+:)*bg-${tone}/\\d+`).test(value) &&
240
- new RegExp(`(?:^|\\s)(?:[\\w-]+:)*text-${tone}(?![\\w-])`).test(value),
241
- );
242
- }
243
-
244
213
  /**
245
214
  * @param {(value: string) => boolean} predicate
246
215
  * @param {string} message
@@ -273,49 +242,22 @@ const VIEWPORT_BREAKPOINT =
273
242
  /(?:^|\s)(?:[\w-]+:)*(?:max-)?(?:sm|md|lg|xl|2xl):[^\s:]/;
274
243
 
275
244
  /**
276
- * A raw Tailwind type step in a class string, when the Ekanos type scale names
277
- * a tier for it.
245
+ * An arbitrary font size in a class string: `text-[13px]`, `text-[0.8rem]`,
246
+ * `text-[length:var(--x)]`. The app uses Tailwind's stock steps
247
+ * (`text-xs` … `text-9xl`) and nothing between them. `text-[#fff]` and
248
+ * `text-[color:var(--brand)]` are colours and pass.
278
249
  *
279
- * Three things the pattern has to get right, because a rule that cries wolf
280
- * on `text-muted-foreground` is turned off the same week:
281
- *
282
- * - only the thirteen SIZE steps, listed out. Every other `text-*` utility
283
- * — a colour (`text-primary`, `text-muted-foreground`), an alignment
284
- * (`text-center`), a wrap (`text-balance`), an overflow
285
- * (`text-ellipsis`), and the TIER names themselves — shares the prefix
286
- * and must pass. A tier is not in the list, so `text-subhead` never
287
- * matches, and neither do the `-lg` ranks: `text-subhead-lg` continues
288
- * past `text-` into a name the alternation does not hold, so there is
289
- * nothing for the trailing `(?=$|\s)` to anchor;
290
- * - an arbitrary value only when it is a SIZE: `text-[18px]`,
291
- * `text-[0.8rem]`, `text-[length:var(--x)]`. `text-[#fff]` and
292
- * `text-[color:var(--brand)]` are colours and pass;
293
- * - a variant chain in front of it (`sm:text-lg`, `2xl:text-2xl`,
294
- * `data-[state=open]:text-xs`). A chain always ends in `:` immediately
295
- * before `text-`, so the whole of it is covered by allowing `:` as the
296
- * left boundary — deliberately, rather than by matching the chain the way
297
- * the overlay-width rule does. That rule's nested `(?:…|…)+:)*` prefix
298
- * group backtracks exponentially on a long non-matching string; it gets
299
- * away with it because it only ever sees an overlay's `className`,
300
- * whereas this rule is handed EVERY string literal in the repo and took
301
- * oxlint from one second to over thirty minutes. The `-` excluded from
302
- * the boundary is what keeps it off `--text-lg` in a stylesheet string.
303
- *
304
- * Tailwind's `/leading` modifier (`text-sm/6`) rides along on the end.
250
+ * `:` is allowed as the left boundary so a variant chain (`sm:text-[15px]`)
251
+ * is covered without matching the chain itself: this rule sees every string
252
+ * literal in the repo, and a nested chain group backtracks exponentially on a
253
+ * long non-matching string. The `-` excluded from the boundary keeps it off
254
+ * `--text-[…]` in a stylesheet string.
305
255
  */
306
256
  const RAW_TEXT_SIZE =
307
- /(?:^|[\s:])text-(?:xs|sm|base|lg|xl|[2-9]xl|\[(?:length:[^\]]*|[\d.]+(?:rem|px|em|ex|ch|pt|pc|in|cm|mm|vw|vh|vmin|vmax|%))\])(?:\/[\w.[\]-]+)?(?=$|\s)/;
308
-
309
- // <type-scale> Generated from the Ekanos type-scale table by `pnpm type-scale`.
310
- const HEADING_FACE_TIER =
311
- /(?:^|[\s:])text-(?:display-lg|display|headline-lg|headline|subhead-lg)(?=$|\s)/;
312
-
313
- const HEADING_FACE_TIER_MESSAGE =
314
- 'A heading-face tier carries its face: write heading-display-lg | heading-display | heading-headline-lg | heading-headline | heading-subhead-lg instead of text-<tier> (with or without font-heading beside it). The heading-<tier> utility sets the face, size, leading, weight and tracking in one class (design-system type-scale rule).';
257
+ /(?:^|[\s:])text-\[(?:length:[^\]]*|[\d.]+(?:rem|px|em|ex|ch|pt|pc|in|cm|mm|vw|vh|vmin|vmax|%))\](?:\/[\w.[\]-]+)?(?=$|\s)/;
315
258
 
316
259
  const RAW_TEXT_SIZE_MESSAGE =
317
- 'A raw type step is not the scale. Use the Ekanos type-scale tier: heading-display-lg (48px/52, 700) | heading-display (36px/40, 700) | heading-headline-lg (30px/36, 700) | heading-headline (24px/32, 600) | heading-subhead-lg (20px/28, 600) | text-subhead (18px/28, 600) | text-title (16px/24, 600) | text-body (16px/24, 400) | text-body-sm (14px/20, 400) | text-label (14px/20, 500) | text-meta (14px/20, 400) | text-eyebrow (12px/16, 500) | text-fine (12px/16, 400). Each tier carries its leading and weight, so the font-* class beside the old step usually goes with it (design-system type-scale rule).';
318
- // </type-scale>
260
+ 'An arbitrary font size is not on the scale. Use a stock Tailwind step: text-xs | text-sm | text-base | text-lg | text-xl | text-2xl … text-9xl, with font-* and tracking-* beside it as needed (design-system type-scale rule).';
319
261
 
320
262
  const TOOLBAR_TAB_ELEMENTS = new Set(['TabsList', 'ScopePills', 'ScopeLinks']);
321
263
  const TOOLBARS = new Set(['PageToolbar', 'PageToolbarActions']);
@@ -349,20 +291,24 @@ function isRenderPropValue(node) {
349
291
  const CARD_FILL = /(?:^|\s)bg-card(?=$|\s)/;
350
292
  const CARD_CORNER = /(?:^|\s)rounded(?:-[\w[\]]+)?(?=$|\s)/;
351
293
  const CARD_EDGE =
352
- /(?:^|\s)(?:shadow-(?:ring|card|widget|xs|sm|md)|border(?:-border)?)(?=$|\s)/;
294
+ /(?:^|\s)(?:shadow-(?:ring|card|widget|xs|sm)|ring-foreground\/10|border(?:-border)?)(?=$|\s)/;
295
+ /** A floating layer (stock `shadow-md` / `shadow-lg`) is a popover or sheet, not a card. */
296
+ const FLOATING = /(?:^|\s)shadow-(?:md|lg)(?=$|\s)/;
353
297
 
354
298
  /** @param {string} value */
355
299
  function isHandDrawnCard(value) {
356
300
  return (
357
- CARD_FILL.test(value) && CARD_CORNER.test(value) && CARD_EDGE.test(value)
301
+ CARD_FILL.test(value) &&
302
+ CARD_CORNER.test(value) &&
303
+ CARD_EDGE.test(value) &&
304
+ !FLOATING.test(value)
358
305
  );
359
306
  }
360
307
 
361
308
  /**
362
309
  * Motion written outside the tokens (plan 253): a raw `duration-<ms>` step
363
310
  * or `transition-all`. Durations come from the motion tokens
364
- * (`duration-(--duration-enter)`, `-exit`, `-colour`, `-press`, `-release`,
365
- * `-spring`, `-sheet`), so one change re-times the product and the specimen's
311
+ * (`duration-(--duration-enter)`, `-exit`, `-colour`, `-spring`, `-sheet`), so one change re-times the product and the specimen's
366
312
  * slow-motion switch reaches every one; `transition-all` animates whatever
367
313
  * property changes next, layout included. Prefix variants ride along, and
368
314
  * `duration-0` (no motion at all) is allowed.
@@ -379,23 +325,14 @@ const HOVER_MOTION =
379
325
  /(?:^|\s)(?:[\w\-[\]/]+:)*(?:group-|peer-)?hover(?:\/[\w-]+)?:(?:[\w\-[\]]+:)*-?(?:scale|translate-[xy])-/;
380
326
 
381
327
  /**
382
- * A focus ring faded with an opacity step (plan 254): `focus-visible:ring-ring/50`
383
- * and the like. The ring token is solved to 3:1 on every surface at full
384
- * strength; an opacity step drops it below that, so the keyboard user loses
385
- * the only mark of where they are. Any variant chain naming `focus` counts.
386
- */
387
- const FADED_FOCUS_RING =
388
- /(?:^|[\s'"`])(?:[\w\-[\]&>*=]+:)*[\w\-[\]]*focus[\w\-[\]/]*:(?:[\w\-[\]]+:)*(?:ring|outline)-(?!offset-)[a-z][\w-]*\/\d+(?=$|[\s'"`])/;
389
-
390
- /**
391
- * A raw Tailwind shadow step (plan 254). Elevation comes from the shadow
392
- * vocabulary — `shadow-ring`, `-control`, `-popover`, `-modal`, `-sticky`,
393
- * `-rail` — whose tiers are drawn so a layer on top reads as on top in both
394
- * modes; `shadow-md` and its siblings are invisible on charcoal and pile on
395
- * in light. `shadow-none` is allowed.
328
+ * A raw Tailwind shadow step (plan 254). Elevation is stock shadcn's
329
+ * (owner, 2026-11-06): `ring-1 ring-foreground/10` for a card or dialog,
330
+ * `shadow-md` plus that ring for a float and `shadow-lg` for a sheet. A
331
+ * control's or a docked panel's edge is a `border`. Every other step is
332
+ * refused. `shadow-none` is allowed.
396
333
  */
397
334
  const RAW_SHADOW =
398
- /(?:^|[\s'"`])(?:[\w\-[\]&>*=/]+:)*!?shadow-(?:2xs|xs|sm|md|lg|xl|2xl|inner|\[[^\s'"`]+\])(?=$|[\s'"`])/;
335
+ /(?:^|[\s'"`])(?:[\w\-[\]&>*=/]+:)*!?shadow-(?:2xs|xs|sm|xl|2xl|inner|\[[^\s'"`]+\])(?=$|[\s'"`])/;
399
336
 
400
337
  /**
401
338
  * The words a steady, healthy state is labelled with. "Healthy" is the
@@ -514,7 +451,7 @@ export default {
514
451
  },
515
452
  create: stringVisitors(
516
453
  RAW_MOTION,
517
- 'Time motion with a token, not a raw step: duration-(--duration-enter) for an entrance, -exit for an exit, -colour for a colour change, -press / -release for a press, -spring, -sheet; or a press-* recipe for a pressable. Name the properties (transition-colors, transition-[opacity,translate]) instead of transition-all, which also animates layout (plan 253).',
454
+ 'Time motion with a token, not a raw step: duration-(--duration-enter) for an entrance, -exit for an exit, -colour for a colour change, -spring, -sheet. Name the properties (transition-colors, transition-[opacity,translate]) instead of transition-all, which also animates layout (plan 253).',
518
455
  ),
519
456
  },
520
457
  'no-hover-motion': {
@@ -527,20 +464,7 @@ export default {
527
464
  },
528
465
  create: stringVisitors(
529
466
  HOVER_MOTION,
530
- 'Hover changes colour only: no scale and no translate under hover:, group-hover: or peer-hover:. An interactive card darkens its ring and steps its surface (cardSurfaceVariants({ interactive: true })); a control answers the press, not the hover, through a press-* recipe (plan 251 D42, plan 253).',
531
- ),
532
- },
533
- 'no-faded-focus-ring': {
534
- meta: {
535
- type: 'problem',
536
- docs: {
537
- description:
538
- 'Disallow an opacity step on a focus ring or outline colour; the ring is drawn at full strength.',
539
- },
540
- },
541
- create: stringVisitors(
542
- FADED_FOCUS_RING,
543
- 'Draw the focus ring at full strength: focus-visible:ring-ring (or outline-ring), never ring-ring/50. The ring token is solved to 3:1 on every surface, and an opacity step drops it below that (the Inputs rule).',
467
+ 'Hover changes colour only: no scale and no translate under hover:, group-hover: or peer-hover:. An interactive card darkens its ring and steps its surface (cardSurfaceVariants({ interactive: true })); a Button answers the press, not the hover (plan 251 D42).',
544
468
  ),
545
469
  },
546
470
  'shadow-tokens': {
@@ -553,7 +477,7 @@ export default {
553
477
  },
554
478
  create: stringVisitors(
555
479
  RAW_SHADOW,
556
- 'Use the shadow vocabulary, not a raw step: shadow-ring for a card or container, shadow-control for a field or button edge, shadow-popover for a menu, popover or tooltip, shadow-modal for a dialog or sheet, shadow-sticky / shadow-rail for one edge. A surface never lifts on hover: darken its ring instead (the Stacking rule).',
480
+ 'Use stock shadcn elevation, not another raw step: ring-1 ring-foreground/10 for a card, dialog or container; shadow-md ring-1 ring-foreground/10 for a menu or popover; shadow-lg for a sheet; a border for a field, button, sticky header or docked rail. A surface never lifts on hover: darken its ring instead (hover:ring-foreground/20).',
557
481
  ),
558
482
  },
559
483
  'no-tone-badge-variant': {
@@ -678,19 +602,6 @@ export default {
678
602
  'Opacity on text-muted-foreground fails WCAG AA: even /90 measures 4.18:1 on a dark card. Use plain text-muted-foreground, a smaller size if it must recede, or text-border for a decorative separator (design-system opacity-on-muted rule).',
679
603
  ),
680
604
  },
681
- 'no-base-primary-text': {
682
- meta: {
683
- type: 'problem',
684
- docs: {
685
- description:
686
- 'Disallow text-primary; the base primary is a 3:1 mark, and teal text or icons use text-primary-strong.',
687
- },
688
- },
689
- create: stringVisitors(
690
- BASE_PRIMARY_TEXT,
691
- 'text-primary is a 3:1 mark colour and reads faint on a light page. Teal text or an icon that marks the action, where you are or a live state takes text-primary-strong; anything else is ink (text-foreground) or text-muted-foreground. A link is buttonVariants({ variant: "link" }); an icon tile is <IconTile> (design-system Strong-Step and Earned Attention rules).',
692
- ),
693
- },
694
605
  'no-absolute-colors': {
695
606
  meta: {
696
607
  type: 'problem',
@@ -709,12 +620,12 @@ export default {
709
620
  type: 'problem',
710
621
  docs: {
711
622
  description:
712
- 'Disallow fa-light / fa-regular in an icon name; write it family-less so the theme decides.',
623
+ 'Disallow a family in an icon name; write it family-less so the theme decides.',
713
624
  },
714
625
  },
715
626
  create: stringVisitors(
716
627
  DEFAULT_ICON_FAMILY,
717
- 'Write the icon family-less (`fa-gear`, not `fa-light fa-gear`): the theme decides the family, regular by default or a Source’s icon style, so a family written here is one more icon a re-brand cannot reach. `fa-solid` / `fa-duotone` for deliberate emphasis and `fa-brands` stay (plan 251 D44).',
628
+ 'Write the icon family-less (`fa-gear`, not `fa-solid fa-gear`): every icon draws in one family, regular by default or a Source’s icon style, and a family written here is ignored. Only `fa-brands` and a filled state glyph (`fa-solid fa-circle`, `fa-star`, `fa-square`, `fa-thumbtack`) keep theirs (plan 251 D44).',
718
629
  ),
719
630
  },
720
631
  'no-overlay-width-class': {
@@ -767,20 +678,7 @@ export default {
767
678
  },
768
679
  create: predicateVisitors(
769
680
  isRoundedRowHover,
770
- 'Rows are flat edge-to-edge bands: padding on the row (px-5 py-3), a flat hover:bg-accent/50, never a rounded pill with side padding (design-system edge-to-edge rows rule).',
771
- ),
772
- },
773
- 'tinted-chip-strong': {
774
- meta: {
775
- type: 'problem',
776
- docs: {
777
- description:
778
- 'Require the -strong text step for small text on a tint of its own colour.',
779
- },
780
- },
781
- create: predicateVisitors(
782
- isWeakTintedChip,
783
- 'Small text on a tint of its own colour takes the -strong step: text-success-strong on bg-success/10, text-primary-strong on bg-primary/10. The base token fails AA once it sits on its own wash; it stays right for the fill and for icons (design-system tinted-chip rule).',
681
+ 'Rows are flat edge-to-edge bands: padding on the row (px-5 py-3), a flat hover:bg-muted, never a rounded pill with side padding (design-system edge-to-edge rows rule).',
784
682
  ),
785
683
  },
786
684
  'no-viewport-breakpoints-in-widgets': {
@@ -833,33 +731,10 @@ export default {
833
731
  type: 'problem',
834
732
  docs: {
835
733
  description:
836
- 'Disallow a raw Tailwind type step, or a heading-face tier spelled text-<tier>; one scale of tiers, each carrying its leading, weight and face.',
734
+ 'Disallow an arbitrary font size; the app uses the stock Tailwind type steps.',
837
735
  },
838
736
  },
839
- /** @param {RuleContext} context */
840
- create(context) {
841
- const raw = stringVisitors(
842
- RAW_TEXT_SIZE,
843
- RAW_TEXT_SIZE_MESSAGE,
844
- )(context);
845
- const face = stringVisitors(
846
- HEADING_FACE_TIER,
847
- HEADING_FACE_TIER_MESSAGE,
848
- )(context);
849
-
850
- return {
851
- /** @param {StringLiteral} node */
852
- Literal: (node) => {
853
- raw.Literal(node);
854
- face.Literal(node);
855
- },
856
- /** @param {TemplateChunk} node */
857
- TemplateElement: (node) => {
858
- raw.TemplateElement(node);
859
- face.TemplateElement(node);
860
- },
861
- };
862
- },
737
+ create: stringVisitors(RAW_TEXT_SIZE, RAW_TEXT_SIZE_MESSAGE),
863
738
  },
864
739
  'no-raw-button': {
865
740
  meta: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekanos/sdk",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "private": false,
5
5
  "description": "The official SDK for building Ekanos integrations.",
6
6
  "homepage": "https://sdk.ekanos.dev/sdk/overview",
@@ -114,8 +114,8 @@
114
114
  "access": "public"
115
115
  },
116
116
  "dependencies": {
117
- "@ekanos/integration-schema": "0.23.0",
118
- "@ekanos/ui": "0.23.0",
117
+ "@ekanos/integration-schema": "0.24.0",
118
+ "@ekanos/ui": "0.24.0",
119
119
  "@supabase/supabase-js": "2.118.0",
120
120
  "server-only": "^0.0.1",
121
121
  "zod-to-json-schema": "3.25.2"