@stacksjs/types 0.70.23 → 0.70.25
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/index.js +1 -1
- package/dist/src/ai.d.ts +37 -0
- package/dist/src/analytics.d.ts +36 -0
- package/dist/src/api.d.ts +26 -0
- package/dist/src/app.d.ts +28 -0
- package/dist/src/attributes.d.ts +1 -0
- package/dist/src/auth.d.ts +49 -0
- package/dist/src/auto-imports.d.ts +8 -0
- package/dist/{binary.d.ts → src/binary.d.ts} +4 -1
- package/dist/src/cache.d.ts +79 -0
- package/dist/{cdn.d.ts → src/cdn.d.ts} +1 -1
- package/dist/{chat.d.ts → src/chat.d.ts} +29 -48
- package/dist/src/cli.d.ts +308 -0
- package/dist/{cloud.d.ts → src/cloud.d.ts} +81 -26
- package/dist/{components.d.ts → src/components.d.ts} +1 -4
- package/dist/{configure.d.ts → src/configure.d.ts} +1 -1
- package/dist/{cron-jobs.d.ts → src/cron-jobs.d.ts} +33 -37
- package/dist/src/dashboard.d.ts +33 -0
- package/dist/{database.d.ts → src/database.d.ts} +20 -12
- package/dist/src/dependencies.d.ts +17 -0
- package/dist/src/deploy.d.ts +16 -0
- package/dist/{dns.d.ts → src/dns.d.ts} +59 -59
- package/dist/src/docs.d.ts +23 -0
- package/dist/src/email.d.ts +201 -0
- package/dist/src/env.d.ts +1 -0
- package/dist/{errors.d.ts → src/errors.d.ts} +17 -24
- package/dist/src/events.d.ts +31 -0
- package/dist/src/exit-code.d.ts +10 -0
- package/dist/{file-systems.d.ts → src/file-systems.d.ts} +10 -6
- package/dist/{git.d.ts → src/git.d.ts} +9 -6
- package/dist/src/hashing.d.ts +57 -0
- package/dist/src/helpers.d.ts +1 -0
- package/dist/src/i18n.d.ts +65 -0
- package/dist/src/index.d.ts +70 -0
- package/dist/{library.d.ts → src/library.d.ts} +31 -33
- package/dist/src/logging.d.ts +12 -0
- package/dist/{manifest.d.ts → src/manifest.d.ts} +4 -1
- package/dist/src/model-names.d.ts +1 -0
- package/dist/src/model.d.ts +251 -0
- package/dist/{notifications.d.ts → src/notifications.d.ts} +1 -26
- package/dist/src/oauth.d.ts +290 -0
- package/dist/{pages.d.ts → src/pages.d.ts} +1 -1
- package/dist/src/payments.d.ts +322 -0
- package/dist/src/phone.d.ts +52 -0
- package/dist/src/ports.d.ts +20 -0
- package/dist/src/promise.d.ts +1 -0
- package/dist/src/push.d.ts +108 -0
- package/dist/src/queue.d.ts +310 -0
- package/dist/src/reactivity.d.ts +1 -0
- package/dist/src/realtime.d.ts +443 -0
- package/dist/src/request.d.ts +154 -0
- package/dist/{response.d.ts → src/response.d.ts} +1 -1
- package/dist/src/router.d.ts +105 -0
- package/dist/{saas.d.ts → src/saas.d.ts} +2 -2
- package/dist/src/scheduler.d.ts +1 -0
- package/dist/{search-engine.d.ts → src/search-engine.d.ts} +41 -45
- package/dist/{security.d.ts → src/security.d.ts} +4 -8
- package/dist/{server.d.ts → src/server.d.ts} +1 -1
- package/dist/src/services.d.ts +140 -0
- package/dist/{settings-config.d.ts → src/settings-config.d.ts} +1 -1
- package/dist/src/sms.d.ts +144 -0
- package/dist/src/stack-extensions.d.ts +137 -0
- package/dist/src/stacks.d.ts +40 -0
- package/dist/src/storage.d.ts +105 -0
- package/dist/src/table-names.d.ts +1 -0
- package/dist/src/tables.d.ts +34 -0
- package/dist/src/team.d.ts +7 -0
- package/dist/src/ui.d.ts +55 -0
- package/dist/src/utils.d.ts +39 -0
- package/package.json +13 -32
- package/src/ai.ts +20 -6
- package/src/analytics.ts +38 -1
- package/src/app.ts +38 -0
- package/src/attributes.ts +5 -1
- package/src/auth.ts +122 -0
- package/src/auto-imports.ts +8 -1
- package/src/cache.ts +226 -69
- package/src/chat.ts +0 -20
- package/src/cli.ts +24 -9
- package/src/cloud.ts +40 -1
- package/src/components.ts +3 -5
- package/src/cron-jobs.ts +1 -1
- package/src/dashboard.ts +40 -0
- package/src/database.ts +18 -2
- package/src/dns.ts +1 -1
- package/src/docs.ts +3 -3
- package/src/email.ts +303 -13
- package/src/errors.ts +2 -3
- package/src/events.ts +10 -5
- package/src/git.ts +3 -3
- package/src/hashing.ts +15 -19
- package/src/i18n.ts +105 -3
- package/src/index.ts +9 -5
- package/src/library.ts +0 -5
- package/src/model-names.ts +1 -1
- package/src/model.ts +87 -10
- package/src/oauth.ts +488 -0
- package/src/payments.ts +370 -27
- package/src/phone.ts +62 -0
- package/src/push.ts +107 -0
- package/src/queue.ts +386 -28
- package/src/reactivity.ts +1 -1
- package/src/realtime.ts +584 -0
- package/src/request.ts +344 -22
- package/src/router.ts +62 -4
- package/src/search-engine.ts +13 -13
- package/src/services.ts +100 -5
- package/src/sms.ts +263 -3
- package/src/stack-extensions.ts +184 -0
- package/src/stacks.ts +34 -4
- package/src/storage.ts +140 -6
- package/src/table-names.ts +1 -1
- package/src/ui.ts +20 -12
- package/src/utils.ts +1 -1
- package/dist/ai.d.ts +0 -20
- package/dist/analytics.d.ts +0 -13
- package/dist/api.d.ts +0 -26
- package/dist/app.d.ts +0 -32
- package/dist/attributes.d.ts +0 -1
- package/dist/auto-imports.d.ts +0 -1
- package/dist/build.d.ts +0 -2
- package/dist/cache.d.ts +0 -49
- package/dist/cli.d.ts +0 -310
- package/dist/dependencies.d.ts +0 -16
- package/dist/deploy.d.ts +0 -10
- package/dist/docs.d.ts +0 -26
- package/dist/email.d.ts +0 -107
- package/dist/events.d.ts +0 -5
- package/dist/exit-code.d.ts +0 -5
- package/dist/hashing.d.ts +0 -36
- package/dist/helpers.d.ts +0 -1
- package/dist/i18n.d.ts +0 -11
- package/dist/index.d.ts +0 -65
- package/dist/inspect.d.ts +0 -3
- package/dist/logging.d.ts +0 -6
- package/dist/model-names.d.ts +0 -1
- package/dist/model.d.ts +0 -232
- package/dist/payments.d.ts +0 -94
- package/dist/ports.d.ts +0 -13
- package/dist/promise.d.ts +0 -1
- package/dist/push.d.ts +0 -35
- package/dist/pwa.d.ts +0 -3
- package/dist/queue.d.ts +0 -45
- package/dist/reactivity.d.ts +0 -1
- package/dist/request.d.ts +0 -49
- package/dist/router.d.ts +0 -65
- package/dist/scheduler.d.ts +0 -1
- package/dist/services.d.ts +0 -81
- package/dist/ssg.d.ts +0 -3
- package/dist/stacks.d.ts +0 -54
- package/dist/storage.d.ts +0 -31
- package/dist/table-names.d.ts +0 -1
- package/dist/tables.d.ts +0 -34
- package/dist/team.d.ts +0 -8
- package/dist/ui.d.ts +0 -47
- package/dist/utils.d.ts +0 -27
- package/src/build.ts +0 -2
- package/src/inspect.ts +0 -10
- package/src/layout.ts +0 -8
- package/src/pwa.ts +0 -8
- 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
|
-
|
|
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 './
|
|
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
package/src/model-names.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type ModelNames = '
|
|
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 {
|
|
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
|
|
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
|
|
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
|
-
|
|
159
|
-
|
|
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:
|
|
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>
|