@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.
Files changed (68) hide show
  1. package/dist/api/endpoints/cart.d.ts +4 -4
  2. package/dist/api/endpoints/catalog/products.d.ts +4 -4
  3. package/dist/api/index.d.ts +75 -75
  4. package/dist/api/operations.d.ts +130 -130
  5. package/dist/api/utils/errors.d.ts +10 -10
  6. package/dist/api/utils/is-allowed-method.d.ts +3 -3
  7. package/dist/api/utils/is-allowed-operation.d.ts +6 -6
  8. package/dist/api/utils/types.d.ts +34 -34
  9. package/dist/cart/use-add-item.d.ts +5 -5
  10. package/dist/cart/use-cart.d.ts +5 -5
  11. package/dist/cart/use-remove-item.d.ts +5 -5
  12. package/dist/cart/use-update-item.d.ts +5 -5
  13. package/dist/commerce.cjs.development.js +23 -20
  14. package/dist/commerce.cjs.development.js.map +1 -1
  15. package/dist/commerce.cjs.production.min.js +1 -1
  16. package/dist/commerce.cjs.production.min.js.map +1 -1
  17. package/dist/commerce.d.ts +43 -43
  18. package/dist/commerce.esm.js +23 -20
  19. package/dist/commerce.esm.js.map +1 -1
  20. package/dist/contexts.d.ts +26 -26
  21. package/dist/index.d.ts +46 -46
  22. package/dist/product/use-price.d.ts +26 -26
  23. package/dist/product/use-product.d.ts +5 -5
  24. package/dist/product/use-search.d.ts +6 -6
  25. package/dist/registerAddToCartButton.d.ts +10 -10
  26. package/dist/registerCart.d.ts +12 -12
  27. package/dist/registerCartProvider.d.ts +6 -6
  28. package/dist/registerCategoryCollection.d.ts +20 -20
  29. package/dist/registerCategoryField.d.ts +11 -11
  30. package/dist/registerCategoryLink.d.ts +12 -12
  31. package/dist/registerCategoryMedia.d.ts +11 -11
  32. package/dist/registerProductBox.d.ts +18 -18
  33. package/dist/registerProductCollection.d.ts +29 -29
  34. package/dist/registerProductLink.d.ts +12 -12
  35. package/dist/registerProductMedia.d.ts +14 -14
  36. package/dist/registerProductMediaCollection.d.ts +11 -11
  37. package/dist/registerProductPrice.d.ts +10 -10
  38. package/dist/registerProductQuantity.d.ts +11 -11
  39. package/dist/registerProductSlider.d.ts +14 -14
  40. package/dist/registerProductTextField.d.ts +11 -11
  41. package/dist/registerProductVariantPicker.d.ts +10 -10
  42. package/dist/registerable.d.ts +4 -4
  43. package/dist/site/use-brands.d.ts +5 -5
  44. package/dist/site/use-categories.d.ts +5 -5
  45. package/dist/types/cart.d.ts +157 -157
  46. package/dist/types/checkout.d.ts +57 -57
  47. package/dist/types/common.d.ts +13 -13
  48. package/dist/types/customer/address.d.ts +110 -110
  49. package/dist/types/customer/card.d.ts +113 -113
  50. package/dist/types/customer/index.d.ts +24 -24
  51. package/dist/types/index.d.ts +12 -12
  52. package/dist/types/login.d.ts +27 -27
  53. package/dist/types/logout.d.ts +17 -17
  54. package/dist/types/page.d.ts +24 -24
  55. package/dist/types/product.d.ts +117 -117
  56. package/dist/types/signup.d.ts +23 -23
  57. package/dist/types/site.d.ts +55 -55
  58. package/dist/types/wishlist.d.ts +83 -83
  59. package/dist/utils/default-fetcher.d.ts +4 -4
  60. package/dist/utils/default-product.d.ts +2 -2
  61. package/dist/utils/define-property.d.ts +21 -21
  62. package/dist/utils/errors.d.ts +27 -27
  63. package/dist/utils/get-product-price.d.ts +2 -2
  64. package/dist/utils/types.d.ts +99 -99
  65. package/dist/utils/use-data.d.ts +13 -13
  66. package/dist/utils/use-extra-features.d.ts +1 -1
  67. package/dist/utils/use-hook.d.ts +7 -7
  68. package/package.json +5 -5
@@ -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 declare 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 declare 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 declare type Fetcher<T = any, B = any> = (options: FetcherOptions<B>) => T | Promise<T>;
19
- export declare type FetcherOptions<Body = any> = {
20
- url?: string;
21
- query?: string;
22
- method?: string;
23
- variables?: any;
24
- body?: Body;
25
- };
26
- export declare 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 declare type HookFetcherFn<H extends HookSchemaBase> = (context: HookFetcherContext<H>) => H['data'] | Promise<H['data']>;
28
- export declare 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 declare type HookFetcherOptions = {
35
- method?: string;
36
- } & ({
37
- query: string;
38
- url?: string;
39
- } | {
40
- query?: string;
41
- url: string;
42
- });
43
- export declare type HookInputValue = string | number | boolean | undefined;
44
- export declare type HookSWRInput = [string, HookInputValue][];
45
- export declare type HookFetchInput = {
46
- [k: string]: HookInputValue;
47
- };
48
- export declare 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 declare type HookSchemaBase = {
52
- data: any;
53
- input?: {};
54
- fetcherInput?: {};
55
- body?: {};
56
- fetchData?: any;
57
- };
58
- export declare type SWRHookSchemaBase = HookSchemaBase & {
59
- swrState?: {};
60
- mutations?: Record<string, ReturnType<MutationHook<any>['useHook']>>;
61
- };
62
- export declare type MutationSchemaBase = HookSchemaBase & {
63
- actionInput?: {};
64
- };
65
- /**
66
- * Generates a SWR hook handler based on the schema of a hook
67
- */
68
- export declare 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 declare 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 declare 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 declare 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 declare type SwrOptions<Data, Input = null, Result = any> = SWRConfiguration<Data, CommerceError, HookFetcher<Data, Input, Result>>;
97
- export declare type CommerceExtraFeatures = {
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
+ };
@@ -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 declare type ResponseState<Result> = SWRResponse<Result, CommerceError> & {
6
- isLoading: boolean;
7
- };
8
- export declare 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
+ 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;
@@ -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<any, any>;
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.247",
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` yarn --cwd=../../.. test --passWithNoTests",
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.6",
22
- "@plasmicapp/query": "0.1.84",
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": "baa35758ccd16c32259942faebbcbd62d5f174a4"
45
+ "gitHead": "6087f1621240c66b20d4a8fcf02c8bf889c554aa"
46
46
  }