Skip to content

Commit

Permalink
chore: add documentation for parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
JulissaDantes committed Mar 21, 2024
1 parent b3198de commit 0029707
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class ModelInstanceDocumentHandler implements StreamHandler<ModelInstance
}

const oldContent = state.content ?? {}
const newContent = jsonpatch.applyPatch(oldContent, payload.data, undefined, false).newDocument
const newContent = jsonpatch.applyPatch(oldContent, payload.data).newDocument
const modelStream = await context.loadStream<Model>(metadata.model)
const isDetType = deterministicTypes.includes(modelStream.content.accountRelation.type)
const isFirstDataCommit = !state.log.some((c) => c.type === EventType.DATA)
Expand Down Expand Up @@ -249,8 +249,9 @@ export class ModelInstanceDocumentHandler implements StreamHandler<ModelInstance
* Validates content against the schema of the model stream with given stream id
* @param ceramic - Interface for reading streams from ceramic network
* @param model - The model that this ModelInstanceDocument belongs to
* @param content - content to validate
* @param genesis - whether the commit being applied is a genesis commit
* @param content - Content to validate
* @param genesis - Whether the commit being applied is a genesis commit
* @param enforceImmutableFields - Whether the incoming commit is the first data commit for a model with deterministic creation (Optional)
* @private
*/
async _validateContent(
Expand All @@ -259,7 +260,7 @@ export class ModelInstanceDocumentHandler implements StreamHandler<ModelInstance
content: any,
genesis: boolean,
payload?: Payload,
hasContent?: boolean
enforceImmutableFields?: boolean
): Promise<void> {
if (
genesis &&
Expand All @@ -280,7 +281,7 @@ export class ModelInstanceDocumentHandler implements StreamHandler<ModelInstance

// Now validate the relations
await this._validateRelationsContent(ceramic, model, content)
if (!genesis && payload && !hasContent) {
if (!genesis && payload && !enforceImmutableFields) {
await this._validateLockedFieldsUpdate(model, payload)
}
}
Expand Down

0 comments on commit 0029707

Please sign in to comment.