@machhub-dev/sdk-ts 0.0.13 → 0.0.14

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.
@@ -97,7 +97,17 @@ class Collection {
97
97
  throw new Error("ID must be provided");
98
98
  }
99
99
  try {
100
- return await this.httpService.request.withJSON(data).put(id);
100
+ const formData = new FormData();
101
+ for (const [key, value] of Object.entries(data)) {
102
+ if (value instanceof File) {
103
+ formData.append(key, value, value.name);
104
+ data[key] = value.name;
105
+ }
106
+ }
107
+ formData.append("record", JSON.stringify(data));
108
+ return await this.httpService.request
109
+ .withBody(formData)
110
+ .put(id);
101
111
  }
102
112
  catch (error) {
103
113
  throw new CollectionError('update', this.collectionName, error);
@@ -93,7 +93,17 @@ export class Collection {
93
93
  throw new Error("ID must be provided");
94
94
  }
95
95
  try {
96
- return await this.httpService.request.withJSON(data).put(id);
96
+ const formData = new FormData();
97
+ for (const [key, value] of Object.entries(data)) {
98
+ if (value instanceof File) {
99
+ formData.append(key, value, value.name);
100
+ data[key] = value.name;
101
+ }
102
+ }
103
+ formData.append("record", JSON.stringify(data));
104
+ return await this.httpService.request
105
+ .withBody(formData)
106
+ .put(id);
97
107
  }
98
108
  catch (error) {
99
109
  throw new CollectionError('update', this.collectionName, error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@machhub-dev/sdk-ts",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "MACHHUB TYPESCRIPT SDK",
5
5
  "keywords": [
6
6
  "machhub",
@@ -115,7 +115,19 @@ export class Collection {
115
115
  throw new Error("ID must be provided");
116
116
  }
117
117
  try {
118
- return await this.httpService.request.withJSON(data).put(id);
118
+ const formData = new FormData();
119
+
120
+ for (const [key, value] of Object.entries(data)) {
121
+ if (value instanceof File) {
122
+ formData.append(key, value, value.name);
123
+ data[key] = value.name;
124
+ }
125
+ }
126
+ formData.append("record", JSON.stringify(data));
127
+
128
+ return await this.httpService.request
129
+ .withBody(formData)
130
+ .put(id);
119
131
  } catch (error) {
120
132
  throw new CollectionError('update', this.collectionName, error as Error);
121
133
  }