@vtxdeo/protocol 3.3.0 → 3.4.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/wit/vtx.wit +74 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtxdeo/protocol",
3
- "version": "3.3.0",
3
+ "version": "3.4.1",
4
4
  "description": "WIT interface definitions for VTX plugins",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/wit/vtx.wit CHANGED
@@ -8,23 +8,38 @@ interface sql {
8
8
  null-val,
9
9
  }
10
10
 
11
- execute: func(statement: string, params: list<db-value>) -> result<u64, string>;
12
-
13
- query-json: func(statement: string, params: list<db-value>) -> result<string, string>;
11
+ execute: func(
12
+ statement: string,
13
+ params: list<db-value>,
14
+ ) -> result<u64, string>;
15
+
16
+ query-json: func(
17
+ statement: string,
18
+ params: list<db-value>,
19
+ ) -> result<string, string>;
14
20
  }
15
21
 
16
22
  interface stream-io {
17
23
  resource buffer {
18
24
  size: func() -> u64;
19
25
 
20
- read: func(offset: u64, max-bytes: u64) -> list<u8>;
26
+ read: func(
27
+ offset: u64,
28
+ max-bytes: u64,
29
+ ) -> list<u8>;
21
30
 
22
- write: func(data: list<u8>) -> u64;
31
+ write: func(
32
+ data: list<u8>,
33
+ ) -> u64;
23
34
  }
24
35
 
25
- open-file: func(uuid: string) -> result<buffer, string>;
36
+ open-file: func(
37
+ uuid: string,
38
+ ) -> result<buffer, string>;
26
39
 
27
- create-memory-buffer: func(data: list<u8>) -> buffer;
40
+ create-memory-buffer: func(
41
+ data: list<u8>,
42
+ ) -> buffer;
28
43
  }
29
44
 
30
45
  interface auth-types {
@@ -34,6 +49,12 @@ interface auth-types {
34
49
  groups: list<string>,
35
50
  metadata: string,
36
51
  }
52
+
53
+ record current-user {
54
+ user-id: string,
55
+ username: string,
56
+ groups: list<string>,
57
+ }
37
58
  }
38
59
 
39
60
  interface types {
@@ -69,18 +90,59 @@ interface ffmpeg {
69
90
  args: list<string>,
70
91
  }
71
92
 
72
- execute: func(params: transcode-params) -> result<buffer, string>;
93
+ execute: func(
94
+ params: transcode-params,
95
+ ) -> result<buffer, string>;
96
+ }
97
+
98
+ interface events {
99
+ record event-context {
100
+ user-id: option<string>,
101
+ username: option<string>,
102
+ request-id: option<string>,
103
+ }
104
+
105
+ record vtx-event {
106
+ id: string,
107
+ topic: string,
108
+ source: string,
109
+ payload: string,
110
+ context: event-context,
111
+ occurred-at: u64,
112
+ }
113
+ }
114
+
115
+ interface context {
116
+ use auth-types.{current-user};
117
+
118
+ get-current-user: func() -> option<current-user>;
119
+ }
120
+
121
+ interface event-bus {
122
+ publish-event: func(
123
+ topic: string,
124
+ payload: string,
125
+ ) -> result<_, string>;
73
126
  }
74
127
 
75
128
  world plugin {
76
129
  use types.{http-request, http-response, manifest};
77
130
  use auth-types.{user-context};
131
+ use events.{vtx-event};
78
132
 
79
133
  import stream-io;
80
134
  import sql;
81
135
  import ffmpeg;
136
+ import context;
137
+ import event-bus;
138
+
139
+ export handle: func(
140
+ req: http-request,
141
+ ) -> http-response;
82
142
 
83
- export handle: func(req: http-request) -> http-response;
143
+ export handle-event: func(
144
+ event: vtx-event,
145
+ ) -> result<_, string>;
84
146
 
85
147
  export get-migrations: func() -> list<string>;
86
148
 
@@ -88,5 +150,7 @@ world plugin {
88
150
 
89
151
  export get-resources: func() -> list<string>;
90
152
 
91
- export authenticate: func(headers: list<tuple<string, string>>) -> result<user-context, u16>;
153
+ export authenticate: func(
154
+ headers: list<tuple<string, string>>,
155
+ ) -> result<user-context, u16>;
92
156
  }