@payloadcms/figma 0.0.1-alpha.42 → 0.0.1-alpha.6
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 +1 -22
- package/dist/api/control-plane.d.ts.map +1 -1
- package/dist/api/control-plane.js +22 -55
- package/dist/api/control-plane.js.map +1 -1
- package/dist/api/figma-api.d.ts.map +1 -1
- package/dist/api/figma-api.js +21 -45
- package/dist/api/figma-api.js.map +1 -1
- package/dist/auth/callback-server.d.ts.map +1 -1
- package/dist/auth/callback-server.js +1 -2
- package/dist/auth/callback-server.js.map +1 -1
- package/dist/auth/crypto-utils.d.ts.map +1 -1
- package/dist/auth/crypto-utils.js +5 -5
- package/dist/auth/crypto-utils.js.map +1 -1
- package/dist/auth/jwt-validator.d.ts +1 -2
- package/dist/auth/jwt-validator.d.ts.map +1 -1
- package/dist/auth/jwt-validator.js +2 -2
- package/dist/auth/jwt-validator.js.map +1 -1
- package/dist/auth/oauth-flow.d.ts +1 -1
- package/dist/auth/oauth-flow.d.ts.map +1 -1
- package/dist/auth/oauth-flow.js +11 -15
- package/dist/auth/oauth-flow.js.map +1 -1
- package/dist/auth/project-token.d.ts.map +1 -1
- package/dist/auth/project-token.js +4 -9
- package/dist/auth/project-token.js.map +1 -1
- package/dist/auth/refresh.d.ts +1 -2
- package/dist/auth/refresh.d.ts.map +1 -1
- package/dist/auth/refresh.js +12 -25
- package/dist/auth/refresh.js.map +1 -1
- package/dist/auth/token-store.d.ts +0 -12
- package/dist/auth/token-store.d.ts.map +1 -1
- package/dist/auth/token-store.js +5 -28
- package/dist/auth/token-store.js.map +1 -1
- package/dist/auth/types.d.ts +4 -7
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -39
- package/dist/cli.js.map +1 -1
- package/dist/commands/deploy.d.ts +0 -4
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +129 -72
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/init.d.ts +5 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +85 -105
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.d.ts.map +1 -1
- package/dist/commands/list-tokens.js +7 -22
- package/dist/commands/list-tokens.js.map +1 -1
- package/dist/commands/login.d.ts +1 -8
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +12 -30
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.d.ts +4 -5
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/logout.js +13 -56
- package/dist/commands/logout.js.map +1 -1
- package/dist/config/oauth.d.ts +14 -4
- package/dist/config/oauth.d.ts.map +1 -1
- package/dist/config/oauth.js +40 -19
- package/dist/config/oauth.js.map +1 -1
- package/dist/constants.d.ts +18 -26
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +20 -34
- package/dist/constants.js.map +1 -1
- package/dist/exports/client.d.ts +0 -1
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +0 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/oauth/components/LoginButton/index.d.ts.map +1 -1
- package/dist/oauth/components/LoginButton/index.js +6 -50
- package/dist/oauth/components/LoginButton/index.js.map +1 -1
- package/dist/oauth/components/LoginButton/index.scss +3 -50
- package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -1
- package/dist/oauth/components/LogoutButton/index.js +4 -5
- package/dist/oauth/components/LogoutButton/index.js.map +1 -1
- package/dist/oauth/defaults.d.ts.map +1 -1
- package/dist/oauth/defaults.js +5 -29
- package/dist/oauth/defaults.js.map +1 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +11 -21
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +1 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js +4 -7
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +1 -1
- package/dist/oauth/index.d.ts.map +1 -1
- package/dist/oauth/index.js +13 -40
- package/dist/oauth/index.js.map +1 -1
- package/dist/oauth/strategy/index.d.ts +2 -0
- package/dist/oauth/strategy/index.d.ts.map +1 -1
- package/dist/oauth/strategy/index.js +15 -38
- package/dist/oauth/strategy/index.js.map +1 -1
- package/dist/oauth/types.d.ts +6 -6
- package/dist/oauth/types.d.ts.map +1 -1
- package/dist/oauth/types.js.map +1 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +1 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +1 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +8 -0
- package/dist/oauth/utilities/getAdminPath.d.ts.map +1 -0
- package/dist/oauth/utilities/getAdminPath.js +9 -0
- package/dist/oauth/utilities/getAdminPath.js.map +1 -0
- package/dist/oauth/utilities/refreshTokens.d.ts.map +1 -1
- package/dist/oauth/utilities/refreshTokens.js +1 -1
- package/dist/oauth/utilities/refreshTokens.js.map +1 -1
- package/dist/plugin/build-config.d.ts +4 -21
- package/dist/plugin/build-config.d.ts.map +1 -1
- package/dist/plugin/build-config.js +7 -113
- package/dist/plugin/build-config.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/asset-collection.d.ts +6 -3
- package/dist/utils/asset-collection.d.ts.map +1 -1
- package/dist/utils/asset-collection.js +34 -10
- package/dist/utils/asset-collection.js.map +1 -1
- package/dist/utils/config.js +1 -1
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/env-management.d.ts +8 -9
- package/dist/utils/env-management.d.ts.map +1 -1
- package/dist/utils/env-management.js +74 -73
- package/dist/utils/env-management.js.map +1 -1
- package/dist/utils/formatter.d.ts.map +1 -1
- package/dist/utils/formatter.js +5 -3
- package/dist/utils/formatter.js.map +1 -1
- package/dist/utils/lambda-config.d.ts +1 -3
- package/dist/utils/lambda-config.d.ts.map +1 -1
- package/dist/utils/lambda-config.js +32 -38
- package/dist/utils/lambda-config.js.map +1 -1
- package/dist/utils/messages.js +8 -8
- package/dist/utils/messages.js.map +1 -1
- package/dist/utils/payload-config-ast.d.ts +3 -22
- package/dist/utils/payload-config-ast.d.ts.map +1 -1
- package/dist/utils/payload-config-ast.js +31 -89
- package/dist/utils/payload-config-ast.js.map +1 -1
- package/dist/utils/payload-config-finder.d.ts +2 -2
- package/dist/utils/payload-config-finder.d.ts.map +1 -1
- package/dist/utils/payload-config-finder.js +9 -48
- package/dist/utils/payload-config-finder.js.map +1 -1
- package/dist/utils/payload-config-modifier.d.ts.map +1 -1
- package/dist/utils/payload-config-modifier.js +6 -54
- package/dist/utils/payload-config-modifier.js.map +1 -1
- package/dist/utils/payload-package-check.d.ts +1 -12
- package/dist/utils/payload-package-check.d.ts.map +1 -1
- package/dist/utils/payload-package-check.js +5 -63
- package/dist/utils/payload-package-check.js.map +1 -1
- package/dist/utils/project.d.ts.map +1 -1
- package/dist/utils/project.js +5 -8
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/s3-upload.d.ts +1 -0
- package/dist/utils/s3-upload.d.ts.map +1 -1
- package/dist/utils/s3-upload.js +3 -10
- package/dist/utils/s3-upload.js.map +1 -1
- package/dist/utils/token-display.d.ts.map +1 -1
- package/dist/utils/token-display.js +5 -11
- package/dist/utils/token-display.js.map +1 -1
- package/dist/utils/typescript-validator.d.ts.map +1 -1
- package/dist/utils/typescript-validator.js +6 -4
- package/dist/utils/typescript-validator.js.map +1 -1
- package/package.json +9 -27
- package/dist/commands/build-lambda-zip.d.ts +0 -5
- package/dist/commands/build-lambda-zip.d.ts.map +0 -1
- package/dist/commands/build-lambda-zip.js +0 -19
- package/dist/commands/build-lambda-zip.js.map +0 -1
- package/dist/db-content-api/README.md +0 -98
- package/dist/db-content-api/generated/content-api-types.d.ts +0 -3914
- package/dist/db-content-api/generated/content-api-types.d.ts.map +0 -1
- package/dist/db-content-api/generated/content-api-types.js +0 -7
- package/dist/db-content-api/generated/content-api-types.js.map +0 -1
- package/dist/db-content-api/index.d.ts +0 -18
- package/dist/db-content-api/index.d.ts.map +0 -1
- package/dist/db-content-api/index.js +0 -586
- package/dist/db-content-api/index.js.map +0 -1
- package/dist/db-content-api/temp-utilities/slug.d.ts +0 -2
- package/dist/db-content-api/temp-utilities/slug.d.ts.map +0 -1
- package/dist/db-content-api/temp-utilities/slug.js +0 -3
- package/dist/db-content-api/temp-utilities/slug.js.map +0 -1
- package/dist/db-content-api/temp-utilities/sorting.d.ts +0 -3
- package/dist/db-content-api/temp-utilities/sorting.d.ts.map +0 -1
- package/dist/db-content-api/temp-utilities/sorting.js +0 -32
- package/dist/db-content-api/temp-utilities/sorting.js.map +0 -1
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +0 -34
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts.map +0 -1
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +0 -53
- package/dist/db-content-api/temp-utilities/unwrapDocument.js.map +0 -1
- package/dist/db-content-api/utilities/auth.d.ts +0 -30
- package/dist/db-content-api/utilities/auth.d.ts.map +0 -1
- package/dist/db-content-api/utilities/auth.js +0 -81
- package/dist/db-content-api/utilities/auth.js.map +0 -1
- package/dist/db-content-api/utilities/buildPathTypes.d.ts +0 -12
- package/dist/db-content-api/utilities/buildPathTypes.d.ts.map +0 -1
- package/dist/db-content-api/utilities/buildPathTypes.js +0 -157
- package/dist/db-content-api/utilities/buildPathTypes.js.map +0 -1
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +0 -7
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts.map +0 -1
- package/dist/db-content-api/utilities/data/applyDefaults.js +0 -59
- package/dist/db-content-api/utilities/data/applyDefaults.js.map +0 -1
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +0 -11
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts.map +0 -1
- package/dist/db-content-api/utilities/data/castFieldValue.js +0 -66
- package/dist/db-content-api/utilities/data/castFieldValue.js.map +0 -1
- package/dist/db-content-api/utilities/data/index.d.ts +0 -32
- package/dist/db-content-api/utilities/data/index.d.ts.map +0 -1
- package/dist/db-content-api/utilities/data/index.js +0 -190
- package/dist/db-content-api/utilities/data/index.js.map +0 -1
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +0 -12
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts.map +0 -1
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +0 -54
- package/dist/db-content-api/utilities/data/removeVirtualFields.js.map +0 -1
- package/dist/db-content-api/utilities/data/stripFields.d.ts +0 -48
- package/dist/db-content-api/utilities/data/stripFields.d.ts.map +0 -1
- package/dist/db-content-api/utilities/data/stripFields.js +0 -195
- package/dist/db-content-api/utilities/data/stripFields.js.map +0 -1
- package/dist/db-content-api/utilities/joins.d.ts +0 -55
- package/dist/db-content-api/utilities/joins.d.ts.map +0 -1
- package/dist/db-content-api/utilities/joins.js +0 -136
- package/dist/db-content-api/utilities/joins.js.map +0 -1
- package/dist/db-content-api/utilities/where.d.ts +0 -12
- package/dist/db-content-api/utilities/where.d.ts.map +0 -1
- package/dist/db-content-api/utilities/where.js +0 -121
- package/dist/db-content-api/utilities/where.js.map +0 -1
- package/dist/endpoints/health.d.ts +0 -3
- package/dist/endpoints/health.d.ts.map +0 -1
- package/dist/endpoints/health.js +0 -11
- package/dist/endpoints/health.js.map +0 -1
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +0 -7
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts.map +0 -1
- package/dist/oauth/utilities/isDuplicateKeyError.js +0 -14
- package/dist/oauth/utilities/isDuplicateKeyError.js.map +0 -1
- package/dist/storage-content-api/api-types.d.ts +0 -168
- package/dist/storage-content-api/api-types.d.ts.map +0 -1
- package/dist/storage-content-api/api-types.js +0 -6
- package/dist/storage-content-api/api-types.js.map +0 -1
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +0 -9
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts.map +0 -1
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +0 -42
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js.map +0 -1
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +0 -13
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts.map +0 -1
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +0 -32
- package/dist/storage-content-api/client-uploads/generateSignedURL.js.map +0 -1
- package/dist/storage-content-api/client.d.ts +0 -6
- package/dist/storage-content-api/client.d.ts.map +0 -1
- package/dist/storage-content-api/client.js +0 -36
- package/dist/storage-content-api/client.js.map +0 -1
- package/dist/storage-content-api/generateURL.d.ts +0 -7
- package/dist/storage-content-api/generateURL.d.ts.map +0 -1
- package/dist/storage-content-api/generateURL.js +0 -8
- package/dist/storage-content-api/generateURL.js.map +0 -1
- package/dist/storage-content-api/handleDelete.d.ts +0 -8
- package/dist/storage-content-api/handleDelete.d.ts.map +0 -1
- package/dist/storage-content-api/handleDelete.js +0 -17
- package/dist/storage-content-api/handleDelete.js.map +0 -1
- package/dist/storage-content-api/handleUpload.d.ts +0 -11
- package/dist/storage-content-api/handleUpload.d.ts.map +0 -1
- package/dist/storage-content-api/handleUpload.js +0 -144
- package/dist/storage-content-api/handleUpload.js.map +0 -1
- package/dist/storage-content-api/index.d.ts +0 -5
- package/dist/storage-content-api/index.d.ts.map +0 -1
- package/dist/storage-content-api/index.js +0 -31
- package/dist/storage-content-api/index.js.map +0 -1
- package/dist/storage-content-api/staticHandler.d.ts +0 -10
- package/dist/storage-content-api/staticHandler.d.ts.map +0 -1
- package/dist/storage-content-api/staticHandler.js +0 -56
- package/dist/storage-content-api/staticHandler.js.map +0 -1
- package/dist/storage-content-api/types.d.ts +0 -10
- package/dist/storage-content-api/types.d.ts.map +0 -1
- package/dist/storage-content-api/types.js +0 -3
- package/dist/storage-content-api/types.js.map +0 -1
- package/dist/templates/README.md +0 -19
- package/dist/utils/build-lambda-zip.d.ts +0 -14
- package/dist/utils/build-lambda-zip.d.ts.map +0 -1
- package/dist/utils/build-lambda-zip.js +0 -81
- package/dist/utils/build-lambda-zip.js.map +0 -1
- package/dist/utils/format-env-suffix.d.ts +0 -12
- package/dist/utils/format-env-suffix.d.ts.map +0 -1
- package/dist/utils/format-env-suffix.js +0 -13
- package/dist/utils/format-env-suffix.js.map +0 -1
- package/dist/utils/version-check.d.ts +0 -3
- package/dist/utils/version-check.d.ts.map +0 -1
- package/dist/utils/version-check.js +0 -38
- package/dist/utils/version-check.js.map +0 -1
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cast field values to the appropriate type for Content API storage.
|
|
3
|
-
*
|
|
4
|
-
* This function implements type coercion similar to Mongoose (used by MongoDB adapter)
|
|
5
|
-
* to ensure data consistency. When users ignore TypeScript types and pass incorrect types,
|
|
6
|
-
* we automatically convert them to the expected type.
|
|
7
|
-
*
|
|
8
|
-
*/ export function castFieldValue(field, value) {
|
|
9
|
-
if (value === null || value === undefined) {
|
|
10
|
-
return value;
|
|
11
|
-
}
|
|
12
|
-
if (field.type === 'number') {
|
|
13
|
-
// Handle hasMany: true - array of numbers
|
|
14
|
-
if ('hasMany' in field && field.hasMany && Array.isArray(value)) {
|
|
15
|
-
return value.map((item)=>{
|
|
16
|
-
if (typeof item === 'number') {
|
|
17
|
-
return item;
|
|
18
|
-
}
|
|
19
|
-
if (typeof item === 'string' || typeof item === 'boolean') {
|
|
20
|
-
return Number(item);
|
|
21
|
-
}
|
|
22
|
-
return item // Pass through other types (will likely fail validation)
|
|
23
|
-
;
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
// Handle single number
|
|
27
|
-
if (typeof value !== 'number') {
|
|
28
|
-
if (typeof value === 'string' || typeof value === 'boolean') {
|
|
29
|
-
return Number(value);
|
|
30
|
-
}
|
|
31
|
-
// For objects/arrays (when not hasMany), return as-is (will likely fail validation later)
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (field.type === 'checkbox' && typeof value !== 'boolean') {
|
|
36
|
-
if (typeof value === 'string') {
|
|
37
|
-
if (value.toLowerCase() === 'true' || value === '1') {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
if (value.toLowerCase() === 'false' || value === '0' || value === '') {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return Boolean(value);
|
|
45
|
-
}
|
|
46
|
-
// Matches Mongoose behavior: stores dates as ISO strings
|
|
47
|
-
if (field.type === 'date' && typeof value !== 'string') {
|
|
48
|
-
if (value instanceof Date) {
|
|
49
|
-
return value.toISOString();
|
|
50
|
-
}
|
|
51
|
-
if (typeof value === 'number') {
|
|
52
|
-
return new Date(value).toISOString();
|
|
53
|
-
}
|
|
54
|
-
// For other types, return as-is (will likely fail validation)
|
|
55
|
-
return value;
|
|
56
|
-
}
|
|
57
|
-
// Text-like fields: convert non-strings to JSON strings
|
|
58
|
-
// This handles text, textarea, email, and code fields
|
|
59
|
-
if ((field.type === 'text' || field.type === 'textarea' || field.type === 'email' || field.type === 'code') && typeof value !== 'string') {
|
|
60
|
-
return JSON.stringify(value);
|
|
61
|
-
}
|
|
62
|
-
// No casting needed for other types or already correct types
|
|
63
|
-
return value;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
//# sourceMappingURL=castFieldValue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/db-content-api/utilities/data/castFieldValue.ts"],"sourcesContent":["import type { Field, TabAsField } from 'payload'\n\n/**\n * Cast field values to the appropriate type for Content API storage.\n *\n * This function implements type coercion similar to Mongoose (used by MongoDB adapter)\n * to ensure data consistency. When users ignore TypeScript types and pass incorrect types,\n * we automatically convert them to the expected type.\n *\n */\nexport function castFieldValue(field: Field | TabAsField, value: unknown): unknown {\n if (value === null || value === undefined) {\n return value\n }\n\n if (field.type === 'number') {\n // Handle hasMany: true - array of numbers\n if ('hasMany' in field && field.hasMany && Array.isArray(value)) {\n return value.map((item) => {\n if (typeof item === 'number') {\n return item\n }\n if (typeof item === 'string' || typeof item === 'boolean') {\n return Number(item)\n }\n return item // Pass through other types (will likely fail validation)\n })\n }\n\n // Handle single number\n if (typeof value !== 'number') {\n if (typeof value === 'string' || typeof value === 'boolean') {\n return Number(value)\n }\n // For objects/arrays (when not hasMany), return as-is (will likely fail validation later)\n return value\n }\n }\n\n if (field.type === 'checkbox' && typeof value !== 'boolean') {\n if (typeof value === 'string') {\n if (value.toLowerCase() === 'true' || value === '1') {\n return true\n }\n if (value.toLowerCase() === 'false' || value === '0' || value === '') {\n return false\n }\n }\n return Boolean(value)\n }\n\n // Matches Mongoose behavior: stores dates as ISO strings\n if (field.type === 'date' && typeof value !== 'string') {\n if (value instanceof Date) {\n return value.toISOString()\n }\n if (typeof value === 'number') {\n return new Date(value).toISOString()\n }\n // For other types, return as-is (will likely fail validation)\n return value\n }\n\n // Text-like fields: convert non-strings to JSON strings\n // This handles text, textarea, email, and code fields\n if (\n (field.type === 'text' ||\n field.type === 'textarea' ||\n field.type === 'email' ||\n field.type === 'code') &&\n typeof value !== 'string'\n ) {\n return JSON.stringify(value)\n }\n\n // No casting needed for other types or already correct types\n return value\n}\n"],"names":["castFieldValue","field","value","undefined","type","hasMany","Array","isArray","map","item","Number","toLowerCase","Boolean","Date","toISOString","JSON","stringify"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,SAASA,eAAeC,KAAyB,EAAEC,KAAc;IACtE,IAAIA,UAAU,QAAQA,UAAUC,WAAW;QACzC,OAAOD;IACT;IAEA,IAAID,MAAMG,IAAI,KAAK,UAAU;QAC3B,0CAA0C;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,32 +0,0 @@
|
|
|
1
|
-
import type { Payload } from 'payload';
|
|
2
|
-
import type { components } from '../../generated/content-api-types.js';
|
|
3
|
-
type DataWithOperations = components['schemas']['DataWithOperations'];
|
|
4
|
-
/**
|
|
5
|
-
* Transform data before sending to Content API (WRITE operations)
|
|
6
|
-
*
|
|
7
|
-
* Conversions applied:
|
|
8
|
-
* - Default values: Apply static defaults for undefined fields (when applyDefaults=true)
|
|
9
|
-
* - Type casting: Convert values to match field types (e.g., number -> string for text fields)
|
|
10
|
-
* - RichText fields: Objects -> JSON strings
|
|
11
|
-
* - Virtual fields: Remove fields with `virtual: true` (pure virtual fields should never be saved)
|
|
12
|
-
* - Timestamps: Add updatedAt (always), and createdAt (when createdAt=true)
|
|
13
|
-
*
|
|
14
|
-
* Note: Date fields are automatically converted to ISO strings by JSON.stringify()
|
|
15
|
-
*/
|
|
16
|
-
export declare function dataToContentAPI(payload: Payload, collectionSlug: string, data: unknown, options?: {
|
|
17
|
-
applyDefaults?: boolean;
|
|
18
|
-
createdAt?: boolean;
|
|
19
|
-
}): DataWithOperations;
|
|
20
|
-
/**
|
|
21
|
-
* Transform data received from Content API (READ operations)
|
|
22
|
-
*
|
|
23
|
-
* Conversions applied:
|
|
24
|
-
* - RichText fields: JSON strings -> Objects
|
|
25
|
-
* - Virtual fields: Remove fields with `virtual: true` (should not be in DB but Content API backend may add them)
|
|
26
|
-
*
|
|
27
|
-
* Note: Date fields come as ISO strings from Content API and stay as strings
|
|
28
|
-
* (matching MongoDB and other adapters' behavior)
|
|
29
|
-
*/
|
|
30
|
-
export declare function dataFromContentAPI(payload: Payload, collectionSlug: string, data: unknown): unknown;
|
|
31
|
-
export {};
|
|
32
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/data/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkC,OAAO,EAA0B,MAAM,SAAS,CAAA;AAI9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAA;AAOtE,KAAK,kBAAkB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,CAAA;AAErE;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GACzD,kBAAkB,CA8EpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,OAAO,GACZ,OAAO,CA0FT"}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { flattenAllFields, traverseFields } from 'payload';
|
|
2
|
-
import { applyDefaults } from './applyDefaults.js';
|
|
3
|
-
import { castFieldValue } from './castFieldValue.js';
|
|
4
|
-
import { removeVirtualFields } from './removeVirtualFields.js';
|
|
5
|
-
import { stripFields } from './stripFields.js';
|
|
6
|
-
/**
|
|
7
|
-
* Transform data before sending to Content API (WRITE operations)
|
|
8
|
-
*
|
|
9
|
-
* Conversions applied:
|
|
10
|
-
* - Default values: Apply static defaults for undefined fields (when applyDefaults=true)
|
|
11
|
-
* - Type casting: Convert values to match field types (e.g., number -> string for text fields)
|
|
12
|
-
* - RichText fields: Objects -> JSON strings
|
|
13
|
-
* - Virtual fields: Remove fields with `virtual: true` (pure virtual fields should never be saved)
|
|
14
|
-
* - Timestamps: Add updatedAt (always), and createdAt (when createdAt=true)
|
|
15
|
-
*
|
|
16
|
-
* Note: Date fields are automatically converted to ISO strings by JSON.stringify()
|
|
17
|
-
*/ export function dataToContentAPI(payload, collectionSlug, data, options) {
|
|
18
|
-
if (!data || typeof data !== 'object') {
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
// Deep clone to avoid mutating original data
|
|
22
|
-
const transformed = JSON.parse(JSON.stringify(data));
|
|
23
|
-
// Get collection config
|
|
24
|
-
const isGlobal = collectionSlug.startsWith('_global-');
|
|
25
|
-
const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
|
|
26
|
-
const collectionConfig = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
|
|
27
|
-
if (!collectionConfig?.fields) {
|
|
28
|
-
return transformed;
|
|
29
|
-
}
|
|
30
|
-
// Apply static defaults recursively to handle nested structures (arrays, groups)
|
|
31
|
-
// This must happen before traverseFields to ensure defaults are in place
|
|
32
|
-
if (options?.applyDefaults) {
|
|
33
|
-
applyDefaults(transformed, collectionConfig.fields);
|
|
34
|
-
}
|
|
35
|
-
// Use Payload's traverseFields to iterate over all fields for transformations
|
|
36
|
-
const callback = ({ field, ref })=>{
|
|
37
|
-
if (!('name' in field) || !field.name) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (!ref || typeof ref !== 'object') {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const current = ref;
|
|
44
|
-
let value = current[field.name];
|
|
45
|
-
// Transform existing values
|
|
46
|
-
if (value !== null && value !== undefined) {
|
|
47
|
-
// Step 1: Apply type casting (e.g., number -> string for text fields)
|
|
48
|
-
value = castFieldValue(field, value);
|
|
49
|
-
current[field.name] = value;
|
|
50
|
-
// Step 2: Apply Content API specific transformations
|
|
51
|
-
// RichText: object -> JSON string
|
|
52
|
-
if (field.type === 'richText' && typeof value !== 'string') {
|
|
53
|
-
current[field.name] = JSON.stringify(value);
|
|
54
|
-
}
|
|
55
|
-
// Date fields are already handled by JSON.stringify() which converts Date -> ISO string
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
traverseFields({
|
|
59
|
-
callback,
|
|
60
|
-
fields: collectionConfig.fields,
|
|
61
|
-
fillEmpty: false,
|
|
62
|
-
ref: transformed
|
|
63
|
-
});
|
|
64
|
-
stripFields({
|
|
65
|
-
config: payload.config,
|
|
66
|
-
data: transformed,
|
|
67
|
-
fields: flattenAllFields({
|
|
68
|
-
cache: true,
|
|
69
|
-
fields: collectionConfig.fields
|
|
70
|
-
}),
|
|
71
|
-
reservedKeys: [
|
|
72
|
-
'id',
|
|
73
|
-
'globalType'
|
|
74
|
-
]
|
|
75
|
-
});
|
|
76
|
-
removeVirtualFields(transformed, collectionConfig.fields);
|
|
77
|
-
// Convert numeric ID to string for Content API
|
|
78
|
-
const customIDType = payload.collections?.[collectionSlug]?.customIDType;
|
|
79
|
-
if (customIDType === 'number') {
|
|
80
|
-
transformed.id = String(transformed.id);
|
|
81
|
-
}
|
|
82
|
-
// Add timestamps (Content API no longer auto-sets these in DB)
|
|
83
|
-
// updatedAt is always set, createdAt only on create operations
|
|
84
|
-
const now = new Date().toISOString();
|
|
85
|
-
transformed.updatedAt = now;
|
|
86
|
-
if (options?.createdAt) {
|
|
87
|
-
transformed.createdAt = now;
|
|
88
|
-
}
|
|
89
|
-
return transformed;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Transform data received from Content API (READ operations)
|
|
93
|
-
*
|
|
94
|
-
* Conversions applied:
|
|
95
|
-
* - RichText fields: JSON strings -> Objects
|
|
96
|
-
* - Virtual fields: Remove fields with `virtual: true` (should not be in DB but Content API backend may add them)
|
|
97
|
-
*
|
|
98
|
-
* Note: Date fields come as ISO strings from Content API and stay as strings
|
|
99
|
-
* (matching MongoDB and other adapters' behavior)
|
|
100
|
-
*/ export function dataFromContentAPI(payload, collectionSlug, data) {
|
|
101
|
-
if (!data || typeof data !== 'object') {
|
|
102
|
-
return data;
|
|
103
|
-
}
|
|
104
|
-
// Deep clone to avoid mutating original data
|
|
105
|
-
const transformed = JSON.parse(JSON.stringify(data));
|
|
106
|
-
// Get collection config
|
|
107
|
-
const isGlobal = collectionSlug.startsWith('_global-');
|
|
108
|
-
const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
|
|
109
|
-
const collectionConfig = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
|
|
110
|
-
if (!collectionConfig?.fields) {
|
|
111
|
-
return transformed;
|
|
112
|
-
}
|
|
113
|
-
// Use Payload's traverseFields to iterate over all fields
|
|
114
|
-
const callback = ({ field, parentPath, ref })=>{
|
|
115
|
-
if (!('name' in field) || !field.name) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (!ref || typeof ref !== 'object') {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const current = ref;
|
|
122
|
-
const value = current[field.name];
|
|
123
|
-
// Normalize undefined → null for optional fields
|
|
124
|
-
// Content API may omit fields (undefined) but Payload expects null for optional fields
|
|
125
|
-
if (value === undefined) {
|
|
126
|
-
const isRequired = 'required' in field && field.required;
|
|
127
|
-
if (!isRequired) {
|
|
128
|
-
current[field.name] = null;
|
|
129
|
-
}
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
if (value !== null) {
|
|
133
|
-
// RichText: JSON string -> object
|
|
134
|
-
if (field.type === 'richText' && typeof value === 'string') {
|
|
135
|
-
try {
|
|
136
|
-
current[field.name] = JSON.parse(value);
|
|
137
|
-
} catch (error) {
|
|
138
|
-
const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name;
|
|
139
|
-
payload.logger.warn({
|
|
140
|
-
err: error instanceof Error ? error : new Error(String(error)),
|
|
141
|
-
msg: `Failed to parse richtext field '${fieldPath}' in collection '${collectionSlug}'`
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
// Date fields: Already ISO strings from Content API, no conversion needed
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
traverseFields({
|
|
149
|
-
callback,
|
|
150
|
-
fields: collectionConfig.fields,
|
|
151
|
-
ref: transformed
|
|
152
|
-
});
|
|
153
|
-
// Convert string ID to number if collection uses numeric custom ID
|
|
154
|
-
const customIDType = payload.collections?.[collectionSlug]?.customIDType;
|
|
155
|
-
if (customIDType === 'number') {
|
|
156
|
-
transformed.id = Number(transformed.id);
|
|
157
|
-
}
|
|
158
|
-
stripFields({
|
|
159
|
-
config: payload.config,
|
|
160
|
-
data: transformed,
|
|
161
|
-
fields: flattenAllFields({
|
|
162
|
-
cache: true,
|
|
163
|
-
fields: collectionConfig.fields
|
|
164
|
-
}),
|
|
165
|
-
reservedKeys: [
|
|
166
|
-
'id',
|
|
167
|
-
'globalType'
|
|
168
|
-
]
|
|
169
|
-
});
|
|
170
|
-
// Remove virtual fields - must happen AFTER stripFields
|
|
171
|
-
removeVirtualFields(transformed, collectionConfig.fields);
|
|
172
|
-
// Handle auth-specific fields that aren't in the field schema
|
|
173
|
-
// When these fields are null in DB, Content API omits them from response (undefined)
|
|
174
|
-
// But Payload expects them to be null, not undefined
|
|
175
|
-
// Only add them if the collection has auth enabled
|
|
176
|
-
if ('auth' in collectionConfig && collectionConfig.auth) {
|
|
177
|
-
const authFields = [
|
|
178
|
-
'resetPasswordExpiration',
|
|
179
|
-
'lockUntil'
|
|
180
|
-
];
|
|
181
|
-
for (const fieldName of authFields){
|
|
182
|
-
if (!(fieldName in transformed)) {
|
|
183
|
-
transformed[fieldName] = null;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return transformed;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/db-content-api/utilities/data/index.ts"],"sourcesContent":["import type { CollectionConfig, GlobalConfig, Payload, TraverseFieldsCallback } from 'payload'\n\nimport { flattenAllFields, traverseFields } from 'payload'\n\nimport type { components } from '../../generated/content-api-types.js'\n\nimport { applyDefaults } from './applyDefaults.js'\nimport { castFieldValue } from './castFieldValue.js'\nimport { removeVirtualFields } from './removeVirtualFields.js'\nimport { stripFields } from './stripFields.js'\n\ntype DataWithOperations = components['schemas']['DataWithOperations']\n\n/**\n * Transform data before sending to Content API (WRITE operations)\n *\n * Conversions applied:\n * - Default values: Apply static defaults for undefined fields (when applyDefaults=true)\n * - Type casting: Convert values to match field types (e.g., number -> string for text fields)\n * - RichText fields: Objects -> JSON strings\n * - Virtual fields: Remove fields with `virtual: true` (pure virtual fields should never be saved)\n * - Timestamps: Add updatedAt (always), and createdAt (when createdAt=true)\n *\n * Note: Date fields are automatically converted to ISO strings by JSON.stringify()\n */\nexport function dataToContentAPI(\n payload: Payload,\n collectionSlug: string,\n data: unknown,\n options?: { applyDefaults?: boolean; createdAt?: boolean },\n): DataWithOperations {\n if (!data || typeof data !== 'object') {\n return data as DataWithOperations\n }\n\n // Deep clone to avoid mutating original data\n const transformed = JSON.parse(JSON.stringify(data))\n\n // Get collection config\n const isGlobal = collectionSlug.startsWith('_global-')\n const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug\n const collectionConfig: CollectionConfig | GlobalConfig | undefined = isGlobal\n ? payload.config.globals?.find((g) => g.slug === actualSlug)\n : payload.config.collections.find((c) => c.slug === actualSlug)\n\n if (!collectionConfig?.fields) {\n return transformed as DataWithOperations\n }\n\n // Apply static defaults recursively to handle nested structures (arrays, groups)\n // This must happen before traverseFields to ensure defaults are in place\n if (options?.applyDefaults) {\n applyDefaults(transformed, collectionConfig.fields)\n }\n\n // Use Payload's traverseFields to iterate over all fields for transformations\n const callback: TraverseFieldsCallback = ({ field, ref }) => {\n if (!('name' in field) || !field.name) {\n return\n }\n if (!ref || typeof ref !== 'object') {\n return\n }\n\n const current = ref as Record<string, unknown>\n let value = current[field.name]\n\n // Transform existing values\n if (value !== null && value !== undefined) {\n // Step 1: Apply type casting (e.g., number -> string for text fields)\n value = castFieldValue(field, value)\n current[field.name] = value\n\n // Step 2: Apply Content API specific transformations\n // RichText: object -> JSON string\n if (field.type === 'richText' && typeof value !== 'string') {\n current[field.name] = JSON.stringify(value)\n }\n // Date fields are already handled by JSON.stringify() which converts Date -> ISO string\n }\n }\n\n traverseFields({ callback, fields: collectionConfig.fields, fillEmpty: false, ref: transformed })\n\n stripFields({\n config: payload.config,\n data: transformed,\n fields: flattenAllFields({ cache: true, fields: collectionConfig.fields }),\n reservedKeys: ['id', 'globalType'],\n })\n\n removeVirtualFields(transformed, collectionConfig.fields)\n\n // Convert numeric ID to string for Content API\n const customIDType = payload.collections?.[collectionSlug]?.customIDType\n if (customIDType === 'number') {\n transformed.id = String(transformed.id)\n }\n\n // Add timestamps (Content API no longer auto-sets these in DB)\n // updatedAt is always set, createdAt only on create operations\n const now = new Date().toISOString()\n transformed.updatedAt = now\n if (options?.createdAt) {\n transformed.createdAt = now\n }\n\n return transformed as DataWithOperations\n}\n\n/**\n * Transform data received from Content API (READ operations)\n *\n * Conversions applied:\n * - RichText fields: JSON strings -> Objects\n * - Virtual fields: Remove fields with `virtual: true` (should not be in DB but Content API backend may add them)\n *\n * Note: Date fields come as ISO strings from Content API and stay as strings\n * (matching MongoDB and other adapters' behavior)\n */\nexport function dataFromContentAPI(\n payload: Payload,\n collectionSlug: string,\n data: unknown,\n): unknown {\n if (!data || typeof data !== 'object') {\n return data\n }\n\n // Deep clone to avoid mutating original data\n const transformed = JSON.parse(JSON.stringify(data))\n\n // Get collection config\n const isGlobal = collectionSlug.startsWith('_global-')\n const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug\n const collectionConfig: CollectionConfig | GlobalConfig | undefined = isGlobal\n ? payload.config.globals?.find((g) => g.slug === actualSlug)\n : payload.config.collections.find((c) => c.slug === actualSlug)\n\n if (!collectionConfig?.fields) {\n return transformed\n }\n\n // Use Payload's traverseFields to iterate over all fields\n const callback: TraverseFieldsCallback = ({ field, parentPath, ref }) => {\n if (!('name' in field) || !field.name) {\n return\n }\n if (!ref || typeof ref !== 'object') {\n return\n }\n\n const current = ref as Record<string, unknown>\n const value = current[field.name]\n\n // Normalize undefined → null for optional fields\n // Content API may omit fields (undefined) but Payload expects null for optional fields\n if (value === undefined) {\n const isRequired = 'required' in field && field.required\n if (!isRequired) {\n current[field.name] = null\n }\n return\n }\n\n if (value !== null) {\n // RichText: JSON string -> object\n if (field.type === 'richText' && typeof value === 'string') {\n try {\n current[field.name] = JSON.parse(value)\n } catch (error) {\n const fieldPath = parentPath ? `${parentPath}.${field.name}` : field.name\n payload.logger.warn({\n err: error instanceof Error ? error : new Error(String(error)),\n msg: `Failed to parse richtext field '${fieldPath}' in collection '${collectionSlug}'`,\n })\n }\n }\n // Date fields: Already ISO strings from Content API, no conversion needed\n }\n }\n\n traverseFields({ callback, fields: collectionConfig.fields, ref: transformed })\n\n // Convert string ID to number if collection uses numeric custom ID\n const customIDType = payload.collections?.[collectionSlug]?.customIDType\n if (customIDType === 'number') {\n transformed.id = Number(transformed.id)\n }\n\n stripFields({\n config: payload.config,\n data: transformed,\n fields: flattenAllFields({ cache: true, fields: collectionConfig.fields }),\n reservedKeys: ['id', 'globalType'],\n })\n\n // Remove virtual fields - must happen AFTER stripFields\n removeVirtualFields(transformed, collectionConfig.fields)\n\n // Handle auth-specific fields that aren't in the field schema\n // When these fields are null in DB, Content API omits them from response (undefined)\n // But Payload expects them to be null, not undefined\n // Only add them if the collection has auth enabled\n if ('auth' in collectionConfig && collectionConfig.auth) {\n const authFields = ['resetPasswordExpiration', 'lockUntil']\n for (const fieldName of authFields) {\n if (!(fieldName in transformed)) {\n transformed[fieldName] = null\n }\n }\n }\n\n return transformed\n}\n"],"names":["flattenAllFields","traverseFields","applyDefaults","castFieldValue","removeVirtualFields","stripFields","dataToContentAPI","payload","collectionSlug","data","options","transformed","JSON","parse","stringify","isGlobal","startsWith","actualSlug","substring","collectionConfig","config","globals","find","g","slug","collections","c","fields","callback","field","ref","name","current","value","undefined","type","fillEmpty","cache","reservedKeys","customIDType","id","String","now","Date","toISOString","updatedAt","createdAt","dataFromContentAPI","parentPath","isRequired","required","error","fieldPath","logger","warn","err","Error","msg","Number","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AAC,CAAC;oBACxF;gBACF;YACF;QACA,0EAA0E;QAC5E;IACF;IAEAP,eAAe;QAAE2B;QAAUD,QAAQR,iBAAiBQ,MAAM;QAAEG,KAAKnB;IAAY;IAE7E,mEAAmE;IACnE,MAAM4B,eAAehC,QAAQkB,WAAW,EAAE,CAACjB,eAAe,EAAE+B;IAC5D,IAAIA,iBAAiB,UAAU;QAC7B5B,YAAY6B,EAAE,GAAGkB,OAAO/C,YAAY6B,EAAE;IACxC;IAEAnC,YAAY;QACVe,QAAQb,QAAQa,MAAM;QACtBX,MAAME;QACNgB,QAAQ3B,iBAAiB;YAAEqC,OAAO;YAAMV,QAAQR,iBAAiBQ,MAAM;QAAC;QACxEW,cAAc;YAAC;YAAM;SAAa;IACpC;IAEA,wDAAwD;IACxDlC,oBAAoBO,aAAaQ,iBAAiBQ,MAAM;IAExD,8DAA8D;IAC9D,qFAAqF;IACrF,qDAAqD;IACrD,mDAAmD;IACnD,IAAI,UAAUR,oBAAoBA,iBAAiBwC,IAAI,EAAE;QACvD,MAAMC,aAAa;YAAC;YAA2B;SAAY;QAC3D,KAAK,MAAMC,aAAaD,WAAY;YAClC,IAAI,CAAEC,CAAAA,aAAalD,WAAU,GAAI;gBAC/BA,WAAW,CAACkD,UAAU,GAAG;YAC3B;QACF;IACF;IAEA,OAAOlD;AACT"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { CollectionConfig } from 'payload';
|
|
2
|
-
/**
|
|
3
|
-
* Removes virtual fields (fields with virtual: true) from data recursively.
|
|
4
|
-
* Virtual fields should never be persisted in the database.
|
|
5
|
-
*
|
|
6
|
-
* @todo It might be a good idea to combine `stripFields` with `stripFields`
|
|
7
|
-
* in a new utility that receives a callback with conditions. I didn't do
|
|
8
|
-
* it now because `stripFields` was copied from db-mongo and I'd like to
|
|
9
|
-
* find a way to unify everything.
|
|
10
|
-
*/
|
|
11
|
-
export declare function removeVirtualFields(data: Record<string, unknown>, fieldConfigs: CollectionConfig['fields']): void;
|
|
12
|
-
//# sourceMappingURL=removeVirtualFields.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"removeVirtualFields.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/data/removeVirtualFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,YAAY,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GACvC,IAAI,CAgDN"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Removes virtual fields (fields with virtual: true) from data recursively.
|
|
3
|
-
* Virtual fields should never be persisted in the database.
|
|
4
|
-
*
|
|
5
|
-
* @todo It might be a good idea to combine `stripFields` with `stripFields`
|
|
6
|
-
* in a new utility that receives a callback with conditions. I didn't do
|
|
7
|
-
* it now because `stripFields` was copied from db-mongo and I'd like to
|
|
8
|
-
* find a way to unify everything.
|
|
9
|
-
*/ export function removeVirtualFields(data, fieldConfigs) {
|
|
10
|
-
for (const field of fieldConfigs){
|
|
11
|
-
// Handle UI fields (row, collapsible, tabs) - they don't have names
|
|
12
|
-
// but contain other fields that might be virtual
|
|
13
|
-
if (field.type === 'row' || field.type === 'collapsible') {
|
|
14
|
-
if ('fields' in field) {
|
|
15
|
-
removeVirtualFields(data, field.fields);
|
|
16
|
-
}
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
if (field.type === 'tabs' && 'tabs' in field) {
|
|
20
|
-
for (const tab of field.tabs){
|
|
21
|
-
if ('fields' in tab) {
|
|
22
|
-
removeVirtualFields(data, tab.fields);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
// Skip fields without names
|
|
28
|
-
if (!('name' in field) || !field.name) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
// Remove field if it has virtual: true
|
|
32
|
-
if ('virtual' in field && field.virtual === true) {
|
|
33
|
-
delete data[field.name];
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
// Recursively handle nested structures (groups, arrays with items, etc.)
|
|
37
|
-
if ('fields' in field && field.name in data) {
|
|
38
|
-
const value = data[field.name];
|
|
39
|
-
if (field.type === 'array' && Array.isArray(value)) {
|
|
40
|
-
// Process each array item
|
|
41
|
-
for (const item of value){
|
|
42
|
-
if (item && typeof item === 'object') {
|
|
43
|
-
removeVirtualFields(item, field.fields);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
} else if (field.type === 'group' && value && typeof value === 'object') {
|
|
47
|
-
// Process group
|
|
48
|
-
removeVirtualFields(value, field.fields);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
//# sourceMappingURL=removeVirtualFields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/db-content-api/utilities/data/removeVirtualFields.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\n/**\n * Removes virtual fields (fields with virtual: true) from data recursively.\n * Virtual fields should never be persisted in the database.\n *\n * @todo It might be a good idea to combine `stripFields` with `stripFields`\n * in a new utility that receives a callback with conditions. I didn't do\n * it now because `stripFields` was copied from db-mongo and I'd like to\n * find a way to unify everything.\n */\nexport function removeVirtualFields(\n data: Record<string, unknown>,\n fieldConfigs: CollectionConfig['fields'],\n): void {\n for (const field of fieldConfigs) {\n // Handle UI fields (row, collapsible, tabs) - they don't have names\n // but contain other fields that might be virtual\n if (field.type === 'row' || field.type === 'collapsible') {\n if ('fields' in field) {\n removeVirtualFields(data, field.fields)\n }\n continue\n }\n\n if (field.type === 'tabs' && 'tabs' in field) {\n for (const tab of field.tabs) {\n if ('fields' in tab) {\n removeVirtualFields(data, tab.fields)\n }\n }\n continue\n }\n\n // Skip fields without names\n if (!('name' in field) || !field.name) {\n continue\n }\n\n // Remove field if it has virtual: true\n if ('virtual' in field && field.virtual === true) {\n delete data[field.name]\n continue\n }\n\n // Recursively handle nested structures (groups, arrays with items, etc.)\n if ('fields' in field && field.name in data) {\n const value = data[field.name]\n\n if (field.type === 'array' && Array.isArray(value)) {\n // Process each array item\n for (const item of value) {\n if (item && typeof item === 'object') {\n removeVirtualFields(item as Record<string, unknown>, field.fields)\n }\n }\n } else if (field.type === 'group' && value && typeof value === 'object') {\n // Process group\n removeVirtualFields(value as Record<string, unknown>, field.fields)\n }\n }\n }\n}\n"],"names":["removeVirtualFields","data","fieldConfigs","field","type","fields","tab","tabs","name","virtual","value","Array","isArray","item"],"mappings":"AAEA;;;;;;;;CAQC,GACD,OAAO,SAASA,oBACdC,IAA6B,EAC7BC,YAAwC;IAExC,KAAK,MAAMC,SAASD,aAAc;QAChC,oEAAoE;QACpE,iDAAiD;QACjD,IAAIC,MAAMC,IAAI,KAAK,SAASD,MAAMC,IAAI,KAAK,eAAe;YACxD,IAAI,YAAYD,OAAO;gBACrBH,oBAAoBC,MAAME,MAAME,MAAM;YACxC;YACA;QACF;QAEA,IAAIF,MAAMC,IAAI,KAAK,UAAU,UAAUD,OAAO;YAC5C,KAAK,MAAMG,OAAOH,MAAMI,IAAI,CAAE;gBAC5B,IAAI,YAAYD,KAAK;oBACnBN,oBAAoBC,MAAMK,IAAID,MAAM;gBACtC;YACF;YACA;QACF;QAEA,4BAA4B;QAC5B,IAAI,CAAE,CAAA,UAAUF,KAAI,KAAM,CAACA,MAAMK,IAAI,EAAE;YACrC;QACF;QAEA,uCAAuC;QACvC,IAAI,aAAaL,SAASA,MAAMM,OAAO,KAAK,MAAM;YAChD,OAAOR,IAAI,CAACE,MAAMK,IAAI,CAAC;YACvB;QACF;QAEA,yEAAyE;QACzE,IAAI,YAAYL,SAASA,MAAMK,IAAI,IAAIP,MAAM;YAC3C,MAAMS,QAAQT,IAAI,CAACE,MAAMK,IAAI,CAAC;YAE9B,IAAIL,MAAMC,IAAI,KAAK,WAAWO,MAAMC,OAAO,CAACF,QAAQ;gBAClD,0BAA0B;gBAC1B,KAAK,MAAMG,QAAQH,MAAO;oBACxB,IAAIG,QAAQ,OAAOA,SAAS,UAAU;wBACpCb,oBAAoBa,MAAiCV,MAAME,MAAM;oBACnE;gBACF;YACF,OAAO,IAAIF,MAAMC,IAAI,KAAK,WAAWM,SAAS,OAAOA,UAAU,UAAU;gBACvE,gBAAgB;gBAChBV,oBAAoBU,OAAkCP,MAAME,MAAM;YACpE;QACF;IACF;AACF"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { FlattenedField, SanitizedConfig } from 'payload';
|
|
2
|
-
/**
|
|
3
|
-
* Strips fields from data that are not defined in the schema or are invalid.
|
|
4
|
-
*
|
|
5
|
-
* This function was copied from the MongoDB adapter's implementation:
|
|
6
|
-
* @see packages/db-mongodb/src/utilities/transform.ts (stripFields function)
|
|
7
|
-
*
|
|
8
|
-
* @description
|
|
9
|
-
* This utility performs deep sanitization of document data by:
|
|
10
|
-
* 1. **Removing undefined fields**: Strips any field not present in the collection's schema
|
|
11
|
-
* (e.g., sensitive fields like `password`, `apiKey`, or any extra fields not in config)
|
|
12
|
-
* 2. **Removing invalid locales**: Deletes locale keys that don't exist in `config.localization.localeCodes`
|
|
13
|
-
* (e.g., if data contains `{ "es-MX": "..." }` but only `"en"` is configured)
|
|
14
|
-
* 3. **Removing invalid blocks**: Filters out blocks with unknown `blockType` values
|
|
15
|
-
* (prevents data corruption from blocks that don't exist in the schema)
|
|
16
|
-
* 4. **Recursive sanitization**: Processes nested structures (arrays, groups, blocks, localized fields)
|
|
17
|
-
* to ensure deep data integrity
|
|
18
|
-
*
|
|
19
|
-
* @remarks
|
|
20
|
-
* Unlike MongoDB's adapter which uses Mongoose schemas with `strict: true` (rejecting extra fields
|
|
21
|
-
* on write), Content API uses flexible JSONB storage that accepts any fields. Therefore, this
|
|
22
|
-
* function is called on **both read and write operations** to ensure data consistency.
|
|
23
|
-
*
|
|
24
|
-
* The MongoDB adapter also supports an `allowAdditionalKeys` option that allows reading/writing
|
|
25
|
-
* fields not in the schema. For now, Content API does not support this feature - we always
|
|
26
|
-
* sanitize data. If users request this functionality in the future, we can consider adding it.
|
|
27
|
-
*
|
|
28
|
-
* @todo
|
|
29
|
-
* 1. Consider moving this utility to `payload/shared` so both MongoDB and Content API adapters
|
|
30
|
-
* can use the same implementation, reducing code duplication and maintenance burden.
|
|
31
|
-
*
|
|
32
|
-
* 2. Performance optimization: This function iterates through all fields recursively.
|
|
33
|
-
* The `dataToContentAPI` and `dataFromContentAPI` functions in
|
|
34
|
-
* `packages/figma/src/db-content-api/utilities/data.ts` also iterate through fields
|
|
35
|
-
* to transform richText (object ↔ JSON string), custom IDs (number ↔ string), and dates.
|
|
36
|
-
* Consider combining both traversals into a single abstraction to avoid iterating twice.
|
|
37
|
-
*
|
|
38
|
-
* 3. Feature parity: MongoDB adapter has `allowAdditionalKeys` option. We currently always
|
|
39
|
-
* strip additional keys, but could add this as a configurable option if users need it.
|
|
40
|
-
*/
|
|
41
|
-
export declare const stripFields: ({ config, data, fields, parentIsLocalized, reservedKeys, }: {
|
|
42
|
-
config: SanitizedConfig;
|
|
43
|
-
data: any;
|
|
44
|
-
fields: FlattenedField[];
|
|
45
|
-
parentIsLocalized?: boolean;
|
|
46
|
-
reservedKeys?: string[];
|
|
47
|
-
}) => void;
|
|
48
|
-
//# sourceMappingURL=stripFields.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stripFields.d.ts","sourceRoot":"","sources":["../../../../src/db-content-api/utilities/data/stripFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,WAAW,+DAMrB;IACD,MAAM,EAAE,eAAe,CAAA;IAEvB,IAAI,EAAE,GAAG,CAAA;IACT,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB,SAmLA,CAAA"}
|