@cellaware/utils 5.4.5 → 5.4.7

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.
@@ -1,3 +1,13 @@
1
1
  export declare const CHATWMS_GENERIC_CLIENT_ID = "chatwms";
2
2
  export declare function chatwmsGetClientId(customer: string, warehouse: string): string;
3
3
  export declare function chatwmsGetWarehouseFromClientId(clientId: string, customer: string): string;
4
+ export declare function chatwmsGetOrganizationFromWarehouse(warehouse: string): string | undefined;
5
+ export declare function chatwmsGetOrganizationFromClientId(clientId: string, customer: string): string | undefined;
6
+ export declare function chatwmsExtractWarehouseAndOrganizationFromWarehouse(warehouse: string): {
7
+ warehouse: string;
8
+ organization: string | undefined;
9
+ };
10
+ export declare function chatwmsExtractWarehouseAndOrganizationFromClientId(clientId: string, customer: string): {
11
+ warehouse: string;
12
+ organization: string | undefined;
13
+ };
@@ -6,3 +6,37 @@ export function chatwmsGetWarehouseFromClientId(clientId, customer) {
6
6
  const prefix = `${customer}_`;
7
7
  return clientId.substring(clientId.indexOf(prefix) + prefix.length);
8
8
  }
9
+ export function chatwmsGetOrganizationFromWarehouse(warehouse) {
10
+ const lastIdx = warehouse.lastIndexOf('_');
11
+ if (lastIdx === -1) {
12
+ return undefined;
13
+ }
14
+ const organization = warehouse.substring(0, lastIdx);
15
+ // We could have multiple organization levels.
16
+ const startIdx = organization.lastIndexOf('_');
17
+ if (startIdx > -1) {
18
+ return organization.substring(startIdx + 1);
19
+ }
20
+ return organization;
21
+ }
22
+ export function chatwmsGetOrganizationFromClientId(clientId, customer) {
23
+ return chatwmsGetOrganizationFromWarehouse(chatwmsGetWarehouseFromClientId(clientId, customer));
24
+ }
25
+ export function chatwmsExtractWarehouseAndOrganizationFromWarehouse(warehouse) {
26
+ const organization = chatwmsGetOrganizationFromWarehouse(warehouse);
27
+ if (!!organization) {
28
+ return {
29
+ warehouse: warehouse.substring(warehouse.lastIndexOf('_') + 1),
30
+ organization
31
+ };
32
+ }
33
+ else {
34
+ return {
35
+ warehouse,
36
+ organization: undefined
37
+ };
38
+ }
39
+ }
40
+ export function chatwmsExtractWarehouseAndOrganizationFromClientId(clientId, customer) {
41
+ return chatwmsExtractWarehouseAndOrganizationFromWarehouse(chatwmsGetWarehouseFromClientId(clientId, customer));
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "5.4.5",
3
+ "version": "5.4.7",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",