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

@wix/redirects_redirects

Package Overview
Dependencies
Maintainers
0
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wix/redirects_redirects - npm Package Compare versions

Comparing version 1.0.29 to 1.0.30

build/cjs/context.js.map

1

build/cjs/context.js

@@ -18,1 +18,2 @@ "use strict";

__exportStar(require("./src/headless-v1-redirect-session-redirects.context"), exports);
//# sourceMappingURL=context.js.map

@@ -18,1 +18,2 @@ "use strict";

__exportStar(require("./src/headless-v1-redirect-session-redirects.context"), exports);
//# sourceMappingURL=index.js.map

@@ -18,1 +18,2 @@ "use strict";

__exportStar(require("./src/headless-v1-redirect-session-redirects.universal"), exports);
//# sourceMappingURL=index.typings.js.map

@@ -18,1 +18,2 @@ "use strict";

__exportStar(require("./src/headless-v1-redirect-session-redirects.meta"), exports);
//# sourceMappingURL=meta.js.map

4

build/cjs/src/headless-v1-redirect-session-redirects.context.d.ts
import { createRedirectSession as publicCreateRedirectSession } from './headless-v1-redirect-session-redirects.public';
import { createEventModule } from '@wix/sdk-runtime/event-definition-modules';
import { BuildRESTFunction } from '@wix/sdk-types';
import { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
import { onRedirectSessionCreated as publicOnRedirectSessionCreated } from './headless-v1-redirect-session-redirects.public';
export declare const createRedirectSession: BuildRESTFunction<typeof publicCreateRedirectSession> & typeof publicCreateRedirectSession;
export declare const createRedirectSession: MaybeContext<BuildRESTFunction<typeof publicCreateRedirectSession> & typeof publicCreateRedirectSession>;
export { publicOnRedirectSessionCreated };

@@ -7,0 +7,0 @@ export type _publicOnRedirectSessionCreatedType = typeof publicOnRedirectSessionCreated;

@@ -20,1 +20,2 @@ "use strict";

Object.defineProperty(exports, "WebhookIdentityType", { enumerable: true, get: function () { return headless_v1_redirect_session_redirects_universal_1.WebhookIdentityType; } });
//# sourceMappingURL=headless-v1-redirect-session-redirects.context.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createRedirectSession = void 0;
const metro_runtime_1 = require("@wix/metro-runtime");
const rest_modules_1 = require("@wix/sdk-runtime/rest-modules");
function resolveWixHeadlessV1RedirectSessionServiceUrl(opts) {

@@ -24,4 +24,5 @@ const domainToMappings = {

};
return (0, metro_runtime_1.resolveUrl)(Object.assign(opts, { domainToMappings }));
return (0, rest_modules_1.resolveUrl)(Object.assign(opts, { domainToMappings }));
}
const PACKAGE_NAME = '@wix/redirects_redirects';
/**

@@ -46,2 +47,3 @@ * Creates a URL for redirecting a visitor from an external client site to a Wix page for Wix-managed functionality.

methodFqn: 'wix.headless.v1.RedirectSessionService.CreateRedirectSession',
packageName: PACKAGE_NAME,
url: resolveWixHeadlessV1RedirectSessionServiceUrl({

@@ -59,1 +61,2 @@ protoPath: '/v1/redirect-session',

exports.createRedirectSession = createRedirectSession;
//# sourceMappingURL=headless-v1-redirect-session-redirects.http.js.map

@@ -47,1 +47,2 @@ "use strict";

exports.createRedirectSession = createRedirectSession;
//# sourceMappingURL=headless-v1-redirect-session-redirects.meta.js.map

@@ -30,1 +30,2 @@ "use strict";

Object.defineProperty(exports, "WebhookIdentityType", { enumerable: true, get: function () { return headless_v1_redirect_session_redirects_universal_2.WebhookIdentityType; } });
//# sourceMappingURL=headless-v1-redirect-session-redirects.public.js.map

@@ -187,2 +187,4 @@ /** Information for redirecting a visitor from an external Wix Headless client site to a Wix page for Wix-managed functionality. */

formattedAddress?: string | null;
/** The full translated address of this location. */
formattedAddressTranslated?: string | null;
/**

@@ -560,3 +562,3 @@ * Location type.

/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
eventTime?: Date;
eventTime?: Date | null;
/**

@@ -592,3 +594,3 @@ * Whether the event was triggered as a result of a privacy regulation application

export interface RestoreInfo {
deletedDate?: Date;
deletedDate?: Date | null;
}

@@ -595,0 +597,0 @@ export interface EntityUpdatedEvent {

@@ -71,1 +71,2 @@ "use strict";

})(WebhookIdentityType || (exports.WebhookIdentityType = WebhookIdentityType = {}));
//# sourceMappingURL=headless-v1-redirect-session-redirects.types.js.map

@@ -185,2 +185,4 @@ /** Information for redirecting a visitor from an external Wix Headless client site to a Wix page for Wix-managed functionality. */

formattedAddress?: string | null;
/** The full translated address of this location. */
formattedAddressTranslated?: string | null;
/**

@@ -557,3 +559,3 @@ * Location type.

/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
eventTime?: Date;
eventTime?: Date | null;
/**

@@ -587,3 +589,3 @@ * Whether the event was triggered as a result of a privacy regulation application

export interface RestoreInfo {
deletedDate?: Date;
deletedDate?: Date | null;
}

@@ -685,3 +687,3 @@ export interface EntityUpdatedEvent {

/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
eventTime?: Date;
eventTime?: Date | null;
/**

@@ -688,0 +690,0 @@ * Whether the event was triggered as a result of a privacy regulation application

@@ -168,1 +168,2 @@ "use strict";

exports.createRedirectSession = createRedirectSession;
//# sourceMappingURL=headless-v1-redirect-session-redirects.universal.js.map
export * from './src/headless-v1-redirect-session-redirects.context';
//# sourceMappingURL=context.js.map
export * from './src/headless-v1-redirect-session-redirects.context';
//# sourceMappingURL=index.js.map
export * from './src/headless-v1-redirect-session-redirects.universal';
//# sourceMappingURL=index.typings.js.map
export * from './src/headless-v1-redirect-session-redirects.meta';
//# sourceMappingURL=meta.js.map
import { createRedirectSession as publicCreateRedirectSession } from './headless-v1-redirect-session-redirects.public';
import { createEventModule } from '@wix/sdk-runtime/event-definition-modules';
import { BuildRESTFunction } from '@wix/sdk-types';
import { BuildRESTFunction, MaybeContext } from '@wix/sdk-types';
import { onRedirectSessionCreated as publicOnRedirectSessionCreated } from './headless-v1-redirect-session-redirects.public';
export declare const createRedirectSession: BuildRESTFunction<typeof publicCreateRedirectSession> & typeof publicCreateRedirectSession;
export declare const createRedirectSession: MaybeContext<BuildRESTFunction<typeof publicCreateRedirectSession> & typeof publicCreateRedirectSession>;
export { publicOnRedirectSessionCreated };

@@ -7,0 +7,0 @@ export type _publicOnRedirectSessionCreatedType = typeof publicOnRedirectSessionCreated;

@@ -5,3 +5,3 @@ import { createRedirectSession as publicCreateRedirectSession } from './headless-v1-redirect-session-redirects.public';

import { onRedirectSessionCreated as publicOnRedirectSessionCreated } from './headless-v1-redirect-session-redirects.public';
export const createRedirectSession = createRESTModule(publicCreateRedirectSession);
export const createRedirectSession = /*#__PURE__*/ createRESTModule(publicCreateRedirectSession);
export { publicOnRedirectSessionCreated };

@@ -11,1 +11,2 @@ /** */

export { LocationType, Prompt, MembersAccountSection, AttachPagesResponseStatus, CallbackType, Status, WebhookIdentityType, } from './headless-v1-redirect-session-redirects.universal';
//# sourceMappingURL=headless-v1-redirect-session-redirects.context.js.map

@@ -1,2 +0,2 @@

import { resolveUrl } from '@wix/metro-runtime';
import { resolveUrl } from '@wix/sdk-runtime/rest-modules';
function resolveWixHeadlessV1RedirectSessionServiceUrl(opts) {

@@ -23,2 +23,3 @@ const domainToMappings = {

}
const PACKAGE_NAME = '@wix/redirects_redirects';
/**

@@ -43,2 +44,3 @@ * Creates a URL for redirecting a visitor from an external client site to a Wix page for Wix-managed functionality.

methodFqn: 'wix.headless.v1.RedirectSessionService.CreateRedirectSession',
packageName: PACKAGE_NAME,
url: resolveWixHeadlessV1RedirectSessionServiceUrl({

@@ -55,1 +57,2 @@ protoPath: '/v1/redirect-session',

}
//# sourceMappingURL=headless-v1-redirect-session-redirects.http.js.map

@@ -20,1 +20,2 @@ import * as ambassadorWixHeadlessV1RedirectSession from './headless-v1-redirect-session-redirects.http';

}
//# sourceMappingURL=headless-v1-redirect-session-redirects.meta.js.map

@@ -19,1 +19,2 @@ import { renameKeysFromRESTResponseToSDKResponse } from '@wix/sdk-runtime/rename-all-nested-keys';

export { AttachPagesResponseStatus, CallbackType, LocationType, MembersAccountSection, Prompt, Status, WebhookIdentityType, } from './headless-v1-redirect-session-redirects.universal';
//# sourceMappingURL=headless-v1-redirect-session-redirects.public.js.map

@@ -187,2 +187,4 @@ /** Information for redirecting a visitor from an external Wix Headless client site to a Wix page for Wix-managed functionality. */

formattedAddress?: string | null;
/** The full translated address of this location. */
formattedAddressTranslated?: string | null;
/**

@@ -560,3 +562,3 @@ * Location type.

/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
eventTime?: Date;
eventTime?: Date | null;
/**

@@ -592,3 +594,3 @@ * Whether the event was triggered as a result of a privacy regulation application

export interface RestoreInfo {
deletedDate?: Date;
deletedDate?: Date | null;
}

@@ -595,0 +597,0 @@ export interface EntityUpdatedEvent {

@@ -68,1 +68,2 @@ export var LocationType;

})(WebhookIdentityType || (WebhookIdentityType = {}));
//# sourceMappingURL=headless-v1-redirect-session-redirects.types.js.map

@@ -185,2 +185,4 @@ /** Information for redirecting a visitor from an external Wix Headless client site to a Wix page for Wix-managed functionality. */

formattedAddress?: string | null;
/** The full translated address of this location. */
formattedAddressTranslated?: string | null;
/**

@@ -557,3 +559,3 @@ * Location type.

/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
eventTime?: Date;
eventTime?: Date | null;
/**

@@ -587,3 +589,3 @@ * Whether the event was triggered as a result of a privacy regulation application

export interface RestoreInfo {
deletedDate?: Date;
deletedDate?: Date | null;
}

@@ -685,3 +687,3 @@ export interface EntityUpdatedEvent {

/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
eventTime?: Date;
eventTime?: Date | null;
/**

@@ -688,0 +690,0 @@ * Whether the event was triggered as a result of a privacy regulation application

@@ -141,1 +141,2 @@ import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';

}
//# sourceMappingURL=headless-v1-redirect-session-redirects.universal.js.map
{
"name": "@wix/redirects_redirects",
"version": "1.0.29",
"version": "1.0.30",
"publishConfig": {

@@ -8,2 +8,5 @@ "registry": "https://registry.npmjs.org/",

},
"keywords": [
"wix-sdk-module=backend,page,public"
],
"sideEffects": false,

@@ -22,6 +25,4 @@ "module": "build/es/index.js",

"dependencies": {
"@wix/metro-runtime": "^1.1792.0",
"@wix/motion-edm-autogen-query-wrapper": "^1.0.37",
"@wix/sdk-runtime": "^0.3.14",
"@wix/sdk-types": "^1.9.2"
"@wix/sdk-runtime": "^0.3.22",
"@wix/sdk-types": "^1.12.4"
},

@@ -50,3 +51,3 @@ "devDependencies": {

},
"falconPackageHash": "4e14e5d64807b6e438687bb82cb0b60069c4cc40fa784160f5d54829"
"falconPackageHash": "53e484ae9dd87c5a732ffe4e800c9a840496f9f3d4f33d53a66ee895"
}

@@ -0,1 +1,43 @@

type HostModule<T, H extends Host> = {
__type: 'host';
create(host: H): T;
};
type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
type Host<Environment = unknown> = {
channel: {
observeState(callback: (props: unknown, environment: Environment) => unknown): {
disconnect: () => void;
} | Promise<{
disconnect: () => void;
}>;
};
environment?: Environment;
/**
* Optional name of the environment, use for logging
*/
name?: string;
/**
* Optional bast url to use for API requests, for example `www.wixapis.com`
*/
apiBaseUrl?: string;
/**
* Possible data to be provided by every host, for cross cutting concerns
* like internationalization, billing, etc.
*/
essentials?: {
/**
* The language of the currently viewed session
*/
language?: string;
/**
* The locale of the currently viewed session
*/
locale?: string;
/**
* Any headers that should be passed through to the API requests
*/
passThroughHeaders?: Record<string, string>;
};
};
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;

@@ -6,2 +48,3 @@ interface HttpClient {

wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
getActiveToken?: () => string | undefined;
}

@@ -39,2 +82,51 @@ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;

type ServicePluginMethodInput = {
request: any;
metadata: any;
};
type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
type ServicePluginMethodMetadata = {
name: string;
primaryHttpMappingPath: string;
transformations: {
fromREST: (...args: unknown[]) => ServicePluginMethodInput;
toREST: (...args: unknown[]) => unknown;
};
};
type ServicePluginDefinition<Contract extends ServicePluginContract> = {
__type: 'service-plugin-definition';
componentType: string;
methods: ServicePluginMethodMetadata[];
__contract: Contract;
};
declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
type RequestContext = {
isSSR: boolean;
host: string;
protocol?: string;
};
type ResponseTransformer = (data: any, headers?: any) => any;
/**
* Ambassador request options types are copied mostly from AxiosRequestConfig.
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
*/
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
type AmbassadorRequestOptions<T = any> = {
_?: T;
url?: string;
method?: Method;
params?: any;
data?: any;
transformResponse?: ResponseTransformer | ResponseTransformer[];
};
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
__isAmbassador: boolean;
};
type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
declare global {

@@ -47,2 +139,344 @@ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.

declare const emptyObjectSymbol: unique symbol;
/**
Represents a strictly empty plain object, the `{}` value.
When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
@example
```
import type {EmptyObject} from 'type-fest';
// The following illustrates the problem with `{}`.
const foo1: {} = {}; // Pass
const foo2: {} = []; // Pass
const foo3: {} = 42; // Pass
const foo4: {} = {a: 1}; // Pass
// With `EmptyObject` only the first case is valid.
const bar1: EmptyObject = {}; // Pass
const bar2: EmptyObject = 42; // Fail
const bar3: EmptyObject = []; // Fail
const bar4: EmptyObject = {a: 1}; // Fail
```
Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
@category Object
*/
type EmptyObject = {[emptyObjectSymbol]?: never};
/**
Returns a boolean for whether the two given types are equal.
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
Use-cases:
- If you want to make a conditional branch based on the result of a comparison of two types.
@example
```
import type {IsEqual} from 'type-fest';
// This type returns a boolean for whether the given array includes the given item.
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
type Includes<Value extends readonly any[], Item> =
Value extends readonly [Value[0], ...infer rest]
? IsEqual<Value[0], Item> extends true
? true
: Includes<rest, Item>
: false;
```
@category Type Guard
@category Utilities
*/
type IsEqual<A, B> =
(<G>() => G extends A ? 1 : 2) extends
(<G>() => G extends B ? 1 : 2)
? true
: false;
/**
Filter out keys from an object.
Returns `never` if `Exclude` is strictly equal to `Key`.
Returns `never` if `Key` extends `Exclude`.
Returns `Key` otherwise.
@example
```
type Filtered = Filter<'foo', 'foo'>;
//=> never
```
@example
```
type Filtered = Filter<'bar', string>;
//=> never
```
@example
```
type Filtered = Filter<'bar', 'foo'>;
//=> 'bar'
```
@see {Except}
*/
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
type ExceptOptions = {
/**
Disallow assigning non-specified properties.
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
@default false
*/
requireExactProps?: boolean;
};
/**
Create a type from an object type without certain keys.
We recommend setting the `requireExactProps` option to `true`.
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
@example
```
import type {Except} from 'type-fest';
type Foo = {
a: number;
b: string;
};
type FooWithoutA = Except<Foo, 'a'>;
//=> {b: string}
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
//=> errors: 'a' does not exist in type '{ b: string; }'
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
//=> {a: number} & Partial<Record<"b", never>>
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
```
@category Object
*/
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
} & (Options['requireExactProps'] extends true
? Partial<Record<KeysType, never>>
: {});
/**
Returns a boolean for whether the given type is `never`.
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
@link https://stackoverflow.com/a/53984913/10292952
@link https://www.zhenghao.io/posts/ts-never
Useful in type utilities, such as checking if something does not occur.
@example
```
import type {IsNever, And} from 'type-fest';
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
type AreStringsEqual<A extends string, B extends string> =
And<
IsNever<Exclude<A, B>> extends true ? true : false,
IsNever<Exclude<B, A>> extends true ? true : false
>;
type EndIfEqual<I extends string, O extends string> =
AreStringsEqual<I, O> extends true
? never
: void;
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
if (input === output) {
process.exit(0);
}
}
endIfEqual('abc', 'abc');
//=> never
endIfEqual('abc', '123');
//=> void
```
@category Type Guard
@category Utilities
*/
type IsNever<T> = [T] extends [never] ? true : false;
/**
An if-else-like type that resolves depending on whether the given type is `never`.
@see {@link IsNever}
@example
```
import type {IfNever} from 'type-fest';
type ShouldBeTrue = IfNever<never>;
//=> true
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
//=> 'bar'
```
@category Type Guard
@category Utilities
*/
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
);
/**
Extract the keys from a type where the value type of the key extends the given `Condition`.
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
@example
```
import type {ConditionalKeys} from 'type-fest';
interface Example {
a: string;
b: string | number;
c?: string;
d: {};
}
type StringKeysOnly = ConditionalKeys<Example, string>;
//=> 'a'
```
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
@example
```
import type {ConditionalKeys} from 'type-fest';
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
//=> 'a' | 'c'
```
@category Object
*/
type ConditionalKeys<Base, Condition> =
{
// Map through all the keys of the given base type.
[Key in keyof Base]-?:
// Pick only keys with types extending the given `Condition` type.
Base[Key] extends Condition
// Retain this key
// If the value for the key extends never, only include it if `Condition` also extends never
? IfNever<Base[Key], IfNever<Condition, Key, never>, Key>
// Discard this key since the condition fails.
: never;
// Convert the produced object into a union type of the keys which passed the conditional test.
}[keyof Base];
/**
Exclude keys from a shape that matches the given `Condition`.
This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties.
@example
```
import type {Primitive, ConditionalExcept} from 'type-fest';
class Awesome {
name: string;
successes: number;
failures: bigint;
run() {}
}
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
//=> {run: () => void}
```
@example
```
import type {ConditionalExcept} from 'type-fest';
interface Example {
a: string;
b: string | number;
c: () => void;
d: {};
}
type NonStringKeysOnly = ConditionalExcept<Example, string>;
//=> {b: string | number; c: () => void; d: {}}
```
@category Object
*/
type ConditionalExcept<Base, Condition> = Except<
Base,
ConditionalKeys<Base, Condition>
>;
/**
* Descriptors are objects that describe the API of a module, and the module
* can either be a REST module or a host module.
* This type is recursive, so it can describe nested modules.
*/
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
[key: string]: Descriptors | PublicMetadata | any;
};
/**
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
* and returns an object with the same structure, but with all descriptors replaced with their API.
* Any non-descriptor properties are removed from the returned object, including descriptors that
* do not match the given host (as they will not work with the given host).
*/
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
done: T;
recurse: T extends {
__type: typeof SERVICE_PLUGIN_ERROR_TYPE;
} ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition<any> ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
[Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
-1,
0,
1,
2,
3,
4,
5
][Depth]> : never;
}, EmptyObject>;
}[Depth extends -1 ? 'done' : 'recurse'];
type PublicMetadata = {
PACKAGE_NAME?: string;
};
declare global {
interface ContextualClient {
}
}
/**
* A type used to create concerete types from SDK descriptors in
* case a contextual client is available.
*/
type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
host: Host;
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
/** Information for redirecting a visitor from an external Wix Headless client site to a Wix page for Wix-managed functionality. */

@@ -232,2 +666,4 @@ interface RedirectSession {

formattedAddress?: string | null;
/** The full translated address of this location. */
formattedAddressTranslated?: string | null;
/**

@@ -604,3 +1040,3 @@ * Location type.

/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
eventTime?: Date;
eventTime?: Date | null;
/**

@@ -634,3 +1070,3 @@ * Whether the event was triggered as a result of a privacy regulation application

interface RestoreInfo {
deletedDate?: Date;
deletedDate?: Date | null;
}

@@ -732,3 +1168,3 @@ interface EntityUpdatedEvent {

/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
eventTime?: Date;
eventTime?: Date | null;
/**

@@ -806,3 +1242,3 @@ * Whether the event was triggered as a result of a privacy regulation application

declare const createRedirectSession: BuildRESTFunction<typeof createRedirectSession$1> & typeof createRedirectSession$1;
declare const createRedirectSession: MaybeContext<BuildRESTFunction<typeof createRedirectSession$1> & typeof createRedirectSession$1>;

@@ -809,0 +1245,0 @@ type _publicOnRedirectSessionCreatedType = typeof onRedirectSessionCreated$1;

@@ -0,1 +1,43 @@

type HostModule<T, H extends Host> = {
__type: 'host';
create(host: H): T;
};
type HostModuleAPI<T extends HostModule<any, any>> = T extends HostModule<infer U, any> ? U : never;
type Host<Environment = unknown> = {
channel: {
observeState(callback: (props: unknown, environment: Environment) => unknown): {
disconnect: () => void;
} | Promise<{
disconnect: () => void;
}>;
};
environment?: Environment;
/**
* Optional name of the environment, use for logging
*/
name?: string;
/**
* Optional bast url to use for API requests, for example `www.wixapis.com`
*/
apiBaseUrl?: string;
/**
* Possible data to be provided by every host, for cross cutting concerns
* like internationalization, billing, etc.
*/
essentials?: {
/**
* The language of the currently viewed session
*/
language?: string;
/**
* The locale of the currently viewed session
*/
locale?: string;
/**
* Any headers that should be passed through to the API requests
*/
passThroughHeaders?: Record<string, string>;
};
};
type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;

@@ -6,2 +48,3 @@ interface HttpClient {

wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
getActiveToken?: () => string | undefined;
}

@@ -39,2 +82,51 @@ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;

type ServicePluginMethodInput = {
request: any;
metadata: any;
};
type ServicePluginContract = Record<string, (payload: ServicePluginMethodInput) => unknown | Promise<unknown>>;
type ServicePluginMethodMetadata = {
name: string;
primaryHttpMappingPath: string;
transformations: {
fromREST: (...args: unknown[]) => ServicePluginMethodInput;
toREST: (...args: unknown[]) => unknown;
};
};
type ServicePluginDefinition<Contract extends ServicePluginContract> = {
__type: 'service-plugin-definition';
componentType: string;
methods: ServicePluginMethodMetadata[];
__contract: Contract;
};
declare function ServicePluginDefinition<Contract extends ServicePluginContract>(componentType: string, methods: ServicePluginMethodMetadata[]): ServicePluginDefinition<Contract>;
type BuildServicePluginDefinition<T extends ServicePluginDefinition<any>> = (implementation: T['__contract']) => void;
declare const SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
type RequestContext = {
isSSR: boolean;
host: string;
protocol?: string;
};
type ResponseTransformer = (data: any, headers?: any) => any;
/**
* Ambassador request options types are copied mostly from AxiosRequestConfig.
* They are copied and not imported to reduce the amount of dependencies (to reduce install time).
* https://github.com/axios/axios/blob/3f53eb6960f05a1f88409c4b731a40de595cb825/index.d.ts#L307-L315
*/
type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
type AmbassadorRequestOptions<T = any> = {
_?: T;
url?: string;
method?: Method;
params?: any;
data?: any;
transformResponse?: ResponseTransformer | ResponseTransformer[];
};
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & {
__isAmbassador: boolean;
};
type AmbassadorFunctionDescriptor<Request = any, Response = any> = AmbassadorFactory<Request, Response>;
type BuildAmbassadorFunction<T extends AmbassadorFunctionDescriptor> = T extends AmbassadorFunctionDescriptor<infer Request, infer Response> ? (req: Request) => Promise<Response> : never;
declare global {

@@ -47,2 +139,344 @@ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.

declare const emptyObjectSymbol: unique symbol;
/**
Represents a strictly empty plain object, the `{}` value.
When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
@example
```
import type {EmptyObject} from 'type-fest';
// The following illustrates the problem with `{}`.
const foo1: {} = {}; // Pass
const foo2: {} = []; // Pass
const foo3: {} = 42; // Pass
const foo4: {} = {a: 1}; // Pass
// With `EmptyObject` only the first case is valid.
const bar1: EmptyObject = {}; // Pass
const bar2: EmptyObject = 42; // Fail
const bar3: EmptyObject = []; // Fail
const bar4: EmptyObject = {a: 1}; // Fail
```
Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
@category Object
*/
type EmptyObject = {[emptyObjectSymbol]?: never};
/**
Returns a boolean for whether the two given types are equal.
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
Use-cases:
- If you want to make a conditional branch based on the result of a comparison of two types.
@example
```
import type {IsEqual} from 'type-fest';
// This type returns a boolean for whether the given array includes the given item.
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
type Includes<Value extends readonly any[], Item> =
Value extends readonly [Value[0], ...infer rest]
? IsEqual<Value[0], Item> extends true
? true
: Includes<rest, Item>
: false;
```
@category Type Guard
@category Utilities
*/
type IsEqual<A, B> =
(<G>() => G extends A ? 1 : 2) extends
(<G>() => G extends B ? 1 : 2)
? true
: false;
/**
Filter out keys from an object.
Returns `never` if `Exclude` is strictly equal to `Key`.
Returns `never` if `Key` extends `Exclude`.
Returns `Key` otherwise.
@example
```
type Filtered = Filter<'foo', 'foo'>;
//=> never
```
@example
```
type Filtered = Filter<'bar', string>;
//=> never
```
@example
```
type Filtered = Filter<'bar', 'foo'>;
//=> 'bar'
```
@see {Except}
*/
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
type ExceptOptions = {
/**
Disallow assigning non-specified properties.
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
@default false
*/
requireExactProps?: boolean;
};
/**
Create a type from an object type without certain keys.
We recommend setting the `requireExactProps` option to `true`.
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
@example
```
import type {Except} from 'type-fest';
type Foo = {
a: number;
b: string;
};
type FooWithoutA = Except<Foo, 'a'>;
//=> {b: string}
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
//=> errors: 'a' does not exist in type '{ b: string; }'
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
//=> {a: number} & Partial<Record<"b", never>>
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
```
@category Object
*/
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {requireExactProps: false}> = {
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
} & (Options['requireExactProps'] extends true
? Partial<Record<KeysType, never>>
: {});
/**
Returns a boolean for whether the given type is `never`.
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
@link https://stackoverflow.com/a/53984913/10292952
@link https://www.zhenghao.io/posts/ts-never
Useful in type utilities, such as checking if something does not occur.
@example
```
import type {IsNever, And} from 'type-fest';
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
type AreStringsEqual<A extends string, B extends string> =
And<
IsNever<Exclude<A, B>> extends true ? true : false,
IsNever<Exclude<B, A>> extends true ? true : false
>;
type EndIfEqual<I extends string, O extends string> =
AreStringsEqual<I, O> extends true
? never
: void;
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
if (input === output) {
process.exit(0);
}
}
endIfEqual('abc', 'abc');
//=> never
endIfEqual('abc', '123');
//=> void
```
@category Type Guard
@category Utilities
*/
type IsNever<T> = [T] extends [never] ? true : false;
/**
An if-else-like type that resolves depending on whether the given type is `never`.
@see {@link IsNever}
@example
```
import type {IfNever} from 'type-fest';
type ShouldBeTrue = IfNever<never>;
//=> true
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
//=> 'bar'
```
@category Type Guard
@category Utilities
*/
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
);
/**
Extract the keys from a type where the value type of the key extends the given `Condition`.
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
@example
```
import type {ConditionalKeys} from 'type-fest';
interface Example {
a: string;
b: string | number;
c?: string;
d: {};
}
type StringKeysOnly = ConditionalKeys<Example, string>;
//=> 'a'
```
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
@example
```
import type {ConditionalKeys} from 'type-fest';
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
//=> 'a' | 'c'
```
@category Object
*/
type ConditionalKeys<Base, Condition> =
{
// Map through all the keys of the given base type.
[Key in keyof Base]-?:
// Pick only keys with types extending the given `Condition` type.
Base[Key] extends Condition
// Retain this key
// If the value for the key extends never, only include it if `Condition` also extends never
? IfNever<Base[Key], IfNever<Condition, Key, never>, Key>
// Discard this key since the condition fails.
: never;
// Convert the produced object into a union type of the keys which passed the conditional test.
}[keyof Base];
/**
Exclude keys from a shape that matches the given `Condition`.
This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties.
@example
```
import type {Primitive, ConditionalExcept} from 'type-fest';
class Awesome {
name: string;
successes: number;
failures: bigint;
run() {}
}
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
//=> {run: () => void}
```
@example
```
import type {ConditionalExcept} from 'type-fest';
interface Example {
a: string;
b: string | number;
c: () => void;
d: {};
}
type NonStringKeysOnly = ConditionalExcept<Example, string>;
//=> {b: string | number; c: () => void; d: {}}
```
@category Object
*/
type ConditionalExcept<Base, Condition> = Except<
Base,
ConditionalKeys<Base, Condition>
>;
/**
* Descriptors are objects that describe the API of a module, and the module
* can either be a REST module or a host module.
* This type is recursive, so it can describe nested modules.
*/
type Descriptors = RESTFunctionDescriptor | AmbassadorFunctionDescriptor | HostModule<any, any> | EventDefinition<any> | ServicePluginDefinition<any> | {
[key: string]: Descriptors | PublicMetadata | any;
};
/**
* This type takes in a descriptors object of a certain Host (including an `unknown` host)
* and returns an object with the same structure, but with all descriptors replaced with their API.
* Any non-descriptor properties are removed from the returned object, including descriptors that
* do not match the given host (as they will not work with the given host).
*/
type BuildDescriptors<T extends Descriptors, H extends Host<any> | undefined, Depth extends number = 5> = {
done: T;
recurse: T extends {
__type: typeof SERVICE_PLUGIN_ERROR_TYPE;
} ? never : T extends AmbassadorFunctionDescriptor ? BuildAmbassadorFunction<T> : T extends RESTFunctionDescriptor ? BuildRESTFunction<T> : T extends EventDefinition<any> ? BuildEventDefinition<T> : T extends ServicePluginDefinition<any> ? BuildServicePluginDefinition<T> : T extends HostModule<any, any> ? HostModuleAPI<T> : ConditionalExcept<{
[Key in keyof T]: T[Key] extends Descriptors ? BuildDescriptors<T[Key], H, [
-1,
0,
1,
2,
3,
4,
5
][Depth]> : never;
}, EmptyObject>;
}[Depth extends -1 ? 'done' : 'recurse'];
type PublicMetadata = {
PACKAGE_NAME?: string;
};
declare global {
interface ContextualClient {
}
}
/**
* A type used to create concerete types from SDK descriptors in
* case a contextual client is available.
*/
type MaybeContext<T extends Descriptors> = globalThis.ContextualClient extends {
host: Host;
} ? BuildDescriptors<T, globalThis.ContextualClient['host']> : T;
/** Information for redirecting a visitor from an external Wix Headless client site to a Wix page for Wix-managed functionality. */

@@ -232,2 +666,4 @@ interface RedirectSession {

formattedAddress?: string | null;
/** The full translated address of this location. */
formattedAddressTranslated?: string | null;
/**

@@ -604,3 +1040,3 @@ * Location type.

/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
eventTime?: Date;
eventTime?: Date | null;
/**

@@ -634,3 +1070,3 @@ * Whether the event was triggered as a result of a privacy regulation application

interface RestoreInfo {
deletedDate?: Date;
deletedDate?: Date | null;
}

@@ -732,3 +1168,3 @@ interface EntityUpdatedEvent {

/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
eventTime?: Date;
eventTime?: Date | null;
/**

@@ -806,3 +1242,3 @@ * Whether the event was triggered as a result of a privacy regulation application

declare const createRedirectSession: BuildRESTFunction<typeof createRedirectSession$1> & typeof createRedirectSession$1;
declare const createRedirectSession: MaybeContext<BuildRESTFunction<typeof createRedirectSession$1> & typeof createRedirectSession$1>;

@@ -809,0 +1245,0 @@ type _publicOnRedirectSessionCreatedType = typeof onRedirectSessionCreated$1;

@@ -185,2 +185,4 @@ /** Information for redirecting a visitor from an external Wix Headless client site to a Wix page for Wix-managed functionality. */

formattedAddress?: string | null;
/** The full translated address of this location. */
formattedAddressTranslated?: string | null;
/**

@@ -557,3 +559,3 @@ * Location type.

/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
eventTime?: Date;
eventTime?: Date | null;
/**

@@ -587,3 +589,3 @@ * Whether the event was triggered as a result of a privacy regulation application

interface RestoreInfo {
deletedDate?: Date;
deletedDate?: Date | null;
}

@@ -685,3 +687,3 @@ interface EntityUpdatedEvent {

/** Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example: 2020-04-26T13:57:50.699Z */
eventTime?: Date;
eventTime?: Date | null;
/**

@@ -688,0 +690,0 @@ * Whether the event was triggered as a result of a privacy regulation application

@@ -187,2 +187,4 @@ /** Information for redirecting a visitor from an external Wix Headless client site to a Wix page for Wix-managed functionality. */

formattedAddress?: string | null;
/** The full translated address of this location. */
formattedAddressTranslated?: string | null;
/**

@@ -596,2 +598,4 @@ * Location type.

formattedAddress?: string | null;
/** The full translated address of this location. */
formattedAddressTranslated?: string | null;
/**

@@ -598,0 +602,0 @@ * Location type.

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