@atcute/tap 0.1.0 → 0.1.1
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/typedefs.d.ts +58 -10
- package/dist/typedefs.d.ts.map +1 -1
- package/dist/typedefs.js +56 -15
- package/dist/typedefs.js.map +1 -1
- package/dist/types.d.ts +20 -3
- package/dist/types.d.ts.map +1 -1
- package/lib/typedefs.ts +70 -16
- package/lib/types.ts +26 -3
- package/package.json +1 -1
package/dist/typedefs.d.ts
CHANGED
|
@@ -3,16 +3,32 @@ import type * as t from './types.js';
|
|
|
3
3
|
export declare const tapRecordEventWireSchema: v.ObjectType<{
|
|
4
4
|
id: v.Type<number>;
|
|
5
5
|
type: v.Type<"record">;
|
|
6
|
-
record: v.ObjectType<{
|
|
6
|
+
record: v.UnionType<[v.ObjectType<{
|
|
7
7
|
did: v.Type<`did:${string}:${string}`>;
|
|
8
8
|
rev: v.Type<string>;
|
|
9
9
|
collection: v.Type<`${string}.${string}.${string}`>;
|
|
10
10
|
rkey: v.Type<string>;
|
|
11
|
-
action: v.
|
|
11
|
+
action: v.Type<"create">;
|
|
12
|
+
cid: v.Type<string>;
|
|
12
13
|
record: v.Optional<Record<string, unknown>>;
|
|
13
|
-
cid: v.Optional<string>;
|
|
14
14
|
live: v.Type<boolean>;
|
|
15
|
-
}, undefined
|
|
15
|
+
}, undefined>, v.ObjectType<{
|
|
16
|
+
did: v.Type<`did:${string}:${string}`>;
|
|
17
|
+
rev: v.Type<string>;
|
|
18
|
+
collection: v.Type<`${string}.${string}.${string}`>;
|
|
19
|
+
rkey: v.Type<string>;
|
|
20
|
+
action: v.Type<"update">;
|
|
21
|
+
cid: v.Type<string>;
|
|
22
|
+
record: v.Optional<Record<string, unknown>>;
|
|
23
|
+
live: v.Type<boolean>;
|
|
24
|
+
}, undefined>, v.ObjectType<{
|
|
25
|
+
did: v.Type<`did:${string}:${string}`>;
|
|
26
|
+
rev: v.Type<string>;
|
|
27
|
+
collection: v.Type<`${string}.${string}.${string}`>;
|
|
28
|
+
rkey: v.Type<string>;
|
|
29
|
+
action: v.Type<"delete">;
|
|
30
|
+
live: v.Type<boolean>;
|
|
31
|
+
}, undefined>]>;
|
|
16
32
|
}, undefined>;
|
|
17
33
|
export declare const tapIdentityEventWireSchema: v.ObjectType<{
|
|
18
34
|
id: v.Type<number>;
|
|
@@ -27,16 +43,32 @@ export declare const tapIdentityEventWireSchema: v.ObjectType<{
|
|
|
27
43
|
export declare const tapEventWireSchema: v.UnionType<[v.ObjectType<{
|
|
28
44
|
id: v.Type<number>;
|
|
29
45
|
type: v.Type<"record">;
|
|
30
|
-
record: v.ObjectType<{
|
|
46
|
+
record: v.UnionType<[v.ObjectType<{
|
|
31
47
|
did: v.Type<`did:${string}:${string}`>;
|
|
32
48
|
rev: v.Type<string>;
|
|
33
49
|
collection: v.Type<`${string}.${string}.${string}`>;
|
|
34
50
|
rkey: v.Type<string>;
|
|
35
|
-
action: v.
|
|
51
|
+
action: v.Type<"create">;
|
|
52
|
+
cid: v.Type<string>;
|
|
36
53
|
record: v.Optional<Record<string, unknown>>;
|
|
37
|
-
cid: v.Optional<string>;
|
|
38
54
|
live: v.Type<boolean>;
|
|
39
|
-
}, undefined
|
|
55
|
+
}, undefined>, v.ObjectType<{
|
|
56
|
+
did: v.Type<`did:${string}:${string}`>;
|
|
57
|
+
rev: v.Type<string>;
|
|
58
|
+
collection: v.Type<`${string}.${string}.${string}`>;
|
|
59
|
+
rkey: v.Type<string>;
|
|
60
|
+
action: v.Type<"update">;
|
|
61
|
+
cid: v.Type<string>;
|
|
62
|
+
record: v.Optional<Record<string, unknown>>;
|
|
63
|
+
live: v.Type<boolean>;
|
|
64
|
+
}, undefined>, v.ObjectType<{
|
|
65
|
+
did: v.Type<`did:${string}:${string}`>;
|
|
66
|
+
rev: v.Type<string>;
|
|
67
|
+
collection: v.Type<`${string}.${string}.${string}`>;
|
|
68
|
+
rkey: v.Type<string>;
|
|
69
|
+
action: v.Type<"delete">;
|
|
70
|
+
live: v.Type<boolean>;
|
|
71
|
+
}, undefined>]>;
|
|
40
72
|
}, undefined>, v.ObjectType<{
|
|
41
73
|
id: v.Type<number>;
|
|
42
74
|
type: v.Type<"identity">;
|
|
@@ -56,9 +88,25 @@ export declare const flattenTapEvent: (wire: {
|
|
|
56
88
|
rev: string;
|
|
57
89
|
collection: `${string}.${string}.${string}`;
|
|
58
90
|
rkey: string;
|
|
59
|
-
action: "create"
|
|
91
|
+
action: "create";
|
|
92
|
+
cid: string;
|
|
60
93
|
record?: Record<string, unknown> | undefined;
|
|
61
|
-
|
|
94
|
+
live: boolean;
|
|
95
|
+
} | {
|
|
96
|
+
did: `did:${string}:${string}`;
|
|
97
|
+
rev: string;
|
|
98
|
+
collection: `${string}.${string}.${string}`;
|
|
99
|
+
rkey: string;
|
|
100
|
+
action: "update";
|
|
101
|
+
cid: string;
|
|
102
|
+
record?: Record<string, unknown> | undefined;
|
|
103
|
+
live: boolean;
|
|
104
|
+
} | {
|
|
105
|
+
did: `did:${string}:${string}`;
|
|
106
|
+
rev: string;
|
|
107
|
+
collection: `${string}.${string}.${string}`;
|
|
108
|
+
rkey: string;
|
|
109
|
+
action: "delete";
|
|
62
110
|
live: boolean;
|
|
63
111
|
};
|
|
64
112
|
} | {
|
package/dist/typedefs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAIpC,OAAO,KAAK,KAAK,CAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAIpC,OAAO,KAAK,KAAK,CAAC,MAAM,YAAY,CAAC;AA8DrC,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAInC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;aAIrC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAAgE,CAAC;AAEhG,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAQ5C,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAiE3B,CAAC"}
|
package/dist/typedefs.js
CHANGED
|
@@ -8,16 +8,35 @@ const tidString = v.string().assert(isTid, `must be a tid`);
|
|
|
8
8
|
const integer = v
|
|
9
9
|
.number()
|
|
10
10
|
.assert((input) => input >= 0 && Number.isSafeInteger(input), `must be a nonnegative integer`);
|
|
11
|
-
const
|
|
11
|
+
const recordEventCreateDataSchema = v.object({
|
|
12
12
|
did: didString,
|
|
13
13
|
rev: tidString,
|
|
14
14
|
collection: nsidString,
|
|
15
15
|
rkey: rkeyString,
|
|
16
|
-
action: v.
|
|
16
|
+
action: v.literal('create'),
|
|
17
|
+
cid: v.string(),
|
|
17
18
|
record: v.record(v.unknown()).optional(),
|
|
18
|
-
cid: v.string().optional(),
|
|
19
19
|
live: v.boolean(),
|
|
20
20
|
});
|
|
21
|
+
const recordEventUpdateDataSchema = v.object({
|
|
22
|
+
did: didString,
|
|
23
|
+
rev: tidString,
|
|
24
|
+
collection: nsidString,
|
|
25
|
+
rkey: rkeyString,
|
|
26
|
+
action: v.literal('update'),
|
|
27
|
+
cid: v.string(),
|
|
28
|
+
record: v.record(v.unknown()).optional(),
|
|
29
|
+
live: v.boolean(),
|
|
30
|
+
});
|
|
31
|
+
const recordEventDeleteDataSchema = v.object({
|
|
32
|
+
did: didString,
|
|
33
|
+
rev: tidString,
|
|
34
|
+
collection: nsidString,
|
|
35
|
+
rkey: rkeyString,
|
|
36
|
+
action: v.literal('delete'),
|
|
37
|
+
live: v.boolean(),
|
|
38
|
+
});
|
|
39
|
+
const recordEventDataSchema = v.union(recordEventCreateDataSchema, recordEventUpdateDataSchema, recordEventDeleteDataSchema);
|
|
21
40
|
const identityEventDataSchema = v.object({
|
|
22
41
|
did: didString,
|
|
23
42
|
handle: handleString,
|
|
@@ -57,18 +76,40 @@ export const flattenTapEvent = (wire) => {
|
|
|
57
76
|
};
|
|
58
77
|
}
|
|
59
78
|
case 'record': {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
79
|
+
switch (wire.record.action) {
|
|
80
|
+
case 'create':
|
|
81
|
+
case 'update': {
|
|
82
|
+
return {
|
|
83
|
+
id: wire.id,
|
|
84
|
+
type: 'record',
|
|
85
|
+
live: wire.record.live,
|
|
86
|
+
rev: wire.record.rev,
|
|
87
|
+
did: wire.record.did,
|
|
88
|
+
collection: wire.record.collection,
|
|
89
|
+
rkey: wire.record.rkey,
|
|
90
|
+
action: wire.record.action,
|
|
91
|
+
cid: wire.record.cid,
|
|
92
|
+
record: wire.record.record,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
case 'delete': {
|
|
96
|
+
return {
|
|
97
|
+
id: wire.id,
|
|
98
|
+
type: 'record',
|
|
99
|
+
live: wire.record.live,
|
|
100
|
+
rev: wire.record.rev,
|
|
101
|
+
did: wire.record.did,
|
|
102
|
+
collection: wire.record.collection,
|
|
103
|
+
rkey: wire.record.rkey,
|
|
104
|
+
action: 'delete',
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
default: {
|
|
108
|
+
wire.record;
|
|
109
|
+
const obj = wire.record;
|
|
110
|
+
throw new Error(`unknown "${obj.action}" action`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
72
113
|
}
|
|
73
114
|
default: {
|
|
74
115
|
wire;
|
package/dist/typedefs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typedefs.js","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAItF,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;AAC5D,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;AACrE,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAChE,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAC;AAC1E,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;AAE5D,MAAM,OAAO,GAAG,CAAC;KACf,MAAM,EAAE;KACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,+BAA+B,CAAC,CAAC;AAEhG,MAAM,
|
|
1
|
+
{"version":3,"file":"typedefs.js","sourceRoot":"","sources":["../lib/typedefs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAItF,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,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, Tid } from '@atcute/lexicons/syntax'
|
|
|
2
2
|
import type { CloseEvent, ErrorEvent, Options } from 'partysocket/ws';
|
|
3
3
|
export type TapRecordAction = 'create' | 'update' | 'delete';
|
|
4
4
|
export type TapRepoStatus = 'active' | 'takendown' | 'suspended' | 'deactivated' | 'deleted';
|
|
5
|
-
export interface
|
|
5
|
+
export interface TapRecordBaseEvent {
|
|
6
6
|
id: number;
|
|
7
7
|
type: 'record';
|
|
8
8
|
live: boolean;
|
|
@@ -10,10 +10,27 @@ export interface TapRecordEvent {
|
|
|
10
10
|
rev: Tid;
|
|
11
11
|
collection: Nsid;
|
|
12
12
|
rkey: RecordKey;
|
|
13
|
-
|
|
13
|
+
}
|
|
14
|
+
export interface TapRecordCreateEvent extends TapRecordBaseEvent {
|
|
15
|
+
action: 'create';
|
|
16
|
+
cid: string;
|
|
17
|
+
/**
|
|
18
|
+
* record may be omitted if tap fails to decode the record body but still has a cid.
|
|
19
|
+
*/
|
|
20
|
+
record?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export interface TapRecordUpdateEvent extends TapRecordBaseEvent {
|
|
23
|
+
action: 'update';
|
|
24
|
+
cid: string;
|
|
25
|
+
/**
|
|
26
|
+
* record may be omitted if tap fails to decode the record body but still has a cid.
|
|
27
|
+
*/
|
|
14
28
|
record?: Record<string, unknown>;
|
|
15
|
-
cid?: string;
|
|
16
29
|
}
|
|
30
|
+
export interface TapRecordDeleteEvent extends TapRecordBaseEvent {
|
|
31
|
+
action: 'delete';
|
|
32
|
+
}
|
|
33
|
+
export type TapRecordEvent = TapRecordCreateEvent | TapRecordUpdateEvent | TapRecordDeleteEvent;
|
|
17
34
|
export interface TapIdentityEvent {
|
|
18
35
|
id: number;
|
|
19
36
|
type: 'identity';
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA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AAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IAChD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAEnC,EAAE,CAAC,EAAE,OAAO,CAAC;CACb;AAED,MAAM,WAAW,sBAAsB;IACtC,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB"}
|
package/lib/typedefs.ts
CHANGED
|
@@ -14,17 +14,43 @@ const integer = v
|
|
|
14
14
|
.number()
|
|
15
15
|
.assert((input) => input >= 0 && Number.isSafeInteger(input), `must be a nonnegative integer`);
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const recordEventCreateDataSchema = v.object({
|
|
18
18
|
did: didString,
|
|
19
19
|
rev: tidString,
|
|
20
20
|
collection: nsidString,
|
|
21
21
|
rkey: rkeyString,
|
|
22
|
-
action: v.
|
|
22
|
+
action: v.literal('create'),
|
|
23
|
+
cid: v.string(),
|
|
23
24
|
record: v.record(v.unknown()).optional(),
|
|
24
|
-
cid: v.string().optional(),
|
|
25
25
|
live: v.boolean(),
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
const recordEventUpdateDataSchema = v.object({
|
|
29
|
+
did: didString,
|
|
30
|
+
rev: tidString,
|
|
31
|
+
collection: nsidString,
|
|
32
|
+
rkey: rkeyString,
|
|
33
|
+
action: v.literal('update'),
|
|
34
|
+
cid: v.string(),
|
|
35
|
+
record: v.record(v.unknown()).optional(),
|
|
36
|
+
live: v.boolean(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const recordEventDeleteDataSchema = v.object({
|
|
40
|
+
did: didString,
|
|
41
|
+
rev: tidString,
|
|
42
|
+
collection: nsidString,
|
|
43
|
+
rkey: rkeyString,
|
|
44
|
+
action: v.literal('delete'),
|
|
45
|
+
live: v.boolean(),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const recordEventDataSchema = v.union(
|
|
49
|
+
recordEventCreateDataSchema,
|
|
50
|
+
recordEventUpdateDataSchema,
|
|
51
|
+
recordEventDeleteDataSchema,
|
|
52
|
+
);
|
|
53
|
+
|
|
28
54
|
const identityEventDataSchema = v.object({
|
|
29
55
|
did: didString,
|
|
30
56
|
handle: handleString,
|
|
@@ -77,19 +103,47 @@ export const flattenTapEvent = (wire: v.Infer<typeof tapEventWireSchema>): t.Tap
|
|
|
77
103
|
}
|
|
78
104
|
|
|
79
105
|
case 'record': {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
106
|
+
switch (wire.record.action) {
|
|
107
|
+
case 'create':
|
|
108
|
+
case 'update': {
|
|
109
|
+
return {
|
|
110
|
+
id: wire.id,
|
|
111
|
+
type: 'record',
|
|
112
|
+
live: wire.record.live,
|
|
113
|
+
|
|
114
|
+
rev: wire.record.rev,
|
|
115
|
+
did: wire.record.did,
|
|
116
|
+
collection: wire.record.collection,
|
|
117
|
+
rkey: wire.record.rkey,
|
|
118
|
+
|
|
119
|
+
action: wire.record.action,
|
|
120
|
+
cid: wire.record.cid,
|
|
121
|
+
record: wire.record.record,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
case 'delete': {
|
|
126
|
+
return {
|
|
127
|
+
id: wire.id,
|
|
128
|
+
type: 'record',
|
|
129
|
+
live: wire.record.live,
|
|
130
|
+
|
|
131
|
+
rev: wire.record.rev,
|
|
132
|
+
did: wire.record.did,
|
|
133
|
+
collection: wire.record.collection,
|
|
134
|
+
rkey: wire.record.rkey,
|
|
135
|
+
|
|
136
|
+
action: 'delete',
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
default: {
|
|
141
|
+
wire.record satisfies never;
|
|
142
|
+
|
|
143
|
+
const obj = wire.record as any;
|
|
144
|
+
throw new Error(`unknown "${obj.action}" action`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
93
147
|
}
|
|
94
148
|
|
|
95
149
|
default: {
|
package/lib/types.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type TapRecordAction = 'create' | 'update' | 'delete';
|
|
|
5
5
|
|
|
6
6
|
export type TapRepoStatus = 'active' | 'takendown' | 'suspended' | 'deactivated' | 'deleted';
|
|
7
7
|
|
|
8
|
-
export interface
|
|
8
|
+
export interface TapRecordBaseEvent {
|
|
9
9
|
id: number;
|
|
10
10
|
type: 'record';
|
|
11
11
|
|
|
@@ -14,11 +14,34 @@ export interface TapRecordEvent {
|
|
|
14
14
|
rev: Tid;
|
|
15
15
|
collection: Nsid;
|
|
16
16
|
rkey: RecordKey;
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TapRecordCreateEvent extends TapRecordBaseEvent {
|
|
20
|
+
action: 'create';
|
|
21
|
+
cid: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* record may be omitted if tap fails to decode the record body but still has a cid.
|
|
25
|
+
*/
|
|
26
|
+
record?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface TapRecordUpdateEvent extends TapRecordBaseEvent {
|
|
30
|
+
action: 'update';
|
|
31
|
+
cid: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* record may be omitted if tap fails to decode the record body but still has a cid.
|
|
35
|
+
*/
|
|
18
36
|
record?: Record<string, unknown>;
|
|
19
|
-
cid?: string;
|
|
20
37
|
}
|
|
21
38
|
|
|
39
|
+
export interface TapRecordDeleteEvent extends TapRecordBaseEvent {
|
|
40
|
+
action: 'delete';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type TapRecordEvent = TapRecordCreateEvent | TapRecordUpdateEvent | TapRecordDeleteEvent;
|
|
44
|
+
|
|
22
45
|
export interface TapIdentityEvent {
|
|
23
46
|
id: number;
|
|
24
47
|
type: 'identity';
|