@fern-api/fdr-sdk 1.2.56-4cf0b0d54d → 1.2.56-d742990ae1

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.
@@ -43708,35 +43708,33 @@ function shouldIncludeHttpSnippetLanguage(language, flags) {
43708
43708
  }
43709
43709
 
43710
43710
  // src/api-definition/snippets/backfill.ts
43711
- var YIELD_BUDGET_MS = 20;
43712
- var yieldToEventLoop = () => new Promise((resolve) => typeof setImmediate === "function" ? setImmediate(resolve) : setTimeout(resolve, 0));
43713
43711
  async function backfillSnippets(apiDefinition, dynamicIr, flags) {
43714
- let lastYield = Date.now();
43715
- const maybeYield = async () => {
43716
- if (Date.now() - lastYield >= YIELD_BUDGET_MS) {
43717
- await yieldToEventLoop();
43718
- lastYield = Date.now();
43719
- }
43712
+ return {
43713
+ ...apiDefinition,
43714
+ endpoints: await Promise.all(
43715
+ Object.entries(apiDefinition.endpoints).map(async ([id2, endpoint]) => {
43716
+ let dynamicGenerators = {};
43717
+ try {
43718
+ if (dynamicIr) {
43719
+ dynamicGenerators = createSnippetGenerators({ endpoint, dynamicIr });
43720
+ }
43721
+ } catch (error) {
43722
+ console.log("[backfill] error creating dynamic snippet generators:", error);
43723
+ }
43724
+ return [
43725
+ id2,
43726
+ {
43727
+ ...endpoint,
43728
+ examples: await Promise.all(
43729
+ endpoint.examples?.map(
43730
+ (example) => backfillSnippetsForExample(apiDefinition, dynamicGenerators, endpoint, example, flags)
43731
+ ) ?? []
43732
+ )
43733
+ }
43734
+ ];
43735
+ })
43736
+ ).then((entries) => Object.fromEntries(entries))
43720
43737
  };
43721
- const endpoints = {};
43722
- for (const [id2, endpoint] of Object.entries(apiDefinition.endpoints)) {
43723
- await maybeYield();
43724
- let dynamicGenerators = {};
43725
- try {
43726
- if (dynamicIr) {
43727
- dynamicGenerators = createSnippetGenerators({ endpoint, dynamicIr });
43728
- }
43729
- } catch (error) {
43730
- console.log("[backfill] error creating dynamic snippet generators:", error);
43731
- }
43732
- const examples = [];
43733
- for (const example of endpoint.examples ?? []) {
43734
- await maybeYield();
43735
- examples.push(await backfillSnippetsForExample(apiDefinition, dynamicGenerators, endpoint, example, flags));
43736
- }
43737
- endpoints[id2] = { ...endpoint, examples };
43738
- }
43739
- return { ...apiDefinition, endpoints };
43740
43738
  }
43741
43739
  async function backfillSnippetsForExample(apiDefinition, dynamicGenerators, endpoint, example, flags) {
43742
43740
  const snippets = { ...example.snippets };