@shushed/helpers 0.0.247-cat-tree-schema-20260130105151 → 0.0.247-fh-20260130141017

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.
Files changed (32) hide show
  1. package/dist/cjs/contracts/product-draft.schema.json +14 -0
  2. package/dist/cjs/contracts/product.schema.json +119 -376
  3. package/dist/cjs/dist-dereferenced/category-tree.js +1 -1
  4. package/dist/cjs/dist-dereferenced/messages/product-draft.js +1 -1
  5. package/dist/cjs/dist-dereferenced/messages/product.js +1 -1
  6. package/dist/cjs/dist-dereferenced/product-draft.js +1 -1
  7. package/dist/cjs/dist-dereferenced/product.js +1 -1
  8. package/dist/cjs/src-public/env.js +2 -0
  9. package/dist/cjs/src-public/fredhopper/fredhopper.base.js +497 -0
  10. package/dist/cjs/src-public/fredhopper/fredhopper.js +105 -0
  11. package/dist/cjs/src-public/fredhopper/fredhopper.types.js +10 -0
  12. package/dist/cjs/src-public/fredhopper/index.js +10 -0
  13. package/dist/cjs/src-public/index.js +2 -3
  14. package/dist/package.json +1 -0
  15. package/dist/types/dist-dereferenced/category-tree.d.ts +0 -6
  16. package/dist/types/dist-dereferenced/messages/product-draft.d.ts +6 -0
  17. package/dist/types/dist-dereferenced/messages/product.d.ts +70 -196
  18. package/dist/types/dist-dereferenced/product-draft.d.ts +6 -0
  19. package/dist/types/dist-dereferenced/product.d.ts +70 -196
  20. package/dist/types/dist-types/category-tree.d.ts +0 -2
  21. package/dist/types/dist-types/messages/product-draft.d.ts +2 -0
  22. package/dist/types/dist-types/messages/product.d.ts +29 -66
  23. package/dist/types/dist-types/product-draft.d.ts +2 -0
  24. package/dist/types/dist-types/product.d.ts +29 -66
  25. package/dist/types/src-public/fredhopper/fredhopper.base.d.ts +59 -0
  26. package/dist/types/src-public/fredhopper/fredhopper.d.ts +21 -0
  27. package/dist/types/src-public/fredhopper/fredhopper.types.d.ts +70 -0
  28. package/dist/types/src-public/fredhopper/index.d.ts +2 -0
  29. package/dist/types/src-public/index.d.ts +1 -1
  30. package/package.json +2 -1
  31. package/dist/cjs/src-public/sitoo.js +0 -349
  32. package/dist/types/src-public/sitoo.d.ts +0 -254
@@ -3,38 +3,23 @@ export type Country = ("AF" | "AX" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "
3
3
  export interface __MainSchema {
4
4
  product_id: string;
5
5
  slug?: string;
6
- style_slug?: string;
7
6
  style_id: string;
8
7
  colour_id?: string;
9
8
  style_name?: string;
10
- product_name: string;
11
- display_name?: (string | null);
9
+ display_name: string;
12
10
  buffer_quantity?: number;
13
11
  display_type?: ("Out-of-stock" | "Permanently-unavailable");
14
12
  available_to_sell_from?: (string | null);
15
- online_from: (string | null);
16
- online_to?: (string | null);
17
- first_online_at?: (string | null);
18
- last_online_at?: (string | null);
19
- first_purchased_at?: string;
20
- first_markdown_at?: (string | null);
21
13
  created_at?: string;
22
14
  last_modified_at?: string;
23
15
  colour_family_name?: string;
24
- colour_code?: string;
25
16
  colour_name?: string;
26
17
  display_tags?: DisplayTags;
27
18
  sizerange_code?: string;
28
- sizerange_name?: string;
29
19
  variants?: {
30
20
  code: string;
31
21
  name: string;
32
- [k: string]: unknown;
33
- }[];
34
- images?: {
35
- type: ("Campaign" | "Ecom" | "Flatlay" | "UGC" | "AI");
36
- url: string;
37
- description?: string;
22
+ ean?: (string | null);
38
23
  [k: string]: unknown;
39
24
  }[];
40
25
  vat_rate_uk?: (number | null);
@@ -43,47 +28,40 @@ export interface __MainSchema {
43
28
  commodity_code_ref?: string;
44
29
  country_of_origin?: Country;
45
30
  port_of_origin?: string;
46
- supplier_id?: string;
47
- supplier_name?: string;
48
- factory_id?: string;
49
31
  packing_method?: (("Standard" | "Hanging") | null);
50
32
  is_bought_in_product?: boolean;
51
33
  [k: string]: unknown;
52
34
  };
53
35
  merch?: {
54
36
  strategy_type?: string;
55
- product_type?: string;
56
- stock_type?: string;
57
37
  category?: string;
58
38
  subcategory?: string;
59
- range?: (("Main Collection" | "Seasonal") | null);
60
- channels_availability?: ("DIRECT-UK" | "DIRECT-INT" | "DIRECT-US" | "JL-STORES" | "JL-WEB" | "NEXT" | "MS" | "FENWICK" | "MORLEYS")[];
61
- collections?: string;
62
39
  seasons?: string[];
63
40
  drops?: string[];
64
- fashionability?: (string | null);
65
41
  [k: string]: unknown;
66
42
  };
43
+ category_assignments?: {
44
+ display_path?: string[];
45
+ path?: string[];
46
+ name?: string;
47
+ id?: string;
48
+ [k: string]: unknown;
49
+ }[];
67
50
  attributes?: Attributes;
68
- presentations?: {
51
+ markets?: string[];
52
+ markets_overrides?: {
69
53
  [k: string]: {
70
54
  locale: string;
71
- presentation_type: string;
55
+ market: string;
72
56
  slug?: string;
73
- style_slug?: string;
74
57
  style_name?: string;
75
- display_name?: (string | null);
58
+ display_name?: string;
76
59
  display_type?: ("Out-of-stock" | "Permanently-unavailable");
77
60
  available_to_sell_from?: (string | null);
78
- online_from?: (string | null);
79
- online_to?: (string | null);
80
- last_online_at?: (string | null);
81
- first_purchased_at?: string;
82
- first_markdown_at?: (string | null);
83
61
  colour_family_name?: string;
84
62
  colour_name?: string;
85
63
  display_tags?: DisplayTags;
86
- sizerange_name?: string;
64
+ last_online_at?: (string | null);
87
65
  variants?: {
88
66
  code: string;
89
67
  name: string;
@@ -94,49 +72,34 @@ export interface __MainSchema {
94
72
  };
95
73
  }
96
74
  export interface Attributes {
75
+ stock_quantity_score?: number;
76
+ stock_availability?: number;
77
+ measurement_chart?: (string | null);
78
+ sizeguide_type?: (string | null);
79
+ brand?: (string | null);
80
+ shoes_type?: (string | null);
97
81
  seo_url_name?: string;
98
- embellishment?: (string | null);
99
82
  seo_title?: (string | null);
100
83
  seo_description?: (string | null);
101
84
  fit_description?: (string | null);
102
85
  description?: (string | null);
103
86
  fabric_care?: (string | null);
104
- delivery_returns?: (string | null);
105
87
  weight?: (number | null);
106
- weight_statement?: (string | null);
107
88
  main_fibre?: (string | null);
108
89
  main_metal?: (string | null);
109
- extra_selling_points?: string[];
110
- length_measurement?: (string | null);
111
- measurement_table_code?: string;
112
- fit?: (string | null);
113
- pockets?: (string | null);
114
- pleats_gathers?: (string | null);
115
- lining?: (string | null);
116
- bias_cut?: (string | null);
117
90
  designer?: (string | null);
118
- fabric?: (string | null);
119
- fabric_composition?: (string | null);
120
91
  certificate_code?: (string | null);
121
- shape?: (string | null);
122
- development_type?: string;
123
- occasion?: (string | null);
124
- design?: (string | null);
125
- block?: (string | null);
126
92
  pattern_name?: (string | null);
127
93
  fit_type?: (string | null);
128
- neckline?: (string | null);
129
- sleeve_length?: (string | null);
130
- sleeve_type?: (string | null);
131
- heel_height?: (string | null);
132
- heel_shape?: (string | null);
133
- toe_shape?: (string | null);
134
- trouser_fit?: (string | null);
135
- leg_length?: (string | null);
136
- handle_straps?: (string | null);
137
- straps_features?: (string | null);
138
- fastening?: ((string[] | null) | null);
139
- sole_material?: (string | null);
94
+ trousers_fit?: (string | null);
95
+ trousers_length?: (string | null);
96
+ dresses_skirts_length?: (string | null);
97
+ coats_jackets_type?: (string | null);
98
+ dresses_skirts_type?: (string | null);
99
+ bag_type?: (string | null);
100
+ product_category?: (string | null);
101
+ product_type?: (string | null);
102
+ metal?: (string | null);
140
103
  care_instructions?: string[];
141
104
  [k: string]: unknown;
142
105
  }
@@ -0,0 +1,59 @@
1
+ import { ILogging } from '../runtime';
2
+ import { FredhopperAttribute, FredhopperCategory, FredhopperConfig, FredhopperProduct, UpdateResult, UpdateStatus } from './fredhopper.types';
3
+ export default abstract class FredHelperBase {
4
+ protected logging: ILogging;
5
+ protected readonly config: FredhopperConfig;
6
+ protected attributes: FredhopperAttribute[];
7
+ protected categories: FredhopperCategory[];
8
+ constructor(logging: ILogging, config: FredhopperConfig, attributes: FredhopperAttribute[], categories: FredhopperCategory[]);
9
+ updateType: 'full' | 'incremental';
10
+ protected get timestamp(): string;
11
+ protected get authHeader(): string;
12
+ protected get baseFilesUrl(): string;
13
+ protected get baseUrl(): string;
14
+ static validateCategoryId(categoryId: string): boolean;
15
+ static validateAttributeId(attributeId: string): boolean;
16
+ static validateProductId(productId: string): boolean;
17
+ static authHeader(config: FredhopperConfig): string;
18
+ getCategories(): Promise<FredhopperCategory[]>;
19
+ getAttributesMeta(): Promise<FredhopperAttribute[]>;
20
+ validateProducts(products: FredhopperProduct[]): Promise<void>;
21
+ uploadProductUpdate(products: FredhopperProduct[]): Promise<string>;
22
+ uploadToFredhopper(zipData: Blob, checksum: string): Promise<string>;
23
+ uploadChecksumFile(checksum: string, timestamp: string): Promise<void>;
24
+ triggerIncrementalUpdate(dataId: string): Promise<string>;
25
+ checkUpdateStatus(triggerId: string): Promise<UpdateStatus>;
26
+ getUpdateLogs(triggerId: string): Promise<string>;
27
+ waitForUpdateCompletion(triggerId: string, pollInterval?: number, timeout?: number): Promise<string>;
28
+ protected triggerUpdate(dataId: string): Promise<UpdateResult>;
29
+ protected generateCategoriesCSV(categories: FredhopperCategory[]): string;
30
+ protected generateAttributesMetaCSV(attributes: FredhopperAttribute[]): string;
31
+ protected generateProductsCSV(products: FredhopperProduct[]): string;
32
+ protected generateVariantsCSV(inputs: {
33
+ variants: any[];
34
+ productId: string;
35
+ }[]): string;
36
+ protected generateCustomVariantAttributesCSV(input: {
37
+ [key: string]: string | number;
38
+ }[][]): string;
39
+ protected generateProductAttributesCSV(products: FredhopperProduct[]): string;
40
+ protected createProductUpdateZip(products: FredhopperProduct[]): Promise<{
41
+ blob: Blob;
42
+ checksum: string;
43
+ }>;
44
+ getProductCategories(productId: string): Promise<any>;
45
+ protected createZip(files: Record<string, string>): Promise<{
46
+ blob: Blob;
47
+ checksum: string;
48
+ }>;
49
+ protected calculateChecksum(filename: string): Promise<string>;
50
+ protected createCSVLine(...parts: (string | number)[]): string;
51
+ protected getProduct(id: string): Promise<any>;
52
+ protected queryProduct(query: {
53
+ [key: string]: string;
54
+ }): Promise<any>;
55
+ protected mapAttributesFromExistingProduct(product: any): any;
56
+ protected updateProducts(products: FredhopperProduct[]): Promise<UpdateResult>;
57
+ protected createProductZipContent(products: FredhopperProduct[]): Promise<Record<string, string>>;
58
+ protected get uploadFileName(): "data.zip" | "data-incremental.zip";
59
+ }
@@ -0,0 +1,21 @@
1
+ import FredHelperBase from './fredhopper.base';
2
+ import { CentraCategory, FredhopperProduct, UpdateResult } from './fredhopper.types';
3
+ export default class FredHelper extends FredHelperBase {
4
+ patchAttributes(updates: Array<{
5
+ productId: string;
6
+ attributes: {
7
+ [attributeId: string]: any;
8
+ };
9
+ }>): Promise<UpdateResult>;
10
+ updateProductCategories(updates: Array<{
11
+ productId: string;
12
+ categories: string[];
13
+ }>): Promise<UpdateResult>;
14
+ updateProductAndVariants(items: Array<{
15
+ product: FredhopperProduct;
16
+ variants: {
17
+ [key: string]: string | number;
18
+ }[];
19
+ }>): Promise<UpdateResult>;
20
+ updateCategory(updatedCentraCategory: CentraCategory): Promise<any>;
21
+ }
@@ -0,0 +1,70 @@
1
+ export interface FredhopperCategory {
2
+ category_id: string;
3
+ parent_id: string;
4
+ locales: {
5
+ locale: string;
6
+ name: string;
7
+ }[];
8
+ }
9
+ export type UpdateStatus = 'RUNNING' | 'SUCCESS' | 'FAILURE' | 'UNKNOWN';
10
+ export type UpdateResult = {
11
+ dataId: string;
12
+ triggerId: string;
13
+ status: string;
14
+ };
15
+ export interface FredhopperAttribute {
16
+ attribute_id: string;
17
+ type: 'float' | 'set' | 'list' | 'int' | 'datetime' | 'asset' | 'text' | 'hierarchical';
18
+ locales?: {
19
+ locale: string;
20
+ name: string;
21
+ }[];
22
+ }
23
+ export interface FredhopperProduct {
24
+ product_id: string;
25
+ attributes: {
26
+ [attributeId: string]: any;
27
+ };
28
+ categories?: string[];
29
+ operation_type?: 'add' | 'update' | 'replace' | 'delete';
30
+ variants?: {
31
+ [key: string]: string | number;
32
+ }[];
33
+ }
34
+ export interface FredhopperConfig {
35
+ username: string;
36
+ password: string;
37
+ baseUrl: string;
38
+ environment: string;
39
+ region?: string;
40
+ base64Credentials?: string;
41
+ }
42
+ export declare class FredhopperValidationError extends Error {
43
+ constructor(message: string);
44
+ }
45
+ export type LocalizedName = {
46
+ name: string;
47
+ locale: string;
48
+ };
49
+ export type CategoryNode = {
50
+ name: string;
51
+ localizedNames: LocalizedName[];
52
+ children: CategoryNode[];
53
+ };
54
+ export type Catalog = {
55
+ tenant: string;
56
+ environment: string;
57
+ version: number;
58
+ name: string;
59
+ children: CategoryNode[];
60
+ localizedNames: LocalizedName[];
61
+ };
62
+ export type CentraCategory = {
63
+ category_code: string;
64
+ parent_category_code?: string;
65
+ status: string;
66
+ translations?: {
67
+ language_code: string;
68
+ name: string;
69
+ }[];
70
+ };
@@ -0,0 +1,2 @@
1
+ export { default as FredHelper } from './fredhopper';
2
+ export { FredhopperValidationError, type FredhopperCategory, type FredhopperAttribute, type FredhopperProduct, type FredhopperConfig, } from './fredhopper.types';
@@ -17,4 +17,4 @@ export { default as setHeaders } from './setHeaders';
17
17
  export { type CentraError, type CentraErrors, type BasicCentraCountry, type BasicCentraMarket, type BasicCentraSizeChart, type BasicPricelist, type BasicCentraWarehouse, type BasicCentraCampaign, type BasicCentraProduct, type BasicCentraVariant, type BasicCentraDisplay } from './centra';
18
18
  export { default as RateLimit, RedisConnectionError } from './rateLimit';
19
19
  export { type TriggerOnCreateOptions, type TriggerOnExecuteOptions, type NodeOptions, type RNConfiguration, type TriggerExtraOptions } from './types';
20
- export { default as SitooHelper, type UnitCost, type StockMovementInput, type BasicSitooWarehouse, type BasicSitooStore, type BasicWarehouseTransaction, type WarehouseTransactionEnvelope, type WarehouseTransactionSyncOptions } from './sitoo';
20
+ export * from './fredhopper';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shushed/helpers",
3
- "version": "0.0.247-cat-tree-schema-20260130105151",
3
+ "version": "0.0.247-fh-20260130141017",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",
@@ -9,6 +9,7 @@
9
9
  "@hackylabs/deep-redact": "^2.2.1",
10
10
  "ajv": "^8.17.1",
11
11
  "ajv-formats": "^3.0.1",
12
+ "archiver": "^7.0.1",
12
13
  "co-body": "^6.2.0",
13
14
  "jose": "^6.0.11",
14
15
  "lodash.chunk": "^4.2.0",