strapi-relation-names 0.0.0

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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +171 -0
  3. package/dist/admin/SettingsPage-BQo5mpAY.mjs +199 -0
  4. package/dist/admin/SettingsPage-C1nFFJjH.js +199 -0
  5. package/dist/admin/de-BBrO1tf0.js +16 -0
  6. package/dist/admin/de-a3KtzZ7N.mjs +16 -0
  7. package/dist/admin/en-8w3y1FSw.mjs +16 -0
  8. package/dist/admin/en-DlY6ZGdo.js +16 -0
  9. package/dist/admin/index-CJO9wtUk.mjs +125 -0
  10. package/dist/admin/index-SsQXjQq0.js +124 -0
  11. package/dist/admin/index.js +4 -0
  12. package/dist/admin/index.mjs +4 -0
  13. package/dist/admin/src/index.d.ts +3 -0
  14. package/dist/admin/src/pages/SettingsPage.d.ts +2 -0
  15. package/dist/admin/src/pluginId.d.ts +1 -0
  16. package/dist/admin/src/types.d.ts +28 -0
  17. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  18. package/dist/admin/src/utils/layout.d.ts +3 -0
  19. package/dist/admin/src/utils/template.d.ts +5 -0
  20. package/dist/server/index.js +564 -0
  21. package/dist/server/index.mjs +564 -0
  22. package/dist/server/src/bootstrap.d.ts +5 -0
  23. package/dist/server/src/config/index.d.ts +12 -0
  24. package/dist/server/src/constants.d.ts +1 -0
  25. package/dist/server/src/content-types/index.d.ts +2 -0
  26. package/dist/server/src/controllers/index.d.ts +9 -0
  27. package/dist/server/src/controllers/settings.d.ts +8 -0
  28. package/dist/server/src/destroy.d.ts +5 -0
  29. package/dist/server/src/index.d.ts +66 -0
  30. package/dist/server/src/middlewares/index.d.ts +2 -0
  31. package/dist/server/src/policies/index.d.ts +2 -0
  32. package/dist/server/src/register.d.ts +5 -0
  33. package/dist/server/src/routes/admin/index.d.ts +12 -0
  34. package/dist/server/src/routes/content-api/index.d.ts +5 -0
  35. package/dist/server/src/routes/index.d.ts +18 -0
  36. package/dist/server/src/services/index.d.ts +19 -0
  37. package/dist/server/src/services/relation-labels.d.ts +14 -0
  38. package/dist/server/src/services/settings.d.ts +11 -0
  39. package/dist/server/src/services/utils/collections.d.ts +1 -0
  40. package/dist/server/src/services/utils/relation-labels.d.ts +27 -0
  41. package/dist/server/src/services/utils/relation-values.d.ts +6 -0
  42. package/dist/server/src/types.d.ts +5 -0
  43. package/package.json +77 -0
@@ -0,0 +1,564 @@
1
+ const bootstrap = ({ strapi }) => {
2
+ };
3
+ const destroy = ({ strapi }) => {
4
+ };
5
+ const PLUGIN_ID$1 = "strapi-relation-names";
6
+ const register = ({ strapi }) => {
7
+ const relationLabels2 = strapi.plugin(PLUGIN_ID$1).service("relation-labels");
8
+ const controllers2 = strapi.get("controllers");
9
+ controllers2.extend("plugin::content-manager.relations", (controller) => ({
10
+ ...controller,
11
+ async findAvailable(ctx, next) {
12
+ await controller.findAvailable(ctx, next);
13
+ if (Array.isArray(ctx.body?.results)) {
14
+ ctx.body.results = await relationLabels2.decorateRelationResults(
15
+ ctx,
16
+ ctx.params.model,
17
+ ctx.params.targetField,
18
+ ctx.body.results
19
+ );
20
+ }
21
+ },
22
+ async findExisting(ctx, next) {
23
+ await controller.findExisting(ctx, next);
24
+ if (Array.isArray(ctx.body?.results)) {
25
+ ctx.body.results = await relationLabels2.decorateRelationResults(
26
+ ctx,
27
+ ctx.params.model,
28
+ ctx.params.targetField,
29
+ ctx.body.results
30
+ );
31
+ }
32
+ }
33
+ }));
34
+ controllers2.extend("plugin::content-manager.collection-types", (controller) => ({
35
+ ...controller,
36
+ async find(ctx, next) {
37
+ await controller.find(ctx, next);
38
+ if (Array.isArray(ctx.body?.results)) {
39
+ ctx.body.results = await relationLabels2.decorateCollectionResults(
40
+ ctx,
41
+ ctx.params.model,
42
+ ctx.body.results
43
+ );
44
+ }
45
+ }
46
+ }));
47
+ const decorateConfiguration = async (ctx, sourceUid) => {
48
+ if (ctx.body?.data) {
49
+ ctx.body.data = await relationLabels2.decorateConfiguration(ctx.body.data, sourceUid);
50
+ }
51
+ };
52
+ controllers2.extend("plugin::content-manager.content-types", (controller) => ({
53
+ ...controller,
54
+ async findContentTypeConfiguration(ctx, next) {
55
+ await controller.findContentTypeConfiguration(ctx, next);
56
+ await decorateConfiguration(ctx, ctx.params.uid);
57
+ },
58
+ async updateContentTypeConfiguration(ctx, next) {
59
+ await controller.updateContentTypeConfiguration(ctx, next);
60
+ await decorateConfiguration(ctx, ctx.params.uid);
61
+ }
62
+ }));
63
+ controllers2.extend("plugin::content-manager.components", (controller) => ({
64
+ ...controller,
65
+ async findComponentConfiguration(ctx, next) {
66
+ await controller.findComponentConfiguration(ctx, next);
67
+ await decorateConfiguration(ctx, ctx.params.uid);
68
+ },
69
+ async updateComponentConfiguration(ctx, next) {
70
+ await controller.updateComponentConfiguration(ctx, next);
71
+ await decorateConfiguration(ctx, ctx.params.uid);
72
+ }
73
+ }));
74
+ };
75
+ const validateConfig = (config2) => {
76
+ if (!config2 || typeof config2 !== "object" || Array.isArray(config2) || !Array.isArray(config2.collections) || !config2.collections.every(
77
+ (collection) => typeof collection === "string"
78
+ )) {
79
+ throw new Error("The collections config must be an array of strings");
80
+ }
81
+ };
82
+ const config = {
83
+ default: {
84
+ collections: []
85
+ },
86
+ validator: validateConfig
87
+ };
88
+ const contentTypes = {};
89
+ const settings$1 = ({ strapi }) => ({
90
+ async find(ctx) {
91
+ const data = await strapi.plugin("strapi-relation-names").service("settings").get();
92
+ ctx.body = { data };
93
+ },
94
+ async update(ctx) {
95
+ const body = ctx.request.body;
96
+ if (!body || typeof body !== "object" || Array.isArray(body)) {
97
+ return ctx.badRequest("Settings must be an object");
98
+ }
99
+ const data = await strapi.plugin("strapi-relation-names").service("settings").set(body);
100
+ ctx.body = { data };
101
+ }
102
+ });
103
+ const controllers = {
104
+ settings: settings$1
105
+ };
106
+ const middlewares = {};
107
+ const policies = {};
108
+ const contentAPIRoutes = () => ({
109
+ type: "content-api",
110
+ routes: []
111
+ });
112
+ const adminAPIRoutes = () => ({
113
+ type: "admin",
114
+ routes: [
115
+ {
116
+ method: "GET",
117
+ path: "/settings",
118
+ handler: "settings.find",
119
+ config: {
120
+ policies: ["admin::isAuthenticatedAdmin"]
121
+ }
122
+ },
123
+ {
124
+ method: "PUT",
125
+ path: "/settings",
126
+ handler: "settings.update",
127
+ config: {
128
+ policies: ["admin::isAuthenticatedAdmin"]
129
+ }
130
+ }
131
+ ]
132
+ });
133
+ const routes = {
134
+ "content-api": contentAPIRoutes,
135
+ admin: adminAPIRoutes
136
+ };
137
+ const SCALAR_TYPES = /* @__PURE__ */ new Set([
138
+ "string",
139
+ "text",
140
+ "email",
141
+ "uid",
142
+ "enumeration",
143
+ "integer",
144
+ "biginteger",
145
+ "decimal",
146
+ "float",
147
+ "date",
148
+ "datetime",
149
+ "time",
150
+ "boolean"
151
+ ]);
152
+ const isRecord$1 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
153
+ const parseTemplate = (template) => {
154
+ if (!template.trim()) {
155
+ return null;
156
+ }
157
+ const placeholders = [];
158
+ let cursor = 0;
159
+ while (cursor < template.length) {
160
+ const openingBrace = template.indexOf("{", cursor);
161
+ const closingBrace = template.indexOf("}", cursor);
162
+ if (closingBrace !== -1 && (openingBrace === -1 || closingBrace < openingBrace)) {
163
+ return null;
164
+ }
165
+ if (openingBrace === -1) {
166
+ break;
167
+ }
168
+ const end = template.indexOf("}", openingBrace + 1);
169
+ if (end === -1) {
170
+ return null;
171
+ }
172
+ const name = template.slice(openingBrace + 1, end);
173
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {
174
+ return null;
175
+ }
176
+ placeholders.push(name);
177
+ cursor = end + 1;
178
+ }
179
+ return placeholders.length > 0 ? placeholders : null;
180
+ };
181
+ const compileTemplate = (template, targetSchema) => {
182
+ const placeholders = parseTemplate(template);
183
+ const attributes = targetSchema?.attributes ?? {};
184
+ if (!placeholders || !targetSchema) {
185
+ return null;
186
+ }
187
+ const valid = placeholders.every((name) => {
188
+ const attribute = attributes[name];
189
+ return Boolean(
190
+ attribute && attribute.private !== true && SCALAR_TYPES.has(attribute.type ?? "")
191
+ );
192
+ });
193
+ if (!valid) {
194
+ return null;
195
+ }
196
+ return {
197
+ template,
198
+ placeholders,
199
+ displayField: placeholders[0]
200
+ };
201
+ };
202
+ const renderTemplate = (compiled, values) => {
203
+ const rendered = compiled.template.replace(
204
+ /\{([A-Za-z_][A-Za-z0-9_]*)\}/g,
205
+ (_match, name) => {
206
+ const value = values[name];
207
+ return value === null || value === void 0 ? "" : String(value);
208
+ }
209
+ );
210
+ return rendered.trim();
211
+ };
212
+ const getIdentity = (value, modelType) => modelType === "component" ? value.id : value.documentId ?? value.id;
213
+ const matchesRelation = (source, candidate, targetModelType) => {
214
+ if (source.id !== void 0 && candidate.id === source.id) {
215
+ return true;
216
+ }
217
+ if (source.documentId !== void 0 && candidate.documentId === source.documentId) {
218
+ if (source.locale !== void 0 && candidate.locale !== source.locale) {
219
+ return false;
220
+ }
221
+ if (source.publishedAt !== void 0 && candidate.publishedAt !== source.publishedAt) {
222
+ return false;
223
+ }
224
+ return true;
225
+ }
226
+ return getIdentity(source, targetModelType) === getIdentity(candidate, targetModelType);
227
+ };
228
+ const applyLabel = (value, hydrated, runtime) => {
229
+ const label = renderTemplate(runtime, hydrated);
230
+ if (label) {
231
+ return { ...value, [runtime.displayField]: label };
232
+ }
233
+ if (runtime.displayField === runtime.originalMainField) {
234
+ return value;
235
+ }
236
+ const fallbackField = runtime.originalMainField === "id" ? "documentId" : runtime.originalMainField;
237
+ const fallback = Object.prototype.hasOwnProperty.call(hydrated, fallbackField) ? hydrated[fallbackField] : void 0;
238
+ return { ...value, [runtime.displayField]: fallback };
239
+ };
240
+ const relationValues = (value) => {
241
+ if (Array.isArray(value)) {
242
+ return value.filter(isRecord$1);
243
+ }
244
+ return isRecord$1(value) ? [value] : [];
245
+ };
246
+ const replaceRelationValue = (original, values, hydrated, runtime) => {
247
+ const decorated = values.map((value) => applyLabel(value, hydrated.get(value) ?? value, runtime));
248
+ return Array.isArray(original) ? decorated : decorated[0] ?? original;
249
+ };
250
+ const isCollectionEnabled = (collections, uid) => collections.length === 0 || collections.includes(uid);
251
+ const getOriginalMainField = async (strapi, sourceSchema, targetSchema, targetField, userAbility) => {
252
+ const serviceName = sourceSchema.modelType === "component" ? "components" : "content-types";
253
+ const configuration = await strapi.plugin("content-manager").service(serviceName).findConfiguration(sourceSchema);
254
+ const configuredMainField = configuration?.metadatas?.[targetField]?.edit?.mainField;
255
+ if (typeof configuredMainField !== "string" || configuredMainField === "documentId" || configuredMainField === "id") {
256
+ return configuredMainField === "documentId" ? "documentId" : "id";
257
+ }
258
+ const permissionChecker = strapi.plugin("content-manager").service("permission-checker").create({ userAbility, model: targetSchema.uid });
259
+ const attribute = targetSchema.attributes?.[configuredMainField];
260
+ if (!attribute || attribute.private === true || permissionChecker.cannot.read(null, configuredMainField)) {
261
+ return "documentId";
262
+ }
263
+ return configuredMainField;
264
+ };
265
+ const getRuntime = async (strapi, settings2, sourceUid, targetField, userAbility) => {
266
+ const sourceSchema = strapi.getModel(sourceUid);
267
+ const attribute = sourceSchema?.attributes?.[targetField];
268
+ if (!sourceSchema || !attribute || attribute.type !== "relation" || !attribute.target) {
269
+ return null;
270
+ }
271
+ const template = settings2.relations[sourceUid]?.[targetField];
272
+ const targetSchema = strapi.getModel(attribute.target);
273
+ const compiled = typeof template === "string" ? compileTemplate(template, targetSchema) : null;
274
+ if (!compiled || !targetSchema) {
275
+ return null;
276
+ }
277
+ return {
278
+ ...compiled,
279
+ sourceUid,
280
+ targetUid: targetSchema.uid,
281
+ originalMainField: await getOriginalMainField(
282
+ strapi,
283
+ sourceSchema,
284
+ targetSchema,
285
+ targetField,
286
+ userAbility
287
+ )
288
+ };
289
+ };
290
+ const hydrateValues = async (strapi, ctx, runtime, values) => {
291
+ const targetSchema = strapi.getModel(runtime.targetUid);
292
+ const targetModelType = targetSchema.modelType;
293
+ const missingFields = runtime.placeholders.filter(
294
+ (field) => values.some((value) => !Object.prototype.hasOwnProperty.call(value, field))
295
+ );
296
+ if (missingFields.length === 0) {
297
+ return new Map(values.map((value) => [value, value]));
298
+ }
299
+ const identities = values.map((value) => getIdentity(value, targetModelType)).filter((identity) => identity !== void 0 && identity !== null);
300
+ if (identities.length === 0) {
301
+ return new Map(values.map((value) => [value, value]));
302
+ }
303
+ try {
304
+ const permissionChecker = strapi.plugin("content-manager").service("permission-checker").create({ userAbility: ctx.state.userAbility, model: runtime.targetUid });
305
+ const fields = Array.from(
306
+ /* @__PURE__ */ new Set([
307
+ ...runtime.placeholders,
308
+ runtime.originalMainField,
309
+ "id",
310
+ "documentId",
311
+ "locale",
312
+ "publishedAt"
313
+ ])
314
+ );
315
+ const identityField = targetModelType === "component" ? "id" : "documentId";
316
+ const permissionQuery = await permissionChecker.sanitizedQuery.read({
317
+ fields,
318
+ filters: { [identityField]: { $in: identities } }
319
+ });
320
+ const query = strapi.get("query-params").transform(runtime.targetUid, permissionQuery);
321
+ const hydrated = await strapi.db.query(runtime.targetUid).findMany(query);
322
+ return new Map(
323
+ values.map((value) => [
324
+ value,
325
+ hydrated.find((candidate) => matchesRelation(value, candidate, targetModelType)) ?? value
326
+ ])
327
+ );
328
+ } catch {
329
+ return new Map(values.map((value) => [value, value]));
330
+ }
331
+ };
332
+ const relationLabels = ({ strapi }) => {
333
+ const getSettings = () => strapi.plugin("strapi-relation-names").service("settings").get();
334
+ const decorateRelationResults = async (ctx, sourceUid, targetField, results) => {
335
+ const settings2 = await getSettings();
336
+ if (!isCollectionEnabled(settings2.collections, sourceUid)) {
337
+ return results;
338
+ }
339
+ const runtime = await getRuntime(
340
+ strapi,
341
+ settings2,
342
+ sourceUid,
343
+ targetField,
344
+ ctx.state.userAbility
345
+ );
346
+ if (!runtime) {
347
+ return results;
348
+ }
349
+ const values = results.filter(isRecord$1);
350
+ const hydrated = await hydrateValues(strapi, ctx, runtime, values);
351
+ return results.map(
352
+ (result) => isRecord$1(result) ? applyLabel(result, hydrated.get(result) ?? result, runtime) : result
353
+ );
354
+ };
355
+ const decorateConfiguration = async (configuration, sourceUid) => {
356
+ if (!configuration || !isRecord$1(configuration.metadatas)) {
357
+ return configuration;
358
+ }
359
+ const settings2 = await getSettings();
360
+ const metadatas = { ...configuration.metadatas };
361
+ const relationNames = {};
362
+ for (const [fieldName, metadata] of Object.entries(metadatas)) {
363
+ const sourceSchema = strapi.getModel(sourceUid);
364
+ const attribute = sourceSchema?.attributes?.[fieldName];
365
+ if (!attribute || attribute.type !== "relation" || !attribute.target) {
366
+ continue;
367
+ }
368
+ const targetSchema = strapi.getModel(attribute.target);
369
+ const compiled = compileTemplate(
370
+ settings2.relations[sourceUid]?.[fieldName] ?? "",
371
+ targetSchema
372
+ );
373
+ if (!compiled || !isRecord$1(metadata)) {
374
+ continue;
375
+ }
376
+ metadatas[fieldName] = {
377
+ ...metadata,
378
+ edit: {
379
+ ...isRecord$1(metadata.edit) ? metadata.edit : {},
380
+ mainField: compiled.displayField
381
+ },
382
+ list: {
383
+ ...isRecord$1(metadata.list) ? metadata.list : {},
384
+ mainField: compiled.displayField
385
+ }
386
+ };
387
+ relationNames[fieldName] = { mainField: compiled.displayField };
388
+ }
389
+ return {
390
+ ...configuration,
391
+ metadatas,
392
+ settings: {
393
+ ...isRecord$1(configuration.settings) ? configuration.settings : {},
394
+ relationNames
395
+ }
396
+ };
397
+ };
398
+ const decorateContentManagerConfiguration = async (data, sourceUid) => {
399
+ if (!isRecord$1(data)) {
400
+ return data;
401
+ }
402
+ const settings2 = await getSettings();
403
+ if (!isCollectionEnabled(settings2.collections, sourceUid)) {
404
+ return data;
405
+ }
406
+ const next = { ...data };
407
+ if (next.contentType) {
408
+ next.contentType = await decorateConfiguration(next.contentType, sourceUid);
409
+ }
410
+ if (next.component) {
411
+ next.component = await decorateConfiguration(next.component, sourceUid);
412
+ }
413
+ if (isRecord$1(next.components)) {
414
+ const components = { ...next.components };
415
+ for (const [uid, configuration] of Object.entries(components)) {
416
+ components[uid] = await decorateConfiguration(configuration, uid);
417
+ }
418
+ next.components = components;
419
+ }
420
+ return next;
421
+ };
422
+ const decorateCollectionResults = async (ctx, sourceUid, results) => {
423
+ const settings2 = await getSettings();
424
+ if (!isCollectionEnabled(settings2.collections, sourceUid)) {
425
+ return results;
426
+ }
427
+ const runtimeCache = /* @__PURE__ */ new Map();
428
+ const sourceSchemas = /* @__PURE__ */ new Map();
429
+ const getSchema = (uid) => {
430
+ if (!sourceSchemas.has(uid)) {
431
+ sourceSchemas.set(uid, strapi.getModel(uid));
432
+ }
433
+ return sourceSchemas.get(uid);
434
+ };
435
+ const visit = async (value, uid) => {
436
+ if (Array.isArray(value)) {
437
+ for (const item of value) {
438
+ await visit(item, uid);
439
+ }
440
+ return;
441
+ }
442
+ if (!isRecord$1(value)) {
443
+ return;
444
+ }
445
+ const schema = getSchema(uid);
446
+ for (const [fieldName, attribute] of Object.entries(schema?.attributes ?? {})) {
447
+ if (attribute.type === "relation" && attribute.target) {
448
+ const cacheKey = `${uid}:${fieldName}`;
449
+ if (!runtimeCache.has(cacheKey)) {
450
+ runtimeCache.set(
451
+ cacheKey,
452
+ await getRuntime(strapi, settings2, uid, fieldName, ctx.state.userAbility)
453
+ );
454
+ }
455
+ const runtime = runtimeCache.get(cacheKey);
456
+ if (runtime) {
457
+ const originalRelation = value[fieldName];
458
+ const relationItems = relationValues(originalRelation);
459
+ const hydrated = await hydrateValues(strapi, ctx, runtime, relationItems);
460
+ value[fieldName] = replaceRelationValue(
461
+ originalRelation,
462
+ relationItems,
463
+ hydrated,
464
+ runtime
465
+ );
466
+ }
467
+ }
468
+ if (attribute.type === "component" && attribute.component) {
469
+ await visit(value[fieldName], attribute.component);
470
+ }
471
+ if (attribute.type === "dynamiczone" && Array.isArray(attribute.components)) {
472
+ for (const item of relationValues(value[fieldName])) {
473
+ if (typeof item.__component === "string" && attribute.components.includes(item.__component)) {
474
+ await visit(item, item.__component);
475
+ }
476
+ }
477
+ }
478
+ }
479
+ };
480
+ for (const result of results) {
481
+ await visit(result, sourceUid);
482
+ }
483
+ return results;
484
+ };
485
+ return {
486
+ decorateCollectionResults,
487
+ decorateConfiguration: decorateContentManagerConfiguration,
488
+ decorateRelationResults,
489
+ compileTemplate,
490
+ parseTemplate,
491
+ renderTemplate
492
+ };
493
+ };
494
+ const EMPTY_SETTINGS = {
495
+ collections: [],
496
+ relations: {}
497
+ };
498
+ const PLUGIN_ID = "strapi-relation-names";
499
+ const STORE_KEY = "settings";
500
+ const isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
501
+ const normalizeSettings = (value, collections = []) => {
502
+ if (!isRecord(value) || !isRecord(value.relations)) {
503
+ return { collections, relations: {} };
504
+ }
505
+ const relations = {};
506
+ for (const [sourceUid, sourceRelations] of Object.entries(value.relations)) {
507
+ if (!isRecord(sourceRelations)) {
508
+ continue;
509
+ }
510
+ const normalizedRelations = {};
511
+ for (const [fieldName, template] of Object.entries(sourceRelations)) {
512
+ if (typeof template === "string" && template.length > 0) {
513
+ normalizedRelations[fieldName] = template;
514
+ }
515
+ }
516
+ if (Object.keys(normalizedRelations).length > 0) {
517
+ relations[sourceUid] = normalizedRelations;
518
+ }
519
+ }
520
+ return { collections, relations };
521
+ };
522
+ const settings = ({ strapi }) => {
523
+ const getCollections = () => {
524
+ const config2 = strapi.config.get("plugin::strapi-relation-names");
525
+ return Array.isArray(config2?.collections) ? config2.collections.filter(
526
+ (collection) => typeof collection === "string"
527
+ ) : [];
528
+ };
529
+ const store = () => strapi.store({
530
+ type: "plugin",
531
+ name: PLUGIN_ID,
532
+ key: STORE_KEY
533
+ });
534
+ return {
535
+ async get() {
536
+ const value = await store().get();
537
+ return normalizeSettings(value ?? EMPTY_SETTINGS, getCollections());
538
+ },
539
+ async set(value) {
540
+ const normalized = normalizeSettings(value, getCollections());
541
+ await store().set({ value: normalized });
542
+ return normalized;
543
+ }
544
+ };
545
+ };
546
+ const services = {
547
+ "relation-labels": relationLabels,
548
+ settings
549
+ };
550
+ const index = {
551
+ register,
552
+ bootstrap,
553
+ destroy,
554
+ config,
555
+ controllers,
556
+ routes,
557
+ services,
558
+ contentTypes,
559
+ policies,
560
+ middlewares
561
+ };
562
+ export {
563
+ index as default
564
+ };
@@ -0,0 +1,5 @@
1
+ import { Core } from '@strapi/strapi';
2
+ declare const bootstrap: ({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }) => void;
5
+ export default bootstrap;
@@ -0,0 +1,12 @@
1
+ type RelationNamesConfig = {
2
+ collections: string[];
3
+ };
4
+ declare const validateConfig: (config: unknown) => asserts config is RelationNamesConfig;
5
+ declare const config: {
6
+ default: {
7
+ collections: any[];
8
+ };
9
+ validator: (config: unknown) => asserts config is RelationNamesConfig;
10
+ };
11
+ export { validateConfig };
12
+ export default config;
@@ -0,0 +1 @@
1
+ export declare const PLUGIN_ID = "strapi-relation-names";
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ settings: ({ strapi }: {
3
+ strapi: import('@strapi/types/dist/core').Strapi;
4
+ }) => {
5
+ find(ctx: any): Promise<void>;
6
+ update(ctx: any): Promise<any>;
7
+ };
8
+ };
9
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { Core } from '@strapi/strapi';
2
+ declare const settings: ({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }) => {
5
+ find(ctx: any): Promise<void>;
6
+ update(ctx: any): Promise<any>;
7
+ };
8
+ export default settings;
@@ -0,0 +1,5 @@
1
+ import { Core } from '@strapi/strapi';
2
+ declare const destroy: ({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }) => void;
5
+ export default destroy;
@@ -0,0 +1,66 @@
1
+ declare const _default: {
2
+ register: ({ strapi }: {
3
+ strapi: import('@strapi/types/dist/core').Strapi;
4
+ }) => void;
5
+ bootstrap: ({ strapi }: {
6
+ strapi: import('@strapi/types/dist/core').Strapi;
7
+ }) => void;
8
+ destroy: ({ strapi }: {
9
+ strapi: import('@strapi/types/dist/core').Strapi;
10
+ }) => void;
11
+ config: {
12
+ default: {
13
+ collections: any[];
14
+ };
15
+ validator: (config: unknown) => asserts config is {
16
+ collections: string[];
17
+ };
18
+ };
19
+ controllers: {
20
+ settings: ({ strapi }: {
21
+ strapi: import('@strapi/types/dist/core').Strapi;
22
+ }) => {
23
+ find(ctx: any): Promise<void>;
24
+ update(ctx: any): Promise<any>;
25
+ };
26
+ };
27
+ routes: {
28
+ 'content-api': () => {
29
+ type: string;
30
+ routes: any[];
31
+ };
32
+ admin: () => {
33
+ type: string;
34
+ routes: {
35
+ method: string;
36
+ path: string;
37
+ handler: string;
38
+ config: {
39
+ policies: string[];
40
+ };
41
+ }[];
42
+ };
43
+ };
44
+ services: {
45
+ 'relation-labels': ({ strapi }: {
46
+ strapi: import('@strapi/types/dist/core').Strapi;
47
+ }) => {
48
+ decorateCollectionResults: (ctx: any, sourceUid: string, results: unknown[]) => Promise<unknown[]>;
49
+ decorateConfiguration: (data: any, sourceUid: string) => Promise<any>;
50
+ decorateRelationResults: (ctx: any, sourceUid: string, targetField: string, results: unknown[]) => Promise<unknown[]>;
51
+ compileTemplate: (template: string, targetSchema: import('./services/utils/relation-labels').SchemaLike | undefined) => import('./services/utils/relation-labels').CompiledTemplate | null;
52
+ parseTemplate: (template: string) => string[] | null;
53
+ renderTemplate: (compiled: import('./services/utils/relation-labels').CompiledTemplate, values: Record<string, unknown>) => string;
54
+ };
55
+ settings: ({ strapi }: {
56
+ strapi: import('@strapi/types/dist/core').Strapi;
57
+ }) => {
58
+ get(): Promise<import('./types').RelationNamesSettings>;
59
+ set(value: unknown): Promise<import('./types').RelationNamesSettings>;
60
+ };
61
+ };
62
+ contentTypes: {};
63
+ policies: {};
64
+ middlewares: {};
65
+ };
66
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { Core } from '@strapi/strapi';
2
+ declare const register: ({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }) => void;
5
+ export default register;