payload 3.26.0 → 3.27.0-canary.ecc3f49

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 (92) hide show
  1. package/dist/admin/forms/Label.d.ts +1 -1
  2. package/dist/admin/forms/Label.d.ts.map +1 -1
  3. package/dist/admin/forms/Label.js.map +1 -1
  4. package/dist/admin/functions/index.d.ts +1 -0
  5. package/dist/admin/functions/index.d.ts.map +1 -1
  6. package/dist/admin/functions/index.js.map +1 -1
  7. package/dist/admin/views/index.d.ts +0 -2
  8. package/dist/admin/views/index.d.ts.map +1 -1
  9. package/dist/admin/views/index.js.map +1 -1
  10. package/dist/admin/views/list.d.ts +3 -0
  11. package/dist/admin/views/list.d.ts.map +1 -1
  12. package/dist/admin/views/list.js.map +1 -1
  13. package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
  14. package/dist/auth/operations/forgotPassword.js +7 -1
  15. package/dist/auth/operations/forgotPassword.js.map +1 -1
  16. package/dist/collections/config/types.d.ts +4 -0
  17. package/dist/collections/config/types.d.ts.map +1 -1
  18. package/dist/collections/config/types.js.map +1 -1
  19. package/dist/config/client.d.ts +1 -1
  20. package/dist/config/client.d.ts.map +1 -1
  21. package/dist/config/client.js +2 -1
  22. package/dist/config/client.js.map +1 -1
  23. package/dist/config/sanitize.d.ts.map +1 -1
  24. package/dist/config/sanitize.js +9 -6
  25. package/dist/config/sanitize.js.map +1 -1
  26. package/dist/config/types.d.ts +55 -16
  27. package/dist/config/types.d.ts.map +1 -1
  28. package/dist/config/types.js.map +1 -1
  29. package/dist/exports/shared.d.ts +5 -0
  30. package/dist/exports/shared.d.ts.map +1 -1
  31. package/dist/exports/shared.js +5 -0
  32. package/dist/exports/shared.js.map +1 -1
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/list-presets/access.d.ts +5 -0
  37. package/dist/list-presets/access.d.ts.map +1 -0
  38. package/dist/list-presets/access.js +68 -0
  39. package/dist/list-presets/access.js.map +1 -0
  40. package/dist/list-presets/config.d.ts +5 -0
  41. package/dist/list-presets/config.d.ts.map +1 -0
  42. package/dist/list-presets/config.js +142 -0
  43. package/dist/list-presets/config.js.map +1 -0
  44. package/dist/list-presets/constraints.d.ts +4 -0
  45. package/dist/list-presets/constraints.d.ts.map +1 -0
  46. package/dist/list-presets/constraints.js +87 -0
  47. package/dist/list-presets/constraints.js.map +1 -0
  48. package/dist/list-presets/types.d.ts +29 -0
  49. package/dist/list-presets/types.d.ts.map +1 -0
  50. package/dist/list-presets/types.js +7 -0
  51. package/dist/list-presets/types.js.map +1 -0
  52. package/dist/lockedDocuments/{lockedDocumentsCollection.d.ts → config.d.ts} +2 -1
  53. package/dist/lockedDocuments/config.d.ts.map +1 -0
  54. package/dist/lockedDocuments/{lockedDocumentsCollection.js → config.js} +3 -2
  55. package/dist/lockedDocuments/config.js.map +1 -0
  56. package/dist/preferences/config.d.ts +5 -0
  57. package/dist/preferences/config.d.ts.map +1 -0
  58. package/dist/preferences/{preferencesCollection.js → config.js} +4 -4
  59. package/dist/preferences/config.js.map +1 -0
  60. package/dist/preferences/types.d.ts +2 -0
  61. package/dist/preferences/types.d.ts.map +1 -1
  62. package/dist/preferences/types.js.map +1 -1
  63. package/dist/queues/config/jobsCollection.d.ts +1 -0
  64. package/dist/queues/config/jobsCollection.d.ts.map +1 -1
  65. package/dist/queues/config/jobsCollection.js +2 -1
  66. package/dist/queues/config/jobsCollection.js.map +1 -1
  67. package/dist/utilities/formatAdminURL.d.ts +9 -0
  68. package/dist/utilities/formatAdminURL.d.ts.map +1 -0
  69. package/dist/utilities/formatAdminURL.js +16 -0
  70. package/dist/utilities/formatAdminURL.js.map +1 -0
  71. package/dist/utilities/mergeListSearchAndWhere.d.ts +12 -0
  72. package/dist/utilities/mergeListSearchAndWhere.d.ts.map +1 -0
  73. package/dist/utilities/mergeListSearchAndWhere.js +52 -0
  74. package/dist/utilities/mergeListSearchAndWhere.js.map +1 -0
  75. package/dist/utilities/transformWhereQuery.d.ts +11 -0
  76. package/dist/utilities/transformWhereQuery.d.ts.map +1 -0
  77. package/dist/utilities/transformWhereQuery.js +54 -0
  78. package/dist/utilities/transformWhereQuery.js.map +1 -0
  79. package/dist/utilities/validateWhereQuery.d.ts +11 -0
  80. package/dist/utilities/validateWhereQuery.d.ts.map +1 -0
  81. package/dist/utilities/validateWhereQuery.js +41 -0
  82. package/dist/utilities/validateWhereQuery.js.map +1 -0
  83. package/package.json +2 -2
  84. package/dist/exports/components/utilities.d.ts +0 -2
  85. package/dist/exports/components/utilities.d.ts.map +0 -1
  86. package/dist/exports/components/utilities.js +0 -2
  87. package/dist/exports/components/utilities.js.map +0 -1
  88. package/dist/lockedDocuments/lockedDocumentsCollection.d.ts.map +0 -1
  89. package/dist/lockedDocuments/lockedDocumentsCollection.js.map +0 -1
  90. package/dist/preferences/preferencesCollection.d.ts +0 -5
  91. package/dist/preferences/preferencesCollection.d.ts.map +0 -1
  92. package/dist/preferences/preferencesCollection.js.map +0 -1
@@ -0,0 +1,16 @@
1
+ /** Will read the `routes.admin` config and appropriately handle `"/"` admin paths */ export const formatAdminURL = (args)=>{
2
+ const { adminRoute, basePath = '', path: pathFromArgs, serverURL } = args;
3
+ const path = pathFromArgs || '';
4
+ if (adminRoute) {
5
+ if (adminRoute === '/') {
6
+ if (!path) {
7
+ return `${serverURL || ''}${basePath}${adminRoute}`;
8
+ }
9
+ } else {
10
+ return `${serverURL || ''}${basePath}${adminRoute}${path}`;
11
+ }
12
+ }
13
+ return `${serverURL || ''}${basePath}${path}`;
14
+ };
15
+
16
+ //# sourceMappingURL=formatAdminURL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/formatAdminURL.ts"],"sourcesContent":["import type { Config } from '../config/types.js'\n\n/** Will read the `routes.admin` config and appropriately handle `\"/\"` admin paths */\nexport const formatAdminURL = (args: {\n adminRoute: NonNullable<Config['routes']>['admin']\n basePath?: string\n path: '' | `/${string}` | null | undefined\n serverURL?: Config['serverURL']\n}): string => {\n const { adminRoute, basePath = '', path: pathFromArgs, serverURL } = args\n const path = pathFromArgs || ''\n\n if (adminRoute) {\n if (adminRoute === '/') {\n if (!path) {\n return `${serverURL || ''}${basePath}${adminRoute}`\n }\n } else {\n return `${serverURL || ''}${basePath}${adminRoute}${path}`\n }\n }\n\n return `${serverURL || ''}${basePath}${path}`\n}\n"],"names":["formatAdminURL","args","adminRoute","basePath","path","pathFromArgs","serverURL"],"mappings":"AAEA,mFAAmF,GACnF,OAAO,MAAMA,iBAAiB,CAACC;IAM7B,MAAM,EAAEC,UAAU,EAAEC,WAAW,EAAE,EAAEC,MAAMC,YAAY,EAAEC,SAAS,EAAE,GAAGL;IACrE,MAAMG,OAAOC,gBAAgB;IAE7B,IAAIH,YAAY;QACd,IAAIA,eAAe,KAAK;YACtB,IAAI,CAACE,MAAM;gBACT,OAAO,GAAGE,aAAa,KAAKH,WAAWD,YAAY;YACrD;QACF,OAAO;YACL,OAAO,GAAGI,aAAa,KAAKH,WAAWD,aAAaE,MAAM;QAC5D;IACF;IAEA,OAAO,GAAGE,aAAa,KAAKH,WAAWC,MAAM;AAC/C,EAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ClientCollectionConfig } from '../collections/config/client.js';
2
+ import type { SanitizedCollectionConfig } from '../collections/config/types.js';
3
+ import type { Where } from '../types/index.js';
4
+ export declare const hoistQueryParamsToAnd: (currentWhere: Where, incomingWhere: Where) => Where;
5
+ type Args = {
6
+ collectionConfig: ClientCollectionConfig | SanitizedCollectionConfig;
7
+ search: string;
8
+ where?: Where;
9
+ };
10
+ export declare const mergeListSearchAndWhere: ({ collectionConfig, search, where }: Args) => Where;
11
+ export {};
12
+ //# sourceMappingURL=mergeListSearchAndWhere.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeListSearchAndWhere.d.ts","sourceRoot":"","sources":["../../src/utilities/mergeListSearchAndWhere.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAA;AAC7E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAI9C,eAAO,MAAM,qBAAqB,iBAAkB,KAAK,iBAAiB,KAAK,UAsB9E,CAAA;AAED,KAAK,IAAI,GAAG;IACV,gBAAgB,EAAE,sBAAsB,GAAG,yBAAyB,CAAA;IACpE,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,KAAK,CAAA;CACd,CAAA;AAED,eAAO,MAAM,uBAAuB,wCAA8C,IAAI,KAAG,KAwBxF,CAAA"}
@@ -0,0 +1,52 @@
1
+ const isEmptyObject = (obj)=>Object.keys(obj).length === 0;
2
+ export const hoistQueryParamsToAnd = (currentWhere, incomingWhere)=>{
3
+ if (isEmptyObject(incomingWhere)) {
4
+ return currentWhere;
5
+ }
6
+ if (isEmptyObject(currentWhere)) {
7
+ return incomingWhere;
8
+ }
9
+ if ('and' in currentWhere && currentWhere.and) {
10
+ currentWhere.and.push(incomingWhere);
11
+ } else if ('or' in currentWhere) {
12
+ currentWhere = {
13
+ and: [
14
+ currentWhere,
15
+ incomingWhere
16
+ ]
17
+ };
18
+ } else {
19
+ currentWhere = {
20
+ and: [
21
+ currentWhere,
22
+ incomingWhere
23
+ ]
24
+ };
25
+ }
26
+ return currentWhere;
27
+ };
28
+ export const mergeListSearchAndWhere = ({ collectionConfig, search, where = {} })=>{
29
+ if (search) {
30
+ let copyOfWhere = {
31
+ ...where || {}
32
+ };
33
+ const searchAsConditions = (collectionConfig.admin.listSearchableFields || [
34
+ collectionConfig.admin?.useAsTitle || 'id'
35
+ ]).map((fieldName)=>({
36
+ [fieldName]: {
37
+ like: search
38
+ }
39
+ }));
40
+ if (searchAsConditions.length > 0) {
41
+ copyOfWhere = hoistQueryParamsToAnd(copyOfWhere, {
42
+ or: searchAsConditions
43
+ });
44
+ }
45
+ if (!isEmptyObject(copyOfWhere)) {
46
+ where = copyOfWhere;
47
+ }
48
+ }
49
+ return where;
50
+ };
51
+
52
+ //# sourceMappingURL=mergeListSearchAndWhere.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/mergeListSearchAndWhere.ts"],"sourcesContent":["import type { ClientCollectionConfig } from '../collections/config/client.js'\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { Where } from '../types/index.js'\n\nconst isEmptyObject = (obj: object) => Object.keys(obj).length === 0\n\nexport const hoistQueryParamsToAnd = (currentWhere: Where, incomingWhere: Where) => {\n if (isEmptyObject(incomingWhere)) {\n return currentWhere\n }\n\n if (isEmptyObject(currentWhere)) {\n return incomingWhere\n }\n\n if ('and' in currentWhere && currentWhere.and) {\n currentWhere.and.push(incomingWhere)\n } else if ('or' in currentWhere) {\n currentWhere = {\n and: [currentWhere, incomingWhere],\n }\n } else {\n currentWhere = {\n and: [currentWhere, incomingWhere],\n }\n }\n\n return currentWhere\n}\n\ntype Args = {\n collectionConfig: ClientCollectionConfig | SanitizedCollectionConfig\n search: string\n where?: Where\n}\n\nexport const mergeListSearchAndWhere = ({ collectionConfig, search, where = {} }: Args): Where => {\n if (search) {\n let copyOfWhere = { ...(where || {}) }\n\n const searchAsConditions = (\n collectionConfig.admin.listSearchableFields || [collectionConfig.admin?.useAsTitle || 'id']\n ).map((fieldName) => ({\n [fieldName]: {\n like: search,\n },\n }))\n\n if (searchAsConditions.length > 0) {\n copyOfWhere = hoistQueryParamsToAnd(copyOfWhere, {\n or: searchAsConditions,\n })\n }\n\n if (!isEmptyObject(copyOfWhere)) {\n where = copyOfWhere\n }\n }\n\n return where\n}\n"],"names":["isEmptyObject","obj","Object","keys","length","hoistQueryParamsToAnd","currentWhere","incomingWhere","and","push","mergeListSearchAndWhere","collectionConfig","search","where","copyOfWhere","searchAsConditions","admin","listSearchableFields","useAsTitle","map","fieldName","like","or"],"mappings":"AAIA,MAAMA,gBAAgB,CAACC,MAAgBC,OAAOC,IAAI,CAACF,KAAKG,MAAM,KAAK;AAEnE,OAAO,MAAMC,wBAAwB,CAACC,cAAqBC;IACzD,IAAIP,cAAcO,gBAAgB;QAChC,OAAOD;IACT;IAEA,IAAIN,cAAcM,eAAe;QAC/B,OAAOC;IACT;IAEA,IAAI,SAASD,gBAAgBA,aAAaE,GAAG,EAAE;QAC7CF,aAAaE,GAAG,CAACC,IAAI,CAACF;IACxB,OAAO,IAAI,QAAQD,cAAc;QAC/BA,eAAe;YACbE,KAAK;gBAACF;gBAAcC;aAAc;QACpC;IACF,OAAO;QACLD,eAAe;YACbE,KAAK;gBAACF;gBAAcC;aAAc;QACpC;IACF;IAEA,OAAOD;AACT,EAAC;AAQD,OAAO,MAAMI,0BAA0B,CAAC,EAAEC,gBAAgB,EAAEC,MAAM,EAAEC,QAAQ,CAAC,CAAC,EAAQ;IACpF,IAAID,QAAQ;QACV,IAAIE,cAAc;YAAE,GAAID,SAAS,CAAC,CAAC;QAAE;QAErC,MAAME,qBAAqB,AACzBJ,CAAAA,iBAAiBK,KAAK,CAACC,oBAAoB,IAAI;YAACN,iBAAiBK,KAAK,EAAEE,cAAc;SAAK,AAAD,EAC1FC,GAAG,CAAC,CAACC,YAAe,CAAA;gBACpB,CAACA,UAAU,EAAE;oBACXC,MAAMT;gBACR;YACF,CAAA;QAEA,IAAIG,mBAAmBX,MAAM,GAAG,GAAG;YACjCU,cAAcT,sBAAsBS,aAAa;gBAC/CQ,IAAIP;YACN;QACF;QAEA,IAAI,CAACf,cAAcc,cAAc;YAC/BD,QAAQC;QACV;IACF;IAEA,OAAOD;AACT,EAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Where } from '../types/index.js';
2
+ /**
3
+ * Transforms a basic "where" query into a format in which the "where builder" can understand.
4
+ * Even though basic queries are valid, we need to hoist them into the "and" / "or" format.
5
+ * Use this function alongside `validateWhereQuery` to check that for valid queries before transforming.
6
+ * @example
7
+ * Inaccurate: [text][equals]=example%20post
8
+ * Accurate: [or][0][and][0][text][equals]=example%20post
9
+ */
10
+ export declare const transformWhereQuery: (whereQuery: Where) => Where;
11
+ //# sourceMappingURL=transformWhereQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformWhereQuery.d.ts","sourceRoot":"","sources":["../../src/utilities/transformWhereQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,eAAgB,KAAK,KAAG,KA4CvD,CAAA"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Transforms a basic "where" query into a format in which the "where builder" can understand.
3
+ * Even though basic queries are valid, we need to hoist them into the "and" / "or" format.
4
+ * Use this function alongside `validateWhereQuery` to check that for valid queries before transforming.
5
+ * @example
6
+ * Inaccurate: [text][equals]=example%20post
7
+ * Accurate: [or][0][and][0][text][equals]=example%20post
8
+ */ export const transformWhereQuery = (whereQuery)=>{
9
+ if (!whereQuery) {
10
+ return {};
11
+ }
12
+ // Check if 'whereQuery' has 'or' field but no 'and'. This is the case for "correct" queries
13
+ if (whereQuery.or && !whereQuery.and) {
14
+ return {
15
+ or: whereQuery.or.map((query)=>{
16
+ // ...but if the or query does not have an and, we need to add it
17
+ if (!query.and) {
18
+ return {
19
+ and: [
20
+ query
21
+ ]
22
+ };
23
+ }
24
+ return query;
25
+ })
26
+ };
27
+ }
28
+ // Check if 'whereQuery' has 'and' field but no 'or'.
29
+ if (whereQuery.and && !whereQuery.or) {
30
+ return {
31
+ or: [
32
+ {
33
+ and: whereQuery.and
34
+ }
35
+ ]
36
+ };
37
+ }
38
+ // Check if 'whereQuery' has neither 'or' nor 'and'.
39
+ if (!whereQuery.or && !whereQuery.and) {
40
+ return {
41
+ or: [
42
+ {
43
+ and: [
44
+ whereQuery
45
+ ]
46
+ }
47
+ ]
48
+ };
49
+ }
50
+ // If 'whereQuery' has 'or' and 'and', just return it as it is.
51
+ return whereQuery;
52
+ };
53
+
54
+ //# sourceMappingURL=transformWhereQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/transformWhereQuery.ts"],"sourcesContent":["import type { Where } from '../types/index.js'\n\n/**\n * Transforms a basic \"where\" query into a format in which the \"where builder\" can understand.\n * Even though basic queries are valid, we need to hoist them into the \"and\" / \"or\" format.\n * Use this function alongside `validateWhereQuery` to check that for valid queries before transforming.\n * @example\n * Inaccurate: [text][equals]=example%20post\n * Accurate: [or][0][and][0][text][equals]=example%20post\n */\nexport const transformWhereQuery = (whereQuery: Where): Where => {\n if (!whereQuery) {\n return {}\n }\n\n // Check if 'whereQuery' has 'or' field but no 'and'. This is the case for \"correct\" queries\n if (whereQuery.or && !whereQuery.and) {\n return {\n or: whereQuery.or.map((query) => {\n // ...but if the or query does not have an and, we need to add it\n if (!query.and) {\n return {\n and: [query],\n }\n }\n return query\n }),\n }\n }\n\n // Check if 'whereQuery' has 'and' field but no 'or'.\n if (whereQuery.and && !whereQuery.or) {\n return {\n or: [\n {\n and: whereQuery.and,\n },\n ],\n }\n }\n\n // Check if 'whereQuery' has neither 'or' nor 'and'.\n if (!whereQuery.or && !whereQuery.and) {\n return {\n or: [\n {\n and: [whereQuery], // top-level siblings are considered 'and'\n },\n ],\n }\n }\n\n // If 'whereQuery' has 'or' and 'and', just return it as it is.\n return whereQuery\n}\n"],"names":["transformWhereQuery","whereQuery","or","and","map","query"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,MAAMA,sBAAsB,CAACC;IAClC,IAAI,CAACA,YAAY;QACf,OAAO,CAAC;IACV;IAEA,4FAA4F;IAC5F,IAAIA,WAAWC,EAAE,IAAI,CAACD,WAAWE,GAAG,EAAE;QACpC,OAAO;YACLD,IAAID,WAAWC,EAAE,CAACE,GAAG,CAAC,CAACC;gBACrB,iEAAiE;gBACjE,IAAI,CAACA,MAAMF,GAAG,EAAE;oBACd,OAAO;wBACLA,KAAK;4BAACE;yBAAM;oBACd;gBACF;gBACA,OAAOA;YACT;QACF;IACF;IAEA,qDAAqD;IACrD,IAAIJ,WAAWE,GAAG,IAAI,CAACF,WAAWC,EAAE,EAAE;QACpC,OAAO;YACLA,IAAI;gBACF;oBACEC,KAAKF,WAAWE,GAAG;gBACrB;aACD;QACH;IACF;IAEA,oDAAoD;IACpD,IAAI,CAACF,WAAWC,EAAE,IAAI,CAACD,WAAWE,GAAG,EAAE;QACrC,OAAO;YACLD,IAAI;gBACF;oBACEC,KAAK;wBAACF;qBAAW;gBACnB;aACD;QACH;IACF;IAEA,+DAA+D;IAC/D,OAAOA;AACT,EAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Where } from '../types/index.js';
2
+ /**
3
+ * Validates that a "where" query is in a format in which the "where builder" can understand.
4
+ * Even though basic queries are valid, we need to hoist them into the "and" / "or" format.
5
+ * Use this function alongside `transformWhereQuery` to perform a transformation if the query is not valid.
6
+ * @example
7
+ * Inaccurate: [text][equals]=example%20post
8
+ * Accurate: [or][0][and][0][text][equals]=example%20post
9
+ */
10
+ export declare const validateWhereQuery: (whereQuery: Where) => whereQuery is Where;
11
+ //# sourceMappingURL=validateWhereQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateWhereQuery.d.ts","sourceRoot":"","sources":["../../src/utilities/validateWhereQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAIxD;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,eAAgB,KAAK,KAAG,UAAU,IAAI,KAyCpE,CAAA"}
@@ -0,0 +1,41 @@
1
+ import { validOperatorSet } from '../types/constants.js';
2
+ /**
3
+ * Validates that a "where" query is in a format in which the "where builder" can understand.
4
+ * Even though basic queries are valid, we need to hoist them into the "and" / "or" format.
5
+ * Use this function alongside `transformWhereQuery` to perform a transformation if the query is not valid.
6
+ * @example
7
+ * Inaccurate: [text][equals]=example%20post
8
+ * Accurate: [or][0][and][0][text][equals]=example%20post
9
+ */ export const validateWhereQuery = (whereQuery)=>{
10
+ if (whereQuery?.or && whereQuery?.or?.length > 0 && whereQuery?.or?.[0]?.and && whereQuery?.or?.[0]?.and?.length > 0) {
11
+ // At this point we know that the whereQuery has 'or' and 'and' fields,
12
+ // now let's check the structure and content of these fields.
13
+ const isValid = whereQuery.or.every((orQuery)=>{
14
+ if (orQuery.and && Array.isArray(orQuery.and)) {
15
+ return orQuery.and.every((andQuery)=>{
16
+ if (typeof andQuery !== 'object') {
17
+ return false;
18
+ }
19
+ const andKeys = Object.keys(andQuery);
20
+ // If there are no keys, it's not a valid WhereField.
21
+ if (andKeys.length === 0) {
22
+ return false;
23
+ }
24
+ for (const key of andKeys){
25
+ const operator = Object.keys(andQuery[key])[0];
26
+ // Check if the key is a valid Operator.
27
+ if (!operator || !validOperatorSet.has(operator)) {
28
+ return false;
29
+ }
30
+ }
31
+ return true;
32
+ });
33
+ }
34
+ return false;
35
+ });
36
+ return isValid;
37
+ }
38
+ return false;
39
+ };
40
+
41
+ //# sourceMappingURL=validateWhereQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/validateWhereQuery.ts"],"sourcesContent":["import type { Operator, Where } from '../types/index.js'\n\nimport { validOperatorSet } from '../types/constants.js'\n\n/**\n * Validates that a \"where\" query is in a format in which the \"where builder\" can understand.\n * Even though basic queries are valid, we need to hoist them into the \"and\" / \"or\" format.\n * Use this function alongside `transformWhereQuery` to perform a transformation if the query is not valid.\n * @example\n * Inaccurate: [text][equals]=example%20post\n * Accurate: [or][0][and][0][text][equals]=example%20post\n */\nexport const validateWhereQuery = (whereQuery: Where): whereQuery is Where => {\n if (\n whereQuery?.or &&\n whereQuery?.or?.length > 0 &&\n whereQuery?.or?.[0]?.and &&\n whereQuery?.or?.[0]?.and?.length > 0\n ) {\n // At this point we know that the whereQuery has 'or' and 'and' fields,\n // now let's check the structure and content of these fields.\n\n const isValid = whereQuery.or.every((orQuery) => {\n if (orQuery.and && Array.isArray(orQuery.and)) {\n return orQuery.and.every((andQuery) => {\n if (typeof andQuery !== 'object') {\n return false\n }\n\n const andKeys = Object.keys(andQuery)\n\n // If there are no keys, it's not a valid WhereField.\n if (andKeys.length === 0) {\n return false\n }\n\n for (const key of andKeys) {\n const operator = Object.keys(andQuery[key])[0]\n // Check if the key is a valid Operator.\n if (!operator || !validOperatorSet.has(operator as Operator)) {\n return false\n }\n }\n return true\n })\n }\n return false\n })\n\n return isValid\n }\n\n return false\n}\n"],"names":["validOperatorSet","validateWhereQuery","whereQuery","or","length","and","isValid","every","orQuery","Array","isArray","andQuery","andKeys","Object","keys","key","operator","has"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,wBAAuB;AAExD;;;;;;;CAOC,GACD,OAAO,MAAMC,qBAAqB,CAACC;IACjC,IACEA,YAAYC,MACZD,YAAYC,IAAIC,SAAS,KACzBF,YAAYC,IAAI,CAAC,EAAE,EAAEE,OACrBH,YAAYC,IAAI,CAAC,EAAE,EAAEE,KAAKD,SAAS,GACnC;QACA,uEAAuE;QACvE,6DAA6D;QAE7D,MAAME,UAAUJ,WAAWC,EAAE,CAACI,KAAK,CAAC,CAACC;YACnC,IAAIA,QAAQH,GAAG,IAAII,MAAMC,OAAO,CAACF,QAAQH,GAAG,GAAG;gBAC7C,OAAOG,QAAQH,GAAG,CAACE,KAAK,CAAC,CAACI;oBACxB,IAAI,OAAOA,aAAa,UAAU;wBAChC,OAAO;oBACT;oBAEA,MAAMC,UAAUC,OAAOC,IAAI,CAACH;oBAE5B,qDAAqD;oBACrD,IAAIC,QAAQR,MAAM,KAAK,GAAG;wBACxB,OAAO;oBACT;oBAEA,KAAK,MAAMW,OAAOH,QAAS;wBACzB,MAAMI,WAAWH,OAAOC,IAAI,CAACH,QAAQ,CAACI,IAAI,CAAC,CAAC,EAAE;wBAC9C,wCAAwC;wBACxC,IAAI,CAACC,YAAY,CAAChB,iBAAiBiB,GAAG,CAACD,WAAuB;4BAC5D,OAAO;wBACT;oBACF;oBACA,OAAO;gBACT;YACF;YACA,OAAO;QACT;QAEA,OAAOV;IACT;IAEA,OAAO;AACT,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "3.26.0",
3
+ "version": "3.27.0-canary.ecc3f49",
4
4
  "description": "Node, React, Headless CMS and Application Framework built on Next.js",
5
5
  "keywords": [
6
6
  "admin panel",
@@ -99,7 +99,7 @@
99
99
  "tsx": "4.19.2",
100
100
  "uuid": "10.0.0",
101
101
  "ws": "^8.16.0",
102
- "@payloadcms/translations": "3.26.0"
102
+ "@payloadcms/translations": "3.27.0-canary.ecc3f49"
103
103
  },
104
104
  "devDependencies": {
105
105
  "@hyrious/esbuild-plugin-commonjs": "^0.2.4",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=utilities.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../src/exports/components/utilities.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=utilities.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/exports/components/utilities.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"lockedDocumentsCollection.d.ts","sourceRoot":"","sources":["../../src/lockedDocuments/lockedDocumentsCollection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,eAAO,MAAM,4BAA4B,WAAY,MAAM,KAAG,gBA6B5D,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lockedDocuments/lockedDocumentsCollection.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { CollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\n\nexport const getLockedDocumentsCollection = (config: Config): CollectionConfig => ({\n slug: 'payload-locked-documents',\n admin: {\n hidden: true,\n },\n fields: [\n {\n name: 'document',\n type: 'relationship',\n index: true,\n maxDepth: 0,\n relationTo: [...config.collections.map((collectionConfig) => collectionConfig.slug)],\n },\n {\n name: 'globalSlug',\n type: 'text',\n index: true,\n },\n {\n name: 'user',\n type: 'relationship',\n maxDepth: 1,\n relationTo: config.collections\n .filter((collectionConfig) => collectionConfig.auth)\n .map((collectionConfig) => collectionConfig.slug),\n required: true,\n },\n ],\n lockDocuments: false,\n})\n"],"names":["getLockedDocumentsCollection","config","slug","admin","hidden","fields","name","type","index","maxDepth","relationTo","collections","map","collectionConfig","filter","auth","required","lockDocuments"],"mappings":"AAAA,oBAAoB;AAIpB,OAAO,MAAMA,+BAA+B,CAACC,SAAsC,CAAA;QACjFC,MAAM;QACNC,OAAO;YACLC,QAAQ;QACV;QACAC,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNC,OAAO;gBACPC,UAAU;gBACVC,YAAY;uBAAIT,OAAOU,WAAW,CAACC,GAAG,CAAC,CAACC,mBAAqBA,iBAAiBX,IAAI;iBAAE;YACtF;YACA;gBACEI,MAAM;gBACNC,MAAM;gBACNC,OAAO;YACT;YACA;gBACEF,MAAM;gBACNC,MAAM;gBACNE,UAAU;gBACVC,YAAYT,OAAOU,WAAW,CAC3BG,MAAM,CAAC,CAACD,mBAAqBA,iBAAiBE,IAAI,EAClDH,GAAG,CAAC,CAACC,mBAAqBA,iBAAiBX,IAAI;gBAClDc,UAAU;YACZ;SACD;QACDC,eAAe;IACjB,CAAA,EAAE"}
@@ -1,5 +0,0 @@
1
- import type { CollectionConfig } from '../collections/config/types.js';
2
- import type { Config } from '../config/types.js';
3
- declare const getPreferencesCollection: (config: Config) => CollectionConfig;
4
- export default getPreferencesCollection;
5
- //# sourceMappingURL=preferencesCollection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preferencesCollection.d.ts","sourceRoot":"","sources":["../../src/preferences/preferencesCollection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAkBxD,QAAA,MAAM,wBAAwB,WAAY,MAAM,KAAG,gBAwEjD,CAAA;AAEF,eAAe,wBAAwB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/preferences/preferencesCollection.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { CollectionConfig } from '../collections/config/types.js'\nimport type { Access, Config } from '../config/types.js'\n\nimport { deleteHandler } from './requestHandlers/delete.js'\nimport { findByIDHandler } from './requestHandlers/findOne.js'\nimport { updateHandler } from './requestHandlers/update.js'\n\nconst preferenceAccess: Access = ({ req }) => {\n if (!req.user) {\n return false\n }\n\n return {\n 'user.value': {\n equals: req?.user?.id,\n },\n }\n}\n\nconst getPreferencesCollection = (config: Config): CollectionConfig => ({\n slug: 'payload-preferences',\n access: {\n delete: preferenceAccess,\n read: preferenceAccess,\n },\n admin: {\n hidden: true,\n },\n endpoints: [\n {\n handler: findByIDHandler,\n method: 'get',\n path: '/:key',\n },\n {\n handler: deleteHandler,\n method: 'delete',\n path: '/:key',\n },\n {\n handler: updateHandler,\n method: 'post',\n path: '/:key',\n },\n ],\n fields: [\n {\n name: 'user',\n type: 'relationship',\n hooks: {\n beforeValidate: [\n ({ req }) => {\n if (!req?.user) {\n return null\n }\n\n return {\n relationTo: req?.user.collection,\n value: req?.user.id,\n }\n },\n ],\n },\n index: true,\n relationTo: config.collections\n .filter((collectionConfig) => collectionConfig.auth)\n .map((collectionConfig) => collectionConfig.slug),\n required: true,\n },\n {\n name: 'key',\n type: 'text',\n index: true,\n },\n {\n name: 'value',\n type: 'json',\n validate: (value) => {\n if (value) {\n try {\n JSON.parse(JSON.stringify(value))\n } catch {\n return 'Invalid JSON'\n }\n }\n\n return true\n },\n },\n ],\n lockDocuments: false,\n})\n\nexport default getPreferencesCollection\n"],"names":["deleteHandler","findByIDHandler","updateHandler","preferenceAccess","req","user","equals","id","getPreferencesCollection","config","slug","access","delete","read","admin","hidden","endpoints","handler","method","path","fields","name","type","hooks","beforeValidate","relationTo","collection","value","index","collections","filter","collectionConfig","auth","map","required","validate","JSON","parse","stringify","lockDocuments"],"mappings":"AAAA,oBAAoB;AAIpB,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,eAAe,QAAQ,+BAA8B;AAC9D,SAASC,aAAa,QAAQ,8BAA6B;AAE3D,MAAMC,mBAA2B,CAAC,EAAEC,GAAG,EAAE;IACvC,IAAI,CAACA,IAAIC,IAAI,EAAE;QACb,OAAO;IACT;IAEA,OAAO;QACL,cAAc;YACZC,QAAQF,KAAKC,MAAME;QACrB;IACF;AACF;AAEA,MAAMC,2BAA2B,CAACC,SAAsC,CAAA;QACtEC,MAAM;QACNC,QAAQ;YACNC,QAAQT;YACRU,MAAMV;QACR;QACAW,OAAO;YACLC,QAAQ;QACV;QACAC,WAAW;YACT;gBACEC,SAAShB;gBACTiB,QAAQ;gBACRC,MAAM;YACR;YACA;gBACEF,SAASjB;gBACTkB,QAAQ;gBACRC,MAAM;YACR;YACA;gBACEF,SAASf;gBACTgB,QAAQ;gBACRC,MAAM;YACR;SACD;QACDC,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNC,OAAO;oBACLC,gBAAgB;wBACd,CAAC,EAAEpB,GAAG,EAAE;4BACN,IAAI,CAACA,KAAKC,MAAM;gCACd,OAAO;4BACT;4BAEA,OAAO;gCACLoB,YAAYrB,KAAKC,KAAKqB;gCACtBC,OAAOvB,KAAKC,KAAKE;4BACnB;wBACF;qBACD;gBACH;gBACAqB,OAAO;gBACPH,YAAYhB,OAAOoB,WAAW,CAC3BC,MAAM,CAAC,CAACC,mBAAqBA,iBAAiBC,IAAI,EAClDC,GAAG,CAAC,CAACF,mBAAqBA,iBAAiBrB,IAAI;gBAClDwB,UAAU;YACZ;YACA;gBACEb,MAAM;gBACNC,MAAM;gBACNM,OAAO;YACT;YACA;gBACEP,MAAM;gBACNC,MAAM;gBACNa,UAAU,CAACR;oBACT,IAAIA,OAAO;wBACT,IAAI;4BACFS,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACX;wBAC5B,EAAE,OAAM;4BACN,OAAO;wBACT;oBACF;oBAEA,OAAO;gBACT;YACF;SACD;QACDY,eAAe;IACjB,CAAA;AAEA,eAAe/B,yBAAwB"}