@aphexcms/cms-core 0.1.9 → 0.1.10
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/api/assets.d.ts +48 -0
- package/dist/api/assets.d.ts.map +1 -0
- package/dist/api/assets.js +52 -0
- package/dist/api/client.d.ts +37 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +125 -0
- package/dist/api/documents.d.ts +56 -0
- package/dist/api/documents.d.ts.map +1 -0
- package/dist/api/documents.js +77 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +5 -0
- package/dist/api/organizations.d.ts +101 -0
- package/dist/api/organizations.d.ts.map +1 -0
- package/dist/api/organizations.js +92 -0
- package/dist/api/types.d.ts +23 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +1 -0
- package/dist/auth/auth-errors.d.ts +7 -0
- package/dist/auth/auth-errors.d.ts.map +1 -0
- package/dist/auth/auth-errors.js +13 -0
- package/dist/auth/auth-hooks.d.ts +6 -0
- package/dist/auth/auth-hooks.d.ts.map +1 -0
- package/dist/auth/auth-hooks.js +108 -0
- package/dist/auth/provider.d.ts +17 -0
- package/dist/auth/provider.d.ts.map +1 -0
- package/dist/auth/provider.js +1 -0
- package/dist/client/index.d.ts +24 -0
- package/dist/client/index.d.ts.map +1 -0
- package/{src/lib/client/index.ts → dist/client/index.js} +7 -18
- package/dist/components/AdminApp.svelte.d.ts +24 -0
- package/dist/components/AdminApp.svelte.d.ts.map +1 -0
- package/dist/components/admin/AdminLayout.svelte.d.ts +15 -0
- package/dist/components/admin/AdminLayout.svelte.d.ts.map +1 -0
- package/dist/components/admin/DocumentEditor.svelte.d.ts +18 -0
- package/dist/components/admin/DocumentEditor.svelte.d.ts.map +1 -0
- package/dist/components/admin/DocumentTypesList.svelte.d.ts +14 -0
- package/dist/components/admin/DocumentTypesList.svelte.d.ts.map +1 -0
- package/dist/components/admin/ObjectModal.svelte.d.ts +15 -0
- package/dist/components/admin/ObjectModal.svelte.d.ts.map +1 -0
- package/dist/components/admin/SchemaField.svelte.d.ts +19 -0
- package/dist/components/admin/SchemaField.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/ArrayField.svelte.d.ts +12 -0
- package/dist/components/admin/fields/ArrayField.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/BooleanField.svelte.d.ts +13 -0
- package/dist/components/admin/fields/BooleanField.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/ImageField.svelte.d.ts +15 -0
- package/dist/components/admin/fields/ImageField.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/NumberField.svelte.d.ts +14 -0
- package/dist/components/admin/fields/NumberField.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/ReferenceField.svelte.d.ts +12 -0
- package/dist/components/admin/fields/ReferenceField.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/SlugField.svelte.d.ts +15 -0
- package/dist/components/admin/fields/SlugField.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/StringField.svelte.d.ts +14 -0
- package/dist/components/admin/fields/StringField.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/TextareaField.svelte.d.ts +14 -0
- package/dist/components/admin/fields/TextareaField.svelte.d.ts.map +1 -0
- package/dist/components/fields/index.d.ts +9 -0
- package/dist/components/fields/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.d.ts.map +1 -0
- package/{src/lib/components/index.ts → dist/components/index.js} +1 -5
- package/dist/components/layout/OrganizationSwitcher.svelte.d.ts +11 -0
- package/dist/components/layout/OrganizationSwitcher.svelte.d.ts.map +1 -0
- package/dist/components/layout/Sidebar.svelte.d.ts +14 -0
- package/dist/components/layout/Sidebar.svelte.d.ts.map +1 -0
- package/dist/components/layout/sidebar/AppSidebar.svelte.d.ts +4 -0
- package/dist/components/layout/sidebar/AppSidebar.svelte.d.ts.map +1 -0
- package/dist/components/layout/sidebar/NavMain.svelte.d.ts +19 -0
- package/dist/components/layout/sidebar/NavMain.svelte.d.ts.map +1 -0
- package/dist/components/layout/sidebar/NavSecondary.svelte.d.ts +9 -0
- package/dist/components/layout/sidebar/NavSecondary.svelte.d.ts.map +1 -0
- package/dist/components/layout/sidebar/NavUser.svelte.d.ts +9 -0
- package/dist/components/layout/sidebar/NavUser.svelte.d.ts.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +15 -0
- package/dist/db/adapters/index.d.ts +1 -0
- package/dist/db/adapters/index.d.ts.map +1 -0
- package/{src/lib/db/adapters/index.ts → dist/db/adapters/index.js} +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.d.ts.map +1 -0
- package/{src/lib/db/index.ts → dist/db/index.js} +1 -2
- package/dist/db/interfaces/asset.d.ts +51 -0
- package/dist/db/interfaces/asset.d.ts.map +1 -0
- package/dist/db/interfaces/asset.js +1 -0
- package/dist/db/interfaces/document.d.ts +36 -0
- package/dist/db/interfaces/document.d.ts.map +1 -0
- package/dist/db/interfaces/document.js +1 -0
- package/dist/db/interfaces/index.d.ts +73 -0
- package/dist/db/interfaces/index.d.ts.map +1 -0
- package/dist/db/interfaces/index.js +1 -0
- package/dist/db/interfaces/organization.d.ts +27 -0
- package/dist/db/interfaces/organization.d.ts.map +1 -0
- package/dist/db/interfaces/organization.js +1 -0
- package/dist/db/interfaces/schema.d.ts +21 -0
- package/dist/db/interfaces/schema.d.ts.map +1 -0
- package/dist/db/interfaces/schema.js +1 -0
- package/dist/db/interfaces/user.d.ts +15 -0
- package/dist/db/interfaces/user.d.ts.map +1 -0
- package/dist/db/interfaces/user.js +1 -0
- package/dist/db/utils/reference-resolver.d.ts +18 -0
- package/dist/db/utils/reference-resolver.d.ts.map +1 -0
- package/dist/db/utils/reference-resolver.js +80 -0
- package/dist/define.d.ts +3 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +4 -0
- package/dist/email/index.d.ts +2 -0
- package/dist/email/index.d.ts.map +1 -0
- package/{src/lib/email/index.ts → dist/email/index.js} +1 -2
- package/dist/email/interfaces/email.d.ts +42 -0
- package/dist/email/interfaces/email.d.ts.map +1 -0
- package/dist/email/interfaces/email.js +1 -0
- package/dist/engine.d.ts +26 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +66 -0
- package/dist/field-validation/rule.d.ts +51 -0
- package/dist/field-validation/rule.d.ts.map +1 -0
- package/dist/field-validation/rule.js +221 -0
- package/dist/field-validation/utils.d.ts +21 -0
- package/dist/field-validation/utils.d.ts.map +1 -0
- package/dist/field-validation/utils.js +66 -0
- package/dist/hooks.d.ts +23 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +96 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/lib/index.ts → dist/index.js} +1 -2
- package/dist/is-mobile.svelte.d.ts +5 -0
- package/dist/is-mobile.svelte.d.ts.map +1 -0
- package/{src/lib/is-mobile.svelte.ts → dist/is-mobile.svelte.js} +3 -5
- package/dist/routes/assets-by-id.d.ts +5 -0
- package/dist/routes/assets-by-id.d.ts.map +1 -0
- package/dist/routes/assets-by-id.js +138 -0
- package/dist/routes/assets-cdn.d.ts +3 -0
- package/dist/routes/assets-cdn.d.ts.map +1 -0
- package/dist/routes/assets-cdn.js +155 -0
- package/dist/routes/assets.d.ts +4 -0
- package/dist/routes/assets.d.ts.map +1 -0
- package/dist/routes/assets.js +94 -0
- package/dist/routes/documents-by-id.d.ts +5 -0
- package/dist/routes/documents-by-id.d.ts.map +1 -0
- package/dist/routes/documents-by-id.js +142 -0
- package/dist/routes/documents-publish.d.ts +4 -0
- package/dist/routes/documents-publish.d.ts.map +1 -0
- package/dist/routes/documents-publish.js +151 -0
- package/dist/routes/documents.d.ts +4 -0
- package/dist/routes/documents.d.ts.map +1 -0
- package/dist/routes/documents.js +131 -0
- package/dist/routes/index.d.ts +6 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +10 -0
- package/dist/routes/organizations-by-id.d.ts +5 -0
- package/dist/routes/organizations-by-id.d.ts.map +1 -0
- package/dist/routes/organizations-by-id.js +187 -0
- package/dist/routes/organizations-invitations.d.ts +4 -0
- package/dist/routes/organizations-invitations.d.ts.map +1 -0
- package/dist/routes/organizations-invitations.js +125 -0
- package/dist/routes/organizations-members.d.ts +5 -0
- package/dist/routes/organizations-members.d.ts.map +1 -0
- package/dist/routes/organizations-members.js +206 -0
- package/dist/routes/organizations-switch.d.ts +3 -0
- package/dist/routes/organizations-switch.d.ts.map +1 -0
- package/dist/routes/organizations-switch.js +53 -0
- package/dist/routes/organizations.d.ts +4 -0
- package/dist/routes/organizations.d.ts.map +1 -0
- package/dist/routes/organizations.js +109 -0
- package/dist/routes/schemas-by-type.d.ts +3 -0
- package/dist/routes/schemas-by-type.d.ts.map +1 -0
- package/dist/routes/schemas-by-type.js +25 -0
- package/dist/routes/schemas.d.ts +3 -0
- package/dist/routes/schemas.d.ts.map +1 -0
- package/dist/routes/schemas.js +11 -0
- package/dist/routes-exports.d.ts +14 -0
- package/dist/routes-exports.d.ts.map +1 -0
- package/dist/routes-exports.js +19 -0
- package/dist/schema-context.svelte.d.ts +10 -0
- package/dist/schema-context.svelte.d.ts.map +1 -0
- package/dist/schema-context.svelte.js +18 -0
- package/dist/schema-utils/cleanup.d.ts +21 -0
- package/dist/schema-utils/cleanup.d.ts.map +1 -0
- package/dist/schema-utils/cleanup.js +80 -0
- package/dist/schema-utils/index.d.ts +4 -0
- package/dist/schema-utils/index.d.ts.map +1 -0
- package/dist/schema-utils/index.js +4 -0
- package/dist/schema-utils/utils.d.ts +30 -0
- package/dist/schema-utils/utils.d.ts.map +1 -0
- package/dist/schema-utils/utils.js +37 -0
- package/dist/schema-utils/validator.d.ts +6 -0
- package/dist/schema-utils/validator.d.ts.map +1 -0
- package/dist/schema-utils/validator.js +45 -0
- package/dist/server/index.d.ts +16 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +28 -0
- package/dist/services/asset-service.d.ts +86 -0
- package/dist/services/asset-service.d.ts.map +1 -0
- package/dist/services/asset-service.js +187 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +4 -0
- package/dist/storage/adapters/index.d.ts +2 -0
- package/dist/storage/adapters/index.d.ts.map +1 -0
- package/dist/storage/adapters/index.js +2 -0
- package/dist/storage/adapters/local-storage-adapter.d.ts +54 -0
- package/dist/storage/adapters/local-storage-adapter.d.ts.map +1 -0
- package/dist/storage/adapters/local-storage-adapter.js +187 -0
- package/dist/storage/index.d.ts +3 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/{src/lib/storage/index.ts → dist/storage/index.js} +2 -4
- package/dist/storage/interfaces/index.d.ts +2 -0
- package/dist/storage/interfaces/index.d.ts.map +1 -0
- package/dist/storage/interfaces/index.js +2 -0
- package/dist/storage/interfaces/storage.d.ts +91 -0
- package/dist/storage/interfaces/storage.d.ts.map +1 -0
- package/dist/storage/interfaces/storage.js +1 -0
- package/dist/storage/providers/storage.d.ts +43 -0
- package/dist/storage/providers/storage.d.ts.map +1 -0
- package/dist/storage/providers/storage.js +64 -0
- package/dist/types/asset.d.ts +73 -0
- package/dist/types/asset.d.ts.map +1 -0
- package/dist/types/asset.js +2 -0
- package/dist/types/auth.d.ts +50 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +41 -0
- package/dist/types/config.d.ts +47 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +1 -0
- package/dist/types/document.d.ts +34 -0
- package/dist/types/document.d.ts.map +1 -0
- package/dist/types/document.js +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/organization.d.ts +105 -0
- package/dist/types/organization.d.ts.map +1 -0
- package/dist/types/organization.js +3 -0
- package/dist/types/schemas.d.ts +114 -0
- package/dist/types/schemas.d.ts.map +1 -0
- package/dist/types/schemas.js +1 -0
- package/dist/types/sidebar.d.ts +33 -0
- package/dist/types/sidebar.d.ts.map +1 -0
- package/dist/types/sidebar.js +1 -0
- package/dist/types/user.d.ts +14 -0
- package/dist/types/user.d.ts.map +1 -0
- package/dist/types/user.js +1 -0
- package/dist/utils/content-hash.d.ts +22 -0
- package/dist/utils/content-hash.d.ts.map +1 -0
- package/dist/utils/content-hash.js +67 -0
- package/dist/utils/image-url.d.ts +88 -0
- package/dist/utils/image-url.d.ts.map +1 -0
- package/dist/utils/image-url.js +165 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/slug.d.ts +13 -0
- package/dist/utils/slug.d.ts.map +1 -0
- package/dist/utils/slug.js +30 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +5 -0
- package/package.json +2 -2
- package/src/lib/api/assets.ts +0 -75
- package/src/lib/api/client.ts +0 -150
- package/src/lib/api/documents.ts +0 -102
- package/src/lib/api/index.ts +0 -7
- package/src/lib/api/organizations.ts +0 -154
- package/src/lib/api/types.ts +0 -34
- package/src/lib/auth/auth-errors.ts +0 -23
- package/src/lib/auth/auth-hooks.ts +0 -132
- package/src/lib/auth/provider.ts +0 -25
- package/src/lib/config.ts +0 -18
- package/src/lib/db/interfaces/asset.ts +0 -61
- package/src/lib/db/interfaces/document.ts +0 -53
- package/src/lib/db/interfaces/index.ts +0 -98
- package/src/lib/db/interfaces/organization.ts +0 -51
- package/src/lib/db/interfaces/schema.ts +0 -13
- package/src/lib/db/interfaces/user.ts +0 -16
- package/src/lib/db/utils/reference-resolver.ts +0 -119
- package/src/lib/define.ts +0 -7
- package/src/lib/email/interfaces/email.ts +0 -45
- package/src/lib/engine.ts +0 -85
- package/src/lib/field-validation/rule.ts +0 -287
- package/src/lib/field-validation/utils.ts +0 -91
- package/src/lib/hooks.ts +0 -142
- package/src/lib/routes/assets-by-id.ts +0 -161
- package/src/lib/routes/assets-cdn.ts +0 -185
- package/src/lib/routes/assets.ts +0 -116
- package/src/lib/routes/documents-by-id.ts +0 -188
- package/src/lib/routes/documents-publish.ts +0 -211
- package/src/lib/routes/documents.ts +0 -172
- package/src/lib/routes/index.ts +0 -13
- package/src/lib/routes/organizations-by-id.ts +0 -258
- package/src/lib/routes/organizations-invitations.ts +0 -183
- package/src/lib/routes/organizations-members.ts +0 -301
- package/src/lib/routes/organizations-switch.ts +0 -74
- package/src/lib/routes/organizations.ts +0 -147
- package/src/lib/routes/schemas-by-type.ts +0 -35
- package/src/lib/routes/schemas.ts +0 -19
- package/src/lib/routes-exports.ts +0 -42
- package/src/lib/schema-context.svelte.ts +0 -24
- package/src/lib/schema-utils/cleanup.ts +0 -116
- package/src/lib/schema-utils/index.ts +0 -4
- package/src/lib/schema-utils/utils.ts +0 -47
- package/src/lib/schema-utils/validator.ts +0 -58
- package/src/lib/server/index.ts +0 -40
- package/src/lib/services/asset-service.ts +0 -256
- package/src/lib/services/index.ts +0 -6
- package/src/lib/storage/adapters/index.ts +0 -2
- package/src/lib/storage/adapters/local-storage-adapter.ts +0 -215
- package/src/lib/storage/interfaces/index.ts +0 -2
- package/src/lib/storage/interfaces/storage.ts +0 -114
- package/src/lib/storage/providers/storage.ts +0 -83
- package/src/lib/types/asset.ts +0 -81
- package/src/lib/types/auth.ts +0 -80
- package/src/lib/types/config.ts +0 -45
- package/src/lib/types/document.ts +0 -38
- package/src/lib/types/index.ts +0 -8
- package/src/lib/types/organization.ts +0 -119
- package/src/lib/types/schemas.ts +0 -151
- package/src/lib/types/sidebar.ts +0 -37
- package/src/lib/types/user.ts +0 -17
- package/src/lib/utils/content-hash.ts +0 -75
- package/src/lib/utils/image-url.ts +0 -204
- package/src/lib/utils/index.ts +0 -12
- package/src/lib/utils/slug.ts +0 -33
- package/src/lib/utils.ts +0 -13
- /package/{src/lib → dist}/app.d.ts +0 -0
- /package/{src/lib → dist}/auth/MULTI_TENANCY_PLAN.md +0 -0
- /package/{src/lib → dist}/components/AdminApp.svelte +0 -0
- /package/{src/lib → dist}/components/admin/AdminLayout.svelte +0 -0
- /package/{src/lib → dist}/components/admin/DocumentEditor.svelte +0 -0
- /package/{src/lib → dist}/components/admin/DocumentTypesList.svelte +0 -0
- /package/{src/lib → dist}/components/admin/ObjectModal.svelte +0 -0
- /package/{src/lib → dist}/components/admin/SchemaField.svelte +0 -0
- /package/{src/lib → dist}/components/admin/fields/ArrayField.svelte +0 -0
- /package/{src/lib → dist}/components/admin/fields/BooleanField.svelte +0 -0
- /package/{src/lib → dist}/components/admin/fields/ImageField.svelte +0 -0
- /package/{src/lib → dist}/components/admin/fields/NumberField.svelte +0 -0
- /package/{src/lib → dist}/components/admin/fields/ReferenceField.svelte +0 -0
- /package/{src/lib → dist}/components/admin/fields/SlugField.svelte +0 -0
- /package/{src/lib → dist}/components/admin/fields/StringField.svelte +0 -0
- /package/{src/lib → dist}/components/admin/fields/TextareaField.svelte +0 -0
- /package/{src/lib/components/fields/index.ts → dist/components/fields/index.js} +0 -0
- /package/{src/lib → dist}/components/layout/OrganizationSwitcher.svelte +0 -0
- /package/{src/lib → dist}/components/layout/Sidebar.svelte +0 -0
- /package/{src/lib → dist}/components/layout/sidebar/AppSidebar.svelte +0 -0
- /package/{src/lib → dist}/components/layout/sidebar/NavMain.svelte +0 -0
- /package/{src/lib → dist}/components/layout/sidebar/NavSecondary.svelte +0 -0
- /package/{src/lib → dist}/components/layout/sidebar/NavUser.svelte +0 -0
- /package/{src/lib → dist}/plugins/README.md +0 -0
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// Organizations API client - composable organization operations
|
|
2
|
-
import { apiClient } from './client';
|
|
3
|
-
import type { Organization, OrganizationMember, OrganizationRole } from '../types/organization';
|
|
4
|
-
import type { ApiResponse } from './types';
|
|
5
|
-
|
|
6
|
-
export interface CreateOrganizationData {
|
|
7
|
-
name: string;
|
|
8
|
-
slug: string;
|
|
9
|
-
metadata?: any;
|
|
10
|
-
parentOrganizationId?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface OrganizationListItem extends Organization {
|
|
14
|
-
role: OrganizationRole;
|
|
15
|
-
joinedAt: Date;
|
|
16
|
-
isActive: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface SwitchOrganizationData {
|
|
20
|
-
organizationId: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface InviteMemberData {
|
|
24
|
-
email: string;
|
|
25
|
-
role: OrganizationRole;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface UpdateMemberRoleData {
|
|
29
|
-
userId: string;
|
|
30
|
-
role: OrganizationRole;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface RemoveMemberData {
|
|
34
|
-
userId: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface CancelInvitationData {
|
|
38
|
-
invitationId: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface UpdateOrganizationData {
|
|
42
|
-
name?: string;
|
|
43
|
-
slug?: string;
|
|
44
|
-
metadata?: any;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export class OrganizationsApi {
|
|
48
|
-
/**
|
|
49
|
-
* List user's organizations
|
|
50
|
-
*/
|
|
51
|
-
static async list(): Promise<ApiResponse<OrganizationListItem[]>> {
|
|
52
|
-
return apiClient.get<OrganizationListItem[]>('/organizations');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Create new organization (super_admin only)
|
|
57
|
-
*/
|
|
58
|
-
static async create(data: CreateOrganizationData): Promise<ApiResponse<Organization>> {
|
|
59
|
-
return apiClient.post<Organization>('/organizations', data);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Switch to a different organization
|
|
64
|
-
*/
|
|
65
|
-
static async switch(data: SwitchOrganizationData): Promise<ApiResponse<{ success: boolean }>> {
|
|
66
|
-
return apiClient.post<{ success: boolean }>('/organizations/switch', data);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Get organization by ID
|
|
71
|
-
*/
|
|
72
|
-
static async getById(id: string): Promise<ApiResponse<Organization>> {
|
|
73
|
-
return apiClient.get<Organization>(`/organizations/${id}`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get active organization
|
|
78
|
-
*/
|
|
79
|
-
static async getActive(): Promise<ApiResponse<Organization>> {
|
|
80
|
-
const result = await this.list();
|
|
81
|
-
const active = result.data?.find((org) => org.isActive);
|
|
82
|
-
if (!active) {
|
|
83
|
-
throw new Error('No active organization found');
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
success: true,
|
|
87
|
-
data: active
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Get organization members
|
|
93
|
-
*/
|
|
94
|
-
static async getMembers(): Promise<ApiResponse<OrganizationMember[]>> {
|
|
95
|
-
return apiClient.get<OrganizationMember[]>('/organizations/members');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Invite a member to the organization
|
|
100
|
-
*/
|
|
101
|
-
static async inviteMember(data: InviteMemberData): Promise<ApiResponse<OrganizationMember>> {
|
|
102
|
-
return apiClient.post<OrganizationMember>('/organizations/invitations', data);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Remove a member from the organization
|
|
107
|
-
*/
|
|
108
|
-
static async removeMember(data: RemoveMemberData): Promise<ApiResponse<{ success: boolean }>> {
|
|
109
|
-
return apiClient.delete<{ success: boolean }>('/organizations/members', data);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Update a member's role
|
|
114
|
-
*/
|
|
115
|
-
static async updateMemberRole(
|
|
116
|
-
data: UpdateMemberRoleData
|
|
117
|
-
): Promise<ApiResponse<OrganizationMember>> {
|
|
118
|
-
return apiClient.patch<OrganizationMember>('/organizations/members', data);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Update organization settings
|
|
123
|
-
*/
|
|
124
|
-
static async update(
|
|
125
|
-
id: string,
|
|
126
|
-
data: UpdateOrganizationData
|
|
127
|
-
): Promise<ApiResponse<Organization>> {
|
|
128
|
-
return apiClient.patch<Organization>(`/organizations/${id}`, data);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Cancel a pending invitation
|
|
133
|
-
*/
|
|
134
|
-
static async cancelInvitation(
|
|
135
|
-
data: CancelInvitationData
|
|
136
|
-
): Promise<ApiResponse<{ success: boolean }>> {
|
|
137
|
-
return apiClient.delete<{ success: boolean }>('/organizations/invitations', data);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Export convenience functions for direct use
|
|
142
|
-
export const organizations = {
|
|
143
|
-
list: OrganizationsApi.list.bind(OrganizationsApi),
|
|
144
|
-
create: OrganizationsApi.create.bind(OrganizationsApi),
|
|
145
|
-
switch: OrganizationsApi.switch.bind(OrganizationsApi),
|
|
146
|
-
getById: OrganizationsApi.getById.bind(OrganizationsApi),
|
|
147
|
-
getActive: OrganizationsApi.getActive.bind(OrganizationsApi),
|
|
148
|
-
update: OrganizationsApi.update.bind(OrganizationsApi),
|
|
149
|
-
getMembers: OrganizationsApi.getMembers.bind(OrganizationsApi),
|
|
150
|
-
inviteMember: OrganizationsApi.inviteMember.bind(OrganizationsApi),
|
|
151
|
-
removeMember: OrganizationsApi.removeMember.bind(OrganizationsApi),
|
|
152
|
-
updateMemberRole: OrganizationsApi.updateMemberRole.bind(OrganizationsApi),
|
|
153
|
-
cancelInvitation: OrganizationsApi.cancelInvitation.bind(OrganizationsApi)
|
|
154
|
-
};
|
package/src/lib/api/types.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// API client types
|
|
2
|
-
import type { Document, NewDocument } from '../types/index';
|
|
3
|
-
|
|
4
|
-
// API Response wrappers
|
|
5
|
-
export interface ApiResponse<T> {
|
|
6
|
-
success: boolean;
|
|
7
|
-
data?: T;
|
|
8
|
-
error?: string;
|
|
9
|
-
message?: string;
|
|
10
|
-
meta?: {
|
|
11
|
-
count: number;
|
|
12
|
-
limit: number;
|
|
13
|
-
offset: number;
|
|
14
|
-
filters: Record<string, any>;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Document-related types
|
|
19
|
-
export interface DocumentListParams {
|
|
20
|
-
docType?: string;
|
|
21
|
-
status?: string;
|
|
22
|
-
limit?: number;
|
|
23
|
-
offset?: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Use database types directly instead of duplicating
|
|
27
|
-
export type CreateDocumentData = Omit<
|
|
28
|
-
NewDocument,
|
|
29
|
-
'id' | 'createdAt' | 'updatedAt' | 'publishedAt'
|
|
30
|
-
>;
|
|
31
|
-
export type UpdateDocumentData = Partial<Pick<Document, 'draftData' | 'status'>>;
|
|
32
|
-
|
|
33
|
-
// Re-export database types for convenience
|
|
34
|
-
export type { Document, NewDocument };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Custom authentication errors with error codes for better error handling
|
|
2
|
-
|
|
3
|
-
export type AuthErrorCode =
|
|
4
|
-
| 'no_session'
|
|
5
|
-
| 'session_expired'
|
|
6
|
-
| 'no_organization'
|
|
7
|
-
| 'kicked_from_org'
|
|
8
|
-
| 'unauthorized';
|
|
9
|
-
|
|
10
|
-
export class AuthError extends Error {
|
|
11
|
-
code: AuthErrorCode;
|
|
12
|
-
|
|
13
|
-
constructor(code: AuthErrorCode, message: string) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.code = code;
|
|
16
|
-
this.name = 'AuthError';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Helper function to create auth errors
|
|
21
|
-
export function createAuthError(code: AuthErrorCode, message: string): AuthError {
|
|
22
|
-
return new AuthError(code, message);
|
|
23
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
|
-
import { redirect } from '@sveltejs/kit';
|
|
3
|
-
import type { DatabaseAdapter } from '../db/index';
|
|
4
|
-
import type { CMSConfig, Auth } from '../types/index';
|
|
5
|
-
import type { AuthProvider } from './provider';
|
|
6
|
-
import { AuthError } from './auth-errors';
|
|
7
|
-
|
|
8
|
-
export async function handleAuthHook(
|
|
9
|
-
event: RequestEvent,
|
|
10
|
-
config: CMSConfig,
|
|
11
|
-
authProvider: AuthProvider,
|
|
12
|
-
db: DatabaseAdapter
|
|
13
|
-
): Promise<Response | null> {
|
|
14
|
-
const path = event.url.pathname;
|
|
15
|
-
|
|
16
|
-
// 1. Admin UI routes - require session authentication
|
|
17
|
-
if (path.startsWith('/admin')) {
|
|
18
|
-
try {
|
|
19
|
-
const session = await authProvider.requireSession(event.request, db);
|
|
20
|
-
event.locals.auth = session;
|
|
21
|
-
} catch (error) {
|
|
22
|
-
// If it's an AuthError, redirect to login with error code
|
|
23
|
-
if (error instanceof AuthError) {
|
|
24
|
-
const loginUrl = config.auth?.loginUrl || '/login';
|
|
25
|
-
throw redirect(302, `${loginUrl}?error=${error.code}`);
|
|
26
|
-
}
|
|
27
|
-
// For other errors, redirect without error code
|
|
28
|
-
throw redirect(302, config.auth?.loginUrl || '/login');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// 2. Asset CDN routes - accept session OR API key OR signed token
|
|
33
|
-
// Support both /assets/ and /media/ paths (media is Sanity-style URL)
|
|
34
|
-
if (path.startsWith('/assets/') || path.startsWith('/media/')) {
|
|
35
|
-
// Try session first (for admin UI)
|
|
36
|
-
let auth: Auth | null = await authProvider.getSession(event.request, db);
|
|
37
|
-
|
|
38
|
-
// If no session, try API key
|
|
39
|
-
if (!auth) {
|
|
40
|
-
auth = await authProvider.validateApiKey(event.request, db);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Make auth available (can be null, route will check for signed token)
|
|
44
|
-
if (auth) {
|
|
45
|
-
event.locals.auth = auth;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// 3. API routes - accept session OR API key
|
|
50
|
-
if (path.startsWith('/api/')) {
|
|
51
|
-
// Skip auth routes (Better Auth handles these)
|
|
52
|
-
if (path.startsWith('/api/auth')) {
|
|
53
|
-
return null; // Let the main hook continue
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// If API key is explicitly provided, prioritize it over session
|
|
57
|
-
// This allows public content access even when user is logged in to a different org
|
|
58
|
-
const hasApiKey = event.request.headers.has('x-api-key');
|
|
59
|
-
let auth: Auth | null = null;
|
|
60
|
-
|
|
61
|
-
if (hasApiKey) {
|
|
62
|
-
// API key takes precedence when explicitly provided
|
|
63
|
-
auth = await authProvider.validateApiKey(event.request, db);
|
|
64
|
-
} else {
|
|
65
|
-
// Otherwise, try session (for admin UI making API calls)
|
|
66
|
-
auth = await authProvider.getSession(event.request, db);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Dynamically find the GraphQL endpoint from plugins
|
|
70
|
-
let graphqlEndpoint: string | undefined;
|
|
71
|
-
const graphqlPlugin = config.plugins?.find((p) => p.name === '@aphexcms/graphql-plugin');
|
|
72
|
-
if (graphqlPlugin && graphqlPlugin.routes) {
|
|
73
|
-
graphqlEndpoint = Object.keys(graphqlPlugin.routes)[0];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Require authentication for protected API routes
|
|
77
|
-
const protectedApiRoutes = [
|
|
78
|
-
'/api/documents',
|
|
79
|
-
'/api/assets',
|
|
80
|
-
'/api/schemas',
|
|
81
|
-
'/api/organizations',
|
|
82
|
-
'/api/settings'
|
|
83
|
-
];
|
|
84
|
-
if (graphqlEndpoint) {
|
|
85
|
-
protectedApiRoutes.push(graphqlEndpoint);
|
|
86
|
-
}
|
|
87
|
-
const isProtectedRoute = protectedApiRoutes.some((route) => path.startsWith(route));
|
|
88
|
-
|
|
89
|
-
if (isProtectedRoute && !auth) {
|
|
90
|
-
return new Response(JSON.stringify({ error: 'Unauthorized' }), {
|
|
91
|
-
status: 401,
|
|
92
|
-
headers: { 'Content-Type': 'application/json' }
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Check write permission for mutations
|
|
97
|
-
if (auth && ['POST', 'PUT', 'PATCH', 'DELETE'].includes(event.request.method)) {
|
|
98
|
-
// Special handling for GraphQL
|
|
99
|
-
if (graphqlEndpoint && path.startsWith(graphqlEndpoint)) {
|
|
100
|
-
// We need to read the body to check if it's a mutation.
|
|
101
|
-
// It's important to clone the request so we don't consume the body stream.
|
|
102
|
-
const requestBody = await event.request.clone().text();
|
|
103
|
-
const isMutation = requestBody.trim().startsWith('mutation');
|
|
104
|
-
|
|
105
|
-
if (isMutation && auth.type === 'api_key' && !auth.permissions.includes('write')) {
|
|
106
|
-
return new Response(
|
|
107
|
-
JSON.stringify({ error: 'Forbidden: Write permission required for mutations' }),
|
|
108
|
-
{
|
|
109
|
-
status: 403,
|
|
110
|
-
headers: { 'Content-Type': 'application/json' }
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
} else {
|
|
115
|
-
// Existing logic for other API routes
|
|
116
|
-
if (auth.type === 'api_key' && !auth.permissions.includes('write')) {
|
|
117
|
-
return new Response(JSON.stringify({ error: 'Forbidden: Write permission required' }), {
|
|
118
|
-
status: 403,
|
|
119
|
-
headers: { 'Content-Type': 'application/json' }
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Make auth available in API routes
|
|
126
|
-
if (auth) {
|
|
127
|
-
event.locals.auth = auth;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return null; // Tell the main hook to continue
|
|
132
|
-
}
|
package/src/lib/auth/provider.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// packages/cms-core/src/auth/provider.ts
|
|
2
|
-
import type { SessionAuth, ApiKeyAuth } from '../types/index';
|
|
3
|
-
import type { DatabaseAdapter } from '../db/interfaces/index';
|
|
4
|
-
|
|
5
|
-
export interface AuthProvider {
|
|
6
|
-
// Session auth (browser, admin UI)
|
|
7
|
-
getSession(request: Request, db: DatabaseAdapter): Promise<SessionAuth | null>;
|
|
8
|
-
requireSession(request: Request, db: DatabaseAdapter): Promise<SessionAuth>;
|
|
9
|
-
|
|
10
|
-
// API key auth (programmatic access)
|
|
11
|
-
validateApiKey(request: Request, db: DatabaseAdapter): Promise<ApiKeyAuth | null>;
|
|
12
|
-
requireApiKey(
|
|
13
|
-
request: Request,
|
|
14
|
-
db: DatabaseAdapter,
|
|
15
|
-
permission?: 'read' | 'write'
|
|
16
|
-
): Promise<ApiKeyAuth>;
|
|
17
|
-
|
|
18
|
-
// User management
|
|
19
|
-
getUserById(userId: string): Promise<{ id: string; name?: string; email: string } | null>;
|
|
20
|
-
changeUserName(userId: string, name: string): Promise<void>;
|
|
21
|
-
|
|
22
|
-
// Password reset
|
|
23
|
-
requestPasswordReset(email: string, redirectTo?: string): Promise<void>;
|
|
24
|
-
resetPassword(token: string, newPassword: string): Promise<void>;
|
|
25
|
-
}
|
package/src/lib/config.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Aphex CMS Configuration System
|
|
2
|
-
import type { CMSConfig } from './types/index';
|
|
3
|
-
|
|
4
|
-
export function createCMSConfig(config: CMSConfig): CMSConfig {
|
|
5
|
-
return {
|
|
6
|
-
// Start with the user's config and apply defaults for missing properties
|
|
7
|
-
...config,
|
|
8
|
-
storage: config.storage ?? null, // Default to null if not provided
|
|
9
|
-
customization: {
|
|
10
|
-
branding: {
|
|
11
|
-
title: 'Aphex CMS',
|
|
12
|
-
...config.customization?.branding
|
|
13
|
-
},
|
|
14
|
-
...config.customization
|
|
15
|
-
},
|
|
16
|
-
plugins: config.plugins ?? []
|
|
17
|
-
};
|
|
18
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// Asset interface for asset operations
|
|
2
|
-
import type { Asset } from '../../types/index';
|
|
3
|
-
|
|
4
|
-
export interface AssetFilters {
|
|
5
|
-
organizationId: string; // Required for multi-tenancy (user's current org for RLS context)
|
|
6
|
-
assetType?: 'image' | 'file';
|
|
7
|
-
mimeType?: string;
|
|
8
|
-
search?: string;
|
|
9
|
-
limit?: number;
|
|
10
|
-
offset?: number;
|
|
11
|
-
filterOrganizationIds?: string[]; // Optional: Filter to specific org(s). RLS still enforces access.
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface CreateAssetData {
|
|
15
|
-
organizationId: string; // Required for multi-tenancy
|
|
16
|
-
assetType: 'image' | 'file';
|
|
17
|
-
filename: string;
|
|
18
|
-
originalFilename: string;
|
|
19
|
-
mimeType: string;
|
|
20
|
-
size: number;
|
|
21
|
-
url: string;
|
|
22
|
-
path: string;
|
|
23
|
-
storageAdapter: string; // Which storage adapter was used
|
|
24
|
-
width?: number;
|
|
25
|
-
height?: number;
|
|
26
|
-
metadata?: any;
|
|
27
|
-
title?: string;
|
|
28
|
-
description?: string;
|
|
29
|
-
alt?: string;
|
|
30
|
-
creditLine?: string;
|
|
31
|
-
createdBy?: string; // User ID (optional for backward compatibility)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface UpdateAssetData {
|
|
35
|
-
url?: string; // Allow updating URL (for local storage after asset creation)
|
|
36
|
-
title?: string;
|
|
37
|
-
description?: string;
|
|
38
|
-
alt?: string;
|
|
39
|
-
creditLine?: string;
|
|
40
|
-
updatedBy?: string; // User ID (optional for backward compatibility)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Asset adapter interface for asset-specific operations
|
|
45
|
-
*/
|
|
46
|
-
export interface AssetAdapter {
|
|
47
|
-
// Asset CRUD operations
|
|
48
|
-
createAsset(data: CreateAssetData): Promise<Asset>;
|
|
49
|
-
findAssetById(organizationId: string, id: string): Promise<Asset | null>;
|
|
50
|
-
findAssets(
|
|
51
|
-
organizationId: string,
|
|
52
|
-
filters?: Omit<AssetFilters, 'organizationId'>
|
|
53
|
-
): Promise<Asset[]>;
|
|
54
|
-
updateAsset(organizationId: string, id: string, data: UpdateAssetData): Promise<Asset | null>;
|
|
55
|
-
deleteAsset(organizationId: string, id: string): Promise<boolean>;
|
|
56
|
-
|
|
57
|
-
// Asset analytics
|
|
58
|
-
countAssets(organizationId: string): Promise<number>;
|
|
59
|
-
countAssetsByType(organizationId: string): Promise<Record<string, number>>;
|
|
60
|
-
getTotalAssetsSize(organizationId: string): Promise<number>;
|
|
61
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// Document interface for document operations
|
|
2
|
-
import type { Document } from '../../types/index';
|
|
3
|
-
|
|
4
|
-
export interface DocumentFilters {
|
|
5
|
-
organizationId: string; // Required for multi-tenancy (user's current org for RLS context)
|
|
6
|
-
type?: string;
|
|
7
|
-
status?: string;
|
|
8
|
-
limit?: number;
|
|
9
|
-
offset?: number;
|
|
10
|
-
depth?: number; // How deep to resolve nested references (0 = no resolution, default = 0)
|
|
11
|
-
filterOrganizationIds?: string[]; // Optional: Filter to specific org(s). RLS still enforces access.
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface CreateDocumentData {
|
|
15
|
-
organizationId: string; // Required for multi-tenancy
|
|
16
|
-
type: string;
|
|
17
|
-
draftData: any;
|
|
18
|
-
createdBy?: string; // User ID (optional for backward compatibility)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface UpdateDocumentData {
|
|
22
|
-
draftData?: any;
|
|
23
|
-
status?: string;
|
|
24
|
-
updatedBy?: string; // User ID (optional for backward compatibility)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Document adapter interface for document-specific operations
|
|
29
|
-
*/
|
|
30
|
-
export interface DocumentAdapter {
|
|
31
|
-
// Document CRUD operations
|
|
32
|
-
findManyDoc(
|
|
33
|
-
organizationId: string,
|
|
34
|
-
filters?: Omit<DocumentFilters, 'organizationId'>
|
|
35
|
-
): Promise<Document[]>;
|
|
36
|
-
findByDocId(organizationId: string, id: string, depth?: number): Promise<Document | null>;
|
|
37
|
-
createDocument(data: CreateDocumentData): Promise<Document>;
|
|
38
|
-
updateDocDraft(
|
|
39
|
-
organizationId: string,
|
|
40
|
-
id: string,
|
|
41
|
-
data: any,
|
|
42
|
-
updatedBy?: string
|
|
43
|
-
): Promise<Document | null>;
|
|
44
|
-
deleteDocById(organizationId: string, id: string): Promise<boolean>;
|
|
45
|
-
|
|
46
|
-
// Publishing operations
|
|
47
|
-
publishDoc(organizationId: string, id: string): Promise<Document | null>;
|
|
48
|
-
unpublishDoc(organizationId: string, id: string): Promise<Document | null>;
|
|
49
|
-
|
|
50
|
-
// Analytics/counts
|
|
51
|
-
countDocsByType(organizationId: string, type: string): Promise<number>;
|
|
52
|
-
getDocCountsByType(organizationId: string): Promise<Record<string, number>>;
|
|
53
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// Combined database interface
|
|
2
|
-
import type { DocumentAdapter } from './document';
|
|
3
|
-
import type { AssetAdapter } from './asset';
|
|
4
|
-
import type { UserProfileAdapter } from './user';
|
|
5
|
-
import type { SchemaAdapter } from './schema';
|
|
6
|
-
import type { OrganizationAdapter } from './organization';
|
|
7
|
-
|
|
8
|
-
// Re-export individual interfaces
|
|
9
|
-
export type {
|
|
10
|
-
DocumentAdapter,
|
|
11
|
-
DocumentFilters,
|
|
12
|
-
CreateDocumentData,
|
|
13
|
-
UpdateDocumentData
|
|
14
|
-
} from './document';
|
|
15
|
-
export type { AssetAdapter, CreateAssetData, UpdateAssetData } from './asset';
|
|
16
|
-
export type { UserProfileAdapter, NewUserProfileData } from './user';
|
|
17
|
-
export type { SchemaAdapter } from './schema';
|
|
18
|
-
export type { OrganizationAdapter } from './organization';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Combined database adapter interface
|
|
22
|
-
* Extends all entity-specific adapters for full database functionality
|
|
23
|
-
*/
|
|
24
|
-
export interface DatabaseAdapter
|
|
25
|
-
extends DocumentAdapter,
|
|
26
|
-
AssetAdapter,
|
|
27
|
-
UserProfileAdapter,
|
|
28
|
-
SchemaAdapter,
|
|
29
|
-
OrganizationAdapter {
|
|
30
|
-
// Connection management
|
|
31
|
-
connect?(): Promise<void>;
|
|
32
|
-
disconnect?(): Promise<void>;
|
|
33
|
-
|
|
34
|
-
// Health check
|
|
35
|
-
isHealthy(): Promise<boolean>;
|
|
36
|
-
|
|
37
|
-
// Multi-tenancy RLS methods (optional - only for adapters that support RLS)
|
|
38
|
-
/**
|
|
39
|
-
* Initialize RLS (enable/disable) on tables - call after migrations
|
|
40
|
-
*/
|
|
41
|
-
initializeRLS?(): Promise<void>;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Execute a function within a transaction with organization context set for RLS
|
|
45
|
-
* Ensures proper isolation with connection pooling
|
|
46
|
-
*/
|
|
47
|
-
withOrgContext?<T>(organizationId: string, fn: () => Promise<T>): Promise<T>;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Get all child organizations for a parent (for hierarchy support)
|
|
51
|
-
*/
|
|
52
|
-
getChildOrganizations?(parentOrganizationId: string): Promise<string[]>;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Check if any user profiles exist in the system (for first-user detection)
|
|
56
|
-
*/
|
|
57
|
-
hasAnyUserProfiles?(): Promise<boolean>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Database provider factory interface
|
|
62
|
-
* Providers are pre-configured and create adapters on demand
|
|
63
|
-
*/
|
|
64
|
-
export interface DatabaseProvider {
|
|
65
|
-
name: string;
|
|
66
|
-
createAdapter(): DatabaseAdapter;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Generic database configuration
|
|
71
|
-
*/
|
|
72
|
-
export interface DatabaseConfig {
|
|
73
|
-
connectionString?: string; // Optional if client is provided
|
|
74
|
-
client?: any; // Pre-initialized database client (recommended for database agnosticism)
|
|
75
|
-
options?: {
|
|
76
|
-
maxConnections?: number;
|
|
77
|
-
timeout?: number;
|
|
78
|
-
ssl?: boolean;
|
|
79
|
-
[key: string]: any;
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Database transaction interface (optional for advanced providers)
|
|
85
|
-
*/
|
|
86
|
-
export interface DatabaseTransaction {
|
|
87
|
-
commit(): Promise<void>;
|
|
88
|
-
rollback(): Promise<void>;
|
|
89
|
-
isActive(): boolean;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Extended database adapter with transaction support
|
|
94
|
-
*/
|
|
95
|
-
export interface TransactionalDatabaseAdapter extends DatabaseAdapter {
|
|
96
|
-
beginTransaction(): Promise<DatabaseTransaction>;
|
|
97
|
-
withTransaction<T>(fn: (adapter: DatabaseAdapter) => Promise<T>): Promise<T>;
|
|
98
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Organization adapter interface for multi-tenancy operations
|
|
2
|
-
import type {
|
|
3
|
-
Organization,
|
|
4
|
-
NewOrganization,
|
|
5
|
-
OrganizationMember,
|
|
6
|
-
NewOrganizationMember,
|
|
7
|
-
Invitation,
|
|
8
|
-
NewInvitation,
|
|
9
|
-
UserSession,
|
|
10
|
-
OrganizationMembership
|
|
11
|
-
} from '../../types/organization';
|
|
12
|
-
|
|
13
|
-
export interface OrganizationAdapter {
|
|
14
|
-
// Organization CRUD
|
|
15
|
-
createOrganization(data: NewOrganization): Promise<Organization>;
|
|
16
|
-
findOrganizationById(id: string): Promise<Organization | null>;
|
|
17
|
-
findOrganizationBySlug(slug: string): Promise<Organization | null>;
|
|
18
|
-
updateOrganization(
|
|
19
|
-
id: string,
|
|
20
|
-
data: Partial<Omit<Organization, 'id' | 'createdAt' | 'createdBy'>>
|
|
21
|
-
): Promise<Organization | null>;
|
|
22
|
-
deleteOrganization(id: string): Promise<boolean>;
|
|
23
|
-
|
|
24
|
-
// Member management
|
|
25
|
-
addMember(data: NewOrganizationMember): Promise<OrganizationMember>;
|
|
26
|
-
removeMember(organizationId: string, userId: string): Promise<boolean>;
|
|
27
|
-
removeAllMembers(organizationId: string): Promise<boolean>;
|
|
28
|
-
updateMemberRole(
|
|
29
|
-
organizationId: string,
|
|
30
|
-
userId: string,
|
|
31
|
-
role: 'owner' | 'admin' | 'editor' | 'viewer'
|
|
32
|
-
): Promise<OrganizationMember | null>;
|
|
33
|
-
findUserMembership(userId: string, organizationId: string): Promise<OrganizationMember | null>;
|
|
34
|
-
findUserOrganizations(userId: string): Promise<OrganizationMembership[]>;
|
|
35
|
-
findOrganizationMembers(organizationId: string): Promise<OrganizationMember[]>;
|
|
36
|
-
|
|
37
|
-
// Invitation management
|
|
38
|
-
createInvitation(data: NewInvitation): Promise<Invitation>;
|
|
39
|
-
findInvitationByToken(token: string): Promise<Invitation | null>;
|
|
40
|
-
findOrganizationInvitations(organizationId: string): Promise<Invitation[]>;
|
|
41
|
-
findInvitationsByEmail(email: string): Promise<Invitation[]>;
|
|
42
|
-
acceptInvitation(token: string, userId: string): Promise<OrganizationMember>;
|
|
43
|
-
deleteInvitation(id: string): Promise<boolean>;
|
|
44
|
-
removeAllInvitations(organizationId: string): Promise<boolean>;
|
|
45
|
-
cleanupExpiredInvitations(): Promise<number>;
|
|
46
|
-
|
|
47
|
-
// User session management
|
|
48
|
-
updateUserSession(userId: string, organizationId: string): Promise<void>;
|
|
49
|
-
findUserSession(userId: string): Promise<UserSession | null>;
|
|
50
|
-
deleteUserSession(userId: string): Promise<boolean>;
|
|
51
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { SchemaType } from '../../types/index';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Defines database operations for managing schemas.
|
|
5
|
-
*/
|
|
6
|
-
export interface SchemaAdapter {
|
|
7
|
-
registerSchemaType(schemaType: SchemaType): Promise<void>;
|
|
8
|
-
getSchemaType(name: string): Promise<SchemaType | null>;
|
|
9
|
-
listSchemas(): Promise<SchemaType[]>;
|
|
10
|
-
listDocumentTypes(): Promise<Array<{ name: string; title: string; description?: string }>>;
|
|
11
|
-
listObjectTypes(): Promise<Array<{ name: string; title: string; description?: string }>>;
|
|
12
|
-
deleteSchemaType(name: string): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { UserProfile } from '../../types/index';
|
|
2
|
-
|
|
3
|
-
export interface NewUserProfileData {
|
|
4
|
-
userId: string;
|
|
5
|
-
role?: 'super_admin' | 'admin' | 'editor' | 'viewer';
|
|
6
|
-
preferences?: Record<string, any>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Defines database operations for managing user profiles.
|
|
11
|
-
*/
|
|
12
|
-
export interface UserProfileAdapter {
|
|
13
|
-
createUserProfile(data: NewUserProfileData): Promise<UserProfile>;
|
|
14
|
-
findUserProfileById(userId: string): Promise<UserProfile | null>;
|
|
15
|
-
deleteUserProfile(userId: string): Promise<boolean>;
|
|
16
|
-
}
|