( client: Client, snapshot: LocalV1Snapshot, plan: MigrationPlan, idOverrides: ReadonlyMap<string, string>, oauthClientIdValues: ReadonlyMap<string, string>, oauthAuthorizationUrls: ReadonlyMap<string, string>, tenantId: string, secretValues: CollectedSecretValues, )
| 782 | }; |
| 783 | |
| 784 | const insertPlan = async ( |
| 785 | client: Client, |
| 786 | snapshot: LocalV1Snapshot, |
| 787 | plan: MigrationPlan, |
| 788 | idOverrides: ReadonlyMap<string, string>, |
| 789 | oauthClientIdValues: ReadonlyMap<string, string>, |
| 790 | oauthAuthorizationUrls: ReadonlyMap<string, string>, |
| 791 | tenantId: string, |
| 792 | secretValues: CollectedSecretValues, |
| 793 | ): Promise<void> => { |
| 794 | const now = timestamp(); |
| 795 | const ownerForScope = localOwnerForScope(tenantId); |
| 796 | const connectionTargets = plan.connections.map((connection) => ({ |
| 797 | sourceScopeId: connection.sourceScopeId, |
| 798 | sourceId: connection.sourceId, |
| 799 | tenant: connection.row.tenant, |
| 800 | owner: connection.row.owner, |
| 801 | subject: ownerSubject(connection.row.owner, connection.row.subject), |
| 802 | connection: connection.row.name, |
| 803 | })); |
| 804 | const runtimeMetadata = buildV1RuntimeMetadataIndex(snapshot.pluginStorage); |
| 805 | const targetsFor = (scopeId: string, sourceId: string) => |
| 806 | connectionTargets.filter( |
| 807 | (target) => target.sourceScopeId === scopeId && target.sourceId === sourceId, |
| 808 | ); |
| 809 | |
| 810 | await client.execute("BEGIN"); |
| 811 | try { |
| 812 | for (const row of plan.integrations) { |
| 813 | await executeSql( |
| 814 | client, |
| 815 | "INSERT INTO integration (slug, plugin_id, description, config, can_remove, can_refresh, created_at, updated_at, row_id, tenant) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", |
| 816 | [ |
| 817 | row.slug, |
| 818 | row.plugin_id, |
| 819 | row.description, |
| 820 | jsonText(row.config), |
| 821 | 1, |
| 822 | 0, |
| 823 | now, |
| 824 | now, |
| 825 | createId(), |
| 826 | row.tenant, |
| 827 | ], |
| 828 | ); |
| 829 | } |
| 830 | |
| 831 | for (const clientRow of plan.oauthClients) { |
| 832 | await executeSql( |
| 833 | client, |
| 834 | "INSERT INTO oauth_client (slug, authorization_url, token_url, grant, client_id, client_secret_item_id, resource, created_at, row_id, tenant, owner, subject) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", |
| 835 | [ |
| 836 | clientRow.slug, |
| 837 | authorizationUrlFor(clientRow, oauthAuthorizationUrls), |
| 838 | clientRow.tokenUrl, |
| 839 | clientRow.grant, |
| 840 | clientIdFor(clientRow, oauthClientIdValues), |
| 841 | mapId(clientRow.clientSecretItemId, idOverrides), |
no test coverage detected