@payloadcms/figma 0.0.1-alpha.2 → 0.0.1-alpha.20

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.
Files changed (72) hide show
  1. package/dist/api/control-plane.d.ts +1 -1
  2. package/dist/api/control-plane.d.ts.map +1 -1
  3. package/dist/api/control-plane.js +12 -7
  4. package/dist/api/control-plane.js.map +1 -1
  5. package/dist/api/figma-api.d.ts.map +1 -1
  6. package/dist/api/figma-api.js +33 -10
  7. package/dist/api/figma-api.js.map +1 -1
  8. package/dist/auth/crypto-utils.d.ts.map +1 -1
  9. package/dist/auth/crypto-utils.js +5 -5
  10. package/dist/auth/crypto-utils.js.map +1 -1
  11. package/dist/auth/oauth-flow.js +3 -3
  12. package/dist/auth/oauth-flow.js.map +1 -1
  13. package/dist/auth/project-token.d.ts.map +1 -1
  14. package/dist/auth/project-token.js +7 -3
  15. package/dist/auth/project-token.js.map +1 -1
  16. package/dist/auth/token-store.d.ts.map +1 -1
  17. package/dist/auth/token-store.js +3 -0
  18. package/dist/auth/token-store.js.map +1 -1
  19. package/dist/cli.js +1 -0
  20. package/dist/cli.js.map +1 -1
  21. package/dist/commands/deploy.d.ts +2 -0
  22. package/dist/commands/deploy.d.ts.map +1 -1
  23. package/dist/commands/deploy.js +11 -6
  24. package/dist/commands/deploy.js.map +1 -1
  25. package/dist/commands/init.d.ts.map +1 -1
  26. package/dist/commands/init.js +14 -76
  27. package/dist/commands/init.js.map +1 -1
  28. package/dist/commands/login.d.ts +8 -1
  29. package/dist/commands/login.d.ts.map +1 -1
  30. package/dist/commands/login.js +10 -4
  31. package/dist/commands/login.js.map +1 -1
  32. package/dist/config/oauth.d.ts.map +1 -1
  33. package/dist/config/oauth.js +3 -3
  34. package/dist/config/oauth.js.map +1 -1
  35. package/dist/db-adapter.d.ts +17 -0
  36. package/dist/db-adapter.d.ts.map +1 -0
  37. package/dist/db-adapter.js +760 -0
  38. package/dist/db-adapter.js.map +1 -0
  39. package/dist/endpoints/health.d.ts +3 -0
  40. package/dist/endpoints/health.d.ts.map +1 -0
  41. package/dist/endpoints/health.js +11 -0
  42. package/dist/endpoints/health.js.map +1 -0
  43. package/dist/exports/client.d.ts +3 -0
  44. package/dist/exports/client.d.ts.map +1 -0
  45. package/dist/exports/client.js +4 -0
  46. package/dist/exports/client.js.map +1 -0
  47. package/dist/oauth/components/LoginButton/index.d.ts.map +1 -1
  48. package/dist/oauth/components/LoginButton/index.js +50 -6
  49. package/dist/oauth/components/LoginButton/index.js.map +1 -1
  50. package/dist/oauth/components/LoginButton/index.scss +50 -3
  51. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
  52. package/dist/oauth/endpoints/getLoginEndpoint.js +1 -1
  53. package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
  54. package/dist/oauth/index.d.ts.map +1 -1
  55. package/dist/oauth/index.js +30 -6
  56. package/dist/oauth/index.js.map +1 -1
  57. package/dist/oauth/utilities/refreshTokens.d.ts.map +1 -1
  58. package/dist/oauth/utilities/refreshTokens.js +1 -1
  59. package/dist/oauth/utilities/refreshTokens.js.map +1 -1
  60. package/dist/plugin/build-config.d.ts +3 -5
  61. package/dist/plugin/build-config.d.ts.map +1 -1
  62. package/dist/plugin/build-config.js +28 -14
  63. package/dist/plugin/build-config.js.map +1 -1
  64. package/dist/utils/payload-config-ast.d.ts +1 -1
  65. package/dist/utils/payload-config-ast.d.ts.map +1 -1
  66. package/dist/utils/payload-config-ast.js +7 -7
  67. package/dist/utils/payload-config-ast.js.map +1 -1
  68. package/dist/utils/s3-upload.d.ts +0 -1
  69. package/dist/utils/s3-upload.d.ts.map +1 -1
  70. package/dist/utils/s3-upload.js +10 -3
  71. package/dist/utils/s3-upload.js.map +1 -1
  72. package/package.json +10 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/oauth/utilities/refreshTokens.ts"],"sourcesContent":["import type jwt from 'jsonwebtoken'\nimport type { Payload } from 'payload'\n\nimport { generateCookie } from 'payload'\n\nimport type { Strategy } from '../strategy/index.js'\n\nimport { getProjectToken } from '../../api/figma-api.js'\nimport { validateProjectToken } from '../../auth/jwt-validator.js'\nimport { getEnvironment } from '../../constants.js'\nimport { createCookieOptions } from './createCookieOptions.js'\nimport { createDebugLogger } from './createDebugLogger.js'\nimport { getCookieExpiration } from './getCookieExpiration.js'\nimport { getTokenExp } from './getTokenExp.js'\n\ninterface Args {\n payload: Payload\n refreshToken: string\n strategy: Strategy\n}\n\ntype Result =\n | {\n decodedOauthToken: jwt.JwtPayload\n headers: Headers\n token: string\n }\n | false\n\nexport const refreshTokens = async ({ payload, refreshToken, strategy }: Args): Promise<Result> => {\n const debugLogger = createDebugLogger(payload, strategy.debug)\n\n debugLogger.info({\n msg: 'Refreshing tokens',\n })\n\n const headers = new Headers()\n\n // At this point, access token is expired\n // but refresh token is still valid\n // so we will refresh both tokens\n\n try {\n // Get another project token\n const { expiresAt, token } = await getProjectToken(refreshToken, 'someproject')\n\n debugLogger.info({\n expiresAt,\n msg: 'Received new tokens from Figma API',\n token,\n })\n\n // On error, no user\n if (!token) {\n debugLogger.error({\n msg: 'Error refreshing tokens',\n })\n return false\n }\n\n if (token) {\n debugLogger.info({\n msg: 'Successfully refreshed project token',\n token,\n })\n\n const expires_in = new Date(expiresAt)\n\n const cookieOptions = createCookieOptions({\n collection: strategy.collection,\n headers,\n pluginOptions: strategy.pluginOptions,\n })\n\n const tokenCookie = generateCookie({\n ...cookieOptions,\n name: strategy.cookieName,\n expires: getCookieExpiration(expires_in),\n returnCookieAsObject: false,\n value: token,\n }) as string\n\n headers.append('Set-Cookie', tokenCookie)\n\n const decodedOauthToken = await validateProjectToken(token, getEnvironment())\n\n return { decodedOauthToken, headers, token }\n }\n } catch (error) {\n debugLogger.error({\n err: error,\n msg: 'Error refreshing tokens',\n })\n }\n\n return false\n}\n"],"names":["generateCookie","getProjectToken","validateProjectToken","getEnvironment","createCookieOptions","createDebugLogger","getCookieExpiration","refreshTokens","payload","refreshToken","strategy","debugLogger","debug","info","msg","headers","Headers","expiresAt","token","error","expires_in","Date","cookieOptions","collection","pluginOptions","tokenCookie","name","cookieName","expires","returnCookieAsObject","value","append","decodedOauthToken","err"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAIxC,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,oBAAoB,QAAQ,8BAA6B;AAClE,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,mBAAmB,QAAQ,2BAA0B;AAiB9D,OAAO,MAAMC,gBAAgB,OAAO,EAAEC,OAAO,EAAEC,YAAY,EAAEC,QAAQ,EAAQ;IAC3E,MAAMC,cAAcN,kBAAkBG,SAASE,SAASE,KAAK;IAE7DD,YAAYE,IAAI,CAAC;QACfC,KAAK;IACP;IAEA,MAAMC,UAAU,IAAIC;IAEpB,yCAAyC;IACzC,mCAAmC;IACnC,iCAAiC;IAEjC,IAAI;QACF,4BAA4B;QAC5B,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAG,MAAMjB,gBAAgBQ,cAAc;QAEjEE,YAAYE,IAAI,CAAC;YACfI;YACAH,KAAK;YACLI;QACF;QAEA,oBAAoB;QACpB,IAAI,CAACA,OAAO;YACVP,YAAYQ,KAAK,CAAC;gBAChBL,KAAK;YACP;YACA,OAAO;QACT;QAEA,IAAII,OAAO;YACTP,YAAYE,IAAI,CAAC;gBACfC,KAAK;gBACLI;YACF;YAEA,MAAME,aAAa,IAAIC,KAAKJ;YAE5B,MAAMK,gBAAgBlB,oBAAoB;gBACxCmB,YAAYb,SAASa,UAAU;gBAC/BR;gBACAS,eAAed,SAASc,aAAa;YACvC;YAEA,MAAMC,cAAczB,eAAe;gBACjC,GAAGsB,aAAa;gBAChBI,MAAMhB,SAASiB,UAAU;gBACzBC,SAAStB,oBAAoBc;gBAC7BS,sBAAsB;gBACtBC,OAAOZ;YACT;YAEAH,QAAQgB,MAAM,CAAC,cAAcN;YAE7B,MAAMO,oBAAoB,MAAM9B,qBAAqBgB,OAAOf;YAE5D,OAAO;gBAAE6B;gBAAmBjB;gBAASG;YAAM;QAC7C;IACF,EAAE,OAAOC,OAAO;QACdR,YAAYQ,KAAK,CAAC;YAChBc,KAAKd;YACLL,KAAK;QACP;IACF;IAEA,OAAO;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/oauth/utilities/refreshTokens.ts"],"sourcesContent":["import type jwt from 'jsonwebtoken'\nimport type { Payload } from 'payload'\n\nimport { generateCookie } from 'payload'\n\nimport type { Strategy } from '../strategy/index.js'\n\nimport { getProjectToken } from '../../api/figma-api.js'\nimport { validateProjectToken } from '../../auth/jwt-validator.js'\nimport { getEnvironment } from '../../constants.js'\nimport { createCookieOptions } from './createCookieOptions.js'\nimport { createDebugLogger } from './createDebugLogger.js'\nimport { getCookieExpiration } from './getCookieExpiration.js'\n\ninterface Args {\n payload: Payload\n refreshToken: string\n strategy: Strategy\n}\n\ntype Result =\n | {\n decodedOauthToken: jwt.JwtPayload\n headers: Headers\n token: string\n }\n | false\n\nexport const refreshTokens = async ({ payload, refreshToken, strategy }: Args): Promise<Result> => {\n const debugLogger = createDebugLogger(payload, strategy.debug)\n\n debugLogger.info({\n msg: 'Refreshing tokens',\n })\n\n const headers = new Headers()\n\n // At this point, access token is expired\n // but refresh token is still valid\n // so we will refresh both tokens\n\n try {\n // Get another project token\n const { expiresAt, token } = await getProjectToken(\n refreshToken,\n payload.config.custom.figma.tenantId,\n )\n\n debugLogger.info({\n expiresAt,\n msg: 'Received new tokens from Figma API',\n token,\n })\n\n // On error, no user\n if (!token) {\n debugLogger.error({\n msg: 'Error refreshing tokens',\n })\n return false\n }\n\n if (token) {\n debugLogger.info({\n msg: 'Successfully refreshed project token',\n token,\n })\n\n const expires_in = new Date(expiresAt)\n\n const cookieOptions = createCookieOptions({\n collection: strategy.collection,\n headers,\n pluginOptions: strategy.pluginOptions,\n })\n\n const tokenCookie = generateCookie({\n ...cookieOptions,\n name: strategy.cookieName,\n expires: getCookieExpiration(expires_in),\n returnCookieAsObject: false,\n value: token,\n }) as string\n\n headers.append('Set-Cookie', tokenCookie)\n\n const decodedOauthToken = await validateProjectToken(token, getEnvironment())\n\n return { decodedOauthToken, headers, token }\n }\n } catch (error) {\n debugLogger.error({\n err: error,\n msg: 'Error refreshing tokens',\n })\n }\n\n return false\n}\n"],"names":["generateCookie","getProjectToken","validateProjectToken","getEnvironment","createCookieOptions","createDebugLogger","getCookieExpiration","refreshTokens","payload","refreshToken","strategy","debugLogger","debug","info","msg","headers","Headers","expiresAt","token","config","custom","figma","tenantId","error","expires_in","Date","cookieOptions","collection","pluginOptions","tokenCookie","name","cookieName","expires","returnCookieAsObject","value","append","decodedOauthToken","err"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAIxC,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,oBAAoB,QAAQ,8BAA6B;AAClE,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,mBAAmB,QAAQ,2BAA0B;AAgB9D,OAAO,MAAMC,gBAAgB,OAAO,EAAEC,OAAO,EAAEC,YAAY,EAAEC,QAAQ,EAAQ;IAC3E,MAAMC,cAAcN,kBAAkBG,SAASE,SAASE,KAAK;IAE7DD,YAAYE,IAAI,CAAC;QACfC,KAAK;IACP;IAEA,MAAMC,UAAU,IAAIC;IAEpB,yCAAyC;IACzC,mCAAmC;IACnC,iCAAiC;IAEjC,IAAI;QACF,4BAA4B;QAC5B,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAG,MAAMjB,gBACjCQ,cACAD,QAAQW,MAAM,CAACC,MAAM,CAACC,KAAK,CAACC,QAAQ;QAGtCX,YAAYE,IAAI,CAAC;YACfI;YACAH,KAAK;YACLI;QACF;QAEA,oBAAoB;QACpB,IAAI,CAACA,OAAO;YACVP,YAAYY,KAAK,CAAC;gBAChBT,KAAK;YACP;YACA,OAAO;QACT;QAEA,IAAII,OAAO;YACTP,YAAYE,IAAI,CAAC;gBACfC,KAAK;gBACLI;YACF;YAEA,MAAMM,aAAa,IAAIC,KAAKR;YAE5B,MAAMS,gBAAgBtB,oBAAoB;gBACxCuB,YAAYjB,SAASiB,UAAU;gBAC/BZ;gBACAa,eAAelB,SAASkB,aAAa;YACvC;YAEA,MAAMC,cAAc7B,eAAe;gBACjC,GAAG0B,aAAa;gBAChBI,MAAMpB,SAASqB,UAAU;gBACzBC,SAAS1B,oBAAoBkB;gBAC7BS,sBAAsB;gBACtBC,OAAOhB;YACT;YAEAH,QAAQoB,MAAM,CAAC,cAAcN;YAE7B,MAAMO,oBAAoB,MAAMlC,qBAAqBgB,OAAOf;YAE5D,OAAO;gBAAEiC;gBAAmBrB;gBAASG;YAAM;QAC7C;IACF,EAAE,OAAOK,OAAO;QACdZ,YAAYY,KAAK,CAAC;YAChBc,KAAKd;YACLT,KAAK;QACP;IACF;IAEA,OAAO;AACT,EAAC"}
@@ -24,11 +24,11 @@ export type FigmaConfig = {
24
24
  editor?: Config['editor'];
25
25
  } & {
26
26
  figma: {
27
+ contentSystemId: string;
27
28
  region: string;
28
- tenantId: string;
29
29
  useContentSystem?: boolean;
30
30
  };
31
- } & Omit<Config, 'editor' | 'secret'>;
31
+ } & Omit<Config, 'db' | 'editor' | 'secret'> & Partial<Pick<Config, 'db'>>;
32
32
  /**
33
33
  * Figma platform wrapper for Payload's buildConfig.
34
34
  * Automatically injects:
@@ -39,7 +39,5 @@ export type FigmaConfig = {
39
39
  * @param config - Payload configuration (db and secret omitted, editor optional)
40
40
  * @returns Promise<SanitizedConfig> - Built Payload configuration
41
41
  */
42
- export declare function buildConfig(config: FigmaConfig, options?: {
43
- useContentSystem: boolean;
44
- }): Promise<SanitizedConfig>;
42
+ export declare function buildConfig(config: FigmaConfig): Promise<SanitizedConfig>;
45
43
  //# sourceMappingURL=build-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-config.d.ts","sourceRoot":"","sources":["../../src/plugin/build-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAQtD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;CAC1B,GAAG;IACF,KAAK,EAAE;QACL,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,EAAE,MAAM,CAAA;QAChB,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC3B,CAAA;CACF,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAA;AAErC;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE;IAAE,gBAAgB,EAAE,OAAO,CAAA;CAA+B,GAClE,OAAO,CAAC,eAAe,CAAC,CAwC1B"}
1
+ {"version":3,"file":"build-config.d.ts","sourceRoot":"","sources":["../../src/plugin/build-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAWtD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;CAC1B,GAAG;IACF,KAAK,EAAE;QACL,eAAe,EAAE,MAAM,CAAA;QACvB,MAAM,EAAE,MAAM,CAAA;QACd,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC3B,CAAA;CACF,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,QAAQ,CAAC,GAC1C,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;AAE7B;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CA4D/E"}
@@ -1,7 +1,10 @@
1
1
  import { lexicalEditor } from '@payloadcms/richtext-lexical';
2
2
  import { buildConfig as payloadBuildConfig } from 'payload';
3
+ import { getValidProjectToken } from '../auth/project-token.js';
4
+ import { TokenStore } from '../auth/token-store.js';
5
+ import { contentAPIAdapter } from '../db-adapter.js';
6
+ import { health } from '../endpoints/health.js';
3
7
  import { oAuth2Plugin } from '../oauth/index.js';
4
- import { figmaContentSystem } from './adapter.js';
5
8
  /**
6
9
  * Figma platform wrapper for Payload's buildConfig.
7
10
  * Automatically injects:
@@ -11,18 +14,33 @@ import { figmaContentSystem } from './adapter.js';
11
14
  *
12
15
  * @param config - Payload configuration (db and secret omitted, editor optional)
13
16
  * @returns Promise<SanitizedConfig> - Built Payload configuration
14
- */ export async function buildConfig(config, options = {
15
- useContentSystem: true
16
- }) {
17
+ */ export async function buildConfig(config) {
18
+ let projectToken = '';
19
+ if (!process.env.FIGMA_CONTENT_API_ACCESS_KEY) {
20
+ const tokenStore = new TokenStore();
21
+ const retrievedToken = await getValidProjectToken(tokenStore, config.figma.contentSystemId);
22
+ if (retrievedToken) {
23
+ projectToken = retrievedToken;
24
+ }
25
+ }
17
26
  // Build complete config with Figma platform defaults
18
27
  const configWithFigmaDefaults = {
19
28
  ...config,
20
- ...options.useContentSystem ? {
21
- db: figmaContentSystem()
22
- } : {
23
- db: config.db
29
+ custom: {
30
+ figma: config.figma || {}
24
31
  },
32
+ // TODO: - cms-tenants-001-staging needs to be dynamic in the future
33
+ db: config.figma.useContentSystem !== false ? contentAPIAdapter({
34
+ contentApiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY,
35
+ contentApiUrl: process.env.FIGMA_CONTENT_API_URL || `https://${config.figma.region}.cms-tenants-001-staging.figmacontentstaging.com`,
36
+ contentSystemId: config.figma.contentSystemId,
37
+ projectToken
38
+ }) : config.db,
25
39
  editor: config.editor ?? lexicalEditor(),
40
+ endpoints: [
41
+ ...config.endpoints ?? [],
42
+ health
43
+ ],
26
44
  secret: 'MY_SECRET',
27
45
  // Add oauth to plugins if not already present
28
46
  plugins: [
@@ -46,15 +64,11 @@ import { figmaContentSystem } from './adapter.js';
46
64
  usernameField: 'email'
47
65
  }
48
66
  ],
49
- debug: true,
50
- disabled: false,
51
- redirectServerURL: 'http://localhost:3000'
67
+ debug: !!process.env.DEBUG,
68
+ disabled: false
52
69
  })
53
70
  ]
54
71
  };
55
- if (options.useContentSystem) {
56
- configWithFigmaDefaults.db = figmaContentSystem();
57
- }
58
72
  // Delegate to Payload's buildConfig
59
73
  return await payloadBuildConfig(configWithFigmaDefaults);
60
74
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugin/build-config.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload'\n\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\nimport { buildConfig as payloadBuildConfig } from 'payload'\n\nimport { oAuth2Plugin } from '../oauth/index.js'\nimport { figmaContentSystem } from './adapter.js'\n\n/**\n * Configuration type for Payload projects on the Figma platform.\n *\n * Differences from standard Payload Config:\n * - `db`: Omitted (auto-injected by Figma platform)\n * - `secret`: Omitted (auto-injected by Figma platform)\n * - `editor`: Optional (defaults to lexicalEditor() if not provided)\n *\n * @example\n * // Minimal config\n * const config: FigmaConfig = {\n * collections: [...]\n * }\n *\n * @example\n * // With custom editor\n * const config: FigmaConfig = {\n * collections: [...],\n * editor: lexicalEditor({ features: [...] })\n * }\n */\nexport type FigmaConfig = {\n editor?: Config['editor']\n} & {\n figma: {\n region: string\n tenantId: string\n useContentSystem?: boolean\n }\n} & Omit<Config, 'editor' | 'secret'>\n\n/**\n * Figma platform wrapper for Payload's buildConfig.\n * Automatically injects:\n * - Figma database adapter\n * - Secret (platform-provided)\n * - Default lexicalEditor (if no custom editor specified)\n *\n * @param config - Payload configuration (db and secret omitted, editor optional)\n * @returns Promise<SanitizedConfig> - Built Payload configuration\n */\nexport async function buildConfig(\n config: FigmaConfig,\n options: { useContentSystem: boolean } = { useContentSystem: true },\n): Promise<SanitizedConfig> {\n // Build complete config with Figma platform defaults\n const configWithFigmaDefaults: Config = {\n ...config,\n ...(options.useContentSystem ? { db: figmaContentSystem() } : { db: config.db }),\n editor: config.editor ?? lexicalEditor(),\n secret: 'MY_SECRET',\n // Add oauth to plugins if not already present\n plugins: [\n ...(config.plugins ?? []),\n oAuth2Plugin({\n collections: [\n {\n slug: 'users',\n // Use adapter because Figma app doesn't support OIDC scopes\n authorizationURLParams: {\n response_mode: 'query',\n response_type: 'code',\n },\n clientID: process.env.FIGMA_OAUTH_CLIENT_ID!,\n clientSecret: process.env.FIGMA_OAUTH_CLIENT_SECRET,\n identityMetadata: 'https://staging.figma.com/.well-known/openid-configuration',\n scope: ['current_user:read'],\n token: 'id_token', // Adapter creates JWT id_token from Figma user info\n usernameField: 'email',\n },\n ],\n debug: true,\n disabled: false,\n redirectServerURL: 'http://localhost:3000',\n }),\n ],\n }\n\n if (options.useContentSystem) {\n configWithFigmaDefaults.db = figmaContentSystem()\n }\n\n // Delegate to Payload's buildConfig\n return await payloadBuildConfig(configWithFigmaDefaults)\n}\n"],"names":["lexicalEditor","buildConfig","payloadBuildConfig","oAuth2Plugin","figmaContentSystem","config","options","useContentSystem","configWithFigmaDefaults","db","editor","secret","plugins","collections","slug","authorizationURLParams","response_mode","response_type","clientID","process","env","FIGMA_OAUTH_CLIENT_ID","clientSecret","FIGMA_OAUTH_CLIENT_SECRET","identityMetadata","scope","token","usernameField","debug","disabled","redirectServerURL"],"mappings":"AAEA,SAASA,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,eAAeC,kBAAkB,QAAQ,UAAS;AAE3D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,kBAAkB,QAAQ,eAAc;AAiCjD;;;;;;;;;CASC,GACD,OAAO,eAAeH,YACpBI,MAAmB,EACnBC,UAAyC;IAAEC,kBAAkB;AAAK,CAAC;IAEnE,qDAAqD;IACrD,MAAMC,0BAAkC;QACtC,GAAGH,MAAM;QACT,GAAIC,QAAQC,gBAAgB,GAAG;YAAEE,IAAIL;QAAqB,IAAI;YAAEK,IAAIJ,OAAOI,EAAE;QAAC,CAAC;QAC/EC,QAAQL,OAAOK,MAAM,IAAIV;QACzBW,QAAQ;QACR,8CAA8C;QAC9CC,SAAS;eACHP,OAAOO,OAAO,IAAI,EAAE;YACxBT,aAAa;gBACXU,aAAa;oBACX;wBACEC,MAAM;wBACN,4DAA4D;wBAC5DC,wBAAwB;4BACtBC,eAAe;4BACfC,eAAe;wBACjB;wBACAC,UAAUC,QAAQC,GAAG,CAACC,qBAAqB;wBAC3CC,cAAcH,QAAQC,GAAG,CAACG,yBAAyB;wBACnDC,kBAAkB;wBAClBC,OAAO;4BAAC;yBAAoB;wBAC5BC,OAAO;wBACPC,eAAe;oBACjB;iBACD;gBACDC,OAAO;gBACPC,UAAU;gBACVC,mBAAmB;YACrB;SACD;IACH;IAEA,IAAIxB,QAAQC,gBAAgB,EAAE;QAC5BC,wBAAwBC,EAAE,GAAGL;IAC/B;IAEA,oCAAoC;IACpC,OAAO,MAAMF,mBAAmBM;AAClC"}
1
+ {"version":3,"sources":["../../src/plugin/build-config.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload'\n\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\nimport { buildConfig as payloadBuildConfig } from 'payload'\n\nimport { getValidProjectToken } from '../auth/project-token.js'\nimport { TokenStore } from '../auth/token-store.js'\nimport { contentAPIAdapter } from '../db-adapter.js'\nimport { health } from '../endpoints/health.js'\nimport { oAuth2Plugin } from '../oauth/index.js'\n\n/**\n * Configuration type for Payload projects on the Figma platform.\n *\n * Differences from standard Payload Config:\n * - `db`: Omitted (auto-injected by Figma platform)\n * - `secret`: Omitted (auto-injected by Figma platform)\n * - `editor`: Optional (defaults to lexicalEditor() if not provided)\n *\n * @example\n * // Minimal config\n * const config: FigmaConfig = {\n * collections: [...]\n * }\n *\n * @example\n * // With custom editor\n * const config: FigmaConfig = {\n * collections: [...],\n * editor: lexicalEditor({ features: [...] })\n * }\n */\nexport type FigmaConfig = {\n editor?: Config['editor']\n} & {\n figma: {\n contentSystemId: string\n region: string\n useContentSystem?: boolean\n }\n} & Omit<Config, 'db' | 'editor' | 'secret'> &\n Partial<Pick<Config, 'db'>>\n\n/**\n * Figma platform wrapper for Payload's buildConfig.\n * Automatically injects:\n * - Figma database adapter\n * - Secret (platform-provided)\n * - Default lexicalEditor (if no custom editor specified)\n *\n * @param config - Payload configuration (db and secret omitted, editor optional)\n * @returns Promise<SanitizedConfig> - Built Payload configuration\n */\nexport async function buildConfig(config: FigmaConfig): Promise<SanitizedConfig> {\n let projectToken = ''\n\n if (!process.env.FIGMA_CONTENT_API_ACCESS_KEY) {\n const tokenStore = new TokenStore()\n const retrievedToken = await getValidProjectToken(tokenStore, config.figma.contentSystemId)\n if (retrievedToken) {\n projectToken = retrievedToken\n }\n }\n\n // Build complete config with Figma platform defaults\n const configWithFigmaDefaults: Config = {\n ...config,\n custom: {\n figma: config.figma || {},\n },\n // TODO: - cms-tenants-001-staging needs to be dynamic in the future\n db:\n config.figma.useContentSystem !== false\n ? contentAPIAdapter({\n contentApiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY!,\n contentApiUrl:\n process.env.FIGMA_CONTENT_API_URL ||\n `https://${config.figma.region}.cms-tenants-001-staging.figmacontentstaging.com`,\n contentSystemId: config.figma.contentSystemId,\n projectToken,\n })\n : config.db!,\n editor: config.editor ?? lexicalEditor(),\n endpoints: [...(config.endpoints ?? []), health],\n secret: 'MY_SECRET',\n // Add oauth to plugins if not already present\n plugins: [\n ...(config.plugins ?? []),\n oAuth2Plugin({\n collections: [\n {\n slug: 'users',\n // Use adapter because Figma app doesn't support OIDC scopes\n authorizationURLParams: {\n response_mode: 'query',\n response_type: 'code',\n },\n clientID: process.env.FIGMA_OAUTH_CLIENT_ID!,\n clientSecret: process.env.FIGMA_OAUTH_CLIENT_SECRET,\n identityMetadata: 'https://staging.figma.com/.well-known/openid-configuration',\n scope: ['current_user:read'],\n token: 'id_token', // Adapter creates JWT id_token from Figma user info\n usernameField: 'email',\n },\n ],\n debug: !!process.env.DEBUG,\n disabled: false,\n }),\n ],\n }\n\n // Delegate to Payload's buildConfig\n return await payloadBuildConfig(configWithFigmaDefaults)\n}\n"],"names":["lexicalEditor","buildConfig","payloadBuildConfig","getValidProjectToken","TokenStore","contentAPIAdapter","health","oAuth2Plugin","config","projectToken","process","env","FIGMA_CONTENT_API_ACCESS_KEY","tokenStore","retrievedToken","figma","contentSystemId","configWithFigmaDefaults","custom","db","useContentSystem","contentApiKey","contentApiUrl","FIGMA_CONTENT_API_URL","region","editor","endpoints","secret","plugins","collections","slug","authorizationURLParams","response_mode","response_type","clientID","FIGMA_OAUTH_CLIENT_ID","clientSecret","FIGMA_OAUTH_CLIENT_SECRET","identityMetadata","scope","token","usernameField","debug","DEBUG","disabled"],"mappings":"AAEA,SAASA,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,eAAeC,kBAAkB,QAAQ,UAAS;AAE3D,SAASC,oBAAoB,QAAQ,2BAA0B;AAC/D,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,iBAAiB,QAAQ,mBAAkB;AACpD,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,SAASC,YAAY,QAAQ,oBAAmB;AAkChD;;;;;;;;;CASC,GACD,OAAO,eAAeN,YAAYO,MAAmB;IACnD,IAAIC,eAAe;IAEnB,IAAI,CAACC,QAAQC,GAAG,CAACC,4BAA4B,EAAE;QAC7C,MAAMC,aAAa,IAAIT;QACvB,MAAMU,iBAAiB,MAAMX,qBAAqBU,YAAYL,OAAOO,KAAK,CAACC,eAAe;QAC1F,IAAIF,gBAAgB;YAClBL,eAAeK;QACjB;IACF;IAEA,qDAAqD;IACrD,MAAMG,0BAAkC;QACtC,GAAGT,MAAM;QACTU,QAAQ;YACNH,OAAOP,OAAOO,KAAK,IAAI,CAAC;QAC1B;QACA,oEAAoE;QACpEI,IACEX,OAAOO,KAAK,CAACK,gBAAgB,KAAK,QAC9Bf,kBAAkB;YAChBgB,eAAeX,QAAQC,GAAG,CAACC,4BAA4B;YACvDU,eACEZ,QAAQC,GAAG,CAACY,qBAAqB,IACjC,CAAC,QAAQ,EAAEf,OAAOO,KAAK,CAACS,MAAM,CAAC,gDAAgD,CAAC;YAClFR,iBAAiBR,OAAOO,KAAK,CAACC,eAAe;YAC7CP;QACF,KACAD,OAAOW,EAAE;QACfM,QAAQjB,OAAOiB,MAAM,IAAIzB;QACzB0B,WAAW;eAAKlB,OAAOkB,SAAS,IAAI,EAAE;YAAGpB;SAAO;QAChDqB,QAAQ;QACR,8CAA8C;QAC9CC,SAAS;eACHpB,OAAOoB,OAAO,IAAI,EAAE;YACxBrB,aAAa;gBACXsB,aAAa;oBACX;wBACEC,MAAM;wBACN,4DAA4D;wBAC5DC,wBAAwB;4BACtBC,eAAe;4BACfC,eAAe;wBACjB;wBACAC,UAAUxB,QAAQC,GAAG,CAACwB,qBAAqB;wBAC3CC,cAAc1B,QAAQC,GAAG,CAAC0B,yBAAyB;wBACnDC,kBAAkB;wBAClBC,OAAO;4BAAC;yBAAoB;wBAC5BC,OAAO;wBACPC,eAAe;oBACjB;iBACD;gBACDC,OAAO,CAAC,CAAChC,QAAQC,GAAG,CAACgC,KAAK;gBAC1BC,UAAU;YACZ;SACD;IACH;IAEA,oCAAoC;IACpC,OAAO,MAAM1C,mBAAmBe;AAClC"}
@@ -29,8 +29,8 @@ export type ASTModificationResult = {
29
29
  */
30
30
  export declare function applyModifications(sourceFile: SourceFile, detection: DetectionResult): ASTModificationResult;
31
31
  export type FigmaPropertyConfig = {
32
+ contentSystemId: string;
32
33
  region: string;
33
- tenantId: string;
34
34
  useContentSystem: boolean;
35
35
  };
36
36
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"payload-config-ast.d.ts","sourceRoot":"","sources":["../../src/utils/payload-config-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAM1C,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE;QACX,OAAO,EAAE,MAAM,CAAA;QACf,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,cAAc,CAAC,EAAE;QACf,YAAY,EAAE,MAAM,CAAA;QACpB,SAAS,EAAE,OAAO,CAAA;KACnB,CAAA;IACD,iBAAiB,EAAE,OAAO,CAAA;IAC1B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,sBAAsB,EAAE,OAAO,CAAA;IAC/B,iBAAiB,EAAE,OAAO,CAAA;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,eAAe,CAiJ7E;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AA0CD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,eAAe,GACzB,qBAAqB,CAyJvB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,mBAAmB,GAC1B,qBAAqB,CA+CvB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,mBAAmB,GAAG,IAAI,CA0ElF"}
1
+ {"version":3,"file":"payload-config-ast.d.ts","sourceRoot":"","sources":["../../src/utils/payload-config-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAM1C,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE;QACX,OAAO,EAAE,MAAM,CAAA;QACf,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,cAAc,CAAC,EAAE;QACf,YAAY,EAAE,MAAM,CAAA;QACpB,SAAS,EAAE,OAAO,CAAA;KACnB,CAAA;IACD,iBAAiB,EAAE,OAAO,CAAA;IAC1B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,sBAAsB,EAAE,OAAO,CAAA;IAC/B,iBAAiB,EAAE,OAAO,CAAA;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,eAAe,CAiJ7E;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AA0CD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,eAAe,GACzB,qBAAqB,CAyJvB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,mBAAmB,GAC1B,qBAAqB,CA+CvB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,mBAAmB,GAAG,IAAI,CAoElF"}
@@ -340,11 +340,11 @@ import * as log from './log.js';
340
340
  name: 'figma',
341
341
  initializer: `{
342
342
  region: '${config.region}',
343
- tenantId: '${config.tenantId}',
343
+ contentSystemId: '${config.contentSystemId}',
344
344
  useContentSystem: ${config.useContentSystem},
345
345
  }`
346
346
  });
347
- changes.push(`Added figma property (region: ${config.region}, tenantId: ${config.tenantId}, useContentSystem: ${config.useContentSystem})`);
347
+ changes.push(`Added figma property (region: ${config.region}, tenantId: ${config.contentSystemId}, useContentSystem: ${config.useContentSystem})`);
348
348
  modified = true;
349
349
  return {
350
350
  changes,
@@ -386,24 +386,24 @@ import * as log from './log.js';
386
386
  }
387
387
  // Extract values
388
388
  const regionProp = initializer.getProperty('region');
389
- const tenantIdProp = initializer.getProperty('tenantId');
389
+ const contentSystemIdProp = initializer.getProperty('contentSystemId');
390
390
  const useContentSystemProp = initializer.getProperty('useContentSystem');
391
- if (!regionProp || !tenantIdProp) {
391
+ if (!regionProp || !contentSystemIdProp) {
392
392
  log.debug('Missing required figma properties (region or tenantId)');
393
393
  return null;
394
394
  }
395
395
  // Extract string values (remove quotes)
396
396
  const region = Node.isPropertyAssignment(regionProp) ? regionProp.getInitializer()?.getText().replace(/['"]/g, '') : undefined;
397
- const tenantId = Node.isPropertyAssignment(tenantIdProp) ? tenantIdProp.getInitializer()?.getText().replace(/['"]/g, '') : undefined;
397
+ const contentSystemId = Node.isPropertyAssignment(contentSystemIdProp) ? contentSystemIdProp.getInitializer()?.getText().replace(/['"]/g, '') : undefined;
398
398
  const useContentSystem = Node.isPropertyAssignment(useContentSystemProp) ? useContentSystemProp.getInitializer()?.getText() === 'true' : true // Default to true if not specified
399
399
  ;
400
- if (!region || !tenantId) {
400
+ if (!region || !contentSystemId) {
401
401
  log.debug('Could not extract region or tenantId values');
402
402
  return null;
403
403
  }
404
404
  return {
405
+ contentSystemId,
405
406
  region,
406
- tenantId,
407
407
  useContentSystem
408
408
  };
409
409
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/payload-config-ast.ts"],"sourcesContent":["import type { SourceFile } from 'ts-morph'\n\nimport { Node, SyntaxKind } from 'ts-morph'\n\nimport * as log from './log.js'\n\nexport type DetectionResult = {\n dbProperty?: {\n adapter: string\n importSource: string\n }\n editorProperty?: {\n importSource: string\n isDefault: boolean\n }\n figmaObjectExists: boolean\n hasAlias: boolean\n hasBuildConfig?: boolean\n hasOtherPayloadImports: boolean\n needsImportChange: boolean\n secretProperty?: boolean\n}\n\n/**\n * Detect what changes are needed in the payload config file\n */\nexport function detectRequiredChanges(sourceFile: SourceFile): DetectionResult {\n const result: DetectionResult = {\n figmaObjectExists: false,\n hasAlias: false,\n hasOtherPayloadImports: false,\n needsImportChange: false,\n }\n\n // Find buildConfig import\n const imports = sourceFile.getImportDeclarations()\n const payloadImport = imports.find(\n (imp) =>\n imp.getModuleSpecifierValue() === 'payload' ||\n imp.getModuleSpecifierValue() === '@payloadcms/figma',\n )\n\n if (!payloadImport) {\n log.debug('No payload or @payloadcms/figma import found')\n result.hasBuildConfig = false\n return result\n }\n\n log.debug(`Found import from: ${payloadImport.getModuleSpecifierValue()}`)\n\n const moduleSpecifier = payloadImport.getModuleSpecifierValue()\n const namedImports = payloadImport.getNamedImports()\n\n // Check if buildConfig is imported\n const buildConfigImport = namedImports.find((ni) => ni.getName() === 'buildConfig')\n\n if (!buildConfigImport) {\n result.hasBuildConfig = false\n return result\n }\n\n // Check for alias and get the actual name used in code\n const aliasNode = buildConfigImport.getAliasNode()\n const buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig'\n if (aliasNode) {\n result.hasAlias = true\n }\n\n // Check if import needs change\n if (moduleSpecifier === 'payload') {\n result.needsImportChange = true\n\n // Check if there are other imports from payload\n if (namedImports.length > 1) {\n result.hasOtherPayloadImports = true\n }\n }\n\n // Find buildConfig call in export default\n // First try to find export default with the buildConfig call\n const exportAssignment = sourceFile.getFirstDescendantByKind(SyntaxKind.ExportAssignment)\n let buildConfigCall = null\n\n if (exportAssignment) {\n // Look for buildConfig call in the export default\n const callExpressions = exportAssignment.getDescendantsOfKind(SyntaxKind.CallExpression)\n buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n return expr.getText() === buildConfigName\n })\n }\n\n // If not found in export default, search all call expressions\n if (!buildConfigCall) {\n const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)\n buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n return expr.getText() === buildConfigName\n })\n }\n\n if (!buildConfigCall) {\n result.hasBuildConfig = false\n return result\n }\n\n // Get config object\n const configArg = buildConfigCall.getArguments()[0]\n if (!configArg || !Node.isObjectLiteralExpression(configArg)) {\n return result\n }\n\n // Check for db property\n const dbProperty = configArg.getProperty('db')\n if (dbProperty) {\n const dbValue = dbProperty.getChildrenOfKind(SyntaxKind.CallExpression)[0]\n if (dbValue) {\n const adapterName = dbValue.getExpression().getText()\n\n // Find the import source for this adapter\n const adapterImport = imports.find((imp) =>\n imp.getNamedImports().some((ni) => ni.getName() === adapterName),\n )\n\n if (adapterImport) {\n result.dbProperty = {\n adapter: adapterName,\n importSource: adapterImport.getModuleSpecifierValue(),\n }\n }\n }\n }\n\n // Check for secret property\n const secretProperty = configArg.getProperty('secret')\n if (secretProperty) {\n result.secretProperty = true\n }\n\n // Check for editor property\n const editorProperty = configArg.getProperty('editor')\n if (editorProperty) {\n const editorValue = editorProperty.getChildrenOfKind(SyntaxKind.CallExpression)[0]\n if (editorValue) {\n const editorName = editorValue.getExpression().getText()\n\n // Find the import source\n const editorImport = imports.find((imp) =>\n imp.getNamedImports().some((ni) => ni.getName() === editorName),\n )\n\n if (editorImport && editorName === 'lexicalEditor') {\n // Check if it has arguments\n const args = editorValue.getArguments()\n const isDefault = args.length === 0\n\n result.editorProperty = {\n importSource: editorImport.getModuleSpecifierValue(),\n isDefault,\n }\n }\n }\n }\n\n // Check for figma property\n const figmaProperty = configArg.getProperty('figma')\n if (figmaProperty) {\n result.figmaObjectExists = true\n }\n\n return result\n}\n\nexport type ASTModificationResult = {\n changes: string[]\n modified: boolean\n}\n\n/**\n * Remove all comments\n * @returns true if any comments were removed\n */\nfunction removeAllComments(sourceFile: SourceFile): boolean {\n const ranges: Array<[number, number]> = []\n\n // Recursively collect comments from node and ALL children (including tokens)\n const collectComments = (node: Node) => {\n node.getLeadingCommentRanges().forEach((range) => {\n ranges.push([range.getPos(), range.getEnd()])\n })\n node.getTrailingCommentRanges().forEach((range) => {\n ranges.push([range.getPos(), range.getEnd()])\n })\n\n // Process ALL children including token nodes (commas, braces, etc.)\n node.getChildren().forEach(collectComments)\n }\n\n collectComments(sourceFile)\n\n if (ranges.length === 0) {\n return false\n }\n\n // Remove duplicates and sort in reverse order to avoid position shifts\n const uniqueRanges = Array.from(new Set(ranges.map((r) => JSON.stringify(r)))).map(\n (r) => JSON.parse(r) as [number, number],\n )\n uniqueRanges.sort((a, b) => b[0] - a[0])\n\n // Remove each comment range\n for (const [pos, end] of uniqueRanges) {\n sourceFile.removeText(pos, end)\n }\n\n return true\n}\n\n/**\n * Apply modifications to the source file based on detection result\n * Modifies the AST in memory - caller must call sourceFile.save()\n */\nexport function applyModifications(\n sourceFile: SourceFile,\n detection: DetectionResult,\n): ASTModificationResult {\n const changes: string[] = []\n let modified = false\n\n if (detection.hasBuildConfig === false || detection.hasAlias) {\n log.debug(\n `Skipping modifications: hasBuildConfig=${detection.hasBuildConfig}, hasAlias=${detection.hasAlias}`,\n )\n return { changes: [], modified: false }\n }\n\n // 1. Remove all comments FIRST (before AST modifications that might shift positions)\n const hadComments = removeAllComments(sourceFile)\n if (hadComments) {\n changes.push('Removed comments')\n modified = true\n }\n\n // Find the import declarations\n const imports = sourceFile.getImportDeclarations()\n const payloadImport = imports.find((imp) => imp.getModuleSpecifierValue() === 'payload')\n\n // Get the buildConfig name (could be aliased)\n let buildConfigName = 'buildConfig'\n if (payloadImport) {\n const buildConfigImport = payloadImport\n .getNamedImports()\n .find((ni) => ni.getName() === 'buildConfig')\n if (buildConfigImport) {\n const aliasNode = buildConfigImport.getAliasNode()\n buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig'\n }\n }\n\n // Find buildConfig call in export default (prefer export default)\n const exportAssignment = sourceFile.getFirstDescendantByKind(SyntaxKind.ExportAssignment)\n let buildConfigCall = null\n\n if (exportAssignment) {\n const callExpressions = exportAssignment.getDescendantsOfKind(SyntaxKind.CallExpression)\n buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n return expr.getText() === buildConfigName\n })\n }\n\n // If not found in export default, search all call expressions\n if (!buildConfigCall) {\n const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)\n buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n return expr.getText() === buildConfigName\n })\n }\n\n if (!buildConfigCall) {\n return { changes: [], modified: false }\n }\n\n const configArg = buildConfigCall.getArguments()[0]\n if (!configArg || !Node.isObjectLiteralExpression(configArg)) {\n return { changes: [], modified: false }\n }\n\n // 1. Remove db property\n if (detection.dbProperty) {\n const dbProperty = configArg.getProperty('db')\n if (dbProperty) {\n dbProperty.remove()\n changes.push('Removed db property')\n modified = true\n }\n }\n\n // 2. Remove secret property\n if (detection.secretProperty) {\n const secretProperty = configArg.getProperty('secret')\n if (secretProperty) {\n secretProperty.remove()\n changes.push('Removed secret property')\n modified = true\n }\n }\n\n // 3. Remove editor if default\n if (detection.editorProperty?.isDefault) {\n const editorProperty = configArg.getProperty('editor')\n if (editorProperty) {\n editorProperty.remove()\n changes.push('Removed default editor property')\n modified = true\n }\n }\n\n // 4. Update buildConfig import\n if (detection.needsImportChange) {\n if (payloadImport) {\n if (detection.hasOtherPayloadImports) {\n // Remove buildConfig from payload import, add new figma import\n const namedImports = payloadImport.getNamedImports()\n const buildConfigImport = namedImports.find((ni) => ni.getName() === 'buildConfig')\n if (buildConfigImport) {\n buildConfigImport.remove()\n\n // If payload import is now empty, remove it\n if (payloadImport.getNamedImports().length === 0) {\n payloadImport.remove()\n }\n }\n\n // Add new import at the top\n sourceFile.addImportDeclaration({\n moduleSpecifier: '@payloadcms/figma',\n namedImports: ['buildConfig'],\n })\n\n changes.push('Split buildConfig import to @payloadcms/figma')\n } else {\n // Replace entire import\n payloadImport.setModuleSpecifier('@payloadcms/figma')\n changes.push('Changed buildConfig import to @payloadcms/figma')\n }\n modified = true\n }\n }\n\n // 5. Remove orphaned imports\n // Re-fetch imports after each removal to avoid stale references\n if (detection.dbProperty) {\n const currentImports = sourceFile.getImportDeclarations()\n const dbImport = currentImports.find(\n (imp) => imp.getModuleSpecifierValue() === detection.dbProperty?.importSource,\n )\n if (dbImport) {\n dbImport.remove()\n changes.push(`Removed ${detection.dbProperty.adapter} import`)\n modified = true\n }\n }\n\n if (detection.editorProperty?.isDefault) {\n const currentImports = sourceFile.getImportDeclarations()\n const editorImport = currentImports.find(\n (imp) => imp.getModuleSpecifierValue() === detection.editorProperty?.importSource,\n )\n if (editorImport) {\n editorImport.remove()\n changes.push('Removed lexicalEditor import')\n modified = true\n }\n }\n\n return { changes, modified }\n}\n\nexport type FigmaPropertyConfig = {\n region: string\n tenantId: string\n useContentSystem: boolean\n}\n\n/**\n * Add figma property to buildConfig if it doesn't exist\n * Modifies the AST in memory - caller must call sourceFile.save()\n */\nexport function addFigmaProperty(\n sourceFile: SourceFile,\n config: FigmaPropertyConfig,\n): ASTModificationResult {\n const changes: string[] = []\n let modified = false\n\n // Find buildConfig call\n const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)\n const buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n const text = expr.getText()\n return text === 'buildConfig' || text.endsWith('.buildConfig')\n })\n\n if (!buildConfigCall) {\n log.debug('No buildConfig call found')\n return { changes: [], modified: false }\n }\n\n // Get config object argument\n const configArg = buildConfigCall.getArguments()[0]\n if (!configArg || !Node.isObjectLiteralExpression(configArg)) {\n log.debug('buildConfig argument is not an object literal')\n return { changes: [], modified: false }\n }\n\n // Check if figma property already exists\n const existingFigmaProperty = configArg.getProperty('figma')\n if (existingFigmaProperty) {\n log.debug('figma property already exists, skipping')\n return { changes: ['Skipped: figma property already exists'], modified: false }\n }\n\n // Add figma property\n configArg.addPropertyAssignment({\n name: 'figma',\n initializer: `{\n region: '${config.region}',\n tenantId: '${config.tenantId}',\n useContentSystem: ${config.useContentSystem},\n }`,\n })\n\n changes.push(\n `Added figma property (region: ${config.region}, tenantId: ${config.tenantId}, useContentSystem: ${config.useContentSystem})`,\n )\n modified = true\n\n return { changes, modified }\n}\n\n/**\n * Read figma configuration from payload.config.ts\n * Returns the figma object if it exists, null otherwise\n */\nexport function readFigmaConfig(sourceFile: SourceFile): FigmaPropertyConfig | null {\n // Find buildConfig call\n const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)\n const buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n const text = expr.getText()\n return text === 'buildConfig' || text.endsWith('.buildConfig')\n })\n\n if (!buildConfigCall) {\n log.debug('No buildConfig call found')\n return null\n }\n\n // Get config object argument\n const configArg = buildConfigCall.getArguments()[0]\n if (!configArg || !Node.isObjectLiteralExpression(configArg)) {\n log.debug('buildConfig argument is not an object literal')\n return null\n }\n\n // Find figma property\n const figmaProperty = configArg.getProperty('figma')\n if (!figmaProperty || !Node.isPropertyAssignment(figmaProperty)) {\n log.debug('No figma property found in buildConfig')\n return null\n }\n\n // Get initializer (the object value)\n const initializer = figmaProperty.getInitializer()\n if (!initializer || !Node.isObjectLiteralExpression(initializer)) {\n log.debug('figma property is not an object literal')\n return null\n }\n\n // Extract values\n const regionProp = initializer.getProperty('region')\n const tenantIdProp = initializer.getProperty('tenantId')\n const useContentSystemProp = initializer.getProperty('useContentSystem')\n\n if (!regionProp || !tenantIdProp) {\n log.debug('Missing required figma properties (region or tenantId)')\n return null\n }\n\n // Extract string values (remove quotes)\n const region = Node.isPropertyAssignment(regionProp)\n ? regionProp\n .getInitializer()\n ?.getText()\n .replace(/['\"]/g, '')\n : undefined\n\n const tenantId = Node.isPropertyAssignment(tenantIdProp)\n ? tenantIdProp\n .getInitializer()\n ?.getText()\n .replace(/['\"]/g, '')\n : undefined\n\n const useContentSystem = Node.isPropertyAssignment(useContentSystemProp)\n ? useContentSystemProp.getInitializer()?.getText() === 'true'\n : true // Default to true if not specified\n\n if (!region || !tenantId) {\n log.debug('Could not extract region or tenantId values')\n return null\n }\n\n return {\n region,\n tenantId,\n useContentSystem,\n }\n}\n"],"names":["Node","SyntaxKind","log","detectRequiredChanges","sourceFile","result","figmaObjectExists","hasAlias","hasOtherPayloadImports","needsImportChange","imports","getImportDeclarations","payloadImport","find","imp","getModuleSpecifierValue","debug","hasBuildConfig","moduleSpecifier","namedImports","getNamedImports","buildConfigImport","ni","getName","aliasNode","getAliasNode","buildConfigName","getText","length","exportAssignment","getFirstDescendantByKind","ExportAssignment","buildConfigCall","callExpressions","getDescendantsOfKind","CallExpression","ce","expr","getExpression","configArg","getArguments","isObjectLiteralExpression","dbProperty","getProperty","dbValue","getChildrenOfKind","adapterName","adapterImport","some","adapter","importSource","secretProperty","editorProperty","editorValue","editorName","editorImport","args","isDefault","figmaProperty","removeAllComments","ranges","collectComments","node","getLeadingCommentRanges","forEach","range","push","getPos","getEnd","getTrailingCommentRanges","getChildren","uniqueRanges","Array","from","Set","map","r","JSON","stringify","parse","sort","a","b","pos","end","removeText","applyModifications","detection","changes","modified","hadComments","remove","addImportDeclaration","setModuleSpecifier","currentImports","dbImport","addFigmaProperty","config","text","endsWith","existingFigmaProperty","addPropertyAssignment","name","initializer","region","tenantId","useContentSystem","readFigmaConfig","isPropertyAssignment","getInitializer","regionProp","tenantIdProp","useContentSystemProp","replace","undefined"],"mappings":"AAEA,SAASA,IAAI,EAAEC,UAAU,QAAQ,WAAU;AAE3C,YAAYC,SAAS,WAAU;AAmB/B;;CAEC,GACD,OAAO,SAASC,sBAAsBC,UAAsB;IAC1D,MAAMC,SAA0B;QAC9BC,mBAAmB;QACnBC,UAAU;QACVC,wBAAwB;QACxBC,mBAAmB;IACrB;IAEA,0BAA0B;IAC1B,MAAMC,UAAUN,WAAWO,qBAAqB;IAChD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,UACDsF,QAAQ,SAAS,MACpBC;IAEJ,MAAMT,WAAWzG,KAAK4G,oBAAoB,CAACG,gBACvCA,aACGF,cAAc,IACblF,UACDsF,QAAQ,SAAS,MACpBC;IAEJ,MAAMR,mBAAmB1G,KAAK4G,oBAAoB,CAACI,wBAC/CA,qBAAqBH,cAAc,IAAIlF,cAAc,SACrD,KAAK,mCAAmC;;IAE5C,IAAI,CAAC6E,UAAU,CAACC,UAAU;QACxBvG,IAAIc,KAAK,CAAC;QACV,OAAO;IACT;IAEA,OAAO;QACLwF;QACAC;QACAC;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/utils/payload-config-ast.ts"],"sourcesContent":["import type { SourceFile } from 'ts-morph'\n\nimport { Node, SyntaxKind } from 'ts-morph'\n\nimport * as log from './log.js'\n\nexport type DetectionResult = {\n dbProperty?: {\n adapter: string\n importSource: string\n }\n editorProperty?: {\n importSource: string\n isDefault: boolean\n }\n figmaObjectExists: boolean\n hasAlias: boolean\n hasBuildConfig?: boolean\n hasOtherPayloadImports: boolean\n needsImportChange: boolean\n secretProperty?: boolean\n}\n\n/**\n * Detect what changes are needed in the payload config file\n */\nexport function detectRequiredChanges(sourceFile: SourceFile): DetectionResult {\n const result: DetectionResult = {\n figmaObjectExists: false,\n hasAlias: false,\n hasOtherPayloadImports: false,\n needsImportChange: false,\n }\n\n // Find buildConfig import\n const imports = sourceFile.getImportDeclarations()\n const payloadImport = imports.find(\n (imp) =>\n imp.getModuleSpecifierValue() === 'payload' ||\n imp.getModuleSpecifierValue() === '@payloadcms/figma',\n )\n\n if (!payloadImport) {\n log.debug('No payload or @payloadcms/figma import found')\n result.hasBuildConfig = false\n return result\n }\n\n log.debug(`Found import from: ${payloadImport.getModuleSpecifierValue()}`)\n\n const moduleSpecifier = payloadImport.getModuleSpecifierValue()\n const namedImports = payloadImport.getNamedImports()\n\n // Check if buildConfig is imported\n const buildConfigImport = namedImports.find((ni) => ni.getName() === 'buildConfig')\n\n if (!buildConfigImport) {\n result.hasBuildConfig = false\n return result\n }\n\n // Check for alias and get the actual name used in code\n const aliasNode = buildConfigImport.getAliasNode()\n const buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig'\n if (aliasNode) {\n result.hasAlias = true\n }\n\n // Check if import needs change\n if (moduleSpecifier === 'payload') {\n result.needsImportChange = true\n\n // Check if there are other imports from payload\n if (namedImports.length > 1) {\n result.hasOtherPayloadImports = true\n }\n }\n\n // Find buildConfig call in export default\n // First try to find export default with the buildConfig call\n const exportAssignment = sourceFile.getFirstDescendantByKind(SyntaxKind.ExportAssignment)\n let buildConfigCall = null\n\n if (exportAssignment) {\n // Look for buildConfig call in the export default\n const callExpressions = exportAssignment.getDescendantsOfKind(SyntaxKind.CallExpression)\n buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n return expr.getText() === buildConfigName\n })\n }\n\n // If not found in export default, search all call expressions\n if (!buildConfigCall) {\n const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)\n buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n return expr.getText() === buildConfigName\n })\n }\n\n if (!buildConfigCall) {\n result.hasBuildConfig = false\n return result\n }\n\n // Get config object\n const configArg = buildConfigCall.getArguments()[0]\n if (!configArg || !Node.isObjectLiteralExpression(configArg)) {\n return result\n }\n\n // Check for db property\n const dbProperty = configArg.getProperty('db')\n if (dbProperty) {\n const dbValue = dbProperty.getChildrenOfKind(SyntaxKind.CallExpression)[0]\n if (dbValue) {\n const adapterName = dbValue.getExpression().getText()\n\n // Find the import source for this adapter\n const adapterImport = imports.find((imp) =>\n imp.getNamedImports().some((ni) => ni.getName() === adapterName),\n )\n\n if (adapterImport) {\n result.dbProperty = {\n adapter: adapterName,\n importSource: adapterImport.getModuleSpecifierValue(),\n }\n }\n }\n }\n\n // Check for secret property\n const secretProperty = configArg.getProperty('secret')\n if (secretProperty) {\n result.secretProperty = true\n }\n\n // Check for editor property\n const editorProperty = configArg.getProperty('editor')\n if (editorProperty) {\n const editorValue = editorProperty.getChildrenOfKind(SyntaxKind.CallExpression)[0]\n if (editorValue) {\n const editorName = editorValue.getExpression().getText()\n\n // Find the import source\n const editorImport = imports.find((imp) =>\n imp.getNamedImports().some((ni) => ni.getName() === editorName),\n )\n\n if (editorImport && editorName === 'lexicalEditor') {\n // Check if it has arguments\n const args = editorValue.getArguments()\n const isDefault = args.length === 0\n\n result.editorProperty = {\n importSource: editorImport.getModuleSpecifierValue(),\n isDefault,\n }\n }\n }\n }\n\n // Check for figma property\n const figmaProperty = configArg.getProperty('figma')\n if (figmaProperty) {\n result.figmaObjectExists = true\n }\n\n return result\n}\n\nexport type ASTModificationResult = {\n changes: string[]\n modified: boolean\n}\n\n/**\n * Remove all comments\n * @returns true if any comments were removed\n */\nfunction removeAllComments(sourceFile: SourceFile): boolean {\n const ranges: Array<[number, number]> = []\n\n // Recursively collect comments from node and ALL children (including tokens)\n const collectComments = (node: Node) => {\n node.getLeadingCommentRanges().forEach((range) => {\n ranges.push([range.getPos(), range.getEnd()])\n })\n node.getTrailingCommentRanges().forEach((range) => {\n ranges.push([range.getPos(), range.getEnd()])\n })\n\n // Process ALL children including token nodes (commas, braces, etc.)\n node.getChildren().forEach(collectComments)\n }\n\n collectComments(sourceFile)\n\n if (ranges.length === 0) {\n return false\n }\n\n // Remove duplicates and sort in reverse order to avoid position shifts\n const uniqueRanges = Array.from(new Set(ranges.map((r) => JSON.stringify(r)))).map(\n (r) => JSON.parse(r) as [number, number],\n )\n uniqueRanges.sort((a, b) => b[0] - a[0])\n\n // Remove each comment range\n for (const [pos, end] of uniqueRanges) {\n sourceFile.removeText(pos, end)\n }\n\n return true\n}\n\n/**\n * Apply modifications to the source file based on detection result\n * Modifies the AST in memory - caller must call sourceFile.save()\n */\nexport function applyModifications(\n sourceFile: SourceFile,\n detection: DetectionResult,\n): ASTModificationResult {\n const changes: string[] = []\n let modified = false\n\n if (detection.hasBuildConfig === false || detection.hasAlias) {\n log.debug(\n `Skipping modifications: hasBuildConfig=${detection.hasBuildConfig}, hasAlias=${detection.hasAlias}`,\n )\n return { changes: [], modified: false }\n }\n\n // 1. Remove all comments FIRST (before AST modifications that might shift positions)\n const hadComments = removeAllComments(sourceFile)\n if (hadComments) {\n changes.push('Removed comments')\n modified = true\n }\n\n // Find the import declarations\n const imports = sourceFile.getImportDeclarations()\n const payloadImport = imports.find((imp) => imp.getModuleSpecifierValue() === 'payload')\n\n // Get the buildConfig name (could be aliased)\n let buildConfigName = 'buildConfig'\n if (payloadImport) {\n const buildConfigImport = payloadImport\n .getNamedImports()\n .find((ni) => ni.getName() === 'buildConfig')\n if (buildConfigImport) {\n const aliasNode = buildConfigImport.getAliasNode()\n buildConfigName = aliasNode ? aliasNode.getText() : 'buildConfig'\n }\n }\n\n // Find buildConfig call in export default (prefer export default)\n const exportAssignment = sourceFile.getFirstDescendantByKind(SyntaxKind.ExportAssignment)\n let buildConfigCall = null\n\n if (exportAssignment) {\n const callExpressions = exportAssignment.getDescendantsOfKind(SyntaxKind.CallExpression)\n buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n return expr.getText() === buildConfigName\n })\n }\n\n // If not found in export default, search all call expressions\n if (!buildConfigCall) {\n const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)\n buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n return expr.getText() === buildConfigName\n })\n }\n\n if (!buildConfigCall) {\n return { changes: [], modified: false }\n }\n\n const configArg = buildConfigCall.getArguments()[0]\n if (!configArg || !Node.isObjectLiteralExpression(configArg)) {\n return { changes: [], modified: false }\n }\n\n // 1. Remove db property\n if (detection.dbProperty) {\n const dbProperty = configArg.getProperty('db')\n if (dbProperty) {\n dbProperty.remove()\n changes.push('Removed db property')\n modified = true\n }\n }\n\n // 2. Remove secret property\n if (detection.secretProperty) {\n const secretProperty = configArg.getProperty('secret')\n if (secretProperty) {\n secretProperty.remove()\n changes.push('Removed secret property')\n modified = true\n }\n }\n\n // 3. Remove editor if default\n if (detection.editorProperty?.isDefault) {\n const editorProperty = configArg.getProperty('editor')\n if (editorProperty) {\n editorProperty.remove()\n changes.push('Removed default editor property')\n modified = true\n }\n }\n\n // 4. Update buildConfig import\n if (detection.needsImportChange) {\n if (payloadImport) {\n if (detection.hasOtherPayloadImports) {\n // Remove buildConfig from payload import, add new figma import\n const namedImports = payloadImport.getNamedImports()\n const buildConfigImport = namedImports.find((ni) => ni.getName() === 'buildConfig')\n if (buildConfigImport) {\n buildConfigImport.remove()\n\n // If payload import is now empty, remove it\n if (payloadImport.getNamedImports().length === 0) {\n payloadImport.remove()\n }\n }\n\n // Add new import at the top\n sourceFile.addImportDeclaration({\n moduleSpecifier: '@payloadcms/figma',\n namedImports: ['buildConfig'],\n })\n\n changes.push('Split buildConfig import to @payloadcms/figma')\n } else {\n // Replace entire import\n payloadImport.setModuleSpecifier('@payloadcms/figma')\n changes.push('Changed buildConfig import to @payloadcms/figma')\n }\n modified = true\n }\n }\n\n // 5. Remove orphaned imports\n // Re-fetch imports after each removal to avoid stale references\n if (detection.dbProperty) {\n const currentImports = sourceFile.getImportDeclarations()\n const dbImport = currentImports.find(\n (imp) => imp.getModuleSpecifierValue() === detection.dbProperty?.importSource,\n )\n if (dbImport) {\n dbImport.remove()\n changes.push(`Removed ${detection.dbProperty.adapter} import`)\n modified = true\n }\n }\n\n if (detection.editorProperty?.isDefault) {\n const currentImports = sourceFile.getImportDeclarations()\n const editorImport = currentImports.find(\n (imp) => imp.getModuleSpecifierValue() === detection.editorProperty?.importSource,\n )\n if (editorImport) {\n editorImport.remove()\n changes.push('Removed lexicalEditor import')\n modified = true\n }\n }\n\n return { changes, modified }\n}\n\nexport type FigmaPropertyConfig = {\n contentSystemId: string\n region: string\n useContentSystem: boolean\n}\n\n/**\n * Add figma property to buildConfig if it doesn't exist\n * Modifies the AST in memory - caller must call sourceFile.save()\n */\nexport function addFigmaProperty(\n sourceFile: SourceFile,\n config: FigmaPropertyConfig,\n): ASTModificationResult {\n const changes: string[] = []\n let modified = false\n\n // Find buildConfig call\n const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)\n const buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n const text = expr.getText()\n return text === 'buildConfig' || text.endsWith('.buildConfig')\n })\n\n if (!buildConfigCall) {\n log.debug('No buildConfig call found')\n return { changes: [], modified: false }\n }\n\n // Get config object argument\n const configArg = buildConfigCall.getArguments()[0]\n if (!configArg || !Node.isObjectLiteralExpression(configArg)) {\n log.debug('buildConfig argument is not an object literal')\n return { changes: [], modified: false }\n }\n\n // Check if figma property already exists\n const existingFigmaProperty = configArg.getProperty('figma')\n if (existingFigmaProperty) {\n log.debug('figma property already exists, skipping')\n return { changes: ['Skipped: figma property already exists'], modified: false }\n }\n\n // Add figma property\n configArg.addPropertyAssignment({\n name: 'figma',\n initializer: `{\n region: '${config.region}',\n contentSystemId: '${config.contentSystemId}',\n useContentSystem: ${config.useContentSystem},\n }`,\n })\n\n changes.push(\n `Added figma property (region: ${config.region}, tenantId: ${config.contentSystemId}, useContentSystem: ${config.useContentSystem})`,\n )\n modified = true\n\n return { changes, modified }\n}\n\n/**\n * Read figma configuration from payload.config.ts\n * Returns the figma object if it exists, null otherwise\n */\nexport function readFigmaConfig(sourceFile: SourceFile): FigmaPropertyConfig | null {\n // Find buildConfig call\n const callExpressions = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression)\n const buildConfigCall = callExpressions.find((ce) => {\n const expr = ce.getExpression()\n const text = expr.getText()\n return text === 'buildConfig' || text.endsWith('.buildConfig')\n })\n\n if (!buildConfigCall) {\n log.debug('No buildConfig call found')\n return null\n }\n\n // Get config object argument\n const configArg = buildConfigCall.getArguments()[0]\n if (!configArg || !Node.isObjectLiteralExpression(configArg)) {\n log.debug('buildConfig argument is not an object literal')\n return null\n }\n\n // Find figma property\n const figmaProperty = configArg.getProperty('figma')\n if (!figmaProperty || !Node.isPropertyAssignment(figmaProperty)) {\n log.debug('No figma property found in buildConfig')\n return null\n }\n\n // Get initializer (the object value)\n const initializer = figmaProperty.getInitializer()\n if (!initializer || !Node.isObjectLiteralExpression(initializer)) {\n log.debug('figma property is not an object literal')\n return null\n }\n\n // Extract values\n const regionProp = initializer.getProperty('region')\n const contentSystemIdProp = initializer.getProperty('contentSystemId')\n const useContentSystemProp = initializer.getProperty('useContentSystem')\n\n if (!regionProp || !contentSystemIdProp) {\n log.debug('Missing required figma properties (region or tenantId)')\n return null\n }\n\n // Extract string values (remove quotes)\n const region = Node.isPropertyAssignment(regionProp)\n ? regionProp.getInitializer()?.getText().replace(/['\"]/g, '')\n : undefined\n\n const contentSystemId = Node.isPropertyAssignment(contentSystemIdProp)\n ? contentSystemIdProp.getInitializer()?.getText().replace(/['\"]/g, '')\n : undefined\n\n const useContentSystem = Node.isPropertyAssignment(useContentSystemProp)\n ? useContentSystemProp.getInitializer()?.getText() === 'true'\n : true // Default to true if not specified\n\n if (!region || !contentSystemId) {\n log.debug('Could not extract region or tenantId values')\n return null\n }\n\n return {\n contentSystemId,\n region,\n useContentSystem,\n }\n}\n"],"names":["Node","SyntaxKind","log","detectRequiredChanges","sourceFile","result","figmaObjectExists","hasAlias","hasOtherPayloadImports","needsImportChange","imports","getImportDeclarations","payloadImport","find","imp","getModuleSpecifierValue","debug","hasBuildConfig","moduleSpecifier","namedImports","getNamedImports","buildConfigImport","ni","getName","aliasNode","getAliasNode","buildConfigName","getText","length","exportAssignment","getFirstDescendantByKind","ExportAssignment","buildConfigCall","callExpressions","getDescendantsOfKind","CallExpression","ce","expr","getExpression","configArg","getArguments","isObjectLiteralExpression","dbProperty","getProperty","dbValue","getChildrenOfKind","adapterName","adapterImport","some","adapter","importSource","secretProperty","editorProperty","editorValue","editorName","editorImport","args","isDefault","figmaProperty","removeAllComments","ranges","collectComments","node","getLeadingCommentRanges","forEach","range","push","getPos","getEnd","getTrailingCommentRanges","getChildren","uniqueRanges","Array","from","Set","map","r","JSON","stringify","parse","sort","a","b","pos","end","removeText","applyModifications","detection","changes","modified","hadComments","remove","addImportDeclaration","setModuleSpecifier","currentImports","dbImport","addFigmaProperty","config","text","endsWith","existingFigmaProperty","addPropertyAssignment","name","initializer","region","contentSystemId","useContentSystem","readFigmaConfig","isPropertyAssignment","getInitializer","regionProp","contentSystemIdProp","useContentSystemProp","replace","undefined"],"mappings":"AAEA,SAASA,IAAI,EAAEC,UAAU,QAAQ,WAAU;AAE3C,YAAYC,SAAS,WAAU;AAmB/B;;CAEC,GACD,OAAO,SAASC,sBAAsBC,UAAsB;IAC1D,MAAMC,SAA0B;QAC9BC,mBAAmB;QACnBC,UAAU;QACVC,wBAAwB;QACxBC,mBAAmB;IACrB;IAEA,0BAA0B;IAC1B,MAAMC,UAAUN,WAAWO,qBAAqB;IAChD,MAAMC,gBAAgBF,QAAQG,IAAI,CAChC,CAACC,MACCA,IAAIC,uBAAuB,OAAO,aAClCD,IAAIC,uBAAuB,OAAO;IAGtC,IAAI,CAACH,eAAe;QAClBV,IAAIc,KAAK,CAAC;QACVX,OAAOY,cAAc,GAAG;QACxB,OAAOZ;IACT;IAEAH,IAAIc,KAAK,CAAC,CAAC,mBAAmB,EAAEJ,cAAcG,uBAAuB,IAAI;IAEzE,MAAMG,kBAAkBN,cAAcG,uBAAuB;IAC7D,MAAMI,eAAeP,cAAcQ,eAAe;IAElD,mCAAmC;IACnC,MAAMC,oBAAoBF,aAAaN,IAAI,CAAC,CAACS,KAAOA,GAAGC,OAAO,OAAO;IAErE,IAAI,CAACF,mBAAmB;QACtBhB,OAAOY,cAAc,GAAG;QACxB,OAAOZ;IACT;IAEA,uDAAuD;IACvD,MAAMmB,YAAYH,kBAAkBI,YAAY;IAChD,MAAMC,kBAAkBF,YAAYA,UAAUG,OAAO,KAAK;IAC1D,IAAIH,WAAW;QACbnB,OAAOE,QAAQ,GAAG;IACpB;IAEA,+BAA+B;IAC/B,IAAIW,oBAAoB,WAAW;QACjCb,OAAOI,iBAAiB,GAAG;QAE3B,gDAAgD;QAChD,IAAI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O;IACT;IAEA,qCAAqC;IACrC,MAAMuF,cAAc7C,cAAcmD,cAAc;IAChD,IAAI,CAACN,eAAe,CAACvG,KAAKyC,yBAAyB,CAAC8D,cAAc;QAChErG,IAAIc,KAAK,CAAC;QACV,OAAO;IACT;IAEA,iBAAiB;IACjB,MAAM8F,aAAaP,YAAY5D,WAAW,CAAC;IAC3C,MAAMoE,sBAAsBR,YAAY5D,WAAW,CAAC;IACpD,MAAMqE,uBAAuBT,YAAY5D,WAAW,CAAC;IAErD,IAAI,CAACmE,cAAc,CAACC,qBAAqB;QACvC7G,IAAIc,KAAK,CAAC;QACV,OAAO;IACT;IAEA,wCAAwC;IACxC,MAAMwF,SAASxG,KAAK4G,oBAAoB,CAACE,cACrCA,WAAWD,cAAc,IAAIlF,UAAUsF,QAAQ,SAAS,MACxDC;IAEJ,MAAMT,kBAAkBzG,KAAK4G,oBAAoB,CAACG,uBAC9CA,oBAAoBF,cAAc,IAAIlF,UAAUsF,QAAQ,SAAS,MACjEC;IAEJ,MAAMR,mBAAmB1G,KAAK4G,oBAAoB,CAACI,wBAC/CA,qBAAqBH,cAAc,IAAIlF,cAAc,SACrD,KAAK,mCAAmC;;IAE5C,IAAI,CAAC6E,UAAU,CAACC,iBAAiB;QAC/BvG,IAAIc,KAAK,CAAC;QACV,OAAO;IACT;IAEA,OAAO;QACLyF;QACAD;QACAE;IACF;AACF"}
@@ -18,7 +18,6 @@ export interface UploadResults {
18
18
  *
19
19
  * @param filePath - Absolute path to file to upload
20
20
  * @param signedUrl - Signed S3 upload URL
21
- * @param contentType - MIME type (optional)
22
21
  * @throws Error if upload fails after retries
23
22
  */
24
23
  export declare function uploadFile(filePath: string, signedUrl: string, contentType?: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"s3-upload.d.ts","sourceRoot":"","sources":["../../src/utils/s3-upload.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,oDAAoD;IACpD,YAAY,EAAE,MAA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OAAO,CAAC,IAAI,CAAC,CAEvF;AAED;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GACrD,OAAO,CAAC,aAAa,CAAC,CAgDxB"}
@@ -23,7 +23,6 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
23
23
  *
24
24
  * @param filePath - Absolute path to file to upload
25
25
  * @param signedUrl - Signed S3 upload URL
26
- * @param contentType - MIME type (optional)
27
26
  * @throws Error if upload fails after retries
28
27
  */ export async function uploadFile(filePath, signedUrl, contentType) {
29
28
  // Skip actual upload for mock URLs
@@ -45,10 +44,18 @@ const INITIAL_RETRY_DELAY = 1000 // 1 second
45
44
  let lastError = null;
46
45
  for(let attempt = 0; attempt < MAX_RETRIES; attempt++){
47
46
  try {
47
+ // Content-type only needed if css or js, else let S3 infer
48
+ const ext = path.extname(filePath).toLowerCase();
49
+ let determinedContentType = contentType;
50
+ if (ext === '.js') {
51
+ determinedContentType = 'application/javascript';
52
+ } else if (ext === '.css') {
53
+ determinedContentType = 'text/css';
54
+ }
48
55
  const response = await fetch(signedUrl, {
49
56
  body: fileBuffer,
50
- headers: contentType ? {
51
- 'Content-Type': contentType
57
+ headers: determinedContentType ? {
58
+ 'Content-Type': determinedContentType
52
59
  } : {},
53
60
  method: 'PUT'
54
61
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/s3-upload.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\nimport * as log from './log.js'\n\n/**\n * Results from uploading assets\n */\nexport interface UploadResults {\n /** Number of static assets that failed to upload */\n assetsFailed: number\n /** Number of static assets successfully uploaded */\n assetsUploaded: number\n /** Whether Lambda code was uploaded */\n lambdaUploaded: boolean\n /** Total bytes uploaded */\n totalBytesUploaded: number\n}\n\n/**\n * Retry configuration\n */\nconst MAX_RETRIES = 3\nconst INITIAL_RETRY_DELAY = 1000 // 1 second\n\n/**\n * Sleep for specified milliseconds\n */\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\n/**\n * Check if a signed URL is a mock URL\n */\nfunction isMockUrl(signedUrl: string): boolean {\n return signedUrl.includes('X-Amz-Signature=mock')\n}\n\n/**\n * Upload a file to S3 using a signed URL\n *\n * Retries up to 3 times with exponential backoff\n *\n * @param filePath - Absolute path to file to upload\n * @param signedUrl - Signed S3 upload URL\n * @param contentType - MIME type (optional)\n * @throws Error if upload fails after retries\n */\nexport async function uploadFile(\n filePath: string,\n signedUrl: string,\n contentType?: string,\n): Promise<void> {\n // Skip actual upload for mock URLs\n if (isMockUrl(signedUrl)) {\n log.debug(`Mock upload detected for ${path.basename(filePath)}`)\n // Verify file exists\n const stats = await fs.stat(filePath)\n\n // Simulate upload latency based on file size\n // lambda.zip: ~1-2 seconds, small files: 50-150ms\n const isLargeFile = stats.size > 1024 * 1024 // > 1MB\n const latency = isLargeFile\n ? 1000 + Math.random() * 1000 // 1-2 seconds for large files\n : 50 + Math.random() * 100 // 50-150ms for small files\n await sleep(latency)\n return\n }\n\n const fileBuffer = await fs.readFile(filePath)\n\n let lastError: Error | null = null\n\n for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {\n try {\n const response = await fetch(signedUrl, {\n body: fileBuffer,\n headers: contentType ? { 'Content-Type': contentType } : {},\n method: 'PUT',\n })\n\n if (response.ok) {\n return // Success\n }\n\n lastError = new Error(`Upload failed: ${response.status} ${response.statusText}`)\n } catch (error) {\n lastError = error instanceof Error ? error : new Error('Unknown error')\n }\n\n // Wait before retry (exponential backoff)\n if (attempt < MAX_RETRIES - 1) {\n await sleep(INITIAL_RETRY_DELAY * Math.pow(2, attempt))\n }\n }\n\n throw lastError || new Error('Upload failed after retries')\n}\n\n/**\n * Upload Lambda code zip to S3\n *\n * @param zipPath - Path to lambda.zip\n * @param signedUrl - Signed S3 upload URL\n */\nexport async function uploadLambdaZip(zipPath: string, signedUrl: string): Promise<void> {\n await uploadFile(zipPath, signedUrl, 'application/zip')\n}\n\n/**\n * Upload static assets to S3 in parallel\n *\n * Uploads up to 5 files concurrently\n *\n * @param projectPath - Path to project root\n * @param assetUrls - Map of asset paths to signed URLs\n * @param onProgress - Optional callback for progress updates (uploaded, total)\n * @returns Upload results with counts\n */\nexport async function uploadStaticAssets(\n projectPath: string,\n assetUrls: Record<string, string>,\n onProgress?: (uploaded: number, total: number) => void,\n): Promise<UploadResults> {\n const results: UploadResults = {\n assetsFailed: 0,\n assetsUploaded: 0,\n lambdaUploaded: false,\n totalBytesUploaded: 0,\n }\n\n const assetPaths = Object.keys(assetUrls)\n\n if (assetPaths.length === 0) {\n return results\n }\n\n // Upload assets with limited concurrency\n const CONCURRENCY = 5\n for (let i = 0; i < assetPaths.length; i += CONCURRENCY) {\n const batch = assetPaths.slice(i, i + CONCURRENCY)\n\n await Promise.all(\n batch.map(async (assetPath) => {\n try {\n // Convert _next back to .next for file system\n const fsPath = assetPath.replace(/^_next\\//, '.next/')\n const fullPath = path.join(projectPath, fsPath)\n const signedUrl = assetUrls[assetPath]\n\n await uploadFile(fullPath, signedUrl)\n\n results.assetsUploaded++\n\n // Track bytes uploaded\n const stats = await fs.stat(fullPath)\n results.totalBytesUploaded += stats.size\n\n // Report progress\n onProgress?.(results.assetsUploaded, assetPaths.length)\n } catch (error) {\n results.assetsFailed++\n log.debug(\n `Failed to upload ${assetPath}: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n }),\n )\n }\n\n return results\n}\n"],"names":["fs","path","log","MAX_RETRIES","INITIAL_RETRY_DELAY","sleep","ms","Promise","resolve","setTimeout","isMockUrl","signedUrl","includes","uploadFile","filePath","contentType","debug","basename","stats","stat","isLargeFile","size","latency","Math","random","fileBuffer","readFile","lastError","attempt","response","fetch","body","headers","method","ok","Error","status","statusText","error","pow","uploadLambdaZip","zipPath","uploadStaticAssets","projectPath","assetUrls","onProgress","results","assetsFailed","assetsUploaded","lambdaUploaded","totalBytesUploaded","assetPaths","Object","keys","length","CONCURRENCY","i","batch","slice","all","map","assetPath","fsPath","replace","fullPath","join","message"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,YAAYC,SAAS,WAAU;AAgB/B;;CAEC,GACD,MAAMC,cAAc;AACpB,MAAMC,sBAAsB,KAAK,WAAW;;AAE5C;;CAEC,GACD,SAASC,MAAMC,EAAU;IACvB,OAAO,IAAIC,QAAQ,CAACC,UAAYC,WAAWD,SAASF;AACtD;AAEA;;CAEC,GACD,SAASI,UAAUC,SAAiB;IAClC,OAAOA,UAAUC,QAAQ,CAAC;AAC5B;AAEA;;;;;;;;;CASC,GACD,OAAO,eAAeC,WACpBC,QAAgB,EAChBH,SAAiB,EACjBI,WAAoB;IAEpB,mCAAmC;IACnC,IAAIL,UAAUC,YAAY;QACxBT,IAAIc,KAAK,CAAC,CAAC,yBAAyB,EAAEf,KAAKgB,QAAQ,CAACH,WAAW;QAC/D,qBAAqB;QACrB,MAAMI,QAAQ,MAAMlB,GAAGmB,IAAI,CAACL;QAE5B,6CAA6C;QAC7C,kDAAkD;QAClD,MAAMM,cAAcF,MAAMG,IAAI,GAAG,OAAO,KAAK,QAAQ;;QACrD,MAAMC,UAAUF,cACZ,OAAOG,KAAKC,MAAM,KAAK,KAAK,8BAA8B;WAC1D,KAAKD,KAAKC,MAAM,KAAK,IAAI,2BAA2B;;QACxD,MAAMnB,MAAMiB;QACZ;IACF;IAEA,MAAMG,aAAa,MAAMzB,GAAG0B,QAAQ,CAACZ;IAErC,IAAIa,YAA0B;IAE9B,IAAK,IAAIC,UAAU,GAAGA,UAAUzB,aAAayB,UAAW;QACtD,IAAI;YACF,MAAMC,WAAW,MAAMC,MAAMnB,WAAW;gBACtCoB,MAAMN;gBACNO,SAASjB,cAAc;oBAAE,gBAAgB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,UAAUrD;gBAE3BmC,QAAQE,cAAc;gBAEtB,uBAAuB;gBACvB,MAAM9B,QAAQ,MAAMlB,GAAGmB,IAAI,CAAC6C;gBAC5BlB,QAAQI,kBAAkB,IAAIhC,MAAMG,IAAI;gBAExC,kBAAkB;gBAClBwB,aAAaC,QAAQE,cAAc,EAAEG,WAAWG,MAAM;YACxD,EAAE,OAAOhB,OAAO;gBACdQ,QAAQC,YAAY;gBACpB7C,IAAIc,KAAK,CACP,CAAC,iBAAiB,EAAE6C,UAAU,EAAE,EAAEvB,iBAAiBH,QAAQG,MAAM4B,OAAO,GAAG,iBAAiB;YAEhG;QACF;IAEJ;IAEA,OAAOpB;AACT"}
1
+ {"version":3,"sources":["../../src/utils/s3-upload.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\nimport * as log from './log.js'\n\n/**\n * Results from uploading assets\n */\nexport interface UploadResults {\n /** Number of static assets that failed to upload */\n assetsFailed: number\n /** Number of static assets successfully uploaded */\n assetsUploaded: number\n /** Whether Lambda code was uploaded */\n lambdaUploaded: boolean\n /** Total bytes uploaded */\n totalBytesUploaded: number\n}\n\n/**\n * Retry configuration\n */\nconst MAX_RETRIES = 3\nconst INITIAL_RETRY_DELAY = 1000 // 1 second\n\n/**\n * Sleep for specified milliseconds\n */\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\n/**\n * Check if a signed URL is a mock URL\n */\nfunction isMockUrl(signedUrl: string): boolean {\n return signedUrl.includes('X-Amz-Signature=mock')\n}\n\n/**\n * Upload a file to S3 using a signed URL\n *\n * Retries up to 3 times with exponential backoff\n *\n * @param filePath - Absolute path to file to upload\n * @param signedUrl - Signed S3 upload URL\n * @throws Error if upload fails after retries\n */\nexport async function uploadFile(\n filePath: string,\n signedUrl: string,\n contentType?: string,\n): Promise<void> {\n // Skip actual upload for mock URLs\n if (isMockUrl(signedUrl)) {\n log.debug(`Mock upload detected for ${path.basename(filePath)}`)\n // Verify file exists\n const stats = await fs.stat(filePath)\n\n // Simulate upload latency based on file size\n // lambda.zip: ~1-2 seconds, small files: 50-150ms\n const isLargeFile = stats.size > 1024 * 1024 // > 1MB\n const latency = isLargeFile\n ? 1000 + Math.random() * 1000 // 1-2 seconds for large files\n : 50 + Math.random() * 100 // 50-150ms for small files\n await sleep(latency)\n return\n }\n\n const fileBuffer = await fs.readFile(filePath)\n\n let lastError: Error | null = null\n\n for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {\n try {\n // Content-type only needed if css or js, else let S3 infer\n const ext = path.extname(filePath).toLowerCase()\n\n let determinedContentType: string | undefined = contentType\n if (ext === '.js') {\n determinedContentType = 'application/javascript'\n } else if (ext === '.css') {\n determinedContentType = 'text/css'\n }\n\n const response = await fetch(signedUrl, {\n body: fileBuffer,\n headers: determinedContentType ? { 'Content-Type': determinedContentType } : {},\n method: 'PUT',\n })\n\n if (response.ok) {\n return // Success\n }\n\n lastError = new Error(`Upload failed: ${response.status} ${response.statusText}`)\n } catch (error) {\n lastError = error instanceof Error ? error : new Error('Unknown error')\n }\n\n // Wait before retry (exponential backoff)\n if (attempt < MAX_RETRIES - 1) {\n await sleep(INITIAL_RETRY_DELAY * Math.pow(2, attempt))\n }\n }\n\n throw lastError || new Error('Upload failed after retries')\n}\n\n/**\n * Upload Lambda code zip to S3\n *\n * @param zipPath - Path to lambda.zip\n * @param signedUrl - Signed S3 upload URL\n */\nexport async function uploadLambdaZip(zipPath: string, signedUrl: string): Promise<void> {\n await uploadFile(zipPath, signedUrl, 'application/zip')\n}\n\n/**\n * Upload static assets to S3 in parallel\n *\n * Uploads up to 5 files concurrently\n *\n * @param projectPath - Path to project root\n * @param assetUrls - Map of asset paths to signed URLs\n * @param onProgress - Optional callback for progress updates (uploaded, total)\n * @returns Upload results with counts\n */\nexport async function uploadStaticAssets(\n projectPath: string,\n assetUrls: Record<string, string>,\n onProgress?: (uploaded: number, total: number) => void,\n): Promise<UploadResults> {\n const results: UploadResults = {\n assetsFailed: 0,\n assetsUploaded: 0,\n lambdaUploaded: false,\n totalBytesUploaded: 0,\n }\n\n const assetPaths = Object.keys(assetUrls)\n\n if (assetPaths.length === 0) {\n return results\n }\n\n // Upload assets with limited concurrency\n const CONCURRENCY = 5\n for (let i = 0; i < assetPaths.length; i += CONCURRENCY) {\n const batch = assetPaths.slice(i, i + CONCURRENCY)\n\n await Promise.all(\n batch.map(async (assetPath) => {\n try {\n // Convert _next back to .next for file system\n const fsPath = assetPath.replace(/^_next\\//, '.next/')\n const fullPath = path.join(projectPath, fsPath)\n const signedUrl = assetUrls[assetPath]\n\n await uploadFile(fullPath, signedUrl)\n\n results.assetsUploaded++\n\n // Track bytes uploaded\n const stats = await fs.stat(fullPath)\n results.totalBytesUploaded += stats.size\n\n // Report progress\n onProgress?.(results.assetsUploaded, assetPaths.length)\n } catch (error) {\n results.assetsFailed++\n log.debug(\n `Failed to upload ${assetPath}: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n }),\n )\n }\n\n return results\n}\n"],"names":["fs","path","log","MAX_RETRIES","INITIAL_RETRY_DELAY","sleep","ms","Promise","resolve","setTimeout","isMockUrl","signedUrl","includes","uploadFile","filePath","contentType","debug","basename","stats","stat","isLargeFile","size","latency","Math","random","fileBuffer","readFile","lastError","attempt","ext","extname","toLowerCase","determinedContentType","response","fetch","body","headers","method","ok","Error","status","statusText","error","pow","uploadLambdaZip","zipPath","uploadStaticAssets","projectPath","assetUrls","onProgress","results","assetsFailed","assetsUploaded","lambdaUploaded","totalBytesUploaded","assetPaths","Object","keys","length","CONCURRENCY","i","batch","slice","all","map","assetPath","fsPath","replace","fullPath","join","message"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,YAAYC,SAAS,WAAU;AAgB/B;;CAEC,GACD,MAAMC,cAAc;AACpB,MAAMC,sBAAsB,KAAK,WAAW;;AAE5C;;CAEC,GACD,SAASC,MAAMC,EAAU;IACvB,OAAO,IAAIC,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AaC,QAAQE,cAAc,EAAEG,WAAWG,MAAM;YACxD,EAAE,OAAOhB,OAAO;gBACdQ,QAAQC,YAAY;gBACpBjD,IAAIc,KAAK,CACP,CAAC,iBAAiB,EAAEiD,UAAU,EAAE,EAAEvB,iBAAiBH,QAAQG,MAAM4B,OAAO,GAAG,iBAAiB;YAEhG;QACF;IAEJ;IAEA,OAAOpB;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/figma",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.20",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "type": "module",
6
6
  "exports": {
@@ -8,6 +8,11 @@
8
8
  "import": "./dist/index.js",
9
9
  "types": "./dist/index.d.ts",
10
10
  "default": "./dist/index.js"
11
+ },
12
+ "./client": {
13
+ "import": "./dist/exports/client.js",
14
+ "types": "./dist/exports/client.d.ts",
15
+ "default": "./dist/exports/client.js"
11
16
  }
12
17
  },
13
18
  "main": "./dist/index.js",
@@ -23,13 +28,16 @@
23
28
  "dependencies": {
24
29
  "@clack/prompts": "^0.11.0",
25
30
  "@figma/rest-api-spec": "^0.34.0",
31
+ "@payloadcms/richtext-lexical": "^3.54.0",
26
32
  "@sindresorhus/slugify": "^3.0.0",
27
33
  "arg": "^5.0.2",
28
34
  "conf": "^13.0.1",
29
35
  "esprima-next": "^6.0.2",
30
36
  "figures": "^6.1.0",
31
37
  "jose": "6.0.12",
38
+ "jsonwebtoken": "9.0.2",
32
39
  "open": "^10.1.0",
40
+ "payload": "^3.54.0",
33
41
  "picocolors": "1.1.1",
34
42
  "tar": "^7.4.3",
35
43
  "terminal-link": "^5.0.0",
@@ -41,10 +49,6 @@
41
49
  "typescript": "5.9.3",
42
50
  "vitest": "3.2.4"
43
51
  },
44
- "peerDependencies": {
45
- "@payloadcms/richtext-lexical": "^3.54.0",
46
- "payload": "^3.54.0"
47
- },
48
52
  "publishConfig": {
49
53
  "registry": "https://registry.npmjs.org/"
50
54
  },
@@ -56,6 +60,7 @@
56
60
  "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/",
57
61
  "debug:clear-tokens": "tsx scripts/clear-tokens.ts",
58
62
  "debug:expire-token": "tsx scripts/expire-token.ts",
63
+ "debug:get-project-token": "tsx scripts/get-project-token.ts",
59
64
  "debug:jwks": "tsx scripts/test-jwks-validation.ts",
60
65
  "debug:refresh-token": "tsx scripts/refresh-token.ts",
61
66
  "debug:tokens": "tsx scripts/debug-tokens.ts",