import { ResourceDefinition, SharedResourcesProvider } from '../types/innerFunction'; import { Utilities } from '../types/function'; import { SharedResourceFetchRequest, SharedResourceInput, V2ResourceScope, V2ResourceDescriptor } from '../types/customFunction'; export type DefineResourceInput = { name: string; scope?: V2ResourceScope; fetch: ResourceDefinition['fetch']; }; /** * Build a MEXWEX V2 resource declaration for `CustomFunctionParams.resources`. * * Validates the shape eagerly so a mis-declared resource fails at bundle import * time rather than at the first lambda invocation. Defaults scope to 'Instance' * (the common case — resource keyed on contextObjectId). * * Static-scope resources receive a handler context with `contextObjectId` * stripped by the dispatcher (see createResourceFetchHandler). */ export declare const defineResource: (def: DefineResourceInput) => ResourceDefinition; /** * Validate a collection of resource definitions (uniqueness of `name`). * * Called by `createResourceFetchHandler` at lambda boot. Also re-usable from a * build-time validator if the form bundle pipeline wants the same check. */ export declare const validateResourceDefinitions: (resources: ResourceDefinition[]) => void; /** * Extract the V2ResourceDescriptor list (name + scope) from a `params.resources` * array. This is what gets mirrored to `CustomFunctionFeatures.resources` so the * backend can list resources without unpacking the lambda. */ export declare const toResourceDescriptors: (resources: ResourceDefinition[]) => V2ResourceDescriptor[]; /** * Normalise a shared function's resource declaration into V2ResourceDescriptor[]. * * Accepts BOTH the scope-map form (`{ Instance: ['a'], Static: ['c'] }`) and an * explicit `{ name, scope }[]` descriptor array. Missing scope defaults to * 'Instance'. Validates scope values and (via validateResourceDefinitions) name * uniqueness so a mis-declared provider fails at build/enumeration time rather * than at the first lambda invocation. */ export declare const normalizeSharedResources: (input: SharedResourceInput) => V2ResourceDescriptor[]; /** * Author-facing helper: build the V2ResourceDescriptor[] a shared function's * factory returns as `resources`. Thin wrapper over normalizeSharedResources so * the authoring contract reads `resources: generateResource({ Instance: [...] })`. */ export declare const generateResource: (input: SharedResourceInput) => V2ResourceDescriptor[]; /** * Resolve a shared function's `resources` declaration to descriptors. * * Called at BUILD time only. When `resources` is a thunk it is invoked with a * real `input` (services authenticated with the tenant admin token pkgr gives the * builder), so the list may be derived from live tenant data. The lambda never * calls this — it receives each name's scope on the wire instead. * * `input` is optional so a static declaration can be enumerated offline (the * author's `generate-info.ts`). A thunk without one throws rather than silently * yielding an empty catalog. * * `resources` itself is optional: a changeset-only shared function declares none, * and serves an empty catalog rather than failing to enumerate. */ export declare const resolveSharedResources: (resources?: SharedResourcesProvider, input?: Utilities) => Promise; /** * Read the requested resources off a shared /resource_fetch body. * * Prefers the `resources` descriptor array. Falls back to the deprecated * `names: string[]`, defaulting every name to Instance scope — the pre-existing * behaviour, kept so the SDK can ship ahead of a backend that still sends names. */ export declare const resolveRequestedResources: (body: SharedResourceFetchRequest) => V2ResourceDescriptor[]; //# sourceMappingURL=defineResource.d.ts.map