@supernova-studio/model 0.53.4 → 0.53.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supernova-studio/model",
3
- "version": "0.53.4",
3
+ "version": "0.53.6",
4
4
  "description": "Supernova Data Models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,11 +32,9 @@
32
32
  "dependencies": {
33
33
  "@sindresorhus/slugify": "1.1.2",
34
34
  "ip-cidr": "3.1.0",
35
- "zod": "3.23.6",
36
- "deep-equal": "2.2.3"
35
+ "zod": "3.23.6"
37
36
  },
38
37
  "devDependencies": {
39
- "@types/deep-equal": "1.0.4",
40
38
  "fs": "0.0.1-security",
41
39
  "tsup": "8.0.2",
42
40
  "typescript": "5.0.4"
@@ -1,7 +1,6 @@
1
- import deepEqual from "deep-equal";
2
1
  import { z } from "zod";
3
2
  import { nullishToOptional } from "../../../helpers";
4
- import { mapByUnique } from "../../../utils";
3
+ import { areShallowObjectsEqual, mapByUnique } from "../../../utils";
5
4
  import { ColorTokenInlineData } from "../../properties";
6
5
  import { Size } from "../primitives";
7
6
  import { DesignTokenType } from "../raw-element";
@@ -46,6 +45,7 @@ export const PageBlockTypeV1 = z.enum([
46
45
  "TableRow",
47
46
  "TableCell",
48
47
  "Guidelines",
48
+ "Guideline",
49
49
  ]);
50
50
 
51
51
  export const PageBlockCodeLanguage = z.enum([
@@ -305,7 +305,7 @@ export const PageBlockBaseV1 = z.object({
305
305
  shortcuts: nullishToOptional(z.array(PageBlockShortcut)),
306
306
 
307
307
  // Guidelines
308
- guidelines: nullishToOptional(PageBlockGuideline.array()),
308
+ guideline: nullishToOptional(PageBlockGuideline),
309
309
 
310
310
  // Custom blocks
311
311
  customBlockKey: nullishToOptional(z.string()),
@@ -416,7 +416,7 @@ function areAttributesEqual(lhs: PageBlockTextSpanAttribute[], rhs: PageBlockTex
416
416
  const lhsMap = mapByUnique(lhs, i => i.type);
417
417
  for (const rhsAttribute of rhs) {
418
418
  const lhsAttribute = lhsMap.get(rhsAttribute.type);
419
- if (!deepEqual(lhsAttribute, rhsAttribute)) return false;
419
+ if (!areShallowObjectsEqual(lhsAttribute, rhsAttribute)) return false;
420
420
  }
421
421
 
422
422
  return true;
@@ -124,6 +124,28 @@ export function uniqueBy<K, V>(items: V[], prop: (v: V) => K): V[] {
124
124
  return Array.from(mapByUnique(items, prop).values());
125
125
  }
126
126
 
127
+ export function areShallowObjectsEqual<T extends object>(lhs: T | undefined, rhs: T | undefined) {
128
+ if ((lhs === undefined) !== (rhs === undefined)) return false;
129
+ if (lhs === undefined || rhs === undefined) return true;
130
+
131
+ if ((lhs === null) !== (rhs === null)) return false;
132
+ if (lhs === null || rhs === null) return true;
133
+
134
+ for (const key in lhs) {
135
+ if (!(key in rhs) || lhs[key] !== rhs[key]) {
136
+ return false;
137
+ }
138
+ }
139
+
140
+ for (const key in rhs) {
141
+ if (!(key in lhs)) {
142
+ return false;
143
+ }
144
+ }
145
+
146
+ return true;
147
+ }
148
+
127
149
  export type Pagination = {
128
150
  skip?: number;
129
151
  take?: number;