@reactionary/fake 0.6.3
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 +11 -0
- package/capabilities/analytics.capability.js +15 -0
- package/capabilities/cart.capability.js +261 -0
- package/capabilities/category.capability.js +160 -0
- package/capabilities/checkout.capability.js +231 -0
- package/capabilities/identity.capability.js +89 -0
- package/capabilities/index.js +15 -0
- package/capabilities/inventory.capability.js +59 -0
- package/capabilities/order-search.capability.js +74 -0
- package/capabilities/order.capability.js +81 -0
- package/capabilities/price.capability.js +99 -0
- package/capabilities/product-associations.capability.js +121 -0
- package/capabilities/product-reviews.capability.js +154 -0
- package/capabilities/product-search.capability.js +145 -0
- package/capabilities/product.capability.js +99 -0
- package/capabilities/profile.capability.js +130 -0
- package/capabilities/store.capability.js +59 -0
- package/core/initialize.js +235 -0
- package/core/initialize.types.js +8 -0
- package/factories/cart/cart.factory.js +17 -0
- package/factories/category/category.factory.js +17 -0
- package/factories/checkout/checkout.factory.js +22 -0
- package/factories/identity/identity.factory.js +12 -0
- package/factories/index.js +14 -0
- package/factories/inventory/inventory.factory.js +12 -0
- package/factories/order/order.factory.js +12 -0
- package/factories/order-search/order-search.factory.js +12 -0
- package/factories/price/price.factory.js +12 -0
- package/factories/product/product.factory.js +12 -0
- package/factories/product-associations/product-associations.factory.js +12 -0
- package/factories/product-reviews/product-reviews.factory.js +22 -0
- package/factories/product-search/product-search.factory.js +12 -0
- package/factories/profile/profile.factory.js +12 -0
- package/factories/store/store.factory.js +12 -0
- package/index.js +6 -0
- package/package.json +15 -0
- package/schema/capabilities.schema.js +41 -0
- package/schema/configuration.schema.js +18 -0
- package/src/capabilities/analytics.capability.d.ts +8 -0
- package/src/capabilities/cart.capability.d.ts +22 -0
- package/src/capabilities/category.capability.d.ts +20 -0
- package/src/capabilities/checkout.capability.d.ts +56 -0
- package/src/capabilities/identity.capability.d.ts +13 -0
- package/src/capabilities/index.d.ts +15 -0
- package/src/capabilities/inventory.capability.d.ts +10 -0
- package/src/capabilities/order-search.capability.d.ts +11 -0
- package/src/capabilities/order.capability.d.ts +11 -0
- package/src/capabilities/price.capability.d.ts +13 -0
- package/src/capabilities/product-associations.capability.d.ts +15 -0
- package/src/capabilities/product-reviews.capability.d.ts +13 -0
- package/src/capabilities/product-search.capability.d.ts +10 -0
- package/src/capabilities/product.capability.d.ts +12 -0
- package/src/capabilities/profile.capability.d.ts +18 -0
- package/src/capabilities/store.capability.d.ts +10 -0
- package/src/core/initialize.d.ts +5 -0
- package/src/core/initialize.types.d.ts +113 -0
- package/src/factories/cart/cart.factory.d.ts +9 -0
- package/src/factories/category/category.factory.d.ts +9 -0
- package/src/factories/checkout/checkout.factory.d.ts +11 -0
- package/src/factories/identity/identity.factory.d.ts +7 -0
- package/src/factories/index.d.ts +14 -0
- package/src/factories/inventory/inventory.factory.d.ts +7 -0
- package/src/factories/order/order.factory.d.ts +7 -0
- package/src/factories/order-search/order-search.factory.d.ts +7 -0
- package/src/factories/price/price.factory.d.ts +9 -0
- package/src/factories/product/product.factory.d.ts +7 -0
- package/src/factories/product-associations/product-associations.factory.d.ts +7 -0
- package/src/factories/product-reviews/product-reviews.factory.d.ts +11 -0
- package/src/factories/product-search/product-search.factory.d.ts +7 -0
- package/src/factories/profile/profile.factory.d.ts +7 -0
- package/src/factories/store/store.factory.d.ts +7 -0
- package/src/index.d.ts +6 -0
- package/src/schema/capabilities.schema.d.ts +117 -0
- package/src/schema/configuration.schema.d.ts +13 -0
- package/src/test/client-builder-product-extension.example.d.ts +1 -0
- package/src/test/test-utils.d.ts +2 -0
- package/src/utilities/jitter.d.ts +1 -0
- package/src/utilities/seed.d.ts +1 -0
- package/test/client-builder-product-extension.example.js +57 -0
- package/test/test-utils.js +16 -0
- package/utilities/jitter.js +13 -0
- package/utilities/seed.js +11 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class FakeCategoryFactory {
|
|
2
|
+
categorySchema;
|
|
3
|
+
categoryPaginatedResultSchema;
|
|
4
|
+
constructor(categorySchema, categoryPaginatedResultSchema) {
|
|
5
|
+
this.categorySchema = categorySchema;
|
|
6
|
+
this.categoryPaginatedResultSchema = categoryPaginatedResultSchema;
|
|
7
|
+
}
|
|
8
|
+
parseCategory(_context, data) {
|
|
9
|
+
return this.categorySchema.parse(data);
|
|
10
|
+
}
|
|
11
|
+
parseCategoryPaginatedResult(_context, data) {
|
|
12
|
+
return this.categoryPaginatedResultSchema.parse(data);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
FakeCategoryFactory
|
|
17
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class FakeCheckoutFactory {
|
|
2
|
+
checkoutSchema;
|
|
3
|
+
shippingMethodSchema;
|
|
4
|
+
paymentMethodSchema;
|
|
5
|
+
constructor(checkoutSchema, shippingMethodSchema, paymentMethodSchema) {
|
|
6
|
+
this.checkoutSchema = checkoutSchema;
|
|
7
|
+
this.shippingMethodSchema = shippingMethodSchema;
|
|
8
|
+
this.paymentMethodSchema = paymentMethodSchema;
|
|
9
|
+
}
|
|
10
|
+
parseCheckout(_context, data) {
|
|
11
|
+
return this.checkoutSchema.parse(data);
|
|
12
|
+
}
|
|
13
|
+
parseShippingMethod(_context, data) {
|
|
14
|
+
return this.shippingMethodSchema.parse(data);
|
|
15
|
+
}
|
|
16
|
+
parsePaymentMethod(_context, data) {
|
|
17
|
+
return this.paymentMethodSchema.parse(data);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
FakeCheckoutFactory
|
|
22
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./cart/cart.factory.js";
|
|
2
|
+
export * from "./category/category.factory.js";
|
|
3
|
+
export * from "./checkout/checkout.factory.js";
|
|
4
|
+
export * from "./identity/identity.factory.js";
|
|
5
|
+
export * from "./inventory/inventory.factory.js";
|
|
6
|
+
export * from "./order-search/order-search.factory.js";
|
|
7
|
+
export * from "./order/order.factory.js";
|
|
8
|
+
export * from "./price/price.factory.js";
|
|
9
|
+
export * from "./product-associations/product-associations.factory.js";
|
|
10
|
+
export * from "./product-reviews/product-reviews.factory.js";
|
|
11
|
+
export * from "./product-search/product-search.factory.js";
|
|
12
|
+
export * from "./product/product.factory.js";
|
|
13
|
+
export * from "./profile/profile.factory.js";
|
|
14
|
+
export * from "./store/store.factory.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class FakeOrderSearchFactory {
|
|
2
|
+
orderSearchResultSchema;
|
|
3
|
+
constructor(orderSearchResultSchema) {
|
|
4
|
+
this.orderSearchResultSchema = orderSearchResultSchema;
|
|
5
|
+
}
|
|
6
|
+
parseOrderSearchResult(_context, data, _query) {
|
|
7
|
+
return this.orderSearchResultSchema.parse(data);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
FakeOrderSearchFactory
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class FakeProductAssociationsFactory {
|
|
2
|
+
productAssociationSchema;
|
|
3
|
+
constructor(productAssociationSchema) {
|
|
4
|
+
this.productAssociationSchema = productAssociationSchema;
|
|
5
|
+
}
|
|
6
|
+
parseAssociation(_context, data) {
|
|
7
|
+
return this.productAssociationSchema.parse(data);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
FakeProductAssociationsFactory
|
|
12
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class FakeProductReviewsFactory {
|
|
2
|
+
ratingSummarySchema;
|
|
3
|
+
reviewSchema;
|
|
4
|
+
reviewPaginatedSchema;
|
|
5
|
+
constructor(ratingSummarySchema, reviewSchema, reviewPaginatedSchema) {
|
|
6
|
+
this.ratingSummarySchema = ratingSummarySchema;
|
|
7
|
+
this.reviewSchema = reviewSchema;
|
|
8
|
+
this.reviewPaginatedSchema = reviewPaginatedSchema;
|
|
9
|
+
}
|
|
10
|
+
parseRatingSummary(_context, data) {
|
|
11
|
+
return this.ratingSummarySchema.parse(data);
|
|
12
|
+
}
|
|
13
|
+
parseReview(_context, data) {
|
|
14
|
+
return this.reviewSchema.parse(data);
|
|
15
|
+
}
|
|
16
|
+
parseReviewPaginatedResult(_context, data) {
|
|
17
|
+
return this.reviewPaginatedSchema.parse(data);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
FakeProductReviewsFactory
|
|
22
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class FakeProductSearchFactory {
|
|
2
|
+
productSearchResultSchema;
|
|
3
|
+
constructor(productSearchResultSchema) {
|
|
4
|
+
this.productSearchResultSchema = productSearchResultSchema;
|
|
5
|
+
}
|
|
6
|
+
parseSearchResult(_context, data, _query) {
|
|
7
|
+
return this.productSearchResultSchema.parse(data);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
FakeProductSearchFactory
|
|
12
|
+
};
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reactionary/fake",
|
|
3
|
+
"version": "0.6.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"vitest": "^4.0.9",
|
|
9
|
+
"@nx/vite": "22.4.5",
|
|
10
|
+
"@reactionary/core": "0.6.3",
|
|
11
|
+
"zod": "4.1.9",
|
|
12
|
+
"@faker-js/faker": "^9.8.0"
|
|
13
|
+
},
|
|
14
|
+
"sideEffects": false
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CapabilitiesSchema } from "@reactionary/core";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
const OverridableCapabilitySchema = z.looseObject({
|
|
4
|
+
enabled: z.boolean(),
|
|
5
|
+
factory: z.unknown().optional(),
|
|
6
|
+
capability: z.unknown().optional()
|
|
7
|
+
});
|
|
8
|
+
const FakeCapabilitiesSchema = CapabilitiesSchema.pick({
|
|
9
|
+
product: true,
|
|
10
|
+
productSearch: true,
|
|
11
|
+
identity: true,
|
|
12
|
+
category: true,
|
|
13
|
+
cart: true,
|
|
14
|
+
inventory: true,
|
|
15
|
+
store: true,
|
|
16
|
+
price: true,
|
|
17
|
+
checkout: true,
|
|
18
|
+
order: true,
|
|
19
|
+
orderSearch: true,
|
|
20
|
+
profile: true,
|
|
21
|
+
productReviews: true,
|
|
22
|
+
productAssociations: true
|
|
23
|
+
}).extend({
|
|
24
|
+
product: OverridableCapabilitySchema.optional(),
|
|
25
|
+
productSearch: OverridableCapabilitySchema.optional(),
|
|
26
|
+
identity: OverridableCapabilitySchema.optional(),
|
|
27
|
+
category: OverridableCapabilitySchema.optional(),
|
|
28
|
+
cart: OverridableCapabilitySchema.optional(),
|
|
29
|
+
inventory: OverridableCapabilitySchema.optional(),
|
|
30
|
+
store: OverridableCapabilitySchema.optional(),
|
|
31
|
+
price: OverridableCapabilitySchema.optional(),
|
|
32
|
+
checkout: OverridableCapabilitySchema.optional(),
|
|
33
|
+
order: OverridableCapabilitySchema.optional(),
|
|
34
|
+
orderSearch: OverridableCapabilitySchema.optional(),
|
|
35
|
+
profile: OverridableCapabilitySchema.optional(),
|
|
36
|
+
productReviews: OverridableCapabilitySchema.optional(),
|
|
37
|
+
productAssociations: OverridableCapabilitySchema.optional()
|
|
38
|
+
}).partial();
|
|
39
|
+
export {
|
|
40
|
+
FakeCapabilitiesSchema
|
|
41
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
const FakeConfigurationSchema = z.looseObject({
|
|
3
|
+
jitter: z.looseObject({
|
|
4
|
+
mean: z.number().min(0).max(1e4),
|
|
5
|
+
deviation: z.number().min(0).max(5e3)
|
|
6
|
+
}).default({
|
|
7
|
+
mean: 0,
|
|
8
|
+
deviation: 0
|
|
9
|
+
}),
|
|
10
|
+
seeds: z.looseObject({
|
|
11
|
+
product: z.number().min(0).max(1e4).default(1),
|
|
12
|
+
search: z.number().min(0).max(1e4).default(1),
|
|
13
|
+
category: z.number().min(0).max(1e4).default(1)
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
export {
|
|
17
|
+
FakeConfigurationSchema
|
|
18
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AnalyticsMutation, Cache, RequestContext } from '@reactionary/core';
|
|
2
|
+
import { AnalyticsCapability } from '@reactionary/core';
|
|
3
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
4
|
+
export declare class FakeAnalyticsCapability extends AnalyticsCapability {
|
|
5
|
+
protected config: FakeConfiguration;
|
|
6
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext);
|
|
7
|
+
track(event: AnalyticsMutation): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Cart, CartFactory, CartFactoryCartOutput, CartFactoryWithOutput, CartQueryById, CartMutationItemAdd, CartMutationItemRemove, CartMutationItemQuantityChange, RequestContext, Cache, CartIdentifier, CartMutationApplyCoupon, CartMutationChangeCurrency, CartMutationDeleteCart, CartMutationRemoveCoupon, Result, NotFoundError } from '@reactionary/core';
|
|
2
|
+
import { CartCapability } from '@reactionary/core';
|
|
3
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
4
|
+
import type { FakeCartFactory } from '../factories/cart/cart.factory.js';
|
|
5
|
+
export declare class FakeCartCapability<TFactory extends CartFactory = FakeCartFactory> extends CartCapability<CartFactoryCartOutput<TFactory>, CartIdentifier> {
|
|
6
|
+
protected config: FakeConfiguration;
|
|
7
|
+
protected factory: CartFactoryWithOutput<TFactory>;
|
|
8
|
+
private carts;
|
|
9
|
+
private generator;
|
|
10
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: CartFactoryWithOutput<TFactory>);
|
|
11
|
+
getById(payload: CartQueryById): Promise<Result<CartFactoryCartOutput<TFactory>, NotFoundError>>;
|
|
12
|
+
add(payload: CartMutationItemAdd): Promise<Result<CartFactoryCartOutput<TFactory>>>;
|
|
13
|
+
remove(payload: CartMutationItemRemove): Promise<Result<CartFactoryCartOutput<TFactory>>>;
|
|
14
|
+
changeQuantity(payload: CartMutationItemQuantityChange): Promise<Result<CartFactoryCartOutput<TFactory>>>;
|
|
15
|
+
getActiveCartId(): Promise<Result<CartIdentifier, NotFoundError>>;
|
|
16
|
+
deleteCart(payload: CartMutationDeleteCart): Promise<Result<void>>;
|
|
17
|
+
applyCouponCode(payload: CartMutationApplyCoupon): Promise<Result<CartFactoryCartOutput<TFactory>>>;
|
|
18
|
+
removeCouponCode(payload: CartMutationRemoveCoupon): Promise<Result<CartFactoryCartOutput<TFactory>>>;
|
|
19
|
+
changeCurrency(payload: CartMutationChangeCurrency): Promise<Result<CartFactoryCartOutput<TFactory>>>;
|
|
20
|
+
protected recalculateCart(cart: Cart): void;
|
|
21
|
+
protected createEmptyCart(): Cart;
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Cache, Category, CategoryFactory, CategoryFactoryCategoryOutput, CategoryFactoryPaginatedOutput, CategoryFactoryWithOutput, CategoryQueryById, CategoryQueryBySlug, CategoryQueryForBreadcrumb, CategoryQueryForChildCategories, CategoryQueryForTopCategories, NotFoundError, RequestContext, Result } from '@reactionary/core';
|
|
2
|
+
import { CategoryCapability } from '@reactionary/core';
|
|
3
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
4
|
+
import { Faker } from '@faker-js/faker';
|
|
5
|
+
import type { FakeCategoryFactory } from '../factories/category/category.factory.js';
|
|
6
|
+
export declare class FakeCategoryCapability<TFactory extends CategoryFactory = FakeCategoryFactory> extends CategoryCapability<CategoryFactoryCategoryOutput<TFactory>, CategoryFactoryPaginatedOutput<TFactory>> {
|
|
7
|
+
protected config: FakeConfiguration;
|
|
8
|
+
protected factory: CategoryFactoryWithOutput<TFactory>;
|
|
9
|
+
protected topCategories: Category[];
|
|
10
|
+
protected childCategories: Map<string, Category[]>;
|
|
11
|
+
protected allCategories: Map<string, Category>;
|
|
12
|
+
protected categoryGenerator: Faker;
|
|
13
|
+
protected generateFakeCategory(parent: Category | undefined, index: number): Category;
|
|
14
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: CategoryFactoryWithOutput<TFactory>);
|
|
15
|
+
getById(payload: CategoryQueryById): Promise<Result<CategoryFactoryCategoryOutput<TFactory>, NotFoundError>>;
|
|
16
|
+
getBySlug(payload: CategoryQueryBySlug): Promise<Result<CategoryFactoryCategoryOutput<TFactory>, NotFoundError>>;
|
|
17
|
+
getBreadcrumbPathToCategory(payload: CategoryQueryForBreadcrumb): Promise<Result<CategoryFactoryCategoryOutput<TFactory>[]>>;
|
|
18
|
+
findTopCategories(_payload: CategoryQueryForTopCategories): Promise<Result<CategoryFactoryPaginatedOutput<TFactory>>>;
|
|
19
|
+
findChildCategories(payload: CategoryQueryForChildCategories): Promise<Result<CategoryFactoryPaginatedOutput<TFactory>>>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { CheckoutCapability, type CheckoutMutationAddPaymentInstruction, type CheckoutMutationFinalizeCheckout, type CheckoutMutationInitiateCheckout, type CheckoutMutationRemovePaymentInstruction, type CheckoutMutationSetShippingAddress, type CheckoutMutationSetShippingInstruction, type CheckoutQueryById, type CheckoutQueryForAvailablePaymentMethods, type CheckoutQueryForAvailableShippingMethods, type NotFoundError, type RequestContext, type Result, type Cache, type CheckoutIdentifier, type CheckoutFactory, type CheckoutFactoryCheckoutOutput, type CheckoutFactoryPaymentMethodOutput, type CheckoutFactoryShippingMethodOutput, type CheckoutFactoryWithOutput } from '@reactionary/core';
|
|
2
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
3
|
+
import { Faker } from '@faker-js/faker';
|
|
4
|
+
import type { FakeCheckoutFactory } from '../factories/checkout/checkout.factory.js';
|
|
5
|
+
export declare class FakeCheckoutCapability<TFactory extends CheckoutFactory = FakeCheckoutFactory> extends CheckoutCapability<CheckoutFactoryCheckoutOutput<TFactory>, CheckoutFactoryShippingMethodOutput<TFactory>, CheckoutFactoryPaymentMethodOutput<TFactory>> {
|
|
6
|
+
protected config: FakeConfiguration;
|
|
7
|
+
protected generator: Faker;
|
|
8
|
+
protected factory: CheckoutFactoryWithOutput<TFactory>;
|
|
9
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: CheckoutFactoryWithOutput<TFactory>);
|
|
10
|
+
initiateCheckoutForCart(payload: CheckoutMutationInitiateCheckout): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>>>;
|
|
11
|
+
getById(payload: CheckoutQueryById): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>, NotFoundError>>;
|
|
12
|
+
setShippingAddress(payload: CheckoutMutationSetShippingAddress): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>>>;
|
|
13
|
+
getAvailableShippingMethods(payload: CheckoutQueryForAvailableShippingMethods): Promise<Result<CheckoutFactoryShippingMethodOutput<TFactory>[]>>;
|
|
14
|
+
getAvailablePaymentMethods(payload: CheckoutQueryForAvailablePaymentMethods): Promise<Result<CheckoutFactoryPaymentMethodOutput<TFactory>[]>>;
|
|
15
|
+
addPaymentInstruction(payload: CheckoutMutationAddPaymentInstruction): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>>>;
|
|
16
|
+
removePaymentInstruction(payload: CheckoutMutationRemovePaymentInstruction): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>>>;
|
|
17
|
+
setShippingInstruction(payload: CheckoutMutationSetShippingInstruction): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>>>;
|
|
18
|
+
finalizeCheckout(payload: CheckoutMutationFinalizeCheckout): Promise<Result<CheckoutFactoryCheckoutOutput<TFactory>>>;
|
|
19
|
+
protected composeBaseCheckout(identifier?: CheckoutIdentifier): {
|
|
20
|
+
description: string;
|
|
21
|
+
identifier: CheckoutIdentifier;
|
|
22
|
+
items: never[];
|
|
23
|
+
name: string;
|
|
24
|
+
originalCartReference: {
|
|
25
|
+
key: string;
|
|
26
|
+
};
|
|
27
|
+
paymentInstructions: never[];
|
|
28
|
+
price: {
|
|
29
|
+
grandTotal: {
|
|
30
|
+
currency: "USD";
|
|
31
|
+
value: number;
|
|
32
|
+
};
|
|
33
|
+
totalDiscount: {
|
|
34
|
+
currency: "USD";
|
|
35
|
+
value: number;
|
|
36
|
+
};
|
|
37
|
+
totalProductPrice: {
|
|
38
|
+
currency: "USD";
|
|
39
|
+
value: number;
|
|
40
|
+
};
|
|
41
|
+
totalShipping: {
|
|
42
|
+
currency: "USD";
|
|
43
|
+
value: number;
|
|
44
|
+
};
|
|
45
|
+
totalSurcharge: {
|
|
46
|
+
currency: "USD";
|
|
47
|
+
value: number;
|
|
48
|
+
};
|
|
49
|
+
totalTax: {
|
|
50
|
+
currency: "USD";
|
|
51
|
+
value: number;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
readyForFinalization: false;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Cache, type IdentityFactory, type IdentityFactoryOutput, type IdentityFactoryWithOutput, type IdentityMutationLogin, type IdentityMutationLogout, type IdentityMutationRegister, type IdentityQuerySelf, IdentityCapability, type RequestContext, type Result } from '@reactionary/core';
|
|
2
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
3
|
+
import type { FakeIdentityFactory } from '../factories/identity/identity.factory.js';
|
|
4
|
+
export declare class FakeIdentityCapability<TFactory extends IdentityFactory = FakeIdentityFactory> extends IdentityCapability<IdentityFactoryOutput<TFactory>> {
|
|
5
|
+
protected config: FakeConfiguration;
|
|
6
|
+
protected factory: IdentityFactoryWithOutput<TFactory>;
|
|
7
|
+
private currentIdentity;
|
|
8
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: IdentityFactoryWithOutput<TFactory>);
|
|
9
|
+
getSelf(_payload: IdentityQuerySelf): Promise<Result<IdentityFactoryOutput<TFactory>>>;
|
|
10
|
+
login(_payload: IdentityMutationLogin): Promise<Result<IdentityFactoryOutput<TFactory>>>;
|
|
11
|
+
logout(_payload: IdentityMutationLogout): Promise<Result<IdentityFactoryOutput<TFactory>>>;
|
|
12
|
+
register(_payload: IdentityMutationRegister): Promise<Result<IdentityFactoryOutput<TFactory>>>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './analytics.capability.js';
|
|
2
|
+
export * from './cart.capability.js';
|
|
3
|
+
export * from './category.capability.js';
|
|
4
|
+
export * from './checkout.capability.js';
|
|
5
|
+
export * from './identity.capability.js';
|
|
6
|
+
export * from './inventory.capability.js';
|
|
7
|
+
export * from './order-search.capability.js';
|
|
8
|
+
export * from './order.capability.js';
|
|
9
|
+
export * from './price.capability.js';
|
|
10
|
+
export * from './product.capability.js';
|
|
11
|
+
export * from './product-associations.capability.js';
|
|
12
|
+
export * from './product-reviews.capability.js';
|
|
13
|
+
export * from './product-search.capability.js';
|
|
14
|
+
export * from './profile.capability.js';
|
|
15
|
+
export * from './store.capability.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Cache, InventoryFactory, InventoryFactoryOutput, InventoryFactoryWithOutput, InventoryQueryBySKU, NotFoundError, RequestContext, Result } from '@reactionary/core';
|
|
2
|
+
import { InventoryCapability } from '@reactionary/core';
|
|
3
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
4
|
+
import type { FakeInventoryFactory } from '../factories/inventory/inventory.factory.js';
|
|
5
|
+
export declare class FakeInventoryCapability<TFactory extends InventoryFactory = FakeInventoryFactory> extends InventoryCapability<InventoryFactoryOutput<TFactory>> {
|
|
6
|
+
protected config: FakeConfiguration;
|
|
7
|
+
protected factory: InventoryFactoryWithOutput<TFactory>;
|
|
8
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: InventoryFactoryWithOutput<TFactory>);
|
|
9
|
+
getBySKU(payload: InventoryQueryBySKU): Promise<Result<InventoryFactoryOutput<TFactory>, NotFoundError>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OrderSearchCapability, type Cache, type OrderSearchFactory, type OrderSearchFactoryOutput, type OrderSearchFactoryWithOutput, type OrderSearchQueryByTerm, type RequestContext, type Result } from '@reactionary/core';
|
|
2
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
3
|
+
import { Faker } from '@faker-js/faker';
|
|
4
|
+
import type { FakeOrderSearchFactory } from '../factories/order-search/order-search.factory.js';
|
|
5
|
+
export declare class FakeOrderSearchCapability<TFactory extends OrderSearchFactory = FakeOrderSearchFactory> extends OrderSearchCapability<OrderSearchFactoryOutput<TFactory>> {
|
|
6
|
+
protected config: FakeConfiguration;
|
|
7
|
+
protected generator: Faker;
|
|
8
|
+
protected factory: OrderSearchFactoryWithOutput<TFactory>;
|
|
9
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: OrderSearchFactoryWithOutput<TFactory>);
|
|
10
|
+
queryByTerm(payload: OrderSearchQueryByTerm): Promise<Result<OrderSearchFactoryOutput<TFactory>>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OrderCapability, type Cache, type NotFoundError, type OrderFactory, type OrderFactoryOutput, type OrderFactoryWithOutput, type OrderQueryById, type RequestContext, type Result } from '@reactionary/core';
|
|
2
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
3
|
+
import { Faker } from '@faker-js/faker';
|
|
4
|
+
import type { FakeOrderFactory } from '../factories/order/order.factory.js';
|
|
5
|
+
export declare class FakeOrderCapability<TFactory extends OrderFactory = FakeOrderFactory> extends OrderCapability<OrderFactoryOutput<TFactory>> {
|
|
6
|
+
protected config: FakeConfiguration;
|
|
7
|
+
protected generator: Faker;
|
|
8
|
+
protected factory: OrderFactoryWithOutput<TFactory>;
|
|
9
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: OrderFactoryWithOutput<TFactory>);
|
|
10
|
+
getById(payload: OrderQueryById): Promise<Result<OrderFactoryOutput<TFactory>, NotFoundError>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PriceCapability, type Cache, type CustomerPriceQuery, type ListPriceQuery, type Price, type PriceFactory, type PriceFactoryOutput, type PriceFactoryWithOutput, type RequestContext, type Result } from '@reactionary/core';
|
|
2
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
3
|
+
import { Faker } from '@faker-js/faker';
|
|
4
|
+
import type { FakePriceFactory } from '../factories/price/price.factory.js';
|
|
5
|
+
export declare class FakePriceCapability<TFactory extends PriceFactory = FakePriceFactory> extends PriceCapability<PriceFactoryOutput<TFactory>> {
|
|
6
|
+
protected config: FakeConfiguration;
|
|
7
|
+
protected faker: Faker;
|
|
8
|
+
protected factory: PriceFactoryWithOutput<TFactory>;
|
|
9
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: PriceFactoryWithOutput<TFactory>);
|
|
10
|
+
protected createPrice(variantSku: string, mode: 'list' | 'customer'): Price;
|
|
11
|
+
getListPrice(payload: ListPriceQuery): Promise<Result<PriceFactoryOutput<TFactory>>>;
|
|
12
|
+
getCustomerPrice(payload: CustomerPriceQuery): Promise<Result<PriceFactoryOutput<TFactory>>>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ProductAssociationsCapability, type ProductAssociationsGetAccessoriesQuery, type ProductAssociationsGetSparepartsQuery, type ProductAssociationsGetReplacementsQuery, type Result, type Cache, type RequestContext } from '@reactionary/core';
|
|
2
|
+
import type { ProductAssociationsFactory, ProductAssociationsFactoryOutput, ProductAssociationsFactoryWithOutput } from '@reactionary/core';
|
|
3
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
4
|
+
import { Faker } from '@faker-js/faker';
|
|
5
|
+
import type { FakeProductAssociationsFactory } from '../factories/product-associations/product-associations.factory.js';
|
|
6
|
+
export declare class FakeProductAssociationsCapability<TFactory extends ProductAssociationsFactory = FakeProductAssociationsFactory> extends ProductAssociationsCapability<ProductAssociationsFactoryOutput<TFactory>> {
|
|
7
|
+
protected config: FakeConfiguration;
|
|
8
|
+
protected factory: ProductAssociationsFactoryWithOutput<TFactory>;
|
|
9
|
+
protected faker: Faker;
|
|
10
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: ProductAssociationsFactoryWithOutput<TFactory>);
|
|
11
|
+
getAccessories(query: ProductAssociationsGetAccessoriesQuery): Promise<Result<ProductAssociationsFactoryOutput<TFactory>[]>>;
|
|
12
|
+
getSpareparts(query: ProductAssociationsGetSparepartsQuery): Promise<Result<ProductAssociationsFactoryOutput<TFactory>[]>>;
|
|
13
|
+
getReplacements(query: ProductAssociationsGetReplacementsQuery): Promise<Result<ProductAssociationsFactoryOutput<TFactory>[]>>;
|
|
14
|
+
private generateFakeAssociatedProducts;
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ProductReviewsCapability, type Cache, type ProductIdentifier, type ProductReviewsFactory, type ProductReviewsFactoryRatingOutput, type ProductReviewsFactoryReviewOutput, type ProductReviewsFactoryReviewPaginatedOutput, type ProductReviewsFactoryWithOutput, type ProductReviewsGetRatingSummaryQuery, type ProductReviewsListQuery, type ProductReview, type ProductReviewMutationSubmit, type RequestContext, type Result } from '@reactionary/core';
|
|
2
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
3
|
+
import type { FakeProductReviewsFactory } from '../factories/product-reviews/product-reviews.factory.js';
|
|
4
|
+
export declare class FakeProductReviewsCapability<TFactory extends ProductReviewsFactory = FakeProductReviewsFactory> extends ProductReviewsCapability<ProductReviewsFactoryRatingOutput<TFactory>, ProductReviewsFactoryReviewPaginatedOutput<TFactory>, ProductReviewsFactoryReviewOutput<TFactory>> {
|
|
5
|
+
protected config: FakeConfiguration;
|
|
6
|
+
protected factory: ProductReviewsFactoryWithOutput<TFactory>;
|
|
7
|
+
private faker;
|
|
8
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: ProductReviewsFactoryWithOutput<TFactory>);
|
|
9
|
+
protected createReviewsForProduct(productIdentifier: ProductIdentifier): ProductReview[];
|
|
10
|
+
getRatingSummary(query: ProductReviewsGetRatingSummaryQuery): Promise<Result<ProductReviewsFactoryRatingOutput<TFactory>>>;
|
|
11
|
+
findReviews(query: ProductReviewsListQuery): Promise<Result<ProductReviewsFactoryReviewPaginatedOutput<TFactory>>>;
|
|
12
|
+
submitReview(mutation: ProductReviewMutationSubmit): Promise<Result<ProductReviewsFactoryReviewOutput<TFactory>>>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProductSearchCapability, type Cache, type FacetValueIdentifier, type ProductSearchFactory, type ProductSearchFactoryOutput, type ProductSearchFactoryWithOutput, type ProductSearchQueryByTerm, type ProductSearchQueryCreateNavigationFilter, type RequestContext, type Result } from '@reactionary/core';
|
|
2
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
3
|
+
import type { FakeProductSearchFactory } from '../factories/product-search/product-search.factory.js';
|
|
4
|
+
export declare class FakeProductSearchCapability<TFactory extends ProductSearchFactory = FakeProductSearchFactory> extends ProductSearchCapability<ProductSearchFactoryOutput<TFactory>> {
|
|
5
|
+
protected config: FakeConfiguration;
|
|
6
|
+
protected factory: ProductSearchFactoryWithOutput<TFactory>;
|
|
7
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: ProductSearchFactoryWithOutput<TFactory>);
|
|
8
|
+
queryByTerm(payload: ProductSearchQueryByTerm): Promise<Result<ProductSearchFactoryOutput<TFactory>>>;
|
|
9
|
+
createCategoryNavigationFilter(payload: ProductSearchQueryCreateNavigationFilter): Promise<Result<FacetValueIdentifier>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Cache, type NotFoundError, type ProductFactory, type ProductFactoryOutput, type ProductFactoryWithOutput, type ProductQueryById, type ProductQueryBySKU, type ProductQueryBySlug, ProductCapability, type RequestContext, type Result } from '@reactionary/core';
|
|
2
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
3
|
+
import type { FakeProductFactory } from '../factories/product/product.factory.js';
|
|
4
|
+
export declare class FakeProductCapability<TFactory extends ProductFactory = FakeProductFactory> extends ProductCapability<ProductFactoryOutput<TFactory>> {
|
|
5
|
+
protected config: FakeConfiguration;
|
|
6
|
+
protected factory: ProductFactoryWithOutput<TFactory>;
|
|
7
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: ProductFactoryWithOutput<TFactory>);
|
|
8
|
+
getById(payload: ProductQueryById): Promise<Result<ProductFactoryOutput<TFactory>>>;
|
|
9
|
+
getBySlug(payload: ProductQueryBySlug): Promise<Result<ProductFactoryOutput<TFactory>, NotFoundError>>;
|
|
10
|
+
getBySKU(payload: ProductQueryBySKU): Promise<Result<ProductFactoryOutput<TFactory>>>;
|
|
11
|
+
protected composeSingle(body: string): ProductFactoryOutput<TFactory>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ProfileCapability, type Cache, type Address, type IdentityIdentifier, type NotFoundError, type ProfileFactory, type ProfileFactoryOutput, type ProfileFactoryWithOutput, type ProfileMutationAddShippingAddress, type ProfileMutationMakeShippingAddressDefault, type ProfileMutationRemoveShippingAddress, type ProfileMutationSetBillingAddress, type ProfileMutationUpdate, type ProfileMutationUpdateShippingAddress, type ProfileQuerySelf, type RequestContext, type Result } from '@reactionary/core';
|
|
2
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
3
|
+
import type { FakeProfileFactory } from '../factories/profile/profile.factory.js';
|
|
4
|
+
export declare class FakeProfileCapability<TFactory extends ProfileFactory = FakeProfileFactory> extends ProfileCapability<ProfileFactoryOutput<TFactory>> {
|
|
5
|
+
protected config: FakeConfiguration;
|
|
6
|
+
protected factory: ProfileFactoryWithOutput<TFactory>;
|
|
7
|
+
private generator;
|
|
8
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: ProfileFactoryWithOutput<TFactory>);
|
|
9
|
+
getById(payload: ProfileQuerySelf): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
|
|
10
|
+
update(payload: ProfileMutationUpdate): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
|
|
11
|
+
addShippingAddress(payload: ProfileMutationAddShippingAddress): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
|
|
12
|
+
updateShippingAddress(payload: ProfileMutationUpdateShippingAddress): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
|
|
13
|
+
removeShippingAddress(payload: ProfileMutationRemoveShippingAddress): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
|
|
14
|
+
makeShippingAddressDefault(payload: ProfileMutationMakeShippingAddressDefault): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
|
|
15
|
+
setBillingAddress(payload: ProfileMutationSetBillingAddress): Promise<Result<ProfileFactoryOutput<TFactory>, NotFoundError>>;
|
|
16
|
+
protected composeProfile(identifier: IdentityIdentifier): ProfileFactoryOutput<TFactory>;
|
|
17
|
+
protected createEmptyAddress(): Address;
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Cache, RequestContext, Result, StoreFactory, StoreFactoryOutput, StoreFactoryWithOutput, StoreQueryByProximity } from '@reactionary/core';
|
|
2
|
+
import { StoreCapability } from '@reactionary/core';
|
|
3
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
4
|
+
import type { FakeStoreFactory } from '../factories/store/store.factory.js';
|
|
5
|
+
export declare class FakeStoreCapability<TFactory extends StoreFactory = FakeStoreFactory> extends StoreCapability<StoreFactoryOutput<TFactory>> {
|
|
6
|
+
protected config: FakeConfiguration;
|
|
7
|
+
protected factory: StoreFactoryWithOutput<TFactory>;
|
|
8
|
+
constructor(config: FakeConfiguration, cache: Cache, context: RequestContext, factory: StoreFactoryWithOutput<TFactory>);
|
|
9
|
+
queryByProximity(payload: StoreQueryByProximity): Promise<Result<StoreFactoryOutput<TFactory>[]>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Cache as ReactinaryCache, RequestContext } from '@reactionary/core';
|
|
2
|
+
import type { FakeConfiguration } from '../schema/configuration.schema.js';
|
|
3
|
+
import type { FakeCapabilities } from '../schema/capabilities.schema.js';
|
|
4
|
+
import { type FakeClientFromCapabilities } from './initialize.types.js';
|
|
5
|
+
export declare function withFakeCapabilities<T extends FakeCapabilities>(configuration: FakeConfiguration, capabilities: T): (cache: ReactinaryCache, context: RequestContext) => FakeClientFromCapabilities<T>;
|