@zachariaz/strapi-plugin-content-variants 0.1.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.
- package/README.md +600 -0
- package/dist/_chunks/Segments-BREqC60L.js +330 -0
- package/dist/_chunks/Segments-BgxnvvtR.mjs +330 -0
- package/dist/_chunks/en-Bnfrhhim.js +62 -0
- package/dist/_chunks/en-e_966kWj.mjs +62 -0
- package/dist/_chunks/index-DVoZM8JU.js +1036 -0
- package/dist/_chunks/index-Dj2sexmk.mjs +1020 -0
- package/dist/admin/index.js +3 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/admin/src/components/Initializer.d.ts +5 -0
- package/dist/admin/src/components/SegmentPickerAction.d.ts +7 -0
- package/dist/admin/src/components/VariantInfoAction.d.ts +8 -0
- package/dist/admin/src/components/VariantPanel.d.ts +13 -0
- package/dist/admin/src/components/VariantPickerAction.d.ts +20 -0
- package/dist/admin/src/contentManagerHooks/editView.d.ts +6 -0
- package/dist/admin/src/contentManagerHooks/listView.d.ts +22 -0
- package/dist/admin/src/hooks/useSegments.d.ts +17 -0
- package/dist/admin/src/hooks/useVariantFamily.d.ts +19 -0
- package/dist/admin/src/hooks/useVariantLinks.d.ts +44 -0
- package/dist/admin/src/index.d.ts +11 -0
- package/dist/admin/src/pages/Settings/Segments.d.ts +2 -0
- package/dist/admin/src/pluginId.d.ts +2 -0
- package/dist/admin/src/utils/batchLinkFetcher.d.ts +11 -0
- package/dist/admin/src/utils/variants.d.ts +13 -0
- package/dist/server/index.js +895 -0
- package/dist/server/index.mjs +896 -0
- package/dist/server/src/bootstrap.d.ts +17 -0
- package/dist/server/src/config/index.d.ts +5 -0
- package/dist/server/src/content-types/index.d.ts +121 -0
- package/dist/server/src/controllers/index.d.ts +24 -0
- package/dist/server/src/controllers/segment.d.ts +11 -0
- package/dist/server/src/controllers/variant-link.d.ts +18 -0
- package/dist/server/src/destroy.d.ts +5 -0
- package/dist/server/src/index.d.ts +244 -0
- package/dist/server/src/register.d.ts +5 -0
- package/dist/server/src/routes/admin.d.ts +12 -0
- package/dist/server/src/routes/content-api.d.ts +19 -0
- package/dist/server/src/routes/index.d.ts +25 -0
- package/dist/server/src/services/index.d.ts +62 -0
- package/dist/server/src/services/segment.d.ts +14 -0
- package/dist/server/src/services/variant-link.d.ts +60 -0
- package/dist/server/src/services/variant-resolver.d.ts +23 -0
- package/package.json +104 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin bootstrap lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* Registers:
|
|
5
|
+
* 1. A Koa middleware that parses `segment` / `includeVariants` from the query
|
|
6
|
+
* string, stashes them in `ctx.state`, and sets cache-friendly headers.
|
|
7
|
+
* 2. A Document Service middleware that intercepts findMany / findOne to:
|
|
8
|
+
* - Filter out variant clone documents from list results
|
|
9
|
+
* - Resolve variant fields when `segment` is present
|
|
10
|
+
* - Embed `_variants` array when `includeVariants=true`
|
|
11
|
+
* - Walk populated relations to resolve/enrich nested variant-enabled entities
|
|
12
|
+
*/
|
|
13
|
+
import type { Core } from '@strapi/strapi';
|
|
14
|
+
declare const bootstrap: ({ strapi }: {
|
|
15
|
+
strapi: Core.Strapi;
|
|
16
|
+
}) => Promise<void>;
|
|
17
|
+
export default bootstrap;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
segment: {
|
|
3
|
+
schema: {
|
|
4
|
+
kind: string;
|
|
5
|
+
collectionName: string;
|
|
6
|
+
info: {
|
|
7
|
+
singularName: string;
|
|
8
|
+
pluralName: string;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
11
|
+
options: {
|
|
12
|
+
draftAndPublish: boolean;
|
|
13
|
+
};
|
|
14
|
+
pluginOptions: {};
|
|
15
|
+
attributes: {
|
|
16
|
+
name: {
|
|
17
|
+
type: string;
|
|
18
|
+
required: boolean;
|
|
19
|
+
unique: boolean;
|
|
20
|
+
};
|
|
21
|
+
slug: {
|
|
22
|
+
type: string;
|
|
23
|
+
required: boolean;
|
|
24
|
+
unique: boolean;
|
|
25
|
+
};
|
|
26
|
+
description: {
|
|
27
|
+
type: string;
|
|
28
|
+
};
|
|
29
|
+
externalId: {
|
|
30
|
+
type: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
'variant-link': {
|
|
36
|
+
schema: {
|
|
37
|
+
kind: string;
|
|
38
|
+
collectionName: string;
|
|
39
|
+
info: {
|
|
40
|
+
singularName: string;
|
|
41
|
+
pluralName: string;
|
|
42
|
+
displayName: string;
|
|
43
|
+
};
|
|
44
|
+
options: {
|
|
45
|
+
draftAndPublish: boolean;
|
|
46
|
+
};
|
|
47
|
+
pluginOptions: {
|
|
48
|
+
"content-manager": {
|
|
49
|
+
visible: boolean;
|
|
50
|
+
};
|
|
51
|
+
"content-type-builder": {
|
|
52
|
+
visible: boolean;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
attributes: {
|
|
56
|
+
baseContentType: {
|
|
57
|
+
type: string;
|
|
58
|
+
required: boolean;
|
|
59
|
+
};
|
|
60
|
+
baseDocumentId: {
|
|
61
|
+
type: string;
|
|
62
|
+
required: boolean;
|
|
63
|
+
};
|
|
64
|
+
variantDocumentId: {
|
|
65
|
+
type: string;
|
|
66
|
+
required: boolean;
|
|
67
|
+
};
|
|
68
|
+
label: {
|
|
69
|
+
type: string;
|
|
70
|
+
};
|
|
71
|
+
assignments: {
|
|
72
|
+
type: string;
|
|
73
|
+
relation: string;
|
|
74
|
+
target: string;
|
|
75
|
+
mappedBy: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
'variant-assignment': {
|
|
81
|
+
schema: {
|
|
82
|
+
kind: string;
|
|
83
|
+
collectionName: string;
|
|
84
|
+
info: {
|
|
85
|
+
singularName: string;
|
|
86
|
+
pluralName: string;
|
|
87
|
+
displayName: string;
|
|
88
|
+
};
|
|
89
|
+
options: {
|
|
90
|
+
draftAndPublish: boolean;
|
|
91
|
+
};
|
|
92
|
+
pluginOptions: {
|
|
93
|
+
"content-manager": {
|
|
94
|
+
visible: boolean;
|
|
95
|
+
};
|
|
96
|
+
"content-type-builder": {
|
|
97
|
+
visible: boolean;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
attributes: {
|
|
101
|
+
variantLink: {
|
|
102
|
+
type: string;
|
|
103
|
+
relation: string;
|
|
104
|
+
target: string;
|
|
105
|
+
inversedBy: string;
|
|
106
|
+
};
|
|
107
|
+
segment: {
|
|
108
|
+
type: string;
|
|
109
|
+
relation: string;
|
|
110
|
+
target: string;
|
|
111
|
+
};
|
|
112
|
+
priority: {
|
|
113
|
+
type: string;
|
|
114
|
+
default: number;
|
|
115
|
+
min: number;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
segment: ({ strapi }: {
|
|
3
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
find(ctx: any): Promise<void>;
|
|
6
|
+
findOne(ctx: any): Promise<void>;
|
|
7
|
+
create(ctx: any): Promise<void>;
|
|
8
|
+
update(ctx: any): Promise<void>;
|
|
9
|
+
delete(ctx: any): Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
'variant-link': ({ strapi }: {
|
|
12
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
13
|
+
}) => {
|
|
14
|
+
find(ctx: any): Promise<void>;
|
|
15
|
+
findOne(ctx: any): Promise<void>;
|
|
16
|
+
create(ctx: any): Promise<void>;
|
|
17
|
+
update(ctx: any): Promise<void>;
|
|
18
|
+
delete(ctx: any): Promise<void>;
|
|
19
|
+
findFamily(ctx: any): Promise<void>;
|
|
20
|
+
findBatch(ctx: any): Promise<void>;
|
|
21
|
+
createWithVariant(ctx: any): Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Core } from '@strapi/strapi';
|
|
2
|
+
declare const segmentController: ({ strapi }: {
|
|
3
|
+
strapi: Core.Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
find(ctx: any): Promise<void>;
|
|
6
|
+
findOne(ctx: any): Promise<void>;
|
|
7
|
+
create(ctx: any): Promise<void>;
|
|
8
|
+
update(ctx: any): Promise<void>;
|
|
9
|
+
delete(ctx: any): Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
export default segmentController;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Core } from '@strapi/strapi';
|
|
2
|
+
declare const variantLinkController: ({ strapi }: {
|
|
3
|
+
strapi: Core.Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
find(ctx: any): Promise<void>;
|
|
6
|
+
findOne(ctx: any): Promise<void>;
|
|
7
|
+
create(ctx: any): Promise<void>;
|
|
8
|
+
update(ctx: any): Promise<void>;
|
|
9
|
+
delete(ctx: any): Promise<void>;
|
|
10
|
+
findFamily(ctx: any): Promise<void>;
|
|
11
|
+
findBatch(ctx: any): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Clones base content document (current locale only), creates the variant document,
|
|
14
|
+
* then creates variant-link + variant-assignments for selected segments.
|
|
15
|
+
*/
|
|
16
|
+
createWithVariant(ctx: any): Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
export default variantLinkController;
|
|
@@ -0,0 +1,244 @@
|
|
|
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
|
+
}) => Promise<void>;
|
|
8
|
+
destroy: ({ strapi }: {
|
|
9
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
10
|
+
}) => void;
|
|
11
|
+
config: {
|
|
12
|
+
default: {};
|
|
13
|
+
validator(config: Record<string, unknown>): void;
|
|
14
|
+
};
|
|
15
|
+
contentTypes: {
|
|
16
|
+
segment: {
|
|
17
|
+
schema: {
|
|
18
|
+
kind: string;
|
|
19
|
+
collectionName: string;
|
|
20
|
+
info: {
|
|
21
|
+
singularName: string;
|
|
22
|
+
pluralName: string;
|
|
23
|
+
displayName: string;
|
|
24
|
+
};
|
|
25
|
+
options: {
|
|
26
|
+
draftAndPublish: boolean;
|
|
27
|
+
};
|
|
28
|
+
pluginOptions: {};
|
|
29
|
+
attributes: {
|
|
30
|
+
name: {
|
|
31
|
+
type: string;
|
|
32
|
+
required: boolean;
|
|
33
|
+
unique: boolean;
|
|
34
|
+
};
|
|
35
|
+
slug: {
|
|
36
|
+
type: string;
|
|
37
|
+
required: boolean;
|
|
38
|
+
unique: boolean;
|
|
39
|
+
};
|
|
40
|
+
description: {
|
|
41
|
+
type: string;
|
|
42
|
+
};
|
|
43
|
+
externalId: {
|
|
44
|
+
type: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
'variant-link': {
|
|
50
|
+
schema: {
|
|
51
|
+
kind: string;
|
|
52
|
+
collectionName: string;
|
|
53
|
+
info: {
|
|
54
|
+
singularName: string;
|
|
55
|
+
pluralName: string;
|
|
56
|
+
displayName: string;
|
|
57
|
+
};
|
|
58
|
+
options: {
|
|
59
|
+
draftAndPublish: boolean;
|
|
60
|
+
};
|
|
61
|
+
pluginOptions: {
|
|
62
|
+
"content-manager": {
|
|
63
|
+
visible: boolean;
|
|
64
|
+
};
|
|
65
|
+
"content-type-builder": {
|
|
66
|
+
visible: boolean;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
attributes: {
|
|
70
|
+
baseContentType: {
|
|
71
|
+
type: string;
|
|
72
|
+
required: boolean;
|
|
73
|
+
};
|
|
74
|
+
baseDocumentId: {
|
|
75
|
+
type: string;
|
|
76
|
+
required: boolean;
|
|
77
|
+
};
|
|
78
|
+
variantDocumentId: {
|
|
79
|
+
type: string;
|
|
80
|
+
required: boolean;
|
|
81
|
+
};
|
|
82
|
+
label: {
|
|
83
|
+
type: string;
|
|
84
|
+
};
|
|
85
|
+
assignments: {
|
|
86
|
+
type: string;
|
|
87
|
+
relation: string;
|
|
88
|
+
target: string;
|
|
89
|
+
mappedBy: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
'variant-assignment': {
|
|
95
|
+
schema: {
|
|
96
|
+
kind: string;
|
|
97
|
+
collectionName: string;
|
|
98
|
+
info: {
|
|
99
|
+
singularName: string;
|
|
100
|
+
pluralName: string;
|
|
101
|
+
displayName: string;
|
|
102
|
+
};
|
|
103
|
+
options: {
|
|
104
|
+
draftAndPublish: boolean;
|
|
105
|
+
};
|
|
106
|
+
pluginOptions: {
|
|
107
|
+
"content-manager": {
|
|
108
|
+
visible: boolean;
|
|
109
|
+
};
|
|
110
|
+
"content-type-builder": {
|
|
111
|
+
visible: boolean;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
attributes: {
|
|
115
|
+
variantLink: {
|
|
116
|
+
type: string;
|
|
117
|
+
relation: string;
|
|
118
|
+
target: string;
|
|
119
|
+
inversedBy: string;
|
|
120
|
+
};
|
|
121
|
+
segment: {
|
|
122
|
+
type: string;
|
|
123
|
+
relation: string;
|
|
124
|
+
target: string;
|
|
125
|
+
};
|
|
126
|
+
priority: {
|
|
127
|
+
type: string;
|
|
128
|
+
default: number;
|
|
129
|
+
min: number;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
controllers: {
|
|
136
|
+
segment: ({ strapi }: {
|
|
137
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
138
|
+
}) => {
|
|
139
|
+
find(ctx: any): Promise<void>;
|
|
140
|
+
findOne(ctx: any): Promise<void>;
|
|
141
|
+
create(ctx: any): Promise<void>;
|
|
142
|
+
update(ctx: any): Promise<void>;
|
|
143
|
+
delete(ctx: any): Promise<void>;
|
|
144
|
+
};
|
|
145
|
+
'variant-link': ({ strapi }: {
|
|
146
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
147
|
+
}) => {
|
|
148
|
+
find(ctx: any): Promise<void>;
|
|
149
|
+
findOne(ctx: any): Promise<void>;
|
|
150
|
+
create(ctx: any): Promise<void>;
|
|
151
|
+
update(ctx: any): Promise<void>;
|
|
152
|
+
delete(ctx: any): Promise<void>;
|
|
153
|
+
findFamily(ctx: any): Promise<void>;
|
|
154
|
+
findBatch(ctx: any): Promise<void>;
|
|
155
|
+
createWithVariant(ctx: any): Promise<void>;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
routes: {
|
|
159
|
+
admin: {
|
|
160
|
+
type: string;
|
|
161
|
+
routes: {
|
|
162
|
+
method: string;
|
|
163
|
+
path: string;
|
|
164
|
+
handler: string;
|
|
165
|
+
config: {
|
|
166
|
+
policies: never[];
|
|
167
|
+
};
|
|
168
|
+
}[];
|
|
169
|
+
};
|
|
170
|
+
'content-api': {
|
|
171
|
+
type: string;
|
|
172
|
+
routes: {
|
|
173
|
+
method: string;
|
|
174
|
+
path: string;
|
|
175
|
+
handler: string;
|
|
176
|
+
config: {
|
|
177
|
+
policies: never[];
|
|
178
|
+
};
|
|
179
|
+
}[];
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
services: {
|
|
183
|
+
segment: ({ strapi }: {
|
|
184
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
185
|
+
}) => {
|
|
186
|
+
find(query?: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument[]>;
|
|
187
|
+
findOne(documentId: string): Promise<import("@strapi/types/dist/modules/documents").AnyDocument | null>;
|
|
188
|
+
create(data: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
|
|
189
|
+
update(documentId: string, data: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument | null>;
|
|
190
|
+
delete(documentId: string): Promise<{
|
|
191
|
+
documentId: string;
|
|
192
|
+
entries: import("@strapi/types/dist/modules/documents").AnyDocument[];
|
|
193
|
+
}>;
|
|
194
|
+
};
|
|
195
|
+
'variant-resolver': ({ strapi }: {
|
|
196
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
197
|
+
}) => {
|
|
198
|
+
getVariantFieldNames(contentTypeUid: string): string[];
|
|
199
|
+
extractVariantFields(document: Record<string, any>, contentTypeUid: string): Record<string, any>;
|
|
200
|
+
resolveDocument(base: Record<string, any>, variant: Record<string, any>, options: import("./services/variant-resolver").ResolveOptions): Record<string, any>;
|
|
201
|
+
};
|
|
202
|
+
'variant-link': ({ strapi }: {
|
|
203
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
204
|
+
}) => {
|
|
205
|
+
find(query?: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument[]>;
|
|
206
|
+
findOne(documentId: string): Promise<import("@strapi/types/dist/modules/documents").AnyDocument | null>;
|
|
207
|
+
create(data: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
|
|
208
|
+
update(documentId: string, data: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument | null>;
|
|
209
|
+
delete(documentId: string): Promise<{
|
|
210
|
+
documentId: string;
|
|
211
|
+
entries: import("@strapi/types/dist/modules/documents").AnyDocument[];
|
|
212
|
+
}>;
|
|
213
|
+
findFamily(query: {
|
|
214
|
+
contentType: string;
|
|
215
|
+
documentId: string;
|
|
216
|
+
}): Promise<{
|
|
217
|
+
baseDocumentId: string;
|
|
218
|
+
isVariant: boolean;
|
|
219
|
+
currentDocumentId: string;
|
|
220
|
+
baseStatus: string;
|
|
221
|
+
links: any[];
|
|
222
|
+
}>;
|
|
223
|
+
findVariantDocumentIds(contentType: string): Promise<Set<string>>;
|
|
224
|
+
findBatch(query: {
|
|
225
|
+
baseContentType: string;
|
|
226
|
+
documentIds: string[];
|
|
227
|
+
}): Promise<Record<string, any[]>>;
|
|
228
|
+
createWithVariant(payload: {
|
|
229
|
+
baseContentType: string;
|
|
230
|
+
baseDocumentId: string;
|
|
231
|
+
locale?: string | undefined;
|
|
232
|
+
label?: string | undefined;
|
|
233
|
+
segments: {
|
|
234
|
+
documentId: string;
|
|
235
|
+
name?: string | undefined;
|
|
236
|
+
}[];
|
|
237
|
+
}): Promise<{
|
|
238
|
+
variantDocumentId: string;
|
|
239
|
+
variantLinkDocumentId: string;
|
|
240
|
+
}>;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public content-API routes.
|
|
3
|
+
*
|
|
4
|
+
* Exposes a read-only segments endpoint so frontends can fetch the list
|
|
5
|
+
* of available segments (for rendering segment pickers or passing to
|
|
6
|
+
* the segment query parameter).
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: {
|
|
9
|
+
type: string;
|
|
10
|
+
routes: {
|
|
11
|
+
method: string;
|
|
12
|
+
path: string;
|
|
13
|
+
handler: string;
|
|
14
|
+
config: {
|
|
15
|
+
policies: never[];
|
|
16
|
+
};
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
admin: {
|
|
3
|
+
type: string;
|
|
4
|
+
routes: {
|
|
5
|
+
method: string;
|
|
6
|
+
path: string;
|
|
7
|
+
handler: string;
|
|
8
|
+
config: {
|
|
9
|
+
policies: never[];
|
|
10
|
+
};
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
'content-api': {
|
|
14
|
+
type: string;
|
|
15
|
+
routes: {
|
|
16
|
+
method: string;
|
|
17
|
+
path: string;
|
|
18
|
+
handler: string;
|
|
19
|
+
config: {
|
|
20
|
+
policies: never[];
|
|
21
|
+
};
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
segment: ({ strapi }: {
|
|
3
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
find(query?: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument[]>;
|
|
6
|
+
findOne(documentId: string): Promise<import("@strapi/types/dist/modules/documents").AnyDocument | null>;
|
|
7
|
+
create(data: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
|
|
8
|
+
update(documentId: string, data: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument | null>;
|
|
9
|
+
delete(documentId: string): Promise<{
|
|
10
|
+
documentId: string;
|
|
11
|
+
entries: import("@strapi/types/dist/modules/documents").AnyDocument[];
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
'variant-resolver': ({ strapi }: {
|
|
15
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
16
|
+
}) => {
|
|
17
|
+
getVariantFieldNames(contentTypeUid: string): string[];
|
|
18
|
+
extractVariantFields(document: Record<string, any>, contentTypeUid: string): Record<string, any>;
|
|
19
|
+
resolveDocument(base: Record<string, any>, variant: Record<string, any>, options: import("./variant-resolver").ResolveOptions): Record<string, any>;
|
|
20
|
+
};
|
|
21
|
+
'variant-link': ({ strapi }: {
|
|
22
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
23
|
+
}) => {
|
|
24
|
+
find(query?: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument[]>;
|
|
25
|
+
findOne(documentId: string): Promise<import("@strapi/types/dist/modules/documents").AnyDocument | null>;
|
|
26
|
+
create(data: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
|
|
27
|
+
update(documentId: string, data: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument | null>;
|
|
28
|
+
delete(documentId: string): Promise<{
|
|
29
|
+
documentId: string;
|
|
30
|
+
entries: import("@strapi/types/dist/modules/documents").AnyDocument[];
|
|
31
|
+
}>;
|
|
32
|
+
findFamily(query: {
|
|
33
|
+
contentType: string;
|
|
34
|
+
documentId: string;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
baseDocumentId: string;
|
|
37
|
+
isVariant: boolean;
|
|
38
|
+
currentDocumentId: string;
|
|
39
|
+
baseStatus: string;
|
|
40
|
+
links: any[];
|
|
41
|
+
}>;
|
|
42
|
+
findVariantDocumentIds(contentType: string): Promise<Set<string>>;
|
|
43
|
+
findBatch(query: {
|
|
44
|
+
baseContentType: string;
|
|
45
|
+
documentIds: string[];
|
|
46
|
+
}): Promise<Record<string, any[]>>;
|
|
47
|
+
createWithVariant(payload: {
|
|
48
|
+
baseContentType: string;
|
|
49
|
+
baseDocumentId: string;
|
|
50
|
+
locale?: string | undefined;
|
|
51
|
+
label?: string | undefined;
|
|
52
|
+
segments: {
|
|
53
|
+
documentId: string;
|
|
54
|
+
name?: string | undefined;
|
|
55
|
+
}[];
|
|
56
|
+
}): Promise<{
|
|
57
|
+
variantDocumentId: string;
|
|
58
|
+
variantLinkDocumentId: string;
|
|
59
|
+
}>;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Core } from '@strapi/strapi';
|
|
2
|
+
declare const segmentService: ({ strapi }: {
|
|
3
|
+
strapi: Core.Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
find(query?: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument[]>;
|
|
6
|
+
findOne(documentId: string): Promise<import("@strapi/types/dist/modules/documents").AnyDocument | null>;
|
|
7
|
+
create(data: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
|
|
8
|
+
update(documentId: string, data: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument | null>;
|
|
9
|
+
delete(documentId: string): Promise<{
|
|
10
|
+
documentId: string;
|
|
11
|
+
entries: import("@strapi/types/dist/modules/documents").AnyDocument[];
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
export default segmentService;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Core } from '@strapi/strapi';
|
|
2
|
+
declare const variantLinkService: ({ strapi }: {
|
|
3
|
+
strapi: Core.Strapi;
|
|
4
|
+
}) => {
|
|
5
|
+
find(query?: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument[]>;
|
|
6
|
+
findOne(documentId: string): Promise<import("@strapi/types/dist/modules/documents").AnyDocument | null>;
|
|
7
|
+
create(data: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
|
|
8
|
+
update(documentId: string, data: any): Promise<import("@strapi/types/dist/modules/documents").AnyDocument | null>;
|
|
9
|
+
delete(documentId: string): Promise<{
|
|
10
|
+
documentId: string;
|
|
11
|
+
entries: import("@strapi/types/dist/modules/documents").AnyDocument[];
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the full "variant family" for any document (base or variant).
|
|
15
|
+
* Returns { baseDocumentId, isVariant, currentDocumentId, baseStatus, links[] }.
|
|
16
|
+
* Each link is enriched with `variantStatus` ('draft' | 'published' | 'modified').
|
|
17
|
+
*/
|
|
18
|
+
findFamily(query: {
|
|
19
|
+
contentType: string;
|
|
20
|
+
documentId: string;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
baseDocumentId: string;
|
|
23
|
+
isVariant: boolean;
|
|
24
|
+
currentDocumentId: string;
|
|
25
|
+
baseStatus: string;
|
|
26
|
+
links: any[];
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a Set of all variantDocumentIds for a given content type.
|
|
30
|
+
* Used to filter variant clones out of public API list results.
|
|
31
|
+
*/
|
|
32
|
+
findVariantDocumentIds(contentType: string): Promise<Set<string>>;
|
|
33
|
+
/**
|
|
34
|
+
* Batch fetch variant links for multiple document IDs (base or variant).
|
|
35
|
+
* Searches both baseDocumentId and variantDocumentId fields.
|
|
36
|
+
* Returns a map of documentId → links[].
|
|
37
|
+
*/
|
|
38
|
+
findBatch(query: {
|
|
39
|
+
baseContentType: string;
|
|
40
|
+
documentIds: string[];
|
|
41
|
+
}): Promise<Record<string, any[]>>;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a new variant document by cloning the base document (current locale),
|
|
44
|
+
* then creates the variant-link and its variant-assignments (segments + priority).
|
|
45
|
+
*/
|
|
46
|
+
createWithVariant(payload: {
|
|
47
|
+
baseContentType: string;
|
|
48
|
+
baseDocumentId: string;
|
|
49
|
+
locale?: string;
|
|
50
|
+
label?: string;
|
|
51
|
+
segments: Array<{
|
|
52
|
+
documentId: string;
|
|
53
|
+
name?: string;
|
|
54
|
+
}>;
|
|
55
|
+
}): Promise<{
|
|
56
|
+
variantDocumentId: string;
|
|
57
|
+
variantLinkDocumentId: string;
|
|
58
|
+
}>;
|
|
59
|
+
};
|
|
60
|
+
export default variantLinkService;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Core } from '@strapi/strapi';
|
|
2
|
+
export interface ResolveOptions {
|
|
3
|
+
segmentSlug: string;
|
|
4
|
+
contentTypeUid: string;
|
|
5
|
+
}
|
|
6
|
+
declare const variantResolverService: ({ strapi }: {
|
|
7
|
+
strapi: Core.Strapi;
|
|
8
|
+
}) => {
|
|
9
|
+
/**
|
|
10
|
+
* Returns the list of field names marked as variant on a content type.
|
|
11
|
+
*/
|
|
12
|
+
getVariantFieldNames(contentTypeUid: string): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Extracts only the variant-marked field values from a document.
|
|
15
|
+
*/
|
|
16
|
+
extractVariantFields(document: Record<string, any>, contentTypeUid: string): Record<string, any>;
|
|
17
|
+
/**
|
|
18
|
+
* Resolve variant fields: start with base document, overlay variant-marked
|
|
19
|
+
* fields from the variant document.
|
|
20
|
+
*/
|
|
21
|
+
resolveDocument(base: Record<string, any>, variant: Record<string, any>, options: ResolveOptions): Record<string, any>;
|
|
22
|
+
};
|
|
23
|
+
export default variantResolverService;
|