@headless-lms/core 0.5.0 → 0.6.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/dist/assets/events.d.ts +18 -18
- package/dist/assets/file-urls.d.ts +3 -0
- package/dist/assets/file-urls.js +1 -0
- package/dist/assets/file-urls.js.map +1 -1
- package/dist/assets/index.js +1 -1
- package/dist/assets/ports.d.ts +1 -1
- package/dist/assets/service.d.ts +1 -1
- package/dist/assets/service.js +28 -23
- package/dist/assets/service.js.map +1 -1
- package/dist/automations/catalog.js +1 -1
- package/dist/automations/notifications/processor.js +2 -2
- package/dist/automations/notifications/service.js +1 -1
- package/dist/automations/service.js +1 -1
- package/dist/content/events.d.ts +84 -48
- package/dist/content/index.d.ts +2 -2
- package/dist/content/model.d.ts +2 -2
- package/dist/content/notification-categories.js +1 -1
- package/dist/content/ports.d.ts +11 -11
- package/dist/content/service.d.ts +16 -12
- package/dist/content/service.js +62 -16
- package/dist/content/service.js.map +1 -1
- package/dist/discussion/chats.js +2 -2
- package/dist/discussion/events.d.ts +8 -8
- package/dist/discussion/posts.d.ts +1 -1
- package/dist/discussion/posts.js +3 -3
- package/dist/discussion/posts.js.map +1 -1
- package/dist/discussion/service.js +2 -2
- package/dist/discussion/subscriptions.js +1 -1
- package/dist/entitlements/events.d.ts +48 -48
- package/dist/entitlements/service.js +1 -1
- package/dist/identity/devices.js +1 -1
- package/dist/identity/events.d.ts +2 -2
- package/dist/identity/notification-settings.js +1 -1
- package/dist/identity/service.d.ts +1 -1
- package/dist/identity/service.js +3 -3
- package/dist/identity/service.js.map +1 -1
- package/dist/integrations/service.js +2 -2
- package/dist/organizations/effective-permissions.d.ts +3 -1
- package/dist/organizations/effective-permissions.js +8 -3
- package/dist/organizations/effective-permissions.js.map +1 -1
- package/dist/organizations/events.d.ts +29 -23
- package/dist/organizations/index.d.ts +2 -2
- package/dist/organizations/model.d.ts +2 -2
- package/dist/organizations/notification-categories.js +1 -1
- package/dist/organizations/ports.d.ts +6 -3
- package/dist/organizations/service.d.ts +1 -1
- package/dist/organizations/service.js +17 -7
- package/dist/organizations/service.js.map +1 -1
- package/dist/organizations/testing.js +1 -1
- package/dist/organizations/testing.js.map +1 -1
- package/dist/progress/service.js +2 -2
- package/dist/reporting/member/model.d.ts +3 -0
- package/dist/reporting/member/ports.d.ts +2 -1
- package/dist/reporting/member/service.d.ts +2 -1
- package/dist/reporting/member/service.js +17 -1
- package/dist/reporting/member/service.js.map +1 -1
- package/dist/shared/actor.d.ts +1 -0
- package/dist/types/content.d.ts +2 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/types/organizations.d.ts +2 -2
- package/dist/types/schemas/content.d.ts +68 -6
- package/dist/types/schemas/content.js +19 -2
- package/dist/types/schemas/content.js.map +1 -1
- package/dist/types/schemas/discussion.d.ts +14 -14
- package/dist/types/schemas/entitlements.d.ts +8 -8
- package/dist/types/schemas/index.d.ts +3 -3
- package/dist/types/schemas/index.js +3 -3
- package/dist/types/schemas/notifications.d.ts +4 -4
- package/dist/types/schemas/organizations.d.ts +4 -1
- package/dist/types/schemas/organizations.js +3 -1
- package/dist/types/schemas/organizations.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ declare const organizationEvents: {
|
|
|
9
9
|
name: string;
|
|
10
10
|
slug: string;
|
|
11
11
|
ownerId: string;
|
|
12
|
+
metadata: Record<string, string>;
|
|
12
13
|
createdAt: Date;
|
|
13
14
|
updatedAt: Date;
|
|
14
15
|
}, "organization.created", 1>, {
|
|
@@ -17,13 +18,14 @@ declare const organizationEvents: {
|
|
|
17
18
|
name: string;
|
|
18
19
|
slug: string;
|
|
19
20
|
ownerId: string;
|
|
21
|
+
metadata: Record<string, string>;
|
|
20
22
|
createdAt: unknown;
|
|
21
23
|
updatedAt: unknown;
|
|
22
24
|
}, z.ZodObject<{
|
|
23
25
|
id: z.ZodString;
|
|
24
|
-
name: z.ZodString;
|
|
25
26
|
createdAt: z.ZodCoercedDate<unknown>;
|
|
26
27
|
updatedAt: z.ZodCoercedDate<unknown>;
|
|
28
|
+
name: z.ZodString;
|
|
27
29
|
slug: z.ZodString;
|
|
28
30
|
ownerId: z.ZodString;
|
|
29
31
|
}, z.core.$strip>>;
|
|
@@ -33,6 +35,7 @@ declare const organizationEvents: {
|
|
|
33
35
|
name: string;
|
|
34
36
|
slug: string;
|
|
35
37
|
ownerId: string;
|
|
38
|
+
metadata: Record<string, string>;
|
|
36
39
|
createdAt: Date;
|
|
37
40
|
updatedAt: Date;
|
|
38
41
|
}, "organization.updated", 1>, {
|
|
@@ -41,13 +44,14 @@ declare const organizationEvents: {
|
|
|
41
44
|
name: string;
|
|
42
45
|
slug: string;
|
|
43
46
|
ownerId: string;
|
|
47
|
+
metadata: Record<string, string>;
|
|
44
48
|
createdAt: unknown;
|
|
45
49
|
updatedAt: unknown;
|
|
46
50
|
}, z.ZodObject<{
|
|
47
51
|
id: z.ZodString;
|
|
48
|
-
name: z.ZodString;
|
|
49
52
|
createdAt: z.ZodCoercedDate<unknown>;
|
|
50
53
|
updatedAt: z.ZodCoercedDate<unknown>;
|
|
54
|
+
name: z.ZodString;
|
|
51
55
|
slug: z.ZodString;
|
|
52
56
|
ownerId: z.ZodString;
|
|
53
57
|
}, z.core.$strip>>;
|
|
@@ -57,6 +61,7 @@ declare const organizationEvents: {
|
|
|
57
61
|
name: string;
|
|
58
62
|
slug: string;
|
|
59
63
|
ownerId: string;
|
|
64
|
+
metadata: Record<string, string>;
|
|
60
65
|
createdAt: Date;
|
|
61
66
|
updatedAt: Date;
|
|
62
67
|
}, "organization.deleted", 1>, {
|
|
@@ -65,13 +70,14 @@ declare const organizationEvents: {
|
|
|
65
70
|
name: string;
|
|
66
71
|
slug: string;
|
|
67
72
|
ownerId: string;
|
|
73
|
+
metadata: Record<string, string>;
|
|
68
74
|
createdAt: unknown;
|
|
69
75
|
updatedAt: unknown;
|
|
70
76
|
}, z.ZodObject<{
|
|
71
77
|
id: z.ZodString;
|
|
72
|
-
name: z.ZodString;
|
|
73
78
|
createdAt: z.ZodCoercedDate<unknown>;
|
|
74
79
|
updatedAt: z.ZodCoercedDate<unknown>;
|
|
80
|
+
name: z.ZodString;
|
|
75
81
|
slug: z.ZodString;
|
|
76
82
|
ownerId: z.ZodString;
|
|
77
83
|
}, z.core.$strip>>;
|
|
@@ -98,12 +104,12 @@ declare const organizationEvents: {
|
|
|
98
104
|
}, z.ZodObject<{
|
|
99
105
|
orgId: z.ZodString;
|
|
100
106
|
id: z.ZodString;
|
|
101
|
-
createdAt: z.ZodCoercedDate<unknown>;
|
|
102
|
-
updatedAt: z.ZodCoercedDate<unknown>;
|
|
103
107
|
status: z.ZodEnum<{
|
|
104
108
|
active: "active";
|
|
105
109
|
invited: "invited";
|
|
106
110
|
}>;
|
|
111
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
112
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
107
113
|
userId: z.ZodString;
|
|
108
114
|
orgRole: z.ZodObject<{
|
|
109
115
|
key: z.ZodString;
|
|
@@ -132,12 +138,12 @@ declare const organizationEvents: {
|
|
|
132
138
|
}, z.ZodObject<{
|
|
133
139
|
orgId: z.ZodString;
|
|
134
140
|
id: z.ZodString;
|
|
135
|
-
createdAt: z.ZodCoercedDate<unknown>;
|
|
136
|
-
updatedAt: z.ZodCoercedDate<unknown>;
|
|
137
141
|
status: z.ZodEnum<{
|
|
138
142
|
active: "active";
|
|
139
143
|
invited: "invited";
|
|
140
144
|
}>;
|
|
145
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
146
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
141
147
|
userId: z.ZodString;
|
|
142
148
|
orgRole: z.ZodObject<{
|
|
143
149
|
key: z.ZodString;
|
|
@@ -166,12 +172,12 @@ declare const organizationEvents: {
|
|
|
166
172
|
}, z.ZodObject<{
|
|
167
173
|
orgId: z.ZodString;
|
|
168
174
|
id: z.ZodString;
|
|
169
|
-
createdAt: z.ZodCoercedDate<unknown>;
|
|
170
|
-
updatedAt: z.ZodCoercedDate<unknown>;
|
|
171
175
|
status: z.ZodEnum<{
|
|
172
176
|
active: "active";
|
|
173
177
|
invited: "invited";
|
|
174
178
|
}>;
|
|
179
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
180
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
175
181
|
userId: z.ZodString;
|
|
176
182
|
orgRole: z.ZodObject<{
|
|
177
183
|
key: z.ZodString;
|
|
@@ -202,18 +208,18 @@ declare const organizationEvents: {
|
|
|
202
208
|
}, z.ZodObject<{
|
|
203
209
|
orgId: z.ZodString;
|
|
204
210
|
id: z.ZodString;
|
|
205
|
-
createdAt: z.ZodCoercedDate<unknown>;
|
|
206
|
-
updatedAt: z.ZodCoercedDate<unknown>;
|
|
207
211
|
status: z.ZodEnum<{
|
|
208
212
|
pending: "pending";
|
|
209
213
|
canceled: "canceled";
|
|
210
214
|
accepted: "accepted";
|
|
211
215
|
rejected: "rejected";
|
|
212
216
|
}>;
|
|
213
|
-
|
|
217
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
218
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
214
219
|
email: z.ZodEmail;
|
|
215
|
-
|
|
220
|
+
expiresAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
216
221
|
roleKey: z.ZodString;
|
|
222
|
+
invitedBy: z.ZodString;
|
|
217
223
|
}, z.core.$strip>>;
|
|
218
224
|
inviteAccepted: RuntimeEventDefinition<VersionedDomainEvent<{
|
|
219
225
|
id: string;
|
|
@@ -240,18 +246,18 @@ declare const organizationEvents: {
|
|
|
240
246
|
}, z.ZodObject<{
|
|
241
247
|
orgId: z.ZodString;
|
|
242
248
|
id: z.ZodString;
|
|
243
|
-
createdAt: z.ZodCoercedDate<unknown>;
|
|
244
|
-
updatedAt: z.ZodCoercedDate<unknown>;
|
|
245
249
|
status: z.ZodEnum<{
|
|
246
250
|
pending: "pending";
|
|
247
251
|
canceled: "canceled";
|
|
248
252
|
accepted: "accepted";
|
|
249
253
|
rejected: "rejected";
|
|
250
254
|
}>;
|
|
251
|
-
|
|
255
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
256
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
252
257
|
email: z.ZodEmail;
|
|
253
|
-
|
|
258
|
+
expiresAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
254
259
|
roleKey: z.ZodString;
|
|
260
|
+
invitedBy: z.ZodString;
|
|
255
261
|
}, z.core.$strip>>;
|
|
256
262
|
inviteCanceled: RuntimeEventDefinition<VersionedDomainEvent<{
|
|
257
263
|
id: string;
|
|
@@ -293,12 +299,12 @@ declare const organizationEvents: {
|
|
|
293
299
|
}, z.ZodObject<{
|
|
294
300
|
orgId: z.ZodString;
|
|
295
301
|
id: z.ZodString;
|
|
296
|
-
createdAt: z.ZodCoercedDate<unknown>;
|
|
297
|
-
updatedAt: z.ZodCoercedDate<unknown>;
|
|
298
302
|
status: z.ZodEnum<{
|
|
299
303
|
active: "active";
|
|
300
304
|
invited: "invited";
|
|
301
305
|
}>;
|
|
306
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
307
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
302
308
|
userId: z.ZodString;
|
|
303
309
|
}, z.core.$strip>>;
|
|
304
310
|
studentDeleted: RuntimeEventDefinition<VersionedDomainEvent<{
|
|
@@ -318,12 +324,12 @@ declare const organizationEvents: {
|
|
|
318
324
|
}, z.ZodObject<{
|
|
319
325
|
orgId: z.ZodString;
|
|
320
326
|
id: z.ZodString;
|
|
321
|
-
createdAt: z.ZodCoercedDate<unknown>;
|
|
322
|
-
updatedAt: z.ZodCoercedDate<unknown>;
|
|
323
327
|
status: z.ZodEnum<{
|
|
324
328
|
active: "active";
|
|
325
329
|
invited: "invited";
|
|
326
330
|
}>;
|
|
331
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
332
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
327
333
|
userId: z.ZodString;
|
|
328
334
|
}, z.core.$strip>>;
|
|
329
335
|
roleUpdated: RuntimeEventDefinition<VersionedDomainEvent<{
|
|
@@ -512,12 +518,12 @@ declare const organizationEvents: {
|
|
|
512
518
|
}, z.ZodObject<{
|
|
513
519
|
orgId: z.ZodString;
|
|
514
520
|
id: z.ZodString;
|
|
515
|
-
createdAt: z.ZodCoercedDate<unknown>;
|
|
516
|
-
updatedAt: z.ZodCoercedDate<unknown>;
|
|
517
521
|
status: z.ZodEnum<{
|
|
518
522
|
active: "active";
|
|
519
523
|
invited: "invited";
|
|
520
524
|
}>;
|
|
525
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
526
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
521
527
|
userId: z.ZodString;
|
|
522
528
|
}, z.core.$strip>>;
|
|
523
529
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AcceptInviteInput, AddOrgUserInput, CreateInviteInput, CreateOrgUserInput, Invite, NewOrganizationInput, OrgUser, OrgUserStatus, Organization, UpdateOrgUserInput } from "../types/schemas/organizations.js";
|
|
1
|
+
import { AcceptInviteInput, AddOrgUserInput, CreateInviteInput, CreateOrgUserInput, Invite, NewOrganizationInput, OrgUser, OrgUserStatus, Organization, OrganizationMetadata, UpdateOrgUserInput } from "../types/schemas/organizations.js";
|
|
2
2
|
import { InviteId, OrgUserId, OrganizationId } from "../types/organizations.js";
|
|
3
3
|
import { AuthHeaders } from "../identity/ports.js";
|
|
4
4
|
import { DEFAULT_ROLES, MEMBER_ROLE_KEY, OWNER_ROLE_KEY, RoleDefinition, RoleSetError, defaultHolders, validateRoleSet } from "./default-roles.js";
|
|
@@ -14,4 +14,4 @@ import { InviteUrls, OrganizationServiceImpl, OrganizationServiceParams } from "
|
|
|
14
14
|
import { OrgNotificationCategories } from "./notification-categories.js";
|
|
15
15
|
import { NotificationCatalog, NotificationCatalogParams, NotificationCatalogService } from "./notification-catalog.js";
|
|
16
16
|
import { ActorShape, actorWith } from "./testing.js";
|
|
17
|
-
export { ALL_PERMISSIONS, type AcceptInviteInput, type Accounts, type ActorFacts, type ActorShape, type AddOrgUserInput, type ApiKeyRole, type ApiKeys, type AssignmentRow, type AssignmentView, type AuthHeaders, type AuthOrganization, type CallerFacts, type CallerLimit, type CreateApiKeyInput, type CreateInviteInput, type CreateOrgUserInput, type CreateOrganizationInput, type CreateRoleInput, DEFAULT_ROLES, type GrantReader, type Invite, type InviteAccepted, type InviteCanceled, type InviteCreated, type InviteDetails, InviteError, type InviteId, type InviteUrls, type ItemRole, MEMBER_ROLE_KEY, type Member, type MemberStatus, type MembersQuery, type MembersRepository, type NewApiKey, type NewInviteRow, type NewOrganizationInput, type NewOrganizationRow, NotificationCatalog, type NotificationCatalogParams, type NotificationCatalogService, OWNER_ROLE_KEY, type OrgAdmin, OrgNotificationCategories, type OrgRole, type OrgUser, type OrgUserDeleted, type OrgUserId, type OrgUserLinked, type OrgUserStatus, type OrgUserUpdated, type Organization, type OrganizationCreated, type OrganizationDeleted, type OrganizationEvent, type OrganizationId, OrganizationRuleError, type OrganizationService, OrganizationServiceImpl, type OrganizationServiceParams, type OrganizationUpdated, type OrganizationsRepository, type OrganizationsUnitOfWork, type OrganizationsWriteScope, type OwnershipTransferred, PERMISSIONS, type Page, type PermissionDefinition, type PermissionGroup, type PermissionListEntry, type PlatformAccount, type PlatformOrganization, type PlatformOrganizationInput, type ResolveInput, type ResolvedCaller, ResolvedPermissions, type RoleAssigned, type RoleCatalog, type RoleCreated, type RoleDefinition, type RoleDeleted, RoleSetError, type RoleUnassigned, type RoleUpdated, type RoleView, type RolesRepository, type StoredApiKey, type StoredOrgRole, type StudentCreated, type StudentDeleted, type StudentLinked, type TeamRow, type TransferOwnershipInput, type UpdateOrgUserInput, type UpdateOrganizationInput, type UpdateRoleInput, type ViewerPermissions, actorWith, catalogOf, defaultHolders, fitsLevels, isPermission, isSystemRole, organizationEvents, permissionList, resolveOrgRoles, resolvePermissions, resolveRole, systemPermissions, validateRoleSet, withImplied };
|
|
17
|
+
export { ALL_PERMISSIONS, type AcceptInviteInput, type Accounts, type ActorFacts, type ActorShape, type AddOrgUserInput, type ApiKeyRole, type ApiKeys, type AssignmentRow, type AssignmentView, type AuthHeaders, type AuthOrganization, type CallerFacts, type CallerLimit, type CreateApiKeyInput, type CreateInviteInput, type CreateOrgUserInput, type CreateOrganizationInput, type CreateRoleInput, DEFAULT_ROLES, type GrantReader, type Invite, type InviteAccepted, type InviteCanceled, type InviteCreated, type InviteDetails, InviteError, type InviteId, type InviteUrls, type ItemRole, MEMBER_ROLE_KEY, type Member, type MemberStatus, type MembersQuery, type MembersRepository, type NewApiKey, type NewInviteRow, type NewOrganizationInput, type NewOrganizationRow, NotificationCatalog, type NotificationCatalogParams, type NotificationCatalogService, OWNER_ROLE_KEY, type OrgAdmin, OrgNotificationCategories, type OrgRole, type OrgUser, type OrgUserDeleted, type OrgUserId, type OrgUserLinked, type OrgUserStatus, type OrgUserUpdated, type Organization, type OrganizationCreated, type OrganizationDeleted, type OrganizationEvent, type OrganizationId, type OrganizationMetadata, OrganizationRuleError, type OrganizationService, OrganizationServiceImpl, type OrganizationServiceParams, type OrganizationUpdated, type OrganizationsRepository, type OrganizationsUnitOfWork, type OrganizationsWriteScope, type OwnershipTransferred, PERMISSIONS, type Page, type PermissionDefinition, type PermissionGroup, type PermissionListEntry, type PlatformAccount, type PlatformOrganization, type PlatformOrganizationInput, type ResolveInput, type ResolvedCaller, ResolvedPermissions, type RoleAssigned, type RoleCatalog, type RoleCreated, type RoleDefinition, type RoleDeleted, RoleSetError, type RoleUnassigned, type RoleUpdated, type RoleView, type RolesRepository, type StoredApiKey, type StoredOrgRole, type StudentCreated, type StudentDeleted, type StudentLinked, type TeamRow, type TransferOwnershipInput, type UpdateOrgUserInput, type UpdateOrganizationInput, type UpdateRoleInput, type ViewerPermissions, actorWith, catalogOf, defaultHolders, fitsLevels, isPermission, isSystemRole, organizationEvents, permissionList, resolveOrgRoles, resolvePermissions, resolveRole, systemPermissions, validateRoleSet, withImplied };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Invite, OrgUser, Organization } from "../types/schemas/organizations.js";
|
|
1
|
+
import { Invite, OrgUser, Organization, OrganizationMetadata } from "../types/schemas/organizations.js";
|
|
2
2
|
import "../types/index.js";
|
|
3
|
-
export type { Invite, OrgUser, Organization };
|
|
3
|
+
export type { Invite, OrgUser, Organization, OrganizationMetadata };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { noopLogger } from "../shared/logger.js";
|
|
2
1
|
import { NotFoundError } from "../shared/errors.js";
|
|
2
|
+
import { noopLogger } from "../shared/logger.js";
|
|
3
3
|
import "../shared/settings.js";
|
|
4
4
|
import { assertValidCategoryList, offeringConfigured, storedCategoryList } from "../shared/notification-categories.js";
|
|
5
5
|
//#region src/organizations/notification-categories.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ContentType } from "../types/schemas/content.js";
|
|
2
2
|
import { ApiKeySummary, ConnectedApp, CreatedApiKey } from "../types/identity.js";
|
|
3
|
-
import { AcceptInviteInput, AddOrgUserInput, CreateInviteInput, CreateOrgUserInput, Invite, NewOrganizationInput, OrgUser, OrgUserProfile, Organization, Permission, RoleAssignment, UpdateOrgUserInput } from "../types/schemas/organizations.js";
|
|
3
|
+
import { AcceptInviteInput, AddOrgUserInput, CreateInviteInput, CreateOrgUserInput, Invite, NewOrganizationInput, OrgUser, OrgUserProfile, Organization, OrganizationMetadata, Permission, RoleAssignment, UpdateOrgUserInput } from "../types/schemas/organizations.js";
|
|
4
4
|
import "../types/index.js";
|
|
5
5
|
import { Actor, EffectivePermissions } from "../shared/actor.js";
|
|
6
6
|
import { OutboxAppender, UnitOfWork } from "../shared/ports.js";
|
|
@@ -35,10 +35,12 @@ type CallerLimit = {
|
|
|
35
35
|
interface PlatformOrganizationInput {
|
|
36
36
|
name: string;
|
|
37
37
|
slug: string;
|
|
38
|
-
|
|
38
|
+
metadata?: OrganizationMetadata | undefined;
|
|
39
39
|
}
|
|
40
40
|
interface PlatformOrganization {
|
|
41
|
-
organization: AuthOrganization
|
|
41
|
+
organization: AuthOrganization & {
|
|
42
|
+
metadata: OrganizationMetadata;
|
|
43
|
+
};
|
|
42
44
|
apiKey: CreatedApiKey;
|
|
43
45
|
}
|
|
44
46
|
interface PlatformAccount {
|
|
@@ -170,6 +172,7 @@ interface OrganizationsRepository {
|
|
|
170
172
|
listIds(): Promise<string[]>;
|
|
171
173
|
findByExternalId(externalId: string): Promise<Organization | null>;
|
|
172
174
|
findBySlug(slug: string): Promise<Organization | null>;
|
|
175
|
+
setMetadata(id: string, metadata: OrganizationMetadata): Promise<Organization>;
|
|
173
176
|
upsertPendingInvite(orgId: string, input: NewInviteRow): Promise<Invite>;
|
|
174
177
|
setInviteStatus(orgId: string, id: string, status: string): Promise<Invite | null>;
|
|
175
178
|
setInviteRole(orgId: string, id: string, roleKey: string, invitedBy: string): Promise<Invite | null>;
|
|
@@ -25,7 +25,7 @@ type OrganizationServiceParams = {
|
|
|
25
25
|
roles: RolesRepository;
|
|
26
26
|
membersRepo: MembersRepository;
|
|
27
27
|
people: IdentityService;
|
|
28
|
-
images: Pick<AssetFiles, '
|
|
28
|
+
images: Pick<AssetFiles, 'syncPublicImages'>;
|
|
29
29
|
uow: OrganizationsUnitOfWork;
|
|
30
30
|
orgAdmin: () => OrgAdmin;
|
|
31
31
|
sessions: () => SessionAdmin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { levelSchema } from "../types/schemas/organizations.js";
|
|
2
|
-
import { noopLogger } from "../shared/logger.js";
|
|
3
|
-
import { ForbiddenError, NotFoundError } from "../shared/errors.js";
|
|
4
2
|
import { genId, prefixId } from "../shared/id.js";
|
|
3
|
+
import { ForbiddenError, NotFoundError } from "../shared/errors.js";
|
|
4
|
+
import { noopLogger } from "../shared/logger.js";
|
|
5
5
|
import { InviteError, OrganizationRuleError } from "./members.js";
|
|
6
6
|
import { organizationEvents } from "./events.js";
|
|
7
7
|
import { generateInviteToken, hashInviteToken } from "../shared/invite-token.js";
|
|
@@ -1097,6 +1097,13 @@ var OrganizationServiceImpl = class {
|
|
|
1097
1097
|
}
|
|
1098
1098
|
async createApiKey(input, actor) {
|
|
1099
1099
|
actor.permissions.require("api_keys:write");
|
|
1100
|
+
if (actor.permissions.isToken()) {
|
|
1101
|
+
this.logger.warn("api key refused: caller is a key or an app token", {
|
|
1102
|
+
orgId: actor.orgId,
|
|
1103
|
+
actorId: actor.id
|
|
1104
|
+
});
|
|
1105
|
+
throw new ForbiddenError("Sign in to create an API key");
|
|
1106
|
+
}
|
|
1100
1107
|
const roles = this.roleMap(await this.roles.storedRoles(actor.orgId));
|
|
1101
1108
|
const role = roles.get(input.role);
|
|
1102
1109
|
if (!role) throw new NotFoundError("Role", input.role);
|
|
@@ -1156,9 +1163,10 @@ var OrganizationServiceImpl = class {
|
|
|
1156
1163
|
name: input.name,
|
|
1157
1164
|
slug: input.slug
|
|
1158
1165
|
});
|
|
1159
|
-
const
|
|
1160
|
-
if (!
|
|
1161
|
-
const
|
|
1166
|
+
const found = await this.repo.findByExternalId(created.id);
|
|
1167
|
+
if (!found) throw new NotFoundError("Organization", created.id);
|
|
1168
|
+
const org = await this.repo.setMetadata(found.id, input.metadata ?? {});
|
|
1169
|
+
const apiKey = await this.platformKey(org, ownerExternalId, "Platform");
|
|
1162
1170
|
this.logger.info("platform organization created", {
|
|
1163
1171
|
orgId: org.id,
|
|
1164
1172
|
slug: org.slug
|
|
@@ -1168,6 +1176,7 @@ var OrganizationServiceImpl = class {
|
|
|
1168
1176
|
id: org.id,
|
|
1169
1177
|
name: org.name,
|
|
1170
1178
|
slug: org.slug,
|
|
1179
|
+
metadata: org.metadata,
|
|
1171
1180
|
createdAt: org.createdAt
|
|
1172
1181
|
},
|
|
1173
1182
|
apiKey
|
|
@@ -1228,7 +1237,7 @@ var OrganizationServiceImpl = class {
|
|
|
1228
1237
|
steps.push(["membership", () => this.orgAdmin().removeMembership(orgExternalId, userExternalId)]);
|
|
1229
1238
|
steps.push(["api keys and tokens", () => this.apiKeys().revokeAllFor(orgExternalId, userExternalId)]);
|
|
1230
1239
|
}
|
|
1231
|
-
steps.push(["profile photo", () => this.images.
|
|
1240
|
+
steps.push(["profile photo", () => this.images.syncPublicImages(orgId, orgUserId, [])]);
|
|
1232
1241
|
if (person) steps.push(["pending invite", async () => {
|
|
1233
1242
|
const pending = await this.repo.findPendingInvite(orgId, person.email);
|
|
1234
1243
|
if (pending) await this.repo.setInviteStatus(orgId, pending.id, "canceled");
|
|
@@ -1385,7 +1394,8 @@ var OrganizationServiceImpl = class {
|
|
|
1385
1394
|
anywhere: (p) => fresh.anywhere(p) && actor.permissions.anywhere(p),
|
|
1386
1395
|
where: (p) => actor.permissions.where(p),
|
|
1387
1396
|
roleOn: (on) => fresh.roleOn(on),
|
|
1388
|
-
isOwner: () => fresh.isOwner() && actor.permissions.isOwner()
|
|
1397
|
+
isOwner: () => fresh.isOwner() && actor.permissions.isOwner(),
|
|
1398
|
+
isToken: () => actor.permissions.isToken()
|
|
1389
1399
|
}
|
|
1390
1400
|
};
|
|
1391
1401
|
}
|