@payloadcms/plugin-redirects 0.0.1 → 1.0.1

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![NPM](https://img.shields.io/npm/v/@payloadcms/plugin-redirects)](https://www.npmjs.com/package/@payloadcms/plugin-redirects)
4
4
 
5
- A plugin for [Payload CMS](https://github.com/payloadcms/payload) to easily manage your redirects.
5
+ A plugin for [Payload](https://github.com/payloadcms/payload) to easily manage your redirects.
6
6
 
7
7
  Core features:
8
8
 
package/dist/deepMerge.js CHANGED
@@ -19,7 +19,7 @@ exports.isObject = void 0;
19
19
  * @returns {boolean}
20
20
  */
21
21
  function isObject(item) {
22
- return (item && typeof item === 'object' && !Array.isArray(item));
22
+ return item && typeof item === 'object' && !Array.isArray(item);
23
23
  }
24
24
  exports.isObject = isObject;
25
25
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"deepMerge.js","sourceRoot":"","sources":["../src/deepMerge.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;AAEd;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,IAAa;IACpC,OAAO,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AACpE,CAAC;AAFD,4BAEC;AAED;;;;GAIG;AACH,SAAwB,SAAS,CAAO,MAAS,EAAE,MAAS;IAC1D,IAAM,MAAM,gBAAQ,MAAM,CAAE,CAAC;IAC7B,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE;QACxC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAC,GAAG;;YAC9B,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;gBACzB,IAAI,CAAC,CAAC,GAAG,IAAI,MA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C,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;iBAClD;aACF;iBAAM;gBACL,MAAM,CAAC,MAAM,CAAC,MAAM,YAAI,GAAC,GAAG,IAAG,MAAM,CAAC,GAAG,CAAC,MAAG,CAAA;aAC9C;QACH,CAAC,CAAC,CAAA;KACH;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAjBD,4BAiBC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Config } from 'payload/config';
2
- import { PluginConfig } from './types';
1
+ import type { Config } from 'payload/config';
2
+ import type { PluginConfig } from './types';
3
3
  declare const redirects: (pluginConfig: PluginConfig) => (incomingConfig: Config) => Config;
4
4
  export default redirects;
package/dist/index.js CHANGED
@@ -24,74 +24,72 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  var deepMerge_1 = __importDefault(require("./deepMerge"));
27
- var redirects = function (pluginConfig) { return function (incomingConfig) { return (__assign(__assign({}, incomingConfig), { collections: __spreadArray(__spreadArray([], (incomingConfig === null || incomingConfig === void 0 ? void 0 : incomingConfig.collections) || [], true), [
28
- (0, deepMerge_1.default)({
29
- slug: 'redirects',
30
- admin: {
31
- defaultColumns: [
32
- 'from',
33
- 'to.type',
34
- 'createdAt',
35
- ],
36
- },
37
- access: {
38
- read: function () { return true; },
39
- },
40
- fields: [
41
- {
42
- name: 'from',
43
- label: 'From URL',
44
- index: true,
45
- required: true,
46
- type: 'text',
27
+ var redirects = function (pluginConfig) {
28
+ return function (incomingConfig) { return (__assign(__assign({}, incomingConfig), { collections: __spreadArray(__spreadArray([], ((incomingConfig === null || incomingConfig === void 0 ? void 0 : incomingConfig.collections) || []), true), [
29
+ (0, deepMerge_1.default)({
30
+ slug: 'redirects',
31
+ admin: {
32
+ defaultColumns: ['from', 'to.type', 'createdAt'],
47
33
  },
48
- {
49
- name: 'to',
50
- label: false,
51
- type: 'group',
52
- fields: [
53
- {
54
- name: 'type',
55
- label: 'To URL Type',
56
- type: 'radio',
57
- options: [
58
- {
59
- label: 'Internal link',
60
- value: 'reference',
61
- },
62
- {
63
- label: 'Custom URL',
64
- value: 'custom',
34
+ access: {
35
+ read: function () { return true; },
36
+ },
37
+ fields: [
38
+ {
39
+ name: 'from',
40
+ label: 'From URL',
41
+ index: true,
42
+ required: true,
43
+ type: 'text',
44
+ },
45
+ {
46
+ name: 'to',
47
+ label: false,
48
+ type: 'group',
49
+ fields: [
50
+ {
51
+ name: 'type',
52
+ label: 'To URL Type',
53
+ type: 'radio',
54
+ options: [
55
+ {
56
+ label: 'Internal link',
57
+ value: 'reference',
58
+ },
59
+ {
60
+ label: 'Custom URL',
61
+ value: 'custom',
62
+ },
63
+ ],
64
+ defaultValue: 'reference',
65
+ admin: {
66
+ layout: 'horizontal',
65
67
  },
66
- ],
67
- defaultValue: 'reference',
68
- admin: {
69
- layout: 'horizontal',
70
68
  },
71
- },
72
- {
73
- name: 'reference',
74
- label: 'Document to redirect to',
75
- type: 'relationship',
76
- relationTo: (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.collections) || [],
77
- required: true,
78
- admin: {
79
- condition: function (_, siblingData) { return (siblingData === null || siblingData === void 0 ? void 0 : siblingData.type) === 'reference'; },
69
+ {
70
+ name: 'reference',
71
+ label: 'Document to redirect to',
72
+ type: 'relationship',
73
+ relationTo: (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.collections) || [],
74
+ required: true,
75
+ admin: {
76
+ condition: function (_, siblingData) { return (siblingData === null || siblingData === void 0 ? void 0 : siblingData.type) === 'reference'; },
77
+ },
80
78
  },
81
- },
82
- {
83
- name: 'url',
84
- label: 'Custom URL',
85
- type: 'text',
86
- required: true,
87
- admin: {
88
- condition: function (_, siblingData) { return (siblingData === null || siblingData === void 0 ? void 0 : siblingData.type) === 'custom'; },
79
+ {
80
+ name: 'url',
81
+ label: 'Custom URL',
82
+ type: 'text',
83
+ required: true,
84
+ admin: {
85
+ condition: function (_, siblingData) { return (siblingData === null || siblingData === void 0 ? void 0 : siblingData.type) === 'custom'; },
86
+ },
89
87
  },
90
- },
91
- ],
92
- },
93
- ],
94
- }, (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.overrides) || {}),
95
- ], false) })); }; };
88
+ ],
89
+ },
90
+ ],
91
+ }, (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.overrides) || {}),
92
+ ], false) })); };
93
+ };
96
94
  exports.default = redirects;
97
95
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,0DAAoC;AAGpC,IAAM,SAAS,GAAG,UAAC,YAA0B,IAAK,OAAA,UAAC,cAAsB,IAAa,OAAA,uBACjF,cAAc,KACjB,WAAW,kCACN,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,WAAW,KAAI,EAAE;QACpC,IAAA,mBAAS,EAAC;YACR,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE;gBACL,cAAc,EAAE;oBACd,MAAM;oBACN,SAAS;oBACT,WAAW;iBACZ;aACF;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,cAAe,OAAA,IAAI,EAAJ,CAAI;aAC1B;YACD,MAAM,EAAE;gBACN;oBACE,IAAI,EAAE,MAAM;oBACZ,KAAK,EAAE,UAAU;oBACjB,KAAK,EAAE,IAAI;oBACX,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE,MAAM;iBACb;gBACD;oBACE,IAAI,EAAE,IAAI;oBACV,KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE,OAAO;oBACb,MAAM,EAAE;wBACN;4BACE,IAAI,EAAE,MAAM;4BACZ,KAAK,EAAE,aAAa;4BACpB,IAAI,EAAE,OAAO;4BACb,OAAO,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ACX,KAAK,EAAE,YAAY;gCACnB,IAAI,EAAE,MAAM;gCACZ,QAAQ,EAAE,IAAI;gCACd,KAAK,EAAE;oCACL,SAAS,EAAE,UAAC,CAAC,EAAE,WAAW,IAAK,OAAA,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,MAAK,QAAQ,EAA9B,CAA8B;iCAC9D;6BACF;yBACF;qBACF;iBACF;aACF,EACD,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,SAAS,KAAI,EAAE,CAC9B;qBAEH,EAvEkC,CAuElC;AAvEF,CAuEE,CAAA;AAEJ,kBAAe,SAAS,CAAA"}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { CollectionConfig } from "payload/types";
2
- export type PluginConfig = {
1
+ import type { CollectionConfig } from 'payload/types';
2
+ export interface PluginConfig {
3
3
  overrides?: Partial<CollectionConfig>;
4
4
  collections?: string[];
5
- };
5
+ }
package/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-redirects",
3
- "version": "0.0.1",
3
+ "version": "1.0.1",
4
4
  "homepage:": "https://payloadcms.com",
5
5
  "repository": "git@github.com:payloadcms/plugin-redirects.git",
6
- "description": "Redirects plugin for Payload CMS",
6
+ "description": "Redirects plugin for Payload",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
9
  "scripts": {
10
10
  "build": "tsc",
11
- "test": "echo \"Error: no test specified\" && exit 1"
11
+ "test": "echo \"Error: no test specified\" && exit 1",
12
+ "lint": "eslint src",
13
+ "lint:fix": "eslint --fix --ext .ts,.tsx src",
14
+ "clean": "rimraf dist",
15
+ "prepublishOnly": "yarn clean && yarn build"
12
16
  },
13
17
  "keywords": [
14
18
  "payload",
@@ -22,13 +26,32 @@
22
26
  "author": "dev@payloadcms.com",
23
27
  "license": "MIT",
24
28
  "peerDependencies": {
25
- "payload": "^0.18.5 || ^1.0.0",
26
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
29
+ "payload": "^0.18.5 || ^1.0.0 || ^2.0.0"
27
30
  },
28
31
  "devDependencies": {
29
- "payload": "^1.0.9",
32
+ "@payloadcms/eslint-config": "^0.0.1",
33
+ "@types/escape-html": "^1.0.1",
34
+ "@types/express": "^4.17.9",
35
+ "@types/node": "18.11.3",
36
+ "@types/react": "18.0.21",
37
+ "@typescript-eslint/eslint-plugin": "^5.51.0",
38
+ "@typescript-eslint/parser": "^5.51.0",
39
+ "copyfiles": "^2.4.1",
40
+ "cross-env": "^7.0.3",
41
+ "eslint": "^8.19.0",
42
+ "eslint-config-prettier": "^8.5.0",
43
+ "eslint-plugin-filenames": "^1.3.2",
44
+ "eslint-plugin-import": "2.25.4",
45
+ "eslint-plugin-prettier": "^4.0.0",
46
+ "eslint-plugin-react-hooks": "^4.6.0",
47
+ "eslint-plugin-simple-import-sort": "^10.0.0",
48
+ "nodemon": "^2.0.6",
49
+ "payload": "^1.8.2",
50
+ "prettier": "^2.7.1",
30
51
  "react": "^18.0.0",
31
- "typescript": "^4.5.5"
52
+ "rimraf": "^5.0.5",
53
+ "ts-node": "^9.1.1",
54
+ "typescript": "^4.8.4"
32
55
  },
33
56
  "files": [
34
57
  "dist",