Skip to content
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @code.store/arcxp-sdk-ts

## 4.45.0

### Minor Changes

- Add uploadImageStream method & Fix updateImage method in ArcProtoCenter

## 4.44.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@code.store/arcxp-sdk-ts",
"version": "4.44.0",
"version": "4.45.0",
"description": "A strongly typed set of ArcXP API's and utilities reduce the amount of work required to develop with ArcXP, starting with reducing the boilerplate code you have to write.",
"type": "commonjs",
"main": "./dist/index.js",
Expand Down
22 changes: 21 additions & 1 deletion src/api/photo-center/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import FormData from 'form-data';
import path from 'node:path';
import { type ReadStream } from 'node:fs';
import type { AGallery } from '../../types/gallery';
import type { AnImage } from '../../types/story';
import { type ArcAPIOptions, ArcAbstractAPI } from '../abstract-api';
Expand All @@ -23,6 +25,24 @@ export class ArcProtoCenter extends ArcAbstractAPI {
return data;
}

async uploadImageStream(
readableStream: ReadStream,
options?: { contentType?: string; filename?: string }
): Promise<AnImage> {
const form = new FormData();
const contentType = options?.contentType ?? 'application/octet-stream';
const filename = path.basename(String(options?.filename || readableStream.path || 'file.jpg'));

form.append('file', readableStream, {
filename: filename,
contentType,
});

const { data } = await this.client.post('/v2/photos', form, { headers: form.getHeaders() });

return data;
}

async deleteImage(imageId: string) {
const { data } = await this.client.delete(`/v2/photos/${imageId}`);
return data;
Expand All @@ -49,7 +69,7 @@ export class ArcProtoCenter extends ArcAbstractAPI {
}

async updateImage(imageId: string, photoDto: AnImage) {
const { data } = await this.client.put<AnImage>(`/v2/photos/${imageId}`, { data: photoDto });
const { data } = await this.client.put<AnImage>(`/v2/photos/${imageId}`, photoDto);
return data;
}
}
4 changes: 2 additions & 2 deletions src/api/site/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export type GetLinksResponse = {
q_results: Link[];
};

export type GetSectionParams ={
export type GetSectionParams = {
website: string;
offset?: number;
include_inactive?: boolean;
}
};
Loading