@stacksjs/orm 0.74.1 → 0.74.3
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/auto-crud.d.ts +30 -0
- package/dist/generate-database-schema.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -9
- package/dist/migration-tables.d.ts +18 -0
- package/dist/models/AnalyticsEvent.ts +5 -0
- package/dist/models/Content/Menu.ts +5 -1
- package/dist/models/Content/MenuItem.ts +6 -1
- package/dist/models/Content/Page.ts +5 -1
- package/dist/models/Content/Post.ts +5 -1
- package/dist/models/Content/Redirect.ts +5 -1
- package/dist/models/EmailIdempotency.ts +5 -0
- package/dist/models/EmailList.ts +6 -0
- package/dist/models/EmailSuppression.ts +5 -0
- package/dist/models/EmailWebhookEvent.ts +5 -0
- package/dist/models/Forms/Form.ts +5 -1
- package/dist/models/Forms/FormField.ts +6 -1
- package/dist/models/MailPreference.ts +5 -0
- package/dist/models/Request.ts +5 -0
- package/dist/models/SiteDomain.ts +5 -1
- package/dist/models/Tag.ts +6 -0
- package/dist/models/Team.ts +6 -1
- package/dist/models/User.ts +6 -1
- package/dist/models/commerce/Auction.ts +6 -0
- package/dist/models/commerce/AuctionItem.ts +6 -0
- package/dist/models/commerce/Cart.ts +6 -1
- package/dist/models/commerce/CartItem.ts +6 -1
- package/dist/models/commerce/Category.ts +6 -0
- package/dist/models/commerce/Coupon.ts +6 -0
- package/dist/models/commerce/DeliveryRoute.ts +6 -1
- package/dist/models/commerce/DeliveryStop.ts +6 -1
- package/dist/models/commerce/GiftCard.ts +6 -1
- package/dist/models/commerce/LicenseKey.ts +6 -1
- package/dist/models/commerce/LoyaltyReward.ts +6 -0
- package/dist/models/commerce/Manufacturer.ts +6 -0
- package/dist/models/commerce/Order.ts +6 -1
- package/dist/models/commerce/Payment.ts +6 -1
- package/dist/models/commerce/PrintDevice.ts +6 -0
- package/dist/models/commerce/Product.ts +6 -0
- package/dist/models/commerce/ProductUnit.ts +6 -0
- package/dist/models/commerce/ProductVariant.ts +6 -0
- package/dist/models/commerce/Review.ts +6 -1
- package/dist/models/commerce/ShippingMethod.ts +6 -0
- package/dist/models/commerce/ShippingRate.ts +6 -0
- package/dist/models/commerce/ShippingZone.ts +6 -0
- package/dist/models/commerce/TaxRate.ts +6 -0
- package/dist/models/commerce/Transaction.ts +6 -1
- package/dist/models/commerce/WaitlistProduct.ts +6 -1
- package/dist/models/commerce/WaitlistRestaurant.ts +6 -1
- package/dist/models/realtime/Websocket.ts +5 -0
- package/dist/ownership.d.ts +96 -0
- package/dist/routes.js +1 -1
- package/package.json +21 -21
package/dist/auto-crud.d.ts
CHANGED
|
@@ -57,6 +57,36 @@ export declare function teamOwnershipField(model: {
|
|
|
57
57
|
attributes?: Record<string, unknown>
|
|
58
58
|
belongsTo?: unknown[]
|
|
59
59
|
} | null | undefined): string | null;
|
|
60
|
+
/**
|
|
61
|
+
* Resolve the database column used for automatic per-user ownership.
|
|
62
|
+
*
|
|
63
|
+
* The same principle `teamOwnershipField` applies to tenants, applied to the
|
|
64
|
+
* rows a single caller owns: a model carrying `user_id` (declared, or created
|
|
65
|
+
* by a `belongsTo: ['User']` relation during model-driven migration) has a
|
|
66
|
+
* per-row owner already, so it does not need to repeat that fact as an
|
|
67
|
+
* `ownership` config just to get API isolation.
|
|
68
|
+
*
|
|
69
|
+
* Ten of the framework's own models are in this shape - Card, Comment,
|
|
70
|
+
* Notification, Subscriber and friends - and every one of them published
|
|
71
|
+
* mutating routes that any authenticated caller could point at any row
|
|
72
|
+
* (stacksjs/stacks#2375).
|
|
73
|
+
*/
|
|
74
|
+
export declare function userOwnershipField(model: {
|
|
75
|
+
attributes?: Record<string, unknown>
|
|
76
|
+
belongsTo?: unknown[]
|
|
77
|
+
} | null | undefined): string | null;
|
|
78
|
+
/**
|
|
79
|
+
* A model that has declared, in as many words, that its rows have no per-caller
|
|
80
|
+
* owner: `ownership: false`.
|
|
81
|
+
*
|
|
82
|
+
* This is what separates "considered, and there is genuinely nothing to scope
|
|
83
|
+
* by" - a public catalog table - from "nobody thought about it", which is the
|
|
84
|
+
* state `security.api.rowScoping: 'deny'` refuses to generate writes for. The
|
|
85
|
+
* two were indistinguishable before, which is why denying by default needed
|
|
86
|
+
* this to exist first: without it the safe default also punishes every model
|
|
87
|
+
* that is legitimately unscoped.
|
|
88
|
+
*/
|
|
89
|
+
export declare function ownershipDeclaredUnscoped(model: { ownership?: unknown } | null | undefined): boolean;
|
|
60
90
|
/**
|
|
61
91
|
* Remove every client spelling of an ownership field, then apply the trusted
|
|
62
92
|
* value resolved from the authenticated request. Array ownership is used for
|
package/dist/index.d.ts
CHANGED
|
@@ -280,6 +280,9 @@ export { createLikeableMethods } from './traits/likeable';
|
|
|
280
280
|
// `@stacksjs/auth`'s './rbac-store-bqb' for back-compat; `mapWriteError`
|
|
281
281
|
// powers the auto-CRUD store/update 409 mapping.
|
|
282
282
|
export { filterFillable, getWritableFields, isUniqueViolation, mapWriteError, toSnakeCaseKeys } from './auto-crud';
|
|
283
|
+
// Ready-made `ownership` resolvers for models whose owner is one hop away
|
|
284
|
+
// (stacksjs/stacks#2375).
|
|
285
|
+
export { customerOwnership, parentOwnership, selfOwnership, siteOwnership, teamMembershipOwnership } from './ownership';
|
|
283
286
|
export * from './batch-loader';
|
|
284
287
|
export * from './db';
|
|
285
288
|
export * from './subquery';
|