@ecomweb/sdk 0.15.0 → 0.16.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/dist/index.d.ts CHANGED
@@ -17,6 +17,12 @@ interface ApiResponse<T = any> {
17
17
  data?: T;
18
18
  error?: ApiError;
19
19
  success: boolean;
20
+ /**
21
+ * The response headers, names in lowercase, when the HTTP client passes
22
+ * them on. Read for totals such as `x-total-count`; optional, so a client
23
+ * that leaves them out still works.
24
+ */
25
+ headers?: Record<string, string>;
20
26
  }
21
27
  interface IHttpClient {
22
28
  get<T>(url: string, options?: RequestOptions): Promise<ApiResponse<T>>;
@@ -4527,6 +4533,21 @@ interface BlogPostQueryParams extends BaseQueryParams {
4527
4533
  include_tags?: boolean;
4528
4534
  include_author?: boolean;
4529
4535
  }
4536
+ /** Paging and order for a post's comments. */
4537
+ interface BlogPostCommentsQuery {
4538
+ /** At most 100 (the default); a larger value is lowered to 100. */
4539
+ limit?: number;
4540
+ /** Comments to skip. Defaults to 0. */
4541
+ offset?: number;
4542
+ /** `asc` (oldest first, the default) or `desc` (newest first). */
4543
+ sort_order?: "asc" | "desc";
4544
+ }
4545
+ /** One page of a post's comments, with the total across all pages. */
4546
+ interface BlogPostCommentsPage {
4547
+ items: any[];
4548
+ /** Every comment the caller can see on the post, across all pages; `null` when the HTTP client does not pass response headers on. */
4549
+ total: number | null;
4550
+ }
4530
4551
  interface BlogCategoryQueryParams extends BaseQueryParams {
4531
4552
  include_post_counts?: boolean;
4532
4553
  }
@@ -4581,21 +4602,42 @@ declare class BlogApi {
4581
4602
  */
4582
4603
  getTags(storeRef: string, query?: BlogTagQueryParams): Promise<PaginatedResponse<BlogTag>>;
4583
4604
  /**
4584
- * Lists the approved comments of a post, as an anonymous visitor.
4605
+ * Lists the approved comments of a post, as an anonymous visitor. Returns at
4606
+ * most 100 per call, oldest first unless `sort_order` is `desc`; use
4607
+ * {@link BlogApi.getPostCommentsPage} for the total.
4585
4608
  *
4586
4609
  * @param storeRef - the store's ref or handle
4587
4610
  * @param postId - the post id
4611
+ * @param query - `limit` (at most 100), `offset` and `sort_order`
4588
4612
  * @returns The comments; throws {@link ApiClientError} when the API answers with an error
4589
4613
  */
4590
- getPostComments(storeRef: string, postId: number): Promise<any[]>;
4614
+ getPostComments(storeRef: string, postId: number, query?: BlogPostCommentsQuery): Promise<any[]>;
4591
4615
  /**
4592
- * Lists the approved comments of a post, sending the signed-in customer's credentials.
4616
+ * Lists the approved comments of a post, sending the signed-in customer's
4617
+ * credentials, so that customer's own comments still waiting for approval
4618
+ * are included. Paging as in {@link BlogApi.getPostComments}.
4593
4619
  *
4594
4620
  * @param storeRef - the store's ref or handle
4595
4621
  * @param postId - the post id
4622
+ * @param query - `limit` (at most 100), `offset` and `sort_order`
4596
4623
  * @returns The comments; throws {@link ApiClientError} when the API answers with an error
4597
4624
  */
4598
- getPostCommentsAuth(storeRef: string, postId: number): Promise<any[]>;
4625
+ getPostCommentsAuth(storeRef: string, postId: number, query?: BlogPostCommentsQuery): Promise<any[]>;
4626
+ /**
4627
+ * One page of a post's comments with the total across all pages, for
4628
+ * "load more" or a comment count. Set `asCustomer` to include the signed-in
4629
+ * customer's own pending comments, as {@link BlogApi.getPostCommentsAuth} does.
4630
+ *
4631
+ * @param storeRef - the store's ref or handle
4632
+ * @param postId - the post id
4633
+ * @param query - `limit` (at most 100), `offset` and `sort_order`
4634
+ * @param options - `asCustomer` sends the signed-in customer's credentials
4635
+ * @returns The page and the total (`null` when the HTTP client does not pass response headers on); throws {@link ApiClientError} when the API answers with an error
4636
+ */
4637
+ getPostCommentsPage(storeRef: string, postId: number, query?: BlogPostCommentsQuery, options?: {
4638
+ asCustomer?: boolean;
4639
+ }): Promise<BlogPostCommentsPage>;
4640
+ private fetchComments;
4599
4641
  }
4600
4642
  /**
4601
4643
  * Blog comment submission, reached through `sdk.blog` on the server and proxied SDKs.
@@ -6117,4 +6159,4 @@ declare function createEcomwebServerSdk(options: EcomwebServerSdkOptions): Ecomw
6117
6159
  */
6118
6160
  declare function createEcomwebProxiedSdk(options: EcomwebProxiedSdkOptions): EcomwebServerSdk;
6119
6161
 
6120
- export { ADJUSTABLE_STATES, ADMIN_ORDER_SOURCES, type AddToCartRequest, type Address, AddressesApi, type AdjustQuantitiesRequest, type AdjustableState, type AdminOrderSource, ApiClientError, type ApiError, type ApiResponse, type AppliedPromotion, type AttributeLink, AuthApi, type AuthErrorCode, type AuthIdentity, type AuthResult, type AuthTokens, type AutocompleteParams, type BankAccount, type BaseDeleteOptions, type BaseDeleteResult, type BaseQueryParams, type BatchOrderReviewInvitationsResult, BlogApi, type BlogCategory, type BlogCategoryQueryParams, type BlogComment, type BlogCommentWithReplies, type BlogPost, type BlogPostCategory, type BlogPostQueryParams, type BlogPostStatus, type BlogPostTag, type BlogPostWithRelations, type BlogSearchParams, type BlogSearchResponse, BlogServerApi, type BlogSettings, type BlogTag, type BlogTagQueryParams, CLIENT_HEADER, COLLECTION_RULE_MATRIX, CONDITION_TYPE_LABELS, CartApi, type CartApiItem, type CartApiResponse, CategoriesApi, type Category, type CategoryQueryParams, type CategorySearchResponse, type CategoryTree, type CategoryWithChildren, type ChangeEmailPayload, type ChangeEmailResult, type ChangePasswordPayload, type ChangedResult, type Collection, type CollectionQueryParams, type CollectionRule, type CollectionRuleSet, type CollectionRuleSetCriteria, type CollectionSearchCriteria, CollectionsApi, ConditionType, ConditionTypeSchema, type ConditionTypeType, type ContentPage, ContentPagesApi, type CreateAddressDto, type CreateBlogCategory, type CreateBlogComment, type CreateBlogPost, type CreateBlogSettings, type CreateBlogTag, type CreateCategory, type CreateContentPage, type CreateEmbeddedScript, type CreateOrder, type CreateOrderItem, type CreateOrderItemRequest, type CreateOrderRequest, type CreateProduct, type CreateProductReview, type CreateProductReviewReply, type CreateProductVariant, type CreatePromotion, CreatePromotionSchema, type CreateStore, type CreateStoreConfig, type CreateStoreSettings, type CreateVariantOption, type CreateVariantOptionValue, type CurrentIdentity, type Customer, type CustomerAccess, type CustomerOrderFilter, type CustomerOrderSummary, CustomersApi, DEFAULT_BUCKET, DISCOUNT_METHOD_LABELS, type DeleteApiFunction, type DeletedAt, DiscountMethod, DiscountMethodSchema, type DiscountMethodType, EMAIL_COLOR_PATTERN, EMAIL_PALETTE_DEFAULTS, ENTRY_HANDLE_PATTERN, type EcomwebProxiedSdkOptions, type EcomwebSdk, type EcomwebSdkOptions, type EcomwebServerSdk, type EcomwebServerSdkOptions, type EmbeddedScript, type EmbeddedScriptPlacement, type EngineResult, FILTERABLE_TYPES, type FileKind, type FulfillmentStatus, type GoogleAuthUrl, type GuestOrderLookupParams, type IHttpClient, INVENTORY_ADJUSTMENT_REASONS, INVENTORY_ERROR_CODES, INVENTORY_POLICIES, INVENTORY_STATES, INVENTORY_STATUS_LABELS, type Id, type ImageFormat, type ImageTransformOptions, type InitiatePaymentResult, type InsufficientInventoryItem, type IntegrationStatus, type InventoryActor, type InventoryAdjustmentReason, type InventoryErrorCode, type InventoryHistoryEntry, type InventoryImportResponse, type InventoryLevelRow, type InventoryLocation, type InventoryPolicy, type InventoryQuantities, type InventoryState, InventoryStatus, KNOWN_PAYMENT_METHODS, LEGACY_STATUS_MIGRATION_MAP, LEVEL_PROVINCE, LEVEL_WARD, type LegacyOrderStatus, type LegacyProductStatus, type LinkValue, type LocationArea, type LocationAreaQuery, type LocationAreasResponse, type LoginPayload, MAX_RULES_PER_SET, MAX_RULE_VALUE_ENTRIES, MEASUREMENT_UNITS, MEDIA_TYPES, MERCHANT_ADJUSTMENT_REASONS, METAFIELD_BASE_TYPES, METAFIELD_KEY_PATTERN, METAFIELD_LIMITS, METAFIELD_OWNER_TYPES, METAFIELD_TYPE_GROUPS, METAOBJECT_REFERENCE_TYPES, METAOBJECT_TYPE_PATTERN, type MeasurementType, type MeasurementValue, MemoryTokenStorage, MenusApi, type MerchantAdjustmentReason, type MessageOutboxStatus, type MetafieldBaseType, type MetafieldBound, type MetafieldContext, type MetafieldDefinitionShape, type MetafieldIssue, type MetafieldIssueCode, type MetafieldListType, type MetafieldOwnerType, type MetafieldType, type MetafieldTypeGroup, type MetafieldValidationKey, type MetafieldValidations, type MetafieldWrite, type MetaobjectDefinitionShape, type MetaobjectFieldShape, type MetaobjectListParams, type MetaobjectListResult, MetaobjectsApi, type MoneyValue, type MoveQuantitiesRequest, type MutationApiFunction, OBJECT_PREFIX, ORDER_ACTOR_TYPES, ORDER_EVENT_TYPES, ORDER_SHIPMENT_ERROR_CODES, ORDER_SOURCES, type OptionalTimestamp, type Order, type OrderActorType, type OrderCommentMutationResult, type OrderCreatedBy, type OrderEventType, type OrderItem, type PaymentMethod$1 as OrderPaymentMethod, type OrderReviewInvitationSummary, type OrderShipmentEvent, type OrderShipmentSummary, type OrderSource, type OrderStatus, type OrderTimelineActor, type OrderTimelineComment, type OrderTimelineCommentAuthor, type OrderTimelineEntry, type OrderTimelineEvent, type OrderTimelineResponse, type OrderWithItems, OrdersApi, PAGINATION_DEFAULTS, PRIVATE_REFERENCE_TYPES, PRODUCT_STATUS_LABELS, PROMOTION_MODE_COLORS, PROMOTION_MODE_LABELS, PROMOTION_STATUS_COLORS, PROMOTION_STATUS_LABELS, PROMOTION_TYPE_COLORS, PROMOTION_TYPE_LABELS, type PaginatedApiFunction, type PaginatedPromotionsResponse, PaginatedPromotionsResponseSchema, type PaginatedResponse, type PaginatedReviewsResponse, type PaginationMeta, type PasswordPolicy, type PaymentCredentialStatus, type PaymentMethod$1 as PaymentMethod, PaymentMethodsApi, type PaymentStateResult, type PaymentStatus, PaymentsApi, type Product, type ProductDetail, type ProductImage, type ProductQueryParams, type ProductReview, type ProductReviewFilters, type ProductReviewReply, type ProductReviewReplyFilters, type ProductReviewStats, type ProductReviewWithReplies, type ProductSearchParams, type ProductSearchResponse, type ProductService, ProductStatus, type ProductVariant, type ProductVariantCombination, type ProductVariantCombinationEntry, type ProductVariantWithCombinations, type ProductVideo, type ProductWithReviewStats, type ProductWithVariants, ProductsApi, type Promotion, type PromotionData, PromotionMode, PromotionModeSchema, type PromotionModeType, type PromotionQueryParams, PromotionQueryParamsSchema, PromotionSchema, type PromotionStatistics, PromotionStatisticsSchema, PromotionStatus, PromotionStatusSchema, type PromotionStatusType, type PromotionSuggestion, type PromotionSuggestionsResponse, PromotionType, PromotionTypeSchema, type PromotionTypeType, type PromotionWithDiscount, PromotionWithDiscountSchema, PromotionsApi, PromotionsServerApi, type PublicAuthConfig, type PublishedStoreTheme, type QuantitiesResponse, RENDER_PREFIX, RESOURCE_REFERENCE_TYPES, RULE_FIELDS, type RatingValue, RedirectsApi, type RegisterPayload, type RegisterResult, type RequestOptions, type ResetPasswordPayload, type ResetResult, type ResizeMode, type ResolvedAsset, type ResolvedBlogPostRef, type ResolvedCollectionRef, type ResolvedImage, type ResolvedMetaobjectRef, type ResolvedMetaobjectStub, type ResolvedPageRef, type ResolvedProductRef, type ResolvedVariantRef, type ReviewInvitationPublicData, type ReviewStatus, ReviewsApi, ReviewsServerApi, type RichTextBlock, type RichTextHeading, type RichTextInline, type RichTextLink, type RichTextList, type RichTextListItem, type RichTextNode, type RichTextParagraph, type RichTextRoot, type RichTextText, type RuleField, type RuleFieldSpec, type RuleOperator, type RuleOperatorSpec, type RuleValueKind, SDK_CLIENT_TOKEN, SDK_VERSION, SHIPMENT_STATUSES, SHIPPING_CONDITION_TYPES, SHIPPING_DELIVERY_TYPES, SHIPPING_ERROR_CODES, SHIPPING_RATE_TYPES, SearchApi, type SearchCategory, type SearchProduct, type SentResult, type SeoMetadata$3 as SeoMetadata, type ServerComputedOrderAmounts, type SetQuantitiesRequest, type SetQuantitiesResponse, type ShipmentStatus, ShippingApi, type ShippingCalculationRequest, type ShippingConditionType, type ShippingDeliveryType, type ShippingOption, type ShippingQuoteChangedDetails, type ShippingRate, type ShippingRateType, ShippingServerApi, type ShippingStatus, type ShippingZone, type SingleEntityApiFunction, type StaleQuantity, type Store, type StoreByDomainInfo, type StoreConfig, type StoreConfigurationInfo, type StoreEmailBrandingSettings, type StoreMenu, type StoreMenuItem, type PaymentMethod as StorePaymentMethod, type StoreSettings, type StoreStatus, type StoreWithRelations, type StorefrontMetafield, type StorefrontMetafields, type StorefrontMetaobjectEntry, StoresApi, type SubmitReviewInvitationPayload, THEME_HEX_COLOR, type ThemeDisplayItem, type ThemeMigration, type ThemeMigrationReport, type ThemeMigrationStep, type ThemeSchema, type ThemeSchemaGroup, type ThemeSchemaItem, type ThemeSetting, type ThemeSettingType, type ThemeSettingsOf, type ThemeValue, type ThemeValueError, type ThemeValues, type ThemeVisibleIf, ThemesApi, type Timestamp, type TocItem, type TokenStorage, UNAVAILABLE_STATES, type UnavailableState, type UpdateAddressDto, type UpdateBlogCategory, type UpdateBlogComment, type UpdateBlogPost, type UpdateBlogSettings, type UpdateBlogTag, type UpdateCartItemRequest, type UpdateCategory, type UpdateContentPage, type UpdateEmbeddedScript, type UpdateOrder, type UpdateOrderItem, type UpdateProduct, type UpdateProductReview, type UpdateProductReviewReply, type UpdateProductVariant, type UpdatePromotion, UpdatePromotionSchema, type UpdateStore, type UpdateStoreConfig, type UpdateStoreSettings, type UpdateVariantOption, type UpdateVariantOptionValue, type UpsertCustomerForAuthPayload, type UrlRedirect, VALIDATION_KEYS, type ValidatePromotionCodeRequest, type ValidatePromotionCodeResponse, type VariantOption, type VariantOptionValue, type VariantStatus, type VerifiedResult, type VerifyOtpPayload, type WithMetafields, type WithSeoMetadata$3 as WithSeoMetadata, allowedCustomerAccess, allowedFileKinds, allowedValuesFor, appliedPromotionSchema, applyThemeMigration, assetBaseUrl, attributeLinkSchema, attributeLinkValueSchema, baseDeleteOptionsSchema, baseDeleteResultSchema, baseQueryParamsSchema, baseTypeOf, blogCategorySchema, blogCommentSchema, blogCommentWithRepliesSchema, blogPostCategorySchema, blogPostSchema, blogPostStatusSchema, blogPostTagSchema, blogPostWithRelationsSchema, blogSettingsSchema, blogTagSchema, buildTransformQuery, categorySchema, categoryTreeSchema, categoryWithChildrenSchema, checkMetaobjectFieldChanges, clientHeaderValue, colorSchema, compareDecimal, contentPageSchema, createAuthAwareHttpClient, createBlogCategorySchema, createBlogCommentSchema, createBlogPostSchema, createBlogSettingsSchema, createBlogTagSchema, createCategorySchema, createContentPageSchema, createEcomwebProxiedSdk, createEcomwebSdk, createEcomwebServerSdk, createEmbeddedScriptSchema, createOrderItemSchema, createOrderSchema, createProductReviewReplySchema, createProductReviewSchema, createProductSchema, createProductVariantSchema, createStoreConfigSchema, createStoreSchema, createStoreSettingsSchema, createVariantOptionSchema, createVariantOptionValueSchema, customerOrderSummarySchema, decimalSchema, deletedAtSchema, dimensionsSchema, emailBrandingSchema, emailBrandingShape, emailSchema, embeddedScriptPlacementSchema, embeddedScriptSchema, ensureSuccess, entryDisplayName, fromObjectPublicUrlToRender, fulfillmentStatusSchema, idSchema, integrationStatusSchema, inventoryStatusSchema, isBlankValue, isBlankValueFor, isEditableStatus, isListType, isMetafieldType, isPublishableStatus, isRuleField, isSafeRegex, isSettingVisible, isUnpublishedStatus, isValidEntryHandle, jsonSchema, legacyOrderStatusSchema, legacyProductStatusSchema, legalLinksSchema, measurementInBaseUnit, messageOutboxStatusSchema, metafieldIdentifier, moneySchema, normalizeDate, normalizeDateTime, normalizeDecimal, normalizeId, onHand, operatorsForField, optionalTimestampSchema, optionalUrlSchema, orderItemSchema, orderSchema, orderStatusSchema, orderWithItemsSchema, paginatedResponseSchema, paginationMetaSchema, paginationSchema, parseMetafieldIdentifier, parseStorageUrl, parseThemeMigration, parseThemeSchema, paymentMethodSchema, paymentStatusSchema, phoneSchema, positionOrderSchema, productReviewFiltersSchema, productReviewReplyFiltersSchema, productReviewReplySchema, productReviewSchema, productReviewStatsSchema, productReviewWithRepliesSchema, productSchema, productStatusSchema, productVariantCombinationEntrySchema, productVariantCombinationSchema, productVariantSchema, productVariantWithCombinationsSchema, productWithReviewStatsSchema, productWithVariantsAndReviewStatsSchema, productWithVariantsSchema, resolveAssetUrl, resolveThemeSettings, reviewStatusSchema, rewriteSupabaseUrl, richTextLength, safeParseBaseQueryParams, safeParsePaginationMeta, shippingStatusSchema, slugSchema, sortOrderSchema, storeConfigSchema, storeIdSchema, storeSchema, storeSettingsSchema, storeStatusSchema, storeWithRelationsSchema, storefrontAccessAllowed, strictUrlSchema, themeDefaults, themeMajor, themeMigrationSchema, themeSchemaSchema, themeSettings, timestampSchema, toEntryHandle, toMetafieldKey, toObjectUrl, toRenderUrl, tocItemSchema, transformationsEnabled, unavailable, unwrap, unwrapOrNull, updateBlogCategorySchema, updateBlogCommentSchema, updateBlogPostSchema, updateBlogSettingsSchema, updateBlogTagSchema, updateCategorySchema, updateContentPageSchema, updateEmbeddedScriptSchema, updateOrderItemSchema, updateOrderSchema, updateProductReviewReplySchema, updateProductReviewSchema, updateProductSchema, updateProductVariantSchema, updateStoreConfigSchema, updateStoreSchema, updateStoreSettingsSchema, updateVariantOptionSchema, updateVariantOptionValueSchema, urlSchema, uuidSchema, validateMetafieldDefinition, validateMetafieldValue, validateMetaobjectDefinition, validateMetaobjectEntry, validatePaginationMeta, validateRichText, validateThemeValues, validateValidations, valueKindFor, variantOptionSchema, variantOptionValueSchema, variantStatusSchema, withClientHeader };
6162
+ export { ADJUSTABLE_STATES, ADMIN_ORDER_SOURCES, type AddToCartRequest, type Address, AddressesApi, type AdjustQuantitiesRequest, type AdjustableState, type AdminOrderSource, ApiClientError, type ApiError, type ApiResponse, type AppliedPromotion, type AttributeLink, AuthApi, type AuthErrorCode, type AuthIdentity, type AuthResult, type AuthTokens, type AutocompleteParams, type BankAccount, type BaseDeleteOptions, type BaseDeleteResult, type BaseQueryParams, type BatchOrderReviewInvitationsResult, BlogApi, type BlogCategory, type BlogCategoryQueryParams, type BlogComment, type BlogCommentWithReplies, type BlogPost, type BlogPostCategory, type BlogPostCommentsPage, type BlogPostCommentsQuery, type BlogPostQueryParams, type BlogPostStatus, type BlogPostTag, type BlogPostWithRelations, type BlogSearchParams, type BlogSearchResponse, BlogServerApi, type BlogSettings, type BlogTag, type BlogTagQueryParams, CLIENT_HEADER, COLLECTION_RULE_MATRIX, CONDITION_TYPE_LABELS, CartApi, type CartApiItem, type CartApiResponse, CategoriesApi, type Category, type CategoryQueryParams, type CategorySearchResponse, type CategoryTree, type CategoryWithChildren, type ChangeEmailPayload, type ChangeEmailResult, type ChangePasswordPayload, type ChangedResult, type Collection, type CollectionQueryParams, type CollectionRule, type CollectionRuleSet, type CollectionRuleSetCriteria, type CollectionSearchCriteria, CollectionsApi, ConditionType, ConditionTypeSchema, type ConditionTypeType, type ContentPage, ContentPagesApi, type CreateAddressDto, type CreateBlogCategory, type CreateBlogComment, type CreateBlogPost, type CreateBlogSettings, type CreateBlogTag, type CreateCategory, type CreateContentPage, type CreateEmbeddedScript, type CreateOrder, type CreateOrderItem, type CreateOrderItemRequest, type CreateOrderRequest, type CreateProduct, type CreateProductReview, type CreateProductReviewReply, type CreateProductVariant, type CreatePromotion, CreatePromotionSchema, type CreateStore, type CreateStoreConfig, type CreateStoreSettings, type CreateVariantOption, type CreateVariantOptionValue, type CurrentIdentity, type Customer, type CustomerAccess, type CustomerOrderFilter, type CustomerOrderSummary, CustomersApi, DEFAULT_BUCKET, DISCOUNT_METHOD_LABELS, type DeleteApiFunction, type DeletedAt, DiscountMethod, DiscountMethodSchema, type DiscountMethodType, EMAIL_COLOR_PATTERN, EMAIL_PALETTE_DEFAULTS, ENTRY_HANDLE_PATTERN, type EcomwebProxiedSdkOptions, type EcomwebSdk, type EcomwebSdkOptions, type EcomwebServerSdk, type EcomwebServerSdkOptions, type EmbeddedScript, type EmbeddedScriptPlacement, type EngineResult, FILTERABLE_TYPES, type FileKind, type FulfillmentStatus, type GoogleAuthUrl, type GuestOrderLookupParams, type IHttpClient, INVENTORY_ADJUSTMENT_REASONS, INVENTORY_ERROR_CODES, INVENTORY_POLICIES, INVENTORY_STATES, INVENTORY_STATUS_LABELS, type Id, type ImageFormat, type ImageTransformOptions, type InitiatePaymentResult, type InsufficientInventoryItem, type IntegrationStatus, type InventoryActor, type InventoryAdjustmentReason, type InventoryErrorCode, type InventoryHistoryEntry, type InventoryImportResponse, type InventoryLevelRow, type InventoryLocation, type InventoryPolicy, type InventoryQuantities, type InventoryState, InventoryStatus, KNOWN_PAYMENT_METHODS, LEGACY_STATUS_MIGRATION_MAP, LEVEL_PROVINCE, LEVEL_WARD, type LegacyOrderStatus, type LegacyProductStatus, type LinkValue, type LocationArea, type LocationAreaQuery, type LocationAreasResponse, type LoginPayload, MAX_RULES_PER_SET, MAX_RULE_VALUE_ENTRIES, MEASUREMENT_UNITS, MEDIA_TYPES, MERCHANT_ADJUSTMENT_REASONS, METAFIELD_BASE_TYPES, METAFIELD_KEY_PATTERN, METAFIELD_LIMITS, METAFIELD_OWNER_TYPES, METAFIELD_TYPE_GROUPS, METAOBJECT_REFERENCE_TYPES, METAOBJECT_TYPE_PATTERN, type MeasurementType, type MeasurementValue, MemoryTokenStorage, MenusApi, type MerchantAdjustmentReason, type MessageOutboxStatus, type MetafieldBaseType, type MetafieldBound, type MetafieldContext, type MetafieldDefinitionShape, type MetafieldIssue, type MetafieldIssueCode, type MetafieldListType, type MetafieldOwnerType, type MetafieldType, type MetafieldTypeGroup, type MetafieldValidationKey, type MetafieldValidations, type MetafieldWrite, type MetaobjectDefinitionShape, type MetaobjectFieldShape, type MetaobjectListParams, type MetaobjectListResult, MetaobjectsApi, type MoneyValue, type MoveQuantitiesRequest, type MutationApiFunction, OBJECT_PREFIX, ORDER_ACTOR_TYPES, ORDER_EVENT_TYPES, ORDER_SHIPMENT_ERROR_CODES, ORDER_SOURCES, type OptionalTimestamp, type Order, type OrderActorType, type OrderCommentMutationResult, type OrderCreatedBy, type OrderEventType, type OrderItem, type PaymentMethod$1 as OrderPaymentMethod, type OrderReviewInvitationSummary, type OrderShipmentEvent, type OrderShipmentSummary, type OrderSource, type OrderStatus, type OrderTimelineActor, type OrderTimelineComment, type OrderTimelineCommentAuthor, type OrderTimelineEntry, type OrderTimelineEvent, type OrderTimelineResponse, type OrderWithItems, OrdersApi, PAGINATION_DEFAULTS, PRIVATE_REFERENCE_TYPES, PRODUCT_STATUS_LABELS, PROMOTION_MODE_COLORS, PROMOTION_MODE_LABELS, PROMOTION_STATUS_COLORS, PROMOTION_STATUS_LABELS, PROMOTION_TYPE_COLORS, PROMOTION_TYPE_LABELS, type PaginatedApiFunction, type PaginatedPromotionsResponse, PaginatedPromotionsResponseSchema, type PaginatedResponse, type PaginatedReviewsResponse, type PaginationMeta, type PasswordPolicy, type PaymentCredentialStatus, type PaymentMethod$1 as PaymentMethod, PaymentMethodsApi, type PaymentStateResult, type PaymentStatus, PaymentsApi, type Product, type ProductDetail, type ProductImage, type ProductQueryParams, type ProductReview, type ProductReviewFilters, type ProductReviewReply, type ProductReviewReplyFilters, type ProductReviewStats, type ProductReviewWithReplies, type ProductSearchParams, type ProductSearchResponse, type ProductService, ProductStatus, type ProductVariant, type ProductVariantCombination, type ProductVariantCombinationEntry, type ProductVariantWithCombinations, type ProductVideo, type ProductWithReviewStats, type ProductWithVariants, ProductsApi, type Promotion, type PromotionData, PromotionMode, PromotionModeSchema, type PromotionModeType, type PromotionQueryParams, PromotionQueryParamsSchema, PromotionSchema, type PromotionStatistics, PromotionStatisticsSchema, PromotionStatus, PromotionStatusSchema, type PromotionStatusType, type PromotionSuggestion, type PromotionSuggestionsResponse, PromotionType, PromotionTypeSchema, type PromotionTypeType, type PromotionWithDiscount, PromotionWithDiscountSchema, PromotionsApi, PromotionsServerApi, type PublicAuthConfig, type PublishedStoreTheme, type QuantitiesResponse, RENDER_PREFIX, RESOURCE_REFERENCE_TYPES, RULE_FIELDS, type RatingValue, RedirectsApi, type RegisterPayload, type RegisterResult, type RequestOptions, type ResetPasswordPayload, type ResetResult, type ResizeMode, type ResolvedAsset, type ResolvedBlogPostRef, type ResolvedCollectionRef, type ResolvedImage, type ResolvedMetaobjectRef, type ResolvedMetaobjectStub, type ResolvedPageRef, type ResolvedProductRef, type ResolvedVariantRef, type ReviewInvitationPublicData, type ReviewStatus, ReviewsApi, ReviewsServerApi, type RichTextBlock, type RichTextHeading, type RichTextInline, type RichTextLink, type RichTextList, type RichTextListItem, type RichTextNode, type RichTextParagraph, type RichTextRoot, type RichTextText, type RuleField, type RuleFieldSpec, type RuleOperator, type RuleOperatorSpec, type RuleValueKind, SDK_CLIENT_TOKEN, SDK_VERSION, SHIPMENT_STATUSES, SHIPPING_CONDITION_TYPES, SHIPPING_DELIVERY_TYPES, SHIPPING_ERROR_CODES, SHIPPING_RATE_TYPES, SearchApi, type SearchCategory, type SearchProduct, type SentResult, type SeoMetadata$3 as SeoMetadata, type ServerComputedOrderAmounts, type SetQuantitiesRequest, type SetQuantitiesResponse, type ShipmentStatus, ShippingApi, type ShippingCalculationRequest, type ShippingConditionType, type ShippingDeliveryType, type ShippingOption, type ShippingQuoteChangedDetails, type ShippingRate, type ShippingRateType, ShippingServerApi, type ShippingStatus, type ShippingZone, type SingleEntityApiFunction, type StaleQuantity, type Store, type StoreByDomainInfo, type StoreConfig, type StoreConfigurationInfo, type StoreEmailBrandingSettings, type StoreMenu, type StoreMenuItem, type PaymentMethod as StorePaymentMethod, type StoreSettings, type StoreStatus, type StoreWithRelations, type StorefrontMetafield, type StorefrontMetafields, type StorefrontMetaobjectEntry, StoresApi, type SubmitReviewInvitationPayload, THEME_HEX_COLOR, type ThemeDisplayItem, type ThemeMigration, type ThemeMigrationReport, type ThemeMigrationStep, type ThemeSchema, type ThemeSchemaGroup, type ThemeSchemaItem, type ThemeSetting, type ThemeSettingType, type ThemeSettingsOf, type ThemeValue, type ThemeValueError, type ThemeValues, type ThemeVisibleIf, ThemesApi, type Timestamp, type TocItem, type TokenStorage, UNAVAILABLE_STATES, type UnavailableState, type UpdateAddressDto, type UpdateBlogCategory, type UpdateBlogComment, type UpdateBlogPost, type UpdateBlogSettings, type UpdateBlogTag, type UpdateCartItemRequest, type UpdateCategory, type UpdateContentPage, type UpdateEmbeddedScript, type UpdateOrder, type UpdateOrderItem, type UpdateProduct, type UpdateProductReview, type UpdateProductReviewReply, type UpdateProductVariant, type UpdatePromotion, UpdatePromotionSchema, type UpdateStore, type UpdateStoreConfig, type UpdateStoreSettings, type UpdateVariantOption, type UpdateVariantOptionValue, type UpsertCustomerForAuthPayload, type UrlRedirect, VALIDATION_KEYS, type ValidatePromotionCodeRequest, type ValidatePromotionCodeResponse, type VariantOption, type VariantOptionValue, type VariantStatus, type VerifiedResult, type VerifyOtpPayload, type WithMetafields, type WithSeoMetadata$3 as WithSeoMetadata, allowedCustomerAccess, allowedFileKinds, allowedValuesFor, appliedPromotionSchema, applyThemeMigration, assetBaseUrl, attributeLinkSchema, attributeLinkValueSchema, baseDeleteOptionsSchema, baseDeleteResultSchema, baseQueryParamsSchema, baseTypeOf, blogCategorySchema, blogCommentSchema, blogCommentWithRepliesSchema, blogPostCategorySchema, blogPostSchema, blogPostStatusSchema, blogPostTagSchema, blogPostWithRelationsSchema, blogSettingsSchema, blogTagSchema, buildTransformQuery, categorySchema, categoryTreeSchema, categoryWithChildrenSchema, checkMetaobjectFieldChanges, clientHeaderValue, colorSchema, compareDecimal, contentPageSchema, createAuthAwareHttpClient, createBlogCategorySchema, createBlogCommentSchema, createBlogPostSchema, createBlogSettingsSchema, createBlogTagSchema, createCategorySchema, createContentPageSchema, createEcomwebProxiedSdk, createEcomwebSdk, createEcomwebServerSdk, createEmbeddedScriptSchema, createOrderItemSchema, createOrderSchema, createProductReviewReplySchema, createProductReviewSchema, createProductSchema, createProductVariantSchema, createStoreConfigSchema, createStoreSchema, createStoreSettingsSchema, createVariantOptionSchema, createVariantOptionValueSchema, customerOrderSummarySchema, decimalSchema, deletedAtSchema, dimensionsSchema, emailBrandingSchema, emailBrandingShape, emailSchema, embeddedScriptPlacementSchema, embeddedScriptSchema, ensureSuccess, entryDisplayName, fromObjectPublicUrlToRender, fulfillmentStatusSchema, idSchema, integrationStatusSchema, inventoryStatusSchema, isBlankValue, isBlankValueFor, isEditableStatus, isListType, isMetafieldType, isPublishableStatus, isRuleField, isSafeRegex, isSettingVisible, isUnpublishedStatus, isValidEntryHandle, jsonSchema, legacyOrderStatusSchema, legacyProductStatusSchema, legalLinksSchema, measurementInBaseUnit, messageOutboxStatusSchema, metafieldIdentifier, moneySchema, normalizeDate, normalizeDateTime, normalizeDecimal, normalizeId, onHand, operatorsForField, optionalTimestampSchema, optionalUrlSchema, orderItemSchema, orderSchema, orderStatusSchema, orderWithItemsSchema, paginatedResponseSchema, paginationMetaSchema, paginationSchema, parseMetafieldIdentifier, parseStorageUrl, parseThemeMigration, parseThemeSchema, paymentMethodSchema, paymentStatusSchema, phoneSchema, positionOrderSchema, productReviewFiltersSchema, productReviewReplyFiltersSchema, productReviewReplySchema, productReviewSchema, productReviewStatsSchema, productReviewWithRepliesSchema, productSchema, productStatusSchema, productVariantCombinationEntrySchema, productVariantCombinationSchema, productVariantSchema, productVariantWithCombinationsSchema, productWithReviewStatsSchema, productWithVariantsAndReviewStatsSchema, productWithVariantsSchema, resolveAssetUrl, resolveThemeSettings, reviewStatusSchema, rewriteSupabaseUrl, richTextLength, safeParseBaseQueryParams, safeParsePaginationMeta, shippingStatusSchema, slugSchema, sortOrderSchema, storeConfigSchema, storeIdSchema, storeSchema, storeSettingsSchema, storeStatusSchema, storeWithRelationsSchema, storefrontAccessAllowed, strictUrlSchema, themeDefaults, themeMajor, themeMigrationSchema, themeSchemaSchema, themeSettings, timestampSchema, toEntryHandle, toMetafieldKey, toObjectUrl, toRenderUrl, tocItemSchema, transformationsEnabled, unavailable, unwrap, unwrapOrNull, updateBlogCategorySchema, updateBlogCommentSchema, updateBlogPostSchema, updateBlogSettingsSchema, updateBlogTagSchema, updateCategorySchema, updateContentPageSchema, updateEmbeddedScriptSchema, updateOrderItemSchema, updateOrderSchema, updateProductReviewReplySchema, updateProductReviewSchema, updateProductSchema, updateProductVariantSchema, updateStoreConfigSchema, updateStoreSchema, updateStoreSettingsSchema, updateVariantOptionSchema, updateVariantOptionValueSchema, urlSchema, uuidSchema, validateMetafieldDefinition, validateMetafieldValue, validateMetaobjectDefinition, validateMetaobjectEntry, validatePaginationMeta, validateRichText, validateThemeValues, validateValidations, valueKindFor, variantOptionSchema, variantOptionValueSchema, variantStatusSchema, withClientHeader };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/core/client-info.ts
2
- var SDK_VERSION = true ? "0.15.0" : "dev";
2
+ var SDK_VERSION = true ? "0.16.0" : "dev";
3
3
  var CLIENT_HEADER = "X-Ecomweb-Client";
4
4
  var SDK_CLIENT_TOKEN = `@ecomweb/sdk/${SDK_VERSION}`;
5
5
  function clientHeaderValue(clientInfo) {
@@ -3366,30 +3366,63 @@ var BlogApi = class {
3366
3366
  return unwrap(res);
3367
3367
  }
3368
3368
  /**
3369
- * Lists the approved comments of a post, as an anonymous visitor.
3369
+ * Lists the approved comments of a post, as an anonymous visitor. Returns at
3370
+ * most 100 per call, oldest first unless `sort_order` is `desc`; use
3371
+ * {@link BlogApi.getPostCommentsPage} for the total.
3370
3372
  *
3371
3373
  * @param storeRef - the store's ref or handle
3372
3374
  * @param postId - the post id
3375
+ * @param query - `limit` (at most 100), `offset` and `sort_order`
3373
3376
  * @returns The comments; throws {@link ApiClientError} when the API answers with an error
3374
3377
  */
3375
- async getPostComments(storeRef, postId) {
3376
- const res = await this.publicHttp.get(
3377
- `/storefront/stores/${storeRef}/blog/posts/${postId}/comments`
3378
- );
3379
- return unwrap(res);
3378
+ async getPostComments(storeRef, postId, query = {}) {
3379
+ return unwrap(await this.fetchComments(this.publicHttp, storeRef, postId, query));
3380
3380
  }
3381
3381
  /**
3382
- * Lists the approved comments of a post, sending the signed-in customer's credentials.
3382
+ * Lists the approved comments of a post, sending the signed-in customer's
3383
+ * credentials, so that customer's own comments still waiting for approval
3384
+ * are included. Paging as in {@link BlogApi.getPostComments}.
3383
3385
  *
3384
3386
  * @param storeRef - the store's ref or handle
3385
3387
  * @param postId - the post id
3388
+ * @param query - `limit` (at most 100), `offset` and `sort_order`
3386
3389
  * @returns The comments; throws {@link ApiClientError} when the API answers with an error
3387
3390
  */
3388
- async getPostCommentsAuth(storeRef, postId) {
3389
- const res = await this.authHttp.get(
3390
- `/storefront/stores/${storeRef}/blog/posts/${postId}/comments`
3391
+ async getPostCommentsAuth(storeRef, postId, query = {}) {
3392
+ return unwrap(await this.fetchComments(this.authHttp, storeRef, postId, query));
3393
+ }
3394
+ /**
3395
+ * One page of a post's comments with the total across all pages, for
3396
+ * "load more" or a comment count. Set `asCustomer` to include the signed-in
3397
+ * customer's own pending comments, as {@link BlogApi.getPostCommentsAuth} does.
3398
+ *
3399
+ * @param storeRef - the store's ref or handle
3400
+ * @param postId - the post id
3401
+ * @param query - `limit` (at most 100), `offset` and `sort_order`
3402
+ * @param options - `asCustomer` sends the signed-in customer's credentials
3403
+ * @returns The page and the total (`null` when the HTTP client does not pass response headers on); throws {@link ApiClientError} when the API answers with an error
3404
+ */
3405
+ async getPostCommentsPage(storeRef, postId, query = {}, options = {}) {
3406
+ const res = await this.fetchComments(
3407
+ options.asCustomer ? this.authHttp : this.publicHttp,
3408
+ storeRef,
3409
+ postId,
3410
+ query
3411
+ );
3412
+ const items = unwrap(res);
3413
+ const header = res.headers?.["x-total-count"];
3414
+ const total = header != null && header !== "" ? Number(header) : NaN;
3415
+ return { items, total: Number.isFinite(total) ? total : null };
3416
+ }
3417
+ fetchComments(http, storeRef, postId, query) {
3418
+ const qsStr = stringify({
3419
+ limit: query.limit,
3420
+ offset: query.offset,
3421
+ sort_order: query.sort_order
3422
+ });
3423
+ return http.get(
3424
+ `/storefront/stores/${storeRef}/blog/posts/${postId}/comments${qsStr ? "?" + qsStr : ""}`
3391
3425
  );
3392
- return unwrap(res);
3393
3426
  }
3394
3427
  };
3395
3428
  var BlogServerApi = class extends BlogApi {