diff --git a/packages/server/src/handler.js b/packages/server/src/handler.js index cd64dc2f..ca8ce8eb 100644 --- a/packages/server/src/handler.js +++ b/packages/server/src/handler.js @@ -10,10 +10,12 @@ import { access, Schema, Failure } from '@ucanto/validator' * @template {API.Ability} A * @template {API.URI} R * @template {API.Caveats} C - * @template {API.Result<{}, {}>} Result + * @template {{}} O + * @template {API.Failure} X + * @template {API.Result} Result * @param {API.CapabilityParser>>} capability * @param {(input:API.ProviderInput>) => API.Await} handler - * @returns {API.ServiceMethod, Result['ok'] & {}, Result['error'] & {}>} + * @returns {API.ServiceMethod, O & Result['ok'], X & Result['error']>} */ export const provide = (capability, handler) => @@ -31,12 +33,13 @@ export const provide = (capability, handler) => * @template {API.URI} R * @template {API.Caveats} C * @template {{}} O - * @template {{}} X + * @template {API.Failure} X + * @template {API.Result} Result * @param {object} input * @param {API.Reader} [input.audience] * @param {API.CapabilityParser>>} input.capability - * @param {(input:API.ProviderInput>) => API.Await>} input.handler - * @returns {API.ServiceMethod, O, X>} + * @param {(input:API.ProviderInput>) => API.Await} input.handler + * @returns {API.ServiceMethod, O & Result['ok'], X & Result['error']>} */ export const provideAdvanced = diff --git a/packages/server/test/handler.spec.js b/packages/server/test/handler.spec.js index 3729d872..091be987 100644 --- a/packages/server/test/handler.spec.js +++ b/packages/server/test/handler.spec.js @@ -240,7 +240,7 @@ test('test access/claim provider', async () => { /** * @type {Client.ConnectionView<{ * access: { - * claim: API.ServiceMethod, never[], {}> + * claim: API.ServiceMethod, never[], API.Failure> * } * }>} */ @@ -350,19 +350,19 @@ test('union result', () => { }) /** - * @type {API.ServiceMethod, ({status: 'done'}|{status:'pending', progress: number}), {}>} + * @type {API.ServiceMethod, ({status: 'done'}|{status:'pending', progress: number}), API.Failure>} */ const provider = Provider.provide(add, async ({ capability }) => { if (capability.nb.key === 'done') { return { ok: { - status: /** @type {const} */ ('done'), + status: 'done', }, } } else { return { ok: { - status: /** @type {const} */ ('pending'), + status: 'pending', progress: 5, }, }