@productminds/article-events 2.0.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/article-events/src/article-events.d.ts +3 -0
- package/lib/article-events/src/article-events.js +10 -0
- package/lib/article-events/src/cmd/write-json-schema.d.ts +1 -0
- package/lib/article-events/src/cmd/write-json-schema.js +14 -0
- package/lib/article-events/src/events/ExternalArticleEvent.d.ts +418 -0
- package/lib/article-events/src/events/ExternalArticleEvent.js +19 -0
- package/lib/article-events/src/events/InternalArticleEvent.d.ts +546 -0
- package/lib/article-events/src/events/InternalArticleEvent.js +19 -0
- package/lib/article-events/src/types/Article.d.ts +47 -0
- package/lib/article-events/src/types/Article.js +41 -0
- package/lib/article-events/src/utils/makeHelpers.d.ts +15 -0
- package/lib/article-events/src/utils/makeHelpers.js +45 -0
- package/lib/events/InternalArticleEvent.d.ts +34 -18
- package/lib/events/InternalArticleEvent.js +1 -1
- package/lib/shared/schema.d.ts +2 -0
- package/lib/shared/schema.js +5 -0
- package/lib/types/Article.d.ts +15 -0
- package/lib/types/Article.js +5 -1
- package/package.json +1 -1
@@ -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;
|
@@ -2,8 +2,7 @@ import { Schema } from '@effect/schema';
|
|
2
2
|
export declare const InternalArticleEventSchema: Schema.Struct<{
|
3
3
|
kind: Schema.Literal<["INTERNAL_ARTICLE_EVENT"]>;
|
4
4
|
payload: Schema.Struct<{
|
5
|
-
article: Schema.extend<Schema.Struct<{
|
6
|
-
id: typeof Schema.UUID;
|
5
|
+
article: Schema.extend<Schema.extend<Schema.Struct<{
|
7
6
|
title: typeof Schema.NonEmptyString;
|
8
7
|
teaser: typeof Schema.NonEmptyString;
|
9
8
|
content: typeof Schema.NonEmptyString;
|
@@ -16,6 +15,8 @@ export declare const InternalArticleEventSchema: Schema.Struct<{
|
|
16
15
|
name: typeof Schema.NonEmptyString;
|
17
16
|
}>>;
|
18
17
|
}>, Schema.Struct<{
|
18
|
+
id: typeof Schema.NonEmptyString;
|
19
|
+
}>>, Schema.Struct<{
|
19
20
|
tags: Schema.Array$<Schema.Union<[Schema.Struct<{
|
20
21
|
type: Schema.Literal<["CATEGORY"]>;
|
21
22
|
value: typeof Schema.NonEmptyString;
|
@@ -37,7 +38,6 @@ declare const _default: {
|
|
37
38
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
38
39
|
readonly payload: {
|
39
40
|
readonly article: {
|
40
|
-
readonly id: string;
|
41
41
|
readonly title: string;
|
42
42
|
readonly teaser: string;
|
43
43
|
readonly content: string;
|
@@ -49,6 +49,8 @@ declare const _default: {
|
|
49
49
|
readonly authors: readonly {
|
50
50
|
readonly name: string;
|
51
51
|
}[];
|
52
|
+
} & {
|
53
|
+
readonly id: string;
|
52
54
|
} & {
|
53
55
|
readonly tags: readonly ({
|
54
56
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -70,7 +72,6 @@ declare const _default: {
|
|
70
72
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
71
73
|
readonly payload: {
|
72
74
|
readonly article: {
|
73
|
-
readonly id: string;
|
74
75
|
readonly title: string;
|
75
76
|
readonly teaser: string;
|
76
77
|
readonly content: string;
|
@@ -82,6 +83,8 @@ declare const _default: {
|
|
82
83
|
readonly authors: readonly {
|
83
84
|
readonly name: string;
|
84
85
|
}[];
|
86
|
+
} & {
|
87
|
+
readonly id: string;
|
85
88
|
} & {
|
86
89
|
readonly tags: readonly ({
|
87
90
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -103,7 +106,6 @@ declare const _default: {
|
|
103
106
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
104
107
|
readonly payload: {
|
105
108
|
readonly article: {
|
106
|
-
readonly id: string;
|
107
109
|
readonly title: string;
|
108
110
|
readonly teaser: string;
|
109
111
|
readonly content: string;
|
@@ -115,6 +117,8 @@ declare const _default: {
|
|
115
117
|
readonly authors: readonly {
|
116
118
|
readonly name: string;
|
117
119
|
}[];
|
120
|
+
} & {
|
121
|
+
readonly id: string;
|
118
122
|
} & {
|
119
123
|
readonly tags: readonly ({
|
120
124
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -135,7 +139,6 @@ declare const _default: {
|
|
135
139
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
136
140
|
readonly payload: {
|
137
141
|
readonly article: {
|
138
|
-
readonly id: string;
|
139
142
|
readonly title: string;
|
140
143
|
readonly teaser: string;
|
141
144
|
readonly content: string;
|
@@ -147,6 +150,8 @@ declare const _default: {
|
|
147
150
|
readonly authors: readonly {
|
148
151
|
readonly name: string;
|
149
152
|
}[];
|
153
|
+
} & {
|
154
|
+
readonly id: string;
|
150
155
|
} & {
|
151
156
|
readonly tags: readonly ({
|
152
157
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -168,7 +173,6 @@ declare const _default: {
|
|
168
173
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
169
174
|
readonly payload: {
|
170
175
|
readonly article: {
|
171
|
-
readonly id: string;
|
172
176
|
readonly title: string;
|
173
177
|
readonly teaser: string;
|
174
178
|
readonly content: string;
|
@@ -180,6 +184,8 @@ declare const _default: {
|
|
180
184
|
readonly authors: readonly {
|
181
185
|
readonly name: string;
|
182
186
|
}[];
|
187
|
+
} & {
|
188
|
+
readonly id: string;
|
183
189
|
} & {
|
184
190
|
readonly tags: readonly ({
|
185
191
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -200,7 +206,6 @@ declare const _default: {
|
|
200
206
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
201
207
|
readonly payload: {
|
202
208
|
readonly article: {
|
203
|
-
readonly id: string;
|
204
209
|
readonly title: string;
|
205
210
|
readonly teaser: string;
|
206
211
|
readonly content: string;
|
@@ -212,6 +217,8 @@ declare const _default: {
|
|
212
217
|
readonly authors: readonly {
|
213
218
|
readonly name: string;
|
214
219
|
}[];
|
220
|
+
} & {
|
221
|
+
readonly id: string;
|
215
222
|
} & {
|
216
223
|
readonly tags: readonly ({
|
217
224
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -233,7 +240,6 @@ declare const _default: {
|
|
233
240
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
234
241
|
readonly payload: {
|
235
242
|
readonly article: {
|
236
|
-
readonly id: string;
|
237
243
|
readonly title: string;
|
238
244
|
readonly teaser: string;
|
239
245
|
readonly content: string;
|
@@ -245,6 +251,8 @@ declare const _default: {
|
|
245
251
|
readonly authors: readonly {
|
246
252
|
readonly name: string;
|
247
253
|
}[];
|
254
|
+
} & {
|
255
|
+
readonly id: string;
|
248
256
|
} & {
|
249
257
|
readonly tags: readonly ({
|
250
258
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -266,7 +274,6 @@ declare const _default: {
|
|
266
274
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
267
275
|
readonly payload: {
|
268
276
|
readonly article: {
|
269
|
-
readonly id: string;
|
270
277
|
readonly title: string;
|
271
278
|
readonly teaser: string;
|
272
279
|
readonly content: string;
|
@@ -278,6 +285,8 @@ declare const _default: {
|
|
278
285
|
readonly authors: readonly {
|
279
286
|
readonly name: string;
|
280
287
|
}[];
|
288
|
+
} & {
|
289
|
+
readonly id: string;
|
281
290
|
} & {
|
282
291
|
readonly tags: readonly ({
|
283
292
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -299,7 +308,6 @@ declare const _default: {
|
|
299
308
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
300
309
|
readonly payload: {
|
301
310
|
readonly article: {
|
302
|
-
readonly id: string;
|
303
311
|
readonly title: string;
|
304
312
|
readonly teaser: string;
|
305
313
|
readonly content: string;
|
@@ -311,6 +319,8 @@ declare const _default: {
|
|
311
319
|
readonly authors: readonly {
|
312
320
|
readonly name: string;
|
313
321
|
}[];
|
322
|
+
} & {
|
323
|
+
readonly id: string;
|
314
324
|
} & {
|
315
325
|
readonly tags: readonly ({
|
316
326
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -332,7 +342,6 @@ declare const _default: {
|
|
332
342
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
333
343
|
readonly payload: {
|
334
344
|
readonly article: {
|
335
|
-
readonly id: string;
|
336
345
|
readonly title: string;
|
337
346
|
readonly teaser: string;
|
338
347
|
readonly content: string;
|
@@ -344,6 +353,8 @@ declare const _default: {
|
|
344
353
|
readonly authors: readonly {
|
345
354
|
readonly name: string;
|
346
355
|
}[];
|
356
|
+
} & {
|
357
|
+
readonly id: string;
|
347
358
|
} & {
|
348
359
|
readonly tags: readonly ({
|
349
360
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -365,7 +376,6 @@ declare const _default: {
|
|
365
376
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
366
377
|
readonly payload: {
|
367
378
|
readonly article: {
|
368
|
-
readonly id: string;
|
369
379
|
readonly title: string;
|
370
380
|
readonly teaser: string;
|
371
381
|
readonly content: string;
|
@@ -377,6 +387,8 @@ declare const _default: {
|
|
377
387
|
readonly authors: readonly {
|
378
388
|
readonly name: string;
|
379
389
|
}[];
|
390
|
+
} & {
|
391
|
+
readonly id: string;
|
380
392
|
} & {
|
381
393
|
readonly tags: readonly ({
|
382
394
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -398,7 +410,6 @@ declare const _default: {
|
|
398
410
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
399
411
|
readonly payload: {
|
400
412
|
readonly article: {
|
401
|
-
readonly id: string;
|
402
413
|
readonly title: string;
|
403
414
|
readonly teaser: string;
|
404
415
|
readonly content: string;
|
@@ -410,6 +421,8 @@ declare const _default: {
|
|
410
421
|
readonly authors: readonly {
|
411
422
|
readonly name: string;
|
412
423
|
}[];
|
424
|
+
} & {
|
425
|
+
readonly id: string;
|
413
426
|
} & {
|
414
427
|
readonly tags: readonly ({
|
415
428
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -431,7 +444,6 @@ declare const _default: {
|
|
431
444
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
432
445
|
readonly payload: {
|
433
446
|
readonly article: {
|
434
|
-
readonly id: string;
|
435
447
|
readonly title: string;
|
436
448
|
readonly teaser: string;
|
437
449
|
readonly content: string;
|
@@ -443,6 +455,8 @@ declare const _default: {
|
|
443
455
|
readonly authors: readonly {
|
444
456
|
readonly name: string;
|
445
457
|
}[];
|
458
|
+
} & {
|
459
|
+
readonly id: string;
|
446
460
|
} & {
|
447
461
|
readonly tags: readonly ({
|
448
462
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -464,7 +478,6 @@ declare const _default: {
|
|
464
478
|
readonly kind: "INTERNAL_ARTICLE_EVENT";
|
465
479
|
readonly payload: {
|
466
480
|
readonly article: {
|
467
|
-
readonly id: string;
|
468
481
|
readonly title: string;
|
469
482
|
readonly teaser: string;
|
470
483
|
readonly content: string;
|
@@ -476,6 +489,8 @@ declare const _default: {
|
|
476
489
|
readonly authors: readonly {
|
477
490
|
readonly name: string;
|
478
491
|
}[];
|
492
|
+
} & {
|
493
|
+
readonly id: string;
|
479
494
|
} & {
|
480
495
|
readonly tags: readonly ({
|
481
496
|
readonly type: "DRUPAL_EXTERNAL_ID";
|
@@ -496,8 +511,7 @@ declare const _default: {
|
|
496
511
|
Schema: Schema.Struct<{
|
497
512
|
kind: Schema.Literal<["INTERNAL_ARTICLE_EVENT"]>;
|
498
513
|
payload: Schema.Struct<{
|
499
|
-
article: Schema.extend<Schema.Struct<{
|
500
|
-
id: typeof Schema.UUID;
|
514
|
+
article: Schema.extend<Schema.extend<Schema.Struct<{
|
501
515
|
title: typeof Schema.NonEmptyString;
|
502
516
|
teaser: typeof Schema.NonEmptyString;
|
503
517
|
content: typeof Schema.NonEmptyString;
|
@@ -510,6 +524,8 @@ declare const _default: {
|
|
510
524
|
name: typeof Schema.NonEmptyString;
|
511
525
|
}>>;
|
512
526
|
}>, Schema.Struct<{
|
527
|
+
id: typeof Schema.NonEmptyString;
|
528
|
+
}>>, Schema.Struct<{
|
513
529
|
tags: Schema.Array$<Schema.Union<[Schema.Struct<{
|
514
530
|
type: Schema.Literal<["CATEGORY"]>;
|
515
531
|
value: typeof Schema.NonEmptyString;
|
@@ -4,7 +4,7 @@ exports.InternalArticleEventSchema = void 0;
|
|
4
4
|
const schema_1 = require("@effect/schema");
|
5
5
|
const Article_1 = require("../types/Article");
|
6
6
|
const makeHelpers_1 = require("../utils/makeHelpers");
|
7
|
-
const InternalArticleSchema = schema_1.Schema.extend(Article_1.
|
7
|
+
const InternalArticleSchema = schema_1.Schema.extend(Article_1.BaseInternalArticleSchema, schema_1.Schema.Struct({
|
8
8
|
tags: schema_1.Schema.Array(schema_1.Schema.Union(Article_1.CategoryTagSchema, Article_1.ExternalArticleReferenceTagSchema, Article_1.DrupalExternalIDTag)),
|
9
9
|
}));
|
10
10
|
exports.InternalArticleEventSchema = schema_1.Schema.Struct({
|
package/lib/types/Article.d.ts
CHANGED
@@ -30,3 +30,18 @@ export declare const BaseArticleSchema: Schema.Struct<{
|
|
30
30
|
name: typeof Schema.NonEmptyString;
|
31
31
|
}>>;
|
32
32
|
}>;
|
33
|
+
export declare const BaseInternalArticleSchema: Schema.extend<Schema.Struct<{
|
34
|
+
title: typeof Schema.NonEmptyString;
|
35
|
+
teaser: typeof Schema.NonEmptyString;
|
36
|
+
content: typeof Schema.NonEmptyString;
|
37
|
+
publishedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
|
38
|
+
updatedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
|
39
|
+
retrievedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
|
40
|
+
url: typeof Schema.NonEmptyString;
|
41
|
+
site: typeof Schema.NonEmptyString;
|
42
|
+
authors: Schema.Array$<Schema.Struct<{
|
43
|
+
name: typeof Schema.NonEmptyString;
|
44
|
+
}>>;
|
45
|
+
}>, Schema.Struct<{
|
46
|
+
id: typeof Schema.NonEmptyString;
|
47
|
+
}>>;
|
package/lib/types/Article.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.BaseArticleSchema = exports.AuthorSchema = exports.DrupalExternalIDTag = exports.ExternalArticleReferenceTagSchema = exports.CategoryTagSchema = exports.DateTimeSchema = void 0;
|
3
|
+
exports.BaseInternalArticleSchema = exports.BaseArticleSchema = exports.AuthorSchema = exports.DrupalExternalIDTag = exports.ExternalArticleReferenceTagSchema = exports.CategoryTagSchema = exports.DateTimeSchema = void 0;
|
4
4
|
const schema_1 = require("@effect/schema");
|
5
5
|
exports.DateTimeSchema = schema_1.Schema.DateTimeUtc.annotations({
|
6
6
|
jsonSchema: { type: 'string', format: 'date-time' },
|
@@ -35,3 +35,7 @@ exports.BaseArticleSchema = schema_1.Schema.Struct({
|
|
35
35
|
site: schema_1.Schema.NonEmptyString,
|
36
36
|
authors: schema_1.Schema.Array(exports.AuthorSchema),
|
37
37
|
});
|
38
|
+
const InternalArticleIDSchema = schema_1.Schema.NonEmptyString;
|
39
|
+
exports.BaseInternalArticleSchema = schema_1.Schema.extend(exports.BaseArticleSchema.omit('id'), schema_1.Schema.Struct({
|
40
|
+
id: InternalArticleIDSchema,
|
41
|
+
}));
|