@payloadcms/plugin-redirects 3.0.0-beta.7 → 3.0.0-canary.0ff7f07
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 +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -71
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +9 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +32 -23
- 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":[],"rangeMappings":"","mappings":"AAAA,WAAwD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Config } from 'payload
|
|
2
|
-
import type {
|
|
3
|
-
declare const
|
|
4
|
-
export { redirects };
|
|
1
|
+
import type { Config } from 'payload';
|
|
2
|
+
import type { RedirectsPluginConfig } from './types.js';
|
|
3
|
+
export declare const redirectsPlugin: (pluginConfig: RedirectsPluginConfig) => (incomingConfig: Config) => Config;
|
|
5
4
|
//# 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,EAAS,MAAM,SAAS,CAAA;AAE9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,eAAe,iBACX,qBAAqB,sBACnB,MAAM,KAAG,MA6EzB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,77 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
export const redirectsPlugin = (pluginConfig)=>(incomingConfig)=>{
|
|
2
|
+
const defaultFields = [
|
|
3
|
+
{
|
|
4
|
+
name: 'from',
|
|
5
|
+
type: 'text',
|
|
6
|
+
index: true,
|
|
7
|
+
label: 'From URL',
|
|
8
|
+
required: true
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
name: 'to',
|
|
12
|
+
type: 'group',
|
|
13
|
+
fields: [
|
|
14
|
+
{
|
|
15
|
+
name: 'type',
|
|
16
|
+
type: 'radio',
|
|
17
|
+
admin: {
|
|
18
|
+
layout: 'horizontal'
|
|
19
|
+
},
|
|
20
|
+
defaultValue: 'reference',
|
|
21
|
+
label: 'To URL Type',
|
|
22
|
+
options: [
|
|
23
|
+
{
|
|
24
|
+
label: 'Internal link',
|
|
25
|
+
value: 'reference'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: 'Custom URL',
|
|
29
|
+
value: 'custom'
|
|
30
|
+
}
|
|
16
31
|
]
|
|
17
32
|
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
label: 'From URL',
|
|
24
|
-
required: true
|
|
33
|
+
{
|
|
34
|
+
name: 'reference',
|
|
35
|
+
type: 'relationship',
|
|
36
|
+
admin: {
|
|
37
|
+
condition: (_, siblingData)=>siblingData?.type === 'reference'
|
|
25
38
|
},
|
|
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
|
-
label: false
|
|
70
|
-
}
|
|
71
|
-
]
|
|
72
|
-
}, pluginConfig?.overrides || {})
|
|
39
|
+
label: 'Document to redirect to',
|
|
40
|
+
relationTo: pluginConfig?.collections || [],
|
|
41
|
+
required: true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'url',
|
|
45
|
+
type: 'text',
|
|
46
|
+
admin: {
|
|
47
|
+
condition: (_, siblingData)=>siblingData?.type === 'custom'
|
|
48
|
+
},
|
|
49
|
+
label: 'Custom URL',
|
|
50
|
+
required: true
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
label: false
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
const redirectsCollection = {
|
|
57
|
+
...pluginConfig?.overrides || {},
|
|
58
|
+
slug: pluginConfig?.overrides?.slug || 'redirects',
|
|
59
|
+
access: {
|
|
60
|
+
read: ()=>true,
|
|
61
|
+
...pluginConfig?.overrides?.access || {}
|
|
62
|
+
},
|
|
63
|
+
admin: {
|
|
64
|
+
defaultColumns: [
|
|
65
|
+
'from',
|
|
66
|
+
'to.type',
|
|
67
|
+
'createdAt'
|
|
68
|
+
],
|
|
69
|
+
...pluginConfig?.overrides?.admin || {}
|
|
70
|
+
},
|
|
71
|
+
fields: pluginConfig?.overrides?.fields && typeof pluginConfig?.overrides?.fields === 'function' ? pluginConfig?.overrides.fields({
|
|
72
|
+
defaultFields
|
|
73
|
+
}) : defaultFields
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
...incomingConfig,
|
|
77
|
+
collections: [
|
|
78
|
+
...incomingConfig?.collections || [],
|
|
79
|
+
redirectsCollection
|
|
73
80
|
]
|
|
74
|
-
}
|
|
75
|
-
|
|
81
|
+
};
|
|
82
|
+
};
|
|
76
83
|
|
|
77
84
|
//# 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 } 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"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import type { CollectionConfig } from 'payload
|
|
2
|
-
export
|
|
1
|
+
import type { CollectionConfig, Field } from 'payload';
|
|
2
|
+
export type FieldsOverride = (args: {
|
|
3
|
+
defaultFields: Field[];
|
|
4
|
+
}) => Field[];
|
|
5
|
+
export type RedirectsPluginConfig = {
|
|
3
6
|
collections?: string[];
|
|
4
|
-
overrides?: Partial<CollectionConfig
|
|
5
|
-
|
|
7
|
+
overrides?: Partial<Omit<CollectionConfig, 'fields'>> & {
|
|
8
|
+
fields: FieldsOverride;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
6
11
|
//# 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,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"}
|
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 } 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":[],"rangeMappings":"","mappings":"AAIA,WAGC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-redirects",
|
|
3
|
-
"version": "3.0.0-
|
|
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-canary.0ff7f07",
|
|
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,33 +11,51 @@
|
|
|
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
|
-
"@payloadcms/eslint-config": "1.1.1",
|
|
33
|
-
"payload": "3.0.0-beta.7"
|
|
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
25
|
"require": "./dist/index.js",
|
|
39
26
|
"types": "./dist/index.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./*": {
|
|
29
|
+
"import": "./dist/exports/*.js",
|
|
30
|
+
"require": "./dist/exports/*.js",
|
|
31
|
+
"types": "./dist/exports/*.d.ts"
|
|
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-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.0ff7f07"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"payload": "3.0.0-canary.0ff7f07"
|
|
50
|
+
},
|
|
51
|
+
"homepage:": "https://payloadcms.com",
|
|
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"
|
|
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
61
|
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/"
|
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 }
|