opencals-storefront-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpencals Storefront API & SDK
Opencals Storefront API & SDK
You are integrating a real, revenue-carrying booking flow against the Opencals
hosted API. You do not implement availability maths, timezones, conflict
resolution, pricing or payments — the API owns all of that. Your job is to call
the right endpoints in the right order and render the results.
The SDK is (class-based, generated from the OpenAPI
spec). Every identifier in this skill's reference files is copied from that SDK —
never invent method names, parameters or enum values. If something you need
isn't documented here, read the generated types in
(or the source )
rather than guessing.
@opencals/storefront-sdknode_modules/@opencals/storefront-sdk/distsrc/client/*.gen.ts你正在对接Opencals托管API的真实盈利性预订流程。你不需要实现可用性计算、时区处理、冲突解决、定价或支付——这些都由API负责。你的工作是按正确的顺序调用对应的端点并渲染结果。
SDK为(基于类实现,由OpenAPI规范生成)。本技能参考文件中的所有标识符均来自该SDK——绝对不要自行编造方法名、参数或枚举值。 如果你需要的内容没有在此处记录,请查阅中的生成类型(或源文件),而不要猜测。
@opencals/storefront-sdknode_modules/@opencals/storefront-sdk/distsrc/client/*.gen.tsWhen to use this skill
何时使用本技能
Trigger on any Opencals API/SDK work: "book an appointment", "show available
slots", "apply a discount code", "let customers reschedule", "add a guest to a
booking", "collect a billing address at checkout", "why am I getting a 429",
"custom booking length", "customer login". If the task is "build me a whole
booking website from a template", start with the
skill and come back here for the exact call shapes.
opencals-build-booking-site任何Opencals API/SDK相关工作都可触发:「预约预订」、「显示可用时段」、「应用优惠码」、「允许客户改期」、「向预订中添加访客」、「结账时收集账单地址」、「为什么我收到429错误」、「自定义预订时长」、「客户登录」。如果任务是「用模板搭建完整的预订网站」,请先使用****技能,再回到此处查看具体的调用格式。
opencals-build-booking-siteSetup (once)
配置(仅需一次)
Initialise the SDK a single time via a side-effect import, then import service
classes directly:
ts
// lib/opencals.ts — imported once at the top of every server file that calls the API
import { setupOpencals } from '@opencals/storefront-sdk';
setupOpencals({
baseUrl: process.env.OPENCALS_API_URL ?? 'https://api.opencals.com',
apiKey: process.env.OPENCALS_API_KEY, // sfk_… storefront key, from the dashboard
logging: process.env.NODE_ENV === 'development',
});ts
import { ProductService, CartService, AppointmentService } from '@opencals/storefront-sdk';Full setup details, the complete service list, , and the
gotcha: .
X-Api-VersionthrowOnErrorreferences/setup.md通过副作用导入单次初始化SDK,然后直接导入服务类:
ts
// lib/opencals.ts — imported once at the top of every server file that calls the API
import { setupOpencals } from '@opencals/storefront-sdk';
setupOpencals({
baseUrl: process.env.OPENCALS_API_URL ?? 'https://api.opencals.com',
apiKey: process.env.OPENCALS_API_KEY, // sfk_… storefront key, from the dashboard
logging: process.env.NODE_ENV === 'development',
});ts
import { ProductService, CartService, AppointmentService } from '@opencals/storefront-sdk';完整的配置详情、完整的服务列表、以及注意事项,详见****。
X-Api-VersionthrowOnErrorreferences/setup.mdThe core booking flow
核心预订流程
- Availability → (exact slots) or
ProductService.getCurrentAvailabilities(calendar highlighting). →getCurrentAvailabilitiesMergedreferences/availability.md - Cart → , persist the
CartService.createOrGet. →X-Cart-Idreferences/cart-lifecycle.md - Appointment → (slot +
AppointmentService.create+cartId+ optional guests/add-ons). →numberOfAttendeesreferences/guests-attendees.md - Checkout → . →
CheckoutService.start → saveCustomer → saveAnswers → submitreferences/checkout.md
- 可用性查询 → (精确时段)或
ProductService.getCurrentAvailabilities(日历高亮)。详见getCurrentAvailabilitiesMergedreferences/availability.md - 购物车 → ,持久化
CartService.createOrGet。详见X-Cart-Idreferences/cart-lifecycle.md - 预约 → (时段 +
AppointmentService.create+cartId+ 可选访客/附加项)。详见numberOfAttendeesreferences/guests-attendees.md - 结账 → 。详见
CheckoutService.start → saveCustomer → saveAnswers → submitreferences/checkout.md
Reference files (load the one you need)
参考文件(按需加载)
| File | Covers |
|---|---|
| |
| |
| |
| |
| create/get, |
| |
| password + passwordless + OAuth login, sessions, |
| |
| automatic vs code ( |
| 429 handling, |
| reading |
| 文件 | 涵盖内容 |
|---|---|
| |
| |
| |
| |
| 创建/获取、 |
| |
| 密码+无密码+OAuth登录、会话、 |
| |
| 自动折扣与优惠码( |
| 429错误处理、 |
| 解读 |
Resources
资源
- Opencals — main site
- Docs & API reference
- @opencals/storefront-sdk on npm
- Dashboard — create stores, manage storefront API keys
- Opencals — 官方网站
- 文档与API参考
- npm上的@opencals/storefront-sdk
- 管理后台 — 创建店铺、管理Storefront API密钥
Guardrails
开发约束
- Never invent SDK names. Methods, params and enums must match the generated
SDK. When unsure, read or the SDK's
references/*files..d.ts - Never hard-code services, prices, availability, staff or locations. They come from the store via the API and are configured in the Opencals dashboard.
- All slot dates/times are UTC. Convert to the customer's timezone for
display only; send on availability queries so slots align to the local day.
timezone - Surface real errors. The SDK throws with the backend status code and field-level detail — never swallow it into a generic 500.
OpencalsApiError - The SDK and the official templates are MIT-licensed; the hosted API is closed-source. You pay Opencals only for bookings.
- 绝对不要编造SDK名称。 方法、参数和枚举必须与生成的SDK一致。如有疑问,请查阅或SDK的
references/*文件。.d.ts - 绝对不要硬编码服务、价格、可用性、员工或地点。 这些数据均通过API从店铺获取,并在Opencals管理后台中配置。
- 所有时段的日期/时间均为UTC。 仅在显示时转换为客户的时区;在可用性查询中传入参数,确保时段与当地日期对齐。
timezone - 透出真实错误。 SDK会抛出包含后端状态码和字段级详情的——绝对不要将其捕获后返回通用的500错误。
OpencalsApiError - SDK和官方模板采用MIT许可证;托管API为闭源。你仅需为成功的预订向Opencals付费。