@localazy/strapi-plugin 1.1.0 → 1.1.2
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.
- package/dist/_chunks/{FetchIdentity-DfV1OWMB.js → FetchIdentity-CevvxeEj.js} +73 -46
- package/dist/_chunks/{FetchIdentity-lkoWjYjn.mjs → FetchIdentity-DeThazz9.mjs} +43 -16
- package/dist/_chunks/{LanguagesSelector-BmWfSZq6.js → LanguagesSelector-BExpl4Vx.js} +15 -3
- package/dist/_chunks/{LanguagesSelector-vSZvVGUT.mjs → LanguagesSelector-D62gLZsM.mjs} +15 -3
- package/dist/_chunks/{LocalazyApp-st8mwIbM.mjs → LocalazyApp-Czkb4s5J.mjs} +791 -61
- package/dist/_chunks/{LocalazyApp-BUfYt7UL.js → LocalazyApp-DIcO748C.js} +791 -59
- package/dist/_chunks/{LocalazyContentTransferSetup-BjLBgqFO.js → LocalazyContentTransferSetup-DAyZdwi9.js} +13 -10
- package/dist/_chunks/{LocalazyContentTransferSetup-D2YvBYs_.mjs → LocalazyContentTransferSetup-Dx0Z6DXc.mjs} +13 -10
- package/dist/_chunks/{LocalazyGlobalSettings-DHCU2_RH.mjs → LocalazyGlobalSettings-DWMBqlN4.mjs} +149 -12
- package/dist/_chunks/{LocalazyGlobalSettings-Do5tOyhB.js → LocalazyGlobalSettings-DjrXGVxl.js} +148 -11
- package/dist/_chunks/{LocalazyPanel-CulgT97p.mjs → LocalazyPanel-B-0HBTL_.mjs} +4 -4
- package/dist/_chunks/{LocalazyPanel-BDxUI_RH.js → LocalazyPanel-nBOpQo5B.js} +4 -4
- package/dist/_chunks/{LocalazyStatusColumn-DoTWD2eL.mjs → LocalazyStatusColumn-CpO3yccG.mjs} +9 -7
- package/dist/_chunks/{LocalazyStatusColumn-Dpwoc5Ig.js → LocalazyStatusColumn-cGsUDMlX.js} +9 -7
- package/dist/_chunks/{RequireLocalazyAuth-BzM7C6Yw.js → RequireLocalazyAuth-56K8HUNR.js} +4 -4
- package/dist/_chunks/{RequireLocalazyAuth-CqHrZ1Ah.mjs → RequireLocalazyAuth-Dh-mAMcg.mjs} +4 -4
- package/dist/_chunks/{entry-exclusion-service-DWFMKgkA.mjs → entry-exclusion-service-Dm5_iP7I.mjs} +1 -1
- package/dist/_chunks/{entry-exclusion-service-Cvu8PQUI.js → entry-exclusion-service-Rf4Tr0zW.js} +1 -1
- package/dist/_chunks/{has-model-changed-CWdMNRB1.mjs → has-model-changed-6p1lR-Ho.mjs} +2 -2
- package/dist/_chunks/{has-model-changed-D1f6is8z.js → has-model-changed-CGyDQARr.js} +2 -2
- package/dist/_chunks/{i18n-DaBjUC3Y.js → i18n-CAsbU4pi.js} +62 -4
- package/dist/_chunks/{i18n-Bga-GG_Z.mjs → i18n-QelOdIB2.mjs} +62 -4
- package/dist/_chunks/{index-BSNW1ypR.js → index-BK7lmZSN.js} +57 -19
- package/dist/_chunks/{index-CtvR-R3c.mjs → index-Bpf1Mw2A.mjs} +8 -8
- package/dist/_chunks/{index-BgPI2yQD.js → index-BsQ_ie4C.js} +8 -8
- package/dist/_chunks/{index-BIHAiJnE.mjs → index-CHjIMO9T.mjs} +78 -40
- package/dist/_chunks/{strapi-api-base-CturxOqD.mjs → strapi-api-base-Bem_CGuz.mjs} +2 -2
- package/dist/_chunks/{strapi-api-base-CN6q5tPh.js → strapi-api-base-W_bUTSlY.js} +2 -2
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/PluginErrorBoundary.d.ts +5 -0
- package/dist/admin/src/modules/@common/locale/en.d.ts +4 -0
- package/dist/admin/src/modules/@common/services/project-service.d.ts +9 -0
- package/dist/admin/src/modules/@common/styles/heading-fix.d.ts +7 -0
- package/dist/admin/src/modules/@common/utils/export-json.d.ts +1 -0
- package/dist/admin/src/modules/@common/utils/redirect-to-plugin-route.d.ts +1 -0
- package/dist/admin/src/modules/activity-logs/components/HighlightMatch.d.ts +6 -0
- package/dist/admin/src/modules/activity-logs/components/SessionMetadata.d.ts +7 -0
- package/dist/admin/src/modules/activity-logs/components/SessionsTable.d.ts +17 -0
- package/dist/admin/src/modules/activity-logs/components/SortableHeader.d.ts +10 -0
- package/dist/admin/src/modules/activity-logs/components/StatusLabel.d.ts +6 -0
- package/dist/admin/src/modules/activity-logs/hooks/use-debounced-search.d.ts +6 -0
- package/dist/admin/src/modules/activity-logs/locale/en.d.ts +33 -0
- package/dist/admin/src/modules/activity-logs/models/activity-logs.d.ts +19 -0
- package/dist/admin/src/modules/activity-logs/services/activity-logs-service.d.ts +6 -0
- package/dist/admin/src/modules/activity-logs/utils/export-logs.d.ts +1 -0
- package/dist/admin/src/modules/activity-logs/utils/format-utils.d.ts +4 -0
- package/dist/admin/src/modules/plugin-settings/components/WebhookSetup.d.ts +2 -0
- package/dist/admin/src/modules/plugin-settings/locale/en.d.ts +21 -0
- package/dist/admin/src/pages/ActivityLogDetail.d.ts +7 -0
- package/dist/admin/src/pages/ActivityLogs.d.ts +7 -0
- package/dist/server/index.js +395 -49
- package/dist/server/index.mjs +395 -49
- package/dist/server/src/controllers/activity-logs-controller.d.ts +10 -0
- package/dist/server/src/controllers/index.d.ts +12 -1
- package/dist/server/src/controllers/localazy-project-controller.d.ts +4 -1
- package/dist/server/src/core/index.d.ts +13 -0
- package/dist/server/src/db/model/activity-logs.d.ts +20 -0
- package/dist/server/src/db/model/plugin-settings.d.ts +14 -0
- package/dist/server/src/index.d.ts +27 -1
- package/dist/server/src/routes/activity-logs-routes.d.ts +9 -0
- package/dist/server/src/services/activity-logs-service.d.ts +17 -0
- package/dist/server/src/services/index.d.ts +15 -0
- package/dist/server/src/services/localazy-pubapi-service.d.ts +2 -0
- package/package.json +4 -3
package/dist/server/index.js
CHANGED
|
@@ -20532,7 +20532,7 @@ var distExports = dist$1.exports;
|
|
|
20532
20532
|
const io = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
|
|
20533
20533
|
const { Server: Server2, Namespace, Socket: Socket3 } = io;
|
|
20534
20534
|
const name = "@localazy/strapi-plugin";
|
|
20535
|
-
const version = "1.1.
|
|
20535
|
+
const version = "1.1.2";
|
|
20536
20536
|
const description = "The official Strapi Plugin by Localazy.";
|
|
20537
20537
|
const keywords = [
|
|
20538
20538
|
"strapi",
|
|
@@ -20582,7 +20582,8 @@ const bin = {
|
|
|
20582
20582
|
};
|
|
20583
20583
|
const files = [
|
|
20584
20584
|
"dist",
|
|
20585
|
-
"install"
|
|
20585
|
+
"install",
|
|
20586
|
+
"README.md"
|
|
20586
20587
|
];
|
|
20587
20588
|
const scripts = {
|
|
20588
20589
|
build: "strapi-plugin build",
|
|
@@ -20598,7 +20599,7 @@ const scripts = {
|
|
|
20598
20599
|
verify: "strapi-plugin verify",
|
|
20599
20600
|
watch: "strapi-plugin watch",
|
|
20600
20601
|
"watch:link": "strapi-plugin watch:link",
|
|
20601
|
-
prepare: "husky"
|
|
20602
|
+
prepare: "husky || true"
|
|
20602
20603
|
};
|
|
20603
20604
|
const dependencies = {
|
|
20604
20605
|
shelljs: "^0.8.5",
|
|
@@ -22076,6 +22077,9 @@ const getLocalazyUploadService = () => {
|
|
|
22076
22077
|
const getEntryExclusionService = () => {
|
|
22077
22078
|
return strapi.plugin(PLUGIN_NAME).service("EntryExclusionService");
|
|
22078
22079
|
};
|
|
22080
|
+
const getActivityLogsService = () => {
|
|
22081
|
+
return strapi.plugin(PLUGIN_NAME).service("ActivityLogsService");
|
|
22082
|
+
};
|
|
22079
22083
|
class PluginSettingsServiceHelper {
|
|
22080
22084
|
constructor() {
|
|
22081
22085
|
this.PluginSettingsService = getPluginSettingsService();
|
|
@@ -24212,13 +24216,74 @@ const StrapiController = ({ strapi: strapi2 }) => ({
|
|
|
24212
24216
|
};
|
|
24213
24217
|
}
|
|
24214
24218
|
});
|
|
24215
|
-
const
|
|
24219
|
+
const STRAPI_WEBHOOK_CUSTOM_ID = "strapi-plugin-localazy";
|
|
24220
|
+
const LocalazyProjectController = ({ strapi: strapi2 }) => ({
|
|
24216
24221
|
async getConnectedProject(ctx) {
|
|
24217
24222
|
const LocalazyUserService2 = getLocalazyUserService();
|
|
24218
24223
|
const LocalazyPubAPIService2 = getLocalazyPubAPIService();
|
|
24219
24224
|
const user = await LocalazyUserService2.getUser();
|
|
24220
24225
|
const project = await LocalazyPubAPIService2.getProject(user.project.id, true, true);
|
|
24221
24226
|
ctx.body = project;
|
|
24227
|
+
},
|
|
24228
|
+
async getWebhookStatus(ctx) {
|
|
24229
|
+
const LocalazyUserService2 = getLocalazyUserService();
|
|
24230
|
+
const user = await LocalazyUserService2.getUser();
|
|
24231
|
+
const LocalazyPubApiService = getLocalazyPubAPIService();
|
|
24232
|
+
const webhooks = await LocalazyPubApiService.listWebhooks(user.project.id);
|
|
24233
|
+
const ours = webhooks.find((w2) => w2.customId === STRAPI_WEBHOOK_CUSTOM_ID);
|
|
24234
|
+
if (ours) {
|
|
24235
|
+
ctx.body = { status: "configured", url: ours.url, enabled: ours.enabled };
|
|
24236
|
+
return;
|
|
24237
|
+
}
|
|
24238
|
+
ctx.body = { status: "not_configured" };
|
|
24239
|
+
},
|
|
24240
|
+
async setupWebhook(ctx) {
|
|
24241
|
+
const { url: url2 } = ctx.request.body;
|
|
24242
|
+
if (!url2 || typeof url2 !== "string") {
|
|
24243
|
+
return ctx.badRequest("Webhook URL is required");
|
|
24244
|
+
}
|
|
24245
|
+
try {
|
|
24246
|
+
const parsed = new URL(url2);
|
|
24247
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
24248
|
+
return ctx.badRequest("Webhook URL must use http or https protocol");
|
|
24249
|
+
}
|
|
24250
|
+
} catch {
|
|
24251
|
+
return ctx.badRequest("Invalid webhook URL");
|
|
24252
|
+
}
|
|
24253
|
+
const LocalazyUserService2 = getLocalazyUserService();
|
|
24254
|
+
const user = await LocalazyUserService2.getUser();
|
|
24255
|
+
const LocalazyPubApiService = getLocalazyPubAPIService();
|
|
24256
|
+
const PluginSettingsService2 = getPluginSettingsService();
|
|
24257
|
+
const existing = await LocalazyPubApiService.listWebhooks(user.project.id);
|
|
24258
|
+
const filtered = existing.filter((w2) => w2.customId !== STRAPI_WEBHOOK_CUSTOM_ID);
|
|
24259
|
+
const items = [
|
|
24260
|
+
...filtered,
|
|
24261
|
+
{
|
|
24262
|
+
enabled: true,
|
|
24263
|
+
customId: STRAPI_WEBHOOK_CUSTOM_ID,
|
|
24264
|
+
url: url2,
|
|
24265
|
+
events: ["project_published"],
|
|
24266
|
+
description: "Strapi Plugin - Download translations"
|
|
24267
|
+
}
|
|
24268
|
+
];
|
|
24269
|
+
await LocalazyPubApiService.updateWebhooks(user.project.id, items);
|
|
24270
|
+
await PluginSettingsService2.updatePluginSettings({
|
|
24271
|
+
webhookConfig: { url: url2 }
|
|
24272
|
+
});
|
|
24273
|
+
ctx.body = { success: true };
|
|
24274
|
+
},
|
|
24275
|
+
async getStrapiUrl(ctx) {
|
|
24276
|
+
let url2 = strapi2.config.get("server.url");
|
|
24277
|
+
if (!url2) {
|
|
24278
|
+
const host = strapi2.config.get("server.host") || "0.0.0.0";
|
|
24279
|
+
const port = strapi2.config.get("server.port") || 1337;
|
|
24280
|
+
const displayHost = host === "0.0.0.0" || host === "::" ? "localhost" : host;
|
|
24281
|
+
url2 = `http://${displayHost}:${port}`;
|
|
24282
|
+
}
|
|
24283
|
+
const isLocal = /^https?:\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0|10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/.test(
|
|
24284
|
+
url2
|
|
24285
|
+
);
|
|
24286
|
+
ctx.body = { url: url2, isLocal };
|
|
24222
24287
|
}
|
|
24223
24288
|
});
|
|
24224
24289
|
const PluginSettingsController = ({ strapi: _strapi }) => ({
|
|
@@ -24416,6 +24481,27 @@ const EntryExclusionController = ({ strapi: strapi2 }) => ({
|
|
|
24416
24481
|
}
|
|
24417
24482
|
}
|
|
24418
24483
|
});
|
|
24484
|
+
const ActivityLogsController = ({ strapi: _strapi }) => ({
|
|
24485
|
+
async getSessions(ctx) {
|
|
24486
|
+
const { type: type2 } = ctx.query;
|
|
24487
|
+
ctx.body = await getActivityLogsService().getSessions(type2);
|
|
24488
|
+
},
|
|
24489
|
+
async getSession(ctx) {
|
|
24490
|
+
const { sessionId } = ctx.params;
|
|
24491
|
+
const session = await getActivityLogsService().getSession(sessionId);
|
|
24492
|
+
if (!session) {
|
|
24493
|
+
return ctx.notFound("Session not found");
|
|
24494
|
+
}
|
|
24495
|
+
ctx.body = session;
|
|
24496
|
+
},
|
|
24497
|
+
async exportSessions(ctx) {
|
|
24498
|
+
ctx.body = await getActivityLogsService().getAllSessionsWithEntries();
|
|
24499
|
+
},
|
|
24500
|
+
async clearSessions(ctx) {
|
|
24501
|
+
await getActivityLogsService().clearSessions();
|
|
24502
|
+
ctx.body = { success: true };
|
|
24503
|
+
}
|
|
24504
|
+
});
|
|
24419
24505
|
const controllers = {
|
|
24420
24506
|
LocalazyUserController,
|
|
24421
24507
|
LocalazyAuthController,
|
|
@@ -24423,7 +24509,8 @@ const controllers = {
|
|
|
24423
24509
|
LocalazyProjectController,
|
|
24424
24510
|
PluginSettingsController,
|
|
24425
24511
|
LocalazyTransferController,
|
|
24426
|
-
EntryExclusionController
|
|
24512
|
+
EntryExclusionController,
|
|
24513
|
+
ActivityLogsController
|
|
24427
24514
|
};
|
|
24428
24515
|
const verifyWebhook = (config2, { strapi: strapi2 }) => {
|
|
24429
24516
|
return async (ctx, next) => {
|
|
@@ -24480,11 +24567,11 @@ const middlewares = {
|
|
|
24480
24567
|
verifyWebhook
|
|
24481
24568
|
};
|
|
24482
24569
|
const policies = {};
|
|
24483
|
-
const ROUTE_PREFIX$
|
|
24570
|
+
const ROUTE_PREFIX$8 = "/user";
|
|
24484
24571
|
const LocalazyUserRoutes = [
|
|
24485
24572
|
{
|
|
24486
24573
|
method: "GET",
|
|
24487
|
-
path: `${ROUTE_PREFIX$
|
|
24574
|
+
path: `${ROUTE_PREFIX$8}`,
|
|
24488
24575
|
handler: "LocalazyUserController.getUser",
|
|
24489
24576
|
config: {
|
|
24490
24577
|
policies: []
|
|
@@ -24492,7 +24579,7 @@ const LocalazyUserRoutes = [
|
|
|
24492
24579
|
},
|
|
24493
24580
|
{
|
|
24494
24581
|
method: "PUT",
|
|
24495
|
-
path: `${ROUTE_PREFIX$
|
|
24582
|
+
path: `${ROUTE_PREFIX$8}`,
|
|
24496
24583
|
handler: "LocalazyUserController.updateUser",
|
|
24497
24584
|
config: {
|
|
24498
24585
|
policies: []
|
|
@@ -24500,18 +24587,18 @@ const LocalazyUserRoutes = [
|
|
|
24500
24587
|
},
|
|
24501
24588
|
{
|
|
24502
24589
|
method: "DELETE",
|
|
24503
|
-
path: `${ROUTE_PREFIX$
|
|
24590
|
+
path: `${ROUTE_PREFIX$8}`,
|
|
24504
24591
|
handler: "LocalazyUserController.deleteUser",
|
|
24505
24592
|
config: {
|
|
24506
24593
|
policies: []
|
|
24507
24594
|
}
|
|
24508
24595
|
}
|
|
24509
24596
|
];
|
|
24510
|
-
const ROUTE_PREFIX$
|
|
24597
|
+
const ROUTE_PREFIX$7 = "/auth";
|
|
24511
24598
|
const LocalazyAuthRoutes = [
|
|
24512
24599
|
{
|
|
24513
24600
|
method: "GET",
|
|
24514
|
-
path: `${ROUTE_PREFIX$
|
|
24601
|
+
path: `${ROUTE_PREFIX$7}/generate-keys`,
|
|
24515
24602
|
handler: "LocalazyAuthController.generateKeys",
|
|
24516
24603
|
config: {
|
|
24517
24604
|
policies: []
|
|
@@ -24519,18 +24606,18 @@ const LocalazyAuthRoutes = [
|
|
|
24519
24606
|
},
|
|
24520
24607
|
{
|
|
24521
24608
|
method: "GET",
|
|
24522
|
-
path: `${ROUTE_PREFIX$
|
|
24609
|
+
path: `${ROUTE_PREFIX$7}/continuous-poll`,
|
|
24523
24610
|
handler: "LocalazyAuthController.continuousPoll",
|
|
24524
24611
|
config: {
|
|
24525
24612
|
policies: []
|
|
24526
24613
|
}
|
|
24527
24614
|
}
|
|
24528
24615
|
];
|
|
24529
|
-
const ROUTE_PREFIX$
|
|
24616
|
+
const ROUTE_PREFIX$6 = "/plugin-settings";
|
|
24530
24617
|
const PluginSettingsRoutes = [
|
|
24531
24618
|
{
|
|
24532
24619
|
method: "GET",
|
|
24533
|
-
path: `${ROUTE_PREFIX$
|
|
24620
|
+
path: `${ROUTE_PREFIX$6}/content-transfer-setup`,
|
|
24534
24621
|
handler: "PluginSettingsController.getContentTransferSetup",
|
|
24535
24622
|
config: {
|
|
24536
24623
|
policies: []
|
|
@@ -24538,7 +24625,7 @@ const PluginSettingsRoutes = [
|
|
|
24538
24625
|
},
|
|
24539
24626
|
{
|
|
24540
24627
|
method: "PUT",
|
|
24541
|
-
path: `${ROUTE_PREFIX$
|
|
24628
|
+
path: `${ROUTE_PREFIX$6}/content-transfer-setup`,
|
|
24542
24629
|
handler: "PluginSettingsController.updateContentTransferSetup",
|
|
24543
24630
|
config: {
|
|
24544
24631
|
policies: []
|
|
@@ -24546,7 +24633,7 @@ const PluginSettingsRoutes = [
|
|
|
24546
24633
|
},
|
|
24547
24634
|
{
|
|
24548
24635
|
method: "GET",
|
|
24549
|
-
path: `${ROUTE_PREFIX$
|
|
24636
|
+
path: `${ROUTE_PREFIX$6}/plugin-settings`,
|
|
24550
24637
|
handler: "PluginSettingsController.getPluginSettings",
|
|
24551
24638
|
config: {
|
|
24552
24639
|
policies: []
|
|
@@ -24554,7 +24641,7 @@ const PluginSettingsRoutes = [
|
|
|
24554
24641
|
},
|
|
24555
24642
|
{
|
|
24556
24643
|
method: "PUT",
|
|
24557
|
-
path: `${ROUTE_PREFIX$
|
|
24644
|
+
path: `${ROUTE_PREFIX$6}/plugin-settings`,
|
|
24558
24645
|
handler: "PluginSettingsController.updatePluginSettings",
|
|
24559
24646
|
config: {
|
|
24560
24647
|
policies: []
|
|
@@ -24562,18 +24649,18 @@ const PluginSettingsRoutes = [
|
|
|
24562
24649
|
},
|
|
24563
24650
|
{
|
|
24564
24651
|
method: "GET",
|
|
24565
|
-
path: `${ROUTE_PREFIX$
|
|
24652
|
+
path: `${ROUTE_PREFIX$6}/sync-cursor`,
|
|
24566
24653
|
handler: "PluginSettingsController.getSyncCursor",
|
|
24567
24654
|
config: {
|
|
24568
24655
|
policies: []
|
|
24569
24656
|
}
|
|
24570
24657
|
}
|
|
24571
24658
|
];
|
|
24572
|
-
const ROUTE_PREFIX$
|
|
24659
|
+
const ROUTE_PREFIX$5 = "/strapi";
|
|
24573
24660
|
const StrapiRoutes = [
|
|
24574
24661
|
{
|
|
24575
24662
|
method: "GET",
|
|
24576
|
-
path: `${ROUTE_PREFIX$
|
|
24663
|
+
path: `${ROUTE_PREFIX$5}/models`,
|
|
24577
24664
|
handler: "StrapiController.getModels",
|
|
24578
24665
|
config: {
|
|
24579
24666
|
policies: []
|
|
@@ -24581,7 +24668,7 @@ const StrapiRoutes = [
|
|
|
24581
24668
|
},
|
|
24582
24669
|
{
|
|
24583
24670
|
method: "GET",
|
|
24584
|
-
path: `${ROUTE_PREFIX$
|
|
24671
|
+
path: `${ROUTE_PREFIX$5}/localizable-models`,
|
|
24585
24672
|
handler: "StrapiController.getLocalizableModels",
|
|
24586
24673
|
config: {
|
|
24587
24674
|
policies: []
|
|
@@ -24589,7 +24676,7 @@ const StrapiRoutes = [
|
|
|
24589
24676
|
},
|
|
24590
24677
|
{
|
|
24591
24678
|
method: "POST",
|
|
24592
|
-
path: `${ROUTE_PREFIX$
|
|
24679
|
+
path: `${ROUTE_PREFIX$5}/lifecycle/localazy-webhooks`,
|
|
24593
24680
|
handler: "StrapiController.postLifecycleLocalazyWebhooks",
|
|
24594
24681
|
config: {
|
|
24595
24682
|
policies: []
|
|
@@ -24597,18 +24684,18 @@ const StrapiRoutes = [
|
|
|
24597
24684
|
},
|
|
24598
24685
|
{
|
|
24599
24686
|
method: "GET",
|
|
24600
|
-
path: `${ROUTE_PREFIX$
|
|
24687
|
+
path: `${ROUTE_PREFIX$5}/version`,
|
|
24601
24688
|
handler: "StrapiController.getPluginVersion",
|
|
24602
24689
|
config: {
|
|
24603
24690
|
policies: []
|
|
24604
24691
|
}
|
|
24605
24692
|
}
|
|
24606
24693
|
];
|
|
24607
|
-
const ROUTE_PREFIX$
|
|
24694
|
+
const ROUTE_PREFIX$4 = "/transfer";
|
|
24608
24695
|
const LocalazyTransferRoutes = [
|
|
24609
24696
|
{
|
|
24610
24697
|
method: "POST",
|
|
24611
|
-
path: `${ROUTE_PREFIX$
|
|
24698
|
+
path: `${ROUTE_PREFIX$4}/upload`,
|
|
24612
24699
|
handler: "LocalazyTransferController.upload",
|
|
24613
24700
|
config: {
|
|
24614
24701
|
policies: []
|
|
@@ -24616,29 +24703,53 @@ const LocalazyTransferRoutes = [
|
|
|
24616
24703
|
},
|
|
24617
24704
|
{
|
|
24618
24705
|
method: "POST",
|
|
24619
|
-
path: `${ROUTE_PREFIX$
|
|
24706
|
+
path: `${ROUTE_PREFIX$4}/download`,
|
|
24620
24707
|
handler: "LocalazyTransferController.download",
|
|
24621
24708
|
config: {
|
|
24622
24709
|
policies: []
|
|
24623
24710
|
}
|
|
24624
24711
|
}
|
|
24625
24712
|
];
|
|
24626
|
-
const ROUTE_PREFIX$
|
|
24713
|
+
const ROUTE_PREFIX$3 = "/project";
|
|
24627
24714
|
const LocalazyProjectRoutes = [
|
|
24628
24715
|
{
|
|
24629
24716
|
method: "GET",
|
|
24630
|
-
path: `${ROUTE_PREFIX$
|
|
24717
|
+
path: `${ROUTE_PREFIX$3}`,
|
|
24631
24718
|
handler: "LocalazyProjectController.getConnectedProject",
|
|
24632
24719
|
config: {
|
|
24633
24720
|
policies: []
|
|
24634
24721
|
}
|
|
24722
|
+
},
|
|
24723
|
+
{
|
|
24724
|
+
method: "GET",
|
|
24725
|
+
path: `${ROUTE_PREFIX$3}/webhooks`,
|
|
24726
|
+
handler: "LocalazyProjectController.getWebhookStatus",
|
|
24727
|
+
config: {
|
|
24728
|
+
policies: []
|
|
24729
|
+
}
|
|
24730
|
+
},
|
|
24731
|
+
{
|
|
24732
|
+
method: "POST",
|
|
24733
|
+
path: `${ROUTE_PREFIX$3}/webhooks/setup`,
|
|
24734
|
+
handler: "LocalazyProjectController.setupWebhook",
|
|
24735
|
+
config: {
|
|
24736
|
+
policies: []
|
|
24737
|
+
}
|
|
24738
|
+
},
|
|
24739
|
+
{
|
|
24740
|
+
method: "GET",
|
|
24741
|
+
path: `${ROUTE_PREFIX$3}/strapi-url`,
|
|
24742
|
+
handler: "LocalazyProjectController.getStrapiUrl",
|
|
24743
|
+
config: {
|
|
24744
|
+
policies: []
|
|
24745
|
+
}
|
|
24635
24746
|
}
|
|
24636
24747
|
];
|
|
24637
|
-
const ROUTE_PREFIX$
|
|
24748
|
+
const ROUTE_PREFIX$2 = "/public/transfer";
|
|
24638
24749
|
const LocalazyPublicTransferRoutes = [
|
|
24639
24750
|
{
|
|
24640
24751
|
method: "POST",
|
|
24641
|
-
path: `${ROUTE_PREFIX$
|
|
24752
|
+
path: `${ROUTE_PREFIX$2}/download`,
|
|
24642
24753
|
handler: "LocalazyTransferController.download",
|
|
24643
24754
|
config: {
|
|
24644
24755
|
policies: [],
|
|
@@ -24648,11 +24759,11 @@ const LocalazyPublicTransferRoutes = [
|
|
|
24648
24759
|
}
|
|
24649
24760
|
}
|
|
24650
24761
|
];
|
|
24651
|
-
const ROUTE_PREFIX = "/entry-exclusion";
|
|
24762
|
+
const ROUTE_PREFIX$1 = "/entry-exclusion";
|
|
24652
24763
|
const EntryExclusionRoutes = [
|
|
24653
24764
|
{
|
|
24654
24765
|
method: "GET",
|
|
24655
|
-
path: `${ROUTE_PREFIX}/:contentType/:documentId`,
|
|
24766
|
+
path: `${ROUTE_PREFIX$1}/:contentType/:documentId`,
|
|
24656
24767
|
handler: "EntryExclusionController.getEntryExclusion",
|
|
24657
24768
|
config: {
|
|
24658
24769
|
policies: []
|
|
@@ -24660,7 +24771,7 @@ const EntryExclusionRoutes = [
|
|
|
24660
24771
|
},
|
|
24661
24772
|
{
|
|
24662
24773
|
method: "PUT",
|
|
24663
|
-
path: `${ROUTE_PREFIX}/:contentType/:documentId`,
|
|
24774
|
+
path: `${ROUTE_PREFIX$1}/:contentType/:documentId`,
|
|
24664
24775
|
handler: "EntryExclusionController.setEntryExclusion",
|
|
24665
24776
|
config: {
|
|
24666
24777
|
policies: []
|
|
@@ -24668,13 +24779,48 @@ const EntryExclusionRoutes = [
|
|
|
24668
24779
|
},
|
|
24669
24780
|
{
|
|
24670
24781
|
method: "GET",
|
|
24671
|
-
path: `${ROUTE_PREFIX}/:contentType`,
|
|
24782
|
+
path: `${ROUTE_PREFIX$1}/:contentType`,
|
|
24672
24783
|
handler: "EntryExclusionController.getContentTypeExclusions",
|
|
24673
24784
|
config: {
|
|
24674
24785
|
policies: []
|
|
24675
24786
|
}
|
|
24676
24787
|
}
|
|
24677
24788
|
];
|
|
24789
|
+
const ROUTE_PREFIX = "/activity-logs";
|
|
24790
|
+
const ActivityLogsRoutes = [
|
|
24791
|
+
{
|
|
24792
|
+
method: "GET",
|
|
24793
|
+
path: `${ROUTE_PREFIX}`,
|
|
24794
|
+
handler: "ActivityLogsController.getSessions",
|
|
24795
|
+
config: {
|
|
24796
|
+
policies: []
|
|
24797
|
+
}
|
|
24798
|
+
},
|
|
24799
|
+
{
|
|
24800
|
+
method: "GET",
|
|
24801
|
+
path: `${ROUTE_PREFIX}/export`,
|
|
24802
|
+
handler: "ActivityLogsController.exportSessions",
|
|
24803
|
+
config: {
|
|
24804
|
+
policies: []
|
|
24805
|
+
}
|
|
24806
|
+
},
|
|
24807
|
+
{
|
|
24808
|
+
method: "GET",
|
|
24809
|
+
path: `${ROUTE_PREFIX}/:sessionId`,
|
|
24810
|
+
handler: "ActivityLogsController.getSession",
|
|
24811
|
+
config: {
|
|
24812
|
+
policies: []
|
|
24813
|
+
}
|
|
24814
|
+
},
|
|
24815
|
+
{
|
|
24816
|
+
method: "DELETE",
|
|
24817
|
+
path: `${ROUTE_PREFIX}`,
|
|
24818
|
+
handler: "ActivityLogsController.clearSessions",
|
|
24819
|
+
config: {
|
|
24820
|
+
policies: []
|
|
24821
|
+
}
|
|
24822
|
+
}
|
|
24823
|
+
];
|
|
24678
24824
|
const routes = {
|
|
24679
24825
|
"content-api": {
|
|
24680
24826
|
routes: [...StrapiRoutes]
|
|
@@ -24688,14 +24834,15 @@ const routes = {
|
|
|
24688
24834
|
...StrapiRoutes,
|
|
24689
24835
|
...LocalazyTransferRoutes,
|
|
24690
24836
|
...LocalazyProjectRoutes,
|
|
24691
|
-
...EntryExclusionRoutes
|
|
24837
|
+
...EntryExclusionRoutes,
|
|
24838
|
+
...ActivityLogsRoutes
|
|
24692
24839
|
]
|
|
24693
24840
|
},
|
|
24694
24841
|
LocalazyPublicTransferRoutes: {
|
|
24695
24842
|
routes: [...LocalazyPublicTransferRoutes]
|
|
24696
24843
|
}
|
|
24697
24844
|
};
|
|
24698
|
-
const KEY$
|
|
24845
|
+
const KEY$4 = "identity";
|
|
24699
24846
|
const emptyIdentity = {
|
|
24700
24847
|
accessToken: "",
|
|
24701
24848
|
project: {
|
|
@@ -24719,13 +24866,13 @@ const getStrapiStore = (strapi2) => strapi2.store({
|
|
|
24719
24866
|
const LocalazyUserService = ({ strapi: strapi2 }) => ({
|
|
24720
24867
|
async getUser() {
|
|
24721
24868
|
const pluginStore = getStrapiStore(strapi2);
|
|
24722
|
-
const user = await pluginStore.get({ key: KEY$
|
|
24869
|
+
const user = await pluginStore.get({ key: KEY$4 });
|
|
24723
24870
|
return user || emptyIdentity;
|
|
24724
24871
|
},
|
|
24725
24872
|
async updateUser(identity2) {
|
|
24726
24873
|
const pluginStore = getStrapiStore(strapi2);
|
|
24727
24874
|
await pluginStore.set({
|
|
24728
|
-
key: KEY$
|
|
24875
|
+
key: KEY$4,
|
|
24729
24876
|
value: identity2
|
|
24730
24877
|
});
|
|
24731
24878
|
return identity2;
|
|
@@ -24844,6 +24991,25 @@ const LocalazyPubAPIService = ({ strapi: strapi2 }) => ({
|
|
|
24844
24991
|
return null;
|
|
24845
24992
|
}
|
|
24846
24993
|
},
|
|
24994
|
+
async listWebhooks(projectId) {
|
|
24995
|
+
try {
|
|
24996
|
+
const LocalazyApi = await LocalazyApiClientFactory();
|
|
24997
|
+
const result = await LocalazyApi.webhooks.list({ project: projectId });
|
|
24998
|
+
return result;
|
|
24999
|
+
} catch (e2) {
|
|
25000
|
+
strapi2.log.error(e2);
|
|
25001
|
+
return [];
|
|
25002
|
+
}
|
|
25003
|
+
},
|
|
25004
|
+
async updateWebhooks(projectId, items) {
|
|
25005
|
+
try {
|
|
25006
|
+
const LocalazyApi = await LocalazyApiClientFactory();
|
|
25007
|
+
await LocalazyApi.webhooks.update({ project: projectId, items });
|
|
25008
|
+
} catch (e2) {
|
|
25009
|
+
strapi2.log.error(e2);
|
|
25010
|
+
throw e2;
|
|
25011
|
+
}
|
|
25012
|
+
},
|
|
24847
25013
|
async getWebhooksSecret(projectId) {
|
|
24848
25014
|
try {
|
|
24849
25015
|
const LocalazyApi = await LocalazyApiClientFactory();
|
|
@@ -24855,23 +25021,23 @@ const LocalazyPubAPIService = ({ strapi: strapi2 }) => ({
|
|
|
24855
25021
|
}
|
|
24856
25022
|
}
|
|
24857
25023
|
});
|
|
24858
|
-
const KEY$
|
|
25024
|
+
const KEY$3 = "content-transfer-setup";
|
|
24859
25025
|
const emptyContentTransferSetup = {
|
|
24860
25026
|
has_setup: false,
|
|
24861
25027
|
setup: []
|
|
24862
25028
|
};
|
|
24863
|
-
const KEY$
|
|
25029
|
+
const KEY$2 = "plugin-settings";
|
|
24864
25030
|
const emptyPluginSettings = {
|
|
24865
25031
|
defaultRoute: null
|
|
24866
25032
|
};
|
|
24867
|
-
const KEY = "sync-cursor";
|
|
25033
|
+
const KEY$1 = "sync-cursor";
|
|
24868
25034
|
const emptySyncCursor = {
|
|
24869
25035
|
processedKeys: {}
|
|
24870
25036
|
};
|
|
24871
25037
|
const PluginSettingsService = ({ strapi: strapi2 }) => ({
|
|
24872
25038
|
async getContentTransferSetup() {
|
|
24873
25039
|
const pluginStore = getStrapiStore(strapi2);
|
|
24874
|
-
const setup2 = await pluginStore.get({ key: KEY$
|
|
25040
|
+
const setup2 = await pluginStore.get({ key: KEY$3 });
|
|
24875
25041
|
return setup2 || emptyContentTransferSetup;
|
|
24876
25042
|
},
|
|
24877
25043
|
async updateContentTransferSetup(setup2) {
|
|
@@ -24881,14 +25047,14 @@ const PluginSettingsService = ({ strapi: strapi2 }) => ({
|
|
|
24881
25047
|
};
|
|
24882
25048
|
const pluginStore = getStrapiStore(strapi2);
|
|
24883
25049
|
await pluginStore.set({
|
|
24884
|
-
key: KEY$
|
|
25050
|
+
key: KEY$3,
|
|
24885
25051
|
value: newSetup
|
|
24886
25052
|
});
|
|
24887
25053
|
return newSetup;
|
|
24888
25054
|
},
|
|
24889
25055
|
async getPluginSettings() {
|
|
24890
25056
|
const pluginStore = getStrapiStore(strapi2);
|
|
24891
|
-
const settings = await pluginStore.get({ key: KEY$
|
|
25057
|
+
const settings = await pluginStore.get({ key: KEY$2 });
|
|
24892
25058
|
return settings || emptyPluginSettings;
|
|
24893
25059
|
},
|
|
24894
25060
|
async updatePluginSettings(settings) {
|
|
@@ -24899,20 +25065,20 @@ const PluginSettingsService = ({ strapi: strapi2 }) => ({
|
|
|
24899
25065
|
};
|
|
24900
25066
|
const pluginStore = getStrapiStore(strapi2);
|
|
24901
25067
|
await pluginStore.set({
|
|
24902
|
-
key: KEY$
|
|
25068
|
+
key: KEY$2,
|
|
24903
25069
|
value: newSettings
|
|
24904
25070
|
});
|
|
24905
25071
|
return newSettings;
|
|
24906
25072
|
},
|
|
24907
25073
|
async getSyncCursor() {
|
|
24908
25074
|
const pluginStore = getStrapiStore(strapi2);
|
|
24909
|
-
const cursor = await pluginStore.get({ key: KEY });
|
|
25075
|
+
const cursor = await pluginStore.get({ key: KEY$1 });
|
|
24910
25076
|
return cursor || emptySyncCursor;
|
|
24911
25077
|
},
|
|
24912
25078
|
async updateSyncCursor(cursor) {
|
|
24913
25079
|
const pluginStore = getStrapiStore(strapi2);
|
|
24914
25080
|
await pluginStore.set({
|
|
24915
|
-
key: KEY,
|
|
25081
|
+
key: KEY$1,
|
|
24916
25082
|
value: cursor
|
|
24917
25083
|
});
|
|
24918
25084
|
return cursor;
|
|
@@ -24924,6 +25090,9 @@ const LocalazyTransferUploadService = ({ strapi: strapi2 }) => ({
|
|
|
24924
25090
|
await notificationService.emit(EventType.UPLOAD, {
|
|
24925
25091
|
message: "Upload started"
|
|
24926
25092
|
});
|
|
25093
|
+
const activityLogsService = getActivityLogsService();
|
|
25094
|
+
const sessionId = await activityLogsService.startSession("upload", "Strapi User");
|
|
25095
|
+
await activityLogsService.addEntry(sessionId, "Upload started");
|
|
24927
25096
|
let success = true;
|
|
24928
25097
|
const StrapiService2 = getStrapiService();
|
|
24929
25098
|
const StrapiI18nService2 = getStrapiI18nService();
|
|
@@ -24937,6 +25106,8 @@ const LocalazyTransferUploadService = ({ strapi: strapi2 }) => ({
|
|
|
24937
25106
|
success,
|
|
24938
25107
|
message
|
|
24939
25108
|
});
|
|
25109
|
+
await activityLogsService.addEntry(sessionId, message);
|
|
25110
|
+
await activityLogsService.finishSession(sessionId, "failed", message);
|
|
24940
25111
|
strapi2.log.info(message);
|
|
24941
25112
|
return;
|
|
24942
25113
|
}
|
|
@@ -24957,6 +25128,7 @@ const LocalazyTransferUploadService = ({ strapi: strapi2 }) => ({
|
|
|
24957
25128
|
await notificationService.emit(EventType.UPLOAD, {
|
|
24958
25129
|
message: message2
|
|
24959
25130
|
});
|
|
25131
|
+
await activityLogsService.addEntry(sessionId, message2);
|
|
24960
25132
|
strapi2.log.info(message2);
|
|
24961
25133
|
continue;
|
|
24962
25134
|
}
|
|
@@ -24967,6 +25139,7 @@ const LocalazyTransferUploadService = ({ strapi: strapi2 }) => ({
|
|
|
24967
25139
|
await notificationService.emit(EventType.UPLOAD, {
|
|
24968
25140
|
message: message2
|
|
24969
25141
|
});
|
|
25142
|
+
await activityLogsService.addEntry(sessionId, message2);
|
|
24970
25143
|
strapi2.log.warn(message2);
|
|
24971
25144
|
continue;
|
|
24972
25145
|
}
|
|
@@ -24993,6 +25166,7 @@ const LocalazyTransferUploadService = ({ strapi: strapi2 }) => ({
|
|
|
24993
25166
|
await notificationService.emit(EventType.UPLOAD, {
|
|
24994
25167
|
message: message2
|
|
24995
25168
|
});
|
|
25169
|
+
await activityLogsService.addEntry(sessionId, message2);
|
|
24996
25170
|
strapi2.log.info(message2);
|
|
24997
25171
|
continue;
|
|
24998
25172
|
}
|
|
@@ -25000,6 +25174,7 @@ const LocalazyTransferUploadService = ({ strapi: strapi2 }) => ({
|
|
|
25000
25174
|
await notificationService.emit(EventType.UPLOAD, {
|
|
25001
25175
|
message
|
|
25002
25176
|
});
|
|
25177
|
+
await activityLogsService.addEntry(sessionId, message);
|
|
25003
25178
|
strapi2.log.info(message);
|
|
25004
25179
|
entries = omitDeep(entries, ["locale", "createdAt", "updatedAt", "publishedAt"]);
|
|
25005
25180
|
entries.forEach((entry) => {
|
|
@@ -25037,12 +25212,33 @@ const LocalazyTransferUploadService = ({ strapi: strapi2 }) => ({
|
|
|
25037
25212
|
await notificationService.emit(EventType.UPLOAD, {
|
|
25038
25213
|
message: "Uploading collections to Localazy..."
|
|
25039
25214
|
});
|
|
25040
|
-
await
|
|
25215
|
+
await activityLogsService.addEntry(sessionId, "Uploading collections to Localazy...");
|
|
25216
|
+
try {
|
|
25217
|
+
await LocalazyUploadService2.upload(importFile, uploadConfig);
|
|
25218
|
+
} catch (error) {
|
|
25219
|
+
success = false;
|
|
25220
|
+
const errorMessage = `Upload to Localazy failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
25221
|
+
strapi2.log.error(errorMessage);
|
|
25222
|
+
await notificationService.emit(EventType.UPLOAD_FINISHED, {
|
|
25223
|
+
success,
|
|
25224
|
+
message: errorMessage
|
|
25225
|
+
});
|
|
25226
|
+
await activityLogsService.addEntry(sessionId, errorMessage);
|
|
25227
|
+
await activityLogsService.finishSession(sessionId, "failed", errorMessage);
|
|
25228
|
+
console.timeEnd("upload");
|
|
25229
|
+
return;
|
|
25230
|
+
}
|
|
25041
25231
|
strapi2.log.info("Upload finished in");
|
|
25042
25232
|
await notificationService.emit(EventType.UPLOAD_FINISHED, {
|
|
25043
25233
|
success,
|
|
25044
25234
|
message: "Upload finished"
|
|
25045
25235
|
});
|
|
25236
|
+
await activityLogsService.addEntry(sessionId, "Upload finished");
|
|
25237
|
+
await activityLogsService.finishSession(
|
|
25238
|
+
sessionId,
|
|
25239
|
+
success ? "completed" : "failed",
|
|
25240
|
+
success ? "Upload completed successfully" : "Upload finished with errors"
|
|
25241
|
+
);
|
|
25046
25242
|
console.timeEnd("upload");
|
|
25047
25243
|
}
|
|
25048
25244
|
});
|
|
@@ -25461,6 +25657,12 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25461
25657
|
await notificationService.emit(EventType.DOWNLOAD, {
|
|
25462
25658
|
message: `Download started (${syncMode})`
|
|
25463
25659
|
});
|
|
25660
|
+
const activityLogsService = getActivityLogsService();
|
|
25661
|
+
const requestInitiatorHelper = new RequestInitiatorHelper(strapi2);
|
|
25662
|
+
const isWebhook = requestInitiatorHelper.isInitiatedByLocalazyWebhook();
|
|
25663
|
+
const initiatedBy = isWebhook ? "Webhook" : "Strapi User";
|
|
25664
|
+
const sessionId = await activityLogsService.startSession(isWebhook ? "webhook" : "download", initiatedBy);
|
|
25665
|
+
await activityLogsService.addEntry(sessionId, `Download started (${syncMode})`);
|
|
25464
25666
|
let success = true;
|
|
25465
25667
|
const StrapiService2 = getStrapiService();
|
|
25466
25668
|
const StrapiI18nService2 = getStrapiI18nService();
|
|
@@ -25479,6 +25681,8 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25479
25681
|
success,
|
|
25480
25682
|
message
|
|
25481
25683
|
});
|
|
25684
|
+
await activityLogsService.addEntry(sessionId, message);
|
|
25685
|
+
await activityLogsService.finishSession(sessionId, "failed", message);
|
|
25482
25686
|
return;
|
|
25483
25687
|
}
|
|
25484
25688
|
const project = await LocalazyPubAPIService2.getProject(user.project.id, false, true);
|
|
@@ -25490,6 +25694,8 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25490
25694
|
success,
|
|
25491
25695
|
message
|
|
25492
25696
|
});
|
|
25697
|
+
await activityLogsService.addEntry(sessionId, message);
|
|
25698
|
+
await activityLogsService.finishSession(sessionId, "failed", message);
|
|
25493
25699
|
return;
|
|
25494
25700
|
}
|
|
25495
25701
|
const projectLanguages = project.languages;
|
|
@@ -25503,6 +25709,8 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25503
25709
|
success,
|
|
25504
25710
|
message
|
|
25505
25711
|
});
|
|
25712
|
+
await activityLogsService.addEntry(sessionId, message);
|
|
25713
|
+
await activityLogsService.finishSession(sessionId, "failed", message);
|
|
25506
25714
|
return;
|
|
25507
25715
|
}
|
|
25508
25716
|
const projectSourceLanguageCode = sourceLanguage.code;
|
|
@@ -25516,6 +25724,8 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25516
25724
|
success,
|
|
25517
25725
|
message
|
|
25518
25726
|
});
|
|
25727
|
+
await activityLogsService.addEntry(sessionId, message);
|
|
25728
|
+
await activityLogsService.finishSession(sessionId, "completed", message);
|
|
25519
25729
|
return;
|
|
25520
25730
|
}
|
|
25521
25731
|
let languagesCodes = projectLanguagesWithoutSourceLanguage.map((language3) => language3.code);
|
|
@@ -25534,6 +25744,7 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25534
25744
|
await notificationService.emit(EventType.DOWNLOAD, {
|
|
25535
25745
|
message: `Created locale ${newLocale.code}`
|
|
25536
25746
|
});
|
|
25747
|
+
await activityLogsService.addEntry(sessionId, `Created locale ${newLocale.code}`);
|
|
25537
25748
|
} catch (e2) {
|
|
25538
25749
|
strapi2.log.error(e2.message);
|
|
25539
25750
|
if (e2.name === "ValidationError") {
|
|
@@ -25541,10 +25752,12 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25541
25752
|
await notificationService.emit(EventType.DOWNLOAD, {
|
|
25542
25753
|
message: `Language ${isoLocalazy} is not supported by Strapi`
|
|
25543
25754
|
});
|
|
25755
|
+
await activityLogsService.addEntry(sessionId, `Language ${isoLocalazy} is not supported by Strapi`);
|
|
25544
25756
|
} else {
|
|
25545
25757
|
await notificationService.emit(EventType.DOWNLOAD, {
|
|
25546
25758
|
message: e2.message
|
|
25547
25759
|
});
|
|
25760
|
+
await activityLogsService.addEntry(sessionId, e2.message);
|
|
25548
25761
|
}
|
|
25549
25762
|
}
|
|
25550
25763
|
}
|
|
@@ -25569,6 +25782,7 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25569
25782
|
await notificationService.emit(EventType.DOWNLOAD, {
|
|
25570
25783
|
message: `No keys found for language ${isoLocalazy}`
|
|
25571
25784
|
});
|
|
25785
|
+
await activityLogsService.addEntry(sessionId, `No keys found for language ${isoLocalazy}`);
|
|
25572
25786
|
} else {
|
|
25573
25787
|
const newKeys = langKeys.filter((k2) => {
|
|
25574
25788
|
const storedEvent = langProcessedKeys[k2.id];
|
|
@@ -25577,6 +25791,10 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25577
25791
|
await notificationService.emit(EventType.DOWNLOAD, {
|
|
25578
25792
|
message: `${syncMode}: ${newKeys.length} changed / ${langKeys.length} total keys for language ${isoLocalazy}`
|
|
25579
25793
|
});
|
|
25794
|
+
await activityLogsService.addEntry(
|
|
25795
|
+
sessionId,
|
|
25796
|
+
`${syncMode}: ${newKeys.length} changed / ${langKeys.length} total keys for language ${isoLocalazy}`
|
|
25797
|
+
);
|
|
25580
25798
|
}
|
|
25581
25799
|
localazyContent[isoLocalazy] = langKeys;
|
|
25582
25800
|
}
|
|
@@ -25729,6 +25947,7 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25729
25947
|
await notificationService.emit(EventType.DOWNLOAD, {
|
|
25730
25948
|
message
|
|
25731
25949
|
});
|
|
25950
|
+
await activityLogsService.addEntry(sessionId, message);
|
|
25732
25951
|
await markKeysProcessed(sourceKeys);
|
|
25733
25952
|
} catch (e2) {
|
|
25734
25953
|
success = false;
|
|
@@ -25741,6 +25960,10 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25741
25960
|
localazy: localazySearchUrl
|
|
25742
25961
|
}
|
|
25743
25962
|
});
|
|
25963
|
+
await activityLogsService.addEntry(
|
|
25964
|
+
sessionId,
|
|
25965
|
+
`Failed to create ${uid} [${documentId}] in ${isoStrapi}: ${e2.message}`
|
|
25966
|
+
);
|
|
25744
25967
|
}
|
|
25745
25968
|
} else {
|
|
25746
25969
|
try {
|
|
@@ -25758,6 +25981,7 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25758
25981
|
await notificationService.emit(EventType.DOWNLOAD, {
|
|
25759
25982
|
message
|
|
25760
25983
|
});
|
|
25984
|
+
await activityLogsService.addEntry(sessionId, message);
|
|
25761
25985
|
await markKeysProcessed(sourceKeys);
|
|
25762
25986
|
} catch (e2) {
|
|
25763
25987
|
success = false;
|
|
@@ -25770,6 +25994,10 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25770
25994
|
localazy: localazySearchUrl
|
|
25771
25995
|
}
|
|
25772
25996
|
});
|
|
25997
|
+
await activityLogsService.addEntry(
|
|
25998
|
+
sessionId,
|
|
25999
|
+
`Failed to update ${uid} [${documentId}] in ${isoStrapi}: ${e2.message}`
|
|
26000
|
+
);
|
|
25773
26001
|
}
|
|
25774
26002
|
}
|
|
25775
26003
|
} catch (e2) {
|
|
@@ -25778,6 +26006,10 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25778
26006
|
await notificationService.emit(EventType.DOWNLOAD, {
|
|
25779
26007
|
message: `Error processing ${uid} [${documentId}] in ${isoStrapi}: ${e2.message}`
|
|
25780
26008
|
});
|
|
26009
|
+
await activityLogsService.addEntry(
|
|
26010
|
+
sessionId,
|
|
26011
|
+
`Error processing ${uid} [${documentId}] in ${isoStrapi}: ${e2.message}`
|
|
26012
|
+
);
|
|
25781
26013
|
}
|
|
25782
26014
|
}
|
|
25783
26015
|
}
|
|
@@ -25793,6 +26025,13 @@ const LocalazyTransferDownloadService = ({ strapi: strapi2 }) => ({
|
|
|
25793
26025
|
success,
|
|
25794
26026
|
message: "Download finished"
|
|
25795
26027
|
});
|
|
26028
|
+
const finishMessage = `Download finished. Tracked ${totalProcessedKeys} processed keys across ${Object.keys(processedKeys).length} languages.`;
|
|
26029
|
+
await activityLogsService.addEntry(sessionId, finishMessage);
|
|
26030
|
+
await activityLogsService.finishSession(
|
|
26031
|
+
sessionId,
|
|
26032
|
+
success ? "completed" : "failed",
|
|
26033
|
+
success ? "Download completed successfully" : "Download finished with errors"
|
|
26034
|
+
);
|
|
25796
26035
|
console.timeEnd("download");
|
|
25797
26036
|
}
|
|
25798
26037
|
});
|
|
@@ -26516,6 +26755,112 @@ const EntryExclusionService = ({ strapi: strapi2 }) => ({
|
|
|
26516
26755
|
return Object.values(exclusions).filter((exclusion) => exclusion.contentType === contentType && exclusion.excludeFromTranslation).map((exclusion) => exclusion.documentId);
|
|
26517
26756
|
}
|
|
26518
26757
|
});
|
|
26758
|
+
const KEY = "activity-logs";
|
|
26759
|
+
const emptyActivityLogs = {
|
|
26760
|
+
sessions: []
|
|
26761
|
+
};
|
|
26762
|
+
const ONE_YEAR_MS = 365 * 24 * 60 * 60 * 1e3;
|
|
26763
|
+
let writeLock = Promise.resolve();
|
|
26764
|
+
const withLock = async (fn) => {
|
|
26765
|
+
let release;
|
|
26766
|
+
const next = new Promise((resolve) => {
|
|
26767
|
+
release = resolve;
|
|
26768
|
+
});
|
|
26769
|
+
const prev2 = writeLock;
|
|
26770
|
+
writeLock = next;
|
|
26771
|
+
await prev2;
|
|
26772
|
+
try {
|
|
26773
|
+
return await fn();
|
|
26774
|
+
} finally {
|
|
26775
|
+
release();
|
|
26776
|
+
}
|
|
26777
|
+
};
|
|
26778
|
+
const ActivityLogsService = ({ strapi: strapi2 }) => ({
|
|
26779
|
+
async getActivityLogs() {
|
|
26780
|
+
const pluginStore = getStrapiStore(strapi2);
|
|
26781
|
+
const logs = await pluginStore.get({ key: KEY });
|
|
26782
|
+
return logs || { sessions: [] };
|
|
26783
|
+
},
|
|
26784
|
+
async saveActivityLogs(logs) {
|
|
26785
|
+
const pluginStore = getStrapiStore(strapi2);
|
|
26786
|
+
await pluginStore.set({
|
|
26787
|
+
key: KEY,
|
|
26788
|
+
value: logs
|
|
26789
|
+
});
|
|
26790
|
+
},
|
|
26791
|
+
async startSession(eventType, initiatedBy) {
|
|
26792
|
+
return withLock(async () => {
|
|
26793
|
+
const logs = await this.getActivityLogs();
|
|
26794
|
+
const sessionId = generateRandomId();
|
|
26795
|
+
const session = {
|
|
26796
|
+
id: sessionId,
|
|
26797
|
+
eventType,
|
|
26798
|
+
status: "in-progress",
|
|
26799
|
+
startedAt: Date.now(),
|
|
26800
|
+
initiatedBy,
|
|
26801
|
+
summary: "",
|
|
26802
|
+
entries: []
|
|
26803
|
+
};
|
|
26804
|
+
logs.sessions.unshift(session);
|
|
26805
|
+
const cutoff = Date.now() - ONE_YEAR_MS;
|
|
26806
|
+
logs.sessions = logs.sessions.filter((s2) => s2.startedAt >= cutoff);
|
|
26807
|
+
await this.saveActivityLogs(logs);
|
|
26808
|
+
return sessionId;
|
|
26809
|
+
});
|
|
26810
|
+
},
|
|
26811
|
+
async addEntry(sessionId, message, data) {
|
|
26812
|
+
return withLock(async () => {
|
|
26813
|
+
const logs = await this.getActivityLogs();
|
|
26814
|
+
const session = logs.sessions.find((s2) => s2.id === sessionId);
|
|
26815
|
+
if (!session) {
|
|
26816
|
+
return;
|
|
26817
|
+
}
|
|
26818
|
+
const entry = {
|
|
26819
|
+
message,
|
|
26820
|
+
timestamp: Date.now(),
|
|
26821
|
+
data
|
|
26822
|
+
};
|
|
26823
|
+
session.entries.push(entry);
|
|
26824
|
+
await this.saveActivityLogs(logs);
|
|
26825
|
+
});
|
|
26826
|
+
},
|
|
26827
|
+
async finishSession(sessionId, status, summary) {
|
|
26828
|
+
return withLock(async () => {
|
|
26829
|
+
const logs = await this.getActivityLogs();
|
|
26830
|
+
const session = logs.sessions.find((s2) => s2.id === sessionId);
|
|
26831
|
+
if (!session) {
|
|
26832
|
+
return;
|
|
26833
|
+
}
|
|
26834
|
+
session.status = status;
|
|
26835
|
+
session.finishedAt = Date.now();
|
|
26836
|
+
session.summary = summary;
|
|
26837
|
+
await this.saveActivityLogs(logs);
|
|
26838
|
+
});
|
|
26839
|
+
},
|
|
26840
|
+
async getSessions(eventType) {
|
|
26841
|
+
const logs = await this.getActivityLogs();
|
|
26842
|
+
let { sessions } = logs;
|
|
26843
|
+
if (eventType) {
|
|
26844
|
+
sessions = sessions.filter((s2) => s2.eventType === eventType);
|
|
26845
|
+
}
|
|
26846
|
+
return sessions.map((s2) => ({
|
|
26847
|
+
...s2,
|
|
26848
|
+
entries: []
|
|
26849
|
+
}));
|
|
26850
|
+
},
|
|
26851
|
+
async getAllSessionsWithEntries() {
|
|
26852
|
+
const logs = await this.getActivityLogs();
|
|
26853
|
+
return logs.sessions;
|
|
26854
|
+
},
|
|
26855
|
+
async getSession(sessionId) {
|
|
26856
|
+
const logs = await this.getActivityLogs();
|
|
26857
|
+
const session = logs.sessions.find((s2) => s2.id === sessionId);
|
|
26858
|
+
return session || null;
|
|
26859
|
+
},
|
|
26860
|
+
async clearSessions() {
|
|
26861
|
+
await this.saveActivityLogs(emptyActivityLogs);
|
|
26862
|
+
}
|
|
26863
|
+
});
|
|
26519
26864
|
const services = {
|
|
26520
26865
|
LocalazyUserService,
|
|
26521
26866
|
StrapiService,
|
|
@@ -26526,7 +26871,8 @@ const services = {
|
|
|
26526
26871
|
StrapiI18nService,
|
|
26527
26872
|
LocalazyUploadService,
|
|
26528
26873
|
StrapiLocalazyI18nService,
|
|
26529
|
-
EntryExclusionService
|
|
26874
|
+
EntryExclusionService,
|
|
26875
|
+
ActivityLogsService
|
|
26530
26876
|
};
|
|
26531
26877
|
const index = {
|
|
26532
26878
|
register,
|