payload 1.11.6 → 1.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/components/forms/Form/fieldReducer.js +0 -4
- package/dist/admin/components/forms/Form/fieldReducer.js.map +1 -1
- package/dist/admin/components/forms/field-types/Array/index.js +6 -7
- package/dist/admin/components/forms/field-types/Array/index.js.map +1 -1
- package/dist/admin/components/forms/field-types/Blocks/index.js +2 -4
- package/dist/admin/components/forms/field-types/Blocks/index.js.map +1 -1
- package/dist/admin/components/forms/useField/index.js +1 -3
- package/dist/admin/components/forms/useField/index.js.map +1 -1
- package/dist/auth/operations/forgotPassword.js +2 -1
- package/dist/auth/operations/forgotPassword.js.map +1 -1
- package/dist/auth/operations/local/forgotPassword.js +2 -0
- package/dist/auth/operations/local/forgotPassword.js.map +1 -1
- package/dist/auth/operations/local/login.js +2 -0
- package/dist/auth/operations/local/login.js.map +1 -1
- package/dist/auth/operations/local/resetPassword.js +2 -0
- package/dist/auth/operations/local/resetPassword.js.map +1 -1
- package/dist/auth/operations/local/unlock.js +2 -0
- package/dist/auth/operations/local/unlock.js.map +1 -1
- package/dist/auth/operations/login.js +5 -0
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/logout.js +1 -0
- package/dist/auth/operations/logout.js.map +1 -1
- package/dist/auth/operations/me.js +1 -0
- package/dist/auth/operations/me.js.map +1 -1
- package/dist/auth/operations/refresh.js +2 -0
- package/dist/auth/operations/refresh.js.map +1 -1
- package/dist/collections/config/types.d.ts +16 -2
- package/dist/collections/operations/create.js +9 -0
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/delete.js +5 -0
- package/dist/collections/operations/delete.js.map +1 -1
- package/dist/collections/operations/deleteByID.js +5 -1
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/find.js +4 -2
- package/dist/collections/operations/find.js.map +1 -1
- package/dist/collections/operations/findByID.js +4 -0
- package/dist/collections/operations/findByID.js.map +1 -1
- package/dist/collections/operations/findVersionByID.js +3 -0
- package/dist/collections/operations/findVersionByID.js.map +1 -1
- package/dist/collections/operations/findVersions.js +3 -2
- package/dist/collections/operations/findVersions.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +5 -1
- package/dist/collections/operations/local/create.js +3 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts +5 -0
- package/dist/collections/operations/local/delete.js +3 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/collections/operations/local/find.d.ts +5 -1
- package/dist/collections/operations/local/find.js +3 -1
- package/dist/collections/operations/local/find.js.map +1 -1
- package/dist/collections/operations/local/findByID.d.ts +5 -1
- package/dist/collections/operations/local/findByID.js +3 -1
- package/dist/collections/operations/local/findByID.js.map +1 -1
- package/dist/collections/operations/local/findVersionByID.d.ts +6 -1
- package/dist/collections/operations/local/findVersionByID.js +3 -1
- package/dist/collections/operations/local/findVersionByID.js.map +1 -1
- package/dist/collections/operations/local/findVersions.d.ts +6 -0
- package/dist/collections/operations/local/findVersions.js +3 -1
- package/dist/collections/operations/local/findVersions.js.map +1 -1
- package/dist/collections/operations/local/restoreVersion.d.ts +6 -0
- package/dist/collections/operations/local/restoreVersion.js +3 -1
- package/dist/collections/operations/local/restoreVersion.js.map +1 -1
- package/dist/collections/operations/local/update.d.ts +5 -0
- package/dist/collections/operations/local/update.js +3 -1
- package/dist/collections/operations/local/update.js.map +1 -1
- package/dist/collections/operations/restoreVersion.js +4 -0
- package/dist/collections/operations/restoreVersion.js.map +1 -1
- package/dist/collections/operations/update.js +10 -0
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.js +10 -0
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/express/middleware/defaultPayload.d.ts +4 -0
- package/dist/express/middleware/defaultPayload.js +9 -0
- package/dist/express/middleware/defaultPayload.js.map +1 -0
- package/dist/express/middleware/errorHandler.js +2 -2
- package/dist/express/middleware/errorHandler.js.map +1 -1
- package/dist/express/middleware/index.js +2 -0
- package/dist/express/middleware/index.js.map +1 -1
- package/dist/express/setRequestContext.d.ts +6 -0
- package/dist/express/setRequestContext.js +22 -0
- package/dist/express/setRequestContext.js.map +1 -0
- package/dist/express/types.d.ts +10 -1
- package/dist/fields/config/types.d.ts +2 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/afterChange/index.d.ts +3 -2
- package/dist/fields/hooks/afterChange/index.js +2 -1
- package/dist/fields/hooks/afterChange/index.js.map +1 -1
- package/dist/fields/hooks/afterChange/promise.d.ts +3 -2
- package/dist/fields/hooks/afterChange/promise.js +8 -1
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts +3 -2
- package/dist/fields/hooks/afterChange/traverseFields.js +2 -1
- package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts +2 -1
- package/dist/fields/hooks/afterRead/index.js +2 -1
- package/dist/fields/hooks/afterRead/index.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts +3 -2
- package/dist/fields/hooks/afterRead/promise.js +11 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +3 -2
- package/dist/fields/hooks/afterRead/traverseFields.js +2 -1
- package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts +3 -2
- package/dist/fields/hooks/beforeChange/index.js +2 -1
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts +3 -2
- package/dist/fields/hooks/beforeChange/promise.js +8 -1
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +3 -2
- package/dist/fields/hooks/beforeChange/traverseFields.js +2 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts +3 -2
- package/dist/fields/hooks/beforeValidate/index.js +2 -1
- package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts +3 -2
- package/dist/fields/hooks/beforeValidate/promise.js +8 -1
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +3 -2
- package/dist/fields/hooks/beforeValidate/traverseFields.js +2 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
- package/dist/globals/operations/findOne.js +1 -0
- package/dist/globals/operations/findOne.js.map +1 -1
- package/dist/globals/operations/findVersionByID.js +1 -0
- package/dist/globals/operations/findVersionByID.js.map +1 -1
- package/dist/globals/operations/findVersions.js +1 -0
- package/dist/globals/operations/findVersions.js.map +1 -1
- package/dist/globals/operations/local/findOne.js +2 -0
- package/dist/globals/operations/local/findOne.js.map +1 -1
- package/dist/globals/operations/local/findVersionByID.js +2 -0
- package/dist/globals/operations/local/findVersionByID.js.map +1 -1
- package/dist/globals/operations/local/findVersions.js +2 -0
- package/dist/globals/operations/local/findVersions.js.map +1 -1
- package/dist/globals/operations/local/restoreVersion.js +2 -0
- package/dist/globals/operations/local/restoreVersion.js.map +1 -1
- package/dist/globals/operations/local/update.js +2 -0
- package/dist/globals/operations/local/update.js.map +1 -1
- package/dist/globals/operations/restoreVersion.js +2 -0
- package/dist/globals/operations/restoreVersion.js.map +1 -1
- package/dist/globals/operations/update.js +5 -0
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/graphql/errorHandler.js +1 -1
- package/dist/graphql/errorHandler.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js.map +1 -1
- package/dist/uploads/generateFileData.js +2 -2
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/imageResizer.js +1 -1
- package/dist/uploads/imageResizer.js.map +1 -1
- package/docs/hooks/context.mdx +127 -0
- package/docs/local-api/overview.mdx +1 -0
- package/package.json +1 -1
|
@@ -58,6 +58,7 @@ async function update(args) {
|
|
|
58
58
|
req,
|
|
59
59
|
overrideAccess: true,
|
|
60
60
|
showHiddenFields,
|
|
61
|
+
context: req.context,
|
|
61
62
|
});
|
|
62
63
|
// /////////////////////////////////////
|
|
63
64
|
// beforeValidate - Fields
|
|
@@ -69,6 +70,7 @@ async function update(args) {
|
|
|
69
70
|
operation: 'update',
|
|
70
71
|
overrideAccess,
|
|
71
72
|
req,
|
|
73
|
+
context: req.context,
|
|
72
74
|
});
|
|
73
75
|
// /////////////////////////////////////
|
|
74
76
|
// beforeValidate - Global
|
|
@@ -103,6 +105,7 @@ async function update(args) {
|
|
|
103
105
|
operation: 'update',
|
|
104
106
|
req,
|
|
105
107
|
skipValidation: shouldSaveDraft,
|
|
108
|
+
context: req.context,
|
|
106
109
|
});
|
|
107
110
|
// /////////////////////////////////////
|
|
108
111
|
// Update
|
|
@@ -145,6 +148,7 @@ async function update(args) {
|
|
|
145
148
|
req,
|
|
146
149
|
overrideAccess,
|
|
147
150
|
showHiddenFields,
|
|
151
|
+
context: req.context,
|
|
148
152
|
});
|
|
149
153
|
// /////////////////////////////////////
|
|
150
154
|
// afterRead - Global
|
|
@@ -165,6 +169,7 @@ async function update(args) {
|
|
|
165
169
|
previousDoc: originalDoc,
|
|
166
170
|
entityConfig: globalConfig,
|
|
167
171
|
operation: 'update',
|
|
172
|
+
context: req.context,
|
|
168
173
|
req,
|
|
169
174
|
});
|
|
170
175
|
// /////////////////////////////////////
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/globals/operations/update.ts"],"names":[],"mappings":";;;;;AAGA,6EAAqD;AACrD,kEAA+D;AAC/D,sEAAmE;AACnE,gEAA6D;AAC7D,4DAAyD;AAEzD,4DAAyD;AACzD,oGAA4E;AAC5E,kFAA+E;AAc/E,KAAK,UAAU,MAAM,CACnB,IAA4C;;IAE5C,MAAM,EACJ,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,CAAC,GAAG,EAAE;YAClB,OAAO,UAAU,CAAC,GAAG,CAAC;SACvB;KACF;IAED,MAAM,WAAW,GAAG,MAAM,IAAA,qBAAS,EAAC;QAClC,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,UAAU;QACf,YAAY,EAAE,YAAY;QAC1B,GAAG;QACH,cAAc,EAAE,IAAI;QACpB,gBAAgB;
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/globals/operations/update.ts"],"names":[],"mappings":";;;;;AAGA,6EAAqD;AACrD,kEAA+D;AAC/D,sEAAmE;AACnE,gEAA6D;AAC7D,4DAAyD;AAEzD,4DAAyD;AACzD,oGAA4E;AAC5E,kFAA+E;AAc/E,KAAK,UAAU,MAAM,CACnB,IAA4C;;IAE5C,MAAM,EACJ,YAAY,EACZ,IAAI,EACJ,GAAG,EACH,GAAG,EAAE,EACH,OAAO,EACP,OAAO,EAAE,EACP,OAAO,EAAE,EACP,KAAK,GACN,GACF,GACF,EACD,KAAK,EACL,cAAc,EACd,gBAAgB,EAChB,KAAK,EAAE,QAAQ,EACf,QAAQ,GACT,GAAG,IAAI,CAAC;IAET,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAEpB,MAAM,eAAe,GAAG,OAAO,CAAC,QAAQ,KAAI,MAAA,YAAY,CAAC,QAAQ,0CAAE,MAAM,CAAA,CAAC,CAAC;IAE3E,wCAAwC;IACxC,iCAAiC;IACjC,wCAAwC;IAExC,MAAM,aAAa,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,IAAA,uBAAa,EAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE9G,wCAAwC;IACxC,oBAAoB;IACpB,wCAAwC;IAExC,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC;QACnC,KAAK,EAAE;YACL,UAAU,EAAE;gBACV,MA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CAAwC;IACxC,uBAAuB;IACvB,wCAAwC;IAExC,MAAM,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE;QACpE,MAAM,SAAS,CAAC;QAEhB,MAAM,GAAG,MAAM,IAAI,CAAC;YAClB,GAAG,EAAE,MAAM;YACX,WAAW,EAAE,WAAW;YACxB,GAAG;SACJ,CAAC,IAAI,MAAM,CAAC;IACf,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAEtB,wCAAwC;IACxC,iBAAiB;IACjB,wCAAwC;IAExC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,kBAAe,MAAM,CAAC"}
|
|
@@ -14,7 +14,7 @@ const errorHandler = async (payload, err, debug, afterErrorHook) => {
|
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
if (afterErrorHook) {
|
|
17
|
-
({ response } = await afterErrorHook(err, response) || { response });
|
|
17
|
+
({ response } = await afterErrorHook(err, response, null) || { response });
|
|
18
18
|
}
|
|
19
19
|
return response;
|
|
20
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandler.js","sourceRoot":"","sources":["../../src/graphql/errorHandler.ts"],"names":[],"mappings":";;AAIA,MAAM,YAAY,GAAG,KAAK,EACxB,OAAgB,EAChB,GAAQ,EACR,KAAc,EACd,cAA8B,EACE,EAAE;;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAEhC,IAAI,QAAQ,GAA0B;QACpC,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,UAAU,EAAE;YACV,IAAI,EAAE,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,aAAa,0CAAE,IAAI,KAAI,SAAS;YAC3C,IAAI,EAAE,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ClB,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Config as GeneratedTypes } from 'payload/generated-types';
|
|
2
2
|
import { InitOptions } from './config/types';
|
|
3
3
|
import { Payload as LocalPayload, BasePayload } from './payload';
|
|
4
|
+
import type { RequestContext } from './express/types';
|
|
4
5
|
export { getPayload } from './payload';
|
|
5
6
|
export declare class Payload extends BasePayload<GeneratedTypes> {
|
|
6
7
|
init(options: InitOptions): Promise<LocalPayload>;
|
|
7
8
|
}
|
|
8
9
|
declare const payload: Payload;
|
|
9
10
|
export default payload;
|
|
11
|
+
export type { RequestContext };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,yCAAsC;AACtC,uCAAiE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,yCAAsC;AACtC,uCAAiE;AAIjE,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AAEnB,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAE5B,MAAa,OAAQ,SAAQ,qBAA2B;IACtD,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAQ,EAAC,OAAO,CAAC,CAAC;QACxC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE7B,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YAClB,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,UAAU;gBAAE,MAAM,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACrE,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,UAAU;gBAAE,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAC9E;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAZD,0BAYC;AAED,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,kBAAe,OAAO,CAAC;AACvB,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -56,10 +56,10 @@ const generateFileData = async ({ config, collection: { config: collectionConfig
|
|
|
56
56
|
sharpOptions.animated = true;
|
|
57
57
|
if (fileSupportsResize && (resizeOptions || formatOptions || trimOptions)) {
|
|
58
58
|
if (file.tempFilePath) {
|
|
59
|
-
sharpFile = (0, sharp_1.default)(file.tempFilePath, sharpOptions);
|
|
59
|
+
sharpFile = (0, sharp_1.default)(file.tempFilePath, sharpOptions).rotate(); // pass rotate() to auto-rotate based on EXIF data. https://github.com/payloadcms/payload/pull/3081
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
sharpFile = (0, sharp_1.default)(file.data, sharpOptions);
|
|
62
|
+
sharpFile = (0, sharp_1.default)(file.data, sharpOptions).rotate(); // pass rotate() to auto-rotate based on EXIF data. https://github.com/payloadcms/payload/pull/3081
|
|
63
63
|
}
|
|
64
64
|
if (resizeOptions) {
|
|
65
65
|
sharpFile = sharpFile
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateFileData.js","sourceRoot":"","sources":["../../src/uploads/generateFileData.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAuC;AACvC,oDAA4B;AAC5B,gDAAwB;AACxB,0EAAyC;AACzC,kDAAqC;AAGrC,sCAAyD;AAEzD,kEAA0C;AAC1C,wEAAgD;AAChD,kEAA2C;AAE3C,sEAA8C;AAC9C,wDAAgC;AAgBzB,MAAM,gBAAgB,GAAG,KAAK,EAAK,EACxC,MAAM,EACN,UAAU,EAAE,EACV,MAAM,EAAE,gBAAgB,EACxB,KAAK,GACN,EACD,GAAG,EACH,IAAI,EACJ,kBAAkB,EAClB,sBAAsB,GACd,EAAa,EAAE;IACvB,IAAI,CA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AAW,EAAE,GAAG,MAAM,IAAA,sBAAa,EAAC;gBACpD,GAAG;gBACH,IAAI;gBACJ,UAAU;gBACV,UAAU;gBACV,MAAM,EAAE,gBAAgB;gBACxB,aAAa,EAAE,UAAU,IAAI,IAAI,CAAC,IAAI;gBACtC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;aAC5B,CAAC,CAAC;YAEH,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC;YAC1B,WAAW,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;SAClC;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,MAAM,IAAI,wBAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KAClC;IAED,OAAO,GAAG;QACR,GAAG,OAAO;QACV,GAAG,QAAQ;KACZ,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,WAAW;KACnB,CAAC;AACJ,CAAC,CAAC;AA1JW,QAAA,gBAAgB,oBA0J3B"}
|
|
@@ -22,7 +22,7 @@ async function resizeAndSave({ req, file, dimensions, staticPath, config, savedF
|
|
|
22
22
|
const { imageSizes } = config.upload;
|
|
23
23
|
const sizesToSave = [];
|
|
24
24
|
const sizeData = {};
|
|
25
|
-
const sharpBase = (0, sharp_1.default)(file.tempFilePath || file.data);
|
|
25
|
+
const sharpBase = (0, sharp_1.default)(file.tempFilePath || file.data).rotate(); // pass rotate() to auto-rotate based on EXIF data. https://github.com/payloadcms/payload/pull/3081
|
|
26
26
|
const promises = imageSizes
|
|
27
27
|
.map(async (desiredSize) => {
|
|
28
28
|
if (!needsResize(desiredSize, dimensions)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageResizer.js","sourceRoot":"","sources":["../../src/uploads/imageResizer.ts"],"names":[],"mappings":";;;;;AACA,yCAAuC;AACvC,4CAAoB;AACpB,0EAAyC;AACzC,kDAA0B;AAG1B,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W,CAAC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;AACnG,CAAC;AAED,SAAS,WAAW,CAAC,WAAsB,EAAE,UAAsB;IACjE,OAAO,CAAC,OAAO,WAAW,CAAC,KAAK,KAAK,QAAQ,IAAI,WAAW,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;WAClF,CAAC,OAAO,WAAW,CAAC,MAAM,KAAK,QAAQ,IAAI,WAAW,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC;WACnF,CAAC,CAAC,WAAW,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Context
|
|
3
|
+
label: Context
|
|
4
|
+
order: 50
|
|
5
|
+
desc: Context allows you to pass in extra data that can be shared between hooks
|
|
6
|
+
keywords: hooks, context, payload context, payloadcontext, data, extra data, shared data, shared, extra
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
The `context` object in hooks is used to share data across different hooks. The persists throughout the entire lifecycle of a request and is available within every hook. This allows you to add logic to your hooks based on the request state by setting properties to `req.context` and using them elsewhere.
|
|
10
|
+
|
|
11
|
+
## When to use Context
|
|
12
|
+
|
|
13
|
+
Context gives you a way forward on otherwise difficult problems such as:
|
|
14
|
+
|
|
15
|
+
1. **Passing data between hooks**: Needing data in multiple hooks from a 3rd party API, it could be retrieved and used in `beforeChange` and later used again in an `afterChange` hook without having to fetch it twice.
|
|
16
|
+
2. **Preventing infinite loops**: Calling `payload.update()` on the same document that triggered an `afterChange` hook will create an infinite loop, control the flow by assigning a no-op condition to context
|
|
17
|
+
3. **Passing data to local API**: Setting values on the `req.context` and pass it to `payload.create()` you can provide additional data to hooks without adding extraneous fields.
|
|
18
|
+
4. **Passing data between hooks and middleware or custom endpoints**: Hooks could set context across multiple collections and then be used in a final `postMiddleware`.
|
|
19
|
+
|
|
20
|
+
## How to Use Context
|
|
21
|
+
|
|
22
|
+
Let's see examples on how context can be used in the first two scenarios mentioned above:
|
|
23
|
+
|
|
24
|
+
### Passing data between hooks
|
|
25
|
+
|
|
26
|
+
To pass data between hooks, you can assign values to context in an earlier hook in the lifecycle of a request and expect it the context in a later hook.
|
|
27
|
+
|
|
28
|
+
For example:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
const Customer: CollectionConfig = {
|
|
32
|
+
slug: 'customers',
|
|
33
|
+
hooks: {
|
|
34
|
+
beforeChange: [async ({ context, data }) => {
|
|
35
|
+
// assign the customerData to context for use later
|
|
36
|
+
context.customerData = await fetchCustomerData(data.customerID);
|
|
37
|
+
return {
|
|
38
|
+
...data,
|
|
39
|
+
// some data we use here
|
|
40
|
+
name: context.customerData.name
|
|
41
|
+
};
|
|
42
|
+
}],
|
|
43
|
+
afterChange: [async ({ context, doc, req }) => {
|
|
44
|
+
// use context.customerData without needing to fetch it again
|
|
45
|
+
if (context.customerData.contacted === false) {
|
|
46
|
+
createTodo('Call Customer', context.customerData)
|
|
47
|
+
}
|
|
48
|
+
}],
|
|
49
|
+
},
|
|
50
|
+
fields: [ /* ... */ ],
|
|
51
|
+
};
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Preventing infinite loops
|
|
55
|
+
|
|
56
|
+
Let's say you have an `afterChange` hook, and you want to do a calculation inside the hook (as the document ID needed for the calculation is available in the `afterChange` hook, but not in the `beforeChange` hook). Once that's done, you want to update the document with the result of the calculation.
|
|
57
|
+
|
|
58
|
+
Bad example:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const Customer: CollectionConfig = {
|
|
62
|
+
slug: 'customers',
|
|
63
|
+
hooks: {
|
|
64
|
+
afterChange: [async ({ doc }) => {
|
|
65
|
+
await payload.update({
|
|
66
|
+
// DANGER: updating the same slug as the collection in an afterChange will create an infinite loop!
|
|
67
|
+
collection: 'customers',
|
|
68
|
+
id: doc.id,
|
|
69
|
+
data: {
|
|
70
|
+
...(await fetchCustomerData(data.customerID))
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}],
|
|
74
|
+
},
|
|
75
|
+
fields: [ /* ... */ ],
|
|
76
|
+
};
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Instead of the above, we need to tell the `afterChange` hook to not run again if it performs the update (and thus not update itself again). We can solve that with context.
|
|
80
|
+
|
|
81
|
+
Fixed example:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const MyCollection: CollectionConfig = {
|
|
85
|
+
slug: 'slug',
|
|
86
|
+
hooks: {
|
|
87
|
+
afterChange: [async ({ context, doc }) => {
|
|
88
|
+
// return if flag was previously set
|
|
89
|
+
if (context.triggerAfterChange === false) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
await payload.update({
|
|
93
|
+
collection: contextHooksSlug,
|
|
94
|
+
id: doc.id,
|
|
95
|
+
data: {
|
|
96
|
+
...(await fetchCustomerData(data.customerID))
|
|
97
|
+
},
|
|
98
|
+
context: {
|
|
99
|
+
// set a flag to prevent from running again
|
|
100
|
+
triggerAfterChange: false,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
}],
|
|
104
|
+
},
|
|
105
|
+
fields: [ /* ... */ ],
|
|
106
|
+
};
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Typing context
|
|
110
|
+
|
|
111
|
+
The default typescript interface for `context` is `{ [key: string]: unknown }`. If you prefer a more strict typing in your project or when authoring plugins for others, you can override this using the `declare` syntax.
|
|
112
|
+
|
|
113
|
+
This is known as "type augmentation" - a TypeScript feature which allows us to add types to existing objects. Simply put this in any .ts or .d.ts file:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { RequestContext as OriginalRequestContext } from 'payload';
|
|
117
|
+
|
|
118
|
+
declare module 'payload' {
|
|
119
|
+
// Create a new interface that merges your additional fields with the original one
|
|
120
|
+
export interface RequestContext extends OriginalRequestContext {
|
|
121
|
+
myObject?: string;
|
|
122
|
+
// ...
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
This will add a the property `myObject` with a type of string to every context object. Make sure to follow this example correctly, as type augmentation can mess up your types if you do it wrong.
|
|
@@ -77,6 +77,7 @@ You can specify more options within the Local API vs. REST or GraphQL due to the
|
|
|
77
77
|
| `user` | If you set `overrideAccess` to `false`, you can pass a user to use against the access control checks. |
|
|
78
78
|
| `showHiddenFields` | Opt-in to receiving hidden fields. By default, they are hidden from returned documents in accordance to your config. |
|
|
79
79
|
| `pagination` | Set to false to return all documents and avoid querying for document counts. |
|
|
80
|
+
| `context` | [Context](/docs/hooks/context), which will then be passed to `context` and `req.context`, which can be read by hooks. Useful if you want to pass additional information to the hooks which shouldn't be necessarily part of the document, for example a `triggerBeforeChange` option which can be read by the BeforeChange hook to determine if it should run or not. |
|
|
80
81
|
|
|
81
82
|
_There are more options available on an operation by operation basis outlined below._
|
|
82
83
|
|