@commerce-ai-tool/core 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/ai/factory.d.ts +5 -0
- package/dist/ai/factory.d.ts.map +1 -0
- package/dist/ai/index.d.ts +3 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/json-schema-errors.d.ts +4 -0
- package/dist/ai/json-schema-errors.d.ts.map +1 -0
- package/dist/ai/providers/bedrock.d.ts +19 -0
- package/dist/ai/providers/bedrock.d.ts.map +1 -0
- package/dist/ai/providers/openrouter.d.ts +27 -0
- package/dist/ai/providers/openrouter.d.ts.map +1 -0
- package/dist/ai/types.d.ts +23 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/cache/search-cache.d.ts +19 -0
- package/dist/cache/search-cache.d.ts.map +1 -0
- package/dist/client.cjs +423 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +12 -0
- package/dist/client.d.ts +12 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +388 -0
- package/dist/client.js.map +1 -0
- package/dist/commercetools/build-search-keywords.d.ts +37 -0
- package/dist/commercetools/build-search-keywords.d.ts.map +1 -0
- package/dist/commercetools/cart.d.ts +70 -0
- package/dist/commercetools/cart.d.ts.map +1 -0
- package/dist/commercetools/checkout.d.ts +33 -0
- package/dist/commercetools/checkout.d.ts.map +1 -0
- package/dist/commercetools/client.d.ts +43 -0
- package/dist/commercetools/client.d.ts.map +1 -0
- package/dist/commercetools/facet-color.d.ts +12 -0
- package/dist/commercetools/facet-color.d.ts.map +1 -0
- package/dist/commercetools/facets.d.ts +31 -0
- package/dist/commercetools/facets.d.ts.map +1 -0
- package/dist/commercetools/graphql-product-cards.d.ts +94 -0
- package/dist/commercetools/graphql-product-cards.d.ts.map +1 -0
- package/dist/commercetools/order.d.ts +27 -0
- package/dist/commercetools/order.d.ts.map +1 -0
- package/dist/commercetools/payment-map.d.ts +18 -0
- package/dist/commercetools/payment-map.d.ts.map +1 -0
- package/dist/commercetools/payment.d.ts +28 -0
- package/dist/commercetools/payment.d.ts.map +1 -0
- package/dist/commercetools/product-card-hydrate.d.ts +25 -0
- package/dist/commercetools/product-card-hydrate.d.ts.map +1 -0
- package/dist/commercetools/product-types.d.ts +34 -0
- package/dist/commercetools/product-types.d.ts.map +1 -0
- package/dist/commercetools/query-builder.d.ts +41 -0
- package/dist/commercetools/query-builder.d.ts.map +1 -0
- package/dist/commercetools/search-helpers.d.ts +16 -0
- package/dist/commercetools/search-helpers.d.ts.map +1 -0
- package/dist/commercetools/suggestion-quality.d.ts +13 -0
- package/dist/commercetools/suggestion-quality.d.ts.map +1 -0
- package/dist/commercetools/suggestions.d.ts +3 -0
- package/dist/commercetools/suggestions.d.ts.map +1 -0
- package/dist/index.cjs +6066 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +42 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5939 -0
- package/dist/index.js.map +1 -0
- package/dist/locale/resolve.d.ts +16 -0
- package/dist/locale/resolve.d.ts.map +1 -0
- package/dist/messages/index.d.ts +110 -0
- package/dist/messages/index.d.ts.map +1 -0
- package/dist/observability/enabled.d.ts +15 -0
- package/dist/observability/enabled.d.ts.map +1 -0
- package/dist/observability/index.d.ts +8 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/redact.d.ts +9 -0
- package/dist/observability/redact.d.ts.map +1 -0
- package/dist/observability/spans.d.ts +20 -0
- package/dist/observability/spans.d.ts.map +1 -0
- package/dist/observability/wrap-ai-provider.d.ts +14 -0
- package/dist/observability/wrap-ai-provider.d.ts.map +1 -0
- package/dist/payments/types.d.ts +35 -0
- package/dist/payments/types.d.ts.map +1 -0
- package/dist/prompts/catalog.d.ts +20 -0
- package/dist/prompts/catalog.d.ts.map +1 -0
- package/dist/prompts/fragments.d.ts +9 -0
- package/dist/prompts/fragments.d.ts.map +1 -0
- package/dist/prompts/index.d.ts +35 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/resolve.d.ts +35 -0
- package/dist/prompts/resolve.d.ts.map +1 -0
- package/dist/prompts/schemas.d.ts +206 -0
- package/dist/prompts/schemas.d.ts.map +1 -0
- package/dist/search/compound-shopping-list.d.ts +6 -0
- package/dist/search/compound-shopping-list.d.ts.map +1 -0
- package/dist/search/mission.d.ts +14 -0
- package/dist/search/mission.d.ts.map +1 -0
- package/dist/search/orchestrator.d.ts +29 -0
- package/dist/search/orchestrator.d.ts.map +1 -0
- package/dist/search/query-passthrough.d.ts +12 -0
- package/dist/search/query-passthrough.d.ts.map +1 -0
- package/dist/search/relax-search.d.ts +8 -0
- package/dist/search/relax-search.d.ts.map +1 -0
- package/dist/search/suggestions-input.d.ts +35 -0
- package/dist/search/suggestions-input.d.ts.map +1 -0
- package/dist/search/voice-tts.d.ts +6 -0
- package/dist/search/voice-tts.d.ts.map +1 -0
- package/dist/types/index.d.ts +510 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/audio.d.ts +4 -0
- package/dist/utils/audio.d.ts.map +1 -0
- package/dist/utils/dev-trace.d.ts +2 -0
- package/dist/utils/dev-trace.d.ts.map +1 -0
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/model-json.d.ts +4 -0
- package/dist/utils/model-json.d.ts.map +1 -0
- package/dist/utils/search-timer.d.ts +11 -0
- package/dist/utils/search-timer.d.ts.map +1 -0
- package/dist/utils/with-timeout.d.ts +6 -0
- package/dist/utils/with-timeout.d.ts.map +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Localized string map as returned by commercetools (locale → text). */
|
|
2
|
+
export type LocalizedTextMap = Record<string, string | undefined | null>;
|
|
3
|
+
export type WhitespaceSearchKeyword = {
|
|
4
|
+
text: string;
|
|
5
|
+
suggestTokenizer: {
|
|
6
|
+
type: "whitespace";
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
/** commercetools SearchKeywords payload for setSearchKeywords. */
|
|
10
|
+
export type BuiltSearchKeywords = Record<string, WhitespaceSearchKeyword[]>;
|
|
11
|
+
export type BuildSearchKeywordsFromProductCopyInput = {
|
|
12
|
+
name?: LocalizedTextMap | null;
|
|
13
|
+
/**
|
|
14
|
+
* Accepted for API compatibility with the seed script; ignored.
|
|
15
|
+
* Descriptions stay searchable via Product Search full-text, not Suggest keywords.
|
|
16
|
+
*/
|
|
17
|
+
description?: LocalizedTextMap | null;
|
|
18
|
+
existingSearchKeywords?: Record<string, unknown> | null;
|
|
19
|
+
/** When true, rebuild even if keywords already exist. */
|
|
20
|
+
force?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type BuildSearchKeywordsFromProductCopyResult = {
|
|
23
|
+
status: "skip";
|
|
24
|
+
reason: "existing" | "empty";
|
|
25
|
+
} | {
|
|
26
|
+
status: "ready";
|
|
27
|
+
searchKeywords: BuiltSearchKeywords;
|
|
28
|
+
};
|
|
29
|
+
export declare function hasNonEmptySearchKeywords(existing: Record<string, unknown> | null | undefined): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Build commercetools SearchKeywords from product names only.
|
|
32
|
+
* Uses a whitespace tokenizer so Suggest matches word prefixes
|
|
33
|
+
* (e.g. "glass" → "Chianti Wine Glass"). Description copy is not indexed here —
|
|
34
|
+
* Product Search already full-texts description.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildSearchKeywordsFromProductCopy(input: BuildSearchKeywordsFromProductCopyInput): BuildSearchKeywordsFromProductCopyResult;
|
|
37
|
+
//# sourceMappingURL=build-search-keywords.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-search-keywords.d.ts","sourceRoot":"","sources":["../../src/commercetools/build-search-keywords.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;AAEzE,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE;QAAE,IAAI,EAAE,YAAY,CAAA;KAAE,CAAC;CAC1C,CAAC;AAEF,kEAAkE;AAClE,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAE5E,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC/B;;;OAGG;IACH,WAAW,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACtC,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACxD,yDAAyD;IACzD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,wCAAwC,GAChD;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAA;CAAE,GAChD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,cAAc,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAI7D,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GACnD,OAAO,CAQT;AAED;;;;;GAKG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,uCAAuC,GAC7C,wCAAwC,CA+B1C"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Cart, CartDraft, CartUpdateAction, LineItem } from "@commercetools/platform-sdk";
|
|
2
|
+
import type { AddItemsToCartRequest, AddToCartRequest, CartLoginRequest, CartLoginResult, CartMutationRequest, CartSnapshot, CheckoutAddress, CustomerSnapshot, MoneyAmount, UpdateCartQuantityRequest } from "../types/index.js";
|
|
3
|
+
export declare const DEFAULT_CART_CURRENCY = "EUR";
|
|
4
|
+
export declare const DEFAULT_CART_LOCALE = "en";
|
|
5
|
+
export interface CustomerLoginInput {
|
|
6
|
+
email: string;
|
|
7
|
+
password: string;
|
|
8
|
+
anonymousId?: string;
|
|
9
|
+
anonymousCartId?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CustomerLoginResult {
|
|
12
|
+
customer: CustomerSnapshot;
|
|
13
|
+
cart?: Cart;
|
|
14
|
+
}
|
|
15
|
+
export interface CartGateway {
|
|
16
|
+
queryCarts(where: string): Promise<Cart[]>;
|
|
17
|
+
getCartById(id: string): Promise<Cart>;
|
|
18
|
+
createCart(draft: CartDraft): Promise<Cart>;
|
|
19
|
+
updateCart(id: string, version: number, actions: CartUpdateAction[]): Promise<Cart>;
|
|
20
|
+
loginCustomer(input: CustomerLoginInput): Promise<CustomerLoginResult>;
|
|
21
|
+
}
|
|
22
|
+
export interface CartOperations {
|
|
23
|
+
getCart(anonymousId: string, locale?: string): Promise<CartSnapshot | null>;
|
|
24
|
+
getCustomerCart(customerId: string, locale?: string): Promise<CartSnapshot | null>;
|
|
25
|
+
addToCart(input: AddToCartRequest): Promise<CartSnapshot>;
|
|
26
|
+
addItemsToCart(input: AddItemsToCartRequest): Promise<CartSnapshot>;
|
|
27
|
+
removeLineItem(input: CartMutationRequest): Promise<CartSnapshot>;
|
|
28
|
+
changeLineItemQuantity(input: UpdateCartQuantityRequest): Promise<CartSnapshot>;
|
|
29
|
+
loginAndMerge(input: CartLoginRequest): Promise<CartLoginResult>;
|
|
30
|
+
}
|
|
31
|
+
export declare function escapePredicateString(value: string): string;
|
|
32
|
+
export declare function buildAnonymousCartWhere(anonymousId: string): string;
|
|
33
|
+
export declare function buildCustomerCartWhere(customerId: string): string;
|
|
34
|
+
export declare function formatMoney(money: {
|
|
35
|
+
centAmount: number;
|
|
36
|
+
currencyCode: string;
|
|
37
|
+
fractionDigits?: number;
|
|
38
|
+
}, locale: string): MoneyAmount;
|
|
39
|
+
export declare function mapLineItemToSnapshot(lineItem: Pick<LineItem, "id" | "name" | "productId" | "quantity" | "price" | "totalPrice" | "variant">, locale: string): CartSnapshot["lineItems"][number];
|
|
40
|
+
export declare function mapCheckoutAddress(address: Cart["shippingAddress"]): CheckoutAddress | undefined;
|
|
41
|
+
export declare function mapCartToSnapshot(cart: Cart, locale: string): CartSnapshot;
|
|
42
|
+
export declare function resolveCartLocale(locale?: string): string;
|
|
43
|
+
export declare function resolveLineItemDraft(input: AddToCartRequest): {
|
|
44
|
+
sku?: string;
|
|
45
|
+
productId?: string;
|
|
46
|
+
variantId?: number;
|
|
47
|
+
quantity: number;
|
|
48
|
+
};
|
|
49
|
+
export declare function assertAddToCartTarget(input: ReturnType<typeof resolveLineItemDraft>): void;
|
|
50
|
+
export declare class CartNotFoundError extends Error {
|
|
51
|
+
constructor(message?: string);
|
|
52
|
+
}
|
|
53
|
+
export declare class CartAccessDeniedError extends Error {
|
|
54
|
+
constructor(message?: string);
|
|
55
|
+
}
|
|
56
|
+
export declare class InvalidCredentialsError extends Error {
|
|
57
|
+
constructor(message?: string);
|
|
58
|
+
}
|
|
59
|
+
export declare class MissingPriceError extends Error {
|
|
60
|
+
constructor(message?: string);
|
|
61
|
+
}
|
|
62
|
+
export declare function isInvalidCredentials(error: unknown): boolean;
|
|
63
|
+
export declare function isConcurrentModification(error: unknown): boolean;
|
|
64
|
+
export declare function isMatchingPriceNotFound(error: unknown): boolean;
|
|
65
|
+
export declare function assertCartOwner(cart: Cart, input: {
|
|
66
|
+
anonymousId?: string;
|
|
67
|
+
customerId?: string;
|
|
68
|
+
}): void;
|
|
69
|
+
export declare function createCartOperations(gateway: CartGateway): CartOperations;
|
|
70
|
+
//# sourceMappingURL=cart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cart.d.ts","sourceRoot":"","sources":["../../src/commercetools/cart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAA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est, CreateOrderRequest, OrderSnapshot, SetCartAddressesRequest, SetShippingMethodRequest, ShippingMethodSnapshot } from "../types/index.js";
|
|
3
|
+
import { mapCartToSnapshot } from "./cart.js";
|
|
4
|
+
import { mapOrderToSnapshot } from "./order.js";
|
|
5
|
+
export interface CheckoutGateway {
|
|
6
|
+
queryCarts(where: string): Promise<Cart[]>;
|
|
7
|
+
getCartById(id: string): Promise<Cart>;
|
|
8
|
+
updateCart(id: string, version: number, actions: CartUpdateAction[]): Promise<Cart>;
|
|
9
|
+
getShippingMethodsMatchingCart(cartId: string): Promise<ShippingMethod[]>;
|
|
10
|
+
createOrderFromCart(input: {
|
|
11
|
+
cartId: string;
|
|
12
|
+
version: number;
|
|
13
|
+
orderNumber: string;
|
|
14
|
+
}): Promise<Order>;
|
|
15
|
+
updateOrder(id: string, version: number, actions: OrderUpdateAction[]): Promise<Order>;
|
|
16
|
+
getPaymentById(id: string): Promise<Payment>;
|
|
17
|
+
}
|
|
18
|
+
export interface CheckoutOperations {
|
|
19
|
+
setCartAddresses(input: SetCartAddressesRequest): Promise<ReturnType<typeof mapCartToSnapshot>>;
|
|
20
|
+
getShippingMethods(input: CheckoutRequest): Promise<ShippingMethodSnapshot[]>;
|
|
21
|
+
setShippingMethod(input: SetShippingMethodRequest): Promise<ReturnType<typeof mapCartToSnapshot>>;
|
|
22
|
+
createOrder(input: CreateOrderRequest): Promise<OrderSnapshot>;
|
|
23
|
+
}
|
|
24
|
+
export interface CheckoutOperationsOptions {
|
|
25
|
+
requirePayment?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare class CheckoutIncompleteError extends Error {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
export declare function createCheckoutOrderNumber(): string;
|
|
31
|
+
export { mapOrderToSnapshot };
|
|
32
|
+
export declare function createCheckoutOperations(gateway: CheckoutGateway, options?: CheckoutOperationsOptions): CheckoutOperations;
|
|
33
|
+
//# sourceMappingURL=checkout.d.ts.map
|
|
@@ -0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AAgB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC;IAChG,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAC;IAC9E,iBAAiB,CACf,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC;IACjD,WAAW,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAChE;AAED,MAAM,WAAW,yBAAyB;IACxC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,wBAAgB,yBAAyB,IAAI,MAAM,CAElD;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAU9B,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,eAAe,EACxB,OAAO,GAAE,yBAA8B,GACtC,kBAAkB,CAuHpB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AddItemsToCartRequest, AddToCartRequest, AuthorizePaymentRequest, CartLoginRequest, CartLoginResult, CartMutationRequest, CartSnapshot, CheckoutRequest, CommercetoolsConfig, CreateOrderRequest, GetOrderRequest, ListOrdersRequest, OrderSnapshot, PaymentConfig, PaymentMethodOption, PaymentSnapshot, ProductCard, SetCartAddressesRequest, SetShippingMethodRequest, ShippingMethodSnapshot, UpdateCartQuantityRequest } from "../types/index.js";
|
|
2
|
+
import type { ProductTypeForFacets } from "./product-types.js";
|
|
3
|
+
import { type ProductSearchBuildInput } from "./query-builder.js";
|
|
4
|
+
export interface CommercetoolsClient {
|
|
5
|
+
searchProducts(input: ProductSearchBuildInput, options?: {
|
|
6
|
+
currency?: string;
|
|
7
|
+
locale?: string;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
productIds: string[];
|
|
10
|
+
total: number;
|
|
11
|
+
projections?: ProductCard[];
|
|
12
|
+
facets?: unknown;
|
|
13
|
+
}>;
|
|
14
|
+
listProductTypes(): Promise<ProductTypeForFacets[]>;
|
|
15
|
+
getProductProjections(productIds: string[], locale: string, currency?: string, country?: string): Promise<ProductCard[]>;
|
|
16
|
+
suggestSearchTerms(prefix: string, locale: string | string[], limit?: number): Promise<string[]>;
|
|
17
|
+
getCart(anonymousId: string, locale?: string): Promise<CartSnapshot | null>;
|
|
18
|
+
getCustomerCart(customerId: string, locale?: string): Promise<CartSnapshot | null>;
|
|
19
|
+
addToCart(input: AddToCartRequest): Promise<CartSnapshot>;
|
|
20
|
+
addItemsToCart(input: AddItemsToCartRequest): Promise<CartSnapshot>;
|
|
21
|
+
removeLineItem(input: CartMutationRequest): Promise<CartSnapshot>;
|
|
22
|
+
changeLineItemQuantity(input: UpdateCartQuantityRequest): Promise<CartSnapshot>;
|
|
23
|
+
loginAndMerge(input: CartLoginRequest): Promise<CartLoginResult>;
|
|
24
|
+
setCartAddresses(input: SetCartAddressesRequest): Promise<CartSnapshot>;
|
|
25
|
+
getShippingMethods(input: CheckoutRequest): Promise<ShippingMethodSnapshot[]>;
|
|
26
|
+
setShippingMethod(input: SetShippingMethodRequest): Promise<CartSnapshot>;
|
|
27
|
+
createOrder(input: CreateOrderRequest): Promise<OrderSnapshot>;
|
|
28
|
+
listPaymentMethods(context: {
|
|
29
|
+
locale?: string;
|
|
30
|
+
country?: string;
|
|
31
|
+
}): Promise<PaymentMethodOption[]>;
|
|
32
|
+
authorizePayment(input: AuthorizePaymentRequest): Promise<{
|
|
33
|
+
payment: PaymentSnapshot;
|
|
34
|
+
cart: CartSnapshot;
|
|
35
|
+
}>;
|
|
36
|
+
getOrder(input: GetOrderRequest): Promise<OrderSnapshot>;
|
|
37
|
+
listOrders(input: ListOrdersRequest): Promise<OrderSnapshot[]>;
|
|
38
|
+
}
|
|
39
|
+
export type { ProductSearchBuildInput, ProductSearchQueryOptions } from "./query-builder.js";
|
|
40
|
+
export declare function createCommercetoolsClient(config: CommercetoolsConfig, options?: {
|
|
41
|
+
payments?: PaymentConfig;
|
|
42
|
+
}): CommercetoolsClient;
|
|
43
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/commercetools/client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAK/D,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAW5B,MAAM,WAAW,mBAAmB;IAClC,cAAc,CACZ,KAAK,EAAE,uBAAuB,EAC9B,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAC/C,OAAO,CAAC;QACT,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;QAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC,CAAC;IACH,gBAAgB,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;IACpD,qBAAqB,CACnB,UAAU,EAAE,MAAM,EAAE,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,CAAC,EA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ClB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;IACnC,gBAAgB,CACd,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC;QAAE,OAAO,EAAE,eAAe,CAAC;QAAC,IAAI,EAAE,YAAY,CAAA;KAAE,CAAC,CAAC;IAC7D,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACzD,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;CAChE;AAID,YAAY,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE7F,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,aAAa,CAAA;CAAE,GACrC,mBAAmB,CAmRrB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** True when a facet id looks like a color/finish attribute (`color-code`, `finish-code`). */
|
|
2
|
+
export declare function isColorLikeFacetName(name: string): boolean;
|
|
3
|
+
/** True when a facet bucket key is a CSS hex color (`#RGB` or `#RRGGBB`). */
|
|
4
|
+
export declare function isHexColorFacetKey(value: string): boolean;
|
|
5
|
+
/** Normalized `#rrggbb` for a hex facet key, or `undefined` when not a color. */
|
|
6
|
+
export declare function hexColorSwatchValue(value: string): string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Human-readable facet chip label. Hex keys on color/finish facets become the
|
|
9
|
+
* nearest CSS color name when close enough; other keys are unchanged.
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatFacetBucketLabel(key: string, facetName?: string): string;
|
|
12
|
+
//# sourceMappingURL=facet-color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facet-color.d.ts","sourceRoot":"","sources":["../../src/commercetools/facet-color.ts"],"names":[],"mappings":"AA2MA,8FAA8F;AAC9F,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMrE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAgB9E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FacetAttributeDefinition, InterpretedSearchFilters, ResolvedFacetSchema, SearchFacetGroup, SuggestedFacet } from "../types/index.js";
|
|
2
|
+
export declare const PRICE_FACET_ID = "price";
|
|
3
|
+
export declare const CATEGORIES_FACET_ID = "categories";
|
|
4
|
+
export declare const DEFAULT_PRICE_RANGES: readonly [{
|
|
5
|
+
readonly key: "under-50";
|
|
6
|
+
readonly to: 5000;
|
|
7
|
+
}, {
|
|
8
|
+
readonly key: "50-to-100";
|
|
9
|
+
readonly from: 5000;
|
|
10
|
+
readonly to: 10000;
|
|
11
|
+
}, {
|
|
12
|
+
readonly key: "100-plus";
|
|
13
|
+
readonly from: 10000;
|
|
14
|
+
}];
|
|
15
|
+
export type PriceRangeDefinition = (typeof DEFAULT_PRICE_RANGES)[number];
|
|
16
|
+
/** Major currency units (e.g. EUR) corresponding to a price range bucket. */
|
|
17
|
+
export declare function priceRangeToFilterValues(range: PriceRangeDefinition): Pick<InterpretedSearchFilters, "priceMin" | "priceMax">;
|
|
18
|
+
export declare function priceBucketKeyFromFilters(filters: InterpretedSearchFilters): string | undefined;
|
|
19
|
+
export declare function isFacetFilterSelected(filters: InterpretedSearchFilters, facetId: string, bucketKey: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Toggle a facet chip into filter state. Price buckets map to priceMin/priceMax;
|
|
22
|
+
* categories map to `category`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function toggleFacetFilter(filters: InterpretedSearchFilters, facetId: string, bucketKey: string): InterpretedSearchFilters;
|
|
25
|
+
export declare function buildProductSearchFacets(schema: ResolvedFacetSchema, suggestedFacets?: SuggestedFacet[]): unknown[];
|
|
26
|
+
/** Product Projection Search `facet` query parameter expressions. */
|
|
27
|
+
export declare function buildProjectionFacetParams(schema: ResolvedFacetSchema, suggestedFacets?: SuggestedFacet[]): string[];
|
|
28
|
+
export declare function normalizeProductSearchFacets(rawFacets: unknown, schema: ResolvedFacetSchema, suggestedFacets?: SuggestedFacet[], filters?: InterpretedSearchFilters): SearchFacetGroup[];
|
|
29
|
+
export declare function filterFacetSuggestions(suggestedFacets: SuggestedFacet[] | undefined, schema: ResolvedFacetSchema): SuggestedFacet[];
|
|
30
|
+
export declare function getFacetAttribute(schema: ResolvedFacetSchema, name: string): FacetAttributeDefinition | undefined;
|
|
31
|
+
//# sourceMappingURL=facets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facets.d.ts","sourceRoot":"","sources":["../../src/commercetools/facets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,cAAc,UAAU,CAAC;AACtC,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAEhD,eAAO,MAAM,oBAAoB;aAC7B,GAAG,EAAE,UAAU;aAAE,EAAE,EAAE,IAAK;;aAC1B,GAAG,EAAE,WAAW;aAAE,IAAI,EAAE,IAAK;aAAE,EAAE,EAAE,KAAM;;aACzC,GAAG,EAAE,UAAU;aAAE,IAAI,EAAE,KAAM;EACvB,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzE,6EAA6E;AAC7E,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,oBAAoB,GAC1B,IAAI,CAAC,wBAAwB,EAAE,UAAU,GAAG,UAAU,CAAC,CASzD;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,wBAAwB,GAChC,MAAM,GAAG,SAAS,CAYpB;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,wBAAwB,EACjC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAQT;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,wBAAwB,EACjC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,wBAAwB,CAyB1B;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,mBAAmB,EAC3B,eAAe,GAAE,cAAc,EAAO,GACrC,OAAO,EAAE,CAmCX;AAED,qEAAqE;AACrE,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,mBAAmB,EAC3B,eAAe,GAAE,cAAc,EAAO,GACrC,MAAM,EAAE,CA2BV;AAED,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,OAAO,EAClB,MAAM,EAAE,mBAAmB,EAC3B,eAAe,GAAE,cAAc,EAAO,EACtC,OAAO,GAAE,wBAA6B,GACrC,gBAAgB,EAAE,CAsDpB;AAED,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,cAAc,EAAE,GAAG,SAAS,EAC7C,MAAM,EAAE,mBAAmB,GAC1B,cAAc,EAAE,CAGlB;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,mBAAmB,EAC3B,IAAI,EAAE,MAAM,GACX,wBAAwB,GAAG,SAAS,CAEtC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { ProductCard } from "../types/index.js";
|
|
2
|
+
/** Max product IDs per GraphQL `products` query (commercetools pagination). */
|
|
3
|
+
export declare const GRAPHQL_PRODUCT_CARD_CHUNK_SIZE = 100;
|
|
4
|
+
/**
|
|
5
|
+
* Card hydrate query — pass only `acceptLanguage` on localized strings
|
|
6
|
+
* (commercetools rejects `locale` and `acceptLanguage` together).
|
|
7
|
+
* Do not use `localeProjection` with `name(acceptLanguage:)`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PRODUCT_CARDS_GRAPHQL_QUERY: string;
|
|
10
|
+
export interface GraphQLMoneyValue {
|
|
11
|
+
centAmount: number;
|
|
12
|
+
currencyCode: string;
|
|
13
|
+
fractionDigits?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface GraphQLLocalizedStringEntry {
|
|
16
|
+
locale: string;
|
|
17
|
+
value?: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface GraphQLProductCardVariant {
|
|
20
|
+
id?: number;
|
|
21
|
+
sku?: string | null;
|
|
22
|
+
images?: Array<{
|
|
23
|
+
url: string;
|
|
24
|
+
} | null> | null;
|
|
25
|
+
price?: {
|
|
26
|
+
value: GraphQLMoneyValue;
|
|
27
|
+
} | null;
|
|
28
|
+
}
|
|
29
|
+
export interface GraphQLProductCardCurrent {
|
|
30
|
+
name?: string | null;
|
|
31
|
+
description?: string | null;
|
|
32
|
+
slug?: string | null;
|
|
33
|
+
nameAllLocales?: Array<GraphQLLocalizedStringEntry | null> | null;
|
|
34
|
+
descriptionAllLocales?: Array<GraphQLLocalizedStringEntry | null> | null;
|
|
35
|
+
slugAllLocales?: Array<GraphQLLocalizedStringEntry | null> | null;
|
|
36
|
+
masterVariant?: GraphQLProductCardVariant | null;
|
|
37
|
+
}
|
|
38
|
+
export interface GraphQLProductCardResult {
|
|
39
|
+
id: string;
|
|
40
|
+
key?: string | null;
|
|
41
|
+
masterData?: {
|
|
42
|
+
current?: GraphQLProductCardCurrent | null;
|
|
43
|
+
} | null;
|
|
44
|
+
}
|
|
45
|
+
export interface GraphQLProductCardsData {
|
|
46
|
+
products?: {
|
|
47
|
+
results?: Array<GraphQLProductCardResult | null> | null;
|
|
48
|
+
} | null;
|
|
49
|
+
}
|
|
50
|
+
export interface ProductCardsGraphQLVariables {
|
|
51
|
+
where: string;
|
|
52
|
+
limit: number;
|
|
53
|
+
locales: string[];
|
|
54
|
+
currency: string;
|
|
55
|
+
country?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Build a commercetools query predicate for product IDs.
|
|
59
|
+
* IDs are UUID strings from Product Search — no escaping beyond quoting.
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildProductIdsWhere(productIds: string[]): string;
|
|
62
|
+
export declare function chunkProductIds(productIds: string[], chunkSize?: number): string[][];
|
|
63
|
+
/**
|
|
64
|
+
* Accept-Language style fallbacks for catalog locales (e.g. en-GB → en-US → en).
|
|
65
|
+
*/
|
|
66
|
+
export declare function buildAcceptLanguageLocales(locale: string): string[];
|
|
67
|
+
export declare function buildProductCardsGraphQLVariables(productIds: string[], locale: string, currency: string, country?: string): ProductCardsGraphQLVariables;
|
|
68
|
+
export declare function pickLocalizedValue(direct: string | null | undefined, allLocales: Array<GraphQLLocalizedStringEntry | null> | null | undefined, preferredLocales: string[]): string | undefined;
|
|
69
|
+
export declare function mapGraphQLProductToCard(product: GraphQLProductCardResult, locale: string): ProductCard | null;
|
|
70
|
+
/**
|
|
71
|
+
* Map GraphQL `products` results to ProductCards, preserving Product Search order.
|
|
72
|
+
* Unpublished products (`current` missing) are skipped.
|
|
73
|
+
*/
|
|
74
|
+
export declare function mapGraphQLProductsToCards(results: Array<GraphQLProductCardResult | null | undefined> | null | undefined, productIds: string[], locale: string): ProductCard[];
|
|
75
|
+
export declare function extractGraphQLProductResults(data: GraphQLProductCardsData | null | undefined): GraphQLProductCardResult[];
|
|
76
|
+
export type GraphQLHydrateDecision = {
|
|
77
|
+
type: "use-data";
|
|
78
|
+
data: GraphQLProductCardsData;
|
|
79
|
+
warnings: string[];
|
|
80
|
+
} | {
|
|
81
|
+
type: "fallback";
|
|
82
|
+
reason: string;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Prefer usable GraphQL `data` even when field-level `errors` are present.
|
|
86
|
+
* Fall back to REST only when there is no products result payload.
|
|
87
|
+
*/
|
|
88
|
+
export declare function decideGraphQLProductCardsHydrate(body: {
|
|
89
|
+
data?: GraphQLProductCardsData | null;
|
|
90
|
+
errors?: Array<{
|
|
91
|
+
message: string;
|
|
92
|
+
}> | null;
|
|
93
|
+
}): GraphQLHydrateDecision;
|
|
94
|
+
//# sourceMappingURL=graphql-product-cards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-product-cards.d.ts","sourceRoot":"","sources":["../../src/commercetools/graphql-product-cards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,+EAA+E;AAC/E,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,QAiChC,CAAC;AAET,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,yBAAyB;IACxC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9C,KAAK,CAAC,EAAE;QAAE,KAAK,EAAE,iBAAiB,CAAA;KAAE,GAAG,IAAI,CAAC;CAC7C;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;I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napshot } from "../types/index.js";
|
|
3
|
+
export interface OrderGateway {
|
|
4
|
+
queryOrders(where: string, options?: {
|
|
5
|
+
limit?: number;
|
|
6
|
+
}): Promise<Order[]>;
|
|
7
|
+
}
|
|
8
|
+
export interface OrderOperations {
|
|
9
|
+
getOrder(input: GetOrderRequest): Promise<OrderSnapshot>;
|
|
10
|
+
listOrders(input: ListOrdersRequest): Promise<OrderSnapshot[]>;
|
|
11
|
+
}
|
|
12
|
+
export declare class OrderNotFoundError extends Error {
|
|
13
|
+
constructor(message?: string);
|
|
14
|
+
}
|
|
15
|
+
export declare function buildAnonymousOrderWhere(orderNumber: string, anonymousId: string): string;
|
|
16
|
+
export declare function buildCustomerOrderWhere(orderNumber: string, customerId: string): string;
|
|
17
|
+
export declare function buildOwnerOrdersWhere(identity: {
|
|
18
|
+
customerId?: string;
|
|
19
|
+
anonymousId?: string;
|
|
20
|
+
}): string | undefined;
|
|
21
|
+
export declare function buildOwnerOrderWhere(orderNumber: string, identity: {
|
|
22
|
+
customerId?: string;
|
|
23
|
+
anonymousId?: string;
|
|
24
|
+
}): string | undefined;
|
|
25
|
+
export declare function mapOrderToSnapshot(order: Order, locale: string): OrderSnapshot;
|
|
26
|
+
export declare function createOrderOperations(gateway: OrderGateway): OrderOperations;
|
|
27
|
+
//# sourceMappingURL=order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../src/commercetools/order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAoB,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAEV,eAAe,EACf,iBAAiB,EACjB,aAAa,EAEd,MAAM,mBAAmB,CAAC;AAY3B,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;CAC5E;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACzD,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;CAChE;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAO,SAAoB,EAGtC;CACF;AAED,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAEzF;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAEvF;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,GAAG,SAAS,CAWrB;AAED,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACtD,MAAM,GAAG,SAAS,CAWpB;AAgDD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAkB9E;AAUD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,YAAY,GAAG,eAAe,CAuC5E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Cart, Payment, PaymentReference, Transaction } from "@commercetools/platform-sdk";
|
|
2
|
+
import type { PaymentSnapshot } from "../types/index.js";
|
|
3
|
+
export declare function mapPaymentStatus(transactions: Transaction[] | undefined): PaymentSnapshot["status"];
|
|
4
|
+
export declare function mapPaymentToSnapshot(payment: Payment, locale: string, clientData?: Record<string, string>): PaymentSnapshot;
|
|
5
|
+
export declare function resolveExpandedPayment(ref: PaymentReference | Payment): Payment | undefined;
|
|
6
|
+
export declare function paymentHasSuccessfulAuthorization(payment: Payment): boolean;
|
|
7
|
+
export declare function paymentHasSuccessfulCharge(payment: Payment): boolean;
|
|
8
|
+
export declare function paymentMatchesCartAmount(payment: Payment, cart: Cart): boolean;
|
|
9
|
+
export declare function paymentCoversCartTotal(payment: Payment, cart: Cart): boolean;
|
|
10
|
+
export declare function paymentOwnedByCart(payment: Payment, cart: Cart): boolean;
|
|
11
|
+
export declare function mapCartPayments(cart: Cart, locale: string): PaymentSnapshot[] | undefined;
|
|
12
|
+
export type CartPaymentCoverage = "ok" | "missing" | "mismatch";
|
|
13
|
+
export declare function resolveCartPaymentCoverage(cart: Cart, getPaymentById: (id: string) => Promise<Payment>): Promise<CartPaymentCoverage>;
|
|
14
|
+
export declare function resolveOrderPaymentState(cart: Cart, getPaymentById: (id: string) => Promise<Payment>): Promise<"Paid" | "Pending" | undefined>;
|
|
15
|
+
export declare function isDuplicateField(error: unknown): boolean;
|
|
16
|
+
export declare function isResourceNotFound(error: unknown): boolean;
|
|
17
|
+
export declare function isAnonymousIdAlreadyUsed(error: unknown): boolean;
|
|
18
|
+
//# sourceMappingURL=payment-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-map.d.ts","sourceRoot":"","sources":["../../src/commercetools/payment-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,WAAW,EAAE,GAAG,SAAS,GACtC,eAAe,CAAC,QAAQ,CAAC,CAY3B;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAA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,CAKhE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Payment, PaymentDraft } from "@commercetools/platform-sdk";
|
|
2
|
+
import type { AuthorizePaymentRequest, CartSnapshot, PaymentMethodOption, PaymentSnapshot } from "../types/index.js";
|
|
3
|
+
import type { PaymentProvider } from "../payments/types.js";
|
|
4
|
+
import { type CheckoutGateway } from "./checkout.js";
|
|
5
|
+
export interface PaymentGateway extends CheckoutGateway {
|
|
6
|
+
createPayment(draft: PaymentDraft): Promise<Payment>;
|
|
7
|
+
getPaymentById(id: string): Promise<Payment>;
|
|
8
|
+
getPaymentByKey(key: string): Promise<Payment>;
|
|
9
|
+
}
|
|
10
|
+
export interface PaymentOperations {
|
|
11
|
+
listPaymentMethods(context: {
|
|
12
|
+
locale?: string;
|
|
13
|
+
country?: string;
|
|
14
|
+
}): Promise<PaymentMethodOption[]>;
|
|
15
|
+
authorizePayment(input: AuthorizePaymentRequest): Promise<{
|
|
16
|
+
payment: PaymentSnapshot;
|
|
17
|
+
cart: CartSnapshot;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export declare class PaymentDeclinedError extends Error {
|
|
21
|
+
constructor(message?: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class PaymentNotConfiguredError extends Error {
|
|
24
|
+
constructor(message?: string);
|
|
25
|
+
}
|
|
26
|
+
export declare function createPaymentKey(orderNumber: string, paymentInterface: string, cartId?: string, attempt?: number): string;
|
|
27
|
+
export declare function createPaymentOperations(gateway: PaymentGateway, provider?: PaymentProvider): PaymentOperations;
|
|
28
|
+
//# sourceMappingURL=payment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../src/commercetools/payment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,KAAK,EACV,uBAAuB,EACvB,YAAY,EACZ,mBAAm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QLVariables } from "./graphql-product-cards.js";
|
|
3
|
+
export interface ProductCardHydrateTransport {
|
|
4
|
+
graphql(input: {
|
|
5
|
+
query: string;
|
|
6
|
+
variables: ProductCardsGraphQLVariables;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
data?: GraphQLProductCardsData | null;
|
|
9
|
+
errors?: Array<{
|
|
10
|
+
message: string;
|
|
11
|
+
}> | null;
|
|
12
|
+
}>;
|
|
13
|
+
rest(input: {
|
|
14
|
+
productIds: string[];
|
|
15
|
+
locale: string;
|
|
16
|
+
currency: string;
|
|
17
|
+
country?: string;
|
|
18
|
+
}): Promise<ProductCard[]>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Hydrate ProductCards via GraphQL, falling back to REST on hard failures.
|
|
22
|
+
* Field-level GraphQL errors with a usable `products.results` payload do not trigger fallback.
|
|
23
|
+
*/
|
|
24
|
+
export declare function hydrateProductCards(transport: ProductCardHydrateTransport, productIds: string[], locale: string, currency: string, country?: string): Promise<ProductCard[]>;
|
|
25
|
+
//# sourceMappingURL=product-card-hydrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-card-hydrate.d.ts","sourceRoot":"","sources":["../../src/commercetools/product-card-hydrate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAOL,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EAClC,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,2BAA2B;IAC1C,OAAO,CAAC,KAAK,EAAE;QACb,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,4BAA4B,CAAC;KACzC,GAAG,OAAO,CAAC;QACV,IAAI,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAAC;QACtC,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,GAAG,IAAI,CAAC;KAC5C,CAAC,CAAC;IACH,IAAI,CAAC,KAAK,EAAE;QACV,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,2BAA2B,EACtC,UAAU,EAAE,MAAM,EAAE,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,EAAE,CAAC,CAgBxB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ResolvedFacetSchema } from "../types/index.js";
|
|
2
|
+
interface ProductTypeAttribute {
|
|
3
|
+
name: string;
|
|
4
|
+
label?: Record<string, string>;
|
|
5
|
+
isSearchable?: boolean;
|
|
6
|
+
type: {
|
|
7
|
+
name: string;
|
|
8
|
+
elementType?: {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface ProductTypeForFacets {
|
|
14
|
+
version: number;
|
|
15
|
+
attributes?: ProductTypeAttribute[];
|
|
16
|
+
}
|
|
17
|
+
export interface FacetSchemaOptions {
|
|
18
|
+
projectKey: string;
|
|
19
|
+
catalogLocale: string;
|
|
20
|
+
include?: string[];
|
|
21
|
+
exclude?: string[];
|
|
22
|
+
maxAttributes?: number;
|
|
23
|
+
}
|
|
24
|
+
export declare class FacetSchemaStore {
|
|
25
|
+
private readonly ttlMs;
|
|
26
|
+
private readonly entries;
|
|
27
|
+
private readonly pending;
|
|
28
|
+
constructor(ttlMs?: number);
|
|
29
|
+
getOrResolve(options: FacetSchemaOptions, loadProductTypes: () => Promise<ProductTypeForFacets[]>): Promise<ResolvedFacetSchema>;
|
|
30
|
+
clear(): void;
|
|
31
|
+
}
|
|
32
|
+
export declare function resolveFacetSchema(productTypes: ProductTypeForFacets[], options: FacetSchemaOptions): ResolvedFacetSchema;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=product-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-types.d.ts","sourceRoot":"","sources":["../../src/commercetools/product-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;KAChC,CAAC;CACH;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAOD,qBAAa,gBAAgB;IAIf,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmC;IAC3D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmD;IAE3E,YAA6B,KAAK,SAAc,EAAI;IAE9C,YAAY,CAChB,OAAO,EAAE,kBAAkB,EAC3B,gBAAgB,EAAE,MAAM,OAAO,CAAC,oBAAoB,EAAE,CAAC,GACtD,OAAO,CAAC,mBAAmB,CAAC,CAsB9B;IAED,KAAK,IAAI,IAAI,CAEZ;CACF;AAED,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,oBAAoB,EAAE,EACpC,OAAO,EAAE,kBAAkB,GAC1B,mBAAmB,CA0CrB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ProductSearchRequest } from "@commercetools/platform-sdk";
|
|
2
|
+
import type { InterpretedSearchQuery, ResolvedFacetSchema } from "../types/index.js";
|
|
3
|
+
export interface ProductSearchQueryOptions {
|
|
4
|
+
currency?: string;
|
|
5
|
+
/** When true, adds a fuzzy match on product name (tolerates typos). Default: true. */
|
|
6
|
+
enableFuzzyName?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Token matching for fullText / fuzzy clauses. Default: `"all"`.
|
|
9
|
+
* `"any"` is used as a last-ditch relaxation when the first search returns zero hits.
|
|
10
|
+
*/
|
|
11
|
+
mustMatch?: "all" | "any";
|
|
12
|
+
/**
|
|
13
|
+
* Store key for future store-scoped search.
|
|
14
|
+
* Not applied unless `storeScopeEnabled` is true (planned feature).
|
|
15
|
+
*/
|
|
16
|
+
storeKey?: string;
|
|
17
|
+
/** When false (default), `storeKey` is ignored. */
|
|
18
|
+
storeScopeEnabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface ProductSearchBuildInput {
|
|
21
|
+
interpreted: InterpretedSearchQuery;
|
|
22
|
+
catalogLocale: string;
|
|
23
|
+
limit?: number;
|
|
24
|
+
offset?: number;
|
|
25
|
+
options?: ProductSearchQueryOptions;
|
|
26
|
+
facetSchema?: ResolvedFacetSchema;
|
|
27
|
+
}
|
|
28
|
+
/** Applied to `TEXT_FIELD_BOOSTS` when the phrase is `primaryTerm`. */
|
|
29
|
+
export declare const PRIMARY_TERM_BOOST_MULTIPLIER = 2;
|
|
30
|
+
export declare function hasSearchableContent(interpreted: InterpretedSearchQuery): boolean;
|
|
31
|
+
/** Joins phrases with spaces. Product Search ORs phrases; this is not used for that query. */
|
|
32
|
+
export declare function joinSearchTerms(searchTerms: string[]): string;
|
|
33
|
+
export declare function buildProductSearchBody(interpreted: InterpretedSearchQuery, catalogLocale: string, limit?: number, offset?: number, options?: ProductSearchQueryOptions): ProductSearchRequest;
|
|
34
|
+
export declare function buildProductSearchRequest(input: ProductSearchBuildInput): ProductSearchRequest;
|
|
35
|
+
/**
|
|
36
|
+
* Product Projection Search query args. Full-text is a single `text.{locale}`
|
|
37
|
+
* value — commercetools does not OR multiple phrases here, so only the first
|
|
38
|
+
* catalog phrase is sent. Product Search remains the multi-phrase path.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildProjectionSearchQueryArgs(input: ProductSearchBuildInput): Record<string, string | number | boolean | string[]>;
|
|
41
|
+
//# sourceMappingURL=query-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-builder.d.ts","sourceRoot":"","sources":["../../src/commercetools/query-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAiB,MAAM,6BAA6B,CAAC;AACvF,OAAO,KAAK,EAEV,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAO3B,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sFAAsF;IACtF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,sBAAsB,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,yBAAyB,CAAC;IACpC,WAAW,CAAC,EAAE,mBAAmB,CAAC;CACnC;AAUD,uEAAuE;AACvE,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAI/C,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,sBAAsB,GAAG,OAAO,CAIjF;AAED,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,CAE7D;AAwBD,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,sBAAsB,EACnC,aAAa,EAAE,MAAM,EACrB,KAAK,SAAK,EACV,MAAM,SAAI,EACV,OAAO,CAAC,EAAE,yBAAyB,GAClC,oBAAoB,CAQtB;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,uBAAuB,GAAG,oBAAoB,CAmC9F;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,uBAAuB,GAC7B,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC,CA0CtD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ProductSearchRequest } from "@commercetools/platform-sdk";
|
|
2
|
+
export interface ExtractedSearchTerms {
|
|
3
|
+
terms: string[];
|
|
4
|
+
locale: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function extractSearchTerms(body: ProductSearchRequest): ExtractedSearchTerms;
|
|
7
|
+
export { buildProjectionSearchQueryArgs } from "./query-builder.js";
|
|
8
|
+
export declare function extractProductSearchIds(results: Array<{
|
|
9
|
+
id?: string;
|
|
10
|
+
productProjection?: {
|
|
11
|
+
id?: string;
|
|
12
|
+
};
|
|
13
|
+
}>): string[];
|
|
14
|
+
export declare function isProductSearchUnavailable(error: unknown): boolean;
|
|
15
|
+
export declare function productSearchUnavailableMessage(projectKey: string): string;
|
|
16
|
+
//# sourceMappingURL=search-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-helpers.d.ts","sourceRoot":"","sources":["../../src/commercetools/search-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,GAAG,oBAAoB,CAcnF;AAwCD,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAEpE,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,KAAK,CAAC;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC,GACnE,MAAM,EAAE,CAIV;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQlE;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAM1E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autocomplete should surface short search phrases / product names,
|
|
3
|
+
* not truncated marketing descriptions from searchKeywords.
|
|
4
|
+
*/
|
|
5
|
+
/** Soft cap for a single suggestion string. */
|
|
6
|
+
export declare const SUGGESTION_MAX_LENGTH = 50;
|
|
7
|
+
/** Soft cap for whitespace-separated tokens. */
|
|
8
|
+
export declare const SUGGESTION_MAX_WORDS = 6;
|
|
9
|
+
/**
|
|
10
|
+
* True when the text looks like a short catalog search phrase suitable for autocomplete.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isSuggestiblePhrase(text: string): boolean;
|
|
13
|
+
//# sourceMappingURL=suggestion-quality.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestion-quality.d.ts","sourceRoot":"","sources":["../../src/commercetools/suggestion-quality.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+CAA+C;AAC/C,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,gDAAgD;AAChD,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAKtC;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA6BzD"}
|