- Source:
- See:
Throws:
-
instancing not allowed for this class
- Type
- Error
Methods
(static) deserializeEvents(sernon-null, optionsopt, callback) → {Array.<object>}
Deserialize/parse the given JSONBatch from JSON format.
Deserialize/parse the given JSONBatch from JSON format.
Note that standard CloudEvent deserialization will be called
for any CloudEvent instance, nothing other;
so options are the same used in CloudEvent related method.
See CloudEvent.deserializeEvent.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
ser |
string | the serialized JSONBatch to parse/deserialize | ||
options |
object |
<optional> |
{} | optional deserialization attributes Additional options valid here: - logError (boolean, default false) to log to console deserialization errors - throwError (boolean, default false) to throw serialization errors |
callback |
object | a callback with usual arguments (err, data) to notify after processing each item |
- Source:
Throws:
-
-
if ser is undefined or null, or an option is undefined/null/wrong
- Type
- Error
-
-
-
in case of JSON parsing error
- Type
- Error
-
-
-
if ser is not a JSONBatch representation
- Type
- TypeError
-
Returns:
the deserialized batch as a JSONBatch (so a CloudEvent array instance)
- Type
- Array.<object>
(generator, static) getEvent(batchnon-null, optionsopt) → {object}
Generator to iterate across all CloudEvent instances in the JSONBatch.
Generator to iterate across all CloudEvent instances in the JSONBatch.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
batch |
object | the JSONBatch to iterate | ||
options |
object |
<optional> |
{} | optional processing attributes: - onlyValid (boolean, default false) to extract only valid instances - strict (boolean, default false) to validate it in a more strict way |
- Source:
Throws:
-
-
if batch is undefined or null
- Type
- Error
-
-
-
if batch is not a JSONBatch
- Type
- TypeError
-
Returns:
a CloudEvent (if any)
- Type
- object
(static) getEvents(batchnon-null, optionsopt) → {Array.<object>}
Return any not null CloudEvent instance from the given object.
Return any not null CloudEvent instance from the given object.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
batch |
object | the JSONBatch to extract CloudEvent instances (if any) | ||
options |
object |
<optional> |
{} | optional processing attributes: - onlyValid (boolean, default false) to extract only valid instances - strict (boolean, default false) to validate it in a more strict way |
- Source:
Throws:
-
-
if batch is undefined or null, or an option is undefined/null/wrong
- Type
- Error
-
-
-
if batch is not a JSONBatch
- Type
- TypeError
-
Returns:
processed events, as an array
- Type
- Array.<object>
(static) isJSONBatch(batchnon-null) → {boolean}
Tell the given object, if it's a JSONBatch (or at least an empty one).
Tell the given object, if it's a JSONBatch (or at least an empty one).
Parameters:
Name | Type | Description |
---|---|---|
batch |
object | the JSONBatch to check |
- Source:
Throws:
-
if batch is undefined or null
- Type
- Error
Returns:
true if it's an array, otherwise false
- Type
- boolean
(static) isValidBatch(batchnon-null, optionsopt) → {boolean}
Tell the given JSONBatch, if it's valid.
Tell the given JSONBatch, if it's valid.
See CloudEvent.validateBatch.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
batch |
object | the JSONBatch to validate | ||
options |
object |
<optional> |
{} | containing: strict (boolean, default false) to validate it in a more strict way |
- Source:
Returns:
true if valid, otherwise false
- Type
- boolean
(static) mediaType() → {string}
Return the MIME Type for CloudEvent intances batched into a single JSON document (array), using the JSON Batch Format.
Return the MIME Type for CloudEvent intances
batched into a single JSON document (array),
using the JSON Batch Format
- Source:
Returns:
the value
- Type
- string
(static) serializeEvents(batchnon-null, optionsopt, callback) → {string}
Serialize the given JSONBatch in JSON format.
Serialize the given JSONBatch in JSON format.
Note that standard CloudEvent serialization will be called
for any CloudEvent instance, nothing other;
so options are the same used in CloudEvent related method.
See CloudEvent.serializeEvent.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
batch |
Array.<object> | the JSONBatch (so a CloudEvent array instance) to serialize | ||
options |
object |
<optional> |
{} | optional serialization attributes Additional options valid here: - logError (boolean, default false) to log to console serialization errors - throwError (boolean, default false) to throw serialization errors |
callback |
object | a callback with usual arguments (err, data) to notify after processing each item |
- Source:
Throws:
-
-
if batch is undefined or null, or an option is undefined/null/wrong or callback is not a function
- Type
- Error
-
-
-
if batch is not a JSONBatch
- Type
- TypeError
-
Returns:
the serialized JSONBatch, as a string
- Type
- string
(static) validateBatch(batch, optionsopt) → {Array.<object>}
Validate the given JSONBatch.
Validate the given JSONBatch.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
batch |
!Array.<object> | object | the JSONBatch (array) to validate, or a single CloudEvent instance | ||
options |
object |
<optional> |
{} | containing: strict (boolean, default false) to validate it in a more strict way |
- Source:
Returns:
an array of (flattened, non null) validation errors, or at least an empty array
- Type
- Array.<object>