1#![cfg(not(target_arch = "wasm32"))]
2#![allow(clippy::all)]
4#![allow(missing_docs)]
5#![allow(unused_macros)]
6
7macro_rules! declare_world {
8 (
9 mod $mod_name:ident,
10 path = $path_literal:literal,
11 world = $world_literal:literal
12 $(, legacy = { $($legacy:item)* } )?
13 ) => {
14 pub mod $mod_name {
15 mod generated {
16 wasmtime::component::bindgen!({
17 path: $path_literal,
18 world: $world_literal,
19 });
20 }
21
22 #[allow(unused_imports)]
23 pub use generated::*;
24
25 $(
26 $($legacy)*
27 )?
28 }
29 };
30}
31
32#[cfg(feature = "describe-v1")]
33declare_world!(
34 mod component_describe_v1,
35 path = "bundled-wit/greentic-component-1.0.0",
36 world = "greentic:component/component@1.0.0",
37 legacy = {
38 pub const PACKAGE_ID: &str = "greentic:component@1.0.0";
40 }
41);
42
43#[cfg(feature = "component-v1")]
44declare_world!(
45 mod component_v1,
46 path = "bundled-wit/greentic-component-v1-0.1.0",
47 world = "greentic:component-v1/component-host@0.1.0",
48 legacy = {
49 pub const PACKAGE_ID: &str = "greentic:component-v1@0.1.0";
51 }
52);
53
54#[cfg(feature = "component-v0-6")]
55declare_world!(
56 mod component_v0_6,
57 path = "bundled-wit/greentic-component-0.6.0",
58 world = "greentic:component/component@0.6.0",
59 legacy = {
60 pub const PACKAGE_ID: &str = "greentic:component@0.6.0";
62 }
63);
64
65#[cfg(feature = "common-types-v0-1")]
66declare_world!(
67 mod common_types_v0_1,
68 path = "bundled-wit/greentic-common-types-0.1.0",
69 world = "greentic:common-types/common@0.1.0",
70 legacy = {
71 pub const PACKAGE_ID: &str = "greentic:common-types@0.1.0";
73 }
74);
75
76#[cfg(feature = "pack-export-v1")]
77declare_world!(
78 mod pack_export_v1,
79 path = "bundled-wit/greentic-pack-export-v1-0.1.0",
80 world = "greentic:pack-export-v1/pack-host@0.1.0",
81 legacy = {
82 pub const PACKAGE_ID: &str = "greentic:pack-export-v1@0.1.0";
84 }
85);
86
87#[cfg(feature = "pack-validate-v0-1")]
88declare_world!(
89 mod pack_validate_v0_1,
90 path = "bundled-wit/greentic-pack-validate-0.1.0",
91 world = "greentic:pack-validate/pack-validator@0.1.0",
92 legacy = {
93 pub const PACKAGE_ID: &str = "greentic:pack-validate@0.1.0";
95 }
96);
97
98#[cfg(feature = "provision-v0-1")]
99declare_world!(
100 mod provision_v0_1,
101 path = "bundled-wit/greentic-provision-0.1.0",
102 world = "greentic:provision/provision-runner@0.1.0",
103 legacy = {
104 pub const PACKAGE_ID: &str = "greentic:provision@0.1.0";
106 }
107);
108
109#[cfg(feature = "runner-host-v1")]
110declare_world!(
111 mod runner_host_v1,
112 path = "bundled-wit/greentic-host-1.0.0",
113 world = "greentic:host/runner-host@1.0.0",
114 legacy = {
115 use std::vec::Vec;
116 use wasmtime::component::Linker;
117 use wasmtime::{Result, StoreContextMut};
118
119 pub use generated::greentic::host::{http_v1, kv_v1};
120
121 pub trait RunnerHost {
123 fn http_request(
124 &mut self,
125 method: String,
126 url: String,
127 headers: Vec<String>,
128 body: Option<Vec<u8>>,
129 ) -> Result<Result<Vec<u8>, String>>;
130
131 fn kv_get(&mut self, ns: String, key: String) -> Result<Option<String>>;
132
133 fn kv_put(&mut self, ns: String, key: String, val: String) -> Result<()>;
134 }
135
136 pub fn add_to_linker<T>(
138 linker: &mut Linker<T>,
139 get_host: impl Fn(&mut T) -> &mut (dyn RunnerHost + Send + Sync + 'static)
140 + Send
141 + Sync
142 + Copy
143 + 'static,
144 ) -> Result<()>
145 where
146 T: Send + 'static,
147 {
148 let mut http = linker.instance("greentic:host/http-v1@1.0.0")?;
149 http.func_wrap(
150 "request",
151 move |mut caller: StoreContextMut<'_, T>,
152 (method, url, headers, body): (String, String, Vec<String>, Option<Vec<u8>>)| {
153 let host = get_host(caller.data_mut());
154 host.http_request(method, url, headers, body)
155 .map(|res| (res,))
156 },
157 )?;
158
159 let mut kv = linker.instance("greentic:host/kv-v1@1.0.0")?;
160 kv.func_wrap(
161 "get",
162 move |mut caller: StoreContextMut<'_, T>, (ns, key): (String, String)| {
163 let host = get_host(caller.data_mut());
164 host.kv_get(ns, key).map(|res| (res,))
165 },
166 )?;
167 kv.func_wrap(
168 "put",
169 move |mut caller: StoreContextMut<'_, T>, (ns, key, val): (String, String, String)| {
170 let host = get_host(caller.data_mut());
171 host.kv_put(ns, key, val)
172 },
173 )?;
174
175 Ok(())
176 }
177
178 pub const PACKAGE_ID: &str = "greentic:host@1.0.0";
180 }
181);
182
183#[cfg(feature = "operator-hooks-v1")]
184declare_world!(
185 mod operator_hook_provider_v1,
186 path = "bundled-wit/greentic-operator-1.0.0",
187 world = "greentic:operator/hook-provider@1.0.0",
188 legacy = {
189 pub const PACKAGE_ID: &str = "greentic:operator@1.0.0";
191 }
192);
193
194#[cfg(feature = "oauth-broker-v1")]
195declare_world!(
196 mod oauth_broker_v1,
197 path = "bundled-wit/greentic-oauth-broker-1.0.0",
198 world = "greentic:oauth-broker/broker@1.0.0",
199 legacy = {
200 pub const PACKAGE_ID: &str = "greentic:oauth-broker@1.0.0";
202 }
203);
204
205#[cfg(feature = "oauth-broker-v1")]
206declare_world!(
207 mod oauth_broker_client_v1,
208 path = "bundled-wit/greentic-oauth-broker-1.0.0",
209 world = "greentic:oauth-broker/broker-client@1.0.0",
210 legacy = {
211 pub const PACKAGE_ID: &str = "greentic:oauth-broker@1.0.0";
213 }
214);
215
216#[cfg(feature = "component-lifecycle-v1")]
217declare_world!(
218 mod component_lifecycle_v1,
219 path = "bundled-wit/greentic-lifecycle-1.0.0",
220 world = "greentic:lifecycle/component-lifecycle@1.0.0",
221 legacy = {
222 pub const PACKAGE_ID: &str = "greentic:lifecycle@1.0.0";
224 }
225);
226
227#[cfg(feature = "secrets-store-v1")]
228declare_world!(
229 mod secrets_store_v1,
230 path = "bundled-wit/greentic-secrets-store-1.0.0",
231 world = "greentic:secrets-store/store@1.0.0",
232 legacy = {
233 pub const PACKAGE_ID: &str = "greentic:secrets-store@1.0.0";
235 }
236);
237
238#[cfg(feature = "provider-core-v1")]
239declare_world!(
240 mod provider_schema_core_v1,
241 path = "bundled-wit/greentic-provider-schema-core-1.0.0",
242 world = "greentic:provider-schema-core/schema-core@1.0.0",
243 legacy = {
244 pub const PACKAGE_ID: &str = "greentic:provider-schema-core@1.0.0";
246 }
247);
248
249#[cfg(feature = "provider-instance-identity-v1")]
250declare_world!(
251 mod provider_instance_identity_v1,
252 path = "bundled-wit/greentic-provider-instance-identity-0.1.0",
253 world = "greentic:provider-instance-identity/instance-identity@0.1.0",
254 legacy = {
255 pub const PACKAGE_ID: &str = "greentic:provider-instance-identity@0.1.0";
257 }
258);
259
260#[cfg(feature = "provider-instance-identity-describe-v1")]
261declare_world!(
262 mod provider_instance_identity_describe_v1,
263 path = "bundled-wit/greentic-provider-instance-identity-0.1.0",
264 world = "greentic:provider-instance-identity/instance-identity-describe@0.1.0"
265);
266
267#[cfg(feature = "provider-common")]
268declare_world!(
269 mod provider_common,
270 path = "bundled-wit/provider-common-0.0.2",
271 world = "provider:common/common@0.0.2"
272);
273
274#[cfg(feature = "state-store-v1")]
275declare_world!(
276 mod state_store_v1,
277 path = "bundled-wit/greentic-state-1.0.0",
278 world = "greentic:state/store@1.0.0",
279 legacy = {
280 pub const PACKAGE_ID: &str = "greentic:state@1.0.0";
281 }
282);
283
284#[cfg(feature = "state-store-v1-1")]
285declare_world!(
286 mod state_store_v1_1,
287 path = "bundled-wit/greentic-state-1.1.0",
288 world = "greentic:state/store@1.1.0",
289 legacy = {
290 pub const PACKAGE_ID: &str = "greentic:state@1.1.0";
291 }
292);
293
294#[cfg(feature = "http-client-v1")]
295declare_world!(
296 mod http_client_v1,
297 path = "bundled-wit/greentic-http-1.0.0",
298 world = "greentic:http/client@1.0.0",
299 legacy = {
300 pub const PACKAGE_ID: &str = "greentic:http@1.0.0";
301 }
302);
303
304#[cfg(feature = "http-client-v1-1")]
305declare_world!(
306 mod http_client_v1_1,
307 path = "bundled-wit/greentic-http-1.1.0",
308 world = "greentic:http/client@1.1.0",
309 legacy = {
310 pub const PACKAGE_ID: &str = "greentic:http@1.1.0";
311 }
312);
313
314#[cfg(feature = "telemetry-logger-v1")]
315declare_world!(
316 mod telemetry_logger_v1,
317 path = "bundled-wit/greentic-telemetry-1.0.0",
318 world = "greentic:telemetry/logger@1.0.0",
319 legacy = {
320 pub const PACKAGE_ID: &str = "greentic:telemetry@1.0.0";
321 }
322);
323
324#[cfg(feature = "source-v1")]
325declare_world!(
326 mod source_v1,
327 path = "bundled-wit/greentic-source-1.0.0",
328 world = "greentic:source/source-sync@1.0.0",
329 legacy = {
330 pub const PACKAGE_ID: &str = "greentic:source@1.0.0";
331 }
332);
333
334#[cfg(feature = "build-v1")]
335declare_world!(
336 mod build_v1,
337 path = "bundled-wit/greentic-build-1.0.0",
338 world = "greentic:build/builder@1.0.0",
339 legacy = {
340 pub const PACKAGE_ID: &str = "greentic:build@1.0.0";
341 }
342);
343
344#[cfg(feature = "scan-v1")]
345declare_world!(
346 mod scan_v1,
347 path = "bundled-wit/greentic-scan-1.0.0",
348 world = "greentic:scan/scanner@1.0.0",
349 legacy = {
350 pub const PACKAGE_ID: &str = "greentic:scan@1.0.0";
351 }
352);
353
354#[cfg(feature = "signing-v1")]
355declare_world!(
356 mod signing_v1,
357 path = "bundled-wit/greentic-signing-1.0.0",
358 world = "greentic:signing/signer@1.0.0",
359 legacy = {
360 pub const PACKAGE_ID: &str = "greentic:signing@1.0.0";
361 }
362);
363
364#[cfg(feature = "attestation-v1")]
365declare_world!(
366 mod attestation_v1,
367 path = "bundled-wit/greentic-attestation-1.0.0",
368 world = "greentic:attestation/attester@1.0.0",
369 legacy = {
370 pub const PACKAGE_ID: &str = "greentic:attestation@1.0.0";
371 }
372);
373
374#[cfg(feature = "policy-v1")]
375declare_world!(
376 mod policy_v1,
377 path = "bundled-wit/greentic-policy-1.0.0",
378 world = "greentic:policy/policy-evaluator@1.0.0",
379 legacy = {
380 pub const PACKAGE_ID: &str = "greentic:policy@1.0.0";
381 }
382);
383
384#[cfg(feature = "metadata-v1")]
385declare_world!(
386 mod metadata_v1,
387 path = "bundled-wit/greentic-metadata-1.0.0",
388 world = "greentic:metadata/metadata-store@1.0.0",
389 legacy = {
390 pub const PACKAGE_ID: &str = "greentic:metadata@1.0.0";
391 }
392);
393
394#[cfg(feature = "distribution-v1")]
395declare_world!(
396 mod distribution_v1,
397 path = "bundled-wit/greentic-distribution-1.0.0",
398 world = "greentic:distribution/distribution@1.0.0",
399 legacy = {
400 pub const PACKAGE_ID: &str = "greentic:distribution@1.0.0";
401 }
402);
403
404#[cfg(feature = "distributor-api")]
405declare_world!(
406 mod distributor_api_v1,
407 path = "bundled-wit/greentic-distributor-api-1.0.0",
408 world = "greentic:distributor-api/distributor-api@1.0.0",
409 legacy = {
410 pub const PACKAGE_ID: &str = "greentic:distributor-api@1.0.0";
411 }
412);
413
414#[cfg(feature = "distributor-api-v1-1")]
415declare_world!(
416 mod distributor_api_v1_1,
417 path = "bundled-wit/greentic-distributor-api-1.1.0",
418 world = "greentic:distributor-api/distributor-api@1.1.0",
419 legacy = {
420 pub const PACKAGE_ID: &str = "greentic:distributor-api@1.1.0";
421 }
422);
423
424#[cfg(feature = "oci-v1")]
425declare_world!(
426 mod oci_v1,
427 path = "bundled-wit/greentic-oci-1.0.0",
428 world = "greentic:oci/oci-distribution@1.0.0",
429 legacy = {
430 pub const PACKAGE_ID: &str = "greentic:oci@1.0.0";
431 }
432);
433
434#[cfg(feature = "repo-ui-actions-v1")]
435declare_world!(
436 mod repo_ui_actions_repo_ui_worker_v1,
437 path = "bundled-wit/greentic-repo-ui-actions-1.0.0",
438 world = "greentic:repo-ui-actions/repo-ui-worker@1.0.0",
439 legacy = {
440 pub const PACKAGE_ID: &str = "greentic:repo-ui-actions@1.0.0";
441 }
442);
443
444#[cfg(feature = "gui-fragment")]
445declare_world!(
446 mod gui_fragment_v1,
447 path = "bundled-wit/greentic-gui-1.0.0",
448 world = "greentic:gui/gui-fragment@1.0.0",
449 legacy = {
450 pub const PACKAGE_ID: &str = "greentic:gui@1.0.0";
451 }
452);
453
454#[cfg(feature = "worker-api")]
455declare_world!(
456 mod worker_v1,
457 path = "bundled-wit/greentic-worker-1.0.0",
458 world = "greentic:worker/worker@1.0.0",
459 legacy = {
460 pub const PACKAGE_ID: &str = "greentic:worker@1.0.0";
461 }
462);
463
464#[cfg(feature = "wasix-mcp-24-11-05")]
465declare_world!(
466 mod wasix_mcp_24_11_05,
467 path = "wit/wasix-mcp@24.11.05.wit",
468 world = "mcp-router",
469 legacy = {
470 pub const PACKAGE_ID: &str = "wasix:mcp@24.11.5";
472 }
473);
474
475#[cfg(feature = "wasix-mcp-25-03-26")]
476declare_world!(
477 mod wasix_mcp_25_03_26,
478 path = "wit/wasix-mcp@25.03.26.wit",
479 world = "mcp-router",
480 legacy = {
481 pub const PACKAGE_ID: &str = "wasix:mcp@25.3.26";
483 }
484);
485
486#[cfg(feature = "wasix-mcp-25-06-18")]
487declare_world!(
488 mod wasix_mcp_25_06_18,
489 path = "wit/wasix-mcp@25.06.18.wit",
490 world = "mcp-router",
491 legacy = {
492 pub const PACKAGE_ID: &str = "wasix:mcp@25.6.18";
494 }
495);