🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@mdedit/sdk

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mdedit/sdk - npm Package Compare versions

Comparing version
0.2.2
to
0.3.0
+37
-1
dist/index.d.ts

@@ -130,2 +130,32 @@ import { ArticleContentSaveOptions } from '@mdedit/mdedit-api-client/articleContent';

}
interface PublishArticleRequest {
customSlug?: string;
seoMetadata?: {
title?: string;
description?: string;
image?: string;
keywords?: string[];
};
}
interface PublishArticleResponse {
publishId: string;
shortUrl: string;
fullUrl: string;
publishedAt: number;
}
interface PublishStatusResponse {
isPublished: boolean;
publishId?: string;
shortUrl?: string;
fullUrl?: string;
publishedAt?: number;
lastUpdated?: number;
viewCount?: number;
customSlug?: string;
seoMetadata?: PublishArticleRequest['seoMetadata'];
}
interface UnpublishArticleResponse {
success: boolean;
publishId: string;
}
interface SdkClient {

@@ -174,5 +204,11 @@ apiKeys: {

};
publish: {
publish: (workspaceId: string, articleId: string, request?: PublishArticleRequest) => Promise<PublishArticleResponse>;
status: (workspaceId: string, articleId: string) => Promise<PublishStatusResponse>;
update: (workspaceId: string, articleId: string, request?: PublishArticleRequest) => Promise<PublishArticleResponse>;
unpublish: (workspaceId: string, articleId: string) => Promise<UnpublishArticleResponse>;
};
}
declare function createSdkClient(config: ApiClientConfig): SdkClient;
export { type ApiClientConfig, type ApiKeyListItem, type AuthHeaders, type CollaborationCheckpointResponse, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateArticleRequest, type CreateWorkspaceRequest, FetchError, type IArticle, type IFolder, type IFolderCreateRequest, type IFolderUpdateRequest, type IWorkspace, type ListApiKeysResponse, type SdkClient, type UpdateArticleRequest, type UpdateWorkspaceRequest, createSdkClient };
export { type ApiClientConfig, type ApiKeyListItem, type AuthHeaders, type CollaborationCheckpointResponse, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateArticleRequest, type CreateWorkspaceRequest, FetchError, type IArticle, type IFolder, type IFolderCreateRequest, type IFolderUpdateRequest, type IWorkspace, type ListApiKeysResponse, type PublishArticleRequest, type PublishArticleResponse, type PublishStatusResponse, type SdkClient, type UnpublishArticleResponse, type UpdateArticleRequest, type UpdateWorkspaceRequest, createSdkClient };

@@ -354,2 +354,14 @@ // ../mdedit-api-client/src/shared.ts

};
var readFolderErrorMessage = async (response, fallback) => {
const errorText = await response.text();
try {
const body = JSON.parse(errorText);
const message = body?.error?.message ?? body?.message;
if (typeof message === "string" && message.trim()) {
return message;
}
} catch {
}
return errorText.trim() || fallback;
};
var normalizeFolder = (raw) => {

@@ -395,4 +407,6 @@ const id = raw?.id ?? raw?.folderId;

if (!response.ok) {
const errorText = await response.text();
throw new errors_default(`Error creating folder. ${errorText}`, response.status);
throw new errors_default(
await readFolderErrorMessage(response, "Error creating folder"),
response.status
);
}

@@ -411,4 +425,6 @@ return normalizeFolder(await response.json());

if (!response.ok) {
const errorText = await response.text();
throw new errors_default(`Error updating folder. ${errorText}`, response.status);
throw new errors_default(
await readFolderErrorMessage(response, "Error updating folder"),
response.status
);
}

@@ -540,2 +556,66 @@ const result = await response.json();

// ../mdedit-api-client/src/publish.ts
var publishArticle = async (workspaceId, articleId, body, fetchers) => {
const fetchV2 = fetchers?.customFetchV2 ?? customFetchV2;
const response = await fetchV2(
`/workspaces/${workspaceId}/articles/${articleId}/publish`,
{
method: "POST",
body: JSON.stringify(body)
}
);
if (!response.ok) {
throw new errors_default(
`Error publishing article: ${await response.text()}`,
response.status
);
}
return response.json();
};
var unpublishArticle = async (workspaceId, articleId, fetchers) => {
const fetchV2 = fetchers?.customFetchV2 ?? customFetchV2;
const response = await fetchV2(
`/workspaces/${workspaceId}/articles/${articleId}/publish`,
{ method: "DELETE" }
);
if (!response.ok) {
throw new errors_default(
`Error unpublishing article: ${await response.text()}`,
response.status
);
}
return response.json();
};
var getPublishStatus = async (workspaceId, articleId, fetchers) => {
const fetchV2 = fetchers?.customFetchV2 ?? customFetchV2;
const response = await fetchV2(
`/workspaces/${workspaceId}/articles/${articleId}/publish`,
{ method: "GET" }
);
if (!response.ok) {
throw new errors_default(
`Error fetching publish status: ${await response.text()}`,
response.status
);
}
return response.json();
};
var updatePublishedArticle = async (workspaceId, articleId, body, fetchers) => {
const fetchV2 = fetchers?.customFetchV2 ?? customFetchV2;
const response = await fetchV2(
`/workspaces/${workspaceId}/articles/${articleId}/publish`,
{
method: "PUT",
body: JSON.stringify(body)
}
);
if (!response.ok) {
throw new errors_default(
`Error updating published article: ${await response.text()}`,
response.status
);
}
return response.json();
};
// src/index.ts

@@ -605,2 +685,8 @@ var FetchError2 = class extends Error {

checkpoint: (workspaceId, articleId) => withFetchError(() => checkpointCollaboration(workspaceId, articleId, fetchers))
},
publish: {
publish: (workspaceId, articleId, request = {}) => withFetchError(() => publishArticle(workspaceId, articleId, request, fetchers)),
status: (workspaceId, articleId) => withFetchError(() => getPublishStatus(workspaceId, articleId, fetchers)),
update: (workspaceId, articleId, request = {}) => withFetchError(() => updatePublishedArticle(workspaceId, articleId, request, fetchers)),
unpublish: (workspaceId, articleId) => withFetchError(() => unpublishArticle(workspaceId, articleId, fetchers))
}

@@ -607,0 +693,0 @@ };

+1
-1
{
"name": "@mdedit/sdk",
"version": "0.2.2",
"version": "0.3.0",
"private": false,

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is too big to display