@payloadcms/typescript-plugin 3.78.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.
- package/LICENSE.md +22 -0
- package/dist/__tests__/fixtures/components/MyField.d.ts +3 -0
- package/dist/__tests__/fixtures/components/MyField.d.ts.map +1 -0
- package/dist/__tests__/fixtures/components/MyField.js +22 -0
- package/dist/__tests__/fixtures/components/MyField.js.map +1 -0
- package/dist/__tests__/fixtures/components/icons/Icon/index.d.ts +3 -0
- package/dist/__tests__/fixtures/components/icons/Icon/index.d.ts.map +1 -0
- package/dist/__tests__/fixtures/components/icons/Icon/index.js +22 -0
- package/dist/__tests__/fixtures/components/icons/Icon/index.js.map +1 -0
- package/dist/__tests__/fixtures/components/views/CustomView/index.d.ts +3 -0
- package/dist/__tests__/fixtures/components/views/CustomView/index.d.ts.map +1 -0
- package/dist/__tests__/fixtures/components/views/CustomView/index.js +22 -0
- package/dist/__tests__/fixtures/components/views/CustomView/index.js.map +1 -0
- package/dist/__tests__/fixtures/payload-types.d.js +3 -0
- package/dist/__tests__/fixtures/payload-types.d.js.map +1 -0
- package/dist/__tests__/fixtures/payload.config.d.ts +3 -0
- package/dist/__tests__/fixtures/payload.config.d.ts.map +1 -0
- package/dist/__tests__/fixtures/payload.config.js +13 -0
- package/dist/__tests__/fixtures/payload.config.js.map +1 -0
- package/dist/__tests__/fixtures/src/components/NavIcon.d.ts +3 -0
- package/dist/__tests__/fixtures/src/components/NavIcon.d.ts.map +1 -0
- package/dist/__tests__/fixtures/src/components/NavIcon.js +22 -0
- package/dist/__tests__/fixtures/src/components/NavIcon.js.map +1 -0
- package/dist/__tests__/fixtures/src/components/ui/Badge.d.ts +4 -0
- package/dist/__tests__/fixtures/src/components/ui/Badge.d.ts.map +1 -0
- package/dist/__tests__/fixtures/src/components/ui/Badge.js +26 -0
- package/dist/__tests__/fixtures/src/components/ui/Badge.js.map +1 -0
- package/dist/__tests__/fixtures/test-config.d.ts +2 -0
- package/dist/__tests__/fixtures/test-config.d.ts.map +1 -0
- package/dist/__tests__/fixtures/test-config.js +146 -0
- package/dist/__tests__/fixtures/test-config.js.map +1 -0
- package/dist/__tests__/fixtures/test-paths.d.ts +2 -0
- package/dist/__tests__/fixtures/test-paths.d.ts.map +1 -0
- package/dist/__tests__/fixtures/test-paths.js +115 -0
- package/dist/__tests__/fixtures/test-paths.js.map +1 -0
- package/dist/helpers.d.ts +26 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +118 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +474 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-2025 Payload CMS, Inc. <info@payloadcms.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MyField.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/fixtures/components/MyField.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,YAAa,CAAA;AACjC,eAAO,MAAM,OAAO,YAAa,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get MyField () {
|
|
13
|
+
return MyField;
|
|
14
|
+
},
|
|
15
|
+
get MyLabel () {
|
|
16
|
+
return MyLabel;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const MyField = ()=>null;
|
|
20
|
+
const MyLabel = ()=>null;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=MyField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/__tests__/fixtures/components/MyField.tsx"],"sourcesContent":["export const MyField = () => null\nexport const MyLabel = () => null\n"],"names":["MyField","MyLabel"],"mappings":";;;;;;;;;;;QAAaA;eAAAA;;QACAC;eAAAA;;;AADN,MAAMD,UAAU,IAAM;AACtB,MAAMC,UAAU,IAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/__tests__/fixtures/components/icons/Icon/index.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,YAAa,CAAA;AAC9B,eAAO,MAAM,SAAS,YAAa,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get Icon () {
|
|
13
|
+
return Icon;
|
|
14
|
+
},
|
|
15
|
+
get IconSmall () {
|
|
16
|
+
return IconSmall;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const Icon = ()=>null;
|
|
20
|
+
const IconSmall = ()=>null;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/__tests__/fixtures/components/icons/Icon/index.tsx"],"sourcesContent":["export const Icon = () => null\nexport const IconSmall = () => null\n"],"names":["Icon","IconSmall"],"mappings":";;;;;;;;;;;QAAaA;eAAAA;;QACAC;eAAAA;;;AADN,MAAMD,OAAO,IAAM;AACnB,MAAMC,YAAY,IAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/__tests__/fixtures/components/views/CustomView/index.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,YAAa,CAAA;AACpC,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get CustomView () {
|
|
13
|
+
return CustomView;
|
|
14
|
+
},
|
|
15
|
+
get default () {
|
|
16
|
+
return _default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const CustomView = ()=>null;
|
|
20
|
+
const _default = CustomView;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/__tests__/fixtures/components/views/CustomView/index.tsx"],"sourcesContent":["export const CustomView = () => null\nexport default CustomView\n"],"names":["CustomView"],"mappings":";;;;;;;;;;;QAAaA;eAAAA;;QACb;eAAA;;;AADO,MAAMA,aAAa,IAAM;MAChC,WAAeA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/fixtures/payload-types.d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payload.config.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/payload.config.ts"],"names":[],"mappings":";AAAA,wBAAiB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _default = {};
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=payload.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/fixtures/payload.config.ts"],"sourcesContent":["export default {}\n"],"names":[],"mappings":";;;;+BAAA;;;eAAA;;;MAAA,WAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavIcon.d.ts","sourceRoot":"","sources":["../../../../../src/__tests__/fixtures/src/components/NavIcon.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,YAAa,CAAA;AACjC,eAAO,MAAM,YAAY,YAAa,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get NavIcon () {
|
|
13
|
+
return NavIcon;
|
|
14
|
+
},
|
|
15
|
+
get NavIconSmall () {
|
|
16
|
+
return NavIconSmall;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const NavIcon = ()=>null;
|
|
20
|
+
const NavIconSmall = ()=>null;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=NavIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/__tests__/fixtures/src/components/NavIcon.tsx"],"sourcesContent":["export const NavIcon = () => null\nexport const NavIconSmall = () => null\n"],"names":["NavIcon","NavIconSmall"],"mappings":";;;;;;;;;;;QAAaA;eAAAA;;QACAC;eAAAA;;;AADN,MAAMD,UAAU,IAAM;AACtB,MAAMC,eAAe,IAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../../../src/__tests__/fixtures/src/components/ui/Badge.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,YAAa,CAAA;AAC/B,eAAO,MAAM,SAAS,YAAa,CAAA;AACnC,eAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get Badge () {
|
|
13
|
+
return Badge;
|
|
14
|
+
},
|
|
15
|
+
get BadgeIcon () {
|
|
16
|
+
return BadgeIcon;
|
|
17
|
+
},
|
|
18
|
+
get default () {
|
|
19
|
+
return _default;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const Badge = ()=>null;
|
|
23
|
+
const BadgeIcon = ()=>null;
|
|
24
|
+
const _default = Badge;
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=Badge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/__tests__/fixtures/src/components/ui/Badge.tsx"],"sourcesContent":["export const Badge = () => null\nexport const BadgeIcon = () => null\nexport default Badge\n"],"names":["Badge","BadgeIcon"],"mappings":";;;;;;;;;;;QAAaA;eAAAA;;QACAC;eAAAA;;QACb;eAAA;;;AAFO,MAAMD,QAAQ,IAAM;AACpB,MAAMC,YAAY,IAAM;MAC/B,WAAeD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-config.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/test-config.ts"],"names":[],"mappings":"AACA,OAAO,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// @ts-ignore - ambient type declarations
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
require("./payload-types.d.ts");
|
|
7
|
+
const validField = {
|
|
8
|
+
name: 'test',
|
|
9
|
+
type: 'text',
|
|
10
|
+
admin: {
|
|
11
|
+
components: {
|
|
12
|
+
Field: '/components/MyField.tsx#MyField',
|
|
13
|
+
Label: '/components/MyField.tsx#MyLabel'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const invalidPath = {
|
|
18
|
+
name: 'broken',
|
|
19
|
+
type: 'text',
|
|
20
|
+
admin: {
|
|
21
|
+
components: {
|
|
22
|
+
Field: '/components/DoesNotExist.tsx#Nope'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const invalidExport = {
|
|
27
|
+
name: 'wrongExport',
|
|
28
|
+
type: 'text',
|
|
29
|
+
admin: {
|
|
30
|
+
components: {
|
|
31
|
+
Field: '/components/MyField.tsx#WrongExport'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const defaultExport = {
|
|
36
|
+
name: 'defaultExport',
|
|
37
|
+
type: 'text',
|
|
38
|
+
admin: {
|
|
39
|
+
components: {
|
|
40
|
+
Field: '/components/views/CustomView/index.tsx'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const objectForm = {
|
|
45
|
+
name: 'objectForm',
|
|
46
|
+
type: 'text',
|
|
47
|
+
admin: {
|
|
48
|
+
components: {
|
|
49
|
+
Field: {
|
|
50
|
+
exportName: 'MyField',
|
|
51
|
+
path: '/components/MyField.tsx'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const objectFormInvalidExport = {
|
|
57
|
+
name: 'objectFormBad',
|
|
58
|
+
type: 'text',
|
|
59
|
+
admin: {
|
|
60
|
+
components: {
|
|
61
|
+
Field: {
|
|
62
|
+
exportName: 'DoesNotExist',
|
|
63
|
+
path: '/components/MyField.tsx'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const objectFormWithHash = {
|
|
69
|
+
name: 'objectFormHash',
|
|
70
|
+
type: 'text',
|
|
71
|
+
admin: {
|
|
72
|
+
components: {
|
|
73
|
+
Field: {
|
|
74
|
+
path: '/components/MyField.tsx#MyField'
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const objectFormDirIndex = {
|
|
80
|
+
name: 'objectFormDirIndex',
|
|
81
|
+
type: 'text',
|
|
82
|
+
admin: {
|
|
83
|
+
components: {
|
|
84
|
+
Field: {
|
|
85
|
+
path: '/components/views/CustomView#CustomView'
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const noDefaultExport = {
|
|
91
|
+
name: 'noDefault',
|
|
92
|
+
type: 'text',
|
|
93
|
+
admin: {
|
|
94
|
+
components: {
|
|
95
|
+
Field: '/components/icons/Icon'
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const noDefaultExportObjectForm = {
|
|
100
|
+
name: 'noDefaultObj',
|
|
101
|
+
type: 'text',
|
|
102
|
+
admin: {
|
|
103
|
+
components: {
|
|
104
|
+
Field: {
|
|
105
|
+
path: '/components/icons/Icon'
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const objectFormWithExportName = {
|
|
111
|
+
name: 'withExportName',
|
|
112
|
+
type: 'text',
|
|
113
|
+
admin: {
|
|
114
|
+
components: {
|
|
115
|
+
Field: {
|
|
116
|
+
exportName: 'Icon',
|
|
117
|
+
path: '/components/icons/Icon'
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const slashOnly = {
|
|
123
|
+
name: 'slashOnly',
|
|
124
|
+
type: 'text',
|
|
125
|
+
admin: {
|
|
126
|
+
components: {
|
|
127
|
+
Field: '/'
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const adminConfig = {
|
|
132
|
+
components: {
|
|
133
|
+
actions: [
|
|
134
|
+
'/components/MyField.tsx#MyField'
|
|
135
|
+
],
|
|
136
|
+
Nav: '/components/MyField.tsx#MyField',
|
|
137
|
+
views: {
|
|
138
|
+
custom: {
|
|
139
|
+
Component: '/components/views/CustomView/index.tsx#CustomView',
|
|
140
|
+
path: '/custom'
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=test-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/fixtures/test-config.ts"],"sourcesContent":["// @ts-ignore - ambient type declarations\nimport './payload-types.d.ts'\n\nconst validField: FieldConfig = {\n name: 'test',\n type: 'text',\n admin: {\n components: {\n Field: '/components/MyField.tsx#MyField',\n Label: '/components/MyField.tsx#MyLabel',\n },\n },\n}\n\nconst invalidPath: FieldConfig = {\n name: 'broken',\n type: 'text',\n admin: {\n components: {\n Field: '/components/DoesNotExist.tsx#Nope',\n },\n },\n}\n\nconst invalidExport: FieldConfig = {\n name: 'wrongExport',\n type: 'text',\n admin: {\n components: {\n Field: '/components/MyField.tsx#WrongExport',\n },\n },\n}\n\nconst defaultExport: FieldConfig = {\n name: 'defaultExport',\n type: 'text',\n admin: {\n components: {\n Field: '/components/views/CustomView/index.tsx',\n },\n },\n}\n\nconst objectForm: FieldConfig = {\n name: 'objectForm',\n type: 'text',\n admin: {\n components: {\n Field: {\n exportName: 'MyField',\n path: '/components/MyField.tsx',\n },\n },\n },\n}\n\nconst objectFormInvalidExport: FieldConfig = {\n name: 'objectFormBad',\n type: 'text',\n admin: {\n components: {\n Field: {\n exportName: 'DoesNotExist',\n path: '/components/MyField.tsx',\n },\n },\n },\n}\n\nconst objectFormWithHash: FieldConfig = {\n name: 'objectFormHash',\n type: 'text',\n admin: {\n components: {\n Field: {\n path: '/components/MyField.tsx#MyField',\n },\n },\n },\n}\n\nconst objectFormDirIndex: FieldConfig = {\n name: 'objectFormDirIndex',\n type: 'text',\n admin: {\n components: {\n Field: {\n path: '/components/views/CustomView#CustomView',\n },\n },\n },\n}\n\nconst noDefaultExport: FieldConfig = {\n name: 'noDefault',\n type: 'text',\n admin: {\n components: {\n Field: '/components/icons/Icon',\n },\n },\n}\n\nconst noDefaultExportObjectForm: FieldConfig = {\n name: 'noDefaultObj',\n type: 'text',\n admin: {\n components: {\n Field: {\n path: '/components/icons/Icon',\n },\n },\n },\n}\n\nconst objectFormWithExportName: FieldConfig = {\n name: 'withExportName',\n type: 'text',\n admin: {\n components: {\n Field: {\n exportName: 'Icon',\n path: '/components/icons/Icon',\n },\n },\n },\n}\n\nconst slashOnly: FieldConfig = {\n name: 'slashOnly',\n type: 'text',\n admin: {\n components: {\n Field: '/',\n },\n },\n}\n\nconst adminConfig: AdminConfig = {\n components: {\n actions: ['/components/MyField.tsx#MyField'],\n Nav: '/components/MyField.tsx#MyField',\n views: {\n custom: {\n Component: '/components/views/CustomView/index.tsx#CustomView',\n path: '/custom',\n },\n },\n },\n}\n"],"names":["validField","name","type","admin","components","Field","Label","invalidPath","invalidExport","defaultExport","objectForm","exportName","path","objectFormInvalidExport","objectFormWithHash","objectFormDirIndex","noDefaultExport","noDefaultExportObjectForm","objectFormWithExportName","slashOnly","adminConfig","actions","Nav","views","custom","Component"],"mappings":"AAAA,yCAAyC;;;;;QAClC;AAEP,MAAMA,aAA0B;IAC9BC,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;YACPC,OAAO;QACT;IACF;AACF;AAEA,MAAMC,cAA2B;IAC/BN,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;AACF;AAEA,MAAMG,gBAA6B;IACjCP,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;AACF;AAEA,MAAMI,gBAA6B;IACjCR,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;AACF;AAEA,MAAMK,aAA0B;IAC9BT,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;gBACLM,YAAY;gBACZC,MAAM;YACR;QACF;IACF;AACF;AAEA,MAAMC,0BAAuC;IAC3CZ,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;gBACLM,YAAY;gBACZC,MAAM;YACR;QACF;IACF;AACF;AAEA,MAAME,qBAAkC;IACtCb,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;gBACLO,MAAM;YACR;QACF;IACF;AACF;AAEA,MAAMG,qBAAkC;IACtCd,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;gBACLO,MAAM;YACR;QACF;IACF;AACF;AAEA,MAAMI,kBAA+B;IACnCf,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;AACF;AAEA,MAAMY,4BAAyC;IAC7ChB,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;gBACLO,MAAM;YACR;QACF;IACF;AACF;AAEA,MAAMM,2BAAwC;IAC5CjB,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;gBACLM,YAAY;gBACZC,MAAM;YACR;QACF;IACF;AACF;AAEA,MAAMO,YAAyB;IAC7BlB,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;AACF;AAEA,MAAMe,cAA2B;IAC/BhB,YAAY;QACViB,SAAS;YAAC;SAAkC;QAC5CC,KAAK;QACLC,OAAO;YACLC,QAAQ;gBACNC,WAAW;gBACXb,MAAM;YACR;QACF;IACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-paths.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/test-paths.ts"],"names":[],"mappings":"AACA,OAAO,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// @ts-ignore - ambient type declarations
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
require("./payload-types.d.ts");
|
|
7
|
+
// --- Valid: @/ alias with named export ---
|
|
8
|
+
const aliasNamedExport = {
|
|
9
|
+
name: 'aliasNamed',
|
|
10
|
+
type: 'text',
|
|
11
|
+
admin: {
|
|
12
|
+
components: {
|
|
13
|
+
Field: '@/components/NavIcon#NavIcon'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
// --- Valid: @/ alias with second named export ---
|
|
18
|
+
const aliasSecondExport = {
|
|
19
|
+
name: 'aliasSecond',
|
|
20
|
+
type: 'text',
|
|
21
|
+
admin: {
|
|
22
|
+
components: {
|
|
23
|
+
Field: '@/components/NavIcon#NavIconSmall'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
// --- Valid: @/ alias to nested path with default export ---
|
|
28
|
+
const aliasDefaultExport = {
|
|
29
|
+
name: 'aliasDefault',
|
|
30
|
+
type: 'text',
|
|
31
|
+
admin: {
|
|
32
|
+
components: {
|
|
33
|
+
Field: '@/components/ui/Badge'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
// --- Valid: @/ alias in object form with exportName ---
|
|
38
|
+
const aliasObjectForm = {
|
|
39
|
+
name: 'aliasObj',
|
|
40
|
+
type: 'text',
|
|
41
|
+
admin: {
|
|
42
|
+
components: {
|
|
43
|
+
Field: {
|
|
44
|
+
exportName: 'Badge',
|
|
45
|
+
path: '@/components/ui/Badge'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
// --- Valid: @/ alias in object form with # in path ---
|
|
51
|
+
const aliasObjectHash = {
|
|
52
|
+
name: 'aliasObjHash',
|
|
53
|
+
type: 'text',
|
|
54
|
+
admin: {
|
|
55
|
+
components: {
|
|
56
|
+
Field: {
|
|
57
|
+
path: '@/components/NavIcon#NavIcon'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
// --- Invalid: @/ alias with wrong export ---
|
|
63
|
+
const aliasWrongExport = {
|
|
64
|
+
name: 'aliasWrongExport',
|
|
65
|
+
type: 'text',
|
|
66
|
+
admin: {
|
|
67
|
+
components: {
|
|
68
|
+
Field: '@/components/NavIcon#DoesNotExist'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
// --- Invalid: @/ alias to non-existent file ---
|
|
73
|
+
const aliasInvalidPath = {
|
|
74
|
+
name: 'aliasBadPath',
|
|
75
|
+
type: 'text',
|
|
76
|
+
admin: {
|
|
77
|
+
components: {
|
|
78
|
+
Field: '@/components/NotAFile#Nope'
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
// --- Invalid: @/ alias no default export ---
|
|
83
|
+
const aliasNoDefault = {
|
|
84
|
+
name: 'aliasNoDefault',
|
|
85
|
+
type: 'text',
|
|
86
|
+
admin: {
|
|
87
|
+
components: {
|
|
88
|
+
Field: '@/components/NavIcon'
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
// --- Invalid: @/ alias in object form with wrong exportName ---
|
|
93
|
+
const aliasObjectWrongExport = {
|
|
94
|
+
name: 'aliasObjWrong',
|
|
95
|
+
type: 'text',
|
|
96
|
+
admin: {
|
|
97
|
+
components: {
|
|
98
|
+
Field: {
|
|
99
|
+
exportName: 'Fake',
|
|
100
|
+
path: '@/components/ui/Badge'
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
// --- Valid: @/ alias in array context ---
|
|
106
|
+
const aliasInArray = {
|
|
107
|
+
components: {
|
|
108
|
+
actions: [
|
|
109
|
+
'@/components/NavIcon#NavIcon'
|
|
110
|
+
],
|
|
111
|
+
Nav: '@/components/ui/Badge#Badge'
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
//# sourceMappingURL=test-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/fixtures/test-paths.ts"],"sourcesContent":["// @ts-ignore - ambient type declarations\nimport './payload-types.d.ts'\n\n// --- Valid: @/ alias with named export ---\nconst aliasNamedExport: FieldConfig = {\n name: 'aliasNamed',\n type: 'text',\n admin: {\n components: {\n Field: '@/components/NavIcon#NavIcon',\n },\n },\n}\n\n// --- Valid: @/ alias with second named export ---\nconst aliasSecondExport: FieldConfig = {\n name: 'aliasSecond',\n type: 'text',\n admin: {\n components: {\n Field: '@/components/NavIcon#NavIconSmall',\n },\n },\n}\n\n// --- Valid: @/ alias to nested path with default export ---\nconst aliasDefaultExport: FieldConfig = {\n name: 'aliasDefault',\n type: 'text',\n admin: {\n components: {\n Field: '@/components/ui/Badge',\n },\n },\n}\n\n// --- Valid: @/ alias in object form with exportName ---\nconst aliasObjectForm: FieldConfig = {\n name: 'aliasObj',\n type: 'text',\n admin: {\n components: {\n Field: {\n exportName: 'Badge',\n path: '@/components/ui/Badge',\n },\n },\n },\n}\n\n// --- Valid: @/ alias in object form with # in path ---\nconst aliasObjectHash: FieldConfig = {\n name: 'aliasObjHash',\n type: 'text',\n admin: {\n components: {\n Field: {\n path: '@/components/NavIcon#NavIcon',\n },\n },\n },\n}\n\n// --- Invalid: @/ alias with wrong export ---\nconst aliasWrongExport: FieldConfig = {\n name: 'aliasWrongExport',\n type: 'text',\n admin: {\n components: {\n Field: '@/components/NavIcon#DoesNotExist',\n },\n },\n}\n\n// --- Invalid: @/ alias to non-existent file ---\nconst aliasInvalidPath: FieldConfig = {\n name: 'aliasBadPath',\n type: 'text',\n admin: {\n components: {\n Field: '@/components/NotAFile#Nope',\n },\n },\n}\n\n// --- Invalid: @/ alias no default export ---\nconst aliasNoDefault: FieldConfig = {\n name: 'aliasNoDefault',\n type: 'text',\n admin: {\n components: {\n Field: '@/components/NavIcon',\n },\n },\n}\n\n// --- Invalid: @/ alias in object form with wrong exportName ---\nconst aliasObjectWrongExport: FieldConfig = {\n name: 'aliasObjWrong',\n type: 'text',\n admin: {\n components: {\n Field: {\n exportName: 'Fake',\n path: '@/components/ui/Badge',\n },\n },\n },\n}\n\n// --- Valid: @/ alias in array context ---\nconst aliasInArray: AdminConfig = {\n components: {\n actions: ['@/components/NavIcon#NavIcon'],\n Nav: '@/components/ui/Badge#Badge',\n },\n}\n"],"names":["aliasNamedExport","name","type","admin","components","Field","aliasSecondExport","aliasDefaultExport","aliasObjectForm","exportName","path","aliasObjectHash","aliasWrongExport","aliasInvalidPath","aliasNoDefault","aliasObjectWrongExport","aliasInArray","actions","Nav"],"mappings":"AAAA,yCAAyC;;;;;QAClC;AAEP,4CAA4C;AAC5C,MAAMA,mBAAgC;IACpCC,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;AACF;AAEA,mDAAmD;AACnD,MAAMC,oBAAiC;IACrCL,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;AACF;AAEA,6DAA6D;AAC7D,MAAME,qBAAkC;IACtCN,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;AACF;AAEA,yDAAyD;AACzD,MAAMG,kBAA+B;IACnCP,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;gBACLI,YAAY;gBACZC,MAAM;YACR;QACF;IACF;AACF;AAEA,wDAAwD;AACxD,MAAMC,kBAA+B;IACnCV,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;gBACLK,MAAM;YACR;QACF;IACF;AACF;AAEA,8CAA8C;AAC9C,MAAME,mBAAgC;IACpCX,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;AACF;AAEA,iDAAiD;AACjD,MAAMQ,mBAAgC;IACpCZ,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;AACF;AAEA,8CAA8C;AAC9C,MAAMS,iBAA8B;IAClCb,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;QACT;IACF;AACF;AAEA,iEAAiE;AACjE,MAAMU,yBAAsC;IAC1Cd,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO;gBACLI,YAAY;gBACZC,MAAM;YACR;QACF;IACF;AACF;AAEA,2CAA2C;AAC3C,MAAMM,eAA4B;IAChCZ,YAAY;QACVa,SAAS;YAAC;SAA+B;QACzCC,KAAK;IACP;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type tslib from 'typescript/lib/tsserverlibrary';
|
|
2
|
+
export type PayloadComponentContext = {
|
|
3
|
+
exportNameValue?: string;
|
|
4
|
+
node: tslib.StringLiteral;
|
|
5
|
+
type: 'path';
|
|
6
|
+
} | {
|
|
7
|
+
node: tslib.StringLiteral;
|
|
8
|
+
pathValue?: string;
|
|
9
|
+
type: 'exportName';
|
|
10
|
+
} | {
|
|
11
|
+
node: tslib.StringLiteral;
|
|
12
|
+
type: 'string';
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Determines if a string literal is in a PayloadComponent context and what kind.
|
|
16
|
+
*
|
|
17
|
+
* - `'string'`: direct string form, e.g. `Field: '@/components/MyField#MyField'`
|
|
18
|
+
* - `'path'`: the `path` property in the object form, e.g. `{ path: '@/components/MyField' }`
|
|
19
|
+
* - `'exportName'`: the `exportName` property in the object form, e.g. `{ exportName: 'MyField' }`
|
|
20
|
+
*/
|
|
21
|
+
export declare function getPayloadComponentContext(ts: typeof tslib, node: tslib.StringLiteral, checker: tslib.TypeChecker): PayloadComponentContext | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the deepest token at a given position, reusing TypeScript's internal traversal.
|
|
24
|
+
*/
|
|
25
|
+
export declare function findNodeAtPosition(ts: typeof tslib, sourceFile: tslib.SourceFile, position: number): tslib.Node | undefined;
|
|
26
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gCAAgC,CAAA;AAEvD,MAAM,MAAM,uBAAuB,GAC/B;IAAE,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACrE;IAAE,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,CAAA;CAAE,GACrE;IAAE,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAA;AAEjD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,OAAO,KAAK,EAChB,IAAI,EAAE,KAAK,CAAC,aAAa,EACzB,OAAO,EAAE,KAAK,CAAC,WAAW,GACzB,uBAAuB,GAAG,SAAS,CA2BrC;AA+ED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,OAAO,KAAK,EAChB,UAAU,EAAE,KAAK,CAAC,UAAU,EAC5B,QAAQ,EAAE,MAAM,GACf,KAAK,CAAC,IAAI,GAAG,SAAS,CA0BxB"}
|