@di-framework/pglite-component 0.0.0-stage → 6.0.9

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,350 @@
1
+ package root:component;
2
+
3
+ world root {
4
+ import wasi:io/poll@0.2.9;
5
+ import wasi:clocks/monotonic-clock@0.2.9;
6
+ import wasi:clocks/wall-clock@0.2.9;
7
+ import wasi:io/error@0.2.9;
8
+ import wasi:io/streams@0.2.9;
9
+ import wasi:cli/stdout@0.2.9;
10
+ import wasi:cli/stderr@0.2.9;
11
+ import wasi:cli/stdin@0.2.9;
12
+ import wasi:cli/environment@0.2.9;
13
+ import wasi:cli/exit@0.2.9;
14
+ import wasi:cli/terminal-input@0.2.9;
15
+ import wasi:cli/terminal-output@0.2.9;
16
+ import wasi:cli/terminal-stdin@0.2.9;
17
+ import wasi:cli/terminal-stdout@0.2.9;
18
+ import wasi:cli/terminal-stderr@0.2.9;
19
+ import wasi:filesystem/types@0.2.9;
20
+ import wasi:filesystem/preopens@0.2.9;
21
+ import wasi:random/random@0.2.3;
22
+
23
+ export di-framework:pglite/types@0.1.0;
24
+ export di-framework:pglite/database@0.1.0;
25
+ }
26
+ package wasi:io@0.2.9 {
27
+ interface poll {
28
+ resource pollable {
29
+ block: func();
30
+ }
31
+
32
+ poll: func(in: list<borrow<pollable>>) -> list<u32>;
33
+ }
34
+ interface error {
35
+ resource error;
36
+ }
37
+ interface streams {
38
+ use error.{error};
39
+ use poll.{pollable};
40
+
41
+ resource input-stream {
42
+ read: func(len: u64) -> result<list<u8>, stream-error>;
43
+ subscribe: func() -> pollable;
44
+ blocking-read: func(len: u64) -> result<list<u8>, stream-error>;
45
+ }
46
+
47
+ resource output-stream {
48
+ check-write: func() -> result<u64, stream-error>;
49
+ write: func(contents: list<u8>) -> result<_, stream-error>;
50
+ blocking-flush: func() -> result<_, stream-error>;
51
+ subscribe: func() -> pollable;
52
+ blocking-write-and-flush: func(contents: list<u8>) -> result<_, stream-error>;
53
+ }
54
+
55
+ variant stream-error {
56
+ last-operation-failed(error),
57
+ closed,
58
+ }
59
+ }
60
+ }
61
+
62
+
63
+ package wasi:clocks@0.2.9 {
64
+ interface monotonic-clock {
65
+ use wasi:io/poll@0.2.9.{pollable};
66
+
67
+ type duration = u64;
68
+
69
+ type instant = u64;
70
+
71
+ subscribe-duration: func(when: duration) -> pollable;
72
+
73
+ now: func() -> instant;
74
+
75
+ subscribe-instant: func(when: instant) -> pollable;
76
+ }
77
+ interface wall-clock {
78
+ record datetime {
79
+ seconds: u64,
80
+ nanoseconds: u32,
81
+ }
82
+
83
+ now: func() -> datetime;
84
+ }
85
+ }
86
+
87
+
88
+ package wasi:cli@0.2.9 {
89
+ interface stdout {
90
+ use wasi:io/streams@0.2.9.{output-stream};
91
+
92
+ get-stdout: func() -> output-stream;
93
+ }
94
+ interface stderr {
95
+ use wasi:io/streams@0.2.9.{output-stream};
96
+
97
+ get-stderr: func() -> output-stream;
98
+ }
99
+ interface stdin {
100
+ use wasi:io/streams@0.2.9.{input-stream};
101
+
102
+ get-stdin: func() -> input-stream;
103
+ }
104
+ interface environment {
105
+ get-environment: func() -> list<tuple<string, string>>;
106
+
107
+ get-arguments: func() -> list<string>;
108
+ }
109
+ interface exit {
110
+ exit: func(status: result);
111
+ }
112
+ interface terminal-input {
113
+ resource terminal-input;
114
+ }
115
+ interface terminal-output {
116
+ resource terminal-output;
117
+ }
118
+ interface terminal-stdin {
119
+ use terminal-input.{terminal-input};
120
+
121
+ get-terminal-stdin: func() -> option<terminal-input>;
122
+ }
123
+ interface terminal-stdout {
124
+ use terminal-output.{terminal-output};
125
+
126
+ get-terminal-stdout: func() -> option<terminal-output>;
127
+ }
128
+ interface terminal-stderr {
129
+ use terminal-output.{terminal-output};
130
+
131
+ get-terminal-stderr: func() -> option<terminal-output>;
132
+ }
133
+ }
134
+
135
+
136
+ package wasi:filesystem@0.2.9 {
137
+ interface types {
138
+ use wasi:io/streams@0.2.9.{input-stream, output-stream};
139
+ use wasi:clocks/wall-clock@0.2.9.{datetime};
140
+ use wasi:io/error@0.2.9.{error};
141
+
142
+ resource descriptor {
143
+ read-via-stream: func(offset: filesize) -> result<input-stream, error-code>;
144
+ write-via-stream: func(offset: filesize) -> result<output-stream, error-code>;
145
+ append-via-stream: func() -> result<output-stream, error-code>;
146
+ get-flags: func() -> result<descriptor-flags, error-code>;
147
+ read-directory: func() -> result<directory-entry-stream, error-code>;
148
+ sync: func() -> result<_, error-code>;
149
+ create-directory-at: func(path: string) -> result<_, error-code>;
150
+ stat: func() -> result<descriptor-stat, error-code>;
151
+ stat-at: func(path-flags: path-flags, path: string) -> result<descriptor-stat, error-code>;
152
+ open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, %flags: descriptor-flags) -> result<descriptor, error-code>;
153
+ rename-at: func(old-path: string, new-descriptor: borrow<descriptor>, new-path: string) -> result<_, error-code>;
154
+ metadata-hash: func() -> result<metadata-hash-value, error-code>;
155
+ metadata-hash-at: func(path-flags: path-flags, path: string) -> result<metadata-hash-value, error-code>;
156
+ advise: func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code>;
157
+ sync-data: func() -> result<_, error-code>;
158
+ get-type: func() -> result<descriptor-type, error-code>;
159
+ set-size: func(size: filesize) -> result<_, error-code>;
160
+ read: func(length: filesize, offset: filesize) -> result<tuple<list<u8>, bool>, error-code>;
161
+ write: func(buffer: list<u8>, offset: filesize) -> result<filesize, error-code>;
162
+ readlink-at: func(path: string) -> result<string, error-code>;
163
+ remove-directory-at: func(path: string) -> result<_, error-code>;
164
+ symlink-at: func(old-path: string, new-path: string) -> result<_, error-code>;
165
+ unlink-file-at: func(path: string) -> result<_, error-code>;
166
+ }
167
+
168
+ resource directory-entry-stream {
169
+ read-directory-entry: func() -> result<option<directory-entry>, error-code>;
170
+ }
171
+
172
+ type filesize = u64;
173
+
174
+ enum error-code {
175
+ access,
176
+ would-block,
177
+ already,
178
+ bad-descriptor,
179
+ busy,
180
+ deadlock,
181
+ quota,
182
+ exist,
183
+ file-too-large,
184
+ illegal-byte-sequence,
185
+ in-progress,
186
+ interrupted,
187
+ invalid,
188
+ io,
189
+ is-directory,
190
+ loop,
191
+ too-many-links,
192
+ message-size,
193
+ name-too-long,
194
+ no-device,
195
+ no-entry,
196
+ no-lock,
197
+ insufficient-memory,
198
+ insufficient-space,
199
+ not-directory,
200
+ not-empty,
201
+ not-recoverable,
202
+ unsupported,
203
+ no-tty,
204
+ no-such-device,
205
+ overflow,
206
+ not-permitted,
207
+ pipe,
208
+ read-only,
209
+ invalid-seek,
210
+ text-file-busy,
211
+ cross-device,
212
+ }
213
+
214
+ flags descriptor-flags {
215
+ read,
216
+ write,
217
+ file-integrity-sync,
218
+ data-integrity-sync,
219
+ requested-write-sync,
220
+ mutate-directory,
221
+ }
222
+
223
+ enum descriptor-type {
224
+ unknown,
225
+ block-device,
226
+ character-device,
227
+ directory,
228
+ fifo,
229
+ symbolic-link,
230
+ regular-file,
231
+ socket,
232
+ }
233
+
234
+ type link-count = u64;
235
+
236
+ record descriptor-stat {
237
+ %type: descriptor-type,
238
+ link-count: link-count,
239
+ size: filesize,
240
+ data-access-timestamp: option<datetime>,
241
+ data-modification-timestamp: option<datetime>,
242
+ status-change-timestamp: option<datetime>,
243
+ }
244
+
245
+ flags path-flags {
246
+ symlink-follow,
247
+ }
248
+
249
+ flags open-flags {
250
+ create,
251
+ directory,
252
+ exclusive,
253
+ truncate,
254
+ }
255
+
256
+ record metadata-hash-value {
257
+ lower: u64,
258
+ upper: u64,
259
+ }
260
+
261
+ record directory-entry {
262
+ %type: descriptor-type,
263
+ name: string,
264
+ }
265
+
266
+ enum advice {
267
+ normal,
268
+ sequential,
269
+ random,
270
+ will-need,
271
+ dont-need,
272
+ no-reuse,
273
+ }
274
+
275
+ filesystem-error-code: func(err: borrow<error>) -> option<error-code>;
276
+ }
277
+ interface preopens {
278
+ use types.{descriptor};
279
+
280
+ get-directories: func() -> list<tuple<descriptor, string>>;
281
+ }
282
+ }
283
+
284
+
285
+ package wasi:random@0.2.3 {
286
+ interface random {
287
+ get-random-bytes: func(len: u64) -> list<u8>;
288
+ }
289
+ }
290
+
291
+
292
+ package di-framework:pglite@0.1.0 {
293
+ interface types {
294
+ record pg-error {
295
+ code: string,
296
+ message: string,
297
+ }
298
+
299
+ variant error {
300
+ open-failed(string),
301
+ closed,
302
+ invalid-sql(string),
303
+ invalid-params(string),
304
+ execution-failed(pg-error),
305
+ value-conversion-failed(string),
306
+ connection-lost(string),
307
+ invalid-transaction-state(string),
308
+ other(string),
309
+ }
310
+
311
+ variant value {
312
+ null,
313
+ integer(s64),
314
+ real(f64),
315
+ text(string),
316
+ blob(list<u8>),
317
+ boolean(bool),
318
+ }
319
+
320
+ type row = list<tuple<string, value>>;
321
+
322
+ record open-options {
323
+ database: option<string>,
324
+ statement-timeout-ms: option<u32>,
325
+ }
326
+ }
327
+ interface database {
328
+ use types.{error, value, row, open-options};
329
+
330
+ resource connection {
331
+ exec: func(sql: string) -> result<_, error>;
332
+ run: func(sql: string, params: list<value>) -> result<u64, error>;
333
+ query: func(sql: string, params: list<value>) -> result<list<row>, error>;
334
+ first: func(sql: string, params: list<value>) -> result<option<row>, error>;
335
+ begin: func() -> result<_, error>;
336
+ commit: func() -> result<_, error>;
337
+ rollback: func() -> result<_, error>;
338
+ savepoint: func(name: string) -> result<_, error>;
339
+ release-savepoint: func(name: string) -> result<_, error>;
340
+ rollback-to-savepoint: func(name: string) -> result<_, error>;
341
+ in-transaction: func() -> bool;
342
+ rows-affected: func() -> u64;
343
+ close: func() -> result<_, error>;
344
+ }
345
+
346
+ open: func(path: string, options: option<open-options>) -> result<connection, error>;
347
+
348
+ server-version: func() -> result<string, error>;
349
+ }
350
+ }
package/package.json CHANGED
@@ -1,6 +1,28 @@
1
1
  {
2
2
  "name": "@di-framework/pglite-component",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "6.0.9",
4
+ "private": false,
5
+ "description": "Embedded PostgreSQL component with persistent WASI storage and no TCP.",
6
+ "license": "(MIT OR Apache-2.0)",
7
+ "author": "@di-framework Contributors",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/di-framework/platform",
11
+ "directory": "platform/pglite-component"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/di-framework/platform/issues"
15
+ },
16
+ "homepage": "https://github.com/di-framework/platform",
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "wit"
21
+ ],
22
+ "scripts": {
23
+ "build": "make build",
24
+ "test": "bun test",
25
+ "smoke": "make smoke",
26
+ "publish-asset": "make publish-asset"
27
+ }
28
+ }
@@ -0,0 +1,16 @@
1
+ package di-framework:pglite-engine@0.1.0;
2
+
3
+ /// Private in-memory bridge to the bundled PostgreSQL engine. Composed away
4
+ /// at build time; these functions are never host imports in the final artifact.
5
+ interface engine {
6
+ set-env: func(name: string, value: string) -> s32;
7
+ start: func(arguments: list<string>) -> s32;
8
+ initdb: func() -> s32;
9
+ backend: func();
10
+ write: func(payload: list<u8>) -> bool;
11
+ read: func() -> list<u8>;
12
+ step: func();
13
+ }
14
+ world embedded-engine {
15
+ export engine;
16
+ }
@@ -0,0 +1,159 @@
1
+ package wasi:cli@0.2.0;
2
+
3
+ interface environment {
4
+ /// Get the POSIX-style environment variables.
5
+ ///
6
+ /// Each environment variable is provided as a pair of string variable names
7
+ /// and string value.
8
+ ///
9
+ /// Morally, these are a value import, but until value imports are available
10
+ /// in the component model, this import function should return the same
11
+ /// values each time it is called.
12
+ get-environment: func() -> list<tuple<string, string>>;
13
+
14
+ /// Get the POSIX-style arguments to the program.
15
+ get-arguments: func() -> list<string>;
16
+
17
+ /// Return a path that programs should use as their initial current working
18
+ /// directory, interpreting `.` as shorthand for this.
19
+ initial-cwd: func() -> option<string>;
20
+ }
21
+
22
+ interface exit {
23
+ /// Exit the current instance and any linked instances.
24
+ exit: func(status: result);
25
+ }
26
+
27
+ interface run {
28
+ /// Run the program.
29
+ run: func() -> result;
30
+ }
31
+
32
+ interface stdin {
33
+ use wasi:io/streams@0.2.0.{input-stream};
34
+
35
+ get-stdin: func() -> input-stream;
36
+ }
37
+
38
+ interface stdout {
39
+ use wasi:io/streams@0.2.0.{output-stream};
40
+
41
+ get-stdout: func() -> output-stream;
42
+ }
43
+
44
+ interface stderr {
45
+ use wasi:io/streams@0.2.0.{output-stream};
46
+
47
+ get-stderr: func() -> output-stream;
48
+ }
49
+
50
+ /// Terminal input.
51
+ ///
52
+ /// In the future, this may include functions for disabling echoing,
53
+ /// disabling input buffering so that keyboard events are sent through
54
+ /// immediately, querying supported features, and so on.
55
+ interface terminal-input {
56
+ /// The input side of a terminal.
57
+ resource terminal-input;
58
+ }
59
+
60
+ /// Terminal output.
61
+ ///
62
+ /// In the future, this may include functions for querying the terminal
63
+ /// size, being notified of terminal size changes, querying supported
64
+ /// features, and so on.
65
+ interface terminal-output {
66
+ /// The output side of a terminal.
67
+ resource terminal-output;
68
+ }
69
+
70
+ /// An interface providing an optional `terminal-input` for stdin as a
71
+ /// link-time authority.
72
+ interface terminal-stdin {
73
+ use terminal-input.{terminal-input};
74
+
75
+ /// If stdin is connected to a terminal, return a `terminal-input` handle
76
+ /// allowing further interaction with it.
77
+ get-terminal-stdin: func() -> option<terminal-input>;
78
+ }
79
+
80
+ /// An interface providing an optional `terminal-output` for stdout as a
81
+ /// link-time authority.
82
+ interface terminal-stdout {
83
+ use terminal-output.{terminal-output};
84
+
85
+ /// If stdout is connected to a terminal, return a `terminal-output` handle
86
+ /// allowing further interaction with it.
87
+ get-terminal-stdout: func() -> option<terminal-output>;
88
+ }
89
+
90
+ /// An interface providing an optional `terminal-output` for stderr as a
91
+ /// link-time authority.
92
+ interface terminal-stderr {
93
+ use terminal-output.{terminal-output};
94
+
95
+ /// If stderr is connected to a terminal, return a `terminal-output` handle
96
+ /// allowing further interaction with it.
97
+ get-terminal-stderr: func() -> option<terminal-output>;
98
+ }
99
+
100
+ world imports {
101
+ import environment;
102
+ import exit;
103
+ import wasi:io/error@0.2.0;
104
+ import wasi:io/poll@0.2.0;
105
+ import wasi:io/streams@0.2.0;
106
+ import stdin;
107
+ import stdout;
108
+ import stderr;
109
+ import terminal-input;
110
+ import terminal-output;
111
+ import terminal-stdin;
112
+ import terminal-stdout;
113
+ import terminal-stderr;
114
+ import wasi:clocks/monotonic-clock@0.2.0;
115
+ import wasi:clocks/wall-clock@0.2.0;
116
+ import wasi:filesystem/types@0.2.0;
117
+ import wasi:filesystem/preopens@0.2.0;
118
+ import wasi:sockets/network@0.2.0;
119
+ import wasi:sockets/instance-network@0.2.0;
120
+ import wasi:sockets/udp@0.2.0;
121
+ import wasi:sockets/udp-create-socket@0.2.0;
122
+ import wasi:sockets/tcp@0.2.0;
123
+ import wasi:sockets/tcp-create-socket@0.2.0;
124
+ import wasi:sockets/ip-name-lookup@0.2.0;
125
+ import wasi:random/random@0.2.0;
126
+ import wasi:random/insecure@0.2.0;
127
+ import wasi:random/insecure-seed@0.2.0;
128
+ }
129
+ world command {
130
+ import environment;
131
+ import exit;
132
+ import wasi:io/error@0.2.0;
133
+ import wasi:io/poll@0.2.0;
134
+ import wasi:io/streams@0.2.0;
135
+ import stdin;
136
+ import stdout;
137
+ import stderr;
138
+ import terminal-input;
139
+ import terminal-output;
140
+ import terminal-stdin;
141
+ import terminal-stdout;
142
+ import terminal-stderr;
143
+ import wasi:clocks/monotonic-clock@0.2.0;
144
+ import wasi:clocks/wall-clock@0.2.0;
145
+ import wasi:filesystem/types@0.2.0;
146
+ import wasi:filesystem/preopens@0.2.0;
147
+ import wasi:sockets/network@0.2.0;
148
+ import wasi:sockets/instance-network@0.2.0;
149
+ import wasi:sockets/udp@0.2.0;
150
+ import wasi:sockets/udp-create-socket@0.2.0;
151
+ import wasi:sockets/tcp@0.2.0;
152
+ import wasi:sockets/tcp-create-socket@0.2.0;
153
+ import wasi:sockets/ip-name-lookup@0.2.0;
154
+ import wasi:random/random@0.2.0;
155
+ import wasi:random/insecure@0.2.0;
156
+ import wasi:random/insecure-seed@0.2.0;
157
+
158
+ export run;
159
+ }
@@ -0,0 +1,29 @@
1
+ package wasi:clocks@0.2.0;
2
+
3
+ interface monotonic-clock {
4
+ use wasi:io/poll@0.2.0.{pollable};
5
+
6
+ type instant = u64;
7
+
8
+ type duration = u64;
9
+
10
+ now: func() -> instant;
11
+
12
+ resolution: func() -> duration;
13
+
14
+ subscribe-instant: func(when: instant) -> pollable;
15
+
16
+ subscribe-duration: func(when: duration) -> pollable;
17
+ }
18
+
19
+ interface wall-clock {
20
+ record datetime {
21
+ seconds: u64,
22
+ nanoseconds: u32,
23
+ }
24
+
25
+ now: func() -> datetime;
26
+
27
+ resolution: func() -> datetime;
28
+ }
29
+