@payloadcms/plugin-redirects 3.0.0-beta.11 → 3.0.0-beta.110
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/exports/types.d.ts +2 -0
- package/dist/exports/types.d.ts.map +1 -0
- package/dist/exports/types.js +3 -0
- package/dist/exports/types.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +91 -71
- package/dist/index.js.map +1 -1
- package/dist/redirectTypes.d.ts +6 -0
- package/dist/redirectTypes.d.ts.map +1 -0
- package/dist/redirectTypes.js +31 -0
- package/dist/redirectTypes.js.map +1 -0
- package/dist/types.d.ts +12 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +37 -26
- package/dist/deepMerge.d.ts +0 -13
- package/dist/deepMerge.d.ts.map +0 -1
- package/dist/deepMerge.js +0 -37
- package/dist/deepMerge.js.map +0 -1
- package/src/index.ts +0 -82
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/exports/types.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/types.ts"],"sourcesContent":["export type { RedirectsPluginConfig } from '../types.js'\n"],"names":[],"mappings":"AAAA,WAAwD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Config } from 'payload
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
import type { Config } from 'payload';
|
|
2
|
+
import type { RedirectsPluginConfig } from './types.js';
|
|
3
|
+
export { redirectOptions, redirectTypes } from './redirectTypes.js';
|
|
4
|
+
export declare const redirectsPlugin: (pluginConfig: RedirectsPluginConfig) => (incomingConfig: Config) => Config;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
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,77 +1,97 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { redirectOptions } from './redirectTypes.js';
|
|
2
|
+
export { redirectOptions, redirectTypes } from './redirectTypes.js';
|
|
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
|
+
};
|
|
12
|
+
const defaultFields = [
|
|
13
|
+
{
|
|
14
|
+
name: 'from',
|
|
15
|
+
type: 'text',
|
|
16
|
+
index: true,
|
|
17
|
+
label: 'From URL',
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'to',
|
|
22
|
+
type: 'group',
|
|
23
|
+
fields: [
|
|
24
|
+
{
|
|
25
|
+
name: 'type',
|
|
26
|
+
type: 'radio',
|
|
27
|
+
admin: {
|
|
28
|
+
layout: 'horizontal'
|
|
29
|
+
},
|
|
30
|
+
defaultValue: 'reference',
|
|
31
|
+
label: 'To URL Type',
|
|
32
|
+
options: [
|
|
33
|
+
{
|
|
34
|
+
label: 'Internal link',
|
|
35
|
+
value: 'reference'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: 'Custom URL',
|
|
39
|
+
value: 'custom'
|
|
40
|
+
}
|
|
16
41
|
]
|
|
17
42
|
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
label: 'From URL',
|
|
24
|
-
required: true
|
|
43
|
+
{
|
|
44
|
+
name: 'reference',
|
|
45
|
+
type: 'relationship',
|
|
46
|
+
admin: {
|
|
47
|
+
condition: (_, siblingData)=>siblingData?.type === 'reference'
|
|
25
48
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
]
|
|
72
|
-
}, pluginConfig?.overrides || {})
|
|
49
|
+
label: 'Document to redirect to',
|
|
50
|
+
relationTo: pluginConfig?.collections || [],
|
|
51
|
+
required: true
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'url',
|
|
55
|
+
type: 'text',
|
|
56
|
+
admin: {
|
|
57
|
+
condition: (_, siblingData)=>siblingData?.type === 'custom'
|
|
58
|
+
},
|
|
59
|
+
label: 'Custom URL',
|
|
60
|
+
required: true
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
label: false
|
|
64
|
+
},
|
|
65
|
+
...pluginConfig?.redirectTypes ? [
|
|
66
|
+
redirectSelectField
|
|
67
|
+
] : []
|
|
68
|
+
];
|
|
69
|
+
const redirectsCollection = {
|
|
70
|
+
...pluginConfig?.overrides || {},
|
|
71
|
+
slug: pluginConfig?.overrides?.slug || 'redirects',
|
|
72
|
+
access: {
|
|
73
|
+
read: ()=>true,
|
|
74
|
+
...pluginConfig?.overrides?.access || {}
|
|
75
|
+
},
|
|
76
|
+
admin: {
|
|
77
|
+
defaultColumns: [
|
|
78
|
+
'from',
|
|
79
|
+
'to.type',
|
|
80
|
+
'createdAt'
|
|
81
|
+
],
|
|
82
|
+
...pluginConfig?.overrides?.admin || {}
|
|
83
|
+
},
|
|
84
|
+
fields: pluginConfig?.overrides?.fields && typeof pluginConfig?.overrides?.fields === 'function' ? pluginConfig?.overrides.fields({
|
|
85
|
+
defaultFields
|
|
86
|
+
}) : defaultFields
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
...incomingConfig,
|
|
90
|
+
collections: [
|
|
91
|
+
...incomingConfig?.collections || [],
|
|
92
|
+
redirectsCollection
|
|
73
93
|
]
|
|
74
|
-
}
|
|
75
|
-
|
|
94
|
+
};
|
|
95
|
+
};
|
|
76
96
|
|
|
77
97
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from 'payload
|
|
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 || {}) as SelectField),\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,GAAKX,cAAcY,6BAA6B,CAAC,CAAC;QACpD;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 @@
|
|
|
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,6 +1,14 @@
|
|
|
1
|
-
import type { CollectionConfig } from 'payload
|
|
2
|
-
|
|
1
|
+
import type { CollectionConfig, Field, SelectField } from 'payload';
|
|
2
|
+
import type { redirectTypes } from './redirectTypes.js';
|
|
3
|
+
export type FieldsOverride = (args: {
|
|
4
|
+
defaultFields: Field[];
|
|
5
|
+
}) => Field[];
|
|
6
|
+
export type RedirectsPluginConfig = {
|
|
3
7
|
collections?: string[];
|
|
4
|
-
overrides?:
|
|
5
|
-
|
|
8
|
+
overrides?: {
|
|
9
|
+
fields?: FieldsOverride;
|
|
10
|
+
} & Partial<Omit<CollectionConfig, 'fields'>>;
|
|
11
|
+
redirectTypeFieldOverride?: Partial<SelectField>;
|
|
12
|
+
redirectTypes?: (typeof redirectTypes)[number][];
|
|
13
|
+
};
|
|
6
14
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,
|
|
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 } from 'payload
|
|
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,16 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-redirects",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
4
|
-
"homepage:": "https://payloadcms.com",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "https://github.com/payloadcms/payload.git",
|
|
8
|
-
"directory": "packages/plugin-redirects"
|
|
9
|
-
},
|
|
3
|
+
"version": "3.0.0-beta.110",
|
|
10
4
|
"description": "Redirects plugin for Payload",
|
|
11
|
-
"main": "./dist/index.js",
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"type": "module",
|
|
14
5
|
"keywords": [
|
|
15
6
|
"payload",
|
|
16
7
|
"cms",
|
|
@@ -20,35 +11,55 @@
|
|
|
20
11
|
"redirects",
|
|
21
12
|
"nextjs"
|
|
22
13
|
],
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@types/express": "^4.17.9",
|
|
30
|
-
"@types/react": "18.2.74",
|
|
31
|
-
"react": "^18.0.0",
|
|
32
|
-
"payload": "3.0.0-beta.11",
|
|
33
|
-
"@payloadcms/eslint-config": "1.1.1"
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/payloadcms/payload.git",
|
|
17
|
+
"directory": "packages/plugin-redirects"
|
|
34
18
|
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
|
21
|
+
"type": "module",
|
|
35
22
|
"exports": {
|
|
36
23
|
".": {
|
|
37
24
|
"import": "./dist/index.js",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./types": {
|
|
29
|
+
"import": "./dist/exports/types.js",
|
|
30
|
+
"types": "./dist/exports/types.d.ts",
|
|
31
|
+
"default": "./dist/exports/types.js"
|
|
40
32
|
}
|
|
41
33
|
},
|
|
34
|
+
"main": "./dist/index.js",
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
42
36
|
"files": [
|
|
43
37
|
"dist",
|
|
44
38
|
"types.js",
|
|
45
39
|
"types.d.ts"
|
|
46
40
|
],
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/express": "^4.17.9",
|
|
43
|
+
"@types/react": "npm:types-react@19.0.0-rc.1",
|
|
44
|
+
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
|
|
45
|
+
"@payloadcms/eslint-config": "3.0.0-beta.97",
|
|
46
|
+
"payload": "3.0.0-beta.110"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"payload": "3.0.0-beta.110"
|
|
50
|
+
},
|
|
51
|
+
"homepage:": "https://payloadcms.com",
|
|
52
|
+
"overrides": {
|
|
53
|
+
"@types/react": "npm:types-react@19.0.0-rc.1",
|
|
54
|
+
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1"
|
|
55
|
+
},
|
|
47
56
|
"scripts": {
|
|
48
|
-
"build": "pnpm copyfiles && pnpm build:
|
|
49
|
-
"build:swc": "swc ./src -d ./dist --config-file .swcrc",
|
|
57
|
+
"build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
|
|
58
|
+
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
50
59
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
51
60
|
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
52
|
-
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/"
|
|
61
|
+
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
62
|
+
"lint": "eslint .",
|
|
63
|
+
"lint:fix": "eslint . --fix"
|
|
53
64
|
}
|
|
54
65
|
}
|
package/dist/deepMerge.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple object check.
|
|
3
|
-
* @param item
|
|
4
|
-
* @returns {boolean}
|
|
5
|
-
*/
|
|
6
|
-
export declare function isObject(item: unknown): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* Deep merge two objects.
|
|
9
|
-
* @param target
|
|
10
|
-
* @param ...sources
|
|
11
|
-
*/
|
|
12
|
-
export default function deepMerge<T, R>(target: T, source: R): T;
|
|
13
|
-
//# sourceMappingURL=deepMerge.d.ts.map
|
package/dist/deepMerge.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deepMerge.d.ts","sourceRoot":"","sources":["../src/deepMerge.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAE/C;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAiB/D"}
|
package/dist/deepMerge.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
/**
|
|
3
|
-
* Simple object check.
|
|
4
|
-
* @param item
|
|
5
|
-
* @returns {boolean}
|
|
6
|
-
*/ export function isObject(item) {
|
|
7
|
-
return item && typeof item === 'object' && !Array.isArray(item);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Deep merge two objects.
|
|
11
|
-
* @param target
|
|
12
|
-
* @param ...sources
|
|
13
|
-
*/ export default function deepMerge(target, source) {
|
|
14
|
-
const output = {
|
|
15
|
-
...target
|
|
16
|
-
};
|
|
17
|
-
if (isObject(target) && isObject(source)) {
|
|
18
|
-
Object.keys(source).forEach((key)=>{
|
|
19
|
-
if (isObject(source[key])) {
|
|
20
|
-
if (!(key in target)) {
|
|
21
|
-
Object.assign(output, {
|
|
22
|
-
[key]: source[key]
|
|
23
|
-
});
|
|
24
|
-
} else {
|
|
25
|
-
output[key] = deepMerge(target[key], source[key]);
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
Object.assign(output, {
|
|
29
|
-
[key]: source[key]
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return output;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
//# sourceMappingURL=deepMerge.js.map
|
package/dist/deepMerge.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deepMerge.ts"],"sourcesContent":["// @ts-nocheck\n\n/**\n * Simple object check.\n * @param item\n * @returns {boolean}\n */\nexport function isObject(item: unknown): boolean {\n return item && typeof item === 'object' && !Array.isArray(item)\n}\n\n/**\n * Deep merge two objects.\n * @param target\n * @param ...sources\n */\nexport default function deepMerge<T, R>(target: T, source: R): T {\n const output = { ...target }\n if (isObject(target) && isObject(source)) {\n Object.keys(source).forEach((key) => {\n if (isObject(source[key])) {\n if (!(key in target)) {\n Object.assign(output, { [key]: source[key] })\n } else {\n output[key] = deepMerge(target[key], source[key])\n }\n } else {\n Object.assign(output, { [key]: source[key] })\n }\n })\n }\n\n return output\n}\n"],"names":["isObject","item","Array","isArray","deepMerge","target","source","output","Object","keys","forEach","key","assign"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,cAAc;AAEd;;;;CAIC,GACD,OAAO,SAASA,SAASC,IAAa;IACpC,OAAOA,QAAQ,OAAOA,SAAS,YAAY,CAACC,MAAMC,OAAO,CAACF;AAC5D;AAEA;;;;CAIC,GACD,eAAe,SAASG,UAAgBC,MAAS,EAAEC,MAAS;IAC1D,MAAMC,SAAS;QAAE,GAAGF,MAAM;IAAC;IAC3B,IAAIL,SAASK,WAAWL,SAASM,SAAS;QACxCE,OAAOC,IAAI,CAACH,QAAQI,OAAO,CAAC,CAACC;YAC3B,IAAIX,SAASM,MAAM,CAACK,IAAI,GAAG;gBACzB,IAAI,CAAEA,CAAAA,OAAON,MAAK,GAAI;oBACpBG,OAAOI,MAAM,CAACL,QAAQ;wBAAE,CAACI,IAAI,EAAEL,MAAM,CAACK,IAAI;oBAAC;gBAC7C,OAAO;oBACLJ,MAAM,CAACI,IAAI,GAAGP,UAAUC,MAAM,CAACM,IAAI,EAAEL,MAAM,CAACK,IAAI;gBAClD;YACF,OAAO;gBACLH,OAAOI,MAAM,CAACL,QAAQ;oBAAE,CAACI,IAAI,EAAEL,MAAM,CAACK,IAAI;gBAAC;YAC7C;QACF;IACF;IAEA,OAAOJ;AACT"}
|
package/src/index.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { Config } from 'payload/config'
|
|
2
|
-
|
|
3
|
-
import type { PluginConfig } from './types.js'
|
|
4
|
-
|
|
5
|
-
import deepMerge from './deepMerge.js'
|
|
6
|
-
|
|
7
|
-
const redirects =
|
|
8
|
-
(pluginConfig: PluginConfig) =>
|
|
9
|
-
(incomingConfig: Config): Config => ({
|
|
10
|
-
...incomingConfig,
|
|
11
|
-
collections: [
|
|
12
|
-
...(incomingConfig?.collections || []),
|
|
13
|
-
deepMerge(
|
|
14
|
-
{
|
|
15
|
-
slug: 'redirects',
|
|
16
|
-
access: {
|
|
17
|
-
read: (): boolean => true,
|
|
18
|
-
},
|
|
19
|
-
admin: {
|
|
20
|
-
defaultColumns: ['from', 'to.type', 'createdAt'],
|
|
21
|
-
},
|
|
22
|
-
fields: [
|
|
23
|
-
{
|
|
24
|
-
name: 'from',
|
|
25
|
-
type: 'text',
|
|
26
|
-
index: true,
|
|
27
|
-
label: 'From URL',
|
|
28
|
-
required: true,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: 'to',
|
|
32
|
-
type: 'group',
|
|
33
|
-
fields: [
|
|
34
|
-
{
|
|
35
|
-
name: 'type',
|
|
36
|
-
type: 'radio',
|
|
37
|
-
admin: {
|
|
38
|
-
layout: 'horizontal',
|
|
39
|
-
},
|
|
40
|
-
defaultValue: 'reference',
|
|
41
|
-
label: 'To URL Type',
|
|
42
|
-
options: [
|
|
43
|
-
{
|
|
44
|
-
label: 'Internal link',
|
|
45
|
-
value: 'reference',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
label: 'Custom URL',
|
|
49
|
-
value: 'custom',
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: 'reference',
|
|
55
|
-
type: 'relationship',
|
|
56
|
-
admin: {
|
|
57
|
-
condition: (_, siblingData) => siblingData?.type === 'reference',
|
|
58
|
-
},
|
|
59
|
-
label: 'Document to redirect to',
|
|
60
|
-
relationTo: pluginConfig?.collections || [],
|
|
61
|
-
required: true,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'url',
|
|
65
|
-
type: 'text',
|
|
66
|
-
admin: {
|
|
67
|
-
condition: (_, siblingData) => siblingData?.type === 'custom',
|
|
68
|
-
},
|
|
69
|
-
label: 'Custom URL',
|
|
70
|
-
required: true,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
label: false,
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
},
|
|
77
|
-
pluginConfig?.overrides || {},
|
|
78
|
-
),
|
|
79
|
-
],
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
export { redirects }
|