@productminds/article-events 0.0.9 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # `article-events`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const articleEvents = require('article-events');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,4 @@
1
+ import ArticleEvent from './events/ArticleEvent';
2
+ import ExternalArticleEvent from './events/ExternalArticleEvent';
3
+ import InternalArticleEvent from './events/InternalArticleEvent';
4
+ export { ArticleEvent, ExternalArticleEvent, InternalArticleEvent };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.InternalArticleEvent = exports.ExternalArticleEvent = exports.ArticleEvent = void 0;
7
+ const ArticleEvent_1 = __importDefault(require("./events/ArticleEvent"));
8
+ exports.ArticleEvent = ArticleEvent_1.default;
9
+ const ExternalArticleEvent_1 = __importDefault(require("./events/ExternalArticleEvent"));
10
+ exports.ExternalArticleEvent = ExternalArticleEvent_1.default;
11
+ const InternalArticleEvent_1 = __importDefault(require("./events/InternalArticleEvent"));
12
+ exports.InternalArticleEvent = InternalArticleEvent_1.default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schema_1 = require("@effect/schema");
4
+ const InternalArticleEvent_1 = require("../events/InternalArticleEvent");
5
+ const ExternalArticleEvent_1 = require("../events/ExternalArticleEvent");
6
+ const fs_1 = require("fs");
7
+ const dir = "./jsonSchemas";
8
+ if (!(0, fs_1.existsSync)(dir)) {
9
+ (0, fs_1.mkdirSync)(dir);
10
+ }
11
+ const jsonSchemaInternal = schema_1.JSONSchema.make(InternalArticleEvent_1.InternalArticleEventSchema);
12
+ (0, fs_1.writeFileSync)(`${dir}/internalArticleEventSchema.json`, JSON.stringify(jsonSchemaInternal, null, 2));
13
+ const jsonSchemaExternal = schema_1.JSONSchema.make(ExternalArticleEvent_1.ExternalArticleEventSchema);
14
+ (0, fs_1.writeFileSync)(`${dir}/externalArticleEventSchema.json`, JSON.stringify(jsonSchemaExternal, null, 2));
@@ -0,0 +1,482 @@
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: {
6
+ readonly article: {
7
+ readonly id: string;
8
+ readonly site: string;
9
+ readonly title: string;
10
+ readonly teaser: string;
11
+ readonly content: string;
12
+ readonly publishedAt: Date;
13
+ readonly updatedAt: Date;
14
+ readonly retrievedAt: Date;
15
+ readonly url: string;
16
+ readonly tags: readonly ({
17
+ readonly type: "CATEGORY";
18
+ readonly value: string;
19
+ } | {
20
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
21
+ readonly id: string;
22
+ } | {
23
+ readonly type: "ENTITY";
24
+ readonly value: string;
25
+ readonly entityType: "PERSON";
26
+ })[];
27
+ readonly authors: readonly {
28
+ readonly name: string;
29
+ }[];
30
+ };
31
+ readonly status: "NEW" | "UPDATED";
32
+ readonly source: "INTERNAL" | "EXTERNAL";
33
+ };
34
+ }, import("@effect/schema/ParseResult").ParseError>;
35
+ decodeExn: (u: unknown) => {
36
+ readonly kind: "ARTICLE_EVENT";
37
+ readonly payload: {
38
+ readonly article: {
39
+ readonly id: string;
40
+ readonly site: string;
41
+ readonly title: string;
42
+ readonly teaser: string;
43
+ readonly content: string;
44
+ readonly publishedAt: Date;
45
+ readonly updatedAt: Date;
46
+ readonly retrievedAt: Date;
47
+ readonly url: string;
48
+ readonly tags: readonly ({
49
+ readonly type: "CATEGORY";
50
+ readonly value: string;
51
+ } | {
52
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
53
+ readonly id: string;
54
+ } | {
55
+ readonly type: "ENTITY";
56
+ readonly value: string;
57
+ readonly entityType: "PERSON";
58
+ })[];
59
+ readonly authors: readonly {
60
+ readonly name: string;
61
+ }[];
62
+ };
63
+ readonly status: "NEW" | "UPDATED";
64
+ readonly source: "INTERNAL" | "EXTERNAL";
65
+ };
66
+ };
67
+ encode: (a: {
68
+ readonly kind: "ARTICLE_EVENT";
69
+ readonly payload: {
70
+ readonly article: {
71
+ readonly id: string;
72
+ readonly site: string;
73
+ readonly title: string;
74
+ readonly teaser: string;
75
+ readonly content: string;
76
+ readonly publishedAt: Date;
77
+ readonly updatedAt: Date;
78
+ readonly retrievedAt: Date;
79
+ readonly url: string;
80
+ readonly tags: readonly ({
81
+ readonly type: "CATEGORY";
82
+ readonly value: string;
83
+ } | {
84
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
85
+ readonly id: string;
86
+ } | {
87
+ readonly type: "ENTITY";
88
+ readonly value: string;
89
+ readonly entityType: "PERSON";
90
+ })[];
91
+ readonly authors: readonly {
92
+ readonly name: string;
93
+ }[];
94
+ };
95
+ readonly status: "NEW" | "UPDATED";
96
+ readonly source: "INTERNAL" | "EXTERNAL";
97
+ };
98
+ }, overrideOptions?: import("@effect/schema/AST").ParseOptions) => import("effect/Either").Either<{
99
+ readonly kind: "ARTICLE_EVENT";
100
+ readonly payload: {
101
+ readonly article: {
102
+ readonly id: string;
103
+ readonly site: string;
104
+ readonly title: string;
105
+ readonly teaser: string;
106
+ readonly content: string;
107
+ readonly publishedAt: string;
108
+ readonly updatedAt: string;
109
+ readonly retrievedAt: string;
110
+ readonly url: string;
111
+ readonly tags: readonly ({
112
+ readonly type: "CATEGORY";
113
+ readonly value: string;
114
+ } | {
115
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
116
+ readonly id: string;
117
+ } | {
118
+ readonly type: "ENTITY";
119
+ readonly value: string;
120
+ readonly entityType: "PERSON";
121
+ })[];
122
+ readonly authors: readonly {
123
+ readonly name: string;
124
+ }[];
125
+ };
126
+ readonly status: "NEW" | "UPDATED";
127
+ readonly source: "INTERNAL" | "EXTERNAL";
128
+ };
129
+ }, import("@effect/schema/ParseResult").ParseError>;
130
+ encodeExn: (event: {
131
+ readonly kind: "ARTICLE_EVENT";
132
+ readonly payload: {
133
+ readonly article: {
134
+ readonly id: string;
135
+ readonly site: string;
136
+ readonly title: string;
137
+ readonly teaser: string;
138
+ readonly content: string;
139
+ readonly publishedAt: Date;
140
+ readonly updatedAt: Date;
141
+ readonly retrievedAt: Date;
142
+ readonly url: string;
143
+ readonly tags: readonly ({
144
+ readonly type: "CATEGORY";
145
+ readonly value: string;
146
+ } | {
147
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
148
+ readonly id: string;
149
+ } | {
150
+ readonly type: "ENTITY";
151
+ readonly value: string;
152
+ readonly entityType: "PERSON";
153
+ })[];
154
+ readonly authors: readonly {
155
+ readonly name: string;
156
+ }[];
157
+ };
158
+ readonly status: "NEW" | "UPDATED";
159
+ readonly source: "INTERNAL" | "EXTERNAL";
160
+ };
161
+ }) => {
162
+ readonly kind: "ARTICLE_EVENT";
163
+ readonly payload: {
164
+ readonly article: {
165
+ readonly id: string;
166
+ readonly site: string;
167
+ readonly title: string;
168
+ readonly teaser: string;
169
+ readonly content: string;
170
+ readonly publishedAt: string;
171
+ readonly updatedAt: string;
172
+ readonly retrievedAt: string;
173
+ readonly url: string;
174
+ readonly tags: readonly ({
175
+ readonly type: "CATEGORY";
176
+ readonly value: string;
177
+ } | {
178
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
179
+ readonly id: string;
180
+ } | {
181
+ readonly type: "ENTITY";
182
+ readonly value: string;
183
+ readonly entityType: "PERSON";
184
+ })[];
185
+ readonly authors: readonly {
186
+ readonly name: string;
187
+ }[];
188
+ };
189
+ readonly status: "NEW" | "UPDATED";
190
+ readonly source: "INTERNAL" | "EXTERNAL";
191
+ };
192
+ };
193
+ fromString: (msg: string) => import("effect/Either").Either<{
194
+ readonly kind: "ARTICLE_EVENT";
195
+ readonly payload: {
196
+ readonly article: {
197
+ readonly id: string;
198
+ readonly site: string;
199
+ readonly title: string;
200
+ readonly teaser: string;
201
+ readonly content: string;
202
+ readonly publishedAt: Date;
203
+ readonly updatedAt: Date;
204
+ readonly retrievedAt: Date;
205
+ readonly url: string;
206
+ readonly tags: readonly ({
207
+ readonly type: "CATEGORY";
208
+ readonly value: string;
209
+ } | {
210
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
211
+ readonly id: string;
212
+ } | {
213
+ readonly type: "ENTITY";
214
+ readonly value: string;
215
+ readonly entityType: "PERSON";
216
+ })[];
217
+ readonly authors: readonly {
218
+ readonly name: string;
219
+ }[];
220
+ };
221
+ readonly status: "NEW" | "UPDATED";
222
+ readonly source: "INTERNAL" | "EXTERNAL";
223
+ };
224
+ }, import("@effect/schema/ParseResult").ParseError>;
225
+ fromBuffer: (msg: Buffer) => import("effect/Either").Either<{
226
+ readonly kind: "ARTICLE_EVENT";
227
+ readonly payload: {
228
+ readonly article: {
229
+ readonly id: string;
230
+ readonly site: 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 tags: readonly ({
239
+ readonly type: "CATEGORY";
240
+ readonly value: string;
241
+ } | {
242
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
243
+ readonly id: string;
244
+ } | {
245
+ readonly type: "ENTITY";
246
+ readonly value: string;
247
+ readonly entityType: "PERSON";
248
+ })[];
249
+ readonly authors: readonly {
250
+ readonly name: string;
251
+ }[];
252
+ };
253
+ readonly status: "NEW" | "UPDATED";
254
+ readonly source: "INTERNAL" | "EXTERNAL";
255
+ };
256
+ }, import("@effect/schema/ParseResult").ParseError>;
257
+ fromStringExn: (msg: string) => {
258
+ readonly kind: "ARTICLE_EVENT";
259
+ readonly payload: {
260
+ readonly article: {
261
+ readonly id: string;
262
+ readonly site: string;
263
+ readonly title: string;
264
+ readonly teaser: string;
265
+ readonly content: string;
266
+ readonly publishedAt: Date;
267
+ readonly updatedAt: Date;
268
+ readonly retrievedAt: Date;
269
+ readonly url: string;
270
+ readonly tags: readonly ({
271
+ readonly type: "CATEGORY";
272
+ readonly value: string;
273
+ } | {
274
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
275
+ readonly id: string;
276
+ } | {
277
+ readonly type: "ENTITY";
278
+ readonly value: string;
279
+ readonly entityType: "PERSON";
280
+ })[];
281
+ readonly authors: readonly {
282
+ readonly name: string;
283
+ }[];
284
+ };
285
+ readonly status: "NEW" | "UPDATED";
286
+ readonly source: "INTERNAL" | "EXTERNAL";
287
+ };
288
+ };
289
+ fromBufferExn: (msg: Buffer) => {
290
+ readonly kind: "ARTICLE_EVENT";
291
+ readonly payload: {
292
+ readonly article: {
293
+ readonly id: string;
294
+ readonly site: string;
295
+ readonly title: string;
296
+ readonly teaser: string;
297
+ readonly content: string;
298
+ readonly publishedAt: Date;
299
+ readonly updatedAt: Date;
300
+ readonly retrievedAt: Date;
301
+ readonly url: string;
302
+ readonly tags: readonly ({
303
+ readonly type: "CATEGORY";
304
+ readonly value: string;
305
+ } | {
306
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
307
+ readonly id: string;
308
+ } | {
309
+ readonly type: "ENTITY";
310
+ readonly value: string;
311
+ readonly entityType: "PERSON";
312
+ })[];
313
+ readonly authors: readonly {
314
+ readonly name: string;
315
+ }[];
316
+ };
317
+ readonly status: "NEW" | "UPDATED";
318
+ readonly source: "INTERNAL" | "EXTERNAL";
319
+ };
320
+ };
321
+ toString: (event: {
322
+ readonly kind: "ARTICLE_EVENT";
323
+ readonly payload: {
324
+ readonly article: {
325
+ readonly id: string;
326
+ readonly site: string;
327
+ readonly title: string;
328
+ readonly teaser: string;
329
+ readonly content: string;
330
+ readonly publishedAt: Date;
331
+ readonly updatedAt: Date;
332
+ readonly retrievedAt: Date;
333
+ readonly url: string;
334
+ readonly tags: readonly ({
335
+ readonly type: "CATEGORY";
336
+ readonly value: string;
337
+ } | {
338
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
339
+ readonly id: string;
340
+ } | {
341
+ readonly type: "ENTITY";
342
+ readonly value: string;
343
+ readonly entityType: "PERSON";
344
+ })[];
345
+ readonly authors: readonly {
346
+ readonly name: string;
347
+ }[];
348
+ };
349
+ readonly status: "NEW" | "UPDATED";
350
+ readonly source: "INTERNAL" | "EXTERNAL";
351
+ };
352
+ }) => string;
353
+ toBuffer: (event: {
354
+ readonly kind: "ARTICLE_EVENT";
355
+ readonly payload: {
356
+ readonly article: {
357
+ readonly id: string;
358
+ readonly site: string;
359
+ readonly title: string;
360
+ readonly teaser: string;
361
+ readonly content: string;
362
+ readonly publishedAt: Date;
363
+ readonly updatedAt: Date;
364
+ readonly retrievedAt: Date;
365
+ readonly url: string;
366
+ readonly tags: readonly ({
367
+ readonly type: "CATEGORY";
368
+ readonly value: string;
369
+ } | {
370
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
371
+ readonly id: string;
372
+ } | {
373
+ readonly type: "ENTITY";
374
+ readonly value: string;
375
+ readonly entityType: "PERSON";
376
+ })[];
377
+ readonly authors: readonly {
378
+ readonly name: string;
379
+ }[];
380
+ };
381
+ readonly status: "NEW" | "UPDATED";
382
+ readonly source: "INTERNAL" | "EXTERNAL";
383
+ };
384
+ }) => Buffer;
385
+ toStringExn: (event: {
386
+ readonly kind: "ARTICLE_EVENT";
387
+ readonly payload: {
388
+ readonly article: {
389
+ readonly id: string;
390
+ readonly site: string;
391
+ readonly title: string;
392
+ readonly teaser: string;
393
+ readonly content: string;
394
+ readonly publishedAt: Date;
395
+ readonly updatedAt: Date;
396
+ readonly retrievedAt: Date;
397
+ readonly url: string;
398
+ readonly tags: readonly ({
399
+ readonly type: "CATEGORY";
400
+ readonly value: string;
401
+ } | {
402
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
403
+ readonly id: string;
404
+ } | {
405
+ readonly type: "ENTITY";
406
+ readonly value: string;
407
+ readonly entityType: "PERSON";
408
+ })[];
409
+ readonly authors: readonly {
410
+ readonly name: string;
411
+ }[];
412
+ };
413
+ readonly status: "NEW" | "UPDATED";
414
+ readonly source: "INTERNAL" | "EXTERNAL";
415
+ };
416
+ }) => string;
417
+ toBufferExn: (event: {
418
+ readonly kind: "ARTICLE_EVENT";
419
+ readonly payload: {
420
+ readonly article: {
421
+ readonly id: string;
422
+ readonly site: string;
423
+ readonly title: string;
424
+ readonly teaser: string;
425
+ readonly content: string;
426
+ readonly publishedAt: Date;
427
+ readonly updatedAt: Date;
428
+ readonly retrievedAt: Date;
429
+ readonly url: string;
430
+ readonly tags: readonly ({
431
+ readonly type: "CATEGORY";
432
+ readonly value: string;
433
+ } | {
434
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
435
+ readonly id: string;
436
+ } | {
437
+ readonly type: "ENTITY";
438
+ readonly value: string;
439
+ readonly entityType: "PERSON";
440
+ })[];
441
+ readonly authors: readonly {
442
+ readonly name: string;
443
+ }[];
444
+ };
445
+ readonly status: "NEW" | "UPDATED";
446
+ readonly source: "INTERNAL" | "EXTERNAL";
447
+ };
448
+ }) => Buffer;
449
+ Schema: Schema.Struct<{
450
+ kind: Schema.Literal<["ARTICLE_EVENT"]>;
451
+ payload: Schema.Struct<{
452
+ article: Schema.Struct<{
453
+ id: typeof Schema.UUID;
454
+ title: typeof Schema.NonEmpty;
455
+ teaser: typeof Schema.NonEmpty;
456
+ content: typeof Schema.NonEmpty;
457
+ publishedAt: typeof Schema.Date;
458
+ updatedAt: typeof Schema.Date;
459
+ retrievedAt: typeof Schema.Date;
460
+ url: typeof Schema.NonEmpty;
461
+ site: typeof Schema.NonEmpty;
462
+ tags: Schema.Array$<Schema.Union<[Schema.Struct<{
463
+ type: Schema.Literal<["CATEGORY"]>;
464
+ value: typeof Schema.NonEmpty;
465
+ }>, Schema.Struct<{
466
+ type: Schema.Literal<["EXTERNAL_ARTICLE_REFERENCE"]>;
467
+ id: typeof Schema.UUID;
468
+ }>, Schema.Struct<{
469
+ type: Schema.Literal<["ENTITY"]>;
470
+ entityType: Schema.Literal<["PERSON"]>;
471
+ value: typeof Schema.NonEmpty;
472
+ }>]>>;
473
+ authors: Schema.Array$<Schema.Struct<{
474
+ name: typeof Schema.NonEmpty;
475
+ }>>;
476
+ }>;
477
+ status: Schema.Literal<["NEW", "UPDATED"]>;
478
+ source: Schema.Literal<["INTERNAL", "EXTERNAL"]>;
479
+ }>;
480
+ }>;
481
+ };
482
+ export default _default;
@@ -0,0 +1,15 @@
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);