@stacksjs/orm 0.70.88 → 0.70.90

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.
@@ -0,0 +1,232 @@
1
+ import '@stacksjs/validation';
2
+ export type { PrunableOptions } from './utils/prunable';
3
+ export type { AuditHelpers } from './traits/audit';
4
+ // Re-export soft-delete option types so user code can `satisfies SoftDeleteOptions`.
5
+ export type { SoftDeleteOptions, SoftDeleteHelpers } from './traits/soft-deletes';
6
+ export type { GenerateSchemaOptions, GenerateSchemaResult } from './generate-database-schema';
7
+ export type { CursorPaginator, Paginator, SimplePaginator } from './paginator';
8
+ export type { ResolvedPageArgs } from './paginator-request';
9
+ // Re-export type utilities from bun-query-builder so consumers can infer
10
+ // model types directly from defineModel() definitions
11
+ export type {
12
+ InferAttributes,
13
+ InferPrimaryKey,
14
+ InferRelationNames,
15
+ InferTableName,
16
+ ModelDefinition,
17
+ } from '@stacksjs/query-builder';
18
+ /**
19
+ * Returns a Proxy that lazily forwards every property access to the
20
+ * loaded model in `_loaded[name]`. Returns `undefined` before the
21
+ * deferred load completes — callers that need the load to finish
22
+ * first should `await ormReady`.
23
+ */
24
+ declare function lazyModel<T>(name: string): T;
25
+ /**
26
+ * Resolves once all framework-default models have been loaded into the
27
+ * lazy-export proxies. Server bootstrap code that wants to ensure model
28
+ * exports are populated before serving the first request should
29
+ * `await ormReady` early. Per-request code doesn't need to — by the
30
+ * time any HTTP handler runs, the microtask queue has long drained.
31
+ */
32
+ export declare const ormReady: Promise<void>;
33
+ export declare const User: boolean;
34
+ // Queue framework models. The CLI commands `buddy queue:status`,
35
+ // `queue:failed`, `queue:flush`, `queue:inspect`, `queue:monitor`,
36
+ // `queue:clear` import them as `import { Job, FailedJob } from
37
+ // '@stacksjs/orm'`. Prefer the userland publication
38
+ // (`app/Models/Job.ts`, dropped in by `buddy publish:model Job`) so
39
+ // projects that customize the queue model see their version.
40
+ //
41
+ // Gated on the 'queue' feature flag — projects that don't run a queue
42
+ // (most marketing sites, plain CMS apps) leave it off and skip the
43
+ // defineModel pipeline for these two entirely. The lazyModel proxy
44
+ // returns `undefined` for unloaded models, and the CLI queue commands
45
+ // can check `await ormReady; if (!Job) throw …` to surface a clear
46
+ // "run ./buddy queue:install" error.
47
+ export declare const Job: boolean;
48
+ export declare const FailedJob: boolean;
49
+ export declare const Activity: boolean;
50
+ export declare const Author: boolean;
51
+ export declare const Campaign: boolean;
52
+ export declare const Cart: boolean;
53
+ export declare const CartItem: boolean;
54
+ export declare const Category: boolean;
55
+ export declare const Comment: boolean;
56
+ export declare const Coupon: boolean;
57
+ export declare const Customer: boolean;
58
+ export declare const DeliveryRoute: boolean;
59
+ export declare const Deployment: boolean;
60
+ export declare const DigitalDelivery: boolean;
61
+ export declare const Driver: boolean;
62
+ export declare const CampaignSend: boolean;
63
+ export declare const EmailList: boolean;
64
+ export declare const EmailListSubscriber: boolean;
65
+ export declare const ErrorModel: boolean;
66
+ export declare const GiftCard: boolean;
67
+ export declare const LicenseKey: boolean;
68
+ export declare const Log: boolean;
69
+ export declare const LoyaltyPoint: boolean;
70
+ export declare const LoyaltyReward: boolean;
71
+ export declare const Manufacturer: boolean;
72
+ export declare const Notification: boolean;
73
+ export declare const Order: boolean;
74
+ export declare const OrderItem: boolean;
75
+ export declare const Page: boolean;
76
+ export declare const Payment: boolean;
77
+ export declare const PaymentMethod: boolean;
78
+ export declare const PaymentProduct: boolean;
79
+ export declare const PaymentTransaction: boolean;
80
+ export declare const Post: boolean;
81
+ export declare const PrintDevice: boolean;
82
+ export declare const Product: boolean;
83
+ export declare const ProductUnit: boolean;
84
+ export declare const ProductVariant: boolean;
85
+ export declare const Receipt: boolean;
86
+ export declare const Release: boolean;
87
+ export declare const Request: boolean;
88
+ export declare const Review: boolean;
89
+ export declare const ShippingMethod: boolean;
90
+ export declare const ShippingRate: boolean;
91
+ export declare const ShippingZone: boolean;
92
+ export declare const SocialPost: boolean;
93
+ export declare const Subscriber: boolean;
94
+ export declare const SubscriberEmail: boolean;
95
+ export declare const Subscription: boolean;
96
+ export declare const Tag: boolean;
97
+ export declare const TaxRate: boolean;
98
+ export declare const Team: boolean;
99
+ export declare const Transaction: boolean;
100
+ export declare const WaitlistProduct: boolean;
101
+ export declare const WaitlistRestaurant: boolean;
102
+ export declare const Websocket: boolean;
103
+ /**
104
+ * Framework-default User row shape. Matches the attributes declared on
105
+ * `storage/framework/defaults/app/Models/User.ts` plus the system
106
+ * fields contributed by `useUuid` / `useTimestamps` / `useAuth` traits.
107
+ *
108
+ * For project-specific narrowing, prefer `ModelRow<typeof User>` so
109
+ * any added attributes flow through automatically.
110
+ */
111
+ export declare interface UserModel {
112
+ id: number
113
+ uuid: string
114
+ name: string
115
+ email: string
116
+ password: string
117
+ avatar?: string | null
118
+ email_verified_at?: string | null
119
+ two_factor_secret?: string | null
120
+ public_key?: string | null
121
+ created_at: string
122
+ updated_at: string | null
123
+ stripe_id?: string | null
124
+ two_factor_enabled?: boolean
125
+ hasStripeId: () => boolean
126
+ hasRole: (role: string) => boolean | Promise<boolean>
127
+ assignRole: (role: string) => unknown | Promise<unknown>
128
+ update: (data: Record<string, unknown>) => Promise<UserModel>
129
+ [key: string]: unknown
130
+ }
131
+ /**
132
+ * Framework-default insertable User shape — fillable attributes from
133
+ * the default User model, all optional (DB-side defaults can fill in
134
+ * the rest). For project-specific narrowing, prefer
135
+ * `NewModelData<typeof User>`.
136
+ */
137
+ export declare interface NewUser {
138
+ name?: string
139
+ email?: string
140
+ password?: string
141
+ avatar?: string | null
142
+ [key: string]: unknown
143
+ }
144
+ /** Row type for the polymorphic categories table (categorizable trait). */
145
+ export declare interface CategorizableTable {
146
+ id?: number
147
+ name: string
148
+ slug: string
149
+ description?: string
150
+ is_active: boolean
151
+ categorizable_type: string
152
+ created_at?: string
153
+ updated_at?: string
154
+ }
155
+ /** Row type for the category-model pivot table (categorizable trait). */
156
+ export declare interface CategorizableModelsTable {
157
+ id?: number
158
+ category_id: number
159
+ categorizable_type: string
160
+ categorizable_id: number
161
+ created_at?: string
162
+ updated_at?: string
163
+ }
164
+ /** Row type for the polymorphic comments table (commentable trait). */
165
+ export declare interface CommentablesTable {
166
+ id?: number
167
+ title: string
168
+ body: string
169
+ status: string
170
+ approved_at: number | null
171
+ rejected_at: number | null
172
+ commentables_id: number
173
+ commentables_type: string
174
+ user_id: number | null
175
+ created_at?: string
176
+ updated_at?: string | null
177
+ }
178
+ /** Row type for the polymorphic tags table (taggable trait). */
179
+ export declare interface TaggableTable {
180
+ id?: number
181
+ name: string
182
+ slug: string
183
+ description?: string
184
+ is_active: boolean
185
+ taggable_type: string
186
+ created_at?: string
187
+ updated_at?: string
188
+ }
189
+ export * from './utils/prunable';
190
+ export {
191
+ collectEncryptedAttributes,
192
+ decryptValue,
193
+ encryptValue,
194
+ isEncrypted,
195
+ } from './utils/encrypted';
196
+ // Audit trait public API: setAuditUser is the queue/cron escape hatch for
197
+ // attributing audit rows to a user when there's no current HTTP request.
198
+ export { setAuditUser, createAuditMethods } from './traits/audit';
199
+ // Shared write-error classifiers (stacksjs/stacks#1957). Named exports only —
200
+ // `export *` would collide with the snakeCase helpers also exported from
201
+ // './auto-crud' via other barrels. `isUniqueViolation` is re-exported by
202
+ // `@stacksjs/auth`'s './rbac-store-bqb' for back-compat; `mapWriteError`
203
+ // powers the auto-CRUD store/update 409 mapping.
204
+ export { isUniqueViolation, mapWriteError } from './auto-crud';
205
+ export * from './batch-loader';
206
+ export * from './db';
207
+ export * from './subquery';
208
+ export * from './transaction';
209
+ export * from './model-types';
210
+ export * from './types';
211
+ export * from './utils';
212
+ export * from './define-model';
213
+ // Codegen for `database/types.d.ts` — augments
214
+ // `@stacksjs/database`'s `DatabaseSchema` so `db.selectFrom(...)` gets
215
+ // table-name autocomplete (stacksjs/stacks#1923).
216
+ export { buildDatabaseSchema, renderDatabaseTypeFile } from './generate-database-schema';
217
+ // Canonical paginator shapes + adapters (stacksjs/stacks#1905 P1).
218
+ export {
219
+ isCursorPaginator,
220
+ isPaginator,
221
+ isSimplePaginator,
222
+ toCursorPaginator,
223
+ toPaginator,
224
+ toSimplePaginator,
225
+ } from './paginator';
226
+ // Request-aware pagination helpers (stacksjs/stacks#1906 P2 + #1907 P3).
227
+ export {
228
+ enrichPaginatorUrls,
229
+ parseCursor,
230
+ resolveCursorArgs,
231
+ resolvePageArgs,
232
+ } from './paginator-request';