@webex/common 3.0.0-beta.414 → 3.0.0-beta.415
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.
package/dist/uuid-utils.js
CHANGED
package/dist/uuid-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hydraBaseUrl","isRequired","Error","constructHydraId","type","id","cluster","toUpperCase","hydraTypes","PEOPLE","ORGANIZATION","encode","deconstructHydraId","payload","decode","split","pop","buildHydraMessageId","uuid","MESSAGE","buildHydraPersonId","buildHydraRoomId","ROOM","buildHydraOrgId","buildHydraMembershipId","personUUID","spaceUUID","MEMBERSHIP","getHydraClusterString","webex","conversationUrl","internalClusterString","internal","services","getClusterId","startsWith","INTERNAL_US_CLUSTER_NAME","INTERNAL_US_INTEGRATION_CLUSTER_NAME","clusterParts","length","getHydraRoomType","tags","includes","SDK_EVENT","INTERNAL","ACTIVITY_TAG","ONE_ON_ONE","EXTERNAL","SPACE_TYPE","DIRECT","GROUP","getHydraFiles","activity","hydraFiles","files","object","items","i","contentId","CONTENT","push"],"sources":["uuid-utils.js"],"sourcesContent":["import {encode, decode} from './base64';\nimport {\n SDK_EVENT,\n hydraTypes,\n INTERNAL_US_CLUSTER_NAME,\n INTERNAL_US_INTEGRATION_CLUSTER_NAME,\n} from './constants';\n\nconst hydraBaseUrl = 'https://api.ciscospark.com/v1';\n\nconst isRequired = () => {\n throw Error('parameter is required');\n};\n\n/**\n * Constructs a Hydra ID for a given UUID and type.\n *\n * @export\n * @param {string} type one of PEOPLE, TEAM, ROOM\n * @param {any} id identifying the \"TYPE\" object\n * @param {string} cluster containing the \"TYPE\" object\n * @returns {string}\n */\nexport function constructHydraId(type = isRequired(), id = isRequired(), cluster = 'us') {\n if (!type.toUpperCase) {\n throw Error('\"type\" must be a string');\n }\n\n if (type === hydraTypes.PEOPLE || type === hydraTypes.ORGANIZATION) {\n // Cluster is always \"us\" for people and orgs\n return encode(`ciscospark://us/${type.toUpperCase()}/${id}`);\n }\n\n return encode(`ciscospark://${cluster}/${type.toUpperCase()}/${id}`);\n}\n\n/**\n * @typedef {Object} DeconstructedHydraId\n * @property {UUID} id identifying the object\n * @property {String} type of the object\n * @property {String} cluster containing the object\n */\n\n/**\n * Deconstructs a Hydra ID.\n *\n * @export\n * @param {String} id Hydra style id\n * @returns {DeconstructedHydraId} deconstructed id\n */\nexport function deconstructHydraId(id) {\n const payload = decode(id).split('/');\n\n return {\n id: payload.pop(),\n type: payload.pop(),\n cluster: payload.pop(),\n };\n}\n\n/**\n * Constructs a Hydra ID for a message based on internal UUID\n *\n * @export\n * @param {any} uuid\n * @param {string} cluster containing the message\n * @returns {string}\n */\nexport function buildHydraMessageId(uuid, cluster) {\n return constructHydraId(hydraTypes.MESSAGE, uuid, cluster);\n}\n\n/**\n * Constructs a Hydra ID for a person based on internal UUID\n *\n * @export\n * @param {any} uuid\n * @param {string} cluster containing the person\n * @returns {string}\n */\nexport function buildHydraPersonId(uuid, cluster) {\n return constructHydraId(hydraTypes.PEOPLE, uuid, cluster);\n}\n\n/**\n * Constructs a Hydra ID for a room based on internal UUID\n *\n * @export\n * @param {any} uuid\n * @param {string} cluster containing the room\n * @returns {string}\n */\nexport function buildHydraRoomId(uuid, cluster) {\n return constructHydraId(hydraTypes.ROOM, uuid, cluster);\n}\n\n/**\n * Constructs a Hydra ID for an organization based on internal UUID\n *\n * @export\n * @param {any} uuid\n * @param {string} cluster containing the organization\n * @returns {string}\n */\nexport function buildHydraOrgId(uuid, cluster) {\n return constructHydraId(hydraTypes.ORGANIZATION, uuid, cluster);\n}\n\n/**\n * Constructs a Hydra ID for an membership based on an\n * internal UUID for the person, and the space\n *\n * @export\n * @param {any} personUUID\n * @param {any} spaceUUID\n * @param {string} cluster containing the membership\n * @returns {string}\n */\nexport function buildHydraMembershipId(personUUID, spaceUUID, cluster) {\n return constructHydraId(hydraTypes.MEMBERSHIP, `${personUUID}:${spaceUUID}`, cluster);\n}\n\n/**\n * Returns a hydra cluster string based on a conversation url\n * @private\n * @memberof Messages\n * @param {Object} webex sdk instance\n * @param {String} conversationUrl url of space where activity took place\n * @returns {String} string suitable for UUID -> public ID encoding\n */\nexport function getHydraClusterString(webex, conversationUrl) {\n const internalClusterString = webex.internal.services.getClusterId(conversationUrl);\n\n if (\n internalClusterString.startsWith(INTERNAL_US_CLUSTER_NAME) ||\n internalClusterString.startsWith(INTERNAL_US_INTEGRATION_CLUSTER_NAME)\n ) {\n // Original US cluster is simply 'us' for backwards compatibility\n return 'us';\n }\n const clusterParts = internalClusterString.split(':');\n\n if (clusterParts.length < 3) {\n throw Error(`Unable to determine cluster for convo: ${conversationUrl}`);\n }\n\n return `${clusterParts[0]}:${clusterParts[1]}:${clusterParts[2]}`;\n}\n\n/**\n * Returns a Hydra roomType based on conversation tags\n *\n * @export\n * @param {arra} tags\n * @
|
|
1
|
+
{"version":3,"names":["hydraBaseUrl","isRequired","Error","constructHydraId","type","id","cluster","toUpperCase","hydraTypes","PEOPLE","ORGANIZATION","encode","deconstructHydraId","payload","decode","split","pop","buildHydraMessageId","uuid","MESSAGE","buildHydraPersonId","buildHydraRoomId","ROOM","buildHydraOrgId","buildHydraMembershipId","personUUID","spaceUUID","MEMBERSHIP","getHydraClusterString","webex","conversationUrl","internalClusterString","internal","services","getClusterId","startsWith","INTERNAL_US_CLUSTER_NAME","INTERNAL_US_INTEGRATION_CLUSTER_NAME","clusterParts","length","getHydraRoomType","tags","includes","SDK_EVENT","INTERNAL","ACTIVITY_TAG","ONE_ON_ONE","EXTERNAL","SPACE_TYPE","DIRECT","GROUP","getHydraFiles","activity","hydraFiles","files","object","items","i","contentId","CONTENT","push"],"sources":["uuid-utils.js"],"sourcesContent":["import {encode, decode} from './base64';\nimport {\n SDK_EVENT,\n hydraTypes,\n INTERNAL_US_CLUSTER_NAME,\n INTERNAL_US_INTEGRATION_CLUSTER_NAME,\n} from './constants';\n\nconst hydraBaseUrl = 'https://api.ciscospark.com/v1';\n\nconst isRequired = () => {\n throw Error('parameter is required');\n};\n\n/**\n * Constructs a Hydra ID for a given UUID and type.\n *\n * @export\n * @param {string} type one of PEOPLE, TEAM, ROOM\n * @param {any} id identifying the \"TYPE\" object\n * @param {string} cluster containing the \"TYPE\" object\n * @returns {string}\n */\nexport function constructHydraId(type = isRequired(), id = isRequired(), cluster = 'us') {\n if (!type.toUpperCase) {\n throw Error('\"type\" must be a string');\n }\n\n if (type === hydraTypes.PEOPLE || type === hydraTypes.ORGANIZATION) {\n // Cluster is always \"us\" for people and orgs\n return encode(`ciscospark://us/${type.toUpperCase()}/${id}`);\n }\n\n return encode(`ciscospark://${cluster}/${type.toUpperCase()}/${id}`);\n}\n\n/**\n * @typedef {Object} DeconstructedHydraId\n * @property {UUID} id identifying the object\n * @property {String} type of the object\n * @property {String} cluster containing the object\n */\n\n/**\n * Deconstructs a Hydra ID.\n *\n * @export\n * @param {String} id Hydra style id\n * @returns {DeconstructedHydraId} deconstructed id\n */\nexport function deconstructHydraId(id) {\n const payload = decode(id).split('/');\n\n return {\n id: payload.pop(),\n type: payload.pop(),\n cluster: payload.pop(),\n };\n}\n\n/**\n * Constructs a Hydra ID for a message based on internal UUID\n *\n * @export\n * @param {any} uuid\n * @param {string} cluster containing the message\n * @returns {string}\n */\nexport function buildHydraMessageId(uuid, cluster) {\n return constructHydraId(hydraTypes.MESSAGE, uuid, cluster);\n}\n\n/**\n * Constructs a Hydra ID for a person based on internal UUID\n *\n * @export\n * @param {any} uuid\n * @param {string} cluster containing the person\n * @returns {string}\n */\nexport function buildHydraPersonId(uuid, cluster) {\n return constructHydraId(hydraTypes.PEOPLE, uuid, cluster);\n}\n\n/**\n * Constructs a Hydra ID for a room based on internal UUID\n *\n * @export\n * @param {any} uuid\n * @param {string} cluster containing the room\n * @returns {string}\n */\nexport function buildHydraRoomId(uuid, cluster) {\n return constructHydraId(hydraTypes.ROOM, uuid, cluster);\n}\n\n/**\n * Constructs a Hydra ID for an organization based on internal UUID\n *\n * @export\n * @param {any} uuid\n * @param {string} cluster containing the organization\n * @returns {string}\n */\nexport function buildHydraOrgId(uuid, cluster) {\n return constructHydraId(hydraTypes.ORGANIZATION, uuid, cluster);\n}\n\n/**\n * Constructs a Hydra ID for an membership based on an\n * internal UUID for the person, and the space\n *\n * @export\n * @param {any} personUUID\n * @param {any} spaceUUID\n * @param {string} cluster containing the membership\n * @returns {string}\n */\nexport function buildHydraMembershipId(personUUID, spaceUUID, cluster) {\n return constructHydraId(hydraTypes.MEMBERSHIP, `${personUUID}:${spaceUUID}`, cluster);\n}\n\n/**\n * Returns a hydra cluster string based on a conversation url\n * @private\n * @memberof Messages\n * @param {Object} webex sdk instance\n * @param {String} conversationUrl url of space where activity took place\n * @returns {String} string suitable for UUID -> public ID encoding\n */\nexport function getHydraClusterString(webex, conversationUrl) {\n const internalClusterString = webex.internal.services.getClusterId(conversationUrl);\n\n if (\n internalClusterString.startsWith(INTERNAL_US_CLUSTER_NAME) ||\n internalClusterString.startsWith(INTERNAL_US_INTEGRATION_CLUSTER_NAME)\n ) {\n // Original US cluster is simply 'us' for backwards compatibility\n return 'us';\n }\n const clusterParts = internalClusterString.split(':');\n\n if (clusterParts.length < 3) {\n throw Error(`Unable to determine cluster for convo: ${conversationUrl}`);\n }\n\n return `${clusterParts[0]}:${clusterParts[1]}:${clusterParts[2]}`;\n}\n\n/**\n * Returns a Hydra roomType based on conversation tags\n *\n * @export\n * @param {arra} tags\n * @returns {string}\n */\nexport function getHydraRoomType(tags) {\n if (tags.includes(SDK_EVENT.INTERNAL.ACTIVITY_TAG.ONE_ON_ONE)) {\n return SDK_EVENT.EXTERNAL.SPACE_TYPE.DIRECT;\n }\n\n return SDK_EVENT.EXTERNAL.SPACE_TYPE.GROUP;\n}\n\n/**\n * Returns file URLs for the activity, adhering to Hydra details,\n * e.g., https://api.ciscospark.com/v1/contents/Y2lzY29zcGF...\n * @see https://developer.webex.com/docs/api/v1/messages/get-message-details\n * @param {Object} activity from mercury\n * @param {string} cluster containing the files\n * @returns {Array} file URLs\n */\nexport function getHydraFiles(activity, cluster) {\n const hydraFiles = [];\n const {files} = activity.object;\n\n if (files) {\n const {items} = files;\n\n // Note: Generated ID is dependent on file order.\n for (let i = 0; i < items.length; i += 1) {\n const contentId = constructHydraId(hydraTypes.CONTENT, `${activity.id}/${i}`, cluster);\n\n hydraFiles.push(`${hydraBaseUrl}/contents/${contentId}`);\n }\n }\n\n return hydraFiles;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AAOA,IAAMA,YAAY,GAAG,+BAA+B;AAEpD,IAAMC,UAAU,GAAG,SAAbA,UAAU,GAAS;EACvB,MAAMC,KAAK,CAAC,uBAAuB,CAAC;AACtC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgB,GAAyD;EAAA,IAAxDC,IAAI,uEAAGH,UAAU,EAAE;EAAA,IAAEI,EAAE,uEAAGJ,UAAU,EAAE;EAAA,IAAEK,OAAO,uEAAG,IAAI;EACrF,IAAI,CAACF,IAAI,CAACG,WAAW,EAAE;IACrB,MAAML,KAAK,CAAC,yBAAyB,CAAC;EACxC;EAEA,IAAIE,IAAI,KAAKI,qBAAU,CAACC,MAAM,IAAIL,IAAI,KAAKI,qBAAU,CAACE,YAAY,EAAE;IAClE;IACA,OAAO,IAAAC,YAAM,4BAAoBP,IAAI,CAACG,WAAW,EAAE,cAAIF,EAAE,EAAG;EAC9D;EAEA,OAAO,IAAAM,YAAM,yBAAiBL,OAAO,cAAIF,IAAI,CAACG,WAAW,EAAE,cAAIF,EAAE,EAAG;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,kBAAkB,CAACP,EAAE,EAAE;EACrC,IAAMQ,OAAO,GAAG,IAAAC,YAAM,EAACT,EAAE,CAAC,CAACU,KAAK,CAAC,GAAG,CAAC;EAErC,OAAO;IACLV,EAAE,EAAEQ,OAAO,CAACG,G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,IAAI,WAAI5D,YAAY,uBAAa0D,SAAS,EAAG;IAC1D;EACF;EAEA,OAAOL,UAAU;AACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/common",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.415",
|
|
4
4
|
"description": "Common utilities for Cisco Webex",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@sinonjs/fake-timers": "^6.0.1",
|
|
28
|
-
"@webex/common": "3.0.0-beta.
|
|
29
|
-
"@webex/test-helper-chai": "3.0.0-beta.
|
|
28
|
+
"@webex/common": "3.0.0-beta.415",
|
|
29
|
+
"@webex/test-helper-chai": "3.0.0-beta.415",
|
|
30
30
|
"ampersand-state": "^5.0.3",
|
|
31
31
|
"sinon": "^9.2.4"
|
|
32
32
|
},
|
package/src/uuid-utils.js
CHANGED
|
@@ -12,7 +12,7 @@ import {browserDetection} from '@webex/common/src/constants.js';
|
|
|
12
12
|
describe('getBowserSerial()', () => {
|
|
13
13
|
const originalWindowNavigator = {...window.navigator};
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
afterEach(() => {
|
|
16
16
|
window.navigator = originalWindowNavigator;
|
|
17
17
|
});
|
|
18
18
|
|