@productminds/article-events 4.1.0 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeHelpers = void 0;
4
- const schema_1 = require("@effect/schema");
5
- const makeHelpers = (schema) => {
6
- const decode = schema_1.Schema.decodeUnknownEither(schema);
7
- const decodeExn = (u) => {
8
- const decoded = decode(u);
9
- if (decoded._tag === 'Left') {
10
- throw new Error('Failed to decode ArticleEvent');
11
- }
12
- return decoded.right;
13
- };
14
- const encode = schema_1.Schema.encodeEither(schema);
15
- const encodeExn = (event) => {
16
- const encoded = encode(event);
17
- if (encoded._tag === 'Left') {
18
- throw new Error('Failed to encode ArticleEvent');
19
- }
20
- return encoded.right;
21
- };
22
- const fromString = (msg) => decode(JSON.parse(msg));
23
- const fromBuffer = (msg) => decode(JSON.parse(msg.toString()));
24
- const fromStringExn = (msg) => decodeExn(JSON.parse(msg));
25
- const fromBufferExn = (msg) => fromStringExn(msg.toString());
26
- const toString = (event) => JSON.stringify(encode(event));
27
- const toBuffer = (event) => Buffer.from(toString(event));
28
- const toStringExn = (event) => JSON.stringify(encodeExn(event));
29
- const toBufferExn = (event) => Buffer.from(toStringExn(event));
30
- return {
31
- decode,
32
- decodeExn,
33
- encode,
34
- encodeExn,
35
- fromString,
36
- fromBuffer,
37
- fromStringExn,
38
- fromBufferExn,
39
- toString,
40
- toBuffer,
41
- toStringExn,
42
- toBufferExn,
43
- };
44
- };
45
- exports.makeHelpers = makeHelpers;
@@ -1,2 +0,0 @@
1
- import { Schema } from "@effect/schema";
2
- export declare const InternalArticleIDSchema: typeof Schema.NonEmptyString;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InternalArticleIDSchema = void 0;
4
- const schema_1 = require("@effect/schema");
5
- exports.InternalArticleIDSchema = schema_1.Schema.NonEmptyString;