@ekanos/sdk 0.19.0 → 0.20.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 (32) hide show
  1. package/api-report.md +23 -4
  2. package/dist/components/base-activation-dialog.js +1 -1
  3. package/dist/components/base-activation-dialog.js.map +1 -1
  4. package/dist/components/current-return-path.d.ts +16 -1
  5. package/dist/components/current-return-path.js +18 -1
  6. package/dist/components/current-return-path.js.map +1 -1
  7. package/dist/components/index.d.ts +1 -1
  8. package/dist/components/index.js +1 -1
  9. package/dist/components/index.js.map +1 -1
  10. package/dist/components/oauth-activation-form.js +2 -2
  11. package/dist/components/oauth-activation-form.js.map +1 -1
  12. package/dist/components/widgets/ai-prompt-chip.js +1 -1
  13. package/dist/components/widgets/ai-prompt-chip.js.map +1 -1
  14. package/dist/components/widgets/widget-ask-bar.js +2 -2
  15. package/dist/components/widgets/widget-ask-bar.js.map +1 -1
  16. package/dist/components/widgets/widget-state-components.js +1 -1
  17. package/dist/components/widgets/widget-state-components.js.map +1 -1
  18. package/dist/components/widgets/widget.js +2 -2
  19. package/dist/components/widgets/widget.js.map +1 -1
  20. package/dist/experience/define-experience.d.ts +69 -4
  21. package/dist/experience/define-experience.js +48 -8
  22. package/dist/experience/define-experience.js.map +1 -1
  23. package/dist/experience/index.d.ts +2 -1
  24. package/dist/experience/index.js +1 -0
  25. package/dist/experience/index.js.map +1 -1
  26. package/dist/hooks/use-oauth-connection-status.d.ts +7 -217
  27. package/dist/hooks/use-oauth-connection-status.js +17 -1
  28. package/dist/hooks/use-oauth-connection-status.js.map +1 -1
  29. package/dist/types/integration.d.ts +3 -3
  30. package/dist/types/integration.js.map +1 -1
  31. package/eslint.design-rules.mjs +18 -0
  32. package/package.json +3 -3
@@ -40,137 +40,6 @@ export interface UseOAuthConnectionStatusOptions {
40
40
  * connected without a manual refresh.
41
41
  */
42
42
  export declare function useOAuthConnectionStatus(accountId: string, options: UseOAuthConnectionStatusOptions): {
43
- dataUpdatedAt: number;
44
- errorUpdatedAt: number;
45
- failureCount: number;
46
- failureReason: Error | null;
47
- errorUpdateCount: number;
48
- isFetched: boolean;
49
- isFetchedAfterMount: boolean;
50
- isFetching: boolean;
51
- isInitialLoading: boolean;
52
- isPaused: boolean;
53
- isRefetching: boolean;
54
- isStale: boolean;
55
- isEnabled: boolean;
56
- refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
57
- isConnected: boolean;
58
- error: string | undefined;
59
- obtainedAt?: undefined;
60
- } | {
61
- error?: undefined;
62
- isConnected: boolean;
63
- obtainedAt: string | null | undefined;
64
- }, Error>>;
65
- fetchStatus: import("@tanstack/react-query").FetchStatus;
66
- data: undefined;
67
- error: Error;
68
- isError: true;
69
- isPending: false;
70
- isLoading: false;
71
- isLoadingError: true;
72
- isRefetchError: false;
73
- isSuccess: false;
74
- isPlaceholderData: false;
75
- status: 'error';
76
- oauthJustCompleted: boolean;
77
- oauthError: string | null;
78
- } | {
79
- dataUpdatedAt: number;
80
- errorUpdatedAt: number;
81
- failureCount: number;
82
- failureReason: Error | null;
83
- errorUpdateCount: number;
84
- isFetched: boolean;
85
- isFetchedAfterMount: boolean;
86
- isFetching: boolean;
87
- isInitialLoading: boolean;
88
- isPaused: boolean;
89
- isRefetching: boolean;
90
- isStale: boolean;
91
- isEnabled: boolean;
92
- refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
93
- isConnected: boolean;
94
- error: string | undefined;
95
- obtainedAt?: undefined;
96
- } | {
97
- error?: undefined;
98
- isConnected: boolean;
99
- obtainedAt: string | null | undefined;
100
- }, Error>>;
101
- fetchStatus: import("@tanstack/react-query").FetchStatus;
102
- data: undefined;
103
- error: null;
104
- isError: false;
105
- isPending: true;
106
- isLoading: true;
107
- isLoadingError: false;
108
- isRefetchError: false;
109
- isSuccess: false;
110
- isPlaceholderData: false;
111
- status: 'pending';
112
- oauthJustCompleted: boolean;
113
- oauthError: string | null;
114
- } | {
115
- dataUpdatedAt: number;
116
- errorUpdatedAt: number;
117
- failureCount: number;
118
- failureReason: Error | null;
119
- errorUpdateCount: number;
120
- isFetched: boolean;
121
- isFetchedAfterMount: boolean;
122
- isFetching: boolean;
123
- isLoading: boolean;
124
- isInitialLoading: boolean;
125
- isPaused: boolean;
126
- isRefetching: boolean;
127
- isStale: boolean;
128
- isEnabled: boolean;
129
- refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
130
- isConnected: boolean;
131
- error: string | undefined;
132
- obtainedAt?: undefined;
133
- } | {
134
- error?: undefined;
135
- isConnected: boolean;
136
- obtainedAt: string | null | undefined;
137
- }, Error>>;
138
- fetchStatus: import("@tanstack/react-query").FetchStatus;
139
- data: undefined;
140
- error: null;
141
- isError: false;
142
- isPending: true;
143
- isLoadingError: false;
144
- isRefetchError: false;
145
- isSuccess: false;
146
- isPlaceholderData: false;
147
- status: 'pending';
148
- oauthJustCompleted: boolean;
149
- oauthError: string | null;
150
- } | {
151
- dataUpdatedAt: number;
152
- errorUpdatedAt: number;
153
- failureCount: number;
154
- failureReason: Error | null;
155
- errorUpdateCount: number;
156
- isFetched: boolean;
157
- isFetchedAfterMount: boolean;
158
- isFetching: boolean;
159
- isInitialLoading: boolean;
160
- isPaused: boolean;
161
- isRefetching: boolean;
162
- isStale: boolean;
163
- isEnabled: boolean;
164
- refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
165
- isConnected: boolean;
166
- error: string | undefined;
167
- obtainedAt?: undefined;
168
- } | {
169
- error?: undefined;
170
- isConnected: boolean;
171
- obtainedAt: string | null | undefined;
172
- }, Error>>;
173
- fetchStatus: import("@tanstack/react-query").FetchStatus;
174
43
  data: {
175
44
  isConnected: boolean;
176
45
  error: string | undefined;
@@ -179,76 +48,16 @@ export declare function useOAuthConnectionStatus(accountId: string, options: Use
179
48
  error?: undefined;
180
49
  isConnected: boolean;
181
50
  obtainedAt: string | null | undefined;
182
- };
183
- isError: false;
184
- error: null;
185
- isPending: false;
186
- isLoading: false;
187
- isLoadingError: false;
188
- isRefetchError: false;
189
- isSuccess: true;
190
- isPlaceholderData: true;
191
- status: 'success';
192
- oauthJustCompleted: boolean;
193
- oauthError: string | null;
194
- } | {
195
- dataUpdatedAt: number;
196
- errorUpdatedAt: number;
197
- failureCount: number;
198
- failureReason: Error | null;
199
- errorUpdateCount: number;
200
- isFetched: boolean;
201
- isFetchedAfterMount: boolean;
51
+ } | undefined;
52
+ error: Error | null;
53
+ status: "error" | "pending" | "success";
54
+ isPending: boolean;
55
+ isLoading: boolean;
56
+ isError: boolean;
57
+ isSuccess: boolean;
202
58
  isFetching: boolean;
203
- isInitialLoading: boolean;
204
- isPaused: boolean;
205
59
  isRefetching: boolean;
206
- isStale: boolean;
207
- isEnabled: boolean;
208
- refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
209
- isConnected: boolean;
210
- error: string | undefined;
211
- obtainedAt?: undefined;
212
- } | {
213
- error?: undefined;
214
- isConnected: boolean;
215
- obtainedAt: string | null | undefined;
216
- }, Error>>;
217
- fetchStatus: import("@tanstack/react-query").FetchStatus;
218
- data: {
219
- isConnected: boolean;
220
- error: string | undefined;
221
- obtainedAt?: undefined;
222
- } | {
223
- error?: undefined;
224
- isConnected: boolean;
225
- obtainedAt: string | null | undefined;
226
- };
227
- error: Error;
228
- isError: true;
229
- isPending: false;
230
- isLoading: false;
231
- isLoadingError: false;
232
- isRefetchError: true;
233
- isSuccess: false;
234
- isPlaceholderData: false;
235
- status: 'error';
236
- oauthJustCompleted: boolean;
237
- oauthError: string | null;
238
- } | {
239
60
  dataUpdatedAt: number;
240
- errorUpdatedAt: number;
241
- failureCount: number;
242
- failureReason: Error | null;
243
- errorUpdateCount: number;
244
- isFetched: boolean;
245
- isFetchedAfterMount: boolean;
246
- isFetching: boolean;
247
- isInitialLoading: boolean;
248
- isPaused: boolean;
249
- isRefetching: boolean;
250
- isStale: boolean;
251
- isEnabled: boolean;
252
61
  refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
253
62
  isConnected: boolean;
254
63
  error: string | undefined;
@@ -258,25 +67,6 @@ export declare function useOAuthConnectionStatus(accountId: string, options: Use
258
67
  isConnected: boolean;
259
68
  obtainedAt: string | null | undefined;
260
69
  }, Error>>;
261
- fetchStatus: import("@tanstack/react-query").FetchStatus;
262
- data: {
263
- isConnected: boolean;
264
- error: string | undefined;
265
- obtainedAt?: undefined;
266
- } | {
267
- error?: undefined;
268
- isConnected: boolean;
269
- obtainedAt: string | null | undefined;
270
- };
271
- error: null;
272
- isError: false;
273
- isPending: false;
274
- isLoading: false;
275
- isLoadingError: false;
276
- isRefetchError: false;
277
- isSuccess: true;
278
- isPlaceholderData: false;
279
- status: 'success';
280
70
  oauthJustCompleted: boolean;
281
71
  oauthError: string | null;
282
72
  };
@@ -75,7 +75,23 @@ export function useOAuthConnectionStatus(accountId, options) {
75
75
  errorParamName,
76
76
  queryClient,
77
77
  ]);
78
- return Object.assign(Object.assign({}, query), { oauthJustCompleted, oauthError });
78
+ // Named, not spread: spreading a query result reads every field, so
79
+ // the component re-renders on all of them (TanStack render optimizations).
80
+ return {
81
+ data: query.data,
82
+ error: query.error,
83
+ status: query.status,
84
+ isPending: query.isPending,
85
+ isLoading: query.isLoading,
86
+ isError: query.isError,
87
+ isSuccess: query.isSuccess,
88
+ isFetching: query.isFetching,
89
+ isRefetching: query.isRefetching,
90
+ dataUpdatedAt: query.dataUpdatedAt,
91
+ refetch: query.refetch,
92
+ oauthJustCompleted,
93
+ oauthError,
94
+ };
79
95
  }
80
96
  /** Pure: the gate options a slug implies. Exported for tests and for widgets that need the key. */
81
97
  export function oauthWidgetGateOptionsFor(slug) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-oauth-connection-status.js","sourceRoot":"","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,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 return { ...query, oauthJustCompleted, oauthError };\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,E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AI,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"]}
@@ -135,7 +135,7 @@ export interface IntegrationMetadata {
135
135
  * omission. An Integration is any package extending `BaseIntegration`; its
136
136
  * kind says who turns it on and whether it needs credentials:
137
137
  *
138
- * 'experience' — an Ekanos-native capability. Enabled for a Source by a
138
+ * 'feature' — an Ekanos-native capability. Enabled for a Source by a
139
139
  * super-admin; no third-party credentials, no activation flow, no
140
140
  * marketplace tile. Always declares its own top-level sidebar Section
141
141
  * via `getSidebarNav()` and NEVER declares `getWorkspaceTargets()` —
@@ -151,7 +151,7 @@ export interface IntegrationMetadata {
151
151
  * a Feature MUST declare a Section and MUST NOT declare a Workspace; a
152
152
  * connector MAY declare either or both.
153
153
  */
154
- kind: 'experience' | 'integration';
154
+ kind: 'feature' | 'integration';
155
155
  /**
156
156
  * Product slugs that MUST be attached to the same Source for this product to
157
157
  * function — a hard dependency, not a suggestion.
@@ -161,7 +161,7 @@ export interface IntegrationMetadata {
161
161
  * the dependency in both directions ("Requires X" / "Enables Y").
162
162
  *
163
163
  * Host CI enforces: every slug is registered, nothing requires itself, no
164
- * cycles, and a `kind: 'experience'` may require a `'integration'` but never
164
+ * cycles, and a `kind: 'feature'` may require a `'integration'` but never
165
165
  * the reverse.
166
166
  */
167
167
  requires?: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"integration.js","sourceRoot":"","sources":["../../src/types/integration.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentType } from 'react';\n\nimport type { IconRenderer } from './icon';\n\n// Capability shown on the integration detail page (numbered grid)\nexport interface IntegrationCapability {\n label: string;\n description: string;\n icon?: IconRenderer;\n}\n\n// Permission scope shown on the integration detail page\nexport interface IntegrationPermission {\n label: string;\n detail: string;\n type: 'read' | 'write';\n}\n\n// ---- Integration Health Monitoring (issue #474) -----------------------------\n\n// Higher = healthier. Used internally for \"least healthy wins\" merging.\nexport type HealthStatus = 'healthy' | 'degraded' | 'unhealthy' | 'unknown';\n\n/**\n * Result returned by `BaseIntegration.healthCheck(accountId)`. Routed through\n * `classifyHealth()` (server-side) before writing to\n * `integration_health_status`.\n */\nexport interface HealthCheckResult {\n status: HealthStatus;\n errorCode?: string;\n errorMessage?: string;\n /** Rolling 24h error rate from `account_product_usage_events`, 0..100. */\n errorRatePct?: number;\n /** Sample size used to compute errorRatePct; if below threshold, treated as unknown. */\n sampleSize?: number;\n /** Whether the most recent observed call succeeded. */\n lastObservationSucceeded?: boolean;\n /** Token/credential expiry, if known. Drives token-expiry warnings. */\n tokenExpiresAt?: string;\n /** Free-form per-integration data carried to the dashboard. */\n metadata?: Record<string, unknown>;\n}\n\n// Activation result from integration\nexport interface ActivationResult {\n success: boolean;\n configData?: Record<string, unknown>;\n externalId?: string;\n errorMessage?: string;\n metadata?: Record<string, unknown>;\n}\n\n// Base props that all integration components need\ninterface BaseIntegrationComponentProps {\n accountId: string;\n sourceId?: string;\n integrationConfig?: Record<string, unknown>;\n}\n\n// Discriminated union for product reference - only one allowed\ntype ProductReference =\n | { productId: string; productSlug?: never }\n | { productSlug: string; productId?: never };\n\n// New base type using discriminated union\nexport type IntegrationComponentProps = BaseIntegrationComponentProps &\n ProductReference;\n\n// Marketplace tile props\nexport type MarketplaceTileProps = IntegrationComponentProps & {\n onActivate?: () => void;\n isActivated?: boolean;\n /** Navigation URL for the integration detail page */\n href?: string;\n};\n\n// Activation form props\nexport type ActivationFormProps = IntegrationComponentProps & {\n onSuccess?: (result: ActivationResult) => void;\n onCancel?: () => void;\n isLoading?: boolean;\n /** Render inline instead of in a dialog */\n inline?: boolean;\n /**\n * The integration is already connected and the person chose to connect it\n * again — after a token expired, a password changed, or a health check\n * failed. An OAuth form sends them through sign-in even when a token is\n * stored; a credential form simply accepts new values. Activating again\n * resets the integration's health to unknown until the next check.\n */\n reconnect?: boolean;\n /**\n * The TEAM account context the user is activating within — separate from\n * `accountId`, which for `scope: 'user'` integrations is collapsed to the\n * personal account for activation storage/token purposes. Only consumed by\n * workspace materialization (`materializeWorkspaceOnActivation`), never for\n * activation/token storage itself (plan 009 Part A2). Optional: undefined\n * for team-scoped integrations (their `accountId` already IS the team) and\n * for any caller that hasn't threaded it yet — the server action falls back\n * to `accountId` when absent.\n */\n teamAccountId?: string;\n};\n\n// Integration metadata\nexport interface IntegrationMetadata {\n productId: string;\n productSlug: string;\n integrationName: string;\n description: string;\n category: string;\n version: string;\n icon?: string;\n /** Bundled logo URL — overrides product.logo_path on the marketplace */\n logoPath?: string;\n /** When 'user', activation data is stored under the user's personal account (user.id) instead of the team account */\n scope?: 'user' | 'team';\n /**\n * Set FALSE to assert this integration has NO self-serve activation surface —\n * the marketplace detail page then renders no activation form at all.\n *\n * This is deliberately distinct from \"has no CUSTOM activation form\": an\n * integration that omits `getActivationForm()` still gets the generic one, and\n * six integrations depend on that. Use this flag only when submitting ANY\n * activation form would be a dead end — where `activate()` cannot succeed, so\n * showing a form hands the user a button that cannot work.\n * Undefined/true = normal self-serve activation.\n */\n selfServeActivation?: boolean;\n /**\n * How this integration's MCP tools resolve credentials — the integration's\n * SELF-DECLARATION of machine-executability, consumed dynamically by the\n * workflow engine's fail-closed tool allowlist (isGatewayExposableTool).\n *\n * 'account' — credentials/identity resolve from team- or source-level\n * config via the ToolContext (`getAccountId(ctx)` + `ctx.supabase`).\n * Safe for durable machine-principal execution (workflows): eligible\n * tools (read + public/internal sensitivity) become workflow-callable.\n * 'user' — credentials or identity are personal (ctx.user.id, personal\n * OAuth, session reads like getSupabaseServerClient()/requireUser()).\n * NEVER machine-executable: a workflow would silently ride one\n * employee's personal grant.\n * 'source' — platform-level credentials (diagnostics-class integrations).\n * Not exposed to account workflows.\n *\n * UNDECLARED = fail closed (treated as not machine-executable). Declaring\n * 'account' is a security assertion: the integration's MCP run() handlers\n * must use ctx-based resolution ONLY — no session clients, no personal\n * grants. A guard test in @kit/integrations-workflows enforces the obvious\n * violations (session-client reads in mcp/ code of 'account' declarers).\n */\n credentialModel?: 'account' | 'user' | 'source';\n /**\n * Which KIND of integration this is. **Required** — nothing is inferred from\n * omission. An Integration is any package extending `BaseIntegration`; its\n * kind says who turns it on and whether it needs credentials:\n *\n * 'experience' — an Ekanos-native capability. Enabled for a Source by a\n * super-admin; no third-party credentials, no activation flow, no\n * marketplace tile. Always declares its own top-level sidebar Section\n * via `getSidebarNav()` and NEVER declares `getWorkspaceTargets()` —\n * its widgets have no Workspace of their own, so an admin places them\n * on one in the composer (`/admin/sources/[id]/layout`).\n * 'integration' — a connection to an outside system. Made available to a\n * Source by a super-admin, then connected by a team or user (usually\n * OAuth/SSO); has credentials, an activation flow and a marketplace\n * tile. Declares a Workspace via `getWorkspaceTargets()`, a top-level\n * Section via `getSidebarNav()`, or both (Centrex does both).\n *\n * The asymmetry is one-directional and enforced by the host's CI:\n * a Feature MUST declare a Section and MUST NOT declare a Workspace; a\n * connector MAY declare either or both.\n */\n kind: 'experience' | 'integration';\n /**\n * Product slugs that MUST be attached to the same Source for this product to\n * function — a hard dependency, not a suggestion.\n *\n * The host REFUSES to attach this product to a Source missing any of them,\n * and refuses a detach that would strand a dependent. Admin surfaces render\n * the dependency in both directions (\"Requires X\" / \"Enables Y\").\n *\n * Host CI enforces: every slug is registered, nothing requires itself, no\n * cycles, and a `kind: 'experience'` may require a `'integration'` but never\n * the reverse.\n */\n requires?: string[];\n}\n\n// Widget configuration\nexport interface WidgetConfig {\n id: string;\n name: string;\n component: ComponentType<IntegrationComponentProps>;\n gridSize?: { cols: number; rows: number } | { cols: number; rows: number }[];\n gridPosition?: { col: number; row: number };\n widgetState: 'active' | 'inactive' | 'disabled';\n /**\n * `compact` (a figure tile, 1 → 2 → 4 across its row), `half` or `full`\n * (the design system's widget rules). Unset, it is derived from `layouts.lg.w`.\n */\n size?: 'compact' | 'half' | 'full';\n // React-grid-layout format\n layouts?: {\n lg?: { x: number; y: number; w: number; h: number; maxHeight?: number };\n md?: { x: number; y: number; w: number; h: number; maxHeight?: number };\n sm?: { x: number; y: number; w: number; h: number; maxHeight?: number };\n };\n // Integration metadata for widgets\n integrationMetadata?: IntegrationMetadata;\n category?: { id: string; name: string; slug: string; icon: string | null };\n // Database product ID (UUID) from widget_config table\n productId?: string;\n isCollapsible?: boolean;\n // For collapsed state persistence\n collapsed?: boolean;\n widgetConfigId?: string;\n // Resolved workspace placement (explicit widget_config.workspace_id\n // override, else the product's inheriting attachment). Populated by the\n // dashboard widgets loader; null = no workspace (unscoped dashboard).\n workspaceId?: string | null;\n isPinnable?: boolean;\n isPinned?: boolean;\n // When true, the dashboard renders the \"Ask about this\" AI footer bar for\n // this widget. The widget may still pass `askContext` to the wrapper for a\n // rich snapshot; otherwise a minimal default is used.\n aiFooterEnabled?: boolean;\n // Integration health for this widget's product. `unhealthy` downgrades the\n // widget to `disabled`; `degraded` surfaces a stale-data footer.\n health?: {\n status: HealthStatus;\n lastSuccessAt?: string | null;\n errorMessage?: string | null;\n };\n}\n\n// Database types for integration tables.\n//\n// PARTNER-VISIBLE SUBSET: these row types deliberately OMIT `vault_secret_id`.\n// A vault id is a host handle to a decryptable secret; the partner surface\n// never exposes one — `ctx.secrets` fences it off. Host code keeps the full\n// row because it needs the handle; a parity test pins the SDK type as the\n// host's row minus exactly the host-only fields, so a new column cannot drift\n// in here unnoticed.\nexport interface IntegrationConfig {\n id: string;\n account_id: string | null;\n product_id: string;\n config_type: 'api_credentials' | 'activation_data' | 'settings';\n config_data: Record<string, unknown>;\n status: 'active' | 'inactive' | 'pending' | 'error' | 'suspended';\n is_active: boolean;\n created_at: string;\n updated_at: string;\n created_by: string | null;\n updated_by: string | null;\n}\n\n/**\n * The PARTNER-VISIBLE `data_type` values on `account_product_data` — a strict\n * SUBSET of `@kit/integrations-core`'s union.\n *\n * `'secret'` is deliberately absent. Secret rows are host-managed (one row per\n * secret name, value in Vault, `vault_secret_id` on the row), written only by\n * the capability context's `persistSecret` and read only through\n * `ctx.secrets`. Naming the kind here would advertise a row shape partner code\n * must never address: `ctx.storage` rejects it, and core's generic accessors\n * reject it too (`config-utils.ts`, `assertNotHostOnlyDataType`) precisely\n * because a write there would land the plaintext in the `data` column.\n *\n * When you add an integration-specific kind, add it in BOTH places (core owns\n * the full union) and keep this one partner-appropriate. Prefer `dataSubtype`\n * for orthogonal slicing within a kind (e.g. `data_type='cache'`,\n * `data_subtype='profile'`); reserve a new top-level kind for data that has a\n * distinct lifecycle or is queried independently.\n */\nexport type AccountProductDataType =\n | 'activation'\n | 'settings'\n | 'metrics_summary'\n | 'sync_state'\n | 'cache'\n // Integration-specific kinds — extend here when needed.\n | 'cash_forecast' // quickbooks — user-supplied manual cash-forecast estimates\n | 'tax_config'; // quickbooks — per-user federal/state tax rate config\n\nexport interface AccountProductData {\n id: string;\n account_id: string;\n product_id: string;\n data_type: AccountProductDataType;\n data_subtype?: string;\n data: Record<string, unknown>;\n expires_at?: string;\n integration_config_id?: string;\n external_id?: string;\n created_at: string;\n updated_at: string;\n created_by: string | null;\n updated_by: string | null;\n}\n"]}
1
+ {"version":3,"file":"integration.js","sourceRoot":"","sources":["../../src/types/integration.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentType } from 'react';\n\nimport type { IconRenderer } from './icon';\n\n// Capability shown on the integration detail page (numbered grid)\nexport interface IntegrationCapability {\n label: string;\n description: string;\n icon?: IconRenderer;\n}\n\n// Permission scope shown on the integration detail page\nexport interface IntegrationPermission {\n label: string;\n detail: string;\n type: 'read' | 'write';\n}\n\n// ---- Integration Health Monitoring (issue #474) -----------------------------\n\n// Higher = healthier. Used internally for \"least healthy wins\" merging.\nexport type HealthStatus = 'healthy' | 'degraded' | 'unhealthy' | 'unknown';\n\n/**\n * Result returned by `BaseIntegration.healthCheck(accountId)`. Routed through\n * `classifyHealth()` (server-side) before writing to\n * `integration_health_status`.\n */\nexport interface HealthCheckResult {\n status: HealthStatus;\n errorCode?: string;\n errorMessage?: string;\n /** Rolling 24h error rate from `account_product_usage_events`, 0..100. */\n errorRatePct?: number;\n /** Sample size used to compute errorRatePct; if below threshold, treated as unknown. */\n sampleSize?: number;\n /** Whether the most recent observed call succeeded. */\n lastObservationSucceeded?: boolean;\n /** Token/credential expiry, if known. Drives token-expiry warnings. */\n tokenExpiresAt?: string;\n /** Free-form per-integration data carried to the dashboard. */\n metadata?: Record<string, unknown>;\n}\n\n// Activation result from integration\nexport interface ActivationResult {\n success: boolean;\n configData?: Record<string, unknown>;\n externalId?: string;\n errorMessage?: string;\n metadata?: Record<string, unknown>;\n}\n\n// Base props that all integration components need\ninterface BaseIntegrationComponentProps {\n accountId: string;\n sourceId?: string;\n integrationConfig?: Record<string, unknown>;\n}\n\n// Discriminated union for product reference - only one allowed\ntype ProductReference =\n | { productId: string; productSlug?: never }\n | { productSlug: string; productId?: never };\n\n// New base type using discriminated union\nexport type IntegrationComponentProps = BaseIntegrationComponentProps &\n ProductReference;\n\n// Marketplace tile props\nexport type MarketplaceTileProps = IntegrationComponentProps & {\n onActivate?: () => void;\n isActivated?: boolean;\n /** Navigation URL for the integration detail page */\n href?: string;\n};\n\n// Activation form props\nexport type ActivationFormProps = IntegrationComponentProps & {\n onSuccess?: (result: ActivationResult) => void;\n onCancel?: () => void;\n isLoading?: boolean;\n /** Render inline instead of in a dialog */\n inline?: boolean;\n /**\n * The integration is already connected and the person chose to connect it\n * again — after a token expired, a password changed, or a health check\n * failed. An OAuth form sends them through sign-in even when a token is\n * stored; a credential form simply accepts new values. Activating again\n * resets the integration's health to unknown until the next check.\n */\n reconnect?: boolean;\n /**\n * The TEAM account context the user is activating within — separate from\n * `accountId`, which for `scope: 'user'` integrations is collapsed to the\n * personal account for activation storage/token purposes. Only consumed by\n * workspace materialization (`materializeWorkspaceOnActivation`), never for\n * activation/token storage itself (plan 009 Part A2). Optional: undefined\n * for team-scoped integrations (their `accountId` already IS the team) and\n * for any caller that hasn't threaded it yet — the server action falls back\n * to `accountId` when absent.\n */\n teamAccountId?: string;\n};\n\n// Integration metadata\nexport interface IntegrationMetadata {\n productId: string;\n productSlug: string;\n integrationName: string;\n description: string;\n category: string;\n version: string;\n icon?: string;\n /** Bundled logo URL — overrides product.logo_path on the marketplace */\n logoPath?: string;\n /** When 'user', activation data is stored under the user's personal account (user.id) instead of the team account */\n scope?: 'user' | 'team';\n /**\n * Set FALSE to assert this integration has NO self-serve activation surface —\n * the marketplace detail page then renders no activation form at all.\n *\n * This is deliberately distinct from \"has no CUSTOM activation form\": an\n * integration that omits `getActivationForm()` still gets the generic one, and\n * six integrations depend on that. Use this flag only when submitting ANY\n * activation form would be a dead end — where `activate()` cannot succeed, so\n * showing a form hands the user a button that cannot work.\n * Undefined/true = normal self-serve activation.\n */\n selfServeActivation?: boolean;\n /**\n * How this integration's MCP tools resolve credentials — the integration's\n * SELF-DECLARATION of machine-executability, consumed dynamically by the\n * workflow engine's fail-closed tool allowlist (isGatewayExposableTool).\n *\n * 'account' — credentials/identity resolve from team- or source-level\n * config via the ToolContext (`getAccountId(ctx)` + `ctx.supabase`).\n * Safe for durable machine-principal execution (workflows): eligible\n * tools (read + public/internal sensitivity) become workflow-callable.\n * 'user' — credentials or identity are personal (ctx.user.id, personal\n * OAuth, session reads like getSupabaseServerClient()/requireUser()).\n * NEVER machine-executable: a workflow would silently ride one\n * employee's personal grant.\n * 'source' — platform-level credentials (diagnostics-class integrations).\n * Not exposed to account workflows.\n *\n * UNDECLARED = fail closed (treated as not machine-executable). Declaring\n * 'account' is a security assertion: the integration's MCP run() handlers\n * must use ctx-based resolution ONLY — no session clients, no personal\n * grants. A guard test in @kit/integrations-workflows enforces the obvious\n * violations (session-client reads in mcp/ code of 'account' declarers).\n */\n credentialModel?: 'account' | 'user' | 'source';\n /**\n * Which KIND of integration this is. **Required** — nothing is inferred from\n * omission. An Integration is any package extending `BaseIntegration`; its\n * kind says who turns it on and whether it needs credentials:\n *\n * 'feature' — an Ekanos-native capability. Enabled for a Source by a\n * super-admin; no third-party credentials, no activation flow, no\n * marketplace tile. Always declares its own top-level sidebar Section\n * via `getSidebarNav()` and NEVER declares `getWorkspaceTargets()` —\n * its widgets have no Workspace of their own, so an admin places them\n * on one in the composer (`/admin/sources/[id]/layout`).\n * 'integration' — a connection to an outside system. Made available to a\n * Source by a super-admin, then connected by a team or user (usually\n * OAuth/SSO); has credentials, an activation flow and a marketplace\n * tile. Declares a Workspace via `getWorkspaceTargets()`, a top-level\n * Section via `getSidebarNav()`, or both (Centrex does both).\n *\n * The asymmetry is one-directional and enforced by the host's CI:\n * a Feature MUST declare a Section and MUST NOT declare a Workspace; a\n * connector MAY declare either or both.\n */\n kind: 'feature' | 'integration';\n /**\n * Product slugs that MUST be attached to the same Source for this product to\n * function — a hard dependency, not a suggestion.\n *\n * The host REFUSES to attach this product to a Source missing any of them,\n * and refuses a detach that would strand a dependent. Admin surfaces render\n * the dependency in both directions (\"Requires X\" / \"Enables Y\").\n *\n * Host CI enforces: every slug is registered, nothing requires itself, no\n * cycles, and a `kind: 'feature'` may require a `'integration'` but never\n * the reverse.\n */\n requires?: string[];\n}\n\n// Widget configuration\nexport interface WidgetConfig {\n id: string;\n name: string;\n component: ComponentType<IntegrationComponentProps>;\n gridSize?: { cols: number; rows: number } | { cols: number; rows: number }[];\n gridPosition?: { col: number; row: number };\n widgetState: 'active' | 'inactive' | 'disabled';\n /**\n * `compact` (a figure tile, 1 → 2 → 4 across its row), `half` or `full`\n * (the design system's widget rules). Unset, it is derived from `layouts.lg.w`.\n */\n size?: 'compact' | 'half' | 'full';\n // React-grid-layout format\n layouts?: {\n lg?: { x: number; y: number; w: number; h: number; maxHeight?: number };\n md?: { x: number; y: number; w: number; h: number; maxHeight?: number };\n sm?: { x: number; y: number; w: number; h: number; maxHeight?: number };\n };\n // Integration metadata for widgets\n integrationMetadata?: IntegrationMetadata;\n category?: { id: string; name: string; slug: string; icon: string | null };\n // Database product ID (UUID) from widget_config table\n productId?: string;\n isCollapsible?: boolean;\n // For collapsed state persistence\n collapsed?: boolean;\n widgetConfigId?: string;\n // Resolved workspace placement (explicit widget_config.workspace_id\n // override, else the product's inheriting attachment). Populated by the\n // dashboard widgets loader; null = no workspace (unscoped dashboard).\n workspaceId?: string | null;\n isPinnable?: boolean;\n isPinned?: boolean;\n // When true, the dashboard renders the \"Ask about this\" AI footer bar for\n // this widget. The widget may still pass `askContext` to the wrapper for a\n // rich snapshot; otherwise a minimal default is used.\n aiFooterEnabled?: boolean;\n // Integration health for this widget's product. `unhealthy` downgrades the\n // widget to `disabled`; `degraded` surfaces a stale-data footer.\n health?: {\n status: HealthStatus;\n lastSuccessAt?: string | null;\n errorMessage?: string | null;\n };\n}\n\n// Database types for integration tables.\n//\n// PARTNER-VISIBLE SUBSET: these row types deliberately OMIT `vault_secret_id`.\n// A vault id is a host handle to a decryptable secret; the partner surface\n// never exposes one — `ctx.secrets` fences it off. Host code keeps the full\n// row because it needs the handle; a parity test pins the SDK type as the\n// host's row minus exactly the host-only fields, so a new column cannot drift\n// in here unnoticed.\nexport interface IntegrationConfig {\n id: string;\n account_id: string | null;\n product_id: string;\n config_type: 'api_credentials' | 'activation_data' | 'settings';\n config_data: Record<string, unknown>;\n status: 'active' | 'inactive' | 'pending' | 'error' | 'suspended';\n is_active: boolean;\n created_at: string;\n updated_at: string;\n created_by: string | null;\n updated_by: string | null;\n}\n\n/**\n * The PARTNER-VISIBLE `data_type` values on `account_product_data` — a strict\n * SUBSET of `@kit/integrations-core`'s union.\n *\n * `'secret'` is deliberately absent. Secret rows are host-managed (one row per\n * secret name, value in Vault, `vault_secret_id` on the row), written only by\n * the capability context's `persistSecret` and read only through\n * `ctx.secrets`. Naming the kind here would advertise a row shape partner code\n * must never address: `ctx.storage` rejects it, and core's generic accessors\n * reject it too (`config-utils.ts`, `assertNotHostOnlyDataType`) precisely\n * because a write there would land the plaintext in the `data` column.\n *\n * When you add an integration-specific kind, add it in BOTH places (core owns\n * the full union) and keep this one partner-appropriate. Prefer `dataSubtype`\n * for orthogonal slicing within a kind (e.g. `data_type='cache'`,\n * `data_subtype='profile'`); reserve a new top-level kind for data that has a\n * distinct lifecycle or is queried independently.\n */\nexport type AccountProductDataType =\n | 'activation'\n | 'settings'\n | 'metrics_summary'\n | 'sync_state'\n | 'cache'\n // Integration-specific kinds — extend here when needed.\n | 'cash_forecast' // quickbooks — user-supplied manual cash-forecast estimates\n | 'tax_config'; // quickbooks — per-user federal/state tax rate config\n\nexport interface AccountProductData {\n id: string;\n account_id: string;\n product_id: string;\n data_type: AccountProductDataType;\n data_subtype?: string;\n data: Record<string, unknown>;\n expires_at?: string;\n integration_config_id?: string;\n external_id?: string;\n created_at: string;\n updated_at: string;\n created_by: string | null;\n updated_by: string | null;\n}\n"]}
@@ -68,6 +68,11 @@
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
+
71
76
  /** `bg-white`, `text-black/50`, `dark:border-white`… — @shadcn/lint's
72
77
  * no-raw-colors covers the palette scales but not these two. */
73
78
  const ABSOLUTE_COLOR =
@@ -673,6 +678,19 @@ export default {
673
678
  '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).',
674
679
  ),
675
680
  },
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
+ },
676
694
  'no-absolute-colors': {
677
695
  meta: {
678
696
  type: 'problem',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekanos/sdk",
3
- "version": "0.19.0",
3
+ "version": "0.20.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.19.0",
118
- "@ekanos/ui": "0.19.0",
117
+ "@ekanos/integration-schema": "0.20.0",
118
+ "@ekanos/ui": "0.20.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"