@ozguraltan/strapi-content-input 1.0.12 → 1.0.21
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/README.md +156 -49
- package/dist/admin/{AnalyticsHubPage-DNREITPq.js → AnalyticsHubPage-0p0Mx4AU.js} +60 -9
- package/dist/admin/{AnalyticsHubPage-Dj4roAe0.mjs → AnalyticsHubPage-DsrcGI_Y.mjs} +60 -9
- package/dist/admin/{ContentInputField-2hk9xG8p.js → ContentInputField-7rWLSx_7.js} +11995 -1174
- package/dist/admin/{ContentInputField-Ko-r12jl.mjs → ContentInputField-CHXrzvE-.mjs} +11813 -1010
- package/dist/admin/{SurveyWidgetEditor-B1S83aBE.mjs → SurveyWidgetEditor-BVN6X_3G.mjs} +3944 -1089
- package/dist/admin/{SurveyWidgetEditor-B3F4DE5r.js → SurveyWidgetEditor-BmgYQaQS.js} +3924 -1068
- package/dist/admin/{en-bneQpRJa.js → en-BZg845za.js} +2 -2
- package/dist/admin/{en-DnLdDKyq.mjs → en-C9LN2PJY.mjs} +2 -2
- package/dist/admin/{index-B4FpXxnK.js → index-CZAwXCFH.js} +16 -6
- package/dist/admin/{index-gn-4eO6g.mjs → index-hFIuYqu5.mjs} +16 -6
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/color-codes/ColorCodesManager.d.ts +10 -0
- package/dist/admin/src/components/common/CIAspectRatioField.d.ts +35 -0
- package/dist/admin/src/components/common/CIColorField.d.ts +13 -0
- package/dist/admin/src/components/widgets/CustomCardWidgetEditor.d.ts +83 -0
- package/dist/admin/src/components/widgets/DataTableWidgetEditor.d.ts +65 -0
- package/dist/admin/src/components/widgets/EntityCardWidgetEditor.d.ts +10 -0
- package/dist/admin/src/components/widgets/HeroSliderStage.d.ts +153 -0
- package/dist/admin/src/components/widgets/HeroSliderWidgetEditor.d.ts +21 -0
- package/dist/admin/src/components/widgets/StrapiMediaPicker.d.ts +2 -0
- package/dist/admin/src/components/widgets/SurveyWidgetEditor.d.ts +1 -1
- package/dist/admin/src/core/colorUtils.d.ts +30 -0
- package/dist/admin/src/core/sampleData.d.ts +2 -1
- package/dist/admin/src/core/useColorCodes.d.ts +43 -0
- package/dist/admin/{tr-00QqO0E7.mjs → tr-MtQFY92V.mjs} +2 -2
- package/dist/admin/{tr-O0nhB9er.js → tr-ZEmzAvKR.js} +2 -2
- package/dist/server/index.js +990 -106
- package/dist/server/index.mjs +990 -106
- package/dist/server/src/content-types/ci-color-palette/schema.json.d.ts +52 -0
- package/dist/server/src/content-types/index.d.ts +50 -0
- package/dist/server/src/controllers/ci-color.d.ts +14 -0
- package/dist/server/src/controllers/index.d.ts +12 -0
- package/dist/server/src/index.d.ts +119 -0
- package/dist/server/src/services/ci-color.d.ts +127 -0
- package/dist/server/src/services/index.d.ts +57 -0
- package/dist/server/src/utils/mailer.d.ts +1 -0
- package/package.json +3 -2
package/dist/server/index.js
CHANGED
|
@@ -20,9 +20,25 @@ const register = ({ strapi }) => {
|
|
|
20
20
|
isResizable: false
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
+
if (strapi?.server?.use) {
|
|
24
|
+
strapi.server.use(async (ctx, next) => {
|
|
25
|
+
await next();
|
|
26
|
+
const csp = ctx?.response?.get?.("Content-Security-Policy");
|
|
27
|
+
if (typeof csp === "string" && csp.includes("frame-src")) {
|
|
28
|
+
const updated = csp.replace(/frame-src\s+([^;]+)/i, (match, sources) => {
|
|
29
|
+
if (sources.includes("https:") || sources.includes("*")) return match;
|
|
30
|
+
return `frame-src ${sources.trim()} https: http: data: blob:`;
|
|
31
|
+
});
|
|
32
|
+
if (updated !== csp) {
|
|
33
|
+
ctx.set("Content-Security-Policy", updated);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
23
38
|
};
|
|
24
39
|
const bootstrap = async ({ strapi }) => {
|
|
25
40
|
try {
|
|
41
|
+
await strapi.plugin("content-input").service("ci-color").ensureSeeded();
|
|
26
42
|
await strapi.plugin("content-input").service("ci-form").ensureSeeded();
|
|
27
43
|
await strapi.plugin("content-input").service("ci-survey").ensureSeeded(false);
|
|
28
44
|
} catch (err) {
|
|
@@ -38,13 +54,27 @@ const config = {
|
|
|
38
54
|
validator() {
|
|
39
55
|
}
|
|
40
56
|
};
|
|
57
|
+
const kind$6 = "collectionType";
|
|
58
|
+
const collectionName$6 = "ci_templates";
|
|
59
|
+
const info$6 = { "singularName": "ci-template", "pluralName": "ci-templates", "displayName": "ContentInput Template", "description": "Saved visual editor row/section templates" };
|
|
60
|
+
const options$6 = { "draftAndPublish": false };
|
|
61
|
+
const pluginOptions$6 = { "content-manager": { "visible": false }, "content-type-builder": { "visible": false } };
|
|
62
|
+
const attributes$6 = { "name": { "type": "string", "required": true }, "category": { "type": "string", "default": "custom" }, "structure": { "type": "json", "required": true }, "thumbnail": { "type": "string", "default": "" } };
|
|
63
|
+
const templateSchema = {
|
|
64
|
+
kind: kind$6,
|
|
65
|
+
collectionName: collectionName$6,
|
|
66
|
+
info: info$6,
|
|
67
|
+
options: options$6,
|
|
68
|
+
pluginOptions: pluginOptions$6,
|
|
69
|
+
attributes: attributes$6
|
|
70
|
+
};
|
|
41
71
|
const kind$5 = "collectionType";
|
|
42
|
-
const collectionName$5 = "
|
|
43
|
-
const info$5 = { "singularName": "ci-
|
|
72
|
+
const collectionName$5 = "ci_menus";
|
|
73
|
+
const info$5 = { "singularName": "ci-menu", "pluralName": "ci-menus", "displayName": "ContentInput Menu", "description": "Reusable nested menus (horizontal & vertical) for ContentInput" };
|
|
44
74
|
const options$5 = { "draftAndPublish": false };
|
|
45
75
|
const pluginOptions$5 = { "content-manager": { "visible": false }, "content-type-builder": { "visible": false } };
|
|
46
|
-
const attributes$5 = { "name": { "type": "string", "required": true }, "
|
|
47
|
-
const
|
|
76
|
+
const attributes$5 = { "name": { "type": "string", "required": true }, "slug": { "type": "string", "required": true }, "mode": { "type": "string", "default": "horizontal" }, "items": { "type": "json", "required": true }, "options": { "type": "json" } };
|
|
77
|
+
const menuSchema = {
|
|
48
78
|
kind: kind$5,
|
|
49
79
|
collectionName: collectionName$5,
|
|
50
80
|
info: info$5,
|
|
@@ -53,12 +83,12 @@ const templateSchema = {
|
|
|
53
83
|
attributes: attributes$5
|
|
54
84
|
};
|
|
55
85
|
const kind$4 = "collectionType";
|
|
56
|
-
const collectionName$4 = "
|
|
57
|
-
const info$4 = { "singularName": "ci-
|
|
86
|
+
const collectionName$4 = "ci_forms";
|
|
87
|
+
const info$4 = { "singularName": "ci-form", "pluralName": "ci-forms", "displayName": "ContentInput Dynamic Form", "description": "Reusable cms-core style dynamic forms with responsive grid layout, validation rules, reCAPTCHA and mail delivery settings" };
|
|
58
88
|
const options$4 = { "draftAndPublish": false };
|
|
59
|
-
const pluginOptions$4 = { "content-manager": { "visible":
|
|
60
|
-
const attributes$4 = { "
|
|
61
|
-
const
|
|
89
|
+
const pluginOptions$4 = { "content-manager": { "visible": true }, "content-type-builder": { "visible": false } };
|
|
90
|
+
const attributes$4 = { "title": { "type": "string", "required": true }, "slug": { "type": "string", "required": true }, "to": { "type": "string" }, "subject": { "type": "string" }, "buttonLabel": { "type": "json" }, "successMessage": { "type": "json" }, "redirect": { "type": "string" }, "hideLabels": { "type": "boolean", "default": false }, "useRecaptcha": { "type": "boolean", "default": true }, "recaptchaSiteKey": { "type": "string" }, "recaptchaSecretKey": { "type": "string", "private": true }, "mailConfig": { "type": "json", "private": true }, "fields": { "type": "json", "required": true }, "form": { "type": "json", "required": true } };
|
|
91
|
+
const formSchema = {
|
|
62
92
|
kind: kind$4,
|
|
63
93
|
collectionName: collectionName$4,
|
|
64
94
|
info: info$4,
|
|
@@ -67,12 +97,12 @@ const menuSchema = {
|
|
|
67
97
|
attributes: attributes$4
|
|
68
98
|
};
|
|
69
99
|
const kind$3 = "collectionType";
|
|
70
|
-
const collectionName$3 = "
|
|
71
|
-
const info$3 = { "singularName": "ci-form", "pluralName": "ci-
|
|
100
|
+
const collectionName$3 = "ci_form_submissions";
|
|
101
|
+
const info$3 = { "singularName": "ci-form-submission", "pluralName": "ci-form-submissions", "displayName": "ContentInput Form Submission", "description": "Submitted entries from ContentInput dynamic forms" };
|
|
72
102
|
const options$3 = { "draftAndPublish": false };
|
|
73
103
|
const pluginOptions$3 = { "content-manager": { "visible": true }, "content-type-builder": { "visible": false } };
|
|
74
|
-
const attributes$3 = { "
|
|
75
|
-
const
|
|
104
|
+
const attributes$3 = { "formId": { "type": "string", "required": true }, "formSlug": { "type": "string" }, "formTitle": { "type": "string" }, "data": { "type": "json", "required": true }, "ip": { "type": "string" }, "userAgent": { "type": "string" }, "mailSent": { "type": "boolean", "default": false }, "mailInfo": { "type": "json" } };
|
|
105
|
+
const formSubmissionSchema = {
|
|
76
106
|
kind: kind$3,
|
|
77
107
|
collectionName: collectionName$3,
|
|
78
108
|
info: info$3,
|
|
@@ -81,12 +111,12 @@ const formSchema = {
|
|
|
81
111
|
attributes: attributes$3
|
|
82
112
|
};
|
|
83
113
|
const kind$2 = "collectionType";
|
|
84
|
-
const collectionName$2 = "
|
|
85
|
-
const info$2 = { "singularName": "ci-
|
|
114
|
+
const collectionName$2 = "ci_surveys";
|
|
115
|
+
const info$2 = { "singularName": "ci-survey", "pluralName": "ci-surveys", "displayName": "ContentInput Survey", "description": "Enterprise surveys, multi-step questionnaires, and live polls with i18n, conditional logic, and analytics" };
|
|
86
116
|
const options$2 = { "draftAndPublish": false };
|
|
87
117
|
const pluginOptions$2 = { "content-manager": { "visible": true }, "content-type-builder": { "visible": false } };
|
|
88
|
-
const attributes$2 = { "
|
|
89
|
-
const
|
|
118
|
+
const attributes$2 = { "title": { "type": "string", "required": true }, "titleI18n": { "type": "json" }, "slug": { "type": "string", "required": true }, "description": { "type": "json" }, "status": { "type": "enumeration", "enum": ["draft", "published", "closed"], "default": "published" }, "displayMode": { "type": "enumeration", "enum": ["quick_poll", "single_page", "multi_step"], "default": "single_page" }, "startsAt": { "type": "datetime" }, "endsAt": { "type": "datetime" }, "quotaLimit": { "type": "integer" }, "submissionPolicy": { "type": "enumeration", "enum": ["unlimited", "one_per_voter", "one_per_token"], "default": "one_per_voter" }, "anonymizeIp": { "type": "boolean", "default": true }, "showPublicResults": { "type": "enumeration", "enum": ["never", "after_vote", "always"], "default": "never" }, "allowBackNavigation": { "type": "boolean", "default": true }, "showProgressBar": { "type": "boolean", "default": true }, "useRecaptcha": { "type": "boolean", "default": false }, "recaptchaSiteKey": { "type": "string" }, "recaptchaSecretKey": { "type": "string", "private": true }, "mailConfig": { "type": "json", "private": true }, "steps": { "type": "json" }, "questions": { "type": "json", "required": true }, "settings": { "type": "json" }, "version": { "type": "integer", "default": 1 } };
|
|
119
|
+
const surveySchema = {
|
|
90
120
|
kind: kind$2,
|
|
91
121
|
collectionName: collectionName$2,
|
|
92
122
|
info: info$2,
|
|
@@ -95,12 +125,12 @@ const formSubmissionSchema = {
|
|
|
95
125
|
attributes: attributes$2
|
|
96
126
|
};
|
|
97
127
|
const kind$1 = "collectionType";
|
|
98
|
-
const collectionName$1 = "
|
|
99
|
-
const info$1 = { "singularName": "ci-survey", "pluralName": "ci-
|
|
128
|
+
const collectionName$1 = "ci_survey_responses";
|
|
129
|
+
const info$1 = { "singularName": "ci-survey-response", "pluralName": "ci-survey-responses", "displayName": "ContentInput Survey Response", "description": "Recorded participant responses and telemetry for ContentInput surveys and polls" };
|
|
100
130
|
const options$1 = { "draftAndPublish": false };
|
|
101
131
|
const pluginOptions$1 = { "content-manager": { "visible": true }, "content-type-builder": { "visible": false } };
|
|
102
|
-
const attributes$1 = { "
|
|
103
|
-
const
|
|
132
|
+
const attributes$1 = { "surveyId": { "type": "string", "required": true }, "surveySlug": { "type": "string", "required": true }, "surveyTitle": { "type": "string" }, "surveyVersion": { "type": "integer", "default": 1 }, "answers": { "type": "json", "required": true }, "otherTexts": { "type": "json" }, "score": { "type": "float" }, "npsValue": { "type": "integer" }, "npsCategory": { "type": "string" }, "locale": { "type": "string", "default": "tr" }, "durationSeconds": { "type": "integer", "default": 0 }, "voterHash": { "type": "string" }, "respondentToken": { "type": "string" }, "ip": { "type": "string" }, "userAgent": { "type": "string" }, "submittedAt": { "type": "datetime" } };
|
|
133
|
+
const surveyResponseSchema = {
|
|
104
134
|
kind: kind$1,
|
|
105
135
|
collectionName: collectionName$1,
|
|
106
136
|
info: info$1,
|
|
@@ -109,12 +139,12 @@ const surveySchema = {
|
|
|
109
139
|
attributes: attributes$1
|
|
110
140
|
};
|
|
111
141
|
const kind = "collectionType";
|
|
112
|
-
const collectionName = "
|
|
113
|
-
const info = { "singularName": "ci-
|
|
142
|
+
const collectionName = "ci_color_palettes";
|
|
143
|
+
const info = { "singularName": "ci-color-palette", "pluralName": "ci-color-palettes", "displayName": "ContentInput Color Palette", "description": "Theme color codes (HEX & RGB/RGBA semantic tokens + custom brand color tokens)" };
|
|
114
144
|
const options = { "draftAndPublish": false };
|
|
115
|
-
const pluginOptions = { "content-manager": { "visible":
|
|
116
|
-
const attributes = { "
|
|
117
|
-
const
|
|
145
|
+
const pluginOptions = { "content-manager": { "visible": false }, "content-type-builder": { "visible": false } };
|
|
146
|
+
const attributes = { "name": { "type": "string", "required": true }, "slug": { "type": "string", "required": true, "unique": true }, "description": { "type": "string", "default": "" }, "isActive": { "type": "boolean", "default": false }, "semanticTokens": { "type": "json", "required": true }, "customTokens": { "type": "json", "default": [] } };
|
|
147
|
+
const colorPaletteSchema = {
|
|
118
148
|
kind,
|
|
119
149
|
collectionName,
|
|
120
150
|
info,
|
|
@@ -140,6 +170,9 @@ const contentTypes = {
|
|
|
140
170
|
},
|
|
141
171
|
"ci-survey-response": {
|
|
142
172
|
schema: surveyResponseSchema
|
|
173
|
+
},
|
|
174
|
+
"ci-color-palette": {
|
|
175
|
+
schema: colorPaletteSchema
|
|
143
176
|
}
|
|
144
177
|
};
|
|
145
178
|
const ciTemplateController = ({ strapi }) => ({
|
|
@@ -153,7 +186,11 @@ const ciTemplateController = ({ strapi }) => ({
|
|
|
153
186
|
},
|
|
154
187
|
async save(ctx) {
|
|
155
188
|
try {
|
|
156
|
-
const
|
|
189
|
+
const body = ctx.request.body || {};
|
|
190
|
+
const name = body.name;
|
|
191
|
+
const structure = body.structure ?? body.rows;
|
|
192
|
+
const category = body.category;
|
|
193
|
+
const thumbnail = body.thumbnail;
|
|
157
194
|
if (!name || !structure) {
|
|
158
195
|
return ctx.badRequest("Name and structure are required");
|
|
159
196
|
}
|
|
@@ -760,9 +797,8 @@ const ciFormController = ({ strapi }) => ({
|
|
|
760
797
|
const { id } = ctx.params;
|
|
761
798
|
const rawBody = ctx.request.body || {};
|
|
762
799
|
const payload = rawBody && typeof rawBody.data === "object" && !Array.isArray(rawBody.data) && Object.keys(rawBody).length === 1 ? rawBody.data : rawBody;
|
|
763
|
-
const
|
|
764
|
-
const
|
|
765
|
-
const inferredLocale = (queryLocale || acceptLang || "tr").toLowerCase();
|
|
800
|
+
const queryLocale = String(ctx.query?.locale || payload?._locale || "").trim();
|
|
801
|
+
const inferredLocale = (queryLocale || "en").toLowerCase();
|
|
766
802
|
const ip = String(ctx.request.headers?.["x-forwarded-for"] || "").split(",")[0].trim() || ctx.request.ip || "";
|
|
767
803
|
const userAgent = String(ctx.request.headers?.["user-agent"] || "");
|
|
768
804
|
const result = await strapi.plugin("content-input").service("ci-form").submitForm(id, payload, {
|
|
@@ -870,7 +906,7 @@ const ciSurveyController = ({ strapi }) => ({
|
|
|
870
906
|
const payload = rawBody && typeof rawBody.data === "object" && !Array.isArray(rawBody.data) && Object.keys(rawBody).length === 1 ? rawBody.data : rawBody;
|
|
871
907
|
const acceptLang = String(ctx.request.headers?.["accept-language"] || "").split(",")[0].split(";")[0].trim();
|
|
872
908
|
const queryLocale = String(ctx.query?.locale || "").trim();
|
|
873
|
-
const inferredLocale = (queryLocale || acceptLang || "
|
|
909
|
+
const inferredLocale = (queryLocale || acceptLang || "en").toLowerCase();
|
|
874
910
|
const ip = String(ctx.request.headers?.["x-forwarded-for"] || "").split(",")[0].trim() || ctx.request.ip || "";
|
|
875
911
|
const userAgent = String(ctx.request.headers?.["user-agent"] || "");
|
|
876
912
|
const result = await strapi.plugin("content-input").service("ci-survey").submitSurvey(id, payload, {
|
|
@@ -925,7 +961,7 @@ const ciSurveyController = ({ strapi }) => ({
|
|
|
925
961
|
try {
|
|
926
962
|
const { id } = ctx.params;
|
|
927
963
|
const format = String(ctx.query?.format || "csv").toLowerCase() === "json" ? "json" : "csv";
|
|
928
|
-
const locale = String(ctx.query?.locale || "
|
|
964
|
+
const locale = String(ctx.query?.locale || "en").trim();
|
|
929
965
|
const from = ctx.query?.from ? String(ctx.query.from) : void 0;
|
|
930
966
|
const to = ctx.query?.to ? String(ctx.query.to) : void 0;
|
|
931
967
|
const exported = await strapi.plugin("content-input").service("ci-survey").exportResponses(id, { format, locale, from, to });
|
|
@@ -949,12 +985,112 @@ const ciSurveyController = ({ strapi }) => ({
|
|
|
949
985
|
}
|
|
950
986
|
}
|
|
951
987
|
});
|
|
988
|
+
const ciColorController = ({ strapi }) => ({
|
|
989
|
+
async indexAdmin(ctx) {
|
|
990
|
+
try {
|
|
991
|
+
const res = await strapi.plugin("content-input").service("ci-color").findAll();
|
|
992
|
+
ctx.body = res;
|
|
993
|
+
} catch (err) {
|
|
994
|
+
ctx.throw(500, err);
|
|
995
|
+
}
|
|
996
|
+
},
|
|
997
|
+
async activePublic(ctx) {
|
|
998
|
+
try {
|
|
999
|
+
const slug = ctx.query?.slug ? String(ctx.query.slug) : void 0;
|
|
1000
|
+
const res = await strapi.plugin("content-input").service("ci-color").findActivePublic(slug);
|
|
1001
|
+
ctx.body = res;
|
|
1002
|
+
} catch (err) {
|
|
1003
|
+
ctx.throw(500, err);
|
|
1004
|
+
}
|
|
1005
|
+
},
|
|
1006
|
+
async save(ctx) {
|
|
1007
|
+
try {
|
|
1008
|
+
const body = ctx.request.body || {};
|
|
1009
|
+
const res = await strapi.plugin("content-input").service("ci-color").save(body);
|
|
1010
|
+
ctx.body = res;
|
|
1011
|
+
} catch (err) {
|
|
1012
|
+
ctx.throw(500, err);
|
|
1013
|
+
}
|
|
1014
|
+
},
|
|
1015
|
+
async activate(ctx) {
|
|
1016
|
+
try {
|
|
1017
|
+
const { id } = ctx.params || {};
|
|
1018
|
+
const res = await strapi.plugin("content-input").service("ci-color").activate(id);
|
|
1019
|
+
if (!res) {
|
|
1020
|
+
return ctx.notFound("Color palette not found");
|
|
1021
|
+
}
|
|
1022
|
+
ctx.body = res;
|
|
1023
|
+
} catch (err) {
|
|
1024
|
+
ctx.throw(500, err);
|
|
1025
|
+
}
|
|
1026
|
+
},
|
|
1027
|
+
async quickToken(ctx) {
|
|
1028
|
+
try {
|
|
1029
|
+
const body = ctx.request.body || {};
|
|
1030
|
+
if (!body.value) {
|
|
1031
|
+
return ctx.badRequest("Color value (HEX or RGB/RGBA) is required");
|
|
1032
|
+
}
|
|
1033
|
+
const res = await strapi.plugin("content-input").service("ci-color").upsertQuickCustomToken({
|
|
1034
|
+
key: body.key || body.label || "customColor",
|
|
1035
|
+
label: body.label,
|
|
1036
|
+
labels: body.labels,
|
|
1037
|
+
value: body.value
|
|
1038
|
+
});
|
|
1039
|
+
ctx.body = res;
|
|
1040
|
+
} catch (err) {
|
|
1041
|
+
ctx.throw(500, err);
|
|
1042
|
+
}
|
|
1043
|
+
},
|
|
1044
|
+
async delete(ctx) {
|
|
1045
|
+
try {
|
|
1046
|
+
const { id } = ctx.params || {};
|
|
1047
|
+
const res = await strapi.plugin("content-input").service("ci-color").remove(id);
|
|
1048
|
+
ctx.body = res;
|
|
1049
|
+
} catch (err) {
|
|
1050
|
+
ctx.badRequest(err?.message || "Unable to delete palette");
|
|
1051
|
+
}
|
|
1052
|
+
},
|
|
1053
|
+
async dataTableCollection(ctx) {
|
|
1054
|
+
try {
|
|
1055
|
+
const { uid, limit, sort } = ctx.query || {};
|
|
1056
|
+
if (!uid) {
|
|
1057
|
+
return ctx.badRequest('Query parameter "uid" is required');
|
|
1058
|
+
}
|
|
1059
|
+
const res = await strapi.plugin("content-input").service("ci-color").queryCollectionForDataTable({
|
|
1060
|
+
uid: String(uid),
|
|
1061
|
+
limit: limit ? Number(limit) : 25,
|
|
1062
|
+
sort: sort ? String(sort) : "createdAt:desc"
|
|
1063
|
+
});
|
|
1064
|
+
ctx.body = { data: res };
|
|
1065
|
+
} catch (err) {
|
|
1066
|
+
ctx.throw(500, err);
|
|
1067
|
+
}
|
|
1068
|
+
},
|
|
1069
|
+
async entityCardsBatch(ctx) {
|
|
1070
|
+
try {
|
|
1071
|
+
const { uid, documentIds, limit } = ctx.query || {};
|
|
1072
|
+
if (!uid) {
|
|
1073
|
+
return ctx.badRequest('Query parameter "uid" is required');
|
|
1074
|
+
}
|
|
1075
|
+
const docList = typeof documentIds === "string" && documentIds.trim() ? documentIds.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
1076
|
+
const items = await strapi.plugin("content-input").service("ci-color").resolveEntityCardsBatch({
|
|
1077
|
+
uid: String(uid),
|
|
1078
|
+
documentIds: docList,
|
|
1079
|
+
limit: limit ? Number(limit) : 6
|
|
1080
|
+
});
|
|
1081
|
+
ctx.body = { data: items };
|
|
1082
|
+
} catch (err) {
|
|
1083
|
+
ctx.throw(500, err);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
952
1087
|
const controllers = {
|
|
953
1088
|
"ci-template": ciTemplateController,
|
|
954
1089
|
"ci-menu": ciMenuController,
|
|
955
1090
|
"ci-image": ciImageController,
|
|
956
1091
|
"ci-form": ciFormController,
|
|
957
|
-
"ci-survey": ciSurveyController
|
|
1092
|
+
"ci-survey": ciSurveyController,
|
|
1093
|
+
"ci-color": ciColorController
|
|
958
1094
|
};
|
|
959
1095
|
const routes = {
|
|
960
1096
|
admin: {
|
|
@@ -1040,6 +1176,62 @@ const routes = {
|
|
|
1040
1176
|
policies: []
|
|
1041
1177
|
}
|
|
1042
1178
|
},
|
|
1179
|
+
{
|
|
1180
|
+
method: "GET",
|
|
1181
|
+
path: "/entity-cards",
|
|
1182
|
+
handler: "ci-color.entityCardsBatch",
|
|
1183
|
+
config: {
|
|
1184
|
+
policies: []
|
|
1185
|
+
}
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
method: "GET",
|
|
1189
|
+
path: "/data-table",
|
|
1190
|
+
handler: "ci-color.dataTableCollection",
|
|
1191
|
+
config: {
|
|
1192
|
+
policies: []
|
|
1193
|
+
}
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
method: "GET",
|
|
1197
|
+
path: "/color-codes",
|
|
1198
|
+
handler: "ci-color.indexAdmin",
|
|
1199
|
+
config: {
|
|
1200
|
+
policies: []
|
|
1201
|
+
}
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
method: "POST",
|
|
1205
|
+
path: "/color-codes",
|
|
1206
|
+
handler: "ci-color.save",
|
|
1207
|
+
config: {
|
|
1208
|
+
policies: []
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
method: "POST",
|
|
1213
|
+
path: "/color-codes/quick-token",
|
|
1214
|
+
handler: "ci-color.quickToken",
|
|
1215
|
+
config: {
|
|
1216
|
+
policies: []
|
|
1217
|
+
}
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
method: "POST",
|
|
1221
|
+
path: "/color-codes/:id/activate",
|
|
1222
|
+
handler: "ci-color.activate",
|
|
1223
|
+
config: {
|
|
1224
|
+
policies: []
|
|
1225
|
+
}
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
method: "DELETE",
|
|
1229
|
+
path: "/color-codes/:id",
|
|
1230
|
+
handler: "ci-color.delete",
|
|
1231
|
+
config: {
|
|
1232
|
+
policies: []
|
|
1233
|
+
}
|
|
1234
|
+
},
|
|
1043
1235
|
{
|
|
1044
1236
|
method: "GET",
|
|
1045
1237
|
path: "/forms",
|
|
@@ -1304,6 +1496,33 @@ const routes = {
|
|
|
1304
1496
|
auth: false,
|
|
1305
1497
|
policies: []
|
|
1306
1498
|
}
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
method: "GET",
|
|
1502
|
+
path: "/entity-cards",
|
|
1503
|
+
handler: "ci-color.entityCardsBatch",
|
|
1504
|
+
config: {
|
|
1505
|
+
auth: false,
|
|
1506
|
+
policies: []
|
|
1507
|
+
}
|
|
1508
|
+
},
|
|
1509
|
+
{
|
|
1510
|
+
method: "GET",
|
|
1511
|
+
path: "/data-table",
|
|
1512
|
+
handler: "ci-color.dataTableCollection",
|
|
1513
|
+
config: {
|
|
1514
|
+
auth: false,
|
|
1515
|
+
policies: []
|
|
1516
|
+
}
|
|
1517
|
+
},
|
|
1518
|
+
{
|
|
1519
|
+
method: "GET",
|
|
1520
|
+
path: "/color-codes",
|
|
1521
|
+
handler: "ci-color.activePublic",
|
|
1522
|
+
config: {
|
|
1523
|
+
auth: false,
|
|
1524
|
+
policies: []
|
|
1525
|
+
}
|
|
1307
1526
|
}
|
|
1308
1527
|
]
|
|
1309
1528
|
}
|
|
@@ -1320,7 +1539,7 @@ const ciTemplateService = ({ strapi }) => ({
|
|
|
1320
1539
|
}));
|
|
1321
1540
|
},
|
|
1322
1541
|
async create(data) {
|
|
1323
|
-
const structure = Array.isArray(data.structure) ? data.structure : [data.structure];
|
|
1542
|
+
const structure = data.category === "card_design" ? data.structure : Array.isArray(data.structure) ? data.structure : [data.structure];
|
|
1324
1543
|
const created = await strapi.db.query(UID).create({
|
|
1325
1544
|
data: {
|
|
1326
1545
|
name: String(data.name || "").trim(),
|
|
@@ -1368,7 +1587,7 @@ function slugifyTR(text) {
|
|
|
1368
1587
|
}
|
|
1369
1588
|
const DEFAULT_SEED_MENUS = [
|
|
1370
1589
|
{
|
|
1371
|
-
name: "
|
|
1590
|
+
name: "Main Header Navigation",
|
|
1372
1591
|
slug: "main-header-menu",
|
|
1373
1592
|
mode: "horizontal",
|
|
1374
1593
|
options: {
|
|
@@ -1380,7 +1599,7 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1380
1599
|
items: [
|
|
1381
1600
|
{
|
|
1382
1601
|
_uId: "m_home",
|
|
1383
|
-
title: "Ana Sayfa",
|
|
1602
|
+
title: { en: "Home", tr: "Ana Sayfa" },
|
|
1384
1603
|
url: "/",
|
|
1385
1604
|
type: "custom",
|
|
1386
1605
|
target: "_self",
|
|
@@ -1389,31 +1608,31 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1389
1608
|
},
|
|
1390
1609
|
{
|
|
1391
1610
|
_uId: "m_corp",
|
|
1392
|
-
title: "Kurumsal",
|
|
1393
|
-
url: "/
|
|
1611
|
+
title: { en: "Company", tr: "Kurumsal" },
|
|
1612
|
+
url: "/company",
|
|
1394
1613
|
type: "custom",
|
|
1395
1614
|
target: "_self",
|
|
1396
1615
|
icon: "business",
|
|
1397
1616
|
children: [
|
|
1398
1617
|
{
|
|
1399
1618
|
_uId: "m_about",
|
|
1400
|
-
title: "Hakkımızda",
|
|
1401
|
-
url: "/
|
|
1619
|
+
title: { en: "About Us", tr: "Hakkımızda" },
|
|
1620
|
+
url: "/company/about",
|
|
1402
1621
|
type: "custom",
|
|
1403
1622
|
target: "_self",
|
|
1404
1623
|
children: []
|
|
1405
1624
|
},
|
|
1406
1625
|
{
|
|
1407
1626
|
_uId: "m_vision",
|
|
1408
|
-
title: "Vizyon & Misyon",
|
|
1409
|
-
url: "/
|
|
1627
|
+
title: { en: "Vision & Mission", tr: "Vizyon & Misyon" },
|
|
1628
|
+
url: "/company/vision-mission",
|
|
1410
1629
|
type: "custom",
|
|
1411
1630
|
target: "_self",
|
|
1412
1631
|
children: [
|
|
1413
1632
|
{
|
|
1414
1633
|
_uId: "m_values",
|
|
1415
|
-
title: "Değerlerimiz & İlkelerimiz",
|
|
1416
|
-
url: "/
|
|
1634
|
+
title: { en: "Core Values & Principles", tr: "Değerlerimiz & İlkelerimiz" },
|
|
1635
|
+
url: "/company/values",
|
|
1417
1636
|
type: "custom",
|
|
1418
1637
|
target: "_self",
|
|
1419
1638
|
children: []
|
|
@@ -1422,8 +1641,8 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1422
1641
|
},
|
|
1423
1642
|
{
|
|
1424
1643
|
_uId: "m_board",
|
|
1425
|
-
title: "Yönetim Kurulu",
|
|
1426
|
-
url: "/
|
|
1644
|
+
title: { en: "Board of Directors", tr: "Yönetim Kurulu" },
|
|
1645
|
+
url: "/company/board",
|
|
1427
1646
|
type: "custom",
|
|
1428
1647
|
target: "_self",
|
|
1429
1648
|
children: []
|
|
@@ -1432,24 +1651,24 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1432
1651
|
},
|
|
1433
1652
|
{
|
|
1434
1653
|
_uId: "m_solutions",
|
|
1435
|
-
title: "Çözümlerimiz",
|
|
1436
|
-
url: "/
|
|
1654
|
+
title: { en: "Solutions", tr: "Çözümlerimiz" },
|
|
1655
|
+
url: "/solutions",
|
|
1437
1656
|
type: "custom",
|
|
1438
1657
|
target: "_self",
|
|
1439
1658
|
icon: "layers",
|
|
1440
1659
|
children: [
|
|
1441
1660
|
{
|
|
1442
1661
|
_uId: "m_sol_cms",
|
|
1443
|
-
title: "Kurumsal İçerik Yönetimi (CMS)",
|
|
1444
|
-
url: "/
|
|
1662
|
+
title: { en: "Enterprise Content Management (CMS)", tr: "Kurumsal İçerik Yönetimi (CMS)" },
|
|
1663
|
+
url: "/solutions/cms",
|
|
1445
1664
|
type: "custom",
|
|
1446
1665
|
target: "_self",
|
|
1447
1666
|
children: []
|
|
1448
1667
|
},
|
|
1449
1668
|
{
|
|
1450
1669
|
_uId: "m_sol_cloud",
|
|
1451
|
-
title: "Bulut & Mikroservis Mimarisi",
|
|
1452
|
-
url: "/
|
|
1670
|
+
title: { en: "Cloud & Microservice Architecture", tr: "Bulut & Mikroservis Mimarisi" },
|
|
1671
|
+
url: "/solutions/cloud",
|
|
1453
1672
|
type: "custom",
|
|
1454
1673
|
target: "_self",
|
|
1455
1674
|
children: []
|
|
@@ -1458,8 +1677,8 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1458
1677
|
},
|
|
1459
1678
|
{
|
|
1460
1679
|
_uId: "m_contact",
|
|
1461
|
-
title: "İletişim",
|
|
1462
|
-
url: "/
|
|
1680
|
+
title: { en: "Contact", tr: "İletişim" },
|
|
1681
|
+
url: "/contact",
|
|
1463
1682
|
type: "custom",
|
|
1464
1683
|
target: "_self",
|
|
1465
1684
|
icon: "mail",
|
|
@@ -1468,7 +1687,7 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1468
1687
|
]
|
|
1469
1688
|
},
|
|
1470
1689
|
{
|
|
1471
|
-
name: "
|
|
1690
|
+
name: "Corporate Sidebar Menu (Vertical Tree)",
|
|
1472
1691
|
slug: "corporate-sidebar-menu",
|
|
1473
1692
|
mode: "vertical",
|
|
1474
1693
|
options: {
|
|
@@ -1480,30 +1699,30 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1480
1699
|
items: [
|
|
1481
1700
|
{
|
|
1482
1701
|
_uId: "v_corp",
|
|
1483
|
-
title: "Kurumsal Bilgiler",
|
|
1484
|
-
url: "/
|
|
1702
|
+
title: { en: "Corporate Profile", tr: "Kurumsal Bilgiler" },
|
|
1703
|
+
url: "/company",
|
|
1485
1704
|
type: "custom",
|
|
1486
1705
|
target: "_self",
|
|
1487
1706
|
children: [
|
|
1488
1707
|
{
|
|
1489
1708
|
_uId: "v_history",
|
|
1490
|
-
title: "Tarihçemiz",
|
|
1491
|
-
url: "/
|
|
1709
|
+
title: { en: "Our History", tr: "Tarihçemiz" },
|
|
1710
|
+
url: "/company/history",
|
|
1492
1711
|
type: "custom",
|
|
1493
1712
|
target: "_self",
|
|
1494
1713
|
children: []
|
|
1495
1714
|
},
|
|
1496
1715
|
{
|
|
1497
1716
|
_uId: "v_quality",
|
|
1498
|
-
title: "Kalite Politikamız",
|
|
1499
|
-
url: "/
|
|
1717
|
+
title: { en: "Quality Policy", tr: "Kalite Politikamız" },
|
|
1718
|
+
url: "/company/quality",
|
|
1500
1719
|
type: "custom",
|
|
1501
1720
|
target: "_self",
|
|
1502
1721
|
children: [
|
|
1503
1722
|
{
|
|
1504
1723
|
_uId: "v_iso",
|
|
1505
|
-
title: "ISO 27001 & Sertifikalar",
|
|
1506
|
-
url: "/
|
|
1724
|
+
title: { en: "ISO 27001 & Certifications", tr: "ISO 27001 & Sertifikalar" },
|
|
1725
|
+
url: "/company/quality/certifications",
|
|
1507
1726
|
type: "custom",
|
|
1508
1727
|
target: "_self",
|
|
1509
1728
|
children: []
|
|
@@ -1514,8 +1733,8 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1514
1733
|
},
|
|
1515
1734
|
{
|
|
1516
1735
|
_uId: "v_career",
|
|
1517
|
-
title: "İnsan Kaynakları & Kariyer",
|
|
1518
|
-
url: "/
|
|
1736
|
+
title: { en: "Careers & Human Resources", tr: "İnsan Kaynakları & Kariyer" },
|
|
1737
|
+
url: "/careers",
|
|
1519
1738
|
type: "custom",
|
|
1520
1739
|
target: "_self",
|
|
1521
1740
|
children: []
|
|
@@ -1542,7 +1761,7 @@ const ciMenuService = ({ strapi }) => ({
|
|
|
1542
1761
|
}));
|
|
1543
1762
|
},
|
|
1544
1763
|
async save(data) {
|
|
1545
|
-
const cleanName = String(data.name || "
|
|
1764
|
+
const cleanName = String(data.name || "Menu").trim();
|
|
1546
1765
|
const cleanSlug = String(data.slug || slugifyTR(cleanName) || `menu-${Date.now()}`).trim();
|
|
1547
1766
|
const cleanMode = data.mode === "vertical" ? "vertical" : "horizontal";
|
|
1548
1767
|
const cleanItems = Array.isArray(data.items) ? data.items : [];
|
|
@@ -1780,13 +1999,13 @@ function splitValidationRules(validationStr) {
|
|
|
1780
1999
|
}
|
|
1781
2000
|
return merged;
|
|
1782
2001
|
}
|
|
1783
|
-
function resolveLocalizedText(val, locale = "
|
|
2002
|
+
function resolveLocalizedText(val, locale = "en", fallback = "") {
|
|
1784
2003
|
if (!val) return fallback;
|
|
1785
2004
|
if (typeof val === "string") return val;
|
|
1786
2005
|
if (typeof val === "object") {
|
|
1787
|
-
const code = String(locale || "
|
|
2006
|
+
const code = String(locale || "en").trim();
|
|
1788
2007
|
const shortCode = code.split(/[-_]/)[0];
|
|
1789
|
-
return val[code] || val[shortCode] || val.
|
|
2008
|
+
return val[code] || val[shortCode] || val.en || val.tr || Object.values(val).find((v) => typeof v === "string" && v.trim() !== "") || fallback;
|
|
1790
2009
|
}
|
|
1791
2010
|
return fallback;
|
|
1792
2011
|
}
|
|
@@ -1801,7 +2020,7 @@ function isEmptyFieldValue(value) {
|
|
|
1801
2020
|
function msg(locale, trText, enText) {
|
|
1802
2021
|
return String(locale || "").toLowerCase().startsWith("tr") ? trText : enText;
|
|
1803
2022
|
}
|
|
1804
|
-
function validateSingleField(value, field, allData = {}, locale = "
|
|
2023
|
+
function validateSingleField(value, field, allData = {}, locale = "en") {
|
|
1805
2024
|
const errors = [];
|
|
1806
2025
|
const rawValidation = typeof field.validation === "object" && field.validation !== null ? resolveLocalizedText(field.validation, locale, "") : String(field.validation || "");
|
|
1807
2026
|
const rules = splitValidationRules(rawValidation);
|
|
@@ -2048,7 +2267,7 @@ function validateSingleField(value, field, allData = {}, locale = "tr") {
|
|
|
2048
2267
|
}
|
|
2049
2268
|
return errors;
|
|
2050
2269
|
}
|
|
2051
|
-
function validateFormSubmission(fieldsMap, payload, locale = "
|
|
2270
|
+
function validateFormSubmission(fieldsMap, payload, locale = "en") {
|
|
2052
2271
|
const errors = {};
|
|
2053
2272
|
const data = payload || {};
|
|
2054
2273
|
for (const [key, fieldDef] of Object.entries(fieldsMap || {})) {
|
|
@@ -2102,25 +2321,28 @@ function escapeHtml(input) {
|
|
|
2102
2321
|
const str = input === null || input === void 0 ? "" : String(input);
|
|
2103
2322
|
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2104
2323
|
}
|
|
2105
|
-
function formatFieldValue(val) {
|
|
2324
|
+
function formatFieldValue(val, locale = "en") {
|
|
2106
2325
|
if (val === null || val === void 0 || val === "") return "-";
|
|
2107
2326
|
if (Array.isArray(val)) return val.join(", ");
|
|
2108
|
-
if (typeof val === "boolean")
|
|
2327
|
+
if (typeof val === "boolean") {
|
|
2328
|
+
const tr = String(locale || "en").toLowerCase().startsWith("tr");
|
|
2329
|
+
return val ? tr ? "Evet" : "Yes" : tr ? "Hayır" : "No";
|
|
2330
|
+
}
|
|
2109
2331
|
if (typeof val === "object") return JSON.stringify(val);
|
|
2110
2332
|
return String(val);
|
|
2111
2333
|
}
|
|
2112
2334
|
function renderContentFormMailHtml(params) {
|
|
2113
2335
|
const { form, data, meta } = params;
|
|
2114
|
-
const locale = meta?.locale || "
|
|
2336
|
+
const locale = meta?.locale || "en";
|
|
2115
2337
|
const fields = form.fields || {};
|
|
2116
2338
|
const entries = Object.keys(fields).length > 0 ? Object.entries(fields).map(([key, def]) => ({
|
|
2117
2339
|
key,
|
|
2118
2340
|
label: resolveLocalizedText(def?.alias, locale, key),
|
|
2119
|
-
value: formatFieldValue(data[key])
|
|
2341
|
+
value: formatFieldValue(data[key], locale)
|
|
2120
2342
|
})) : Object.entries(data || {}).map(([key, val]) => ({
|
|
2121
2343
|
key,
|
|
2122
2344
|
label: key,
|
|
2123
|
-
value: formatFieldValue(val)
|
|
2345
|
+
value: formatFieldValue(val, locale)
|
|
2124
2346
|
}));
|
|
2125
2347
|
const rowsHtml = entries.map(
|
|
2126
2348
|
(item) => `
|
|
@@ -2186,6 +2408,46 @@ function parseFromAddress(rawFrom, rawName) {
|
|
|
2186
2408
|
const name = (rawName || fallbackName).trim();
|
|
2187
2409
|
return { email: trimmed, name, formatted: `"${name}" <${trimmed}>` };
|
|
2188
2410
|
}
|
|
2411
|
+
const mailtrapInboxCache = /* @__PURE__ */ new Map();
|
|
2412
|
+
async function discoverMailtrapSandboxInbox(rawToken) {
|
|
2413
|
+
const token = String(rawToken || "").trim();
|
|
2414
|
+
if (!token) return "";
|
|
2415
|
+
if (mailtrapInboxCache.has(token)) {
|
|
2416
|
+
return mailtrapInboxCache.get(token) || "";
|
|
2417
|
+
}
|
|
2418
|
+
try {
|
|
2419
|
+
const accRes = await fetch("https://mailtrap.io/api/accounts", {
|
|
2420
|
+
headers: {
|
|
2421
|
+
Authorization: `Bearer ${token}`,
|
|
2422
|
+
"Api-Token": token
|
|
2423
|
+
}
|
|
2424
|
+
});
|
|
2425
|
+
if (!accRes.ok) return "";
|
|
2426
|
+
const accounts = await accRes.json();
|
|
2427
|
+
const accountId = Array.isArray(accounts) && accounts[0]?.id ? accounts[0].id : null;
|
|
2428
|
+
if (!accountId) return "";
|
|
2429
|
+
const inbRes = await fetch(
|
|
2430
|
+
`https://mailtrap.io/api/accounts/${encodeURIComponent(String(accountId))}/inboxes`,
|
|
2431
|
+
{
|
|
2432
|
+
headers: {
|
|
2433
|
+
Authorization: `Bearer ${token}`,
|
|
2434
|
+
"Api-Token": token
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
);
|
|
2438
|
+
if (!inbRes.ok) return "";
|
|
2439
|
+
const inboxes = await inbRes.json();
|
|
2440
|
+
if (!Array.isArray(inboxes) || inboxes.length === 0) return "";
|
|
2441
|
+
const activeInbox = inboxes.find((i) => i?.status === "active") || inboxes[0];
|
|
2442
|
+
const discoveredId = activeInbox?.id ? String(activeInbox.id) : "";
|
|
2443
|
+
if (discoveredId) {
|
|
2444
|
+
mailtrapInboxCache.set(token, discoveredId);
|
|
2445
|
+
}
|
|
2446
|
+
return discoveredId;
|
|
2447
|
+
} catch {
|
|
2448
|
+
return "";
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2189
2451
|
async function sendDynamicFormMail(params) {
|
|
2190
2452
|
const { form, strapi } = params;
|
|
2191
2453
|
const cfg = form.mailConfig || {};
|
|
@@ -2213,7 +2475,8 @@ async function sendDynamicFormMail(params) {
|
|
|
2213
2475
|
cfg.from || process.env.MAIL_FROM,
|
|
2214
2476
|
cfg.fromName || process.env.MAIL_FROM_NAME
|
|
2215
2477
|
);
|
|
2216
|
-
const
|
|
2478
|
+
const isTr = String(params.meta?.locale || "en").toLowerCase().startsWith("tr");
|
|
2479
|
+
const subject = form.subject?.trim() || `${form.title} — ${isTr ? "Yeni Form Başvurusu" : "New Form Submission"}`;
|
|
2217
2480
|
const { html, text } = renderContentFormMailHtml(params);
|
|
2218
2481
|
let resolvedDriver = explicitDriver;
|
|
2219
2482
|
if (resolvedDriver === "auto") {
|
|
@@ -2225,11 +2488,17 @@ async function sendDynamicFormMail(params) {
|
|
|
2225
2488
|
try {
|
|
2226
2489
|
if (resolvedDriver === "mailtrap") {
|
|
2227
2490
|
if (mailtrapToken) {
|
|
2228
|
-
const
|
|
2491
|
+
const cleanToken = mailtrapToken.trim();
|
|
2492
|
+
let effectiveInboxId = mailtrapInboxId ? String(mailtrapInboxId).trim() : "";
|
|
2493
|
+
if (!effectiveInboxId) {
|
|
2494
|
+
effectiveInboxId = await discoverMailtrapSandboxInbox(cleanToken);
|
|
2495
|
+
}
|
|
2496
|
+
const endpoint = effectiveInboxId ? `https://sandbox.api.mailtrap.io/api/send/${encodeURIComponent(effectiveInboxId)}` : "https://send.api.mailtrap.io/api/send";
|
|
2229
2497
|
const res = await fetch(endpoint, {
|
|
2230
2498
|
method: "POST",
|
|
2231
2499
|
headers: {
|
|
2232
|
-
Authorization: `Bearer ${
|
|
2500
|
+
Authorization: `Bearer ${cleanToken}`,
|
|
2501
|
+
"Api-Token": cleanToken,
|
|
2233
2502
|
"Content-Type": "application/json"
|
|
2234
2503
|
},
|
|
2235
2504
|
body: JSON.stringify({
|
|
@@ -2246,7 +2515,7 @@ async function sendDynamicFormMail(params) {
|
|
|
2246
2515
|
}
|
|
2247
2516
|
return {
|
|
2248
2517
|
sent: true,
|
|
2249
|
-
driver:
|
|
2518
|
+
driver: effectiveInboxId ? "mailtrap-sandbox-api" : "mailtrap-sending-api",
|
|
2250
2519
|
detail: resBody
|
|
2251
2520
|
};
|
|
2252
2521
|
}
|
|
@@ -2374,10 +2643,10 @@ async function sendDynamicFormMail(params) {
|
|
|
2374
2643
|
}
|
|
2375
2644
|
const DEFAULT_SEED_SURVEYS = [
|
|
2376
2645
|
{
|
|
2377
|
-
title: "
|
|
2646
|
+
title: "Enterprise Product & Developer Experience Survey (3-Step)",
|
|
2378
2647
|
titleI18n: {
|
|
2379
|
-
|
|
2380
|
-
|
|
2648
|
+
en: "Enterprise Product & Developer Experience Survey",
|
|
2649
|
+
tr: "Kurumsal Ürün & Geliştirici Deneyimi Anketi"
|
|
2381
2650
|
},
|
|
2382
2651
|
slug: "showcase_dx_survey",
|
|
2383
2652
|
description: {
|
|
@@ -2713,10 +2982,10 @@ const DEFAULT_SEED_SURVEYS = [
|
|
|
2713
2982
|
}
|
|
2714
2983
|
},
|
|
2715
2984
|
{
|
|
2716
|
-
title: "
|
|
2985
|
+
title: "Quick Poll: What Should We Ship Next?",
|
|
2717
2986
|
titleI18n: {
|
|
2718
|
-
|
|
2719
|
-
|
|
2987
|
+
en: "Quick Poll: What Should We Ship Next?",
|
|
2988
|
+
tr: "Hızlı Oylama: Sıradaki Büyük Özellik Ne Olsun?"
|
|
2720
2989
|
},
|
|
2721
2990
|
slug: "showcase_roadmap_poll",
|
|
2722
2991
|
description: {
|
|
@@ -2787,10 +3056,10 @@ const DEFAULT_SEED_SURVEYS = [
|
|
|
2787
3056
|
}
|
|
2788
3057
|
},
|
|
2789
3058
|
{
|
|
2790
|
-
title: "
|
|
3059
|
+
title: "Visual Showcase & Readability Poll (Live Results)",
|
|
2791
3060
|
titleI18n: {
|
|
2792
|
-
|
|
2793
|
-
|
|
3061
|
+
en: "Visual Showcase & Readability Poll (Live Results)",
|
|
3062
|
+
tr: "Görsel Vitrin & Okunabilirlik Tercihi (Açık Sonuçlu)"
|
|
2794
3063
|
},
|
|
2795
3064
|
slug: "showcase_visual_theme_poll",
|
|
2796
3065
|
description: {
|
|
@@ -3291,7 +3560,7 @@ const DEFAULT_SEED_FORMS = [
|
|
|
3291
3560
|
title: "Enterprise Inquiry & Support Form",
|
|
3292
3561
|
slug: "showcase_contact_form",
|
|
3293
3562
|
to: "info@example.com",
|
|
3294
|
-
subject: "
|
|
3563
|
+
subject: "Enterprise Inquiry & Support Submission",
|
|
3295
3564
|
buttonLabel: {
|
|
3296
3565
|
tr: "Başvuruyu Gönder",
|
|
3297
3566
|
en: "Submit Inquiry"
|
|
@@ -3586,8 +3855,8 @@ const ciFormService = ({ strapi }) => ({
|
|
|
3586
3855
|
} catch {
|
|
3587
3856
|
}
|
|
3588
3857
|
return [
|
|
3589
|
-
{ code: "
|
|
3590
|
-
{ code: "
|
|
3858
|
+
{ code: "en", name: "English (en)", isDefault: true },
|
|
3859
|
+
{ code: "tr", name: "Türkçe (tr)", isDefault: false }
|
|
3591
3860
|
];
|
|
3592
3861
|
},
|
|
3593
3862
|
async ensureSampleSubmissions(force = false) {
|
|
@@ -3621,6 +3890,22 @@ const ciFormService = ({ strapi }) => ({
|
|
|
3621
3890
|
for (const seed of DEFAULT_SEED_FORMS) {
|
|
3622
3891
|
await strapi.db.query(FORM_UID).create({ data: seed });
|
|
3623
3892
|
}
|
|
3893
|
+
} else {
|
|
3894
|
+
try {
|
|
3895
|
+
const showcase = await strapi.db.query(FORM_UID).findOne({
|
|
3896
|
+
where: { slug: "showcase_contact_form" }
|
|
3897
|
+
});
|
|
3898
|
+
if (showcase && (showcase.subject === "Kurumsal İletişim & Destek Başvurusu" || showcase.title === "Kurumsal İletişim & Destek Formu")) {
|
|
3899
|
+
await strapi.db.query(FORM_UID).update({
|
|
3900
|
+
where: { id: showcase.id },
|
|
3901
|
+
data: {
|
|
3902
|
+
title: "Enterprise Inquiry & Support Form",
|
|
3903
|
+
subject: "Enterprise Inquiry & Support Submission"
|
|
3904
|
+
}
|
|
3905
|
+
});
|
|
3906
|
+
}
|
|
3907
|
+
} catch {
|
|
3908
|
+
}
|
|
3624
3909
|
}
|
|
3625
3910
|
await this.ensureSampleSubmissions(false);
|
|
3626
3911
|
},
|
|
@@ -3664,7 +3949,7 @@ const ciFormService = ({ strapi }) => ({
|
|
|
3664
3949
|
return sanitizeFormForPublic(found);
|
|
3665
3950
|
},
|
|
3666
3951
|
async save(payload) {
|
|
3667
|
-
const cleanTitle = String(payload.title || "
|
|
3952
|
+
const cleanTitle = String(payload.title || "New Dynamic Form").trim();
|
|
3668
3953
|
const cleanSlug = String(
|
|
3669
3954
|
payload.slug || slugifyIdentifier$1(cleanTitle) || `form_${Date.now()}`
|
|
3670
3955
|
).trim();
|
|
@@ -3681,6 +3966,16 @@ const ciFormService = ({ strapi }) => ({
|
|
|
3681
3966
|
if (!existing && cleanSlug) {
|
|
3682
3967
|
existing = await strapi.db.query(FORM_UID).findOne({ where: { slug: cleanSlug } });
|
|
3683
3968
|
}
|
|
3969
|
+
const mergedMailConfig = {
|
|
3970
|
+
...existing?.mailConfig || { driver: "env" },
|
|
3971
|
+
...payload.mailConfig || {}
|
|
3972
|
+
};
|
|
3973
|
+
if (mergedMailConfig.driver === "mailtrap" && mergedMailConfig.apiKey && !String(mergedMailConfig.inboxId || "").trim()) {
|
|
3974
|
+
const autoInbox = await discoverMailtrapSandboxInbox(mergedMailConfig.apiKey);
|
|
3975
|
+
if (autoInbox) {
|
|
3976
|
+
mergedMailConfig.inboxId = autoInbox;
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3684
3979
|
const recordData = {
|
|
3685
3980
|
title: cleanTitle,
|
|
3686
3981
|
slug: cleanSlug,
|
|
@@ -3699,7 +3994,7 @@ const ciFormService = ({ strapi }) => ({
|
|
|
3699
3994
|
useRecaptcha: payload.useRecaptcha !== void 0 ? Boolean(payload.useRecaptcha) : existing?.useRecaptcha !== void 0 ? Boolean(existing.useRecaptcha) : true,
|
|
3700
3995
|
recaptchaSiteKey: payload.recaptchaSiteKey !== void 0 ? String(payload.recaptchaSiteKey) : existing?.recaptchaSiteKey || "",
|
|
3701
3996
|
recaptchaSecretKey: payload.recaptchaSecretKey !== void 0 ? String(payload.recaptchaSecretKey) : existing?.recaptchaSecretKey || "",
|
|
3702
|
-
mailConfig:
|
|
3997
|
+
mailConfig: mergedMailConfig,
|
|
3703
3998
|
fields: payload.fields && typeof payload.fields === "object" ? payload.fields : existing?.fields || {},
|
|
3704
3999
|
form: Array.isArray(payload.form) ? payload.form : existing?.form || []
|
|
3705
4000
|
};
|
|
@@ -3768,8 +4063,8 @@ const ciFormService = ({ strapi }) => ({
|
|
|
3768
4063
|
};
|
|
3769
4064
|
}
|
|
3770
4065
|
const body = rawBody && typeof rawBody === "object" ? rawBody : {};
|
|
3771
|
-
const rawLocale = String(body._locale || meta.locale || "
|
|
3772
|
-
const locale = rawLocale ? rawLocale.split(/[,;]/)[0].trim() : "
|
|
4066
|
+
const rawLocale = String(body._locale || meta.locale || "en").trim().toLowerCase();
|
|
4067
|
+
const locale = rawLocale ? rawLocale.split(/[,;]/)[0].trim() : "en";
|
|
3773
4068
|
const fieldsMap = form.fields && typeof form.fields === "object" ? form.fields : {};
|
|
3774
4069
|
const { errors } = validateFormSubmission(fieldsMap, body, locale);
|
|
3775
4070
|
const activeSecretKey = String(
|
|
@@ -4066,7 +4361,7 @@ function isQuestionVisible(question, survey, answers) {
|
|
|
4066
4361
|
function lMsg(locale, tr, en) {
|
|
4067
4362
|
return String(locale || "").toLowerCase().startsWith("tr") ? tr : en;
|
|
4068
4363
|
}
|
|
4069
|
-
function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "
|
|
4364
|
+
function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en") {
|
|
4070
4365
|
const errors = {};
|
|
4071
4366
|
const questions = Array.isArray(survey.questions) ? survey.questions : [];
|
|
4072
4367
|
for (const q of questions) {
|
|
@@ -4262,7 +4557,7 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
4262
4557
|
const dailyCounts = {};
|
|
4263
4558
|
let lastSubmittedAt = null;
|
|
4264
4559
|
for (const r of responses) {
|
|
4265
|
-
const loc = String(r.locale || "
|
|
4560
|
+
const loc = String(r.locale || "en");
|
|
4266
4561
|
localeCounts[loc] = (localeCounts[loc] || 0) + 1;
|
|
4267
4562
|
const tsRaw = r.submittedAt || r.createdAt;
|
|
4268
4563
|
if (tsRaw) {
|
|
@@ -4324,7 +4619,7 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
4324
4619
|
if (txt && otherSamples.length < 30) {
|
|
4325
4620
|
otherSamples.push({
|
|
4326
4621
|
text: txt,
|
|
4327
|
-
locale: r.locale || "
|
|
4622
|
+
locale: r.locale || "en",
|
|
4328
4623
|
submittedAt: r.submittedAt || r.createdAt || ""
|
|
4329
4624
|
});
|
|
4330
4625
|
}
|
|
@@ -4531,7 +4826,7 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
4531
4826
|
textResponses.push({
|
|
4532
4827
|
id: r.id || r.documentId,
|
|
4533
4828
|
text: v.trim(),
|
|
4534
|
-
locale: r.locale || "
|
|
4829
|
+
locale: r.locale || "en",
|
|
4535
4830
|
submittedAt: r.submittedAt || r.createdAt || "",
|
|
4536
4831
|
npsValue: r.npsValue ?? null
|
|
4537
4832
|
});
|
|
@@ -4594,7 +4889,7 @@ function escapeCsvCell(val) {
|
|
|
4594
4889
|
}
|
|
4595
4890
|
return str;
|
|
4596
4891
|
}
|
|
4597
|
-
function exportSurveyResponsesToCsv(survey, rawResponses, locale = "
|
|
4892
|
+
function exportSurveyResponsesToCsv(survey, rawResponses, locale = "en") {
|
|
4598
4893
|
const activeQuestions = (survey.questions || []).filter((q) => q && q.type !== "statement");
|
|
4599
4894
|
const headers = [
|
|
4600
4895
|
"Response ID",
|
|
@@ -5010,8 +5305,8 @@ const ciSurveyService = ({ strapi }) => ({
|
|
|
5010
5305
|
};
|
|
5011
5306
|
}
|
|
5012
5307
|
const body = rawBody && typeof rawBody === "object" ? rawBody : {};
|
|
5013
|
-
const rawLocale = String(body._locale || meta.locale || "
|
|
5014
|
-
const locale = rawLocale ? rawLocale.split(/[,;]/)[0].trim() : "
|
|
5308
|
+
const rawLocale = String(body._locale || meta.locale || "en").trim().toLowerCase();
|
|
5309
|
+
const locale = rawLocale ? rawLocale.split(/[,;]/)[0].trim() : "en";
|
|
5015
5310
|
const isTr = locale.startsWith("tr");
|
|
5016
5311
|
if (body._hp && String(body._hp).trim() !== "") {
|
|
5017
5312
|
return {
|
|
@@ -5150,7 +5445,7 @@ const ciSurveyService = ({ strapi }) => ({
|
|
|
5150
5445
|
form: {
|
|
5151
5446
|
title: survey.title,
|
|
5152
5447
|
to: notifyEmails,
|
|
5153
|
-
subject:
|
|
5448
|
+
subject: `${isTr ? "[Anket Yanıtı]" : "[Survey Response]"} ${survey.title}`,
|
|
5154
5449
|
mailConfig: survey.mailConfig
|
|
5155
5450
|
},
|
|
5156
5451
|
data: {
|
|
@@ -5259,7 +5554,7 @@ const ciSurveyService = ({ strapi }) => ({
|
|
|
5259
5554
|
const csv = exportSurveyResponsesToCsv(
|
|
5260
5555
|
survey,
|
|
5261
5556
|
responses,
|
|
5262
|
-
options2.locale || "
|
|
5557
|
+
options2.locale || "en"
|
|
5263
5558
|
);
|
|
5264
5559
|
return {
|
|
5265
5560
|
filename: `${survey.slug}-responses.csv`,
|
|
@@ -5268,11 +5563,600 @@ const ciSurveyService = ({ strapi }) => ({
|
|
|
5268
5563
|
};
|
|
5269
5564
|
}
|
|
5270
5565
|
});
|
|
5566
|
+
const PALETTE_UID = "plugin::content-input.ci-color-palette";
|
|
5567
|
+
function clamp(n, min, max) {
|
|
5568
|
+
return Math.max(min, Math.min(max, n));
|
|
5569
|
+
}
|
|
5570
|
+
function parseColorToRgba(rawInput, fallback = { r: 79, g: 70, b: 229, a: 1 }) {
|
|
5571
|
+
const str = String(rawInput || "").trim();
|
|
5572
|
+
if (!str) return fallback;
|
|
5573
|
+
const varMatch = str.match(/^var\([^,]+,\s*(.+)\)$/);
|
|
5574
|
+
const target = varMatch ? varMatch[1].trim() : str;
|
|
5575
|
+
const hexMatch = target.match(/^#([0-9a-fA-F]{3,8})$/);
|
|
5576
|
+
if (hexMatch) {
|
|
5577
|
+
const h = hexMatch[1];
|
|
5578
|
+
if (h.length === 3 || h.length === 4) {
|
|
5579
|
+
const r = parseInt(h[0] + h[0], 16);
|
|
5580
|
+
const g = parseInt(h[1] + h[1], 16);
|
|
5581
|
+
const b = parseInt(h[2] + h[2], 16);
|
|
5582
|
+
const a = h.length === 4 ? Number((parseInt(h[3] + h[3], 16) / 255).toFixed(2)) : 1;
|
|
5583
|
+
return { r, g, b, a };
|
|
5584
|
+
}
|
|
5585
|
+
if (h.length === 6 || h.length === 8) {
|
|
5586
|
+
const r = parseInt(h.slice(0, 2), 16);
|
|
5587
|
+
const g = parseInt(h.slice(2, 4), 16);
|
|
5588
|
+
const b = parseInt(h.slice(4, 6), 16);
|
|
5589
|
+
const a = h.length === 8 ? Number((parseInt(h.slice(6, 8), 16) / 255).toFixed(2)) : 1;
|
|
5590
|
+
return { r, g, b, a };
|
|
5591
|
+
}
|
|
5592
|
+
}
|
|
5593
|
+
const rgbMatch = target.match(/^rgba?\(\s*([\d.]+)\s*[,\s]\s*([\d.]+)\s*[,\s]\s*([\d.]+)(?:\s*[,/]\s*([\d.%]+))?\s*\)$/i);
|
|
5594
|
+
if (rgbMatch) {
|
|
5595
|
+
const r = clamp(Math.round(Number(rgbMatch[1])), 0, 255);
|
|
5596
|
+
const g = clamp(Math.round(Number(rgbMatch[2])), 0, 255);
|
|
5597
|
+
const b = clamp(Math.round(Number(rgbMatch[3])), 0, 255);
|
|
5598
|
+
let a = 1;
|
|
5599
|
+
if (rgbMatch[4] !== void 0) {
|
|
5600
|
+
const rawA = rgbMatch[4].trim();
|
|
5601
|
+
a = rawA.endsWith("%") ? clamp(Number(rawA.slice(0, -1)) / 100, 0, 1) : clamp(Number(rawA), 0, 1);
|
|
5602
|
+
a = Number(a.toFixed(2));
|
|
5603
|
+
}
|
|
5604
|
+
return { r, g, b, a };
|
|
5605
|
+
}
|
|
5606
|
+
return fallback;
|
|
5607
|
+
}
|
|
5608
|
+
function rgbaToHex({ r, g, b, a }) {
|
|
5609
|
+
const to2 = (n) => clamp(Math.round(n), 0, 255).toString(16).padStart(2, "0");
|
|
5610
|
+
if (a < 1) {
|
|
5611
|
+
return `#${to2(r)}${to2(g)}${to2(b)}${to2(Math.round(a * 255))}`;
|
|
5612
|
+
}
|
|
5613
|
+
return `#${to2(r)}${to2(g)}${to2(b)}`;
|
|
5614
|
+
}
|
|
5615
|
+
function rgbaToCssString({ r, g, b, a }) {
|
|
5616
|
+
const cr = clamp(Math.round(r), 0, 255);
|
|
5617
|
+
const cg = clamp(Math.round(g), 0, 255);
|
|
5618
|
+
const cb = clamp(Math.round(b), 0, 255);
|
|
5619
|
+
const ca = clamp(Number(a.toFixed(2)), 0, 1);
|
|
5620
|
+
return ca < 1 ? `rgba(${cr}, ${cg}, ${cb}, ${ca})` : `rgb(${cr}, ${cg}, ${cb})`;
|
|
5621
|
+
}
|
|
5622
|
+
function buildTokenEntry(rawVal, labels, overrides) {
|
|
5623
|
+
const parsed = parseColorToRgba(rawVal);
|
|
5624
|
+
const hex = rgbaToHex(parsed);
|
|
5625
|
+
const rgb = rgbaToCssString(parsed);
|
|
5626
|
+
const cleanTrimmed = String(rawVal || "").trim();
|
|
5627
|
+
const value = cleanTrimmed.toLowerCase().startsWith("rgb") ? rgb : hex;
|
|
5628
|
+
const srgb = [parsed.r, parsed.g, parsed.b].map((v) => {
|
|
5629
|
+
const c = v / 255;
|
|
5630
|
+
return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
5631
|
+
});
|
|
5632
|
+
const lum = 0.2126 * srgb[0] + 0.7152 * srgb[1] + 0.0722 * srgb[2];
|
|
5633
|
+
const autoContrast = lum > 0.44 ? "#0f172a" : "#ffffff";
|
|
5634
|
+
const autoSoft = `rgba(${parsed.r}, ${parsed.g}, ${parsed.b}, 0.14)`;
|
|
5635
|
+
return {
|
|
5636
|
+
value,
|
|
5637
|
+
hex,
|
|
5638
|
+
rgb,
|
|
5639
|
+
soft: overrides?.soft || autoSoft,
|
|
5640
|
+
contrast: overrides?.contrast || autoContrast,
|
|
5641
|
+
...labels ? { labels } : {}
|
|
5642
|
+
};
|
|
5643
|
+
}
|
|
5644
|
+
const SEMANTIC_TOKEN_META = [
|
|
5645
|
+
{ key: "primary", tr: "Birincil (Primary)", en: "Primary" },
|
|
5646
|
+
{ key: "secondary", tr: "İkincil (Secondary)", en: "Secondary" },
|
|
5647
|
+
{ key: "accent", tr: "Vurgu (Accent)", en: "Accent" },
|
|
5648
|
+
{ key: "success", tr: "Başarı (Success)", en: "Success" },
|
|
5649
|
+
{ key: "warning", tr: "Uyarı (Warning)", en: "Warning" },
|
|
5650
|
+
{ key: "error", tr: "Hata / Tehlike (Error)", en: "Error" },
|
|
5651
|
+
{ key: "info", tr: "Bilgi (Info)", en: "Info" },
|
|
5652
|
+
{ key: "surface", tr: "Kart / Yüzey (Surface)", en: "Surface" },
|
|
5653
|
+
{ key: "surfaceAlt", tr: "Alternatif Yüzey", en: "Surface Alt" },
|
|
5654
|
+
{ key: "background", tr: "Sayfa Arka Planı", en: "Background" },
|
|
5655
|
+
{ key: "textPrimary", tr: "Ana Metin Rengi", en: "Primary Text" },
|
|
5656
|
+
{ key: "textSecondary", tr: "İkincil Metin Rengi", en: "Secondary Text" },
|
|
5657
|
+
{ key: "border", tr: "Kenarlık (Border)", en: "Border" }
|
|
5658
|
+
];
|
|
5659
|
+
const DEFAULT_PALETTE_SEEDS = [
|
|
5660
|
+
{
|
|
5661
|
+
name: "Enterprise Indigo (Default)",
|
|
5662
|
+
slug: "enterprise-indigo",
|
|
5663
|
+
description: "Balanced Indigo, Sky Blue, and Dark Slate palette for modern SaaS & enterprise interfaces",
|
|
5664
|
+
isActive: true,
|
|
5665
|
+
rawSemantic: {
|
|
5666
|
+
primary: "#4f46e5",
|
|
5667
|
+
secondary: "#0ea5e9",
|
|
5668
|
+
accent: "#8b5cf6",
|
|
5669
|
+
success: "#10b981",
|
|
5670
|
+
warning: "#f59e0b",
|
|
5671
|
+
error: "#ef4444",
|
|
5672
|
+
info: "#3b82f6",
|
|
5673
|
+
surface: "#ffffff",
|
|
5674
|
+
surfaceAlt: "#f8fafc",
|
|
5675
|
+
background: "#f1f5f9",
|
|
5676
|
+
textPrimary: "#0f172a",
|
|
5677
|
+
textSecondary: "#475569",
|
|
5678
|
+
border: "#e2e8f0"
|
|
5679
|
+
},
|
|
5680
|
+
rawCustom: [
|
|
5681
|
+
{ key: "brandGold", value: "#d97706", labels: { tr: "Kurumsal Altın", en: "Brand Gold" } },
|
|
5682
|
+
{ key: "heroCyan", value: "rgb(6, 182, 212)", labels: { tr: "Vitrin Turkuaz (RGB)", en: "Hero Cyan (RGB)" } },
|
|
5683
|
+
{ key: "glassDark", value: "rgba(15, 23, 42, 0.76)", labels: { tr: "Koyu Cam Efekt (RGBA)", en: "Dark Glass Scrim (RGBA)" } },
|
|
5684
|
+
{ key: "coralHighlight", value: "#f43f5e", labels: { tr: "Mercan Vurgu", en: "Coral Highlight" } }
|
|
5685
|
+
]
|
|
5686
|
+
},
|
|
5687
|
+
{
|
|
5688
|
+
name: "Emerald Fintech & Sustainability",
|
|
5689
|
+
slug: "emerald-fintech",
|
|
5690
|
+
description: "Emerald Green & Ocean Navy palette crafted for fintech, energy, and sustainability platforms",
|
|
5691
|
+
isActive: false,
|
|
5692
|
+
rawSemantic: {
|
|
5693
|
+
primary: "#059669",
|
|
5694
|
+
secondary: "#0f766e",
|
|
5695
|
+
accent: "#0284c7",
|
|
5696
|
+
success: "#16a34a",
|
|
5697
|
+
warning: "#d97706",
|
|
5698
|
+
error: "#dc2626",
|
|
5699
|
+
info: "#0ea5e9",
|
|
5700
|
+
surface: "#ffffff",
|
|
5701
|
+
surfaceAlt: "#f0fdf4",
|
|
5702
|
+
background: "#f8fafc",
|
|
5703
|
+
textPrimary: "#064e3b",
|
|
5704
|
+
textSecondary: "#334155",
|
|
5705
|
+
border: "#d1fae5"
|
|
5706
|
+
},
|
|
5707
|
+
rawCustom: [
|
|
5708
|
+
{ key: "brandGold", value: "#ca8a04", labels: { tr: "Kurumsal Altın", en: "Brand Gold" } },
|
|
5709
|
+
{ key: "heroCyan", value: "rgb(20, 184, 166)", labels: { tr: "Mint Yeşil (RGB)", en: "Mint Teal (RGB)" } },
|
|
5710
|
+
{ key: "glassDark", value: "rgba(6, 78, 59, 0.78)", labels: { tr: "Zümrüt Cam (RGBA)", en: "Emerald Glass (RGBA)" } },
|
|
5711
|
+
{ key: "coralHighlight", value: "#ea580c", labels: { tr: "Sıcak Turuncu", en: "Warm Terracotta" } }
|
|
5712
|
+
]
|
|
5713
|
+
},
|
|
5714
|
+
{
|
|
5715
|
+
name: "Royal Amber & Executive Navy",
|
|
5716
|
+
slug: "royal-amber",
|
|
5717
|
+
description: "Executive Navy & Royal Amber Gold palette for corporate holdings, legal, real estate, and luxury brands",
|
|
5718
|
+
isActive: false,
|
|
5719
|
+
rawSemantic: {
|
|
5720
|
+
primary: "#1e3a8a",
|
|
5721
|
+
secondary: "#d97706",
|
|
5722
|
+
accent: "#b45309",
|
|
5723
|
+
success: "#15803d",
|
|
5724
|
+
warning: "#eab308",
|
|
5725
|
+
error: "#b91c1c",
|
|
5726
|
+
info: "#1d4ed8",
|
|
5727
|
+
surface: "#ffffff",
|
|
5728
|
+
surfaceAlt: "#fffbeb",
|
|
5729
|
+
background: "#f8fafc",
|
|
5730
|
+
textPrimary: "#0f172a",
|
|
5731
|
+
textSecondary: "#475569",
|
|
5732
|
+
border: "#e2e8f0"
|
|
5733
|
+
},
|
|
5734
|
+
rawCustom: [
|
|
5735
|
+
{ key: "brandGold", value: "#f59e0b", labels: { tr: "Kraliyet Altını", en: "Royal Gold" } },
|
|
5736
|
+
{ key: "heroCyan", value: "rgb(59, 130, 246)", labels: { tr: "Kraliyet Mavisi (RGB)", en: "Royal Blue (RGB)" } },
|
|
5737
|
+
{ key: "glassDark", value: "rgba(23, 37, 84, 0.82)", labels: { tr: "Lacivert Cam (RGBA)", en: "Navy Glass (RGBA)" } },
|
|
5738
|
+
{ key: "coralHighlight", value: "#e11d48", labels: { tr: "Yakut Vurgu", en: "Ruby Highlight" } }
|
|
5739
|
+
]
|
|
5740
|
+
},
|
|
5741
|
+
{
|
|
5742
|
+
name: "Crimson Editorial & Media",
|
|
5743
|
+
slug: "crimson-editorial",
|
|
5744
|
+
description: "High-energy Crimson & Violet palette for editorial media, e-commerce campaigns, and digital agencies",
|
|
5745
|
+
isActive: false,
|
|
5746
|
+
rawSemantic: {
|
|
5747
|
+
primary: "#e11d48",
|
|
5748
|
+
secondary: "#7c3aed",
|
|
5749
|
+
accent: "#f97316",
|
|
5750
|
+
success: "#10b981",
|
|
5751
|
+
warning: "#f59e0b",
|
|
5752
|
+
error: "#dc2626",
|
|
5753
|
+
info: "#6366f1",
|
|
5754
|
+
surface: "#ffffff",
|
|
5755
|
+
surfaceAlt: "#fff1f2",
|
|
5756
|
+
background: "#fafafa",
|
|
5757
|
+
textPrimary: "#18181b",
|
|
5758
|
+
textSecondary: "#52525b",
|
|
5759
|
+
border: "#e4e4e7"
|
|
5760
|
+
},
|
|
5761
|
+
rawCustom: [
|
|
5762
|
+
{ key: "brandGold", value: "#f97316", labels: { tr: "Kampanya Turuncusu", en: "Campaign Orange" } },
|
|
5763
|
+
{ key: "heroCyan", value: "rgb(168, 85, 247)", labels: { tr: "Neon Mor (RGB)", en: "Neon Purple (RGB)" } },
|
|
5764
|
+
{ key: "glassDark", value: "rgba(24, 24, 27, 0.80)", labels: { tr: "Antrasit Cam (RGBA)", en: "Charcoal Glass (RGBA)" } },
|
|
5765
|
+
{ key: "coralHighlight", value: "#f43f5e", labels: { tr: "Mercan Vurgu", en: "Coral Highlight" } }
|
|
5766
|
+
]
|
|
5767
|
+
}
|
|
5768
|
+
];
|
|
5769
|
+
function normalizePalettePayload(raw) {
|
|
5770
|
+
const semanticIn = raw?.semanticTokens && typeof raw.semanticTokens === "object" ? raw.semanticTokens : {};
|
|
5771
|
+
const semanticTokens = {};
|
|
5772
|
+
for (const meta of SEMANTIC_TOKEN_META) {
|
|
5773
|
+
const incoming = semanticIn[meta.key];
|
|
5774
|
+
const rawColor = typeof incoming === "string" ? incoming : incoming?.value || incoming?.hex || incoming?.rgb || "#4f46e5";
|
|
5775
|
+
semanticTokens[meta.key] = buildTokenEntry(
|
|
5776
|
+
rawColor,
|
|
5777
|
+
incoming?.labels || { tr: meta.tr, en: meta.en },
|
|
5778
|
+
{
|
|
5779
|
+
soft: incoming?.soft,
|
|
5780
|
+
contrast: incoming?.contrast
|
|
5781
|
+
}
|
|
5782
|
+
);
|
|
5783
|
+
}
|
|
5784
|
+
const customIn = Array.isArray(raw?.customTokens) ? raw.customTokens : [];
|
|
5785
|
+
const customTokens = customIn.filter((c) => c && typeof c.key === "string" && c.key.trim()).map((c) => {
|
|
5786
|
+
const cleanKey = String(c.key).trim().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
5787
|
+
const base = buildTokenEntry(
|
|
5788
|
+
c.value || c.hex || c.rgb || "#4f46e5",
|
|
5789
|
+
c.labels && typeof c.labels === "object" ? c.labels : { tr: cleanKey, en: cleanKey },
|
|
5790
|
+
{
|
|
5791
|
+
soft: c.soft,
|
|
5792
|
+
contrast: c.contrast
|
|
5793
|
+
}
|
|
5794
|
+
);
|
|
5795
|
+
return {
|
|
5796
|
+
key: cleanKey,
|
|
5797
|
+
...base,
|
|
5798
|
+
labels: c.labels && typeof c.labels === "object" ? c.labels : { tr: cleanKey, en: cleanKey }
|
|
5799
|
+
};
|
|
5800
|
+
});
|
|
5801
|
+
return {
|
|
5802
|
+
name: String(raw?.name || "Custom Theme Palette").trim(),
|
|
5803
|
+
slug: String(raw?.slug || raw?.name || "custom-palette").toLowerCase().replace(/[^a-z0-9-_]+/g, "-").replace(/^-+|-+$/g, "") || `palette-${Date.now()}`,
|
|
5804
|
+
description: String(raw?.description || "").trim(),
|
|
5805
|
+
isActive: Boolean(raw?.isActive),
|
|
5806
|
+
semanticTokens,
|
|
5807
|
+
customTokens
|
|
5808
|
+
};
|
|
5809
|
+
}
|
|
5810
|
+
function buildCssVariablesMap(palette) {
|
|
5811
|
+
const vars = {};
|
|
5812
|
+
if (!palette) return vars;
|
|
5813
|
+
const sem = palette.semanticTokens || {};
|
|
5814
|
+
for (const [key, entry] of Object.entries(sem)) {
|
|
5815
|
+
if (!entry) continue;
|
|
5816
|
+
const val = entry.value || entry.hex || "#4f46e5";
|
|
5817
|
+
vars[`--ci-color-${key}`] = val;
|
|
5818
|
+
if (entry.soft) vars[`--ci-color-${key}-soft`] = entry.soft;
|
|
5819
|
+
if (entry.contrast) vars[`--ci-color-${key}-contrast`] = entry.contrast;
|
|
5820
|
+
if (entry.hex) vars[`--ci-color-${key}-hex`] = entry.hex;
|
|
5821
|
+
if (entry.rgb) vars[`--ci-color-${key}-rgb`] = entry.rgb;
|
|
5822
|
+
}
|
|
5823
|
+
const cust = Array.isArray(palette.customTokens) ? palette.customTokens : [];
|
|
5824
|
+
for (const item of cust) {
|
|
5825
|
+
if (!item?.key) continue;
|
|
5826
|
+
const val = item.value || item.hex || "#4f46e5";
|
|
5827
|
+
vars[`--ci-color-${item.key}`] = val;
|
|
5828
|
+
if (item.soft) vars[`--ci-color-${item.key}-soft`] = item.soft;
|
|
5829
|
+
if (item.contrast) vars[`--ci-color-${item.key}-contrast`] = item.contrast;
|
|
5830
|
+
}
|
|
5831
|
+
return vars;
|
|
5832
|
+
}
|
|
5833
|
+
const ciColorService = ({ strapi }) => ({
|
|
5834
|
+
async ensureSeeded() {
|
|
5835
|
+
const existing = await strapi.db.query(PALETTE_UID).findMany({ limit: 50 });
|
|
5836
|
+
if (Array.isArray(existing) && existing.length > 0) {
|
|
5837
|
+
const hasActive = existing.some((p) => p.isActive);
|
|
5838
|
+
if (!hasActive && existing[0]?.id) {
|
|
5839
|
+
await strapi.db.query(PALETTE_UID).update({
|
|
5840
|
+
where: { id: existing[0].id },
|
|
5841
|
+
data: { isActive: true }
|
|
5842
|
+
});
|
|
5843
|
+
}
|
|
5844
|
+
return;
|
|
5845
|
+
}
|
|
5846
|
+
for (const seed of DEFAULT_PALETTE_SEEDS) {
|
|
5847
|
+
const semanticTokens = {};
|
|
5848
|
+
for (const meta of SEMANTIC_TOKEN_META) {
|
|
5849
|
+
const rawHex = seed.rawSemantic[meta.key] || "#4f46e5";
|
|
5850
|
+
semanticTokens[meta.key] = buildTokenEntry(rawHex, { tr: meta.tr, en: meta.en });
|
|
5851
|
+
}
|
|
5852
|
+
const customTokens = seed.rawCustom.map((c) => ({
|
|
5853
|
+
key: c.key,
|
|
5854
|
+
...buildTokenEntry(c.value, c.labels),
|
|
5855
|
+
labels: c.labels
|
|
5856
|
+
}));
|
|
5857
|
+
await strapi.db.query(PALETTE_UID).create({
|
|
5858
|
+
data: {
|
|
5859
|
+
name: seed.name,
|
|
5860
|
+
slug: seed.slug,
|
|
5861
|
+
description: seed.description,
|
|
5862
|
+
isActive: seed.isActive,
|
|
5863
|
+
semanticTokens,
|
|
5864
|
+
customTokens
|
|
5865
|
+
}
|
|
5866
|
+
});
|
|
5867
|
+
}
|
|
5868
|
+
},
|
|
5869
|
+
async findAll() {
|
|
5870
|
+
await this.ensureSeeded();
|
|
5871
|
+
const palettes = await strapi.db.query(PALETTE_UID).findMany({
|
|
5872
|
+
orderBy: { id: "asc" }
|
|
5873
|
+
});
|
|
5874
|
+
const active = palettes.find((p) => p.isActive) || palettes[0] || null;
|
|
5875
|
+
return {
|
|
5876
|
+
data: palettes,
|
|
5877
|
+
active,
|
|
5878
|
+
cssVariables: buildCssVariablesMap(active)
|
|
5879
|
+
};
|
|
5880
|
+
},
|
|
5881
|
+
async findActivePublic(slugOverride) {
|
|
5882
|
+
await this.ensureSeeded();
|
|
5883
|
+
const allPalettes = await strapi.db.query(PALETTE_UID).findMany({
|
|
5884
|
+
orderBy: { id: "asc" }
|
|
5885
|
+
});
|
|
5886
|
+
let palette = null;
|
|
5887
|
+
if (slugOverride) {
|
|
5888
|
+
palette = allPalettes.find((p) => p.slug === slugOverride) || null;
|
|
5889
|
+
}
|
|
5890
|
+
if (!palette) {
|
|
5891
|
+
palette = allPalettes.find((p) => p.isActive) || allPalettes[0] || null;
|
|
5892
|
+
}
|
|
5893
|
+
return {
|
|
5894
|
+
data: palette,
|
|
5895
|
+
palette,
|
|
5896
|
+
palettes: allPalettes.map((p) => ({
|
|
5897
|
+
name: p.name,
|
|
5898
|
+
slug: p.slug,
|
|
5899
|
+
isActive: Boolean(p.isActive),
|
|
5900
|
+
primary: p.semanticTokens?.primary?.value || p.semanticTokens?.primary?.hex || "#4f46e5",
|
|
5901
|
+
secondary: p.semanticTokens?.secondary?.value || p.semanticTokens?.secondary?.hex || "#0ea5e9",
|
|
5902
|
+
accent: p.semanticTokens?.accent?.value || p.semanticTokens?.accent?.hex || "#f59e0b"
|
|
5903
|
+
})),
|
|
5904
|
+
cssVariables: buildCssVariablesMap(palette)
|
|
5905
|
+
};
|
|
5906
|
+
},
|
|
5907
|
+
async save(payload) {
|
|
5908
|
+
await this.ensureSeeded();
|
|
5909
|
+
const normalized = normalizePalettePayload(payload);
|
|
5910
|
+
let existing = null;
|
|
5911
|
+
if (payload?.id) {
|
|
5912
|
+
existing = await strapi.db.query(PALETTE_UID).findOne({ where: { id: Number(payload.id) } });
|
|
5913
|
+
}
|
|
5914
|
+
if (!existing && payload?.documentId) {
|
|
5915
|
+
existing = await strapi.db.query(PALETTE_UID).findOne({ where: { documentId: payload.documentId } });
|
|
5916
|
+
}
|
|
5917
|
+
if (!existing && normalized.slug) {
|
|
5918
|
+
existing = await strapi.db.query(PALETTE_UID).findOne({ where: { slug: normalized.slug } });
|
|
5919
|
+
}
|
|
5920
|
+
if (normalized.isActive) {
|
|
5921
|
+
await strapi.db.query(PALETTE_UID).updateMany({
|
|
5922
|
+
where: { isActive: true },
|
|
5923
|
+
data: { isActive: false }
|
|
5924
|
+
});
|
|
5925
|
+
}
|
|
5926
|
+
let saved;
|
|
5927
|
+
if (existing) {
|
|
5928
|
+
saved = await strapi.db.query(PALETTE_UID).update({
|
|
5929
|
+
where: { id: existing.id },
|
|
5930
|
+
data: {
|
|
5931
|
+
...normalized,
|
|
5932
|
+
isActive: normalized.isActive || existing.isActive
|
|
5933
|
+
}
|
|
5934
|
+
});
|
|
5935
|
+
} else {
|
|
5936
|
+
saved = await strapi.db.query(PALETTE_UID).create({
|
|
5937
|
+
data: normalized
|
|
5938
|
+
});
|
|
5939
|
+
}
|
|
5940
|
+
return this.findAll().then((res) => ({
|
|
5941
|
+
...res,
|
|
5942
|
+
saved
|
|
5943
|
+
}));
|
|
5944
|
+
},
|
|
5945
|
+
async activate(idOrSlug) {
|
|
5946
|
+
await this.ensureSeeded();
|
|
5947
|
+
const str = String(idOrSlug).trim();
|
|
5948
|
+
let target = null;
|
|
5949
|
+
if (/^\d+$/.test(str)) {
|
|
5950
|
+
target = await strapi.db.query(PALETTE_UID).findOne({ where: { id: Number(str) } });
|
|
5951
|
+
}
|
|
5952
|
+
if (!target) {
|
|
5953
|
+
target = await strapi.db.query(PALETTE_UID).findOne({
|
|
5954
|
+
where: { $or: [{ slug: str }, { documentId: str }] }
|
|
5955
|
+
});
|
|
5956
|
+
}
|
|
5957
|
+
if (!target) return null;
|
|
5958
|
+
await strapi.db.query(PALETTE_UID).updateMany({
|
|
5959
|
+
where: { isActive: true },
|
|
5960
|
+
data: { isActive: false }
|
|
5961
|
+
});
|
|
5962
|
+
await strapi.db.query(PALETTE_UID).update({
|
|
5963
|
+
where: { id: target.id },
|
|
5964
|
+
data: { isActive: true }
|
|
5965
|
+
});
|
|
5966
|
+
return this.findAll();
|
|
5967
|
+
},
|
|
5968
|
+
async upsertQuickCustomToken(input) {
|
|
5969
|
+
await this.ensureSeeded();
|
|
5970
|
+
const { active } = await this.findActivePublic().then((r) => ({ active: r.data }));
|
|
5971
|
+
if (!active) return null;
|
|
5972
|
+
const cleanKey = String(input.key || input.label || "customColor").trim().replace(/[^a-zA-Z0-9_-]/g, "") || `color_${Date.now()}`;
|
|
5973
|
+
const labelStr = String(input.label || cleanKey).trim();
|
|
5974
|
+
const labels = input.labels && typeof input.labels === "object" ? input.labels : { tr: labelStr, en: labelStr };
|
|
5975
|
+
const tokenEntry = {
|
|
5976
|
+
key: cleanKey,
|
|
5977
|
+
...buildTokenEntry(input.value, labels),
|
|
5978
|
+
labels
|
|
5979
|
+
};
|
|
5980
|
+
const prevCustom = Array.isArray(active.customTokens) ? [...active.customTokens] : [];
|
|
5981
|
+
const idx = prevCustom.findIndex((t) => t.key === cleanKey);
|
|
5982
|
+
if (idx >= 0) {
|
|
5983
|
+
prevCustom[idx] = tokenEntry;
|
|
5984
|
+
} else {
|
|
5985
|
+
prevCustom.push(tokenEntry);
|
|
5986
|
+
}
|
|
5987
|
+
await strapi.db.query(PALETTE_UID).update({
|
|
5988
|
+
where: { id: active.id },
|
|
5989
|
+
data: { customTokens: prevCustom }
|
|
5990
|
+
});
|
|
5991
|
+
return {
|
|
5992
|
+
...await this.findAll(),
|
|
5993
|
+
addedToken: tokenEntry
|
|
5994
|
+
};
|
|
5995
|
+
},
|
|
5996
|
+
async remove(idOrSlug) {
|
|
5997
|
+
const str = String(idOrSlug).trim();
|
|
5998
|
+
const all = await strapi.db.query(PALETTE_UID).findMany();
|
|
5999
|
+
if (all.length <= 1) {
|
|
6000
|
+
throw new Error("Cannot delete the last remaining color palette");
|
|
6001
|
+
}
|
|
6002
|
+
const target = all.find(
|
|
6003
|
+
(p) => String(p.id) === str || p.slug === str || p.documentId === str
|
|
6004
|
+
);
|
|
6005
|
+
if (!target) return this.findAll();
|
|
6006
|
+
await strapi.db.query(PALETTE_UID).delete({ where: { id: target.id } });
|
|
6007
|
+
if (target.isActive) {
|
|
6008
|
+
const remaining = await strapi.db.query(PALETTE_UID).findMany({ limit: 1 });
|
|
6009
|
+
if (remaining[0]) {
|
|
6010
|
+
await strapi.db.query(PALETTE_UID).update({
|
|
6011
|
+
where: { id: remaining[0].id },
|
|
6012
|
+
data: { isActive: true }
|
|
6013
|
+
});
|
|
6014
|
+
}
|
|
6015
|
+
}
|
|
6016
|
+
return this.findAll();
|
|
6017
|
+
},
|
|
6018
|
+
/**
|
|
6019
|
+
* Safe public collection query for Data Table (`sourceMode: 'strapi_collection'`)
|
|
6020
|
+
*/
|
|
6021
|
+
async queryCollectionForDataTable(params) {
|
|
6022
|
+
const uid = String(params.uid || "").trim();
|
|
6023
|
+
if (!uid.startsWith("api::")) {
|
|
6024
|
+
return { columns: [], rows: [] };
|
|
6025
|
+
}
|
|
6026
|
+
const ct = strapi.contentTypes[uid];
|
|
6027
|
+
if (!ct) {
|
|
6028
|
+
return { columns: [], rows: [] };
|
|
6029
|
+
}
|
|
6030
|
+
const attrs = ct.attributes || {};
|
|
6031
|
+
const forbiddenTypes = /* @__PURE__ */ new Set(["password", "dynamiczone", "component", "relation"]);
|
|
6032
|
+
const allowedFields = [
|
|
6033
|
+
{ key: "documentId", type: "text" }
|
|
6034
|
+
];
|
|
6035
|
+
for (const [fieldName, attr] of Object.entries(attrs)) {
|
|
6036
|
+
if (!attr || attr.private) continue;
|
|
6037
|
+
if (/password|secret|token|hash/i.test(fieldName)) continue;
|
|
6038
|
+
if (attr.customField === "plugin::content-input.content-input") continue;
|
|
6039
|
+
if (forbiddenTypes.has(attr.type)) continue;
|
|
6040
|
+
allowedFields.push({ key: fieldName, type: attr.type || "string" });
|
|
6041
|
+
}
|
|
6042
|
+
for (const sysKey of ["createdAt", "updatedAt", "publishedAt"]) {
|
|
6043
|
+
if (!allowedFields.some((f) => f.key === sysKey)) {
|
|
6044
|
+
allowedFields.push({ key: sysKey, type: "datetime" });
|
|
6045
|
+
}
|
|
6046
|
+
}
|
|
6047
|
+
if (!allowedFields.some((f) => f.key === "collectionLabel")) {
|
|
6048
|
+
allowedFields.push({ key: "collectionLabel", type: "enumeration" });
|
|
6049
|
+
}
|
|
6050
|
+
if (attrs.slug && !allowedFields.some((f) => f.key === "url")) {
|
|
6051
|
+
allowedFields.push({ key: "url", type: "uid" });
|
|
6052
|
+
}
|
|
6053
|
+
const limit = clamp(Number(params.limit) || 25, 1, 100);
|
|
6054
|
+
let entries = [];
|
|
6055
|
+
try {
|
|
6056
|
+
const docService = strapi.documents?.(uid);
|
|
6057
|
+
if (docService) {
|
|
6058
|
+
entries = await docService.findMany({
|
|
6059
|
+
status: "published",
|
|
6060
|
+
limit,
|
|
6061
|
+
sort: params.sort || "createdAt:desc",
|
|
6062
|
+
populate: "*"
|
|
6063
|
+
});
|
|
6064
|
+
if (!entries.length) {
|
|
6065
|
+
entries = await docService.findMany({
|
|
6066
|
+
limit,
|
|
6067
|
+
sort: params.sort || "createdAt:desc",
|
|
6068
|
+
populate: "*"
|
|
6069
|
+
});
|
|
6070
|
+
}
|
|
6071
|
+
} else {
|
|
6072
|
+
entries = await strapi.db.query(uid).findMany({ limit, populate: true });
|
|
6073
|
+
}
|
|
6074
|
+
} catch {
|
|
6075
|
+
entries = [];
|
|
6076
|
+
}
|
|
6077
|
+
const collectionLabelText = ct.info?.displayName || uid;
|
|
6078
|
+
const sanitizedRows = (entries || []).map((entry) => {
|
|
6079
|
+
const row = {};
|
|
6080
|
+
for (const f of allowedFields) {
|
|
6081
|
+
if (f.key === "collectionLabel" && entry.collectionLabel === void 0) {
|
|
6082
|
+
row.collectionLabel = collectionLabelText;
|
|
6083
|
+
continue;
|
|
6084
|
+
}
|
|
6085
|
+
if (f.key === "url" && entry.url === void 0) {
|
|
6086
|
+
const slugStr = entry.slug ? String(entry.slug).trim() : "";
|
|
6087
|
+
row.url = slugStr ? slugStr === "home" ? "/" : `/${slugStr.replace(/^\/+/, "")}` : "";
|
|
6088
|
+
continue;
|
|
6089
|
+
}
|
|
6090
|
+
const val = entry[f.key];
|
|
6091
|
+
if (val !== null && val !== void 0 && typeof val === "object") {
|
|
6092
|
+
if (Array.isArray(val)) {
|
|
6093
|
+
row[f.key] = val[0]?.url || `${val.length} item`;
|
|
6094
|
+
} else if (val.url) {
|
|
6095
|
+
row[f.key] = val.url;
|
|
6096
|
+
} else {
|
|
6097
|
+
row[f.key] = "";
|
|
6098
|
+
}
|
|
6099
|
+
} else {
|
|
6100
|
+
row[f.key] = val ?? "";
|
|
6101
|
+
}
|
|
6102
|
+
}
|
|
6103
|
+
return row;
|
|
6104
|
+
});
|
|
6105
|
+
return {
|
|
6106
|
+
uid,
|
|
6107
|
+
displayName: ct.info?.displayName || uid,
|
|
6108
|
+
availableFields: allowedFields,
|
|
6109
|
+
rows: sanitizedRows
|
|
6110
|
+
};
|
|
6111
|
+
},
|
|
6112
|
+
/**
|
|
6113
|
+
* Batch Entity Cards resolver for `entityCard` Swiper Carousel & Grid modes
|
|
6114
|
+
*/
|
|
6115
|
+
async resolveEntityCardsBatch(params) {
|
|
6116
|
+
const uid = String(params.uid || "api::page.page").trim();
|
|
6117
|
+
if (!uid.startsWith("api::")) return [];
|
|
6118
|
+
const formSvc = strapi.plugin("content-input").service("ci-form");
|
|
6119
|
+
const docIds = Array.isArray(params.documentIds) ? params.documentIds.map((s) => String(s).trim()).filter(Boolean) : [];
|
|
6120
|
+
if (docIds.length > 0) {
|
|
6121
|
+
const results = await Promise.all(
|
|
6122
|
+
docIds.map(
|
|
6123
|
+
(documentId) => formSvc.resolveEntityCard({ uid, documentId }).catch(() => null)
|
|
6124
|
+
)
|
|
6125
|
+
);
|
|
6126
|
+
return results.filter(Boolean);
|
|
6127
|
+
}
|
|
6128
|
+
const limit = clamp(Number(params.limit) || 6, 1, 24);
|
|
6129
|
+
try {
|
|
6130
|
+
const docService = strapi.documents?.(uid);
|
|
6131
|
+
let entries = [];
|
|
6132
|
+
if (docService) {
|
|
6133
|
+
entries = await docService.findMany({ status: "published", limit, sort: "createdAt:desc" });
|
|
6134
|
+
if (!entries.length) {
|
|
6135
|
+
entries = await docService.findMany({ limit, sort: "createdAt:desc" });
|
|
6136
|
+
}
|
|
6137
|
+
} else {
|
|
6138
|
+
entries = await strapi.db.query(uid).findMany({ limit });
|
|
6139
|
+
}
|
|
6140
|
+
const uniqueDocIds = Array.from(
|
|
6141
|
+
new Set(entries.map((e) => e.documentId).filter(Boolean))
|
|
6142
|
+
);
|
|
6143
|
+
const cards = await Promise.all(
|
|
6144
|
+
uniqueDocIds.slice(0, limit).map(
|
|
6145
|
+
(documentId) => formSvc.resolveEntityCard({ uid, documentId }).catch(() => null)
|
|
6146
|
+
)
|
|
6147
|
+
);
|
|
6148
|
+
return cards.filter(Boolean);
|
|
6149
|
+
} catch {
|
|
6150
|
+
return [];
|
|
6151
|
+
}
|
|
6152
|
+
}
|
|
6153
|
+
});
|
|
5271
6154
|
const services = {
|
|
5272
6155
|
"ci-template": ciTemplateService,
|
|
5273
6156
|
"ci-menu": ciMenuService,
|
|
5274
6157
|
"ci-form": ciFormService,
|
|
5275
|
-
"ci-survey": ciSurveyService
|
|
6158
|
+
"ci-survey": ciSurveyService,
|
|
6159
|
+
"ci-color": ciColorService
|
|
5276
6160
|
};
|
|
5277
6161
|
const index = {
|
|
5278
6162
|
register,
|