@productminds/article-events 6.2.3 → 7.0.2

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.
@@ -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,70 +0,0 @@
1
- import { Schema } from '@effect/schema';
2
- declare const _default: {
3
- decode: (u: unknown, overrideOptions?: import("@effect/schema/AST").ParseOptions) => import("effect/Either").Either<{
4
- readonly kind: "ARTICLE_EVENT";
5
- readonly payload: any;
6
- }, import("@effect/schema/ParseResult").ParseError>;
7
- decodeExn: (u: unknown) => {
8
- readonly kind: "ARTICLE_EVENT";
9
- readonly payload: any;
10
- };
11
- encode: (a: {
12
- readonly kind: "ARTICLE_EVENT";
13
- readonly payload: any;
14
- }, overrideOptions?: import("@effect/schema/AST").ParseOptions) => import("effect/Either").Either<{
15
- readonly kind: "ARTICLE_EVENT";
16
- readonly payload: {
17
- readonly [x: string]: any;
18
- };
19
- }, import("@effect/schema/ParseResult").ParseError>;
20
- encodeExn: (event: {
21
- readonly kind: "ARTICLE_EVENT";
22
- readonly payload: any;
23
- }) => {
24
- readonly kind: "ARTICLE_EVENT";
25
- readonly payload: {
26
- readonly [x: string]: any;
27
- };
28
- };
29
- fromString: (msg: string) => import("effect/Either").Either<{
30
- readonly kind: "ARTICLE_EVENT";
31
- readonly payload: any;
32
- }, import("@effect/schema/ParseResult").ParseError>;
33
- fromBuffer: (msg: Buffer) => import("effect/Either").Either<{
34
- readonly kind: "ARTICLE_EVENT";
35
- readonly payload: any;
36
- }, import("@effect/schema/ParseResult").ParseError>;
37
- fromStringExn: (msg: string) => {
38
- readonly kind: "ARTICLE_EVENT";
39
- readonly payload: any;
40
- };
41
- fromBufferExn: (msg: Buffer) => {
42
- readonly kind: "ARTICLE_EVENT";
43
- readonly payload: any;
44
- };
45
- toString: (event: {
46
- readonly kind: "ARTICLE_EVENT";
47
- readonly payload: any;
48
- }) => string;
49
- toBuffer: (event: {
50
- readonly kind: "ARTICLE_EVENT";
51
- readonly payload: any;
52
- }) => Buffer;
53
- toStringExn: (event: {
54
- readonly kind: "ARTICLE_EVENT";
55
- readonly payload: any;
56
- }) => string;
57
- toBufferExn: (event: {
58
- readonly kind: "ARTICLE_EVENT";
59
- readonly payload: any;
60
- }) => Buffer;
61
- Schema: Schema.Struct<{
62
- kind: Schema.Literal<["ARTICLE_EVENT"]>;
63
- payload: Schema.Struct<{
64
- article: any;
65
- status: Schema.Literal<["NEW", "UPDATED"]>;
66
- source: Schema.Literal<["INTERNAL", "EXTERNAL"]>;
67
- }>;
68
- }>;
69
- };
70
- export default _default;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const schema_1 = require("@effect/schema");
4
- const Article_1 = require("../types/Article");
5
- const makeHelpers_1 = require("../utils/makeHelpers");
6
- const ArticleEventSchema = schema_1.Schema.Struct({
7
- kind: schema_1.Schema.Literal('ARTICLE_EVENT'),
8
- payload: schema_1.Schema.Struct({
9
- article: Article_1.ArticleSchema,
10
- status: schema_1.Schema.Literal('NEW', 'UPDATED'),
11
- source: schema_1.Schema.Literal('INTERNAL', 'EXTERNAL'),
12
- }),
13
- });
14
- const helpers = (0, makeHelpers_1.makeHelpers)(ArticleEventSchema);
15
- exports.default = Object.assign({ Schema: ArticleEventSchema }, helpers);
@@ -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;