@dropins/tools 1.3.1-alpha012 → 1.3.1-alpha013

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.
@@ -1,166 +0,0 @@
1
- /********************************************************************
2
- * Copyright 2024 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this
6
- * file in accordance with the terms of the Adobe license agreement
7
- * accompanying it.
8
- *******************************************************************/
9
- export type Header = {
10
- [key: string]: string | null;
11
- };
12
- export type FetchOptions = {
13
- method?: 'GET' | 'POST';
14
- variables?: {
15
- [key: string]: any;
16
- };
17
- signal?: AbortSignal;
18
- cache?: 'default' | 'no-store' | 'reload' | 'no-cache' | 'force-cache' | 'only-if-cached';
19
- };
20
- export type FetchQueryError = Array<{
21
- message: string;
22
- extensions: {
23
- category: string;
24
- };
25
- }>;
26
- export type BeforeHook = (requestInit: RequestInit) => RequestInit;
27
- export type AfterHook<T = any> = (requestInit: RequestInit, response: {
28
- errors?: FetchQueryError;
29
- data: T;
30
- }) => {
31
- errors?: FetchQueryError;
32
- data: T;
33
- };
34
- declare class FetchGraphQLMesh {
35
- _endpoint?: string;
36
- get endpoint(): string | undefined;
37
- get fetchGraphQlHeaders(): Header;
38
- _fetchGraphQlHeaders: Header;
39
- _beforeHooks: BeforeHook[];
40
- _afterHooks: AfterHook[];
41
- /**
42
- * Sets the GraphQL endpoint.
43
- * @param endpoint - The GraphQL endpoint.
44
- */
45
- setEndpoint(endpoint: string): void;
46
- /**
47
- * Sets the GraphQL headers.
48
- * @param key - The key of the header.
49
- * @param value - The value of the header.
50
- */
51
- setFetchGraphQlHeader(key: string, value: string | null): void;
52
- /**
53
- * Removes a specific GraphQL header.
54
- * @param key - The key of the header.
55
- */
56
- removeFetchGraphQlHeader(key: string): void;
57
- /**
58
- * Sets the GraphQL headers.
59
- * @param header - The header object or a function that returns a header object.
60
- * If a function is provided, it will be called with the previous headers.
61
- * The returned object will be merged with the previous headers.
62
- * @example
63
- * ```js
64
- * // set headers
65
- * setFetchGraphQlHeaders({ test: 'test' });
66
- *
67
- * // merge with previous headers
68
- * setFetchGraphQlHeaders((prev) => ({
69
- * ...prev,
70
- * test: 'test2',
71
- * }));
72
- * ```
73
- */
74
- setFetchGraphQlHeaders(header: Header | ((prev: Header) => Header)): void;
75
- /**
76
- * Adds a hook executed before the GraphQL call.
77
- * @param hook - The hook function.
78
- * @example
79
- * ```js
80
- * // add before hook
81
- * addBeforeHook((requestInit) => console.log('About to execute ' + requestInit.method + ' call.'));
82
- *
83
- * // modify the requestInit before executing the request
84
- * addBeforeHook((requestInit) => {method: requestInit.method, body: 'new body'});
85
- * ```
86
- */
87
- addBeforeHook(hook: BeforeHook): void;
88
- /**
89
- * Adds a hook executed before the GraphQL call.
90
- * @param hook - The hook function.
91
- * @example
92
- * ```js
93
- * // add before hook
94
- * addAfterHook((requestInit, response) => console.log(
95
- * 'The result of ' + requestInit.method + ' call is ' + response.json().body
96
- * ));
97
- *
98
- * // modify the response
99
- * addAfterHook((requestInit, response) => new Response(JSON.stringify({ ...response, modified: true }));
100
- * ```
101
- */
102
- addAfterHook(hook: AfterHook): void;
103
- /**
104
- * Fetches GraphQL data.
105
- * @param query - The GraphQL query.
106
- * @param options - Optional configuration for the fetch request.
107
- * @returns
108
- */
109
- fetchGraphQl<T = any>(query: string, options?: FetchOptions): Promise<{
110
- errors?: FetchQueryError;
111
- data: T;
112
- }>;
113
- /**
114
- * Gets the configuration.
115
- */
116
- getConfig(): {
117
- endpoint: string | undefined;
118
- fetchGraphQlHeaders: Header;
119
- };
120
- getMethods(): {
121
- setEndpoint: (endpoint: string) => void;
122
- setFetchGraphQlHeader: (key: string, value: string | null) => void;
123
- removeFetchGraphQlHeader: (key: string) => void;
124
- setFetchGraphQlHeaders: (header: Header | ((prev: Header) => Header)) => void;
125
- fetchGraphQl: <T = any>(query: string, options?: FetchOptions | undefined) => Promise<{
126
- errors?: FetchQueryError | undefined;
127
- data: T;
128
- }>;
129
- getConfig: () => {
130
- endpoint: string | undefined;
131
- fetchGraphQlHeaders: Header;
132
- };
133
- addBeforeHook: (hook: BeforeHook) => void;
134
- addAfterHook: (hook: AfterHook<any>) => void;
135
- };
136
- }
137
- /**
138
- * `FetchGraphQL` is a class that extends `FetchGraphQLMesh`.
139
- * It provides methods to get the GraphQL endpoint and headers.
140
- *
141
- * @class
142
- *
143
- */
144
- export declare class FetchGraphQL extends FetchGraphQLMesh {
145
- get endpoint(): string | undefined;
146
- get fetchGraphQlHeaders(): Header;
147
- }
148
- /**
149
- * Exports several methods from the `mesh` object.
150
- *
151
- * @property {Function} setEndpoint - Sets the GraphQL endpoint.
152
- * @property {Function} setFetchGraphQlHeaders - Sets the GraphQL headers.
153
- * @property {Function} setFetchGraphQlHeader - Sets a specific GraphQL header.
154
- * @property {Function} removeFetchGraphQlHeader - Removes a specific GraphQL header.
155
- * @property {Function} fetchGraphQl - Fetches GraphQL data.
156
- * @property {Function} getConfig - Gets the configuration.
157
- */
158
- export declare const setEndpoint: (endpoint: string) => void, setFetchGraphQlHeaders: (header: Header | ((prev: Header) => Header)) => void, setFetchGraphQlHeader: (key: string, value: string | null) => void, removeFetchGraphQlHeader: (key: string) => void, fetchGraphQl: <T = any>(query: string, options?: FetchOptions) => Promise<{
159
- errors?: FetchQueryError | undefined;
160
- data: T;
161
- }>, getConfig: () => {
162
- endpoint: string | undefined;
163
- fetchGraphQlHeaders: Header;
164
- }, addBeforeHook: (hook: BeforeHook) => void, addAfterHook: (hook: AfterHook) => void;
165
- export {};
166
- //# sourceMappingURL=index.d.ts.map
@@ -1,12 +0,0 @@
1
- /********************************************************************
2
- * Copyright 2024 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this
6
- * file in accordance with the terms of the Adobe license agreement
7
- * accompanying it.
8
- *******************************************************************/
9
- export * from './message.config';
10
- export * from './typeForms.config';
11
- export * from './types/recaptchaBadgeSelector.config';
12
- //# sourceMappingURL=index.d.ts.map
@@ -1,16 +0,0 @@
1
- /********************************************************************
2
- * Copyright 2024 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this
6
- * file in accordance with the terms of the Adobe license agreement
7
- * accompanying it.
8
- *******************************************************************/
9
- export declare const recaptchaMessage: {
10
- failedFetch: string;
11
- failedSetStorageConfig: string;
12
- failedGetStorageConfig: string;
13
- failedExecutionRecaptcha: string;
14
- failedInitializing: string;
15
- };
16
- //# sourceMappingURL=message.config.d.ts.map
@@ -1,10 +0,0 @@
1
- /********************************************************************
2
- * Copyright 2024 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this
6
- * file in accordance with the terms of the Adobe license agreement
7
- * accompanying it.
8
- *******************************************************************/
9
- export declare const recaptchaBadgeSelector = ".grecaptcha-badge iframe";
10
- //# sourceMappingURL=recaptchaBadgeSelector.config.d.ts.map
@@ -1,10 +0,0 @@
1
- /********************************************************************
2
- * Copyright 2024 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this
6
- * file in accordance with the terms of the Adobe license agreement
7
- * accompanying it.
8
- *******************************************************************/
9
- export declare const typeDefaultForm: Record<string, string>;
10
- //# sourceMappingURL=typeForms.config.d.ts.map
@@ -1,10 +0,0 @@
1
- /********************************************************************
2
- * Copyright 2024 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this
6
- * file in accordance with the terms of the Adobe license agreement
7
- * accompanying it.
8
- *******************************************************************/
9
- export declare const RECAPTCHA_CONFIGURATION_V3 = "query {\n recaptchaV3Config {\n is_enabled\n website_key\n minimum_score\n badge_position\n language_code\n failure_message\n forms\n theme\n } \n}";
10
- //# sourceMappingURL=recaptchaConfig.graphql.d.ts.map
@@ -1,44 +0,0 @@
1
- import { ReCaptchaV3Response, PropsFormTypes, ReCaptchaV3Model } from './types/recaptcha.types';
2
-
3
- export declare const recaptchaFetchApi: {
4
- setEndpoint: (endpoint: string) => void;
5
- setFetchGraphQlHeader: (key: string, value: string | null) => void;
6
- removeFetchGraphQlHeader: (key: string) => void;
7
- setFetchGraphQlHeaders: (header: import('@adobe-commerce/fetch-graphql').Header | ((prev: import('@adobe-commerce/fetch-graphql').Header) => import('@adobe-commerce/fetch-graphql').Header)) => void;
8
- fetchGraphQl: <T = any>(query: string, options?: import('@adobe-commerce/fetch-graphql').FetchOptions | undefined) => Promise<{
9
- errors?: import('@adobe-commerce/fetch-graphql').FetchQueryError | undefined;
10
- data: T;
11
- }>;
12
- getConfig: () => {
13
- endpoint: string | undefined;
14
- fetchGraphQlHeaders: import('@adobe-commerce/fetch-graphql').Header;
15
- };
16
- addBeforeHook: (hook: import('@adobe-commerce/fetch-graphql').BeforeHook) => void;
17
- addAfterHook: (hook: import('@adobe-commerce/fetch-graphql').AfterHook<any>) => void;
18
- };
19
- export declare class RecaptchaModule {
20
- _enableReCAPTCHA: boolean;
21
- _recaptchaBackendEndpoint: string;
22
- _recaptchaScriptUrl: string;
23
- _configStorageKey: string;
24
- _logger: boolean;
25
- _updateBadgePosition(badgeId: string, config: ReCaptchaV3Model): Promise<void | null>;
26
- _addRecaptchaScript(): Promise<void>;
27
- _fetchStoreConfig(): Promise<ReCaptchaV3Response | undefined>;
28
- _loadConfig(): Promise<ReCaptchaV3Model | null>;
29
- setEndpoint(url: string): void;
30
- setConfig(configList: PropsFormTypes[]): Promise<void>;
31
- initReCaptcha(lazyLoadTimeout?: number): Promise<void>;
32
- verifyReCaptcha(): Promise<string | undefined>;
33
- enableLogger(logger: boolean): void;
34
- getMethods(): {
35
- enableLogger: (logger: boolean) => void;
36
- setEndpoint: (url: string) => void;
37
- setConfig: (configList: PropsFormTypes[]) => Promise<void>;
38
- initReCaptcha: (lazyLoadTimeout?: number) => Promise<void>;
39
- verifyReCaptcha: () => Promise<string | undefined>;
40
- };
41
- }
42
- declare const initReCaptcha: (lazyLoadTimeout?: number) => Promise<void>, verifyReCaptcha: () => Promise<string | undefined>, setEndpoint: (url: string) => void, setConfig: (configList: PropsFormTypes[]) => Promise<void>, enableLogger: (logger: boolean) => void;
43
- export { setEndpoint, setConfig, initReCaptcha, verifyReCaptcha, enableLogger };
44
- //# sourceMappingURL=index.d.ts.map
@@ -1,10 +0,0 @@
1
- /********************************************************************
2
- * Copyright 2024 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this
6
- * file in accordance with the terms of the Adobe license agreement
7
- * accompanying it.
8
- *******************************************************************/
9
- export declare const checkRecaptchaBadge: () => Promise<boolean>;
10
- //# sourceMappingURL=_checkRecaptchaBadge.d.ts.map
@@ -1,14 +0,0 @@
1
- /********************************************************************
2
- * Copyright 2024 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this
6
- * file in accordance with the terms of the Adobe license agreement
7
- * accompanying it.
8
- *******************************************************************/
9
- export declare const convertKeysToCamelCase: (obj: {
10
- [key: string]: any;
11
- }) => {
12
- [key: string]: string | number | boolean;
13
- };
14
- //# sourceMappingURL=_convertKeysToCamelCase.d.ts.map
@@ -1,4 +0,0 @@
1
- import { ReCaptchaV3Model } from '../types/recaptcha.types';
2
-
3
- export declare const extendConfig: (config: ReCaptchaV3Model, modifyParams: any[]) => ReCaptchaV3Model | undefined;
4
- //# sourceMappingURL=_extendConfig.d.ts.map
@@ -1,6 +0,0 @@
1
- import { ReCaptchaV3Model } from '../types/recaptcha.types';
2
-
3
- declare const getConfigStorage: (storageKey: string, retries?: number, delay?: number) => Promise<ReCaptchaV3Model | null>;
4
- declare const setConfigStorage: (storageKey: string, config: ReCaptchaV3Model, logger: boolean) => null | undefined;
5
- export { getConfigStorage, setConfigStorage };
6
- //# sourceMappingURL=_storageConfig.d.ts.map
@@ -1,13 +0,0 @@
1
- /********************************************************************
2
- * Copyright 2024 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this
6
- * file in accordance with the terms of the Adobe license agreement
7
- * accompanying it.
8
- *******************************************************************/
9
- export * from './_extendConfig';
10
- export * from './_storageConfig';
11
- export * from './_checkRecaptchaBadge';
12
- export * from './_convertKeysToCamelCase';
13
- //# sourceMappingURL=index.d.ts.map
@@ -1,6 +0,0 @@
1
- import { ReCaptchaV3Model } from '../types/recaptcha.types';
2
-
3
- export declare const getRecaptchaToken: (websiteKey: string) => Promise<string>;
4
- export declare const waitForReCaptcha: () => Promise<unknown>;
5
- export declare const verifyReCaptchaLoad: (badgeId: string, config: ReCaptchaV3Model, logger: boolean) => Promise<void>;
6
- //# sourceMappingURL=recaptcha.service.d.ts.map