@01.software/sdk 0.4.3-dev.260324.6dc30aa → 0.5.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 +13 -13
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -12
- package/dist/index.d.ts +21 -12
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/realtime.cjs +1 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.js +1 -1
- package/dist/realtime.js.map +1 -1
- package/dist/server-B80o7igg.d.cts +242 -0
- package/dist/server-B80o7igg.d.ts +242 -0
- package/dist/ui/flow/server.cjs +233 -0
- package/dist/ui/flow/server.cjs.map +1 -0
- package/dist/ui/flow/server.d.cts +3 -0
- package/dist/ui/flow/server.d.ts +3 -0
- package/dist/ui/flow/server.js +213 -0
- package/dist/ui/flow/server.js.map +1 -0
- package/dist/ui/flow.cjs +302 -139
- package/dist/ui/flow.cjs.map +1 -1
- package/dist/ui/flow.d.cts +20 -215
- package/dist/ui/flow.d.ts +20 -215
- package/dist/ui/flow.js +306 -147
- package/dist/ui/flow.js.map +1 -1
- package/package.json +12 -8
package/README.md
CHANGED
|
@@ -15,19 +15,19 @@ pnpm add @01.software/sdk
|
|
|
15
15
|
|
|
16
16
|
- Full TypeScript type inference
|
|
17
17
|
- Browser and server environment support
|
|
18
|
-
- React Query integration (both
|
|
18
|
+
- React Query integration (both Client and ServerClient)
|
|
19
19
|
- Mutation hooks (useCreate, useUpdate, useRemove) with automatic cache invalidation
|
|
20
20
|
- Customer auth hooks (useCustomerMe, useCustomerLogin, etc.) with cache management
|
|
21
21
|
- Automatic retry with exponential backoff (non-retryable: 401, 403, 404, 422)
|
|
22
22
|
- Webhook handling with HMAC-SHA256 signature verification
|
|
23
23
|
- Sub-path imports (`./auth`, `./webhook`, `./components`) for tree-shaking
|
|
24
|
-
- Type-safe read-only `from()` for
|
|
24
|
+
- Type-safe read-only `from()` for Client (compile-time write prevention)
|
|
25
25
|
|
|
26
26
|
### Sub-path Imports
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
29
|
// Main entry - clients, query builder, hooks, utilities
|
|
30
|
-
import {
|
|
30
|
+
import { createClient, createServerClient } from '@01.software/sdk'
|
|
31
31
|
|
|
32
32
|
// Auth only - JWT & API Key utilities (smaller bundle)
|
|
33
33
|
import {
|
|
@@ -53,12 +53,12 @@ import { VideoPlayer } from '@01.software/sdk/ui/video'
|
|
|
53
53
|
|
|
54
54
|
## Getting Started
|
|
55
55
|
|
|
56
|
-
###
|
|
56
|
+
### Client
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
|
-
import {
|
|
59
|
+
import { createClient } from '@01.software/sdk'
|
|
60
60
|
|
|
61
|
-
const client =
|
|
61
|
+
const client = createClient({
|
|
62
62
|
clientKey: process.env.NEXT_PUBLIC_SOFTWARE_CLIENT_KEY,
|
|
63
63
|
})
|
|
64
64
|
|
|
@@ -102,7 +102,7 @@ await client.query.prefetchQuery({
|
|
|
102
102
|
### Client Configuration
|
|
103
103
|
|
|
104
104
|
```typescript
|
|
105
|
-
const client =
|
|
105
|
+
const client = createClient({
|
|
106
106
|
clientKey: string, // Required
|
|
107
107
|
})
|
|
108
108
|
```
|
|
@@ -121,7 +121,7 @@ API URL은 환경변수로 오버라이드 가능합니다:
|
|
|
121
121
|
|
|
122
122
|
Access collections via `client.from(collection)` method.
|
|
123
123
|
|
|
124
|
-
> **Note:** `
|
|
124
|
+
> **Note:** `Client.from()` returns a `ReadOnlyQueryBuilder` (only `find`, `findById`, `count`, `findMetadata`, `findMetadataById`). Write operations (`create`, `update`, `remove`, `updateMany`, `removeMany`) are only available on `ServerClient.from()`.
|
|
125
125
|
|
|
126
126
|
```typescript
|
|
127
127
|
// List query - returns PayloadFindResponse
|
|
@@ -218,7 +218,7 @@ interface PayloadMutationResponse<T> {
|
|
|
218
218
|
|
|
219
219
|
### React Query Hooks
|
|
220
220
|
|
|
221
|
-
Read hooks are available on both `
|
|
221
|
+
Read hooks are available on both `Client` and `ServerClient` via `client.query.*`. Mutation hooks (`useCreate`, `useUpdate`, `useRemove`) are only available on `ServerClient`.
|
|
222
222
|
|
|
223
223
|
```typescript
|
|
224
224
|
// List query
|
|
@@ -273,7 +273,7 @@ client.query.invalidateQueries('products')
|
|
|
273
273
|
client.query.getQueryData('products', 'list', options)
|
|
274
274
|
client.query.setQueryData('products', 'detail', id, data)
|
|
275
275
|
|
|
276
|
-
// Customer auth hooks (
|
|
276
|
+
// Customer auth hooks (Client only)
|
|
277
277
|
const { data: profile } = client.query.useCustomerMe()
|
|
278
278
|
const { mutate: login } = client.query.useCustomerLogin()
|
|
279
279
|
const { mutate: register } = client.query.useCustomerRegister()
|
|
@@ -295,10 +295,10 @@ client.query.setCustomerData(profile)
|
|
|
295
295
|
|
|
296
296
|
### Customer Auth
|
|
297
297
|
|
|
298
|
-
Available on
|
|
298
|
+
Available on Client via `client.customer.*`.
|
|
299
299
|
|
|
300
300
|
```typescript
|
|
301
|
-
const client =
|
|
301
|
+
const client = createClient({
|
|
302
302
|
clientKey: process.env.NEXT_PUBLIC_SOFTWARE_CLIENT_KEY,
|
|
303
303
|
customer: { persist: true },
|
|
304
304
|
})
|
|
@@ -370,7 +370,7 @@ const { results, allAvailable } = await client.product.stockCheck({
|
|
|
370
370
|
|
|
371
371
|
### Cart API
|
|
372
372
|
|
|
373
|
-
Available in both ServerClient and
|
|
373
|
+
Available in both ServerClient and Client via `client.cart.*`.
|
|
374
374
|
|
|
375
375
|
```typescript
|
|
376
376
|
// Add item to cart
|
package/dist/index.cjs
CHANGED
|
@@ -72,9 +72,9 @@ var src_exports = {};
|
|
|
72
72
|
__export(src_exports, {
|
|
73
73
|
ApiError: () => ApiError,
|
|
74
74
|
BaseApi: () => BaseApi,
|
|
75
|
-
BrowserClient: () => BrowserClient,
|
|
76
75
|
COLLECTIONS: () => COLLECTIONS,
|
|
77
76
|
CartApi: () => CartApi,
|
|
77
|
+
Client: () => Client,
|
|
78
78
|
CollectionClient: () => CollectionClient,
|
|
79
79
|
CollectionHooks: () => CollectionHooks,
|
|
80
80
|
CollectionQueryBuilder: () => CollectionQueryBuilder,
|
|
@@ -96,7 +96,7 @@ __export(src_exports, {
|
|
|
96
96
|
ValidationError: () => ValidationError,
|
|
97
97
|
collectionKeys: () => collectionKeys,
|
|
98
98
|
createApiKey: () => createApiKey,
|
|
99
|
-
|
|
99
|
+
createClient: () => createClient,
|
|
100
100
|
createServerClient: () => createServerClient,
|
|
101
101
|
createServerToken: () => createServerToken,
|
|
102
102
|
createTypedWebhookHandler: () => createTypedWebhookHandler,
|
|
@@ -348,7 +348,7 @@ function resolveApiUrl() {
|
|
|
348
348
|
return envUrl.replace(/\/$/, "");
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
-
return "https://api
|
|
351
|
+
return "https://api.01.software";
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
// src/core/internal/utils/http.ts
|
|
@@ -1941,7 +1941,7 @@ var CustomerHooks = class {
|
|
|
1941
1941
|
ensureCustomerAuth() {
|
|
1942
1942
|
if (!this.customerAuth) {
|
|
1943
1943
|
throw createConfigError(
|
|
1944
|
-
"Customer hooks require
|
|
1944
|
+
"Customer hooks require Client. Use createClient() instead of createServerClient()."
|
|
1945
1945
|
);
|
|
1946
1946
|
}
|
|
1947
1947
|
return this.customerAuth;
|
|
@@ -2065,7 +2065,7 @@ var QueryHooks = class extends CollectionHooks {
|
|
|
2065
2065
|
};
|
|
2066
2066
|
|
|
2067
2067
|
// src/core/client/client.ts
|
|
2068
|
-
var
|
|
2068
|
+
var Client = class {
|
|
2069
2069
|
constructor(options) {
|
|
2070
2070
|
var _a;
|
|
2071
2071
|
if (!options.clientKey) {
|
|
@@ -2122,8 +2122,8 @@ var BrowserClient = class {
|
|
|
2122
2122
|
return __spreadValues({}, this.config);
|
|
2123
2123
|
}
|
|
2124
2124
|
};
|
|
2125
|
-
function
|
|
2126
|
-
return new
|
|
2125
|
+
function createClient(options) {
|
|
2126
|
+
return new Client(options);
|
|
2127
2127
|
}
|
|
2128
2128
|
|
|
2129
2129
|
// src/core/client/client.server.ts
|
|
@@ -2131,7 +2131,7 @@ var ServerClient = class {
|
|
|
2131
2131
|
constructor(options) {
|
|
2132
2132
|
if (typeof window !== "undefined") {
|
|
2133
2133
|
throw createConfigError(
|
|
2134
|
-
"ServerClient must not be used in a browser environment. This risks exposing your secretKey in client bundles. Use
|
|
2134
|
+
"ServerClient must not be used in a browser environment. This risks exposing your secretKey in client bundles. Use createClient() for browser code instead."
|
|
2135
2135
|
);
|
|
2136
2136
|
}
|
|
2137
2137
|
if (!options.clientKey) {
|