Skip to content

feat!: SDK 8 and provisioning-sdk 3 previews (draft, do not merge) - #250

Draft
pviti wants to merge 5 commits into
monorepofrom
feat/sdk-8-preview
Draft

pviti wants to merge 5 commits into
monorepofrom
feat/sdk-8-preview

Conversation

@pviti

@pviti pviti commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Draft — do not merge. The SDK-independent changes went to #251 (merged); only what SDK 8 needs is here.

Do not merge: the catalog points at the pkg.pr.new previews of SDK 8 (commercelayer-sdk 5259929, branch pkg-pr-new-staging1): @commercelayer/sdk 8.0.0-beta.13 and @commercelayer/provisioning-sdk 3.0.0-beta.1. To be updated with each new preview and merged once SDK 8 is on npm.

Changes in the CLI

  • apiVersion: this is a version-aware SDK build: its types require apiVersion (2017-08 | 2026-05), which becomes a path segment (/api/2026-05/orders). The production API doesn't serve versioned paths yet (checked: /api/skus → 401, /api/2017-08/skus and /api/2026-05/skus → 404), so requests stay unversioned by default (the SDK omits the segment at runtime when apiVersion is undefined).
  • --api-version, an operating parameter like --domain: the domain says where the requests go, and more API versions can answer there, so the version can be chosen, otherwise a default applies.
    • It is a hidden flag on every command that calls the Core API, set by CL_CLI_API_VERSION (as --domain by CL_CLI_DOMAIN), mostly to pick the environment in development (clCommand.apiVersionFlag, clApi.apiVersion in cli-core).
    • applications:login / applications:add --api-version <v> save it with the application, as the domain. The prerun hook adds it to the commands, and applications:scope keeps it. applications --extra shows an API VERSION column.
    • The default is clConfig.api.default_api_version (next to default_domain), unversioned for now. A version equal to the default isn't saved.
    • Precedence: the command's flag (or the version saved with the application), then CL_CLI_API_VERSION, then the default.
    • Tests: apiVersion precedence and default (core). The prerun hook adds the saved domain and API version only to commands that have the flags (cli, temporary config folder).
  • provisioning-sdk typings workaround: its CommonJS declarations (lib/index.d.cts) end with export =, which hides the named exports (CommerceLayerProvisioningStatic, QueryParams, …) from CommonJS code. plugins/provisioning/src/sdk.ts re-exports them typed with the ESM declarations; the runtime exports are fine. To remove once the SDK is fixed (see below).
  • resources: Node snippet with the named CommerceLayer import (the default export is deprecated); resource list regenerated from the SDK — from the staging1 schema, so it includes resources not yet in production (payment_*, …).
  • Tests: resources:schema prints the API version (2026-05) instead of a semver.
  • The SDK-independent parts (exports SDK 8 drops: resource classes, QueryArraySortable/QueryRecordSortable/QueryRecordFields; provisioning list mocks; integration on dependency changes) moved to refactor: stop using SDK exports that SDK 8 drops; integration on dependency changes #251.

To fix in the SDK

  1. CommonJS declarations: lib/index.d.cts of both packages ends with // @ts-ignore + export = <default> next to named exports. TypeScript (module nodenext, CommonJS consumers) then ignores the named exports: with the provisioning-sdk preview, CommerceLayerProvisioningStatic, QueryParams, ResourceTypeLock, RequestObj are "not exported". Dropping export = (keeping export default + named exports, or the cjsInterop option of tsup) would fix it.
  2. apiVersion and production: apiVersion is required by the types, but no value works against production today, where versioned paths answer 404. Either an unversioned option in the types, or 2017-08 mapped to the unversioned path.

Test plan

🤖 Generated with Claude Code

pviti and others added 2 commits October 1, 2026 18:03
SDK 8 can put an API version in the request path (/api/<version>/…).
clApi.apiVersion reads it from the --api-version flag, then
CL_CLI_API_VERSION; without one the requests stay unversioned, which
is what the production API serves today (versioned paths answer 404).
clCommand.apiVersionFlag is the shared flag definition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previews come from pkg.pr.new (commercelayer-sdk 5259929, built from
the staging1 schemas): @commercelayer/sdk 8.0.0-beta.13 and
@commercelayer/provisioning-sdk 3.0.0-beta.1. Not for release: the
catalog points at preview URLs until SDK 8 is on npm.

- The Core API clients pass apiVersion (clApi.apiVersion), and the
  commands that call the Core API get the --api-version flag; requests
  stay unversioned by default. The resources Node snippet uses the
  named CommerceLayer import (the default export is deprecated) and
  adds apiVersion when set.
- provisioning: the CommonJS declarations of the provisioning-sdk
  preview end with export=, which hides its named exports from
  CommonJS code. src/sdk.ts re-exports them typed with the ESM
  declarations (the runtime exports are fine); the cli patch does the
  same for CommerceLayerProvisioningStatic. To remove once the SDK
  fixes its declarations.
- Tests: resources:schema prints the API version (2026-05) instead of
  a semver.
- resources: the resource list is regenerated from the SDK (staging1
  schema, so it includes resources not yet in production).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pviti
pviti force-pushed the feat/sdk-8-preview branch from 391a3b5 to 8008678 Compare October 1, 2026 16:04
@pviti
pviti changed the base branch from monorepo to chore/sdk-agnostic October 1, 2026 16:04
@pviti
pviti changed the base branch from chore/sdk-agnostic to monorepo October 1, 2026 16:14
pviti and others added 3 commits October 2, 2026 12:41
The Core API version is an operating parameter, as the domain is: the
domain says where the requests go, and more API versions can answer
there, so the version can be given, or a default applies.

- The --api-version flag of the commands is hidden, set by
  CL_CLI_API_VERSION (as --domain by CL_CLI_DOMAIN).
- applications:login and applications:add take --api-version and save it
  with the application, as the domain; the prerun hook adds it to the
  commands' flags, and applications:scope keeps it.
- The default is clConfig.api.default_api_version (as default_domain),
  unversioned for now: production doesn't serve /api/<version>/… yet. A
  version equal to the default isn't saved.
- applications --extra shows the API VERSION column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant