@labdigital/commercetools-mock 0.14.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import express from 'express';
2
2
  import * as ctp from '@commercetools/platform-sdk';
3
- import { Project, ResourceIdentifier, QueryParam, CartDraft, Cart, CartAddLineItemAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, ChannelDraft, Channel, ChannelUpdateAction, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerChangeEmailAction, CustomerSetAuthenticationModeAction, CustomerGroupDraft, CustomerGroup, CustomerGroupSetKeyAction, CustomerGroupChangeNameAction, CustomerGroupSetCustomTypeAction, CustomerGroupSetCustomFieldAction, DiscountCodeDraft, DiscountCode, DiscountCodeUpdateAction, Extension, ExtensionDraft, ExtensionUpdateAction, InventoryEntryDraft, InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetRestockableInDaysAction, OrderFromCartDraft, Order, CartReference, OrderImportDraft, OrderAddPaymentAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderTransitionStateAction, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, OrderEditUpdateAction, PaymentDraft, Payment, TransactionDraft, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, PaymentAddTransactionAction, PaymentChangeTransactionStateAction, PaymentTransitionStateAction, ProductDraft, Product, ProductUpdateAction, ProductDiscountDraft, ProductDiscount, ProductDiscountUpdateAction, ProductProjectionPagedSearchResponse, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ReviewUpdateAction, Review, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ProjectUpdateAction, QuoteDraft, Quote, QuoteUpdateAction, QuoteRequestDraft, QuoteRequest, QuoteRequestUpdateAction, ReviewDraft, ShippingMethodDraft, ShippingMethod, ShippingMethodUpdateAction, ShoppingListDraft, ShoppingList, StagedQuoteDraft, StagedQuote, StagedQuoteUpdateAction, StandalonePrice, StandalonePriceUpdateAction, StateDraft, State, StateUpdateAction, StoreDraft, Store, StoreUpdateAction, SubscriptionDraft, Subscription, TaxCategoryDraft, TaxCategory, TaxCategoryUpdateAction, TypeDraft, Type, TypeUpdateAction, ZoneDraft, Zone, ZoneUpdateAction, BaseResource, UpdateAction } from '@commercetools/platform-sdk';
3
+ import { Project, ResourceIdentifier, QueryParam, CartDraft, Cart, CartAddLineItemAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, ChannelDraft, Channel, ChannelUpdateAction, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerChangeEmailAction, CustomerSetAuthenticationModeAction, CustomerGroupDraft, CustomerGroup, CustomerGroupSetKeyAction, CustomerGroupChangeNameAction, CustomerGroupSetCustomTypeAction, CustomerGroupSetCustomFieldAction, DiscountCodeDraft, DiscountCode, DiscountCodeUpdateAction, Extension, ExtensionDraft, ExtensionUpdateAction, InventoryEntryDraft, InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetRestockableInDaysAction, OrderFromCartDraft, Order, CartReference, OrderImportDraft, OrderAddPaymentAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderTransitionStateAction, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, OrderEditUpdateAction, PaymentDraft, Payment, TransactionDraft, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, PaymentAddTransactionAction, PaymentChangeTransactionStateAction, PaymentTransitionStateAction, ProductDraft, Product, ProductUpdateAction, ProductDiscountDraft, ProductDiscount, ProductDiscountUpdateAction, ProductProjectionPagedSearchResponse, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ReviewUpdateAction, Review, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ProjectUpdateAction, QuoteDraft, Quote, QuoteUpdateAction, QuoteRequestDraft, QuoteRequest, QuoteRequestUpdateAction, ReviewDraft, ShippingMethodDraft, ShippingMethod, ShippingMethodUpdateAction, ShoppingListDraft, ShoppingList, StagedQuoteDraft, StagedQuote, StagedQuoteUpdateAction, StandalonePriceDraft, StandalonePrice, ChannelResourceIdentifier, ChannelReference, DiscountedPriceDraft, StandalonePriceChangeActiveAction, StandalonePriceChangeValueAction, StandalonePriceSetDiscountedPriceAction, StateDraft, State, StateUpdateAction, StoreDraft, Store, StoreUpdateAction, SubscriptionDraft, Subscription, TaxCategoryDraft, TaxCategory, TaxCategoryUpdateAction, TypeDraft, Type, TypeUpdateAction, ZoneDraft, Zone, ZoneUpdateAction, BaseResource, UpdateAction } from '@commercetools/platform-sdk';
4
4
  import { ParsedQs } from 'qs';
5
5
 
6
6
  declare type GetParams$1 = {
@@ -329,8 +329,17 @@ declare class StagedQuoteRepository extends AbstractResourceRepository<'staged-q
329
329
 
330
330
  declare class StandAlonePriceRepository extends AbstractResourceRepository<'standalone-price'> {
331
331
  getTypeId(): "standalone-price";
332
- create(context: RepositoryContext, draft: StandalonePrice): StandalonePrice;
333
- actions: Partial<Record<StandalonePriceUpdateAction['action'], (context: RepositoryContext, resource: Writable<Review>, action: any) => void>>;
332
+ create(context: RepositoryContext, draft: StandalonePriceDraft): StandalonePrice;
333
+ transformChannelReferenceDraft(channel: ChannelResourceIdentifier): ChannelReference;
334
+ transformDiscountDraft(discounted: DiscountedPriceDraft): {
335
+ value: ctp.TypedMoney;
336
+ discount: ctp.ProductDiscountReference;
337
+ };
338
+ actions: {
339
+ setActive: (context: RepositoryContext, resource: Writable<StandalonePrice>, action: StandalonePriceChangeActiveAction) => void;
340
+ changeValue: (context: RepositoryContext, resource: Writable<StandalonePrice>, action: StandalonePriceChangeValueAction) => void;
341
+ setDiscountedPrice: (context: RepositoryContext, resource: Writable<StandalonePrice>, action: StandalonePriceSetDiscountedPriceAction) => void;
342
+ };
334
343
  }
335
344
 
336
345
  declare class StateRepository extends AbstractResourceRepository<'state'> {
@@ -37913,11 +37913,314 @@ ${this.pendingMocks().join("\n")}`
37913
37913
  }
37914
37914
  });
37915
37915
 
37916
+ // node_modules/.pnpm/get-intrinsic@1.2.0/node_modules/get-intrinsic/index.js
37917
+ var require_get_intrinsic2 = __commonJS({
37918
+ "node_modules/.pnpm/get-intrinsic@1.2.0/node_modules/get-intrinsic/index.js"(exports, module) {
37919
+ "use strict";
37920
+ var undefined2;
37921
+ var $SyntaxError = SyntaxError;
37922
+ var $Function = Function;
37923
+ var $TypeError = TypeError;
37924
+ var getEvalledConstructor = function(expressionSyntax) {
37925
+ try {
37926
+ return $Function('"use strict"; return (' + expressionSyntax + ").constructor;")();
37927
+ } catch (e) {
37928
+ }
37929
+ };
37930
+ var $gOPD = Object.getOwnPropertyDescriptor;
37931
+ if ($gOPD) {
37932
+ try {
37933
+ $gOPD({}, "");
37934
+ } catch (e) {
37935
+ $gOPD = null;
37936
+ }
37937
+ }
37938
+ var throwTypeError = function() {
37939
+ throw new $TypeError();
37940
+ };
37941
+ var ThrowTypeError = $gOPD ? function() {
37942
+ try {
37943
+ arguments.callee;
37944
+ return throwTypeError;
37945
+ } catch (calleeThrows) {
37946
+ try {
37947
+ return $gOPD(arguments, "callee").get;
37948
+ } catch (gOPDthrows) {
37949
+ return throwTypeError;
37950
+ }
37951
+ }
37952
+ }() : throwTypeError;
37953
+ var hasSymbols = require_has_symbols()();
37954
+ var getProto = Object.getPrototypeOf || function(x) {
37955
+ return x.__proto__;
37956
+ };
37957
+ var needsEval = {};
37958
+ var TypedArray = typeof Uint8Array === "undefined" ? undefined2 : getProto(Uint8Array);
37959
+ var INTRINSICS = {
37960
+ "%AggregateError%": typeof AggregateError === "undefined" ? undefined2 : AggregateError,
37961
+ "%Array%": Array,
37962
+ "%ArrayBuffer%": typeof ArrayBuffer === "undefined" ? undefined2 : ArrayBuffer,
37963
+ "%ArrayIteratorPrototype%": hasSymbols ? getProto([][Symbol.iterator]()) : undefined2,
37964
+ "%AsyncFromSyncIteratorPrototype%": undefined2,
37965
+ "%AsyncFunction%": needsEval,
37966
+ "%AsyncGenerator%": needsEval,
37967
+ "%AsyncGeneratorFunction%": needsEval,
37968
+ "%AsyncIteratorPrototype%": needsEval,
37969
+ "%Atomics%": typeof Atomics === "undefined" ? undefined2 : Atomics,
37970
+ "%BigInt%": typeof BigInt === "undefined" ? undefined2 : BigInt,
37971
+ "%BigInt64Array%": typeof BigInt64Array === "undefined" ? undefined2 : BigInt64Array,
37972
+ "%BigUint64Array%": typeof BigUint64Array === "undefined" ? undefined2 : BigUint64Array,
37973
+ "%Boolean%": Boolean,
37974
+ "%DataView%": typeof DataView === "undefined" ? undefined2 : DataView,
37975
+ "%Date%": Date,
37976
+ "%decodeURI%": decodeURI,
37977
+ "%decodeURIComponent%": decodeURIComponent,
37978
+ "%encodeURI%": encodeURI,
37979
+ "%encodeURIComponent%": encodeURIComponent,
37980
+ "%Error%": Error,
37981
+ "%eval%": eval,
37982
+ "%EvalError%": EvalError,
37983
+ "%Float32Array%": typeof Float32Array === "undefined" ? undefined2 : Float32Array,
37984
+ "%Float64Array%": typeof Float64Array === "undefined" ? undefined2 : Float64Array,
37985
+ "%FinalizationRegistry%": typeof FinalizationRegistry === "undefined" ? undefined2 : FinalizationRegistry,
37986
+ "%Function%": $Function,
37987
+ "%GeneratorFunction%": needsEval,
37988
+ "%Int8Array%": typeof Int8Array === "undefined" ? undefined2 : Int8Array,
37989
+ "%Int16Array%": typeof Int16Array === "undefined" ? undefined2 : Int16Array,
37990
+ "%Int32Array%": typeof Int32Array === "undefined" ? undefined2 : Int32Array,
37991
+ "%isFinite%": isFinite,
37992
+ "%isNaN%": isNaN,
37993
+ "%IteratorPrototype%": hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined2,
37994
+ "%JSON%": typeof JSON === "object" ? JSON : undefined2,
37995
+ "%Map%": typeof Map === "undefined" ? undefined2 : Map,
37996
+ "%MapIteratorPrototype%": typeof Map === "undefined" || !hasSymbols ? undefined2 : getProto((/* @__PURE__ */ new Map())[Symbol.iterator]()),
37997
+ "%Math%": Math,
37998
+ "%Number%": Number,
37999
+ "%Object%": Object,
38000
+ "%parseFloat%": parseFloat,
38001
+ "%parseInt%": parseInt,
38002
+ "%Promise%": typeof Promise === "undefined" ? undefined2 : Promise,
38003
+ "%Proxy%": typeof Proxy === "undefined" ? undefined2 : Proxy,
38004
+ "%RangeError%": RangeError,
38005
+ "%ReferenceError%": ReferenceError,
38006
+ "%Reflect%": typeof Reflect === "undefined" ? undefined2 : Reflect,
38007
+ "%RegExp%": RegExp,
38008
+ "%Set%": typeof Set === "undefined" ? undefined2 : Set,
38009
+ "%SetIteratorPrototype%": typeof Set === "undefined" || !hasSymbols ? undefined2 : getProto((/* @__PURE__ */ new Set())[Symbol.iterator]()),
38010
+ "%SharedArrayBuffer%": typeof SharedArrayBuffer === "undefined" ? undefined2 : SharedArrayBuffer,
38011
+ "%String%": String,
38012
+ "%StringIteratorPrototype%": hasSymbols ? getProto(""[Symbol.iterator]()) : undefined2,
38013
+ "%Symbol%": hasSymbols ? Symbol : undefined2,
38014
+ "%SyntaxError%": $SyntaxError,
38015
+ "%ThrowTypeError%": ThrowTypeError,
38016
+ "%TypedArray%": TypedArray,
38017
+ "%TypeError%": $TypeError,
38018
+ "%Uint8Array%": typeof Uint8Array === "undefined" ? undefined2 : Uint8Array,
38019
+ "%Uint8ClampedArray%": typeof Uint8ClampedArray === "undefined" ? undefined2 : Uint8ClampedArray,
38020
+ "%Uint16Array%": typeof Uint16Array === "undefined" ? undefined2 : Uint16Array,
38021
+ "%Uint32Array%": typeof Uint32Array === "undefined" ? undefined2 : Uint32Array,
38022
+ "%URIError%": URIError,
38023
+ "%WeakMap%": typeof WeakMap === "undefined" ? undefined2 : WeakMap,
38024
+ "%WeakRef%": typeof WeakRef === "undefined" ? undefined2 : WeakRef,
38025
+ "%WeakSet%": typeof WeakSet === "undefined" ? undefined2 : WeakSet
38026
+ };
38027
+ try {
38028
+ null.error;
38029
+ } catch (e) {
38030
+ errorProto = getProto(getProto(e));
38031
+ INTRINSICS["%Error.prototype%"] = errorProto;
38032
+ }
38033
+ var errorProto;
38034
+ var doEval = function doEval2(name) {
38035
+ var value;
38036
+ if (name === "%AsyncFunction%") {
38037
+ value = getEvalledConstructor("async function () {}");
38038
+ } else if (name === "%GeneratorFunction%") {
38039
+ value = getEvalledConstructor("function* () {}");
38040
+ } else if (name === "%AsyncGeneratorFunction%") {
38041
+ value = getEvalledConstructor("async function* () {}");
38042
+ } else if (name === "%AsyncGenerator%") {
38043
+ var fn = doEval2("%AsyncGeneratorFunction%");
38044
+ if (fn) {
38045
+ value = fn.prototype;
38046
+ }
38047
+ } else if (name === "%AsyncIteratorPrototype%") {
38048
+ var gen = doEval2("%AsyncGenerator%");
38049
+ if (gen) {
38050
+ value = getProto(gen.prototype);
38051
+ }
38052
+ }
38053
+ INTRINSICS[name] = value;
38054
+ return value;
38055
+ };
38056
+ var LEGACY_ALIASES = {
38057
+ "%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"],
38058
+ "%ArrayPrototype%": ["Array", "prototype"],
38059
+ "%ArrayProto_entries%": ["Array", "prototype", "entries"],
38060
+ "%ArrayProto_forEach%": ["Array", "prototype", "forEach"],
38061
+ "%ArrayProto_keys%": ["Array", "prototype", "keys"],
38062
+ "%ArrayProto_values%": ["Array", "prototype", "values"],
38063
+ "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"],
38064
+ "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"],
38065
+ "%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"],
38066
+ "%BooleanPrototype%": ["Boolean", "prototype"],
38067
+ "%DataViewPrototype%": ["DataView", "prototype"],
38068
+ "%DatePrototype%": ["Date", "prototype"],
38069
+ "%ErrorPrototype%": ["Error", "prototype"],
38070
+ "%EvalErrorPrototype%": ["EvalError", "prototype"],
38071
+ "%Float32ArrayPrototype%": ["Float32Array", "prototype"],
38072
+ "%Float64ArrayPrototype%": ["Float64Array", "prototype"],
38073
+ "%FunctionPrototype%": ["Function", "prototype"],
38074
+ "%Generator%": ["GeneratorFunction", "prototype"],
38075
+ "%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"],
38076
+ "%Int8ArrayPrototype%": ["Int8Array", "prototype"],
38077
+ "%Int16ArrayPrototype%": ["Int16Array", "prototype"],
38078
+ "%Int32ArrayPrototype%": ["Int32Array", "prototype"],
38079
+ "%JSONParse%": ["JSON", "parse"],
38080
+ "%JSONStringify%": ["JSON", "stringify"],
38081
+ "%MapPrototype%": ["Map", "prototype"],
38082
+ "%NumberPrototype%": ["Number", "prototype"],
38083
+ "%ObjectPrototype%": ["Object", "prototype"],
38084
+ "%ObjProto_toString%": ["Object", "prototype", "toString"],
38085
+ "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"],
38086
+ "%PromisePrototype%": ["Promise", "prototype"],
38087
+ "%PromiseProto_then%": ["Promise", "prototype", "then"],
38088
+ "%Promise_all%": ["Promise", "all"],
38089
+ "%Promise_reject%": ["Promise", "reject"],
38090
+ "%Promise_resolve%": ["Promise", "resolve"],
38091
+ "%RangeErrorPrototype%": ["RangeError", "prototype"],
38092
+ "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"],
38093
+ "%RegExpPrototype%": ["RegExp", "prototype"],
38094
+ "%SetPrototype%": ["Set", "prototype"],
38095
+ "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"],
38096
+ "%StringPrototype%": ["String", "prototype"],
38097
+ "%SymbolPrototype%": ["Symbol", "prototype"],
38098
+ "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"],
38099
+ "%TypedArrayPrototype%": ["TypedArray", "prototype"],
38100
+ "%TypeErrorPrototype%": ["TypeError", "prototype"],
38101
+ "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"],
38102
+ "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"],
38103
+ "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"],
38104
+ "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"],
38105
+ "%URIErrorPrototype%": ["URIError", "prototype"],
38106
+ "%WeakMapPrototype%": ["WeakMap", "prototype"],
38107
+ "%WeakSetPrototype%": ["WeakSet", "prototype"]
38108
+ };
38109
+ var bind = require_function_bind();
38110
+ var hasOwn = require_src3();
38111
+ var $concat = bind.call(Function.call, Array.prototype.concat);
38112
+ var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
38113
+ var $replace = bind.call(Function.call, String.prototype.replace);
38114
+ var $strSlice = bind.call(Function.call, String.prototype.slice);
38115
+ var $exec = bind.call(Function.call, RegExp.prototype.exec);
38116
+ var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
38117
+ var reEscapeChar = /\\(\\)?/g;
38118
+ var stringToPath = function stringToPath2(string) {
38119
+ var first = $strSlice(string, 0, 1);
38120
+ var last = $strSlice(string, -1);
38121
+ if (first === "%" && last !== "%") {
38122
+ throw new $SyntaxError("invalid intrinsic syntax, expected closing `%`");
38123
+ } else if (last === "%" && first !== "%") {
38124
+ throw new $SyntaxError("invalid intrinsic syntax, expected opening `%`");
38125
+ }
38126
+ var result = [];
38127
+ $replace(string, rePropName, function(match, number, quote, subString) {
38128
+ result[result.length] = quote ? $replace(subString, reEscapeChar, "$1") : number || match;
38129
+ });
38130
+ return result;
38131
+ };
38132
+ var getBaseIntrinsic = function getBaseIntrinsic2(name, allowMissing) {
38133
+ var intrinsicName = name;
38134
+ var alias;
38135
+ if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
38136
+ alias = LEGACY_ALIASES[intrinsicName];
38137
+ intrinsicName = "%" + alias[0] + "%";
38138
+ }
38139
+ if (hasOwn(INTRINSICS, intrinsicName)) {
38140
+ var value = INTRINSICS[intrinsicName];
38141
+ if (value === needsEval) {
38142
+ value = doEval(intrinsicName);
38143
+ }
38144
+ if (typeof value === "undefined" && !allowMissing) {
38145
+ throw new $TypeError("intrinsic " + name + " exists, but is not available. Please file an issue!");
38146
+ }
38147
+ return {
38148
+ alias,
38149
+ name: intrinsicName,
38150
+ value
38151
+ };
38152
+ }
38153
+ throw new $SyntaxError("intrinsic " + name + " does not exist!");
38154
+ };
38155
+ module.exports = function GetIntrinsic(name, allowMissing) {
38156
+ if (typeof name !== "string" || name.length === 0) {
38157
+ throw new $TypeError("intrinsic name must be a non-empty string");
38158
+ }
38159
+ if (arguments.length > 1 && typeof allowMissing !== "boolean") {
38160
+ throw new $TypeError('"allowMissing" argument must be a boolean');
38161
+ }
38162
+ if ($exec(/^%?[^%]*%?$/, name) === null) {
38163
+ throw new $SyntaxError("`%` may not be present anywhere but at the beginning and end of the intrinsic name");
38164
+ }
38165
+ var parts = stringToPath(name);
38166
+ var intrinsicBaseName = parts.length > 0 ? parts[0] : "";
38167
+ var intrinsic = getBaseIntrinsic("%" + intrinsicBaseName + "%", allowMissing);
38168
+ var intrinsicRealName = intrinsic.name;
38169
+ var value = intrinsic.value;
38170
+ var skipFurtherCaching = false;
38171
+ var alias = intrinsic.alias;
38172
+ if (alias) {
38173
+ intrinsicBaseName = alias[0];
38174
+ $spliceApply(parts, $concat([0, 1], alias));
38175
+ }
38176
+ for (var i = 1, isOwn = true; i < parts.length; i += 1) {
38177
+ var part = parts[i];
38178
+ var first = $strSlice(part, 0, 1);
38179
+ var last = $strSlice(part, -1);
38180
+ if ((first === '"' || first === "'" || first === "`" || (last === '"' || last === "'" || last === "`")) && first !== last) {
38181
+ throw new $SyntaxError("property names with quotes must have matching quotes");
38182
+ }
38183
+ if (part === "constructor" || !isOwn) {
38184
+ skipFurtherCaching = true;
38185
+ }
38186
+ intrinsicBaseName += "." + part;
38187
+ intrinsicRealName = "%" + intrinsicBaseName + "%";
38188
+ if (hasOwn(INTRINSICS, intrinsicRealName)) {
38189
+ value = INTRINSICS[intrinsicRealName];
38190
+ } else if (value != null) {
38191
+ if (!(part in value)) {
38192
+ if (!allowMissing) {
38193
+ throw new $TypeError("base intrinsic for " + name + " exists, but the property is not available.");
38194
+ }
38195
+ return void 0;
38196
+ }
38197
+ if ($gOPD && i + 1 >= parts.length) {
38198
+ var desc = $gOPD(value, part);
38199
+ isOwn = !!desc;
38200
+ if (isOwn && "get" in desc && !("originalValue" in desc.get)) {
38201
+ value = desc.get;
38202
+ } else {
38203
+ value = value[part];
38204
+ }
38205
+ } else {
38206
+ isOwn = hasOwn(value, part);
38207
+ value = value[part];
38208
+ }
38209
+ if (isOwn && !skipFurtherCaching) {
38210
+ INTRINSICS[intrinsicRealName] = value;
38211
+ }
38212
+ }
38213
+ }
38214
+ return value;
38215
+ };
38216
+ }
38217
+ });
38218
+
37916
38219
  // node_modules/.pnpm/has-property-descriptors@1.0.0/node_modules/has-property-descriptors/index.js
37917
38220
  var require_has_property_descriptors = __commonJS({
37918
38221
  "node_modules/.pnpm/has-property-descriptors@1.0.0/node_modules/has-property-descriptors/index.js"(exports, module) {
37919
38222
  "use strict";
37920
- var GetIntrinsic = require_get_intrinsic();
38223
+ var GetIntrinsic = require_get_intrinsic2();
37921
38224
  var $defineProperty = GetIntrinsic("%Object.defineProperty%", true);
37922
38225
  var hasPropertyDescriptors = function hasPropertyDescriptors2() {
37923
38226
  if ($defineProperty) {
@@ -38626,7 +38929,7 @@ ${this.pendingMocks().join("\n")}`
38626
38929
  var require_is_weakset = __commonJS({
38627
38930
  "node_modules/.pnpm/is-weakset@2.0.2/node_modules/is-weakset/index.js"(exports, module) {
38628
38931
  "use strict";
38629
- var GetIntrinsic = require_get_intrinsic();
38932
+ var GetIntrinsic = require_get_intrinsic2();
38630
38933
  var callBound = require_callBound();
38631
38934
  var $WeakSet = GetIntrinsic("%WeakSet%", true);
38632
38935
  var $setHas = callBound("WeakSet.prototype.has", true);
@@ -38890,7 +39193,24 @@ ${this.pendingMocks().join("\n")}`
38890
39193
  var require_getOwnPropertyDescriptor = __commonJS({
38891
39194
  "node_modules/.pnpm/es-abstract@1.20.1/node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js"(exports, module) {
38892
39195
  "use strict";
38893
- var GetIntrinsic = require_get_intrinsic();
39196
+ var GetIntrinsic = require_get_intrinsic2();
39197
+ var $gOPD = GetIntrinsic("%Object.getOwnPropertyDescriptor%", true);
39198
+ if ($gOPD) {
39199
+ try {
39200
+ $gOPD([], "length");
39201
+ } catch (e) {
39202
+ $gOPD = null;
39203
+ }
39204
+ }
39205
+ module.exports = $gOPD;
39206
+ }
39207
+ });
39208
+
39209
+ // node_modules/.pnpm/gopd@1.0.1/node_modules/gopd/index.js
39210
+ var require_gopd = __commonJS({
39211
+ "node_modules/.pnpm/gopd@1.0.1/node_modules/gopd/index.js"(exports, module) {
39212
+ "use strict";
39213
+ var GetIntrinsic = require_get_intrinsic2();
38894
39214
  var $gOPD = GetIntrinsic("%Object.getOwnPropertyDescriptor%", true);
38895
39215
  if ($gOPD) {
38896
39216
  try {
@@ -38903,6 +39223,14 @@ ${this.pendingMocks().join("\n")}`
38903
39223
  }
38904
39224
  });
38905
39225
 
39226
+ // node_modules/.pnpm/es-abstract@1.21.1/node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js
39227
+ var require_getOwnPropertyDescriptor2 = __commonJS({
39228
+ "node_modules/.pnpm/es-abstract@1.21.1/node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js"(exports, module) {
39229
+ "use strict";
39230
+ module.exports = require_gopd();
39231
+ }
39232
+ });
39233
+
38906
39234
  // node_modules/.pnpm/is-typed-array@1.1.9/node_modules/is-typed-array/index.js
38907
39235
  var require_is_typed_array = __commonJS({
38908
39236
  "node_modules/.pnpm/is-typed-array@1.1.9/node_modules/is-typed-array/index.js"(exports, module) {
@@ -38924,7 +39252,7 @@ ${this.pendingMocks().join("\n")}`
38924
39252
  };
38925
39253
  var $slice = callBound("String.prototype.slice");
38926
39254
  var toStrTags = {};
38927
- var gOPD = require_getOwnPropertyDescriptor();
39255
+ var gOPD = require_getOwnPropertyDescriptor2();
38928
39256
  var getPrototypeOf = Object.getPrototypeOf;
38929
39257
  if (hasToStringTag && gOPD && getPrototypeOf) {
38930
39258
  forEach(typedArrays, function(typedArray) {
@@ -47696,6 +48024,122 @@ ${this.pendingMocks().join("\n")}`
47696
48024
  }
47697
48025
  checkForStagedChanges(resource);
47698
48026
  return resource;
48027
+ },
48028
+ addPrice: (context, resource, { variantId, sku, price, staged }) => {
48029
+ const addVariantPrice = (data) => {
48030
+ const { variant, isMasterVariant, variantIndex } = getVariant(
48031
+ data,
48032
+ variantId,
48033
+ sku
48034
+ );
48035
+ if (!variant) {
48036
+ throw new Error(
48037
+ `Variant with id ${variantId} or sku ${sku} not found on product ${resource.id}`
48038
+ );
48039
+ }
48040
+ if (variant.prices === void 0) {
48041
+ variant.prices = [priceFromDraft(price)];
48042
+ } else {
48043
+ variant.prices.push(priceFromDraft(price));
48044
+ }
48045
+ if (isMasterVariant) {
48046
+ data.masterVariant = variant;
48047
+ } else {
48048
+ data.variants[variantIndex] = variant;
48049
+ }
48050
+ };
48051
+ const onlyStaged = staged !== void 0 ? staged : true;
48052
+ addVariantPrice(resource.masterData.staged);
48053
+ if (!onlyStaged) {
48054
+ addVariantPrice(resource.masterData.current);
48055
+ }
48056
+ checkForStagedChanges(resource);
48057
+ return resource;
48058
+ },
48059
+ changePrice: (context, resource, { priceId, price, staged }) => {
48060
+ const changeVariantPrice = (data) => {
48061
+ var _a;
48062
+ const allVariants = [data.masterVariant, ...data.variants ?? []];
48063
+ const priceVariant = allVariants.find(
48064
+ (variant2) => {
48065
+ var _a2;
48066
+ return (_a2 = variant2.prices) == null ? void 0 : _a2.some((x) => x.id === priceId);
48067
+ }
48068
+ );
48069
+ if (!priceVariant) {
48070
+ throw new Error(
48071
+ `Price with id ${priceId} not found on product ${resource.id}`
48072
+ );
48073
+ }
48074
+ const { variant, isMasterVariant, variantIndex } = getVariant(
48075
+ data,
48076
+ priceVariant.id,
48077
+ priceVariant.sku
48078
+ );
48079
+ if (!variant) {
48080
+ throw new Error(
48081
+ `Variant with id ${priceVariant.id} or sku ${priceVariant.sku} not found on product ${resource.id}`
48082
+ );
48083
+ }
48084
+ variant.prices = (_a = variant.prices) == null ? void 0 : _a.map((x) => {
48085
+ if (x.id === priceId) {
48086
+ return { ...x, ...price };
48087
+ }
48088
+ return x;
48089
+ });
48090
+ if (isMasterVariant) {
48091
+ data.masterVariant = variant;
48092
+ } else {
48093
+ data.variants[variantIndex] = variant;
48094
+ }
48095
+ };
48096
+ const onlyStaged = staged !== void 0 ? staged : true;
48097
+ changeVariantPrice(resource.masterData.staged);
48098
+ if (!onlyStaged) {
48099
+ changeVariantPrice(resource.masterData.current);
48100
+ }
48101
+ checkForStagedChanges(resource);
48102
+ return resource;
48103
+ },
48104
+ removePrice: (context, resource, { priceId, staged }) => {
48105
+ const removeVariantPrice = (data) => {
48106
+ var _a;
48107
+ const allVariants = [data.masterVariant, ...data.variants ?? []];
48108
+ const priceVariant = allVariants.find(
48109
+ (variant2) => {
48110
+ var _a2;
48111
+ return (_a2 = variant2.prices) == null ? void 0 : _a2.some((x) => x.id === priceId);
48112
+ }
48113
+ );
48114
+ if (!priceVariant) {
48115
+ throw new Error(
48116
+ `Price with id ${priceId} not found on product ${resource.id}`
48117
+ );
48118
+ }
48119
+ const { variant, isMasterVariant, variantIndex } = getVariant(
48120
+ data,
48121
+ priceVariant.id,
48122
+ priceVariant.sku
48123
+ );
48124
+ if (!variant) {
48125
+ throw new Error(
48126
+ `Variant with id ${priceVariant.id} or sku ${priceVariant.sku} not found on product ${resource.id}`
48127
+ );
48128
+ }
48129
+ variant.prices = (_a = variant.prices) == null ? void 0 : _a.filter((x) => x.id !== priceId);
48130
+ if (isMasterVariant) {
48131
+ data.masterVariant = variant;
48132
+ } else {
48133
+ data.variants[variantIndex] = variant;
48134
+ }
48135
+ };
48136
+ const onlyStaged = staged !== void 0 ? staged : true;
48137
+ removeVariantPrice(resource.masterData.staged);
48138
+ if (!onlyStaged) {
48139
+ removeVariantPrice(resource.masterData.current);
48140
+ }
48141
+ checkForStagedChanges(resource);
48142
+ return resource;
47699
48143
  }
47700
48144
  };
47701
48145
  }
@@ -47789,6 +48233,7 @@ ${this.pendingMocks().join("\n")}`
47789
48233
  };
47790
48234
  var priceFromDraft = (draft) => ({
47791
48235
  id: v4(),
48236
+ country: draft.country,
47792
48237
  value: {
47793
48238
  currencyCode: draft.value.currencyCode,
47794
48239
  centAmount: draft.value.centAmount,
@@ -48840,21 +49285,49 @@ ${this.pendingMocks().join("\n")}`
48840
49285
  var StandAlonePriceRepository = class extends AbstractResourceRepository {
48841
49286
  constructor() {
48842
49287
  super(...arguments);
48843
- this.actions = {};
49288
+ this.actions = {
49289
+ setActive: (context, resource, action) => {
49290
+ resource.active = action.active;
49291
+ },
49292
+ changeValue: (context, resource, action) => {
49293
+ resource.value = createTypedMoney(action.value);
49294
+ },
49295
+ setDiscountedPrice: (context, resource, action) => {
49296
+ resource.discounted = action.discounted ? this.transformDiscountDraft(action.discounted) : void 0;
49297
+ }
49298
+ };
48844
49299
  }
48845
49300
  getTypeId() {
48846
49301
  return "standalone-price";
48847
49302
  }
48848
49303
  create(context, draft) {
49304
+ var _a;
48849
49305
  const resource = {
48850
49306
  ...getBaseResourceProperties(),
48851
- active: draft.active,
49307
+ active: draft.active ? draft.active : false,
48852
49308
  sku: draft.sku,
48853
- value: draft.value
49309
+ value: createTypedMoney(draft.value),
49310
+ country: draft.country,
49311
+ discounted: draft.discounted ? this.transformDiscountDraft(draft.discounted) : void 0,
49312
+ channel: ((_a = draft.channel) == null ? void 0 : _a.id) ? this.transformChannelReferenceDraft(draft.channel) : void 0,
49313
+ validFrom: draft.validFrom,
49314
+ validUntil: draft.validUntil
48854
49315
  };
48855
49316
  this.saveNew(context, resource);
48856
49317
  return resource;
48857
49318
  }
49319
+ transformChannelReferenceDraft(channel) {
49320
+ return {
49321
+ typeId: channel.typeId,
49322
+ id: channel.id
49323
+ };
49324
+ }
49325
+ transformDiscountDraft(discounted) {
49326
+ return {
49327
+ value: createTypedMoney(discounted.value),
49328
+ discount: discounted.discount
49329
+ };
49330
+ }
48858
49331
  };
48859
49332
 
48860
49333
  // src/repositories/state.ts