@based/db 0.0.51 → 0.0.52

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.
Binary file
Binary file
@@ -1,4 +1,5 @@
1
1
  import { getPropType } from '@based/schema';
2
+ import { deepCopy } from '@saulx/utils';
2
3
  const exclude = new Set(['id', 'lastId', 'hash']);
3
4
  export const schemaLooseEqual = (a, b, key) => {
4
5
  if (a === b) {
@@ -49,20 +50,17 @@ export const schemaLooseEqual = (a, b, key) => {
49
50
  export const parseSchema = (strictSchema) => {
50
51
  let parsedSchema = strictSchema;
51
52
  if (strictSchema.props) {
52
- parsedSchema = {
53
- ...strictSchema,
54
- types: { ...parsedSchema.types },
55
- };
56
- const props = { ...strictSchema.props };
57
- for (const key in props) {
58
- const prop = { ...props[key] };
53
+ // TODO do this more precise
54
+ parsedSchema = deepCopy(strictSchema);
55
+ for (const key in parsedSchema.props) {
56
+ const prop = parsedSchema.props[key];
59
57
  const propType = getPropType(prop);
60
58
  let refProp;
61
59
  if (propType === 'reference') {
62
60
  refProp = prop;
63
61
  }
64
62
  else if (propType === 'references') {
65
- refProp = { ...prop.items };
63
+ refProp = prop.items;
66
64
  prop.items = refProp;
67
65
  }
68
66
  if (refProp) {
@@ -82,12 +80,12 @@ export const parseSchema = (strictSchema) => {
82
80
  };
83
81
  refProp.prop = inverseKey;
84
82
  }
85
- props[key] = prop;
86
83
  }
84
+ parsedSchema.types ??= {};
87
85
  // @ts-ignore This creates an internal type to use for root props
88
86
  parsedSchema.types._root = {
89
87
  id: 1,
90
- props,
88
+ props: parsedSchema.props,
91
89
  };
92
90
  delete parsedSchema.props;
93
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@based/db",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",