@sanity/codegen 5.9.3 → 5.10.0
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/README.md +1 -1
- package/dist/commands/typegen/generate.js +2 -4
- package/dist/commands/typegen/generate.js.map +1 -1
- package/dist/typescript/expressionResolvers.js +163 -12
- package/dist/typescript/expressionResolvers.js.map +1 -1
- package/oclif.config.js +1 -1
- package/oclif.manifest.json +2 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# @sanity/codegen
|
|
2
2
|
|
|
3
|
-
Codegen toolkit for Sanity.io, used to generate Typescript types for a Sanity Schema & GROQ queries.
|
|
3
|
+
Codegen toolkit for Sanity.io, used to generate Typescript types for a Sanity Schema & GROQ queries.
|
|
@@ -10,8 +10,7 @@ import { configDefinition, readConfig } from '../../readConfig.js';
|
|
|
10
10
|
import { TypegenWatchModeTrace, TypesGeneratedTrace } from '../../typegen.telemetry.js';
|
|
11
11
|
import { debug } from '../../utils/debug.js';
|
|
12
12
|
import { promiseWithResolvers } from '../../utils/promiseWithResolvers.js';
|
|
13
|
-
const description = `Sanity TypeGen
|
|
14
|
-
This command is currently in beta and may undergo significant changes. Feedback is welcome!
|
|
13
|
+
const description = `Sanity TypeGen
|
|
15
14
|
|
|
16
15
|
${styleText('bold', 'Configuration:')}
|
|
17
16
|
This command can utilize configuration settings defined in a \`sanity-typegen.json\` file. These settings include:
|
|
@@ -28,8 +27,7 @@ This command can utilize configuration settings defined in a \`sanity-typegen.js
|
|
|
28
27
|
The default configuration values listed above are used if not overridden in your \`sanity-typegen.json\` configuration file. To customize the behavior of the type generation, adjust these properties in the configuration file according to your project's needs.
|
|
29
28
|
|
|
30
29
|
${styleText('bold', 'Note:')}
|
|
31
|
-
- The \`sanity schema extract\` command is a prerequisite for extracting your Sanity Studio schema into a \`schema.json\` file, which is then used by the \`sanity typegen generate\` command to generate type definitions
|
|
32
|
-
- While this tool is in beta, we encourage you to experiment with these configurations and provide feedback to help improve its functionality and usability.`.trim();
|
|
30
|
+
- The \`sanity schema extract\` command is a prerequisite for extracting your Sanity Studio schema into a \`schema.json\` file, which is then used by the \`sanity typegen generate\` command to generate type definitions.`.trim();
|
|
33
31
|
/**
|
|
34
32
|
* @internal
|
|
35
33
|
*/ export class TypegenGenerateCommand extends SanityCommand {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/typegen/generate.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {styleText} from 'node:util'\n\nimport {Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {omit, once} from 'lodash-es'\n\nimport {runTypegenGenerate} from '../../actions/typegenGenerate.js'\nimport {runTypegenWatcher} from '../../actions/typegenWatch.js'\nimport {configDefinition, readConfig, type TypeGenConfig} from '../../readConfig.js'\nimport {TypegenWatchModeTrace, TypesGeneratedTrace} from '../../typegen.telemetry.js'\nimport {debug} from '../../utils/debug.js'\nimport {promiseWithResolvers} from '../../utils/promiseWithResolvers.js'\n\nconst description = `Sanity TypeGen (Beta)\nThis command is currently in beta and may undergo significant changes. Feedback is welcome!\n\n${styleText('bold', 'Configuration:')}\nThis command can utilize configuration settings defined in a \\`sanity-typegen.json\\` file. These settings include:\n\n- \"path\": Specifies a glob pattern to locate your TypeScript or JavaScript files.\n Default: \"./src/**/*.{ts,tsx,js,jsx}\"\n\n- \"schema\": Defines the path to your Sanity schema file. This file should be generated using the \\`sanity schema extract\\` command.\n Default: \"schema.json\"\n\n- \"generates\": Indicates the path where the generated TypeScript type definitions will be saved.\n Default: \"./sanity.types.ts\"\n\nThe default configuration values listed above are used if not overridden in your \\`sanity-typegen.json\\` configuration file. To customize the behavior of the type generation, adjust these properties in the configuration file according to your project's needs.\n\n${styleText('bold', 'Note:')}\n- The \\`sanity schema extract\\` command is a prerequisite for extracting your Sanity Studio schema into a \\`schema.json\\` file, which is then used by the \\`sanity typegen generate\\` command to generate type definitions.\n- While this tool is in beta, we encourage you to experiment with these configurations and provide feedback to help improve its functionality and usability.`.trim()\n\n/**\n * @internal\n */\nexport class TypegenGenerateCommand extends SanityCommand<typeof TypegenGenerateCommand> {\n static override description = description\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: `Generate TypeScript type definitions from a Sanity Studio schema extracted using the \\`sanity schema extract\\` command.`,\n },\n ]\n\n static override flags = {\n 'config-path': Flags.string({\n description:\n '[Default: sanity-typegen.json] Specifies the path to the typegen configuration file. This file should be a JSON file that contains settings for the type generation process.',\n }),\n watch: Flags.boolean({\n default: false,\n description: '[Default: false] Run the typegen in watch mode',\n }),\n }\n\n public async run() {\n const {flags} = await this.parse(TypegenGenerateCommand)\n\n if (flags.watch) {\n await this.runWatcher()\n return\n }\n\n await this.runSingle()\n }\n\n private async getConfig(): Promise<{\n config: TypeGenConfig\n path?: string\n type: 'cli' | 'legacy'\n workDir: string\n }> {\n const spin = spinner({}).start('Loading config…')\n\n try {\n const {flags} = await this.parse(TypegenGenerateCommand)\n const rootDir = await this.getProjectRoot()\n const config = await this.getCliConfig()\n\n const configPath = flags['config-path']\n const workDir = rootDir.directory\n\n // check if the legacy config exist\n const legacyConfigPath = configPath || 'sanity-typegen.json'\n let hasLegacyConfig = false\n\n try {\n const file = await stat(legacyConfigPath)\n hasLegacyConfig = file.isFile()\n } catch (err) {\n if (err instanceof Error && 'code' in err && err.code === 'ENOENT' && configPath) {\n spin.fail()\n this.error(`Typegen config file not found: ${configPath}`, {exit: 1})\n }\n\n if (err instanceof Error && 'code' in err && err.code !== 'ENOENT') {\n spin.fail()\n this.error(`Error when checking if typegen config file exists: ${legacyConfigPath}`, {\n exit: 1,\n })\n }\n }\n\n // we have both legacy and cli config with typegen\n if (config?.typegen && hasLegacyConfig) {\n spin.warn(\n styleText(\n 'yellow',\n `You've specified typegen in your Sanity CLI config, but also have a typegen config.\n\n The config from the Sanity CLI config is used.\n `,\n ),\n )\n\n return {\n config: configDefinition.parse(config.typegen || {}),\n path: rootDir.path,\n type: 'cli',\n workDir,\n }\n }\n\n // we only have legacy typegen config\n if (hasLegacyConfig) {\n spin.warn(\n styleText(\n 'yellow',\n `The separate typegen config has been deprecated. Use \\`typegen\\` in the sanity CLI config instead.\n\n See: https://www.sanity.io/docs/help/configuring-typegen-in-sanity-cli-config`,\n ),\n )\n return {\n config: await readConfig(legacyConfigPath),\n path: legacyConfigPath,\n type: 'legacy',\n workDir,\n }\n }\n\n spin.succeed(`Config loaded from sanity.cli.ts`)\n\n // we only have cli config\n return {\n config: configDefinition.parse(config.typegen || {}),\n path: rootDir.path,\n type: 'cli',\n workDir,\n }\n } catch (err) {\n spin.fail()\n this.error(`An error occured during config loading ${err}`, {exit: 1})\n }\n }\n\n private async runSingle() {\n const trace = this.telemetry.trace(TypesGeneratedTrace)\n\n try {\n const {config: typegenConfig, type: typegenConfigMethod, workDir} = await this.getConfig()\n trace.start()\n\n const result = await runTypegenGenerate({\n config: typegenConfig,\n workDir,\n })\n\n const traceStats = omit(result, 'code', 'duration')\n\n trace.log({\n configMethod: typegenConfigMethod,\n configOverloadClientMethods: typegenConfig.overloadClientMethods,\n ...traceStats,\n })\n trace.complete()\n } catch (error) {\n debug(error)\n trace.error(error as Error)\n this.error(`${error instanceof Error ? error.message : 'Unknown error'}`, {\n exit: 1,\n })\n }\n }\n\n private async runWatcher() {\n const trace = this.telemetry.trace(TypegenWatchModeTrace)\n\n try {\n const {config: typegenConfig, workDir} = await this.getConfig()\n trace.start()\n\n const {promise, resolve} = promiseWithResolvers()\n\n const typegenWatcher = runTypegenWatcher({\n config: typegenConfig,\n workDir,\n })\n\n const stop = once(async () => {\n process.off('SIGINT', stop)\n process.off('SIGTERM', stop)\n\n trace.log({\n step: 'stopped',\n ...typegenWatcher.getStats(),\n })\n trace.complete()\n\n await typegenWatcher.stop()\n resolve()\n })\n\n process.on('SIGINT', stop)\n process.on('SIGTERM', stop)\n\n await promise\n } catch (error) {\n debug(error)\n trace.error(error as Error)\n this.error(`${error instanceof Error ? error.message : 'Unknown error'}`, {\n exit: 1,\n })\n }\n }\n}\n"],"names":["stat","styleText","Flags","SanityCommand","spinner","omit","once","runTypegenGenerate","runTypegenWatcher","configDefinition","readConfig","TypegenWatchModeTrace","TypesGeneratedTrace","debug","promiseWithResolvers","description","trim","TypegenGenerateCommand","examples","command","flags","string","watch","boolean","default","run","parse","runWatcher","runSingle","getConfig","spin","start","rootDir","getProjectRoot","config","getCliConfig","configPath","workDir","directory","legacyConfigPath","hasLegacyConfig","file","isFile","err","Error","code","fail","error","exit","typegen","warn","path","type","succeed","trace","telemetry","typegenConfig","typegenConfigMethod","result","traceStats","log","configMethod","configOverloadClientMethods","overloadClientMethods","complete","message","promise","resolve","typegenWatcher","stop","process","off","step","getStats","on"],"mappings":"AAAA,SAAQA,IAAI,QAAO,mBAAkB;AACrC,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,KAAK,QAAO,cAAa;AACjC,SAAQC,aAAa,QAAO,mBAAkB;AAC9C,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,IAAI,EAAEC,IAAI,QAAO,YAAW;AAEpC,SAAQC,kBAAkB,QAAO,mCAAkC;AACnE,SAAQC,iBAAiB,QAAO,gCAA+B;AAC/D,SAAQC,gBAAgB,EAAEC,UAAU,QAA2B,sBAAqB;AACpF,SAAQC,qBAAqB,EAAEC,mBAAmB,QAAO,6BAA4B;AACrF,SAAQC,KAAK,QAAO,uBAAsB;AAC1C,SAAQC,oBAAoB,QAAO,sCAAqC;AAExE,MAAMC,cAAc,CAAC;;;AAGrB,EAAEd,UAAU,QAAQ,kBAAkB;;;;;;;;;;;;;;AActC,EAAEA,UAAU,QAAQ,SAAS;;4JAE+H,CAAC,CAACe,IAAI;AAElK;;CAEC,GACD,OAAO,MAAMC,+BAA+Bd;IAC1C,OAAgBY,cAAcA,YAAW;IAEzC,OAAgBG,WAAW;QACzB;YACEC,SA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GJ,UAAU;YACf;YACAL,MAAMU,QAAQ;QAChB,EAAE,OAAOjB,OAAO;YACdlC,MAAMkC;YACNO,MAAMP,KAAK,CAACA;YACZ,IAAI,CAACA,KAAK,CAAC,GAAGA,iBAAiBH,QAAQG,MAAMkB,OAAO,GAAG,iBAAiB,EAAE;gBACxEjB,MAAM;YACR;QACF;IACF;IAEA,MAAcrB,aAAa;QACzB,MAAM2B,QAAQ,IAAI,CAACC,SAAS,CAACD,KAAK,CAAC3C;QAEnC,IAAI;YACF,MAAM,EAACuB,QAAQsB,aAAa,EAAEnB,OAAO,EAAC,GAAG,MAAM,IAAI,CAACR,SAAS;YAC7DyB,MAAMvB,KAAK;YAEX,MAAM,EAACmC,OAAO,EAAEC,OAAO,EAAC,GAAGrD;YAE3B,MAAMsD,iBAAiB5D,kBAAkB;gBACvC0B,QAAQsB;gBACRnB;YACF;YAEA,MAAMgC,OAAO/D,KAAK;gBAChBgE,QAAQC,GAAG,CAAC,UAAUF;gBACtBC,QAAQC,GAAG,CAAC,WAAWF;gBAEvBf,MAAMM,GAAG,CAAC;oBACRY,MAAM;oBACN,GAAGJ,eAAeK,QAAQ,EAAE;gBAC9B;gBACAnB,MAAMU,QAAQ;gBAEd,MAAMI,eAAeC,IAAI;gBACzBF;YACF;YAEAG,QAAQI,EAAE,CAAC,UAAUL;YACrBC,QAAQI,EAAE,CAAC,WAAWL;YAEtB,MAAMH;QACR,EAAE,OAAOnB,OAAO;YACdlC,MAAMkC;YACNO,MAAMP,KAAK,CAACA;YACZ,IAAI,CAACA,KAAK,CAAC,GAAGA,iBAAiBH,QAAQG,MAAMkB,OAAO,GAAG,iBAAiB,EAAE;gBACxEjB,MAAM;YACR;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/typegen/generate.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {styleText} from 'node:util'\n\nimport {Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {omit, once} from 'lodash-es'\n\nimport {runTypegenGenerate} from '../../actions/typegenGenerate.js'\nimport {runTypegenWatcher} from '../../actions/typegenWatch.js'\nimport {configDefinition, readConfig, type TypeGenConfig} from '../../readConfig.js'\nimport {TypegenWatchModeTrace, TypesGeneratedTrace} from '../../typegen.telemetry.js'\nimport {debug} from '../../utils/debug.js'\nimport {promiseWithResolvers} from '../../utils/promiseWithResolvers.js'\n\nconst description = `Sanity TypeGen\n\n${styleText('bold', 'Configuration:')}\nThis command can utilize configuration settings defined in a \\`sanity-typegen.json\\` file. These settings include:\n\n- \"path\": Specifies a glob pattern to locate your TypeScript or JavaScript files.\n Default: \"./src/**/*.{ts,tsx,js,jsx}\"\n\n- \"schema\": Defines the path to your Sanity schema file. This file should be generated using the \\`sanity schema extract\\` command.\n Default: \"schema.json\"\n\n- \"generates\": Indicates the path where the generated TypeScript type definitions will be saved.\n Default: \"./sanity.types.ts\"\n\nThe default configuration values listed above are used if not overridden in your \\`sanity-typegen.json\\` configuration file. To customize the behavior of the type generation, adjust these properties in the configuration file according to your project's needs.\n\n${styleText('bold', 'Note:')}\n- The \\`sanity schema extract\\` command is a prerequisite for extracting your Sanity Studio schema into a \\`schema.json\\` file, which is then used by the \\`sanity typegen generate\\` command to generate type definitions.`.trim()\n\n/**\n * @internal\n */\nexport class TypegenGenerateCommand extends SanityCommand<typeof TypegenGenerateCommand> {\n static override description = description\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: `Generate TypeScript type definitions from a Sanity Studio schema extracted using the \\`sanity schema extract\\` command.`,\n },\n ]\n\n static override flags = {\n 'config-path': Flags.string({\n description:\n '[Default: sanity-typegen.json] Specifies the path to the typegen configuration file. This file should be a JSON file that contains settings for the type generation process.',\n }),\n watch: Flags.boolean({\n default: false,\n description: '[Default: false] Run the typegen in watch mode',\n }),\n }\n\n public async run() {\n const {flags} = await this.parse(TypegenGenerateCommand)\n\n if (flags.watch) {\n await this.runWatcher()\n return\n }\n\n await this.runSingle()\n }\n\n private async getConfig(): Promise<{\n config: TypeGenConfig\n path?: string\n type: 'cli' | 'legacy'\n workDir: string\n }> {\n const spin = spinner({}).start('Loading config…')\n\n try {\n const {flags} = await this.parse(TypegenGenerateCommand)\n const rootDir = await this.getProjectRoot()\n const config = await this.getCliConfig()\n\n const configPath = flags['config-path']\n const workDir = rootDir.directory\n\n // check if the legacy config exist\n const legacyConfigPath = configPath || 'sanity-typegen.json'\n let hasLegacyConfig = false\n\n try {\n const file = await stat(legacyConfigPath)\n hasLegacyConfig = file.isFile()\n } catch (err) {\n if (err instanceof Error && 'code' in err && err.code === 'ENOENT' && configPath) {\n spin.fail()\n this.error(`Typegen config file not found: ${configPath}`, {exit: 1})\n }\n\n if (err instanceof Error && 'code' in err && err.code !== 'ENOENT') {\n spin.fail()\n this.error(`Error when checking if typegen config file exists: ${legacyConfigPath}`, {\n exit: 1,\n })\n }\n }\n\n // we have both legacy and cli config with typegen\n if (config?.typegen && hasLegacyConfig) {\n spin.warn(\n styleText(\n 'yellow',\n `You've specified typegen in your Sanity CLI config, but also have a typegen config.\n\n The config from the Sanity CLI config is used.\n `,\n ),\n )\n\n return {\n config: configDefinition.parse(config.typegen || {}),\n path: rootDir.path,\n type: 'cli',\n workDir,\n }\n }\n\n // we only have legacy typegen config\n if (hasLegacyConfig) {\n spin.warn(\n styleText(\n 'yellow',\n `The separate typegen config has been deprecated. Use \\`typegen\\` in the sanity CLI config instead.\n\n See: https://www.sanity.io/docs/help/configuring-typegen-in-sanity-cli-config`,\n ),\n )\n return {\n config: await readConfig(legacyConfigPath),\n path: legacyConfigPath,\n type: 'legacy',\n workDir,\n }\n }\n\n spin.succeed(`Config loaded from sanity.cli.ts`)\n\n // we only have cli config\n return {\n config: configDefinition.parse(config.typegen || {}),\n path: rootDir.path,\n type: 'cli',\n workDir,\n }\n } catch (err) {\n spin.fail()\n this.error(`An error occured during config loading ${err}`, {exit: 1})\n }\n }\n\n private async runSingle() {\n const trace = this.telemetry.trace(TypesGeneratedTrace)\n\n try {\n const {config: typegenConfig, type: typegenConfigMethod, workDir} = await this.getConfig()\n trace.start()\n\n const result = await runTypegenGenerate({\n config: typegenConfig,\n workDir,\n })\n\n const traceStats = omit(result, 'code', 'duration')\n\n trace.log({\n configMethod: typegenConfigMethod,\n configOverloadClientMethods: typegenConfig.overloadClientMethods,\n ...traceStats,\n })\n trace.complete()\n } catch (error) {\n debug(error)\n trace.error(error as Error)\n this.error(`${error instanceof Error ? error.message : 'Unknown error'}`, {\n exit: 1,\n })\n }\n }\n\n private async runWatcher() {\n const trace = this.telemetry.trace(TypegenWatchModeTrace)\n\n try {\n const {config: typegenConfig, workDir} = await this.getConfig()\n trace.start()\n\n const {promise, resolve} = promiseWithResolvers()\n\n const typegenWatcher = runTypegenWatcher({\n config: typegenConfig,\n workDir,\n })\n\n const stop = once(async () => {\n process.off('SIGINT', stop)\n process.off('SIGTERM', stop)\n\n trace.log({\n step: 'stopped',\n ...typegenWatcher.getStats(),\n })\n trace.complete()\n\n await typegenWatcher.stop()\n resolve()\n })\n\n process.on('SIGINT', stop)\n process.on('SIGTERM', stop)\n\n await promise\n } catch (error) {\n debug(error)\n trace.error(error as Error)\n this.error(`${error instanceof Error ? error.message : 'Unknown error'}`, {\n exit: 1,\n })\n }\n }\n}\n"],"names":["stat","styleText","Flags","SanityCommand","spinner","omit","once","runTypegenGenerate","runTypegenWatcher","configDefinition","readConfig","TypegenWatchModeTrace","TypesGeneratedTrace","debug","promiseWithResolvers","description","trim","TypegenGenerateCommand","examples","command","flags","string","watch","boolean","default","run","parse","runWatcher","runSingle","getConfig","spin","start","rootDir","getProjectRoot","config","getCliConfig","configPath","workDir","directory","legacyConfigPath","hasLegacyConfig","file","isFile","err","Error","code","fail","error","exit","typegen","warn","path","type","succeed","trace","telemetry","typegenConfig","typegenConfigMethod","result","traceStats","log","configMethod","configOverloadClientMethods","overloadClientMethods","complete","message","promise","resolve","typegenWatcher","stop","process","off","step","getStats","on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,QAAQsB;gBACRnB;YACF;YAEA,MAAMgC,OAAO/D,KAAK;gBAChBgE,QAAQC,GAAG,CAAC,UAAUF;gBACtBC,QAAQC,GAAG,CAAC,WAAWF;gBAEvBf,MAAMM,GAAG,CAAC;oBACRY,MAAM;oBACN,GAAGJ,eAAeK,QAAQ,EAAE;gBAC9B;gBACAnB,MAAMU,QAAQ;gBAEd,MAAMI,eAAeC,IAAI;gBACzBF;YACF;YAEAG,QAAQI,EAAE,CAAC,UAAUL;YACrBC,QAAQI,EAAE,CAAC,WAAWL;YAEtB,MAAMH;QACR,EAAE,OAAOnB,OAAO;YACdlC,MAAMkC;YACNO,MAAMP,KAAK,CAACA;YACZ,IAAI,CAACA,KAAK,CAAC,GAAGA,iBAAiBH,QAAQG,MAAMkB,OAAO,GAAG,iBAAiB,EAAE;gBACxEjB,MAAM;YACR;QACF;IACF;AACF"}
|
|
@@ -138,8 +138,7 @@ const FUNCTION_WRAPPER_ALLOW_LIST = new Set([
|
|
|
138
138
|
filename,
|
|
139
139
|
fnArguments,
|
|
140
140
|
node,
|
|
141
|
-
resolver
|
|
142
|
-
scope
|
|
141
|
+
resolver
|
|
143
142
|
});
|
|
144
143
|
}
|
|
145
144
|
if (babelTypes.isAssignmentPattern(node)) {
|
|
@@ -167,6 +166,28 @@ const FUNCTION_WRAPPER_ALLOW_LIST = new Set([
|
|
|
167
166
|
scope
|
|
168
167
|
});
|
|
169
168
|
}
|
|
169
|
+
if (babelTypes.isMemberExpression(node)) {
|
|
170
|
+
const propertyName = getMemberPropertyName(node);
|
|
171
|
+
const objExpr = resolveToObjectExpression({
|
|
172
|
+
babelConfig,
|
|
173
|
+
file,
|
|
174
|
+
filename,
|
|
175
|
+
node: node.object,
|
|
176
|
+
resolver,
|
|
177
|
+
scope
|
|
178
|
+
});
|
|
179
|
+
const prop = findObjectProperty(objExpr, propertyName, filename, node);
|
|
180
|
+
return resolveExpression({
|
|
181
|
+
babelConfig,
|
|
182
|
+
file,
|
|
183
|
+
filename,
|
|
184
|
+
fnArguments,
|
|
185
|
+
node: prop.value,
|
|
186
|
+
params,
|
|
187
|
+
resolver,
|
|
188
|
+
scope
|
|
189
|
+
});
|
|
190
|
+
}
|
|
170
191
|
throw new Error(`Unsupported expression type: ${node.type} in ${filename}:${node.loc?.start.line}:${node.loc?.start.column}`);
|
|
171
192
|
}
|
|
172
193
|
function resolveIdentifier({ babelConfig, file, filename, fnArguments, node, params, resolver, scope }) {
|
|
@@ -221,7 +242,7 @@ function resolveCallExpression({ babelConfig, file, filename, node, params, reso
|
|
|
221
242
|
scope
|
|
222
243
|
});
|
|
223
244
|
}
|
|
224
|
-
function
|
|
245
|
+
function resolveImportBinding({ babelConfig, file, filename, node, resolver }) {
|
|
225
246
|
let importDeclaration;
|
|
226
247
|
traverse(file, {
|
|
227
248
|
ImportDeclaration (n) {
|
|
@@ -242,24 +263,39 @@ function resolveImportSpecifier({ babelConfig, file, filename, fnArguments, node
|
|
|
242
263
|
if (!importDeclaration) {
|
|
243
264
|
throw new Error(`Could not find import declaration for ${node.local.name}`);
|
|
244
265
|
}
|
|
245
|
-
const importName = node.local.name
|
|
246
|
-
;
|
|
247
|
-
const importFileName = importDeclaration.source.value // the file to import from
|
|
248
|
-
;
|
|
266
|
+
const importName = node.local.name;
|
|
267
|
+
const importFileName = importDeclaration.source.value;
|
|
249
268
|
const importPath = importFileName.startsWith('./') || importFileName.startsWith('../') ? path.resolve(path.dirname(filename), importFileName) : importFileName;
|
|
250
269
|
const resolvedFile = resolver(formatPath(importPath));
|
|
251
270
|
const source = fs.readFileSync(resolvedFile);
|
|
252
271
|
const tree = parseSourceFile(source.toString(), resolvedFile, babelConfig);
|
|
253
|
-
let
|
|
272
|
+
let scope;
|
|
254
273
|
traverse(tree, {
|
|
255
274
|
Program (p) {
|
|
256
|
-
|
|
275
|
+
scope = p.scope;
|
|
257
276
|
}
|
|
258
277
|
});
|
|
259
|
-
if (!
|
|
278
|
+
if (!scope) {
|
|
260
279
|
throw new Error(`Could not find scope for ${filename}`);
|
|
261
280
|
}
|
|
262
|
-
const binding =
|
|
281
|
+
const binding = scope.getBinding(importName);
|
|
282
|
+
return {
|
|
283
|
+
binding,
|
|
284
|
+
importFileName,
|
|
285
|
+
importName,
|
|
286
|
+
resolvedFile,
|
|
287
|
+
scope,
|
|
288
|
+
tree
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
function resolveImportSpecifier({ babelConfig, file, filename, fnArguments, node, resolver }) {
|
|
292
|
+
const { binding, importFileName, importName, resolvedFile, scope, tree } = resolveImportBinding({
|
|
293
|
+
babelConfig,
|
|
294
|
+
file,
|
|
295
|
+
filename,
|
|
296
|
+
node,
|
|
297
|
+
resolver
|
|
298
|
+
});
|
|
263
299
|
if (binding) {
|
|
264
300
|
return resolveExpression({
|
|
265
301
|
babelConfig,
|
|
@@ -268,7 +304,7 @@ function resolveImportSpecifier({ babelConfig, file, filename, fnArguments, node
|
|
|
268
304
|
fnArguments,
|
|
269
305
|
node: binding.path.node,
|
|
270
306
|
resolver,
|
|
271
|
-
scope
|
|
307
|
+
scope
|
|
272
308
|
});
|
|
273
309
|
}
|
|
274
310
|
// It's not a global binding, but it might be a named export
|
|
@@ -352,5 +388,120 @@ function resolveExportSpecifier({ babelConfig, filename, fnArguments, importName
|
|
|
352
388
|
cause: `noBinding:${importName}`
|
|
353
389
|
});
|
|
354
390
|
}
|
|
391
|
+
function getMemberPropertyName(node) {
|
|
392
|
+
const { computed, loc, property } = node;
|
|
393
|
+
if (!computed && babelTypes.isIdentifier(property)) {
|
|
394
|
+
return property.name;
|
|
395
|
+
}
|
|
396
|
+
if (computed && babelTypes.isStringLiteral(property)) {
|
|
397
|
+
return property.value;
|
|
398
|
+
}
|
|
399
|
+
const locInfo = loc ? `${loc.filename}:${loc.start.line}:${loc.start.column}` : 'unknown location';
|
|
400
|
+
throw new Error(`Unsupported MemberExpression property type: ${property.type} @ ${locInfo}`);
|
|
401
|
+
}
|
|
402
|
+
function findObjectProperty(objExpr, propertyName, filename, node) {
|
|
403
|
+
for (const prop of objExpr.properties){
|
|
404
|
+
if (!babelTypes.isObjectProperty(prop)) continue;
|
|
405
|
+
if (babelTypes.isIdentifier(prop.key) && prop.key.name === propertyName) {
|
|
406
|
+
return prop;
|
|
407
|
+
}
|
|
408
|
+
if (babelTypes.isStringLiteral(prop.key) && prop.key.value === propertyName) {
|
|
409
|
+
return prop;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
throw new Error(`Could not find property "${propertyName}" in object expression in ${filename}:${node.loc?.start.line}:${node.loc?.start.column}`);
|
|
413
|
+
}
|
|
414
|
+
function resolveToObjectExpression({ babelConfig, file, filename, node, resolver, scope }) {
|
|
415
|
+
if (babelTypes.isObjectExpression(node)) {
|
|
416
|
+
return node;
|
|
417
|
+
}
|
|
418
|
+
if (babelTypes.isTSAsExpression(node)) {
|
|
419
|
+
return resolveToObjectExpression({
|
|
420
|
+
babelConfig,
|
|
421
|
+
file,
|
|
422
|
+
filename,
|
|
423
|
+
node: node.expression,
|
|
424
|
+
resolver,
|
|
425
|
+
scope
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
if (babelTypes.isIdentifier(node)) {
|
|
429
|
+
const binding = scope.getBinding(node.name);
|
|
430
|
+
if (!binding) {
|
|
431
|
+
throw new Error(`Could not find binding for "${node.name}" in ${filename}`);
|
|
432
|
+
}
|
|
433
|
+
return resolveToObjectExpression({
|
|
434
|
+
babelConfig,
|
|
435
|
+
file,
|
|
436
|
+
filename,
|
|
437
|
+
node: binding.path.node,
|
|
438
|
+
resolver,
|
|
439
|
+
scope
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
if (babelTypes.isVariableDeclarator(node)) {
|
|
443
|
+
if (!node.init) {
|
|
444
|
+
throw new Error(`Variable declarator has no init`);
|
|
445
|
+
}
|
|
446
|
+
return resolveToObjectExpression({
|
|
447
|
+
babelConfig,
|
|
448
|
+
file,
|
|
449
|
+
filename,
|
|
450
|
+
node: node.init,
|
|
451
|
+
resolver,
|
|
452
|
+
scope
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
if (babelTypes.isMemberExpression(node)) {
|
|
456
|
+
const propertyName = getMemberPropertyName(node);
|
|
457
|
+
const objExpr = resolveToObjectExpression({
|
|
458
|
+
babelConfig,
|
|
459
|
+
file,
|
|
460
|
+
filename,
|
|
461
|
+
node: node.object,
|
|
462
|
+
resolver,
|
|
463
|
+
scope
|
|
464
|
+
});
|
|
465
|
+
const prop = findObjectProperty(objExpr, propertyName, filename, node);
|
|
466
|
+
return resolveToObjectExpression({
|
|
467
|
+
babelConfig,
|
|
468
|
+
file,
|
|
469
|
+
filename,
|
|
470
|
+
node: prop.value,
|
|
471
|
+
resolver,
|
|
472
|
+
scope
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
if (babelTypes.isImportDefaultSpecifier(node) || babelTypes.isImportSpecifier(node)) {
|
|
476
|
+
return resolveImportToObjectExpression({
|
|
477
|
+
babelConfig,
|
|
478
|
+
file,
|
|
479
|
+
filename,
|
|
480
|
+
node,
|
|
481
|
+
resolver
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
throw new Error(`Cannot resolve node type "${node.type}" to ObjectExpression in ${filename}:${node.loc?.start.line}:${node.loc?.start.column}`);
|
|
485
|
+
}
|
|
486
|
+
function resolveImportToObjectExpression({ babelConfig, file, filename, node, resolver }) {
|
|
487
|
+
const { binding, importFileName, importName, resolvedFile, scope, tree } = resolveImportBinding({
|
|
488
|
+
babelConfig,
|
|
489
|
+
file,
|
|
490
|
+
filename,
|
|
491
|
+
node,
|
|
492
|
+
resolver
|
|
493
|
+
});
|
|
494
|
+
if (!binding) {
|
|
495
|
+
throw new Error(`Could not find binding for import "${importName}" in ${importFileName}`);
|
|
496
|
+
}
|
|
497
|
+
return resolveToObjectExpression({
|
|
498
|
+
babelConfig,
|
|
499
|
+
file: tree,
|
|
500
|
+
filename: resolvedFile,
|
|
501
|
+
node: binding.path.node,
|
|
502
|
+
resolver,
|
|
503
|
+
scope
|
|
504
|
+
});
|
|
505
|
+
}
|
|
355
506
|
|
|
356
507
|
//# sourceMappingURL=expressionResolvers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/typescript/expressionResolvers.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport {type TransformOptions, traverse} from '@babel/core'\nimport {Scope} from '@babel/traverse'\nimport * as babelTypes from '@babel/types'\nimport createDebug from 'debug'\n\nimport {formatPath} from '../utils/formatPath.js'\nimport {parseSourceFile} from './parseSource.js'\n\nconst debug = createDebug('sanity:codegen:findQueries:debug')\n\ntype resolveExpressionReturnType = string\n\nconst TAGGED_TEMPLATE_ALLOW_LIST = new Set(['groq'])\nconst FUNCTION_WRAPPER_ALLOW_LIST = new Set(['defineQuery'])\n\n/**\n * resolveExpression takes a node and returns the resolved value of the expression.\n * @beta\n * @internal\n */\nexport function resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments = [],\n node,\n params = [],\n resolver,\n scope,\n}: {\n babelConfig: TransformOptions\n file: babelTypes.File\n filename: string\n fnArguments?: babelTypes.Node[]\n node: babelTypes.Node\n params?: babelTypes.Node[]\n resolver: NodeJS.RequireResolve\n scope: Scope\n}): resolveExpressionReturnType {\n debug(\n `Resolving node ${node.type} in ${filename}:${node.loc?.start.line}:${node.loc?.start.column}`,\n )\n if (\n babelTypes.isTaggedTemplateExpression(node) &&\n babelTypes.isIdentifier(node.tag) &&\n TAGGED_TEMPLATE_ALLOW_LIST.has(node.tag.name)\n ) {\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: node.quasi,\n params,\n resolver,\n scope,\n })\n }\n\n if (babelTypes.isTemplateLiteral(node)) {\n const resolvedExpressions = node.expressions.map((expression) =>\n resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: expression,\n params,\n resolver,\n scope,\n }),\n )\n return node.quasis\n .map((quasi, idx) => {\n return (quasi.value.cooked || '') + (resolvedExpressions[idx] || '')\n })\n .join('')\n }\n\n if (babelTypes.isLiteral(node)) {\n if (node.type === 'NullLiteral' || node.type === 'RegExpLiteral') {\n throw new Error(`Unsupported literal type: ${node.type}`)\n }\n\n return node.value.toString()\n }\n\n if (babelTypes.isIdentifier(node)) {\n return resolveIdentifier({\n babelConfig,\n file,\n filename,\n fnArguments,\n node,\n params,\n resolver,\n scope,\n })\n }\n\n if (babelTypes.isVariableDeclarator(node)) {\n const init = node.init ?? (babelTypes.isAssignmentPattern(node.id) && node.id.right)\n if (!init) {\n throw new Error(`Unsupported variable declarator`)\n }\n\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: init,\n resolver,\n scope,\n })\n }\n\n if (\n babelTypes.isCallExpression(node) &&\n babelTypes.isIdentifier(node.callee) &&\n FUNCTION_WRAPPER_ALLOW_LIST.has(node.callee.name)\n ) {\n return resolveExpression({\n babelConfig,\n file,\n filename,\n node: node.arguments[0]!,\n params,\n resolver,\n scope,\n })\n }\n\n if (babelTypes.isCallExpression(node)) {\n return resolveCallExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node,\n params,\n resolver,\n scope,\n })\n }\n\n if (\n babelTypes.isArrowFunctionExpression(node) ||\n babelTypes.isFunctionDeclaration(node) ||\n babelTypes.isFunctionExpression(node)\n ) {\n const newScope = new Scope(scope.path, scope)\n\n for (const [i, param] of params.entries()) {\n newScope.push({\n id: param as babelTypes.LVal,\n init: fnArguments[i] as babelTypes.Expression | undefined,\n })\n }\n\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: node.body,\n params: node.params,\n resolver,\n scope: newScope,\n })\n }\n\n if (babelTypes.isNewExpression(node)) {\n return resolveExpression({\n babelConfig,\n file,\n filename,\n node: node.callee,\n resolver,\n scope,\n })\n }\n\n if (babelTypes.isImportDefaultSpecifier(node) || babelTypes.isImportSpecifier(node)) {\n return resolveImportSpecifier({babelConfig, file, filename, fnArguments, node, resolver, scope})\n }\n\n if (babelTypes.isAssignmentPattern(node)) {\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: node.right,\n params,\n resolver,\n scope,\n })\n }\n\n // Handle TypeScript type assertions (e.g., `'foo' as string`)\n if (babelTypes.isTSAsExpression(node)) {\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: node.expression,\n params,\n resolver,\n scope,\n })\n }\n\n throw new Error(\n `Unsupported expression type: ${node.type} in ${filename}:${node.loc?.start.line}:${node.loc?.start.column}`,\n )\n}\n\nfunction resolveIdentifier({\n babelConfig,\n file,\n filename,\n fnArguments,\n node,\n params,\n resolver,\n scope,\n}: {\n babelConfig: TransformOptions\n file: babelTypes.File\n filename: string\n fnArguments: babelTypes.Node[]\n node: babelTypes.Identifier\n params: babelTypes.Node[]\n resolver: NodeJS.RequireResolve\n scope: Scope\n}): resolveExpressionReturnType {\n const paramIndex = params.findIndex(\n (param) =>\n (babelTypes.isIdentifier(param) && node.name === param.name) ||\n (babelTypes.isAssignmentPattern(param) &&\n babelTypes.isIdentifier(param.left) &&\n node.name === param.left.name),\n )\n let argument = fnArguments[paramIndex]\n if (!argument && paramIndex !== -1 && babelTypes.isAssignmentPattern(params[paramIndex])) {\n argument = params[paramIndex].right\n }\n if (argument && babelTypes.isLiteral(argument)) {\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: argument,\n params,\n resolver,\n scope,\n })\n }\n const binding = scope.getBinding(node.name)\n if (binding) {\n if (babelTypes.isIdentifier(binding.path.node)) {\n const isSame = binding.path.node.name === node.name\n if (isSame) {\n throw new Error(\n `Could not resolve same identifier \"${node.name}\" in \"${filename}:${node.loc?.start.line}:${node.loc?.start.column}\"`,\n )\n }\n }\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: binding.path.node,\n params,\n resolver,\n scope,\n })\n }\n\n throw new Error(\n `Could not find binding for node \"${node.name}\" in ${filename}:${node.loc?.start.line}:${node.loc?.start.column}`,\n )\n}\n\nfunction resolveCallExpression({\n babelConfig,\n file,\n filename,\n node,\n params,\n resolver,\n scope,\n}: {\n babelConfig: TransformOptions\n file: babelTypes.File\n filename: string\n fnArguments: babelTypes.Node[]\n node: babelTypes.CallExpression\n params: babelTypes.Node[]\n resolver: NodeJS.RequireResolve\n scope: Scope\n}): resolveExpressionReturnType {\n const {callee} = node\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments: node.arguments,\n node: callee,\n params,\n resolver,\n scope,\n })\n}\n\nfunction resolveImportSpecifier({\n babelConfig,\n file,\n filename,\n fnArguments,\n node,\n resolver,\n}: {\n babelConfig: TransformOptions\n file: babelTypes.File\n filename: string\n fnArguments: babelTypes.Node[]\n node: babelTypes.ExportSpecifier | babelTypes.ImportDefaultSpecifier | babelTypes.ImportSpecifier\n resolver: NodeJS.RequireResolve\n scope: Scope\n}): resolveExpressionReturnType {\n let importDeclaration: babelTypes.ImportDeclaration | undefined\n traverse(file, {\n ImportDeclaration(n) {\n if (!babelTypes.isImportDeclaration(n.node)) {\n return\n }\n for (const specifier of n.node.specifiers) {\n if (\n babelTypes.isImportDefaultSpecifier(specifier) &&\n specifier.local.loc?.identifierName === node.local.name\n ) {\n importDeclaration = n.node\n break\n }\n if (specifier.local.name === node.local.name) {\n importDeclaration = n.node\n }\n }\n },\n })\n\n if (!importDeclaration) {\n throw new Error(`Could not find import declaration for ${node.local.name}`)\n }\n\n const importName = node.local.name // the name of the variable to import\n const importFileName = importDeclaration.source.value // the file to import from\n\n const importPath =\n importFileName.startsWith('./') || importFileName.startsWith('../')\n ? path.resolve(path.dirname(filename), importFileName)\n : importFileName\n\n const resolvedFile = resolver(formatPath(importPath))\n const source = fs.readFileSync(resolvedFile)\n const tree = parseSourceFile(source.toString(), resolvedFile, babelConfig)\n\n let newScope: Scope | undefined\n traverse(tree, {\n Program(p) {\n newScope = p.scope\n },\n })\n if (!newScope) {\n throw new Error(`Could not find scope for ${filename}`)\n }\n\n const binding = newScope.getBinding(importName)\n if (binding) {\n return resolveExpression({\n babelConfig,\n file: tree,\n filename: resolvedFile,\n fnArguments,\n node: binding.path.node,\n resolver,\n scope: newScope,\n })\n }\n\n // It's not a global binding, but it might be a named export\n let namedExport: babelTypes.ExportNamedDeclaration | undefined\n let newImportName: string | undefined\n traverse(tree, {\n ExportDeclaration(p) {\n if (p.node.type === 'ExportNamedDeclaration') {\n for (const specifier of p.node.specifiers) {\n if (\n specifier.type === 'ExportSpecifier' &&\n specifier.exported.type === 'Identifier' &&\n specifier.exported.name === importName\n ) {\n namedExport = p.node\n newImportName = specifier.exported.name\n }\n }\n }\n },\n })\n\n if (namedExport && newImportName) {\n return resolveExportSpecifier({\n babelConfig,\n filename: resolvedFile,\n fnArguments,\n importName: newImportName,\n node: namedExport,\n resolver,\n })\n }\n\n let result: resolveExpressionReturnType | undefined\n traverse(tree, {\n ExportDeclaration(p) {\n if (p.node.type === 'ExportAllDeclaration') {\n try {\n result = resolveExportSpecifier({\n babelConfig,\n filename: resolvedFile,\n fnArguments,\n importName,\n node: p.node,\n resolver,\n })\n } catch (e) {\n if ((e as Error).cause !== `noBinding:${importName}`) throw e\n }\n }\n },\n })\n if (result) return result\n\n throw new Error(`Could not find binding for import \"${importName}\" in ${importFileName}`)\n}\n\nfunction resolveExportSpecifier({\n babelConfig,\n filename,\n fnArguments,\n importName,\n node,\n resolver,\n}: {\n babelConfig: TransformOptions\n filename: string\n fnArguments: babelTypes.Node[]\n importName: string\n node: babelTypes.ExportAllDeclaration | babelTypes.ExportNamedDeclaration\n resolver: NodeJS.RequireResolve\n}): resolveExpressionReturnType {\n if (!node.source) {\n throw new Error(`Could not find source for export \"${importName}\" in ${filename}`)\n }\n\n const importFileName = node.source.value\n const importPath = path.resolve(path.dirname(filename), importFileName)\n const resolvedFile = resolver(formatPath(importPath))\n const source = fs.readFileSync(resolvedFile)\n const tree = parseSourceFile(source.toString(), resolvedFile, babelConfig)\n\n let newScope: Scope | undefined\n traverse(tree, {\n Program(p) {\n newScope = p.scope\n },\n })\n if (!newScope) {\n throw new Error(`Could not find scope for ${filename}`)\n }\n\n const binding = newScope.getBinding(importName)\n if (binding) {\n return resolveExpression({\n babelConfig,\n file: tree,\n filename: resolvedFile,\n fnArguments,\n node: binding.path.node,\n resolver,\n scope: newScope,\n })\n }\n\n throw new Error(`Could not find binding for export \"${importName}\" in ${importFileName}`, {\n cause: `noBinding:${importName}`,\n })\n}\n"],"names":["fs","path","traverse","Scope","babelTypes","createDebug","formatPath","parseSourceFile","debug","TAGGED_TEMPLATE_ALLOW_LIST","Set","FUNCTION_WRAPPER_ALLOW_LIST","resolveExpression","babelConfig","file","filename","fnArguments","node","params","resolver","scope","type","loc","start","line","column","isTaggedTemplateExpression","isIdentifier","tag","has","name","quasi","isTemplateLiteral","resolvedExpressions","expressions","map","expression","quasis","idx","value","cooked","join","isLiteral","Error","toString","resolveIdentifier","isVariableDeclarator","init","isAssignmentPattern","id","right","isCallExpression","callee","arguments","resolveCallExpression","isArrowFunctionExpression","isFunctionDeclaration","isFunctionExpression","newScope","i","param","entries","push","body","isNewExpression","isImportDefaultSpecifier","isImportSpecifier","resolveImportSpecifier","isTSAsExpression","paramIndex","findIndex","left","argument","binding","getBinding","isSame","importDeclaration","ImportDeclaration","n","isImportDeclaration","specifier","specifiers","local","identifierName","importName","importFileName","source","importPath","startsWith","resolve","dirname","resolvedFile","readFileSync","tree","Program","p","namedExport","newImportName","ExportDeclaration","exported","resolveExportSpecifier","result","e","cause"],"mappings":"AAAA,OAAOA,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,SAA+BC,QAAQ,QAAO,cAAa;AAC3D,SAAQC,KAAK,QAAO,kBAAiB;AACrC,YAAYC,gBAAgB,eAAc;AAC1C,OAAOC,iBAAiB,QAAO;AAE/B,SAAQC,UAAU,QAAO,yBAAwB;AACjD,SAAQC,eAAe,QAAO,mBAAkB;AAEhD,MAAMC,QAAQH,YAAY;AAI1B,MAAMI,6BAA6B,IAAIC,IAAI;IAAC;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gBAAgB,EAAE;QACxFkB,OAAO,CAAC,UAAU,EAAEnB,YAAY;IAClC;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/typescript/expressionResolvers.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport {type TransformOptions, traverse} from '@babel/core'\nimport {Scope} from '@babel/traverse'\nimport * as babelTypes from '@babel/types'\nimport createDebug from 'debug'\n\nimport {formatPath} from '../utils/formatPath.js'\nimport {parseSourceFile} from './parseSource.js'\n\nconst debug = createDebug('sanity:codegen:findQueries:debug')\n\ntype resolveExpressionReturnType = string\n\nconst TAGGED_TEMPLATE_ALLOW_LIST = new Set(['groq'])\nconst FUNCTION_WRAPPER_ALLOW_LIST = new Set(['defineQuery'])\n\n/**\n * resolveExpression takes a node and returns the resolved value of the expression.\n * @beta\n * @internal\n */\nexport function resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments = [],\n node,\n params = [],\n resolver,\n scope,\n}: {\n babelConfig: TransformOptions\n file: babelTypes.File\n filename: string\n fnArguments?: babelTypes.Node[]\n node: babelTypes.Node\n params?: babelTypes.Node[]\n resolver: NodeJS.RequireResolve\n scope: Scope\n}): resolveExpressionReturnType {\n debug(\n `Resolving node ${node.type} in ${filename}:${node.loc?.start.line}:${node.loc?.start.column}`,\n )\n if (\n babelTypes.isTaggedTemplateExpression(node) &&\n babelTypes.isIdentifier(node.tag) &&\n TAGGED_TEMPLATE_ALLOW_LIST.has(node.tag.name)\n ) {\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: node.quasi,\n params,\n resolver,\n scope,\n })\n }\n\n if (babelTypes.isTemplateLiteral(node)) {\n const resolvedExpressions = node.expressions.map((expression) =>\n resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: expression,\n params,\n resolver,\n scope,\n }),\n )\n return node.quasis\n .map((quasi, idx) => {\n return (quasi.value.cooked || '') + (resolvedExpressions[idx] || '')\n })\n .join('')\n }\n\n if (babelTypes.isLiteral(node)) {\n if (node.type === 'NullLiteral' || node.type === 'RegExpLiteral') {\n throw new Error(`Unsupported literal type: ${node.type}`)\n }\n\n return node.value.toString()\n }\n\n if (babelTypes.isIdentifier(node)) {\n return resolveIdentifier({\n babelConfig,\n file,\n filename,\n fnArguments,\n node,\n params,\n resolver,\n scope,\n })\n }\n\n if (babelTypes.isVariableDeclarator(node)) {\n const init = node.init ?? (babelTypes.isAssignmentPattern(node.id) && node.id.right)\n if (!init) {\n throw new Error(`Unsupported variable declarator`)\n }\n\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: init,\n resolver,\n scope,\n })\n }\n\n if (\n babelTypes.isCallExpression(node) &&\n babelTypes.isIdentifier(node.callee) &&\n FUNCTION_WRAPPER_ALLOW_LIST.has(node.callee.name)\n ) {\n return resolveExpression({\n babelConfig,\n file,\n filename,\n node: node.arguments[0]!,\n params,\n resolver,\n scope,\n })\n }\n\n if (babelTypes.isCallExpression(node)) {\n return resolveCallExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node,\n params,\n resolver,\n scope,\n })\n }\n\n if (\n babelTypes.isArrowFunctionExpression(node) ||\n babelTypes.isFunctionDeclaration(node) ||\n babelTypes.isFunctionExpression(node)\n ) {\n const newScope = new Scope(scope.path, scope)\n\n for (const [i, param] of params.entries()) {\n newScope.push({\n id: param as babelTypes.LVal,\n init: fnArguments[i] as babelTypes.Expression | undefined,\n })\n }\n\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: node.body,\n params: node.params,\n resolver,\n scope: newScope,\n })\n }\n\n if (babelTypes.isNewExpression(node)) {\n return resolveExpression({\n babelConfig,\n file,\n filename,\n node: node.callee,\n resolver,\n scope,\n })\n }\n\n if (babelTypes.isImportDefaultSpecifier(node) || babelTypes.isImportSpecifier(node)) {\n return resolveImportSpecifier({babelConfig, file, filename, fnArguments, node, resolver})\n }\n\n if (babelTypes.isAssignmentPattern(node)) {\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: node.right,\n params,\n resolver,\n scope,\n })\n }\n\n // Handle TypeScript type assertions (e.g., `'foo' as string`)\n if (babelTypes.isTSAsExpression(node)) {\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: node.expression,\n params,\n resolver,\n scope,\n })\n }\n\n if (babelTypes.isMemberExpression(node)) {\n const propertyName = getMemberPropertyName(node)\n const objExpr = resolveToObjectExpression({\n babelConfig,\n file,\n filename,\n node: node.object,\n resolver,\n scope,\n })\n const prop = findObjectProperty(objExpr, propertyName, filename, node)\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: prop.value,\n params,\n resolver,\n scope,\n })\n }\n\n throw new Error(\n `Unsupported expression type: ${node.type} in ${filename}:${node.loc?.start.line}:${node.loc?.start.column}`,\n )\n}\n\nfunction resolveIdentifier({\n babelConfig,\n file,\n filename,\n fnArguments,\n node,\n params,\n resolver,\n scope,\n}: {\n babelConfig: TransformOptions\n file: babelTypes.File\n filename: string\n fnArguments: babelTypes.Node[]\n node: babelTypes.Identifier\n params: babelTypes.Node[]\n resolver: NodeJS.RequireResolve\n scope: Scope\n}): resolveExpressionReturnType {\n const paramIndex = params.findIndex(\n (param) =>\n (babelTypes.isIdentifier(param) && node.name === param.name) ||\n (babelTypes.isAssignmentPattern(param) &&\n babelTypes.isIdentifier(param.left) &&\n node.name === param.left.name),\n )\n let argument = fnArguments[paramIndex]\n if (!argument && paramIndex !== -1 && babelTypes.isAssignmentPattern(params[paramIndex])) {\n argument = params[paramIndex].right\n }\n if (argument && babelTypes.isLiteral(argument)) {\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: argument,\n params,\n resolver,\n scope,\n })\n }\n const binding = scope.getBinding(node.name)\n if (binding) {\n if (babelTypes.isIdentifier(binding.path.node)) {\n const isSame = binding.path.node.name === node.name\n if (isSame) {\n throw new Error(\n `Could not resolve same identifier \"${node.name}\" in \"${filename}:${node.loc?.start.line}:${node.loc?.start.column}\"`,\n )\n }\n }\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments,\n node: binding.path.node,\n params,\n resolver,\n scope,\n })\n }\n\n throw new Error(\n `Could not find binding for node \"${node.name}\" in ${filename}:${node.loc?.start.line}:${node.loc?.start.column}`,\n )\n}\n\nfunction resolveCallExpression({\n babelConfig,\n file,\n filename,\n node,\n params,\n resolver,\n scope,\n}: {\n babelConfig: TransformOptions\n file: babelTypes.File\n filename: string\n fnArguments: babelTypes.Node[]\n node: babelTypes.CallExpression\n params: babelTypes.Node[]\n resolver: NodeJS.RequireResolve\n scope: Scope\n}): resolveExpressionReturnType {\n const {callee} = node\n return resolveExpression({\n babelConfig,\n file,\n filename,\n fnArguments: node.arguments,\n node: callee,\n params,\n resolver,\n scope,\n })\n}\n\nfunction resolveImportBinding({\n babelConfig,\n file,\n filename,\n node,\n resolver,\n}: {\n babelConfig: TransformOptions\n file: babelTypes.File\n filename: string\n node: babelTypes.ExportSpecifier | babelTypes.ImportDefaultSpecifier | babelTypes.ImportSpecifier\n resolver: NodeJS.RequireResolve\n}) {\n let importDeclaration: babelTypes.ImportDeclaration | undefined\n traverse(file, {\n ImportDeclaration(n) {\n if (!babelTypes.isImportDeclaration(n.node)) {\n return\n }\n for (const specifier of n.node.specifiers) {\n if (\n babelTypes.isImportDefaultSpecifier(specifier) &&\n specifier.local.loc?.identifierName === node.local.name\n ) {\n importDeclaration = n.node\n break\n }\n if (specifier.local.name === node.local.name) {\n importDeclaration = n.node\n }\n }\n },\n })\n\n if (!importDeclaration) {\n throw new Error(`Could not find import declaration for ${node.local.name}`)\n }\n\n const importName = node.local.name\n const importFileName = importDeclaration.source.value\n\n const importPath =\n importFileName.startsWith('./') || importFileName.startsWith('../')\n ? path.resolve(path.dirname(filename), importFileName)\n : importFileName\n\n const resolvedFile = resolver(formatPath(importPath))\n const source = fs.readFileSync(resolvedFile)\n const tree = parseSourceFile(source.toString(), resolvedFile, babelConfig)\n\n let scope: Scope | undefined\n traverse(tree, {\n Program(p) {\n scope = p.scope\n },\n })\n if (!scope) {\n throw new Error(`Could not find scope for ${filename}`)\n }\n\n const binding = scope.getBinding(importName)\n return {binding, importFileName, importName, resolvedFile, scope, tree}\n}\n\nfunction resolveImportSpecifier({\n babelConfig,\n file,\n filename,\n fnArguments,\n node,\n resolver,\n}: {\n babelConfig: TransformOptions\n file: babelTypes.File\n filename: string\n fnArguments: babelTypes.Node[]\n node: babelTypes.ExportSpecifier | babelTypes.ImportDefaultSpecifier | babelTypes.ImportSpecifier\n resolver: NodeJS.RequireResolve\n}): resolveExpressionReturnType {\n const {binding, importFileName, importName, resolvedFile, scope, tree} = resolveImportBinding({\n babelConfig,\n file,\n filename,\n node,\n resolver,\n })\n\n if (binding) {\n return resolveExpression({\n babelConfig,\n file: tree,\n filename: resolvedFile,\n fnArguments,\n node: binding.path.node,\n resolver,\n scope,\n })\n }\n\n // It's not a global binding, but it might be a named export\n let namedExport: babelTypes.ExportNamedDeclaration | undefined\n let newImportName: string | undefined\n traverse(tree, {\n ExportDeclaration(p) {\n if (p.node.type === 'ExportNamedDeclaration') {\n for (const specifier of p.node.specifiers) {\n if (\n specifier.type === 'ExportSpecifier' &&\n specifier.exported.type === 'Identifier' &&\n specifier.exported.name === importName\n ) {\n namedExport = p.node\n newImportName = specifier.exported.name\n }\n }\n }\n },\n })\n\n if (namedExport && newImportName) {\n return resolveExportSpecifier({\n babelConfig,\n filename: resolvedFile,\n fnArguments,\n importName: newImportName,\n node: namedExport,\n resolver,\n })\n }\n\n let result: resolveExpressionReturnType | undefined\n traverse(tree, {\n ExportDeclaration(p) {\n if (p.node.type === 'ExportAllDeclaration') {\n try {\n result = resolveExportSpecifier({\n babelConfig,\n filename: resolvedFile,\n fnArguments,\n importName,\n node: p.node,\n resolver,\n })\n } catch (e) {\n if ((e as Error).cause !== `noBinding:${importName}`) throw e\n }\n }\n },\n })\n if (result) return result\n\n throw new Error(`Could not find binding for import \"${importName}\" in ${importFileName}`)\n}\n\nfunction resolveExportSpecifier({\n babelConfig,\n filename,\n fnArguments,\n importName,\n node,\n resolver,\n}: {\n babelConfig: TransformOptions\n filename: string\n fnArguments: babelTypes.Node[]\n importName: string\n node: babelTypes.ExportAllDeclaration | babelTypes.ExportNamedDeclaration\n resolver: NodeJS.RequireResolve\n}): resolveExpressionReturnType {\n if (!node.source) {\n throw new Error(`Could not find source for export \"${importName}\" in ${filename}`)\n }\n\n const importFileName = node.source.value\n const importPath = path.resolve(path.dirname(filename), importFileName)\n const resolvedFile = resolver(formatPath(importPath))\n const source = fs.readFileSync(resolvedFile)\n const tree = parseSourceFile(source.toString(), resolvedFile, babelConfig)\n\n let newScope: Scope | undefined\n traverse(tree, {\n Program(p) {\n newScope = p.scope\n },\n })\n if (!newScope) {\n throw new Error(`Could not find scope for ${filename}`)\n }\n\n const binding = newScope.getBinding(importName)\n if (binding) {\n return resolveExpression({\n babelConfig,\n file: tree,\n filename: resolvedFile,\n fnArguments,\n node: binding.path.node,\n resolver,\n scope: newScope,\n })\n }\n\n throw new Error(`Could not find binding for export \"${importName}\" in ${importFileName}`, {\n cause: `noBinding:${importName}`,\n })\n}\n\nfunction getMemberPropertyName(node: babelTypes.MemberExpression): string {\n const {computed, loc, property} = node\n if (!computed && babelTypes.isIdentifier(property)) {\n return property.name\n }\n if (computed && babelTypes.isStringLiteral(property)) {\n return property.value\n }\n const locInfo = loc ? `${loc.filename}:${loc.start.line}:${loc.start.column}` : 'unknown location'\n throw new Error(`Unsupported MemberExpression property type: ${property.type} @ ${locInfo}`)\n}\n\nfunction findObjectProperty(\n objExpr: babelTypes.ObjectExpression,\n propertyName: string,\n filename: string,\n node: babelTypes.Node,\n): babelTypes.ObjectProperty {\n for (const prop of objExpr.properties) {\n if (!babelTypes.isObjectProperty(prop)) continue\n if (babelTypes.isIdentifier(prop.key) && prop.key.name === propertyName) {\n return prop\n }\n if (babelTypes.isStringLiteral(prop.key) && prop.key.value === propertyName) {\n return prop\n }\n }\n throw new Error(\n `Could not find property \"${propertyName}\" in object expression in ${filename}:${node.loc?.start.line}:${node.loc?.start.column}`,\n )\n}\n\nfunction resolveToObjectExpression({\n babelConfig,\n file,\n filename,\n node,\n resolver,\n scope,\n}: {\n babelConfig: TransformOptions\n file: babelTypes.File\n filename: string\n node: babelTypes.Node\n resolver: NodeJS.RequireResolve\n scope: Scope\n}): babelTypes.ObjectExpression {\n if (babelTypes.isObjectExpression(node)) {\n return node\n }\n if (babelTypes.isTSAsExpression(node)) {\n return resolveToObjectExpression({\n babelConfig,\n file,\n filename,\n node: node.expression,\n resolver,\n scope,\n })\n }\n if (babelTypes.isIdentifier(node)) {\n const binding = scope.getBinding(node.name)\n if (!binding) {\n throw new Error(`Could not find binding for \"${node.name}\" in ${filename}`)\n }\n return resolveToObjectExpression({\n babelConfig,\n file,\n filename,\n node: binding.path.node,\n resolver,\n scope,\n })\n }\n if (babelTypes.isVariableDeclarator(node)) {\n if (!node.init) {\n throw new Error(`Variable declarator has no init`)\n }\n return resolveToObjectExpression({\n babelConfig,\n file,\n filename,\n node: node.init,\n resolver,\n scope,\n })\n }\n if (babelTypes.isMemberExpression(node)) {\n const propertyName = getMemberPropertyName(node)\n const objExpr = resolveToObjectExpression({\n babelConfig,\n file,\n filename,\n node: node.object,\n resolver,\n scope,\n })\n const prop = findObjectProperty(objExpr, propertyName, filename, node)\n return resolveToObjectExpression({\n babelConfig,\n file,\n filename,\n node: prop.value,\n resolver,\n scope,\n })\n }\n if (babelTypes.isImportDefaultSpecifier(node) || babelTypes.isImportSpecifier(node)) {\n return resolveImportToObjectExpression({babelConfig, file, filename, node, resolver})\n }\n throw new Error(\n `Cannot resolve node type \"${node.type}\" to ObjectExpression in ${filename}:${node.loc?.start.line}:${node.loc?.start.column}`,\n )\n}\n\nfunction resolveImportToObjectExpression({\n babelConfig,\n file,\n filename,\n node,\n resolver,\n}: {\n babelConfig: TransformOptions\n file: babelTypes.File\n filename: string\n node: babelTypes.ImportDefaultSpecifier | babelTypes.ImportSpecifier\n resolver: NodeJS.RequireResolve\n}): babelTypes.ObjectExpression {\n const {binding, importFileName, importName, resolvedFile, scope, tree} = resolveImportBinding({\n babelConfig,\n file,\n filename,\n node,\n resolver,\n })\n\n if (!binding) {\n throw new Error(`Could not find binding for import \"${importName}\" in ${importFileName}`)\n }\n\n return resolveToObjectExpression({\n babelConfig,\n file: tree,\n filename: resolvedFile,\n node: binding.path.node,\n resolver,\n scope,\n })\n}\n"],"names":["fs","path","traverse","Scope","babelTypes","createDebug","formatPath","parseSourceFile","debug","TAGGED_TEMPLATE_ALLOW_LIST","Set","FUNCTION_WRAPPER_ALLOW_LIST","resolveExpression","babelConfig","file","filename","fnArguments","node","params","resolver","scope","type","loc","start","line","column","isTaggedTemplateExpression","isIdentifier","tag","has","name","quasi","isTemplateLiteral","resolvedExpressions","expressions","map","expression","quasis","idx","value","cooked","join","isLiteral","Error","toString","resolveIdentifier","isVariableDeclarator","init","isAssignmentPattern","id","right","isCallExpression","callee","arguments","resolveCallExpression","isArrowFunctionExpression","isFunctionDeclaration","isFunctionExpression","newScope","i","param","entries","push","body","isNewExpression","isImportDefaultSpecifier","isImportSpecifier","resolveImportSpecifier","isTSAsExpression","isMemberExpression","propertyName","getMemberPropertyName","objExpr","resolveToObjectExpression","object","prop","findObjectProperty","paramIndex","findIndex","left","argument","binding","getBinding","isSame","resolveImportBinding","importDeclaration","ImportDeclaration","n","isImportDeclaration","specifier","specifiers","local","identifierName","importName","importFileName","source","importPath","startsWith","resolve","dirname","resolvedFile","readFileSync","tree","Program","p","namedExport","newImportName","ExportDeclaration","exported","resolveExportSpecifier","result","e","cause","computed","property","isStringLiteral","locInfo","properties","isObjectProperty","key","isObjectExpression","resolveImportToObjectExpression"],"mappings":"AAAA,OAAOA,QAAQ,UAAS;AACxB,OAAOC,UAAU,YAAW;AAE5B,SAA+BC,QAAQ,QAAO,cAAa;AAC3D,SAAQC,KAAK,QAAO,kBAAiB;AACrC,YAAYC,gBAAgB,eAAc;AAC1C,OAAOC,iBAAiB,QAAO;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,IAAI,CAAC8D,SAAS;QACZ,MAAM,IAAItC,MAAM,CAAC,mCAAmC,EAAEkD,WAAW,KAAK,EAAEC,gBAAgB;IAC1F;IAEA,OAAOrB,0BAA0B;QAC/B5D;QACAC,MAAMwF;QACNvF,UAAUqF;QACVnF,MAAMgE,QAAQhF,IAAI,CAACgB,IAAI;QACvBE;QACAC;IACF;AACF"}
|
package/oclif.config.js
CHANGED
package/oclif.manifest.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"typegen:generate": {
|
|
4
4
|
"aliases": [],
|
|
5
5
|
"args": {},
|
|
6
|
-
"description": "Sanity TypeGen
|
|
6
|
+
"description": "Sanity TypeGen\n\nConfiguration:\nThis command can utilize configuration settings defined in a `sanity-typegen.json` file. These settings include:\n\n- \"path\": Specifies a glob pattern to locate your TypeScript or JavaScript files.\n Default: \"./src/**/*.{ts,tsx,js,jsx}\"\n\n- \"schema\": Defines the path to your Sanity schema file. This file should be generated using the `sanity schema extract` command.\n Default: \"schema.json\"\n\n- \"generates\": Indicates the path where the generated TypeScript type definitions will be saved.\n Default: \"./sanity.types.ts\"\n\nThe default configuration values listed above are used if not overridden in your `sanity-typegen.json` configuration file. To customize the behavior of the type generation, adjust these properties in the configuration file according to your project's needs.\n\nNote:\n- The `sanity schema extract` command is a prerequisite for extracting your Sanity Studio schema into a `schema.json` file, which is then used by the `sanity typegen generate` command to generate type definitions.",
|
|
7
7
|
"examples": [
|
|
8
8
|
{
|
|
9
9
|
"command": "<%= config.bin %> <%= command.id %>",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
]
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
"version": "5.
|
|
44
|
+
"version": "5.10.0"
|
|
45
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/codegen",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.0",
|
|
4
4
|
"description": "Codegen toolkit for Sanity.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
"@babel/types": "^7.28.6",
|
|
54
54
|
"@oclif/core": "^4.8.0",
|
|
55
55
|
"@oclif/plugin-help": "^6.2.36",
|
|
56
|
-
"@sanity/cli-core": "^0.1.0-alpha.
|
|
56
|
+
"@sanity/cli-core": "^0.1.0-alpha.12",
|
|
57
57
|
"@sanity/worker-channels": "^1.1.0",
|
|
58
58
|
"chokidar": "^3.6.0",
|
|
59
59
|
"debug": "^4.4.3",
|
|
60
60
|
"globby": "^11.1.0",
|
|
61
|
-
"groq": "^5.
|
|
62
|
-
"groq-js": "^1.
|
|
61
|
+
"groq": "^5.10.0",
|
|
62
|
+
"groq-js": "^1.27.1",
|
|
63
63
|
"json5": "^2.2.3",
|
|
64
64
|
"lodash-es": "^4.17.23",
|
|
65
65
|
"prettier": "^3.7.4",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@eslint/compat": "^2.0.1",
|
|
72
72
|
"@microsoft/api-extractor": "^7.55.2",
|
|
73
73
|
"@oclif/test": "^4.1.15",
|
|
74
|
-
"@sanity/cli-test": "^0.0.2-alpha.
|
|
74
|
+
"@sanity/cli-test": "^0.0.2-alpha.11",
|
|
75
75
|
"@sanity/eslint-config-cli": "0.0.0-alpha.2",
|
|
76
76
|
"@sanity/telemetry": "^0.8.0",
|
|
77
77
|
"@swc/cli": "^0.7.9",
|