From 8d7aa4dad99f6b6ce43c56d6577aa5e932aa84e4 Mon Sep 17 00:00:00 2001 From: Casey Occhialini <1508707+littlespex@users.noreply.github.com> Date: Fri, 28 Apr 2023 16:25:12 -0700 Subject: [PATCH] release/0.2.0 (#15) * feat: Update CMCD APIs * feat: Add namespaced exports * chore: add aliases to readme and license files --- CHANGELOG.md | 12 +++++++- LICENSE.md | 22 +-------------- README.md | 6 +--- dev/package.json | 2 +- ...ders.test.ts => appendCmcdHeaders.test.ts} | 6 ++-- ...dToUrl.test.ts => appendCmcdQuery.test.ts} | 8 +++--- ...{toHeader.test.ts => toCmcdHeader.test.ts} | 9 +++--- dev/src/cmcd/toCmcdJson.test.ts | 14 ++++++++++ dev/src/cmcd/toCmcdQuery.test.ts | 14 ++++++++++ dev/src/cmcd/toJson.test.ts | 14 ---------- dev/src/cmcd/toQuery.test.ts | 14 ---------- docs/package.json | 2 +- lib/README.md | 28 ++++++++++++++++++- lib/package.json | 6 +++- lib/src/cmcd.ts | 19 +++++++++++++ lib/src/cmcd/appendCmcdHeaders.ts | 11 ++++++++ .../{appendToUrl.ts => appendCmcdQuery.ts} | 6 ++-- lib/src/cmcd/appendToHeaders.ts | 11 -------- lib/src/cmcd/index.ts | 18 ------------ .../cmcd/{toHeaders.ts => toCmcdHeaders.ts} | 2 +- lib/src/cmcd/{toJson.ts => toCmcdJson.ts} | 2 +- lib/src/cmcd/{toQuery.ts => toCmcdQuery.ts} | 2 +- lib/src/index.ts | 4 +-- lib/src/utils.ts | 1 + lib/src/utils/index.ts | 1 - package-lock.json | 10 +++---- package.json | 2 +- tsconfig.json | 5 +++- 28 files changed, 135 insertions(+), 116 deletions(-) mode change 100644 => 120000 LICENSE.md mode change 100644 => 120000 README.md rename dev/src/cmcd/{appendToHeaders.test.ts => appendCmcdHeaders.test.ts} (63%) rename dev/src/cmcd/{appendToUrl.test.ts => appendCmcdQuery.test.ts} (55%) rename dev/src/cmcd/{toHeader.test.ts => toCmcdHeader.test.ts} (74%) create mode 100644 dev/src/cmcd/toCmcdJson.test.ts create mode 100644 dev/src/cmcd/toCmcdQuery.test.ts delete mode 100644 dev/src/cmcd/toJson.test.ts delete mode 100644 dev/src/cmcd/toQuery.test.ts create mode 100644 lib/src/cmcd.ts create mode 100644 lib/src/cmcd/appendCmcdHeaders.ts rename lib/src/cmcd/{appendToUrl.ts => appendCmcdQuery.ts} (58%) delete mode 100644 lib/src/cmcd/appendToHeaders.ts delete mode 100644 lib/src/cmcd/index.ts rename lib/src/cmcd/{toHeaders.ts => toCmcdHeaders.ts} (95%) rename lib/src/cmcd/{toJson.ts => toCmcdJson.ts} (85%) rename lib/src/cmcd/{toQuery.ts => toCmcdQuery.ts} (80%) create mode 100644 lib/src/utils.ts delete mode 100644 lib/src/utils/index.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 2af19f91..72c6534b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.2.0] - 2023-04-28 + +### Changed +- Update CMCD APIs + +### Added +- Add namespaced exports + + ## [0.1.2] - 2023-04-28 ### Fixed @@ -37,7 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bootstrap project [#2](https://github.com/streaming-video-technology-alliance/common-media-library/issues/2) -[Unreleased]\: https://github.com/streaming-video-technology-alliance/common-media-library/compare/v0.1.2...HEAD +[Unreleased]\: https://github.com/streaming-video-technology-alliance/common-media-library/compare/v0.2.0...HEAD +[0.2.0]\: https://github.com/streaming-video-technology-alliance/common-media-library/compare/v0.1.2...v0.2.0 [0.1.2]\: https://github.com/streaming-video-technology-alliance/common-media-library/compare/v0.1.1...v0.1.2 [0.1.1]\: https://github.com/streaming-video-technology-alliance/common-media-library/compare/v0.1.0...v0.1.1 [0.1.0]\: https://github.com/streaming-video-technology-alliance/common-media-library/compare/v0.0.0...v0.1.0 diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 4cf3c2c7..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 The Streaming Video Technology Alliance (SVTA). - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/LICENSE.md b/LICENSE.md new file mode 120000 index 00000000..332f7a67 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1 @@ +lib/LICENSE.md \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index fda100e7..00000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# common-media-library -A common library for media playback in JavaScript - -## Project structure -This project is a mono-repo with two packages: dev and lib. The lib package contains the compiled code for the library. The lib package is published to npm. The dev package contains code to develop and test the lib package. The dev package is not published to npm. diff --git a/README.md b/README.md new file mode 120000 index 00000000..5be180e3 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +lib/README.md \ No newline at end of file diff --git a/dev/package.json b/dev/package.json index 00747119..ca933aa0 100644 --- a/dev/package.json +++ b/dev/package.json @@ -1,6 +1,6 @@ { "name": "@svta.org/common-media-library-dev", - "version": "0.1.2", + "version": "0.2.0", "license": "MIT", "type": "module", "homepage": "https://github.com/streaming-video-technology-alliance/common-media-library", diff --git a/dev/src/cmcd/appendToHeaders.test.ts b/dev/src/cmcd/appendCmcdHeaders.test.ts similarity index 63% rename from dev/src/cmcd/appendToHeaders.test.ts rename to dev/src/cmcd/appendCmcdHeaders.test.ts index e3635c06..e34a1140 100644 --- a/dev/src/cmcd/appendToHeaders.test.ts +++ b/dev/src/cmcd/appendCmcdHeaders.test.ts @@ -1,4 +1,4 @@ -import { appendToHeaders } from '@svta.org/common-media-library/cmcd/appendToHeaders'; +import { appendCmcdHeaders } from '@svta.org/common-media-library'; import { deepEqual } from 'node:assert'; import { describe, it } from 'node:test'; @@ -12,11 +12,11 @@ describe('CMCD appendToHeaders', () => { }; it('handles null data object', () => { - deepEqual(appendToHeaders(headers, null as any), headers); + deepEqual(appendCmcdHeaders(headers, null as any), headers); }); it('appends headers', () => { - deepEqual(appendToHeaders(headers, data), { + deepEqual(appendCmcdHeaders(headers, data), { ...headers, ['CMCD-Object']: 'br=1000', }); diff --git a/dev/src/cmcd/appendToUrl.test.ts b/dev/src/cmcd/appendCmcdQuery.test.ts similarity index 55% rename from dev/src/cmcd/appendToUrl.test.ts rename to dev/src/cmcd/appendCmcdQuery.test.ts index 27a02c0c..4ed25e12 100644 --- a/dev/src/cmcd/appendToUrl.test.ts +++ b/dev/src/cmcd/appendCmcdQuery.test.ts @@ -1,4 +1,4 @@ -import { appendToUrl } from '@svta.org/common-media-library/cmcd/appendToUrl'; +import { appendCmcdQuery } from '@svta.org/common-media-library'; import { equal } from 'node:assert'; import { describe, it } from 'node:test'; @@ -9,14 +9,14 @@ describe('CMCD appendToUrl', () => { }; it('handles null data object', () => { - equal(appendToUrl(null as any, url), url); + equal(appendCmcdQuery(null as any, url), url); }); it('add ? when query does not exist', () => { - equal(appendToUrl(data, url), `${url}?CMCD=br%3D1000`); + equal(appendCmcdQuery(data, url), `${url}?CMCD=br%3D1000`); }); it('add & when query does exist', () => { - equal(appendToUrl(data, `${url}?hello=world`), `${url}?hello=world&CMCD=br%3D1000`); + equal(appendCmcdQuery(data, `${url}?hello=world`), `${url}?hello=world&CMCD=br%3D1000`); }); }); diff --git a/dev/src/cmcd/toHeader.test.ts b/dev/src/cmcd/toCmcdHeader.test.ts similarity index 74% rename from dev/src/cmcd/toHeader.test.ts rename to dev/src/cmcd/toCmcdHeader.test.ts index 64fe96e1..c5c36800 100644 --- a/dev/src/cmcd/toHeader.test.ts +++ b/dev/src/cmcd/toCmcdHeader.test.ts @@ -1,5 +1,4 @@ -import { CmcdHeaderField } from '@svta.org/common-media-library/cmcd/CmcdHeaderField'; -import { toHeaders } from '@svta.org/common-media-library/cmcd/toHeaders'; +import { CmcdHeaderField, toCmcdHeaders } from '@svta.org/common-media-library'; import { deepEqual } from 'node:assert'; import { describe, it } from 'node:test'; import { data } from './data.js'; @@ -13,7 +12,7 @@ const customHeaderMap = { describe('CMCD Header serialization', () => { it('produces all shards', () => { - deepEqual(toHeaders(data, { customHeaderMap }), { + deepEqual(toCmcdHeaders(data, { customHeaderMap }), { 'CMCD-Object': 'br=200,com.example-hello="world",d=325,ot=m', 'CMCD-Request': 'com.example-quote="\\"Quote\\"",com.example-token=s,mtp=10049,nor="..%2Ftesting%2F3.m4v",nrr="0-99"', 'CMCD-Session': 'cid="content-id",com.example-testing=1234,sid="session-id"', @@ -22,12 +21,12 @@ describe('CMCD Header serialization', () => { }); it('ignores empty shards', () => { - deepEqual(toHeaders({ br: 200 }), { + deepEqual(toCmcdHeaders({ br: 200 }), { 'CMCD-Object': 'br=200', }); }); it('handles null data object', () => { - deepEqual(toHeaders(null as any), {}); + deepEqual(toCmcdHeaders(null as any), {}); }); }); diff --git a/dev/src/cmcd/toCmcdJson.test.ts b/dev/src/cmcd/toCmcdJson.test.ts new file mode 100644 index 00000000..0048729c --- /dev/null +++ b/dev/src/cmcd/toCmcdJson.test.ts @@ -0,0 +1,14 @@ +import { toCmcdJson } from '@svta.org/common-media-library'; +import { equal } from 'node:assert'; +import { describe, it } from 'node:test'; +import { data } from './data.js'; + +describe('CMCD JSON serialization', () => { + it('produces json', () => { + equal(toCmcdJson(data), '{"br":200,"bs":true,"cid":"content-id","com.example-exists":true,"com.example-hello":"world","com.example-quote":"\\"Quote\\"","com.example-testing":1234,"com.example-token":"s","d":325,"mtp":10049,"nor":"..%2Ftesting%2F3.m4v","nrr":"0-99","ot":"m","sid":"session-id"}'); + }); + + it('handles empty data', () => { + equal(toCmcdJson(null as any), '{}'); + }); +}); diff --git a/dev/src/cmcd/toCmcdQuery.test.ts b/dev/src/cmcd/toCmcdQuery.test.ts new file mode 100644 index 00000000..adecacdf --- /dev/null +++ b/dev/src/cmcd/toCmcdQuery.test.ts @@ -0,0 +1,14 @@ +import { toCmcdQuery } from '@svta.org/common-media-library'; +import { equal } from 'node:assert'; +import { describe, it } from 'node:test'; +import { data } from './data.js'; + +describe('CMCD Query serialization', () => { + it('handles null data object', () => { + equal(toCmcdQuery(null as any), ''); + }); + + it('returns encoded query string', () => { + equal(toCmcdQuery(data), 'CMCD=br%3D200%2Cbs%2Ccid%3D%22content-id%22%2Ccom.example-exists%2Ccom.example-hello%3D%22world%22%2Ccom.example-quote%3D%22%5C%22Quote%5C%22%22%2Ccom.example-testing%3D1234%2Ccom.example-token%3Ds%2Cd%3D325%2Cmtp%3D10049%2Cnor%3D%22..%252Ftesting%252F3.m4v%22%2Cnrr%3D%220-99%22%2Cot%3Dm%2Csid%3D%22session-id%22'); + }); +}); diff --git a/dev/src/cmcd/toJson.test.ts b/dev/src/cmcd/toJson.test.ts deleted file mode 100644 index 203ac65d..00000000 --- a/dev/src/cmcd/toJson.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { toJson } from '@svta.org/common-media-library/cmcd/toJson'; -import { equal } from 'node:assert'; -import { describe, it } from 'node:test'; -import { data } from './data.js'; - -describe('CMCD JSON serialization', () => { - it('produces json', () => { - equal(toJson(data), '{"br":200,"bs":true,"cid":"content-id","com.example-exists":true,"com.example-hello":"world","com.example-quote":"\\"Quote\\"","com.example-testing":1234,"com.example-token":"s","d":325,"mtp":10049,"nor":"..%2Ftesting%2F3.m4v","nrr":"0-99","ot":"m","sid":"session-id"}'); - }); - - it('handles empty data', () => { - equal(toJson(null as any), '{}'); - }); -}); diff --git a/dev/src/cmcd/toQuery.test.ts b/dev/src/cmcd/toQuery.test.ts deleted file mode 100644 index b1f0c5ee..00000000 --- a/dev/src/cmcd/toQuery.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { toQuery } from '@svta.org/common-media-library/cmcd/toQuery'; -import { equal } from 'node:assert'; -import { describe, it } from 'node:test'; -import { data } from './data.js'; - -describe('CMCD Query serialization', () => { - it('handles null data object', () => { - equal(toQuery(null as any), ''); - }); - - it('returns encoded query string', () => { - equal(toQuery(data), 'CMCD=br%3D200%2Cbs%2Ccid%3D%22content-id%22%2Ccom.example-exists%2Ccom.example-hello%3D%22world%22%2Ccom.example-quote%3D%22%5C%22Quote%5C%22%22%2Ccom.example-testing%3D1234%2Ccom.example-token%3Ds%2Cd%3D325%2Cmtp%3D10049%2Cnor%3D%22..%252Ftesting%252F3.m4v%22%2Cnrr%3D%220-99%22%2Cot%3Dm%2Csid%3D%22session-id%22'); - }); -}); diff --git a/docs/package.json b/docs/package.json index fa4de8d7..df98b416 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "name": "@svta.org/common-media-library-docs", - "version": "0.1.2", + "version": "0.2.0", "license": "MIT", "type": "module", "homepage": "https://github.com/streaming-video-technology-alliance/common-media-library", diff --git a/lib/README.md b/lib/README.md index 791c452c..4d9cf025 100644 --- a/lib/README.md +++ b/lib/README.md @@ -1,4 +1,30 @@ # common-media-library -A common library for media playback in JavaScript. +A common library for media playback in JavaScript Looking at open source players like [hls.js](https://github.com/video-dev/hls.js/), [dash.js](https://github.com/Dash-Industry-Forum/dash.js/) and [shaka-player](https://github.com/shaka-project/shaka-player) there are common pieces of functionality that have been implemented independently, and sometimes copy and pasted, across the libraries. This is particularly true when looking at standards based features, like ID3 parsing, 608 parsing and CMCD. Since the functionality is shared in spirit but not implementation, they can fall out of sync where certain bugs are fixed in one player but not the others. The goal of this library is to create a single place where these utilities can be maintained and distributed. + +## Project structure +This project is a mono-repo with three workspaces: `dev`, `lib` and `docs`. The lib package contains the compiled code for the library which is published to npm. The dev package contains code to develop and test the lib package and is not published to npm. The docs package contains the documentation for the library and is published to GitHub pages. + +## Installation +```bash +npm install @scta/common-media-library +``` + +## Usage +```typescript +import { appendCmcdQuery, CmcdObjectType } from '@svta.org/common-media-library'; + +const url = 'https://example.com/playlist.m3u8'; +const cmcd = { + sid: '4f2867f2-b0fd-4db7-a3e0-cea7dff44cfb', + cid: 'cc002fc3-d9e1-418d-9a5f-3d0eac601882', + d: 324.69, + ot: CmcdObjectType.MANIFEST, + ['com.example-hello']: 'world', +}; + +const cmcdUrl = appendCmcdQuery(cmcd, url); +console.log(cmcdUrl); +// https://example.com/playlist.m3u8?CMCD=cid%3D%22cc002fc3-d9e1-418d-9a5f-3d0eac601882%22%2Ccom.example-hello%3D%22world%22%2Cd%3D325%2Cot%3Dm%2Csid%3D%224f2867f2-b0fd-4db7-a3e0-cea7dff44cfb%22 +``` diff --git a/lib/package.json b/lib/package.json index 1aa79ff7..f80ca47a 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,6 +1,6 @@ { "name": "@svta.org/common-media-library", - "version": "0.1.2", + "version": "0.2.0", "license": "MIT", "type": "module", "homepage": "https://github.com/streaming-video-technology-alliance/common-media-library", @@ -22,6 +22,10 @@ "dist/**/*" ], "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, "./*": { "types": "./dist/*.d.ts", "default": "./dist/*.js" diff --git a/lib/src/cmcd.ts b/lib/src/cmcd.ts new file mode 100644 index 00000000..24397603 --- /dev/null +++ b/lib/src/cmcd.ts @@ -0,0 +1,19 @@ +export type { Cmcd } from './cmcd/Cmcd.js'; +export type { CmcdCustomKey } from './cmcd/CmcdCustomKey.js'; +export type { CmcdEncodeOptions } from './cmcd/CmcdEncodeOptions.js'; +export { CmcdEncoding } from './cmcd/CmcdEncoding.js'; +export type { CmcdFormatter } from './cmcd/CmcdFormatter.js'; +export { CmcdHeaderField } from './cmcd/CmcdHeaderField.js'; +export type { CmcdKey } from './cmcd/CmcdKey.js'; +export { CmcdObjectType } from './cmcd/CmcdObjectType.js'; +export { CmcdStreamType } from './cmcd/CmcdStreamType.js'; +export { CmcdStreamingFormat } from './cmcd/CmcdStreamingFormat.js'; +export type { CmcdValue } from './cmcd/CmcdValue.js'; +export { appendCmcdHeaders } from './cmcd/appendCmcdHeaders.js'; +export { appendCmcdQuery } from './cmcd/appendCmcdQuery.js'; +export { decodeCmcd } from './cmcd/decodeCmcd.js'; +export { encodeCmcd } from './cmcd/encodeCmcd.js'; +export { toCmcdHeaders } from './cmcd/toCmcdHeaders.js'; +export { toCmcdJson } from './cmcd/toCmcdJson.js'; +export { toCmcdQuery } from './cmcd/toCmcdQuery.js'; + diff --git a/lib/src/cmcd/appendCmcdHeaders.ts b/lib/src/cmcd/appendCmcdHeaders.ts new file mode 100644 index 00000000..4b66d8e7 --- /dev/null +++ b/lib/src/cmcd/appendCmcdHeaders.ts @@ -0,0 +1,11 @@ +import { Cmcd } from './Cmcd.js'; +import { CmcdCustomKey } from './CmcdCustomKey.js'; +import { CmcdHeaderField } from './CmcdHeaderField.js'; +import { toCmcdHeaders } from './toCmcdHeaders.js'; + +/** + * Append CMCD query args to a header object. + */ +export function appendCmcdHeaders(headers: Record, cmcd: Cmcd, customHeaderMap?: Record) { + return Object.assign(headers, toCmcdHeaders(cmcd, customHeaderMap)); +} diff --git a/lib/src/cmcd/appendToUrl.ts b/lib/src/cmcd/appendCmcdQuery.ts similarity index 58% rename from lib/src/cmcd/appendToUrl.ts rename to lib/src/cmcd/appendCmcdQuery.ts index e8807f17..45c81bc6 100644 --- a/lib/src/cmcd/appendToUrl.ts +++ b/lib/src/cmcd/appendCmcdQuery.ts @@ -1,11 +1,11 @@ import { Cmcd } from './Cmcd.js'; -import { toQuery } from './toQuery.js'; +import { toCmcdQuery } from './toCmcdQuery.js'; /** * Append CMCD query args to a URL. */ -export function appendToUrl(cmcd: Cmcd, url: string) { - const query = toQuery(cmcd); +export function appendCmcdQuery(cmcd: Cmcd, url: string) { + const query = toCmcdQuery(cmcd); if (!query) { return url; } diff --git a/lib/src/cmcd/appendToHeaders.ts b/lib/src/cmcd/appendToHeaders.ts deleted file mode 100644 index 997c1077..00000000 --- a/lib/src/cmcd/appendToHeaders.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Cmcd } from './Cmcd.js'; -import { CmcdCustomKey } from './CmcdCustomKey.js'; -import { CmcdHeaderField } from './CmcdHeaderField.js'; -import { toHeaders } from './toHeaders.js'; - -/** - * Append CMCD query args to a header object. - */ -export function appendToHeaders(headers: Record, cmcd: Cmcd, customHeaderMap?: Record) { - return Object.assign(headers, toHeaders(cmcd, customHeaderMap)); -} diff --git a/lib/src/cmcd/index.ts b/lib/src/cmcd/index.ts deleted file mode 100644 index ed61dc2f..00000000 --- a/lib/src/cmcd/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -export type { Cmcd } from './Cmcd.js'; -export type { CmcdCustomKey } from './CmcdCustomKey.js'; -export type { CmcdEncodeOptions } from './CmcdEncodeOptions.js'; -export { CmcdEncoding } from './CmcdEncoding.js'; -export type { CmcdFormatter } from './CmcdFormatter.js'; -export { CmcdHeaderField } from './CmcdHeaderField.js'; -export type { CmcdKey } from './CmcdKey.js'; -export { CmcdObjectType } from './CmcdObjectType.js'; -export { CmcdStreamType } from './CmcdStreamType.js'; -export { CmcdStreamingFormat } from './CmcdStreamingFormat.js'; -export type { CmcdValue } from './CmcdValue.js'; -export { appendToHeaders } from './appendToHeaders.js'; -export { appendToUrl } from './appendToUrl.js'; -export { decodeCmcd } from './decodeCmcd.js'; -export { encodeCmcd } from './encodeCmcd.js'; -export { toHeaders } from './toHeaders.js'; -export { toJson } from './toJson.js'; -export { toQuery } from './toQuery.js'; diff --git a/lib/src/cmcd/toHeaders.ts b/lib/src/cmcd/toCmcdHeaders.ts similarity index 95% rename from lib/src/cmcd/toHeaders.ts rename to lib/src/cmcd/toCmcdHeaders.ts index d857347c..3233bfd2 100644 --- a/lib/src/cmcd/toHeaders.ts +++ b/lib/src/cmcd/toCmcdHeaders.ts @@ -18,7 +18,7 @@ const toHeaderCase = (value: string) => `${value[0].toUpperCase()}${value.slice( /** * Convert a CMCD data object to request headers */ -export function toHeaders(cmcd: Cmcd, options: CmcdEncodeOptions = {}) { +export function toCmcdHeaders(cmcd: Cmcd, options: CmcdEncodeOptions = {}) { const results: Record = {}; if (!cmcd) { diff --git a/lib/src/cmcd/toJson.ts b/lib/src/cmcd/toCmcdJson.ts similarity index 85% rename from lib/src/cmcd/toJson.ts rename to lib/src/cmcd/toCmcdJson.ts index 8de2c51a..e7697a22 100644 --- a/lib/src/cmcd/toJson.ts +++ b/lib/src/cmcd/toCmcdJson.ts @@ -6,7 +6,7 @@ import { processCmcd } from './processCmcd.js'; /** * Convert a CMCD data object to JSON */ -export function toJson(cmcd: Partial, options?: CmcdEncodeOptions) { +export function toCmcdJson(cmcd: Partial, options?: CmcdEncodeOptions) { const toValue = (value: CmcdValue) => typeof value == 'symbol' ? value.description : value; const data = processCmcd(cmcd, (key, value) => [key, toValue(value)], options); diff --git a/lib/src/cmcd/toQuery.ts b/lib/src/cmcd/toCmcdQuery.ts similarity index 80% rename from lib/src/cmcd/toQuery.ts rename to lib/src/cmcd/toCmcdQuery.ts index 023b0f81..98cdcc2c 100644 --- a/lib/src/cmcd/toQuery.ts +++ b/lib/src/cmcd/toCmcdQuery.ts @@ -5,7 +5,7 @@ import { encodeCmcd } from './encodeCmcd.js'; /** * Convert a CMCD data object to query args */ -export function toQuery(cmcd: Cmcd, options: CmcdEncodeOptions = {}) { +export function toCmcdQuery(cmcd: Cmcd, options: CmcdEncodeOptions = {}) { if (!cmcd) { return ''; } diff --git a/lib/src/index.ts b/lib/src/index.ts index 8b5253f7..0efafd4c 100644 --- a/lib/src/index.ts +++ b/lib/src/index.ts @@ -1,3 +1,3 @@ -export * from './cmcd/index.js'; -export * from './utils/index.js'; +export * from './cmcd.js'; +export * from './utils.js'; diff --git a/lib/src/utils.ts b/lib/src/utils.ts new file mode 100644 index 00000000..9f7aa4f5 --- /dev/null +++ b/lib/src/utils.ts @@ -0,0 +1 @@ +export * from './utils/uuid.js'; diff --git a/lib/src/utils/index.ts b/lib/src/utils/index.ts deleted file mode 100644 index 1b6e6458..00000000 --- a/lib/src/utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './uuid.js'; diff --git a/package-lock.json b/package-lock.json index 64e2fbc7..aca00a5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@svta.org/common-media-library-workspace", - "version": "0.1.2", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@svta.org/common-media-library-workspace", - "version": "0.1.2", + "version": "0.2.0", "license": "MIT", "workspaces": [ "dev", @@ -26,7 +26,7 @@ }, "dev": { "name": "@svta.org/common-media-library-dev", - "version": "0.1.2", + "version": "0.2.0", "license": "MIT", "devDependencies": { "@svta.org/common-media-library": "*" @@ -34,7 +34,7 @@ }, "docs": { "name": "@svta.org/common-media-library-docs", - "version": "0.1.2", + "version": "0.2.0", "license": "MIT", "devDependencies": { "typedoc": "^0.24.6" @@ -42,7 +42,7 @@ }, "lib": { "name": "@svta.org/common-media-library", - "version": "0.1.2", + "version": "0.2.0", "license": "MIT" }, "node_modules/@cspotcode/source-map-support": { diff --git a/package.json b/package.json index e4e688d9..f936f394 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@svta.org/common-media-library-workspace", - "version": "0.1.2", + "version": "0.2.0", "license": "MIT", "type": "module", "homepage": "https://github.com/streaming-video-technology-alliance/common-media-library", diff --git a/tsconfig.json b/tsconfig.json index df357736..3df94211 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,5 +37,8 @@ "**/dist", "**/node_modules", "**/docs" - ] + ], + "ts-node": { + "esm": true + } }