@labdigital/commercetools-mock 0.5.13 → 0.5.16
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/README.md +6 -2
- package/dist/commercetools-mock.cjs.development.js +3087 -1642
- 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 +3087 -1642
- package/dist/commercetools-mock.esm.js.map +1 -1
- package/dist/ctMock.d.ts +1 -0
- package/dist/lib/masking.d.ts +1 -0
- package/dist/repositories/abstract.d.ts +9 -7
- package/dist/repositories/cart-discount.d.ts +9 -0
- package/dist/repositories/cart.d.ts +16 -3
- package/dist/repositories/category.d.ts +18 -0
- package/dist/repositories/channel.d.ts +6 -0
- package/dist/repositories/custom-object.d.ts +2 -2
- package/dist/repositories/customer-group.d.ts +11 -0
- package/dist/repositories/customer.d.ts +2 -2
- package/dist/repositories/discount-code.d.ts +8 -0
- package/dist/repositories/errors.d.ts +2 -2
- package/dist/repositories/extension.d.ts +8 -0
- package/dist/repositories/inventory-entry.d.ts +2 -2
- package/dist/repositories/order.d.ts +2 -2
- package/dist/repositories/payment.d.ts +4 -3
- package/dist/repositories/product-projection.d.ts +2 -2
- package/dist/repositories/product-type.d.ts +5 -4
- package/dist/repositories/product.d.ts +2 -2
- package/dist/repositories/project.d.ts +8 -0
- package/dist/repositories/shipping-method.d.ts +7 -5
- package/dist/repositories/shopping-list.d.ts +2 -2
- package/dist/repositories/state.d.ts +5 -4
- package/dist/repositories/store.d.ts +6 -3
- package/dist/repositories/subscription.d.ts +6 -0
- package/dist/repositories/tax-category.d.ts +6 -5
- package/dist/repositories/type.d.ts +5 -3
- package/dist/repositories/zone.d.ts +8 -0
- package/dist/services/abstract.d.ts +4 -3
- package/dist/services/cart-discount.d.ts +9 -0
- package/dist/services/category.d.ts +9 -0
- package/dist/services/channel.d.ts +9 -0
- package/dist/services/customer-group.d.ts +9 -0
- package/dist/services/discount-code.d.ts +9 -0
- package/dist/services/extension.d.ts +9 -0
- package/dist/services/my-cart.d.ts +11 -0
- package/dist/services/project.d.ts +11 -0
- package/dist/services/subscription.d.ts +9 -0
- package/dist/services/zone.d.ts +9 -0
- package/dist/storage.d.ts +10 -1
- package/dist/types.d.ts +2 -1
- package/package.json +20 -20
- package/src/ctMock.ts +44 -17
- package/src/lib/masking.ts +22 -0
- package/src/oauth/server.ts +3 -1
- package/src/repositories/abstract.ts +39 -33
- package/src/repositories/cart-discount.ts +140 -0
- package/src/repositories/cart.ts +247 -3
- package/src/repositories/category.ts +140 -0
- package/src/repositories/channel.ts +23 -0
- package/src/repositories/custom-object.ts +2 -2
- package/src/repositories/customer-group.ts +42 -0
- package/src/repositories/customer.ts +2 -2
- package/src/repositories/discount-code.ts +143 -0
- package/src/repositories/errors.ts +7 -2
- package/src/repositories/extension.ts +65 -0
- package/src/repositories/inventory-entry.ts +2 -2
- package/src/repositories/order.ts +2 -2
- package/src/repositories/payment.ts +10 -6
- package/src/repositories/product-projection.ts +4 -3
- package/src/repositories/product-type.ts +57 -4
- package/src/repositories/product.ts +4 -2
- package/src/repositories/project.ts +156 -0
- package/src/repositories/shipping-method.ts +149 -13
- package/src/repositories/shopping-list.ts +2 -2
- package/src/repositories/state.ts +48 -4
- package/src/repositories/store.ts +69 -4
- package/src/repositories/subscription.ts +50 -0
- package/src/repositories/tax-category.ts +80 -6
- package/src/repositories/type.ts +133 -3
- package/src/repositories/zone.ts +77 -0
- package/src/server.ts +6 -1
- package/src/services/abstract.ts +16 -15
- package/src/services/cart-discount.ts +17 -0
- package/src/services/cart.test.ts +314 -3
- package/src/services/category.test.ts +37 -0
- package/src/services/category.ts +17 -0
- package/src/services/channel.ts +17 -0
- package/src/services/custom-object.test.ts +3 -3
- package/src/services/customer-group.ts +17 -0
- package/src/services/discount-code.ts +17 -0
- package/src/services/extension.ts +17 -0
- package/src/services/inventory-entry.test.ts +3 -3
- package/src/services/my-cart.test.ts +93 -0
- package/src/services/my-cart.ts +44 -0
- package/src/services/my-payment.test.ts +2 -2
- package/src/services/order.test.ts +4 -4
- package/src/services/payment.test.ts +2 -2
- package/src/services/product-projection.test.ts +44 -6
- package/src/services/product-type.test.ts +2 -2
- package/src/services/product.test.ts +6 -2
- package/src/services/project.ts +42 -0
- package/src/services/shipping-method.test.ts +3 -3
- package/src/services/state.test.ts +2 -2
- package/src/services/subscription.ts +17 -0
- package/src/services/tax-category.test.ts +3 -3
- package/src/services/zone.ts +17 -0
- package/src/storage.ts +77 -3
- package/src/types.ts +2 -1
package/dist/ctMock.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const maskSecretValue: <T>(resource: T, path: string) => T;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RepositoryTypes } from './../types';
|
|
2
|
-
import { BaseResource, UpdateAction } from '@commercetools/platform-sdk';
|
|
2
|
+
import { BaseResource, Project, UpdateAction } from '@commercetools/platform-sdk';
|
|
3
3
|
import { AbstractStorage } from '../storage';
|
|
4
4
|
export declare type QueryParams = {
|
|
5
5
|
expand?: string[];
|
|
@@ -8,18 +8,20 @@ export declare type QueryParams = {
|
|
|
8
8
|
export declare type GetParams = {
|
|
9
9
|
expand?: string[];
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export declare abstract class AbstractRepository {
|
|
12
12
|
protected _storage: AbstractStorage;
|
|
13
|
-
protected actions:
|
|
14
|
-
[key: string]: (projectKey: string, resource: any, actions: any) => void;
|
|
15
|
-
};
|
|
13
|
+
protected actions: Partial<Record<any, (projectKey: string, resource: any, action: any) => void>>;
|
|
16
14
|
constructor(storage: AbstractStorage);
|
|
17
|
-
abstract
|
|
15
|
+
abstract save(projectKey: string, resource: BaseResource | Project): void;
|
|
16
|
+
processUpdateActions(projectKey: string, resource: BaseResource | Project, actions: UpdateAction[]): BaseResource;
|
|
17
|
+
}
|
|
18
|
+
export declare abstract class AbstractResourceRepository extends AbstractRepository {
|
|
18
19
|
abstract create(projectKey: string, draft: any): BaseResource;
|
|
20
|
+
abstract getTypeId(): RepositoryTypes;
|
|
21
|
+
constructor(storage: AbstractStorage);
|
|
19
22
|
query(projectKey: string, params?: QueryParams): import("@commercetools/platform-sdk").PagedQueryResponse;
|
|
20
23
|
get(projectKey: string, id: string, params?: GetParams): BaseResource | null;
|
|
21
24
|
getByKey(projectKey: string, key: string, params?: GetParams): BaseResource | null;
|
|
22
25
|
delete(projectKey: string, id: string, params?: GetParams): BaseResource | null;
|
|
23
26
|
save(projectKey: string, resource: BaseResource): void;
|
|
24
|
-
processUpdateActions(projectKey: string, resource: BaseResource, actions: UpdateAction[]): BaseResource;
|
|
25
27
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CartDiscount, CartDiscountDraft, CartDiscountUpdateAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
+
import { Writable } from 'types';
|
|
3
|
+
import { AbstractResourceRepository } from './abstract';
|
|
4
|
+
export declare class CartDiscountRepository extends AbstractResourceRepository {
|
|
5
|
+
getTypeId(): ReferenceTypeId;
|
|
6
|
+
create(projectKey: string, draft: CartDiscountDraft): CartDiscount;
|
|
7
|
+
private transformValueDraft;
|
|
8
|
+
actions: Partial<Record<CartDiscountUpdateAction['action'], (projectKey: string, resource: Writable<CartDiscount>, action: any) => void>>;
|
|
9
|
+
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import { Cart, CartDraft, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { Cart, CartAddLineItemAction, CartDraft, CartRemoveLineItemAction, CartSetBillingAddressAction, CartSetCountryAction, CartSetCustomerEmailAction, CartSetCustomFieldAction, CartSetCustomTypeAction, CartSetLocaleAction, CartSetShippingAddressAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { Writable } from '../types';
|
|
4
|
+
export declare class CartRepository extends AbstractResourceRepository {
|
|
4
5
|
getTypeId(): ReferenceTypeId;
|
|
5
6
|
create(projectKey: string, draft: CartDraft): Cart;
|
|
7
|
+
getActiveCart(projectKey: string): Cart | undefined;
|
|
8
|
+
actions: {
|
|
9
|
+
addLineItem: (projectKey: string, resource: Writable<Cart>, { productId, variantId, sku, quantity }: CartAddLineItemAction) => void;
|
|
10
|
+
removeLineItem: (projectKey: string, resource: Writable<Cart>, { lineItemId, quantity }: CartRemoveLineItemAction) => void;
|
|
11
|
+
setBillingAddress: (projectKey: string, resource: Writable<Cart>, { address }: CartSetBillingAddressAction) => void;
|
|
12
|
+
setCountry: (projectKey: string, resource: Writable<Cart>, { country }: CartSetCountryAction) => void;
|
|
13
|
+
setCustomerEmail: (projectKey: string, resource: Writable<Cart>, { email }: CartSetCustomerEmailAction) => void;
|
|
14
|
+
setCustomField: (projectKey: string, resource: Cart, { name, value }: CartSetCustomFieldAction) => void;
|
|
15
|
+
setCustomType: (projectKey: string, resource: Writable<Cart>, { type, fields }: CartSetCustomTypeAction) => void;
|
|
16
|
+
setLocale: (projectKey: string, resource: Writable<Cart>, { locale }: CartSetLocaleAction) => void;
|
|
17
|
+
setShippingAddress: (projectKey: string, resource: Writable<Cart>, { address }: CartSetShippingAddressAction) => void;
|
|
18
|
+
};
|
|
6
19
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Category, CategoryChangeAssetNameAction, CategoryChangeSlugAction, CategoryDraft, CategorySetAssetDescriptionAction, CategorySetAssetSourcesAction, CategorySetDescriptionAction, CategorySetKeyAction, CategorySetMetaDescriptionAction, CategorySetMetaKeywordsAction, CategorySetMetaTitleAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
+
import { Writable } from 'types';
|
|
3
|
+
import { AbstractResourceRepository } from './abstract';
|
|
4
|
+
export declare class CategoryRepository extends AbstractResourceRepository {
|
|
5
|
+
getTypeId(): ReferenceTypeId;
|
|
6
|
+
create(projectKey: string, draft: CategoryDraft): Category;
|
|
7
|
+
actions: {
|
|
8
|
+
changeAssetName: (projectKey: string, resource: Writable<Category>, { assetId, assetKey, name }: CategoryChangeAssetNameAction) => void;
|
|
9
|
+
changeSlug: (projectKey: string, resource: Writable<Category>, { slug }: CategoryChangeSlugAction) => void;
|
|
10
|
+
setKey: (projectKey: string, resource: Writable<Category>, { key }: CategorySetKeyAction) => void;
|
|
11
|
+
setAssetDescription: (projectKey: string, resource: Writable<Category>, { assetId, assetKey, description }: CategorySetAssetDescriptionAction) => void;
|
|
12
|
+
setAssetSources: (projectKey: string, resource: Writable<Category>, { assetId, assetKey, sources }: CategorySetAssetSourcesAction) => void;
|
|
13
|
+
setDescription: (projectKey: string, resource: Writable<Category>, { description }: CategorySetDescriptionAction) => void;
|
|
14
|
+
setMetaDescription: (projectKey: string, resource: Writable<Category>, { metaDescription }: CategorySetMetaDescriptionAction) => void;
|
|
15
|
+
setMetaKeywords: (projectKey: string, resource: Writable<Category>, { metaKeywords }: CategorySetMetaKeywordsAction) => void;
|
|
16
|
+
setMetaTitle: (projectKey: string, resource: Writable<Category>, { metaTitle }: CategorySetMetaTitleAction) => void;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Channel, ChannelDraft, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
export declare class ChannelRepository extends AbstractResourceRepository {
|
|
4
|
+
getTypeId(): ReferenceTypeId;
|
|
5
|
+
create(projectKey: string, draft: ChannelDraft): Channel;
|
|
6
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CustomObject, CustomObjectDraft, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
3
|
import { Writable } from '../types';
|
|
4
|
-
export declare class CustomObjectRepository extends
|
|
4
|
+
export declare class CustomObjectRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
6
|
create(projectKey: string, draft: Writable<CustomObjectDraft>): CustomObject;
|
|
7
7
|
getWithContainerAndKey(projectKey: string, container: string, key: string): CustomObject | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CustomerGroup, CustomerGroupChangeNameAction, CustomerGroupDraft, CustomerGroupSetKeyAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
+
import { Writable } from 'types';
|
|
3
|
+
import { AbstractResourceRepository } from './abstract';
|
|
4
|
+
export declare class CustomerGroupRepository extends AbstractResourceRepository {
|
|
5
|
+
getTypeId(): ReferenceTypeId;
|
|
6
|
+
create(projectKey: string, draft: CustomerGroupDraft): CustomerGroup;
|
|
7
|
+
actions: {
|
|
8
|
+
setKey: (projectKey: string, resource: Writable<CustomerGroup>, { key }: CustomerGroupSetKeyAction) => void;
|
|
9
|
+
changeName: (projectKey: string, resource: Writable<CustomerGroup>, { name }: CustomerGroupChangeNameAction) => void;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Customer, CustomerDraft, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import
|
|
3
|
-
export declare class CustomerRepository extends
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
export declare class CustomerRepository extends AbstractResourceRepository {
|
|
4
4
|
getTypeId(): ReferenceTypeId;
|
|
5
5
|
create(projectKey: string, draft: CustomerDraft): Customer;
|
|
6
6
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DiscountCode, DiscountCodeDraft, DiscountCodeUpdateAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
+
import { Writable } from 'types';
|
|
3
|
+
import { AbstractResourceRepository } from './abstract';
|
|
4
|
+
export declare class DiscountCodeRepository extends AbstractResourceRepository {
|
|
5
|
+
getTypeId(): ReferenceTypeId;
|
|
6
|
+
create(projectKey: string, draft: DiscountCodeDraft): DiscountCode;
|
|
7
|
+
actions: Partial<Record<DiscountCodeUpdateAction['action'], (projectKey: string, resource: Writable<DiscountCode>, action: any) => void>>;
|
|
8
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BaseResource } from '@commercetools/platform-sdk';
|
|
2
|
-
export declare const checkConcurrentModification: (resource: BaseResource, expectedVersion: number) => void;
|
|
1
|
+
import { BaseResource, Project } from '@commercetools/platform-sdk';
|
|
2
|
+
export declare const checkConcurrentModification: (resource: BaseResource | Project, expectedVersion: number) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Extension, ExtensionDraft, ExtensionUpdateAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
+
import { Writable } from '../types';
|
|
3
|
+
import { AbstractResourceRepository } from './abstract';
|
|
4
|
+
export declare class ExtensionRepository extends AbstractResourceRepository {
|
|
5
|
+
getTypeId(): ReferenceTypeId;
|
|
6
|
+
create(projectKey: string, draft: ExtensionDraft): Extension;
|
|
7
|
+
actions: Record<ExtensionUpdateAction['action'], (projectKey: string, resource: Writable<Extension>, action: any) => void>;
|
|
8
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InventoryEntry, InventoryEntryChangeQuantityAction, InventoryEntryDraft, InventoryEntrySetCustomFieldAction, InventoryEntrySetCustomTypeAction, InventoryEntrySetExpectedDeliveryAction, InventoryEntrySetRestockableInDaysAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
3
|
import { Writable } from '../types';
|
|
4
|
-
export declare class InventoryEntryRepository extends
|
|
4
|
+
export declare class InventoryEntryRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
6
|
create(projectKey: string, draft: InventoryEntryDraft): InventoryEntry;
|
|
7
7
|
actions: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Order, OrderAddPaymentAction, OrderChangeOrderStateAction, OrderChangePaymentStateAction, OrderFromCartDraft, OrderImportDraft, OrderSetBillingAddressAction, OrderSetCustomerEmailAction, OrderSetCustomFieldAction, OrderSetCustomTypeAction, OrderSetLocaleAction, OrderSetOrderNumberAction, OrderSetShippingAddressAction, OrderSetStoreAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import
|
|
2
|
+
import { AbstractResourceRepository, QueryParams } from './abstract';
|
|
3
3
|
import { Writable } from '../types';
|
|
4
|
-
export declare class OrderRepository extends
|
|
4
|
+
export declare class OrderRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
6
|
create(projectKey: string, draft: OrderFromCartDraft): Order;
|
|
7
7
|
import(projectKey: string, draft: OrderImportDraft): Order;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Payment, PaymentAddTransactionAction, PaymentDraft, PaymentSetCustomFieldAction, PaymentSetCustomTypeAction, ReferenceTypeId, TransactionDraft } from '@commercetools/platform-sdk';
|
|
2
|
-
import
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
3
|
import { Writable } from '../types';
|
|
4
|
-
export declare class PaymentRepository extends
|
|
4
|
+
export declare class PaymentRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
6
|
create(projectKey: string, draft: PaymentDraft): Payment;
|
|
7
|
-
transactionFromTransactionDraft: (draft: TransactionDraft) => {
|
|
7
|
+
transactionFromTransactionDraft: (draft: TransactionDraft, projectKey: string) => {
|
|
8
8
|
id: string;
|
|
9
9
|
amount: import("@commercetools/platform-sdk").TypedMoney;
|
|
10
|
+
custom: import("@commercetools/platform-sdk").CustomFields | undefined;
|
|
10
11
|
timestamp?: string | undefined;
|
|
11
12
|
type: import("@commercetools/platform-sdk").TransactionType;
|
|
12
13
|
interactionId?: string | undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ParsedQs } from 'qs';
|
|
2
2
|
import { ProductDraft, ProductProjection } from '@commercetools/platform-sdk';
|
|
3
|
-
import
|
|
3
|
+
import { AbstractResourceRepository } from './abstract';
|
|
4
4
|
import { RepositoryTypes } from '../types';
|
|
5
|
-
export declare class ProductProjectionRepository extends
|
|
5
|
+
export declare class ProductProjectionRepository extends AbstractResourceRepository {
|
|
6
6
|
getTypeId(): RepositoryTypes;
|
|
7
7
|
create(projectKey: string, draft: ProductDraft): ProductProjection;
|
|
8
8
|
search(projectKey: string, query: ParsedQs): import("@commercetools/platform-sdk").PagedQueryResponse;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AttributeDefinition, AttributeDefinitionDraft, ProductType, ProductTypeDraft, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { AttributeDefinition, AttributeDefinitionDraft, ProductType, ProductTypeDraft, ProductTypeUpdateAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { Writable } from 'types';
|
|
4
|
+
export declare class ProductTypeRepository extends AbstractResourceRepository {
|
|
4
5
|
getTypeId(): ReferenceTypeId;
|
|
5
6
|
create(projectKey: string, draft: ProductTypeDraft): ProductType;
|
|
6
7
|
attributeDefinitionFromAttributeDefinitionDraft: (_projectKey: string, draft: AttributeDefinitionDraft) => AttributeDefinition;
|
|
7
8
|
getWithKey(projectKey: string, key: string): ProductType | undefined;
|
|
8
|
-
actions:
|
|
9
|
+
actions: Partial<Record<ProductTypeUpdateAction['action'], (projectKey: string, resource: Writable<ProductType>, action: any) => void>>;
|
|
9
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Product, ProductDraft, ProductPublishAction, ProductSetAttributeAction, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
3
|
import { Writable } from '../types';
|
|
4
|
-
export declare class ProductRepository extends
|
|
4
|
+
export declare class ProductRepository extends AbstractResourceRepository {
|
|
5
5
|
getTypeId(): ReferenceTypeId;
|
|
6
6
|
create(projectKey: string, draft: ProductDraft): Product;
|
|
7
7
|
actions: {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Project, ProjectUpdateAction } from '@commercetools/platform-sdk';
|
|
2
|
+
import { Writable } from 'types';
|
|
3
|
+
import { AbstractRepository } from './abstract';
|
|
4
|
+
export declare class ProjectRepository extends AbstractRepository {
|
|
5
|
+
get(projectKey: string): Project | null;
|
|
6
|
+
save(projectKey: string, resource: Project): void;
|
|
7
|
+
actions: Partial<Record<ProjectUpdateAction['action'], (projectKey: string, resource: Writable<Project>, action: any) => void>>;
|
|
8
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { ReferenceTypeId, ShippingMethod, ShippingMethodDraft,
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { ReferenceTypeId, ShippingMethod, ShippingMethodDraft, ShippingMethodUpdateAction } from '@commercetools/platform-sdk';
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { Writable } from 'types';
|
|
4
|
+
export declare class ShippingMethodRepository extends AbstractResourceRepository {
|
|
4
5
|
getTypeId(): ReferenceTypeId;
|
|
5
6
|
create(projectKey: string, draft: ShippingMethodDraft): ShippingMethod;
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
private _transformZoneRateDraft;
|
|
8
|
+
private _transformShippingRate;
|
|
9
|
+
actions: Partial<Record<ShippingMethodUpdateAction['action'], (projectKey: string, resource: Writable<ShippingMethod>, action: any) => void>>;
|
|
8
10
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReferenceTypeId, ShoppingList, ShoppingListDraft } from '@commercetools/platform-sdk';
|
|
2
|
-
import
|
|
3
|
-
export declare class ShoppingListRepository extends
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
export declare class ShoppingListRepository extends AbstractResourceRepository {
|
|
4
4
|
getTypeId(): ReferenceTypeId;
|
|
5
5
|
create(projectKey: string, draft: ShoppingListDraft): ShoppingList;
|
|
6
6
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ReferenceTypeId, State, StateDraft } from '@commercetools/platform-sdk';
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { ReferenceTypeId, State, StateDraft, StateUpdateAction } from '@commercetools/platform-sdk';
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { Writable } from 'types';
|
|
4
|
+
export declare class StateRepository extends AbstractResourceRepository {
|
|
4
5
|
getTypeId(): ReferenceTypeId;
|
|
5
6
|
create(projectKey: string, draft: StateDraft): State;
|
|
6
|
-
actions:
|
|
7
|
+
actions: Partial<Record<StateUpdateAction['action'], (projectKey: string, resource: Writable<State>, action: any) => void>>;
|
|
7
8
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { Store, StoreDraft, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { Store, StoreDraft, ReferenceTypeId, StoreUpdateAction } from '@commercetools/platform-sdk';
|
|
2
|
+
import { Writable } from 'types';
|
|
3
|
+
import { AbstractResourceRepository } from './abstract';
|
|
4
|
+
export declare class StoreRepository extends AbstractResourceRepository {
|
|
4
5
|
getTypeId(): ReferenceTypeId;
|
|
5
6
|
create(projectKey: string, draft: StoreDraft): Store;
|
|
7
|
+
private transformChannels;
|
|
8
|
+
actions: Partial<Record<StoreUpdateAction['action'], (projectKey: string, resource: Writable<Store>, action: any) => void>>;
|
|
6
9
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ReferenceTypeId, Subscription, SubscriptionDraft } from '@commercetools/platform-sdk';
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
export declare class SubscriptionRepository extends AbstractResourceRepository {
|
|
4
|
+
getTypeId(): ReferenceTypeId;
|
|
5
|
+
create(projectKey: string, draft: SubscriptionDraft): Subscription;
|
|
6
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ReferenceTypeId, TaxCategory, TaxCategoryDraft,
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { ReferenceTypeId, TaxCategory, TaxCategoryDraft, TaxCategoryUpdateAction } from '@commercetools/platform-sdk';
|
|
2
|
+
import { AbstractResourceRepository } from './abstract';
|
|
3
|
+
import { Writable } from 'types';
|
|
4
|
+
export declare class TaxCategoryRepository extends AbstractResourceRepository {
|
|
4
5
|
getTypeId(): ReferenceTypeId;
|
|
5
6
|
create(projectKey: string, draft: TaxCategoryDraft): TaxCategory;
|
|
6
|
-
taxRateFromTaxRateDraft
|
|
7
|
+
private taxRateFromTaxRateDraft;
|
|
7
8
|
getWithKey(projectKey: string, key: string): TaxCategory | undefined;
|
|
8
|
-
actions:
|
|
9
|
+
actions: Partial<Record<TaxCategoryUpdateAction['action'], (projectKey: string, resource: Writable<TaxCategory>, action: any) => void>>;
|
|
9
10
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Type, TypeDraft, ReferenceTypeId } from '@commercetools/platform-sdk';
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { Type, TypeDraft, ReferenceTypeId, TypeUpdateAction } from '@commercetools/platform-sdk';
|
|
2
|
+
import { Writable } from 'types';
|
|
3
|
+
import { AbstractResourceRepository } from './abstract';
|
|
4
|
+
export declare class TypeRepository extends AbstractResourceRepository {
|
|
4
5
|
getTypeId(): ReferenceTypeId;
|
|
5
6
|
create(projectKey: string, draft: TypeDraft): Type;
|
|
7
|
+
actions: Partial<Record<TypeUpdateAction['action'], (projectKey: string, resource: Writable<Type>, action: any) => void>>;
|
|
6
8
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReferenceTypeId, Zone, ZoneDraft, ZoneUpdateAction } from '@commercetools/platform-sdk';
|
|
2
|
+
import { Writable } from 'types';
|
|
3
|
+
import { AbstractResourceRepository } from './abstract';
|
|
4
|
+
export declare class ZoneRepository extends AbstractResourceRepository {
|
|
5
|
+
getTypeId(): ReferenceTypeId;
|
|
6
|
+
create(projectKey: string, draft: ZoneDraft): Zone;
|
|
7
|
+
actions: Partial<Record<ZoneUpdateAction['action'], (projectKey: string, resource: Writable<Zone>, action: any) => void>>;
|
|
8
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Request, Response, Router } from 'express';
|
|
2
|
-
import
|
|
2
|
+
import { AbstractResourceRepository } from '../repositories/abstract';
|
|
3
3
|
export default abstract class AbstractService {
|
|
4
4
|
protected abstract getBasePath(): string;
|
|
5
|
-
abstract repository:
|
|
5
|
+
abstract repository: AbstractResourceRepository;
|
|
6
|
+
createStatusCode: number;
|
|
6
7
|
constructor(parent: Router);
|
|
7
8
|
extraRoutes(router: Router): void;
|
|
8
9
|
registerRoutes(parent: Router): void;
|
|
@@ -14,6 +15,6 @@ export default abstract class AbstractService {
|
|
|
14
15
|
post(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
15
16
|
postWithId(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
16
17
|
postWithKey(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
17
|
-
protected _expandWithId(request: Request,
|
|
18
|
+
protected _expandWithId(request: Request, resourceId: string): import("@commercetools/platform-sdk").BaseResource | null;
|
|
18
19
|
private _parseParam;
|
|
19
20
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import AbstractService from './abstract';
|
|
3
|
+
import { AbstractStorage } from '../storage';
|
|
4
|
+
import { CartDiscountRepository } from '../repositories/cart-discount';
|
|
5
|
+
export declare class CartDiscountService extends AbstractService {
|
|
6
|
+
repository: CartDiscountRepository;
|
|
7
|
+
constructor(parent: Router, storage: AbstractStorage);
|
|
8
|
+
getBasePath(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import AbstractService from './abstract';
|
|
2
|
+
import { Router } from 'express';
|
|
3
|
+
import { AbstractStorage } from '../storage';
|
|
4
|
+
import { CategoryRepository } from '../repositories/category';
|
|
5
|
+
export declare class CategoryServices extends AbstractService {
|
|
6
|
+
repository: CategoryRepository;
|
|
7
|
+
constructor(parent: Router, storage: AbstractStorage);
|
|
8
|
+
getBasePath(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import AbstractService from './abstract';
|
|
2
|
+
import { Router } from 'express';
|
|
3
|
+
import { ChannelRepository } from '../repositories/channel';
|
|
4
|
+
import { AbstractStorage } from '../storage';
|
|
5
|
+
export declare class ChannelService extends AbstractService {
|
|
6
|
+
repository: ChannelRepository;
|
|
7
|
+
constructor(parent: Router, storage: AbstractStorage);
|
|
8
|
+
getBasePath(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import AbstractService from './abstract';
|
|
2
|
+
import { Router } from 'express';
|
|
3
|
+
import { CustomerGroupRepository } from '../repositories/customer-group';
|
|
4
|
+
import { AbstractStorage } from '../storage';
|
|
5
|
+
export declare class CustomerGroupService extends AbstractService {
|
|
6
|
+
repository: CustomerGroupRepository;
|
|
7
|
+
constructor(parent: Router, storage: AbstractStorage);
|
|
8
|
+
getBasePath(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import AbstractService from './abstract';
|
|
3
|
+
import { AbstractStorage } from '../storage';
|
|
4
|
+
import { DiscountCodeRepository } from '../repositories/discount-code';
|
|
5
|
+
export declare class DiscountCodeService extends AbstractService {
|
|
6
|
+
repository: DiscountCodeRepository;
|
|
7
|
+
constructor(parent: Router, storage: AbstractStorage);
|
|
8
|
+
getBasePath(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import AbstractService from './abstract';
|
|
2
|
+
import { Router } from 'express';
|
|
3
|
+
import { AbstractStorage } from '../storage';
|
|
4
|
+
import { ExtensionRepository } from '../repositories/extension';
|
|
5
|
+
export declare class ExtensionServices extends AbstractService {
|
|
6
|
+
repository: ExtensionRepository;
|
|
7
|
+
constructor(parent: Router, storage: AbstractStorage);
|
|
8
|
+
getBasePath(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import AbstractService from './abstract';
|
|
2
|
+
import { Request, Response, Router } from 'express';
|
|
3
|
+
import { AbstractStorage } from '../storage';
|
|
4
|
+
import { CartRepository } from '../repositories/cart';
|
|
5
|
+
export declare class MyCartService extends AbstractService {
|
|
6
|
+
repository: CartRepository;
|
|
7
|
+
constructor(parent: Router, storage: AbstractStorage);
|
|
8
|
+
getBasePath(): string;
|
|
9
|
+
registerRoutes(parent: Router): void;
|
|
10
|
+
activeCart(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import { AbstractStorage } from '../storage';
|
|
4
|
+
import { ProjectRepository } from '../repositories/project';
|
|
5
|
+
export declare class ProjectService {
|
|
6
|
+
repository: ProjectRepository;
|
|
7
|
+
constructor(parent: Router, storage: AbstractStorage);
|
|
8
|
+
registerRoutes(parent: Router): void;
|
|
9
|
+
get(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
10
|
+
post(request: Request, response: Response): Response<any, Record<string, any>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import AbstractService from './abstract';
|
|
2
|
+
import { Router } from 'express';
|
|
3
|
+
import { AbstractStorage } from '../storage';
|
|
4
|
+
import { SubscriptionRepository } from '../repositories/subscription';
|
|
5
|
+
export declare class SubscriptionService extends AbstractService {
|
|
6
|
+
repository: SubscriptionRepository;
|
|
7
|
+
constructor(parent: Router, storage: AbstractStorage);
|
|
8
|
+
getBasePath(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
import AbstractService from './abstract';
|
|
3
|
+
import { AbstractStorage } from '../storage';
|
|
4
|
+
import { ZoneRepository } from '../repositories/zone';
|
|
5
|
+
export declare class ZoneService extends AbstractService {
|
|
6
|
+
repository: ZoneRepository;
|
|
7
|
+
constructor(parent: Router, storage: AbstractStorage);
|
|
8
|
+
getBasePath(): string;
|
|
9
|
+
}
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseResource, PagedQueryResponse, QueryParam, ResourceIdentifier } from '@commercetools/platform-sdk';
|
|
1
|
+
import { BaseResource, PagedQueryResponse, QueryParam, ResourceIdentifier, Project } from '@commercetools/platform-sdk';
|
|
2
2
|
import { RepositoryTypes, ResourceMap } from './types';
|
|
3
3
|
declare type GetParams = {
|
|
4
4
|
expand?: string[];
|
|
@@ -19,6 +19,9 @@ export declare abstract class AbstractStorage {
|
|
|
19
19
|
abstract add<RepositoryTypes extends keyof ResourceMap>(projectKey: string, typeId: RepositoryTypes, obj: ResourceMap[RepositoryTypes]): void;
|
|
20
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
|
+
abstract addProject(projectKey: string): Project;
|
|
23
|
+
abstract getProject(projectKey: string): Project;
|
|
24
|
+
abstract saveProject(project: Project): Project;
|
|
22
25
|
abstract delete(projectKey: string, typeId: RepositoryTypes, id: string, params: GetParams): BaseResource | null;
|
|
23
26
|
abstract query(projectKey: string, typeId: RepositoryTypes, params: QueryParams): PagedQueryResponse;
|
|
24
27
|
abstract getByResourceIdentifier(projectKey: string, identifier: ResourceIdentifier): BaseResource | undefined;
|
|
@@ -30,6 +33,9 @@ export declare class InMemoryStorage extends AbstractStorage {
|
|
|
30
33
|
protected resources: {
|
|
31
34
|
[projectKey: string]: ProjectStorage;
|
|
32
35
|
};
|
|
36
|
+
protected projects: {
|
|
37
|
+
[projectKey: string]: Project;
|
|
38
|
+
};
|
|
33
39
|
private forProjectKey;
|
|
34
40
|
clear(): void;
|
|
35
41
|
assertStorage(typeId: RepositoryTypes): void;
|
|
@@ -40,6 +46,9 @@ export declare class InMemoryStorage extends AbstractStorage {
|
|
|
40
46
|
delete(projectKey: string, typeId: RepositoryTypes, id: string, params?: GetParams): BaseResource | null;
|
|
41
47
|
query(projectKey: string, typeId: RepositoryTypes, params: QueryParams): PagedQueryResponse;
|
|
42
48
|
getByResourceIdentifier<RepositoryTypes extends keyof ResourceMap>(projectKey: string, identifier: ResourceIdentifier): ResourceMap[RepositoryTypes] | undefined;
|
|
49
|
+
addProject: (projectKey: string) => Project;
|
|
50
|
+
saveProject: (project: Project) => Project;
|
|
51
|
+
getProject: (projectKey: string) => Project;
|
|
43
52
|
private expand;
|
|
44
53
|
private _resolveResource;
|
|
45
54
|
private _resolveReference;
|
package/dist/types.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare type Writable<T> = {
|
|
|
18
18
|
-readonly [P in keyof T]: Writable<T[P]>;
|
|
19
19
|
};
|
|
20
20
|
export declare type RepositoryTypes = ReferenceTypeId | 'product-projection';
|
|
21
|
-
export declare type ServiceTypes = RepositoryTypes | 'my-payment';
|
|
21
|
+
export declare type ServiceTypes = RepositoryTypes | 'my-cart' | 'my-payment';
|
|
22
22
|
export declare type Services = Partial<{
|
|
23
23
|
[index in ServiceTypes]: AbstractService;
|
|
24
24
|
}>;
|
|
@@ -39,6 +39,7 @@ export declare type ResourceMap = {
|
|
|
39
39
|
product: ctp.Product;
|
|
40
40
|
'product-discount': ctp.ProductDiscount;
|
|
41
41
|
'product-projection': ctp.ProductProjection;
|
|
42
|
+
'product-selection': ctp.ProductSelection;
|
|
42
43
|
'product-type': ctp.ProductType;
|
|
43
44
|
review: ctp.Review;
|
|
44
45
|
'shipping-method': ctp.ShippingMethod;
|