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,12 @@
1
+ declare const _default: () => {
2
+ type: string;
3
+ routes: {
4
+ method: string;
5
+ path: string;
6
+ handler: string;
7
+ config: {
8
+ policies: string[];
9
+ };
10
+ }[];
11
+ };
12
+ export default _default;
@@ -0,0 +1,5 @@
1
+ declare const _default: () => {
2
+ type: string;
3
+ routes: any[];
4
+ };
5
+ export default _default;
@@ -0,0 +1,18 @@
1
+ declare const routes: {
2
+ 'content-api': () => {
3
+ type: string;
4
+ routes: any[];
5
+ };
6
+ admin: () => {
7
+ type: string;
8
+ routes: {
9
+ method: string;
10
+ path: string;
11
+ handler: string;
12
+ config: {
13
+ policies: string[];
14
+ };
15
+ }[];
16
+ };
17
+ };
18
+ export default routes;
@@ -0,0 +1,19 @@
1
+ declare const _default: {
2
+ 'relation-labels': ({ strapi }: {
3
+ strapi: import('@strapi/types/dist/core').Strapi;
4
+ }) => {
5
+ decorateCollectionResults: (ctx: any, sourceUid: string, results: unknown[]) => Promise<unknown[]>;
6
+ decorateConfiguration: (data: any, sourceUid: string) => Promise<any>;
7
+ decorateRelationResults: (ctx: any, sourceUid: string, targetField: string, results: unknown[]) => Promise<unknown[]>;
8
+ compileTemplate: (template: string, targetSchema: import('./utils/relation-labels').SchemaLike | undefined) => import('./utils/relation-labels').CompiledTemplate | null;
9
+ parseTemplate: (template: string) => string[] | null;
10
+ renderTemplate: (compiled: import('./utils/relation-labels').CompiledTemplate, values: Record<string, unknown>) => string;
11
+ };
12
+ settings: ({ strapi }: {
13
+ strapi: import('@strapi/types/dist/core').Strapi;
14
+ }) => {
15
+ get(): Promise<import('../types').RelationNamesSettings>;
16
+ set(value: unknown): Promise<import('../types').RelationNamesSettings>;
17
+ };
18
+ };
19
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { Core } from '@strapi/strapi';
2
+ import { SchemaLike } from './utils/relation-labels';
3
+ declare const relationLabels: ({ strapi }: {
4
+ strapi: Core.Strapi;
5
+ }) => {
6
+ decorateCollectionResults: (ctx: any, sourceUid: string, results: unknown[]) => Promise<unknown[]>;
7
+ decorateConfiguration: (data: any, sourceUid: string) => Promise<any>;
8
+ decorateRelationResults: (ctx: any, sourceUid: string, targetField: string, results: unknown[]) => Promise<unknown[]>;
9
+ compileTemplate: (template: string, targetSchema: SchemaLike | undefined) => import('./utils/relation-labels').CompiledTemplate | null;
10
+ parseTemplate: (template: string) => string[] | null;
11
+ renderTemplate: (compiled: import('./utils/relation-labels').CompiledTemplate, values: Record<string, unknown>) => string;
12
+ };
13
+ export { compileTemplate, parseTemplate, renderTemplate } from './utils/relation-labels';
14
+ export default relationLabels;
@@ -0,0 +1,11 @@
1
+ import { Core } from '@strapi/strapi';
2
+ import { RelationNamesSettings } from '../types';
3
+ declare const normalizeSettings: (value: unknown, collections?: string[]) => RelationNamesSettings;
4
+ declare const settings: ({ strapi }: {
5
+ strapi: Core.Strapi;
6
+ }) => {
7
+ get(): Promise<RelationNamesSettings>;
8
+ set(value: unknown): Promise<RelationNamesSettings>;
9
+ };
10
+ export { normalizeSettings };
11
+ export default settings;
@@ -0,0 +1 @@
1
+ export declare const isCollectionEnabled: (collections: string[], uid: string) => boolean;
@@ -0,0 +1,27 @@
1
+ export type SchemaAttribute = {
2
+ type?: string;
3
+ target?: string;
4
+ component?: string;
5
+ components?: string[];
6
+ relation?: string;
7
+ private?: boolean;
8
+ };
9
+ export type SchemaLike = {
10
+ uid: string;
11
+ modelType?: string;
12
+ attributes?: Record<string, SchemaAttribute>;
13
+ };
14
+ export type CompiledTemplate = {
15
+ template: string;
16
+ placeholders: string[];
17
+ displayField: string;
18
+ };
19
+ export type RelationRuntime = CompiledTemplate & {
20
+ sourceUid: string;
21
+ targetUid: string;
22
+ originalMainField: string;
23
+ };
24
+ export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
25
+ export declare const parseTemplate: (template: string) => string[] | null;
26
+ export declare const compileTemplate: (template: string, targetSchema: SchemaLike | undefined) => CompiledTemplate | null;
27
+ export declare const renderTemplate: (compiled: CompiledTemplate, values: Record<string, unknown>) => string;
@@ -0,0 +1,6 @@
1
+ import { RelationRuntime } from './relation-labels';
2
+ export declare const getIdentity: (value: Record<string, unknown>, modelType?: string) => unknown;
3
+ export declare const matchesRelation: (source: Record<string, unknown>, candidate: Record<string, unknown>, targetModelType?: string) => boolean;
4
+ export declare const applyLabel: (value: Record<string, unknown>, hydrated: Record<string, unknown>, runtime: RelationRuntime) => Record<string, unknown>;
5
+ export declare const relationValues: (value: unknown) => Record<string, unknown>[];
6
+ export declare const replaceRelationValue: (original: unknown, values: Record<string, unknown>[], hydrated: Map<Record<string, unknown>, Record<string, unknown>>, runtime: RelationRuntime) => unknown;
@@ -0,0 +1,5 @@
1
+ export type RelationNamesSettings = {
2
+ collections: string[];
3
+ relations: Record<string, Record<string, string>>;
4
+ };
5
+ export declare const EMPTY_SETTINGS: RelationNamesSettings;
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "strapi-relation-names",
3
+ "description": "Display Strapi relations with clear, customizable labels built from your content fields",
4
+ "license": "MIT",
5
+ "author": "Christoph Tupi <christoph.tupi@gmail.com>",
6
+ "keywords": [],
7
+ "type": "commonjs",
8
+ "version": "0.0.0",
9
+ "strapi": {
10
+ "kind": "plugin",
11
+ "name": "strapi-relation-names",
12
+ "displayName": "Strapi Relation Names",
13
+ "description": "Display Strapi relations with clear, customizable labels built from your content fields"
14
+ },
15
+ "exports": {
16
+ "./package.json": "./package.json",
17
+ "./strapi-admin": {
18
+ "types": "./dist/admin/src/index.d.ts",
19
+ "source": "./admin/src/index.ts",
20
+ "import": "./dist/admin/index.mjs",
21
+ "require": "./dist/admin/index.js",
22
+ "default": "./dist/admin/index.js"
23
+ },
24
+ "./strapi-server": {
25
+ "types": "./dist/server/src/index.d.ts",
26
+ "source": "./server/src/index.ts",
27
+ "import": "./dist/server/index.mjs",
28
+ "require": "./dist/server/index.js",
29
+ "default": "./dist/server/index.js"
30
+ }
31
+ },
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "scripts": {
36
+ "build": "strapi-plugin build",
37
+ "watch": "strapi-plugin watch",
38
+ "watch:link": "strapi-plugin watch:link",
39
+ "verify": "strapi-plugin verify",
40
+ "prepare": "lefthook install",
41
+ "test": "vitest run",
42
+ "test:ts:front": "tsc -p admin/tsconfig.json",
43
+ "test:ts:back": "tsc -p server/tsconfig.json",
44
+ "lint": "oxlint",
45
+ "fmt": "oxfmt"
46
+ },
47
+ "devDependencies": {
48
+ "@strapi/design-system": "^2.2.4",
49
+ "@strapi/icons": "^2.2.4",
50
+ "@strapi/sdk-plugin": "^6.1.1",
51
+ "@strapi/strapi": "^5.52.3",
52
+ "@strapi/typescript-utils": "^5.52.3",
53
+ "@types/react": "^18.3.31",
54
+ "@types/react-dom": "^18.3.7",
55
+ "lefthook": "^2.1.12",
56
+ "oxfmt": "^0.67.0",
57
+ "oxlint": "^1.82.0",
58
+ "react": "^18.3.1",
59
+ "react-dom": "^18.3.1",
60
+ "react-intl": "^6.8.9",
61
+ "react-router-dom": "^6.30.6",
62
+ "styled-components": "^6.5.3",
63
+ "typescript": "^5.9.3",
64
+ "vitest": "^5.0.0"
65
+ },
66
+ "peerDependencies": {
67
+ "@strapi/design-system": "^2.2.4",
68
+ "@strapi/icons": "^2.2.4",
69
+ "@strapi/sdk-plugin": "^6.1.1",
70
+ "@strapi/strapi": "^5.52.3",
71
+ "react": "^18.3.1",
72
+ "react-dom": "^18.3.1",
73
+ "react-intl": "^6.8.9",
74
+ "react-router-dom": "^6.30.6",
75
+ "styled-components": "^6.5.3"
76
+ }
77
+ }