@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.
Files changed (169) hide show
  1. package/README.md +408 -0
  2. package/dist/actor-protocol.d.ts +4 -0
  3. package/dist/actor-protocol.js +162 -0
  4. package/dist/actors.d.ts +31 -0
  5. package/dist/actors.js +296 -0
  6. package/dist/args.d.ts +15 -0
  7. package/dist/args.js +66 -0
  8. package/dist/assets/http-adapter.js +876 -0
  9. package/dist/assets/platform/.gitignore.tmpl +6 -0
  10. package/dist/assets/platform/Pulumi.yaml.tmpl +6 -0
  11. package/dist/assets/platform/README.md +208 -0
  12. package/dist/assets/platform/index.ts.tmpl +2 -0
  13. package/dist/assets/platform/package.json.tmpl +18 -0
  14. package/dist/assets/platform/tsconfig.json +11 -0
  15. package/dist/assets/queue-adapter.js +60 -0
  16. package/dist/assets/sqlite/BUILD-INFO.txt +13 -0
  17. package/dist/assets/sqlite/SHA256SUMS +2 -0
  18. package/dist/assets/sqlite/di-framework-sqlite.wasm +0 -0
  19. package/dist/assets/sqlite/di-framework-sqlite.wit +337 -0
  20. package/dist/assets/wit/deps/LICENSE.md +8 -0
  21. package/dist/assets/wit/deps/di-framework-queues/package.wit +18 -0
  22. package/dist/assets/wit/deps/di-framework-sqlite/package.wit +211 -0
  23. package/dist/assets/wit/deps/wasi-cli/package.wit +70 -0
  24. package/dist/assets/wit/deps/wasi-clocks/package.wit +42 -0
  25. package/dist/assets/wit/deps/wasi-config/package.wit +15 -0
  26. package/dist/assets/wit/deps/wasi-filesystem/package.wit +184 -0
  27. package/dist/assets/wit/deps/wasi-http/package.wit +170 -0
  28. package/dist/assets/wit/deps/wasi-random/package.wit +17 -0
  29. package/dist/assets/wit/deps/wasi-sockets/package.wit +105 -0
  30. package/dist/assets/wit/deps/wasi-tls/package.wit +26 -0
  31. package/dist/assets/wit/deps/wasmcloud-blobstore/package.wit +153 -0
  32. package/dist/assets/wit/deps/wasmcloud-keyvalue/package.wit +370 -0
  33. package/dist/assets/wit/deps/wasmcloud-messaging/package.wit +125 -0
  34. package/dist/assets/wit/deps/wasmcloud-postgres/package.wit +435 -0
  35. package/dist/assets/wit/deps/wasmcloud-secrets/package.wit +80 -0
  36. package/dist/async-transform.d.ts +3 -0
  37. package/dist/async-transform.js +60 -0
  38. package/dist/bindings.d.ts +34 -0
  39. package/dist/bindings.js +307 -0
  40. package/dist/build.d.ts +29 -0
  41. package/dist/build.js +325 -0
  42. package/dist/command.d.ts +3 -0
  43. package/dist/command.js +141 -0
  44. package/dist/control/auth.d.ts +18 -0
  45. package/dist/control/auth.js +89 -0
  46. package/dist/control/cron.d.ts +7 -0
  47. package/dist/control/cron.js +86 -0
  48. package/dist/control/index.d.ts +4 -0
  49. package/dist/control/index.js +4 -0
  50. package/dist/control/network.d.ts +12 -0
  51. package/dist/control/network.js +49 -0
  52. package/dist/control/queues.d.ts +15 -0
  53. package/dist/control/queues.js +77 -0
  54. package/dist/cron.d.ts +26 -0
  55. package/dist/cron.js +239 -0
  56. package/dist/deploy.d.ts +29 -0
  57. package/dist/deploy.js +57 -0
  58. package/dist/deps.d.ts +96 -0
  59. package/dist/deps.js +303 -0
  60. package/dist/destroy.d.ts +3 -0
  61. package/dist/destroy.js +24 -0
  62. package/dist/dev-runner.d.ts +24 -0
  63. package/dist/dev-runner.js +83 -0
  64. package/dist/dev.d.ts +8 -0
  65. package/dist/dev.js +76 -0
  66. package/dist/discovery.d.ts +15 -0
  67. package/dist/discovery.js +182 -0
  68. package/dist/doctor.d.ts +8 -0
  69. package/dist/doctor.js +82 -0
  70. package/dist/guests.d.ts +9 -0
  71. package/dist/guests.js +56 -0
  72. package/dist/host-interface.d.ts +29 -0
  73. package/dist/host-interface.js +142 -0
  74. package/dist/index.d.ts +33 -0
  75. package/dist/index.js +39 -0
  76. package/dist/kubernetes.d.ts +9 -0
  77. package/dist/kubernetes.js +17 -0
  78. package/dist/managed-bindings.d.ts +9 -0
  79. package/dist/managed-bindings.js +150 -0
  80. package/dist/manifest.d.ts +36 -0
  81. package/dist/manifest.js +257 -0
  82. package/dist/namespace.d.ts +2 -0
  83. package/dist/namespace.js +4 -0
  84. package/dist/node-compat/async-hooks.d.ts +29 -0
  85. package/dist/node-compat/async-hooks.js +80 -0
  86. package/dist/node-compat/bootstrap.d.ts +1 -0
  87. package/dist/node-compat/bootstrap.js +9 -0
  88. package/dist/node-compat/bytes.d.ts +7 -0
  89. package/dist/node-compat/bytes.js +41 -0
  90. package/dist/node-compat/crypto-hash.d.ts +27 -0
  91. package/dist/node-compat/crypto-hash.js +108 -0
  92. package/dist/node-compat/crypto-subtle.d.ts +59 -0
  93. package/dist/node-compat/crypto-subtle.js +288 -0
  94. package/dist/node-compat/crypto.d.ts +136 -0
  95. package/dist/node-compat/crypto.js +142 -0
  96. package/dist/node-compat/dgram.d.ts +49 -0
  97. package/dist/node-compat/dgram.js +197 -0
  98. package/dist/node-compat/env.d.ts +6 -0
  99. package/dist/node-compat/env.js +88 -0
  100. package/dist/node-compat/fetch-runtime.d.ts +80 -0
  101. package/dist/node-compat/fetch-runtime.js +314 -0
  102. package/dist/node-compat/fs.d.ts +84 -0
  103. package/dist/node-compat/fs.js +285 -0
  104. package/dist/node-compat/http-parser.d.ts +40 -0
  105. package/dist/node-compat/http-parser.js +185 -0
  106. package/dist/node-compat/http.d.ts +130 -0
  107. package/dist/node-compat/http.js +688 -0
  108. package/dist/node-compat/https.d.ts +28 -0
  109. package/dist/node-compat/https.js +88 -0
  110. package/dist/node-compat/module.d.ts +11 -0
  111. package/dist/node-compat/module.js +35 -0
  112. package/dist/node-compat/net.d.ts +119 -0
  113. package/dist/node-compat/net.js +441 -0
  114. package/dist/node-compat/process.d.ts +25 -0
  115. package/dist/node-compat/process.js +63 -0
  116. package/dist/node-compat/runtime-application.d.ts +4 -0
  117. package/dist/node-compat/runtime-application.js +24 -0
  118. package/dist/node-compat/seed-virtual.d.ts +6 -0
  119. package/dist/node-compat/seed-virtual.js +6 -0
  120. package/dist/node-compat/seed.d.ts +20 -0
  121. package/dist/node-compat/seed.js +106 -0
  122. package/dist/node-compat/socket-address.d.ts +35 -0
  123. package/dist/node-compat/socket-address.js +162 -0
  124. package/dist/node-compat/timers.d.ts +32 -0
  125. package/dist/node-compat/timers.js +96 -0
  126. package/dist/node-compat/tls.d.ts +57 -0
  127. package/dist/node-compat/tls.js +290 -0
  128. package/dist/node-compat/wasi-random.d.ts +2 -0
  129. package/dist/node-compat/wasi-random.js +25 -0
  130. package/dist/node-compat/wasi-sockets.d.ts +47 -0
  131. package/dist/node-compat/wasi-sockets.js +134 -0
  132. package/dist/oci.d.ts +9 -0
  133. package/dist/oci.js +9 -0
  134. package/dist/paths.d.ts +7 -0
  135. package/dist/paths.js +13 -0
  136. package/dist/platform-init.d.ts +13 -0
  137. package/dist/platform-init.js +265 -0
  138. package/dist/platform.d.ts +22 -0
  139. package/dist/platform.js +170 -0
  140. package/dist/project.d.ts +39 -0
  141. package/dist/project.js +130 -0
  142. package/dist/publish.d.ts +15 -0
  143. package/dist/publish.js +57 -0
  144. package/dist/pulumi.d.ts +4 -0
  145. package/dist/pulumi.js +27 -0
  146. package/dist/queues-module.d.ts +4 -0
  147. package/dist/queues-module.js +89 -0
  148. package/dist/queues.d.ts +16 -0
  149. package/dist/queues.js +167 -0
  150. package/dist/registry.d.ts +16 -0
  151. package/dist/registry.js +27 -0
  152. package/dist/service.d.ts +162 -0
  153. package/dist/service.js +678 -0
  154. package/dist/support.d.ts +14 -0
  155. package/dist/support.js +37 -0
  156. package/dist/target.d.ts +18 -0
  157. package/dist/target.js +45 -0
  158. package/dist/toml.d.ts +6 -0
  159. package/dist/toml.js +245 -0
  160. package/dist/wash-dev.d.ts +18 -0
  161. package/dist/wash-dev.js +80 -0
  162. package/dist/wit.d.ts +76 -0
  163. package/dist/wit.js +248 -0
  164. package/dist/workload-members.d.ts +12 -0
  165. package/dist/workload-members.js +136 -0
  166. package/dist/workload.d.ts +45 -0
  167. package/dist/workload.js +457 -0
  168. package/package.json +55 -8
  169. package/src/index.ts +0 -2
@@ -0,0 +1,370 @@
1
+ package wasmcloud:keyvalue@0.2.0;
2
+
3
+ /// Types shared across the keyvalue interfaces.
4
+ ///
5
+ /// The `bucket` resource lives here (rather than in `store`) so that every
6
+ /// interface that operates on a bucket — `store`, `atomics`, `cas`, `batch`,
7
+ /// `watcher` — `use`s the *same* resource type. That matters for the
8
+ /// component-model `(implements ..)` mechanism: a host can route each labeled
9
+ /// `store` import to a different backend, and the bucket a guest opens through
10
+ /// one label is still accepted by the (unlabeled) `atomics`/`cas`/`batch`
11
+ /// interfaces, because they all reference this one `types.bucket`.
12
+ interface types {
13
+ /// The set of errors which may be raised by functions in this package.
14
+ ///
15
+ /// Following the wasip3 convention, this enumerates specific named cases
16
+ /// rather than leaning on stringly-typed errors. It is intentionally
17
+ /// non-exhaustive: future versions may add cases, and generated bindings are
18
+ /// marked non-exhaustive accordingly, so consumers must always include a
19
+ /// catch-all arm. Backend-specific failures that do not map to a named case
20
+ /// are reported via `other`.
21
+ variant error {
22
+ /// The host does not recognize the store identifier requested.
23
+ no-such-store,
24
+ /// The requesting component does not have access to the specified store
25
+ /// (which may or may not exist).
26
+ access-denied,
27
+ /// The request was malformed or self-contradictory, e.g. a `cas.swap`
28
+ /// whose `cas-options` sets no precondition.
29
+ invalid-argument,
30
+ /// A conditional operation did not meet its precondition, e.g. a `set` with
31
+ /// `if-not-exists` against a key that already exists.
32
+ precondition-failed,
33
+ /// The operation did not complete within the host- or backend-imposed time
34
+ /// limit.
35
+ timeout,
36
+ /// The store is currently unreachable or otherwise unavailable. The
37
+ /// operation may succeed if retried later.
38
+ store-unavailable,
39
+ /// The operation was rejected because a quota or rate limit was exceeded.
40
+ quota-exceeded,
41
+ /// Some other implementation-specific error has occurred (e.g. I/O). Used
42
+ /// for backend-specific failures that do not map to a named case above.
43
+ other(string),
44
+ }
45
+
46
+ /// A response to a `list-keys` operation.
47
+ record key-response {
48
+ /// The list of keys returned by the query.
49
+ keys: list<string>,
50
+ /// The continuation token to use to fetch the next page of keys. If this is `none`, then
51
+ /// there are no more keys to fetch.
52
+ cursor: option<string>,
53
+ }
54
+
55
+ /// Options that modify the behavior of a `set` operation.
56
+ record set-options {
57
+ /// If set, the entry expires this many milliseconds after the write, after
58
+ /// which the host removes it. `none` stores the entry without expiry.
59
+ ///
60
+ /// Hosts whose backend cannot honor expiry MUST raise an error rather than
61
+ /// silently ignoring the TTL.
62
+ ttl-ms: option<u64>,
63
+ /// When true, the write succeeds only if the key does not already exist,
64
+ /// failing with `error::precondition-failed` otherwise. Useful for locks
65
+ /// and idempotent initialization.
66
+ if-not-exists: bool,
67
+ }
68
+
69
+ /// A bucket is a collection of key-value pairs. Each key-value pair is stored as an entry in the
70
+ /// bucket, and the bucket itself acts as a collection of all these entries.
71
+ ///
72
+ /// It is worth noting that the exact terminology for bucket in key-value stores can vary
73
+ /// depending on the specific implementation. For example:
74
+ ///
75
+ /// 1. Amazon DynamoDB calls a collection of key-value pairs a table
76
+ /// 2. Redis has hashes, sets, and sorted sets as different types of collections
77
+ /// 3. Cassandra calls a collection of key-value pairs a column family
78
+ /// 4. MongoDB calls a collection of key-value pairs a collection
79
+ /// 5. Riak calls a collection of key-value pairs a bucket
80
+ /// 6. Memcached calls a collection of key-value pairs a slab
81
+ /// 7. Azure Cosmos DB calls a collection of key-value pairs a container
82
+ ///
83
+ /// In this interface, we use the term `bucket` to refer to a collection of key-value pairs
84
+ resource bucket {
85
+ /// Get the value associated with the specified `key`
86
+ ///
87
+ /// The value is returned as an option. If the key-value pair exists in the
88
+ /// store, it returns `ok(value)`. If the key does not exist in the
89
+ /// store, it returns `ok(none)`.
90
+ ///
91
+ /// If any other error occurs, it returns an `err(error)`.
92
+ get: async func(key: string) -> result<option<list<u8>>, error>;
93
+ /// Set the value associated with the key in the store. If the key already
94
+ /// exists in the store, it overwrites the value.
95
+ ///
96
+ /// If the key does not exist in the store, it creates a new key-value pair.
97
+ ///
98
+ /// `options` controls expiry (`ttl-ms`) and conditional writes
99
+ /// (`if-not-exists`); pass `none` for the default overwrite-on-exists
100
+ /// behavior with no expiry.
101
+ ///
102
+ /// If any other error occurs, it returns an `err(error)`.
103
+ set: async func(key: string, value: list<u8>, options: option<set-options>) -> result<_, error>;
104
+ /// Delete the key-value pair associated with the key in the store.
105
+ ///
106
+ /// If the key does not exist in the store, it does nothing.
107
+ ///
108
+ /// If any other error occurs, it returns an `err(error)`.
109
+ delete: async func(key: string) -> result<_, error>;
110
+ /// Check if the key exists in the store.
111
+ ///
112
+ /// If the key exists in the store, it returns `ok(true)`. If the key does
113
+ /// not exist in the store, it returns `ok(false)`.
114
+ ///
115
+ /// If any other error occurs, it returns an `err(error)`.
116
+ exists: async func(key: string) -> result<bool, error>;
117
+ /// Get the keys in the store, optionally restricted to those starting with
118
+ /// `prefix`, with an optional cursor (for use in pagination). It returns a
119
+ /// list of keys. Please note that for most KeyValue implementations, this
120
+ /// can be a very expensive operation and so it should be used judiciously. Implementations
121
+ /// can return any number of keys in a single response, but they should never attempt to
122
+ /// send more data than is reasonable (i.e. on a small edge device, this may only be a few
123
+ /// KB, while on a large machine this could be several MB). Any response should also return
124
+ /// a cursor that can be used to fetch the next page of keys. See the `key-response` record
125
+ /// for more information.
126
+ ///
127
+ /// `prefix` filters the result to keys that begin with the given string; pass
128
+ /// `none` to list all keys. When paginating, the same `prefix` should be
129
+ /// supplied alongside each `cursor`.
130
+ ///
131
+ /// Note that the keys are not guaranteed to be returned in any particular order.
132
+ ///
133
+ /// If the store is empty (or no keys match `prefix`), it returns an empty list.
134
+ ///
135
+ /// MAY show an out-of-date list of keys if there are concurrent writes to the store.
136
+ ///
137
+ /// If any error occurs, it returns an `err(error)`.
138
+ list-keys: async func(prefix: option<string>, cursor: option<string>) -> result<key-response, error>;
139
+ }
140
+ }
141
+
142
+
143
+ /// A keyvalue interface that provides eventually consistent key-value operations.
144
+ ///
145
+ /// Each of these operations acts on a single key-value pair.
146
+ ///
147
+ /// The value in the key-value pair is defined as a `u8` byte array and the intention is that it is
148
+ /// the common denominator for all data types defined by different key-value stores to handle data,
149
+ /// ensuring compatibility between different key-value stores. Note: the clients will be expecting
150
+ /// serialization/deserialization overhead to be handled by the key-value store. The value could be
151
+ /// a serialized object from JSON, HTML or vendor-specific data types like AWS S3 objects.
152
+ ///
153
+ /// Data consistency in a key value store refers to the guarantee that once a write operation
154
+ /// completes, all subsequent read operations will return the value that was written.
155
+ ///
156
+ /// Any implementation of this interface must have enough consistency to guarantee "reading your
157
+ /// writes." In particular, this means that the client should never get a value that is older than
158
+ /// the one it wrote, but it MAY get a newer value if one was written around the same time. These
159
+ /// guarantees only apply to the same client (which will likely be provided by the host or an
160
+ /// external capability of some kind). In this context a "client" is referring to the caller or
161
+ /// guest that is consuming this interface. Once a write request is committed by a specific client,
162
+ /// all subsequent read requests by the same client will reflect that write or any subsequent
163
+ /// writes. Another client running in a different context may or may not immediately see the result
164
+ /// due to the replication lag.
165
+ ///
166
+ /// Unlike `wasi:keyvalue@0.2.0-draft`, every operation that touches a backend is an `async func`.
167
+ /// This lets a single component issue many in-flight key-value operations concurrently without the
168
+ /// `wasi:io/poll` ceremony required under wasip2.
169
+ interface store {
170
+ use types.{bucket, error};
171
+
172
+ /// Get the bucket with the specified identifier.
173
+ ///
174
+ /// `identifier` must refer to a bucket provided by the host.
175
+ ///
176
+ /// `error::no-such-store` will be raised if the `identifier` is not recognized.
177
+ open: async func(identifier: string) -> result<bucket, error>;
178
+ }
179
+
180
+
181
+ /// A keyvalue interface that provides atomic operations.
182
+ ///
183
+ /// Atomic operations are single, indivisible operations. When a fault causes an atomic operation to
184
+ /// fail, it will appear to the invoker of the atomic operation that the action either completed
185
+ /// successfully or did nothing at all.
186
+ interface atomics {
187
+ use types.{bucket, error};
188
+
189
+ /// Atomically increment the value associated with the key in the store by the given (signed)
190
+ /// delta, returning the new value. A negative delta decrements, where decrement is just a
191
+ /// negative increment, rather than `wasi:keyvalue`'s unsigned-only counter.
192
+ ///
193
+ /// If the key does not exist in the store, it creates a new key-value pair with the value set
194
+ /// to the given delta.
195
+ ///
196
+ /// If any other error occurs, it returns an `err(error)`.
197
+ increment: async func(bucket: borrow<bucket>, key: string, delta: s64) -> result<s64, error>;
198
+ }
199
+
200
+
201
+ /// A keyvalue interface that provides compare-and-swap (optimistic concurrency) for a single key.
202
+ ///
203
+ /// This is kept separate from `atomics` so a host can grant or deny it independently, and so
204
+ /// backends that cannot perform conditional writes can decline just this capability. It is a
205
+ /// one-shot, resource-free API: each `swap` carries its own preconditions and reports the current
206
+ /// state back on conflict, so the read-modify-write retry loop needs no extra round trips.
207
+ interface cas {
208
+ use types.{bucket, error};
209
+
210
+ /// An opaque, backend-defined version token for an entry: an etcd revision, an S3/HTTP ETag, a
211
+ /// Cosmos DB `_etag`, a monotonic counter, and so on. Treat it as opaque — only equality is
212
+ /// meaningful, and tokens are not ordered or comparable across keys or backends.
213
+ type version = string;
214
+
215
+ /// A key's value together with its current version.
216
+ record entry {
217
+ value: list<u8>,
218
+ version: version,
219
+ }
220
+
221
+ /// Read a key's current value and version, for use as the precondition of a later `swap`.
222
+ /// Returns `none` if the key does not exist.
223
+ ///
224
+ /// `store.get` deliberately omits the version; use this when you intend to do a
225
+ /// version-checked swap.
226
+ current: async func(bucket: borrow<bucket>, key: string) -> result<option<entry>, error>;
227
+
228
+ /// Preconditions for a `swap`. Every condition that is set must hold for the write to be
229
+ /// applied. At least one condition must be set: a `swap` with an empty `cas-options` is a
230
+ /// misuse and is rejected with `error::invalid-argument` (use `store.set` for an unconditional
231
+ /// write).
232
+ record cas-options {
233
+ /// Require the entry's current version to equal this. This is the ABA-safe check: it detects
234
+ /// a value that changed A -> B -> A, which a value comparison misses. Omit it if you do not
235
+ /// care about ABA.
236
+ require-version: option<version>,
237
+ /// Require the entry's current value to equal this. A version-free optimistic check: simpler,
238
+ /// but ABA-prone. Omit to skip.
239
+ require-value: option<list<u8>>,
240
+ }
241
+
242
+ /// The outcome of a `swap`.
243
+ variant cas-result {
244
+ /// The new value was written.
245
+ swapped,
246
+ /// A precondition did not hold; nothing was written. The current entry is returned (`none`
247
+ /// if the key is absent) so the caller can recompute and retry without a separate read.
248
+ stale(option<entry>),
249
+ }
250
+
251
+ /// Conditionally and atomically set `key` to `value` if every precondition in `options` holds.
252
+ ///
253
+ /// Returns `cas-result::swapped` on success, or `cas-result::stale` with the current entry if a
254
+ /// precondition fails. A lost race is the expected `stale` outcome, not an `error`. `options`
255
+ /// must set at least one precondition; an empty `cas-options` returns `err(error::invalid-argument)`
256
+ /// rather than performing an unconditional write. Other `err(error)` values are store-level
257
+ /// failures.
258
+ swap: async func(
259
+ bucket: borrow<bucket>,
260
+ key: string,
261
+ value: list<u8>,
262
+ options: cas-options,
263
+ ) -> result<cas-result, error>;
264
+ }
265
+
266
+
267
+ /// A keyvalue interface that provides batch operations.
268
+ ///
269
+ /// A batch operation is an operation that operates on multiple keys at once.
270
+ ///
271
+ /// Batch operations are useful for reducing network round-trip time. For example, if you want to
272
+ /// get the values associated with 100 keys, you can either do 100 get operations or you can do 1
273
+ /// batch get operation. The batch operation is faster because it only needs to make 1 network call
274
+ /// instead of 100.
275
+ ///
276
+ /// A batch operation does not guarantee atomicity, meaning that if the batch operation fails, some
277
+ /// of the keys may have been modified and some may not.
278
+ ///
279
+ /// This interface has the same consistency guarantees as the `store` interface, meaning that you
280
+ /// should be able to "read your writes."
281
+ interface batch {
282
+ use types.{bucket, error};
283
+
284
+ /// Get the key-value pairs associated with the keys in the store. It returns a list of
285
+ /// key-value pairs.
286
+ ///
287
+ /// If any of the keys do not exist in the store, it returns a `none` value for that pair in the
288
+ /// list.
289
+ ///
290
+ /// MAY show an out-of-date value if there are concurrent writes to the store.
291
+ ///
292
+ /// If any other error occurs, it returns an `err(error)`.
293
+ get-many: async func(bucket: borrow<bucket>, keys: list<string>) -> result<list<option<tuple<string, list<u8>>>>, error>;
294
+
295
+ /// Set the values associated with the keys in the store. If the key already exists in the
296
+ /// store, it overwrites the value.
297
+ ///
298
+ /// Note that the key-value pairs are not guaranteed to be set in the order they are provided.
299
+ ///
300
+ /// If any of the keys do not exist in the store, it creates a new key-value pair.
301
+ ///
302
+ /// If any other error occurs, it returns an `err(error)`. When an error occurs, it does not
303
+ /// rollback the key-value pairs that were already set. Thus, this batch operation does not
304
+ /// guarantee atomicity, implying that some key-value pairs could be set while others might
305
+ /// fail.
306
+ ///
307
+ /// Other concurrent operations may also be able to see the partial results.
308
+ set-many: async func(bucket: borrow<bucket>, key-values: list<tuple<string, list<u8>>>) -> result<_, error>;
309
+
310
+ /// Delete the key-value pairs associated with the keys in the store.
311
+ ///
312
+ /// Note that the key-value pairs are not guaranteed to be deleted in the order they are
313
+ /// provided.
314
+ ///
315
+ /// If any of the keys do not exist in the store, it skips the key.
316
+ ///
317
+ /// If any other error occurs, it returns an `err(error)`. When an error occurs, it does not
318
+ /// rollback the key-value pairs that were already deleted. Thus, this batch operation does not
319
+ /// guarantee atomicity, implying that some key-value pairs could be deleted while others might
320
+ /// fail.
321
+ ///
322
+ /// Other concurrent operations may also be able to see the partial results.
323
+ delete-many: async func(bucket: borrow<bucket>, keys: list<string>) -> result<_, error>;
324
+ }
325
+
326
+
327
+ /// A keyvalue interface that provides event-driven notifications of changes to a bucket.
328
+ ///
329
+ /// This interface is exported by a component that wants to react to key-value changes, and the
330
+ /// callbacks are delivered by the host as those changes occur.
331
+ interface watcher {
332
+ use types.{bucket};
333
+
334
+ /// Handle the `set` event for the given bucket and key. It includes a handle to the `bucket`
335
+ /// that can be used to interact with the store.
336
+ on-set: async func(bucket: bucket, key: string, value: list<u8>);
337
+
338
+ /// Handle the `delete` event for the given bucket and key. It includes a handle to the
339
+ /// `bucket` that can be used to interact with the store.
340
+ on-delete: async func(bucket: bucket, key: string);
341
+ }
342
+
343
+
344
+ /// The `wasmcloud:keyvalue/imports` world provides common APIs for interacting with key-value
345
+ /// stores. Components targeting this world will be able to do:
346
+ ///
347
+ /// 1. CRUD (create, read, update, delete) operations on key-value stores, with optional
348
+ /// per-entry expiry and conditional writes.
349
+ /// 2. Atomic `increment` operations, and compare-and-swap (CAS) via the `cas` interface.
350
+ /// 3. Batch operations that can reduce the number of round trips to the network.
351
+ world imports {
352
+ import types;
353
+ import store;
354
+ import atomics;
355
+ import cas;
356
+ import batch;
357
+ }
358
+
359
+ /// The `wasmcloud:keyvalue/watch-service` world is implemented by components that want to receive
360
+ /// change notifications for a bucket in addition to performing key-value operations themselves.
361
+ world watch-service {
362
+ import types;
363
+ import store;
364
+ import atomics;
365
+ import cas;
366
+ import batch;
367
+
368
+ export watcher;
369
+ }
370
+
@@ -0,0 +1,125 @@
1
+ package wasmcloud:messaging@0.3.0;
2
+
3
+ /// Types common to message broker interactions.
4
+ ///
5
+ /// Unlike `wasmcloud:messaging@0.2.0`, every broker operation in this package is an `async func`,
6
+ /// and message bodies are native `stream<u8>` values rather than `list<u8>`. A single component
7
+ /// can keep many publishes and requests in flight at once, and a payload can flow incrementally
8
+ /// instead of being held in memory in its totality.
9
+ interface types {
10
+ /// A message sent to or received from a broker.
11
+ ///
12
+ /// The body is a `stream<u8>`: the payload flows incrementally on both the producing and the
13
+ /// consuming side, so neither end is required to hold it whole in memory. Hosts whose backend
14
+ /// cannot stream a message (e.g. core NATS, which sends a message as one bounded payload) MAY
15
+ /// buffer a body internally before forwarding it — the interface permits streaming without
16
+ /// requiring every backend to provide it, and a backend that can fan a stream out efficiently
17
+ /// pays no buffering cost.
18
+ record broker-message {
19
+ subject: string,
20
+ body: stream<u8>,
21
+ reply-to: option<string>,
22
+ }
23
+
24
+ /// The set of errors which may be raised by broker operations (the `consumer` interface).
25
+ variant error {
26
+ /// The subject is malformed, empty, or otherwise rejected by the broker.
27
+ subject-invalid,
28
+ /// The requesting component is not permitted to publish to this subject.
29
+ access-denied,
30
+ /// A `request` did not receive a reply within its `timeout-ms`.
31
+ timeout,
32
+ /// The broker is currently unreachable or otherwise unavailable. The operation
33
+ /// may succeed if retried later.
34
+ broker-unavailable,
35
+ /// The message body exceeded the broker's maximum payload size.
36
+ message-too-large,
37
+ /// The operation was rejected because a quota or rate limit was exceeded.
38
+ quota-exceeded,
39
+ /// Some other implementation-specific error has occurred (e.g. I/O). Used for
40
+ /// backend-specific failures that do not map to a named case above.
41
+ other(string),
42
+ }
43
+
44
+ /// The disposition a message handler reports for a delivery it could not process.
45
+ ///
46
+ /// Hosts currently record the disposition; backends with redelivery semantics
47
+ /// (e.g. NATS JetStream) can map `retry` to a negative acknowledgement and
48
+ /// `reject` to a terminal one.
49
+ variant handle-message-error {
50
+ /// The message cannot be processed, and redelivering the same message will
51
+ /// not help (malformed payload, unrecognized subject shape, ...).
52
+ reject,
53
+ /// Processing failed transiently; redelivering the message later may succeed
54
+ /// (e.g. a downstream dependency was briefly unavailable).
55
+ retry,
56
+ /// Some other handler-specific failure, with detail. Hosts treat it as
57
+ /// `reject` for redelivery purposes.
58
+ other(string),
59
+ }
60
+ }
61
+
62
+
63
+ /// The producing side of a broker: operations a component calls to send messages.
64
+ interface consumer {
65
+ use types.{broker-message, error};
66
+
67
+ /// Perform a request operation on a subject, resolving once the reply arrives.
68
+ ///
69
+ /// Because this is an `async func`, a component may have many requests
70
+ /// outstanding concurrently; awaiting one does not block the instance.
71
+ ///
72
+ /// The request `body` is a `stream<u8>` the callee consumes; the reply's body
73
+ /// streams back inside the returned `broker-message`. `timeout-ms` bounds the
74
+ /// wait for the reply, measured once the request body has been fully consumed
75
+ /// and sent — the caller controls how fast its own body is produced, so that
76
+ /// time is not counted against the broker. Pass `none` to use the backend's
77
+ /// default request timeout (e.g. the NATS client's configured timeout).
78
+ ///
79
+ /// Returns `error::timeout` if no reply arrives in time.
80
+ request: async func(subject: string, body: stream<u8>, timeout-ms: option<u32>) -> result<broker-message, error>;
81
+
82
+ /// Publish a message to a subject without awaiting a response.
83
+ ///
84
+ /// Resolving indicates the callee has fully consumed `msg.body` and the broker
85
+ /// accepted the message — not that any subscriber received it.
86
+ publish: async func(msg: broker-message) -> result<_, error>;
87
+ }
88
+
89
+
90
+ /// The consuming side of a broker: implemented by components that subscribe.
91
+ interface handler {
92
+ use types.{broker-message, handle-message-error};
93
+
94
+ /// Callback invoked when a message is received from a subscription.
95
+ ///
96
+ /// As an `async func` this may await other operations — including
97
+ /// `consumer.publish` to reply on `msg.reply-to` — while the host continues to
98
+ /// deliver further messages to the same instance concurrently. The message
99
+ /// body is a `stream<u8>` the handler drains, or drops to discard the payload.
100
+ ///
101
+ /// The error is a per-delivery disposition (`handle-message-error`), not the
102
+ /// broker `error` — a handler cannot raise transport failures about a message
103
+ /// it has already received; what it reports is whether redelivery could help.
104
+ handle-message: async func(msg: broker-message) -> result<_, handle-message-error>;
105
+ }
106
+
107
+
108
+ /// The `wasmcloud:messaging/imports` world is for components that only produce
109
+ /// messages — publishing to subjects and issuing request/reply calls.
110
+ world imports {
111
+ import types;
112
+ import consumer;
113
+ }
114
+
115
+ /// The `wasmcloud:messaging/handler-service` world is implemented by components
116
+ /// that consume a subscription. The host delivers each received message to the
117
+ /// exported `handler`, and the component may also produce messages itself (for
118
+ /// example, to reply on a message's `reply-to` subject).
119
+ world handler-service {
120
+ import types;
121
+ import consumer;
122
+
123
+ export handler;
124
+ }
125
+