@ozguraltan/strapi-content-input 0.0.0-stage → 1.0.4
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 +353 -2
- package/dist/admin/ContentInputField-CmfnTMVL.js +13891 -0
- package/dist/admin/ContentInputField-DWTaFM9i.mjs +13888 -0
- package/dist/admin/en-BRL85DLZ.js +7 -0
- package/dist/admin/en-ua8BQs0I.mjs +7 -0
- package/dist/admin/index-C7Z1NWlp.js +173 -0
- package/dist/admin/index-DhJXTZlO.mjs +172 -0
- package/dist/admin/index.js +5 -0
- package/dist/admin/index.mjs +5 -0
- package/dist/admin/src/components/ContentInputField.d.ts +23 -0
- package/dist/admin/src/components/editor/CIContextMenu.d.ts +2 -0
- package/dist/admin/src/components/editor/CanvasNodes.d.ts +20 -0
- package/dist/admin/src/components/editor/VECanvas.d.ts +2 -0
- package/dist/admin/src/components/editor/VEInsertPoint.d.ts +7 -0
- package/dist/admin/src/components/editor/VELeftPanel.d.ts +5 -0
- package/dist/admin/src/components/editor/VENodeToolbar.d.ts +13 -0
- package/dist/admin/src/components/editor/VEPreviewFrame.d.ts +7 -0
- package/dist/admin/src/components/editor/VETopBar.d.ts +5 -0
- package/dist/admin/src/components/editor/VisualEditorModal.d.ts +6 -0
- package/dist/admin/src/components/editor/inspector/VEInspector.d.ts +5 -0
- package/dist/admin/src/components/icons/MaterialIcon.d.ts +9 -0
- package/dist/admin/src/components/widgets/MenuWidgetEditor.d.ts +30 -0
- package/dist/admin/src/components/widgets/RichHtmlEditor.d.ts +8 -0
- package/dist/admin/src/components/widgets/StrapiMediaPicker.d.ts +9 -0
- package/dist/admin/src/components/widgets/TabAccordionEditor.d.ts +26 -0
- package/dist/admin/src/components/widgets/WidgetEditor.d.ts +10 -0
- package/dist/admin/src/components/widgets/WidgetPreview.d.ts +9 -0
- package/dist/admin/src/core/EditorContext.d.ts +134 -0
- package/dist/admin/src/core/canvasClasses.d.ts +9 -0
- package/dist/admin/src/core/clipboard.d.ts +9 -0
- package/dist/admin/src/core/devices.d.ts +16 -0
- package/dist/admin/src/core/history.d.ts +13 -0
- package/dist/admin/src/core/i18n.d.ts +2 -0
- package/dist/admin/src/core/presets.d.ts +23 -0
- package/dist/admin/src/core/sampleData.d.ts +2 -0
- package/dist/admin/src/core/treeOps.d.ts +10 -0
- package/dist/admin/src/core/types.d.ts +72 -0
- package/dist/admin/src/index.d.ts +14 -0
- package/dist/admin/src/pluginId.d.ts +1 -0
- package/dist/admin/src/styles/ciCanvasStyles.d.ts +2 -0
- package/dist/admin/tr-BmB19xV-.js +7 -0
- package/dist/admin/tr-Dg7KhusF.mjs +7 -0
- package/dist/server/index.js +702 -0
- package/dist/server/index.mjs +702 -0
- package/dist/server/src/bootstrap.d.ts +5 -0
- package/dist/server/src/config/index.d.ts +7 -0
- package/dist/server/src/content-types/ci-menu/schema.json.d.ts +46 -0
- package/dist/server/src/content-types/ci-template/schema.json.d.ts +42 -0
- package/dist/server/src/content-types/index.d.ts +88 -0
- package/dist/server/src/controllers/ci-menu.d.ts +12 -0
- package/dist/server/src/controllers/ci-template.d.ts +9 -0
- package/dist/server/src/controllers/index.d.ts +20 -0
- package/dist/server/src/destroy.d.ts +5 -0
- package/dist/server/src/index.d.ts +187 -0
- package/dist/server/src/register.d.ts +5 -0
- package/dist/server/src/routes/index.d.ts +14 -0
- package/dist/server/src/services/ci-menu.d.ts +36 -0
- package/dist/server/src/services/ci-template.d.ts +16 -0
- package/dist/server/src/services/index.d.ts +51 -0
- package/package.json +89 -4
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const register = ({ strapi }) => {
|
|
4
|
+
strapi.customFields.register({
|
|
5
|
+
name: "content-input",
|
|
6
|
+
plugin: "content-input",
|
|
7
|
+
type: "json",
|
|
8
|
+
inputSize: {
|
|
9
|
+
default: 12,
|
|
10
|
+
isResizable: false
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
const bootstrap = ({ strapi }) => {
|
|
15
|
+
};
|
|
16
|
+
const destroy = ({ strapi }) => {
|
|
17
|
+
};
|
|
18
|
+
const config = {
|
|
19
|
+
default: {
|
|
20
|
+
previewUrl: "/ci-preview"
|
|
21
|
+
},
|
|
22
|
+
validator() {
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const kind$1 = "collectionType";
|
|
26
|
+
const collectionName$1 = "ci_templates";
|
|
27
|
+
const info$1 = { "singularName": "ci-template", "pluralName": "ci-templates", "displayName": "ContentInput Template", "description": "Saved visual editor row/section templates" };
|
|
28
|
+
const options$1 = { "draftAndPublish": false };
|
|
29
|
+
const pluginOptions$1 = { "content-manager": { "visible": false }, "content-type-builder": { "visible": false } };
|
|
30
|
+
const attributes$1 = { "name": { "type": "string", "required": true }, "category": { "type": "string", "default": "custom" }, "structure": { "type": "json", "required": true }, "thumbnail": { "type": "string", "default": "" } };
|
|
31
|
+
const templateSchema = {
|
|
32
|
+
kind: kind$1,
|
|
33
|
+
collectionName: collectionName$1,
|
|
34
|
+
info: info$1,
|
|
35
|
+
options: options$1,
|
|
36
|
+
pluginOptions: pluginOptions$1,
|
|
37
|
+
attributes: attributes$1
|
|
38
|
+
};
|
|
39
|
+
const kind = "collectionType";
|
|
40
|
+
const collectionName = "ci_menus";
|
|
41
|
+
const info = { "singularName": "ci-menu", "pluralName": "ci-menus", "displayName": "ContentInput Menu", "description": "Reusable nested menus (horizontal & vertical) for ContentInput" };
|
|
42
|
+
const options = { "draftAndPublish": false };
|
|
43
|
+
const pluginOptions = { "content-manager": { "visible": false }, "content-type-builder": { "visible": false } };
|
|
44
|
+
const attributes = { "name": { "type": "string", "required": true }, "slug": { "type": "string", "required": true }, "mode": { "type": "string", "default": "horizontal" }, "items": { "type": "json", "required": true }, "options": { "type": "json" } };
|
|
45
|
+
const menuSchema = {
|
|
46
|
+
kind,
|
|
47
|
+
collectionName,
|
|
48
|
+
info,
|
|
49
|
+
options,
|
|
50
|
+
pluginOptions,
|
|
51
|
+
attributes
|
|
52
|
+
};
|
|
53
|
+
const contentTypes = {
|
|
54
|
+
"ci-template": {
|
|
55
|
+
schema: templateSchema
|
|
56
|
+
},
|
|
57
|
+
"ci-menu": {
|
|
58
|
+
schema: menuSchema
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const ciTemplateController = ({ strapi }) => ({
|
|
62
|
+
async index(ctx) {
|
|
63
|
+
try {
|
|
64
|
+
const list = await strapi.plugin("content-input").service("ci-template").findAll();
|
|
65
|
+
ctx.body = list;
|
|
66
|
+
} catch (err) {
|
|
67
|
+
ctx.throw(500, err);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
async save(ctx) {
|
|
71
|
+
try {
|
|
72
|
+
const { name, structure, category, thumbnail } = ctx.request.body || {};
|
|
73
|
+
if (!name || !structure) {
|
|
74
|
+
return ctx.badRequest("Name and structure are required");
|
|
75
|
+
}
|
|
76
|
+
const created = await strapi.plugin("content-input").service("ci-template").create({
|
|
77
|
+
name,
|
|
78
|
+
category,
|
|
79
|
+
structure,
|
|
80
|
+
thumbnail
|
|
81
|
+
});
|
|
82
|
+
ctx.status = 201;
|
|
83
|
+
ctx.body = created;
|
|
84
|
+
} catch (err) {
|
|
85
|
+
ctx.throw(500, err);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
async delete(ctx) {
|
|
89
|
+
try {
|
|
90
|
+
const { id } = ctx.params;
|
|
91
|
+
const result = await strapi.plugin("content-input").service("ci-template").remove(id);
|
|
92
|
+
ctx.body = result;
|
|
93
|
+
} catch (err) {
|
|
94
|
+
ctx.throw(500, err);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const ciMenuController = ({ strapi }) => ({
|
|
99
|
+
async index(ctx) {
|
|
100
|
+
try {
|
|
101
|
+
const list = await strapi.plugin("content-input").service("ci-menu").findAll();
|
|
102
|
+
ctx.body = list;
|
|
103
|
+
} catch (err) {
|
|
104
|
+
ctx.throw(500, err);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
async save(ctx) {
|
|
108
|
+
try {
|
|
109
|
+
const { id, name, slug, mode, items, options: options2 } = ctx.request.body || {};
|
|
110
|
+
if (!name) {
|
|
111
|
+
return ctx.badRequest("Menu name is required");
|
|
112
|
+
}
|
|
113
|
+
const saved = await strapi.plugin("content-input").service("ci-menu").save({
|
|
114
|
+
id,
|
|
115
|
+
name,
|
|
116
|
+
slug,
|
|
117
|
+
mode,
|
|
118
|
+
items: Array.isArray(items) ? items : [],
|
|
119
|
+
options: options2
|
|
120
|
+
});
|
|
121
|
+
ctx.status = 200;
|
|
122
|
+
ctx.body = saved;
|
|
123
|
+
} catch (err) {
|
|
124
|
+
ctx.throw(500, err);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
async delete(ctx) {
|
|
128
|
+
try {
|
|
129
|
+
const { id } = ctx.params;
|
|
130
|
+
const result = await strapi.plugin("content-input").service("ci-menu").remove(id);
|
|
131
|
+
ctx.body = result;
|
|
132
|
+
} catch (err) {
|
|
133
|
+
ctx.throw(500, err);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
async entityTypes(ctx) {
|
|
137
|
+
try {
|
|
138
|
+
const types = strapi.plugin("content-input").service("ci-menu").getEntityTypes();
|
|
139
|
+
ctx.body = types;
|
|
140
|
+
} catch (err) {
|
|
141
|
+
ctx.throw(500, err);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
async entities(ctx) {
|
|
145
|
+
try {
|
|
146
|
+
const { uid, q, tree } = ctx.query || {};
|
|
147
|
+
const result = await strapi.plugin("content-input").service("ci-menu").searchEntities({
|
|
148
|
+
uid: uid ? String(uid) : void 0,
|
|
149
|
+
q: q ? String(q) : void 0,
|
|
150
|
+
tree: tree === "true" || tree === "1"
|
|
151
|
+
});
|
|
152
|
+
ctx.body = result;
|
|
153
|
+
} catch (err) {
|
|
154
|
+
ctx.throw(500, err);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
async mediaList(ctx) {
|
|
158
|
+
try {
|
|
159
|
+
const files = await strapi.db.query("plugin::upload.file").findMany({
|
|
160
|
+
orderBy: { createdAt: "desc" },
|
|
161
|
+
limit: 120
|
|
162
|
+
});
|
|
163
|
+
ctx.body = { data: Array.isArray(files) ? files : [] };
|
|
164
|
+
} catch (err) {
|
|
165
|
+
ctx.throw(500, err);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
const controllers = {
|
|
170
|
+
"ci-template": ciTemplateController,
|
|
171
|
+
"ci-menu": ciMenuController
|
|
172
|
+
};
|
|
173
|
+
const routes = {
|
|
174
|
+
admin: {
|
|
175
|
+
type: "admin",
|
|
176
|
+
routes: [
|
|
177
|
+
{
|
|
178
|
+
method: "GET",
|
|
179
|
+
path: "/templates",
|
|
180
|
+
handler: "ci-template.index",
|
|
181
|
+
config: {
|
|
182
|
+
policies: []
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
method: "POST",
|
|
187
|
+
path: "/templates",
|
|
188
|
+
handler: "ci-template.save",
|
|
189
|
+
config: {
|
|
190
|
+
policies: []
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
method: "DELETE",
|
|
195
|
+
path: "/templates/:id",
|
|
196
|
+
handler: "ci-template.delete",
|
|
197
|
+
config: {
|
|
198
|
+
policies: []
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
method: "GET",
|
|
203
|
+
path: "/menus",
|
|
204
|
+
handler: "ci-menu.index",
|
|
205
|
+
config: {
|
|
206
|
+
policies: []
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
method: "POST",
|
|
211
|
+
path: "/menus",
|
|
212
|
+
handler: "ci-menu.save",
|
|
213
|
+
config: {
|
|
214
|
+
policies: []
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
method: "DELETE",
|
|
219
|
+
path: "/menus/:id",
|
|
220
|
+
handler: "ci-menu.delete",
|
|
221
|
+
config: {
|
|
222
|
+
policies: []
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
method: "GET",
|
|
227
|
+
path: "/entity-types",
|
|
228
|
+
handler: "ci-menu.entityTypes",
|
|
229
|
+
config: {
|
|
230
|
+
policies: []
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
method: "GET",
|
|
235
|
+
path: "/entities",
|
|
236
|
+
handler: "ci-menu.entities",
|
|
237
|
+
config: {
|
|
238
|
+
policies: []
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
method: "GET",
|
|
243
|
+
path: "/media",
|
|
244
|
+
handler: "ci-menu.mediaList",
|
|
245
|
+
config: {
|
|
246
|
+
policies: []
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
const UID = "plugin::content-input.ci-template";
|
|
253
|
+
const ciTemplateService = ({ strapi }) => ({
|
|
254
|
+
async findAll() {
|
|
255
|
+
const entries = await strapi.db.query(UID).findMany({
|
|
256
|
+
orderBy: { createdAt: "desc" }
|
|
257
|
+
});
|
|
258
|
+
return entries.map((item) => ({
|
|
259
|
+
...item,
|
|
260
|
+
_id: item.documentId || String(item.id)
|
|
261
|
+
}));
|
|
262
|
+
},
|
|
263
|
+
async create(data) {
|
|
264
|
+
const structure = Array.isArray(data.structure) ? data.structure : [data.structure];
|
|
265
|
+
const created = await strapi.db.query(UID).create({
|
|
266
|
+
data: {
|
|
267
|
+
name: String(data.name || "").trim(),
|
|
268
|
+
category: data.category || "custom",
|
|
269
|
+
structure,
|
|
270
|
+
thumbnail: data.thumbnail || ""
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
return {
|
|
274
|
+
...created,
|
|
275
|
+
_id: created.documentId || String(created.id)
|
|
276
|
+
};
|
|
277
|
+
},
|
|
278
|
+
async remove(idOrDocId) {
|
|
279
|
+
const numericId = Number(idOrDocId);
|
|
280
|
+
if (!Number.isNaN(numericId) && String(numericId) === String(idOrDocId)) {
|
|
281
|
+
await strapi.db.query(UID).delete({
|
|
282
|
+
where: { id: numericId }
|
|
283
|
+
});
|
|
284
|
+
} else {
|
|
285
|
+
await strapi.db.query(UID).delete({
|
|
286
|
+
where: { documentId: String(idOrDocId) }
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
return { success: true };
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
const MENU_UID = "plugin::content-input.ci-menu";
|
|
293
|
+
function slugifyTR(text) {
|
|
294
|
+
const map = {
|
|
295
|
+
ç: "c",
|
|
296
|
+
Ç: "c",
|
|
297
|
+
ğ: "g",
|
|
298
|
+
Ğ: "g",
|
|
299
|
+
ı: "i",
|
|
300
|
+
İ: "i",
|
|
301
|
+
ö: "o",
|
|
302
|
+
Ö: "o",
|
|
303
|
+
ş: "s",
|
|
304
|
+
Ş: "s",
|
|
305
|
+
ü: "u",
|
|
306
|
+
Ü: "u"
|
|
307
|
+
};
|
|
308
|
+
return String(text || "").replace(/[çÇğĞıİöÖşŞüÜ]/g, (ch) => map[ch] || ch).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
309
|
+
}
|
|
310
|
+
const DEFAULT_SEED_MENUS = [
|
|
311
|
+
{
|
|
312
|
+
name: "Üst Ana Navigasyon Menüsü",
|
|
313
|
+
slug: "main-header-menu",
|
|
314
|
+
mode: "horizontal",
|
|
315
|
+
options: {
|
|
316
|
+
mode: "horizontal",
|
|
317
|
+
bgColor: "#ffffff",
|
|
318
|
+
textColor: "#0f172a",
|
|
319
|
+
accentColor: "#2669a0"
|
|
320
|
+
},
|
|
321
|
+
items: [
|
|
322
|
+
{
|
|
323
|
+
_uId: "m_home",
|
|
324
|
+
title: "Ana Sayfa",
|
|
325
|
+
url: "/",
|
|
326
|
+
type: "custom",
|
|
327
|
+
target: "_self",
|
|
328
|
+
icon: "home",
|
|
329
|
+
children: []
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
_uId: "m_corp",
|
|
333
|
+
title: "Kurumsal",
|
|
334
|
+
url: "/kurumsal",
|
|
335
|
+
type: "custom",
|
|
336
|
+
target: "_self",
|
|
337
|
+
icon: "business",
|
|
338
|
+
children: [
|
|
339
|
+
{
|
|
340
|
+
_uId: "m_about",
|
|
341
|
+
title: "Hakkımızda",
|
|
342
|
+
url: "/kurumsal/hakkimizda",
|
|
343
|
+
type: "custom",
|
|
344
|
+
target: "_self",
|
|
345
|
+
children: []
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
_uId: "m_vision",
|
|
349
|
+
title: "Vizyon & Misyon",
|
|
350
|
+
url: "/kurumsal/vizyon-misyon",
|
|
351
|
+
type: "custom",
|
|
352
|
+
target: "_self",
|
|
353
|
+
children: [
|
|
354
|
+
{
|
|
355
|
+
_uId: "m_values",
|
|
356
|
+
title: "Değerlerimiz & İlkelerimiz",
|
|
357
|
+
url: "/kurumsal/degerlerimiz",
|
|
358
|
+
type: "custom",
|
|
359
|
+
target: "_self",
|
|
360
|
+
children: []
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
_uId: "m_board",
|
|
366
|
+
title: "Yönetim Kurulu",
|
|
367
|
+
url: "/kurumsal/yonetim-kurulu",
|
|
368
|
+
type: "custom",
|
|
369
|
+
target: "_self",
|
|
370
|
+
children: []
|
|
371
|
+
}
|
|
372
|
+
]
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
_uId: "m_solutions",
|
|
376
|
+
title: "Çözümlerimiz",
|
|
377
|
+
url: "/cozumler",
|
|
378
|
+
type: "custom",
|
|
379
|
+
target: "_self",
|
|
380
|
+
icon: "layers",
|
|
381
|
+
children: [
|
|
382
|
+
{
|
|
383
|
+
_uId: "m_sol_cms",
|
|
384
|
+
title: "Kurumsal İçerik Yönetimi (CMS)",
|
|
385
|
+
url: "/cozumler/cms",
|
|
386
|
+
type: "custom",
|
|
387
|
+
target: "_self",
|
|
388
|
+
children: []
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
_uId: "m_sol_cloud",
|
|
392
|
+
title: "Bulut & Mikroservis Mimarisi",
|
|
393
|
+
url: "/cozumler/bulut",
|
|
394
|
+
type: "custom",
|
|
395
|
+
target: "_self",
|
|
396
|
+
children: []
|
|
397
|
+
}
|
|
398
|
+
]
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
_uId: "m_contact",
|
|
402
|
+
title: "İletişim",
|
|
403
|
+
url: "/iletisim",
|
|
404
|
+
type: "custom",
|
|
405
|
+
target: "_self",
|
|
406
|
+
icon: "mail",
|
|
407
|
+
children: []
|
|
408
|
+
}
|
|
409
|
+
]
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
name: "Kurumsal Sol Yan Menü (Düşey Ağaç)",
|
|
413
|
+
slug: "corporate-sidebar-menu",
|
|
414
|
+
mode: "vertical",
|
|
415
|
+
options: {
|
|
416
|
+
mode: "vertical",
|
|
417
|
+
bgColor: "#f8fafc",
|
|
418
|
+
textColor: "#1e293b",
|
|
419
|
+
accentColor: "#2669a0"
|
|
420
|
+
},
|
|
421
|
+
items: [
|
|
422
|
+
{
|
|
423
|
+
_uId: "v_corp",
|
|
424
|
+
title: "Kurumsal Bilgiler",
|
|
425
|
+
url: "/kurumsal",
|
|
426
|
+
type: "custom",
|
|
427
|
+
target: "_self",
|
|
428
|
+
children: [
|
|
429
|
+
{
|
|
430
|
+
_uId: "v_history",
|
|
431
|
+
title: "Tarihçemiz",
|
|
432
|
+
url: "/kurumsal/tarihce",
|
|
433
|
+
type: "custom",
|
|
434
|
+
target: "_self",
|
|
435
|
+
children: []
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
_uId: "v_quality",
|
|
439
|
+
title: "Kalite Politikamız",
|
|
440
|
+
url: "/kurumsal/kalite",
|
|
441
|
+
type: "custom",
|
|
442
|
+
target: "_self",
|
|
443
|
+
children: [
|
|
444
|
+
{
|
|
445
|
+
_uId: "v_iso",
|
|
446
|
+
title: "ISO 27001 & Sertifikalar",
|
|
447
|
+
url: "/kurumsal/kalite/sertifikalar",
|
|
448
|
+
type: "custom",
|
|
449
|
+
target: "_self",
|
|
450
|
+
children: []
|
|
451
|
+
}
|
|
452
|
+
]
|
|
453
|
+
}
|
|
454
|
+
]
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
_uId: "v_career",
|
|
458
|
+
title: "İnsan Kaynakları & Kariyer",
|
|
459
|
+
url: "/kariyer",
|
|
460
|
+
type: "custom",
|
|
461
|
+
target: "_self",
|
|
462
|
+
children: []
|
|
463
|
+
}
|
|
464
|
+
]
|
|
465
|
+
}
|
|
466
|
+
];
|
|
467
|
+
const ciMenuService = ({ strapi }) => ({
|
|
468
|
+
async findAll() {
|
|
469
|
+
let entries = await strapi.db.query(MENU_UID).findMany({
|
|
470
|
+
orderBy: { createdAt: "desc" }
|
|
471
|
+
});
|
|
472
|
+
if (!entries || entries.length === 0) {
|
|
473
|
+
for (const seed of DEFAULT_SEED_MENUS) {
|
|
474
|
+
await strapi.db.query(MENU_UID).create({ data: seed });
|
|
475
|
+
}
|
|
476
|
+
entries = await strapi.db.query(MENU_UID).findMany({
|
|
477
|
+
orderBy: { createdAt: "desc" }
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
return entries.map((item) => ({
|
|
481
|
+
...item,
|
|
482
|
+
_id: item.documentId || String(item.id)
|
|
483
|
+
}));
|
|
484
|
+
},
|
|
485
|
+
async save(data) {
|
|
486
|
+
const cleanName = String(data.name || "Menü").trim();
|
|
487
|
+
const cleanSlug = String(data.slug || slugifyTR(cleanName) || `menu-${Date.now()}`).trim();
|
|
488
|
+
const cleanMode = data.mode === "vertical" ? "vertical" : "horizontal";
|
|
489
|
+
const cleanItems = Array.isArray(data.items) ? data.items : [];
|
|
490
|
+
let existing = null;
|
|
491
|
+
if (data.id) {
|
|
492
|
+
const numId = Number(data.id);
|
|
493
|
+
if (!Number.isNaN(numId) && String(numId) === String(data.id)) {
|
|
494
|
+
existing = await strapi.db.query(MENU_UID).findOne({ where: { id: numId } });
|
|
495
|
+
} else {
|
|
496
|
+
existing = await strapi.db.query(MENU_UID).findOne({ where: { documentId: String(data.id) } });
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (!existing && cleanSlug) {
|
|
500
|
+
existing = await strapi.db.query(MENU_UID).findOne({ where: { slug: cleanSlug } });
|
|
501
|
+
}
|
|
502
|
+
if (existing) {
|
|
503
|
+
const updated = await strapi.db.query(MENU_UID).update({
|
|
504
|
+
where: { id: existing.id },
|
|
505
|
+
data: {
|
|
506
|
+
name: cleanName,
|
|
507
|
+
slug: cleanSlug,
|
|
508
|
+
mode: cleanMode,
|
|
509
|
+
items: cleanItems,
|
|
510
|
+
options: data.options || existing.options || {}
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
return {
|
|
514
|
+
...updated,
|
|
515
|
+
_id: updated.documentId || String(updated.id)
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
const created = await strapi.db.query(MENU_UID).create({
|
|
519
|
+
data: {
|
|
520
|
+
name: cleanName,
|
|
521
|
+
slug: cleanSlug,
|
|
522
|
+
mode: cleanMode,
|
|
523
|
+
items: cleanItems,
|
|
524
|
+
options: data.options || {}
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
return {
|
|
528
|
+
...created,
|
|
529
|
+
_id: created.documentId || String(created.id)
|
|
530
|
+
};
|
|
531
|
+
},
|
|
532
|
+
async remove(idOrDocId) {
|
|
533
|
+
const numericId = Number(idOrDocId);
|
|
534
|
+
if (!Number.isNaN(numericId) && String(numericId) === String(idOrDocId)) {
|
|
535
|
+
await strapi.db.query(MENU_UID).delete({
|
|
536
|
+
where: { id: numericId }
|
|
537
|
+
});
|
|
538
|
+
} else {
|
|
539
|
+
await strapi.db.query(MENU_UID).delete({
|
|
540
|
+
where: { documentId: String(idOrDocId) }
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
return { success: true };
|
|
544
|
+
},
|
|
545
|
+
getEntityTypes() {
|
|
546
|
+
const contentTypes2 = strapi.contentTypes || {};
|
|
547
|
+
const result = [];
|
|
548
|
+
for (const [uid, ct] of Object.entries(contentTypes2)) {
|
|
549
|
+
if (!uid.startsWith("api::")) continue;
|
|
550
|
+
const attrs = ct.attributes || {};
|
|
551
|
+
const attrNames = Object.keys(attrs);
|
|
552
|
+
const titleCandidates = ["title", "name", "label", "heading", "subject", "baslik", "ad"];
|
|
553
|
+
const titleField = titleCandidates.find((c) => attrNames.includes(c)) || attrNames.find((k) => ["string", "text"].includes(attrs[k]?.type)) || "id";
|
|
554
|
+
const slugCandidates = ["slug", "path", "url", "permalink", "code"];
|
|
555
|
+
const slugField = slugCandidates.find((c) => attrNames.includes(c)) || null;
|
|
556
|
+
let parentField = null;
|
|
557
|
+
for (const [k, attr] of Object.entries(attrs)) {
|
|
558
|
+
if (attr?.type === "relation" && attr?.target === uid || ["parent", "parentId", "parent_id", "ust"].includes(k)) {
|
|
559
|
+
parentField = k;
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
result.push({
|
|
564
|
+
uid,
|
|
565
|
+
displayName: ct.info?.displayName || ct.info?.pluralName || uid,
|
|
566
|
+
singularName: ct.info?.singularName || "item",
|
|
567
|
+
pluralName: ct.info?.pluralName || "items",
|
|
568
|
+
kind: ct.kind || "collectionType",
|
|
569
|
+
titleField,
|
|
570
|
+
slugField,
|
|
571
|
+
parentField
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
return result;
|
|
575
|
+
},
|
|
576
|
+
async searchEntities(params) {
|
|
577
|
+
const types = this.getEntityTypes();
|
|
578
|
+
const targetUid = params.uid || types[0]?.uid || "api::page.page";
|
|
579
|
+
const meta = types.find((t) => t.uid === targetUid) || {
|
|
580
|
+
uid: targetUid,
|
|
581
|
+
displayName: targetUid,
|
|
582
|
+
singularName: "page",
|
|
583
|
+
pluralName: "pages",
|
|
584
|
+
kind: "collectionType",
|
|
585
|
+
titleField: "title",
|
|
586
|
+
slugField: "slug",
|
|
587
|
+
parentField: null
|
|
588
|
+
};
|
|
589
|
+
const populate = {};
|
|
590
|
+
if (meta.parentField) {
|
|
591
|
+
populate[meta.parentField] = true;
|
|
592
|
+
}
|
|
593
|
+
let rawEntries = [];
|
|
594
|
+
try {
|
|
595
|
+
rawEntries = await strapi.db.query(targetUid).findMany({
|
|
596
|
+
limit: 200,
|
|
597
|
+
orderBy: { id: "asc" },
|
|
598
|
+
populate: Object.keys(populate).length > 0 ? populate : void 0
|
|
599
|
+
});
|
|
600
|
+
} catch {
|
|
601
|
+
rawEntries = [];
|
|
602
|
+
}
|
|
603
|
+
const byDocId = /* @__PURE__ */ new Map();
|
|
604
|
+
for (const row of rawEntries) {
|
|
605
|
+
const key = String(row.documentId || row.id);
|
|
606
|
+
const existing = byDocId.get(key);
|
|
607
|
+
if (!existing || row.publishedAt && !existing.publishedAt) {
|
|
608
|
+
byDocId.set(key, row);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
const searchQuery = String(params.q || "").trim().toLocaleLowerCase("tr-TR");
|
|
612
|
+
const flatNodes = Array.from(byDocId.values()).map((entry) => {
|
|
613
|
+
const rawTitle = entry[meta.titleField] || entry.title || entry.name || entry.label || `#${entry.documentId || entry.id}`;
|
|
614
|
+
const title = String(rawTitle);
|
|
615
|
+
const rawSlug = meta.slugField && entry[meta.slugField] || entry.slug || String(title).split(/[/|>»]+/).map((part) => slugifyTR(part.trim())).filter(Boolean).join("/");
|
|
616
|
+
const prefix = meta.pluralName === "pages" ? "" : `/${meta.pluralName}`;
|
|
617
|
+
const url = String(rawSlug).startsWith("/") ? String(rawSlug) : `${prefix}/${rawSlug}`.replace(/\/+/g, "/");
|
|
618
|
+
let parentDocId = null;
|
|
619
|
+
if (meta.parentField && entry[meta.parentField]) {
|
|
620
|
+
const p = entry[meta.parentField];
|
|
621
|
+
parentDocId = typeof p === "object" ? String(p.documentId || p.id) : String(p);
|
|
622
|
+
} else if (entry.parentId || entry.parent_id) {
|
|
623
|
+
parentDocId = String(entry.parentId || entry.parent_id);
|
|
624
|
+
}
|
|
625
|
+
return {
|
|
626
|
+
id: entry.id,
|
|
627
|
+
documentId: String(entry.documentId || entry.id),
|
|
628
|
+
uid: targetUid,
|
|
629
|
+
collectionName: meta.pluralName,
|
|
630
|
+
title,
|
|
631
|
+
slug: String(rawSlug),
|
|
632
|
+
url,
|
|
633
|
+
parentId: parentDocId,
|
|
634
|
+
children: []
|
|
635
|
+
};
|
|
636
|
+
}).filter((node) => {
|
|
637
|
+
if (!searchQuery) return true;
|
|
638
|
+
return node.title.toLocaleLowerCase("tr-TR").includes(searchQuery) || node.url.toLocaleLowerCase("tr-TR").includes(searchQuery) || node.slug.toLocaleLowerCase("tr-TR").includes(searchQuery);
|
|
639
|
+
});
|
|
640
|
+
if (!params.tree) {
|
|
641
|
+
return {
|
|
642
|
+
meta,
|
|
643
|
+
items: flatNodes
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
647
|
+
const urlMap = /* @__PURE__ */ new Map();
|
|
648
|
+
flatNodes.forEach((n) => {
|
|
649
|
+
const cloned = { ...n, children: [] };
|
|
650
|
+
nodeMap.set(String(n.documentId), cloned);
|
|
651
|
+
nodeMap.set(String(n.id), cloned);
|
|
652
|
+
urlMap.set(n.url.replace(/\/+$/, ""), cloned);
|
|
653
|
+
});
|
|
654
|
+
const roots = [];
|
|
655
|
+
for (const orig of flatNodes) {
|
|
656
|
+
const current = nodeMap.get(String(orig.documentId));
|
|
657
|
+
if (!current) continue;
|
|
658
|
+
let attached = false;
|
|
659
|
+
if (orig.parentId && nodeMap.has(String(orig.parentId))) {
|
|
660
|
+
const parent = nodeMap.get(String(orig.parentId));
|
|
661
|
+
if (parent && parent !== current) {
|
|
662
|
+
parent.children.push(current);
|
|
663
|
+
attached = true;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
if (!attached) {
|
|
667
|
+
const cleanUrl = orig.url.replace(/\/+$/, "");
|
|
668
|
+
const lastSlash = cleanUrl.lastIndexOf("/");
|
|
669
|
+
if (lastSlash > 0) {
|
|
670
|
+
const parentPath = cleanUrl.slice(0, lastSlash);
|
|
671
|
+
const parentByPath = urlMap.get(parentPath);
|
|
672
|
+
if (parentByPath && parentByPath !== current) {
|
|
673
|
+
parentByPath.children.push(current);
|
|
674
|
+
attached = true;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
if (!attached) {
|
|
679
|
+
roots.push(current);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return {
|
|
683
|
+
meta,
|
|
684
|
+
items: roots
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
const services = {
|
|
689
|
+
"ci-template": ciTemplateService,
|
|
690
|
+
"ci-menu": ciMenuService
|
|
691
|
+
};
|
|
692
|
+
const index = {
|
|
693
|
+
register,
|
|
694
|
+
bootstrap,
|
|
695
|
+
destroy,
|
|
696
|
+
config,
|
|
697
|
+
controllers,
|
|
698
|
+
routes,
|
|
699
|
+
services,
|
|
700
|
+
contentTypes
|
|
701
|
+
};
|
|
702
|
+
exports.default = index;
|