@fern-api/fern-api-dev 3.27.2 → 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 +227 -7
  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.2",
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.2",
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.2";
1493985
+ return "3.27.3";
1493986
1493986
  }
1493987
1493987
  getCliName() {
1493988
1493988
  if (false) {
@@ -1588481,7 +1588481,7 @@ var import_path35 = __toESM(require("path"), 1);
1588481
1588481
  var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
1588482
1588482
  var LOGS_FOLDER_NAME = "logs";
1588483
1588483
  function getCliSource() {
1588484
- const version6 = "3.27.2";
1588484
+ const version6 = "3.27.3";
1588485
1588485
  return `cli@${version6}`;
1588486
1588486
  }
1588487
1588487
  var DebugLogger = class {
@@ -1627884,13 +1627884,33 @@ async function publishDocs({ token, organization, docsWorkspace, domain: domain2
1627884
1627884
  apiDefinition = await enhanceExamplesWithAI(apiDefinition, aiEnhancerConfig, context2, token, organization, sourceFilePath);
1627885
1627885
  }
1627886
1627886
  let dynamicIRsByLanguage;
1627887
+ let languagesWithExistingSdkDynamicIr = /* @__PURE__ */ new Set();
1627887
1627888
  if (useDynamicSnippets) {
1627888
- dynamicIRsByLanguage = await generateLanguageSpecificDynamicIRs({
1627889
+ const existingSdkDynamicIrs = await checkAndDownloadExistingSdkDynamicIRs({
1627890
+ fdr,
1627889
1627891
  workspace,
1627890
1627892
  organization,
1627891
1627893
  context: context2,
1627892
1627894
  snippetsConfig
1627893
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
+ }
1627894
1627914
  }
1627895
1627915
  const response = await fdr.api.v1.register.registerApiDefinition({
1627896
1627916
  orgId: FdrAPI_exports.OrgId(organization),
@@ -1628060,7 +1628080,203 @@ function parseBasePath(domain2) {
1628060
1628080
  return void 0;
1628061
1628081
  }
1628062
1628082
  }
1628063
- 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() }) {
1628064
1628280
  let languageSpecificIRs = {};
1628065
1628281
  if (!workspace) {
1628066
1628282
  return void 0;
@@ -1628118,6 +1628334,10 @@ async function generateLanguageSpecificDynamicIRs({ workspace, organization, con
1628118
1628334
  if (!generatorInvocation.language) {
1628119
1628335
  continue;
1628120
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
+ }
1628121
1628341
  if (generatorInvocation.language && snippetConfiguration[generatorInvocation.language] === packageName) {
1628122
1628342
  const irForDynamicSnippets = generateIntermediateRepresentation({
1628123
1628343
  workspace,
@@ -1628158,7 +1628378,7 @@ async function generateLanguageSpecificDynamicIRs({ workspace, organization, con
1628158
1628378
  }
1628159
1628379
  }
1628160
1628380
  for (const [language, packageName] of Object.entries(snippetConfiguration)) {
1628161
- if (language && packageName && !Object.keys(languageSpecificIRs).includes(language)) {
1628381
+ if (language && packageName && !Object.keys(languageSpecificIRs).includes(language) && !skipLanguages.has(language)) {
1628162
1628382
  context2.logger.warn();
1628163
1628383
  context2.logger.warn(`Failed to upload ${language} SDK snippets because of unknown package \`${packageName}\`.`);
1628164
1628384
  context2.logger.warn(`Please make sure your ${workspace.workspaceName ? `${workspace.workspaceName}/` : ""}generators.yml has a generator that publishes a ${packageName} package.`);
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.27.2",
2
+ "version": "3.27.3",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",