@sanity/mutator
Advanced tools
Comparing version 3.57.2-canary.16 to 3.57.2-manifests.67
@@ -100,2 +100,3 @@ import {CreateIfNotExistsMutation} from '@sanity/types' | ||
_updatedAt?: string | ||
_createdAt?: string | ||
[attribute: string]: unknown | ||
@@ -102,0 +103,0 @@ } |
{ | ||
"name": "@sanity/mutator", | ||
"version": "3.57.2-canary.16+5cb335b1a2", | ||
"version": "3.57.2-manifests.67+0246fa6e86", | ||
"description": "A set of models to make it easier to utilize the powerful real time collaborative features of Sanity", | ||
@@ -53,3 +53,3 @@ "keywords": [ | ||
"@sanity/diff-match-patch": "^3.1.1", | ||
"@sanity/types": "3.57.2-canary.16+5cb335b1a2", | ||
"@sanity/types": "3.57.2-manifests.67+0246fa6e86", | ||
"@sanity/uuid": "^3.0.1", | ||
@@ -61,3 +61,3 @@ "debug": "^4.3.4", | ||
"@jest/globals": "^29.7.0", | ||
"@repo/package.config": "3.57.1", | ||
"@repo/package.config": "3.57.4", | ||
"@types/debug": "^4.1.5", | ||
@@ -67,3 +67,3 @@ "@types/lodash": "^4.17.7", | ||
}, | ||
"gitHead": "5cb335b1a2dcdf5cc967e88e22d2e8c082bb9c2e" | ||
"gitHead": "0246fa6e86d13669d16c487d1667baf36981ed98" | ||
} |
@@ -109,6 +109,10 @@ import {Patcher} from '../patch' | ||
// creation requires a _createdAt | ||
const getGuaranteedCreatedAt = (doc: Doc): string => | ||
doc?._createdAt || this.params.timestamp || new Date().toISOString() | ||
this.mutations.forEach((mutation) => { | ||
if (mutation.create) { | ||
// TODO: Fail entire patch if document did exist | ||
const create = mutation.create || {} | ||
const create = (mutation.create || {}) as Doc | ||
operations.push((doc): Doc => { | ||
@@ -119,4 +123,4 @@ if (doc) { | ||
return Object.assign(create as Doc, { | ||
_createdAt: create._createdAt || this.params.timestamp, | ||
return Object.assign(create, { | ||
_createdAt: getGuaranteedCreatedAt(create), | ||
}) | ||
@@ -132,3 +136,3 @@ }) | ||
? Object.assign(createIfNotExists, { | ||
_createdAt: createIfNotExists._createdAt || this.params.timestamp, | ||
_createdAt: getGuaranteedCreatedAt(createIfNotExists), | ||
}) | ||
@@ -144,3 +148,3 @@ : doc, | ||
Object.assign(createOrReplace, { | ||
_createdAt: createOrReplace._createdAt || this.params.timestamp, | ||
_createdAt: getGuaranteedCreatedAt(createOrReplace), | ||
}), | ||
@@ -147,0 +151,0 @@ ) |
@@ -19,2 +19,3 @@ import { | ||
_updatedAt?: string | ||
_createdAt?: string | ||
[attribute: string]: unknown | ||
@@ -21,0 +22,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
785123
9008