Skip to content

Commit

Permalink
feat: audience filters
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Oct 10, 2024
1 parent af711fa commit 9f3c4ff
Show file tree
Hide file tree
Showing 18 changed files with 255 additions and 40 deletions.
2 changes: 2 additions & 0 deletions fern/apis/fdr/definition/commons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ types:

PropertyKey: string

AudienceId: string

EndpointIdentifier:
properties:
path: EndpointPathLiteral
Expand Down
17 changes: 15 additions & 2 deletions fern/apis/fdr/definition/navigation/latest/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,21 @@ types:
type: optional<Slug>
docs: The slug that should be used in the canonical URL rel. If not provided, the `slug` will be used.
icon: optional<string>
hidden: optional<boolean>
authed: optional<boolean>
hidden:
type: optional<boolean>
docs: If true, this node will not be displayed in the sidebar, and noindex will be considered true.
authed:
type: optional<boolean>
docs: |
If true, this node is only visible to authenticated users.
If false, this node is only visible to all users (including anonymous).
audience:
type: optional<list<commons.AudienceId>>
availability: in-development
docs: |
The audience(s) that this node is intended for. If not provided, the node is intended for all audiences.
If provided, the node is only intended for the specified audience(s). OR logic is used for multiple audiences on a single node.
AND logic is used when evaluating audiences up the tree.
WithPage:
properties:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions packages/fdr-sdk/src/navigation/migrators/v1ToV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class FernNavigationV1ToLatest {
icon: node.icon,
hidden: node.hidden,
authed: undefined,
audience: undefined,
};

return latest;
Expand Down Expand Up @@ -100,6 +101,7 @@ export class FernNavigationV1ToLatest {
authed: undefined,
id: FernNavigation.NodeId(node.id),
pointsTo: node.pointsTo ? FernNavigation.Slug(node.pointsTo) : undefined,
audience: undefined,
};
return latest;
};
Expand All @@ -124,6 +126,7 @@ export class FernNavigationV1ToLatest {
id: FernNavigation.NodeId(node.id),
pageId: FernNavigation.PageId(node.pageId),
noindex: node.noindex,
audience: undefined,
};
return latest;
};
Expand Down Expand Up @@ -161,6 +164,7 @@ export class FernNavigationV1ToLatest {
authed: undefined,
id: FernNavigation.NodeId(node.id),
pointsTo: node.pointsTo ? FernNavigation.Slug(node.pointsTo) : undefined,
audience: undefined,
};
return latest;
};
Expand Down Expand Up @@ -261,6 +265,7 @@ export class FernNavigationV1ToLatest {
versioned: (value) => this.versioned(value, [...parents, node]),
}),
subtitle: node.subtitle,
audience: undefined,
};
return latest;
};
Expand Down Expand Up @@ -315,6 +320,7 @@ export class FernNavigationV1ToLatest {
authed: undefined,
pageId: FernNavigation.PageId(node.pageId),
noindex: node.noindex,
audience: undefined,
};
return latest;
};
Expand Down Expand Up @@ -346,6 +352,7 @@ export class FernNavigationV1ToLatest {
collapsed: node.collapsed,
overviewPageId,
noindex: node.noindex,
audience: undefined,
};
return latest;
};
Expand Down Expand Up @@ -383,6 +390,7 @@ export class FernNavigationV1ToLatest {
apiDefinitionId: node.apiDefinitionId,
availability: this.#availability(node.availability),
pointsTo: node.pointsTo ? FernNavigation.Slug(node.pointsTo) : undefined,
audience: undefined,
};
return latest;
};
Expand Down Expand Up @@ -412,6 +420,7 @@ export class FernNavigationV1ToLatest {
authed: undefined,
overviewPageId,
noindex: node.noindex,
audience: undefined,
};
return latest;
};
Expand All @@ -431,6 +440,7 @@ export class FernNavigationV1ToLatest {
hidden: node.hidden,
authed: undefined,
year: node.year,
audience: undefined,
};
return latest;
};
Expand All @@ -450,6 +460,7 @@ export class FernNavigationV1ToLatest {
hidden: node.hidden,
authed: undefined,
month: node.month,
audience: undefined,
};
return latest;
};
Expand All @@ -475,6 +486,7 @@ export class FernNavigationV1ToLatest {
date: node.date,
pageId: FernNavigation.PageId(node.pageId),
noindex: node.noindex,
audience: undefined,
};
return latest;
};
Expand Down Expand Up @@ -508,6 +520,7 @@ export class FernNavigationV1ToLatest {
noindex: node.noindex,
apiDefinitionId: node.apiDefinitionId,
availability: this.#availability(node.availability),
audience: undefined,
};
return latest;
};
Expand Down Expand Up @@ -539,6 +552,7 @@ export class FernNavigationV1ToLatest {
method: node.method,
endpointId: node.endpointId,
isResponseStream: node.isResponseStream,
audience: undefined,
};
return latest;
};
Expand Down Expand Up @@ -581,6 +595,7 @@ export class FernNavigationV1ToLatest {
apiDefinitionId: node.apiDefinitionId,
availability: this.#availability(node.availability),
webSocketId: node.webSocketId,
audience: undefined,
};
return latest;
};
Expand Down Expand Up @@ -610,6 +625,7 @@ export class FernNavigationV1ToLatest {
availability: this.#availability(node.availability),
method: node.method,
webhookId: node.webhookId,
audience: undefined,
};
return latest;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe("pruneNavigationTree", () => {
hidden: undefined,
authed: undefined,
noindex: undefined,
audience: undefined,
},
],
collapsed: undefined,
Expand All @@ -30,6 +31,7 @@ describe("pruneNavigationTree", () => {
overviewPageId: undefined,
noindex: undefined,
pointsTo: undefined,
audience: undefined,
};

const result = Pruner.from(root)
Expand All @@ -56,6 +58,7 @@ describe("pruneNavigationTree", () => {
hidden: undefined,
authed: undefined,
noindex: undefined,
audience: undefined,
},
],
collapsed: undefined,
Expand All @@ -66,6 +69,7 @@ describe("pruneNavigationTree", () => {
overviewPageId: undefined,
noindex: undefined,
pointsTo: FernNavigation.Slug("root/page"),
audience: undefined,
});
});

Expand All @@ -87,6 +91,7 @@ describe("pruneNavigationTree", () => {
hidden: undefined,
authed: undefined,
noindex: undefined,
audience: undefined,
},
],
collapsed: undefined,
Expand All @@ -97,6 +102,7 @@ describe("pruneNavigationTree", () => {
overviewPageId: undefined,
noindex: undefined,
pointsTo: FernNavigation.Slug("root/page"),
audience: undefined,
};

const result = Pruner.from(root)
Expand Down Expand Up @@ -125,6 +131,7 @@ describe("pruneNavigationTree", () => {
hidden: undefined,
authed: undefined,
noindex: undefined,
audience: undefined,
},
],
collapsed: undefined,
Expand All @@ -134,6 +141,7 @@ describe("pruneNavigationTree", () => {
authed: undefined,
noindex: undefined,
pointsTo: undefined,
audience: undefined,
};

const result = Pruner.from(root)
Expand Down Expand Up @@ -161,6 +169,7 @@ describe("pruneNavigationTree", () => {
hidden: undefined,
authed: undefined,
noindex: undefined,
audience: undefined,
},
],
collapsed: undefined,
Expand All @@ -170,6 +179,7 @@ describe("pruneNavigationTree", () => {
authed: undefined,
noindex: undefined,
pointsTo: FernNavigation.Slug("root/page"),
audience: undefined,
});
});

Expand All @@ -192,6 +202,7 @@ describe("pruneNavigationTree", () => {
hidden: undefined,
authed: undefined,
noindex: undefined,
audience: undefined,
},
],
collapsed: undefined,
Expand All @@ -201,6 +212,7 @@ describe("pruneNavigationTree", () => {
authed: undefined,
noindex: undefined,
pointsTo: undefined,
audience: undefined,
};

const result = Pruner.from(root)
Expand All @@ -224,6 +236,7 @@ describe("pruneNavigationTree", () => {
authed: undefined,
noindex: undefined,
pointsTo: undefined,
audience: undefined,
});
});

Expand All @@ -246,6 +259,7 @@ describe("pruneNavigationTree", () => {
hidden: undefined,
authed: undefined,
noindex: undefined,
audience: undefined,
},
],
collapsed: undefined,
Expand All @@ -255,6 +269,7 @@ describe("pruneNavigationTree", () => {
authed: undefined,
noindex: undefined,
pointsTo: undefined,
audience: undefined,
};

const result = Pruner.from(root)
Expand Down Expand Up @@ -282,6 +297,7 @@ describe("pruneNavigationTree", () => {
hidden: undefined,
authed: undefined,
noindex: undefined,
audience: undefined,
},
],
collapsed: undefined,
Expand All @@ -291,6 +307,7 @@ describe("pruneNavigationTree", () => {
authed: undefined,
noindex: undefined,
pointsTo: FernNavigation.Slug("root/page"),
audience: undefined,
});
});

Expand Down Expand Up @@ -320,6 +337,7 @@ describe("pruneNavigationTree", () => {
hidden: undefined,
authed: undefined,
noindex: undefined,
audience: undefined,
},
],
collapsed: undefined,
Expand All @@ -329,6 +347,7 @@ describe("pruneNavigationTree", () => {
authed: undefined,
noindex: undefined,
pointsTo: undefined,
audience: undefined,
},
{
type: "page",
Expand All @@ -341,6 +360,7 @@ describe("pruneNavigationTree", () => {
hidden: undefined,
authed: undefined,
noindex: undefined,
audience: undefined,
},
],
collapsed: undefined,
Expand All @@ -350,6 +370,7 @@ describe("pruneNavigationTree", () => {
authed: undefined,
noindex: undefined,
pointsTo: undefined,
audience: undefined,
};

const result = Pruner.from(root)
Expand Down Expand Up @@ -377,6 +398,7 @@ describe("pruneNavigationTree", () => {
hidden: undefined,
authed: undefined,
noindex: undefined,
audience: undefined,
},
],
collapsed: undefined,
Expand All @@ -385,6 +407,7 @@ describe("pruneNavigationTree", () => {
hidden: undefined,
authed: undefined,
noindex: undefined,
audience: undefined,

// NOTE: points to is updated!
pointsTo: "root/page",
Expand Down
Loading

0 comments on commit 9f3c4ff

Please sign in to comment.