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

Function seedOrg

apps/hash-api/src/seed-data/index.ts:21–68  ·  view source on GitHub ↗
(params: {
  logger: Logger;
  context: ImpureGraphContext<false, true>;
  owner: User;
})

Source from the content-addressed store, hash-verified

19
20// Seed Org with some pages.
21const seedOrg = async (params: {
22 logger: Logger;
23 context: ImpureGraphContext<false, true>;
24 owner: User;
25}): Promise<Org> => {
26 const authentication = { actorId: params.owner.accountId };
27 const { logger, context } = params;
28
29 const exampleOrgShortname = "example-org";
30 const exampleOrgName = "Example";
31
32 const existingOrg = await getOrgByShortname(context, authentication, {
33 shortname: exampleOrgShortname,
34 });
35
36 if (existingOrg) {
37 return existingOrg;
38 }
39
40 const sharedOrg = await createOrg(context, authentication, {
41 name: exampleOrgName,
42 shortname: exampleOrgShortname,
43 });
44
45 logger.info(
46 `Development Org available with shortname = "${sharedOrg.shortname}"`,
47 );
48
49 const pageTitles: PageDefinition[] = [
50 {
51 title: "First",
52 },
53 {
54 title: "Second",
55 },
56 {
57 title: "Third",
58 },
59 ];
60
61 await seedPages(authentication, pageTitles, sharedOrg.webId, params);
62
63 logger.info(
64 `Development Org with shortname = "${sharedOrg.shortname}" now has seeded pages.`,
65 );
66
67 return sharedOrg;
68};
69
70export const seedOrgsAndUsers = async (params: {
71 logger: Logger;

Callers 1

seedOrgsAndUsersFunction · 0.85

Calls 4

getOrgByShortnameFunction · 0.90
createOrgFunction · 0.90
seedPagesFunction · 0.90
infoMethod · 0.80

Tested by

no test coverage detected