@porulle/plugin-channel-connector 0.10.8 → 0.11.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/service.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import type { Actor, ChannelConnector, ChannelOrderSlice, PluginDb, PluginResult, PluginTxFn } from "@porulle/core";
1
+ import type { Actor, ChannelConnector, ChannelOrderSlice, ChannelPushCatalogItem, PluginDb, PluginResult, PluginTxFn } from "@porulle/core";
2
+ import type { FieldPath } from "@porulle/core";
2
3
  import type { JobsAdapter } from "@porulle/core";
3
4
  import { type ChannelOrderExport, type ChannelRefundRequest, type ConnectedStore } from "./schema.js";
5
+ import { type CatalogFieldMapping } from "./catalog-field-mapping.js";
4
6
  export type ExportState = ChannelOrderExport["state"];
5
7
  export interface ReconcileReport extends Record<string, unknown> {
6
8
  imported: number;
@@ -8,11 +10,37 @@ export interface ReconcileReport extends Record<string, unknown> {
8
10
  archived: number;
9
11
  inventoryUpdated: number;
10
12
  driftAlert: boolean;
13
+ skipped?: CatalogFieldSkip[];
14
+ conflicts?: CatalogFieldConflict[];
15
+ warnings?: string[];
16
+ }
17
+ export interface CatalogFieldConflict {
18
+ entityId: string;
19
+ storeId: string;
20
+ fieldPath: FieldPath;
21
+ localValueSummary: string;
22
+ remoteValueSummary: string;
23
+ }
24
+ export interface CatalogFieldSkip {
25
+ entityId: string;
26
+ fieldPath: FieldPath;
27
+ }
28
+ export type CatalogPushSkipReason = "no_mapping" | "held" | "entity_not_active" | "unmapped_entity";
29
+ export interface CatalogPushFieldSkip {
30
+ entityId: string;
31
+ fieldPath: FieldPath;
32
+ reason: CatalogPushSkipReason;
11
33
  }
12
34
  export type PublicConnectedStore = Omit<ConnectedStore, "credentials" | "webhookSecret"> & {
13
35
  credentials: "[REDACTED]";
14
36
  webhookSecret: "[REDACTED]";
15
37
  };
38
+ export interface CatalogWriteSettings {
39
+ enabled: boolean;
40
+ overrides: CatalogFieldMapping;
41
+ merged: CatalogFieldMapping;
42
+ warnings?: string[];
43
+ }
16
44
  export interface ChannelComplianceData {
17
45
  customer: {
18
46
  id?: string;
@@ -47,6 +75,32 @@ export interface ChannelStockLine {
47
75
  title?: string;
48
76
  quantity: number;
49
77
  }
78
+ interface BackfillCounts {
79
+ entitiesTouched: number;
80
+ attributesCreated: number;
81
+ mediaImported: number;
82
+ variantsGivenOptionValues: number;
83
+ }
84
+ export interface BackfillCatalogReport extends BackfillCounts, Record<string, unknown> {
85
+ cursor: string | null;
86
+ complete: boolean;
87
+ skipped?: CatalogFieldSkip[];
88
+ conflicts?: CatalogFieldConflict[];
89
+ warnings?: string[];
90
+ }
91
+ export interface BackfillCatalogOptions {
92
+ dryRun?: boolean;
93
+ resume?: boolean;
94
+ maxPages?: number;
95
+ }
96
+ export interface BuildCatalogPushItemsOptions {
97
+ recordRevision?: boolean;
98
+ }
99
+ export interface BuildCatalogPushItemsResult {
100
+ items: ChannelPushCatalogItem[];
101
+ skipped: CatalogPushFieldSkip[];
102
+ warnings: string[];
103
+ }
50
104
  export declare function canExportTransition(from: ExportState, to: ExportState): boolean;
51
105
  export declare class ChannelConnectorService {
52
106
  private readonly db;
@@ -58,9 +112,27 @@ export declare class ChannelConnectorService {
58
112
  constructor(db: PluginDb, services: Record<string, unknown>, options?: ChannelConnectorPluginOptions, transaction?: PluginTxFn);
59
113
  getConnector(providerId: string): ChannelConnector | undefined;
60
114
  private get catalog();
115
+ private get media();
116
+ private get pricing();
117
+ private filterOwnedFields;
118
+ private filterOwnedFieldsAtPaths;
119
+ private filterConflictingFields;
120
+ private remoteFieldValue;
121
+ private localFieldValue;
122
+ private detectSharedConflicts;
123
+ private setCatalogAttributes;
124
+ private upsertOptionAxes;
125
+ private upsertVariants;
126
+ private applyTaxonomy;
127
+ private applyMedia;
61
128
  private getStoreRecord;
62
129
  getStoreByDomain(shopDomain: string): Promise<ConnectedStore | undefined>;
63
130
  getStoresByDomain(shopDomain: string): Promise<ConnectedStore[]>;
131
+ resolveCatalogFieldMapping(store: Pick<ConnectedStore, "provider" | "catalogFieldMapping">, filterableCustomFields?: ReadonlySet<string> | Readonly<Record<string, boolean>>, warnings?: string[]): CatalogFieldMapping;
132
+ buildCatalogPushItems(orgId: string, storeId: string, entityIds: string[], options?: BuildCatalogPushItemsOptions): Promise<PluginResult<BuildCatalogPushItemsResult>>;
133
+ getCatalogWriteSettings(orgId: string, storeId: string): Promise<PluginResult<CatalogWriteSettings>>;
134
+ updateCatalogWriteEnabled(orgId: string, storeId: string, enabled: boolean): Promise<PluginResult<CatalogWriteSettings>>;
135
+ updateCatalogFieldMapping(orgId: string, storeId: string, mapping: unknown): Promise<PluginResult<CatalogWriteSettings>>;
64
136
  connectStore(orgId: string, input: {
65
137
  provider: string;
66
138
  credentials: Record<string, unknown>;
@@ -76,7 +148,14 @@ export declare class ChannelConnectorService {
76
148
  importCatalog(orgId: string, storeId: string, actor: Actor): Promise<PluginResult<{
77
149
  imported: number;
78
150
  cursor: string | null;
151
+ skipped?: CatalogFieldSkip[];
152
+ conflicts?: CatalogFieldConflict[];
153
+ warnings?: string[];
79
154
  }>>;
155
+ private promoteLegacyAttributes;
156
+ private saveBackfillState;
157
+ backfillCatalog(orgId: string, storeId: string, actor: Actor, options?: BackfillCatalogOptions): Promise<PluginResult<BackfillCatalogReport>>;
158
+ private estimateCatalogItems;
80
159
  private convergeCatalogItems;
81
160
  reconcile(orgId: string, storeId: string, actor: Actor): Promise<PluginResult<ReconcileReport>>;
82
161
  getReconcileStatus(orgId: string, storeId: string): Promise<PluginResult<{
@@ -130,3 +209,4 @@ export declare class ChannelConnectorService {
130
209
  retryExport(orgId: string, exportId: string, changedBy: string): Promise<PluginResult<ChannelOrderExport>>;
131
210
  abandonExport(orgId: string, exportId: string, changedBy: string, reason?: string): Promise<PluginResult<ChannelOrderExport>>;
132
211
  }
212
+ export {};