Skip to content

Commit

Permalink
fix: allow any for array_output in older versions of the schema (#580)
Browse files Browse the repository at this point in the history
* fix: allow any for array_output

* Update validateGridFile.ts

* Update validateGridFile.ts

* Update validateGridFile.test.ts
  • Loading branch information
jimniels committed Jun 27, 2023
1 parent 0e1ee87 commit 8a3c4ad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/schemas/GridFileV1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import z from 'zod';

const ArrayOutputSchema = z.array(z.union([z.string(), z.number(), z.boolean()]));
const ArrayOutputSchema = z.array(z.any());

export enum BorderType {
line1 = 0,
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/GridFileV1_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { v4 as uuid } from 'uuid';
import { DEFAULT_FILE_NAME } from '../constants/app';

// Shared schemas
const ArrayOutputSchema = z.array(z.union([z.string(), z.number(), z.boolean()]));
const ArrayOutputSchema = z.array(z.any());
const BorderDirectionSchema = z.object({
color: z.string().optional(),
type: z.enum(['line1', 'line2', 'line3', 'dotted', 'dashed', 'double']).optional(),
Expand Down
22 changes: 21 additions & 1 deletion src/schemas/validateGridFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,27 @@ const v1File: GridFileV1 = {

const v1_1File: GridFileV1_1 = {
version: '1.1',
cells: [],
cells: [
// Test to allow `any` for `array_output`
{
x: 0,
y: 0,
type: 'PYTHON',
value: '1,2,3',
last_modified: '2023-06-27T16:54:40.619Z',
evaluation_result: {
success: true,
std_out: '',
output_value: '[[[1, 2, 3]]]',
cells_accessed: [],
array_output: [[[1, 2, 3]]],
formatted_code: '[[[1, 2, 3]]]\n',
error_span: null,
},
python_code: '[[[1,2,3]]]',
array_cells: [[0, 0]],
},
],
columns: [],
rows: [],
borders: [],
Expand Down

1 comment on commit 8a3c4ad

@vercel
Copy link

@vercel vercel bot commented on 8a3c4ad Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

quadratic – ./

quadratic-quadratic.vercel.app
quadratic-git-main-quadratic.vercel.app
quadratic-nu.vercel.app

Please sign in to comment.