@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.
Files changed (43) hide show
  1. package/README.md +600 -0
  2. package/dist/_chunks/Segments-BREqC60L.js +330 -0
  3. package/dist/_chunks/Segments-BgxnvvtR.mjs +330 -0
  4. package/dist/_chunks/en-Bnfrhhim.js +62 -0
  5. package/dist/_chunks/en-e_966kWj.mjs +62 -0
  6. package/dist/_chunks/index-DVoZM8JU.js +1036 -0
  7. package/dist/_chunks/index-Dj2sexmk.mjs +1020 -0
  8. package/dist/admin/index.js +3 -0
  9. package/dist/admin/index.mjs +4 -0
  10. package/dist/admin/src/components/Initializer.d.ts +5 -0
  11. package/dist/admin/src/components/SegmentPickerAction.d.ts +7 -0
  12. package/dist/admin/src/components/VariantInfoAction.d.ts +8 -0
  13. package/dist/admin/src/components/VariantPanel.d.ts +13 -0
  14. package/dist/admin/src/components/VariantPickerAction.d.ts +20 -0
  15. package/dist/admin/src/contentManagerHooks/editView.d.ts +6 -0
  16. package/dist/admin/src/contentManagerHooks/listView.d.ts +22 -0
  17. package/dist/admin/src/hooks/useSegments.d.ts +17 -0
  18. package/dist/admin/src/hooks/useVariantFamily.d.ts +19 -0
  19. package/dist/admin/src/hooks/useVariantLinks.d.ts +44 -0
  20. package/dist/admin/src/index.d.ts +11 -0
  21. package/dist/admin/src/pages/Settings/Segments.d.ts +2 -0
  22. package/dist/admin/src/pluginId.d.ts +2 -0
  23. package/dist/admin/src/utils/batchLinkFetcher.d.ts +11 -0
  24. package/dist/admin/src/utils/variants.d.ts +13 -0
  25. package/dist/server/index.js +895 -0
  26. package/dist/server/index.mjs +896 -0
  27. package/dist/server/src/bootstrap.d.ts +17 -0
  28. package/dist/server/src/config/index.d.ts +5 -0
  29. package/dist/server/src/content-types/index.d.ts +121 -0
  30. package/dist/server/src/controllers/index.d.ts +24 -0
  31. package/dist/server/src/controllers/segment.d.ts +11 -0
  32. package/dist/server/src/controllers/variant-link.d.ts +18 -0
  33. package/dist/server/src/destroy.d.ts +5 -0
  34. package/dist/server/src/index.d.ts +244 -0
  35. package/dist/server/src/register.d.ts +5 -0
  36. package/dist/server/src/routes/admin.d.ts +12 -0
  37. package/dist/server/src/routes/content-api.d.ts +19 -0
  38. package/dist/server/src/routes/index.d.ts +25 -0
  39. package/dist/server/src/services/index.d.ts +62 -0
  40. package/dist/server/src/services/segment.d.ts +14 -0
  41. package/dist/server/src/services/variant-link.d.ts +60 -0
  42. package/dist/server/src/services/variant-resolver.d.ts +23 -0
  43. package/package.json +104 -0
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ const index = require("../_chunks/index-DVoZM8JU.js");
3
+ module.exports = index.index;
@@ -0,0 +1,4 @@
1
+ import { i } from "../_chunks/index-Dj2sexmk.mjs";
2
+ export {
3
+ i as default
4
+ };
@@ -0,0 +1,5 @@
1
+ type InitializerProps = {
2
+ setPlugin: (id: string) => void;
3
+ };
4
+ export declare const Initializer: ({ setPlugin }: InitializerProps) => null;
5
+ export {};
@@ -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,8 @@
1
+ interface DocumentActionProps {
2
+ model: string;
3
+ documentId?: string;
4
+ document?: any;
5
+ collectionType: string;
6
+ }
7
+ declare const VariantInfoAction: ({ model, documentId, collectionType, }: DocumentActionProps) => null;
8
+ export { VariantInfoAction };
@@ -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,6 @@
1
+ import type { EditLayout } from '@strapi/content-manager/strapi-admin';
2
+ interface MutateEditViewArgs {
3
+ layout: EditLayout;
4
+ }
5
+ export declare const mutateEditViewHook: ({ layout }: MutateEditViewArgs) => MutateEditViewArgs;
6
+ export {};
@@ -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
+ declare const _default: {
2
+ register(app: any): void;
3
+ bootstrap(app: any): void;
4
+ registerTrads({ locales }: {
5
+ locales: string[];
6
+ }): Promise<{
7
+ locale: string;
8
+ data: {};
9
+ }[]>;
10
+ };
11
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const SegmentsSettingsPage: () => import("react/jsx-runtime").JSX.Element;
2
+ export default SegmentsSettingsPage;
@@ -0,0 +1,2 @@
1
+ declare const pluginId = "content-variants";
2
+ export default pluginId;
@@ -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;