@shopify/app-bridge-core
Advanced tools
Comparing version 1.3.1-snapshot-20240805023429 to 1.4.0-snapshot-20240812165150
@@ -31,2 +31,2 @@ import { ClientApplication } from '../client/types'; | ||
export declare function unsubscribeActions(subscriptions: ActionSubscription[], defaultGroup: string, reassign?: boolean): void; | ||
export declare type ActionSetChildAction = ActionSet | ActionSetWithChildren; | ||
export type ActionSetChildAction = ActionSet | ActionSetWithChildren; |
@@ -28,6 +28,10 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -38,3 +42,4 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.unsubscribeActions = exports.ActionSetWithChildren = exports.ActionSet = void 0; | ||
exports.ActionSetWithChildren = exports.ActionSet = void 0; | ||
exports.unsubscribeActions = unsubscribeActions; | ||
var types_1 = require("../client/types"); | ||
@@ -55,5 +60,5 @@ var collection_1 = require("../util/collection"); | ||
if (!app) { | ||
Error_1.throwError(Error_1.Action.INVALID_ACTION, 'Missing required `app`'); | ||
(0, Error_1.throwError)(Error_1.Action.INVALID_ACTION, 'Missing required `app`'); | ||
} | ||
this.id = id || uuid_1.default(); | ||
this.id = id || (0, uuid_1.default)(); | ||
this.defaultGroup = group; | ||
@@ -70,3 +75,3 @@ var defaultSet = this.set; | ||
} | ||
return (_a = _this.app.hooks).run.apply(_a, __spreadArray([types_1.LifecycleHook.UpdateAction, defaultSet, _this], args)); | ||
return (_a = _this.app.hooks).run.apply(_a, __spreadArray([types_1.LifecycleHook.UpdateAction, defaultSet, _this], args, false)); | ||
}; | ||
@@ -109,3 +114,3 @@ } | ||
var subscriptionIndices = []; | ||
helper_1.forEachInEnum(Error_1.Action, function (eventNameSpace) { | ||
(0, helper_1.forEachInEnum)(Error_1.Action, function (eventNameSpace) { | ||
// Keep track of subscription index so we can call unsubscribe later | ||
@@ -119,3 +124,3 @@ // This ensure it will continue to work even when the subscription has been updated | ||
subscriptionsToRemove.forEach(function (toRemove) { | ||
collection_1.removeFromCollection(_this.subscriptions, toRemove, function (removed) { | ||
(0, collection_1.removeFromCollection)(_this.subscriptions, toRemove, function (removed) { | ||
removed.unsubscribe(); | ||
@@ -132,7 +137,7 @@ }); | ||
var eventNameSpace; | ||
if (Error_1.isErrorEventName(eventName)) { | ||
eventNameSpace = helper_1.getEventNameSpace(types_2.Group.Error, eventName, __assign(__assign({}, eventComponent), { type: '' })); | ||
if ((0, Error_1.isErrorEventName)(eventName)) { | ||
eventNameSpace = (0, helper_1.getEventNameSpace)(types_2.Group.Error, eventName, __assign(__assign({}, eventComponent), { type: '' })); | ||
} | ||
else { | ||
eventNameSpace = helper_1.getEventNameSpace(this.group, eventName, eventComponent); | ||
eventNameSpace = (0, helper_1.getEventNameSpace)(this.group, eventName, eventComponent); | ||
} | ||
@@ -225,6 +230,6 @@ var unsubscribe = this.app.subscribe(eventNameSpace, boundedCallback, component ? component.id : this.id); | ||
var _this = this; | ||
collection_1.removeFromCollection(this.children, this.getChild(id), function () { | ||
(0, collection_1.removeFromCollection)(this.children, this.getChild(id), function () { | ||
var toBeRemoved = _this.subscriptions.filter(function (subs) { return subs.component.id === id; }); | ||
toBeRemoved.forEach(function (toRemove) { | ||
collection_1.removeFromCollection(_this.subscriptions, toRemove, function (removed) { | ||
(0, collection_1.removeFromCollection)(_this.subscriptions, toRemove, function (removed) { | ||
removed.unsubscribe(); | ||
@@ -310,2 +315,1 @@ }); | ||
} | ||
exports.unsubscribeActions = unsubscribeActions; |
@@ -32,3 +32,3 @@ import { Group, MetaAction } from '../types'; | ||
} | ||
export declare type ResponsePayload = ExchangeRequiredPayload | FailedResponsePayload; | ||
export type ResponsePayload = ExchangeRequiredPayload | FailedResponsePayload; | ||
export declare function respond(payload?: ResponsePayload): RespondWithAuthCodeAction; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.respond = exports.Action = void 0; | ||
exports.Action = void 0; | ||
exports.respond = respond; | ||
var helper_1 = require("../helper"); | ||
@@ -10,5 +11,5 @@ var types_1 = require("../types"); | ||
Action["RESPOND"] = "APP::AUTH_CODE::RESPOND"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function respond(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -19,2 +20,1 @@ group: types_1.Group.AuthCode, | ||
} | ||
exports.respond = respond; |
@@ -35,3 +35,3 @@ import { ClientApplication } from '../../client/types'; | ||
} | ||
export declare type ButtonAction = ButtonUpdateAction | ClickAction | MetaAction; | ||
export type ButtonAction = ButtonUpdateAction | ClickAction | MetaAction; | ||
export declare function clickButton(group: string, component: Component, payload?: ClickPayload): ClickAction; | ||
@@ -38,0 +38,0 @@ export declare function update(group: string, component: Component, props: Payload): ButtonUpdateAction; |
@@ -29,3 +29,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Button = exports.update = exports.clickButton = exports.Style = exports.Icon = exports.Action = void 0; | ||
exports.Button = exports.Style = exports.Icon = exports.Action = void 0; | ||
exports.clickButton = clickButton; | ||
exports.update = update; | ||
var helper_1 = require("../helper"); | ||
@@ -38,14 +40,14 @@ var ActionSet_1 = require("../ActionSet"); | ||
Action["UPDATE"] = "UPDATE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
var Icon; | ||
(function (Icon) { | ||
Icon["Print"] = "print"; | ||
})(Icon = exports.Icon || (exports.Icon = {})); | ||
})(Icon || (exports.Icon = Icon = {})); | ||
var Style; | ||
(function (Style) { | ||
Style["Danger"] = "danger"; | ||
})(Style = exports.Style || (exports.Style = {})); | ||
})(Style || (exports.Style = Style = {})); | ||
function clickButton(group, component, payload) { | ||
var id = component.id; | ||
var action = helper_1.getEventNameSpace(group, Action.CLICK, component); | ||
var action = (0, helper_1.getEventNameSpace)(group, Action.CLICK, component); | ||
var buttonPayload = { | ||
@@ -55,13 +57,11 @@ id: id, | ||
}; | ||
return helper_1.actionWrapper({ type: action, group: group, payload: buttonPayload }); | ||
return (0, helper_1.actionWrapper)({ type: action, group: group, payload: buttonPayload }); | ||
} | ||
exports.clickButton = clickButton; | ||
function update(group, component, props) { | ||
var id = component.id; | ||
var label = props.label; | ||
var action = helper_1.getEventNameSpace(group, Action.UPDATE, component); | ||
var action = (0, helper_1.getEventNameSpace)(group, Action.UPDATE, component); | ||
var buttonPayload = __assign(__assign({}, props), { id: id, label: label }); | ||
return helper_1.actionWrapper({ type: action, group: group, payload: buttonPayload }); | ||
return (0, helper_1.actionWrapper)({ type: action, group: group, payload: buttonPayload }); | ||
} | ||
exports.update = update; | ||
var Button = /** @class */ (function (_super) { | ||
@@ -100,3 +100,3 @@ __extends(Button, _super); | ||
if (shouldUpdate === void 0) { shouldUpdate = true; } | ||
var mergedOptions = helper_1.getMergedProps(this.options, options); | ||
var mergedOptions = (0, helper_1.getMergedProps)(this.options, options); | ||
var label = mergedOptions.label, disabled = mergedOptions.disabled, icon = mergedOptions.icon, style = mergedOptions.style, loading = mergedOptions.loading, plain = mergedOptions.plain; | ||
@@ -103,0 +103,0 @@ this.label = label; |
@@ -25,3 +25,3 @@ import { ClientApplication } from '../../client/types'; | ||
} | ||
export declare type ButtonGroupAction = ButtonGroupUpdateAction | MetaAction; | ||
export type ButtonGroupAction = ButtonGroupUpdateAction | MetaAction; | ||
export declare function update(group: string, component: Component, props: Payload): ButtonGroupUpdateAction; | ||
@@ -28,0 +28,0 @@ export declare function isGroupedButton(options: ButtonGroup | object): options is ButtonGroup; |
@@ -29,3 +29,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.create = exports.ButtonGroup = exports.isGroupedButtonPayload = exports.isGroupedButton = exports.update = exports.Action = void 0; | ||
exports.ButtonGroup = exports.Action = void 0; | ||
exports.update = update; | ||
exports.isGroupedButton = isGroupedButton; | ||
exports.isGroupedButtonPayload = isGroupedButtonPayload; | ||
exports.create = create; | ||
var buttonHelper_1 = require("../buttonHelper"); | ||
@@ -38,7 +42,6 @@ var helper_1 = require("../helper"); | ||
Action["UPDATE"] = "UPDATE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function update(group, component, props) { | ||
return buttonActionWrapper(group, component, Action.UPDATE, props); | ||
} | ||
exports.update = update; | ||
function isGroupedButton(options) { | ||
@@ -48,3 +51,2 @@ var castOptions = options; | ||
} | ||
exports.isGroupedButton = isGroupedButton; | ||
function isGroupedButtonPayload(payload) { | ||
@@ -56,3 +58,2 @@ var castOptions = payload; | ||
} | ||
exports.isGroupedButtonPayload = isGroupedButtonPayload; | ||
var ButtonGroup = /** @class */ (function (_super) { | ||
@@ -90,3 +91,3 @@ __extends(ButtonGroup, _super); | ||
if (shouldUpdate === void 0) { shouldUpdate = true; } | ||
var mergedOptions = helper_1.getMergedProps(this.options, options); | ||
var mergedOptions = (0, helper_1.getMergedProps)(this.options, options); | ||
var label = mergedOptions.label, disabled = mergedOptions.disabled, buttons = mergedOptions.buttons, plain = mergedOptions.plain; | ||
@@ -119,3 +120,3 @@ this.label = label; | ||
var action = _a[_i]; | ||
updated = helper_1.updateActionFromPayload(action, newPayload); | ||
updated = (0, helper_1.updateActionFromPayload)(action, newPayload); | ||
if (updated) { | ||
@@ -130,3 +131,3 @@ break; | ||
ButtonGroup.prototype.getSingleButton = function (button) { | ||
return buttonHelper_1.getSingleButton(this, button, this.subgroups, this.updateButtons); | ||
return (0, buttonHelper_1.getSingleButton)(this, button, this.subgroups, this.updateButtons); | ||
}; | ||
@@ -140,3 +141,3 @@ ButtonGroup.prototype.getButtons = function (buttonOptions) { | ||
buttonOptions.forEach(function (button) { | ||
var singleButton = buttonHelper_1.getSingleButton(_this, button, _this.subgroups, _this.updateButtons); | ||
var singleButton = (0, buttonHelper_1.getSingleButton)(_this, button, _this.subgroups, _this.updateButtons); | ||
buttons.push(singleButton); | ||
@@ -153,9 +154,8 @@ }); | ||
} | ||
exports.create = create; | ||
function buttonActionWrapper(group, component, eventName, props, payload) { | ||
var id = component.id; | ||
var label = props.label; | ||
var action = helper_1.getEventNameSpace(group, eventName, component); | ||
var action = (0, helper_1.getEventNameSpace)(group, eventName, component); | ||
var buttonPayload = __assign(__assign({}, props), { id: id, label: label, payload: payload }); | ||
return helper_1.actionWrapper({ type: action, group: group, payload: buttonPayload }); | ||
return (0, helper_1.actionWrapper)({ type: action, group: group, payload: buttonPayload }); | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getGroupedButton = void 0; | ||
exports.getGroupedButton = getGroupedButton; | ||
var ButtonGroup_1 = require("./ButtonGroup"); | ||
@@ -11,2 +11,1 @@ function getGroupedButton(action, button, subgroups, updateCb) { | ||
} | ||
exports.getGroupedButton = getGroupedButton; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getSingleButton = void 0; | ||
exports.getSingleButton = getSingleButton; | ||
var Button_1 = require("./Button"); | ||
@@ -10,2 +10,1 @@ function getSingleButton(action, button, subgroups, updateCb) { | ||
} | ||
exports.getSingleButton = getSingleButton; |
@@ -160,3 +160,3 @@ import { ClientApplication } from '../../client/types'; | ||
} | ||
export declare type NoteAttributes = { | ||
export type NoteAttributes = { | ||
name: string; | ||
@@ -163,0 +163,0 @@ value: string; |
@@ -29,3 +29,19 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Cart = exports.setLineItemProperties = exports.removeLineItemDiscount = exports.setLineItemDiscount = exports.removeLineItem = exports.updateLineItem = exports.addLineItem = exports.removeProperties = exports.setProperties = exports.removeAllDiscounts = exports.setCodeDiscount = exports.setDiscount = exports.updateCustomerAddress = exports.addCustomerAddress = exports.setCustomer = exports.update = exports.fetch = exports.Action = void 0; | ||
exports.Cart = exports.Action = void 0; | ||
exports.fetch = fetch; | ||
exports.update = update; | ||
exports.setCustomer = setCustomer; | ||
exports.addCustomerAddress = addCustomerAddress; | ||
exports.updateCustomerAddress = updateCustomerAddress; | ||
exports.setDiscount = setDiscount; | ||
exports.setCodeDiscount = setCodeDiscount; | ||
exports.removeAllDiscounts = removeAllDiscounts; | ||
exports.setProperties = setProperties; | ||
exports.removeProperties = removeProperties; | ||
exports.addLineItem = addLineItem; | ||
exports.updateLineItem = updateLineItem; | ||
exports.removeLineItem = removeLineItem; | ||
exports.setLineItemDiscount = setLineItemDiscount; | ||
exports.removeLineItemDiscount = removeLineItemDiscount; | ||
exports.setLineItemProperties = setLineItemProperties; | ||
var helper_1 = require("../helper"); | ||
@@ -56,3 +72,3 @@ var ActionSet_1 = require("../ActionSet"); | ||
Action["REMOVE_LINE_ITEM_PROPERTIES"] = "APP::CART::REMOVE_LINE_ITEM_PROPERTIES"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
/** | ||
@@ -64,3 +80,3 @@ * Cart action | ||
if (payload === void 0) { payload = {}; } | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Cart, | ||
@@ -74,63 +90,47 @@ type: type, | ||
} | ||
exports.fetch = fetch; | ||
function update(payload) { | ||
return createCartAction(Action.UPDATE, payload); | ||
} | ||
exports.update = update; | ||
function setCustomer(payload) { | ||
return createCartAction(Action.SET_CUSTOMER, payload); | ||
} | ||
exports.setCustomer = setCustomer; | ||
function addCustomerAddress(payload) { | ||
return createCartAction(Action.ADD_CUSTOMER_ADDRESS, payload); | ||
} | ||
exports.addCustomerAddress = addCustomerAddress; | ||
function updateCustomerAddress(payload) { | ||
return createCartAction(Action.UPDATE_CUSTOMER_ADDRESS, payload); | ||
} | ||
exports.updateCustomerAddress = updateCustomerAddress; | ||
function setDiscount(payload) { | ||
return createCartAction(Action.SET_DISCOUNT, payload); | ||
} | ||
exports.setDiscount = setDiscount; | ||
function setCodeDiscount(payload) { | ||
return createCartAction(Action.SET_CODE_DISCOUNT, payload); | ||
} | ||
exports.setCodeDiscount = setCodeDiscount; | ||
function removeAllDiscounts(payload) { | ||
return createCartAction(Action.REMOVE_ALL_DISCOUNTS, payload); | ||
} | ||
exports.removeAllDiscounts = removeAllDiscounts; | ||
function setProperties(payload) { | ||
return createCartAction(Action.SET_PROPERTIES, payload); | ||
} | ||
exports.setProperties = setProperties; | ||
function removeProperties(payload) { | ||
return createCartAction(Action.REMOVE_PROPERTIES, payload); | ||
} | ||
exports.removeProperties = removeProperties; | ||
function addLineItem(payload) { | ||
return createCartAction(Action.ADD_LINE_ITEM, payload); | ||
} | ||
exports.addLineItem = addLineItem; | ||
function updateLineItem(payload) { | ||
return createCartAction(Action.UPDATE_LINE_ITEM, payload); | ||
} | ||
exports.updateLineItem = updateLineItem; | ||
function removeLineItem(payload) { | ||
return createCartAction(Action.REMOVE_LINE_ITEM, payload); | ||
} | ||
exports.removeLineItem = removeLineItem; | ||
function setLineItemDiscount(payload) { | ||
return createCartAction(Action.SET_LINE_ITEM_DISCOUNT, payload); | ||
} | ||
exports.setLineItemDiscount = setLineItemDiscount; | ||
function removeLineItemDiscount(payload) { | ||
return createCartAction(Action.REMOVE_LINE_ITEM_DISCOUNT, payload); | ||
} | ||
exports.removeLineItemDiscount = removeLineItemDiscount; | ||
function setLineItemProperties(payload) { | ||
return createCartAction(Action.SET_LINE_ITEM_PROPERTIES, payload); | ||
} | ||
exports.setLineItemProperties = setLineItemProperties; | ||
/** | ||
@@ -137,0 +137,0 @@ * Cart |
@@ -7,2 +7,2 @@ "use strict"; | ||
Action["INITIALIZE"] = "APP::CLIENT::INITIALIZE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); |
@@ -53,3 +53,3 @@ import { ClientApplication } from '../../client/types'; | ||
} | ||
export declare type ShowOptions = Pick<Options, 'fullWidth' | 'leaveConfirmationDisable'>; | ||
export type ShowOptions = Pick<Options, 'fullWidth' | 'leaveConfirmationDisable'>; | ||
export interface SaveActionOptions extends ContextAction { | ||
@@ -90,10 +90,10 @@ onAction?: () => void; | ||
get payload(): { | ||
fullWidth?: boolean | undefined; | ||
discardAction?: DiscardAction | undefined; | ||
saveAction?: ContextAction | undefined; | ||
leaveConfirmationDisable?: boolean | undefined; | ||
fullWidth?: boolean; | ||
discardAction?: DiscardAction; | ||
saveAction?: ContextAction; | ||
leaveConfirmationDisable?: boolean; | ||
/** | ||
* @deprecated as of 1.6.0 | ||
*/ | ||
message?: string | undefined; | ||
message?: string; | ||
id: string; | ||
@@ -100,0 +100,0 @@ }; |
@@ -29,3 +29,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ContextualSaveBar = exports.update = exports.discard = exports.save = exports.hide = exports.show = exports.Action = void 0; | ||
exports.ContextualSaveBar = exports.Action = void 0; | ||
exports.show = show; | ||
exports.hide = hide; | ||
exports.save = save; | ||
exports.discard = discard; | ||
exports.update = update; | ||
var helper_1 = require("../helper"); | ||
@@ -44,5 +49,5 @@ var ActionSet_1 = require("../ActionSet"); | ||
Action["UPDATE"] = "APP::CONTEXTUAL_SAVE_BAR::UPDATE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function createContextBarAction(action, payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.ContextualSaveBar, | ||
@@ -56,19 +61,14 @@ type: action, | ||
} | ||
exports.show = show; | ||
function hide(payload) { | ||
return createContextBarAction(Action.HIDE, payload); | ||
} | ||
exports.hide = hide; | ||
function save(payload) { | ||
return createContextBarAction(Action.SAVE, payload); | ||
} | ||
exports.save = save; | ||
function discard(payload) { | ||
return createContextBarAction(Action.DISCARD, payload); | ||
} | ||
exports.discard = discard; | ||
function update(payload) { | ||
return createContextBarAction(Action.UPDATE, payload); | ||
} | ||
exports.update = update; | ||
/** | ||
@@ -102,3 +102,3 @@ * ContextualSaveBar action set | ||
if (shouldUpdate === void 0) { shouldUpdate = true; } | ||
var mergedOptions = helper_1.getMergedProps(this.options, options); | ||
var mergedOptions = (0, helper_1.getMergedProps)(this.options, options); | ||
this.options = mergedOptions; | ||
@@ -105,0 +105,0 @@ if (shouldUpdate) { |
@@ -26,3 +26,3 @@ import { MetaAction, AnyAction } from '../types'; | ||
} | ||
export declare type Payload = MetaAction | AnyAction; | ||
export type Payload = MetaAction | AnyAction; | ||
export declare class AppBridgeError extends Error { | ||
@@ -29,0 +29,0 @@ message: string; |
@@ -18,3 +18,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.permissionAction = exports.isErrorEventName = exports.throwError = exports.invalidOriginAction = exports.fromAction = exports.AppBridgeError = exports.AppActionType = exports.Action = void 0; | ||
exports.AppBridgeError = exports.AppActionType = exports.Action = void 0; | ||
exports.fromAction = fromAction; | ||
exports.invalidOriginAction = invalidOriginAction; | ||
exports.throwError = throwError; | ||
exports.isErrorEventName = isErrorEventName; | ||
exports.permissionAction = permissionAction; | ||
var types_1 = require("../types"); | ||
@@ -36,3 +41,3 @@ var helper_1 = require("../helper"); | ||
Action["INVALID_ORIGIN"] = "APP::ERROR::INVALID_ORIGIN"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
// Errors thrown in response to app setup | ||
@@ -50,3 +55,3 @@ var AppActionType; | ||
AppActionType["MISSING_HISTORY_BLOCK"] = "APP::APP_ERROR::MISSING_HISTORY_BLOCK"; | ||
})(AppActionType = exports.AppActionType || (exports.AppActionType = {})); | ||
})(AppActionType || (exports.AppActionType = AppActionType = {})); | ||
var AppBridgeError = /** @class */ (function (_super) { | ||
@@ -71,3 +76,3 @@ __extends(AppBridgeError, _super); | ||
function fromAction(message, type, action) { | ||
var errorMessage = message ? type + ": " + message : type; | ||
var errorMessage = message ? "".concat(type, ": ").concat(message) : type; | ||
var error = new AppBridgeError(errorMessage); | ||
@@ -78,5 +83,4 @@ error.action = action; | ||
} | ||
exports.fromAction = fromAction; | ||
function invalidOriginAction(message) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Error, | ||
@@ -90,3 +94,2 @@ payload: { | ||
} | ||
exports.invalidOriginAction = invalidOriginAction; | ||
function throwError() { | ||
@@ -109,11 +112,9 @@ var args = []; | ||
} | ||
exports.throwError = throwError; | ||
function isErrorEventName(eventName) { | ||
var match = helper_1.findMatchInEnum(Action, eventName); | ||
var match = (0, helper_1.findMatchInEnum)(Action, eventName); | ||
return typeof match === 'string'; | ||
} | ||
exports.isErrorEventName = isErrorEventName; | ||
function errorActionWrapperWithId(type, action, message) { | ||
var castPayload = action.payload; | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
type: type, | ||
@@ -132,2 +133,1 @@ group: types_1.Group.Error, | ||
} | ||
exports.permissionAction = permissionAction; |
@@ -8,3 +8,3 @@ import { ActionSet } from '../ActionSet'; | ||
*/ | ||
export declare type FeaturesAction = MetaAction | AnyAction; | ||
export type FeaturesAction = MetaAction | AnyAction; | ||
/** | ||
@@ -11,0 +11,0 @@ * A set of Actions for Updating, Requesting Features of AppBridge |
@@ -58,3 +58,3 @@ "use strict"; | ||
Features.prototype.dispatchFeaturesAction = function (type, payload) { | ||
this.app.dispatch(helper_1.actionWrapper({ | ||
this.app.dispatch((0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Features, | ||
@@ -61,0 +61,0 @@ type: type, |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -16,2 +16,2 @@ "use strict"; | ||
Action["REQUEST_UPDATE"] = "APP::FEATURES::REQUEST::UPDATE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); |
@@ -29,3 +29,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.create = exports.FeedbackModal = exports.close = exports.open = exports.Action = void 0; | ||
exports.FeedbackModal = exports.Action = void 0; | ||
exports.open = open; | ||
exports.close = close; | ||
exports.create = create; | ||
var helper_1 = require("../helper"); | ||
@@ -42,5 +45,5 @@ var ActionSet_1 = require("../ActionSet"); | ||
Action["CLOSE"] = "APP::FEEDBACK_MODAL::CLOSE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function open(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.FeedbackModal, | ||
@@ -51,5 +54,4 @@ payload: payload, | ||
} | ||
exports.open = open; | ||
function close(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.FeedbackModal, | ||
@@ -60,3 +62,2 @@ payload: payload, | ||
} | ||
exports.close = close; | ||
/** | ||
@@ -88,3 +89,3 @@ * FeedbackModal action set | ||
FeedbackModal.prototype.set = function (options) { | ||
this.options = helper_1.getMergedProps(this.options, options); | ||
this.options = (0, helper_1.getMergedProps)(this.options, options); | ||
return this; | ||
@@ -122,2 +123,1 @@ }; | ||
} | ||
exports.create = create; |
@@ -18,3 +18,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Fullscreen = exports.exit = exports.enter = exports.Action = void 0; | ||
exports.Fullscreen = exports.Action = void 0; | ||
exports.enter = enter; | ||
exports.exit = exit; | ||
var helper_1 = require("../helper"); | ||
@@ -33,5 +35,5 @@ var ActionSet_1 = require("../ActionSet"); | ||
Action["EXIT"] = "APP::FULLSCREEN::EXIT"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function enter() { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Fullscreen, | ||
@@ -41,5 +43,4 @@ type: Action.ENTER, | ||
} | ||
exports.enter = enter; | ||
function exit() { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Fullscreen, | ||
@@ -49,3 +50,2 @@ type: Action.EXIT, | ||
} | ||
exports.exit = exit; | ||
/** | ||
@@ -80,3 +80,3 @@ * Fullscreen action set | ||
Fullscreen.prototype.dispatch = function (action) { | ||
this.app.dispatch(helper_1.actionWrapper({ | ||
this.app.dispatch((0, helper_1.actionWrapper)({ | ||
group: this.group, | ||
@@ -83,0 +83,0 @@ type: action, |
@@ -6,3 +6,11 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.updateActionFromPayload = exports.isValidOptionalString = exports.isValidOptionalNumber = exports.forEachInEnum = exports.getMergedProps = exports.findMatchInEnum = exports.getEventNameSpace = exports.NonSnakeCaseGroup = exports.actionWrapper = void 0; | ||
exports.NonSnakeCaseGroup = void 0; | ||
exports.actionWrapper = actionWrapper; | ||
exports.getEventNameSpace = getEventNameSpace; | ||
exports.findMatchInEnum = findMatchInEnum; | ||
exports.getMergedProps = getMergedProps; | ||
exports.forEachInEnum = forEachInEnum; | ||
exports.isValidOptionalNumber = isValidOptionalNumber; | ||
exports.isValidOptionalString = isValidOptionalString; | ||
exports.updateActionFromPayload = updateActionFromPayload; | ||
var merge_1 = __importDefault(require("./merge")); | ||
@@ -14,3 +22,2 @@ var constants_1 = require("./constants"); | ||
} | ||
exports.actionWrapper = actionWrapper; | ||
exports.NonSnakeCaseGroup = [ | ||
@@ -41,3 +48,3 @@ types_1.Group.AuthCode, | ||
return value.replace(/([A-Z])/g, function (matcher, _val, index) { | ||
return "" + (index === 0 ? '' : '_') + matcher[0].toLowerCase(); | ||
return "".concat(index === 0 ? '' : '_').concat(matcher[0].toLowerCase()); | ||
}); | ||
@@ -63,3 +70,3 @@ } | ||
function getEventNameSpace(group, eventName, component) { | ||
if (eventName.startsWith("" + constants_1.PREFIX + constants_1.SEPARATOR)) { | ||
if (eventName.startsWith("".concat(constants_1.PREFIX).concat(constants_1.SEPARATOR))) { | ||
return eventName; | ||
@@ -73,15 +80,14 @@ } | ||
subgroups_1.forEach(function (subgroup, index) { | ||
eventNameSpace += "" + subgroup.toUpperCase() + (index < subgroups_1.length - 1 ? constants_1.SEPARATOR : ''); | ||
eventNameSpace += "".concat(subgroup.toUpperCase()).concat(index < subgroups_1.length - 1 ? constants_1.SEPARATOR : ''); | ||
}); | ||
} | ||
if (type !== group && type) { | ||
eventNameSpace += "" + (eventNameSpace.length > 0 ? constants_1.SEPARATOR : '') + type.toUpperCase(); | ||
eventNameSpace += "".concat(eventNameSpace.length > 0 ? constants_1.SEPARATOR : '').concat(type.toUpperCase()); | ||
} | ||
} | ||
if (eventNameSpace) { | ||
eventNameSpace += "" + (eventNameSpace.length > 0 ? constants_1.SEPARATOR : '') + eventName.toUpperCase(); | ||
eventNameSpace += "".concat(eventNameSpace.length > 0 ? constants_1.SEPARATOR : '').concat(eventName.toUpperCase()); | ||
} | ||
return "" + constants_1.PREFIX + constants_1.SEPARATOR + eventNameSpace; | ||
return "".concat(constants_1.PREFIX).concat(constants_1.SEPARATOR).concat(eventNameSpace); | ||
} | ||
exports.getEventNameSpace = getEventNameSpace; | ||
function findMatchInEnum(types, lookup) { | ||
@@ -93,5 +99,4 @@ var match = Object.keys(types).find(function (key) { | ||
} | ||
exports.findMatchInEnum = findMatchInEnum; | ||
function getMergedProps(props, newProps) { | ||
var merged = merge_1.default(props, newProps); | ||
var merged = (0, merge_1.default)(props, newProps); | ||
if (!merged) { | ||
@@ -104,3 +109,2 @@ // tslint:disable-next-line:prefer-object-spread | ||
} | ||
exports.getMergedProps = getMergedProps; | ||
function forEachInEnum(types, callback) { | ||
@@ -111,11 +115,8 @@ Object.keys(types).forEach(function (key) { | ||
} | ||
exports.forEachInEnum = forEachInEnum; | ||
function isValidOptionalNumber(value) { | ||
return value === null || value === undefined || typeof value === 'number'; | ||
} | ||
exports.isValidOptionalNumber = isValidOptionalNumber; | ||
function isValidOptionalString(value) { | ||
return value === null || value === undefined || typeof value === 'string'; | ||
} | ||
exports.isValidOptionalString = isValidOptionalString; | ||
function updateActionFromPayload(action, newProps) { | ||
@@ -130,2 +131,1 @@ var id = action.id; | ||
} | ||
exports.updateActionFromPayload = updateActionFromPayload; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -29,3 +29,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LeaveConfirmation = exports.confirm = exports.disable = exports.enable = exports.Action = void 0; | ||
exports.LeaveConfirmation = exports.Action = void 0; | ||
exports.enable = enable; | ||
exports.disable = disable; | ||
exports.confirm = confirm; | ||
var helper_1 = require("../helper"); | ||
@@ -43,6 +46,6 @@ var ActionSet_1 = require("../ActionSet"); | ||
Action["CONFIRM"] = "APP::LEAVE_CONFIRMATION::CONFIRM"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function enable(payload) { | ||
if (payload === void 0) { payload = {}; } | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.LeaveConfirmation, | ||
@@ -53,6 +56,5 @@ payload: payload, | ||
} | ||
exports.enable = enable; | ||
function disable(payload) { | ||
if (payload === void 0) { payload = {}; } | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.LeaveConfirmation, | ||
@@ -63,6 +65,5 @@ payload: payload, | ||
} | ||
exports.disable = disable; | ||
function confirm(payload) { | ||
if (payload === void 0) { payload = {}; } | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.LeaveConfirmation, | ||
@@ -73,3 +74,2 @@ payload: payload, | ||
} | ||
exports.confirm = confirm; | ||
/** | ||
@@ -102,3 +102,3 @@ * Leave Confirmation action set | ||
LeaveConfirmation.prototype.set = function (options) { | ||
this.options = helper_1.getMergedProps(this.options, options); | ||
this.options = (0, helper_1.getMergedProps)(this.options, options); | ||
return this; | ||
@@ -105,0 +105,0 @@ }; |
@@ -29,3 +29,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AppLink = exports.update = exports.Action = void 0; | ||
exports.AppLink = exports.Action = void 0; | ||
exports.update = update; | ||
var helper_1 = require("../../helper"); | ||
@@ -38,3 +39,3 @@ var ActionSet_1 = require("../../ActionSet"); | ||
Action["UPDATE"] = "UPDATE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function update(group, component, updatePayload) { | ||
@@ -44,9 +45,8 @@ var id = component.id; | ||
var linkPayload = __assign(__assign({}, updatePayload), { id: id, label: label, destination: destination }); | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: group, | ||
type: helper_1.getEventNameSpace(group, Action.UPDATE, component), | ||
type: (0, helper_1.getEventNameSpace)(group, Action.UPDATE, component), | ||
payload: linkPayload, | ||
}); | ||
} | ||
exports.update = update; | ||
var AppLink = /** @class */ (function (_super) { | ||
@@ -89,3 +89,3 @@ __extends(AppLink, _super); | ||
if (shouldUpdate === void 0) { shouldUpdate = true; } | ||
var _a = helper_1.getMergedProps(this.options, options), label = _a.label, destination = _a.destination; | ||
var _a = (0, helper_1.getMergedProps)(this.options, options), label = _a.label, destination = _a.destination; | ||
this.label = label; | ||
@@ -92,0 +92,0 @@ this.destination = destination; |
@@ -11,3 +11,3 @@ import { ClientApplication } from '../../client/types'; | ||
} | ||
export declare type LoadingAction = MetaAction; | ||
export type LoadingAction = MetaAction; | ||
export declare function start(payload?: Payload): LoadingAction; | ||
@@ -14,0 +14,0 @@ export declare function stop(payload?: Payload): LoadingAction; |
@@ -18,3 +18,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Loading = exports.stop = exports.start = exports.Action = void 0; | ||
exports.Loading = exports.Action = void 0; | ||
exports.start = start; | ||
exports.stop = stop; | ||
var helper_1 = require("../helper"); | ||
@@ -27,5 +29,5 @@ var ActionSet_1 = require("../ActionSet"); | ||
Action["STOP"] = "APP::LOADING::STOP"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function start(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -36,5 +38,4 @@ group: types_1.Group.Loading, | ||
} | ||
exports.start = start; | ||
function stop(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -45,3 +46,2 @@ group: types_1.Group.Loading, | ||
} | ||
exports.stop = stop; | ||
var Loading = /** @class */ (function (_super) { | ||
@@ -48,0 +48,0 @@ __extends(Loading, _super); |
@@ -9,2 +9,2 @@ "use strict"; | ||
Action["BUTTON_UPDATE"] = "APP::MARKETING_EXTERNAL_ACTIVITY_TOP_BAR::BUTTONS::BUTTON::UPDATE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); |
@@ -23,3 +23,3 @@ import { AppLink, Payload as LinkPayload } from '../../Link/AppLink'; | ||
} | ||
export declare type ChannelMenuAction = MenuAction | MetaAction; | ||
export type ChannelMenuAction = MenuAction | MetaAction; | ||
export declare function update(payload: Payload): MenuAction; | ||
@@ -26,0 +26,0 @@ export declare class ChannelMenu extends ActionSetWithChildren implements ActionSetProps<Options, Payload> { |
@@ -29,3 +29,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ChannelMenu = exports.update = exports.Action = void 0; | ||
exports.ChannelMenu = exports.Action = void 0; | ||
exports.update = update; | ||
var AppLink_1 = require("../../Link/AppLink"); | ||
@@ -40,5 +41,5 @@ var helper_1 = require("../../helper"); | ||
Action["LINK_UPDATE"] = "APP::MENU::CHANNEL_MENU::LINK::UPDATE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function update(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -49,3 +50,2 @@ group: types_1.Group.Menu, | ||
} | ||
exports.update = update; | ||
var ChannelMenu = /** @class */ (function (_super) { | ||
@@ -79,3 +79,3 @@ __extends(ChannelMenu, _super); | ||
if (shouldUpdate === void 0) { shouldUpdate = true; } | ||
var mergedOptions = helper_1.getMergedProps(this.options, options); | ||
var mergedOptions = (0, helper_1.getMergedProps)(this.options, options); | ||
var items = mergedOptions.items, active = mergedOptions.active; | ||
@@ -106,3 +106,3 @@ this.setItems(items); | ||
} | ||
if (helper_1.updateActionFromPayload(itemToUpdate, newPayload)) { | ||
if ((0, helper_1.updateActionFromPayload)(itemToUpdate, newPayload)) { | ||
this.dispatch(Action.UPDATE); | ||
@@ -109,0 +109,0 @@ } |
@@ -23,3 +23,3 @@ import { AppLink, Payload as LinkPayload } from '../../Link/AppLink'; | ||
} | ||
export declare type NavigationMenuAction = MenuAction | MetaAction; | ||
export type NavigationMenuAction = MenuAction | MetaAction; | ||
export declare function update(payload: Payload): MenuAction; | ||
@@ -26,0 +26,0 @@ export declare class NavigationMenu extends ActionSetWithChildren implements ActionSetProps<Options, Payload> { |
@@ -29,3 +29,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NavigationMenu = exports.update = exports.Action = void 0; | ||
exports.NavigationMenu = exports.Action = void 0; | ||
exports.update = update; | ||
var AppLink_1 = require("../../Link/AppLink"); | ||
@@ -40,5 +41,5 @@ var helper_1 = require("../../helper"); | ||
Action["LINK_UPDATE"] = "APP::MENU::NAVIGATION_MENU::LINK::UPDATE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function update(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -49,3 +50,2 @@ group: types_1.Group.Menu, | ||
} | ||
exports.update = update; | ||
var NavigationMenu = /** @class */ (function (_super) { | ||
@@ -79,3 +79,3 @@ __extends(NavigationMenu, _super); | ||
if (shouldUpdate === void 0) { shouldUpdate = true; } | ||
var mergedOptions = helper_1.getMergedProps(this.options, options); | ||
var mergedOptions = (0, helper_1.getMergedProps)(this.options, options); | ||
var items = mergedOptions.items, active = mergedOptions.active; | ||
@@ -106,3 +106,3 @@ this.setItems(items); | ||
} | ||
if (helper_1.updateActionFromPayload(itemToUpdate, newPayload)) { | ||
if ((0, helper_1.updateActionFromPayload)(itemToUpdate, newPayload)) { | ||
this.dispatch(Action.UPDATE); | ||
@@ -109,0 +109,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = mergeProps; | ||
/** | ||
@@ -43,2 +44,1 @@ * Returns a deeply merged object with properties from the 2 provided objects | ||
} | ||
exports.default = mergeProps; |
@@ -89,3 +89,3 @@ import { ClientApplication } from '../../client/types'; | ||
} | ||
export declare type UpdateAction = OpenAction; | ||
export type UpdateAction = OpenAction; | ||
export interface CloseAction extends ActionBase { | ||
@@ -104,3 +104,3 @@ readonly type: typeof Action.CLOSE; | ||
*/ | ||
export declare type ModalAction = OpenAction | UpdateAction | CloseAction | MetaAction | UpdateSizeAction; | ||
export type ModalAction = OpenAction | UpdateAction | CloseAction | MetaAction | UpdateSizeAction; | ||
export declare function openModal(modalPayload: MessagePayload | IframePayload): OpenAction; | ||
@@ -107,0 +107,0 @@ export declare function closeModal(modalClosePayload: ClosePayload): CloseAction; |
@@ -29,3 +29,11 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ModalIframe = exports.ModalMessage = exports.Modal = exports.isMessageModal = exports.isIframeModal = exports.data = exports.update = exports.clickFooterButton = exports.updateModalSize = exports.closeModal = exports.openModal = exports.Size = exports.Action = void 0; | ||
exports.ModalIframe = exports.ModalMessage = exports.Modal = exports.Size = exports.Action = void 0; | ||
exports.openModal = openModal; | ||
exports.closeModal = closeModal; | ||
exports.updateModalSize = updateModalSize; | ||
exports.clickFooterButton = clickFooterButton; | ||
exports.update = update; | ||
exports.data = data; | ||
exports.isIframeModal = isIframeModal; | ||
exports.isMessageModal = isMessageModal; | ||
var buttonHelper_1 = require("../buttonHelper"); | ||
@@ -46,3 +54,3 @@ var helper_1 = require("../helper"); | ||
Action["DATA"] = "APP::MODAL::DATA"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
/** | ||
@@ -68,3 +76,3 @@ * Options available to the Modal `size` param | ||
Size["Auto"] = "auto"; | ||
})(Size = exports.Size || (exports.Size = {})); | ||
})(Size || (exports.Size = Size = {})); | ||
var FOOTER_BUTTON_PROPS = { | ||
@@ -76,3 +84,3 @@ group: types_1.Group.Modal, | ||
function openModal(modalPayload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Modal, | ||
@@ -83,5 +91,4 @@ payload: modalPayload, | ||
} | ||
exports.openModal = openModal; | ||
function closeModal(modalClosePayload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Modal, | ||
@@ -92,3 +99,2 @@ payload: modalClosePayload, | ||
} | ||
exports.closeModal = closeModal; | ||
/** | ||
@@ -99,3 +105,3 @@ * Action creator for modal update size action | ||
function updateModalSize(updateSizePayload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Modal, | ||
@@ -106,10 +112,8 @@ payload: updateSizePayload, | ||
} | ||
exports.updateModalSize = updateModalSize; | ||
function clickFooterButton(id, payload) { | ||
var component = __assign({ id: id }, FOOTER_BUTTON_PROPS); | ||
return Button_1.clickButton(types_1.Group.Modal, component, payload); | ||
return (0, Button_1.clickButton)(types_1.Group.Modal, component, payload); | ||
} | ||
exports.clickFooterButton = clickFooterButton; | ||
function update(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -120,5 +124,4 @@ group: types_1.Group.Modal, | ||
} | ||
exports.update = update; | ||
function data(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -129,3 +132,2 @@ group: types_1.Group.Modal, | ||
} | ||
exports.data = data; | ||
function isIframeModal(options) { | ||
@@ -135,7 +137,5 @@ return (typeof options.url === 'string' || | ||
} | ||
exports.isIframeModal = isIframeModal; | ||
function isMessageModal(options) { | ||
return typeof options.message === 'string'; | ||
} | ||
exports.isMessageModal = isMessageModal; | ||
var Modal = /** @class */ (function (_super) { | ||
@@ -186,3 +186,3 @@ __extends(Modal, _super); | ||
this.footerPrimary = this.footerPrimaryOptions | ||
? buttonHelper_1.getSingleButton(this, this.footerPrimaryOptions, subgroups, function (newPayload) { | ||
? (0, buttonHelper_1.getSingleButton)(this, this.footerPrimaryOptions, subgroups, function (newPayload) { | ||
_this.updatePrimaryFooterButton(newPayload, updateCb); | ||
@@ -200,3 +200,3 @@ }) | ||
? this.footerSecondaryOptions.map(function (action) { | ||
return buttonHelper_1.getSingleButton(_this, action, subgroups, function (newPayload) { | ||
return (0, buttonHelper_1.getSingleButton)(_this, action, subgroups, function (newPayload) { | ||
_this.updateSecondaryFooterButton(newPayload, updateCb); | ||
@@ -217,3 +217,3 @@ }); | ||
} | ||
if (helper_1.updateActionFromPayload(this.footer.buttons.primary, newPayload)) { | ||
if ((0, helper_1.updateActionFromPayload)(this.footer.buttons.primary, newPayload)) { | ||
updateCb(); | ||
@@ -229,3 +229,3 @@ } | ||
var action = _a[_i]; | ||
updated = helper_1.updateActionFromPayload(action, newPayload); | ||
updated = (0, helper_1.updateActionFromPayload)(action, newPayload); | ||
if (updated) { | ||
@@ -271,3 +271,3 @@ break; | ||
if (shouldUpdate === void 0) { shouldUpdate = true; } | ||
var mergedOptions = helper_1.getMergedProps(this.options, options); | ||
var mergedOptions = (0, helper_1.getMergedProps)(this.options, options); | ||
var title = mergedOptions.title, footer = mergedOptions.footer, message = mergedOptions.message, size = mergedOptions.size; | ||
@@ -336,3 +336,3 @@ this.title = title; | ||
if (shouldUpdate === void 0) { shouldUpdate = true; } | ||
var mergedOptions = helper_1.getMergedProps(this.options, options); | ||
var mergedOptions = (0, helper_1.getMergedProps)(this.options, options); | ||
var title = mergedOptions.title, footer = mergedOptions.footer, path = mergedOptions.path, url = mergedOptions.url, size = mergedOptions.size, loading = mergedOptions.loading; | ||
@@ -339,0 +339,0 @@ this.title = title; |
@@ -43,3 +43,3 @@ "use strict"; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -75,3 +75,3 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
Action["LOADED"] = "LOADED"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
/** | ||
@@ -113,3 +113,3 @@ * A set of Actions for updating the modal component | ||
return __generator(this, function (_a) { | ||
updateAction = helper_1.actionWrapper({ | ||
updateAction = (0, helper_1.actionWrapper)({ | ||
type: type, | ||
@@ -116,0 +116,0 @@ group: types_1.Group.Modal, |
@@ -29,3 +29,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.History = exports.replace = exports.push = exports.Action = void 0; | ||
exports.History = exports.Action = void 0; | ||
exports.push = push; | ||
exports.replace = replace; | ||
var helper_1 = require("../../helper"); | ||
@@ -38,5 +40,5 @@ var ActionSet_1 = require("../../ActionSet"); | ||
Action["REPLACE"] = "APP::NAVIGATION::HISTORY::REPLACE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function push(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -47,5 +49,4 @@ group: types_1.Group.Navigation, | ||
} | ||
exports.push = push; | ||
function replace(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -56,3 +57,2 @@ group: types_1.Group.Navigation, | ||
} | ||
exports.replace = replace; | ||
var History = /** @class */ (function (_super) { | ||
@@ -59,0 +59,0 @@ __extends(History, _super); |
@@ -67,3 +67,3 @@ import { ClientApplication } from '../../../client/types'; | ||
} | ||
export declare type RedirectAction = AdminPathAction | RemoteAction | AppAction | AdminSectionAction | MetaAction; | ||
export type RedirectAction = AdminPathAction | RemoteAction | AppAction | AdminSectionAction | MetaAction; | ||
export interface Location { | ||
@@ -81,4 +81,4 @@ pathname: string; | ||
} | ||
export declare type Options = AppOptions | HostOptions; | ||
export declare type To = Location | URL | string; | ||
export type Options = AppOptions | HostOptions; | ||
export type To = Location | URL | string; | ||
export interface SectionStringName extends Omit<Section, 'name'> { | ||
@@ -85,0 +85,0 @@ name: keyof typeof ResourceType; |
@@ -29,3 +29,19 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Redirect = exports.isProductVariantResourcePayload = exports.isCreateResourcePayload = exports.isAdminSection = exports.isRemotePayload = exports.isAdminSectionPayload = exports.isAdminPathPayload = exports.isAppPayload = exports.getRelativePath = exports.normalizeUrl = exports.getPathWithSearchAndHash = exports.toDestination = exports.toApp = exports.toRemote = exports.toAdminSection = exports.toAdminPath = exports.isResourcePayload = exports.ResourceType = exports.Action = void 0; | ||
exports.Redirect = exports.ResourceType = exports.Action = void 0; | ||
exports.isResourcePayload = isResourcePayload; | ||
exports.toAdminPath = toAdminPath; | ||
exports.toAdminSection = toAdminSection; | ||
exports.toRemote = toRemote; | ||
exports.toApp = toApp; | ||
exports.toDestination = toDestination; | ||
exports.getPathWithSearchAndHash = getPathWithSearchAndHash; | ||
exports.normalizeUrl = normalizeUrl; | ||
exports.getRelativePath = getRelativePath; | ||
exports.isAppPayload = isAppPayload; | ||
exports.isAdminPathPayload = isAdminPathPayload; | ||
exports.isAdminSectionPayload = isAdminSectionPayload; | ||
exports.isRemotePayload = isRemotePayload; | ||
exports.isAdminSection = isAdminSection; | ||
exports.isCreateResourcePayload = isCreateResourcePayload; | ||
exports.isProductVariantResourcePayload = isProductVariantResourcePayload; | ||
var helper_1 = require("../../helper"); | ||
@@ -40,3 +56,3 @@ var ActionSet_1 = require("../../ActionSet"); | ||
Action["APP"] = "APP::NAVIGATION::REDIRECT::APP"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
var ResourceType; | ||
@@ -49,3 +65,3 @@ (function (ResourceType) { | ||
ResourceType["Discount"] = "discounts"; | ||
})(ResourceType = exports.ResourceType || (exports.ResourceType = {})); | ||
})(ResourceType || (exports.ResourceType = ResourceType = {})); | ||
function isResourcePayload(resource) { | ||
@@ -55,5 +71,4 @@ // tslint:disable-next-line:no-boolean-literal-compare | ||
} | ||
exports.isResourcePayload = isResourcePayload; | ||
function toAdminPath(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -64,5 +79,4 @@ group: types_1.Group.Navigation, | ||
} | ||
exports.toAdminPath = toAdminPath; | ||
function toAdminSection(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -73,5 +87,4 @@ group: types_1.Group.Navigation, | ||
} | ||
exports.toAdminSection = toAdminSection; | ||
function toRemote(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -82,5 +95,4 @@ group: types_1.Group.Navigation, | ||
} | ||
exports.toRemote = toRemote; | ||
function toApp(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -91,3 +103,2 @@ group: types_1.Group.Navigation, | ||
} | ||
exports.toApp = toApp; | ||
function toDestination(action, payload, id) { | ||
@@ -115,8 +126,6 @@ switch (action) { | ||
} | ||
exports.toDestination = toDestination; | ||
function getPathWithSearchAndHash(_a) { | ||
var pathname = _a.pathname, search = _a.search, hash = _a.hash; | ||
return "" + pathname + (search || '') + (hash || ''); | ||
return "".concat(pathname).concat(search || '').concat(hash || ''); | ||
} | ||
exports.getPathWithSearchAndHash = getPathWithSearchAndHash; | ||
function normalizeUrl(to) { | ||
@@ -131,3 +140,2 @@ if (to instanceof URL) { | ||
} | ||
exports.normalizeUrl = normalizeUrl; | ||
function getRelativePath(to) { | ||
@@ -143,11 +151,8 @@ if (typeof to === 'string') { | ||
} | ||
exports.getRelativePath = getRelativePath; | ||
function isAppPayload(payload) { | ||
return typeof payload === 'object' && Object.prototype.hasOwnProperty.call(payload, 'path'); | ||
} | ||
exports.isAppPayload = isAppPayload; | ||
function isAdminPathPayload(payload) { | ||
return typeof payload === 'object' && Object.prototype.hasOwnProperty.call(payload, 'path'); | ||
} | ||
exports.isAdminPathPayload = isAdminPathPayload; | ||
function isAdminSectionPayload(payload) { | ||
@@ -158,11 +163,8 @@ return (typeof payload === 'object' && | ||
} | ||
exports.isAdminSectionPayload = isAdminSectionPayload; | ||
function isRemotePayload(payload) { | ||
return typeof payload === 'object' && Object.prototype.hasOwnProperty.call(payload, 'url'); | ||
} | ||
exports.isRemotePayload = isRemotePayload; | ||
function isAdminSection(to) { | ||
return typeof to === 'object' && typeof (to === null || to === void 0 ? void 0 : to.name) === 'string'; | ||
} | ||
exports.isAdminSection = isAdminSection; | ||
function isCreateResourcePayload(resource) { | ||
@@ -172,3 +174,2 @@ // tslint:disable-next-line:no-boolean-literal-compare | ||
} | ||
exports.isCreateResourcePayload = isCreateResourcePayload; | ||
function isProductVariantResourcePayload(resource) { | ||
@@ -179,3 +180,2 @@ var castResource = resource; | ||
} | ||
exports.isProductVariantResourcePayload = isProductVariantResourcePayload; | ||
var Redirect = /** @class */ (function (_super) { | ||
@@ -182,0 +182,0 @@ __extends(Redirect, _super); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fullPageLoad = exports.skeletonPageLoad = exports.Action = void 0; | ||
exports.Action = void 0; | ||
exports.skeletonPageLoad = skeletonPageLoad; | ||
exports.fullPageLoad = fullPageLoad; | ||
var types_1 = require("../types"); | ||
@@ -10,5 +12,5 @@ var helper_1 = require("../helper"); | ||
Action["FULL_PAGE_LOAD"] = "APP::PERFORMANCE::FULL_PAGE_LOAD"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function skeletonPageLoad() { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Performance, | ||
@@ -18,5 +20,4 @@ type: Action.SKELETON_PAGE_LOAD, | ||
} | ||
exports.skeletonPageLoad = skeletonPageLoad; | ||
function fullPageLoad() { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Performance, | ||
@@ -26,2 +27,1 @@ type: Action.FULL_PAGE_LOAD, | ||
} | ||
exports.fullPageLoad = fullPageLoad; |
@@ -12,6 +12,6 @@ import { ClientApplication } from '../../client/types'; | ||
} | ||
export declare type BadgeProgress = 'incomplete' | 'partiallyComplete' | 'complete'; | ||
export declare type BadgeStatus = 'success' | 'info' | 'attention' | 'critical' | 'warning' | 'new'; | ||
export declare type MediaKind = 'Avatar' | 'Thumbnail'; | ||
export declare type VerticalAlignment = 'leading' | 'trailing' | 'center'; | ||
export type BadgeProgress = 'incomplete' | 'partiallyComplete' | 'complete'; | ||
export type BadgeStatus = 'success' | 'info' | 'attention' | 'critical' | 'warning' | 'new'; | ||
export type MediaKind = 'Avatar' | 'Thumbnail'; | ||
export type VerticalAlignment = 'leading' | 'trailing' | 'center'; | ||
/** | ||
@@ -168,3 +168,3 @@ * To be used on validator as matchEnum(...). Make sure as new values are added to update | ||
} | ||
export declare type PickerAction = SelectAction | UpdateAction | CancelAction | OpenAction | SearchAction | LoadMoreAction | MetaAction; | ||
export type PickerAction = SelectAction | UpdateAction | CancelAction | OpenAction | SearchAction | LoadMoreAction | MetaAction; | ||
export declare function select(payload: SelectPayload): SelectAction; | ||
@@ -221,31 +221,31 @@ export declare function open(payload: Payload): OpenAction; | ||
/** Whether the picker can load more items on the list */ | ||
canLoadMore?: boolean | undefined; | ||
canLoadMore?: boolean; | ||
/** An object that describes the interface of the picker when there is no item to display. */ | ||
emptySearchLabel?: EmptySearchLabel | undefined; | ||
emptySearchLabel?: EmptySearchLabel; | ||
/** The list of items to display. */ | ||
items: BaseResource[]; | ||
/** Indicates if the Picker should be in a loading state. */ | ||
loading?: boolean | undefined; | ||
loading?: boolean; | ||
/** Indicates if the Picker is currently loading more items. */ | ||
loadingMore?: boolean | undefined; | ||
loadingMore?: boolean; | ||
/** Limits the total number of selections to a maximum of the passed value, or 0 for no limit. */ | ||
maxSelectable?: number | undefined; | ||
maxSelectable?: number; | ||
/** Limits the total number of selections to a maximum of the passed value, or 0 for no limit. */ | ||
primaryActionLabel?: string | undefined; | ||
primaryActionLabel?: string; | ||
/** Text content of the search box when first loaded */ | ||
searchQuery?: string | undefined; | ||
searchQuery?: string; | ||
/** Used as the placeholder in the search input. */ | ||
searchQueryPlaceholder?: string | undefined; | ||
searchQueryPlaceholder?: string; | ||
/** Label to be used on the secondary action button. */ | ||
secondaryActionLabel?: string | undefined; | ||
secondaryActionLabel?: string; | ||
/** The items which are selected. */ | ||
selectedItems?: BaseResource[] | undefined; | ||
selectedItems?: BaseResource[]; | ||
/** Used as the title of the modal. */ | ||
title?: string | undefined; | ||
title?: string; | ||
/** Adjust vertical alignment of elements */ | ||
/** @default 'center' */ | ||
verticalAlignment?: VerticalAlignment | undefined; | ||
verticalAlignment?: VerticalAlignment; | ||
/** Allow submission when no items are selected */ | ||
/** @default false */ | ||
allowEmptySelection?: boolean | undefined; | ||
allowEmptySelection?: boolean; | ||
/** Name of the resource, such as customers or products. **/ | ||
@@ -255,3 +255,3 @@ resourceName?: { | ||
plural: string; | ||
} | undefined; | ||
}; | ||
}; | ||
@@ -258,0 +258,0 @@ get options(): Options; |
@@ -29,3 +29,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.unstable_Picker = exports.loadMore = exports.search = exports.update = exports.cancel = exports.open = exports.select = exports.ALL_RESOURCE_VERTICAL_ALIGNMENT = exports.ALL_MEDIA_KINDS = exports.ALL_BADGE_STATUSES = exports.ALL_BADGE_PROGRESSES = exports.Action = void 0; | ||
exports.unstable_Picker = exports.ALL_RESOURCE_VERTICAL_ALIGNMENT = exports.ALL_MEDIA_KINDS = exports.ALL_BADGE_STATUSES = exports.ALL_BADGE_PROGRESSES = exports.Action = void 0; | ||
exports.select = select; | ||
exports.open = open; | ||
exports.cancel = cancel; | ||
exports.update = update; | ||
exports.search = search; | ||
exports.loadMore = loadMore; | ||
var helper_1 = require("../helper"); | ||
@@ -42,3 +48,3 @@ var ActionSet_1 = require("../ActionSet"); | ||
Action["LOAD_MORE"] = "APP::PICKER::LOAD_MORE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
/** | ||
@@ -71,3 +77,3 @@ * To be used on validator as matchEnum(...). Make sure as new values are added to update | ||
function select(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -78,5 +84,4 @@ group: types_1.Group.unstable_Picker, | ||
} | ||
exports.select = select; | ||
function open(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -87,5 +92,4 @@ group: types_1.Group.unstable_Picker, | ||
} | ||
exports.open = open; | ||
function cancel(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -96,5 +100,4 @@ group: types_1.Group.unstable_Picker, | ||
} | ||
exports.cancel = cancel; | ||
function update(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -105,5 +108,4 @@ group: types_1.Group.unstable_Picker, | ||
} | ||
exports.update = update; | ||
function search(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -114,5 +116,4 @@ group: types_1.Group.unstable_Picker, | ||
} | ||
exports.search = search; | ||
function loadMore(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -123,3 +124,2 @@ group: types_1.Group.unstable_Picker, | ||
} | ||
exports.loadMore = loadMore; | ||
/** | ||
@@ -169,3 +169,3 @@ * @unstable This API may be updated without warning in the future | ||
if (shouldUpdate === void 0) { shouldUpdate = true; } | ||
var mergedOptions = helper_1.getMergedProps(this.options, options); | ||
var mergedOptions = (0, helper_1.getMergedProps)(this.options, options); | ||
var _a = mergedOptions.selectedItems, selectedItems = _a === void 0 ? [] : _a, _b = mergedOptions.maxSelectable, maxSelectable = _b === void 0 ? 0 : _b, _c = mergedOptions.items, items = _c === void 0 ? [] : _c, _d = mergedOptions.loading, loading = _d === void 0 ? false : _d, title = mergedOptions.title, searchQuery = mergedOptions.searchQuery, searchQueryPlaceholder = mergedOptions.searchQueryPlaceholder, primaryActionLabel = mergedOptions.primaryActionLabel, secondaryActionLabel = mergedOptions.secondaryActionLabel, emptySearchLabel = mergedOptions.emptySearchLabel, _e = mergedOptions.canLoadMore, canLoadMore = _e === void 0 ? false : _e, _f = mergedOptions.loadingMore, loadingMore = _f === void 0 ? false : _f, verticalAlignment = mergedOptions.verticalAlignment, allowEmptySelection = mergedOptions.allowEmptySelection, resourceName = mergedOptions.resourceName; | ||
@@ -172,0 +172,0 @@ this.title = title; |
@@ -18,3 +18,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Pos = exports.close = exports.Action = void 0; | ||
exports.Pos = exports.Action = void 0; | ||
exports.close = close; | ||
var helper_1 = require("../helper"); | ||
@@ -34,5 +35,5 @@ var ActionSet_1 = require("../ActionSet"); | ||
Action["DEVICE_UPDATE"] = "APP::POS::DEVICE::UPDATE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function close() { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Pos, | ||
@@ -42,3 +43,2 @@ type: Action.CLOSE, | ||
} | ||
exports.close = close; | ||
var Pos = /** @class */ (function (_super) { | ||
@@ -45,0 +45,0 @@ __extends(Pos, _super); |
@@ -5,3 +5,3 @@ import { MetaAction } from '../types'; | ||
} | ||
export declare type PrintAction = MetaAction; | ||
export type PrintAction = MetaAction; | ||
export declare function app(): PrintAction; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.app = exports.Action = void 0; | ||
exports.Action = void 0; | ||
exports.app = app; | ||
var helper_1 = require("../helper"); | ||
@@ -9,5 +10,5 @@ var types_1 = require("../types"); | ||
Action["APP"] = "APP::PRINT::APP"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function app() { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Print, | ||
@@ -17,2 +18,1 @@ type: Action.APP, | ||
} | ||
exports.app = app; |
@@ -11,3 +11,3 @@ import { ClientApplication } from '../../client/types'; | ||
} | ||
export declare type Money = string; | ||
export type Money = string; | ||
export declare enum CollectionSortOrder { | ||
@@ -160,3 +160,3 @@ Manual = "MANUAL", | ||
} | ||
export declare type ClosePayload = CancelPayload; | ||
export type ClosePayload = CancelPayload; | ||
export interface Payload { | ||
@@ -177,3 +177,3 @@ readonly id?: string; | ||
} | ||
export declare type ResourceSelection = Product | ProductVariant | Collection; | ||
export type ResourceSelection = Product | ProductVariant | Collection; | ||
export interface SelectPayload { | ||
@@ -225,3 +225,3 @@ readonly id?: string; | ||
} | ||
export declare type CloseAction = CancelAction; | ||
export type CloseAction = CancelAction; | ||
export interface OpenAction extends ActionBase { | ||
@@ -231,3 +231,3 @@ readonly type: typeof Action.OPEN; | ||
} | ||
export declare type ResourcePickerAction = SelectAction | UpdateAction | CancelAction | OpenAction | MetaAction; | ||
export type ResourcePickerAction = SelectAction | UpdateAction | CancelAction | OpenAction | MetaAction; | ||
export declare function select(payload: SelectPayload): SelectAction; | ||
@@ -256,8 +256,8 @@ export declare function open(payload: Payload): OpenAction; | ||
resourceType: ResourceType; | ||
initialQuery?: string | undefined; | ||
filterQuery?: string | undefined; | ||
initialSelectionIds?: BaseResource[] | undefined; | ||
showHidden?: boolean | undefined; | ||
selectMultiple?: number | boolean | undefined; | ||
actionVerb?: ActionVerb | undefined; | ||
initialQuery?: string; | ||
filterQuery?: string; | ||
initialSelectionIds?: BaseResource[]; | ||
showHidden?: boolean; | ||
selectMultiple?: boolean | number; | ||
actionVerb?: ActionVerb; | ||
}; | ||
@@ -264,0 +264,0 @@ get options(): Options; |
@@ -29,3 +29,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ResourcePicker = exports.update = exports.close = exports.cancel = exports.open = exports.select = exports.ActionVerb = exports.ResourceType = exports.ProductStatus = exports.ProductVariantInventoryManagement = exports.ProductVariantInventoryPolicy = exports.WeightUnit = exports.FulfillmentServiceType = exports.CollectionSortOrder = exports.Action = void 0; | ||
exports.ResourcePicker = exports.ActionVerb = exports.ResourceType = exports.ProductStatus = exports.ProductVariantInventoryManagement = exports.ProductVariantInventoryPolicy = exports.WeightUnit = exports.FulfillmentServiceType = exports.CollectionSortOrder = exports.Action = void 0; | ||
exports.select = select; | ||
exports.open = open; | ||
exports.cancel = cancel; | ||
exports.close = close; | ||
exports.update = update; | ||
var helper_1 = require("../helper"); | ||
@@ -42,3 +47,3 @@ var ActionSet_1 = require("../ActionSet"); | ||
Action["CANCEL"] = "APP::RESOURCE_PICKER::CANCEL"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
var CollectionSortOrder; | ||
@@ -55,3 +60,3 @@ (function (CollectionSortOrder) { | ||
CollectionSortOrder["MostRelevant"] = "MOST_RELEVANT"; | ||
})(CollectionSortOrder = exports.CollectionSortOrder || (exports.CollectionSortOrder = {})); | ||
})(CollectionSortOrder || (exports.CollectionSortOrder = CollectionSortOrder = {})); | ||
var FulfillmentServiceType; | ||
@@ -62,3 +67,3 @@ (function (FulfillmentServiceType) { | ||
FulfillmentServiceType["ThirdParty"] = "THIRD_PARTY"; | ||
})(FulfillmentServiceType = exports.FulfillmentServiceType || (exports.FulfillmentServiceType = {})); | ||
})(FulfillmentServiceType || (exports.FulfillmentServiceType = FulfillmentServiceType = {})); | ||
var WeightUnit; | ||
@@ -70,3 +75,3 @@ (function (WeightUnit) { | ||
WeightUnit["Ounces"] = "OUNCES"; | ||
})(WeightUnit = exports.WeightUnit || (exports.WeightUnit = {})); | ||
})(WeightUnit || (exports.WeightUnit = WeightUnit = {})); | ||
var ProductVariantInventoryPolicy; | ||
@@ -76,3 +81,3 @@ (function (ProductVariantInventoryPolicy) { | ||
ProductVariantInventoryPolicy["Continue"] = "CONTINUE"; | ||
})(ProductVariantInventoryPolicy = exports.ProductVariantInventoryPolicy || (exports.ProductVariantInventoryPolicy = {})); | ||
})(ProductVariantInventoryPolicy || (exports.ProductVariantInventoryPolicy = ProductVariantInventoryPolicy = {})); | ||
var ProductVariantInventoryManagement; | ||
@@ -83,3 +88,3 @@ (function (ProductVariantInventoryManagement) { | ||
ProductVariantInventoryManagement["FulfillmentService"] = "FULFILLMENT_SERVICE"; | ||
})(ProductVariantInventoryManagement = exports.ProductVariantInventoryManagement || (exports.ProductVariantInventoryManagement = {})); | ||
})(ProductVariantInventoryManagement || (exports.ProductVariantInventoryManagement = ProductVariantInventoryManagement = {})); | ||
var ProductStatus; | ||
@@ -90,3 +95,3 @@ (function (ProductStatus) { | ||
ProductStatus["Draft"] = "DRAFT"; | ||
})(ProductStatus = exports.ProductStatus || (exports.ProductStatus = {})); | ||
})(ProductStatus || (exports.ProductStatus = ProductStatus = {})); | ||
var ResourceType; | ||
@@ -97,3 +102,3 @@ (function (ResourceType) { | ||
ResourceType["Collection"] = "collection"; | ||
})(ResourceType = exports.ResourceType || (exports.ResourceType = {})); | ||
})(ResourceType || (exports.ResourceType = ResourceType = {})); | ||
var ActionVerb; | ||
@@ -103,5 +108,5 @@ (function (ActionVerb) { | ||
ActionVerb["Select"] = "select"; | ||
})(ActionVerb = exports.ActionVerb || (exports.ActionVerb = {})); | ||
})(ActionVerb || (exports.ActionVerb = ActionVerb = {})); | ||
function select(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -112,5 +117,4 @@ group: types_1.Group.ResourcePicker, | ||
} | ||
exports.select = select; | ||
function open(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -121,5 +125,4 @@ group: types_1.Group.ResourcePicker, | ||
} | ||
exports.open = open; | ||
function cancel(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -130,5 +133,4 @@ group: types_1.Group.ResourcePicker, | ||
} | ||
exports.cancel = cancel; | ||
function close(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -139,5 +141,4 @@ group: types_1.Group.ResourcePicker, | ||
} | ||
exports.close = close; | ||
function update(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -148,3 +149,2 @@ group: types_1.Group.ResourcePicker, | ||
} | ||
exports.update = update; | ||
var ResourcePicker = /** @class */ (function (_super) { | ||
@@ -188,3 +188,3 @@ __extends(ResourcePicker, _super); | ||
if (shouldUpdate === void 0) { shouldUpdate = true; } | ||
var mergedOptions = helper_1.getMergedProps(this.options, options); | ||
var mergedOptions = (0, helper_1.getMergedProps)(this.options, options); | ||
var initialQuery = mergedOptions.initialQuery, filterQuery = mergedOptions.filterQuery, _a = mergedOptions.initialSelectionIds, initialSelectionIds = _a === void 0 ? [] : _a, _b = mergedOptions.showHidden, showHidden = _b === void 0 ? true : _b, _c = mergedOptions.showVariants, showVariants = _c === void 0 ? true : _c, _d = mergedOptions.showDraft, showDraft = _d === void 0 ? true : _d, _e = mergedOptions.showArchived, showArchived = _e === void 0 ? true : _e, _f = mergedOptions.showDraftBadge, showDraftBadge = _f === void 0 ? false : _f, _g = mergedOptions.showArchivedBadge, showArchivedBadge = _g === void 0 ? false : _g, _h = mergedOptions.selectMultiple, selectMultiple = _h === void 0 ? true : _h, _j = mergedOptions.actionVerb, actionVerb = _j === void 0 ? ActionVerb.Add : _j; | ||
@@ -191,0 +191,0 @@ this.initialQuery = initialQuery; |
@@ -40,4 +40,4 @@ import { ClientApplication } from '../../client/types'; | ||
} | ||
export declare type ScannerAction = MetaAction; | ||
export type ScannerAction = MetaAction; | ||
export declare function openCamera(): ScannerAction; | ||
export declare function capture(payload: Payload & Options): ScannerAction; |
@@ -18,3 +18,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.capture = exports.openCamera = exports.Scanner = exports.Action = void 0; | ||
exports.Scanner = exports.Action = void 0; | ||
exports.openCamera = openCamera; | ||
exports.capture = capture; | ||
var helper_1 = require("../helper"); | ||
@@ -31,3 +33,3 @@ var ActionSet_1 = require("../ActionSet"); | ||
Action["CAPTURE"] = "APP::SCANNER::CAPTURE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
/** | ||
@@ -57,3 +59,3 @@ * A set of Actions for displaying a Camera Scanner component | ||
Scanner.prototype.dispatchScannerAction = function (type) { | ||
this.app.dispatch(helper_1.actionWrapper({ | ||
this.app.dispatch((0, helper_1.actionWrapper)({ | ||
type: type, | ||
@@ -70,3 +72,3 @@ group: types_1.Group.Scanner, | ||
function openCamera() { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Scanner, | ||
@@ -76,5 +78,4 @@ type: Action.OPEN_CAMERA, | ||
} | ||
exports.openCamera = openCamera; | ||
function capture(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Scanner, | ||
@@ -85,2 +86,1 @@ type: Action.CAPTURE, | ||
} | ||
exports.capture = capture; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.respond = exports.request = exports.Action = void 0; | ||
exports.Action = void 0; | ||
exports.request = request; | ||
exports.respond = respond; | ||
var helper_1 = require("../helper"); | ||
@@ -10,5 +12,5 @@ var types_1 = require("../types"); | ||
Action["RESPOND"] = "APP::SESSION_TOKEN::RESPOND"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function request() { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.SessionToken, | ||
@@ -18,5 +20,4 @@ type: Action.REQUEST, | ||
} | ||
exports.request = request; | ||
function respond(sessionToken) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: sessionToken, | ||
@@ -27,2 +28,1 @@ group: types_1.Group.SessionToken, | ||
} | ||
exports.respond = respond; |
@@ -23,3 +23,3 @@ import { ClientApplication } from '../../client/types'; | ||
} | ||
export declare type InputPayload = TextPayload | UrlPayload; | ||
export type InputPayload = TextPayload | UrlPayload; | ||
/** | ||
@@ -51,4 +51,4 @@ * @public | ||
} | ||
export declare type ShareAction = MetaAction; | ||
export type ShareAction = MetaAction; | ||
export declare function show(): ShareAction; | ||
export declare function close(payload: OutputPayload): ShareAction; |
@@ -29,3 +29,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.close = exports.show = exports.Share = exports.Action = void 0; | ||
exports.Share = exports.Action = void 0; | ||
exports.show = show; | ||
exports.close = close; | ||
var types_1 = require("../types"); | ||
@@ -44,3 +46,3 @@ var helper_1 = require("../helper"); | ||
Action["CLOSE"] = "APP::SHARE::CLOSE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
/** | ||
@@ -67,3 +69,3 @@ * Action | ||
default: | ||
throw new Error("Action: " + action + " not supported"); | ||
throw new Error("Action: ".concat(action, " not supported")); | ||
} | ||
@@ -76,3 +78,3 @@ return this; | ||
Share.prototype.dispatchShareAction = function (actionType, payload) { | ||
this.app.dispatch(helper_1.actionWrapper({ | ||
this.app.dispatch((0, helper_1.actionWrapper)({ | ||
type: actionType, | ||
@@ -87,3 +89,3 @@ group: types_1.Group.Share, | ||
function show() { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Share, | ||
@@ -93,5 +95,4 @@ type: Action.SHOW, | ||
} | ||
exports.show = show; | ||
function close(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Share, | ||
@@ -102,2 +103,1 @@ type: Action.CLOSE, | ||
} | ||
exports.close = close; |
@@ -42,7 +42,7 @@ import { Action as AppBridgeRedirectAction } from '../Navigation/Redirect'; | ||
} | ||
export declare type TitleBarAction = UpdateAction | ClickAction | MetaAction; | ||
export type TitleBarAction = UpdateAction | ClickAction | MetaAction; | ||
export declare function clickActionButton(id: string, payload?: any): ClickAction; | ||
export declare function clickBreadcrumb(id: string, payload?: any): ClickAction; | ||
export declare function update(payload: Payload): UpdateAction; | ||
export declare type Target = Exclude<keyof typeof AppBridgeRedirectAction, 'ADMIN_SECTION'>; | ||
export type Target = Exclude<keyof typeof AppBridgeRedirectAction, 'ADMIN_SECTION'>; | ||
export interface ActionProps { | ||
@@ -72,3 +72,3 @@ /** Content the action displays */ | ||
} | ||
export declare type DeepPartial<T> = T extends object ? { | ||
export type DeepPartial<T> = T extends object ? { | ||
[P in keyof T]?: DeepPartial<T[P]>; | ||
@@ -75,0 +75,0 @@ } : T; |
@@ -29,3 +29,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TitleBar = exports.update = exports.clickBreadcrumb = exports.clickActionButton = exports.Action = void 0; | ||
exports.TitleBar = exports.Action = void 0; | ||
exports.clickActionButton = clickActionButton; | ||
exports.clickBreadcrumb = clickBreadcrumb; | ||
exports.update = update; | ||
var ActionSet_1 = require("../ActionSet"); | ||
@@ -46,3 +49,3 @@ var Button_1 = require("../Button"); | ||
Action["BREADCRUMBS_UPDATE"] = "APP::TITLEBAR::BREADCRUMBS::BUTTON::UPDATE"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
var TITLEBAR_BUTTON_PROPS = { | ||
@@ -60,12 +63,10 @@ group: types_1.Group.TitleBar, | ||
var component = __assign({ id: id, type: type }, TITLEBAR_BUTTON_PROPS); | ||
return Button_1.clickButton(types_1.Group.TitleBar, component, payload); | ||
return (0, Button_1.clickButton)(types_1.Group.TitleBar, component, payload); | ||
} | ||
exports.clickActionButton = clickActionButton; | ||
function clickBreadcrumb(id, payload) { | ||
var component = __assign({ id: id }, BREADCRUMB_BUTTON_PROPS); | ||
return Button_1.clickButton(types_1.Group.TitleBar, component, payload); | ||
return (0, Button_1.clickButton)(types_1.Group.TitleBar, component, payload); | ||
} | ||
exports.clickBreadcrumb = clickBreadcrumb; | ||
function update(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -76,3 +77,2 @@ group: types_1.Group.TitleBar, | ||
} | ||
exports.update = update; | ||
var TitleBar = /** @class */ (function (_super) { | ||
@@ -135,3 +135,3 @@ __extends(TitleBar, _super); | ||
if (shouldUpdate === void 0) { shouldUpdate = true; } | ||
var mergedOptions = helper_1.getMergedProps(this.options, options); | ||
var mergedOptions = (0, helper_1.getMergedProps)(this.options, options); | ||
var title = mergedOptions.title, buttons = mergedOptions.buttons, breadcrumbs = mergedOptions.breadcrumbs; | ||
@@ -157,5 +157,5 @@ this.title = title; | ||
if (button instanceof ButtonGroup_1.ButtonGroup) { | ||
return buttonGroupHelper_1.getGroupedButton(this, button, subgroups, updateCb); | ||
return (0, buttonGroupHelper_1.getGroupedButton)(this, button, subgroups, updateCb); | ||
} | ||
return buttonHelper_1.getSingleButton(this, button, subgroups, updateCb); | ||
return (0, buttonHelper_1.getSingleButton)(this, button, subgroups, updateCb); | ||
}; | ||
@@ -166,3 +166,3 @@ TitleBar.prototype.updatePrimaryButton = function (newPayload) { | ||
} | ||
if (helper_1.updateActionFromPayload(this.primary, newPayload)) { | ||
if ((0, helper_1.updateActionFromPayload)(this.primary, newPayload)) { | ||
this.dispatch(Action.UPDATE); | ||
@@ -180,7 +180,7 @@ } | ||
var updated = false; | ||
if (ButtonGroup_1.isGroupedButtonPayload(newPayload)) { | ||
updated = helper_1.updateActionFromPayload(buttonToUpdate, newPayload); | ||
if ((0, ButtonGroup_1.isGroupedButtonPayload)(newPayload)) { | ||
updated = (0, helper_1.updateActionFromPayload)(buttonToUpdate, newPayload); | ||
} | ||
else { | ||
updated = helper_1.updateActionFromPayload(buttonToUpdate, newPayload); | ||
updated = (0, helper_1.updateActionFromPayload)(buttonToUpdate, newPayload); | ||
} | ||
@@ -195,3 +195,3 @@ if (updated) { | ||
} | ||
if (helper_1.updateActionFromPayload(this.breadcrumb, newPayload)) { | ||
if ((0, helper_1.updateActionFromPayload)(this.breadcrumb, newPayload)) { | ||
this.dispatch(Action.UPDATE); | ||
@@ -198,0 +198,0 @@ } |
@@ -37,4 +37,4 @@ import { ActionSet } from '../ActionSet'; | ||
} | ||
export declare type ToastAction = ShowAction | ClearAction | MetaAction; | ||
export declare type ShowPayload = Omit<Payload, 'action'> & { | ||
export type ToastAction = ShowAction | ClearAction | MetaAction; | ||
export type ShowPayload = Omit<Payload, 'action'> & { | ||
action?: { | ||
@@ -41,0 +41,0 @@ content: string; |
@@ -29,3 +29,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Toast = exports.primaryAction = exports.clear = exports.show = exports.Action = void 0; | ||
exports.Toast = exports.Action = void 0; | ||
exports.show = show; | ||
exports.clear = clear; | ||
exports.primaryAction = primaryAction; | ||
var helper_1 = require("../helper"); | ||
@@ -39,5 +42,5 @@ var ActionSet_1 = require("../ActionSet"); | ||
Action["ACTION"] = "APP::TOAST::ACTION"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); | ||
function show(toastMessage) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
group: types_1.Group.Toast, | ||
@@ -48,5 +51,4 @@ payload: toastMessage, | ||
} | ||
exports.show = show; | ||
function clear(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -57,5 +59,4 @@ group: types_1.Group.Toast, | ||
} | ||
exports.clear = clear; | ||
function primaryAction(payload) { | ||
return helper_1.actionWrapper({ | ||
return (0, helper_1.actionWrapper)({ | ||
payload: payload, | ||
@@ -66,3 +67,2 @@ group: types_1.Group.Toast, | ||
} | ||
exports.primaryAction = primaryAction; | ||
var Toast = /** @class */ (function (_super) { | ||
@@ -102,3 +102,3 @@ __extends(Toast, _super); | ||
Toast.prototype.set = function (options) { | ||
var mergedOptions = helper_1.getMergedProps(this.options, options); | ||
var mergedOptions = (0, helper_1.getMergedProps)(this.options, options); | ||
var message = mergedOptions.message, duration = mergedOptions.duration, isError = mergedOptions.isError, action = mergedOptions.action; | ||
@@ -105,0 +105,0 @@ this.message = message; |
@@ -41,3 +41,3 @@ "use strict"; | ||
Group["WebVitals"] = "WebVitals"; | ||
})(Group = exports.Group || (exports.Group = {})); | ||
})(Group || (exports.Group = Group = {})); | ||
/** | ||
@@ -50,2 +50,2 @@ * @internal | ||
ComponentType["ButtonGroup"] = "ButtonGroup"; | ||
})(ComponentType = exports.ComponentType || (exports.ComponentType = {})); | ||
})(ComponentType || (exports.ComponentType = ComponentType = {})); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateUuid = void 0; | ||
exports.generateUuid = generateUuid; | ||
/** | ||
@@ -9,3 +9,3 @@ * Convert a number or array of integers to a string of padded hex octets. | ||
return Array.from(value) | ||
.map(function (i) { return ("00" + i.toString(16)).slice(-2); }) | ||
.map(function (i) { return "00".concat(i.toString(16)).slice(-2); }) | ||
.join(''); | ||
@@ -59,3 +59,2 @@ } | ||
} | ||
exports.generateUuid = generateUuid; | ||
exports.default = generateUuid; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isPermitted = exports.getPermissionKey = exports.isPerformanceOrWebVitalsAction = exports.isAppMessage = exports.isAppBridgeAction = void 0; | ||
exports.isAppBridgeAction = isAppBridgeAction; | ||
exports.isAppMessage = isAppMessage; | ||
exports.isPerformanceOrWebVitalsAction = isPerformanceOrWebVitalsAction; | ||
exports.getPermissionKey = getPermissionKey; | ||
exports.isPermitted = isPermitted; | ||
var types_1 = require("../client/types"); | ||
@@ -16,3 +20,2 @@ var constants_1 = require("./constants"); | ||
} | ||
exports.isAppBridgeAction = isAppBridgeAction; | ||
/** | ||
@@ -28,5 +31,4 @@ * Predicate to determine if an event originated from an application. | ||
return (Object.prototype.hasOwnProperty.call(data, 'type') && | ||
helper_1.findMatchInEnum(types_1.MessageType, data.type) !== undefined); | ||
(0, helper_1.findMatchInEnum)(types_1.MessageType, data.type) !== undefined); | ||
} | ||
exports.isAppMessage = isAppMessage; | ||
/** | ||
@@ -40,3 +42,2 @@ * Function used to determine if an action is in the Performance or WebVitals groups | ||
} | ||
exports.isPerformanceOrWebVitalsAction = isPerformanceOrWebVitalsAction; | ||
/** | ||
@@ -47,5 +48,4 @@ * Returns the action type without the prefix and group | ||
function getPermissionKey(type) { | ||
return type.replace(new RegExp("^" + constants_1.PREFIX + constants_1.SEPARATOR + "\\w+" + constants_1.SEPARATOR), ''); | ||
return type.replace(new RegExp("^".concat(constants_1.PREFIX).concat(constants_1.SEPARATOR, "\\w+").concat(constants_1.SEPARATOR)), ''); | ||
} | ||
exports.getPermissionKey = getPermissionKey; | ||
/** | ||
@@ -67,2 +67,1 @@ * Predicate to determine if an action is permitted | ||
} | ||
exports.isPermitted = isPermitted; |
@@ -12,2 +12,2 @@ "use strict"; | ||
Action["INTERACTION_TO_NEXT_PAINT"] = "APP::WEB_VITALS::INTERACTION_TO_NEXT_PAINT"; | ||
})(Action = exports.Action || (exports.Action = {})); | ||
})(Action || (exports.Action = Action = {})); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -48,7 +48,7 @@ import { AnyAction, Group, MetaAction, Dispatch, ErrorSubscriber, ActionCallback, Unsubscribe, ActionSetInterface, ActionSetOptions } from '../actions/types'; | ||
*/ | ||
export declare type FeaturesAvailable<T extends Group = Group> = Record<T, FeaturesAction>; | ||
export type FeaturesAvailable<T extends Group = Group> = Record<T, FeaturesAction>; | ||
/** | ||
* @internal | ||
*/ | ||
export declare type FeaturesState<T = FeaturesAvailable> = { | ||
export type FeaturesState<T = FeaturesAvailable> = { | ||
[key in Context]?: T; | ||
@@ -59,3 +59,3 @@ }; | ||
*/ | ||
export declare type FeaturePermission = { | ||
export type FeaturePermission = { | ||
[key in PermissionType]: boolean; | ||
@@ -72,3 +72,3 @@ }; | ||
*/ | ||
export declare type StateWithoutFeatures<S> = Omit<S, 'features'>; | ||
export type StateWithoutFeatures<S> = Omit<S, 'features'>; | ||
/** | ||
@@ -84,12 +84,12 @@ * The shared App Bridge state which contains information about | ||
} | ||
declare type PathImpl<T, Key extends keyof T> = Key extends string ? T[Key] extends Record<string, any> ? `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}` | `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : never : never; | ||
declare type PathImpl2<T> = PathImpl<T, keyof T> | keyof T; | ||
type PathImpl<T, Key extends keyof T> = Key extends string ? T[Key] extends Record<string, any> ? `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}` | `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : never : never; | ||
type PathImpl2<T> = PathImpl<T, keyof T> | keyof T; | ||
/** | ||
* @internal | ||
*/ | ||
export declare type Path<T> = PathImpl2<T> extends string | keyof T ? PathImpl2<T> : keyof T; | ||
export type Path<T> = PathImpl2<T> extends string | keyof T ? PathImpl2<T> : keyof T; | ||
/** | ||
* @internal | ||
*/ | ||
export declare type PathValue<T, P extends Path<T>> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends Path<T[Key]> ? PathValue<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never; | ||
export type PathValue<T, P extends Path<T>> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends Path<T[Key]> ? PathValue<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never; | ||
/** | ||
@@ -96,0 +96,0 @@ * Application instance, required for use with actions. |
@@ -13,3 +13,3 @@ "use strict"; | ||
MessageType["Unsubscribe"] = "unsubscribe"; | ||
})(MessageType = exports.MessageType || (exports.MessageType = {})); | ||
})(MessageType || (exports.MessageType = MessageType = {})); | ||
/** | ||
@@ -22,3 +22,3 @@ * @internal | ||
PermissionType["Subscribe"] = "Subscribe"; | ||
})(PermissionType = exports.PermissionType || (exports.PermissionType = {})); | ||
})(PermissionType || (exports.PermissionType = PermissionType = {})); | ||
/** | ||
@@ -48,2 +48,2 @@ * | ||
LifecycleHook["DispatchAction"] = "DispatchAction"; | ||
})(LifecycleHook = exports.LifecycleHook || (exports.LifecycleHook = {})); | ||
})(LifecycleHook || (exports.LifecycleHook = LifecycleHook = {})); |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -58,3 +58,3 @@ import type { AnyAction, ActionCallback, Unsubscribe } from './actions/types'; | ||
*/ | ||
export declare type Handler = (event: MessageEvent) => void; | ||
export type Handler = (event: MessageEvent) => void; | ||
/** | ||
@@ -61,0 +61,0 @@ * @internal |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createTransportListener = exports.fromWindow = exports.fromFrame = exports.Context = void 0; | ||
exports.Context = void 0; | ||
exports.fromFrame = fromFrame; | ||
exports.fromWindow = fromWindow; | ||
exports.createTransportListener = createTransportListener; | ||
var Error_1 = require("./actions/Error"); | ||
@@ -13,3 +16,3 @@ var validator_1 = require("./actions/validator"); | ||
Context["Main"] = "Main"; | ||
})(Context = exports.Context || (exports.Context = {})); | ||
})(Context || (exports.Context = Context = {})); | ||
/** | ||
@@ -25,3 +28,3 @@ * Create a MessageTransport from a Frame. | ||
if (!host) { | ||
throw Error_1.fromAction('App frame is undefined', Error_1.AppActionType.WINDOW_UNDEFINED); | ||
throw (0, Error_1.fromAction)('App frame is undefined', Error_1.AppActionType.WINDOW_UNDEFINED); | ||
} | ||
@@ -55,8 +58,8 @@ if (env_1.isUnframed && window.MobileWebView) { | ||
host.addEventListener('message', function (event) { | ||
if (event.source === host || !validator_1.isAppMessage(event)) { | ||
if (event.source === host || !(0, validator_1.isAppMessage)(event)) { | ||
return; | ||
} | ||
if (event.origin !== localOrigin) { | ||
var errorMessage = "Message origin '" + event.origin + "' does not match app origin '" + localOrigin + "'."; | ||
var payload = Error_1.invalidOriginAction(errorMessage); | ||
var errorMessage = "Message origin '".concat(event.origin, "' does not match app origin '").concat(localOrigin, "'."); | ||
var payload = (0, Error_1.invalidOriginAction)(errorMessage); | ||
var message = { | ||
@@ -92,7 +95,6 @@ type: 'dispatch', | ||
subscribe: function (handler) { | ||
return collection_1.addAndRemoveFromCollection(handlers, handler); | ||
return (0, collection_1.addAndRemoveFromCollection)(handlers, handler); | ||
}, | ||
}; | ||
} | ||
exports.fromFrame = fromFrame; | ||
/** | ||
@@ -112,3 +114,3 @@ * Create a MessageTransport from a parent window. | ||
event.source !== contentWindow || | ||
!(validator_1.isAppBridgeAction(event.data.payload) || validator_1.isAppMessage(event))) { | ||
!((0, validator_1.isAppBridgeAction)(event.data.payload) || (0, validator_1.isAppMessage)(event))) { | ||
return; | ||
@@ -139,11 +141,10 @@ } | ||
} | ||
var messageOrigin = new URL("https://" + message.source.host).origin; | ||
var messageOrigin = new URL("https://".concat(message.source.host)).origin; | ||
contentWindow.postMessage(message, messageOrigin); | ||
}, | ||
subscribe: function (handler) { | ||
return collection_1.addAndRemoveFromCollection(handlers, handler); | ||
return (0, collection_1.addAndRemoveFromCollection)(handlers, handler); | ||
}, | ||
}; | ||
} | ||
exports.fromWindow = fromWindow; | ||
function createTransportListener() { | ||
@@ -156,3 +157,3 @@ var listeners = []; | ||
// eslint-disable-next-line prefer-rest-params | ||
return collection_1.addAndRemoveFromCollection(listeners, { callback: arguments[0] }); | ||
return (0, collection_1.addAndRemoveFromCollection)(listeners, { callback: arguments[0] }); | ||
} | ||
@@ -169,3 +170,3 @@ // eslint-disable-next-line prefer-rest-params | ||
} | ||
return collection_1.addAndRemoveFromCollection(actionListeners[type], actionCallback, function () { | ||
return (0, collection_1.addAndRemoveFromCollection)(actionListeners[type], actionCallback, function () { | ||
if (dispatcher) { | ||
@@ -201,3 +202,2 @@ dispatcher(types_1.MessageType.Unsubscribe, payload); | ||
} | ||
exports.createTransportListener = createTransportListener; | ||
function isDispatchAction(message) { | ||
@@ -204,0 +204,0 @@ return (message !== null && |
{ | ||
"name": "@shopify/app-bridge-core", | ||
"version": "1.3.1-snapshot-20240805023429", | ||
"version": "1.4.0-snapshot-20240812165150", | ||
"types": "index.d.ts", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeFromCollection = exports.addAndRemoveFromCollection = void 0; | ||
exports.addAndRemoveFromCollection = addAndRemoveFromCollection; | ||
exports.removeFromCollection = removeFromCollection; | ||
/** | ||
@@ -17,3 +18,2 @@ * Add an item to a collection, return a function that can then be used to | ||
} | ||
exports.addAndRemoveFromCollection = addAndRemoveFromCollection; | ||
/** | ||
@@ -36,2 +36,1 @@ * Remove the item from the collection. Optionally accepting a callback that is | ||
} | ||
exports.removeFromCollection = removeFromCollection; |
@@ -9,3 +9,3 @@ import type { MetaAction } from '../../actions/types'; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
@@ -12,0 +12,0 @@ }[] | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Action = exports.validateAction = exports.validateProps = exports.buttonSchemaWithId = exports.buttonSchema = void 0; | ||
exports.Action = exports.buttonSchemaWithId = exports.buttonSchema = void 0; | ||
exports.validateProps = validateProps; | ||
exports.validateAction = validateAction; | ||
var Button_1 = require("../../actions/Button"); | ||
@@ -8,21 +10,19 @@ Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return Button_1.Action; } }); | ||
var utils_1 = require("../utils"); | ||
exports.buttonSchema = type_validate_1.matchesObject({ | ||
disabled: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
label: type_validate_1.matchesString(), | ||
style: type_validate_1.makeOptional(type_validate_1.matchesEnum(Button_1.Style)), | ||
icon: type_validate_1.makeOptional(type_validate_1.matchesEnum(Button_1.Icon)), | ||
loading: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
plain: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
exports.buttonSchema = (0, type_validate_1.matchesObject)({ | ||
disabled: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
label: (0, type_validate_1.matchesString)(), | ||
style: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesEnum)(Button_1.Style)), | ||
icon: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesEnum)(Button_1.Icon)), | ||
loading: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
plain: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
}); | ||
exports.buttonSchemaWithId = type_validate_1.composeSchemas(type_validate_1.matchesObject({ | ||
id: type_validate_1.matchesString(), | ||
exports.buttonSchemaWithId = (0, type_validate_1.composeSchemas)((0, type_validate_1.matchesObject)({ | ||
id: (0, type_validate_1.matchesString)(), | ||
}), exports.buttonSchema); | ||
function validateProps(props) { | ||
return type_validate_1.validate(props, exports.buttonSchema); | ||
return (0, type_validate_1.validate)(props, exports.buttonSchema); | ||
} | ||
exports.validateProps = validateProps; | ||
function validateAction(action) { | ||
var validator = utils_1.createActionValidator(Button_1.Action, action.type === Button_1.Action.UPDATE ? exports.buttonSchema : undefined, true, true); | ||
return type_validate_1.validate(action, validator); | ||
var validator = (0, utils_1.createActionValidator)(Button_1.Action, action.type === Button_1.Action.UPDATE ? exports.buttonSchema : undefined, true, true); | ||
return (0, type_validate_1.validate)(action, validator); | ||
} | ||
exports.validateAction = validateAction; |
@@ -7,3 +7,3 @@ import { ButtonGroupAction, Action } from '../../actions/ButtonGroup'; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
@@ -14,5 +14,5 @@ }[] | undefined; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
}[] | undefined; | ||
export { Action }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Action = exports.validateAction = exports.validateProps = exports.buttonGroupSchema = void 0; | ||
exports.Action = exports.buttonGroupSchema = void 0; | ||
exports.validateProps = validateProps; | ||
exports.validateAction = validateAction; | ||
var ButtonGroup_1 = require("../../actions/ButtonGroup"); | ||
@@ -9,13 +11,11 @@ Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return ButtonGroup_1.Action; } }); | ||
var button_1 = require("./button"); | ||
exports.buttonGroupSchema = type_validate_1.composeSchemas(button_1.buttonSchema, type_validate_1.matchesObject({ | ||
buttons: type_validate_1.matchesArray(type_validate_1.makeOptional(button_1.buttonSchemaWithId)), | ||
exports.buttonGroupSchema = (0, type_validate_1.composeSchemas)(button_1.buttonSchema, (0, type_validate_1.matchesObject)({ | ||
buttons: (0, type_validate_1.matchesArray)((0, type_validate_1.makeOptional)(button_1.buttonSchemaWithId)), | ||
})); | ||
function validateProps(props) { | ||
return type_validate_1.validate(props, exports.buttonGroupSchema); | ||
return (0, type_validate_1.validate)(props, exports.buttonGroupSchema); | ||
} | ||
exports.validateProps = validateProps; | ||
function validateAction(action) { | ||
var validator = utils_1.createActionValidator(ButtonGroup_1.Action, exports.buttonGroupSchema, true, true); | ||
return type_validate_1.validate(action, validator); | ||
var validator = (0, utils_1.createActionValidator)(ButtonGroup_1.Action, exports.buttonGroupSchema, true, true); | ||
return (0, type_validate_1.validate)(action, validator); | ||
} | ||
exports.validateAction = validateAction; |
@@ -8,3 +8,3 @@ import type { MetaAction } from '../../actions/types'; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
@@ -11,0 +11,0 @@ }[] | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Action = exports.validateAction = exports.validateProps = exports.contextSaveBarSchema = void 0; | ||
exports.Action = exports.contextSaveBarSchema = void 0; | ||
exports.validateProps = validateProps; | ||
exports.validateAction = validateAction; | ||
var type_validate_1 = require("../type-validate"); | ||
@@ -8,21 +10,19 @@ var ContextualSaveBar_1 = require("../../actions/ContextualSaveBar"); | ||
var utils_1 = require("../utils"); | ||
exports.contextSaveBarSchema = type_validate_1.makeOptional(type_validate_1.matchesObject({ | ||
fullWidth: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
discardAction: type_validate_1.makeOptional(type_validate_1.matchesObject({ | ||
disabled: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
discardConfirmationModal: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
exports.contextSaveBarSchema = (0, type_validate_1.makeOptional)((0, type_validate_1.matchesObject)({ | ||
fullWidth: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
discardAction: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesObject)({ | ||
disabled: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
discardConfirmationModal: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
})), | ||
saveAction: type_validate_1.makeOptional(type_validate_1.matchesObject({ | ||
disabled: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
saveAction: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesObject)({ | ||
disabled: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
})), | ||
leaveConfirmationDisable: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
leaveConfirmationDisable: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
})); | ||
function validateProps(props) { | ||
return type_validate_1.validate(props, exports.contextSaveBarSchema); | ||
return (0, type_validate_1.validate)(props, exports.contextSaveBarSchema); | ||
} | ||
exports.validateProps = validateProps; | ||
function validateAction(action) { | ||
var validator = utils_1.createActionValidator(ContextualSaveBar_1.Action, exports.contextSaveBarSchema); | ||
return type_validate_1.validate(action, validator); | ||
var validator = (0, utils_1.createActionValidator)(ContextualSaveBar_1.Action, exports.contextSaveBarSchema); | ||
return (0, type_validate_1.validate)(action, validator); | ||
} | ||
exports.validateAction = validateAction; |
@@ -8,3 +8,3 @@ import type { MetaAction } from '../../actions/types'; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
@@ -11,0 +11,0 @@ }[] | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Action = exports.validateAction = exports.validateProps = exports.feedbackModalSchema = void 0; | ||
exports.Action = exports.feedbackModalSchema = void 0; | ||
exports.validateProps = validateProps; | ||
exports.validateAction = validateAction; | ||
var FeedbackModal_1 = require("../../actions/FeedbackModal"); | ||
@@ -8,18 +10,16 @@ Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return FeedbackModal_1.Action; } }); | ||
var utils_1 = require("../utils"); | ||
exports.feedbackModalSchema = type_validate_1.matchesObject({ | ||
formId: type_validate_1.matchesPositiveInteger(), | ||
exports.feedbackModalSchema = (0, type_validate_1.matchesObject)({ | ||
formId: (0, type_validate_1.matchesPositiveInteger)(), | ||
}); | ||
function validateProps(props) { | ||
return type_validate_1.validate(props, exports.feedbackModalSchema); | ||
return (0, type_validate_1.validate)(props, exports.feedbackModalSchema); | ||
} | ||
exports.validateProps = validateProps; | ||
function validateAction(action) { | ||
switch (action.type) { | ||
case FeedbackModal_1.Action.OPEN: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(FeedbackModal_1.Action, exports.feedbackModalSchema, true)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(FeedbackModal_1.Action, exports.feedbackModalSchema, true)); | ||
case FeedbackModal_1.Action.CLOSE: | ||
default: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(FeedbackModal_1.Action)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(FeedbackModal_1.Action)); | ||
} | ||
} | ||
exports.validateAction = validateAction; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Action = exports.validateAction = void 0; | ||
exports.Action = void 0; | ||
exports.validateAction = validateAction; | ||
var LeaveConfirmation_1 = require("../../actions/LeaveConfirmation"); | ||
@@ -9,5 +10,4 @@ Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return LeaveConfirmation_1.Action; } }); | ||
function validateAction(action) { | ||
var validator = utils_1.createActionValidator(LeaveConfirmation_1.Action); | ||
return type_validate_1.validate(action, validator); | ||
var validator = (0, utils_1.createActionValidator)(LeaveConfirmation_1.Action); | ||
return (0, type_validate_1.validate)(action, validator); | ||
} | ||
exports.validateAction = validateAction; |
@@ -9,3 +9,3 @@ import { Action } from '../../actions/Link/AppLink'; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
@@ -12,0 +12,0 @@ }[] | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Action = exports.validateAction = exports.validateProps = exports.linkActionSchema = exports.linkPropsSchema = void 0; | ||
exports.Action = exports.linkActionSchema = exports.linkPropsSchema = void 0; | ||
exports.validateProps = validateProps; | ||
exports.validateAction = validateAction; | ||
var AppLink_1 = require("../../actions/Link/AppLink"); | ||
@@ -13,19 +15,17 @@ Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return AppLink_1.Action; } }); | ||
})(AllowedRedirectType || (AllowedRedirectType = {})); | ||
exports.linkPropsSchema = type_validate_1.matchesObject({ | ||
label: type_validate_1.matchesString(), | ||
exports.linkPropsSchema = (0, type_validate_1.matchesObject)({ | ||
label: (0, type_validate_1.matchesString)(), | ||
destination: utils_1.relativeUrlSchema, | ||
redirectType: type_validate_1.matchesEnum(AllowedRedirectType), | ||
redirectType: (0, type_validate_1.matchesEnum)(AllowedRedirectType), | ||
}); | ||
exports.linkActionSchema = type_validate_1.matchesObject({ | ||
label: type_validate_1.matchesString(), | ||
exports.linkActionSchema = (0, type_validate_1.matchesObject)({ | ||
label: (0, type_validate_1.matchesString)(), | ||
destination: utils_1.relativePathSchema, | ||
redirectType: type_validate_1.matchesEnum(AllowedRedirectType), | ||
redirectType: (0, type_validate_1.matchesEnum)(AllowedRedirectType), | ||
}); | ||
function validateProps(props) { | ||
return type_validate_1.validate(props, exports.linkPropsSchema); | ||
return (0, type_validate_1.validate)(props, exports.linkPropsSchema); | ||
} | ||
exports.validateProps = validateProps; | ||
function validateAction(action) { | ||
return type_validate_1.validate(action, utils_1.createActionValidator(AppLink_1.Action, exports.linkActionSchema, true, true)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(AppLink_1.Action, exports.linkActionSchema, true, true)); | ||
} | ||
exports.validateAction = validateAction; |
@@ -7,5 +7,5 @@ import type { NavigationMenuAction } from '../../actions/Menu/NavigationMenu'; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
}[] | undefined; | ||
export declare function validateAction(action: NavigationMenuAction | ChannelMenuAction): ValidationError[] | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateAction = exports.validateProps = void 0; | ||
exports.validateProps = validateProps; | ||
exports.validateAction = validateAction; | ||
var NavigationMenu_1 = require("../../actions/Menu/NavigationMenu"); | ||
@@ -10,3 +11,3 @@ var ChannelMenu_1 = require("../../actions/Menu/ChannelMenu"); | ||
var link_1 = require("./link"); | ||
var linkOptionsValidator = type_validate_1.matchesObject({ id: type_validate_1.matchesString(), options: link_1.linkPropsSchema }); | ||
var linkOptionsValidator = (0, type_validate_1.matchesObject)({ id: (0, type_validate_1.matchesString)(), options: link_1.linkPropsSchema }); | ||
function activeLinkError(value) { | ||
@@ -22,14 +23,14 @@ return [ | ||
function getOptionsSchema(options) { | ||
var baseSchema = type_validate_1.matchesObject({ | ||
items: type_validate_1.makeOptional(type_validate_1.matchesArray(linkOptionsValidator)), | ||
active: type_validate_1.makeOptional(linkOptionsValidator), | ||
var baseSchema = (0, type_validate_1.matchesObject)({ | ||
items: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesArray)(linkOptionsValidator)), | ||
active: (0, type_validate_1.makeOptional)(linkOptionsValidator), | ||
}); | ||
var items = options.items, active = options.active; | ||
if (items && active) { | ||
var activeItemSchema = type_validate_1.matchesObject({ | ||
active: type_validate_1.composeSchemas(linkOptionsValidator, function (value) { | ||
var activeItemSchema = (0, type_validate_1.matchesObject)({ | ||
active: (0, type_validate_1.composeSchemas)(linkOptionsValidator, function (value) { | ||
return items.find(function (item) { return item.id === value.id; }) ? undefined : activeLinkError(value); | ||
}), | ||
}); | ||
return type_validate_1.composeSchemas(baseSchema, activeItemSchema); | ||
return (0, type_validate_1.composeSchemas)(baseSchema, activeItemSchema); | ||
} | ||
@@ -39,10 +40,10 @@ return baseSchema; | ||
function getPayloadSchema(payload) { | ||
var baseSchema = type_validate_1.matchesObject({ | ||
items: type_validate_1.makeOptional(type_validate_1.matchesArray(link_1.linkActionSchema)), | ||
active: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
var baseSchema = (0, type_validate_1.matchesObject)({ | ||
items: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesArray)(link_1.linkActionSchema)), | ||
active: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
}); | ||
var items = payload.items, active = payload.active; | ||
if (items && active) { | ||
var activeItemSchema = type_validate_1.matchesObject({ | ||
active: type_validate_1.composeSchemas(type_validate_1.matchesString(), function (value) { | ||
var activeItemSchema = (0, type_validate_1.matchesObject)({ | ||
active: (0, type_validate_1.composeSchemas)((0, type_validate_1.matchesString)(), function (value) { | ||
return items.find(function (item) { return item.id === value; }) | ||
@@ -53,3 +54,3 @@ ? undefined | ||
}); | ||
return type_validate_1.composeSchemas(baseSchema, activeItemSchema); | ||
return (0, type_validate_1.composeSchemas)(baseSchema, activeItemSchema); | ||
} | ||
@@ -59,13 +60,11 @@ return baseSchema; | ||
function validateProps(props) { | ||
var result = type_validate_1.validate(props, getOptionsSchema(props)); | ||
var result = (0, type_validate_1.validate)(props, getOptionsSchema(props)); | ||
return result; | ||
} | ||
exports.validateProps = validateProps; | ||
function validateAction(action) { | ||
var actionType = NavigationMenu_1.Action; | ||
if (helper_1.findMatchInEnum(ChannelMenu_1.Action, action.type)) { | ||
if ((0, helper_1.findMatchInEnum)(ChannelMenu_1.Action, action.type)) { | ||
actionType = ChannelMenu_1.Action; | ||
} | ||
return type_validate_1.validate(action, utils_1.createActionValidator(actionType, getPayloadSchema(action.payload), true, false)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(actionType, getPayloadSchema(action.payload), true, false)); | ||
} | ||
exports.validateAction = validateAction; |
@@ -7,3 +7,3 @@ import type { MetaAction } from '../../actions/types'; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
@@ -10,0 +10,0 @@ }[] | undefined; |
@@ -14,3 +14,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Action = exports.validateAction = exports.validateProps = void 0; | ||
exports.Action = void 0; | ||
exports.validateProps = validateProps; | ||
exports.validateAction = validateAction; | ||
var type_validate_1 = require("../type-validate"); | ||
@@ -33,7 +35,7 @@ var utils_1 = require("../utils"); | ||
value: localOrigin, | ||
message: "Provided value for app origin: `" + localOrigin + "` is invalid", | ||
message: "Provided value for app origin: `".concat(localOrigin, "` is invalid"), | ||
}, | ||
]; | ||
} | ||
var isSafeSrc = safe_redirect_1.isSafe(value, { | ||
var isSafeSrc = (0, safe_redirect_1.isSafe)(value, { | ||
requireAbsolute: true, | ||
@@ -49,3 +51,3 @@ requireSSL: true, | ||
value: value, | ||
message: "Provided URL origin does not match app origin `" + hostName + "`", | ||
message: "Provided URL origin does not match app origin `".concat(hostName, "`"), | ||
}, | ||
@@ -61,8 +63,8 @@ ]; | ||
} | ||
var message = "expected:" + values.map(function (val) { return "`" + val + "`"; }).join(' or '); | ||
var message = "expected:".concat(values.map(function (val) { return "`".concat(val, "`"); }).join(' or ')); | ||
if (value === Modal_1.Size.Full) { | ||
message += ". Size `" + value + "` is deprecated as of version 1.6.5 and will fall back to size `medium`"; | ||
message += ". Size `".concat(value, "` is deprecated as of version 1.6.5 and will fall back to size `medium`"); | ||
} | ||
if (value === Modal_1.Size.Auto) { | ||
message += ". Size `" + value + "` is deprecated as of version 1.12.x and will fall back to size `medium`. Use the `setUpModalAutoSizing` utility from `app-bridge` instead"; | ||
message += ". Size `".concat(value, "` is deprecated as of version 1.12.x and will fall back to size `medium`. Use the `setUpModalAutoSizing` utility from `app-bridge` instead"); | ||
} | ||
@@ -80,29 +82,28 @@ return [ | ||
if (props === void 0) { props = {}; } | ||
var baseModalSchema = type_validate_1.matchesObject({ | ||
title: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
footer: type_validate_1.makeOptional(type_validate_1.matchesObject({ | ||
buttons: type_validate_1.matchesObject({ | ||
primary: type_validate_1.makeOptional(button_1.buttonSchemaWithId), | ||
secondary: type_validate_1.makeOptional(type_validate_1.matchesArray(button_1.buttonSchemaWithId)), | ||
var baseModalSchema = (0, type_validate_1.matchesObject)({ | ||
title: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
footer: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesObject)({ | ||
buttons: (0, type_validate_1.matchesObject)({ | ||
primary: (0, type_validate_1.makeOptional)(button_1.buttonSchemaWithId), | ||
secondary: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesArray)(button_1.buttonSchemaWithId)), | ||
}), | ||
})), | ||
size: type_validate_1.makeOptional(matchesSize()), | ||
size: (0, type_validate_1.makeOptional)(matchesSize()), | ||
}); | ||
if (Modal_1.isIframeModal(props)) { | ||
if ((0, Modal_1.isIframeModal)(props)) { | ||
if (props.url) { | ||
var urlSchema = type_validate_1.matchesObject({ | ||
url: type_validate_1.composeSchemas(type_validate_1.matchesString(), function (value) { | ||
var urlSchema = (0, type_validate_1.matchesObject)({ | ||
url: (0, type_validate_1.composeSchemas)((0, type_validate_1.matchesString)(), function (value) { | ||
return localOrigin ? matchesSafeOrigin(value, localOrigin) : undefined; | ||
}), | ||
}); | ||
return type_validate_1.composeSchemas(baseModalSchema, urlSchema); | ||
return (0, type_validate_1.composeSchemas)(baseModalSchema, urlSchema); | ||
} | ||
return type_validate_1.composeSchemas(baseModalSchema, utils_1.relativePathSchema); | ||
return (0, type_validate_1.composeSchemas)(baseModalSchema, utils_1.relativePathSchema); | ||
} | ||
return type_validate_1.composeSchemas(baseModalSchema, type_validate_1.matchesObject({ message: type_validate_1.matchesString() })); | ||
return (0, type_validate_1.composeSchemas)(baseModalSchema, (0, type_validate_1.matchesObject)({ message: (0, type_validate_1.matchesString)() })); | ||
} | ||
function validateProps(props, localOrigin) { | ||
return type_validate_1.validate(props, getModalSchema(props, localOrigin)); | ||
return (0, type_validate_1.validate)(props, getModalSchema(props, localOrigin)); | ||
} | ||
exports.validateProps = validateProps; | ||
function validateAction(action, localOrigin) { | ||
@@ -113,12 +114,11 @@ var schema = getModalSchema(action.payload, localOrigin); | ||
case Modal_1.Action.UPDATE: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(Modal_1.Action, schema, true, action.type === Modal_1.Action.UPDATE)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(Modal_1.Action, schema, true, action.type === Modal_1.Action.UPDATE)); | ||
case Modal_1.Action.FOOTER_BUTTON_CLICK: | ||
return button_1.validateAction(__assign(__assign({}, action), { type: Button_1.Action.CLICK })); | ||
return (0, button_1.validateAction)(__assign(__assign({}, action), { type: Button_1.Action.CLICK })); | ||
case Modal_1.Action.FOOTER_BUTTON_UPDATE: | ||
return button_1.validateAction(__assign(__assign({}, action), { type: Button_1.Action.UPDATE })); | ||
return (0, button_1.validateAction)(__assign(__assign({}, action), { type: Button_1.Action.UPDATE })); | ||
case Modal_1.Action.CLOSE: | ||
default: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(Modal_1.Action)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(Modal_1.Action)); | ||
} | ||
} | ||
exports.validateAction = validateAction; |
@@ -12,4 +12,4 @@ import type { MetaAction } from '../../actions/types'; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
}[] | undefined; |
@@ -15,3 +15,7 @@ "use strict"; | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -34,3 +38,5 @@ if (k2 === undefined) k2 = k; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateAction = exports.getSectionSchema = exports.matchesAbsolutePath = void 0; | ||
exports.matchesAbsolutePath = matchesAbsolutePath; | ||
exports.getSectionSchema = getSectionSchema; | ||
exports.validateAction = validateAction; | ||
var History = __importStar(require("../../actions/Navigation/History")); | ||
@@ -51,3 +57,2 @@ var Redirect = __importStar(require("../../actions/Navigation/Redirect")); | ||
} | ||
exports.matchesAbsolutePath = matchesAbsolutePath; | ||
function getSectionSchema(payload) { | ||
@@ -59,16 +64,15 @@ var isProductVariant = payload && | ||
var resourceSchema = { | ||
create: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
id: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
create: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
id: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
}; | ||
var productVariantSchema = __assign(__assign({}, resourceSchema), { variant: type_validate_1.makeOptional(type_validate_1.matchesObject(resourceSchema)) }); | ||
return type_validate_1.matchesObject({ | ||
section: type_validate_1.matchesObject({ | ||
name: type_validate_1.matchesEnum(Redirect.ResourceType), | ||
resource: type_validate_1.makeOptional(type_validate_1.matchesObject(isProductVariant ? productVariantSchema : resourceSchema)), | ||
var productVariantSchema = __assign(__assign({}, resourceSchema), { variant: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesObject)(resourceSchema)) }); | ||
return (0, type_validate_1.matchesObject)({ | ||
section: (0, type_validate_1.matchesObject)({ | ||
name: (0, type_validate_1.matchesEnum)(Redirect.ResourceType), | ||
resource: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesObject)(isProductVariant ? productVariantSchema : resourceSchema)), | ||
}), | ||
}); | ||
} | ||
exports.getSectionSchema = getSectionSchema; | ||
function validateAction(action) { | ||
var newContextSchema = type_validate_1.matchesObject({ newContext: type_validate_1.makeOptional(type_validate_1.matchesBoolean()) }); | ||
var newContextSchema = (0, type_validate_1.matchesObject)({ newContext: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()) }); | ||
var actionType = Redirect.Action; | ||
@@ -86,15 +90,14 @@ var schema; | ||
case Redirect.Action.REMOTE: | ||
schema = type_validate_1.composeSchemas(type_validate_1.matchesObject({ | ||
url: type_validate_1.composeSchemas(type_validate_1.matchesString(), function (value) { return matchesAbsolutePath(value); }), | ||
schema = (0, type_validate_1.composeSchemas)((0, type_validate_1.matchesObject)({ | ||
url: (0, type_validate_1.composeSchemas)((0, type_validate_1.matchesString)(), function (value) { return matchesAbsolutePath(value); }), | ||
}), newContextSchema); | ||
break; | ||
case Redirect.Action.ADMIN_PATH: | ||
schema = type_validate_1.composeSchemas(utils_1.relativePathSchema, newContextSchema); | ||
schema = (0, type_validate_1.composeSchemas)(utils_1.relativePathSchema, newContextSchema); | ||
break; | ||
case Redirect.Action.ADMIN_SECTION: | ||
schema = type_validate_1.composeSchemas(getSectionSchema(action.payload), newContextSchema); | ||
schema = (0, type_validate_1.composeSchemas)(getSectionSchema(action.payload), newContextSchema); | ||
break; | ||
} | ||
return type_validate_1.validate(action, utils_1.createActionValidator(actionType, schema)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(actionType, schema)); | ||
} | ||
exports.validateAction = validateAction; |
@@ -9,3 +9,3 @@ import { PickerAction, Action } from '../../actions/Picker'; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
@@ -12,0 +12,0 @@ }[] | undefined; |
@@ -14,3 +14,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Action = exports.validateAction = exports.validateProps = void 0; | ||
exports.Action = void 0; | ||
exports.validateProps = validateProps; | ||
exports.validateAction = validateAction; | ||
var Picker_1 = require("../../actions/Picker"); | ||
@@ -20,62 +22,62 @@ Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return Picker_1.Action; } }); | ||
var utils_1 = require("../utils"); | ||
var resourceBadge = type_validate_1.matchesObject({ | ||
content: type_validate_1.matchesString(), | ||
id: type_validate_1.matchesString(), | ||
progress: type_validate_1.matchesEnum(Picker_1.ALL_BADGE_PROGRESSES), | ||
status: type_validate_1.matchesEnum(Picker_1.ALL_BADGE_STATUSES), | ||
var resourceBadge = (0, type_validate_1.matchesObject)({ | ||
content: (0, type_validate_1.matchesString)(), | ||
id: (0, type_validate_1.matchesString)(), | ||
progress: (0, type_validate_1.matchesEnum)(Picker_1.ALL_BADGE_PROGRESSES), | ||
status: (0, type_validate_1.matchesEnum)(Picker_1.ALL_BADGE_STATUSES), | ||
}); | ||
var resourceMedia = type_validate_1.matchesObject({ | ||
accessibilityLabel: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
alt: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
initials: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
kind: type_validate_1.makeOptional(type_validate_1.matchesEnum(Picker_1.ALL_MEDIA_KINDS)), | ||
name: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
source: type_validate_1.matchesString(), | ||
var resourceMedia = (0, type_validate_1.matchesObject)({ | ||
accessibilityLabel: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
alt: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
initials: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
kind: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesEnum)(Picker_1.ALL_MEDIA_KINDS)), | ||
name: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
source: (0, type_validate_1.matchesString)(), | ||
}); | ||
var sharedResourceSchema = { | ||
accessibilityLabel: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
badges: type_validate_1.makeOptional(type_validate_1.matchesArray(resourceBadge)), | ||
disabled: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
id: type_validate_1.matchesString(), | ||
loading: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
media: type_validate_1.makeOptional(resourceMedia), | ||
name: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
caption: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
selectable: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
accessibilityLabel: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
badges: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesArray)(resourceBadge)), | ||
disabled: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
id: (0, type_validate_1.matchesString)(), | ||
loading: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
media: (0, type_validate_1.makeOptional)(resourceMedia), | ||
name: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
caption: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
selectable: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
}; | ||
var resourceOption = type_validate_1.matchesObject(__assign({}, sharedResourceSchema)); | ||
var resourceSelectionSchema = type_validate_1.matchesArray(type_validate_1.matchesObject(__assign(__assign({}, sharedResourceSchema), { options: type_validate_1.makeOptional(type_validate_1.matchesArray(resourceOption)) }))); | ||
var resourceName = type_validate_1.matchesObject({ | ||
plural: type_validate_1.matchesString(), | ||
singular: type_validate_1.matchesString(), | ||
var resourceOption = (0, type_validate_1.matchesObject)(__assign({}, sharedResourceSchema)); | ||
var resourceSelectionSchema = (0, type_validate_1.matchesArray)((0, type_validate_1.matchesObject)(__assign(__assign({}, sharedResourceSchema), { options: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesArray)(resourceOption)) }))); | ||
var resourceName = (0, type_validate_1.matchesObject)({ | ||
plural: (0, type_validate_1.matchesString)(), | ||
singular: (0, type_validate_1.matchesString)(), | ||
}); | ||
var pickerOptions = type_validate_1.matchesObject({ | ||
canLoadMore: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
emptySearchLabel: type_validate_1.makeOptional(type_validate_1.matchesObject({ | ||
title: type_validate_1.matchesString(), | ||
description: type_validate_1.matchesString(), | ||
withIllustration: type_validate_1.matchesBoolean(), | ||
var pickerOptions = (0, type_validate_1.matchesObject)({ | ||
canLoadMore: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
emptySearchLabel: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesObject)({ | ||
title: (0, type_validate_1.matchesString)(), | ||
description: (0, type_validate_1.matchesString)(), | ||
withIllustration: (0, type_validate_1.matchesBoolean)(), | ||
})), | ||
items: type_validate_1.makeOptional(resourceSelectionSchema), | ||
loading: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
loadingMore: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
maxSelectable: type_validate_1.makeOptional(type_validate_1.matchesPositiveInteger()), | ||
primaryActionLabel: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
searchQuery: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
searchQueryPlaceholder: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
secondaryActionLabel: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
selectedItems: type_validate_1.makeOptional(type_validate_1.matchesArray(type_validate_1.matchesObject(sharedResourceSchema))), | ||
title: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
verticalAlignment: type_validate_1.makeOptional(type_validate_1.matchesEnum(Picker_1.ALL_RESOURCE_VERTICAL_ALIGNMENT)), | ||
allowEmptySelection: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
resourceName: type_validate_1.makeOptional(resourceName), | ||
items: (0, type_validate_1.makeOptional)(resourceSelectionSchema), | ||
loading: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
loadingMore: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
maxSelectable: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesPositiveInteger)()), | ||
primaryActionLabel: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
searchQuery: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
searchQueryPlaceholder: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
secondaryActionLabel: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
selectedItems: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesArray)((0, type_validate_1.matchesObject)(sharedResourceSchema))), | ||
title: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
verticalAlignment: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesEnum)(Picker_1.ALL_RESOURCE_VERTICAL_ALIGNMENT)), | ||
allowEmptySelection: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
resourceName: (0, type_validate_1.makeOptional)(resourceName), | ||
}); | ||
var pickerActionSchema = type_validate_1.matchesObject({ | ||
options: type_validate_1.makeOptional(resourceSelectionSchema), | ||
var pickerActionSchema = (0, type_validate_1.matchesObject)({ | ||
options: (0, type_validate_1.makeOptional)(resourceSelectionSchema), | ||
}); | ||
var selectionSchema = type_validate_1.matchesObject({ | ||
var selectionSchema = (0, type_validate_1.matchesObject)({ | ||
selectedItems: resourceSelectionSchema, | ||
}); | ||
var searchSchema = type_validate_1.matchesObject({ | ||
searchQuery: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
var searchSchema = (0, type_validate_1.matchesObject)({ | ||
searchQuery: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
}); | ||
@@ -86,5 +88,4 @@ /** | ||
function validateProps(props) { | ||
return type_validate_1.validate(props, pickerOptions); | ||
return (0, type_validate_1.validate)(props, pickerOptions); | ||
} | ||
exports.validateProps = validateProps; | ||
/** | ||
@@ -97,14 +98,13 @@ * @unstable This API may be updated without warning in the future | ||
case Picker_1.Action.OPEN: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(Picker_1.Action, pickerActionSchema, false, true)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(Picker_1.Action, pickerActionSchema, false, true)); | ||
case Picker_1.Action.SELECT: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(Picker_1.Action, selectionSchema, true, true)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(Picker_1.Action, selectionSchema, true, true)); | ||
case Picker_1.Action.SEARCH: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(Picker_1.Action, searchSchema, true, true)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(Picker_1.Action, searchSchema, true, true)); | ||
case Picker_1.Action.CANCEL: | ||
case Picker_1.Action.LOAD_MORE: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(Picker_1.Action)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(Picker_1.Action)); | ||
default: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(Picker_1.Action)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(Picker_1.Action)); | ||
} | ||
} | ||
exports.validateAction = validateAction; |
@@ -6,3 +6,3 @@ import { ResourcePickerAction, Action } from '../../actions/ResourcePicker'; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
@@ -9,0 +9,0 @@ }[] | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Action = exports.validateAction = exports.validateProps = void 0; | ||
exports.Action = void 0; | ||
exports.validateProps = validateProps; | ||
exports.validateAction = validateAction; | ||
var ResourcePicker_1 = require("../../actions/ResourcePicker"); | ||
@@ -8,29 +10,28 @@ Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return ResourcePicker_1.Action; } }); | ||
var utils_1 = require("../utils"); | ||
var resourceSelectionSchema = type_validate_1.matchesArray(type_validate_1.matchesObject({ | ||
id: type_validate_1.matchesString(), | ||
var resourceSelectionSchema = (0, type_validate_1.matchesArray)((0, type_validate_1.matchesObject)({ | ||
id: (0, type_validate_1.matchesString)(), | ||
})); | ||
var resourcePickerOptions = type_validate_1.matchesObject({ | ||
initialQuery: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
filterQuery: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
initialSelectionIds: type_validate_1.makeOptional(resourceSelectionSchema), | ||
selectMultiple: type_validate_1.makeOptional(type_validate_1.oneOf(type_validate_1.matchesBoolean(), type_validate_1.matchesPositiveInteger())), | ||
showHidden: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
showVariants: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
showDraft: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
showArchived: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
showDraftBadge: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
showArchivedBadge: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
actionVerb: type_validate_1.makeOptional(type_validate_1.matchesEnum(ResourcePicker_1.ActionVerb)), | ||
var resourcePickerOptions = (0, type_validate_1.matchesObject)({ | ||
initialQuery: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
filterQuery: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
initialSelectionIds: (0, type_validate_1.makeOptional)(resourceSelectionSchema), | ||
selectMultiple: (0, type_validate_1.makeOptional)((0, type_validate_1.oneOf)((0, type_validate_1.matchesBoolean)(), (0, type_validate_1.matchesPositiveInteger)())), | ||
showHidden: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
showVariants: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
showDraft: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
showArchived: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
showDraftBadge: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
showArchivedBadge: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
actionVerb: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesEnum)(ResourcePicker_1.ActionVerb)), | ||
}); | ||
var resourcePickerActionSchema = type_validate_1.matchesObject({ | ||
resourceType: type_validate_1.matchesEnum(ResourcePicker_1.ResourceType), | ||
options: type_validate_1.makeOptional(resourcePickerOptions), | ||
var resourcePickerActionSchema = (0, type_validate_1.matchesObject)({ | ||
resourceType: (0, type_validate_1.matchesEnum)(ResourcePicker_1.ResourceType), | ||
options: (0, type_validate_1.makeOptional)(resourcePickerOptions), | ||
}); | ||
var selectionSchema = type_validate_1.matchesObject({ | ||
var selectionSchema = (0, type_validate_1.matchesObject)({ | ||
selection: resourceSelectionSchema, | ||
}); | ||
function validateProps(props) { | ||
return type_validate_1.validate(props, resourcePickerOptions); | ||
return (0, type_validate_1.validate)(props, resourcePickerOptions); | ||
} | ||
exports.validateProps = validateProps; | ||
function validateAction(action) { | ||
@@ -40,11 +41,10 @@ switch (action.type) { | ||
case ResourcePicker_1.Action.OPEN: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(ResourcePicker_1.Action, resourcePickerActionSchema, false, true)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(ResourcePicker_1.Action, resourcePickerActionSchema, false, true)); | ||
case ResourcePicker_1.Action.SELECT: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(ResourcePicker_1.Action, selectionSchema, true, true)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(ResourcePicker_1.Action, selectionSchema, true, true)); | ||
case ResourcePicker_1.Action.CANCEL: | ||
case ResourcePicker_1.Action.CLOSE: | ||
default: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(ResourcePicker_1.Action)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(ResourcePicker_1.Action)); | ||
} | ||
} | ||
exports.validateAction = validateAction; |
@@ -7,3 +7,3 @@ import { TitleBarAction, Action } from '../../actions/TitleBar'; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
@@ -10,0 +10,0 @@ }[] | undefined; |
@@ -14,3 +14,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Action = exports.validateAction = exports.validateProps = exports.titleBarSchema = void 0; | ||
exports.Action = exports.titleBarSchema = void 0; | ||
exports.validateProps = validateProps; | ||
exports.validateAction = validateAction; | ||
var TitleBar_1 = require("../../actions/TitleBar"); | ||
@@ -24,12 +26,12 @@ Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return TitleBar_1.Action; } }); | ||
var buttonGroup_1 = require("./buttonGroup"); | ||
var buttonSchemaWithId = type_validate_1.composeSchemas(button_1.buttonSchema, type_validate_1.matchesObject({ | ||
id: type_validate_1.matchesString(), | ||
var buttonSchemaWithId = (0, type_validate_1.composeSchemas)(button_1.buttonSchema, (0, type_validate_1.matchesObject)({ | ||
id: (0, type_validate_1.matchesString)(), | ||
})); | ||
exports.titleBarSchema = type_validate_1.matchesObject({ | ||
breadcrumbs: type_validate_1.makeOptional(button_1.buttonSchema), | ||
title: type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
buttons: type_validate_1.makeOptional(type_validate_1.matchesObject({ | ||
primary: type_validate_1.makeOptional(buttonSchemaWithId), | ||
secondary: type_validate_1.makeOptional(type_validate_1.matchesArray(type_validate_1.composeSchemas(buttonSchemaWithId, type_validate_1.matchesObject({ | ||
buttons: type_validate_1.makeOptional(type_validate_1.matchesArray(buttonSchemaWithId)), | ||
exports.titleBarSchema = (0, type_validate_1.matchesObject)({ | ||
breadcrumbs: (0, type_validate_1.makeOptional)(button_1.buttonSchema), | ||
title: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
buttons: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesObject)({ | ||
primary: (0, type_validate_1.makeOptional)(buttonSchemaWithId), | ||
secondary: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesArray)((0, type_validate_1.composeSchemas)(buttonSchemaWithId, (0, type_validate_1.matchesObject)({ | ||
buttons: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesArray)(buttonSchemaWithId)), | ||
})))), | ||
@@ -39,5 +41,4 @@ })), | ||
function validateProps(props) { | ||
return type_validate_1.validate(props, exports.titleBarSchema); | ||
return (0, type_validate_1.validate)(props, exports.titleBarSchema); | ||
} | ||
exports.validateProps = validateProps; | ||
function validateAction(action) { | ||
@@ -47,13 +48,12 @@ switch (action.type) { | ||
case TitleBar_1.Action.UPDATE: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(TitleBar_1.Action, exports.titleBarSchema, true, false)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(TitleBar_1.Action, exports.titleBarSchema, true, false)); | ||
case TitleBar_1.Action.BUTTON_CLICK: | ||
case TitleBar_1.Action.BREADCRUMBS_CLICK: | ||
return button_1.validateAction(__assign(__assign({}, action), { type: Button_1.Action.CLICK })); | ||
return (0, button_1.validateAction)(__assign(__assign({}, action), { type: Button_1.Action.CLICK })); | ||
case TitleBar_1.Action.BUTTON_UPDATE: | ||
case TitleBar_1.Action.BREADCRUMBS_UPDATE: | ||
return button_1.validateAction(__assign(__assign({}, action), { type: Button_1.Action.UPDATE })); | ||
return (0, button_1.validateAction)(__assign(__assign({}, action), { type: Button_1.Action.UPDATE })); | ||
case TitleBar_1.Action.BUTTON_GROUP_UPDATE: | ||
return buttonGroup_1.validateAction(__assign(__assign({}, action), { type: ButtonGroup_1.Action.UPDATE })); | ||
return (0, buttonGroup_1.validateAction)(__assign(__assign({}, action), { type: ButtonGroup_1.Action.UPDATE })); | ||
} | ||
} | ||
exports.validateAction = validateAction; |
@@ -9,5 +9,5 @@ import { Action } from '../../actions/Toast'; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
}[] | undefined; | ||
export { Action }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Action = exports.validateProps = exports.validateAction = exports.toastSchema = void 0; | ||
exports.Action = exports.toastSchema = void 0; | ||
exports.validateAction = validateAction; | ||
exports.validateProps = validateProps; | ||
var Toast_1 = require("../../actions/Toast"); | ||
@@ -8,8 +10,8 @@ Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return Toast_1.Action; } }); | ||
var utils_1 = require("../utils"); | ||
exports.toastSchema = type_validate_1.matchesObject({ | ||
message: type_validate_1.matchesString(), | ||
duration: type_validate_1.matchesPositiveInteger(), | ||
isError: type_validate_1.makeOptional(type_validate_1.matchesBoolean()), | ||
action: type_validate_1.makeOptional(type_validate_1.matchesObject({ | ||
content: type_validate_1.matchesString(), | ||
exports.toastSchema = (0, type_validate_1.matchesObject)({ | ||
message: (0, type_validate_1.matchesString)(), | ||
duration: (0, type_validate_1.matchesPositiveInteger)(), | ||
isError: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesBoolean)()), | ||
action: (0, type_validate_1.makeOptional)((0, type_validate_1.matchesObject)({ | ||
content: (0, type_validate_1.matchesString)(), | ||
})), | ||
@@ -20,11 +22,9 @@ }); | ||
case Toast_1.Action.SHOW: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(Toast_1.Action, exports.toastSchema, true)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(Toast_1.Action, exports.toastSchema, true)); | ||
default: | ||
return type_validate_1.validate(action, utils_1.createActionValidator(Toast_1.Action)); | ||
return (0, type_validate_1.validate)(action, (0, utils_1.createActionValidator)(Toast_1.Action)); | ||
} | ||
} | ||
exports.validateAction = validateAction; | ||
function validateProps(props) { | ||
return type_validate_1.validate(props, exports.toastSchema); | ||
return (0, type_validate_1.validate)(props, exports.toastSchema); | ||
} | ||
exports.validateProps = validateProps; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isSafe = void 0; | ||
exports.isSafe = isSafe; | ||
var constants_1 = require("../util/constants"); | ||
@@ -51,3 +51,2 @@ var FILE_URI_MATCH = /\/\/\//; | ||
} | ||
exports.isSafe = isSafe; | ||
function hostIsValid(url, allowedDomains, subdomains) { | ||
@@ -54,0 +53,0 @@ if (!subdomains.every(function (subdomain) { return subdomain.startsWith('.'); })) { |
@@ -7,3 +7,3 @@ export interface ErrorMessageCallback { | ||
} | ||
export declare type Schema<TMap extends Object = {}> = { | ||
export type Schema<TMap extends Object = {}> = { | ||
[key in keyof TMap]-?: Validator; | ||
@@ -36,3 +36,3 @@ }; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
@@ -48,4 +48,4 @@ }[] | undefined; | ||
error: string; | ||
message?: string | undefined; | ||
message?: string; | ||
value: any; | ||
}[] | undefined; |
@@ -13,9 +13,24 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validate = exports.matchesPositiveInteger = exports.matchesBoolean = exports.makeOptional = exports.matchesString = exports.matchesObject = exports.getErrors = exports.oneOf = exports.matchesArray = exports.matchesEnum = exports.composeSchemas = exports.TYPE_ERROR = void 0; | ||
exports.TYPE_ERROR = void 0; | ||
exports.composeSchemas = composeSchemas; | ||
exports.matchesEnum = matchesEnum; | ||
exports.matchesArray = matchesArray; | ||
exports.oneOf = oneOf; | ||
exports.getErrors = getErrors; | ||
exports.matchesObject = matchesObject; | ||
exports.matchesString = matchesString; | ||
exports.makeOptional = makeOptional; | ||
exports.matchesBoolean = matchesBoolean; | ||
exports.matchesPositiveInteger = matchesPositiveInteger; | ||
exports.validate = validate; | ||
exports.TYPE_ERROR = 'type_error_expected'; | ||
@@ -40,3 +55,2 @@ function composeSchemas() { | ||
} | ||
exports.composeSchemas = composeSchemas; | ||
/** | ||
@@ -50,3 +64,3 @@ * Returns a validator that matches values in the given enum | ||
var values = Object.keys(types).map(function (key) { return types[key]; }); | ||
var message = (options && options.message) || "expected:" + values.map(function (val) { return "`" + val + "`"; }).join(' or '); | ||
var message = (options && options.message) || "expected:".concat(values.map(function (val) { return "`".concat(val, "`"); }).join(' or ')); | ||
return values.includes(value) | ||
@@ -57,7 +71,6 @@ ? undefined | ||
} | ||
exports.matchesEnum = matchesEnum; | ||
function matchesArray(validator, options) { | ||
return function (value) { | ||
if (!Array.isArray(value)) { | ||
return constructErrors(value, exports.TYPE_ERROR + "_array", options); | ||
return constructErrors(value, "".concat(exports.TYPE_ERROR, "_array"), options); | ||
} | ||
@@ -71,3 +84,3 @@ if (!validator) { | ||
if (objectError) { | ||
errors = errors.concat(objectError.map(function (error) { return (__assign(__assign({}, error), { path: "['" + key + "']" + (error.path || '') })); })); | ||
errors = errors.concat(objectError.map(function (error) { return (__assign(__assign({}, error), { path: "['".concat(key, "']").concat(error.path || '') })); })); | ||
} | ||
@@ -78,3 +91,2 @@ }); | ||
} | ||
exports.matchesArray = matchesArray; | ||
function oneOf() { | ||
@@ -97,3 +109,2 @@ var validators = []; | ||
} | ||
exports.oneOf = oneOf; | ||
function constructErrors(value, error, options) { | ||
@@ -111,3 +122,3 @@ if (options === void 0) { options = { message: undefined }; } | ||
var value = key ? obj[key] : obj; | ||
var path = key ? "['" + key + "']" : undefined; | ||
var path = key ? "['".concat(key, "']") : undefined; | ||
var error = validator(value); | ||
@@ -117,12 +128,11 @@ if (!error) { | ||
} | ||
return error.map(function (errorObj) { return (__assign(__assign({}, errorObj), { path: "" + (path || '') + (errorObj.path || '') || undefined })); }); | ||
return error.map(function (errorObj) { return (__assign(__assign({}, errorObj), { path: "".concat(path || '').concat(errorObj.path || '') || undefined })); }); | ||
} | ||
exports.getErrors = getErrors; | ||
function matchesObject(schema, options) { | ||
return function (val) { | ||
if (typeof val !== 'object' || !val || Array.isArray(val)) { | ||
return constructErrors(val, exports.TYPE_ERROR + "_object", options); | ||
return constructErrors(val, "".concat(exports.TYPE_ERROR, "_object"), options); | ||
} | ||
var flattened = Object.keys(schema).reduce(function (acc, key) { | ||
return __spreadArray(__spreadArray([], acc), (getErrors(val, schema[key], key) || [])); | ||
return __spreadArray(__spreadArray([], acc, true), (getErrors(val, schema[key], key) || []), true); | ||
}, []); | ||
@@ -132,9 +142,7 @@ return flattened.length ? flattened : undefined; | ||
} | ||
exports.matchesObject = matchesObject; | ||
function matchesString(options) { | ||
return function (value) { | ||
return typeof value === 'string' ? undefined : constructErrors(value, exports.TYPE_ERROR + "_string", options); | ||
return typeof value === 'string' ? undefined : constructErrors(value, "".concat(exports.TYPE_ERROR, "_string"), options); | ||
}; | ||
} | ||
exports.matchesString = matchesString; | ||
function makeOptional(validator) { | ||
@@ -148,3 +156,2 @@ return function (value) { | ||
} | ||
exports.makeOptional = makeOptional; | ||
function matchesBoolean(options) { | ||
@@ -154,17 +161,14 @@ return function (value) { | ||
? undefined | ||
: constructErrors(value, exports.TYPE_ERROR + "_boolean", options); | ||
: constructErrors(value, "".concat(exports.TYPE_ERROR, "_boolean"), options); | ||
}; | ||
} | ||
exports.matchesBoolean = matchesBoolean; | ||
function matchesPositiveInteger(options) { | ||
return function (value) { | ||
return !Number.isInteger(value) || value < 0 | ||
? constructErrors(value, exports.TYPE_ERROR + "_integer", options) | ||
? constructErrors(value, "".concat(exports.TYPE_ERROR, "_integer"), options) | ||
: undefined; | ||
}; | ||
} | ||
exports.matchesPositiveInteger = matchesPositiveInteger; | ||
function validate(obj, validator) { | ||
return getErrors(obj, validator); | ||
} | ||
exports.validate = validate; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.relativePathSchema = exports.relativeUrlSchema = exports.isValidRelativePath = exports.createActionValidator = void 0; | ||
exports.relativePathSchema = exports.relativeUrlSchema = void 0; | ||
exports.createActionValidator = createActionValidator; | ||
exports.isValidRelativePath = isValidRelativePath; | ||
var type_validate_1 = require("./type-validate"); | ||
@@ -9,19 +11,17 @@ function createActionValidator(type, payloadSchema, payloadRequired, idRequired) { | ||
if (idRequired === void 0) { idRequired = false; } | ||
var idSchema = type_validate_1.matchesObject({ | ||
id: idRequired ? type_validate_1.matchesString() : type_validate_1.makeOptional(type_validate_1.matchesString()), | ||
var idSchema = (0, type_validate_1.matchesObject)({ | ||
id: idRequired ? (0, type_validate_1.matchesString)() : (0, type_validate_1.makeOptional)((0, type_validate_1.matchesString)()), | ||
}); | ||
var schema = payloadSchema ? type_validate_1.composeSchemas(idSchema, payloadSchema) : idSchema; | ||
return type_validate_1.matchesObject({ | ||
type: type_validate_1.matchesEnum(type, { | ||
message: function (_, val) { return "The action type `" + val + "` is invalid or unsupported"; }, | ||
var schema = payloadSchema ? (0, type_validate_1.composeSchemas)(idSchema, payloadSchema) : idSchema; | ||
return (0, type_validate_1.matchesObject)({ | ||
type: (0, type_validate_1.matchesEnum)(type, { | ||
message: function (_, val) { return "The action type `".concat(val, "` is invalid or unsupported"); }, | ||
}), | ||
payload: payloadRequired ? schema : type_validate_1.makeOptional(schema), | ||
payload: payloadRequired ? schema : (0, type_validate_1.makeOptional)(schema), | ||
}); | ||
} | ||
exports.createActionValidator = createActionValidator; | ||
function isValidRelativePath(path) { | ||
return typeof path === 'string' && (path === '' || path.startsWith('/')); | ||
} | ||
exports.isValidRelativePath = isValidRelativePath; | ||
exports.relativeUrlSchema = type_validate_1.composeSchemas(type_validate_1.matchesString(), function (value) { | ||
exports.relativeUrlSchema = (0, type_validate_1.composeSchemas)((0, type_validate_1.matchesString)(), function (value) { | ||
return isValidRelativePath(value) | ||
@@ -31,4 +31,4 @@ ? undefined | ||
}); | ||
exports.relativePathSchema = type_validate_1.matchesObject({ | ||
exports.relativePathSchema = (0, type_validate_1.matchesObject)({ | ||
path: exports.relativeUrlSchema, | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12704
470359