@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.
@@ -0,0 +1,450 @@
1
+ import { Schema } from "@effect/schema";
2
+ export declare const InternalArticleEventSchema: Schema.Struct<{
3
+ kind: Schema.Literal<["INTERNAL_ARTICLE_EVENT"]>;
4
+ payload: Schema.Struct<{
5
+ article: Schema.Struct<{
6
+ tags: Schema.Array$<Schema.Union<[Schema.Struct<{
7
+ type: Schema.Literal<["CATEGORY"]>;
8
+ value: typeof Schema.NonEmpty;
9
+ }>, Schema.Struct<{
10
+ type: Schema.Literal<["EXTERNAL_ARTICLE_REFERENCE"]>;
11
+ id: typeof Schema.UUID;
12
+ }>]>>;
13
+ id: typeof Schema.UUID;
14
+ title: typeof Schema.NonEmpty;
15
+ teaser: typeof Schema.NonEmpty;
16
+ content: typeof Schema.NonEmpty;
17
+ publishedAt: typeof Schema.Date;
18
+ updatedAt: typeof Schema.Date;
19
+ retrievedAt: typeof Schema.Date;
20
+ url: typeof Schema.NonEmpty;
21
+ site: typeof Schema.NonEmpty;
22
+ authors: Schema.Array$<Schema.Struct<{
23
+ name: typeof Schema.NonEmpty;
24
+ }>>;
25
+ }>;
26
+ status: Schema.Literal<["NEW", "UPDATED"]>;
27
+ source: Schema.Literal<["INTERNAL"]>;
28
+ }>;
29
+ }>;
30
+ declare const _default: {
31
+ decode: (u: unknown, overrideOptions?: import("@effect/schema/AST").ParseOptions) => import("effect/Either").Either<{
32
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
33
+ readonly payload: {
34
+ readonly article: {
35
+ readonly id: string;
36
+ readonly site: string;
37
+ readonly title: string;
38
+ readonly teaser: string;
39
+ readonly content: string;
40
+ readonly publishedAt: Date;
41
+ readonly updatedAt: Date;
42
+ readonly retrievedAt: Date;
43
+ readonly url: string;
44
+ readonly tags: readonly ({
45
+ readonly type: "CATEGORY";
46
+ readonly value: string;
47
+ } | {
48
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
49
+ readonly id: string;
50
+ })[];
51
+ readonly authors: readonly {
52
+ readonly name: string;
53
+ }[];
54
+ };
55
+ readonly status: "NEW" | "UPDATED";
56
+ readonly source: "INTERNAL";
57
+ };
58
+ }, import("@effect/schema/ParseResult").ParseError>;
59
+ decodeExn: (u: unknown) => {
60
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
61
+ readonly payload: {
62
+ readonly article: {
63
+ readonly id: string;
64
+ readonly site: string;
65
+ readonly title: string;
66
+ readonly teaser: string;
67
+ readonly content: string;
68
+ readonly publishedAt: Date;
69
+ readonly updatedAt: Date;
70
+ readonly retrievedAt: Date;
71
+ readonly url: string;
72
+ readonly tags: readonly ({
73
+ readonly type: "CATEGORY";
74
+ readonly value: string;
75
+ } | {
76
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
77
+ readonly id: string;
78
+ })[];
79
+ readonly authors: readonly {
80
+ readonly name: string;
81
+ }[];
82
+ };
83
+ readonly status: "NEW" | "UPDATED";
84
+ readonly source: "INTERNAL";
85
+ };
86
+ };
87
+ encode: (a: {
88
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
89
+ readonly payload: {
90
+ readonly article: {
91
+ readonly id: string;
92
+ readonly site: string;
93
+ readonly title: string;
94
+ readonly teaser: string;
95
+ readonly content: string;
96
+ readonly publishedAt: Date;
97
+ readonly updatedAt: Date;
98
+ readonly retrievedAt: Date;
99
+ readonly url: string;
100
+ readonly tags: readonly ({
101
+ readonly type: "CATEGORY";
102
+ readonly value: string;
103
+ } | {
104
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
105
+ readonly id: string;
106
+ })[];
107
+ readonly authors: readonly {
108
+ readonly name: string;
109
+ }[];
110
+ };
111
+ readonly status: "NEW" | "UPDATED";
112
+ readonly source: "INTERNAL";
113
+ };
114
+ }, overrideOptions?: import("@effect/schema/AST").ParseOptions) => import("effect/Either").Either<{
115
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
116
+ readonly payload: {
117
+ readonly article: {
118
+ readonly id: string;
119
+ readonly site: string;
120
+ readonly title: string;
121
+ readonly teaser: string;
122
+ readonly content: string;
123
+ readonly publishedAt: string;
124
+ readonly updatedAt: string;
125
+ readonly retrievedAt: string;
126
+ readonly url: string;
127
+ readonly tags: readonly ({
128
+ readonly type: "CATEGORY";
129
+ readonly value: string;
130
+ } | {
131
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
132
+ readonly id: string;
133
+ })[];
134
+ readonly authors: readonly {
135
+ readonly name: string;
136
+ }[];
137
+ };
138
+ readonly status: "NEW" | "UPDATED";
139
+ readonly source: "INTERNAL";
140
+ };
141
+ }, import("@effect/schema/ParseResult").ParseError>;
142
+ encodeExn: (event: {
143
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
144
+ readonly payload: {
145
+ readonly article: {
146
+ readonly id: string;
147
+ readonly site: string;
148
+ readonly title: string;
149
+ readonly teaser: string;
150
+ readonly content: string;
151
+ readonly publishedAt: Date;
152
+ readonly updatedAt: Date;
153
+ readonly retrievedAt: Date;
154
+ readonly url: string;
155
+ readonly tags: readonly ({
156
+ readonly type: "CATEGORY";
157
+ readonly value: string;
158
+ } | {
159
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
160
+ readonly id: string;
161
+ })[];
162
+ readonly authors: readonly {
163
+ readonly name: string;
164
+ }[];
165
+ };
166
+ readonly status: "NEW" | "UPDATED";
167
+ readonly source: "INTERNAL";
168
+ };
169
+ }) => {
170
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
171
+ readonly payload: {
172
+ readonly article: {
173
+ readonly id: string;
174
+ readonly site: string;
175
+ readonly title: string;
176
+ readonly teaser: string;
177
+ readonly content: string;
178
+ readonly publishedAt: string;
179
+ readonly updatedAt: string;
180
+ readonly retrievedAt: string;
181
+ readonly url: string;
182
+ readonly tags: readonly ({
183
+ readonly type: "CATEGORY";
184
+ readonly value: string;
185
+ } | {
186
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
187
+ readonly id: string;
188
+ })[];
189
+ readonly authors: readonly {
190
+ readonly name: string;
191
+ }[];
192
+ };
193
+ readonly status: "NEW" | "UPDATED";
194
+ readonly source: "INTERNAL";
195
+ };
196
+ };
197
+ fromString: (msg: string) => import("effect/Either").Either<{
198
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
199
+ readonly payload: {
200
+ readonly article: {
201
+ readonly id: string;
202
+ readonly site: string;
203
+ readonly title: string;
204
+ readonly teaser: string;
205
+ readonly content: string;
206
+ readonly publishedAt: Date;
207
+ readonly updatedAt: Date;
208
+ readonly retrievedAt: Date;
209
+ readonly url: string;
210
+ readonly tags: readonly ({
211
+ readonly type: "CATEGORY";
212
+ readonly value: string;
213
+ } | {
214
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
215
+ readonly id: string;
216
+ })[];
217
+ readonly authors: readonly {
218
+ readonly name: string;
219
+ }[];
220
+ };
221
+ readonly status: "NEW" | "UPDATED";
222
+ readonly source: "INTERNAL";
223
+ };
224
+ }, import("@effect/schema/ParseResult").ParseError>;
225
+ fromBuffer: (msg: Buffer) => import("effect/Either").Either<{
226
+ readonly kind: "INTERNAL_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 authors: readonly {
246
+ readonly name: string;
247
+ }[];
248
+ };
249
+ readonly status: "NEW" | "UPDATED";
250
+ readonly source: "INTERNAL";
251
+ };
252
+ }, import("@effect/schema/ParseResult").ParseError>;
253
+ fromStringExn: (msg: string) => {
254
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
255
+ readonly payload: {
256
+ readonly article: {
257
+ readonly id: string;
258
+ readonly site: string;
259
+ readonly title: string;
260
+ readonly teaser: string;
261
+ readonly content: string;
262
+ readonly publishedAt: Date;
263
+ readonly updatedAt: Date;
264
+ readonly retrievedAt: Date;
265
+ readonly url: string;
266
+ readonly tags: readonly ({
267
+ readonly type: "CATEGORY";
268
+ readonly value: string;
269
+ } | {
270
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
271
+ readonly id: string;
272
+ })[];
273
+ readonly authors: readonly {
274
+ readonly name: string;
275
+ }[];
276
+ };
277
+ readonly status: "NEW" | "UPDATED";
278
+ readonly source: "INTERNAL";
279
+ };
280
+ };
281
+ fromBufferExn: (msg: Buffer) => {
282
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
283
+ readonly payload: {
284
+ readonly article: {
285
+ readonly id: string;
286
+ readonly site: string;
287
+ readonly title: string;
288
+ readonly teaser: string;
289
+ readonly content: string;
290
+ readonly publishedAt: Date;
291
+ readonly updatedAt: Date;
292
+ readonly retrievedAt: Date;
293
+ readonly url: string;
294
+ readonly tags: readonly ({
295
+ readonly type: "CATEGORY";
296
+ readonly value: string;
297
+ } | {
298
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
299
+ readonly id: string;
300
+ })[];
301
+ readonly authors: readonly {
302
+ readonly name: string;
303
+ }[];
304
+ };
305
+ readonly status: "NEW" | "UPDATED";
306
+ readonly source: "INTERNAL";
307
+ };
308
+ };
309
+ toString: (event: {
310
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
311
+ readonly payload: {
312
+ readonly article: {
313
+ readonly id: string;
314
+ readonly site: string;
315
+ readonly title: string;
316
+ readonly teaser: string;
317
+ readonly content: string;
318
+ readonly publishedAt: Date;
319
+ readonly updatedAt: Date;
320
+ readonly retrievedAt: Date;
321
+ readonly url: string;
322
+ readonly tags: readonly ({
323
+ readonly type: "CATEGORY";
324
+ readonly value: string;
325
+ } | {
326
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
327
+ readonly id: string;
328
+ })[];
329
+ readonly authors: readonly {
330
+ readonly name: string;
331
+ }[];
332
+ };
333
+ readonly status: "NEW" | "UPDATED";
334
+ readonly source: "INTERNAL";
335
+ };
336
+ }) => string;
337
+ toBuffer: (event: {
338
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
339
+ readonly payload: {
340
+ readonly article: {
341
+ readonly id: string;
342
+ readonly site: string;
343
+ readonly title: string;
344
+ readonly teaser: string;
345
+ readonly content: string;
346
+ readonly publishedAt: Date;
347
+ readonly updatedAt: Date;
348
+ readonly retrievedAt: Date;
349
+ readonly url: string;
350
+ readonly tags: readonly ({
351
+ readonly type: "CATEGORY";
352
+ readonly value: string;
353
+ } | {
354
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
355
+ readonly id: string;
356
+ })[];
357
+ readonly authors: readonly {
358
+ readonly name: string;
359
+ }[];
360
+ };
361
+ readonly status: "NEW" | "UPDATED";
362
+ readonly source: "INTERNAL";
363
+ };
364
+ }) => Buffer;
365
+ toStringExn: (event: {
366
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
367
+ readonly payload: {
368
+ readonly article: {
369
+ readonly id: string;
370
+ readonly site: string;
371
+ readonly title: string;
372
+ readonly teaser: string;
373
+ readonly content: string;
374
+ readonly publishedAt: Date;
375
+ readonly updatedAt: Date;
376
+ readonly retrievedAt: Date;
377
+ readonly url: string;
378
+ readonly tags: readonly ({
379
+ readonly type: "CATEGORY";
380
+ readonly value: string;
381
+ } | {
382
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
383
+ readonly id: string;
384
+ })[];
385
+ readonly authors: readonly {
386
+ readonly name: string;
387
+ }[];
388
+ };
389
+ readonly status: "NEW" | "UPDATED";
390
+ readonly source: "INTERNAL";
391
+ };
392
+ }) => string;
393
+ toBufferExn: (event: {
394
+ readonly kind: "INTERNAL_ARTICLE_EVENT";
395
+ readonly payload: {
396
+ readonly article: {
397
+ readonly id: string;
398
+ readonly site: string;
399
+ readonly title: string;
400
+ readonly teaser: string;
401
+ readonly content: string;
402
+ readonly publishedAt: Date;
403
+ readonly updatedAt: Date;
404
+ readonly retrievedAt: Date;
405
+ readonly url: string;
406
+ readonly tags: readonly ({
407
+ readonly type: "CATEGORY";
408
+ readonly value: string;
409
+ } | {
410
+ readonly type: "EXTERNAL_ARTICLE_REFERENCE";
411
+ readonly id: string;
412
+ })[];
413
+ readonly authors: readonly {
414
+ readonly name: string;
415
+ }[];
416
+ };
417
+ readonly status: "NEW" | "UPDATED";
418
+ readonly source: "INTERNAL";
419
+ };
420
+ }) => Buffer;
421
+ Schema: Schema.Struct<{
422
+ kind: Schema.Literal<["INTERNAL_ARTICLE_EVENT"]>;
423
+ payload: Schema.Struct<{
424
+ article: Schema.Struct<{
425
+ tags: Schema.Array$<Schema.Union<[Schema.Struct<{
426
+ type: Schema.Literal<["CATEGORY"]>;
427
+ value: typeof Schema.NonEmpty;
428
+ }>, Schema.Struct<{
429
+ type: Schema.Literal<["EXTERNAL_ARTICLE_REFERENCE"]>;
430
+ id: typeof Schema.UUID;
431
+ }>]>>;
432
+ id: typeof Schema.UUID;
433
+ title: typeof Schema.NonEmpty;
434
+ teaser: typeof Schema.NonEmpty;
435
+ content: typeof Schema.NonEmpty;
436
+ publishedAt: typeof Schema.Date;
437
+ updatedAt: typeof Schema.Date;
438
+ retrievedAt: typeof Schema.Date;
439
+ url: typeof Schema.NonEmpty;
440
+ site: typeof Schema.NonEmpty;
441
+ authors: Schema.Array$<Schema.Struct<{
442
+ name: typeof Schema.NonEmpty;
443
+ }>>;
444
+ }>;
445
+ status: Schema.Literal<["NEW", "UPDATED"]>;
446
+ source: Schema.Literal<["INTERNAL"]>;
447
+ }>;
448
+ }>;
449
+ };
450
+ export default _default;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InternalArticleEventSchema = void 0;
4
+ const schema_1 = require("@effect/schema");
5
+ const Article_1 = require("../types/Article");
6
+ const makeHelpers_1 = require("../utils/makeHelpers");
7
+ const TagSchema = schema_1.Schema.Union(Article_1.CategoryTagSchema, Article_1.ArticleReferenceSchema);
8
+ const ArticleSchema = schema_1.Schema.Struct(Object.assign(Object.assign({}, Article_1.ArticleSchema.fields), { tags: schema_1.Schema.Array(TagSchema) }));
9
+ exports.InternalArticleEventSchema = schema_1.Schema.Struct({
10
+ kind: schema_1.Schema.Literal("INTERNAL_ARTICLE_EVENT"),
11
+ payload: schema_1.Schema.Struct({
12
+ article: ArticleSchema,
13
+ status: schema_1.Schema.Literal("NEW", "UPDATED"),
14
+ source: schema_1.Schema.Literal("INTERNAL"),
15
+ }),
16
+ });
17
+ const helpers = (0, makeHelpers_1.makeHelpers)(exports.InternalArticleEventSchema);
18
+ exports.default = Object.assign({ Schema: exports.InternalArticleEventSchema }, helpers);
@@ -0,0 +1,59 @@
1
+ import { Schema } from '@effect/schema';
2
+ export declare const DateTimeSchema: typeof Schema.Date;
3
+ export declare const CategoryTagSchema: Schema.Struct<{
4
+ type: Schema.Literal<["CATEGORY"]>;
5
+ value: typeof Schema.NonEmpty;
6
+ }>;
7
+ export declare const ArticleReferenceSchema: Schema.Struct<{
8
+ type: Schema.Literal<["EXTERNAL_ARTICLE_REFERENCE"]>;
9
+ id: typeof Schema.UUID;
10
+ }>;
11
+ export declare const EntityTag: Schema.Struct<{
12
+ type: Schema.Literal<["ENTITY"]>;
13
+ entityType: Schema.Literal<["PERSON"]>;
14
+ value: typeof Schema.NonEmpty;
15
+ }>;
16
+ export declare const TagSchema: Schema.Union<[Schema.Struct<{
17
+ type: Schema.Literal<["CATEGORY"]>;
18
+ value: typeof Schema.NonEmpty;
19
+ }>, Schema.Struct<{
20
+ type: Schema.Literal<["EXTERNAL_ARTICLE_REFERENCE"]>;
21
+ id: typeof Schema.UUID;
22
+ }>, Schema.Struct<{
23
+ type: Schema.Literal<["ENTITY"]>;
24
+ entityType: Schema.Literal<["PERSON"]>;
25
+ value: typeof Schema.NonEmpty;
26
+ }>]>;
27
+ export declare const AuthorSchema: Schema.Struct<{
28
+ name: typeof Schema.NonEmpty;
29
+ }>;
30
+ export declare const ScoreItemsSchema: Schema.Array$<Schema.Struct<{
31
+ site: typeof Schema.String;
32
+ relevance: typeof Schema.Number;
33
+ potential: typeof Schema.Number;
34
+ }>>;
35
+ export declare const ArticleSchema: Schema.Struct<{
36
+ id: typeof Schema.UUID;
37
+ title: typeof Schema.NonEmpty;
38
+ teaser: typeof Schema.NonEmpty;
39
+ content: typeof Schema.NonEmpty;
40
+ publishedAt: typeof Schema.Date;
41
+ updatedAt: typeof Schema.Date;
42
+ retrievedAt: typeof Schema.Date;
43
+ url: typeof Schema.NonEmpty;
44
+ site: typeof Schema.NonEmpty;
45
+ tags: Schema.Array$<Schema.Union<[Schema.Struct<{
46
+ type: Schema.Literal<["CATEGORY"]>;
47
+ value: typeof Schema.NonEmpty;
48
+ }>, Schema.Struct<{
49
+ type: Schema.Literal<["EXTERNAL_ARTICLE_REFERENCE"]>;
50
+ id: typeof Schema.UUID;
51
+ }>, Schema.Struct<{
52
+ type: Schema.Literal<["ENTITY"]>;
53
+ entityType: Schema.Literal<["PERSON"]>;
54
+ value: typeof Schema.NonEmpty;
55
+ }>]>>;
56
+ authors: Schema.Array$<Schema.Struct<{
57
+ name: typeof Schema.NonEmpty;
58
+ }>>;
59
+ }>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArticleSchema = exports.ScoreItemsSchema = exports.AuthorSchema = exports.TagSchema = exports.EntityTag = exports.ArticleReferenceSchema = exports.CategoryTagSchema = exports.DateTimeSchema = void 0;
4
+ const schema_1 = require("@effect/schema");
5
+ exports.DateTimeSchema = schema_1.Schema.Date.annotations({
6
+ jsonSchema: { format: 'date-time' },
7
+ });
8
+ exports.CategoryTagSchema = schema_1.Schema.Struct({
9
+ type: schema_1.Schema.Literal('CATEGORY'),
10
+ value: schema_1.Schema.NonEmpty,
11
+ });
12
+ exports.ArticleReferenceSchema = schema_1.Schema.Struct({
13
+ type: schema_1.Schema.Literal('EXTERNAL_ARTICLE_REFERENCE'),
14
+ id: schema_1.Schema.UUID,
15
+ });
16
+ exports.EntityTag = schema_1.Schema.Struct({
17
+ type: schema_1.Schema.Literal('ENTITY'),
18
+ entityType: schema_1.Schema.Literal('PERSON'),
19
+ value: schema_1.Schema.NonEmpty,
20
+ });
21
+ exports.TagSchema = schema_1.Schema.Union(exports.CategoryTagSchema, exports.ArticleReferenceSchema, exports.EntityTag);
22
+ exports.AuthorSchema = schema_1.Schema.Struct({
23
+ name: schema_1.Schema.NonEmpty,
24
+ });
25
+ const ScoreSchema = schema_1.Schema.Struct({
26
+ site: schema_1.Schema.String,
27
+ relevance: schema_1.Schema.Number,
28
+ potential: schema_1.Schema.Number,
29
+ });
30
+ exports.ScoreItemsSchema = schema_1.Schema.Array(ScoreSchema);
31
+ exports.ArticleSchema = schema_1.Schema.Struct({
32
+ id: schema_1.Schema.UUID,
33
+ title: schema_1.Schema.NonEmpty,
34
+ teaser: schema_1.Schema.NonEmpty,
35
+ content: schema_1.Schema.NonEmpty,
36
+ publishedAt: exports.DateTimeSchema,
37
+ updatedAt: exports.DateTimeSchema,
38
+ retrievedAt: exports.DateTimeSchema,
39
+ url: schema_1.Schema.NonEmpty,
40
+ site: schema_1.Schema.NonEmpty,
41
+ tags: schema_1.Schema.Array(exports.TagSchema),
42
+ authors: schema_1.Schema.Array(exports.AuthorSchema),
43
+ });
@@ -0,0 +1,15 @@
1
+ import { Schema } from '@effect/schema';
2
+ export declare const makeHelpers: <A, I>(schema: Schema.Schema<A, I, never>) => {
3
+ decode: (u: unknown, overrideOptions?: import("@effect/schema/AST").ParseOptions) => import("effect/Either").Either<A, import("@effect/schema/ParseResult").ParseError>;
4
+ decodeExn: (u: unknown) => A;
5
+ encode: (a: A, overrideOptions?: import("@effect/schema/AST").ParseOptions) => import("effect/Either").Either<I, import("@effect/schema/ParseResult").ParseError>;
6
+ encodeExn: (event: typeof schema.Type) => I;
7
+ fromString: (msg: string) => import("effect/Either").Either<A, import("@effect/schema/ParseResult").ParseError>;
8
+ fromBuffer: (msg: Buffer) => import("effect/Either").Either<A, import("@effect/schema/ParseResult").ParseError>;
9
+ fromStringExn: (msg: string) => A;
10
+ fromBufferExn: (msg: Buffer) => A;
11
+ toString: (event: typeof schema.Type) => string;
12
+ toBuffer: (event: typeof schema.Type) => Buffer;
13
+ toStringExn: (event: typeof schema.Type) => string;
14
+ toBufferExn: (event: typeof schema.Type) => Buffer;
15
+ };
@@ -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;
package/package.json CHANGED
@@ -1,39 +1,20 @@
1
1
  {
2
2
  "name": "@productminds/article-events",
3
- "version": "0.0.9",
4
- "description": "",
5
- "exports": {
6
- ".": {
7
- "types": "./dist/index.d.ts",
8
- "default": "./dist/index.js"
9
- },
10
- "./ArticleEvent": {
11
- "types": "./dist/src/events/ArticleEvent.d.ts",
12
- "default": "./dist/src/events/ArticleEvent.js"
13
- },
14
- "./InternalArticleEvent": {
15
- "types": "./dist/src/events/InternalArticleEvent.d.ts",
16
- "default": "./dist/src/events/InternalArticleEvent.js"
17
- },
18
- "./ExternalArticleEvent": {
19
- "types": "./dist/src/events/ExternalArticleEvent.d.ts",
20
- "default": "./dist/src/events/ExternalArticleEvent.js"
21
- }
3
+ "version": "0.0.11",
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"
22
10
  },
11
+ "files": [
12
+ "lib"
13
+ ],
23
14
  "scripts": {
15
+ "cmd:generate_json_schema": "tsc && node ./lib/cmd/write-json-schema.js",
24
16
  "build": "tsc",
25
17
  "build:watch": "tsc --watch",
26
- "build_and_publish": "npm run build && npm publish",
27
- "test": "echo \"Error: no test specified\" && exit 1"
28
- },
29
- "keywords": [],
30
- "author": "mbirkegaard",
31
- "license": "ISC",
32
- "devDependencies": {
33
- "@types/node": "^20.14.11",
34
- "typescript": "^5.5.3"
35
- },
36
- "dependencies": {
37
- "@effect/schema": "^0.68.26"
18
+ "build_and_publish": "npm run build && lerna publish from-package"
38
19
  }
39
20
  }