@payloadcms/plugin-redirects 3.0.0-canary.f83d96a → 3.0.0-canary.fb81f02

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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Config } from 'payload';
2
2
  import type { RedirectsPluginConfig } from './types.js';
3
+ export { redirectOptions, redirectTypes } from './redirectTypes.js';
3
4
  export declare const redirectsPlugin: (pluginConfig: RedirectsPluginConfig) => (incomingConfig: Config) => Config;
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,MAAM,EAAS,MAAM,SAAS,CAAA;AAE9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,eAAe,iBACX,qBAAqB,sBACnB,MAAM,KAAG,MA6EzB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,MAAM,EAAsB,MAAM,SAAS,CAAA;AAE3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAIvD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACnE,eAAO,MAAM,eAAe,iBACX,qBAAqB,sBACnB,MAAM,KAAG,MAyFzB,CAAA"}
package/dist/index.js CHANGED
@@ -1,4 +1,14 @@
1
+ import { redirectOptions } from './redirectTypes.js';
2
+ export { redirectOptions, redirectTypes } from './redirectTypes.js';
1
3
  export const redirectsPlugin = (pluginConfig)=>(incomingConfig)=>{
4
+ const redirectSelectField = {
5
+ name: 'type',
6
+ type: 'select',
7
+ label: 'Redirect Type',
8
+ options: redirectOptions.filter((option)=>pluginConfig?.redirectTypes?.includes(option.value)),
9
+ required: true,
10
+ ...pluginConfig?.redirectTypeFieldOverride || {}
11
+ };
2
12
  const defaultFields = [
3
13
  {
4
14
  name: 'from',
@@ -51,7 +61,10 @@ export const redirectsPlugin = (pluginConfig)=>(incomingConfig)=>{
51
61
  }
52
62
  ],
53
63
  label: false
54
- }
64
+ },
65
+ ...pluginConfig?.redirectTypes ? [
66
+ redirectSelectField
67
+ ] : []
55
68
  ];
56
69
  const redirectsCollection = {
57
70
  ...pluginConfig?.overrides || {},
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionConfig, Config, Field } from 'payload'\n\nimport type { RedirectsPluginConfig } from './types.js'\n\nexport const redirectsPlugin =\n (pluginConfig: RedirectsPluginConfig) =>\n (incomingConfig: Config): Config => {\n const defaultFields: Field[] = [\n {\n name: 'from',\n type: 'text',\n index: true,\n label: 'From URL',\n required: true,\n },\n {\n name: 'to',\n type: 'group',\n fields: [\n {\n name: 'type',\n type: 'radio',\n admin: {\n layout: 'horizontal',\n },\n defaultValue: 'reference',\n label: 'To URL Type',\n options: [\n {\n label: 'Internal link',\n value: 'reference',\n },\n {\n label: 'Custom URL',\n value: 'custom',\n },\n ],\n },\n {\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'reference',\n },\n label: 'Document to redirect to',\n relationTo: pluginConfig?.collections || [],\n required: true,\n },\n {\n name: 'url',\n type: 'text',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'custom',\n },\n label: 'Custom URL',\n required: true,\n },\n ],\n label: false,\n },\n ]\n\n const redirectsCollection: CollectionConfig = {\n ...(pluginConfig?.overrides || {}),\n slug: pluginConfig?.overrides?.slug || 'redirects',\n access: {\n read: () => true,\n ...(pluginConfig?.overrides?.access || {}),\n },\n admin: {\n defaultColumns: ['from', 'to.type', 'createdAt'],\n ...(pluginConfig?.overrides?.admin || {}),\n },\n fields:\n pluginConfig?.overrides?.fields && typeof pluginConfig?.overrides?.fields === 'function'\n ? pluginConfig?.overrides.fields({ defaultFields })\n : defaultFields,\n }\n\n return {\n ...incomingConfig,\n collections: [...(incomingConfig?.collections || []), redirectsCollection],\n }\n }\n"],"names":["redirectsPlugin","pluginConfig","incomingConfig","defaultFields","name","type","index","label","required","fields","admin","layout","defaultValue","options","value","condition","_","siblingData","relationTo","collections","redirectsCollection","overrides","slug","access","read","defaultColumns"],"mappings":"AAIA,OAAO,MAAMA,kBACX,CAACC,eACD,CAACC;QACC,MAAMC,gBAAyB;YAC7B;gBACEC,MAAM;gBACNC,MAAM;gBACNC,OAAO;gBACPC,OAAO;gBACPC,UAAU;YACZ;YACA;gBACEJ,MAAM;gBACNC,MAAM;gBACNI,QAAQ;oBACN;wBACEL,MAAM;wBACNC,MAAM;wBACNK,OAAO;4BACLC,QAAQ;wBACV;wBACAC,cAAc;wBACdL,OAAO;wBACPM,SAAS;4BACP;gCACEN,OAAO;gCACPO,OAAO;4BACT;4BACA;gCACEP,OAAO;gCACPO,OAAO;4BACT;yBACD;oBACH;oBACA;wBACEV,MAAM;wBACNC,MAAM;wBACNK,OAAO;4BACLK,WAAW,CAACC,GAAGC,cAAgBA,aAAaZ,SAAS;wBACvD;wBACAE,OAAO;wBACPW,YAAYjB,cAAckB,eAAe,EAAE;wBAC3CX,UAAU;oBACZ;oBACA;wBACEJ,MAAM;wBACNC,MAAM;wBACNK,OAAO;4BACLK,WAAW,CAACC,GAAGC,cAAgBA,aAAaZ,SAAS;wBACvD;wBACAE,OAAO;wBACPC,UAAU;oBACZ;iBACD;gBACDD,OAAO;YACT;SACD;QAED,MAAMa,sBAAwC;YAC5C,GAAInB,cAAcoB,aAAa,CAAC,CAAC;YACjCC,MAAMrB,cAAcoB,WAAWC,QAAQ;YACvCC,QAAQ;gBACNC,MAAM,IAAM;gBACZ,GAAIvB,cAAcoB,WAAWE,UAAU,CAAC,CAAC;YAC3C;YACAb,OAAO;gBACLe,gBAAgB;oBAAC;oBAAQ;oBAAW;iBAAY;gBAChD,GAAIxB,cAAcoB,WAAWX,SAAS,CAAC,CAAC;YAC1C;YACAD,QACER,cAAcoB,WAAWZ,UAAU,OAAOR,cAAcoB,WAAWZ,WAAW,aAC1ER,cAAcoB,UAAUZ,OAAO;gBAAEN;YAAc,KAC/CA;QACR;QAEA,OAAO;YACL,GAAGD,cAAc;YACjBiB,aAAa;mBAAKjB,gBAAgBiB,eAAe,EAAE;gBAAGC;aAAoB;QAC5E;IACF,EAAC"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { CollectionConfig, Config, Field, SelectField } from 'payload'\n\nimport type { RedirectsPluginConfig } from './types.js'\n\nimport { redirectOptions } from './redirectTypes.js'\n\nexport { redirectOptions, redirectTypes } from './redirectTypes.js'\nexport const redirectsPlugin =\n (pluginConfig: RedirectsPluginConfig) =>\n (incomingConfig: Config): Config => {\n const redirectSelectField: SelectField = {\n name: 'type',\n type: 'select',\n label: 'Redirect Type',\n options: redirectOptions.filter((option) =>\n pluginConfig?.redirectTypes?.includes(option.value),\n ),\n required: true,\n ...(pluginConfig?.redirectTypeFieldOverride || {}),\n }\n\n const defaultFields: Field[] = [\n {\n name: 'from',\n type: 'text',\n index: true,\n label: 'From URL',\n required: true,\n },\n {\n name: 'to',\n type: 'group',\n fields: [\n {\n name: 'type',\n type: 'radio',\n admin: {\n layout: 'horizontal',\n },\n defaultValue: 'reference',\n label: 'To URL Type',\n options: [\n {\n label: 'Internal link',\n value: 'reference',\n },\n {\n label: 'Custom URL',\n value: 'custom',\n },\n ],\n },\n {\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'reference',\n },\n label: 'Document to redirect to',\n relationTo: pluginConfig?.collections || [],\n required: true,\n },\n {\n name: 'url',\n type: 'text',\n admin: {\n condition: (_, siblingData) => siblingData?.type === 'custom',\n },\n label: 'Custom URL',\n required: true,\n },\n ],\n label: false,\n },\n ...(pluginConfig?.redirectTypes ? [redirectSelectField] : []),\n ]\n\n const redirectsCollection: CollectionConfig = {\n ...(pluginConfig?.overrides || {}),\n slug: pluginConfig?.overrides?.slug || 'redirects',\n access: {\n read: () => true,\n ...(pluginConfig?.overrides?.access || {}),\n },\n admin: {\n defaultColumns: ['from', 'to.type', 'createdAt'],\n ...(pluginConfig?.overrides?.admin || {}),\n },\n fields:\n pluginConfig?.overrides?.fields && typeof pluginConfig?.overrides?.fields === 'function'\n ? pluginConfig?.overrides.fields({ defaultFields })\n : defaultFields,\n }\n\n return {\n ...incomingConfig,\n collections: [...(incomingConfig?.collections || []), redirectsCollection],\n }\n }\n"],"names":["redirectOptions","redirectTypes","redirectsPlugin","pluginConfig","incomingConfig","redirectSelectField","name","type","label","options","filter","option","includes","value","required","redirectTypeFieldOverride","defaultFields","index","fields","admin","layout","defaultValue","condition","_","siblingData","relationTo","collections","redirectsCollection","overrides","slug","access","read","defaultColumns"],"mappings":"AAIA,SAASA,eAAe,QAAQ,qBAAoB;AAEpD,SAASA,eAAe,EAAEC,aAAa,QAAQ,qBAAoB;AACnE,OAAO,MAAMC,kBACX,CAACC,eACD,CAACC;QACC,MAAMC,sBAAmC;YACvCC,MAAM;YACNC,MAAM;YACNC,OAAO;YACPC,SAAST,gBAAgBU,MAAM,CAAC,CAACC,SAC/BR,cAAcF,eAAeW,SAASD,OAAOE,KAAK;YAEpDC,UAAU;YACV,GAAIX,cAAcY,6BAA6B,CAAC,CAAC;QACnD;QAEA,MAAMC,gBAAyB;YAC7B;gBACEV,MAAM;gBACNC,MAAM;gBACNU,OAAO;gBACPT,OAAO;gBACPM,UAAU;YACZ;YACA;gBACER,MAAM;gBACNC,MAAM;gBACNW,QAAQ;oBACN;wBACEZ,MAAM;wBACNC,MAAM;wBACNY,OAAO;4BACLC,QAAQ;wBACV;wBACAC,cAAc;wBACdb,OAAO;wBACPC,SAAS;4BACP;gCACED,OAAO;gCACPK,OAAO;4BACT;4BACA;gCACEL,OAAO;gCACPK,OAAO;4BACT;yBACD;oBACH;oBACA;wBACEP,MAAM;wBACNC,MAAM;wBACNY,OAAO;4BACLG,WAAW,CAACC,GAAGC,cAAgBA,aAAajB,SAAS;wBACvD;wBACAC,OAAO;wBACPiB,YAAYtB,cAAcuB,eAAe,EAAE;wBAC3CZ,UAAU;oBACZ;oBACA;wBACER,MAAM;wBACNC,MAAM;wBACNY,OAAO;4BACLG,WAAW,CAACC,GAAGC,cAAgBA,aAAajB,SAAS;wBACvD;wBACAC,OAAO;wBACPM,UAAU;oBACZ;iBACD;gBACDN,OAAO;YACT;eACIL,cAAcF,gBAAgB;gBAACI;aAAoB,GAAG,EAAE;SAC7D;QAED,MAAMsB,sBAAwC;YAC5C,GAAIxB,cAAcyB,aAAa,CAAC,CAAC;YACjCC,MAAM1B,cAAcyB,WAAWC,QAAQ;YACvCC,QAAQ;gBACNC,MAAM,IAAM;gBACZ,GAAI5B,cAAcyB,WAAWE,UAAU,CAAC,CAAC;YAC3C;YACAX,OAAO;gBACLa,gBAAgB;oBAAC;oBAAQ;oBAAW;iBAAY;gBAChD,GAAI7B,cAAcyB,WAAWT,SAAS,CAAC,CAAC;YAC1C;YACAD,QACEf,cAAcyB,WAAWV,UAAU,OAAOf,cAAcyB,WAAWV,WAAW,aAC1Ef,cAAcyB,UAAUV,OAAO;gBAAEF;YAAc,KAC/CA;QACR;QAEA,OAAO;YACL,GAAGZ,cAAc;YACjBsB,aAAa;mBAAKtB,gBAAgBsB,eAAe,EAAE;gBAAGC;aAAoB;QAC5E;IACF,EAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const redirectTypes: readonly ["301", "302", "303", "307", "308"];
2
+ export declare const redirectOptions: {
3
+ label: string;
4
+ value: (typeof redirectTypes)[number];
5
+ }[];
6
+ //# sourceMappingURL=redirectTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirectTypes.d.ts","sourceRoot":"","sources":["../src/redirectTypes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,8CAA+C,CAAA;AAEzE,eAAO,MAAM,eAAe,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAA;CAAE,EAqBrF,CAAA"}
@@ -0,0 +1,31 @@
1
+ export const redirectTypes = [
2
+ '301',
3
+ '302',
4
+ '303',
5
+ '307',
6
+ '308'
7
+ ];
8
+ export const redirectOptions = [
9
+ {
10
+ label: '301 - Permanent',
11
+ value: '301'
12
+ },
13
+ {
14
+ label: '302 - Temporary',
15
+ value: '302'
16
+ },
17
+ {
18
+ label: '303 - See Other',
19
+ value: '303'
20
+ },
21
+ {
22
+ label: '307 - Temporary Redirect',
23
+ value: '307'
24
+ },
25
+ {
26
+ label: '308 - Permanent Redirect',
27
+ value: '308'
28
+ }
29
+ ];
30
+
31
+ //# sourceMappingURL=redirectTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/redirectTypes.ts"],"sourcesContent":["export const redirectTypes = ['301', '302', '303', '307', '308'] as const\n\nexport const redirectOptions: { label: string; value: (typeof redirectTypes)[number] }[] = [\n {\n label: '301 - Permanent',\n value: '301',\n },\n {\n label: '302 - Temporary',\n value: '302',\n },\n {\n label: '303 - See Other',\n value: '303',\n },\n {\n label: '307 - Temporary Redirect',\n value: '307',\n },\n {\n label: '308 - Permanent Redirect',\n value: '308',\n },\n]\n"],"names":["redirectTypes","redirectOptions","label","value"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB;IAAC;IAAO;IAAO;IAAO;IAAO;CAAM,CAAS;AAEzE,OAAO,MAAMC,kBAA8E;IACzF;QACEC,OAAO;QACPC,OAAO;IACT;IACA;QACED,OAAO;QACPC,OAAO;IACT;IACA;QACED,OAAO;QACPC,OAAO;IACT;IACA;QACED,OAAO;QACPC,OAAO;IACT;IACA;QACED,OAAO;QACPC,OAAO;IACT;CACD,CAAA"}
package/dist/types.d.ts CHANGED
@@ -1,11 +1,14 @@
1
- import type { CollectionConfig, Field } from 'payload';
1
+ import type { CollectionConfig, Field, SelectField } from 'payload';
2
+ import type { redirectTypes } from './redirectTypes.js';
2
3
  export type FieldsOverride = (args: {
3
4
  defaultFields: Field[];
4
5
  }) => Field[];
5
6
  export type RedirectsPluginConfig = {
6
7
  collections?: string[];
7
- overrides?: Partial<Omit<CollectionConfig, 'fields'>> & {
8
- fields: FieldsOverride;
9
- };
8
+ overrides?: {
9
+ fields?: FieldsOverride;
10
+ } & Partial<Omit<CollectionConfig, 'fields'>>;
11
+ redirectTypeFieldOverride?: Partial<SelectField>;
12
+ redirectTypes?: (typeof redirectTypes)[number][];
10
13
  };
11
14
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEtD,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE;IAAE,aAAa,EAAE,KAAK,EAAE,CAAA;CAAE,KAAK,KAAK,EAAE,CAAA;AAE1E,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC,GAAG;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,CAAA;CACnF,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE;IAAE,aAAa,EAAE,KAAK,EAAE,CAAA;CAAE,KAAK,KAAK,EAAE,CAAA;AAE1E,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,SAAS,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAA;IACnF,yBAAyB,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAChD,aAAa,CAAC,EAAE,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE,CAAA;CACjD,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type RedirectsPluginConfig = {\n collections?: string[]\n overrides?: Partial<Omit<CollectionConfig, 'fields'>> & { fields: FieldsOverride }\n}\n"],"names":[],"mappings":"AAIA,WAGC"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { CollectionConfig, Field, SelectField } from 'payload'\n\nimport type { redirectTypes } from './redirectTypes.js'\nexport type FieldsOverride = (args: { defaultFields: Field[] }) => Field[]\n\nexport type RedirectsPluginConfig = {\n collections?: string[]\n overrides?: { fields?: FieldsOverride } & Partial<Omit<CollectionConfig, 'fields'>>\n redirectTypeFieldOverride?: Partial<SelectField>\n redirectTypes?: (typeof redirectTypes)[number][]\n}\n"],"names":[],"mappings":"AAKA,WAKC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-redirects",
3
- "version": "3.0.0-canary.f83d96a",
3
+ "version": "3.0.0-canary.fb81f02",
4
4
  "description": "Redirects plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -40,18 +40,18 @@
40
40
  ],
41
41
  "devDependencies": {
42
42
  "@types/express": "^4.17.9",
43
- "@types/react": "npm:types-react@19.0.0-beta.2",
44
- "@types/react-dom": "npm:types-react-dom@19.0.0-beta.2",
45
- "@payloadcms/eslint-config": "1.1.1",
46
- "payload": "3.0.0-canary.f83d96a"
43
+ "@types/react": "npm:types-react@19.0.0-rc.0",
44
+ "@types/react-dom": "npm:types-react-dom@19.0.0-rc.0",
45
+ "@payloadcms/eslint-config": "3.0.0-beta.59",
46
+ "payload": "3.0.0-canary.fb81f02"
47
47
  },
48
48
  "peerDependencies": {
49
- "payload": "3.0.0-canary.f83d96a"
49
+ "payload": "3.0.0-canary.fb81f02"
50
50
  },
51
51
  "homepage:": "https://payloadcms.com",
52
52
  "overrides": {
53
- "@types/react": "npm:types-react@19.0.0-beta.2",
54
- "@types/react-dom": "npm:types-react-dom@19.0.0-beta.2"
53
+ "@types/react": "npm:types-react@19.0.0-rc.0",
54
+ "@types/react-dom": "npm:types-react-dom@19.0.0-rc.0"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",