import { Event, Store } from "effector"; import { AbstractOp, GraphQLOpts, RequestResponseError } from "../request"; import { AnswerCreate, AnswerModify, FileNoFallbackFragment, ReviewDimensionFragment, ReviewDimensionSetFragment, ReviewSettingsFragment, SearchQuestionsSortBy, SearchReviewsSortBy, StorefrontCustomerVote, StorefrontProductQuestionCreate, StorefrontProductQuestionModify, StorefrontProductReviewCreate, StorefrontProductReviewModify } from "../graphql/types"; import { Dict } from "../commonTypes"; import { ScoreValue } from "../rdsToInitialScores"; import { ResultErrorCode } from "../genericFile"; interface SearchPage { count: number; items: (T | null)[] | null; } interface NullPage { count: number; last_key: string; items: (T | null)[] | null; } interface Page { last_key: string; items: T[]; } interface ProductTypeReq { id: string; review_dimension_set: ReviewDimensionSetFragment | null; } interface QuestionTypeReq { id: string; text: string; answers: ({ id: string; text: string; } | null)[] | null; } interface ReviewTypeReq { id: string; recommended: StorefrontCustomerVote; title: string; text: string; scores: { review_dimension: { id: string; name: string; } | null; score: number; }[]; image_files: ({ id: string; public_url: string; } | null)[] | null; } declare type LoadResponse = { products: ProductType[] | null; reviews: SearchPage | null; questions: SearchPage | null; ownReviews: Page | null; ownQuestions: Page | null; images: NullPage | null; }; interface ReviewImageFile { uuid: string; id: string; preview: string; public_url: string; status: ResultErrorCode | "ok" | "uploading"; } interface ReviewImageFileUpdate { uuid: string; id?: string; preview?: string; public_url?: string; status?: ResultErrorCode | "ok" | "uploading"; } export interface ProductConfig { readonly graphql: { readonly loadProductQuery: AbstractOp, { shopID: string; productID: string; customerID: string; }>; readonly loadProductNoCustomerQuery: AbstractOp<{ products: ProductType[] | null; reviews: SearchPage | null; questions: SearchPage | null; images: NullPage | null; }, { shopID: string; productID: string; }>; readonly createReviewMutation: AbstractOp<{ reviews: ReviewType[] | null; }, { shopID: string; data: StorefrontProductReviewCreate; }>; readonly modifyReviewMutation: AbstractOp<{ reviews: ReviewType[] | null; }, { shopID: string; reviewID: string; data: StorefrontProductReviewModify; }>; readonly createQuestionMutation: AbstractOp<{ questions: QuestionType[] | null; }, { shopID: string; data: StorefrontProductQuestionCreate; }>; readonly modifyQuestionMutation: AbstractOp<{ questions: QuestionType[] | null; }, { shopID: string; questionID: string; data: StorefrontProductQuestionModify; }>; readonly createQuestionAnswerMutation: AbstractOp<{ questionAnswers: { id: string; }[] | null; }, { shopID: string; questionID: string; data: AnswerCreate; }>; readonly modifyQuestionAnswerMutation: AbstractOp<{ questionAnswers: { id: string; }[] | null; }, { shopID: string; questionID: string; questionAnswerID: string; data: AnswerModify; }>; readonly deleteReviewMutation: AbstractOp<{ reviews: boolean | null; }, { shopID: string; reviewID: string; }>; readonly deleteQuestionMutation: AbstractOp<{ questions: boolean | null; }, { shopID: string; questionID: string; }>; readonly deleteQuestionAnswerMutation: AbstractOp<{ questionAnswers: boolean | null; }, { shopID: string; questionAnswerID: string; }>; readonly voteReviewMutation: AbstractOp<{ reviews: boolean | null; }, { shopID: string; reviewID: string; y: boolean; delete?: boolean | null; }>; readonly flagReviewMutation: AbstractOp<{ reviews: boolean | null; }, { shopID: string; reviewID: string; delete?: boolean | null; }>; readonly voteQuestionMutation: AbstractOp<{ questions: boolean | null; }, { shopID: string; questionID: string; y: boolean; delete?: boolean | null; }>; readonly flagQuestionMutation: AbstractOp<{ questions: boolean | null; }, { shopID: string; questionID: string; delete?: boolean | null; }>; readonly voteQuestionAnswerMutation: AbstractOp<{ questionAnswers: boolean | null; }, { shopID: string; questionAnswerID: string; y: boolean; delete?: boolean | null; }>; readonly flagQuestionAnswerMutation: AbstractOp<{ questionAnswers: boolean | null; }, { shopID: string; questionAnswerID: string; delete?: boolean | null; }>; readonly getReviewQuery: AbstractOp<{ reviews: ReviewType[] | null; }, { shopID: string; reviewID: string; }>; readonly getQuestionQuery: AbstractOp<{ questions: QuestionType[] | null; }, { shopID: string; questionID: string; }>; readonly searchReviewsQuery: AbstractOp<{ reviews: SearchPage | null; }, { shopID: string; productID: string; offset: number; limit: number; sortBy: SearchReviewsSortBy; sortDesc: boolean; notCustomerID?: string | null; }>; readonly searchQuestionsQuery: AbstractOp<{ questions: SearchPage | null; }, { shopID: string; productID: string; offset: number; limit: number; sortBy: SearchQuestionsSortBy; sortDesc: boolean; notCustomerID?: string | null; }>; }; /** Your shop id. */ readonly shopID: string; /** These graphql options are applied to all "request" api calls product module does. */ readonly opts?: Readonly>; /** Review dimensions of the shop. */ readonly reviewDimensions: Dict; /** Review settings of the shop. */ readonly reviewSettings: ReviewSettingsFragment; /** A store that represents current auth state. You should pass it in to keep auth state in-sync. */ readonly jwt: Store; /** Current locale. Module will react to its changes. */ readonly locale: Store; } export interface Product { signInRequired: Event; message: Event; load: Event; unexpectedError: Event; product: Store; images: Store | null>; reviewsSortBy: Store; reviewsSortDesc: Store; setReviewsSortBy: Event; setReviewsSortDesc: Event; reviews: Store; questionsSortBy: Store; questionsSortDesc: Store; setQuestionsSortBy: Event; setQuestionsSortDesc: Event; questions: Store; ownReview: Store; ownQuestions: Store; somethingPending: Store; forms: ReturnType; voteReviewYes: Event; voteReviewNo: Event; voteReviewDelete: Event; flagReview: Event; flagReviewDelete: Event; voteQuestionYes: Event; voteQuestionNo: Event; voteQuestionDelete: Event; flagQuestion: Event; flagQuestionDelete: Event; deleteReview: Event; deleteQuestion: Event; deleteQuestionAnswer: Event<[string, string]>; voteQuestionAnswerYes: Event<[string, string]>; voteQuestionAnswerNo: Event<[string, string]>; voteQuestionAnswerDelete: Event<[string, string]>; flagQuestionAnswer: Event<[string, string]>; flagQuestionAnswerDelete: Event<[string, string]>; totalReviews: Store; totalQuestions: Store; canLoadMoreReviews: Store; canLoadMoreQuestions: Store; loadMoreReviews: Event; loadMoreQuestions: Event; } declare function createProductForms(everythingIdle: Store): { questionForm: import("../effector/form").Form<{ text: import("../effector/form").StringField<[import("../effector/validator").Validator<"invalid_non_empty">, import("../effector/validator").Validator<"max_length_exceeded">], string>; }>; showQuestionForm: Event; hideQuestionForm: Event; isQuestionFormVisible: Store; questionAnswerForm: import("../effector/form").Form<{ text: import("../effector/form").StringField<[import("../effector/validator").Validator<"invalid_non_empty">, import("../effector/validator").Validator<"max_length_exceeded">], string>; }>; showQuestionAnswerForm: Event<[string, string]>; hideQuestionAnswerForm: Event; isQuestionAnswerFormVisible: Store<[string, string] | null>; reviewForm: import("../effector/form").Form<{ title: import("../effector/form").StringField<[import("../effector/validator").Validator<"invalid_non_empty">, import("../effector/validator").Validator<"max_length_exceeded">], string>; text: import("../effector/form").StringField<[import("../effector/validator").Validator<"invalid_non_empty">, import("../effector/validator").Validator<"max_length_exceeded">], string>; }>; uploadReviewImageFile: Event; removeReviewImageFile: Event; updateReviewImageFile: Event; appendReviewImageFile: Event; reviewImageFiles: Store; setReviewScores: Event; reviewScores: Store; setReviewRecommended: Event; reviewRecommended: Store; isReviewFormVisible: Store; toggleReviewFormVisibility: Event; }; export declare type MessageType = "review_voted_yes" | "review_voted_no" | "review_vote_deleted" | "review_flagged" | "review_unflagged" | "review_created" | "review_modified" | "review_deleted" | "question_vote_deleted" | "question_voted_yes" | "question_voted_no" | "question_unflagged" | "question_flagged" | "question_answer_vote_deleted" | "question_answer_voted_yes" | "question_answer_voted_no" | "question_answer_unflagged" | "question_answer_flagged" | "question_created" | "question_modified" | "question_deleted" | "question_answer_modified" | "question_answer_created" | "question_answer_deleted"; export declare function createProduct(config: ProductConfig): Product; export {};