@archtx/procedures 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/schema/types.d.ts +3 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/index.ts +8 -8
- package/src/schema/types.ts +5 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from './errors.js'
|
|
6
6
|
import { ProcedureCodes } from './procedure-codes.js'
|
|
7
7
|
import { computeSchema } from './schema/compute-schema.js'
|
|
8
|
-
import { TJSONSchema, TSchemaLib } from './schema/types.js'
|
|
8
|
+
import { Prettify, TJSONSchema, TSchemaLib } from './schema/types.js'
|
|
9
9
|
|
|
10
10
|
export type TNoContextProvided = unknown
|
|
11
11
|
|
|
@@ -47,7 +47,7 @@ export function Procedures<TContext = TNoContextProvided>(
|
|
|
47
47
|
{
|
|
48
48
|
name: string
|
|
49
49
|
config: TProcedureRegistration['config']
|
|
50
|
-
handler: (ctx: TContext
|
|
50
|
+
handler: (ctx: Prettify<TContext>, args: any) => Promise<any>
|
|
51
51
|
}
|
|
52
52
|
> = new Map()
|
|
53
53
|
|
|
@@ -56,21 +56,21 @@ export function Procedures<TContext = TNoContextProvided>(
|
|
|
56
56
|
config: {
|
|
57
57
|
description?: string
|
|
58
58
|
hook?: (
|
|
59
|
-
ctx: TContext & TLocalContext
|
|
59
|
+
ctx: Prettify<TContext & TLocalContext>,
|
|
60
60
|
args: TSchemaLib<TArgs>,
|
|
61
|
-
) => Promise<TLocalHook
|
|
61
|
+
) => Promise<Prettify<TLocalHook>>
|
|
62
62
|
schema?: {
|
|
63
63
|
args?: TArgs
|
|
64
64
|
data?: TData
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
handler: (
|
|
68
|
-
ctx: TContext & TLocalContext & TLocalHook
|
|
68
|
+
ctx: Prettify<TContext & TLocalContext & TLocalHook>,
|
|
69
69
|
args: TSchemaLib<TArgs>,
|
|
70
70
|
) => Promise<TSchemaLib<TData>>,
|
|
71
71
|
): {
|
|
72
72
|
[K in TName | `${TName}_Info`]: K extends TName
|
|
73
|
-
? (ctx: TContext
|
|
73
|
+
? (ctx: Prettify<TContext>, args: TSchemaLib<TArgs>) => Promise<TSchemaLib<TData>>
|
|
74
74
|
: {
|
|
75
75
|
description?: string
|
|
76
76
|
schema: {
|
|
@@ -92,7 +92,7 @@ export function Procedures<TContext = TNoContextProvided>(
|
|
|
92
92
|
},
|
|
93
93
|
},
|
|
94
94
|
|
|
95
|
-
handler: async (ctx: TContext
|
|
95
|
+
handler: async (ctx: Prettify<TContext>, args: TSchemaLib<TArgs>) => {
|
|
96
96
|
try {
|
|
97
97
|
if (validations?.args) {
|
|
98
98
|
const { errors } = validations.args(args)
|
|
@@ -143,7 +143,7 @@ export function Procedures<TContext = TNoContextProvided>(
|
|
|
143
143
|
...ctx,
|
|
144
144
|
...localCtx,
|
|
145
145
|
...computedLocalHook,
|
|
146
|
-
} as TContext & TLocalContext & TLocalHook
|
|
146
|
+
} as Prettify<TContext & TLocalContext & TLocalHook>,
|
|
147
147
|
args,
|
|
148
148
|
)
|
|
149
149
|
} catch (error: any) {
|
package/src/schema/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
1
2
|
import { CoreValidator, TypeOf } from 'suretype'
|
|
2
3
|
import { Static, TSchema } from '@sinclair/typebox'
|
|
3
4
|
|
|
@@ -10,3 +11,7 @@ export type TSchemaLib<SchemaLibType> =
|
|
|
10
11
|
: unknown
|
|
11
12
|
|
|
12
13
|
export type TJSONSchema = Record<string, any>
|
|
14
|
+
|
|
15
|
+
export type Prettify<TObject> = {
|
|
16
|
+
[Key in keyof TObject]: TObject[Key]
|
|
17
|
+
} & {}
|