Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 | 1x 1x 1x 1x 1x 1x 1x 1x 29x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 29x 4x 1x 3x 1x 1x 2x 29x 2x 1x 1x 29x 15x 15x 29x 15x 29x 20x 20x 2x 2x 2x 20x 20x 11x 11x 20x 29x 1x 29x 1x 29x 1x 29x 1x 29x 1x 29x 1x 29x 29x 29x 29x 29x 29x 29x 29x 29x 29x 3x 29x 1x 29x 1x 29x 1x 29x 1x 29x 1x 29x 1x 29x 1x 29x 1x 29x 1x 29x 29x 29x 29x 1x 29x 1x 29x 29x 29x 1x | import { Cart } from './cart.js';
import { Category } from './category.js';
import { Company } from './company.js';
import { DomainInvitation } from './domain_invitation.js';
import { DomainTag } from './domain_tag.js';
import { EnrolledDomain } from './enrolled_domain.js';
import { Entity } from '../entity.js';
import type {
AgentTokenAnalyticsTimeseries,
DomainAnalyticsResponse,
} from './agent_token_analytics.js';
import { MerchiFile } from './file.js';
import { InternalTag } from './internal_tag.js';
import { Invoice } from './invoice.js';
import { Job } from './job.js';
import { User } from './user.js';
import { Notification } from './notification.js';
import { Product } from './product.js';
import { Reminder } from './reminder.js';
import { Session } from './session.js';
import { SupplyDomain } from './supply_domain.js';
import { DomainChatSettings } from './domain_chat_settings.js';
import { Theme } from './theme.js';
import { DomainType } from '../constants/domain_types.js';
import { ShipmentMethod } from './shipment_method.js';
// Sentinel for passthrough JSON columns. Must not be `Object` (decorator rejects it).
const jsonPropertyType = class {};
import { RequestOptions } from '../request.js';
export type StorefrontChangeRequestStatus =
| 'created'
| 'running'
| 'preview_ready'
| 'approved'
| 'rejected';
export interface StorefrontChecksSummary {
overall?: 'passing' | 'failing' | 'pending' | 'unknown';
statusState?: string;
counts?: {
total?: number;
passed?: number;
failed?: number;
pending?: number;
neutral?: number;
};
updatedAt?: string;
}
export interface StorefrontExecutionEvent {
timestamp: string;
stage: string;
level?: 'info' | 'error' | string;
message: string;
metadata?: Record<string, any>;
}
export interface StorefrontRequestContextImage {
name: string;
mimeType?: string | null;
dataUrl: string;
}
export interface StorefrontV2ChangeRequestPayload {
prompt: string;
contextFilePaths?: string[];
contextImages?: StorefrontRequestContextImage[];
branchName?: string;
startNewBranch?: boolean;
clarificationAnswers?: Record<string, string | string[]>;
generationBriefSummary?: string;
generationBoilerplateFit?: string;
clarificationSkipped?: boolean;
}
export interface StorefrontV2ChangeRequestRunPayload {
status?: 'running' | 'preview_ready';
branchName?: string;
commitSha?: string;
previewUrl?: string;
summary?: string;
pullRequestNumber?: number;
checksSummary?: StorefrontChecksSummary;
checksUpdatedAt?: string;
errorDetails?: string;
}
export interface StorefrontV2ChangeRequestRejectPayload {
errorDetails?: string;
}
export interface StorefrontV2ChangeRequest {
id: number;
domainId: number;
storefrontV2Id: number;
requestedByUserId?: number | null;
status: StorefrontChangeRequestStatus;
prompt: string;
branchName?: string | null;
commitSha?: string | null;
pullRequestNumber?: number | null;
previewUrl?: string | null;
summary?: string | null;
checksSummary?: StorefrontChecksSummary | null;
checksUpdatedAt?: string | null;
errorDetails?: string | null;
executionEvents?: StorefrontExecutionEvent[] | null;
creationDate?: string | null;
updatedAt?: string | null;
}
export interface StorefrontGoogleIntegrations {
ga4MeasurementId?: string;
ga4PropertyId?: string;
googleAdsId?: string;
googleAdsConversionLabel?: string;
googleAdsQuoteConversionLabel?: string;
}
export type StorefrontV2InfrastructureMode = 'platform' | 'byo';
/** Public BYO connection status (never includes encrypted tokens). */
export interface StorefrontV2ByoStatus {
infrastructureMode: StorefrontV2InfrastructureMode;
githubAppConfigured: boolean;
vercelOauthConfigured: boolean;
githubConnected: boolean;
vercelConnected: boolean;
githubAccountLogin?: string | null;
githubInstallationId?: string | null;
vercelTeamId?: string | null;
}
export interface StorefrontV2Config {
id?: number;
domainId?: number;
status?: 'provisioning' | 'ready' | 'failed' | 'archived' | string;
starterTemplate?: string | null;
urlStructure?: string | null;
defaultBranch?: string | null;
activePreviewBranchName?: string | null;
activePreviewStartedAt?: string | null;
activePreviewLastRequestId?: number | null;
repoProvider?: string | null;
repoOwner?: string | null;
repoName?: string | null;
vercelProjectId?: string | null;
vercelTeamId?: string | null;
infrastructureMode?: StorefrontV2InfrastructureMode | string | null;
githubInstallationId?: string | null;
githubAccountLogin?: string | null;
byo?: StorefrontV2ByoStatus | null;
lastSuccessfulCommitSha?: string | null;
googleIntegrations?: StorefrontGoogleIntegrations | null;
approvedStarterTemplates?: string[];
providerMode?: 'real' | 'deterministic' | 'unknown' | string;
isProvisioned?: boolean;
creationDate?: string | null;
updatedAt?: string | null;
}
export interface StorefrontV2GetResponse {
storefrontV2?: StorefrontV2Config;
isProvisioned?: boolean;
provisioned?: boolean;
providerMode?: string;
approvedStarterTemplates?: string[];
}
export interface StorefrontV2ProvisionPayload {
starterTemplate?: string;
urlStructure?: string;
}
export interface StorefrontV2StarterTemplateUrlStructureResult {
starterTemplate: string;
urlStructure: string;
}
export interface StorefrontV2SiteContextInput {
url?: string;
sourceUrl?: string;
}
export interface StorefrontV2GenerationBriefQuestionOption {
id: string;
label: string;
}
export interface StorefrontV2GenerationBriefQuestion {
id: string;
topicId: string;
prompt: string;
type: 'single' | 'multi' | 'text';
options?: StorefrontV2GenerationBriefQuestionOption[];
required?: boolean;
}
export interface StorefrontV2GenerationBriefGapTopic {
id: string;
category: string;
severity: 'high' | 'medium' | 'low' | string;
evidence: string;
suggestedOptions?: string[];
}
export interface StorefrontV2GenerationBrief {
planSummary: string;
boilerplateFit: string;
gapTopics: StorefrontV2GenerationBriefGapTopic[];
questions: StorefrontV2GenerationBriefQuestion[];
questionCount: number;
}
export interface StorefrontV2GenerationBriefPayload {
siteContext: StorefrontV2SiteContext;
urlStructure?: string;
starterTemplate?: string;
}
export interface StorefrontV2ResetResult {
status: string;
isProvisioned: boolean;
providerMode?: 'real' | 'deterministic' | 'unknown' | string;
approvedStarterTemplates?: string[];
}
export interface StorefrontV2RepositoryTreeEntry {
name: string;
path: string;
type: 'directory' | 'file';
}
export interface StorefrontV2RepositoryTree {
path: string;
ref: string;
entries: StorefrontV2RepositoryTreeEntry[];
}
export interface StorefrontV2RepositoryBranches {
defaultBranch: string;
activeBranchName?: string | null;
branches: string[];
}
export interface StorefrontV2RepositoryFile {
path: string;
ref: string;
sha?: string;
content: string;
}
export interface StorefrontV2RepositoryFileUpdate {
path: string;
branch: string;
commitSha: string;
}
export interface StorefrontV2RepositoryFileUpdatePayload {
path: string;
content: string;
message?: string;
branch?: string;
}
export interface StorefrontV2Deployment {
id: string;
environment: 'preview' | 'production' | string;
status: string;
commitSha?: string | null;
url?: string | null;
}
export interface StorefrontV2DeploymentLog {
timestamp: string;
level: string;
message: string;
}
export interface StorefrontV2RollbackResult {
status: string;
targetCommitSha: string;
deployment?: {
deploymentId: string;
status?: string;
};
}
export interface StorefrontV2ProductPublishResult {
action: 'deploy' | 'recache' | string;
productName?: string | null;
productId?: number | null;
lastDeployed?: number | null;
status?: string;
productUrl?: string;
deploymentId?: string;
previewUrl?: string;
branchName?: string;
message?: string;
httpStatus?: number;
}
export interface StorefrontV2ProductStatus {
activated: boolean;
outOfSync?: boolean;
lastUpdated?: number | null;
lastDeployed?: number | null;
}
export interface StorefrontV2CategoryPublishResult {
action: 'deploy' | 'recache' | string;
categoryName?: string | null;
status?: string;
categoryUrl?: string;
deploymentId?: string;
previewUrl?: string;
branchName?: string;
message?: string;
httpStatus?: number;
}
export interface StorefrontV2ProductPublishPayload {
productName?: string;
productUrl?: string;
productId?: number;
branchName?: string;
}
export interface StorefrontV2CategoryPublishPayload {
categoryName?: string;
categoryUrl?: string;
branchName?: string;
}
export interface StorefrontV2EmulationRoute {
name?: string;
path: string;
pageType?: string;
targetFile?: string;
}
export interface StorefrontV2EmulationSpec {
routeContract?: {
recommendedUrlStructure?: string;
dynamicParams?: string[];
routes?: StorefrontV2EmulationRoute[];
};
componentMapping?: Array<{
section?: string;
sourceSignals?: string[];
boilerplateTargets?: string[];
implementationNotes?: string;
}>;
}
export interface StorefrontV2PageAnalysisItem {
url: string;
title?: string | null;
description?: string | null;
h1?: string | null;
headings?: string[];
contentPreview?: string | null;
}
export interface StorefrontV2SiteContext {
sourceUrl: string;
style?: {
title?: string | null;
description?: string | null;
colors?: string[];
fontFamilies?: string[];
} | null;
sitemap?: string[];
navigation?: Array<{label?: string; url: string}>;
categories?: string[];
products?: string[];
scrapedCategories?: string[];
scrapedProducts?: string[];
domainCatalog?: {
categories?: Array<{id?: number; name?: string; slug?: string}>;
products?: Array<{
id?: number;
name?: string;
slug?: string;
categories?: Array<{id?: number; name?: string; slug?: string}>;
}>;
} | null;
catalogMapping?: {
categories?: Array<{
domainCategoryId?: number;
domainCategoryName?: string;
domainCategorySlug?: string;
scrapedCategoryLabel?: string | null;
matchedScrapedUrl?: string | null;
matchSource?: string | null;
}>;
products?: Array<{
domainProductId?: number;
domainProductName?: string;
domainProductSlug?: string;
domainCategoryIds?: number[];
domainCategoryNames?: string[];
scrapedProductLabel?: string | null;
matchedScrapedUrl?: string | null;
matchSource?: string | null;
}>;
} | null;
tracking?: Array<{provider?: string; value?: string}>;
wireframe?: string[];
stylesheets?: Array<{url: string; content: string}>;
pageAnalysis?: StorefrontV2PageAnalysisItem[];
emulationSpec?: StorefrontV2EmulationSpec | null;
analysisMarkdown?: string | null;
analysisFilePath?: string | null;
analysisJsonFilePath?: string | null;
analysisScreenshotPaths?: string[];
analysisScreenshots?: Array<{
name?: string;
pageUrl?: string;
path?: string;
viewport?: string;
width?: number;
height?: number;
screenshotUrl?: string;
mimeType?: string;
dataUrl?: string;
}>;
analysisBranch?: string | null;
analysisCommitSha?: string | null;
analysisJsonCommitSha?: string | null;
}
export class Domain extends Entity {
protected static resourceName = 'domains';
protected static singularName = 'domain';
protected static pluralName = 'domains';
@Domain.property({type: Date})
public archived?: Date | null;
@Domain.property()
public id?: number;
@Domain.property()
public domain?: string;
@Domain.property()
public country?: string;
@Domain.property()
public currency?: string;
@Domain.property()
public callToActions?: string;
@Domain.property()
public callToActionDetails?: any[];
@Domain.property()
public isMaster?: boolean;
@Domain.property()
public deploymentOnline?: boolean;
@Domain.property()
public deploymentInProgress?: boolean;
@Domain.property()
public deploymentSucceeded?: boolean;
@Domain.property()
public deploymentMessage?: string;
@Domain.property()
public deploymentKey?: string;
@Domain.property()
public internalUseNotes?: string;
@Domain.property()
public internalUseAiContext?: string;
@Domain.property()
public aiContext?: string;
@Domain.property()
public domainType?: DomainType;
@Domain.property()
public subDomain?: string;
@Domain.property()
public emailDomain?: string;
@Domain.property()
public smsName?: string;
@Domain.property()
public whatsappPhoneNumberId?: string;
@Domain.property()
public showDomainPublicly?: boolean;
@Domain.property()
public publicAccessRestricted?: boolean;
@Domain.property()
public showDomainToAccessibleEntitiesOnly?: boolean;
@Domain.property()
public enableEmailNotifications?: boolean;
@Domain.property()
public enableSmsNotifications?: boolean;
@Domain.property()
public enableWhatsappNotifications?: boolean;
@Domain.property()
public mailgunRecords?: any[];
@Domain.property()
public enableNotifications?: boolean;
@Domain.property()
public assignToAgent?: boolean;
@Domain.property({type: jsonPropertyType})
public jobAgentPolicy?: {
toneInstructions?: string;
outreach?: {
clientMessaging?: 'auto' | 'team_draft_only';
sendEmail?: boolean;
sendSms?: boolean;
proactiveChase?: boolean;
};
playbooks?: {
deadlineAsk?: boolean;
emailIntake?: boolean;
drafting?: boolean;
designerAssign?: boolean;
productionTender?: boolean;
shipment?: boolean;
invoice?: boolean;
};
} | null;
@Domain.property({ type: User })
public merchiAgentUser?: User | null;
@Domain.property({type: String})
public trackingCodeGoogleConversion?: string | null;
@Domain.property({type: String})
public trackingCodeGoogleGlobal?: string | null;
@Domain.property({type: String})
public apiSecret?: string | null;
@Domain.property({type: String})
public webflowApiKey?: string | null;
@Domain.property({type: String})
public telegramChatId?: string;
@Domain.property({type: String})
public shopifyShopUrl?: string | null;
@Domain.property()
public shopifyIsActive?: boolean;
@Domain.property({type: String})
public qrShopQrCode?: string | null;
@Domain.property({type: String})
public unltdAiApiOrganizationId?: string;
@Domain.property({type: String})
public unltdAiApiSecretKey?: string;
@Domain.property({type: String})
public scalablePressApiKey?: string;
@Domain.property({type: String})
public googleMerchantApiKey?: string;
@Domain.property({type: String})
public googleMerchantId?: string;
@Domain.property({type: Boolean})
public googleProductReviewsFeedEnabled?: boolean;
@Domain.property({type: String})
public googleProductReviewsFeedToken?: string | null;
@Domain.property({type: String})
public googleProductReviewsFeedUrl?: string | null;
@Domain.property({type: String})
public socialBitchute?: string | null;
@Domain.property({type: String})
public socialDiscord?: string | null;
@Domain.property({type: String})
public socialFacebook?: string | null;
@Domain.property({type: String})
public socialGoogle?: string | null;
@Domain.property({type: String})
public socialInstagram?: string | null;
@Domain.property({type: String})
public socialLinkedin?: string | null;
@Domain.property({type: String})
public socialRumble?: string | null;
@Domain.property({type: String})
public socialTelegram?: string | null;
@Domain.property({type: String})
public socialTiktok?: string | null;
@Domain.property({type: String})
public socialX?: string | null;
@Domain.property({type: String})
public socialYoutube?: string | null;
@Domain.property()
public ownedBy?: Company;
@Domain.property()
public company?: Company;
@Domain.property({type: MerchiFile})
public logo?: MerchiFile | null;
@Domain.property({type: MerchiFile})
public favicon?: MerchiFile | null;
@Domain.property({arrayType: 'ShipmentMethod'})
public shipmentMethods?: ShipmentMethod[];
@Domain.property()
public activeTheme?: Theme;
@Domain.property({arrayType: 'InternalTag'})
public internalTags?: InternalTag[];
@Domain.property({arrayType: 'DomainTag'})
public tags?: DomainTag[];
@Domain.property({arrayType: 'Domain'})
public canSupply?: Domain[];
@Domain.property({arrayType: 'Domain'})
public suppliedBy?: Domain[];
@Domain.property({arrayType: 'User'})
public accessibleClients?: User[];
@Domain.property({arrayType: 'Company'})
public accessibleClientCompanies?: Company[];
@Domain.property({arrayType: 'Session'})
public sessions?: Session[];
@Domain.property({arrayType: 'Category'})
public categories?: Category[];
@Domain.property({arrayType: 'Notification'})
public notifications?: Notification[];
@Domain.property({arrayType: 'Reminder'})
public reminders?: Reminder[];
@Domain.property({arrayType: 'Product'})
public products?: Product[];
@Domain.property({arrayType: 'SupplyDomain'})
public supplyProducts?: SupplyDomain[];
@Domain.property({arrayType: 'Job'})
public jobs?: Job[];
@Domain.property({arrayType: 'User'})
public jobsAssignees?: User[];
@Domain.property({arrayType: 'Cart'})
public carts?: Cart[];
@Domain.property({arrayType: 'EnrolledDomain'})
public enrollments?: EnrolledDomain[];
@Domain.property({arrayType: 'Invoice'})
public invoices?: Invoice[];
@Domain.property({arrayType: 'DomainInvitation'})
public domainInvitations?: DomainInvitation[];
@Domain.property({ type: DomainChatSettings })
public domainChatSettings?: DomainChatSettings | null;
@Domain.property({arrayType: 'Theme'})
public themes?: Theme[];
public defaultTaxType = () => {
if (this.company === undefined) {
throw new Error('company is undefined, did you forget to embed it?');
}
if (this.company.defaultTaxType === undefined) {
const err = 'company.defaultTaxType is undefined, did you forget to' +
' embed it?';
throw new Error(err);
}
return this.company.defaultTaxType;
};
public getActiveTheme = (): Theme => {
if (this.activeTheme === undefined) {
throw new Error('activeTheme is undefined, did you forget to embed it?');
}
return this.activeTheme!;
};
private getDomainId = () => {
Iif (this.id === undefined || this.id === null) {
throw new Error('id is undefined, did you forget to set it?');
}
return this.id;
};
private storefrontV2DomainResource = (suffix = '') => {
return `/domains/${this.getDomainId()}/storefront_v2/${suffix}`;
};
private storefrontV2Request = (
resource: string,
method: 'GET' | 'POST',
payload?: Record<string, any>,
queryParams?: Record<string, string | undefined>
) => {
const query: Array<[string, string]> = [['skip_rights', 'y']];
if (queryParams) {
Object.entries(queryParams).forEach(([key, value]) => {
if (value !== undefined && value !== '') {
query.push([key, value]);
}
});
}
const fetchOptions: RequestOptions = {
method: method,
query: query
};
if (payload !== undefined) {
fetchOptions.body = JSON.stringify(payload);
fetchOptions.headers = {'Content-Type': 'application/json'};
}
return this.merchi.authenticatedFetch(resource, fetchOptions);
};
public getStorefrontV2 = (): Promise<StorefrontV2GetResponse> => {
return this.storefrontV2Request(this.storefrontV2DomainResource(), 'GET');
};
public provisionStorefrontV2 = (
payload?: StorefrontV2ProvisionPayload
): Promise<{storefrontV2: StorefrontV2Config}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('provision/'),
'POST',
payload
);
};
public resolveStarterTemplateUrlStructure = (
payload: {starterTemplate: string}
): Promise<StorefrontV2StarterTemplateUrlStructureResult> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('starter_template/url_structure/'),
'POST',
payload
) as Promise<StorefrontV2StarterTemplateUrlStructureResult>;
};
public extractStorefrontV2SiteContext = (
payload: StorefrontV2SiteContextInput
): Promise<{siteContext: StorefrontV2SiteContext}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('site_context/extract/'),
'POST',
payload
) as Promise<{siteContext: StorefrontV2SiteContext}>;
};
public createStorefrontV2GenerationBrief = (
payload: StorefrontV2GenerationBriefPayload
): Promise<{generationBrief: StorefrontV2GenerationBrief}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('generation_brief/'),
'POST',
payload
) as Promise<{generationBrief: StorefrontV2GenerationBrief}>;
};
public resetStorefrontV2 = (): Promise<StorefrontV2ResetResult> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('reset/'),
'POST'
) as Promise<StorefrontV2ResetResult>;
};
public getStorefrontV2GoogleIntegrations = (): Promise<{
googleIntegrations: StorefrontGoogleIntegrations;
}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('google_integrations/'),
'GET'
) as Promise<{googleIntegrations: StorefrontGoogleIntegrations}>;
};
public saveStorefrontV2GoogleIntegrations = (
payload: StorefrontGoogleIntegrations | {googleIntegrations: StorefrontGoogleIntegrations}
): Promise<{googleIntegrations: StorefrontGoogleIntegrations}> => {
const body =
payload &&
typeof payload === 'object' &&
('googleIntegrations' in payload || 'google_integrations' in payload)
? payload
: {googleIntegrations: payload};
return this.storefrontV2Request(
this.storefrontV2DomainResource('google_integrations/'),
'POST',
body
) as Promise<{googleIntegrations: StorefrontGoogleIntegrations}>;
};
public getStorefrontV2GaStatus = (): Promise<{gaStatus: Record<string, any>}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('ga/status/'),
'GET'
) as Promise<{gaStatus: Record<string, any>}>;
};
public verifyStorefrontV2GaInstallation = (): Promise<{
gaVerification: Record<string, any>;
}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('ga/verify/'),
'POST'
) as Promise<{gaVerification: Record<string, any>}>;
};
public analyzeStorefrontV2Ga = (
payload?: {days?: number}
): Promise<{gaAnalysis: Record<string, any>}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('ga/analyze/'),
'POST',
payload
) as Promise<{gaAnalysis: Record<string, any>}>;
};
public applyStorefrontV2GaRecommendations = (payload: {
recommendationIds: string[];
recommendations?: Array<Record<string, any>>;
narrative?: string;
days?: number;
startNewBranch?: boolean;
branchName?: string;
}): Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('ga/apply/'),
'POST',
payload
) as Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}>;
};
public getStorefrontV2GscStatus = (): Promise<{gscStatus: Record<string, any>}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('gsc/status/'),
'GET'
) as Promise<{gscStatus: Record<string, any>}>;
};
public analyzeStorefrontV2Gsc = (
payload?: {days?: number}
): Promise<{gscAnalysis: Record<string, any>}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('gsc/analyze/'),
'POST',
payload
) as Promise<{gscAnalysis: Record<string, any>}>;
};
public applyStorefrontV2GscRecommendations = (payload: {
recommendationIds: string[];
recommendations?: Array<Record<string, any>>;
narrative?: string;
days?: number;
startNewBranch?: boolean;
branchName?: string;
}): Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('gsc/apply/'),
'POST',
payload
) as Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}>;
};
public createStorefrontChangeRequest = (
payload?: StorefrontV2ChangeRequestPayload
): Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('requests/'),
'POST',
payload
) as Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}>;
};
public getStorefrontChangeRequest = (
requestId: number | string
): Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}> => {
return this.storefrontV2Request(
`/storefront_change_requests/${String(requestId)}/`,
'GET'
) as Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}>;
};
public getStorefrontChangeRequestEvents = (
requestId: number | string
): Promise<{requestId: number; events: StorefrontExecutionEvent[]}> => {
return this.storefrontV2Request(
`/storefront_change_requests/${String(requestId)}/events/`,
'GET'
) as Promise<{requestId: number; events: StorefrontExecutionEvent[]}>;
};
public runStorefrontChangeRequest = (
requestId: number | string,
payload?: StorefrontV2ChangeRequestRunPayload
): Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}> => {
return this.storefrontV2Request(
`/storefront_change_requests/${String(requestId)}/run/`,
'POST',
payload
) as Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}>;
};
public approveStorefrontChangeRequest = (
requestId: number | string,
payload?: Record<string, any>
): Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}> => {
return this.storefrontV2Request(
`/storefront_change_requests/${String(requestId)}/approve/`,
'POST',
payload
) as Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}>;
};
public rejectStorefrontChangeRequest = (
requestId: number | string,
payload?: StorefrontV2ChangeRequestRejectPayload
): Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}> => {
return this.storefrontV2Request(
`/storefront_change_requests/${String(requestId)}/reject/`,
'POST',
payload
) as Promise<{storefrontChangeRequest: StorefrontV2ChangeRequest}>;
};
public getStorefrontV2Deployments = (): Promise<{deployments: StorefrontV2Deployment[]}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('deployments/'),
'GET'
) as Promise<{deployments: StorefrontV2Deployment[]}>;
};
public getStorefrontV2DeploymentLogs = (
deploymentId: number | string
): Promise<{deploymentId: string; logs: StorefrontV2DeploymentLog[]}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource(`deployments/${String(deploymentId)}/logs/`),
'GET'
) as Promise<{deploymentId: string; logs: StorefrontV2DeploymentLog[]}>;
};
public rollbackStorefrontV2 = (): Promise<{rollback: StorefrontV2RollbackResult}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('rollback/'),
'POST'
) as Promise<{rollback: StorefrontV2RollbackResult}>;
};
public getStorefrontV2RepositoryTree = (input?: {
path?: string;
ref?: string;
}): Promise<{repositoryTree: StorefrontV2RepositoryTree}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('repository_tree/'),
'GET',
undefined,
input
) as Promise<{repositoryTree: StorefrontV2RepositoryTree}>;
};
public getStorefrontV2RepositoryBranches = (): Promise<{
repositoryBranches: StorefrontV2RepositoryBranches;
}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('repository_branches/'),
'GET'
) as Promise<{repositoryBranches: StorefrontV2RepositoryBranches}>;
};
public getStorefrontV2RepositoryFile = (
path: string,
input?: {ref?: string}
): Promise<{repositoryFile: StorefrontV2RepositoryFile}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('repository_file/'),
'GET',
undefined,
{path, ...input}
) as Promise<{repositoryFile: StorefrontV2RepositoryFile}>;
};
public updateStorefrontV2RepositoryFile = (
payload: StorefrontV2RepositoryFileUpdatePayload
): Promise<{repositoryFileUpdate: StorefrontV2RepositoryFileUpdate}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('repository_file/'),
'POST',
payload
) as Promise<{repositoryFileUpdate: StorefrontV2RepositoryFileUpdate}>;
};
public getStorefrontV2ProductStatus = (
productId: number
): Promise<{storefrontProductStatus: StorefrontV2ProductStatus}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource(`products/${String(productId)}/status/`),
'GET'
) as Promise<{storefrontProductStatus: StorefrontV2ProductStatus}>;
};
public publishStorefrontV2Product = (
payload?: StorefrontV2ProductPublishPayload
): Promise<{productPublish: StorefrontV2ProductPublishResult}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('products/publish/'),
'POST',
payload
) as Promise<{productPublish: StorefrontV2ProductPublishResult}>;
};
public publishStorefrontV2Category = (
payload?: StorefrontV2CategoryPublishPayload
): Promise<{categoryPublish: StorefrontV2CategoryPublishResult}> => {
return this.storefrontV2Request(
this.storefrontV2DomainResource('categories/publish/'),
'POST',
payload
) as Promise<{categoryPublish: StorefrontV2CategoryPublishResult}>;
};
public getAnalytics = (): Promise<DomainAnalyticsResponse> => {
return this.storefrontV2Request(
`/domains/${this.getDomainId()}/analytics/`,
'GET'
) as Promise<DomainAnalyticsResponse>;
};
public getAgentTokenAnalytics = (
queryParams?: Record<string, string | undefined>
): Promise<AgentTokenAnalyticsTimeseries> => {
return this.storefrontV2Request(
`/domains/${this.getDomainId()}/agent_token_analytics/`,
'GET',
undefined,
queryParams
) as Promise<AgentTokenAnalyticsTimeseries>;
};
}
|