Skip to content

Commit

Permalink
merge from develop
Browse files Browse the repository at this point in the history
  • Loading branch information
techsmyth committed Nov 9, 2024
2 parents e4c0df1 + a6855b3 commit 6878843
Show file tree
Hide file tree
Showing 124 changed files with 2,337 additions and 18,998 deletions.
10 changes: 0 additions & 10 deletions alkemio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ hosting:
port: ${WHITEBOARD_RT_PORT}:4001

max_json_payload_size: ${HOSTING_MAX_JSON_PAYLOAD_SIZE}:64mb
## bootstrap ##
# Used to determine the the information that is used to to initialize a functional Alkemio instance.
bootstrap:
# The bootstrap authorization file specifies the minimum set of users and their associated credentials that are always available
# in the Alkemio instance.
#
# Default: the default file that is picked up is: src/services/configuraiton/templates/authorization-bootstrap.json.
authorization:
enabled: ${BOOTSTRAP_AUTHORIZATION_ENABLED}:true
file: ${BOOTSTRAP_AUTHORIZATION_FILE}
# Settings related to the authorization framework
authorization:
# amount of authorization policies saved in a single chunk
Expand Down
2 changes: 0 additions & 2 deletions src/common/enums/authorization.privilege.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export enum AuthorizationPrivilege {
CREATE_INNOVATION_HUB = 'create-innovation-hub',
FILE_UPLOAD = 'file-upload',
FILE_DELETE = 'file-delete',
UPDATE_WHITEBOARD = 'update-whiteboard',
UPDATE_INNOVATION_FLOW = 'update-innovation-flow',
COMMUNITY_JOIN = 'community-join',
COMMUNITY_APPLY = 'community-apply',
Expand All @@ -43,7 +42,6 @@ export enum AuthorizationPrivilege {
MOVE_CONTRIBUTION = 'move-contribution',
ACCESS_INTERACTIVE_GUIDANCE = 'access-interactive-guidance',
ACCESS_VIRTUAL_CONTRIBUTOR = 'access-virtual-contributor',
ACCESS_DASHBOARD_REFRESH = 'access-dashboard-refresh',
UPDATE_CONTENT = 'update-content',
SAVE_AS_TEMPLATE = 'save-as-template',
TRANSFER_RESOURCE = 'transfer-resource',
Expand Down
4 changes: 4 additions & 0 deletions src/core/bootstrap/bootstrap.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { TemplatesSetModule } from '@domain/template/templates-set/templates.set
import { TemplatesManagerModule } from '@domain/template/templates-manager/templates.manager.module';
import { TemplateDefaultModule } from '@domain/template/template-default/template.default.module';
import { LicenseModule } from '@domain/common/license/license.module';
import { LicensePlanModule } from '@platform/license-plan/license.plan.module';
import { LicensingFrameworkModule } from '@platform/licensing-framework/licensing.framework.module';

@Module({
imports: [
Expand All @@ -43,6 +45,8 @@ import { LicenseModule } from '@domain/common/license/license.module';
TemplatesSetModule,
TemplatesManagerModule,
TemplateDefaultModule,
LicensingFrameworkModule,
LicensePlanModule,
],
providers: [BootstrapService],
exports: [BootstrapService],
Expand Down
90 changes: 49 additions & 41 deletions src/core/bootstrap/bootstrap.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { InjectRepository } from '@nestjs/typeorm';
import { SpaceService } from '@domain/space/space/space.service';
import { UserService } from '@domain/community/user/user.service';
import { Repository } from 'typeorm';
import fs from 'fs';
import * as defaultRoles from '@templates/authorization-bootstrap.json';
import * as defaultRoles from './platform-template-definitions/user/users.json';
import * as defaultLicensePlan from './platform-template-definitions/license-plan/license-plans.json';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
import { Profiling } from '@common/decorators';
import { LogContext } from '@common/enums';
Expand Down Expand Up @@ -57,6 +57,8 @@ import { bootstrapSpaceTutorialsCalloutGroups } from './platform-template-defini
import { bootstrapSpaceTutorialsCallouts } from './platform-template-definitions/space-tutorials/bootstrap.space.tutorials.callouts';
import { LicenseService } from '@domain/common/license/license.service';
import { AccountLicenseService } from '@domain/space/account/account.service.license';
import { LicensePlanService } from '@platform/license-plan/license.plan.service';
import { LicensingFrameworkService } from '@platform/licensing-framework/licensing.framework.service';

@Injectable()
export class BootstrapService {
Expand Down Expand Up @@ -85,7 +87,9 @@ export class BootstrapService {
private templatesSetService: TemplatesSetService,
private templateDefaultService: TemplateDefaultService,
private accountLicenseService: AccountLicenseService,
private licenseService: LicenseService
private licenseService: LicenseService,
private licensingFrameworkService: LicensingFrameworkService,
private licensePlanService: LicensePlanService
) {}

async bootstrap() {
Expand All @@ -103,6 +107,7 @@ export class BootstrapService {
}

await this.bootstrapUserProfiles();
await this.bootstrapLicensePlans();
await this.platformService.ensureForumCreated();
await this.ensureAuthorizationsPopulated();
await this.ensurePlatformTemplatesArePresent();
Expand Down Expand Up @@ -234,59 +239,62 @@ export class BootstrapService {
}

async bootstrapUserProfiles() {
const bootstrapAuthorizationEnabled = this.configService.get(
'bootstrap.authorization.enabled',
{ infer: true }
const bootstrapAuthorizationRolesJson = {
...defaultRoles,
};

this.logger.verbose?.(
'Authorization bootstrap: default configuration being loaded',
LogContext.BOOTSTRAP
);
if (!bootstrapAuthorizationEnabled) {

const users = bootstrapAuthorizationRolesJson.users;
if (!users) {
this.logger.verbose?.(
`Authorization Profile Loading: ${bootstrapAuthorizationEnabled}`,
'No users section in the authorization bootstrap file!',
LogContext.BOOTSTRAP
);
return;
} else {
await this.createUserProfiles(users);
}
}

const bootstrapFilePath = this.configService.get(
'bootstrap.authorization.file',
{ infer: true }
);

let bootstrapJson = {
...defaultRoles,
async bootstrapLicensePlans() {
const bootstrapLicensePlans = {
...defaultLicensePlan,
};

if (
bootstrapFilePath &&
fs.existsSync(bootstrapFilePath) &&
fs.statSync(bootstrapFilePath).isFile()
) {
const licensePlans = bootstrapLicensePlans.licensePlans;
if (!licensePlans) {
this.logger.verbose?.(
`Authorization bootstrap: configuration being loaded from '${bootstrapFilePath}'`,
'No licensePlans section in the license plans bootstrap file!',
LogContext.BOOTSTRAP
);
const bootstratDataStr = fs.readFileSync(bootstrapFilePath).toString();
this.logger.verbose?.(bootstratDataStr);
if (!bootstratDataStr) {
throw new BootstrapException(
'Specified authorization bootstrap file not found!'
);
}
bootstrapJson = JSON.parse(bootstratDataStr);
} else {
this.logger.verbose?.(
'Authorization bootstrap: default configuration being loaded',
LogContext.BOOTSTRAP
);
await this.createLicensePlans(licensePlans);
}
}

const users = bootstrapJson.users;
if (!users) {
this.logger.verbose?.(
'No users section in the authorization bootstrap file!',
LogContext.BOOTSTRAP
async createLicensePlans(licensePlansData: any[]) {
try {
const licensing =
await this.licensingFrameworkService.getDefaultLicensingOrFail();
for (const licensePlanData of licensePlansData) {
const planExists =
await this.licensePlanService.licensePlanByNameExists(
licensePlanData.type
);
if (!planExists) {
await this.licensingFrameworkService.createLicensePlan({
...licensePlanData,
licensingID: licensing.id,
});
}
}
} catch (error: any) {
throw new BootstrapException(
`Unable to create license plans ${error.message}`
);
} else {
await this.createUserProfiles(users);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"licensePlans": [
{
"name": "SPACE_LICENSE_PREMIUM",
"enabled": "1",
"sortOrder": "30",
"pricePerMonth": "749.00",
"isFree": "0",
"trialEnabled": "0",
"requiresPaymentMethod": "0",
"requiresContactSupport": "1",
"licenseCredential": "space-license-premium",
"assignToNewOrganizationAccounts": "0",
"assignToNewUserAccounts": "0",
"type": "space-plan"
},
{
"name": "SPACE_LICENSE_PLUS",
"enabled": "1",
"sortOrder": "20",
"pricePerMonth": "249.00",
"isFree": "0",
"trialEnabled": "1",
"requiresPaymentMethod": "0",
"requiresContactSupport": "0",
"licenseCredential": "space-license-plus",
"assignToNewOrganizationAccounts": "0",
"assignToNewUserAccounts": "0",
"type": "space-plan"
},
{
"name": "SPACE_LICENSE_FREE",
"enabled": "1",
"sortOrder": "10",
"pricePerMonth": "0.00",
"isFree": "1",
"trialEnabled": "0",
"requiresPaymentMethod": "0",
"requiresContactSupport": "0",
"licenseCredential": "space-license-free",
"assignToNewOrganizationAccounts": "1",
"assignToNewUserAccounts": "1",
"type": "space-plan"
},
{
"name": "SPACE_FEATURE_WHITEBOARD_MULTI_USER",
"enabled": "1",
"sortOrder": "50",
"pricePerMonth": "0.00",
"isFree": "1",
"trialEnabled": "0",
"requiresPaymentMethod": "0",
"requiresContactSupport": "1",
"licenseCredential": "space-feature-whiteboard-multi-user",
"assignToNewOrganizationAccounts": "0",
"assignToNewUserAccounts": "0",
"type": "space-feature-flag"
},
{
"name": "ACCOUNT_LICENSE_PLUS",
"enabled": "1",
"sortOrder": "50",
"pricePerMonth": "0.00",
"isFree": "0",
"trialEnabled": "0",
"requiresPaymentMethod": "0",
"requiresContactSupport": "1",
"licenseCredential": "account-license-plus",
"assignToNewOrganizationAccounts": "0",
"assignToNewUserAccounts": "0",
"type": "account-plan"
},
{
"name": "SPACE_FEATURE_VIRTUAL_CONTIBUTORS",
"enabled": "1",
"sortOrder": "70",
"pricePerMonth": "0.00",
"isFree": "1",
"trialEnabled": "0",
"requiresPaymentMethod": "0",
"requiresContactSupport": "1",
"licenseCredential": "space-feature-virtual-contributors",
"assignToNewOrganizationAccounts": "1",
"assignToNewUserAccounts": "1",
"type": "space-feature-flag"
},
{
"name": "SPACE_LICENSE_ENTERPRISE",
"enabled": "1",
"sortOrder": "40",
"pricePerMonth": null,
"isFree": "0",
"trialEnabled": "0",
"requiresPaymentMethod": "0",
"requiresContactSupport": "1",
"licenseCredential": "space-license-enterprise",
"assignToNewOrganizationAccounts": "0",
"assignToNewUserAccounts": "0",
"type": "space-plan"
},
{
"name": "SPACE_FEATURE_SAVE_AS_TEMPLATE",
"enabled": "1",
"sortOrder": "60",
"pricePerMonth": "0.00",
"isFree": "1",
"trialEnabled": "0",
"requiresPaymentMethod": "0",
"requiresContactSupport": "1",
"licenseCredential": "space-feature-save-as-template",
"assignToNewOrganizationAccounts": "1",
"assignToNewUserAccounts": "1",
"type": "space-feature-flag"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CalloutGroupName } from '@common/enums/callout.group.name';
import { TagsetReservedName } from '@common/enums/tagset.reserved.name';
import { FlowState } from './bootstrap.space.tutorials.innovation.flow.states';
import { CreateCalloutInput } from '@domain/collaboration/callout/dto/callout.dto.create';
import { CalloutVisibility } from '@common/enums/callout.visibility';

export const bootstrapSpaceTutorialsCallouts: CreateCalloutInput[] = [
{
Expand All @@ -15,6 +16,7 @@ export const bootstrapSpaceTutorialsCallouts: CreateCalloutInput[] = [
},
sortOrder: 1,
groupName: CalloutGroupName.HOME,
visibility: CalloutVisibility.PUBLISHED,
framing: {
profile: {
displayName: '👋 Welcome to your space!',
Expand All @@ -37,6 +39,7 @@ export const bootstrapSpaceTutorialsCallouts: CreateCalloutInput[] = [
},
sortOrder: 2,
groupName: CalloutGroupName.HOME,
visibility: CalloutVisibility.PUBLISHED,
framing: {
profile: {
displayName: '⚙️ Set it up your way!',
Expand All @@ -59,6 +62,7 @@ export const bootstrapSpaceTutorialsCallouts: CreateCalloutInput[] = [
},
sortOrder: 3,
groupName: CalloutGroupName.HOME,
visibility: CalloutVisibility.PUBLISHED,
framing: {
profile: {
displayName: '🧩 Collaboration tools',
Expand All @@ -81,6 +85,7 @@ export const bootstrapSpaceTutorialsCallouts: CreateCalloutInput[] = [
},
sortOrder: 4,
groupName: CalloutGroupName.HOME,
visibility: CalloutVisibility.PUBLISHED,
framing: {
profile: {
displayName: '🧹 Cleaning up',
Expand All @@ -103,6 +108,7 @@ export const bootstrapSpaceTutorialsCallouts: CreateCalloutInput[] = [
},
sortOrder: 1,
groupName: CalloutGroupName.COMMUNITY,
visibility: CalloutVisibility.PUBLISHED,
framing: {
profile: {
displayName: '🤝 Set up your Community',
Expand All @@ -125,6 +131,7 @@ export const bootstrapSpaceTutorialsCallouts: CreateCalloutInput[] = [
},
sortOrder: 1,
groupName: CalloutGroupName.SUBSPACES,
visibility: CalloutVisibility.PUBLISHED,
framing: {
profile: {
displayName: '↪️ Subspaces',
Expand All @@ -147,6 +154,7 @@ export const bootstrapSpaceTutorialsCallouts: CreateCalloutInput[] = [
},
sortOrder: 1,
groupName: CalloutGroupName.KNOWLEDGE,
visibility: CalloutVisibility.PUBLISHED,
framing: {
profile: {
displayName: '📚 The Knowledge Base',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CalloutGroupName } from '@common/enums/callout.group.name';
import { TagsetReservedName } from '@common/enums/tagset.reserved.name';
import { FlowState } from './bootstrap.space.innovation.flow';
import { CreateCalloutInput } from '@domain/collaboration/callout/dto/callout.dto.create';
import { CalloutVisibility } from '@common/enums/callout.visibility';

export const bootstrapSpaceCallouts: CreateCalloutInput[] = [
{
Expand All @@ -15,6 +16,7 @@ export const bootstrapSpaceCallouts: CreateCalloutInput[] = [
},
sortOrder: 1,
groupName: CalloutGroupName.HOME,
visibility: CalloutVisibility.PUBLISHED,
framing: {
profile: {
displayName: '👋 Welcome to your space!',
Expand Down
Loading

0 comments on commit 6878843

Please sign in to comment.