@productminds/article-events 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +316 -0
- package/dist/index.js +75 -0
- package/index.ts +84 -0
- package/package.json +22 -0
- package/tsconfig.json +100 -0
package/dist/index.d.ts
ADDED
@@ -0,0 +1,316 @@
|
|
1
|
+
import { Schema } from '@effect/schema';
|
2
|
+
export declare const ArticleSchema: Schema.Struct<{
|
3
|
+
id: typeof Schema.UUID;
|
4
|
+
title: typeof Schema.NonEmpty;
|
5
|
+
teaser: typeof Schema.NonEmpty;
|
6
|
+
content: typeof Schema.NonEmpty;
|
7
|
+
publishedAt: typeof Schema.Date;
|
8
|
+
updatedAt: typeof Schema.Date;
|
9
|
+
retrievedAt: typeof Schema.Date;
|
10
|
+
url: typeof Schema.NonEmpty;
|
11
|
+
site: typeof Schema.NonEmpty;
|
12
|
+
tags: Schema.Array$<Schema.Union<[Schema.Struct<{
|
13
|
+
type: Schema.Literal<["category"]>;
|
14
|
+
value: typeof Schema.NonEmpty;
|
15
|
+
}>, Schema.Struct<{
|
16
|
+
type: Schema.Literal<["articleReference"]>;
|
17
|
+
id: typeof Schema.UUID;
|
18
|
+
}>]>>;
|
19
|
+
authors: Schema.Array$<Schema.Struct<{
|
20
|
+
name: typeof Schema.NonEmpty;
|
21
|
+
}>>;
|
22
|
+
meta: Schema.optional<typeof Schema.Unknown>;
|
23
|
+
}>;
|
24
|
+
export declare const ArticleEventSchema: Schema.Struct<{
|
25
|
+
kind: Schema.Literal<["ARTICLE_EVENT"]>;
|
26
|
+
payload: Schema.Struct<{
|
27
|
+
article: Schema.Struct<{
|
28
|
+
id: typeof Schema.UUID;
|
29
|
+
title: typeof Schema.NonEmpty;
|
30
|
+
teaser: typeof Schema.NonEmpty;
|
31
|
+
content: typeof Schema.NonEmpty;
|
32
|
+
publishedAt: typeof Schema.Date;
|
33
|
+
updatedAt: typeof Schema.Date;
|
34
|
+
retrievedAt: typeof Schema.Date;
|
35
|
+
url: typeof Schema.NonEmpty;
|
36
|
+
site: typeof Schema.NonEmpty;
|
37
|
+
tags: Schema.Array$<Schema.Union<[Schema.Struct<{
|
38
|
+
type: Schema.Literal<["category"]>;
|
39
|
+
value: typeof Schema.NonEmpty;
|
40
|
+
}>, Schema.Struct<{
|
41
|
+
type: Schema.Literal<["articleReference"]>;
|
42
|
+
id: typeof Schema.UUID;
|
43
|
+
}>]>>;
|
44
|
+
authors: Schema.Array$<Schema.Struct<{
|
45
|
+
name: typeof Schema.NonEmpty;
|
46
|
+
}>>;
|
47
|
+
meta: Schema.optional<typeof Schema.Unknown>;
|
48
|
+
}>;
|
49
|
+
status: Schema.Literal<["NEW", "UPDATED"]>;
|
50
|
+
source: Schema.Literal<["INTERNAL", "EXTERNAL"]>;
|
51
|
+
}>;
|
52
|
+
}>;
|
53
|
+
export declare const decode: (u: unknown, overrideOptions?: import("@effect/schema/AST").ParseOptions) => import("effect/Either").Either<{
|
54
|
+
readonly kind: "ARTICLE_EVENT";
|
55
|
+
readonly payload: {
|
56
|
+
readonly article: {
|
57
|
+
readonly id: string;
|
58
|
+
readonly title: string;
|
59
|
+
readonly teaser: string;
|
60
|
+
readonly content: string;
|
61
|
+
readonly publishedAt: Date;
|
62
|
+
readonly updatedAt: Date;
|
63
|
+
readonly retrievedAt: Date;
|
64
|
+
readonly url: string;
|
65
|
+
readonly site: string;
|
66
|
+
readonly tags: readonly ({
|
67
|
+
readonly type: "category";
|
68
|
+
readonly value: string;
|
69
|
+
} | {
|
70
|
+
readonly type: "articleReference";
|
71
|
+
readonly id: string;
|
72
|
+
})[];
|
73
|
+
readonly authors: readonly {
|
74
|
+
readonly name: string;
|
75
|
+
}[];
|
76
|
+
readonly meta?: unknown;
|
77
|
+
};
|
78
|
+
readonly status: "NEW" | "UPDATED";
|
79
|
+
readonly source: "INTERNAL" | "EXTERNAL";
|
80
|
+
};
|
81
|
+
}, import("@effect/schema/ParseResult").ParseError>;
|
82
|
+
export declare const decodeExn: (u: unknown) => {
|
83
|
+
readonly kind: "ARTICLE_EVENT";
|
84
|
+
readonly payload: {
|
85
|
+
readonly article: {
|
86
|
+
readonly id: string;
|
87
|
+
readonly title: string;
|
88
|
+
readonly teaser: string;
|
89
|
+
readonly content: string;
|
90
|
+
readonly publishedAt: Date;
|
91
|
+
readonly updatedAt: Date;
|
92
|
+
readonly retrievedAt: Date;
|
93
|
+
readonly url: string;
|
94
|
+
readonly site: string;
|
95
|
+
readonly tags: readonly ({
|
96
|
+
readonly type: "category";
|
97
|
+
readonly value: string;
|
98
|
+
} | {
|
99
|
+
readonly type: "articleReference";
|
100
|
+
readonly id: string;
|
101
|
+
})[];
|
102
|
+
readonly authors: readonly {
|
103
|
+
readonly name: string;
|
104
|
+
}[];
|
105
|
+
readonly meta?: unknown;
|
106
|
+
};
|
107
|
+
readonly status: "NEW" | "UPDATED";
|
108
|
+
readonly source: "INTERNAL" | "EXTERNAL";
|
109
|
+
};
|
110
|
+
};
|
111
|
+
export declare const encode: (a: {
|
112
|
+
readonly kind: "ARTICLE_EVENT";
|
113
|
+
readonly payload: {
|
114
|
+
readonly article: {
|
115
|
+
readonly id: string;
|
116
|
+
readonly title: string;
|
117
|
+
readonly teaser: string;
|
118
|
+
readonly content: string;
|
119
|
+
readonly publishedAt: Date;
|
120
|
+
readonly updatedAt: Date;
|
121
|
+
readonly retrievedAt: Date;
|
122
|
+
readonly url: string;
|
123
|
+
readonly site: string;
|
124
|
+
readonly tags: readonly ({
|
125
|
+
readonly type: "category";
|
126
|
+
readonly value: string;
|
127
|
+
} | {
|
128
|
+
readonly type: "articleReference";
|
129
|
+
readonly id: string;
|
130
|
+
})[];
|
131
|
+
readonly authors: readonly {
|
132
|
+
readonly name: string;
|
133
|
+
}[];
|
134
|
+
readonly meta?: unknown;
|
135
|
+
};
|
136
|
+
readonly status: "NEW" | "UPDATED";
|
137
|
+
readonly source: "INTERNAL" | "EXTERNAL";
|
138
|
+
};
|
139
|
+
}, overrideOptions?: import("@effect/schema/AST").ParseOptions) => import("effect/Either").Either<{
|
140
|
+
readonly kind: "ARTICLE_EVENT";
|
141
|
+
readonly payload: {
|
142
|
+
readonly article: {
|
143
|
+
readonly id: string;
|
144
|
+
readonly title: string;
|
145
|
+
readonly teaser: string;
|
146
|
+
readonly content: string;
|
147
|
+
readonly publishedAt: string;
|
148
|
+
readonly updatedAt: string;
|
149
|
+
readonly retrievedAt: string;
|
150
|
+
readonly url: string;
|
151
|
+
readonly site: string;
|
152
|
+
readonly tags: readonly ({
|
153
|
+
readonly type: "category";
|
154
|
+
readonly value: string;
|
155
|
+
} | {
|
156
|
+
readonly type: "articleReference";
|
157
|
+
readonly id: string;
|
158
|
+
})[];
|
159
|
+
readonly authors: readonly {
|
160
|
+
readonly name: string;
|
161
|
+
}[];
|
162
|
+
readonly meta?: unknown;
|
163
|
+
};
|
164
|
+
readonly status: "NEW" | "UPDATED";
|
165
|
+
readonly source: "INTERNAL" | "EXTERNAL";
|
166
|
+
};
|
167
|
+
}, import("@effect/schema/ParseResult").ParseError>;
|
168
|
+
export declare const encodeExn: (event: typeof ArticleEventSchema.Type) => {
|
169
|
+
readonly kind: "ARTICLE_EVENT";
|
170
|
+
readonly payload: {
|
171
|
+
readonly article: {
|
172
|
+
readonly id: string;
|
173
|
+
readonly title: string;
|
174
|
+
readonly teaser: string;
|
175
|
+
readonly content: string;
|
176
|
+
readonly publishedAt: string;
|
177
|
+
readonly updatedAt: string;
|
178
|
+
readonly retrievedAt: string;
|
179
|
+
readonly url: string;
|
180
|
+
readonly site: string;
|
181
|
+
readonly tags: readonly ({
|
182
|
+
readonly type: "category";
|
183
|
+
readonly value: string;
|
184
|
+
} | {
|
185
|
+
readonly type: "articleReference";
|
186
|
+
readonly id: string;
|
187
|
+
})[];
|
188
|
+
readonly authors: readonly {
|
189
|
+
readonly name: string;
|
190
|
+
}[];
|
191
|
+
readonly meta?: unknown;
|
192
|
+
};
|
193
|
+
readonly status: "NEW" | "UPDATED";
|
194
|
+
readonly source: "INTERNAL" | "EXTERNAL";
|
195
|
+
};
|
196
|
+
};
|
197
|
+
export declare const fromString: (msg: string) => import("effect/Either").Either<{
|
198
|
+
readonly kind: "ARTICLE_EVENT";
|
199
|
+
readonly payload: {
|
200
|
+
readonly article: {
|
201
|
+
readonly id: string;
|
202
|
+
readonly title: string;
|
203
|
+
readonly teaser: string;
|
204
|
+
readonly content: string;
|
205
|
+
readonly publishedAt: Date;
|
206
|
+
readonly updatedAt: Date;
|
207
|
+
readonly retrievedAt: Date;
|
208
|
+
readonly url: string;
|
209
|
+
readonly site: string;
|
210
|
+
readonly tags: readonly ({
|
211
|
+
readonly type: "category";
|
212
|
+
readonly value: string;
|
213
|
+
} | {
|
214
|
+
readonly type: "articleReference";
|
215
|
+
readonly id: string;
|
216
|
+
})[];
|
217
|
+
readonly authors: readonly {
|
218
|
+
readonly name: string;
|
219
|
+
}[];
|
220
|
+
readonly meta?: unknown;
|
221
|
+
};
|
222
|
+
readonly status: "NEW" | "UPDATED";
|
223
|
+
readonly source: "INTERNAL" | "EXTERNAL";
|
224
|
+
};
|
225
|
+
}, import("@effect/schema/ParseResult").ParseError>;
|
226
|
+
export declare const fromBuffer: (msg: Buffer) => import("effect/Either").Either<{
|
227
|
+
readonly kind: "ARTICLE_EVENT";
|
228
|
+
readonly payload: {
|
229
|
+
readonly article: {
|
230
|
+
readonly id: string;
|
231
|
+
readonly title: string;
|
232
|
+
readonly teaser: string;
|
233
|
+
readonly content: string;
|
234
|
+
readonly publishedAt: Date;
|
235
|
+
readonly updatedAt: Date;
|
236
|
+
readonly retrievedAt: Date;
|
237
|
+
readonly url: string;
|
238
|
+
readonly site: string;
|
239
|
+
readonly tags: readonly ({
|
240
|
+
readonly type: "category";
|
241
|
+
readonly value: string;
|
242
|
+
} | {
|
243
|
+
readonly type: "articleReference";
|
244
|
+
readonly id: string;
|
245
|
+
})[];
|
246
|
+
readonly authors: readonly {
|
247
|
+
readonly name: string;
|
248
|
+
}[];
|
249
|
+
readonly meta?: unknown;
|
250
|
+
};
|
251
|
+
readonly status: "NEW" | "UPDATED";
|
252
|
+
readonly source: "INTERNAL" | "EXTERNAL";
|
253
|
+
};
|
254
|
+
}, import("@effect/schema/ParseResult").ParseError>;
|
255
|
+
export declare const fromStringExn: (msg: string) => {
|
256
|
+
readonly kind: "ARTICLE_EVENT";
|
257
|
+
readonly payload: {
|
258
|
+
readonly article: {
|
259
|
+
readonly id: string;
|
260
|
+
readonly title: string;
|
261
|
+
readonly teaser: string;
|
262
|
+
readonly content: string;
|
263
|
+
readonly publishedAt: Date;
|
264
|
+
readonly updatedAt: Date;
|
265
|
+
readonly retrievedAt: Date;
|
266
|
+
readonly url: string;
|
267
|
+
readonly site: string;
|
268
|
+
readonly tags: readonly ({
|
269
|
+
readonly type: "category";
|
270
|
+
readonly value: string;
|
271
|
+
} | {
|
272
|
+
readonly type: "articleReference";
|
273
|
+
readonly id: string;
|
274
|
+
})[];
|
275
|
+
readonly authors: readonly {
|
276
|
+
readonly name: string;
|
277
|
+
}[];
|
278
|
+
readonly meta?: unknown;
|
279
|
+
};
|
280
|
+
readonly status: "NEW" | "UPDATED";
|
281
|
+
readonly source: "INTERNAL" | "EXTERNAL";
|
282
|
+
};
|
283
|
+
};
|
284
|
+
export declare const fromBufferExn: (msg: Buffer) => {
|
285
|
+
readonly kind: "ARTICLE_EVENT";
|
286
|
+
readonly payload: {
|
287
|
+
readonly article: {
|
288
|
+
readonly id: string;
|
289
|
+
readonly title: string;
|
290
|
+
readonly teaser: string;
|
291
|
+
readonly content: string;
|
292
|
+
readonly publishedAt: Date;
|
293
|
+
readonly updatedAt: Date;
|
294
|
+
readonly retrievedAt: Date;
|
295
|
+
readonly url: string;
|
296
|
+
readonly site: string;
|
297
|
+
readonly tags: readonly ({
|
298
|
+
readonly type: "category";
|
299
|
+
readonly value: string;
|
300
|
+
} | {
|
301
|
+
readonly type: "articleReference";
|
302
|
+
readonly id: string;
|
303
|
+
})[];
|
304
|
+
readonly authors: readonly {
|
305
|
+
readonly name: string;
|
306
|
+
}[];
|
307
|
+
readonly meta?: unknown;
|
308
|
+
};
|
309
|
+
readonly status: "NEW" | "UPDATED";
|
310
|
+
readonly source: "INTERNAL" | "EXTERNAL";
|
311
|
+
};
|
312
|
+
};
|
313
|
+
export declare const toString: (event: typeof ArticleEventSchema.Type) => string;
|
314
|
+
export declare const toBuffer: (event: typeof ArticleEventSchema.Type) => Buffer;
|
315
|
+
export declare const toStringExn: (event: typeof ArticleEventSchema.Type) => string;
|
316
|
+
export declare const toBufferExn: (event: typeof ArticleEventSchema.Type) => Buffer;
|
package/dist/index.js
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.toBufferExn = exports.toStringExn = exports.toBuffer = exports.toString = exports.fromBufferExn = exports.fromStringExn = exports.fromBuffer = exports.fromString = exports.encodeExn = exports.encode = exports.decodeExn = exports.decode = exports.ArticleEventSchema = exports.ArticleSchema = void 0;
|
4
|
+
const schema_1 = require("@effect/schema");
|
5
|
+
const DateTimeSchema = schema_1.Schema.Date.annotations({
|
6
|
+
jsonSchema: { format: 'date-time' }
|
7
|
+
});
|
8
|
+
const CategoryTagSchema = schema_1.Schema.Struct({
|
9
|
+
type: schema_1.Schema.Literal('category'),
|
10
|
+
value: schema_1.Schema.NonEmpty
|
11
|
+
});
|
12
|
+
const ArticleReferenceSchema = schema_1.Schema.Struct({
|
13
|
+
type: schema_1.Schema.Literal('articleReference'),
|
14
|
+
id: schema_1.Schema.UUID
|
15
|
+
});
|
16
|
+
const TagSchema = schema_1.Schema.Union(CategoryTagSchema, ArticleReferenceSchema);
|
17
|
+
const AuthorSchema = schema_1.Schema.Struct({
|
18
|
+
name: schema_1.Schema.NonEmpty
|
19
|
+
});
|
20
|
+
exports.ArticleSchema = schema_1.Schema.Struct({
|
21
|
+
id: schema_1.Schema.UUID,
|
22
|
+
title: schema_1.Schema.NonEmpty,
|
23
|
+
teaser: schema_1.Schema.NonEmpty,
|
24
|
+
content: schema_1.Schema.NonEmpty,
|
25
|
+
publishedAt: DateTimeSchema,
|
26
|
+
updatedAt: DateTimeSchema,
|
27
|
+
retrievedAt: DateTimeSchema,
|
28
|
+
url: schema_1.Schema.NonEmpty,
|
29
|
+
site: schema_1.Schema.NonEmpty,
|
30
|
+
tags: schema_1.Schema.Array(TagSchema),
|
31
|
+
authors: schema_1.Schema.Array(AuthorSchema),
|
32
|
+
meta: schema_1.Schema.optional(schema_1.Schema.Unknown)
|
33
|
+
});
|
34
|
+
exports.ArticleEventSchema = schema_1.Schema.Struct({
|
35
|
+
kind: schema_1.Schema.Literal('ARTICLE_EVENT'),
|
36
|
+
payload: schema_1.Schema.Struct({
|
37
|
+
article: exports.ArticleSchema,
|
38
|
+
status: schema_1.Schema.Literal('NEW', 'UPDATED'),
|
39
|
+
source: schema_1.Schema.Literal('INTERNAL', 'EXTERNAL')
|
40
|
+
})
|
41
|
+
});
|
42
|
+
exports.decode = schema_1.Schema.decodeUnknownEither(exports.ArticleEventSchema);
|
43
|
+
const decodeExn = (u) => {
|
44
|
+
const decoded = (0, exports.decode)(u);
|
45
|
+
if (decoded._tag === 'Left') {
|
46
|
+
throw new Error('Failed to decode ArticleEvent');
|
47
|
+
}
|
48
|
+
return decoded.right;
|
49
|
+
};
|
50
|
+
exports.decodeExn = decodeExn;
|
51
|
+
exports.encode = schema_1.Schema.encodeEither(exports.ArticleEventSchema);
|
52
|
+
const encodeExn = (event) => {
|
53
|
+
const encoded = (0, exports.encode)(event);
|
54
|
+
if (encoded._tag === 'Left') {
|
55
|
+
throw new Error('Failed to encode ArticleEvent');
|
56
|
+
}
|
57
|
+
return encoded.right;
|
58
|
+
};
|
59
|
+
exports.encodeExn = encodeExn;
|
60
|
+
const fromString = (msg) => (0, exports.decode)(JSON.parse(msg));
|
61
|
+
exports.fromString = fromString;
|
62
|
+
const fromBuffer = (msg) => (0, exports.decode)(JSON.parse(msg.toString()));
|
63
|
+
exports.fromBuffer = fromBuffer;
|
64
|
+
const fromStringExn = (msg) => (0, exports.decodeExn)(JSON.parse(msg));
|
65
|
+
exports.fromStringExn = fromStringExn;
|
66
|
+
const fromBufferExn = (msg) => (0, exports.fromStringExn)(msg.toString());
|
67
|
+
exports.fromBufferExn = fromBufferExn;
|
68
|
+
const toString = (event) => JSON.stringify((0, exports.encode)(event));
|
69
|
+
exports.toString = toString;
|
70
|
+
const toBuffer = (event) => Buffer.from((0, exports.toString)(event));
|
71
|
+
exports.toBuffer = toBuffer;
|
72
|
+
const toStringExn = (event) => JSON.stringify((0, exports.encodeExn)(event));
|
73
|
+
exports.toStringExn = toStringExn;
|
74
|
+
const toBufferExn = (event) => Buffer.from((0, exports.toStringExn)(event));
|
75
|
+
exports.toBufferExn = toBufferExn;
|
package/index.ts
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
import { Schema } from '@effect/schema';
|
2
|
+
|
3
|
+
const DateTimeSchema = Schema.Date.annotations({
|
4
|
+
jsonSchema: { format: 'date-time' }
|
5
|
+
});
|
6
|
+
|
7
|
+
const CategoryTagSchema = Schema.Struct({
|
8
|
+
type: Schema.Literal('category'),
|
9
|
+
value: Schema.NonEmpty
|
10
|
+
});
|
11
|
+
|
12
|
+
const ArticleReferenceSchema = Schema.Struct({
|
13
|
+
type: Schema.Literal('articleReference'),
|
14
|
+
id: Schema.UUID
|
15
|
+
});
|
16
|
+
|
17
|
+
const TagSchema = Schema.Union(CategoryTagSchema, ArticleReferenceSchema);
|
18
|
+
|
19
|
+
const AuthorSchema = Schema.Struct({
|
20
|
+
name: Schema.NonEmpty
|
21
|
+
});
|
22
|
+
|
23
|
+
export const ArticleSchema = Schema.Struct({
|
24
|
+
id: Schema.UUID,
|
25
|
+
title: Schema.NonEmpty,
|
26
|
+
teaser: Schema.NonEmpty,
|
27
|
+
content: Schema.NonEmpty,
|
28
|
+
publishedAt: DateTimeSchema,
|
29
|
+
updatedAt: DateTimeSchema,
|
30
|
+
retrievedAt: DateTimeSchema,
|
31
|
+
url: Schema.NonEmpty,
|
32
|
+
site: Schema.NonEmpty,
|
33
|
+
tags: Schema.Array(TagSchema),
|
34
|
+
authors: Schema.Array(AuthorSchema),
|
35
|
+
meta: Schema.optional(Schema.Unknown)
|
36
|
+
});
|
37
|
+
|
38
|
+
export const ArticleEventSchema = Schema.Struct({
|
39
|
+
kind: Schema.Literal('ARTICLE_EVENT'),
|
40
|
+
payload: Schema.Struct({
|
41
|
+
article: ArticleSchema,
|
42
|
+
status: Schema.Literal('NEW', 'UPDATED'),
|
43
|
+
source: Schema.Literal('INTERNAL', 'EXTERNAL')
|
44
|
+
})
|
45
|
+
});
|
46
|
+
|
47
|
+
export const decode = Schema.decodeUnknownEither(ArticleEventSchema);
|
48
|
+
export const decodeExn = (u: unknown) => {
|
49
|
+
const decoded = decode(u);
|
50
|
+
|
51
|
+
if (decoded._tag === 'Left') {
|
52
|
+
throw new Error('Failed to decode ArticleEvent');
|
53
|
+
}
|
54
|
+
|
55
|
+
return decoded.right;
|
56
|
+
};
|
57
|
+
|
58
|
+
export const encode = Schema.encodeEither(ArticleEventSchema);
|
59
|
+
export const encodeExn = (event: typeof ArticleEventSchema.Type) => {
|
60
|
+
const encoded = encode(event);
|
61
|
+
|
62
|
+
if (encoded._tag === 'Left') {
|
63
|
+
throw new Error('Failed to encode ArticleEvent');
|
64
|
+
}
|
65
|
+
|
66
|
+
return encoded.right;
|
67
|
+
};
|
68
|
+
|
69
|
+
export const fromString = (msg: string) => decode(JSON.parse(msg));
|
70
|
+
export const fromBuffer = (msg: Buffer) => decode(JSON.parse(msg.toString()));
|
71
|
+
|
72
|
+
export const fromStringExn = (msg: string) => decodeExn(JSON.parse(msg));
|
73
|
+
export const fromBufferExn = (msg: Buffer) => fromStringExn(msg.toString());
|
74
|
+
|
75
|
+
export const toString = (event: typeof ArticleEventSchema.Type) =>
|
76
|
+
JSON.stringify(encode(event));
|
77
|
+
|
78
|
+
export const toBuffer = (event: typeof ArticleEventSchema.Type) =>
|
79
|
+
Buffer.from(toString(event));
|
80
|
+
|
81
|
+
export const toStringExn = (event: typeof ArticleEventSchema.Type) =>
|
82
|
+
JSON.stringify(encodeExn(event));
|
83
|
+
export const toBufferExn = (event: typeof ArticleEventSchema.Type) =>
|
84
|
+
Buffer.from(toStringExn(event));
|
package/package.json
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"name": "@productminds/article-events",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": "",
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"types": "dist/index.d.ts",
|
7
|
+
"scripts": {
|
8
|
+
"build": "tsc",
|
9
|
+
"build:watch": "tsc --watch",
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
11
|
+
},
|
12
|
+
"keywords": [],
|
13
|
+
"author": "mbirkegaard",
|
14
|
+
"license": "ISC",
|
15
|
+
"devDependencies": {
|
16
|
+
"@types/node": "^20.14.11",
|
17
|
+
"typescript": "^5.5.3"
|
18
|
+
},
|
19
|
+
"dependencies": {
|
20
|
+
"@effect/schema": "^0.68.26"
|
21
|
+
}
|
22
|
+
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
4
|
+
/* Projects */
|
5
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
6
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
7
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
8
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
9
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
10
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
11
|
+
/* Language and Environment */
|
12
|
+
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
13
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
14
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
15
|
+
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
16
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
17
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
18
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
19
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
20
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
21
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
22
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
23
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
24
|
+
/* Modules */
|
25
|
+
"module": "commonjs", /* Specify what module code is generated. */
|
26
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
27
|
+
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
28
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
29
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
30
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
31
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
32
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
33
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
34
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
35
|
+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
36
|
+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
37
|
+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
38
|
+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
39
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
40
|
+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
41
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
42
|
+
/* JavaScript Support */
|
43
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
44
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
45
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
46
|
+
/* Emit */
|
47
|
+
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
48
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
49
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
50
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
51
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
52
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
53
|
+
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
54
|
+
// "removeComments": true, /* Disable emitting comments. */
|
55
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
56
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
57
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
58
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
59
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
60
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
61
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
62
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
63
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
64
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
65
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
66
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
67
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
68
|
+
/* Interop Constraints */
|
69
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
70
|
+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
71
|
+
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
72
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
73
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
74
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
75
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
76
|
+
/* Type Checking */
|
77
|
+
"strict": true, /* Enable all strict type-checking options. */
|
78
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
79
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
80
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
81
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
82
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
83
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
84
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
85
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
86
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
87
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
88
|
+
"exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
89
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
90
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
91
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
92
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
93
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
94
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
95
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
96
|
+
/* Completeness */
|
97
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
98
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
99
|
+
}
|
100
|
+
}
|