@labdigital/commercetools-mock 0.6.1 → 0.6.4
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/commercetools-mock.cjs.development.js +365 -332
- package/dist/commercetools-mock.cjs.development.js.map +1 -1
- package/dist/commercetools-mock.cjs.production.min.js +1 -1
- package/dist/commercetools-mock.cjs.production.min.js.map +1 -1
- package/dist/commercetools-mock.esm.js +365 -332
- package/dist/commercetools-mock.esm.js.map +1 -1
- package/dist/projectAPI.d.ts +1 -1
- package/dist/repositories/abstract.d.ts +13 -9
- package/dist/repositories/cart-discount.d.ts +3 -3
- package/dist/repositories/cart.d.ts +12 -12
- package/dist/repositories/category.d.ts +11 -11
- package/dist/repositories/channel.d.ts +2 -2
- package/dist/repositories/custom-object.d.ts +3 -3
- package/dist/repositories/customer-group.d.ts +4 -4
- package/dist/repositories/customer.d.ts +4 -4
- package/dist/repositories/discount-code.d.ts +3 -3
- package/dist/repositories/extension.d.ts +3 -3
- package/dist/repositories/helpers.d.ts +3 -0
- package/dist/repositories/inventory-entry.d.ts +7 -7
- package/dist/repositories/my-order.d.ts +6 -0
- package/dist/repositories/order.d.ts +18 -17
- package/dist/repositories/payment.d.ts +8 -8
- package/dist/repositories/product-projection.d.ts +3 -3
- package/dist/repositories/product-type.d.ts +5 -5
- package/dist/repositories/product.d.ts +4 -4
- package/dist/repositories/project.d.ts +4 -4
- package/dist/repositories/shipping-method.d.ts +3 -3
- package/dist/repositories/shopping-list.d.ts +2 -2
- package/dist/repositories/state.d.ts +3 -3
- package/dist/repositories/store.d.ts +4 -4
- package/dist/repositories/subscription.d.ts +2 -2
- package/dist/repositories/tax-category.d.ts +4 -4
- package/dist/repositories/type.d.ts +3 -3
- package/dist/repositories/zone.d.ts +3 -3
- package/dist/services/my-order.d.ts +2 -2
- package/dist/storage.d.ts +1 -1
- package/package.json +1 -1
- package/src/ctMock.ts +6 -0
- package/src/projectAPI.ts +1 -1
- package/src/repositories/abstract.ts +37 -17
- package/src/repositories/cart-discount.ts +11 -11
- package/src/repositories/cart.ts +28 -19
- package/src/repositories/category.ts +17 -13
- package/src/repositories/channel.ts +3 -3
- package/src/repositories/custom-object.ts +16 -8
- package/src/repositories/customer-group.ts +5 -5
- package/src/repositories/customer.ts +10 -6
- package/src/repositories/discount-code.ts +14 -14
- package/src/repositories/errors.ts +3 -3
- package/src/repositories/extension.ts +12 -8
- package/src/repositories/helpers.ts +9 -0
- package/src/repositories/inventory-entry.ts +17 -10
- package/src/repositories/my-order.ts +19 -0
- package/src/repositories/order.test.ts +79 -3
- package/src/repositories/order.ts +77 -37
- package/src/repositories/payment.ts +21 -17
- package/src/repositories/product-projection.ts +5 -5
- package/src/repositories/product-type.ts +14 -10
- package/src/repositories/product.ts +5 -5
- package/src/repositories/project.ts +21 -17
- package/src/repositories/shipping-method.ts +27 -20
- package/src/repositories/shopping-list.ts +10 -6
- package/src/repositories/state.ts +13 -9
- package/src/repositories/store.ts +18 -14
- package/src/repositories/subscription.ts +3 -3
- package/src/repositories/tax-category.ts +16 -12
- package/src/repositories/type.ts +15 -11
- package/src/repositories/zone.ts +13 -9
- package/src/services/abstract.ts +17 -9
- package/src/services/cart.ts +6 -12
- package/src/services/custom-object.ts +8 -4
- package/src/services/customer.ts +5 -2
- package/src/services/my-customer.ts +7 -3
- package/src/services/my-order.ts +3 -3
- package/src/services/order.ts +3 -2
- package/src/services/product-projection.ts +2 -1
- package/src/services/product-type.ts +2 -1
- package/src/services/project.ts +4 -4
- package/src/services/store.ts +2 -1
- package/src/services/tax-category.ts +2 -1
- package/src/storage.ts +1 -1
package/dist/projectAPI.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export declare class ProjectAPI {
|
|
|
7
7
|
private _services;
|
|
8
8
|
constructor(projectKey: string, services: Services, storage: AbstractStorage);
|
|
9
9
|
add<ReferenceTypeId extends keyof ResourceMap>(typeId: ReferenceTypeId | 'custom-object', resource: ResourceMap[ReferenceTypeId]): void;
|
|
10
|
-
get<ReferenceTypeId extends keyof ResourceMap>(typeId: ReferenceTypeId, id: string, params
|
|
10
|
+
get<ReferenceTypeId extends keyof ResourceMap>(typeId: ReferenceTypeId, id: string, params?: GetParams): ResourceMap[ReferenceTypeId];
|
|
11
11
|
getRepository<ReferenceTypeId extends keyof RepositoryMap>(typeId: ReferenceTypeId): RepositoryMap[ReferenceTypeId];
|
|
12
12
|
}
|
|
@@ -10,20 +10,24 @@ export declare type QueryParams = {
|
|
|
10
10
|
export declare type GetParams = {
|
|
11
11
|
expand?: string[];
|
|
12
12
|
};
|
|
13
|
+
export declare type RepositoryContext = {
|
|
14
|
+
projectKey: string;
|
|
15
|
+
storeKey?: string;
|
|
16
|
+
};
|
|
13
17
|
export declare abstract class AbstractRepository {
|
|
14
18
|
protected _storage: AbstractStorage;
|
|
15
|
-
protected actions: Partial<Record<any, (
|
|
19
|
+
protected actions: Partial<Record<any, (context: RepositoryContext, resource: any, action: any) => void>>;
|
|
16
20
|
constructor(storage: AbstractStorage);
|
|
17
|
-
abstract save(projectKey:
|
|
18
|
-
processUpdateActions(
|
|
21
|
+
abstract save({ projectKey }: RepositoryContext, resource: BaseResource | Project): void;
|
|
22
|
+
processUpdateActions(context: RepositoryContext, resource: BaseResource | Project, actions: UpdateAction[]): BaseResource;
|
|
19
23
|
}
|
|
20
24
|
export declare abstract class AbstractResourceRepository extends AbstractRepository {
|
|
21
|
-
abstract create(
|
|
25
|
+
abstract create(context: RepositoryContext, draft: any): BaseResource;
|
|
22
26
|
abstract getTypeId(): RepositoryTypes;
|
|
23
27
|
constructor(storage: AbstractStorage);
|
|
24
|
-
query(
|
|
25
|
-
get(
|
|
26
|
-
getByKey(
|
|
27
|
-
delete(
|
|
28
|
-
save(
|
|
28
|
+
query(context: RepositoryContext, params?: QueryParams): import("@commercetools/platform-sdk").PagedQueryResponse;
|
|
29
|
+
get(context: RepositoryContext, id: string, params?: GetParams): BaseResource | null;
|
|
30
|
+
getByKey(context: RepositoryContext, key: string, params?: GetParams): BaseResource | null;
|
|
31
|
+
delete(context: RepositoryContext, id: string, params?: GetParams): BaseResource | null;
|
|
32
|
+
save(context: RepositoryContext, resource: BaseResource): void;
|
|
29
33
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CartDiscount, CartDiscountDraft, CartDiscountUpdateAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
2
|
import { Writable } from 'types';
|
|
3
|
-
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
4
4
|
export declare class CartDiscountRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
6
|
+
create(context: RepositoryContext, draft: CartDiscountDraft): CartDiscount;
|
|
7
7
|
private transformValueDraft;
|
|
8
|
-
actions: Partial<Record<CartDiscountUpdateAction['action'], (
|
|
8
|
+
actions: Partial<Record<CartDiscountUpdateAction['action'], (context: RepositoryContext, resource: Writable<CartDiscount>, action: any) => void>>;
|
|
9
9
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { Cart, CartAddLineItemAction, CartDraft, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, CartSetShippingMethodAction, LineItem, LineItemDraft, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository } from './abstract';
|
|
2
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
3
3
|
import { Writable } from '../types';
|
|
4
4
|
export declare class CartRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
6
|
+
create(context: RepositoryContext, draft: CartDraft): Cart;
|
|
7
7
|
getActiveCart(projectKey: string): Cart | undefined;
|
|
8
8
|
actions: {
|
|
9
|
-
addLineItem: (
|
|
10
|
-
removeLineItem: (
|
|
11
|
-
setBillingAddress: (
|
|
12
|
-
setShippingMethod: (
|
|
13
|
-
setCountry: (
|
|
14
|
-
setCustomerEmail: (
|
|
15
|
-
setCustomField: (
|
|
16
|
-
setCustomType: (
|
|
17
|
-
setLocale: (
|
|
18
|
-
setShippingAddress: (
|
|
9
|
+
addLineItem: (context: RepositoryContext, resource: Writable<Cart>, { productId, variantId, sku, quantity }: CartAddLineItemAction) => void;
|
|
10
|
+
removeLineItem: (context: RepositoryContext, resource: Writable<Cart>, { lineItemId, quantity }: CartRemoveLineItemAction) => void;
|
|
11
|
+
setBillingAddress: (context: RepositoryContext, resource: Writable<Cart>, { address }: CartSetBillingAddressAction) => void;
|
|
12
|
+
setShippingMethod: (context: RepositoryContext, resource: Writable<Cart>, { shippingMethod }: CartSetShippingMethodAction) => void;
|
|
13
|
+
setCountry: (context: RepositoryContext, resource: Writable<Cart>, { country }: CartSetCountryAction) => void;
|
|
14
|
+
setCustomerEmail: (context: RepositoryContext, resource: Writable<Cart>, { email }: CartSetCustomerEmailAction) => void;
|
|
15
|
+
setCustomField: (context: RepositoryContext, resource: Cart, { name, value }: CartSetCustomFieldAction) => void;
|
|
16
|
+
setCustomType: (context: RepositoryContext, resource: Writable<Cart>, { type, fields }: CartSetCustomTypeAction) => void;
|
|
17
|
+
setLocale: (context: RepositoryContext, resource: Writable<Cart>, { locale }: CartSetLocaleAction) => void;
|
|
18
|
+
setShippingAddress: (context: RepositoryContext, resource: Writable<Cart>, { address }: CartSetShippingAddressAction) => void;
|
|
19
19
|
};
|
|
20
20
|
draftLineItemtoLineItem: (projectKey: string, draftLineItem: LineItemDraft, currency: string, country: string | undefined) => LineItem;
|
|
21
21
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategoryDraft, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetKeyAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
2
|
import { Writable } from 'types';
|
|
3
|
-
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
4
4
|
export declare class CategoryRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
6
|
+
create(context: RepositoryContext, draft: CategoryDraft): Category;
|
|
7
7
|
actions: {
|
|
8
|
-
changeAssetName: (
|
|
9
|
-
changeSlug: (
|
|
10
|
-
setKey: (
|
|
11
|
-
setAssetDescription: (
|
|
12
|
-
setAssetSources: (
|
|
13
|
-
setDescription: (
|
|
14
|
-
setMetaDescription: (
|
|
15
|
-
setMetaKeywords: (
|
|
16
|
-
setMetaTitle: (
|
|
8
|
+
changeAssetName: (context: RepositoryContext, resource: Writable<Category>, { assetId, assetKey, name }: CategoryChangeAssetNameAction) => void;
|
|
9
|
+
changeSlug: (context: RepositoryContext, resource: Writable<Category>, { slug }: CategoryChangeSlugAction) => void;
|
|
10
|
+
setKey: (context: RepositoryContext, resource: Writable<Category>, { key }: CategorySetKeyAction) => void;
|
|
11
|
+
setAssetDescription: (context: RepositoryContext, resource: Writable<Category>, { assetId, assetKey, description }: CategorySetAssetDescriptionAction) => void;
|
|
12
|
+
setAssetSources: (context: RepositoryContext, resource: Writable<Category>, { assetId, assetKey, sources }: CategorySetAssetSourcesAction) => void;
|
|
13
|
+
setDescription: (context: RepositoryContext, resource: Writable<Category>, { description }: CategorySetDescriptionAction) => void;
|
|
14
|
+
setMetaDescription: (context: RepositoryContext, resource: Writable<Category>, { metaDescription }: CategorySetMetaDescriptionAction) => void;
|
|
15
|
+
setMetaKeywords: (context: RepositoryContext, resource: Writable<Category>, { metaKeywords }: CategorySetMetaKeywordsAction) => void;
|
|
16
|
+
setMetaTitle: (context: RepositoryContext, resource: Writable<Category>, { metaTitle }: CategorySetMetaTitleAction) => void;
|
|
17
17
|
};
|
|
18
18
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Channel, ChannelDraft, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository } from './abstract';
|
|
2
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
3
3
|
export declare class ChannelRepository extends AbstractResourceRepository {
|
|
4
4
|
getTypeId(): ReferenceTypeId;
|
|
5
|
-
create(
|
|
5
|
+
create(context: RepositoryContext, draft: ChannelDraft): Channel;
|
|
6
6
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CustomObject, CustomObjectDraft, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository } from './abstract';
|
|
2
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
3
3
|
import { Writable } from '../types';
|
|
4
4
|
export declare class CustomObjectRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
7
|
-
getWithContainerAndKey(
|
|
6
|
+
create(context: RepositoryContext, draft: Writable<CustomObjectDraft>): CustomObject;
|
|
7
|
+
getWithContainerAndKey(context: RepositoryContext, container: string, key: string): CustomObject | undefined;
|
|
8
8
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CustomerGroup, CustomerGroupChangeNameAction, CustomerGroupDraft, CustomerGroupSetKeyAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
2
|
import { Writable } from 'types';
|
|
3
|
-
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
4
4
|
export declare class CustomerGroupRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
6
|
+
create(context: RepositoryContext, draft: CustomerGroupDraft): CustomerGroup;
|
|
7
7
|
actions: {
|
|
8
|
-
setKey: (
|
|
9
|
-
changeName: (
|
|
8
|
+
setKey: (context: RepositoryContext, resource: Writable<CustomerGroup>, { key }: CustomerGroupSetKeyAction) => void;
|
|
9
|
+
changeName: (context: RepositoryContext, resource: Writable<CustomerGroup>, { name }: CustomerGroupChangeNameAction) => void;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Customer, CustomerChangeEmailAction, CustomerDraft, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
2
|
import { Writable } from 'types';
|
|
3
|
-
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
4
4
|
export declare class CustomerRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
7
|
-
getMe(
|
|
6
|
+
create(context: RepositoryContext, draft: CustomerDraft): Customer;
|
|
7
|
+
getMe(context: RepositoryContext): Customer | undefined;
|
|
8
8
|
actions: {
|
|
9
|
-
changeEmail: (
|
|
9
|
+
changeEmail: (_context: RepositoryContext, resource: Writable<Customer>, { email }: CustomerChangeEmailAction) => void;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DiscountCode, DiscountCodeDraft, DiscountCodeUpdateAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
2
|
import { Writable } from 'types';
|
|
3
|
-
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
4
4
|
export declare class DiscountCodeRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
7
|
-
actions: Partial<Record<DiscountCodeUpdateAction['action'], (
|
|
6
|
+
create(context: RepositoryContext, draft: DiscountCodeDraft): DiscountCode;
|
|
7
|
+
actions: Partial<Record<DiscountCodeUpdateAction['action'], (context: RepositoryContext, resource: Writable<DiscountCode>, action: any) => void>>;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Extension, ExtensionDraft, ExtensionUpdateAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
2
|
import { Writable } from '../types';
|
|
3
|
-
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
4
4
|
export declare class ExtensionRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
7
|
-
actions: Record<ExtensionUpdateAction['action'], (
|
|
6
|
+
create(context: RepositoryContext, draft: ExtensionDraft): Extension;
|
|
7
|
+
actions: Record<ExtensionUpdateAction['action'], (context: RepositoryContext, resource: Writable<Extension>, action: any) => void>;
|
|
8
8
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { CustomFields, CustomFieldsDraft, Money, Price, PriceDraft, Reference, ResourceIdentifier, StoreKeyReference, StoreResourceIdentifier, TypedMoney } from '@commercetools/platform-sdk';
|
|
2
2
|
import { AbstractStorage } from '../storage';
|
|
3
|
+
import { RepositoryContext } from './abstract';
|
|
4
|
+
import { Request } from 'express';
|
|
3
5
|
export declare const createCustomFields: (draft: CustomFieldsDraft | undefined, projectKey: string, storage: AbstractStorage) => CustomFields | undefined;
|
|
4
6
|
export declare const createPrice: (draft: PriceDraft) => Price;
|
|
5
7
|
export declare const createTypedMoney: (value: Money) => TypedMoney;
|
|
6
8
|
export declare const resolveStoreReference: (ref: StoreResourceIdentifier | undefined, projectKey: string, storage: AbstractStorage) => StoreKeyReference | undefined;
|
|
7
9
|
export declare const getReferenceFromResourceIdentifier: <T extends Reference>(resourceIdentifier: ResourceIdentifier, projectKey: string, storage: AbstractStorage) => T;
|
|
10
|
+
export declare const getRepositoryContext: (request: Request) => RepositoryContext;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntryDraft, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetRestockableInDaysAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository } from './abstract';
|
|
2
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
3
3
|
import { Writable } from '../types';
|
|
4
4
|
export declare class InventoryEntryRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
6
|
+
create(context: RepositoryContext, draft: InventoryEntryDraft): InventoryEntry;
|
|
7
7
|
actions: {
|
|
8
|
-
changeQuantity: (
|
|
9
|
-
setExpectedDelivery: (
|
|
10
|
-
setCustomField: (
|
|
11
|
-
setCustomType: (
|
|
12
|
-
setRestockableInDays: (
|
|
8
|
+
changeQuantity: (context: RepositoryContext, resource: Writable<InventoryEntry>, { quantity }: InventoryEntryChangeQuantityAction) => void;
|
|
9
|
+
setExpectedDelivery: (context: RepositoryContext, resource: Writable<InventoryEntry>, { expectedDelivery }: InventoryEntrySetExpectedDeliveryAction) => void;
|
|
10
|
+
setCustomField: (context: RepositoryContext, resource: InventoryEntry, { name, value }: InventoryEntrySetCustomFieldAction) => void;
|
|
11
|
+
setCustomType: (context: RepositoryContext, resource: Writable<InventoryEntry>, { type, fields }: InventoryEntrySetCustomTypeAction) => void;
|
|
12
|
+
setRestockableInDays: (context: RepositoryContext, resource: Writable<InventoryEntry>, { restockableInDays }: InventoryEntrySetRestockableInDaysAction) => void;
|
|
13
13
|
};
|
|
14
14
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MyOrderFromCartDraft, Order } from '@commercetools/platform-sdk';
|
|
2
|
+
import { OrderRepository } from './order';
|
|
3
|
+
import { RepositoryContext } from './abstract';
|
|
4
|
+
export declare class MyOrderRepository extends OrderRepository {
|
|
5
|
+
create(context: RepositoryContext, draft: MyOrderFromCartDraft): Order;
|
|
6
|
+
}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { Order, OrderAddPaymentAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderFromCartDraft, OrderImportDraft, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, OrderTransitionStateAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository, QueryParams } from './abstract';
|
|
1
|
+
import { CartReference, Order, OrderAddPaymentAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderFromCartDraft, OrderImportDraft, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, OrderTransitionStateAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
+
import { AbstractResourceRepository, QueryParams, RepositoryContext } from './abstract';
|
|
3
3
|
import { Writable } from '../types';
|
|
4
4
|
export declare class OrderRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
7
|
-
|
|
6
|
+
create(context: RepositoryContext, draft: OrderFromCartDraft): Order;
|
|
7
|
+
createFromCart(context: RepositoryContext, cartReference: CartReference, orderNumber?: string): Order;
|
|
8
|
+
import(context: RepositoryContext, draft: OrderImportDraft): Order;
|
|
8
9
|
private lineItemFromImportDraft;
|
|
9
10
|
private customLineItemFromImportDraft;
|
|
10
|
-
getWithOrderNumber(
|
|
11
|
+
getWithOrderNumber(context: RepositoryContext, orderNumber: string, params?: QueryParams): Order | undefined;
|
|
11
12
|
actions: {
|
|
12
|
-
addPayment: (
|
|
13
|
-
changeOrderState: (
|
|
14
|
-
changePaymentState: (
|
|
15
|
-
transitionState: (
|
|
16
|
-
setBillingAddress: (
|
|
17
|
-
setCustomerEmail: (
|
|
18
|
-
setCustomField: (
|
|
19
|
-
setCustomType: (
|
|
20
|
-
setLocale: (
|
|
21
|
-
setOrderNumber: (
|
|
22
|
-
setShippingAddress: (
|
|
23
|
-
setStore: (
|
|
13
|
+
addPayment: (context: RepositoryContext, resource: Writable<Order>, { payment }: OrderAddPaymentAction) => void;
|
|
14
|
+
changeOrderState: (context: RepositoryContext, resource: Writable<Order>, { orderState }: OrderChangeOrderStateAction) => void;
|
|
15
|
+
changePaymentState: (context: RepositoryContext, resource: Writable<Order>, { paymentState }: OrderChangePaymentStateAction) => void;
|
|
16
|
+
transitionState: (context: RepositoryContext, resource: Writable<Order>, { state }: OrderTransitionStateAction) => void;
|
|
17
|
+
setBillingAddress: (context: RepositoryContext, resource: Writable<Order>, { address }: OrderSetBillingAddressAction) => void;
|
|
18
|
+
setCustomerEmail: (context: RepositoryContext, resource: Writable<Order>, { email }: OrderSetCustomerEmailAction) => void;
|
|
19
|
+
setCustomField: (context: RepositoryContext, resource: Order, { name, value }: OrderSetCustomFieldAction) => void;
|
|
20
|
+
setCustomType: (context: RepositoryContext, resource: Writable<Order>, { type, fields }: OrderSetCustomTypeAction) => void;
|
|
21
|
+
setLocale: (context: RepositoryContext, resource: Writable<Order>, { locale }: OrderSetLocaleAction) => void;
|
|
22
|
+
setOrderNumber: (context: RepositoryContext, resource: Writable<Order>, { orderNumber }: OrderSetOrderNumberAction) => void;
|
|
23
|
+
setShippingAddress: (context: RepositoryContext, resource: Writable<Order>, { address }: OrderSetShippingAddressAction) => void;
|
|
24
|
+
setStore: (context: RepositoryContext, resource: Writable<Order>, { store }: OrderSetStoreAction) => void;
|
|
24
25
|
};
|
|
25
26
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Payment, PaymentAddTransactionAction, PaymentChangeTransactionStateAction, PaymentDraft, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, PaymentTransitionStateAction, ReferenceTypeId, TransactionDraft } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository } from './abstract';
|
|
2
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
3
3
|
import { Writable } from '../types';
|
|
4
4
|
export declare class PaymentRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
7
|
-
transactionFromTransactionDraft: (draft: TransactionDraft,
|
|
6
|
+
create(context: RepositoryContext, draft: PaymentDraft): Payment;
|
|
7
|
+
transactionFromTransactionDraft: (draft: TransactionDraft, context: RepositoryContext) => {
|
|
8
8
|
id: string;
|
|
9
9
|
amount: import("@commercetools/platform-sdk").TypedMoney;
|
|
10
10
|
custom: import("@commercetools/platform-sdk").CustomFields | undefined;
|
|
@@ -14,10 +14,10 @@ export declare class PaymentRepository extends AbstractResourceRepository {
|
|
|
14
14
|
state?: "Failure" | "Initial" | "Pending" | "Success" | undefined;
|
|
15
15
|
};
|
|
16
16
|
actions: {
|
|
17
|
-
setCustomField: (
|
|
18
|
-
setCustomType: (
|
|
19
|
-
addTransaction: (
|
|
20
|
-
changeTransactionState: (
|
|
21
|
-
transitionState: (
|
|
17
|
+
setCustomField: (context: RepositoryContext, resource: Payment, { name, value }: PaymentSetCustomFieldAction) => void;
|
|
18
|
+
setCustomType: (context: RepositoryContext, resource: Writable<Payment>, { type, fields }: PaymentSetCustomTypeAction) => void;
|
|
19
|
+
addTransaction: (context: RepositoryContext, resource: Writable<Payment>, { transaction }: PaymentAddTransactionAction) => void;
|
|
20
|
+
changeTransactionState: (_context: RepositoryContext, resource: Writable<Payment>, { transactionId, state }: PaymentChangeTransactionStateAction) => void;
|
|
21
|
+
transitionState: (context: RepositoryContext, resource: Writable<Payment>, { state }: PaymentTransitionStateAction) => void;
|
|
22
22
|
};
|
|
23
23
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ParsedQs } from 'qs';
|
|
2
2
|
import { ProductDraft, ProductProjection } from '@commercetools/platform-sdk';
|
|
3
|
-
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
4
4
|
import { RepositoryTypes } from '../types';
|
|
5
5
|
export declare class ProductProjectionRepository extends AbstractResourceRepository {
|
|
6
6
|
getTypeId(): RepositoryTypes;
|
|
7
|
-
create(
|
|
8
|
-
search(
|
|
7
|
+
create(context: RepositoryContext, draft: ProductDraft): ProductProjection;
|
|
8
|
+
search(context: RepositoryContext, query: ParsedQs): import("@commercetools/platform-sdk").PagedQueryResponse;
|
|
9
9
|
actions: {};
|
|
10
10
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AttributeDefinition, AttributeDefinitionDraft, ProductType, ProductTypeDraft, ProductTypeUpdateAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository } from './abstract';
|
|
2
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
3
3
|
import { Writable } from 'types';
|
|
4
4
|
export declare class ProductTypeRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
7
|
-
attributeDefinitionFromAttributeDefinitionDraft: (
|
|
8
|
-
getWithKey(
|
|
9
|
-
actions: Partial<Record<ProductTypeUpdateAction['action'], (
|
|
6
|
+
create(context: RepositoryContext, draft: ProductTypeDraft): ProductType;
|
|
7
|
+
attributeDefinitionFromAttributeDefinitionDraft: (_context: RepositoryContext, draft: AttributeDefinitionDraft) => AttributeDefinition;
|
|
8
|
+
getWithKey(context: RepositoryContext, key: string): ProductType | undefined;
|
|
9
|
+
actions: Partial<Record<ProductTypeUpdateAction['action'], (context: RepositoryContext, resource: Writable<ProductType>, action: any) => void>>;
|
|
10
10
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Product, ProductDraft, ProductPublishAction, ProductSetAttributeAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository } from './abstract';
|
|
2
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
3
3
|
import { Writable } from '../types';
|
|
4
4
|
export declare class ProductRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
6
|
+
create(context: RepositoryContext, draft: ProductDraft): Product;
|
|
7
7
|
actions: {
|
|
8
|
-
publish: (
|
|
9
|
-
setAttribute: (
|
|
8
|
+
publish: (context: RepositoryContext, resource: Writable<Product>, { scope }: ProductPublishAction) => void;
|
|
9
|
+
setAttribute: (context: RepositoryContext, resource: Writable<Product>, { variantId, sku, name, value, staged }: ProductSetAttributeAction) => void;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Project, ProjectUpdateAction } from '@commercetools/platform-sdk';
|
|
2
2
|
import { Writable } from 'types';
|
|
3
|
-
import { AbstractRepository } from './abstract';
|
|
3
|
+
import { AbstractRepository, RepositoryContext } from './abstract';
|
|
4
4
|
export declare class ProjectRepository extends AbstractRepository {
|
|
5
|
-
get(
|
|
6
|
-
save(
|
|
7
|
-
actions: Partial<Record<ProjectUpdateAction['action'], (
|
|
5
|
+
get(context: RepositoryContext): Project | null;
|
|
6
|
+
save(context: RepositoryContext, resource: Project): void;
|
|
7
|
+
actions: Partial<Record<ProjectUpdateAction['action'], (context: RepositoryContext, resource: Writable<Project>, action: any) => void>>;
|
|
8
8
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ReferenceTypeId, ShippingMethod, ShippingMethodDraft, ShippingMethodUpdateAction } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository } from './abstract';
|
|
2
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
3
3
|
import { Writable } from 'types';
|
|
4
4
|
export declare class ShippingMethodRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
6
|
+
create(context: RepositoryContext, draft: ShippingMethodDraft): ShippingMethod;
|
|
7
7
|
private _transformZoneRateDraft;
|
|
8
8
|
private _transformShippingRate;
|
|
9
|
-
actions: Partial<Record<ShippingMethodUpdateAction['action'], (
|
|
9
|
+
actions: Partial<Record<ShippingMethodUpdateAction['action'], (context: RepositoryContext, resource: Writable<ShippingMethod>, action: any) => void>>;
|
|
10
10
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReferenceTypeId, ShoppingList, ShoppingListDraft } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository } from './abstract';
|
|
2
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
3
3
|
export declare class ShoppingListRepository extends AbstractResourceRepository {
|
|
4
4
|
getTypeId(): ReferenceTypeId;
|
|
5
|
-
create(
|
|
5
|
+
create(context: RepositoryContext, draft: ShoppingListDraft): ShoppingList;
|
|
6
6
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReferenceTypeId, State, StateDraft, StateUpdateAction } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository } from './abstract';
|
|
2
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
3
3
|
import { Writable } from 'types';
|
|
4
4
|
export declare class StateRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
7
|
-
actions: Partial<Record<StateUpdateAction['action'], (
|
|
6
|
+
create(context: RepositoryContext, draft: StateDraft): State;
|
|
7
|
+
actions: Partial<Record<StateUpdateAction['action'], (context: RepositoryContext, resource: Writable<State>, action: any) => void>>;
|
|
8
8
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Store, StoreDraft, ReferenceTypeId, StoreUpdateAction } from '@commercetools/platform-sdk';
|
|
2
2
|
import { Writable } from 'types';
|
|
3
|
-
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
4
4
|
export declare class StoreRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
6
|
+
create(context: RepositoryContext, draft: StoreDraft): Store;
|
|
7
7
|
private transformChannels;
|
|
8
|
-
getWithKey(
|
|
9
|
-
actions: Partial<Record<StoreUpdateAction['action'], (
|
|
8
|
+
getWithKey(context: RepositoryContext, key: string): Store | undefined;
|
|
9
|
+
actions: Partial<Record<StoreUpdateAction['action'], (context: RepositoryContext, resource: Writable<Store>, action: any) => void>>;
|
|
10
10
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReferenceTypeId, Subscription, SubscriptionDraft } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository } from './abstract';
|
|
2
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
3
3
|
export declare class SubscriptionRepository extends AbstractResourceRepository {
|
|
4
4
|
getTypeId(): ReferenceTypeId;
|
|
5
|
-
create(
|
|
5
|
+
create(context: RepositoryContext, draft: SubscriptionDraft): Subscription;
|
|
6
6
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ReferenceTypeId, TaxCategory, TaxCategoryDraft, TaxCategoryUpdateAction } from '@commercetools/platform-sdk';
|
|
2
|
-
import { AbstractResourceRepository } from './abstract';
|
|
2
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
3
3
|
import { Writable } from 'types';
|
|
4
4
|
export declare class TaxCategoryRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
6
|
+
create(context: RepositoryContext, draft: TaxCategoryDraft): TaxCategory;
|
|
7
7
|
private taxRateFromTaxRateDraft;
|
|
8
|
-
getWithKey(
|
|
9
|
-
actions: Partial<Record<TaxCategoryUpdateAction['action'], (
|
|
8
|
+
getWithKey(context: RepositoryContext, key: string): TaxCategory | undefined;
|
|
9
|
+
actions: Partial<Record<TaxCategoryUpdateAction['action'], (context: RepositoryContext, resource: Writable<TaxCategory>, action: any) => void>>;
|
|
10
10
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Type, TypeDraft, ReferenceTypeId, TypeUpdateAction } from '@commercetools/platform-sdk';
|
|
2
2
|
import { Writable } from 'types';
|
|
3
|
-
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
4
4
|
export declare class TypeRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
7
|
-
actions: Partial<Record<TypeUpdateAction['action'], (
|
|
6
|
+
create(context: RepositoryContext, draft: TypeDraft): Type;
|
|
7
|
+
actions: Partial<Record<TypeUpdateAction['action'], (context: RepositoryContext, resource: Writable<Type>, action: any) => void>>;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReferenceTypeId, Zone, ZoneDraft, ZoneUpdateAction } from '@commercetools/platform-sdk';
|
|
2
2
|
import { Writable } from 'types';
|
|
3
|
-
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract';
|
|
4
4
|
export declare class ZoneRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
|
-
create(
|
|
7
|
-
actions: Partial<Record<ZoneUpdateAction['action'], (
|
|
6
|
+
create(context: RepositoryContext, draft: ZoneDraft): Zone;
|
|
7
|
+
actions: Partial<Record<ZoneUpdateAction['action'], (context: RepositoryContext, resource: Writable<Zone>, action: any) => void>>;
|
|
8
8
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import AbstractService from './abstract';
|
|
2
2
|
import { Router } from 'express';
|
|
3
3
|
import { AbstractStorage } from '../storage';
|
|
4
|
-
import {
|
|
4
|
+
import { MyOrderRepository } from '../repositories/my-order';
|
|
5
5
|
export declare class MyOrderService extends AbstractService {
|
|
6
|
-
repository:
|
|
6
|
+
repository: MyOrderRepository;
|
|
7
7
|
constructor(parent: Router, storage: AbstractStorage);
|
|
8
8
|
getBasePath(): string;
|
|
9
9
|
registerRoutes(parent: Router): void;
|
package/dist/storage.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare abstract class AbstractStorage {
|
|
|
17
17
|
abstract assertStorage(typeId: RepositoryTypes): void;
|
|
18
18
|
abstract all(projectKey: string, typeId: RepositoryTypes): Array<BaseResource>;
|
|
19
19
|
abstract add<RepositoryTypes extends keyof ResourceMap>(projectKey: string, typeId: RepositoryTypes, obj: ResourceMap[RepositoryTypes]): void;
|
|
20
|
-
abstract get<RepositoryTypes extends keyof ResourceMap>(projectKey: string, typeId: RepositoryTypes, id: string, params
|
|
20
|
+
abstract get<RepositoryTypes extends keyof ResourceMap>(projectKey: string, typeId: RepositoryTypes, id: string, params?: GetParams): ResourceMap[RepositoryTypes] | null;
|
|
21
21
|
abstract getByKey<RepositoryTypes extends keyof ResourceMap>(projectKey: string, typeId: RepositoryTypes, key: string, params: GetParams): ResourceMap[RepositoryTypes] | null;
|
|
22
22
|
abstract addProject(projectKey: string): Project;
|
|
23
23
|
abstract getProject(projectKey: string): Project;
|
package/package.json
CHANGED
package/src/ctMock.ts
CHANGED
|
@@ -139,8 +139,14 @@ export class CommercetoolsMock {
|
|
|
139
139
|
// Only enable auth middleware if we have enabled this
|
|
140
140
|
if (this.options.enableAuthentication) {
|
|
141
141
|
app.use('/:projectKey', this._oauth2.createMiddleware(), projectRouter)
|
|
142
|
+
app.use(
|
|
143
|
+
'/:projectKey/in-store/key=:storeKey',
|
|
144
|
+
this._oauth2.createMiddleware(),
|
|
145
|
+
projectRouter
|
|
146
|
+
)
|
|
142
147
|
} else {
|
|
143
148
|
app.use('/:projectKey', projectRouter)
|
|
149
|
+
app.use('/:projectKey/in-store/key=:storeKey', projectRouter)
|
|
144
150
|
}
|
|
145
151
|
|
|
146
152
|
this._projectService = new ProjectService(projectRouter, this._storage)
|
package/src/projectAPI.ts
CHANGED