sdk-module-development
БесплатноБез исполняемых скриптовНе проверенAdding new modules and exports to the @salesforce/b2c-tooling-sdk package. Use when creating a new SDK module, adding barrel file exports, configuring…
Об этом скилле
SDK Module Development
This skill covers adding new modules and exports to the @salesforce/b2c-tooling-sdk package.
Package Structure
The SDK is organized into functional layers:
packages/b2c-tooling-sdk/src/
├── auth/ # Authentication strategies
├── instance/ # B2CInstance entry point
├── clients/ # HTTP clients (WebDAV, OCAPI, SLAS, ODS, MRT)
├── platform/ # Platform APIs
├── operations/ # High-level business operations
│ ├── code/ # Code deployment
│ ├── jobs/ # Job execution
│ ├── sites/ # Site management
│ └── mrt/ # MRT deployments
├── cli/ # Base command classes for oclif
├── logging/ # Pino-based logging
├── errors/ # Error types
├── config/ # Configuration loading
└── i18n/ # Internationalization
Barrel File Pattern
Each module uses an index.ts barrel file that exports the public API:
/**
* Authentication strategies for B2C Commerce APIs.
*
* This module provides various authentication mechanisms for B2C Commerce:
* - OAuth 2.0 client credentials flow
* - Basic authentication for WebDAV
* - API key authentication
*
* @example
* ```typescript
* import { OAuthStrategy } from '@salesforce/b2c-tooling-sdk/auth';
*
* const auth = new OAuthStrategy({
* clientId: 'my-client',
* clientSecret: 'my-secret',
* });
* ```
*
* @module auth
*/
// Types
export type { AuthStrategy, AuthConfig } from './types.js';
// Strategies
export { BasicAuthStrategy } from './basic.js';
export { OAuthStrategy, decodeJWT } from './oauth.js';
// Resolution helpers
export { resolveAuthStrategy, checkAvailableAuthMethods } from './resolve.js';
Key points:
- Module-level JSDoc with
@moduletag for TypeDoc - Include usage examples in the JSDoc
- Group exports logically (types, classes, functions)
- Only export public API items
Package.json Exports
The exports field in packages/b2c-tooling-sdk/package.json uses a development condition pattern:
{
"exports": {
"./newmodule": {
"development": "./src/newmodule/index.ts",
"import": {
"types": "./dist/esm/newmodule/index.d.ts",
"default": "./dist/esm/newmodule/index.js"
},
"require": {
"types": "./dist/cjs/newmodule/index.d.ts",
"default": "./dist/cjs/newmodule/index.js"
}
}
}
}
The development condition:
- Points directly to TypeScript source files
- Used when running with
--conditions=development(viabin/dev.js) - Enables hot-reloading during development without rebuilding
Client Factory Pattern
HTTP clients follow a consistent factory function pattern. Always build them with createHttpClient(options, auth) from src/clients/http-transport.ts (and use getApiFetch(auth) instead of the global fetch for direct API requests) so the auth strategy's transport options apply — see API Client Development.
// src/clients/newapi.ts
import type { Client } from 'openapi-fetch';
import { createHttpClient } from './http-transport.js';
import type { AuthStrategy } from '../auth/types.js';
import type { paths, components } from './newapi.generated.js';
import { createAuthMiddleware, createLoggingMiddleware } from './middleware.js';
// Re-export generated types for consumers
export type { paths, components };
// Define client type alias
export type NewApiClient = Client<paths>;
// Factory function (not class)
export function createNewApiClient(
hostname: string,
auth: AuthStrategy,
options?: { apiVersion?: string }
): NewApiClient {
const { apiVersion = 'v1' } = options ?? {};
const client = createHttpClient<paths>({
baseUrl: `https://${hostname}/api/newapi/${apiVersion}`,
}, auth);
// Middleware order: auth first (runs last), logging last (sees complete request)
client.use(createAuthMiddleware(auth));
client.use(createLoggingMiddleware('NEWAPI'));
return client;
}
Then export from the clients barrel:
// src/clients/index.ts
export { createNewApiClient } from './newapi.js';
export type { NewApiClient, paths as NewApiPaths, components as NewApiComponents } from './newapi.js';
For SCAPI clients with OAuth scope requirements, see API Client Development for advanced patterns including scope injection and tenant ID handling.
OpenAPI Type Generation
For APIs with OpenAPI specs, generate TypeScript types:
Add the spec file to
packages/b2c-tooling-sdk/specs/Update the generate script in
package.json:
{
"scripts": {
"generate:types": "openapi-typescript specs/data-api.json -o src/clients/ocapi.generated.ts && openapi-typescript specs/newapi-v1.yaml -o src/clients/newapi.generated.ts"
}
}
- Run generation:
pnpm --filter @salesforce/b2c-tooling-sdk run generate:types
`
Установить sdk-module-development в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл sdk-module-development?
Adding new modules and exports to the @salesforce/b2c-tooling-sdk package. Use when creating a new SDK module, adding barrel file exports, configuring package.json exports, or building client factory functions.
Как установить скилл sdk-module-development?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sdk-module-development запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic