@stacksjs/types 0.68.2 → 0.69.2

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.
Files changed (53) hide show
  1. package/dist/ai.d.ts +4 -2
  2. package/dist/app.d.ts +4 -2
  3. package/dist/attributes.d.ts +1 -0
  4. package/dist/auto-imports.d.ts +1 -1
  5. package/dist/build.d.ts +2 -2
  6. package/dist/cache.d.ts +2 -1
  7. package/dist/chat.d.ts +1 -1
  8. package/dist/cli.d.ts +92 -48
  9. package/dist/cloud.d.ts +10 -5
  10. package/dist/components.d.ts +1 -1
  11. package/dist/cron-jobs.d.ts +48 -19
  12. package/dist/database.d.ts +4 -2
  13. package/dist/dns.d.ts +12 -7
  14. package/dist/docs.d.ts +5 -2
  15. package/dist/errors.d.ts +6 -3
  16. package/dist/events.d.ts +3 -1
  17. package/dist/git.d.ts +2 -1
  18. package/dist/hashing.d.ts +6 -3
  19. package/dist/index.d.ts +3 -0
  20. package/dist/index.js +1 -1
  21. package/dist/model-names.d.ts +1 -1
  22. package/dist/model.d.ts +98 -59
  23. package/dist/payments.d.ts +14 -9
  24. package/dist/queue.d.ts +8 -0
  25. package/dist/reactivity.d.ts +1 -1
  26. package/dist/request.d.ts +10 -4
  27. package/dist/response.d.ts +15 -0
  28. package/dist/router.d.ts +20 -10
  29. package/dist/saas.d.ts +1 -1
  30. package/dist/scheduler.d.ts +1 -1
  31. package/dist/search-engine.d.ts +87 -49
  32. package/dist/security.d.ts +4 -2
  33. package/dist/storage.d.ts +2 -1
  34. package/dist/table-names.d.ts +1 -0
  35. package/dist/team.d.ts +2 -1
  36. package/dist/ui.d.ts +12 -7
  37. package/dist/utils.d.ts +14 -7
  38. package/package.json +19 -21
  39. package/src/attributes.ts +1 -0
  40. package/src/cli.ts +22 -4
  41. package/src/cron-jobs.ts +124 -30
  42. package/src/docs.ts +1 -0
  43. package/src/events.ts +2 -0
  44. package/src/index.ts +3 -0
  45. package/src/model-names.ts +1 -1
  46. package/src/model.ts +62 -42
  47. package/src/queue.ts +9 -0
  48. package/src/request.ts +2 -0
  49. package/src/response.ts +16 -0
  50. package/src/saas.ts +1 -1
  51. package/src/search-engine.ts +104 -45
  52. package/src/table-names.ts +1 -0
  53. package/src/ui.ts +2 -2
package/src/model.ts CHANGED
@@ -1,9 +1,41 @@
1
- import type { ModelNames } from '@stacksjs/types'
1
+ import type { ModelNames, TableNames } from '@stacksjs/types'
2
2
  import type { VineBoolean, VineNumber, VineString } from '@vinejs/vine'
3
- import type { DeepPartial, Nullable, SearchOptions } from '.'
3
+ import type { DeepPartial, Nullable } from '.'
4
+ import type { SearchOptions } from './search-engine'
4
5
 
5
6
  export type Model = Partial<ModelOptions>
6
7
 
8
+ export interface BaseRelation {
9
+ foreignKey?: string
10
+ relationName?: string
11
+ }
12
+
13
+ export interface Relation<T = string> extends BaseRelation {
14
+ model: T
15
+ }
16
+
17
+ export interface HasOne<T = string> extends Array<Relation<T>> {}
18
+ export interface HasMany<T = string> extends Array<Relation<T>> {}
19
+ export interface BelongsTo<T = string> extends Array<Relation<T>> {}
20
+
21
+ export interface BelongsToMany<T = string> extends Array<BaseBelongsToMany<T> | T> {}
22
+ export interface HasOneThrough<T = string> extends Array<BaseHasOneThrough<T> | T> {}
23
+
24
+ export interface BaseBelongsToMany<T = string> {
25
+ model: T
26
+ firstForeignKey?: string
27
+ secondForeignKey?: string
28
+ pivotTable?: string
29
+ }
30
+
31
+ export interface BaseHasOneThrough<T = string> {
32
+ model: T
33
+ through: T
34
+ foreignKey?: string
35
+ throughForeignKey?: string
36
+ relationName?: string
37
+ }
38
+
7
39
  export interface FieldArrayElement {
8
40
  entity: string
9
41
  charValue?: string | null
@@ -21,6 +53,10 @@ export interface AuthOptions {
21
53
  useTwoFactor?: boolean
22
54
  usePasskey?: boolean
23
55
  }
56
+ export interface LikeableOptions {
57
+ table?: string
58
+ foreignKey?: string
59
+ }
24
60
 
25
61
  type ActionPath = string
26
62
  type ActionName = string
@@ -41,12 +77,11 @@ interface ActivityLogOption {
41
77
  logOnly: LogAttribute[]
42
78
  }
43
79
 
44
- interface BelongsToManyType {
45
- model: ModelNames
46
- firstForeignKey?: string
47
- secondForeignKey?: string
48
- pivotTable?: string
49
- relationName?: string
80
+ export interface Relations {
81
+ hasOne: HasOne<ModelNames> | ModelNames[]
82
+ hasMany: HasMany<ModelNames> | ModelNames[]
83
+ belongsTo: BelongsTo<ModelNames> | ModelNames[]
84
+ belongsToMany: BelongsToMany<ModelNames> | ModelNames[]
50
85
  }
51
86
 
52
87
  export interface ApiSettings {
@@ -112,40 +147,22 @@ export interface ModelOptions extends Base {
112
147
  observe?: string[] | boolean
113
148
  billable?: boolean
114
149
  useActivityLog?: boolean | ActivityLogOption
150
+
151
+ likeable?: boolean | LikeableOptions
115
152
  }
116
153
 
117
- attributes?: Attributes
154
+ attributes?: AttributesElements
118
155
 
119
156
  // relationships
120
- hasOne?:
121
- | {
122
- model: ModelNames
123
- foreignKey?: string
124
- relationName?: string
125
- }[]
126
- | string[]
127
- hasMany?:
128
- | {
129
- model: ModelNames // should be typed as ModelName
130
- foreignKey?: string
131
- relationName?: string
132
- }[]
133
- | ModelNames[]
134
- belongsTo?:
135
- | {
136
- model: ModelNames // should be typed as ModelName
137
- foreignKey?: string
138
- relationName?: string
139
- }[]
140
- | ModelNames[] // belongsTo: 'User'
141
- belongsToMany?: BelongsToManyType[] | ModelNames[]
142
- hasOneThrough?: {
143
- model: ModelNames
144
- through: ModelNames
145
- foreignKey?: string
146
- throughForeignKey?: string
147
- relationName?: string
148
- }[]
157
+ hasOne?: HasOne<ModelNames> | ModelNames[]
158
+
159
+ hasMany?: HasMany<ModelNames> | ModelNames[]
160
+
161
+ belongsTo?: BelongsTo<ModelNames> | ModelNames[]
162
+
163
+ belongsToMany?: BelongsToMany<ModelNames> | ModelNames[]
164
+
165
+ hasOneThrough?: HasOneThrough<ModelNames> | ModelNames[]
149
166
 
150
167
  scopes?: {
151
168
  [key: string]: (value: any) => any
@@ -167,28 +184,31 @@ export interface Attribute {
167
184
  required?: boolean
168
185
  hidden?: boolean
169
186
  fillable?: boolean
187
+ guarded?: boolean
170
188
  factory?: () => any
171
189
  validation?: {
172
190
  rule: VineType
173
- message: ValidatorMessage
191
+ message?: ValidatorMessage
174
192
  }
175
193
  // validation?: String | Number | Boolean | Date
176
194
  }
177
195
 
178
- export interface Attributes {
196
+ export interface AttributesElements {
179
197
  [key: string]: Attribute
180
198
  }
181
199
 
182
200
  export interface RelationConfig {
183
201
  relationship: string
184
202
  model: string
185
- table: string
203
+ table: TableNames
186
204
  relationModel?: string
187
205
  relationTable?: string
188
206
  foreignKey: string
189
207
  modelKey: string
208
+ pivotKey?: string
209
+ pivotForeign?: string
190
210
  relationName?: string
191
211
  throughModel?: string
192
212
  throughForeignKey?: string
193
- pivotTable: string
213
+ pivotTable: TableNames
194
214
  }
package/src/queue.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { JobOptions } from './cron-jobs'
1
2
  import type { DeepPartial } from './utils'
2
3
 
3
4
  export interface QueueOptions {
@@ -35,4 +36,12 @@ export interface QueueOptions {
35
36
  }
36
37
  }
37
38
 
39
+ export interface QueueOption extends JobOptions {
40
+ delay?: number
41
+ payload?: any
42
+ afterResponse?: any
43
+ context?: string
44
+ maxTries?: number
45
+ }
46
+
38
47
  export type QueueConfig = DeepPartial<QueueOptions>
package/src/request.ts CHANGED
@@ -41,6 +41,8 @@ export interface RequestInstance {
41
41
 
42
42
  getParam: (key: string) => number | string | null
43
43
 
44
+ route: (key: string) => number | string | null
45
+
44
46
  getParams: () => RouteParams
45
47
 
46
48
  getParamAsInt: (key: string) => number | null
@@ -0,0 +1,16 @@
1
+ export interface ResponseInstance {
2
+ json: (data: any, status?: number) => ResponseData
3
+ success: (data: any) => ResponseData
4
+ created: (data: any) => ResponseData
5
+ noContent: () => ResponseData
6
+ error: (message: string, status: number) => ResponseData
7
+ forbidden: (message: string) => ResponseData
8
+ unauthorized: (message: string) => ResponseData
9
+ notFound: (message: string) => ResponseData
10
+ }
11
+
12
+ export interface ResponseData {
13
+ status: number
14
+ headers: { [key: string]: string }
15
+ body: string
16
+ }
package/src/saas.ts CHANGED
@@ -5,7 +5,7 @@ export interface SaasOption {
5
5
  pricing: {
6
6
  key: string
7
7
  price: number
8
- interval: 'day' | 'month' | 'week' | 'year'
8
+ interval?: 'day' | 'month' | 'week' | 'year' // Optional interval
9
9
  currency: string
10
10
  }[]
11
11
  metadata: {
@@ -1,28 +1,35 @@
1
1
  import type {
2
+ Dictionary,
3
+ DocumentOptions,
2
4
  EnqueuedTask,
5
+ Faceting,
3
6
  Hits,
4
7
  Index,
5
8
  IndexesResults,
6
9
  IndexOptions,
7
10
  MeiliSearch,
8
11
  Settings as MeilisearchOptions,
12
+ PaginationSettings,
9
13
  DocumentOptions as RecordOptions,
10
14
  SearchParams,
11
15
  SearchResponse,
16
+ Settings,
17
+ Synonyms,
18
+ TypoTolerance,
12
19
  } from 'meilisearch'
13
20
  import type { MaybePromise } from '.'
14
21
 
15
- type Search = any
16
- type Page = any
17
- type Pages = Page[]
18
- type Filter = any
19
- type Filters = Filter[]
20
- type Result = any
21
- type Results = Result[]
22
- type SearchFilter = any
23
- type SearchFilters = SearchFilter[]
24
- type Sorts = any
25
- type Sort = any
22
+ // type Search = any
23
+ // type Page = any
24
+ // type Pages = Page[]
25
+ // type Filter = any
26
+ // type Filters = Filter[]
27
+ // type Result = any
28
+ // type Results = Result[]
29
+ // type SearchFilter = any
30
+ // type SearchFilters = SearchFilter[]
31
+ // type Sorts = any
32
+ // type Sort = any
26
33
 
27
34
  export interface SearchEngineOptions {
28
35
  /**
@@ -48,6 +55,14 @@ export interface SearchEngineOptions {
48
55
  auth: string
49
56
  }
50
57
 
58
+ meilisearch?: {
59
+ host: string
60
+ protocol: number
61
+ port: number
62
+ auth: string
63
+ apiKey: string
64
+ }
65
+
51
66
  filters?: {
52
67
  [key: string]: string
53
68
  }
@@ -63,50 +78,93 @@ export interface SearchEngineOptions {
63
78
  export type SearchEngineConfig = Partial<SearchEngineOptions>
64
79
 
65
80
  export interface SearchEngineDriver {
66
- client: MeiliSearch
81
+ client: () => MeiliSearch
82
+
83
+ search: (index: string, params: any) => Promise<SearchResponse<Record<string, any>>>
67
84
 
68
85
  // Indexes
69
86
  createIndex: (name: string, options?: IndexOptions) => MaybePromise<EnqueuedTask>
70
- getIndex: (name: string) => MaybePromise<Index>
87
+ getIndex: (name: string) => Promise<Index<Record<string, any>>>
88
+ addDocument: (indexName: string, params: any) => Promise<EnqueuedTask>
89
+ updateDocuments: (indexName: string, params: DocumentOptions[]) => Promise<EnqueuedTask>
90
+ updateDocument: (indexName: string, params: DocumentOptions) => Promise<EnqueuedTask>
91
+ addDocuments: (indexName: string, params: any[]) => Promise<EnqueuedTask>
92
+ getDocument: (indexName: string, id: number, fields: any) => Promise<EnqueuedTask>
93
+ deleteDocument: (indexName: string, id: number) => Promise<EnqueuedTask>
94
+ deleteDocuments: (indexName: string, filters: string | string[]) => Promise<EnqueuedTask>
71
95
  updateIndex: (name: string, options: IndexOptions) => MaybePromise<EnqueuedTask>
72
96
  deleteIndex: (name: string) => MaybePromise<EnqueuedTask>
73
- updateIndexSettings: (name: string, settings: SearchEngineOptions) => MaybePromise<EnqueuedTask>
74
97
  listAllIndexes: () => MaybePromise<IndexesResults<Index[]>>
75
98
  listAllIndices: () => MaybePromise<IndexesResults<Index[]>> // alternatives plural spelling
76
99
 
77
- // Records (MeiliSearch uses the term "documents")
78
- getRecord: (key: string) => MaybePromise<any>
79
- getRecords: (key: string) => MaybePromise<RecordOptions>
80
- createRecord: (record: any, indexName: string, options: RecordOptions) => MaybePromise<EnqueuedTask>
81
- createRecords: (records: any, indexName: string, options: RecordOptions) => MaybePromise<EnqueuedTask>
82
- createOrReplaceRecord: (record: any, indexName: string, options: RecordOptions) => MaybePromise<EnqueuedTask>
83
- createOrUpdateRecord: (record: any, indexName: string, options: RecordOptions) => MaybePromise<EnqueuedTask>
84
- deleteRecord: (recordId: string | number, indexName: string) => MaybePromise<EnqueuedTask>
85
- deleteAllRecords: (indexName: string) => MaybePromise<EnqueuedTask>
86
- batchDeleteRecords: (recordIds: string[] | number[], indexName: string) => MaybePromise<EnqueuedTask>
100
+ getFilterableAttributes: (index: string) => Promise<string[]>
101
+ updateFilterableAttributes: (index: string, filterableAttributes: string[] | null) => Promise<EnqueuedTask>
102
+ resetFilterableAttributes: (index: string) => Promise<EnqueuedTask>
103
+
104
+ updateSearchableAttributes: (index: string, searchableAttributes: string[] | null) => Promise<EnqueuedTask>
105
+ resetSearchableAttributes: (index: string) => Promise<EnqueuedTask>
106
+ getSearchableAttributes: (index: string) => Promise<string[]>
107
+
108
+ updateSortableAttributes: (index: string, sortableAttributes: string[] | null) => Promise<EnqueuedTask>
109
+ resetSortableAttributes: (index: string) => Promise<EnqueuedTask>
110
+ getSortableAttributes: (index: string) => Promise<string[]>
111
+
112
+ updateDisplayedAttributes: (index: string, displayedAttributes: string[] | null) => Promise<EnqueuedTask>
113
+ getDisplayedAttributes: (index: string) => Promise<string[]>
114
+ resetDisplayedAttributes: (index: string) => Promise<EnqueuedTask>
115
+
116
+ getSettings: (index: string) => Promise<Settings>
117
+ updateSettings: (index: string, settings: Settings) => Promise<EnqueuedTask>
118
+ resetSettings: (index: string) => Promise<EnqueuedTask>
119
+ å
120
+ getPagination: (index: string) => Promise<PaginationSettings>
121
+ updatePagination: (index: string, pagination: PaginationSettings) => Promise<EnqueuedTask>
122
+ resetPagination: (index: string) => Promise<EnqueuedTask>
123
+
124
+ getSynonyms: (index: string) => Promise<any>
125
+ updateSynonyms: (index: string, synonyms: Synonyms) => Promise<EnqueuedTask>
126
+ resetSynonyms: (index: string) => Promise<EnqueuedTask>
127
+
128
+ getRankingRules: (index: string) => Promise<string[]>
129
+ updateRankingRules: (index: string, rankingRules: string[] | null) => Promise<EnqueuedTask>
130
+ resetRankingRules: (index: string) => Promise<EnqueuedTask>
131
+
132
+ getDistinctAttribute: (index: string) => Promise<string | null>
133
+ updateDistinctAttribute: (index: string, distinctAttribute: string | null) => Promise<EnqueuedTask>
134
+ resetDistinctAttribute: (index: string) => Promise<EnqueuedTask>
135
+
136
+ getFaceting: (index: string) => Promise<Faceting>
137
+ updateFaceting: (index: string, faceting: Faceting) => Promise<EnqueuedTask>
138
+ resetFaceting: (index: string) => Promise<EnqueuedTask>
139
+
140
+ getTypoTolerance: (index: string) => Promise<TypoTolerance>
141
+ updateTypoTolerance: (index: string, typoTolerance: TypoTolerance | null) => Promise<EnqueuedTask>
142
+ resetTypoTolerance: (index: string) => Promise<EnqueuedTask>
143
+
144
+ getDictionary: (index: string) => Promise<Dictionary>
145
+ updateDictionary: (index: string, dictionary: Dictionary | null) => Promise<EnqueuedTask>
146
+ resetDictionary: (index: string) => Promise<EnqueuedTask>
87
147
 
88
148
  // Search
89
- search: (query: string, indexName: string, options: SearchParams) => MaybePromise<Search>
90
-
91
- calculatePagination: Pages
92
- currentPage: Page
93
- filterName: string
94
- filters: Filters
95
- goToNextPage: () => Page
96
- goToPage: (pageNumber: number) => Page
97
- goToPrevPage: () => Page
98
- hits: Hits
99
- index: Index
100
- lastPage: Page
101
- perPage: number
102
- query: string
103
- results: Results // SearchResponse
104
- searchFilters: SearchFilters
105
- searchParams: SearchParams
106
- setTotalHits: number
107
- sort: Sort
108
- sorts: Sorts
109
- totalPages: number
149
+ // calculatePagination: Pages
150
+ // currentPage: Page
151
+ // filterName: string
152
+ // filters: Filters
153
+ // goToNextPage: () => Page
154
+ // goToPage: (pageNumber: number) => Page
155
+ // goToPrevPage: () => Page
156
+ // hits: Hits
157
+ // index: Index
158
+ // lastPage: Page
159
+ // perPage: number
160
+ // query: string
161
+ // results: Results // SearchResponse
162
+ // searchFilters: SearchFilters
163
+ // searchParams: SearchParams
164
+ // setTotalHits: number
165
+ // sort: Sort
166
+ // sorts: Sorts
167
+ // totalPages: number
110
168
  }
111
169
 
112
170
  /**
@@ -141,6 +199,7 @@ export interface SearchEngineStorage {
141
199
  }
142
200
 
143
201
  export interface SearchOptions {
202
+ displayable: string[]
144
203
  searchable: string[]
145
204
  sortable: string[]
146
205
  filterable: string[]
@@ -0,0 +1 @@
1
+ export type TableNames = 'projects' | 'subscriber_emails' | 'personal_access_tokens' | 'team_users' | 'teams' | 'activities' | 'subscribers' | 'deployments' | 'releases' | 'team_users' | 'users' | 'posts' | 'failed_jobs' | 'products' | 'payment_methods' | 'transactions' | 'jobs' | 'subscriptions' | 'errors'
package/src/ui.ts CHANGED
@@ -2,7 +2,7 @@ import type { UserConfig } from '@unocss/core'
2
2
  import type { UserShortcuts } from 'unocss'
3
3
 
4
4
  export type Font = 'inter' | 'mona' | 'hubot'
5
- export type Icon = 'heroicons'
5
+ export type Icon = 'heroicons' | 'hugeicons'
6
6
  export type WebFontsProviders = 'google' | 'bunny' | 'fontshare'
7
7
  export type Shortcuts = UserShortcuts
8
8
 
@@ -149,7 +149,7 @@ export interface UiOptions {
149
149
  * are displayed utilizing a technique called "icons in pure css."
150
150
  * Learn more here https://antfu.me/posts/icons-in-pure-css.
151
151
  *
152
- * @see https://stacks.ow3.org/config/icons — list of available icon sets
152
+ * @see https://stacksjs.org/config/icons — list of available icon sets
153
153
  * @todo implement this into Vite build flow
154
154
  * @example
155
155
  * ```ts