Skip to content

Commit 4c5d377

Browse files
release(v2.1.1-beta): add latest type declarations
* chore(api): update models and methods for latest openapi.json changes * automate manual fixes for auto-generated type errors with diff patch file in pre-commit hook
1 parent 95c570f commit 4c5d377

39 files changed

+322
-148
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- [ ] My code follows the code style of this project.
1313
- [ ] I have tested this code.
1414
- [ ] I have performed a self-review of my own code.
15-
- [ ] I have made corresponding changes to the documentation if needed.
15+
- [ ] (optional) I have made corresponding changes to the documentation
1616

1717
## Screenshots (if applicable)
1818

.github/workflows/deploy-docs.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,17 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v4
23-
- uses: actions/setup-node@v4
23+
24+
- name: Read Node version for CI from package.json
25+
id: node-version
26+
run: |
27+
NODE_VERSION=$(jq -r '.ci.node' package.json)
28+
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT
29+
30+
- name: Set up Node.js
31+
uses: actions/setup-node@v4
2432
with:
25-
node-version: 18
33+
node-version: ${{ steps.node-version.outputs.node_version }}
2634

2735
- name: Cache Yarn packages
2836
uses: actions/cache@v4
@@ -50,4 +58,4 @@ jobs:
5058
id: deployment
5159
uses: actions/deploy-pages@v4
5260
with:
53-
folder: docs
61+
folder: docs

.github/workflows/npm-publish.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,27 @@ on:
1313
env:
1414
RELEASE_NODE_VERSION: "18.x" # https://nodejs.dev/en/about/releases
1515

16+
permissions:
17+
contents: read
18+
1619
jobs:
1720
publish-dry-run:
1821
runs-on: ubuntu-latest
1922
environment: release
2023

2124
steps:
2225
- uses: actions/checkout@v4
23-
- uses: actions/setup-node@v4
26+
27+
- name: Read Node version for CI from package.json
28+
id: node-version
29+
run: |
30+
NODE_VERSION=$(jq -r '.ci.node' package.json)
31+
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT
32+
33+
- name: Set up Node.js
34+
uses: actions/setup-node@v4
2435
with:
25-
node-version: ${{ env.RELEASE_NODE_VERSION }}
26-
registry-url: "https://registry.npmjs.org"
36+
node-version: ${{ steps.node-version.outputs.node_version }}
2737

2838
- name: Cache Yarn packages
2939
uses: actions/cache@v4

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ $ yarn run generate-sdk
7777
$ yarn run release
7878
```
7979

80-
If any TypeScript errors occur, make manual edits:
80+
You may run into type errors after generating `src` code with `openapi-typescript-codegen`. To resolve this, we created `overrides.patch` wich will force apply changes during pre-commit and build.
8181

82+
1. Make manual changes to fix Typescript errors
83+
2. Create a patch diff `git diff src/index.ts >> overrides.patch && git commit overrides.patch`
84+
85+
Example:
8286
```diff
8387
// index.ts
8488
export { Placement } from './models/Placement';

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![NPM Version](https://img.shields.io/npm/v/printful-sdk-js-v2)](https://www.npmjs.com/package/printful-sdk-js-v2)
44
![MIT license](https://img.shields.io/badge/License-MIT-blue.svg) ![TypeScript](https://img.shields.io/badge/TypeScript-Ready-green.svg)
5-
![package size](https://img.shields.io/bundlephobia/minzip/printful-sdk-js-v2) [![Socket.dev Vulnerabilities](https://img.shields.io/badge/Security-Socket.dev%20Scan-brightgreen?logo=socket&logoColor=white)](https://socket.dev/npm/package/printful-sdk-js-v2)
5+
![package size](https://img.shields.io/bundlephobia/minzip/printful-sdk-js-v2) [![Socket Badge](https://socket.dev//api/badge/npm/package/printful-sdk-js-v2/2.0.0-beta)](https://socket.dev//npm/package/printful-sdk-js-v2/overview/2.0.0-beta)
66

77
A lightweight SDK for interacting with the Printful RESTful API, written in TypeScript. Designed for server-side use in Node.js environments.
88

overrides.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/index.ts b/src/index.ts
2+
index 826809d..fd8bf7a 100644
3+
--- a/src/index.ts
4+
+++ b/src/index.ts
5+
@@ -108,7 +108,7 @@ export type { PackingSlipReadonly } from './models/PackingSlipReadonly';
6+
export type { Paging } from './models/Paging';
7+
export type { ParameterSource } from './models/ParameterSource';
8+
export type { PathStoreId } from './models/PathStoreId';
9+
-export { Placement } from './models/Placement';
10+
+// export { Placement } from './models/Placement';
11+
export type { Placement } from './models/Placement';
12+
export { Placement_2 } from './models/Placement_2';
13+
export type { PlacementList } from './models/PlacementList';

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "printful-sdk-js-v2",
3-
"version": "2.1.0-beta",
3+
"version": "2.1.1-beta",
44
"description": "Printful SDK for Node.js / TypeScript. A wrapper for the Printful REST API (v2)",
55
"author": "Spencer Lepine <spencer.sayhello@gmail.com>",
66
"license": "MIT",
@@ -49,10 +49,12 @@
4949
"scripts": {
5050
"test": "jest",
5151
"bundle": "rollup -c",
52+
"apply-overrides": "git apply overrides.patch && git add src",
5253
"generate-sdk": "openapi --input ./openapi.json --output ./src --name PrintfulClient",
5354
"generate-docs": "typedoc src/index.ts",
54-
"release": "npm run bundle && npm run generate-docs",
55-
"audit:fix": "npm_config_yes=true npx yarn-audit-fix"
55+
"release": "npm run generate-sdk && npm run apply-overrides && npm run bundle && npm run generate-docs",
56+
"audit:fix": "npm_config_yes=true npx yarn-audit-fix",
57+
"pre-commit": "lint-staged && npm run release"
5658
},
5759
"devDependencies": {
5860
"@rollup/plugin-commonjs": "^26.0.1",
@@ -85,7 +87,7 @@
8587
},
8688
"husky": {
8789
"hooks": {
88-
"pre-commit": "lint-staged && npm run release"
90+
"pre-commit": "npm run pre-commit"
8991
}
9092
},
9193
"lint-staged": {

src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export type { DateFrom } from './models/DateFrom';
4343
export type { DateTo } from './models/DateTo';
4444
export type { DefaultEventConfigurationRequest } from './models/DefaultEventConfigurationRequest';
4545
export type { DesignPlacement } from './models/DesignPlacement';
46+
export type { DestinationCountry } from './models/DestinationCountry';
4647
export { dPuffOption } from './models/dPuffOption';
4748
export type { Error } from './models/Error';
4849
export type { EstimationAddress } from './models/EstimationAddress';
@@ -64,6 +65,7 @@ export type { Item } from './models/Item';
6465
export type { ItemExternalId } from './models/ItemExternalId';
6566
export type { ItemId } from './models/ItemId';
6667
export type { ItemReadonly } from './models/ItemReadonly';
68+
export type { ItemWithoutPlacements } from './models/ItemWithoutPlacements';
6769
export type { ItemWithoutPlacementsReadonly } from './models/ItemWithoutPlacementsReadonly';
6870
export { KnitwearBaseColor } from './models/KnitwearBaseColor';
6971
export { KnitwearColorReductionMode } from './models/KnitwearColorReductionMode';
@@ -106,8 +108,10 @@ export type { PackingSlipReadonly } from './models/PackingSlipReadonly';
106108
export type { Paging } from './models/Paging';
107109
export type { ParameterSource } from './models/ParameterSource';
108110
export type { PathStoreId } from './models/PathStoreId';
109-
export { Placement } from './models/Placement';
110-
export type { PlacementFilter } from './models/PlacementFilter';
111+
// export { Placement } from './models/Placement';
112+
export type { Placement } from './models/Placement';
113+
export { Placement_2 } from './models/Placement_2';
114+
export type { PlacementList } from './models/PlacementList';
111115
export type { PlacementOptions } from './models/PlacementOptions';
112116
export type { PlacementsFilter } from './models/PlacementsFilter';
113117
export type { PlacementsList } from './models/PlacementsList';
@@ -125,6 +129,7 @@ export type { ProductPrices } from './models/ProductPrices';
125129
export type { ProductSizeGuide } from './models/ProductSizeGuide';
126130
export type { ProductsLinks } from './models/ProductsLinks';
127131
export type { ProductsParam } from './models/ProductsParam';
132+
export { ProductTemplateItem } from './models/ProductTemplateItem';
128133
export type { Profit } from './models/Profit';
129134
export { ReportTypes } from './models/ReportTypes';
130135
export type { Response200 } from './models/Response200';
@@ -141,6 +146,7 @@ export { Shipment } from './models/Shipment';
141146
export type { Shipment_2 } from './models/Shipment_2';
142147
export type { ShipmentItem } from './models/ShipmentItem';
143148
export type { ShipmentItem_2 } from './models/ShipmentItem_2';
149+
export type { ShippingCountry } from './models/ShippingCountry';
144150
export type { ShippingRatesAddress } from './models/ShippingRatesAddress';
145151
export type { ShowExpired } from './models/ShowExpired';
146152
export { SizeTable } from './models/SizeTable';

src/models/BaseMockupProduct.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export type BaseMockupProduct = {
1616
* Available mockup styles for catalog product can be found under _[Retrieve catalog product mockup styles](#operation/retrieveMockupStylesByProductId)_.
1717
*
1818
*/
19-
mockup_style_ids: Array<number>;
19+
mockup_style_ids?: Array<number>;
2020
};
2121

src/models/CatalogShippingRateItem.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/* istanbul ignore file */
33
/* tslint:disable */
44
/* eslint-disable */
5+
import type { PlacementList } from './PlacementList';
6+
import type { ProductOptions } from './ProductOptions';
57
export type CatalogShippingRateItem = {
68
/**
79
* Catalog source
@@ -15,6 +17,8 @@ export type CatalogShippingRateItem = {
1517
* ID of catalog variant
1618
*/
1719
catalog_variant_id: number;
20+
placements?: PlacementList;
21+
product_options?: ProductOptions;
1822
};
1923
export namespace CatalogShippingRateItem {
2024
/**

0 commit comments

Comments
 (0)