@wix/sdk 1.12.0 → 1.12.2
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/auth/AppStrategy.d.ts +1 -7
- package/build/auth/AppStrategy.js +0 -33
- package/build/context.d.ts +1 -1
- package/build/context.js +8 -2
- package/build/event-handlers-modules.js +10 -3
- package/build/service-plugin-modules.js +1 -2
- package/build/wixClient.d.ts +1 -2
- package/build/wixClient.js +0 -6
- package/cjs/build/auth/AppStrategy.d.ts +1 -7
- package/cjs/build/auth/AppStrategy.js +0 -33
- package/cjs/build/context.d.ts +1 -1
- package/cjs/build/context.js +8 -2
- package/cjs/build/event-handlers-modules.js +10 -3
- package/cjs/build/service-plugin-modules.js +1 -2
- package/cjs/build/wixClient.d.ts +1 -2
- package/cjs/build/wixClient.js +0 -6
- package/package.json +6 -6
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { AuthenticationStrategy } from '@wix/sdk-types';
|
|
2
|
-
export type AppStrategy = AuthenticationStrategy<undefined
|
|
3
|
-
instanceId: string;
|
|
4
|
-
} | {
|
|
5
|
-
refreshToken: string;
|
|
6
|
-
} | {
|
|
7
|
-
fromRequest: Request;
|
|
8
|
-
}) => AppStrategy> & {
|
|
2
|
+
export type AppStrategy = AuthenticationStrategy<undefined> & {
|
|
9
3
|
getInstallUrl(opts: {
|
|
10
4
|
redirectUrl: string;
|
|
11
5
|
state?: string;
|
|
@@ -53,39 +53,6 @@ export function AppStrategy(opts) {
|
|
|
53
53
|
}
|
|
54
54
|
return `https://www.wix.com/installer/install?${params.toString()}`;
|
|
55
55
|
},
|
|
56
|
-
withAuth(params) {
|
|
57
|
-
if ('instanceId' in params) {
|
|
58
|
-
return AppStrategy({
|
|
59
|
-
appId: opts.appId,
|
|
60
|
-
appSecret: opts.appSecret,
|
|
61
|
-
publicKey: opts.publicKey,
|
|
62
|
-
instanceId: params.instanceId,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
else if ('refreshToken' in params) {
|
|
66
|
-
return AppStrategy({
|
|
67
|
-
appId: opts.appId,
|
|
68
|
-
appSecret: opts.appSecret,
|
|
69
|
-
publicKey: opts.publicKey,
|
|
70
|
-
refreshToken: params.refreshToken,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
else if ('fromRequest' in params) {
|
|
74
|
-
const authFromRequest = params.fromRequest.headers.get('Authorization');
|
|
75
|
-
if (!authFromRequest) {
|
|
76
|
-
throw new Error('Missing Authorization header in the request');
|
|
77
|
-
}
|
|
78
|
-
return AppStrategy({
|
|
79
|
-
appId: opts.appId,
|
|
80
|
-
appSecret: opts.appSecret,
|
|
81
|
-
publicKey: opts.publicKey,
|
|
82
|
-
accessToken: authFromRequest,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
throw new Error('Invalid parameters for withAuth');
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
56
|
async handleOAuthCallback(url, oauthOpts) {
|
|
90
57
|
if (!opts.appSecret) {
|
|
91
58
|
throw new Error('App secret is required for handling OAuth callback. Make sure to pass it to the AppStrategy');
|
package/build/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WixClient } from './wixClient.js';
|
|
2
|
-
export declare function elevate<T extends (...arg: any) => any>(func: T):
|
|
2
|
+
export declare function elevate<T extends (...arg: any) => any>(func: T): T;
|
|
3
3
|
export declare const fetchWithAuth: WixClient['fetchWithAuth'];
|
|
4
4
|
export declare const graphql: WixClient['graphql'];
|
|
5
5
|
export { setGlobalWixContext } from './wix-context.js';
|
package/build/context.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveContext } from '@wix/sdk-runtime/context';
|
|
2
2
|
export function elevate(func) {
|
|
3
|
-
return (...args) => {
|
|
3
|
+
return ((...args) => {
|
|
4
4
|
let fullArgs = Array(func.length)
|
|
5
5
|
.fill(undefined)
|
|
6
6
|
.map((_, index) => args[index]);
|
|
@@ -9,14 +9,20 @@ export function elevate(func) {
|
|
|
9
9
|
fullArgs = args;
|
|
10
10
|
}
|
|
11
11
|
return func(...fullArgs, { suppressAuth: true });
|
|
12
|
-
};
|
|
12
|
+
});
|
|
13
13
|
}
|
|
14
14
|
export const fetchWithAuth = async (...args) => {
|
|
15
15
|
const context = resolveContext();
|
|
16
|
+
if (!context) {
|
|
17
|
+
throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');
|
|
18
|
+
}
|
|
16
19
|
return context.fetchWithAuth(...args);
|
|
17
20
|
};
|
|
18
21
|
export const graphql = async (...args) => {
|
|
19
22
|
const context = resolveContext();
|
|
23
|
+
if (!context) {
|
|
24
|
+
throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');
|
|
25
|
+
}
|
|
20
26
|
return context.graphql(...args);
|
|
21
27
|
};
|
|
22
28
|
export { setGlobalWixContext } from './wix-context.js';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export const isEventHandlerModule = (val) => isObject(val) && val.__type === 'event-definition';
|
|
1
|
+
export const isEventHandlerModule = (val) => val.__type === 'event-definition';
|
|
3
2
|
export function buildEventDefinition(eventDefinition, registerHandler) {
|
|
4
3
|
return (handler) => {
|
|
5
4
|
registerHandler(eventDefinition, handler);
|
|
@@ -15,7 +14,15 @@ export function runHandler(eventDefinition, handler, payload, baseEventMetadata)
|
|
|
15
14
|
...domainEventMetadata,
|
|
16
15
|
};
|
|
17
16
|
if (deletedEvent) {
|
|
18
|
-
|
|
17
|
+
if (deletedEvent?.deletedEntity) {
|
|
18
|
+
envelope = {
|
|
19
|
+
entity: deletedEvent?.deletedEntity,
|
|
20
|
+
metadata,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
envelope = { metadata };
|
|
25
|
+
}
|
|
19
26
|
}
|
|
20
27
|
else if (actionEvent) {
|
|
21
28
|
envelope = {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export const isServicePluginModule = (val) => isObject(val) && val.__type === 'service-plugin-definition';
|
|
1
|
+
export const isServicePluginModule = (val) => val.__type === 'service-plugin-definition';
|
|
3
2
|
export function buildServicePluginDefinition(servicePluginDefinition, registrServicePluginImplementation, decodeJWT) {
|
|
4
3
|
return (implementation) => {
|
|
5
4
|
registrServicePluginImplementation(servicePluginDefinition, implementation);
|
package/build/wixClient.d.ts
CHANGED
|
@@ -29,7 +29,6 @@ type TypedQueryInput<Result = {
|
|
|
29
29
|
export type WixClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = {}> = {
|
|
30
30
|
setHeaders(headers: Headers): void;
|
|
31
31
|
auth: Omit<Z, 'getAuthHeaders'> & BoundAuthenticationStrategy;
|
|
32
|
-
withAuth: Z['withAuth'] extends undefined ? never : (...args: Parameters<NonNullable<Z['withAuth']>>) => WixClient<H, Z, T>;
|
|
33
32
|
fetch(relativeUrl: string, options: RequestInit): Promise<Response>;
|
|
34
33
|
fetchWithAuth: typeof fetch;
|
|
35
34
|
use<R extends Descriptors = EmptyObject>(modules: H extends Host<any> ? AssertHostMatches<R, H> : R): BuildDescriptors<R, H>;
|
|
@@ -89,7 +88,7 @@ export type ProcessedEvent<T extends EventDefinition<any>[] = []> = {
|
|
|
89
88
|
eventType: string;
|
|
90
89
|
payload: unknown;
|
|
91
90
|
} : ResolvePossibleEvents<T>);
|
|
92
|
-
export declare function createClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H
|
|
91
|
+
export declare function createClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = EmptyObject>(config: {
|
|
93
92
|
modules?: H extends Host<any> ? AssertHostMatches<T, H> : T;
|
|
94
93
|
auth?: Z;
|
|
95
94
|
headers?: Headers;
|
package/build/wixClient.js
CHANGED
|
@@ -87,12 +87,6 @@ export function createClient(config) {
|
|
|
87
87
|
return {
|
|
88
88
|
...wrappedModules,
|
|
89
89
|
auth: authStrategy,
|
|
90
|
-
withAuth: (authStrategy.withAuth
|
|
91
|
-
? (...args) => createClient({
|
|
92
|
-
...config,
|
|
93
|
-
auth: authStrategy.withAuth(...args),
|
|
94
|
-
})
|
|
95
|
-
: undefined),
|
|
96
90
|
setHeaders,
|
|
97
91
|
use,
|
|
98
92
|
enableContext(contextType, opts = { elevated: false }) {
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { AuthenticationStrategy } from '@wix/sdk-types';
|
|
2
|
-
export type AppStrategy = AuthenticationStrategy<undefined
|
|
3
|
-
instanceId: string;
|
|
4
|
-
} | {
|
|
5
|
-
refreshToken: string;
|
|
6
|
-
} | {
|
|
7
|
-
fromRequest: Request;
|
|
8
|
-
}) => AppStrategy> & {
|
|
2
|
+
export type AppStrategy = AuthenticationStrategy<undefined> & {
|
|
9
3
|
getInstallUrl(opts: {
|
|
10
4
|
redirectUrl: string;
|
|
11
5
|
state?: string;
|
|
@@ -79,39 +79,6 @@ function AppStrategy(opts) {
|
|
|
79
79
|
}
|
|
80
80
|
return `https://www.wix.com/installer/install?${params.toString()}`;
|
|
81
81
|
},
|
|
82
|
-
withAuth(params) {
|
|
83
|
-
if ('instanceId' in params) {
|
|
84
|
-
return AppStrategy({
|
|
85
|
-
appId: opts.appId,
|
|
86
|
-
appSecret: opts.appSecret,
|
|
87
|
-
publicKey: opts.publicKey,
|
|
88
|
-
instanceId: params.instanceId,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
else if ('refreshToken' in params) {
|
|
92
|
-
return AppStrategy({
|
|
93
|
-
appId: opts.appId,
|
|
94
|
-
appSecret: opts.appSecret,
|
|
95
|
-
publicKey: opts.publicKey,
|
|
96
|
-
refreshToken: params.refreshToken,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
else if ('fromRequest' in params) {
|
|
100
|
-
const authFromRequest = params.fromRequest.headers.get('Authorization');
|
|
101
|
-
if (!authFromRequest) {
|
|
102
|
-
throw new Error('Missing Authorization header in the request');
|
|
103
|
-
}
|
|
104
|
-
return AppStrategy({
|
|
105
|
-
appId: opts.appId,
|
|
106
|
-
appSecret: opts.appSecret,
|
|
107
|
-
publicKey: opts.publicKey,
|
|
108
|
-
accessToken: authFromRequest,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
throw new Error('Invalid parameters for withAuth');
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
82
|
async handleOAuthCallback(url, oauthOpts) {
|
|
116
83
|
if (!opts.appSecret) {
|
|
117
84
|
throw new Error('App secret is required for handling OAuth callback. Make sure to pass it to the AppStrategy');
|
package/cjs/build/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WixClient } from './wixClient.js';
|
|
2
|
-
export declare function elevate<T extends (...arg: any) => any>(func: T):
|
|
2
|
+
export declare function elevate<T extends (...arg: any) => any>(func: T): T;
|
|
3
3
|
export declare const fetchWithAuth: WixClient['fetchWithAuth'];
|
|
4
4
|
export declare const graphql: WixClient['graphql'];
|
|
5
5
|
export { setGlobalWixContext } from './wix-context.js';
|
package/cjs/build/context.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setGlobalWixContext = exports.graphql = exports.fetchWithAuth = exports.elevate = void 0;
|
|
4
4
|
const context_1 = require("@wix/sdk-runtime/context");
|
|
5
5
|
function elevate(func) {
|
|
6
|
-
return (...args) => {
|
|
6
|
+
return ((...args) => {
|
|
7
7
|
let fullArgs = Array(func.length)
|
|
8
8
|
.fill(undefined)
|
|
9
9
|
.map((_, index) => args[index]);
|
|
@@ -12,16 +12,22 @@ function elevate(func) {
|
|
|
12
12
|
fullArgs = args;
|
|
13
13
|
}
|
|
14
14
|
return func(...fullArgs, { suppressAuth: true });
|
|
15
|
-
};
|
|
15
|
+
});
|
|
16
16
|
}
|
|
17
17
|
exports.elevate = elevate;
|
|
18
18
|
const fetchWithAuth = async (...args) => {
|
|
19
19
|
const context = (0, context_1.resolveContext)();
|
|
20
|
+
if (!context) {
|
|
21
|
+
throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');
|
|
22
|
+
}
|
|
20
23
|
return context.fetchWithAuth(...args);
|
|
21
24
|
};
|
|
22
25
|
exports.fetchWithAuth = fetchWithAuth;
|
|
23
26
|
const graphql = async (...args) => {
|
|
24
27
|
const context = (0, context_1.resolveContext)();
|
|
28
|
+
if (!context) {
|
|
29
|
+
throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');
|
|
30
|
+
}
|
|
25
31
|
return context.graphql(...args);
|
|
26
32
|
};
|
|
27
33
|
exports.graphql = graphql;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runHandler = exports.buildEventDefinition = exports.isEventHandlerModule = void 0;
|
|
4
|
-
const
|
|
5
|
-
const isEventHandlerModule = (val) => (0, helpers_js_1.isObject)(val) && val.__type === 'event-definition';
|
|
4
|
+
const isEventHandlerModule = (val) => val.__type === 'event-definition';
|
|
6
5
|
exports.isEventHandlerModule = isEventHandlerModule;
|
|
7
6
|
function buildEventDefinition(eventDefinition, registerHandler) {
|
|
8
7
|
return (handler) => {
|
|
@@ -20,7 +19,15 @@ function runHandler(eventDefinition, handler, payload, baseEventMetadata) {
|
|
|
20
19
|
...domainEventMetadata,
|
|
21
20
|
};
|
|
22
21
|
if (deletedEvent) {
|
|
23
|
-
|
|
22
|
+
if (deletedEvent?.deletedEntity) {
|
|
23
|
+
envelope = {
|
|
24
|
+
entity: deletedEvent?.deletedEntity,
|
|
25
|
+
metadata,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
envelope = { metadata };
|
|
30
|
+
}
|
|
24
31
|
}
|
|
25
32
|
else if (actionEvent) {
|
|
26
33
|
envelope = {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildServicePluginDefinition = exports.isServicePluginModule = void 0;
|
|
4
|
-
const
|
|
5
|
-
const isServicePluginModule = (val) => (0, helpers_js_1.isObject)(val) && val.__type === 'service-plugin-definition';
|
|
4
|
+
const isServicePluginModule = (val) => val.__type === 'service-plugin-definition';
|
|
6
5
|
exports.isServicePluginModule = isServicePluginModule;
|
|
7
6
|
function buildServicePluginDefinition(servicePluginDefinition, registrServicePluginImplementation, decodeJWT) {
|
|
8
7
|
return (implementation) => {
|
package/cjs/build/wixClient.d.ts
CHANGED
|
@@ -29,7 +29,6 @@ type TypedQueryInput<Result = {
|
|
|
29
29
|
export type WixClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = {}> = {
|
|
30
30
|
setHeaders(headers: Headers): void;
|
|
31
31
|
auth: Omit<Z, 'getAuthHeaders'> & BoundAuthenticationStrategy;
|
|
32
|
-
withAuth: Z['withAuth'] extends undefined ? never : (...args: Parameters<NonNullable<Z['withAuth']>>) => WixClient<H, Z, T>;
|
|
33
32
|
fetch(relativeUrl: string, options: RequestInit): Promise<Response>;
|
|
34
33
|
fetchWithAuth: typeof fetch;
|
|
35
34
|
use<R extends Descriptors = EmptyObject>(modules: H extends Host<any> ? AssertHostMatches<R, H> : R): BuildDescriptors<R, H>;
|
|
@@ -89,7 +88,7 @@ export type ProcessedEvent<T extends EventDefinition<any>[] = []> = {
|
|
|
89
88
|
eventType: string;
|
|
90
89
|
payload: unknown;
|
|
91
90
|
} : ResolvePossibleEvents<T>);
|
|
92
|
-
export declare function createClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H
|
|
91
|
+
export declare function createClient<H extends Host<any> | undefined = undefined, Z extends AuthenticationStrategy<H> = AuthenticationStrategy<H>, T extends Descriptors = EmptyObject>(config: {
|
|
93
92
|
modules?: H extends Host<any> ? AssertHostMatches<T, H> : T;
|
|
94
93
|
auth?: Z;
|
|
95
94
|
headers?: Headers;
|
package/cjs/build/wixClient.js
CHANGED
|
@@ -90,12 +90,6 @@ function createClient(config) {
|
|
|
90
90
|
return {
|
|
91
91
|
...wrappedModules,
|
|
92
92
|
auth: authStrategy,
|
|
93
|
-
withAuth: (authStrategy.withAuth
|
|
94
|
-
? (...args) => createClient({
|
|
95
|
-
...config,
|
|
96
|
-
auth: authStrategy.withAuth(...args),
|
|
97
|
-
})
|
|
98
|
-
: undefined),
|
|
99
93
|
setHeaders,
|
|
100
94
|
use,
|
|
101
95
|
enableContext(contextType, opts = { elevated: false }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/sdk",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.2",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ronny Ringel",
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@babel/runtime": "^7.23.2",
|
|
67
67
|
"@wix/identity": "^1.0.78",
|
|
68
|
-
"@wix/image-kit": "^1.
|
|
68
|
+
"@wix/image-kit": "^1.73.0",
|
|
69
69
|
"@wix/redirects": "^1.0.41",
|
|
70
70
|
"@wix/sdk-context": "^0.0.1",
|
|
71
|
-
"@wix/sdk-runtime": "0.3.
|
|
72
|
-
"@wix/sdk-types": "^1.9.
|
|
71
|
+
"@wix/sdk-runtime": "0.3.4",
|
|
72
|
+
"@wix/sdk-types": "^1.9.1",
|
|
73
73
|
"crypto-js": "^4.2.0",
|
|
74
74
|
"jose": "^5.2.1",
|
|
75
75
|
"pkce-challenge": "^3.1.0",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@wix/events": "^1.0.179",
|
|
89
89
|
"@wix/metro": "^1.0.73",
|
|
90
90
|
"@wix/metro-runtime": "^1.1677.0",
|
|
91
|
-
"@wix/sdk-runtime": "0.3.
|
|
91
|
+
"@wix/sdk-runtime": "0.3.4",
|
|
92
92
|
"eslint": "^8.56.0",
|
|
93
93
|
"eslint-config-sdk": "0.0.0",
|
|
94
94
|
"graphql": "^16.8.0",
|
|
@@ -122,5 +122,5 @@
|
|
|
122
122
|
"wallaby": {
|
|
123
123
|
"autoDetect": true
|
|
124
124
|
},
|
|
125
|
-
"falconPackageHash": "
|
|
125
|
+
"falconPackageHash": "ed5720dfec98f21769aaeee980c988a9df712ff266666d56b450a53d"
|
|
126
126
|
}
|