@payloadcms/figma 0.0.1-alpha.4 → 0.0.1-alpha.40

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 (269) hide show
  1. package/dist/api/control-plane.d.ts +22 -1
  2. package/dist/api/control-plane.d.ts.map +1 -1
  3. package/dist/api/control-plane.js +55 -22
  4. package/dist/api/control-plane.js.map +1 -1
  5. package/dist/api/figma-api.d.ts.map +1 -1
  6. package/dist/api/figma-api.js +45 -26
  7. package/dist/api/figma-api.js.map +1 -1
  8. package/dist/auth/callback-server.d.ts.map +1 -1
  9. package/dist/auth/callback-server.js +2 -1
  10. package/dist/auth/callback-server.js.map +1 -1
  11. package/dist/auth/crypto-utils.d.ts.map +1 -1
  12. package/dist/auth/crypto-utils.js +5 -5
  13. package/dist/auth/crypto-utils.js.map +1 -1
  14. package/dist/auth/jwt-validator.d.ts +2 -1
  15. package/dist/auth/jwt-validator.d.ts.map +1 -1
  16. package/dist/auth/jwt-validator.js +2 -2
  17. package/dist/auth/jwt-validator.js.map +1 -1
  18. package/dist/auth/oauth-flow.d.ts +1 -1
  19. package/dist/auth/oauth-flow.d.ts.map +1 -1
  20. package/dist/auth/oauth-flow.js +9 -8
  21. package/dist/auth/oauth-flow.js.map +1 -1
  22. package/dist/auth/project-token.d.ts.map +1 -1
  23. package/dist/auth/project-token.js +9 -4
  24. package/dist/auth/project-token.js.map +1 -1
  25. package/dist/auth/refresh.d.ts.map +1 -1
  26. package/dist/auth/refresh.js +14 -9
  27. package/dist/auth/refresh.js.map +1 -1
  28. package/dist/auth/token-store.d.ts +10 -0
  29. package/dist/auth/token-store.d.ts.map +1 -1
  30. package/dist/auth/token-store.js +20 -0
  31. package/dist/auth/token-store.js.map +1 -1
  32. package/dist/cli.d.ts.map +1 -1
  33. package/dist/cli.js +31 -0
  34. package/dist/cli.js.map +1 -1
  35. package/dist/commands/build-lambda-zip.d.ts +5 -0
  36. package/dist/commands/build-lambda-zip.d.ts.map +1 -0
  37. package/dist/commands/build-lambda-zip.js +19 -0
  38. package/dist/commands/build-lambda-zip.js.map +1 -0
  39. package/dist/commands/deploy.d.ts +4 -0
  40. package/dist/commands/deploy.d.ts.map +1 -1
  41. package/dist/commands/deploy.js +71 -129
  42. package/dist/commands/deploy.js.map +1 -1
  43. package/dist/commands/init.d.ts +1 -5
  44. package/dist/commands/init.d.ts.map +1 -1
  45. package/dist/commands/init.js +94 -85
  46. package/dist/commands/init.js.map +1 -1
  47. package/dist/commands/list-tokens.d.ts.map +1 -1
  48. package/dist/commands/list-tokens.js +6 -3
  49. package/dist/commands/list-tokens.js.map +1 -1
  50. package/dist/commands/login.d.ts +8 -1
  51. package/dist/commands/login.d.ts.map +1 -1
  52. package/dist/commands/login.js +21 -11
  53. package/dist/commands/login.js.map +1 -1
  54. package/dist/commands/logout.js +2 -2
  55. package/dist/commands/logout.js.map +1 -1
  56. package/dist/config/oauth.d.ts +4 -14
  57. package/dist/config/oauth.d.ts.map +1 -1
  58. package/dist/config/oauth.js +19 -40
  59. package/dist/config/oauth.js.map +1 -1
  60. package/dist/constants.d.ts +26 -18
  61. package/dist/constants.d.ts.map +1 -1
  62. package/dist/constants.js +34 -20
  63. package/dist/constants.js.map +1 -1
  64. package/dist/db-content-api/README.md +98 -0
  65. package/dist/db-content-api/generated/content-api-types.d.ts +3848 -0
  66. package/dist/db-content-api/generated/content-api-types.d.ts.map +1 -0
  67. package/dist/db-content-api/generated/content-api-types.js +7 -0
  68. package/dist/db-content-api/generated/content-api-types.js.map +1 -0
  69. package/dist/db-content-api/index.d.ts +18 -0
  70. package/dist/db-content-api/index.d.ts.map +1 -0
  71. package/dist/db-content-api/index.js +571 -0
  72. package/dist/db-content-api/index.js.map +1 -0
  73. package/dist/db-content-api/temp-utilities/pagination.d.ts +13 -0
  74. package/dist/db-content-api/temp-utilities/pagination.d.ts.map +1 -0
  75. package/dist/db-content-api/temp-utilities/pagination.js +45 -0
  76. package/dist/db-content-api/temp-utilities/pagination.js.map +1 -0
  77. package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
  78. package/dist/db-content-api/temp-utilities/slug.d.ts.map +1 -0
  79. package/dist/db-content-api/temp-utilities/slug.js +3 -0
  80. package/dist/db-content-api/temp-utilities/slug.js.map +1 -0
  81. package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
  82. package/dist/db-content-api/temp-utilities/sorting.d.ts.map +1 -0
  83. package/dist/db-content-api/temp-utilities/sorting.js +32 -0
  84. package/dist/db-content-api/temp-utilities/sorting.js.map +1 -0
  85. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +4 -0
  86. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts.map +1 -0
  87. package/dist/db-content-api/temp-utilities/unwrapDocument.js +53 -0
  88. package/dist/db-content-api/temp-utilities/unwrapDocument.js.map +1 -0
  89. package/dist/db-content-api/utilities/auth.d.ts +30 -0
  90. package/dist/db-content-api/utilities/auth.d.ts.map +1 -0
  91. package/dist/db-content-api/utilities/auth.js +81 -0
  92. package/dist/db-content-api/utilities/auth.js.map +1 -0
  93. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
  94. package/dist/db-content-api/utilities/data/applyDefaults.d.ts.map +1 -0
  95. package/dist/db-content-api/utilities/data/applyDefaults.js +59 -0
  96. package/dist/db-content-api/utilities/data/applyDefaults.js.map +1 -0
  97. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
  98. package/dist/db-content-api/utilities/data/castFieldValue.d.ts.map +1 -0
  99. package/dist/db-content-api/utilities/data/castFieldValue.js +66 -0
  100. package/dist/db-content-api/utilities/data/castFieldValue.js.map +1 -0
  101. package/dist/db-content-api/utilities/data/index.d.ts +30 -0
  102. package/dist/db-content-api/utilities/data/index.d.ts.map +1 -0
  103. package/dist/db-content-api/utilities/data/index.js +173 -0
  104. package/dist/db-content-api/utilities/data/index.js.map +1 -0
  105. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
  106. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts.map +1 -0
  107. package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
  108. package/dist/db-content-api/utilities/data/removeVirtualFields.js.map +1 -0
  109. package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
  110. package/dist/db-content-api/utilities/data/stripFields.d.ts.map +1 -0
  111. package/dist/db-content-api/utilities/data/stripFields.js +195 -0
  112. package/dist/db-content-api/utilities/data/stripFields.js.map +1 -0
  113. package/dist/db-content-api/utilities/joins.d.ts +55 -0
  114. package/dist/db-content-api/utilities/joins.d.ts.map +1 -0
  115. package/dist/db-content-api/utilities/joins.js +136 -0
  116. package/dist/db-content-api/utilities/joins.js.map +1 -0
  117. package/dist/db-content-api/utilities/where.d.ts +12 -0
  118. package/dist/db-content-api/utilities/where.d.ts.map +1 -0
  119. package/dist/db-content-api/utilities/where.js +107 -0
  120. package/dist/db-content-api/utilities/where.js.map +1 -0
  121. package/dist/endpoints/health.d.ts +3 -0
  122. package/dist/endpoints/health.d.ts.map +1 -0
  123. package/dist/endpoints/health.js +11 -0
  124. package/dist/endpoints/health.js.map +1 -0
  125. package/dist/exports/client.d.ts +4 -0
  126. package/dist/exports/client.d.ts.map +1 -0
  127. package/dist/exports/client.js +5 -0
  128. package/dist/exports/client.js.map +1 -0
  129. package/dist/index.d.ts +2 -1
  130. package/dist/index.d.ts.map +1 -1
  131. package/dist/index.js +3 -1
  132. package/dist/index.js.map +1 -1
  133. package/dist/oauth/components/LoginButton/index.d.ts.map +1 -1
  134. package/dist/oauth/components/LoginButton/index.js +50 -6
  135. package/dist/oauth/components/LoginButton/index.js.map +1 -1
  136. package/dist/oauth/components/LoginButton/index.scss +50 -3
  137. package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -1
  138. package/dist/oauth/components/LogoutButton/index.js +0 -1
  139. package/dist/oauth/components/LogoutButton/index.js.map +1 -1
  140. package/dist/oauth/defaults.d.ts.map +1 -1
  141. package/dist/oauth/defaults.js +29 -5
  142. package/dist/oauth/defaults.js.map +1 -1
  143. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
  144. package/dist/oauth/endpoints/getLoginEndpoint.js +4 -4
  145. package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
  146. package/dist/oauth/index.d.ts.map +1 -1
  147. package/dist/oauth/index.js +42 -7
  148. package/dist/oauth/index.js.map +1 -1
  149. package/dist/oauth/strategy/index.d.ts +0 -2
  150. package/dist/oauth/strategy/index.d.ts.map +1 -1
  151. package/dist/oauth/strategy/index.js +38 -15
  152. package/dist/oauth/strategy/index.js.map +1 -1
  153. package/dist/oauth/types.d.ts +6 -6
  154. package/dist/oauth/types.d.ts.map +1 -1
  155. package/dist/oauth/types.js.map +1 -1
  156. package/dist/oauth/utilities/createCookieOptions.d.ts.map +1 -1
  157. package/dist/oauth/utilities/createCookieOptions.js.map +1 -1
  158. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
  159. package/dist/oauth/utilities/isDuplicateKeyError.d.ts.map +1 -0
  160. package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
  161. package/dist/oauth/utilities/isDuplicateKeyError.js.map +1 -0
  162. package/dist/oauth/utilities/refreshTokens.d.ts.map +1 -1
  163. package/dist/oauth/utilities/refreshTokens.js +1 -1
  164. package/dist/oauth/utilities/refreshTokens.js.map +1 -1
  165. package/dist/plugin/build-config.d.ts +21 -4
  166. package/dist/plugin/build-config.d.ts.map +1 -1
  167. package/dist/plugin/build-config.js +114 -8
  168. package/dist/plugin/build-config.js.map +1 -1
  169. package/dist/storage-content-api/api-types.d.ts +161 -0
  170. package/dist/storage-content-api/api-types.d.ts.map +1 -0
  171. package/dist/storage-content-api/api-types.js +6 -0
  172. package/dist/storage-content-api/api-types.js.map +1 -0
  173. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
  174. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts.map +1 -0
  175. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +42 -0
  176. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js.map +1 -0
  177. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
  178. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts.map +1 -0
  179. package/dist/storage-content-api/client-uploads/generateSignedURL.js +31 -0
  180. package/dist/storage-content-api/client-uploads/generateSignedURL.js.map +1 -0
  181. package/dist/storage-content-api/client.d.ts +6 -0
  182. package/dist/storage-content-api/client.d.ts.map +1 -0
  183. package/dist/storage-content-api/client.js +36 -0
  184. package/dist/storage-content-api/client.js.map +1 -0
  185. package/dist/storage-content-api/generateURL.d.ts +7 -0
  186. package/dist/storage-content-api/generateURL.d.ts.map +1 -0
  187. package/dist/storage-content-api/generateURL.js +7 -0
  188. package/dist/storage-content-api/generateURL.js.map +1 -0
  189. package/dist/storage-content-api/handleDelete.d.ts +8 -0
  190. package/dist/storage-content-api/handleDelete.d.ts.map +1 -0
  191. package/dist/storage-content-api/handleDelete.js +15 -0
  192. package/dist/storage-content-api/handleDelete.js.map +1 -0
  193. package/dist/storage-content-api/handleUpload.d.ts +11 -0
  194. package/dist/storage-content-api/handleUpload.d.ts.map +1 -0
  195. package/dist/storage-content-api/handleUpload.js +136 -0
  196. package/dist/storage-content-api/handleUpload.js.map +1 -0
  197. package/dist/storage-content-api/index.d.ts +5 -0
  198. package/dist/storage-content-api/index.d.ts.map +1 -0
  199. package/dist/storage-content-api/index.js +31 -0
  200. package/dist/storage-content-api/index.js.map +1 -0
  201. package/dist/storage-content-api/staticHandler.d.ts +10 -0
  202. package/dist/storage-content-api/staticHandler.d.ts.map +1 -0
  203. package/dist/storage-content-api/staticHandler.js +55 -0
  204. package/dist/storage-content-api/staticHandler.js.map +1 -0
  205. package/dist/storage-content-api/types.d.ts +10 -0
  206. package/dist/storage-content-api/types.d.ts.map +1 -0
  207. package/dist/storage-content-api/types.js +3 -0
  208. package/dist/storage-content-api/types.js.map +1 -0
  209. package/dist/templates/README.md +19 -0
  210. package/dist/types.d.ts +1 -0
  211. package/dist/types.d.ts.map +1 -1
  212. package/dist/types.js.map +1 -1
  213. package/dist/utils/asset-collection.d.ts +3 -6
  214. package/dist/utils/asset-collection.d.ts.map +1 -1
  215. package/dist/utils/asset-collection.js +10 -34
  216. package/dist/utils/asset-collection.js.map +1 -1
  217. package/dist/utils/build-lambda-zip.d.ts +14 -0
  218. package/dist/utils/build-lambda-zip.d.ts.map +1 -0
  219. package/dist/utils/build-lambda-zip.js +81 -0
  220. package/dist/utils/build-lambda-zip.js.map +1 -0
  221. package/dist/utils/config.js +1 -1
  222. package/dist/utils/config.js.map +1 -1
  223. package/dist/utils/env-management.d.ts +9 -8
  224. package/dist/utils/env-management.d.ts.map +1 -1
  225. package/dist/utils/env-management.js +73 -74
  226. package/dist/utils/env-management.js.map +1 -1
  227. package/dist/utils/formatter.d.ts.map +1 -1
  228. package/dist/utils/formatter.js +3 -5
  229. package/dist/utils/formatter.js.map +1 -1
  230. package/dist/utils/lambda-config.d.ts +3 -1
  231. package/dist/utils/lambda-config.d.ts.map +1 -1
  232. package/dist/utils/lambda-config.js +13 -21
  233. package/dist/utils/lambda-config.js.map +1 -1
  234. package/dist/utils/messages.d.ts.map +1 -1
  235. package/dist/utils/messages.js +8 -7
  236. package/dist/utils/messages.js.map +1 -1
  237. package/dist/utils/payload-config-ast.d.ts +22 -3
  238. package/dist/utils/payload-config-ast.d.ts.map +1 -1
  239. package/dist/utils/payload-config-ast.js +89 -31
  240. package/dist/utils/payload-config-ast.js.map +1 -1
  241. package/dist/utils/payload-config-finder.d.ts +2 -2
  242. package/dist/utils/payload-config-finder.d.ts.map +1 -1
  243. package/dist/utils/payload-config-finder.js +48 -9
  244. package/dist/utils/payload-config-finder.js.map +1 -1
  245. package/dist/utils/payload-config-modifier.d.ts.map +1 -1
  246. package/dist/utils/payload-config-modifier.js +54 -6
  247. package/dist/utils/payload-config-modifier.js.map +1 -1
  248. package/dist/utils/payload-package-check.d.ts +12 -1
  249. package/dist/utils/payload-package-check.d.ts.map +1 -1
  250. package/dist/utils/payload-package-check.js +63 -5
  251. package/dist/utils/payload-package-check.js.map +1 -1
  252. package/dist/utils/project.d.ts.map +1 -1
  253. package/dist/utils/project.js +8 -5
  254. package/dist/utils/project.js.map +1 -1
  255. package/dist/utils/s3-upload.d.ts +0 -1
  256. package/dist/utils/s3-upload.d.ts.map +1 -1
  257. package/dist/utils/s3-upload.js +10 -3
  258. package/dist/utils/s3-upload.js.map +1 -1
  259. package/dist/utils/token-display.d.ts.map +1 -1
  260. package/dist/utils/token-display.js +11 -5
  261. package/dist/utils/token-display.js.map +1 -1
  262. package/dist/utils/typescript-validator.d.ts.map +1 -1
  263. package/dist/utils/typescript-validator.js +4 -6
  264. package/dist/utils/typescript-validator.js.map +1 -1
  265. package/dist/utils/version-check.d.ts +3 -0
  266. package/dist/utils/version-check.d.ts.map +1 -0
  267. package/dist/utils/version-check.js +38 -0
  268. package/dist/utils/version-check.js.map +1 -0
  269. package/package.json +31 -7
@@ -0,0 +1,136 @@
1
+ import { addFallbackSort } from '../temp-utilities/sorting.js';
2
+ import { convertPayloadWhereToContentAPI } from './where.js';
3
+ /**
4
+ * Convert Payload's JoinQuery to Content API's join format.
5
+ *
6
+ * ## Content API Join Limitations
7
+ *
8
+ * The following Payload join features are NOT YET supported by Content API:
9
+ *
10
+ * 1. **hasMany relationships** - Content API's join uses `data#>'{path}'#>>'{}'` to extract
11
+ * a single ID. HasMany relationships store arrays `["id1", "id2"]` which can't match.
12
+ *
13
+ * 2. **Array field relationships** - `on: 'array.category'` expects iteration over array
14
+ * elements, but Content API treats the path as a single JSONB extraction.
15
+ *
16
+ * 3. **Polymorphic relationships** - Stored as `{ relationTo, value }` objects, but
17
+ * Content API expects a simple ID string.
18
+ *
19
+ * 4. **Localized relationship fields** - Locale-aware joins not implemented.
20
+ *
21
+ * Note: "Where querying through joins" (e.g., `where: { 'relatedPosts.title': { equals: 'x' } }`)
22
+ * is a separate Payload feature that filters documents based on joined data. This is NOT
23
+ * a join feature but a where clause feature, and would need separate Content API support.
24
+ *
25
+ * Payload's JoinQuery format (at runtime):
26
+ * {
27
+ * 'group.relatedPosts': { // joinPath - where results go in the document
28
+ * sort: '-title',
29
+ * limit: 10,
30
+ * page: 2, // page-based pagination
31
+ * where: { ... }, // Payload where format
32
+ * count: true
33
+ * }
34
+ * }
35
+ *
36
+ * Content API's join format:
37
+ * [{
38
+ * collectionId: 'posts', // collection to join FROM
39
+ * on: 'group.category', // field in joined collection pointing to this doc
40
+ * path: 'group.relatedPosts', // where to put results
41
+ * count: false,
42
+ * where: { ... }, // Content API where format
43
+ * sort: '-title',
44
+ * limit: 10,
45
+ * offset: 10 // offset-based pagination
46
+ * }]
47
+ *
48
+ * The mapping requires the collection config to resolve:
49
+ * - Which collection each join field refers to
50
+ * - What the 'on' field is for each join
51
+ */ export function convertPayloadJoinsToContentAPI(payload, collectionSlug, joins) {
52
+ const collectionConfig = payload.config.collections.find((c)=>c.slug === collectionSlug);
53
+ if (!collectionConfig) {
54
+ return undefined;
55
+ }
56
+ // joins === false means explicitly disable all joins
57
+ // joins === undefined means use defaults (no custom query params)
58
+ if (joins === false || !joins) {
59
+ return undefined;
60
+ }
61
+ const result = [];
62
+ // Iterate through all join paths in the query
63
+ for (const [joinPath, joinQueryValue] of Object.entries(joins)){
64
+ // joinQuery === false means skip this specific join
65
+ if (joinQueryValue === false) {
66
+ continue;
67
+ }
68
+ // Normalize undefined/empty to empty object
69
+ const joinQuery = joinQueryValue ?? {};
70
+ // Find the SanitizedJoin config for this joinPath
71
+ // SanitizedJoins is indexed by the collection being joined FROM
72
+ let foundJoin;
73
+ // Search through all collections in the joins config
74
+ for (const [collectionSlug, sanitizedJoins] of Object.entries(collectionConfig.joins)){
75
+ for (const sanitizedJoin of sanitizedJoins){
76
+ if (sanitizedJoin.joinPath === joinPath) {
77
+ foundJoin = {
78
+ collectionSlug,
79
+ on: sanitizedJoin.field.on
80
+ };
81
+ break;
82
+ }
83
+ }
84
+ if (foundJoin) {
85
+ break;
86
+ }
87
+ }
88
+ // Also check polymorphic joins
89
+ if (!foundJoin) {
90
+ for (const sanitizedJoin of collectionConfig.polymorphicJoins){
91
+ if (sanitizedJoin.joinPath === joinPath) {
92
+ // For polymorphic joins, collection is an array - use first one
93
+ const collections = sanitizedJoin.field.collection;
94
+ foundJoin = {
95
+ collectionSlug: Array.isArray(collections) ? collections[0] : collections,
96
+ on: sanitizedJoin.field.on
97
+ };
98
+ break;
99
+ }
100
+ }
101
+ }
102
+ if (!foundJoin) {
103
+ payload.logger.warn(`Join path '${joinPath}' not found in collection config for '${collectionConfig.slug}'`);
104
+ continue;
105
+ }
106
+ // Convert pagination: Payload uses page, Content API JoinClause uses offset
107
+ let offset;
108
+ if (joinQuery.page && joinQuery.page > 1 && joinQuery.limit) {
109
+ offset = (joinQuery.page - 1) * joinQuery.limit;
110
+ }
111
+ // Add fallback sort for the joined collection
112
+ const sortWithFallback = addFallbackSort(joinQuery.sort, payload, foundJoin.collectionSlug);
113
+ const contentAPIJoin = {
114
+ collectionId: foundJoin.collectionSlug,
115
+ count: joinQuery.count ?? false,
116
+ on: foundJoin.on,
117
+ path: joinPath,
118
+ ...joinQuery.limit !== undefined && {
119
+ limit: joinQuery.limit
120
+ },
121
+ ...offset !== undefined && {
122
+ offset
123
+ },
124
+ ...sortWithFallback && {
125
+ sort: sortWithFallback
126
+ },
127
+ ...joinQuery.where && {
128
+ where: convertPayloadWhereToContentAPI(joinQuery.where)
129
+ }
130
+ };
131
+ result.push(contentAPIJoin);
132
+ }
133
+ return result.length > 0 ? result : undefined;
134
+ }
135
+
136
+ //# sourceMappingURL=joins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/db-content-api/utilities/joins.ts"],"sourcesContent":["import type { JoinQuery, Payload } from 'payload'\n\nimport type { components } from '../generated/content-api-types.js'\n\nimport { addFallbackSort } from '../temp-utilities/sorting.js'\nimport { convertPayloadWhereToContentAPI } from './where.js'\n\n// JoinClause is an array type, so we extract the element type\ntype ContentAPIJoin = components['schemas']['JoinClause'][number]\n\n/**\n * Convert Payload's JoinQuery to Content API's join format.\n *\n * ## Content API Join Limitations\n *\n * The following Payload join features are NOT YET supported by Content API:\n *\n * 1. **hasMany relationships** - Content API's join uses `data#>'{path}'#>>'{}'` to extract\n * a single ID. HasMany relationships store arrays `[\"id1\", \"id2\"]` which can't match.\n *\n * 2. **Array field relationships** - `on: 'array.category'` expects iteration over array\n * elements, but Content API treats the path as a single JSONB extraction.\n *\n * 3. **Polymorphic relationships** - Stored as `{ relationTo, value }` objects, but\n * Content API expects a simple ID string.\n *\n * 4. **Localized relationship fields** - Locale-aware joins not implemented.\n *\n * Note: \"Where querying through joins\" (e.g., `where: { 'relatedPosts.title': { equals: 'x' } }`)\n * is a separate Payload feature that filters documents based on joined data. This is NOT\n * a join feature but a where clause feature, and would need separate Content API support.\n *\n * Payload's JoinQuery format (at runtime):\n * {\n * 'group.relatedPosts': { // joinPath - where results go in the document\n * sort: '-title',\n * limit: 10,\n * page: 2, // page-based pagination\n * where: { ... }, // Payload where format\n * count: true\n * }\n * }\n *\n * Content API's join format:\n * [{\n * collectionId: 'posts', // collection to join FROM\n * on: 'group.category', // field in joined collection pointing to this doc\n * path: 'group.relatedPosts', // where to put results\n * count: false,\n * where: { ... }, // Content API where format\n * sort: '-title',\n * limit: 10,\n * offset: 10 // offset-based pagination\n * }]\n *\n * The mapping requires the collection config to resolve:\n * - Which collection each join field refers to\n * - What the 'on' field is for each join\n */\nexport function convertPayloadJoinsToContentAPI(\n payload: Payload,\n collectionSlug: string,\n joins: false | JoinQuery | undefined,\n): ContentAPIJoin[] | undefined {\n const collectionConfig = payload.config.collections.find((c) => c.slug === collectionSlug)\n if (!collectionConfig) {\n return undefined\n }\n // joins === false means explicitly disable all joins\n // joins === undefined means use defaults (no custom query params)\n if (joins === false || !joins) {\n return undefined\n }\n\n const result: ContentAPIJoin[] = []\n\n // Iterate through all join paths in the query\n for (const [joinPath, joinQueryValue] of Object.entries(joins)) {\n // joinQuery === false means skip this specific join\n if (joinQueryValue === false) {\n continue\n }\n\n // Normalize undefined/empty to empty object\n const joinQuery = joinQueryValue ?? {}\n\n // Find the SanitizedJoin config for this joinPath\n // SanitizedJoins is indexed by the collection being joined FROM\n let foundJoin: { collectionSlug: string; on: string } | undefined\n\n // Search through all collections in the joins config\n for (const [collectionSlug, sanitizedJoins] of Object.entries(collectionConfig.joins)) {\n for (const sanitizedJoin of sanitizedJoins) {\n if (sanitizedJoin.joinPath === joinPath) {\n foundJoin = {\n collectionSlug,\n on: sanitizedJoin.field.on,\n }\n break\n }\n }\n if (foundJoin) {\n break\n }\n }\n\n // Also check polymorphic joins\n if (!foundJoin) {\n for (const sanitizedJoin of collectionConfig.polymorphicJoins) {\n if (sanitizedJoin.joinPath === joinPath) {\n // For polymorphic joins, collection is an array - use first one\n const collections = sanitizedJoin.field.collection\n foundJoin = {\n collectionSlug: Array.isArray(collections) ? collections[0] : collections,\n on: sanitizedJoin.field.on,\n }\n break\n }\n }\n }\n\n if (!foundJoin) {\n payload.logger.warn(\n `Join path '${joinPath}' not found in collection config for '${collectionConfig.slug}'`,\n )\n continue\n }\n\n // Convert pagination: Payload uses page, Content API JoinClause uses offset\n let offset: number | undefined\n if (joinQuery.page && joinQuery.page > 1 && joinQuery.limit) {\n offset = (joinQuery.page - 1) * joinQuery.limit\n }\n\n // Add fallback sort for the joined collection\n const sortWithFallback = addFallbackSort(joinQuery.sort, payload, foundJoin.collectionSlug)\n\n const contentAPIJoin: ContentAPIJoin = {\n collectionId: foundJoin.collectionSlug,\n count: joinQuery.count ?? false,\n on: foundJoin.on,\n path: joinPath,\n ...(joinQuery.limit !== undefined && { limit: joinQuery.limit }),\n ...(offset !== undefined && { offset }),\n ...(sortWithFallback && { sort: sortWithFallback }),\n ...(joinQuery.where && { where: convertPayloadWhereToContentAPI(joinQuery.where) }),\n }\n\n result.push(contentAPIJoin)\n }\n\n return result.length > 0 ? result : undefined\n}\n"],"names":["addFallbackSort","convertPayloadWhereToContentAPI","convertPayloadJoinsToContentAPI","payload","collectionSlug","joins","collectionConfig","config","collections","find","c","slug","undefined","result","joinPath","joinQueryValue","Object","entries","joinQuery","foundJoin","sanitizedJoins","sanitizedJoin","on","field","polymorphicJoins","collection","Array","isArray","logger","warn","offset","page","limit","sortWithFallback","sort","contentAPIJoin","collectionId","count","path","where","push","length"],"mappings":"AAIA,SAASA,eAAe,QAAQ,+BAA8B;AAC9D,SAASC,+BAA+B,QAAQ,aAAY;AAK5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDC,GACD,OAAO,SAASC,gCACdC,OAAgB,EAChBC,cAAsB,EACtBC,KAAoC;IAEpC,MAAMC,mBAAmBH,QAAQI,MAAM,CAACC,WAAW,CAACC,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKP;IAC3E,IAAI,CAACE,kBAAkB;QACrB,OAAOM;IACT;IACA,qDAAqD;IACrD,kEAAkE;IAClE,IAAIP,UAAU,SAAS,CAACA,OAAO;QAC7B,OAAOO;IACT;IAEA,MAAMC,SAA2B,EAAE;IAEnC,8CAA8C;IAC9C,KAAK,MAAM,CAACC,UAAUC,eAAe,IAAIC,OAAOC,OAAO,CAACZ,OAAQ;QAC9D,oDAAoD;QACpD,IAAIU,mBAAmB,OAAO;YAC5B;QACF;QAEA,4CAA4C;QAC5C,MAAMG,YAAYH,kBAAkB,CAAC;QAErC,kDAAkD;QAClD,gEAAgE;QAChE,IAAII;QAEJ,qDAAqD;QACrD,KAAK,MAAM,CAACf,gBAAgBgB,eAAe,IAAIJ,OAAOC,OAAO,CAACX,iBAAiBD,KAAK,EAAG;YACrF,KAAK,MAAMgB,iBAAiBD,eAAgB;gBAC1C,IAAIC,cAAcP,QAAQ,KAAKA,UAAU;oBACvCK,YAAY;wBACVf;wBACAkB,IAAID,cAAcE,KAAK,CAACD,EAAE;oBAC5B;oBACA;gBACF;YACF;YACA,IAAI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OAAO2B,IAAI,CAACL;IACd;IAEA,OAAOtB,OAAO4B,MAAM,GAAG,IAAI5B,SAASD;AACtC"}
@@ -0,0 +1,12 @@
1
+ import type { Where } from 'payload';
2
+ import type { components } from '../generated/content-api-types.js';
3
+ type WhereClause = components['schemas']['WhereClause'];
4
+ type ConvertOptions = {
5
+ /** Internal flag to track if we're inside a logical operator (and/or) */
6
+ insideLogicalOperator?: boolean;
7
+ /** If true, transform 'parent' field to 'documentId' (used for version queries) */
8
+ parentToDocumentId?: boolean;
9
+ };
10
+ export declare function convertPayloadWhereToContentAPI(where: undefined | Where, options?: ConvertOptions): WhereClause;
11
+ export {};
12
+ //# sourceMappingURL=where.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"where.d.ts","sourceRoot":"","sources":["../../../src/db-content-api/utilities/where.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,KAAK,WAAW,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAA;AASvD,KAAK,cAAc,GAAG;IACpB,yEAAyE;IACzE,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,mFAAmF;IACnF,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AAED,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,SAAS,GAAG,KAAK,EACxB,OAAO,GAAE,cAAmB,GAC3B,WAAW,CA4Gb"}
@@ -0,0 +1,107 @@
1
+ export function convertPayloadWhereToContentAPI(where, options = {}) {
2
+ // Empty where {} should be { and: [] } not undefined
3
+ // Content API requires a where clause structure even for "no filter"
4
+ if (!where || Object.keys(where).length === 0) {
5
+ return {
6
+ and: []
7
+ };
8
+ }
9
+ const conditions = [];
10
+ for (const [key, value] of Object.entries(where)){
11
+ if (key === 'and') {
12
+ // Recursively convert nested 'and' conditions, preserving options
13
+ const nestedConditions = value.map((item)=>convertPayloadWhereToContentAPI(item, {
14
+ ...options,
15
+ insideLogicalOperator: true
16
+ }))// TODO: A better solution would be to make the `where` schema of `zod` in `content-api`
17
+ // more permissive. For now I'll do it this way because I have an idea to simplify
18
+ // everything we're doing with `where` (Post EAP) anyway.
19
+ // Filter out empty conditions { and: [] } that would be invalid
20
+ .filter((condition)=>{
21
+ if ('and' in condition) {
22
+ return condition.and.length > 0;
23
+ }
24
+ if ('or' in condition) {
25
+ return condition.or.length > 0;
26
+ }
27
+ return true // Keep path/operator/value conditions
28
+ ;
29
+ });
30
+ // If filtering resulted in no conditions, return empty and
31
+ if (nestedConditions.length === 0) {
32
+ return {
33
+ and: []
34
+ };
35
+ }
36
+ return {
37
+ and: nestedConditions
38
+ };
39
+ } else if (key === 'or') {
40
+ // Recursively convert nested 'or' conditions, preserving options
41
+ const nestedConditions = value.map((item)=>convertPayloadWhereToContentAPI(item, {
42
+ ...options,
43
+ insideLogicalOperator: true
44
+ }))// Filter out empty conditions { and: [] } or { or: [] } that would be invalid
45
+ .filter((condition)=>{
46
+ if ('and' in condition) {
47
+ return condition.and.length > 0;
48
+ }
49
+ if ('or' in condition) {
50
+ return condition.or.length > 0;
51
+ }
52
+ return true // Keep path/operator/value conditions
53
+ ;
54
+ });
55
+ // If filtering resulted in no conditions, return empty and
56
+ if (nestedConditions.length === 0) {
57
+ return {
58
+ and: []
59
+ };
60
+ }
61
+ return {
62
+ or: nestedConditions
63
+ };
64
+ } else {
65
+ // TODO: fix this in content api
66
+ // WORKAROUND: Payload uses 'parent' for version queries, but Content API expects 'documentId'
67
+ let fieldPath = key;
68
+ if (options.parentToDocumentId && key === 'parent') {
69
+ fieldPath = 'documentId';
70
+ }
71
+ // Convert field conditions: { fieldName: { operator: value } }
72
+ // to: { path: fieldName, operator, value }
73
+ const operators = value;
74
+ // Skip empty operator objects { fieldName: {} }
75
+ if (Object.keys(operators).length === 0) {
76
+ continue;
77
+ }
78
+ for (const [op, operatorValue] of Object.entries(operators)){
79
+ // Skip operators with undefined values (e.g., { equals: undefined })
80
+ // This can happen when Payload sends incomplete where clauses
81
+ if (operatorValue === undefined) {
82
+ continue;
83
+ }
84
+ let finalValue = operatorValue;
85
+ // Add wildcards for contains/like operators (Payload doesn't add them)
86
+ if ((op === 'contains' || op === 'like') && typeof operatorValue === 'string') {
87
+ finalValue = `%${operatorValue}%`;
88
+ }
89
+ conditions.push({
90
+ operator: op,
91
+ path: fieldPath,
92
+ value: finalValue
93
+ });
94
+ }
95
+ }
96
+ }
97
+ // If inside a logical operator (and/or), return conditions directly
98
+ // Otherwise, wrap in 'and' to match WhereClause type
99
+ if (options.insideLogicalOperator && conditions.length === 1) {
100
+ return conditions[0];
101
+ }
102
+ return {
103
+ and: conditions
104
+ };
105
+ }
106
+
107
+ //# sourceMappingURL=where.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/db-content-api/utilities/where.ts"],"sourcesContent":["import type { Where } from 'payload'\n\nimport type { components } from '../generated/content-api-types.js'\n\ntype WhereClause = components['schemas']['WhereClause']\n\n// Payload's format: { fieldName: { operator: value }, and: [...], or: [...] }\n// Content API expects: { and: [{ path, operator, value }], or: [{ path, operator, value }] }\n//\n// The format stays different. This allows the Content API to evolve its filter schema,\n// for example to support composite types like Point, which are not lexicographically sortable.\n// Semantics must remain identical to Payload.\n\ntype ConvertOptions = {\n /** Internal flag to track if we're inside a logical operator (and/or) */\n insideLogicalOperator?: boolean\n /** If true, transform 'parent' field to 'documentId' (used for version queries) */\n parentToDocumentId?: boolean\n}\n\nexport function convertPayloadWhereToContentAPI(\n where: undefined | Where,\n options: ConvertOptions = {},\n): WhereClause {\n // Empty where {} should be { and: [] } not undefined\n // Content API requires a where clause structure even for \"no filter\"\n if (!where || Object.keys(where).length === 0) {\n return { and: [] }\n }\n\n // Extract the condition type (the variant with 'path', 'operator', 'value') from WhereClause union\n type WhereCondition = Extract<WhereClause, { path: string }>\n const conditions: WhereClause[] = []\n\n for (const [key, value] of Object.entries(where)) {\n if (key === 'and') {\n // Recursively convert nested 'and' conditions, preserving options\n const nestedConditions = (value as Where[])\n .map((item) =>\n convertPayloadWhereToContentAPI(item, { ...options, insideLogicalOperator: true }),\n )\n // TODO: A better solution would be to make the `where` schema of `zod` in `content-api`\n // more permissive. For now I'll do it this way because I have an idea to simplify\n // everything we're doing with `where` (Post EAP) anyway.\n // Filter out empty conditions { and: [] } that would be invalid\n .filter((condition) => {\n if ('and' in condition) {\n return condition.and.length > 0\n }\n if ('or' in condition) {\n return condition.or.length > 0\n }\n return true // Keep path/operator/value conditions\n })\n\n // If filtering resulted in no conditions, return empty and\n if (nestedConditions.length === 0) {\n return { and: [] }\n }\n\n return { and: nestedConditions }\n } else if (key === 'or') {\n // Recursively convert nested 'or' conditions, preserving options\n const nestedConditions = (value as Where[])\n .map((item) =>\n convertPayloadWhereToContentAPI(item, { ...options, insideLogicalOperator: true }),\n )\n // Filter out empty conditions { and: [] } or { or: [] } that would be invalid\n .filter((condition) => {\n if ('and' in condition) {\n return condition.and.length > 0\n }\n if ('or' in condition) {\n return condition.or.length > 0\n }\n return true // Keep path/operator/value conditions\n })\n\n // If filtering resulted in no conditions, return empty and\n if (nestedConditions.length === 0) {\n return { and: [] }\n }\n\n return { or: nestedConditions }\n } else {\n // TODO: fix this in content api\n // WORKAROUND: Payload uses 'parent' for version queries, but Content API expects 'documentId'\n let fieldPath = key\n if (options.parentToDocumentId && key === 'parent') {\n fieldPath = 'documentId'\n }\n\n // Convert field conditions: { fieldName: { operator: value } }\n // to: { path: fieldName, operator, value }\n const operators = value as Record<string, unknown>\n\n // Skip empty operator objects { fieldName: {} }\n if (Object.keys(operators).length === 0) {\n continue\n }\n\n for (const [op, operatorValue] of Object.entries(operators)) {\n // Skip operators with undefined values (e.g., { equals: undefined })\n // This can happen when Payload sends incomplete where clauses\n if (operatorValue === undefined) {\n continue\n }\n\n let finalValue = operatorValue\n\n // Add wildcards for contains/like operators (Payload doesn't add them)\n if ((op === 'contains' || op === 'like') && typeof operatorValue === 'string') {\n finalValue = `%${operatorValue}%`\n }\n\n conditions.push({\n operator: op as WhereCondition['operator'],\n path: fieldPath,\n value: finalValue,\n } as WhereCondition)\n }\n }\n }\n\n // If inside a logical operator (and/or), return conditions directly\n // Otherwise, wrap in 'and' to match WhereClause type\n if (options.insideLogicalOperator && conditions.length === 1) {\n return conditions[0]\n }\n\n return { and: conditions }\n}\n"],"names":["convertPayloadWhereToContentAPI","where","options","Object","keys","length","and","conditions","key","value","entries","nestedConditions","map","item","insideLogicalOperator","filter","condition","or","fieldPath","parentToDocumentId","operators","op","operatorValue","undefined","finalValue","push","operator","path"],"mappings":"AAoBA,OAAO,SAASA,gCACdC,KAAwB,EACxBC,UAA0B,CAAC,CAAC;IAE5B,qDAAqD;IACrD,qEAAqE;IACrE,IAAI,CAACD,SAASE,OAAOC,IAAI,CAACH,OAAOI,MAAM,KAAK,GAAG;QAC7C,OAAO;YAAEC,KAAK,EAAE;QAAC;IACnB;IAIA,MAAMC,aAA4B,EAAE;IAEpC,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIN,OAAOO,OAAO,CAACT,OAAQ;QAChD,IAAIO,QAAQ,OAAO;YACjB,kEAAkE;YAClE,MAAMG,mBAAmB,AAACF,MACvBG,GAAG,CAAC,CAACC,OACJb,gCAAgCa,MAAM;oBAAE,GAAGX,OAAO;oBAAEY,uBAAuB;gBAAK,GAElF,wFAAwF;YACxF,kFAAkF;YAClF,yDAAyD;YACzD,gEAAgE;aAC/DC,MAAM,CAAC,CAACC;gBACP,IAAI,SAASA,WAAW;oBACtB,OAAOA,UAAUV,GAAG,CAACD,MAAM,GAAG;gBAChC;gBACA,IAAI,QAAQW,WAAW;oBACrB,OAAOA,UAAUC,EAAE,CAACZ,MAAM,GAAG;gBAC/B;gBACA,OAAO,KAAK,sCAAsC;;YACpD;YAEF,2DAA2D;YAC3D,IAAIM,iBAAiBN,MAAM,KAAK,GAAG;gBACjC,OAAO;oBAAEC,K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;oBACVM,MAAMT;oBACNT,OAAOe;gBACT;YACF;QACF;IACF;IAEA,oEAAoE;IACpE,qDAAqD;IACrD,IAAItB,QAAQY,qBAAqB,IAAIP,WAAWF,MAAM,KAAK,GAAG;QAC5D,OAAOE,UAAU,CAAC,EAAE;IACtB;IAEA,OAAO;QAAED,KAAKC;IAAW;AAC3B"}
@@ -0,0 +1,3 @@
1
+ import type { Endpoint } from 'payload';
2
+ export declare const health: Endpoint;
3
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/endpoints/health.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,eAAO,MAAM,MAAM,EAAE,QAMpB,CAAA"}
@@ -0,0 +1,11 @@
1
+ export const health = {
2
+ handler: ()=>{
3
+ return Response.json({
4
+ status: 200
5
+ });
6
+ },
7
+ method: 'get',
8
+ path: '/health'
9
+ };
10
+
11
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/endpoints/health.ts"],"sourcesContent":["import type { Endpoint } from 'payload'\n\nexport const health: Endpoint = {\n handler: () => {\n return Response.json({ status: 200 })\n },\n method: 'get',\n path: '/health',\n}\n"],"names":["health","handler","Response","json","status","method","path"],"mappings":"AAEA,OAAO,MAAMA,SAAmB;IAC9BC,SAAS;QACP,OAAOC,SAASC,IAAI,CAAC;YAAEC,QAAQ;QAAI;IACrC;IACAC,QAAQ;IACRC,MAAM;AACR,EAAC"}
@@ -0,0 +1,4 @@
1
+ export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
2
+ export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
3
+ export { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js';
4
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAA;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8DAA8D,CAAA"}
@@ -0,0 +1,5 @@
1
+ export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
2
+ export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
3
+ export { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js';
4
+
5
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js'\nexport { LogoutButton } from '../oauth/components/LogoutButton/index.js'\nexport { ContentApiClientUploadHandler } from '../storage-content-api/client-uploads/ClientUploadHandler.js'\n"],"names":["DefaultLoginButton","LogoutButton","ContentApiClientUploadHandler"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,YAAY,QAAQ,4CAA2C;AACxE,SAASC,6BAA6B,QAAQ,+DAA8D"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ export { contentAPIAdapter } from './db-content-api/index.js';
1
2
  export { figmaContentSystem } from './plugin/adapter.js';
2
3
  export type { FigmaContentSystemOptions } from './plugin/adapter.js';
3
- export { buildConfig } from './plugin/build-config.js';
4
+ export { buildFigmaConfig } from './plugin/build-config.js';
4
5
  export type { FigmaConfig } from './plugin/build-config.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAGpE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAG7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAGpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA"}
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
+ // Export contentAPIAdapter for testing use cases
2
+ export { contentAPIAdapter } from './db-content-api/index.js';
1
3
  // Export database adapter for advanced use cases
2
4
  export { figmaContentSystem } from './plugin/adapter.js';
3
5
  // Export buildConfig wrapper and its config type
4
- export { buildConfig } from './plugin/build-config.js';
6
+ export { buildFigmaConfig } from './plugin/build-config.js';
5
7
 
6
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Export database adapter for advanced use cases\nexport { figmaContentSystem } from './plugin/adapter.js'\nexport type { FigmaContentSystemOptions } from './plugin/adapter.js'\n\n// Export buildConfig wrapper and its config type\nexport { buildConfig } from './plugin/build-config.js'\nexport type { FigmaConfig } from './plugin/build-config.js'\n"],"names":["figmaContentSystem","buildConfig"],"mappings":"AAAA,iDAAiD;AACjD,SAASA,kBAAkB,QAAQ,sBAAqB;AAGxD,iDAAiD;AACjD,SAASC,WAAW,QAAQ,2BAA0B"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Export contentAPIAdapter for testing use cases\nexport { contentAPIAdapter } from './db-content-api/index.js'\n\n// Export database adapter for advanced use cases\nexport { figmaContentSystem } from './plugin/adapter.js'\nexport type { FigmaContentSystemOptions } from './plugin/adapter.js'\n\n// Export buildConfig wrapper and its config type\nexport { buildFigmaConfig } from './plugin/build-config.js'\nexport type { FigmaConfig } from './plugin/build-config.js'\n"],"names":["contentAPIAdapter","figmaContentSystem","buildFigmaConfig"],"mappings":"AAAA,iDAAiD;AACjD,SAASA,iBAAiB,QAAQ,4BAA2B;AAE7D,iDAAiD;AACjD,SAASC,kBAAkB,QAAQ,sBAAqB;AAGxD,iDAAiD;AACjD,SAASC,gBAAgB,QAAQ,2BAA0B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,cAAc,CAAA;AAIrB,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAoDhE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,cAAc,CAAA;AAgDrB,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAqDhE,CAAA"}
@@ -1,10 +1,49 @@
1
1
  'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Button, useConfig } from '@payloadcms/ui';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useConfig } from '@payloadcms/ui';
4
4
  import { useSearchParams } from 'next/navigation.js';
5
5
  import React, { useEffect, useState } from 'react';
6
6
  import './index.scss';
7
7
  const baseClass = 'oauth-login';
8
+ // Figma logo SVG colored version
9
+ // const FigmaIcon: React.FC = () => (
10
+ // <svg fill="none" height="27" viewBox="0 0 400 600" width="18">
11
+ // <path
12
+ // d="M0 500C0 444.772 44.772 400 100 400H200V500C200 555.228 155.228 600 100 600C44.772 600 0 555.228 0 500Z"
13
+ // fill="#24CB71"
14
+ // />
15
+ // <path
16
+ // d="M200 0V200H300C355.228 200 400 155.228 400 100C400 44.772 355.228 0 300 0H200Z"
17
+ // fill="#FF7237"
18
+ // />
19
+ // <path
20
+ // d="M299.167 400C354.395 400 399.167 355.228 399.167 300C399.167 244.772 354.395 200 299.167 200C243.939 200 199.167 244.772 199.167 300C199.167 355.228 243.939 400 299.167 400Z"
21
+ // fill="#00B6FF"
22
+ // />
23
+ // <path
24
+ // d="M0 100C0 155.228 44.772 200 100 200H200V0H100C44.772 0 0 44.772 0 100Z"
25
+ // fill="#FF3737"
26
+ // />
27
+ // <path
28
+ // d="M0 300C0 355.228 44.772 400 100 400H200V200H100C44.772 200 0 244.772 0 300Z"
29
+ // fill="#874FFF"
30
+ // />
31
+ // </svg>
32
+ // )
33
+ // Figma logo SVG monochrome version
34
+ const FigmaIcon = ()=>/*#__PURE__*/ _jsx("svg", {
35
+ fill: "none",
36
+ height: "20px",
37
+ viewBox: "0 0 15 15",
38
+ width: "20px",
39
+ xmlns: "http://www.w3.org/2000/svg",
40
+ children: /*#__PURE__*/ _jsx("path", {
41
+ clipRule: "evenodd",
42
+ d: "M7.00005 2.04999H5.52505C4.71043 2.04999 4.05005 2.71037 4.05005 3.52499C4.05005 4.33961 4.71043 4.99999 5.52505 4.99999H7.00005V2.04999ZM7.00005 1.04999H8.00005H9.47505C10.842 1.04999 11.95 2.15808 11.95 3.52499C11.95 4.33163 11.5642 5.04815 10.9669 5.49999C11.5642 5.95184 11.95 6.66836 11.95 7.475C11.95 8.8419 10.842 9.95 9.47505 9.95C8.92236 9.95 8.41198 9.76884 8.00005 9.46266V9.95L8.00005 11.425C8.00005 12.7919 6.89195 13.9 5.52505 13.9C4.15814 13.9 3.05005 12.7919 3.05005 11.425C3.05005 10.6183 3.43593 9.90184 4.03317 9.44999C3.43593 8.99814 3.05005 8.28163 3.05005 7.475C3.05005 6.66836 3.43594 5.95184 4.03319 5.5C3.43594 5.04815 3.05005 4.33163 3.05005 3.52499C3.05005 2.15808 4.15814 1.04999 5.52505 1.04999H7.00005ZM8.00005 2.04999V4.99999H9.47505C10.2897 4.99999 10.95 4.33961 10.95 3.52499C10.95 2.71037 10.2897 2.04999 9.47505 2.04999H8.00005ZM5.52505 8.94998H7.00005L7.00005 7.4788L7.00005 7.475L7.00005 7.4712V6H5.52505C4.71043 6 4.05005 6.66038 4.05005 7.475C4.05005 8.28767 4.70727 8.94684 5.5192 8.94999L5.52505 8.94998ZM4.05005 11.425C4.05005 10.6123 4.70727 9.95315 5.5192 9.94999L5.52505 9.95H7.00005L7.00005 11.425C7.00005 12.2396 6.33967 12.9 5.52505 12.9C4.71043 12.9 4.05005 12.2396 4.05005 11.425ZM8.00005 7.47206C8.00164 6.65879 8.66141 6 9.47505 6C10.2897 6 10.95 6.66038 10.95 7.475C10.95 8.28962 10.2897 8.95 9.47505 8.95C8.66141 8.95 8.00164 8.29121 8.00005 7.47794V7.47206Z",
43
+ fill: "#FFFFFF",
44
+ fillRule: "evenodd"
45
+ })
46
+ });
8
47
  export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
9
48
  const { config: { admin: { user: userSlug }, routes: { api }, serverURL } } = useConfig();
10
49
  const [authorizeURL, setAuthorizeURL] = useState('');
@@ -40,11 +79,16 @@ export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
40
79
  }
41
80
  return /*#__PURE__*/ _jsx("div", {
42
81
  className: baseClass,
43
- children: /*#__PURE__*/ _jsx(Button, {
82
+ children: /*#__PURE__*/ _jsxs("a", {
44
83
  className: `${baseClass}__btn`,
45
- el: "anchor",
46
- url: authorizeURL,
47
- children: "Log in"
84
+ href: authorizeURL,
85
+ children: [
86
+ /*#__PURE__*/ _jsx(FigmaIcon, {}),
87
+ /*#__PURE__*/ _jsx("span", {
88
+ className: `${baseClass}__text`,
89
+ children: "Log in with Figma"
90
+ })
91
+ ]
48
92
  })
49
93
  });
50
94
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"sourcesContent":["'use client'\n\nimport { Button, useConfig } from '@payloadcms/ui'\nimport { useSearchParams } from 'next/navigation.js'\nimport React, { useEffect, useState } from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'oauth-login'\n\ntype DefaultLoginButtonProps = {\n disabled?: boolean\n endpointSlug: string\n}\n\nexport const DefaultLoginButton: React.FC<DefaultLoginButtonProps> = ({\n disabled,\n endpointSlug,\n}: {\n disabled?: boolean\n endpointSlug: string\n}) => {\n const {\n config: {\n admin: { user: userSlug },\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const [authorizeURL, setAuthorizeURL] = useState('')\n\n const searchParams = useSearchParams()\n const payloadRedirect = searchParams.get('redirect')\n\n useEffect(() => {\n if (payloadRedirect && !disabled) {\n // set cookie to redirect to the original page\n document.cookie = `payloadRedirect=${payloadRedirect}; path=/`\n }\n }, [payloadRedirect, disabled])\n\n useEffect(() => {\n const getAuthorizeURL = async () => {\n const serverURLFromWindow = window.location.origin\n const data = await fetch(\n `${serverURL}${api}/${userSlug}/${endpointSlug}/meta?serverURL=${serverURLFromWindow}`,\n ).then((res) => res.json())\n\n if (!disabled) {\n setAuthorizeURL(data.authorizeURL)\n }\n }\n\n void getAuthorizeURL()\n }, [api, serverURL, userSlug, disabled, endpointSlug])\n\n if (disabled) {\n return null\n }\n\n return (\n <div className={baseClass}>\n <Button className={`${baseClass}__btn`} el=\"anchor\" url={authorizeURL}>\n Log in\n </Button>\n </div>\n )\n}\n"],"names":["Button","useConfig","useSearchParams","React","useEffect","useState","baseClass","DefaultLoginButton","disabled","endpointSlug","config","admin","user","userSlug","routes","api","serverURL","authorizeURL","setAuthorizeURL","searchParams","payloadRedirect","get","document","cookie","getAuthorizeURL","serverURLFromWindow","window","location","origin","data","fetch","then","res","json","div","className","el","url"],"mappings":"AAAA;;AAEA,SAASA,MAAM,EAAEC,SAAS,QAAQ,iBAAgB;AAClD,SAASC,eAAe,QAAQ,qBAAoB;AACpD,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAElD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAOlB,OAAO,MAAMC,qBAAwD,CAAC,EACpEC,QAAQ,EACRC,YAAY,EAIb;IACC,MAAM,EACJC,QAAQ,EACNC,OAAO,EAAEC,MAAMC,QAAQ,EAAE,EACzBC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAGf;IACJ,MAAM,CAACgB,cAAcC,gBAAgB,GAAGb,SAAS;IAEjD,MAAMc,eAAejB;IACrB,MAAMkB,kBAAkBD,aAAaE,GAAG,CAAC;IAEzCjB,UAAU;QACR,IAAIgB,mBAAmB,CAACZ,UAAU;YAChC,8CAA8C;YAC9Cc,SAASC,MAAM,GAAG,CAAC,gBAAgB,EAAEH,gBAAgB,QAAQ,CAAC;QAChE;IACF,GAAG;QAACA;QAAiBZ;KAAS;IAE9BJ,UAAU;QACR,MAAMoB,kBAAkB;YACtB,MAAMC,sBAAsBC,OAAOC,QAAQ,CAACC,MAAM;YAClD,MAAMC,OAAO,MAAMC,MACjB,GAAGd,YAAYD,IAAI,CAAC,EAAEF,SAAS,CAAC,EAAEJ,aAAa,gBAAgB,EAAEgB,qBAAqB,EACtFM,IAAI,CAAC,CAACC,MAAQA,IAAIC,IAAI;YAExB,IAAI,CAACzB,UAAU;gBACbU,gBAAgBW,KAAKZ,YAAY;YACnC;QACF;QAEA,KAAKO;IACP,GAAG;QAACT;QAAKC;QAAWH;QAAUL;QAAUC;KAAa;IAErD,IAAID,UAAU;QACZ,OAAO;IACT;IAEA,qBACE,KAAC0B;QAAIC,WAAW7B;kBACd,cAAA,KAACN;YAAOmC,WAAW,GAAG7B,UAAU,KAAK,CAAC;YAAE8B,IAAG;YAASC,KAAKpB;sBAAc;;;AAK7E,EAAC"}
1
+ {"version":3,"sources":["../../../../src/oauth/components/LoginButton/index.tsx"],"sourcesContent":["'use client'\n\nimport { useConfig } from '@payloadcms/ui'\nimport { useSearchParams } from 'next/navigation.js'\nimport React, { useEffect, useState } from 'react'\n\nimport './index.scss'\n\nconst baseClass = 'oauth-login'\n\n// Figma logo SVG colored version\n// const FigmaIcon: React.FC = () => (\n// <svg fill=\"none\" height=\"27\" viewBox=\"0 0 400 600\" width=\"18\">\n// <path\n// d=\"M0 500C0 444.772 44.772 400 100 400H200V500C200 555.228 155.228 600 100 600C44.772 600 0 555.228 0 500Z\"\n// fill=\"#24CB71\"\n// />\n// <path\n// d=\"M200 0V200H300C355.228 200 400 155.228 400 100C400 44.772 355.228 0 300 0H200Z\"\n// fill=\"#FF7237\"\n// />\n// <path\n// d=\"M299.167 400C354.395 400 399.167 355.228 399.167 300C399.167 244.772 354.395 200 299.167 200C243.939 200 199.167 244.772 199.167 300C199.167 355.228 243.939 400 299.167 400Z\"\n// fill=\"#00B6FF\"\n// />\n// <path\n// d=\"M0 100C0 155.228 44.772 200 100 200H200V0H100C44.772 0 0 44.772 0 100Z\"\n// fill=\"#FF3737\"\n// />\n// <path\n// d=\"M0 300C0 355.228 44.772 400 100 400H200V200H100C44.772 200 0 244.772 0 300Z\"\n// fill=\"#874FFF\"\n// />\n// </svg>\n// )\n\n// Figma logo SVG monochrome version\nconst FigmaIcon: React.FC = () => (\n <svg\n fill=\"none\"\n height=\"20px\"\n viewBox=\"0 0 15 15\"\n width=\"20px\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n clipRule=\"evenodd\"\n d=\"M7.00005 2.04999H5.52505C4.71043 2.04999 4.05005 2.71037 4.05005 3.52499C4.05005 4.33961 4.71043 4.99999 5.52505 4.99999H7.00005V2.04999ZM7.00005 1.04999H8.00005H9.47505C10.842 1.04999 11.95 2.15808 11.95 3.52499C11.95 4.33163 11.5642 5.04815 10.9669 5.49999C11.5642 5.95184 11.95 6.66836 11.95 7.475C11.95 8.8419 10.842 9.95 9.47505 9.95C8.92236 9.95 8.41198 9.76884 8.00005 9.46266V9.95L8.00005 11.425C8.00005 12.7919 6.89195 13.9 5.52505 13.9C4.15814 13.9 3.05005 12.7919 3.05005 11.425C3.05005 10.6183 3.43593 9.90184 4.03317 9.44999C3.43593 8.99814 3.05005 8.28163 3.05005 7.475C3.05005 6.66836 3.43594 5.95184 4.03319 5.5C3.43594 5.04815 3.05005 4.33163 3.05005 3.52499C3.05005 2.15808 4.15814 1.04999 5.52505 1.04999H7.00005ZM8.00005 2.04999V4.99999H9.47505C10.2897 4.99999 10.95 4.33961 10.95 3.52499C10.95 2.71037 10.2897 2.04999 9.47505 2.04999H8.00005ZM5.52505 8.94998H7.00005L7.00005 7.4788L7.00005 7.475L7.00005 7.4712V6H5.52505C4.71043 6 4.05005 6.66038 4.05005 7.475C4.05005 8.28767 4.70727 8.94684 5.5192 8.94999L5.52505 8.94998ZM4.05005 11.425C4.05005 10.6123 4.70727 9.95315 5.5192 9.94999L5.52505 9.95H7.00005L7.00005 11.425C7.00005 12.2396 6.33967 12.9 5.52505 12.9C4.71043 12.9 4.05005 12.2396 4.05005 11.425ZM8.00005 7.47206C8.00164 6.65879 8.66141 6 9.47505 6C10.2897 6 10.95 6.66038 10.95 7.475C10.95 8.28962 10.2897 8.95 9.47505 8.95C8.66141 8.95 8.00164 8.29121 8.00005 7.47794V7.47206Z\"\n fill=\"#FFFFFF\"\n fillRule=\"evenodd\"\n />\n </svg>\n)\n\ntype DefaultLoginButtonProps = {\n disabled?: boolean\n endpointSlug: string\n}\n\nexport const DefaultLoginButton: React.FC<DefaultLoginButtonProps> = ({\n disabled,\n endpointSlug,\n}: {\n disabled?: boolean\n endpointSlug: string\n}) => {\n const {\n config: {\n admin: { user: userSlug },\n routes: { api },\n serverURL,\n },\n } = useConfig()\n const [authorizeURL, setAuthorizeURL] = useState('')\n\n const searchParams = useSearchParams()\n const payloadRedirect = searchParams.get('redirect')\n\n useEffect(() => {\n if (payloadRedirect && !disabled) {\n // set cookie to redirect to the original page\n document.cookie = `payloadRedirect=${payloadRedirect}; path=/`\n }\n }, [payloadRedirect, disabled])\n\n useEffect(() => {\n const getAuthorizeURL = async () => {\n const serverURLFromWindow = window.location.origin\n const data = await fetch(\n `${serverURL}${api}/${userSlug}/${endpointSlug}/meta?serverURL=${serverURLFromWindow}`,\n ).then((res) => res.json())\n\n if (!disabled) {\n setAuthorizeURL(data.authorizeURL)\n }\n }\n\n void getAuthorizeURL()\n }, [api, serverURL, userSlug, disabled, endpointSlug])\n\n if (disabled) {\n return null\n }\n\n return (\n <div className={baseClass}>\n <a className={`${baseClass}__btn`} href={authorizeURL}>\n <FigmaIcon />\n <span className={`${baseClass}__text`}>Log in with Figma</span>\n </a>\n </div>\n )\n}\n"],"names":["useConfig","useSearchParams","React","useEffect","useState","baseClass","FigmaIcon","svg","fill","height","viewBox","width","xmlns","path","clipRule","d","fillRule","DefaultLoginButton","disabled","endpointSlug","config","admin","user","userSlug","routes","api","serverURL","authorizeURL","setAuthorizeURL","searchParams","payloadRedirect","get","document","cookie","getAuthorizeURL","serverURLFromWindow","window","location","origin","data","fetch","then","res","json","div","className","a","href","span"],"mappings":"AAAA;;AAEA,SAASA,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,eAAe,QAAQ,qBAAoB;AACpD,OAAOC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAElD,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,iCAAiC;AACjC,sCAAsC;AACtC,mEAAmE;AACnE,YAAY;AACZ,oHAAoH;AACpH,uBAAuB;AACvB,SAAS;AACT,YAAY;AACZ,2FAA2F;AAC3F,uBAAuB;AACvB,SAAS;AACT,YAAY;AACZ,0LAA0L;AAC1L,uBAAuB;AACvB,SAAS;AACT,YAAY;AACZ,m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ACd,cAAA,MAACyC;YAAED,WAAW,GAAGxC,UAAU,KAAK,CAAC;YAAE0C,MAAMpB;;8BACvC,KAACrB;8BACD,KAAC0C;oBAAKH,WAAW,GAAGxC,UAAU,MAAM,CAAC;8BAAE;;;;;AAI/C,EAAC"}
@@ -1,10 +1,57 @@
1
1
  .oauth-login {
2
2
  display: flex;
3
3
  justify-content: center;
4
+ padding: 1rem 0;
4
5
 
5
- &__btn:focus {
6
- .btn__icon {
7
- background: none;
6
+ &__btn {
7
+ display: inline-flex;
8
+ align-items: center;
9
+ justify-content: center;
10
+ gap: 0.75rem;
11
+ padding: 0.75rem 1.5rem;
12
+ min-height: 3rem;
13
+ background-color: #4d49fc;
14
+ color: #ffffff;
15
+ border: none;
16
+ border-radius: 0.5rem;
17
+ font-size: 1rem;
18
+ font-weight: 450;
19
+ letter-spacing: 0.05px;
20
+ text-decoration: none;
21
+ cursor: pointer;
22
+ transition: background-color 0.2s ease, transform 0.1s ease;
23
+ box-shadow: none;
24
+
25
+ &:hover {
26
+ background-color: #4440e8;
27
+ transform: translateY(-1px);
28
+ }
29
+
30
+ &:active {
31
+ background-color: #3c38d4;
32
+ transform: translateY(0);
33
+ }
34
+
35
+ &:focus {
36
+ outline: none;
37
+ box-shadow: 0 0 0 2px rgba(77, 73, 252, 0.4);
8
38
  }
9
39
  }
40
+
41
+ &__icon {
42
+ flex-shrink: 0;
43
+ width: 20px;
44
+ height: 20px;
45
+ display: flex;
46
+ align-items: center;
47
+ justify-content: center;
48
+ color: #ffffff;
49
+ }
50
+
51
+ &__text {
52
+ white-space: nowrap;
53
+ line-height: 1rem;
54
+ font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
55
+ Oxygen, Ubuntu, Cantarell, sans-serif;
56
+ }
10
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/LogoutButton/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CA2D/E,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/oauth/components/LogoutButton/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CA0D/E,CAAA"}
@@ -17,7 +17,6 @@ export const LogoutButton = ({ disabled, endpointSlug })=>{
17
17
  redirectToSet += `:${port}`;
18
18
  }
19
19
  redirectToSet += getAdminPath(config);
20
- // eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
21
20
  setRedirect(redirectToSet);
22
21
  }, [
23
22
  config
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/oauth/components/LogoutButton/index.tsx"],"sourcesContent":["'use client'\n\nimport { Logout, useConfig } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { getAdminPath } from '../../utilities/getAdminPath.js'\nimport './index.scss'\n\nconst baseClass = 'oauth-logout'\n\nexport const LogoutButton: React.FC<{ disabled?: boolean; endpointSlug: string }> = ({\n disabled,\n endpointSlug,\n}) => {\n const {\n config,\n config: {\n admin: { user: userSlug },\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const [redirect, setRedirect] = React.useState('')\n React.useEffect(() => {\n const protocol = window.location.protocol\n const domain = window.location.hostname\n const port = window.location.port\n\n let redirectToSet = `${protocol}//${domain}`\n if (port) {\n redirectToSet += `:${port}`\n }\n\n redirectToSet += getAdminPath(config)\n\n // eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect\n setRedirect(redirectToSet)\n }, [config])\n\n if (!redirect) {\n return null\n }\n\n if (disabled) {\n return <Logout />\n }\n\n return (\n <div className={baseClass}>\n <a\n aria-label=\"Logout\"\n href={`${serverURL}${api}/${userSlug}/${endpointSlug}/logout?redirect=${redirect}`}\n >\n <svg\n className=\"icon icon--logout\"\n fill=\"none\"\n viewBox=\"0 0 25 25\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path className=\"stroke\" d=\"M10 5H18V19H10\" />\n <g>\n <path className=\"stroke\" d=\"M8 8.5L4.46447 12.0355L8 15.5711\" />\n <line className=\"stroke\" x1=\"5\" x2=\"13\" y1=\"12\" y2=\"12\" />\n </g>\n </svg>\n </a>\n </div>\n )\n}\n"],"names":["Logout","useConfig","React","getAdminPath","baseClass","LogoutButton","disabled","endpointSlug","config","admin","user","userSlug","routes","api","serverURL","redirect","setRedirect","useState","useEffect","protocol","window","location","domain","hostname","port","redirectToSet","div","className","a","aria-label","href","svg","fill","viewBox","xmlns","path","d","g","line","x1","x2","y1","y2"],"mappings":"AAAA;;AAEA,SAASA,MAAM,EAAEC,SAAS,QAAQ,iBAAgB;AAClD,OAAOC,WAAW,QAAO;AAEzB,SAASC,YAAY,QAAQ,kCAAiC;AAC9D,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,OAAO,MAAMC,eAAuE,CAAC,EACnFC,QAAQ,EACRC,YAAY,EACb;IACC,MAAM,EACJC,MAAM,EACNA,QAAQ,EACNC,OAAO,EAAEC,MAAMC,QAAQ,EAAE,EACzBC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAGb;IAEJ,MAAM,CAACc,UAAUC,YAAY,GAAGd,MAAMe,QAAQ,CAAC;IAC/Cf,MAAMgB,SAAS,CAAC;QACd,MAAMC,WAAWC,OAAOC,QAAQ,CAACF,QAAQ;QACzC,MAAMG,SAASF,OAAOC,QAAQ,CAACE,QAAQ;QACvC,MAAMC,OAAOJ,OAAOC,QAAQ,CAACG,IAAI;QAEjC,IAAIC,gBAAgB,GAAGN,SAAS,EAAE,EAAEG,QAAQ;QAC5C,IAAIE,MAAM;YACRC,iBAAiB,CAAC,CAAC,EAAED,MAAM;QAC7B;QAEAC,iBAAiBtB,aAAaK;QAE9B,uFAAuF;QACvFQ,YAAYS;IACd,GAAG;QAACjB;KAAO;IAEX,IAAI,CAACO,UAAU;QACb,OAAO;IACT;IAEA,IAAIT,UAAU;QACZ,qBAAO,KAACN;IACV;IAEA,qBACE,KAAC0B;QAAIC,WAAWvB;kBACd,cAAA,KAACwB;YACCC,cAAW;YACXC,MAAM,GAAGhB,YAAYD,IAAI,CAAC,EAAEF,SAAS,CAAC,EAAEJ,aAAa,iBAAiB,EAAEQ,UAAU;sBAElF,cAAA,MAACgB;gBACCJ,WAAU;gBACVK,MAAK;gBACLC,SAAQ;gBACRC,OAAM;;kCAEN,KAACC;wBAAKR,WAAU;wBAASS,GAAE;;kCAC3B,MAACC;;0CACC,KAACF;gCAAKR,WAAU;gCAASS,GAAE;;0CAC3B,KAACE;gCAAKX,WAAU;gCAASY,IAAG;gCAAIC,IAAG;gCAAKC,IAAG;gCAAKC,IAAG;;;;;;;;AAM/D,EAAC"}
1
+ {"version":3,"sources":["../../../../src/oauth/components/LogoutButton/index.tsx"],"sourcesContent":["'use client'\n\nimport { Logout, useConfig } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { getAdminPath } from '../../utilities/getAdminPath.js'\nimport './index.scss'\n\nconst baseClass = 'oauth-logout'\n\nexport const LogoutButton: React.FC<{ disabled?: boolean; endpointSlug: string }> = ({\n disabled,\n endpointSlug,\n}) => {\n const {\n config,\n config: {\n admin: { user: userSlug },\n routes: { api },\n serverURL,\n },\n } = useConfig()\n\n const [redirect, setRedirect] = React.useState('')\n React.useEffect(() => {\n const protocol = window.location.protocol\n const domain = window.location.hostname\n const port = window.location.port\n\n let redirectToSet = `${protocol}//${domain}`\n if (port) {\n redirectToSet += `:${port}`\n }\n\n redirectToSet += getAdminPath(config)\n\n setRedirect(redirectToSet)\n }, [config])\n\n if (!redirect) {\n return null\n }\n\n if (disabled) {\n return <Logout />\n }\n\n return (\n <div className={baseClass}>\n <a\n aria-label=\"Logout\"\n href={`${serverURL}${api}/${userSlug}/${endpointSlug}/logout?redirect=${redirect}`}\n >\n <svg\n className=\"icon icon--logout\"\n fill=\"none\"\n viewBox=\"0 0 25 25\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path className=\"stroke\" d=\"M10 5H18V19H10\" />\n <g>\n <path className=\"stroke\" d=\"M8 8.5L4.46447 12.0355L8 15.5711\" />\n <line className=\"stroke\" x1=\"5\" x2=\"13\" y1=\"12\" y2=\"12\" />\n </g>\n </svg>\n </a>\n </div>\n )\n}\n"],"names":["Logout","useConfig","React","getAdminPath","baseClass","LogoutButton","disabled","endpointSlug","config","admin","user","userSlug","routes","api","serverURL","redirect","setRedirect","useState","useEffect","protocol","window","location","domain","hostname","port","redirectToSet","div","className","a","aria-label","href","svg","fill","viewBox","xmlns","path","d","g","line","x1","x2","y1","y2"],"mappings":"AAAA;;AAEA,SAASA,MAAM,EAAEC,SAAS,QAAQ,iBAAgB;AAClD,OAAOC,WAAW,QAAO;AAEzB,SAASC,YAAY,QAAQ,kCAAiC;AAC9D,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,OAAO,MAAMC,eAAuE,CAAC,EACnFC,QAAQ,EACRC,YAAY,EACb;IACC,MAAM,EACJC,MAAM,EACNA,QAAQ,EACNC,OAAO,EAAEC,MAAMC,QAAQ,EAAE,EACzBC,QAAQ,EAAEC,GAAG,EAAE,EACfC,SAAS,EACV,EACF,GAAGb;IAEJ,MAAM,CAACc,UAAUC,YAAY,GAAGd,MAAMe,QAAQ,CAAC;IAC/Cf,MAAMgB,SAAS,CAAC;QACd,MAAMC,WAAWC,OAAOC,QAAQ,CAACF,QAAQ;QACzC,MAAMG,SAASF,OAAOC,QAAQ,CAACE,QAAQ;QACvC,MAAMC,OAAOJ,OAAO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":"defaults.d.ts","sourceRoot":"","sources":["../../src/oauth/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAQ,MAAM,SAAS,CAAA;AAI5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,eAAO,MAAM,YAAY,UAAiC,CAAA;AAE1D,eAAO,MAAM,oBAAoB,EAAE,SAQlC,CAAA;AAED,eAAO,MAAM,aAAa,iDAKrB;IACD,UAAU,EAAE,gBAAgB,CAAA;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,UAAU,GAAG,SAAS,CAAA;CACtC,KAAG,cAuGH,CAAA"}