Skip to content

Commit 6012f93

Browse files
authored
Isolate client config between multiple instances (#375)
2 parents 57aea59 + ffb8609 commit 6012f93

8 files changed

Lines changed: 679 additions & 388 deletions

File tree

.github/workflows/pkg-pr-new.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish preview package
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
- '!main'
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
workflow_dispatch:
11+
12+
jobs:
13+
preview:
14+
name: pkg.pr.new
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v7
19+
with:
20+
fetch-depth: 1
21+
22+
- name: Install pnpm
23+
uses: pnpm/action-setup@v6
24+
with:
25+
version: 11
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v7
29+
with:
30+
node-version: 'lts/*'
31+
cache: 'pnpm'
32+
33+
- name: Install dependencies
34+
run: pnpm install --frozen-lockfile
35+
36+
- name: Build package
37+
run: pnpm build
38+
39+
- name: Publish preview
40+
run: npx pkg-pr-new publish --no-template

gen/generator.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ export const CONFIG: ConfigType = {
2525
RELATIONSHIP_FUNCTIONS: true,
2626
TRIGGER_FUNCTIONS: true,
2727
RESOURCES_FULL_BUNDLE: true,
28-
RESOURCES_INSTANCE_STYLE: 'accessors_only'
28+
// Bundle clients must be isolated per access token. `leazy_loading` emits
29+
// private cache fields + lazy getters that bind each resource to the
30+
// client's own adapter (via `.withAdapter(this.adapter)`), instead of
31+
// `accessors_only` which returned the shared process-global singletons.
32+
RESOURCES_INSTANCE_STYLE: 'leazy_loading'
2933
}
3034
CONFIG.RESOURCES_STANDARD_OBJECT = (CONFIG.RESOURCES_INSTANCE_STYLE === 'standard_object')
3135
CONFIG.RESOURCES_LEAZY_LOADING = (CONFIG.RESOURCES_INSTANCE_STYLE === 'leazy_loading')

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,23 @@
5757
"node": ">=20"
5858
},
5959
"devDependencies": {
60-
"@biomejs/biome": "^2.5.1",
60+
"@biomejs/biome": "^2.5.4",
6161
"@commercelayer/js-auth": "^7.4.2",
6262
"@semantic-release/changelog": "^6.0.3",
6363
"@semantic-release/git": "^10.0.1",
6464
"@types/debug": "^4.1.13",
65-
"@types/node": "^25.9.4",
66-
"@vitest/coverage-v8": "^4.1.9",
67-
"@vitest/eslint-plugin": "^1.6.20",
65+
"@types/node": "^25.9.5",
66+
"@vitest/coverage-v8": "^4.1.10",
67+
"@vitest/eslint-plugin": "^1.6.23",
6868
"conventional-changelog-conventionalcommits": "^9.3.1",
6969
"dotenv": "^17.4.2",
7070
"json-typescript": "^1.1.2",
7171
"jsonapi-typescript": "^0.1.3",
72-
"semantic-release": "^25.0.5",
72+
"semantic-release": "^25.0.7",
7373
"tsup": "^8.5.1",
74-
"tsx": "^4.22.4",
74+
"tsx": "^4.23.1",
7575
"typescript": "^5.9.3",
76-
"vitest": "^4.1.9"
76+
"vitest": "^4.1.10"
7777
},
7878
"repository": "github:commercelayer/commercelayer-sdk",
7979
"bugs": "https://github.com/commercelayer/commercelayer-sdk/issues",

0 commit comments

Comments
 (0)