@stacksjs/types 0.61.18 → 0.61.20

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/types",
3
3
  "type": "module",
4
- "version": "0.61.18",
4
+ "version": "0.61.20",
5
5
  "description": "The Stacks framework types.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -55,7 +55,7 @@
55
55
  "@rollup/pluginutils": "^5.1.0",
56
56
  "@stacksjs/validation": "latest",
57
57
  "@types/aws4": "^1.11.6",
58
- "@types/bun": "^1.1.2",
58
+ "@types/bun": "^1.1.3",
59
59
  "@types/crypto-js": "^4.2.2",
60
60
  "@types/fs-extra": "^11.0.4",
61
61
  "@types/markdown-it-link-attributes": "^3.0.5",
@@ -78,7 +78,7 @@
78
78
  "vue": "^3.4.27"
79
79
  },
80
80
  "devDependencies": {
81
- "aws-cdk-lib": "^2.142.1",
81
+ "aws-cdk-lib": "^2.143.0",
82
82
  "typescript": "^5.4.5"
83
83
  }
84
84
  }
@@ -1 +1,9 @@
1
- export type ModelNames = 'Project' | 'AccessToken' | 'Team' | 'Subscriber' | 'Deployment' | 'User' | 'Post'
1
+ export type ModelNames =
2
+ | 'Project'
3
+ | 'SubscriberEmail'
4
+ | 'AccessToken'
5
+ | 'Team'
6
+ | 'Subscriber'
7
+ | 'Deployment'
8
+ | 'User'
9
+ | 'Post'
package/src/model.ts CHANGED
@@ -25,6 +25,10 @@ export interface TimestampOptions {
25
25
  deletedAt?: string
26
26
  }
27
27
 
28
+ interface ValidatorMessage {
29
+ [key: string]: string
30
+ }
31
+
28
32
  export interface SoftDeleteOptions {
29
33
  deletedAt?: string // defaults to 'deleted_at' & can be used for localized tables
30
34
  }
@@ -116,7 +120,7 @@ export interface Attribute {
116
120
  factory?: () => any
117
121
  validator?: {
118
122
  rule: VineType
119
- message: string
123
+ message: ValidatorMessage
120
124
  }
121
125
  // validation?: String | Number | Boolean | Date
122
126
  }
package/src/router.ts CHANGED
@@ -1,36 +1,6 @@
1
1
  import type { Action } from '@stacksjs/actions'
2
- import type { ActionPath } from '~/storage/framework/types/actions'
3
2
 
4
- export interface NitroEventHandler {
5
- /**
6
- * Path prefix or route
7
- *
8
- * If an empty string used, will be used as a middleware
9
- */
10
- route?: string
11
-
12
- /**
13
- * Specifies this is a middleware handler.
14
- * Middleware are called on every route and should normally return nothing to pass to the next handlers
15
- */
16
- middleware?: boolean
17
-
18
- /**
19
- * Use lazy loading to import handler
20
- */
21
- lazy?: boolean
22
-
23
- /**
24
- * Path to event handler
25
- *
26
- */
27
- handler: string
28
-
29
- /**
30
- * Router method matcher
31
- */
32
- method?: string
33
- }
3
+ type ActionPath = string // TODO: narrow this by automating its generation
34
4
 
35
5
  // need to refactor before, after, view to be a part of some other type
36
6
  export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'before' | 'after' | 'view'
@@ -40,7 +10,9 @@ export type RouteCallback = (params?: Record<string, any>) => any | string | obj
40
10
  export interface Route {
41
11
  name: string
42
12
  uri: string
43
- url: string // used synonymously with uri
13
+ url: string // used synonymously with uri, TODO: narrow this type by ensuring it's generated
14
+ path?: string
15
+ prefix?: string
44
16
  method: HttpMethod
45
17
  pattern: RegExp
46
18
  callback: RouteCallback | ActionPath | Action | Promise<any> // we may be able to improve the `Promise<any>` if we could narrow this type `import('../app/Actions/BuddyAction')`
@@ -59,6 +31,8 @@ export interface MiddlewareOptions {
59
31
  export type StatusCode = 200 | 201 | 202 | 204 | 301 | 302 | 304 | 400 | 401 | 403 | 404 | 500
60
32
  export type RedirectCode = Extract<StatusCode, 301 | 302>
61
33
 
34
+ export type RouteParam = { [key: string]: string | number } | null
35
+
62
36
  export type MiddlewareFn = () => void
63
37
 
64
38
  export interface Middlewares {
@@ -75,7 +49,7 @@ export interface RouteGroupOptions {
75
49
  type Prefix = string
76
50
 
77
51
  export interface RouterInterface {
78
- get: (url: Route['url'], callback: Route['callback']) => Promise<this>
52
+ get: (url: Route['url'], callback: Route['callback']) => this
79
53
  post: (url: Route['url'], callback: Route['callback']) => this
80
54
  view: (url: Route['url'], callback: Route['callback']) => this
81
55
  redirect: (url: Route['url'], callback: Route['callback'], status?: RedirectCode) => this