@wix/sdk 1.10.0 → 1.10.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,5 +1,5 @@
1
1
  export function setGlobalWixContext(wixContext, options = {}) {
2
- if (!globalThis.__wix_context__ && options.dangerouslyOverride) {
2
+ if (!globalThis.__wix_context__ || options.dangerouslyOverride) {
3
3
  globalThis.__wix_context__ = wixContext;
4
4
  }
5
5
  }
@@ -5,6 +5,7 @@ import { AmbassadorFunctionDescriptor, BuildAmbassadorFunction } from './ambassa
5
5
  import { PublicMetadata } from './common.js';
6
6
  import type { GraphQLFormattedError } from 'graphql';
7
7
  type Headers = Record<string, string>;
8
+ declare const SPI_ERROR_TYPE = "wix_spi_error";
8
9
  /**
9
10
  * This type takes in a descriptors object of a certain Host (including an `unknown` host)
10
11
  * and returns an object with the same structure, but with all descriptors replaced with their API.
@@ -13,8 +14,18 @@ type Headers = Record<string, string>;
13
14
  */
14
15
  export type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
15
16
  done: T;
16
- recurse: T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
17
- [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [-1, 0, 1, 2, 3, 4, 5][Depth]> : never;
17
+ recurse: T extends {
18
+ __type: typeof SPI_ERROR_TYPE;
19
+ } ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
20
+ [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
21
+ -1,
22
+ 0,
23
+ 1,
24
+ 2,
25
+ 3,
26
+ 4,
27
+ 5
28
+ ][Depth]> : never;
18
29
  }, EmptyObject>;
19
30
  }[Depth extends -1 ? 'done' : 'recurse'];
20
31
  /**
@@ -7,6 +7,7 @@ import { buildHostModule, isHostModule } from './host-modules.js';
7
7
  import { buildRESTDescriptor } from './rest-modules.js';
8
8
  import { buildEventDefinition, isEventHandlerModule, runHandler, } from './event-handlers-modules.js';
9
9
  import { buildServicePluginDefinition, isServicePluginModule, } from './service-plugin-modules.js';
10
+ const SPI_ERROR_TYPE = 'wix_spi_error';
10
11
  export function createClient(config) {
11
12
  const _headers = config.headers || { Authorization: '' };
12
13
  const eventHandlers = new Map();
@@ -52,6 +53,12 @@ export function createClient(config) {
52
53
  return buildHostModule(modules, config.host);
53
54
  }
54
55
  else if (typeof modules === 'function') {
56
+ // The generated namespaces all have the error classes on them and
57
+ // a class is also a function, so we need to explicitly ignore these
58
+ // error classes using a static field that exists on them.
59
+ if ('__type' in modules && modules.__type === SPI_ERROR_TYPE) {
60
+ return modules;
61
+ }
55
62
  const { module, options } = isAmbassadorModule(modules)
56
63
  ? {
57
64
  module: toHTTPModule(modules),
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setGlobalWixContext = void 0;
4
4
  function setGlobalWixContext(wixContext, options = {}) {
5
- if (!globalThis.__wix_context__ && options.dangerouslyOverride) {
5
+ if (!globalThis.__wix_context__ || options.dangerouslyOverride) {
6
6
  globalThis.__wix_context__ = wixContext;
7
7
  }
8
8
  }
@@ -5,6 +5,7 @@ import { AmbassadorFunctionDescriptor, BuildAmbassadorFunction } from './ambassa
5
5
  import { PublicMetadata } from './common.js';
6
6
  import type { GraphQLFormattedError } from 'graphql';
7
7
  type Headers = Record<string, string>;
8
+ declare const SPI_ERROR_TYPE = "wix_spi_error";
8
9
  /**
9
10
  * This type takes in a descriptors object of a certain Host (including an `unknown` host)
10
11
  * and returns an object with the same structure, but with all descriptors replaced with their API.
@@ -13,8 +14,18 @@ type Headers = Record<string, string>;
13
14
  */
14
15
  export type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
15
16
  done: T;
16
- recurse: T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
17
- [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [-1, 0, 1, 2, 3, 4, 5][Depth]> : never;
17
+ recurse: T extends {
18
+ __type: typeof SPI_ERROR_TYPE;
19
+ } ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
20
+ [Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
21
+ -1,
22
+ 0,
23
+ 1,
24
+ 2,
25
+ 3,
26
+ 4,
27
+ 5
28
+ ][Depth]> : never;
18
29
  }, EmptyObject>;
19
30
  }[Depth extends -1 ? 'done' : 'recurse'];
20
31
  /**
@@ -10,6 +10,7 @@ const host_modules_js_1 = require("./host-modules.js");
10
10
  const rest_modules_js_1 = require("./rest-modules.js");
11
11
  const event_handlers_modules_js_1 = require("./event-handlers-modules.js");
12
12
  const service_plugin_modules_js_1 = require("./service-plugin-modules.js");
13
+ const SPI_ERROR_TYPE = 'wix_spi_error';
13
14
  function createClient(config) {
14
15
  const _headers = config.headers || { Authorization: '' };
15
16
  const eventHandlers = new Map();
@@ -55,6 +56,12 @@ function createClient(config) {
55
56
  return (0, host_modules_js_1.buildHostModule)(modules, config.host);
56
57
  }
57
58
  else if (typeof modules === 'function') {
59
+ // The generated namespaces all have the error classes on them and
60
+ // a class is also a function, so we need to explicitly ignore these
61
+ // error classes using a static field that exists on them.
62
+ if ('__type' in modules && modules.__type === SPI_ERROR_TYPE) {
63
+ return modules;
64
+ }
58
65
  const { module, options } = (0, ambassador_modules_js_1.isAmbassadorModule)(modules)
59
66
  ? {
60
67
  module: (0, ambassador_modules_js_1.toHTTPModule)(modules),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/sdk",
3
- "version": "1.10.0",
3
+ "version": "1.10.2",
4
4
  "license": "UNLICENSED",
5
5
  "author": {
6
6
  "name": "Ronny Ringel",
@@ -120,5 +120,5 @@
120
120
  "wallaby": {
121
121
  "autoDetect": true
122
122
  },
123
- "falconPackageHash": "dc49e3c9b4a2688e193e6698b9a859dd1b3dc26ca312ca4dbf339cf9"
123
+ "falconPackageHash": "445126e56e9a0b8384a7ceb1768d9aa017a75cdd8ce0004a4bdbc6f9"
124
124
  }