Skip to content

Commit 31df340

Browse files
committed
refactor(payments): merge credential setup into pre-deploy-identity
Payment credential providers use the same /identities/ endpoint as API key and OAuth providers. Move setupPaymentCredentialProviders, hasPaymentCredentialProviders, and cleanupPaymentCredentialProviders into pre-deploy-identity.ts alongside the other credential provider operations. - Delete pre-deploy-payments.ts (merged into pre-deploy-identity.ts) - Delete payment-types.ts (types inlined in pre-deploy-identity.ts) - Rename: setupPaymentResources → setupPaymentCredentialProviders - Rename: hasPaymentManagers → hasPaymentCredentialProviders - Update all import paths and barrel exports - Update test imports
1 parent a8e6cb6 commit 31df340

7 files changed

Lines changed: 265 additions & 302 deletions

File tree

src/cli/commands/deploy/actions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ import { setupHttpGateways } from '../../operations/deploy/post-deploy-http-gate
4444
import { enableOnlineEvalConfigs } from '../../operations/deploy/post-deploy-online-evals';
4545
import {
4646
cleanupPaymentCredentialProviders,
47-
hasPaymentManagers,
48-
setupPaymentResources,
49-
} from '../../operations/deploy/pre-deploy-payments';
47+
hasPaymentCredentialProviders,
48+
setupPaymentCredentialProviders,
49+
} from '../../operations/deploy/pre-deploy-identity';
5050
import { toStackName } from '../import/import-utils';
5151
import type { DeployResult } from './types';
5252
import { StackSelectionStrategy } from '@aws-cdk/toolkit-lib';
@@ -261,10 +261,10 @@ export async function handleDeploy(options: ValidatedDeployOptions): Promise<Dep
261261

262262
// Set up payment credential providers before CDK synth (secrets stay imperative)
263263
// PaymentManager, PaymentConnector, and IAM roles are created by CDK constructs
264-
if (hasPaymentManagers(context.projectSpec)) {
264+
if (hasPaymentCredentialProviders(context.projectSpec)) {
265265
startStep('Setting up payment credentials...');
266266

267-
const paymentPreDeployResult = await setupPaymentResources({
267+
const paymentPreDeployResult = await setupPaymentCredentialProviders({
268268
projectSpec: context.projectSpec,
269269
configBaseDir: configIO.getConfigRoot(),
270270
region: target.region,

src/cli/operations/deploy/__tests__/pre-deploy-payments.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cleanupPaymentCredentialProviders, setupPaymentResources } from '../pre-deploy-payments.js';
1+
import { cleanupPaymentCredentialProviders, setupPaymentCredentialProviders } from '../pre-deploy-identity.js';
22
import { afterEach, describe, expect, it, vi } from 'vitest';
33

44
// ============================================================================
@@ -115,10 +115,10 @@ function makeStripePrivySpec(credentialName = 'my-stripe-cred') {
115115
}
116116

117117
// ============================================================================
118-
// setupPaymentResources
118+
// setupPaymentCredentialProviders
119119
// ============================================================================
120120

121-
describe('setupPaymentResources', () => {
121+
describe('setupPaymentCredentialProviders', () => {
122122
afterEach(() => vi.clearAllMocks());
123123

124124
it('returns empty credentialProviders when payments array is empty', async () => {
@@ -129,7 +129,7 @@ describe('setupPaymentResources', () => {
129129
runtimes: [],
130130
};
131131

132-
const result = await setupPaymentResources({
132+
const result = await setupPaymentCredentialProviders({
133133
projectSpec: projectSpec as any,
134134
configBaseDir: BASE_DIR,
135135
region: REGION,
@@ -145,7 +145,7 @@ describe('setupPaymentResources', () => {
145145
it('returns error when .env.local does not exist', async () => {
146146
mockExistsSync.mockReturnValue(false);
147147

148-
const result = await setupPaymentResources({
148+
const result = await setupPaymentCredentialProviders({
149149
projectSpec: makeCoinbaseSpec() as any,
150150
configBaseDir: BASE_DIR,
151151
region: REGION,
@@ -164,7 +164,7 @@ describe('setupPaymentResources', () => {
164164
it('lists all required StripePrivy vars in the missing .env.local error', async () => {
165165
mockExistsSync.mockReturnValue(false);
166166

167-
const result = await setupPaymentResources({
167+
const result = await setupPaymentCredentialProviders({
168168
projectSpec: makeStripePrivySpec() as any,
169169
configBaseDir: BASE_DIR,
170170
region: REGION,
@@ -190,7 +190,7 @@ describe('setupPaymentResources', () => {
190190
status: 'ACTIVE',
191191
});
192192

193-
const result = await setupPaymentResources({
193+
const result = await setupPaymentCredentialProviders({
194194
projectSpec: makeCoinbaseSpec() as any,
195195
configBaseDir: BASE_DIR,
196196
region: REGION,
@@ -223,7 +223,7 @@ describe('setupPaymentResources', () => {
223223
status: 'ACTIVE',
224224
});
225225

226-
const result = await setupPaymentResources({
226+
const result = await setupPaymentCredentialProviders({
227227
projectSpec: makeCoinbaseSpec() as any,
228228
configBaseDir: BASE_DIR,
229229
region: REGION,
@@ -245,7 +245,7 @@ describe('setupPaymentResources', () => {
245245
});
246246
mockGetPaymentCredentialProvider.mockResolvedValue(null);
247247

248-
const result = await setupPaymentResources({
248+
const result = await setupPaymentCredentialProviders({
249249
projectSpec: makeCoinbaseSpec() as any,
250250
configBaseDir: BASE_DIR,
251251
region: REGION,
@@ -267,7 +267,7 @@ describe('setupPaymentResources', () => {
267267
});
268268
mockGetPaymentCredentialProvider.mockResolvedValue(null);
269269

270-
const result = await setupPaymentResources({
270+
const result = await setupPaymentCredentialProviders({
271271
projectSpec: makeStripePrivySpec() as any,
272272
configBaseDir: BASE_DIR,
273273
region: REGION,
@@ -295,7 +295,7 @@ describe('setupPaymentResources', () => {
295295
status: 'ACTIVE',
296296
});
297297

298-
await setupPaymentResources({
298+
await setupPaymentCredentialProviders({
299299
projectSpec: makeCoinbaseSpec() as any,
300300
configBaseDir: BASE_DIR,
301301
region: REGION,
@@ -327,7 +327,7 @@ describe('setupPaymentResources', () => {
327327
status: 'ACTIVE',
328328
});
329329

330-
await setupPaymentResources({
330+
await setupPaymentCredentialProviders({
331331
projectSpec: makeStripePrivySpec() as any,
332332
configBaseDir: BASE_DIR,
333333
region: REGION,

src/cli/operations/deploy/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ export {
4141
type DestroyTargetOptions,
4242
} from './teardown';
4343

44-
// Pre-deploy payment setup
44+
// Pre-deploy payment credential setup
4545
export {
46-
setupPaymentResources,
47-
hasPaymentManagers,
46+
setupPaymentCredentialProviders,
47+
hasPaymentCredentialProviders,
4848
cleanupPaymentCredentialProviders,
49-
type SetupPaymentResourcesOptions,
50-
} from './pre-deploy-payments';
51-
52-
export type { PaymentPreDeployResult, PaymentCredentialProviderResult } from './payment-types';
49+
type SetupPaymentCredentialProvidersOptions,
50+
type PaymentCredentialProvidersResult,
51+
type PaymentCredentialProviderResult,
52+
} from './pre-deploy-identity';
5353

5454
// Post-deploy observability setup
5555
export { setupTransactionSearch } from './post-deploy-observability';

src/cli/operations/deploy/payment-types.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)