package alga:extension; interface types { record context-data { request-id: option, tenant-id: string, extension-id: string, install-id: option, version-id: option, } enum secret-error { missing, denied, expired, internal, } record http-header { name: string, value: string, } record http-request { method: string, url: string, headers: list, body: option>, } record http-response { status: u16, headers: list, body: option>, } enum http-error { invalid-url, not-allowed, transport, internal, } enum storage-error { missing, conflict, denied, internal, } record storage-entry { namespace: string, key: string, value: list, revision: option, } enum proxy-error { route-not-found, denied, bad-request, internal, } record user-data { tenant-id: string, client-name: string, user-id: string, user-email: string, user-name: string, user-type: string, } enum user-error { not-available, not-allowed, } record execute-request { context: context-data, http: http-request, } record execute-response { status: u16, headers: list, body: option>, } } interface context { use types.{context-data}; get-context: func() -> context-data; } interface secrets { use types.{secret-error}; get: func(key: string) -> result; list-keys: func() -> list; } interface http { use types.{http-request, http-response, http-error}; fetch: func(request: http-request) -> result; } interface storage { use types.{storage-entry, storage-error}; get: func(namespace: string, key: string) -> result; put: func(entry: storage-entry) -> result; delete: func(namespace: string, key: string) -> result<_, storage-error>; list-entries: func(namespace: string, cursor: option) -> result, storage-error>; } interface logging { log-info: func(message: string); log-warn: func(message: string); log-error: func(message: string); } interface ui-proxy { use types.{proxy-error}; call-route: func(route: string, payload: option>) -> result, proxy-error>; } interface user { use types.{user-data, user-error}; get-user: func() -> result; } world runner { use types.{execute-request, execute-response}; import context; import secrets; import http; import storage; import logging; import ui-proxy; import user; export handler: func(request: execute-request) -> execute-response; }