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

@vtex/order-items

Package Overview
Dependencies
Maintainers
0
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vtex/order-items - npm Package Compare versions

Comparing version 0.6.7 to 0.7.0

12

dist/index.esm.js
/*!
* @vtex/order-items v0.6.7
* @vtex/order-items v0.7.0
* (c) VTEX

@@ -279,3 +279,3 @@ * Released under the MIT License.

const mutate = useMutateUpdateQuantity();
const updateItemTask = useCallback(({ items, orderFormItems, id, allowedOutdatedData, }) => {
const updateItemTask = useCallback(({ items, orderFormItems, id, allowedOutdatedData, splitItem, }) => {
return {

@@ -302,2 +302,3 @@ id,

allowedOutdatedData,
splitItem,
};

@@ -580,2 +581,3 @@ const { data, errors } = await mutate(mutationVariables);

allowedOutdatedData: options === null || options === void 0 ? void 0 : options.allowedOutdatedData,
splitItem: options === null || options === void 0 ? void 0 : options.splitItem,
orderItems: itemIndexInPreviousTask > -1

@@ -591,2 +593,3 @@ ? previousTaskItems.map((prevInput, prevInputIndex) => prevInputIndex === itemIndexInPreviousTask

allowedOutdatedData: options === null || options === void 0 ? void 0 : options.allowedOutdatedData,
splitItem: options === null || options === void 0 ? void 0 : options.splitItem,
orderItems: [{ uniqueId, quantity }],

@@ -606,2 +609,3 @@ };

allowedOutdatedData: options === null || options === void 0 ? void 0 : options.allowedOutdatedData,
splitItem: options === null || options === void 0 ? void 0 : options.splitItem,
}));

@@ -614,3 +618,3 @@ }, [enqueueTask, log, setOrderForm, updateItemsTask]);

const addItems = useCallback(async (items, options) => {
const { salesChannel, marketingData, allowedOutdatedData } = options !== null && options !== void 0 ? options : {};
const { salesChannel, marketingData, allowedOutdatedData, splitItem } = options !== null && options !== void 0 ? options : {};
const { newItems, updatedItems } = items.reduce((acc, item) => {

@@ -640,2 +644,3 @@ var _a;

allowedOutdatedData,
splitItem,
});

@@ -711,2 +716,3 @@ updatedItemsPromises.push(updatedItemPromise);

allowedOutdatedData: task.variables.allowedOutdatedData,
splitItem: task.variables.splitItem,
id: task.id,

@@ -713,0 +719,0 @@ }));

/*!
* @vtex/order-items v0.6.7
* @vtex/order-items v0.7.0
* (c) VTEX

@@ -26,5 +26,3 @@ * Released under the MIT License.

enumerable: true,
get: function () {
return e[k];
}
get: function () { return e[k]; }
});

@@ -34,3 +32,3 @@ }

}
n['default'] = e;
n["default"] = e;
return Object.freeze(n);

@@ -310,3 +308,3 @@ }

const mutate = useMutateUpdateQuantity();
const updateItemTask = React.useCallback(({ items, orderFormItems, id, allowedOutdatedData, }) => {
const updateItemTask = React.useCallback(({ items, orderFormItems, id, allowedOutdatedData, splitItem, }) => {
return {

@@ -333,2 +331,3 @@ id,

allowedOutdatedData,
splitItem,
};

@@ -611,2 +610,3 @@ const { data, errors } = await mutate(mutationVariables);

allowedOutdatedData: options === null || options === void 0 ? void 0 : options.allowedOutdatedData,
splitItem: options === null || options === void 0 ? void 0 : options.splitItem,
orderItems: itemIndexInPreviousTask > -1

@@ -622,2 +622,3 @@ ? previousTaskItems.map((prevInput, prevInputIndex) => prevInputIndex === itemIndexInPreviousTask

allowedOutdatedData: options === null || options === void 0 ? void 0 : options.allowedOutdatedData,
splitItem: options === null || options === void 0 ? void 0 : options.splitItem,
orderItems: [{ uniqueId, quantity }],

@@ -637,2 +638,3 @@ };

allowedOutdatedData: options === null || options === void 0 ? void 0 : options.allowedOutdatedData,
splitItem: options === null || options === void 0 ? void 0 : options.splitItem,
}));

@@ -645,3 +647,3 @@ }, [enqueueTask, log, setOrderForm, updateItemsTask]);

const addItems = React.useCallback(async (items, options) => {
const { salesChannel, marketingData, allowedOutdatedData } = options !== null && options !== void 0 ? options : {};
const { salesChannel, marketingData, allowedOutdatedData, splitItem } = options !== null && options !== void 0 ? options : {};
const { newItems, updatedItems } = items.reduce((acc, item) => {

@@ -671,2 +673,3 @@ var _a;

allowedOutdatedData,
splitItem,
});

@@ -742,2 +745,3 @@ updatedItemsPromises.push(updatedItemPromise);

allowedOutdatedData: task.variables.allowedOutdatedData,
splitItem: task.variables.splitItem,
id: task.id,

@@ -748,3 +752,3 @@ }));

}, [addItemsTask, enqueueTask, log, updateItemsTask]);
return (React__default['default'].createElement(OrderItemsContext.Provider, { value: value }, children));
return (React__default["default"].createElement(OrderItemsContext.Provider, { value: value }, children));
};

@@ -751,0 +755,0 @@ return { OrderItemsProvider };

{
"name": "@vtex/order-items",
"version": "0.6.7",
"version": "0.7.0",
"description": "",

@@ -5,0 +5,0 @@ "cdn": "dist/index.umd.js",

@@ -44,2 +44,3 @@ import { useCallback } from 'react'

allowedOutdatedData,
splitItem,
}: {

@@ -50,2 +51,3 @@ items: UpdateQuantityInput[]

allowedOutdatedData?: string[]
splitItem?: boolean
}) => {

@@ -75,2 +77,3 @@ return {

allowedOutdatedData,
splitItem,
}

@@ -77,0 +80,0 @@

@@ -13,2 +13,3 @@ import type { Item, OrderFormItemInput, MarketingData } from '../typings'

allowedOutdatedData?: string[]
splitItem?: boolean
}

@@ -15,0 +16,0 @@

@@ -140,2 +140,3 @@ import type { OrderForm as BaseOrderForm } from '@vtex/order-manager'

allowedOutdatedData?: string[]
splitItem?: boolean
}

@@ -142,0 +143,0 @@

import type { CatalogItem } from '../typings';
export declare const orderFormWithItems: Readonly<{
id: string;
canEditData: boolean;
id: "4b406196ed3646c394053ead7069e74a";
canEditData: true;
messages: {

@@ -47,3 +47,3 @@ generalMessages: never[];

}[];
value: number;
value: 9585000;
}>;

@@ -50,0 +50,0 @@ export declare const availableCatalogItem: CatalogItem;

@@ -9,3 +9,3 @@ import type { OrderFormContext } from '@vtex/order-manager';

}
declare type AddItemsMutate<O extends OrderForm, T = AddItemData<O>> = (input: AddItemsMutationVariables) => Promise<T>;
type AddItemsMutate<O extends OrderForm, T = AddItemData<O>> = (input: AddItemsMutationVariables) => Promise<T>;
export interface CreateAddItemsParams<O extends OrderForm> {

@@ -12,0 +12,0 @@ useMutateAddItems: () => AddItemsMutate<O>;

@@ -6,3 +6,3 @@ import type { OrderForm } from '@vtex/order-manager';

}
declare type UpdateManualPriceMutate<O extends OrderForm, T = SetManualPriceData<O>> = (input: {
type UpdateManualPriceMutate<O extends OrderForm, T = SetManualPriceData<O>> = (input: {
itemIndex: number;

@@ -9,0 +9,0 @@ price: number;

@@ -7,3 +7,3 @@ import type { OrderFormContext } from '@vtex/order-manager';

}
declare type UpdateQuantityMutation<O extends OrderForm, T = UpdateQuantityData<O>> = <I extends UpdateQuantityInput>(options: {
type UpdateQuantityMutation<O extends OrderForm, T = UpdateQuantityData<O>> = <I extends UpdateQuantityInput>(options: {
orderItems: I[];

@@ -15,3 +15,3 @@ }) => Promise<T>;

}
export declare function createUseUpdateQuantity<O extends OrderForm>({ useMutateUpdateQuantity, useOrderForm, }: CreateUseUpdateQuantityParams<O>): (fakeUniqueIdMapRef: React.MutableRefObject<FakeUniqueIdMap>) => ({ items, orderFormItems, id, allowedOutdatedData, }: {
export declare function createUseUpdateQuantity<O extends OrderForm>({ useMutateUpdateQuantity, useOrderForm, }: CreateUseUpdateQuantityParams<O>): (fakeUniqueIdMapRef: React.MutableRefObject<FakeUniqueIdMap>) => ({ items, orderFormItems, id, allowedOutdatedData, splitItem, }: {
items: UpdateQuantityInput[];

@@ -21,2 +21,3 @@ orderFormItems: Item[];

allowedOutdatedData?: string[] | undefined;
splitItem?: boolean | undefined;
}) => {

@@ -23,0 +24,0 @@ id: string;

import type { Item, OrderFormItemInput, MarketingData } from '../typings';
import type { LogFn } from './logger';
export declare type LocalOrderTaskType = 'add_mutation' | 'update_mutation';
export declare type UpdateQuantityInput = {
export type LocalOrderTaskType = 'add_mutation' | 'update_mutation';
export type UpdateQuantityInput = {
index: number;

@@ -14,2 +14,3 @@ quantity: number;

allowedOutdatedData?: string[];
splitItem?: boolean;
}

@@ -22,3 +23,3 @@ export interface AddItemsMutationVariables {

}
declare type LocalOrderTask = {
type LocalOrderTask = {
id?: string;

@@ -37,6 +38,6 @@ variables: AddItemsMutationVariables;

}
declare type GetLocalOrderQueue = (log?: LogFn) => LocalOrderQueue;
declare type PushLocalOrderQueueFn = (task: LocalOrderTask, log?: LogFn) => number;
declare type PopLocalOrderQueueFn = (index?: number, log?: LogFn) => LocalOrderTask | undefined;
declare type UpdateLocalQueueItemIdsFn = (args: {
type GetLocalOrderQueue = (log?: LogFn) => LocalOrderQueue;
type PushLocalOrderQueueFn = (task: LocalOrderTask, log?: LogFn) => number;
type PopLocalOrderQueueFn = (index?: number, log?: LogFn) => LocalOrderTask | undefined;
type UpdateLocalQueueItemIdsFn = (args: {
fakeUniqueId: string;

@@ -43,0 +44,0 @@ uniqueId: string;

@@ -8,4 +8,4 @@ interface LogParams {

}
export declare type LogFn = (params: LogParams) => void;
export declare type UseLogger = () => {
export type LogFn = (params: LogParams) => void;
export type UseLogger = () => {
log: LogFn;

@@ -12,0 +12,0 @@ };

@@ -13,3 +13,3 @@ /// <reference types="react" />

}
export declare type AddItemItemParam = {
export type AddItemItemParam = {
id: string;

@@ -21,3 +21,3 @@ seller: string;

} & OptimisticItemInfo;
declare type OptimisticItemInfo = {
type OptimisticItemInfo = {
productId?: string;

@@ -37,9 +37,10 @@ name?: string;

};
export declare type AddItemsOptions = {
export type AddItemsOptions = {
marketingData?: Partial<MarketingData>;
salesChannel?: string;
allowedOutdatedData?: string[];
splitItem?: boolean;
};
export declare type AddItemsFn = (items: AddItemItemParam[], options?: AddItemsOptions) => PromiseLike<void>;
export declare type AddItemFn = (items: AddItemItemParam[], marketingData?: Partial<MarketingData>, salesChannel?: string) => void;
export type AddItemsFn = (items: AddItemItemParam[], options?: AddItemsOptions) => PromiseLike<void>;
export type AddItemFn = (items: AddItemItemParam[], marketingData?: Partial<MarketingData>, salesChannel?: string) => void;
interface ItemIdentificationById {

@@ -60,16 +61,17 @@ id: string;

}
declare type ItemIdentification = ItemIdentificationById | ItemIdentificationByUniqueId | ItemIdentificationByIndex;
declare type UpdateQuantityItemParam = {
type ItemIdentification = ItemIdentificationById | ItemIdentificationByUniqueId | ItemIdentificationByIndex;
type UpdateQuantityItemParam = {
seller: string;
quantity: number;
} & ItemIdentification;
export declare type UpdateQuantityOptions = {
export type UpdateQuantityOptions = {
allowedOutdatedData?: string[];
splitItem?: boolean;
};
export declare type UpdateQuantityFn = (item: UpdateQuantityItemParam, options?: UpdateQuantityOptions) => PromiseLike<void>;
declare type RemoveItemParam = {
export type UpdateQuantityFn = (item: UpdateQuantityItemParam, options?: UpdateQuantityOptions) => PromiseLike<void>;
type RemoveItemParam = {
seller: string;
} & ItemIdentification;
export declare type RemoveItemFn = (input: RemoveItemParam, options?: UpdateQuantityOptions) => void;
export declare type SetManualPriceFn = (price: number, itemIndex: number) => void;
export type RemoveItemFn = (input: RemoveItemParam, options?: UpdateQuantityOptions) => void;
export type SetManualPriceFn = (price: number, itemIndex: number) => void;
export declare const OrderItemsContext: import("react").Context<Context>;

@@ -76,0 +78,0 @@ export declare const useOrderItems: () => Context;

@@ -54,3 +54,3 @@ import type { OrderForm as BaseOrderForm } from '@vtex/order-manager';

}
declare type Maybe<T> = null | undefined | T;
type Maybe<T> = null | undefined | T;
export interface FullItem extends Item {

@@ -84,7 +84,7 @@ additionalInfo?: Maybe<ItemAdditionalInfo>;

}
export declare type SkuSpecification = {
export type SkuSpecification = {
fieldName?: Maybe<string>;
fieldValues: Array<Maybe<string>>;
};
export declare type ImageUrls = {
export type ImageUrls = {
at1x: string;

@@ -114,3 +114,3 @@ at2x: string;

}
declare type TotalizersType = 'Items' | 'Discounts';
type TotalizersType = 'Items' | 'Discounts';
export interface Totalizer {

@@ -121,3 +121,3 @@ id: TotalizersType;

}
export declare type UpdateQuantityInput = {
export type UpdateQuantityInput = {
index: number;

@@ -132,2 +132,3 @@ quantity: number;

allowedOutdatedData?: string[];
splitItem?: boolean;
}

@@ -134,0 +135,0 @@ export interface FakeUniqueIdMap {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc