instant-cli 0.22.96-experimental.drewh-ts-target.20761590091.1 → 0.22.96-experimental.surgical.20765817844.1
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/.turbo/turbo-build.log +1 -1
- package/__tests__/__snapshots__/updateSchemaFile.test.ts.snap +248 -0
- package/__tests__/updateSchemaFile.test.ts +557 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1152 -1044
- package/dist/index.js.map +1 -1
- package/dist/rename.js +69 -58
- package/dist/rename.js.map +1 -1
- package/dist/renderSchemaPlan.js +22 -10
- package/dist/renderSchemaPlan.js.map +1 -1
- package/dist/ui/index.js +102 -115
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/lib.js +30 -29
- package/dist/ui/lib.js.map +1 -1
- package/dist/util/fs.js +30 -17
- package/dist/util/fs.js.map +1 -1
- package/dist/util/isHeadlessEnvironment.js +1 -1
- package/dist/util/isHeadlessEnvironment.js.map +1 -1
- package/dist/util/loadConfig.js +32 -32
- package/dist/util/loadConfig.js.map +1 -1
- package/dist/util/packageManager.js +37 -26
- package/dist/util/packageManager.js.map +1 -1
- package/dist/util/projectDir.js +27 -16
- package/dist/util/projectDir.js.map +1 -1
- package/dist/util/promptOk.js +21 -14
- package/dist/util/promptOk.js.map +1 -1
- package/dist/util/renamePrompt.js +2 -4
- package/dist/util/renamePrompt.js.map +1 -1
- package/dist/util/updateSchemaFile.d.ts +3 -0
- package/dist/util/updateSchemaFile.d.ts.map +1 -0
- package/dist/util/updateSchemaFile.js +610 -0
- package/dist/util/updateSchemaFile.js.map +1 -0
- package/package.json +4 -4
- package/src/index.js +19 -10
- package/src/util/updateSchemaFile.ts +760 -0
- package/__tests__/mergeSchema.test.ts +0 -197
- package/dist/util/mergeSchema.d.ts +0 -2
- package/dist/util/mergeSchema.d.ts.map +0 -1
- package/dist/util/mergeSchema.js +0 -334
- package/dist/util/mergeSchema.js.map +0 -1
- package/src/util/mergeSchema.js +0 -364
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
import { test, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
diffSchemas,
|
|
4
|
+
i,
|
|
5
|
+
schemaTypescriptFileToInstantSchema,
|
|
6
|
+
} from '@instantdb/platform';
|
|
7
|
+
import { updateSchemaFile } from '../src/util/updateSchemaFile';
|
|
8
|
+
|
|
9
|
+
test('throws when schema call is missing', async () => {
|
|
10
|
+
const oldFile = `
|
|
11
|
+
import { i } from '@instantdb/core';
|
|
12
|
+
|
|
13
|
+
export const nope = 1;
|
|
14
|
+
`;
|
|
15
|
+
const schema = i.schema({
|
|
16
|
+
entities: { todos: i.entity({ title: i.string() }) },
|
|
17
|
+
links: {},
|
|
18
|
+
});
|
|
19
|
+
await expect(updateSchemaFile(oldFile, schema, schema)).rejects.toThrow(
|
|
20
|
+
'Could not find i.schema',
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('throws when entities object is missing', async () => {
|
|
25
|
+
const oldFile = `
|
|
26
|
+
import { i } from '@instantdb/core';
|
|
27
|
+
|
|
28
|
+
const _schema = i.schema({
|
|
29
|
+
links: {},
|
|
30
|
+
rooms: {},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export default _schema;
|
|
34
|
+
`;
|
|
35
|
+
const schema = i.schema({
|
|
36
|
+
entities: { todos: i.entity({ title: i.string() }) },
|
|
37
|
+
links: {},
|
|
38
|
+
});
|
|
39
|
+
await expect(updateSchemaFile(oldFile, schema, schema)).rejects.toThrow(
|
|
40
|
+
'entities object',
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('throws when links object is missing', async () => {
|
|
45
|
+
const oldFile = `
|
|
46
|
+
import { i } from '@instantdb/core';
|
|
47
|
+
|
|
48
|
+
const _schema = i.schema({
|
|
49
|
+
entities: {
|
|
50
|
+
todos: i.entity({
|
|
51
|
+
title: i.string(),
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
rooms: {},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export default _schema;
|
|
58
|
+
`;
|
|
59
|
+
const schema = i.schema({
|
|
60
|
+
entities: { todos: i.entity({ title: i.string() }) },
|
|
61
|
+
links: {},
|
|
62
|
+
});
|
|
63
|
+
await expect(updateSchemaFile(oldFile, schema, schema)).rejects.toThrow(
|
|
64
|
+
'links object',
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('preserves type params across chained calls', async () => {
|
|
69
|
+
const oldFile = `
|
|
70
|
+
import { i } from '@instantdb/core';
|
|
71
|
+
import { Label } from './types';
|
|
72
|
+
|
|
73
|
+
const _schema = i.schema({
|
|
74
|
+
entities: {
|
|
75
|
+
todos: i.entity({
|
|
76
|
+
title: i.string(),
|
|
77
|
+
status: i.string<'todo' | 'done'>().optional().indexed(),
|
|
78
|
+
labels: i.json<Label[]>(),
|
|
79
|
+
}),
|
|
80
|
+
users: i.entity({
|
|
81
|
+
email: i.string(),
|
|
82
|
+
}),
|
|
83
|
+
},
|
|
84
|
+
links: {
|
|
85
|
+
},
|
|
86
|
+
rooms: {},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export default _schema;
|
|
90
|
+
`;
|
|
91
|
+
const serverSchema = i.schema({
|
|
92
|
+
entities: {
|
|
93
|
+
todos: i.entity({
|
|
94
|
+
title: i.string(),
|
|
95
|
+
status: i.string().unique().indexed(),
|
|
96
|
+
labels: i.json(),
|
|
97
|
+
metadata: i.json(),
|
|
98
|
+
}),
|
|
99
|
+
users: i.entity({
|
|
100
|
+
email: i.string().unique(),
|
|
101
|
+
}),
|
|
102
|
+
},
|
|
103
|
+
links: {},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const result = await update(oldFile, serverSchema);
|
|
107
|
+
|
|
108
|
+
expect(result).toMatchSnapshot();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('drops constraints removed by server', async () => {
|
|
112
|
+
const oldFile = `
|
|
113
|
+
import { i } from '@instantdb/core';
|
|
114
|
+
|
|
115
|
+
const _schema = i.schema({
|
|
116
|
+
entities: {
|
|
117
|
+
todos: i.entity({
|
|
118
|
+
title: i.string().unique().indexed().optional(),
|
|
119
|
+
done: i.boolean().optional(),
|
|
120
|
+
}),
|
|
121
|
+
},
|
|
122
|
+
links: {
|
|
123
|
+
},
|
|
124
|
+
rooms: {},
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export default _schema;
|
|
128
|
+
`;
|
|
129
|
+
const serverSchema = i.schema({
|
|
130
|
+
entities: {
|
|
131
|
+
todos: i.entity({
|
|
132
|
+
title: i.string(),
|
|
133
|
+
done: i.boolean().optional(),
|
|
134
|
+
}),
|
|
135
|
+
},
|
|
136
|
+
links: {},
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const result = await update(oldFile, serverSchema);
|
|
140
|
+
|
|
141
|
+
expect(result).toMatchSnapshot();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('updates link details', async () => {
|
|
145
|
+
const oldFile = `
|
|
146
|
+
import { i } from '@instantdb/core';
|
|
147
|
+
|
|
148
|
+
const _schema = i.schema({
|
|
149
|
+
entities: {
|
|
150
|
+
todos: i.entity({
|
|
151
|
+
title: i.string(),
|
|
152
|
+
}),
|
|
153
|
+
users: i.entity({
|
|
154
|
+
email: i.string(),
|
|
155
|
+
}),
|
|
156
|
+
},
|
|
157
|
+
links: {
|
|
158
|
+
todoOwner: {
|
|
159
|
+
forward: { on: 'todos', has: 'one', label: 'owner' },
|
|
160
|
+
reverse: { on: 'users', has: 'many', label: 'todos' },
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
rooms: {},
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
export default _schema;
|
|
167
|
+
`;
|
|
168
|
+
const serverSchema = i.schema({
|
|
169
|
+
entities: {
|
|
170
|
+
todos: i.entity({ title: i.string() }),
|
|
171
|
+
users: i.entity({ email: i.string() }),
|
|
172
|
+
},
|
|
173
|
+
links: {
|
|
174
|
+
todoOwner: {
|
|
175
|
+
forward: {
|
|
176
|
+
on: 'todos',
|
|
177
|
+
has: 'one',
|
|
178
|
+
label: 'owner',
|
|
179
|
+
required: true,
|
|
180
|
+
onDelete: 'cascade',
|
|
181
|
+
},
|
|
182
|
+
reverse: {
|
|
183
|
+
on: 'users',
|
|
184
|
+
has: 'many',
|
|
185
|
+
label: 'todos',
|
|
186
|
+
onDelete: 'cascade',
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const result = await update(oldFile, serverSchema);
|
|
193
|
+
|
|
194
|
+
expect(result).toMatchSnapshot();
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test('removes a link with surrounding comments and commas', async () => {
|
|
198
|
+
const oldFile = `
|
|
199
|
+
import { i } from '@instantdb/core';
|
|
200
|
+
|
|
201
|
+
const _schema = i.schema({
|
|
202
|
+
entities: {
|
|
203
|
+
todos: i.entity({
|
|
204
|
+
title: i.string(),
|
|
205
|
+
}),
|
|
206
|
+
users: i.entity({
|
|
207
|
+
email: i.string(),
|
|
208
|
+
}),
|
|
209
|
+
projects: i.entity({
|
|
210
|
+
name: i.string(),
|
|
211
|
+
}),
|
|
212
|
+
},
|
|
213
|
+
links: {
|
|
214
|
+
// owner link
|
|
215
|
+
todoOwner: {
|
|
216
|
+
forward: { on: 'todos', has: 'one', label: 'owner' },
|
|
217
|
+
reverse: { on: 'users', has: 'many', label: 'todos' },
|
|
218
|
+
},
|
|
219
|
+
/* project link */
|
|
220
|
+
projectTodos: {
|
|
221
|
+
forward: { on: 'projects', has: 'many', label: 'todos' },
|
|
222
|
+
reverse: { on: 'todos', has: 'one', label: 'project' },
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
rooms: {},
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
export default _schema;
|
|
229
|
+
`;
|
|
230
|
+
const serverSchema = i.schema({
|
|
231
|
+
entities: {
|
|
232
|
+
todos: i.entity({ title: i.string() }),
|
|
233
|
+
users: i.entity({ email: i.string() }),
|
|
234
|
+
projects: i.entity({ name: i.string() }),
|
|
235
|
+
},
|
|
236
|
+
links: {
|
|
237
|
+
projectTodos: {
|
|
238
|
+
forward: { on: 'projects', has: 'many', label: 'todos' },
|
|
239
|
+
reverse: { on: 'todos', has: 'one', label: 'project' },
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const result = await update(oldFile, serverSchema);
|
|
245
|
+
|
|
246
|
+
expect(result).toMatchSnapshot();
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test('updates single-line entity in place', async () => {
|
|
250
|
+
const oldFile = `
|
|
251
|
+
import { i } from '@instantdb/core';
|
|
252
|
+
|
|
253
|
+
const _schema = i.schema({
|
|
254
|
+
entities: {
|
|
255
|
+
projects: i.entity({ name: i.string() }),
|
|
256
|
+
todos: i.entity({
|
|
257
|
+
title: i.string(),
|
|
258
|
+
}),
|
|
259
|
+
},
|
|
260
|
+
links: {
|
|
261
|
+
},
|
|
262
|
+
rooms: {},
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
export default _schema;
|
|
266
|
+
`;
|
|
267
|
+
const serverSchema = i.schema({
|
|
268
|
+
entities: {
|
|
269
|
+
projects: i.entity({
|
|
270
|
+
name: i.string(),
|
|
271
|
+
status: i.string(),
|
|
272
|
+
}),
|
|
273
|
+
todos: i.entity({
|
|
274
|
+
title: i.string(),
|
|
275
|
+
}),
|
|
276
|
+
},
|
|
277
|
+
links: {},
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const result = await update(oldFile, serverSchema);
|
|
281
|
+
|
|
282
|
+
expect(result).toMatchSnapshot();
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
test('adds multiple attrs to a single-line entity', async () => {
|
|
286
|
+
const oldFile = `
|
|
287
|
+
import { i } from '@instantdb/core';
|
|
288
|
+
|
|
289
|
+
const _schema = i.schema({
|
|
290
|
+
entities: {
|
|
291
|
+
projects: i.entity({ name: i.string() }),
|
|
292
|
+
},
|
|
293
|
+
links: {
|
|
294
|
+
},
|
|
295
|
+
rooms: {},
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
export default _schema;
|
|
299
|
+
`;
|
|
300
|
+
const serverSchema = i.schema({
|
|
301
|
+
entities: {
|
|
302
|
+
projects: i.entity({
|
|
303
|
+
name: i.string(),
|
|
304
|
+
status: i.string(),
|
|
305
|
+
priority: i.number(),
|
|
306
|
+
}),
|
|
307
|
+
},
|
|
308
|
+
links: {},
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
const result = await update(oldFile, serverSchema);
|
|
312
|
+
|
|
313
|
+
await expectNoDiff(result, serverSchema);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
test('inserts attrs into multi-line entities with indentation', async () => {
|
|
317
|
+
const oldFile = `
|
|
318
|
+
import { i } from '@instantdb/core';
|
|
319
|
+
|
|
320
|
+
const _schema = i.schema({
|
|
321
|
+
entities: {
|
|
322
|
+
todos: i.entity({
|
|
323
|
+
title: i.string(),
|
|
324
|
+
done: i.boolean().optional(),
|
|
325
|
+
}),
|
|
326
|
+
},
|
|
327
|
+
links: {
|
|
328
|
+
},
|
|
329
|
+
rooms: {},
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
export default _schema;
|
|
333
|
+
`;
|
|
334
|
+
const serverSchema = i.schema({
|
|
335
|
+
entities: {
|
|
336
|
+
todos: i.entity({
|
|
337
|
+
title: i.string(),
|
|
338
|
+
done: i.boolean().optional(),
|
|
339
|
+
priority: i.number(),
|
|
340
|
+
}),
|
|
341
|
+
},
|
|
342
|
+
links: {},
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
const result = await update(oldFile, serverSchema);
|
|
346
|
+
|
|
347
|
+
expect(result).toMatchSnapshot();
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
test('adds and updates attrs in a single-line entity', async () => {
|
|
351
|
+
const oldFile = `
|
|
352
|
+
import { i } from '@instantdb/core';
|
|
353
|
+
|
|
354
|
+
const _schema = i.schema({
|
|
355
|
+
entities: {
|
|
356
|
+
projects: i.entity({ name: i.string().optional(), code: i.string() }),
|
|
357
|
+
},
|
|
358
|
+
links: {
|
|
359
|
+
},
|
|
360
|
+
rooms: {},
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
export default _schema;
|
|
364
|
+
`;
|
|
365
|
+
const serverSchema = i.schema({
|
|
366
|
+
entities: {
|
|
367
|
+
projects: i.entity({
|
|
368
|
+
name: i.string(),
|
|
369
|
+
code: i.string().unique(),
|
|
370
|
+
status: i.string(),
|
|
371
|
+
priority: i.number(),
|
|
372
|
+
}),
|
|
373
|
+
},
|
|
374
|
+
links: {},
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
const result = await update(oldFile, serverSchema);
|
|
378
|
+
|
|
379
|
+
await expectNoDiff(result, serverSchema);
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
test('handles quoted keys for entities, attrs, and links', async () => {
|
|
383
|
+
const oldFile = `
|
|
384
|
+
import { i } from '@instantdb/core';
|
|
385
|
+
|
|
386
|
+
const _schema = i.schema({
|
|
387
|
+
entities: {
|
|
388
|
+
todos: i.entity({
|
|
389
|
+
title: i.string(),
|
|
390
|
+
}),
|
|
391
|
+
users: i.entity({
|
|
392
|
+
email: i.string(),
|
|
393
|
+
}),
|
|
394
|
+
'user-profiles': i.entity({
|
|
395
|
+
'display-name': i.string(),
|
|
396
|
+
}),
|
|
397
|
+
},
|
|
398
|
+
links: {
|
|
399
|
+
},
|
|
400
|
+
rooms: {},
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
export default _schema;
|
|
404
|
+
`;
|
|
405
|
+
const serverSchema = i.schema({
|
|
406
|
+
entities: {
|
|
407
|
+
todos: i.entity({ title: i.string() }),
|
|
408
|
+
users: i.entity({ email: i.string() }),
|
|
409
|
+
'user-profiles': i.entity({
|
|
410
|
+
'display-name': i.string(),
|
|
411
|
+
'avatar-url': i.string(),
|
|
412
|
+
}),
|
|
413
|
+
},
|
|
414
|
+
links: {
|
|
415
|
+
'todo-owner': {
|
|
416
|
+
forward: { on: 'todos', has: 'one', label: 'owner' },
|
|
417
|
+
reverse: { on: 'users', has: 'many', label: 'todos' },
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
const result = await update(oldFile, serverSchema);
|
|
423
|
+
|
|
424
|
+
expect(result).toMatchSnapshot();
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
test('adds a link when links object is empty', async () => {
|
|
428
|
+
const oldFile = `
|
|
429
|
+
import { i } from '@instantdb/core';
|
|
430
|
+
|
|
431
|
+
const _schema = i.schema({
|
|
432
|
+
entities: {
|
|
433
|
+
todos: i.entity({
|
|
434
|
+
title: i.string(),
|
|
435
|
+
}),
|
|
436
|
+
users: i.entity({
|
|
437
|
+
email: i.string(),
|
|
438
|
+
}),
|
|
439
|
+
},
|
|
440
|
+
links: {
|
|
441
|
+
},
|
|
442
|
+
rooms: {},
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
export default _schema;
|
|
446
|
+
`;
|
|
447
|
+
const serverSchema = i.schema({
|
|
448
|
+
entities: {
|
|
449
|
+
todos: i.entity({ title: i.string() }),
|
|
450
|
+
users: i.entity({ email: i.string() }),
|
|
451
|
+
},
|
|
452
|
+
links: {
|
|
453
|
+
todoOwner: {
|
|
454
|
+
forward: { on: 'todos', has: 'one', label: 'owner' },
|
|
455
|
+
reverse: { on: 'users', has: 'many', label: 'todos' },
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
const result = await update(oldFile, serverSchema);
|
|
461
|
+
|
|
462
|
+
expect(result).toMatchSnapshot();
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
test('adds multiple links when links object is empty', async () => {
|
|
466
|
+
const oldFile = `
|
|
467
|
+
import { i } from '@instantdb/core';
|
|
468
|
+
|
|
469
|
+
const _schema = i.schema({
|
|
470
|
+
entities: {
|
|
471
|
+
todos: i.entity({
|
|
472
|
+
title: i.string(),
|
|
473
|
+
}),
|
|
474
|
+
users: i.entity({
|
|
475
|
+
email: i.string(),
|
|
476
|
+
}),
|
|
477
|
+
projects: i.entity({
|
|
478
|
+
name: i.string(),
|
|
479
|
+
}),
|
|
480
|
+
},
|
|
481
|
+
links: {
|
|
482
|
+
},
|
|
483
|
+
rooms: {},
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
export default _schema;
|
|
487
|
+
`;
|
|
488
|
+
const serverSchema = i.schema({
|
|
489
|
+
entities: {
|
|
490
|
+
todos: i.entity({ title: i.string() }),
|
|
491
|
+
users: i.entity({ email: i.string() }),
|
|
492
|
+
projects: i.entity({ name: i.string() }),
|
|
493
|
+
},
|
|
494
|
+
links: {
|
|
495
|
+
todoOwner: {
|
|
496
|
+
forward: { on: 'todos', has: 'one', label: 'owner' },
|
|
497
|
+
reverse: { on: 'users', has: 'many', label: 'todos' },
|
|
498
|
+
},
|
|
499
|
+
projectTodos: {
|
|
500
|
+
forward: { on: 'projects', has: 'many', label: 'todos' },
|
|
501
|
+
reverse: { on: 'todos', has: 'one', label: 'project' },
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
const result = await update(oldFile, serverSchema);
|
|
507
|
+
|
|
508
|
+
await expectNoDiff(result, serverSchema);
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
test('removes the last link cleanly', async () => {
|
|
512
|
+
const oldFile = `
|
|
513
|
+
import { i } from '@instantdb/core';
|
|
514
|
+
|
|
515
|
+
const _schema = i.schema({
|
|
516
|
+
entities: {
|
|
517
|
+
todos: i.entity({
|
|
518
|
+
title: i.string(),
|
|
519
|
+
}),
|
|
520
|
+
users: i.entity({
|
|
521
|
+
email: i.string(),
|
|
522
|
+
}),
|
|
523
|
+
},
|
|
524
|
+
links: {
|
|
525
|
+
todoOwner: {
|
|
526
|
+
forward: { on: 'todos', has: 'one', label: 'owner' },
|
|
527
|
+
reverse: { on: 'users', has: 'many', label: 'todos' },
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
rooms: {},
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
export default _schema;
|
|
534
|
+
`;
|
|
535
|
+
const serverSchema = i.schema({
|
|
536
|
+
entities: {
|
|
537
|
+
todos: i.entity({ title: i.string() }),
|
|
538
|
+
users: i.entity({ email: i.string() }),
|
|
539
|
+
},
|
|
540
|
+
links: {},
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
const result = await update(oldFile, serverSchema);
|
|
544
|
+
|
|
545
|
+
expect(result).toMatchSnapshot();
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
async function update(oldFile: string, serverSchema: any) {
|
|
549
|
+
const localSchema = schemaTypescriptFileToInstantSchema(oldFile);
|
|
550
|
+
return updateSchemaFile(oldFile, localSchema, serverSchema);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
async function expectNoDiff(result: string, serverSchema: any) {
|
|
554
|
+
const parsed = schemaTypescriptFileToInstantSchema(result);
|
|
555
|
+
const diff = await diffSchemas(parsed, serverSchema, async (created) => created, {});
|
|
556
|
+
expect(diff).toEqual([]);
|
|
557
|
+
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAg+DA,8EAQC;AA+ED;;;;;EAKE"}
|