@productminds/article-events 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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;
@@ -7,9 +7,9 @@ export declare const ExternalArticleEventSchema: Schema.Struct<{
7
7
  title: typeof Schema.NonEmptyString;
8
8
  teaser: typeof Schema.NonEmptyString;
9
9
  content: typeof Schema.NonEmptyString;
10
- publishedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
11
- updatedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
12
- retrievedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
10
+ publishedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
11
+ updatedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
12
+ retrievedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
13
13
  url: typeof Schema.NonEmptyString;
14
14
  site: typeof Schema.NonEmptyString;
15
15
  authors: Schema.Array$<Schema.Struct<{
@@ -34,9 +34,9 @@ declare const _default: {
34
34
  readonly title: string;
35
35
  readonly teaser: string;
36
36
  readonly content: string;
37
- readonly publishedAt: Date;
38
- readonly updatedAt: Date;
39
- readonly retrievedAt: Date;
37
+ readonly publishedAt: import("effect/DateTime").Utc;
38
+ readonly updatedAt: import("effect/DateTime").Utc;
39
+ readonly retrievedAt: import("effect/DateTime").Utc;
40
40
  readonly url: string;
41
41
  readonly site: string;
42
42
  readonly authors: readonly {
@@ -60,9 +60,9 @@ declare const _default: {
60
60
  readonly title: string;
61
61
  readonly teaser: string;
62
62
  readonly content: string;
63
- readonly publishedAt: Date;
64
- readonly updatedAt: Date;
65
- readonly retrievedAt: Date;
63
+ readonly publishedAt: import("effect/DateTime").Utc;
64
+ readonly updatedAt: import("effect/DateTime").Utc;
65
+ readonly retrievedAt: import("effect/DateTime").Utc;
66
66
  readonly url: string;
67
67
  readonly site: string;
68
68
  readonly authors: readonly {
@@ -86,9 +86,9 @@ declare const _default: {
86
86
  readonly title: string;
87
87
  readonly teaser: string;
88
88
  readonly content: string;
89
- readonly publishedAt: Date;
90
- readonly updatedAt: Date;
91
- readonly retrievedAt: Date;
89
+ readonly publishedAt: import("effect/DateTime").Utc;
90
+ readonly updatedAt: import("effect/DateTime").Utc;
91
+ readonly retrievedAt: import("effect/DateTime").Utc;
92
92
  readonly url: string;
93
93
  readonly site: string;
94
94
  readonly authors: readonly {
@@ -137,9 +137,9 @@ declare const _default: {
137
137
  readonly title: string;
138
138
  readonly teaser: string;
139
139
  readonly content: string;
140
- readonly publishedAt: Date;
141
- readonly updatedAt: Date;
142
- readonly retrievedAt: Date;
140
+ readonly publishedAt: import("effect/DateTime").Utc;
141
+ readonly updatedAt: import("effect/DateTime").Utc;
142
+ readonly retrievedAt: import("effect/DateTime").Utc;
143
143
  readonly url: string;
144
144
  readonly site: string;
145
145
  readonly authors: readonly {
@@ -188,9 +188,9 @@ declare const _default: {
188
188
  readonly title: string;
189
189
  readonly teaser: string;
190
190
  readonly content: string;
191
- readonly publishedAt: Date;
192
- readonly updatedAt: Date;
193
- readonly retrievedAt: Date;
191
+ readonly publishedAt: import("effect/DateTime").Utc;
192
+ readonly updatedAt: import("effect/DateTime").Utc;
193
+ readonly retrievedAt: import("effect/DateTime").Utc;
194
194
  readonly url: string;
195
195
  readonly site: string;
196
196
  readonly authors: readonly {
@@ -214,9 +214,9 @@ declare const _default: {
214
214
  readonly title: string;
215
215
  readonly teaser: string;
216
216
  readonly content: string;
217
- readonly publishedAt: Date;
218
- readonly updatedAt: Date;
219
- readonly retrievedAt: Date;
217
+ readonly publishedAt: import("effect/DateTime").Utc;
218
+ readonly updatedAt: import("effect/DateTime").Utc;
219
+ readonly retrievedAt: import("effect/DateTime").Utc;
220
220
  readonly url: string;
221
221
  readonly site: string;
222
222
  readonly authors: readonly {
@@ -240,9 +240,9 @@ declare const _default: {
240
240
  readonly title: string;
241
241
  readonly teaser: string;
242
242
  readonly content: string;
243
- readonly publishedAt: Date;
244
- readonly updatedAt: Date;
245
- readonly retrievedAt: Date;
243
+ readonly publishedAt: import("effect/DateTime").Utc;
244
+ readonly updatedAt: import("effect/DateTime").Utc;
245
+ readonly retrievedAt: import("effect/DateTime").Utc;
246
246
  readonly url: string;
247
247
  readonly site: string;
248
248
  readonly authors: readonly {
@@ -266,9 +266,9 @@ declare const _default: {
266
266
  readonly title: string;
267
267
  readonly teaser: string;
268
268
  readonly content: string;
269
- readonly publishedAt: Date;
270
- readonly updatedAt: Date;
271
- readonly retrievedAt: Date;
269
+ readonly publishedAt: import("effect/DateTime").Utc;
270
+ readonly updatedAt: import("effect/DateTime").Utc;
271
+ readonly retrievedAt: import("effect/DateTime").Utc;
272
272
  readonly url: string;
273
273
  readonly site: string;
274
274
  readonly authors: readonly {
@@ -292,9 +292,9 @@ declare const _default: {
292
292
  readonly title: string;
293
293
  readonly teaser: string;
294
294
  readonly content: string;
295
- readonly publishedAt: Date;
296
- readonly updatedAt: Date;
297
- readonly retrievedAt: Date;
295
+ readonly publishedAt: import("effect/DateTime").Utc;
296
+ readonly updatedAt: import("effect/DateTime").Utc;
297
+ readonly retrievedAt: import("effect/DateTime").Utc;
298
298
  readonly url: string;
299
299
  readonly site: string;
300
300
  readonly authors: readonly {
@@ -318,9 +318,9 @@ declare const _default: {
318
318
  readonly title: string;
319
319
  readonly teaser: string;
320
320
  readonly content: string;
321
- readonly publishedAt: Date;
322
- readonly updatedAt: Date;
323
- readonly retrievedAt: Date;
321
+ readonly publishedAt: import("effect/DateTime").Utc;
322
+ readonly updatedAt: import("effect/DateTime").Utc;
323
+ readonly retrievedAt: import("effect/DateTime").Utc;
324
324
  readonly url: string;
325
325
  readonly site: string;
326
326
  readonly authors: readonly {
@@ -344,9 +344,9 @@ declare const _default: {
344
344
  readonly title: string;
345
345
  readonly teaser: string;
346
346
  readonly content: string;
347
- readonly publishedAt: Date;
348
- readonly updatedAt: Date;
349
- readonly retrievedAt: Date;
347
+ readonly publishedAt: import("effect/DateTime").Utc;
348
+ readonly updatedAt: import("effect/DateTime").Utc;
349
+ readonly retrievedAt: import("effect/DateTime").Utc;
350
350
  readonly url: string;
351
351
  readonly site: string;
352
352
  readonly authors: readonly {
@@ -370,9 +370,9 @@ declare const _default: {
370
370
  readonly title: string;
371
371
  readonly teaser: string;
372
372
  readonly content: string;
373
- readonly publishedAt: Date;
374
- readonly updatedAt: Date;
375
- readonly retrievedAt: Date;
373
+ readonly publishedAt: import("effect/DateTime").Utc;
374
+ readonly updatedAt: import("effect/DateTime").Utc;
375
+ readonly retrievedAt: import("effect/DateTime").Utc;
376
376
  readonly url: string;
377
377
  readonly site: string;
378
378
  readonly authors: readonly {
@@ -396,9 +396,9 @@ declare const _default: {
396
396
  title: typeof Schema.NonEmptyString;
397
397
  teaser: typeof Schema.NonEmptyString;
398
398
  content: typeof Schema.NonEmptyString;
399
- publishedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
400
- updatedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
401
- retrievedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
399
+ publishedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
400
+ updatedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
401
+ retrievedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
402
402
  url: typeof Schema.NonEmptyString;
403
403
  site: typeof Schema.NonEmptyString;
404
404
  authors: Schema.Array$<Schema.Struct<{
@@ -7,9 +7,9 @@ export declare const InternalArticleEventSchema: Schema.Struct<{
7
7
  title: typeof Schema.NonEmptyString;
8
8
  teaser: typeof Schema.NonEmptyString;
9
9
  content: typeof Schema.NonEmptyString;
10
- publishedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
11
- updatedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
12
- retrievedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
10
+ publishedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
11
+ updatedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
12
+ retrievedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
13
13
  url: typeof Schema.NonEmptyString;
14
14
  site: typeof Schema.NonEmptyString;
15
15
  authors: Schema.Array$<Schema.Struct<{
@@ -41,9 +41,9 @@ declare const _default: {
41
41
  readonly title: string;
42
42
  readonly teaser: string;
43
43
  readonly content: string;
44
- readonly publishedAt: Date;
45
- readonly updatedAt: Date;
46
- readonly retrievedAt: Date;
44
+ readonly publishedAt: import("effect/DateTime").Utc;
45
+ readonly updatedAt: import("effect/DateTime").Utc;
46
+ readonly retrievedAt: import("effect/DateTime").Utc;
47
47
  readonly url: string;
48
48
  readonly site: string;
49
49
  readonly authors: readonly {
@@ -74,9 +74,9 @@ declare const _default: {
74
74
  readonly title: string;
75
75
  readonly teaser: string;
76
76
  readonly content: string;
77
- readonly publishedAt: Date;
78
- readonly updatedAt: Date;
79
- readonly retrievedAt: Date;
77
+ readonly publishedAt: import("effect/DateTime").Utc;
78
+ readonly updatedAt: import("effect/DateTime").Utc;
79
+ readonly retrievedAt: import("effect/DateTime").Utc;
80
80
  readonly url: string;
81
81
  readonly site: string;
82
82
  readonly authors: readonly {
@@ -107,9 +107,9 @@ declare const _default: {
107
107
  readonly title: string;
108
108
  readonly teaser: string;
109
109
  readonly content: string;
110
- readonly publishedAt: Date;
111
- readonly updatedAt: Date;
112
- readonly retrievedAt: Date;
110
+ readonly publishedAt: import("effect/DateTime").Utc;
111
+ readonly updatedAt: import("effect/DateTime").Utc;
112
+ readonly retrievedAt: import("effect/DateTime").Utc;
113
113
  readonly url: string;
114
114
  readonly site: string;
115
115
  readonly authors: readonly {
@@ -172,9 +172,9 @@ declare const _default: {
172
172
  readonly title: string;
173
173
  readonly teaser: string;
174
174
  readonly content: string;
175
- readonly publishedAt: Date;
176
- readonly updatedAt: Date;
177
- readonly retrievedAt: Date;
175
+ readonly publishedAt: import("effect/DateTime").Utc;
176
+ readonly updatedAt: import("effect/DateTime").Utc;
177
+ readonly retrievedAt: import("effect/DateTime").Utc;
178
178
  readonly url: string;
179
179
  readonly site: string;
180
180
  readonly authors: readonly {
@@ -237,9 +237,9 @@ declare const _default: {
237
237
  readonly title: string;
238
238
  readonly teaser: string;
239
239
  readonly content: string;
240
- readonly publishedAt: Date;
241
- readonly updatedAt: Date;
242
- readonly retrievedAt: Date;
240
+ readonly publishedAt: import("effect/DateTime").Utc;
241
+ readonly updatedAt: import("effect/DateTime").Utc;
242
+ readonly retrievedAt: import("effect/DateTime").Utc;
243
243
  readonly url: string;
244
244
  readonly site: string;
245
245
  readonly authors: readonly {
@@ -270,9 +270,9 @@ declare const _default: {
270
270
  readonly title: string;
271
271
  readonly teaser: string;
272
272
  readonly content: string;
273
- readonly publishedAt: Date;
274
- readonly updatedAt: Date;
275
- readonly retrievedAt: Date;
273
+ readonly publishedAt: import("effect/DateTime").Utc;
274
+ readonly updatedAt: import("effect/DateTime").Utc;
275
+ readonly retrievedAt: import("effect/DateTime").Utc;
276
276
  readonly url: string;
277
277
  readonly site: string;
278
278
  readonly authors: readonly {
@@ -303,9 +303,9 @@ declare const _default: {
303
303
  readonly title: string;
304
304
  readonly teaser: string;
305
305
  readonly content: string;
306
- readonly publishedAt: Date;
307
- readonly updatedAt: Date;
308
- readonly retrievedAt: Date;
306
+ readonly publishedAt: import("effect/DateTime").Utc;
307
+ readonly updatedAt: import("effect/DateTime").Utc;
308
+ readonly retrievedAt: import("effect/DateTime").Utc;
309
309
  readonly url: string;
310
310
  readonly site: string;
311
311
  readonly authors: readonly {
@@ -336,9 +336,9 @@ declare const _default: {
336
336
  readonly title: string;
337
337
  readonly teaser: string;
338
338
  readonly content: string;
339
- readonly publishedAt: Date;
340
- readonly updatedAt: Date;
341
- readonly retrievedAt: Date;
339
+ readonly publishedAt: import("effect/DateTime").Utc;
340
+ readonly updatedAt: import("effect/DateTime").Utc;
341
+ readonly retrievedAt: import("effect/DateTime").Utc;
342
342
  readonly url: string;
343
343
  readonly site: string;
344
344
  readonly authors: readonly {
@@ -369,9 +369,9 @@ declare const _default: {
369
369
  readonly title: string;
370
370
  readonly teaser: string;
371
371
  readonly content: string;
372
- readonly publishedAt: Date;
373
- readonly updatedAt: Date;
374
- readonly retrievedAt: Date;
372
+ readonly publishedAt: import("effect/DateTime").Utc;
373
+ readonly updatedAt: import("effect/DateTime").Utc;
374
+ readonly retrievedAt: import("effect/DateTime").Utc;
375
375
  readonly url: string;
376
376
  readonly site: string;
377
377
  readonly authors: readonly {
@@ -402,9 +402,9 @@ declare const _default: {
402
402
  readonly title: string;
403
403
  readonly teaser: string;
404
404
  readonly content: string;
405
- readonly publishedAt: Date;
406
- readonly updatedAt: Date;
407
- readonly retrievedAt: Date;
405
+ readonly publishedAt: import("effect/DateTime").Utc;
406
+ readonly updatedAt: import("effect/DateTime").Utc;
407
+ readonly retrievedAt: import("effect/DateTime").Utc;
408
408
  readonly url: string;
409
409
  readonly site: string;
410
410
  readonly authors: readonly {
@@ -435,9 +435,9 @@ declare const _default: {
435
435
  readonly title: string;
436
436
  readonly teaser: string;
437
437
  readonly content: string;
438
- readonly publishedAt: Date;
439
- readonly updatedAt: Date;
440
- readonly retrievedAt: Date;
438
+ readonly publishedAt: import("effect/DateTime").Utc;
439
+ readonly updatedAt: import("effect/DateTime").Utc;
440
+ readonly retrievedAt: import("effect/DateTime").Utc;
441
441
  readonly url: string;
442
442
  readonly site: string;
443
443
  readonly authors: readonly {
@@ -468,9 +468,9 @@ declare const _default: {
468
468
  readonly title: string;
469
469
  readonly teaser: string;
470
470
  readonly content: string;
471
- readonly publishedAt: Date;
472
- readonly updatedAt: Date;
473
- readonly retrievedAt: Date;
471
+ readonly publishedAt: import("effect/DateTime").Utc;
472
+ readonly updatedAt: import("effect/DateTime").Utc;
473
+ readonly retrievedAt: import("effect/DateTime").Utc;
474
474
  readonly url: string;
475
475
  readonly site: string;
476
476
  readonly authors: readonly {
@@ -501,9 +501,9 @@ declare const _default: {
501
501
  title: typeof Schema.NonEmptyString;
502
502
  teaser: typeof Schema.NonEmptyString;
503
503
  content: typeof Schema.NonEmptyString;
504
- publishedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
505
- updatedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
506
- retrievedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
504
+ publishedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
505
+ updatedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
506
+ retrievedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
507
507
  url: typeof Schema.NonEmptyString;
508
508
  site: typeof Schema.NonEmptyString;
509
509
  authors: Schema.Array$<Schema.Struct<{
@@ -0,0 +1,2 @@
1
+ import { Schema } from "@effect/schema";
2
+ export declare const InternalArticleIDSchema: typeof Schema.NonEmptyString;
@@ -0,0 +1,5 @@
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;
@@ -1,5 +1,5 @@
1
1
  import { Schema } from '@effect/schema';
2
- export declare const DateTimeSchema: Schema.refine<Date, Schema.Schema<Date, string, never>>;
2
+ export declare const DateTimeSchema: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
3
3
  export declare const CategoryTagSchema: Schema.Struct<{
4
4
  type: Schema.Literal<["CATEGORY"]>;
5
5
  value: typeof Schema.NonEmptyString;
@@ -21,9 +21,9 @@ export declare const BaseArticleSchema: Schema.Struct<{
21
21
  title: typeof Schema.NonEmptyString;
22
22
  teaser: typeof Schema.NonEmptyString;
23
23
  content: typeof Schema.NonEmptyString;
24
- publishedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
25
- updatedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
26
- retrievedAt: Schema.refine<Date, Schema.Schema<Date, string, never>>;
24
+ publishedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
25
+ updatedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
26
+ retrievedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
27
27
  url: typeof Schema.NonEmptyString;
28
28
  site: typeof Schema.NonEmptyString;
29
29
  authors: Schema.Array$<Schema.Struct<{
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseArticleSchema = exports.AuthorSchema = exports.DrupalExternalIDTag = exports.ExternalArticleReferenceTagSchema = exports.CategoryTagSchema = exports.DateTimeSchema = void 0;
4
4
  const schema_1 = require("@effect/schema");
5
- exports.DateTimeSchema = schema_1.Schema.Date.annotations({
5
+ exports.DateTimeSchema = schema_1.Schema.DateTimeUtc.annotations({
6
6
  jsonSchema: { type: 'string', format: 'date-time' },
7
7
  });
8
8
  exports.CategoryTagSchema = schema_1.Schema.Struct({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@productminds/article-events",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "Article events",
5
5
  "license": "ISC",
6
6
  "main": "lib/article-events.js",