Skip to content

Commit e2fa425

Browse files
committed
Remove Assets.update
1 parent e289781 commit e2fa425

File tree

5 files changed

+13
-44
lines changed

5 files changed

+13
-44
lines changed

src/metafold.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ class MetafoldClient implements Client {
4343
* @param {string} [projectID] - ID of the project to make API calls against.
4444
* @param {string} [baseURL] - Metafold API URL. Used for internal testing.
4545
*/
46-
constructor(accessToken: string, public projectID?: string, baseURL: string = DEFAULT_BASE_URL) {
46+
constructor(
47+
accessToken: string,
48+
public projectID?: string,
49+
baseURL: string = DEFAULT_BASE_URL,
50+
) {
4751
this.axios = axios.create({
4852
baseURL,
4953
headers: {

src/resources/Assets.spec.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,6 @@ describe("Assets", function() {
169169
})
170170
})
171171

172-
describe("#update()", function() {
173-
it("should upload and update asset 1", async function() {
174-
const data = fs.readFileSync("test/test.png")
175-
const file = new Blob([data], { type: "image/png" })
176-
const asset = await metafold.assets.update("1", file, "test.png")
177-
assert.deepEqual(asset, {
178-
id: "1",
179-
filename: "test.png",
180-
size: 67,
181-
checksum: "sha256:089ad5bf4831b6758e9907db43bc5ebba2e9248a9929dad6132c49932e538278",
182-
created: defaultDate,
183-
modified: defaultDate,
184-
})
185-
})
186-
})
187-
188172
describe("#delete()", function() {
189173
it("should delete asset 1", async function() {
190174
const scope = nock("https://api.metafold3d.com")

src/resources/Assets.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -120,26 +120,6 @@ export class Assets {
120120
return asset(r.data)
121121
}
122122

123-
/**
124-
* Update an asset.
125-
*
126-
* @param {string} id - ID of asset to update.
127-
* @param {any} data - Asset data to upload, typically a File or Blob.
128-
* @param {string} [filename] - Name of the file.
129-
* @returns Asset resource.
130-
*/
131-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
132-
async update(id: string, data: any, filename?: string): Promise<Asset> {
133-
const form = new FormData()
134-
if (filename) {
135-
form.append("file", data, filename)
136-
} else {
137-
form.append("file", data)
138-
}
139-
const r = await this.client.patch(`/projects/${this.client.projectID}/assets/${id}`, form)
140-
return asset(r.data)
141-
}
142-
143123
/**
144124
* Delete an asset.
145125
*

src/resources/Jobs.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const jobList: JobJSON[] = [
3535
},
3636
"created": "Mon, 01 Jan 2024 00:00:00 GMT",
3737
"state": "success",
38-
"assets": [assetJSON],
3938
"meta": null,
4039
},
4140
{
@@ -47,7 +46,6 @@ const jobList: JobJSON[] = [
4746
},
4847
"created": "Mon, 01 Jan 2024 00:00:00 GMT",
4948
"state": "success",
50-
"assets": [assetJSON],
5149
"meta": null,
5250
},
5351
{
@@ -59,7 +57,6 @@ const jobList: JobJSON[] = [
5957
},
6058
"created": "Mon, 01 Jan 2024 00:00:00 GMT",
6159
"state": "success",
62-
"assets": [assetJSON],
6360
"meta": null,
6461
},
6562
]
@@ -95,7 +92,10 @@ describe("Jobs", function() {
9592
.reply(200, jobList.slice().filter(
9693
(j: JobJSON) => j.name === "foo"))
9794
.get("/projects/1/jobs/1")
98-
.reply(200, jobList[jobList.length - 1])
95+
.reply(200, {
96+
...jobList[jobList.length - 1],
97+
assets: [assetJSON]
98+
})
9999
// Job success
100100
.post("/projects/1/jobs")
101101
.reply(202, {
@@ -126,6 +126,7 @@ describe("Jobs", function() {
126126
.reply(200, {
127127
...jobList[jobList.length - 1],
128128
name: "baz",
129+
assets: [assetJSON],
129130
})
130131

131132
describe("#list()", function() {

src/resources/Jobs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export type JobJSON = {
2222
/** Job state. */
2323
state: JobState
2424
/** List of generated asset JSONs. */
25-
assets: AssetJSON[]
25+
assets?: AssetJSON[]
2626
/** Additional metadata generated by the job. */
2727
meta: object | null
2828
}
@@ -32,14 +32,14 @@ export type Job = Omit<JobJSON, "created" | "assets"> & {
3232
/** Job creation datetime. */
3333
created: Date
3434
/** List of generated asset resources. */
35-
assets: Asset[]
35+
assets?: Asset[]
3636
}
3737

3838
function job(j: JobJSON): Job {
3939
return {
4040
...j,
4141
created: new Date(j.created),
42-
assets: j.assets.map((a: AssetJSON) => ({
42+
assets: j.assets?.map((a: AssetJSON) => ({
4343
...a,
4444
created: new Date(a.created),
4545
modified: new Date(a.modified),

0 commit comments

Comments
 (0)