@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.mjs
CHANGED
|
@@ -13,9 +13,25 @@ const register = ({ strapi }) => {
|
|
|
13
13
|
isResizable: false
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
+
if (strapi?.server?.use) {
|
|
17
|
+
strapi.server.use(async (ctx, next) => {
|
|
18
|
+
await next();
|
|
19
|
+
const csp = ctx?.response?.get?.("Content-Security-Policy");
|
|
20
|
+
if (typeof csp === "string" && csp.includes("frame-src")) {
|
|
21
|
+
const updated = csp.replace(/frame-src\s+([^;]+)/i, (match, sources) => {
|
|
22
|
+
if (sources.includes("https:") || sources.includes("*")) return match;
|
|
23
|
+
return `frame-src ${sources.trim()} https: http: data: blob:`;
|
|
24
|
+
});
|
|
25
|
+
if (updated !== csp) {
|
|
26
|
+
ctx.set("Content-Security-Policy", updated);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
16
31
|
};
|
|
17
32
|
const bootstrap = async ({ strapi }) => {
|
|
18
33
|
try {
|
|
34
|
+
await strapi.plugin("content-input").service("ci-color").ensureSeeded();
|
|
19
35
|
await strapi.plugin("content-input").service("ci-form").ensureSeeded();
|
|
20
36
|
await strapi.plugin("content-input").service("ci-survey").ensureSeeded(false);
|
|
21
37
|
} catch (err) {
|
|
@@ -31,13 +47,27 @@ const config = {
|
|
|
31
47
|
validator() {
|
|
32
48
|
}
|
|
33
49
|
};
|
|
50
|
+
const kind$6 = "collectionType";
|
|
51
|
+
const collectionName$6 = "ci_templates";
|
|
52
|
+
const info$6 = { "singularName": "ci-template", "pluralName": "ci-templates", "displayName": "ContentInput Template", "description": "Saved visual editor row/section templates" };
|
|
53
|
+
const options$6 = { "draftAndPublish": false };
|
|
54
|
+
const pluginOptions$6 = { "content-manager": { "visible": false }, "content-type-builder": { "visible": false } };
|
|
55
|
+
const attributes$6 = { "name": { "type": "string", "required": true }, "category": { "type": "string", "default": "custom" }, "structure": { "type": "json", "required": true }, "thumbnail": { "type": "string", "default": "" } };
|
|
56
|
+
const templateSchema = {
|
|
57
|
+
kind: kind$6,
|
|
58
|
+
collectionName: collectionName$6,
|
|
59
|
+
info: info$6,
|
|
60
|
+
options: options$6,
|
|
61
|
+
pluginOptions: pluginOptions$6,
|
|
62
|
+
attributes: attributes$6
|
|
63
|
+
};
|
|
34
64
|
const kind$5 = "collectionType";
|
|
35
|
-
const collectionName$5 = "
|
|
36
|
-
const info$5 = { "singularName": "ci-
|
|
65
|
+
const collectionName$5 = "ci_menus";
|
|
66
|
+
const info$5 = { "singularName": "ci-menu", "pluralName": "ci-menus", "displayName": "ContentInput Menu", "description": "Reusable nested menus (horizontal & vertical) for ContentInput" };
|
|
37
67
|
const options$5 = { "draftAndPublish": false };
|
|
38
68
|
const pluginOptions$5 = { "content-manager": { "visible": false }, "content-type-builder": { "visible": false } };
|
|
39
|
-
const attributes$5 = { "name": { "type": "string", "required": true }, "
|
|
40
|
-
const
|
|
69
|
+
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" } };
|
|
70
|
+
const menuSchema = {
|
|
41
71
|
kind: kind$5,
|
|
42
72
|
collectionName: collectionName$5,
|
|
43
73
|
info: info$5,
|
|
@@ -46,12 +76,12 @@ const templateSchema = {
|
|
|
46
76
|
attributes: attributes$5
|
|
47
77
|
};
|
|
48
78
|
const kind$4 = "collectionType";
|
|
49
|
-
const collectionName$4 = "
|
|
50
|
-
const info$4 = { "singularName": "ci-
|
|
79
|
+
const collectionName$4 = "ci_forms";
|
|
80
|
+
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" };
|
|
51
81
|
const options$4 = { "draftAndPublish": false };
|
|
52
|
-
const pluginOptions$4 = { "content-manager": { "visible":
|
|
53
|
-
const attributes$4 = { "
|
|
54
|
-
const
|
|
82
|
+
const pluginOptions$4 = { "content-manager": { "visible": true }, "content-type-builder": { "visible": false } };
|
|
83
|
+
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 } };
|
|
84
|
+
const formSchema = {
|
|
55
85
|
kind: kind$4,
|
|
56
86
|
collectionName: collectionName$4,
|
|
57
87
|
info: info$4,
|
|
@@ -60,12 +90,12 @@ const menuSchema = {
|
|
|
60
90
|
attributes: attributes$4
|
|
61
91
|
};
|
|
62
92
|
const kind$3 = "collectionType";
|
|
63
|
-
const collectionName$3 = "
|
|
64
|
-
const info$3 = { "singularName": "ci-form", "pluralName": "ci-
|
|
93
|
+
const collectionName$3 = "ci_form_submissions";
|
|
94
|
+
const info$3 = { "singularName": "ci-form-submission", "pluralName": "ci-form-submissions", "displayName": "ContentInput Form Submission", "description": "Submitted entries from ContentInput dynamic forms" };
|
|
65
95
|
const options$3 = { "draftAndPublish": false };
|
|
66
96
|
const pluginOptions$3 = { "content-manager": { "visible": true }, "content-type-builder": { "visible": false } };
|
|
67
|
-
const attributes$3 = { "
|
|
68
|
-
const
|
|
97
|
+
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" } };
|
|
98
|
+
const formSubmissionSchema = {
|
|
69
99
|
kind: kind$3,
|
|
70
100
|
collectionName: collectionName$3,
|
|
71
101
|
info: info$3,
|
|
@@ -74,12 +104,12 @@ const formSchema = {
|
|
|
74
104
|
attributes: attributes$3
|
|
75
105
|
};
|
|
76
106
|
const kind$2 = "collectionType";
|
|
77
|
-
const collectionName$2 = "
|
|
78
|
-
const info$2 = { "singularName": "ci-
|
|
107
|
+
const collectionName$2 = "ci_surveys";
|
|
108
|
+
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" };
|
|
79
109
|
const options$2 = { "draftAndPublish": false };
|
|
80
110
|
const pluginOptions$2 = { "content-manager": { "visible": true }, "content-type-builder": { "visible": false } };
|
|
81
|
-
const attributes$2 = { "
|
|
82
|
-
const
|
|
111
|
+
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 } };
|
|
112
|
+
const surveySchema = {
|
|
83
113
|
kind: kind$2,
|
|
84
114
|
collectionName: collectionName$2,
|
|
85
115
|
info: info$2,
|
|
@@ -88,12 +118,12 @@ const formSubmissionSchema = {
|
|
|
88
118
|
attributes: attributes$2
|
|
89
119
|
};
|
|
90
120
|
const kind$1 = "collectionType";
|
|
91
|
-
const collectionName$1 = "
|
|
92
|
-
const info$1 = { "singularName": "ci-survey", "pluralName": "ci-
|
|
121
|
+
const collectionName$1 = "ci_survey_responses";
|
|
122
|
+
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" };
|
|
93
123
|
const options$1 = { "draftAndPublish": false };
|
|
94
124
|
const pluginOptions$1 = { "content-manager": { "visible": true }, "content-type-builder": { "visible": false } };
|
|
95
|
-
const attributes$1 = { "
|
|
96
|
-
const
|
|
125
|
+
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" } };
|
|
126
|
+
const surveyResponseSchema = {
|
|
97
127
|
kind: kind$1,
|
|
98
128
|
collectionName: collectionName$1,
|
|
99
129
|
info: info$1,
|
|
@@ -102,12 +132,12 @@ const surveySchema = {
|
|
|
102
132
|
attributes: attributes$1
|
|
103
133
|
};
|
|
104
134
|
const kind = "collectionType";
|
|
105
|
-
const collectionName = "
|
|
106
|
-
const info = { "singularName": "ci-
|
|
135
|
+
const collectionName = "ci_color_palettes";
|
|
136
|
+
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)" };
|
|
107
137
|
const options = { "draftAndPublish": false };
|
|
108
|
-
const pluginOptions = { "content-manager": { "visible":
|
|
109
|
-
const attributes = { "
|
|
110
|
-
const
|
|
138
|
+
const pluginOptions = { "content-manager": { "visible": false }, "content-type-builder": { "visible": false } };
|
|
139
|
+
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": [] } };
|
|
140
|
+
const colorPaletteSchema = {
|
|
111
141
|
kind,
|
|
112
142
|
collectionName,
|
|
113
143
|
info,
|
|
@@ -133,6 +163,9 @@ const contentTypes = {
|
|
|
133
163
|
},
|
|
134
164
|
"ci-survey-response": {
|
|
135
165
|
schema: surveyResponseSchema
|
|
166
|
+
},
|
|
167
|
+
"ci-color-palette": {
|
|
168
|
+
schema: colorPaletteSchema
|
|
136
169
|
}
|
|
137
170
|
};
|
|
138
171
|
const ciTemplateController = ({ strapi }) => ({
|
|
@@ -146,7 +179,11 @@ const ciTemplateController = ({ strapi }) => ({
|
|
|
146
179
|
},
|
|
147
180
|
async save(ctx) {
|
|
148
181
|
try {
|
|
149
|
-
const
|
|
182
|
+
const body = ctx.request.body || {};
|
|
183
|
+
const name = body.name;
|
|
184
|
+
const structure = body.structure ?? body.rows;
|
|
185
|
+
const category = body.category;
|
|
186
|
+
const thumbnail = body.thumbnail;
|
|
150
187
|
if (!name || !structure) {
|
|
151
188
|
return ctx.badRequest("Name and structure are required");
|
|
152
189
|
}
|
|
@@ -753,9 +790,8 @@ const ciFormController = ({ strapi }) => ({
|
|
|
753
790
|
const { id } = ctx.params;
|
|
754
791
|
const rawBody = ctx.request.body || {};
|
|
755
792
|
const payload = rawBody && typeof rawBody.data === "object" && !Array.isArray(rawBody.data) && Object.keys(rawBody).length === 1 ? rawBody.data : rawBody;
|
|
756
|
-
const
|
|
757
|
-
const
|
|
758
|
-
const inferredLocale = (queryLocale || acceptLang || "tr").toLowerCase();
|
|
793
|
+
const queryLocale = String(ctx.query?.locale || payload?._locale || "").trim();
|
|
794
|
+
const inferredLocale = (queryLocale || "en").toLowerCase();
|
|
759
795
|
const ip = String(ctx.request.headers?.["x-forwarded-for"] || "").split(",")[0].trim() || ctx.request.ip || "";
|
|
760
796
|
const userAgent = String(ctx.request.headers?.["user-agent"] || "");
|
|
761
797
|
const result = await strapi.plugin("content-input").service("ci-form").submitForm(id, payload, {
|
|
@@ -863,7 +899,7 @@ const ciSurveyController = ({ strapi }) => ({
|
|
|
863
899
|
const payload = rawBody && typeof rawBody.data === "object" && !Array.isArray(rawBody.data) && Object.keys(rawBody).length === 1 ? rawBody.data : rawBody;
|
|
864
900
|
const acceptLang = String(ctx.request.headers?.["accept-language"] || "").split(",")[0].split(";")[0].trim();
|
|
865
901
|
const queryLocale = String(ctx.query?.locale || "").trim();
|
|
866
|
-
const inferredLocale = (queryLocale || acceptLang || "
|
|
902
|
+
const inferredLocale = (queryLocale || acceptLang || "en").toLowerCase();
|
|
867
903
|
const ip = String(ctx.request.headers?.["x-forwarded-for"] || "").split(",")[0].trim() || ctx.request.ip || "";
|
|
868
904
|
const userAgent = String(ctx.request.headers?.["user-agent"] || "");
|
|
869
905
|
const result = await strapi.plugin("content-input").service("ci-survey").submitSurvey(id, payload, {
|
|
@@ -918,7 +954,7 @@ const ciSurveyController = ({ strapi }) => ({
|
|
|
918
954
|
try {
|
|
919
955
|
const { id } = ctx.params;
|
|
920
956
|
const format = String(ctx.query?.format || "csv").toLowerCase() === "json" ? "json" : "csv";
|
|
921
|
-
const locale = String(ctx.query?.locale || "
|
|
957
|
+
const locale = String(ctx.query?.locale || "en").trim();
|
|
922
958
|
const from = ctx.query?.from ? String(ctx.query.from) : void 0;
|
|
923
959
|
const to = ctx.query?.to ? String(ctx.query.to) : void 0;
|
|
924
960
|
const exported = await strapi.plugin("content-input").service("ci-survey").exportResponses(id, { format, locale, from, to });
|
|
@@ -942,12 +978,112 @@ const ciSurveyController = ({ strapi }) => ({
|
|
|
942
978
|
}
|
|
943
979
|
}
|
|
944
980
|
});
|
|
981
|
+
const ciColorController = ({ strapi }) => ({
|
|
982
|
+
async indexAdmin(ctx) {
|
|
983
|
+
try {
|
|
984
|
+
const res = await strapi.plugin("content-input").service("ci-color").findAll();
|
|
985
|
+
ctx.body = res;
|
|
986
|
+
} catch (err) {
|
|
987
|
+
ctx.throw(500, err);
|
|
988
|
+
}
|
|
989
|
+
},
|
|
990
|
+
async activePublic(ctx) {
|
|
991
|
+
try {
|
|
992
|
+
const slug = ctx.query?.slug ? String(ctx.query.slug) : void 0;
|
|
993
|
+
const res = await strapi.plugin("content-input").service("ci-color").findActivePublic(slug);
|
|
994
|
+
ctx.body = res;
|
|
995
|
+
} catch (err) {
|
|
996
|
+
ctx.throw(500, err);
|
|
997
|
+
}
|
|
998
|
+
},
|
|
999
|
+
async save(ctx) {
|
|
1000
|
+
try {
|
|
1001
|
+
const body = ctx.request.body || {};
|
|
1002
|
+
const res = await strapi.plugin("content-input").service("ci-color").save(body);
|
|
1003
|
+
ctx.body = res;
|
|
1004
|
+
} catch (err) {
|
|
1005
|
+
ctx.throw(500, err);
|
|
1006
|
+
}
|
|
1007
|
+
},
|
|
1008
|
+
async activate(ctx) {
|
|
1009
|
+
try {
|
|
1010
|
+
const { id } = ctx.params || {};
|
|
1011
|
+
const res = await strapi.plugin("content-input").service("ci-color").activate(id);
|
|
1012
|
+
if (!res) {
|
|
1013
|
+
return ctx.notFound("Color palette not found");
|
|
1014
|
+
}
|
|
1015
|
+
ctx.body = res;
|
|
1016
|
+
} catch (err) {
|
|
1017
|
+
ctx.throw(500, err);
|
|
1018
|
+
}
|
|
1019
|
+
},
|
|
1020
|
+
async quickToken(ctx) {
|
|
1021
|
+
try {
|
|
1022
|
+
const body = ctx.request.body || {};
|
|
1023
|
+
if (!body.value) {
|
|
1024
|
+
return ctx.badRequest("Color value (HEX or RGB/RGBA) is required");
|
|
1025
|
+
}
|
|
1026
|
+
const res = await strapi.plugin("content-input").service("ci-color").upsertQuickCustomToken({
|
|
1027
|
+
key: body.key || body.label || "customColor",
|
|
1028
|
+
label: body.label,
|
|
1029
|
+
labels: body.labels,
|
|
1030
|
+
value: body.value
|
|
1031
|
+
});
|
|
1032
|
+
ctx.body = res;
|
|
1033
|
+
} catch (err) {
|
|
1034
|
+
ctx.throw(500, err);
|
|
1035
|
+
}
|
|
1036
|
+
},
|
|
1037
|
+
async delete(ctx) {
|
|
1038
|
+
try {
|
|
1039
|
+
const { id } = ctx.params || {};
|
|
1040
|
+
const res = await strapi.plugin("content-input").service("ci-color").remove(id);
|
|
1041
|
+
ctx.body = res;
|
|
1042
|
+
} catch (err) {
|
|
1043
|
+
ctx.badRequest(err?.message || "Unable to delete palette");
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
1046
|
+
async dataTableCollection(ctx) {
|
|
1047
|
+
try {
|
|
1048
|
+
const { uid, limit, sort } = ctx.query || {};
|
|
1049
|
+
if (!uid) {
|
|
1050
|
+
return ctx.badRequest('Query parameter "uid" is required');
|
|
1051
|
+
}
|
|
1052
|
+
const res = await strapi.plugin("content-input").service("ci-color").queryCollectionForDataTable({
|
|
1053
|
+
uid: String(uid),
|
|
1054
|
+
limit: limit ? Number(limit) : 25,
|
|
1055
|
+
sort: sort ? String(sort) : "createdAt:desc"
|
|
1056
|
+
});
|
|
1057
|
+
ctx.body = { data: res };
|
|
1058
|
+
} catch (err) {
|
|
1059
|
+
ctx.throw(500, err);
|
|
1060
|
+
}
|
|
1061
|
+
},
|
|
1062
|
+
async entityCardsBatch(ctx) {
|
|
1063
|
+
try {
|
|
1064
|
+
const { uid, documentIds, limit } = ctx.query || {};
|
|
1065
|
+
if (!uid) {
|
|
1066
|
+
return ctx.badRequest('Query parameter "uid" is required');
|
|
1067
|
+
}
|
|
1068
|
+
const docList = typeof documentIds === "string" && documentIds.trim() ? documentIds.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
1069
|
+
const items = await strapi.plugin("content-input").service("ci-color").resolveEntityCardsBatch({
|
|
1070
|
+
uid: String(uid),
|
|
1071
|
+
documentIds: docList,
|
|
1072
|
+
limit: limit ? Number(limit) : 6
|
|
1073
|
+
});
|
|
1074
|
+
ctx.body = { data: items };
|
|
1075
|
+
} catch (err) {
|
|
1076
|
+
ctx.throw(500, err);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
945
1080
|
const controllers = {
|
|
946
1081
|
"ci-template": ciTemplateController,
|
|
947
1082
|
"ci-menu": ciMenuController,
|
|
948
1083
|
"ci-image": ciImageController,
|
|
949
1084
|
"ci-form": ciFormController,
|
|
950
|
-
"ci-survey": ciSurveyController
|
|
1085
|
+
"ci-survey": ciSurveyController,
|
|
1086
|
+
"ci-color": ciColorController
|
|
951
1087
|
};
|
|
952
1088
|
const routes = {
|
|
953
1089
|
admin: {
|
|
@@ -1033,6 +1169,62 @@ const routes = {
|
|
|
1033
1169
|
policies: []
|
|
1034
1170
|
}
|
|
1035
1171
|
},
|
|
1172
|
+
{
|
|
1173
|
+
method: "GET",
|
|
1174
|
+
path: "/entity-cards",
|
|
1175
|
+
handler: "ci-color.entityCardsBatch",
|
|
1176
|
+
config: {
|
|
1177
|
+
policies: []
|
|
1178
|
+
}
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
method: "GET",
|
|
1182
|
+
path: "/data-table",
|
|
1183
|
+
handler: "ci-color.dataTableCollection",
|
|
1184
|
+
config: {
|
|
1185
|
+
policies: []
|
|
1186
|
+
}
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
method: "GET",
|
|
1190
|
+
path: "/color-codes",
|
|
1191
|
+
handler: "ci-color.indexAdmin",
|
|
1192
|
+
config: {
|
|
1193
|
+
policies: []
|
|
1194
|
+
}
|
|
1195
|
+
},
|
|
1196
|
+
{
|
|
1197
|
+
method: "POST",
|
|
1198
|
+
path: "/color-codes",
|
|
1199
|
+
handler: "ci-color.save",
|
|
1200
|
+
config: {
|
|
1201
|
+
policies: []
|
|
1202
|
+
}
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
method: "POST",
|
|
1206
|
+
path: "/color-codes/quick-token",
|
|
1207
|
+
handler: "ci-color.quickToken",
|
|
1208
|
+
config: {
|
|
1209
|
+
policies: []
|
|
1210
|
+
}
|
|
1211
|
+
},
|
|
1212
|
+
{
|
|
1213
|
+
method: "POST",
|
|
1214
|
+
path: "/color-codes/:id/activate",
|
|
1215
|
+
handler: "ci-color.activate",
|
|
1216
|
+
config: {
|
|
1217
|
+
policies: []
|
|
1218
|
+
}
|
|
1219
|
+
},
|
|
1220
|
+
{
|
|
1221
|
+
method: "DELETE",
|
|
1222
|
+
path: "/color-codes/:id",
|
|
1223
|
+
handler: "ci-color.delete",
|
|
1224
|
+
config: {
|
|
1225
|
+
policies: []
|
|
1226
|
+
}
|
|
1227
|
+
},
|
|
1036
1228
|
{
|
|
1037
1229
|
method: "GET",
|
|
1038
1230
|
path: "/forms",
|
|
@@ -1297,6 +1489,33 @@ const routes = {
|
|
|
1297
1489
|
auth: false,
|
|
1298
1490
|
policies: []
|
|
1299
1491
|
}
|
|
1492
|
+
},
|
|
1493
|
+
{
|
|
1494
|
+
method: "GET",
|
|
1495
|
+
path: "/entity-cards",
|
|
1496
|
+
handler: "ci-color.entityCardsBatch",
|
|
1497
|
+
config: {
|
|
1498
|
+
auth: false,
|
|
1499
|
+
policies: []
|
|
1500
|
+
}
|
|
1501
|
+
},
|
|
1502
|
+
{
|
|
1503
|
+
method: "GET",
|
|
1504
|
+
path: "/data-table",
|
|
1505
|
+
handler: "ci-color.dataTableCollection",
|
|
1506
|
+
config: {
|
|
1507
|
+
auth: false,
|
|
1508
|
+
policies: []
|
|
1509
|
+
}
|
|
1510
|
+
},
|
|
1511
|
+
{
|
|
1512
|
+
method: "GET",
|
|
1513
|
+
path: "/color-codes",
|
|
1514
|
+
handler: "ci-color.activePublic",
|
|
1515
|
+
config: {
|
|
1516
|
+
auth: false,
|
|
1517
|
+
policies: []
|
|
1518
|
+
}
|
|
1300
1519
|
}
|
|
1301
1520
|
]
|
|
1302
1521
|
}
|
|
@@ -1313,7 +1532,7 @@ const ciTemplateService = ({ strapi }) => ({
|
|
|
1313
1532
|
}));
|
|
1314
1533
|
},
|
|
1315
1534
|
async create(data) {
|
|
1316
|
-
const structure = Array.isArray(data.structure) ? data.structure : [data.structure];
|
|
1535
|
+
const structure = data.category === "card_design" ? data.structure : Array.isArray(data.structure) ? data.structure : [data.structure];
|
|
1317
1536
|
const created = await strapi.db.query(UID).create({
|
|
1318
1537
|
data: {
|
|
1319
1538
|
name: String(data.name || "").trim(),
|
|
@@ -1361,7 +1580,7 @@ function slugifyTR(text) {
|
|
|
1361
1580
|
}
|
|
1362
1581
|
const DEFAULT_SEED_MENUS = [
|
|
1363
1582
|
{
|
|
1364
|
-
name: "
|
|
1583
|
+
name: "Main Header Navigation",
|
|
1365
1584
|
slug: "main-header-menu",
|
|
1366
1585
|
mode: "horizontal",
|
|
1367
1586
|
options: {
|
|
@@ -1373,7 +1592,7 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1373
1592
|
items: [
|
|
1374
1593
|
{
|
|
1375
1594
|
_uId: "m_home",
|
|
1376
|
-
title: "Ana Sayfa",
|
|
1595
|
+
title: { en: "Home", tr: "Ana Sayfa" },
|
|
1377
1596
|
url: "/",
|
|
1378
1597
|
type: "custom",
|
|
1379
1598
|
target: "_self",
|
|
@@ -1382,31 +1601,31 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1382
1601
|
},
|
|
1383
1602
|
{
|
|
1384
1603
|
_uId: "m_corp",
|
|
1385
|
-
title: "Kurumsal",
|
|
1386
|
-
url: "/
|
|
1604
|
+
title: { en: "Company", tr: "Kurumsal" },
|
|
1605
|
+
url: "/company",
|
|
1387
1606
|
type: "custom",
|
|
1388
1607
|
target: "_self",
|
|
1389
1608
|
icon: "business",
|
|
1390
1609
|
children: [
|
|
1391
1610
|
{
|
|
1392
1611
|
_uId: "m_about",
|
|
1393
|
-
title: "Hakkımızda",
|
|
1394
|
-
url: "/
|
|
1612
|
+
title: { en: "About Us", tr: "Hakkımızda" },
|
|
1613
|
+
url: "/company/about",
|
|
1395
1614
|
type: "custom",
|
|
1396
1615
|
target: "_self",
|
|
1397
1616
|
children: []
|
|
1398
1617
|
},
|
|
1399
1618
|
{
|
|
1400
1619
|
_uId: "m_vision",
|
|
1401
|
-
title: "Vizyon & Misyon",
|
|
1402
|
-
url: "/
|
|
1620
|
+
title: { en: "Vision & Mission", tr: "Vizyon & Misyon" },
|
|
1621
|
+
url: "/company/vision-mission",
|
|
1403
1622
|
type: "custom",
|
|
1404
1623
|
target: "_self",
|
|
1405
1624
|
children: [
|
|
1406
1625
|
{
|
|
1407
1626
|
_uId: "m_values",
|
|
1408
|
-
title: "Değerlerimiz & İlkelerimiz",
|
|
1409
|
-
url: "/
|
|
1627
|
+
title: { en: "Core Values & Principles", tr: "Değerlerimiz & İlkelerimiz" },
|
|
1628
|
+
url: "/company/values",
|
|
1410
1629
|
type: "custom",
|
|
1411
1630
|
target: "_self",
|
|
1412
1631
|
children: []
|
|
@@ -1415,8 +1634,8 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1415
1634
|
},
|
|
1416
1635
|
{
|
|
1417
1636
|
_uId: "m_board",
|
|
1418
|
-
title: "Yönetim Kurulu",
|
|
1419
|
-
url: "/
|
|
1637
|
+
title: { en: "Board of Directors", tr: "Yönetim Kurulu" },
|
|
1638
|
+
url: "/company/board",
|
|
1420
1639
|
type: "custom",
|
|
1421
1640
|
target: "_self",
|
|
1422
1641
|
children: []
|
|
@@ -1425,24 +1644,24 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1425
1644
|
},
|
|
1426
1645
|
{
|
|
1427
1646
|
_uId: "m_solutions",
|
|
1428
|
-
title: "Çözümlerimiz",
|
|
1429
|
-
url: "/
|
|
1647
|
+
title: { en: "Solutions", tr: "Çözümlerimiz" },
|
|
1648
|
+
url: "/solutions",
|
|
1430
1649
|
type: "custom",
|
|
1431
1650
|
target: "_self",
|
|
1432
1651
|
icon: "layers",
|
|
1433
1652
|
children: [
|
|
1434
1653
|
{
|
|
1435
1654
|
_uId: "m_sol_cms",
|
|
1436
|
-
title: "Kurumsal İçerik Yönetimi (CMS)",
|
|
1437
|
-
url: "/
|
|
1655
|
+
title: { en: "Enterprise Content Management (CMS)", tr: "Kurumsal İçerik Yönetimi (CMS)" },
|
|
1656
|
+
url: "/solutions/cms",
|
|
1438
1657
|
type: "custom",
|
|
1439
1658
|
target: "_self",
|
|
1440
1659
|
children: []
|
|
1441
1660
|
},
|
|
1442
1661
|
{
|
|
1443
1662
|
_uId: "m_sol_cloud",
|
|
1444
|
-
title: "Bulut & Mikroservis Mimarisi",
|
|
1445
|
-
url: "/
|
|
1663
|
+
title: { en: "Cloud & Microservice Architecture", tr: "Bulut & Mikroservis Mimarisi" },
|
|
1664
|
+
url: "/solutions/cloud",
|
|
1446
1665
|
type: "custom",
|
|
1447
1666
|
target: "_self",
|
|
1448
1667
|
children: []
|
|
@@ -1451,8 +1670,8 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1451
1670
|
},
|
|
1452
1671
|
{
|
|
1453
1672
|
_uId: "m_contact",
|
|
1454
|
-
title: "İletişim",
|
|
1455
|
-
url: "/
|
|
1673
|
+
title: { en: "Contact", tr: "İletişim" },
|
|
1674
|
+
url: "/contact",
|
|
1456
1675
|
type: "custom",
|
|
1457
1676
|
target: "_self",
|
|
1458
1677
|
icon: "mail",
|
|
@@ -1461,7 +1680,7 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1461
1680
|
]
|
|
1462
1681
|
},
|
|
1463
1682
|
{
|
|
1464
|
-
name: "
|
|
1683
|
+
name: "Corporate Sidebar Menu (Vertical Tree)",
|
|
1465
1684
|
slug: "corporate-sidebar-menu",
|
|
1466
1685
|
mode: "vertical",
|
|
1467
1686
|
options: {
|
|
@@ -1473,30 +1692,30 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1473
1692
|
items: [
|
|
1474
1693
|
{
|
|
1475
1694
|
_uId: "v_corp",
|
|
1476
|
-
title: "Kurumsal Bilgiler",
|
|
1477
|
-
url: "/
|
|
1695
|
+
title: { en: "Corporate Profile", tr: "Kurumsal Bilgiler" },
|
|
1696
|
+
url: "/company",
|
|
1478
1697
|
type: "custom",
|
|
1479
1698
|
target: "_self",
|
|
1480
1699
|
children: [
|
|
1481
1700
|
{
|
|
1482
1701
|
_uId: "v_history",
|
|
1483
|
-
title: "Tarihçemiz",
|
|
1484
|
-
url: "/
|
|
1702
|
+
title: { en: "Our History", tr: "Tarihçemiz" },
|
|
1703
|
+
url: "/company/history",
|
|
1485
1704
|
type: "custom",
|
|
1486
1705
|
target: "_self",
|
|
1487
1706
|
children: []
|
|
1488
1707
|
},
|
|
1489
1708
|
{
|
|
1490
1709
|
_uId: "v_quality",
|
|
1491
|
-
title: "Kalite Politikamız",
|
|
1492
|
-
url: "/
|
|
1710
|
+
title: { en: "Quality Policy", tr: "Kalite Politikamız" },
|
|
1711
|
+
url: "/company/quality",
|
|
1493
1712
|
type: "custom",
|
|
1494
1713
|
target: "_self",
|
|
1495
1714
|
children: [
|
|
1496
1715
|
{
|
|
1497
1716
|
_uId: "v_iso",
|
|
1498
|
-
title: "ISO 27001 & Sertifikalar",
|
|
1499
|
-
url: "/
|
|
1717
|
+
title: { en: "ISO 27001 & Certifications", tr: "ISO 27001 & Sertifikalar" },
|
|
1718
|
+
url: "/company/quality/certifications",
|
|
1500
1719
|
type: "custom",
|
|
1501
1720
|
target: "_self",
|
|
1502
1721
|
children: []
|
|
@@ -1507,8 +1726,8 @@ const DEFAULT_SEED_MENUS = [
|
|
|
1507
1726
|
},
|
|
1508
1727
|
{
|
|
1509
1728
|
_uId: "v_career",
|
|
1510
|
-
title: "İnsan Kaynakları & Kariyer",
|
|
1511
|
-
url: "/
|
|
1729
|
+
title: { en: "Careers & Human Resources", tr: "İnsan Kaynakları & Kariyer" },
|
|
1730
|
+
url: "/careers",
|
|
1512
1731
|
type: "custom",
|
|
1513
1732
|
target: "_self",
|
|
1514
1733
|
children: []
|
|
@@ -1535,7 +1754,7 @@ const ciMenuService = ({ strapi }) => ({
|
|
|
1535
1754
|
}));
|
|
1536
1755
|
},
|
|
1537
1756
|
async save(data) {
|
|
1538
|
-
const cleanName = String(data.name || "
|
|
1757
|
+
const cleanName = String(data.name || "Menu").trim();
|
|
1539
1758
|
const cleanSlug = String(data.slug || slugifyTR(cleanName) || `menu-${Date.now()}`).trim();
|
|
1540
1759
|
const cleanMode = data.mode === "vertical" ? "vertical" : "horizontal";
|
|
1541
1760
|
const cleanItems = Array.isArray(data.items) ? data.items : [];
|
|
@@ -1773,13 +1992,13 @@ function splitValidationRules(validationStr) {
|
|
|
1773
1992
|
}
|
|
1774
1993
|
return merged;
|
|
1775
1994
|
}
|
|
1776
|
-
function resolveLocalizedText(val, locale = "
|
|
1995
|
+
function resolveLocalizedText(val, locale = "en", fallback = "") {
|
|
1777
1996
|
if (!val) return fallback;
|
|
1778
1997
|
if (typeof val === "string") return val;
|
|
1779
1998
|
if (typeof val === "object") {
|
|
1780
|
-
const code = String(locale || "
|
|
1999
|
+
const code = String(locale || "en").trim();
|
|
1781
2000
|
const shortCode = code.split(/[-_]/)[0];
|
|
1782
|
-
return val[code] || val[shortCode] || val.
|
|
2001
|
+
return val[code] || val[shortCode] || val.en || val.tr || Object.values(val).find((v) => typeof v === "string" && v.trim() !== "") || fallback;
|
|
1783
2002
|
}
|
|
1784
2003
|
return fallback;
|
|
1785
2004
|
}
|
|
@@ -1794,7 +2013,7 @@ function isEmptyFieldValue(value) {
|
|
|
1794
2013
|
function msg(locale, trText, enText) {
|
|
1795
2014
|
return String(locale || "").toLowerCase().startsWith("tr") ? trText : enText;
|
|
1796
2015
|
}
|
|
1797
|
-
function validateSingleField(value, field, allData = {}, locale = "
|
|
2016
|
+
function validateSingleField(value, field, allData = {}, locale = "en") {
|
|
1798
2017
|
const errors = [];
|
|
1799
2018
|
const rawValidation = typeof field.validation === "object" && field.validation !== null ? resolveLocalizedText(field.validation, locale, "") : String(field.validation || "");
|
|
1800
2019
|
const rules = splitValidationRules(rawValidation);
|
|
@@ -2041,7 +2260,7 @@ function validateSingleField(value, field, allData = {}, locale = "tr") {
|
|
|
2041
2260
|
}
|
|
2042
2261
|
return errors;
|
|
2043
2262
|
}
|
|
2044
|
-
function validateFormSubmission(fieldsMap, payload, locale = "
|
|
2263
|
+
function validateFormSubmission(fieldsMap, payload, locale = "en") {
|
|
2045
2264
|
const errors = {};
|
|
2046
2265
|
const data = payload || {};
|
|
2047
2266
|
for (const [key, fieldDef] of Object.entries(fieldsMap || {})) {
|
|
@@ -2095,25 +2314,28 @@ function escapeHtml(input) {
|
|
|
2095
2314
|
const str = input === null || input === void 0 ? "" : String(input);
|
|
2096
2315
|
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2097
2316
|
}
|
|
2098
|
-
function formatFieldValue(val) {
|
|
2317
|
+
function formatFieldValue(val, locale = "en") {
|
|
2099
2318
|
if (val === null || val === void 0 || val === "") return "-";
|
|
2100
2319
|
if (Array.isArray(val)) return val.join(", ");
|
|
2101
|
-
if (typeof val === "boolean")
|
|
2320
|
+
if (typeof val === "boolean") {
|
|
2321
|
+
const tr = String(locale || "en").toLowerCase().startsWith("tr");
|
|
2322
|
+
return val ? tr ? "Evet" : "Yes" : tr ? "Hayır" : "No";
|
|
2323
|
+
}
|
|
2102
2324
|
if (typeof val === "object") return JSON.stringify(val);
|
|
2103
2325
|
return String(val);
|
|
2104
2326
|
}
|
|
2105
2327
|
function renderContentFormMailHtml(params) {
|
|
2106
2328
|
const { form, data, meta } = params;
|
|
2107
|
-
const locale = meta?.locale || "
|
|
2329
|
+
const locale = meta?.locale || "en";
|
|
2108
2330
|
const fields = form.fields || {};
|
|
2109
2331
|
const entries = Object.keys(fields).length > 0 ? Object.entries(fields).map(([key, def]) => ({
|
|
2110
2332
|
key,
|
|
2111
2333
|
label: resolveLocalizedText(def?.alias, locale, key),
|
|
2112
|
-
value: formatFieldValue(data[key])
|
|
2334
|
+
value: formatFieldValue(data[key], locale)
|
|
2113
2335
|
})) : Object.entries(data || {}).map(([key, val]) => ({
|
|
2114
2336
|
key,
|
|
2115
2337
|
label: key,
|
|
2116
|
-
value: formatFieldValue(val)
|
|
2338
|
+
value: formatFieldValue(val, locale)
|
|
2117
2339
|
}));
|
|
2118
2340
|
const rowsHtml = entries.map(
|
|
2119
2341
|
(item) => `
|
|
@@ -2179,6 +2401,46 @@ function parseFromAddress(rawFrom, rawName) {
|
|
|
2179
2401
|
const name = (rawName || fallbackName).trim();
|
|
2180
2402
|
return { email: trimmed, name, formatted: `"${name}" <${trimmed}>` };
|
|
2181
2403
|
}
|
|
2404
|
+
const mailtrapInboxCache = /* @__PURE__ */ new Map();
|
|
2405
|
+
async function discoverMailtrapSandboxInbox(rawToken) {
|
|
2406
|
+
const token = String(rawToken || "").trim();
|
|
2407
|
+
if (!token) return "";
|
|
2408
|
+
if (mailtrapInboxCache.has(token)) {
|
|
2409
|
+
return mailtrapInboxCache.get(token) || "";
|
|
2410
|
+
}
|
|
2411
|
+
try {
|
|
2412
|
+
const accRes = await fetch("https://mailtrap.io/api/accounts", {
|
|
2413
|
+
headers: {
|
|
2414
|
+
Authorization: `Bearer ${token}`,
|
|
2415
|
+
"Api-Token": token
|
|
2416
|
+
}
|
|
2417
|
+
});
|
|
2418
|
+
if (!accRes.ok) return "";
|
|
2419
|
+
const accounts = await accRes.json();
|
|
2420
|
+
const accountId = Array.isArray(accounts) && accounts[0]?.id ? accounts[0].id : null;
|
|
2421
|
+
if (!accountId) return "";
|
|
2422
|
+
const inbRes = await fetch(
|
|
2423
|
+
`https://mailtrap.io/api/accounts/${encodeURIComponent(String(accountId))}/inboxes`,
|
|
2424
|
+
{
|
|
2425
|
+
headers: {
|
|
2426
|
+
Authorization: `Bearer ${token}`,
|
|
2427
|
+
"Api-Token": token
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
);
|
|
2431
|
+
if (!inbRes.ok) return "";
|
|
2432
|
+
const inboxes = await inbRes.json();
|
|
2433
|
+
if (!Array.isArray(inboxes) || inboxes.length === 0) return "";
|
|
2434
|
+
const activeInbox = inboxes.find((i) => i?.status === "active") || inboxes[0];
|
|
2435
|
+
const discoveredId = activeInbox?.id ? String(activeInbox.id) : "";
|
|
2436
|
+
if (discoveredId) {
|
|
2437
|
+
mailtrapInboxCache.set(token, discoveredId);
|
|
2438
|
+
}
|
|
2439
|
+
return discoveredId;
|
|
2440
|
+
} catch {
|
|
2441
|
+
return "";
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2182
2444
|
async function sendDynamicFormMail(params) {
|
|
2183
2445
|
const { form, strapi } = params;
|
|
2184
2446
|
const cfg = form.mailConfig || {};
|
|
@@ -2206,7 +2468,8 @@ async function sendDynamicFormMail(params) {
|
|
|
2206
2468
|
cfg.from || process.env.MAIL_FROM,
|
|
2207
2469
|
cfg.fromName || process.env.MAIL_FROM_NAME
|
|
2208
2470
|
);
|
|
2209
|
-
const
|
|
2471
|
+
const isTr = String(params.meta?.locale || "en").toLowerCase().startsWith("tr");
|
|
2472
|
+
const subject = form.subject?.trim() || `${form.title} — ${isTr ? "Yeni Form Başvurusu" : "New Form Submission"}`;
|
|
2210
2473
|
const { html, text } = renderContentFormMailHtml(params);
|
|
2211
2474
|
let resolvedDriver = explicitDriver;
|
|
2212
2475
|
if (resolvedDriver === "auto") {
|
|
@@ -2218,11 +2481,17 @@ async function sendDynamicFormMail(params) {
|
|
|
2218
2481
|
try {
|
|
2219
2482
|
if (resolvedDriver === "mailtrap") {
|
|
2220
2483
|
if (mailtrapToken) {
|
|
2221
|
-
const
|
|
2484
|
+
const cleanToken = mailtrapToken.trim();
|
|
2485
|
+
let effectiveInboxId = mailtrapInboxId ? String(mailtrapInboxId).trim() : "";
|
|
2486
|
+
if (!effectiveInboxId) {
|
|
2487
|
+
effectiveInboxId = await discoverMailtrapSandboxInbox(cleanToken);
|
|
2488
|
+
}
|
|
2489
|
+
const endpoint = effectiveInboxId ? `https://sandbox.api.mailtrap.io/api/send/${encodeURIComponent(effectiveInboxId)}` : "https://send.api.mailtrap.io/api/send";
|
|
2222
2490
|
const res = await fetch(endpoint, {
|
|
2223
2491
|
method: "POST",
|
|
2224
2492
|
headers: {
|
|
2225
|
-
Authorization: `Bearer ${
|
|
2493
|
+
Authorization: `Bearer ${cleanToken}`,
|
|
2494
|
+
"Api-Token": cleanToken,
|
|
2226
2495
|
"Content-Type": "application/json"
|
|
2227
2496
|
},
|
|
2228
2497
|
body: JSON.stringify({
|
|
@@ -2239,7 +2508,7 @@ async function sendDynamicFormMail(params) {
|
|
|
2239
2508
|
}
|
|
2240
2509
|
return {
|
|
2241
2510
|
sent: true,
|
|
2242
|
-
driver:
|
|
2511
|
+
driver: effectiveInboxId ? "mailtrap-sandbox-api" : "mailtrap-sending-api",
|
|
2243
2512
|
detail: resBody
|
|
2244
2513
|
};
|
|
2245
2514
|
}
|
|
@@ -2367,10 +2636,10 @@ async function sendDynamicFormMail(params) {
|
|
|
2367
2636
|
}
|
|
2368
2637
|
const DEFAULT_SEED_SURVEYS = [
|
|
2369
2638
|
{
|
|
2370
|
-
title: "
|
|
2639
|
+
title: "Enterprise Product & Developer Experience Survey (3-Step)",
|
|
2371
2640
|
titleI18n: {
|
|
2372
|
-
|
|
2373
|
-
|
|
2641
|
+
en: "Enterprise Product & Developer Experience Survey",
|
|
2642
|
+
tr: "Kurumsal Ürün & Geliştirici Deneyimi Anketi"
|
|
2374
2643
|
},
|
|
2375
2644
|
slug: "showcase_dx_survey",
|
|
2376
2645
|
description: {
|
|
@@ -2706,10 +2975,10 @@ const DEFAULT_SEED_SURVEYS = [
|
|
|
2706
2975
|
}
|
|
2707
2976
|
},
|
|
2708
2977
|
{
|
|
2709
|
-
title: "
|
|
2978
|
+
title: "Quick Poll: What Should We Ship Next?",
|
|
2710
2979
|
titleI18n: {
|
|
2711
|
-
|
|
2712
|
-
|
|
2980
|
+
en: "Quick Poll: What Should We Ship Next?",
|
|
2981
|
+
tr: "Hızlı Oylama: Sıradaki Büyük Özellik Ne Olsun?"
|
|
2713
2982
|
},
|
|
2714
2983
|
slug: "showcase_roadmap_poll",
|
|
2715
2984
|
description: {
|
|
@@ -2780,10 +3049,10 @@ const DEFAULT_SEED_SURVEYS = [
|
|
|
2780
3049
|
}
|
|
2781
3050
|
},
|
|
2782
3051
|
{
|
|
2783
|
-
title: "
|
|
3052
|
+
title: "Visual Showcase & Readability Poll (Live Results)",
|
|
2784
3053
|
titleI18n: {
|
|
2785
|
-
|
|
2786
|
-
|
|
3054
|
+
en: "Visual Showcase & Readability Poll (Live Results)",
|
|
3055
|
+
tr: "Görsel Vitrin & Okunabilirlik Tercihi (Açık Sonuçlu)"
|
|
2787
3056
|
},
|
|
2788
3057
|
slug: "showcase_visual_theme_poll",
|
|
2789
3058
|
description: {
|
|
@@ -3284,7 +3553,7 @@ const DEFAULT_SEED_FORMS = [
|
|
|
3284
3553
|
title: "Enterprise Inquiry & Support Form",
|
|
3285
3554
|
slug: "showcase_contact_form",
|
|
3286
3555
|
to: "info@example.com",
|
|
3287
|
-
subject: "
|
|
3556
|
+
subject: "Enterprise Inquiry & Support Submission",
|
|
3288
3557
|
buttonLabel: {
|
|
3289
3558
|
tr: "Başvuruyu Gönder",
|
|
3290
3559
|
en: "Submit Inquiry"
|
|
@@ -3579,8 +3848,8 @@ const ciFormService = ({ strapi }) => ({
|
|
|
3579
3848
|
} catch {
|
|
3580
3849
|
}
|
|
3581
3850
|
return [
|
|
3582
|
-
{ code: "
|
|
3583
|
-
{ code: "
|
|
3851
|
+
{ code: "en", name: "English (en)", isDefault: true },
|
|
3852
|
+
{ code: "tr", name: "Türkçe (tr)", isDefault: false }
|
|
3584
3853
|
];
|
|
3585
3854
|
},
|
|
3586
3855
|
async ensureSampleSubmissions(force = false) {
|
|
@@ -3614,6 +3883,22 @@ const ciFormService = ({ strapi }) => ({
|
|
|
3614
3883
|
for (const seed of DEFAULT_SEED_FORMS) {
|
|
3615
3884
|
await strapi.db.query(FORM_UID).create({ data: seed });
|
|
3616
3885
|
}
|
|
3886
|
+
} else {
|
|
3887
|
+
try {
|
|
3888
|
+
const showcase = await strapi.db.query(FORM_UID).findOne({
|
|
3889
|
+
where: { slug: "showcase_contact_form" }
|
|
3890
|
+
});
|
|
3891
|
+
if (showcase && (showcase.subject === "Kurumsal İletişim & Destek Başvurusu" || showcase.title === "Kurumsal İletişim & Destek Formu")) {
|
|
3892
|
+
await strapi.db.query(FORM_UID).update({
|
|
3893
|
+
where: { id: showcase.id },
|
|
3894
|
+
data: {
|
|
3895
|
+
title: "Enterprise Inquiry & Support Form",
|
|
3896
|
+
subject: "Enterprise Inquiry & Support Submission"
|
|
3897
|
+
}
|
|
3898
|
+
});
|
|
3899
|
+
}
|
|
3900
|
+
} catch {
|
|
3901
|
+
}
|
|
3617
3902
|
}
|
|
3618
3903
|
await this.ensureSampleSubmissions(false);
|
|
3619
3904
|
},
|
|
@@ -3657,7 +3942,7 @@ const ciFormService = ({ strapi }) => ({
|
|
|
3657
3942
|
return sanitizeFormForPublic(found);
|
|
3658
3943
|
},
|
|
3659
3944
|
async save(payload) {
|
|
3660
|
-
const cleanTitle = String(payload.title || "
|
|
3945
|
+
const cleanTitle = String(payload.title || "New Dynamic Form").trim();
|
|
3661
3946
|
const cleanSlug = String(
|
|
3662
3947
|
payload.slug || slugifyIdentifier$1(cleanTitle) || `form_${Date.now()}`
|
|
3663
3948
|
).trim();
|
|
@@ -3674,6 +3959,16 @@ const ciFormService = ({ strapi }) => ({
|
|
|
3674
3959
|
if (!existing && cleanSlug) {
|
|
3675
3960
|
existing = await strapi.db.query(FORM_UID).findOne({ where: { slug: cleanSlug } });
|
|
3676
3961
|
}
|
|
3962
|
+
const mergedMailConfig = {
|
|
3963
|
+
...existing?.mailConfig || { driver: "env" },
|
|
3964
|
+
...payload.mailConfig || {}
|
|
3965
|
+
};
|
|
3966
|
+
if (mergedMailConfig.driver === "mailtrap" && mergedMailConfig.apiKey && !String(mergedMailConfig.inboxId || "").trim()) {
|
|
3967
|
+
const autoInbox = await discoverMailtrapSandboxInbox(mergedMailConfig.apiKey);
|
|
3968
|
+
if (autoInbox) {
|
|
3969
|
+
mergedMailConfig.inboxId = autoInbox;
|
|
3970
|
+
}
|
|
3971
|
+
}
|
|
3677
3972
|
const recordData = {
|
|
3678
3973
|
title: cleanTitle,
|
|
3679
3974
|
slug: cleanSlug,
|
|
@@ -3692,7 +3987,7 @@ const ciFormService = ({ strapi }) => ({
|
|
|
3692
3987
|
useRecaptcha: payload.useRecaptcha !== void 0 ? Boolean(payload.useRecaptcha) : existing?.useRecaptcha !== void 0 ? Boolean(existing.useRecaptcha) : true,
|
|
3693
3988
|
recaptchaSiteKey: payload.recaptchaSiteKey !== void 0 ? String(payload.recaptchaSiteKey) : existing?.recaptchaSiteKey || "",
|
|
3694
3989
|
recaptchaSecretKey: payload.recaptchaSecretKey !== void 0 ? String(payload.recaptchaSecretKey) : existing?.recaptchaSecretKey || "",
|
|
3695
|
-
mailConfig:
|
|
3990
|
+
mailConfig: mergedMailConfig,
|
|
3696
3991
|
fields: payload.fields && typeof payload.fields === "object" ? payload.fields : existing?.fields || {},
|
|
3697
3992
|
form: Array.isArray(payload.form) ? payload.form : existing?.form || []
|
|
3698
3993
|
};
|
|
@@ -3761,8 +4056,8 @@ const ciFormService = ({ strapi }) => ({
|
|
|
3761
4056
|
};
|
|
3762
4057
|
}
|
|
3763
4058
|
const body = rawBody && typeof rawBody === "object" ? rawBody : {};
|
|
3764
|
-
const rawLocale = String(body._locale || meta.locale || "
|
|
3765
|
-
const locale = rawLocale ? rawLocale.split(/[,;]/)[0].trim() : "
|
|
4059
|
+
const rawLocale = String(body._locale || meta.locale || "en").trim().toLowerCase();
|
|
4060
|
+
const locale = rawLocale ? rawLocale.split(/[,;]/)[0].trim() : "en";
|
|
3766
4061
|
const fieldsMap = form.fields && typeof form.fields === "object" ? form.fields : {};
|
|
3767
4062
|
const { errors } = validateFormSubmission(fieldsMap, body, locale);
|
|
3768
4063
|
const activeSecretKey = String(
|
|
@@ -4059,7 +4354,7 @@ function isQuestionVisible(question, survey, answers) {
|
|
|
4059
4354
|
function lMsg(locale, tr, en) {
|
|
4060
4355
|
return String(locale || "").toLowerCase().startsWith("tr") ? tr : en;
|
|
4061
4356
|
}
|
|
4062
|
-
function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "
|
|
4357
|
+
function validateSurveySubmission(survey, answers, otherTexts = {}, locale = "en") {
|
|
4063
4358
|
const errors = {};
|
|
4064
4359
|
const questions = Array.isArray(survey.questions) ? survey.questions : [];
|
|
4065
4360
|
for (const q of questions) {
|
|
@@ -4255,7 +4550,7 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
4255
4550
|
const dailyCounts = {};
|
|
4256
4551
|
let lastSubmittedAt = null;
|
|
4257
4552
|
for (const r of responses) {
|
|
4258
|
-
const loc = String(r.locale || "
|
|
4553
|
+
const loc = String(r.locale || "en");
|
|
4259
4554
|
localeCounts[loc] = (localeCounts[loc] || 0) + 1;
|
|
4260
4555
|
const tsRaw = r.submittedAt || r.createdAt;
|
|
4261
4556
|
if (tsRaw) {
|
|
@@ -4317,7 +4612,7 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
4317
4612
|
if (txt && otherSamples.length < 30) {
|
|
4318
4613
|
otherSamples.push({
|
|
4319
4614
|
text: txt,
|
|
4320
|
-
locale: r.locale || "
|
|
4615
|
+
locale: r.locale || "en",
|
|
4321
4616
|
submittedAt: r.submittedAt || r.createdAt || ""
|
|
4322
4617
|
});
|
|
4323
4618
|
}
|
|
@@ -4524,7 +4819,7 @@ function computeSurveyAnalytics(survey, rawResponses, filter = {}) {
|
|
|
4524
4819
|
textResponses.push({
|
|
4525
4820
|
id: r.id || r.documentId,
|
|
4526
4821
|
text: v.trim(),
|
|
4527
|
-
locale: r.locale || "
|
|
4822
|
+
locale: r.locale || "en",
|
|
4528
4823
|
submittedAt: r.submittedAt || r.createdAt || "",
|
|
4529
4824
|
npsValue: r.npsValue ?? null
|
|
4530
4825
|
});
|
|
@@ -4587,7 +4882,7 @@ function escapeCsvCell(val) {
|
|
|
4587
4882
|
}
|
|
4588
4883
|
return str;
|
|
4589
4884
|
}
|
|
4590
|
-
function exportSurveyResponsesToCsv(survey, rawResponses, locale = "
|
|
4885
|
+
function exportSurveyResponsesToCsv(survey, rawResponses, locale = "en") {
|
|
4591
4886
|
const activeQuestions = (survey.questions || []).filter((q) => q && q.type !== "statement");
|
|
4592
4887
|
const headers = [
|
|
4593
4888
|
"Response ID",
|
|
@@ -5003,8 +5298,8 @@ const ciSurveyService = ({ strapi }) => ({
|
|
|
5003
5298
|
};
|
|
5004
5299
|
}
|
|
5005
5300
|
const body = rawBody && typeof rawBody === "object" ? rawBody : {};
|
|
5006
|
-
const rawLocale = String(body._locale || meta.locale || "
|
|
5007
|
-
const locale = rawLocale ? rawLocale.split(/[,;]/)[0].trim() : "
|
|
5301
|
+
const rawLocale = String(body._locale || meta.locale || "en").trim().toLowerCase();
|
|
5302
|
+
const locale = rawLocale ? rawLocale.split(/[,;]/)[0].trim() : "en";
|
|
5008
5303
|
const isTr = locale.startsWith("tr");
|
|
5009
5304
|
if (body._hp && String(body._hp).trim() !== "") {
|
|
5010
5305
|
return {
|
|
@@ -5143,7 +5438,7 @@ const ciSurveyService = ({ strapi }) => ({
|
|
|
5143
5438
|
form: {
|
|
5144
5439
|
title: survey.title,
|
|
5145
5440
|
to: notifyEmails,
|
|
5146
|
-
subject:
|
|
5441
|
+
subject: `${isTr ? "[Anket Yanıtı]" : "[Survey Response]"} ${survey.title}`,
|
|
5147
5442
|
mailConfig: survey.mailConfig
|
|
5148
5443
|
},
|
|
5149
5444
|
data: {
|
|
@@ -5252,7 +5547,7 @@ const ciSurveyService = ({ strapi }) => ({
|
|
|
5252
5547
|
const csv = exportSurveyResponsesToCsv(
|
|
5253
5548
|
survey,
|
|
5254
5549
|
responses,
|
|
5255
|
-
options2.locale || "
|
|
5550
|
+
options2.locale || "en"
|
|
5256
5551
|
);
|
|
5257
5552
|
return {
|
|
5258
5553
|
filename: `${survey.slug}-responses.csv`,
|
|
@@ -5261,11 +5556,600 @@ const ciSurveyService = ({ strapi }) => ({
|
|
|
5261
5556
|
};
|
|
5262
5557
|
}
|
|
5263
5558
|
});
|
|
5559
|
+
const PALETTE_UID = "plugin::content-input.ci-color-palette";
|
|
5560
|
+
function clamp(n, min, max) {
|
|
5561
|
+
return Math.max(min, Math.min(max, n));
|
|
5562
|
+
}
|
|
5563
|
+
function parseColorToRgba(rawInput, fallback = { r: 79, g: 70, b: 229, a: 1 }) {
|
|
5564
|
+
const str = String(rawInput || "").trim();
|
|
5565
|
+
if (!str) return fallback;
|
|
5566
|
+
const varMatch = str.match(/^var\([^,]+,\s*(.+)\)$/);
|
|
5567
|
+
const target = varMatch ? varMatch[1].trim() : str;
|
|
5568
|
+
const hexMatch = target.match(/^#([0-9a-fA-F]{3,8})$/);
|
|
5569
|
+
if (hexMatch) {
|
|
5570
|
+
const h = hexMatch[1];
|
|
5571
|
+
if (h.length === 3 || h.length === 4) {
|
|
5572
|
+
const r = parseInt(h[0] + h[0], 16);
|
|
5573
|
+
const g = parseInt(h[1] + h[1], 16);
|
|
5574
|
+
const b = parseInt(h[2] + h[2], 16);
|
|
5575
|
+
const a = h.length === 4 ? Number((parseInt(h[3] + h[3], 16) / 255).toFixed(2)) : 1;
|
|
5576
|
+
return { r, g, b, a };
|
|
5577
|
+
}
|
|
5578
|
+
if (h.length === 6 || h.length === 8) {
|
|
5579
|
+
const r = parseInt(h.slice(0, 2), 16);
|
|
5580
|
+
const g = parseInt(h.slice(2, 4), 16);
|
|
5581
|
+
const b = parseInt(h.slice(4, 6), 16);
|
|
5582
|
+
const a = h.length === 8 ? Number((parseInt(h.slice(6, 8), 16) / 255).toFixed(2)) : 1;
|
|
5583
|
+
return { r, g, b, a };
|
|
5584
|
+
}
|
|
5585
|
+
}
|
|
5586
|
+
const rgbMatch = target.match(/^rgba?\(\s*([\d.]+)\s*[,\s]\s*([\d.]+)\s*[,\s]\s*([\d.]+)(?:\s*[,/]\s*([\d.%]+))?\s*\)$/i);
|
|
5587
|
+
if (rgbMatch) {
|
|
5588
|
+
const r = clamp(Math.round(Number(rgbMatch[1])), 0, 255);
|
|
5589
|
+
const g = clamp(Math.round(Number(rgbMatch[2])), 0, 255);
|
|
5590
|
+
const b = clamp(Math.round(Number(rgbMatch[3])), 0, 255);
|
|
5591
|
+
let a = 1;
|
|
5592
|
+
if (rgbMatch[4] !== void 0) {
|
|
5593
|
+
const rawA = rgbMatch[4].trim();
|
|
5594
|
+
a = rawA.endsWith("%") ? clamp(Number(rawA.slice(0, -1)) / 100, 0, 1) : clamp(Number(rawA), 0, 1);
|
|
5595
|
+
a = Number(a.toFixed(2));
|
|
5596
|
+
}
|
|
5597
|
+
return { r, g, b, a };
|
|
5598
|
+
}
|
|
5599
|
+
return fallback;
|
|
5600
|
+
}
|
|
5601
|
+
function rgbaToHex({ r, g, b, a }) {
|
|
5602
|
+
const to2 = (n) => clamp(Math.round(n), 0, 255).toString(16).padStart(2, "0");
|
|
5603
|
+
if (a < 1) {
|
|
5604
|
+
return `#${to2(r)}${to2(g)}${to2(b)}${to2(Math.round(a * 255))}`;
|
|
5605
|
+
}
|
|
5606
|
+
return `#${to2(r)}${to2(g)}${to2(b)}`;
|
|
5607
|
+
}
|
|
5608
|
+
function rgbaToCssString({ r, g, b, a }) {
|
|
5609
|
+
const cr = clamp(Math.round(r), 0, 255);
|
|
5610
|
+
const cg = clamp(Math.round(g), 0, 255);
|
|
5611
|
+
const cb = clamp(Math.round(b), 0, 255);
|
|
5612
|
+
const ca = clamp(Number(a.toFixed(2)), 0, 1);
|
|
5613
|
+
return ca < 1 ? `rgba(${cr}, ${cg}, ${cb}, ${ca})` : `rgb(${cr}, ${cg}, ${cb})`;
|
|
5614
|
+
}
|
|
5615
|
+
function buildTokenEntry(rawVal, labels, overrides) {
|
|
5616
|
+
const parsed = parseColorToRgba(rawVal);
|
|
5617
|
+
const hex = rgbaToHex(parsed);
|
|
5618
|
+
const rgb = rgbaToCssString(parsed);
|
|
5619
|
+
const cleanTrimmed = String(rawVal || "").trim();
|
|
5620
|
+
const value = cleanTrimmed.toLowerCase().startsWith("rgb") ? rgb : hex;
|
|
5621
|
+
const srgb = [parsed.r, parsed.g, parsed.b].map((v) => {
|
|
5622
|
+
const c = v / 255;
|
|
5623
|
+
return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
5624
|
+
});
|
|
5625
|
+
const lum = 0.2126 * srgb[0] + 0.7152 * srgb[1] + 0.0722 * srgb[2];
|
|
5626
|
+
const autoContrast = lum > 0.44 ? "#0f172a" : "#ffffff";
|
|
5627
|
+
const autoSoft = `rgba(${parsed.r}, ${parsed.g}, ${parsed.b}, 0.14)`;
|
|
5628
|
+
return {
|
|
5629
|
+
value,
|
|
5630
|
+
hex,
|
|
5631
|
+
rgb,
|
|
5632
|
+
soft: overrides?.soft || autoSoft,
|
|
5633
|
+
contrast: overrides?.contrast || autoContrast,
|
|
5634
|
+
...labels ? { labels } : {}
|
|
5635
|
+
};
|
|
5636
|
+
}
|
|
5637
|
+
const SEMANTIC_TOKEN_META = [
|
|
5638
|
+
{ key: "primary", tr: "Birincil (Primary)", en: "Primary" },
|
|
5639
|
+
{ key: "secondary", tr: "İkincil (Secondary)", en: "Secondary" },
|
|
5640
|
+
{ key: "accent", tr: "Vurgu (Accent)", en: "Accent" },
|
|
5641
|
+
{ key: "success", tr: "Başarı (Success)", en: "Success" },
|
|
5642
|
+
{ key: "warning", tr: "Uyarı (Warning)", en: "Warning" },
|
|
5643
|
+
{ key: "error", tr: "Hata / Tehlike (Error)", en: "Error" },
|
|
5644
|
+
{ key: "info", tr: "Bilgi (Info)", en: "Info" },
|
|
5645
|
+
{ key: "surface", tr: "Kart / Yüzey (Surface)", en: "Surface" },
|
|
5646
|
+
{ key: "surfaceAlt", tr: "Alternatif Yüzey", en: "Surface Alt" },
|
|
5647
|
+
{ key: "background", tr: "Sayfa Arka Planı", en: "Background" },
|
|
5648
|
+
{ key: "textPrimary", tr: "Ana Metin Rengi", en: "Primary Text" },
|
|
5649
|
+
{ key: "textSecondary", tr: "İkincil Metin Rengi", en: "Secondary Text" },
|
|
5650
|
+
{ key: "border", tr: "Kenarlık (Border)", en: "Border" }
|
|
5651
|
+
];
|
|
5652
|
+
const DEFAULT_PALETTE_SEEDS = [
|
|
5653
|
+
{
|
|
5654
|
+
name: "Enterprise Indigo (Default)",
|
|
5655
|
+
slug: "enterprise-indigo",
|
|
5656
|
+
description: "Balanced Indigo, Sky Blue, and Dark Slate palette for modern SaaS & enterprise interfaces",
|
|
5657
|
+
isActive: true,
|
|
5658
|
+
rawSemantic: {
|
|
5659
|
+
primary: "#4f46e5",
|
|
5660
|
+
secondary: "#0ea5e9",
|
|
5661
|
+
accent: "#8b5cf6",
|
|
5662
|
+
success: "#10b981",
|
|
5663
|
+
warning: "#f59e0b",
|
|
5664
|
+
error: "#ef4444",
|
|
5665
|
+
info: "#3b82f6",
|
|
5666
|
+
surface: "#ffffff",
|
|
5667
|
+
surfaceAlt: "#f8fafc",
|
|
5668
|
+
background: "#f1f5f9",
|
|
5669
|
+
textPrimary: "#0f172a",
|
|
5670
|
+
textSecondary: "#475569",
|
|
5671
|
+
border: "#e2e8f0"
|
|
5672
|
+
},
|
|
5673
|
+
rawCustom: [
|
|
5674
|
+
{ key: "brandGold", value: "#d97706", labels: { tr: "Kurumsal Altın", en: "Brand Gold" } },
|
|
5675
|
+
{ key: "heroCyan", value: "rgb(6, 182, 212)", labels: { tr: "Vitrin Turkuaz (RGB)", en: "Hero Cyan (RGB)" } },
|
|
5676
|
+
{ key: "glassDark", value: "rgba(15, 23, 42, 0.76)", labels: { tr: "Koyu Cam Efekt (RGBA)", en: "Dark Glass Scrim (RGBA)" } },
|
|
5677
|
+
{ key: "coralHighlight", value: "#f43f5e", labels: { tr: "Mercan Vurgu", en: "Coral Highlight" } }
|
|
5678
|
+
]
|
|
5679
|
+
},
|
|
5680
|
+
{
|
|
5681
|
+
name: "Emerald Fintech & Sustainability",
|
|
5682
|
+
slug: "emerald-fintech",
|
|
5683
|
+
description: "Emerald Green & Ocean Navy palette crafted for fintech, energy, and sustainability platforms",
|
|
5684
|
+
isActive: false,
|
|
5685
|
+
rawSemantic: {
|
|
5686
|
+
primary: "#059669",
|
|
5687
|
+
secondary: "#0f766e",
|
|
5688
|
+
accent: "#0284c7",
|
|
5689
|
+
success: "#16a34a",
|
|
5690
|
+
warning: "#d97706",
|
|
5691
|
+
error: "#dc2626",
|
|
5692
|
+
info: "#0ea5e9",
|
|
5693
|
+
surface: "#ffffff",
|
|
5694
|
+
surfaceAlt: "#f0fdf4",
|
|
5695
|
+
background: "#f8fafc",
|
|
5696
|
+
textPrimary: "#064e3b",
|
|
5697
|
+
textSecondary: "#334155",
|
|
5698
|
+
border: "#d1fae5"
|
|
5699
|
+
},
|
|
5700
|
+
rawCustom: [
|
|
5701
|
+
{ key: "brandGold", value: "#ca8a04", labels: { tr: "Kurumsal Altın", en: "Brand Gold" } },
|
|
5702
|
+
{ key: "heroCyan", value: "rgb(20, 184, 166)", labels: { tr: "Mint Yeşil (RGB)", en: "Mint Teal (RGB)" } },
|
|
5703
|
+
{ key: "glassDark", value: "rgba(6, 78, 59, 0.78)", labels: { tr: "Zümrüt Cam (RGBA)", en: "Emerald Glass (RGBA)" } },
|
|
5704
|
+
{ key: "coralHighlight", value: "#ea580c", labels: { tr: "Sıcak Turuncu", en: "Warm Terracotta" } }
|
|
5705
|
+
]
|
|
5706
|
+
},
|
|
5707
|
+
{
|
|
5708
|
+
name: "Royal Amber & Executive Navy",
|
|
5709
|
+
slug: "royal-amber",
|
|
5710
|
+
description: "Executive Navy & Royal Amber Gold palette for corporate holdings, legal, real estate, and luxury brands",
|
|
5711
|
+
isActive: false,
|
|
5712
|
+
rawSemantic: {
|
|
5713
|
+
primary: "#1e3a8a",
|
|
5714
|
+
secondary: "#d97706",
|
|
5715
|
+
accent: "#b45309",
|
|
5716
|
+
success: "#15803d",
|
|
5717
|
+
warning: "#eab308",
|
|
5718
|
+
error: "#b91c1c",
|
|
5719
|
+
info: "#1d4ed8",
|
|
5720
|
+
surface: "#ffffff",
|
|
5721
|
+
surfaceAlt: "#fffbeb",
|
|
5722
|
+
background: "#f8fafc",
|
|
5723
|
+
textPrimary: "#0f172a",
|
|
5724
|
+
textSecondary: "#475569",
|
|
5725
|
+
border: "#e2e8f0"
|
|
5726
|
+
},
|
|
5727
|
+
rawCustom: [
|
|
5728
|
+
{ key: "brandGold", value: "#f59e0b", labels: { tr: "Kraliyet Altını", en: "Royal Gold" } },
|
|
5729
|
+
{ key: "heroCyan", value: "rgb(59, 130, 246)", labels: { tr: "Kraliyet Mavisi (RGB)", en: "Royal Blue (RGB)" } },
|
|
5730
|
+
{ key: "glassDark", value: "rgba(23, 37, 84, 0.82)", labels: { tr: "Lacivert Cam (RGBA)", en: "Navy Glass (RGBA)" } },
|
|
5731
|
+
{ key: "coralHighlight", value: "#e11d48", labels: { tr: "Yakut Vurgu", en: "Ruby Highlight" } }
|
|
5732
|
+
]
|
|
5733
|
+
},
|
|
5734
|
+
{
|
|
5735
|
+
name: "Crimson Editorial & Media",
|
|
5736
|
+
slug: "crimson-editorial",
|
|
5737
|
+
description: "High-energy Crimson & Violet palette for editorial media, e-commerce campaigns, and digital agencies",
|
|
5738
|
+
isActive: false,
|
|
5739
|
+
rawSemantic: {
|
|
5740
|
+
primary: "#e11d48",
|
|
5741
|
+
secondary: "#7c3aed",
|
|
5742
|
+
accent: "#f97316",
|
|
5743
|
+
success: "#10b981",
|
|
5744
|
+
warning: "#f59e0b",
|
|
5745
|
+
error: "#dc2626",
|
|
5746
|
+
info: "#6366f1",
|
|
5747
|
+
surface: "#ffffff",
|
|
5748
|
+
surfaceAlt: "#fff1f2",
|
|
5749
|
+
background: "#fafafa",
|
|
5750
|
+
textPrimary: "#18181b",
|
|
5751
|
+
textSecondary: "#52525b",
|
|
5752
|
+
border: "#e4e4e7"
|
|
5753
|
+
},
|
|
5754
|
+
rawCustom: [
|
|
5755
|
+
{ key: "brandGold", value: "#f97316", labels: { tr: "Kampanya Turuncusu", en: "Campaign Orange" } },
|
|
5756
|
+
{ key: "heroCyan", value: "rgb(168, 85, 247)", labels: { tr: "Neon Mor (RGB)", en: "Neon Purple (RGB)" } },
|
|
5757
|
+
{ key: "glassDark", value: "rgba(24, 24, 27, 0.80)", labels: { tr: "Antrasit Cam (RGBA)", en: "Charcoal Glass (RGBA)" } },
|
|
5758
|
+
{ key: "coralHighlight", value: "#f43f5e", labels: { tr: "Mercan Vurgu", en: "Coral Highlight" } }
|
|
5759
|
+
]
|
|
5760
|
+
}
|
|
5761
|
+
];
|
|
5762
|
+
function normalizePalettePayload(raw) {
|
|
5763
|
+
const semanticIn = raw?.semanticTokens && typeof raw.semanticTokens === "object" ? raw.semanticTokens : {};
|
|
5764
|
+
const semanticTokens = {};
|
|
5765
|
+
for (const meta of SEMANTIC_TOKEN_META) {
|
|
5766
|
+
const incoming = semanticIn[meta.key];
|
|
5767
|
+
const rawColor = typeof incoming === "string" ? incoming : incoming?.value || incoming?.hex || incoming?.rgb || "#4f46e5";
|
|
5768
|
+
semanticTokens[meta.key] = buildTokenEntry(
|
|
5769
|
+
rawColor,
|
|
5770
|
+
incoming?.labels || { tr: meta.tr, en: meta.en },
|
|
5771
|
+
{
|
|
5772
|
+
soft: incoming?.soft,
|
|
5773
|
+
contrast: incoming?.contrast
|
|
5774
|
+
}
|
|
5775
|
+
);
|
|
5776
|
+
}
|
|
5777
|
+
const customIn = Array.isArray(raw?.customTokens) ? raw.customTokens : [];
|
|
5778
|
+
const customTokens = customIn.filter((c) => c && typeof c.key === "string" && c.key.trim()).map((c) => {
|
|
5779
|
+
const cleanKey = String(c.key).trim().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
5780
|
+
const base = buildTokenEntry(
|
|
5781
|
+
c.value || c.hex || c.rgb || "#4f46e5",
|
|
5782
|
+
c.labels && typeof c.labels === "object" ? c.labels : { tr: cleanKey, en: cleanKey },
|
|
5783
|
+
{
|
|
5784
|
+
soft: c.soft,
|
|
5785
|
+
contrast: c.contrast
|
|
5786
|
+
}
|
|
5787
|
+
);
|
|
5788
|
+
return {
|
|
5789
|
+
key: cleanKey,
|
|
5790
|
+
...base,
|
|
5791
|
+
labels: c.labels && typeof c.labels === "object" ? c.labels : { tr: cleanKey, en: cleanKey }
|
|
5792
|
+
};
|
|
5793
|
+
});
|
|
5794
|
+
return {
|
|
5795
|
+
name: String(raw?.name || "Custom Theme Palette").trim(),
|
|
5796
|
+
slug: String(raw?.slug || raw?.name || "custom-palette").toLowerCase().replace(/[^a-z0-9-_]+/g, "-").replace(/^-+|-+$/g, "") || `palette-${Date.now()}`,
|
|
5797
|
+
description: String(raw?.description || "").trim(),
|
|
5798
|
+
isActive: Boolean(raw?.isActive),
|
|
5799
|
+
semanticTokens,
|
|
5800
|
+
customTokens
|
|
5801
|
+
};
|
|
5802
|
+
}
|
|
5803
|
+
function buildCssVariablesMap(palette) {
|
|
5804
|
+
const vars = {};
|
|
5805
|
+
if (!palette) return vars;
|
|
5806
|
+
const sem = palette.semanticTokens || {};
|
|
5807
|
+
for (const [key, entry] of Object.entries(sem)) {
|
|
5808
|
+
if (!entry) continue;
|
|
5809
|
+
const val = entry.value || entry.hex || "#4f46e5";
|
|
5810
|
+
vars[`--ci-color-${key}`] = val;
|
|
5811
|
+
if (entry.soft) vars[`--ci-color-${key}-soft`] = entry.soft;
|
|
5812
|
+
if (entry.contrast) vars[`--ci-color-${key}-contrast`] = entry.contrast;
|
|
5813
|
+
if (entry.hex) vars[`--ci-color-${key}-hex`] = entry.hex;
|
|
5814
|
+
if (entry.rgb) vars[`--ci-color-${key}-rgb`] = entry.rgb;
|
|
5815
|
+
}
|
|
5816
|
+
const cust = Array.isArray(palette.customTokens) ? palette.customTokens : [];
|
|
5817
|
+
for (const item of cust) {
|
|
5818
|
+
if (!item?.key) continue;
|
|
5819
|
+
const val = item.value || item.hex || "#4f46e5";
|
|
5820
|
+
vars[`--ci-color-${item.key}`] = val;
|
|
5821
|
+
if (item.soft) vars[`--ci-color-${item.key}-soft`] = item.soft;
|
|
5822
|
+
if (item.contrast) vars[`--ci-color-${item.key}-contrast`] = item.contrast;
|
|
5823
|
+
}
|
|
5824
|
+
return vars;
|
|
5825
|
+
}
|
|
5826
|
+
const ciColorService = ({ strapi }) => ({
|
|
5827
|
+
async ensureSeeded() {
|
|
5828
|
+
const existing = await strapi.db.query(PALETTE_UID).findMany({ limit: 50 });
|
|
5829
|
+
if (Array.isArray(existing) && existing.length > 0) {
|
|
5830
|
+
const hasActive = existing.some((p) => p.isActive);
|
|
5831
|
+
if (!hasActive && existing[0]?.id) {
|
|
5832
|
+
await strapi.db.query(PALETTE_UID).update({
|
|
5833
|
+
where: { id: existing[0].id },
|
|
5834
|
+
data: { isActive: true }
|
|
5835
|
+
});
|
|
5836
|
+
}
|
|
5837
|
+
return;
|
|
5838
|
+
}
|
|
5839
|
+
for (const seed of DEFAULT_PALETTE_SEEDS) {
|
|
5840
|
+
const semanticTokens = {};
|
|
5841
|
+
for (const meta of SEMANTIC_TOKEN_META) {
|
|
5842
|
+
const rawHex = seed.rawSemantic[meta.key] || "#4f46e5";
|
|
5843
|
+
semanticTokens[meta.key] = buildTokenEntry(rawHex, { tr: meta.tr, en: meta.en });
|
|
5844
|
+
}
|
|
5845
|
+
const customTokens = seed.rawCustom.map((c) => ({
|
|
5846
|
+
key: c.key,
|
|
5847
|
+
...buildTokenEntry(c.value, c.labels),
|
|
5848
|
+
labels: c.labels
|
|
5849
|
+
}));
|
|
5850
|
+
await strapi.db.query(PALETTE_UID).create({
|
|
5851
|
+
data: {
|
|
5852
|
+
name: seed.name,
|
|
5853
|
+
slug: seed.slug,
|
|
5854
|
+
description: seed.description,
|
|
5855
|
+
isActive: seed.isActive,
|
|
5856
|
+
semanticTokens,
|
|
5857
|
+
customTokens
|
|
5858
|
+
}
|
|
5859
|
+
});
|
|
5860
|
+
}
|
|
5861
|
+
},
|
|
5862
|
+
async findAll() {
|
|
5863
|
+
await this.ensureSeeded();
|
|
5864
|
+
const palettes = await strapi.db.query(PALETTE_UID).findMany({
|
|
5865
|
+
orderBy: { id: "asc" }
|
|
5866
|
+
});
|
|
5867
|
+
const active = palettes.find((p) => p.isActive) || palettes[0] || null;
|
|
5868
|
+
return {
|
|
5869
|
+
data: palettes,
|
|
5870
|
+
active,
|
|
5871
|
+
cssVariables: buildCssVariablesMap(active)
|
|
5872
|
+
};
|
|
5873
|
+
},
|
|
5874
|
+
async findActivePublic(slugOverride) {
|
|
5875
|
+
await this.ensureSeeded();
|
|
5876
|
+
const allPalettes = await strapi.db.query(PALETTE_UID).findMany({
|
|
5877
|
+
orderBy: { id: "asc" }
|
|
5878
|
+
});
|
|
5879
|
+
let palette = null;
|
|
5880
|
+
if (slugOverride) {
|
|
5881
|
+
palette = allPalettes.find((p) => p.slug === slugOverride) || null;
|
|
5882
|
+
}
|
|
5883
|
+
if (!palette) {
|
|
5884
|
+
palette = allPalettes.find((p) => p.isActive) || allPalettes[0] || null;
|
|
5885
|
+
}
|
|
5886
|
+
return {
|
|
5887
|
+
data: palette,
|
|
5888
|
+
palette,
|
|
5889
|
+
palettes: allPalettes.map((p) => ({
|
|
5890
|
+
name: p.name,
|
|
5891
|
+
slug: p.slug,
|
|
5892
|
+
isActive: Boolean(p.isActive),
|
|
5893
|
+
primary: p.semanticTokens?.primary?.value || p.semanticTokens?.primary?.hex || "#4f46e5",
|
|
5894
|
+
secondary: p.semanticTokens?.secondary?.value || p.semanticTokens?.secondary?.hex || "#0ea5e9",
|
|
5895
|
+
accent: p.semanticTokens?.accent?.value || p.semanticTokens?.accent?.hex || "#f59e0b"
|
|
5896
|
+
})),
|
|
5897
|
+
cssVariables: buildCssVariablesMap(palette)
|
|
5898
|
+
};
|
|
5899
|
+
},
|
|
5900
|
+
async save(payload) {
|
|
5901
|
+
await this.ensureSeeded();
|
|
5902
|
+
const normalized = normalizePalettePayload(payload);
|
|
5903
|
+
let existing = null;
|
|
5904
|
+
if (payload?.id) {
|
|
5905
|
+
existing = await strapi.db.query(PALETTE_UID).findOne({ where: { id: Number(payload.id) } });
|
|
5906
|
+
}
|
|
5907
|
+
if (!existing && payload?.documentId) {
|
|
5908
|
+
existing = await strapi.db.query(PALETTE_UID).findOne({ where: { documentId: payload.documentId } });
|
|
5909
|
+
}
|
|
5910
|
+
if (!existing && normalized.slug) {
|
|
5911
|
+
existing = await strapi.db.query(PALETTE_UID).findOne({ where: { slug: normalized.slug } });
|
|
5912
|
+
}
|
|
5913
|
+
if (normalized.isActive) {
|
|
5914
|
+
await strapi.db.query(PALETTE_UID).updateMany({
|
|
5915
|
+
where: { isActive: true },
|
|
5916
|
+
data: { isActive: false }
|
|
5917
|
+
});
|
|
5918
|
+
}
|
|
5919
|
+
let saved;
|
|
5920
|
+
if (existing) {
|
|
5921
|
+
saved = await strapi.db.query(PALETTE_UID).update({
|
|
5922
|
+
where: { id: existing.id },
|
|
5923
|
+
data: {
|
|
5924
|
+
...normalized,
|
|
5925
|
+
isActive: normalized.isActive || existing.isActive
|
|
5926
|
+
}
|
|
5927
|
+
});
|
|
5928
|
+
} else {
|
|
5929
|
+
saved = await strapi.db.query(PALETTE_UID).create({
|
|
5930
|
+
data: normalized
|
|
5931
|
+
});
|
|
5932
|
+
}
|
|
5933
|
+
return this.findAll().then((res) => ({
|
|
5934
|
+
...res,
|
|
5935
|
+
saved
|
|
5936
|
+
}));
|
|
5937
|
+
},
|
|
5938
|
+
async activate(idOrSlug) {
|
|
5939
|
+
await this.ensureSeeded();
|
|
5940
|
+
const str = String(idOrSlug).trim();
|
|
5941
|
+
let target = null;
|
|
5942
|
+
if (/^\d+$/.test(str)) {
|
|
5943
|
+
target = await strapi.db.query(PALETTE_UID).findOne({ where: { id: Number(str) } });
|
|
5944
|
+
}
|
|
5945
|
+
if (!target) {
|
|
5946
|
+
target = await strapi.db.query(PALETTE_UID).findOne({
|
|
5947
|
+
where: { $or: [{ slug: str }, { documentId: str }] }
|
|
5948
|
+
});
|
|
5949
|
+
}
|
|
5950
|
+
if (!target) return null;
|
|
5951
|
+
await strapi.db.query(PALETTE_UID).updateMany({
|
|
5952
|
+
where: { isActive: true },
|
|
5953
|
+
data: { isActive: false }
|
|
5954
|
+
});
|
|
5955
|
+
await strapi.db.query(PALETTE_UID).update({
|
|
5956
|
+
where: { id: target.id },
|
|
5957
|
+
data: { isActive: true }
|
|
5958
|
+
});
|
|
5959
|
+
return this.findAll();
|
|
5960
|
+
},
|
|
5961
|
+
async upsertQuickCustomToken(input) {
|
|
5962
|
+
await this.ensureSeeded();
|
|
5963
|
+
const { active } = await this.findActivePublic().then((r) => ({ active: r.data }));
|
|
5964
|
+
if (!active) return null;
|
|
5965
|
+
const cleanKey = String(input.key || input.label || "customColor").trim().replace(/[^a-zA-Z0-9_-]/g, "") || `color_${Date.now()}`;
|
|
5966
|
+
const labelStr = String(input.label || cleanKey).trim();
|
|
5967
|
+
const labels = input.labels && typeof input.labels === "object" ? input.labels : { tr: labelStr, en: labelStr };
|
|
5968
|
+
const tokenEntry = {
|
|
5969
|
+
key: cleanKey,
|
|
5970
|
+
...buildTokenEntry(input.value, labels),
|
|
5971
|
+
labels
|
|
5972
|
+
};
|
|
5973
|
+
const prevCustom = Array.isArray(active.customTokens) ? [...active.customTokens] : [];
|
|
5974
|
+
const idx = prevCustom.findIndex((t) => t.key === cleanKey);
|
|
5975
|
+
if (idx >= 0) {
|
|
5976
|
+
prevCustom[idx] = tokenEntry;
|
|
5977
|
+
} else {
|
|
5978
|
+
prevCustom.push(tokenEntry);
|
|
5979
|
+
}
|
|
5980
|
+
await strapi.db.query(PALETTE_UID).update({
|
|
5981
|
+
where: { id: active.id },
|
|
5982
|
+
data: { customTokens: prevCustom }
|
|
5983
|
+
});
|
|
5984
|
+
return {
|
|
5985
|
+
...await this.findAll(),
|
|
5986
|
+
addedToken: tokenEntry
|
|
5987
|
+
};
|
|
5988
|
+
},
|
|
5989
|
+
async remove(idOrSlug) {
|
|
5990
|
+
const str = String(idOrSlug).trim();
|
|
5991
|
+
const all = await strapi.db.query(PALETTE_UID).findMany();
|
|
5992
|
+
if (all.length <= 1) {
|
|
5993
|
+
throw new Error("Cannot delete the last remaining color palette");
|
|
5994
|
+
}
|
|
5995
|
+
const target = all.find(
|
|
5996
|
+
(p) => String(p.id) === str || p.slug === str || p.documentId === str
|
|
5997
|
+
);
|
|
5998
|
+
if (!target) return this.findAll();
|
|
5999
|
+
await strapi.db.query(PALETTE_UID).delete({ where: { id: target.id } });
|
|
6000
|
+
if (target.isActive) {
|
|
6001
|
+
const remaining = await strapi.db.query(PALETTE_UID).findMany({ limit: 1 });
|
|
6002
|
+
if (remaining[0]) {
|
|
6003
|
+
await strapi.db.query(PALETTE_UID).update({
|
|
6004
|
+
where: { id: remaining[0].id },
|
|
6005
|
+
data: { isActive: true }
|
|
6006
|
+
});
|
|
6007
|
+
}
|
|
6008
|
+
}
|
|
6009
|
+
return this.findAll();
|
|
6010
|
+
},
|
|
6011
|
+
/**
|
|
6012
|
+
* Safe public collection query for Data Table (`sourceMode: 'strapi_collection'`)
|
|
6013
|
+
*/
|
|
6014
|
+
async queryCollectionForDataTable(params) {
|
|
6015
|
+
const uid = String(params.uid || "").trim();
|
|
6016
|
+
if (!uid.startsWith("api::")) {
|
|
6017
|
+
return { columns: [], rows: [] };
|
|
6018
|
+
}
|
|
6019
|
+
const ct = strapi.contentTypes[uid];
|
|
6020
|
+
if (!ct) {
|
|
6021
|
+
return { columns: [], rows: [] };
|
|
6022
|
+
}
|
|
6023
|
+
const attrs = ct.attributes || {};
|
|
6024
|
+
const forbiddenTypes = /* @__PURE__ */ new Set(["password", "dynamiczone", "component", "relation"]);
|
|
6025
|
+
const allowedFields = [
|
|
6026
|
+
{ key: "documentId", type: "text" }
|
|
6027
|
+
];
|
|
6028
|
+
for (const [fieldName, attr] of Object.entries(attrs)) {
|
|
6029
|
+
if (!attr || attr.private) continue;
|
|
6030
|
+
if (/password|secret|token|hash/i.test(fieldName)) continue;
|
|
6031
|
+
if (attr.customField === "plugin::content-input.content-input") continue;
|
|
6032
|
+
if (forbiddenTypes.has(attr.type)) continue;
|
|
6033
|
+
allowedFields.push({ key: fieldName, type: attr.type || "string" });
|
|
6034
|
+
}
|
|
6035
|
+
for (const sysKey of ["createdAt", "updatedAt", "publishedAt"]) {
|
|
6036
|
+
if (!allowedFields.some((f) => f.key === sysKey)) {
|
|
6037
|
+
allowedFields.push({ key: sysKey, type: "datetime" });
|
|
6038
|
+
}
|
|
6039
|
+
}
|
|
6040
|
+
if (!allowedFields.some((f) => f.key === "collectionLabel")) {
|
|
6041
|
+
allowedFields.push({ key: "collectionLabel", type: "enumeration" });
|
|
6042
|
+
}
|
|
6043
|
+
if (attrs.slug && !allowedFields.some((f) => f.key === "url")) {
|
|
6044
|
+
allowedFields.push({ key: "url", type: "uid" });
|
|
6045
|
+
}
|
|
6046
|
+
const limit = clamp(Number(params.limit) || 25, 1, 100);
|
|
6047
|
+
let entries = [];
|
|
6048
|
+
try {
|
|
6049
|
+
const docService = strapi.documents?.(uid);
|
|
6050
|
+
if (docService) {
|
|
6051
|
+
entries = await docService.findMany({
|
|
6052
|
+
status: "published",
|
|
6053
|
+
limit,
|
|
6054
|
+
sort: params.sort || "createdAt:desc",
|
|
6055
|
+
populate: "*"
|
|
6056
|
+
});
|
|
6057
|
+
if (!entries.length) {
|
|
6058
|
+
entries = await docService.findMany({
|
|
6059
|
+
limit,
|
|
6060
|
+
sort: params.sort || "createdAt:desc",
|
|
6061
|
+
populate: "*"
|
|
6062
|
+
});
|
|
6063
|
+
}
|
|
6064
|
+
} else {
|
|
6065
|
+
entries = await strapi.db.query(uid).findMany({ limit, populate: true });
|
|
6066
|
+
}
|
|
6067
|
+
} catch {
|
|
6068
|
+
entries = [];
|
|
6069
|
+
}
|
|
6070
|
+
const collectionLabelText = ct.info?.displayName || uid;
|
|
6071
|
+
const sanitizedRows = (entries || []).map((entry) => {
|
|
6072
|
+
const row = {};
|
|
6073
|
+
for (const f of allowedFields) {
|
|
6074
|
+
if (f.key === "collectionLabel" && entry.collectionLabel === void 0) {
|
|
6075
|
+
row.collectionLabel = collectionLabelText;
|
|
6076
|
+
continue;
|
|
6077
|
+
}
|
|
6078
|
+
if (f.key === "url" && entry.url === void 0) {
|
|
6079
|
+
const slugStr = entry.slug ? String(entry.slug).trim() : "";
|
|
6080
|
+
row.url = slugStr ? slugStr === "home" ? "/" : `/${slugStr.replace(/^\/+/, "")}` : "";
|
|
6081
|
+
continue;
|
|
6082
|
+
}
|
|
6083
|
+
const val = entry[f.key];
|
|
6084
|
+
if (val !== null && val !== void 0 && typeof val === "object") {
|
|
6085
|
+
if (Array.isArray(val)) {
|
|
6086
|
+
row[f.key] = val[0]?.url || `${val.length} item`;
|
|
6087
|
+
} else if (val.url) {
|
|
6088
|
+
row[f.key] = val.url;
|
|
6089
|
+
} else {
|
|
6090
|
+
row[f.key] = "";
|
|
6091
|
+
}
|
|
6092
|
+
} else {
|
|
6093
|
+
row[f.key] = val ?? "";
|
|
6094
|
+
}
|
|
6095
|
+
}
|
|
6096
|
+
return row;
|
|
6097
|
+
});
|
|
6098
|
+
return {
|
|
6099
|
+
uid,
|
|
6100
|
+
displayName: ct.info?.displayName || uid,
|
|
6101
|
+
availableFields: allowedFields,
|
|
6102
|
+
rows: sanitizedRows
|
|
6103
|
+
};
|
|
6104
|
+
},
|
|
6105
|
+
/**
|
|
6106
|
+
* Batch Entity Cards resolver for `entityCard` Swiper Carousel & Grid modes
|
|
6107
|
+
*/
|
|
6108
|
+
async resolveEntityCardsBatch(params) {
|
|
6109
|
+
const uid = String(params.uid || "api::page.page").trim();
|
|
6110
|
+
if (!uid.startsWith("api::")) return [];
|
|
6111
|
+
const formSvc = strapi.plugin("content-input").service("ci-form");
|
|
6112
|
+
const docIds = Array.isArray(params.documentIds) ? params.documentIds.map((s) => String(s).trim()).filter(Boolean) : [];
|
|
6113
|
+
if (docIds.length > 0) {
|
|
6114
|
+
const results = await Promise.all(
|
|
6115
|
+
docIds.map(
|
|
6116
|
+
(documentId) => formSvc.resolveEntityCard({ uid, documentId }).catch(() => null)
|
|
6117
|
+
)
|
|
6118
|
+
);
|
|
6119
|
+
return results.filter(Boolean);
|
|
6120
|
+
}
|
|
6121
|
+
const limit = clamp(Number(params.limit) || 6, 1, 24);
|
|
6122
|
+
try {
|
|
6123
|
+
const docService = strapi.documents?.(uid);
|
|
6124
|
+
let entries = [];
|
|
6125
|
+
if (docService) {
|
|
6126
|
+
entries = await docService.findMany({ status: "published", limit, sort: "createdAt:desc" });
|
|
6127
|
+
if (!entries.length) {
|
|
6128
|
+
entries = await docService.findMany({ limit, sort: "createdAt:desc" });
|
|
6129
|
+
}
|
|
6130
|
+
} else {
|
|
6131
|
+
entries = await strapi.db.query(uid).findMany({ limit });
|
|
6132
|
+
}
|
|
6133
|
+
const uniqueDocIds = Array.from(
|
|
6134
|
+
new Set(entries.map((e) => e.documentId).filter(Boolean))
|
|
6135
|
+
);
|
|
6136
|
+
const cards = await Promise.all(
|
|
6137
|
+
uniqueDocIds.slice(0, limit).map(
|
|
6138
|
+
(documentId) => formSvc.resolveEntityCard({ uid, documentId }).catch(() => null)
|
|
6139
|
+
)
|
|
6140
|
+
);
|
|
6141
|
+
return cards.filter(Boolean);
|
|
6142
|
+
} catch {
|
|
6143
|
+
return [];
|
|
6144
|
+
}
|
|
6145
|
+
}
|
|
6146
|
+
});
|
|
5264
6147
|
const services = {
|
|
5265
6148
|
"ci-template": ciTemplateService,
|
|
5266
6149
|
"ci-menu": ciMenuService,
|
|
5267
6150
|
"ci-form": ciFormService,
|
|
5268
|
-
"ci-survey": ciSurveyService
|
|
6151
|
+
"ci-survey": ciSurveyService,
|
|
6152
|
+
"ci-color": ciColorService
|
|
5269
6153
|
};
|
|
5270
6154
|
const index = {
|
|
5271
6155
|
register,
|