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,68 @@
1
+ const operations = [
2
+ 'delete',
3
+ 'read',
4
+ 'update'
5
+ ];
6
+ export const getAccess = (config)=>operations.reduce((acc, operation)=>{
7
+ acc[operation] = async (args)=>{
8
+ const { req } = args;
9
+ // TODO: wire this up when `collectionSlug` is available
10
+ // if (config?.collections?.[collectionSlug]?.admin.disableListPresets) {
11
+ // return false
12
+ // }
13
+ const userDefinedAccess = config?.listPresets?.access?.[operation] ? await config?.listPresets?.access?.[operation](args) : undefined;
14
+ if (typeof userDefinedAccess === 'boolean') {
15
+ return userDefinedAccess;
16
+ }
17
+ if (!req.user) {
18
+ return false;
19
+ }
20
+ const constraints = {
21
+ or: [
22
+ {
23
+ and: [
24
+ {
25
+ [`access.${operation}.users`]: {
26
+ in: [
27
+ req.user.id
28
+ ]
29
+ }
30
+ },
31
+ {
32
+ or: [
33
+ {
34
+ [`access.${operation}.constraint`]: {
35
+ in: [
36
+ 'onlyMe',
37
+ 'specificUsers'
38
+ ]
39
+ }
40
+ },
41
+ {
42
+ isShared: {
43
+ not_equals: true
44
+ }
45
+ }
46
+ ]
47
+ }
48
+ ]
49
+ },
50
+ {
51
+ [`access.${operation}.constraint`]: {
52
+ equals: 'everyone'
53
+ }
54
+ }
55
+ ]
56
+ };
57
+ if (typeof userDefinedAccess === 'object') {
58
+ if (!constraints.or) {
59
+ constraints.or = [];
60
+ }
61
+ constraints.or.push(userDefinedAccess);
62
+ }
63
+ return constraints;
64
+ };
65
+ return acc;
66
+ }, {});
67
+
68
+ //# sourceMappingURL=access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/list-presets/access.ts"],"sourcesContent":["import type { Access, Config } from '../config/types.js'\nimport type { Where } from '../types/index.js'\n\ntype Operation = 'delete' | 'read' | 'update'\n\nconst operations = ['delete', 'read', 'update'] as const\n\nexport const getAccess = (config: Config): Record<Operation, Access> =>\n operations.reduce(\n (acc, operation) => {\n acc[operation] = async (args) => {\n const { req } = args\n\n // TODO: wire this up when `collectionSlug` is available\n // if (config?.collections?.[collectionSlug]?.admin.disableListPresets) {\n // return false\n // }\n\n const userDefinedAccess = config?.listPresets?.access?.[operation]\n ? await config?.listPresets?.access?.[operation](args)\n : undefined\n\n if (typeof userDefinedAccess === 'boolean') {\n return userDefinedAccess\n }\n\n if (!req.user) {\n return false\n }\n\n const constraints: Where = {\n or: [\n {\n and: [\n {\n [`access.${operation}.users`]: {\n in: [req.user.id],\n },\n },\n {\n or: [\n {\n [`access.${operation}.constraint`]: {\n in: ['onlyMe', 'specificUsers'],\n },\n },\n {\n isShared: {\n not_equals: true,\n },\n },\n ],\n },\n ],\n },\n\n {\n [`access.${operation}.constraint`]: {\n equals: 'everyone',\n },\n },\n ],\n }\n\n if (typeof userDefinedAccess === 'object') {\n if (!constraints.or) {\n constraints.or = []\n }\n\n constraints.or.push(userDefinedAccess)\n }\n\n return constraints\n }\n\n return acc\n },\n {} as Record<Operation, Access>,\n )\n"],"names":["operations","getAccess","config","reduce","acc","operation","args","req","userDefinedAccess","listPresets","access","undefined","user","constraints","or","and","in","id","isShared","not_equals","equals","push"],"mappings":"AAKA,MAAMA,aAAa;IAAC;IAAU;IAAQ;CAAS;AAE/C,OAAO,MAAMC,YAAY,CAACC,SACxBF,WAAWG,MAAM,CACf,CAACC,KAAKC;QACJD,GAAG,CAACC,UAAU,GAAG,OAAOC;YACtB,MAAM,EAAEC,GAAG,EAAE,GAAGD;YAEhB,wDAAwD;YACxD,yEAAyE;YACzE,iBAAiB;YACjB,IAAI;YAEJ,MAAME,oBAAoBN,QAAQO,aAAaC,QAAQ,CAACL,UAAU,GAC9D,MAAMH,QAAQO,aAAaC,QAAQ,CAACL,UAAU,CAACC,QAC/CK;YAEJ,IAAI,OAAOH,sBAAsB,WAAW;gBAC1C,OAAOA;YACT;YAEA,IAAI,CAACD,IAAIK,IAAI,EAAE;gBACb,OAAO;YACT;YAEA,MAAMC,cAAqB;gBACzBC,IAAI;oBACF;wBACEC,KAAK;4BACH;gCACE,CAAC,CAAC,OAAO,EAAEV,UAAU,MAAM,CAAC,CAAC,EAAE;oCAC7BW,IAAI;wCAACT,IAAIK,IAAI,CAACK,EAAE;qCAAC;gCACnB;4BACF;4BACA;gCACEH,IAAI;oCACF;wCACE,CAAC,CAAC,OAAO,EAAET,UAAU,WAAW,CAAC,CAAC,EAAE;4CAClCW,IAAI;gDAAC;gDAAU;6CAAgB;wCACjC;oCACF;oCACA;wCACEE,UAAU;4CACRC,YAAY;wCACd;oCACF;iCACD;4BACH;yBACD;oBACH;oBAEA;wBACE,CAAC,CAAC,OAAO,EAAEd,UAAU,WAAW,CAAC,CAAC,EAAE;4BAClCe,QAAQ;wBACV;oBACF;iBACD;YACH;YAEA,IAAI,OAAOZ,sBAAsB,UAAU;gBACzC,IAAI,CAACK,YAAYC,EAAE,EAAE;oBACnBD,YAAYC,EAAE,GAAG,EAAE;gBACrB;gBAEAD,YAAYC,EAAE,CAACO,IAAI,CAACb;YACtB;YAEA,OAAOK;QACT;QAEA,OAAOT;IACT,GACA,CAAC,GACF"}
@@ -0,0 +1,5 @@
1
+ import type { CollectionConfig } from '../collections/config/types.js';
2
+ import type { Config } from '../config/types.js';
3
+ export declare const listPresetsCollectionSlug = "payload-list-presets";
4
+ export declare const getListPresetsConfig: (config: Config) => CollectionConfig;
5
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/list-presets/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAShD,eAAO,MAAM,yBAAyB,yBAAyB,CAAA;AAE/D,eAAO,MAAM,oBAAoB,WAAY,MAAM,KAAG,gBAsJpD,CAAA"}
@@ -0,0 +1,142 @@
1
+ import { transformWhereQuery } from '../utilities/transformWhereQuery.js';
2
+ import { validateWhereQuery } from '../utilities/validateWhereQuery.js';
3
+ import { getAccess } from './access.js';
4
+ import { getConstraints } from './constraints.js';
5
+ import { operations } from './types.js';
6
+ export const listPresetsCollectionSlug = 'payload-list-presets';
7
+ export const getListPresetsConfig = (config)=>({
8
+ slug: listPresetsCollectionSlug,
9
+ access: getAccess(config),
10
+ admin: {
11
+ hidden: true,
12
+ useAsTitle: 'title'
13
+ },
14
+ fields: [
15
+ {
16
+ name: 'title',
17
+ type: 'text',
18
+ required: true
19
+ },
20
+ {
21
+ name: 'isShared',
22
+ type: 'checkbox',
23
+ defaultValue: false,
24
+ validate: (isShared, { data })=>{
25
+ const typedData = data;
26
+ // ensure the `isShared` is only true if all constraints are 'onlyMe'
27
+ if (typedData?.access) {
28
+ const someOperationsAreShared = Object.values(typedData.access).some((operation)=>operation.constraint !== 'onlyMe');
29
+ if (!isShared && someOperationsAreShared) {
30
+ return 'If any constraint is not "onlyMe", the preset must be shared';
31
+ }
32
+ }
33
+ return true;
34
+ }
35
+ },
36
+ getConstraints(config),
37
+ {
38
+ name: 'where',
39
+ type: 'json',
40
+ // hidden: true, // uncomment this when ready
41
+ admin: {
42
+ components: {
43
+ Cell: '@payloadcms/ui#ListPresetsWhereCell',
44
+ Field: '@payloadcms/ui#ListPresetsWhereField'
45
+ }
46
+ },
47
+ hooks: {
48
+ beforeValidate: [
49
+ ({ data })=>{
50
+ // transform the "where" query here so that the client-side doesn't have to
51
+ if (data?.where) {
52
+ if (validateWhereQuery(data.where)) {
53
+ return data.where;
54
+ } else {
55
+ return transformWhereQuery(data.where);
56
+ }
57
+ }
58
+ return data?.where;
59
+ }
60
+ ]
61
+ }
62
+ },
63
+ {
64
+ name: 'columns',
65
+ type: 'json',
66
+ // hidden: true, // uncomment this when ready
67
+ admin: {
68
+ components: {
69
+ Cell: '@payloadcms/ui#ListPresetsColumnsCell',
70
+ Field: '@payloadcms/ui#ListPresetsColumnsField'
71
+ }
72
+ },
73
+ validate: (value)=>{
74
+ if (value) {
75
+ try {
76
+ JSON.parse(JSON.stringify(value));
77
+ } catch {
78
+ return 'Invalid JSON';
79
+ }
80
+ }
81
+ return true;
82
+ }
83
+ },
84
+ {
85
+ name: 'relatedCollection',
86
+ type: 'select',
87
+ admin: {
88
+ hidden: true
89
+ },
90
+ options: config.collections ? config.collections.reduce((acc, collection)=>{
91
+ if (collection.enableListPresets) {
92
+ acc.push({
93
+ label: collection.labels?.plural || collection.slug,
94
+ value: collection.slug
95
+ });
96
+ }
97
+ return acc;
98
+ }, []) : [],
99
+ required: true
100
+ }
101
+ ],
102
+ hooks: {
103
+ beforeValidate: [
104
+ ({ data, operation })=>{
105
+ // TODO: type this
106
+ const typedData = data;
107
+ if (operation === 'create' || operation === 'update') {
108
+ // Ensure all operations have a constraint
109
+ operations.forEach((operation)=>{
110
+ if (!typedData.access) {
111
+ typedData.access = {};
112
+ }
113
+ if (!typedData.access?.[operation]) {
114
+ typedData[operation] = {};
115
+ }
116
+ // If there is no default constraint for this operation, or if the list preset is not shared, set the constraint to 'onlyMe'
117
+ if (!typedData.access[operation]?.constraint || !data?.isShared) {
118
+ typedData.access[operation] = {
119
+ ...typedData.access[operation],
120
+ constraint: 'onlyMe'
121
+ };
122
+ }
123
+ });
124
+ // If at least one constraint is not `onlyMe` then `isShared` must be true
125
+ if (typedData?.access) {
126
+ const someOperationsAreShared = Object.values(typedData.access).some(// TODO: remove the `any` here
127
+ (operation)=>operation.constraint !== 'onlyMe');
128
+ typedData.isShared = someOperationsAreShared;
129
+ }
130
+ }
131
+ return typedData;
132
+ }
133
+ ]
134
+ },
135
+ labels: {
136
+ plural: 'List Presets',
137
+ singular: 'List Preset'
138
+ },
139
+ lockDocuments: false
140
+ });
141
+
142
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/list-presets/config.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\nimport type { Option } from '../fields/config/types.js'\n\nimport { transformWhereQuery } from '../utilities/transformWhereQuery.js'\nimport { validateWhereQuery } from '../utilities/validateWhereQuery.js'\nimport { getAccess } from './access.js'\nimport { getConstraints } from './constraints.js'\nimport { type ListPreset, operations } from './types.js'\n\nexport const listPresetsCollectionSlug = 'payload-list-presets'\n\nexport const getListPresetsConfig = (config: Config): CollectionConfig => ({\n slug: listPresetsCollectionSlug,\n access: getAccess(config),\n admin: {\n hidden: true,\n useAsTitle: 'title',\n },\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n },\n {\n name: 'isShared',\n type: 'checkbox',\n defaultValue: false,\n validate: (isShared, { data }) => {\n const typedData = data as ListPreset\n\n // ensure the `isShared` is only true if all constraints are 'onlyMe'\n if (typedData?.access) {\n const someOperationsAreShared = Object.values(typedData.access).some(\n (operation) => operation.constraint !== 'onlyMe',\n )\n\n if (!isShared && someOperationsAreShared) {\n return 'If any constraint is not \"onlyMe\", the preset must be shared'\n }\n }\n\n return true\n },\n },\n getConstraints(config),\n {\n name: 'where',\n type: 'json',\n // hidden: true, // uncomment this when ready\n admin: {\n components: {\n Cell: '@payloadcms/ui#ListPresetsWhereCell',\n Field: '@payloadcms/ui#ListPresetsWhereField',\n },\n },\n hooks: {\n beforeValidate: [\n ({ data }) => {\n // transform the \"where\" query here so that the client-side doesn't have to\n if (data?.where) {\n if (validateWhereQuery(data.where)) {\n return data.where\n } else {\n return transformWhereQuery(data.where)\n }\n }\n\n return data?.where\n },\n ],\n },\n },\n {\n name: 'columns',\n type: 'json',\n // hidden: true, // uncomment this when ready\n admin: {\n components: {\n Cell: '@payloadcms/ui#ListPresetsColumnsCell',\n Field: '@payloadcms/ui#ListPresetsColumnsField',\n },\n },\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 name: 'relatedCollection',\n type: 'select',\n admin: {\n hidden: true,\n },\n options: config.collections\n ? config.collections.reduce((acc, collection) => {\n if (collection.enableListPresets) {\n acc.push({\n label: collection.labels?.plural || collection.slug,\n value: collection.slug,\n })\n }\n return acc\n }, [] as Option[])\n : [],\n required: true,\n },\n ],\n hooks: {\n beforeValidate: [\n ({ data, operation }) => {\n // TODO: type this\n const typedData = data as any\n\n if (operation === 'create' || operation === 'update') {\n // Ensure all operations have a constraint\n operations.forEach((operation) => {\n if (!typedData.access) {\n typedData.access = {}\n }\n\n if (!typedData.access?.[operation]) {\n typedData[operation] = {}\n }\n\n // If there is no default constraint for this operation, or if the list preset is not shared, set the constraint to 'onlyMe'\n if (!typedData.access[operation]?.constraint || !data?.isShared) {\n typedData.access[operation] = {\n ...typedData.access[operation],\n constraint: 'onlyMe',\n }\n }\n })\n\n // If at least one constraint is not `onlyMe` then `isShared` must be true\n if (typedData?.access) {\n const someOperationsAreShared = Object.values(typedData.access).some(\n // TODO: remove the `any` here\n (operation: any) => operation.constraint !== 'onlyMe',\n )\n\n typedData.isShared = someOperationsAreShared\n }\n }\n\n return typedData\n },\n ],\n },\n labels: {\n plural: 'List Presets',\n singular: 'List Preset',\n },\n lockDocuments: false,\n})\n"],"names":["transformWhereQuery","validateWhereQuery","getAccess","getConstraints","operations","listPresetsCollectionSlug","getListPresetsConfig","config","slug","access","admin","hidden","useAsTitle","fields","name","type","required","defaultValue","validate","isShared","data","typedData","someOperationsAreShared","Object","values","some","operation","constraint","components","Cell","Field","hooks","beforeValidate","where","value","JSON","parse","stringify","options","collections","reduce","acc","collection","enableListPresets","push","label","labels","plural","forEach","singular","lockDocuments"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,SAAS,QAAQ,cAAa;AACvC,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAA0BC,UAAU,QAAQ,aAAY;AAExD,OAAO,MAAMC,4BAA4B,uBAAsB;AAE/D,OAAO,MAAMC,uBAAuB,CAACC,SAAsC,CAAA;QACzEC,MAAMH;QACNI,QAAQP,UAAUK;QAClBG,OAAO;YACLC,QAAQ;YACRC,YAAY;QACd;QACAC,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNC,UAAU;YACZ;YACA;gBACEF,MAAM;gBACNC,MAAM;gBACNE,cAAc;gBACdC,UAAU,CAACC,UAAU,EAAEC,IAAI,EAAE;oBAC3B,MAAMC,YAAYD;oBAElB,qEAAqE;oBACrE,IAAIC,WAAWZ,QAAQ;wBACrB,MAAMa,0BAA0BC,OAAOC,MAAM,CAACH,UAAUZ,MAAM,EAAEgB,IAAI,CAClE,CAACC,YAAcA,UAAUC,UAAU,KAAK;wBAG1C,IAAI,CAACR,YAAYG,yBAAyB;4BACxC,OAAO;wBACT;oBACF;oBAEA,OAAO;gBACT;YACF;YACAnB,eAAeI;YACf;gBACEO,MAAM;gBACNC,MAAM;gBACN,6CAA6C;gBAC7CL,OAAO;oBACLkB,YAAY;wBACVC,MAAM;wBACNC,OAAO;oBACT;gBACF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C;4BACtB;4BAEA,IAAI,CAACY,UAAUZ,MAAM,EAAE,CAACiB,UAAU,EAAE;gCAClCL,SAAS,CAACK,UAAU,GAAG,CAAC;4BAC1B;4BAEA,4HAA4H;4BAC5H,IAAI,CAACL,UAAUZ,MAAM,CAACiB,UAAU,EAAEC,cAAc,CAACP,MAAMD,UAAU;gCAC/DE,UAAUZ,MAAM,CAACiB,UAAU,GAAG;oCAC5B,GAAGL,UAAUZ,MAAM,CAACiB,UAAU;oCAC9BC,YAAY;gCACd;4BACF;wBACF;wBAEA,0EAA0E;wBAC1E,IAAIN,WAAWZ,QAAQ;4BACrB,MAAMa,0BAA0BC,OAAOC,MAAM,CAACH,UAAUZ,MAAM,EAAEgB,IAAI,CAClE,8BAA8B;4BAC9B,CAACC,YAAmBA,UAAUC,UAAU,KAAK;4BAG/CN,UAAUF,QAAQ,GAAGG;wBACvB;oBACF;oBAEA,OAAOD;gBACT;aACD;QACH;QACAyB,QAAQ;YACNC,QAAQ;YACRE,UAAU;QACZ;QACAC,eAAe;IACjB,CAAA,EAAE"}
@@ -0,0 +1,4 @@
1
+ import type { Config } from '../config/types.js';
2
+ import type { Field } from '../fields/config/types.js';
3
+ export declare const getConstraints: (config: Config) => Field;
4
+ //# sourceMappingURL=constraints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../../src/list-presets/constraints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAKtD,eAAO,MAAM,cAAc,WAAY,MAAM,KAAG,KAuF9C,CAAA"}
@@ -0,0 +1,87 @@
1
+ import { fieldAffectsData } from '../fields/config/types.js';
2
+ import { operations } from './types.js';
3
+ export const getConstraints = (config)=>({
4
+ name: 'access',
5
+ type: 'group',
6
+ admin: {
7
+ components: {
8
+ Cell: '@payloadcms/ui#ListPresetsAccessCell'
9
+ },
10
+ condition: (data)=>Boolean(data?.isShared)
11
+ },
12
+ fields: operations.map((operation)=>({
13
+ name: operation,
14
+ type: 'group',
15
+ admin: {
16
+ components: {
17
+ Label: '@payloadcms/ui#ListPresetsAccessLabel'
18
+ },
19
+ hideGutter: true
20
+ },
21
+ fields: [
22
+ {
23
+ name: 'constraint',
24
+ type: 'select',
25
+ defaultValue: 'onlyMe',
26
+ label: false,
27
+ options: [
28
+ {
29
+ label: 'Everyone',
30
+ value: 'everyone'
31
+ },
32
+ {
33
+ label: 'Only Me',
34
+ value: 'onlyMe'
35
+ },
36
+ {
37
+ label: 'Specific Users',
38
+ value: 'specificUsers'
39
+ },
40
+ ...config?.listPresets?.constraints?.[operation]?.map((option)=>({
41
+ label: option.label,
42
+ value: option.value
43
+ })) || []
44
+ ]
45
+ },
46
+ {
47
+ name: 'users',
48
+ type: 'relationship',
49
+ admin: {
50
+ condition: (data)=>Boolean(data?.access?.[operation]?.constraint === 'specificUsers')
51
+ },
52
+ hasMany: true,
53
+ hooks: {
54
+ beforeChange: [
55
+ ({ data, req })=>{
56
+ if (data?.access?.[operation]?.constraint === 'onlyMe') {
57
+ if (req.user) {
58
+ return [
59
+ req.user.id
60
+ ];
61
+ }
62
+ }
63
+ return data?.access?.[operation]?.users;
64
+ }
65
+ ]
66
+ },
67
+ relationTo: 'users'
68
+ },
69
+ ...config?.listPresets?.constraints?.[operation]?.reduce((acc, option)=>{
70
+ option.fields.forEach((field, index)=>{
71
+ acc.push({
72
+ ...field
73
+ });
74
+ if (fieldAffectsData(field)) {
75
+ acc[index].admin = {
76
+ ...acc[index]?.admin || {},
77
+ condition: (data)=>Boolean(data?.access?.[operation]?.constraint === option.value)
78
+ };
79
+ }
80
+ });
81
+ return acc;
82
+ }, []) || []
83
+ ]
84
+ }))
85
+ });
86
+
87
+ //# sourceMappingURL=constraints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/list-presets/constraints.ts"],"sourcesContent":["import type { Config } from '../config/types.js'\nimport type { Field } from '../fields/config/types.js'\n\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { type ListPresetConstraint, operations } from './types.js'\n\nexport const getConstraints = (config: Config): Field => ({\n name: 'access',\n type: 'group',\n admin: {\n components: {\n Cell: '@payloadcms/ui#ListPresetsAccessCell',\n },\n condition: (data) => Boolean(data?.isShared),\n },\n fields: operations.map((operation) => ({\n name: operation,\n type: 'group',\n admin: {\n components: {\n Label: '@payloadcms/ui#ListPresetsAccessLabel',\n },\n hideGutter: true,\n },\n fields: [\n {\n name: 'constraint',\n type: 'select',\n defaultValue: 'onlyMe',\n label: false,\n options: [\n {\n label: 'Everyone',\n value: 'everyone',\n },\n {\n label: 'Only Me',\n value: 'onlyMe',\n },\n {\n label: 'Specific Users',\n value: 'specificUsers',\n },\n ...(config?.listPresets?.constraints?.[operation]?.map(\n (option: ListPresetConstraint) => ({\n label: option.label,\n value: option.value,\n }),\n ) || []),\n ],\n },\n {\n name: 'users',\n type: 'relationship',\n admin: {\n condition: (data) => Boolean(data?.access?.[operation]?.constraint === 'specificUsers'),\n },\n hasMany: true,\n hooks: {\n beforeChange: [\n ({ data, req }) => {\n if (data?.access?.[operation]?.constraint === 'onlyMe') {\n if (req.user) {\n return [req.user.id]\n }\n }\n\n return data?.access?.[operation]?.users\n },\n ],\n },\n relationTo: 'users',\n },\n ...(config?.listPresets?.constraints?.[operation]?.reduce(\n (acc: Field[], option: ListPresetConstraint) => {\n option.fields.forEach((field, index) => {\n acc.push({ ...field })\n\n if (fieldAffectsData(field)) {\n acc[index].admin = {\n ...(acc[index]?.admin || {}),\n condition: (data) =>\n Boolean(data?.access?.[operation]?.constraint === option.value),\n }\n }\n })\n\n return acc\n },\n [] as Field[],\n ) || []),\n ],\n })),\n})\n"],"names":["fieldAffectsData","operations","getConstraints","config","name","type","admin","components","Cell","condition","data","Boolean","isShared","fields","map","operation","Label","hideGutter","defaultValue","label","options","value","listPresets","constraints","option","access","constraint","hasMany","hooks","beforeChange","req","user","id","users","relationTo","reduce","acc","forEach","field","index","push"],"mappings":"AAGA,SAASA,gBAAgB,QAAQ,4BAA2B;AAC5D,SAAoCC,UAAU,QAAQ,aAAY;AAElE,OAAO,MAAMC,iBAAiB,CAACC,SAA2B,CAAA;QACxDC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,YAAY;gBACVC,MAAM;YACR;YACAC,WAAW,CAACC,OAASC,QAAQD,MAAME;QACrC;QACAC,QAAQZ,WAAWa,GAAG,CAAC,CAACC,YAAe,CAAA;gBACrCX,MAAMW;gBACNV,MAAM;gBACNC,OAAO;oBACLC,YAAY;wBACVS,OAAO;oBACT;oBACAC,YAAY;gBACd;gBACAJ,QAAQ;oBACN;wBACET,MAAM;wBACNC,MAAM;wBACNa,cAAc;wBACdC,OAAO;wBACPC,SAAS;4BACP;gCACED,OAAO;gCACPE,OAAO;4BACT;4BACA;gCACEF,OAAO;gCACPE,OAAO;4BACT;4BACA;gCACEF,OAAO;gCACPE,OAAO;4BACT;+BACIlB,QAAQmB,aAAaC,aAAa,CAACR,UAAU,EAAED,IACjD,CAACU,SAAkC,CAAA;oCACjCL,OAAOK,OAAOL,KAAK;oCACnBE,OAAOG,OAAOH,KAAK;gCACrB,CAAA,MACG,EAAE;yBACR;oBACH;oBACA;wBACEjB,MAAM;wBACNC,MAAM;wBACNC,OAAO;4BACLG,WAAW,CAACC,OAASC,QAAQD,MAAMe,QAAQ,CAACV,UAAU,EAAEW,eAAe;wBACzE;wBACAC,SAAS;wBACTC,OAAO;4BACLC,cAAc;gCACZ,CAAC,EAAEnB,IAAI,EAAEoB,GAAG,EAAE;oCACZ,IAAIpB,MAAMe,QAAQ,CAACV,UAAU,EAAEW,eAAe,UAAU;wCACtD,IAAII,IAAIC,IAAI,EAAE;4CACZ,OAAO;gDAACD,IAAIC,IAAI,CAACC,EAAE;6CAAC;wCACtB;oCACF;oCAEA,OAAOtB,MAAMe,QAAQ,CAACV,UAAU,EAAEkB;gCACpC;6BACD;wBACH;wBACAC,YAAY;oBACd;uBACI/B,QAAQmB,aAAaC,aAAa,CAACR,UAAU,EAAEoB,OACjD,CAACC,KAAcZ;wBACbA,OAAOX,MAAM,CAACwB,OAAO,CAAC,CAACC,OAAOC;4BAC5BH,IAAII,IAAI,CAAC;gCAAE,GAAGF,KAAK;4BAAC;4BAEpB,IAAItC,iBAAiBsC,QAAQ;gCAC3BF,GAAG,CAACG,MAAM,CAACjC,KAAK,GAAG;oCACjB,GAAI8B,GAAG,CAACG,MAAM,EAAEjC,SAAS,CAAC,CAAC;oCAC3BG,WAAW,CAACC,OACVC,QAAQD,MAAMe,QAAQ,CAACV,UAAU,EAAEW,eAAeF,OAAOH,KAAK;gCAClE;4BACF;wBACF;wBAEA,OAAOe;oBACT,GACA,EAAE,KACC,EAAE;iBACR;YACH,CAAA;IACF,CAAA,EAAE"}
@@ -0,0 +1,29 @@
1
+ import type { Field } from '../fields/config/types.js';
2
+ import type { CollectionSlug } from '../index.js';
3
+ import type { ListPreferences } from '../preferences/types.js';
4
+ import type { Where } from '../types/index.js';
5
+ export declare const operations: readonly ["delete", "read", "update"];
6
+ type Operation = (typeof operations)[number];
7
+ export type ListPreset = {
8
+ access: Access;
9
+ columns: ListPreferences['columns'];
10
+ id: number | string;
11
+ isShared: boolean;
12
+ relatedCollection: CollectionSlug;
13
+ title: string;
14
+ where: Where;
15
+ };
16
+ export type Access = {
17
+ [operation in Operation]: {
18
+ constraint: 'everyone' | 'onlyMe' | 'specificUsers';
19
+ users?: string[];
20
+ };
21
+ };
22
+ export type ListPresetConstraint = {
23
+ fields: Field[];
24
+ label: string;
25
+ value: string;
26
+ };
27
+ export type ListPresetConstraints = ListPresetConstraint[];
28
+ export {};
29
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/list-presets/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9C,eAAO,MAAM,UAAU,uCAAwC,CAAA;AAE/D,KAAK,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAG5C,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,CAAA;IACnC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,iBAAiB,EAAE,cAAc,CAAA;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAGD,MAAM,MAAM,MAAM,GAAG;KAClB,SAAS,IAAI,SAAS,GAAG;QACxB,UAAU,EAAE,UAAU,GAAG,QAAQ,GAAG,eAAe,CAAA;QACnD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KACjB;CACF,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,EAAE,CAAA"}
@@ -0,0 +1,7 @@
1
+ export const operations = [
2
+ 'delete',
3
+ 'read',
4
+ 'update'
5
+ ];
6
+
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/list-presets/types.ts"],"sourcesContent":["import type { Field } from '../fields/config/types.js'\nimport type { CollectionSlug } from '../index.js'\nimport type { ListPreferences } from '../preferences/types.js'\nimport type { Where } from '../types/index.js'\n\nexport const operations = ['delete', 'read', 'update'] as const\n\ntype Operation = (typeof operations)[number]\n\n// TODO: this should just exist in `GeneratedTypes` instead\nexport type ListPreset = {\n access: Access\n columns: ListPreferences['columns']\n id: number | string\n isShared: boolean\n relatedCollection: CollectionSlug\n title: string\n where: Where\n}\n\n// TODO: this should just exist in `GeneratedTypes` instead\nexport type Access = {\n [operation in Operation]: {\n constraint: 'everyone' | 'onlyMe' | 'specificUsers'\n users?: string[]\n }\n}\n\nexport type ListPresetConstraint = {\n fields: Field[]\n label: string\n value: string\n}\n\nexport type ListPresetConstraints = ListPresetConstraint[]\n"],"names":["operations"],"mappings":"AAKA,OAAO,MAAMA,aAAa;IAAC;IAAU;IAAQ;CAAS,CAAS"}
@@ -1,4 +1,5 @@
1
1
  import type { CollectionConfig } from '../collections/config/types.js';
2
2
  import type { Config } from '../config/types.js';
3
+ export declare const lockedDocumentsCollectionSlug = "payload-locked-documents";
3
4
  export declare const getLockedDocumentsCollection: (config: Config) => CollectionConfig;
4
- //# sourceMappingURL=lockedDocumentsCollection.d.ts.map
5
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lockedDocuments/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,eAAO,MAAM,6BAA6B,6BAA6B,CAAA;AAEvE,eAAO,MAAM,4BAA4B,WAAY,MAAM,KAAG,gBA6B5D,CAAA"}
@@ -1,6 +1,7 @@
1
1
  // @ts-strict-ignore
2
+ export const lockedDocumentsCollectionSlug = 'payload-locked-documents';
2
3
  export const getLockedDocumentsCollection = (config)=>({
3
- slug: 'payload-locked-documents',
4
+ slug: lockedDocumentsCollectionSlug,
4
5
  admin: {
5
6
  hidden: true
6
7
  },
@@ -30,4 +31,4 @@ export const getLockedDocumentsCollection = (config)=>({
30
31
  lockDocuments: false
31
32
  });
32
33
 
33
- //# sourceMappingURL=lockedDocumentsCollection.js.map
34
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lockedDocuments/config.ts"],"sourcesContent":["// @ts-strict-ignore\nimport type { CollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\n\nexport const lockedDocumentsCollectionSlug = 'payload-locked-documents'\n\nexport const getLockedDocumentsCollection = (config: Config): CollectionConfig => ({\n slug: lockedDocumentsCollectionSlug,\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":["lockedDocumentsCollectionSlug","getLockedDocumentsCollection","config","slug","admin","hidden","fields","name","type","index","maxDepth","relationTo","collections","map","collectionConfig","filter","auth","required","lockDocuments"],"mappings":"AAAA,oBAAoB;AAIpB,OAAO,MAAMA,gCAAgC,2BAA0B;AAEvE,OAAO,MAAMC,+BAA+B,CAACC,SAAsC,CAAA;QACjFC,MAAMH;QACNI,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"}
@@ -0,0 +1,5 @@
1
+ import type { CollectionConfig } from '../collections/config/types.js';
2
+ import type { Config } from '../config/types.js';
3
+ export declare const preferencesCollectionSlug = "payload-preferences";
4
+ export declare const getPreferencesCollection: (config: Config) => CollectionConfig;
5
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/preferences/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAkBxD,eAAO,MAAM,yBAAyB,wBAAwB,CAAA;AAE9D,eAAO,MAAM,wBAAwB,WAAY,MAAM,KAAG,gBAwExD,CAAA"}
@@ -12,8 +12,9 @@ const preferenceAccess = ({ req })=>{
12
12
  }
13
13
  };
14
14
  };
15
- const getPreferencesCollection = (config)=>({
16
- slug: 'payload-preferences',
15
+ export const preferencesCollectionSlug = 'payload-preferences';
16
+ export const getPreferencesCollection = (config)=>({
17
+ slug: preferencesCollectionSlug,
17
18
  access: {
18
19
  delete: preferenceAccess,
19
20
  read: preferenceAccess
@@ -81,6 +82,5 @@ const getPreferencesCollection = (config)=>({
81
82
  ],
82
83
  lockDocuments: false
83
84
  });
84
- export default getPreferencesCollection;
85
85
 
86
- //# sourceMappingURL=preferencesCollection.js.map
86
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/preferences/config.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\nexport const preferencesCollectionSlug = 'payload-preferences'\n\nexport const getPreferencesCollection = (config: Config): CollectionConfig => ({\n slug: preferencesCollectionSlug,\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"],"names":["deleteHandler","findByIDHandler","updateHandler","preferenceAccess","req","user","equals","id","preferencesCollectionSlug","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,OAAO,MAAMC,4BAA4B,sBAAqB;AAE9D,OAAO,MAAMC,2BAA2B,CAACC,SAAsC,CAAA;QAC7EC,MAAMH;QACNI,QAAQ;YACNC,QAAQV;YACRW,MAAMX;QACR;QACAY,OAAO;YACLC,QAAQ;QACV;QACAC,WAAW;YACT;gBACEC,SAASjB;gBACTkB,QAAQ;gBACRC,MAAM;YACR;YACA;gBACEF,SAASlB;gBACTmB,QAAQ;gBACRC,MAAM;YACR;YACA;gBACEF,SAAShB;gBACTiB,QAAQ;gBACRC,MAAM;YACR;SACD;QACDC,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNC,OAAO;oBACLC,gBAAgB;wBACd,CAAC,EAAErB,GAAG,EAAE;4BACN,IAAI,CAACA,KAAKC,MAAM;gCACd,OAAO;4BACT;4BAEA,OAAO;gCACLqB,YAAYtB,KAAKC,KAAKsB;gCACtBC,OAAOxB,KAAKC,KAAKE;4BACnB;wBACF;qBACD;gBACH;gBACAsB,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,EAAE"}
@@ -1,3 +1,4 @@
1
+ import type { DefaultDocumentIDType } from '../index.js';
1
2
  import type { PayloadRequest } from '../types/index.js';
2
3
  export type PreferenceRequest = {
3
4
  key: string;
@@ -29,6 +30,7 @@ export type ColumnPreference = {
29
30
  export type ListPreferences = {
30
31
  columns?: ColumnPreference[];
31
32
  limit?: number;
33
+ preset?: DefaultDocumentIDType;
32
34
  sort?: string;
33
35
  };
34
36
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/preferences/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,iBAAiB,CAAA;AAE5E,MAAM,MAAM,oBAAoB,GAAG,MAAM,EAAE,CAAA;AAE3C,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC;IAClC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACvB,CAAC,CAAA;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,oBAAoB,CAAA;IAC/B,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,iBAAiB,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC5B,KAAK,CAAC,EAAE,M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,CAAC,EAAE,MAAM,CAAA;CACd,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/preferences/types.ts"],"sourcesContent":["import type { PayloadRequest } from '../types/index.js'\n\nexport type PreferenceRequest = {\n key: string\n overrideAccess?: boolean\n req: PayloadRequest\n user: PayloadRequest['user']\n}\n\nexport type PreferenceUpdateRequest = { value: unknown } & PreferenceRequest\n\nexport type CollapsedPreferences = string[]\n\nexport type TabsPreferences = Array<{\n [path: string]: number\n}>\n\nexport type InsideFieldsPreferences = {\n collapsed: CollapsedPreferences\n tabIndex: number\n}\n\nexport type FieldsPreferences = {\n [key: string]: InsideFieldsPreferences\n}\n\nexport type DocumentPreferences = {\n fields: FieldsPreferences\n}\n\nexport type ColumnPreference = {\n accessor: string\n active: boolean\n}\n\nexport type ListPreferences = {\n columns?: ColumnPreference[]\n limit?: number\n sort?: string\n}\n"],"names":[],"mappings":"AAmCA,WAIC"}
1
+ {"version":3,"sources":["../../src/preferences/types.ts"],"sourcesContent":["import type { DefaultDocumentIDType } from '../index.js'\nimport type { PayloadRequest } from '../types/index.js'\n\nexport type PreferenceRequest = {\n key: string\n overrideAccess?: boolean\n req: PayloadRequest\n user: PayloadRequest['user']\n}\n\nexport type PreferenceUpdateRequest = { value: unknown } & PreferenceRequest\n\nexport type CollapsedPreferences = string[]\n\nexport type TabsPreferences = Array<{\n [path: string]: number\n}>\n\nexport type InsideFieldsPreferences = {\n collapsed: CollapsedPreferences\n tabIndex: number\n}\n\nexport type FieldsPreferences = {\n [key: string]: InsideFieldsPreferences\n}\n\nexport type DocumentPreferences = {\n fields: FieldsPreferences\n}\n\nexport type ColumnPreference = {\n accessor: string\n active: boolean\n}\n\nexport type ListPreferences = {\n columns?: ColumnPreference[]\n limit?: number\n preset?: DefaultDocumentIDType\n sort?: string\n}\n"],"names":[],"mappings":"AAoCA,WAKC"}
@@ -1,4 +1,5 @@
1
1
  import type { CollectionConfig } from '../../collections/config/types.js';
2
2
  import type { Config } from '../../config/types.js';
3
+ export declare const jobsCollectionSlug = "payload-jobs";
3
4
  export declare const getDefaultJobsCollection: (config: Config) => CollectionConfig | null;
4
5
  //# sourceMappingURL=jobsCollection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jobsCollection.d.ts","sourceRoot":"","sources":["../../../src/queues/config/jobsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAMnD,eAAO,MAAM,wBAAwB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,gBAAgB,GAAG,IA4O7E,CAAA"}
1
+ {"version":3,"file":"jobsCollection.d.ts","sourceRoot":"","sources":["../../../src/queues/config/jobsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAMnD,eAAO,MAAM,kBAAkB,iBAAiB,CAAA;AAEhD,eAAO,MAAM,wBAAwB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,gBAAgB,GAAG,IA4O7E,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { runJobsEndpoint } from '../restEndpointRun.js';
2
2
  import { getJobTaskStatus } from '../utilities/getJobTaskStatus.js';
3
+ export const jobsCollectionSlug = 'payload-jobs';
3
4
  export const getDefaultJobsCollection = (config)=>{
4
5
  if (!Array.isArray(config?.jobs?.workflows)) {
5
6
  return null;
@@ -91,7 +92,7 @@ export const getDefaultJobsCollection = (config)=>{
91
92
  });
92
93
  }
93
94
  const jobsCollection = {
94
- slug: 'payload-jobs',
95
+ slug: jobsCollectionSlug,
95
96
  admin: {
96
97
  group: 'System',
97
98
  hidden: true
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/queues/config/jobsCollection.ts"],"sourcesContent":["import type { CollectionConfig } from '../../collections/config/types.js'\nimport type { Config } from '../../config/types.js'\nimport type { Field } from '../../fields/config/types.js'\n\nimport { runJobsEndpoint } from '../restEndpointRun.js'\nimport { getJobTaskStatus } from '../utilities/getJobTaskStatus.js'\n\nexport const getDefaultJobsCollection: (config: Config) => CollectionConfig | null = (config) => {\n if (!Array.isArray(config?.jobs?.workflows)) {\n return null\n }\n\n const workflowSlugs: Set<string> = new Set()\n const taskSlugs: Set<string> = new Set(['inline'])\n\n if (config.jobs?.workflows.length) {\n config.jobs?.workflows.forEach((workflow) => {\n workflowSlugs.add(workflow.slug)\n })\n }\n\n if (config.jobs?.tasks.length) {\n config.jobs.tasks.forEach((task) => {\n if (workflowSlugs.has(task.slug)) {\n throw new Error(\n `Task slug \"${task.slug}\" is already used by a workflow. No tasks are allowed to have the same slug as a workflow.`,\n )\n }\n taskSlugs.add(task.slug)\n })\n }\n\n const logFields: Field[] = [\n {\n name: 'executedAt',\n type: 'date',\n required: true,\n },\n {\n name: 'completedAt',\n type: 'date',\n required: true,\n },\n {\n name: 'taskSlug',\n type: 'select',\n options: [...taskSlugs],\n required: true,\n },\n {\n name: 'taskID',\n type: 'text',\n required: true,\n },\n {\n name: 'input',\n type: 'json',\n },\n {\n name: 'output',\n type: 'json',\n },\n {\n name: 'state',\n type: 'radio',\n options: ['failed', 'succeeded'],\n required: true,\n },\n {\n name: 'error',\n type: 'json',\n admin: {\n condition: (_, data) => data.state === 'failed',\n },\n required: true,\n },\n ]\n\n if (config?.jobs?.addParentToTaskLog) {\n logFields.push({\n name: 'parent',\n type: 'group',\n fields: [\n {\n name: 'taskSlug',\n type: 'select',\n options: [...taskSlugs],\n },\n {\n name: 'taskID',\n type: 'text',\n },\n ],\n })\n }\n\n const jobsCollection: CollectionConfig = {\n slug: 'payload-jobs',\n admin: {\n group: 'System',\n hidden: true,\n },\n endpoints: [runJobsEndpoint],\n fields: [\n {\n name: 'input',\n type: 'json',\n admin: {\n description: 'Input data provided to the job',\n },\n },\n {\n name: 'taskStatus',\n type: 'json',\n virtual: true,\n },\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'completedAt',\n type: 'date',\n index: true,\n },\n {\n name: 'totalTried',\n type: 'number',\n defaultValue: 0,\n index: true,\n },\n {\n name: 'hasError',\n type: 'checkbox',\n admin: {\n description: 'If hasError is true this job will not be retried',\n },\n defaultValue: false,\n index: true,\n },\n {\n name: 'error',\n type: 'json',\n admin: {\n condition: (data) => data.hasError,\n description: 'If hasError is true, this is the error that caused it',\n },\n },\n {\n name: 'log',\n type: 'array',\n admin: {\n description: 'Task execution log',\n },\n fields: logFields,\n },\n ],\n label: 'Status',\n },\n ],\n },\n // only include the workflowSlugs field if workflows exist\n ...((workflowSlugs.size > 0\n ? [\n {\n name: 'workflowSlug',\n type: 'select',\n admin: {\n position: 'sidebar',\n },\n index: true,\n options: [...workflowSlugs],\n },\n ]\n : []) as Field[]),\n {\n name: 'taskSlug',\n type: 'select',\n admin: {\n position: 'sidebar',\n },\n index: true,\n options: [...taskSlugs],\n required: false,\n },\n {\n name: 'queue',\n type: 'text',\n admin: {\n position: 'sidebar',\n },\n defaultValue: 'default',\n index: true,\n },\n {\n name: 'waitUntil',\n type: 'date',\n index: true,\n },\n {\n name: 'processing',\n type: 'checkbox',\n admin: {\n position: 'sidebar',\n },\n defaultValue: false,\n index: true,\n },\n ],\n hooks: {\n afterRead: [\n ({ doc, req }) => {\n // This hook is used to add the virtual `tasks` field to the document, that is computed from the `log` field\n\n doc.taskStatus = getJobTaskStatus({\n jobLog: doc.log,\n tasksConfig: req.payload.config.jobs.tasks,\n })\n\n return doc\n },\n ],\n /**\n * If another update comes in after a job as already been cancelled, we need to make sure that update doesn't\n * change the state of the job.\n */\n beforeChange: [\n ({ data, originalDoc }) => {\n if (originalDoc?.error?.cancelled) {\n data.processing = false\n data.hasError = true\n delete data.completedAt\n delete data.waitUntil\n }\n return data\n },\n ],\n },\n lockDocuments: false,\n }\n\n return jobsCollection\n}\n"],"names":["runJobsEndpoint","getJobTaskStatus","getDefaultJobsCollection","config","Array","isArray","jobs","workflows","workflowSlugs","Set","taskSlugs","length","forEach","workflow","add","slug","tasks","task","has","Error","logFields","name","type","required","options","admin","condition","_","data","state","addParentToTaskLog","push","fields","jobsCollection","group","hidden","endpoints","description","virtual","tabs","index","defaultValue","hasError","label","size","position","hooks","afterRead","doc","req","taskStatus","jobLog","log","tasksConfig","payload","beforeChange","originalDoc","error","cancelled","processing","completedAt","waitUntil","lockDocuments"],"mappings":"AAIA,SAASA,eAAe,QAAQ,wBAAuB;AACvD,SAASC,gBAAgB,QAAQ,mCAAkC;AAEnE,OAAO,MAAMC,2BAAwE,CAACC;IACpF,IAAI,CAACC,MAAMC,OAAO,CAACF,QAAQG,MAAMC,YAAY;QAC3C,OAAO;IACT;IAEA,MAAMC,gBAA6B,IAAIC;IACvC,MAAMC,YAAyB,IAAID,IAAI;QAAC;KAAS;IAEjD,IAAIN,OAAOG,IAAI,EAAEC,UAAUI,QAAQ;QACjCR,OAAOG,IAAI,EAAEC,UAAUK,QAAQ,CAACC;YAC9BL,cAAcM,GAAG,CAACD,SAASE,IAAI;QACjC;IACF;IAEA,IAAIZ,OAAOG,IAAI,EAAEU,MAAML,QAAQ;QAC7BR,OAAOG,IAAI,CAACU,KAAK,CAACJ,OAAO,CAAC,CAACK;YACzB,IAAIT,cAAcU,GAAG,CAACD,KAAKF,IAAI,GAAG;gBAChC,MAAM,IAAII,MACR,CAAC,WAAW,EAAEF,KAAKF,IAAI,CAAC,0FAA0F,CAAC;YAEvH;YACAL,UAAUI,GAAG,CAACG,KAAKF,IAAI;QACzB;IACF;IAEA,MAAMK,YAAqB;QACzB;YACEC,MAAM;YACNC,MAAM;YACNC,UAAU;QACZ;QACA;YACEF,MAAM;YACNC,MAAM;YACNC,UAAU;QACZ;QACA;YACEF,MAAM;YACNC,MAAM;YACNE,SAAS;mBAAId;aAAU;YACvBa,UAAU;QACZ;QACA;YACEF,MAAM;YACNC,MAAM;YACNC,UAAU;QACZ;QACA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;YACH;YACA,0DAA0D;eACrDnC,cAAcoC,IAAI,GAAG,IACtB;gBACE;oBACEvB,MAAM;oBACNC,MAAM;oBACNG,OAAO;wBACLoB,UAAU;oBACZ;oBACAL,OAAO;oBACPhB,SAAS;2BAAIhB;qBAAc;gBAC7B;aACD,GACD,EAAE;YACN;gBACEa,MAAM;gBACNC,MAAM;gBACNG,OAAO;oBACLoB,UAAU;gBACZ;gBACAL,OAAO;gBACPhB,SAAS;uBAAId;iBAAU;gBACvBa,UAAU;YACZ;YACA;gBACEF,MAAM;gBACNC,MAAM;gBACNG,OAAO;oBACLoB,UAAU;gBACZ;gBACAJ,cAAc;gBACdD,OAAO;YACT;YACA;gBACEnB,MAAM;gBACNC,MAAM;gBACNkB,OAAO;YACT;YACA;gBACEnB,MAAM;gBACNC,MAAM;gBACNG,OAAO;oBACLoB,UAAU;gBACZ;gBACAJ,cAAc;gBACdD,OAAO;YACT;SACD;QACDM,OAAO;YACLC,WAAW;gBACT,CAAC,EAAEC,GAAG,EAAEC,GAAG,EAAE;oBACX,4GAA4G;oBAE5GD,IAAIE,UAAU,GAAGjD,iBAAiB;wBAChCkD,QAAQH,IAAII,GAAG;wBACfC,aAAaJ,IAAIK,OAAO,CAACnD,MAAM,CAACG,IAAI,CAACU,KAAK;oBAC5C;oBAEA,OAAOgC;gBACT;aACD;YACD;;;OAGC,GACDO,cAAc;gBACZ,CAAC,EAAE3B,IAAI,EAAE4B,WAAW,EAAE;oBACpB,IAAIA,aAAaC,OAAOC,WAAW;wBACjC9B,KAAK+B,UAAU,GAAG;wBAClB/B,KAAKc,QAAQ,GAAG;wBAChB,OAAOd,KAAKgC,WAAW;wBACvB,OAAOhC,KAAKiC,SAAS;oBACvB;oBACA,OAAOjC;gBACT;aACD;QACH;QACAkC,eAAe;IACjB;IAEA,OAAO7B;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/queues/config/jobsCollection.ts"],"sourcesContent":["import type { CollectionConfig } from '../../collections/config/types.js'\nimport type { Config } from '../../config/types.js'\nimport type { Field } from '../../fields/config/types.js'\n\nimport { runJobsEndpoint } from '../restEndpointRun.js'\nimport { getJobTaskStatus } from '../utilities/getJobTaskStatus.js'\n\nexport const jobsCollectionSlug = 'payload-jobs'\n\nexport const getDefaultJobsCollection: (config: Config) => CollectionConfig | null = (config) => {\n if (!Array.isArray(config?.jobs?.workflows)) {\n return null\n }\n\n const workflowSlugs: Set<string> = new Set()\n const taskSlugs: Set<string> = new Set(['inline'])\n\n if (config.jobs?.workflows.length) {\n config.jobs?.workflows.forEach((workflow) => {\n workflowSlugs.add(workflow.slug)\n })\n }\n\n if (config.jobs?.tasks.length) {\n config.jobs.tasks.forEach((task) => {\n if (workflowSlugs.has(task.slug)) {\n throw new Error(\n `Task slug \"${task.slug}\" is already used by a workflow. No tasks are allowed to have the same slug as a workflow.`,\n )\n }\n taskSlugs.add(task.slug)\n })\n }\n\n const logFields: Field[] = [\n {\n name: 'executedAt',\n type: 'date',\n required: true,\n },\n {\n name: 'completedAt',\n type: 'date',\n required: true,\n },\n {\n name: 'taskSlug',\n type: 'select',\n options: [...taskSlugs],\n required: true,\n },\n {\n name: 'taskID',\n type: 'text',\n required: true,\n },\n {\n name: 'input',\n type: 'json',\n },\n {\n name: 'output',\n type: 'json',\n },\n {\n name: 'state',\n type: 'radio',\n options: ['failed', 'succeeded'],\n required: true,\n },\n {\n name: 'error',\n type: 'json',\n admin: {\n condition: (_, data) => data.state === 'failed',\n },\n required: true,\n },\n ]\n\n if (config?.jobs?.addParentToTaskLog) {\n logFields.push({\n name: 'parent',\n type: 'group',\n fields: [\n {\n name: 'taskSlug',\n type: 'select',\n options: [...taskSlugs],\n },\n {\n name: 'taskID',\n type: 'text',\n },\n ],\n })\n }\n\n const jobsCollection: CollectionConfig = {\n slug: jobsCollectionSlug,\n admin: {\n group: 'System',\n hidden: true,\n },\n endpoints: [runJobsEndpoint],\n fields: [\n {\n name: 'input',\n type: 'json',\n admin: {\n description: 'Input data provided to the job',\n },\n },\n {\n name: 'taskStatus',\n type: 'json',\n virtual: true,\n },\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'completedAt',\n type: 'date',\n index: true,\n },\n {\n name: 'totalTried',\n type: 'number',\n defaultValue: 0,\n index: true,\n },\n {\n name: 'hasError',\n type: 'checkbox',\n admin: {\n description: 'If hasError is true this job will not be retried',\n },\n defaultValue: false,\n index: true,\n },\n {\n name: 'error',\n type: 'json',\n admin: {\n condition: (data) => data.hasError,\n description: 'If hasError is true, this is the error that caused it',\n },\n },\n {\n name: 'log',\n type: 'array',\n admin: {\n description: 'Task execution log',\n },\n fields: logFields,\n },\n ],\n label: 'Status',\n },\n ],\n },\n // only include the workflowSlugs field if workflows exist\n ...((workflowSlugs.size > 0\n ? [\n {\n name: 'workflowSlug',\n type: 'select',\n admin: {\n position: 'sidebar',\n },\n index: true,\n options: [...workflowSlugs],\n },\n ]\n : []) as Field[]),\n {\n name: 'taskSlug',\n type: 'select',\n admin: {\n position: 'sidebar',\n },\n index: true,\n options: [...taskSlugs],\n required: false,\n },\n {\n name: 'queue',\n type: 'text',\n admin: {\n position: 'sidebar',\n },\n defaultValue: 'default',\n index: true,\n },\n {\n name: 'waitUntil',\n type: 'date',\n index: true,\n },\n {\n name: 'processing',\n type: 'checkbox',\n admin: {\n position: 'sidebar',\n },\n defaultValue: false,\n index: true,\n },\n ],\n hooks: {\n afterRead: [\n ({ doc, req }) => {\n // This hook is used to add the virtual `tasks` field to the document, that is computed from the `log` field\n\n doc.taskStatus = getJobTaskStatus({\n jobLog: doc.log,\n tasksConfig: req.payload.config.jobs.tasks,\n })\n\n return doc\n },\n ],\n /**\n * If another update comes in after a job as already been cancelled, we need to make sure that update doesn't\n * change the state of the job.\n */\n beforeChange: [\n ({ data, originalDoc }) => {\n if (originalDoc?.error?.cancelled) {\n data.processing = false\n data.hasError = true\n delete data.completedAt\n delete data.waitUntil\n }\n return data\n },\n ],\n },\n lockDocuments: false,\n }\n\n return jobsCollection\n}\n"],"names":["runJobsEndpoint","getJobTaskStatus","jobsCollectionSlug","getDefaultJobsCollection","config","Array","isArray","jobs","workflows","workflowSlugs","Set","taskSlugs","length","forEach","workflow","add","slug","tasks","task","has","Error","logFields","name","type","required","options","admin","condition","_","data","state","addParentToTaskLog","push","fields","jobsCollection","group","hidden","endpoints","description","virtual","tabs","index","defaultValue","hasError","label","size","position","hooks","afterRead","doc","req","taskStatus","jobLog","log","tasksConfig","payload","beforeChange","originalDoc","error","cancelled","processing","completedAt","waitUntil","lockDocuments"],"mappings":"AAIA,SAASA,eAAe,QAAQ,wBAAuB;AACvD,SAASC,gBAAgB,QAAQ,mCAAkC;AAEnE,OAAO,MAAMC,qBAAqB,eAAc;AAEhD,OAAO,MAAMC,2BAAwE,CAACC;IACpF,IAAI,CAACC,MAAMC,OAAO,CAACF,QAAQG,MAAMC,YAAY;QAC3C,OAAO;IACT;IAEA,MAAMC,gBAA6B,IAAIC;IACvC,MAAMC,YAAyB,IAAID,IAAI;QAAC;KAAS;IAEjD,IAAIN,OAAOG,IAAI,EAAEC,UAAUI,QAAQ;QACjCR,OAAOG,IAAI,EAAEC,UAAUK,QAAQ,CAACC;YAC9BL,cAAcM,GAAG,CAACD,SAASE,IAAI;QACjC;IACF;IAEA,IAAIZ,OAAOG,IAAI,EAAEU,MAAML,QAAQ;QAC7BR,OAAOG,IAAI,CAACU,KAAK,CAACJ,OAAO,CAAC,CAACK;YACzB,IAAIT,cAAcU,GAAG,CAACD,KAAKF,IAAI,GAAG;gBAChC,MAAM,IAAII,MACR,CAAC,WAAW,EAAEF,KAAKF,IAAI,CAAC,0FAA0F,CAAC;YAEvH;YACAL,UAAUI,GAAG,CAACG,KAAKF,IAAI;QACzB;IACF;IAEA,MAAMK,YAAqB;QACzB;YACEC,MAAM;YACNC,MAAM;YACNC,UAAU;QACZ;QACA;YACEF,MAAM;YACNC,MAAM;YACNC,UAAU;QACZ;QACA;YACEF,MAAM;YACNC,MAAM;YACNE,SAAS;mBAAId;aAAU;Y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+ import type { Config } from '../config/types.js';
2
+ /** Will read the `routes.admin` config and appropriately handle `"/"` admin paths */
3
+ export declare const formatAdminURL: (args: {
4
+ adminRoute: NonNullable<Config["routes"]>["admin"];
5
+ basePath?: string;
6
+ path: "" | `/${string}` | null | undefined;
7
+ serverURL?: Config["serverURL"];
8
+ }) => string;
9
+ //# sourceMappingURL=formatAdminURL.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatAdminURL.d.ts","sourceRoot":"","sources":["../../src/utilities/formatAdminURL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,qFAAqF;AACrF,eAAO,MAAM,cAAc,SAAU;IACnC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,IAAI,GAAG,SAAS,CAAA;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,CAAA;CAChC,KAAG,MAeH,CAAA"}