Skip to content

Commit c933db1

Browse files
authored
chore: docblock improvements (#451)
# Why Asked claude to audit the docblocks for incorrect or missing info. This is what it mentioned as being good improvements. # How Update docblocks. # Test Plan Proofread.
1 parent d9377a2 commit c933db1

4 files changed

Lines changed: 33 additions & 1 deletion

File tree

packages/entity/src/EnforcingEntityCreator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ReadonlyEntity } from './ReadonlyEntity';
66
import { ViewerContext } from './ViewerContext';
77

88
/**
9-
* Enforcing entity creator. All updates
9+
* Enforcing entity creator. All creates
1010
* through this creator will throw if authorization is not successful.
1111
*/
1212
export class EnforcingEntityCreator<

packages/entity/src/Entity.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ import { ViewerContext } from './ViewerContext';
3232
*
3333
* All concrete entity implementations should extend this class and provide their
3434
* own EntityCompanionDefinition.
35+
*
36+
* Generic type parameters:
37+
* TFields - the shape of the underlying data for this entity, typically corresponding to a database table schema. The mapping from TFields to the actual database schema is defined in the EntityCompanionDefinition for this entity.
38+
* TIDField - the key of the ID field in TFields, which must be non-nullable and is used to uniquely identify individual entities
39+
* TViewerContext - the type of ViewerContext that can be used with this entity
40+
* TSelectedFields - the keys of fields in TFields that belong to this entity; used when there are multiple entities backed by the same underlying table with different field subsets
3541
*/
3642
export abstract class Entity<
3743
TFields extends Record<string, any>,

packages/entity/src/EntityPrivacyPolicy.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,27 +123,42 @@ export abstract class EntityPrivacyPolicy<
123123
TEntity extends ReadonlyEntity<TFields, TIDField, TViewerContext, TSelectedFields>,
124124
TSelectedFields extends keyof TFields = keyof TFields,
125125
> {
126+
/**
127+
* List of rules to evaluate for create authorization.
128+
*/
126129
protected readonly createRules: readonly PrivacyPolicyRule<
127130
TFields,
128131
TIDField,
129132
TViewerContext,
130133
TEntity,
131134
TSelectedFields
132135
>[] = [];
136+
137+
/**
138+
* List of rules to evaluate for read authorization.
139+
*/
133140
protected readonly readRules: readonly PrivacyPolicyRule<
134141
TFields,
135142
TIDField,
136143
TViewerContext,
137144
TEntity,
138145
TSelectedFields
139146
>[] = [];
147+
148+
/**
149+
* List of rules to evaluate for update authorization.
150+
*/
140151
protected readonly updateRules: readonly PrivacyPolicyRule<
141152
TFields,
142153
TIDField,
143154
TViewerContext,
144155
TEntity,
145156
TSelectedFields
146157
>[] = [];
158+
159+
/**
160+
* List of rules to evaluate for delete authorization.
161+
*/
147162
protected readonly deleteRules: readonly PrivacyPolicyRule<
148163
TFields,
149164
TIDField,
@@ -156,6 +171,9 @@ export abstract class EntityPrivacyPolicy<
156171
* Get the privacy policy evaluation mode and deny handler for this policy.
157172
* Defaults to normal enforcing policy.
158173
*
174+
* DRY_RUN mode is useful for testing and logging the effects of a policy without actually enforcing it, such as when
175+
* first rolling out a new policy. Entities that fail the policy will be allowed so caution should be take when using.
176+
*
159177
* @remarks
160178
*
161179
* Override to enable dry run evaluation of the policy.
@@ -204,7 +222,9 @@ export abstract class EntityPrivacyPolicy<
204222
* Authorize an entity against read policy.
205223
* @param viewerContext - viewer context of user reading the entity
206224
* @param queryContext - query context in which to perform the read authorization
225+
* @param evaluationContext - context about the reason for this privacy policy evaluation
207226
* @param entity - entity to authorize
227+
* @param metricsAdapter - adapter for logging metrics about this authorization
208228
* @returns entity if authorized
209229
* @throws EntityNotAuthorizedError when not authorized
210230
*/
@@ -236,7 +256,9 @@ export abstract class EntityPrivacyPolicy<
236256
* Authorize an entity against update policy.
237257
* @param viewerContext - viewer context of user updating the entity
238258
* @param queryContext - query context in which to perform the update authorization
259+
* @param evaluationContext - context about the reason for this privacy policy evaluation
239260
* @param entity - entity to authorize
261+
* @param metricsAdapter - adapter for logging metrics about this authorization
240262
* @returns entity if authorized
241263
* @throws EntityNotAuthorizedError when not authorized
242264
*/
@@ -268,7 +290,9 @@ export abstract class EntityPrivacyPolicy<
268290
* Authorize an entity against deletion policy.
269291
* @param viewerContext - viewer context of user deleting the entity
270292
* @param queryContext - query context in which to perform the delete authorization
293+
* @param evaluationContext - context about the reason for this privacy policy evaluation
271294
* @param entity - entity to authorize
295+
* @param metricsAdapter - adapter for logging metrics about this authorization
272296
* @returns entity if authorized
273297
* @throws EntityNotAuthorizedError when not authorized
274298
*/

packages/entity/src/internal/EntityLoadInterfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { ISerializable, SerializableKeyMap } from '../utils/collections/Serializ
33

44
/**
55
* Load method type identifier of a load key. Used for keying data loaders and identification in metrics.
6+
*
7+
* @internal
68
*/
79
export enum EntityLoadMethodType {
810
/**

0 commit comments

Comments
 (0)