@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,3 +1,2 @@
|
|
|
1
1
|
import type { Payload } from 'payload';
|
|
2
2
|
export declare function addFallbackSort(sort: string | string[] | undefined, payload: Payload, collectionSlug: string | string[], defaultSort?: string | string[]): string | string[] | undefined;
|
|
3
|
-
//# sourceMappingURL=sorting.d.ts.map
|
|
@@ -4,4 +4,3 @@ import type { Field } from 'payload';
|
|
|
4
4
|
* This handles defaults for nested structures (arrays, groups) which traverseFields doesn't handle
|
|
5
5
|
*/
|
|
6
6
|
export declare function applyDefaults(data: Record<string, unknown>, fields: Field[]): void;
|
|
7
|
-
//# sourceMappingURL=applyDefaults.d.ts.map
|
|
@@ -46,4 +46,3 @@ export declare function dataToContentAPI(payload: Payload, collectionSlug: strin
|
|
|
46
46
|
export declare function resolveVersionContent(version: unknown, versionMeta: Record<string, unknown>): unknown;
|
|
47
47
|
export declare function dataFromContentAPI(payload: Payload, collectionSlug: string, data: unknown, locale?: string): unknown;
|
|
48
48
|
export {};
|
|
49
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload stores a point as GeoJSON; the v1 server uses a bare `[lng, lat]`
|
|
3
|
+
* tuple. Unwrap on write, re-wrap on read so afterRead can restore the tuple.
|
|
4
|
+
*/ function isPlainObject(value) {
|
|
5
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
function isCoordinateTuple(value) {
|
|
8
|
+
return Array.isArray(value) && value.length === 2 && value.every((v)=>typeof v === 'number');
|
|
9
|
+
}
|
|
10
|
+
function pointLeafToWire(value) {
|
|
11
|
+
if (isPlainObject(value) && isCoordinateTuple(value.coordinates)) {
|
|
12
|
+
return value.coordinates;
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
function pointLeafFromWire(value) {
|
|
17
|
+
if (isCoordinateTuple(value)) {
|
|
18
|
+
return {
|
|
19
|
+
type: 'Point',
|
|
20
|
+
coordinates: value
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
function mapPoint(field, value, mapLeaf) {
|
|
26
|
+
if (field.type !== 'point' || value === null || value === undefined) {
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
if ('localized' in field && field.localized && isPlainObject(value)) {
|
|
30
|
+
const result = {};
|
|
31
|
+
for (const [locale, localeValue] of Object.entries(value)){
|
|
32
|
+
result[locale] = mapLeaf(localeValue);
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
return mapLeaf(value);
|
|
37
|
+
}
|
|
38
|
+
export function encodePointForWrite(field, value) {
|
|
39
|
+
return mapPoint(field, value, pointLeafToWire);
|
|
40
|
+
}
|
|
41
|
+
export function decodePointFromRead(field, value) {
|
|
42
|
+
return mapPoint(field, value, pointLeafFromWire);
|
|
43
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Field, Payload, TabAsField } from 'payload';
|
|
2
|
+
export declare function encodeRichTextForWrite(field: Field | TabAsField, value: unknown): unknown;
|
|
3
|
+
export declare function decodeRichTextFromRead(field: Field | TabAsField, value: unknown, payload: Payload, fieldPath: string, collectionSlug: string): unknown;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The v1 server stores richText as a serialized JSON string, so stringify on
|
|
3
|
+
* write and parse on read. A localized richText is a per-locale map, serialized
|
|
4
|
+
* and parsed per entry (not as one blob).
|
|
5
|
+
*/ function isPlainObject(value) {
|
|
6
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function richTextLeafToWire(value) {
|
|
9
|
+
if (value === null || value === undefined || typeof value === 'string') {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
return JSON.stringify(value);
|
|
13
|
+
}
|
|
14
|
+
export function encodeRichTextForWrite(field, value) {
|
|
15
|
+
if (field.type !== 'richText' || value === null || value === undefined) {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
if ('localized' in field && field.localized && isPlainObject(value)) {
|
|
19
|
+
const result = {};
|
|
20
|
+
for (const [locale, localeValue] of Object.entries(value)){
|
|
21
|
+
result[locale] = richTextLeafToWire(localeValue);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
return richTextLeafToWire(value);
|
|
26
|
+
}
|
|
27
|
+
function richTextLeafFromWire(value, onError) {
|
|
28
|
+
if (typeof value !== 'string') {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(value);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
onError(error);
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function decodeRichTextFromRead(field, value, payload, fieldPath, collectionSlug) {
|
|
39
|
+
if (field.type !== 'richText' || value === null || value === undefined) {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
const onError = (error)=>{
|
|
43
|
+
payload.logger.warn({
|
|
44
|
+
err: error instanceof Error ? error : new Error(String(error)),
|
|
45
|
+
msg: `Failed to parse richtext field '${fieldPath}' in collection '${collectionSlug}'`
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
if ('localized' in field && field.localized && isPlainObject(value)) {
|
|
49
|
+
const result = {};
|
|
50
|
+
for (const [locale, localeValue] of Object.entries(value)){
|
|
51
|
+
result[locale] = richTextLeafFromWire(localeValue, onError);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
return richTextLeafFromWire(value, onError);
|
|
56
|
+
}
|
|
@@ -50,4 +50,3 @@ type ContentAPIJoin = components['schemas']['JoinClause'][number];
|
|
|
50
50
|
*/
|
|
51
51
|
export declare function convertPayloadJoinsToContentAPI(payload: Payload, collectionSlug: string, joins: false | JoinQuery | undefined, locale?: string): ContentAPIJoin[] | undefined;
|
|
52
52
|
export {};
|
|
53
|
-
//# sourceMappingURL=joins.d.ts.map
|
|
@@ -7,4 +7,3 @@ import type { Payload } from 'payload';
|
|
|
7
7
|
* Returns undefined for 'all' and '*' (special Payload values for returning all locales).
|
|
8
8
|
*/
|
|
9
9
|
export declare function addFallbackLocale(locale: null | string | undefined, payload: Payload): string | undefined;
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -8,4 +8,3 @@ import type { Payload } from 'payload';
|
|
|
8
8
|
* @returns Array of dot-notation paths to localized fields (e.g., ['title', 'metadata.description'])
|
|
9
9
|
*/
|
|
10
10
|
export declare function buildLocalizedPaths(payload: Payload, collectionSlug: string): string[];
|
|
11
|
-
//# sourceMappingURL=buildLocalizedPaths.d.ts.map
|
|
@@ -14,4 +14,3 @@ import type { PathTypesRecord } from '../../temp-utilities/types.js';
|
|
|
14
14
|
* - The locale-specific path (e.g. "localizedBlocks.en") IS marked as 'array'
|
|
15
15
|
*/
|
|
16
16
|
export declare function buildPathTypes(payload: Payload, collectionSlug: string, where: undefined | Where): PathTypesRecord;
|
|
17
|
-
//# sourceMappingURL=buildPathTypes.d.ts.map
|
|
@@ -7,4 +7,3 @@ import type { Payload, Where } from 'payload';
|
|
|
7
7
|
* Returns the original where clause if no transformation is needed.
|
|
8
8
|
*/
|
|
9
9
|
export declare function normalizeLocaleInWhere(where: undefined | Where, payload: Payload, collectionSlug: string, locale: string | undefined): undefined | Where;
|
|
10
|
-
//# sourceMappingURL=normalizeLocaleInWhere.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Config } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Wire form of the v1 `DocumentSchema` sent on every request so the server can
|
|
4
|
+
* classify each queried path against the index tables. Paths are
|
|
5
|
+
* period-delimited (e.g. `author.name`).
|
|
6
|
+
*/
|
|
7
|
+
export interface DocumentSchemaWire {
|
|
8
|
+
collections: Record<string, WireCollectionSchema>;
|
|
9
|
+
version: 1;
|
|
10
|
+
}
|
|
11
|
+
interface WireCollectionSchema {
|
|
12
|
+
hints: WireHint[];
|
|
13
|
+
name: string;
|
|
14
|
+
paths: Record<string, WireFieldSchema>;
|
|
15
|
+
}
|
|
16
|
+
type WireHint = {
|
|
17
|
+
paths: string[];
|
|
18
|
+
type: 'unique';
|
|
19
|
+
};
|
|
20
|
+
type WireFieldSchema = {
|
|
21
|
+
collection: string | string[];
|
|
22
|
+
on: string;
|
|
23
|
+
type: 'join';
|
|
24
|
+
} | {
|
|
25
|
+
collection: string | string[];
|
|
26
|
+
hasMany: boolean;
|
|
27
|
+
localized: boolean;
|
|
28
|
+
type: 'relationship' | 'upload';
|
|
29
|
+
unique: boolean;
|
|
30
|
+
} | {
|
|
31
|
+
format: 'lexical';
|
|
32
|
+
localized: boolean;
|
|
33
|
+
type: 'richText';
|
|
34
|
+
} | {
|
|
35
|
+
hasMany: boolean;
|
|
36
|
+
localized: boolean;
|
|
37
|
+
type: 'group';
|
|
38
|
+
} | {
|
|
39
|
+
hasMany: boolean;
|
|
40
|
+
localized: boolean;
|
|
41
|
+
type: 'number' | 'select' | 'text';
|
|
42
|
+
unique: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
localized: boolean;
|
|
45
|
+
type: 'array' | 'blocks';
|
|
46
|
+
} | {
|
|
47
|
+
localized: boolean;
|
|
48
|
+
type: 'checkbox' | 'date' | 'json' | 'radio';
|
|
49
|
+
} | {
|
|
50
|
+
localized: boolean;
|
|
51
|
+
type: 'code' | 'email' | 'point' | 'textarea';
|
|
52
|
+
unique: boolean;
|
|
53
|
+
};
|
|
54
|
+
export declare function buildDocumentSchema(config: Config): DocumentSchemaWire;
|
|
55
|
+
export declare function buildVersionDocumentSchema(schema: DocumentSchemaWire, targetCollectionSlug: string): DocumentSchemaWire;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
export function buildDocumentSchema(config) {
|
|
2
|
+
const collections = {};
|
|
3
|
+
const blocksBySlug = new Map();
|
|
4
|
+
for (const block of config.blocks ?? []){
|
|
5
|
+
blocksBySlug.set(block.slug, block);
|
|
6
|
+
}
|
|
7
|
+
for (const collection of config.collections ?? []){
|
|
8
|
+
collections[collection.slug] = buildCollectionSchema(collection.slug, collection.fields, blocksBySlug);
|
|
9
|
+
}
|
|
10
|
+
for (const global of config.globals ?? []){
|
|
11
|
+
const slug = `_global-${global.slug}`;
|
|
12
|
+
collections[slug] = buildCollectionSchema(slug, global.fields, blocksBySlug);
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
collections,
|
|
16
|
+
version: 1
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function buildVersionDocumentSchema(schema, targetCollectionSlug) {
|
|
20
|
+
const target = schema.collections[targetCollectionSlug];
|
|
21
|
+
if (!target) {
|
|
22
|
+
return schema;
|
|
23
|
+
}
|
|
24
|
+
const prefixedPaths = {};
|
|
25
|
+
for (const [path, fieldSchema] of Object.entries(target.paths)){
|
|
26
|
+
prefixedPaths[`version.${path}`] = fieldSchema;
|
|
27
|
+
}
|
|
28
|
+
prefixedPaths['version._payloadAutosave'] = {
|
|
29
|
+
type: 'checkbox',
|
|
30
|
+
localized: false
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
...schema,
|
|
34
|
+
collections: {
|
|
35
|
+
...schema.collections,
|
|
36
|
+
[targetCollectionSlug]: {
|
|
37
|
+
...target,
|
|
38
|
+
paths: prefixedPaths
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function buildCollectionSchema(name, fields, blocksBySlug) {
|
|
44
|
+
const paths = {};
|
|
45
|
+
collectPaths(fields, '', false, paths, blocksBySlug);
|
|
46
|
+
return {
|
|
47
|
+
name,
|
|
48
|
+
hints: [],
|
|
49
|
+
paths
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function collectPaths(fields, prefix, absorbed, paths, blocksBySlug) {
|
|
53
|
+
for (const field of fields){
|
|
54
|
+
if (field.type === 'row' || field.type === 'collapsible' || field.type === 'group' && (!('name' in field) || !field.name)) {
|
|
55
|
+
collectPaths(field.fields, prefix, absorbed, paths, blocksBySlug);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (field.type === 'tabs') {
|
|
59
|
+
for (const tab of field.tabs){
|
|
60
|
+
const tabOwnLocalized = 'localized' in tab && tab.localized === true;
|
|
61
|
+
if ('name' in tab && tab.name) {
|
|
62
|
+
paths[`${prefix}${tab.name}`] = {
|
|
63
|
+
type: 'group',
|
|
64
|
+
hasMany: false,
|
|
65
|
+
localized: tabOwnLocalized && !absorbed
|
|
66
|
+
};
|
|
67
|
+
collectPaths(tab.fields, `${prefix}${tab.name}.`, absorbed || tabOwnLocalized, paths, blocksBySlug);
|
|
68
|
+
} else {
|
|
69
|
+
collectPaths(tab.fields, prefix, absorbed, paths, blocksBySlug);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (field.type === 'ui' || !('name' in field) || !field.name) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
collectNamedField(field, prefix, absorbed, paths, blocksBySlug);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function collectNamedField(field, prefix, absorbed, paths, blocksBySlug) {
|
|
81
|
+
if (!('name' in field) || !field.name) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const path = `${prefix}${field.name}`;
|
|
85
|
+
const localized = 'localized' in field && field.localized === true && !absorbed;
|
|
86
|
+
const childAbsorbed = absorbed || 'localized' in field && field.localized === true;
|
|
87
|
+
const hasMany = 'hasMany' in field ? Boolean(field.hasMany) : false;
|
|
88
|
+
const unique = 'unique' in field ? Boolean(field.unique) : false;
|
|
89
|
+
switch(field.type){
|
|
90
|
+
case 'array':
|
|
91
|
+
paths[path] = {
|
|
92
|
+
type: 'array',
|
|
93
|
+
localized
|
|
94
|
+
};
|
|
95
|
+
collectPaths(field.fields, `${path}.`, childAbsorbed, paths, blocksBySlug);
|
|
96
|
+
return;
|
|
97
|
+
case 'blocks':
|
|
98
|
+
{
|
|
99
|
+
paths[path] = {
|
|
100
|
+
type: 'blocks',
|
|
101
|
+
localized
|
|
102
|
+
};
|
|
103
|
+
paths[`${path}.blockType`] = {
|
|
104
|
+
type: 'text',
|
|
105
|
+
hasMany: false,
|
|
106
|
+
localized: false,
|
|
107
|
+
unique: false
|
|
108
|
+
};
|
|
109
|
+
const blockFields = [];
|
|
110
|
+
for (const block of field.blocks){
|
|
111
|
+
const resolved = typeof block === 'string' ? blocksBySlug.get(block) : block;
|
|
112
|
+
if (resolved) {
|
|
113
|
+
blockFields.push(...resolved.fields);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
collectPaths(blockFields, `${path}.`, childAbsorbed, paths, blocksBySlug);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
case 'checkbox':
|
|
120
|
+
case 'date':
|
|
121
|
+
case 'json':
|
|
122
|
+
case 'radio':
|
|
123
|
+
paths[path] = {
|
|
124
|
+
type: field.type,
|
|
125
|
+
localized
|
|
126
|
+
};
|
|
127
|
+
return;
|
|
128
|
+
case 'code':
|
|
129
|
+
case 'email':
|
|
130
|
+
case 'point':
|
|
131
|
+
case 'textarea':
|
|
132
|
+
paths[path] = {
|
|
133
|
+
type: field.type,
|
|
134
|
+
localized,
|
|
135
|
+
unique
|
|
136
|
+
};
|
|
137
|
+
return;
|
|
138
|
+
case 'group':
|
|
139
|
+
paths[path] = {
|
|
140
|
+
type: 'group',
|
|
141
|
+
hasMany,
|
|
142
|
+
localized
|
|
143
|
+
};
|
|
144
|
+
collectPaths(field.fields, `${path}.`, childAbsorbed, paths, blocksBySlug);
|
|
145
|
+
return;
|
|
146
|
+
case 'join':
|
|
147
|
+
paths[path] = {
|
|
148
|
+
type: 'join',
|
|
149
|
+
collection: field.collection,
|
|
150
|
+
on: field.on
|
|
151
|
+
};
|
|
152
|
+
return;
|
|
153
|
+
case 'number':
|
|
154
|
+
case 'select':
|
|
155
|
+
case 'text':
|
|
156
|
+
paths[path] = {
|
|
157
|
+
type: field.type,
|
|
158
|
+
hasMany,
|
|
159
|
+
localized,
|
|
160
|
+
unique
|
|
161
|
+
};
|
|
162
|
+
return;
|
|
163
|
+
case 'relationship':
|
|
164
|
+
case 'upload':
|
|
165
|
+
paths[path] = {
|
|
166
|
+
type: field.type,
|
|
167
|
+
collection: field.relationTo,
|
|
168
|
+
hasMany,
|
|
169
|
+
localized,
|
|
170
|
+
unique
|
|
171
|
+
};
|
|
172
|
+
return;
|
|
173
|
+
case 'richText':
|
|
174
|
+
paths[path] = {
|
|
175
|
+
type: 'richText',
|
|
176
|
+
format: 'lexical',
|
|
177
|
+
localized
|
|
178
|
+
};
|
|
179
|
+
return;
|
|
180
|
+
default:
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
}
|