@1mill/cloudevents 4.0.1 → 4.1.0

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 ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog for @1mill/cloudevents
2
+
3
+ ## 4.1.0
4
+
5
+ * Add new optional `originatorid` attribute.
6
+ * Add unit tests for every Cloudevent attribute (e.g. `id`, `data`, `originid`, etc.) using `mocha`, `sinon`, and `chai`.
7
+
8
+ ## 4.0.1
9
+
10
+ * Check that `process.env` be defined before using it to fix compatability issue with browsers.
11
+ * Replace `require` with `import`.
12
+
13
+ ## 4.0.0
14
+
15
+ * Bundle package with `microbundle@^0.14.2` to build Browser and Node compatable versions.
16
+ * Change pacakge to `"type": "module"`.
package/README.md CHANGED
@@ -21,72 +21,69 @@ npm install @1mill/cloudevents@^4
21
21
  const { Cloudevent } = require('@1mill/cloudevents') // CommonJs
22
22
  import { Cloudevent } from '@1mill/cloudevents' // EMS
23
23
 
24
- const cloudevent = new Cloudevent({
25
- data: JSON.stringify({
26
- someAttribute: 'yes',
27
- someOtherAttribute: { thing: true },
28
- }),
29
- source: 'https://www.my-website.com/my/page/123', // * Required
30
- subject: '123',
31
- type: 'cmd.do-this-command.v0', // * Required
24
+ const originCloudevent = new Cloudevent({
25
+ data: JSON.stringify({ some: 'payload' }),
26
+ source: 'https://github.com/1mill/cloudevents',
27
+ type: 'cmd.do-this-command.v0',
28
+ originatorid: 'user.id.1234',
32
29
  })
33
-
34
- console.log(cloudevent)
35
- // Cloudevent {
36
- // id: '-of0T1jfpvD7_lOXtynbb',
37
- // source: 'https://www.my-website.come/my/page/123',
30
+ console.log(originCloudevent)
31
+ // {
32
+ // id: 'f_2R8OyOtfYW4YPs2SOdv',
33
+ // source: 'https://github.com/1mill/cloudevents',
38
34
  // type: 'cmd.do-this-command.v0',
39
35
  // specversion: '1.0',
40
- // data: '{"someAttribute":"yes","someOtherAttribute":{"thing":true}}',
36
+ // time: '2022-09-16T03:47:47.310Z',
37
+ // data: '{"some":"payload"}',
41
38
  // datacontenttype: 'application/json',
42
39
  // dataschema: undefined,
43
- // subject: '123',
44
- // time: '2021-09-06T16:29:26.527Z',
45
- // origintime: '2021-09-06T16:29:26.527Z',
46
- // originid: '-of0T1jfpvD7_lOXtynbb',
47
- // originsource: 'https://www.my-website.come/my/page/123',
48
- // origintype: 'cmd.do-this-command.v0'
40
+ // subject: undefined,
41
+ // origintime: '2022-09-16T03:47:47.310Z',
42
+ // originid: 'f_2R8OyOtfYW4YPs2SOdv',
43
+ // originsource: 'https://github.com/1mill/cloudevents',
44
+ // origintype: 'cmd.do-this-command.v0',
45
+ // originatorid: 'user.id.1234'
49
46
  // }
50
47
 
51
- const enrichment = payloadFromMyBusinessProcess()
52
- const myReactionCloudevent = new Cloudevent({
53
- ...cloudevent,
54
- data: JSON.stringify(enrichment),
55
- source: 'arn:aws:lambda:us-east-1:123456789012:function:my-function',
56
- type: 'fct.this-thing-happened.v0',
48
+ const enrichedCloudevent = new Cloudevent({
49
+ ...originCloudevent,
50
+ data: JSON.stringify({ new: 'payload', value: true }),
51
+ source: 'https://www.erikekberg.com/',
52
+ type: 'fct.this-thing-happened.v0',
57
53
  })
58
-
59
- console.log(myReactionCloudevent)
60
- // Cloudevent {
61
- // id: 'N02yLAd_bZeZLGRUl78AS',
62
- // source: 'arn:aws:lambda:us-east-1:123456789012:function:my-function',
54
+ console.log(enrichedCloudevent)
55
+ // {
56
+ // id: 'mux85XsamwvGkDFgeElQy',
57
+ // source: 'https://www.erikekberg.com/',
63
58
  // type: 'fct.this-thing-happened.v0',
64
59
  // specversion: '1.0',
65
- // data: '{...}',
60
+ // time: '2022-09-16T03:47:47.320Z',
61
+ // data: '{"new":"payload","value":true}',
66
62
  // datacontenttype: 'application/json',
67
63
  // dataschema: undefined,
68
- // subject: '123',
69
- // time: '2021-09-06T16:38:49.717Z',
70
- // origintime: '2021-09-06T16:29:26.527Z',
71
- // originid: '-of0T1jfpvD7_lOXtynbb',
72
- // originsource: 'https://www.my-website.come/my/page/123',
73
- // origintype: 'cmd.do-this-command.v0'
64
+ // subject: undefined,
65
+ // origintime: '2022-09-16T03:47:47.310Z',
66
+ // originid: 'f_2R8OyOtfYW4YPs2SOdv',
67
+ // originsource: 'https://github.com/1mill/cloudevents',
68
+ // origintype: 'cmd.do-this-command.v0',
69
+ // originatorid: 'user.id.1234'
74
70
  // }
75
71
  ```
76
72
 
77
- | | Required | Type | Default | Notes |
78
- |-----------------|----------|--------|--------------------------------------|------------------------------------------------------------------------------------------|
79
- | data | | Any | | |
80
- | datacontenttype | | String | | If "data" is present, defaults to "application/json" unless specified otherwise |
81
- | dataschema | | String | | |
82
- | source | yes | String | process.env.MILL_CLOUDEVENTS_SOURCE | Recommended to use universal identifier (e.g. https://my-domain.com/my/feature/path/123) |
83
- | specversion | yes | String | 1.0 | Cloudevent specification version |
84
- | subject | | String | | |
85
- | type | yes | String | | |
86
- | origintime | yes | String | "time" property | "time" property is internally generated as part of the package |
87
- | originid | yes | String | "id" property | "id" property is internally generated as part of the package |
88
- | originsource | yes | String | "source" property | |
89
- | origintype | yes | String | "type" property | |
73
+ | | Required | Type | Default | Notes |
74
+ |----------------- |---------- |-------- |------------------------------------- |------------------------------------------------------------------------------------------ |
75
+ | data | | Any | | |
76
+ | datacontenttype | | String | | If "data" is present, defaults to "application/json" unless specified otherwise |
77
+ | dataschema | | String | | |
78
+ | source | yes | String | process.env.MILL_CLOUDEVENTS_SOURCE | Recommended to use universal identifier (e.g. <https://my-domain.com/my/feature/path/123>)|
79
+ | specversion | yes | String | 1.0 | Cloudevent specification version |
80
+ | subject | | String | | |
81
+ | type | yes | String | | |
82
+ | originid | yes | String | "id" property | "id" property is internally generated as part of the package |
83
+ | originsource | yes | String | "source" property | |
84
+ | origintime | yes | String | "time" property | "time" property is internally generated as part of the package |
85
+ | origintype | yes | String | "type" property | |
86
+ | originatorid | | String | | |
90
87
 
91
88
  ## Release new version
92
89
 
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var t=require("nanoid"),i=function(t){return"undefined"!=typeof process&&process&&process.env&&process.env[t]};exports.Cloudevent=function(e){var r=e.data,o=e.datacontenttype,s=e.dataschema,n=e.originid,h=e.originsource,u=e.origintime,d=e.origintype,a=e.source,g=e.specversion,p=e.subject,c=e.type;if(this.id=t.nanoid(i("MILL_CLOUDEVENTS_NANOID_LENGTH")||21),!this.id)throw new Error('Cloudevent "id" is required');if("string"!=typeof this.id)throw new Error('Cloudevent "id" must be a string');if(this.source=a||i("MILL_CLOUDEVENTS_SOURCE"),!this.source)throw new Error('Cloudevent "source" is required');if("string"!=typeof this.source)throw new Error('Cloudevent "source" must be a string');if(this.type=c,!this.type)throw new Error('Cloudevent "type" is required');if("string"!=typeof this.type)throw new Error('Cloudevent "type" must be a string');if(this.specversion=g||"1.0",!this.specversion)throw new Error('Cloudevent "specversion" is required');if("string"!=typeof this.specversion)throw new Error('Cloudevent "specversion" must be a string');if(this.data=r,this.datacontenttype=void 0!==this.data?o||"application/json":o,this.datacontenttype&&"string"!=typeof this.datacontenttype)throw new Error('Cloudevent "datacontenttype" must be a string');if(this.dataschema=s,this.dataschema&&"string"!=typeof this.dataschema)throw new Error('Cloudevent "dataschema" must be a string');if(this.subject=p,this.subject&&"string"!=typeof this.subject)throw new Error('Cloudevent "subject" must be a string');if(this.time=(new Date).toISOString(),this.origintime=u||this.time,!this.origintime)throw new Error('Cloudevent "origintime" is required');if("string"!=typeof this.origintime)throw new Error('Cloudevent "origintime" must be a string');if(this.originid=n||this.id,!this.originid)throw new Error('Cloudevent "originid" is required');if("string"!=typeof this.originid)throw new Error('Cloudevent "originid" must be a string');if(this.originsource=h||this.source,!this.originsource)throw new Error('Cloudevent "originsource" is required');if("string"!=typeof this.originsource)throw new Error('Cloudevent "originsource" must be a string');if(this.origintype=d||this.type,!this.origintype)throw new Error('Cloudevent "origintype" is required');if("string"!=typeof this.origintype)throw new Error('Cloudevent "origintype" must be a string')};
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,v=i.originsource,d=i.origintime,c=i.origintype,l=i.source,p=i.specversion,g=i.subject,y=i.type,m=this,f=e.nanoid(n("MILL_CLOUDEVENTS_NANOID_LENGTH",21));t({cloudevent:m,name:"id",types:["string"],value:f});var E=l||n("MILL_CLOUDEVENTS_SOURCE");t({cloudevent:m,name:"source",types:["string"],value:E});var L=y;t({cloudevent:m,name:"type",types:["string"],value:L}),t({cloudevent:m,name:"specversion",types:["string"],value:p||"1.0"});var C=(new Date).toISOString();t({cloudevent:m,name:"time",types:["string"],value:C}),t({cloudevent:m,name:"data",value:a}),t({cloudevent:m,name:"datacontenttype",types:["string","undefined"],value:void 0!==a?o||"application/json":o}),t({cloudevent:m,name:"dataschema",types:["string","undefined"],value:r}),t({cloudevent:m,name:"subject",types:["string","undefined"],value:g}),t({cloudevent:m,name:"origintime",types:["string"],value:d||C}),t({cloudevent:m,name:"originid",types:["string"],value:s||f}),t({cloudevent:m,name:"originsource",types:["string"],value:v||E}),t({cloudevent:m,name:"origintype",types:["string"],value:c||L}),t({cloudevent:m,name:"originatorid",types:["string","undefined"],value:u})};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/index.js"],"sourcesContent":["import { nanoid } from 'nanoid'\r\n\r\nconst fetchNodeEnv = name => (typeof process !== 'undefined') && process && process.env && process.env[name]\r\n\r\nexport class Cloudevent {\r\n\tconstructor({\r\n\t\tdata,\r\n\t\tdatacontenttype,\r\n\t\tdataschema,\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\t// * Required fields by CloudEvent specification\r\n\t\tthis.id = nanoid(fetchNodeEnv('MILL_CLOUDEVENTS_NANOID_LENGTH') || 21)\r\n\t\tif (!this.id) throw new Error('Cloudevent \"id\" is required')\r\n\t\tif (typeof this.id !== 'string') throw new Error('Cloudevent \"id\" must be a string')\r\n\r\n\t\tthis.source = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tif (!this.source) throw new Error('Cloudevent \"source\" is required')\r\n\t\tif (typeof this.source !== 'string') throw new Error('Cloudevent \"source\" must be a string')\r\n\r\n\t\tthis.type = type\r\n\t\tif (!this.type) throw new Error('Cloudevent \"type\" is required')\r\n\t\tif (typeof this.type !== 'string') throw new Error('Cloudevent \"type\" must be a string')\r\n\r\n\t\tthis.specversion = specversion || '1.0'\r\n\t\tif (!this.specversion) throw new Error('Cloudevent \"specversion\" is required')\r\n\t\tif (typeof this.specversion !== 'string') throw new Error('Cloudevent \"specversion\" must be a string')\r\n\r\n\t\t// * Optional fields by CloudEvent specification\r\n\t\tthis.data = data\r\n\r\n\t\tthis.datacontenttype = typeof this.data !== 'undefined'\r\n\t\t\t? datacontenttype || 'application/json'\r\n\t\t\t: datacontenttype\r\n\t\tif (this.datacontenttype && typeof this.datacontenttype !== 'string') throw new Error('Cloudevent \"datacontenttype\" must be a string')\r\n\r\n\t\tthis.dataschema = dataschema\r\n\t\tif (this.dataschema && typeof this.dataschema !== 'string') throw new Error('Cloudevent \"dataschema\" must be a string')\r\n\r\n\t\tthis.subject = subject\r\n\t\tif (this.subject && typeof this.subject !== 'string') throw new Error('Cloudevent \"subject\" must be a string')\r\n\r\n\t\tthis.time = new Date().toISOString()\r\n\r\n\t\t// * In-house extentions\r\n\t\tthis.origintime = origintime || this.time\r\n\t\tif (!this.origintime) throw new Error('Cloudevent \"origintime\" is required')\r\n\t\tif (typeof this.origintime !== 'string') throw new Error('Cloudevent \"origintime\" must be a string')\r\n\r\n\t\tthis.originid = originid || this.id\r\n\t\tif (!this.originid) throw new Error('Cloudevent \"originid\" is required')\r\n\t\tif (typeof this.originid !== 'string') throw new Error('Cloudevent \"originid\" must be a string')\r\n\r\n\t\tthis.originsource = originsource || this.source\r\n\t\tif (!this.originsource) throw new Error('Cloudevent \"originsource\" is required')\r\n\t\tif (typeof this.originsource !== 'string') throw new Error('Cloudevent \"originsource\" must be a string')\r\n\r\n\t\tthis.origintype = origintype || this.type\r\n\t\tif (!this.origintype) throw new Error('Cloudevent \"origintype\" is required')\r\n\t\tif (typeof this.origintype !== 'string') throw new Error('Cloudevent \"origintype\" must be a string')\r\n\t}\r\n}\r\n"],"names":["fetchNodeEnv","name","process","env","data","datacontenttype","dataschema","originid","originsource","origintime","origintype","source","specversion","subject","type","this","id","nanoid","Error","time","Date","toISOString"],"mappings":"wBAEMA,EAAe,SAAAC,SAA4B,oBAAZC,SAA4BA,SAAWA,QAAQC,KAAOD,QAAQC,IAAIF,uBAGtG,gBACCG,IAAAA,KACAC,IAAAA,gBACAC,IAAAA,WACAC,IAAAA,SACAC,IAAAA,aACAC,IAAAA,WACAC,IAAAA,WACAC,IAAAA,OACAC,IAAAA,YACAC,IAAAA,QACAC,IAAAA,KAIA,GADAC,KAAKC,GAAKC,SAAOjB,EAAa,mCAAqC,KAC9De,KAAKC,GAAI,UAAUE,MAAM,+BAC9B,GAAuB,sBAAPF,GAAiB,UAAUE,MAAM,oCAGjD,GADAH,KAAKJ,OAASA,GAAUX,EAAa,4BAChCe,KAAKJ,OAAQ,UAAUO,MAAM,mCAClC,GAA2B,sBAAXP,OAAqB,UAAUO,MAAM,wCAGrD,GADAH,KAAKD,KAAOA,GACPC,KAAKD,KAAM,UAAUI,MAAM,iCAChC,GAAyB,sBAATJ,KAAmB,UAAUI,MAAM,sCAGnD,GADAH,KAAKH,YAAcA,GAAe,OAC7BG,KAAKH,YAAa,UAAUM,MAAM,wCACvC,GAAgC,sBAAhBN,YAA0B,UAAUM,MAAM,6CAQ1D,GALAH,KAAKX,KAAOA,EAEZW,KAAKV,qBAAuC,SAATD,KAChCC,GAAmB,mBACnBA,EACCU,KAAKV,iBAAmD,sBAApBA,gBAA8B,UAAUa,MAAM,iDAGtF,GADAH,KAAKT,WAAaA,EACdS,KAAKT,YAAyC,sBAAfA,WAAyB,UAAUY,MAAM,4CAG5E,GADAH,KAAKF,QAAUA,EACXE,KAAKF,SAAmC,sBAAZA,QAAsB,UAAUK,MAAM,yCAMtE,GAJAH,KAAKI,MAAO,IAAIC,MAAOC,cAGvBN,KAAKN,WAAaA,GAAcM,KAAKI,MAChCJ,KAAKN,WAAY,UAAUS,MAAM,uCACtC,GAA+B,sBAAfT,WAAyB,UAAUS,MAAM,4CAGzD,GADAH,KAAKR,SAAWA,GAAYQ,KAAKC,IAC5BD,KAAKR,SAAU,UAAUW,MAAM,qCACpC,GAA6B,sBAAbX,SAAuB,UAAUW,MAAM,0CAGvD,GADAH,KAAKP,aAAeA,GAAgBO,KAAKJ,QACpCI,KAAKP,aAAc,UAAUU,MAAM,yCACxC,GAAiC,sBAAjBV,aAA2B,UAAUU,MAAM,8CAG3D,GADAH,KAAKL,WAAaA,GAAcK,KAAKD,MAChCC,KAAKL,WAAY,UAAUQ,MAAM,uCACtC,GAA+B,sBAAfR,WAAyB,UAAUQ,MAAM"}
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({ cloudevent, name: 'id', types: ['string'], value: idValue })\r\n\r\n\t\tconst sourceValue = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tsetAttribute({ cloudevent, name: 'source', types: ['string'], value: sourceValue })\r\n\r\n\t\tconst typeValue = type\r\n\t\tsetAttribute({ cloudevent, name: 'type', types: ['string'], value: typeValue })\r\n\r\n\t\tconst specversionValue = specversion || '1.0'\r\n\t\tsetAttribute({ cloudevent, name: 'specversion', types: ['string'], value: specversionValue })\r\n\r\n\t\tconst timeValue = new Date().toISOString()\r\n\t\tsetAttribute({ cloudevent, name: 'time', types: ['string'], value: timeValue })\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional fields by Cloudevent v1 specification\r\n\t\tsetAttribute({ cloudevent, name: 'data', value: data })\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({ cloudevent, name: 'datacontenttype', types: ['string', 'undefined'], value: datacontenttypeValue })\r\n\r\n\t\tsetAttribute({ cloudevent, name: 'dataschema', types: ['string', 'undefined'], value: dataschema })\r\n\r\n\t\tsetAttribute({ cloudevent, name: 'subject', types: ['string', 'undefined'], value: subject })\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({ cloudevent, name: 'origintime', types: ['string'], value: origintimeValue })\r\n\r\n\t\tconst originidValue = originid || idValue\r\n\t\tsetAttribute({ cloudevent, name: 'originid', types: ['string'], value: originidValue })\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({ cloudevent, name: 'origintype', types: ['string'], value: origintypeValue })\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional in-house extentions\r\n\t\tsetAttribute({ cloudevent, name: 'originatorid', types: ['string', 'undefined'], value: originatorid })\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,ECHYG,EAAe,gBAAGC,IAAAA,WAAYL,IAAAA,SAAMM,MAAAA,aAAQ,KAAIC,IAAAA,MAC5D,GAAID,EAAME,OAAS,IAAMF,EAAMG,gBAAgBF,GAAQ,CACtD,IAAMG,iBAAyBV,uBAAyBM,EAAMK,IAAI,SAAAC,UAAKA,EAAEC,aAAN,GAAqBC,OAAOC,KAAK,YACpG,UAAUC,MAAMN,EAChB,CACDL,EAAWL,GAAQO,CACnB,qBCDA,gBACCU,IAAAA,KACAC,IAAAA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MAAO,CAAC,UAAWC,MAD1Ce,GAAgBU,IAI1C5B,EAAa,CAAEC,WAAAA,EAAYL,KAAM,aAAcM,MAAO,CAAC,UAAWC,MAD1CiB,GAAcS,IAMtC7B,EAAa,CAAEC,WAAAA,EAAYL,KAAM,eAAgBM,MAAO,CAAC,SAAU,aAAcC,MAAOa,GAExF"}
@@ -1,2 +1,2 @@
1
- const t=t=>"undefined"!=typeof process&&process&&process.env&&process.env[t];class e{constructor({data:e,datacontenttype:i,dataschema:r,originid:o,originsource:s,origintime:n,origintype:h,source:u,specversion:d,subject:a,type:g}){if(this.id=((t=21)=>{let e="",i=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let r=63&i[t];e+=r<36?r.toString(36):r<62?(r-26).toString(36).toUpperCase():r<63?"_":"-"}return e})(t("MILL_CLOUDEVENTS_NANOID_LENGTH")||21),!this.id)throw new Error('Cloudevent "id" is required');if("string"!=typeof this.id)throw new Error('Cloudevent "id" must be a string');if(this.source=u||t("MILL_CLOUDEVENTS_SOURCE"),!this.source)throw new Error('Cloudevent "source" is required');if("string"!=typeof this.source)throw new Error('Cloudevent "source" must be a string');if(this.type=g,!this.type)throw new Error('Cloudevent "type" is required');if("string"!=typeof this.type)throw new Error('Cloudevent "type" must be a string');if(this.specversion=d||"1.0",!this.specversion)throw new Error('Cloudevent "specversion" is required');if("string"!=typeof this.specversion)throw new Error('Cloudevent "specversion" must be a string');if(this.data=e,this.datacontenttype=void 0!==this.data?i||"application/json":i,this.datacontenttype&&"string"!=typeof this.datacontenttype)throw new Error('Cloudevent "datacontenttype" must be a string');if(this.dataschema=r,this.dataschema&&"string"!=typeof this.dataschema)throw new Error('Cloudevent "dataschema" must be a string');if(this.subject=a,this.subject&&"string"!=typeof this.subject)throw new Error('Cloudevent "subject" must be a string');if(this.time=(new Date).toISOString(),this.origintime=n||this.time,!this.origintime)throw new Error('Cloudevent "origintime" is required');if("string"!=typeof this.origintime)throw new Error('Cloudevent "origintime" must be a string');if(this.originid=o||this.id,!this.originid)throw new Error('Cloudevent "originid" is required');if("string"!=typeof this.originid)throw new Error('Cloudevent "originid" must be a string');if(this.originsource=s||this.source,!this.originsource)throw new Error('Cloudevent "originsource" is required');if("string"!=typeof this.originsource)throw new Error('Cloudevent "originsource" must be a string');if(this.origintype=h||this.type,!this.origintype)throw new Error('Cloudevent "origintype" is required');if("string"!=typeof this.origintype)throw new Error('Cloudevent "origintype" must be a string')}}export{e as Cloudevent};
1
+ const e=(e,t)=>{if("undefined"!=typeof process)return process.env[e]||t},t=({cloudevent:e,name:t,types:n=[],value:o})=>{if(n.length>0&&!n.includes(typeof o)){const e=`Cloudevent "${t}" must be of type ${n.map(e=>e.toUpperCase()).sort().join(" or ")}.`;throw new Error(e)}e[t]=o};class n{constructor({data:n,datacontenttype:o,dataschema:i,originatorid:s,originid:a,originsource:r,origintime:u,origintype:c,source:d,specversion:l,subject:p,type:v}){const g=this,y=((e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_"),""))(e("MILL_CLOUDEVENTS_NANOID_LENGTH",21));t({cloudevent:g,name:"id",types:["string"],value:y});const m=d||e("MILL_CLOUDEVENTS_SOURCE");t({cloudevent:g,name:"source",types:["string"],value:m});const f=v;t({cloudevent:g,name:"type",types:["string"],value:f}),t({cloudevent:g,name:"specversion",types:["string"],value:l||"1.0"});const E=(new Date).toISOString();t({cloudevent:g,name:"time",types:["string"],value:E}),t({cloudevent:g,name:"data",value:n}),t({cloudevent:g,name:"datacontenttype",types:["string","undefined"],value:void 0!==n?o||"application/json":o}),t({cloudevent:g,name:"dataschema",types:["string","undefined"],value:i}),t({cloudevent:g,name:"subject",types:["string","undefined"],value:p}),t({cloudevent:g,name:"origintime",types:["string"],value:u||E}),t({cloudevent:g,name:"originid",types:["string"],value:a||y}),t({cloudevent:g,name:"originsource",types:["string"],value:r||m}),t({cloudevent:g,name:"origintype",types:["string"],value:c||f}),t({cloudevent:g,name:"originatorid",types:["string","undefined"],value:s})}}export{n as Cloudevent};
2
2
  //# sourceMappingURL=index.modern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.modern.js","sources":["../src/index.js","../node_modules/nanoid/index.prod.js"],"sourcesContent":["import { nanoid } from 'nanoid'\r\n\r\nconst fetchNodeEnv = name => (typeof process !== 'undefined') && process && process.env && process.env[name]\r\n\r\nexport class Cloudevent {\r\n\tconstructor({\r\n\t\tdata,\r\n\t\tdatacontenttype,\r\n\t\tdataschema,\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\t// * Required fields by CloudEvent specification\r\n\t\tthis.id = nanoid(fetchNodeEnv('MILL_CLOUDEVENTS_NANOID_LENGTH') || 21)\r\n\t\tif (!this.id) throw new Error('Cloudevent \"id\" is required')\r\n\t\tif (typeof this.id !== 'string') throw new Error('Cloudevent \"id\" must be a string')\r\n\r\n\t\tthis.source = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tif (!this.source) throw new Error('Cloudevent \"source\" is required')\r\n\t\tif (typeof this.source !== 'string') throw new Error('Cloudevent \"source\" must be a string')\r\n\r\n\t\tthis.type = type\r\n\t\tif (!this.type) throw new Error('Cloudevent \"type\" is required')\r\n\t\tif (typeof this.type !== 'string') throw new Error('Cloudevent \"type\" must be a string')\r\n\r\n\t\tthis.specversion = specversion || '1.0'\r\n\t\tif (!this.specversion) throw new Error('Cloudevent \"specversion\" is required')\r\n\t\tif (typeof this.specversion !== 'string') throw new Error('Cloudevent \"specversion\" must be a string')\r\n\r\n\t\t// * Optional fields by CloudEvent specification\r\n\t\tthis.data = data\r\n\r\n\t\tthis.datacontenttype = typeof this.data !== 'undefined'\r\n\t\t\t? datacontenttype || 'application/json'\r\n\t\t\t: datacontenttype\r\n\t\tif (this.datacontenttype && typeof this.datacontenttype !== 'string') throw new Error('Cloudevent \"datacontenttype\" must be a string')\r\n\r\n\t\tthis.dataschema = dataschema\r\n\t\tif (this.dataschema && typeof this.dataschema !== 'string') throw new Error('Cloudevent \"dataschema\" must be a string')\r\n\r\n\t\tthis.subject = subject\r\n\t\tif (this.subject && typeof this.subject !== 'string') throw new Error('Cloudevent \"subject\" must be a string')\r\n\r\n\t\tthis.time = new Date().toISOString()\r\n\r\n\t\t// * In-house extentions\r\n\t\tthis.origintime = origintime || this.time\r\n\t\tif (!this.origintime) throw new Error('Cloudevent \"origintime\" is required')\r\n\t\tif (typeof this.origintime !== 'string') throw new Error('Cloudevent \"origintime\" must be a string')\r\n\r\n\t\tthis.originid = originid || this.id\r\n\t\tif (!this.originid) throw new Error('Cloudevent \"originid\" is required')\r\n\t\tif (typeof this.originid !== 'string') throw new Error('Cloudevent \"originid\" must be a string')\r\n\r\n\t\tthis.originsource = originsource || this.source\r\n\t\tif (!this.originsource) throw new Error('Cloudevent \"originsource\" is required')\r\n\t\tif (typeof this.originsource !== 'string') throw new Error('Cloudevent \"originsource\" must be a string')\r\n\r\n\t\tthis.origintype = origintype || this.type\r\n\t\tif (!this.origintype) throw new Error('Cloudevent \"origintype\" is required')\r\n\t\tif (typeof this.origintype !== 'string') throw new Error('Cloudevent \"origintype\" must be a string')\r\n\t}\r\n}\r\n","import { urlAlphabet } from './url-alphabet/index.js'\nif (false) {\n if (\n typeof navigator !== 'undefined' &&\n navigator.product === 'ReactNative' &&\n typeof crypto === 'undefined'\n ) {\n throw new Error(\n 'React Native does not have a built-in secure random generator. ' +\n 'If you don’t need unpredictable IDs use `nanoid/non-secure`. ' +\n 'For secure IDs, import `react-native-get-random-values` ' +\n 'before Nano ID.'\n )\n }\n if (typeof msCrypto !== 'undefined' && typeof crypto === 'undefined') {\n throw new Error(\n 'Import file with `if (!window.crypto) window.crypto = window.msCrypto`' +\n ' before importing Nano ID to fix IE 11 support'\n )\n }\n if (typeof crypto === 'undefined') {\n throw new Error(\n 'Your browser does not have secure random generator. ' +\n 'If you don’t need unpredictable IDs, you can use nanoid/non-secure.'\n )\n }\n}\nlet random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nlet customRandom = (alphabet, size, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * size) / alphabet.length)\n return () => {\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) => customRandom(alphabet, size, random)\nlet nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array(size))\n while (size--) {\n let byte = bytes[size] & 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 < 63) {\n id += '_'\n } else {\n id += '-'\n }\n }\n return id\n}\nexport { nanoid, customAlphabet, customRandom, urlAlphabet, random }\n"],"names":["fetchNodeEnv","name","process","env","Cloudevent","constructor","data","datacontenttype","dataschema","originid","originsource","origintime","origintype","source","specversion","subject","type","this","id","size","bytes","crypto","getRandomValues","Uint8Array","byte","toString","toUpperCase","nanoid","Error","time","Date","toISOString"],"mappings":"AAEA,MAAMA,EAAeC,GAA4B,oBAAZC,SAA4BA,SAAWA,QAAQC,KAAOD,QAAQC,IAAIF,SAE1FG,EACZC,aAAYC,KACXA,EADWC,gBAEXA,EAFWC,WAGXA,EAHWC,SAIXA,EAJWC,aAKXA,EALWC,WAMXA,EANWC,WAOXA,EAPWC,OAQXA,EARWC,YASXA,EATWC,QAUXA,EAVWC,KAWXA,IAIA,GADAC,KAAKC,GCyBM,EAACC,EAAO,MACnB,IAAID,EAAK,GACLE,EAAQC,OAAOC,gBAAgB,IAAIC,WAAWJ,IAClD,KAAOA,KAAQ,CACb,IAAIK,EAAqB,GAAdJ,EAAMD,GAEfD,GADEM,EAAO,GACHA,EAA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aAA2B,UAAUkB,MAAM,8CAG3D,GADAX,KAAKL,WAAaA,GAAcK,KAAKD,MAChCC,KAAKL,WAAY,UAAUgB,MAAM,uCACtC,GAA+B,sBAAfhB,WAAyB,UAAUgB,MAAM"}
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({ cloudevent, name: 'id', types: ['string'], value: idValue })\r\n\r\n\t\tconst sourceValue = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tsetAttribute({ cloudevent, name: 'source', types: ['string'], value: sourceValue })\r\n\r\n\t\tconst typeValue = type\r\n\t\tsetAttribute({ cloudevent, name: 'type', types: ['string'], value: typeValue })\r\n\r\n\t\tconst specversionValue = specversion || '1.0'\r\n\t\tsetAttribute({ cloudevent, name: 'specversion', types: ['string'], value: specversionValue })\r\n\r\n\t\tconst timeValue = new Date().toISOString()\r\n\t\tsetAttribute({ cloudevent, name: 'time', types: ['string'], value: timeValue })\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional fields by Cloudevent v1 specification\r\n\t\tsetAttribute({ cloudevent, name: 'data', value: data })\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({ cloudevent, name: 'datacontenttype', types: ['string', 'undefined'], value: datacontenttypeValue })\r\n\r\n\t\tsetAttribute({ cloudevent, name: 'dataschema', types: ['string', 'undefined'], value: dataschema })\r\n\r\n\t\tsetAttribute({ cloudevent, name: 'subject', types: ['string', 'undefined'], value: subject })\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({ cloudevent, name: 'origintime', types: ['string'], value: origintimeValue })\r\n\r\n\t\tconst originidValue = originid || idValue\r\n\t\tsetAttribute({ cloudevent, name: 'originid', types: ['string'], value: originidValue })\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({ cloudevent, name: 'origintype', types: ['string'], value: origintypeValue })\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional in-house extentions\r\n\t\tsetAttribute({ cloudevent, name: 'originatorid', types: ['string', 'undefined'], value: originatorid })\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","Cloudevent","constructor","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":"MAAaA,EAAe,CAACC,EAAMC,KAClC,GAAuB,oBAAZC,QACX,OAAOA,QAAQC,IAAIH,IAASC,GCFhBG,EAAe,EAAGC,aAAYL,OAAMM,MAAAA,EAAQ,GAAIC,YAC5D,GAAID,EAAME,OAAS,IAAMF,EAAMG,gBAAgBF,GAAQ,CACtD,MAAMG,EAAW,eAAcV,sBAAyBM,EAAMK,IAAIC,GAAKA,EAAEC,eAAeC,OAAOC,KAAK,WACpG,UAAUC,MAAMN,EAChB,CACDL,EAAWL,GAAQO,SCDPU,EACZC,aAAYC,KACXA,EADWC,gBAEXA,EAFWC,WAGXA,EAHWC,aAIXA,EAJWC,SAKXA,EALWC,aAMXA,EANWC,WAOXA,EAPWC,WAQXA,EARWC,OASXA,EATWC,YAUXA,EAVWC,QAW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AAM,eAAgBM,MAAO,CAAC,UAAWC,MAD1CiB,GAAgBkB,IAI1CtC,EAAa,CAAEC,aAAYL,KAAM,aAAcM,MAAO,CAAC,UAAWC,MAD1CmB,GAAciB,IAMtCvC,EAAa,CAAEC,aAAYL,KAAM,eAAgBM,MAAO,CAAC,SAAU,aAAcC,MAAOe,GAExF"}
@@ -1,2 +1,2 @@
1
- import{nanoid as t}from"nanoid";var i=function(t){return"undefined"!=typeof process&&process&&process.env&&process.env[t]},e=function(e){var r=e.data,o=e.datacontenttype,s=e.dataschema,n=e.originid,h=e.originsource,u=e.origintime,d=e.origintype,a=e.source,g=e.specversion,p=e.subject,c=e.type;if(this.id=t(i("MILL_CLOUDEVENTS_NANOID_LENGTH")||21),!this.id)throw new Error('Cloudevent "id" is required');if("string"!=typeof this.id)throw new Error('Cloudevent "id" must be a string');if(this.source=a||i("MILL_CLOUDEVENTS_SOURCE"),!this.source)throw new Error('Cloudevent "source" is required');if("string"!=typeof this.source)throw new Error('Cloudevent "source" must be a string');if(this.type=c,!this.type)throw new Error('Cloudevent "type" is required');if("string"!=typeof this.type)throw new Error('Cloudevent "type" must be a string');if(this.specversion=g||"1.0",!this.specversion)throw new Error('Cloudevent "specversion" is required');if("string"!=typeof this.specversion)throw new Error('Cloudevent "specversion" must be a string');if(this.data=r,this.datacontenttype=void 0!==this.data?o||"application/json":o,this.datacontenttype&&"string"!=typeof this.datacontenttype)throw new Error('Cloudevent "datacontenttype" must be a string');if(this.dataschema=s,this.dataschema&&"string"!=typeof this.dataschema)throw new Error('Cloudevent "dataschema" must be a string');if(this.subject=p,this.subject&&"string"!=typeof this.subject)throw new Error('Cloudevent "subject" must be a string');if(this.time=(new Date).toISOString(),this.origintime=u||this.time,!this.origintime)throw new Error('Cloudevent "origintime" is required');if("string"!=typeof this.origintime)throw new Error('Cloudevent "origintime" must be a string');if(this.originid=n||this.id,!this.originid)throw new Error('Cloudevent "originid" is required');if("string"!=typeof this.originid)throw new Error('Cloudevent "originid" must be a string');if(this.originsource=h||this.source,!this.originsource)throw new Error('Cloudevent "originsource" is required');if("string"!=typeof this.originsource)throw new Error('Cloudevent "originsource" must be a string');if(this.origintype=d||this.type,!this.origintype)throw new Error('Cloudevent "origintype" is required');if("string"!=typeof this.origintype)throw new Error('Cloudevent "origintype" must be a string')};export{e as Cloudevent};
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,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},i=function(i){var o=i.data,a=i.datacontenttype,r=i.dataschema,u=i.originatorid,s=i.originid,v=i.originsource,d=i.origintime,c=i.origintype,l=i.source,p=i.specversion,g=i.subject,m=i.type,y=this,f=e(n("MILL_CLOUDEVENTS_NANOID_LENGTH",21));t({cloudevent:y,name:"id",types:["string"],value:f});var E=l||n("MILL_CLOUDEVENTS_SOURCE");t({cloudevent:y,name:"source",types:["string"],value:E});var L=m;t({cloudevent:y,name:"type",types:["string"],value:L}),t({cloudevent:y,name:"specversion",types:["string"],value:p||"1.0"});var h=(new Date).toISOString();t({cloudevent:y,name:"time",types:["string"],value:h}),t({cloudevent:y,name:"data",value:o}),t({cloudevent:y,name:"datacontenttype",types:["string","undefined"],value:void 0!==o?a||"application/json":a}),t({cloudevent:y,name:"dataschema",types:["string","undefined"],value:r}),t({cloudevent:y,name:"subject",types:["string","undefined"],value:g}),t({cloudevent:y,name:"origintime",types:["string"],value:d||h}),t({cloudevent:y,name:"originid",types:["string"],value:s||f}),t({cloudevent:y,name:"originsource",types:["string"],value:v||E}),t({cloudevent:y,name:"origintype",types:["string"],value:c||L}),t({cloudevent:y,name:"originatorid",types:["string","undefined"],value:u})};export{i as Cloudevent};
2
2
  //# sourceMappingURL=index.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.module.js","sources":["../src/index.js"],"sourcesContent":["import { nanoid } from 'nanoid'\r\n\r\nconst fetchNodeEnv = name => (typeof process !== 'undefined') && process && process.env && process.env[name]\r\n\r\nexport class Cloudevent {\r\n\tconstructor({\r\n\t\tdata,\r\n\t\tdatacontenttype,\r\n\t\tdataschema,\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\t// * Required fields by CloudEvent specification\r\n\t\tthis.id = nanoid(fetchNodeEnv('MILL_CLOUDEVENTS_NANOID_LENGTH') || 21)\r\n\t\tif (!this.id) throw new Error('Cloudevent \"id\" is required')\r\n\t\tif (typeof this.id !== 'string') throw new Error('Cloudevent \"id\" must be a string')\r\n\r\n\t\tthis.source = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tif (!this.source) throw new Error('Cloudevent \"source\" is required')\r\n\t\tif (typeof this.source !== 'string') throw new Error('Cloudevent \"source\" must be a string')\r\n\r\n\t\tthis.type = type\r\n\t\tif (!this.type) throw new Error('Cloudevent \"type\" is required')\r\n\t\tif (typeof this.type !== 'string') throw new Error('Cloudevent \"type\" must be a string')\r\n\r\n\t\tthis.specversion = specversion || '1.0'\r\n\t\tif (!this.specversion) throw new Error('Cloudevent \"specversion\" is required')\r\n\t\tif (typeof this.specversion !== 'string') throw new Error('Cloudevent \"specversion\" must be a string')\r\n\r\n\t\t// * Optional fields by CloudEvent specification\r\n\t\tthis.data = data\r\n\r\n\t\tthis.datacontenttype = typeof this.data !== 'undefined'\r\n\t\t\t? datacontenttype || 'application/json'\r\n\t\t\t: datacontenttype\r\n\t\tif (this.datacontenttype && typeof this.datacontenttype !== 'string') throw new Error('Cloudevent \"datacontenttype\" must be a string')\r\n\r\n\t\tthis.dataschema = dataschema\r\n\t\tif (this.dataschema && typeof this.dataschema !== 'string') throw new Error('Cloudevent \"dataschema\" must be a string')\r\n\r\n\t\tthis.subject = subject\r\n\t\tif (this.subject && typeof this.subject !== 'string') throw new Error('Cloudevent \"subject\" must be a string')\r\n\r\n\t\tthis.time = new Date().toISOString()\r\n\r\n\t\t// * In-house extentions\r\n\t\tthis.origintime = origintime || this.time\r\n\t\tif (!this.origintime) throw new Error('Cloudevent \"origintime\" is required')\r\n\t\tif (typeof this.origintime !== 'string') throw new Error('Cloudevent \"origintime\" must be a string')\r\n\r\n\t\tthis.originid = originid || this.id\r\n\t\tif (!this.originid) throw new Error('Cloudevent \"originid\" is required')\r\n\t\tif (typeof this.originid !== 'string') throw new Error('Cloudevent \"originid\" must be a string')\r\n\r\n\t\tthis.originsource = originsource || this.source\r\n\t\tif (!this.originsource) throw new Error('Cloudevent \"originsource\" is required')\r\n\t\tif (typeof this.originsource !== 'string') throw new Error('Cloudevent \"originsource\" must be a string')\r\n\r\n\t\tthis.origintype = origintype || this.type\r\n\t\tif (!this.origintype) throw new Error('Cloudevent \"origintype\" is required')\r\n\t\tif (typeof this.origintype !== 'string') throw new Error('Cloudevent \"origintype\" must be a string')\r\n\t}\r\n}\r\n"],"names":["fetchNodeEnv","name","process","env","Cloudevent","data","datacontenttype","dataschema","originid","originsource","origintime","origintype","source","specversion","subject","type","this","id","nanoid","Error","time","Date","toISOString"],"mappings":"gCAEA,IAAMA,EAAe,SAAAC,SAA4B,oBAAZC,SAA4BA,SAAWA,QAAQC,KAAOD,QAAQC,IAAIF,IAE1FG,EACZ,gBACCC,IAAAA,KACAC,IAAAA,gBACAC,IAAAA,WACAC,IAAAA,SACAC,IAAAA,aACAC,IAAAA,WACAC,IAAAA,WACAC,IAAAA,OACAC,IAAAA,YACAC,IAAAA,QACAC,IAAAA,KAIA,GADAC,KAAKC,GAAKC,EAAOlB,EAAa,mCAAqC,KAC9DgB,KAAKC,GAAI,UAAUE,MAAM,+BAC9B,GAAuB,sBAAPF,GAAiB,UAAUE,MAAM,oCAGjD,GADAH,KAAKJ,OAASA,GAAUZ,EAAa,4BAChCgB,KAAKJ,OAAQ,UAAUO,MAAM,mCAClC,GAA2B,sBAAXP,OAAqB,UAAUO,MAAM,wCAGrD,GADAH,KAAKD,KAAOA,GACPC,KAAKD,KAAM,UAAUI,MAAM,iCAChC,GAAyB,sBAATJ,KAAmB,UAAUI,MAAM,sCAGnD,GADAH,KAAKH,YAAcA,GAAe,OAC7BG,KAAKH,YAAa,UAAUM,MAAM,wCACvC,GAAgC,sBAAhBN,YAA0B,UAAUM,MAAM,6CAQ1D,GALAH,KAAKX,KAAOA,EAEZW,KAAKV,qBAAuC,SAATD,KAChCC,GAAmB,mBACnBA,EACCU,KAAKV,iBAAmD,sBAApBA,gBAA8B,UAAUa,MAAM,iDAGtF,GADAH,KAAKT,WAAaA,EACdS,KAAKT,YAAyC,sBAAfA,WAAyB,UAAUY,MAAM,4CAG5E,GADAH,KAAKF,QAAUA,EACXE,KAAKF,SAAmC,sBAAZA,QAAsB,UAAUK,MAAM,yCAMtE,GAJAH,KAAKI,MAAO,IAAIC,MAAOC,cAGvBN,KAAKN,WAAaA,GAAcM,KAAKI,MAChCJ,KAAKN,WAAY,UAAUS,MAAM,uCACtC,GAA+B,sBAAfT,WAAyB,UAAUS,MAAM,4CAGzD,GADAH,KAAKR,SAAWA,GAAYQ,KAAKC,IAC5BD,KAAKR,SAAU,UAAUW,MAAM,qCACpC,GAA6B,sBAAbX,SAAuB,UAAUW,MAAM,0CAGvD,GADAH,KAAKP,aAAeA,GAAgBO,KAAKJ,QACpCI,KAAKP,aAAc,UAAUU,MAAM,yCACxC,GAAiC,sBAAjBV,aAA2B,UAAUU,MAAM,8CAG3D,GADAH,KAAKL,WAAaA,GAAcK,KAAKD,MAChCC,KAAKL,WAAY,UAAUQ,MAAM,uCACtC,GAA+B,sBAAfR,WAAyB,UAAUQ,MAAM"}
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({ cloudevent, name: 'id', types: ['string'], value: idValue })\r\n\r\n\t\tconst sourceValue = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tsetAttribute({ cloudevent, name: 'source', types: ['string'], value: sourceValue })\r\n\r\n\t\tconst typeValue = type\r\n\t\tsetAttribute({ cloudevent, name: 'type', types: ['string'], value: typeValue })\r\n\r\n\t\tconst specversionValue = specversion || '1.0'\r\n\t\tsetAttribute({ cloudevent, name: 'specversion', types: ['string'], value: specversionValue })\r\n\r\n\t\tconst timeValue = new Date().toISOString()\r\n\t\tsetAttribute({ cloudevent, name: 'time', types: ['string'], value: timeValue })\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional fields by Cloudevent v1 specification\r\n\t\tsetAttribute({ cloudevent, name: 'data', value: data })\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({ cloudevent, name: 'datacontenttype', types: ['string', 'undefined'], value: datacontenttypeValue })\r\n\r\n\t\tsetAttribute({ cloudevent, name: 'dataschema', types: ['string', 'undefined'], value: dataschema })\r\n\r\n\t\tsetAttribute({ cloudevent, name: 'subject', types: ['string', 'undefined'], value: subject })\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({ cloudevent, name: 'origintime', types: ['string'], value: origintimeValue })\r\n\r\n\t\tconst originidValue = originid || idValue\r\n\t\tsetAttribute({ cloudevent, name: 'originid', types: ['string'], value: originidValue })\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({ cloudevent, name: 'origintype', types: ['string'], value: origintypeValue })\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional in-house extentions\r\n\t\tsetAttribute({ cloudevent, name: 'originatorid', types: ['string', 'undefined'], value: originatorid })\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":"oCAAaA,EAAe,SAACC,EAAMC,GAClC,GAAuB,oBAAZC,QACX,OAAOA,QAAQC,IAAIH,IAASC,CAC5B,ECHYG,EAAe,gBAAGC,IAAAA,WAAYL,IAAAA,SAAMM,MAAAA,aAAQ,KAAIC,IA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AAC,SAAU,aAAcC,MAAOqB,IAMnFxB,EAAa,CAAEC,WAAAA,EAAYL,KAAM,aAAcM,MAAO,CAAC,UAAWC,MAD1CiB,GAAcW,IAItC/B,EAAa,CAAEC,WAAAA,EAAYL,KAAM,WAAYM,MAAO,CAAC,UAAWC,MAD1Ce,GAAYS,IAIlC3B,EAAa,CAAEC,WAAAA,EAAYL,KAAM,eAAgBM,MAAO,CAAC,UAAWC,MAD1CgB,GAAgBU,IAI1C7B,EAAa,CAAEC,WAAAA,EAAYL,KAAM,aAAcM,MAAO,CAAC,UAAWC,MAD1CkB,GAAcS,IAMtC9B,EAAa,CAAEC,WAAAA,EAAYL,KAAM,eAAgBM,MAAO,CAAC,SAAU,aAAcC,MAAOc,GAExF"}
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t||self).cloudevents={})}(this,function(t){var e=function(t){return"undefined"!=typeof process&&process&&process.env&&process.env[t]};t.Cloudevent=function(t){var i=t.data,r=t.datacontenttype,o=t.dataschema,s=t.originid,n=t.originsource,u=t.origintime,d=t.origintype,h=t.source,a=t.specversion,g=t.subject,p=t.type;if(this.id=((t=21)=>{let e="",i=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let r=63&i[t];e+=r<36?r.toString(36):r<62?(r-26).toString(36).toUpperCase():r<63?"_":"-"}return e})(e("MILL_CLOUDEVENTS_NANOID_LENGTH")||21),!this.id)throw new Error('Cloudevent "id" is required');if("string"!=typeof this.id)throw new Error('Cloudevent "id" must be a string');if(this.source=h||e("MILL_CLOUDEVENTS_SOURCE"),!this.source)throw new Error('Cloudevent "source" is required');if("string"!=typeof this.source)throw new Error('Cloudevent "source" must be a string');if(this.type=p,!this.type)throw new Error('Cloudevent "type" is required');if("string"!=typeof this.type)throw new Error('Cloudevent "type" must be a string');if(this.specversion=a||"1.0",!this.specversion)throw new Error('Cloudevent "specversion" is required');if("string"!=typeof this.specversion)throw new Error('Cloudevent "specversion" must be a string');if(this.data=i,this.datacontenttype=void 0!==this.data?r||"application/json":r,this.datacontenttype&&"string"!=typeof this.datacontenttype)throw new Error('Cloudevent "datacontenttype" must be a string');if(this.dataschema=o,this.dataschema&&"string"!=typeof this.dataschema)throw new Error('Cloudevent "dataschema" must be a string');if(this.subject=g,this.subject&&"string"!=typeof this.subject)throw new Error('Cloudevent "subject" must be a string');if(this.time=(new Date).toISOString(),this.origintime=u||this.time,!this.origintime)throw new Error('Cloudevent "origintime" is required');if("string"!=typeof this.origintime)throw new Error('Cloudevent "origintime" must be a string');if(this.originid=s||this.id,!this.originid)throw new Error('Cloudevent "originid" is required');if("string"!=typeof this.originid)throw new Error('Cloudevent "originid" must be a string');if(this.originsource=n||this.source,!this.originsource)throw new Error('Cloudevent "originsource" is required');if("string"!=typeof this.originsource)throw new Error('Cloudevent "originsource" must be a string');if(this.origintype=d||this.type,!this.origintype)throw new Error('Cloudevent "origintype" is required');if("string"!=typeof this.origintype)throw new Error('Cloudevent "origintype" must be a string')}});
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,o=e.types,i=void 0===o?[]:o,a=e.value;if(i.length>0&&!i.includes(typeof a)){var r='Cloudevent "'+t+'" must be of type '+i.map(function(e){return e.toUpperCase()}).sort().join(" or ")+".";throw new Error(r)}n[t]=a};e.Cloudevent=function(e){var o=e.data,i=e.datacontenttype,a=e.dataschema,r=e.originatorid,u=e.originid,s=e.originsource,d=e.origintime,v=e.origintype,l=e.source,c=e.specversion,p=e.subject,g=e.type,y=this,f=((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:y,name:"id",types:["string"],value:f});var m=l||n("MILL_CLOUDEVENTS_SOURCE");t({cloudevent:y,name:"source",types:["string"],value:m});var h=g;t({cloudevent:y,name:"type",types:["string"],value:h}),t({cloudevent:y,name:"specversion",types:["string"],value:c||"1.0"});var C=(new Date).toISOString();t({cloudevent:y,name:"time",types:["string"],value:C}),t({cloudevent:y,name:"data",value:o}),t({cloudevent:y,name:"datacontenttype",types:["string","undefined"],value:void 0!==o?i||"application/json":i}),t({cloudevent:y,name:"dataschema",types:["string","undefined"],value:a}),t({cloudevent:y,name:"subject",types:["string","undefined"],value:p}),t({cloudevent:y,name:"origintime",types:["string"],value:d||C}),t({cloudevent:y,name:"originid",types:["string"],value:u||f}),t({cloudevent:y,name:"originsource",types:["string"],value:s||m}),t({cloudevent:y,name:"origintype",types:["string"],value:v||h}),t({cloudevent:y,name:"originatorid",types:["string","undefined"],value:r})}});
2
2
  //# sourceMappingURL=index.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/index.js","../node_modules/nanoid/index.prod.js"],"sourcesContent":["import { nanoid } from 'nanoid'\r\n\r\nconst fetchNodeEnv = name => (typeof process !== 'undefined') && process && process.env && process.env[name]\r\n\r\nexport class Cloudevent {\r\n\tconstructor({\r\n\t\tdata,\r\n\t\tdatacontenttype,\r\n\t\tdataschema,\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\t// * Required fields by CloudEvent specification\r\n\t\tthis.id = nanoid(fetchNodeEnv('MILL_CLOUDEVENTS_NANOID_LENGTH') || 21)\r\n\t\tif (!this.id) throw new Error('Cloudevent \"id\" is required')\r\n\t\tif (typeof this.id !== 'string') throw new Error('Cloudevent \"id\" must be a string')\r\n\r\n\t\tthis.source = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tif (!this.source) throw new Error('Cloudevent \"source\" is required')\r\n\t\tif (typeof this.source !== 'string') throw new Error('Cloudevent \"source\" must be a string')\r\n\r\n\t\tthis.type = type\r\n\t\tif (!this.type) throw new Error('Cloudevent \"type\" is required')\r\n\t\tif (typeof this.type !== 'string') throw new Error('Cloudevent \"type\" must be a string')\r\n\r\n\t\tthis.specversion = specversion || '1.0'\r\n\t\tif (!this.specversion) throw new Error('Cloudevent \"specversion\" is required')\r\n\t\tif (typeof this.specversion !== 'string') throw new Error('Cloudevent \"specversion\" must be a string')\r\n\r\n\t\t// * Optional fields by CloudEvent specification\r\n\t\tthis.data = data\r\n\r\n\t\tthis.datacontenttype = typeof this.data !== 'undefined'\r\n\t\t\t? datacontenttype || 'application/json'\r\n\t\t\t: datacontenttype\r\n\t\tif (this.datacontenttype && typeof this.datacontenttype !== 'string') throw new Error('Cloudevent \"datacontenttype\" must be a string')\r\n\r\n\t\tthis.dataschema = dataschema\r\n\t\tif (this.dataschema && typeof this.dataschema !== 'string') throw new Error('Cloudevent \"dataschema\" must be a string')\r\n\r\n\t\tthis.subject = subject\r\n\t\tif (this.subject && typeof this.subject !== 'string') throw new Error('Cloudevent \"subject\" must be a string')\r\n\r\n\t\tthis.time = new Date().toISOString()\r\n\r\n\t\t// * In-house extentions\r\n\t\tthis.origintime = origintime || this.time\r\n\t\tif (!this.origintime) throw new Error('Cloudevent \"origintime\" is required')\r\n\t\tif (typeof this.origintime !== 'string') throw new Error('Cloudevent \"origintime\" must be a string')\r\n\r\n\t\tthis.originid = originid || this.id\r\n\t\tif (!this.originid) throw new Error('Cloudevent \"originid\" is required')\r\n\t\tif (typeof this.originid !== 'string') throw new Error('Cloudevent \"originid\" must be a string')\r\n\r\n\t\tthis.originsource = originsource || this.source\r\n\t\tif (!this.originsource) throw new Error('Cloudevent \"originsource\" is required')\r\n\t\tif (typeof this.originsource !== 'string') throw new Error('Cloudevent \"originsource\" must be a string')\r\n\r\n\t\tthis.origintype = origintype || this.type\r\n\t\tif (!this.origintype) throw new Error('Cloudevent \"origintype\" is required')\r\n\t\tif (typeof this.origintype !== 'string') throw new Error('Cloudevent \"origintype\" must be a string')\r\n\t}\r\n}\r\n","import { urlAlphabet } from './url-alphabet/index.js'\nif (false) {\n if (\n typeof navigator !== 'undefined' &&\n navigator.product === 'ReactNative' &&\n typeof crypto === 'undefined'\n ) {\n throw new Error(\n 'React Native does not have a built-in secure random generator. ' +\n 'If you don’t need unpredictable IDs use `nanoid/non-secure`. ' +\n 'For secure IDs, import `react-native-get-random-values` ' +\n 'before Nano ID.'\n )\n }\n if (typeof msCrypto !== 'undefined' && typeof crypto === 'undefined') {\n throw new Error(\n 'Import file with `if (!window.crypto) window.crypto = window.msCrypto`' +\n ' before importing Nano ID to fix IE 11 support'\n )\n }\n if (typeof crypto === 'undefined') {\n throw new Error(\n 'Your browser does not have secure random generator. ' +\n 'If you don’t need unpredictable IDs, you can use nanoid/non-secure.'\n )\n }\n}\nlet random = bytes => crypto.getRandomValues(new Uint8Array(bytes))\nlet customRandom = (alphabet, size, getRandom) => {\n let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1\n let step = -~((1.6 * mask * size) / alphabet.length)\n return () => {\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) => customRandom(alphabet, size, random)\nlet nanoid = (size = 21) => {\n let id = ''\n let bytes = crypto.getRandomValues(new Uint8Array(size))\n while (size--) {\n let byte = bytes[size] & 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 < 63) {\n id += '_'\n } else {\n id += '-'\n }\n }\n return id\n}\nexport { nanoid, customAlphabet, customRandom, urlAlphabet, random }\n"],"names":["fetchNodeEnv","name","process","env","data","datacontenttype","dataschema","originid","originsource","origintime","origintype","source","specversion","subject","type","this","id","size","bytes","crypto","getRandomValues","Uint8Array","byte","toString","toUpperCase","nanoid","Error","time","Date","toISOString"],"mappings":"qOAEA,IAAMA,EAAe,SAAAC,SAA4B,oBAAZC,SAA4BA,SAAWA,QAAQC,KAAOD,QAAQC,IAAIF,iBAGtG,gBACCG,IAAAA,KACAC,IAAAA,gBACAC,IAAAA,WACAC,IAAAA,SACAC,IAAAA,aACAC,IAAAA,WACAC,IAAAA,WACAC,IAAAA,OACAC,IAAAA,YACAC,IAAAA,QACAC,IAAAA,KAIA,GADAC,KAAKC,GCyBM,EAACC,EAAO,MACnB,IAAID,EAAK,GACLE,EAAQC,OAAOC,gBAAgB,IAAIC,WAAWJ,IAClD,KAAOA,KAAQ,CACb,IAAIK,EAAqB,GAAdJ,EAAMD,GAEfD,GADEM,EAAO,GACHA,EAAKC,SAAS,IACXD,EAAO,IACTA,EAAO,IAAIC,SAAS,IAAIC,cACtBF,EAAO,GACV,IAEA,IAGV,OAAON,GDxCGS,CAAOzB,EAAa,mCAAqC,KAC9De,KAAKC,GAAI,UAAUU,MAAM,+BAC9B,GAAuB,sBAAPV,GAAiB,UAAUU,MAAM,oCAGjD,GADAX,KAAKJ,OAASA,GAAUX,EAAa,4BAChCe,KAAKJ,OAAQ,UAAUe,MAAM,mCAClC,GAA2B,sBAAXf,OAAqB,UAAUe,MAAM,wCAGrD,GADAX,KAAKD,KAAOA,GACPC,KAAKD,KAAM,UAAUY,MAAM,iCAChC,GAAyB,sBAATZ,KAAmB,UAAUY,MAAM,sCAGnD,GADAX,KAAKH,YAAcA,GAAe,OAC7BG,KAAKH,YAAa,UAAUc,MAAM,wCACvC,GAAgC,sBAAhBd,YAA0B,UAAUc,MAAM,6CAQ1D,GALAX,KAAKX,KAAOA,EAEZW,KAAKV,qBAAuC,SAATD,KAChCC,GAAmB,mBACnBA,EACCU,KAAKV,iBAAmD,sBAApBA,gBAA8B,UAAUqB,MAAM,iDAGtF,GADAX,KAAKT,WAAaA,EACdS,KAAKT,YAAyC,sBAAfA,WAAyB,UAAUoB,MAAM,4CAG5E,GADAX,KAAKF,QAAUA,EACXE,KAAKF,SAAmC,sBAAZA,QAAsB,UAAUa,MAAM,yCAMtE,GAJAX,KAAKY,MAAO,IAAIC,MAAOC,cAGvBd,KAAKN,WAAaA,GAAcM,KAAKY,MAChCZ,KAAKN,WAAY,UAAUiB,MAAM,uCACtC,GAA+B,sBAAfjB,WAAyB,UAAUiB,MAAM,4CAGzD,GADAX,KAAKR,SAAWA,GAAYQ,KAAKC,IAC5BD,KAAKR,SAAU,UAAUmB,MAAM,qCACpC,GAA6B,sBAAbnB,SAAuB,UAAUmB,MAAM,0CAGvD,GADAX,KAAKP,aAAeA,GAAgBO,KAAKJ,QACpCI,KAAKP,aAAc,UAAUkB,MAAM,yCACxC,GAAiC,sBAAjBlB,aAA2B,UAAUkB,MAAM,8CAG3D,GADAX,KAAKL,WAAaA,GAAcK,KAAKD,MAChCC,KAAKL,WAAY,UAAUgB,MAAM,uCACtC,GAA+B,sBAAfhB,WAAyB,UAAUgB,MAAM"}
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({ cloudevent, name: 'id', types: ['string'], value: idValue })\r\n\r\n\t\tconst sourceValue = source || fetchNodeEnv('MILL_CLOUDEVENTS_SOURCE')\r\n\t\tsetAttribute({ cloudevent, name: 'source', types: ['string'], value: sourceValue })\r\n\r\n\t\tconst typeValue = type\r\n\t\tsetAttribute({ cloudevent, name: 'type', types: ['string'], value: typeValue })\r\n\r\n\t\tconst specversionValue = specversion || '1.0'\r\n\t\tsetAttribute({ cloudevent, name: 'specversion', types: ['string'], value: specversionValue })\r\n\r\n\t\tconst timeValue = new Date().toISOString()\r\n\t\tsetAttribute({ cloudevent, name: 'time', types: ['string'], value: timeValue })\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional fields by Cloudevent v1 specification\r\n\t\tsetAttribute({ cloudevent, name: 'data', value: data })\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({ cloudevent, name: 'datacontenttype', types: ['string', 'undefined'], value: datacontenttypeValue })\r\n\r\n\t\tsetAttribute({ cloudevent, name: 'dataschema', types: ['string', 'undefined'], value: dataschema })\r\n\r\n\t\tsetAttribute({ cloudevent, name: 'subject', types: ['string', 'undefined'], value: subject })\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({ cloudevent, name: 'origintime', types: ['string'], value: origintimeValue })\r\n\r\n\t\tconst originidValue = originid || idValue\r\n\t\tsetAttribute({ cloudevent, name: 'originid', types: ['string'], value: originidValue })\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({ cloudevent, name: 'origintype', types: ['string'], value: origintypeValue })\r\n\t\t// *******\r\n\r\n\t\t// *******\r\n\t\t// * Optional in-house extentions\r\n\t\tsetAttribute({ cloudevent, name: 'originatorid', types: ['string', 'undefined'], value: originatorid })\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","to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Aa,CAAEC,WAAAA,EAAYL,KAAM,OAAQM,MAAO,CAAC,UAAWC,MAAOmC,IAKnEtC,EAAa,CAAEC,WAAAA,EAAYL,KAAM,OAAQO,MAAOU,IAKhDb,EAAa,CAAEC,WAAAA,EAAYL,KAAM,kBAAmBM,MAAO,CAAC,SAAU,aAAcC,WAHvC,IAATU,EACjCC,GAAmB,mBACnBA,IAGHd,EAAa,CAAEC,WAAAA,EAAYL,KAAM,aAAcM,MAAO,CAAC,SAAU,aAAcC,MAAOY,IAEtFf,EAAa,CAAEC,WAAAA,EAAYL,KAAM,UAAWM,MAAO,CAAC,SAAU,aAAcC,MAAOoB,IAMnFvB,EAAa,CAAEC,WAAAA,EAAYL,KAAM,aAAcM,MAAO,CAAC,UAAWC,MAD1CgB,GAAcmB,IAItCtC,EAAa,CAAEC,WAAAA,EAAYL,KAAM,WAAYM,MAAO,CAAC,UAAWC,MAD1Cc,GAAYS,IAIlC1B,EAAa,CAAEC,WAAAA,EAAYL,KAAM,eAAgBM,MAAO,CAAC,UAAWC,MAD1Ce,GAAgBkB,IAI1CpC,EAAa,CAAEC,WAAAA,EAAYL,KAAM,aAAcM,MAAO,CAAC,UAAWC,MAD1CiB,GAAciB,IAMtCrC,EAAa,CAAEC,WAAAA,EAAYL,KAAM,eAAgBM,MAAO,CAAC,SAAU,aAAcC,MAAOa,GAExF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1mill/cloudevents",
3
- "version": "4.0.1",
3
+ "version": "4.1.0",
4
4
  "description": "Node cloudevents specification and helper",
5
5
  "jsnext:main": "dist/index.module.js",
6
6
  "main": "dist/index.cjs",
@@ -18,7 +18,8 @@
18
18
  "build:browser": "microbundle --format modern,umd --external none",
19
19
  "build:node": "microbundle --format cjs,esm",
20
20
  "deploy": "npm run build && npm publish",
21
- "dev": "microbundle watch"
21
+ "dev": "microbundle watch",
22
+ "test:unit": "mocha \"src/**/*.test.js\" --recursive"
22
23
  },
23
24
  "homepage": "https://github.com/1mill/cloudevents",
24
25
  "authors": [
@@ -30,9 +31,14 @@
30
31
  "url": "https://github.com/1mill/cloudevents.git"
31
32
  },
32
33
  "dependencies": {
33
- "nanoid": "^3.2.0"
34
+ "nanoid": "^3.3.4"
34
35
  },
35
36
  "devDependencies": {
36
- "microbundle": "^0.14.2"
37
+ "chai": "^4.3.6",
38
+ "chai-iso8601": "^1.0.0",
39
+ "chai-subset": "^1.6.0",
40
+ "microbundle": "^0.14.2",
41
+ "mocha": "^10.0.0",
42
+ "sinon": "^14.0.0"
37
43
  }
38
44
  }