@productminds/article-events 5.2.0 → 6.2.0

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.
@@ -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;
@@ -1,7 +1,45 @@
1
1
  import { Schema } from '@effect/schema';
2
+ export declare const ArticleUnpublishedSchema: Schema.Struct<{
3
+ status: Schema.Literal<["UNPUBLISHED"]>;
4
+ id: typeof Schema.NonEmptyString;
5
+ unpublishedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
6
+ }>;
7
+ export declare const ArticleIngressSchema: Schema.Struct<{
8
+ source: Schema.Literal<["INTERNAL"]>;
9
+ status: Schema.Literal<["NEW", "UPDATED"]>;
10
+ article: Schema.extend<Schema.Struct<{
11
+ id: typeof Schema.NonEmptyString;
12
+ title: typeof Schema.NonEmptyString;
13
+ teaser: typeof Schema.NonEmptyString;
14
+ content: typeof Schema.NonEmptyString;
15
+ publishedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
16
+ updatedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
17
+ retrievedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
18
+ url: typeof Schema.NonEmptyString;
19
+ site: typeof Schema.NonEmptyString;
20
+ authors: Schema.Array$<Schema.Struct<{
21
+ name: typeof Schema.NonEmptyString;
22
+ }>>;
23
+ }>, Schema.Struct<{
24
+ tags: Schema.Array$<Schema.Union<[Schema.Struct<{
25
+ type: Schema.Literal<["CATEGORY"]>;
26
+ value: typeof Schema.NonEmptyString;
27
+ }>, Schema.Struct<{
28
+ type: Schema.Literal<["EXTERNAL_ARTICLE_REFERENCE"]>;
29
+ id: typeof Schema.NonEmptyString;
30
+ }>, Schema.Struct<{
31
+ type: Schema.Literal<["DRUPAL_EXTERNAL_ID"]>;
32
+ extID: typeof Schema.UUID;
33
+ extSource: typeof Schema.String;
34
+ }>]>>;
35
+ reusePolicy: Schema.optional<Schema.Literal<["strictly_no_reuse", "by_request", "free_to_reuse"]>>;
36
+ }>>;
37
+ }>;
2
38
  export declare const InternalArticleEventSchema: Schema.Struct<{
3
39
  kind: Schema.Literal<["INTERNAL_ARTICLE_EVENT"]>;
4
- payload: Schema.Struct<{
40
+ payload: Schema.Union<[Schema.Struct<{
41
+ source: Schema.Literal<["INTERNAL"]>;
42
+ status: Schema.Literal<["NEW", "UPDATED"]>;
5
43
  article: Schema.extend<Schema.Struct<{
6
44
  id: typeof Schema.NonEmptyString;
7
45
  title: typeof Schema.NonEmptyString;
@@ -27,10 +65,13 @@ export declare const InternalArticleEventSchema: Schema.Struct<{
27
65
  extID: typeof Schema.UUID;
28
66
  extSource: typeof Schema.String;
29
67
  }>]>>;
68
+ reusePolicy: Schema.optional<Schema.Literal<["strictly_no_reuse", "by_request", "free_to_reuse"]>>;
30
69
  }>>;
31
- status: Schema.Literal<["NEW", "UPDATED"]>;
32
- source: Schema.Literal<["INTERNAL"]>;
33
- }>;
70
+ }>, Schema.Struct<{
71
+ status: Schema.Literal<["UNPUBLISHED"]>;
72
+ id: typeof Schema.NonEmptyString;
73
+ unpublishedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
74
+ }>]>;
34
75
  }>;
35
76
  declare const _default: {
36
77
  decode: (u: unknown, overrideOptions?: import("@effect/schema/AST").ParseOptions) => import("effect/Either").Either<{
@@ -61,9 +102,14 @@ declare const _default: {
61
102
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
62
103
  readonly id: string;
63
104
  })[];
105
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
64
106
  };
65
107
  readonly status: "NEW" | "UPDATED";
66
108
  readonly source: "INTERNAL";
109
+ } | {
110
+ readonly id: string;
111
+ readonly status: "UNPUBLISHED";
112
+ readonly unpublishedAt: import("effect/DateTime").Utc;
67
113
  };
68
114
  }, import("@effect/schema/ParseResult").ParseError>;
69
115
  decodeExn: (u: unknown) => {
@@ -94,9 +140,14 @@ declare const _default: {
94
140
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
95
141
  readonly id: string;
96
142
  })[];
143
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
97
144
  };
98
145
  readonly status: "NEW" | "UPDATED";
99
146
  readonly source: "INTERNAL";
147
+ } | {
148
+ readonly id: string;
149
+ readonly status: "UNPUBLISHED";
150
+ readonly unpublishedAt: import("effect/DateTime").Utc;
100
151
  };
101
152
  };
102
153
  encode: (a: {
@@ -127,9 +178,14 @@ declare const _default: {
127
178
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
128
179
  readonly id: string;
129
180
  })[];
181
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
130
182
  };
131
183
  readonly status: "NEW" | "UPDATED";
132
184
  readonly source: "INTERNAL";
185
+ } | {
186
+ readonly id: string;
187
+ readonly status: "UNPUBLISHED";
188
+ readonly unpublishedAt: import("effect/DateTime").Utc;
133
189
  };
134
190
  }, overrideOptions?: import("@effect/schema/AST").ParseOptions) => import("effect/Either").Either<{
135
191
  readonly kind: "INTERNAL_ARTICLE_EVENT";
@@ -159,9 +215,14 @@ declare const _default: {
159
215
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
160
216
  readonly id: string;
161
217
  })[];
218
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
162
219
  };
163
220
  readonly status: "NEW" | "UPDATED";
164
221
  readonly source: "INTERNAL";
222
+ } | {
223
+ readonly id: string;
224
+ readonly status: "UNPUBLISHED";
225
+ readonly unpublishedAt: string;
165
226
  };
166
227
  }, import("@effect/schema/ParseResult").ParseError>;
167
228
  encodeExn: (event: {
@@ -192,9 +253,14 @@ declare const _default: {
192
253
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
193
254
  readonly id: string;
194
255
  })[];
256
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
195
257
  };
196
258
  readonly status: "NEW" | "UPDATED";
197
259
  readonly source: "INTERNAL";
260
+ } | {
261
+ readonly id: string;
262
+ readonly status: "UNPUBLISHED";
263
+ readonly unpublishedAt: import("effect/DateTime").Utc;
198
264
  };
199
265
  }) => {
200
266
  readonly kind: "INTERNAL_ARTICLE_EVENT";
@@ -224,9 +290,14 @@ declare const _default: {
224
290
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
225
291
  readonly id: string;
226
292
  })[];
293
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
227
294
  };
228
295
  readonly status: "NEW" | "UPDATED";
229
296
  readonly source: "INTERNAL";
297
+ } | {
298
+ readonly id: string;
299
+ readonly status: "UNPUBLISHED";
300
+ readonly unpublishedAt: string;
230
301
  };
231
302
  };
232
303
  fromString: (msg: string) => import("effect/Either").Either<{
@@ -257,9 +328,14 @@ declare const _default: {
257
328
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
258
329
  readonly id: string;
259
330
  })[];
331
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
260
332
  };
261
333
  readonly status: "NEW" | "UPDATED";
262
334
  readonly source: "INTERNAL";
335
+ } | {
336
+ readonly id: string;
337
+ readonly status: "UNPUBLISHED";
338
+ readonly unpublishedAt: import("effect/DateTime").Utc;
263
339
  };
264
340
  }, import("@effect/schema/ParseResult").ParseError>;
265
341
  fromBuffer: (msg: Buffer) => import("effect/Either").Either<{
@@ -290,9 +366,14 @@ declare const _default: {
290
366
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
291
367
  readonly id: string;
292
368
  })[];
369
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
293
370
  };
294
371
  readonly status: "NEW" | "UPDATED";
295
372
  readonly source: "INTERNAL";
373
+ } | {
374
+ readonly id: string;
375
+ readonly status: "UNPUBLISHED";
376
+ readonly unpublishedAt: import("effect/DateTime").Utc;
296
377
  };
297
378
  }, import("@effect/schema/ParseResult").ParseError>;
298
379
  fromStringExn: (msg: string) => {
@@ -323,9 +404,14 @@ declare const _default: {
323
404
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
324
405
  readonly id: string;
325
406
  })[];
407
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
326
408
  };
327
409
  readonly status: "NEW" | "UPDATED";
328
410
  readonly source: "INTERNAL";
411
+ } | {
412
+ readonly id: string;
413
+ readonly status: "UNPUBLISHED";
414
+ readonly unpublishedAt: import("effect/DateTime").Utc;
329
415
  };
330
416
  };
331
417
  fromBufferExn: (msg: Buffer) => {
@@ -356,9 +442,14 @@ declare const _default: {
356
442
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
357
443
  readonly id: string;
358
444
  })[];
445
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
359
446
  };
360
447
  readonly status: "NEW" | "UPDATED";
361
448
  readonly source: "INTERNAL";
449
+ } | {
450
+ readonly id: string;
451
+ readonly status: "UNPUBLISHED";
452
+ readonly unpublishedAt: import("effect/DateTime").Utc;
362
453
  };
363
454
  };
364
455
  toString: (event: {
@@ -389,9 +480,14 @@ declare const _default: {
389
480
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
390
481
  readonly id: string;
391
482
  })[];
483
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
392
484
  };
393
485
  readonly status: "NEW" | "UPDATED";
394
486
  readonly source: "INTERNAL";
487
+ } | {
488
+ readonly id: string;
489
+ readonly status: "UNPUBLISHED";
490
+ readonly unpublishedAt: import("effect/DateTime").Utc;
395
491
  };
396
492
  }) => string;
397
493
  toBuffer: (event: {
@@ -422,9 +518,14 @@ declare const _default: {
422
518
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
423
519
  readonly id: string;
424
520
  })[];
521
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
425
522
  };
426
523
  readonly status: "NEW" | "UPDATED";
427
524
  readonly source: "INTERNAL";
525
+ } | {
526
+ readonly id: string;
527
+ readonly status: "UNPUBLISHED";
528
+ readonly unpublishedAt: import("effect/DateTime").Utc;
428
529
  };
429
530
  }) => Buffer;
430
531
  toStringExn: (event: {
@@ -455,9 +556,14 @@ declare const _default: {
455
556
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
456
557
  readonly id: string;
457
558
  })[];
559
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
458
560
  };
459
561
  readonly status: "NEW" | "UPDATED";
460
562
  readonly source: "INTERNAL";
563
+ } | {
564
+ readonly id: string;
565
+ readonly status: "UNPUBLISHED";
566
+ readonly unpublishedAt: import("effect/DateTime").Utc;
461
567
  };
462
568
  }) => string;
463
569
  toBufferExn: (event: {
@@ -488,14 +594,21 @@ declare const _default: {
488
594
  readonly type: "EXTERNAL_ARTICLE_REFERENCE";
489
595
  readonly id: string;
490
596
  })[];
597
+ readonly reusePolicy?: "strictly_no_reuse" | "by_request" | "free_to_reuse" | undefined;
491
598
  };
492
599
  readonly status: "NEW" | "UPDATED";
493
600
  readonly source: "INTERNAL";
601
+ } | {
602
+ readonly id: string;
603
+ readonly status: "UNPUBLISHED";
604
+ readonly unpublishedAt: import("effect/DateTime").Utc;
494
605
  };
495
606
  }) => Buffer;
496
607
  Schema: Schema.Struct<{
497
608
  kind: Schema.Literal<["INTERNAL_ARTICLE_EVENT"]>;
498
- payload: Schema.Struct<{
609
+ payload: Schema.Union<[Schema.Struct<{
610
+ source: Schema.Literal<["INTERNAL"]>;
611
+ status: Schema.Literal<["NEW", "UPDATED"]>;
499
612
  article: Schema.extend<Schema.Struct<{
500
613
  id: typeof Schema.NonEmptyString;
501
614
  title: typeof Schema.NonEmptyString;
@@ -521,10 +634,13 @@ declare const _default: {
521
634
  extID: typeof Schema.UUID;
522
635
  extSource: typeof Schema.String;
523
636
  }>]>>;
637
+ reusePolicy: Schema.optional<Schema.Literal<["strictly_no_reuse", "by_request", "free_to_reuse"]>>;
524
638
  }>>;
525
- status: Schema.Literal<["NEW", "UPDATED"]>;
526
- source: Schema.Literal<["INTERNAL"]>;
527
- }>;
639
+ }>, Schema.Struct<{
640
+ status: Schema.Literal<["UNPUBLISHED"]>;
641
+ id: typeof Schema.NonEmptyString;
642
+ unpublishedAt: Schema.transformOrFail<typeof Schema.String, typeof Schema.DateTimeUtcFromSelf, never>;
643
+ }>]>;
528
644
  }>;
529
645
  };
530
646
  export default _default;
@@ -1,19 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InternalArticleEventSchema = void 0;
3
+ exports.InternalArticleEventSchema = exports.ArticleIngressSchema = exports.ArticleUnpublishedSchema = 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
7
  const InternalArticleSchema = schema_1.Schema.extend(Article_1.BaseArticleSchema, 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
+ reusePolicy: schema_1.Schema.optional(schema_1.Schema.Literal('strictly_no_reuse', 'by_request', 'free_to_reuse')),
9
10
  }));
11
+ exports.ArticleUnpublishedSchema = schema_1.Schema.Struct({
12
+ status: schema_1.Schema.Literal('UNPUBLISHED'),
13
+ id: schema_1.Schema.NonEmptyString,
14
+ unpublishedAt: Article_1.DateTimeSchema,
15
+ });
16
+ exports.ArticleIngressSchema = schema_1.Schema.Struct({
17
+ source: schema_1.Schema.Literal('INTERNAL'),
18
+ status: schema_1.Schema.Literal('NEW', 'UPDATED'),
19
+ article: InternalArticleSchema,
20
+ });
10
21
  exports.InternalArticleEventSchema = schema_1.Schema.Struct({
11
22
  kind: schema_1.Schema.Literal('INTERNAL_ARTICLE_EVENT'),
12
- payload: schema_1.Schema.Struct({
13
- article: InternalArticleSchema,
14
- status: schema_1.Schema.Literal('NEW', 'UPDATED'),
15
- source: schema_1.Schema.Literal('INTERNAL'),
16
- }),
23
+ payload: schema_1.Schema.Union(exports.ArticleIngressSchema, exports.ArticleUnpublishedSchema),
17
24
  });
18
25
  const helpers = (0, makeHelpers_1.makeHelpers)(exports.InternalArticleEventSchema);
19
26
  exports.default = Object.assign({ Schema: exports.InternalArticleEventSchema }, helpers);
@@ -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;
@@ -0,0 +1,2 @@
1
+ import { Schema } from '@effect/schema';
2
+ export declare const ReusePolicySchema: Schema.Struct<{}>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReusePolicySchema = void 0;
4
+ const schema_1 = require("@effect/schema");
5
+ exports.ReusePolicySchema = schema_1.Schema.Struct({});
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
- {
2
- "name": "@productminds/article-events",
3
- "version": "5.2.0",
4
- "description": "Article events",
5
- "license": "ISC",
6
- "main": "lib/article-events.js",
7
- "typings": "lib/article-events.d.ts",
8
- "directories": {
9
- "lib": "lib"
10
- },
11
- "files": [
12
- "lib"
13
- ],
14
- "scripts": {
15
- "cmd:generate_json_schema": "tsc && node ./lib/cmd/write-json-schema.js",
16
- "build": "tsc",
17
- "build:watch": "tsc --watch",
18
- "build_and_publish": "npm run build && npm publish"
19
- }
20
- }
1
+ {
2
+ "name": "@productminds/article-events",
3
+ "version": "6.2.0",
4
+ "description": "Article events",
5
+ "license": "ISC",
6
+ "main": "lib/article-events.js",
7
+ "typings": "lib/article-events.d.ts",
8
+ "directories": {
9
+ "lib": "lib"
10
+ },
11
+ "files": [
12
+ "lib"
13
+ ],
14
+ "scripts": {
15
+ "cmd:generate_json_schema": "tsc && node ./lib/cmd/write-json-schema.js",
16
+ "build": "tsc",
17
+ "build:watch": "tsc --watch",
18
+ "build_and_publish": "npm run build && npm publish"
19
+ }
20
+ }