@wix/sdk 1.12.1 → 1.12.3

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,5 +1,6 @@
1
1
  import { WixClient } from './wixClient.js';
2
- export declare function elevate<T extends (...arg: any) => any>(func: T): (...param: Parameters<T>) => ReturnType<T>;
2
+ import { RESTFunctionDescriptor } from '@wix/sdk-types';
3
+ export declare function elevate<T extends RESTFunctionDescriptor>(restModule: T): T;
3
4
  export declare const fetchWithAuth: WixClient['fetchWithAuth'];
4
5
  export declare const graphql: WixClient['graphql'];
5
6
  export { setGlobalWixContext } from './wix-context.js';
package/build/context.js CHANGED
@@ -1,22 +1,20 @@
1
1
  import { resolveContext } from '@wix/sdk-runtime/context';
2
- export function elevate(func) {
3
- return (...args) => {
4
- let fullArgs = Array(func.length)
5
- .fill(undefined)
6
- .map((_, index) => args[index]);
7
- // support old EDMs
8
- if (fullArgs.length === 0) {
9
- fullArgs = args;
10
- }
11
- return func(...fullArgs, { suppressAuth: true });
12
- };
2
+ import { createRESTModule } from '@wix/sdk-runtime/rest-modules';
3
+ export function elevate(restModule) {
4
+ return createRESTModule(restModule, true);
13
5
  }
14
6
  export const fetchWithAuth = async (...args) => {
15
7
  const context = resolveContext();
8
+ if (!context) {
9
+ throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');
10
+ }
16
11
  return context.fetchWithAuth(...args);
17
12
  };
18
13
  export const graphql = async (...args) => {
19
14
  const context = resolveContext();
15
+ if (!context) {
16
+ throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');
17
+ }
20
18
  return context.graphql(...args);
21
19
  };
22
20
  export { setGlobalWixContext } from './wix-context.js';
@@ -1,5 +1,4 @@
1
- import { isObject } from './helpers.js';
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
- envelope = { metadata };
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
- import { isObject } from './helpers.js';
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);
@@ -1,5 +1,6 @@
1
1
  import { WixClient } from './wixClient.js';
2
- export declare function elevate<T extends (...arg: any) => any>(func: T): (...param: Parameters<T>) => ReturnType<T>;
2
+ import { RESTFunctionDescriptor } from '@wix/sdk-types';
3
+ export declare function elevate<T extends RESTFunctionDescriptor>(restModule: T): T;
3
4
  export declare const fetchWithAuth: WixClient['fetchWithAuth'];
4
5
  export declare const graphql: WixClient['graphql'];
5
6
  export { setGlobalWixContext } from './wix-context.js';
@@ -2,26 +2,24 @@
2
2
  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
- function elevate(func) {
6
- return (...args) => {
7
- let fullArgs = Array(func.length)
8
- .fill(undefined)
9
- .map((_, index) => args[index]);
10
- // support old EDMs
11
- if (fullArgs.length === 0) {
12
- fullArgs = args;
13
- }
14
- return func(...fullArgs, { suppressAuth: true });
15
- };
5
+ const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
6
+ function elevate(restModule) {
7
+ return (0, rest_modules_1.createRESTModule)(restModule, true);
16
8
  }
17
9
  exports.elevate = elevate;
18
10
  const fetchWithAuth = async (...args) => {
19
11
  const context = (0, context_1.resolveContext)();
12
+ if (!context) {
13
+ throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');
14
+ }
20
15
  return context.fetchWithAuth(...args);
21
16
  };
22
17
  exports.fetchWithAuth = fetchWithAuth;
23
18
  const graphql = async (...args) => {
24
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
+ }
25
23
  return context.graphql(...args);
26
24
  };
27
25
  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 helpers_js_1 = require("./helpers.js");
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
- envelope = { metadata };
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 helpers_js_1 = require("./helpers.js");
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk",
3
- "version": "1.12.1",
3
+ "version": "1.12.3",
4
4
  "license": "UNLICENSED",
5
5
  "author": {
6
6
  "name": "Ronny Ringel",
@@ -65,10 +65,10 @@
65
65
  "dependencies": {
66
66
  "@babel/runtime": "^7.23.2",
67
67
  "@wix/identity": "^1.0.78",
68
- "@wix/image-kit": "^1.71.0",
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.3",
71
+ "@wix/sdk-runtime": "0.3.5",
72
72
  "@wix/sdk-types": "^1.9.1",
73
73
  "crypto-js": "^4.2.0",
74
74
  "jose": "^5.2.1",
@@ -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.3",
91
+ "@wix/sdk-runtime": "0.3.5",
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": "177ec0d44fe0da191345f8a3682db306bf5ed81105ff12431590e217"
125
+ "falconPackageHash": "239bd2509209b4a672bd9f2a52c27b12bd92045e93c1bc44f4bbda4b"
126
126
  }