@01.software/sdk 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -79,7 +79,7 @@ const { docs } = await client.collections.from('products').find({
79
79
  import { createServerClient } from '@01.software/sdk'
80
80
 
81
81
  const client = createServerClient({
82
- publishableKey: process.env.NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY,
82
+ publishableKey: process.env.SOFTWARE_PUBLISHABLE_KEY,
83
83
  secretKey: process.env.SOFTWARE_SECRET_KEY, // sk01_... opaque API key from Console
84
84
  })
85
85
 
@@ -113,7 +113,7 @@ const client = createClient({
113
113
  const server = createServerClient({
114
114
  publishableKey: string,
115
115
  secretKey: string, // sk01_... or pat01_...
116
- tenantId: string, // required when secretKey is pat01_
116
+ tenantId?: string, // for PAT workflows, must match the pinned tenant when supplied
117
117
  })
118
118
  ```
119
119
 
@@ -121,6 +121,7 @@ const server = createServerClient({
121
121
  | ---------------- | -------- | ---------------------------- |
122
122
  | `publishableKey` | `string` | API publishable key |
123
123
  | `secretKey` | `string` | API secret key (server only) |
124
+ | `tenantId` | `string` | Optional generally; required when a PAT must disambiguate multi-tenant access. Must match the pinned tenant when supplied. |
124
125
 
125
126
  API URL은 환경변수로 오버라이드 가능합니다:
126
127
 
@@ -464,22 +465,25 @@ const handler = createTypedWebhookHandler('orders', async (event) => {
464
465
 
465
466
  ## Supported Collections
466
467
 
467
- | Category | Collections |
468
- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
469
- | Tenant | `tenants`, `tenant-metadata`, `tenant-logos` |
470
- | Images | `images` (unified), `brand-logos` |
471
- | Products | `products`, `product-variants`, `product-options`, `product-option-values`, `product-categories`, `product-tags`, `product-collections`, `brands`, `brand-logos` |
472
- | Orders | `orders`, `order-items`, `returns`, `return-items`, `fulfillments`, `fulfillment-items`, `transactions`, `order-status-logs` |
473
- | Customers | `customers`, `customer-addresses`, `customer-groups` |
474
- | Carts | `carts`, `cart-items` |
475
- | Commerce | `discounts`, `shipping-policies` |
476
- | Content | `posts`, `post-authors`, `post-categories`, `post-tags`, `documents`, `document-categories`, `document-types` |
477
- | Playlists | `playlists`, `playlist-categories`, `playlist-tags`, `tracks`, `track-categories`, `track-tags` |
478
- | Galleries | `galleries`, `gallery-items`, `gallery-categories`, `gallery-tags` |
479
- | Canvas | `canvases`, `canvas-node-types`, `canvas-edge-types`, `canvas-categories`, `canvas-tags` |
480
- | Videos | `videos`, `video-categories`, `video-tags` |
481
- | Live Streams | `live-streams` |
482
- | Forms | `forms`, `form-submissions` |
468
+ Source of truth: `packages/sdk/src/core/collection/const.ts` (`COLLECTIONS`: 70).
469
+
470
+ | Category | Collections |
471
+ | --- | --- |
472
+ | Tenant | `tenants`, `tenant-metadata`, `tenant-logos` |
473
+ | Products | `products`, `product-variants`, `product-options`, `product-option-values`, `product-categories`, `product-tags`, `product-collections`, `brands`, `brand-logos` |
474
+ | Orders | `orders`, `order-items`, `returns`, `return-items`, `fulfillments`, `fulfillment-items`, `transactions` |
475
+ | Customers | `customers`, `customer-profiles`, `customer-addresses`, `customer-groups` |
476
+ | Carts | `carts`, `cart-items` |
477
+ | Commerce | `discounts`, `promotions`, `shipping-policies` |
478
+ | Content | `documents`, `document-categories`, `document-types`, `posts`, `post-authors`, `post-categories`, `post-tags`, `links`, `link-categories`, `link-tags` |
479
+ | Playlists / Tracks | `playlists`, `playlist-categories`, `playlist-tags`, `tracks`, `track-categories`, `track-tags` |
480
+ | Galleries | `galleries`, `gallery-categories`, `gallery-tags`, `gallery-items` |
481
+ | Canvas | `canvases`, `canvas-node-types`, `canvas-edge-types`, `canvas-categories`, `canvas-tags`, `canvas-nodes`, `canvas-edges` |
482
+ | Videos | `videos`, `video-categories`, `video-tags` |
483
+ | Live Streams | `live-streams` |
484
+ | Media | `images` |
485
+ | Forms | `forms`, `form-submissions` |
486
+ | Community | `threads`, `comments`, `reactions`, `reaction-types`, `bookmarks`, `thread-categories`, `reports`, `community-bans` |
483
487
 
484
488
  ## Utilities
485
489
 
@@ -581,6 +585,7 @@ Error classes: `SDKError`, `ApiError`, `NetworkError`, `ValidationError`, `Confi
581
585
 
582
586
  ```bash
583
587
  NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY=your_publishable_key
588
+ SOFTWARE_PUBLISHABLE_KEY=your_publishable_key
584
589
  SOFTWARE_SECRET_KEY=sk01_... # Server only — opaque API key from Console
585
590
  ```
586
591
 
@@ -590,6 +595,22 @@ SOFTWARE_SECRET_KEY=sk01_... # Server only — opaque API key from Console
590
595
 
591
596
  ## Migration Guide
592
597
 
598
+ ### v0.16.0 (Phase 1–7 sync — additive)
599
+
600
+ New error codes propagated via `SDKError.code` (no breaking change; existing callers ignore unknown codes safely):
601
+
602
+ | Code | Phase | Trigger |
603
+ |---|---|---|
604
+ | `account_suspended` | P1 | Suspended session / `sk01_` / `pat01_` / customer JWT — 401 |
605
+ | `pat_tenant_header_forbidden` | P1 | `pat01_` request with a forbidden or mismatched `X-Tenant-Id` header — 401 |
606
+ | `tenant_mismatch` | P3 | Cross-tenant FK rejection (forms / community / orders) |
607
+ | `server_derived` | P3 | Body-driven write into a server-derived state field — 422 |
608
+ | `scope_denied` | P5 | `pat01_` whose `ApiKeys.scopes` lacks the operation |
609
+
610
+ P5 also adds JWT-`jti` revocation: `revokeCustomerJti(jti, ttl)` on the server invalidates a token immediately; subsequent SDK calls receive `401 { code: 'token_revoked' }`.
611
+
612
+ `COLLECTIONS` and `INTERNAL_COLLECTIONS` are now both exported from `@01.software/sdk`. Use `INTERNAL_COLLECTIONS` to detect admin-only slugs in custom tooling.
613
+
593
614
  ### v0.8.0 (Breaking Changes)
594
615
 
595
616
  **Field renames** — update any code that reads these fields from API responses:
@@ -0,0 +1,24 @@
1
+ import { C as Config } from './payload-types-CMoyAOjJ.cjs';
2
+
3
+ /**
4
+ * Collection type derived from Payload Config.
5
+ * This ensures type safety and automatic synchronization with payload-types.ts
6
+ */
7
+ type Collection = keyof Config['collections'];
8
+ /**
9
+ * Internal collections that should not be exposed via SDK.
10
+ * Includes Payload system collections and admin-only collections.
11
+ */
12
+ declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "tenant-auth-settings", "tenant-community-settings", "api-usage", "tenant-analytics-daily", "analytics-event-schemas", "subscriptions", "billing-history", "order-status-logs", "api-keys", "personal-access-tokens", "tenant-entitlements", "webhook-events", "webhook-deliveries", "audit-logs", "plans", "webhooks"];
13
+ /**
14
+ * Array of all public collection names for runtime use (e.g., Zod enum validation).
15
+ * This is the single source of truth for which collections are publicly accessible via SDK.
16
+ */
17
+ declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "customer-groups", "carts", "cart-items", "discounts", "promotions", "shipping-policies", "documents", "document-categories", "document-types", "posts", "post-authors", "post-categories", "post-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "threads", "comments", "reactions", "reaction-types", "bookmarks", "thread-categories", "reports", "community-bans"];
18
+ /**
19
+ * Public collections available for SDK access.
20
+ * Derived from the COLLECTIONS array (single source of truth).
21
+ */
22
+ type PublicCollection = (typeof COLLECTIONS)[number];
23
+
24
+ export { type Collection as C, INTERNAL_COLLECTIONS as I, type PublicCollection as P, COLLECTIONS as a };
@@ -0,0 +1,24 @@
1
+ import { C as Config } from './payload-types-CMoyAOjJ.js';
2
+
3
+ /**
4
+ * Collection type derived from Payload Config.
5
+ * This ensures type safety and automatic synchronization with payload-types.ts
6
+ */
7
+ type Collection = keyof Config['collections'];
8
+ /**
9
+ * Internal collections that should not be exposed via SDK.
10
+ * Includes Payload system collections and admin-only collections.
11
+ */
12
+ declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "tenant-auth-settings", "tenant-community-settings", "api-usage", "tenant-analytics-daily", "analytics-event-schemas", "subscriptions", "billing-history", "order-status-logs", "api-keys", "personal-access-tokens", "tenant-entitlements", "webhook-events", "webhook-deliveries", "audit-logs", "plans", "webhooks"];
13
+ /**
14
+ * Array of all public collection names for runtime use (e.g., Zod enum validation).
15
+ * This is the single source of truth for which collections are publicly accessible via SDK.
16
+ */
17
+ declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "customer-groups", "carts", "cart-items", "discounts", "promotions", "shipping-policies", "documents", "document-categories", "document-types", "posts", "post-authors", "post-categories", "post-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "threads", "comments", "reactions", "reaction-types", "bookmarks", "thread-categories", "reports", "community-bans"];
18
+ /**
19
+ * Public collections available for SDK access.
20
+ * Derived from the COLLECTIONS array (single source of truth).
21
+ */
22
+ type PublicCollection = (typeof COLLECTIONS)[number];
23
+
24
+ export { type Collection as C, INTERNAL_COLLECTIONS as I, type PublicCollection as P, COLLECTIONS as a };
package/dist/index.cjs CHANGED
@@ -39,6 +39,7 @@ __export(src_exports, {
39
39
  DiscountApi: () => DiscountApi,
40
40
  GoneError: () => GoneError,
41
41
  IMAGE_SIZES: () => IMAGE_SIZES,
42
+ INTERNAL_COLLECTIONS: () => INTERNAL_COLLECTIONS,
42
43
  ModerationApi: () => ModerationApi,
43
44
  NetworkError: () => NetworkError,
44
45
  NotFoundError: () => NotFoundError,
@@ -1065,6 +1066,34 @@ var CollectionClient = class extends HttpClient {
1065
1066
  };
1066
1067
 
1067
1068
  // src/core/collection/const.ts
1069
+ var INTERNAL_COLLECTIONS = [
1070
+ "users",
1071
+ "payload-kv",
1072
+ "payload-locked-documents",
1073
+ "payload-preferences",
1074
+ "payload-migrations",
1075
+ "field-configs",
1076
+ "system-media",
1077
+ "track-assets",
1078
+ "audiences",
1079
+ "email-logs",
1080
+ "tenant-auth-settings",
1081
+ "tenant-community-settings",
1082
+ "api-usage",
1083
+ "tenant-analytics-daily",
1084
+ "analytics-event-schemas",
1085
+ "subscriptions",
1086
+ "billing-history",
1087
+ "order-status-logs",
1088
+ "api-keys",
1089
+ "personal-access-tokens",
1090
+ "tenant-entitlements",
1091
+ "webhook-events",
1092
+ "webhook-deliveries",
1093
+ "audit-logs",
1094
+ "plans",
1095
+ "webhooks"
1096
+ ];
1068
1097
  var COLLECTIONS = [
1069
1098
  "tenants",
1070
1099
  "tenant-metadata",
@@ -1086,11 +1115,13 @@ var COLLECTIONS = [
1086
1115
  "fulfillment-items",
1087
1116
  "transactions",
1088
1117
  "customers",
1118
+ "customer-profiles",
1089
1119
  "customer-addresses",
1090
1120
  "customer-groups",
1091
1121
  "carts",
1092
1122
  "cart-items",
1093
1123
  "discounts",
1124
+ "promotions",
1094
1125
  "shipping-policies",
1095
1126
  "documents",
1096
1127
  "document-categories",
@@ -1117,6 +1148,8 @@ var COLLECTIONS = [
1117
1148
  "canvas-edge-types",
1118
1149
  "canvas-categories",
1119
1150
  "canvas-tags",
1151
+ "canvas-nodes",
1152
+ "canvas-edges",
1120
1153
  "videos",
1121
1154
  "video-categories",
1122
1155
  "video-tags",