@wix/essentials 0.1.28 → 1.0.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/build/mock-factory.d.ts +16 -16
- package/build/mock-factory.js +37 -30
- package/cjs/build/mock-factory.d.ts +16 -16
- package/cjs/build/mock-factory.js +37 -30
- package/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/internal/build/mock-factory.d.ts +16 -16
- package/internal/build/mock-factory.js +37 -30
- package/internal/cjs/build/mock-factory.d.ts +16 -16
- package/internal/cjs/build/mock-factory.js +37 -30
- package/internal/cjs/tsconfig.internal.cjs.tsbuildinfo +1 -1
- package/internal/tsconfig.internal.tsbuildinfo +1 -1
- package/package.json +12 -12
package/build/mock-factory.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
export declare function createEssentialsMockFactory(mockFn: any): {
|
|
2
2
|
i18n: {
|
|
3
|
-
getLanguage:
|
|
4
|
-
getLocale:
|
|
3
|
+
getLanguage: Function | undefined;
|
|
4
|
+
getLocale: Function | undefined;
|
|
5
5
|
};
|
|
6
6
|
bi: {
|
|
7
|
-
getLogger:
|
|
7
|
+
getLogger: Function | undefined;
|
|
8
8
|
};
|
|
9
9
|
monitoring: {
|
|
10
|
-
getMonitoringClient:
|
|
10
|
+
getMonitoringClient: Function | undefined;
|
|
11
11
|
};
|
|
12
12
|
experiments: {
|
|
13
|
-
enabled:
|
|
14
|
-
get:
|
|
13
|
+
enabled: Function | undefined;
|
|
14
|
+
get: Function | undefined;
|
|
15
15
|
};
|
|
16
16
|
settings: {
|
|
17
|
-
getTimezone:
|
|
17
|
+
getTimezone: Function | undefined;
|
|
18
18
|
};
|
|
19
19
|
auth: {
|
|
20
|
-
elevate:
|
|
21
|
-
getContextualAuth:
|
|
22
|
-
getTokenInfo:
|
|
20
|
+
elevate: Function | undefined;
|
|
21
|
+
getContextualAuth: Function | undefined;
|
|
22
|
+
getTokenInfo: Function | undefined;
|
|
23
23
|
};
|
|
24
24
|
httpClient: {
|
|
25
|
-
fetchWithAuth:
|
|
26
|
-
graphql:
|
|
25
|
+
fetchWithAuth: Function | undefined;
|
|
26
|
+
graphql: Function | undefined;
|
|
27
27
|
};
|
|
28
28
|
errorHandler: {
|
|
29
|
-
withErrorHandler:
|
|
30
|
-
getResolvedError:
|
|
31
|
-
showError:
|
|
32
|
-
reportRetryAttempt:
|
|
29
|
+
withErrorHandler: Function | undefined;
|
|
30
|
+
getResolvedError: Function | undefined;
|
|
31
|
+
showError: Function | undefined;
|
|
32
|
+
reportRetryAttempt: Function | undefined;
|
|
33
33
|
};
|
|
34
34
|
};
|
package/build/mock-factory.js
CHANGED
|
@@ -1,45 +1,52 @@
|
|
|
1
1
|
export function createEssentialsMockFactory(mockFn) {
|
|
2
|
+
const mockFns = new Map();
|
|
3
|
+
const createUniqueFn = (name, implementation) => {
|
|
4
|
+
if (!mockFns.has(name)) {
|
|
5
|
+
mockFns.set(name, mockFn(implementation));
|
|
6
|
+
}
|
|
7
|
+
return mockFns.get(name);
|
|
8
|
+
};
|
|
2
9
|
return {
|
|
3
10
|
i18n: {
|
|
4
|
-
getLanguage:
|
|
5
|
-
getLocale:
|
|
11
|
+
getLanguage: createUniqueFn('i18n.getLanguage', () => 'en'),
|
|
12
|
+
getLocale: createUniqueFn('i18n.getLocale', () => 'en-US'),
|
|
6
13
|
},
|
|
7
14
|
bi: {
|
|
8
|
-
getLogger:
|
|
9
|
-
log:
|
|
10
|
-
report:
|
|
11
|
-
flush:
|
|
12
|
-
updateDefaults:
|
|
13
|
-
log:
|
|
14
|
-
report:
|
|
15
|
-
flush:
|
|
16
|
-
updateDefaults:
|
|
15
|
+
getLogger: createUniqueFn('bi.getLogger', () => ({
|
|
16
|
+
log: createUniqueFn('bi.getLogger.log'),
|
|
17
|
+
report: createUniqueFn('bi.getLogger.report'),
|
|
18
|
+
flush: createUniqueFn('bi.getLogger.flush'),
|
|
19
|
+
updateDefaults: createUniqueFn('bi.getLogger.updateDefaults', (params) => ({
|
|
20
|
+
log: createUniqueFn('bi.getLogger.updateDefaults.log'),
|
|
21
|
+
report: createUniqueFn('bi.getLogger.updateDefaults.report'),
|
|
22
|
+
flush: createUniqueFn('bi.getLogger.updateDefaults.flush'),
|
|
23
|
+
updateDefaults: createUniqueFn('bi.getLogger.updateDefaults.updateDefaults'),
|
|
17
24
|
})),
|
|
18
25
|
})),
|
|
19
26
|
},
|
|
20
27
|
monitoring: {
|
|
21
|
-
getMonitoringClient:
|
|
22
|
-
captureException:
|
|
23
|
-
captureMessage:
|
|
24
|
-
setContext:
|
|
25
|
-
setTag:
|
|
26
|
-
setUser:
|
|
27
|
-
addBreadcrumb:
|
|
28
|
+
getMonitoringClient: createUniqueFn('monitoring.getMonitoringClient', () => ({
|
|
29
|
+
captureException: createUniqueFn('monitoring.getMonitoringClient.captureException'),
|
|
30
|
+
captureMessage: createUniqueFn('monitoring.getMonitoringClient.captureMessage'),
|
|
31
|
+
setContext: createUniqueFn('monitoring.getMonitoringClient.setContext'),
|
|
32
|
+
setTag: createUniqueFn('monitoring.getMonitoringClient.setTag'),
|
|
33
|
+
setUser: createUniqueFn('monitoring.getMonitoringClient.setUser'),
|
|
34
|
+
addBreadcrumb: createUniqueFn('monitoring.getMonitoringClient.addBreadcrumb'),
|
|
28
35
|
})),
|
|
29
36
|
},
|
|
30
37
|
experiments: {
|
|
31
|
-
enabled:
|
|
32
|
-
get:
|
|
38
|
+
enabled: createUniqueFn('experiments.enabled', () => false),
|
|
39
|
+
get: createUniqueFn('experiments.get', () => null),
|
|
33
40
|
},
|
|
34
41
|
settings: {
|
|
35
|
-
getTimezone:
|
|
42
|
+
getTimezone: createUniqueFn('settings.getTimezone', () => 'UTC'),
|
|
36
43
|
},
|
|
37
44
|
auth: {
|
|
38
|
-
elevate:
|
|
39
|
-
getContextualAuth:
|
|
45
|
+
elevate: createUniqueFn('auth.elevate', (restModule) => restModule),
|
|
46
|
+
getContextualAuth: createUniqueFn('auth.getContextualAuth', () => ({
|
|
40
47
|
headers: {},
|
|
41
48
|
})),
|
|
42
|
-
getTokenInfo:
|
|
49
|
+
getTokenInfo: createUniqueFn('auth.getTokenInfo', () => Promise.resolve({
|
|
43
50
|
active: true,
|
|
44
51
|
subjectType: 'USER',
|
|
45
52
|
subjectId: 'mock-user-id',
|
|
@@ -51,21 +58,21 @@ export function createEssentialsMockFactory(mockFn) {
|
|
|
51
58
|
})),
|
|
52
59
|
},
|
|
53
60
|
httpClient: {
|
|
54
|
-
fetchWithAuth:
|
|
55
|
-
graphql:
|
|
61
|
+
fetchWithAuth: createUniqueFn('httpClient.fetchWithAuth', () => global.fetch || mockFn()),
|
|
62
|
+
graphql: createUniqueFn('httpClient.graphql', () => Promise.resolve({
|
|
56
63
|
data: {},
|
|
57
64
|
errors: [],
|
|
58
65
|
})),
|
|
59
66
|
},
|
|
60
67
|
errorHandler: {
|
|
61
|
-
withErrorHandler:
|
|
62
|
-
getResolvedError:
|
|
68
|
+
withErrorHandler: createUniqueFn('errorHandler.withErrorHandler', (fn) => fn()),
|
|
69
|
+
getResolvedError: createUniqueFn('errorHandler.getResolvedError', () => ({
|
|
63
70
|
code: 'UNKNOWN_ERROR',
|
|
64
71
|
message: 'Mock error',
|
|
65
72
|
details: {},
|
|
66
73
|
})),
|
|
67
|
-
showError:
|
|
68
|
-
reportRetryAttempt:
|
|
74
|
+
showError: createUniqueFn('errorHandler.showError'),
|
|
75
|
+
reportRetryAttempt: createUniqueFn('errorHandler.reportRetryAttempt'),
|
|
69
76
|
},
|
|
70
77
|
};
|
|
71
78
|
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
export declare function createEssentialsMockFactory(mockFn: any): {
|
|
2
2
|
i18n: {
|
|
3
|
-
getLanguage:
|
|
4
|
-
getLocale:
|
|
3
|
+
getLanguage: Function | undefined;
|
|
4
|
+
getLocale: Function | undefined;
|
|
5
5
|
};
|
|
6
6
|
bi: {
|
|
7
|
-
getLogger:
|
|
7
|
+
getLogger: Function | undefined;
|
|
8
8
|
};
|
|
9
9
|
monitoring: {
|
|
10
|
-
getMonitoringClient:
|
|
10
|
+
getMonitoringClient: Function | undefined;
|
|
11
11
|
};
|
|
12
12
|
experiments: {
|
|
13
|
-
enabled:
|
|
14
|
-
get:
|
|
13
|
+
enabled: Function | undefined;
|
|
14
|
+
get: Function | undefined;
|
|
15
15
|
};
|
|
16
16
|
settings: {
|
|
17
|
-
getTimezone:
|
|
17
|
+
getTimezone: Function | undefined;
|
|
18
18
|
};
|
|
19
19
|
auth: {
|
|
20
|
-
elevate:
|
|
21
|
-
getContextualAuth:
|
|
22
|
-
getTokenInfo:
|
|
20
|
+
elevate: Function | undefined;
|
|
21
|
+
getContextualAuth: Function | undefined;
|
|
22
|
+
getTokenInfo: Function | undefined;
|
|
23
23
|
};
|
|
24
24
|
httpClient: {
|
|
25
|
-
fetchWithAuth:
|
|
26
|
-
graphql:
|
|
25
|
+
fetchWithAuth: Function | undefined;
|
|
26
|
+
graphql: Function | undefined;
|
|
27
27
|
};
|
|
28
28
|
errorHandler: {
|
|
29
|
-
withErrorHandler:
|
|
30
|
-
getResolvedError:
|
|
31
|
-
showError:
|
|
32
|
-
reportRetryAttempt:
|
|
29
|
+
withErrorHandler: Function | undefined;
|
|
30
|
+
getResolvedError: Function | undefined;
|
|
31
|
+
showError: Function | undefined;
|
|
32
|
+
reportRetryAttempt: Function | undefined;
|
|
33
33
|
};
|
|
34
34
|
};
|
|
@@ -2,47 +2,54 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createEssentialsMockFactory = createEssentialsMockFactory;
|
|
4
4
|
function createEssentialsMockFactory(mockFn) {
|
|
5
|
+
const mockFns = new Map();
|
|
6
|
+
const createUniqueFn = (name, implementation) => {
|
|
7
|
+
if (!mockFns.has(name)) {
|
|
8
|
+
mockFns.set(name, mockFn(implementation));
|
|
9
|
+
}
|
|
10
|
+
return mockFns.get(name);
|
|
11
|
+
};
|
|
5
12
|
return {
|
|
6
13
|
i18n: {
|
|
7
|
-
getLanguage:
|
|
8
|
-
getLocale:
|
|
14
|
+
getLanguage: createUniqueFn('i18n.getLanguage', () => 'en'),
|
|
15
|
+
getLocale: createUniqueFn('i18n.getLocale', () => 'en-US'),
|
|
9
16
|
},
|
|
10
17
|
bi: {
|
|
11
|
-
getLogger:
|
|
12
|
-
log:
|
|
13
|
-
report:
|
|
14
|
-
flush:
|
|
15
|
-
updateDefaults:
|
|
16
|
-
log:
|
|
17
|
-
report:
|
|
18
|
-
flush:
|
|
19
|
-
updateDefaults:
|
|
18
|
+
getLogger: createUniqueFn('bi.getLogger', () => ({
|
|
19
|
+
log: createUniqueFn('bi.getLogger.log'),
|
|
20
|
+
report: createUniqueFn('bi.getLogger.report'),
|
|
21
|
+
flush: createUniqueFn('bi.getLogger.flush'),
|
|
22
|
+
updateDefaults: createUniqueFn('bi.getLogger.updateDefaults', (params) => ({
|
|
23
|
+
log: createUniqueFn('bi.getLogger.updateDefaults.log'),
|
|
24
|
+
report: createUniqueFn('bi.getLogger.updateDefaults.report'),
|
|
25
|
+
flush: createUniqueFn('bi.getLogger.updateDefaults.flush'),
|
|
26
|
+
updateDefaults: createUniqueFn('bi.getLogger.updateDefaults.updateDefaults'),
|
|
20
27
|
})),
|
|
21
28
|
})),
|
|
22
29
|
},
|
|
23
30
|
monitoring: {
|
|
24
|
-
getMonitoringClient:
|
|
25
|
-
captureException:
|
|
26
|
-
captureMessage:
|
|
27
|
-
setContext:
|
|
28
|
-
setTag:
|
|
29
|
-
setUser:
|
|
30
|
-
addBreadcrumb:
|
|
31
|
+
getMonitoringClient: createUniqueFn('monitoring.getMonitoringClient', () => ({
|
|
32
|
+
captureException: createUniqueFn('monitoring.getMonitoringClient.captureException'),
|
|
33
|
+
captureMessage: createUniqueFn('monitoring.getMonitoringClient.captureMessage'),
|
|
34
|
+
setContext: createUniqueFn('monitoring.getMonitoringClient.setContext'),
|
|
35
|
+
setTag: createUniqueFn('monitoring.getMonitoringClient.setTag'),
|
|
36
|
+
setUser: createUniqueFn('monitoring.getMonitoringClient.setUser'),
|
|
37
|
+
addBreadcrumb: createUniqueFn('monitoring.getMonitoringClient.addBreadcrumb'),
|
|
31
38
|
})),
|
|
32
39
|
},
|
|
33
40
|
experiments: {
|
|
34
|
-
enabled:
|
|
35
|
-
get:
|
|
41
|
+
enabled: createUniqueFn('experiments.enabled', () => false),
|
|
42
|
+
get: createUniqueFn('experiments.get', () => null),
|
|
36
43
|
},
|
|
37
44
|
settings: {
|
|
38
|
-
getTimezone:
|
|
45
|
+
getTimezone: createUniqueFn('settings.getTimezone', () => 'UTC'),
|
|
39
46
|
},
|
|
40
47
|
auth: {
|
|
41
|
-
elevate:
|
|
42
|
-
getContextualAuth:
|
|
48
|
+
elevate: createUniqueFn('auth.elevate', (restModule) => restModule),
|
|
49
|
+
getContextualAuth: createUniqueFn('auth.getContextualAuth', () => ({
|
|
43
50
|
headers: {},
|
|
44
51
|
})),
|
|
45
|
-
getTokenInfo:
|
|
52
|
+
getTokenInfo: createUniqueFn('auth.getTokenInfo', () => Promise.resolve({
|
|
46
53
|
active: true,
|
|
47
54
|
subjectType: 'USER',
|
|
48
55
|
subjectId: 'mock-user-id',
|
|
@@ -54,21 +61,21 @@ function createEssentialsMockFactory(mockFn) {
|
|
|
54
61
|
})),
|
|
55
62
|
},
|
|
56
63
|
httpClient: {
|
|
57
|
-
fetchWithAuth:
|
|
58
|
-
graphql:
|
|
64
|
+
fetchWithAuth: createUniqueFn('httpClient.fetchWithAuth', () => global.fetch || mockFn()),
|
|
65
|
+
graphql: createUniqueFn('httpClient.graphql', () => Promise.resolve({
|
|
59
66
|
data: {},
|
|
60
67
|
errors: [],
|
|
61
68
|
})),
|
|
62
69
|
},
|
|
63
70
|
errorHandler: {
|
|
64
|
-
withErrorHandler:
|
|
65
|
-
getResolvedError:
|
|
71
|
+
withErrorHandler: createUniqueFn('errorHandler.withErrorHandler', (fn) => fn()),
|
|
72
|
+
getResolvedError: createUniqueFn('errorHandler.getResolvedError', () => ({
|
|
66
73
|
code: 'UNKNOWN_ERROR',
|
|
67
74
|
message: 'Mock error',
|
|
68
75
|
details: {},
|
|
69
76
|
})),
|
|
70
|
-
showError:
|
|
71
|
-
reportRetryAttempt:
|
|
77
|
+
showError: createUniqueFn('errorHandler.showError'),
|
|
78
|
+
reportRetryAttempt: createUniqueFn('errorHandler.reportRetryAttempt'),
|
|
72
79
|
},
|
|
73
80
|
};
|
|
74
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/auth.ts","../src/bi.ts","../src/experiments.ts","../src/http-client.ts","../src/index.ts","../src/mock-factory.ts","../src/monitoring.ts","../src/settings.ts","../src/error-handler/createErrorHandler.ts","../src/error-handler/error-handler.ts","../src/i18n/createI18n.ts","../src/i18n/i18n.ts"],"version":"5.9.
|
|
1
|
+
{"root":["../src/auth.ts","../src/bi.ts","../src/experiments.ts","../src/http-client.ts","../src/index.ts","../src/mock-factory.ts","../src/monitoring.ts","../src/settings.ts","../src/error-handler/createErrorHandler.ts","../src/error-handler/error-handler.ts","../src/i18n/createI18n.ts","../src/i18n/i18n.ts"],"version":"5.9.3"}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
export declare function createEssentialsMockFactory(mockFn: any): {
|
|
2
2
|
i18n: {
|
|
3
|
-
getLanguage:
|
|
4
|
-
getLocale:
|
|
3
|
+
getLanguage: Function | undefined;
|
|
4
|
+
getLocale: Function | undefined;
|
|
5
5
|
};
|
|
6
6
|
bi: {
|
|
7
|
-
getLogger:
|
|
7
|
+
getLogger: Function | undefined;
|
|
8
8
|
};
|
|
9
9
|
monitoring: {
|
|
10
|
-
getMonitoringClient:
|
|
10
|
+
getMonitoringClient: Function | undefined;
|
|
11
11
|
};
|
|
12
12
|
experiments: {
|
|
13
|
-
enabled:
|
|
14
|
-
get:
|
|
13
|
+
enabled: Function | undefined;
|
|
14
|
+
get: Function | undefined;
|
|
15
15
|
};
|
|
16
16
|
settings: {
|
|
17
|
-
getTimezone:
|
|
17
|
+
getTimezone: Function | undefined;
|
|
18
18
|
};
|
|
19
19
|
auth: {
|
|
20
|
-
elevate:
|
|
21
|
-
getContextualAuth:
|
|
22
|
-
getTokenInfo:
|
|
20
|
+
elevate: Function | undefined;
|
|
21
|
+
getContextualAuth: Function | undefined;
|
|
22
|
+
getTokenInfo: Function | undefined;
|
|
23
23
|
};
|
|
24
24
|
httpClient: {
|
|
25
|
-
fetchWithAuth:
|
|
26
|
-
graphql:
|
|
25
|
+
fetchWithAuth: Function | undefined;
|
|
26
|
+
graphql: Function | undefined;
|
|
27
27
|
};
|
|
28
28
|
errorHandler: {
|
|
29
|
-
withErrorHandler:
|
|
30
|
-
getResolvedError:
|
|
31
|
-
showError:
|
|
32
|
-
reportRetryAttempt:
|
|
29
|
+
withErrorHandler: Function | undefined;
|
|
30
|
+
getResolvedError: Function | undefined;
|
|
31
|
+
showError: Function | undefined;
|
|
32
|
+
reportRetryAttempt: Function | undefined;
|
|
33
33
|
};
|
|
34
34
|
};
|
|
@@ -1,45 +1,52 @@
|
|
|
1
1
|
export function createEssentialsMockFactory(mockFn) {
|
|
2
|
+
const mockFns = new Map();
|
|
3
|
+
const createUniqueFn = (name, implementation) => {
|
|
4
|
+
if (!mockFns.has(name)) {
|
|
5
|
+
mockFns.set(name, mockFn(implementation));
|
|
6
|
+
}
|
|
7
|
+
return mockFns.get(name);
|
|
8
|
+
};
|
|
2
9
|
return {
|
|
3
10
|
i18n: {
|
|
4
|
-
getLanguage:
|
|
5
|
-
getLocale:
|
|
11
|
+
getLanguage: createUniqueFn('i18n.getLanguage', () => 'en'),
|
|
12
|
+
getLocale: createUniqueFn('i18n.getLocale', () => 'en-US'),
|
|
6
13
|
},
|
|
7
14
|
bi: {
|
|
8
|
-
getLogger:
|
|
9
|
-
log:
|
|
10
|
-
report:
|
|
11
|
-
flush:
|
|
12
|
-
updateDefaults:
|
|
13
|
-
log:
|
|
14
|
-
report:
|
|
15
|
-
flush:
|
|
16
|
-
updateDefaults:
|
|
15
|
+
getLogger: createUniqueFn('bi.getLogger', () => ({
|
|
16
|
+
log: createUniqueFn('bi.getLogger.log'),
|
|
17
|
+
report: createUniqueFn('bi.getLogger.report'),
|
|
18
|
+
flush: createUniqueFn('bi.getLogger.flush'),
|
|
19
|
+
updateDefaults: createUniqueFn('bi.getLogger.updateDefaults', (params) => ({
|
|
20
|
+
log: createUniqueFn('bi.getLogger.updateDefaults.log'),
|
|
21
|
+
report: createUniqueFn('bi.getLogger.updateDefaults.report'),
|
|
22
|
+
flush: createUniqueFn('bi.getLogger.updateDefaults.flush'),
|
|
23
|
+
updateDefaults: createUniqueFn('bi.getLogger.updateDefaults.updateDefaults'),
|
|
17
24
|
})),
|
|
18
25
|
})),
|
|
19
26
|
},
|
|
20
27
|
monitoring: {
|
|
21
|
-
getMonitoringClient:
|
|
22
|
-
captureException:
|
|
23
|
-
captureMessage:
|
|
24
|
-
setContext:
|
|
25
|
-
setTag:
|
|
26
|
-
setUser:
|
|
27
|
-
addBreadcrumb:
|
|
28
|
+
getMonitoringClient: createUniqueFn('monitoring.getMonitoringClient', () => ({
|
|
29
|
+
captureException: createUniqueFn('monitoring.getMonitoringClient.captureException'),
|
|
30
|
+
captureMessage: createUniqueFn('monitoring.getMonitoringClient.captureMessage'),
|
|
31
|
+
setContext: createUniqueFn('monitoring.getMonitoringClient.setContext'),
|
|
32
|
+
setTag: createUniqueFn('monitoring.getMonitoringClient.setTag'),
|
|
33
|
+
setUser: createUniqueFn('monitoring.getMonitoringClient.setUser'),
|
|
34
|
+
addBreadcrumb: createUniqueFn('monitoring.getMonitoringClient.addBreadcrumb'),
|
|
28
35
|
})),
|
|
29
36
|
},
|
|
30
37
|
experiments: {
|
|
31
|
-
enabled:
|
|
32
|
-
get:
|
|
38
|
+
enabled: createUniqueFn('experiments.enabled', () => false),
|
|
39
|
+
get: createUniqueFn('experiments.get', () => null),
|
|
33
40
|
},
|
|
34
41
|
settings: {
|
|
35
|
-
getTimezone:
|
|
42
|
+
getTimezone: createUniqueFn('settings.getTimezone', () => 'UTC'),
|
|
36
43
|
},
|
|
37
44
|
auth: {
|
|
38
|
-
elevate:
|
|
39
|
-
getContextualAuth:
|
|
45
|
+
elevate: createUniqueFn('auth.elevate', (restModule) => restModule),
|
|
46
|
+
getContextualAuth: createUniqueFn('auth.getContextualAuth', () => ({
|
|
40
47
|
headers: {},
|
|
41
48
|
})),
|
|
42
|
-
getTokenInfo:
|
|
49
|
+
getTokenInfo: createUniqueFn('auth.getTokenInfo', () => Promise.resolve({
|
|
43
50
|
active: true,
|
|
44
51
|
subjectType: 'USER',
|
|
45
52
|
subjectId: 'mock-user-id',
|
|
@@ -51,21 +58,21 @@ export function createEssentialsMockFactory(mockFn) {
|
|
|
51
58
|
})),
|
|
52
59
|
},
|
|
53
60
|
httpClient: {
|
|
54
|
-
fetchWithAuth:
|
|
55
|
-
graphql:
|
|
61
|
+
fetchWithAuth: createUniqueFn('httpClient.fetchWithAuth', () => global.fetch || mockFn()),
|
|
62
|
+
graphql: createUniqueFn('httpClient.graphql', () => Promise.resolve({
|
|
56
63
|
data: {},
|
|
57
64
|
errors: [],
|
|
58
65
|
})),
|
|
59
66
|
},
|
|
60
67
|
errorHandler: {
|
|
61
|
-
withErrorHandler:
|
|
62
|
-
getResolvedError:
|
|
68
|
+
withErrorHandler: createUniqueFn('errorHandler.withErrorHandler', (fn) => fn()),
|
|
69
|
+
getResolvedError: createUniqueFn('errorHandler.getResolvedError', () => ({
|
|
63
70
|
code: 'UNKNOWN_ERROR',
|
|
64
71
|
message: 'Mock error',
|
|
65
72
|
details: {},
|
|
66
73
|
})),
|
|
67
|
-
showError:
|
|
68
|
-
reportRetryAttempt:
|
|
74
|
+
showError: createUniqueFn('errorHandler.showError'),
|
|
75
|
+
reportRetryAttempt: createUniqueFn('errorHandler.reportRetryAttempt'),
|
|
69
76
|
},
|
|
70
77
|
};
|
|
71
78
|
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
export declare function createEssentialsMockFactory(mockFn: any): {
|
|
2
2
|
i18n: {
|
|
3
|
-
getLanguage:
|
|
4
|
-
getLocale:
|
|
3
|
+
getLanguage: Function | undefined;
|
|
4
|
+
getLocale: Function | undefined;
|
|
5
5
|
};
|
|
6
6
|
bi: {
|
|
7
|
-
getLogger:
|
|
7
|
+
getLogger: Function | undefined;
|
|
8
8
|
};
|
|
9
9
|
monitoring: {
|
|
10
|
-
getMonitoringClient:
|
|
10
|
+
getMonitoringClient: Function | undefined;
|
|
11
11
|
};
|
|
12
12
|
experiments: {
|
|
13
|
-
enabled:
|
|
14
|
-
get:
|
|
13
|
+
enabled: Function | undefined;
|
|
14
|
+
get: Function | undefined;
|
|
15
15
|
};
|
|
16
16
|
settings: {
|
|
17
|
-
getTimezone:
|
|
17
|
+
getTimezone: Function | undefined;
|
|
18
18
|
};
|
|
19
19
|
auth: {
|
|
20
|
-
elevate:
|
|
21
|
-
getContextualAuth:
|
|
22
|
-
getTokenInfo:
|
|
20
|
+
elevate: Function | undefined;
|
|
21
|
+
getContextualAuth: Function | undefined;
|
|
22
|
+
getTokenInfo: Function | undefined;
|
|
23
23
|
};
|
|
24
24
|
httpClient: {
|
|
25
|
-
fetchWithAuth:
|
|
26
|
-
graphql:
|
|
25
|
+
fetchWithAuth: Function | undefined;
|
|
26
|
+
graphql: Function | undefined;
|
|
27
27
|
};
|
|
28
28
|
errorHandler: {
|
|
29
|
-
withErrorHandler:
|
|
30
|
-
getResolvedError:
|
|
31
|
-
showError:
|
|
32
|
-
reportRetryAttempt:
|
|
29
|
+
withErrorHandler: Function | undefined;
|
|
30
|
+
getResolvedError: Function | undefined;
|
|
31
|
+
showError: Function | undefined;
|
|
32
|
+
reportRetryAttempt: Function | undefined;
|
|
33
33
|
};
|
|
34
34
|
};
|
|
@@ -2,47 +2,54 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createEssentialsMockFactory = createEssentialsMockFactory;
|
|
4
4
|
function createEssentialsMockFactory(mockFn) {
|
|
5
|
+
const mockFns = new Map();
|
|
6
|
+
const createUniqueFn = (name, implementation) => {
|
|
7
|
+
if (!mockFns.has(name)) {
|
|
8
|
+
mockFns.set(name, mockFn(implementation));
|
|
9
|
+
}
|
|
10
|
+
return mockFns.get(name);
|
|
11
|
+
};
|
|
5
12
|
return {
|
|
6
13
|
i18n: {
|
|
7
|
-
getLanguage:
|
|
8
|
-
getLocale:
|
|
14
|
+
getLanguage: createUniqueFn('i18n.getLanguage', () => 'en'),
|
|
15
|
+
getLocale: createUniqueFn('i18n.getLocale', () => 'en-US'),
|
|
9
16
|
},
|
|
10
17
|
bi: {
|
|
11
|
-
getLogger:
|
|
12
|
-
log:
|
|
13
|
-
report:
|
|
14
|
-
flush:
|
|
15
|
-
updateDefaults:
|
|
16
|
-
log:
|
|
17
|
-
report:
|
|
18
|
-
flush:
|
|
19
|
-
updateDefaults:
|
|
18
|
+
getLogger: createUniqueFn('bi.getLogger', () => ({
|
|
19
|
+
log: createUniqueFn('bi.getLogger.log'),
|
|
20
|
+
report: createUniqueFn('bi.getLogger.report'),
|
|
21
|
+
flush: createUniqueFn('bi.getLogger.flush'),
|
|
22
|
+
updateDefaults: createUniqueFn('bi.getLogger.updateDefaults', (params) => ({
|
|
23
|
+
log: createUniqueFn('bi.getLogger.updateDefaults.log'),
|
|
24
|
+
report: createUniqueFn('bi.getLogger.updateDefaults.report'),
|
|
25
|
+
flush: createUniqueFn('bi.getLogger.updateDefaults.flush'),
|
|
26
|
+
updateDefaults: createUniqueFn('bi.getLogger.updateDefaults.updateDefaults'),
|
|
20
27
|
})),
|
|
21
28
|
})),
|
|
22
29
|
},
|
|
23
30
|
monitoring: {
|
|
24
|
-
getMonitoringClient:
|
|
25
|
-
captureException:
|
|
26
|
-
captureMessage:
|
|
27
|
-
setContext:
|
|
28
|
-
setTag:
|
|
29
|
-
setUser:
|
|
30
|
-
addBreadcrumb:
|
|
31
|
+
getMonitoringClient: createUniqueFn('monitoring.getMonitoringClient', () => ({
|
|
32
|
+
captureException: createUniqueFn('monitoring.getMonitoringClient.captureException'),
|
|
33
|
+
captureMessage: createUniqueFn('monitoring.getMonitoringClient.captureMessage'),
|
|
34
|
+
setContext: createUniqueFn('monitoring.getMonitoringClient.setContext'),
|
|
35
|
+
setTag: createUniqueFn('monitoring.getMonitoringClient.setTag'),
|
|
36
|
+
setUser: createUniqueFn('monitoring.getMonitoringClient.setUser'),
|
|
37
|
+
addBreadcrumb: createUniqueFn('monitoring.getMonitoringClient.addBreadcrumb'),
|
|
31
38
|
})),
|
|
32
39
|
},
|
|
33
40
|
experiments: {
|
|
34
|
-
enabled:
|
|
35
|
-
get:
|
|
41
|
+
enabled: createUniqueFn('experiments.enabled', () => false),
|
|
42
|
+
get: createUniqueFn('experiments.get', () => null),
|
|
36
43
|
},
|
|
37
44
|
settings: {
|
|
38
|
-
getTimezone:
|
|
45
|
+
getTimezone: createUniqueFn('settings.getTimezone', () => 'UTC'),
|
|
39
46
|
},
|
|
40
47
|
auth: {
|
|
41
|
-
elevate:
|
|
42
|
-
getContextualAuth:
|
|
48
|
+
elevate: createUniqueFn('auth.elevate', (restModule) => restModule),
|
|
49
|
+
getContextualAuth: createUniqueFn('auth.getContextualAuth', () => ({
|
|
43
50
|
headers: {},
|
|
44
51
|
})),
|
|
45
|
-
getTokenInfo:
|
|
52
|
+
getTokenInfo: createUniqueFn('auth.getTokenInfo', () => Promise.resolve({
|
|
46
53
|
active: true,
|
|
47
54
|
subjectType: 'USER',
|
|
48
55
|
subjectId: 'mock-user-id',
|
|
@@ -54,21 +61,21 @@ function createEssentialsMockFactory(mockFn) {
|
|
|
54
61
|
})),
|
|
55
62
|
},
|
|
56
63
|
httpClient: {
|
|
57
|
-
fetchWithAuth:
|
|
58
|
-
graphql:
|
|
64
|
+
fetchWithAuth: createUniqueFn('httpClient.fetchWithAuth', () => global.fetch || mockFn()),
|
|
65
|
+
graphql: createUniqueFn('httpClient.graphql', () => Promise.resolve({
|
|
59
66
|
data: {},
|
|
60
67
|
errors: [],
|
|
61
68
|
})),
|
|
62
69
|
},
|
|
63
70
|
errorHandler: {
|
|
64
|
-
withErrorHandler:
|
|
65
|
-
getResolvedError:
|
|
71
|
+
withErrorHandler: createUniqueFn('errorHandler.withErrorHandler', (fn) => fn()),
|
|
72
|
+
getResolvedError: createUniqueFn('errorHandler.getResolvedError', () => ({
|
|
66
73
|
code: 'UNKNOWN_ERROR',
|
|
67
74
|
message: 'Mock error',
|
|
68
75
|
details: {},
|
|
69
76
|
})),
|
|
70
|
-
showError:
|
|
71
|
-
reportRetryAttempt:
|
|
77
|
+
showError: createUniqueFn('errorHandler.showError'),
|
|
78
|
+
reportRetryAttempt: createUniqueFn('errorHandler.reportRetryAttempt'),
|
|
72
79
|
},
|
|
73
80
|
};
|
|
74
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../src/auth.ts","../../src/bi.ts","../../src/experiments.ts","../../src/http-client.ts","../../src/index.ts","../../src/mock-factory.ts","../../src/monitoring.ts","../../src/settings.ts","../../src/error-handler/createErrorHandler.ts","../../src/error-handler/error-handler.ts","../../src/i18n/createI18n.ts","../../src/i18n/i18n.ts"],"version":"5.9.
|
|
1
|
+
{"root":["../../src/auth.ts","../../src/bi.ts","../../src/experiments.ts","../../src/http-client.ts","../../src/index.ts","../../src/mock-factory.ts","../../src/monitoring.ts","../../src/settings.ts","../../src/error-handler/createErrorHandler.ts","../../src/error-handler/error-handler.ts","../../src/i18n/createI18n.ts","../../src/i18n/i18n.ts"],"version":"5.9.3"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/auth.ts","../src/bi.ts","../src/experiments.ts","../src/http-client.ts","../src/index.ts","../src/mock-factory.ts","../src/monitoring.ts","../src/settings.ts","../src/error-handler/createErrorHandler.ts","../src/error-handler/error-handler.ts","../src/i18n/createI18n.ts","../src/i18n/i18n.ts"],"version":"5.9.
|
|
1
|
+
{"root":["../src/auth.ts","../src/bi.ts","../src/experiments.ts","../src/http-client.ts","../src/index.ts","../src/mock-factory.ts","../src/monitoring.ts","../src/settings.ts","../src/error-handler/createErrorHandler.ts","../src/error-handler/error-handler.ts","../src/i18n/createI18n.ts","../src/i18n/i18n.ts"],"version":"5.9.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/essentials",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "cjs/build/index.js",
|
|
6
6
|
"module": "build/index.mjs",
|
|
@@ -42,27 +42,27 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@wix/error-handler": "^1.67.0",
|
|
44
44
|
"@wix/monitoring": "^0.21.0",
|
|
45
|
-
"@wix/sdk-runtime": "
|
|
46
|
-
"@wix/sdk-types": "
|
|
47
|
-
"i18next": "^25.
|
|
48
|
-
"i18next-icu": "^2.
|
|
49
|
-
"intl-messageformat": "^10.7.
|
|
45
|
+
"@wix/sdk-runtime": "1.0.0",
|
|
46
|
+
"@wix/sdk-types": "1.14.0",
|
|
47
|
+
"i18next": "^25.6.1",
|
|
48
|
+
"i18next-icu": "^2.4.1",
|
|
49
|
+
"intl-messageformat": "^10.7.18"
|
|
50
50
|
},
|
|
51
51
|
"optionalDependencies": {
|
|
52
52
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/is-ci": "^3.0.4",
|
|
56
|
-
"@types/node": "^20.19.
|
|
56
|
+
"@types/node": "^20.19.24",
|
|
57
57
|
"@vitest/ui": "^1.6.1",
|
|
58
|
-
"@wix/sdk": "1.
|
|
58
|
+
"@wix/sdk": "1.17.3",
|
|
59
59
|
"eslint": "^8.57.1",
|
|
60
|
-
"eslint-config-sdk": "
|
|
60
|
+
"eslint-config-sdk": "1.0.0",
|
|
61
61
|
"graphql": "^16.8.0",
|
|
62
62
|
"is-ci": "^3.0.1",
|
|
63
63
|
"jsdom": "^22.1.0",
|
|
64
|
-
"msw": "^2.
|
|
65
|
-
"typescript": "^5.9.
|
|
64
|
+
"msw": "^2.12.0",
|
|
65
|
+
"typescript": "^5.9.3",
|
|
66
66
|
"vitest": "^1.6.1",
|
|
67
67
|
"vitest-teamcity-reporter": "^0.3.1"
|
|
68
68
|
},
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
]
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
|
-
"falconPackageHash": "
|
|
86
|
+
"falconPackageHash": "ceaddd2df4618ad4d9ffefde1b9f902264ed7753d2b7b2c62c5e9924"
|
|
87
87
|
}
|