@labdigital/commercetools-mock 2.13.0 → 2.14.1
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.cjs +112 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -4
- package/dist/index.d.ts +16 -4
- package/dist/index.js +112 -37
- package/dist/index.js.map +1 -1
- package/package.json +31 -31
- package/src/repositories/cart.ts +2 -2
- package/src/repositories/customer.ts +72 -0
- package/src/repositories/order.ts +1 -1
- package/src/repositories/payment.ts +92 -47
- package/src/repositories/product.ts +5 -5
- package/src/repositories/review.ts +2 -2
- package/src/repositories/shopping-list.ts +1 -1
- package/src/services/customer.test.ts +154 -0
- package/src/services/customer.ts +1 -1
- package/src/services/my-customer.test.ts +32 -2
- package/src/services/my-customer.ts +32 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { SetupServer } from 'msw/node';
|
|
3
3
|
import * as ctp from '@commercetools/platform-sdk';
|
|
4
|
-
import { Project, ResourceIdentifier, QueryParam, AssociateRoleDraft, AssociateRole, AssociateRoleSetNameAction, AssociateRoleSetPermissionsAction, AssociateRoleChangeBuyerAssignableAction, AssociateRoleSetCustomFieldAction, AssociateRoleAddPermissionAction, AssociateRoleRemovePermissionAction, AttributeGroupDraft, AttributeGroup, AttributeGroupSetAttributesAction, AttributeGroupChangeNameAction, AttributeGroupSetDescriptionAction, AttributeGroupSetKeyAction, BusinessUnitDraft, BusinessUnit, BusinessUnitAddAddressAction, BusinessUnitAddAssociateAction, BusinessUnitSetAssociatesAction, BusinessUnitSetContactEmailAction, BusinessUnitSetStoreModeAction, BusinessUnitChangeNameAction, BusinessUnitChangeAddressAction, BusinessUnitAddStoreAction, BusinessUnitChangeParentUnitAction, BusinessUnitChangeStatusAction, CartDraft, Cart, CartAddLineItemAction, CartAddItemShippingAddressAction, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomShippingMethodAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetLineItemShippingDetailsAction, CartSetShippingAddressAction, CartRemoveDiscountCodeAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, AssetDraft, Asset, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategoryChangeNameAction, CategoryChangeParentAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, CategoryRemoveAssetAction, CategoryAddAssetAction, ChannelDraft, Channel, ChannelUpdateAction, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerChangeEmailAction, CustomerSetAuthenticationModeAction, CustomerSetCustomFieldAction, CustomerGroupDraft, CustomerGroup, CustomerGroupSetKeyAction, CustomerGroupChangeNameAction, CustomerGroupSetCustomTypeAction, CustomerGroupSetCustomFieldAction, DiscountCodeDraft, DiscountCode, DiscountCodeUpdateAction, Extension, ExtensionDraft, ExtensionUpdateAction, InventoryEntryDraft, InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetRestockableInDaysAction, OrderFromCartDraft, Order, CartReference, OrderImportDraft, OrderAddPaymentAction, OrderAddReturnInfoAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderTransitionStateAction, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, OrderUpdateSyncInfoAction, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, OrderEditUpdateAction, PaymentDraft, Payment, TransactionDraft, Transaction, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction,
|
|
4
|
+
import { Project, ResourceIdentifier, QueryParam, AssociateRoleDraft, AssociateRole, AssociateRoleSetNameAction, AssociateRoleSetPermissionsAction, AssociateRoleChangeBuyerAssignableAction, AssociateRoleSetCustomFieldAction, AssociateRoleAddPermissionAction, AssociateRoleRemovePermissionAction, AttributeGroupDraft, AttributeGroup, AttributeGroupSetAttributesAction, AttributeGroupChangeNameAction, AttributeGroupSetDescriptionAction, AttributeGroupSetKeyAction, BusinessUnitDraft, BusinessUnit, BusinessUnitAddAddressAction, BusinessUnitAddAssociateAction, BusinessUnitSetAssociatesAction, BusinessUnitSetContactEmailAction, BusinessUnitSetStoreModeAction, BusinessUnitChangeNameAction, BusinessUnitChangeAddressAction, BusinessUnitAddStoreAction, BusinessUnitChangeParentUnitAction, BusinessUnitChangeStatusAction, CartDraft, Cart, CartAddLineItemAction, CartAddItemShippingAddressAction, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomShippingMethodAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetLineItemShippingDetailsAction, CartSetShippingAddressAction, CartRemoveDiscountCodeAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, AssetDraft, Asset, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategoryChangeNameAction, CategoryChangeParentAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, CategoryRemoveAssetAction, CategoryAddAssetAction, ChannelDraft, Channel, ChannelUpdateAction, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerChangeEmailAction, CustomerSetFirstNameAction, CustomerSetLastNameAction, CustomerSetCompanyNameAction, CustomerSetVatIdAction, CustomerChangeAddressAction, CustomerSetAuthenticationModeAction, CustomerSetCustomFieldAction, CustomerGroupDraft, CustomerGroup, CustomerGroupSetKeyAction, CustomerGroupChangeNameAction, CustomerGroupSetCustomTypeAction, CustomerGroupSetCustomFieldAction, DiscountCodeDraft, DiscountCode, DiscountCodeUpdateAction, Extension, ExtensionDraft, ExtensionUpdateAction, InventoryEntryDraft, InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetRestockableInDaysAction, OrderFromCartDraft, Order, CartReference, OrderImportDraft, OrderAddPaymentAction, OrderAddReturnInfoAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderTransitionStateAction, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, OrderUpdateSyncInfoAction, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, OrderEditUpdateAction, PaymentDraft, Payment, TransactionDraft, Transaction, PaymentAddTransactionAction, PaymentChangeTransactionStateAction, PaymentTransitionStateAction, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, PaymentSetKeyAction, PaymentSetStatusInterfaceCodeAction, PaymentSetStatusInterfaceTextAction, PaymentSetMethodInfoNameAction, PaymentSetMethodInfoMethodAction, PaymentSetMethodInfoInterfaceAction, PaymentSetInterfaceIdAction, ProductDraft, Product, ProductUpdateAction, ProductDiscountDraft, ProductDiscount, ProductDiscountUpdateAction, ProductProjectionPagedSearchResponse, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ProductSelectionUpdateAction, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ProjectUpdateAction, QuoteDraft, Quote, QuoteUpdateAction, QuoteRequestDraft, QuoteRequest, QuoteRequestUpdateAction, ReviewDraft, Review, ReviewUpdateAction, ShippingMethodDraft, ShippingMethod, ZoneReference, ShippingRate, 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';
|
|
5
5
|
|
|
6
6
|
type Token = {
|
|
7
7
|
access_token: string;
|
|
@@ -174,6 +174,11 @@ declare class CustomerRepository extends AbstractResourceRepository<'customer'>
|
|
|
174
174
|
deleteMe(context: RepositoryContext): Customer | undefined;
|
|
175
175
|
actions: {
|
|
176
176
|
changeEmail: (_context: RepositoryContext, resource: Writable<Customer>, { email }: CustomerChangeEmailAction) => void;
|
|
177
|
+
setFirstName: (_context: RepositoryContext, resource: Writable<Customer>, { firstName }: CustomerSetFirstNameAction) => void;
|
|
178
|
+
setLastName: (_context: RepositoryContext, resource: Writable<Customer>, { lastName }: CustomerSetLastNameAction) => void;
|
|
179
|
+
setCompanyName: (_context: RepositoryContext, resource: Writable<Customer>, { companyName }: CustomerSetCompanyNameAction) => void;
|
|
180
|
+
setVatId: (_context: RepositoryContext, resource: Writable<Customer>, { vatId }: CustomerSetVatIdAction) => void;
|
|
181
|
+
changeAddress: (context: RepositoryContext, resource: Writable<Customer>, { addressId, addressKey, address }: CustomerChangeAddressAction) => void;
|
|
177
182
|
setAuthenticationMode: (_context: RepositoryContext, resource: Writable<Customer>, { authMode, password }: CustomerSetAuthenticationModeAction) => void;
|
|
178
183
|
setCustomField: (_context: RepositoryContext, resource: Writable<Customer>, { name, value }: CustomerSetCustomFieldAction) => void;
|
|
179
184
|
};
|
|
@@ -256,11 +261,18 @@ declare class PaymentRepository extends AbstractResourceRepository<'payment'> {
|
|
|
256
261
|
create(context: RepositoryContext, draft: PaymentDraft): Payment;
|
|
257
262
|
transactionFromTransactionDraft: (draft: TransactionDraft, context: RepositoryContext) => Transaction;
|
|
258
263
|
actions: {
|
|
259
|
-
setCustomField: (context: RepositoryContext, resource: Payment, { name, value }: PaymentSetCustomFieldAction) => void;
|
|
260
|
-
setCustomType: (context: RepositoryContext, resource: Writable<Payment>, { type, fields }: PaymentSetCustomTypeAction) => void;
|
|
261
264
|
addTransaction: (context: RepositoryContext, resource: Writable<Payment>, { transaction }: PaymentAddTransactionAction) => void;
|
|
262
265
|
changeTransactionState: (_context: RepositoryContext, resource: Writable<Payment>, { transactionId, state }: PaymentChangeTransactionStateAction) => void;
|
|
263
266
|
transitionState: (context: RepositoryContext, resource: Writable<Payment>, { state }: PaymentTransitionStateAction) => void;
|
|
267
|
+
setCustomField: (context: RepositoryContext, resource: Payment, { name, value }: PaymentSetCustomFieldAction) => void;
|
|
268
|
+
setCustomType: (context: RepositoryContext, resource: Writable<Payment>, { type, fields }: PaymentSetCustomTypeAction) => void;
|
|
269
|
+
setKey: (_context: RepositoryContext, resource: Writable<Payment>, { key }: PaymentSetKeyAction) => void;
|
|
270
|
+
setStatusInterfaceCode: (_context: RepositoryContext, resource: Writable<Payment>, { interfaceCode }: PaymentSetStatusInterfaceCodeAction) => void;
|
|
271
|
+
setStatusInterfaceText: (_context: RepositoryContext, resource: Writable<Payment>, { interfaceText }: PaymentSetStatusInterfaceTextAction) => void;
|
|
272
|
+
setMethodInfoName: (_context: RepositoryContext, resource: Writable<Payment>, { name }: PaymentSetMethodInfoNameAction) => void;
|
|
273
|
+
setMethodInfoMethod: (_context: RepositoryContext, resource: Writable<Payment>, { method }: PaymentSetMethodInfoMethodAction) => void;
|
|
274
|
+
setMethodInfoInterface: (_context: RepositoryContext, resource: Writable<Payment>, args: PaymentSetMethodInfoInterfaceAction) => void;
|
|
275
|
+
setInterfaceId: (_context: RepositoryContext, resource: Writable<Payment>, { interfaceId }: PaymentSetInterfaceIdAction) => void;
|
|
264
276
|
};
|
|
265
277
|
}
|
|
266
278
|
|
|
@@ -718,4 +730,4 @@ declare const getBaseResourceProperties: () => {
|
|
|
718
730
|
version: number;
|
|
719
731
|
};
|
|
720
732
|
|
|
721
|
-
export { CommercetoolsMock, CommercetoolsMockOptions, getBaseResourceProperties };
|
|
733
|
+
export { CommercetoolsMock, type CommercetoolsMockOptions, getBaseResourceProperties };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { SetupServer } from 'msw/node';
|
|
3
3
|
import * as ctp from '@commercetools/platform-sdk';
|
|
4
|
-
import { Project, ResourceIdentifier, QueryParam, AssociateRoleDraft, AssociateRole, AssociateRoleSetNameAction, AssociateRoleSetPermissionsAction, AssociateRoleChangeBuyerAssignableAction, AssociateRoleSetCustomFieldAction, AssociateRoleAddPermissionAction, AssociateRoleRemovePermissionAction, AttributeGroupDraft, AttributeGroup, AttributeGroupSetAttributesAction, AttributeGroupChangeNameAction, AttributeGroupSetDescriptionAction, AttributeGroupSetKeyAction, BusinessUnitDraft, BusinessUnit, BusinessUnitAddAddressAction, BusinessUnitAddAssociateAction, BusinessUnitSetAssociatesAction, BusinessUnitSetContactEmailAction, BusinessUnitSetStoreModeAction, BusinessUnitChangeNameAction, BusinessUnitChangeAddressAction, BusinessUnitAddStoreAction, BusinessUnitChangeParentUnitAction, BusinessUnitChangeStatusAction, CartDraft, Cart, CartAddLineItemAction, CartAddItemShippingAddressAction, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomShippingMethodAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetLineItemShippingDetailsAction, CartSetShippingAddressAction, CartRemoveDiscountCodeAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, AssetDraft, Asset, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategoryChangeNameAction, CategoryChangeParentAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, CategoryRemoveAssetAction, CategoryAddAssetAction, ChannelDraft, Channel, ChannelUpdateAction, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerChangeEmailAction, CustomerSetAuthenticationModeAction, CustomerSetCustomFieldAction, CustomerGroupDraft, CustomerGroup, CustomerGroupSetKeyAction, CustomerGroupChangeNameAction, CustomerGroupSetCustomTypeAction, CustomerGroupSetCustomFieldAction, DiscountCodeDraft, DiscountCode, DiscountCodeUpdateAction, Extension, ExtensionDraft, ExtensionUpdateAction, InventoryEntryDraft, InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetRestockableInDaysAction, OrderFromCartDraft, Order, CartReference, OrderImportDraft, OrderAddPaymentAction, OrderAddReturnInfoAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderTransitionStateAction, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, OrderUpdateSyncInfoAction, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, OrderEditUpdateAction, PaymentDraft, Payment, TransactionDraft, Transaction, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction,
|
|
4
|
+
import { Project, ResourceIdentifier, QueryParam, AssociateRoleDraft, AssociateRole, AssociateRoleSetNameAction, AssociateRoleSetPermissionsAction, AssociateRoleChangeBuyerAssignableAction, AssociateRoleSetCustomFieldAction, AssociateRoleAddPermissionAction, AssociateRoleRemovePermissionAction, AttributeGroupDraft, AttributeGroup, AttributeGroupSetAttributesAction, AttributeGroupChangeNameAction, AttributeGroupSetDescriptionAction, AttributeGroupSetKeyAction, BusinessUnitDraft, BusinessUnit, BusinessUnitAddAddressAction, BusinessUnitAddAssociateAction, BusinessUnitSetAssociatesAction, BusinessUnitSetContactEmailAction, BusinessUnitSetStoreModeAction, BusinessUnitChangeNameAction, BusinessUnitChangeAddressAction, BusinessUnitAddStoreAction, BusinessUnitChangeParentUnitAction, BusinessUnitChangeStatusAction, CartDraft, Cart, CartAddLineItemAction, CartAddItemShippingAddressAction, CartChangeLineItemQuantityAction, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetShippingMethodAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomShippingMethodAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetLineItemShippingDetailsAction, CartSetShippingAddressAction, CartRemoveDiscountCodeAction, LineItemDraft, LineItem, CartDiscountDraft, CartDiscount, CartDiscountUpdateAction, AssetDraft, Asset, CategoryDraft, Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategoryChangeNameAction, CategoryChangeParentAction, CategorySetKeyAction, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, CategorySetCustomTypeAction, CategorySetCustomFieldAction, CategoryRemoveAssetAction, CategoryAddAssetAction, ChannelDraft, Channel, ChannelUpdateAction, CustomObjectDraft, CustomObject, CustomerDraft, Customer, CustomerChangeEmailAction, CustomerSetFirstNameAction, CustomerSetLastNameAction, CustomerSetCompanyNameAction, CustomerSetVatIdAction, CustomerChangeAddressAction, CustomerSetAuthenticationModeAction, CustomerSetCustomFieldAction, CustomerGroupDraft, CustomerGroup, CustomerGroupSetKeyAction, CustomerGroupChangeNameAction, CustomerGroupSetCustomTypeAction, CustomerGroupSetCustomFieldAction, DiscountCodeDraft, DiscountCode, DiscountCodeUpdateAction, Extension, ExtensionDraft, ExtensionUpdateAction, InventoryEntryDraft, InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetRestockableInDaysAction, OrderFromCartDraft, Order, CartReference, OrderImportDraft, OrderAddPaymentAction, OrderAddReturnInfoAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderTransitionStateAction, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, OrderUpdateSyncInfoAction, MyOrderFromCartDraft, OrderEditDraft, OrderEdit, OrderEditUpdateAction, PaymentDraft, Payment, TransactionDraft, Transaction, PaymentAddTransactionAction, PaymentChangeTransactionStateAction, PaymentTransitionStateAction, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, PaymentSetKeyAction, PaymentSetStatusInterfaceCodeAction, PaymentSetStatusInterfaceTextAction, PaymentSetMethodInfoNameAction, PaymentSetMethodInfoMethodAction, PaymentSetMethodInfoInterfaceAction, PaymentSetInterfaceIdAction, ProductDraft, Product, ProductUpdateAction, ProductDiscountDraft, ProductDiscount, ProductDiscountUpdateAction, ProductProjectionPagedSearchResponse, ProductProjection, FacetResults, TermFacetResult, FilteredFacetResult, RangeFacetResult, ProductSelectionDraft, ProductSelection, ProductSelectionUpdateAction, ProductTypeDraft, ProductType, AttributeDefinitionDraft, AttributeDefinition, ProductTypeUpdateAction, ProjectUpdateAction, QuoteDraft, Quote, QuoteUpdateAction, QuoteRequestDraft, QuoteRequest, QuoteRequestUpdateAction, ReviewDraft, Review, ReviewUpdateAction, ShippingMethodDraft, ShippingMethod, ZoneReference, ShippingRate, 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';
|
|
5
5
|
|
|
6
6
|
type Token = {
|
|
7
7
|
access_token: string;
|
|
@@ -174,6 +174,11 @@ declare class CustomerRepository extends AbstractResourceRepository<'customer'>
|
|
|
174
174
|
deleteMe(context: RepositoryContext): Customer | undefined;
|
|
175
175
|
actions: {
|
|
176
176
|
changeEmail: (_context: RepositoryContext, resource: Writable<Customer>, { email }: CustomerChangeEmailAction) => void;
|
|
177
|
+
setFirstName: (_context: RepositoryContext, resource: Writable<Customer>, { firstName }: CustomerSetFirstNameAction) => void;
|
|
178
|
+
setLastName: (_context: RepositoryContext, resource: Writable<Customer>, { lastName }: CustomerSetLastNameAction) => void;
|
|
179
|
+
setCompanyName: (_context: RepositoryContext, resource: Writable<Customer>, { companyName }: CustomerSetCompanyNameAction) => void;
|
|
180
|
+
setVatId: (_context: RepositoryContext, resource: Writable<Customer>, { vatId }: CustomerSetVatIdAction) => void;
|
|
181
|
+
changeAddress: (context: RepositoryContext, resource: Writable<Customer>, { addressId, addressKey, address }: CustomerChangeAddressAction) => void;
|
|
177
182
|
setAuthenticationMode: (_context: RepositoryContext, resource: Writable<Customer>, { authMode, password }: CustomerSetAuthenticationModeAction) => void;
|
|
178
183
|
setCustomField: (_context: RepositoryContext, resource: Writable<Customer>, { name, value }: CustomerSetCustomFieldAction) => void;
|
|
179
184
|
};
|
|
@@ -256,11 +261,18 @@ declare class PaymentRepository extends AbstractResourceRepository<'payment'> {
|
|
|
256
261
|
create(context: RepositoryContext, draft: PaymentDraft): Payment;
|
|
257
262
|
transactionFromTransactionDraft: (draft: TransactionDraft, context: RepositoryContext) => Transaction;
|
|
258
263
|
actions: {
|
|
259
|
-
setCustomField: (context: RepositoryContext, resource: Payment, { name, value }: PaymentSetCustomFieldAction) => void;
|
|
260
|
-
setCustomType: (context: RepositoryContext, resource: Writable<Payment>, { type, fields }: PaymentSetCustomTypeAction) => void;
|
|
261
264
|
addTransaction: (context: RepositoryContext, resource: Writable<Payment>, { transaction }: PaymentAddTransactionAction) => void;
|
|
262
265
|
changeTransactionState: (_context: RepositoryContext, resource: Writable<Payment>, { transactionId, state }: PaymentChangeTransactionStateAction) => void;
|
|
263
266
|
transitionState: (context: RepositoryContext, resource: Writable<Payment>, { state }: PaymentTransitionStateAction) => void;
|
|
267
|
+
setCustomField: (context: RepositoryContext, resource: Payment, { name, value }: PaymentSetCustomFieldAction) => void;
|
|
268
|
+
setCustomType: (context: RepositoryContext, resource: Writable<Payment>, { type, fields }: PaymentSetCustomTypeAction) => void;
|
|
269
|
+
setKey: (_context: RepositoryContext, resource: Writable<Payment>, { key }: PaymentSetKeyAction) => void;
|
|
270
|
+
setStatusInterfaceCode: (_context: RepositoryContext, resource: Writable<Payment>, { interfaceCode }: PaymentSetStatusInterfaceCodeAction) => void;
|
|
271
|
+
setStatusInterfaceText: (_context: RepositoryContext, resource: Writable<Payment>, { interfaceText }: PaymentSetStatusInterfaceTextAction) => void;
|
|
272
|
+
setMethodInfoName: (_context: RepositoryContext, resource: Writable<Payment>, { name }: PaymentSetMethodInfoNameAction) => void;
|
|
273
|
+
setMethodInfoMethod: (_context: RepositoryContext, resource: Writable<Payment>, { method }: PaymentSetMethodInfoMethodAction) => void;
|
|
274
|
+
setMethodInfoInterface: (_context: RepositoryContext, resource: Writable<Payment>, args: PaymentSetMethodInfoInterfaceAction) => void;
|
|
275
|
+
setInterfaceId: (_context: RepositoryContext, resource: Writable<Payment>, { interfaceId }: PaymentSetInterfaceIdAction) => void;
|
|
264
276
|
};
|
|
265
277
|
}
|
|
266
278
|
|
|
@@ -718,4 +730,4 @@ declare const getBaseResourceProperties: () => {
|
|
|
718
730
|
version: number;
|
|
719
731
|
};
|
|
720
732
|
|
|
721
|
-
export { CommercetoolsMock, CommercetoolsMockOptions, getBaseResourceProperties };
|
|
733
|
+
export { CommercetoolsMock, type CommercetoolsMockOptions, getBaseResourceProperties };
|
package/dist/index.js
CHANGED
|
@@ -3153,6 +3153,46 @@ var CustomerRepository = class extends AbstractResourceRepository {
|
|
|
3153
3153
|
changeEmail: (_context, resource, { email }) => {
|
|
3154
3154
|
resource.email = email;
|
|
3155
3155
|
},
|
|
3156
|
+
setFirstName: (_context, resource, { firstName }) => {
|
|
3157
|
+
resource.firstName = firstName;
|
|
3158
|
+
},
|
|
3159
|
+
setLastName: (_context, resource, { lastName }) => {
|
|
3160
|
+
resource.lastName = lastName;
|
|
3161
|
+
},
|
|
3162
|
+
setCompanyName: (_context, resource, { companyName }) => {
|
|
3163
|
+
resource.companyName = companyName;
|
|
3164
|
+
},
|
|
3165
|
+
setVatId: (_context, resource, { vatId }) => {
|
|
3166
|
+
resource.vatId = vatId;
|
|
3167
|
+
},
|
|
3168
|
+
changeAddress: (context, resource, { addressId, addressKey, address }) => {
|
|
3169
|
+
const oldAddressIndex = resource.addresses.findIndex((a) => {
|
|
3170
|
+
if (a.id != void 0 && addressId != void 0 && a.id === addressId) {
|
|
3171
|
+
return true;
|
|
3172
|
+
}
|
|
3173
|
+
return a.key != void 0 && addressKey != void 0 && a.key === addressKey;
|
|
3174
|
+
});
|
|
3175
|
+
if (oldAddressIndex === -1) {
|
|
3176
|
+
throw new CommercetoolsError(
|
|
3177
|
+
{
|
|
3178
|
+
code: "InvalidInput",
|
|
3179
|
+
message: `Address with id '${addressId}' or key '${addressKey}' not found.`
|
|
3180
|
+
},
|
|
3181
|
+
400
|
|
3182
|
+
);
|
|
3183
|
+
}
|
|
3184
|
+
const newAddress = createAddress(
|
|
3185
|
+
address,
|
|
3186
|
+
context.projectKey,
|
|
3187
|
+
this._storage
|
|
3188
|
+
);
|
|
3189
|
+
if (newAddress) {
|
|
3190
|
+
resource.addresses[oldAddressIndex] = {
|
|
3191
|
+
id: addressId,
|
|
3192
|
+
...newAddress
|
|
3193
|
+
};
|
|
3194
|
+
}
|
|
3195
|
+
},
|
|
3156
3196
|
setAuthenticationMode: (_context, resource, { authMode, password }) => {
|
|
3157
3197
|
if (resource.authenticationMode === authMode) {
|
|
3158
3198
|
throw new CommercetoolsError(
|
|
@@ -3902,32 +3942,6 @@ var PaymentRepository = class extends AbstractResourceRepository {
|
|
|
3902
3942
|
// Documented as default
|
|
3903
3943
|
});
|
|
3904
3944
|
actions = {
|
|
3905
|
-
setCustomField: (context, resource, { name, value }) => {
|
|
3906
|
-
if (!resource.custom) {
|
|
3907
|
-
throw new Error("Resource has no custom field");
|
|
3908
|
-
}
|
|
3909
|
-
resource.custom.fields[name] = value;
|
|
3910
|
-
},
|
|
3911
|
-
setCustomType: (context, resource, { type, fields }) => {
|
|
3912
|
-
if (!type) {
|
|
3913
|
-
resource.custom = void 0;
|
|
3914
|
-
} else {
|
|
3915
|
-
const resolvedType = this._storage.getByResourceIdentifier(
|
|
3916
|
-
context.projectKey,
|
|
3917
|
-
type
|
|
3918
|
-
);
|
|
3919
|
-
if (!resolvedType) {
|
|
3920
|
-
throw new Error(`Type ${type} not found`);
|
|
3921
|
-
}
|
|
3922
|
-
resource.custom = {
|
|
3923
|
-
type: {
|
|
3924
|
-
typeId: "type",
|
|
3925
|
-
id: resolvedType.id
|
|
3926
|
-
},
|
|
3927
|
-
fields: fields ?? {}
|
|
3928
|
-
};
|
|
3929
|
-
}
|
|
3930
|
-
},
|
|
3931
3945
|
addTransaction: (context, resource, { transaction }) => {
|
|
3932
3946
|
resource.transactions = [
|
|
3933
3947
|
...resource.transactions,
|
|
@@ -3957,24 +3971,60 @@ var PaymentRepository = class extends AbstractResourceRepository {
|
|
|
3957
3971
|
id: stateObj.id,
|
|
3958
3972
|
obj: stateObj
|
|
3959
3973
|
};
|
|
3974
|
+
},
|
|
3975
|
+
setCustomField: (context, resource, { name, value }) => {
|
|
3976
|
+
if (!resource.custom) {
|
|
3977
|
+
throw new Error("Resource has no custom field");
|
|
3978
|
+
}
|
|
3979
|
+
resource.custom.fields[name] = value;
|
|
3980
|
+
},
|
|
3981
|
+
setCustomType: (context, resource, { type, fields }) => {
|
|
3982
|
+
if (!type) {
|
|
3983
|
+
resource.custom = void 0;
|
|
3984
|
+
} else {
|
|
3985
|
+
const resolvedType = this._storage.getByResourceIdentifier(
|
|
3986
|
+
context.projectKey,
|
|
3987
|
+
type
|
|
3988
|
+
);
|
|
3989
|
+
if (!resolvedType) {
|
|
3990
|
+
throw new Error(`Type ${type} not found`);
|
|
3991
|
+
}
|
|
3992
|
+
resource.custom = {
|
|
3993
|
+
type: {
|
|
3994
|
+
typeId: "type",
|
|
3995
|
+
id: resolvedType.id
|
|
3996
|
+
},
|
|
3997
|
+
fields: fields ?? {}
|
|
3998
|
+
};
|
|
3999
|
+
}
|
|
4000
|
+
},
|
|
4001
|
+
setKey: (_context, resource, { key }) => {
|
|
4002
|
+
resource.key = key;
|
|
4003
|
+
},
|
|
4004
|
+
setStatusInterfaceCode: (_context, resource, { interfaceCode }) => {
|
|
4005
|
+
resource.paymentStatus.interfaceCode = interfaceCode;
|
|
4006
|
+
},
|
|
4007
|
+
setStatusInterfaceText: (_context, resource, { interfaceText }) => {
|
|
4008
|
+
resource.paymentStatus.interfaceText = interfaceText;
|
|
4009
|
+
},
|
|
4010
|
+
setMethodInfoName: (_context, resource, { name }) => {
|
|
4011
|
+
resource.paymentMethodInfo.name = name;
|
|
4012
|
+
},
|
|
4013
|
+
setMethodInfoMethod: (_context, resource, { method }) => {
|
|
4014
|
+
resource.paymentMethodInfo.method = method;
|
|
4015
|
+
},
|
|
4016
|
+
setMethodInfoInterface: (_context, resource, args) => {
|
|
4017
|
+
resource.paymentMethodInfo.paymentInterface = args.interface;
|
|
4018
|
+
},
|
|
4019
|
+
setInterfaceId: (_context, resource, { interfaceId }) => {
|
|
4020
|
+
resource.interfaceId = interfaceId;
|
|
3960
4021
|
}
|
|
3961
4022
|
// addInterfaceInteraction: () => {},
|
|
3962
4023
|
// changeAmountPlanned: () => {},
|
|
3963
4024
|
// changeTransactionInteractionId: () => {},
|
|
3964
4025
|
// changeTransactionTimestamp: () => {},
|
|
3965
|
-
// setAmountPaid: () => {},
|
|
3966
|
-
// setAmountRefunded: () => {},
|
|
3967
4026
|
// setAnonymousId: () => {},
|
|
3968
|
-
// setAuthorization: () => {},
|
|
3969
4027
|
// setCustomer: () => {},
|
|
3970
|
-
// setExternalId: () => {},
|
|
3971
|
-
// setInterfaceId: () => {},
|
|
3972
|
-
// setKey: () => {},
|
|
3973
|
-
// setMethodInfoInterface: () => {},
|
|
3974
|
-
// setMethodInfoMethod: () => {},
|
|
3975
|
-
// setMethodInfoName: () => {},
|
|
3976
|
-
// setStatusInterfaceCode: () => {},
|
|
3977
|
-
// setStatusInterfaceText: () => {},
|
|
3978
4028
|
};
|
|
3979
4029
|
};
|
|
3980
4030
|
|
|
@@ -6820,6 +6870,7 @@ var MyCustomerService = class extends AbstractService {
|
|
|
6820
6870
|
router.delete("", this.deleteMe.bind(this));
|
|
6821
6871
|
router.post("/signup", this.signUp.bind(this));
|
|
6822
6872
|
router.post("/login", this.signIn.bind(this));
|
|
6873
|
+
router.post("/password", this.changePassword.bind(this));
|
|
6823
6874
|
parent.use(`/${basePath}`, router);
|
|
6824
6875
|
}
|
|
6825
6876
|
getMe(request, response) {
|
|
@@ -6860,6 +6911,30 @@ var MyCustomerService = class extends AbstractService {
|
|
|
6860
6911
|
const result = this._expandWithId(request, resource.id);
|
|
6861
6912
|
return response.status(this.createStatusCode).send({ customer: result });
|
|
6862
6913
|
}
|
|
6914
|
+
changePassword(request, response) {
|
|
6915
|
+
const { currentPassword, newPassword } = request.body;
|
|
6916
|
+
const encodedPassword = hashPassword(currentPassword);
|
|
6917
|
+
const result = this.repository.query(getRepositoryContext(request), {
|
|
6918
|
+
where: [`password = "${encodedPassword}"`]
|
|
6919
|
+
});
|
|
6920
|
+
if (result.count === 0) {
|
|
6921
|
+
return response.status(404).send({
|
|
6922
|
+
message: "Account with the given credentials not found.",
|
|
6923
|
+
errors: [
|
|
6924
|
+
{
|
|
6925
|
+
code: "InvalidCredentials",
|
|
6926
|
+
message: "Account with the given credentials not found."
|
|
6927
|
+
}
|
|
6928
|
+
]
|
|
6929
|
+
});
|
|
6930
|
+
}
|
|
6931
|
+
const newCustomer = {
|
|
6932
|
+
...result.results[0],
|
|
6933
|
+
password: hashPassword(newPassword)
|
|
6934
|
+
};
|
|
6935
|
+
this.repository.saveNew(getRepositoryContext(request), newCustomer);
|
|
6936
|
+
return response.status(200).send(newCustomer);
|
|
6937
|
+
}
|
|
6863
6938
|
signIn(request, response) {
|
|
6864
6939
|
const { email, password } = request.body;
|
|
6865
6940
|
const encodedPassword = hashPassword(password);
|