@atproto/tap 0.1.2 → 0.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.
package/dist/types.d.ts CHANGED
@@ -1,286 +1,135 @@
1
- import { z } from 'zod';
2
- export declare const recordEventDataSchema: z.ZodObject<{
3
- did: z.ZodString;
4
- rev: z.ZodString;
5
- collection: z.ZodString;
6
- rkey: z.ZodString;
7
- action: z.ZodEnum<["create", "update", "delete"]>;
8
- record: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
9
- cid: z.ZodOptional<z.ZodString>;
10
- live: z.ZodBoolean;
11
- }, "strip", z.ZodTypeAny, {
12
- did: string;
13
- rev: string;
14
- collection: string;
15
- rkey: string;
16
- action: "create" | "update" | "delete";
17
- live: boolean;
18
- record?: Record<string, unknown> | undefined;
19
- cid?: string | undefined;
20
- }, {
21
- did: string;
22
- rev: string;
23
- collection: string;
24
- rkey: string;
25
- action: "create" | "update" | "delete";
26
- live: boolean;
27
- record?: Record<string, unknown> | undefined;
28
- cid?: string | undefined;
1
+ import { LexMap, LexValue, l } from '@atproto/lex';
2
+ import { DidString, HandleString, NsidString } from '@atproto/syntax';
3
+ export declare const recordEventDataSchema: l.ObjectSchema<{
4
+ readonly did: l.StringSchema<{
5
+ readonly format: "did";
6
+ }>;
7
+ readonly rev: l.StringSchema<{}>;
8
+ readonly collection: l.StringSchema<{
9
+ readonly format: "nsid";
10
+ }>;
11
+ readonly rkey: l.StringSchema<{
12
+ readonly format: "record-key";
13
+ }>;
14
+ readonly action: l.EnumSchema<"create" | "update" | "delete">;
15
+ readonly record: l.OptionalSchema<l.UnknownObjectSchema>;
16
+ readonly cid: l.OptionalSchema<l.StringSchema<{
17
+ readonly format: "cid";
18
+ }>>;
19
+ readonly live: l.BooleanSchema;
29
20
  }>;
30
- export declare const identityEventDataSchema: z.ZodObject<{
31
- did: z.ZodString;
32
- handle: z.ZodString;
33
- is_active: z.ZodBoolean;
34
- status: z.ZodEnum<["active", "takendown", "suspended", "deactivated", "deleted"]>;
35
- }, "strip", z.ZodTypeAny, {
36
- did: string;
37
- status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
38
- handle: string;
39
- is_active: boolean;
40
- }, {
41
- did: string;
42
- status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
43
- handle: string;
44
- is_active: boolean;
21
+ export declare const identityEventDataSchema: l.ObjectSchema<{
22
+ readonly did: l.StringSchema<{
23
+ readonly format: "did";
24
+ }>;
25
+ readonly handle: l.StringSchema<{
26
+ readonly format: "handle";
27
+ }>;
28
+ readonly is_active: l.BooleanSchema;
29
+ readonly status: l.EnumSchema<"active" | "takendown" | "suspended" | "deactivated" | "deleted">;
45
30
  }>;
46
- export declare const recordEventSchema: z.ZodObject<{
47
- id: z.ZodNumber;
48
- type: z.ZodLiteral<"record">;
49
- record: z.ZodObject<{
50
- did: z.ZodString;
51
- rev: z.ZodString;
52
- collection: z.ZodString;
53
- rkey: z.ZodString;
54
- action: z.ZodEnum<["create", "update", "delete"]>;
55
- record: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
56
- cid: z.ZodOptional<z.ZodString>;
57
- live: z.ZodBoolean;
58
- }, "strip", z.ZodTypeAny, {
59
- did: string;
60
- rev: string;
61
- collection: string;
62
- rkey: string;
63
- action: "create" | "update" | "delete";
64
- live: boolean;
65
- record?: Record<string, unknown> | undefined;
66
- cid?: string | undefined;
67
- }, {
68
- did: string;
69
- rev: string;
70
- collection: string;
71
- rkey: string;
72
- action: "create" | "update" | "delete";
73
- live: boolean;
74
- record?: Record<string, unknown> | undefined;
75
- cid?: string | undefined;
31
+ export declare const recordEventSchema: l.ObjectSchema<{
32
+ readonly id: l.IntegerSchema;
33
+ readonly type: l.LiteralSchema<"record">;
34
+ readonly record: l.ObjectSchema<{
35
+ readonly did: l.StringSchema<{
36
+ readonly format: "did";
37
+ }>;
38
+ readonly rev: l.StringSchema<{}>;
39
+ readonly collection: l.StringSchema<{
40
+ readonly format: "nsid";
41
+ }>;
42
+ readonly rkey: l.StringSchema<{
43
+ readonly format: "record-key";
44
+ }>;
45
+ readonly action: l.EnumSchema<"create" | "update" | "delete">;
46
+ readonly record: l.OptionalSchema<l.UnknownObjectSchema>;
47
+ readonly cid: l.OptionalSchema<l.StringSchema<{
48
+ readonly format: "cid";
49
+ }>>;
50
+ readonly live: l.BooleanSchema;
76
51
  }>;
77
- }, "strip", z.ZodTypeAny, {
78
- type: "record";
79
- record: {
80
- did: string;
81
- rev: string;
82
- collection: string;
83
- rkey: string;
84
- action: "create" | "update" | "delete";
85
- live: boolean;
86
- record?: Record<string, unknown> | undefined;
87
- cid?: string | undefined;
88
- };
89
- id: number;
90
- }, {
91
- type: "record";
92
- record: {
93
- did: string;
94
- rev: string;
95
- collection: string;
96
- rkey: string;
97
- action: "create" | "update" | "delete";
98
- live: boolean;
99
- record?: Record<string, unknown> | undefined;
100
- cid?: string | undefined;
101
- };
102
- id: number;
103
52
  }>;
104
- export declare const identityEventSchema: z.ZodObject<{
105
- id: z.ZodNumber;
106
- type: z.ZodLiteral<"identity">;
107
- identity: z.ZodObject<{
108
- did: z.ZodString;
109
- handle: z.ZodString;
110
- is_active: z.ZodBoolean;
111
- status: z.ZodEnum<["active", "takendown", "suspended", "deactivated", "deleted"]>;
112
- }, "strip", z.ZodTypeAny, {
113
- did: string;
114
- status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
115
- handle: string;
116
- is_active: boolean;
117
- }, {
118
- did: string;
119
- status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
120
- handle: string;
121
- is_active: boolean;
53
+ export declare const identityEventSchema: l.ObjectSchema<{
54
+ readonly id: l.IntegerSchema;
55
+ readonly type: l.LiteralSchema<"identity">;
56
+ readonly identity: l.ObjectSchema<{
57
+ readonly did: l.StringSchema<{
58
+ readonly format: "did";
59
+ }>;
60
+ readonly handle: l.StringSchema<{
61
+ readonly format: "handle";
62
+ }>;
63
+ readonly is_active: l.BooleanSchema;
64
+ readonly status: l.EnumSchema<"active" | "takendown" | "suspended" | "deactivated" | "deleted">;
122
65
  }>;
123
- }, "strip", z.ZodTypeAny, {
124
- type: "identity";
125
- id: number;
126
- identity: {
127
- did: string;
128
- status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
129
- handle: string;
130
- is_active: boolean;
131
- };
132
- }, {
133
- type: "identity";
134
- id: number;
135
- identity: {
136
- did: string;
137
- status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
138
- handle: string;
139
- is_active: boolean;
140
- };
141
66
  }>;
142
- export declare const tapEventSchema: z.ZodUnion<[z.ZodObject<{
143
- id: z.ZodNumber;
144
- type: z.ZodLiteral<"record">;
145
- record: z.ZodObject<{
146
- did: z.ZodString;
147
- rev: z.ZodString;
148
- collection: z.ZodString;
149
- rkey: z.ZodString;
150
- action: z.ZodEnum<["create", "update", "delete"]>;
151
- record: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
152
- cid: z.ZodOptional<z.ZodString>;
153
- live: z.ZodBoolean;
154
- }, "strip", z.ZodTypeAny, {
155
- did: string;
156
- rev: string;
157
- collection: string;
158
- rkey: string;
159
- action: "create" | "update" | "delete";
160
- live: boolean;
161
- record?: Record<string, unknown> | undefined;
162
- cid?: string | undefined;
163
- }, {
164
- did: string;
165
- rev: string;
166
- collection: string;
167
- rkey: string;
168
- action: "create" | "update" | "delete";
169
- live: boolean;
170
- record?: Record<string, unknown> | undefined;
171
- cid?: string | undefined;
67
+ export declare const tapEventSchema: l.DiscriminatedUnionSchema<"type", readonly [l.ObjectSchema<{
68
+ readonly id: l.IntegerSchema;
69
+ readonly type: l.LiteralSchema<"record">;
70
+ readonly record: l.ObjectSchema<{
71
+ readonly did: l.StringSchema<{
72
+ readonly format: "did";
73
+ }>;
74
+ readonly rev: l.StringSchema<{}>;
75
+ readonly collection: l.StringSchema<{
76
+ readonly format: "nsid";
77
+ }>;
78
+ readonly rkey: l.StringSchema<{
79
+ readonly format: "record-key";
80
+ }>;
81
+ readonly action: l.EnumSchema<"create" | "update" | "delete">;
82
+ readonly record: l.OptionalSchema<l.UnknownObjectSchema>;
83
+ readonly cid: l.OptionalSchema<l.StringSchema<{
84
+ readonly format: "cid";
85
+ }>>;
86
+ readonly live: l.BooleanSchema;
172
87
  }>;
173
- }, "strip", z.ZodTypeAny, {
174
- type: "record";
175
- record: {
176
- did: string;
177
- rev: string;
178
- collection: string;
179
- rkey: string;
180
- action: "create" | "update" | "delete";
181
- live: boolean;
182
- record?: Record<string, unknown> | undefined;
183
- cid?: string | undefined;
184
- };
185
- id: number;
186
- }, {
187
- type: "record";
188
- record: {
189
- did: string;
190
- rev: string;
191
- collection: string;
192
- rkey: string;
193
- action: "create" | "update" | "delete";
194
- live: boolean;
195
- record?: Record<string, unknown> | undefined;
196
- cid?: string | undefined;
197
- };
198
- id: number;
199
- }>, z.ZodObject<{
200
- id: z.ZodNumber;
201
- type: z.ZodLiteral<"identity">;
202
- identity: z.ZodObject<{
203
- did: z.ZodString;
204
- handle: z.ZodString;
205
- is_active: z.ZodBoolean;
206
- status: z.ZodEnum<["active", "takendown", "suspended", "deactivated", "deleted"]>;
207
- }, "strip", z.ZodTypeAny, {
208
- did: string;
209
- status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
210
- handle: string;
211
- is_active: boolean;
212
- }, {
213
- did: string;
214
- status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
215
- handle: string;
216
- is_active: boolean;
88
+ }>, l.ObjectSchema<{
89
+ readonly id: l.IntegerSchema;
90
+ readonly type: l.LiteralSchema<"identity">;
91
+ readonly identity: l.ObjectSchema<{
92
+ readonly did: l.StringSchema<{
93
+ readonly format: "did";
94
+ }>;
95
+ readonly handle: l.StringSchema<{
96
+ readonly format: "handle";
97
+ }>;
98
+ readonly is_active: l.BooleanSchema;
99
+ readonly status: l.EnumSchema<"active" | "takendown" | "suspended" | "deactivated" | "deleted">;
217
100
  }>;
218
- }, "strip", z.ZodTypeAny, {
219
- type: "identity";
220
- id: number;
221
- identity: {
222
- did: string;
223
- status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
224
- handle: string;
225
- is_active: boolean;
226
- };
227
- }, {
228
- type: "identity";
229
- id: number;
230
- identity: {
231
- did: string;
232
- status: "active" | "takendown" | "suspended" | "deactivated" | "deleted";
233
- handle: string;
234
- is_active: boolean;
235
- };
236
101
  }>]>;
237
102
  export type RecordEvent = {
238
103
  id: number;
239
104
  type: 'record';
240
105
  action: 'create' | 'update' | 'delete';
241
- did: string;
106
+ did: DidString;
242
107
  rev: string;
243
- collection: string;
108
+ collection: NsidString;
244
109
  rkey: string;
245
- record?: Record<string, unknown>;
110
+ record?: LexMap;
246
111
  cid?: string;
247
112
  live: boolean;
248
113
  };
249
114
  export type IdentityEvent = {
250
115
  id: number;
251
116
  type: 'identity';
252
- did: string;
253
- handle: string;
117
+ did: DidString;
118
+ handle: HandleString;
254
119
  isActive: boolean;
255
120
  status: RepoStatus;
256
121
  };
257
122
  export type RepoStatus = 'active' | 'takendown' | 'suspended' | 'deactivated' | 'deleted';
258
123
  export type TapEvent = IdentityEvent | RecordEvent;
259
- export declare const parseTapEvent: (data: unknown) => TapEvent;
260
- export declare const repoInfoSchema: z.ZodObject<{
261
- did: z.ZodString;
262
- handle: z.ZodString;
263
- state: z.ZodString;
264
- rev: z.ZodString;
265
- records: z.ZodNumber;
266
- error: z.ZodOptional<z.ZodString>;
267
- retries: z.ZodOptional<z.ZodNumber>;
268
- }, "strip", z.ZodTypeAny, {
269
- did: string;
270
- rev: string;
271
- handle: string;
272
- state: string;
273
- records: number;
274
- error?: string | undefined;
275
- retries?: number | undefined;
276
- }, {
277
- did: string;
278
- rev: string;
279
- handle: string;
280
- state: string;
281
- records: number;
282
- error?: string | undefined;
283
- retries?: number | undefined;
124
+ export declare const parseTapEvent: (data: LexValue) => TapEvent;
125
+ export declare const repoInfoSchema: l.ObjectSchema<{
126
+ readonly did: l.StringSchema<{}>;
127
+ readonly handle: l.StringSchema<{}>;
128
+ readonly state: l.StringSchema<{}>;
129
+ readonly rev: l.StringSchema<{}>;
130
+ readonly records: l.IntegerSchema;
131
+ readonly error: l.OptionalSchema<l.StringSchema<{}>>;
132
+ readonly retries: l.OptionalSchema<l.IntegerSchema>;
284
133
  }>;
285
- export type RepoInfo = z.infer<typeof repoInfoSchema>;
134
+ export type RepoInfo = l.Infer<typeof repoInfoSchema>;
286
135
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAShC,CAAA;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;EAWlC,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI5B,CAAA;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI9B,CAAA;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAoD,CAAA;AAE/E,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,QAAQ,CAAA;IACd,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;IACtC,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,GAAG,CAAC,EAA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d,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;IACtC,GAAG,EAAE,SAAS,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,UAAU,CAAA;IAChB,GAAG,EAAE,SAAS,CAAA;IACd,MAAM,EAAE,YAAY,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,UAAU,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,WAAW,GACX,WAAW,GACX,aAAa,GACb,SAAS,CAAA;AAEb,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,WAAW,CAAA;AAElD,eAAO,MAAM,aAAa,GAAI,MAAM,QAAQ,KAAG,QAyB9C,CAAA;AAED,eAAO,MAAM,cAAc;;;;;;;;EAQzB,CAAA;AAEF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA"}
package/dist/types.js CHANGED
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.repoInfoSchema = exports.parseTapEvent = exports.tapEventSchema = exports.identityEventSchema = exports.recordEventSchema = exports.identityEventDataSchema = exports.recordEventDataSchema = void 0;
4
- const zod_1 = require("zod");
5
- exports.recordEventDataSchema = zod_1.z.object({
6
- did: zod_1.z.string(),
7
- rev: zod_1.z.string(),
8
- collection: zod_1.z.string(),
9
- rkey: zod_1.z.string(),
10
- action: zod_1.z.enum(['create', 'update', 'delete']),
11
- record: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
12
- cid: zod_1.z.string().optional(),
13
- live: zod_1.z.boolean(),
4
+ const lex_1 = require("@atproto/lex");
5
+ exports.recordEventDataSchema = lex_1.l.object({
6
+ did: lex_1.l.string({ format: 'did' }),
7
+ rev: lex_1.l.string(),
8
+ collection: lex_1.l.string({ format: 'nsid' }),
9
+ rkey: lex_1.l.string({ format: 'record-key' }),
10
+ action: lex_1.l.enum(['create', 'update', 'delete']),
11
+ record: lex_1.l.optional(lex_1.l.unknownObject()),
12
+ cid: lex_1.l.optional(lex_1.l.string({ format: 'cid' })),
13
+ live: lex_1.l.boolean(),
14
14
  });
15
- exports.identityEventDataSchema = zod_1.z.object({
16
- did: zod_1.z.string(),
17
- handle: zod_1.z.string(),
18
- is_active: zod_1.z.boolean(),
19
- status: zod_1.z.enum([
15
+ exports.identityEventDataSchema = lex_1.l.object({
16
+ did: lex_1.l.string({ format: 'did' }),
17
+ handle: lex_1.l.string({ format: 'handle' }),
18
+ is_active: lex_1.l.boolean(),
19
+ status: lex_1.l.enum([
20
20
  'active',
21
21
  'takendown',
22
22
  'suspended',
@@ -24,17 +24,20 @@ exports.identityEventDataSchema = zod_1.z.object({
24
24
  'deleted',
25
25
  ]),
26
26
  });
27
- exports.recordEventSchema = zod_1.z.object({
28
- id: zod_1.z.number(),
29
- type: zod_1.z.literal('record'),
27
+ exports.recordEventSchema = lex_1.l.object({
28
+ id: lex_1.l.integer(),
29
+ type: lex_1.l.literal('record'),
30
30
  record: exports.recordEventDataSchema,
31
31
  });
32
- exports.identityEventSchema = zod_1.z.object({
33
- id: zod_1.z.number(),
34
- type: zod_1.z.literal('identity'),
32
+ exports.identityEventSchema = lex_1.l.object({
33
+ id: lex_1.l.integer(),
34
+ type: lex_1.l.literal('identity'),
35
35
  identity: exports.identityEventDataSchema,
36
36
  });
37
- exports.tapEventSchema = zod_1.z.union([exports.recordEventSchema, exports.identityEventSchema]);
37
+ exports.tapEventSchema = lex_1.l.discriminatedUnion('type', [
38
+ exports.recordEventSchema,
39
+ exports.identityEventSchema,
40
+ ]);
38
41
  const parseTapEvent = (data) => {
39
42
  const parsed = exports.tapEventSchema.parse(data);
40
43
  if (parsed.type === 'identity') {
@@ -63,13 +66,13 @@ const parseTapEvent = (data) => {
63
66
  }
64
67
  };
65
68
  exports.parseTapEvent = parseTapEvent;
66
- exports.repoInfoSchema = zod_1.z.object({
67
- did: zod_1.z.string(),
68
- handle: zod_1.z.string(),
69
- state: zod_1.z.string(),
70
- rev: zod_1.z.string(),
71
- records: zod_1.z.number(),
72
- error: zod_1.z.string().optional(),
73
- retries: zod_1.z.number().optional(),
69
+ exports.repoInfoSchema = lex_1.l.object({
70
+ did: lex_1.l.string(),
71
+ handle: lex_1.l.string(),
72
+ state: lex_1.l.string(),
73
+ rev: lex_1.l.string(),
74
+ records: lex_1.l.integer(),
75
+ error: lex_1.l.optional(lex_1.l.string()),
76
+ retries: lex_1.l.optional(lex_1.l.integer()),
74
77
  });
75
78
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAEV,QAAA,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;IACtB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC9C,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpD,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1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,CAAC,SAAS;YACnC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;SAC/B,CAAA;IACH,CAAC;SAAM,CAAC;QACN,OAAO;YACL,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;YAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;YACtB,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;YACtB,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;YACpC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;YACxB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;YAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;YACtB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;SACzB,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAzBY,QAAA,aAAa,iBAyBzB;AAEY,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;IACnB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAA","sourcesContent":["import { z } from 'zod'\n\nexport const recordEventDataSchema = z.object({\n did: z.string(),\n rev: z.string(),\n collection: z.string(),\n rkey: z.string(),\n action: z.enum(['create', 'update', 'delete']),\n record: z.record(z.string(), z.unknown()).optional(),\n cid: z.string().optional(),\n live: z.boolean(),\n})\n\nexport const identityEventDataSchema = z.object({\n did: z.string(),\n handle: z.string(),\n is_active: z.boolean(),\n status: z.enum([\n 'active',\n 'takendown',\n 'suspended',\n 'deactivated',\n 'deleted',\n ]),\n})\n\nexport const recordEventSchema = z.object({\n id: z.number(),\n type: z.literal('record'),\n record: recordEventDataSchema,\n})\n\nexport const identityEventSchema = z.object({\n id: z.number(),\n type: z.literal('identity'),\n identity: identityEventDataSchema,\n})\n\nexport const tapEventSchema = z.union([recordEventSchema, identityEventSchema])\n\nexport type RecordEvent = {\n id: number\n type: 'record'\n action: 'create' | 'update' | 'delete'\n did: string\n rev: string\n collection: string\n rkey: string\n record?: Record<string, unknown>\n cid?: string\n live: boolean\n}\n\nexport type IdentityEvent = {\n id: number\n type: 'identity'\n did: string\n handle: string\n isActive: boolean\n status: RepoStatus\n}\n\nexport type RepoStatus =\n | 'active'\n | 'takendown'\n | 'suspended'\n | 'deactivated'\n | 'deleted'\n\nexport type TapEvent = IdentityEvent | RecordEvent\n\nexport const parseTapEvent = (data: unknown): TapEvent => {\n const parsed = tapEventSchema.parse(data)\n if (parsed.type === 'identity') {\n return {\n id: parsed.id,\n type: parsed.type,\n did: parsed.identity.did,\n handle: parsed.identity.handle,\n isActive: parsed.identity.is_active,\n status: parsed.identity.status,\n }\n } else {\n return {\n id: parsed.id,\n type: parsed.type,\n action: parsed.record.action,\n did: parsed.record.did,\n rev: parsed.record.rev,\n collection: parsed.record.collection,\n rkey: parsed.record.rkey,\n record: parsed.record.record,\n cid: parsed.record.cid,\n live: parsed.record.live,\n }\n }\n}\n\nexport const repoInfoSchema = z.object({\n did: z.string(),\n handle: z.string(),\n state: z.string(),\n rev: z.string(),\n records: z.number(),\n error: z.string().optional(),\n retries: z.number().optional(),\n})\n\nexport type RepoInfo = z.infer<typeof repoInfoSchema>\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,sCAAkD;AAGrC,QAAA,qBAAqB,GAAG,OAAC,CAAC,MA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AA;IACH,CAAC;AACH,CAAC,CAAA;AAzBY,QAAA,aAAa,iBAyBzB;AAEY,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IACrC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;IAClB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE;IACpB,KAAK,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,OAAO,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC;CACjC,CAAC,CAAA","sourcesContent":["import { LexMap, LexValue, l } from '@atproto/lex'\nimport { DidString, HandleString, NsidString } from '@atproto/syntax'\n\nexport const recordEventDataSchema = l.object({\n did: l.string({ format: 'did' }),\n rev: l.string(),\n collection: l.string({ format: 'nsid' }),\n rkey: l.string({ format: 'record-key' }),\n action: l.enum(['create', 'update', 'delete']),\n record: l.optional(l.unknownObject()),\n cid: l.optional(l.string({ format: 'cid' })),\n live: l.boolean(),\n})\n\nexport const identityEventDataSchema = l.object({\n did: l.string({ format: 'did' }),\n handle: l.string({ format: 'handle' }),\n is_active: l.boolean(),\n status: l.enum([\n 'active',\n 'takendown',\n 'suspended',\n 'deactivated',\n 'deleted',\n ]),\n})\n\nexport const recordEventSchema = l.object({\n id: l.integer(),\n type: l.literal('record'),\n record: recordEventDataSchema,\n})\n\nexport const identityEventSchema = l.object({\n id: l.integer(),\n type: l.literal('identity'),\n identity: identityEventDataSchema,\n})\n\nexport const tapEventSchema = l.discriminatedUnion('type', [\n recordEventSchema,\n identityEventSchema,\n])\n\nexport type RecordEvent = {\n id: number\n type: 'record'\n action: 'create' | 'update' | 'delete'\n did: DidString\n rev: string\n collection: NsidString\n rkey: string\n record?: LexMap\n cid?: string\n live: boolean\n}\n\nexport type IdentityEvent = {\n id: number\n type: 'identity'\n did: DidString\n handle: HandleString\n isActive: boolean\n status: RepoStatus\n}\n\nexport type RepoStatus =\n | 'active'\n | 'takendown'\n | 'suspended'\n | 'deactivated'\n | 'deleted'\n\nexport type TapEvent = IdentityEvent | RecordEvent\n\nexport const parseTapEvent = (data: LexValue): TapEvent => {\n const parsed = tapEventSchema.parse(data)\n if (parsed.type === 'identity') {\n return {\n id: parsed.id,\n type: parsed.type,\n did: parsed.identity.did,\n handle: parsed.identity.handle,\n isActive: parsed.identity.is_active,\n status: parsed.identity.status,\n }\n } else {\n return {\n id: parsed.id,\n type: parsed.type,\n action: parsed.record.action,\n did: parsed.record.did,\n rev: parsed.record.rev,\n collection: parsed.record.collection,\n rkey: parsed.record.rkey,\n record: parsed.record.record,\n cid: parsed.record.cid,\n live: parsed.record.live,\n }\n }\n}\n\nexport const repoInfoSchema = l.object({\n did: l.string(),\n handle: l.string(),\n state: l.string(),\n rev: l.string(),\n records: l.integer(),\n error: l.optional(l.string()),\n retries: l.optional(l.integer()),\n})\n\nexport type RepoInfo = l.Infer<typeof repoInfoSchema>\n"]}
package/dist/util.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare const formatAdminAuthHeader: (password: string) => string;
2
2
  export declare const parseAdminAuthHeader: (header: string) => string;
3
3
  export declare const assureAdminAuth: (expectedPassword: string, header: string) => void;
4
+ export declare function isCausedBySignal(err: unknown, signal: AbortSignal): boolean;
4
5
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,WAErD,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,WASlD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,kBAAkB,MAAM,EAAE,QAAQ,MAAM,SAMvE,CAAA"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,WAErD,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,WASlD,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,kBAAkB,MAAM,EAAE,QAAQ,MAAM,SAMvE,CAAA;AAaD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,WAOjE"}
package/dist/util.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assureAdminAuth = exports.parseAdminAuthHeader = exports.formatAdminAuthHeader = void 0;
4
+ exports.isCausedBySignal = isCausedBySignal;
4
5
  const formatAdminAuthHeader = (password) => {
5
6
  return 'Basic ' + Buffer.from(`admin:${password}`).toString('base64');
6
7
  };
@@ -34,4 +35,12 @@ const timingSafeEqual = (a, b) => {
34
35
  }
35
36
  return bufA.compare(bufB) === 0;
36
37
  };
38
+ function isCausedBySignal(err, signal) {
39
+ if (!signal.aborted)
40
+ return false;
41
+ if (signal.reason == null)
42
+ return false; // Ignore nullish reasons
43
+ return (err === signal.reason ||
44
+ (err instanceof Error && err.cause === signal.reason));
45
+ }
37
46
  //# sourceMappingURL=util.js.map
package/dist/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAO,MAAM,qBAAqB,GAAG,CAAC,QAAgB,EAAE,EAAE;IACxD,OAAO,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AACvE,CAAC,CAAA;AAFY,QAAA,qBAAqB,yBAEjC;AAEM,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAE,EAAE;IACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,U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,CAAC,KAAK,CAAC,CAAA;AACjC,CAAC,CAAA","sourcesContent":["export const formatAdminAuthHeader = (password: string) => {\n return 'Basic ' + Buffer.from(`admin:${password}`).toString('base64')\n}\n\nexport const parseAdminAuthHeader = (header: string) => {\n const noPrefix = header.startsWith('Basic ') ? header.slice(6) : header\n const [username, password] = Buffer.from(noPrefix, 'base64')\n .toString()\n .split(':')\n if (username !== 'admin') {\n throw new Error(\"Unexpected username in admin headers. Expected 'admin'\")\n }\n return password\n}\n\nexport const assureAdminAuth = (expectedPassword: string, header: string) => {\n const headerPassword = parseAdminAuthHeader(header)\n const passEqual = timingSafeEqual(headerPassword, expectedPassword)\n if (!passEqual) {\n throw new Error('Invalid admin password')\n }\n}\n\nconst timingSafeEqual = (a: string, b: string): boolean => {\n const bufA = Buffer.from(a)\n const bufB = Buffer.from(b)\n if (bufA.length !== bufB.length) {\n // Compare against self to maintain constant time even with length mismatch\n Buffer.from(a).compare(Buffer.from(a))\n return false\n }\n return bufA.compare(bufB) === 0\n}\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAkCA,4CAOC;AAzCM,MAAM,qBAAqB,GAAG,CAAC,QAAgB,EAAE,EAAE;IACxD,OAAO,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AACvE,CAAC,CAAA;AAFY,QAAA,qBAAqB,yBAEjC;AAEM,MAAM,oBAAoB,GAAG,CAAC,MAAc,EAAE,EAAE;IACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;IACvE,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC;SACzD,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CAAC,yBAAyB;IACjE,OAAO,CACL,GAAG,KAAK,MAAM,CAAC,MAAM;QACrB,CAAC,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,CACtD,CAAA;AACH,CAAC","sourcesContent":["export const formatAdminAuthHeader = (password: string) => {\n return 'Basic ' + Buffer.from(`admin:${password}`).toString('base64')\n}\n\nexport const parseAdminAuthHeader = (header: string) => {\n const noPrefix = header.startsWith('Basic ') ? header.slice(6) : header\n const [username, password] = Buffer.from(noPrefix, 'base64')\n .toString()\n .split(':')\n if (username !== 'admin') {\n throw new Error(\"Unexpected username in admin headers. Expected 'admin'\")\n }\n return password\n}\n\nexport const assureAdminAuth = (expectedPassword: string, header: string) => {\n const headerPassword = parseAdminAuthHeader(header)\n const passEqual = timingSafeEqual(headerPassword, expectedPassword)\n if (!passEqual) {\n throw new Error('Invalid admin password')\n }\n}\n\nconst timingSafeEqual = (a: string, b: string): boolean => {\n const bufA = Buffer.from(a)\n const bufB = Buffer.from(b)\n if (bufA.length !== bufB.length) {\n // Compare against self to maintain constant time even with length mismatch\n Buffer.from(a).compare(Buffer.from(a))\n return false\n }\n return bufA.compare(bufB) === 0\n}\n\nexport function isCausedBySignal(err: unknown, signal: AbortSignal) {\n if (!signal.aborted) return false\n if (signal.reason == null) return false // Ignore nullish reasons\n return (\n err === signal.reason ||\n (err instanceof Error && err.cause === signal.reason)\n )\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/tap",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "description": "atproto tap client",
6
6
  "keywords": [
@@ -23,22 +23,21 @@
23
23
  "types": "dist/index.d.ts",
24
24
  "dependencies": {
25
25
  "ws": "^8.12.0",
26
- "zod": "^3.23.8",
27
- "@atproto/common": "^0.5.7",
28
- "@atproto/lex": "^0.0.10",
29
- "@atproto/syntax": "^0.4.2",
26
+ "@atproto/common": "^0.5.9",
27
+ "@atproto/lex": "^0.0.12",
28
+ "@atproto/syntax": "^0.4.3",
30
29
  "@atproto/ws-client": "^0.0.4"
31
30
  },
32
31
  "devDependencies": {
33
32
  "@types/express": "^4.17.17",
34
33
  "@types/ws": "^8.5.4",
35
34
  "express": "^4.18.2",
36
- "get-port": "^6.1.2",
37
- "jest": "^28.1.2",
38
- "typescript": "^5.6.3"
35
+ "typescript": "^5.6.3",
36
+ "@vitest/coverage-v8": "4.0.16",
37
+ "vitest": "^4.0.16"
39
38
  },
40
39
  "scripts": {
41
40
  "build": "tsc --build tsconfig.build.json",
42
- "test": "jest"
41
+ "test": "vitest run"
43
42
  }
44
43
  }