@payloadcms/figma 0.0.1-alpha.73 → 0.0.1-alpha.75
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/api/control-plane.d.ts +0 -1
- package/dist/api/control-plane.js +0 -2
- package/dist/api/error-response.d.ts +0 -1
- package/dist/api/error-response.js +0 -2
- package/dist/api/figma-api.d.ts +2 -2
- package/dist/api/figma-api.js +33 -5
- package/dist/auth/browser.d.ts +0 -1
- package/dist/auth/browser.js +0 -2
- package/dist/auth/callback-server.d.ts +0 -1
- package/dist/auth/callback-server.js +0 -2
- package/dist/auth/credentials.d.ts +0 -1
- package/dist/auth/credentials.js +0 -2
- package/dist/auth/crypto-utils.d.ts +0 -1
- package/dist/auth/crypto-utils.js +0 -2
- package/dist/auth/jwt-validator.d.ts +22 -6
- package/dist/auth/jwt-validator.js +33 -7
- package/dist/auth/oauth-flow.d.ts +0 -1
- package/dist/auth/oauth-flow.js +0 -2
- package/dist/auth/paste-code.d.ts +0 -1
- package/dist/auth/paste-code.js +0 -2
- package/dist/auth/pkce.d.ts +0 -1
- package/dist/auth/pkce.js +0 -2
- package/dist/auth/project-token.d.ts +0 -1
- package/dist/auth/project-token.js +6 -4
- package/dist/auth/refresh.d.ts +0 -1
- package/dist/auth/refresh.js +0 -2
- package/dist/auth/token-store-migration.d.ts +0 -1
- package/dist/auth/token-store-migration.js +0 -2
- package/dist/auth/token-store.d.ts +0 -1
- package/dist/auth/token-store.js +0 -2
- package/dist/auth/types.d.ts +5 -2
- package/dist/auth/types.js +1 -3
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +7 -2
- package/dist/commands/bootstrap.d.ts +0 -1
- package/dist/commands/bootstrap.js +0 -2
- package/dist/commands/build-lambda-zip.d.ts +0 -1
- package/dist/commands/build-lambda-zip.js +0 -2
- package/dist/commands/debug.d.ts +0 -1
- package/dist/commands/debug.js +0 -2
- package/dist/commands/deploy.d.ts +0 -1
- package/dist/commands/deploy.js +0 -2
- package/dist/commands/dump-tokens.d.ts +0 -1
- package/dist/commands/dump-tokens.js +0 -2
- package/dist/commands/env.d.ts +0 -1
- package/dist/commands/env.js +0 -2
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/init.js +0 -2
- package/dist/commands/list-tokens.d.ts +0 -1
- package/dist/commands/list-tokens.js +0 -2
- package/dist/commands/login.d.ts +0 -1
- package/dist/commands/login.js +0 -2
- package/dist/commands/logout.d.ts +0 -1
- package/dist/commands/logout.js +0 -2
- package/dist/commands/upgrade.d.ts +0 -1
- package/dist/commands/upgrade.js +0 -2
- package/dist/commands/upload-schema.d.ts +8 -0
- package/dist/commands/upload-schema.js +91 -0
- package/dist/config/oauth.d.ts +0 -1
- package/dist/config/oauth.js +0 -2
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -2
- package/dist/db-content-api/generated/content-api-types.d.ts +4188 -592
- package/dist/db-content-api/generated/content-api-types.js +0 -2
- package/dist/db-content-api/index.d.ts +0 -1
- package/dist/db-content-api/index.js +0 -2
- package/dist/db-content-api/temp-utilities/slug.d.ts +0 -1
- package/dist/db-content-api/temp-utilities/slug.js +0 -2
- package/dist/db-content-api/temp-utilities/sorting.d.ts +0 -1
- package/dist/db-content-api/temp-utilities/sorting.js +0 -2
- package/dist/db-content-api/temp-utilities/types.d.ts +0 -1
- package/dist/db-content-api/temp-utilities/types.js +0 -2
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +0 -1
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +0 -2
- package/dist/db-content-api/utilities/auth.d.ts +0 -1
- package/dist/db-content-api/utilities/auth.js +0 -2
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +0 -1
- package/dist/db-content-api/utilities/data/applyDefaults.js +0 -2
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +0 -1
- package/dist/db-content-api/utilities/data/castFieldValue.js +0 -2
- package/dist/db-content-api/utilities/data/index.d.ts +0 -1
- package/dist/db-content-api/utilities/data/index.js +0 -2
- package/dist/db-content-api/utilities/data/pointShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/pointShape.js +43 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +0 -1
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +0 -2
- package/dist/db-content-api/utilities/data/richTextShape.d.ts +3 -0
- package/dist/db-content-api/utilities/data/richTextShape.js +56 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +0 -1
- package/dist/db-content-api/utilities/data/stripFields.js +0 -2
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +0 -1
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +0 -2
- package/dist/db-content-api/utilities/data/validateRelationships.d.ts +0 -1
- package/dist/db-content-api/utilities/data/validateRelationships.js +0 -2
- package/dist/db-content-api/utilities/joins.d.ts +0 -1
- package/dist/db-content-api/utilities/joins.js +0 -2
- package/dist/db-content-api/utilities/locale/index.d.ts +0 -1
- package/dist/db-content-api/utilities/locale/index.js +0 -2
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +0 -1
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +0 -2
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +0 -1
- package/dist/db-content-api/utilities/meta/buildMeta.js +0 -2
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +0 -1
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +0 -2
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +0 -1
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +0 -2
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.d.ts +0 -1
- package/dist/db-content-api/utilities/meta/normalizeLocaleInWhere.js +0 -2
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +56 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +183 -0
- package/dist/db-content-api/utilities/where.d.ts +0 -1
- package/dist/db-content-api/utilities/where.js +0 -2
- package/dist/deploy/schedule-extract-plugin.d.ts +0 -1
- package/dist/deploy/schedule-extract-plugin.js +0 -2
- package/dist/endpoints/health.d.ts +0 -1
- package/dist/endpoints/health.js +0 -2
- package/dist/endpoints/schema.d.ts +0 -1
- package/dist/endpoints/schema.js +0 -2
- package/dist/exports/client.d.ts +0 -1
- package/dist/exports/client.js +0 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2
- package/dist/lib/download-skill.d.ts +0 -1
- package/dist/lib/download-skill.js +0 -2
- package/dist/oauth/components/FigmaAvatar/index.d.ts +0 -1
- package/dist/oauth/components/FigmaAvatar/index.js +0 -2
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +0 -1
- package/dist/oauth/components/FigmaAvatarCell/index.js +0 -2
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +0 -1
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +0 -2
- package/dist/oauth/components/LoginButton/iframeAutoLogin.d.ts +0 -1
- package/dist/oauth/components/LoginButton/iframeAutoLogin.js +0 -2
- package/dist/oauth/components/LoginButton/index.d.ts +0 -1
- package/dist/oauth/components/LoginButton/index.js +3 -5
- package/dist/oauth/components/LogoutButton/index.d.ts +0 -1
- package/dist/oauth/components/LogoutButton/index.js +0 -2
- package/dist/oauth/defaults.d.ts +0 -1
- package/dist/oauth/defaults.js +8 -2
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +4 -8
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js +0 -2
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js +0 -2
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js +0 -2
- package/dist/oauth/exports/client.d.ts +0 -1
- package/dist/oauth/exports/client.js +0 -2
- package/dist/oauth/hooks/afterLogout.d.ts +0 -1
- package/dist/oauth/hooks/afterLogout.js +0 -2
- package/dist/oauth/hooks/me.d.ts +0 -1
- package/dist/oauth/hooks/me.js +0 -2
- package/dist/oauth/hooks/refresh.d.ts +0 -1
- package/dist/oauth/hooks/refresh.js +0 -2
- package/dist/oauth/index.d.ts +0 -1
- package/dist/oauth/index.js +0 -2
- package/dist/oauth/strategy/index.d.ts +0 -1
- package/dist/oauth/strategy/index.js +17 -19
- package/dist/oauth/types.d.ts +0 -1
- package/dist/oauth/types.js +0 -2
- package/dist/oauth/utilities/clearCookie.d.ts +0 -1
- package/dist/oauth/utilities/clearCookie.js +0 -2
- package/dist/oauth/utilities/createCookieOptions.d.ts +0 -1
- package/dist/oauth/utilities/createCookieOptions.js +0 -2
- package/dist/oauth/utilities/createDebugLogger.d.ts +0 -1
- package/dist/oauth/utilities/createDebugLogger.js +0 -2
- package/dist/oauth/utilities/establishSession.d.ts +4 -5
- package/dist/oauth/utilities/establishSession.js +9 -12
- package/dist/oauth/utilities/exchangeCodeForAccessToken.d.ts +0 -1
- package/dist/oauth/utilities/exchangeCodeForAccessToken.js +0 -2
- package/dist/oauth/utilities/extractOrigin.d.ts +0 -1
- package/dist/oauth/utilities/extractOrigin.js +0 -2
- package/dist/oauth/utilities/figmaHostnames.d.ts +0 -1
- package/dist/oauth/utilities/figmaHostnames.js +0 -2
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js +0 -2
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.js +0 -2
- package/dist/oauth/utilities/getCookieExpiration.d.ts +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js +0 -2
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js +0 -2
- package/dist/oauth/utilities/getTokenExp.d.ts +0 -1
- package/dist/oauth/utilities/getTokenExp.js +0 -2
- package/dist/oauth/utilities/getUsernameField.d.ts +0 -1
- package/dist/oauth/utilities/getUsernameField.js +0 -2
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js +0 -2
- package/dist/oauth/utilities/isAbsoluteURL.d.ts +0 -1
- package/dist/oauth/utilities/isAbsoluteURL.js +0 -2
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +0 -1
- package/dist/oauth/utilities/isDuplicateKeyError.js +0 -2
- package/dist/oauth/utilities/mergeHeaders.d.ts +0 -1
- package/dist/oauth/utilities/mergeHeaders.js +0 -2
- package/dist/oauth/utilities/refreshTokens.d.ts +0 -1
- package/dist/oauth/utilities/refreshTokens.js +16 -12
- package/dist/oauth/utilities/withPartitionedCookie.d.ts +0 -1
- package/dist/oauth/utilities/withPartitionedCookie.js +0 -2
- package/dist/oauth/utils/getSearchParam.d.ts +27 -0
- package/dist/oauth/utils/getSearchParam.js +45 -0
- package/dist/plugin/adapter.d.ts +0 -1
- package/dist/plugin/adapter.js +0 -2
- package/dist/plugin/auth-preflight.d.ts +0 -1
- package/dist/plugin/auth-preflight.js +0 -2
- package/dist/plugin/bootstrap-preflight.d.ts +0 -1
- package/dist/plugin/bootstrap-preflight.js +0 -2
- package/dist/plugin/build-config.d.ts +1 -1
- package/dist/plugin/build-config.js +66 -3
- package/dist/plugin/dev-cookie-names.d.ts +0 -1
- package/dist/plugin/dev-cookie-names.js +0 -2
- package/dist/storage-content-api/api-types.d.ts +0 -1
- package/dist/storage-content-api/api-types.js +0 -2
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +0 -1
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +0 -2
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +0 -1
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +0 -2
- package/dist/storage-content-api/client.d.ts +0 -1
- package/dist/storage-content-api/client.js +0 -2
- package/dist/storage-content-api/generateURL.d.ts +0 -1
- package/dist/storage-content-api/generateURL.js +0 -2
- package/dist/storage-content-api/handleDelete.d.ts +0 -1
- package/dist/storage-content-api/handleDelete.js +0 -2
- package/dist/storage-content-api/handleUpload.d.ts +0 -1
- package/dist/storage-content-api/handleUpload.js +0 -2
- package/dist/storage-content-api/index.d.ts +0 -1
- package/dist/storage-content-api/index.js +0 -2
- package/dist/storage-content-api/staticHandler.d.ts +0 -1
- package/dist/storage-content-api/staticHandler.js +0 -2
- package/dist/storage-content-api/types.d.ts +0 -1
- package/dist/storage-content-api/types.js +0 -2
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +0 -1
- package/dist/storage-content-api/utilities/getSafeFilename.js +0 -2
- package/dist/storage-content-api/utilities/index.d.ts +0 -1
- package/dist/storage-content-api/utilities/index.js +0 -2
- package/dist/storage-content-api/utilities/parseClientUploadContext.d.ts +0 -1
- package/dist/storage-content-api/utilities/parseClientUploadContext.js +0 -2
- package/dist/types/config.d.ts +0 -1
- package/dist/types/config.js +0 -2
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -2
- package/dist/utils/adapters/nextjs.d.ts +0 -1
- package/dist/utils/adapters/nextjs.js +0 -2
- package/dist/utils/adapters/nitro.d.ts +0 -1
- package/dist/utils/adapters/nitro.js +0 -2
- package/dist/utils/adapters/vite.d.ts +0 -1
- package/dist/utils/adapters/vite.js +0 -2
- package/dist/utils/asset-collection.d.ts +0 -1
- package/dist/utils/asset-collection.js +0 -2
- package/dist/utils/build-detection.d.ts +0 -1
- package/dist/utils/build-detection.js +0 -2
- package/dist/utils/build-lambda-zip.d.ts +0 -1
- package/dist/utils/build-lambda-zip.js +0 -2
- package/dist/utils/cache-bootstrap.d.ts +0 -1
- package/dist/utils/cache-bootstrap.js +0 -2
- package/dist/utils/config.d.ts +0 -1
- package/dist/utils/config.js +0 -2
- package/dist/utils/deploy-adapter.d.ts +0 -1
- package/dist/utils/deploy-adapter.js +0 -2
- package/dist/utils/download-template.d.ts +0 -1
- package/dist/utils/download-template.js +0 -2
- package/dist/utils/env-management.d.ts +0 -1
- package/dist/utils/env-management.js +0 -2
- package/dist/utils/format-env-suffix.d.ts +0 -1
- package/dist/utils/format-env-suffix.js +0 -2
- package/dist/utils/format.d.ts +0 -1
- package/dist/utils/format.js +0 -2
- package/dist/utils/formatter.d.ts +0 -1
- package/dist/utils/formatter.js +0 -2
- package/dist/utils/fs-utils.d.ts +0 -1
- package/dist/utils/fs-utils.js +0 -2
- package/dist/utils/git.d.ts +0 -1
- package/dist/utils/git.js +0 -2
- package/dist/utils/handle-upgrade.d.ts +0 -1
- package/dist/utils/handle-upgrade.js +0 -2
- package/dist/utils/is-debug.d.ts +0 -1
- package/dist/utils/is-debug.js +0 -2
- package/dist/utils/lambda-config.d.ts +0 -1
- package/dist/utils/lambda-config.js +0 -2
- package/dist/utils/load-payload-config.d.ts +9 -0
- package/dist/utils/load-payload-config.js +27 -0
- package/dist/utils/log.d.ts +0 -1
- package/dist/utils/log.js +0 -2
- package/dist/utils/messages.d.ts +0 -1
- package/dist/utils/messages.js +7 -2
- package/dist/utils/package-manager.d.ts +0 -1
- package/dist/utils/package-manager.js +0 -2
- package/dist/utils/parse-template-spec.d.ts +0 -1
- package/dist/utils/parse-template-spec.js +0 -2
- package/dist/utils/payload-config-ast.d.ts +0 -1
- package/dist/utils/payload-config-ast.js +0 -2
- package/dist/utils/payload-config-finder.d.ts +0 -1
- package/dist/utils/payload-config-finder.js +0 -2
- package/dist/utils/payload-config-modifier.d.ts +0 -1
- package/dist/utils/payload-config-modifier.js +0 -2
- package/dist/utils/payload-package-check.d.ts +0 -1
- package/dist/utils/payload-package-check.js +0 -2
- package/dist/utils/project.d.ts +0 -1
- package/dist/utils/project.js +0 -2
- package/dist/utils/resolve-environment.d.ts +0 -1
- package/dist/utils/resolve-environment.js +0 -2
- package/dist/utils/s3-upload.d.ts +0 -1
- package/dist/utils/s3-upload.js +0 -2
- package/dist/utils/token-display.d.ts +0 -1
- package/dist/utils/token-display.js +0 -2
- package/dist/utils/typescript-validator.d.ts +0 -1
- package/dist/utils/typescript-validator.js +0 -2
- package/dist/utils/version-check.d.ts +0 -1
- package/dist/utils/version-check.js +0 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { generateCookie } from 'payload';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { getPayloadAdminToken } from '../../api/figma-api.js';
|
|
3
|
+
import { validatePayloadAdminToken } from '../../auth/jwt-validator.js';
|
|
4
4
|
import { getInfraEnvironment } from '../../constants.js';
|
|
5
5
|
import { createCookieOptions } from './createCookieOptions.js';
|
|
6
6
|
import { createDebugLogger } from './createDebugLogger.js';
|
|
@@ -16,15 +16,18 @@ export const refreshTokens = async ({ payload, refreshToken, strategy })=>{
|
|
|
16
16
|
// but refresh token is still valid
|
|
17
17
|
// so we will refresh both tokens
|
|
18
18
|
try {
|
|
19
|
-
// Get another
|
|
20
|
-
const
|
|
19
|
+
// Get another Payload Admin token.
|
|
20
|
+
const environmentId = payload.config.custom.figma.environmentId;
|
|
21
|
+
if (!environmentId) {
|
|
22
|
+
throw new Error('Cannot refresh Payload Admin token: environmentId is not configured');
|
|
23
|
+
}
|
|
24
|
+
const { expiresAt, token } = await getPayloadAdminToken({
|
|
21
25
|
type: 'oauth',
|
|
22
26
|
token: refreshToken
|
|
23
|
-
},
|
|
27
|
+
}, environmentId);
|
|
24
28
|
debugLogger.info({
|
|
25
29
|
expiresAt,
|
|
26
|
-
msg: 'Received new
|
|
27
|
-
token
|
|
30
|
+
msg: 'Received new Payload Admin token from Figma API'
|
|
28
31
|
});
|
|
29
32
|
// On error, no user
|
|
30
33
|
if (!token) {
|
|
@@ -35,8 +38,7 @@ export const refreshTokens = async ({ payload, refreshToken, strategy })=>{
|
|
|
35
38
|
}
|
|
36
39
|
if (token) {
|
|
37
40
|
debugLogger.info({
|
|
38
|
-
msg: 'Successfully refreshed
|
|
39
|
-
token
|
|
41
|
+
msg: 'Successfully refreshed Payload Admin token'
|
|
40
42
|
});
|
|
41
43
|
const expires_in = new Date(expiresAt);
|
|
42
44
|
const cookieOptions = createCookieOptions({
|
|
@@ -52,7 +54,11 @@ export const refreshTokens = async ({ payload, refreshToken, strategy })=>{
|
|
|
52
54
|
value: token
|
|
53
55
|
});
|
|
54
56
|
headers.append('Set-Cookie', withPartitionedCookie(tokenCookie));
|
|
55
|
-
const decodedOauthToken = await
|
|
57
|
+
const decodedOauthToken = await validatePayloadAdminToken({
|
|
58
|
+
audience: environmentId,
|
|
59
|
+
environment: getInfraEnvironment(),
|
|
60
|
+
token
|
|
61
|
+
});
|
|
56
62
|
return {
|
|
57
63
|
decodedOauthToken,
|
|
58
64
|
headers,
|
|
@@ -67,5 +73,3 @@ export const refreshTokens = async ({ payload, refreshToken, strategy })=>{
|
|
|
67
73
|
}
|
|
68
74
|
return false;
|
|
69
75
|
};
|
|
70
|
-
|
|
71
|
-
//# sourceMappingURL=refreshTokens.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves a single search-parameter value from the return type of
|
|
3
|
+
* `@payloadcms/ui`'s `useSearchParams` hook in a version-agnostic way.
|
|
4
|
+
*
|
|
5
|
+
* The hook's return shape changed between Payload v3 and v4:
|
|
6
|
+
*
|
|
7
|
+
* **v3** — returns a context object; params are accessed via `searchParams[key]` (`ParsedQs`):
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { useSearchParams } from '@payloadcms/ui'
|
|
10
|
+
* const { searchParams } = useSearchParams()
|
|
11
|
+
* const value = searchParams['redirect'] // string | string[] | ParsedQs | …
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* **v4** — returns a `URLSearchParams`-like object directly; params are accessed via `.get(key)`:
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { useSearchParams } from '@payloadcms/ui'
|
|
17
|
+
* const searchParams = useSearchParams()
|
|
18
|
+
* const value = searchParams.get('redirect') // string | null
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Pass the raw hook return value here and it handles both shapes transparently.
|
|
22
|
+
*
|
|
23
|
+
* @param searchParamsHookResult - Raw return value of `useSearchParams()` from `@payloadcms/ui`.
|
|
24
|
+
* @param key - The query-string parameter name to read.
|
|
25
|
+
* @returns The first string value for `key`, or `undefined` if absent.
|
|
26
|
+
*/
|
|
27
|
+
export declare const getSearchParam: (searchParamsHookResult: unknown, key: string) => string | undefined;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves a single search-parameter value from the return type of
|
|
3
|
+
* `@payloadcms/ui`'s `useSearchParams` hook in a version-agnostic way.
|
|
4
|
+
*
|
|
5
|
+
* The hook's return shape changed between Payload v3 and v4:
|
|
6
|
+
*
|
|
7
|
+
* **v3** — returns a context object; params are accessed via `searchParams[key]` (`ParsedQs`):
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { useSearchParams } from '@payloadcms/ui'
|
|
10
|
+
* const { searchParams } = useSearchParams()
|
|
11
|
+
* const value = searchParams['redirect'] // string | string[] | ParsedQs | …
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* **v4** — returns a `URLSearchParams`-like object directly; params are accessed via `.get(key)`:
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { useSearchParams } from '@payloadcms/ui'
|
|
17
|
+
* const searchParams = useSearchParams()
|
|
18
|
+
* const value = searchParams.get('redirect') // string | null
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Pass the raw hook return value here and it handles both shapes transparently.
|
|
22
|
+
*
|
|
23
|
+
* @param searchParamsHookResult - Raw return value of `useSearchParams()` from `@payloadcms/ui`.
|
|
24
|
+
* @param key - The query-string parameter name to read.
|
|
25
|
+
* @returns The first string value for `key`, or `undefined` if absent.
|
|
26
|
+
*/ export const getSearchParam = (searchParamsHookResult, key)=>{
|
|
27
|
+
// v4 / next/navigation: result is URLSearchParams-like, access via .get()
|
|
28
|
+
if (searchParamsHookResult && typeof searchParamsHookResult === 'object' && 'get' in searchParamsHookResult && typeof searchParamsHookResult.get === 'function') {
|
|
29
|
+
const value = searchParamsHookResult.get(key);
|
|
30
|
+
return typeof value === 'string' ? value : undefined;
|
|
31
|
+
}
|
|
32
|
+
// v3: result is { searchParams: ParsedQs; … }, access via .searchParams[key]
|
|
33
|
+
if (searchParamsHookResult && typeof searchParamsHookResult === 'object' && 'searchParams' in searchParamsHookResult) {
|
|
34
|
+
const legacySearchParams = searchParamsHookResult.searchParams;
|
|
35
|
+
const value = legacySearchParams?.[key];
|
|
36
|
+
if (typeof value === 'string') {
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
// ParsedQs may parse repeated params as an array — take the first entry
|
|
40
|
+
if (Array.isArray(value) && typeof value[0] === 'string') {
|
|
41
|
+
return value[0];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
};
|
package/dist/plugin/adapter.d.ts
CHANGED
package/dist/plugin/adapter.js
CHANGED
|
@@ -47,9 +47,9 @@ export type FigmaConfig = {
|
|
|
47
47
|
} & {
|
|
48
48
|
figma: {
|
|
49
49
|
contentSystemId?: string;
|
|
50
|
+
environmentId?: string;
|
|
50
51
|
storage?: boolean;
|
|
51
52
|
useContentSystem?: boolean;
|
|
52
53
|
};
|
|
53
54
|
} & Omit<Config, 'db' | 'editor' | 'secret'> & Partial<Pick<Config, 'db'>>;
|
|
54
55
|
export declare function buildFigmaConfig(config: FigmaConfig): Promise<SanitizedConfig>;
|
|
55
|
-
//# sourceMappingURL=build-config.d.ts.map
|
|
@@ -51,6 +51,57 @@ import { getDevCookieNames } from './dev-cookie-names.js';
|
|
|
51
51
|
readOnly: true
|
|
52
52
|
},
|
|
53
53
|
label: 'Profile Picture'
|
|
54
|
+
},
|
|
55
|
+
// Virtual (never persisted): populated per-request from the session JWT. The
|
|
56
|
+
// afterRead hook surfaces the claim on the requester's OWN user record only —
|
|
57
|
+
// a JWT describes its bearer, so these are meaningful for req.user, not for
|
|
58
|
+
// reads of other users. See defaults.ts (defaultVerify) which attaches the
|
|
59
|
+
// live claim to req.user.
|
|
60
|
+
{
|
|
61
|
+
name: 'userGroups',
|
|
62
|
+
type: 'text',
|
|
63
|
+
access: {
|
|
64
|
+
read: ({ id, req })=>req.user?.id === id
|
|
65
|
+
},
|
|
66
|
+
admin: {
|
|
67
|
+
readOnly: true
|
|
68
|
+
},
|
|
69
|
+
hasMany: true,
|
|
70
|
+
hooks: {
|
|
71
|
+
afterRead: [
|
|
72
|
+
({ data, req })=>data?.id !== undefined && req.user?.id === data.id ? req.user.userGroups : undefined
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
label: 'User Groups',
|
|
76
|
+
virtual: true
|
|
77
|
+
},
|
|
78
|
+
// KEEP_IN_SYNC(sinatra/controllers/api/api_payload_control_plane.rb) — resolve_make_permission
|
|
79
|
+
{
|
|
80
|
+
name: 'makePermission',
|
|
81
|
+
type: 'select',
|
|
82
|
+
access: {
|
|
83
|
+
read: ({ id, req })=>req.user?.id === id
|
|
84
|
+
},
|
|
85
|
+
admin: {
|
|
86
|
+
readOnly: true
|
|
87
|
+
},
|
|
88
|
+
hooks: {
|
|
89
|
+
afterRead: [
|
|
90
|
+
({ data, req })=>data?.id !== undefined && req.user?.id === data.id ? req.user.makePermission : undefined
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
label: 'Make Permission',
|
|
94
|
+
options: [
|
|
95
|
+
{
|
|
96
|
+
label: 'View',
|
|
97
|
+
value: 'view'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
label: 'Edit',
|
|
101
|
+
value: 'edit'
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
virtual: true
|
|
54
105
|
}
|
|
55
106
|
];
|
|
56
107
|
function missingOAuthCredential(name) {
|
|
@@ -176,6 +227,7 @@ export async function buildFigmaConfig(config) {
|
|
|
176
227
|
const envConfig = getEnvConfig();
|
|
177
228
|
// Resolve contentSystemId: config first, env var, then local store fallback (dev)
|
|
178
229
|
let { contentSystemId } = config.figma;
|
|
230
|
+
let environmentId = config.figma.environmentId ?? process.env.FIGMA_EID;
|
|
179
231
|
contentSystemId ??= process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID;
|
|
180
232
|
let bootstrapData = null;
|
|
181
233
|
let bootstrapReason = null;
|
|
@@ -202,9 +254,21 @@ export async function buildFigmaConfig(config) {
|
|
|
202
254
|
}
|
|
203
255
|
if (bootstrapData) {
|
|
204
256
|
contentSystemId = bootstrapData.contentSystemId;
|
|
257
|
+
environmentId ??= bootstrapData.tenantInstanceId;
|
|
205
258
|
}
|
|
206
259
|
}
|
|
207
260
|
}
|
|
261
|
+
if (!environmentId) {
|
|
262
|
+
const projectId = process.env.FIGMA_PROJECT_ID ?? getEnvVarSync(process.cwd(), 'FIGMA_PROJECT_ID');
|
|
263
|
+
const environmentName = process.env.FIGMA_ENVIRONMENT_NAME ?? getEnvVarSync(process.cwd(), 'FIGMA_ENVIRONMENT_NAME');
|
|
264
|
+
if (projectId && environmentName) {
|
|
265
|
+
bootstrapData ??= getTokenStore().getBootstrapData(projectId, environmentName);
|
|
266
|
+
environmentId = bootstrapData?.tenantInstanceId;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (!environmentId) {
|
|
270
|
+
throw new Error('Environment ID could not be resolved. Set FIGMA_EID or initialize the project.');
|
|
271
|
+
}
|
|
208
272
|
if (!contentSystemId) {
|
|
209
273
|
logMissingContentSystemId(bootstrapReason ?? {
|
|
210
274
|
kind: 'no-config'
|
|
@@ -273,7 +337,8 @@ export async function buildFigmaConfig(config) {
|
|
|
273
337
|
custom: {
|
|
274
338
|
figma: {
|
|
275
339
|
...config.figma,
|
|
276
|
-
contentSystemId
|
|
340
|
+
contentSystemId,
|
|
341
|
+
environmentId
|
|
277
342
|
}
|
|
278
343
|
},
|
|
279
344
|
db,
|
|
@@ -359,5 +424,3 @@ export async function buildFigmaConfig(config) {
|
|
|
359
424
|
// Delegate to Payload's buildConfig
|
|
360
425
|
return await payloadBuildConfig(configWithFigmaDefaults);
|
|
361
426
|
}
|
|
362
|
-
|
|
363
|
-
//# sourceMappingURL=build-config.js.map
|
|
@@ -3,4 +3,3 @@ import type { UploadPaths } from './api-types.js';
|
|
|
3
3
|
import type { StorageClientConfig } from './types.js';
|
|
4
4
|
export type StorageClient = ReturnType<typeof createClient<UploadPaths>>;
|
|
5
5
|
export declare function createStorageClient(config: StorageClientConfig): StorageClient;
|
|
6
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -4,5 +4,3 @@ export const getGenerateURL = ({ baseUrl })=>({ collection, filename, prefix = '
|
|
|
4
4
|
const fileKey = path.posix.join(prefix, filename);
|
|
5
5
|
return `${baseUrl}/api/v0/uploads/download/${collectionId}/${encodeURIComponent(fileKey)}`;
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=generateURL.js.map
|
|
@@ -2,4 +2,3 @@ import type { Adapter } from '@payloadcms/plugin-cloud-storage/types';
|
|
|
2
2
|
import type { StorageClientConfig } from './types.js';
|
|
3
3
|
export type { StorageClientConfig } from './types.js';
|
|
4
4
|
export declare function contentApiStorageAdapter(config: StorageClientConfig): Adapter;
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/types/config.d.ts
CHANGED
package/dist/types/config.js
CHANGED
package/dist/types.d.ts
CHANGED
package/dist/types.js
CHANGED