@etsoo/appscript 1.6.29 → 1.6.31

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.
@@ -19,6 +19,13 @@ export declare namespace BusinessUtils {
19
19
  * @returns 12 months
20
20
  */
21
21
  function getMonths(monthLabels: string[], startMonth?: number): ListType[];
22
+ /**
23
+ * Check if the item is a custom culture data
24
+ * @param item Item to check
25
+ * @param hasOrgId Has orgId or not
26
+ * @returns Result
27
+ */
28
+ function isCustomCultureData(item: unknown, hasOrgId?: boolean): item is CustomCultureData;
22
29
  /**
23
30
  * Merge custom resources to target collection
24
31
  * @param target Target collection merges to
@@ -56,6 +56,20 @@ var BusinessUtils;
56
56
  return months;
57
57
  }
58
58
  BusinessUtils.getMonths = getMonths;
59
+ /**
60
+ * Check if the item is a custom culture data
61
+ * @param item Item to check
62
+ * @param hasOrgId Has orgId or not
63
+ * @returns Result
64
+ */
65
+ function isCustomCultureData(item, hasOrgId = false) {
66
+ return (item != null &&
67
+ typeof item === "object" &&
68
+ "key" in item &&
69
+ "title" in item &&
70
+ (!hasOrgId || "orgId" in item));
71
+ }
72
+ BusinessUtils.isCustomCultureData = isCustomCultureData;
59
73
  /**
60
74
  * Merge custom resources to target collection
61
75
  * @param target Target collection merges to
@@ -63,20 +77,19 @@ var BusinessUtils;
63
77
  */
64
78
  function mergeCustomResources(target, resources) {
65
79
  for (const item of resources) {
66
- if (item.organizationId) {
80
+ if (item.orgId) {
67
81
  // Backup
68
- const backup = target[item.id];
69
- if (backup != null &&
70
- (typeof backup !== "object" || !("organizationId" in backup))) {
71
- resourcesCache[item.id] = backup;
82
+ const backup = target[item.key];
83
+ if (backup != null && !isCustomCultureData(backup, true)) {
84
+ resourcesCache[item.key] = backup;
72
85
  }
73
86
  }
74
87
  if (item.description || item.jsonData) {
75
- const { id, ...rest } = item;
76
- target[item.id] = rest;
88
+ const { key, ...rest } = item;
89
+ target[key] = rest;
77
90
  }
78
91
  else {
79
- target[item.id] = item.title;
92
+ target[item.key] = item.title;
80
93
  }
81
94
  }
82
95
  }
@@ -3,13 +3,13 @@
3
3
  */
4
4
  export type CustomCultureData = {
5
5
  /**
6
- * Target id
6
+ * Key
7
7
  */
8
- id: string;
8
+ key: string;
9
9
  /**
10
10
  * Organization id
11
11
  */
12
- organizationId?: number;
12
+ orgId?: number;
13
13
  /**
14
14
  * Title / label
15
15
  */
@@ -19,6 +19,13 @@ export declare namespace BusinessUtils {
19
19
  * @returns 12 months
20
20
  */
21
21
  function getMonths(monthLabels: string[], startMonth?: number): ListType[];
22
+ /**
23
+ * Check if the item is a custom culture data
24
+ * @param item Item to check
25
+ * @param hasOrgId Has orgId or not
26
+ * @returns Result
27
+ */
28
+ function isCustomCultureData(item: unknown, hasOrgId?: boolean): item is CustomCultureData;
22
29
  /**
23
30
  * Merge custom resources to target collection
24
31
  * @param target Target collection merges to
@@ -53,6 +53,20 @@ export var BusinessUtils;
53
53
  return months;
54
54
  }
55
55
  BusinessUtils.getMonths = getMonths;
56
+ /**
57
+ * Check if the item is a custom culture data
58
+ * @param item Item to check
59
+ * @param hasOrgId Has orgId or not
60
+ * @returns Result
61
+ */
62
+ function isCustomCultureData(item, hasOrgId = false) {
63
+ return (item != null &&
64
+ typeof item === "object" &&
65
+ "key" in item &&
66
+ "title" in item &&
67
+ (!hasOrgId || "orgId" in item));
68
+ }
69
+ BusinessUtils.isCustomCultureData = isCustomCultureData;
56
70
  /**
57
71
  * Merge custom resources to target collection
58
72
  * @param target Target collection merges to
@@ -60,20 +74,19 @@ export var BusinessUtils;
60
74
  */
61
75
  function mergeCustomResources(target, resources) {
62
76
  for (const item of resources) {
63
- if (item.organizationId) {
77
+ if (item.orgId) {
64
78
  // Backup
65
- const backup = target[item.id];
66
- if (backup != null &&
67
- (typeof backup !== "object" || !("organizationId" in backup))) {
68
- resourcesCache[item.id] = backup;
79
+ const backup = target[item.key];
80
+ if (backup != null && !isCustomCultureData(backup, true)) {
81
+ resourcesCache[item.key] = backup;
69
82
  }
70
83
  }
71
84
  if (item.description || item.jsonData) {
72
- const { id, ...rest } = item;
73
- target[item.id] = rest;
85
+ const { key, ...rest } = item;
86
+ target[key] = rest;
74
87
  }
75
88
  else {
76
- target[item.id] = item.title;
89
+ target[item.key] = item.title;
77
90
  }
78
91
  }
79
92
  }
@@ -3,13 +3,13 @@
3
3
  */
4
4
  export type CustomCultureData = {
5
5
  /**
6
- * Target id
6
+ * Key
7
7
  */
8
- id: string;
8
+ key: string;
9
9
  /**
10
10
  * Organization id
11
11
  */
12
- organizationId?: number;
12
+ orgId?: number;
13
13
  /**
14
14
  * Title / label
15
15
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.6.29",
3
+ "version": "1.6.31",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -37,15 +37,15 @@
37
37
  "dependencies": {
38
38
  "@etsoo/notificationbase": "^1.1.60",
39
39
  "@etsoo/restclient": "^1.1.27",
40
- "@etsoo/shared": "^1.2.69",
40
+ "@etsoo/shared": "^1.2.70",
41
41
  "crypto-js": "^4.2.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@babel/cli": "^7.27.0",
45
- "@babel/core": "^7.26.10",
46
- "@babel/plugin-transform-runtime": "^7.26.10",
47
- "@babel/preset-env": "^7.26.9",
48
- "@babel/runtime-corejs3": "^7.27.0",
44
+ "@babel/cli": "^7.27.1",
45
+ "@babel/core": "^7.27.1",
46
+ "@babel/plugin-transform-runtime": "^7.27.1",
47
+ "@babel/preset-env": "^7.27.1",
48
+ "@babel/runtime-corejs3": "^7.27.1",
49
49
  "@types/crypto-js": "^4.2.2",
50
50
  "@vitejs/plugin-react": "^4.4.1",
51
51
  "jsdom": "^26.1.0",
@@ -66,6 +66,25 @@ export namespace BusinessUtils {
66
66
  return months;
67
67
  }
68
68
 
69
+ /**
70
+ * Check if the item is a custom culture data
71
+ * @param item Item to check
72
+ * @param hasOrgId Has orgId or not
73
+ * @returns Result
74
+ */
75
+ export function isCustomCultureData(
76
+ item: unknown,
77
+ hasOrgId: boolean = false
78
+ ): item is CustomCultureData {
79
+ return (
80
+ item != null &&
81
+ typeof item === "object" &&
82
+ "key" in item &&
83
+ "title" in item &&
84
+ (!hasOrgId || "orgId" in item)
85
+ );
86
+ }
87
+
69
88
  /**
70
89
  * Merge custom resources to target collection
71
90
  * @param target Target collection merges to
@@ -76,22 +95,19 @@ export namespace BusinessUtils {
76
95
  resources: CustomCultureData[]
77
96
  ) {
78
97
  for (const item of resources) {
79
- if (item.organizationId) {
98
+ if (item.orgId) {
80
99
  // Backup
81
- const backup = target[item.id];
82
- if (
83
- backup != null &&
84
- (typeof backup !== "object" || !("organizationId" in backup))
85
- ) {
86
- resourcesCache[item.id] = backup;
100
+ const backup = target[item.key];
101
+ if (backup != null && !isCustomCultureData(backup, true)) {
102
+ resourcesCache[item.key] = backup;
87
103
  }
88
104
  }
89
105
 
90
106
  if (item.description || item.jsonData) {
91
- const { id, ...rest } = item;
92
- target[item.id] = rest;
107
+ const { key, ...rest } = item;
108
+ target[key] = rest;
93
109
  } else {
94
- target[item.id] = item.title;
110
+ target[item.key] = item.title;
95
111
  }
96
112
  }
97
113
  }
@@ -3,14 +3,14 @@
3
3
  */
4
4
  export type CustomCultureData = {
5
5
  /**
6
- * Target id
6
+ * Key
7
7
  */
8
- id: string;
8
+ key: string;
9
9
 
10
10
  /**
11
11
  * Organization id
12
12
  */
13
- organizationId?: number;
13
+ orgId?: number;
14
14
 
15
15
  /**
16
16
  * Title / label