Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix webresource write #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
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
Loading