Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export interface WebResource {
size?: number;
};
`,
write: '',
write: `
export interface WebResourceWrite extends Blob {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this type is actually correct because you can send other things to the server right? eg based on https://github.com/balena-io-modules/sbvr-types/blob/v7.0.1/src/types/web-resource.ts#L94-L102 then either string or object is valid

name: string;
};
`,
};

const trimNL = new TemplateTag(
Expand Down Expand Up @@ -116,7 +120,7 @@ const sqlTypeToTypescriptType = (
case 'JSON':
return 'object';
case 'WebResource':
return 'WebResource';
return opts.mode === 'read' ? 'WebResource' : 'WebResourceWrite';
default:
throw new Error(`Unknown data type: '${f.dataType}'`);
}
Expand Down
10 changes: 8 additions & 2 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ const test = (
${expectation}
`);
} else {
expect(result).to.equal(expectation);
expect(result).to.equal(source`
export interface WebResourceWrite extends Blob {
name: string;
};

${expectation}
`);
}
});
};
Expand Down Expand Up @@ -358,7 +364,7 @@ test(
modified_at: Date;
id: number;
a_date: Date;
a_file: WebResource;
a_file: WebResourceWrite;
parent: number;
references__other: number;
}
Expand Down