@headless-lms/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/assets/events.d.ts +81 -0
- package/dist/assets/events.js +24 -0
- package/dist/assets/events.js.map +1 -0
- package/dist/assets/index.d.ts +7 -0
- package/dist/assets/index.js +3 -0
- package/dist/assets/model.d.ts +4 -0
- package/dist/assets/model.js +1 -0
- package/dist/assets/ports.d.ts +34 -0
- package/dist/assets/ports.js +1 -0
- package/dist/assets/service.d.ts +29 -0
- package/dist/assets/service.js +130 -0
- package/dist/assets/service.js.map +1 -0
- package/dist/automations/actions.d.ts +24 -0
- package/dist/automations/actions.js +59 -0
- package/dist/automations/actions.js.map +1 -0
- package/dist/automations/catalog.d.ts +12 -0
- package/dist/automations/catalog.js +224 -0
- package/dist/automations/catalog.js.map +1 -0
- package/dist/automations/events.d.ts +264 -0
- package/dist/automations/events.js +54 -0
- package/dist/automations/events.js.map +1 -0
- package/dist/automations/index.d.ts +9 -0
- package/dist/automations/index.js +4 -0
- package/dist/automations/model.d.ts +12 -0
- package/dist/automations/model.js +14 -0
- package/dist/automations/model.js.map +1 -0
- package/dist/automations/ports.d.ts +56 -0
- package/dist/automations/ports.js +1 -0
- package/dist/automations/service.d.ts +53 -0
- package/dist/automations/service.js +225 -0
- package/dist/automations/service.js.map +1 -0
- package/dist/automations/types.d.ts +3 -0
- package/dist/automations/types.js +1 -0
- package/dist/content/events.d.ts +410 -0
- package/dist/content/events.js +105 -0
- package/dist/content/events.js.map +1 -0
- package/dist/content/index.d.ts +8 -0
- package/dist/content/index.js +3 -0
- package/dist/content/model.d.ts +3 -0
- package/dist/content/model.js +1 -0
- package/dist/content/ports.d.ts +85 -0
- package/dist/content/ports.js +1 -0
- package/dist/content/service.d.ts +54 -0
- package/dist/content/service.js +479 -0
- package/dist/content/service.js.map +1 -0
- package/dist/content/types.d.ts +4 -0
- package/dist/content/types.js +1 -0
- package/dist/discussion/events.d.ts +101 -0
- package/dist/discussion/events.js +29 -0
- package/dist/discussion/events.js.map +1 -0
- package/dist/discussion/index.d.ts +8 -0
- package/dist/discussion/index.js +3 -0
- package/dist/discussion/model.d.ts +5 -0
- package/dist/discussion/model.js +1 -0
- package/dist/discussion/ports.d.ts +112 -0
- package/dist/discussion/ports.js +1 -0
- package/dist/discussion/service.d.ts +67 -0
- package/dist/discussion/service.js +343 -0
- package/dist/discussion/service.js.map +1 -0
- package/dist/discussion/types.d.ts +4 -0
- package/dist/discussion/types.js +1 -0
- package/dist/entitlements/events.d.ts +89 -0
- package/dist/entitlements/events.js +29 -0
- package/dist/entitlements/events.js.map +1 -0
- package/dist/entitlements/index.d.ts +7 -0
- package/dist/entitlements/index.js +3 -0
- package/dist/entitlements/model.d.ts +4 -0
- package/dist/entitlements/model.js +1 -0
- package/dist/entitlements/ports.d.ts +34 -0
- package/dist/entitlements/ports.js +1 -0
- package/dist/entitlements/service.d.ts +27 -0
- package/dist/entitlements/service.js +60 -0
- package/dist/entitlements/service.js.map +1 -0
- package/dist/identity/events.d.ts +63 -0
- package/dist/identity/events.js +24 -0
- package/dist/identity/events.js.map +1 -0
- package/dist/identity/index.d.ts +8 -0
- package/dist/identity/index.js +3 -0
- package/dist/identity/model.d.ts +3 -0
- package/dist/identity/model.js +1 -0
- package/dist/identity/ports.d.ts +58 -0
- package/dist/identity/ports.js +1 -0
- package/dist/identity/service.d.ts +38 -0
- package/dist/identity/service.js +79 -0
- package/dist/identity/service.js.map +1 -0
- package/dist/identity/types.d.ts +4 -0
- package/dist/identity/types.js +1 -0
- package/dist/integrations/events.d.ts +70 -0
- package/dist/integrations/events.js +24 -0
- package/dist/integrations/events.js.map +1 -0
- package/dist/integrations/index.d.ts +9 -0
- package/dist/integrations/index.js +6 -0
- package/dist/integrations/model.d.ts +28 -0
- package/dist/integrations/model.js +45 -0
- package/dist/integrations/model.js.map +1 -0
- package/dist/integrations/ports.d.ts +62 -0
- package/dist/integrations/ports.js +1 -0
- package/dist/integrations/registry.d.ts +7 -0
- package/dist/integrations/registry.js +16 -0
- package/dist/integrations/registry.js.map +1 -0
- package/dist/integrations/service.d.ts +47 -0
- package/dist/integrations/service.js +184 -0
- package/dist/integrations/service.js.map +1 -0
- package/dist/integrations/zod.d.ts +29 -0
- package/dist/integrations/zod.js +40 -0
- package/dist/integrations/zod.js.map +1 -0
- package/dist/organizations/events.d.ts +197 -0
- package/dist/organizations/events.js +59 -0
- package/dist/organizations/events.js.map +1 -0
- package/dist/organizations/index.d.ts +11 -0
- package/dist/organizations/index.js +5 -0
- package/dist/organizations/members.d.ts +32 -0
- package/dist/organizations/members.js +12 -0
- package/dist/organizations/members.js.map +1 -0
- package/dist/organizations/model.d.ts +3 -0
- package/dist/organizations/model.js +1 -0
- package/dist/organizations/ports.d.ts +127 -0
- package/dist/organizations/ports.js +1 -0
- package/dist/organizations/roles.d.ts +23 -0
- package/dist/organizations/roles.js +70 -0
- package/dist/organizations/roles.js.map +1 -0
- package/dist/organizations/service.d.ts +58 -0
- package/dist/organizations/service.js +359 -0
- package/dist/organizations/service.js.map +1 -0
- package/dist/organizations/types.d.ts +39 -0
- package/dist/organizations/types.js +1 -0
- package/dist/progress/events.d.ts +55 -0
- package/dist/progress/events.js +19 -0
- package/dist/progress/events.js.map +1 -0
- package/dist/progress/index.d.ts +8 -0
- package/dist/progress/index.js +3 -0
- package/dist/progress/model.d.ts +3 -0
- package/dist/progress/model.js +1 -0
- package/dist/progress/ports.d.ts +37 -0
- package/dist/progress/ports.js +1 -0
- package/dist/progress/service.d.ts +33 -0
- package/dist/progress/service.js +181 -0
- package/dist/progress/service.js.map +1 -0
- package/dist/progress/types.d.ts +4 -0
- package/dist/progress/types.js +1 -0
- package/dist/reporting/dashboard/index.d.ts +4 -0
- package/dist/reporting/dashboard/index.js +2 -0
- package/dist/reporting/dashboard/model.d.ts +14 -0
- package/dist/reporting/dashboard/model.js +1 -0
- package/dist/reporting/dashboard/ports.d.ts +13 -0
- package/dist/reporting/dashboard/ports.js +1 -0
- package/dist/reporting/dashboard/service.d.ts +19 -0
- package/dist/reporting/dashboard/service.js +20 -0
- package/dist/reporting/dashboard/service.js.map +1 -0
- package/dist/reporting/learn/index.d.ts +5 -0
- package/dist/reporting/learn/index.js +2 -0
- package/dist/reporting/learn/model.d.ts +23 -0
- package/dist/reporting/learn/model.js +1 -0
- package/dist/reporting/learn/ports.d.ts +42 -0
- package/dist/reporting/learn/ports.js +1 -0
- package/dist/reporting/learn/service.d.ts +48 -0
- package/dist/reporting/learn/service.js +111 -0
- package/dist/reporting/learn/service.js.map +1 -0
- package/dist/reporting/students/index.d.ts +4 -0
- package/dist/reporting/students/index.js +2 -0
- package/dist/reporting/students/model.d.ts +31 -0
- package/dist/reporting/students/model.js +1 -0
- package/dist/reporting/students/ports.d.ts +13 -0
- package/dist/reporting/students/ports.js +1 -0
- package/dist/reporting/students/service.d.ts +19 -0
- package/dist/reporting/students/service.js +20 -0
- package/dist/reporting/students/service.js.map +1 -0
- package/dist/shared/errors.d.ts +22 -0
- package/dist/shared/errors.js +34 -0
- package/dist/shared/errors.js.map +1 -0
- package/dist/shared/events.d.ts +31 -0
- package/dist/shared/events.js +75 -0
- package/dist/shared/events.js.map +1 -0
- package/dist/shared/id.d.ts +44 -0
- package/dist/shared/id.js +53 -0
- package/dist/shared/id.js.map +1 -0
- package/dist/shared/invite-token.d.ts +9 -0
- package/dist/shared/invite-token.js +16 -0
- package/dist/shared/invite-token.js.map +1 -0
- package/dist/shared/logger.d.ts +19 -0
- package/dist/shared/logger.js +44 -0
- package/dist/shared/logger.js.map +1 -0
- package/dist/shared/mailer.d.ts +23 -0
- package/dist/shared/mailer.js +27 -0
- package/dist/shared/mailer.js.map +1 -0
- package/dist/shared/ports.d.ts +62 -0
- package/dist/shared/ports.js +2 -0
- package/dist/shared/settings.d.ts +25 -0
- package/dist/shared/settings.js +21 -0
- package/dist/shared/settings.js.map +1 -0
- package/dist/types/assets.d.ts +2 -0
- package/dist/types/assets.js +1 -0
- package/dist/types/automations.d.ts +23 -0
- package/dist/types/automations.js +1 -0
- package/dist/types/content.d.ts +2 -0
- package/dist/types/content.js +1 -0
- package/dist/types/discussion.d.ts +36 -0
- package/dist/types/discussion.js +1 -0
- package/dist/types/email-templates.d.ts +57 -0
- package/dist/types/email-templates.js +1 -0
- package/dist/types/entitlements.d.ts +3 -0
- package/dist/types/entitlements.js +1 -0
- package/dist/types/events.d.ts +25 -0
- package/dist/types/events.js +1 -0
- package/dist/types/identity.d.ts +37 -0
- package/dist/types/identity.js +1 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/index.js +1 -0
- package/dist/types/integrations.d.ts +45 -0
- package/dist/types/integrations.js +1 -0
- package/dist/types/organizations.d.ts +15 -0
- package/dist/types/organizations.js +1 -0
- package/dist/types/ports.d.ts +57 -0
- package/dist/types/ports.js +1 -0
- package/dist/types/progress.d.ts +6 -0
- package/dist/types/progress.js +1 -0
- package/dist/types/schemas/assets.d.ts +109 -0
- package/dist/types/schemas/assets.js +49 -0
- package/dist/types/schemas/assets.js.map +1 -0
- package/dist/types/schemas/automations.d.ts +118 -0
- package/dist/types/schemas/automations.js +73 -0
- package/dist/types/schemas/automations.js.map +1 -0
- package/dist/types/schemas/content.d.ts +216 -0
- package/dist/types/schemas/content.js +138 -0
- package/dist/types/schemas/content.js.map +1 -0
- package/dist/types/schemas/credentials.d.ts +15 -0
- package/dist/types/schemas/credentials.js +15 -0
- package/dist/types/schemas/credentials.js.map +1 -0
- package/dist/types/schemas/discussion.d.ts +192 -0
- package/dist/types/schemas/discussion.js +100 -0
- package/dist/types/schemas/discussion.js.map +1 -0
- package/dist/types/schemas/entitlements.d.ts +50 -0
- package/dist/types/schemas/entitlements.js +38 -0
- package/dist/types/schemas/entitlements.js.map +1 -0
- package/dist/types/schemas/identity.d.ts +37 -0
- package/dist/types/schemas/identity.js +34 -0
- package/dist/types/schemas/identity.js.map +1 -0
- package/dist/types/schemas/index.d.ts +14 -0
- package/dist/types/schemas/index.js +14 -0
- package/dist/types/schemas/integrations.d.ts +36 -0
- package/dist/types/schemas/integrations.js +30 -0
- package/dist/types/schemas/integrations.js.map +1 -0
- package/dist/types/schemas/organizations.d.ts +135 -0
- package/dist/types/schemas/organizations.js +90 -0
- package/dist/types/schemas/organizations.js.map +1 -0
- package/dist/types/schemas/outbox.d.ts +19 -0
- package/dist/types/schemas/outbox.js +18 -0
- package/dist/types/schemas/outbox.js.map +1 -0
- package/dist/types/schemas/progress.d.ts +53 -0
- package/dist/types/schemas/progress.js +37 -0
- package/dist/types/schemas/progress.js.map +1 -0
- package/dist/types/schemas/settings.d.ts +16 -0
- package/dist/types/schemas/settings.js +15 -0
- package/dist/types/schemas/settings.js.map +1 -0
- package/dist/types/schemas/shared.d.ts +13 -0
- package/dist/types/schemas/shared.js +28 -0
- package/dist/types/schemas/shared.js.map +1 -0
- package/dist/types/shared.d.ts +25 -0
- package/dist/types/shared.js +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { inviteSchema, orgUserSchema, organizationSchema } from "../types/schemas/organizations.js";
|
|
2
|
+
import { defineEvent } from "../shared/events.js";
|
|
3
|
+
//#region src/organizations/events.ts
|
|
4
|
+
const organizationEvents = {
|
|
5
|
+
organizationCreated: defineEvent({
|
|
6
|
+
type: "organization.created",
|
|
7
|
+
version: 1,
|
|
8
|
+
data: organizationSchema
|
|
9
|
+
}),
|
|
10
|
+
organizationUpdated: defineEvent({
|
|
11
|
+
type: "organization.updated",
|
|
12
|
+
version: 1,
|
|
13
|
+
data: organizationSchema
|
|
14
|
+
}),
|
|
15
|
+
organizationDeleted: defineEvent({
|
|
16
|
+
type: "organization.deleted",
|
|
17
|
+
version: 1,
|
|
18
|
+
data: organizationSchema
|
|
19
|
+
}),
|
|
20
|
+
orgUserLinked: defineEvent({
|
|
21
|
+
type: "organization.user.linked",
|
|
22
|
+
version: 1,
|
|
23
|
+
data: orgUserSchema
|
|
24
|
+
}),
|
|
25
|
+
orgUserDeleted: defineEvent({
|
|
26
|
+
type: "organization.user.deleted",
|
|
27
|
+
version: 1,
|
|
28
|
+
data: orgUserSchema
|
|
29
|
+
}),
|
|
30
|
+
inviteCreated: defineEvent({
|
|
31
|
+
type: "organization.invite.created",
|
|
32
|
+
version: 1,
|
|
33
|
+
data: inviteSchema
|
|
34
|
+
}),
|
|
35
|
+
inviteAccepted: defineEvent({
|
|
36
|
+
type: "organization.invite.accepted",
|
|
37
|
+
version: 1,
|
|
38
|
+
data: inviteSchema
|
|
39
|
+
}),
|
|
40
|
+
studentCreated: defineEvent({
|
|
41
|
+
type: "organization.student.created",
|
|
42
|
+
version: 1,
|
|
43
|
+
data: orgUserSchema
|
|
44
|
+
}),
|
|
45
|
+
studentDeleted: defineEvent({
|
|
46
|
+
type: "organization.student.deleted",
|
|
47
|
+
version: 1,
|
|
48
|
+
data: orgUserSchema
|
|
49
|
+
}),
|
|
50
|
+
studentLinked: defineEvent({
|
|
51
|
+
type: "organization.student.linked",
|
|
52
|
+
version: 1,
|
|
53
|
+
data: orgUserSchema
|
|
54
|
+
})
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { organizationEvents };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","names":[],"sources":["../../src/organizations/events.ts"],"sourcesContent":["import {\n inviteSchema,\n organizationSchema,\n orgUserSchema,\n} from '../types/schemas/index.js';\nimport { defineEvent, type EventOf, type EventOfValues } from '../shared/ports.js';\n\nexport const organizationEvents = {\n organizationCreated: defineEvent({\n type: 'organization.created',\n version: 1,\n data: organizationSchema,\n }),\n organizationUpdated: defineEvent({\n type: 'organization.updated',\n version: 1,\n data: organizationSchema,\n }),\n organizationDeleted: defineEvent({\n type: 'organization.deleted',\n version: 1,\n data: organizationSchema,\n }),\n orgUserLinked: defineEvent({\n type: 'organization.user.linked',\n version: 1,\n data: orgUserSchema,\n }),\n orgUserDeleted: defineEvent({\n type: 'organization.user.deleted',\n version: 1,\n data: orgUserSchema,\n }),\n inviteCreated: defineEvent({\n type: 'organization.invite.created',\n version: 1,\n data: inviteSchema,\n }),\n inviteAccepted: defineEvent({\n type: 'organization.invite.accepted',\n version: 1,\n data: inviteSchema,\n }),\n studentCreated: defineEvent({\n type: 'organization.student.created',\n version: 1,\n data: orgUserSchema,\n }),\n studentDeleted: defineEvent({\n type: 'organization.student.deleted',\n version: 1,\n data: orgUserSchema,\n }),\n studentLinked: defineEvent({\n type: 'organization.student.linked',\n version: 1,\n data: orgUserSchema,\n }),\n};\n\nexport type OrganizationCreated = EventOf<typeof organizationEvents.organizationCreated>;\nexport type OrganizationUpdated = EventOf<typeof organizationEvents.organizationUpdated>;\nexport type OrganizationDeleted = EventOf<typeof organizationEvents.organizationDeleted>;\nexport type OrgUserLinked = EventOf<typeof organizationEvents.orgUserLinked>;\nexport type OrgUserDeleted = EventOf<typeof organizationEvents.orgUserDeleted>;\nexport type InviteCreated = EventOf<typeof organizationEvents.inviteCreated>;\nexport type InviteAccepted = EventOf<typeof organizationEvents.inviteAccepted>;\nexport type StudentCreated = EventOf<typeof organizationEvents.studentCreated>;\nexport type StudentDeleted = EventOf<typeof organizationEvents.studentDeleted>;\nexport type StudentLinked = EventOf<typeof organizationEvents.studentLinked>;\nexport type OrganizationEvent = EventOfValues<typeof organizationEvents>;\n"],"mappings":";;;AAOA,MAAa,qBAAqB;CAChC,qBAAqB,YAAY;EAC/B,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,qBAAqB,YAAY;EAC/B,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,qBAAqB,YAAY;EAC/B,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,eAAe,YAAY;EACzB,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,gBAAgB,YAAY;EAC1B,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,eAAe,YAAY;EACzB,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,gBAAgB,YAAY;EAC1B,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,gBAAgB,YAAY;EAC1B,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,gBAAgB,YAAY;EAC1B,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CACD,eAAe,YAAY;EACzB,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;AACH"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AcceptInviteInput, AddOrgUserInput, CreateInviteInput, CreateOrgUserInput, Invite, InviteRole, NewOrganizationInput, OrgUser, OrgUserStatus, Organization, Role } from "../types/schemas/organizations.js";
|
|
2
|
+
import { InviteId, OrgUserId, OrganizationId } from "../types/organizations.js";
|
|
3
|
+
import { AuthHeaders } from "../identity/ports.js";
|
|
4
|
+
import { InviteAccepted, InviteCreated, OrgUserDeleted, OrgUserLinked, OrganizationCreated, OrganizationDeleted, OrganizationEvent, OrganizationUpdated, StudentCreated, StudentDeleted, StudentLinked, organizationEvents } from "./events.js";
|
|
5
|
+
import "./model.js";
|
|
6
|
+
import { Capability, Permission, ROLES, STAFF_ROLES, STUDENT_ROLE, StaffRole, capability, isRole, isStaffRole, normalizeRole, parseRole } from "./roles.js";
|
|
7
|
+
import { Member, MemberStatus, MembersQuery, OrganizationRuleError, Page } from "./members.js";
|
|
8
|
+
import { CreateOrganizationInput, LinkOrgUserInput, ResendStudentInviteInput, UnlinkOrgUserInput, UpdateOrganizationInput, UpdatePersonInput, UpdateStudentInput } from "./types.js";
|
|
9
|
+
import { AuthOrganization, MemberRecord, MemberWriteContext, MembersRepository, NewInviteRow, NewOrganizationRow, OrgAdmin, OrganizationService, OrganizationsRepository } from "./ports.js";
|
|
10
|
+
import { OrganizationServiceImpl } from "./service.js";
|
|
11
|
+
export { type AcceptInviteInput, type AddOrgUserInput, type AuthHeaders, type AuthOrganization, type Capability, type CreateInviteInput, type CreateOrgUserInput, type CreateOrganizationInput, type Invite, type InviteAccepted, type InviteCreated, type InviteId, type InviteRole, type LinkOrgUserInput, type Member, type MemberRecord, type MemberStatus, type MemberWriteContext, type MembersQuery, type MembersRepository, type NewInviteRow, type NewOrganizationInput, type NewOrganizationRow, type OrgAdmin, type OrgUser, type OrgUserDeleted, type OrgUserId, type OrgUserLinked, type OrgUserStatus, type Organization, type OrganizationCreated, type OrganizationDeleted, type OrganizationEvent, type OrganizationId, OrganizationRuleError, type OrganizationService, OrganizationServiceImpl, type OrganizationUpdated, type OrganizationsRepository, type Page, type Permission, ROLES, type ResendStudentInviteInput, type Role, STAFF_ROLES, STUDENT_ROLE, type StaffRole, type StudentCreated, type StudentDeleted, type StudentLinked, type UnlinkOrgUserInput, type UpdateOrganizationInput, type UpdatePersonInput, type UpdateStudentInput, capability, isRole, isStaffRole, normalizeRole, organizationEvents, parseRole };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ROLES, STAFF_ROLES, STUDENT_ROLE, capability, isRole, isStaffRole, normalizeRole, parseRole } from "./roles.js";
|
|
2
|
+
import { OrganizationRuleError } from "./members.js";
|
|
3
|
+
import { organizationEvents } from "./events.js";
|
|
4
|
+
import { OrganizationServiceImpl } from "./service.js";
|
|
5
|
+
export { OrganizationRuleError, OrganizationServiceImpl, ROLES, STAFF_ROLES, STUDENT_ROLE, capability, isRole, isStaffRole, normalizeRole, organizationEvents, parseRole };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { OrgUserProfile } from "../types/schemas/organizations.js";
|
|
2
|
+
import "../types/index.js";
|
|
3
|
+
import { StaffRole } from "./roles.js";
|
|
4
|
+
//#region src/organizations/members.d.ts
|
|
5
|
+
type MemberStatus = 'active' | 'invited';
|
|
6
|
+
interface Member extends OrgUserProfile {
|
|
7
|
+
role: StaffRole;
|
|
8
|
+
status: MemberStatus;
|
|
9
|
+
joinedAt: string | null;
|
|
10
|
+
invitedAt: string | null;
|
|
11
|
+
}
|
|
12
|
+
interface MembersQuery {
|
|
13
|
+
page: number;
|
|
14
|
+
pageSize: number;
|
|
15
|
+
search?: string | undefined;
|
|
16
|
+
sort?: string | undefined;
|
|
17
|
+
role?: StaffRole | undefined;
|
|
18
|
+
status?: MemberStatus | undefined;
|
|
19
|
+
}
|
|
20
|
+
interface Page<T> {
|
|
21
|
+
rows: T[];
|
|
22
|
+
total: number;
|
|
23
|
+
page: number;
|
|
24
|
+
pageSize: number;
|
|
25
|
+
}
|
|
26
|
+
declare class OrganizationRuleError extends Error {}
|
|
27
|
+
declare class InviteError extends Error {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { InviteError, Member, MemberStatus, MembersQuery, OrganizationRuleError, Page };
|
|
32
|
+
//# sourceMappingURL=members.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/organizations/members.ts
|
|
2
|
+
var OrganizationRuleError = class extends Error {};
|
|
3
|
+
var InviteError = class extends Error {
|
|
4
|
+
constructor(message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "InviteError";
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { InviteError, OrganizationRuleError };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=members.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"members.js","names":[],"sources":["../../src/organizations/members.ts"],"sourcesContent":["// organizations context — member-management types (invite / change-role / remove).\n// The operational surface over the org's members and pending invites. Roles\n// come from ./roles.ts (the single role model); writes go through Better Auth.\nimport type { StaffRole } from './roles.js';\nimport type { OrgUserProfile } from '../types/index.js';\n\nexport type MemberStatus = 'active' | 'invited';\n\nexport interface Member extends OrgUserProfile {\n role: StaffRole;\n status: MemberStatus;\n joinedAt: string | null;\n invitedAt: string | null;\n}\n\nexport interface MembersQuery {\n page: number;\n pageSize: number;\n search?: string | undefined;\n sort?: string | undefined;\n role?: StaffRole | undefined;\n status?: MemberStatus | undefined;\n}\n\nexport interface Page<T> {\n rows: T[];\n total: number;\n page: number;\n pageSize: number;\n}\n\n\nexport class OrganizationRuleError extends Error {}\nexport class InviteError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'InviteError';\n }\n}\n"],"mappings":";AAgCA,IAAa,wBAAb,cAA2C,MAAM,CAAC;AAClD,IAAa,cAAb,cAAiC,MAAM;CACrC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { AcceptInviteInput, AddOrgUserInput, CreateInviteInput, CreateOrgUserInput, Invite, InviteRole, NewOrganizationInput, OrgUser, Organization, Role } from "../types/schemas/organizations.js";
|
|
2
|
+
import { OutboxAppender, UnitOfWork } from "../shared/ports.js";
|
|
3
|
+
import { AuthHeaders } from "../identity/ports.js";
|
|
4
|
+
import "../identity/index.js";
|
|
5
|
+
import "./model.js";
|
|
6
|
+
import "./roles.js";
|
|
7
|
+
import { Member, MembersQuery, Page } from "./members.js";
|
|
8
|
+
import { CreateOrganizationInput, ResendStudentInviteInput, UpdateOrganizationInput, UpdateStudentInput } from "./types.js";
|
|
9
|
+
//#region src/organizations/ports.d.ts
|
|
10
|
+
interface OrganizationService {
|
|
11
|
+
createOrganization(input: CreateOrganizationInput): Promise<Organization>;
|
|
12
|
+
updateOrganization(id: string, input: UpdateOrganizationInput): Promise<Organization>;
|
|
13
|
+
deleteOrganization(id: string): Promise<Organization>;
|
|
14
|
+
addOrgUser(input: AddOrgUserInput): Promise<OrgUser>;
|
|
15
|
+
removeOrgUser(orgId: string, id: string): Promise<OrgUser>;
|
|
16
|
+
getByExternalId(externalId: string): Promise<Organization | null>;
|
|
17
|
+
getOrgUser(orgId: string, userId: string): Promise<OrgUser | null>;
|
|
18
|
+
getOrgUsersForUser(userId: string): Promise<OrgUser[]>;
|
|
19
|
+
getById(id: string): Promise<Organization | null>;
|
|
20
|
+
createInvite(input: CreateInviteInput): Promise<Invite>;
|
|
21
|
+
peekInvite(token: string): Promise<Invite | null>;
|
|
22
|
+
acceptInvite(input: AcceptInviteInput): Promise<OrgUser>;
|
|
23
|
+
deleteOrgUser(orgId: string, id: string): Promise<OrgUser>;
|
|
24
|
+
resendStudentInvite(input: ResendStudentInviteInput): Promise<void>;
|
|
25
|
+
updateStudent(input: UpdateStudentInput): Promise<OrgUser>;
|
|
26
|
+
getBySlug(slug: string): Promise<Organization | null>;
|
|
27
|
+
listMembers(orgId: string, query: MembersQuery): Promise<Page<Member>>;
|
|
28
|
+
updateMemberRole(ctx: MemberWriteContext, id: string, role: Role): Promise<Member | null>;
|
|
29
|
+
removeMember(ctx: MemberWriteContext, id: string): Promise<boolean>;
|
|
30
|
+
}
|
|
31
|
+
/** Atomic write scope: tx-bound repo + outbox appender, one transaction. */
|
|
32
|
+
interface OrganizationsWriteScope {
|
|
33
|
+
organizations: OrganizationsRepository;
|
|
34
|
+
outbox: OutboxAppender;
|
|
35
|
+
}
|
|
36
|
+
type OrganizationsUnitOfWork = UnitOfWork<OrganizationsWriteScope>;
|
|
37
|
+
/** Repo-facing write shape for a new org row. The service mints the id and
|
|
38
|
+
* resolves the defaults, so nothing is optional by the time it lands here. */
|
|
39
|
+
interface NewOrganizationRow {
|
|
40
|
+
id: string;
|
|
41
|
+
externalId?: string | null;
|
|
42
|
+
name: string;
|
|
43
|
+
slug: string;
|
|
44
|
+
ownerId: string;
|
|
45
|
+
}
|
|
46
|
+
/** Repo-facing write shape for a freshly minted invite. */
|
|
47
|
+
interface NewInviteRow {
|
|
48
|
+
email: string;
|
|
49
|
+
role: InviteRole;
|
|
50
|
+
invitedBy: string;
|
|
51
|
+
tokenHash: string;
|
|
52
|
+
expiresAt: Date;
|
|
53
|
+
}
|
|
54
|
+
interface OrganizationsRepository {
|
|
55
|
+
create(input: NewOrganizationRow): Promise<Organization>;
|
|
56
|
+
update(id: string, input: UpdateOrganizationInput): Promise<Organization | null>;
|
|
57
|
+
/** Drops the org row and its dependents; null when none matched. */
|
|
58
|
+
delete(id: string): Promise<Organization>;
|
|
59
|
+
findById(id: string): Promise<Organization | null>;
|
|
60
|
+
findByExternalId(externalId: string): Promise<Organization | null>;
|
|
61
|
+
findBySlug(slug: string): Promise<Organization | null>;
|
|
62
|
+
upsertOrgUser(orgId: string, input: AddOrgUserInput): Promise<OrgUser>;
|
|
63
|
+
/** Inserts a pending invite, or re-issues the org's existing pending one
|
|
64
|
+
* for this email (fresh token/expiry/role) — atomic upsert. */
|
|
65
|
+
upsertPendingInvite(orgId: string, input: NewInviteRow): Promise<Invite>;
|
|
66
|
+
setInviteStatus(orgId: string, id: string, status: string): Promise<Invite | null>;
|
|
67
|
+
findInviteByTokenHash(tokenHash: string): Promise<Invite | null>;
|
|
68
|
+
/** The person's row in one org. `(org_id, user_id)` is unique. */
|
|
69
|
+
findOrgUser(orgId: string, userId: string): Promise<OrgUser | null>;
|
|
70
|
+
/** Every org this person belongs to, oldest first. */
|
|
71
|
+
findOrgUsersByUser(userId: string): Promise<OrgUser[]>;
|
|
72
|
+
findOrgUserById(orgId: string, id: string): Promise<OrgUser | null>;
|
|
73
|
+
/** Links a user to the org under a role. Throws ConflictError when they
|
|
74
|
+
* already hold a row there. */
|
|
75
|
+
createOrgUser(input: CreateOrgUserInput): Promise<OrgUser>;
|
|
76
|
+
/** createOrgUser, but idempotent on `(org_id, user_id)`: an existing row is
|
|
77
|
+
* promoted to the requested status rather than refused. `created` says
|
|
78
|
+
* whether a row appeared, so `student.created` fires exactly once. */
|
|
79
|
+
ensureOrgUser(input: CreateOrgUserInput): Promise<{
|
|
80
|
+
orgUser: OrgUser;
|
|
81
|
+
created: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
/** Every org this person is a student in — the scope of `student.linked`. */
|
|
84
|
+
findStudentOrgUsers(userId: string): Promise<OrgUser[]>;
|
|
85
|
+
/** Kills the org's pending invite for an address, if any. */
|
|
86
|
+
cancelPendingInvite(orgId: string, email: string): Promise<Invite | null>;
|
|
87
|
+
deleteOrgUser(orgId: string, id: string): Promise<OrgUser | null>;
|
|
88
|
+
}
|
|
89
|
+
/** A member row enriched with the ids needed to drive writes. */
|
|
90
|
+
interface MemberRecord extends Member {
|
|
91
|
+
kind: 'member' | 'invite';
|
|
92
|
+
userExternalId: string | null;
|
|
93
|
+
inviteId: string | null;
|
|
94
|
+
}
|
|
95
|
+
interface MembersRepository {
|
|
96
|
+
list(orgId: string, query: MembersQuery): Promise<Page<Member>>;
|
|
97
|
+
findByEmail(orgId: string, email: string): Promise<MemberRecord | null>;
|
|
98
|
+
findById(orgId: string, id: string): Promise<MemberRecord | null>;
|
|
99
|
+
}
|
|
100
|
+
/** The person as this context reads them back after a correction. */
|
|
101
|
+
interface PersonRecord {
|
|
102
|
+
id: string;
|
|
103
|
+
email: string;
|
|
104
|
+
firstName: string | null;
|
|
105
|
+
lastName: string | null;
|
|
106
|
+
}
|
|
107
|
+
/** Context for a write: domain org (reads/rules) + auth org & session (writes). */
|
|
108
|
+
interface MemberWriteContext {
|
|
109
|
+
orgId: string;
|
|
110
|
+
authOrgId: string;
|
|
111
|
+
headers: Record<string, string | string[] | undefined>;
|
|
112
|
+
}
|
|
113
|
+
/** The provider's view of an org: what it stores itself, minus the fields only
|
|
114
|
+
* the domain row carries (`ownerId`, `externalId`, `updatedAt`). */
|
|
115
|
+
type AuthOrganization = Pick<Organization, 'id' | 'name' | 'slug' | 'createdAt'>;
|
|
116
|
+
interface OrgAdmin {
|
|
117
|
+
createOrganization(headers: AuthHeaders, input: NewOrganizationInput): Promise<AuthOrganization>;
|
|
118
|
+
setActiveOrganization(headers: AuthHeaders, externalId: string): Promise<void>;
|
|
119
|
+
updateOrganization(headers: AuthHeaders, id: string, input: UpdateOrganizationInput): Promise<AuthOrganization>;
|
|
120
|
+
deleteOrganization(headers: AuthHeaders, externalId: string): Promise<void>;
|
|
121
|
+
grantMembership(orgExternalId: string, userExternalId: string, role: string): Promise<void>;
|
|
122
|
+
updateRole(ctx: MemberWriteContext, userExternalId: string, role: Role): Promise<void>;
|
|
123
|
+
removeMember(ctx: MemberWriteContext, userExternalId: string): Promise<void>;
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
export { type AuthHeaders, AuthOrganization, MemberRecord, MemberWriteContext, MembersRepository, NewInviteRow, NewOrganizationRow, OrgAdmin, OrganizationService, OrganizationsRepository, OrganizationsUnitOfWork, OrganizationsWriteScope, PersonRecord };
|
|
127
|
+
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Role } from "../types/schemas/organizations.js";
|
|
2
|
+
import "../types/index.js";
|
|
3
|
+
//#region src/organizations/roles.d.ts
|
|
4
|
+
declare const ROLES: readonly ["owner", "admin", "instructor", "student"];
|
|
5
|
+
/**
|
|
6
|
+
* The roles that operate the back office. `student` belongs to the org but
|
|
7
|
+
* never appears on a staff surface, so the member-management types are typed
|
|
8
|
+
* with this narrower union — the exclusion is a compiler guarantee, not a
|
|
9
|
+
* convention a query has to remember.
|
|
10
|
+
*/
|
|
11
|
+
type StaffRole = Exclude<Role, 'student'>;
|
|
12
|
+
declare const STAFF_ROLES: readonly ["owner", "admin", "instructor"];
|
|
13
|
+
declare function isRole(value: string): value is Role;
|
|
14
|
+
declare function isStaffRole(value: string): value is StaffRole;
|
|
15
|
+
declare function parseRole(value: string): Role;
|
|
16
|
+
type Permission = 'manage_billing' | 'manage_org_settings' | 'manage_users' | 'create_course' | 'edit_assigned_course' | 'view_student_progress' | 'consume_content';
|
|
17
|
+
type Capability = true | 'assigned' | 'enrolled';
|
|
18
|
+
declare function capability(role: Role, permission: Permission): Capability | false;
|
|
19
|
+
declare function normalizeRole(raw: string): Role;
|
|
20
|
+
declare const STUDENT_ROLE = "student";
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Capability, Permission, ROLES, type Role, STAFF_ROLES, STUDENT_ROLE, StaffRole, capability, isRole, isStaffRole, normalizeRole, parseRole };
|
|
23
|
+
//# sourceMappingURL=roles.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//#region src/organizations/roles.ts
|
|
2
|
+
const ROLES = [
|
|
3
|
+
"owner",
|
|
4
|
+
"admin",
|
|
5
|
+
"instructor",
|
|
6
|
+
"student"
|
|
7
|
+
];
|
|
8
|
+
const STAFF_ROLES = [
|
|
9
|
+
"owner",
|
|
10
|
+
"admin",
|
|
11
|
+
"instructor"
|
|
12
|
+
];
|
|
13
|
+
function isRole(value) {
|
|
14
|
+
return ROLES.includes(value);
|
|
15
|
+
}
|
|
16
|
+
function isStaffRole(value) {
|
|
17
|
+
return STAFF_ROLES.includes(value);
|
|
18
|
+
}
|
|
19
|
+
function parseRole(value) {
|
|
20
|
+
if (!isRole(value)) throw new Error(`unknown role: ${value}`);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
const MATRIX = {
|
|
24
|
+
owner: {
|
|
25
|
+
manage_billing: true,
|
|
26
|
+
manage_org_settings: true,
|
|
27
|
+
manage_users: true,
|
|
28
|
+
create_course: true,
|
|
29
|
+
edit_assigned_course: true,
|
|
30
|
+
view_student_progress: true
|
|
31
|
+
},
|
|
32
|
+
admin: {
|
|
33
|
+
manage_org_settings: true,
|
|
34
|
+
manage_users: true,
|
|
35
|
+
create_course: true,
|
|
36
|
+
edit_assigned_course: true,
|
|
37
|
+
view_student_progress: true
|
|
38
|
+
},
|
|
39
|
+
instructor: {
|
|
40
|
+
edit_assigned_course: "assigned",
|
|
41
|
+
view_student_progress: "assigned"
|
|
42
|
+
},
|
|
43
|
+
student: { consume_content: "enrolled" }
|
|
44
|
+
};
|
|
45
|
+
function capability(role, permission) {
|
|
46
|
+
return MATRIX[role][permission] ?? false;
|
|
47
|
+
}
|
|
48
|
+
const RANK = {
|
|
49
|
+
owner: 3,
|
|
50
|
+
admin: 2,
|
|
51
|
+
instructor: 1,
|
|
52
|
+
student: 0
|
|
53
|
+
};
|
|
54
|
+
function normalizeRole(raw) {
|
|
55
|
+
let best = "instructor";
|
|
56
|
+
let bestRank = -1;
|
|
57
|
+
for (const token of raw.split(",").map((t) => t.trim())) {
|
|
58
|
+
const r = isRole(token) ? token : token === "member" ? "instructor" : null;
|
|
59
|
+
if (r && RANK[r] > bestRank) {
|
|
60
|
+
best = r;
|
|
61
|
+
bestRank = RANK[r];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return best;
|
|
65
|
+
}
|
|
66
|
+
const STUDENT_ROLE = "student";
|
|
67
|
+
//#endregion
|
|
68
|
+
export { ROLES, STAFF_ROLES, STUDENT_ROLE, capability, isRole, isStaffRole, normalizeRole, parseRole };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.js","names":[],"sources":["../../src/organizations/roles.ts"],"sourcesContent":["// organizations context — roles and the authorization matrix.\n// Defined in code (no DB enum). The DB stores role as text; the domain narrows\n// it to Role and answers authorization questions here. The Role type itself is\n// owned by @headless-lms/core/types; RANK/MATRIX below are Record<Role, …>, so the\n// compiler forces this file to cover every role the published type declares.\nimport type { Role } from '../types/index.js';\n\nexport type { Role };\nexport const ROLES = [\n 'owner',\n 'admin',\n 'instructor',\n 'student',\n] as const satisfies readonly Role[];\n\n/**\n * The roles that operate the back office. `student` belongs to the org but\n * never appears on a staff surface, so the member-management types are typed\n * with this narrower union — the exclusion is a compiler guarantee, not a\n * convention a query has to remember.\n */\nexport type StaffRole = Exclude<Role, 'student'>;\nexport const STAFF_ROLES = ['owner', 'admin', 'instructor'] as const satisfies readonly StaffRole[];\n\nexport function isRole(value: string): value is Role {\n return (ROLES as readonly string[]).includes(value);\n}\n\nexport function isStaffRole(value: string): value is StaffRole {\n return (STAFF_ROLES as readonly string[]).includes(value);\n}\n\nexport function parseRole(value: string): Role {\n if (!isRole(value)) {\n throw new Error(`unknown role: ${value}`);\n }\n return value;\n}\n\nexport type Permission =\n | 'manage_billing'\n | 'manage_org_settings'\n | 'manage_users'\n | 'create_course'\n | 'edit_assigned_course'\n | 'view_student_progress'\n | 'consume_content';\n\n// Unconditional (true), course-scoped (\"assigned\"), or enrollment-scoped\n// (\"enrolled\" — access owned by entitlements). Absent ⇒ denied.\n//\n// \"assigned\" is a granted-but-narrowed answer: the role holds the permission,\n// but only over some subset of courses. Nothing narrows it today — there is no\n// course-assignment store — so callers must decide what a narrowed grant means\n// for them. `authorize` treats it as denied; `tools.ts` treats it as granted.\nexport type Capability = true | 'assigned' | 'enrolled';\n\nconst MATRIX: Record<Role, Partial<Record<Permission, Capability>>> = {\n owner: {\n manage_billing: true,\n manage_org_settings: true,\n manage_users: true,\n create_course: true,\n edit_assigned_course: true,\n view_student_progress: true,\n },\n admin: {\n manage_org_settings: true,\n manage_users: true,\n create_course: true,\n edit_assigned_course: true,\n view_student_progress: true,\n },\n instructor: {\n edit_assigned_course: 'assigned',\n view_student_progress: 'assigned',\n },\n // A learner belongs to the org to consume content they hold an\n // entitlement for. No management capability of any kind.\n student: {\n consume_content: 'enrolled',\n },\n};\n\nexport function capability(role: Role, permission: Permission): Capability | false {\n return MATRIX[role][permission] ?? false;\n}\n\n// Better Auth's role model is broader than ours: it keeps a built-in `member`\n// role and allows comma-joined multi-role strings. Normalize any incoming role\n// string to a single domain Role before persisting: `member` -> `instructor`, a\n// multi-role string -> its highest-privilege known role, unknown -> `instructor`.\nconst RANK: Record<Role, number> = { owner: 3, admin: 2, instructor: 1, student: 0 };\n\nexport function normalizeRole(raw: string): Role {\n let best: Role = 'instructor';\n let bestRank = -1;\n for (const token of raw.split(',').map((t) => t.trim())) {\n const r: Role | null = isRole(token) ? token : token === 'member' ? 'instructor' : null;\n if (r && RANK[r] > bestRank) {\n best = r;\n bestRank = RANK[r];\n }\n }\n return best;\n}\n\n// Invites carry either a staff Role or this marker: the invited account is\n// a portal student, not an org member. Owned by the organizations domain — the\n// invite provider adapter reuses it to branch links, emails, and grants.\nexport const STUDENT_ROLE = 'student';\n"],"mappings":";AAQA,MAAa,QAAQ;CACnB;CACA;CACA;CACA;AACF;AASA,MAAa,cAAc;CAAC;CAAS;CAAS;AAAY;AAE1D,SAAgB,OAAO,OAA8B;CACnD,OAAQ,MAA4B,SAAS,KAAK;AACpD;AAEA,SAAgB,YAAY,OAAmC;CAC7D,OAAQ,YAAkC,SAAS,KAAK;AAC1D;AAEA,SAAgB,UAAU,OAAqB;CAC7C,IAAI,CAAC,OAAO,KAAK,GACf,MAAM,IAAI,MAAM,iBAAiB,OAAO;CAE1C,OAAO;AACT;AAoBA,MAAM,SAAgE;CACpE,OAAO;EACL,gBAAgB;EAChB,qBAAqB;EACrB,cAAc;EACd,eAAe;EACf,sBAAsB;EACtB,uBAAuB;CACzB;CACA,OAAO;EACL,qBAAqB;EACrB,cAAc;EACd,eAAe;EACf,sBAAsB;EACtB,uBAAuB;CACzB;CACA,YAAY;EACV,sBAAsB;EACtB,uBAAuB;CACzB;CAGA,SAAS,EACP,iBAAiB,WACnB;AACF;AAEA,SAAgB,WAAW,MAAY,YAA4C;CACjF,OAAO,OAAO,KAAK,CAAC,eAAe;AACrC;AAMA,MAAM,OAA6B;CAAE,OAAO;CAAG,OAAO;CAAG,YAAY;CAAG,SAAS;AAAE;AAEnF,SAAgB,cAAc,KAAmB;CAC/C,IAAI,OAAa;CACjB,IAAI,WAAW;CACf,KAAK,MAAM,SAAS,IAAI,MAAM,GAAG,CAAC,CAAC,KAAK,MAAM,EAAE,KAAK,CAAC,GAAG;EACvD,MAAM,IAAiB,OAAO,KAAK,IAAI,QAAQ,UAAU,WAAW,eAAe;EACnF,IAAI,KAAK,KAAK,KAAK,UAAU;GAC3B,OAAO;GACP,WAAW,KAAK;EAClB;CACF;CACA,OAAO;AACT;AAKA,MAAa,eAAe"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Logger } from "../types/ports.js";
|
|
2
|
+
import { AcceptInviteInput, AddOrgUserInput, CreateInviteInput, Invite, OrgUser, Organization, Role } from "../types/schemas/organizations.js";
|
|
3
|
+
import "../shared/ports.js";
|
|
4
|
+
import { Mailer } from "../shared/mailer.js";
|
|
5
|
+
import { IdentityService } from "../identity/ports.js";
|
|
6
|
+
import "../identity/index.js";
|
|
7
|
+
import "./model.js";
|
|
8
|
+
import "./roles.js";
|
|
9
|
+
import { Member, MembersQuery, Page } from "./members.js";
|
|
10
|
+
import { CreateOrganizationInput, ResendStudentInviteInput, UpdateOrganizationInput, UpdateStudentInput } from "./types.js";
|
|
11
|
+
import { MemberWriteContext, MembersRepository, OrganizationService, OrganizationsRepository, OrganizationsUnitOfWork } from "./ports.js";
|
|
12
|
+
//#region src/organizations/service.d.ts
|
|
13
|
+
interface InviteUrls {
|
|
14
|
+
studentPortalUrl: string;
|
|
15
|
+
adminAppUrl: string;
|
|
16
|
+
}
|
|
17
|
+
type OrganizationServiceParams = {
|
|
18
|
+
repo: OrganizationsRepository;
|
|
19
|
+
membersRepo: MembersRepository;
|
|
20
|
+
people: IdentityService;
|
|
21
|
+
uow: OrganizationsUnitOfWork;
|
|
22
|
+
logger?: Logger;
|
|
23
|
+
mailer?: Pick<Mailer, 'send'>;
|
|
24
|
+
inviteUrls?: InviteUrls;
|
|
25
|
+
};
|
|
26
|
+
declare class OrganizationServiceImpl implements OrganizationService {
|
|
27
|
+
private readonly repo;
|
|
28
|
+
private readonly membersRepo;
|
|
29
|
+
private readonly people;
|
|
30
|
+
private readonly uow;
|
|
31
|
+
private readonly logger;
|
|
32
|
+
private readonly mailer?;
|
|
33
|
+
private readonly inviteUrls?;
|
|
34
|
+
constructor(params: OrganizationServiceParams);
|
|
35
|
+
createOrganization(input: CreateOrganizationInput): Promise<Organization>;
|
|
36
|
+
updateOrganization(id: string, input: UpdateOrganizationInput): Promise<Organization>;
|
|
37
|
+
deleteOrganization(id: string): Promise<Organization>;
|
|
38
|
+
addOrgUser({ orgId, userId, role }: AddOrgUserInput): Promise<OrgUser>;
|
|
39
|
+
removeOrgUser(orgId: string, id: string): Promise<OrgUser>;
|
|
40
|
+
createInvite(input: CreateInviteInput): Promise<Invite>;
|
|
41
|
+
updateStudent(input: UpdateStudentInput): Promise<OrgUser>;
|
|
42
|
+
resendStudentInvite(input: ResendStudentInviteInput): Promise<void>;
|
|
43
|
+
peekInvite(token: string): Promise<Invite | null>;
|
|
44
|
+
acceptInvite(input: AcceptInviteInput): Promise<OrgUser>;
|
|
45
|
+
getOrgUser(orgId: string, userId: string): Promise<OrgUser | null>;
|
|
46
|
+
deleteOrgUser(orgId: string, id: string): Promise<OrgUser>;
|
|
47
|
+
getOrgUsersForUser(userId: string): Promise<OrgUser[]>;
|
|
48
|
+
getById(id: string): Promise<Organization | null>;
|
|
49
|
+
private sendInviteEmail;
|
|
50
|
+
getByExternalId(externalId: string): Promise<Organization | null>;
|
|
51
|
+
getBySlug(slug: string): Promise<Organization | null>;
|
|
52
|
+
listMembers(orgId: string, query: MembersQuery): Promise<Page<Member>>;
|
|
53
|
+
updateMemberRole(ctx: MemberWriteContext, id: string, role: Role): Promise<Member | null>;
|
|
54
|
+
removeMember(_ctx: MemberWriteContext, _id: string): Promise<boolean>;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { InviteUrls, OrganizationServiceImpl, OrganizationServiceParams };
|
|
58
|
+
//# sourceMappingURL=service.d.ts.map
|