@based/schema 3.1.0 → 3.2.0

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 (61) hide show
  1. package/README.md +1 -20
  2. package/dist/display/index.d.ts +2 -0
  3. package/dist/display/index.js +26 -0
  4. package/dist/display/number.d.ts +3 -0
  5. package/dist/display/number.js +89 -0
  6. package/dist/display/string.d.ts +3 -0
  7. package/dist/display/string.js +23 -0
  8. package/dist/display/timestamp.d.ts +3 -0
  9. package/dist/display/timestamp.js +127 -0
  10. package/dist/error.d.ts +19 -0
  11. package/dist/error.js +24 -0
  12. package/dist/index.d.ts +5 -0
  13. package/dist/index.js +22 -0
  14. package/dist/languages.d.ts +187 -0
  15. package/dist/languages.js +190 -0
  16. package/dist/set/fields/array.d.ts +2 -0
  17. package/dist/set/fields/array.js +123 -0
  18. package/dist/set/fields/index.d.ts +3 -0
  19. package/dist/set/fields/index.js +74 -0
  20. package/dist/set/fields/number.d.ts +4 -0
  21. package/dist/set/fields/number.js +129 -0
  22. package/dist/set/fields/object.d.ts +3 -0
  23. package/dist/set/fields/object.js +33 -0
  24. package/dist/set/fields/references.d.ts +3 -0
  25. package/dist/set/fields/references.js +128 -0
  26. package/dist/set/fields/set.d.ts +2 -0
  27. package/dist/set/fields/set.js +63 -0
  28. package/dist/set/fields/string.d.ts +3 -0
  29. package/dist/set/fields/string.js +284 -0
  30. package/dist/set/index.d.ts +3 -0
  31. package/dist/set/index.js +183 -0
  32. package/dist/set/isValidId.d.ts +2 -0
  33. package/dist/set/isValidId.js +21 -0
  34. package/dist/set/types.d.ts +0 -0
  35. package/dist/set/types.js +1 -0
  36. package/dist/src/compat/index.js +10 -2
  37. package/dist/src/compat/newToOld.d.ts +2 -2
  38. package/dist/src/compat/newToOld.js +173 -31
  39. package/dist/src/compat/oldToNew.d.ts +1 -1
  40. package/dist/src/compat/oldToNew.js +200 -25
  41. package/dist/src/generateQuery.d.ts +12 -0
  42. package/dist/src/generateQuery.js +75 -0
  43. package/dist/src/set/fields/references.js +40 -0
  44. package/dist/test/compat.js +25 -0
  45. package/dist/test/query.d.ts +1 -0
  46. package/dist/test/query.js +93 -0
  47. package/dist/types.d.ts +205 -0
  48. package/dist/types.js +27 -0
  49. package/dist/updateSchema.d.ts +2 -0
  50. package/dist/updateSchema.js +16 -0
  51. package/dist/validateSchema.d.ts +4 -0
  52. package/dist/validateSchema.js +41 -0
  53. package/dist/walker/args.d.ts +36 -0
  54. package/dist/walker/args.js +162 -0
  55. package/dist/walker/index.d.ts +6 -0
  56. package/dist/walker/index.js +49 -0
  57. package/dist/walker/parse.d.ts +3 -0
  58. package/dist/walker/parse.js +186 -0
  59. package/dist/walker/types.d.ts +45 -0
  60. package/dist/walker/types.js +10 -0
  61. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ import { FieldParser } from '../../walker';
2
+ export declare const set: FieldParser<'set'>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.set = void 0;
4
+ const error_1 = require("../../error");
5
+ async function parseOperator(args, key) {
6
+ if (Array.isArray(args.value[key])) {
7
+ const n = args.create({
8
+ key,
9
+ skipCollection: true,
10
+ value: args.value[key],
11
+ });
12
+ await n.parse();
13
+ if (n.value?.$value) {
14
+ return n.value.$value;
15
+ }
16
+ return [];
17
+ }
18
+ const n = args.create({
19
+ key,
20
+ skipCollection: true,
21
+ value: args.value[key],
22
+ fieldSchema: args.fieldSchema.items,
23
+ });
24
+ await n.parse();
25
+ return [n.value];
26
+ }
27
+ const set = async (args) => {
28
+ if (typeof args.value !== 'object' || args.value === null) {
29
+ args.error(error_1.ParseError.incorrectFormat);
30
+ return;
31
+ }
32
+ args.stop();
33
+ const isArray = Array.isArray(args.value);
34
+ if (isArray) {
35
+ const newArgs = [];
36
+ for (let i = 0; i < args.value.length; i++) {
37
+ newArgs.push(args.create({
38
+ key: i,
39
+ value: args.value[i],
40
+ fieldSchema: args.fieldSchema.items,
41
+ skipCollection: true,
42
+ }));
43
+ }
44
+ await Promise.all(newArgs.map((args) => args.parse()));
45
+ args.value = { $value: newArgs.map((args) => args.value) };
46
+ }
47
+ else {
48
+ for (const key in args.value) {
49
+ if (key === '$add') {
50
+ args.value.$add = await parseOperator(args, key);
51
+ }
52
+ else if (key === '$remove') {
53
+ args.value.$remove = await parseOperator(args, key);
54
+ }
55
+ else {
56
+ args.create({ key }).error(error_1.ParseError.fieldDoesNotExist);
57
+ }
58
+ }
59
+ }
60
+ args.collect();
61
+ };
62
+ exports.set = set;
63
+ //# sourceMappingURL=set.js.map
@@ -0,0 +1,3 @@
1
+ import { FieldParser } from '../../walker';
2
+ export declare const string: FieldParser<'string'>;
3
+ export declare const text: FieldParser<'text'>;
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.text = exports.string = void 0;
7
+ const error_1 = require("../../error");
8
+ const validator_1 = __importDefault(require("validator"));
9
+ const formatPatterns = {
10
+ email: validator_1.default.isEmail,
11
+ URL: validator_1.default.isURL,
12
+ MACAddress: validator_1.default.isMACAddress,
13
+ IP: validator_1.default.isIP,
14
+ IPRange: validator_1.default.isIPRange,
15
+ FQDN: validator_1.default.isFQDN,
16
+ IBAN: validator_1.default.isIBAN,
17
+ BIC: validator_1.default.isBIC,
18
+ alpha: validator_1.default.isAlpha,
19
+ alphaLocales: validator_1.default.isAlphaLocales,
20
+ alphanumeric: validator_1.default.isAlphanumeric,
21
+ alphanumericLocales: validator_1.default.isAlphanumericLocales,
22
+ passportNumber: validator_1.default.isPassportNumber,
23
+ port: validator_1.default.isPort,
24
+ lowercase: validator_1.default.isLowercase,
25
+ uppercase: validator_1.default.isUppercase,
26
+ ascii: validator_1.default.isAscii,
27
+ semVer: validator_1.default.isSemVer,
28
+ surrogatePair: validator_1.default.isSurrogatePair,
29
+ IMEI: validator_1.default.isIMEI,
30
+ hexadecimal: validator_1.default.isHexadecimal,
31
+ octal: validator_1.default.isOctal,
32
+ hexColor: validator_1.default.isHexColor,
33
+ rgbColor: validator_1.default.isRgbColor,
34
+ HSL: validator_1.default.isHSL,
35
+ ISRC: validator_1.default.isISRC,
36
+ MD5: validator_1.default.isMD5,
37
+ JWT: validator_1.default.isJWT,
38
+ UUID: validator_1.default.isUUID,
39
+ luhnNumber: validator_1.default.isLuhnNumber,
40
+ creditCard: validator_1.default.isCreditCard,
41
+ identityCard: validator_1.default.isIdentityCard,
42
+ EAN: validator_1.default.isEAN,
43
+ ISIN: validator_1.default.isISIN,
44
+ ISBN: validator_1.default.isISBN,
45
+ ISSN: validator_1.default.isISSN,
46
+ mobilePhone: validator_1.default.isMobilePhone,
47
+ mobilePhoneLocales: validator_1.default.isMobilePhoneLocales,
48
+ postalCode: validator_1.default.isPostalCode,
49
+ postalCodeLocales: validator_1.default.isPostalCodeLocales,
50
+ ethereumAddress: validator_1.default.isEthereumAddress,
51
+ currency: validator_1.default.isCurrency,
52
+ btcAddress: validator_1.default.isBtcAddress,
53
+ ISO6391: validator_1.default.isISO6391,
54
+ ISO8601: validator_1.default.isISO8601,
55
+ RFC3339: validator_1.default.isRFC3339,
56
+ ISO31661Alpha2: validator_1.default.isISO31661Alpha2,
57
+ ISO31661Alpha3: validator_1.default.isISO31661Alpha3,
58
+ ISO4217: validator_1.default.isISO4217,
59
+ base32: validator_1.default.isBase32,
60
+ base58: validator_1.default.isBase58,
61
+ base64: validator_1.default.isBase64,
62
+ dataURI: validator_1.default.isDataURI,
63
+ magnetURI: validator_1.default.isMagnetURI,
64
+ mimeType: validator_1.default.isMimeType,
65
+ latLong: validator_1.default.isLatLong,
66
+ slug: validator_1.default.isSlug,
67
+ strongPassword: validator_1.default.isStrongPassword,
68
+ taxID: validator_1.default.isTaxID,
69
+ licensePlate: validator_1.default.isLicensePlate,
70
+ VAT: validator_1.default.isVAT,
71
+ };
72
+ const validateString = (args, value) => {
73
+ if (typeof value !== 'string') {
74
+ args.error(error_1.ParseError.incorrectFormat);
75
+ return false;
76
+ }
77
+ if (args.fieldSchema.minLength && value.length < args.fieldSchema.minLength) {
78
+ args.error(error_1.ParseError.subceedsMinimum);
79
+ return false;
80
+ }
81
+ if (args.fieldSchema.maxLength && value.length > args.fieldSchema.maxLength) {
82
+ args.error(error_1.ParseError.exceedsMaximum);
83
+ return false;
84
+ }
85
+ if (args.fieldSchema.pattern) {
86
+ const re = new RegExp(args.fieldSchema.pattern);
87
+ if (!re.test(value)) {
88
+ args.error(error_1.ParseError.incorrectFormat);
89
+ return false;
90
+ }
91
+ }
92
+ if (args.fieldSchema.format &&
93
+ !formatPatterns[args.fieldSchema.format](value)) {
94
+ args.error(error_1.ParseError.incorrectFormat);
95
+ return false;
96
+ }
97
+ return true;
98
+ };
99
+ const string = async (args) => {
100
+ if (!validateString(args, args.value)) {
101
+ return;
102
+ }
103
+ args.collect();
104
+ };
105
+ exports.string = string;
106
+ // --- bla
107
+ // if typeof === string
108
+ const text = async (args) => {
109
+ const value = args.value;
110
+ args.stop();
111
+ if (value === null) {
112
+ args.error(error_1.ParseError.incorrectFormat);
113
+ return;
114
+ }
115
+ if (typeof value === 'object') {
116
+ for (const key in value) {
117
+ if (key === '$merge') {
118
+ if (typeof value.$merge !== 'boolean') {
119
+ args.error(error_1.ParseError.incorrectFormat);
120
+ return;
121
+ }
122
+ }
123
+ else if (key === '$delete') {
124
+ if (value[key] !== true) {
125
+ args.error(error_1.ParseError.incorrectFormat);
126
+ return;
127
+ }
128
+ args.collect({ $delete: true });
129
+ return;
130
+ }
131
+ else if (key === '$value') {
132
+ const valueArgs = args.create({
133
+ path: args.path,
134
+ value: args.value[key],
135
+ });
136
+ valueArgs._stopObject = true;
137
+ await valueArgs.parse();
138
+ }
139
+ else if (key === '$default') {
140
+ if (value[key] === null) {
141
+ args.error(error_1.ParseError.incorrectFormat);
142
+ return;
143
+ }
144
+ if (typeof value[key] === 'object') {
145
+ for (const k in value[key]) {
146
+ if (!validateString(args, args.value[key][k])) {
147
+ args.error(error_1.ParseError.incorrectFormat);
148
+ return;
149
+ }
150
+ args
151
+ .create({
152
+ key: k,
153
+ fieldSchema: { type: 'string' },
154
+ value: { $default: args.value[key][k] },
155
+ })
156
+ .collect();
157
+ }
158
+ }
159
+ else if (typeof value[key] !== 'string') {
160
+ args.error(error_1.ParseError.incorrectFormat);
161
+ return;
162
+ }
163
+ else if (!args.target.$language) {
164
+ args.error(error_1.ParseError.noLanguageFound);
165
+ return;
166
+ }
167
+ else if (!validateString(args, value[key])) {
168
+ args.error(error_1.ParseError.incorrectFormat);
169
+ return;
170
+ }
171
+ else {
172
+ args
173
+ .create({
174
+ fieldSchema: { type: 'string' },
175
+ key: args.target.$language,
176
+ value: { $default: args.value[key] },
177
+ })
178
+ .collect();
179
+ }
180
+ }
181
+ else if ((args.schema.translations || [])
182
+ .concat(args.schema.language)
183
+ .includes(key)) {
184
+ if (value[key] && typeof value[key] === 'object') {
185
+ for (const k in value[key]) {
186
+ if (k === '$delete') {
187
+ if (value[key].$delete !== true) {
188
+ args.error(error_1.ParseError.incorrectFormat);
189
+ return;
190
+ }
191
+ args
192
+ .create({
193
+ key,
194
+ fieldSchema: { type: 'string' },
195
+ value: args.value[key],
196
+ })
197
+ .collect();
198
+ }
199
+ else if (k === '$value') {
200
+ if (!validateString(args, value[key].$value)) {
201
+ args.create({ key }).error(error_1.ParseError.incorrectFormat);
202
+ }
203
+ else {
204
+ args
205
+ .create({
206
+ key,
207
+ fieldSchema: { type: 'string' },
208
+ value: args.value[key].$value,
209
+ })
210
+ .collect();
211
+ }
212
+ }
213
+ else if (k === '$default') {
214
+ if (!validateString(args, value[key].$default)) {
215
+ args.create({ key }).error(error_1.ParseError.incorrectFormat);
216
+ }
217
+ else {
218
+ args
219
+ .create({
220
+ key,
221
+ fieldSchema: { type: 'string' },
222
+ value: { $default: args.value[key].$default },
223
+ })
224
+ .collect();
225
+ }
226
+ }
227
+ else {
228
+ args
229
+ .create({ path: [...args.path, key, k] })
230
+ .error(error_1.ParseError.fieldDoesNotExist);
231
+ return;
232
+ }
233
+ }
234
+ }
235
+ else {
236
+ if (!validateString(args, args.value[key])) {
237
+ args.error(error_1.ParseError.incorrectFormat);
238
+ return;
239
+ }
240
+ args
241
+ .create({
242
+ key,
243
+ fieldSchema: { type: 'string' },
244
+ value: args.value[key],
245
+ })
246
+ .collect();
247
+ }
248
+ }
249
+ else {
250
+ args.create({ key }).error(error_1.ParseError.languageNotSupported);
251
+ }
252
+ }
253
+ if (!args._stopObject) {
254
+ args.collect();
255
+ }
256
+ return;
257
+ }
258
+ if (typeof value !== 'string') {
259
+ args.error(error_1.ParseError.incorrectFormat);
260
+ return;
261
+ }
262
+ if (!args.target.$language) {
263
+ args.error(error_1.ParseError.noLanguageFound);
264
+ return;
265
+ }
266
+ if (!validateString(args, args.value)) {
267
+ args.error(error_1.ParseError.incorrectFormat);
268
+ return;
269
+ }
270
+ args
271
+ .create({
272
+ value,
273
+ key: args.target.$language,
274
+ fieldSchema: { type: 'string' },
275
+ })
276
+ .collect();
277
+ if (!args._stopObject) {
278
+ args.collect({
279
+ [args.target.$language]: value,
280
+ });
281
+ }
282
+ };
283
+ exports.text = text;
284
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1,3 @@
1
+ import { BasedSchema, BasedSetTarget } from '../types';
2
+ import { AsyncOperation } from '../walker';
3
+ export declare const setWalker: (schema: BasedSchema, value: any, asyncOperationHandler?: AsyncOperation<BasedSetTarget>) => Promise<BasedSetTarget>;
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setWalker = void 0;
4
+ const error_1 = require("../error");
5
+ const walker_1 = require("../walker");
6
+ const fields_1 = require("./fields");
7
+ const isValidId_1 = require("./isValidId");
8
+ const opts = {
9
+ parsers: {
10
+ keys: {
11
+ $delete: async (args) => {
12
+ if (args.prev === args.root) {
13
+ args.error(error_1.ParseError.cannotDeleteNodeFromModify);
14
+ return;
15
+ }
16
+ if (args.value === true) {
17
+ args.stop();
18
+ args.prev.collect();
19
+ args.prev.stop();
20
+ return;
21
+ }
22
+ },
23
+ $alias: async (args) => {
24
+ if (Array.isArray(args.value)) {
25
+ for (const field of args.value) {
26
+ if (typeof field !== 'string') {
27
+ args.error(error_1.ParseError.incorrectFormat);
28
+ return;
29
+ }
30
+ }
31
+ return;
32
+ }
33
+ if (typeof args.value !== 'string') {
34
+ args.error(error_1.ParseError.incorrectFormat);
35
+ }
36
+ },
37
+ $merge: async (args) => {
38
+ if (typeof args.value !== 'boolean') {
39
+ args.error(error_1.ParseError.incorrectFormat);
40
+ return;
41
+ }
42
+ if (args.prev !== args.root) {
43
+ args.prev.collect({ $delete: true });
44
+ }
45
+ return;
46
+ },
47
+ $id: async (args) => {
48
+ if (!(0, isValidId_1.isValidId)(args.schema, args.value)) {
49
+ args.error(error_1.ParseError.incorrectFormat);
50
+ return;
51
+ }
52
+ },
53
+ $language: async (args) => {
54
+ if (!(args.schema.translations || [])
55
+ .concat(args.schema.language)
56
+ .includes(args.value)) {
57
+ args.error(error_1.ParseError.languageNotSupported);
58
+ return;
59
+ }
60
+ },
61
+ $value: async (args) => {
62
+ const type = args.fieldSchema?.type;
63
+ if (type === 'text' || type === 'set' || type == 'references') {
64
+ return;
65
+ }
66
+ args.prev.stop();
67
+ args.stop();
68
+ if (args.prev.value.$default) {
69
+ args.error(error_1.ParseError.valueAndDefault);
70
+ return;
71
+ }
72
+ return {
73
+ path: args.path.slice(0, -1),
74
+ value: args.value,
75
+ };
76
+ },
77
+ $default: async (args) => {
78
+ const type = args.fieldSchema?.type;
79
+ if (type === 'number' || type === 'integer' || type === 'text') {
80
+ // default can exist with $incr and $decr
81
+ return;
82
+ }
83
+ args.prev.stop();
84
+ args.stop();
85
+ if (type === 'references' || type === 'set' || type === 'array') {
86
+ const newArgs = args.create({
87
+ path: args.path.slice(0, -1),
88
+ skipCollection: true,
89
+ });
90
+ await newArgs.parse();
91
+ newArgs.skipCollection = false;
92
+ newArgs.value = { $default: newArgs.value };
93
+ newArgs.collect();
94
+ }
95
+ else {
96
+ const collect = args._collectOverride ?? args.root._opts.collect;
97
+ const newArgs = args.create({
98
+ path: args.path.slice(0, -1),
99
+ collect: (a) => {
100
+ if (a.path.length === args.path.length - 1) {
101
+ collect(a.create({ value: { $default: a.value } }));
102
+ }
103
+ else {
104
+ // console.info('hello', a.path) can handle this later
105
+ }
106
+ },
107
+ });
108
+ await newArgs.parse();
109
+ }
110
+ for (const key in args.prev.value) {
111
+ if (key !== '$default') {
112
+ args.prev.create({ key }).error(error_1.ParseError.fieldDoesNotExist);
113
+ }
114
+ }
115
+ },
116
+ },
117
+ fields: fields_1.fields,
118
+ catch: async (args) => {
119
+ args.error(error_1.ParseError.fieldDoesNotExist);
120
+ },
121
+ },
122
+ init: async (value, schema, error) => {
123
+ let type;
124
+ const target = {
125
+ type,
126
+ schema,
127
+ required: [],
128
+ collected: [],
129
+ errors: [],
130
+ };
131
+ if (value.$id) {
132
+ if (value.$id === 'root') {
133
+ type = 'root';
134
+ }
135
+ else {
136
+ type = schema.prefixToTypeMapping[value.$id.slice(0, 2)];
137
+ }
138
+ if (!type) {
139
+ error(error_1.ParseError.incorrectFieldType, { target });
140
+ return { target };
141
+ }
142
+ }
143
+ else if (value.$alias) {
144
+ target.$alias = value.$alias;
145
+ }
146
+ if (value.type) {
147
+ if (type && value.type !== type) {
148
+ error(error_1.ParseError.incorrectNodeType, { target });
149
+ return { target };
150
+ }
151
+ type = value.type;
152
+ }
153
+ const typeSchema = type === 'root' ? schema.root : schema.types[type];
154
+ if (!typeSchema) {
155
+ error(error_1.ParseError.incorrectNodeType, { target });
156
+ return { target };
157
+ }
158
+ target.type = type;
159
+ target.$language = value.$language;
160
+ target.$id = value.$id;
161
+ if ('$merge' in value) {
162
+ if (typeof value.$merge !== 'boolean') {
163
+ error(error_1.ParseError.incorrectFormat, { target });
164
+ }
165
+ target.$merge = value.$merge;
166
+ }
167
+ return { target, typeSchema };
168
+ },
169
+ error: (code, args) => {
170
+ args.target.errors.push({
171
+ code,
172
+ path: args.path ?? [],
173
+ });
174
+ },
175
+ collect: (args) => {
176
+ args.root.target.collected.push(args);
177
+ },
178
+ };
179
+ const setWalker = (schema, value, asyncOperationHandler) => {
180
+ return (0, walker_1.walk)(schema, opts, value, asyncOperationHandler);
181
+ };
182
+ exports.setWalker = setWalker;
183
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import { BasedSchema } from '../types';
2
+ export declare const isValidId: (schema: BasedSchema, id: any) => boolean;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidId = void 0;
4
+ const isValidId = (schema, id) => {
5
+ if (typeof id !== 'string') {
6
+ return false;
7
+ }
8
+ if (id === 'root') {
9
+ return true;
10
+ }
11
+ if (id.length > 16) {
12
+ return false;
13
+ }
14
+ const prefix = id.slice(0, 2);
15
+ if (!schema.prefixToTypeMapping[prefix]) {
16
+ return false;
17
+ }
18
+ return true;
19
+ };
20
+ exports.isValidId = isValidId;
21
+ //# sourceMappingURL=isValidId.js.map
File without changes
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -58,7 +58,7 @@ const convertOldToNewMeta = (props) => {
58
58
  };
59
59
  const convertNewFieldToOldField = (newField) => {
60
60
  // @ts-ignore
61
- const { type, properties, values, items, ...props } = newField;
61
+ const { type, bidirectional, properties, values, items, ...props } = newField;
62
62
  const meta = convertNewToOldMeta(props);
63
63
  // @ts-ignore
64
64
  const overwrite = newToOldType[type] || newToOldType[props.format];
@@ -70,6 +70,10 @@ const convertNewFieldToOldField = (newField) => {
70
70
  if (meta) {
71
71
  oldField.meta = meta;
72
72
  }
73
+ if (bidirectional) {
74
+ // @ts-ignore
75
+ oldField.bidirectional = bidirectional;
76
+ }
73
77
  if (properties) {
74
78
  // @ts-ignore
75
79
  oldField.properties = {};
@@ -133,7 +137,7 @@ export const convertNewToOld = (newSchema) => {
133
137
  };
134
138
  const convertOldFieldToNewField = (oldField) => {
135
139
  // @ts-ignore
136
- const { type, properties, values, items, meta = {} } = oldField;
140
+ const { type, bidirectional, properties, values, items, meta = {} } = oldField;
137
141
  const overwrite = oldToNewType[type] || oldToNewType[meta.format];
138
142
  const newField = overwrite
139
143
  ? {
@@ -144,6 +148,10 @@ const convertOldFieldToNewField = (oldField) => {
144
148
  type,
145
149
  ...convertOldToNewMeta(meta),
146
150
  };
151
+ if (bidirectional) {
152
+ // @ts-ignore
153
+ newField.bidirectional = bidirectional;
154
+ }
147
155
  if (properties) {
148
156
  // @ts-ignore
149
157
  newField.properties = {};
@@ -1,3 +1,3 @@
1
- import { BasedSchema } from '../types.js';
2
1
  import { BasedOldSchema } from './oldSchemaType.js';
3
- export declare const convertNewToOld: (schema: BasedSchema) => Partial<BasedOldSchema>;
2
+ import { BasedSchemaPartial } from '../types.js';
3
+ export declare const convertNewToOld: (schema: BasedSchemaPartial) => Partial<BasedOldSchema>;