{"version":3,"file":"exposure.mjs","names":["selections","executors","selectOperation","owner","key","kind","definition","selected","bindOperationExecutor","configuration","executor","operationToolDialect","createOperationTools","entries","definitions","tools","name","paired","args","schemaSnapshot","errors","raw","error","ConvexError","schemaKeywords","types","textKeywords","countKeywords","numberKeywords","scalarKeywords","seen","copy","value","isRecord","item","check","schema","child","type","field","snapshot","prototype"],"sources":["../../../src/modules/contracts/exposure.ts"],"sourcesContent":["/* oxlint-disable anti-slop/no-unknown-parameters, anti-slop/no-unknown-type-aliases, anti-slop/no-runtime-typeof, anti-slop/no-unsafe-dictionary-type -- Selected native transport boundaries validate opaque identities and converter JSON without decoding domain inputs. */\nimport { ConvexError } from 'convex/values'\nimport type { ContractInput, ContractOutput, ContractSchema } from './contract'\nimport type { DecodedFailure, ErrorContract, ErrorDefinitions, UnknownFailure } from './errors'\n\ndeclare const selectedTypes: unique symbol\ndeclare const executorTypes: unique symbol\n\ntype Definition = {\n\tinput: ContractSchema\n\tresult: ContractSchema\n\twire?: { schema: ContractSchema }\n}\nexport type OperationPublicResult<D extends Definition> = D extends {\n\twire: { schema: infer Schema extends ContractSchema }\n}\n\t? ContractInput<Schema>\n\t: ContractOutput<D['result']>\n\n/** Only the selected input/public contracts are exposed, never handlers or other operations. */\nexport type SelectedOperation<\n\tOwner extends symbol,\n\tKey extends string,\n\tInput extends ContractSchema,\n\tPublic,\n> = Readonly<{\n\towner: Owner\n\tkey: Key\n\tkind: 'mutation' | 'query'\n\tinput: Input\n\tresult: ContractSchema\n\treadonly [selectedTypes]: { readonly input: ContractInput<Input>; readonly public: Public }\n}>\ntype Selection = Readonly<{\n\towner: symbol\n\tkey: string\n\tkind: 'mutation' | 'query'\n\tinput: ContractSchema\n\tresult: ContractSchema\n\treadonly [selectedTypes]: { readonly input: unknown; readonly public: unknown }\n}>\ntype InputOf<S extends Selection> = S[typeof selectedTypes]['input']\ntype PublicOf<S extends Selection> = S[typeof selectedTypes]['public']\n\nconst selections = new WeakSet<object>()\nconst executors = new WeakMap<\n\tobject,\n\t{\n\t\tselection: Selection\n\t\t// oxlint-disable-next-line anti-slop/no-unknown-returns -- Private heterogeneous storage erases public result types; selected identity checks recover the exact raw/public pair at invocation.\n\t\texecute: (input: never) => Promise<unknown>\n\t}\n>()\n\n/** Registry integrators must check membership before selecting their own definition. */\nexport function selectOperation<\n\tconst Owner extends symbol,\n\tconst Key extends string,\n\tconst D extends Definition,\n>(\n\towner: Owner,\n\tkind: 'mutation' | 'query',\n\tkey: Key,\n\tdefinition: D,\n): SelectedOperation<Owner, Key, D['input'], OperationPublicResult<D>> {\n\tif (\n\t\ttypeof owner !== 'symbol' ||\n\t\t!key ||\n\t\t(kind !== 'mutation' && kind !== 'query') ||\n\t\t!definition?.input ||\n\t\t!definition.result\n\t) {\n\t\tthrow Error('Invalid selected operation')\n\t}\n\t// SAFETY: private identity records this exact paired schema; its type-only slots are never read at runtime.\n\tconst selected = Object.freeze({\n\t\towner,\n\t\tkey,\n\t\tkind,\n\t\tinput: definition.input,\n\t\tresult: definition.wire?.schema ?? definition.result,\n\t}) as SelectedOperation<Owner, Key, D['input'], OperationPublicResult<D>>\n\tselections.add(selected)\n\treturn selected\n}\n\nexport type OperationExecutor<S extends Selection> = Readonly<{\n\towner: S['owner']\n\tkey: S['key']\n\treadonly [executorTypes]: S\n}>\n\n/** The host captures authority in an already authorized native Promise call. */\nexport function bindOperationExecutor<const S extends Selection>(\n\tselected: S,\n\tconfiguration: {\n\t\towner: NoInfer<S['owner']>\n\t\tkey: NoInfer<S['key']>\n\t\texecute: (raw: NoInfer<InputOf<S>>) => Promise<NoInfer<PublicOf<S>>>\n\t},\n): OperationExecutor<S> {\n\tif (\n\t\t!selections.has(selected) ||\n\t\tconfiguration.owner !== selected.owner ||\n\t\tconfiguration.key !== selected.key ||\n\t\ttypeof configuration.execute !== 'function'\n\t) {\n\t\tthrow Error('Executor does not own the selected operation')\n\t}\n\t// SAFETY: the private map restores the concrete selected raw/public pair only after identity checks.\n\tconst executor = Object.freeze({\n\t\towner: selected.owner,\n\t\tkey: selected.key,\n\t}) as OperationExecutor<S>\n\texecutors.set(executor, {\n\t\tselection: selected,\n\t\texecute: configuration.execute,\n\t})\n\treturn executor\n}\n\nexport const operationToolDialect = 'https://json-schema.org/draft/2020-12/schema' as const\ntype Json = null | boolean | number | string | readonly Json[] | { readonly [key: string]: Json }\nexport type OperationToolJsonSchema = Readonly<{ [keyword: string]: Json }>\nexport type OperationToolConverter<Input extends ContractSchema = ContractSchema> = Readonly<{\n\tdialect: typeof operationToolDialect\n\t/** Represent raw transport input. Unsupported IDs/transforms must throw, never be approximated. */\n\tconvert: (input: Input) => OperationToolJsonSchema\n}>\nexport type OperationToolDefinition<\n\tS extends Selection = Selection,\n\tErrors extends ErrorDefinitions = ErrorDefinitions,\n> = Readonly<{\n\toperation: S\n\texecutor: OperationExecutor<S>\n\tdescription: string\n\tconverter: OperationToolConverter<S['input']>\n\terrors?: Pick<ErrorContract<Errors>, 'decode'>\n}>\ntype ToolConstraint = Readonly<{\n\toperation: Selection\n\texecutor: OperationExecutor<Selection>\n\tdescription: string\n\tconverter: {\n\t\tdialect: typeof operationToolDialect\n\t\tconvert: (input: never) => OperationToolJsonSchema\n\t}\n\terrors?: Pick<ErrorContract<ErrorDefinitions>, 'decode'>\n}>\ntype Checked<T extends ToolConstraint> = T & OperationToolDefinition<T['operation']>\ntype FailureOf<T> = T extends { errors: Pick<ErrorContract<infer E>, 'decode'> }\n\t? DecodedFailure<E>\n\t: UnknownFailure\nexport type OperationToolOutcome<Public, Failure = UnknownFailure> =\n\t| Readonly<{ _tag: 'Success'; value: Public }>\n\t| Failure\nexport type OperationTool<T extends ToolConstraint> = Readonly<{\n\tname: string\n\tdescription: string\n\targs: OperationToolJsonSchema\n\tinvoke: (\n\t\traw: InputOf<T['operation']>,\n\t) => Promise<OperationToolOutcome<PublicOf<T['operation']>, FailureOf<T>>>\n}>\n\nexport function createOperationTools<const T extends Readonly<Record<string, ToolConstraint>>>(\n\tdefinitions: T & { [K in keyof T]: Checked<T[K]> },\n): Readonly<{ [K in keyof T]: OperationTool<T[K]> }>\nexport function createOperationTools<\n\tconst T extends readonly (ToolConstraint & { name: string })[],\n>(\n\tdefinitions: T & { [K in keyof T]: Checked<T[K]> },\n): Readonly<{ [D in T[number] as D['name']]: OperationTool<D> }>\nexport function createOperationTools(\n\tdefinitions:\n\t\t| Readonly<Record<string, ToolConstraint>>\n\t\t| readonly (ToolConstraint & { name: string })[],\n): Readonly<Record<string, OperationTool<ToolConstraint>>> {\n\tconst entries = Array.isArray(definitions)\n\t\t? definitions.map((definition) => [definition.name, definition] as const)\n\t\t: Object.entries(definitions)\n\tconst tools: Record<string, OperationTool<ToolConstraint>> = Object.create(null)\n\tfor (const [name, definition] of entries) {\n\t\tif (!name || Object.hasOwn(tools, name)) throw Error('Duplicate or empty operation tool name')\n\t\tconst paired = definition.executor && executors.get(definition.executor)\n\t\tif (\n\t\t\t!selections.has(definition.operation) ||\n\t\t\t!paired ||\n\t\t\tpaired.selection !== definition.operation\n\t\t)\n\t\t\tthrow Error('Tool requires its selected operation executor')\n\t\tif (\n\t\t\t!definition.description ||\n\t\t\tdefinition.converter?.dialect !== operationToolDialect ||\n\t\t\ttypeof definition.converter.convert !== 'function'\n\t\t)\n\t\t\tthrow Error('Unsupported operation tool converter')\n\t\t// Conversion never executes the input decoder, and invocation never executes conversion.\n\t\t// SAFETY: the checked tool overload pairs the converter with this selected input schema; the never cast bridges heterogeneous iteration without changing the schema.\n\t\tconst args = schemaSnapshot(definition.converter.convert(definition.operation.input as never))\n\t\tconst errors = definition.errors\n\t\ttools[name] = Object.freeze({\n\t\t\tname,\n\t\t\tdescription: definition.description,\n\t\t\targs,\n\t\t\tasync invoke(raw: unknown) {\n\t\t\t\ttry {\n\t\t\t\t\t// SAFETY: binding owns this raw/public pair and its native boundary performs decoding/policy/projection.\n\t\t\t\t\treturn { _tag: 'Success' as const, value: await paired.execute(raw as never) }\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// This catch runs only after the native call rejects. Native mutations retain rollback semantics.\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (error instanceof ConvexError && errors) return errors.decode(error.data)\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t/* Invalid host error decoders cannot publish diagnostics. */\n\t\t\t\t\t}\n\t\t\t\t\treturn { _tag: 'UnknownFailure' as const, version: 1 as const }\n\t\t\t\t}\n\t\t\t},\n\t\t})\n\t}\n\treturn Object.freeze(tools)\n}\n\nconst schemaKeywords = new Set([\n\t'properties',\n\t'$defs',\n\t'items',\n\t'additionalProperties',\n\t'anyOf',\n\t'oneOf',\n\t'allOf',\n\t'not',\n\t'required',\n\t'enum',\n\t'const',\n\t'default',\n\t'examples',\n])\nconst types = new Set(['object', 'array', 'string', 'number', 'integer', 'boolean', 'null'])\nconst textKeywords = new Set([\n\t'title',\n\t'description',\n\t'format',\n\t'pattern',\n\t'$ref',\n\t'$id',\n\t'x-convex-table',\n])\nconst countKeywords = new Set([\n\t'minLength',\n\t'maxLength',\n\t'minItems',\n\t'maxItems',\n\t'minProperties',\n\t'maxProperties',\n])\nconst numberKeywords = new Set([\n\t'minimum',\n\t'maximum',\n\t'exclusiveMinimum',\n\t'exclusiveMaximum',\n\t'multipleOf',\n])\nconst scalarKeywords = new Set([\n\t...textKeywords,\n\t...countKeywords,\n\t...numberKeywords,\n\t'type',\n\t'uniqueItems',\n\t'$schema',\n])\n\nfunction schemaSnapshot(value: OperationToolJsonSchema): OperationToolJsonSchema {\n\tconst seen = new Set<object>()\n\tfunction copy(value: Json): Json {\n\t\tif (value === null || typeof value === 'string' || typeof value === 'boolean') return value\n\t\tif (typeof value === 'number' && Number.isFinite(value)) return value\n\t\tif (typeof value !== 'object' || seen.has(value))\n\t\t\tthrow Error('Converter schema must be JSON safe')\n\t\tseen.add(value)\n\t\ttry {\n\t\t\tif (Array.isArray(value)) return Object.freeze(value.map(copy))\n\t\t\tif (!isRecord(value)) throw Error('Converter schema must be a plain JSON object')\n\t\t\treturn Object.freeze(\n\t\t\t\tObject.fromEntries(Object.entries(value).map(([key, item]) => [key, copy(item)])),\n\t\t\t)\n\t\t} finally {\n\t\t\tseen.delete(value)\n\t\t}\n\t}\n\tfunction check(schema: Json): void {\n\t\tif (typeof schema === 'boolean') return\n\t\tif (!isRecord(schema)) throw Error('Unsupported JSON Schema shape')\n\t\tfor (const [key, child] of Object.entries(schema)) {\n\t\t\tif (!scalarKeywords.has(key) && !schemaKeywords.has(key))\n\t\t\t\tthrow Error('Unsupported JSON Schema keyword')\n\t\t\tif (textKeywords.has(key) && typeof child !== 'string')\n\t\t\t\tthrow Error('Invalid JSON Schema text keyword')\n\t\t\tif (\n\t\t\t\tcountKeywords.has(key) &&\n\t\t\t\t(typeof child !== 'number' || !Number.isInteger(child) || child < 0)\n\t\t\t)\n\t\t\t\tthrow Error('Invalid JSON Schema count keyword')\n\t\t\tif (\n\t\t\t\tnumberKeywords.has(key) &&\n\t\t\t\t(typeof child !== 'number' ||\n\t\t\t\t\t!Number.isFinite(child) ||\n\t\t\t\t\t(key === 'multipleOf' && child <= 0))\n\t\t\t)\n\t\t\t\tthrow Error('Invalid JSON Schema number keyword')\n\t\t\tif (key === 'uniqueItems' && typeof child !== 'boolean')\n\t\t\t\tthrow Error('Invalid JSON Schema boolean keyword')\n\t\t\tif (key === 'pattern') {\n\t\t\t\ttry {\n\t\t\t\t\t// SAFETY: pattern belongs to textKeywords and passed the string check above; this validates syntax without matching input.\n\t\t\t\t\tnew RegExp(child as string)\n\t\t\t\t} catch {\n\t\t\t\t\tthrow Error('Invalid JSON Schema pattern')\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ((key === 'enum' || key === 'examples') && !Array.isArray(child))\n\t\t\t\tthrow Error('Invalid JSON Schema array keyword')\n\t\t\tif (key === 'enum' && Array.isArray(child) && !child.length)\n\t\t\t\tthrow Error('Invalid JSON Schema enum')\n\t\t\tif (key === '$schema' && child !== operationToolDialect)\n\t\t\t\tthrow Error('Unsupported JSON Schema dialect')\n\t\t\tif (\n\t\t\t\tkey === 'type' &&\n\t\t\t\t!(typeof child === 'string' && types.has(child)) &&\n\t\t\t\t!(\n\t\t\t\t\tArray.isArray(child) &&\n\t\t\t\t\tchild.length > 0 &&\n\t\t\t\t\tchild.every((type) => typeof type === 'string' && types.has(type))\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow Error('Unsupported JSON Schema type')\n\t\t\tif (key === 'properties' || key === '$defs') {\n\t\t\t\tif (!isRecord(child)) throw Error('Unsupported JSON Schema properties')\n\t\t\t\tObject.values(child).forEach(check)\n\t\t\t} else if (key === 'items' || key === 'not' || key === 'additionalProperties') check(child)\n\t\t\telse if (key === 'anyOf' || key === 'oneOf' || key === 'allOf') {\n\t\t\t\tif (!Array.isArray(child) || !child.length)\n\t\t\t\t\tthrow Error('Unsupported JSON Schema alternatives')\n\t\t\t\tchild.forEach(check)\n\t\t\t} else if (\n\t\t\t\tkey === 'required' &&\n\t\t\t\t(!Array.isArray(child) ||\n\t\t\t\t\tchild.some((field) => typeof field !== 'string') ||\n\t\t\t\t\tnew Set(child).size !== child.length)\n\t\t\t)\n\t\t\t\tthrow Error('Unsupported JSON Schema required fields')\n\t\t}\n\t}\n\tconst snapshot = copy(value)\n\tif (!isRecord(snapshot) || snapshot.type !== 'object')\n\t\tthrow Error('Operation tool arguments require an object JSON Schema')\n\tcheck(snapshot)\n\treturn snapshot\n}\nfunction isRecord(value: Json): value is { readonly [key: string]: Json } {\n\tif (value === null || typeof value !== 'object' || Array.isArray(value)) return false\n\tconst prototype = Object.getPrototypeOf(value)\n\treturn prototype === Object.prototype || prototype === null\n}\n"],"mappings":"4CA4CA,MAAMA,kBAAa,IAAI,QACjBC,kBAAY,IAAI,QAUtB,SAAgBC,EAKf,EACA,EACA,EACA,EACsE,CACtE,GACC,OAAOC,GAAU,UACjB,CAACC,GACAC,IAAS,YAAcA,IAAS,SACjC,CAACC,GAAY,OACb,CAACA,EAAW,OAEZ,MAAM,MAAM,4BAA4B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