@goenhance/strapi-plugins-translate 1.1.8 → 1.1.9

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.
@@ -1145,6 +1145,46 @@ const apiController = ({ strapi: strapi2 }) => ({
1145
1145
  };
1146
1146
  }
1147
1147
  },
1148
+ // Unpublish a document (optionally for a specific locale)
1149
+ async unpublish(ctx) {
1150
+ const { uid, documentId, locale } = ctx.request.body;
1151
+ if (!uid || !documentId) {
1152
+ ctx.status = 400;
1153
+ ctx.body = {
1154
+ data: null,
1155
+ meta: { ok: false, message: "Missing required fields: uid, documentId" }
1156
+ };
1157
+ return;
1158
+ }
1159
+ if (!strapi2.contentTypes[uid]) {
1160
+ ctx.status = 404;
1161
+ ctx.body = {
1162
+ data: null,
1163
+ meta: { ok: false, message: `Content type "${uid}" not found` }
1164
+ };
1165
+ return;
1166
+ }
1167
+ try {
1168
+ const result = await strapi2.documents(uid).unpublish({
1169
+ documentId,
1170
+ ...locale ? { locale } : {}
1171
+ });
1172
+ ctx.body = {
1173
+ data: result,
1174
+ meta: { ok: true, message: "Document unpublished successfully" }
1175
+ };
1176
+ } catch (error) {
1177
+ console.error("Error unpublishing document:", error);
1178
+ ctx.status = 500;
1179
+ ctx.body = {
1180
+ data: null,
1181
+ meta: {
1182
+ ok: false,
1183
+ message: error instanceof Error ? error.message : "Failed to unpublish document"
1184
+ }
1185
+ };
1186
+ }
1187
+ },
1148
1188
  // Trigger batch translation (async - returns immediately)
1149
1189
  async batchTranslate(ctx) {
1150
1190
  const { contentType, entries, sourceLocale, targetLocales, publish = false } = ctx.request.body;
@@ -1282,6 +1322,17 @@ const adminRoutes = [
1282
1322
  }
1283
1323
  ];
1284
1324
  const contentApiRoutes = [
1325
+ {
1326
+ method: "POST",
1327
+ path: "/unpublish",
1328
+ handler: "api.unpublish",
1329
+ config: {
1330
+ policies: [],
1331
+ auth: {
1332
+ scope: []
1333
+ }
1334
+ }
1335
+ },
1285
1336
  {
1286
1337
  method: "POST",
1287
1338
  path: "/batch-translate",
@@ -1144,6 +1144,46 @@ const apiController = ({ strapi: strapi2 }) => ({
1144
1144
  };
1145
1145
  }
1146
1146
  },
1147
+ // Unpublish a document (optionally for a specific locale)
1148
+ async unpublish(ctx) {
1149
+ const { uid, documentId, locale } = ctx.request.body;
1150
+ if (!uid || !documentId) {
1151
+ ctx.status = 400;
1152
+ ctx.body = {
1153
+ data: null,
1154
+ meta: { ok: false, message: "Missing required fields: uid, documentId" }
1155
+ };
1156
+ return;
1157
+ }
1158
+ if (!strapi2.contentTypes[uid]) {
1159
+ ctx.status = 404;
1160
+ ctx.body = {
1161
+ data: null,
1162
+ meta: { ok: false, message: `Content type "${uid}" not found` }
1163
+ };
1164
+ return;
1165
+ }
1166
+ try {
1167
+ const result = await strapi2.documents(uid).unpublish({
1168
+ documentId,
1169
+ ...locale ? { locale } : {}
1170
+ });
1171
+ ctx.body = {
1172
+ data: result,
1173
+ meta: { ok: true, message: "Document unpublished successfully" }
1174
+ };
1175
+ } catch (error) {
1176
+ console.error("Error unpublishing document:", error);
1177
+ ctx.status = 500;
1178
+ ctx.body = {
1179
+ data: null,
1180
+ meta: {
1181
+ ok: false,
1182
+ message: error instanceof Error ? error.message : "Failed to unpublish document"
1183
+ }
1184
+ };
1185
+ }
1186
+ },
1147
1187
  // Trigger batch translation (async - returns immediately)
1148
1188
  async batchTranslate(ctx) {
1149
1189
  const { contentType, entries, sourceLocale, targetLocales, publish = false } = ctx.request.body;
@@ -1281,6 +1321,17 @@ const adminRoutes = [
1281
1321
  }
1282
1322
  ];
1283
1323
  const contentApiRoutes = [
1324
+ {
1325
+ method: "POST",
1326
+ path: "/unpublish",
1327
+ handler: "api.unpublish",
1328
+ config: {
1329
+ policies: [],
1330
+ auth: {
1331
+ scope: []
1332
+ }
1333
+ }
1334
+ },
1284
1335
  {
1285
1336
  method: "POST",
1286
1337
  path: "/batch-translate",
@@ -2,6 +2,15 @@ import { BatchTranslateRequestBody, RequestContext, StrapiContext } from 'src/ty
2
2
  declare const apiController: ({ strapi }: StrapiContext) => {
3
3
  getContentTypes(ctx: RequestContext): Promise<void>;
4
4
  getLocales(ctx: RequestContext): Promise<void>;
5
+ unpublish(ctx: RequestContext & {
6
+ request: {
7
+ body: {
8
+ uid: string;
9
+ documentId: string;
10
+ locale?: string;
11
+ };
12
+ };
13
+ }): Promise<void>;
5
14
  batchTranslate(ctx: RequestContext & {
6
15
  request: {
7
16
  body: BatchTranslateRequestBody;
@@ -57,6 +57,25 @@ declare const _default: {
57
57
  api: ({ strapi }: import("../types").StrapiContext) => {
58
58
  getContentTypes(ctx: import("../types").RequestContext): Promise<void>;
59
59
  getLocales(ctx: import("../types").RequestContext): Promise<void>;
60
+ unpublish(ctx: Omit<import("koa").Context, "body" | "query" | "request"> & {
61
+ body: object;
62
+ query: object;
63
+ params: object;
64
+ request: Omit<import("koa").Request, "body"> & {
65
+ body: object;
66
+ };
67
+ state: {
68
+ user?: import("../types").AdminUser;
69
+ };
70
+ } & {
71
+ request: {
72
+ body: {
73
+ uid: string;
74
+ documentId: string;
75
+ locale?: string;
76
+ };
77
+ };
78
+ }): Promise<void>;
60
79
  batchTranslate(ctx: Omit<import("koa").Context, "body" | "query" | "request"> & {
61
80
  body: object;
62
81
  query: object;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.8",
2
+ "version": "1.1.9",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "plugin",