@payloadcms/figma 0.1.0-alpha.0 → 0.1.0-alpha.10
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/LICENSE.md +1 -1
- package/dist/{utils → adapters}/asset-collection.d.ts +17 -3
- package/dist/adapters/asset-collection.js +242 -0
- package/dist/{utils → adapters}/build-lambda-zip.d.ts +8 -7
- package/dist/adapters/build-lambda-zip.js +111 -0
- package/dist/adapters/configureNextjsCache.d.ts +8 -0
- package/dist/adapters/configureNextjsCache.js +55 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput.d.ts +12 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput.js +28 -0
- package/dist/adapters/deploy-output/inspectNitroOutput.d.ts +9 -0
- package/dist/adapters/deploy-output/inspectNitroOutput.js +13 -0
- package/dist/adapters/deploy-output/isFile.d.ts +1 -0
- package/dist/adapters/deploy-output/isFile.js +4 -0
- package/dist/adapters/deploy-output/readJson.d.ts +1 -0
- package/dist/adapters/deploy-output/readJson.js +9 -0
- package/dist/adapters/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
- package/dist/adapters/deploy-output/resolveNitroOutputLayout.js +16 -0
- package/dist/adapters/deploy-output/resolveOutputPath.d.ts +2 -0
- package/dist/adapters/deploy-output/resolveOutputPath.js +9 -0
- package/dist/adapters/deploy-output/resolveWithin.d.ts +1 -0
- package/dist/adapters/deploy-output/resolveWithin.js +12 -0
- package/dist/adapters/fs-utils.d.ts +39 -0
- package/dist/adapters/fs-utils.js +135 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/lambda-runtime/nextjs-cache.d.ts +40 -0
- package/dist/adapters/lambda-runtime/nextjs-cache.js +174 -0
- package/dist/adapters/nextjs.d.ts +12 -0
- package/dist/adapters/nextjs.js +67 -0
- package/dist/adapters/nitro.d.ts +8 -0
- package/dist/adapters/nitro.js +193 -0
- package/dist/adapters/secret-files.d.ts +25 -0
- package/dist/adapters/secret-files.js +50 -0
- package/dist/adapters/types.d.ts +42 -0
- package/dist/adapters/types.js +1 -0
- package/dist/{utils/adapters → adapters}/vite.d.ts +2 -2
- package/dist/adapters/vite.js +33 -0
- package/dist/api/check-project-subdomain-availability.d.ts +12 -0
- package/dist/api/check-project-subdomain-availability.js +32 -0
- package/dist/api/control-plane-error.d.ts +6 -0
- package/dist/api/control-plane-error.js +8 -0
- package/dist/api/control-plane-fetch.d.ts +7 -0
- package/dist/api/control-plane-fetch.js +37 -0
- package/dist/api/control-plane.d.ts +1 -9
- package/dist/api/control-plane.js +2 -48
- package/dist/api/create-project.d.ts +18 -0
- package/dist/api/create-project.js +37 -0
- package/dist/api/list-project-workspaces.d.ts +8 -0
- package/dist/api/list-project-workspaces.js +28 -0
- package/dist/api/project-resource-type.d.ts +1 -0
- package/dist/api/project-resource-type.js +1 -0
- package/dist/auth/headless-oauth-flow.d.ts +23 -0
- package/dist/auth/headless-oauth-flow.js +69 -0
- package/dist/auth/oauth-flow.d.ts +2 -0
- package/dist/auth/oauth-flow.js +13 -8
- package/dist/auth/token-store.d.ts +4 -1
- package/dist/auth/token-store.js +14 -0
- package/dist/auth/types.d.ts +12 -0
- package/dist/cli.d.ts +39 -0
- package/dist/cli.js +71 -36
- package/dist/commands/bootstrap.js +2 -1
- package/dist/commands/build-lambda-zip.js +1 -1
- package/dist/commands/deploy.d.ts +12 -0
- package/dist/commands/deploy.js +63 -25
- package/dist/commands/detect-project-resource-type.d.ts +3 -0
- package/dist/commands/detect-project-resource-type.js +28 -0
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.js +164 -79
- package/dist/commands/login.d.ts +11 -1
- package/dist/commands/login.js +66 -4
- package/dist/commands/prompt-to-create-project/format-project-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-project-subdomain.js +3 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.js +7 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.js +13 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.d.ts +7 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.js +32 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.d.ts +8 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.js +27 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.js +54 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.js +23 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.d.ts +12 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.js +36 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.js +9 -0
- package/dist/commands/prompt-to-create-project.d.ts +24 -0
- package/dist/commands/prompt-to-create-project.js +69 -0
- package/dist/commands/setup-agent.d.ts +12 -0
- package/dist/commands/setup-agent.js +123 -0
- package/dist/commands/write-project-configuration.d.ts +12 -0
- package/dist/commands/write-project-configuration.js +16 -0
- package/dist/db-content-api/generated/content-api-types.d.ts +661 -16
- package/dist/db-content-api/index.d.ts +3 -0
- package/dist/db-content-api/index.js +155 -161
- package/dist/db-content-api/utilities/clientVersionHeaders.d.ts +7 -0
- package/dist/db-content-api/utilities/clientVersionHeaders.js +15 -0
- package/dist/db-content-api/utilities/data/atomicOperations.d.ts +16 -0
- package/dist/db-content-api/utilities/data/atomicOperations.js +48 -0
- package/dist/db-content-api/utilities/data/convertRelationshipIds.d.ts +25 -0
- package/dist/db-content-api/utilities/data/convertRelationshipIds.js +109 -0
- package/dist/db-content-api/utilities/data/index.js +73 -57
- package/dist/db-content-api/utilities/data/injectGlobalType.d.ts +6 -0
- package/dist/db-content-api/utilities/data/injectGlobalType.js +11 -0
- package/dist/db-content-api/utilities/data/isLocaleMap.d.ts +10 -0
- package/dist/db-content-api/utilities/data/isLocaleMap.js +13 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +3 -11
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +12 -50
- package/dist/db-content-api/utilities/data/resolveFieldLocalization.d.ts +18 -0
- package/dist/db-content-api/utilities/data/resolveFieldLocalization.js +21 -0
- package/dist/db-content-api/utilities/data/validateRelationships.js +19 -12
- package/dist/db-content-api/utilities/isRecord.d.ts +9 -0
- package/dist/db-content-api/utilities/isRecord.js +19 -0
- package/dist/db-content-api/utilities/joins.d.ts +6 -8
- package/dist/db-content-api/utilities/joins.js +13 -22
- package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.js +95 -0
- package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.d.ts +9 -0
- package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.js +112 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.d.ts +21 -4
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +118 -36
- package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
- package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
- package/dist/db-content-api/utilities/where.d.ts +3 -17
- package/dist/db-content-api/utilities/where.js +21 -21
- package/dist/exports/client.d.ts +2 -0
- package/dist/exports/client.js +2 -0
- package/dist/exports/views.d.ts +1 -0
- package/dist/exports/views.js +1 -0
- package/dist/imageSizeOptions.d.ts +23 -0
- package/dist/imageSizeOptions.js +26 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/write-agent-config.d.ts +12 -0
- package/dist/lib/write-agent-config.js +52 -0
- package/dist/next/image-loader.d.ts +6 -0
- package/dist/next/image-loader.js +14 -0
- package/dist/oauth/components/LoginButton/index.js +66 -19
- package/dist/oauth/components/LoginButton/index.scss +121 -15
- package/dist/oauth/defaults.js +4 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +5 -2
- package/dist/oauth/index.js +8 -7
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +1 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +1 -0
- package/dist/oauth/utilities/getAuthorizeURL.js +5 -1
- package/dist/plugin/build-config.d.ts +4 -2
- package/dist/plugin/build-config.js +95 -31
- package/dist/plugin/cache-revalidation-hooks.d.ts +6 -0
- package/dist/plugin/cache-revalidation-hooks.js +69 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +8 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.js +66 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +56 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +4 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +110 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.css +14 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.d.ts +4 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.js +52 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +7 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +1 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.js +27 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +2 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
- package/dist/plugin/cloud-limits/routes.d.ts +2 -0
- package/dist/plugin/cloud-limits/routes.js +4 -0
- package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.d.ts +9 -0
- package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.js +28 -0
- package/dist/plugin/cloud-limits/shared.d.ts +10 -0
- package/dist/plugin/cloud-limits/shared.js +52 -0
- package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.d.ts +2 -0
- package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.js +134 -0
- package/dist/plugin/cloud-limits/utilities/toasts.d.ts +4 -0
- package/dist/plugin/cloud-limits/utilities/toasts.js +19 -0
- package/dist/plugin/make-permission-access/make-permission-access.d.ts +8 -0
- package/dist/plugin/make-permission-access/make-permission-access.js +24 -0
- package/dist/plugin/sandbox-upload-fetch.d.ts +32 -0
- package/dist/plugin/sandbox-upload-fetch.js +53 -0
- package/dist/skills/deploy-to-figma/SKILL.md +234 -0
- package/dist/skills/deploy-to-figma/references/cli-reference.md +146 -0
- package/dist/storage-content-api/client-uploads/generate.js +2 -1
- package/dist/storage-content-api/getDownloadResponseHeaderPolicy.d.ts +11 -0
- package/dist/storage-content-api/getDownloadResponseHeaderPolicy.js +27 -0
- package/dist/storage-content-api/index.js +1 -0
- package/dist/storage-content-api/resolveDownloadResponseHeaders.d.ts +5 -0
- package/dist/storage-content-api/resolveDownloadResponseHeaders.js +13 -0
- package/dist/storage-content-api/staticHandler.js +2 -1
- package/dist/storage-content-api/types.d.ts +4 -1
- package/dist/translations/ar.d.ts +12 -0
- package/dist/translations/ar.js +12 -0
- package/dist/translations/az.d.ts +12 -0
- package/dist/translations/az.js +12 -0
- package/dist/translations/bg.d.ts +12 -0
- package/dist/translations/bg.js +12 -0
- package/dist/translations/bnBd.d.ts +12 -0
- package/dist/translations/bnBd.js +12 -0
- package/dist/translations/bnIn.d.ts +12 -0
- package/dist/translations/bnIn.js +12 -0
- package/dist/translations/ca.d.ts +12 -0
- package/dist/translations/ca.js +12 -0
- package/dist/translations/cs.d.ts +12 -0
- package/dist/translations/cs.js +12 -0
- package/dist/translations/da.d.ts +12 -0
- package/dist/translations/da.js +12 -0
- package/dist/translations/de.d.ts +12 -0
- package/dist/translations/de.js +12 -0
- package/dist/translations/en.d.ts +12 -0
- package/dist/translations/en.js +12 -0
- package/dist/translations/es.d.ts +12 -0
- package/dist/translations/es.js +12 -0
- package/dist/translations/et.d.ts +12 -0
- package/dist/translations/et.js +12 -0
- package/dist/translations/fa.d.ts +12 -0
- package/dist/translations/fa.js +12 -0
- package/dist/translations/fr.d.ts +12 -0
- package/dist/translations/fr.js +12 -0
- package/dist/translations/he.d.ts +12 -0
- package/dist/translations/he.js +12 -0
- package/dist/translations/hr.d.ts +12 -0
- package/dist/translations/hr.js +12 -0
- package/dist/translations/hu.d.ts +12 -0
- package/dist/translations/hu.js +12 -0
- package/dist/translations/hy.d.ts +12 -0
- package/dist/translations/hy.js +12 -0
- package/dist/translations/id.d.ts +12 -0
- package/dist/translations/id.js +12 -0
- package/dist/translations/index.d.ts +533 -0
- package/dist/translations/index.js +90 -0
- package/dist/translations/is.d.ts +12 -0
- package/dist/translations/is.js +12 -0
- package/dist/translations/it.d.ts +12 -0
- package/dist/translations/it.js +12 -0
- package/dist/translations/ja.d.ts +12 -0
- package/dist/translations/ja.js +12 -0
- package/dist/translations/ko.d.ts +12 -0
- package/dist/translations/ko.js +12 -0
- package/dist/translations/lt.d.ts +12 -0
- package/dist/translations/lt.js +12 -0
- package/dist/translations/lv.d.ts +12 -0
- package/dist/translations/lv.js +12 -0
- package/dist/translations/my.d.ts +12 -0
- package/dist/translations/my.js +12 -0
- package/dist/translations/nb.d.ts +12 -0
- package/dist/translations/nb.js +12 -0
- package/dist/translations/nl.d.ts +12 -0
- package/dist/translations/nl.js +12 -0
- package/dist/translations/pl.d.ts +12 -0
- package/dist/translations/pl.js +12 -0
- package/dist/translations/pt.d.ts +12 -0
- package/dist/translations/pt.js +12 -0
- package/dist/translations/ro.d.ts +12 -0
- package/dist/translations/ro.js +12 -0
- package/dist/translations/rs.d.ts +12 -0
- package/dist/translations/rs.js +12 -0
- package/dist/translations/rsLatin.d.ts +12 -0
- package/dist/translations/rsLatin.js +12 -0
- package/dist/translations/ru.d.ts +12 -0
- package/dist/translations/ru.js +12 -0
- package/dist/translations/sk.d.ts +12 -0
- package/dist/translations/sk.js +12 -0
- package/dist/translations/sl.d.ts +12 -0
- package/dist/translations/sl.js +12 -0
- package/dist/translations/sv.d.ts +12 -0
- package/dist/translations/sv.js +12 -0
- package/dist/translations/ta.d.ts +12 -0
- package/dist/translations/ta.js +12 -0
- package/dist/translations/th.d.ts +12 -0
- package/dist/translations/th.js +12 -0
- package/dist/translations/tr.d.ts +12 -0
- package/dist/translations/tr.js +12 -0
- package/dist/translations/uk.d.ts +12 -0
- package/dist/translations/uk.js +12 -0
- package/dist/translations/vi.d.ts +12 -0
- package/dist/translations/vi.js +12 -0
- package/dist/translations/zh.d.ts +12 -0
- package/dist/translations/zh.js +12 -0
- package/dist/translations/zhTw.d.ts +12 -0
- package/dist/translations/zhTw.js +12 -0
- package/dist/types.d.ts +11 -0
- package/dist/utils/assert-never.d.ts +1 -0
- package/dist/utils/assert-never.js +3 -0
- package/dist/utils/build-detection.d.ts +6 -1
- package/dist/utils/build-detection.js +68 -89
- package/dist/utils/deploy-adapter.d.ts +3 -35
- package/dist/utils/deploy-adapter.js +25 -14
- package/dist/utils/lambda-config.js +18 -23
- package/dist/utils/load-payload-config.d.ts +2 -2
- package/dist/utils/messages.js +24 -3
- package/dist/utils/next-image-loader-config.d.ts +2 -0
- package/dist/utils/next-image-loader-config.js +63 -0
- package/dist/utils/next-image-loader-file.d.ts +2 -0
- package/dist/utils/next-image-loader-file.js +11 -0
- package/dist/utils/payload-generate.d.ts +10 -0
- package/dist/utils/payload-generate.js +59 -0
- package/dist/utils/pnpm-builds.d.ts +14 -0
- package/dist/utils/pnpm-builds.js +125 -0
- package/dist/utils/s3-upload.js +4 -1
- package/package.json +31 -7
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +0 -10
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +0 -71
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +0 -41
- package/dist/db-content-api/utilities/meta/buildMeta.js +0 -39
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +0 -16
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +0 -243
- package/dist/db-content-api/utilities/meta/buildUniquePaths.d.ts +0 -12
- package/dist/db-content-api/utilities/meta/buildUniquePaths.js +0 -60
- package/dist/lib/download-skill.d.ts +0 -12
- package/dist/lib/download-skill.js +0 -77
- package/dist/utils/adapters/nextjs.d.ts +0 -8
- package/dist/utils/adapters/nextjs.js +0 -61
- package/dist/utils/adapters/nitro.d.ts +0 -8
- package/dist/utils/adapters/nitro.js +0 -172
- package/dist/utils/adapters/vite.js +0 -31
- package/dist/utils/asset-collection.js +0 -144
- package/dist/utils/build-lambda-zip.js +0 -90
- package/dist/utils/fs-utils.d.ts +0 -12
- package/dist/utils/fs-utils.js +0 -55
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { resolveBlocks } from '../resolveBlocks.js';
|
|
2
|
-
/**
|
|
3
|
-
* Extracts all field paths from a where clause recursively
|
|
4
|
-
*/ function extractPathsFromWhere(where, paths = new Set()) {
|
|
5
|
-
if (!where || typeof where !== 'object') {
|
|
6
|
-
return paths;
|
|
7
|
-
}
|
|
8
|
-
// Handle 'and' operator
|
|
9
|
-
if ('and' in where && Array.isArray(where.and)) {
|
|
10
|
-
for (const clause of where.and){
|
|
11
|
-
extractPathsFromWhere(clause, paths);
|
|
12
|
-
}
|
|
13
|
-
return paths;
|
|
14
|
-
}
|
|
15
|
-
// Handle 'or' operator
|
|
16
|
-
if ('or' in where && Array.isArray(where.or)) {
|
|
17
|
-
for (const clause of where.or){
|
|
18
|
-
extractPathsFromWhere(clause, paths);
|
|
19
|
-
}
|
|
20
|
-
return paths;
|
|
21
|
-
}
|
|
22
|
-
// Handle regular conditions - keys are field paths
|
|
23
|
-
for(const key in where){
|
|
24
|
-
if (key === 'and' || key === 'or') {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
// Add the path
|
|
28
|
-
paths.add(key.replace(/__/g, '.'));
|
|
29
|
-
// Check if the value is a nested where clause (for relationships)
|
|
30
|
-
const value = where[key];
|
|
31
|
-
if (value && typeof value === 'object' && !('equals' in value) && !('in' in value)) {
|
|
32
|
-
// Might be a nested where, recurse
|
|
33
|
-
extractPathsFromWhere(value, paths);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return paths;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Determines the type of a field based on its configuration.
|
|
40
|
-
* Returns PathTypeValue for fields that need special handling in Content API queries.
|
|
41
|
-
*/ function getFieldType(field) {
|
|
42
|
-
// Array field
|
|
43
|
-
if (field.type === 'array') {
|
|
44
|
-
return 'array';
|
|
45
|
-
}
|
|
46
|
-
// Blocks field (array of objects)
|
|
47
|
-
if (field.type === 'blocks') {
|
|
48
|
-
return 'array';
|
|
49
|
-
}
|
|
50
|
-
// Relationship field - always include for JOIN support
|
|
51
|
-
if (field.type === 'relationship') {
|
|
52
|
-
const { hasMany = false, relationTo: collection } = field;
|
|
53
|
-
return {
|
|
54
|
-
type: 'relationship',
|
|
55
|
-
collection,
|
|
56
|
-
hasMany
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
// Upload field - treated like relationship
|
|
60
|
-
if (field.type === 'upload') {
|
|
61
|
-
const { hasMany = false, relationTo: collection } = field;
|
|
62
|
-
return {
|
|
63
|
-
type: 'relationship',
|
|
64
|
-
collection,
|
|
65
|
-
hasMany
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
// Join field - virtual reverse lookup
|
|
69
|
-
if (field.type === 'join') {
|
|
70
|
-
const { collection, on } = field;
|
|
71
|
-
return {
|
|
72
|
-
type: 'join',
|
|
73
|
-
collection,
|
|
74
|
-
hasMany: true,
|
|
75
|
-
on
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
// Text field with hasMany (array of strings)
|
|
79
|
-
if (field.type === 'text' && 'hasMany' in field && field.hasMany) {
|
|
80
|
-
return 'array';
|
|
81
|
-
}
|
|
82
|
-
// Number field with hasMany (array of numbers)
|
|
83
|
-
if (field.type === 'number' && 'hasMany' in field && field.hasMany) {
|
|
84
|
-
return 'array';
|
|
85
|
-
}
|
|
86
|
-
// Select field with hasMany (array)
|
|
87
|
-
if (field.type === 'select' && 'hasMany' in field && field.hasMany) {
|
|
88
|
-
return 'array';
|
|
89
|
-
}
|
|
90
|
-
// Objects (group, collapsible, row, tabs) don't need traversal
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Finds a field in the collection schema by its path.
|
|
95
|
-
* Supports nested paths like "access.read.users".
|
|
96
|
-
* For localized array/blocks fields, locale key segments (e.g. "en") are skipped transparently,
|
|
97
|
-
* so "localizedBlocks.en.richText" resolves to the richText field inside localizedBlocks.
|
|
98
|
-
*/ function findFieldByPath(payload, collectionSlug, path) {
|
|
99
|
-
const collectionConfig = payload.config.collections.find((c)=>c.slug === collectionSlug);
|
|
100
|
-
if (!collectionConfig) {
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
const localeCodes = payload.config.localization ? payload.config.localization.localeCodes : [];
|
|
104
|
-
const pathSegments = path.split('.');
|
|
105
|
-
// Walk through the path segments to find the field
|
|
106
|
-
let currentFields = collectionConfig.fields;
|
|
107
|
-
let currentField = undefined;
|
|
108
|
-
for(let i = 0; i < pathSegments.length; i++){
|
|
109
|
-
const segment = pathSegments[i];
|
|
110
|
-
// If this segment is a locale key for the previously found localized array/blocks field,
|
|
111
|
-
// skip it transparently (the locale key is the wrapping object key, not a real field).
|
|
112
|
-
if (localeCodes.includes(segment) && currentField && 'localized' in currentField && currentField.localized && (currentField.type === 'blocks' || currentField.type === 'array')) {
|
|
113
|
-
if (i === pathSegments.length - 1) {
|
|
114
|
-
// Last segment is a locale key → return the localized field (represents locale-specific array)
|
|
115
|
-
return currentField;
|
|
116
|
-
}
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
// First try to find a direct match
|
|
120
|
-
currentField = currentFields.find((f)=>'name' in f && f.name === segment);
|
|
121
|
-
// If not found, check if any unnamed container fields (collapsible, row) contain it
|
|
122
|
-
if (!currentField) {
|
|
123
|
-
for (const field of currentFields){
|
|
124
|
-
if (!('name' in field) || !field.name) {
|
|
125
|
-
// This is an unnamed field, check its contents
|
|
126
|
-
if ('fields' in field && field.type === 'collapsible' || 'fields' in field && field.type === 'row' || 'fields' in field && field.type === 'group') {
|
|
127
|
-
currentField = field.fields.find((f)=>'name' in f && f.name === segment);
|
|
128
|
-
if (currentField) {
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
} else if ('tabs' in field && field.type === 'tabs') {
|
|
132
|
-
// Check all tabs
|
|
133
|
-
for (const tab of field.tabs){
|
|
134
|
-
// Named tab: the tab name itself is a path segment (acts like a group)
|
|
135
|
-
if ('name' in tab && tab.name === segment) {
|
|
136
|
-
currentField = {
|
|
137
|
-
name: tab.name,
|
|
138
|
-
type: 'group',
|
|
139
|
-
fields: tab.fields
|
|
140
|
-
};
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
// Unnamed tab: search its fields for the segment
|
|
144
|
-
const found = tab.fields.find((f)=>'name' in f && f.name === segment);
|
|
145
|
-
if (found) {
|
|
146
|
-
currentField = found;
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (currentField) {
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (!currentField) {
|
|
158
|
-
return undefined;
|
|
159
|
-
}
|
|
160
|
-
// If we're not at the end, get nested fields
|
|
161
|
-
if (i < pathSegments.length - 1) {
|
|
162
|
-
if (currentField.type === 'group' && 'fields' in currentField) {
|
|
163
|
-
currentFields = currentField.fields;
|
|
164
|
-
} else if (currentField.type === 'array' && 'fields' in currentField) {
|
|
165
|
-
currentFields = currentField.fields;
|
|
166
|
-
} else if (currentField.type === 'blocks' && 'blocks' in currentField) {
|
|
167
|
-
// Collect all fields from all block definitions to continue traversal
|
|
168
|
-
const allBlockFields = [];
|
|
169
|
-
for (const block of resolveBlocks(currentField.blocks, payload.config.blocks)){
|
|
170
|
-
allBlockFields.push(...block.fields);
|
|
171
|
-
}
|
|
172
|
-
currentFields = allBlockFields;
|
|
173
|
-
} else if ((currentField.type === 'relationship' || currentField.type === 'upload') && typeof currentField.relationTo === 'string') {
|
|
174
|
-
// Traverse into the related collection's fields
|
|
175
|
-
const { relationTo } = currentField;
|
|
176
|
-
const relatedConfig = payload.config.collections.find((c)=>c.slug === relationTo);
|
|
177
|
-
if (relatedConfig) {
|
|
178
|
-
currentFields = relatedConfig.fields;
|
|
179
|
-
} else {
|
|
180
|
-
return undefined;
|
|
181
|
-
}
|
|
182
|
-
} else {
|
|
183
|
-
// Field doesn't have nested fields, can't continue
|
|
184
|
-
return undefined;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return currentField;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Builds pathTypes metadata for Content API request.
|
|
192
|
-
* Returns a record of paths with their types for proper query generation.
|
|
193
|
-
*
|
|
194
|
-
* Includes:
|
|
195
|
-
* - Array fields (type: "array")
|
|
196
|
-
* - Relationship fields (type: { type: "relationship", collection, hasMany })
|
|
197
|
-
* - Join fields (type: { type: "join", collection, hasMany, on })
|
|
198
|
-
*
|
|
199
|
-
* Localized array/blocks fields (stored as locale maps) are handled specially:
|
|
200
|
-
* - The localized field itself is NOT marked as 'array' (it's a locale map object)
|
|
201
|
-
* - The locale-specific path (e.g. "localizedBlocks.en") IS marked as 'array'
|
|
202
|
-
*/ export function buildPathTypes(payload, collectionSlug, where) {
|
|
203
|
-
if (!where) {
|
|
204
|
-
return {};
|
|
205
|
-
}
|
|
206
|
-
const localeCodes = payload.config.localization ? payload.config.localization.localeCodes : [];
|
|
207
|
-
const pathTypes = {};
|
|
208
|
-
const paths = extractPathsFromWhere(where);
|
|
209
|
-
for (const path of paths){
|
|
210
|
-
// For each path, we need to check all segments to see if any intermediate ones are arrays/relationships
|
|
211
|
-
const segments = path.split('.');
|
|
212
|
-
for(let i = 0; i < segments.length; i++){
|
|
213
|
-
const partialPath = segments.slice(0, i + 1).join('.');
|
|
214
|
-
// Skip if we already have this path
|
|
215
|
-
if (partialPath in pathTypes) {
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
// If the current segment is a locale code and the parent field is a localized array/blocks,
|
|
219
|
-
// mark this locale-specific path as 'array' (the per-locale content is the actual array).
|
|
220
|
-
if (i > 0 && localeCodes.includes(segments[i])) {
|
|
221
|
-
const parentPath = segments.slice(0, i).join('.');
|
|
222
|
-
const parentField = findFieldByPath(payload, collectionSlug, parentPath);
|
|
223
|
-
if (parentField && 'localized' in parentField && parentField.localized && (parentField.type === 'blocks' || parentField.type === 'array')) {
|
|
224
|
-
pathTypes[partialPath] = 'array';
|
|
225
|
-
continue;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
const field = findFieldByPath(payload, collectionSlug, partialPath);
|
|
229
|
-
if (field) {
|
|
230
|
-
// Localized array/blocks fields are stored as locale maps (not arrays).
|
|
231
|
-
// Skip them here — the locale-specific path (e.g. "localizedBlocks.en") is marked above.
|
|
232
|
-
if ('localized' in field && field.localized && (field.type === 'blocks' || field.type === 'array')) {
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
const fieldType = getFieldType(field);
|
|
236
|
-
if (fieldType !== null) {
|
|
237
|
-
pathTypes[partialPath] = fieldType;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return pathTypes;
|
|
243
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Payload } from 'payload';
|
|
2
|
-
import type { components } from '../../generated/content-api-types.js';
|
|
3
|
-
type UniquePath = components['schemas']['UniquePath'];
|
|
4
|
-
/**
|
|
5
|
-
* Builds a UniquePath[] from the collection's field config by collecting
|
|
6
|
-
* all fields with `unique: true` that have a non-null value in the data.
|
|
7
|
-
*
|
|
8
|
-
* Fields with null/undefined values are excluded to match sparse unique index
|
|
9
|
-
* behavior (multiple documents can have null for a unique field).
|
|
10
|
-
*/
|
|
11
|
-
export declare function buildUniquePaths(payload: Payload, collectionSlug: string, data: Record<string, unknown>): UniquePath[];
|
|
12
|
-
export {};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds a UniquePath[] from the collection's field config by collecting
|
|
3
|
-
* all fields with `unique: true` that have a non-null value in the data.
|
|
4
|
-
*
|
|
5
|
-
* Fields with null/undefined values are excluded to match sparse unique index
|
|
6
|
-
* behavior (multiple documents can have null for a unique field).
|
|
7
|
-
*/ export function buildUniquePaths(payload, collectionSlug, data) {
|
|
8
|
-
const isGlobal = collectionSlug.startsWith('_global-');
|
|
9
|
-
const actualSlug = isGlobal ? collectionSlug.substring(8) : collectionSlug;
|
|
10
|
-
const config = isGlobal ? payload.config.globals?.find((g)=>g.slug === actualSlug) : payload.config.collections.find((c)=>c.slug === actualSlug);
|
|
11
|
-
if (!config?.fields) {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
const unique = [];
|
|
15
|
-
collectUniqueFields(config.fields, '', data, unique);
|
|
16
|
-
return unique;
|
|
17
|
-
}
|
|
18
|
-
function getValueAtPath(data, path) {
|
|
19
|
-
const segments = path.split('.');
|
|
20
|
-
let current = data;
|
|
21
|
-
for (const segment of segments){
|
|
22
|
-
if (current == null || typeof current !== 'object') {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
current = current[segment];
|
|
26
|
-
}
|
|
27
|
-
return current;
|
|
28
|
-
}
|
|
29
|
-
function collectUniqueFields(fields, prefix, data, result) {
|
|
30
|
-
for (const field of fields){
|
|
31
|
-
if (field.type === 'row' || field.type === 'collapsible') {
|
|
32
|
-
collectUniqueFields(field.fields, prefix, data, result);
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (field.type === 'tabs') {
|
|
36
|
-
for (const tab of field.tabs){
|
|
37
|
-
const tabPrefix = 'name' in tab && tab.name ? `${prefix}${tab.name}.` : prefix;
|
|
38
|
-
collectUniqueFields(tab.fields, tabPrefix, data, result);
|
|
39
|
-
}
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (!('name' in field) || !field.name) {
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
const path = prefix + field.name;
|
|
46
|
-
if ('unique' in field && field.unique) {
|
|
47
|
-
const value = getValueAtPath(data, path);
|
|
48
|
-
if (value != null) {
|
|
49
|
-
result.push({
|
|
50
|
-
paths: [
|
|
51
|
-
path
|
|
52
|
-
]
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (field.type === 'group' && 'fields' in field) {
|
|
57
|
-
collectUniqueFields(field.fields, `${path}.`, data, result);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type DownloadSkillResult = {
|
|
2
|
-
detail?: string;
|
|
3
|
-
ok: false;
|
|
4
|
-
reason: 'already-installed' | 'empty-extract' | 'error' | 'fetch-failed';
|
|
5
|
-
} | {
|
|
6
|
-
ok: true;
|
|
7
|
-
};
|
|
8
|
-
export declare function downloadSkill(args: {
|
|
9
|
-
branch?: string;
|
|
10
|
-
debug?: boolean;
|
|
11
|
-
projectDir: string;
|
|
12
|
-
}): Promise<DownloadSkillResult>;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import { Readable } from 'node:stream';
|
|
3
|
-
import { pipeline } from 'node:stream/promises';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { x } from 'tar';
|
|
6
|
-
export async function downloadSkill(args) {
|
|
7
|
-
const { branch = 'main', debug, projectDir } = args;
|
|
8
|
-
const destDir = path.join(projectDir, '.claude', 'skills', 'payload');
|
|
9
|
-
if (await pathExists(path.join(destDir, 'SKILL.md'))) {
|
|
10
|
-
return {
|
|
11
|
-
ok: false,
|
|
12
|
-
reason: 'already-installed'
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
const url = `https://codeload.github.com/payloadcms/payload/tar.gz/${branch}`;
|
|
16
|
-
const filter = `payload-${branch.replace(/^v/, '').replaceAll('/', '-')}/tools/claude-plugin/skills/payload/`;
|
|
17
|
-
if (debug) {
|
|
18
|
-
// eslint-disable-next-line no-console
|
|
19
|
-
console.log(`[download-skill] url=${url} dest=${destDir}`);
|
|
20
|
-
}
|
|
21
|
-
try {
|
|
22
|
-
const res = await fetch(url);
|
|
23
|
-
if (!res.ok) {
|
|
24
|
-
return {
|
|
25
|
-
detail: `${res.status} ${res.statusText}`,
|
|
26
|
-
ok: false,
|
|
27
|
-
reason: 'fetch-failed'
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
if (!res.body) {
|
|
31
|
-
return {
|
|
32
|
-
detail: 'empty response body',
|
|
33
|
-
ok: false,
|
|
34
|
-
reason: 'fetch-failed'
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
await fs.mkdir(destDir, {
|
|
38
|
-
recursive: true
|
|
39
|
-
});
|
|
40
|
-
await pipeline(Readable.from(res.body), x({
|
|
41
|
-
cwd: destDir,
|
|
42
|
-
filter: (p)=>p.includes(filter),
|
|
43
|
-
strip: filter.split('/').length - 1
|
|
44
|
-
}));
|
|
45
|
-
if (!await pathExists(path.join(destDir, 'SKILL.md'))) {
|
|
46
|
-
await fs.rm(destDir, {
|
|
47
|
-
force: true,
|
|
48
|
-
recursive: true
|
|
49
|
-
});
|
|
50
|
-
return {
|
|
51
|
-
ok: false,
|
|
52
|
-
reason: 'empty-extract'
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
ok: true
|
|
57
|
-
};
|
|
58
|
-
} catch (err) {
|
|
59
|
-
await fs.rm(destDir, {
|
|
60
|
-
force: true,
|
|
61
|
-
recursive: true
|
|
62
|
-
}).catch(()=>{});
|
|
63
|
-
return {
|
|
64
|
-
detail: err instanceof Error ? err.message : String(err),
|
|
65
|
-
ok: false,
|
|
66
|
-
reason: 'error'
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async function pathExists(p) {
|
|
71
|
-
try {
|
|
72
|
-
await fs.access(p);
|
|
73
|
-
return true;
|
|
74
|
-
} catch {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { AssetCollection, DeployAdapter, LambdaBundle, PageCollection } from '../deploy-adapter.js';
|
|
2
|
-
export declare class NextjsAdapter implements DeployAdapter {
|
|
3
|
-
name: "nextjs";
|
|
4
|
-
collectAssets(projectPath: string): Promise<AssetCollection>;
|
|
5
|
-
collectPages(projectPath: string): Promise<PageCollection>;
|
|
6
|
-
prepareLambdaBundle(projectPath: string): Promise<LambdaBundle>;
|
|
7
|
-
}
|
|
8
|
-
export declare const nextjsAdapter: NextjsAdapter;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { collectSSGAssets, collectStaticAssets } from '../asset-collection.js';
|
|
4
|
-
import { buildLambdaZip } from '../build-lambda-zip.js';
|
|
5
|
-
import { collectFilesRecursive } from '../fs-utils.js';
|
|
6
|
-
export class NextjsAdapter {
|
|
7
|
-
name = 'nextjs';
|
|
8
|
-
async collectAssets(projectPath) {
|
|
9
|
-
// Bundle assets: .next/static/ → _next/static/
|
|
10
|
-
const staticAssets = await collectStaticAssets(projectPath);
|
|
11
|
-
// Public assets: public/ directory
|
|
12
|
-
const publicDir = path.join(projectPath, 'public');
|
|
13
|
-
let publicAssets = [];
|
|
14
|
-
try {
|
|
15
|
-
await fs.stat(publicDir);
|
|
16
|
-
publicAssets = await collectFilesRecursive(publicDir, publicDir);
|
|
17
|
-
} catch {
|
|
18
|
-
// No public directory
|
|
19
|
-
}
|
|
20
|
-
const allKeys = [
|
|
21
|
-
...staticAssets,
|
|
22
|
-
...publicAssets
|
|
23
|
-
];
|
|
24
|
-
const pathMap = {};
|
|
25
|
-
for (const key of staticAssets){
|
|
26
|
-
pathMap[key] = key.replace(/^_next\//, '.next/');
|
|
27
|
-
}
|
|
28
|
-
for (const key of publicAssets){
|
|
29
|
-
pathMap[key] = path.join('public', key);
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
pathMap,
|
|
33
|
-
routes: allKeys.map((k)=>`/${k}`),
|
|
34
|
-
uploadKeys: allKeys
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
async collectPages(projectPath) {
|
|
38
|
-
const ssg = await collectSSGAssets(projectPath);
|
|
39
|
-
// Build route → asset keys mapping and extract unique routes
|
|
40
|
-
const routeAssetMap = {};
|
|
41
|
-
for (const key of ssg.keys){
|
|
42
|
-
// Strip extension to get the base, then derive the route
|
|
43
|
-
const base = key.replace(/\.(?:html|rsc|meta)$/, '');
|
|
44
|
-
const route = base === 'index' ? '/' : `/${base}`;
|
|
45
|
-
if (!routeAssetMap[route]) {
|
|
46
|
-
routeAssetMap[route] = [];
|
|
47
|
-
}
|
|
48
|
-
routeAssetMap[route].push(key);
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
pathMap: ssg.pathMap,
|
|
52
|
-
routeAssetMap,
|
|
53
|
-
routes: Object.keys(routeAssetMap),
|
|
54
|
-
uploadKeys: ssg.keys
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
async prepareLambdaBundle(projectPath) {
|
|
58
|
-
return buildLambdaZip(projectPath);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export const nextjsAdapter = new NextjsAdapter();
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { AssetCollection, DeployAdapter, LambdaBundle, PageCollection } from '../deploy-adapter.js';
|
|
2
|
-
export declare class NitroAdapter implements DeployAdapter {
|
|
3
|
-
name: "nitro";
|
|
4
|
-
collectAssets(projectPath: string): Promise<AssetCollection>;
|
|
5
|
-
collectPages(projectPath: string): Promise<PageCollection>;
|
|
6
|
-
prepareLambdaBundle(projectPath: string): Promise<LambdaBundle>;
|
|
7
|
-
}
|
|
8
|
-
export declare const nitroAdapter: NitroAdapter;
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import archiver from 'archiver';
|
|
2
|
-
import { createWriteStream, statSync } from 'fs';
|
|
3
|
-
import fs from 'fs/promises';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { collectFilesRecursive, getDirectorySize } from '../fs-utils.js';
|
|
6
|
-
const RUN_SCRIPT = `#!/bin/bash -x
|
|
7
|
-
[ ! -d '/tmp/cache' ] && mkdir -p /tmp/cache
|
|
8
|
-
NODE_ENV=production exec node server/index.mjs
|
|
9
|
-
`;
|
|
10
|
-
/** Directories in .output/public/ that are NOT pre-rendered pages */ const NON_PAGE_DIRS = new Set([
|
|
11
|
-
'_next',
|
|
12
|
-
'assets'
|
|
13
|
-
]);
|
|
14
|
-
export class NitroAdapter {
|
|
15
|
-
name = 'nitro';
|
|
16
|
-
async collectAssets(projectPath) {
|
|
17
|
-
const publicDir = path.join(projectPath, '.output', 'public');
|
|
18
|
-
const assets = [];
|
|
19
|
-
const pathMap = {};
|
|
20
|
-
// Collect flat files in .output/public/ (public dir assets)
|
|
21
|
-
try {
|
|
22
|
-
const entries = await fs.readdir(publicDir, {
|
|
23
|
-
withFileTypes: true
|
|
24
|
-
});
|
|
25
|
-
for (const entry of entries){
|
|
26
|
-
if (entry.isFile()) {
|
|
27
|
-
assets.push(entry.name);
|
|
28
|
-
pathMap[entry.name] = path.join('.output', 'public', entry.name);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
} catch {
|
|
32
|
-
// No public directory
|
|
33
|
-
}
|
|
34
|
-
// Collect bundle assets from .output/public/_next/static/
|
|
35
|
-
const bundleDir = path.join(publicDir, '_next', 'static');
|
|
36
|
-
try {
|
|
37
|
-
const bundleFiles = await collectFilesRecursive(bundleDir, bundleDir);
|
|
38
|
-
for (const file of bundleFiles){
|
|
39
|
-
const key = `_next/static/${file}`;
|
|
40
|
-
assets.push(key);
|
|
41
|
-
pathMap[key] = path.join('.output', 'public', '_next', 'static', file);
|
|
42
|
-
}
|
|
43
|
-
} catch {
|
|
44
|
-
// No bundle directory
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
pathMap,
|
|
48
|
-
routes: assets.map((k)=>`/${k}`),
|
|
49
|
-
uploadKeys: assets
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
async collectPages(projectPath) {
|
|
53
|
-
const publicDir = path.join(projectPath, '.output', 'public');
|
|
54
|
-
const pages = await scanForPages(publicDir, publicDir);
|
|
55
|
-
const routes = pages.map((p)=>p === 'index' ? '/' : `/${p}`);
|
|
56
|
-
const uploadKeys = pages.map((p)=>p === 'index' ? 'index.html' : `${p}/index.html`);
|
|
57
|
-
const pathMap = {};
|
|
58
|
-
const routeAssetMap = {};
|
|
59
|
-
for(let i = 0; i < uploadKeys.length; i++){
|
|
60
|
-
pathMap[uploadKeys[i]] = path.join('.output', 'public', uploadKeys[i]);
|
|
61
|
-
routeAssetMap[routes[i]] = [
|
|
62
|
-
uploadKeys[i]
|
|
63
|
-
];
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
pathMap,
|
|
67
|
-
routeAssetMap,
|
|
68
|
-
routes,
|
|
69
|
-
uploadKeys
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
async prepareLambdaBundle(projectPath) {
|
|
73
|
-
const zipPath = path.join(projectPath, 'lambda.zip');
|
|
74
|
-
const serverDir = path.join(projectPath, '.output', 'server');
|
|
75
|
-
const publicDir = path.join(projectPath, '.output', 'public');
|
|
76
|
-
// Verify server directory exists
|
|
77
|
-
try {
|
|
78
|
-
await fs.stat(serverDir);
|
|
79
|
-
} catch {
|
|
80
|
-
throw new Error('Nitro server build not found at .output/server. Run build first.');
|
|
81
|
-
}
|
|
82
|
-
// Write run.sh to a temp location
|
|
83
|
-
const runShPath = path.join(projectPath, '.output', 'run.sh');
|
|
84
|
-
await fs.writeFile(runShPath, RUN_SCRIPT, {
|
|
85
|
-
mode: 0o755
|
|
86
|
-
});
|
|
87
|
-
// Create zip: server/ + public/ + run.sh
|
|
88
|
-
await createZip(zipPath, [
|
|
89
|
-
{
|
|
90
|
-
prefix: 'server/',
|
|
91
|
-
source: serverDir
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
prefix: 'public/',
|
|
95
|
-
source: publicDir
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
prefix: '',
|
|
99
|
-
source: runShPath
|
|
100
|
-
}
|
|
101
|
-
]);
|
|
102
|
-
const runShStat = await fs.stat(runShPath);
|
|
103
|
-
const unzippedBytes = await getDirectorySize(serverDir) + await getDirectorySize(publicDir) + runShStat.size;
|
|
104
|
-
// Clean up temp run.sh
|
|
105
|
-
await fs.rm(runShPath, {
|
|
106
|
-
force: true
|
|
107
|
-
});
|
|
108
|
-
return {
|
|
109
|
-
unzippedBytes,
|
|
110
|
-
zipPath
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
export const nitroAdapter = new NitroAdapter();
|
|
115
|
-
/**
|
|
116
|
-
* Recursively scan for pre-rendered pages (directories containing index.html).
|
|
117
|
-
* Skips known non-page directories (_next/, assets/).
|
|
118
|
-
*/ async function scanForPages(dir, baseDir) {
|
|
119
|
-
const pages = [];
|
|
120
|
-
// Check if this directory has an index.html (it's a page)
|
|
121
|
-
const indexPath = path.join(dir, 'index.html');
|
|
122
|
-
try {
|
|
123
|
-
await fs.stat(indexPath);
|
|
124
|
-
const relative = path.relative(baseDir, dir);
|
|
125
|
-
pages.push(relative || 'index'); // root dir -> 'index'
|
|
126
|
-
} catch {
|
|
127
|
-
// Not a page directory
|
|
128
|
-
}
|
|
129
|
-
// Recurse into subdirectories
|
|
130
|
-
try {
|
|
131
|
-
const entries = await fs.readdir(dir, {
|
|
132
|
-
withFileTypes: true
|
|
133
|
-
});
|
|
134
|
-
for (const entry of entries){
|
|
135
|
-
if (entry.isDirectory() && !NON_PAGE_DIRS.has(entry.name)) {
|
|
136
|
-
const subPages = await scanForPages(path.join(dir, entry.name), baseDir);
|
|
137
|
-
pages.push(...subPages);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
} catch {
|
|
141
|
-
// Directory not readable
|
|
142
|
-
}
|
|
143
|
-
return pages;
|
|
144
|
-
}
|
|
145
|
-
async function createZip(zipPath, entries) {
|
|
146
|
-
return new Promise((resolve, reject)=>{
|
|
147
|
-
const output = createWriteStream(zipPath);
|
|
148
|
-
const archive = archiver('zip', {
|
|
149
|
-
zlib: {
|
|
150
|
-
level: 9
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
output.on('close', ()=>resolve());
|
|
154
|
-
archive.on('error', (err)=>reject(err));
|
|
155
|
-
archive.pipe(output);
|
|
156
|
-
for (const entry of entries){
|
|
157
|
-
try {
|
|
158
|
-
const stat = statSync(entry.source);
|
|
159
|
-
if (stat.isDirectory()) {
|
|
160
|
-
archive.directory(entry.source, entry.prefix.replace(/\/$/, '') || false);
|
|
161
|
-
} else {
|
|
162
|
-
archive.file(entry.source, {
|
|
163
|
-
name: entry.prefix + path.basename(entry.source)
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
} catch {
|
|
167
|
-
// Skip missing entries
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
void archive.finalize();
|
|
171
|
-
});
|
|
172
|
-
}
|