(params: {
logger: Logger;
context: ImpureGraphContext<false, true>;
owner: User;
})
| 19 | |
| 20 | // Seed Org with some pages. |
| 21 | const 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 | |
| 70 | export const seedOrgsAndUsers = async (params: { |
| 71 | logger: Logger; |
no test coverage detected