From d854c49ba9686f949bb9cabdee38ef6f3a20dc71 Mon Sep 17 00:00:00 2001 From: Casey Occhialini <1508707+littlespex@users.noreply.github.com> Date: Mon, 8 Nov 2021 10:04:45 -0800 Subject: [PATCH] Doc update --- README.md | 39 +++++++++++++++++++++++++-------------- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 4c688d6..9cce658 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ All CMCD properties are optional. Properties that with nullish values will not b ```typescript import { Cmcd, - CmcdHeaader, + CmcdHeader, CmcdObjectType, CmcdStreamingFormat, CmcdStreamType, @@ -35,7 +35,7 @@ const data: Cmcd = { const query = toQuery(data); console.log(query); /* -'CMCD=br%3D200%2Cbs%2Cmtp%3D10000%2Cot%3Dm%2Csf%3Dd%2Ccid%3D%229f7f349b-baba-43d7-bbe7-b0dc8a65af0d%22%2Cst%3Dv' +'CMCD=br%3D200%2Cbs%2Ccid%3D%229f7f349b-baba-43d7-bbe7-b0dc8a65af0d%22%2Cmtp%3D10000%2Cot%3Dm%2Csf%3Dd%2Cst%3Dv' */ const headers = toHeaders(data); @@ -44,38 +44,49 @@ console.log(headers); { 'CMCD-Object': 'br=200,ot=m', 'CMCD-Request': 'mtp=10000', - 'CMCD-Session': 'sf=d,cid="9f7f349b-baba-43d7-bbe7-b0dc8a65af0d",st=v', - 'CMCD-Status': 'bs', + 'CMCD-Session': 'cid="9f7f349b-baba-43d7-bbe7-b0dc8a65af0d",sf=d,st=v', + 'CMCD-Status': 'bs' } */ const json = toJson(data); console.log(json); /* -'{"mtp":10000,"su":false,"br":200,"ot":"m","sf":"d","cid":"9f7f349b-baba-43d7-bbe7-b0dc8a65af0d","st":"v","bs":true}' +'{"br":200,"bs":true,"cid":"9f7f349b-baba-43d7-bbe7-b0dc8a65af0d","mtp":10000,"ot":"m","sf":"d","st":"v"}' */ -/* Custom Fields */ +/** + * Custom Fields + */ + data['com.example-a'] = 'hello'; -data['com.example-b']: 1234; -data['com.example-c']: true; -data['com.example-d']: Symbol('s'); +data['com.example-b'] = 1234; +data['com.example-c'] = true; +data['com.example-d'] = Symbol('s'); + +console.log(toQuery(data)); +/* +'CMCD=br%3D200%2Cbs%2Ccid%3D%229f7f349b-baba-43d7-bbe7-b0dc8a65af0d%22%2Ccom.example-a%3D%22hello%22%2Ccom.example-b%3D1234%2Ccom.example-c%2Ccom.example-d%3Ds%2Cmtp%3D10000%2Cot%3Dm%2Csf%3Dd%2Cst%3Dv' +*/ +/** + * Custom fields can be mapped to specific headers by providing a mapping + * object to the `toHeader` function. Unmapped custom fields are added to + * the CMCD-Request header. + */ const headerMap = { ['com.example-a']: CmcdHeader.Object, ['com.example-b']: CmcdHeader.Session, ['com.example-c']: CmcdHeader.Status, - // Unmapped custom fields are added to the CMCD-Request header }; -const headers = toHeaders(data, headerMap); -console.log(headers); +console.log(toHeaders(data, headerMap)); /* { 'CMCD-Object': 'br=200,com.example-a="hello",ot=m', - 'CMCD-Request': 'mtp=10000', + 'CMCD-Request': 'com.example-d=s,mtp=10000', 'CMCD-Session': 'cid="9f7f349b-baba-43d7-bbe7-b0dc8a65af0d",com.example-b=1234,sf=d,st=v', - 'CMCD-Status': 'bs,com.example-c', + 'CMCD-Status': 'bs,com.example-c' } */ ``` diff --git a/package-lock.json b/package-lock.json index e4b632f..600d1d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cmcd.js", - "version": "0.6.1", + "version": "0.6.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "cmcd.js", - "version": "0.6.1", + "version": "0.6.2", "license": "ISC", "devDependencies": { "@types/jest": "27.0.2", diff --git a/package.json b/package.json index 860739b..5c0c433 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cmcd.js", - "version": "0.6.1", + "version": "0.6.2", "description": "CMCD (Common Media Client Data) library with Typescript definitions", "main": "dist/cmcd.min.js", "types": "dist/types/index.d.ts",