@1mill/cloudevents 4.1.1 → 4.2.1
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/CHANGELOG.md +10 -1
- package/README.md +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/index.js +8 -0
- package/src/tests/datacontenttype.test.js +8 -8
- package/src/tests/dataschema.test.js +1 -1
- package/src/tests/id.test.js +1 -1
- package/src/tests/originatorid.test.js +2 -2
- package/src/tests/originid.test.js +1 -1
- package/src/tests/originsource.test.js +1 -1
- package/src/tests/origintime.test.js +1 -1
- package/src/tests/origintype.test.js +1 -1
- package/src/tests/source.test.js +1 -1
- package/src/tests/subjest.test.js +1 -1
- package/src/tests/time.test.js +1 -1
- package/src/tests/wschannelid.test.js +39 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog for @1mill/cloudevents
|
|
2
2
|
|
|
3
|
+
## 4.2.1
|
|
4
|
+
|
|
5
|
+
* Upgrade to `microbundle@^0.15.1`
|
|
6
|
+
|
|
7
|
+
## 4.2.0
|
|
8
|
+
|
|
9
|
+
* Add optional `wschannelid` attribute.
|
|
10
|
+
* Fix unit test description.
|
|
11
|
+
|
|
3
12
|
## 4.1.1
|
|
4
13
|
|
|
5
14
|
* Improve formatting of code.
|
|
@@ -7,7 +16,7 @@
|
|
|
7
16
|
|
|
8
17
|
## 4.1.0
|
|
9
18
|
|
|
10
|
-
* Add
|
|
19
|
+
* Add optional `originatorid` attribute.
|
|
11
20
|
* Add unit tests for every Cloudevent attribute (e.g. `id`, `data`, `originid`, etc.) using `mocha`, `sinon`, and `chai`.
|
|
12
21
|
* Update `nanoid@^3.3.4`
|
|
13
22
|
|
package/README.md
CHANGED
|
@@ -83,6 +83,7 @@ console.log(enrichedCloudevent)
|
|
|
83
83
|
| origintime | yes | String | "time" property | "time" property is internally generated as part of the package |
|
|
84
84
|
| origintype | yes | String | "type" property | |
|
|
85
85
|
| originatorid | | String | | |
|
|
86
|
+
| wschannelid | | String | | |
|
|
86
87
|
|
|
87
88
|
## Release new version
|
|
88
89
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=require("nanoid"),n=function(e,n){if("undefined"!=typeof process)return process.env[e]||n},t=function(e){var n=e.cloudevent,t=e.name,i=e.types,a=void 0===i?[]:i,o=e.value;if(a.length>0&&!a.includes(typeof o)){var r='Cloudevent "'+t+'" must be of type '+a.map(function(e){return e.toUpperCase()}).sort().join(" or ")+".";throw new Error(r)}n[t]=o};exports.Cloudevent=function(i){var a=i.data,o=i.datacontenttype,r=i.dataschema,u=i.originatorid,s=i.originid,
|
|
1
|
+
var e=require("nanoid"),n=function(e,n){if("undefined"!=typeof process)return process.env[e]||n},t=function(e){var n=e.cloudevent,t=e.name,i=e.types,a=void 0===i?[]:i,o=e.value;if(a.length>0&&!a.includes(typeof o)){var r='Cloudevent "'+t+'" must be of type '+a.map(function(e){return e.toUpperCase()}).sort().join(" or ")+".";throw new Error(r)}n[t]=o};exports.Cloudevent=function(i){var a=i.data,o=i.datacontenttype,r=i.dataschema,u=i.originatorid,s=i.originid,d=i.originsource,v=i.origintime,l=i.origintype,c=i.source,p=i.specversion,g=i.subject,y=i.type,m=i.wschannelid,f=this,h=e.nanoid(n("MILL_CLOUDEVENTS_NANOID_LENGTH",21));t({cloudevent:f,name:"id",types:["string"],value:h});var E=c||n("MILL_CLOUDEVENTS_SOURCE");t({cloudevent:f,name:"source",types:["string"],value:E});var L=y;t({cloudevent:f,name:"type",types:["string"],value:L}),t({cloudevent:f,name:"specversion",types:["string"],value:p||"1.0"});var C=(new Date).toISOString();t({cloudevent:f,name:"time",types:["string"],value:C}),t({cloudevent:f,name:"data",value:a}),t({cloudevent:f,name:"datacontenttype",types:["string","undefined"],value:void 0!==a?o||"application/json":o}),t({cloudevent:f,name:"dataschema",types:["string","undefined"],value:r}),t({cloudevent:f,name:"subject",types:["string","undefined"],value:g}),t({cloudevent:f,name:"origintime",types:["string"],value:v||C}),t({cloudevent:f,name:"originid",types:["string"],value:s||h}),t({cloudevent:f,name:"originsource",types:["string"],value:d||E}),t({cloudevent:f,name:"origintype",types:["string"],value:l||L}),t({cloudevent:f,name:"originatorid",types:["string","undefined"],value:u}),t({cloudevent:f,name:"wschannelid",types:["string","undefined"],value:m})};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/utils/fetchNodeEnv/index.js","../src/utils/setAttribute/index.js","../src/index.js"],"sourcesContent":["export const fetchNodeEnv = (name, fallbackValue) => {\r\n\tif (typeof process === 'undefined') { return }\r\n\treturn process.env[name] || fallbackValue\r\n}\r\n","export const setAttribute = ({ cloudevent, name, types = [], value }) => {\r\n\tif (types.length > 0 && !types.includes(typeof value)) {\r\n\t\tconst message = `Cloudevent \"${name}\" must be of type ${types.map(s => s.toUpperCase()).sort().join(' or ')}.`\r\n\t\tthrow new Error(message)\r\n\t}\r\n\tcloudevent[name] = value\r\n}\r\n","import { fetchNodeEnv } from './utils/fetchNodeEnv/index.js'\r\nimport { nanoid } from 'nanoid'\r\nimport { setAttribute } from './utils/setAttribute/index.js'\r\n\r\nexport class Cloudevent {\r\n\tconstructor({\r\n\t\tdata,\r\n\t\tdatacontenttype,\r\n\t\tdataschema,\r\n\t\toriginatorid,\r\n\t\toriginid,\r\n\t\toriginsource,\r\n\t\torigintime,\r\n\t\torigintype,\r\n\t\tsource,\r\n\t\tspecversion,\r\n\t\tsubject,\r\n\t\ttype,\r\n\t}) {\r\n\t\tconst cloudevent = this\r\n\r\n\t\t// *******\r\n\t\t// * Required fields by Cloudevent v1 specification\r\n\t\tconst idValue = nanoid(fetchNodeEnv('MILL_CLOUDEVENTS_NANOID_LENGTH', 21))\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'id',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: idValue\r\n\t\t})\r\n\r\n\t\tconst sourceValue = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'source',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: sourceValue\r\n\t\t})\r\n\r\n\t\tconst typeValue = type\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'type',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: typeValue\r\n\t\t})\r\n\r\n\t\tconst specversionValue = specversion || '1.0'\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'specversion',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: specversionValue\r\n\t\t})\r\n\r\n\t\tconst timeValue = new Date().toISOString()\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'time',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: timeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional fields by Cloudevent v1 specification\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'data',\r\n\t\t\tvalue: data\r\n\t\t})\r\n\r\n\t\tconst datacontenttypeValue = typeof data !== 'undefined'\r\n\t\t\t? datacontenttype || 'application/json'\r\n\t\t\t: datacontenttype\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'datacontenttype',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: datacontenttypeValue\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'dataschema',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: dataschema\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'subject',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: subject\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Required in-house extentions\r\n\t\tconst origintimeValue = origintime || timeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintime',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintimeValue\r\n\t\t})\r\n\r\n\t\tconst originidValue = originid || idValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originid',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: originidValue\r\n\t\t})\r\n\r\n\t\tconst originsourceValue = originsource || sourceValue\r\n\t\tsetAttribute({ cloudevent, name: 'originsource', types: ['string'], value: originsourceValue })\r\n\r\n\t\tconst origintypeValue = origintype || typeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintype',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintypeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional in-house extentions\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originatorid',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: originatorid\r\n\t\t})\r\n\t\t// *******\r\n\t}\r\n}\r\n"],"names":["fetchNodeEnv","name","fallbackValue","process","env","setAttribute","cloudevent","types","value","length","includes","message","map","s","toUpperCase","sort","join","Error","data","datacontenttype","dataschema","originatorid","originid","originsource","origintime","origintype","source","specversion","subject","type","this","idValue","nanoid","sourceValue","typeValue","timeValue","Date","toISOString"],"mappings":"wBAAaA,EAAe,SAACC,EAAMC,GAClC,GAAuB,oBAAZC,QACX,OAAOA,QAAQC,IAAIH,IAASC,CAC5B,
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/utils/fetchNodeEnv/index.js","../src/utils/setAttribute/index.js","../src/index.js"],"sourcesContent":["export const fetchNodeEnv = (name, fallbackValue) => {\r\n\tif (typeof process === 'undefined') { return }\r\n\treturn process.env[name] || fallbackValue\r\n}\r\n","export const setAttribute = ({ cloudevent, name, types = [], value }) => {\r\n\tif (types.length > 0 && !types.includes(typeof value)) {\r\n\t\tconst message = `Cloudevent \"${name}\" must be of type ${types.map(s => s.toUpperCase()).sort().join(' or ')}.`\r\n\t\tthrow new Error(message)\r\n\t}\r\n\tcloudevent[name] = value\r\n}\r\n","import { fetchNodeEnv } from './utils/fetchNodeEnv/index.js'\r\nimport { nanoid } from 'nanoid'\r\nimport { setAttribute } from './utils/setAttribute/index.js'\r\n\r\nexport class Cloudevent {\r\n\tconstructor({\r\n\t\tdata,\r\n\t\tdatacontenttype,\r\n\t\tdataschema,\r\n\t\toriginatorid,\r\n\t\toriginid,\r\n\t\toriginsource,\r\n\t\torigintime,\r\n\t\torigintype,\r\n\t\tsource,\r\n\t\tspecversion,\r\n\t\tsubject,\r\n\t\ttype,\r\n\t\twschannelid,\r\n\t}) {\r\n\t\tconst cloudevent = this\r\n\r\n\t\t// *******\r\n\t\t// * Required fields by Cloudevent v1 specification\r\n\t\tconst idValue = nanoid(fetchNodeEnv('MILL_CLOUDEVENTS_NANOID_LENGTH', 21))\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'id',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: idValue\r\n\t\t})\r\n\r\n\t\tconst sourceValue = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'source',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: sourceValue\r\n\t\t})\r\n\r\n\t\tconst typeValue = type\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'type',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: typeValue\r\n\t\t})\r\n\r\n\t\tconst specversionValue = specversion || '1.0'\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'specversion',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: specversionValue\r\n\t\t})\r\n\r\n\t\tconst timeValue = new Date().toISOString()\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'time',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: timeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional fields by Cloudevent v1 specification\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'data',\r\n\t\t\tvalue: data\r\n\t\t})\r\n\r\n\t\tconst datacontenttypeValue = typeof data !== 'undefined'\r\n\t\t\t? datacontenttype || 'application/json'\r\n\t\t\t: datacontenttype\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'datacontenttype',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: datacontenttypeValue\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'dataschema',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: dataschema\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'subject',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: subject\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Required in-house extentions\r\n\t\tconst origintimeValue = origintime || timeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintime',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintimeValue\r\n\t\t})\r\n\r\n\t\tconst originidValue = originid || idValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originid',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: originidValue\r\n\t\t})\r\n\r\n\t\tconst originsourceValue = originsource || sourceValue\r\n\t\tsetAttribute({ cloudevent, name: 'originsource', types: ['string'], value: originsourceValue })\r\n\r\n\t\tconst origintypeValue = origintype || typeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintype',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintypeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional in-house extentions\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originatorid',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: originatorid\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'wschannelid',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: wschannelid\r\n\t\t})\r\n\t\t// *******\r\n\t}\r\n}\r\n"],"names":["fetchNodeEnv","name","fallbackValue","process","env","setAttribute","cloudevent","_ref","types","_ref$types","value","length","includes","message","map","s","toUpperCase","sort","join","Error","data","datacontenttype","dataschema","originatorid","originid","originsource","origintime","origintype","source","specversion","subject","type","wschannelid","this","idValue","nanoid","sourceValue","typeValue","timeValue","Date","toISOString"],"mappings":"wBAAaA,EAAe,SAACC,EAAMC,GAClC,GAAuB,oBAAZC,QACX,OAAOA,QAAQC,IAAIH,IAASC,CAC5B,ECHwBG,EAAG,YAAGC,IAAAA,EAAAA,EAAAA,WAAYL,EAA8BM,EAA9BN,KAAMO,EAAAA,EAAAA,MAAAA,OAAwB,IAAAC,EAAhB,GAAgBA,EAAZC,EAAAA,EAAAA,MAC5D,GAAIF,EAAMG,OAAS,IAAMH,EAAMI,gBAANF,GAA8B,CACtD,IAAaG,EAAA,eAAkBZ,EAAlB,qBAA2CO,EAAMM,IAAI,SAAAC,GAAKA,OAAAA,EAAEC,aAAN,GAAqBC,OAAOC,KAAK,YACpG,UAAMC,MAAUN,EAChB,CACDP,EAAWL,GAAQS,CACnB,qBCDA,SAAAH,GACCa,IAAAA,EAAAA,EAAAA,KACAC,EAAAA,EAAAA,gBACAC,EAAAA,EAAAA,WACAC,EAAAA,EAAAA,aACAC,EAAAA,EAAAA,SACAC,EAAAA,EAAAA,aACAC,EAAAA,EAAAA,WACAC,EAAAA,EAAAA,WACAC,EAAAA,EAAAA,OACAC,EAAAA,EAAAA,YACAC,EAAAA,EAAAA,QACAC,EAAAA,EAAAA,KACAC,EAAAA,EAAAA,YAEgB1B,EAAG2B,KAIbC,EAAUC,EAAMA,OAACnC,EAAa,iCAAkC,KACtEK,EAAa,CACZC,WAAAA,EACAL,KAAM,KACNO,MAAO,CAAC,UACRE,MAAOwB,IAGR,IAAME,EAAcR,GAAU5B,EAAa,2BAC3CK,EAAa,CACZC,WAAAA,EACAL,KAAM,SACNO,MAAO,CAAC,UACRE,MAAO0B,IAGR,IAAeC,EAAGN,EAClB1B,EAAa,CACZC,WAAAA,EACAL,KAAM,OACNO,MAAO,CAAC,UACRE,MAAO2B,IAIRhC,EAAa,CACZC,WAAAA,EACAL,KAAM,cACNO,MAAO,CAAC,UACRE,MALwBmB,GAAe,QAQxC,IAAeS,GAAG,IAAIC,MAAOC,cAC7BnC,EAAa,CACZC,WAAAA,EACAL,KAAM,OACNO,MAAO,CAAC,UACRE,MAAO4B,IAMRjC,EAAa,CACZC,WAAAA,EACAL,KAAM,OACNS,MAAOU,IAMRf,EAAa,CACZC,WAAAA,EACAL,KAAM,kBACNO,MAAO,CAAC,SAAU,aAClBE,WAP4C,IAATU,EACjCC,GAAmB,mBACnBA,IAQHhB,EAAa,CACZC,WAAAA,EACAL,KAAM,aACNO,MAAO,CAAC,SAAU,aAClBE,MAAOY,IAGRjB,EAAa,CACZC,WAAAA,EACAL,KAAM,UACNO,MAAO,CAAC,SAAU,aAClBE,MAAOoB,IAORzB,EAAa,CACZC,WAAAA,EACAL,KAAM,aACNO,MAAO,CAAC,UACRE,MALuBgB,GAAcY,IAStCjC,EAAa,CACZC,WAAAA,EACAL,KAAM,WACNO,MAAO,CAAC,UACRE,MALqBc,GAAYU,IASlC7B,EAAa,CAAEC,WAAAA,EAAYL,KAAM,eAAgBO,MAAO,CAAC,UAAWE,MAD1Ce,GAAgBW,IAI1C/B,EAAa,CACZC,WAAAA,EACAL,KAAM,aACNO,MAAO,CAAC,UACRE,MALuBiB,GAAcU,IAWtChC,EAAa,CACZC,WAAAA,EACAL,KAAM,eACNO,MAAO,CAAC,SAAU,aAClBE,MAAOa,IAGRlB,EAAa,CACZC,WAAAA,EACAL,KAAM,cACNO,MAAO,CAAC,SAAU,aAClBE,MAAOsB,GAGR"}
|
package/dist/index.modern.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=(e,
|
|
1
|
+
const e=(e,n)=>{if("undefined"!=typeof process)return process.env[e]||n},n=({cloudevent:e,name:n,types:t=[],value:o})=>{if(t.length>0&&!t.includes(typeof o)){const e=`Cloudevent "${n}" must be of type ${t.map(e=>e.toUpperCase()).sort().join(" or ")}.`;throw new Error(e)}e[n]=o};class t{constructor({data:t,datacontenttype:o,dataschema:i,originatorid:s,originid:a,originsource:r,origintime:u,origintype:d,source:c,specversion:l,subject:p,type:v,wschannelid:g}){const y=this,m=((e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((e,n)=>e+((n&=63)<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n>62?"-":"_"),""))(e("MILL_CLOUDEVENTS_NANOID_LENGTH",21));n({cloudevent:y,name:"id",types:["string"],value:m});const f=c||e("MILL_CLOUDEVENTS_SOURCE");n({cloudevent:y,name:"source",types:["string"],value:f});const h=v;n({cloudevent:y,name:"type",types:["string"],value:h}),n({cloudevent:y,name:"specversion",types:["string"],value:l||"1.0"});const E=(new Date).toISOString();n({cloudevent:y,name:"time",types:["string"],value:E}),n({cloudevent:y,name:"data",value:t}),n({cloudevent:y,name:"datacontenttype",types:["string","undefined"],value:void 0!==t?o||"application/json":o}),n({cloudevent:y,name:"dataschema",types:["string","undefined"],value:i}),n({cloudevent:y,name:"subject",types:["string","undefined"],value:p}),n({cloudevent:y,name:"origintime",types:["string"],value:u||E}),n({cloudevent:y,name:"originid",types:["string"],value:a||m}),n({cloudevent:y,name:"originsource",types:["string"],value:r||f}),n({cloudevent:y,name:"origintype",types:["string"],value:d||h}),n({cloudevent:y,name:"originatorid",types:["string","undefined"],value:s}),n({cloudevent:y,name:"wschannelid",types:["string","undefined"],value:g})}}export{t as Cloudevent};
|
|
2
2
|
//# sourceMappingURL=index.modern.js.map
|
package/dist/index.modern.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.modern.js","sources":["../src/utils/fetchNodeEnv/index.js","../src/utils/setAttribute/index.js","../src/index.js","../node_modules/nanoid/index.browser.js"],"sourcesContent":["export const fetchNodeEnv = (name, fallbackValue) => {\r\n\tif (typeof process === 'undefined') { return }\r\n\treturn process.env[name] || fallbackValue\r\n}\r\n","export const setAttribute = ({ cloudevent, name, types = [], value }) => {\r\n\tif (types.length > 0 && !types.includes(typeof value)) {\r\n\t\tconst message = `Cloudevent \"${name}\" must be of type ${types.map(s => s.toUpperCase()).sort().join(' or ')}.`\r\n\t\tthrow new Error(message)\r\n\t}\r\n\tcloudevent[name] = value\r\n}\r\n","import { fetchNodeEnv } from './utils/fetchNodeEnv/index.js'\r\nimport { nanoid } from 'nanoid'\r\nimport { setAttribute } from './utils/setAttribute/index.js'\r\n\r\nexport class Cloudevent {\r\n\tconstructor({\r\n\t\tdata,\r\n\t\tdatacontenttype,\r\n\t\tdataschema,\r\n\t\toriginatorid,\r\n\t\toriginid,\r\n\t\toriginsource,\r\n\t\torigintime,\r\n\t\torigintype,\r\n\t\tsource,\r\n\t\tspecversion,\r\n\t\tsubject,\r\n\t\ttype,\r\n\t}) {\r\n\t\tconst cloudevent = this\r\n\r\n\t\t// *******\r\n\t\t// * Required fields by Cloudevent v1 specification\r\n\t\tconst idValue = nanoid(fetchNodeEnv('MILL_CLOUDEVENTS_NANOID_LENGTH', 21))\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'id',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: idValue\r\n\t\t})\r\n\r\n\t\tconst sourceValue = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'source',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: sourceValue\r\n\t\t})\r\n\r\n\t\tconst typeValue = type\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'type',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: typeValue\r\n\t\t})\r\n\r\n\t\tconst specversionValue = specversion || '1.0'\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'specversion',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: specversionValue\r\n\t\t})\r\n\r\n\t\tconst timeValue = new Date().toISOString()\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'time',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: timeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional fields by Cloudevent v1 specification\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'data',\r\n\t\t\tvalue: data\r\n\t\t})\r\n\r\n\t\tconst datacontenttypeValue = typeof data !== 'undefined'\r\n\t\t\t? datacontenttype || 'application/json'\r\n\t\t\t: datacontenttype\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'datacontenttype',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: datacontenttypeValue\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'dataschema',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: dataschema\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'subject',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: subject\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Required in-house extentions\r\n\t\tconst origintimeValue = origintime || timeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintime',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintimeValue\r\n\t\t})\r\n\r\n\t\tconst originidValue = originid || idValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originid',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: originidValue\r\n\t\t})\r\n\r\n\t\tconst originsourceValue = originsource || sourceValue\r\n\t\tsetAttribute({ cloudevent, name: 'originsource', types: ['string'], value: originsourceValue })\r\n\r\n\t\tconst origintypeValue = origintype || typeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintype',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintypeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional in-house extentions\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originatorid',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: originatorid\r\n\t\t})\r\n\t\t// *******\r\n\t}\r\n}\r\n","import { urlAlphabet } from './url-alphabet/index.js'\nlet random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nlet customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nlet customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nlet nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n byte &= 63\n if (byte < 36) {\n id += byte.toString(36)\n } else if (byte < 62) {\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\nexport { nanoid, customAlphabet, customRandom, urlAlphabet, random }\n"],"names":["fetchNodeEnv","name","fallbackValue","process","env","setAttribute","cloudevent","types","value","length","includes","message","map","s","toUpperCase","sort","join","
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/utils/fetchNodeEnv/index.js","../src/utils/setAttribute/index.js","../src/index.js","../node_modules/nanoid/index.browser.js"],"sourcesContent":["export const fetchNodeEnv = (name, fallbackValue) => {\r\n\tif (typeof process === 'undefined') { return }\r\n\treturn process.env[name] || fallbackValue\r\n}\r\n","export const setAttribute = ({ cloudevent, name, types = [], value }) => {\r\n\tif (types.length > 0 && !types.includes(typeof value)) {\r\n\t\tconst message = `Cloudevent \"${name}\" must be of type ${types.map(s => s.toUpperCase()).sort().join(' or ')}.`\r\n\t\tthrow new Error(message)\r\n\t}\r\n\tcloudevent[name] = value\r\n}\r\n","import { fetchNodeEnv } from './utils/fetchNodeEnv/index.js'\r\nimport { nanoid } from 'nanoid'\r\nimport { setAttribute } from './utils/setAttribute/index.js'\r\n\r\nexport class Cloudevent {\r\n\tconstructor({\r\n\t\tdata,\r\n\t\tdatacontenttype,\r\n\t\tdataschema,\r\n\t\toriginatorid,\r\n\t\toriginid,\r\n\t\toriginsource,\r\n\t\torigintime,\r\n\t\torigintype,\r\n\t\tsource,\r\n\t\tspecversion,\r\n\t\tsubject,\r\n\t\ttype,\r\n\t\twschannelid,\r\n\t}) {\r\n\t\tconst cloudevent = this\r\n\r\n\t\t// *******\r\n\t\t// * Required fields by Cloudevent v1 specification\r\n\t\tconst idValue = nanoid(fetchNodeEnv('MILL_CLOUDEVENTS_NANOID_LENGTH', 21))\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'id',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: idValue\r\n\t\t})\r\n\r\n\t\tconst sourceValue = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'source',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: sourceValue\r\n\t\t})\r\n\r\n\t\tconst typeValue = type\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'type',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: typeValue\r\n\t\t})\r\n\r\n\t\tconst specversionValue = specversion || '1.0'\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'specversion',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: specversionValue\r\n\t\t})\r\n\r\n\t\tconst timeValue = new Date().toISOString()\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'time',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: timeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional fields by Cloudevent v1 specification\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'data',\r\n\t\t\tvalue: data\r\n\t\t})\r\n\r\n\t\tconst datacontenttypeValue = typeof data !== 'undefined'\r\n\t\t\t? datacontenttype || 'application/json'\r\n\t\t\t: datacontenttype\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'datacontenttype',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: datacontenttypeValue\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'dataschema',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: dataschema\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'subject',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: subject\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Required in-house extentions\r\n\t\tconst origintimeValue = origintime || timeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintime',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintimeValue\r\n\t\t})\r\n\r\n\t\tconst originidValue = originid || idValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originid',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: originidValue\r\n\t\t})\r\n\r\n\t\tconst originsourceValue = originsource || sourceValue\r\n\t\tsetAttribute({ cloudevent, name: 'originsource', types: ['string'], value: originsourceValue })\r\n\r\n\t\tconst origintypeValue = origintype || typeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintype',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintypeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional in-house extentions\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originatorid',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: originatorid\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'wschannelid',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: wschannelid\r\n\t\t})\r\n\t\t// *******\r\n\t}\r\n}\r\n","import { urlAlphabet } from './url-alphabet/index.js'\nlet random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nlet customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nlet customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nlet nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n byte &= 63\n if (byte < 36) {\n id += byte.toString(36)\n } else if (byte < 62) {\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\nexport { nanoid, customAlphabet, customRandom, urlAlphabet, random }\n"],"names":["fetchNodeEnv","name","fallbackValue","process","env","setAttribute","cloudevent","types","value","length","includes","message","map","s","toUpperCase","sort","join","Cloudevent","constructor","data","datacontenttype","dataschema","originatorid","originid","originsource","origintime","origintype","source","specversion","subject","type","wschannelid","this","size","crypto","getRandomValues","Uint8Array","reduce","id","byte","toString","nanoid","idValue","sourceValue","typeValue","timeValue","Date","toISOString"],"mappings":"AAAO,MAAkBA,EAAG,CAACC,EAAMC,KAClC,GAAuB,oBAAnBC,QACJ,OAAOA,QAAQC,IAAIH,IAASC,GCFhBG,EAAe,EAAGC,aAAYL,OAAMM,MAAAA,EAAQ,GAAIC,YAC5D,GAAID,EAAME,OAAS,IAAMF,EAAMG,gBAANF,GAA8B,CACtD,MAAaG,EAAI,eAAcV,sBAAyBM,EAAMK,IAAIC,GAAKA,EAAEC,eAAeC,OAAOC,KAAK,WACpG,MAAM,UAAUL,EAChB,CACDL,EAAWL,GAAQO,GCDPS,MAAAA,EACZC,aAAYC,KACXA,EADWC,gBAEXA,EAFWC,WAGXA,EAHWC,aAIXA,EAJWC,SAKXA,EALWC,aAMXA,EANWC,WAOXA,EAPWC,WAQXA,EARWC,OASXA,EATWC,YAUXA,EAVWC,QAWXA,EAXWC,KAYXA,EAZWC,YAaXA,IAEA,MAAMzB,EAAa0B,OCDR,EAACC,EAAO,KACnBC,OAAOC,gBAAgB,IAAIC,WAAWH,IAAOI,OAAO,CAACC,EAAIC,IAGrDD,IAFFC,GAAQ,IACG,GACHA,EAAKC,SAAS,IACXD,EAAO,IACTA,EAAO,IAAIC,SAAS,IAAI1B,cACtByB,EAAO,GACV,IAEA,KAGP,IDRaE,CAAOzC,EAAa,iCAAkC,KACtEK,EAAa,CACZC,aACAL,KAAM,KACNM,MAAO,CAAC,UACRC,MAAOkC,IAGR,MAAiBC,EAAGhB,GAAU3B,EAAa,2BAC3CK,EAAa,CACZC,aACAL,KAAM,SACNM,MAAO,CAAC,UACRC,MAAOmC,IAGR,QAAkBb,EAClBzB,EAAa,CACZC,aACAL,KAAM,OACNM,MAAO,CAAC,UACRC,MAAOoC,IAIRvC,EAAa,CACZC,aACAL,KAAM,cACNM,MAAO,CAAC,UACRC,MALwBoB,GAAe,QAQxC,MAAeiB,GAAG,IAAIC,MAAOC,cAC7B1C,EAAa,CACZC,aACAL,KAAM,OACNM,MAAO,CAAC,UACRC,MAAOqC,IAMRxC,EAAa,CACZC,aACAL,KAAM,OACNO,MAAOW,IAMRd,EAAa,CACZC,aACAL,KAAM,kBACNM,MAAO,CAAC,SAAU,aAClBC,WAP4C,IAATW,EACjCC,GAAmB,mBACnBA,IAQHf,EAAa,CACZC,aACAL,KAAM,aACNM,MAAO,CAAC,SAAU,aAClBC,MAAOa,IAGRhB,EAAa,CACZC,aACAL,KAAM,UACNM,MAAO,CAAC,SAAU,aAClBC,MAAOqB,IAORxB,EAAa,CACZC,aACAL,KAAM,aACNM,MAAO,CAAC,UACRC,MALuBiB,GAAcoB,IAStCxC,EAAa,CACZC,aACAL,KAAM,WACNM,MAAO,CAAC,UACRC,MALqBe,GAAYmB,IASlCrC,EAAa,CAAEC,aAAYL,KAAM,eAAgBM,MAAO,CAAC,UAAWC,MAD1CgB,GAAgBmB,IAI1CtC,EAAa,CACZC,aACAL,KAAM,aACNM,MAAO,CAAC,UACRC,MALuBkB,GAAckB,IAWtCvC,EAAa,CACZC,aACAL,KAAM,eACNM,MAAO,CAAC,SAAU,aAClBC,MAAOc,IAGRjB,EAAa,CACZC,aACAL,KAAM,cACNM,MAAO,CAAC,SAAU,aAClBC,MAAOuB,GAGR"}
|
package/dist/index.module.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{nanoid as e}from"nanoid";var n=function(e,n){if("undefined"!=typeof process)return process.env[e]||n},t=function(e){var n=e.cloudevent,t=e.name,i=e.types,
|
|
1
|
+
import{nanoid as e}from"nanoid";var n=function(e,n){if("undefined"!=typeof process)return process.env[e]||n},t=function(e){var n=e.cloudevent,t=e.name,i=e.types,a=void 0===i?[]:i,o=e.value;if(a.length>0&&!a.includes(typeof o)){var r='Cloudevent "'+t+'" must be of type '+a.map(function(e){return e.toUpperCase()}).sort().join(" or ")+".";throw new Error(r)}n[t]=o},i=function(i){var a=i.data,o=i.datacontenttype,r=i.dataschema,s=i.originatorid,u=i.originid,d=i.originsource,v=i.origintime,c=i.origintype,l=i.source,p=i.specversion,g=i.subject,m=i.type,y=i.wschannelid,f=this,h=e(n("MILL_CLOUDEVENTS_NANOID_LENGTH",21));t({cloudevent:f,name:"id",types:["string"],value:h});var E=l||n("MILL_CLOUDEVENTS_SOURCE");t({cloudevent:f,name:"source",types:["string"],value:E});var L=m;t({cloudevent:f,name:"type",types:["string"],value:L}),t({cloudevent:f,name:"specversion",types:["string"],value:p||"1.0"});var w=(new Date).toISOString();t({cloudevent:f,name:"time",types:["string"],value:w}),t({cloudevent:f,name:"data",value:a}),t({cloudevent:f,name:"datacontenttype",types:["string","undefined"],value:void 0!==a?o||"application/json":o}),t({cloudevent:f,name:"dataschema",types:["string","undefined"],value:r}),t({cloudevent:f,name:"subject",types:["string","undefined"],value:g}),t({cloudevent:f,name:"origintime",types:["string"],value:v||w}),t({cloudevent:f,name:"originid",types:["string"],value:u||h}),t({cloudevent:f,name:"originsource",types:["string"],value:d||E}),t({cloudevent:f,name:"origintype",types:["string"],value:c||L}),t({cloudevent:f,name:"originatorid",types:["string","undefined"],value:s}),t({cloudevent:f,name:"wschannelid",types:["string","undefined"],value:y})};export{i as Cloudevent};
|
|
2
2
|
//# sourceMappingURL=index.module.js.map
|
package/dist/index.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.js","sources":["../src/utils/fetchNodeEnv/index.js","../src/utils/setAttribute/index.js","../src/index.js"],"sourcesContent":["export const fetchNodeEnv = (name, fallbackValue) => {\r\n\tif (typeof process === 'undefined') { return }\r\n\treturn process.env[name] || fallbackValue\r\n}\r\n","export const setAttribute = ({ cloudevent, name, types = [], value }) => {\r\n\tif (types.length > 0 && !types.includes(typeof value)) {\r\n\t\tconst message = `Cloudevent \"${name}\" must be of type ${types.map(s => s.toUpperCase()).sort().join(' or ')}.`\r\n\t\tthrow new Error(message)\r\n\t}\r\n\tcloudevent[name] = value\r\n}\r\n","import { fetchNodeEnv } from './utils/fetchNodeEnv/index.js'\r\nimport { nanoid } from 'nanoid'\r\nimport { setAttribute } from './utils/setAttribute/index.js'\r\n\r\nexport class Cloudevent {\r\n\tconstructor({\r\n\t\tdata,\r\n\t\tdatacontenttype,\r\n\t\tdataschema,\r\n\t\toriginatorid,\r\n\t\toriginid,\r\n\t\toriginsource,\r\n\t\torigintime,\r\n\t\torigintype,\r\n\t\tsource,\r\n\t\tspecversion,\r\n\t\tsubject,\r\n\t\ttype,\r\n\t}) {\r\n\t\tconst cloudevent = this\r\n\r\n\t\t// *******\r\n\t\t// * Required fields by Cloudevent v1 specification\r\n\t\tconst idValue = nanoid(fetchNodeEnv('MILL_CLOUDEVENTS_NANOID_LENGTH', 21))\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'id',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: idValue\r\n\t\t})\r\n\r\n\t\tconst sourceValue = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'source',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: sourceValue\r\n\t\t})\r\n\r\n\t\tconst typeValue = type\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'type',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: typeValue\r\n\t\t})\r\n\r\n\t\tconst specversionValue = specversion || '1.0'\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'specversion',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: specversionValue\r\n\t\t})\r\n\r\n\t\tconst timeValue = new Date().toISOString()\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'time',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: timeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional fields by Cloudevent v1 specification\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'data',\r\n\t\t\tvalue: data\r\n\t\t})\r\n\r\n\t\tconst datacontenttypeValue = typeof data !== 'undefined'\r\n\t\t\t? datacontenttype || 'application/json'\r\n\t\t\t: datacontenttype\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'datacontenttype',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: datacontenttypeValue\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'dataschema',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: dataschema\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'subject',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: subject\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Required in-house extentions\r\n\t\tconst origintimeValue = origintime || timeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintime',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintimeValue\r\n\t\t})\r\n\r\n\t\tconst originidValue = originid || idValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originid',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: originidValue\r\n\t\t})\r\n\r\n\t\tconst originsourceValue = originsource || sourceValue\r\n\t\tsetAttribute({ cloudevent, name: 'originsource', types: ['string'], value: originsourceValue })\r\n\r\n\t\tconst origintypeValue = origintype || typeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintype',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintypeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional in-house extentions\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originatorid',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: originatorid\r\n\t\t})\r\n\t\t// *******\r\n\t}\r\n}\r\n"],"names":["fetchNodeEnv","name","fallbackValue","process","env","setAttribute","cloudevent","types","value","length","includes","message","map","s","toUpperCase","sort","join","Error","Cloudevent","data","datacontenttype","dataschema","originatorid","originid","originsource","origintime","origintype","source","specversion","subject","type","this","idValue","nanoid","sourceValue","typeValue","timeValue","Date","toISOString"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.module.js","sources":["../src/utils/fetchNodeEnv/index.js","../src/utils/setAttribute/index.js","../src/index.js"],"sourcesContent":["export const fetchNodeEnv = (name, fallbackValue) => {\r\n\tif (typeof process === 'undefined') { return }\r\n\treturn process.env[name] || fallbackValue\r\n}\r\n","export const setAttribute = ({ cloudevent, name, types = [], value }) => {\r\n\tif (types.length > 0 && !types.includes(typeof value)) {\r\n\t\tconst message = `Cloudevent \"${name}\" must be of type ${types.map(s => s.toUpperCase()).sort().join(' or ')}.`\r\n\t\tthrow new Error(message)\r\n\t}\r\n\tcloudevent[name] = value\r\n}\r\n","import { fetchNodeEnv } from './utils/fetchNodeEnv/index.js'\r\nimport { nanoid } from 'nanoid'\r\nimport { setAttribute } from './utils/setAttribute/index.js'\r\n\r\nexport class Cloudevent {\r\n\tconstructor({\r\n\t\tdata,\r\n\t\tdatacontenttype,\r\n\t\tdataschema,\r\n\t\toriginatorid,\r\n\t\toriginid,\r\n\t\toriginsource,\r\n\t\torigintime,\r\n\t\torigintype,\r\n\t\tsource,\r\n\t\tspecversion,\r\n\t\tsubject,\r\n\t\ttype,\r\n\t\twschannelid,\r\n\t}) {\r\n\t\tconst cloudevent = this\r\n\r\n\t\t// *******\r\n\t\t// * Required fields by Cloudevent v1 specification\r\n\t\tconst idValue = nanoid(fetchNodeEnv('MILL_CLOUDEVENTS_NANOID_LENGTH', 21))\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'id',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: idValue\r\n\t\t})\r\n\r\n\t\tconst sourceValue = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'source',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: sourceValue\r\n\t\t})\r\n\r\n\t\tconst typeValue = type\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'type',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: typeValue\r\n\t\t})\r\n\r\n\t\tconst specversionValue = specversion || '1.0'\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'specversion',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: specversionValue\r\n\t\t})\r\n\r\n\t\tconst timeValue = new Date().toISOString()\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'time',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: timeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional fields by Cloudevent v1 specification\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'data',\r\n\t\t\tvalue: data\r\n\t\t})\r\n\r\n\t\tconst datacontenttypeValue = typeof data !== 'undefined'\r\n\t\t\t? datacontenttype || 'application/json'\r\n\t\t\t: datacontenttype\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'datacontenttype',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: datacontenttypeValue\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'dataschema',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: dataschema\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'subject',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: subject\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Required in-house extentions\r\n\t\tconst origintimeValue = origintime || timeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintime',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintimeValue\r\n\t\t})\r\n\r\n\t\tconst originidValue = originid || idValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originid',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: originidValue\r\n\t\t})\r\n\r\n\t\tconst originsourceValue = originsource || sourceValue\r\n\t\tsetAttribute({ cloudevent, name: 'originsource', types: ['string'], value: originsourceValue })\r\n\r\n\t\tconst origintypeValue = origintype || typeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintype',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintypeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional in-house extentions\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originatorid',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: originatorid\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'wschannelid',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: wschannelid\r\n\t\t})\r\n\t\t// *******\r\n\t}\r\n}\r\n"],"names":["fetchNodeEnv","name","fallbackValue","process","env","setAttribute","cloudevent","_ref","types","_ref$types","value","length","includes","message","map","s","toUpperCase","sort","join","Error","Cloudevent","data","datacontenttype","dataschema","originatorid","originid","originsource","origintime","origintype","source","specversion","subject","type","wschannelid","this","idValue","nanoid","sourceValue","typeValue","timeValue","Date","toISOString"],"mappings":"gCAAaA,IAAAA,EAAe,SAACC,EAAMC,GAClC,GAAuB,oBAAZC,QACX,OAAOA,QAAQC,IAAIH,IAASC,CAC5B,ECHwBG,EAAG,YAAGC,IAAAA,EAAAA,EAAAA,WAAYL,EAA8BM,EAA9BN,KAAMO,EAAAA,EAAAA,MAAAA,OAAwB,IAAAC,EAAhB,GAAgBA,EAAZC,EAAAA,EAAAA,MAC5D,GAAIF,EAAMG,OAAS,IAAMH,EAAMI,gBAANF,GAA8B,CACtD,IAAaG,EAAA,eAAkBZ,EAAlB,qBAA2CO,EAAMM,IAAI,SAAAC,GAAKA,OAAAA,EAAEC,aAAN,GAAqBC,OAAOC,KAAK,YACpG,UAAMC,MAAUN,EAChB,CACDP,EAAWL,GAAQS,CACnB,ECFYU,EACZ,SAAAb,GACCc,IAAAA,EAAAA,EAAAA,KACAC,EAAAA,EAAAA,gBACAC,EAAAA,EAAAA,WACAC,EAAAA,EAAAA,aACAC,EAAAA,EAAAA,SACAC,EAAAA,EAAAA,aACAC,EAAAA,EAAAA,WACAC,EAAAA,EAAAA,WACAC,EAAAA,EAAAA,OACAC,EAAAA,EAAAA,YACAC,EAAAA,EAAAA,QACAC,EAAAA,EAAAA,KACAC,EAAAA,EAAAA,YAEgB3B,EAAG4B,KAIbC,EAAUC,EAAOpC,EAAa,iCAAkC,KACtEK,EAAa,CACZC,WAAAA,EACAL,KAAM,KACNO,MAAO,CAAC,UACRE,MAAOyB,IAGR,IAAME,EAAcR,GAAU7B,EAAa,2BAC3CK,EAAa,CACZC,WAAAA,EACAL,KAAM,SACNO,MAAO,CAAC,UACRE,MAAO2B,IAGR,IAAeC,EAAGN,EAClB3B,EAAa,CACZC,WAAAA,EACAL,KAAM,OACNO,MAAO,CAAC,UACRE,MAAO4B,IAIRjC,EAAa,CACZC,WAAAA,EACAL,KAAM,cACNO,MAAO,CAAC,UACRE,MALwBoB,GAAe,QAQxC,IAAeS,GAAG,IAAIC,MAAOC,cAC7BpC,EAAa,CACZC,WAAAA,EACAL,KAAM,OACNO,MAAO,CAAC,UACRE,MAAO6B,IAMRlC,EAAa,CACZC,WAAAA,EACAL,KAAM,OACNS,MAAOW,IAMRhB,EAAa,CACZC,WAAAA,EACAL,KAAM,kBACNO,MAAO,CAAC,SAAU,aAClBE,WAP4C,IAATW,EACjCC,GAAmB,mBACnBA,IAQHjB,EAAa,CACZC,WAAAA,EACAL,KAAM,aACNO,MAAO,CAAC,SAAU,aAClBE,MAAOa,IAGRlB,EAAa,CACZC,WAAAA,EACAL,KAAM,UACNO,MAAO,CAAC,SAAU,aAClBE,MAAOqB,IAOR1B,EAAa,CACZC,WAAAA,EACAL,KAAM,aACNO,MAAO,CAAC,UACRE,MALuBiB,GAAcY,IAStClC,EAAa,CACZC,WAAAA,EACAL,KAAM,WACNO,MAAO,CAAC,UACRE,MALqBe,GAAYU,IASlC9B,EAAa,CAAEC,WAAAA,EAAYL,KAAM,eAAgBO,MAAO,CAAC,UAAWE,MAD1CgB,GAAgBW,IAI1ChC,EAAa,CACZC,WAAAA,EACAL,KAAM,aACNO,MAAO,CAAC,UACRE,MALuBkB,GAAcU,IAWtCjC,EAAa,CACZC,WAAAA,EACAL,KAAM,eACNO,MAAO,CAAC,SAAU,aAClBE,MAAOc,IAGRnB,EAAa,CACZC,WAAAA,EACAL,KAAM,cACNO,MAAO,CAAC,SAAU,aAClBE,MAAOuB,GAGR"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e||self).cloudevents={})}(this,function(e){var n=function(e,n){if("undefined"!=typeof process)return process.env[e]||n},t=function(e){var n=e.cloudevent,t=e.name,
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e||self).cloudevents={})}(this,function(e){var n=function(e,n){if("undefined"!=typeof process)return process.env[e]||n},t=function(e){var n=e.cloudevent,t=e.name,i=e.types,o=void 0===i?[]:i,a=e.value;if(o.length>0&&!o.includes(typeof a)){var r='Cloudevent "'+t+'" must be of type '+o.map(function(e){return e.toUpperCase()}).sort().join(" or ")+".";throw new Error(r)}n[t]=a};e.Cloudevent=function(e){var i=e.data,o=e.datacontenttype,a=e.dataschema,r=e.originatorid,s=e.originid,u=e.originsource,d=e.origintime,l=e.origintype,v=e.source,c=e.specversion,p=e.subject,g=e.type,y=e.wschannelid,f=this,m=((e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((e,n)=>e+((n&=63)<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n>62?"-":"_"),""))(n("MILL_CLOUDEVENTS_NANOID_LENGTH",21));t({cloudevent:f,name:"id",types:["string"],value:m});var h=v||n("MILL_CLOUDEVENTS_SOURCE");t({cloudevent:f,name:"source",types:["string"],value:h});var C=g;t({cloudevent:f,name:"type",types:["string"],value:C}),t({cloudevent:f,name:"specversion",types:["string"],value:c||"1.0"});var E=(new Date).toISOString();t({cloudevent:f,name:"time",types:["string"],value:E}),t({cloudevent:f,name:"data",value:i}),t({cloudevent:f,name:"datacontenttype",types:["string","undefined"],value:void 0!==i?o||"application/json":o}),t({cloudevent:f,name:"dataschema",types:["string","undefined"],value:a}),t({cloudevent:f,name:"subject",types:["string","undefined"],value:p}),t({cloudevent:f,name:"origintime",types:["string"],value:d||E}),t({cloudevent:f,name:"originid",types:["string"],value:s||m}),t({cloudevent:f,name:"originsource",types:["string"],value:u||h}),t({cloudevent:f,name:"origintype",types:["string"],value:l||C}),t({cloudevent:f,name:"originatorid",types:["string","undefined"],value:r}),t({cloudevent:f,name:"wschannelid",types:["string","undefined"],value:y})}});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/utils/fetchNodeEnv/index.js","../src/utils/setAttribute/index.js","../src/index.js","../node_modules/nanoid/index.browser.js"],"sourcesContent":["export const fetchNodeEnv = (name, fallbackValue) => {\r\n\tif (typeof process === 'undefined') { return }\r\n\treturn process.env[name] || fallbackValue\r\n}\r\n","export const setAttribute = ({ cloudevent, name, types = [], value }) => {\r\n\tif (types.length > 0 && !types.includes(typeof value)) {\r\n\t\tconst message = `Cloudevent \"${name}\" must be of type ${types.map(s => s.toUpperCase()).sort().join(' or ')}.`\r\n\t\tthrow new Error(message)\r\n\t}\r\n\tcloudevent[name] = value\r\n}\r\n","import { fetchNodeEnv } from './utils/fetchNodeEnv/index.js'\r\nimport { nanoid } from 'nanoid'\r\nimport { setAttribute } from './utils/setAttribute/index.js'\r\n\r\nexport class Cloudevent {\r\n\tconstructor({\r\n\t\tdata,\r\n\t\tdatacontenttype,\r\n\t\tdataschema,\r\n\t\toriginatorid,\r\n\t\toriginid,\r\n\t\toriginsource,\r\n\t\torigintime,\r\n\t\torigintype,\r\n\t\tsource,\r\n\t\tspecversion,\r\n\t\tsubject,\r\n\t\ttype,\r\n\t}) {\r\n\t\tconst cloudevent = this\r\n\r\n\t\t// *******\r\n\t\t// * Required fields by Cloudevent v1 specification\r\n\t\tconst idValue = nanoid(fetchNodeEnv('MILL_CLOUDEVENTS_NANOID_LENGTH', 21))\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'id',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: idValue\r\n\t\t})\r\n\r\n\t\tconst sourceValue = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'source',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: sourceValue\r\n\t\t})\r\n\r\n\t\tconst typeValue = type\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'type',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: typeValue\r\n\t\t})\r\n\r\n\t\tconst specversionValue = specversion || '1.0'\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'specversion',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: specversionValue\r\n\t\t})\r\n\r\n\t\tconst timeValue = new Date().toISOString()\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'time',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: timeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional fields by Cloudevent v1 specification\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'data',\r\n\t\t\tvalue: data\r\n\t\t})\r\n\r\n\t\tconst datacontenttypeValue = typeof data !== 'undefined'\r\n\t\t\t? datacontenttype || 'application/json'\r\n\t\t\t: datacontenttype\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'datacontenttype',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: datacontenttypeValue\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'dataschema',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: dataschema\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'subject',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: subject\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Required in-house extentions\r\n\t\tconst origintimeValue = origintime || timeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintime',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintimeValue\r\n\t\t})\r\n\r\n\t\tconst originidValue = originid || idValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originid',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: originidValue\r\n\t\t})\r\n\r\n\t\tconst originsourceValue = originsource || sourceValue\r\n\t\tsetAttribute({ cloudevent, name: 'originsource', types: ['string'], value: originsourceValue })\r\n\r\n\t\tconst origintypeValue = origintype || typeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintype',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintypeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional in-house extentions\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originatorid',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: originatorid\r\n\t\t})\r\n\t\t// *******\r\n\t}\r\n}\r\n","import { urlAlphabet } from './url-alphabet/index.js'\nlet random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nlet customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nlet customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nlet nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n byte &= 63\n if (byte < 36) {\n id += byte.toString(36)\n } else if (byte < 62) {\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\nexport { nanoid, customAlphabet, customRandom, urlAlphabet, random }\n"],"names":["fetchNodeEnv","name","fallbackValue","process","env","setAttribute","cloudevent","types","value","length","includes","message","map","s","toUpperCase","sort","join","Error","data","datacontenttype","dataschema","originatorid","originid","originsource","origintime","origintype","source","specversion","subject","type","this","idValue","size","crypto","getRandomValues","Uint8Array","reduce","id","byte","toString","nanoid","sourceValue","typeValue","timeValue","Date","toISOString"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/utils/fetchNodeEnv/index.js","../src/utils/setAttribute/index.js","../src/index.js","../node_modules/nanoid/index.browser.js"],"sourcesContent":["export const fetchNodeEnv = (name, fallbackValue) => {\r\n\tif (typeof process === 'undefined') { return }\r\n\treturn process.env[name] || fallbackValue\r\n}\r\n","export const setAttribute = ({ cloudevent, name, types = [], value }) => {\r\n\tif (types.length > 0 && !types.includes(typeof value)) {\r\n\t\tconst message = `Cloudevent \"${name}\" must be of type ${types.map(s => s.toUpperCase()).sort().join(' or ')}.`\r\n\t\tthrow new Error(message)\r\n\t}\r\n\tcloudevent[name] = value\r\n}\r\n","import { fetchNodeEnv } from './utils/fetchNodeEnv/index.js'\r\nimport { nanoid } from 'nanoid'\r\nimport { setAttribute } from './utils/setAttribute/index.js'\r\n\r\nexport class Cloudevent {\r\n\tconstructor({\r\n\t\tdata,\r\n\t\tdatacontenttype,\r\n\t\tdataschema,\r\n\t\toriginatorid,\r\n\t\toriginid,\r\n\t\toriginsource,\r\n\t\torigintime,\r\n\t\torigintype,\r\n\t\tsource,\r\n\t\tspecversion,\r\n\t\tsubject,\r\n\t\ttype,\r\n\t\twschannelid,\r\n\t}) {\r\n\t\tconst cloudevent = this\r\n\r\n\t\t// *******\r\n\t\t// * Required fields by Cloudevent v1 specification\r\n\t\tconst idValue = nanoid(fetchNodeEnv('MILL_CLOUDEVENTS_NANOID_LENGTH', 21))\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'id',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: idValue\r\n\t\t})\r\n\r\n\t\tconst sourceValue = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'source',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: sourceValue\r\n\t\t})\r\n\r\n\t\tconst typeValue = type\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'type',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: typeValue\r\n\t\t})\r\n\r\n\t\tconst specversionValue = specversion || '1.0'\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'specversion',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: specversionValue\r\n\t\t})\r\n\r\n\t\tconst timeValue = new Date().toISOString()\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'time',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: timeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional fields by Cloudevent v1 specification\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'data',\r\n\t\t\tvalue: data\r\n\t\t})\r\n\r\n\t\tconst datacontenttypeValue = typeof data !== 'undefined'\r\n\t\t\t? datacontenttype || 'application/json'\r\n\t\t\t: datacontenttype\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'datacontenttype',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: datacontenttypeValue\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'dataschema',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: dataschema\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'subject',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: subject\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Required in-house extentions\r\n\t\tconst origintimeValue = origintime || timeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintime',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintimeValue\r\n\t\t})\r\n\r\n\t\tconst originidValue = originid || idValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originid',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: originidValue\r\n\t\t})\r\n\r\n\t\tconst originsourceValue = originsource || sourceValue\r\n\t\tsetAttribute({ cloudevent, name: 'originsource', types: ['string'], value: originsourceValue })\r\n\r\n\t\tconst origintypeValue = origintype || typeValue\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'origintype',\r\n\t\t\ttypes: ['string'],\r\n\t\t\tvalue: origintypeValue\r\n\t\t})\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional in-house extentions\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'originatorid',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: originatorid\r\n\t\t})\r\n\r\n\t\tsetAttribute({\r\n\t\t\tcloudevent,\r\n\t\t\tname: 'wschannelid',\r\n\t\t\ttypes: ['string', 'undefined'],\r\n\t\t\tvalue: wschannelid\r\n\t\t})\r\n\t\t// *******\r\n\t}\r\n}\r\n","import { urlAlphabet } from './url-alphabet/index.js'\nlet random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nlet customRandom = (alphabet, defaultSize, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * defaultSize) / alphabet.length)\n return (size = defaultSize) => {\n let id = ''\n while (true) {\n let bytes = getRandom(step)\n let j = step\n while (j--) {\n id += alphabet[bytes[j] & mask] || ''\n if (id.length === size) return id\n }\n }\n }\n}\nlet customAlphabet = (alphabet, size = 21) =>\n customRandom(alphabet, size, random)\nlet nanoid = (size = 21) =>\n crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {\n byte &= 63\n if (byte < 36) {\n id += byte.toString(36)\n } else if (byte < 62) {\n id += (byte - 26).toString(36).toUpperCase()\n } else if (byte > 62) {\n id += '-'\n } else {\n id += '_'\n }\n return id\n }, '')\nexport { nanoid, customAlphabet, customRandom, urlAlphabet, random }\n"],"names":["fetchNodeEnv","name","fallbackValue","process","env","setAttribute","cloudevent","_ref","types","_ref$types","value","length","includes","message","map","s","toUpperCase","sort","join","Error","data","datacontenttype","dataschema","originatorid","originid","originsource","origintime","origintype","source","specversion","subject","type","wschannelid","this","idValue","size","crypto","getRandomValues","Uint8Array","reduce","id","byte","toString","nanoid","sourceValue","typeValue","timeValue","Date","toISOString"],"mappings":"qOAAaA,IAAAA,EAAe,SAACC,EAAMC,GAClC,GAAuB,oBAAZC,QACX,OAAOA,QAAQC,IAAIH,IAASC,CAC5B,ECHwBG,EAAG,YAAGC,IAAAA,EAAAA,EAAAA,WAAYL,EAA8BM,EAA9BN,KAAMO,EAAAA,EAAAA,MAAAA,OAAwB,IAAAC,EAAhB,GAAgBA,EAAZC,EAAAA,EAAAA,MAC5D,GAAIF,EAAMG,OAAS,IAAMH,EAAMI,gBAANF,GAA8B,CACtD,IAAaG,EAAA,eAAkBZ,EAAlB,qBAA2CO,EAAMM,IAAI,SAAAC,GAAKA,OAAAA,EAAEC,aAAN,GAAqBC,OAAOC,KAAK,YACpG,UAAMC,MAAUN,EAChB,CACDP,EAAWL,GAAQS,CACnB,eCDA,SAAAH,GACCa,IAAAA,EAAAA,EAAAA,KACAC,EAAAA,EAAAA,gBACAC,EAAAA,EAAAA,WACAC,EAAAA,EAAAA,aACAC,EAAAA,EAAAA,SACAC,EAAAA,EAAAA,aACAC,EAAAA,EAAAA,WACAC,EAAAA,EAAAA,WACAC,EAAAA,EAAAA,OACAC,EAAAA,EAAAA,YACAC,EAAAA,EAAAA,QACAC,EAAAA,EAAAA,KACAC,EAAAA,EAAAA,YAEgB1B,EAAG2B,KAIbC,ECLK,EAACC,EAAO,KACnBC,OAAOC,gBAAgB,IAAIC,WAAWH,IAAOI,OAAO,CAACC,EAAIC,IAGrDD,IAFFC,GAAQ,IACG,GACHA,EAAKC,SAAS,IACXD,EAAO,IACTA,EAAO,IAAIC,SAAS,IAAI1B,cACtByB,EAAO,GACV,IAEA,KAGP,IDRaE,CAAO3C,EAAa,iCAAkC,KACtEK,EAAa,CACZC,WAAAA,EACAL,KAAM,KACNO,MAAO,CAAC,UACRE,MAAOwB,IAGR,IAAMU,EAAchB,GAAU5B,EAAa,2BAC3CK,EAAa,CACZC,WAAAA,EACAL,KAAM,SACNO,MAAO,CAAC,UACRE,MAAOkC,IAGR,IAAeC,EAAGd,EAClB1B,EAAa,CACZC,WAAAA,EACAL,KAAM,OACNO,MAAO,CAAC,UACRE,MAAOmC,IAIRxC,EAAa,CACZC,WAAAA,EACAL,KAAM,cACNO,MAAO,CAAC,UACRE,MALwBmB,GAAe,QAQxC,IAAeiB,GAAG,IAAIC,MAAOC,cAC7B3C,EAAa,CACZC,WAAAA,EACAL,KAAM,OACNO,MAAO,CAAC,UACRE,MAAOoC,IAMRzC,EAAa,CACZC,WAAAA,EACAL,KAAM,OACNS,MAAOU,IAMRf,EAAa,CACZC,WAAAA,EACAL,KAAM,kBACNO,MAAO,CAAC,SAAU,aAClBE,WAP4C,IAATU,EACjCC,GAAmB,mBACnBA,IAQHhB,EAAa,CACZC,WAAAA,EACAL,KAAM,aACNO,MAAO,CAAC,SAAU,aAClBE,MAAOY,IAGRjB,EAAa,CACZC,WAAAA,EACAL,KAAM,UACNO,MAAO,CAAC,SAAU,aAClBE,MAAOoB,IAORzB,EAAa,CACZC,WAAAA,EACAL,KAAM,aACNO,MAAO,CAAC,UACRE,MALuBgB,GAAcoB,IAStCzC,EAAa,CACZC,WAAAA,EACAL,KAAM,WACNO,MAAO,CAAC,UACRE,MALqBc,GAAYU,IASlC7B,EAAa,CAAEC,WAAAA,EAAYL,KAAM,eAAgBO,MAAO,CAAC,UAAWE,MAD1Ce,GAAgBmB,IAI1CvC,EAAa,CACZC,WAAAA,EACAL,KAAM,aACNO,MAAO,CAAC,UACRE,MALuBiB,GAAckB,IAWtCxC,EAAa,CACZC,WAAAA,EACAL,KAAM,eACNO,MAAO,CAAC,SAAU,aAClBE,MAAOa,IAGRlB,EAAa,CACZC,WAAAA,EACAL,KAAM,cACNO,MAAO,CAAC,SAAU,aAClBE,MAAOsB,GAGR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1mill/cloudevents",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "Node cloudevents specification and helper",
|
|
5
5
|
"jsnext:main": "dist/index.module.js",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"chai": "^4.3.6",
|
|
38
38
|
"chai-iso8601": "^1.0.0",
|
|
39
39
|
"chai-subset": "^1.6.0",
|
|
40
|
-
"microbundle": "^0.
|
|
40
|
+
"microbundle": "^0.15.1",
|
|
41
41
|
"mocha": "^10.0.0",
|
|
42
42
|
"sinon": "^14.0.0"
|
|
43
43
|
}
|
package/src/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export class Cloudevent {
|
|
|
16
16
|
specversion,
|
|
17
17
|
subject,
|
|
18
18
|
type,
|
|
19
|
+
wschannelid,
|
|
19
20
|
}) {
|
|
20
21
|
const cloudevent = this
|
|
21
22
|
|
|
@@ -133,6 +134,13 @@ export class Cloudevent {
|
|
|
133
134
|
types: ['string', 'undefined'],
|
|
134
135
|
value: originatorid
|
|
135
136
|
})
|
|
137
|
+
|
|
138
|
+
setAttribute({
|
|
139
|
+
cloudevent,
|
|
140
|
+
name: 'wschannelid',
|
|
141
|
+
types: ['string', 'undefined'],
|
|
142
|
+
value: wschannelid
|
|
143
|
+
})
|
|
136
144
|
// *******
|
|
137
145
|
}
|
|
138
146
|
}
|
|
@@ -55,6 +55,14 @@ describe('cloudevent#datacontenttype', () => {
|
|
|
55
55
|
describe('when #datacontenttype is input', () => {
|
|
56
56
|
const validValues = ['some-string', undefined]
|
|
57
57
|
|
|
58
|
+
describe(`when #datacontenttype is not of type ${validValues.map(item => typeof item).join(' or ')}`, () => {
|
|
59
|
+
it('throws the proper error', () => {
|
|
60
|
+
const expected = `Cloudevent "datacontenttype" must be of type STRING or UNDEFINED`
|
|
61
|
+
params.datacontenttype = 1234
|
|
62
|
+
expect(() => new Cloudevent(params)).to.throw(expected)
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
|
|
58
66
|
validValues.forEach(value => {
|
|
59
67
|
describe(`when #datacontenttype is a ${typeof value}`, () => {
|
|
60
68
|
it('returns the input value', () => {
|
|
@@ -64,14 +72,6 @@ describe('cloudevent#datacontenttype', () => {
|
|
|
64
72
|
})
|
|
65
73
|
})
|
|
66
74
|
})
|
|
67
|
-
|
|
68
|
-
describe(`when #datacontenttype is not of type ${validValues.map(item => typeof item).join(' or ')}`, () => {
|
|
69
|
-
it('throws the proper error', () => {
|
|
70
|
-
const expected = `Cloudevent "datacontenttype" must be of type STRING or UNDEFINED`
|
|
71
|
-
params.datacontenttype = 1234
|
|
72
|
-
expect(() => new Cloudevent(params)).to.throw(expected)
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
75
|
})
|
|
76
76
|
})
|
|
77
77
|
})
|
|
@@ -29,7 +29,7 @@ describe('cloudevent#dataschema', () => {
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
describe('when the input value is valid', () => {
|
|
32
|
-
it('
|
|
32
|
+
it('returns the input value', () => {
|
|
33
33
|
params.dataschema = 'some-string'
|
|
34
34
|
const { dataschema } = new Cloudevent(params)
|
|
35
35
|
expect(dataschema).to.eq(params.dataschema)
|
package/src/tests/id.test.js
CHANGED
|
@@ -33,7 +33,7 @@ describe('cloudevent#id', () => {
|
|
|
33
33
|
|
|
34
34
|
describe('when process.env.MILL_CLOUDEVENTS_NANOID_LENGTH is input', () => {
|
|
35
35
|
it('returns a string with the proper length', () => {
|
|
36
|
-
const expected =
|
|
36
|
+
const expected = 123
|
|
37
37
|
|
|
38
38
|
const env = { MILL_CLOUDEVENTS_NANOID_LENGTH: expected }
|
|
39
39
|
sandbox.stub(process, 'env').value(env)
|
|
@@ -13,7 +13,7 @@ describe('cloudevent#originatorid', () => {
|
|
|
13
13
|
})
|
|
14
14
|
|
|
15
15
|
describe('when #originatorid is not input', () => {
|
|
16
|
-
it('returns
|
|
16
|
+
it('returns undefined', () => {
|
|
17
17
|
const { originatorid } = new Cloudevent(params)
|
|
18
18
|
expect(originatorid).to.be.undefined
|
|
19
19
|
})
|
|
@@ -29,7 +29,7 @@ describe('cloudevent#originatorid', () => {
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
describe('when the input value is valid', () => {
|
|
32
|
-
it('
|
|
32
|
+
it('returns the input value', () => {
|
|
33
33
|
params.originatorid = 'some-originator-id'
|
|
34
34
|
const { originatorid } = new Cloudevent(params)
|
|
35
35
|
expect(originatorid).to.eq(params.originatorid)
|
|
@@ -30,7 +30,7 @@ describe('cloudevent#originid', () => {
|
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
describe('when the input value is valid', () => {
|
|
33
|
-
it('
|
|
33
|
+
it('returns the input value', () => {
|
|
34
34
|
params.originid = 'some-origin-id'
|
|
35
35
|
const { originid } = new Cloudevent(params)
|
|
36
36
|
expect(originid).to.eq(params.originid)
|
|
@@ -30,7 +30,7 @@ describe('cloudevent#originsource', () => {
|
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
describe('when the input value is valid', () => {
|
|
33
|
-
it('
|
|
33
|
+
it('returns the input value', () => {
|
|
34
34
|
params.originsource = 'some-origin-source'
|
|
35
35
|
const { originsource } = new Cloudevent(params)
|
|
36
36
|
expect(originsource).to.eq(params.originsource)
|
|
@@ -29,7 +29,7 @@ describe('cloudevent#origintime', () => {
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
describe('when the input value is valid', () => {
|
|
32
|
-
it('
|
|
32
|
+
it('returns the input value', () => {
|
|
33
33
|
params.origintime = new Date().toISOString()
|
|
34
34
|
const { origintime } = new Cloudevent(params)
|
|
35
35
|
expect(origintime).to.eq(params.origintime)
|
|
@@ -30,7 +30,7 @@ describe('cloudevent#origintype', () => {
|
|
|
30
30
|
})
|
|
31
31
|
|
|
32
32
|
describe('when the input value is valtype', () => {
|
|
33
|
-
it('
|
|
33
|
+
it('returns the input value', () => {
|
|
34
34
|
params.origintype = 'some-origin-type'
|
|
35
35
|
const { origintype } = new Cloudevent(params)
|
|
36
36
|
expect(origintype).to.eq(params.origintype)
|
package/src/tests/source.test.js
CHANGED
|
@@ -32,7 +32,7 @@ describe('cloudevent#source', () => {
|
|
|
32
32
|
})
|
|
33
33
|
|
|
34
34
|
describe('when process.env.MILL_CLOUDEVENTS_SOURCE is input', () => {
|
|
35
|
-
it('returns the input
|
|
35
|
+
it('returns the input value', () => {
|
|
36
36
|
const expected = 'some-env-var-value'
|
|
37
37
|
|
|
38
38
|
const env = { MILL_CLOUDEVENTS_SOURCE: expected }
|
|
@@ -29,7 +29,7 @@ describe('cloudevent#subject', () => {
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
describe('when the input value is valid', () => {
|
|
32
|
-
it('
|
|
32
|
+
it('returns the input value', () => {
|
|
33
33
|
params.subject = 'some-string'
|
|
34
34
|
const { subject } = new Cloudevent(params)
|
|
35
35
|
expect(subject).to.eq(params.subject)
|
package/src/tests/time.test.js
CHANGED
|
@@ -21,7 +21,7 @@ describe('cloudevent#time', () => {
|
|
|
21
21
|
expect(time).to.be.a('string')
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
it('returns the current
|
|
24
|
+
it('returns the current datetime in ISO8601 format', () => {
|
|
25
25
|
const clock = useFakeTimers()
|
|
26
26
|
|
|
27
27
|
clock.tick(987654321) // * Jump into the future
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Cloudevent } from '../index.js'
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
|
|
4
|
+
describe('cloudevent#wschannelid', () => {
|
|
5
|
+
let params
|
|
6
|
+
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
params = {
|
|
9
|
+
// * Required base defaults
|
|
10
|
+
source: 'some-source',
|
|
11
|
+
type: 'some-type',
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
describe('when #wschannelid is not input', () => {
|
|
16
|
+
it('returns undefined', () => {
|
|
17
|
+
const { wschannelid } = new Cloudevent(params)
|
|
18
|
+
expect(wschannelid).to.be.undefined
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
describe('when #wschannelid is input', () => {
|
|
23
|
+
describe('when the input value is invalid', () => {
|
|
24
|
+
it('throws the proper error', () => {
|
|
25
|
+
const expected = 'Cloudevent "wschannelid" must be of type STRING or UNDEFINED'
|
|
26
|
+
params.wschannelid = 1234
|
|
27
|
+
expect(() => new Cloudevent(params)).to.throw(expected)
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
describe('when the input value is valid', () => {
|
|
32
|
+
it('returns the input value', () => {
|
|
33
|
+
params.wschannelid = 'some-wschannel-id'
|
|
34
|
+
const { wschannelid } = new Cloudevent(params)
|
|
35
|
+
expect(wschannelid).to.eq(params.wschannelid)
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
})
|