Skip to content

Commit

Permalink
Fixed API version in types (#2218)
Browse files Browse the repository at this point in the history
  • Loading branch information
prathmesh-stripe authored Oct 30, 2024
1 parent 6c42d32 commit 2f7a544
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions scripts/updateAPIVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const read = (file) => fs.readFileSync(path.resolve(file)).toString();
const write = (file, str) => fs.writeFileSync(path.resolve(file), str);
const edit = (file, cb) => write(file, cb(read(file)));

const API_VERSION = '2[0-9][2-9][0-9]-[0-9]{2}-[0-9]{2}';
const API_VERSION = '2[0-9][2-9][0-9]-[0-9]{2}-[0-9]{2}.[a-z]+';

const main = () => {
const matches = [
Expand Down Expand Up @@ -36,9 +36,6 @@ const main = () => {
);
});

replaceAPIVersion('README.md', 'apiVersion: [\'"]API_VERSION[\'"]');
replaceAPIVersion('package.json', '"types": "types/API_VERSION/index.d.ts');

replaceAPIVersion(
'types/lib.d.ts',
'export type LatestApiVersion = [\'"]API_VERSION[\'"]'
Expand Down
2 changes: 1 addition & 1 deletion types/lib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ declare module 'stripe' {
}): (...args: any[]) => Response<ResponseObject>; //eslint-disable-line @typescript-eslint/no-explicit-any
static MAX_BUFFERED_REQUEST_METRICS: number;
}
export type LatestApiVersion = '2024-09-30.acacia';
export type LatestApiVersion = '2024-10-28.acacia';
export type HttpAgent = Agent;
export type HttpProtocol = 'http' | 'https';

Expand Down
6 changes: 3 additions & 3 deletions types/test/typescriptTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Stripe from 'stripe';

let stripe = new Stripe('sk_test_123', {
apiVersion: '2024-09-30.acacia',
apiVersion: '2024-10-28.acacia',
});

stripe = new Stripe('sk_test_123');
Expand All @@ -26,7 +26,7 @@ stripe = new Stripe('sk_test_123', {

// Check config object.
stripe = new Stripe('sk_test_123', {
apiVersion: '2024-09-30.acacia',
apiVersion: '2024-10-28.acacia',
typescript: true,
maxNetworkRetries: 1,
timeout: 1000,
Expand All @@ -44,7 +44,7 @@ stripe = new Stripe('sk_test_123', {
description: 'test',
};
const opts: Stripe.RequestOptions = {
apiVersion: '2024-09-30.acacia',
apiVersion: '2024-10-28.acacia',
};
const customer: Stripe.Customer = await stripe.customers.create(params, opts);

Expand Down

0 comments on commit 2f7a544

Please sign in to comment.