(input: {
readonly scopeId: string;
readonly integration: string;
readonly name: string;
readonly template: string;
readonly provider: string;
readonly identityLabel: string | null;
readonly grant: MigrationGrant;
readonly v1ExpiresAt: number | null;
readonly oauthScopes: readonly string[];
readonly oauthClientSlug: string | null;
readonly oauthClientOwner: OwnerKeys | null;
readonly nowMs: number;
readonly ownerForScope?: ScopeOwnerResolver;
})
| 882 | /** Build a v2 `connection` row (owner split, C1a expiry, oauth-client ref). The |
| 883 | * runner attaches `item_ids`/`refresh_item_id` from its secret-op results. */ |
| 884 | export const planConnectionRow = (input: { |
| 885 | readonly scopeId: string; |
| 886 | readonly integration: string; |
| 887 | readonly name: string; |
| 888 | readonly template: string; |
| 889 | readonly provider: string; |
| 890 | readonly identityLabel: string | null; |
| 891 | readonly grant: MigrationGrant; |
| 892 | readonly v1ExpiresAt: number | null; |
| 893 | readonly oauthScopes: readonly string[]; |
| 894 | readonly oauthClientSlug: string | null; |
| 895 | readonly oauthClientOwner: OwnerKeys | null; |
| 896 | readonly nowMs: number; |
| 897 | readonly ownerForScope?: ScopeOwnerResolver; |
| 898 | }): PlannedConnectionRow | null => { |
| 899 | const keys = (input.ownerForScope ?? parseScope)(input.scopeId); |
| 900 | if (!keys) return null; |
| 901 | return { |
| 902 | tenant: keys.tenant, |
| 903 | owner: keys.owner, |
| 904 | subject: keys.subject, |
| 905 | integration: input.integration, |
| 906 | name: input.name, |
| 907 | template: input.template, |
| 908 | provider: input.provider, |
| 909 | identityLabel: input.identityLabel, |
| 910 | oauthClientSlug: input.oauthClientSlug, |
| 911 | oauthClientOwner: input.oauthClientOwner ? input.oauthClientOwner.owner : null, |
| 912 | oauthScope: input.oauthScopes.length > 0 ? serializeOAuthScopes(input.oauthScopes) : null, |
| 913 | expiresAt: migrateExpiresAt({ |
| 914 | grant: input.grant, |
| 915 | v1ExpiresAt: input.v1ExpiresAt, |
| 916 | nowMs: input.nowMs, |
| 917 | }), |
| 918 | }; |
| 919 | }; |
| 920 | |
| 921 | // --------------------------------------------------------------------------- |
| 922 | // Deterministic v2 item id. |
no test coverage detected