Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wix/api-client

Package Overview
Dependencies
Maintainers
26
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wix/api-client - npm Package Compare versions

Comparing version 1.7.14 to 1.8.0

build/event-handlers-modules.d.ts

9

build/wixClient.d.ts

@@ -1,4 +0,4 @@

import { AuthenticationStrategy, BoundAuthenticationStrategy, BuildRESTFunction, Host, HostModule, HostModuleAPI, RESTFunctionDescriptor, SPIDefinition, EventDefinition } from '@wix/sdk-types';
import { AuthenticationStrategy, BoundAuthenticationStrategy, BuildEventDefinition, BuildRESTFunction, EventDefinition, Host, HostModule, HostModuleAPI, RESTFunctionDescriptor, SPIDefinition } from '@wix/sdk-types';
import { ConditionalExcept } from 'type-fest/source/conditional-except.js';
import { EmptyObject } from 'type-fest/source/empty-object.js';
import { ConditionalExcept } from 'type-fest/source/conditional-except.js';
import { AmbassadorFunctionDescriptor, BuildAmbassadorFunction } from './ambassador-modules.js';

@@ -14,3 +14,3 @@ import { PublicMetadata } from './common.js';

*/
export type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined> = BuildRESTDescriptors<T> & BuildAmbassadorDescriptors<T> & (H extends Host<any> ? BuildHostDescriptors<T> : {});
export type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined> = BuildRESTDescriptors<T> & BuildAmbassadorDescriptors<T> & BuildEventDefinitions<T> & (H extends Host<any> ? BuildHostDescriptors<T> : {});
type BuildRESTDescriptors<T extends Descriptors> = T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : ConditionalExcept<{

@@ -25,2 +25,5 @@ [Key in keyof T]: T[Key] extends Descriptors ? BuildRESTDescriptors<T[Key]> : never;

}, EmptyObject>;
type BuildEventDefinitions<T extends Descriptors> = T extends EventDefinition ? BuildEventDefinition<T> : ConditionalExcept<{
[Key in keyof T]: T[Key] extends Descriptors ? BuildEventDefinitions<T[Key]> : never;
}, EmptyObject>;
/**

@@ -27,0 +30,0 @@ * Descriptors are objects that describe the API of a module, and the module

import { EventDefinition, } from '@wix/sdk-types';
import { toHTTPModule, isAmbassadorModule, ambassadorModuleOptions, } from './ambassador-modules.js';
import { ambassadorModuleOptions, isAmbassadorModule, toHTTPModule, } from './ambassador-modules.js';
import { API_URL, PUBLIC_METADATA_KEY } from './common.js';
import { FetchErrorResponse } from './fetch-error.js';
import { getDefaultContentHeader, isObject } from './helpers.js';
import { buildHostModule, isHostModule } from './host-modules.js';
import { buildRESTDescriptor } from './rest-modules.js';
import { FetchErrorResponse } from './fetch-error.js';
import { buildEventDefinition, isEventHandlerModule, } from './event-handlers-modules.js';
export function createClient(config) {
const _headers = config.headers || { Authorization: '' };
const eventHandlers = new Map();
const authStrategy = config.auth ||

@@ -33,3 +35,10 @@ {

const use = (modules, metadata) => {
if (isHostModule(modules) && config.host) {
if (isEventHandlerModule(modules)) {
return buildEventDefinition(modules, (eventType, handler) => {
const handlers = eventHandlers.get(eventType) ?? [];
handlers.push(handler);
eventHandlers.set(eventType, handlers);
});
}
else if (isHostModule(modules) && config.host) {
return buildHostModule(modules, config.host);

@@ -128,8 +137,16 @@ }

const payload = JSON.parse(parsedDecoded.data);
if (opts.expectedEvents.length > 0 &&
!opts.expectedEvents.some(({ type }) => type === eventType)) {
throw new Error(`Unexpected event type: ${eventType}. Expected one of: ${opts.expectedEvents
const allExpectedEvents = [
...opts.expectedEvents,
...Array.from(eventHandlers.keys()).map((type) => ({ type })),
];
if (allExpectedEvents.length > 0 &&
!allExpectedEvents.some(({ type }) => type === eventType)) {
throw new Error(`Unexpected event type: ${eventType}. Expected one of: ${allExpectedEvents
.map((x) => x.type)
.join(', ')}`);
}
const handlers = eventHandlers.get(eventType) ?? [];
await Promise.all(handlers.map((handler) => handler(payload, {
instanceId,
})));
return {

@@ -136,0 +153,0 @@ instanceId,

{
"name": "@wix/api-client",
"version": "1.7.14",
"version": "1.8.0",
"license": "UNLICENSED",

@@ -24,6 +24,6 @@ "main": "build/index.js",

"@babel/runtime": "^7.23.2",
"@wix/identity": "^1.0.74",
"@wix/image-kit": "^1.62.0",
"@wix/redirects": "^1.0.36",
"@wix/sdk-types": "^1.5.11",
"@wix/identity": "^1.0.78",
"@wix/image-kit": "^1.64.0",
"@wix/redirects": "^1.0.41",
"@wix/sdk-types": "^1.6.0",
"crypto-js": "^4.2.0",

@@ -36,4 +36,4 @@ "jose": "^5.2.1",

"devDependencies": {
"@wix/metro-runtime": "^1.1669.0",
"@wix/sdk": "1.7.14"
"@wix/metro-runtime": "^1.1677.0",
"@wix/sdk": "1.8.0"
},

@@ -51,3 +51,3 @@ "wix": {

},
"falconPackageHash": "e2d57cb173f20f0e9c373ee3cba8a82fae77409ecf4fe56108c89ea5"
"falconPackageHash": "e1e40f021c18a2bfb030619a30deafbd7820895b10e698c62985e952"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc