payload 3.0.0-beta.45 → 3.0.0-beta.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/admin/RichText.d.ts +117 -17
  2. package/dist/admin/RichText.d.ts.map +1 -1
  3. package/dist/admin/RichText.js.map +1 -1
  4. package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
  5. package/dist/auth/operations/forgotPassword.js +1 -2
  6. package/dist/auth/operations/forgotPassword.js.map +1 -1
  7. package/dist/auth/sendVerificationEmail.d.ts.map +1 -1
  8. package/dist/auth/sendVerificationEmail.js +1 -2
  9. package/dist/auth/sendVerificationEmail.js.map +1 -1
  10. package/dist/bin/generateTypes.d.ts.map +1 -1
  11. package/dist/bin/generateTypes.js +9 -0
  12. package/dist/bin/generateTypes.js.map +1 -1
  13. package/dist/collections/operations/create.d.ts.map +1 -1
  14. package/dist/collections/operations/create.js +1 -2
  15. package/dist/collections/operations/create.js.map +1 -1
  16. package/dist/fields/config/sanitize.d.ts.map +1 -1
  17. package/dist/fields/config/sanitize.js +0 -15
  18. package/dist/fields/config/sanitize.js.map +1 -1
  19. package/dist/fields/config/schema.js +1 -1
  20. package/dist/fields/config/schema.js.map +1 -1
  21. package/dist/fields/config/types.d.ts +14 -2
  22. package/dist/fields/config/types.d.ts.map +1 -1
  23. package/dist/fields/config/types.js.map +1 -1
  24. package/dist/fields/getFieldPaths.d.ts +10 -0
  25. package/dist/fields/getFieldPaths.d.ts.map +1 -0
  26. package/dist/fields/getFieldPaths.js +45 -0
  27. package/dist/fields/getFieldPaths.js.map +1 -0
  28. package/dist/fields/hooks/afterChange/index.d.ts +6 -0
  29. package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
  30. package/dist/fields/hooks/afterChange/index.js +2 -0
  31. package/dist/fields/hooks/afterChange/index.js.map +1 -1
  32. package/dist/fields/hooks/afterChange/promise.d.ts +9 -1
  33. package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
  34. package/dist/fields/hooks/afterChange/promise.js +67 -3
  35. package/dist/fields/hooks/afterChange/promise.js.map +1 -1
  36. package/dist/fields/hooks/afterChange/traverseFields.d.ts +3 -1
  37. package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
  38. package/dist/fields/hooks/afterChange/traverseFields.js +3 -1
  39. package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
  40. package/dist/fields/hooks/afterRead/index.d.ts +1 -1
  41. package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
  42. package/dist/fields/hooks/afterRead/index.js +3 -1
  43. package/dist/fields/hooks/afterRead/index.js.map +1 -1
  44. package/dist/fields/hooks/afterRead/promise.d.ts +9 -1
  45. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  46. package/dist/fields/hooks/afterRead/promise.js +129 -25
  47. package/dist/fields/hooks/afterRead/promise.js.map +1 -1
  48. package/dist/fields/hooks/afterRead/traverseFields.d.ts +3 -1
  49. package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
  50. package/dist/fields/hooks/afterRead/traverseFields.js +3 -1
  51. package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
  52. package/dist/fields/hooks/beforeChange/index.d.ts +1 -1
  53. package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
  54. package/dist/fields/hooks/beforeChange/index.js +3 -2
  55. package/dist/fields/hooks/beforeChange/index.js.map +1 -1
  56. package/dist/fields/hooks/beforeChange/promise.d.ts +9 -2
  57. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  58. package/dist/fields/hooks/beforeChange/promise.js +77 -10
  59. package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
  60. package/dist/fields/hooks/beforeChange/traverseFields.d.ts +4 -3
  61. package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
  62. package/dist/fields/hooks/beforeChange/traverseFields.js +4 -3
  63. package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
  64. package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
  65. package/dist/fields/hooks/beforeValidate/index.js +2 -0
  66. package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
  67. package/dist/fields/hooks/beforeValidate/promise.d.ts +3 -1
  68. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  69. package/dist/fields/hooks/beforeValidate/promise.js +69 -4
  70. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  71. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +3 -1
  72. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
  73. package/dist/fields/hooks/beforeValidate/traverseFields.js +3 -1
  74. package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
  75. package/package.json +2 -2
@@ -1,13 +1,113 @@
1
1
  import type { GenericLanguages, I18n, I18nClient } from '@payloadcms/translations';
2
2
  import type { JSONSchema4 } from 'json-schema';
3
3
  import type React from 'react';
4
+ import type { SanitizedCollectionConfig, TypeWithID } from '../collections/config/types.js';
4
5
  import type { SanitizedConfig } from '../config/types.js';
5
- import type { Field, FieldBase, RichTextField, Validate } from '../fields/config/types.js';
6
+ import type { Field, FieldAffectingData, RichTextField, Validate } from '../fields/config/types.js';
7
+ import type { SanitizedGlobalConfig } from '../globals/config/types.js';
6
8
  import type { PayloadRequestWithData, RequestContext } from '../types/index.js';
7
9
  import type { WithServerSidePropsComponentProps } from './elements/WithServerSideProps.js';
8
10
  export type RichTextFieldProps<Value extends object, AdapterProps, ExtraFieldProperties = {}> = Omit<RichTextField<Value, AdapterProps, ExtraFieldProperties>, 'type'> & {
9
11
  path?: string;
10
12
  };
13
+ export type AfterReadRichTextHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {
14
+ currentDepth?: number;
15
+ depth?: number;
16
+ draft?: boolean;
17
+ fallbackLocale?: string;
18
+ fieldPromises?: Promise<void>[];
19
+ /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */
20
+ findMany?: boolean;
21
+ flattenLocales?: boolean;
22
+ locale?: string;
23
+ /** A string relating to which operation the field type is currently executing within. */
24
+ operation?: 'create' | 'delete' | 'read' | 'update';
25
+ overrideAccess?: boolean;
26
+ populationPromises?: Promise<void>[];
27
+ showHiddenFields?: boolean;
28
+ triggerAccessControl?: boolean;
29
+ triggerHooks?: boolean;
30
+ };
31
+ export type AfterChangeRichTextHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {
32
+ /** A string relating to which operation the field type is currently executing within. */
33
+ operation: 'create' | 'update';
34
+ /** The document before changes were applied. */
35
+ previousDoc?: TData;
36
+ /** The sibling data of the document before changes being applied. */
37
+ previousSiblingDoc?: TData;
38
+ /** The previous value of the field, before changes */
39
+ previousValue?: TValue;
40
+ };
41
+ export type BeforeValidateRichTextHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {
42
+ /** A string relating to which operation the field type is currently executing within. */
43
+ operation: 'create' | 'update';
44
+ overrideAccess?: boolean;
45
+ /** The sibling data of the document before changes being applied. */
46
+ previousSiblingDoc?: TData;
47
+ /** The previous value of the field, before changes */
48
+ previousValue?: TValue;
49
+ };
50
+ export type BeforeChangeRichTextHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {
51
+ /**
52
+ * The original data with locales (not modified by any hooks). Only available in `beforeChange` and `beforeDuplicate` field hooks.
53
+ */
54
+ docWithLocales?: Record<string, unknown>;
55
+ duplicate?: boolean;
56
+ errors?: {
57
+ field: string;
58
+ message: string;
59
+ }[];
60
+ /** Only available in `beforeChange` field hooks */
61
+ mergeLocaleActions?: (() => Promise<void>)[];
62
+ /** A string relating to which operation the field type is currently executing within. */
63
+ operation?: 'create' | 'delete' | 'read' | 'update';
64
+ /** The sibling data of the document before changes being applied. */
65
+ previousSiblingDoc?: TData;
66
+ /** The previous value of the field, before changes */
67
+ previousValue?: TValue;
68
+ /**
69
+ * The original siblingData with locales (not modified by any hooks).
70
+ */
71
+ siblingDocWithLocales?: Record<string, unknown>;
72
+ skipValidation?: boolean;
73
+ };
74
+ export type BaseRichTextHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {
75
+ /** The collection which the field belongs to. If the field belongs to a global, this will be null. */
76
+ collection: SanitizedCollectionConfig | null;
77
+ context: RequestContext;
78
+ /** The data passed to update the document within create and update operations, and the full document itself in the afterRead hook. */
79
+ data?: Partial<TData>;
80
+ /** The field which the hook is running against. */
81
+ field: FieldAffectingData;
82
+ /** The global which the field belongs to. If the field belongs to a collection, this will be null. */
83
+ global: SanitizedGlobalConfig | null;
84
+ /** The full original document in `update` operations. In the `afterChange` hook, this is the resulting document of the operation. */
85
+ originalDoc?: TData;
86
+ /**
87
+ * The path of the field, e.g. ["group", "myArray", 1, "textField"]. The path is the schemaPath but with indexes and would be used in the context of field data, not field schemas.
88
+ */
89
+ path: (number | string)[];
90
+ /** The Express request object. It is mocked for Local API operations. */
91
+ req: PayloadRequestWithData;
92
+ /**
93
+ * The schemaPath of the field, e.g. ["group", "myArray", "textField"]. The schemaPath is the path but without indexes and would be used in the context of field schemas, not field data.
94
+ */
95
+ schemaPath: string[];
96
+ /** The sibling data passed to a field that the hook is running against. */
97
+ siblingData: Partial<TSiblingData>;
98
+ /** The value of the field. */
99
+ value?: TValue;
100
+ };
101
+ export type AfterReadRichTextHook<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = (args: BaseRichTextHookArgs<TData, TValue, TSiblingData> & AfterReadRichTextHookArgs<TData, TValue, TSiblingData>) => Promise<TValue> | TValue;
102
+ export type AfterChangeRichTextHook<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = (args: BaseRichTextHookArgs<TData, TValue, TSiblingData> & AfterChangeRichTextHookArgs<TData, TValue, TSiblingData>) => Promise<TValue> | TValue;
103
+ export type BeforeChangeRichTextHook<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = (args: BaseRichTextHookArgs<TData, TValue, TSiblingData> & BeforeChangeRichTextHookArgs<TData, TValue, TSiblingData>) => Promise<TValue> | TValue;
104
+ export type BeforeValidateRichTextHook<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = (args: BaseRichTextHookArgs<TData, TValue, TSiblingData> & BeforeValidateRichTextHookArgs<TData, TValue, TSiblingData>) => Promise<TValue> | TValue;
105
+ export type RichTextHooks = {
106
+ afterChange?: AfterChangeRichTextHook[];
107
+ afterRead?: AfterReadRichTextHook[];
108
+ beforeChange?: BeforeChangeRichTextHook[];
109
+ beforeValidate?: BeforeValidateRichTextHook[];
110
+ };
11
111
  type RichTextAdapterBase<Value extends object = object, AdapterProps = any, ExtraFieldProperties = {}> = {
12
112
  generateComponentMap: (args: {
13
113
  WithServerSideProps: React.FC<Omit<WithServerSidePropsComponentProps, 'serverOnlyProps'>>;
@@ -21,27 +121,13 @@ type RichTextAdapterBase<Value extends object = object, AdapterProps = any, Extr
21
121
  schemaMap: Map<string, Field[]>;
22
122
  schemaPath: string;
23
123
  }) => Map<string, Field[]>;
24
- hooks?: FieldBase['hooks'];
25
- i18n?: Partial<GenericLanguages>;
26
- outputSchema?: ({ collectionIDFieldTypes, config, field, interfaceNameDefinitions, isRequired, }: {
27
- collectionIDFieldTypes: {
28
- [key: string]: 'number' | 'string';
29
- };
30
- config?: SanitizedConfig;
31
- field: RichTextField<Value, AdapterProps, ExtraFieldProperties>;
32
- /**
33
- * Allows you to define new top-level interfaces that can be re-used in the output schema.
34
- */
35
- interfaceNameDefinitions: Map<string, JSONSchema4>;
36
- isRequired: boolean;
37
- }) => JSONSchema4;
38
124
  /**
39
- * Like an afterRead hook, but runs for both afterRead AND in the GraphQL resolver. For populating data, this should be used.
125
+ * Like an afterRead hook, but runs only for the GraphQL resolver. For populating data, this should be used, as afterRead hooks do not have a depth in graphQL.
40
126
  *
41
127
  * To populate stuff / resolve field hooks, mutate the incoming populationPromises or fieldPromises array. They will then be awaited in the correct order within payload itself.
42
128
  * @param data
43
129
  */
44
- populationPromises?: (data: {
130
+ graphQLPopulationPromises?: (data: {
45
131
  context: RequestContext;
46
132
  currentDepth?: number;
47
133
  depth: number;
@@ -56,6 +142,20 @@ type RichTextAdapterBase<Value extends object = object, AdapterProps = any, Extr
56
142
  showHiddenFields: boolean;
57
143
  siblingDoc: Record<string, unknown>;
58
144
  }) => void;
145
+ hooks?: RichTextHooks;
146
+ i18n?: Partial<GenericLanguages>;
147
+ outputSchema?: ({ collectionIDFieldTypes, config, field, interfaceNameDefinitions, isRequired, }: {
148
+ collectionIDFieldTypes: {
149
+ [key: string]: 'number' | 'string';
150
+ };
151
+ config?: SanitizedConfig;
152
+ field: RichTextField<Value, AdapterProps, ExtraFieldProperties>;
153
+ /**
154
+ * Allows you to define new top-level interfaces that can be re-used in the output schema.
155
+ */
156
+ interfaceNameDefinitions: Map<string, JSONSchema4>;
157
+ isRequired: boolean;
158
+ }) => JSONSchema4;
59
159
  validate: Validate<Value, Value, unknown, RichTextField<Value, AdapterProps, ExtraFieldProperties>>;
60
160
  };
61
161
  export type RichTextAdapter<Value extends object = object, AdapterProps = any, ExtraFieldProperties = {}> = RichTextAdapterBase<Value, AdapterProps, ExtraFieldProperties> & {
@@ -1 +1 @@
1
- {"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../../src/admin/RichText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AAC1F,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAC/E,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,mCAAmC,CAAA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,CAAC,KAAK,EAAE,YAAY,EAAE,oBAAoB,CAAC,CAAA;QAC/D;;WAEG;QACH,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAClD,UAAU,EAAE,OAAO,CAAA;KACpB,KAAK,WAAW,CAAA;IACjB,QAAQ,EAAE,QAAQ,CAChB,KAAK,EACL,KAAK,EACL,OAAO,EACP,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,oBAAoB,CAAC,CACzD,CAAA;CACF,CAAA;AAED,MAAM,MAAM,eAAe,CACzB,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,YAAY,GAAG,GAAG,EAClB,oBAAoB,GAAG,EAAE,IACvB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,oBAAoB,CAAC,GAAG;IACnE,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;IAC5B,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,oBAAoB,CAAC,CAAC,CAAA;CACxF,CAAA;AAED,MAAM,MAAM,uBAAuB,CACjC,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,YAAY,GAAG,GAAG,EAClB,oBAAoB,GAAG,EAAE,IACvB,CAAC,EACH,MAAM,EACN,MAAM,GACP,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,KACG,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,oBAAoB,CAAC,CAAC,GACnE,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,oBAAoB,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/admin/RichText.ts"],"sourcesContent":["import type { GenericLanguages, I18n, I18nClient } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type React from 'react'\n\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FieldBase, RichTextField, Validate } from '../fields/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../types/index.js'\nimport type { WithServerSidePropsComponentProps } from './elements/WithServerSideProps.js'\n\nexport type RichTextFieldProps<\n Value extends object,\n AdapterProps,\n ExtraFieldProperties = {},\n> = Omit<RichTextField<Value, AdapterProps, ExtraFieldProperties>, 'type'> & {\n path?: string\n}\n\ntype RichTextAdapterBase<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = {\n generateComponentMap: (args: {\n WithServerSideProps: React.FC<Omit<WithServerSidePropsComponentProps, 'serverOnlyProps'>>\n config: SanitizedConfig\n i18n: I18nClient\n schemaPath: string\n }) => Map<string, React.ReactNode>\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n i18n: I18n<any, any>\n schemaMap: Map<string, Field[]>\n schemaPath: string\n }) => Map<string, Field[]>\n hooks?: FieldBase['hooks']\n i18n?: Partial<GenericLanguages>\n outputSchema?: ({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n field: RichTextField<Value, AdapterProps, ExtraFieldProperties>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n /**\n * Like an afterRead hook, but runs for both afterRead AND in the GraphQL resolver. For populating data, this should be used.\n *\n * To populate stuff / resolve field hooks, mutate the incoming populationPromises or fieldPromises array. They will then be awaited in the correct order within payload itself.\n * @param data\n */\n populationPromises?: (data: {\n context: RequestContext\n currentDepth?: number\n depth: number\n draft: boolean\n field: RichTextField<Value, AdapterProps, ExtraFieldProperties>\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n overrideAccess?: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequestWithData\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n }) => void\n validate: Validate<\n Value,\n Value,\n unknown,\n RichTextField<Value, AdapterProps, ExtraFieldProperties>\n >\n}\n\nexport type RichTextAdapter<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = RichTextAdapterBase<Value, AdapterProps, ExtraFieldProperties> & {\n CellComponent: React.FC<any>\n FieldComponent: React.FC<RichTextFieldProps<Value, AdapterProps, ExtraFieldProperties>>\n}\n\nexport type RichTextAdapterProvider<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = ({\n config,\n isRoot,\n}: {\n config: SanitizedConfig\n /**\n * Whether or not this is the root richText editor, defined in the payload.config.ts.\n *\n * @default false\n */\n isRoot?: boolean\n}) =>\n | Promise<RichTextAdapter<Value, AdapterProps, ExtraFieldProperties>>\n | RichTextAdapter<Value, AdapterProps, ExtraFieldProperties>\n"],"names":[],"rangeMappings":"","mappings":"AA0FA,WAiB8D"}
1
+ {"version":3,"sources":["../../src/admin/RichText.ts"],"sourcesContent":["import type { GenericLanguages, I18n, I18nClient } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type React from 'react'\n\nimport type { SanitizedCollectionConfig, TypeWithID } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FieldAffectingData, RichTextField, Validate } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../types/index.js'\nimport type { WithServerSidePropsComponentProps } from './elements/WithServerSideProps.js'\n\nexport type RichTextFieldProps<\n Value extends object,\n AdapterProps,\n ExtraFieldProperties = {},\n> = Omit<RichTextField<Value, AdapterProps, ExtraFieldProperties>, 'type'> & {\n path?: string\n}\n\nexport type AfterReadRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n currentDepth?: number\n\n depth?: number\n\n draft?: boolean\n\n fallbackLocale?: string\n\n fieldPromises?: Promise<void>[]\n\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany?: boolean\n\n flattenLocales?: boolean\n\n locale?: string\n\n /** A string relating to which operation the field type is currently executing within. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n\n overrideAccess?: boolean\n\n populationPromises?: Promise<void>[]\n showHiddenFields?: boolean\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\nexport type AfterChangeRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /** A string relating to which operation the field type is currently executing within. */\n operation: 'create' | 'update'\n /** The document before changes were applied. */\n previousDoc?: TData\n /** The sibling data of the document before changes being applied. */\n previousSiblingDoc?: TData\n /** The previous value of the field, before changes */\n previousValue?: TValue\n}\nexport type BeforeValidateRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /** A string relating to which operation the field type is currently executing within. */\n operation: 'create' | 'update'\n overrideAccess?: boolean\n /** The sibling data of the document before changes being applied. */\n previousSiblingDoc?: TData\n /** The previous value of the field, before changes */\n previousValue?: TValue\n}\n\nexport type BeforeChangeRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /**\n * The original data with locales (not modified by any hooks). Only available in `beforeChange` and `beforeDuplicate` field hooks.\n */\n docWithLocales?: Record<string, unknown>\n\n duplicate?: boolean\n\n errors?: { field: string; message: string }[]\n /** Only available in `beforeChange` field hooks */\n mergeLocaleActions?: (() => Promise<void>)[]\n /** A string relating to which operation the field type is currently executing within. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n /** The sibling data of the document before changes being applied. */\n previousSiblingDoc?: TData\n /** The previous value of the field, before changes */\n previousValue?: TValue\n /**\n * The original siblingData with locales (not modified by any hooks).\n */\n siblingDocWithLocales?: Record<string, unknown>\n\n skipValidation?: boolean\n}\n\nexport type BaseRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /** The collection which the field belongs to. If the field belongs to a global, this will be null. */\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n /** The data passed to update the document within create and update operations, and the full document itself in the afterRead hook. */\n data?: Partial<TData>\n /** The field which the hook is running against. */\n field: FieldAffectingData\n /** The global which the field belongs to. If the field belongs to a collection, this will be null. */\n global: SanitizedGlobalConfig | null\n\n /** The full original document in `update` operations. In the `afterChange` hook, this is the resulting document of the operation. */\n originalDoc?: TData\n /**\n * The path of the field, e.g. [\"group\", \"myArray\", 1, \"textField\"]. The path is the schemaPath but with indexes and would be used in the context of field data, not field schemas.\n */\n path: (number | string)[]\n\n /** The Express request object. It is mocked for Local API operations. */\n req: PayloadRequestWithData\n /**\n * The schemaPath of the field, e.g. [\"group\", \"myArray\", \"textField\"]. The schemaPath is the path but without indexes and would be used in the context of field schemas, not field data.\n */\n schemaPath: string[]\n /** The sibling data passed to a field that the hook is running against. */\n siblingData: Partial<TSiblingData>\n /** The value of the field. */\n value?: TValue\n}\n\nexport type AfterReadRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: BaseRichTextHookArgs<TData, TValue, TSiblingData> &\n AfterReadRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type AfterChangeRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: BaseRichTextHookArgs<TData, TValue, TSiblingData> &\n AfterChangeRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type BeforeChangeRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: BaseRichTextHookArgs<TData, TValue, TSiblingData> &\n BeforeChangeRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type BeforeValidateRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: BaseRichTextHookArgs<TData, TValue, TSiblingData> &\n BeforeValidateRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type RichTextHooks = {\n afterChange?: AfterChangeRichTextHook[]\n afterRead?: AfterReadRichTextHook[]\n beforeChange?: BeforeChangeRichTextHook[]\n beforeValidate?: BeforeValidateRichTextHook[]\n}\n\ntype RichTextAdapterBase<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = {\n generateComponentMap: (args: {\n WithServerSideProps: React.FC<Omit<WithServerSidePropsComponentProps, 'serverOnlyProps'>>\n config: SanitizedConfig\n i18n: I18nClient\n schemaPath: string\n }) => Map<string, React.ReactNode>\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n i18n: I18n<any, any>\n schemaMap: Map<string, Field[]>\n schemaPath: string\n }) => Map<string, Field[]>\n /**\n * Like an afterRead hook, but runs only for the GraphQL resolver. For populating data, this should be used, as afterRead hooks do not have a depth in graphQL.\n *\n * To populate stuff / resolve field hooks, mutate the incoming populationPromises or fieldPromises array. They will then be awaited in the correct order within payload itself.\n * @param data\n */\n graphQLPopulationPromises?: (data: {\n context: RequestContext\n currentDepth?: number\n depth: number\n draft: boolean\n field: RichTextField<Value, AdapterProps, ExtraFieldProperties>\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n overrideAccess?: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequestWithData\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n }) => void\n hooks?: RichTextHooks\n i18n?: Partial<GenericLanguages>\n outputSchema?: ({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n field: RichTextField<Value, AdapterProps, ExtraFieldProperties>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n validate: Validate<\n Value,\n Value,\n unknown,\n RichTextField<Value, AdapterProps, ExtraFieldProperties>\n >\n}\n\nexport type RichTextAdapter<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = RichTextAdapterBase<Value, AdapterProps, ExtraFieldProperties> & {\n CellComponent: React.FC<any>\n FieldComponent: React.FC<RichTextFieldProps<Value, AdapterProps, ExtraFieldProperties>>\n}\n\nexport type RichTextAdapterProvider<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = ({\n config,\n isRoot,\n}: {\n config: SanitizedConfig\n /**\n * Whether or not this is the root richText editor, defined in the payload.config.ts.\n *\n * @default false\n */\n isRoot?: boolean\n}) =>\n | Promise<RichTextAdapter<Value, AdapterProps, ExtraFieldProperties>>\n | RichTextAdapter<Value, AdapterProps, ExtraFieldProperties>\n"],"names":[],"rangeMappings":"","mappings":"AAmQA,WAiB8D"}
@@ -1 +1 @@
1
- {"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/forgotPassword.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAQlE,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;QACtB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,sBAAsB,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,eAAO,MAAM,uBAAuB,iBAAwB,SAAS,KAAG,QAAQ,IAAI,GAAG,MAAM,CA6I5F,CAAA"}
1
+ {"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/forgotPassword.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAQlE,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;QACtB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,sBAAsB,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,eAAO,MAAM,uBAAuB,iBAAwB,SAAS,KAAG,QAAQ,IAAI,GAAG,MAAM,CA4I5F,CAAA"}
@@ -78,8 +78,7 @@ export const forgotPasswordOperation = async (incomingArgs)=>{
78
78
  user
79
79
  });
80
80
  }
81
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
82
- email.sendEmail({
81
+ await email.sendEmail({
83
82
  from: `"${email.defaultFromName}" <${email.defaultFromAddress}>`,
84
83
  html,
85
84
  subject,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/operations/forgotPassword.ts"],"sourcesContent":["import crypto from 'crypto'\nimport httpStatus from 'http-status'\nimport { URL } from 'url'\n\nimport type { Collection } from '../../collections/config/types.js'\nimport type { PayloadRequestWithData } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { APIError } from '../../errors/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n collection: Collection\n data: {\n [key: string]: unknown\n email: string\n }\n disableEmail?: boolean\n expiration?: number\n req: PayloadRequestWithData\n}\n\nexport type Result = string\n\nexport const forgotPasswordOperation = async (incomingArgs: Arguments): Promise<null | string> => {\n if (!Object.prototype.hasOwnProperty.call(incomingArgs.data, 'email')) {\n throw new APIError('Missing email.', httpStatus.BAD_REQUEST)\n }\n\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(async (priorHook, hook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'forgotPassword',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n collection: { config: collectionConfig },\n data,\n disableEmail,\n expiration,\n req: {\n payload: { config, email },\n payload,\n },\n req,\n } = args\n\n // /////////////////////////////////////\n // Forget password\n // /////////////////////////////////////\n\n let token: string = crypto.randomBytes(20).toString('hex')\n\n type UserDoc = {\n id: number | string\n resetPasswordExpiration?: string\n resetPasswordToken?: string\n }\n\n if (!data.email) {\n throw new APIError('Missing email.', httpStatus.BAD_REQUEST)\n }\n\n let user = await payload.db.findOne<UserDoc>({\n collection: collectionConfig.slug,\n req,\n where: { email: { equals: data.email.toLowerCase() } },\n })\n\n // We don't want to indicate specifically that an email was not found,\n // as doing so could lead to the exposure of registered emails.\n // Therefore, we prefer to fail silently.\n if (!user) return null\n\n user.resetPasswordToken = token\n user.resetPasswordExpiration = new Date(expiration || Date.now() + 3600000).toISOString() // 1 hour\n\n user = await payload.update({\n id: user.id,\n collection: collectionConfig.slug,\n data: user,\n req,\n })\n\n if (!disableEmail) {\n const protocol = new URL(req.url).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n\n let html = `${req.t('authentication:youAreReceivingResetPassword')}\n <a href=\"${serverURL}${config.routes.admin}/reset/${token}\">${serverURL}${config.routes.admin}/reset/${token}</a>\n ${req.t('authentication:youDidNotRequestPassword')}`\n\n if (typeof collectionConfig.auth.forgotPassword.generateEmailHTML === 'function') {\n html = await collectionConfig.auth.forgotPassword.generateEmailHTML({\n req,\n token,\n user,\n })\n }\n\n let subject = req.t('authentication:resetYourPassword')\n\n if (typeof collectionConfig.auth.forgotPassword.generateEmailSubject === 'function') {\n subject = await collectionConfig.auth.forgotPassword.generateEmailSubject({\n req,\n token,\n user,\n })\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n email.sendEmail({\n from: `\"${email.defaultFromName}\" <${email.defaultFromAddress}>`,\n html,\n subject,\n to: data.email,\n })\n }\n\n // /////////////////////////////////////\n // afterForgotPassword - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterForgotPassword.reduce(async (priorHook, hook) => {\n await priorHook\n await hook({ args, collection: args.collection?.config, context: req.context })\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n token = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'forgotPassword',\n result: token,\n })\n\n if (shouldCommit) await commitTransaction(req)\n\n return token\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["crypto","httpStatus","URL","buildAfterOperation","APIError","commitTransaction","initTransaction","killTransaction","forgotPasswordOperation","incomingArgs","Object","prototype","hasOwnProperty","call","data","BAD_REQUEST","args","shouldCommit","req","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","collectionConfig","disableEmail","expiration","payload","email","token","randomBytes","toString","user","db","findOne","slug","where","equals","toLowerCase","resetPasswordToken","resetPasswordExpiration","Date","now","toISOString","update","id","protocol","url","serverURL","headers","get","html","t","routes","admin","auth","forgotPassword","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to","afterForgotPassword","result","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"A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,cAAc,CAACC,iBAAiB,CAAC;oBAClE7C;oBACAiB;oBACAG;gBACF;YACF;YAEA,IAAI0B,UAAU9C,IAAIwC,CAAC,CAAC;YAEpB,IAAI,OAAO5B,iBAAiB+B,IAAI,CAACC,cAAc,CAACG,oBAAoB,KAAK,YAAY;gBACnFD,UAAU,MAAMlC,iBAAiB+B,IAAI,CAACC,cAAc,CAACG,oBAAoB,CAAC;oBACxE/C;oBACAiB;oBACAG;gBACF;YACF;YAEA,mEAAmE;YACnEJ,MAAMgC,SAAS,CAAC;gBACdC,MAAM,CAAC,CAAC,EAAEjC,MAAMkC,eAAe,CAAC,GAAG,EAAElC,MAAMmC,kBAAkB,CAAC,CAAC,CAAC;gBAChEZ;gBACAO;gBACAM,IAAIxD,KAAKoB,KAAK;YAChB;QACF;QAEA,wCAAwC;QACxC,mCAAmC;QACnC,wCAAwC;QAExC,MAAMJ,iBAAiBT,KAAK,CAACkD,mBAAmB,CAAChD,MAAM,CAAC,OAAOC,WAAWC;YACxE,MAAMD;YACN,MAAMC,KAAK;gBAAET;gBAAMG,YAAYH,KAAKG,UAAU,EAAEC;gBAAQM,SAASR,IAAIQ,OAAO;YAAC;QAC/E,GAAGE,QAAQC,OAAO;QAElB,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCM,QAAQ,MAAMhC,oBAAoB;YAChCa;YACAG,YAAYH,KAAKG,UAAU,EAAEC;YAC7BO,WAAW;YACX6C,QAAQrC;QACV;QAEA,IAAIlB,cAAc,MAAMZ,kBAAkBa;QAE1C,OAAOiB;IACT,EAAE,OAAOsC,OAAgB;QACvB,MAAMlE,gBAAgBS,KAAKE,GAAG;QAC9B,MAAMuD;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/operations/forgotPassword.ts"],"sourcesContent":["import crypto from 'crypto'\nimport httpStatus from 'http-status'\nimport { URL } from 'url'\n\nimport type { Collection } from '../../collections/config/types.js'\nimport type { PayloadRequestWithData } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { APIError } from '../../errors/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n collection: Collection\n data: {\n [key: string]: unknown\n email: string\n }\n disableEmail?: boolean\n expiration?: number\n req: PayloadRequestWithData\n}\n\nexport type Result = string\n\nexport const forgotPasswordOperation = async (incomingArgs: Arguments): Promise<null | string> => {\n if (!Object.prototype.hasOwnProperty.call(incomingArgs.data, 'email')) {\n throw new APIError('Missing email.', httpStatus.BAD_REQUEST)\n }\n\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(async (priorHook, hook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'forgotPassword',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n collection: { config: collectionConfig },\n data,\n disableEmail,\n expiration,\n req: {\n payload: { config, email },\n payload,\n },\n req,\n } = args\n\n // /////////////////////////////////////\n // Forget password\n // /////////////////////////////////////\n\n let token: string = crypto.randomBytes(20).toString('hex')\n\n type UserDoc = {\n id: number | string\n resetPasswordExpiration?: string\n resetPasswordToken?: string\n }\n\n if (!data.email) {\n throw new APIError('Missing email.', httpStatus.BAD_REQUEST)\n }\n\n let user = await payload.db.findOne<UserDoc>({\n collection: collectionConfig.slug,\n req,\n where: { email: { equals: data.email.toLowerCase() } },\n })\n\n // We don't want to indicate specifically that an email was not found,\n // as doing so could lead to the exposure of registered emails.\n // Therefore, we prefer to fail silently.\n if (!user) return null\n\n user.resetPasswordToken = token\n user.resetPasswordExpiration = new Date(expiration || Date.now() + 3600000).toISOString() // 1 hour\n\n user = await payload.update({\n id: user.id,\n collection: collectionConfig.slug,\n data: user,\n req,\n })\n\n if (!disableEmail) {\n const protocol = new URL(req.url).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n\n let html = `${req.t('authentication:youAreReceivingResetPassword')}\n <a href=\"${serverURL}${config.routes.admin}/reset/${token}\">${serverURL}${config.routes.admin}/reset/${token}</a>\n ${req.t('authentication:youDidNotRequestPassword')}`\n\n if (typeof collectionConfig.auth.forgotPassword.generateEmailHTML === 'function') {\n html = await collectionConfig.auth.forgotPassword.generateEmailHTML({\n req,\n token,\n user,\n })\n }\n\n let subject = req.t('authentication:resetYourPassword')\n\n if (typeof collectionConfig.auth.forgotPassword.generateEmailSubject === 'function') {\n subject = await collectionConfig.auth.forgotPassword.generateEmailSubject({\n req,\n token,\n user,\n })\n }\n\n await email.sendEmail({\n from: `\"${email.defaultFromName}\" <${email.defaultFromAddress}>`,\n html,\n subject,\n to: data.email,\n })\n }\n\n // /////////////////////////////////////\n // afterForgotPassword - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterForgotPassword.reduce(async (priorHook, hook) => {\n await priorHook\n await hook({ args, collection: args.collection?.config, context: req.context })\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n token = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'forgotPassword',\n result: token,\n })\n\n if (shouldCommit) await commitTransaction(req)\n\n return token\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["crypto","httpStatus","URL","buildAfterOperation","APIError","commitTransaction","initTransaction","killTransaction","forgotPasswordOperation","incomingArgs","Object","prototype","hasOwnProperty","call","data","BAD_REQUEST","args","shouldCommit","req","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","collectionConfig","disableEmail","expiration","payload","email","token","randomBytes","toString","user","db","findOne","slug","where","equals","toLowerCase","resetPasswordToken","resetPasswordExpiration","Date","now","toISOString","update","id","protocol","url","serverURL","headers","get","html","t","routes","admin","auth","forgotPassword","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to","afterForgotPassword","result","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,OAAOC,gBAAgB,cAAa;AACpC,SAASC,GAAG,QAAQ,MAAK;AAKzB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AAepE,OAAO,MAAMC,0BAA0B,OAAOC;IAC5C,IAAI,CAACC,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACJ,aAAaK,IAAI,EAAE,UAAU;QACrE,MAAM,IAAIV,SAAS,kBAAkBH,WAAWc,WAAW;IAC7D;IAEA,IAAIC,OAAOP;IAEX,IAAI;QACF,MAAMQ,eAAe,MAAMX,gBAAgBU,KAAKE,GAAG;QAEnD,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExC,MAAMF,KAAKG,UAAU,CAACC,MAAM,CAACC,KAAK,CAACC,eAAe,CAACC,MAAM,CAAC,OAAOC,WAAWC;YAC1E,MAAMD;YAENR,OACE,AAAC,MAAMS,KAAK;gBACVT;gBACAG,YAAYH,KAAKG,UAAU,EAAEC;gBAC7BM,SAASV,KAAKE,GAAG,CAACQ,OAAO;gBACzBC,WAAW;gBACXT,KAAKF,KAAKE,GAAG;YACf,MAAOF;QACX,GAAGY,QAAQC,OAAO;QAElB,MAAM,EACJV,YAAY,EAAEC,QAAQU,gBAAgB,EAAE,EACxChB,IAAI,EACJiB,YAAY,EACZC,UAAU,EACV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AOsC,OAAgB;QACvB,MAAMlE,gBAAgBS,KAAKE,GAAG;QAC9B,MAAMuD;IACR;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sendVerificationEmail.d.ts","sourceRoot":"","sources":["../../src/auth/sendVerificationEmail.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAgB,MAAM,YAAY,CAAA;AAEpD,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,eAAe,CAAA;IACvB,YAAY,EAAE,OAAO,CAAA;IACrB,KAAK,EAAE,uBAAuB,CAAA;IAC9B,GAAG,EAAE,sBAAsB,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAwDrE"}
1
+ {"version":3,"file":"sendVerificationEmail.d.ts","sourceRoot":"","sources":["../../src/auth/sendVerificationEmail.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAgB,MAAM,YAAY,CAAA;AAEpD,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,eAAe,CAAA;IACvB,YAAY,EAAE,OAAO,CAAA;IACrB,KAAK,EAAE,uBAAuB,CAAA;IAC9B,GAAG,EAAE,sBAAsB,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAuDrE"}
@@ -29,8 +29,7 @@ export async function sendVerificationEmail(args) {
29
29
  user
30
30
  });
31
31
  }
32
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
33
- email.sendEmail({
32
+ await email.sendEmail({
34
33
  from: `"${email.defaultFromName}" <${email.defaultFromAddress}>`,
35
34
  html,
36
35
  subject,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/sendVerificationEmail.ts"],"sourcesContent":["import { URL } from 'url'\n\nimport type { Collection } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { InitializedEmailAdapter } from '../email/types.js'\nimport type { PayloadRequestWithData } from '../types/index.js'\nimport type { User, VerifyConfig } from './types.js'\n\ntype Args = {\n collection: Collection\n config: SanitizedConfig\n disableEmail: boolean\n email: InitializedEmailAdapter\n req: PayloadRequestWithData\n token: string\n user: User\n}\n\nexport async function sendVerificationEmail(args: Args): Promise<void> {\n // Verify token from e-mail\n const {\n collection: { config: collectionConfig },\n config,\n disableEmail,\n email,\n req,\n token,\n user,\n } = args\n\n if (!disableEmail) {\n const protocol = new URL(req.url).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n\n const verificationURL = `${serverURL}${config.routes.admin}/${collectionConfig.slug}/verify/${token}`\n\n let html = `${req.t('authentication:newAccountCreated', {\n serverURL: config.serverURL,\n verificationURL,\n })}`\n\n const verify = collectionConfig.auth.verify as VerifyConfig\n\n // Allow config to override email content\n if (typeof verify.generateEmailHTML === 'function') {\n html = await verify.generateEmailHTML({\n req,\n token,\n user,\n })\n }\n\n let subject = req.t('authentication:verifyYourEmail')\n\n // Allow config to override email subject\n if (typeof verify.generateEmailSubject === 'function') {\n subject = await verify.generateEmailSubject({\n req,\n token,\n user,\n })\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n email.sendEmail({\n from: `\"${email.defaultFromName}\" <${email.defaultFromAddress}>`,\n html,\n subject,\n to: user.email,\n })\n }\n}\n"],"names":["URL","sendVerificationEmail","args","collection","config","collectionConfig","disableEmail","email","req","token","user","protocol","url","serverURL","headers","get","verificationURL","routes","admin","slug","html","t","verify","auth","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,GAAG,QAAQ,MAAK;AAkBzB,OAAO,eAAeC,sBAAsBC,IAAU;IACpD,2BAA2B;IAC3B,MAAM,EACJC,YAAY,EAAEC,QAAQC,gBAAgB,EAAE,EACxCD,MAAM,EACNE,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,IAAI,EACL,GAAGR;IAEJ,IAAI,CAACI,cAAc;QACjB,MAAMK,WAAW,IAAIX,IAAIQ,IAAII,GAAG,EAAED,QAAQ,CAAC,uBAAuB;;QAClE,MAAME,YACJT,OAAOS,SAAS,KAAK,QAAQT,OAAOS,SAAS,KAAK,KAC9CT,OAAOS,SAAS,GAChB,CAAC,EAAEF,SAAS,EAAE,EAAEH,IAAIM,OAAO,CAACC,GAAG,CAAC,QAAQ,CAAC;QAE/C,MAAMC,kBAAkB,CAAC,EAAEH,UAAU,EAAET,OAAOa,MAAM,CAACC,KAAK,CAAC,CAAC,EAAEb,iBAAiBc,IAAI,CAAC,QAAQ,EAAEV,MAAM,CAAC;QAErG,IAAIW,OAAO,CAAC,EAAEZ,IAAIa,CAAC,CAAC,oCAAoC;YACtDR,WAAWT,OAAOS,SAAS;YAC3BG;QACF,GAAG,CAAC;QAEJ,MAAMM,SAASjB,iBAAiBkB,IAAI,CAACD,MAAM;QAE3C,yCAAyC;QACzC,IAAI,OAAOA,OAAOE,iBAAiB,KAAK,YAAY;YAClDJ,OAAO,MAAME,OAAOE,iBAAiB,CAAC;gBACpChB;gBACAC;gBACAC;YACF;QACF;QAEA,IAAIe,UAAUjB,IAAIa,CAAC,CAAC;QAEpB,yCAAyC;QACzC,IAAI,OAAOC,OAAOI,oBAAoB,KAAK,YAAY;YACrDD,UAAU,MAAMH,OAAOI,oBAAoB,CAAC;gBAC1ClB;gBACAC;gBACAC;YACF;QACF;QAEA,mEAAmE;QACnEH,MAAMoB,SAAS,CAAC;YACdC,MAAM,CAAC,CAAC,EAAErB,MAAMsB,eAAe,CAAC,GAAG,EAAEtB,MAAMuB,kBAAkB,CAAC,CAAC,CAAC;YAChEV;YACAK;YACAM,IAAIrB,KAAKH,KAAK;QAChB;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/auth/sendVerificationEmail.ts"],"sourcesContent":["import { URL } from 'url'\n\nimport type { Collection } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { InitializedEmailAdapter } from '../email/types.js'\nimport type { PayloadRequestWithData } from '../types/index.js'\nimport type { User, VerifyConfig } from './types.js'\n\ntype Args = {\n collection: Collection\n config: SanitizedConfig\n disableEmail: boolean\n email: InitializedEmailAdapter\n req: PayloadRequestWithData\n token: string\n user: User\n}\n\nexport async function sendVerificationEmail(args: Args): Promise<void> {\n // Verify token from e-mail\n const {\n collection: { config: collectionConfig },\n config,\n disableEmail,\n email,\n req,\n token,\n user,\n } = args\n\n if (!disableEmail) {\n const protocol = new URL(req.url).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n\n const verificationURL = `${serverURL}${config.routes.admin}/${collectionConfig.slug}/verify/${token}`\n\n let html = `${req.t('authentication:newAccountCreated', {\n serverURL: config.serverURL,\n verificationURL,\n })}`\n\n const verify = collectionConfig.auth.verify as VerifyConfig\n\n // Allow config to override email content\n if (typeof verify.generateEmailHTML === 'function') {\n html = await verify.generateEmailHTML({\n req,\n token,\n user,\n })\n }\n\n let subject = req.t('authentication:verifyYourEmail')\n\n // Allow config to override email subject\n if (typeof verify.generateEmailSubject === 'function') {\n subject = await verify.generateEmailSubject({\n req,\n token,\n user,\n })\n }\n\n await email.sendEmail({\n from: `\"${email.defaultFromName}\" <${email.defaultFromAddress}>`,\n html,\n subject,\n to: user.email,\n })\n }\n}\n"],"names":["URL","sendVerificationEmail","args","collection","config","collectionConfig","disableEmail","email","req","token","user","protocol","url","serverURL","headers","get","verificationURL","routes","admin","slug","html","t","verify","auth","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,GAAG,QAAQ,MAAK;AAkBzB,OAAO,eAAeC,sBAAsBC,IAAU;IACpD,2BAA2B;IAC3B,MAAM,EACJC,YAAY,EAAEC,QAAQC,gBAAgB,EAAE,EACxCD,MAAM,EACNE,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,IAAI,EACL,GAAGR;IAEJ,IAAI,CAACI,cAAc;QACjB,MAAMK,WAAW,IAAIX,IAAIQ,IAAII,GAAG,EAAED,QAAQ,CAAC,uBAAuB;;QAClE,MAAME,YACJT,OAAOS,SAAS,KAAK,QAAQT,OAAOS,SAAS,KAAK,KAC9CT,OAAOS,SAAS,GAChB,CAAC,EAAEF,SAAS,EAAE,EAAEH,IAAIM,OAAO,CAACC,GAAG,CAAC,QAAQ,CAAC;QAE/C,MAAMC,kBAAkB,CAAC,EAAEH,UAAU,EAAET,OAAOa,MAAM,CAACC,KAAK,CAAC,CAAC,EAAEb,iBAAiBc,IAAI,CAAC,QAAQ,EAAEV,MAAM,CAAC;QAErG,IAAIW,OAAO,CAAC,EAAEZ,IAAIa,CAAC,CAAC,oCAAoC;YACtDR,WAAWT,OAAOS,SAAS;YAC3BG;QACF,GAAG,CAAC;QAEJ,MAAMM,SAASjB,iBAAiBkB,IAAI,CAACD,MAAM;QAE3C,yCAAyC;QACzC,IAAI,OAAOA,OAAOE,iBAAiB,KAAK,YAAY;YAClDJ,OAAO,MAAME,OAAOE,iBAAiB,CAAC;gBACpChB;gBACAC;gBACAC;YACF;QACF;QAEA,IAAIe,UAAUjB,IAAIa,CAAC,CAAC;QAEpB,yCAAyC;QACzC,IAAI,OAAOC,OAAOI,oBAAoB,KAAK,YAAY;YACrDD,UAAU,MAAMH,OAAOI,oBAAoB,CAAC;gBAC1ClB;gBACAC;gBACAC;YACF;QACF;QAEA,MAAMH,MAAMoB,SAAS,CAAC;YACpBC,MAAM,CAAC,CAAC,EAAErB,MAAMsB,eAAe,CAAC,GAAG,EAAEtB,MAAMuB,kBAAkB,CAAC,CAAC,CAAC;YAChEV;YACAK;YACAM,IAAIrB,KAAKH,KAAK;QAChB;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"generateTypes.d.ts","sourceRoot":"","sources":["../../src/bin/generateTypes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAKzD,wBAAsB,aAAa,CACjC,MAAM,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,GACzB,OAAO,CAAC,IAAI,CAAC,CAkCf"}
1
+ {"version":3,"file":"generateTypes.d.ts","sourceRoot":"","sources":["../../src/bin/generateTypes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAKzD,wBAAsB,aAAa,CACjC,MAAM,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,GACzB,OAAO,CAAC,IAAI,CAAC,CA8Cf"}
@@ -27,6 +27,15 @@ export async function generateTypes(config, options) {
27
27
  compiled += `\n\n${declare}`;
28
28
  }
29
29
  }
30
+ // Diff the compiled types against the existing types file
31
+ try {
32
+ const existingTypes = fs.readFileSync(outputFile, 'utf-8');
33
+ if (compiled === existingTypes) {
34
+ return;
35
+ }
36
+ } catch (_) {
37
+ // swallow err
38
+ }
30
39
  fs.writeFileSync(outputFile, compiled);
31
40
  if (shouldLog) logger.info(`Types written to ${outputFile}`);
32
41
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bin/generateTypes.ts"],"sourcesContent":["import fs from 'fs'\nimport { compile } from 'json-schema-to-typescript'\n\nimport type { SanitizedConfig } from '../config/types.js'\n\nimport { configToJSONSchema } from '../utilities/configToJSONSchema.js'\nimport Logger from '../utilities/logger.js'\n\nexport async function generateTypes(\n config: SanitizedConfig,\n options?: { log: boolean },\n): Promise<void> {\n const logger = Logger()\n const outputFile = process.env.PAYLOAD_TS_OUTPUT_PATH || config.typescript.outputFile\n\n const shouldLog = options?.log ?? true\n\n if (shouldLog) logger.info('Compiling TS types for Collections and Globals...')\n\n const jsonSchema = configToJSONSchema(config, config.db.defaultIDType)\n\n const declare = `declare module 'payload' {\\n export interface GeneratedTypes extends Config {}\\n}`\n const declareWithTSIgnoreError = `declare module 'payload' {\\n // @ts-ignore \\n export interface GeneratedTypes extends Config {}\\n}`\n\n let compiled = await compile(jsonSchema, 'Config', {\n bannerComment:\n '/* tslint:disable */\\n/* eslint-disable */\\n/**\\n* This file was automatically generated by Payload.\\n* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,\\n* and re-run `payload generate:types` to regenerate this file.\\n*/',\n style: {\n singleQuote: true,\n },\n // Generates code for $defs that aren't referenced by the schema. Reason:\n // If a field defines an interfaceName, it should be included in the generated types\n // even if it's not used by another type. Reason: the user might want to use it in their own code.\n unreachableDefinitions: true,\n })\n\n if (config.typescript.declare !== false) {\n if (config.typescript.declare?.ignoreTSError) {\n compiled += `\\n\\n${declareWithTSIgnoreError}`\n } else {\n compiled += `\\n\\n${declare}`\n }\n }\n fs.writeFileSync(outputFile, compiled)\n if (shouldLog) logger.info(`Types written to ${outputFile}`)\n}\n"],"names":["fs","compile","configToJSONSchema","Logger","generateTypes","config","options","logger","outputFile","process","env","PAYLOAD_TS_OUTPUT_PATH","typescript","shouldLog","log","info","jsonSchema","db","defaultIDType","declare","declareWithTSIgnoreError","compiled","bannerComment","style","singleQuote","unreachableDefinitions","ignoreTSError","writeFileSync"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,SAASC,OAAO,QAAQ,4BAA2B;AAInD,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,OAAOC,YAAY,yBAAwB;AAE3C,OAAO,eAAeC,cACpBC,MAAuB,EACvBC,OAA0B;IAE1B,MAAMC,SAASJ;IACf,MAAMK,aAAaC,QAAQC,GAAG,CAACC,sBAAsB,IAAIN,OAAOO,UAAU,CAACJ,UAAU;IAErF,MAAMK,YAAYP,SAASQ,OAAO;IAElC,IAAID,WAAWN,OAAOQ,IAAI,CAAC;IAE3B,MAAMC,aAAad,mBAAmBG,QAAQA,OAAOY,EAAE,CAACC,aAAa;IAErE,MAAMC,UAAU,CAAC,kFAAkF,CAAC;IACpG,MAAMC,2BAA2B,CAAC,oGAAoG,CAAC;IAEvI,IAAIC,WAAW,MAAMpB,QAAQe,YAAY,UAAU;QACjDM,eACE;QACFC,OAAO;YACLC,aAAa;QACf;QACA,yEAAyE;QACzE,oFAAoF;QACpF,kGAAkG;QAClGC,wBAAwB;IAC1B;IAEA,IAAIpB,OAAOO,UAAU,CAACO,OAAO,KAAK,OAAO;QACvC,IAAId,OAAOO,UAAU,CAACO,OAAO,EAAEO,eAAe;YAC5CL,YAAY,CAAC,IAAI,EAAED,yBAAyB,CAAC;QAC/C,OAAO;YACLC,YAAY,CAAC,IAAI,EAAEF,QAAQ,CAAC;QAC9B;IACF;IACAnB,GAAG2B,aAAa,CAACnB,YAAYa;IAC7B,IAAIR,WAAWN,OAAOQ,IAAI,CAAC,CAAC,iBAAiB,EAAEP,WAAW,CAAC;AAC7D"}
1
+ {"version":3,"sources":["../../src/bin/generateTypes.ts"],"sourcesContent":["import fs from 'fs'\nimport { compile } from 'json-schema-to-typescript'\n\nimport type { SanitizedConfig } from '../config/types.js'\n\nimport { configToJSONSchema } from '../utilities/configToJSONSchema.js'\nimport Logger from '../utilities/logger.js'\n\nexport async function generateTypes(\n config: SanitizedConfig,\n options?: { log: boolean },\n): Promise<void> {\n const logger = Logger()\n const outputFile = process.env.PAYLOAD_TS_OUTPUT_PATH || config.typescript.outputFile\n\n const shouldLog = options?.log ?? true\n\n if (shouldLog) logger.info('Compiling TS types for Collections and Globals...')\n\n const jsonSchema = configToJSONSchema(config, config.db.defaultIDType)\n\n const declare = `declare module 'payload' {\\n export interface GeneratedTypes extends Config {}\\n}`\n const declareWithTSIgnoreError = `declare module 'payload' {\\n // @ts-ignore \\n export interface GeneratedTypes extends Config {}\\n}`\n\n let compiled = await compile(jsonSchema, 'Config', {\n bannerComment:\n '/* tslint:disable */\\n/* eslint-disable */\\n/**\\n* This file was automatically generated by Payload.\\n* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,\\n* and re-run `payload generate:types` to regenerate this file.\\n*/',\n style: {\n singleQuote: true,\n },\n // Generates code for $defs that aren't referenced by the schema. Reason:\n // If a field defines an interfaceName, it should be included in the generated types\n // even if it's not used by another type. Reason: the user might want to use it in their own code.\n unreachableDefinitions: true,\n })\n\n if (config.typescript.declare !== false) {\n if (config.typescript.declare?.ignoreTSError) {\n compiled += `\\n\\n${declareWithTSIgnoreError}`\n } else {\n compiled += `\\n\\n${declare}`\n }\n }\n\n // Diff the compiled types against the existing types file\n try {\n const existingTypes = fs.readFileSync(outputFile, 'utf-8')\n\n if (compiled === existingTypes) {\n return\n }\n } catch (_) {\n // swallow err\n }\n\n fs.writeFileSync(outputFile, compiled)\n if (shouldLog) logger.info(`Types written to ${outputFile}`)\n}\n"],"names":["fs","compile","configToJSONSchema","Logger","generateTypes","config","options","logger","outputFile","process","env","PAYLOAD_TS_OUTPUT_PATH","typescript","shouldLog","log","info","jsonSchema","db","defaultIDType","declare","declareWithTSIgnoreError","compiled","bannerComment","style","singleQuote","unreachableDefinitions","ignoreTSError","existingTypes","readFileSync","_","writeFileSync"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,SAASC,OAAO,QAAQ,4BAA2B;AAInD,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,OAAOC,YAAY,yBAAwB;AAE3C,OAAO,eAAeC,cACpBC,MAAuB,EACvBC,OAA0B;IAE1B,MAAMC,SAASJ;IACf,MAAMK,aAAaC,QAAQC,GAAG,CAACC,sBAAsB,IAAIN,OAAOO,UAAU,CAACJ,UAAU;IAErF,MAAMK,YAAYP,SAASQ,OAAO;IAElC,IAAID,WAAWN,OAAOQ,IAAI,CAAC;IAE3B,MAAMC,aAAad,mBAAmBG,QAAQA,OAAOY,EAAE,CAACC,aAAa;IAErE,MAAMC,UAAU,CAAC,kFAAkF,CAAC;IACpG,MAAMC,2BAA2B,CAAC,oGAAoG,CAAC;IAEvI,IAAIC,WAAW,MAAMpB,QAAQe,YAAY,UAAU;QACjDM,eACE;QACFC,OAAO;YACLC,aAAa;QACf;QACA,yEAAyE;QACzE,oFAAoF;QACpF,kGAAkG;QAClGC,wBAAwB;IAC1B;IAEA,IAAIpB,OAAOO,UAAU,CAACO,OAAO,KAAK,OAAO;QACvC,IAAId,OAAOO,UAAU,CAACO,OAAO,EAAEO,eAAe;YAC5CL,YAAY,CAAC,IAAI,EAAED,yBAAyB,CAAC;QAC/C,OAAO;YACLC,YAAY,CAAC,IAAI,EAAEF,QAAQ,CAAC;QAC9B;IACF;IAEA,0DAA0D;IAC1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C,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC,KAC5D,QAAQ,cAAc,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,CAoU9C,CAAA"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/collections/operations/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAIjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAY,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAC5E,OAAO,KAAK,EAIV,UAAU,EACX,MAAM,oBAAoB,CAAA;AAmB3B,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,CAAA;AAE7E,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,gBAAgB,IAAI;IAClD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE,YAAY,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,GAAG,WAAW,CAAC,CAAA;IACjE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,GAAG,EAAE,sBAAsB,CAAA;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,eAAe,yDACZ,UAAU,cAAc,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC,KAC5D,QAAQ,cAAc,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,CAmU9C,CAAA"}
@@ -170,8 +170,7 @@ export const createOperation = async (incomingArgs)=>{
170
170
  // Send verification email if applicable
171
171
  // /////////////////////////////////////
172
172
  if (collectionConfig.auth && collectionConfig.auth.verify) {
173
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
174
- sendVerificationEmail({
173
+ await sendVerificationEmail({
175
174
  collection: {
176
175
  config: collectionConfig
177
176
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/operations/create.ts"],"sourcesContent":["import type { MarkOptional } from 'ts-essentials'\n\nimport crypto from 'crypto'\n\nimport type { GeneratedTypes } from '../../index.js'\nimport type { Document, PayloadRequestWithData } from '../../types/index.js'\nimport type {\n AfterChangeHook,\n BeforeOperationHook,\n BeforeValidateHook,\n Collection,\n} from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { sendVerificationEmail } from '../../auth/sendVerificationEmail.js'\nimport { registerLocalStrategy } from '../../auth/strategies/local/register.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { generateFileData } from '../../uploads/generateFileData.js'\nimport { unlinkTempFiles } from '../../uploads/unlinkTempFiles.js'\nimport { uploadFiles } from '../../uploads/uploadFiles.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\nimport { buildAfterOperation } from './utils.js'\n\nexport type CreateUpdateType = { [field: number | string | symbol]: unknown }\n\nexport type Arguments<T extends CreateUpdateType> = {\n autosave?: boolean\n collection: Collection\n data: MarkOptional<T, 'createdAt' | 'id' | 'sizes' | 'updatedAt'>\n depth?: number\n disableVerificationEmail?: boolean\n draft?: boolean\n overrideAccess?: boolean\n overwriteExistingFiles?: boolean\n req: PayloadRequestWithData\n showHiddenFields?: boolean\n}\n\nexport const createOperation = async <TSlug extends keyof GeneratedTypes['collections']>(\n incomingArgs: Arguments<GeneratedTypes['collections'][TSlug]>,\n): Promise<GeneratedTypes['collections'][TSlug]> => {\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(\n async (priorHook: BeforeOperationHook | Promise<void>, hook: BeforeOperationHook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req.context,\n operation: 'create',\n req: args.req,\n })) || args\n },\n Promise.resolve(),\n )\n\n const {\n autosave = false,\n collection: { config: collectionConfig },\n collection,\n depth,\n disableVerificationEmail,\n draft = false,\n overrideAccess,\n overwriteExistingFiles = false,\n req: {\n fallbackLocale,\n locale,\n payload,\n payload: { config, email },\n },\n req,\n showHiddenFields,\n } = args\n\n let { data } = args\n\n const shouldSaveDraft = Boolean(draft && collectionConfig.versions.drafts)\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n if (!overrideAccess) {\n await executeAccess({ data, req }, collectionConfig.access.create)\n }\n\n // /////////////////////////////////////\n // Custom id\n // /////////////////////////////////////\n\n if (payload.collections[collectionConfig.slug].customIDType) {\n data = {\n _id: data.id,\n ...data,\n }\n }\n\n // /////////////////////////////////////\n // Generate data for all files and sizes\n // /////////////////////////////////////\n\n const { data: newFileData, files: filesToUpload } = await generateFileData({\n collection,\n config,\n data,\n operation: 'create',\n overwriteExistingFiles,\n req,\n throwOnMissingFile:\n !shouldSaveDraft && collection.config.upload.filesRequiredOnCreate !== false,\n })\n\n data = newFileData\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: {},\n global: null,\n operation: 'create',\n overrideAccess,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Collections\n // /////////////////////////////////////\n\n await collectionConfig.hooks.beforeValidate.reduce(\n async (priorHook: BeforeValidateHook | Promise<void>, hook: BeforeValidateHook) => {\n await priorHook\n\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'create',\n req,\n })) || data\n },\n Promise.resolve(),\n )\n\n // /////////////////////////////////////\n // beforeChange - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.beforeChange.reduce(async (priorHook, hook) => {\n await priorHook\n\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'create',\n req,\n })) || data\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n const resultWithLocales = await beforeChange<Record<string, unknown>>({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: {},\n docWithLocales: {},\n global: null,\n operation: 'create',\n req,\n skipValidation:\n shouldSaveDraft &&\n collectionConfig.versions.drafts &&\n !collectionConfig.versions.drafts.validate,\n })\n\n // /////////////////////////////////////\n // Write files to local storage\n // /////////////////////////////////////\n\n if (!collectionConfig.upload.disableLocalStorage) {\n await uploadFiles(payload, filesToUpload, req)\n }\n\n // /////////////////////////////////////\n // Create\n // /////////////////////////////////////\n\n let doc\n\n if (collectionConfig.auth && !collectionConfig.auth.disableLocalStrategy) {\n if (data.email) {\n resultWithLocales.email = (data.email as string).toLowerCase()\n }\n\n if (collectionConfig.auth.verify) {\n resultWithLocales._verified = Boolean(resultWithLocales._verified) || false\n resultWithLocales._verificationToken = crypto.randomBytes(20).toString('hex')\n }\n\n doc = await registerLocalStrategy({\n collection: collectionConfig,\n doc: resultWithLocales,\n password: data.password as string,\n payload: req.payload,\n req,\n })\n } else {\n doc = await payload.db.create({\n collection: collectionConfig.slug,\n data: resultWithLocales,\n req,\n })\n }\n\n const verificationToken = doc._verificationToken\n let result: Document = sanitizeInternalFields(doc)\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n\n if (collectionConfig.versions) {\n await saveVersion({\n id: result.id,\n autosave,\n collection: collectionConfig,\n docWithLocales: result,\n payload,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Send verification email if applicable\n // /////////////////////////////////////\n\n if (collectionConfig.auth && collectionConfig.auth.verify) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n sendVerificationEmail({\n collection: { config: collectionConfig },\n config: payload.config,\n disableEmail: disableVerificationEmail,\n email: payload.email,\n req,\n token: verificationToken,\n user: result,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth,\n doc: result,\n draft,\n fallbackLocale,\n global: null,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n global: null,\n operation: 'create',\n previousDoc: {},\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterChange.reduce(\n async (priorHook: AfterChangeHook | Promise<void>, hook: AfterChangeHook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n operation: 'create',\n previousDoc: {},\n req: args.req,\n })) || result\n },\n Promise.resolve(),\n )\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation<GeneratedTypes['collections'][TSlug]>({\n args,\n collection: collectionConfig,\n operation: 'create',\n result,\n })\n\n await unlinkTempFiles({ collectionConfig, config, req })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) await commitTransaction(req)\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["crypto","executeAccess","sendVerificationEmail","registerLocalStrategy","afterChange","afterRead","beforeChange","beforeValidate","generateFileData","unlinkTempFiles","uploadFiles","commitTransaction","initTransaction","killTransaction","sanitizeInternalFields","saveVersion","buildAfterOperation","createOperation","incomingArgs","args","shouldCommit","req","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","autosave","collectionConfig","depth","disableVerificationEmail","draft","overrideAccess","overwriteExistingFiles","fallbackLocale","locale","payload","email","showHiddenFields","data","shouldSaveDraft","Boolean","versions","drafts","access","create","collections","slug","customIDType","_id","id","newFileData","files","filesToUpload","throwOnMissingFile","upload","filesRequiredOnCreate","doc","global","resultWithLocales","docWithLocales","skipValidation","validate","disableLocalStorage","auth","disableLocalStrategy","toLowerCase","verify","_verified","_verificationToken","randomBytes","toString","password","db","verificationToken","result","disableEmail","token","user","previousDoc","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,YAAY,SAAQ;AAW3B,OAAOC,mBAAmB,8BAA6B;AACvD,SAASC,qBAAqB,QAAQ,sCAAqC;AAC3E,SAASC,qBAAqB,QAAQ,0CAAyC;AAC/E,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,SAASC,gBAAgB,QAAQ,oCAAm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AW;YACXuD,aAAa,CAAC;YACdhE;QACF;QAEA,wCAAwC;QACxC,2BAA2B;QAC3B,wCAAwC;QAExC,MAAMa,iBAAiBV,KAAK,CAACpB,WAAW,CAACsB,MAAM,CAC7C,OAAOC,WAA4CC;YACjD,MAAMD;YAENsD,SACE,AAAC,MAAMrD,KAAK;gBACVN,YAAYY;gBACZL,SAASR,IAAIQ,OAAO;gBACpBkC,KAAKkB;gBACLnD,WAAW;gBACXuD,aAAa,CAAC;gBACdhE,KAAKF,KAAKE,GAAG;YACf,MAAO4D;QACX,GACAlD,QAAQC,OAAO;QAGjB,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCiD,SAAS,MAAMjE,oBAA0D;YACvEG;YACAG,YAAYY;YACZJ,WAAW;YACXmD;QACF;QAEA,MAAMxE,gBAAgB;YAAEyB;YAAkBX;YAAQF;QAAI;QAEtD,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,IAAID,cAAc,MAAMT,kBAAkBU;QAE1C,OAAO4D;IACT,EAAE,OAAOK,OAAgB;QACvB,MAAMzE,gBAAgBM,KAAKE,GAAG;QAC9B,MAAMiE;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/collections/operations/create.ts"],"sourcesContent":["import type { MarkOptional } from 'ts-essentials'\n\nimport crypto from 'crypto'\n\nimport type { GeneratedTypes } from '../../index.js'\nimport type { Document, PayloadRequestWithData } from '../../types/index.js'\nimport type {\n AfterChangeHook,\n BeforeOperationHook,\n BeforeValidateHook,\n Collection,\n} from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { sendVerificationEmail } from '../../auth/sendVerificationEmail.js'\nimport { registerLocalStrategy } from '../../auth/strategies/local/register.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { generateFileData } from '../../uploads/generateFileData.js'\nimport { unlinkTempFiles } from '../../uploads/unlinkTempFiles.js'\nimport { uploadFiles } from '../../uploads/uploadFiles.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\nimport { buildAfterOperation } from './utils.js'\n\nexport type CreateUpdateType = { [field: number | string | symbol]: unknown }\n\nexport type Arguments<T extends CreateUpdateType> = {\n autosave?: boolean\n collection: Collection\n data: MarkOptional<T, 'createdAt' | 'id' | 'sizes' | 'updatedAt'>\n depth?: number\n disableVerificationEmail?: boolean\n draft?: boolean\n overrideAccess?: boolean\n overwriteExistingFiles?: boolean\n req: PayloadRequestWithData\n showHiddenFields?: boolean\n}\n\nexport const createOperation = async <TSlug extends keyof GeneratedTypes['collections']>(\n incomingArgs: Arguments<GeneratedTypes['collections'][TSlug]>,\n): Promise<GeneratedTypes['collections'][TSlug]> => {\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(\n async (priorHook: BeforeOperationHook | Promise<void>, hook: BeforeOperationHook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection.config,\n context: args.req.context,\n operation: 'create',\n req: args.req,\n })) || args\n },\n Promise.resolve(),\n )\n\n const {\n autosave = false,\n collection: { config: collectionConfig },\n collection,\n depth,\n disableVerificationEmail,\n draft = false,\n overrideAccess,\n overwriteExistingFiles = false,\n req: {\n fallbackLocale,\n locale,\n payload,\n payload: { config, email },\n },\n req,\n showHiddenFields,\n } = args\n\n let { data } = args\n\n const shouldSaveDraft = Boolean(draft && collectionConfig.versions.drafts)\n\n // /////////////////////////////////////\n // Access\n // /////////////////////////////////////\n\n if (!overrideAccess) {\n await executeAccess({ data, req }, collectionConfig.access.create)\n }\n\n // /////////////////////////////////////\n // Custom id\n // /////////////////////////////////////\n\n if (payload.collections[collectionConfig.slug].customIDType) {\n data = {\n _id: data.id,\n ...data,\n }\n }\n\n // /////////////////////////////////////\n // Generate data for all files and sizes\n // /////////////////////////////////////\n\n const { data: newFileData, files: filesToUpload } = await generateFileData({\n collection,\n config,\n data,\n operation: 'create',\n overwriteExistingFiles,\n req,\n throwOnMissingFile:\n !shouldSaveDraft && collection.config.upload.filesRequiredOnCreate !== false,\n })\n\n data = newFileData\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: {},\n global: null,\n operation: 'create',\n overrideAccess,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Collections\n // /////////////////////////////////////\n\n await collectionConfig.hooks.beforeValidate.reduce(\n async (priorHook: BeforeValidateHook | Promise<void>, hook: BeforeValidateHook) => {\n await priorHook\n\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'create',\n req,\n })) || data\n },\n Promise.resolve(),\n )\n\n // /////////////////////////////////////\n // beforeChange - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.beforeChange.reduce(async (priorHook, hook) => {\n await priorHook\n\n data =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n data,\n operation: 'create',\n req,\n })) || data\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n const resultWithLocales = await beforeChange<Record<string, unknown>>({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: {},\n docWithLocales: {},\n global: null,\n operation: 'create',\n req,\n skipValidation:\n shouldSaveDraft &&\n collectionConfig.versions.drafts &&\n !collectionConfig.versions.drafts.validate,\n })\n\n // /////////////////////////////////////\n // Write files to local storage\n // /////////////////////////////////////\n\n if (!collectionConfig.upload.disableLocalStorage) {\n await uploadFiles(payload, filesToUpload, req)\n }\n\n // /////////////////////////////////////\n // Create\n // /////////////////////////////////////\n\n let doc\n\n if (collectionConfig.auth && !collectionConfig.auth.disableLocalStrategy) {\n if (data.email) {\n resultWithLocales.email = (data.email as string).toLowerCase()\n }\n\n if (collectionConfig.auth.verify) {\n resultWithLocales._verified = Boolean(resultWithLocales._verified) || false\n resultWithLocales._verificationToken = crypto.randomBytes(20).toString('hex')\n }\n\n doc = await registerLocalStrategy({\n collection: collectionConfig,\n doc: resultWithLocales,\n password: data.password as string,\n payload: req.payload,\n req,\n })\n } else {\n doc = await payload.db.create({\n collection: collectionConfig.slug,\n data: resultWithLocales,\n req,\n })\n }\n\n const verificationToken = doc._verificationToken\n let result: Document = sanitizeInternalFields(doc)\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n\n if (collectionConfig.versions) {\n await saveVersion({\n id: result.id,\n autosave,\n collection: collectionConfig,\n docWithLocales: result,\n payload,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Send verification email if applicable\n // /////////////////////////////////////\n\n if (collectionConfig.auth && collectionConfig.auth.verify) {\n await sendVerificationEmail({\n collection: { config: collectionConfig },\n config: payload.config,\n disableEmail: disableVerificationEmail,\n email: payload.email,\n req,\n token: verificationToken,\n user: result,\n })\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth,\n doc: result,\n draft,\n fallbackLocale,\n global: null,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n req,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: collectionConfig,\n context: req.context,\n data,\n doc: result,\n global: null,\n operation: 'create',\n previousDoc: {},\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterChange.reduce(\n async (priorHook: AfterChangeHook | Promise<void>, hook: AfterChangeHook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collectionConfig,\n context: req.context,\n doc: result,\n operation: 'create',\n previousDoc: {},\n req: args.req,\n })) || result\n },\n Promise.resolve(),\n )\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation<GeneratedTypes['collections'][TSlug]>({\n args,\n collection: collectionConfig,\n operation: 'create',\n result,\n })\n\n await unlinkTempFiles({ collectionConfig, config, req })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) await commitTransaction(req)\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["crypto","executeAccess","sendVerificationEmail","registerLocalStrategy","afterChange","afterRead","beforeChange","beforeValidate","generateFileData","unlinkTempFiles","uploadFiles","commitTransaction","initTransaction","killTransaction","sanitizeInternalFields","saveVersion","buildAfterOperation","createOperation","incomingArgs","args","shouldCommit","req","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","autosave","collectionConfig","depth","disableVerificationEmail","draft","overrideAccess","overwriteExistingFiles","fallbackLocale","locale","payload","email","showHiddenFields","data","shouldSaveDraft","Boolean","versions","drafts","access","create","collections","slug","customIDType","_id","id","newFileData","files","filesToUpload","throwOnMissingFile","upload","filesRequiredOnCreate","doc","global","resultWithLocales","docWithLocales","skipValidation","validate","disableLocalStorage","auth","disableLocalStrategy","toLowerCase","verify","_verified","_verificationToken","randomBytes","toString","password","db","verificationToken","result","disableEmail","token","user","previousDoc","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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 -1 +1 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/fields/config/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAiBvC,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAChC,MAAM,EAAE,KAAK,EAAE,CAAA;IACf;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAA;IACzC;;;OAGG;IACH,4BAA4B,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAEhF;;;OAGG;IACH,kBAAkB,EAAE,IAAI,GAAG,MAAM,EAAE,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,+HAOxB,IAAI,KAAG,QAAQ,KAAK,EAAE,CA4MxB,CAAA"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../src/fields/config/sanitize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAiBvC,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAChC,MAAM,EAAE,KAAK,EAAE,CAAA;IACf;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAA;IACzC;;;OAGG;IACH,4BAA4B,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAEhF;;;OAGG;IACH,kBAAkB,EAAE,IAAI,GAAG,MAAM,EAAE,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,+HAOxB,IAAI,KAAG,QAAQ,KAAK,EAAE,CAyLxB,CAAA"}
@@ -106,21 +106,6 @@ export const sanitizeFields = async ({ config, existingFieldNames = new Set(), f
106
106
  if (field.editor.i18n && Object.keys(field.editor.i18n).length >= 0) {
107
107
  config.i18n.translations = deepMerge(config.i18n.translations, field.editor.i18n);
108
108
  }
109
- // Add editor adapter hooks to field hooks
110
- if (!field.hooks) field.hooks = {};
111
- const mergeHooks = (hookName)=>{
112
- if (typeof field.editor === 'function') return;
113
- if (field.editor?.hooks?.[hookName]?.length) {
114
- field.hooks[hookName] = field.hooks[hookName] ? field.hooks[hookName].concat(field.editor.hooks[hookName]) : [
115
- ...field.editor.hooks[hookName]
116
- ];
117
- }
118
- };
119
- mergeHooks('afterRead');
120
- mergeHooks('afterChange');
121
- mergeHooks('beforeChange');
122
- mergeHooks('beforeValidate');
123
- mergeHooks('beforeDuplicate');
124
109
  };
125
110
  if (richTextSanitizationPromises) {
126
111
  richTextSanitizationPromises.push(sanitizeRichText);