@payloadcms/figma 1.0.0-beta.0 → 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.
- package/dist/adapters/build-lambda-zip.d.ts +2 -1
- package/dist/adapters/build-lambda-zip.js +4 -1
- package/dist/adapters/deploy-output/assertDeployableServerActionsKey.d.ts +14 -0
- package/dist/adapters/deploy-output/assertDeployableServerActionsKey.js +33 -0
- package/dist/commands/upload-schema.js +23 -9
- package/dist/content-api/auth.d.ts +34 -0
- package/dist/content-api/auth.js +70 -0
- package/dist/content-api/awaitWithSignal.d.ts +2 -0
- package/dist/content-api/awaitWithSignal.js +27 -0
- package/dist/content-api/createContentApiClient.d.ts +18 -0
- package/dist/content-api/createContentApiClient.js +90 -0
- package/dist/content-api/withRateLimitRetries.d.ts +7 -0
- package/dist/content-api/withRateLimitRetries.js +45 -0
- package/dist/db-content-api/generated/content-api-types.d.ts +247 -0
- package/dist/db-content-api/index.d.ts +5 -5
- package/dist/db-content-api/index.js +46 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/oauth/components/FigmaAvatar/index.js +3 -2
- package/dist/oauth/components/FigmaAvatarCell/index.js +3 -1
- package/dist/oauth/components/LoginButton/index.js +8 -4
- package/dist/oauth/components/LogoutButton/index.js +3 -2
- package/dist/oauth/defaults.js +2 -2
- package/dist/oauth/endpoints/getLoginEndpoint.js +2 -5
- package/dist/oauth/hooks/me.d.ts +4 -3
- package/dist/oauth/hooks/me.js +6 -52
- package/dist/oauth/hooks/refresh.js +9 -1
- package/dist/oauth/index.js +3 -3
- package/dist/oauth/strategy/index.d.ts +3 -0
- package/dist/oauth/strategy/index.js +49 -3
- package/dist/oauth/utilities/clearCookie.d.ts +1 -0
- package/dist/oauth/utilities/clearCookie.js +13 -9
- package/dist/oauth/utilities/clearSessionCookies.d.ts +5 -0
- package/dist/oauth/utilities/clearSessionCookies.js +17 -0
- package/dist/oauth/utilities/getAuthorizeURL.js +1 -2
- package/dist/oauth/utilities/mergeHeaders.js +11 -23
- package/dist/oauth/utilities/refreshTokens.d.ts +9 -3
- package/dist/oauth/utilities/refreshTokens.js +45 -34
- package/dist/oauth/utilities/resolvePayloadRedirect.d.ts +13 -0
- package/dist/oauth/utilities/resolvePayloadRedirect.js +30 -0
- package/dist/plugin/build-config.js +16 -13
- package/dist/plugin/cloud-limits/CloudLimitModal/index.js +1 -1
- package/dist/plugin/cloud-limits/shared.d.ts +5 -1
- package/dist/plugin/cloud-limits/utilities/toasts.d.ts +2 -1
- package/dist/plugin/dev-cookie-names.d.ts +4 -1
- package/dist/plugin/dev-cookie-names.js +6 -3
- package/dist/plugin/environment-error.d.ts +4 -0
- package/dist/plugin/environment-error.js +22 -0
- package/dist/plugin/mcp-oauth.d.ts +10 -0
- package/dist/plugin/mcp-oauth.js +24 -0
- package/dist/plugin/sandbox-upload-fetch.d.ts +5 -6
- package/dist/plugin/sandbox-upload-fetch.js +22 -14
- package/dist/scss.d.js +1 -1
- package/dist/storage-content-api/api-types.d.ts +22 -1
- package/dist/storage-content-api/api-types.js +2 -1
- package/dist/storage-content-api/client.d.ts +3 -3
- package/dist/storage-content-api/client.js +13 -35
- package/dist/storage-content-api/index.js +20 -21
- package/dist/storage-content-api/staticHandler.js +4 -1
- package/dist/storage-content-api/types.d.ts +2 -2
- package/dist/translations/ar.d.ts +9 -0
- package/dist/translations/ar.js +10 -1
- package/dist/translations/az.d.ts +9 -0
- package/dist/translations/az.js +10 -1
- package/dist/translations/bg.d.ts +9 -0
- package/dist/translations/bg.js +10 -1
- package/dist/translations/bnBd.d.ts +9 -0
- package/dist/translations/bnBd.js +10 -1
- package/dist/translations/bnIn.d.ts +9 -0
- package/dist/translations/bnIn.js +10 -1
- package/dist/translations/ca.d.ts +9 -0
- package/dist/translations/ca.js +10 -1
- package/dist/translations/cs.d.ts +9 -0
- package/dist/translations/cs.js +10 -1
- package/dist/translations/da.d.ts +9 -0
- package/dist/translations/da.js +10 -1
- package/dist/translations/de.d.ts +9 -0
- package/dist/translations/de.js +10 -1
- package/dist/translations/en.d.ts +9 -0
- package/dist/translations/en.js +10 -1
- package/dist/translations/es.d.ts +9 -0
- package/dist/translations/es.js +15 -6
- package/dist/translations/et.d.ts +9 -0
- package/dist/translations/et.js +10 -1
- package/dist/translations/fa.d.ts +9 -0
- package/dist/translations/fa.js +10 -1
- package/dist/translations/fr.d.ts +9 -0
- package/dist/translations/fr.js +10 -1
- package/dist/translations/he.d.ts +9 -0
- package/dist/translations/he.js +10 -1
- package/dist/translations/hr.d.ts +9 -0
- package/dist/translations/hr.js +10 -1
- package/dist/translations/hu.d.ts +9 -0
- package/dist/translations/hu.js +10 -1
- package/dist/translations/hy.d.ts +9 -0
- package/dist/translations/hy.js +10 -1
- package/dist/translations/id.d.ts +9 -0
- package/dist/translations/id.js +10 -1
- package/dist/translations/index.d.ts +400 -3
- package/dist/translations/is.d.ts +9 -0
- package/dist/translations/is.js +10 -1
- package/dist/translations/it.d.ts +9 -0
- package/dist/translations/it.js +10 -1
- package/dist/translations/ja.d.ts +9 -0
- package/dist/translations/ja.js +14 -5
- package/dist/translations/ko.d.ts +9 -0
- package/dist/translations/ko.js +16 -7
- package/dist/translations/lt.d.ts +9 -0
- package/dist/translations/lt.js +10 -1
- package/dist/translations/lv.d.ts +9 -0
- package/dist/translations/lv.js +10 -1
- package/dist/translations/my.d.ts +9 -0
- package/dist/translations/my.js +10 -1
- package/dist/translations/nb.d.ts +9 -0
- package/dist/translations/nb.js +10 -1
- package/dist/translations/nl.d.ts +9 -0
- package/dist/translations/nl.js +10 -1
- package/dist/translations/pl.d.ts +9 -0
- package/dist/translations/pl.js +10 -1
- package/dist/translations/pt.d.ts +9 -0
- package/dist/translations/pt.js +15 -6
- package/dist/translations/ro.d.ts +9 -0
- package/dist/translations/ro.js +10 -1
- package/dist/translations/rs.d.ts +9 -0
- package/dist/translations/rs.js +10 -1
- package/dist/translations/rsLatin.d.ts +9 -0
- package/dist/translations/rsLatin.js +10 -1
- package/dist/translations/ru.d.ts +9 -0
- package/dist/translations/ru.js +10 -1
- package/dist/translations/sk.d.ts +9 -0
- package/dist/translations/sk.js +10 -1
- package/dist/translations/sl.d.ts +9 -0
- package/dist/translations/sl.js +10 -1
- package/dist/translations/sv.d.ts +9 -0
- package/dist/translations/sv.js +10 -1
- package/dist/translations/ta.d.ts +9 -0
- package/dist/translations/ta.js +10 -1
- package/dist/translations/th.d.ts +9 -0
- package/dist/translations/th.js +10 -1
- package/dist/translations/tr.d.ts +9 -0
- package/dist/translations/tr.js +10 -1
- package/dist/translations/uk.d.ts +9 -0
- package/dist/translations/uk.js +10 -1
- package/dist/translations/vi.d.ts +9 -0
- package/dist/translations/vi.js +10 -1
- package/dist/translations/zh.d.ts +9 -0
- package/dist/translations/zh.js +10 -1
- package/dist/translations/zhTw.d.ts +9 -0
- package/dist/translations/zhTw.js +10 -1
- package/dist/utils/env-management.js +7 -0
- package/package.json +20 -22
- package/dist/db-content-api/utilities/auth.d.ts +0 -29
- package/dist/db-content-api/utilities/auth.js +0 -82
|
@@ -6242,6 +6242,171 @@ export type paths = {
|
|
|
6242
6242
|
patch?: never;
|
|
6243
6243
|
trace?: never;
|
|
6244
6244
|
};
|
|
6245
|
+
'/api/v0/uploads/transform/sign': {
|
|
6246
|
+
parameters: {
|
|
6247
|
+
query?: never;
|
|
6248
|
+
header?: never;
|
|
6249
|
+
path?: never;
|
|
6250
|
+
cookie?: never;
|
|
6251
|
+
};
|
|
6252
|
+
get?: never;
|
|
6253
|
+
put?: never;
|
|
6254
|
+
post: {
|
|
6255
|
+
parameters: {
|
|
6256
|
+
query?: never;
|
|
6257
|
+
header?: never;
|
|
6258
|
+
path?: never;
|
|
6259
|
+
cookie?: never;
|
|
6260
|
+
};
|
|
6261
|
+
requestBody?: {
|
|
6262
|
+
content: {
|
|
6263
|
+
'application/json': components['schemas']['SignImageTransformRequest'];
|
|
6264
|
+
};
|
|
6265
|
+
};
|
|
6266
|
+
responses: {
|
|
6267
|
+
/** @description Image transform path signed */
|
|
6268
|
+
200: {
|
|
6269
|
+
headers: {
|
|
6270
|
+
[name: string]: unknown;
|
|
6271
|
+
};
|
|
6272
|
+
content: {
|
|
6273
|
+
'application/json': components['schemas']['SignImageTransformResponse'];
|
|
6274
|
+
};
|
|
6275
|
+
};
|
|
6276
|
+
/** @description Bad Request */
|
|
6277
|
+
400: {
|
|
6278
|
+
headers: {
|
|
6279
|
+
[name: string]: unknown;
|
|
6280
|
+
};
|
|
6281
|
+
content: {
|
|
6282
|
+
'application/json': {
|
|
6283
|
+
/** @example Error message describing the issue. */
|
|
6284
|
+
message: string;
|
|
6285
|
+
/** @example database.constraint_violation */
|
|
6286
|
+
code?: string;
|
|
6287
|
+
/** @example email */
|
|
6288
|
+
field?: string;
|
|
6289
|
+
/** @example unique_constraint */
|
|
6290
|
+
constraint?: string;
|
|
6291
|
+
};
|
|
6292
|
+
};
|
|
6293
|
+
};
|
|
6294
|
+
/** @description Unauthorized */
|
|
6295
|
+
401: {
|
|
6296
|
+
headers: {
|
|
6297
|
+
[name: string]: unknown;
|
|
6298
|
+
};
|
|
6299
|
+
content: {
|
|
6300
|
+
'application/json': {
|
|
6301
|
+
/** @example Error message describing the issue. */
|
|
6302
|
+
message: string;
|
|
6303
|
+
/** @example database.constraint_violation */
|
|
6304
|
+
code?: string;
|
|
6305
|
+
/** @example email */
|
|
6306
|
+
field?: string;
|
|
6307
|
+
/** @example unique_constraint */
|
|
6308
|
+
constraint?: string;
|
|
6309
|
+
};
|
|
6310
|
+
};
|
|
6311
|
+
};
|
|
6312
|
+
/** @description Forbidden */
|
|
6313
|
+
403: {
|
|
6314
|
+
headers: {
|
|
6315
|
+
[name: string]: unknown;
|
|
6316
|
+
};
|
|
6317
|
+
content: {
|
|
6318
|
+
'application/json': {
|
|
6319
|
+
/** @example Error message describing the issue. */
|
|
6320
|
+
message: string;
|
|
6321
|
+
/** @example database.constraint_violation */
|
|
6322
|
+
code?: string;
|
|
6323
|
+
/** @example email */
|
|
6324
|
+
field?: string;
|
|
6325
|
+
/** @example unique_constraint */
|
|
6326
|
+
constraint?: string;
|
|
6327
|
+
};
|
|
6328
|
+
};
|
|
6329
|
+
};
|
|
6330
|
+
/** @description Not Found */
|
|
6331
|
+
404: {
|
|
6332
|
+
headers: {
|
|
6333
|
+
[name: string]: unknown;
|
|
6334
|
+
};
|
|
6335
|
+
content: {
|
|
6336
|
+
'application/json': {
|
|
6337
|
+
/** @example Error message describing the issue. */
|
|
6338
|
+
message: string;
|
|
6339
|
+
/** @example database.constraint_violation */
|
|
6340
|
+
code?: string;
|
|
6341
|
+
/** @example email */
|
|
6342
|
+
field?: string;
|
|
6343
|
+
/** @example unique_constraint */
|
|
6344
|
+
constraint?: string;
|
|
6345
|
+
};
|
|
6346
|
+
};
|
|
6347
|
+
};
|
|
6348
|
+
/** @description Content system rate limit exceeded */
|
|
6349
|
+
429: {
|
|
6350
|
+
headers: {
|
|
6351
|
+
[name: string]: unknown;
|
|
6352
|
+
};
|
|
6353
|
+
content: {
|
|
6354
|
+
'application/json': {
|
|
6355
|
+
/** @example Error message describing the issue. */
|
|
6356
|
+
message: string;
|
|
6357
|
+
/** @example database.constraint_violation */
|
|
6358
|
+
code?: string;
|
|
6359
|
+
/** @example email */
|
|
6360
|
+
field?: string;
|
|
6361
|
+
/** @example unique_constraint */
|
|
6362
|
+
constraint?: string;
|
|
6363
|
+
};
|
|
6364
|
+
};
|
|
6365
|
+
};
|
|
6366
|
+
/** @description Internal Server Error */
|
|
6367
|
+
500: {
|
|
6368
|
+
headers: {
|
|
6369
|
+
[name: string]: unknown;
|
|
6370
|
+
};
|
|
6371
|
+
content: {
|
|
6372
|
+
'application/json': {
|
|
6373
|
+
/** @example Error message describing the issue. */
|
|
6374
|
+
message: string;
|
|
6375
|
+
/** @example database.constraint_violation */
|
|
6376
|
+
code?: string;
|
|
6377
|
+
/** @example email */
|
|
6378
|
+
field?: string;
|
|
6379
|
+
/** @example unique_constraint */
|
|
6380
|
+
constraint?: string;
|
|
6381
|
+
};
|
|
6382
|
+
};
|
|
6383
|
+
};
|
|
6384
|
+
/** @description Service Unavailable */
|
|
6385
|
+
503: {
|
|
6386
|
+
headers: {
|
|
6387
|
+
[name: string]: unknown;
|
|
6388
|
+
};
|
|
6389
|
+
content: {
|
|
6390
|
+
'application/json': {
|
|
6391
|
+
/** @example Error message describing the issue. */
|
|
6392
|
+
message: string;
|
|
6393
|
+
/** @example database.constraint_violation */
|
|
6394
|
+
code?: string;
|
|
6395
|
+
/** @example email */
|
|
6396
|
+
field?: string;
|
|
6397
|
+
/** @example unique_constraint */
|
|
6398
|
+
constraint?: string;
|
|
6399
|
+
};
|
|
6400
|
+
};
|
|
6401
|
+
};
|
|
6402
|
+
};
|
|
6403
|
+
};
|
|
6404
|
+
delete?: never;
|
|
6405
|
+
options?: never;
|
|
6406
|
+
head?: never;
|
|
6407
|
+
patch?: never;
|
|
6408
|
+
trace?: never;
|
|
6409
|
+
};
|
|
6245
6410
|
};
|
|
6246
6411
|
export type webhooks = Record<string, never>;
|
|
6247
6412
|
export type components = {
|
|
@@ -8208,6 +8373,88 @@ export type components = {
|
|
|
8208
8373
|
*/
|
|
8209
8374
|
content_system_id?: string;
|
|
8210
8375
|
};
|
|
8376
|
+
SignImageTransformRequest: {
|
|
8377
|
+
collectionId: string;
|
|
8378
|
+
filename: string;
|
|
8379
|
+
/** @description Stored MIME type supplied by Payload after file resolution and access checks */
|
|
8380
|
+
mimeType: string;
|
|
8381
|
+
/**
|
|
8382
|
+
* @default GET
|
|
8383
|
+
* @enum {string}
|
|
8384
|
+
*/
|
|
8385
|
+
method: 'GET' | 'HEAD';
|
|
8386
|
+
size?: {
|
|
8387
|
+
name: string;
|
|
8388
|
+
anim?: boolean;
|
|
8389
|
+
background?: string;
|
|
8390
|
+
blur?: number;
|
|
8391
|
+
border?: {
|
|
8392
|
+
color: string;
|
|
8393
|
+
width: number;
|
|
8394
|
+
} | {
|
|
8395
|
+
color: string;
|
|
8396
|
+
bottom: number;
|
|
8397
|
+
left: number;
|
|
8398
|
+
right: number;
|
|
8399
|
+
top: number;
|
|
8400
|
+
};
|
|
8401
|
+
brightness?: number;
|
|
8402
|
+
/** @enum {string} */
|
|
8403
|
+
compression?: 'fast';
|
|
8404
|
+
contrast?: number;
|
|
8405
|
+
dpr?: number;
|
|
8406
|
+
/** @enum {string} */
|
|
8407
|
+
fit?: 'contain' | 'cover' | 'crop' | 'pad' | 'scale-down' | 'scale-up' | 'squeeze';
|
|
8408
|
+
/** @enum {string} */
|
|
8409
|
+
flip?: 'h' | 'hv' | 'v';
|
|
8410
|
+
/** @enum {string} */
|
|
8411
|
+
format?: 'avif' | 'baseline-jpeg' | 'jpeg' | 'png' | 'png-force' | 'webp';
|
|
8412
|
+
gamma?: number;
|
|
8413
|
+
gravity?: ('auto' | 'bottom' | 'center' | 'entropy' | 'face' | 'left' | 'right' | 'top') | {
|
|
8414
|
+
/** @enum {string} */
|
|
8415
|
+
mode?: 'box-center' | 'remainder';
|
|
8416
|
+
x?: number;
|
|
8417
|
+
y?: number;
|
|
8418
|
+
};
|
|
8419
|
+
height?: number;
|
|
8420
|
+
/** @enum {string} */
|
|
8421
|
+
metadata?: 'copyright' | 'keep' | 'none';
|
|
8422
|
+
quality?: number | ('high' | 'medium-high' | 'medium-low' | 'low');
|
|
8423
|
+
rotate?: 90 | 180 | 270;
|
|
8424
|
+
saturation?: number;
|
|
8425
|
+
/** @enum {string} */
|
|
8426
|
+
segment?: 'foreground';
|
|
8427
|
+
sharpen?: number;
|
|
8428
|
+
trim?: 'border' | {
|
|
8429
|
+
border?: boolean | {
|
|
8430
|
+
color?: string;
|
|
8431
|
+
keep?: number;
|
|
8432
|
+
tolerance?: number;
|
|
8433
|
+
};
|
|
8434
|
+
bottom?: number;
|
|
8435
|
+
height?: number;
|
|
8436
|
+
left?: number;
|
|
8437
|
+
right?: number;
|
|
8438
|
+
top?: number;
|
|
8439
|
+
width?: number;
|
|
8440
|
+
};
|
|
8441
|
+
/** @enum {string} */
|
|
8442
|
+
upscale?: 'generate' | 'interpolate';
|
|
8443
|
+
width?: number;
|
|
8444
|
+
zoom?: number;
|
|
8445
|
+
};
|
|
8446
|
+
request?: {
|
|
8447
|
+
w?: number;
|
|
8448
|
+
q?: number;
|
|
8449
|
+
};
|
|
8450
|
+
responseHeaders?: {
|
|
8451
|
+
/** @example public, max-age=3600 */
|
|
8452
|
+
cacheControl: string;
|
|
8453
|
+
};
|
|
8454
|
+
};
|
|
8455
|
+
SignImageTransformResponse: {
|
|
8456
|
+
path: string;
|
|
8457
|
+
};
|
|
8211
8458
|
};
|
|
8212
8459
|
responses: never;
|
|
8213
8460
|
parameters: never;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { BaseDatabaseAdapter, CreateArgs, DatabaseAdapterObj } from 'payload';
|
|
2
|
-
import
|
|
2
|
+
import type { ContentApiAuth } from '../content-api/auth.js';
|
|
3
3
|
import type { paths } from './generated/content-api-types.js';
|
|
4
|
-
import {
|
|
4
|
+
import { createContentApiClient } from '../content-api/createContentApiClient.js';
|
|
5
5
|
import { type DocumentSchemaWire } from './utilities/schema/buildDocumentSchema.js';
|
|
6
6
|
type ContentAPIOptions = {
|
|
7
7
|
allowIDOnCreate?: boolean;
|
|
8
|
-
auth:
|
|
8
|
+
auth: ContentApiAuth;
|
|
9
9
|
contentSystemId: string;
|
|
10
10
|
environmentName?: string;
|
|
11
11
|
notifyLocalJobQueue: boolean;
|
|
@@ -24,9 +24,9 @@ export declare const LOCAL_JOB_QUEUE_NOTICE: string;
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function maybeNotifyLocalJobQueue(adapter: ContentAPIAdapter, args: CreateArgs): void;
|
|
26
26
|
export type ContentAPIAdapter = {
|
|
27
|
-
auth:
|
|
27
|
+
auth: ContentApiAuth;
|
|
28
28
|
clearDatabase: () => Promise<void>;
|
|
29
|
-
client: ReturnType<typeof
|
|
29
|
+
client: ReturnType<typeof createContentApiClient<paths>>['api'];
|
|
30
30
|
clientVersionHeaders: Record<string, string>;
|
|
31
31
|
contentSystemId: string;
|
|
32
32
|
documentSchema: () => DocumentSchemaWire;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
3
|
import { APIError, createDatabaseAdapter, ValidationError } from 'payload';
|
|
3
|
-
import { v4 as uuid } from 'uuid';
|
|
4
4
|
import { FigmaApiError } from '../api/figma-api.js';
|
|
5
5
|
import { CONTENT_SYSTEM_NOT_FOUND_MESSAGE } from '../constants.js';
|
|
6
|
+
import { createContentApiClient } from '../content-api/createContentApiClient.js';
|
|
6
7
|
import { redirectInitialAutosaveCreate } from '../plugin/cloud-limits/server/redirectInitialAutosaveCreate.js';
|
|
7
8
|
import { getGlobalSlug } from './temp-utilities/slug.js';
|
|
8
9
|
import { addFallbackSort } from './temp-utilities/sorting.js';
|
|
9
10
|
import { unwrapDocument, unwrapFindResponse } from './temp-utilities/unwrapDocument.js';
|
|
10
|
-
import { createAuthMiddleware, createErrorMiddleware } from './utilities/auth.js';
|
|
11
11
|
import { getClientVersionHeaders } from './utilities/clientVersionHeaders.js';
|
|
12
12
|
import { dataToContentAPI, resolveVersionContent } from './utilities/data/index.js';
|
|
13
13
|
import { injectGlobalType } from './utilities/data/injectGlobalType.js';
|
|
@@ -501,7 +501,7 @@ async function create(args) {
|
|
|
501
501
|
} else if ((isGlobalCollection || customIDType || this.allowIDOnCreate) && args.data.id != null && (typeof args.data.id === 'string' || typeof args.data.id === 'number')) {
|
|
502
502
|
id = String(args.data.id);
|
|
503
503
|
} else {
|
|
504
|
-
id =
|
|
504
|
+
id = randomUUID();
|
|
505
505
|
}
|
|
506
506
|
const locale = addFallbackLocale(args.locale, this.payload);
|
|
507
507
|
validateRelationshipIds({
|
|
@@ -573,7 +573,43 @@ export function getClearDatabaseUrl(url, cutoverState) {
|
|
|
573
573
|
}
|
|
574
574
|
return clearDatabaseUrl.toString();
|
|
575
575
|
}
|
|
576
|
+
async function countJobsForHandleSchedules(args) {
|
|
577
|
+
if (args.collection !== 'payload-jobs') {
|
|
578
|
+
return undefined;
|
|
579
|
+
}
|
|
580
|
+
// Payload's /handle-schedules counts unfinished jobs before queuing another occurrence.
|
|
581
|
+
// Until v1 supports error and meta.scheduled JSON filters, apply those filters locally.
|
|
582
|
+
const countFilters = args.where?.and ?? [];
|
|
583
|
+
const noErrorFilter = countFilters.find((filter)=>isDeepStrictEqual(filter, {
|
|
584
|
+
error: {
|
|
585
|
+
exists: false
|
|
586
|
+
}
|
|
587
|
+
}));
|
|
588
|
+
if (!noErrorFilter) {
|
|
589
|
+
return undefined;
|
|
590
|
+
}
|
|
591
|
+
const onlyScheduledJobsFilter = countFilters.find((filter)=>isDeepStrictEqual(filter, {
|
|
592
|
+
'meta.scheduled': {
|
|
593
|
+
equals: true
|
|
594
|
+
}
|
|
595
|
+
}));
|
|
596
|
+
const { docs } = await this.find({
|
|
597
|
+
...args,
|
|
598
|
+
limit: 0,
|
|
599
|
+
where: {
|
|
600
|
+
...args.where,
|
|
601
|
+
and: countFilters.filter((filter)=>filter !== noErrorFilter && filter !== onlyScheduledJobsFilter)
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
return {
|
|
605
|
+
totalDocs: docs.filter((job)=>job.error == null && (!onlyScheduledJobsFilter || job.meta?.scheduled === true)).length
|
|
606
|
+
};
|
|
607
|
+
}
|
|
576
608
|
async function count(args) {
|
|
609
|
+
const handleSchedulesCount = await countJobsForHandleSchedules.call(this, args);
|
|
610
|
+
if (handleSchedulesCount) {
|
|
611
|
+
return handleSchedulesCount;
|
|
612
|
+
}
|
|
577
613
|
const locale = addFallbackLocale(args.locale, this.payload);
|
|
578
614
|
const { data: response, error, response: httpResponse } = await this.client.POST('/api/v1/documents:count', {
|
|
579
615
|
body: {
|
|
@@ -631,7 +667,7 @@ async function upsert(args) {
|
|
|
631
667
|
}
|
|
632
668
|
}
|
|
633
669
|
if (!documentId) {
|
|
634
|
-
documentId =
|
|
670
|
+
documentId = randomUUID();
|
|
635
671
|
}
|
|
636
672
|
const locale = addFallbackLocale(args.locale, this.payload);
|
|
637
673
|
validateRelationshipIds({
|
|
@@ -870,25 +906,19 @@ export const contentAPIAdapter = (opts)=>({
|
|
|
870
906
|
defaultIDType: 'text',
|
|
871
907
|
init: ({ payload })=>{
|
|
872
908
|
const clientVersionHeaders = getClientVersionHeaders();
|
|
873
|
-
const
|
|
874
|
-
baseUrl: opts.url,
|
|
875
|
-
headers: clientVersionHeaders
|
|
876
|
-
});
|
|
877
|
-
const middlewareOpts = {
|
|
909
|
+
const contentApi = createContentApiClient({
|
|
878
910
|
auth: opts.auth,
|
|
911
|
+
baseUrl: opts.url,
|
|
879
912
|
contentSystemId: opts.contentSystemId,
|
|
880
|
-
logger: payload.logger
|
|
881
|
-
|
|
882
|
-
};
|
|
883
|
-
client.use(createAuthMiddleware(middlewareOpts));
|
|
884
|
-
client.use(createErrorMiddleware(middlewareOpts));
|
|
913
|
+
logger: payload.logger
|
|
914
|
+
});
|
|
885
915
|
return createDatabaseAdapter({
|
|
886
916
|
name: 'content-api',
|
|
887
917
|
allowIDOnCreate: opts.allowIDOnCreate ?? false,
|
|
888
918
|
auth: opts.auth,
|
|
889
919
|
beginTransaction: ()=>Promise.resolve(null),
|
|
890
920
|
clearDatabase: clearDatabase,
|
|
891
|
-
client,
|
|
921
|
+
client: contentApi.api,
|
|
892
922
|
clientVersionHeaders,
|
|
893
923
|
commitTransaction: async ()=>{},
|
|
894
924
|
connect: connect,
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export { figmaContentSystem } from './plugin/adapter.js';
|
|
|
4
4
|
export type { FigmaContentSystemOptions } from './plugin/adapter.js';
|
|
5
5
|
export { buildFigmaConfig } from './plugin/build-config.js';
|
|
6
6
|
export type { FigmaConfig } from './plugin/build-config.js';
|
|
7
|
+
export { FigmaEnvironmentError } from './plugin/environment-error.js';
|
|
7
8
|
export { passesMakeViewerWriteGate } from './plugin/make-permission-access/make-permission-access.js';
|
package/dist/index.js
CHANGED
|
@@ -4,5 +4,6 @@ export { contentAPIAdapter } from './db-content-api/index.js';
|
|
|
4
4
|
export { figmaContentSystem } from './plugin/adapter.js';
|
|
5
5
|
// Export buildConfig wrapper and its config type
|
|
6
6
|
export { buildFigmaConfig } from './plugin/build-config.js';
|
|
7
|
+
export { FigmaEnvironmentError } from './plugin/environment-error.js';
|
|
7
8
|
// Export the Make permission predicate for slug-specific baseAccess overrides.
|
|
8
9
|
export { passesMakeViewerWriteGate } from './plugin/make-permission-access/make-permission-access.js';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useAuth } from '@payloadcms/ui';
|
|
3
|
+
import { useAuth, useTranslation } from '@payloadcms/ui';
|
|
4
4
|
import { useState } from 'react';
|
|
5
5
|
import { FigmaAvatarPlaceholder, isValidImageUrl } from '../FigmaAvatarPlaceholder/index.js';
|
|
6
6
|
import './index.scss';
|
|
7
7
|
const baseClass = 'figma-avatar';
|
|
8
8
|
export const FigmaAvatar = ()=>{
|
|
9
9
|
const { user } = useAuth();
|
|
10
|
+
const { t } = useTranslation();
|
|
10
11
|
const [hasError, setHasError] = useState(false);
|
|
11
12
|
const figmaImageUrl = user?.figmaImageUrl;
|
|
12
13
|
if (!figmaImageUrl || hasError || !isValidImageUrl(figmaImageUrl)) {
|
|
@@ -15,7 +16,7 @@ export const FigmaAvatar = ()=>{
|
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
18
|
return /*#__PURE__*/ _jsx("img", {
|
|
18
|
-
alt:
|
|
19
|
+
alt: t('figma:profile'),
|
|
19
20
|
className: `${baseClass}__image`,
|
|
20
21
|
height: 25,
|
|
21
22
|
onError: ()=>setHasError(true),
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useTranslation } from '@payloadcms/ui';
|
|
3
4
|
import { useState } from 'react';
|
|
4
5
|
import { FigmaAvatarPlaceholder, isValidImageUrl } from '../FigmaAvatarPlaceholder/index.js';
|
|
5
6
|
import './index.scss';
|
|
6
7
|
const baseClass = 'figma-avatar-cell';
|
|
7
8
|
export const FigmaAvatarCell = ({ cellData })=>{
|
|
9
|
+
const { t } = useTranslation();
|
|
8
10
|
const [hasError, setHasError] = useState(false);
|
|
9
11
|
const figmaImageUrl = cellData;
|
|
10
12
|
if (!figmaImageUrl || hasError || !isValidImageUrl(figmaImageUrl)) {
|
|
@@ -13,7 +15,7 @@ export const FigmaAvatarCell = ({ cellData })=>{
|
|
|
13
15
|
});
|
|
14
16
|
}
|
|
15
17
|
return /*#__PURE__*/ _jsx("img", {
|
|
16
|
-
alt:
|
|
18
|
+
alt: t('figma:avatar'),
|
|
17
19
|
className: `${baseClass}__image`,
|
|
18
20
|
height: 20,
|
|
19
21
|
onError: ()=>setHasError(true),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useConfig, useSearchParams } from '@payloadcms/ui';
|
|
3
|
+
import { useConfig, useSearchParams, useTranslation } from '@payloadcms/ui';
|
|
4
4
|
import React, { useEffect, useState } from 'react';
|
|
5
5
|
import { getSearchParam } from '../../utils/getSearchParam.js';
|
|
6
6
|
import { resolveParentTargetOrigin, setupIframeAutoLogin } from './iframeAutoLogin.js';
|
|
@@ -60,8 +60,10 @@ const FigmaIcon = ()=>/*#__PURE__*/ _jsx("svg", {
|
|
|
60
60
|
fillRule: "evenodd"
|
|
61
61
|
})
|
|
62
62
|
});
|
|
63
|
-
const PayloadAdminLoadingShimmer = ()
|
|
64
|
-
|
|
63
|
+
const PayloadAdminLoadingShimmer = ()=>{
|
|
64
|
+
const { t } = useTranslation();
|
|
65
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
66
|
+
"aria-label": t('figma:signingIn'),
|
|
65
67
|
"aria-live": "polite",
|
|
66
68
|
className: `${baseClass}__admin-shimmer`,
|
|
67
69
|
role: "status",
|
|
@@ -111,8 +113,10 @@ const PayloadAdminLoadingShimmer = ()=>/*#__PURE__*/ _jsx("div", {
|
|
|
111
113
|
]
|
|
112
114
|
})
|
|
113
115
|
});
|
|
116
|
+
};
|
|
114
117
|
export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
|
|
115
118
|
const { config: { admin: { user: userSlug }, routes: { api }, serverURL } } = useConfig();
|
|
119
|
+
const { t } = useTranslation();
|
|
116
120
|
const [authorizeURL, setAuthorizeURL] = useState('');
|
|
117
121
|
const [isInIframe, setIsInIframe] = useState(null);
|
|
118
122
|
const [autoLoginFailed, setAutoLoginFailed] = useState(false);
|
|
@@ -229,7 +233,7 @@ export const DefaultLoginButton = ({ disabled, endpointSlug })=>{
|
|
|
229
233
|
/*#__PURE__*/ _jsx(FigmaIcon, {}),
|
|
230
234
|
/*#__PURE__*/ _jsx("span", {
|
|
231
235
|
className: `${baseClass}__text`,
|
|
232
|
-
children:
|
|
236
|
+
children: t('figma:logInWithFigma')
|
|
233
237
|
})
|
|
234
238
|
]
|
|
235
239
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Logout, useConfig } from '@payloadcms/ui';
|
|
3
|
+
import { Logout, useConfig, useTranslation } from '@payloadcms/ui';
|
|
4
4
|
import { formatAdminURL } from 'payload/shared';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import './index.scss';
|
|
@@ -12,6 +12,7 @@ export const LogoutButton = ({ disabled, endpointSlug })=>{
|
|
|
12
12
|
// logout. Redirect to the site root instead so the user actually stays
|
|
13
13
|
// logged out. Outside an iframe, keep the original behavior of redirecting
|
|
14
14
|
// back to /admin.
|
|
15
|
+
const { t } = useTranslation();
|
|
15
16
|
const [redirect, setRedirect] = React.useState('');
|
|
16
17
|
React.useEffect(()=>{
|
|
17
18
|
const protocol = window.location.protocol;
|
|
@@ -44,7 +45,7 @@ export const LogoutButton = ({ disabled, endpointSlug })=>{
|
|
|
44
45
|
return /*#__PURE__*/ _jsx("div", {
|
|
45
46
|
className: baseClass,
|
|
46
47
|
children: /*#__PURE__*/ _jsx("a", {
|
|
47
|
-
"aria-label":
|
|
48
|
+
"aria-label": t('authentication:logout'),
|
|
48
49
|
href: `${serverURL}${api}/${userSlug}/${endpointSlug}/logout?redirect=${encodeURIComponent(redirect)}`,
|
|
49
50
|
children: /*#__PURE__*/ _jsxs("svg", {
|
|
50
51
|
className: "icon icon--logout",
|
package/dist/oauth/defaults.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import crypto from 'crypto';
|
|
1
2
|
import { parseCookies } from 'payload';
|
|
2
|
-
import { v4 as uuid } from 'uuid';
|
|
3
3
|
import { hasUserTokenPropsChanged } from './utilities/hasUserTokenPropsChanged.js';
|
|
4
4
|
import { isDuplicateKeyError } from './utilities/isDuplicateKeyError.js';
|
|
5
5
|
export const DEFAULT_USER_INFO_COOKIE_NAME = 'figma-user-info';
|
|
@@ -95,7 +95,7 @@ export const defaultVerify = ({ collection, strategyName, userInfoCookieName = D
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
if (typeof collection.auth === 'object' && !collection.auth.disableLocalStrategy) {
|
|
98
|
-
newUser.password =
|
|
98
|
+
newUser.password = crypto.randomUUID();
|
|
99
99
|
}
|
|
100
100
|
try {
|
|
101
101
|
user = await payload.create({
|
|
@@ -8,6 +8,7 @@ import { exchangeCodeForAccessToken } from '../utilities/exchangeCodeForAccessTo
|
|
|
8
8
|
import { extractOrigin } from '../utilities/extractOrigin.js';
|
|
9
9
|
import { buildCsrfCookieClearHeader, getOAuthCallbackPath, OAUTH_STATE_CSRF_COOKIE_NAME } from '../utilities/getAuthorizeURL.js';
|
|
10
10
|
import { isAbsoluteURL } from '../utilities/isAbsoluteURL.js';
|
|
11
|
+
import { resolvePayloadRedirect } from '../utilities/resolvePayloadRedirect.js';
|
|
11
12
|
export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug, pluginOptions, strategy })=>({
|
|
12
13
|
handler: async (req)=>{
|
|
13
14
|
const { config } = req.payload;
|
|
@@ -196,11 +197,7 @@ export const getLoginEndpoint = ({ collection, collectionOptions, endpointSlug,
|
|
|
196
197
|
// is single-use; leaving it around lets a replay try again.
|
|
197
198
|
req.responseHeaders.append('Set-Cookie', buildCsrfCookieClearHeader());
|
|
198
199
|
if (payloadRedirect) {
|
|
199
|
-
|
|
200
|
-
redirectToUse = payloadRedirect;
|
|
201
|
-
} else {
|
|
202
|
-
redirectToUse += payloadRedirect;
|
|
203
|
-
}
|
|
200
|
+
redirectToUse = resolvePayloadRedirect(payloadRedirect, redirectToUse);
|
|
204
201
|
req.responseHeaders.append('Set-Cookie', // Match the attributes the cookie was set with so the clear removes it
|
|
205
202
|
// in the cross-site Make iframe.
|
|
206
203
|
`payloadRedirect=${redirectToUse}; Max-Age=0; Path=/; Secure; SameSite=None; Partitioned`);
|
package/dist/oauth/hooks/me.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { CollectionMeHook } from 'payload';
|
|
2
|
+
import type { Strategy } from '../strategy/index.js';
|
|
3
|
+
export declare const getMeHook: ({ strategy }: {
|
|
4
|
+
strategy: Strategy;
|
|
4
5
|
}) => CollectionMeHook;
|
package/dist/oauth/hooks/me.js
CHANGED
|
@@ -1,53 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const cookies = parseCookies(args.req.headers);
|
|
8
|
-
const refreshToken = cookies.get(`${cookieName}-refresh`);
|
|
9
|
-
let token = cookies.get(cookieName);
|
|
10
|
-
let exp;
|
|
11
|
-
if (refreshToken) {
|
|
12
|
-
exp = getTokenExp({
|
|
13
|
-
debugLogger,
|
|
14
|
-
token: refreshToken
|
|
15
|
-
});
|
|
16
|
-
if (exp) {
|
|
17
|
-
return {
|
|
18
|
-
exp,
|
|
19
|
-
user
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (!token) {
|
|
24
|
-
// Parse Authorization header if exists
|
|
25
|
-
const jwtFromHeader = args.req.headers.get('authorization');
|
|
26
|
-
if (typeof jwtFromHeader === 'string' && jwtFromHeader.startsWith('Bearer ')) {
|
|
27
|
-
token = jwtFromHeader.replace('Bearer ', '');
|
|
28
|
-
exp = getTokenExp({
|
|
29
|
-
debugLogger,
|
|
30
|
-
token
|
|
31
|
-
});
|
|
32
|
-
if (exp) {
|
|
33
|
-
return {
|
|
34
|
-
exp,
|
|
35
|
-
user
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (token) {
|
|
41
|
-
exp = getTokenExp({
|
|
42
|
-
debugLogger,
|
|
43
|
-
token
|
|
44
|
-
});
|
|
45
|
-
if (exp) {
|
|
46
|
-
return {
|
|
47
|
-
exp,
|
|
48
|
-
user
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return undefined;
|
|
1
|
+
export const getMeHook = ({ strategy })=>({ args, user })=>{
|
|
2
|
+
const exp = strategy.authenticatedTokenExpirations.get(args.req.headers);
|
|
3
|
+
return exp === undefined ? undefined : {
|
|
4
|
+
exp,
|
|
5
|
+
user
|
|
6
|
+
};
|
|
53
7
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import jwt from 'jsonwebtoken';
|
|
2
2
|
import { generateCookie, parseCookies } from 'payload';
|
|
3
|
+
import { clearSessionCookies } from '../utilities/clearSessionCookies.js';
|
|
3
4
|
import { createCookieOptions } from '../utilities/createCookieOptions.js';
|
|
4
5
|
import { createDebugLogger } from '../utilities/createDebugLogger.js';
|
|
5
6
|
import { getCookieExpiration } from '../utilities/getCookieExpiration.js';
|
|
@@ -69,11 +70,18 @@ export const getRefreshHook = ({ pluginOptions, strategy })=>async ({ args, user
|
|
|
69
70
|
return undefined;
|
|
70
71
|
}
|
|
71
72
|
const result = await refreshTokens({
|
|
73
|
+
headers: args.req.headers,
|
|
72
74
|
payload: args.req.payload,
|
|
73
75
|
refreshToken,
|
|
74
76
|
strategy
|
|
75
77
|
});
|
|
76
|
-
if (
|
|
78
|
+
if (result.status !== 'success') {
|
|
79
|
+
if (result.status === 'rejected') {
|
|
80
|
+
mergeHeaders(clearSessionCookies({
|
|
81
|
+
headers: args.req.headers,
|
|
82
|
+
strategy
|
|
83
|
+
}), args.req.responseHeaders);
|
|
84
|
+
}
|
|
77
85
|
return undefined;
|
|
78
86
|
}
|
|
79
87
|
mergeHeaders(result.headers, args.req.responseHeaders);
|