@fern-api/fern-api-dev 3.27.1-1-g21d8c43893 → 3.27.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.cjs +279 -10
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -1413817,7 +1413817,7 @@ var AccessTokenPosthogManager = class {
1413817
1413817
  properties: {
1413818
1413818
  ...event,
1413819
1413819
  ...event.properties,
1413820
- version: "3.27.1-1-g21d8c43893",
1413820
+ version: "3.27.3",
1413821
1413821
  usingAccessToken: true
1413822
1413822
  }
1413823
1413823
  });
@@ -1413916,7 +1413916,7 @@ var UserPosthogManager = class {
1413916
1413916
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
1413917
1413917
  event: "CLI",
1413918
1413918
  properties: {
1413919
- version: "3.27.1-1-g21d8c43893",
1413919
+ version: "3.27.3",
1413920
1413920
  ...event,
1413921
1413921
  ...event.properties,
1413922
1413922
  usingAccessToken: false,
@@ -1493982,7 +1493982,7 @@ var CliContext = class {
1493982
1493982
  if (false) {
1493983
1493983
  this.logger.error("CLI_VERSION is not defined");
1493984
1493984
  }
1493985
- return "3.27.1-1-g21d8c43893";
1493985
+ return "3.27.3";
1493986
1493986
  }
1493987
1493987
  getCliName() {
1493988
1493988
  if (false) {
@@ -1570472,6 +1570472,13 @@ var ExampleResolverImpl = class {
1570472
1570472
  file
1570473
1570473
  };
1570474
1570474
  }
1570475
+ const parsedReference = this.parseExampleReference(example);
1570476
+ if (parsedReference == null) {
1570477
+ return {
1570478
+ resolvedExample: example,
1570479
+ file
1570480
+ };
1570481
+ }
1570475
1570482
  return this.resolveExampleReference(example, file);
1570476
1570483
  }
1570477
1570484
  resolveExampleReference(example, file) {
@@ -1570505,17 +1570512,32 @@ var ExampleResolverImpl = class {
1570505
1570512
  return void 0;
1570506
1570513
  }
1570507
1570514
  if (third == null) {
1570515
+ const rawTypeReference = first3.slice(EXAMPLE_REFERENCE_PREFIX.length);
1570516
+ if (!isValidTypeNameStart(rawTypeReference)) {
1570517
+ return void 0;
1570518
+ }
1570508
1570519
  return {
1570509
- rawTypeReference: first3.slice(EXAMPLE_REFERENCE_PREFIX.length),
1570520
+ rawTypeReference,
1570510
1570521
  exampleName: second
1570511
1570522
  };
1570512
1570523
  }
1570524
+ const importName = first3.slice(EXAMPLE_REFERENCE_PREFIX.length);
1570525
+ if (!isValidTypeNameStart(importName) || !isValidTypeNameStart(second)) {
1570526
+ return void 0;
1570527
+ }
1570513
1570528
  return {
1570514
- rawTypeReference: `${first3}.${second}`.slice(EXAMPLE_REFERENCE_PREFIX.length),
1570529
+ rawTypeReference: `${importName}.${second}`,
1570515
1570530
  exampleName: third
1570516
1570531
  };
1570517
1570532
  }
1570518
1570533
  };
1570534
+ function isValidTypeNameStart(name2) {
1570535
+ if (name2.length === 0) {
1570536
+ return false;
1570537
+ }
1570538
+ const firstChar = name2.charAt(0);
1570539
+ return firstChar >= "a" && firstChar <= "z" || firstChar >= "A" && firstChar <= "Z";
1570540
+ }
1570519
1570541
 
1570520
1570542
  // ../generation/ir-generator/lib/resolvers/PropertyResolver.js
1570521
1570543
  var PropertyResolverImpl = class {
@@ -1588459,7 +1588481,7 @@ var import_path35 = __toESM(require("path"), 1);
1588459
1588481
  var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
1588460
1588482
  var LOGS_FOLDER_NAME = "logs";
1588461
1588483
  function getCliSource() {
1588462
- const version6 = "3.27.1-1-g21d8c43893";
1588484
+ const version6 = "3.27.3";
1588463
1588485
  return `cli@${version6}`;
1588464
1588486
  }
1588465
1588487
  var DebugLogger = class {
@@ -1627862,13 +1627884,33 @@ async function publishDocs({ token, organization, docsWorkspace, domain: domain2
1627862
1627884
  apiDefinition = await enhanceExamplesWithAI(apiDefinition, aiEnhancerConfig, context2, token, organization, sourceFilePath);
1627863
1627885
  }
1627864
1627886
  let dynamicIRsByLanguage;
1627887
+ let languagesWithExistingSdkDynamicIr = /* @__PURE__ */ new Set();
1627865
1627888
  if (useDynamicSnippets) {
1627866
- dynamicIRsByLanguage = await generateLanguageSpecificDynamicIRs({
1627889
+ const existingSdkDynamicIrs = await checkAndDownloadExistingSdkDynamicIRs({
1627890
+ fdr,
1627867
1627891
  workspace,
1627868
1627892
  organization,
1627869
1627893
  context: context2,
1627870
1627894
  snippetsConfig
1627871
1627895
  });
1627896
+ if (existingSdkDynamicIrs && Object.keys(existingSdkDynamicIrs).length > 0) {
1627897
+ dynamicIRsByLanguage = existingSdkDynamicIrs;
1627898
+ languagesWithExistingSdkDynamicIr = new Set(Object.keys(existingSdkDynamicIrs));
1627899
+ context2.logger.debug(`Using existing SDK dynamic IRs for: ${Object.keys(existingSdkDynamicIrs).join(", ")}`);
1627900
+ }
1627901
+ const generatedDynamicIRs = await generateLanguageSpecificDynamicIRs({
1627902
+ workspace,
1627903
+ organization,
1627904
+ context: context2,
1627905
+ snippetsConfig,
1627906
+ skipLanguages: languagesWithExistingSdkDynamicIr
1627907
+ });
1627908
+ if (generatedDynamicIRs) {
1627909
+ dynamicIRsByLanguage = {
1627910
+ ...dynamicIRsByLanguage,
1627911
+ ...generatedDynamicIRs
1627912
+ };
1627913
+ }
1627872
1627914
  }
1627873
1627915
  const response = await fdr.api.v1.register.registerApiDefinition({
1627874
1627916
  orgId: FdrAPI_exports.OrgId(organization),
@@ -1628038,7 +1628080,203 @@ function parseBasePath(domain2) {
1628038
1628080
  return void 0;
1628039
1628081
  }
1628040
1628082
  }
1628041
- async function generateLanguageSpecificDynamicIRs({ workspace, organization, context: context2, snippetsConfig }) {
1628083
+ async function checkAndDownloadExistingSdkDynamicIRs({ fdr, workspace, organization, context: context2, snippetsConfig }) {
1628084
+ if (!workspace) {
1628085
+ return void 0;
1628086
+ }
1628087
+ const snippetConfigWithVersions = await buildSnippetConfigurationWithVersions({
1628088
+ fdr,
1628089
+ workspace,
1628090
+ snippetsConfig,
1628091
+ context: context2
1628092
+ });
1628093
+ if (Object.keys(snippetConfigWithVersions).length === 0) {
1628094
+ context2.logger.debug(`[SDK Dynamic IR] No snippet configs with versions found, skipping S3 check`);
1628095
+ return void 0;
1628096
+ }
1628097
+ try {
1628098
+ const response = await fdr.api.v1.register.checkSdkDynamicIrExists({
1628099
+ orgId: FdrAPI_exports.OrgId(organization),
1628100
+ snippetConfiguration: snippetConfigWithVersions
1628101
+ });
1628102
+ if (!response.ok || !response.body) {
1628103
+ context2.logger.debug(`[SDK Dynamic IR] API call failed or returned empty body`);
1628104
+ return void 0;
1628105
+ }
1628106
+ const existingDynamicIrs = response.body.existingDynamicIrs;
1628107
+ if (Object.keys(existingDynamicIrs).length === 0) {
1628108
+ context2.logger.debug("[SDK Dynamic IR] No existing SDK dynamic IRs found in S3");
1628109
+ return void 0;
1628110
+ }
1628111
+ const result = {};
1628112
+ for (const [language, sdkDynamicIrDownload] of Object.entries(existingDynamicIrs)) {
1628113
+ try {
1628114
+ context2.logger.debug(`Downloading existing SDK dynamic IR for ${language}...`);
1628115
+ const downloadResponse = await fetch(sdkDynamicIrDownload.downloadUrl);
1628116
+ if (downloadResponse.ok) {
1628117
+ const dynamicIR = await downloadResponse.json();
1628118
+ result[language] = { dynamicIR };
1628119
+ context2.logger.debug(`Successfully downloaded SDK dynamic IR for ${language}`);
1628120
+ } else {
1628121
+ context2.logger.warn(`Failed to download SDK dynamic IR for ${language}: ${downloadResponse.status}`);
1628122
+ }
1628123
+ } catch (error2) {
1628124
+ context2.logger.warn(`Error downloading SDK dynamic IR for ${language}: ${error2}`);
1628125
+ }
1628126
+ }
1628127
+ return Object.keys(result).length > 0 ? result : void 0;
1628128
+ } catch (error2) {
1628129
+ context2.logger.debug(`Error checking for existing SDK dynamic IRs: ${error2}`);
1628130
+ return void 0;
1628131
+ }
1628132
+ }
1628133
+ async function buildSnippetConfigurationWithVersions({ fdr, workspace, snippetsConfig, context: context2 }) {
1628134
+ const result = {};
1628135
+ const snippetConfigs = [
1628136
+ {
1628137
+ language: "typescript",
1628138
+ snippetName: snippetsConfig.typescriptSdk?.package,
1628139
+ explicitVersion: snippetsConfig.typescriptSdk?.version
1628140
+ },
1628141
+ {
1628142
+ language: "python",
1628143
+ snippetName: snippetsConfig.pythonSdk?.package,
1628144
+ explicitVersion: snippetsConfig.pythonSdk?.version
1628145
+ },
1628146
+ {
1628147
+ language: "java",
1628148
+ snippetName: snippetsConfig.javaSdk?.coordinate,
1628149
+ explicitVersion: snippetsConfig.javaSdk?.version
1628150
+ },
1628151
+ {
1628152
+ language: "go",
1628153
+ snippetName: snippetsConfig.goSdk?.githubRepo,
1628154
+ explicitVersion: snippetsConfig.goSdk?.version
1628155
+ },
1628156
+ {
1628157
+ language: "csharp",
1628158
+ snippetName: snippetsConfig.csharpSdk?.package,
1628159
+ explicitVersion: snippetsConfig.csharpSdk?.version
1628160
+ },
1628161
+ {
1628162
+ language: "ruby",
1628163
+ snippetName: snippetsConfig.rubySdk?.gem,
1628164
+ explicitVersion: snippetsConfig.rubySdk?.version
1628165
+ },
1628166
+ {
1628167
+ language: "php",
1628168
+ snippetName: snippetsConfig.phpSdk?.package,
1628169
+ explicitVersion: snippetsConfig.phpSdk?.version
1628170
+ },
1628171
+ {
1628172
+ language: "swift",
1628173
+ snippetName: snippetsConfig.swiftSdk?.package,
1628174
+ explicitVersion: snippetsConfig.swiftSdk?.version
1628175
+ },
1628176
+ {
1628177
+ language: "rust",
1628178
+ snippetName: snippetsConfig.rustSdk?.package,
1628179
+ explicitVersion: snippetsConfig.rustSdk?.version
1628180
+ }
1628181
+ ];
1628182
+ for (const config2 of snippetConfigs) {
1628183
+ if (!config2.snippetName) {
1628184
+ continue;
1628185
+ }
1628186
+ let version6 = config2.explicitVersion;
1628187
+ if (!version6) {
1628188
+ const versionResult = await computeSemanticVersionForLanguage({
1628189
+ fdr,
1628190
+ workspace,
1628191
+ language: config2.language,
1628192
+ snippetName: config2.snippetName,
1628193
+ context: context2
1628194
+ });
1628195
+ version6 = versionResult?.version;
1628196
+ }
1628197
+ if (version6) {
1628198
+ result[config2.language] = { packageName: config2.snippetName, version: version6 };
1628199
+ } else {
1628200
+ context2.logger.debug(`[SDK Dynamic IR] ${config2.language}: skipping S3 check (no version available)`);
1628201
+ }
1628202
+ }
1628203
+ return result;
1628204
+ }
1628205
+ async function computeSemanticVersionForLanguage({ fdr, workspace, language, snippetName, context: context2 }) {
1628206
+ let fdrLanguage;
1628207
+ switch (language) {
1628208
+ case "csharp":
1628209
+ fdrLanguage = "Csharp";
1628210
+ break;
1628211
+ case "go":
1628212
+ fdrLanguage = "Go";
1628213
+ break;
1628214
+ case "java":
1628215
+ fdrLanguage = "Java";
1628216
+ break;
1628217
+ case "python":
1628218
+ fdrLanguage = "Python";
1628219
+ break;
1628220
+ case "ruby":
1628221
+ fdrLanguage = "Ruby";
1628222
+ break;
1628223
+ case "typescript":
1628224
+ fdrLanguage = "TypeScript";
1628225
+ break;
1628226
+ case "php":
1628227
+ fdrLanguage = "Php";
1628228
+ break;
1628229
+ case "swift":
1628230
+ fdrLanguage = "Swift";
1628231
+ break;
1628232
+ default:
1628233
+ return void 0;
1628234
+ }
1628235
+ let githubRepository;
1628236
+ let generatorPackage;
1628237
+ let matchedGeneratorName;
1628238
+ if (workspace.generatorsConfiguration?.groups) {
1628239
+ const candidatePackages = [];
1628240
+ for (const group of workspace.generatorsConfiguration.groups) {
1628241
+ for (const generatorInvocation of group.generators) {
1628242
+ if (generatorInvocation.language === language) {
1628243
+ const pkgName = generators_yml_exports.getPackageName({ generatorInvocation });
1628244
+ if (pkgName) {
1628245
+ candidatePackages.push(pkgName);
1628246
+ }
1628247
+ if (!generatorPackage && pkgName) {
1628248
+ generatorPackage = pkgName;
1628249
+ matchedGeneratorName = generatorInvocation.name;
1628250
+ if (generatorInvocation.outputMode.type === "githubV2") {
1628251
+ githubRepository = `${generatorInvocation.outputMode.githubV2.owner}/${generatorInvocation.outputMode.githubV2.repo}`;
1628252
+ }
1628253
+ }
1628254
+ }
1628255
+ }
1628256
+ }
1628257
+ }
1628258
+ if (!generatorPackage) {
1628259
+ context2.logger.debug(`[SDK Dynamic IR] ${language}: no generator found with a package name`);
1628260
+ return void 0;
1628261
+ }
1628262
+ try {
1628263
+ const response = await fdr.sdks.versions.computeSemanticVersion({
1628264
+ githubRepository,
1628265
+ language: fdrLanguage,
1628266
+ package: generatorPackage
1628267
+ });
1628268
+ if (!response.ok) {
1628269
+ context2.logger.debug(`[SDK Dynamic IR] ${language}: version computation failed for package "${generatorPackage}"`);
1628270
+ return void 0;
1628271
+ }
1628272
+ context2.logger.debug(`[SDK Dynamic IR] ${language}: computed version ${response.body.version} for package "${generatorPackage}"`);
1628273
+ return { version: response.body.version, generatorPackage };
1628274
+ } catch (error2) {
1628275
+ context2.logger.debug(`[SDK Dynamic IR] ${language}: error computing version: ${error2}`);
1628276
+ return void 0;
1628277
+ }
1628278
+ }
1628279
+ async function generateLanguageSpecificDynamicIRs({ workspace, organization, context: context2, snippetsConfig, skipLanguages = /* @__PURE__ */ new Set() }) {
1628042
1628280
  let languageSpecificIRs = {};
1628043
1628281
  if (!workspace) {
1628044
1628282
  return void 0;
@@ -1628096,6 +1628334,10 @@ async function generateLanguageSpecificDynamicIRs({ workspace, organization, con
1628096
1628334
  if (!generatorInvocation.language) {
1628097
1628335
  continue;
1628098
1628336
  }
1628337
+ if (skipLanguages.has(generatorInvocation.language)) {
1628338
+ context2.logger.debug(`Skipping dynamic IR generation for ${generatorInvocation.language} (using existing SDK dynamic IR)`);
1628339
+ continue;
1628340
+ }
1628099
1628341
  if (generatorInvocation.language && snippetConfiguration[generatorInvocation.language] === packageName) {
1628100
1628342
  const irForDynamicSnippets = generateIntermediateRepresentation({
1628101
1628343
  workspace,
@@ -1628136,7 +1628378,7 @@ async function generateLanguageSpecificDynamicIRs({ workspace, organization, con
1628136
1628378
  }
1628137
1628379
  }
1628138
1628380
  for (const [language, packageName] of Object.entries(snippetConfiguration)) {
1628139
- if (language && packageName && !Object.keys(languageSpecificIRs).includes(language)) {
1628381
+ if (language && packageName && !Object.keys(languageSpecificIRs).includes(language) && !skipLanguages.has(language)) {
1628140
1628382
  context2.logger.warn();
1628141
1628383
  context2.logger.warn(`Failed to upload ${language} SDK snippets because of unknown package \`${packageName}\`.`);
1628142
1628384
  context2.logger.warn(`Please make sure your ${workspace.workspaceName ? `${workspace.workspaceName}/` : ""}generators.yml has a generator that publishes a ${packageName} package.`);
@@ -1632006,9 +1632248,36 @@ function createDocsVisitor(visitor, nodePath) {
1632006
1632248
  }
1632007
1632249
 
1632008
1632250
  // ../fern-definition/validator/lib/ast/visitors/utils/visitAllReferencesInExample.js
1632251
+ function isValidExampleReference(example) {
1632252
+ if (!example.startsWith(EXAMPLE_REFERENCE_PREFIX)) {
1632253
+ return false;
1632254
+ }
1632255
+ const parts = example.split(".");
1632256
+ if (parts.length < 2 || parts.length > 3) {
1632257
+ return false;
1632258
+ }
1632259
+ const firstPart = parts[0]?.slice(EXAMPLE_REFERENCE_PREFIX.length);
1632260
+ if (!firstPart || !startsWithLetter(firstPart)) {
1632261
+ return false;
1632262
+ }
1632263
+ if (parts.length === 3) {
1632264
+ const secondPart = parts[1];
1632265
+ if (!secondPart || !startsWithLetter(secondPart)) {
1632266
+ return false;
1632267
+ }
1632268
+ }
1632269
+ return true;
1632270
+ }
1632271
+ function startsWithLetter(str3) {
1632272
+ if (str3.length === 0) {
1632273
+ return false;
1632274
+ }
1632275
+ const firstChar = str3.charAt(0);
1632276
+ return firstChar >= "a" && firstChar <= "z" || firstChar >= "A" && firstChar <= "Z";
1632277
+ }
1632009
1632278
  function visitAllReferencesInExample({ example, visitor, nodePath }) {
1632010
1632279
  if (typeof example === "string") {
1632011
- if (example.startsWith(EXAMPLE_REFERENCE_PREFIX)) {
1632280
+ if (isValidExampleReference(example)) {
1632012
1632281
  visitor.exampleTypeReference?.(example, nodePath);
1632013
1632282
  }
1632014
1632283
  } else if (isPlainObject2(example)) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.27.1-1-g21d8c43893",
2
+ "version": "3.27.3",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",