diff --git a/README.md b/README.md index ae4ec5b2..80e18a19 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,32 @@ await client.payments.create({ }); ``` +### Subpath imports + +For applications where startup latency matters (serverless cold starts, autoscaling +boots, etc.), the SDK exposes its internal modules as package subpaths so consumers +can avoid loading the full surface — including the ~1,300 runtime serialization +schemas — when they only need a slice of it. + +```typescript +// Just the type definitions for a single resource — no runtime schemas loaded. +import type { Payment, Money } from "square/api/types/Payment"; + +// Just one resource client. +import { PaymentsClient } from "square/api/resources/payments"; + +// Just the runtime serialization for a single model, e.g. for a custom worker +// that needs to (de)serialize Square payloads without booting the client. +import { Payment as PaymentSchema } from "square/serialization/types/Payment"; + +// Just the SDK entry-point class and constants. +import { SquareClient } from "square/Client"; +import { SquareEnvironment } from "square/environments"; +``` + +The default `import { SquareClient } from "square"` entry continues to re-export the +full surface and remains the recommended import for typical usage. + ## Legacy SDK ## Legacy SDK diff --git a/package.json b/package.json index 483ff3dc..9fb7b5c0 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,51 @@ }, "exports": { ".": "./index.js", + "./api": { + "types": "./api/index.d.ts", + "default": "./api/index.js" + }, + "./api/resources/*": { + "types": "./api/resources/*/index.d.ts", + "default": "./api/resources/*/index.js" + }, + "./api/types/*": { + "types": "./api/types/*.d.ts", + "default": "./api/types/*.js" + }, + "./serialization": { + "types": "./serialization/index.d.ts", + "default": "./serialization/index.js" + }, + "./serialization/resources/*": { + "types": "./serialization/resources/*/index.d.ts", + "default": "./serialization/resources/*/index.js" + }, + "./serialization/types/*": { + "types": "./serialization/types/*.d.ts", + "default": "./serialization/types/*.js" + }, + "./Client": { + "types": "./Client.d.ts", + "default": "./Client.js" + }, + "./BaseClient": { + "types": "./BaseClient.d.ts", + "default": "./BaseClient.js" + }, + "./environments": { + "types": "./environments.d.ts", + "default": "./environments.js" + }, + "./errors": { + "types": "./errors/index.d.ts", + "default": "./errors/index.js" + }, + "./version": { + "types": "./version.d.ts", + "default": "./version.js" + }, + "./package.json": "./package.json", "./legacy": { "types": "./legacy/exports/index.d.ts", "require": {