@wix/sdk 1.7.13 → 1.7.14
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/wix-context.d.ts +4 -51
- package/build/wix-context.js +2 -51
- package/cjs/build/wix-context.d.ts +4 -51
- package/cjs/build/wix-context.js +4 -53
- package/package.json +4 -4
package/build/wix-context.d.ts
CHANGED
|
@@ -1,52 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type MaybeWithWixContext<T extends RESTFunctionDescriptor> = typeof globalThis extends {
|
|
5
|
-
__wix_context__: {
|
|
6
|
-
initWixModules: unknown;
|
|
7
|
-
};
|
|
8
|
-
} ? BuildRESTFunction<T> : T;
|
|
9
|
-
declare namespace globalThis {
|
|
10
|
-
let __wix_context__: {
|
|
11
|
-
asyncLocalStorage?: import('node:async_hooks').AsyncLocalStorage<{
|
|
12
|
-
authStrategy: {
|
|
13
|
-
getAuthHeaders: () => Promise<{
|
|
14
|
-
headers: {
|
|
15
|
-
Authorization: string;
|
|
16
|
-
};
|
|
17
|
-
}>;
|
|
18
|
-
};
|
|
19
|
-
}>;
|
|
20
|
-
initWixModules: unknown;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export declare function setGlobalWixModulesInit(initWixModules: <T extends Descriptors, H extends Host>(wixModules: T) => BuildDescriptors<T, H>): void;
|
|
24
|
-
export declare const AsyncLocalStorageContext: {
|
|
25
|
-
asyncLocalStorage: AsyncLocalStorage<{
|
|
26
|
-
authStrategy: {
|
|
27
|
-
getAuthHeaders: () => Promise<{
|
|
28
|
-
headers: {
|
|
29
|
-
Authorization: string;
|
|
30
|
-
};
|
|
31
|
-
}>;
|
|
32
|
-
};
|
|
33
|
-
}> | undefined;
|
|
34
|
-
init(AsyncLocalStorageConstructor: typeof AsyncLocalStorage): void;
|
|
35
|
-
run(authStrategy: {
|
|
36
|
-
getAuthHeaders: () => Promise<{
|
|
37
|
-
headers: {
|
|
38
|
-
Authorization: string;
|
|
39
|
-
};
|
|
40
|
-
}>;
|
|
41
|
-
}, fn: () => unknown): unknown;
|
|
1
|
+
import { BuildDescriptors, Descriptors, Host } from './index.js';
|
|
2
|
+
export type WixContext = {
|
|
3
|
+
initWixModules: <T extends Descriptors, H extends Host>(wixModules: T, elevated?: boolean) => BuildDescriptors<T, H>;
|
|
42
4
|
};
|
|
43
|
-
export declare
|
|
44
|
-
init(authStrategy: {
|
|
45
|
-
getAuthHeaders: () => Promise<{
|
|
46
|
-
headers: {
|
|
47
|
-
Authorization: string;
|
|
48
|
-
};
|
|
49
|
-
}>;
|
|
50
|
-
}): void;
|
|
51
|
-
};
|
|
52
|
-
export {};
|
|
5
|
+
export declare function setGlobalWixContext(wixContext: WixContext): void;
|
package/build/wix-context.js
CHANGED
|
@@ -1,52 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
globalThis.__wix_context__ = {
|
|
4
|
-
initWixModules,
|
|
5
|
-
};
|
|
1
|
+
export function setGlobalWixContext(wixContext) {
|
|
2
|
+
globalThis.__wix_context__ = wixContext;
|
|
6
3
|
}
|
|
7
|
-
export const AsyncLocalStorageContext = {
|
|
8
|
-
asyncLocalStorage: undefined,
|
|
9
|
-
init(AsyncLocalStorageConstructor) {
|
|
10
|
-
const asyncLocalStorage = new AsyncLocalStorageConstructor();
|
|
11
|
-
this.asyncLocalStorage = asyncLocalStorage;
|
|
12
|
-
setGlobalWixModulesInit((wixModules) => {
|
|
13
|
-
const client = createClient({
|
|
14
|
-
auth: {
|
|
15
|
-
async getAuthHeaders() {
|
|
16
|
-
const store = asyncLocalStorage.getStore();
|
|
17
|
-
if (!store) {
|
|
18
|
-
throw new Error('No wix context found, make sure to init and use wix context');
|
|
19
|
-
}
|
|
20
|
-
return store.authStrategy.getAuthHeaders();
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
return client.use(wixModules);
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
run(authStrategy, fn) {
|
|
28
|
-
if (!globalThis.__wix_context__) {
|
|
29
|
-
throw new Error('Wix context not initialized');
|
|
30
|
-
}
|
|
31
|
-
if (this.asyncLocalStorage) {
|
|
32
|
-
return this.asyncLocalStorage.run({ authStrategy }, fn);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
throw new Error('AsyncLocalStorageContext: `run` has been called before `init` method. Make sure to call `init` method before using `run` method.');
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
export const GlobalSingletonContext = {
|
|
40
|
-
init(authStrategy) {
|
|
41
|
-
setGlobalWixModulesInit((wixModules) => {
|
|
42
|
-
const client = createClient({
|
|
43
|
-
auth: {
|
|
44
|
-
async getAuthHeaders() {
|
|
45
|
-
return authStrategy.getAuthHeaders();
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
return client.use(wixModules);
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
};
|
|
@@ -1,52 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type MaybeWithWixContext<T extends RESTFunctionDescriptor> = typeof globalThis extends {
|
|
5
|
-
__wix_context__: {
|
|
6
|
-
initWixModules: unknown;
|
|
7
|
-
};
|
|
8
|
-
} ? BuildRESTFunction<T> : T;
|
|
9
|
-
declare namespace globalThis {
|
|
10
|
-
let __wix_context__: {
|
|
11
|
-
asyncLocalStorage?: import('node:async_hooks').AsyncLocalStorage<{
|
|
12
|
-
authStrategy: {
|
|
13
|
-
getAuthHeaders: () => Promise<{
|
|
14
|
-
headers: {
|
|
15
|
-
Authorization: string;
|
|
16
|
-
};
|
|
17
|
-
}>;
|
|
18
|
-
};
|
|
19
|
-
}>;
|
|
20
|
-
initWixModules: unknown;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export declare function setGlobalWixModulesInit(initWixModules: <T extends Descriptors, H extends Host>(wixModules: T) => BuildDescriptors<T, H>): void;
|
|
24
|
-
export declare const AsyncLocalStorageContext: {
|
|
25
|
-
asyncLocalStorage: AsyncLocalStorage<{
|
|
26
|
-
authStrategy: {
|
|
27
|
-
getAuthHeaders: () => Promise<{
|
|
28
|
-
headers: {
|
|
29
|
-
Authorization: string;
|
|
30
|
-
};
|
|
31
|
-
}>;
|
|
32
|
-
};
|
|
33
|
-
}> | undefined;
|
|
34
|
-
init(AsyncLocalStorageConstructor: typeof AsyncLocalStorage): void;
|
|
35
|
-
run(authStrategy: {
|
|
36
|
-
getAuthHeaders: () => Promise<{
|
|
37
|
-
headers: {
|
|
38
|
-
Authorization: string;
|
|
39
|
-
};
|
|
40
|
-
}>;
|
|
41
|
-
}, fn: () => unknown): unknown;
|
|
1
|
+
import { BuildDescriptors, Descriptors, Host } from './index.js';
|
|
2
|
+
export type WixContext = {
|
|
3
|
+
initWixModules: <T extends Descriptors, H extends Host>(wixModules: T, elevated?: boolean) => BuildDescriptors<T, H>;
|
|
42
4
|
};
|
|
43
|
-
export declare
|
|
44
|
-
init(authStrategy: {
|
|
45
|
-
getAuthHeaders: () => Promise<{
|
|
46
|
-
headers: {
|
|
47
|
-
Authorization: string;
|
|
48
|
-
};
|
|
49
|
-
}>;
|
|
50
|
-
}): void;
|
|
51
|
-
};
|
|
52
|
-
export {};
|
|
5
|
+
export declare function setGlobalWixContext(wixContext: WixContext): void;
|
package/cjs/build/wix-context.js
CHANGED
|
@@ -1,56 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
globalThis.__wix_context__ = {
|
|
7
|
-
initWixModules,
|
|
8
|
-
};
|
|
3
|
+
exports.setGlobalWixContext = void 0;
|
|
4
|
+
function setGlobalWixContext(wixContext) {
|
|
5
|
+
globalThis.__wix_context__ = wixContext;
|
|
9
6
|
}
|
|
10
|
-
exports.
|
|
11
|
-
exports.AsyncLocalStorageContext = {
|
|
12
|
-
asyncLocalStorage: undefined,
|
|
13
|
-
init(AsyncLocalStorageConstructor) {
|
|
14
|
-
const asyncLocalStorage = new AsyncLocalStorageConstructor();
|
|
15
|
-
this.asyncLocalStorage = asyncLocalStorage;
|
|
16
|
-
setGlobalWixModulesInit((wixModules) => {
|
|
17
|
-
const client = (0, index_js_1.createClient)({
|
|
18
|
-
auth: {
|
|
19
|
-
async getAuthHeaders() {
|
|
20
|
-
const store = asyncLocalStorage.getStore();
|
|
21
|
-
if (!store) {
|
|
22
|
-
throw new Error('No wix context found, make sure to init and use wix context');
|
|
23
|
-
}
|
|
24
|
-
return store.authStrategy.getAuthHeaders();
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
return client.use(wixModules);
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
run(authStrategy, fn) {
|
|
32
|
-
if (!globalThis.__wix_context__) {
|
|
33
|
-
throw new Error('Wix context not initialized');
|
|
34
|
-
}
|
|
35
|
-
if (this.asyncLocalStorage) {
|
|
36
|
-
return this.asyncLocalStorage.run({ authStrategy }, fn);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
throw new Error('AsyncLocalStorageContext: `run` has been called before `init` method. Make sure to call `init` method before using `run` method.');
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
exports.GlobalSingletonContext = {
|
|
44
|
-
init(authStrategy) {
|
|
45
|
-
setGlobalWixModulesInit((wixModules) => {
|
|
46
|
-
const client = (0, index_js_1.createClient)({
|
|
47
|
-
auth: {
|
|
48
|
-
async getAuthHeaders() {
|
|
49
|
-
return authStrategy.getAuthHeaders();
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
return client.use(wixModules);
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
};
|
|
7
|
+
exports.setGlobalWixContext = setGlobalWixContext;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/sdk",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.14",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ronny Ringel",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"@types/is-ci": "^3.0.4",
|
|
83
83
|
"@types/node": "^20.10.6",
|
|
84
84
|
"@vitest/ui": "^1.1.3",
|
|
85
|
-
"@wix/ecom": "^1.0.
|
|
86
|
-
"@wix/events": "^1.0.
|
|
85
|
+
"@wix/ecom": "^1.0.519",
|
|
86
|
+
"@wix/events": "^1.0.169",
|
|
87
87
|
"@wix/metro": "^1.0.73",
|
|
88
88
|
"@wix/metro-runtime": "^1.1669.0",
|
|
89
89
|
"@wix/sdk-runtime": "0.2.8",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"wallaby": {
|
|
121
121
|
"autoDetect": true
|
|
122
122
|
},
|
|
123
|
-
"falconPackageHash": "
|
|
123
|
+
"falconPackageHash": "26e8ad87ca64212f00e6d70a72fde208558be3a6c14e56440cbb70dd"
|
|
124
124
|
}
|