@sanity/diff 5.8.0 → 5.8.1-next.10

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.
Files changed (2) hide show
  1. package/lib/index.d.ts +100 -95
  2. package/package.json +16 -16
package/lib/index.d.ts CHANGED
@@ -7,11 +7,11 @@
7
7
  * @public
8
8
  */
9
9
  export declare interface AddedDiff<A, V> {
10
- action: 'added'
11
- isChanged: true
12
- fromValue: null | undefined
13
- toValue: V
14
- annotation: A
10
+ action: "added";
11
+ isChanged: true;
12
+ fromValue: null | undefined;
13
+ toValue: V;
14
+ annotation: A;
15
15
  }
16
16
 
17
17
  /**
@@ -22,9 +22,9 @@ export declare interface AddedDiff<A, V> {
22
22
  * @public
23
23
  */
24
24
  export declare type ArrayDiff<A, V = unknown> = FullDiff<A, V[]> & {
25
- type: 'array'
26
- items: ItemDiff<A>[]
27
- }
25
+ type: "array";
26
+ items: ItemDiff<A>[];
27
+ };
28
28
 
29
29
  /**
30
30
  * Input type for array values. Helper functions are available for getting the item and/or
@@ -34,29 +34,29 @@ export declare type ArrayDiff<A, V = unknown> = FullDiff<A, V[]> & {
34
34
  * @public
35
35
  */
36
36
  export declare interface ArrayInput<A> extends BaseInput<A> {
37
- type: 'array'
37
+ type: "array";
38
38
  /**
39
39
  * The actual array value
40
40
  */
41
- value: unknown[]
41
+ value: unknown[];
42
42
  /**
43
43
  * The length of the array
44
44
  */
45
- length: number
45
+ length: number;
46
46
  /**
47
47
  * Retrieve the value at the given `index`, automatically wrapping it in an input container.
48
48
  *
49
49
  * @param index - The index of the item to retrieve
50
50
  * @returns Typed input container, or `undefined` if the item does not exist
51
51
  */
52
- at(index: number): Input<A>
52
+ at(index: number): Input<A>;
53
53
  /**
54
54
  * Retrieve the _annotation_ for an item at the given index
55
55
  *
56
56
  * @param index - The index of the item to fetch the annotation for
57
57
  * @returns The annotation at the given index, or `undefined` if the item does not exist
58
58
  */
59
- annotationAt(index: number): A
59
+ annotationAt(index: number): A;
60
60
  }
61
61
 
62
62
  /**
@@ -66,7 +66,7 @@ export declare interface ArrayInput<A> extends BaseInput<A> {
66
66
  * @public
67
67
  */
68
68
  export declare interface BaseInput<A> {
69
- annotation: A
69
+ annotation: A;
70
70
  }
71
71
 
72
72
  /**
@@ -76,8 +76,8 @@ export declare interface BaseInput<A> {
76
76
  * @public
77
77
  */
78
78
  export declare type BooleanDiff<A> = FullDiff<A, boolean> & {
79
- type: 'boolean'
80
- }
79
+ type: "boolean";
80
+ };
81
81
 
82
82
  /**
83
83
  * Input type for booleans.
@@ -86,8 +86,8 @@ export declare type BooleanDiff<A> = FullDiff<A, boolean> & {
86
86
  * @public
87
87
  */
88
88
  export declare interface BooleanInput<A> extends BaseInput<A> {
89
- type: 'boolean'
90
- value: boolean
89
+ type: "boolean";
90
+ value: boolean;
91
91
  }
92
92
 
93
93
  /**
@@ -101,11 +101,11 @@ export declare interface BooleanInput<A> extends BaseInput<A> {
101
101
  * @public
102
102
  */
103
103
  export declare interface ChangedDiff<A, V> {
104
- action: 'changed'
105
- isChanged: true
106
- fromValue: V
107
- toValue: V
108
- annotation: A
104
+ action: "changed";
105
+ isChanged: true;
106
+ fromValue: V;
107
+ toValue: V;
108
+ annotation: A;
109
109
  }
110
110
 
111
111
  /**
@@ -121,7 +121,7 @@ export declare type Diff<A> =
121
121
  | BooleanDiff<A>
122
122
  | ObjectDiff<A>
123
123
  | ArrayDiff<A>
124
- | TypeChangeDiff<A>
124
+ | TypeChangeDiff<A>;
125
125
 
126
126
  /**
127
127
  * Takes a `from` and `to` input and calulates a diff between the two
@@ -136,14 +136,14 @@ export declare function diffInput<A>(
136
136
  fromInput: Input<A>,
137
137
  toInput: Input<A>,
138
138
  options?: DiffOptions,
139
- ): Diff<A>
139
+ ): Diff<A>;
140
140
 
141
141
  /**
142
142
  * Options available for doing diffs. Currently no options are defined.
143
143
  *
144
144
  * @public
145
145
  */
146
- export declare type DiffOptions = Record<string, never>
146
+ export declare type DiffOptions = Record<string, never>;
147
147
 
148
148
  /**
149
149
  * Diff with all the possible diff types.
@@ -156,7 +156,7 @@ export declare type FullDiff<A, V> =
156
156
  | AddedDiff<A, V>
157
157
  | RemovedDiff<A, V>
158
158
  | ChangedDiff<A, V>
159
- | UnchangedDiff<A, V>
159
+ | UnchangedDiff<A, V>;
160
160
 
161
161
  /**
162
162
  * An "input" holds the _type_ of the value, the actual value, an optional annotation,
@@ -170,7 +170,7 @@ export declare type Input<T> =
170
170
  | StringInput<T>
171
171
  | NullInput<T>
172
172
  | ObjectInput<T>
173
- | ArrayInput<T>
173
+ | ArrayInput<T>;
174
174
 
175
175
  /**
176
176
  * Diff of an item in an array, representing whether or not it has moved within the array,
@@ -184,11 +184,11 @@ export declare type Input<T> =
184
184
  * @public
185
185
  */
186
186
  export declare interface ItemDiff<A> {
187
- fromIndex: number | undefined
188
- toIndex: number | undefined
189
- hasMoved: boolean
190
- diff: Diff<A>
191
- annotation: A
187
+ fromIndex: number | undefined;
188
+ toIndex: number | undefined;
189
+ hasMoved: boolean;
190
+ diff: Diff<A>;
191
+ annotation: A;
192
192
  }
193
193
 
194
194
  /**
@@ -198,8 +198,8 @@ export declare interface ItemDiff<A> {
198
198
  * @public
199
199
  */
200
200
  export declare type NullDiff<A> = FullDiff<A, null> & {
201
- type: 'null'
202
- }
201
+ type: "null";
202
+ };
203
203
 
204
204
  /**
205
205
  * Input type for `null` values.
@@ -208,8 +208,8 @@ export declare type NullDiff<A> = FullDiff<A, null> & {
208
208
  * @public
209
209
  */
210
210
  export declare interface NullInput<A> extends BaseInput<A> {
211
- type: 'null'
212
- value: null
211
+ type: "null";
212
+ value: null;
213
213
  }
214
214
 
215
215
  /**
@@ -219,8 +219,8 @@ export declare interface NullInput<A> extends BaseInput<A> {
219
219
  * @public
220
220
  */
221
221
  export declare type NumberDiff<A> = FullDiff<A, number> & {
222
- type: 'number'
223
- }
222
+ type: "number";
223
+ };
224
224
 
225
225
  /**
226
226
  * Input type for numbers.
@@ -229,8 +229,8 @@ export declare type NumberDiff<A> = FullDiff<A, number> & {
229
229
  * @public
230
230
  */
231
231
  export declare interface NumberInput<A> extends BaseInput<A> {
232
- type: 'number'
233
- value: number
232
+ type: "number";
233
+ value: number;
234
234
  }
235
235
 
236
236
  /**
@@ -240,10 +240,13 @@ export declare interface NumberInput<A> extends BaseInput<A> {
240
240
  * @typeParam T - Value type.
241
241
  * @public
242
242
  */
243
- export declare type ObjectDiff<A, T extends object = Record<string, any>> = FullDiff<A, T> & {
244
- type: 'object'
245
- fields: Record<keyof T, Diff<A>>
246
- }
243
+ export declare type ObjectDiff<
244
+ A,
245
+ T extends object = Record<string, any>,
246
+ > = FullDiff<A, T> & {
247
+ type: "object";
248
+ fields: Record<keyof T, Diff<A>>;
249
+ };
247
250
 
248
251
  /**
249
252
  * Input type for object values. Caches the available keys, and allows retrieval of properties,
@@ -253,22 +256,22 @@ export declare type ObjectDiff<A, T extends object = Record<string, any>> = Full
253
256
  * @public
254
257
  */
255
258
  export declare interface ObjectInput<A> extends BaseInput<A> {
256
- type: 'object'
259
+ type: "object";
257
260
  /**
258
261
  * The actual object value
259
262
  */
260
- value: Record<string, unknown>
263
+ value: Record<string, unknown>;
261
264
  /**
262
265
  * The keys of the object
263
266
  */
264
- keys: string[]
267
+ keys: string[];
265
268
  /**
266
269
  * Retrieve the property with the given `key`, automatically wrapping it in an input container.
267
270
  *
268
271
  * @param key - The key of the property you want to retrieve.
269
272
  * @returns Typed input container, or `undefined` if the property does not exist
270
273
  */
271
- get(key: string): Input<A> | undefined
274
+ get(key: string): Input<A> | undefined;
272
275
  }
273
276
 
274
277
  /**
@@ -280,11 +283,11 @@ export declare interface ObjectInput<A> extends BaseInput<A> {
280
283
  * @public
281
284
  */
282
285
  export declare interface RemovedDiff<A, V> {
283
- action: 'removed'
284
- isChanged: true
285
- fromValue: V
286
- toValue: null | undefined
287
- annotation: A
286
+ action: "removed";
287
+ isChanged: true;
288
+ fromValue: V;
289
+ toValue: null | undefined;
290
+ annotation: A;
288
291
  }
289
292
 
290
293
  /**
@@ -295,9 +298,9 @@ export declare interface RemovedDiff<A, V> {
295
298
  * @public
296
299
  */
297
300
  export declare type StringDiff<A> = FullDiff<A, string> & {
298
- type: 'string'
299
- segments: StringDiffSegment<A>[]
300
- }
301
+ type: "string";
302
+ segments: StringDiffSegment<A>[];
303
+ };
301
304
 
302
305
  /**
303
306
  * Diff of a string segment (eg a portion/slice), and whether or not it was changed or unchanged.
@@ -305,7 +308,9 @@ export declare type StringDiff<A> = FullDiff<A, string> & {
305
308
  * @typeParam A - Annotation. Timestamps, author and similar info is attached by Sanity, but anything is allowed.
306
309
  * @public
307
310
  */
308
- export declare type StringDiffSegment<A> = StringSegmentChanged<A> | StringSegmentUnchanged
311
+ export declare type StringDiffSegment<A> =
312
+ | StringSegmentChanged<A>
313
+ | StringSegmentUnchanged;
309
314
 
310
315
  /**
311
316
  * Input type for strings, which supports slicing parts of the string while maintaining the
@@ -315,15 +320,15 @@ export declare type StringDiffSegment<A> = StringSegmentChanged<A> | StringSegme
315
320
  * @public
316
321
  */
317
322
  export declare interface StringInput<A> extends BaseInput<A> {
318
- type: 'string'
319
- value: string
323
+ type: "string";
324
+ value: string;
320
325
  sliceAnnotation(
321
326
  start: number,
322
327
  end: number,
323
328
  ): {
324
- text: string
325
- annotation: A
326
- }[]
329
+ text: string;
330
+ annotation: A;
331
+ }[];
327
332
  }
328
333
 
329
334
  /**
@@ -333,10 +338,10 @@ export declare interface StringInput<A> extends BaseInput<A> {
333
338
  * @public
334
339
  */
335
340
  export declare interface StringSegmentChanged<A> {
336
- type: 'stringSegment'
337
- action: 'added' | 'removed'
338
- text: string
339
- annotation: A
341
+ type: "stringSegment";
342
+ action: "added" | "removed";
343
+ text: string;
344
+ annotation: A;
340
345
  }
341
346
 
342
347
  /**
@@ -345,9 +350,9 @@ export declare interface StringSegmentChanged<A> {
345
350
  * @public
346
351
  */
347
352
  export declare interface StringSegmentUnchanged {
348
- type: 'stringSegment'
349
- action: 'unchanged'
350
- text: string
353
+ type: "stringSegment";
354
+ action: "unchanged";
355
+ text: string;
351
356
  }
352
357
 
353
358
  /**
@@ -358,20 +363,20 @@ export declare interface StringSegmentUnchanged {
358
363
  * @public
359
364
  */
360
365
  export declare interface TypeChangeDiff<A> {
361
- type: 'typeChange'
362
- action: 'changed'
363
- isChanged: true
364
- fromType: string
365
- fromValue: unknown
366
+ type: "typeChange";
367
+ action: "changed";
368
+ isChanged: true;
369
+ fromType: string;
370
+ fromValue: unknown;
366
371
  fromDiff: Diff<A> & {
367
- action: 'removed'
368
- }
369
- toType: string
370
- toValue: unknown
372
+ action: "removed";
373
+ };
374
+ toType: string;
375
+ toValue: unknown;
371
376
  toDiff: Diff<A> & {
372
- action: 'added'
373
- }
374
- annotation: A
377
+ action: "added";
378
+ };
379
+ annotation: A;
375
380
  }
376
381
 
377
382
  /**
@@ -382,10 +387,10 @@ export declare interface TypeChangeDiff<A> {
382
387
  * @public
383
388
  */
384
389
  export declare interface UnchangedDiff<A, V> {
385
- action: 'unchanged'
386
- isChanged: false
387
- fromValue: V
388
- toValue: V
390
+ action: "unchanged";
391
+ isChanged: false;
392
+ fromValue: V;
393
+ toValue: V;
389
394
  }
390
395
 
391
396
  /**
@@ -394,13 +399,13 @@ export declare interface UnchangedDiff<A, V> {
394
399
  * @public
395
400
  */
396
401
  export declare type ValueType =
397
- | 'array'
398
- | 'boolean'
399
- | 'null'
400
- | 'number'
401
- | 'object'
402
- | 'string'
403
- | 'undefined'
402
+ | "array"
403
+ | "boolean"
404
+ | "null"
405
+ | "number"
406
+ | "object"
407
+ | "string"
408
+ | "undefined";
404
409
 
405
410
  /**
406
411
  * Takes an input (any JSON-serializable value) and an annotation, and generates an input
@@ -412,6 +417,6 @@ export declare type ValueType =
412
417
  * @throws if `input` is not a JSON-serializable type
413
418
  * @public
414
419
  */
415
- export declare function wrap<A>(input: unknown, annotation: A): Input<A>
420
+ export declare function wrap<A>(input: unknown, annotation: A): Input<A>;
416
421
 
417
- export {}
422
+ export {};
package/package.json CHANGED
@@ -1,48 +1,48 @@
1
1
  {
2
2
  "name": "@sanity/diff",
3
- "version": "5.8.0",
3
+ "version": "5.8.1-next.10+8618f8476b",
4
4
  "description": "Generates diffs between documents and primitive types",
5
5
  "keywords": [
6
- "sanity",
7
6
  "cms",
7
+ "content",
8
+ "diff",
8
9
  "headless",
9
10
  "realtime",
10
- "content",
11
- "diff"
11
+ "sanity"
12
12
  ],
13
13
  "homepage": "https://www.sanity.io/",
14
14
  "bugs": {
15
15
  "url": "https://github.com/sanity-io/sanity/issues"
16
16
  },
17
+ "license": "MIT",
18
+ "author": "Sanity.io <hello@sanity.io>",
17
19
  "repository": {
18
20
  "type": "git",
19
21
  "url": "git+https://github.com/sanity-io/sanity.git",
20
22
  "directory": "packages/@sanity/diff"
21
23
  },
22
- "license": "MIT",
23
- "author": "Sanity.io <hello@sanity.io>",
24
- "sideEffects": false,
24
+ "files": [
25
+ "lib"
26
+ ],
25
27
  "type": "module",
28
+ "sideEffects": false,
29
+ "main": "./lib/index.js",
30
+ "types": "./lib/index.d.ts",
26
31
  "exports": {
27
32
  ".": "./lib/index.js",
28
33
  "./package.json": "./package.json"
29
34
  },
30
- "main": "./lib/index.js",
31
- "types": "./lib/index.d.ts",
32
- "files": [
33
- "lib"
34
- ],
35
35
  "dependencies": {
36
36
  "@sanity/diff-match-patch": "^3.2.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@sanity/pkg-utils": "^10.4.3",
39
+ "@sanity/pkg-utils": "^10.4.4",
40
40
  "@typescript/native-preview": "7.0.0-dev.20260112.1",
41
41
  "eslint": "^9.39.2",
42
42
  "rimraf": "^5.0.10",
43
- "@repo/eslint-config": "5.8.0",
44
- "@repo/package.config": "5.8.0",
45
- "@repo/tsconfig": "5.8.0"
43
+ "@repo/tsconfig": "5.8.1-next.10+8618f8476b",
44
+ "@repo/eslint-config": "5.8.1-next.10+8618f8476b",
45
+ "@repo/package.config": "5.8.1-next.10+8618f8476b"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=20.19 <22 || >=22.12"