@seshuk/payload-plugin-openapi 1.0.0-beta.1 → 1.0.0-beta.2

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 (148) hide show
  1. package/README.md +8 -4
  2. package/dist/server/spec/buildDocument.js +62 -9
  3. package/dist/server/spec/buildDocument.js.map +1 -1
  4. package/dist/server/spec/components.js.map +1 -1
  5. package/dist/server/spec/entitySchemas.d.ts +5 -6
  6. package/dist/server/spec/entitySchemas.js.map +1 -1
  7. package/dist/server/spec/filters.d.ts +5 -1
  8. package/dist/server/spec/filters.js +21 -10
  9. package/dist/server/spec/filters.js.map +1 -1
  10. package/dist/server/spec/hierarchy.js +9 -4
  11. package/dist/server/spec/hierarchy.js.map +1 -1
  12. package/dist/server/spec/paths/collections.js +111 -7
  13. package/dist/server/spec/paths/collections.js.map +1 -1
  14. package/dist/server/spec/paths/custom.d.ts +4 -2
  15. package/dist/server/spec/paths/custom.js +1 -1
  16. package/dist/server/spec/paths/custom.js.map +1 -1
  17. package/dist/server/spec/paths/system.d.ts +2 -1
  18. package/dist/server/spec/paths/system.js +67 -1
  19. package/dist/server/spec/paths/system.js.map +1 -1
  20. package/dist/server/spec/plugins/ecommerce.d.ts +3 -0
  21. package/dist/server/spec/plugins/ecommerce.js +270 -0
  22. package/dist/server/spec/plugins/ecommerce.js.map +1 -0
  23. package/dist/server/spec/plugins/importExport.d.ts +3 -0
  24. package/dist/server/spec/plugins/importExport.js +202 -0
  25. package/dist/server/spec/plugins/importExport.js.map +1 -0
  26. package/dist/server/spec/plugins/index.d.ts +3 -0
  27. package/dist/server/spec/plugins/index.js +21 -0
  28. package/dist/server/spec/plugins/index.js.map +1 -0
  29. package/dist/server/spec/plugins/mcp.d.ts +3 -0
  30. package/dist/server/spec/plugins/mcp.js +118 -0
  31. package/dist/server/spec/plugins/mcp.js.map +1 -0
  32. package/dist/server/spec/plugins/multiTenant.d.ts +3 -0
  33. package/dist/server/spec/plugins/multiTenant.js +39 -0
  34. package/dist/server/spec/plugins/multiTenant.js.map +1 -0
  35. package/dist/server/spec/plugins/search.d.ts +3 -0
  36. package/dist/server/spec/plugins/search.js +43 -0
  37. package/dist/server/spec/plugins/search.js.map +1 -0
  38. package/dist/server/spec/plugins/seo.d.ts +3 -0
  39. package/dist/server/spec/plugins/seo.js +83 -0
  40. package/dist/server/spec/plugins/seo.js.map +1 -0
  41. package/dist/server/spec/plugins/shared.d.ts +35 -0
  42. package/dist/server/spec/plugins/shared.js +37 -0
  43. package/dist/server/spec/plugins/shared.js.map +1 -0
  44. package/dist/server/spec/plugins/storageR2.d.ts +3 -0
  45. package/dist/server/spec/plugins/storageR2.js +91 -0
  46. package/dist/server/spec/plugins/storageR2.js.map +1 -0
  47. package/dist/server/spec/plugins/stripe.d.ts +10 -0
  48. package/dist/server/spec/plugins/stripe.js +102 -0
  49. package/dist/server/spec/plugins/stripe.js.map +1 -0
  50. package/dist/server/spec/security.d.ts +2 -1
  51. package/dist/server/spec/security.js +5 -2
  52. package/dist/server/spec/security.js.map +1 -1
  53. package/dist/server/spec/tags.d.ts +4 -1
  54. package/dist/server/spec/tags.js +18 -2
  55. package/dist/server/spec/tags.js.map +1 -1
  56. package/dist/server/ui/html.js +2 -2
  57. package/dist/server/ui/html.js.map +1 -1
  58. package/dist/shared/translations/locales/ar.js +74 -0
  59. package/dist/shared/translations/locales/ar.js.map +1 -1
  60. package/dist/shared/translations/locales/az.js +74 -0
  61. package/dist/shared/translations/locales/az.js.map +1 -1
  62. package/dist/shared/translations/locales/bg.js +74 -0
  63. package/dist/shared/translations/locales/bg.js.map +1 -1
  64. package/dist/shared/translations/locales/bnBd.js +74 -0
  65. package/dist/shared/translations/locales/bnBd.js.map +1 -1
  66. package/dist/shared/translations/locales/bnIn.js +74 -0
  67. package/dist/shared/translations/locales/bnIn.js.map +1 -1
  68. package/dist/shared/translations/locales/ca.js +74 -0
  69. package/dist/shared/translations/locales/ca.js.map +1 -1
  70. package/dist/shared/translations/locales/cs.js +74 -0
  71. package/dist/shared/translations/locales/cs.js.map +1 -1
  72. package/dist/shared/translations/locales/da.js +74 -0
  73. package/dist/shared/translations/locales/da.js.map +1 -1
  74. package/dist/shared/translations/locales/de.js +74 -0
  75. package/dist/shared/translations/locales/de.js.map +1 -1
  76. package/dist/shared/translations/locales/en.js +74 -0
  77. package/dist/shared/translations/locales/en.js.map +1 -1
  78. package/dist/shared/translations/locales/es.js +74 -0
  79. package/dist/shared/translations/locales/es.js.map +1 -1
  80. package/dist/shared/translations/locales/et.js +74 -0
  81. package/dist/shared/translations/locales/et.js.map +1 -1
  82. package/dist/shared/translations/locales/fa.js +74 -0
  83. package/dist/shared/translations/locales/fa.js.map +1 -1
  84. package/dist/shared/translations/locales/fr.js +74 -0
  85. package/dist/shared/translations/locales/fr.js.map +1 -1
  86. package/dist/shared/translations/locales/he.js +74 -0
  87. package/dist/shared/translations/locales/he.js.map +1 -1
  88. package/dist/shared/translations/locales/hr.js +74 -0
  89. package/dist/shared/translations/locales/hr.js.map +1 -1
  90. package/dist/shared/translations/locales/hu.js +74 -0
  91. package/dist/shared/translations/locales/hu.js.map +1 -1
  92. package/dist/shared/translations/locales/hy.js +74 -0
  93. package/dist/shared/translations/locales/hy.js.map +1 -1
  94. package/dist/shared/translations/locales/id.js +74 -0
  95. package/dist/shared/translations/locales/id.js.map +1 -1
  96. package/dist/shared/translations/locales/is.js +74 -0
  97. package/dist/shared/translations/locales/is.js.map +1 -1
  98. package/dist/shared/translations/locales/it.js +74 -0
  99. package/dist/shared/translations/locales/it.js.map +1 -1
  100. package/dist/shared/translations/locales/ja.js +74 -0
  101. package/dist/shared/translations/locales/ja.js.map +1 -1
  102. package/dist/shared/translations/locales/ko.js +74 -0
  103. package/dist/shared/translations/locales/ko.js.map +1 -1
  104. package/dist/shared/translations/locales/lt.js +74 -0
  105. package/dist/shared/translations/locales/lt.js.map +1 -1
  106. package/dist/shared/translations/locales/lv.js +74 -0
  107. package/dist/shared/translations/locales/lv.js.map +1 -1
  108. package/dist/shared/translations/locales/my.js +74 -0
  109. package/dist/shared/translations/locales/my.js.map +1 -1
  110. package/dist/shared/translations/locales/nb.js +74 -0
  111. package/dist/shared/translations/locales/nb.js.map +1 -1
  112. package/dist/shared/translations/locales/nl.js +74 -0
  113. package/dist/shared/translations/locales/nl.js.map +1 -1
  114. package/dist/shared/translations/locales/pl.js +74 -0
  115. package/dist/shared/translations/locales/pl.js.map +1 -1
  116. package/dist/shared/translations/locales/pt.js +74 -0
  117. package/dist/shared/translations/locales/pt.js.map +1 -1
  118. package/dist/shared/translations/locales/ro.js +74 -0
  119. package/dist/shared/translations/locales/ro.js.map +1 -1
  120. package/dist/shared/translations/locales/rs.js +74 -0
  121. package/dist/shared/translations/locales/rs.js.map +1 -1
  122. package/dist/shared/translations/locales/rsLatin.js +74 -0
  123. package/dist/shared/translations/locales/rsLatin.js.map +1 -1
  124. package/dist/shared/translations/locales/ru.js +74 -0
  125. package/dist/shared/translations/locales/ru.js.map +1 -1
  126. package/dist/shared/translations/locales/sk.js +74 -0
  127. package/dist/shared/translations/locales/sk.js.map +1 -1
  128. package/dist/shared/translations/locales/sl.js +74 -0
  129. package/dist/shared/translations/locales/sl.js.map +1 -1
  130. package/dist/shared/translations/locales/sv.js +74 -0
  131. package/dist/shared/translations/locales/sv.js.map +1 -1
  132. package/dist/shared/translations/locales/ta.js +74 -0
  133. package/dist/shared/translations/locales/ta.js.map +1 -1
  134. package/dist/shared/translations/locales/th.js +74 -0
  135. package/dist/shared/translations/locales/th.js.map +1 -1
  136. package/dist/shared/translations/locales/tr.js +74 -0
  137. package/dist/shared/translations/locales/tr.js.map +1 -1
  138. package/dist/shared/translations/locales/uk.js +74 -0
  139. package/dist/shared/translations/locales/uk.js.map +1 -1
  140. package/dist/shared/translations/locales/vi.js +74 -0
  141. package/dist/shared/translations/locales/vi.js.map +1 -1
  142. package/dist/shared/translations/locales/zh.js +74 -0
  143. package/dist/shared/translations/locales/zh.js.map +1 -1
  144. package/dist/shared/translations/locales/zhTw.js +74 -0
  145. package/dist/shared/translations/locales/zhTw.js.map +1 -1
  146. package/dist/shared/translations/types.d.ts +74 -0
  147. package/dist/shared/types/index.d.ts +23 -8
  148. package/package.json +23 -15
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecommerce.js","names":[],"sources":["../../../../src/server/spec/plugins/ecommerce.ts"],"sourcesContent":["import type { OperationObject, ParameterObject, SchemaObject } from '@scalar/openapi-types/3.2'\n\nimport { ERROR_SCHEMA_NAME, errorResponses, jsonBody, jsonResponse } from '@/server/spec/components.js'\nimport { refTo, schemaName } from '@/server/spec/names.js'\nimport { securedRequirement } from '@/server/spec/security.js'\nimport type { MessageKey } from '@/shared/translations/types.js'\nimport { upperFirst } from '@/shared/utils.js'\n\nimport { type OfficialPlugin, collectionGroups, idSchema, messageErrors, mountEndpoints } from './shared.js'\nimport { stripeWebhookOperation } from './stripe.js'\n\nconst TAG = 'Ecommerce'\n\nconst PAYMENT_PATH = /^\\/payments\\/([^/]+)\\/(initiate|confirm-order)$/\n\nconst CART_OPERATIONS: Record<string, { operationId: string; summary: MessageKey }> = {\n '/:id/add-item': { operationId: 'addItem', summary: 'ecommerceAddItem' },\n '/:id/remove-item': { operationId: 'removeItem', summary: 'ecommerceRemoveItem' },\n '/:id/update-item': { operationId: 'updateItem', summary: 'ecommerceUpdateItem' },\n '/:id/clear': { operationId: 'clear', summary: 'ecommerceClearCart' },\n '/:id/merge': { operationId: 'merge', summary: 'ecommerceMergeCart' },\n}\n\nexport const ecommerce: OfficialPlugin = {\n slug: '@payloadcms/plugin-ecommerce',\n tag: TAG,\n build: ({ config, collections, ctx, schemas, t }) => {\n const id = idSchema(ctx)\n const secret: SchemaObject = { type: 'string' }\n const failure: SchemaObject = {\n type: 'object',\n properties: { message: { type: 'string' }, success: { type: 'boolean', enum: [false] } },\n required: ['message', 'success'],\n }\n\n const cartBodies: Record<string, SchemaObject> = {\n '/:id/add-item': {\n type: 'object',\n properties: {\n item: {\n type: 'object',\n additionalProperties: true,\n properties: { product: id, variant: id },\n required: ['product'],\n },\n quantity: { type: 'number', default: 1 },\n secret,\n },\n required: ['item'],\n },\n '/:id/remove-item': {\n type: 'object',\n properties: { itemID: { type: 'string' }, secret },\n required: ['itemID'],\n },\n '/:id/update-item': {\n type: 'object',\n properties: {\n itemID: { type: 'string' },\n quantity: {\n description: t('ecommerceQuantity'),\n oneOf: [\n { type: 'number' },\n { type: 'object', properties: { $inc: { type: 'number' } }, required: ['$inc'] },\n ],\n },\n removeOnZero: { type: 'boolean', default: true },\n secret,\n },\n required: ['itemID', 'quantity'],\n },\n '/:id/clear': { type: 'object', properties: { secret } },\n '/:id/merge': {\n type: 'object',\n properties: { sourceCartID: id, sourceSecret: { type: 'string' } },\n required: ['sourceCartID', 'sourceSecret'],\n },\n }\n\n const cartGroups = collectionGroups(\n collections.filter((c) =>\n (c.endpoints || []).some((endpoint) => endpoint.method === 'post' && endpoint.path === '/:id/add-item'),\n ),\n ctx,\n ({ method, path }, collection): OperationObject | undefined => {\n const meta = CART_OPERATIONS[path]\n if (!meta || method !== 'post') return undefined\n const name = schemaName(collection.slug)\n const merge = path === '/:id/merge'\n const cart: SchemaObject = schemas[name]\n ? { $ref: refTo(name) }\n : { type: 'object', additionalProperties: true }\n const param: ParameterObject = { name: 'id', in: 'path', required: true, schema: id }\n return {\n tags: [TAG],\n operationId: `${meta.operationId}${name}`,\n summary: t(meta.summary),\n description: merge ? undefined : t('ecommerceCartAccess'),\n parameters: [param],\n requestBody: { ...jsonBody(cartBodies[path]!), required: path !== '/:id/clear' },\n responses: {\n '200': jsonResponse(t('ecommerceCartResult'), {\n type: 'object',\n properties: { cart, message: { type: 'string' }, success: { type: 'boolean', enum: [true] } },\n required: ['cart', 'message', 'success'],\n }),\n ...messageErrors(merge ? ['400', '401'] : ['400'], t, failure),\n ...errorResponses(['403'], t),\n '404': jsonResponse(t('errorPluginEcommerce404'), {\n oneOf: [\n {\n type: 'object',\n properties: { cart: { type: ['object', 'null'] }, ...failure.properties },\n required: ['cart', 'message', 'success'],\n },\n { $ref: refTo(ERROR_SCHEMA_NAME) },\n ],\n }),\n },\n ...(merge ? { security: securedRequirement() } : {}),\n }\n },\n )\n\n const address: SchemaObject = { type: 'object', additionalProperties: true }\n const paymentBody = (extra: Record<string, SchemaObject>) => ({\n ...jsonBody({\n type: 'object',\n additionalProperties: true,\n properties: {\n cartID: id,\n secret,\n customerEmail: { type: 'string', format: 'email' },\n billingAddress: address,\n shippingAddress: address,\n ...extra,\n },\n ...(Object.keys(extra).length > 0 ? { required: Object.keys(extra) } : {}),\n }),\n description: t('ecommercePaymentBody'),\n })\n\n const usedIds = new Set<string>()\n const uniqueId = (base: string) => {\n let operationId = base\n for (let n = 2; usedIds.has(operationId); n++) operationId = `${base}${n}`\n usedIds.add(operationId)\n return operationId\n }\n\n const payments = mountEndpoints(config.endpoints, ctx.apiRoute, ({ method, path }) => {\n if (method !== 'post') return undefined\n if (path === '/payments/stripe/webhooks') {\n return stripeWebhookOperation({ tag: TAG, operationId: 'ecommerceStripeWebhooks', t })\n }\n const match = PAYMENT_PATH.exec(path)\n if (!match) return undefined\n const [, methodName = '', step] = match\n const stripe = methodName === 'stripe'\n const suffix = upperFirst(methodName.replace(/[^A-Za-z0-9]+(.)?/g, (_, c: string = '') => c.toUpperCase()))\n if (step === 'initiate') {\n return {\n tags: [TAG],\n operationId: uniqueId(`initiatePayment${suffix}`),\n summary: t('ecommerceInitiatePayment', { method: methodName }),\n requestBody: paymentBody({}),\n responses: {\n '200': jsonResponse(t('ecommerceInitiateResult'), {\n type: 'object',\n additionalProperties: true,\n properties: {\n message: { type: 'string' },\n ...(stripe ? { clientSecret: { type: 'string' }, paymentIntentID: { type: 'string' } } : {}),\n },\n required: ['message'],\n }),\n ...messageErrors(['400', '404', '500'], t),\n },\n }\n }\n return {\n tags: [TAG],\n operationId: uniqueId(`confirmOrder${suffix}`),\n summary: t('ecommerceConfirmOrder', { method: methodName }),\n requestBody: paymentBody(stripe ? { paymentIntentID: { type: 'string' } } : {}),\n responses: {\n '200': jsonResponse(t('ecommerceConfirmResult'), {\n type: 'object',\n additionalProperties: true,\n properties: {\n message: { type: 'string' },\n orderID: id,\n transactionID: id,\n ...(stripe ? { accessToken: { type: 'string' } } : {}),\n },\n required: ['message', 'orderID', 'transactionID'],\n }),\n ...messageErrors(['400', '404', '500'], t),\n },\n }\n })\n\n return [{ paths: payments }, ...cartGroups]\n },\n}\n"],"mappings":";;;;;;AAWA,MAAM,MAAM;AAEZ,MAAM,eAAe;AAErB,MAAM,kBAAgF;CACpF,iBAAiB;EAAE,aAAa;EAAW,SAAS;CAAmB;CACvE,oBAAoB;EAAE,aAAa;EAAc,SAAS;CAAsB;CAChF,oBAAoB;EAAE,aAAa;EAAc,SAAS;CAAsB;CAChF,cAAc;EAAE,aAAa;EAAS,SAAS;CAAqB;CACpE,cAAc;EAAE,aAAa;EAAS,SAAS;CAAqB;AACtE;AAEA,MAAa,YAA4B;CACvC,MAAM;CACN,KAAK;CACL,QAAQ,EAAE,QAAQ,aAAa,KAAK,SAAS,QAAQ;EACnD,MAAM,KAAK,SAAS,GAAG;EACvB,MAAM,SAAuB,EAAE,MAAM,SAAS;EAC9C,MAAM,UAAwB;GAC5B,MAAM;GACN,YAAY;IAAE,SAAS,EAAE,MAAM,SAAS;IAAG,SAAS;KAAE,MAAM;KAAW,MAAM,CAAC,KAAK;IAAE;GAAE;GACvF,UAAU,CAAC,WAAW,SAAS;EACjC;EAEA,MAAM,aAA2C;GAC/C,iBAAiB;IACf,MAAM;IACN,YAAY;KACV,MAAM;MACJ,MAAM;MACN,sBAAsB;MACtB,YAAY;OAAE,SAAS;OAAI,SAAS;MAAG;MACvC,UAAU,CAAC,SAAS;KACtB;KACA,UAAU;MAAE,MAAM;MAAU,SAAS;KAAE;KACvC;IACF;IACA,UAAU,CAAC,MAAM;GACnB;GACA,oBAAoB;IAClB,MAAM;IACN,YAAY;KAAE,QAAQ,EAAE,MAAM,SAAS;K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MAAM;MACN,sBAAsB;MACtB,YAAY;OACV,SAAS,EAAE,MAAM,SAAS;OAC1B,SAAS;OACT,eAAe;OACf,GAAI,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,EAAE,IAAI,CAAC;MACtD;MACA,UAAU;OAAC;OAAW;OAAW;MAAe;KAClD,CAAC;KACD,GAAG,cAAc;MAAC;MAAO;MAAO;KAAK,GAAG,CAAC;IAC3C;GACF;EACF,CAEwB,EAAE,GAAG,GAAG,UAAU;CAC5C;AACF"}
@@ -0,0 +1,3 @@
1
+ import { OfficialPlugin } from "./shared.js";
2
+ export declare const importExport: OfficialPlugin;
3
+ //# sourceMappingURL=importExport.d.ts.map
@@ -0,0 +1,202 @@
1
+ import { schemaName } from "../names.js";
2
+ import { errorResponses, jsonBody, jsonResponse } from "../components.js";
3
+ import { securedRequirement } from "../security.js";
4
+ import { collectionGroups, messageErrors } from "./shared.js";
5
+ const TAG = "Import/Export";
6
+ const targetSlugs = (collection) => {
7
+ const meta = (collection.admin?.custom)?.["plugin-import-export"];
8
+ return Array.isArray(meta?.collectionSlugs) ? meta.collectionSlugs : void 0;
9
+ };
10
+ const errorSchema = {
11
+ type: "object",
12
+ properties: { error: { type: "string" } },
13
+ required: ["error"]
14
+ };
15
+ const pageProperties = {
16
+ docs: {
17
+ type: "array",
18
+ items: {
19
+ type: "object",
20
+ additionalProperties: true
21
+ }
22
+ },
23
+ hasNextPage: { type: "boolean" },
24
+ hasPrevPage: { type: "boolean" },
25
+ limit: { type: "integer" },
26
+ maxLimit: { type: "integer" },
27
+ page: { type: "integer" },
28
+ totalDocs: { type: "integer" },
29
+ totalPages: { type: "integer" }
30
+ };
31
+ const previewPaging = {
32
+ previewLimit: {
33
+ type: "integer",
34
+ minimum: 1,
35
+ maximum: 100,
36
+ default: 10
37
+ },
38
+ previewPage: {
39
+ type: "integer",
40
+ minimum: 1,
41
+ default: 1
42
+ }
43
+ };
44
+ const format = {
45
+ type: "string",
46
+ enum: ["csv", "json"]
47
+ };
48
+ const drafts = {
49
+ type: "string",
50
+ enum: ["yes", "no"]
51
+ };
52
+ const query = {
53
+ fields: {
54
+ type: "array",
55
+ items: { type: "string" }
56
+ },
57
+ limit: {
58
+ type: "integer",
59
+ minimum: 0
60
+ },
61
+ locale: { type: "string" },
62
+ sort: { type: "string" },
63
+ where: {
64
+ type: "object",
65
+ additionalProperties: true
66
+ }
67
+ };
68
+ const importExport = {
69
+ slug: "@payloadcms/plugin-import-export",
70
+ tag: TAG,
71
+ build: ({ collections, ctx, t }) => {
72
+ const visible = new Set(collections.map((c) => c.slug));
73
+ return collectionGroups(collections, ctx, ({ method, path }, collection) => {
74
+ const slugs = targetSlugs(collection)?.filter((slug) => visible.has(slug));
75
+ if (!slugs || method !== "post") return void 0;
76
+ const name = schemaName(collection.slug);
77
+ const collectionSlug = {
78
+ type: "string",
79
+ ...slugs.length > 0 ? { enum: slugs } : {}
80
+ };
81
+ if (path === "/download") return {
82
+ tags: [TAG],
83
+ operationId: `download${name}`,
84
+ summary: t("exportDownload"),
85
+ requestBody: jsonBody({
86
+ type: "object",
87
+ properties: { data: {
88
+ type: "object",
89
+ additionalProperties: true,
90
+ properties: {
91
+ collectionSlug,
92
+ format,
93
+ name: { type: "string" },
94
+ ...query,
95
+ page: { type: "integer" },
96
+ drafts
97
+ },
98
+ required: ["collectionSlug", "format"]
99
+ } },
100
+ required: ["data"]
101
+ }),
102
+ responses: {
103
+ "200": {
104
+ description: t("exportDownloadResult"),
105
+ headers: { "Content-Disposition": { schema: { type: "string" } } },
106
+ content: {
107
+ "text/csv": { schema: { type: "string" } },
108
+ "application/json": { schema: {
109
+ type: "array",
110
+ items: {
111
+ type: "object",
112
+ additionalProperties: true
113
+ }
114
+ } }
115
+ }
116
+ },
117
+ ...errorResponses(["400"], t)
118
+ },
119
+ security: securedRequirement()
120
+ };
121
+ if (path === "/export-preview") return {
122
+ tags: [TAG],
123
+ operationId: `preview${name}`,
124
+ summary: t("exportPreview"),
125
+ requestBody: jsonBody({
126
+ type: "object",
127
+ additionalProperties: true,
128
+ properties: {
129
+ collectionSlug,
130
+ format,
131
+ ...query,
132
+ ...previewPaging,
133
+ draft: drafts
134
+ },
135
+ required: ["collectionSlug"]
136
+ }),
137
+ responses: {
138
+ "200": jsonResponse(t("previewResult"), {
139
+ type: "object",
140
+ properties: {
141
+ columns: {
142
+ type: "array",
143
+ items: { type: "string" }
144
+ },
145
+ exportTotalDocs: { type: "integer" },
146
+ ...pageProperties
147
+ },
148
+ required: [
149
+ "docs",
150
+ "page",
151
+ "limit",
152
+ "totalDocs",
153
+ "totalPages"
154
+ ]
155
+ }),
156
+ ...messageErrors(["400"], t, errorSchema)
157
+ }
158
+ };
159
+ if (path === "/preview-data") return {
160
+ tags: [TAG],
161
+ operationId: `preview${name}Data`,
162
+ summary: t("importPreview"),
163
+ requestBody: jsonBody({
164
+ type: "object",
165
+ additionalProperties: true,
166
+ properties: {
167
+ collectionSlug,
168
+ fileData: {
169
+ type: "string",
170
+ contentEncoding: "base64",
171
+ description: t("importFileData")
172
+ },
173
+ format,
174
+ ...previewPaging
175
+ },
176
+ required: ["collectionSlug", "fileData"]
177
+ }),
178
+ responses: {
179
+ "200": jsonResponse(t("previewResult"), {
180
+ type: "object",
181
+ properties: {
182
+ ...pageProperties,
183
+ limitExceeded: { type: "boolean" }
184
+ },
185
+ required: [
186
+ "docs",
187
+ "page",
188
+ "limit",
189
+ "totalDocs",
190
+ "totalPages",
191
+ "limitExceeded"
192
+ ]
193
+ }),
194
+ ...messageErrors(["400", "500"], t, errorSchema)
195
+ }
196
+ };
197
+ });
198
+ }
199
+ };
200
+ export { importExport };
201
+
202
+ //# sourceMappingURL=importExport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importExport.js","names":[],"sources":["../../../../src/server/spec/plugins/importExport.ts"],"sourcesContent":["import type { OperationObject, SchemaObject } from '@scalar/openapi-types/3.2'\nimport type { SanitizedCollectionConfig } from 'payload'\n\nimport { errorResponses, jsonBody, jsonResponse } from '@/server/spec/components.js'\nimport { schemaName } from '@/server/spec/names.js'\nimport { securedRequirement } from '@/server/spec/security.js'\n\nimport { type OfficialPlugin, collectionGroups, messageErrors } from './shared.js'\n\nconst TAG = 'Import/Export'\n\nconst targetSlugs = (collection: SanitizedCollectionConfig): string[] | undefined => {\n const meta = (collection.admin?.custom as Record<string, { collectionSlugs?: unknown } | undefined> | undefined)?.[\n 'plugin-import-export'\n ]\n return Array.isArray(meta?.collectionSlugs) ? (meta.collectionSlugs as string[]) : undefined\n}\n\nconst errorSchema: SchemaObject = { type: 'object', properties: { error: { type: 'string' } }, required: ['error'] }\n\nconst pageProperties: Record<string, SchemaObject> = {\n docs: { type: 'array', items: { type: 'object', additionalProperties: true } },\n hasNextPage: { type: 'boolean' },\n hasPrevPage: { type: 'boolean' },\n limit: { type: 'integer' },\n maxLimit: { type: 'integer' },\n page: { type: 'integer' },\n totalDocs: { type: 'integer' },\n totalPages: { type: 'integer' },\n}\n\nconst previewPaging: Record<string, SchemaObject> = {\n previewLimit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },\n previewPage: { type: 'integer', minimum: 1, default: 1 },\n}\n\nconst format: SchemaObject = { type: 'string', enum: ['csv', 'json'] }\nconst drafts: SchemaObject = { type: 'string', enum: ['yes', 'no'] }\n\nconst query: Record<string, SchemaObject> = {\n fields: { type: 'array', items: { type: 'string' } },\n limit: { type: 'integer', minimum: 0 },\n locale: { type: 'string' },\n sort: { type: 'string' },\n where: { type: 'object', additionalProperties: true },\n}\n\nexport const importExport: OfficialPlugin = {\n slug: '@payloadcms/plugin-import-export',\n tag: TAG,\n build: ({ collections, ctx, t }) => {\n const visible = new Set(collections.map((c) => c.slug))\n return collectionGroups(collections, ctx, ({ method, path }, collection): OperationObject | undefined => {\n const slugs = targetSlugs(collection)?.filter((slug) => visible.has(slug))\n if (!slugs || method !== 'post') return undefined\n const name = schemaName(collection.slug)\n const collectionSlug: SchemaObject = { type: 'string', ...(slugs.length > 0 ? { enum: slugs } : {}) }\n if (path === '/download') {\n return {\n tags: [TAG],\n operationId: `download${name}`,\n summary: t('exportDownload'),\n requestBody: jsonBody({\n type: 'object',\n properties: {\n data: {\n type: 'object',\n additionalProperties: true,\n properties: {\n collectionSlug,\n format,\n name: { type: 'string' },\n ...query,\n page: { type: 'integer' },\n drafts,\n },\n required: ['collectionSlug', 'format'],\n },\n },\n required: ['data'],\n }),\n responses: {\n '200': {\n description: t('exportDownloadResult'),\n headers: { 'Content-Disposition': { schema: { type: 'string' } } },\n content: {\n 'text/csv': { schema: { type: 'string' } },\n 'application/json': {\n schema: { type: 'array', items: { type: 'object', additionalProperties: true } },\n },\n },\n },\n ...errorResponses(['400'], t),\n },\n security: securedRequirement(),\n }\n }\n if (path === '/export-preview') {\n return {\n tags: [TAG],\n operationId: `preview${name}`,\n summary: t('exportPreview'),\n requestBody: jsonBody({\n type: 'object',\n additionalProperties: true,\n properties: { collectionSlug, format, ...query, ...previewPaging, draft: drafts },\n required: ['collectionSlug'],\n }),\n responses: {\n '200': jsonResponse(t('previewResult'), {\n type: 'object',\n properties: {\n columns: { type: 'array', items: { type: 'string' } },\n exportTotalDocs: { type: 'integer' },\n ...pageProperties,\n },\n required: ['docs', 'page', 'limit', 'totalDocs', 'totalPages'],\n }),\n ...messageErrors(['400'], t, errorSchema),\n },\n }\n }\n if (path === '/preview-data') {\n return {\n tags: [TAG],\n operationId: `preview${name}Data`,\n summary: t('importPreview'),\n requestBody: jsonBody({\n type: 'object',\n additionalProperties: true,\n properties: {\n collectionSlug,\n fileData: { type: 'string', contentEncoding: 'base64', description: t('importFileData') },\n format,\n ...previewPaging,\n },\n required: ['collectionSlug', 'fileData'],\n }),\n responses: {\n '200': jsonResponse(t('previewResult'), {\n type: 'object',\n properties: { ...pageProperties, limitExceeded: { type: 'boolean' } },\n required: ['docs', 'page', 'limit', 'totalDocs', 'totalPages', 'limitExceeded'],\n }),\n ...messageErrors(['400', '500'], t, errorSchema),\n },\n }\n }\n return undefined\n })\n },\n}\n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;MAAQ,GAAG;MAAO,GAAG;MAAe,OAAO;KAAO;KAChF,UAAU,CAAC,gBAAgB;IAC7B,CAAC;IACD,WAAW;KACT,OAAO,aAAa,EAAE,eAAe,GAAG;MACtC,MAAM;MACN,YAAY;OACV,SAAS;QAAE,MAAM;QAAS,OAAO,EAAE,MAAM,SAAS;OAAE;OACpD,iBAAiB,EAAE,MAAM,UAAU;OACnC,GAAG;MACL;MACA,UAAU;OAAC;OAAQ;OAAQ;OAAS;OAAa;MAAY;KAC/D,CAAC;KACD,GAAG,cAAc,CAAC,KAAK,GAAG,GAAG,WAAW;IAC1C;GACF;GAEF,IAAI,SAAS,iBACX,OAAO;IACL,MAAM,CAAC,GAAG;IACV,aAAa,UAAU,KAAK;IAC5B,SAAS,EAAE,eAAe;IAC1B,aAAa,SAAS;KACpB,MAAM;KACN,sBAAsB;KACtB,YAAY;MACV;MACA,UAAU;OAAE,MAAM;OAAU,iBAAiB;OAAU,aAAa,EAAE,gBAAgB;MAAE;MACxF;MACA,GAAG;KACL;KACA,UAAU,CAAC,kBAAkB,UAAU;IACzC,CAAC;IACD,WAAW;KACT,OAAO,aAAa,EAAE,eAAe,GAAG;MACtC,MAAM;MACN,YAAY;OAAE,GAAG;OAAgB,eAAe,EAAE,MAAM,UAAU;MAAE;MACpE,UAAU;OAAC;OAAQ;OAAQ;OAAS;OAAa;OAAc;MAAe;KAChF,CAAC;KACD,GAAG,cAAc,CAAC,OAAO,KAAK,GAAG,GAAG,WAAW;IACjD;GACF;EAGJ,CAAC;CACH;AACF"}
@@ -0,0 +1,3 @@
1
+ import { OfficialPlugin } from "./shared.js";
2
+ export declare const OFFICIAL_PLUGINS: OfficialPlugin[];
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { stripe } from "./stripe.js";
2
+ import { ecommerce } from "./ecommerce.js";
3
+ import { importExport } from "./importExport.js";
4
+ import { mcp } from "./mcp.js";
5
+ import { multiTenant } from "./multiTenant.js";
6
+ import { search } from "./search.js";
7
+ import { seo } from "./seo.js";
8
+ import { storageR2 } from "./storageR2.js";
9
+ const OFFICIAL_PLUGINS = [
10
+ ecommerce,
11
+ stripe,
12
+ mcp,
13
+ seo,
14
+ search,
15
+ multiTenant,
16
+ importExport,
17
+ storageR2
18
+ ];
19
+ export { OFFICIAL_PLUGINS };
20
+
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/server/spec/plugins/index.ts"],"sourcesContent":["import { ecommerce } from './ecommerce.js'\nimport { importExport } from './importExport.js'\nimport { mcp } from './mcp.js'\nimport { multiTenant } from './multiTenant.js'\nimport { search } from './search.js'\nimport { seo } from './seo.js'\nimport type { OfficialPlugin } from './shared.js'\nimport { storageR2 } from './storageR2.js'\nimport { stripe } from './stripe.js'\n\nexport const OFFICIAL_PLUGINS: OfficialPlugin[] = [\n ecommerce,\n stripe,\n mcp,\n seo,\n search,\n multiTenant,\n importExport,\n storageR2,\n]\n"],"mappings":";;;;;;;;AAUA,MAAa,mBAAqC;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -0,0 +1,3 @@
1
+ import { OfficialPlugin } from "./shared.js";
2
+ export declare const mcp: OfficialPlugin;
3
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1,118 @@
1
+ import { refTo } from "../names.js";
2
+ import { ERROR_SCHEMA_NAME, errorResponses, jsonBody, jsonResponse } from "../components.js";
3
+ import { mountEndpoints } from "./shared.js";
4
+ const TAG = "MCP";
5
+ const jsonRpcId = { type: [
6
+ "string",
7
+ "integer",
8
+ "null"
9
+ ] };
10
+ const jsonRpc = {
11
+ type: "object",
12
+ additionalProperties: true,
13
+ properties: {
14
+ jsonrpc: {
15
+ type: "string",
16
+ enum: ["2.0"]
17
+ },
18
+ id: jsonRpcId,
19
+ method: { type: "string" },
20
+ params: {
21
+ type: "object",
22
+ additionalProperties: true
23
+ },
24
+ result: {},
25
+ error: {
26
+ type: "object",
27
+ additionalProperties: true
28
+ }
29
+ },
30
+ required: ["jsonrpc"]
31
+ };
32
+ const jsonRpcBatch = { oneOf: [jsonRpc, {
33
+ type: "array",
34
+ items: jsonRpc
35
+ }] };
36
+ const jsonRpcError = {
37
+ type: "object",
38
+ properties: {
39
+ jsonrpc: {
40
+ type: "string",
41
+ enum: ["2.0"]
42
+ },
43
+ error: {
44
+ type: "object",
45
+ properties: {
46
+ code: { type: "integer" },
47
+ message: { type: "string" },
48
+ data: {}
49
+ },
50
+ required: ["code", "message"]
51
+ },
52
+ id: jsonRpcId
53
+ },
54
+ required: [
55
+ "jsonrpc",
56
+ "error",
57
+ "id"
58
+ ]
59
+ };
60
+ const mcp = {
61
+ slug: "@payloadcms/plugin-mcp",
62
+ tag: TAG,
63
+ build: ({ config, ctx, t }) => {
64
+ const rpcError = (description) => jsonResponse(description, jsonRpcError);
65
+ const post = {
66
+ tags: [TAG],
67
+ operationId: "mcp",
68
+ summary: t("mcp"),
69
+ description: t("mcpDesc"),
70
+ parameters: [{
71
+ name: "overrideAccess",
72
+ in: "query",
73
+ description: t("mcpOverrideAccess"),
74
+ schema: {
75
+ type: "string",
76
+ enum: ["true", "false"]
77
+ }
78
+ }, {
79
+ name: "MCP-Protocol-Version",
80
+ in: "header",
81
+ description: t("mcpProtocolVersion"),
82
+ schema: { type: "string" }
83
+ }],
84
+ requestBody: jsonBody(jsonRpcBatch),
85
+ responses: {
86
+ "200": jsonResponse(t("mcpResult"), jsonRpcBatch),
87
+ "202": { description: t("mcpResult202") },
88
+ "400": jsonResponse(t("errorPlugin400"), { oneOf: [jsonRpcError, { $ref: refTo(ERROR_SCHEMA_NAME) }] }),
89
+ ...errorResponses(["401"], t),
90
+ "404": rpcError(t("errorPluginMcp404")),
91
+ "406": rpcError(t("errorPluginMcp406")),
92
+ "413": rpcError(t("errorPluginMcp413")),
93
+ "415": rpcError(t("errorPluginMcp415")),
94
+ "500": rpcError(t("errorPlugin500"))
95
+ }
96
+ };
97
+ const get = {
98
+ tags: [TAG],
99
+ operationId: "mcpStream",
100
+ summary: t("mcpGet"),
101
+ responses: { "405": {
102
+ description: t("errorPluginMcpGet405"),
103
+ headers: { Allow: { schema: {
104
+ type: "string",
105
+ enum: ["POST"]
106
+ } } }
107
+ } }
108
+ };
109
+ return [{ paths: mountEndpoints(config.endpoints, ctx.apiRoute, ({ method, path }) => {
110
+ if (path !== "/mcp") return void 0;
111
+ if (method === "post") return post;
112
+ return method === "get" ? get : void 0;
113
+ }) }];
114
+ }
115
+ };
116
+ export { mcp };
117
+
118
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","names":[],"sources":["../../../../src/server/spec/plugins/mcp.ts"],"sourcesContent":["import type { OperationObject, SchemaObject } from '@scalar/openapi-types/3.2'\n\nimport { ERROR_SCHEMA_NAME, errorResponses, jsonBody, jsonResponse } from '@/server/spec/components.js'\nimport { refTo } from '@/server/spec/names.js'\n\nimport { type OfficialPlugin, mountEndpoints } from './shared.js'\n\nconst TAG = 'MCP'\n\nconst jsonRpcId: SchemaObject = { type: ['string', 'integer', 'null'] }\n\nconst jsonRpc: SchemaObject = {\n type: 'object',\n additionalProperties: true,\n properties: {\n jsonrpc: { type: 'string', enum: ['2.0'] },\n id: jsonRpcId,\n method: { type: 'string' },\n params: { type: 'object', additionalProperties: true },\n result: {},\n error: { type: 'object', additionalProperties: true },\n },\n required: ['jsonrpc'],\n}\n\nconst jsonRpcBatch: SchemaObject = { oneOf: [jsonRpc, { type: 'array', items: jsonRpc }] }\n\nconst jsonRpcError: SchemaObject = {\n type: 'object',\n properties: {\n jsonrpc: { type: 'string', enum: ['2.0'] },\n error: {\n type: 'object',\n properties: { code: { type: 'integer' }, message: { type: 'string' }, data: {} },\n required: ['code', 'message'],\n },\n id: jsonRpcId,\n },\n required: ['jsonrpc', 'error', 'id'],\n}\n\nexport const mcp: OfficialPlugin = {\n slug: '@payloadcms/plugin-mcp',\n tag: TAG,\n build: ({ config, ctx, t }) => {\n const rpcError = (description: string) => jsonResponse(description, jsonRpcError)\n const post: OperationObject = {\n tags: [TAG],\n operationId: 'mcp',\n summary: t('mcp'),\n description: t('mcpDesc'),\n parameters: [\n {\n name: 'overrideAccess',\n in: 'query',\n description: t('mcpOverrideAccess'),\n schema: { type: 'string', enum: ['true', 'false'] },\n },\n {\n name: 'MCP-Protocol-Version',\n in: 'header',\n description: t('mcpProtocolVersion'),\n schema: { type: 'string' },\n },\n ],\n requestBody: jsonBody(jsonRpcBatch),\n responses: {\n '200': jsonResponse(t('mcpResult'), jsonRpcBatch),\n '202': { description: t('mcpResult202') },\n '400': jsonResponse(t('errorPlugin400'), { oneOf: [jsonRpcError, { $ref: refTo(ERROR_SCHEMA_NAME) }] }),\n ...errorResponses(['401'], t),\n '404': rpcError(t('errorPluginMcp404')),\n '406': rpcError(t('errorPluginMcp406')),\n '413': rpcError(t('errorPluginMcp413')),\n '415': rpcError(t('errorPluginMcp415')),\n '500': rpcError(t('errorPlugin500')),\n },\n }\n const get: OperationObject = {\n tags: [TAG],\n operationId: 'mcpStream',\n summary: t('mcpGet'),\n responses: {\n '405': {\n description: t('errorPluginMcpGet405'),\n headers: { Allow: { schema: { type: 'string', enum: ['POST'] } } },\n },\n },\n }\n return [\n {\n paths: mountEndpoints(config.endpoints, ctx.apiRoute, ({ method, path }) => {\n if (path !== '/mcp') return undefined\n if (method === 'post') return post\n return method === 'get' ? get : undefined\n }),\n },\n ]\n },\n}\n"],"mappings":";;;AAOA,MAAM,MAAM;AAEZ,MAAM,YAA0B,EAAE,MAAM;CAAC;CAAU;CAAW;AAAM,EAAE;AAEtE,MAAM,UAAwB;CAC5B,MAAM;CACN,sBAAsB;CACtB,YAAY;EACV,SAAS;GAAE,MAAM;GAAU,MAAM,CAAC,KAAK;EAAE;EACzC,IAAI;EACJ,QAAQ,EAAE,MAAM,SAAS;EACzB,QAAQ;GAAE,MAAM;GAAU,sBAAsB;EAAK;EACrD,QAAQ,CAAC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,mBAAmB,CAAC;IACtC,OAAO,SAAS,EAAE,mBAAmB,CAAC;IACtC,OAAO,SAAS,EAAE,mBAAmB,CAAC;IACtC,OAAO,SAAS,EAAE,mBAAmB,CAAC;IACtC,OAAO,SAAS,EAAE,gBAAgB,CAAC;GACrC;EACF;EACA,MAAM,MAAuB;GAC3B,MAAM,CAAC,GAAG;GACV,aAAa;GACb,SAAS,EAAE,QAAQ;GACnB,WAAW,EACT,OAAO;IACL,aAAa,EAAE,sBAAsB;IACrC,SAAS,EAAE,OAAO,EAAE,QAAQ;KAAE,MAAM;KAAU,MAAM,CAAC,MAAM;IAAE,EAAE,EAAE;GACnE,EACF;EACF;EACA,OAAO,CACL,EACE,OAAO,eAAe,OAAO,WAAW,IAAI,WAAW,EAAE,QAAQ,WAAW;GAC1E,IAAI,SAAS,QAAQ,OAAO,KAAA;GAC5B,IAAI,WAAW,QAAQ,OAAO;GAC9B,OAAO,WAAW,QAAQ,MAAM,KAAA;EAClC,CAAC,EACH,CACF;CACF;AACF"}
@@ -0,0 +1,3 @@
1
+ import { OfficialPlugin } from "./shared.js";
2
+ export declare const multiTenant: OfficialPlugin;
3
+ //# sourceMappingURL=multiTenant.d.ts.map
@@ -0,0 +1,39 @@
1
+ import { schemaName } from "../names.js";
2
+ import { errorResponses, jsonResponse } from "../components.js";
3
+ import { securedRequirement } from "../security.js";
4
+ import { collectionGroups } from "./shared.js";
5
+ const TAG = "Multi-tenant";
6
+ const multiTenant = {
7
+ slug: "@payloadcms/plugin-multi-tenant",
8
+ tag: TAG,
9
+ build: ({ collections, ctx, options, t }) => {
10
+ const tenantsSlug = options?.tenantsSlug || "tenants";
11
+ return collectionGroups(collections.filter((c) => c.slug === tenantsSlug), ctx, ({ method, path }, collection) => method === "get" && path === "/populate-tenant-options" ? {
12
+ tags: [TAG],
13
+ operationId: `populate${schemaName(collection.slug)}Options`,
14
+ summary: t("tenantOptions"),
15
+ responses: {
16
+ "200": jsonResponse(t("tenantOptionsResult"), {
17
+ type: "object",
18
+ properties: { tenantOptions: {
19
+ type: "array",
20
+ items: {
21
+ type: "object",
22
+ properties: {
23
+ label: { type: "string" },
24
+ value: { oneOf: [{ type: "string" }, { type: "number" }] }
25
+ },
26
+ required: ["label", "value"]
27
+ }
28
+ } },
29
+ required: ["tenantOptions"]
30
+ }),
31
+ ...errorResponses(["401"], t)
32
+ },
33
+ security: securedRequirement()
34
+ } : void 0);
35
+ }
36
+ };
37
+ export { multiTenant };
38
+
39
+ //# sourceMappingURL=multiTenant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiTenant.js","names":[],"sources":["../../../../src/server/spec/plugins/multiTenant.ts"],"sourcesContent":["import { errorResponses, jsonResponse } from '@/server/spec/components.js'\nimport { schemaName } from '@/server/spec/names.js'\nimport { securedRequirement } from '@/server/spec/security.js'\n\nimport { type OfficialPlugin, collectionGroups } from './shared.js'\n\nconst TAG = 'Multi-tenant'\n\nexport const multiTenant: OfficialPlugin = {\n slug: '@payloadcms/plugin-multi-tenant',\n tag: TAG,\n build: ({ collections, ctx, options, t }) => {\n const tenantsSlug = (options?.tenantsSlug as string | undefined) || 'tenants'\n return collectionGroups(\n collections.filter((c) => c.slug === tenantsSlug),\n ctx,\n ({ method, path }, collection) =>\n method === 'get' && path === '/populate-tenant-options'\n ? {\n tags: [TAG],\n operationId: `populate${schemaName(collection.slug)}Options`,\n summary: t('tenantOptions'),\n responses: {\n '200': jsonResponse(t('tenantOptionsResult'), {\n type: 'object',\n properties: {\n tenantOptions: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n label: { type: 'string' },\n value: { oneOf: [{ type: 'string' }, { type: 'number' }] },\n },\n required: ['label', 'value'],\n },\n },\n },\n required: ['tenantOptions'],\n }),\n ...errorResponses(['401'], t),\n },\n security: securedRequirement(),\n }\n : undefined,\n )\n },\n}\n"],"mappings":";;;;AAMA,MAAM,MAAM;AAEZ,MAAa,cAA8B;CACzC,MAAM;CACN,KAAK;CACL,QAAQ,EAAE,aAAa,KAAK,SAAS,QAAQ;EAC3C,MAAM,cAAe,SAAS,eAAsC;EACpE,OAAO,iBACL,YAAY,QAAQ,MAAM,EAAE,SAAS,WAAW,GAChD,MACC,EAAE,QAAQ,QAAQ,eACjB,WAAW,SAAS,SAAS,6BACzB;GACE,MAAM,CAAC,GAAG;GACV,aAAa,WAAW,WAAW,WAAW,IAAI,EAAE;GACpD,SAAS,EAAE,eAAe;GAC1B,WAAW;IACT,OAAO,aAAa,EAAE,qBAAqB,GAAG;KAC5C,MAAM;KACN,YAAY,EACV,eAAe;MACb,MAAM;MACN,OAAO;OACL,MAAM;OACN,YAAY;QACV,OAAO,EAAE,MAAM,SAAS;QACxB,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,SAAS,GAAG,EAAE,MAAM,SAAS,CAAC,EAAE;OAC3D;OACA,UAAU,CAAC,SAAS,OAAO;MAC7B;KACF,EACF;KACA,UAAU,CAAC,eAAe;IAC5B,CAAC;IACD,GAAG,eAAe,CAAC,KAAK,GAAG,CAAC;GAC9B;GACA,UAAU,mBAAmB;EAC/B,IACA,KAAA,CACR;CACF;AACF"}
@@ -0,0 +1,3 @@
1
+ import { OfficialPlugin } from "./shared.js";
2
+ export declare const search: OfficialPlugin;
3
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1,43 @@
1
+ import { schemaName } from "../names.js";
2
+ import { jsonBody, jsonResponse } from "../components.js";
3
+ import { securedRequirement } from "../security.js";
4
+ import { collectionGroups, messageErrors, messageSchema } from "./shared.js";
5
+ const TAG = "Search";
6
+ const search = {
7
+ slug: "@payloadcms/plugin-search",
8
+ tag: TAG,
9
+ build: ({ collections, ctx, options, t }) => {
10
+ const searchSlug = (options?.searchOverrides)?.slug || "search";
11
+ const visible = new Set(collections.map((c) => c.slug));
12
+ const indexed = Array.isArray(options?.collections) ? options.collections.filter((slug) => visible.has(slug)) : [];
13
+ return collectionGroups(collections.filter((c) => c.slug === searchSlug), ctx, ({ method, path }, collection) => method === "post" && path === "/reindex" ? {
14
+ tags: [TAG],
15
+ operationId: `reindex${schemaName(collection.slug)}`,
16
+ summary: t("searchReindex"),
17
+ requestBody: jsonBody({
18
+ type: "object",
19
+ properties: { collections: {
20
+ type: "array",
21
+ minItems: 1,
22
+ items: {
23
+ type: "string",
24
+ ...indexed.length > 0 ? { enum: indexed } : {}
25
+ }
26
+ } },
27
+ required: ["collections"]
28
+ }),
29
+ responses: {
30
+ "200": jsonResponse(t("searchReindexResult"), messageSchema),
31
+ ...messageErrors([
32
+ "400",
33
+ "401",
34
+ "500"
35
+ ], t)
36
+ },
37
+ security: securedRequirement()
38
+ } : void 0);
39
+ }
40
+ };
41
+ export { search };
42
+
43
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.js","names":[],"sources":["../../../../src/server/spec/plugins/search.ts"],"sourcesContent":["import { jsonBody, jsonResponse } from '@/server/spec/components.js'\nimport { schemaName } from '@/server/spec/names.js'\nimport { securedRequirement } from '@/server/spec/security.js'\n\nimport { type OfficialPlugin, collectionGroups, messageErrors, messageSchema } from './shared.js'\n\nconst TAG = 'Search'\n\nexport const search: OfficialPlugin = {\n slug: '@payloadcms/plugin-search',\n tag: TAG,\n build: ({ collections, ctx, options, t }) => {\n const overrides = options?.searchOverrides as { slug?: string } | undefined\n const searchSlug = overrides?.slug || 'search'\n const visible = new Set(collections.map((c) => c.slug))\n const indexed = Array.isArray(options?.collections)\n ? (options.collections as string[]).filter((slug) => visible.has(slug))\n : []\n return collectionGroups(\n collections.filter((c) => c.slug === searchSlug),\n ctx,\n ({ method, path }, collection) =>\n method === 'post' && path === '/reindex'\n ? {\n tags: [TAG],\n operationId: `reindex${schemaName(collection.slug)}`,\n summary: t('searchReindex'),\n requestBody: jsonBody({\n type: 'object',\n properties: {\n collections: {\n type: 'array',\n minItems: 1,\n items: { type: 'string', ...(indexed.length > 0 ? { enum: indexed } : {}) },\n },\n },\n required: ['collections'],\n }),\n responses: {\n '200': jsonResponse(t('searchReindexResult'), messageSchema),\n ...messageErrors(['400', '401', '500'], t),\n },\n security: securedRequirement(),\n }\n : undefined,\n )\n },\n}\n"],"mappings":";;;;AAMA,MAAM,MAAM;AAEZ,MAAa,SAAyB;CACpC,MAAM;CACN,KAAK;CACL,QAAQ,EAAE,aAAa,KAAK,SAAS,QAAQ;EAE3C,MAAM,cADY,SAAS,gBAAA,EACG,QAAQ;EACtC,MAAM,UAAU,IAAI,IAAI,YAAY,KAAK,MAAM,EAAE,IAAI,CAAC;EACtD,MAAM,UAAU,MAAM,QAAQ,SAAS,WAAW,IAC7C,QAAQ,YAAyB,QAAQ,SAAS,QAAQ,IAAI,IAAI,CAAC,IACpE,CAAC;EACL,OAAO,iBACL,YAAY,QAAQ,MAAM,EAAE,SAAS,UAAU,GAC/C,MACC,EAAE,QAAQ,QAAQ,eACjB,WAAW,UAAU,SAAS,aAC1B;GACE,MAAM,CAAC,GAAG;GACV,aAAa,UAAU,WAAW,WAAW,IAAI;GACjD,SAAS,EAAE,eAAe;GAC1B,aAAa,SAAS;IACpB,MAAM;IACN,YAAY,EACV,aAAa;KACX,MAAM;KACN,UAAU;KACV,OAAO;MAAE,MAAM;MAAU,GAAI,QAAQ,SAAS,IAAI,EAAE,MAAM,QAAQ,IAAI,CAAC;KAAG;IAC5E,EACF;IACA,UAAU,CAAC,aAAa;GAC1B,CAAC;GACD,WAAW;IACT,OAAO,aAAa,EAAE,qBAAqB,GAAG,aAAa;IAC3D,GAAG,cAAc;KAAC;KAAO;KAAO;IAAK,GAAG,CAAC;GAC3C;GACA,UAAU,mBAAmB;EAC/B,IACA,KAAA,CACR;CACF;AACF"}
@@ -0,0 +1,3 @@
1
+ import { OfficialPlugin } from "./shared.js";
2
+ export declare const seo: OfficialPlugin;
3
+ //# sourceMappingURL=seo.d.ts.map
@@ -0,0 +1,83 @@
1
+ import { errorResponses, jsonBody, jsonResponse } from "../components.js";
2
+ import { securedRequirement } from "../security.js";
3
+ import { idSchema, mountEndpoints } from "./shared.js";
4
+ const TAG = "SEO";
5
+ const GENERATORS = {
6
+ "/plugin-seo/generate-title": {
7
+ operationId: "seoGenerateTitle",
8
+ summary: "seoTitle"
9
+ },
10
+ "/plugin-seo/generate-description": {
11
+ operationId: "seoGenerateDescription",
12
+ summary: "seoDescription"
13
+ },
14
+ "/plugin-seo/generate-url": {
15
+ operationId: "seoGenerateUrl",
16
+ summary: "seoUrl"
17
+ },
18
+ "/plugin-seo/generate-image": {
19
+ operationId: "seoGenerateImage",
20
+ summary: "seoImage",
21
+ image: true
22
+ }
23
+ };
24
+ const seo = {
25
+ slug: "@payloadcms/plugin-seo",
26
+ tag: TAG,
27
+ build: ({ config, ctx, t }) => {
28
+ const id = idSchema(ctx);
29
+ const operation = (path) => {
30
+ const generator = GENERATORS[path];
31
+ if (!generator) return void 0;
32
+ const result = generator.image ? { oneOf: [
33
+ { type: "string" },
34
+ { type: "number" },
35
+ {
36
+ type: "object",
37
+ additionalProperties: true
38
+ }
39
+ ] } : { type: "string" };
40
+ return {
41
+ tags: [TAG],
42
+ operationId: generator.operationId,
43
+ summary: t(generator.summary),
44
+ requestBody: {
45
+ ...jsonBody({
46
+ type: "object",
47
+ additionalProperties: true,
48
+ properties: {
49
+ id: { oneOf: [{ type: "string" }, { type: "number" }] },
50
+ collectionSlug: { type: "string" },
51
+ globalSlug: { type: "string" },
52
+ doc: {
53
+ type: "object",
54
+ additionalProperties: true,
55
+ properties: { id }
56
+ },
57
+ locale: { type: "string" },
58
+ title: { type: "string" }
59
+ }
60
+ }),
61
+ description: t("seoBody")
62
+ },
63
+ responses: {
64
+ "200": jsonResponse(t("seoResult"), {
65
+ type: "object",
66
+ properties: { result },
67
+ required: ["result"]
68
+ }),
69
+ ...errorResponses([
70
+ "401",
71
+ "403",
72
+ "500"
73
+ ], t)
74
+ },
75
+ security: securedRequirement()
76
+ };
77
+ };
78
+ return [{ paths: mountEndpoints(config.endpoints, ctx.apiRoute, (endpoint) => endpoint.method === "post" ? operation(endpoint.path) : void 0) }];
79
+ }
80
+ };
81
+ export { seo };
82
+
83
+ //# sourceMappingURL=seo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seo.js","names":[],"sources":["../../../../src/server/spec/plugins/seo.ts"],"sourcesContent":["import type { OperationObject, SchemaObject } from '@scalar/openapi-types/3.2'\n\nimport { errorResponses, jsonBody, jsonResponse } from '@/server/spec/components.js'\nimport { securedRequirement } from '@/server/spec/security.js'\nimport type { MessageKey } from '@/shared/translations/types.js'\n\nimport { type OfficialPlugin, idSchema, mountEndpoints } from './shared.js'\n\nconst TAG = 'SEO'\n\nconst GENERATORS: Record<string, { operationId: string; summary: MessageKey; image?: boolean }> = {\n '/plugin-seo/generate-title': { operationId: 'seoGenerateTitle', summary: 'seoTitle' },\n '/plugin-seo/generate-description': { operationId: 'seoGenerateDescription', summary: 'seoDescription' },\n '/plugin-seo/generate-url': { operationId: 'seoGenerateUrl', summary: 'seoUrl' },\n '/plugin-seo/generate-image': { operationId: 'seoGenerateImage', summary: 'seoImage', image: true },\n}\n\nexport const seo: OfficialPlugin = {\n slug: '@payloadcms/plugin-seo',\n tag: TAG,\n build: ({ config, ctx, t }) => {\n const id = idSchema(ctx)\n const operation = (path: string): OperationObject | undefined => {\n const generator = GENERATORS[path]\n if (!generator) return undefined\n const result: SchemaObject = generator.image\n ? { oneOf: [{ type: 'string' }, { type: 'number' }, { type: 'object', additionalProperties: true }] }\n : { type: 'string' }\n return {\n tags: [TAG],\n operationId: generator.operationId,\n summary: t(generator.summary),\n requestBody: {\n ...jsonBody({\n type: 'object',\n additionalProperties: true,\n properties: {\n id: { oneOf: [{ type: 'string' }, { type: 'number' }] },\n collectionSlug: { type: 'string' },\n globalSlug: { type: 'string' },\n doc: { type: 'object', additionalProperties: true, properties: { id } },\n locale: { type: 'string' },\n title: { type: 'string' },\n },\n }),\n description: t('seoBody'),\n },\n responses: {\n '200': jsonResponse(t('seoResult'), {\n type: 'object',\n properties: { result },\n required: ['result'],\n }),\n ...errorResponses(['401', '403', '500'], t),\n },\n security: securedRequirement(),\n }\n }\n return [\n {\n paths: mountEndpoints(config.endpoints, ctx.apiRoute, (endpoint) =>\n endpoint.method === 'post' ? operation(endpoint.path) : undefined,\n ),\n },\n ]\n },\n}\n"],"mappings":";;;AAQA,MAAM,MAAM;AAEZ,MAAM,aAA4F;CAChG,8BAA8B;EAAE,aAAa;EAAoB,SAAS;CAAW;CACrF,oCAAoC;EAAE,aAAa;EAA0B,SAAS;CAAiB;CACvG,4BAA4B;EAAE,aAAa;EAAkB,SAAS;CAAS;CAC/E,8BAA8B;EAAE,aAAa;EAAoB,SAAS;EAAY,OAAO;CAAK;AACpG;AAEA,MAAa,MAAsB;CACjC,MAAM;CACN,KAAK;CACL,QAAQ,EAAE,QAAQ,KAAK,QAAQ;EAC7B,MAAM,KAAK,SAAS,GAAG;EACvB,MAAM,aAAa,SAA8C;GAC/D,MAAM,YAAY,WAAW;GAC7B,IAAI,CAAC,WAAW,OAAO,KAAA;GACvB,MAAM,SAAuB,UAAU,QACnC,EAAE,OAAO;IAAC,EAAE,MAAM,SAAS;IAAG,EAAE,MAAM,SAAS;IAAG;KAAE,MAAM;KAAU,sBAAsB;IAAK;GAAC,EAAE,IAClG,EAAE,MAAM,SAAS;GACrB,OAAO;IACL,MAAM,CAAC,GAAG;IACV,aAAa,UAAU;IACvB,SAAS,EAAE,UAAU,OAAO;IAC5B,aAAa;KACX,GAAG,SAAS;MACV,MAAM;MACN,sBAAsB;MACtB,YAAY;OACV,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,SAAS,GAAG,EAAE,MAAM,SAAS,CAAC,EAAE;OACtD,gBAAgB,EAAE,MAAM,SAAS;OACjC,YAAY,EAAE,MAAM,SAAS;OAC7B,KAAK;QAAE,MAAM;QAAU,sBAAsB;QAAM,YAAY,EAAE,GAAG;OAAE;OACtE,QAAQ,EAAE,MAAM,SAAS;OACzB,OAAO,EAAE,MAAM,SAAS;MAC1B;KACF,CAAC;KACD,aAAa,EAAE,SAAS;IAC1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