@ekanos/sdk 0.25.0 → 0.27.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.
- package/README.md +9 -11
- package/api-report.md +27 -6
- package/dist/components/base-activation-dialog.js +2 -2
- package/dist/components/base-activation-dialog.js.map +1 -1
- package/dist/components/base-activation-form.js +1 -1
- package/dist/components/base-activation-form.js.map +1 -1
- package/dist/components/base-marketplace-tile.js +2 -2
- package/dist/components/base-marketplace-tile.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/oauth-activation-form.d.ts +8 -0
- package/dist/components/oauth-activation-form.js +10 -4
- package/dist/components/oauth-activation-form.js.map +1 -1
- package/dist/components/widgets/ai-prompt-chip.js +3 -3
- package/dist/components/widgets/ai-prompt-chip.js.map +1 -1
- package/dist/components/widgets/widget-ask-bar.js +1 -1
- package/dist/components/widgets/widget-ask-bar.js.map +1 -1
- package/dist/components/widgets/widget-ask-presentation.d.ts +35 -0
- package/dist/components/widgets/widget-ask-presentation.js +35 -0
- package/dist/components/widgets/widget-ask-presentation.js.map +1 -0
- package/dist/components/widgets/widget-state-components.d.ts +6 -1
- package/dist/components/widgets/widget-state-components.js +9 -9
- package/dist/components/widgets/widget-state-components.js.map +1 -1
- package/dist/components/widgets/widget.d.ts +4 -4
- package/dist/components/widgets/widget.js +43 -31
- package/dist/components/widgets/widget.js.map +1 -1
- package/dist/context/types.d.ts +1 -1
- package/dist/context/types.js.map +1 -1
- package/dist/contract/derive-contract.js +16 -10
- package/dist/contract/derive-contract.js.map +1 -1
- package/dist/contract/types.d.ts +1 -1
- package/dist/contract/types.js.map +1 -1
- package/dist/experience/client.d.ts +76 -0
- package/dist/experience/client.js +103 -2
- package/dist/experience/client.js.map +1 -1
- package/dist/experience/runtime.d.ts +16 -0
- package/dist/experience/runtime.js.map +1 -1
- package/dist/experience/sdk-instances.d.ts +11 -0
- package/dist/experience/sdk-instances.js +47 -0
- package/dist/experience/sdk-instances.js.map +1 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/partner-oauth.d.ts +15 -2
- package/dist/hooks/partner-oauth.js +3 -0
- package/dist/hooks/partner-oauth.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integration/index.d.ts +4 -2
- package/dist/integration/index.js +4 -1
- package/dist/integration/index.js.map +1 -1
- package/dist/testing/mock-context.d.ts +21 -2
- package/dist/testing/mock-context.js +102 -45
- package/dist/testing/mock-context.js.map +1 -1
- package/dist/types/workspace-target.d.ts +1 -1
- package/dist/types/workspace-target.js.map +1 -1
- package/dist/version.d.ts +7 -0
- package/dist/version.js +8 -0
- package/dist/version.js.map +1 -0
- package/eslint.design-preset.mjs +6 -4
- package/eslint.design-rules.mjs +218 -9
- package/package.json +3 -3
|
@@ -34,10 +34,23 @@ export interface PartnerOAuthPathOptions {
|
|
|
34
34
|
*/
|
|
35
35
|
baseUrl?: string;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Options for a status read. The connect route takes the same `connection`
|
|
39
|
+
* through `OAuthActivationFormConfig.connection`, which adds it to the query
|
|
40
|
+
* the form builds.
|
|
41
|
+
*/
|
|
42
|
+
export interface PartnerOAuthStatusOptions extends PartnerOAuthPathOptions {
|
|
43
|
+
/**
|
|
44
|
+
* A named connection's id (an `oauthConnections` key, e.g. `agent`). Absent
|
|
45
|
+
* or `default` is the main `oauth`. Sent as `?connection=<id>`, which the
|
|
46
|
+
* host and the harness both serve.
|
|
47
|
+
*/
|
|
48
|
+
connection?: string;
|
|
49
|
+
}
|
|
37
50
|
/** The hosted connect route the activation form sends the browser to. */
|
|
38
51
|
export declare function partnerOAuthConnectPath(integrationSlug: string, options?: PartnerOAuthPathOptions): string;
|
|
39
52
|
/** The hosted status route `createPartnerConnectionCheck` reads. */
|
|
40
|
-
export declare function partnerOAuthStatusUrl(integrationSlug: string, options:
|
|
53
|
+
export declare function partnerOAuthStatusUrl(integrationSlug: string, options: PartnerOAuthStatusOptions & {
|
|
41
54
|
accountId: string;
|
|
42
55
|
}): string;
|
|
43
56
|
/**
|
|
@@ -53,4 +66,4 @@ export declare function partnerOAuthErrorParam(integrationSlug: string): OAuthEr
|
|
|
53
66
|
* status only when the request itself is unauthorized, so a query error
|
|
54
67
|
* surfaces as an error rather than as a misleading "not connected".
|
|
55
68
|
*/
|
|
56
|
-
export declare function createPartnerConnectionCheck(integrationSlug: string, options?:
|
|
69
|
+
export declare function createPartnerConnectionCheck(integrationSlug: string, options?: PartnerOAuthStatusOptions): ConnectionCheckAction;
|
|
@@ -10,6 +10,9 @@ export function partnerOAuthStatusUrl(integrationSlug, options) {
|
|
|
10
10
|
var _a;
|
|
11
11
|
const base = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_BASE_URL;
|
|
12
12
|
const query = new URLSearchParams({ accountId: options.accountId });
|
|
13
|
+
if (options.connection && options.connection !== 'default') {
|
|
14
|
+
query.set('connection', options.connection);
|
|
15
|
+
}
|
|
13
16
|
return `${base}/${integrationSlug}/oauth/status?${query}`;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partner-oauth.js","sourceRoot":"","sources":["../../src/hooks/partner-oauth.ts"],"names":[],"mappings":"AAiCA,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"partner-oauth.js","sourceRoot":"","sources":["../../src/hooks/partner-oauth.ts"],"names":[],"mappings":"AAiCA,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAyB7C,yEAAyE;AACzE,MAAM,UAAU,uBAAuB,CACrC,eAAuB,EACvB,OAAO,GAA4B,EAAE;;IAErC,MAAM,IAAI,SAAG,OAAO,CAAC,OAAO,mCAAI,gBAAgB,CAAC;IACjD,OAAO,GAAG,IAAI,IAAI,eAAe,gBAAg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AE;QAC7B,MAAM,GAAG,GAAG,qBAAqB,CAAC,eAAe,kCAC5C,OAAO,KACV,SAAS,IACT,CAAC;QAEH,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE;YAC3C,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;SACxC,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,uBAAuB,eAAe,wBAAwB,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,IAAI,CACzG,CAAC;QACJ,CAAC;QAED,MAAM,OAAO,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAE/C,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,QAAQ,eAAe,gDAAgD,CACxE,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAC9B,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAA+B,CAAC,OAAO,KAAK,SAAS,CAC9D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The browser half of the hosted partner OAuth transport.\n *\n * A partner's `oauth` declaration names the provider endpoints and the\n * client-credential secrets; the HOST owns the flow — authorize redirect,\n * `state`, callback, code exchange, and the `onTokens` call — behind three\n * generic routes it serves for every partner integration:\n *\n * GET /api/integrations/[slug]/oauth/connect?accountId=…&returnPath=…\n * GET /api/integrations/[slug]/oauth/callback (the provider redirects here)\n * GET /api/integrations/[slug]/oauth/status?accountId=…\n *\n * These helpers are the only place a partner package should reference those\n * paths, so a route move is one SDK change rather than a hunt through every\n * integration. `OAuthActivationForm`'s `connectPath` default still points at\n * the per-integration `/connect` route first-party packages ship themselves;\n * a partner passes `connectPath: partnerOAuthConnectPath(slug)` explicitly.\n *\n * ```tsx\n * <OAuthActivationForm\n * {...props}\n * config={{ slug, displayName: 'Acme', connectPath: partnerOAuthConnectPath(slug), … }}\n * checkConnection={createPartnerConnectionCheck(slug)}\n * errorParam={partnerOAuthErrorParam(slug)}\n * />\n * ```\n */\nimport type {\n ConnectionCheckAction,\n ConnectionCheckResult,\n OAuthErrorParam,\n} from './use-oauth-connection-status';\n\nconst DEFAULT_BASE_URL = '/api/integrations';\n\nexport interface PartnerOAuthPathOptions {\n /**\n * Overrides the base path. Exists for harnesses and tests that serve the\n * routes from somewhere other than the host's own origin; production code\n * should leave it alone.\n */\n baseUrl?: string;\n}\n\n/**\n * Options for a status read. The connect route takes the same `connection`\n * through `OAuthActivationFormConfig.connection`, which adds it to the query\n * the form builds.\n */\nexport interface PartnerOAuthStatusOptions extends PartnerOAuthPathOptions {\n /**\n * A named connection's id (an `oauthConnections` key, e.g. `agent`). Absent\n * or `default` is the main `oauth`. Sent as `?connection=<id>`, which the\n * host and the harness both serve.\n */\n connection?: string;\n}\n\n/** The hosted connect route the activation form sends the browser to. */\nexport function partnerOAuthConnectPath(\n integrationSlug: string,\n options: PartnerOAuthPathOptions = {},\n): string {\n const base = options.baseUrl ?? DEFAULT_BASE_URL;\n return `${base}/${integrationSlug}/oauth/connect`;\n}\n\n/** The hosted status route `createPartnerConnectionCheck` reads. */\nexport function partnerOAuthStatusUrl(\n integrationSlug: string,\n options: PartnerOAuthStatusOptions & { accountId: string },\n): string {\n const base = options.baseUrl ?? DEFAULT_BASE_URL;\n const query = new URLSearchParams({ accountId: options.accountId });\n if (options.connection && options.connection !== 'default') {\n query.set('connection', options.connection);\n }\n return `${base}/${integrationSlug}/oauth/status?${query}`;\n}\n\n/**\n * The error query param the hosted callback appends on failure:\n * `<slug>_oauth_error=<code>`. Codes are the transport's, so the messages\n * live here rather than in every partner package.\n */\nexport function partnerOAuthErrorParam(\n integrationSlug: string,\n): OAuthErrorParam {\n return {\n name: `${integrationSlug}_oauth_error`,\n toMessage: (value) => PARTNER_OAUTH_ERROR_MESSAGES[value] ?? null,\n };\n}\n\nconst PARTNER_OAUTH_ERROR_MESSAGES: Record<string, string> = {\n // A declined grant is proof the consent screen worked. It is the one code\n // here that is not a fault, so it does not get fault-shaped copy.\n denied:\n 'Nothing was connected, and nothing changed at the provider. Connect again whenever you are ready.',\n provider_error:\n 'The provider refused the connection request. Trying again won’t help; contact support if it keeps happening.',\n expired: 'The connection attempt expired. Try connecting again.',\n invalid:\n 'The connection attempt could not be verified. Try connecting again.',\n unauthorized:\n 'You need to be signed in as the person who started the connection.',\n permission_lost:\n 'You no longer have permission to connect apps for this team. Ask an owner or an admin to connect it.',\n not_configured:\n 'This integration is not configured for your workspace yet. Ask an administrator to add its OAuth credentials.',\n exchange_failed:\n 'The provider rejected the connection. Try again, or contact support if it keeps failing.',\n save_failed: 'Connected, but the credentials could not be saved. Try again.',\n wrong_workspace:\n 'You signed in to a different account or workspace than this one is set up for. Switch to that account at the provider and try again.',\n app_not_set_up:\n 'The provider refused this integration’s app settings, so trying again won’t help. Ask an administrator to check the app’s scopes and credentials.',\n organization_access:\n 'Connect with personal access — this integration only uses your own account. Try again and choose personal access.',\n};\n\n/**\n * A `ConnectionCheckAction` backed by the hosted status route. The route\n * answers 200 with the standard envelope for both outcomes — `{ success:\n * true, data: { obtainedAt } }` or `{ success: false, error }` — and a non-OK\n * status only when the request itself is unauthorized, so a query error\n * surfaces as an error rather than as a misleading \"not connected\".\n */\nexport function createPartnerConnectionCheck(\n integrationSlug: string,\n options: PartnerOAuthStatusOptions = {},\n): ConnectionCheckAction {\n return async ({ accountId }) => {\n const url = partnerOAuthStatusUrl(integrationSlug, {\n ...options,\n accountId,\n });\n\n const response = await globalThis.fetch(url, {\n headers: { accept: 'application/json' },\n });\n\n if (!response.ok) {\n throw new Error(\n `Could not read the '${integrationSlug}' connection status (${response.status} ${response.statusText}).`,\n );\n }\n\n const payload: unknown = await response.json();\n\n if (!isConnectionCheckResult(payload)) {\n throw new Error(\n `The '${integrationSlug}' status route returned an unexpected payload.`,\n );\n }\n\n return payload;\n };\n}\n\nfunction isConnectionCheckResult(\n value: unknown,\n): value is ConnectionCheckResult {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { success?: unknown }).success === 'boolean'\n );\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -17,4 +17,4 @@
|
|
|
17
17
|
* Keep the whole surface readable in one pass.
|
|
18
18
|
*/
|
|
19
19
|
export type { IntegrationMetadata, IntegrationCapability, IntegrationPermission, IntegrationConfig, IntegrationComponentProps, ActivationFormProps, ActivationResult, MarketplaceTileProps, WidgetConfig, WorkspaceTargetDefinition, WidgetAskContext, WidgetSnapshot, WidgetSuggestedPrompt, AttentionSignal, WidgetVerdict, WidgetVerdictTone, HealthCheckResult, HealthStatus, AccountProductData, AccountProductDataType, } from './types/index.js';
|
|
20
|
-
export type { IntegrationContext, IntegrationActor, IntegrationConnection, IntegrationRouting, IntegrationStorage, ScopedStore, IntegrationSecrets, IntegrationFetch, IntegrationLogger, StorageEntry, StorageWriteOptions, StorageSchemas, StorageSchemaMap, StorageScopeSchemas, StorageKeyDeclaration, StorageKeyDeclarationInput, StorageKeySchema, } from './context/types.js';
|
|
20
|
+
export type { IntegrationContext, IntegrationActor, IntegrationConnection, IntegrationRouting, IntegrationPrincipal, IntegrationIdentity, IntegrationStorage, ScopedStore, IntegrationSecrets, IntegrationFetch, IntegrationLogger, StorageEntry, StorageWriteOptions, StorageSchemas, StorageSchemaMap, StorageScopeSchemas, StorageKeyDeclaration, StorageKeyDeclarationInput, StorageKeySchema, } from './context/types.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG","sourcesContent":["/**\n * @ekanos/sdk — the integration contract.\n *\n * Types only. This entrypoint is importable from any module, client or\n * server, and must stay that way: every export below is a `type` re-export,\n * so nothing here can pull runtime code into a client bundle. Runtime lives\n * in `@ekanos/sdk/components`, `@ekanos/sdk/hooks`, and `@ekanos/sdk/mcp`.\n *\n * The SDK OWNS these definitions (`./types` — nothing imported from `@kit/*`);\n * `@kit/integrations-core` keeps copies of some for now, and the parity guard\n * (a host-side parity test asserts it —\n * core-side since the inversion, because the dependency arrow is core → SDK)\n * fails core's typecheck on any drift.\n *\n * Surface discipline: additions require a second consumer and a line in\n * api-report.md, the checked-in snapshot of every entrypoint's exports.\n * Keep the whole surface readable in one pass.\n */\n\nexport type {\n // The integration definition\n IntegrationMetadata,\n IntegrationCapability,\n IntegrationPermission,\n IntegrationConfig,\n\n // Component contracts\n IntegrationComponentProps,\n ActivationFormProps,\n ActivationResult,\n MarketplaceTileProps,\n WidgetConfig,\n WorkspaceTargetDefinition,\n\n // AI ask-footer contract\n WidgetAskContext,\n WidgetSnapshot,\n WidgetSuggestedPrompt,\n\n // Widget verdicts (the design system's widget rules)\n AttentionSignal,\n WidgetVerdict,\n WidgetVerdictTone,\n\n // Health contract (required to implement checkHealth)\n HealthCheckResult,\n HealthStatus,\n\n // Account-scoped data seam\n AccountProductData,\n AccountProductDataType,\n} from './types';\n\nexport type {\n // The capability context — the one object partner code receives;\n // handed to MCP tool run() and server handlers; the mock lives in\n // @ekanos/sdk/testing, the shared runtime values in @ekanos/sdk/context.\n IntegrationContext,\n IntegrationActor,\n // Whose connection a call runs on, and the routed slice of a Source\n // connection it may touch (plan 241).\n IntegrationConnection,\n IntegrationRouting,\n IntegrationStorage,\n ScopedStore,\n IntegrationSecrets,\n IntegrationFetch,\n IntegrationLogger,\n StorageEntry,\n StorageWriteOptions,\n\n // Storage schema declaration (ruling 1) — consumed by defineIntegration()\n // and createMockContext()\n StorageSchemas,\n StorageSchemaMap,\n StorageScopeSchemas,\n\n // Per-key declaration form carrying exposure flags. `clientReadable`\n // (default false) is what opts a key in to the generic browser-readable\n // storage route — see StorageKeyDeclaration for the full rationale.\n StorageKeyDeclaration,\n StorageKeyDeclarationInput,\n StorageKeySchema,\n} from './context/types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG","sourcesContent":["/**\n * @ekanos/sdk — the integration contract.\n *\n * Types only. This entrypoint is importable from any module, client or\n * server, and must stay that way: every export below is a `type` re-export,\n * so nothing here can pull runtime code into a client bundle. Runtime lives\n * in `@ekanos/sdk/components`, `@ekanos/sdk/hooks`, and `@ekanos/sdk/mcp`.\n *\n * The SDK OWNS these definitions (`./types` — nothing imported from `@kit/*`);\n * `@kit/integrations-core` keeps copies of some for now, and the parity guard\n * (a host-side parity test asserts it —\n * core-side since the inversion, because the dependency arrow is core → SDK)\n * fails core's typecheck on any drift.\n *\n * Surface discipline: additions require a second consumer and a line in\n * api-report.md, the checked-in snapshot of every entrypoint's exports.\n * Keep the whole surface readable in one pass.\n */\n\nexport type {\n // The integration definition\n IntegrationMetadata,\n IntegrationCapability,\n IntegrationPermission,\n IntegrationConfig,\n\n // Component contracts\n IntegrationComponentProps,\n ActivationFormProps,\n ActivationResult,\n MarketplaceTileProps,\n WidgetConfig,\n WorkspaceTargetDefinition,\n\n // AI ask-footer contract\n WidgetAskContext,\n WidgetSnapshot,\n WidgetSuggestedPrompt,\n\n // Widget verdicts (the design system's widget rules)\n AttentionSignal,\n WidgetVerdict,\n WidgetVerdictTone,\n\n // Health contract (required to implement checkHealth)\n HealthCheckResult,\n HealthStatus,\n\n // Account-scoped data seam\n AccountProductData,\n AccountProductDataType,\n} from './types';\n\nexport type {\n // The capability context — the one object partner code receives;\n // handed to MCP tool run() and server handlers; the mock lives in\n // @ekanos/sdk/testing, the shared runtime values in @ekanos/sdk/context.\n IntegrationContext,\n IntegrationActor,\n // Whose connection a call runs on, and the routed slice of a Source\n // connection it may touch (plan 241).\n IntegrationConnection,\n IntegrationRouting,\n // Who a call runs for, and the person's own credential tier (plan 261).\n IntegrationPrincipal,\n IntegrationIdentity,\n IntegrationStorage,\n ScopedStore,\n IntegrationSecrets,\n IntegrationFetch,\n IntegrationLogger,\n StorageEntry,\n StorageWriteOptions,\n\n // Storage schema declaration (ruling 1) — consumed by defineIntegration()\n // and createMockContext()\n StorageSchemas,\n StorageSchemaMap,\n StorageScopeSchemas,\n\n // Per-key declaration form carrying exposure flags. `clientReadable`\n // (default false) is what opts a key in to the generic browser-readable\n // storage route — see StorageKeyDeclaration for the full rationale.\n StorageKeyDeclaration,\n StorageKeyDeclarationInput,\n StorageKeySchema,\n} from './context/types';\n"]}
|
|
@@ -20,7 +20,9 @@ export { parseCronExpression } from './cron.js';
|
|
|
20
20
|
export { PublicActionError } from '../errors/public-action-error.js';
|
|
21
21
|
export { ADMIN_HIERARCHY_LEVEL, OWNER_HIERARCHY_LEVEL, actorIsAtLeast, } from './actor-role.js';
|
|
22
22
|
export { DEFAULT_UNTRUSTED_TEXT_MAX_CHARS, untrustedText, untrustedTextNote, } from './untrusted-text.js';
|
|
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';
|
|
23
|
+
export { DEFAULT_OAUTH_CONNECTION_ID, DEFAULT_SIGNATURE_TOLERANCE_SECONDS, joinOAuthScopes, IntegrationDefinitionSchema, MAX_AGENT_CONVERSATION_KEY_LENGTH, MAX_AGENT_EVENT_DEDUPE_KEY_LENGTH, MAX_AGENT_RUN_CANCELS, MAX_RAISED_AGENT_EVENTS, MAX_ROUTE_VALUE_LENGTH, MAX_ROUTING_KEYS, PARTNER_STORAGE_LIMITS, RESERVED_OAUTH_AUTHORIZATION_PARAMS, validateIntegrationDefinitions, } from '@ekanos/integration-schema';
|
|
24
|
+
export { CREDENTIAL_LEVELS, DEFAULT_CREDENTIAL_LEVEL, declaredCredentialLevels, declaredCredentials, } from '@ekanos/integration-schema';
|
|
25
|
+
export type { CredentialLevel, DeclaredCredential, } from '@ekanos/integration-schema';
|
|
24
26
|
export { normalizeOAuthUrlValue, oauthProviderPlaceholders, resolveOAuthProvider, resolveOAuthUrl, } from '@ekanos/integration-schema';
|
|
25
27
|
export type { ResolveOAuthProviderResult, ResolveOAuthUrlResult, } 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';
|
|
28
|
+
export type { IntegrationDefinition, IntegrationComponentDeclarations, ActivationCredentialDeclaration, ActivationDeclaration, ActivationFieldDeclaration, IntegrationProposals, IntegrationCapabilityDeclaration, IntegrationPermissionDeclaration, PartnerWidgetDeclaration, PartnerToolModule, PartnerToolParameters, PartnerActionDeclaration, ToolClassificationProposal, DefinitionCollisionInput, FirstPartyInventory, PartnerWebhookDeclaration, WebhookSignatureDeclaration, WebhookSignatureScheme, WebhookEvent, WebhookResult, RaisedAgentEvent, AgentRunCancel, 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';
|
|
@@ -29,7 +29,10 @@ export { PublicActionError } from '../errors/public-action-error.js';
|
|
|
29
29
|
export { ADMIN_HIERARCHY_LEVEL, OWNER_HIERARCHY_LEVEL, actorIsAtLeast, } from './actor-role.js';
|
|
30
30
|
// Vendor/user-authored text in tool output: one name (`untrusted*`), one clip.
|
|
31
31
|
export { DEFAULT_UNTRUSTED_TEXT_MAX_CHARS, untrustedText, untrustedTextNote, } from './untrusted-text.js';
|
|
32
|
-
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';
|
|
32
|
+
export { DEFAULT_OAUTH_CONNECTION_ID, DEFAULT_SIGNATURE_TOLERANCE_SECONDS, joinOAuthScopes, IntegrationDefinitionSchema, MAX_AGENT_CONVERSATION_KEY_LENGTH, MAX_AGENT_EVENT_DEDUPE_KEY_LENGTH, MAX_AGENT_RUN_CANCELS, MAX_RAISED_AGENT_EVENTS, MAX_ROUTE_VALUE_LENGTH, MAX_ROUTING_KEYS, PARTNER_STORAGE_LIMITS, RESERVED_OAUTH_AUTHORIZATION_PARAMS, validateIntegrationDefinitions, } from '@ekanos/integration-schema';
|
|
33
|
+
// Credential levels (who connects each credential): the contract's
|
|
34
|
+
// `connection.levels` is derived from them.
|
|
35
|
+
export { CREDENTIAL_LEVELS, DEFAULT_CREDENTIAL_LEVEL, declaredCredentialLevels, declaredCredentials, } from '@ekanos/integration-schema';
|
|
33
36
|
// OAuth endpoint templates (`https://{subdomain}.zendesk.com/…`): the
|
|
34
37
|
// resolver the host transport and the harness fill them with, exported so a
|
|
35
38
|
// partner refreshing its own tokens builds the token URL by the same rules.
|
|
@@ -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 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"]}
|
|
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,eAAe,EACf,2BAA2B,EAC3B,iCAAiC,EACjC,iCAAiC,EACjC,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,mCAAmC,EACnC,8BAA8B,GAC/B,MAAM,4BAA4B,CAAC;AAEpC,mEAAmE;AACnE,4CAA4C;AAC5C,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAMpC,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 joinOAuthScopes,\n IntegrationDefinitionSchema,\n MAX_AGENT_CONVERSATION_KEY_LENGTH,\n MAX_AGENT_EVENT_DEDUPE_KEY_LENGTH,\n MAX_AGENT_RUN_CANCELS,\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// Credential levels (who connects each credential): the contract's\n// `connection.levels` is derived from them.\nexport {\n CREDENTIAL_LEVELS,\n DEFAULT_CREDENTIAL_LEVEL,\n declaredCredentialLevels,\n declaredCredentials,\n} from '@ekanos/integration-schema';\nexport type {\n CredentialLevel,\n DeclaredCredential,\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 ActivationCredentialDeclaration,\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 AgentRunCancel,\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"]}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* egress surprise later.
|
|
9
9
|
*/
|
|
10
10
|
import type { z } from 'zod';
|
|
11
|
-
import type { IntegrationActor, IntegrationConnection, IntegrationContext, IntegrationRouting, StorageKeySchema, StorageSchemaMap, StorageSchemas } from '../context/types.js';
|
|
11
|
+
import type { IntegrationActor, IntegrationConnection, IntegrationContext, IntegrationPrincipal, IntegrationRouting, StorageKeySchema, StorageSchemaMap, StorageSchemas } from '../context/types.js';
|
|
12
12
|
import { type MockFetchHandler } from './fetch-matching.js';
|
|
13
13
|
type ScopeSeed<M> = M extends StorageSchemaMap ? {
|
|
14
14
|
[K in keyof M & string]?: z.input<StorageKeySchema<M[K]>>;
|
|
@@ -24,9 +24,26 @@ export interface MockContextOptions<Schemas extends StorageSchemas = StorageSche
|
|
|
24
24
|
/**
|
|
25
25
|
* Whose connection the call runs on (plan 241). Defaults to
|
|
26
26
|
* `{ owner: 'team' }`; pass `{ owner: 'source' }` to run a tool, webhook
|
|
27
|
-
* or channel hook the way the host runs it on a Source connection
|
|
27
|
+
* or channel hook the way the host runs it on a Source connection, or
|
|
28
|
+
* `{ owner: 'user' }` to run on one person's own connection (an experience
|
|
29
|
+
* `invoker` call, a user-level credential's `onTokens` / `onActivate`).
|
|
28
30
|
*/
|
|
29
31
|
connection?: IntegrationConnection;
|
|
32
|
+
/**
|
|
33
|
+
* Who the call runs for (plan 261). Defaults from the actor: a user actor
|
|
34
|
+
* is `{ kind: 'user', userId, displayName: null, avatarUrl: null }`, a
|
|
35
|
+
* machine actor `{ kind: 'machine' }`. It must agree with the actor.
|
|
36
|
+
*/
|
|
37
|
+
principal?: IntegrationPrincipal;
|
|
38
|
+
/**
|
|
39
|
+
* Seed the calling person's OWN credential tier, `ctx.identity.secrets`
|
|
40
|
+
* (plan 261): a store separate from `ctx.secrets`, writable, holding only
|
|
41
|
+
* the values given here. Throws for a machine actor or principal, which
|
|
42
|
+
* never has `ctx.identity`. Omit it and `ctx.identity` is absent.
|
|
43
|
+
*/
|
|
44
|
+
identity?: {
|
|
45
|
+
secrets?: Record<string, string>;
|
|
46
|
+
};
|
|
30
47
|
/**
|
|
31
48
|
* The routed values the call may touch on a Source connection — what the
|
|
32
49
|
* host derives from the team's mappings. Only with
|
|
@@ -76,6 +93,8 @@ export interface RecordedLog {
|
|
|
76
93
|
export interface MockIntegrationContext<Schemas extends StorageSchemas = StorageSchemas> extends IntegrationContext<Schemas> {
|
|
77
94
|
/** Always set on the mock: `{ owner: 'team' }` unless the options say otherwise. */
|
|
78
95
|
readonly connection: IntegrationConnection;
|
|
96
|
+
/** Current values of the person's own tier (`ctx.identity.secrets`); `{}` when there is no identity. */
|
|
97
|
+
dumpIdentitySecrets(): Record<string, string>;
|
|
79
98
|
/** Every ctx.fetch call, allowed or denied, in order. */
|
|
80
99
|
readonly fetchCalls: readonly RecordedFetchCall[];
|
|
81
100
|
/** Every log line, per level. */
|
|
@@ -94,8 +94,8 @@ function utf8Bytes(value) {
|
|
|
94
94
|
function resolveConnection(connection, routing) {
|
|
95
95
|
var _a;
|
|
96
96
|
const owner = (_a = connection === null || connection === void 0 ? void 0 : connection.owner) !== null && _a !== void 0 ? _a : 'team';
|
|
97
|
-
if (owner !== 'team' && owner !== 'source') {
|
|
98
|
-
throw new TypeError(`connection.owner must be 'team' or '
|
|
97
|
+
if (owner !== 'team' && owner !== 'source' && owner !== 'user') {
|
|
98
|
+
throw new TypeError(`connection.owner must be 'team', 'source' or 'user', not ${JSON.stringify(owner)}.`);
|
|
99
99
|
}
|
|
100
100
|
const resolved = Object.freeze({ owner });
|
|
101
101
|
if (!routing)
|
|
@@ -128,16 +128,94 @@ function dumpScope(rows) {
|
|
|
128
128
|
}
|
|
129
129
|
return out;
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* An in-memory `IntegrationSecrets` over an own tier (readable, writable) and
|
|
133
|
+
* an admin tier (readable, a `set()` against a name only there is refused).
|
|
134
|
+
*/
|
|
135
|
+
function createSecrets(args) {
|
|
136
|
+
const { own: accountSecrets, admin: adminSecrets } = args;
|
|
137
|
+
return {
|
|
138
|
+
async get(name) {
|
|
139
|
+
var _a, _b;
|
|
140
|
+
return (_b = (_a = accountSecrets.get(name)) !== null && _a !== void 0 ? _a : adminSecrets.get(name)) !== null && _b !== void 0 ? _b : null;
|
|
141
|
+
},
|
|
142
|
+
async names() {
|
|
143
|
+
return [
|
|
144
|
+
...new Set([...accountSecrets.keys(), ...adminSecrets.keys()]),
|
|
145
|
+
].sort();
|
|
146
|
+
},
|
|
147
|
+
async set(name, value) {
|
|
148
|
+
if (!accountSecrets.has(name) && adminSecrets.has(name)) {
|
|
149
|
+
throw new SecretAccessError(name);
|
|
150
|
+
}
|
|
151
|
+
// The host's caps (finding E): one Vault record per value, one row +
|
|
152
|
+
// record per distinct name. Same wording as the host.
|
|
153
|
+
const valueBytes = utf8Bytes(value);
|
|
154
|
+
if (valueBytes > PARTNER_STORAGE_LIMITS.maxSerializedValueBytes) {
|
|
155
|
+
throw new TypeError(`secrets.set("${name}", …): the value is ${valueBytes} bytes, ` +
|
|
156
|
+
`above the ${PARTNER_STORAGE_LIMITS.maxSerializedValueBytes}-byte ` +
|
|
157
|
+
`per-secret limit. Secrets hold credentials, not payloads — store ` +
|
|
158
|
+
`bulk data under a ctx.storage key instead.`);
|
|
159
|
+
}
|
|
160
|
+
if (!accountSecrets.has(name) &&
|
|
161
|
+
accountSecrets.size >= PARTNER_STORAGE_LIMITS.maxSecretNames) {
|
|
162
|
+
throw new Error(`secrets.set("${name}", …): this integration already stores ` +
|
|
163
|
+
`${PARTNER_STORAGE_LIMITS.maxSecretNames} distinct secret names, ` +
|
|
164
|
+
`the per-integration limit. Reuse or rotate an existing name.`);
|
|
165
|
+
}
|
|
166
|
+
accountSecrets.set(name, value);
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Resolve `principal` against the actor: they must agree, and a machine never
|
|
172
|
+
* has a person's tier.
|
|
173
|
+
*/
|
|
174
|
+
function resolvePrincipal(args) {
|
|
175
|
+
const { actor, principal, identity } = args;
|
|
176
|
+
if (actor.kind === 'machine') {
|
|
177
|
+
if (principal && principal.kind !== 'machine') {
|
|
178
|
+
throw new TypeError('principal { kind: "user" } cannot be paired with a machine actor: ' +
|
|
179
|
+
'they must agree. Pass a user actor, or omit principal.');
|
|
180
|
+
}
|
|
181
|
+
if (identity) {
|
|
182
|
+
throw new TypeError('identity is unavailable here: a machine principal never has ' +
|
|
183
|
+
"ctx.identity. Use a user actor to test a person's own credentials.");
|
|
184
|
+
}
|
|
185
|
+
return { kind: 'machine' };
|
|
186
|
+
}
|
|
187
|
+
if (principal && principal.kind === 'machine') {
|
|
188
|
+
throw new TypeError('principal { kind: "machine" } cannot be paired with a user actor: ' +
|
|
189
|
+
'they must agree. Pass a machine actor, or omit principal.');
|
|
190
|
+
}
|
|
191
|
+
if (principal && principal.userId !== actor.userId) {
|
|
192
|
+
throw new TypeError(`principal.userId "${principal.userId}" must match the actor's userId ` +
|
|
193
|
+
`"${actor.userId}".`);
|
|
194
|
+
}
|
|
195
|
+
return (principal !== null && principal !== void 0 ? principal : {
|
|
196
|
+
kind: 'user',
|
|
197
|
+
userId: actor.userId,
|
|
198
|
+
displayName: null,
|
|
199
|
+
avatarUrl: null,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
131
202
|
export function createMockContext(options) {
|
|
132
|
-
var _a, _b, _c, _d;
|
|
133
|
-
var
|
|
203
|
+
var _a, _b, _c, _d, _e;
|
|
204
|
+
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
134
205
|
const userId = options.userId !== undefined ? options.userId : 'mock-user-id';
|
|
135
|
-
const actor = (
|
|
206
|
+
const actor = (_f = options.actor) !== null && _f !== void 0 ? _f : (userId !== null
|
|
136
207
|
? // The host always resolves a role; the mock's default user is the
|
|
137
208
|
// account owner. Pass `actor` with a lower role to test a gate.
|
|
138
209
|
{ kind: 'user', userId, role: { name: 'owner', hierarchyLevel: 1 } }
|
|
139
210
|
: { kind: 'machine', tokenId: 'mock-token-id', createdBy: null });
|
|
140
|
-
const
|
|
211
|
+
const principal = resolvePrincipal({
|
|
212
|
+
actor,
|
|
213
|
+
userId,
|
|
214
|
+
principal: options.principal,
|
|
215
|
+
identity: options.identity,
|
|
216
|
+
});
|
|
217
|
+
const hasIdentity = options.identity !== undefined;
|
|
218
|
+
const schemas = (_g = options.storageSchemas) !== null && _g !== void 0 ? _g : {};
|
|
141
219
|
const { connection, routing } = resolveConnection(options.connection, options.routing);
|
|
142
220
|
const accountRows = new Map();
|
|
143
221
|
const userRows = new Map();
|
|
@@ -184,43 +262,19 @@ export function createMockContext(options) {
|
|
|
184
262
|
guard: guardUserScope,
|
|
185
263
|
}),
|
|
186
264
|
};
|
|
187
|
-
const accountSecrets = new Map(Object.entries((
|
|
188
|
-
const adminSecrets = new Map(Object.entries((
|
|
189
|
-
const secrets = {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
].sort();
|
|
198
|
-
},
|
|
199
|
-
async set(name, value) {
|
|
200
|
-
if (!accountSecrets.has(name) && adminSecrets.has(name)) {
|
|
201
|
-
throw new SecretAccessError(name);
|
|
202
|
-
}
|
|
203
|
-
// The host's caps (finding E): one Vault record per value, one row +
|
|
204
|
-
// record per distinct name. Same wording as the host.
|
|
205
|
-
const valueBytes = utf8Bytes(value);
|
|
206
|
-
if (valueBytes > PARTNER_STORAGE_LIMITS.maxSerializedValueBytes) {
|
|
207
|
-
throw new TypeError(`secrets.set("${name}", …): the value is ${valueBytes} bytes, ` +
|
|
208
|
-
`above the ${PARTNER_STORAGE_LIMITS.maxSerializedValueBytes}-byte ` +
|
|
209
|
-
`per-secret limit. Secrets hold credentials, not payloads — store ` +
|
|
210
|
-
`bulk data under a ctx.storage key instead.`);
|
|
211
|
-
}
|
|
212
|
-
if (!accountSecrets.has(name) &&
|
|
213
|
-
accountSecrets.size >= PARTNER_STORAGE_LIMITS.maxSecretNames) {
|
|
214
|
-
throw new Error(`secrets.set("${name}", …): this integration already stores ` +
|
|
215
|
-
`${PARTNER_STORAGE_LIMITS.maxSecretNames} distinct secret names, ` +
|
|
216
|
-
`the per-integration limit. Reuse or rotate an existing name.`);
|
|
217
|
-
}
|
|
218
|
-
accountSecrets.set(name, value);
|
|
219
|
-
},
|
|
220
|
-
};
|
|
265
|
+
const accountSecrets = new Map(Object.entries((_h = (_c = options.secrets) === null || _c === void 0 ? void 0 : _c.account) !== null && _h !== void 0 ? _h : {}));
|
|
266
|
+
const adminSecrets = new Map(Object.entries((_j = (_d = options.secrets) === null || _d === void 0 ? void 0 : _d.admin) !== null && _j !== void 0 ? _j : {}));
|
|
267
|
+
const secrets = createSecrets({ own: accountSecrets, admin: adminSecrets });
|
|
268
|
+
const identitySecrets = new Map(Object.entries((_k = (_e = options.identity) === null || _e === void 0 ? void 0 : _e.secrets) !== null && _k !== void 0 ? _k : {}));
|
|
269
|
+
const identity = hasIdentity
|
|
270
|
+
? {
|
|
271
|
+
userId: principal.kind === 'user' ? principal.userId : '',
|
|
272
|
+
secrets: createSecrets({ own: identitySecrets, admin: new Map() }),
|
|
273
|
+
}
|
|
274
|
+
: undefined;
|
|
221
275
|
const fetchCalls = [];
|
|
222
|
-
const egress = (
|
|
223
|
-
const fetchHandlers = (
|
|
276
|
+
const egress = (_l = options.egress) !== null && _l !== void 0 ? _l : [];
|
|
277
|
+
const fetchHandlers = (_m = options.fetchHandlers) !== null && _m !== void 0 ? _m : [];
|
|
224
278
|
// Not an async function: a denied call must throw synchronously, before
|
|
225
279
|
// any I/O (proposal §2.3) — same behavior the production wrapper has.
|
|
226
280
|
const fetch = (input, init) => {
|
|
@@ -251,15 +305,18 @@ export function createMockContext(options) {
|
|
|
251
305
|
warn: record('warn'),
|
|
252
306
|
error: record('error'),
|
|
253
307
|
};
|
|
254
|
-
return Object.assign(Object.assign({ accountId: (
|
|
308
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({ accountId: (_o = options.accountId) !== null && _o !== void 0 ? _o : 'mock-account-id', accountSlug: (_p = options.accountSlug) !== null && _p !== void 0 ? _p : null, userId: actor.kind === 'machine' ? null : userId, actor, sourceId: (_q = options.sourceId) !== null && _q !== void 0 ? _q : null, integration: {
|
|
255
309
|
slug: options.integration.slug,
|
|
256
|
-
productId: (
|
|
257
|
-
}, timezone: (
|
|
310
|
+
productId: (_r = options.integration.productId) !== null && _r !== void 0 ? _r : 'mock-product-id',
|
|
311
|
+
}, timezone: (_s = options.timezone) !== null && _s !== void 0 ? _s : null, connection }, (routing ? { routing } : {})), { principal }), (identity ? { identity } : {})), { storage,
|
|
258
312
|
secrets,
|
|
259
313
|
fetch,
|
|
260
314
|
logger,
|
|
261
315
|
fetchCalls,
|
|
262
316
|
logs,
|
|
317
|
+
dumpIdentitySecrets() {
|
|
318
|
+
return Object.fromEntries(identitySecrets);
|
|
319
|
+
},
|
|
263
320
|
dumpStorage() {
|
|
264
321
|
return { account: dumpScope(accountRows), user: dumpScope(userRows) };
|
|
265
322
|
} });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-context.js","sourceRoot":"","sources":["../../src/testing/mock-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAYpE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,+BAA+B,CAAC;AAiBvC,OAAO,EAAyB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAmG5E,SAAS,SAAS,CAAC,GAAc;IAC/B,OAAO,GAAG,CAAC,SAAS,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AAC3E,CAAC;AAED,SAAS,cAAc,CACrB,OAAwC;IAExC,MAAM,SAAS,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC;IACrC,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACzC,IAAI,MAAM,CAAC,KAAK,CA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EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxE,CAAC,IACD;AACJ,CAAC","sourcesContent":["import { PARTNER_STORAGE_LIMITS } from '@ekanos/integration-schema';\n/**\n * `createMockContext()` — the day-1 in-memory `IntegrationContext` for the\n * partner harness (proposal §4, amended by rulings 1–4). Self-contained:\n * nothing here touches Supabase, Vault, or the network. Enforcement is the\n * SAME shared implementation the production wrapper uses\n * (`@ekanos/sdk/context`): schema validation via `parseStorageValue`, egress\n * via `isEgressAllowed` — a test that passes the mock cannot be a schema or\n * egress surprise later.\n */\nimport type { z } from 'zod';\n\nimport { isEgressAllowed } from '../context/egress';\nimport {\n EgressDeniedError,\n SecretAccessError,\n StorageValidationError,\n} from '../context/errors';\nimport {\n assertStorageKeyDeclared,\n assertStorageKeyWritable,\n parseStorageValue,\n} from '../context/storage-validation';\nimport type {\n IntegrationActor,\n IntegrationConnection,\n IntegrationContext,\n IntegrationFetch,\n IntegrationLogger,\n IntegrationRouting,\n IntegrationSecrets,\n IntegrationStorage,\n ScopedStore,\n StorageEntry,\n StorageKeySchema,\n StorageSchemaMap,\n StorageSchemas,\n StorageWriteOptions,\n} from '../context/types';\nimport { type MockFetchHandler, matchFetchHandler } from './fetch-matching';\n\ntype StorageScope = 'account' | 'user';\n\n// Seeds are typed off the DECLARED schema, resolved out of whichever\n// declaration form the key used — a bare zod schema or a\n// `{ schema, clientReadable }` descriptor.\ntype ScopeSeed<M> = M extends StorageSchemaMap\n ? { [K in keyof M & string]?: z.input<StorageKeySchema<M[K]>> }\n : Record<never, never>;\n\n// Re-exported from here for backward compatibility — `MockFetchHandler`'s\n// canonical home is now `./fetch-matching`, shared with `createMockFetchProvider`.\nexport type { MockFetchHandler } from './fetch-matching';\n\nexport interface MockContextOptions<\n Schemas extends StorageSchemas = StorageSchemas,\n> {\n accountId?: string;\n accountSlug?: string | null;\n userId?: string | null;\n actor?: IntegrationActor;\n sourceId?: string | null;\n timezone?: string | null;\n /**\n * Whose connection the call runs on (plan 241). Defaults to\n * `{ owner: 'team' }`; pass `{ owner: 'source' }` to run a tool, webhook\n * or channel hook the way the host runs it on a Source connection.\n */\n connection?: IntegrationConnection;\n /**\n * The routed values the call may touch on a Source connection — what the\n * host derives from the team's mappings. Only with\n * `connection: { owner: 'source' }`, as on the host.\n */\n routing?: IntegrationRouting;\n integration: { slug: string; productId?: string };\n /**\n * The storage declaration `defineIntegration({ storage })` will carry —\n * the mock enforces the identical schemas via the same shared validator\n * (ruling 1). Omit it and every storage access throws.\n */\n storageSchemas?: Schemas;\n /** Seed rows: key → data, per scope. Validated on construction via the write path. */\n storage?: {\n account?: ScopeSeed<Schemas['account']>;\n user?: ScopeSeed<Schemas['user']>;\n };\n /**\n * Seed secrets, by tier (ruling 2): `account` values are the rows this\n * integration stored — writable via `secrets.set()`; `admin` values stand\n * in for admin-issued source/global-tier credentials — readable, and a\n * `set()` against a name resolvable only there throws `SecretAccessError`.\n */\n secrets?: {\n account?: Record<string, string>;\n admin?: Record<string, string>;\n };\n /** Same allowlist the manifest would declare — enforced by the stub. */\n egress?: readonly string[];\n /** Programmable responses; unmatched allowed calls resolve 200 `{}`. */\n fetchHandlers?: MockFetchHandler[];\n}\n\nexport interface RecordedFetchCall {\n url: string;\n init?: RequestInit;\n denied: boolean;\n}\n\nexport interface RecordedLog {\n level: 'debug' | 'info' | 'warn' | 'error';\n context: Record<string, unknown>;\n message: string;\n}\n\nexport interface MockIntegrationContext<\n Schemas extends StorageSchemas = StorageSchemas,\n> extends IntegrationContext<Schemas> {\n /** Always set on the mock: `{ owner: 'team' }` unless the options say otherwise. */\n readonly connection: IntegrationConnection;\n /** Every ctx.fetch call, allowed or denied, in order. */\n readonly fetchCalls: readonly RecordedFetchCall[];\n /** Every log line, per level. */\n readonly logs: readonly RecordedLog[];\n /** Current readable storage state (expired entries excluded), key → data. */\n dumpStorage(): {\n account: Record<string, unknown>;\n user: Record<string, unknown>;\n };\n}\n\ninterface StoredRow {\n data: unknown;\n externalId: string | null;\n expiresAt: string | null;\n updatedAt: string;\n}\n\nfunction isExpired(row: StoredRow): boolean {\n return row.expiresAt !== null && Date.parse(row.expiresAt) <= Date.now();\n}\n\nfunction parseExpiresAt(\n options: StorageWriteOptions | undefined,\n): string | null {\n const expiresAt = options?.expiresAt;\n if (expiresAt === undefined) return null;\n if (Number.isNaN(Date.parse(expiresAt))) {\n throw new TypeError(\n `expiresAt \"${expiresAt}\" is not a parseable timestamp. Pass an ` +\n `ISO-8601 string, e.g. new Date(Date.now() + 60_000).toISOString().`,\n );\n }\n return expiresAt;\n}\n\nfunction createInMemoryStore(args: {\n scope: StorageScope;\n schemas: StorageSchemaMap | undefined;\n rows: Map<string, StoredRow>;\n guard: () => void;\n}): ScopedStore {\n const { scope, schemas, rows, guard } = args;\n\n return {\n async get(key: string): Promise<StorageEntry<unknown> | null> {\n guard();\n assertStorageKeyDeclared({ scope, key, schemas });\n const row = rows.get(key);\n if (!row) return null;\n if (isExpired(row)) {\n rows.delete(key);\n return null;\n }\n const data = parseStorageValue({\n scope,\n key,\n operation: 'read',\n schemas,\n value: row.data,\n });\n return {\n data,\n externalId: row.externalId,\n expiresAt: row.expiresAt,\n updatedAt: row.updatedAt,\n };\n },\n\n async set(\n key: string,\n data: unknown,\n options?: StorageWriteOptions,\n ): Promise<void> {\n guard();\n assertStorageKeyWritable({ scope, key });\n const parsed = parseStorageValue({\n scope,\n key,\n operation: 'write',\n schemas,\n value: data,\n });\n // The host's per-value cap (finding E), enforced here with the host's\n // own wording so `ekanos test` fails where production would.\n const serializedBytes = utf8Bytes(JSON.stringify(parsed));\n if (serializedBytes > PARTNER_STORAGE_LIMITS.maxSerializedValueBytes) {\n throw new StorageValidationError({\n scope,\n key,\n hint:\n `The value written to ${scope} storage key \"${key}\" serializes ` +\n `to ${serializedBytes} bytes, above the ` +\n `${PARTNER_STORAGE_LIMITS.maxSerializedValueBytes}-byte per-value ` +\n `limit. Store less per key: trim cached payloads, or split state ` +\n `across purpose-named keys.`,\n });\n }\n rows.set(key, {\n data: parsed,\n externalId: options?.externalId ?? null,\n expiresAt: parseExpiresAt(options),\n updatedAt: new Date().toISOString(),\n });\n },\n\n async delete(key: string): Promise<void> {\n guard();\n assertStorageKeyWritable({ scope, key });\n assertStorageKeyDeclared({ scope, key, schemas });\n rows.delete(key);\n },\n };\n}\n\n/** Byte length of a string as UTF-8, without Buffer (this module runs in the browser-side harness too). */\nfunction utf8Bytes(value: string): number {\n return new TextEncoder().encode(value).length;\n}\n\n/**\n * The host sets `ctx.routing` only on a Source connection, so a mock that\n * pairs it with a team connection would prove scoping the host never runs.\n */\nfunction resolveConnection(\n connection: IntegrationConnection | undefined,\n routing: IntegrationRouting | undefined,\n): { connection: IntegrationConnection; routing?: IntegrationRouting } {\n const owner = connection?.owner ?? 'team';\n if (owner !== 'team' && owner !== 'source') {\n throw new TypeError(\n `connection.owner must be 'team' or 'source', not ${JSON.stringify(owner)}.`,\n );\n }\n const resolved = Object.freeze({ owner });\n if (!routing) return { connection: resolved };\n if (owner !== 'source') {\n throw new TypeError(\n 'routing is only set on a Source connection: pass ' +\n \"connection: { owner: 'source' } with it. A team's own connection \" +\n 'reaches only that team, so the host never scopes it.',\n );\n }\n if (\n typeof routing.key !== 'string' ||\n routing.key.length === 0 ||\n !Array.isArray(routing.values) ||\n routing.values.some((value) => typeof value !== 'string')\n ) {\n throw new TypeError(\n 'routing must be { key: string, values: string[] }: the routing key ' +\n 'id and the values mapped to the team.',\n );\n }\n return {\n connection: resolved,\n routing: Object.freeze({\n key: routing.key,\n values: Object.freeze([...routing.values]),\n }),\n };\n}\n\nfunction dumpScope(rows: Map<string, StoredRow>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [key, row] of rows) {\n if (!isExpired(row)) out[key] = row.data;\n }\n return out;\n}\n\nexport function createMockContext<\n Schemas extends StorageSchemas = StorageSchemas,\n>(options: MockContextOptions<Schemas>): MockIntegrationContext<Schemas> {\n const userId = options.userId !== undefined ? options.userId : 'mock-user-id';\n const actor: IntegrationActor =\n options.actor ??\n (userId !== null\n ? // The host always resolves a role; the mock's default user is the\n // account owner. Pass `actor` with a lower role to test a gate.\n { kind: 'user', userId, role: { name: 'owner', hierarchyLevel: 1 } }\n : { kind: 'machine', tokenId: 'mock-token-id', createdBy: null });\n\n const schemas: StorageSchemas = options.storageSchemas ?? {};\n const { connection, routing } = resolveConnection(\n options.connection,\n options.routing,\n );\n\n const accountRows = new Map<string, StoredRow>();\n const userRows = new Map<string, StoredRow>();\n\n const seedScope = (\n scope: StorageScope,\n rows: Map<string, StoredRow>,\n seed: Record<string, unknown> | undefined,\n ) => {\n for (const [key, value] of Object.entries(seed ?? {})) {\n const parsed = parseStorageValue({\n scope,\n key,\n operation: 'write',\n schemas: schemas[scope],\n value,\n });\n rows.set(key, {\n data: parsed,\n externalId: null,\n expiresAt: null,\n updatedAt: new Date().toISOString(),\n });\n }\n };\n seedScope('account', accountRows, options.storage?.account);\n seedScope('user', userRows, options.storage?.user);\n\n const guardUserScope = () => {\n if (actor.kind === 'machine') {\n throw new Error(\n 'ctx.storage.user is unavailable for machine actors: there is no ' +\n 'user to scope the row to. Store machine-written state in ' +\n 'ctx.storage.account instead.',\n );\n }\n };\n\n // The stores validate every key and value at runtime via the shared\n // validator; the cast narrows the runtime-checked store to the\n // schema-typed interface the declaration promises.\n const storage = {\n account: createInMemoryStore({\n scope: 'account',\n schemas: schemas.account,\n rows: accountRows,\n guard: () => void 0,\n }),\n user: createInMemoryStore({\n scope: 'user',\n schemas: schemas.user,\n rows: userRows,\n guard: guardUserScope,\n }),\n } as unknown as IntegrationStorage<Schemas>;\n\n const accountSecrets = new Map(\n Object.entries(options.secrets?.account ?? {}),\n );\n const adminSecrets = new Map(Object.entries(options.secrets?.admin ?? {}));\n\n const secrets: IntegrationSecrets = {\n async get(name) {\n return accountSecrets.get(name) ?? adminSecrets.get(name) ?? null;\n },\n async names() {\n return [\n ...new Set([...accountSecrets.keys(), ...adminSecrets.keys()]),\n ].sort();\n },\n async set(name, value) {\n if (!accountSecrets.has(name) && adminSecrets.has(name)) {\n throw new SecretAccessError(name);\n }\n // The host's caps (finding E): one Vault record per value, one row +\n // record per distinct name. Same wording as the host.\n const valueBytes = utf8Bytes(value);\n if (valueBytes > PARTNER_STORAGE_LIMITS.maxSerializedValueBytes) {\n throw new TypeError(\n `secrets.set(\"${name}\", …): the value is ${valueBytes} bytes, ` +\n `above the ${PARTNER_STORAGE_LIMITS.maxSerializedValueBytes}-byte ` +\n `per-secret limit. Secrets hold credentials, not payloads — store ` +\n `bulk data under a ctx.storage key instead.`,\n );\n }\n if (\n !accountSecrets.has(name) &&\n accountSecrets.size >= PARTNER_STORAGE_LIMITS.maxSecretNames\n ) {\n throw new Error(\n `secrets.set(\"${name}\", …): this integration already stores ` +\n `${PARTNER_STORAGE_LIMITS.maxSecretNames} distinct secret names, ` +\n `the per-integration limit. Reuse or rotate an existing name.`,\n );\n }\n accountSecrets.set(name, value);\n },\n };\n\n const fetchCalls: RecordedFetchCall[] = [];\n const egress = options.egress ?? [];\n const fetchHandlers = options.fetchHandlers ?? [];\n\n // Not an async function: a denied call must throw synchronously, before\n // any I/O (proposal §2.3) — same behavior the production wrapper has.\n const fetch: IntegrationFetch = (input, init) => {\n const url = new URL(input).toString();\n const allowed = isEgressAllowed(url, egress);\n fetchCalls.push(\n init === undefined\n ? { url, denied: !allowed }\n : { url, init, denied: !allowed },\n );\n if (!allowed) {\n throw new EgressDeniedError(new URL(url).origin);\n }\n const handler = matchFetchHandler(url, fetchHandlers);\n if (handler) {\n return Promise.resolve(handler.respond(new Request(url, init)));\n }\n return Promise.resolve(\n new Response('{}', {\n status: 200,\n headers: { 'content-type': 'application/json' },\n }),\n );\n };\n\n const logs: RecordedLog[] = [];\n const record =\n (level: RecordedLog['level']) =>\n (context: Record<string, unknown>, message: string) => {\n logs.push({ level, context, message });\n };\n const logger: IntegrationLogger = {\n debug: record('debug'),\n info: record('info'),\n warn: record('warn'),\n error: record('error'),\n };\n\n return {\n accountId: options.accountId ?? 'mock-account-id',\n accountSlug: options.accountSlug ?? null,\n userId: actor.kind === 'machine' ? null : userId,\n actor,\n sourceId: options.sourceId ?? null,\n integration: {\n slug: options.integration.slug,\n productId: options.integration.productId ?? 'mock-product-id',\n },\n timezone: options.timezone ?? null,\n connection,\n ...(routing ? { routing } : {}),\n storage,\n secrets,\n fetch,\n logger,\n fetchCalls,\n logs,\n dumpStorage() {\n return { account: dumpScope(accountRows), user: dumpScope(userRows) };\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mock-context.js","sourceRoot":"","sources":["../../src/testing/mock-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAYpE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,+BAA+B,CAAC;AAmBvC,OAAO,EAAyB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAoH5E,SAAS,SAAS,CAAC,GAAc;IAC/B,OAAO,GAAG,CAAC,SAAS,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AAC3E,CAAC;AAED,SAAS,cAAc,CACrB,OAAwC;IAExC,MAAM,SAAS,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC;IACrC,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACzC,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,SAAS,CACjB,cAAc,SAAS,0CAA0C;YAC/D,oEAAoE,CACvE,CAAC;IACJ,CAAC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,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAChD,KAAK,EACL,QAAQ,QAAE,OAAO,CAAC,QAAQ,mCAAI,IAAI,EAClC,WAAW,EAAE;YACX,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI;YAC9B,SAAS,QAAE,OAAO,CAAC,WAAW,CAAC,SAAS,mCAAI,iBAAiB;SAC9D,EACD,QAAQ,QAAE,OAAO,CAAC,QAAQ,mCAAI,IAAI,EAClC,UAAU,IACP,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAC/B,SAAS,KACN,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACjC,OAAO;QACP,OAAO;QACP,KAAK;QACL,MAAM;QACN,UAAU;QACV,IAAI;QACJ,mBAAmB;YACjB,OAAO,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;QAC7C,CAAC;QACD,WAAW;YACT,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxE,CAAC,IACD;AACJ,CAAC","sourcesContent":["import { PARTNER_STORAGE_LIMITS } from '@ekanos/integration-schema';\n/**\n * `createMockContext()` — the day-1 in-memory `IntegrationContext` for the\n * partner harness (proposal §4, amended by rulings 1–4). Self-contained:\n * nothing here touches Supabase, Vault, or the network. Enforcement is the\n * SAME shared implementation the production wrapper uses\n * (`@ekanos/sdk/context`): schema validation via `parseStorageValue`, egress\n * via `isEgressAllowed` — a test that passes the mock cannot be a schema or\n * egress surprise later.\n */\nimport type { z } from 'zod';\n\nimport { isEgressAllowed } from '../context/egress';\nimport {\n EgressDeniedError,\n SecretAccessError,\n StorageValidationError,\n} from '../context/errors';\nimport {\n assertStorageKeyDeclared,\n assertStorageKeyWritable,\n parseStorageValue,\n} from '../context/storage-validation';\nimport type {\n IntegrationActor,\n IntegrationConnection,\n IntegrationContext,\n IntegrationFetch,\n IntegrationIdentity,\n IntegrationLogger,\n IntegrationPrincipal,\n IntegrationRouting,\n IntegrationSecrets,\n IntegrationStorage,\n ScopedStore,\n StorageEntry,\n StorageKeySchema,\n StorageSchemaMap,\n StorageSchemas,\n StorageWriteOptions,\n} from '../context/types';\nimport { type MockFetchHandler, matchFetchHandler } from './fetch-matching';\n\ntype StorageScope = 'account' | 'user';\n\n// Seeds are typed off the DECLARED schema, resolved out of whichever\n// declaration form the key used — a bare zod schema or a\n// `{ schema, clientReadable }` descriptor.\ntype ScopeSeed<M> = M extends StorageSchemaMap\n ? { [K in keyof M & string]?: z.input<StorageKeySchema<M[K]>> }\n : Record<never, never>;\n\n// Re-exported from here for backward compatibility — `MockFetchHandler`'s\n// canonical home is now `./fetch-matching`, shared with `createMockFetchProvider`.\nexport type { MockFetchHandler } from './fetch-matching';\n\nexport interface MockContextOptions<\n Schemas extends StorageSchemas = StorageSchemas,\n> {\n accountId?: string;\n accountSlug?: string | null;\n userId?: string | null;\n actor?: IntegrationActor;\n sourceId?: string | null;\n timezone?: string | null;\n /**\n * Whose connection the call runs on (plan 241). Defaults to\n * `{ owner: 'team' }`; pass `{ owner: 'source' }` to run a tool, webhook\n * or channel hook the way the host runs it on a Source connection, or\n * `{ owner: 'user' }` to run on one person's own connection (an experience\n * `invoker` call, a user-level credential's `onTokens` / `onActivate`).\n */\n connection?: IntegrationConnection;\n /**\n * Who the call runs for (plan 261). Defaults from the actor: a user actor\n * is `{ kind: 'user', userId, displayName: null, avatarUrl: null }`, a\n * machine actor `{ kind: 'machine' }`. It must agree with the actor.\n */\n principal?: IntegrationPrincipal;\n /**\n * Seed the calling person's OWN credential tier, `ctx.identity.secrets`\n * (plan 261): a store separate from `ctx.secrets`, writable, holding only\n * the values given here. Throws for a machine actor or principal, which\n * never has `ctx.identity`. Omit it and `ctx.identity` is absent.\n */\n identity?: { secrets?: Record<string, string> };\n /**\n * The routed values the call may touch on a Source connection — what the\n * host derives from the team's mappings. Only with\n * `connection: { owner: 'source' }`, as on the host.\n */\n routing?: IntegrationRouting;\n integration: { slug: string; productId?: string };\n /**\n * The storage declaration `defineIntegration({ storage })` will carry —\n * the mock enforces the identical schemas via the same shared validator\n * (ruling 1). Omit it and every storage access throws.\n */\n storageSchemas?: Schemas;\n /** Seed rows: key → data, per scope. Validated on construction via the write path. */\n storage?: {\n account?: ScopeSeed<Schemas['account']>;\n user?: ScopeSeed<Schemas['user']>;\n };\n /**\n * Seed secrets, by tier (ruling 2): `account` values are the rows this\n * integration stored — writable via `secrets.set()`; `admin` values stand\n * in for admin-issued source/global-tier credentials — readable, and a\n * `set()` against a name resolvable only there throws `SecretAccessError`.\n */\n secrets?: {\n account?: Record<string, string>;\n admin?: Record<string, string>;\n };\n /** Same allowlist the manifest would declare — enforced by the stub. */\n egress?: readonly string[];\n /** Programmable responses; unmatched allowed calls resolve 200 `{}`. */\n fetchHandlers?: MockFetchHandler[];\n}\n\nexport interface RecordedFetchCall {\n url: string;\n init?: RequestInit;\n denied: boolean;\n}\n\nexport interface RecordedLog {\n level: 'debug' | 'info' | 'warn' | 'error';\n context: Record<string, unknown>;\n message: string;\n}\n\nexport interface MockIntegrationContext<\n Schemas extends StorageSchemas = StorageSchemas,\n> extends IntegrationContext<Schemas> {\n /** Always set on the mock: `{ owner: 'team' }` unless the options say otherwise. */\n readonly connection: IntegrationConnection;\n /** Current values of the person's own tier (`ctx.identity.secrets`); `{}` when there is no identity. */\n dumpIdentitySecrets(): Record<string, string>;\n /** Every ctx.fetch call, allowed or denied, in order. */\n readonly fetchCalls: readonly RecordedFetchCall[];\n /** Every log line, per level. */\n readonly logs: readonly RecordedLog[];\n /** Current readable storage state (expired entries excluded), key → data. */\n dumpStorage(): {\n account: Record<string, unknown>;\n user: Record<string, unknown>;\n };\n}\n\ninterface StoredRow {\n data: unknown;\n externalId: string | null;\n expiresAt: string | null;\n updatedAt: string;\n}\n\nfunction isExpired(row: StoredRow): boolean {\n return row.expiresAt !== null && Date.parse(row.expiresAt) <= Date.now();\n}\n\nfunction parseExpiresAt(\n options: StorageWriteOptions | undefined,\n): string | null {\n const expiresAt = options?.expiresAt;\n if (expiresAt === undefined) return null;\n if (Number.isNaN(Date.parse(expiresAt))) {\n throw new TypeError(\n `expiresAt \"${expiresAt}\" is not a parseable timestamp. Pass an ` +\n `ISO-8601 string, e.g. new Date(Date.now() + 60_000).toISOString().`,\n );\n }\n return expiresAt;\n}\n\nfunction createInMemoryStore(args: {\n scope: StorageScope;\n schemas: StorageSchemaMap | undefined;\n rows: Map<string, StoredRow>;\n guard: () => void;\n}): ScopedStore {\n const { scope, schemas, rows, guard } = args;\n\n return {\n async get(key: string): Promise<StorageEntry<unknown> | null> {\n guard();\n assertStorageKeyDeclared({ scope, key, schemas });\n const row = rows.get(key);\n if (!row) return null;\n if (isExpired(row)) {\n rows.delete(key);\n return null;\n }\n const data = parseStorageValue({\n scope,\n key,\n operation: 'read',\n schemas,\n value: row.data,\n });\n return {\n data,\n externalId: row.externalId,\n expiresAt: row.expiresAt,\n updatedAt: row.updatedAt,\n };\n },\n\n async set(\n key: string,\n data: unknown,\n options?: StorageWriteOptions,\n ): Promise<void> {\n guard();\n assertStorageKeyWritable({ scope, key });\n const parsed = parseStorageValue({\n scope,\n key,\n operation: 'write',\n schemas,\n value: data,\n });\n // The host's per-value cap (finding E), enforced here with the host's\n // own wording so `ekanos test` fails where production would.\n const serializedBytes = utf8Bytes(JSON.stringify(parsed));\n if (serializedBytes > PARTNER_STORAGE_LIMITS.maxSerializedValueBytes) {\n throw new StorageValidationError({\n scope,\n key,\n hint:\n `The value written to ${scope} storage key \"${key}\" serializes ` +\n `to ${serializedBytes} bytes, above the ` +\n `${PARTNER_STORAGE_LIMITS.maxSerializedValueBytes}-byte per-value ` +\n `limit. Store less per key: trim cached payloads, or split state ` +\n `across purpose-named keys.`,\n });\n }\n rows.set(key, {\n data: parsed,\n externalId: options?.externalId ?? null,\n expiresAt: parseExpiresAt(options),\n updatedAt: new Date().toISOString(),\n });\n },\n\n async delete(key: string): Promise<void> {\n guard();\n assertStorageKeyWritable({ scope, key });\n assertStorageKeyDeclared({ scope, key, schemas });\n rows.delete(key);\n },\n };\n}\n\n/** Byte length of a string as UTF-8, without Buffer (this module runs in the browser-side harness too). */\nfunction utf8Bytes(value: string): number {\n return new TextEncoder().encode(value).length;\n}\n\n/**\n * The host sets `ctx.routing` only on a Source connection, so a mock that\n * pairs it with a team connection would prove scoping the host never runs.\n */\nfunction resolveConnection(\n connection: IntegrationConnection | undefined,\n routing: IntegrationRouting | undefined,\n): { connection: IntegrationConnection; routing?: IntegrationRouting } {\n const owner = connection?.owner ?? 'team';\n if (owner !== 'team' && owner !== 'source' && owner !== 'user') {\n throw new TypeError(\n `connection.owner must be 'team', 'source' or 'user', not ${JSON.stringify(owner)}.`,\n );\n }\n const resolved = Object.freeze({ owner });\n if (!routing) return { connection: resolved };\n if (owner !== 'source') {\n throw new TypeError(\n 'routing is only set on a Source connection: pass ' +\n \"connection: { owner: 'source' } with it. A team's own connection \" +\n 'reaches only that team, so the host never scopes it.',\n );\n }\n if (\n typeof routing.key !== 'string' ||\n routing.key.length === 0 ||\n !Array.isArray(routing.values) ||\n routing.values.some((value) => typeof value !== 'string')\n ) {\n throw new TypeError(\n 'routing must be { key: string, values: string[] }: the routing key ' +\n 'id and the values mapped to the team.',\n );\n }\n return {\n connection: resolved,\n routing: Object.freeze({\n key: routing.key,\n values: Object.freeze([...routing.values]),\n }),\n };\n}\n\nfunction dumpScope(rows: Map<string, StoredRow>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [key, row] of rows) {\n if (!isExpired(row)) out[key] = row.data;\n }\n return out;\n}\n\n/**\n * An in-memory `IntegrationSecrets` over an own tier (readable, writable) and\n * an admin tier (readable, a `set()` against a name only there is refused).\n */\nfunction createSecrets(args: {\n own: Map<string, string>;\n admin: Map<string, string>;\n}): IntegrationSecrets {\n const { own: accountSecrets, admin: adminSecrets } = args;\n return {\n async get(name) {\n return accountSecrets.get(name) ?? adminSecrets.get(name) ?? null;\n },\n async names() {\n return [\n ...new Set([...accountSecrets.keys(), ...adminSecrets.keys()]),\n ].sort();\n },\n async set(name, value) {\n if (!accountSecrets.has(name) && adminSecrets.has(name)) {\n throw new SecretAccessError(name);\n }\n // The host's caps (finding E): one Vault record per value, one row +\n // record per distinct name. Same wording as the host.\n const valueBytes = utf8Bytes(value);\n if (valueBytes > PARTNER_STORAGE_LIMITS.maxSerializedValueBytes) {\n throw new TypeError(\n `secrets.set(\"${name}\", …): the value is ${valueBytes} bytes, ` +\n `above the ${PARTNER_STORAGE_LIMITS.maxSerializedValueBytes}-byte ` +\n `per-secret limit. Secrets hold credentials, not payloads — store ` +\n `bulk data under a ctx.storage key instead.`,\n );\n }\n if (\n !accountSecrets.has(name) &&\n accountSecrets.size >= PARTNER_STORAGE_LIMITS.maxSecretNames\n ) {\n throw new Error(\n `secrets.set(\"${name}\", …): this integration already stores ` +\n `${PARTNER_STORAGE_LIMITS.maxSecretNames} distinct secret names, ` +\n `the per-integration limit. Reuse or rotate an existing name.`,\n );\n }\n accountSecrets.set(name, value);\n },\n };\n}\n\n/**\n * Resolve `principal` against the actor: they must agree, and a machine never\n * has a person's tier.\n */\nfunction resolvePrincipal(args: {\n actor: IntegrationActor;\n userId: string | null;\n principal: IntegrationPrincipal | undefined;\n identity: MockContextOptions['identity'];\n}): IntegrationPrincipal {\n const { actor, principal, identity } = args;\n if (actor.kind === 'machine') {\n if (principal && principal.kind !== 'machine') {\n throw new TypeError(\n 'principal { kind: \"user\" } cannot be paired with a machine actor: ' +\n 'they must agree. Pass a user actor, or omit principal.',\n );\n }\n if (identity) {\n throw new TypeError(\n 'identity is unavailable here: a machine principal never has ' +\n \"ctx.identity. Use a user actor to test a person's own credentials.\",\n );\n }\n return { kind: 'machine' };\n }\n if (principal && principal.kind === 'machine') {\n throw new TypeError(\n 'principal { kind: \"machine\" } cannot be paired with a user actor: ' +\n 'they must agree. Pass a machine actor, or omit principal.',\n );\n }\n if (principal && principal.userId !== actor.userId) {\n throw new TypeError(\n `principal.userId \"${principal.userId}\" must match the actor's userId ` +\n `\"${actor.userId}\".`,\n );\n }\n return (\n principal ?? {\n kind: 'user',\n userId: actor.userId,\n displayName: null,\n avatarUrl: null,\n }\n );\n}\n\nexport function createMockContext<\n Schemas extends StorageSchemas = StorageSchemas,\n>(options: MockContextOptions<Schemas>): MockIntegrationContext<Schemas> {\n const userId = options.userId !== undefined ? options.userId : 'mock-user-id';\n const actor: IntegrationActor =\n options.actor ??\n (userId !== null\n ? // The host always resolves a role; the mock's default user is the\n // account owner. Pass `actor` with a lower role to test a gate.\n { kind: 'user', userId, role: { name: 'owner', hierarchyLevel: 1 } }\n : { kind: 'machine', tokenId: 'mock-token-id', createdBy: null });\n\n const principal = resolvePrincipal({\n actor,\n userId,\n principal: options.principal,\n identity: options.identity,\n });\n const hasIdentity = options.identity !== undefined;\n\n const schemas: StorageSchemas = options.storageSchemas ?? {};\n const { connection, routing } = resolveConnection(\n options.connection,\n options.routing,\n );\n\n const accountRows = new Map<string, StoredRow>();\n const userRows = new Map<string, StoredRow>();\n\n const seedScope = (\n scope: StorageScope,\n rows: Map<string, StoredRow>,\n seed: Record<string, unknown> | undefined,\n ) => {\n for (const [key, value] of Object.entries(seed ?? {})) {\n const parsed = parseStorageValue({\n scope,\n key,\n operation: 'write',\n schemas: schemas[scope],\n value,\n });\n rows.set(key, {\n data: parsed,\n externalId: null,\n expiresAt: null,\n updatedAt: new Date().toISOString(),\n });\n }\n };\n seedScope('account', accountRows, options.storage?.account);\n seedScope('user', userRows, options.storage?.user);\n\n const guardUserScope = () => {\n if (actor.kind === 'machine') {\n throw new Error(\n 'ctx.storage.user is unavailable for machine actors: there is no ' +\n 'user to scope the row to. Store machine-written state in ' +\n 'ctx.storage.account instead.',\n );\n }\n };\n\n // The stores validate every key and value at runtime via the shared\n // validator; the cast narrows the runtime-checked store to the\n // schema-typed interface the declaration promises.\n const storage = {\n account: createInMemoryStore({\n scope: 'account',\n schemas: schemas.account,\n rows: accountRows,\n guard: () => void 0,\n }),\n user: createInMemoryStore({\n scope: 'user',\n schemas: schemas.user,\n rows: userRows,\n guard: guardUserScope,\n }),\n } as unknown as IntegrationStorage<Schemas>;\n\n const accountSecrets = new Map(\n Object.entries(options.secrets?.account ?? {}),\n );\n const adminSecrets = new Map(Object.entries(options.secrets?.admin ?? {}));\n\n const secrets = createSecrets({ own: accountSecrets, admin: adminSecrets });\n\n const identitySecrets = new Map(\n Object.entries(options.identity?.secrets ?? {}),\n );\n const identity: IntegrationIdentity | undefined = hasIdentity\n ? {\n userId: principal.kind === 'user' ? principal.userId : '',\n secrets: createSecrets({ own: identitySecrets, admin: new Map() }),\n }\n : undefined;\n\n const fetchCalls: RecordedFetchCall[] = [];\n const egress = options.egress ?? [];\n const fetchHandlers = options.fetchHandlers ?? [];\n\n // Not an async function: a denied call must throw synchronously, before\n // any I/O (proposal §2.3) — same behavior the production wrapper has.\n const fetch: IntegrationFetch = (input, init) => {\n const url = new URL(input).toString();\n const allowed = isEgressAllowed(url, egress);\n fetchCalls.push(\n init === undefined\n ? { url, denied: !allowed }\n : { url, init, denied: !allowed },\n );\n if (!allowed) {\n throw new EgressDeniedError(new URL(url).origin);\n }\n const handler = matchFetchHandler(url, fetchHandlers);\n if (handler) {\n return Promise.resolve(handler.respond(new Request(url, init)));\n }\n return Promise.resolve(\n new Response('{}', {\n status: 200,\n headers: { 'content-type': 'application/json' },\n }),\n );\n };\n\n const logs: RecordedLog[] = [];\n const record =\n (level: RecordedLog['level']) =>\n (context: Record<string, unknown>, message: string) => {\n logs.push({ level, context, message });\n };\n const logger: IntegrationLogger = {\n debug: record('debug'),\n info: record('info'),\n warn: record('warn'),\n error: record('error'),\n };\n\n return {\n accountId: options.accountId ?? 'mock-account-id',\n accountSlug: options.accountSlug ?? null,\n userId: actor.kind === 'machine' ? null : userId,\n actor,\n sourceId: options.sourceId ?? null,\n integration: {\n slug: options.integration.slug,\n productId: options.integration.productId ?? 'mock-product-id',\n },\n timezone: options.timezone ?? null,\n connection,\n ...(routing ? { routing } : {}),\n principal,\n ...(identity ? { identity } : {}),\n storage,\n secrets,\n fetch,\n logger,\n fetchCalls,\n logs,\n dumpIdentitySecrets() {\n return Object.fromEntries(identitySecrets);\n },\n dumpStorage() {\n return { account: dumpScope(accountRows), user: dumpScope(userRows) };\n },\n };\n}\n"]}
|
|
@@ -16,7 +16,7 @@ export interface WorkspaceTargetDefinition {
|
|
|
16
16
|
* alphanumeric with single hyphens between segments. */
|
|
17
17
|
slug: string;
|
|
18
18
|
name: string;
|
|
19
|
-
/** A
|
|
19
|
+
/** A Phosphor icon name, e.g. `tray`. Validated by the host at
|
|
20
20
|
* gate time. */
|
|
21
21
|
icon?: string;
|
|
22
22
|
description?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-target.js","sourceRoot":"","sources":["../../src/types/workspace-target.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The contract an integration uses to declare the workspaces it ships with\n * (`BaseIntegration.getWorkspaceTargets()`).\n *\n * The host's canonical definition is `z.input<typeof WorkspaceTargetSchema>`\n * (`@kit/integrations-core`, `schemas/workspace-target.schema.ts`) — the\n * schema validates declarations in CI and at materialization time, including\n * cross-field rules a type cannot carry (icon-name validity, slug format,\n * `inheritsWidgets`/`includedWidgetIds` exclusivity, one inheriting target\n * per set). This structural twin exists so the SDK's root entrypoint owns its\n * types without importing the host schema; the parity test beside these types\n * keeps the two shapes mutually assignable.\n */\nexport interface WorkspaceTargetDefinition {\n /** Stable URL segment — `/workspace/<slug>` routes reference it. Lowercase\n * alphanumeric with single hyphens between segments. */\n slug: string;\n name: string;\n /** A
|
|
1
|
+
{"version":3,"file":"workspace-target.js","sourceRoot":"","sources":["../../src/types/workspace-target.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * The contract an integration uses to declare the workspaces it ships with\n * (`BaseIntegration.getWorkspaceTargets()`).\n *\n * The host's canonical definition is `z.input<typeof WorkspaceTargetSchema>`\n * (`@kit/integrations-core`, `schemas/workspace-target.schema.ts`) — the\n * schema validates declarations in CI and at materialization time, including\n * cross-field rules a type cannot carry (icon-name validity, slug format,\n * `inheritsWidgets`/`includedWidgetIds` exclusivity, one inheriting target\n * per set). This structural twin exists so the SDK's root entrypoint owns its\n * types without importing the host schema; the parity test beside these types\n * keeps the two shapes mutually assignable.\n */\nexport interface WorkspaceTargetDefinition {\n /** Stable URL segment — `/workspace/<slug>` routes reference it. Lowercase\n * alphanumeric with single hyphens between segments. */\n slug: string;\n name: string;\n /** A Phosphor icon name, e.g. `tray`. Validated by the host at\n * gate time. */\n icon?: string;\n description?: string;\n /** Defaults to `'masonry'` when omitted. */\n layout?: 'masonry' | 'two-column';\n /**\n * Whether this workspace receives the product's otherwise-unplaced\n * widgets. Exactly one target per product must set it; mutually exclusive\n * with `includedWidgetIds`.\n */\n inheritsWidgets?: boolean;\n /** Limit this workspace to specific widget ids. */\n includedWidgetIds?: string[];\n /**\n * Create this workspace on a Source as soon as the product is made\n * available there, instead of waiting for an admin to add it. Only for a\n * product that works as shipped (`activation: { required: false }`).\n */\n materializeOnEntitlement?: boolean;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This package's own version, for diagnostics that must name which copy of
|
|
3
|
+
* `@ekanos/sdk` is loaded. `src/__tests__/version.test.ts` fails when it drifts
|
|
4
|
+
* from `package.json#version`; after `changeset version`, copy the new version
|
|
5
|
+
* here.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SDK_VERSION = "0.27.0";
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This package's own version, for diagnostics that must name which copy of
|
|
3
|
+
* `@ekanos/sdk` is loaded. `src/__tests__/version.test.ts` fails when it drifts
|
|
4
|
+
* from `package.json#version`; after `changeset version`, copy the new version
|
|
5
|
+
* here.
|
|
6
|
+
*/
|
|
7
|
+
export const SDK_VERSION = '0.27.0';
|
|
8
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC","sourcesContent":["/**\n * This package's own version, for diagnostics that must name which copy of\n * `@ekanos/sdk` is loaded. `src/__tests__/version.test.ts` fails when it drifts\n * from `package.json#version`; after `changeset version`, copy the new version\n * here.\n */\nexport const SDK_VERSION = '0.27.0';\n"]}
|