feed-common 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [1.0.1](https://github.com/advertikon/package-maxify-feed-common/compare/v1.0.0...v1.0.1) (2024-01-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add company types ([cd62d4d](https://github.com/advertikon/package-maxify-feed-common/commit/cd62d4d762b6afd72279426f42fab34eefce1bc0))
7
+ * add type definitions ([8f5d33f](https://github.com/advertikon/package-maxify-feed-common/commit/8f5d33f69a5f65772fdc0f1ba7bb543ff0f88afe))
8
+ * fix ci ([6444435](https://github.com/advertikon/package-maxify-feed-common/commit/6444435746003edbebe340a258f9c9c5b1639289))
9
+
1
10
  # 1.0.0 (2024-01-28)
2
11
 
3
12
 
@@ -0,0 +1,11 @@
1
+ export declare enum GmcProductSyncStatus {
2
+ REJECTED = "rejected",
3
+ APPROVED = "approved",
4
+ WARINING = "warning",
5
+ SYNC_SHEDULED = "sync_sheduled"
6
+ }
7
+ export declare enum GoogleAccountStatus {
8
+ ENABLED = "ENABLED",
9
+ REMOVED = "REMOVED",
10
+ REJECTED = "REJECTED"
11
+ }
@@ -0,0 +1,4 @@
1
+ export declare enum ProductSyncStatus {
2
+ SYNCING = "syncing",
3
+ SYNCED = "synced"
4
+ }
@@ -0,0 +1,69 @@
1
+ import { ProductUploadMapSource } from '../types/profile.types.js';
2
+ import { ProductUploadRuleFilterType } from '../types/profile.types.js';
3
+ export declare const SOURCE_VENDORS = "source.vendor";
4
+ export declare const SOURCE_TAGS = "source.tag";
5
+ export declare const SOURCE_PORODUCT_TYPE = "source.product_type";
6
+ export declare const SOURCE_COLLECTIONS = "source.collection";
7
+ export declare const SOURCE_LANGUAGE = "source.language";
8
+ export declare const SOURCE_GOOGLE_CATEGORY = "source.google_category";
9
+ export declare const SOURCE_COUNTRY = "source.country";
10
+ export declare const SOURCE_SHOPIFY_VENDORS = "shopify.vendor";
11
+ export declare const SOURCE_SHOPIFY_BARCODE = "shopify.barcode";
12
+ export declare const SOURCE_SHOPIFY_SKU = "shopify.sku";
13
+ export declare const SOURCE_CUSTOM = "custom_input";
14
+ export declare const RuleOperators: {
15
+ contains: {
16
+ label: string;
17
+ value: string;
18
+ };
19
+ notContains: {
20
+ label: string;
21
+ value: string;
22
+ };
23
+ equals: {
24
+ label: string;
25
+ value: string;
26
+ };
27
+ notEquals: {
28
+ label: string;
29
+ value: string;
30
+ };
31
+ startsWith: {
32
+ label: string;
33
+ value: string;
34
+ };
35
+ notStartsWith: {
36
+ label: string;
37
+ value: string;
38
+ };
39
+ endsWith: {
40
+ label: string;
41
+ value: string;
42
+ };
43
+ notEndsWith: {
44
+ label: string;
45
+ value: string;
46
+ };
47
+ in: {
48
+ label: string;
49
+ value: string;
50
+ };
51
+ notIn: {
52
+ label: string;
53
+ value: string;
54
+ };
55
+ };
56
+ export declare const PruoductUploadRulesOperators: {
57
+ string: {
58
+ label: string;
59
+ value: string;
60
+ }[];
61
+ list: {
62
+ label: string;
63
+ value: string;
64
+ }[];
65
+ };
66
+ export declare const ProductUploadRuleFilters: ProductUploadRuleFilterType[];
67
+ export declare const ProductUploadMappings: ProductUploadMapSource[];
68
+ export declare const CHANNEL = "online";
69
+ export declare const GMC_PRODUCT_ID_TEMPLATE = "{PRODUCT_ID}_{VARIANT_ID}";
@@ -0,0 +1,9 @@
1
+ export * from './constants/google.constants.js';
2
+ export * from './constants/product.constants.js';
3
+ export * from './constants/profile.constants.js';
4
+ export * from './types/product.types.js';
5
+ export * from './types/profile.types.js';
6
+ export * from './types/company.types.js';
7
+ export * from './utils/gmc.js';
8
+ export * from './utils/profile.js';
9
+ export * from './utils/utils.js';
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ export * from './constants/product.constants.js';
3
3
  export * from './constants/profile.constants.js';
4
4
  export * from './types/product.types.js';
5
5
  export * from './types/profile.types.js';
6
+ export * from './types/company.types.js';
6
7
  export * from './utils/gmc.js';
7
8
  export * from './utils/profile.js';
8
9
  export * from './utils/utils.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AAEjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AAEjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export type CompanyActionProgress = {
2
+ progress: number;
3
+ totalCount: number;
4
+ name: 'shopify' | 'gmc' | 'issues' | 'shopify-collection';
5
+ threadId: string;
6
+ };
7
+ export type CompanyActivity = CompanyActionProgress & {
8
+ shop: string;
9
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=company.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"company.types.js","sourceRoot":"","sources":["../../src/types/company.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,86 @@
1
+ import { GmcProductSyncStatus } from '../constants/google.constants.js';
2
+ import { ProductSyncStatus } from '../constants/product.constants.js';
3
+ export type AppProductStatus = 'active' | 'draft' | 'archived';
4
+ export type AppProductVariant = {
5
+ id: number;
6
+ title: string;
7
+ price: string;
8
+ sku: string | null;
9
+ image_id: number | null;
10
+ };
11
+ export type GmcProductId = {
12
+ id: string;
13
+ profileId: string;
14
+ gmcAccount: string;
15
+ uploaded_at: string;
16
+ status?: GmcProductSyncStatus;
17
+ };
18
+ export type GoogleProductIssue = {
19
+ servability?: 'demoted' | 'disapproved' | 'unaffected' | string;
20
+ description?: string;
21
+ documentation?: string;
22
+ };
23
+ export type gmcIssue = {
24
+ gmcProductId: string;
25
+ gmcAccount: string;
26
+ updated_at: string;
27
+ issue: GoogleProductIssue[];
28
+ };
29
+ export type ShopifyCollection = {
30
+ id: number;
31
+ handle: string;
32
+ title: string;
33
+ };
34
+ export type AppProduct = {
35
+ status: AppProductStatus;
36
+ handle: string;
37
+ title: string;
38
+ category?: string;
39
+ id: number;
40
+ googleCategory?: number;
41
+ image?: string;
42
+ _id: string;
43
+ gmcIssues?: gmcIssue[];
44
+ gmcProductId?: GmcProductId[];
45
+ updated_at: string;
46
+ variants: AppProductVariant[];
47
+ images: {
48
+ src: string;
49
+ id: string;
50
+ }[];
51
+ collections: ShopifyCollection[];
52
+ tags: string[];
53
+ vendor: string;
54
+ product_type: string;
55
+ syncStatus: ProductSyncStatus;
56
+ };
57
+ export type GetProductsQuery = {
58
+ before?: string;
59
+ after?: string;
60
+ limit?: number;
61
+ handle?: string;
62
+ title?: string;
63
+ id?: number[];
64
+ sortField?: 'title' | 'id';
65
+ sort?: 'asc' | 'desc';
66
+ fields?: string[];
67
+ gmcProductId?: string[] | boolean;
68
+ };
69
+ export type GetProductsResponse = {
70
+ products: AppProduct[];
71
+ pagination: {
72
+ firstId: string;
73
+ lastId: string;
74
+ hasMore: boolean;
75
+ hasLess: boolean;
76
+ };
77
+ };
78
+ export type ProductsList = {
79
+ ids: string[];
80
+ };
81
+ export type UploadProductBulkPayload = {
82
+ collections: string[];
83
+ vendors: string[];
84
+ types: string[];
85
+ tags: string[];
86
+ };
@@ -0,0 +1,68 @@
1
+ import { ProductUploadRuleFilters, ProductUploadMappings } from '../constants/profile.constants.js';
2
+ import { RuleOperators } from '../constants/profile.constants.js';
3
+ export type ProductUploadRuleOpratorType = {
4
+ label: string;
5
+ value: string;
6
+ };
7
+ export type ProductUploadRuleFilterType = {
8
+ label: string;
9
+ operators: ProductUploadRuleOpratorType[];
10
+ value: string;
11
+ disabled?: boolean;
12
+ };
13
+ export type RuleOperatorsType = typeof RuleOperators;
14
+ export type ValueType = string | string[] | number[] | number | boolean;
15
+ export type OptionTypeItem = {
16
+ label: string;
17
+ value: ValueType;
18
+ };
19
+ export type OptionTypeGroup = {
20
+ title: string;
21
+ options: OptionTypeItem[];
22
+ };
23
+ export type OptionType = OptionTypeItem | OptionTypeGroup | string;
24
+ export type ProductUploadMapSource = {
25
+ required: boolean;
26
+ label: string;
27
+ attribute: string;
28
+ type: 'select' | 'multiselect' | 'text' | 'number';
29
+ choises?: OptionType[];
30
+ rules: ProductUploadRuleFilterType['value'][];
31
+ description?: string;
32
+ defaultValue?: ValueType;
33
+ };
34
+ export type ProductUploadMapping = {
35
+ attribute: MappingFields;
36
+ value: ValueType;
37
+ rules: {
38
+ sections: {
39
+ ruleItems: {
40
+ attribute: (typeof ProductUploadRuleFilters)[number]['value'];
41
+ operator: ProductUploadRuleOpratorType['value'];
42
+ value: string | string[] | number[] | number | boolean;
43
+ id: string;
44
+ }[];
45
+ }[];
46
+ };
47
+ };
48
+ type MappingFields = (typeof ProductUploadMappings)[number]['attribute'];
49
+ export type ProductUploadProfile = {
50
+ id: string;
51
+ name: string;
52
+ active?: boolean;
53
+ rules: ProductUploadRules;
54
+ mappings: ProductUploadMapping[];
55
+ };
56
+ export type ProductUploadRules = {
57
+ sections: ProductUploadRuleSection[];
58
+ };
59
+ export type ProductUploadRuleSection = {
60
+ ruleItems: ProductUploadRuleItem[];
61
+ };
62
+ export type ProductUploadRuleItem = {
63
+ id: string;
64
+ attribute: string;
65
+ operator: string;
66
+ value: string | number | string[] | number[] | boolean;
67
+ };
68
+ export {};
@@ -0,0 +1,16 @@
1
+ export declare function isGmcProductId(productId: string): boolean;
2
+ export declare function GMCProductIdToShopify(productId: string): number;
3
+ export declare function GmcIdParts(gmcProductId: string): {
4
+ channel: string;
5
+ locale: string;
6
+ country: string;
7
+ idPart: string;
8
+ shopifyId: number;
9
+ shopifyVariantId: number;
10
+ };
11
+ export declare function makeGmcIdPart(productId: number | null, variantId: number | null): string;
12
+ export declare function getShopifyIdsFromGmcIdPart(gmcId: string): {
13
+ shopifyId: number;
14
+ shopifyVariantId: number;
15
+ };
16
+ export declare function getProductIdFromGmcId(gmcId: string): number;
@@ -0,0 +1,28 @@
1
+ import { OptionType, OptionTypeItem, OptionTypeGroup, ProductUploadProfile } from '../types/profile.types.js';
2
+ import { ProductUploadMapping } from '../types/profile.types.js';
3
+ import { ProductUploadRuleFilterType } from '../types/profile.types.js';
4
+ import { ProductUploadRuleItem, ProductUploadRuleSection, ProductUploadRules } from '../types/profile.types.js';
5
+ export declare function checkRuleDuplication(rules: ProductUploadRuleItem[]): string[];
6
+ export declare function checkRuleAlwaysness(rules: ProductUploadRuleItem[]): string[];
7
+ export declare function checkRuleDeadlocks(sections: ProductUploadRuleSection[]): string[];
8
+ export declare function getEmptyRuleItem(attribute?: ProductUploadRuleFilterType['value']): ProductUploadRuleItem;
9
+ export declare function sortMappings(a: ProductUploadMapping, b: ProductUploadMapping): number;
10
+ export declare function hasRules(rules: ProductUploadRules): boolean;
11
+ /**
12
+ * Checks if two rules are the same
13
+ * @param a
14
+ * @param b
15
+ * @returns
16
+ */
17
+ export declare function compareRules(a?: ProductUploadRules, b?: ProductUploadRules): boolean;
18
+ export declare function compareMappings(a: ProductUploadMapping[], b: ProductUploadMapping[]): boolean;
19
+ export declare function optionIsString(option: OptionType): option is string;
20
+ export declare function optionIsItem(option: OptionType): option is OptionTypeItem;
21
+ export declare function optionIsGroup(option: OptionType): option is OptionTypeGroup;
22
+ export declare function detectProfileChange(a: ProductUploadProfile, b: ProductUploadProfile): {
23
+ name: boolean;
24
+ rules: boolean;
25
+ mappings: boolean;
26
+ id: boolean;
27
+ };
28
+ export declare function sanitizeUploadProfile(profile: ProductUploadProfile): ProductUploadProfile;
@@ -0,0 +1 @@
1
+ export declare function code(): string;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "feed-common",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Maxify feed common library",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "build": "tsc"
8
+ "build": "tsc",
9
+ "install-local": "scripts/install.sh"
9
10
  },
10
11
  "devDependencies": {
11
12
  "@semantic-release/changelog": "^6.0.1",
@@ -0,0 +1,9 @@
1
+ rm -R /var/www/html/shopify/maxify-feed-express/server/node_modules/feed-common/dist/
2
+ rm -R /var/www/html/shopify/maxify-feed-express/server/node_modules/feed-common/src/
3
+ cp -R dist/ /var/www/html/shopify/maxify-feed-express/server/node_modules/feed-common/
4
+ cp -R src/ /var/www/html/shopify/maxify-feed-express/server/node_modules/feed-common/
5
+
6
+ rm -R /var/www/html/shopify/maxify-feed-express/front/node_modules/feed-common/dist/
7
+ rm -R /var/www/html/shopify/maxify-feed-express/front/node_modules/feed-common/src/
8
+ cp -R dist/ /var/www/html/shopify/maxify-feed-express/front/node_modules/feed-common/
9
+ cp -R src/ /var/www/html/shopify/maxify-feed-express/front/node_modules/feed-common/
@@ -0,0 +1,12 @@
1
+ export enum GmcProductSyncStatus {
2
+ REJECTED = 'rejected',
3
+ APPROVED = 'approved',
4
+ WARINING = 'warning',
5
+ SYNC_SHEDULED = 'sync_sheduled',
6
+ }
7
+
8
+ export enum GoogleAccountStatus {
9
+ ENABLED = 'ENABLED',
10
+ REMOVED = 'REMOVED',
11
+ REJECTED = 'REJECTED',
12
+ }
@@ -0,0 +1,4 @@
1
+ export enum ProductSyncStatus {
2
+ SYNCING = 'syncing',
3
+ SYNCED = 'synced',
4
+ }