@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,7 @@
|
|
|
1
|
+
import { type HeaderActionProps } from '@strapi/content-manager/strapi-admin';
|
|
2
|
+
declare const SegmentPickerAction: ({ model, documentId, collectionType }: HeaderActionProps) => {
|
|
3
|
+
label: string;
|
|
4
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
customizeContent: () => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
} | null;
|
|
7
|
+
export { SegmentPickerAction };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface EditViewContext {
|
|
2
|
+
document?: any;
|
|
3
|
+
documentId?: string;
|
|
4
|
+
meta?: any;
|
|
5
|
+
model?: string;
|
|
6
|
+
collectionType?: 'single-types' | 'collection-types';
|
|
7
|
+
activeTab?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const VariantPanel: ({ documentId, model, collectionType }: EditViewContext) => {
|
|
10
|
+
title: string;
|
|
11
|
+
content: import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
} | null;
|
|
13
|
+
export { VariantPanel };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Header action dropdown for switching between base and variant documents,
|
|
3
|
+
* and creating new variants — mirrors Strapi's i18n locale picker pattern.
|
|
4
|
+
*
|
|
5
|
+
* Returns the `options` shape that Strapi's HeaderActions renders as a SingleSelect.
|
|
6
|
+
*/
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { type HeaderActionProps } from '@strapi/content-manager/strapi-admin';
|
|
9
|
+
declare const VariantPickerAction: ({ model, documentId, collectionType }: HeaderActionProps) => {
|
|
10
|
+
label: string;
|
|
11
|
+
options: {
|
|
12
|
+
label: React.ReactNode;
|
|
13
|
+
value: string;
|
|
14
|
+
startIcon?: React.ReactNode;
|
|
15
|
+
}[];
|
|
16
|
+
value: string;
|
|
17
|
+
customizeContent: () => string;
|
|
18
|
+
onSelect: (value: string) => Promise<void>;
|
|
19
|
+
} | null;
|
|
20
|
+
export { VariantPickerAction };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ListFieldLayout, ListLayout } from '@strapi/content-manager/strapi-admin';
|
|
2
|
+
interface AddColumnToTableHookArgs {
|
|
3
|
+
layout: ListLayout;
|
|
4
|
+
displayedHeaders: ListFieldLayout[];
|
|
5
|
+
}
|
|
6
|
+
export declare const addVariantColumnHook: ({ displayedHeaders, layout, }: AddColumnToTableHookArgs) => {
|
|
7
|
+
displayedHeaders: (ListFieldLayout | {
|
|
8
|
+
attribute: {
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
label: {
|
|
12
|
+
id: string;
|
|
13
|
+
defaultMessage: string;
|
|
14
|
+
};
|
|
15
|
+
searchable: boolean;
|
|
16
|
+
sortable: boolean;
|
|
17
|
+
name: string;
|
|
18
|
+
cellFormatter: (props: any, _header: any, _meta: any) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
})[];
|
|
20
|
+
layout: ListLayout;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Segment {
|
|
2
|
+
id: number;
|
|
3
|
+
documentId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
slug: string;
|
|
6
|
+
description: string | null;
|
|
7
|
+
externalId: string | null;
|
|
8
|
+
}
|
|
9
|
+
export declare function useSegments(): {
|
|
10
|
+
segments: Segment[];
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
error: string | null;
|
|
13
|
+
fetchSegments: () => Promise<void>;
|
|
14
|
+
createSegment: (payload: Partial<Segment>) => Promise<any>;
|
|
15
|
+
updateSegment: (documentId: string, payload: Partial<Segment>) => Promise<any>;
|
|
16
|
+
deleteSegment: (documentId: string) => Promise<void>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { VariantLink } from './useVariantLinks';
|
|
2
|
+
export interface VariantFamily {
|
|
3
|
+
baseDocumentId: string;
|
|
4
|
+
isVariant: boolean;
|
|
5
|
+
currentDocumentId: string;
|
|
6
|
+
baseStatus?: 'draft' | 'published' | 'modified';
|
|
7
|
+
links: VariantLink[];
|
|
8
|
+
}
|
|
9
|
+
interface UseVariantFamilyOptions {
|
|
10
|
+
contentType: string;
|
|
11
|
+
documentId?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function useVariantFamily({ contentType, documentId }: UseVariantFamilyOptions): {
|
|
14
|
+
family: VariantFamily | null;
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
error: string | null;
|
|
17
|
+
refetch: () => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface VariantLink {
|
|
2
|
+
id?: number;
|
|
3
|
+
documentId?: string;
|
|
4
|
+
baseContentType: string;
|
|
5
|
+
baseDocumentId: string;
|
|
6
|
+
variantDocumentId: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
variantStatus?: 'draft' | 'published' | 'modified';
|
|
9
|
+
assignments?: {
|
|
10
|
+
id?: number;
|
|
11
|
+
priority?: number;
|
|
12
|
+
segment?: {
|
|
13
|
+
id?: number;
|
|
14
|
+
documentId?: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
slug?: string;
|
|
17
|
+
} | null;
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
interface UseVariantLinksOptions {
|
|
21
|
+
baseContentType: string;
|
|
22
|
+
baseDocumentId?: string;
|
|
23
|
+
variantDocumentId?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function useVariantLinks({ baseContentType, baseDocumentId, variantDocumentId }: UseVariantLinksOptions): {
|
|
26
|
+
links: VariantLink[];
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
error: string | null;
|
|
29
|
+
fetchLinks: () => Promise<void>;
|
|
30
|
+
createLink: (payload: Partial<VariantLink>) => Promise<any>;
|
|
31
|
+
createVariantWithSegments: (payload: {
|
|
32
|
+
baseContentType: string;
|
|
33
|
+
baseDocumentId: string;
|
|
34
|
+
locale?: string;
|
|
35
|
+
label?: string;
|
|
36
|
+
segments: Array<{
|
|
37
|
+
documentId: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
}>;
|
|
40
|
+
}) => Promise<any>;
|
|
41
|
+
updateLink: (documentId: string, payload: Partial<VariantLink>) => Promise<any>;
|
|
42
|
+
deleteLink: (documentId: string) => Promise<void>;
|
|
43
|
+
};
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module-level batch collector that accumulates per-cell documentId requests
|
|
3
|
+
* and fires a single POST /links/batch after a 50ms debounce.
|
|
4
|
+
* Each cell gets a Promise that resolves when the batch response arrives.
|
|
5
|
+
*/
|
|
6
|
+
import type { VariantLink } from '../hooks/useVariantLinks';
|
|
7
|
+
type FetchFn = (url: string, config?: any) => Promise<{
|
|
8
|
+
data: any;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function fetchLinksForDocument(postFn: FetchFn, contentType: string, documentId: string): Promise<VariantLink[]>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const PLUGIN_ID = "content-variants";
|
|
2
|
+
export interface SegmentAssignment {
|
|
3
|
+
id?: number;
|
|
4
|
+
segment?: {
|
|
5
|
+
id?: number;
|
|
6
|
+
documentId?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
slug?: string;
|
|
9
|
+
} | null;
|
|
10
|
+
priority?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function isVariantEnabledContentType(options: Record<string, any> | undefined): boolean;
|
|
13
|
+
export declare function isVariantField(attribute: Record<string, any>): boolean;
|