MCPcopy Create free account
hub / github.com/hashintel/hash / seedPages

Function seedPages

apps/hash-api/src/seed-data/seed-pages.ts:17–60  ·  view source on GitHub ↗
(
  authentication: AuthenticationContext,
  pageDefinitions: PageDefinition[],
  webId: WebId,
  sharedParams: {
    logger: Logger;
    context: ImpureGraphContext<false, true>;
  },
  parentPage?: Page,
)

Source from the content-addressed store, hash-verified

15};
16
17export const seedPages = async (
18 authentication: AuthenticationContext,
19 pageDefinitions: PageDefinition[],
20 webId: WebId,
21 sharedParams: {
22 logger: Logger;
23 context: ImpureGraphContext<false, true>;
24 },
25 parentPage?: Page,
26) => {
27 const { context } = sharedParams;
28
29 let prevFractionalIndex: string | undefined;
30
31 for (const pageDefinition of pageDefinitions) {
32 const newPage: Page = await createPage(context, authentication, {
33 webId,
34 title: pageDefinition.title,
35 prevFractionalIndex,
36 type: "document",
37 });
38
39 if (parentPage) {
40 await setPageParentPage(context, authentication, {
41 page: newPage,
42 parentPage,
43 prevFractionalIndex: parentPage.fractionalIndex ?? null,
44 nextIndex: null,
45 });
46 }
47
48 prevFractionalIndex = newPage.fractionalIndex;
49
50 if (pageDefinition.nestedPages) {
51 await seedPages(
52 authentication,
53 pageDefinition.nestedPages,
54 webId,
55 sharedParams,
56 newPage,
57 );
58 }
59 }
60};

Callers 2

seedOrgFunction · 0.90
seedOrgsAndUsersFunction · 0.90

Calls 2

createPageFunction · 0.90
setPageParentPageFunction · 0.90

Tested by

no test coverage detected