@productminds/article-events 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +3 -0
- package/dist/index.js +29 -0
- package/dist/src/events/ArticleEvent.d.ts +497 -0
- package/dist/src/events/ArticleEvent.js +15 -0
- package/dist/src/events/ExternalArticleEvent.d.ts +530 -0
- package/dist/src/events/ExternalArticleEvent.js +16 -0
- package/dist/src/events/InternalArticleEvent.d.ts +530 -0
- package/dist/src/events/InternalArticleEvent.js +16 -0
- package/dist/src/types/Article.d.ts +55 -0
- package/dist/src/types/Article.js +38 -0
- package/dist/src/utils/makeHelpers.d.ts +15 -0
- package/dist/src/utils/makeHelpers.js +45 -0
- package/index.ts +5 -3
- package/package.json +3 -19
@@ -0,0 +1,45 @@
|
|
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;
|
package/index.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
import ArticleEvent from './src/events/ArticleEvent';
|
2
|
+
import ExternalArticleEvent from './src/events/ExternalArticleEvent';
|
3
|
+
import InternalArticleEvent from './src/events/InternalArticleEvent';
|
4
|
+
|
5
|
+
export { ArticleEvent, ExternalArticleEvent, InternalArticleEvent };
|
package/package.json
CHANGED
@@ -1,25 +1,9 @@
|
|
1
1
|
{
|
2
2
|
"name": "@productminds/article-events",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.10",
|
4
4
|
"description": "",
|
5
|
-
"
|
6
|
-
|
7
|
-
"types": "./dist/index.d.ts",
|
8
|
-
"default": "./dist/index.js"
|
9
|
-
},
|
10
|
-
"./ArticleEvent": {
|
11
|
-
"types": "./dist/ArticleEvent.d.ts",
|
12
|
-
"default": "./dist/ArticleEvent.js"
|
13
|
-
},
|
14
|
-
"./InternalArticleEvent": {
|
15
|
-
"types": "./dist/InternalArticleEvent.d.ts",
|
16
|
-
"default": "./dist/InternalArticleEvent.js"
|
17
|
-
},
|
18
|
-
"./ExternalArticleEvent": {
|
19
|
-
"types": "./dist/ExternalArticleEvent.d.ts",
|
20
|
-
"default": "./dist/ExternalArticleEvent.js"
|
21
|
-
}
|
22
|
-
},
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"types": "dist/index.d.ts",
|
23
7
|
"scripts": {
|
24
8
|
"build": "tsc",
|
25
9
|
"build:watch": "tsc --watch",
|