@plasmicpkgs/commerce 0.0.247 → 0.0.248
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/dist/api/endpoints/cart.d.ts +4 -4
- package/dist/api/endpoints/catalog/products.d.ts +4 -4
- package/dist/api/index.d.ts +75 -75
- package/dist/api/operations.d.ts +130 -130
- package/dist/api/utils/errors.d.ts +10 -10
- package/dist/api/utils/is-allowed-method.d.ts +3 -3
- package/dist/api/utils/is-allowed-operation.d.ts +6 -6
- package/dist/api/utils/types.d.ts +34 -34
- package/dist/cart/use-add-item.d.ts +5 -5
- package/dist/cart/use-cart.d.ts +5 -5
- package/dist/cart/use-remove-item.d.ts +5 -5
- package/dist/cart/use-update-item.d.ts +5 -5
- package/dist/commerce.cjs.development.js +23 -20
- package/dist/commerce.cjs.development.js.map +1 -1
- package/dist/commerce.cjs.production.min.js +1 -1
- package/dist/commerce.cjs.production.min.js.map +1 -1
- package/dist/commerce.d.ts +43 -43
- package/dist/commerce.esm.js +23 -20
- package/dist/commerce.esm.js.map +1 -1
- package/dist/contexts.d.ts +26 -26
- package/dist/index.d.ts +46 -46
- package/dist/product/use-price.d.ts +26 -26
- package/dist/product/use-product.d.ts +5 -5
- package/dist/product/use-search.d.ts +6 -6
- package/dist/registerAddToCartButton.d.ts +10 -10
- package/dist/registerCart.d.ts +12 -12
- package/dist/registerCartProvider.d.ts +6 -6
- package/dist/registerCategoryCollection.d.ts +20 -20
- package/dist/registerCategoryField.d.ts +11 -11
- package/dist/registerCategoryLink.d.ts +12 -12
- package/dist/registerCategoryMedia.d.ts +11 -11
- package/dist/registerProductBox.d.ts +18 -18
- package/dist/registerProductCollection.d.ts +29 -29
- package/dist/registerProductLink.d.ts +12 -12
- package/dist/registerProductMedia.d.ts +14 -14
- package/dist/registerProductMediaCollection.d.ts +11 -11
- package/dist/registerProductPrice.d.ts +10 -10
- package/dist/registerProductQuantity.d.ts +11 -11
- package/dist/registerProductSlider.d.ts +14 -14
- package/dist/registerProductTextField.d.ts +11 -11
- package/dist/registerProductVariantPicker.d.ts +10 -10
- package/dist/registerable.d.ts +4 -4
- package/dist/site/use-brands.d.ts +5 -5
- package/dist/site/use-categories.d.ts +5 -5
- package/dist/types/cart.d.ts +157 -157
- package/dist/types/checkout.d.ts +57 -57
- package/dist/types/common.d.ts +13 -13
- package/dist/types/customer/address.d.ts +110 -110
- package/dist/types/customer/card.d.ts +113 -113
- package/dist/types/customer/index.d.ts +24 -24
- package/dist/types/index.d.ts +12 -12
- package/dist/types/login.d.ts +27 -27
- package/dist/types/logout.d.ts +17 -17
- package/dist/types/page.d.ts +24 -24
- package/dist/types/product.d.ts +117 -117
- package/dist/types/signup.d.ts +23 -23
- package/dist/types/site.d.ts +55 -55
- package/dist/types/wishlist.d.ts +83 -83
- package/dist/utils/default-fetcher.d.ts +4 -4
- package/dist/utils/default-product.d.ts +2 -2
- package/dist/utils/define-property.d.ts +21 -21
- package/dist/utils/errors.d.ts +27 -27
- package/dist/utils/get-product-price.d.ts +2 -2
- package/dist/utils/types.d.ts +99 -99
- package/dist/utils/use-data.d.ts +13 -13
- package/dist/utils/use-extra-features.d.ts +1 -1
- package/dist/utils/use-hook.d.ts +7 -7
- package/package.json +5 -5
package/dist/utils/types.d.ts
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import type { SWRConfiguration } from 'swr';
|
|
2
|
-
import type { CommerceError } from './errors';
|
|
3
|
-
import type { ResponseState } from './use-data';
|
|
4
|
-
import { Provider } from '../commerce';
|
|
5
|
-
/**
|
|
6
|
-
* Returns the properties in T with the properties in type K, overriding properties defined in T
|
|
7
|
-
*/
|
|
8
|
-
export
|
|
9
|
-
/**
|
|
10
|
-
* Returns the properties in T with the properties in type K changed from optional to required
|
|
11
|
-
*/
|
|
12
|
-
export
|
|
13
|
-
[P in K]-?: NonNullable<T[P]>;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Core fetcher added by CommerceProvider
|
|
17
|
-
*/
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
url?: string;
|
|
21
|
-
query?: string;
|
|
22
|
-
method?: string;
|
|
23
|
-
variables?: any;
|
|
24
|
-
body?: Body;
|
|
25
|
-
};
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
options: HookFetcherOptions;
|
|
30
|
-
input: H['fetcherInput'];
|
|
31
|
-
fetch: <T = H['fetchData'] extends {} | null ? H['fetchData'] : any, B = H['body']>(options: FetcherOptions<B>) => Promise<T>;
|
|
32
|
-
provider?: Provider;
|
|
33
|
-
};
|
|
34
|
-
export
|
|
35
|
-
method?: string;
|
|
36
|
-
} & ({
|
|
37
|
-
query: string;
|
|
38
|
-
url?: string;
|
|
39
|
-
} | {
|
|
40
|
-
query?: string;
|
|
41
|
-
url: string;
|
|
42
|
-
});
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
[k: string]: HookInputValue;
|
|
47
|
-
};
|
|
48
|
-
export
|
|
49
|
-
[k: string]: unknown;
|
|
50
|
-
} | undefined, T> = keyof Input extends never ? () => T : Partial<Input> extends Input ? (input?: Input) => T : (input: Input) => T;
|
|
51
|
-
export
|
|
52
|
-
data: any;
|
|
53
|
-
input?: {};
|
|
54
|
-
fetcherInput?: {};
|
|
55
|
-
body?: {};
|
|
56
|
-
fetchData?: any;
|
|
57
|
-
};
|
|
58
|
-
export
|
|
59
|
-
swrState?: {};
|
|
60
|
-
mutations?: Record<string, ReturnType<MutationHook<any>['useHook']>>;
|
|
61
|
-
};
|
|
62
|
-
export
|
|
63
|
-
actionInput?: {};
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Generates a SWR hook handler based on the schema of a hook
|
|
67
|
-
*/
|
|
68
|
-
export
|
|
69
|
-
useHook(context: SWRHookContext<H>): HookFunction<H['input'] & {
|
|
70
|
-
swrOptions?: SwrOptions<H['data'], H['fetcherInput']>;
|
|
71
|
-
}, ResponseState<H['data']> & H['swrState'] & H['mutations']>;
|
|
72
|
-
fetchOptions: HookFetcherOptions;
|
|
73
|
-
fetcher?: HookFetcherFn<H>;
|
|
74
|
-
};
|
|
75
|
-
export
|
|
76
|
-
useData(context?: {
|
|
77
|
-
input?: HookFetchInput | HookSWRInput;
|
|
78
|
-
swrOptions?: SwrOptions<H['data'], H['fetcherInput']>;
|
|
79
|
-
}): ResponseState<H['data']>;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Generates a mutation hook handler based on the schema of a hook
|
|
83
|
-
*/
|
|
84
|
-
export
|
|
85
|
-
useHook(context: MutationHookContext<H>): HookFunction<H['input'], HookFunction<H['actionInput'], H['data'] | Promise<H['data']>>>;
|
|
86
|
-
fetchOptions: HookFetcherOptions;
|
|
87
|
-
fetcher?: HookFetcherFn<H>;
|
|
88
|
-
};
|
|
89
|
-
export
|
|
90
|
-
fetch: keyof H['fetcherInput'] extends never ? () => H['data'] | Promise<H['data']> : Partial<H['fetcherInput']> extends H['fetcherInput'] ? (context?: {
|
|
91
|
-
input?: H['fetcherInput'];
|
|
92
|
-
}) => H['data'] | Promise<H['data']> : (context: {
|
|
93
|
-
input: H['fetcherInput'];
|
|
94
|
-
}) => H['data'] | Promise<H['data']>;
|
|
95
|
-
};
|
|
96
|
-
export
|
|
97
|
-
export
|
|
98
|
-
includeSubCategories?: boolean;
|
|
99
|
-
};
|
|
1
|
+
import type { SWRConfiguration } from 'swr';
|
|
2
|
+
import type { CommerceError } from './errors';
|
|
3
|
+
import type { ResponseState } from './use-data';
|
|
4
|
+
import { Provider } from '../commerce';
|
|
5
|
+
/**
|
|
6
|
+
* Returns the properties in T with the properties in type K, overriding properties defined in T
|
|
7
|
+
*/
|
|
8
|
+
export type Override<T, K> = Omit<T, keyof K> & K;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the properties in T with the properties in type K changed from optional to required
|
|
11
|
+
*/
|
|
12
|
+
export type PickRequired<T, K extends keyof T> = Omit<T, K> & {
|
|
13
|
+
[P in K]-?: NonNullable<T[P]>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Core fetcher added by CommerceProvider
|
|
17
|
+
*/
|
|
18
|
+
export type Fetcher<T = any, B = any> = (options: FetcherOptions<B>) => T | Promise<T>;
|
|
19
|
+
export type FetcherOptions<Body = any> = {
|
|
20
|
+
url?: string;
|
|
21
|
+
query?: string;
|
|
22
|
+
method?: string;
|
|
23
|
+
variables?: any;
|
|
24
|
+
body?: Body;
|
|
25
|
+
};
|
|
26
|
+
export type HookFetcher<Data, Input = null, Result = any> = (options: HookFetcherOptions | null, input: Input, fetch: <T = Result, Body = any>(options: FetcherOptions<Body>) => Promise<T>) => Data | Promise<Data>;
|
|
27
|
+
export type HookFetcherFn<H extends HookSchemaBase> = (context: HookFetcherContext<H>) => H['data'] | Promise<H['data']>;
|
|
28
|
+
export type HookFetcherContext<H extends HookSchemaBase> = {
|
|
29
|
+
options: HookFetcherOptions;
|
|
30
|
+
input: H['fetcherInput'];
|
|
31
|
+
fetch: <T = H['fetchData'] extends {} | null ? H['fetchData'] : any, B = H['body']>(options: FetcherOptions<B>) => Promise<T>;
|
|
32
|
+
provider?: Provider;
|
|
33
|
+
};
|
|
34
|
+
export type HookFetcherOptions = {
|
|
35
|
+
method?: string;
|
|
36
|
+
} & ({
|
|
37
|
+
query: string;
|
|
38
|
+
url?: string;
|
|
39
|
+
} | {
|
|
40
|
+
query?: string;
|
|
41
|
+
url: string;
|
|
42
|
+
});
|
|
43
|
+
export type HookInputValue = string | number | boolean | undefined;
|
|
44
|
+
export type HookSWRInput = [string, HookInputValue][];
|
|
45
|
+
export type HookFetchInput = {
|
|
46
|
+
[k: string]: HookInputValue;
|
|
47
|
+
};
|
|
48
|
+
export type HookFunction<Input extends {
|
|
49
|
+
[k: string]: unknown;
|
|
50
|
+
} | undefined, T> = keyof Input extends never ? () => T : Partial<Input> extends Input ? (input?: Input) => T : (input: Input) => T;
|
|
51
|
+
export type HookSchemaBase = {
|
|
52
|
+
data: any;
|
|
53
|
+
input?: {};
|
|
54
|
+
fetcherInput?: {};
|
|
55
|
+
body?: {};
|
|
56
|
+
fetchData?: any;
|
|
57
|
+
};
|
|
58
|
+
export type SWRHookSchemaBase = HookSchemaBase & {
|
|
59
|
+
swrState?: {};
|
|
60
|
+
mutations?: Record<string, ReturnType<MutationHook<any>['useHook']>>;
|
|
61
|
+
};
|
|
62
|
+
export type MutationSchemaBase = HookSchemaBase & {
|
|
63
|
+
actionInput?: {};
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Generates a SWR hook handler based on the schema of a hook
|
|
67
|
+
*/
|
|
68
|
+
export type SWRHook<H extends SWRHookSchemaBase> = {
|
|
69
|
+
useHook(context: SWRHookContext<H>): HookFunction<H['input'] & {
|
|
70
|
+
swrOptions?: SwrOptions<H['data'], H['fetcherInput']>;
|
|
71
|
+
}, ResponseState<H['data']> & H['swrState'] & H['mutations']>;
|
|
72
|
+
fetchOptions: HookFetcherOptions;
|
|
73
|
+
fetcher?: HookFetcherFn<H>;
|
|
74
|
+
};
|
|
75
|
+
export type SWRHookContext<H extends SWRHookSchemaBase> = {
|
|
76
|
+
useData(context?: {
|
|
77
|
+
input?: HookFetchInput | HookSWRInput;
|
|
78
|
+
swrOptions?: SwrOptions<H['data'], H['fetcherInput']>;
|
|
79
|
+
}): ResponseState<H['data']>;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Generates a mutation hook handler based on the schema of a hook
|
|
83
|
+
*/
|
|
84
|
+
export type MutationHook<H extends MutationSchemaBase> = {
|
|
85
|
+
useHook(context: MutationHookContext<H>): HookFunction<H['input'], HookFunction<H['actionInput'], H['data'] | Promise<H['data']>>>;
|
|
86
|
+
fetchOptions: HookFetcherOptions;
|
|
87
|
+
fetcher?: HookFetcherFn<H>;
|
|
88
|
+
};
|
|
89
|
+
export type MutationHookContext<H extends MutationSchemaBase> = {
|
|
90
|
+
fetch: keyof H['fetcherInput'] extends never ? () => H['data'] | Promise<H['data']> : Partial<H['fetcherInput']> extends H['fetcherInput'] ? (context?: {
|
|
91
|
+
input?: H['fetcherInput'];
|
|
92
|
+
}) => H['data'] | Promise<H['data']> : (context: {
|
|
93
|
+
input: H['fetcherInput'];
|
|
94
|
+
}) => H['data'] | Promise<H['data']>;
|
|
95
|
+
};
|
|
96
|
+
export type SwrOptions<Data, Input = null, Result = any> = SWRConfiguration<Data, CommerceError, HookFetcher<Data, Input, Result>>;
|
|
97
|
+
export type CommerceExtraFeatures = {
|
|
98
|
+
includeSubCategories?: boolean;
|
|
99
|
+
};
|
package/dist/utils/use-data.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { SWRResponse } from "swr";
|
|
2
|
-
import { Provider } from "../commerce";
|
|
3
|
-
import { CommerceError } from "./errors";
|
|
4
|
-
import type { Fetcher, HookFetcherFn, HookFetcherOptions, HookFetchInput, HookSWRInput, SWRHookSchemaBase, SwrOptions } from "./types";
|
|
5
|
-
export
|
|
6
|
-
isLoading: boolean;
|
|
7
|
-
};
|
|
8
|
-
export
|
|
9
|
-
fetchOptions: HookFetcherOptions;
|
|
10
|
-
fetcher: HookFetcherFn<H>;
|
|
11
|
-
}, input: HookFetchInput | HookSWRInput, fetcherFn: Fetcher, swrOptions?: SwrOptions<H["data"], H["fetcherInput"]>, provider?: Provider) => ResponseState<H["data"]>;
|
|
12
|
-
declare const useData: UseData;
|
|
13
|
-
export default useData;
|
|
1
|
+
import { SWRResponse } from "swr";
|
|
2
|
+
import { Provider } from "../commerce";
|
|
3
|
+
import { CommerceError } from "./errors";
|
|
4
|
+
import type { Fetcher, HookFetcherFn, HookFetcherOptions, HookFetchInput, HookSWRInput, SWRHookSchemaBase, SwrOptions } from "./types";
|
|
5
|
+
export type ResponseState<Result> = SWRResponse<Result, CommerceError> & {
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type UseData = <H extends SWRHookSchemaBase>(options: {
|
|
9
|
+
fetchOptions: HookFetcherOptions;
|
|
10
|
+
fetcher: HookFetcherFn<H>;
|
|
11
|
+
}, input: HookFetchInput | HookSWRInput, fetcherFn: Fetcher, swrOptions?: SwrOptions<H["data"], H["fetcherInput"]>, provider?: Provider) => ResponseState<H["data"]>;
|
|
12
|
+
declare const useData: UseData;
|
|
13
|
+
export default useData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useCommerceExtraFeatures: () => import("./types").CommerceExtraFeatures | undefined;
|
|
1
|
+
export declare const useCommerceExtraFeatures: () => import("./types").CommerceExtraFeatures | undefined;
|
package/dist/utils/use-hook.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Provider } from '../commerce';
|
|
2
|
-
import type { MutationHook, PickRequired, SWRHook } from './types';
|
|
3
|
-
export declare function useFetcher(): import("./types").Fetcher
|
|
4
|
-
export declare function useProvider(): Provider;
|
|
5
|
-
export declare function useHook<P extends Provider, H extends MutationHook<any> | SWRHook<any>>(fn: (provider: P) => H): H;
|
|
6
|
-
export declare function useSWRHook<H extends SWRHook<any>>(hook: PickRequired<H, 'fetcher'>): (input?: any) => any;
|
|
7
|
-
export declare function useMutationHook<H extends MutationHook<any>>(hook: PickRequired<H, 'fetcher'>): (input?: any) => (input?: any) => any;
|
|
1
|
+
import { Provider } from '../commerce';
|
|
2
|
+
import type { MutationHook, PickRequired, SWRHook } from './types';
|
|
3
|
+
export declare function useFetcher(): import("./types").Fetcher;
|
|
4
|
+
export declare function useProvider(): Provider;
|
|
5
|
+
export declare function useHook<P extends Provider, H extends MutationHook<any> | SWRHook<any>>(fn: (provider: P) => H): H;
|
|
6
|
+
export declare function useSWRHook<H extends SWRHook<any>>(hook: PickRequired<H, 'fetcher'>): (input?: any) => any;
|
|
7
|
+
export declare function useMutationHook<H extends MutationHook<any>>(hook: PickRequired<H, 'fetcher'>): (input?: any) => (input?: any) => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicpkgs/commerce",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.248",
|
|
4
4
|
"description": "Plasmic registration calls for commerce components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "tsdx build",
|
|
13
13
|
"start": "tsdx watch",
|
|
14
|
-
"test": "TEST_CWD=`pwd`
|
|
14
|
+
"test": "TEST_CWD=`pwd` pnpm -w test --passWithNoTests",
|
|
15
15
|
"lint": "tsdx lint",
|
|
16
16
|
"prepublishOnly": "npm run build",
|
|
17
17
|
"size": "size-limit",
|
|
18
18
|
"analyze": "size-limit --why"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@plasmicapp/host": "2.0.
|
|
22
|
-
"@plasmicapp/query": "0.1.
|
|
21
|
+
"@plasmicapp/host": "2.0.7",
|
|
22
|
+
"@plasmicapp/query": "0.1.85",
|
|
23
23
|
"@types/debounce": "^1.2.1",
|
|
24
24
|
"@types/js-cookie": "^3.0.1",
|
|
25
25
|
"@types/lodash.debounce": "^4.0.7",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"react-hook-form": "^7.28.0",
|
|
43
43
|
"swr": "^1.2.2"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "6087f1621240c66b20d4a8fcf02c8bf889c554aa"
|
|
46
46
|
}
|