@archtx/procedures 6.0.0 → 6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archtx/procedures",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "Procedure generator for @archtx",
5
5
  "main": "dist/exports.js",
6
6
  "types": "dist/exports.d.ts",
@@ -33,12 +33,12 @@
33
33
  "suretype": "^3.3.1"
34
34
  },
35
35
  "devDependencies": {
36
- "typebox": "^1.0.30",
37
- "@types/jest": "^29.5.11",
38
- "@typescript-eslint/eslint-plugin": "^5.48.1",
39
- "@typescript-eslint/parser": "^5.48.1",
40
- "eslint": "^8.56.0",
36
+ "@eslint/js": "^9.17.0",
37
+ "@types/jest": "^29.5.14",
38
+ "eslint": "^9.17.0",
41
39
  "suretype": "^3.3.1",
42
- "vitest": "^3.0.8"
40
+ "typebox": "^1.0.77",
41
+ "typescript-eslint": "^8.53.0",
42
+ "vitest": "^3.2.4"
43
43
  }
44
44
  }
package/src/index.ts CHANGED
@@ -17,11 +17,14 @@ export type TLocalContext = {
17
17
  ) => ProcedureError
18
18
  }
19
19
 
20
- export type TProcedureRegistration<TExtendedConfig = unknown> = {
20
+ export type TProcedureRegistration<
21
+ TContext = unknown,
22
+ TExtendedConfig = unknown,
23
+ > = {
21
24
  name: string
22
25
  config: {
23
26
  description?: string
24
- hook?: (ctx: any, args?: any) => any
27
+ hook?: (ctx: TContext, args?: any) => any
25
28
  schema?: {
26
29
  args?: TJSONSchema
27
30
  data?: TJSONSchema
@@ -31,7 +34,7 @@ export type TProcedureRegistration<TExtendedConfig = unknown> = {
31
34
  }
32
35
  } & TExtendedConfig
33
36
 
34
- handler: (ctx: any, args?: any) => Promise<any>
37
+ handler: (ctx: TContext, args?: any) => Promise<any>
35
38
  }
36
39
 
37
40
  export function Procedures<
@@ -42,14 +45,50 @@ export function Procedures<
42
45
  * Optionally provided builder to register Procedures
43
46
  */
44
47
  builder?: {
45
- onCreate?: (config: TProcedureRegistration<TExtendedConfig>) => void
48
+ onCreate?: (
49
+ procedure: Prettify<{
50
+ name: string
51
+ handler: (ctx: Prettify<TContext>, args?: any) => Promise<any>
52
+ config: Prettify<
53
+ {
54
+ description?: string
55
+ hook?: (
56
+ ctx: Prettify<TContext & TLocalContext>,
57
+ args?: any,
58
+ ) => Promise<any>
59
+ schema?: {
60
+ args?: TJSONSchema
61
+ data?: TJSONSchema
62
+ }
63
+ validation?: {
64
+ args?: (args: any) => { errors?: any[] }
65
+ }
66
+ } & TExtendedConfig
67
+ >
68
+ }>,
69
+ ) => void
46
70
  },
47
71
  ) {
48
72
  const procedures: Map<
49
73
  string,
50
74
  {
51
75
  name: string
52
- config: TProcedureRegistration['config']
76
+ config: Prettify<
77
+ {
78
+ description?: string
79
+ hook?: (
80
+ ctx: Prettify<TContext & TLocalContext>,
81
+ args?: any,
82
+ ) => Promise<any>
83
+ schema?: {
84
+ args?: TJSONSchema
85
+ data?: TJSONSchema
86
+ }
87
+ validation?: {
88
+ args?: (args: any) => { errors?: any[] }
89
+ }
90
+ } & TExtendedConfig
91
+ >
53
92
  handler: (ctx: Prettify<TContext>, args: any) => Promise<any>
54
93
  }
55
94
  > = new Map()