@wix/sdk 1.15.0 → 1.15.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.
@@ -1,12 +1,6 @@
1
1
  export declare const isWebMethodModules: (val: any) => val is WebMethodModules;
2
2
  export type WebMethodClient = {
3
3
  processRequest(request: Request, devMode?: boolean): Promise<Response>;
4
- callWebMethod(options: {
5
- filename: string;
6
- method: string;
7
- args: unknown[];
8
- baseURL: string;
9
- }): Promise<unknown>;
10
4
  };
11
5
  declare enum Permissions {
12
6
  Anyone = "anyone",
@@ -20,16 +14,10 @@ type WebMethod<T extends unknown[], R> = {
20
14
  };
21
15
  type WebMethodModule = Record<string, WebMethod<unknown[], unknown>>;
22
16
  export type WebMethodModules = Record<string, () => Promise<WebMethodModule>>;
23
- export declare function webMethodModules(fetchWithAuth: (urlOrRequest: string | URL | Request, requestInit?: RequestInit) => Promise<Response>): {
17
+ export declare function webMethodModules(): {
24
18
  initModule(webMethodModule: WebMethodModules): void;
25
19
  client: {
26
20
  processRequest(request: Request, devMode?: boolean | undefined): Promise<Response>;
27
- callWebMethod({ baseURL, filename, method, args }: {
28
- filename: string;
29
- method: string;
30
- args: unknown[];
31
- baseURL: string;
32
- }): Promise<any>;
33
21
  };
34
22
  };
35
23
  export {};
@@ -48,7 +48,7 @@ function isRequestBodyValid(body) {
48
48
  return !!body && typeof body === 'object' && Array.isArray(body);
49
49
  }
50
50
  const productionErrorMessage = 'Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information.';
51
- export function webMethodModules(fetchWithAuth) {
51
+ export function webMethodModules() {
52
52
  const webMethods = {};
53
53
  const client = {
54
54
  async processRequest(request, devMode = false) {
@@ -90,18 +90,6 @@ export function webMethodModules(fetchWithAuth) {
90
90
  });
91
91
  }
92
92
  },
93
- async callWebMethod({ baseURL, filename, method, args }) {
94
- const response = await fetchWithAuth(`${baseURL}/_webMethods/${filename}/${method}.ajax`, {
95
- body: JSON.stringify(args),
96
- method: 'POST',
97
- });
98
- const json = await response.json();
99
- // request failed
100
- if (json.exception === true) {
101
- throw json.result;
102
- }
103
- return json.result;
104
- },
105
93
  };
106
94
  return {
107
95
  initModule(webMethodModule) {
@@ -0,0 +1,8 @@
1
+ type Options = {
2
+ baseURL: string;
3
+ filename: string;
4
+ method: string;
5
+ args: unknown[];
6
+ };
7
+ export declare const callWebMethod: (({ baseURL, filename, method, args }: Options) => Promise<any>) & (({ fetchWithAuth }: import("@wix/sdk-types").HttpClient) => ({ baseURL, filename, method, args }: Options) => Promise<any>);
8
+ export {};
@@ -0,0 +1,15 @@
1
+ import { createRESTModule } from '@wix/sdk-runtime/rest-modules';
2
+ export const callWebMethod = createRESTModule(({ fetchWithAuth }) => {
3
+ return async ({ baseURL, filename, method, args }) => {
4
+ const response = await fetchWithAuth(`${baseURL}/_webMethods/${filename}/${method}.ajax`, {
5
+ body: JSON.stringify(args),
6
+ method: 'POST',
7
+ });
8
+ const json = await response.json();
9
+ // request failed
10
+ if (json.exception === true) {
11
+ throw json.result;
12
+ }
13
+ return json.result;
14
+ };
15
+ });
@@ -37,7 +37,7 @@ export function createClient(config) {
37
37
  };
38
38
  const { client: servicePluginsClient, initModule: initServicePluginModule } = servicePluginsModules(authStrategy);
39
39
  const { client: eventHandlersClient, initModule: initEventHandlerModule } = eventHandlersModules(authStrategy);
40
- const { client: webMethodClient, initModule } = webMethodModules(fetchWithAuth);
40
+ const { client: webMethodClient, initModule } = webMethodModules();
41
41
  const boundFetch = async (url, options) => {
42
42
  const authHeaders = await boundGetAuthHeaders();
43
43
  const defaultContentTypeHeader = getDefaultContentHeader(options);
@@ -1,12 +1,6 @@
1
1
  export declare const isWebMethodModules: (val: any) => val is WebMethodModules;
2
2
  export type WebMethodClient = {
3
3
  processRequest(request: Request, devMode?: boolean): Promise<Response>;
4
- callWebMethod(options: {
5
- filename: string;
6
- method: string;
7
- args: unknown[];
8
- baseURL: string;
9
- }): Promise<unknown>;
10
4
  };
11
5
  declare enum Permissions {
12
6
  Anyone = "anyone",
@@ -20,16 +14,10 @@ type WebMethod<T extends unknown[], R> = {
20
14
  };
21
15
  type WebMethodModule = Record<string, WebMethod<unknown[], unknown>>;
22
16
  export type WebMethodModules = Record<string, () => Promise<WebMethodModule>>;
23
- export declare function webMethodModules(fetchWithAuth: (urlOrRequest: string | URL | Request, requestInit?: RequestInit) => Promise<Response>): {
17
+ export declare function webMethodModules(): {
24
18
  initModule(webMethodModule: WebMethodModules): void;
25
19
  client: {
26
20
  processRequest(request: Request, devMode?: boolean | undefined): Promise<Response>;
27
- callWebMethod({ baseURL, filename, method, args }: {
28
- filename: string;
29
- method: string;
30
- args: unknown[];
31
- baseURL: string;
32
- }): Promise<any>;
33
21
  };
34
22
  };
35
23
  export {};
@@ -53,7 +53,7 @@ function isRequestBodyValid(body) {
53
53
  return !!body && typeof body === 'object' && Array.isArray(body);
54
54
  }
55
55
  const productionErrorMessage = 'Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information.';
56
- function webMethodModules(fetchWithAuth) {
56
+ function webMethodModules() {
57
57
  const webMethods = {};
58
58
  const client = {
59
59
  async processRequest(request, devMode = false) {
@@ -95,18 +95,6 @@ function webMethodModules(fetchWithAuth) {
95
95
  });
96
96
  }
97
97
  },
98
- async callWebMethod({ baseURL, filename, method, args }) {
99
- const response = await fetchWithAuth(`${baseURL}/_webMethods/${filename}/${method}.ajax`, {
100
- body: JSON.stringify(args),
101
- method: 'POST',
102
- });
103
- const json = await response.json();
104
- // request failed
105
- if (json.exception === true) {
106
- throw json.result;
107
- }
108
- return json.result;
109
- },
110
98
  };
111
99
  return {
112
100
  initModule(webMethodModule) {
@@ -0,0 +1,8 @@
1
+ type Options = {
2
+ baseURL: string;
3
+ filename: string;
4
+ method: string;
5
+ args: unknown[];
6
+ };
7
+ export declare const callWebMethod: (({ baseURL, filename, method, args }: Options) => Promise<any>) & (({ fetchWithAuth }: import("@wix/sdk-types").HttpClient) => ({ baseURL, filename, method, args }: Options) => Promise<any>);
8
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callWebMethod = void 0;
4
+ const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
5
+ exports.callWebMethod = (0, rest_modules_1.createRESTModule)(({ fetchWithAuth }) => {
6
+ return async ({ baseURL, filename, method, args }) => {
7
+ const response = await fetchWithAuth(`${baseURL}/_webMethods/${filename}/${method}.ajax`, {
8
+ body: JSON.stringify(args),
9
+ method: 'POST',
10
+ });
11
+ const json = await response.json();
12
+ // request failed
13
+ if (json.exception === true) {
14
+ throw json.result;
15
+ }
16
+ return json.result;
17
+ };
18
+ });
@@ -40,7 +40,7 @@ function createClient(config) {
40
40
  };
41
41
  const { client: servicePluginsClient, initModule: initServicePluginModule } = (0, service_plugin_modules_js_1.servicePluginsModules)(authStrategy);
42
42
  const { client: eventHandlersClient, initModule: initEventHandlerModule } = (0, event_handlers_modules_js_1.eventHandlersModules)(authStrategy);
43
- const { client: webMethodClient, initModule } = (0, web_method_modules_js_1.webMethodModules)(fetchWithAuth);
43
+ const { client: webMethodClient, initModule } = (0, web_method_modules_js_1.webMethodModules)();
44
44
  const boundFetch = async (url, options) => {
45
45
  const authHeaders = await boundGetAuthHeaders();
46
46
  const defaultContentTypeHeader = (0, helpers_js_1.getDefaultContentHeader)(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk",
3
- "version": "1.15.0",
3
+ "version": "1.15.2",
4
4
  "license": "UNLICENSED",
5
5
  "author": {
6
6
  "name": "Ronny Ringel",
@@ -38,6 +38,10 @@
38
38
  "./auth/velo": {
39
39
  "import": "./build/auth/VeloAuthStrategy.js",
40
40
  "require": "./cjs/build/auth/VeloAuthStrategy.js"
41
+ },
42
+ "./web-methods": {
43
+ "import": "./build/web-methods.js",
44
+ "require": "./cjs/build/web-methods.js"
41
45
  }
42
46
  },
43
47
  "sideEffects": false,
@@ -63,14 +67,14 @@
63
67
  "*.{js,ts}": "yarn lint"
64
68
  },
65
69
  "dependencies": {
66
- "@wix/identity": "^1.0.89",
70
+ "@wix/identity": "^1.0.90",
67
71
  "@wix/image-kit": "^1.96.0",
68
72
  "@wix/redirects": "^1.0.64",
69
73
  "@wix/sdk-context": "^0.0.1",
70
- "@wix/sdk-runtime": "0.3.24",
71
- "@wix/sdk-types": "^1.12.4",
74
+ "@wix/sdk-runtime": "0.3.25",
75
+ "@wix/sdk-types": "^1.12.5",
72
76
  "jose": "^5.9.6",
73
- "serialize-error": "^11.0.3",
77
+ "serialize-error": "^8.1.0",
74
78
  "type-fest": "^4.29.0"
75
79
  },
76
80
  "optionalDependencies": {
@@ -81,10 +85,10 @@
81
85
  "@types/node": "^20.17.9",
82
86
  "@vitest/ui": "^1.6.0",
83
87
  "@wix/ecom": "^1.0.845",
84
- "@wix/events": "^1.0.347",
88
+ "@wix/events": "^1.0.348",
85
89
  "@wix/metro": "^1.0.90",
86
- "@wix/metro-runtime": "^1.1864.0",
87
- "@wix/sdk-runtime": "0.3.24",
90
+ "@wix/metro-runtime": "^1.1865.0",
91
+ "@wix/sdk-runtime": "0.3.25",
88
92
  "eslint": "^8.57.1",
89
93
  "eslint-config-sdk": "0.0.0",
90
94
  "graphql": "^16.8.0",
@@ -118,5 +122,5 @@
118
122
  "wallaby": {
119
123
  "autoDetect": true
120
124
  },
121
- "falconPackageHash": "d5bd9917829f690f2cd2bf73f7634aaf3ad2064c7fcbb9f6bb6afd43"
125
+ "falconPackageHash": "a2c7f94cc4b75d51e4cedb69abe8e84c0dba1a761ccbb7ed2f3bc92f"
122
126
  }