@cellaware/utils 5.4.4 → 5.4.6

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,7 +1,7 @@
1
1
  import { storageBlobDelete, storageBlobDownload, storageBlobUpload, storageContainerCreate } from "../../azure/storage.js";
2
2
  const CONTAINER_CLIENT_ID = 'chatwms';
3
3
  export function chatwmsStorageGetBlobId(clientId, blobName) {
4
- return clientId.replace('_', '-') + '-' + blobName;
4
+ return clientId.replaceAll('_', '-') + '-' + blobName;
5
5
  }
6
6
  export async function chatwmsStorageContainerCreate() {
7
7
  return storageContainerCreate(CONTAINER_CLIENT_ID);
@@ -1,3 +1,5 @@
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,3 +6,19 @@ 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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "5.4.4",
3
+ "version": "5.4.6",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",