@efaj/pulumi-dynamic-stripe 0.0.2-bf2823e → 0.0.2-bfb0df3

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 CHANGED
@@ -71,3 +71,18 @@ export const paymentUrl = premiumPaymentLink.url;
71
71
  ## How it works
72
72
 
73
73
  Behind the scenes, this library defines custom Pulumi Dynamic Resource Providers that implement the CRUD operations for Stripe entities via the `@pulumi/pulumi` and `stripe` Node packages.
74
+
75
+ ## Development
76
+
77
+ If you wish to contribute or build the project locally, please use the provided `Makefile`.
78
+
79
+ ```bash
80
+ # Install dependencies
81
+ make install
82
+
83
+ # Build the TypeScript source
84
+ make build
85
+
86
+ # Run the Vitest test suite
87
+ make test
88
+ ```
@@ -41,7 +41,7 @@ const pulumi = __importStar(require("@pulumi/pulumi"));
41
41
  const stripe_1 = __importDefault(require("stripe"));
42
42
  class StripePaymentLinkProvider {
43
43
  async create(inputs) {
44
- const stripe = new stripe_1.default(inputs.apiKey, { apiVersion: '2022-11-15' });
44
+ const stripe = new stripe_1.default(inputs.apiKey);
45
45
  const paymentLink = await stripe.paymentLinks.create({
46
46
  line_items: [{
47
47
  price: inputs.priceId,
@@ -93,7 +93,7 @@ class StripePaymentLinkProvider {
93
93
  };
94
94
  }
95
95
  async delete(id, props) {
96
- const stripe = new stripe_1.default(props.apiKey, { apiVersion: '2022-11-15' });
96
+ const stripe = new stripe_1.default(props.apiKey);
97
97
  await stripe.paymentLinks.update(id, { active: false });
98
98
  }
99
99
  }
@@ -41,7 +41,7 @@ const pulumi = __importStar(require("@pulumi/pulumi"));
41
41
  const stripe_1 = __importDefault(require("stripe"));
42
42
  class StripePriceProvider {
43
43
  async create(inputs) {
44
- const stripe = new stripe_1.default(inputs.apiKey, { apiVersion: '2022-11-15' });
44
+ const stripe = new stripe_1.default(inputs.apiKey);
45
45
  const price = await stripe.prices.create({
46
46
  product: inputs.productId,
47
47
  unit_amount: inputs.unitAmount,
@@ -71,7 +71,7 @@ class StripePriceProvider {
71
71
  };
72
72
  }
73
73
  async delete(id, props) {
74
- const stripe = new stripe_1.default(props.apiKey, { apiVersion: '2022-11-15' });
74
+ const stripe = new stripe_1.default(props.apiKey);
75
75
  await stripe.prices.update(id, { active: false });
76
76
  }
77
77
  }
@@ -41,7 +41,7 @@ const pulumi = __importStar(require("@pulumi/pulumi"));
41
41
  const stripe_1 = __importDefault(require("stripe"));
42
42
  class StripeProductProvider {
43
43
  async create(inputs) {
44
- const stripe = new stripe_1.default(inputs.apiKey, { apiVersion: '2022-11-15' });
44
+ const stripe = new stripe_1.default(inputs.apiKey);
45
45
  const product = await stripe.products.create({
46
46
  name: inputs.name,
47
47
  description: inputs.description,
@@ -71,7 +71,7 @@ class StripeProductProvider {
71
71
  };
72
72
  }
73
73
  async update(id, olds, news) {
74
- const stripe = new stripe_1.default(news.apiKey, { apiVersion: '2022-11-15' });
74
+ const stripe = new stripe_1.default(news.apiKey);
75
75
  await stripe.products.update(id, {
76
76
  name: news.name,
77
77
  description: news.description,
@@ -85,7 +85,7 @@ class StripeProductProvider {
85
85
  };
86
86
  }
87
87
  async delete(id, props) {
88
- const stripe = new stripe_1.default(props.apiKey, { apiVersion: '2022-11-15' });
88
+ const stripe = new stripe_1.default(props.apiKey);
89
89
  await stripe.products.update(id, { active: false });
90
90
  }
91
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efaj/pulumi-dynamic-stripe",
3
- "version": "0.0.2-bf2823e",
3
+ "version": "0.0.2-bfb0df3",
4
4
  "description": "A Pulumi Dynamic Provider for Stripe, supporting modern features like Payment Links.",
5
5
  "keywords": [
6
6
  "pulumi",
@@ -22,17 +22,15 @@
22
22
  "scripts": {
23
23
  "build": "tsc",
24
24
  "prepare": "tsc",
25
- "test": "jest"
25
+ "test": "vitest run"
26
26
  },
27
27
  "dependencies": {
28
28
  "@pulumi/pulumi": "^3.259.0",
29
29
  "stripe": "^22.6.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/jest": "^30.0.0",
33
32
  "@types/node": "^26.4.0",
34
- "jest": "^30.4.2",
35
- "ts-jest": "^29.4.12",
33
+ "vitest": "^2.0.5",
36
34
  "typescript": "^6.0.3"
37
35
  }
38
36
  }
@@ -1,32 +1,33 @@
1
1
  import { StripePaymentLinkProvider, StripeProductProvider, StripePriceProvider } from "../src/index";
2
2
  import Stripe from "stripe";
3
- import { describe, it, expect, jest, beforeEach } from '@jest/globals';
3
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
4
+ import type { Mock } from 'vitest';
4
5
 
5
6
  // Mock the Stripe SDK
6
- jest.mock("stripe");
7
+ vi.mock("stripe");
7
8
 
8
- const MockedStripe = Stripe as jest.MockedClass<typeof Stripe>;
9
+ const MockedStripe = Stripe as any;
9
10
 
10
11
  describe("Stripe Providers", () => {
11
- let mockPaymentLinksCreate: jest.Mock<any>;
12
- let mockPaymentLinksUpdate: jest.Mock<any>;
13
- let mockProductsCreate: jest.Mock<any>;
14
- let mockProductsUpdate: jest.Mock<any>;
15
- let mockPricesCreate: jest.Mock<any>;
16
- let mockPricesUpdate: jest.Mock<any>;
12
+ let mockPaymentLinksCreate: Mock<any>;
13
+ let mockPaymentLinksUpdate: Mock<any>;
14
+ let mockProductsCreate: Mock<any>;
15
+ let mockProductsUpdate: Mock<any>;
16
+ let mockPricesCreate: Mock<any>;
17
+ let mockPricesUpdate: Mock<any>;
17
18
 
18
19
  beforeEach(() => {
19
20
  // Reset mocks before each test
20
- jest.clearAllMocks();
21
+ vi.clearAllMocks();
21
22
 
22
- mockPaymentLinksCreate = jest.fn<any>().mockResolvedValue({ id: "plink_123", url: "https://stripe.com/plink_123" } as any);
23
- mockPaymentLinksUpdate = jest.fn<any>().mockResolvedValue({ id: "plink_123" } as any);
23
+ mockPaymentLinksCreate = vi.fn<any>().mockResolvedValue({ id: "plink_123", url: "https://stripe.com/plink_123" } as any);
24
+ mockPaymentLinksUpdate = vi.fn<any>().mockResolvedValue({ id: "plink_123" } as any);
24
25
 
25
- mockProductsCreate = jest.fn<any>().mockResolvedValue({ id: "prod_123" } as any);
26
- mockProductsUpdate = jest.fn<any>().mockResolvedValue({ id: "prod_123" } as any);
26
+ mockProductsCreate = vi.fn<any>().mockResolvedValue({ id: "prod_123" } as any);
27
+ mockProductsUpdate = vi.fn<any>().mockResolvedValue({ id: "prod_123" } as any);
27
28
 
28
- mockPricesCreate = jest.fn<any>().mockResolvedValue({ id: "price_123" } as any);
29
- mockPricesUpdate = jest.fn<any>().mockResolvedValue({ id: "price_123" } as any);
29
+ mockPricesCreate = vi.fn<any>().mockResolvedValue({ id: "price_123" } as any);
30
+ mockPricesUpdate = vi.fn<any>().mockResolvedValue({ id: "price_123" } as any);
30
31
 
31
32
  // Setup the mocked Stripe instance's internal resource objects
32
33
  MockedStripe.mockImplementation(() => {
@@ -102,7 +103,7 @@ describe("Stripe Providers", () => {
102
103
  expect(result.outs?.paymentLinkId).toBe("plink_123");
103
104
  expect(result.outs?.url).toBe("https://stripe.com/plink_123");
104
105
 
105
- expect(MockedStripe).toHaveBeenCalledWith(inputs.apiKey, { apiVersion: '2022-11-15' as any });
106
+ expect(MockedStripe).toHaveBeenCalledWith(inputs.apiKey);
106
107
  expect(mockPaymentLinksCreate).toHaveBeenCalledWith(expectedPayload);
107
108
  });
108
109
  });
@@ -187,7 +188,7 @@ describe("Stripe Providers", () => {
187
188
  expect(result.id).toBe("prod_123");
188
189
  expect(result.outs?.productId).toBe("prod_123");
189
190
 
190
- expect(MockedStripe).toHaveBeenCalledWith(inputs.apiKey, { apiVersion: '2022-11-15' as any });
191
+ expect(MockedStripe).toHaveBeenCalledWith(inputs.apiKey);
191
192
  expect(mockProductsCreate).toHaveBeenCalledWith(expectedPayload);
192
193
  });
193
194
  });
@@ -274,7 +275,7 @@ describe("Stripe Providers", () => {
274
275
  expect(result.id).toBe("price_123");
275
276
  expect(result.outs?.priceId).toBe("price_123");
276
277
 
277
- expect(MockedStripe).toHaveBeenCalledWith(inputs.apiKey, { apiVersion: '2022-11-15' as any });
278
+ expect(MockedStripe).toHaveBeenCalledWith(inputs.apiKey);
278
279
  expect(mockPricesCreate).toHaveBeenCalledWith(expectedPayload);
279
280
  });
280
281
  });
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ['tests/**/*.test.ts'],
6
+ },
7
+ });
package/jest.config.js DELETED
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- preset: 'ts-jest',
3
- testEnvironment: 'node',
4
- testMatch: ['**/tests/**/*.test.ts'],
5
- };