@stacksjs/types 0.70.23 → 0.70.26

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 (161) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/src/ai.d.ts +37 -0
  3. package/dist/src/analytics.d.ts +36 -0
  4. package/dist/src/api.d.ts +26 -0
  5. package/dist/src/app.d.ts +28 -0
  6. package/dist/src/attributes.d.ts +1 -0
  7. package/dist/src/auth.d.ts +49 -0
  8. package/dist/src/auto-imports.d.ts +8 -0
  9. package/dist/{binary.d.ts → src/binary.d.ts} +4 -1
  10. package/dist/src/cache.d.ts +79 -0
  11. package/dist/{cdn.d.ts → src/cdn.d.ts} +1 -1
  12. package/dist/{chat.d.ts → src/chat.d.ts} +29 -48
  13. package/dist/src/cli.d.ts +308 -0
  14. package/dist/{cloud.d.ts → src/cloud.d.ts} +81 -26
  15. package/dist/{components.d.ts → src/components.d.ts} +1 -4
  16. package/dist/{configure.d.ts → src/configure.d.ts} +1 -1
  17. package/dist/{cron-jobs.d.ts → src/cron-jobs.d.ts} +33 -37
  18. package/dist/src/dashboard.d.ts +33 -0
  19. package/dist/{database.d.ts → src/database.d.ts} +20 -12
  20. package/dist/src/dependencies.d.ts +17 -0
  21. package/dist/src/deploy.d.ts +16 -0
  22. package/dist/{dns.d.ts → src/dns.d.ts} +59 -59
  23. package/dist/src/docs.d.ts +23 -0
  24. package/dist/src/email.d.ts +201 -0
  25. package/dist/src/env.d.ts +1 -0
  26. package/dist/{errors.d.ts → src/errors.d.ts} +17 -24
  27. package/dist/src/events.d.ts +31 -0
  28. package/dist/src/exit-code.d.ts +10 -0
  29. package/dist/{file-systems.d.ts → src/file-systems.d.ts} +10 -6
  30. package/dist/{git.d.ts → src/git.d.ts} +9 -6
  31. package/dist/src/hashing.d.ts +57 -0
  32. package/dist/src/helpers.d.ts +1 -0
  33. package/dist/src/i18n.d.ts +65 -0
  34. package/dist/src/index.d.ts +70 -0
  35. package/dist/{library.d.ts → src/library.d.ts} +31 -33
  36. package/dist/src/logging.d.ts +12 -0
  37. package/dist/{manifest.d.ts → src/manifest.d.ts} +4 -1
  38. package/dist/src/model-names.d.ts +1 -0
  39. package/dist/src/model.d.ts +251 -0
  40. package/dist/{notifications.d.ts → src/notifications.d.ts} +1 -26
  41. package/dist/src/oauth.d.ts +290 -0
  42. package/dist/{pages.d.ts → src/pages.d.ts} +1 -1
  43. package/dist/src/payments.d.ts +322 -0
  44. package/dist/src/phone.d.ts +52 -0
  45. package/dist/src/ports.d.ts +20 -0
  46. package/dist/src/promise.d.ts +1 -0
  47. package/dist/src/push.d.ts +108 -0
  48. package/dist/src/queue.d.ts +310 -0
  49. package/dist/src/reactivity.d.ts +1 -0
  50. package/dist/src/realtime.d.ts +443 -0
  51. package/dist/src/request.d.ts +154 -0
  52. package/dist/{response.d.ts → src/response.d.ts} +1 -1
  53. package/dist/src/router.d.ts +105 -0
  54. package/dist/{saas.d.ts → src/saas.d.ts} +2 -2
  55. package/dist/src/scheduler.d.ts +1 -0
  56. package/dist/{search-engine.d.ts → src/search-engine.d.ts} +41 -45
  57. package/dist/{security.d.ts → src/security.d.ts} +4 -8
  58. package/dist/{server.d.ts → src/server.d.ts} +1 -1
  59. package/dist/src/services.d.ts +140 -0
  60. package/dist/{settings-config.d.ts → src/settings-config.d.ts} +1 -1
  61. package/dist/src/sms.d.ts +144 -0
  62. package/dist/src/stack-extensions.d.ts +137 -0
  63. package/dist/src/stacks.d.ts +40 -0
  64. package/dist/src/storage.d.ts +105 -0
  65. package/dist/src/table-names.d.ts +1 -0
  66. package/dist/src/tables.d.ts +34 -0
  67. package/dist/src/team.d.ts +7 -0
  68. package/dist/src/ui.d.ts +55 -0
  69. package/dist/src/utils.d.ts +39 -0
  70. package/package.json +13 -32
  71. package/src/ai.ts +20 -6
  72. package/src/analytics.ts +38 -1
  73. package/src/app.ts +38 -0
  74. package/src/attributes.ts +5 -1
  75. package/src/auth.ts +122 -0
  76. package/src/auto-imports.ts +8 -1
  77. package/src/cache.ts +226 -69
  78. package/src/chat.ts +0 -20
  79. package/src/cli.ts +24 -9
  80. package/src/cloud.ts +40 -1
  81. package/src/components.ts +3 -5
  82. package/src/cron-jobs.ts +1 -1
  83. package/src/dashboard.ts +40 -0
  84. package/src/database.ts +18 -2
  85. package/src/dns.ts +1 -1
  86. package/src/docs.ts +3 -3
  87. package/src/email.ts +303 -13
  88. package/src/errors.ts +2 -3
  89. package/src/events.ts +10 -5
  90. package/src/git.ts +3 -3
  91. package/src/hashing.ts +15 -19
  92. package/src/i18n.ts +105 -3
  93. package/src/index.ts +9 -5
  94. package/src/library.ts +0 -5
  95. package/src/model-names.ts +1 -1
  96. package/src/model.ts +87 -10
  97. package/src/oauth.ts +488 -0
  98. package/src/payments.ts +370 -27
  99. package/src/phone.ts +62 -0
  100. package/src/push.ts +107 -0
  101. package/src/queue.ts +386 -28
  102. package/src/reactivity.ts +1 -1
  103. package/src/realtime.ts +584 -0
  104. package/src/request.ts +344 -22
  105. package/src/router.ts +62 -4
  106. package/src/search-engine.ts +13 -13
  107. package/src/services.ts +100 -5
  108. package/src/sms.ts +263 -3
  109. package/src/stack-extensions.ts +184 -0
  110. package/src/stacks.ts +34 -4
  111. package/src/storage.ts +140 -6
  112. package/src/table-names.ts +1 -1
  113. package/src/ui.ts +20 -12
  114. package/src/utils.ts +1 -1
  115. package/dist/ai.d.ts +0 -20
  116. package/dist/analytics.d.ts +0 -13
  117. package/dist/api.d.ts +0 -26
  118. package/dist/app.d.ts +0 -32
  119. package/dist/attributes.d.ts +0 -1
  120. package/dist/auto-imports.d.ts +0 -1
  121. package/dist/build.d.ts +0 -2
  122. package/dist/cache.d.ts +0 -49
  123. package/dist/cli.d.ts +0 -310
  124. package/dist/dependencies.d.ts +0 -16
  125. package/dist/deploy.d.ts +0 -10
  126. package/dist/docs.d.ts +0 -26
  127. package/dist/email.d.ts +0 -107
  128. package/dist/events.d.ts +0 -5
  129. package/dist/exit-code.d.ts +0 -5
  130. package/dist/hashing.d.ts +0 -36
  131. package/dist/helpers.d.ts +0 -1
  132. package/dist/i18n.d.ts +0 -11
  133. package/dist/index.d.ts +0 -65
  134. package/dist/inspect.d.ts +0 -3
  135. package/dist/logging.d.ts +0 -6
  136. package/dist/model-names.d.ts +0 -1
  137. package/dist/model.d.ts +0 -232
  138. package/dist/payments.d.ts +0 -94
  139. package/dist/ports.d.ts +0 -13
  140. package/dist/promise.d.ts +0 -1
  141. package/dist/push.d.ts +0 -35
  142. package/dist/pwa.d.ts +0 -3
  143. package/dist/queue.d.ts +0 -45
  144. package/dist/reactivity.d.ts +0 -1
  145. package/dist/request.d.ts +0 -49
  146. package/dist/router.d.ts +0 -65
  147. package/dist/scheduler.d.ts +0 -1
  148. package/dist/services.d.ts +0 -81
  149. package/dist/ssg.d.ts +0 -3
  150. package/dist/stacks.d.ts +0 -54
  151. package/dist/storage.d.ts +0 -31
  152. package/dist/table-names.d.ts +0 -1
  153. package/dist/tables.d.ts +0 -34
  154. package/dist/team.d.ts +0 -8
  155. package/dist/ui.d.ts +0 -47
  156. package/dist/utils.d.ts +0 -27
  157. package/src/build.ts +0 -2
  158. package/src/inspect.ts +0 -10
  159. package/src/layout.ts +0 -8
  160. package/src/pwa.ts +0 -8
  161. package/src/ssg.ts +0 -3
package/src/index.ts CHANGED
@@ -3,9 +3,13 @@ export * from './analytics'
3
3
  export * from './api'
4
4
  export * from './app'
5
5
  export * from './attributes'
6
+ export * from './auth'
7
+ export * from './oauth'
6
8
  export * from './auto-imports'
7
9
  export * from './binary'
8
- export * from './build'
10
+ // `./build` removed — exposed `vite` / `vite-ssg` types we no longer use
11
+ // (Stacks builds with Bun). The same applies to `./inspect`, `./pwa`,
12
+ // `./ssg`, and `./layout` which all wrapped vite-* plugins.
9
13
  export * from './cache'
10
14
  export * from './cdn'
11
15
  export * from './chat'
@@ -14,6 +18,7 @@ export * from './cloud'
14
18
  export * from './components'
15
19
  export * from './configure'
16
20
  export * from './cron-jobs'
21
+ export * from './dashboard'
17
22
  export * from './database'
18
23
  export * from './dependencies'
19
24
  export * from './deploy'
@@ -29,8 +34,6 @@ export * from './git'
29
34
  export * from './hashing'
30
35
  export * from './helpers'
31
36
  export * from './i18n'
32
- export * from './inspect'
33
- // export * from './layout'
34
37
  export * from './library'
35
38
  export * from './logging'
36
39
  export * from './manifest'
@@ -39,12 +42,13 @@ export * from './model-names'
39
42
  export * from './notifications'
40
43
  export * from './pages'
41
44
  export * from './payments'
45
+ export * from './phone'
42
46
  export * from './ports'
43
47
  export * from './promise'
44
48
  export * from './push'
45
- export * from './pwa'
46
49
  export * from './queue'
47
50
  export * from './reactivity'
51
+ export * from './realtime'
48
52
  export * from './request'
49
53
  export * from './response'
50
54
  export * from './router'
@@ -56,7 +60,7 @@ export * from './server'
56
60
  export * from './services'
57
61
  export * from './settings-config.ts'
58
62
  export * from './sms'
59
- export * from './ssg'
63
+ export * from './stack-extensions'
60
64
  export * from './stacks'
61
65
  export * from './storage'
62
66
  export * from './table-names'
package/src/library.ts CHANGED
@@ -64,11 +64,6 @@ export interface LibraryOptions {
64
64
  */
65
65
  defaultLanguage: LanguageCode
66
66
 
67
- /**
68
- * The Vue component library options.
69
- */
70
- vueComponents: LibraryBuildOptions
71
-
72
67
  /**
73
68
  * The Web Component library options.
74
69
  */
@@ -1 +1 @@
1
- export type ModelNames = 'Project' | 'SubscriberEmail' | 'AccessToken' | 'Team' | 'Subscriber' | 'Deployment' | 'Release' | 'User' | 'Post' | 'PrintDevice' | 'Category' | 'Payment' | 'Driver' | 'WaitlistProduct' | 'DigitalDelivery' | 'Manufacturer' | 'OrderItem' | 'ShippingZone' | 'Customer' | 'Product' | 'Receipt' | 'ProductVariant' | 'LicenseKey' | 'WaitlistRestaurant' | 'Review' | 'ProductUnit' | 'GiftCard' | 'Order' | 'Coupon' | 'TaxRate' | 'Transaction' | 'LoyaltyPoint' | 'ProductItem' | 'LoyaltyReward' | 'ShippingMethod' | 'ShippingRate' | 'DeliveryRoute' | 'FailedJob' | 'PaymentMethod' | 'PaymentTransaction' | 'Request' | 'Job' | 'Subscription' | 'PaymentProduct' | 'Error'
1
+ export type ModelNames = 'Tag' | 'PaymentProduct' | 'FailedJob' | 'SocialPost' | 'PaymentMethod' | 'Campaign' | 'PaymentTransaction' | 'Request' | 'Activity' | 'EmailList' | 'Notification' | 'Job' | 'Log' | 'Subscription' | 'Error' | 'Comment' | 'User' | 'Websocket' | 'Page' | 'Author' | 'Post' | 'PrintDevice' | 'Category' | 'Payment' | 'Driver' | 'WaitlistProduct' | 'DigitalDelivery' | 'Manufacturer' | 'OrderItem' | 'ShippingZone' | 'Customer' | 'Product' | 'Receipt' | 'ProductVariant' | 'LicenseKey' | 'WaitlistRestaurant' | 'Review' | 'ProductUnit' | 'GiftCard' | 'Order' | 'Coupon' | 'TaxRate' | 'Transaction' | 'LoyaltyPoint' | 'LoyaltyReward' | 'ShippingMethod' | 'ShippingRate' | 'Cart' | 'DeliveryRoute' | 'CartItem'
package/src/model.ts CHANGED
@@ -1,9 +1,16 @@
1
1
  import type { Faker } from '@stacksjs/faker'
2
+ import type { ValidationType } from '@stacksjs/ts-validation'
2
3
  import type { ModelNames, TableNames } from '@stacksjs/types'
3
- import type { VineBoolean, VineNumber, VineString } from '@vinejs/vine'
4
- import type { DeepPartial, Nullable } from '.'
4
+ import type { DeepPartial } from '.'
5
5
  import type { SearchOptions } from './search-engine'
6
6
 
7
+ /**
8
+ * Model definition type - compatible with bun-query-builder
9
+ *
10
+ * Models can be defined in app/Models/ (userland; overrides defaults by name)
11
+ * or storage/framework/defaults/app/Models/ (framework defaults), and are used
12
+ * to generate the ORM classes, migrations, and API routes.
13
+ */
7
14
  export type Model = Partial<ModelOptions>
8
15
 
9
16
  export interface BaseRelation {
@@ -51,6 +58,20 @@ export interface BaseHasOneThrough<T = string> {
51
58
  relationName?: string
52
59
  }
53
60
 
61
+ export interface BaseHasManyThrough<T = string> {
62
+ model: T
63
+ through: T
64
+ foreignKey?: string
65
+ throughForeignKey?: string
66
+ relationName?: string
67
+ }
68
+
69
+ export interface HasManyThrough<T = string> extends Array<BaseHasManyThrough<T> | T> {}
70
+
71
+ export interface MorphToMany<T = string> extends Array<T> {}
72
+
73
+ export interface MorphedByMany<T = string> extends Array<T> {}
74
+
54
75
  export interface FieldArrayElement {
55
76
  entity: string
56
77
  charValue?: string | null
@@ -61,11 +82,13 @@ export interface ModelElement {
61
82
  field: string
62
83
  default: string | number | boolean | Date | undefined | null
63
84
  unique: boolean
85
+ fillable: boolean
86
+ hidden: boolean
64
87
  required: boolean
65
88
  fieldArray: FieldArrayElement | null
66
89
  }
67
90
 
68
- export interface AuthOptions {
91
+ export interface UserAuthOptions {
69
92
  useTwoFactor?: boolean
70
93
  usePasskey?: boolean
71
94
  }
@@ -80,7 +103,8 @@ type Action = ActionPath | ActionName | undefined
80
103
 
81
104
  export type ApiRoutes = 'index' | 'show' | 'store' | 'update' | 'destroy'
82
105
 
83
- export type VineType = VineString | VineNumber | VineBoolean | Date | Nullable<any>
106
+ export type SocialProviders = 'google' | 'github' | 'twitter' | 'facebook'
107
+
84
108
  export interface SeedOptions {
85
109
  count: number
86
110
  }
@@ -100,6 +124,8 @@ export interface Relations {
100
124
  belongsToMany: BelongsToMany<ModelNames> | ModelNames[]
101
125
  }
102
126
 
127
+ export type SocialOptions = SocialProviders[]
128
+
103
129
  export interface ApiSettings {
104
130
  uri: string
105
131
  middleware: string[]
@@ -154,12 +180,15 @@ export interface ModelOptions extends Base {
154
180
  timestampable?: boolean | TimestampOptions // useTimestamps alias
155
181
  useSoftDeletes?: boolean | SoftDeleteOptions // defaults to false
156
182
  softDeletable?: boolean | SoftDeleteOptions // useSoftDeletes alias
157
-
158
- useAuth?: boolean | AuthOptions // defaults to false
159
- authenticatable?: boolean | AuthOptions // useAuth alias
183
+ categorizable?: boolean // defaults to false
184
+ taggable?: boolean // defaults to false
185
+ commentables?: boolean // defaults to false
186
+ useAuth?: boolean | UserAuthOptions // defaults to false
187
+ authenticatable?: boolean | UserAuthOptions // useAuth alias
160
188
  useSeeder?: boolean | SeedOptions // defaults to a count of 10
161
189
  seedable?: boolean | SeedOptions // useSeeder alias
162
190
  useSearch?: boolean | SearchOptions // defaults to false
191
+ useSocials?: SocialOptions // defaults to false
163
192
  searchable?: boolean | SearchOptions // useSearch alias
164
193
  useApi?: ApiOptions | boolean
165
194
  observe?: string[] | boolean
@@ -182,12 +211,18 @@ export interface ModelOptions extends Base {
182
211
 
183
212
  hasOneThrough?: HasOneThrough<ModelNames> | ModelNames[]
184
213
 
214
+ hasManyThrough?: HasManyThrough<ModelNames> | ModelNames[]
215
+
185
216
  morphOne?: MorphOne<ModelNames> | ModelNames
186
217
 
187
218
  morphMany?: MorphMany<ModelNames>[] | ModelNames[]
188
219
 
189
220
  morphTo?: MorphTo
190
221
 
222
+ morphToMany?: MorphToMany<ModelNames> | ModelNames[]
223
+
224
+ morphedByMany?: MorphedByMany<ModelNames> | ModelNames[]
225
+
191
226
  scopes?: {
192
227
  [key: string]: (value: any) => any
193
228
  }
@@ -205,13 +240,12 @@ export interface Attribute {
205
240
  default?: string | number | boolean | Date
206
241
  unique?: boolean
207
242
  order?: number
208
- required?: boolean
209
243
  hidden?: boolean
210
244
  fillable?: boolean
211
245
  guarded?: boolean
212
246
  factory?: (faker: Faker) => any
213
- validation?: {
214
- rule: VineType
247
+ validation: {
248
+ rule: ValidationType
215
249
  message?: ValidatorMessage
216
250
  }
217
251
  }
@@ -240,3 +274,46 @@ export interface RelationConfig {
240
274
  throughForeignKey?: string
241
275
  pivotTable: TableNames
242
276
  }
277
+
278
+ /**
279
+ * Helper to define a model with proper type inference.
280
+ * Compatible with bun-query-builder's defineModel pattern.
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * export default defineModel({
285
+ * name: 'User',
286
+ * table: 'users',
287
+ * primaryKey: 'id',
288
+ * attributes: {
289
+ * name: { validation: { rule: schema.string() } },
290
+ * email: { validation: { rule: schema.string().email() }, unique: true },
291
+ * },
292
+ * traits: {
293
+ * useTimestamps: true,
294
+ * useApi: true,
295
+ * },
296
+ * })
297
+ * ```
298
+ */
299
+ export function defineModel<const T extends Model>(model: T): T {
300
+ return model
301
+ }
302
+
303
+ /**
304
+ * Helper to define multiple models with proper type inference.
305
+ * Useful for building a typed database schema.
306
+ *
307
+ * @example
308
+ * ```ts
309
+ * const models = defineModels({ User, Post, Comment })
310
+ * ```
311
+ */
312
+ export function defineModels<const T extends Record<string, Model>>(models: T): T {
313
+ return models
314
+ }
315
+
316
+ /**
317
+ * Type alias for a collection of models
318
+ */
319
+ export type ModelRecord = Record<string, Model>