Compare commits

..

610 Commits

Author SHA1 Message Date
James
b1a15f6e33 0.1.121 2020-12-27 15:22:52 -05:00
James
9037e6c64b 0.1.20 2020-12-27 15:22:02 -05:00
James
604922a26e feat: improves edit scroll UX in Account and Globals 2020-12-27 15:21:53 -05:00
James
0117f18eb1 fix: removes unnecessary meta defaults in admin config 2020-12-27 15:21:33 -05:00
James
a715a4206e feat: improves scrolling UX in Edit views 2020-12-27 15:16:14 -05:00
James
6e83edc988 fix: production webpack css 2020-12-27 15:15:46 -05:00
James
9f1ebaf850 0.1.19 2020-12-27 14:38:40 -05:00
James
8571dc3965 feat: flattens build into one command 2020-12-27 14:38:32 -05:00
James
5b8c721292 fix: copyfiles, autocomplete transition 2020-12-27 14:34:36 -05:00
James
e2248a066d 0.1.18 2020-12-27 14:03:41 -05:00
James
62dea6d52a exposes additional types 2020-12-27 14:03:29 -05:00
James
fe380bd943 0.1.17 2020-12-27 13:45:02 -05:00
James
b266ae1356 remedies ts error in me collection 2020-12-27 13:42:57 -05:00
James
4abcad67b7 0.1.16 2020-12-27 13:38:34 -05:00
James Mikrut
0243371c71 Merge pull request #469 from trouble/ts-final
Migrates to Typescript
2020-12-27 13:36:55 -05:00
James
15323a6b6d removes location state clear on route change 2020-12-27 13:31:39 -05:00
James
f5b9d32317 restricts ActionPanel to only show add button when max rows not met 2020-12-27 13:13:37 -05:00
James
71ed0ad0ca migrates object-to-formdata 2020-12-27 13:07:01 -05:00
James
b4fd2b1976 adds default value to block field schema validation 2020-12-27 13:06:53 -05:00
James
b6d2c95ee7 disables hover on read only DraggableSections 2020-12-27 13:06:34 -05:00
James
238232cf51 fixes hover states in read-only radio group 2020-12-27 12:38:05 -05:00
James
04cf39749b upgrades dependencies 2020-12-27 12:28:37 -05:00
James
c9616b01ac removes old code 2020-12-27 12:19:43 -05:00
James
dede06ad76 removes serverModules, removes publicENV and better structures webpack configs 2020-12-27 12:15:57 -05:00
James
843d65f494 removes PropTypes 2020-12-27 11:45:08 -05:00
James
58788c327f mobile improvements 2020-12-27 11:02:53 -05:00
James
0124ae8812 ensures returned documents from create / update do not include fallbacks 2020-12-26 21:13:07 -05:00
James
3d08222c29 resolves remaining type errors 2020-12-26 21:04:41 -05:00
James
f6c0251a6c types operations, GraphQL 2020-12-26 20:24:28 -05:00
James
cf32ee460c lays operation type pattern 2020-12-26 16:25:58 -05:00
James
569ce08174 further types to admin 2020-12-26 14:51:07 -05:00
James
e2d370a415 field typing changes due to useFieldType updates 2020-12-26 13:12:29 -05:00
James
152799ecc7 finishes admin field typing 2020-12-26 12:23:08 -05:00
James
087ac31533 removes _id from relationships 2020-12-24 12:24:58 -05:00
James
b184b26a4e types RichText 2020-12-24 12:15:00 -05:00
James
f86e90b072 revises Config type 2020-12-24 10:47:14 -05:00
James
be04310810 flattens dist folder 2020-12-24 10:28:41 -05:00
James
d510961f6c ensures relationship fields can be cleared 2020-12-24 09:57:41 -05:00
James
d29f6775a8 streamlines Select, ReactSelect, Relationship 2020-12-20 17:19:38 -05:00
James
7be836cced Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-12-20 15:17:36 -05:00
James
4528586849 typing progress, refactor Relationship 2020-12-20 15:17:33 -05:00
Elliot DeNolf
47e82cb069 lots of operation typing 2020-12-20 15:09:12 -05:00
Elliot DeNolf
d38c6f8118 buildSchema types and exclude tests from tsconfig 2020-12-20 11:42:36 -05:00
James
757c8647bf adds option type 2020-12-20 11:36:24 -05:00
James
ba6c1b9439 progress to field typing 2020-12-20 11:11:35 -05:00
James
ac92e1289b further typing 2020-12-20 09:13:25 -05:00
James
6a49bffa9a Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-12-18 07:56:52 -05:00
Elliot DeNolf
a95aada35a misc gql types 2020-12-12 22:50:43 -05:00
Elliot DeNolf
8fd430819b add more graphql schema typing 2020-12-09 11:02:37 -05:00
Elliot DeNolf
396760d523 More graphql typing 2020-12-09 09:35:08 -05:00
Elliot DeNolf
6ab15fce1c ci: use registry-url 2020-12-08 13:33:40 -05:00
Elliot DeNolf
81ca30c9d4 ci: try always-auth 2020-12-08 11:59:06 -05:00
Elliot DeNolf
a5085b6e56 ci: auth against npm 2020-12-08 11:52:36 -05:00
Elliot DeNolf
4cb8bbd2f4 type traverseFields and other misc 2020-12-08 11:36:00 -05:00
Elliot DeNolf
b9c597af92 add global request handler types 2020-12-03 15:00:40 -05:00
Elliot DeNolf
47b6bb683b docs(access): stub out access control configuration 2020-12-03 12:00:46 -05:00
Elliot DeNolf
d3df6c606c chore: add build:watch script 2020-12-03 11:50:39 -05:00
Elliot DeNolf
1cd578ef44 fix: handle access result gracefully 2020-12-03 11:50:08 -05:00
James
55dd4768b9 Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-12-03 10:32:32 -05:00
Elliot DeNolf
66946c8697 fix: undo property fix, field exists - bad typing 2020-12-02 21:50:54 -05:00
Elliot DeNolf
1e4e6e9619 more typing in src/fields 2020-12-02 21:36:40 -05:00
Elliot DeNolf
c97fb62228 fix basefield types 2020-12-02 17:03:20 -05:00
James
cd5a24e308 0.1.15 2020-12-02 16:33:43 -05:00
James
c17a03ef60 fixes schema validation for custom graphics 2020-12-02 16:33:38 -05:00
James
abfad8c088 0.1.14 2020-12-02 15:28:00 -05:00
James
82b4042b26 0.1.13 2020-12-02 15:24:26 -05:00
James
1129711f75 adds sort to local find operation 2020-12-02 15:24:14 -05:00
James
69582b2e8c 0.1.12 2020-12-02 10:35:47 -05:00
James
00821bf0a2 stubs dotenv for webpack 2020-12-02 10:35:38 -05:00
James
4a313ee7c3 Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-12-02 10:35:03 -05:00
Elliot DeNolf
85f3a8b038 test: ignore dist 2020-12-01 23:04:57 -05:00
Elliot DeNolf
5fe4cb9eee add missing operation typings 2020-12-01 23:04:31 -05:00
James
0e120093cf Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-12-01 17:35:13 -05:00
James
064ab8846d 0.1.11 2020-12-01 17:34:43 -05:00
James
1d5338a8dc fixes bugs with local payload 2020-12-01 17:34:38 -05:00
Elliot DeNolf
4ac08dac65 type some collection operations 2020-12-01 16:38:27 -05:00
James
41df1c447f 0.1.10 2020-12-01 16:17:52 -05:00
James
808a283f74 exports PayloadCollectionConfig type 2020-12-01 16:15:17 -05:00
Dan Ribbens
be69ff5849 Merge branch 'ts-final' of github.com:trouble/payload into ts-final 2020-12-01 11:47:24 -05:00
Dan Ribbens
9d94c509e7 bring back collection after error hook for restful calls 2020-12-01 11:47:07 -05:00
James
282f575cab further types to Elements 2020-12-01 10:48:08 -05:00
Dan Ribbens
6b61714d7e types for error handler 2020-12-01 09:46:57 -05:00
James
dc8ffa34e4 type progress to Elements 2020-12-01 08:04:31 -05:00
James
8c8c49c66d builds a type guard for determining if field has subfields 2020-12-01 08:04:25 -05:00
James
bb7c829c5e progress to typing Blocks and Arrays 2020-11-30 20:12:15 -05:00
James
6bf60ff5d6 Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-11-30 17:31:29 -05:00
James
100d1e7220 further types 2020-11-30 17:31:05 -05:00
Elliot DeNolf
c97732cef3 add some collection/graphql types 2020-11-30 15:11:38 -05:00
James
c398c8b2a2 further types 2020-11-30 14:41:53 -05:00
James
cee40169f3 renames tests to js 2020-11-30 14:36:08 -05:00
James
7d3b6d12e3 further types 2020-11-30 14:29:14 -05:00
James
98b62df792 further types 2020-11-30 14:16:55 -05:00
James
e2d9cd1eed Merge branch 'ts-final' of github.com:keen-studio/payload into admin-types 2020-11-30 11:40:15 -05:00
James
f873a84f08 begins form typing 2020-11-30 10:59:57 -05:00
Elliot DeNolf
c1b1b81774 add requesthandlers to bindings 2020-11-30 10:56:40 -05:00
Elliot DeNolf
7333cc25d8 fix CollectionConfig type, boolean unions will have been sanitized 2020-11-30 10:56:03 -05:00
Elliot DeNolf
32957833f3 add requestHandler types 2020-11-30 10:55:26 -05:00
James
20fabb81e8 further types 2020-11-30 08:47:58 -05:00
James
7644b031c1 further typing 2020-11-30 08:42:06 -05:00
James
dbc403319d instantiates auth forgot password 2020-11-29 20:46:10 -05:00
James
c1d025e241 better sanitization pattern 2020-11-29 20:38:10 -05:00
James
c3c3f3fc88 replaces sanitization 2020-11-29 20:08:06 -05:00
James
6f1d61aabc ensures loadConfig returns a full config 2020-11-29 17:55:45 -05:00
James
3d282d2523 revises payload.authenticate type 2020-11-29 17:52:17 -05:00
James
ba66a0e801 merge 2020-11-29 15:41:03 -05:00
James
0fcd3d8f28 further types 2020-11-29 15:40:11 -05:00
Dan Ribbens
ddda183090 merge ts-final 2020-11-29 15:39:54 -05:00
Dan Ribbens
f19fc9057d replace payloadconfig with config in places 2020-11-29 15:33:03 -05:00
James
17e4d78bdc further typing 2020-11-29 14:27:56 -05:00
James
9ef954f430 defines pattern for request handler types 2020-11-29 14:18:23 -05:00
James
767b68b0bd fixes tests 2020-11-29 12:41:13 -05:00
James
53d78e995b few type fixes 2020-11-29 11:42:34 -05:00
James
0119965287 fixes build script 2020-11-29 11:36:01 -05:00
James
45dc3cab11 sets defaults for auth and upload 2020-11-29 11:35:52 -05:00
James
73d27be947 fixes bug in RenderFields 2020-11-29 11:35:37 -05:00
James
a5bbb338b9 resets ts error truncation 2020-11-29 11:35:28 -05:00
James
fd7cd0324d validates field types 2020-11-28 17:34:32 -05:00
James
aa795d19d5 converts demo to ts 2020-11-28 16:07:54 -05:00
James
9019cc9101 merges and WIP - field types 2020-11-27 14:40:16 -05:00
James
cd64238a51 progress to joi validation 2020-11-27 13:05:22 -05:00
James
5ffa0ed6ee swaps out ajv for joi 2020-11-26 15:22:34 -05:00
Elliot DeNolf
1889f00f8f more field type adjustments 2020-11-26 11:44:14 -05:00
James
0e2fbe0e8f enables build w/ typescript, refines the way configs are found 2020-11-25 18:57:17 -05:00
Dan Ribbens
70a84d90ad cleanup in payload init 2020-11-25 17:36:51 -05:00
James
56072e952d 0.1.9 2020-11-25 15:14:18 -05:00
James
f88f482837 properly formats bin 2020-11-25 15:14:12 -05:00
James
ca55c4e55f 0.1.8 2020-11-25 15:11:07 -05:00
James
a00809db8e further types frontend 2020-11-25 15:10:59 -05:00
James
e930abe741 0.1.7 2020-11-25 13:43:05 -05:00
James
b584d22b3a adds bin executable 2020-11-25 13:43:01 -05:00
James
254524ab1b updates webpack 5 dependencies 2020-11-25 11:31:36 -05:00
James
472a6cb232 13639$ types 13639$ 2020-11-25 11:23:03 -05:00
James
ed8d7f2106 adds paths to local ts declarations 2020-11-25 10:50:35 -05:00
James
4239f8e592 Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-11-25 08:09:53 -05:00
James
55deb3f01b types hooks 2020-11-25 08:09:51 -05:00
Dan Ribbens
d09fba47f1 webpack config windows safe path names 2020-11-25 06:33:49 -05:00
James
2420969375 Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-11-24 21:04:29 -05:00
James
055ff455fe builds unlicensed route 2020-11-24 21:04:19 -05:00
James
f3be1fcc62 0.1.6 2020-11-24 20:05:37 -05:00
James
ec00edcdad merges admin-types and adds asset types 2020-11-24 20:05:29 -05:00
Elliot DeNolf
e36be704a5 add types for most of graphql 2020-11-24 20:03:41 -05:00
James
75e557b894 0.1.5 2020-11-24 19:40:30 -05:00
James
41a26289b3 0.1.4 2020-11-24 19:34:38 -05:00
James
c9cb1ea05c adds unlicensed view 2020-11-24 19:34:02 -05:00
James
b3f326fead 0.1.3 2020-11-24 18:38:37 -05:00
James
a1f4168d50 adds babel config to package 2020-11-24 18:38:31 -05:00
James
8d946f225e 0.1.2 2020-11-24 18:34:03 -05:00
James
26a01afa1a fixes access bug 2020-11-24 18:33:24 -05:00
James
35686a7dca adds more files to package 2020-11-24 18:33:03 -05:00
Jessica Boezwinkle
34942daf94 element typescript updates 2020-11-24 17:58:25 -05:00
James
0bdd159fb9 0.1.1 2020-11-24 14:03:50 -05:00
James
d6e7211539 0.1.0 2020-11-24 14:03:03 -05:00
James
713673bc42 bumps payload config provider 2020-11-24 14:02:56 -05:00
James
d75da16fef Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-11-24 12:53:11 -05:00
James
cfdacea210 changes access permissions structure to be more typescript-friendly 2020-11-24 12:53:09 -05:00
Elliot DeNolf
924eb1d0b5 fix(webpack): more require.resolves needed 2020-11-24 10:40:08 -05:00
Elliot DeNolf
6fcf4ebc48 add types for errors 2020-11-23 22:43:35 -05:00
Elliot DeNolf
badd59ac38 fix(webpack): use require.resolve for modules 2020-11-23 21:36:00 -05:00
Elliot DeNolf
5b6392009d add types for buildQuery 2020-11-23 20:56:36 -05:00
James
777a2292dc fixes bug in rate limit definitions 2020-11-23 20:36:41 -05:00
James
352f70a9e4 supports typescript configs 2020-11-23 20:36:28 -05:00
James
09f267c378 merges 2020-11-23 19:37:44 -05:00
James
c2d2702a59 - abstracts AuthProvider and ConfigProvider
- updates Webpack and React
- adds further typing
2020-11-23 19:29:11 -05:00
Elliot DeNolf
062771e0a7 type field validations 2020-11-23 19:25:05 -05:00
Jessica Boezwinkle
d2571fa798 elements to TS 2020-11-23 17:44:57 -05:00
Elliot DeNolf
eafc0876a1 type uploads and images 2020-11-23 13:55:39 -05:00
Jessica Boezwinkle
56ce92e012 Icons to TS 2020-11-23 13:32:12 -05:00
Elliot DeNolf
51958c25ac ci: use tsc-silent for pretest 2020-11-23 11:21:36 -05:00
Elliot DeNolf
8789dae155 fix: add missing webpack dep path-browserify 2020-11-23 10:32:09 -05:00
Elliot DeNolf
d10f3f140f add hook types 2020-11-23 10:23:04 -05:00
Elliot DeNolf
7670a23611 more types and intellisense comments 2020-11-22 18:29:27 -05:00
James
53811b2324 re-implements custom view in CustomComponents, types a few files 2020-11-22 13:41:44 -05:00
James
3344656e6a updates to webpack 5 2020-11-22 13:41:26 -05:00
Elliot DeNolf
e4eece0352 handle singular and plural slugs for auto-label 2020-11-22 08:24:42 -05:00
Dan Ribbens
2a4b821c34 merge ts-final 2020-11-22 01:35:16 -05:00
Dan Ribbens
4a4c4223e6 more typescript types 2020-11-22 01:30:38 -05:00
Elliot DeNolf
314ea43e6d revise field types and type buildSchema 2020-11-22 01:22:28 -05:00
Elliot DeNolf
fdbdf93250 add types for all field-types, and other type tweaks 2020-11-22 00:46:19 -05:00
Dan Ribbens
cb33417924 more typescript errors resolved 2020-11-22 00:01:47 -05:00
Dan Ribbens
cbf12524fe added types to basefields and collection sanitize 2020-11-21 23:07:26 -05:00
James
8b34cab19a Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-11-21 21:00:54 -05:00
James
05a99b5798 revises build script 2020-11-21 21:00:51 -05:00
Elliot DeNolf
f1a83de772 type out the majority of auth 2020-11-21 20:47:22 -05:00
Elliot DeNolf
eb3d299521 more typing 2020-11-21 20:46:02 -05:00
James
60afdd239c revises admin source maps 2020-11-21 20:38:27 -05:00
James
307840edd1 fixes webpack bugs 2020-11-21 20:12:45 -05:00
James
95b8df6d70 adds copyfiles 2020-11-21 18:52:15 -05:00
James
700f28c3ac adds copyfiles 2020-11-21 18:43:39 -05:00
James
1487c3ff16 updates main entrypoint, fixes bad path in /errrors 2020-11-21 18:35:33 -05:00
James
b94772bfcd begins typing admin, fixes editorconfig 2020-11-21 16:11:40 -05:00
James
44d79d2153 removes unused dependencies 2020-11-21 15:12:03 -05:00
James
09f3008569 passing tests 2020-11-21 14:56:49 -05:00
James
e5043e73e3 bumps secret to payload context 2020-11-21 14:34:38 -05:00
James
16d308f452 adds yarn build:tsc 2020-11-21 14:27:43 -05:00
James
3e9ad427ec enables typescript intellisense in buildConfig 2020-11-21 13:53:54 -05:00
James
16d0289c36 progress to buildConfig, splitting out type organization 2020-11-21 12:22:38 -05:00
James
894a400b86 client tests pass 2020-11-21 10:05:10 -05:00
James
9134b51985 merge 2020-11-21 10:03:18 -05:00
James
e00321a101 int tests pass 2020-11-21 10:02:46 -05:00
Elliot DeNolf
75d0b5bb50 add email typing and others 2020-11-21 06:28:07 -05:00
Elliot DeNolf
b774d09b4b type payload logger and format 2020-11-21 03:45:14 -05:00
Elliot DeNolf
a91451e946 chore(nodemon): watch ts files 2020-11-21 03:31:06 -05:00
Elliot DeNolf
983bf713b3 feat: add initial types 2020-11-21 03:30:47 -05:00
Elliot DeNolf
f0ac9d6935 fix conflicts 2020-11-21 02:11:20 -05:00
James
d2572ba4e4 everything works? 2020-11-20 17:12:39 -05:00
James
51307f29c5 fixes bugs with gql 2020-11-20 15:38:01 -05:00
Dan Ribbens
a608a799aa merge ts-final 2020-11-20 15:37:19 -05:00
Dan Ribbens
e7822f7a51 refactor ts graphql index 2020-11-20 15:36:04 -05:00
James
e3277cf120 Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-11-20 15:24:27 -05:00
James
2ffb2b5200 adds jest types 2020-11-20 15:24:14 -05:00
Dan Ribbens
18698a9f18 refactor graphql and utilities 2020-11-20 15:23:32 -05:00
James
95c96247d9 Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-11-20 15:15:26 -05:00
James
f2f65952b2 Merge branch 'ts-final' of github.com:keen-studio/payload into ts-final 2020-11-20 15:15:14 -05:00
Elliot DeNolf
afe5f16af0 convert some errors 2020-11-20 15:15:13 -05:00
James
6a7da1e603 converts auth and email 2020-11-20 15:15:10 -05:00
Elliot DeNolf
bc9adb9fe5 convert src/uploads 2020-11-20 15:10:11 -05:00
Elliot DeNolf
9e1153639e convert src/express and src/fields 2020-11-20 15:05:51 -05:00
Elliot DeNolf
59e5a73e49 convert src/collections 2020-11-20 14:54:47 -05:00
James
8d1856ae2d merges 2020-11-20 14:54:22 -05:00
James
1eeee4854a converts auth and email 2020-11-20 14:53:45 -05:00
Elliot DeNolf
3bea32883d more module conversion 2020-11-20 14:42:36 -05:00
Elliot DeNolf
4f2891836e fix conflicts 2020-11-20 14:42:05 -05:00
James
63e86c4147 further module conversion 2020-11-20 14:39:35 -05:00
James
dfc77f0a3f further module conversion 2020-11-20 14:34:32 -05:00
James
1aaed161eb converts modules 2020-11-20 14:29:49 -05:00
James
7d411622c6 progress to build 2020-11-20 14:21:48 -05:00
Elliot DeNolf
a106fa62fe reinstate all collections in config 2020-11-20 13:41:54 -05:00
Elliot DeNolf
551c249e39 refactor: migrate to typescript 2020-11-20 13:39:18 -05:00
Elliot DeNolf
38028dd36b fix conflicts 2020-11-20 12:02:31 -05:00
James
5b22d91579 0.0.141 2020-11-20 08:45:47 -05:00
James
09b9ce60ad Merge branch 'master' of github.com:keen-studio/payload 2020-11-20 08:45:34 -05:00
James
e20a07e06f 0.0.140 2020-11-20 08:45:10 -05:00
James
0204aa962c moves types into separate folder 2020-11-20 08:45:06 -05:00
Jarrod Flesch
d46051435f Merge branch 'master' of github.com:trouble/payload 2020-11-19 16:52:40 -05:00
Jarrod Flesch
0d56cf4496 properly passes overrideAccess through populationPromise when finding by ID 2020-11-19 16:52:33 -05:00
James
61dae53fc3 Merge branch 'master' of github.com:keen-studio/payload 2020-11-19 10:27:18 -05:00
James
f5377120c4 yarn 2020-11-19 10:27:15 -05:00
James
780106c7f6 declares type for sanitizeConfig 2020-11-19 10:27:09 -05:00
James
811e4bb265 avoids eslint on typescript files 2020-11-19 10:26:56 -05:00
James
111cab1564 runs editorconfig on ts files 2020-11-19 10:26:08 -05:00
Elliot DeNolf
131dd51c39 feat: use react-toastify for notifications 2020-11-19 10:00:48 -05:00
James
0d333ce7da exports Forbidden 2020-11-18 16:02:31 -05:00
James
fa7ad6e9ed adds locale back to admin 2020-11-17 21:25:33 -05:00
James
9b6dd0c771 Merge branch 'master' of github.com:keen-studio/payload 2020-11-17 21:00:27 -05:00
James
a7a0624235 removes requirement of field-level hooks to returrn value 2020-11-17 21:00:00 -05:00
James
8f08269916 better identifies field-level access control 2020-11-17 20:59:35 -05:00
Elliot DeNolf
dbd305acc5 feat: show email creds when explicitly set to 'mock' 2020-11-17 17:33:05 -05:00
Elliot DeNolf
83d32e4449 feat: validate admin user 2020-11-17 16:59:36 -05:00
James
78d7aa7707 0.0.139 2020-11-17 16:45:57 -05:00
Jacob Fletcher
a3ecd7324a - removes duplicative user lookup in login operation
- enables depth and access control in login operation
2020-11-17 16:41:15 -05:00
Jarrod Flesch
87525001f7 adds payload to the express router globally 2020-11-17 15:50:05 -05:00
Elliot DeNolf
f52836a7e3 fix: missed a file 2020-11-17 15:01:50 -05:00
Elliot DeNolf
fe536f0628 refactor: pull all base fields out of collection sanitize 2020-11-17 14:39:10 -05:00
James
1de5ac8cba 0.0.138 2020-11-17 11:27:33 -05:00
Elliot DeNolf
2624ad5f7e fix: properly concat verification and locking fields 2020-11-17 11:24:33 -05:00
Dan Ribbens
7fb23ab6be Merge pull request #451 from trouble/feature/timestamps-default-true
timestamps default to true for collections
2020-11-17 08:53:14 -05:00
Dan Ribbens
208e6fe47a timestamps default to true for collections 2020-11-17 08:51:05 -05:00
Elliot DeNolf
9a1c1f64c0 feat: add blind index for encrypting API Keys 2020-11-16 14:59:47 -05:00
Elliot DeNolf
65fe6c2f95 fix unnecessary reducing of locales 2020-11-15 20:19:41 -05:00
Elliot DeNolf
65ade57c94 /me return null if wrong user collection 2020-11-15 19:34:25 -05:00
Elliot DeNolf
2565005cc0 feat: add license key to access routej 2020-11-15 19:20:20 -05:00
Elliot DeNolf
de4538bf5f docs(hooks): add beforeOperation hook 2020-11-15 15:01:01 -05:00
James
2b80020393 Merge branch 'master' of github.com:keen-studio/payload 2020-11-14 16:40:51 -05:00
James
1166e85fad removes potentially unused code in hookPromise 2020-11-13 22:07:58 -05:00
James
e5193476c4 reorders removeInternalFields 2020-11-13 22:07:08 -05:00
James
5dbf276e82 adds beforeOperation hook, cleans operations 2020-11-13 13:54:10 -05:00
Elliot DeNolf
a6f3230915 docs(guides): blog API draft 2020-11-13 07:32:34 -05:00
Elliot DeNolf
0694a09abd fix: auth json schema didn't allow auth as boolean 2020-11-13 05:59:17 -05:00
Elliot DeNolf
dceeeaac6a fix: allow e-mail to be unconfigured, remove default fromName and fromAddress 2020-11-13 05:30:28 -05:00
James
bdc92bcdf0 Merge branch 'master' of github.com:keen-studio/payload 2020-11-12 16:43:47 -05:00
Elliot DeNolf
06a6056e1c docs(rest-api): first draft 2020-11-12 12:39:08 -05:00
James
4b951279a8 0.0.137 2020-11-12 11:36:31 -05:00
Jacob Fletcher
3984f8b36c exposes express json options in config 2020-11-12 11:35:34 -05:00
Elliot DeNolf
b9b3a0dcc7 docs(fields): add line highlighting, move common options to bottom 2020-11-11 20:32:01 -05:00
Elliot DeNolf
7caa025278 docs(fields): add common options 2020-11-11 15:39:21 -05:00
Elliot DeNolf
27e5dc4d55 docs(hooks): move Lifecycle section down 2020-11-11 15:38:50 -05:00
Elliot DeNolf
63fc9b76be docs(fields): first pass 2020-11-11 13:42:39 -05:00
James
5c1e2846a2 0.0.136 2020-11-10 16:30:04 -05:00
Jarrod Flesch
73c45944f4 adds res cookie options from collection config to logout route 2020-11-10 16:29:27 -05:00
Dan Ribbens
86171c500f Merge pull request #444 from trouble/rename-auth-verify-email
auth email verify anyOf type to allow one or both subject and html
2020-11-10 11:16:36 -05:00
Dan Ribbens
1010334f76 improve auth veryify description 2020-11-10 11:14:18 -05:00
Dan Ribbens
f44869f7cb auth email verify anyOf type to allow one or both subject and html properties 2020-11-10 11:12:08 -05:00
James
4b0c5cc9a2 Merge branch 'master' of github.com:keen-studio/payload 2020-11-10 09:18:35 -05:00
James
36b8f46f7e 0.0.135 2020-11-10 09:18:16 -05:00
James
d5ecbc96a3 fixes bug with not using formatted vals in buildQuery 2020-11-10 09:17:33 -05:00
Elliot DeNolf
760114b718 Merge pull request #443 from trouble/docs-hooks 2020-11-10 00:38:48 -05:00
Elliot DeNolf
76068637fb docs(hooks): add examples 2020-11-10 00:36:48 -05:00
Elliot DeNolf
bed0b1c04e docs(hooks): add lifecycle and more collection hooks 2020-11-10 00:29:21 -05:00
Elliot DeNolf
8a1cdc3f7d fix(hooks): incorrect hook executing for field-level afterChange 2020-11-09 22:27:50 -05:00
Elliot DeNolf
462f7f1f42 docs(hooks): first pass 2020-11-09 16:28:38 -05:00
James
10a657e9d7 0.0.134 2020-11-09 14:53:18 -05:00
James
ae7a94bf47 Merge branch 'master' of github.com:keen-studio/payload 2020-11-09 14:47:35 -05:00
James
e12bdb320d fixes bug with removing internal fields 2020-11-09 14:47:26 -05:00
Dan Ribbens
f667937aef Merge pull request #442 from trouble/rename-auth-verify-email
rename collection auth email verification to verify and add to collec…
2020-11-09 14:26:35 -05:00
Dan Ribbens
20c508cb12 remove default auth property for collection schema 2020-11-09 14:21:58 -05:00
Dan Ribbens
c00e5e8904 rename collection auth email verification to verify and add to collection schema json 2020-11-09 14:10:37 -05:00
Dan Ribbens
c6b00c9aca Merge pull request #430 from trouble/schema-json
Schema json
2020-11-09 08:26:12 -05:00
James
7154a1e35c 0.0.133 2020-11-08 14:52:38 -05:00
James
734662a9b4 includes docs in npm export 2020-11-08 14:52:29 -05:00
James
b11aa62001 ensures token is delivered properly within verification email 2020-11-08 14:48:56 -05:00
James
f4c066e475 allows async email html generation 2020-11-08 14:48:43 -05:00
James
1d7a789604 0.0.132 2020-11-08 10:32:24 -05:00
James
3f74eff0fe adds additional docs 2020-11-08 10:31:59 -05:00
James
2a2d33cd0b fixes bug with delete operation and hasWhereAccess 2020-11-08 10:31:53 -05:00
James
4e61ae84f7 adds installation doc 2020-11-08 08:32:00 -05:00
James
165634d127 scaffolds more docs 2020-11-07 15:51:05 -05:00
James
082c6d010c Merge branch 'master' of github.com:keen-studio/payload 2020-11-07 13:27:46 -05:00
James
62f65d5ffb updates docs 2020-11-07 13:27:43 -05:00
Elliot DeNolf
738698edad add key to collection list 2020-11-05 11:48:56 -05:00
James
a83064ed97 lints buildQuery 2020-11-04 09:08:27 -05:00
James
5ef407ba17 0.0.131 2020-11-04 09:07:26 -05:00
James
21fabfcb29 Merge branch 'master' of github.com:keen-studio/payload 2020-11-04 09:07:12 -05:00
James
521f250688 re-yarn 2020-11-04 09:07:09 -05:00
James
df33ceca79 sanitizes null strings provided to relationship queries 2020-11-04 09:07:02 -05:00
James
0ffbd2ee0f removes leftover autopopulate in schema construction 2020-11-04 09:05:54 -05:00
Dan Ribbens
4d64569c34 merge master 2020-11-02 16:01:32 -05:00
Dan Ribbens
32c025a2fa enforce boolean timestamps on collection schema 2020-11-02 15:53:47 -05:00
Dan Ribbens
58fa48a4da validates some parts of payload config schema and collections 2020-11-02 15:31:33 -05:00
Elliot DeNolf
699aa1b60f remove console.log 2020-11-02 13:44:02 -05:00
Elliot DeNolf
a00c565a62 allow unlock from admin UI 2020-11-02 13:42:06 -05:00
James
90bac7f4ab 0.0.130 2020-10-28 16:20:48 -04:00
James
ec2cda20cf exposes exp in login 2020-10-28 16:20:41 -04:00
James
1702261a15 0.0.129 2020-10-28 16:15:58 -04:00
James
bd85d621f5 Merge branch 'master' of github.com:keen-studio/payload 2020-10-28 16:15:51 -04:00
Jacob Fletcher
61bc485bf1 extracts exp from user 2020-10-28 16:15:32 -04:00
James
eaf89794ab 0.0.128 2020-10-28 10:33:59 -04:00
Jacob Fletcher
6a6b23d3d6 Merge branch 'master' of github.com:trouble/payload 2020-10-28 10:33:30 -04:00
Jacob Fletcher
5bb8a6d6d5 migrates away from optional chaining in express/responses/formatError 2020-10-28 10:33:21 -04:00
James
cc73db9bf0 0.0.127 2020-10-28 10:30:19 -04:00
James
48d2e230a3 Merge branch 'master' of github.com:keen-studio/payload 2020-10-28 10:29:40 -04:00
James
0ac24bc4f2 removes optional chaining 2020-10-28 10:29:37 -04:00
James
29e148763a adds custom component to docs 2020-10-27 09:46:19 -04:00
Elliot DeNolf
354d1527e1 fix: only allow /logout on current user's collection 2020-10-26 20:41:59 -04:00
Elliot DeNolf
ffa56e6c81 fix: /me only works on current user's collection 2020-10-26 20:41:49 -04:00
James
edcc6b56c8 Merge branch 'master' of github.com:keen-studio/payload 2020-10-26 16:56:31 -04:00
James
7e2f3e21ba updates docs for testing purposes 2020-10-26 16:56:26 -04:00
James
0d238085ba exports banner 2020-10-26 16:56:12 -04:00
James
082bf2fba4 adds ability to override depth on auth user 2020-10-26 16:56:03 -04:00
Elliot DeNolf
56a3ccaee8 rename useAuthentication to useAuth 2020-10-26 16:34:46 -04:00
Dan Ribbens
3f4c66467d add trustProxy to payload config and set express trust proxy on payload init (#429) 2020-10-26 16:17:49 -04:00
Dan Ribbens
85ccd80906 fix package import 2020-10-26 06:20:54 -04:00
Dan Ribbens
de539d00b6 schema validation using ajv with collections and assign default values 2020-10-26 06:01:33 -04:00
Dan Ribbens
f37c9eec04 WIP: add schema validation for payload config 2020-10-25 17:03:35 -04:00
James
9fd3e8d84f Merge branch 'master' of github.com:keen-studio/payload 2020-10-24 12:15:49 -04:00
James
07c917e33d adds webpack cli 2020-10-24 12:15:44 -04:00
Dan Ribbens
10c51f11c5 Merge branch 'rest-gql-errors' into schema-json 2020-10-23 13:14:35 -04:00
Dan Ribbens
5431b8ebcc Merge pull request #428 from trouble/rest-gql-errors
Rest gql errors
2020-10-23 13:12:40 -04:00
Dan Ribbens
e233551d0b cleanup graphql init 2020-10-23 13:11:16 -04:00
Dan Ribbens
5d4d1bf60c add trustProxy to payload config and set express trust proxy on payload init 2020-10-23 13:06:07 -04:00
Dan Ribbens
e6bfe00843 add cross-env to build scripts 2020-10-23 11:11:39 -04:00
Dan Ribbens
5c3b20643a Merge pull request #426 from trouble/rest-gql-errors
validation error respone and handling change
2020-10-22 17:07:22 -04:00
Dan Ribbens
e9600802a8 handle validation error data object to display field level error messages 2020-10-22 16:44:25 -04:00
Dan Ribbens
0aa2e5138c rest errorHandler now returns the same object as graphql for validation errors 2020-10-22 16:39:36 -04:00
James
27dad40d5c 0.0.126 2020-10-21 18:02:42 -04:00
James
646b46528d removes breaking optional chaining in graphql error handler 2020-10-21 18:02:36 -04:00
James
e097e924f2 0.0.125 2020-10-21 17:59:02 -04:00
James
777aaf9afd Merge branch 'master' of github.com:keen-studio/payload 2020-10-21 17:58:49 -04:00
James
221ec0bb10 takes copy of all docs found by ID in case they were memoized 2020-10-21 17:58:36 -04:00
Dan Ribbens
67ff273a9e use logger in graphql error handler 2020-10-20 09:45:57 -04:00
Dan Ribbens
397d36291d Merge pull request #425 from trouble/graphql-errors
gql errors include formatted field validation data
2020-10-20 09:36:27 -04:00
Dan Ribbens
a4066e4802 gql errors include formatted field validation data 2020-10-20 01:14:19 -04:00
Elliot DeNolf
88e24ba452 add ability to disable graphql playground in production 2020-10-19 20:18:24 -04:00
Elliot DeNolf
c7b377b84c fix: use proper user object in me operation 2020-10-18 01:34:36 -04:00
James
05a06a9aa8 allows for auth to be specified as true with no options 2020-10-17 15:08:39 -04:00
Elliot DeNolf
90a686ea0b Merge pull request #422 from trouble/query-exists 2020-10-16 21:45:41 -04:00
Elliot DeNolf
215df7ff9e handle graphql exists type 2020-10-16 21:42:55 -04:00
Elliot DeNolf
0758f01120 wip: exists query 2020-10-16 17:13:52 -04:00
James
bb7a910377 0.0.124 2020-10-16 16:05:32 -04:00
James
078293833d exposes local verifyEmail operation 2020-10-16 14:17:12 -04:00
James
99f61150d6 Merge branch 'master' of github.com:keen-studio/payload 2020-10-16 11:26:02 -04:00
James
ac64013a07 improves error messages in verifyEmail operation 2020-10-16 10:10:13 -04:00
James
5735b4bbec adds specificity to verified users 2020-10-16 08:48:33 -04:00
James
f0374d5772 adds an option to show hidden fields within local operations 2020-10-15 18:12:19 -04:00
James
20a9dcf6fe ensures hidden fields do not get added to graphql schemas 2020-10-15 16:48:02 -04:00
James
d0ef42a16b improves email api 2020-10-15 16:47:35 -04:00
James
18077d98bf allows for generating custom emails via collection config 2020-10-15 16:47:04 -04:00
James
cda4792ff7 simplifies verification view 2020-10-15 16:44:59 -04:00
Elliot DeNolf
76df2bc75a adjust FileGraphic to fill thumbnail area 2020-10-15 15:00:16 -04:00
Elliot DeNolf
e52b639e64 fix: upload sort from SelectExisting 2020-10-15 14:07:53 -04:00
Elliot DeNolf
75604e9b6c add 'date' to sortable field types 2020-10-15 11:21:54 -04:00
Elliot DeNolf
e058933192 test: add automatic account unlock test 2020-10-14 22:15:25 -04:00
Elliot DeNolf
a12ae0a1b6 test: add account lock test 2020-10-14 22:15:19 -04:00
Elliot DeNolf
5e0fd00b4e Merge pull request #420 from trouble/verify-tests 2020-10-14 16:45:15 -04:00
Elliot DeNolf
b4a43475ac test: add user verification test 2020-10-14 16:42:22 -04:00
Elliot DeNolf
f0bc59dd0c test: remove faker 2020-10-14 15:08:47 -04:00
Elliot DeNolf
c5aba71aa7 fix: show field requirement of 1 when Array/Blocks are required but no minRows specified 2020-10-14 11:49:26 -04:00
Elliot DeNolf
cac6a8869b test: split out collection tests into multiple files 2020-10-14 10:39:00 -04:00
Elliot DeNolf
787691859d remove verificationToken after verified 2020-10-13 16:48:06 -04:00
Elliot DeNolf
bf0d20461a fix: handle undefined in DateCell and DatePicker, homogenize formatting 2020-10-13 13:27:55 -04:00
Elliot DeNolf
7da73626ac fix: less_than_equal filter 2020-10-13 12:22:38 -04:00
James
8086120703 Merge branch 'master' of github.com:keen-studio/payload 2020-10-12 18:24:23 -04:00
James
7afa815467 0.0.123 2020-10-12 18:24:03 -04:00
James
5400500360 implements custom date and email gql scalars 2020-10-12 18:23:55 -04:00
Elliot DeNolf
ccae4014ec Merge pull request #416 from trouble/upload-tests 2020-10-12 16:59:32 -04:00
Elliot DeNolf
02279a769d test: upload with same name 2020-10-12 16:56:49 -04:00
Elliot DeNolf
c766a5a40e test: update upload 2020-10-12 16:31:05 -04:00
Elliot DeNolf
7ac2d0dcff test: remove beforeRead hook, messes with tests 2020-10-12 16:22:40 -04:00
James
6dfa1616ea 0.0.122 2020-10-12 16:14:13 -04:00
James
8a0411d6b1 condenses exports 2020-10-12 16:14:05 -04:00
Elliot DeNolf
fc63a692be test: add update upload 2020-10-12 15:21:36 -04:00
James
2b9b504573 0.0.121 2020-10-12 15:13:46 -04:00
James
fd9453889e sanitizes json before it comes out of global and collection find operations 2020-10-12 15:13:37 -04:00
James
dea21a0aae 0.0.120 2020-10-12 13:30:58 -04:00
James
12c520c3b1 re-adds node-sass as dependency 2020-10-12 13:30:51 -04:00
James
abc0383ecc 0.0.119 2020-10-12 13:24:32 -04:00
James
bb4dce09df allows for disableErrors to be passed through local findByID 2020-10-12 13:24:28 -04:00
James
6b932168ce 0.0.118 2020-10-12 12:41:48 -04:00
James
681bba82a9 removes mongoose-hidden, updates globals accordingly 2020-10-12 12:41:31 -04:00
Elliot DeNolf
4cfde3eba7 fix: do not attempt to delete upload if file doesn't exist 2020-10-12 11:04:57 -04:00
Elliot DeNolf
71633b1c8d test: check for actual files on create 2020-10-12 10:56:16 -04:00
Elliot DeNolf
2eb863aff0 test: extract out headers 2020-10-12 10:40:50 -04:00
Elliot DeNolf
5aede8affb fix component compilation 2020-10-11 14:29:46 -04:00
Elliot DeNolf
09dfb9793a fix webpack paths for both unix and windows 2020-10-11 14:14:21 -04:00
Elliot DeNolf
09897de77d add sort complex 2020-10-11 14:10:42 -04:00
Dan Ribbens
0362290d40 fix windows compatibility with webpack 2020-10-11 12:04:26 -04:00
James
57ef9fe623 fixes broken tests 2020-10-10 18:37:31 -04:00
James
38f08d54e3 0.0.117 2020-10-10 18:28:27 -04:00
James
84191ec8fd renames client to admin, sets up component library 2020-10-10 18:28:17 -04:00
James
e88be6b251 0.0.116 2020-10-09 13:39:14 -04:00
James
3bec424d05 Merge branch 'master' of github.com:keen-studio/payload 2020-10-09 13:39:07 -04:00
James
fc56a42fb0 fixes issue with relationship field and null value 2020-10-09 13:39:02 -04:00
James
05a5cc16bd further removes dependency on mongoose-hidden 2020-10-09 13:38:51 -04:00
Elliot DeNolf
c99b2f35f4 add disableScrollOnSuccess per-collection 2020-10-09 12:24:17 -04:00
Elliot DeNolf
8ae7457a3f add missing autoComplete attribute on password fields 2020-10-09 12:06:29 -04:00
Elliot DeNolf
bb8a04dd7b add style and width props for Group, Array, and Blocks 2020-10-09 11:45:58 -04:00
James
a681f5f725 builds unlock operation 2020-10-09 11:04:36 -04:00
Elliot DeNolf
613552de0a add style and width props for Blocks 2020-10-09 10:07:16 -04:00
Elliot DeNolf
cd38d37242 enforce maxRows on Arrays and Blocks 2020-10-09 10:07:10 -04:00
James
6b6b503ef0 0.0.115 2020-10-09 08:04:13 -04:00
James
f880072697 fixes bug with adding blocks and arrays due to async buildStateFromSchema 2020-10-08 23:03:37 -04:00
James
ffc3f10177 adds indication for readOnly Array and Blocks when no rows are present 2020-10-08 21:41:47 -04:00
James
f9b7e3239e adds both singular and plural labels to Blocks and Array, adjusts impacted files accordingly 2020-10-08 21:33:37 -04:00
James
09cc61c96a fixes modal scroll 2020-10-08 20:09:00 -04:00
James
a6325c69f4 Merge branch 'master' of github.com:keen-studio/payload 2020-10-08 19:32:36 -04:00
James
2f1b1a02b1 enables default values in new rows of array / block fields 2020-10-08 19:32:10 -04:00
James
727c5a4a53 styles baseline richText 2020-10-08 19:31:42 -04:00
James
918d3bd2bc fixes bug with clearing hasMany relationship field values 2020-10-08 19:31:26 -04:00
Elliot DeNolf
2d7bacad09 don't render 'Add Blocks' button when readOnly 2020-10-08 17:00:41 -04:00
James
234ed07ad6 Merge branch 'master' of github.com:keen-studio/payload 2020-10-08 16:18:08 -04:00
Elliot DeNolf
964fdf779a make rich text respect readOnly 2020-10-08 16:05:23 -04:00
Elliot DeNolf
40afb5e8fa add default value test for normal fields 2020-10-08 10:16:05 -04:00
James
72c0145816 0.0.114 2020-10-08 09:15:24 -04:00
James
12eb33b5c9 fixes bug with fromAddress in sanitizeConfig 2020-10-08 09:14:50 -04:00
Elliot DeNolf
ddb238c7e4 add blocks cell tests 2020-10-08 07:09:24 -04:00
Elliot DeNolf
32980fcafc Merge pull request #410 from trouble/tests-reorg 2020-10-08 06:29:30 -04:00
Elliot DeNolf
db6315a621 fix date cell test for timezone in CI 2020-10-08 06:27:19 -04:00
Elliot DeNolf
6bf0c2aab6 ci: add client tests 2020-10-08 05:53:47 -04:00
Elliot DeNolf
3dc9ddcb52 add some cell type tests 2020-10-08 05:50:07 -04:00
Elliot DeNolf
352dfa9a09 finish configuring client tests 2020-10-08 05:20:52 -04:00
Elliot DeNolf
60a3e680dd move tests dir to root 2020-10-08 05:01:48 -04:00
Elliot DeNolf
18f98e24e5 disable logging during tests, remove unused test:unit script, and add 'test' task to run all 2020-10-08 04:55:06 -04:00
Elliot DeNolf
c599522e44 isolate api tests inside tests/api 2020-10-08 04:50:33 -04:00
Elliot DeNolf
64fef7d380 implement basic react testing suite 2020-10-07 17:20:10 -04:00
James
6381d4cf6b 0.0.113 2020-10-07 16:52:58 -04:00
James
91016ec206 removes image-size in favor of probe-image-size to handle CMYK jpgs 2020-10-07 16:52:48 -04:00
James
9aeab9548d ensures default values work for Group and Array 2020-10-07 16:43:08 -04:00
James
69d7f21b56 partially working buildStateFromSchema 2020-10-07 16:26:56 -04:00
James
9de596605b fixes bug with localization 2020-10-07 16:18:01 -04:00
James
650edcf56a reduces padding on position-panel 2020-10-07 16:17:49 -04:00
James
2c4dedff2c only loads uploads if modal is open 2020-10-07 15:55:25 -04:00
James
870e39961c implements env-based bundle analyzer 2020-10-07 15:55:16 -04:00
James
319148ca68 adds default value collection 2020-10-07 15:54:53 -04:00
James
6dac68606b adds build scripts 2020-10-07 15:54:42 -04:00
James
9716d008a9 Merge branch 'master' of github.com:keen-studio/payload 2020-10-07 15:39:08 -04:00
James
b5fd68c3dc 0.0.112 2020-10-07 15:10:48 -04:00
James
eea9d14749 ensures modals have proper Z index, allows Upload field to handle deleted files gracefully 2020-10-07 15:10:39 -04:00
Elliot DeNolf
77de6e4b60 fix: initial form state 2020-10-07 14:53:55 -04:00
James
58f68e3bda 0.0.111 2020-10-07 14:51:50 -04:00
James
1ea3763185 better handles failed form submissions, allows customization of file uploads 2020-10-07 14:51:42 -04:00
James
920251f296 0.0.110 2020-10-07 12:42:41 -04:00
James
dffb554ebe fixes bug in Number field type 2020-10-07 12:42:32 -04:00
James
7255f6108f 0.0.109 2020-10-06 14:40:57 -04:00
James
078392f2c5 0.0.107 2020-10-06 14:40:52 -04:00
James
c2e9407f50 removes unused arg in findByID memoization 2020-10-06 14:39:53 -04:00
James
a5a4f1490e Merge branch 'master' of github.com:keen-studio/payload 2020-10-06 14:39:10 -04:00
James Mikrut
e20555f9cf Memoize populate (#408)
* Revert "0.0.108"

This reverts commit 7aafe49662.

* Revert "swaps out fast-memoize for micro-memoize that supports async"

This reverts commit 33d8ec8a13.

* Revert "implements a named populate function to memoize"

This reverts commit fb73e772af.

* Revert "0.0.107"

This reverts commit c2692e9b4a.

* reverts back to 106

* memoizes findByID
2020-10-06 14:38:20 -04:00
James
791a222d28 reverts back to 106 2020-10-06 13:16:36 -04:00
James
cb97090d88 Revert "0.0.107"
This reverts commit c2692e9b4a.
2020-10-06 13:15:33 -04:00
James
923cdc7b6a Revert "implements a named populate function to memoize"
This reverts commit fb73e772af.
2020-10-06 13:15:09 -04:00
James
19369b4c33 Revert "swaps out fast-memoize for micro-memoize that supports async"
This reverts commit 33d8ec8a13.
2020-10-06 13:15:00 -04:00
James
4ec230e8a0 Revert "0.0.108"
This reverts commit 7aafe49662.
2020-10-06 13:14:52 -04:00
James
7aafe49662 0.0.108 2020-10-06 09:47:13 -04:00
James
33d8ec8a13 swaps out fast-memoize for micro-memoize that supports async 2020-10-06 09:47:05 -04:00
James
fb73e772af implements a named populate function to memoize 2020-10-06 09:11:09 -04:00
James
c2692e9b4a 0.0.107 2020-10-06 08:58:30 -04:00
James
a0d6fe5ca7 memoizes the Populate function 2020-10-06 08:58:25 -04:00
James
7f65e68e82 0.0.106 2020-10-05 22:14:44 -04:00
James
d9f78fc5bf removes unused salt and hash hidden options 2020-10-05 22:14:11 -04:00
James
b2a5279bcb hides fields manually, removes isLocked virtual in favor of a defined Payload field 2020-10-05 22:12:33 -04:00
James
28baba822b 0.0.105 2020-10-05 21:43:13 -04:00
James
3b4875b754 fixes bug with incoming richText stringified JSON 2020-10-05 21:42:47 -04:00
James
8ce88deda2 fixes bug with create / update improperly reducing locales 2020-10-05 21:37:31 -04:00
James
4527658027 misc responsive fixes 2020-10-05 21:18:29 -04:00
James
8057c0ecb8 abstracts performFieldOperations into functions for performance reasons 2020-10-05 20:26:04 -04:00
James
eb74a42386 0.0.104 2020-10-05 17:09:12 -04:00
James
d589a90a42 allows for local payload initialization 2020-10-05 17:08:59 -04:00
James
bf3d05cb40 fixes bug with registerFirstUser 2020-10-05 17:08:44 -04:00
James
7bd4859a31 0.0.103 2020-10-05 10:40:22 -04:00
James
9af097c39c restores required initialState via form context 2020-10-05 10:40:14 -04:00
James
7f47cdacbb enables lean mongoose queries for all find operations 2020-10-05 10:25:35 -04:00
James
d85cbde7a7 0.0.102 2020-10-04 20:42:50 -04:00
James
79284941db fixes a grave mistake 2020-10-04 20:42:36 -04:00
James
35c11aa7aa 0.0.101 2020-10-04 15:31:15 -04:00
James
5ac2b1fb3d adds richText Relationship WIP 2020-10-04 15:30:47 -04:00
James
0a5e8ab618 implements maxDepth 2020-10-04 15:30:38 -04:00
James
5ae267f743 updates styles of RichText, improves its API 2020-10-04 12:50:14 -04:00
James
bc48e92aea fixes bug with autocompleted input fields 2020-10-04 12:41:03 -04:00
James
98af494dd6 further styles RichText and its Link element 2020-10-03 15:55:59 -04:00
James
31487fb022 adds a method to deserialize pasted HTML into RichText 2020-10-03 15:55:38 -04:00
James
e00a2eeef7 fixes fields with less than 100% width on mobile 2020-10-03 15:55:21 -04:00
James
c5ea2dcd2a revises the way that negative field type gutter works 2020-10-03 15:55:07 -04:00
James
e9c2b46c97 extends Popup to be more usable 2020-10-03 15:54:19 -04:00
James
043d3fffbf fixes bug with window info breakpoints 2020-10-03 15:54:00 -04:00
James
febe213e80 implements accessibility measures and finishes Link richText element 2020-10-03 13:04:15 -04:00
James
0764f34c64 adds accessibility to buttons 2020-10-03 11:38:33 -04:00
James
3dbf9ac27c properly sets user to null when logged out 2020-10-03 11:20:35 -04:00
James
eccb4383a1 fixes DeleteDocument and leaveWithoutSaving incompatibility 2020-10-03 11:07:06 -04:00
James
31180bfc2b 0.0.99 2020-10-02 21:36:15 -04:00
James
c6105d9ed3 ensures NODE_ENV is set properly within client 2020-10-02 21:36:02 -04:00
James
3b82d1ccba runs admin static through compression middleware 2020-10-02 21:28:40 -04:00
James
9fe8a09ac9 0.0.98 2020-10-02 21:11:20 -04:00
James
18a59f84ab migrates all custom components to new pattern 2020-10-02 21:11:08 -04:00
James
c28f78cb8a further optimizes webpack bundle 2020-10-02 20:46:08 -04:00
James
18baefed0d progress to code-splitting 2020-10-02 18:47:43 -04:00
James
f56eeddff4 0.0.97 2020-10-02 15:46:46 -04:00
James
f5561b4b4f adds safety checks for building initial form state with no blockType 2020-10-02 15:46:27 -04:00
James
d42171d465 Merge branch 'master' of github.com:keen-studio/payload 2020-10-02 15:02:41 -04:00
Elliot DeNolf
f3d56fe435 add code cell type 2020-10-02 12:37:00 -04:00
Elliot DeNolf
52e9e4daa7 fix default checkbox cell value 2020-10-02 12:34:28 -04:00
Elliot DeNolf
dde76572e3 disappearing cancel button was bothering me 2020-10-02 12:06:59 -04:00
Elliot DeNolf
df4563274b disable scroll on save for upload media modal 2020-10-02 11:04:02 -04:00
Elliot DeNolf
6e93bd006e fix checkbox style 2020-10-02 10:27:33 -04:00
Elliot DeNolf
814cc9658c add checkbox cell type for boolean values 2020-10-02 10:21:23 -04:00
Elliot DeNolf
efc6d0adf1 fix graphQL tests 2020-10-02 09:45:58 -04:00
James
f37fe42c70 0.0.96 2020-10-01 14:58:07 -04:00
James
3359cd4e9b ensures reset password sends back a new user 2020-10-01 14:57:59 -04:00
Elliot DeNolf
2b80c5fda6 remove unused email props 2020-10-01 13:20:07 -04:00
Elliot DeNolf
4c2bcb2933 fix no data in useAsTitle field 2020-10-01 13:20:01 -04:00
James
96c1362a5d flattens me auth type to match collection type 2020-10-01 11:37:20 -04:00
James
5f3b1aec0a increases max rateLimit 2020-10-01 11:37:04 -04:00
James
942afd96fe returns user with login 2020-10-01 11:36:58 -04:00
James
39ddde082c 0.0.95 2020-10-01 09:17:45 -04:00
James
9b384e8192 removes dependency of passing publicENV through options on init 2020-10-01 09:17:37 -04:00
James
09543831b9 fixes webpack prod env config 2020-10-01 09:02:15 -04:00
James
eb0b5870a3 Merge branch 'master' of github.com:keen-studio/payload 2020-10-01 08:51:55 -04:00
James
49c03135a9 0.0.94 2020-10-01 08:51:37 -04:00
James
22ba992b6d removes dotenv-webpack for a more declarative approach 2020-10-01 08:51:25 -04:00
Elliot DeNolf
553d3ebd48 disable pointer events if code field is readOnly 2020-09-30 22:25:30 -04:00
James
f80bda89b6 0.0.93 2020-09-30 12:13:25 -04:00
James
722f2fc88d merges master 2020-09-30 12:13:19 -04:00
James
c89d2e0f01 Merge branch 'master' of github.com:keen-studio/payload 2020-09-30 12:13:10 -04:00
James
7aab4214b7 implements a way to skip over certain ips in rate limiter 2020-09-30 12:12:59 -04:00
Elliot DeNolf
6294333c88 highlight token field on generation 2020-09-30 11:03:55 -04:00
James
98afd9c53b 0.0.92 2020-09-30 10:34:20 -04:00
James
6ccca08319 tries to export appropriate files once more 2020-09-30 10:34:15 -04:00
James
f497fdde22 0.0.91 2020-09-30 10:31:54 -04:00
James
d73fdf6572 includes more files in npm export 2020-09-30 10:31:50 -04:00
James
0e6f790734 Merge branch 'master' of github.com:keen-studio/payload 2020-09-30 08:54:25 -04:00
James
18774c05ea 0.0.90 2020-09-30 08:53:38 -04:00
James
b3dda3c070 standardizes custom component naming to proper nouns 2020-09-30 08:53:15 -04:00
James
d9e62e9a6d fixes bug with graphql maxComplexity default value 2020-09-30 07:49:29 -04:00
Elliot DeNolf
3f5518aa3a Merge pull request #401 from trouble/token-gen-confirm
add token generation confirmation modal
2020-09-29 22:31:16 -04:00
Elliot DeNolf
0c12b8dfda add token generation confirmation modal 2020-09-29 22:29:30 -04:00
James
a53ac62164 0.0.89 2020-09-28 18:26:06 -04:00
James
8fa63c7131 fixes paths for custom icon and logo 2020-09-28 18:25:54 -04:00
James
5599b8bd30 0.0.88 2020-09-28 18:15:30 -04:00
James
5694258b74 cleans performFieldOperations 2020-09-28 18:15:26 -04:00
James
a974c908b5 fixes bug in Upload cell, returns nullAsUndefineds to object-to-formdata 2020-09-28 18:15:08 -04:00
James
6d7d996d61 properly runs exported field-types and hooks through babel 2020-09-28 16:25:42 -04:00
James
da4d9c5e71 0.0.87 2020-09-28 16:02:53 -04:00
James
c409ac985c removes console logs 2020-09-28 16:02:41 -04:00
James
62072e2d0f 0.0.86 2020-09-28 15:49:36 -04:00
James
18e08ad5a7 revises RichText structure and functionality 2020-09-28 15:49:20 -04:00
Elliot DeNolf
ae8cc7b9ed fix: upload cell prop validation errors 2020-09-28 15:35:01 -04:00
Elliot DeNolf
06fd32786d fix: add back image field 2020-09-28 15:18:43 -04:00
Elliot DeNolf
2f5c13aac3 fix: select cell component handle strings and arrays of strings 2020-09-28 15:16:54 -04:00
Elliot DeNolf
5025972450 add select cell component 2020-09-28 13:37:18 -04:00
Elliot DeNolf
e7d3f77560 Merge pull request #400 from trouble/tune-package
add files whitelist to package.json
2020-09-28 12:50:04 -04:00
Elliot DeNolf
f171adc88d add files whitelist to package.json 2020-09-28 12:48:10 -04:00
Elliot DeNolf
e24428c42c Merge pull request #399 from trouble/cell-components 2020-09-28 10:30:40 -04:00
Elliot DeNolf
e849f0f49e add upload cell component 2020-09-28 10:27:02 -04:00
Elliot DeNolf
b011163d90 use singular label from block items 2020-09-28 00:46:54 -04:00
Elliot DeNolf
0492603ac7 add custom cell types for array, textarea, and richtext 2020-09-28 00:05:10 -04:00
James
15a488c03f creates a better pattern for how to render table cells 2020-09-27 15:33:49 -04:00
James
77096cb252 Merge branch 'master' of github.com:keen-studio/payload 2020-09-27 15:07:46 -04:00
James
6efeafe819 fixes modals scrolling to top of screen 2020-09-27 15:07:32 -04:00
Elliot DeNolf
dabc5749d4 Merge pull request #398 from trouble/graphql-query-complexity 2020-09-27 15:03:55 -04:00
Elliot DeNolf
79fc3f72a6 implement graphql query complexity limits 2020-09-27 15:01:35 -04:00
Elliot DeNolf
7c2de28de9 Merge pull request #397 from trouble/lock-adjustments
some adjustments to how locking and verification work
2020-09-26 23:48:07 -04:00
Elliot DeNolf
83f77d3a05 some adjustments to how locking and verification work 2020-09-26 23:46:09 -04:00
James
5b71a3cb60 0.0.85 2020-09-26 17:52:35 -04:00
James
04650a86a5 handles either relative or absolute paths for upload directories 2020-09-26 17:50:12 -04:00
James
69b4f9f59f 0.0.84 2020-09-25 16:27:40 -04:00
James
4df979565e re-adds baseFields 2020-09-25 16:24:26 -04:00
James
193cdbbe5e Merge branch 'master' of github.com:keen-studio/payload 2020-09-25 16:21:11 -04:00
Elliot DeNolf
a634a5c00c Merge pull request #396 from trouble/rate-limiter 2020-09-25 14:29:43 -04:00
Elliot DeNolf
c19ccd5df4 implement account locking on too many attempts and unlocking after time window 2020-09-25 14:22:13 -04:00
Elliot DeNolf
57c6afa3a9 implement basic rate limiting for /api routes 2020-09-24 23:25:59 -04:00
Elliot DeNolf
9354d86af2 feat(ts): add collection hook types
Signed-off-by: Elliot DeNolf <denolfe@gmail.com>
2020-09-24 17:20:21 -04:00
Elliot DeNolf
791de301cc Merge pull request #395 from trouble/verify-graphql 2020-09-24 17:08:07 -04:00
Elliot DeNolf
87ccdae795 implement verify graphql resolver 2020-09-24 16:39:38 -04:00
Elliot DeNolf
a412e68e89 update typescript types 2020-09-24 11:19:41 -04:00
Elliot DeNolf
98e2f2be08 fix: NotFound bad call to useConfig 2020-09-24 11:08:13 -04:00
Elliot DeNolf
b8b5ca17ed Merge pull request #390 from trouble/verify-view 2020-09-24 10:56:42 -04:00
Elliot DeNolf
96ccebdedd add 'already activated' response 2020-09-24 10:54:42 -04:00
James
59da900a1d 0.0.83 2020-09-24 09:36:27 -04:00
James
fbc4429648 fixes bug with combining AND clauses, extends graphql id operations 2020-09-24 09:36:21 -04:00
James
3feec809e6 0.0.82 2020-09-23 20:15:45 -04:00
James
8dd3298f9a performance improvements 2020-09-23 20:14:27 -04:00
Elliot DeNolf
0c3986917f implement verify view 2020-09-23 16:04:19 -04:00
973 changed files with 23795 additions and 17370 deletions

View File

@@ -4,7 +4,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.js]
[*.{js,ts,tsx}]
indent_style = space
indent_size = 2

View File

@@ -1,16 +1,62 @@
module.exports = {
parser: "babel-eslint",
extends: "@trbl",
rules: {
"import/no-unresolved": [
2,
{
ignore: [
'payload/config',
'payload/unsanitizedConfig',
]
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
plugins: [
'@typescript-eslint',
],
extends: [
'@trbl',
],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
extends: [
'plugin:@typescript-eslint/recommended',
],
rules: {
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"],
'import/no-unresolved': [
2,
{
ignore: [
'payload/config',
],
},
],
}
],
},
],
rules: {
"import/no-extraneous-dependencies": ["error", { "packageDir": "./" }],
'react/jsx-filename-extension': [2, { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
'import/prefer-default-export': 'off',
'react/prop-types': 'off',
'react/no-unused-prop-types': 'off',
'no-underscore-dangle': 'off',
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
},
};

View File

@@ -15,6 +15,9 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org
scope: '@payloadcms'
always-auth: true
- name: Cache node modules
uses: actions/cache@v1
with:
@@ -25,6 +28,9 @@ jobs:
${{ runner.os }}-build-
${{ runner.os }}-
- run: yarn
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: yarn test:client
- run: yarn test:int # In-memory db + api tests
env:
CI: true

8
.gitignore vendored
View File

@@ -215,10 +215,16 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk
# End of https://www.gitignore.io/api/node,macos,windows,webstorm,sublimetext,visualstudiocode
# Ignore all uploads
demo/upload
demo/media
demo/files
# Ignore build folder
build
# Ignore built components
components/index.js
components/styles.css

49
.vscode/launch.json vendored
View File

@@ -23,37 +23,40 @@
"<node_internals>/**"
]
},
{
"name": "Debug Jest Test - Current File",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
"${fileBasename}",
"--runInBand"
],
"env": {
"PAYLOAD_CONFIG_PATH": "demo/payload.config.js"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229,
"skipFiles": [
"<node_internals>/**"
]
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"env": {
"PAYLOAD_CONFIG_PATH": "demo/payload.config.js"
"PAYLOAD_CONFIG_PATH": "demo/payload.config.ts",
"BABEL_ENV": "development"
},
"program": "${workspaceFolder}/demo/server.js",
"program": "${workspaceFolder}/demo/index.js",
"skipFiles": [
"<node_internals>/**"
]
],
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/babel-node",
"runtimeArgs": [
"--nolazy"
],
},
{
"type": "node",
"request": "launch",
"name": "Launch Program - Production",
"env": {
"PAYLOAD_CONFIG_PATH": "demo/payload.config.ts",
"NODE_ENV": "production",
"BABEL_ENV": "development"
},
"program": "${workspaceFolder}/demo/index.js",
"skipFiles": [
"<node_internals>/**"
],
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/babel-node",
"runtimeArgs": [
"--nolazy"
],
},
{
"type": "chrome",

View File

@@ -1,3 +0,0 @@
export { default as Popup } from '../src/client/components/elements/Popup';
export { default as MinimalTemplate } from '../src/client/components/templates/Minimal';

View File

@@ -1 +0,0 @@
export { default as Button } from '../src/client/components/elements/Button';

View File

@@ -1,6 +0,0 @@
export { default as Form } from '../src/client/components/forms/Form';
export { default as Text } from '../src/client/components/forms/field-types/Text';
export { default as Select } from '../src/client/components/forms/field-types/Select';
export { default as Checkbox } from '../src/client/components/forms/field-types/Checkbox';
export { default as Submit } from '../src/client/components/forms/Submit';
export { default as reduceFieldsToValues } from '../src/client/components/forms/Form/reduceFieldsToValues';

View File

@@ -1 +0,0 @@
export { default as X } from '../src/client/components/icons/X';

View File

@@ -1,4 +0,0 @@
export { default as LeafButton } from '../src/client/components/forms/field-types/RichText/LeafButton';
export { default as ElementButton } from '../src/client/components/forms/field-types/RichText/ElementButton';
export { default as toggleElement } from '../src/client/components/forms/field-types/RichText/toggleElement';

View File

@@ -1 +0,0 @@
@import '../src/client/scss/styles.scss';

1
auth.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export * from './dist/auth';

1
auth.js Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./dist/auth');

View File

@@ -1,21 +1,3 @@
module.exports = {
presets: [
[
require.resolve('@babel/preset-env'),
{
modules: 'cjs',
targets: [
'defaults',
'not IE 11',
'not IE_Mob 11',
],
},
],
require.resolve('@babel/preset-react'),
],
plugins: [
require.resolve('@babel/plugin-proposal-class-properties'),
require.resolve('@babel/plugin-proposal-optional-chaining'),
require.resolve('babel-plugin-add-module-exports'),
],
};
const config = require('./src/babel.config');
module.exports = config;

2
bin.js Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./dist/bin');

19
components/forms.js Normal file
View File

@@ -0,0 +1,19 @@
export {
useForm,
useWatchForm,
useFormSubmitted,
useFormProcessing,
useFormModified,
} from '../src/admin/components/forms/Form/context';
export { default as useFieldType } from '../src/admin/components/forms/useFieldType';
export { default as Form } from '../src/admin/components/forms/Form';
export { default as Text } from '../src/admin/components/forms/field-types/Text';
export { default as Group } from '../src/admin/components/forms/field-types/Group';
export { default as Select } from '../src/admin/components/forms/field-types/Select';
export { default as Checkbox } from '../src/admin/components/forms/field-types/Checkbox';
export { default as Submit } from '../src/admin/components/forms/Submit';
export { default as reduceFieldsToValues } from '../src/admin/components/forms/Form/reduceFieldsToValues';

3
components/rich-text.js Normal file
View File

@@ -0,0 +1,3 @@
export { default as LeafButton } from '../src/admin/components/forms/field-types/RichText/leaves/Button';
export { default as ElementButton } from '../src/admin/components/forms/field-types/RichText/elements/Button';
export { default as toggleElement } from '../src/admin/components/forms/field-types/RichText/elements/toggle';

2
components/views.js Normal file
View File

@@ -0,0 +1,2 @@
export { default as Edit } from '../src/admin/components/views/collections/Edit/Default';
export { default as List } from '../src/admin/components/views/collections/List/Default';

2
config.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
export { buildConfig } from './dist/config/build';
export * from './dist/config/types';

1
config.js Normal file
View File

@@ -0,0 +1 @@
exports.buildConfig = require('./dist/config/build').buildConfig;

View File

@@ -6,11 +6,7 @@
*/
const checkRole = (allRoles, user) => {
if (user) {
if (allRoles.some((role) => {
return user.roles && user.roles.some((individualRole) => {
return individualRole === role;
});
})) {
if (allRoles.some((role) => user.roles && user.roles.some((individualRole) => individualRole === role))) {
return true;
}
}
@@ -18,4 +14,4 @@ const checkRole = (allRoles, user) => {
return false;
};
module.exports = checkRole;
export default checkRole;

View File

@@ -1,4 +1,4 @@
module.exports = [
export default [
'admin',
'editor',
'moderator',

View File

@@ -1,4 +1,6 @@
module.exports = {
import { Block } from '../../src/fields/config/types';
const CTA: Block = {
slug: 'cta',
labels: {
singular: 'Call to Action',
@@ -16,8 +18,9 @@ module.exports = {
name: 'url',
label: 'URL',
type: 'text',
height: 100,
required: true,
},
],
};
export default CTA;

View File

@@ -1,4 +1,6 @@
module.exports = {
import { Block } from '../../src/fields/config/types';
const Email: Block = {
slug: 'email',
labels: {
singular: 'Email',
@@ -9,8 +11,9 @@ module.exports = {
name: 'testEmail',
label: 'Test Email Field',
type: 'email',
maxLength: 100,
required: true,
},
],
};
export default Email;

View File

@@ -1,4 +1,6 @@
module.exports = {
import { Block } from '../../src/fields/config/types';
const NumberBlock: Block = {
slug: 'number',
labels: {
singular: 'Number',
@@ -9,8 +11,10 @@ module.exports = {
name: 'testNumber',
label: 'Test Number Field',
type: 'number',
maxLength: 100,
max: 100,
required: true,
},
],
};
export default NumberBlock;

View File

@@ -1,4 +1,6 @@
module.exports = {
import { Block } from '../../src/fields/config/types';
const Quote: Block = {
blockImage: '/static/assets/images/generic-block-image.svg',
slug: 'quote',
labels: {
@@ -17,7 +19,6 @@ module.exports = {
name: 'quote',
label: 'Quote',
type: 'textarea',
height: 100,
required: true,
},
{
@@ -29,3 +30,5 @@ module.exports = {
},
],
};
export default Quote;

View File

@@ -1,5 +0,0 @@
import React from 'react';
const Sidebar = () => <div className="sidebar">fake sidebar</div>
export default Sidebar;

View File

@@ -1,4 +1,4 @@
@import '../../../../../../../admin/styles';
@import '../../../../../../../scss/vars.scss';
.button-rich-text-button {
.btn {
@@ -6,18 +6,22 @@
}
&__modal {
@include blur-bg;
display: flex;
align-items: center;
height: 100%;
&.payload__modal-item--enterDone {
@include blur-bg;
}
}
&__header {
width: 100%;
margin-bottom: $baseline;
display: flex;
justify-content: space-between;
h4 {
h3 {
margin: 0;
}

View File

@@ -1,35 +1,41 @@
import React, { Fragment, useCallback } from 'react';
import PropTypes from 'prop-types';
import { Modal, useModal } from '@faceless-ui/modal';
import { Transforms } from 'slate';
import { useSlate } from 'slate-react';
import { MinimalTemplate } from '../../../../../../../admin/components';
import { ElementButton } from '../../../../../../../admin/rich-text';
import { X } from '../../../../../../../admin/icons';
import { Button } from '../../../../../../../admin/elements';
import { Form, Text, Checkbox, Select, Submit, reduceFieldsToValues } from '../../../../../../../admin/forms';
import MinimalTemplate from '../../../../../../../src/admin/components/templates/Minimal';
import { ElementButton } from '../../../../../../../components/rich-text';
import X from '../../../../../../../src/admin/components/icons/X';
import Button from '../../../../../../../src/admin/components/elements/Button';
import { Form, Text, Checkbox, Select, Submit, reduceFieldsToValues } from '../../../../../../../components/forms';
import './index.scss';
const modalSlug = 'add-button';
const baseClass = 'button-rich-text-button';
const insertButton = (editor, { url, label, style, newTab = false }) => {
const text = { text: label };
const initialFormData = {
style: 'primary',
};
const insertButton = (editor, { href, label, style, newTab = false }) => {
const text = { text: ' ' };
const button = {
type: 'button',
url,
href,
style,
newTab,
label,
children: [
text,
],
};
Transforms.insertNodes(editor, button);
const nodes = [button, { children: [{ text: '' }] }];
Transforms.insertNodes(editor, nodes);
};
const ButtonButton = () => {
const ToolbarButton: React.FC = ({ path }) => {
const { open, closeAll } = useModal();
const editor = useSlate();
@@ -39,6 +45,8 @@ const ButtonButton = () => {
closeAll();
}, [editor, closeAll]);
const modalSlug = `${path}-add-button`;
return (
<Fragment>
<ElementButton
@@ -62,7 +70,10 @@ const ButtonButton = () => {
<X />
</Button>
</header>
<Form onSubmit={handleAddButton}>
<Form
onSubmit={handleAddButton}
initialData={initialFormData}
>
<Text
label="Label"
name="label"
@@ -70,7 +81,7 @@ const ButtonButton = () => {
/>
<Text
label="URL"
name="URL"
name="href"
required
/>
<Select
@@ -101,4 +112,8 @@ const ButtonButton = () => {
);
};
export default ButtonButton;
ToolbarButton.propTypes = {
path: PropTypes.string.isRequired,
};
export default ToolbarButton;

View File

@@ -1,9 +1,12 @@
@import '../../../../../../../admin/styles.scss';
@import '../../../../../../../scss/vars.scss';
.rich-text-button {
margin: $baseline 0;
}
.rich-text-button__button {
padding: base(.5) base(1.5);
border-radius: $style-radius-s;
display: inline-flex;
&--primary {
background-color: $color-dark-gray;

View File

@@ -5,20 +5,25 @@ import './index.scss';
const baseClass = 'rich-text-button';
const ButtonElement = ({ attributes, children, element }) => {
const { label, style = 'primary' } = element;
const ButtonElement: React.FC = ({ attributes, children, element }) => {
const { style = 'primary', label } = element;
return (
<span
{...attributes}
className={[
baseClass,
`${baseClass}--${style}`,
].join(' ')}
<div
className={baseClass}
contentEditable={false}
>
{label}
{children}
</span>
<span
{...attributes}
className={[
`${baseClass}__button`,
`${baseClass}__button--${style}`,
].join(' ')}
>
{label}
{children}
</span>
</div>
);
};

View File

@@ -1,10 +0,0 @@
const button = require('./Button');
const element = require('./Element');
const plugin = require('./plugin');
module.exports = {
name: 'button',
button,
element,
plugin,
};

View File

@@ -0,0 +1,12 @@
import Button from './Button';
import Element from './Element';
import plugin from './plugin';
export default {
name: 'button',
Button,
Element,
plugins: [
plugin,
],
};

View File

@@ -1,4 +1,6 @@
const withButton = (incomingEditor) => {
import { Editor } from 'slate';
const withButton = (incomingEditor: Editor): Editor => {
const editor = incomingEditor;
const { isVoid } = editor;

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { LeafButton } from '../../../../../../../admin/rich-text';
import { LeafButton } from '../../../../../../../components/rich-text';
const Button = () => (
<LeafButton format="purple-background">

View File

@@ -1,8 +0,0 @@
const button = require('./Button');
const leaf = require('./Leaf');
module.exports = {
name: 'purple-background',
button,
leaf,
};

View File

@@ -0,0 +1,8 @@
import Button from './Button';
import Leaf from './Leaf';
export default {
name: 'purple-background',
Button,
Leaf,
};

View File

@@ -1,12 +1,13 @@
const roles = require('../access/roles');
const checkRole = require('../access/checkRole');
import { PayloadCollectionConfig } from '../../src/collections/config/types';
import roles from '../access/roles';
import checkRole from '../access/checkRole';
const access = ({ req: { user } }) => {
const result = checkRole(['admin'], user);
return result;
};
module.exports = {
const Admin: PayloadCollectionConfig = {
slug: 'admins',
labels: {
singular: 'Admin',
@@ -20,11 +21,14 @@ module.exports = {
admin: () => true,
},
auth: {
tokenExpiration: 7200,
emailVerification: false,
tokenExpiration: 7200, // 2 hours
verify: false,
maxLoginAttempts: 5,
lockTime: 600 * 1000, // lock time in ms
useAPIKey: true,
depth: 0,
cookies: {
secure: process.env.NODE_ENV === 'production',
secure: false,
sameSite: 'Lax',
domain: undefined,
},
@@ -42,6 +46,7 @@ module.exports = {
},
{
name: 'apiKey',
type: 'text',
access: {
read: ({ req: { user } }) => {
if (checkRole(['admin'], user)) {
@@ -64,3 +69,5 @@ module.exports = {
useAsTitle: 'email',
},
};
export default Admin;

View File

@@ -1,15 +1,16 @@
const checkRole = require('../access/checkRole');
const Email = require('../blocks/Email');
const Quote = require('../blocks/Quote');
const NumberBlock = require('../blocks/Number');
const CallToAction = require('../blocks/CallToAction');
import { PayloadCollectionConfig } from '../../src/collections/config/types';
import checkRole from '../access/checkRole';
import Email from '../blocks/Email';
import Quote from '../blocks/Quote';
import NumberBlock from '../blocks/Number';
import CallToAction from '../blocks/CallToAction';
const AllFields = {
const AllFields: PayloadCollectionConfig = {
slug: 'all-fields',
labels: {
singular: 'All Fields',
plural: 'All Fields',
},
// labels: {
// singular: 'All Fields',
// plural: 'All Fields',
// },
admin: {
useAsTitle: 'text',
},
@@ -100,6 +101,9 @@ const AllFields = {
}],
defaultValue: 'option-2',
required: true,
admin: {
readOnly: true,
},
},
{
type: 'row',
@@ -190,7 +194,6 @@ const AllFields = {
label: 'Blocks Content',
name: 'blocks',
minRows: 2,
singularLabel: 'Block',
blocks: [Email, NumberBlock, Quote, CallToAction],
localized: true,
required: true,
@@ -238,8 +241,34 @@ const AllFields = {
position: 'sidebar',
},
},
{
name: 'richText',
type: 'richText',
label: 'Rich Text',
required: true,
admin: {
elements: [
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'blockquote',
'ul',
'ol',
'link',
],
leaves: [
'bold',
'italic',
'underline',
'strikethrough',
],
},
},
],
timestamps: true,
};
module.exports = AllFields;
export default AllFields;

View File

@@ -0,0 +1,12 @@
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const AutoLabel: PayloadCollectionConfig = {
slug: 'auto-label',
fields: [{
name: 'text',
type: 'text',
label: 'Text',
}],
};
export default AutoLabel;

View File

@@ -1,26 +0,0 @@
const Email = require('../blocks/Email');
const Quote = require('../blocks/Quote');
const NumberBlock = require('../blocks/Number');
const CallToAction = require('../blocks/CallToAction');
module.exports = {
slug: 'blocks',
labels: {
singular: 'Blocks',
plural: 'Blocks',
},
access: {
read: () => true,
},
fields: [
{
name: 'layout',
label: 'Layout Blocks',
singularLabel: 'Block',
type: 'blocks',
blocks: [Email, NumberBlock, Quote, CallToAction],
localized: true,
required: true,
},
],
};

View File

@@ -0,0 +1,43 @@
import { PayloadCollectionConfig } from '../../src/collections/config/types';
import Email from '../blocks/Email';
import Quote from '../blocks/Quote';
import NumberBlock from '../blocks/Number';
import CallToAction from '../blocks/CallToAction';
const Blocks: PayloadCollectionConfig = {
slug: 'blocks',
labels: {
singular: 'Blocks',
plural: 'Blocks',
},
access: {
read: () => true,
},
fields: [
{
name: 'layout',
label: 'Layout Blocks',
labels: {
singular: 'Block',
plural: 'Blocks',
},
type: 'blocks',
blocks: [Email, NumberBlock, Quote, CallToAction],
localized: true,
required: true,
},
{
name: 'nonLocalizedLayout',
label: 'Non Localized Layout',
labels: {
singular: 'Layout',
plural: 'Layouts',
},
type: 'blocks',
blocks: [Email, NumberBlock, Quote, CallToAction],
required: true,
},
],
};
export default Blocks;

View File

@@ -1,4 +1,6 @@
const Code = {
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const Code: PayloadCollectionConfig = {
slug: 'code',
labels: {
singular: 'Code',
@@ -17,4 +19,4 @@ const Code = {
],
};
module.exports = Code;
export default Code;

View File

@@ -1,4 +1,6 @@
const Conditions = {
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const Conditions: PayloadCollectionConfig = {
slug: 'conditions',
labels: {
singular: 'Conditions',
@@ -50,4 +52,4 @@ const Conditions = {
],
};
module.exports = Conditions;
export default Conditions;

View File

@@ -1,5 +0,0 @@
import React from 'react';
const Description = () => <div className="description">fake description field</div>
export default Description;

View File

@@ -0,0 +1,5 @@
import React from 'react';
const Description: React.FC = () => <div className="description">fake description field</div>;
export default Description;

View File

@@ -1,9 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Props } from './types';
import './index.scss';
const Filter = ({ onChange, value }) => (
const Filter: React.FC<Props> = ({ onChange, value }) => (
<input
className="custom-description-filter"
type="text"
@@ -12,13 +12,4 @@ const Filter = ({ onChange, value }) => (
/>
);
Filter.defaultProps = {
value: '',
};
Filter.propTypes = {
onChange: PropTypes.func.isRequired,
value: PropTypes.string,
};
export default Filter;

View File

@@ -0,0 +1,4 @@
export type Props = {
value?: string
onChange: (value: string) => void
}

View File

@@ -1,14 +1,12 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Group } from '../../../../../../../field-types';
import { Group } from '../../../../../../../components/forms';
const CustomGroup = (props) => {
return (
<div className="custom-group">
<Group {...props} />
</div>
);
};
const CustomGroup: React.FC = (props) => (
<div className="custom-group">
<Group {...props} />
</div>
);
CustomGroup.defaultProps = {
value: '',

View File

@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import DefaultList from '../../../../../../src/client/components/views/collections/List/Default';
import DefaultList from '../../../../../../src/admin/components/views/collections/List/Default';
import './index.scss';

View File

@@ -1,13 +1,14 @@
const DescriptionField = require('./components/fields/Description/Field');
const DescriptionCell = require('./components/fields/Description/Cell');
const DescriptionFilter = require('./components/fields/Description/Filter');
const NestedArrayField = require('./components/fields/NestedArrayCustomField/Field');
const GroupField = require('./components/fields/Group/Field');
const NestedGroupField = require('./components/fields/NestedGroupCustomField/Field');
const NestedText1Field = require('./components/fields/NestedText1/Field');
const ListView = require('./components/views/List');
import { PayloadCollectionConfig } from '../../../src/collections/config/types';
import DescriptionField from './components/fields/Description/Field';
import DescriptionCell from './components/fields/Description/Cell';
import DescriptionFilter from './components/fields/Description/Filter';
import NestedArrayField from './components/fields/NestedArrayCustomField/Field';
import GroupField from './components/fields/Group/Field';
import NestedGroupField from './components/fields/NestedGroupCustomField/Field';
import NestedText1Field from './components/fields/NestedText1/Field';
import ListView from './components/views/List';
module.exports = {
const CustomComponents: PayloadCollectionConfig = {
slug: 'custom-components',
labels: {
singular: 'Custom Component',
@@ -27,14 +28,13 @@ module.exports = {
name: 'description',
label: 'Description',
type: 'textarea',
height: 100,
required: true,
localized: true,
admin: {
components: {
field: DescriptionField,
cell: DescriptionCell,
filter: DescriptionFilter,
Field: DescriptionField,
Cell: DescriptionCell,
Filter: DescriptionFilter,
},
},
},
@@ -49,7 +49,7 @@ module.exports = {
label: 'Nested Array Custom Field',
admin: {
components: {
field: NestedArrayField,
Field: NestedArrayField,
},
},
},
@@ -61,7 +61,7 @@ module.exports = {
type: 'group',
admin: {
components: {
field: GroupField,
Field: GroupField,
},
},
fields: [
@@ -71,7 +71,7 @@ module.exports = {
label: 'Nested Group Custom Field',
admin: {
components: {
field: NestedGroupField,
Field: NestedGroupField,
},
},
},
@@ -86,7 +86,7 @@ module.exports = {
type: 'text',
admin: {
components: {
field: NestedText1Field,
Field: NestedText1Field,
},
},
}, {
@@ -101,9 +101,9 @@ module.exports = {
admin: {
useAsTitle: 'title',
components: {
views: {
List: ListView,
},
List: ListView,
},
},
};
export default CustomComponents;

View File

@@ -0,0 +1,293 @@
import { PayloadCollectionConfig } from '../../src/collections/config/types';
import checkRole from '../access/checkRole';
import Email from '../blocks/Email';
import Quote from '../blocks/Quote';
import NumberBlock from '../blocks/Number';
import CallToAction from '../blocks/CallToAction';
const DefaultValues: PayloadCollectionConfig = {
slug: 'default-values',
labels: {
singular: 'Default Value Test',
plural: 'Default Value Tests',
},
admin: {
useAsTitle: 'text',
},
preview: (doc, token) => {
if (doc && doc.text) {
return `http://localhost:3000/previewable-posts/${doc.text.value}?preview=true&token=${token}`;
}
return null;
},
access: {
read: () => true,
},
fields: [
{
name: 'text',
type: 'text',
label: 'Text',
defaultValue: 'Default Value',
unique: true,
access: {
create: ({ req: { user } }) => checkRole(['admin'], user),
update: ({ req: { user } }) => checkRole(['admin'], user),
read: ({ req: { user } }) => Boolean(user),
},
},
{
name: 'image',
type: 'upload',
label: 'Image',
relationTo: 'media',
},
{
name: 'select',
label: 'Select',
type: 'select',
options: [{
value: 'option-1',
label: 'Option 1 Label',
}, {
value: 'option-2',
label: 'Option 2 Label',
}, {
value: 'option-3',
label: 'Option 3 Label',
}, {
value: 'option-4',
label: 'Option 4 Label',
}],
defaultValue: 'option-1',
},
{
name: 'selectMany',
label: 'Select w/ hasMany',
type: 'select',
options: [{
value: 'option-1',
label: 'Option 1 Label',
}, {
value: 'option-2',
label: 'Option 2 Label',
}, {
value: 'option-3',
label: 'Option 3 Label',
}, {
value: 'option-4',
label: 'Option 4 Label',
}],
defaultValue: ['option-1', 'option-4'],
hasMany: true,
},
{
name: 'radioGroupExample',
label: 'Radio Group Example',
type: 'radio',
options: [{
value: 'option-1',
label: 'Options 1 Label',
}, {
value: 'option-2',
label: 'Option 2 Label',
}, {
value: 'option-3',
label: 'Option 3 Label',
}],
defaultValue: 'option-2',
},
{
type: 'row',
fields: [
{
name: 'email',
label: 'Email',
type: 'email',
defaultValue: 'some@email.com',
}, {
name: 'number',
label: 'Number',
type: 'number',
defaultValue: 5,
},
],
},
{
type: 'group',
label: 'Group',
name: 'group',
defaultValue: {
nestedText1: 'neat',
},
fields: [
{
type: 'row',
fields: [
{
name: 'nestedText1',
label: 'Nested Text 1',
type: 'text',
defaultValue: 'nested default text 1',
}, {
name: 'nestedText2',
label: 'Nested Text 2',
type: 'text',
defaultValue: 'nested default text 2',
},
],
},
],
},
{
type: 'array',
label: 'Array',
name: 'array',
admin: {
readOnly: true,
},
defaultValue: [
{
arrayText1: 'Get out',
},
],
fields: [
{
type: 'row',
fields: [
{
name: 'arrayText1',
label: 'Array Text 1',
type: 'text',
admin: {
width: '50%',
},
defaultValue: 'default array text',
},
{
name: 'arrayText2',
label: 'Array Text 2',
type: 'text',
admin: {
width: '50%',
},
access: {
read: ({ req: { user } }) => Boolean(user),
update: ({ req: { user } }) => checkRole(['admin'], user),
},
},
],
},
{
type: 'text',
name: 'arrayText3',
label: 'Array Text 3',
admin: {
readOnly: true,
},
},
{
name: 'checkbox',
label: 'Checkbox',
type: 'checkbox',
defaultValue: true,
},
],
},
{
type: 'blocks',
label: 'Blocks Content',
name: 'blocks',
labels: {
singular: 'Block',
plural: 'Blocks',
},
blocks: [Email, NumberBlock, Quote, CallToAction],
localized: true,
admin: {
readOnly: true,
},
defaultValue: [
{
blockType: 'email',
testEmail: 'dev@payloadcms.com',
},
],
},
{
type: 'relationship',
label: 'Relationship to One Collection',
name: 'relationship',
relationTo: 'conditions',
},
{
type: 'relationship',
label: 'Relationship hasMany',
name: 'relationshipHasMany',
relationTo: 'localized-posts',
hasMany: true,
},
{
type: 'relationship',
label: 'Relationship to Multiple Collections',
name: 'relationshipMultipleCollections',
relationTo: ['localized-posts', 'conditions'],
},
{
type: 'textarea',
label: 'Textarea',
name: 'textarea',
defaultValue: 'my textarea text',
},
{
name: 'slug',
type: 'text',
label: 'Slug',
admin: {
position: 'sidebar',
},
localized: true,
unique: true,
defaultValue: 'my-slug',
},
{
name: 'checkbox',
type: 'checkbox',
label: 'Checkbox',
admin: {
position: 'sidebar',
},
defaultValue: true,
},
{
name: 'richText',
type: 'richText',
label: 'Rich Text',
admin: {
elements: [
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'blockquote',
'ul',
'ol',
'link',
],
leaves: [
'bold',
'italic',
'underline',
'strikethrough',
],
},
defaultValue: [{
children: [{ text: 'Cookin now' }],
}],
},
],
timestamps: true,
};
export default DefaultValues;

View File

@@ -1,4 +1,5 @@
const checkRole = require('../access/checkRole');
import { PayloadCollectionConfig } from '../../src/collections/config/types';
import checkRole from '../access/checkRole';
const access = ({ req: { user } }) => {
const isAdmin = checkRole(['admin'], user);
@@ -18,7 +19,7 @@ const access = ({ req: { user } }) => {
return false;
};
module.exports = {
const Files: PayloadCollectionConfig = {
slug: 'files',
labels: {
singular: 'File',
@@ -65,3 +66,5 @@ module.exports = {
useAsTitle: 'filename',
},
};
export default Files;

View File

@@ -1,4 +1,6 @@
const HiddenFields = {
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const HiddenFields: PayloadCollectionConfig = {
slug: 'hidden-fields',
labels: {
singular: 'Hidden Fields',
@@ -15,7 +17,9 @@ const HiddenFields = {
name: 'hiddenAdmin',
type: 'text',
label: 'Hidden on Admin',
hidden: 'admin',
admin: {
hidden: true,
},
required: true,
},
{
@@ -28,4 +32,4 @@ const HiddenFields = {
],
};
module.exports = HiddenFields;
export default HiddenFields;

View File

@@ -1,5 +1,8 @@
/* eslint-disable no-param-reassign */
module.exports = {
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const Hooks: PayloadCollectionConfig = {
slug: 'hooks',
labels: {
singular: 'Hook',
@@ -82,10 +85,11 @@ module.exports = {
name: 'description',
label: 'Description',
type: 'textarea',
height: 100,
required: true,
localized: true,
},
],
timestamps: true,
};
export default Hooks;

View File

@@ -1,4 +1,6 @@
const LocalOperations = {
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const LocalOperations: PayloadCollectionConfig = {
slug: 'local-operations',
labels: {
singular: 'Local Operation',
@@ -33,4 +35,4 @@ const LocalOperations = {
],
};
module.exports = LocalOperations;
export default LocalOperations;

View File

@@ -1,4 +1,6 @@
module.exports = {
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const LocalizedPosts: PayloadCollectionConfig = {
slug: 'localized-posts',
labels: {
singular: 'Localized Post',
@@ -11,6 +13,7 @@ module.exports = {
'priority',
'createdAt',
],
enableRichTextRelationship: true,
},
access: {
read: () => true,
@@ -42,7 +45,6 @@ module.exports = {
name: 'description',
label: 'Description',
type: 'textarea',
height: 100,
required: true,
localized: true,
},
@@ -56,3 +58,5 @@ module.exports = {
],
timestamps: true,
};
export default LocalizedPosts;

View File

@@ -1,4 +1,6 @@
const LocalizedArrays = {
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const LocalizedArrays: PayloadCollectionConfig = {
slug: 'localized-arrays',
labels: {
singular: 'Localized Array',
@@ -47,4 +49,4 @@ const LocalizedArrays = {
timestamps: true,
};
module.exports = LocalizedArrays;
export default LocalizedArrays;

View File

@@ -1,7 +1,6 @@
const path = require('path');
const checkRole = require('../access/checkRole');
import { PayloadCollectionConfig } from '../../src/collections/config/types';
module.exports = {
const Media: PayloadCollectionConfig = {
slug: 'media',
labels: {
singular: 'Media',
@@ -10,6 +9,9 @@ module.exports = {
access: {
read: () => true,
},
admin: {
enableRichTextRelationship: true,
},
upload: {
staticURL: '/media',
staticDir: './media',
@@ -41,26 +43,9 @@ module.exports = {
type: 'text',
required: true,
localized: true,
hooks: {
afterRead: [
({ value }) => `${value} alt`,
],
},
},
{
name: 'sizes',
fields: [
{
name: 'icon',
access: {
read: ({ req: { user } }) => {
const result = checkRole(['admin'], user);
return result;
},
},
},
],
},
],
timestamps: true,
};
export default Media;

View File

@@ -1,4 +1,6 @@
const NestedArray = {
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const NestedArray: PayloadCollectionConfig = {
slug: 'nested-arrays',
labels: {
singular: 'Nested Array',
@@ -23,7 +25,7 @@ const NestedArray = {
{
name: 'parentIdentifier',
label: 'Parent Identifier',
defaultValue: '',
defaultValue: ' ',
type: 'text',
required: true,
},
@@ -67,4 +69,4 @@ const NestedArray = {
timestamps: true,
};
module.exports = NestedArray;
export default NestedArray;

View File

@@ -1,4 +1,6 @@
module.exports = {
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const Preview: PayloadCollectionConfig = {
slug: 'previewable-post',
labels: {
singular: 'Previewable Post',
@@ -27,3 +29,5 @@ module.exports = {
],
timestamps: true,
};
export default Preview;

View File

@@ -1,8 +1,9 @@
const checkRole = require('../access/checkRole');
import checkRole from '../access/checkRole';
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const access = ({ req: { user } }) => checkRole(['admin'], user);
module.exports = {
const PublicUsers: PayloadCollectionConfig = {
slug: 'public-users',
labels: {
singular: 'Public User',
@@ -32,8 +33,9 @@ module.exports = {
},
auth: {
tokenExpiration: 300,
emailVerification: true,
generateVerificationUrl: (req, token) => `http://localhost:3000/api/verify?token=${token}`,
verify: true,
maxLoginAttempts: 5,
lockTime: 600 * 1000, // lock time in ms
cookies: {
secure: process.env.NODE_ENV === 'production',
sameSite: 'Lax',
@@ -55,3 +57,5 @@ module.exports = {
],
timestamps: true,
};
export default PublicUsers;

View File

@@ -1,20 +0,0 @@
module.exports = {
slug: 'relationship-a',
access: {
read: () => true,
},
labels: {
singular: 'Relationship A',
plural: 'Relationship A',
},
fields: [
{
name: 'post',
label: 'Post',
type: 'relationship',
relationTo: 'relationship-b',
localized: false,
},
],
timestamps: true,
};

View File

@@ -0,0 +1,40 @@
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const RelationshipA: PayloadCollectionConfig = {
slug: 'relationship-a',
access: {
read: () => true,
},
labels: {
singular: 'Relationship A',
plural: 'Relationship A',
},
fields: [
{
name: 'post',
label: 'Post',
type: 'relationship',
relationTo: 'relationship-b',
localized: true,
},
// {
// name: 'LocalizedPost',
// label: 'Localized Post',
// type: 'relationship',
// relationTo: 'localized-posts',
// hasMany: true,
// localized: true,
// },
{
name: 'postLocalizedMultiple',
label: 'Localized Post Multiple',
type: 'relationship',
relationTo: ['localized-posts', 'all-fields'],
hasMany: true,
localized: true,
},
],
timestamps: true,
};
export default RelationshipA;

View File

@@ -1,4 +1,6 @@
module.exports = {
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const RelationshipB: PayloadCollectionConfig = {
slug: 'relationship-b',
access: {
read: () => true,
@@ -19,3 +21,5 @@ module.exports = {
],
timestamps: true,
};
export default RelationshipB;

View File

@@ -1,42 +0,0 @@
const Button = require('../client/components/richText/elements/Button');
const PurpleBackground = require('../client/components/richText/leaves/PurpleBackground');
const RichText = {
slug: 'rich-text',
labels: {
singular: 'Rich Text',
plural: 'Rich Texts',
},
fields: [
{
name: 'richText',
type: 'richText',
label: 'Rich Text',
required: true,
admin: {
elements: [
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
// 'blockquote',
Button,
'ul',
'ol',
'link',
],
leaves: [
'bold',
'italic',
PurpleBackground,
// 'underline',
// 'strikethrough',
],
},
},
],
};
module.exports = RichText;

View File

@@ -0,0 +1,38 @@
import Button from '../client/components/richText/elements/Button';
import PurpleBackground from '../client/components/richText/leaves/PurpleBackground';
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const RichText: PayloadCollectionConfig = {
slug: 'rich-text',
labels: {
singular: 'Rich Text',
plural: 'Rich Texts',
},
fields: [
{
name: 'defaultRichText',
type: 'richText',
label: 'Default Rich Text',
required: true,
},
{
name: 'customRichText',
type: 'richText',
label: 'Customized Rich Text',
required: true,
admin: {
elements: [
'h2',
'h3',
Button,
],
leaves: [
'bold',
PurpleBackground,
],
},
},
],
};
export default RichText;

View File

@@ -1,4 +1,6 @@
const Select = {
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const Select: PayloadCollectionConfig = {
slug: 'select',
labels: {
singular: 'Select',
@@ -40,4 +42,4 @@ const Select = {
],
};
module.exports = Select;
export default Select;

View File

@@ -1,6 +1,7 @@
const checkRole = require('../access/checkRole');
import { PayloadCollectionConfig } from '../../src/collections/config/types';
import checkRole from '../access/checkRole';
module.exports = {
const StrictAccess: PayloadCollectionConfig = {
slug: 'strict-access',
labels: {
singular: 'Strict Access',
@@ -71,3 +72,5 @@ module.exports = {
],
timestamps: true,
};
export default StrictAccess;

View File

@@ -1,4 +1,6 @@
module.exports = {
import { PayloadCollectionConfig } from '../../src/collections/config/types';
const Validations: PayloadCollectionConfig = {
slug: 'validations',
labels: {
singular: 'Validation',
@@ -106,5 +108,6 @@ module.exports = {
],
},
],
timestamps: true,
};
export default Validations;

View File

@@ -1,8 +1,9 @@
const checkRole = require('../access/checkRole');
const Quote = require('../blocks/Quote');
const CallToAction = require('../blocks/CallToAction');
import checkRole from '../access/checkRole';
import Quote from '../blocks/Quote';
import CallToAction from '../blocks/CallToAction';
import { PayloadGlobalConfig } from '../../src/globals/config/types';
module.exports = {
export default {
slug: 'blocks-global',
label: 'Blocks Global',
access: {
@@ -18,4 +19,4 @@ module.exports = {
localized: true,
},
],
};
} as PayloadGlobalConfig;

View File

@@ -1,6 +1,7 @@
const checkRole = require('../access/checkRole');
import { PayloadGlobalConfig } from '../../src/globals/config/types';
import checkRole from '../access/checkRole';
module.exports = {
export default {
slug: 'global-with-access',
label: 'Global with Strict Access',
access: {
@@ -31,4 +32,4 @@ module.exports = {
required: true,
},
],
};
} as PayloadGlobalConfig;

View File

@@ -1,6 +1,7 @@
const checkRole = require('../access/checkRole');
import { PayloadGlobalConfig } from '../../src/globals/config/types';
import checkRole from '../access/checkRole';
module.exports = {
export default {
slug: 'navigation-array',
label: 'Navigation Array',
access: {
@@ -24,4 +25,4 @@ module.exports = {
}],
},
],
};
} as PayloadGlobalConfig;

14
demo/index.js Normal file
View File

@@ -0,0 +1,14 @@
const babelConfig = require('../babel.config');
require('@babel/register')({
...babelConfig,
extensions: ['.ts', '.tsx', '.js', '.jsx'],
env: {
development: {
sourceMaps: 'inline',
retainLines: true,
},
},
});
require('./server.ts');

View File

@@ -1,119 +0,0 @@
const Admin = require('./collections/Admin');
const AllFields = require('./collections/AllFields');
const Code = require('./collections/Code');
const Conditions = require('./collections/Conditions');
const CustomComponents = require('./collections/CustomComponents');
const File = require('./collections/File');
const Blocks = require('./collections/Blocks');
const HiddenFields = require('./collections/HiddenFields');
const Hooks = require('./collections/Hooks');
const Localized = require('./collections/Localized');
const LocalizedArray = require('./collections/LocalizedArray');
const LocalOperations = require('./collections/LocalOperations');
const Media = require('./collections/Media');
const NestedArrays = require('./collections/NestedArrays');
const Preview = require('./collections/Preview');
const PublicUsers = require('./collections/PublicUsers');
const RelationshipA = require('./collections/RelationshipA');
const RelationshipB = require('./collections/RelationshipB');
const RichText = require('./collections/RichText');
const Select = require('./collections/Select');
const StrictPolicies = require('./collections/StrictPolicies');
const Validations = require('./collections/Validations');
const BlocksGlobal = require('./globals/BlocksGlobal');
const NavigationArray = require('./globals/NavigationArray');
const GlobalWithStrictAccess = require('./globals/GlobalWithStrictAccess');
module.exports = {
admin: {
user: 'admins',
// indexHTML: 'custom-index.html',
meta: {
titleSuffix: '- Payload Demo',
// ogImage: '/static/find-image-here.jpg',
// favicon: '/img/whatever.png',
},
disable: false,
components: {
// nav: () => (
// <div>Hello</div>
// ),
},
},
email: {
fromName: 'Payload',
fromAddress: 'hello@payloadcms.com',
},
collections: [
Admin,
AllFields,
Code,
Conditions,
CustomComponents,
File,
Blocks,
HiddenFields,
Hooks,
Localized,
LocalizedArray,
LocalOperations,
Media,
NestedArrays,
Preview,
PublicUsers,
RelationshipA,
RelationshipB,
RichText,
Select,
StrictPolicies,
Validations,
],
globals: [
NavigationArray,
GlobalWithStrictAccess,
BlocksGlobal,
],
cookiePrefix: 'payload',
serverURL: 'http://localhost:3000',
cors: [
'http://localhost',
'http://localhost:3000',
'http://localhost:8080',
'http://localhost:8081',
],
csrf: [
'http://localhost:3000',
'https://other-app-here.com',
],
routes: {
api: '/api',
admin: '/admin',
graphQL: '/graphql',
graphQLPlayground: '/graphql-playground',
},
defaultDepth: 2,
compression: {},
paths: {
scss: 'client/scss/overrides.scss',
},
graphQL: {
mutations: {},
queries: {},
},
localization: {
locales: [
'en',
'es',
],
defaultLocale: 'en',
fallback: true,
},
productionGraphQLPlayground: false,
hooks: {
afterError: () => {
console.error('global error config handler');
},
},
webpack: (config) => config,
};

140
demo/payload.config.ts Normal file
View File

@@ -0,0 +1,140 @@
import path from 'path';
import { buildConfig } from '../src/config/build';
import Admin from './collections/Admin';
import AllFields from './collections/AllFields';
import AutoLabel from './collections/AutoLabel';
import Code from './collections/Code';
import Conditions from './collections/Conditions';
import CustomComponents from './collections/CustomComponents';
import File from './collections/File';
import Blocks from './collections/Blocks';
import DefaultValues from './collections/DefaultValues';
import HiddenFields from './collections/HiddenFields';
import Hooks from './collections/Hooks';
import Localized from './collections/Localized';
import LocalizedArray from './collections/LocalizedArray';
import LocalOperations from './collections/LocalOperations';
import Media from './collections/Media';
import NestedArrays from './collections/NestedArrays';
import Preview from './collections/Preview';
import PublicUsers from './collections/PublicUsers';
import RelationshipA from './collections/RelationshipA';
import RelationshipB from './collections/RelationshipB';
import RichText from './collections/RichText';
import Select from './collections/Select';
import StrictPolicies from './collections/StrictPolicies';
import Validations from './collections/Validations';
import BlocksGlobal from './globals/BlocksGlobal';
import NavigationArray from './globals/NavigationArray';
import GlobalWithStrictAccess from './globals/GlobalWithStrictAccess';
export default buildConfig({
cookiePrefix: 'payload',
serverURL: 'http://localhost:3000',
admin: {
user: 'admins',
indexHTML: path.resolve(__dirname, './client/index.html'),
// meta: {
// titleSuffix: '- Payload Demo',
// // ogImage: '/static/find-image-here.jpg',
// // favicon: '/img/whatever.png',
// },
disable: false,
components: {
// Nav: () => (
// <div>Hello</div>
// ),
},
},
email: {
transport: 'mock',
fromName: 'Payload',
fromAddress: 'hello@payloadcms.com',
},
collections: [
Admin,
AllFields,
AutoLabel,
Code,
Conditions,
CustomComponents,
File,
DefaultValues,
Blocks,
HiddenFields,
Hooks,
Localized,
LocalizedArray,
LocalOperations,
Media,
NestedArrays,
Preview,
PublicUsers,
RelationshipA,
RelationshipB,
RichText,
Select,
StrictPolicies,
Validations,
],
globals: [
NavigationArray,
GlobalWithStrictAccess,
BlocksGlobal,
],
cors: [
'http://localhost',
'http://localhost:3000',
'http://localhost:8080',
'http://localhost:8081',
],
csrf: [
'http://localhost:3000',
'https://other-app-here.com',
],
routes: {
api: '/api',
admin: '/admin',
graphQL: '/graphql',
graphQLPlayground: '/graphql-playground',
},
defaultDepth: 2,
compression: {},
paths: {
scss: path.resolve(__dirname, './client/scss/overrides.scss'),
},
graphQL: {
maxComplexity: 1000,
mutations: {}, // TODO: needs typing
queries: {}, // TODO: needs typing
disablePlaygroundInProduction: true,
},
// rateLimit: {
// window: 15 * 60 * 100,
// max: 100,
// trustProxy: true,
// skip: (req) => req.ip === '127.0.0.1',
// },
maxDepth: 10,
localization: {
locales: [
'en',
'es',
],
defaultLocale: 'en',
fallback: true,
},
hooks: {
afterError: (err) => {
console.error('global error config handler', err);
},
},
upload: {
limits: {
fileSize: 10000000, // 10MB
},
},
webpack: (config) => config,
});

View File

@@ -1,56 +0,0 @@
/* eslint-disable no-console */
const express = require('express');
const path = require('path');
const payload = require('../src');
const logger = require('../src/utilities/logger')();
const expressApp = express();
expressApp.use('/static', express.static(path.resolve(__dirname, 'client/static')));
payload.init({
email: {
transport: 'mock',
},
secret: 'SECRET_KEY',
mongoURL: 'mongodb://localhost/payload',
express: expressApp,
onInit: () => {
logger.info('Payload is initialized');
// console.log('Payload is initialized');
},
});
const externalRouter = express.Router();
externalRouter.use(payload.authenticate);
externalRouter.get('/', (req, res) => {
if (req.user) {
return res.send(`Authenticated successfully as ${req.user.email}.`);
}
return res.send('Not authenticated');
});
expressApp.use('/external-route', externalRouter);
exports.start = (cb) => {
const server = expressApp.listen(3000, async () => {
logger.info(`listening on ${3000}...`);
const creds = await payload.getMockEmailCredentials();
logger.info(`Mock email account username: ${creds.user}`);
logger.info(`Mock email account password: ${creds.pass}`);
logger.info(`Log in to mock email provider at ${creds.web}`);
if (cb) cb();
});
return server;
};
// when server.js is launched directly
if (module.id === require.main.id) {
exports.start();
}

35
demo/server.ts Normal file
View File

@@ -0,0 +1,35 @@
/* eslint-disable no-console */
import express from 'express';
import path from 'path';
import payload from '../src';
const expressApp = express();
expressApp.use('/static', express.static(path.resolve(__dirname, 'client/static')));
payload.init({
secret: 'SECRET_KEY',
mongoURL: 'mongodb://localhost/payload',
express: expressApp,
onInit: (app) => {
app.logger.info('Payload Demo Initialized');
},
});
const externalRouter = express.Router();
externalRouter.use(payload.authenticate);
externalRouter.get('/', (req, res) => {
if (req.user) {
return res.send(`Authenticated successfully as ${req.user.email}.`);
}
return res.send('Not authenticated');
});
expressApp.use('/external-route', externalRouter);
expressApp.listen(3000, async () => {
payload.logger.info(`listening on ${3000}...`);
});

View File

@@ -0,0 +1,38 @@
---
title: Access Control Config
label: Config
order: 10
---
Access can be configured at a Collection-level or field-level within your Collection configuration.
```js
// Collection config
module.exports = {
slug: 'public-user',
// highlight-start
access: {
create: () => true,
read: () => true,
update: () => true,
delete: () => true,
admin: () => true,
},
// highlight-end
fields: [
{
name: 'lockedDownField',
label: 'Locked Down',
type: 'text'
// highlight-start
access: {
create: () => true,
read: () => true,
update: () => true,
delete: () => true,
},
// highlight-end
};
],
}
```

View File

@@ -0,0 +1,7 @@
---
title: Access Control Examples
label: Examples
order: 20
---
Show examples of how to write access control functions.

View File

@@ -0,0 +1,9 @@
---
title: Accessing the User
label: Accessing the User
order: 40
---
Talk about how to access the User in custom code like hooks and access control. The User is on the req.
Show code examples.

View File

@@ -0,0 +1,18 @@
---
title: Authentication Config
label: Config
order: 10
---
Talk about how to configure authentication here.
Need to cover:
1. What collection to use for Admin panel and how there can only be one
1. Can have multiple auth collections
1. Token expiration
1. Email verification
1. Security (max login, lock time)
1. API keys
1. Depth to populate (performance impact)
1. Cookie settings (HTTP only discussion)

View File

@@ -0,0 +1,43 @@
---
title: Authentication Operations
label: Operations
order: 30
---
Talk about Auth operations here.
#### Me
Returns null or logged in user with token (useful for HTTP only)
#### Create operation modifications
Discuss if verification is required, etc etc
#### Init
Checks if there have been users created, checks Admin access
#### Login
HTTP-only cookies, token response. Discuss max login attempts
#### Logout
Removes HTTP-only cookie
#### Refresh
Refreshes token (requires valid token)
#### Register First User
Allows for anyone to register first user through UI
#### Forgot Password
Takes an email, sends email to that address. Discuss how to customize email
#### Access
Shows what the user can and cant do.

View File

@@ -0,0 +1,7 @@
---
title: Authentication Security
label: Security
order: 20
---
Talk about how Payload securely authenticates here.

View File

@@ -0,0 +1,7 @@
---
title: Using the Payload Auth Middleware
label: Using the Middleware
order: 50
---
Talk about how to use `payload.authenticate()` outside of Payload - show examples

View File

@@ -0,0 +1,7 @@
---
title: Custom Components
label: Overview
order: 10
---
Talk about how to build custom components. Show a list of all components that can be swapped out.

View File

@@ -0,0 +1,7 @@
---
title: Block Configs
label: Blocks
order: 40
---
Talk about how to write block configs here.

View File

@@ -0,0 +1,20 @@
---
title: Collection Configuration
label: Collections
order: 20
---
Talk about how to write collection configs here.
TODO: What collections are and what they represent
### Stand-alone file
```js
module.exports = {
slug: 'customer',
labels: {
singular: 'Customer',
plural: 'Customers',
}
}

View File

@@ -0,0 +1,7 @@
---
title: Global Configs
label: Globals
order: 30
---
Talk about how to write Globals configs here.

View File

@@ -0,0 +1,7 @@
---
title: The Main Config
label: Main
order: 10
---
Talk about how to write the main config here.

298
docs/Fields/overview.mdx Normal file
View File

@@ -0,0 +1,298 @@
---
title: Fields Overview
label: Overview
order: 10
---
<Banner type="info">
Fields are the building blocks of Payload. Collections and Globals both use Fields to define the shape of the data that they store. Payload offers a wide-array of field-types - both simple and complex.
</Banner>
## Field types
The `type` property on a field determines how the input will be rendered in the admin interface, what values it can accept, and how it is presented in the API.
```js
// Collection config
{
fields: [
{
name: 'my-field',
type: 'text', // highlight-line
label: 'Text',
}
]
}
```
### Simple Types
#### `text`
Plain text
#### `textarea`
Large blocks of text. No formatting.
#### `number`
Simple number input
#### `checkbox`
Boolean value that renders a checkbox
#### `date`
Renders date-picker
#### `email`
Email. Includes validation.
#### `code`
Monospaced code block
#### `richText`
Large formatted text. Includes rich text editor in the admin interface.
#### `select`
Renders a select box with any number of options
Options:
- `hasMany` - Allows for multiple options to be selected
```js
{
name: 'select',
label: 'Select',
type: 'select',
hasMany: true // Optional
options: [
{
value: 'option-1',
label: 'Option 1 Label',
}, {
value: 'option-2',
label: 'Option 2 Label',
},
],
},
```
#### `radio`
```js
{
name: 'radioGroup',
label: 'Radio Group Example',
type: 'radio',
options: [
{
value: 'option-1',
label: 'Options 1 Label',
},
{
value: 'option-2',
label: 'Option 2 Label',
},
],
},
```
### Complex Types
More powerful types but require more complex configuration
#### `upload`
Allows file and image upload. Useful for uploaded assets that can be referenced and re-used.
_TODO: Link to Upload configuration docs_
```js
{
name: 'image',
type: 'upload',
label: 'Image',
relationTo: 'media', // A collection with the `upload` properties configured
}
```
#### `row`
Rows allow for deeper nesting of values. They have their own set of fields.
```js
{
type: 'row',
fields: [
{
name: 'text',
label: 'Text',
type: 'text',
},
{
name: 'number',
label: 'Number',
type: 'number',
},
],
}
```
#### `array`
An array of the specified fields
Options:
- `minRows` - Minimum number of items required
- `maxRows` - Maximum number of items allowed
```js
{
name: 'array',
label: 'Array',
type: 'array',
minRows: 2, // Optional
maxRows: 4, // Optional
fields: [
{
name: 'textField',
label: 'Text Field',
type: 'text'
},
{
name: 'checkbox',
label: 'Checkbox',
type: 'checkbox'
}
]
}
```
#### `group`
A way to group related fields together. They will be rendered as a group in the admin interface.
```js
{
type: 'group',
label: 'Group',
name: 'group',
fields: [
{
type: 'row',
fields: [
{
name: 'nestedText1',
label: 'Nested Text 1',
type: 'text',
}, {
name: 'nestedText2',
label: 'Nested Text 2',
type: 'text',
},
],
},
],
},
```
#### `blocks`
Repeat any type of content any number of times
The `blocks` property takes an array of the allowed fields
_TODO: Link to more powerful and complex examples_
Options:
- `minRows` - Minimum number of items required
- `maxRows` - Maximum number of items allowed
```js
{
name: 'page',
type: 'blocks',
label: 'Page',
labels: {
singular: 'Page',
plural: 'Pages',
},
minRows: 2, // Optional
maxRows: 4, // Optional
blocks: [
{
slug: 'quote'
label: 'Quote',
type: 'text'
},
{
slug: 'testimonial',
label: 'Testimonial',
type: 'textarea'
},
{
slug: 'cta',
label: 'Call To Action',
type: 'text'
}
],
}
```
## Common Options
Most fields have the ability to use the following options
#### `defaultValue`
Initial value for the field
#### `required`
`true/false` value if the field is required to be populated
#### `localized`
`true/false` value to enable localization on the field
#### `admin`
The `admin` is an optional object with properties that specify how the field should be represented in the admin interface.
Properties:
- `position` - If specified as `sidebar`, the field will show in the admin interface's sidebar
- `width` - A percentage value ie. `50%` that will control the max-width of the field
- `readOnly` - `true/false` to set the field to read-only after it is saved
### Common Options Example
```js
// Collection config
{
fields: [
{
name: 'my-field',
type: 'text',
label: 'Text'
// highlight-start
admin: {
position: 'sidebar',
width: '50%',
readOnly: true,
}
// highlight-end
}
]
}
```

11
docs/GraphQL/config.mdx Normal file
View File

@@ -0,0 +1,11 @@
---
title: GraphQL Overview
label: Overview
order: 10
---
Go over GraphQL configuration options.
- Naming conventions
- List of all queries and mutations w/ examples
- Context

View File

@@ -0,0 +1,7 @@
---
title: Adding your own Queries and Mutations
label: Custom Queries and Mutations
order: 20
---
Talk about how to add your own queries and mutations.

253
docs/Guides/blog-api.mdx Normal file
View File

@@ -0,0 +1,253 @@
---
title: Blog API From Scratch
label: Blog API
order: 20
---
In this guide, we will be creating a Blog API from scratch.
Prerequisites:
- Node
- npm or yarn
- MongoDB server
## Initial Setup
Let's get started by creating a project in a blank directory
```sh
yarn init -y
```
We then will install Payload and Express
```sh
yarn add payload express
```
### Server
Create a file named `server.js` in the root folder with the following contents
```js
const express = require('express');
const app = express();
app.listen(3000, async () => {
console.log('Express is now listening for incoming connections on port 3000.');
});
```
This is a basic Express application. Now let's pull in Payload and fill in the `init` parameters. `secret` and `mongoURL` can be changed as needed.
```js
const express = require('express');
const payload = require('payload'); // highlight-line
const app = express();
// highlight-start
payload.init({
secret: 'SECRET_KEY',
mongoURL: 'mongodb://localhost/payload-blog',
express: app,
})
// highlight-end
app.listen(3000, async () => {
console.log('Express is now listening for incoming connections on port 3000.');
});
```
### Payload Configuration
Next, let's get some basics put into our `payload.config.js` file
```js
module.exports = {
serverURL: 'http://localhost:3000',
collections: [],
}
```
#### Collections
We'll need a few different collections for our blog:
- Posts
- Categories
- Tags
The Posts will have the ability to have a single category and multiple tags
Let's create a `collections` directory and create a `.js` file for each
```js:title=Posts.js
module.exports = {
slug: 'posts',
labels: {
singular: 'Post',
plural: 'Posts',
},
admin: {
useAsTitle: 'title',
},
fields: [
{
name: 'title',
label: 'Title',
type: 'text'
},
{
name: 'content',
label: 'Content',
type: 'textarea',
},
{
name: 'category',
label: 'Category',
type: 'relationship',
relationTo: 'categories', // Categories Slug // highlight-line
},
{
name: 'tags',
label: 'Tags',
type: 'relationship',
relationTo: 'tags', // Tags Slug // highlight-line
hasMany: true, // Allow multiple tags per post
},
]
};
```
```js:title=Categories.js
module.exports = {
slug: 'categories',
labels: {
singular: 'Category',
plural: 'Categories',
},
admin: {
useAsTitle: 'name',
},
fields: [
{
name: 'name',
label: 'Name',
type: 'text',
},
],
};
```
```js:title=Tags.js
module.exports = {
slug: 'tags',
labels: {
singular: 'Tag',
plural: 'Tags',
},
admin: {
useAsTitle: 'name',
},
fields: [
{
name: 'name',
label: 'Name',
type: 'text',
},
],
};
```
Once these are created, we can pull them into the `collections` array in our `payload.config.js`
```js:title=payload.config.js
const Admins = require('./collections/Admins');
// highlight-start
const Posts = require('./collections/Posts');
const Categories = require('./collections/Categories');
const Tags = require('./collections/Tags');
// highlight-end
module.exports = {
serverURL: 'http://localhost:3000',
admin: {
user: 'admins',
},
collections: [
Admins,
// highlight-start
Posts,
Categories,
Tags
// highlight-end
],
}
```
### Create Content
**TODO: Should a guide like this use the Admin interface or `curl`?**
Navigate to the admin interface at `http://localhost:3000/admin` and create your first user.
Then create some Categories, Tags, and a Post.
Let's use `curl` to quickly create some data. The following commands will create 2 tags and 1 category.
```sh
curl -H "Content-Type: application/json" -X POST -d '{"name": "JavaScript"}' http://localhost:3000/api/tags
curl -H "Content-Type: application/json" -X POST -d '{"name": "TypeScript"}' http://localhost:3000/api/tags
curl -H "Content-Type: application/json" -X POST -d '{"name": "Code"}' http://localhost:3000/api/categories
```
We'll then make a request to create a Post, this will inclue a relationship to the category and tags created previously.
TODO: Somehow retrieve tag and category IDs then include them in a request to create a Post
Once complete, navigate to `http://localhost:3000/api/posts`, and you should see something similar to the following:
```js
{
"docs": [
{
"tags": [
{
"name": "TypeScript",
"createdAt": "2020-11-13T11:48:05.993Z",
"updatedAt": "2020-11-13T11:48:05.993Z",
"id": "5fae72758315da656fb3a8f0"
},
{
"name": "JavaScript",
"createdAt": "2020-11-13T11:48:00.064Z",
"updatedAt": "2020-11-13T11:48:00.064Z",
"id": "5fae72708315da656fb3a8ef"
}
],
"title": "My Title",
"content": "This is some content",
"category": {
"name": "Code",
"createdAt": "2020-11-13T11:48:10.351Z",
"updatedAt": "2020-11-13T11:48:36.358Z",
"id": "5fae727a8315da656fb3a8f1"
},
"createdAt": "2020-11-13T11:50:14.312Z",
"updatedAt": "2020-11-13T11:50:14.312Z",
"id": "5fae72f68e314b67609e05d1"
}
],
"totalDocs": 1,
"limit": 10,
"totalPages": 1,
"page": 1,
"pagingCounter": 1,
"hasPrevPage": false,
"hasNextPage": false,
"prevPage": null,
"nextPage": null
}
```

Some files were not shown because too many files have changed in this diff Show More