jsii-rosetta 6.0.8 → 6.0.10-dev.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.
@@ -83,6 +83,43 @@ export interface TypeLookupAssembly {
83
83
  * load the assembly into memory.
84
84
  */
85
85
  export declare function findTypeLookupAssembly(startingDirectory: string): TypeLookupAssembly | undefined;
86
+ /**
87
+ * Look up the jsii fqn for a given symbolId in a `TypeLookupAssembly`
88
+ *
89
+ * The symbolId as computed from the TypeScript AST is not guaranteed to
90
+ * match the symbolId recorded in the assembly: symbolIds in the assembly are
91
+ * relative to the package's source root (`rootDir`), while the symbolId
92
+ * computed by a consumer is derived from the shipped `.d.ts` files (under
93
+ * `outDir`).
94
+ *
95
+ * `symbolIdentifier()` normalizes the path if it can determine both `rootDir`
96
+ * and `outDir`, but packages that manage their own `tsconfig.json` (via
97
+ * `jsii.tsconfig`) don't have `jsii.tsc` in their `package.json`, and their
98
+ * `tsconfig.json` is typically not published to npm. In that case the computed
99
+ * symbolId comes out as (e.g.) `lib/construct:Construct` while the assembly
100
+ * records `src/construct:Construct`, and a direct map lookup misses.
101
+ *
102
+ * To compensate, if the direct lookup fails we try to reconstruct the source
103
+ * path ourselves:
104
+ *
105
+ * - If the assembly records the `outDir` in its metadata (`tscOutDir`, written
106
+ * by newer jsii compilers, symmetric with `tscRootDir`), we re-root the path
107
+ * exactly.
108
+ * - Otherwise (e.g. `constructs@10.8.0`), we only know the `rootDir`, so we
109
+ * progressively strip leading path segments (candidate `outDir`s) from the
110
+ * computed symbolId, prepend the `rootDir`, and accept the first candidate
111
+ * that matches a symbolId recorded in the assembly.
112
+ */
113
+ export declare function resolveSymbolIdFqn(lookup: TypeLookupAssembly, symbolId: string): string | undefined;
114
+ /**
115
+ * Warn (once per unique occurrence) that a symbolId could not be resolved against an assembly
116
+ *
117
+ * If we get here, the type demonstrably lives in a package with a jsii
118
+ * assembly, so we *should* have been able to resolve it. Failing to do so
119
+ * means the translation will silently fall back to guessing target names,
120
+ * which may well be wrong. Make that failure visible.
121
+ */
122
+ export declare function reportUnresolvedSymbolId(lookup: TypeLookupAssembly, symbolId: string): void;
86
123
  /**
87
124
  * Find the jsii [sub]module that contains the given FQN
88
125
  *
@@ -41,6 +41,8 @@ exports.compressedTabletExists = compressedTabletExists;
41
41
  exports.allSnippetSources = allSnippetSources;
42
42
  exports.allTypeScriptSnippets = allTypeScriptSnippets;
43
43
  exports.findTypeLookupAssembly = findTypeLookupAssembly;
44
+ exports.resolveSymbolIdFqn = resolveSymbolIdFqn;
45
+ exports.reportUnresolvedSymbolId = reportUnresolvedSymbolId;
44
46
  exports.findContainingSubmodule = findContainingSubmodule;
45
47
  const node_fs_1 = require("node:fs");
46
48
  const fs = __importStar(require("node:fs"));
@@ -48,6 +50,7 @@ const path = __importStar(require("node:path"));
48
50
  const spec_1 = require("@jsii/spec");
49
51
  const spec = __importStar(require("@jsii/spec"));
50
52
  const fixtures_1 = require("../fixtures");
53
+ const logging = __importStar(require("../logging"));
51
54
  const extract_snippets_1 = require("../markdown/extract-snippets");
52
55
  const snippet_1 = require("../snippet");
53
56
  const snippet_dependencies_1 = require("../snippet-dependencies");
@@ -268,6 +271,97 @@ function loadLookupAssembly(directory) {
268
271
  return undefined;
269
272
  }
270
273
  }
274
+ /**
275
+ * Look up the jsii fqn for a given symbolId in a `TypeLookupAssembly`
276
+ *
277
+ * The symbolId as computed from the TypeScript AST is not guaranteed to
278
+ * match the symbolId recorded in the assembly: symbolIds in the assembly are
279
+ * relative to the package's source root (`rootDir`), while the symbolId
280
+ * computed by a consumer is derived from the shipped `.d.ts` files (under
281
+ * `outDir`).
282
+ *
283
+ * `symbolIdentifier()` normalizes the path if it can determine both `rootDir`
284
+ * and `outDir`, but packages that manage their own `tsconfig.json` (via
285
+ * `jsii.tsconfig`) don't have `jsii.tsc` in their `package.json`, and their
286
+ * `tsconfig.json` is typically not published to npm. In that case the computed
287
+ * symbolId comes out as (e.g.) `lib/construct:Construct` while the assembly
288
+ * records `src/construct:Construct`, and a direct map lookup misses.
289
+ *
290
+ * To compensate, if the direct lookup fails we try to reconstruct the source
291
+ * path ourselves:
292
+ *
293
+ * - If the assembly records the `outDir` in its metadata (`tscOutDir`, written
294
+ * by newer jsii compilers, symmetric with `tscRootDir`), we re-root the path
295
+ * exactly.
296
+ * - Otherwise (e.g. `constructs@10.8.0`), we only know the `rootDir`, so we
297
+ * progressively strip leading path segments (candidate `outDir`s) from the
298
+ * computed symbolId, prepend the `rootDir`, and accept the first candidate
299
+ * that matches a symbolId recorded in the assembly.
300
+ */
301
+ function resolveSymbolIdFqn(lookup, symbolId) {
302
+ const direct = lookup.symbolIdMap[symbolId];
303
+ if (direct !== undefined) {
304
+ return direct;
305
+ }
306
+ const metadata = lookup.assembly.metadata;
307
+ const tsc = lookup.packageJson.jsii?.tsc;
308
+ const rootDir = splitPrefix(tsc?.rootDir ?? metadata?.tscRootDir);
309
+ if (rootDir === undefined) {
310
+ return undefined;
311
+ }
312
+ const parts = symbolId.split(':');
313
+ if (parts.length !== 2) {
314
+ return undefined;
315
+ }
316
+ const [fileName, typeName] = parts;
317
+ const segments = fileName.split('/');
318
+ const outDir = splitPrefix(tsc?.outDir ?? metadata?.tscOutDir);
319
+ if (outDir !== undefined) {
320
+ // We know the exact outDir: re-root the path and do a single lookup
321
+ if (!outDir.every((seg, i) => segments[i] === seg)) {
322
+ return undefined;
323
+ }
324
+ return lookup.symbolIdMap[`${[...rootDir, ...segments.slice(outDir.length)].join('/')}:${typeName}`];
325
+ }
326
+ // The outDir is unknown: try candidate outDirs of increasing depth
327
+ for (let strip = 0; strip <= segments.length - 1; strip++) {
328
+ const found = lookup.symbolIdMap[`${[...rootDir, ...segments.slice(strip)].join('/')}:${typeName}`];
329
+ if (found !== undefined) {
330
+ return found;
331
+ }
332
+ }
333
+ return undefined;
334
+ }
335
+ /**
336
+ * Split a relative directory prefix into segments, treating '', '.' and undefined appropriately
337
+ */
338
+ function splitPrefix(dir) {
339
+ if (dir === undefined) {
340
+ return undefined;
341
+ }
342
+ return dir.split('/').filter((seg) => seg !== '' && seg !== '.');
343
+ }
344
+ /**
345
+ * Symbol ids we have already warned about, so we only warn once per unique failure
346
+ */
347
+ const REPORTED_UNRESOLVED_SYMBOL_IDS = new Set();
348
+ /**
349
+ * Warn (once per unique occurrence) that a symbolId could not be resolved against an assembly
350
+ *
351
+ * If we get here, the type demonstrably lives in a package with a jsii
352
+ * assembly, so we *should* have been able to resolve it. Failing to do so
353
+ * means the translation will silently fall back to guessing target names,
354
+ * which may well be wrong. Make that failure visible.
355
+ */
356
+ function reportUnresolvedSymbolId(lookup, symbolId) {
357
+ const key = `${lookup.assembly.name}:${symbolId}`;
358
+ if (REPORTED_UNRESOLVED_SYMBOL_IDS.has(key)) {
359
+ return;
360
+ }
361
+ REPORTED_UNRESOLVED_SYMBOL_IDS.add(key);
362
+ logging.warn(`Could not resolve symbol id ${JSON.stringify(symbolId)} against the assembly of ${JSON.stringify(lookup.assembly.name)}. Target language names for this symbol will be guessed and may be incorrect. ` +
363
+ `To fix this, rebuild ${JSON.stringify(lookup.assembly.name)} with an up-to-date jsii compiler, or report the issue to the library maintainers.`);
364
+ }
271
365
  function findPackageJsonLocation(currentPath) {
272
366
  // eslint-disable-next-line no-constant-condition
273
367
  while (true) {
@@ -1 +1 @@
1
- {"version":3,"file":"assemblies.js","sourceRoot":"","sources":["../../src/jsii/assemblies.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,wCAoBC;AAOD,sDAQC;AAOD,kDAIC;AAED,wDAEC;AASD,8CA6EC;AAED,sDA8CC;AAkBD,wDAsBC;AA2CD,0DASC;AApVD,qCAAiD;AACjD,4CAA8B;AAC9B,gDAAkC;AAClC,qCAA0F;AAC1F,iDAAmC;AACnC,0CAAwC;AACxC,mEAAqF;AACrF,wCASoB;AACpB,kEAA6E;AAC7E,sCAA+C;AAC/C,gDAAyG;AACzG,kCAA2D;AAE3D;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H,MAAM,CAAC,MAAM,CACX,uBAAuB,EACvB,IAAA,aAAM,EACJ,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,mBAAmB,IAAI,EAAE,CAAC,CAAC,GAAG,CACzE,CAAC,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,CAAU,CAC9E,CACF,CACF,CAAC;IAEF,OAAO;QACL,GAAG,OAAO;QACV,uBAAuB;KACxB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,MAAsB;IACtC,OAAO,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,IAAI,IAAA,2BAAkB,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACxF,CAAC","sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { loadAssemblyFromFile, loadAssemblyFromPath, findAssemblyFile } from '@jsii/spec';\nimport * as spec from '@jsii/spec';\nimport { fixturize } from '../fixtures';\nimport { extractTypescriptSnippetsFromMarkdown } from '../markdown/extract-snippets';\nimport {\n TypeScriptSnippet,\n updateParameters,\n SnippetParameters,\n ApiLocation,\n parseMetadataLine,\n CompilationDependency,\n INITIALIZER_METHOD_NAME,\n typeScriptSnippetFromVisibleSource,\n} from '../snippet';\nimport { resolveDependenciesFromPackageJson } from '../snippet-dependencies';\nimport { enforcesStrictMode } from '../strict';\nimport { LanguageTablet, DEFAULT_TABLET_NAME, DEFAULT_TABLET_NAME_COMPRESSED } from '../tablets/tablets';\nimport { fmap, mkDict, pathExists, sortBy } from '../util';\n\n/**\n * The Assembly features jsii-rosetta supports\n *\n * In actual fact, Rosetta doesn't do much with the Assembly, just crawl all\n * API documentations, so basically most new features would be supported... but\n * we technically should advertise a known list here anyway since we don't\n * know what future extension are going to be.\n */\nexport const SUPPORTED_ASSEMBLY_FEATURES: spec.JsiiFeature[] = ['intersection-types', 'class-covariant-overrides'];\n\n/**\n * The JSDoc tag users can use to associate non-visible metadata with an example\n *\n * In a Markdown section, metadata goes after the code block fence, where it will\n * be attached to the example but invisible.\n *\n * ```ts metadata=goes here\n *\n * But in doc comments, '@example' already delineates the example, and any metadata\n * in there added by the '///' tags becomes part of the visible code (there is no\n * place to put hidden information).\n *\n * We introduce the '@exampleMetadata' tag to put that additional information.\n */\nexport const EXAMPLE_METADATA_JSDOCTAG = 'exampleMetadata';\n\ninterface RosettaPackageJson extends spec.PackageJson {\n readonly jsiiRosetta?: {\n readonly strict?: boolean;\n readonly exampleDependencies?: Record<string, string>;\n };\n}\n\nexport interface LoadedAssembly {\n readonly assembly: spec.Assembly;\n readonly directory: string;\n readonly packageJson?: RosettaPackageJson;\n}\n\n/**\n * Load assemblies by filename or directory\n */\nexport function loadAssemblies(\n assemblyLocations: readonly string[],\n validateAssemblies: boolean,\n): readonly LoadedAssembly[] {\n return assemblyLocations.map(loadAssembly);\n\n function loadAssembly(location: string): LoadedAssembly {\n const stat = fs.statSync(location);\n if (stat.isDirectory()) {\n return loadAssembly(findAssemblyFile(location));\n }\n\n const directory = path.dirname(location);\n const pjLocation = path.join(directory, 'package.json');\n\n const assembly = loadAssemblyFromFile(location, validateAssemblies, SUPPORTED_ASSEMBLY_FEATURES);\n const packageJson = fs.existsSync(pjLocation) ? JSON.parse(fs.readFileSync(pjLocation, 'utf-8')) : undefined;\n\n return { assembly, directory, packageJson };\n }\n}\n\n/**\n * Load the default tablets for every assembly, if available\n *\n * Returns a map of { directory -> tablet }.\n */\nexport async function loadAllDefaultTablets(asms: readonly LoadedAssembly[]): Promise<Record<string, LanguageTablet>> {\n return mkDict(\n await Promise.all(\n asms.map(\n async (a) => [a.directory, await LanguageTablet.fromOptionalFile(guessTabletLocation(a.directory))] as const,\n ),\n ),\n );\n}\n\n/**\n * Returns the location of the tablet file, either .jsii.tabl.json or .jsii.tabl.json.gz.\n * Assumes that a tablet exists in the directory and if not, the ensuing behavior is\n * handled by the caller of this function.\n */\nexport function guessTabletLocation(directory: string) {\n return compressedTabletExists(directory)\n ? path.join(directory, DEFAULT_TABLET_NAME_COMPRESSED)\n : path.join(directory, DEFAULT_TABLET_NAME);\n}\n\nexport function compressedTabletExists(directory: string) {\n return fs.existsSync(path.join(directory, DEFAULT_TABLET_NAME_COMPRESSED));\n}\n\nexport type AssemblySnippetSource =\n | { type: 'markdown'; markdown: string; location: ApiLocation }\n | { type: 'example'; source: string; metadata?: { [key: string]: string }; location: ApiLocation };\n\n/**\n * Return all markdown and example snippets from the given assembly\n */\nexport function allSnippetSources(assembly: spec.Assembly): AssemblySnippetSource[] {\n const ret: AssemblySnippetSource[] = [];\n\n if (assembly.readme) {\n ret.push({\n type: 'markdown',\n markdown: assembly.readme.markdown,\n location: { api: 'moduleReadme', moduleFqn: assembly.name },\n });\n }\n\n for (const [submoduleFqn, submodule] of Object.entries(assembly.submodules ?? {})) {\n if (submodule.readme) {\n ret.push({\n type: 'markdown',\n markdown: submodule.readme.markdown,\n location: { api: 'moduleReadme', moduleFqn: submoduleFqn },\n });\n }\n }\n\n if (assembly.types) {\n for (const type of Object.values(assembly.types)) {\n emitDocs(type.docs, { api: 'type', fqn: type.fqn });\n\n if (spec.isEnumType(type)) {\n for (const m of type.members) emitDocs(m.docs, { api: 'member', fqn: type.fqn, memberName: m.name });\n }\n if (spec.isClassType(type)) {\n emitDocsForCallable(type.initializer, type.fqn);\n }\n if (spec.isClassOrInterfaceType(type)) {\n for (const m of type.methods ?? []) emitDocsForCallable(m, type.fqn, m.name);\n for (const m of type.properties ?? []) emitDocs(m.docs, { api: 'member', fqn: type.fqn, memberName: m.name });\n }\n }\n }\n\n return ret;\n\n function emitDocsForCallable(callable: spec.Callable | undefined, fqn: string, memberName?: string) {\n if (!callable) {\n return;\n }\n emitDocs(callable.docs, memberName ? { api: 'member', fqn, memberName } : { api: 'initializer', fqn });\n\n for (const parameter of callable.parameters ?? []) {\n emitDocs(parameter.docs, {\n api: 'parameter',\n fqn: fqn,\n methodName: memberName ?? INITIALIZER_METHOD_NAME,\n parameterName: parameter.name,\n });\n }\n }\n\n function emitDocs(docs: spec.Docs | undefined, location: ApiLocation) {\n if (!docs) {\n return;\n }\n\n if (docs.remarks) {\n ret.push({\n type: 'markdown',\n markdown: docs.remarks,\n location,\n });\n }\n if (docs.example) {\n ret.push({\n type: 'example',\n source: docs.example,\n metadata: fmap(docs.custom?.[EXAMPLE_METADATA_JSDOCTAG], parseMetadataLine),\n location,\n });\n }\n }\n}\n\nexport async function allTypeScriptSnippets(\n assemblies: readonly LoadedAssembly[],\n loose = false,\n): Promise<TypeScriptSnippet[]> {\n const sources = assemblies\n .flatMap((loaded) => allSnippetSources(loaded.assembly).map((source) => ({ source, loaded })))\n .flatMap(({ source, loaded }) => {\n switch (source.type) {\n case 'example':\n return [\n {\n snippet: updateParameters(\n typeScriptSnippetFromVisibleSource(\n source.source,\n { api: source.location, field: { field: 'example' } },\n isStrict(loaded),\n ),\n source.metadata ?? {},\n ),\n loaded,\n },\n ];\n case 'markdown':\n return extractTypescriptSnippetsFromMarkdown(source.markdown, source.location, isStrict(loaded)).map(\n (snippet) => ({ snippet, loaded }),\n );\n }\n });\n\n const fixtures = [];\n for (let { snippet, loaded } of sources) {\n const isInfused = snippet.parameters?.infused != null;\n\n // Ignore fixturization errors if requested on this command, or if the snippet was infused\n const ignoreFixtureErrors = loose || isInfused;\n\n // Also if the snippet was infused: switch off 'strict' mode if it was set\n if (isInfused) {\n snippet = { ...snippet, strict: false };\n }\n\n snippet = await withDependencies(loaded, withProjectDirectory(loaded.directory, snippet));\n fixtures.push(fixturize(snippet, ignoreFixtureErrors));\n }\n\n return fixtures;\n}\n\nexport interface TypeLookupAssembly {\n readonly packageJson: any;\n readonly assembly: spec.Assembly;\n readonly directory: string;\n readonly symbolIdMap: Record<string, string>;\n}\n\nconst MAX_ASM_CACHE = 3;\nconst ASM_CACHE: TypeLookupAssembly[] = [];\n\n/**\n * Recursively searches for a .jsii file in the directory.\n * When file is found, checks cache to see if we already\n * stored the assembly in memory. If not, we synchronously\n * load the assembly into memory.\n */\nexport function findTypeLookupAssembly(startingDirectory: string): TypeLookupAssembly | undefined {\n const pjLocation = findPackageJsonLocation(path.resolve(startingDirectory));\n if (!pjLocation) {\n return undefined;\n }\n const directory = path.dirname(pjLocation);\n\n const fromCache = ASM_CACHE.find((c) => c.directory === directory);\n if (fromCache) {\n return fromCache;\n }\n\n const loaded = loadLookupAssembly(directory);\n if (!loaded) {\n return undefined;\n }\n\n while (ASM_CACHE.length >= MAX_ASM_CACHE) {\n ASM_CACHE.pop();\n }\n ASM_CACHE.unshift(loaded);\n return loaded;\n}\n\nfunction loadLookupAssembly(directory: string): TypeLookupAssembly | undefined {\n try {\n const packageJson = JSON.parse(fs.readFileSync(path.join(directory, 'package.json'), 'utf-8'));\n const assembly: spec.Assembly = loadAssemblyFromPath(directory, false, SUPPORTED_ASSEMBLY_FEATURES);\n const symbolIdMap = mkDict([\n ...Object.values(assembly.types ?? {}).map((type) => [type.symbolId ?? '', type.fqn] as const),\n ...Object.entries(assembly.submodules ?? {}).map(([fqn, mod]) => [mod.symbolId ?? '', fqn] as const),\n ]);\n\n return {\n packageJson,\n assembly,\n directory,\n symbolIdMap,\n };\n } catch {\n return undefined;\n }\n}\n\nfunction findPackageJsonLocation(currentPath: string): string | undefined {\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const candidate = path.join(currentPath, 'package.json');\n if (fs.existsSync(candidate)) {\n return candidate;\n }\n\n const parentPath = path.resolve(currentPath, '..');\n if (parentPath === currentPath) {\n return undefined;\n }\n currentPath = parentPath;\n }\n}\n\n/**\n * Find the jsii [sub]module that contains the given FQN\n *\n * @returns `undefined` if the type is a member of the assembly root.\n */\nexport function findContainingSubmodule(assembly: spec.Assembly, fqn: string): string | undefined {\n const submoduleNames = Object.keys(assembly.submodules ?? {});\n sortBy(submoduleNames, (s) => [-s.length]); // Longest first\n for (const s of submoduleNames) {\n if (fqn.startsWith(`${s}.`)) {\n return s;\n }\n }\n return undefined;\n}\n\nfunction withProjectDirectory(dir: string, snippet: TypeScriptSnippet) {\n return updateParameters(snippet, {\n [SnippetParameters.$PROJECT_DIRECTORY]: dir,\n });\n}\n\n/**\n * Return a TypeScript snippet with dependencies added\n *\n * The dependencies will be taken from the package.json, and will consist of:\n *\n * - The package itself\n * - The package's dependencies and peerDependencies (but NOT devDependencies). Will\n * symlink to the files on disk.\n * - Any additional dependencies declared in `jsiiRosetta.exampleDependencies`.\n */\nasync function withDependencies(asm: LoadedAssembly, snippet: TypeScriptSnippet): Promise<TypeScriptSnippet> {\n const compilationDependencies: Record<string, CompilationDependency> = {};\n\n if (await pathExists(path.join(asm.directory, 'package.json'))) {\n compilationDependencies[asm.assembly.name] = {\n type: 'concrete',\n resolvedDirectory: await fsPromises.realpath(asm.directory),\n };\n }\n\n Object.assign(compilationDependencies, await resolveDependenciesFromPackageJson(asm.packageJson, asm.directory));\n\n Object.assign(\n compilationDependencies,\n mkDict(\n Object.entries(asm.packageJson?.jsiiRosetta?.exampleDependencies ?? {}).map(\n ([name, versionRange]) => [name, { type: 'symbolic', versionRange }] as const,\n ),\n ),\n );\n\n return {\n ...snippet,\n compilationDependencies,\n };\n}\n\n/**\n * Whether samples in the assembly should be treated as strict\n *\n * True if the strict flag is found in the package.json (modern) or the assembly itself (legacy).\n */\nfunction isStrict(loaded: LoadedAssembly) {\n return loaded.packageJson?.jsiiRosetta?.strict ?? enforcesStrictMode(loaded.assembly);\n}\n"]}
1
+ {"version":3,"file":"assemblies.js","sourceRoot":"","sources":["../../src/jsii/assemblies.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,wCAoBC;AAOD,sDAQC;AAOD,kDAIC;AAED,wDAEC;AASD,8CA6EC;AAED,sDA8CC;AAkBD,wDAsBC;AAiDD,gDAqCC;AAyBD,4DAcC;AAuBD,0DASC;AA9bD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AA,iBAAU,EAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC;QAC/D,uBAAuB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG;YAC3C,IAAI,EAAE,UAAU;YAChB,iBAAiB,EAAE,MAAM,kBAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC;SAC5D,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,uBAAuB,EAAE,MAAM,IAAA,yDAAkC,EAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IAEjH,MAAM,CAAC,MAAM,CACX,uBAAuB,EACvB,IAAA,aAAM,EACJ,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,mBAAmB,IAAI,EAAE,CAAC,CAAC,GAAG,CACzE,CAAC,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,CAAU,CAC9E,CACF,CACF,CAAC;IAEF,OAAO;QACL,GAAG,OAAO;QACV,uBAAuB;KACxB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,MAAsB;IACtC,OAAO,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,IAAI,IAAA,2BAAkB,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACxF,CAAC","sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { loadAssemblyFromFile, loadAssemblyFromPath, findAssemblyFile } from '@jsii/spec';\nimport * as spec from '@jsii/spec';\nimport { fixturize } from '../fixtures';\nimport * as logging from '../logging';\nimport { extractTypescriptSnippetsFromMarkdown } from '../markdown/extract-snippets';\nimport {\n TypeScriptSnippet,\n updateParameters,\n SnippetParameters,\n ApiLocation,\n parseMetadataLine,\n CompilationDependency,\n INITIALIZER_METHOD_NAME,\n typeScriptSnippetFromVisibleSource,\n} from '../snippet';\nimport { resolveDependenciesFromPackageJson } from '../snippet-dependencies';\nimport { enforcesStrictMode } from '../strict';\nimport { LanguageTablet, DEFAULT_TABLET_NAME, DEFAULT_TABLET_NAME_COMPRESSED } from '../tablets/tablets';\nimport { fmap, mkDict, pathExists, sortBy } from '../util';\n\n/**\n * The Assembly features jsii-rosetta supports\n *\n * In actual fact, Rosetta doesn't do much with the Assembly, just crawl all\n * API documentations, so basically most new features would be supported... but\n * we technically should advertise a known list here anyway since we don't\n * know what future extension are going to be.\n */\nexport const SUPPORTED_ASSEMBLY_FEATURES: spec.JsiiFeature[] = ['intersection-types', 'class-covariant-overrides'];\n\n/**\n * The JSDoc tag users can use to associate non-visible metadata with an example\n *\n * In a Markdown section, metadata goes after the code block fence, where it will\n * be attached to the example but invisible.\n *\n * ```ts metadata=goes here\n *\n * But in doc comments, '@example' already delineates the example, and any metadata\n * in there added by the '///' tags becomes part of the visible code (there is no\n * place to put hidden information).\n *\n * We introduce the '@exampleMetadata' tag to put that additional information.\n */\nexport const EXAMPLE_METADATA_JSDOCTAG = 'exampleMetadata';\n\ninterface RosettaPackageJson extends spec.PackageJson {\n readonly jsiiRosetta?: {\n readonly strict?: boolean;\n readonly exampleDependencies?: Record<string, string>;\n };\n}\n\nexport interface LoadedAssembly {\n readonly assembly: spec.Assembly;\n readonly directory: string;\n readonly packageJson?: RosettaPackageJson;\n}\n\n/**\n * Load assemblies by filename or directory\n */\nexport function loadAssemblies(\n assemblyLocations: readonly string[],\n validateAssemblies: boolean,\n): readonly LoadedAssembly[] {\n return assemblyLocations.map(loadAssembly);\n\n function loadAssembly(location: string): LoadedAssembly {\n const stat = fs.statSync(location);\n if (stat.isDirectory()) {\n return loadAssembly(findAssemblyFile(location));\n }\n\n const directory = path.dirname(location);\n const pjLocation = path.join(directory, 'package.json');\n\n const assembly = loadAssemblyFromFile(location, validateAssemblies, SUPPORTED_ASSEMBLY_FEATURES);\n const packageJson = fs.existsSync(pjLocation) ? JSON.parse(fs.readFileSync(pjLocation, 'utf-8')) : undefined;\n\n return { assembly, directory, packageJson };\n }\n}\n\n/**\n * Load the default tablets for every assembly, if available\n *\n * Returns a map of { directory -> tablet }.\n */\nexport async function loadAllDefaultTablets(asms: readonly LoadedAssembly[]): Promise<Record<string, LanguageTablet>> {\n return mkDict(\n await Promise.all(\n asms.map(\n async (a) => [a.directory, await LanguageTablet.fromOptionalFile(guessTabletLocation(a.directory))] as const,\n ),\n ),\n );\n}\n\n/**\n * Returns the location of the tablet file, either .jsii.tabl.json or .jsii.tabl.json.gz.\n * Assumes that a tablet exists in the directory and if not, the ensuing behavior is\n * handled by the caller of this function.\n */\nexport function guessTabletLocation(directory: string) {\n return compressedTabletExists(directory)\n ? path.join(directory, DEFAULT_TABLET_NAME_COMPRESSED)\n : path.join(directory, DEFAULT_TABLET_NAME);\n}\n\nexport function compressedTabletExists(directory: string) {\n return fs.existsSync(path.join(directory, DEFAULT_TABLET_NAME_COMPRESSED));\n}\n\nexport type AssemblySnippetSource =\n | { type: 'markdown'; markdown: string; location: ApiLocation }\n | { type: 'example'; source: string; metadata?: { [key: string]: string }; location: ApiLocation };\n\n/**\n * Return all markdown and example snippets from the given assembly\n */\nexport function allSnippetSources(assembly: spec.Assembly): AssemblySnippetSource[] {\n const ret: AssemblySnippetSource[] = [];\n\n if (assembly.readme) {\n ret.push({\n type: 'markdown',\n markdown: assembly.readme.markdown,\n location: { api: 'moduleReadme', moduleFqn: assembly.name },\n });\n }\n\n for (const [submoduleFqn, submodule] of Object.entries(assembly.submodules ?? {})) {\n if (submodule.readme) {\n ret.push({\n type: 'markdown',\n markdown: submodule.readme.markdown,\n location: { api: 'moduleReadme', moduleFqn: submoduleFqn },\n });\n }\n }\n\n if (assembly.types) {\n for (const type of Object.values(assembly.types)) {\n emitDocs(type.docs, { api: 'type', fqn: type.fqn });\n\n if (spec.isEnumType(type)) {\n for (const m of type.members) emitDocs(m.docs, { api: 'member', fqn: type.fqn, memberName: m.name });\n }\n if (spec.isClassType(type)) {\n emitDocsForCallable(type.initializer, type.fqn);\n }\n if (spec.isClassOrInterfaceType(type)) {\n for (const m of type.methods ?? []) emitDocsForCallable(m, type.fqn, m.name);\n for (const m of type.properties ?? []) emitDocs(m.docs, { api: 'member', fqn: type.fqn, memberName: m.name });\n }\n }\n }\n\n return ret;\n\n function emitDocsForCallable(callable: spec.Callable | undefined, fqn: string, memberName?: string) {\n if (!callable) {\n return;\n }\n emitDocs(callable.docs, memberName ? { api: 'member', fqn, memberName } : { api: 'initializer', fqn });\n\n for (const parameter of callable.parameters ?? []) {\n emitDocs(parameter.docs, {\n api: 'parameter',\n fqn: fqn,\n methodName: memberName ?? INITIALIZER_METHOD_NAME,\n parameterName: parameter.name,\n });\n }\n }\n\n function emitDocs(docs: spec.Docs | undefined, location: ApiLocation) {\n if (!docs) {\n return;\n }\n\n if (docs.remarks) {\n ret.push({\n type: 'markdown',\n markdown: docs.remarks,\n location,\n });\n }\n if (docs.example) {\n ret.push({\n type: 'example',\n source: docs.example,\n metadata: fmap(docs.custom?.[EXAMPLE_METADATA_JSDOCTAG], parseMetadataLine),\n location,\n });\n }\n }\n}\n\nexport async function allTypeScriptSnippets(\n assemblies: readonly LoadedAssembly[],\n loose = false,\n): Promise<TypeScriptSnippet[]> {\n const sources = assemblies\n .flatMap((loaded) => allSnippetSources(loaded.assembly).map((source) => ({ source, loaded })))\n .flatMap(({ source, loaded }) => {\n switch (source.type) {\n case 'example':\n return [\n {\n snippet: updateParameters(\n typeScriptSnippetFromVisibleSource(\n source.source,\n { api: source.location, field: { field: 'example' } },\n isStrict(loaded),\n ),\n source.metadata ?? {},\n ),\n loaded,\n },\n ];\n case 'markdown':\n return extractTypescriptSnippetsFromMarkdown(source.markdown, source.location, isStrict(loaded)).map(\n (snippet) => ({ snippet, loaded }),\n );\n }\n });\n\n const fixtures = [];\n for (let { snippet, loaded } of sources) {\n const isInfused = snippet.parameters?.infused != null;\n\n // Ignore fixturization errors if requested on this command, or if the snippet was infused\n const ignoreFixtureErrors = loose || isInfused;\n\n // Also if the snippet was infused: switch off 'strict' mode if it was set\n if (isInfused) {\n snippet = { ...snippet, strict: false };\n }\n\n snippet = await withDependencies(loaded, withProjectDirectory(loaded.directory, snippet));\n fixtures.push(fixturize(snippet, ignoreFixtureErrors));\n }\n\n return fixtures;\n}\n\nexport interface TypeLookupAssembly {\n readonly packageJson: any;\n readonly assembly: spec.Assembly;\n readonly directory: string;\n readonly symbolIdMap: Record<string, string>;\n}\n\nconst MAX_ASM_CACHE = 3;\nconst ASM_CACHE: TypeLookupAssembly[] = [];\n\n/**\n * Recursively searches for a .jsii file in the directory.\n * When file is found, checks cache to see if we already\n * stored the assembly in memory. If not, we synchronously\n * load the assembly into memory.\n */\nexport function findTypeLookupAssembly(startingDirectory: string): TypeLookupAssembly | undefined {\n const pjLocation = findPackageJsonLocation(path.resolve(startingDirectory));\n if (!pjLocation) {\n return undefined;\n }\n const directory = path.dirname(pjLocation);\n\n const fromCache = ASM_CACHE.find((c) => c.directory === directory);\n if (fromCache) {\n return fromCache;\n }\n\n const loaded = loadLookupAssembly(directory);\n if (!loaded) {\n return undefined;\n }\n\n while (ASM_CACHE.length >= MAX_ASM_CACHE) {\n ASM_CACHE.pop();\n }\n ASM_CACHE.unshift(loaded);\n return loaded;\n}\n\nfunction loadLookupAssembly(directory: string): TypeLookupAssembly | undefined {\n try {\n const packageJson = JSON.parse(fs.readFileSync(path.join(directory, 'package.json'), 'utf-8'));\n const assembly: spec.Assembly = loadAssemblyFromPath(directory, false, SUPPORTED_ASSEMBLY_FEATURES);\n const symbolIdMap = mkDict([\n ...Object.values(assembly.types ?? {}).map((type) => [type.symbolId ?? '', type.fqn] as const),\n ...Object.entries(assembly.submodules ?? {}).map(([fqn, mod]) => [mod.symbolId ?? '', fqn] as const),\n ]);\n\n return {\n packageJson,\n assembly,\n directory,\n symbolIdMap,\n };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Look up the jsii fqn for a given symbolId in a `TypeLookupAssembly`\n *\n * The symbolId as computed from the TypeScript AST is not guaranteed to\n * match the symbolId recorded in the assembly: symbolIds in the assembly are\n * relative to the package's source root (`rootDir`), while the symbolId\n * computed by a consumer is derived from the shipped `.d.ts` files (under\n * `outDir`).\n *\n * `symbolIdentifier()` normalizes the path if it can determine both `rootDir`\n * and `outDir`, but packages that manage their own `tsconfig.json` (via\n * `jsii.tsconfig`) don't have `jsii.tsc` in their `package.json`, and their\n * `tsconfig.json` is typically not published to npm. In that case the computed\n * symbolId comes out as (e.g.) `lib/construct:Construct` while the assembly\n * records `src/construct:Construct`, and a direct map lookup misses.\n *\n * To compensate, if the direct lookup fails we try to reconstruct the source\n * path ourselves:\n *\n * - If the assembly records the `outDir` in its metadata (`tscOutDir`, written\n * by newer jsii compilers, symmetric with `tscRootDir`), we re-root the path\n * exactly.\n * - Otherwise (e.g. `constructs@10.8.0`), we only know the `rootDir`, so we\n * progressively strip leading path segments (candidate `outDir`s) from the\n * computed symbolId, prepend the `rootDir`, and accept the first candidate\n * that matches a symbolId recorded in the assembly.\n */\nexport function resolveSymbolIdFqn(lookup: TypeLookupAssembly, symbolId: string): string | undefined {\n const direct = lookup.symbolIdMap[symbolId];\n if (direct !== undefined) {\n return direct;\n }\n\n const metadata = lookup.assembly.metadata as { tscRootDir?: string; tscOutDir?: string } | undefined;\n const tsc = lookup.packageJson.jsii?.tsc;\n const rootDir = splitPrefix(tsc?.rootDir ?? metadata?.tscRootDir);\n if (rootDir === undefined) {\n return undefined;\n }\n\n const parts = symbolId.split(':');\n if (parts.length !== 2) {\n return undefined;\n }\n const [fileName, typeName] = parts;\n const segments = fileName.split('/');\n\n const outDir = splitPrefix(tsc?.outDir ?? metadata?.tscOutDir);\n if (outDir !== undefined) {\n // We know the exact outDir: re-root the path and do a single lookup\n if (!outDir.every((seg, i) => segments[i] === seg)) {\n return undefined;\n }\n return lookup.symbolIdMap[`${[...rootDir, ...segments.slice(outDir.length)].join('/')}:${typeName}`];\n }\n\n // The outDir is unknown: try candidate outDirs of increasing depth\n for (let strip = 0; strip <= segments.length - 1; strip++) {\n const found = lookup.symbolIdMap[`${[...rootDir, ...segments.slice(strip)].join('/')}:${typeName}`];\n if (found !== undefined) {\n return found;\n }\n }\n return undefined;\n}\n\n/**\n * Split a relative directory prefix into segments, treating '', '.' and undefined appropriately\n */\nfunction splitPrefix(dir: string | undefined): string[] | undefined {\n if (dir === undefined) {\n return undefined;\n }\n return dir.split('/').filter((seg) => seg !== '' && seg !== '.');\n}\n\n/**\n * Symbol ids we have already warned about, so we only warn once per unique failure\n */\nconst REPORTED_UNRESOLVED_SYMBOL_IDS = new Set<string>();\n\n/**\n * Warn (once per unique occurrence) that a symbolId could not be resolved against an assembly\n *\n * If we get here, the type demonstrably lives in a package with a jsii\n * assembly, so we *should* have been able to resolve it. Failing to do so\n * means the translation will silently fall back to guessing target names,\n * which may well be wrong. Make that failure visible.\n */\nexport function reportUnresolvedSymbolId(lookup: TypeLookupAssembly, symbolId: string) {\n const key = `${lookup.assembly.name}:${symbolId}`;\n if (REPORTED_UNRESOLVED_SYMBOL_IDS.has(key)) {\n return;\n }\n REPORTED_UNRESOLVED_SYMBOL_IDS.add(key);\n logging.warn(\n `Could not resolve symbol id ${JSON.stringify(symbolId)} against the assembly of ${JSON.stringify(\n lookup.assembly.name,\n )}. Target language names for this symbol will be guessed and may be incorrect. ` +\n `To fix this, rebuild ${JSON.stringify(\n lookup.assembly.name,\n )} with an up-to-date jsii compiler, or report the issue to the library maintainers.`,\n );\n}\n\nfunction findPackageJsonLocation(currentPath: string): string | undefined {\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const candidate = path.join(currentPath, 'package.json');\n if (fs.existsSync(candidate)) {\n return candidate;\n }\n\n const parentPath = path.resolve(currentPath, '..');\n if (parentPath === currentPath) {\n return undefined;\n }\n currentPath = parentPath;\n }\n}\n\n/**\n * Find the jsii [sub]module that contains the given FQN\n *\n * @returns `undefined` if the type is a member of the assembly root.\n */\nexport function findContainingSubmodule(assembly: spec.Assembly, fqn: string): string | undefined {\n const submoduleNames = Object.keys(assembly.submodules ?? {});\n sortBy(submoduleNames, (s) => [-s.length]); // Longest first\n for (const s of submoduleNames) {\n if (fqn.startsWith(`${s}.`)) {\n return s;\n }\n }\n return undefined;\n}\n\nfunction withProjectDirectory(dir: string, snippet: TypeScriptSnippet) {\n return updateParameters(snippet, {\n [SnippetParameters.$PROJECT_DIRECTORY]: dir,\n });\n}\n\n/**\n * Return a TypeScript snippet with dependencies added\n *\n * The dependencies will be taken from the package.json, and will consist of:\n *\n * - The package itself\n * - The package's dependencies and peerDependencies (but NOT devDependencies). Will\n * symlink to the files on disk.\n * - Any additional dependencies declared in `jsiiRosetta.exampleDependencies`.\n */\nasync function withDependencies(asm: LoadedAssembly, snippet: TypeScriptSnippet): Promise<TypeScriptSnippet> {\n const compilationDependencies: Record<string, CompilationDependency> = {};\n\n if (await pathExists(path.join(asm.directory, 'package.json'))) {\n compilationDependencies[asm.assembly.name] = {\n type: 'concrete',\n resolvedDirectory: await fsPromises.realpath(asm.directory),\n };\n }\n\n Object.assign(compilationDependencies, await resolveDependenciesFromPackageJson(asm.packageJson, asm.directory));\n\n Object.assign(\n compilationDependencies,\n mkDict(\n Object.entries(asm.packageJson?.jsiiRosetta?.exampleDependencies ?? {}).map(\n ([name, versionRange]) => [name, { type: 'symbolic', versionRange }] as const,\n ),\n ),\n );\n\n return {\n ...snippet,\n compilationDependencies,\n };\n}\n\n/**\n * Whether samples in the assembly should be treated as strict\n *\n * True if the strict flag is found in the package.json (modern) or the assembly itself (legacy).\n */\nfunction isStrict(loaded: LoadedAssembly) {\n return loaded.packageJson?.jsiiRosetta?.strict ?? enforcesStrictMode(loaded.assembly);\n}\n"]}
@@ -193,7 +193,7 @@ function lookupJsiiSymbol(typeChecker, sym) {
193
193
  // This is a module.
194
194
  const sourceAssembly = (0, assemblies_1.findTypeLookupAssembly)(decl.fileName);
195
195
  return (0, util_1.fmap)(sourceAssembly, (asm) => ({
196
- fqn: (0, util_1.fmap)((0, common_1.symbolIdentifier)(typeChecker, sym, (0, util_1.fmap)(sourceAssembly, (sa) => ({ assembly: sa.assembly }))), (symbolId) => sourceAssembly?.symbolIdMap[symbolId]) ?? sourceAssembly?.assembly.name,
196
+ fqn: (0, util_1.fmap)((0, common_1.symbolIdentifier)(typeChecker, sym, (0, util_1.fmap)(sourceAssembly, (sa) => ({ assembly: sa.assembly }))), (symbolId) => (0, util_1.fmap)(sourceAssembly, (sa) => (0, assemblies_1.resolveSymbolIdFqn)(sa, symbolId))) ?? sourceAssembly?.assembly.name,
197
197
  sourceAssembly: asm,
198
198
  symbolType: 'module',
199
199
  }));
@@ -216,14 +216,23 @@ function lookupJsiiSymbol(typeChecker, sym) {
216
216
  return undefined;
217
217
  }
218
218
  return (0, util_1.fmap)(/([^#]*)(#.*)?/.exec(symbolId), ([, typeSymbolId, memberFragment]) => {
219
+ const fqn = (0, util_1.fmap)(sourceAssembly, (sa) => (0, assemblies_1.resolveSymbolIdFqn)(sa, typeSymbolId));
220
+ if (fqn === undefined) {
221
+ // The symbol lives in a package that demonstrably has a jsii assembly,
222
+ // yet we cannot resolve it. Warn user about guessed target names.
223
+ if (sourceAssembly) {
224
+ (0, assemblies_1.reportUnresolvedSymbolId)(sourceAssembly, typeSymbolId);
225
+ }
226
+ return undefined;
227
+ }
219
228
  if (memberFragment) {
220
- return (0, util_1.fmap)(sourceAssembly?.symbolIdMap[typeSymbolId], (fqn) => ({
229
+ return {
221
230
  fqn: `${fqn}${memberFragment}`,
222
231
  sourceAssembly,
223
232
  symbolType: 'member',
224
- }));
233
+ };
225
234
  }
226
- return (0, util_1.fmap)(sourceAssembly?.symbolIdMap[typeSymbolId], (fqn) => ({ fqn, sourceAssembly, symbolType: 'type' }));
235
+ return { fqn, sourceAssembly, symbolType: 'type' };
227
236
  });
228
237
  }
229
238
  function is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K,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import * as spec from '@jsii/spec';\nimport { symbolIdentifier } from 'jsii/common';\nimport * as ts from 'typescript';\n\nimport { findTypeLookupAssembly, TypeLookupAssembly } from './assemblies';\nimport { ObjectLiteralStruct } from './jsii-types';\nimport { AstRenderer } from '../renderer';\nimport { typeContainsUndefined } from '../typescript/types';\nimport { fmap } from '../util';\n\nexport function isNamedLikeStruct(name: string) {\n // Start with an I and another uppercase character\n return !/^I[A-Z]/.test(name);\n}\n\nexport function analyzeStructType(typeChecker: ts.TypeChecker, type: ts.Type): ObjectLiteralStruct | false {\n if (\n !type.isClassOrInterface() ||\n !hasAllFlags(type.objectFlags, ts.ObjectFlags.Interface) ||\n !isNamedLikeStruct(type.symbol.name)\n ) {\n return false;\n }\n\n const jsiiSym = lookupJsiiSymbol(typeChecker, type.symbol);\n if (jsiiSym) {\n return { kind: 'struct', type, jsiiSym };\n }\n\n return { kind: 'local-struct', type };\n}\n\n/**\n * Whether the given type is a protocol AND comes from jsii\n *\n * - Protocol: a TypeScript interface that is *not* a \"struct\" type.\n * A.k.a. \"behavioral interface\".\n * - From jsii: whether the interface type is defined in and exported\n * via a jsii assembly. There can be literal interfaces defined\n * in an example, and they will not be mangled in the same way\n * as a jsii interface would be.\n *\n *\n * Examples:\n *\n * ```ts\n * // isJsiiProtocolType() -> false: not a protocol\n * interface Banana {\n * readonly arc: number;\n * }\n *\n * // isJsiiProtocolType() -> might be true: depends on whether it was defined\n * // in a jsii assembly.\n * interface IHello {\n * sayIt(): void;\n * }\n *\n * // isJsiiProtocolType() -> false: declared to not be a protocol, even though\n * // it has the naming scheme of one\n * /**\n * * @struct\n * * /\n * interface IPAddress {\n * readonly octets: number[];\n * }\n * ```\n */\nexport function isJsiiProtocolType(typeChecker: ts.TypeChecker, type: ts.Type): boolean | undefined {\n if (!type.isClassOrInterface() || !hasAllFlags(type.objectFlags, ts.ObjectFlags.Interface)) {\n return false;\n }\n\n const sym = lookupJsiiSymbol(typeChecker, type.symbol);\n if (!sym) {\n return false;\n }\n\n if (!sym.sourceAssembly) {\n // No source assembly, so this is a 'fake-from-jsii' type\n return !isNamedLikeStruct(type.symbol.name);\n }\n\n const jsiiType = resolveJsiiSymbolType(sym);\n return spec.isInterfaceType(jsiiType) && !jsiiType.datatype;\n}\n\nexport function hasAllFlags<A extends number>(flags: A, test: A) {\n // tslint:disable-next-line:no-bitwise\n return test !== 0 && (flags & test) === test;\n}\n\nexport function hasAnyFlag<A extends number>(flags: A, test: A) {\n // tslint:disable-next-line:no-bitwise\n return test !== 0 && (flags & test) !== 0;\n}\n\nexport interface StructProperty {\n name: string;\n type: ts.Type | undefined;\n questionMark: boolean;\n}\n\nexport function propertiesOfStruct(type: ts.Type, context: AstRenderer<any>): StructProperty[] {\n return type.isClassOrInterface()\n ? type.getProperties().map((s) => {\n let propType;\n let questionMark = false;\n\n const propSymbol = type.getProperty(s.name)!;\n const symbolDecl = propSymbol.valueDeclaration ?? propSymbol.declarations![0];\n if (ts.isPropertyDeclaration(symbolDecl) || ts.isPropertySignature(symbolDecl)) {\n questionMark = symbolDecl.questionToken !== undefined;\n propType = symbolDecl.type && context.typeOfType(symbolDecl.type);\n }\n\n return {\n name: s.name,\n type: propType,\n questionMark,\n };\n })\n : [];\n}\n\nexport function structPropertyAcceptsUndefined(prop: StructProperty): boolean {\n return prop.questionMark || (!!prop.type && typeContainsUndefined(prop.type));\n}\n\n/**\n * A TypeScript symbol resolved to its jsii type\n */\nexport interface JsiiSymbol {\n /**\n * FQN of the symbol\n *\n * Is either the FQN of a type (for a type). For a membr, the FQN looks like:\n * 'type.fqn#memberName'.\n */\n readonly fqn: string;\n\n /**\n * What kind of symbol this is\n */\n readonly symbolType: 'module' | 'type' | 'member';\n\n /**\n * Assembly where the type was found\n *\n * Might be undefined if the type was FAKE from jsii (for tests)\n */\n readonly sourceAssembly?: TypeLookupAssembly;\n}\n\nexport function lookupJsiiSymbolFromNode(typeChecker: ts.TypeChecker, node: ts.Node): JsiiSymbol | undefined {\n return fmap(typeChecker.getSymbolAtLocation(node), (s) => lookupJsiiSymbol(typeChecker, s));\n}\n\nexport function resolveJsiiSymbolType(jsiiSymbol: JsiiSymbol): spec.Type {\n if (jsiiSymbol.symbolType !== 'type') {\n throw new Error(\n `Expected symbol to refer to a 'type', got '${jsiiSymbol.fqn}' which is a '${jsiiSymbol.symbolType}'`,\n );\n }\n\n if (!jsiiSymbol.sourceAssembly) {\n throw new Error('`resolveJsiiSymbolType: requires an actual source assembly');\n }\n\n const type = jsiiSymbol.sourceAssembly?.assembly.types?.[jsiiSymbol.fqn];\n if (!type) {\n throw new Error(\n `resolveJsiiSymbolType: ${jsiiSymbol.fqn} not found in assembly ${jsiiSymbol.sourceAssembly.assembly.name}`,\n );\n }\n return type;\n}\n\n/**\n * Returns the jsii FQN for a TypeScript (class or type) symbol\n *\n * TypeScript only knows the symbol NAME plus the FILE the symbol is defined\n * in. We need to extract two things:\n *\n * 1. The package name (extracted from the nearest `package.json`)\n * 2. The submodule name (...?? don't know how to get this yet)\n * 3. Any containing type names or namespace names.\n *\n * For tests, we also treat symbols in a file that has the string '/// fake-from-jsii'\n * as coming from jsii.\n */\nexport function lookupJsiiSymbol(typeChecker: ts.TypeChecker, sym: ts.Symbol): JsiiSymbol | undefined {\n // Resolve alias, if it is one. This comes into play if the symbol refers to a module,\n // we need to resolve the alias to find the ACTUAL module.\n if (hasAnyFlag(sym.flags, ts.SymbolFlags.Alias)) {\n sym = typeChecker.getAliasedSymbol(sym);\n }\n\n const decl: ts.Node | undefined = sym.declarations?.[0];\n if (!decl) {\n return undefined;\n }\n\n if (ts.isSourceFile(decl)) {\n // This is a module.\n const sourceAssembly = findTypeLookupAssembly(decl.fileName);\n return fmap(\n sourceAssembly,\n (asm) =>\n ({\n fqn:\n fmap(\n symbolIdentifier(\n typeChecker,\n sym,\n fmap(sourceAssembly, (sa) => ({ assembly: sa.assembly })),\n ),\n (symbolId) => sourceAssembly?.symbolIdMap[symbolId],\n ) ?? sourceAssembly?.assembly.name,\n sourceAssembly: asm,\n symbolType: 'module',\n } as JsiiSymbol),\n );\n }\n\n if (!isDeclaration(decl)) {\n return undefined;\n }\n\n const declaringFile = decl.getSourceFile();\n if (/^\\/\\/\\/ fake-from-jsii/m.test(declaringFile.getFullText())) {\n return { fqn: `fake_jsii.${sym.name}`, symbolType: 'type' };\n }\n\n const declSym = getSymbolFromDeclaration(decl, typeChecker);\n if (!declSym) {\n return undefined;\n }\n\n const fileName = decl.getSourceFile().fileName;\n const sourceAssembly = findTypeLookupAssembly(fileName);\n const symbolId = symbolIdentifier(typeChecker, declSym, { assembly: sourceAssembly?.assembly });\n if (!symbolId) {\n return undefined;\n }\n\n return fmap(/([^#]*)(#.*)?/.exec(symbolId), ([, typeSymbolId, memberFragment]) => {\n if (memberFragment) {\n return fmap(sourceAssembly?.symbolIdMap[typeSymbolId], (fqn) => ({\n fqn: `${fqn}${memberFragment}`,\n sourceAssembly,\n symbolType: 'member',\n }));\n }\n\n return fmap(sourceAssembly?.symbolIdMap[typeSymbolId], (fqn) => ({ fqn, sourceAssembly, symbolType: 'type' }));\n });\n}\n\nfunction isDeclaration(x: ts.Node): x is ts.Declaration {\n return (\n ts.isClassDeclaration(x) ||\n ts.isNamespaceExportDeclaration(x) ||\n ts.isNamespaceExport(x) ||\n ts.isModuleDeclaration(x) ||\n ts.isEnumDeclaration(x) ||\n ts.isEnumMember(x) ||\n ts.isInterfaceDeclaration(x) ||\n ts.isMethodDeclaration(x) ||\n ts.isMethodSignature(x) ||\n ts.isPropertyDeclaration(x) ||\n ts.isPropertySignature(x)\n );\n}\n\n/**\n * If the given type is an enum literal, resolve to the enum type\n */\nexport function resolveEnumLiteral(typeChecker: ts.TypeChecker, type: ts.Type) {\n if (!hasAnyFlag(type.flags, ts.TypeFlags.EnumLiteral)) {\n return type;\n }\n\n return typeChecker.getBaseTypeOfLiteralType(type);\n}\n\nexport function resolvedSymbolAtLocation(typeChecker: ts.TypeChecker, node: ts.Node) {\n let symbol = typeChecker.getSymbolAtLocation(node);\n while (symbol && hasAnyFlag(symbol.flags, ts.SymbolFlags.Alias)) {\n symbol = typeChecker.getAliasedSymbol(symbol);\n }\n return symbol;\n}\n\nfunction getSymbolFromDeclaration(decl: ts.Node, typeChecker: ts.TypeChecker): ts.Symbol | undefined {\n if (!isDeclaration(decl)) {\n return undefined;\n }\n\n const name = ts.getNameOfDeclaration(decl);\n return name ? typeChecker.getSymbolAtLocation(name) : undefined;\n}\n\nexport function parentSymbol(sym: JsiiSymbol): JsiiSymbol | undefined {\n const parts = sym.fqn.split('.');\n if (parts.length === 1) {\n return undefined;\n }\n\n return {\n fqn: parts.slice(0, -1).join('.'),\n symbolType: 'module', // Might not be true, but probably good enough\n sourceAssembly: sym.sourceAssembly,\n };\n}\n\n/**\n * Get the last part of a dot-separated string\n */\nexport function simpleName(x: string) {\n return x.split('.').slice(-1)[0];\n}\n\n/**\n * Get all parts except the last of a dot-separated string\n */\nexport function namespaceName(x: string) {\n return x.split('.').slice(0, -1).join('.');\n}\n"]}
1
+ {"version":3,"file":"jsii-utils.js","sourceRoot":"","sources":["../../src/jsii/jsii-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,8CAGC;AAED,8CAeC;AAqCD,gDAiBC;AAED,kCAGC;AAED,gCAGC;AAQD,gDAoBC;AAED,wEAEC;AA2BD,4DAEC;AAED,sDAkBC;AAeD,4CA2EC;AAqBD,gDAMC;AAED,4DAMC;AAWD,oCAWC;AAKD,gCAEC;AAKD,sCAEC;AAhVD,iDAAmC;AACnC,wCAA+C;AAC/C,+CAAiC;AAEjC,6CAAwH;AAGxH,+CAA4D;AAC5D,kCAA+B;AAE/B,SAAgB,iBAAiB,CAAC,IAAY;IAC5C,kDAAkD;IAClD,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,C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zB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,GAAG,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC3C,OAAO,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAED,SAAgB,YAAY,CAAC,GAAe;IAC1C,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QACjC,UAAU,EAAE,QAAQ,EAAE,8CAA8C;QACpE,cAAc,EAAE,GAAG,CAAC,cAAc;KACnC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,CAAS;IAClC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,CAAS;IACrC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import * as spec from '@jsii/spec';\nimport { symbolIdentifier } from 'jsii/common';\nimport * as ts from 'typescript';\n\nimport { findTypeLookupAssembly, reportUnresolvedSymbolId, resolveSymbolIdFqn, TypeLookupAssembly } from './assemblies';\nimport { ObjectLiteralStruct } from './jsii-types';\nimport { AstRenderer } from '../renderer';\nimport { typeContainsUndefined } from '../typescript/types';\nimport { fmap } from '../util';\n\nexport function isNamedLikeStruct(name: string) {\n // Start with an I and another uppercase character\n return !/^I[A-Z]/.test(name);\n}\n\nexport function analyzeStructType(typeChecker: ts.TypeChecker, type: ts.Type): ObjectLiteralStruct | false {\n if (\n !type.isClassOrInterface() ||\n !hasAllFlags(type.objectFlags, ts.ObjectFlags.Interface) ||\n !isNamedLikeStruct(type.symbol.name)\n ) {\n return false;\n }\n\n const jsiiSym = lookupJsiiSymbol(typeChecker, type.symbol);\n if (jsiiSym) {\n return { kind: 'struct', type, jsiiSym };\n }\n\n return { kind: 'local-struct', type };\n}\n\n/**\n * Whether the given type is a protocol AND comes from jsii\n *\n * - Protocol: a TypeScript interface that is *not* a \"struct\" type.\n * A.k.a. \"behavioral interface\".\n * - From jsii: whether the interface type is defined in and exported\n * via a jsii assembly. There can be literal interfaces defined\n * in an example, and they will not be mangled in the same way\n * as a jsii interface would be.\n *\n *\n * Examples:\n *\n * ```ts\n * // isJsiiProtocolType() -> false: not a protocol\n * interface Banana {\n * readonly arc: number;\n * }\n *\n * // isJsiiProtocolType() -> might be true: depends on whether it was defined\n * // in a jsii assembly.\n * interface IHello {\n * sayIt(): void;\n * }\n *\n * // isJsiiProtocolType() -> false: declared to not be a protocol, even though\n * // it has the naming scheme of one\n * /**\n * * @struct\n * * /\n * interface IPAddress {\n * readonly octets: number[];\n * }\n * ```\n */\nexport function isJsiiProtocolType(typeChecker: ts.TypeChecker, type: ts.Type): boolean | undefined {\n if (!type.isClassOrInterface() || !hasAllFlags(type.objectFlags, ts.ObjectFlags.Interface)) {\n return false;\n }\n\n const sym = lookupJsiiSymbol(typeChecker, type.symbol);\n if (!sym) {\n return false;\n }\n\n if (!sym.sourceAssembly) {\n // No source assembly, so this is a 'fake-from-jsii' type\n return !isNamedLikeStruct(type.symbol.name);\n }\n\n const jsiiType = resolveJsiiSymbolType(sym);\n return spec.isInterfaceType(jsiiType) && !jsiiType.datatype;\n}\n\nexport function hasAllFlags<A extends number>(flags: A, test: A) {\n // tslint:disable-next-line:no-bitwise\n return test !== 0 && (flags & test) === test;\n}\n\nexport function hasAnyFlag<A extends number>(flags: A, test: A) {\n // tslint:disable-next-line:no-bitwise\n return test !== 0 && (flags & test) !== 0;\n}\n\nexport interface StructProperty {\n name: string;\n type: ts.Type | undefined;\n questionMark: boolean;\n}\n\nexport function propertiesOfStruct(type: ts.Type, context: AstRenderer<any>): StructProperty[] {\n return type.isClassOrInterface()\n ? type.getProperties().map((s) => {\n let propType;\n let questionMark = false;\n\n const propSymbol = type.getProperty(s.name)!;\n const symbolDecl = propSymbol.valueDeclaration ?? propSymbol.declarations![0];\n if (ts.isPropertyDeclaration(symbolDecl) || ts.isPropertySignature(symbolDecl)) {\n questionMark = symbolDecl.questionToken !== undefined;\n propType = symbolDecl.type && context.typeOfType(symbolDecl.type);\n }\n\n return {\n name: s.name,\n type: propType,\n questionMark,\n };\n })\n : [];\n}\n\nexport function structPropertyAcceptsUndefined(prop: StructProperty): boolean {\n return prop.questionMark || (!!prop.type && typeContainsUndefined(prop.type));\n}\n\n/**\n * A TypeScript symbol resolved to its jsii type\n */\nexport interface JsiiSymbol {\n /**\n * FQN of the symbol\n *\n * Is either the FQN of a type (for a type). For a membr, the FQN looks like:\n * 'type.fqn#memberName'.\n */\n readonly fqn: string;\n\n /**\n * What kind of symbol this is\n */\n readonly symbolType: 'module' | 'type' | 'member';\n\n /**\n * Assembly where the type was found\n *\n * Might be undefined if the type was FAKE from jsii (for tests)\n */\n readonly sourceAssembly?: TypeLookupAssembly;\n}\n\nexport function lookupJsiiSymbolFromNode(typeChecker: ts.TypeChecker, node: ts.Node): JsiiSymbol | undefined {\n return fmap(typeChecker.getSymbolAtLocation(node), (s) => lookupJsiiSymbol(typeChecker, s));\n}\n\nexport function resolveJsiiSymbolType(jsiiSymbol: JsiiSymbol): spec.Type {\n if (jsiiSymbol.symbolType !== 'type') {\n throw new Error(\n `Expected symbol to refer to a 'type', got '${jsiiSymbol.fqn}' which is a '${jsiiSymbol.symbolType}'`,\n );\n }\n\n if (!jsiiSymbol.sourceAssembly) {\n throw new Error('`resolveJsiiSymbolType: requires an actual source assembly');\n }\n\n const type = jsiiSymbol.sourceAssembly?.assembly.types?.[jsiiSymbol.fqn];\n if (!type) {\n throw new Error(\n `resolveJsiiSymbolType: ${jsiiSymbol.fqn} not found in assembly ${jsiiSymbol.sourceAssembly.assembly.name}`,\n );\n }\n return type;\n}\n\n/**\n * Returns the jsii FQN for a TypeScript (class or type) symbol\n *\n * TypeScript only knows the symbol NAME plus the FILE the symbol is defined\n * in. We need to extract two things:\n *\n * 1. The package name (extracted from the nearest `package.json`)\n * 2. The submodule name (...?? don't know how to get this yet)\n * 3. Any containing type names or namespace names.\n *\n * For tests, we also treat symbols in a file that has the string '/// fake-from-jsii'\n * as coming from jsii.\n */\nexport function lookupJsiiSymbol(typeChecker: ts.TypeChecker, sym: ts.Symbol): JsiiSymbol | undefined {\n // Resolve alias, if it is one. This comes into play if the symbol refers to a module,\n // we need to resolve the alias to find the ACTUAL module.\n if (hasAnyFlag(sym.flags, ts.SymbolFlags.Alias)) {\n sym = typeChecker.getAliasedSymbol(sym);\n }\n\n const decl: ts.Node | undefined = sym.declarations?.[0];\n if (!decl) {\n return undefined;\n }\n\n if (ts.isSourceFile(decl)) {\n // This is a module.\n const sourceAssembly = findTypeLookupAssembly(decl.fileName);\n return fmap(\n sourceAssembly,\n (asm) =>\n ({\n fqn:\n fmap(\n symbolIdentifier(\n typeChecker,\n sym,\n fmap(sourceAssembly, (sa) => ({ assembly: sa.assembly })),\n ),\n (symbolId) => fmap(sourceAssembly, (sa) => resolveSymbolIdFqn(sa, symbolId)),\n ) ?? sourceAssembly?.assembly.name,\n sourceAssembly: asm,\n symbolType: 'module',\n } as JsiiSymbol),\n );\n }\n\n if (!isDeclaration(decl)) {\n return undefined;\n }\n\n const declaringFile = decl.getSourceFile();\n if (/^\\/\\/\\/ fake-from-jsii/m.test(declaringFile.getFullText())) {\n return { fqn: `fake_jsii.${sym.name}`, symbolType: 'type' };\n }\n\n const declSym = getSymbolFromDeclaration(decl, typeChecker);\n if (!declSym) {\n return undefined;\n }\n\n const fileName = decl.getSourceFile().fileName;\n const sourceAssembly = findTypeLookupAssembly(fileName);\n const symbolId = symbolIdentifier(typeChecker, declSym, { assembly: sourceAssembly?.assembly });\n if (!symbolId) {\n return undefined;\n }\n\n return fmap(/([^#]*)(#.*)?/.exec(symbolId), ([, typeSymbolId, memberFragment]) => {\n const fqn = fmap(sourceAssembly, (sa) => resolveSymbolIdFqn(sa, typeSymbolId));\n if (fqn === undefined) {\n // The symbol lives in a package that demonstrably has a jsii assembly,\n // yet we cannot resolve it. Warn user about guessed target names.\n if (sourceAssembly) {\n reportUnresolvedSymbolId(sourceAssembly, typeSymbolId);\n }\n return undefined;\n }\n\n if (memberFragment) {\n return {\n fqn: `${fqn}${memberFragment}`,\n sourceAssembly,\n symbolType: 'member',\n } as JsiiSymbol;\n }\n return { fqn, sourceAssembly, symbolType: 'type' } as JsiiSymbol;\n });\n}\n\nfunction isDeclaration(x: ts.Node): x is ts.Declaration {\n return (\n ts.isClassDeclaration(x) ||\n ts.isNamespaceExportDeclaration(x) ||\n ts.isNamespaceExport(x) ||\n ts.isModuleDeclaration(x) ||\n ts.isEnumDeclaration(x) ||\n ts.isEnumMember(x) ||\n ts.isInterfaceDeclaration(x) ||\n ts.isMethodDeclaration(x) ||\n ts.isMethodSignature(x) ||\n ts.isPropertyDeclaration(x) ||\n ts.isPropertySignature(x)\n );\n}\n\n/**\n * If the given type is an enum literal, resolve to the enum type\n */\nexport function resolveEnumLiteral(typeChecker: ts.TypeChecker, type: ts.Type) {\n if (!hasAnyFlag(type.flags, ts.TypeFlags.EnumLiteral)) {\n return type;\n }\n\n return typeChecker.getBaseTypeOfLiteralType(type);\n}\n\nexport function resolvedSymbolAtLocation(typeChecker: ts.TypeChecker, node: ts.Node) {\n let symbol = typeChecker.getSymbolAtLocation(node);\n while (symbol && hasAnyFlag(symbol.flags, ts.SymbolFlags.Alias)) {\n symbol = typeChecker.getAliasedSymbol(symbol);\n }\n return symbol;\n}\n\nfunction getSymbolFromDeclaration(decl: ts.Node, typeChecker: ts.TypeChecker): ts.Symbol | undefined {\n if (!isDeclaration(decl)) {\n return undefined;\n }\n\n const name = ts.getNameOfDeclaration(decl);\n return name ? typeChecker.getSymbolAtLocation(name) : undefined;\n}\n\nexport function parentSymbol(sym: JsiiSymbol): JsiiSymbol | undefined {\n const parts = sym.fqn.split('.');\n if (parts.length === 1) {\n return undefined;\n }\n\n return {\n fqn: parts.slice(0, -1).join('.'),\n symbolType: 'module', // Might not be true, but probably good enough\n sourceAssembly: sym.sourceAssembly,\n };\n}\n\n/**\n * Get the last part of a dot-separated string\n */\nexport function simpleName(x: string) {\n return x.split('.').slice(-1)[0];\n}\n\n/**\n * Get all parts except the last of a dot-separated string\n */\nexport function namespaceName(x: string) {\n return x.split('.').slice(0, -1).join('.');\n}\n"]}
package/package.json CHANGED
@@ -91,12 +91,13 @@
91
91
  "publishConfig": {
92
92
  "access": "public"
93
93
  },
94
- "version": "6.0.8",
94
+ "version": "6.0.10-dev.0",
95
95
  "packageManager": "yarn@4.13.0",
96
96
  "types": "lib/index.d.ts",
97
97
  "exports": {
98
98
  ".": "./lib/index.js",
99
99
  "./package.json": "./package.json"
100
100
  },
101
- "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"yarn projen\"."
101
+ "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"yarn projen\".",
102
+ "stableVersion": "0.0.0"
102
103
  }