@di-framework/cli-plugin-platform 0.0.1 → 6.0.2
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/README.md +408 -0
- package/dist/actor-protocol.d.ts +4 -0
- package/dist/actor-protocol.js +162 -0
- package/dist/actors.d.ts +31 -0
- package/dist/actors.js +296 -0
- package/dist/args.d.ts +15 -0
- package/dist/args.js +66 -0
- package/dist/assets/http-adapter.js +876 -0
- package/dist/assets/platform/.gitignore.tmpl +6 -0
- package/dist/assets/platform/Pulumi.yaml.tmpl +6 -0
- package/dist/assets/platform/README.md +208 -0
- package/dist/assets/platform/index.ts.tmpl +2 -0
- package/dist/assets/platform/package.json.tmpl +18 -0
- package/dist/assets/platform/tsconfig.json +11 -0
- package/dist/assets/queue-adapter.js +60 -0
- package/dist/assets/sqlite/BUILD-INFO.txt +13 -0
- package/dist/assets/sqlite/SHA256SUMS +2 -0
- package/dist/assets/sqlite/di-framework-sqlite.wasm +0 -0
- package/dist/assets/sqlite/di-framework-sqlite.wit +337 -0
- package/dist/assets/wit/deps/LICENSE.md +8 -0
- package/dist/assets/wit/deps/di-framework-queues/package.wit +18 -0
- package/dist/assets/wit/deps/di-framework-sqlite/package.wit +211 -0
- package/dist/assets/wit/deps/wasi-cli/package.wit +70 -0
- package/dist/assets/wit/deps/wasi-clocks/package.wit +42 -0
- package/dist/assets/wit/deps/wasi-config/package.wit +15 -0
- package/dist/assets/wit/deps/wasi-filesystem/package.wit +184 -0
- package/dist/assets/wit/deps/wasi-http/package.wit +170 -0
- package/dist/assets/wit/deps/wasi-random/package.wit +17 -0
- package/dist/assets/wit/deps/wasi-sockets/package.wit +105 -0
- package/dist/assets/wit/deps/wasi-tls/package.wit +26 -0
- package/dist/assets/wit/deps/wasmcloud-blobstore/package.wit +153 -0
- package/dist/assets/wit/deps/wasmcloud-keyvalue/package.wit +370 -0
- package/dist/assets/wit/deps/wasmcloud-messaging/package.wit +125 -0
- package/dist/assets/wit/deps/wasmcloud-postgres/package.wit +435 -0
- package/dist/assets/wit/deps/wasmcloud-secrets/package.wit +80 -0
- package/dist/async-transform.d.ts +3 -0
- package/dist/async-transform.js +60 -0
- package/dist/bindings.d.ts +34 -0
- package/dist/bindings.js +307 -0
- package/dist/build.d.ts +29 -0
- package/dist/build.js +325 -0
- package/dist/command.d.ts +3 -0
- package/dist/command.js +141 -0
- package/dist/control/auth.d.ts +18 -0
- package/dist/control/auth.js +89 -0
- package/dist/control/cron.d.ts +7 -0
- package/dist/control/cron.js +86 -0
- package/dist/control/index.d.ts +4 -0
- package/dist/control/index.js +4 -0
- package/dist/control/network.d.ts +12 -0
- package/dist/control/network.js +49 -0
- package/dist/control/queues.d.ts +15 -0
- package/dist/control/queues.js +77 -0
- package/dist/cron.d.ts +26 -0
- package/dist/cron.js +239 -0
- package/dist/deploy.d.ts +29 -0
- package/dist/deploy.js +57 -0
- package/dist/deps.d.ts +96 -0
- package/dist/deps.js +303 -0
- package/dist/destroy.d.ts +3 -0
- package/dist/destroy.js +24 -0
- package/dist/dev-runner.d.ts +24 -0
- package/dist/dev-runner.js +83 -0
- package/dist/dev.d.ts +8 -0
- package/dist/dev.js +76 -0
- package/dist/discovery.d.ts +15 -0
- package/dist/discovery.js +182 -0
- package/dist/doctor.d.ts +8 -0
- package/dist/doctor.js +82 -0
- package/dist/guests.d.ts +9 -0
- package/dist/guests.js +56 -0
- package/dist/host-interface.d.ts +29 -0
- package/dist/host-interface.js +142 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +39 -0
- package/dist/kubernetes.d.ts +9 -0
- package/dist/kubernetes.js +17 -0
- package/dist/managed-bindings.d.ts +9 -0
- package/dist/managed-bindings.js +150 -0
- package/dist/manifest.d.ts +36 -0
- package/dist/manifest.js +257 -0
- package/dist/namespace.d.ts +2 -0
- package/dist/namespace.js +4 -0
- package/dist/node-compat/async-hooks.d.ts +29 -0
- package/dist/node-compat/async-hooks.js +80 -0
- package/dist/node-compat/bootstrap.d.ts +1 -0
- package/dist/node-compat/bootstrap.js +9 -0
- package/dist/node-compat/bytes.d.ts +7 -0
- package/dist/node-compat/bytes.js +41 -0
- package/dist/node-compat/crypto-hash.d.ts +27 -0
- package/dist/node-compat/crypto-hash.js +108 -0
- package/dist/node-compat/crypto-subtle.d.ts +59 -0
- package/dist/node-compat/crypto-subtle.js +288 -0
- package/dist/node-compat/crypto.d.ts +136 -0
- package/dist/node-compat/crypto.js +142 -0
- package/dist/node-compat/dgram.d.ts +49 -0
- package/dist/node-compat/dgram.js +197 -0
- package/dist/node-compat/env.d.ts +6 -0
- package/dist/node-compat/env.js +88 -0
- package/dist/node-compat/fetch-runtime.d.ts +80 -0
- package/dist/node-compat/fetch-runtime.js +314 -0
- package/dist/node-compat/fs.d.ts +84 -0
- package/dist/node-compat/fs.js +285 -0
- package/dist/node-compat/http-parser.d.ts +40 -0
- package/dist/node-compat/http-parser.js +185 -0
- package/dist/node-compat/http.d.ts +130 -0
- package/dist/node-compat/http.js +688 -0
- package/dist/node-compat/https.d.ts +28 -0
- package/dist/node-compat/https.js +88 -0
- package/dist/node-compat/module.d.ts +11 -0
- package/dist/node-compat/module.js +35 -0
- package/dist/node-compat/net.d.ts +119 -0
- package/dist/node-compat/net.js +441 -0
- package/dist/node-compat/process.d.ts +25 -0
- package/dist/node-compat/process.js +63 -0
- package/dist/node-compat/runtime-application.d.ts +4 -0
- package/dist/node-compat/runtime-application.js +24 -0
- package/dist/node-compat/seed-virtual.d.ts +6 -0
- package/dist/node-compat/seed-virtual.js +6 -0
- package/dist/node-compat/seed.d.ts +20 -0
- package/dist/node-compat/seed.js +106 -0
- package/dist/node-compat/socket-address.d.ts +35 -0
- package/dist/node-compat/socket-address.js +162 -0
- package/dist/node-compat/timers.d.ts +32 -0
- package/dist/node-compat/timers.js +96 -0
- package/dist/node-compat/tls.d.ts +57 -0
- package/dist/node-compat/tls.js +290 -0
- package/dist/node-compat/wasi-random.d.ts +2 -0
- package/dist/node-compat/wasi-random.js +25 -0
- package/dist/node-compat/wasi-sockets.d.ts +47 -0
- package/dist/node-compat/wasi-sockets.js +134 -0
- package/dist/oci.d.ts +9 -0
- package/dist/oci.js +9 -0
- package/dist/paths.d.ts +7 -0
- package/dist/paths.js +13 -0
- package/dist/platform-init.d.ts +13 -0
- package/dist/platform-init.js +265 -0
- package/dist/platform.d.ts +22 -0
- package/dist/platform.js +170 -0
- package/dist/project.d.ts +39 -0
- package/dist/project.js +130 -0
- package/dist/publish.d.ts +15 -0
- package/dist/publish.js +57 -0
- package/dist/pulumi.d.ts +4 -0
- package/dist/pulumi.js +27 -0
- package/dist/queues-module.d.ts +4 -0
- package/dist/queues-module.js +89 -0
- package/dist/queues.d.ts +16 -0
- package/dist/queues.js +167 -0
- package/dist/registry.d.ts +16 -0
- package/dist/registry.js +27 -0
- package/dist/service.d.ts +162 -0
- package/dist/service.js +678 -0
- package/dist/support.d.ts +14 -0
- package/dist/support.js +37 -0
- package/dist/target.d.ts +18 -0
- package/dist/target.js +45 -0
- package/dist/toml.d.ts +6 -0
- package/dist/toml.js +245 -0
- package/dist/wash-dev.d.ts +18 -0
- package/dist/wash-dev.js +80 -0
- package/dist/wit.d.ts +76 -0
- package/dist/wit.js +248 -0
- package/dist/workload-members.d.ts +12 -0
- package/dist/workload-members.js +136 -0
- package/dist/workload.d.ts +45 -0
- package/dist/workload.js +457 -0
- package/package.json +55 -8
- package/src/index.ts +0 -2
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
package wasmcloud:postgres@0.2.0;
|
|
2
|
+
|
|
3
|
+
/// Types shared across the postgres interfaces.
|
|
4
|
+
///
|
|
5
|
+
/// The value model (`pg-value`) and the error model (`error`, `db-error`) live
|
|
6
|
+
/// here so that `query` and `prepared` `use` the *same* types. That matters for
|
|
7
|
+
/// the component-model `(implements ..)` mechanism: a host can route each
|
|
8
|
+
/// labeled `query`/`prepared` import to its own credentialed connection, and the
|
|
9
|
+
/// values and errors flowing through one label unify with the (unlabeled)
|
|
10
|
+
/// interfaces because they all reference this one `types` package.
|
|
11
|
+
interface types {
|
|
12
|
+
/// A structured error reported by the database itself.
|
|
13
|
+
///
|
|
14
|
+
/// The fields mirror what Postgres returns in an error response, so that a
|
|
15
|
+
/// guest can branch on machine-readable fields — notably `code`, the
|
|
16
|
+
/// five-character SQLSTATE — rather than parsing `message`. For example, a
|
|
17
|
+
/// unique-constraint violation is SQLSTATE `23505`.
|
|
18
|
+
record db-error {
|
|
19
|
+
/// The five-character SQLSTATE code, e.g. `23505` for a unique-constraint
|
|
20
|
+
/// violation. See the Postgres "Error Codes" appendix.
|
|
21
|
+
code: string,
|
|
22
|
+
/// The severity as reported by the database, e.g. `ERROR`, `FATAL`, or
|
|
23
|
+
/// `PANIC`.
|
|
24
|
+
severity: string,
|
|
25
|
+
/// The primary human-readable error message.
|
|
26
|
+
message: string,
|
|
27
|
+
/// An optional secondary message carrying more detail about the problem.
|
|
28
|
+
detail: option<string>,
|
|
29
|
+
/// Any additional fields the database provided that are not captured above,
|
|
30
|
+
/// as `(field-name, value)` pairs.
|
|
31
|
+
extras: list<tuple<string, string>>,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/// The set of errors which may be raised by functions in this package.
|
|
35
|
+
///
|
|
36
|
+
/// Following the wasip3 convention, this enumerates specific named cases
|
|
37
|
+
/// rather than leaning on stringly-typed errors. It is intentionally
|
|
38
|
+
/// non-exhaustive: future versions may add cases, and generated bindings are
|
|
39
|
+
/// marked non-exhaustive accordingly, so consumers must always include a
|
|
40
|
+
/// catch-all arm. Backend-specific failures that do not map to a named case
|
|
41
|
+
/// are reported via `other`.
|
|
42
|
+
variant error {
|
|
43
|
+
/// The host could not establish or maintain a connection to the database.
|
|
44
|
+
/// The operation may succeed if retried once the database is reachable.
|
|
45
|
+
connection-failed(string),
|
|
46
|
+
/// A query parameter was invalid: the wrong number of parameters, a value
|
|
47
|
+
/// whose type does not match the target column, or a value that could not
|
|
48
|
+
/// be encoded for the wire protocol.
|
|
49
|
+
invalid-params(string),
|
|
50
|
+
/// The SQL statement was rejected before it reached the database (e.g. by
|
|
51
|
+
/// host-side validation). Statements rejected by the database itself are
|
|
52
|
+
/// reported via `query-failed` instead.
|
|
53
|
+
invalid-query(string),
|
|
54
|
+
/// The database rejected or failed the statement. `db-error` carries the
|
|
55
|
+
/// structured detail (SQLSTATE `code`, `severity`, ...); branch on
|
|
56
|
+
/// `db-error.code` to distinguish conditions such as a unique-constraint
|
|
57
|
+
/// violation (`23505`).
|
|
58
|
+
query-failed(db-error),
|
|
59
|
+
/// A value returned by the database could not be converted into a
|
|
60
|
+
/// `pg-value` (e.g. an unsupported column type).
|
|
61
|
+
value-conversion-failed(string),
|
|
62
|
+
/// The prepared-statement token is not recognized: it was never prepared by
|
|
63
|
+
/// this component, or has since been evicted.
|
|
64
|
+
unknown-prepared-statement,
|
|
65
|
+
/// The requesting component is not permitted to reach the requested
|
|
66
|
+
/// database.
|
|
67
|
+
access-denied,
|
|
68
|
+
/// The operation did not complete within the host- or backend-imposed time
|
|
69
|
+
/// limit.
|
|
70
|
+
timeout,
|
|
71
|
+
/// Some other implementation-specific error has occurred (e.g. I/O). Used
|
|
72
|
+
/// for backend-specific failures that do not map to a named case above.
|
|
73
|
+
other(string),
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/// This type of floating point is necessary as rust does not allow Eq/PartialEq/Hash on real `f64`
|
|
77
|
+
/// Instead we use a sign + mantissa + exponent
|
|
78
|
+
///
|
|
79
|
+
/// see: https://docs.rs/num/latest/num/trait.Float.html#tymethod.integer_decode
|
|
80
|
+
type hashable-f64 = tuple<u64, s16, s8>;
|
|
81
|
+
|
|
82
|
+
type hashable-f32 = hashable-f64;
|
|
83
|
+
|
|
84
|
+
type point = tuple<hashable-f64, hashable-f64>;
|
|
85
|
+
|
|
86
|
+
type lower-left-point = point;
|
|
87
|
+
|
|
88
|
+
type upper-right-point = point;
|
|
89
|
+
|
|
90
|
+
type start-point = point;
|
|
91
|
+
|
|
92
|
+
type end-point = point;
|
|
93
|
+
|
|
94
|
+
type center-point = point;
|
|
95
|
+
|
|
96
|
+
type radius = hashable-f64;
|
|
97
|
+
|
|
98
|
+
type ipv4-addr = string;
|
|
99
|
+
|
|
100
|
+
type ipv6-addr = string;
|
|
101
|
+
|
|
102
|
+
type subnet = string;
|
|
103
|
+
|
|
104
|
+
type xmin = s64;
|
|
105
|
+
|
|
106
|
+
type xmax = s64;
|
|
107
|
+
|
|
108
|
+
type xip-list = list<s64>;
|
|
109
|
+
|
|
110
|
+
type logfile-num = u32;
|
|
111
|
+
|
|
112
|
+
type logfile-byte-offset = u32;
|
|
113
|
+
|
|
114
|
+
type column-name = string;
|
|
115
|
+
|
|
116
|
+
/// Arbitrary precision numeric type
|
|
117
|
+
type numeric = string;
|
|
118
|
+
|
|
119
|
+
/// Chosen weight of a Lexeme
|
|
120
|
+
enum lexeme-weight {
|
|
121
|
+
A,
|
|
122
|
+
B,
|
|
123
|
+
C,
|
|
124
|
+
D,
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// Represents an arbitrary precision numeric type
|
|
128
|
+
record lexeme {
|
|
129
|
+
/// Position (1->16383)
|
|
130
|
+
position: option<u16>,
|
|
131
|
+
/// Weight of the lexeme (in a relevant ts-vector)
|
|
132
|
+
weight: option<lexeme-weight>,
|
|
133
|
+
/// Data
|
|
134
|
+
data: string,
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/// Offsets are expressed in seconds of timezone difference in either from the
|
|
138
|
+
/// eastern hemisphere or western hemisphere.
|
|
139
|
+
///
|
|
140
|
+
/// ex. "America/New York", which is UTC-4 can be expressed as western-hemisphere-secs(4 * 3600)
|
|
141
|
+
variant offset {
|
|
142
|
+
eastern-hemisphere-secs(s32),
|
|
143
|
+
western-hemisphere-secs(s32),
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/// Dates are represented similarly to tokio-postgres implementation
|
|
147
|
+
/// see: https://docs.rs/postgres-types/0.2.6/postgres_types/enum.Date.html#variant.Value
|
|
148
|
+
variant date {
|
|
149
|
+
positive-infinity,
|
|
150
|
+
negative-infinity,
|
|
151
|
+
ymd(tuple<s32, u32, u32>),
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
record interval {
|
|
155
|
+
start: date,
|
|
156
|
+
start-inclusive: bool,
|
|
157
|
+
end: date,
|
|
158
|
+
end-inclusive: bool,
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
record time {
|
|
162
|
+
hour: u32,
|
|
163
|
+
min: u32,
|
|
164
|
+
sec: u32,
|
|
165
|
+
micro: u32,
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
record time-tz {
|
|
169
|
+
timesonze: string,
|
|
170
|
+
time: time,
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
record timestamp {
|
|
174
|
+
date: date,
|
|
175
|
+
time: time,
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
record timestamp-tz {
|
|
179
|
+
timestamp: timestamp,
|
|
180
|
+
offset: offset,
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
record mac-address-eui48 {
|
|
184
|
+
bytes: tuple<u8, u8, u8, u8, u8, u8>,
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
record mac-address-eui64 {
|
|
188
|
+
bytes: tuple<u8, u8, u8, u8, u8, u8, u8, u8>,
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/// Postgres data values, usable as parameters or via queries
|
|
192
|
+
/// see: https://www.postgresql.org/docs/current/datatype.html
|
|
193
|
+
///
|
|
194
|
+
/// This datatype is primarily intended to be used with the `raw` encoding scheme.
|
|
195
|
+
///
|
|
196
|
+
/// NOTE: all numeric values are little-endian unless otherwise specified
|
|
197
|
+
variant pg-value {
|
|
198
|
+
null,
|
|
199
|
+
/// Numeric
|
|
200
|
+
big-int(s64),
|
|
201
|
+
int8(s64),
|
|
202
|
+
int8-array(list<s64>),
|
|
203
|
+
big-serial(s64),
|
|
204
|
+
serial8(s64),
|
|
205
|
+
%bool(bool),
|
|
206
|
+
boolean(bool),
|
|
207
|
+
bool-array(list<bool>),
|
|
208
|
+
double(hashable-f64),
|
|
209
|
+
float8(hashable-f64),
|
|
210
|
+
float8-array(list<hashable-f64>),
|
|
211
|
+
real(hashable-f32),
|
|
212
|
+
float4(hashable-f32),
|
|
213
|
+
float4-array(list<hashable-f32>),
|
|
214
|
+
integer(s32),
|
|
215
|
+
int(s32),
|
|
216
|
+
int4(s32),
|
|
217
|
+
int4-array(list<s32>),
|
|
218
|
+
numeric(numeric),
|
|
219
|
+
decimal(numeric),
|
|
220
|
+
numeric-array(list<numeric>),
|
|
221
|
+
serial(u32),
|
|
222
|
+
serial4(u32),
|
|
223
|
+
small-int(s16),
|
|
224
|
+
int2(s16),
|
|
225
|
+
int2-array(list<s16>),
|
|
226
|
+
int2-vector(list<s16>),
|
|
227
|
+
int2-vector-array(list<list<s16>>),
|
|
228
|
+
small-serial(s16),
|
|
229
|
+
serial2(s16),
|
|
230
|
+
/// note: matches tokio-postgres
|
|
231
|
+
/// Bytes
|
|
232
|
+
///
|
|
233
|
+
/// For bit & bit-varying, see the encoding scheme used by bit-vec:
|
|
234
|
+
/// https://contain-rs.github.io/bit-vec/bit_vec/struct.BitVec.html#method.to_bytes
|
|
235
|
+
bit(tuple<u32, list<u8>>),
|
|
236
|
+
bit-array(list<tuple<u32, list<u8>>>),
|
|
237
|
+
bit-varying(tuple<option<u32>, list<u8>>),
|
|
238
|
+
varbit(tuple<option<u32>, list<u8>>),
|
|
239
|
+
varbit-array(list<tuple<option<u32>, list<u8>>>),
|
|
240
|
+
bytea(list<u8>),
|
|
241
|
+
bytea-array(list<list<u8>>),
|
|
242
|
+
/// Characters
|
|
243
|
+
/// TODO: specify text encoding, to negotiate possible component/DB mismatch?
|
|
244
|
+
%char(tuple<u32, list<u8>>),
|
|
245
|
+
char-array(list<tuple<u32, list<u8>>>),
|
|
246
|
+
varchar(tuple<option<u32>, list<u8>>),
|
|
247
|
+
varchar-array(list<tuple<option<u32>, list<u8>>>),
|
|
248
|
+
/// Networking
|
|
249
|
+
cidr(string),
|
|
250
|
+
cidr-array(list<string>),
|
|
251
|
+
inet(string),
|
|
252
|
+
inet-array(list<string>),
|
|
253
|
+
macaddr(mac-address-eui48),
|
|
254
|
+
/// EUI-48
|
|
255
|
+
macaddr-array(list<mac-address-eui48>),
|
|
256
|
+
/// EUI-48
|
|
257
|
+
macaddr8(mac-address-eui64),
|
|
258
|
+
/// EUI-64 (deprecated)
|
|
259
|
+
macaddr8-array(list<mac-address-eui64>),
|
|
260
|
+
/// EUI-64 (deprecated)
|
|
261
|
+
/// Geo
|
|
262
|
+
box(tuple<lower-left-point, upper-right-point>),
|
|
263
|
+
box-array(list<tuple<lower-left-point, upper-right-point>>),
|
|
264
|
+
circle(tuple<center-point, radius>),
|
|
265
|
+
circle-array(list<tuple<center-point, radius>>),
|
|
266
|
+
line(tuple<start-point, end-point>),
|
|
267
|
+
line-array(list<tuple<start-point, end-point>>),
|
|
268
|
+
lseg(tuple<start-point, end-point>),
|
|
269
|
+
lseg-array(list<tuple<start-point, end-point>>),
|
|
270
|
+
path(list<point>),
|
|
271
|
+
path-array(list<list<point>>),
|
|
272
|
+
point(point),
|
|
273
|
+
point-array(list<point>),
|
|
274
|
+
polygon(list<point>),
|
|
275
|
+
polygon-array(list<list<point>>),
|
|
276
|
+
/// Date-time
|
|
277
|
+
date(date),
|
|
278
|
+
date-array(list<date>),
|
|
279
|
+
interval(interval),
|
|
280
|
+
interval-array(list<interval>),
|
|
281
|
+
time(time),
|
|
282
|
+
time-array(list<time>),
|
|
283
|
+
time-tz(time-tz),
|
|
284
|
+
time-tz-array(list<time-tz>),
|
|
285
|
+
timestamp(timestamp),
|
|
286
|
+
timestamp-array(list<timestamp>),
|
|
287
|
+
timestamp-tz(timestamp-tz),
|
|
288
|
+
timestamp-tz-array(list<timestamp-tz>),
|
|
289
|
+
/// JSON
|
|
290
|
+
json(string),
|
|
291
|
+
json-array(list<string>),
|
|
292
|
+
jsonb(string),
|
|
293
|
+
jsonb-array(list<string>),
|
|
294
|
+
/// Money (use is discouraged)
|
|
295
|
+
///
|
|
296
|
+
/// fractional precision is determined by the database's `lc_monetary` setting.
|
|
297
|
+
///
|
|
298
|
+
/// NOTE: if you are storing currency amounts, consider
|
|
299
|
+
/// using integer (whole number) counts of smallest indivisible pieces of currency
|
|
300
|
+
/// (ex. cent amounts to represent United States Dollars; 100 cents = 1 USD)
|
|
301
|
+
money(numeric),
|
|
302
|
+
money-array(list<numeric>),
|
|
303
|
+
/// Postgres-internal
|
|
304
|
+
pg-lsn(u64),
|
|
305
|
+
pg-lsn-array(list<u64>),
|
|
306
|
+
/// see: https://www.postgresql.org/docs/current/functions-info.html#FUNCTIONS-PG-SNAPSHOT-PARTS
|
|
307
|
+
pg-snapshot(tuple<xmin, xmax, xip-list>),
|
|
308
|
+
txid-snapshot(s64),
|
|
309
|
+
/// Text
|
|
310
|
+
name(string),
|
|
311
|
+
name-array(list<string>),
|
|
312
|
+
text(string),
|
|
313
|
+
text-array(list<string>),
|
|
314
|
+
xml(string),
|
|
315
|
+
xml-array(list<string>),
|
|
316
|
+
/// Full Text Search
|
|
317
|
+
ts-query(string),
|
|
318
|
+
ts-vector(list<lexeme>),
|
|
319
|
+
/// UUIDs
|
|
320
|
+
uuid(string),
|
|
321
|
+
uuid-array(list<string>),
|
|
322
|
+
/// Containers
|
|
323
|
+
hstore(list<tuple<string, option<string>>>),
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/// A single row of a query result.
|
|
327
|
+
///
|
|
328
|
+
/// Values are positional: the value at index `i` corresponds to the column
|
|
329
|
+
/// name at index `i` of the accompanying `list<column-name>` header returned
|
|
330
|
+
/// by `query`. Carrying the column names once alongside the row stream (rather
|
|
331
|
+
/// than repeating a name with every value) keeps large result sets compact.
|
|
332
|
+
type row = list<pg-value>;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
/// Interface for querying a Postgres database.
|
|
337
|
+
///
|
|
338
|
+
/// Unlike `wasmcloud:postgres@0.1.1-draft`, every operation is an `async func`,
|
|
339
|
+
/// so a single component can issue many in-flight queries concurrently without
|
|
340
|
+
/// the `wasi:io/poll` ceremony required under wasip2. `query` also streams its
|
|
341
|
+
/// result rows rather than buffering the whole result set in host memory before
|
|
342
|
+
/// returning.
|
|
343
|
+
interface query {
|
|
344
|
+
use types.{pg-value, column-name, row, error};
|
|
345
|
+
|
|
346
|
+
/// Query a Postgres database, leaving connection/session management to the
|
|
347
|
+
/// callee/implementer of this interface (normally a provider configured with
|
|
348
|
+
/// connection credentials).
|
|
349
|
+
///
|
|
350
|
+
/// Queries *must* be parameterized, with named arguments in the form of
|
|
351
|
+
/// `$<integer>`, for example:
|
|
352
|
+
///
|
|
353
|
+
/// ```
|
|
354
|
+
/// SELECT email,username FROM users WHERE uuid=$1;
|
|
355
|
+
/// ```
|
|
356
|
+
///
|
|
357
|
+
/// On success the result is delivered in three parts:
|
|
358
|
+
///
|
|
359
|
+
/// 1. `list<column-name>` — the result columns, in order, delivered once up
|
|
360
|
+
/// front. Position `i` names the value at position `i` of every `row`.
|
|
361
|
+
/// 2. `stream<row>` — the result rows, produced incrementally as the database
|
|
362
|
+
/// returns them. The caller owns the stream and drives it to completion (or
|
|
363
|
+
/// drops it early to stop consuming).
|
|
364
|
+
/// 3. `future<result<_, error>>` — a completion signal that resolves once the
|
|
365
|
+
/// row stream is exhausted. It reports an error encountered *after* the
|
|
366
|
+
/// column header was sent (e.g. a failure partway through a large result),
|
|
367
|
+
/// which the row stream itself has no way to surface.
|
|
368
|
+
///
|
|
369
|
+
/// The outer `result` reports failures that occur before any rows stream, such
|
|
370
|
+
/// as a rejected statement or a lost connection.
|
|
371
|
+
query: async func(query: string, params: list<pg-value>)
|
|
372
|
+
-> result<tuple<list<column-name>, stream<row>, future<result<_, error>>>, error>;
|
|
373
|
+
|
|
374
|
+
/// Perform a batch query (which could contain multiple statements) against a
|
|
375
|
+
/// Postgres database, leaving connection/session management to the
|
|
376
|
+
/// callee/implementer of this interface (normally a provider configured with
|
|
377
|
+
/// connection credentials).
|
|
378
|
+
///
|
|
379
|
+
/// No user-provided or untrusted data should be used with this query --
|
|
380
|
+
/// parameters are not allowed.
|
|
381
|
+
///
|
|
382
|
+
/// This query *can* be used to execute multi-statement queries (common in
|
|
383
|
+
/// migrations).
|
|
384
|
+
query-batch: async func(query: string) -> result<_, error>;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
/// Interface for querying a Postgres database with prepared statements.
|
|
389
|
+
///
|
|
390
|
+
/// Unlike `wasmcloud:postgres@0.1.1-draft`, every operation is an `async func`,
|
|
391
|
+
/// so preparing and executing statements does not block the component and many
|
|
392
|
+
/// executions can be in flight concurrently.
|
|
393
|
+
interface prepared {
|
|
394
|
+
use types.{pg-value, error};
|
|
395
|
+
|
|
396
|
+
/// A token that represents a previously created prepared statement.
|
|
397
|
+
///
|
|
398
|
+
/// This token can be expected to be somewhat opaque to users.
|
|
399
|
+
type prepared-statement-token = string;
|
|
400
|
+
|
|
401
|
+
/// Prepare a statement against a Postgres database, leaving connection/session
|
|
402
|
+
/// management to the callee/implementer of this interface (normally a provider
|
|
403
|
+
/// configured with connection credentials).
|
|
404
|
+
///
|
|
405
|
+
/// Queries *must* be parameterized, with named arguments in the form of
|
|
406
|
+
/// `$<integer>`, for example:
|
|
407
|
+
///
|
|
408
|
+
/// ```
|
|
409
|
+
/// SELECT email,username FROM users WHERE uuid=$1;
|
|
410
|
+
/// ```
|
|
411
|
+
prepare: async func(statement: string) -> result<prepared-statement-token, error>;
|
|
412
|
+
|
|
413
|
+
/// Execute a prepared statement, returning the number of rows affected.
|
|
414
|
+
///
|
|
415
|
+
/// If the token is not recognized, this fails with
|
|
416
|
+
/// `error::unknown-prepared-statement`.
|
|
417
|
+
exec: async func(stmt-token: prepared-statement-token, params: list<pg-value>) -> result<u64, error>;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
/// The `wasmcloud:postgres/imports` world provides common APIs for querying a
|
|
422
|
+
/// Postgres database. Components targeting this world can:
|
|
423
|
+
///
|
|
424
|
+
/// 1. Run parameterized queries whose result rows stream back incrementally
|
|
425
|
+
/// (`query`), and run multi-statement batch queries (`query-batch`).
|
|
426
|
+
/// 2. Prepare statements once and execute them repeatedly (`prepared`).
|
|
427
|
+
///
|
|
428
|
+
/// Every operation is an `async func`, so a component can keep many queries in
|
|
429
|
+
/// flight concurrently.
|
|
430
|
+
world imports {
|
|
431
|
+
import types;
|
|
432
|
+
import query;
|
|
433
|
+
import prepared;
|
|
434
|
+
}
|
|
435
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
package wasmcloud:secrets@2.1.0;
|
|
2
|
+
|
|
3
|
+
/// Opaque-handle access to a secrets backend. Returning `secret` rather than
|
|
4
|
+
/// the underlying value lets the host gate reveal independently of lookup.
|
|
5
|
+
///
|
|
6
|
+
/// The operations are `async`: a secrets backend is commonly served by a host
|
|
7
|
+
/// component plugin from its own store, and cross-store capability calls are
|
|
8
|
+
/// dispatched asynchronously. (This is the async revision of the synchronous
|
|
9
|
+
/// `wasmcloud:secrets@1.0.0` interface.)
|
|
10
|
+
interface store {
|
|
11
|
+
/// An error type that encapsulates the different errors that can occur fetching secrets
|
|
12
|
+
variant secrets-error {
|
|
13
|
+
/// This indicates an error from an "upstream" secrets source.
|
|
14
|
+
/// As this could be almost _anything_ (such as Vault, Kubernetes Secrets, KeyValue buckets, etc),
|
|
15
|
+
/// the error message is a string.
|
|
16
|
+
upstream(string),
|
|
17
|
+
/// This indicates an error from an I/O operation.
|
|
18
|
+
/// As this could be almost _anything_ (such as a file read, network connection, etc),
|
|
19
|
+
/// the error message is a string.
|
|
20
|
+
/// Depending on how this ends up being consumed,
|
|
21
|
+
/// we may consider moving this to use the `wasi:io/error` type instead.
|
|
22
|
+
/// For simplicity right now in supporting multiple implementations, it is being left as a string.
|
|
23
|
+
io(string),
|
|
24
|
+
/// This indicates that the requested secret was not found.
|
|
25
|
+
not-found,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/// A secret value can be either a string or a byte array, which lets you
|
|
29
|
+
/// store binary data as a secret.
|
|
30
|
+
variant secret-value {
|
|
31
|
+
%string(string),
|
|
32
|
+
bytes(list<u8>),
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// A secret is a resource that can only be borrowed. This allows you to
|
|
36
|
+
/// pass around handles to secrets and not reveal the values until a
|
|
37
|
+
/// component needs them.
|
|
38
|
+
/// You need to use the reveal interface to get the value.
|
|
39
|
+
resource secret;
|
|
40
|
+
|
|
41
|
+
/// Gets a single opaque secrets value set at the given key if it exists
|
|
42
|
+
get: async func(key: string) -> result<secret, secrets-error>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/// Unwraps an opaque `secret` handle into its underlying value. Split from
|
|
46
|
+
/// `store` so a host can audit or restrict reveal calls separately.
|
|
47
|
+
interface reveal {
|
|
48
|
+
use store.{secret, secret-value};
|
|
49
|
+
|
|
50
|
+
/// Reveals the value of a secret to the caller.
|
|
51
|
+
/// This lets you easily audit your code to discover where secrets are being used.
|
|
52
|
+
reveal: async func(s: borrow<secret>) -> secret-value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// A single secret, statically identified by the `(implements ..)` label a
|
|
56
|
+
/// component imports it under, instead of a runtime `key` argument.
|
|
57
|
+
///
|
|
58
|
+
/// A component that knows its exact secret names up front (the common case)
|
|
59
|
+
/// can import one labeled instance of this interface per secret — e.g.
|
|
60
|
+
/// `import db-password: wasmcloud:secrets/secret;`. Because the label is part
|
|
61
|
+
/// of the component's own type, a host can check that every labeled secret it
|
|
62
|
+
/// imports has a matching entry in the component's resolved bind-time config
|
|
63
|
+
/// from the component's import list alone, before instantiating it — instead
|
|
64
|
+
/// of only discovering a missing one when a dynamic `store.get` call returns
|
|
65
|
+
/// `not-found`. `store` remains the interface for a component whose set of
|
|
66
|
+
/// keys is only known at runtime.
|
|
67
|
+
interface secret {
|
|
68
|
+
use store.{secret};
|
|
69
|
+
|
|
70
|
+
/// Returns the one secret this labeled import identifies. There is no `key`
|
|
71
|
+
/// parameter — which secret this is comes entirely from the label.
|
|
72
|
+
get: async func() -> secret;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
world imports {
|
|
76
|
+
import store;
|
|
77
|
+
import reveal;
|
|
78
|
+
import secret;
|
|
79
|
+
}
|
|
80
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { types as t, template } from '@babel/core';
|
|
2
|
+
/** Lower for-await loops before async-to-generator, retaining native generators. */
|
|
3
|
+
export function lowerForAwait() {
|
|
4
|
+
return {
|
|
5
|
+
visitor: {
|
|
6
|
+
Program(program, state) {
|
|
7
|
+
program.traverse({
|
|
8
|
+
ForOfStatement(path) {
|
|
9
|
+
if (!path.node.await)
|
|
10
|
+
return;
|
|
11
|
+
const iterator = path.scope.generateUidIdentifier('iterator');
|
|
12
|
+
const step = path.scope.generateUidIdentifier('step');
|
|
13
|
+
const abrupt = path.scope.generateUidIdentifier('abrupt');
|
|
14
|
+
const failed = path.scope.generateUidIdentifier('failed');
|
|
15
|
+
const error = path.scope.generateUidIdentifier('error');
|
|
16
|
+
const caught = path.scope.generateUidIdentifier('caught');
|
|
17
|
+
const { left, right, body } = path.node;
|
|
18
|
+
const value = t.memberExpression(step, t.identifier('value'));
|
|
19
|
+
const assignment = t.isVariableDeclaration(left)
|
|
20
|
+
? t.variableDeclaration(left.kind, [
|
|
21
|
+
t.variableDeclarator(left.declarations[0].id, value),
|
|
22
|
+
])
|
|
23
|
+
: t.expressionStatement(t.assignmentExpression('=', left, value));
|
|
24
|
+
const block = template.statement(`{
|
|
25
|
+
var ITERATOR = HELPER(SOURCE), STEP, ABRUPT = false, FAILED = false, ERROR;
|
|
26
|
+
try {
|
|
27
|
+
for (; ABRUPT = !(STEP = await ITERATOR.next()).done; ABRUPT = false) {
|
|
28
|
+
ASSIGNMENT;
|
|
29
|
+
BODY;
|
|
30
|
+
}
|
|
31
|
+
} catch (CAUGHT) { FAILED = true; ERROR = CAUGHT; }
|
|
32
|
+
finally {
|
|
33
|
+
try { if (ABRUPT && ITERATOR.return != null) await ITERATOR.return(); }
|
|
34
|
+
finally { if (FAILED) throw ERROR; }
|
|
35
|
+
}
|
|
36
|
+
}`, { allowAwaitOutsideFunction: true })({
|
|
37
|
+
ITERATOR: iterator,
|
|
38
|
+
STEP: step,
|
|
39
|
+
ABRUPT: abrupt,
|
|
40
|
+
FAILED: failed,
|
|
41
|
+
ERROR: error,
|
|
42
|
+
CAUGHT: caught,
|
|
43
|
+
HELPER: state.file.addHelper('asyncIterator'),
|
|
44
|
+
SOURCE: right,
|
|
45
|
+
ASSIGNMENT: assignment,
|
|
46
|
+
BODY: t.isBlockStatement(body) ? body.body : [body],
|
|
47
|
+
});
|
|
48
|
+
if (path.parentPath.isLabeledStatement()) {
|
|
49
|
+
const statement = block.body[1];
|
|
50
|
+
statement.block.body[0] = t.labeledStatement(path.parentPath.node.label, statement.block.body[0]);
|
|
51
|
+
path.parentPath.replaceWith(block);
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
path.replaceWith(block);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { WasmcloudDeps } from './deps.js';
|
|
2
|
+
import { type WasmcloudProject } from './project.js';
|
|
3
|
+
import type { WitRequirement } from './wit.js';
|
|
4
|
+
export type BindingKind = 'Postgres' | 'KeyValue' | 'Blobstore' | 'Messaging' | 'Config' | 'Secrets' | 'OutgoingHttp';
|
|
5
|
+
export type CatalogEntry = {
|
|
6
|
+
kind: BindingKind;
|
|
7
|
+
package: string;
|
|
8
|
+
version: string;
|
|
9
|
+
interfaces: string[];
|
|
10
|
+
primaryInterface: string;
|
|
11
|
+
namedInstance: boolean;
|
|
12
|
+
sharedResources: string[];
|
|
13
|
+
witDep: string;
|
|
14
|
+
usesSecret: boolean;
|
|
15
|
+
configKeys: string[];
|
|
16
|
+
};
|
|
17
|
+
export type BindingCatalog = Record<string, CatalogEntry>;
|
|
18
|
+
export type BindingRecord = {
|
|
19
|
+
className: string;
|
|
20
|
+
name: string;
|
|
21
|
+
kind: BindingKind;
|
|
22
|
+
requirement: WitRequirement;
|
|
23
|
+
serviceName?: string;
|
|
24
|
+
secretFrom?: string;
|
|
25
|
+
configFrom?: string;
|
|
26
|
+
config?: Record<string, string>;
|
|
27
|
+
};
|
|
28
|
+
export declare function defaultSecretName(applicationName: string, bindingName: string): string;
|
|
29
|
+
export declare function rejectsPlaintextSecret(config: Record<string, string> | undefined): string | undefined;
|
|
30
|
+
export declare function bindingsPath(project: WasmcloudProject): string | undefined;
|
|
31
|
+
export declare function loadBindingCatalog(projectRoot: string, deps: WasmcloudDeps): BindingCatalog | undefined;
|
|
32
|
+
export declare function parseBindingsFile(filePath: string, catalog: BindingCatalog, applicationName: string): BindingRecord[];
|
|
33
|
+
export declare function discoverBindings(project: WasmcloudProject, deps: WasmcloudDeps): BindingRecord[];
|
|
34
|
+
export declare function requirementsFromBindings(bindings: readonly BindingRecord[]): WitRequirement[];
|