@typewoo/sdk 3.5.3 → 3.5.4-beta.1
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 +6 -5
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/configs/sdk.config.d.ts +62 -1
- package/dist/lib/configs/sdk.config.d.ts.map +1 -1
- package/dist/lib/configs/sdk.config.js +33 -29
- package/dist/lib/configs/sdk.config.js.map +1 -1
- package/dist/lib/sdk.d.ts +115 -1
- package/dist/lib/sdk.d.ts.map +1 -1
- package/dist/lib/sdk.js +167 -0
- package/dist/lib/sdk.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ For full documentation, guides, and API reference, visit **[typewoo.dev](https:/
|
|
|
13
13
|
- 🔄 Built-in interceptors for nonce, cart token, and JWT authentication
|
|
14
14
|
- 🛠️ Fully typed responses powered by TypeScript
|
|
15
15
|
- ⚡ Event-driven core with custom EventBus
|
|
16
|
+
- 🔌 Custom endpoints with full type inference
|
|
16
17
|
- ⚙️ Built with modern tooling (Nx, Vitest, Pure ESM)
|
|
17
18
|
|
|
18
19
|
## 📦 Installation
|
|
@@ -24,16 +25,16 @@ npm install @typewoo/sdk axios qs zod
|
|
|
24
25
|
## 🚀 Quick Start
|
|
25
26
|
|
|
26
27
|
```typescript
|
|
27
|
-
import {
|
|
28
|
+
import { createTypewoo } from '@typewoo/sdk';
|
|
28
29
|
|
|
29
|
-
//
|
|
30
|
-
const sdk =
|
|
30
|
+
// Create your SDK instance
|
|
31
|
+
const sdk = createTypewoo({
|
|
31
32
|
baseUrl: 'https://your-store.com',
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
// Access store services
|
|
35
|
-
const products = await sdk.store.products.list();
|
|
36
|
-
const cart = await sdk.store.cart.get();
|
|
36
|
+
const { data: products } = await sdk.store.products.list();
|
|
37
|
+
const { data: cart } = await sdk.store.cart.get();
|
|
37
38
|
```
|
|
38
39
|
|
|
39
40
|
## 📖 Learn More
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './lib/sdk.js';
|
|
2
2
|
export * from './lib/configs/sdk.config.js';
|
|
3
|
+
export type { CustomEndpoints } from './lib/configs/sdk.config.js';
|
|
4
|
+
export type { TypewooClient } from './lib/sdk.js';
|
|
5
|
+
export { createTypewoo } from './lib/sdk.js';
|
|
3
6
|
export * from './lib/configs/index.js';
|
|
4
7
|
export { isJwtExpired, getJwtExpiration } from './lib/utilities/jwt.utility.js';
|
|
5
8
|
export * from './lib/extensions/index.js';
|
|
@@ -37,4 +40,5 @@ export { EventBus } from './lib/bus/event.bus.js';
|
|
|
37
40
|
export * from './lib/sdk.events.js';
|
|
38
41
|
export * from './lib/types/sdk.state.js';
|
|
39
42
|
export * from './lib/types/index.js';
|
|
43
|
+
export type { RequestOptions, RequestContext } from './lib/types/request.js';
|
|
40
44
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,cAAc,wBAAwB,CAAC;AAGvC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGhF,cAAc,2BAA2B,CAAC;AA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AAyC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAC7F,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAG5C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,cAAc,wBAAwB,CAAC;AAEvC,YAAY;AACZ,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAEhF,4CAA4C;AAC5C,cAAc,2BAA2B,CAAC;AAE1C,SAAS;AACT,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EACL,K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M,wCAAwC,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAC;AAC7F,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,8BAA8B;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,13 +1,45 @@
|
|
|
1
1
|
import { AxiosRequestConfig, Method } from 'axios';
|
|
2
2
|
import { StorageType, StorageProvider } from '../storage/auth.storage.js';
|
|
3
|
+
/**
|
|
4
|
+
* Type for custom endpoint functions.
|
|
5
|
+
* Each endpoint is a function that can have any parameters and returns a Promise.
|
|
6
|
+
* Use the exported HTTP helpers (doGet, doPost, etc.) inside your endpoint functions.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createTypewoo, doGet, doPost, RequestOptions } from '@typewoo/core';
|
|
11
|
+
*
|
|
12
|
+
* const sdk = createTypewoo({
|
|
13
|
+
* baseUrl: 'https://mystore.com',
|
|
14
|
+
* endpoints: {
|
|
15
|
+
* getNotifications: (userId: string, options?: RequestOptions) =>
|
|
16
|
+
* doGet<Notification[]>(`/custom/notifications/${userId}`, options),
|
|
17
|
+
* markAsRead: (id: number) =>
|
|
18
|
+
* doPost(`/custom/notifications/${id}/read`),
|
|
19
|
+
* },
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Endpoints are fully typed:
|
|
23
|
+
* const { data } = await sdk.endpoints.getNotifications('user-123');
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type CustomEndpoints = Record<string, (...args: any[]) => Promise<any>>;
|
|
3
27
|
export declare function setSdkConfig(config: ResolvedSdkConfig): void;
|
|
4
28
|
export declare function getSdkConfig(): ResolvedSdkConfig | null;
|
|
5
29
|
/**
|
|
6
30
|
* Configuration interface for the SDK.
|
|
7
31
|
* This is the input type - storage can be either a string type or a provider instance.
|
|
32
|
+
* @template TEndpoints - The type of custom endpoints, inferred from the endpoints object.
|
|
8
33
|
*/
|
|
9
|
-
export interface SdkConfig {
|
|
34
|
+
export interface SdkConfig<TEndpoints extends CustomEndpoints = CustomEndpoints> {
|
|
10
35
|
baseUrl: string;
|
|
36
|
+
/**
|
|
37
|
+
* Unique identifier for this SDK instance.
|
|
38
|
+
* Useful for logging, debugging, and telemetry.
|
|
39
|
+
* Can be a string or a function that returns a string (for lazy/dynamic generation).
|
|
40
|
+
* If not provided, one will be auto-generated using `crypto.randomUUID()`.
|
|
41
|
+
*/
|
|
42
|
+
uniqueIdentifier?: string | (() => string);
|
|
11
43
|
admin?: {
|
|
12
44
|
consumer_key?: string;
|
|
13
45
|
consumer_secret?: string;
|
|
@@ -52,6 +84,31 @@ export interface SdkConfig {
|
|
|
52
84
|
storage?: StorageType | StorageProvider;
|
|
53
85
|
};
|
|
54
86
|
axiosConfig?: AxiosRequestConfig;
|
|
87
|
+
/**
|
|
88
|
+
* Custom endpoints object.
|
|
89
|
+
* Define custom API endpoints that will be accessible via the returned SDK's `endpoints` property.
|
|
90
|
+
* Use the exported HTTP helpers (doGet, doPost, doPut, doDelete, doHead) in your endpoint functions.
|
|
91
|
+
* Each endpoint can have any parameters you need.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* import { createTypewoo, doGet, doPost, RequestOptions } from '@typewoo/core';
|
|
96
|
+
*
|
|
97
|
+
* const sdk = createTypewoo({
|
|
98
|
+
* baseUrl: 'https://mystore.com',
|
|
99
|
+
* endpoints: {
|
|
100
|
+
* getNotifications: (userId: string, options?: RequestOptions) =>
|
|
101
|
+
* doGet<Notification[]>(`/custom/notifications/${userId}`, options),
|
|
102
|
+
* markAsRead: (id: number) =>
|
|
103
|
+
* doPost(`/custom/notifications/${id}/read`),
|
|
104
|
+
* },
|
|
105
|
+
* });
|
|
106
|
+
*
|
|
107
|
+
* // Endpoints are fully typed from the config:
|
|
108
|
+
* const { data } = await sdk.endpoints.getNotifications('user-123');
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
endpoints?: TEndpoints;
|
|
55
112
|
request?: {
|
|
56
113
|
/**
|
|
57
114
|
* Retry configuration for failed requests.
|
|
@@ -112,6 +169,10 @@ interface ResolvedStorageConfig {
|
|
|
112
169
|
*/
|
|
113
170
|
export interface ResolvedSdkConfig {
|
|
114
171
|
baseUrl: string;
|
|
172
|
+
/**
|
|
173
|
+
* Unique identifier for this SDK instance.
|
|
174
|
+
*/
|
|
175
|
+
uniqueIdentifier: string;
|
|
115
176
|
admin?: {
|
|
116
177
|
consumer_key?: string;
|
|
117
178
|
consumer_secret?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.config.d.ts","sourceRoot":"","sources":["../../../src/lib/configs/sdk.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EACL,WAAW,EACX,eAAe,EAEhB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.config.d.ts","sourceRoot":"","sources":["../../../src/lib/configs/sdk.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EACL,WAAW,EACX,eAAe,EAEhB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,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
|
|
|
26
26
|
* This ensures all storage fields are StorageProvider instances.
|
|
27
27
|
*/
|
|
28
28
|
export const resolveConfig = (config) => {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23;
|
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24;
|
|
30
|
+
const resolvedIdentifier = typeof config.uniqueIdentifier === 'function'
|
|
31
|
+
? config.uniqueIdentifier()
|
|
32
|
+
: (_a = config.uniqueIdentifier) !== null && _a !== void 0 ? _a : crypto.randomUUID();
|
|
30
33
|
const resolved = {
|
|
31
34
|
baseUrl: config.baseUrl,
|
|
35
|
+
uniqueIdentifier: resolvedIdentifier,
|
|
32
36
|
admin: config.admin,
|
|
33
37
|
axiosConfig: config.axiosConfig,
|
|
34
38
|
request: {
|
|
@@ -37,55 +41,55 @@ export const resolveConfig = (config) => {
|
|
|
37
41
|
},
|
|
38
42
|
},
|
|
39
43
|
};
|
|
40
|
-
if ((
|
|
44
|
+
if ((_b = config.request) === null || _b === void 0 ? void 0 : _b.retry) {
|
|
41
45
|
resolved.request.retry = {
|
|
42
|
-
enabled: (
|
|
43
|
-
delay: (
|
|
44
|
-
retryOnMethods: (
|
|
45
|
-
retryOnStatus: (
|
|
46
|
-
maxRetries: (
|
|
47
|
-
retryCondition: (
|
|
46
|
+
enabled: (_c = config.request.retry.enabled) !== null && _c !== void 0 ? _c : false,
|
|
47
|
+
delay: (_d = config.request.retry.delay) !== null && _d !== void 0 ? _d : DEFAULT_RETRY_CONFIG.delay,
|
|
48
|
+
retryOnMethods: (_e = config.request.retry.retryOnMethods) !== null && _e !== void 0 ? _e : DEFAULT_RETRY_CONFIG.retryOnMethods,
|
|
49
|
+
retryOnStatus: (_f = config.request.retry.retryOnStatus) !== null && _f !== void 0 ? _f : DEFAULT_RETRY_CONFIG.retryOnStatus,
|
|
50
|
+
maxRetries: (_g = config.request.retry.maxRetries) !== null && _g !== void 0 ? _g : DEFAULT_RETRY_CONFIG.maxRetries,
|
|
51
|
+
retryCondition: (_h = config.request) === null || _h === void 0 ? void 0 : _h.retry.retryCondition,
|
|
48
52
|
};
|
|
49
53
|
}
|
|
50
54
|
// Resolve auth storage providers
|
|
51
55
|
// Auth is always initialized unless access token is explicitly disabled
|
|
52
|
-
const accessTokenDisabled = ((
|
|
53
|
-
const refreshTokenDisabled = ((
|
|
56
|
+
const accessTokenDisabled = ((_k = (_j = config.auth) === null || _j === void 0 ? void 0 : _j.accessToken) === null || _k === void 0 ? void 0 : _k.disabled) === true;
|
|
57
|
+
const refreshTokenDisabled = ((_m = (_l = config.auth) === null || _l === void 0 ? void 0 : _l.refreshToken) === null || _m === void 0 ? void 0 : _m.disabled) === true;
|
|
54
58
|
if (!accessTokenDisabled) {
|
|
55
59
|
resolved.auth = {
|
|
56
|
-
autoLoginUrl: (
|
|
57
|
-
fetchCartOnLogin: (
|
|
58
|
-
revokeTokenBeforeLogin: (
|
|
60
|
+
autoLoginUrl: (_o = config.auth) === null || _o === void 0 ? void 0 : _o.autoLoginUrl,
|
|
61
|
+
fetchCartOnLogin: (_p = config.auth) === null || _p === void 0 ? void 0 : _p.fetchCartOnLogin,
|
|
62
|
+
revokeTokenBeforeLogin: (_q = config.auth) === null || _q === void 0 ? void 0 : _q.revokeTokenBeforeLogin,
|
|
59
63
|
accessToken: {
|
|
60
|
-
key: (
|
|
61
|
-
disabled: (
|
|
62
|
-
useInterceptor: (
|
|
63
|
-
storage: resolveStorageProvider((
|
|
64
|
+
key: (_s = (_r = config.auth) === null || _r === void 0 ? void 0 : _r.accessToken) === null || _s === void 0 ? void 0 : _s.key,
|
|
65
|
+
disabled: (_u = (_t = config.auth) === null || _t === void 0 ? void 0 : _t.accessToken) === null || _u === void 0 ? void 0 : _u.disabled,
|
|
66
|
+
useInterceptor: (_w = (_v = config.auth) === null || _v === void 0 ? void 0 : _v.accessToken) === null || _w === void 0 ? void 0 : _w.useInterceptor,
|
|
67
|
+
storage: resolveStorageProvider((_y = (_x = config.auth) === null || _x === void 0 ? void 0 : _x.accessToken) === null || _y === void 0 ? void 0 : _y.storage, (_1 = (_0 = (_z = config.auth) === null || _z === void 0 ? void 0 : _z.accessToken) === null || _0 === void 0 ? void 0 : _0.key) !== null && _1 !== void 0 ? _1 : 'typewoo_access_token'),
|
|
64
68
|
},
|
|
65
69
|
};
|
|
66
70
|
if (!refreshTokenDisabled) {
|
|
67
71
|
resolved.auth.refreshToken = {
|
|
68
|
-
key: (
|
|
69
|
-
disabled: (
|
|
70
|
-
useInterceptor: (
|
|
71
|
-
storage: resolveStorageProvider((
|
|
72
|
+
key: (_3 = (_2 = config.auth) === null || _2 === void 0 ? void 0 : _2.refreshToken) === null || _3 === void 0 ? void 0 : _3.key,
|
|
73
|
+
disabled: (_5 = (_4 = config.auth) === null || _4 === void 0 ? void 0 : _4.refreshToken) === null || _5 === void 0 ? void 0 : _5.disabled,
|
|
74
|
+
useInterceptor: (_7 = (_6 = config.auth) === null || _6 === void 0 ? void 0 : _6.refreshToken) === null || _7 === void 0 ? void 0 : _7.useInterceptor,
|
|
75
|
+
storage: resolveStorageProvider((_9 = (_8 = config.auth) === null || _8 === void 0 ? void 0 : _8.refreshToken) === null || _9 === void 0 ? void 0 : _9.storage, (_12 = (_11 = (_10 = config.auth) === null || _10 === void 0 ? void 0 : _10.refreshToken) === null || _11 === void 0 ? void 0 : _11.key) !== null && _12 !== void 0 ? _12 : 'typewoo_refresh_token'),
|
|
72
76
|
};
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
// Resolve cart token storage
|
|
76
|
-
if (!((
|
|
80
|
+
if (!((_13 = config.cartToken) === null || _13 === void 0 ? void 0 : _13.disabled)) {
|
|
77
81
|
resolved.cartToken = {
|
|
78
|
-
key: (
|
|
79
|
-
disabled: (
|
|
80
|
-
storage: resolveStorageProvider((
|
|
82
|
+
key: (_14 = config.cartToken) === null || _14 === void 0 ? void 0 : _14.key,
|
|
83
|
+
disabled: (_15 = config.cartToken) === null || _15 === void 0 ? void 0 : _15.disabled,
|
|
84
|
+
storage: resolveStorageProvider((_16 = config.cartToken) === null || _16 === void 0 ? void 0 : _16.storage, (_18 = (_17 = config.cartToken) === null || _17 === void 0 ? void 0 : _17.key) !== null && _18 !== void 0 ? _18 : 'typewoo_cart_token'),
|
|
81
85
|
};
|
|
82
86
|
}
|
|
83
87
|
// Resolve nonce storage
|
|
84
|
-
if (!((
|
|
88
|
+
if (!((_19 = config.nonce) === null || _19 === void 0 ? void 0 : _19.disabled)) {
|
|
85
89
|
resolved.nonce = {
|
|
86
|
-
key: (
|
|
87
|
-
disabled: (
|
|
88
|
-
storage: resolveStorageProvider((
|
|
90
|
+
key: (_20 = config.nonce) === null || _20 === void 0 ? void 0 : _20.key,
|
|
91
|
+
disabled: (_21 = config.nonce) === null || _21 === void 0 ? void 0 : _21.disabled,
|
|
92
|
+
storage: resolveStorageProvider((_22 = config.nonce) === null || _22 === void 0 ? void 0 : _22.storage, (_24 = (_23 = config.nonce) === null || _23 === void 0 ? void 0 : _23.key) !== null && _24 !== void 0 ? _24 : 'typewoo_nonce'),
|
|
89
93
|
};
|
|
90
94
|
}
|
|
91
95
|
return resolved;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.config.js","sourceRoot":"","sources":["../../../src/lib/configs/sdk.config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAGL,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.config.js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AAA,MAAM,CAAC,SAAS,4CAAE,GAAG,qCAAI,oBAAoB,CAC9C;SACF,CAAC;IACJ,CAAC;IAED,wBAAwB;IACxB,IAAI,CAAC,CAAA,OAAA,MAAM,CAAC,KAAK,4CAAE,QAAQ,CAAA,EAAE,CAAC;QAC5B,QAAQ,CAAC,KAAK,GAAG;YACf,GAAG,EAAE,OAAA,MAAM,CAAC,KAAK,4CAAE,GAAG;YACtB,QAAQ,EAAE,OAAA,MAAM,CAAC,KAAK,4CAAE,QAAQ;YAChC,OAAO,EAAE,sBAAsB,CAC7B,OAAA,MAAM,CAAC,KAAK,4CAAE,OAAO,EACrB,OAAA,OAAA,MAAM,CAAC,KAAK,4CAAE,GAAG,qCAAI,eAAe,CACrC;SACF,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|
package/dist/lib/sdk.d.ts
CHANGED
|
@@ -1,10 +1,91 @@
|
|
|
1
|
-
import { ResolvedSdkConfig, SdkConfig } from './configs/sdk.config.js';
|
|
1
|
+
import { CustomEndpoints, ResolvedSdkConfig, SdkConfig } from './configs/sdk.config.js';
|
|
2
2
|
import { SdkState } from './types/sdk.state.js';
|
|
3
3
|
import { StoreService } from './services/store.service.js';
|
|
4
4
|
import { SdkEvent } from './sdk.events.js';
|
|
5
5
|
import { EventBus } from './bus/event.bus.js';
|
|
6
6
|
import { AuthService } from './services/auth/auth.service.js';
|
|
7
7
|
import { AdminService } from './services/admin.service.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create a fully typed Typewoo SDK instance.
|
|
10
|
+
*
|
|
11
|
+
* This is the recommended way to initialize the SDK when using custom endpoints,
|
|
12
|
+
* as it provides full TypeScript inference for your endpoint functions.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { createTypewoo, doGet, doPost, RequestOptions } from '@typewoo/core';
|
|
17
|
+
*
|
|
18
|
+
* // Create your typed SDK instance
|
|
19
|
+
* export const typewoo = createTypewoo({
|
|
20
|
+
* baseUrl: 'https://mystore.com',
|
|
21
|
+
* endpoints: {
|
|
22
|
+
* posts: (options?: RequestOptions) => doGet(`/wp/v2/posts`, options),
|
|
23
|
+
* pages: () => doGet(`/wp/v2/pages`),
|
|
24
|
+
*
|
|
25
|
+
* // using different baseUrl
|
|
26
|
+
* pages: () => doGet(`https://another-store.com/wp/v2/comments`),
|
|
27
|
+
* },
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Full autocomplete and type checking!
|
|
31
|
+
* const { data } = await typewoo.endpoints.posts();
|
|
32
|
+
* const products = await typewoo.store.products.list();
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @param config - SDK configuration with optional custom endpoints
|
|
36
|
+
* @returns A fully typed SDK instance
|
|
37
|
+
*/
|
|
38
|
+
export declare const createTypewoo: <TEndpoints extends CustomEndpoints = Record<string, never>>(config: SdkConfig<TEndpoints>) => TypewooClient<TEndpoints>;
|
|
39
|
+
export declare class TypewooClient<TEndpoints extends CustomEndpoints = Record<string, never>> {
|
|
40
|
+
private _auth;
|
|
41
|
+
private _store;
|
|
42
|
+
private _admin;
|
|
43
|
+
private _config;
|
|
44
|
+
private _endpoints;
|
|
45
|
+
state: SdkState;
|
|
46
|
+
events: EventBus<SdkEvent>;
|
|
47
|
+
constructor(config: SdkConfig<TEndpoints>);
|
|
48
|
+
/**
|
|
49
|
+
* Sets the unique identifier for the SDK instance.
|
|
50
|
+
* Useful when the identifier needs to be set asynchronously after SDK initialization.
|
|
51
|
+
*/
|
|
52
|
+
setUniqueIdentifier(identifier: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* Resolved SDK configuration.
|
|
55
|
+
* Storage fields are guaranteed to be StorageProvider instances after initialization.
|
|
56
|
+
*/
|
|
57
|
+
get config(): ResolvedSdkConfig;
|
|
58
|
+
/**
|
|
59
|
+
* Auth API
|
|
60
|
+
*/
|
|
61
|
+
get auth(): AuthService;
|
|
62
|
+
/**
|
|
63
|
+
* Store API
|
|
64
|
+
*/
|
|
65
|
+
get store(): StoreService;
|
|
66
|
+
/**
|
|
67
|
+
* Admin API
|
|
68
|
+
*/
|
|
69
|
+
get admin(): AdminService;
|
|
70
|
+
/**
|
|
71
|
+
* Custom endpoints defined in the SDK configuration.
|
|
72
|
+
*
|
|
73
|
+
* For full type inference on custom endpoints, use `createTypewoo()` instead:
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const typewoo = createTypewoo({
|
|
77
|
+
* baseUrl: 'https://mystore.com',
|
|
78
|
+
* endpoints: {
|
|
79
|
+
* getNotifications: (userId: string) => doGet<Notification[]>(`/notifications/${userId}`),
|
|
80
|
+
* },
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* // Full type inference:
|
|
84
|
+
* const { data } = await typewoo.endpoints.getNotifications('user-123');
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
get endpoints(): TEndpoints;
|
|
88
|
+
}
|
|
8
89
|
export declare class Sdk {
|
|
9
90
|
private _config;
|
|
10
91
|
state: SdkState;
|
|
@@ -14,6 +95,11 @@ export declare class Sdk {
|
|
|
14
95
|
private _initialized;
|
|
15
96
|
events: EventBus<SdkEvent>;
|
|
16
97
|
init(config: SdkConfig): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Sets the unique identifier for the SDK instance.
|
|
100
|
+
* Useful when the identifier needs to be set asynchronously after SDK initialization.
|
|
101
|
+
*/
|
|
102
|
+
setUniqueIdentifier(identifier: string): void;
|
|
17
103
|
/**
|
|
18
104
|
* Resolved SDK configuration.
|
|
19
105
|
* Storage fields are guaranteed to be StorageProvider instances after initialization.
|
|
@@ -33,5 +119,33 @@ export declare class Sdk {
|
|
|
33
119
|
get admin(): AdminService;
|
|
34
120
|
private throwIfNotInitized;
|
|
35
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Default Typewoo singleton instance.
|
|
124
|
+
*
|
|
125
|
+
* For simple usage without custom endpoints:
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* await Typewoo.init({ baseUrl: 'https://mystore.com' });
|
|
129
|
+
* const products = await Typewoo.store.products.list();
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* For custom endpoints with full type inference, use `createTypewoo()` instead.
|
|
133
|
+
*
|
|
134
|
+
* @deprecated Use `createTypewoo()` instead to create a single typewoo instance. This will be removed in a future major version.
|
|
135
|
+
*
|
|
136
|
+
* **Migration:**
|
|
137
|
+
* ```typescript
|
|
138
|
+
* // Before (deprecated):
|
|
139
|
+
* await Typewoo.init({ baseUrl: 'https://mystore.com' });
|
|
140
|
+
* const products = await Typewoo.store.products.list();
|
|
141
|
+
*
|
|
142
|
+
* // After (recommended):
|
|
143
|
+
* // Create once at app startup (e.g., in a shared module or context provider)
|
|
144
|
+
* const typewoo = createTypewoo({ baseUrl: 'https://mystore.com' });
|
|
145
|
+
*
|
|
146
|
+
* // Then import and use throughout your app
|
|
147
|
+
* const products = await typewoo.store.products.list();
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
36
150
|
export declare const Typewoo: Sdk;
|
|
37
151
|
//# sourceMappingURL=sdk.d.ts.map
|
package/dist/lib/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/lib/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/lib/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,iBAAiB,EACjB,SAAS,EAEV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,QAAQ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OAAO,CAAC,IAAI,CAAC;IA+DnD;;;OAGG;IACH,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK7C;;;OAGG;IACH,IAAI,MAAM,IAAI,iBAAiB,CAG9B;IAED;;OAEG;IACH,IAAI,IAAI,gBAGP;IAED;;OAEG;IACH,IAAI,KAAK,iBAGR;IAED;;OAEG;IACH,IAAI,KAAK,iBAGR;IAED,OAAO,CAAC,kBAAkB;CAI3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,OAAO,KAAY,CAAC"}
|
package/dist/lib/sdk.js
CHANGED
|
@@ -10,6 +10,137 @@ import { AuthService } from './services/auth/auth.service.js';
|
|
|
10
10
|
import { addRefreshTokenInterceptor } from './interceptors/refresh.token.interceptor.js';
|
|
11
11
|
import { AdminService } from './services/admin.service.js';
|
|
12
12
|
import { addAdminAuthInterceptor } from './interceptors/admin-auth.interceptor.js';
|
|
13
|
+
/**
|
|
14
|
+
* Create a fully typed Typewoo SDK instance.
|
|
15
|
+
*
|
|
16
|
+
* This is the recommended way to initialize the SDK when using custom endpoints,
|
|
17
|
+
* as it provides full TypeScript inference for your endpoint functions.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { createTypewoo, doGet, doPost, RequestOptions } from '@typewoo/core';
|
|
22
|
+
*
|
|
23
|
+
* // Create your typed SDK instance
|
|
24
|
+
* export const typewoo = createTypewoo({
|
|
25
|
+
* baseUrl: 'https://mystore.com',
|
|
26
|
+
* endpoints: {
|
|
27
|
+
* posts: (options?: RequestOptions) => doGet(`/wp/v2/posts`, options),
|
|
28
|
+
* pages: () => doGet(`/wp/v2/pages`),
|
|
29
|
+
*
|
|
30
|
+
* // using different baseUrl
|
|
31
|
+
* pages: () => doGet(`https://another-store.com/wp/v2/comments`),
|
|
32
|
+
* },
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Full autocomplete and type checking!
|
|
36
|
+
* const { data } = await typewoo.endpoints.posts();
|
|
37
|
+
* const products = await typewoo.store.products.list();
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param config - SDK configuration with optional custom endpoints
|
|
41
|
+
* @returns A fully typed SDK instance
|
|
42
|
+
*/
|
|
43
|
+
export const createTypewoo = (config) => {
|
|
44
|
+
return new TypewooClient(config);
|
|
45
|
+
};
|
|
46
|
+
export class TypewooClient {
|
|
47
|
+
constructor(config) {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
49
|
+
this.state = {};
|
|
50
|
+
this.events = new EventBus();
|
|
51
|
+
// Resolve all storage providers to ensure type safety
|
|
52
|
+
this._config = resolveConfig(config);
|
|
53
|
+
// Store original config for retry logic access
|
|
54
|
+
setSdkConfig(this._config);
|
|
55
|
+
// Store custom endpoints
|
|
56
|
+
this._endpoints = ((_a = config.endpoints) !== null && _a !== void 0 ? _a : {});
|
|
57
|
+
this._auth = new AuthService(this.state, this._config, this.events);
|
|
58
|
+
this._store = new StoreService(this.state, this._config, this.events);
|
|
59
|
+
this._admin = new AdminService(this.state, this._config, this.events);
|
|
60
|
+
createHttpClient(Object.assign({ baseURL: this._config.baseUrl }, this._config.axiosConfig));
|
|
61
|
+
addNonceInterceptors(this._config, this.state, this.events);
|
|
62
|
+
addCartTokenInterceptors(this._config, this.state, this.events);
|
|
63
|
+
if (!((_c = (_b = config.auth) === null || _b === void 0 ? void 0 : _b.accessToken) === null || _c === void 0 ? void 0 : _c.disabled)) {
|
|
64
|
+
const useTokenInterceptor = (_f = (_e = (_d = this._config.auth) === null || _d === void 0 ? void 0 : _d.accessToken) === null || _e === void 0 ? void 0 : _e.useInterceptor) !== null && _f !== void 0 ? _f : true;
|
|
65
|
+
if (useTokenInterceptor) {
|
|
66
|
+
addTokenInterceptor(this._config);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!((_h = (_g = config.auth) === null || _g === void 0 ? void 0 : _g.accessToken) === null || _h === void 0 ? void 0 : _h.disabled) &&
|
|
70
|
+
!((_k = (_j = config.auth) === null || _j === void 0 ? void 0 : _j.refreshToken) === null || _k === void 0 ? void 0 : _k.disabled)) {
|
|
71
|
+
const useRefreshTokenInterceptor = (_o = (_m = (_l = this._config.auth) === null || _l === void 0 ? void 0 : _l.refreshToken) === null || _m === void 0 ? void 0 : _m.useInterceptor) !== null && _o !== void 0 ? _o : true;
|
|
72
|
+
if (useRefreshTokenInterceptor) {
|
|
73
|
+
addRefreshTokenInterceptor(this._config, this._auth);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (((_p = this._config.admin) === null || _p === void 0 ? void 0 : _p.consumer_key) &&
|
|
77
|
+
this._config.admin.consumer_secret) {
|
|
78
|
+
if (this._config.admin.useAuthInterceptor !== false) {
|
|
79
|
+
addAdminAuthInterceptor(this._config);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Set initial authentication state based on stored token
|
|
83
|
+
const accessTokenStorage = (_r = (_q = this._config.auth) === null || _q === void 0 ? void 0 : _q.accessToken) === null || _r === void 0 ? void 0 : _r.storage;
|
|
84
|
+
if (accessTokenStorage) {
|
|
85
|
+
accessTokenStorage.get().then((value) => {
|
|
86
|
+
this.state.authenticated = !!value;
|
|
87
|
+
this.events.emit('auth:changed', !!value);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Sets the unique identifier for the SDK instance.
|
|
93
|
+
* Useful when the identifier needs to be set asynchronously after SDK initialization.
|
|
94
|
+
*/
|
|
95
|
+
setUniqueIdentifier(identifier) {
|
|
96
|
+
this._config.uniqueIdentifier = identifier;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Resolved SDK configuration.
|
|
100
|
+
* Storage fields are guaranteed to be StorageProvider instances after initialization.
|
|
101
|
+
*/
|
|
102
|
+
get config() {
|
|
103
|
+
return this._config;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Auth API
|
|
107
|
+
*/
|
|
108
|
+
get auth() {
|
|
109
|
+
return this._auth;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Store API
|
|
113
|
+
*/
|
|
114
|
+
get store() {
|
|
115
|
+
return this._store;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Admin API
|
|
119
|
+
*/
|
|
120
|
+
get admin() {
|
|
121
|
+
return this._admin;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Custom endpoints defined in the SDK configuration.
|
|
125
|
+
*
|
|
126
|
+
* For full type inference on custom endpoints, use `createTypewoo()` instead:
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const typewoo = createTypewoo({
|
|
130
|
+
* baseUrl: 'https://mystore.com',
|
|
131
|
+
* endpoints: {
|
|
132
|
+
* getNotifications: (userId: string) => doGet<Notification[]>(`/notifications/${userId}`),
|
|
133
|
+
* },
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* // Full type inference:
|
|
137
|
+
* const { data } = await typewoo.endpoints.getNotifications('user-123');
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
get endpoints() {
|
|
141
|
+
return this._endpoints;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
13
144
|
export class Sdk {
|
|
14
145
|
constructor() {
|
|
15
146
|
this.state = {};
|
|
@@ -62,6 +193,14 @@ export class Sdk {
|
|
|
62
193
|
// await this._store.cart.get();
|
|
63
194
|
});
|
|
64
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Sets the unique identifier for the SDK instance.
|
|
198
|
+
* Useful when the identifier needs to be set asynchronously after SDK initialization.
|
|
199
|
+
*/
|
|
200
|
+
setUniqueIdentifier(identifier) {
|
|
201
|
+
this.throwIfNotInitized();
|
|
202
|
+
this._config.uniqueIdentifier = identifier;
|
|
203
|
+
}
|
|
65
204
|
/**
|
|
66
205
|
* Resolved SDK configuration.
|
|
67
206
|
* Storage fields are guaranteed to be StorageProvider instances after initialization.
|
|
@@ -97,5 +236,33 @@ export class Sdk {
|
|
|
97
236
|
throw new Error('SDK not initialized. Call `await Typewoo.init()` first.');
|
|
98
237
|
}
|
|
99
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Default Typewoo singleton instance.
|
|
241
|
+
*
|
|
242
|
+
* For simple usage without custom endpoints:
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* await Typewoo.init({ baseUrl: 'https://mystore.com' });
|
|
246
|
+
* const products = await Typewoo.store.products.list();
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* For custom endpoints with full type inference, use `createTypewoo()` instead.
|
|
250
|
+
*
|
|
251
|
+
* @deprecated Use `createTypewoo()` instead to create a single typewoo instance. This will be removed in a future major version.
|
|
252
|
+
*
|
|
253
|
+
* **Migration:**
|
|
254
|
+
* ```typescript
|
|
255
|
+
* // Before (deprecated):
|
|
256
|
+
* await Typewoo.init({ baseUrl: 'https://mystore.com' });
|
|
257
|
+
* const products = await Typewoo.store.products.list();
|
|
258
|
+
*
|
|
259
|
+
* // After (recommended):
|
|
260
|
+
* // Create once at app startup (e.g., in a shared module or context provider)
|
|
261
|
+
* const typewoo = createTypewoo({ baseUrl: 'https://mystore.com' });
|
|
262
|
+
*
|
|
263
|
+
* // Then import and use throughout your app
|
|
264
|
+
* const products = await typewoo.store.products.list();
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
100
267
|
export const Typewoo = new Sdk();
|
|
101
268
|
//# sourceMappingURL=sdk.js.map
|
package/dist/lib/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/lib/sdk.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/lib/sdk.ts"],"names":[],"mappings":";AAAA,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