@aphexcms/cms-core 11.2.1 → 12.0.0-next.20261109083516
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/admin/client-auth.svelte.d.ts +120 -0
- package/dist/admin/client-auth.svelte.d.ts.map +1 -0
- package/dist/admin/client-auth.svelte.js +14 -0
- package/dist/admin/client-config.d.ts +72 -0
- package/dist/admin/client-config.d.ts.map +1 -0
- package/dist/admin/client-config.js +1 -0
- package/dist/admin/settings-header-actions.d.ts +12 -0
- package/dist/admin/settings-header-actions.d.ts.map +1 -0
- package/dist/admin/settings-header-actions.js +1 -0
- package/dist/admin/view-data.d.ts +189 -0
- package/dist/admin/view-data.d.ts.map +1 -0
- package/dist/admin/view-data.js +1 -0
- package/dist/admin.css +6 -0
- package/dist/api/invitations.d.ts +2 -2
- package/dist/api/invitations.d.ts.map +1 -1
- package/dist/api/organizations.d.ts +13 -3
- package/dist/api/organizations.d.ts.map +1 -1
- package/dist/api/organizations.js +11 -1
- package/dist/api/user.d.ts +6 -1
- package/dist/api/user.d.ts.map +1 -1
- package/dist/api/user.js +7 -0
- package/dist/app-augment.d.ts +2 -3
- package/dist/app-augment.d.ts.map +1 -1
- package/dist/app.d.ts +1 -1
- package/dist/auth/auth-errors.d.ts +6 -0
- package/dist/auth/auth-errors.d.ts.map +1 -1
- package/dist/auth/auth-errors.js +8 -0
- package/dist/auth/auth-hooks.d.ts.map +1 -1
- package/dist/auth/auth-hooks.js +36 -17
- package/dist/auth/invitation-email.d.ts +9 -0
- package/dist/auth/invitation-email.d.ts.map +1 -0
- package/dist/auth/invitation-email.js +49 -0
- package/dist/auth/pages.d.ts +16 -0
- package/dist/auth/pages.d.ts.map +1 -0
- package/dist/auth/pages.js +23 -0
- package/dist/auth/provider.d.ts +31 -1
- package/dist/auth/provider.d.ts.map +1 -1
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +9 -0
- package/dist/client/ui.d.ts +17 -0
- package/dist/client/ui.d.ts.map +1 -1
- package/dist/client/ui.js +27 -0
- package/dist/components/AdminApp.svelte +7 -4
- package/dist/components/AdminApp.svelte.d.ts.map +1 -1
- package/dist/components/AphexStudio.svelte +268 -0
- package/dist/components/AphexStudio.svelte.d.ts +16 -0
- package/dist/components/AphexStudio.svelte.d.ts.map +1 -0
- package/dist/components/admin/AccountSettings.svelte +339 -0
- package/dist/components/admin/AccountSettings.svelte.d.ts +8 -0
- package/dist/components/admin/AccountSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/AccountSettingsView.svelte +61 -0
- package/dist/components/admin/AccountSettingsView.svelte.d.ts +19 -0
- package/dist/components/admin/AccountSettingsView.svelte.d.ts.map +1 -0
- package/dist/components/admin/ApiKeysSettings.svelte +435 -0
- package/dist/components/admin/ApiKeysSettings.svelte.d.ts +15 -0
- package/dist/components/admin/ApiKeysSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/AuthPageShell.svelte +32 -0
- package/dist/components/admin/AuthPageShell.svelte.d.ts +16 -0
- package/dist/components/admin/AuthPageShell.svelte.d.ts.map +1 -0
- package/dist/components/admin/CreateOrganization.svelte +158 -0
- package/dist/components/admin/CreateOrganization.svelte.d.ts +11 -0
- package/dist/components/admin/CreateOrganization.svelte.d.ts.map +1 -0
- package/dist/components/admin/DeleteAccountSettings.svelte +124 -0
- package/dist/components/admin/DeleteAccountSettings.svelte.d.ts +7 -0
- package/dist/components/admin/DeleteAccountSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/DeleteOrganizationSettings.svelte +123 -0
- package/dist/components/admin/DeleteOrganizationSettings.svelte.d.ts +11 -0
- package/dist/components/admin/DeleteOrganizationSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/DocumentEditor.svelte +108 -36
- package/dist/components/admin/DocumentEditor.svelte.d.ts.map +1 -1
- package/dist/components/admin/GeneralSettings.svelte +45 -0
- package/dist/components/admin/GeneralSettings.svelte.d.ts +10 -0
- package/dist/components/admin/GeneralSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/GodModeView.svelte +112 -0
- package/dist/components/admin/GodModeView.svelte.d.ts +9 -0
- package/dist/components/admin/GodModeView.svelte.d.ts.map +1 -0
- package/dist/components/admin/InvitationsView.svelte +277 -0
- package/dist/components/admin/InvitationsView.svelte.d.ts +11 -0
- package/dist/components/admin/InvitationsView.svelte.d.ts.map +1 -0
- package/dist/components/admin/InviteView.svelte +98 -0
- package/dist/components/admin/InviteView.svelte.d.ts +9 -0
- package/dist/components/admin/InviteView.svelte.d.ts.map +1 -0
- package/dist/components/admin/LoginView.svelte +478 -0
- package/dist/components/admin/LoginView.svelte.d.ts +5 -0
- package/dist/components/admin/LoginView.svelte.d.ts.map +1 -0
- package/dist/components/admin/MembersSettings.svelte +661 -0
- package/dist/components/admin/MembersSettings.svelte.d.ts +8 -0
- package/dist/components/admin/MembersSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/OrganizationSettings.svelte +367 -0
- package/dist/components/admin/OrganizationSettings.svelte.d.ts +9 -0
- package/dist/components/admin/OrganizationSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/OrganizationsList.svelte +92 -0
- package/dist/components/admin/OrganizationsList.svelte.d.ts +8 -0
- package/dist/components/admin/OrganizationsList.svelte.d.ts.map +1 -0
- package/dist/components/admin/OrganizationsView.svelte +31 -0
- package/dist/components/admin/OrganizationsView.svelte.d.ts +9 -0
- package/dist/components/admin/OrganizationsView.svelte.d.ts.map +1 -0
- package/dist/components/admin/PasswordInput.svelte +43 -0
- package/dist/components/admin/PasswordInput.svelte.d.ts +8 -0
- package/dist/components/admin/PasswordInput.svelte.d.ts.map +1 -0
- package/dist/components/admin/PasswordSettings.svelte +179 -0
- package/dist/components/admin/PasswordSettings.svelte.d.ts +4 -0
- package/dist/components/admin/PasswordSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/PreferencesSettings.svelte +80 -0
- package/dist/components/admin/PreferencesSettings.svelte.d.ts +20 -0
- package/dist/components/admin/PreferencesSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/ResetPasswordView.svelte +117 -0
- package/dist/components/admin/ResetPasswordView.svelte.d.ts +9 -0
- package/dist/components/admin/ResetPasswordView.svelte.d.ts.map +1 -0
- package/dist/components/admin/RolesSettings.svelte +360 -0
- package/dist/components/admin/RolesSettings.svelte.d.ts +11 -0
- package/dist/components/admin/RolesSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/SchemaField.svelte +12 -2
- package/dist/components/admin/SchemaField.svelte.d.ts.map +1 -1
- package/dist/components/admin/SettingsHeaderActions.svelte +25 -0
- package/dist/components/admin/SettingsHeaderActions.svelte.d.ts +8 -0
- package/dist/components/admin/SettingsHeaderActions.svelte.d.ts.map +1 -0
- package/dist/components/admin/SettingsShell.svelte +136 -0
- package/dist/components/admin/SettingsShell.svelte.d.ts +9 -0
- package/dist/components/admin/SettingsShell.svelte.d.ts.map +1 -0
- package/dist/components/admin/TwoFactorChallengeView.svelte +377 -0
- package/dist/components/admin/TwoFactorChallengeView.svelte.d.ts +11 -0
- package/dist/components/admin/TwoFactorChallengeView.svelte.d.ts.map +1 -0
- package/dist/components/admin/TwoFactorSettings.svelte +436 -0
- package/dist/components/admin/TwoFactorSettings.svelte.d.ts +7 -0
- package/dist/components/admin/TwoFactorSettings.svelte.d.ts.map +1 -0
- package/dist/components/admin/fields/ImageField.svelte +4 -2
- package/dist/components/admin/fields/SlugField.svelte +3 -1
- package/dist/components/admin/fields/SlugField.svelte.d.ts.map +1 -1
- package/dist/components/admin/fields/richtext/PortableTextImageView.svelte +3 -2
- package/dist/components/admin/fields/richtext/RichtextField.svelte +54 -7
- package/dist/components/admin/fields/richtext/RichtextField.svelte.d.ts.map +1 -1
- package/dist/components/layout/sidebar/NavUser.svelte +2 -2
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/db/interfaces/document.d.ts +15 -2
- package/dist/db/interfaces/document.d.ts.map +1 -1
- package/dist/db/interfaces/index.d.ts +1 -1
- package/dist/db/interfaces/index.d.ts.map +1 -1
- package/dist/email/index.d.ts +1 -0
- package/dist/email/index.d.ts.map +1 -1
- package/dist/email/index.js +2 -0
- package/dist/email/interfaces/email.d.ts +2 -0
- package/dist/email/interfaces/email.d.ts.map +1 -1
- package/dist/email/link-email.d.ts +15 -0
- package/dist/email/link-email.d.ts.map +1 -0
- package/dist/email/link-email.js +30 -0
- package/dist/field-validation/date-utils.d.ts.map +1 -1
- package/dist/field-validation/date-utils.js +4 -2
- package/dist/field-validation/utils.d.ts +42 -2
- package/dist/field-validation/utils.d.ts.map +1 -1
- package/dist/field-validation/utils.js +176 -14
- package/dist/graphql/index.d.ts.map +1 -1
- package/dist/graphql/index.js +1 -1
- package/dist/hooks.d.ts +6 -3
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +53 -17
- package/dist/jobs/recurring.d.ts +4 -1
- package/dist/jobs/recurring.d.ts.map +1 -1
- package/dist/jobs/recurring.js +28 -0
- package/dist/local-api/auth-helpers.d.ts +4 -4
- package/dist/local-api/auth-helpers.js +4 -4
- package/dist/local-api/collection-api.d.ts +10 -1
- package/dist/local-api/collection-api.d.ts.map +1 -1
- package/dist/local-api/collection-api.js +40 -12
- package/dist/local-api/index.d.ts +1 -1
- package/dist/local-api/index.d.ts.map +1 -1
- package/dist/local-api/index.js +12 -6
- package/dist/local-api/types.d.ts +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +3 -1
- package/dist/preview/perspective.d.ts +1 -1
- package/dist/preview/perspective.js +1 -1
- package/dist/resolve-config.d.ts +22 -0
- package/dist/resolve-config.d.ts.map +1 -0
- package/dist/resolve-config.js +106 -0
- package/dist/routes/assets-cdn.d.ts +7 -2
- package/dist/routes/assets-cdn.d.ts.map +1 -1
- package/dist/routes/assets-cdn.js +11 -5
- package/dist/server/api/index.d.ts +1 -2
- package/dist/server/api/index.d.ts.map +1 -1
- package/dist/server/api/index.js +12 -3
- package/dist/server/api/openapi/registry.d.ts.map +1 -1
- package/dist/server/api/openapi/registry.js +70 -0
- package/dist/server/api/routes/api-keys.d.ts +4 -0
- package/dist/server/api/routes/api-keys.d.ts.map +1 -0
- package/dist/server/api/routes/api-keys.js +88 -0
- package/dist/server/api/routes/documents-by-id.d.ts.map +1 -1
- package/dist/server/api/routes/documents-by-id.js +16 -1
- package/dist/server/api/routes/documents-publish.d.ts.map +1 -1
- package/dist/server/api/routes/documents-publish.js +11 -1
- package/dist/server/api/routes/documents.d.ts.map +1 -1
- package/dist/server/api/routes/documents.js +16 -2
- package/dist/server/api/routes/instance-settings.d.ts +4 -0
- package/dist/server/api/routes/instance-settings.d.ts.map +1 -0
- package/dist/server/api/routes/instance-settings.js +47 -0
- package/dist/server/api/routes/invitations.d.ts +9 -0
- package/dist/server/api/routes/invitations.d.ts.map +1 -0
- package/dist/server/api/routes/invitations.js +79 -0
- package/dist/server/api/routes/organizations-invitations.d.ts +0 -6
- package/dist/server/api/routes/organizations-invitations.d.ts.map +1 -1
- package/dist/server/api/routes/organizations-invitations.js +6 -7
- package/dist/server/api/routes/organizations-team.d.ts +14 -0
- package/dist/server/api/routes/organizations-team.d.ts.map +1 -0
- package/dist/server/api/routes/organizations-team.js +36 -0
- package/dist/server/api/routes/organizations.d.ts.map +1 -1
- package/dist/server/api/routes/organizations.js +35 -9
- package/dist/server/core-routes.d.ts +8 -0
- package/dist/server/core-routes.d.ts.map +1 -0
- package/dist/server/core-routes.js +67 -0
- package/dist/server/index.d.ts +5 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +7 -1
- package/dist/server/pages/admin.d.ts +24 -0
- package/dist/server/pages/admin.d.ts.map +1 -0
- package/dist/server/pages/admin.js +468 -0
- package/dist/server/queries/organization-team.d.ts +14 -0
- package/dist/server/queries/organization-team.d.ts.map +1 -0
- package/dist/server/queries/organization-team.js +65 -0
- package/dist/server/queries/pending-invitations.d.ts +8 -0
- package/dist/server/queries/pending-invitations.d.ts.map +1 -0
- package/dist/server/queries/pending-invitations.js +24 -0
- package/dist/types/api-key.d.ts +18 -0
- package/dist/types/api-key.d.ts.map +1 -0
- package/dist/types/api-key.js +1 -0
- package/dist/types/auth.d.ts +35 -0
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/capabilities.d.ts +1 -2
- package/dist/types/capabilities.d.ts.map +1 -1
- package/dist/types/config.d.ts +124 -4
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/filters.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/organization.d.ts +30 -0
- package/dist/types/organization.d.ts.map +1 -1
- package/dist/utils/preview.d.ts +8 -1
- package/dist/utils/preview.d.ts.map +1 -1
- package/dist/utils/preview.js +35 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +46 -39
- package/package.json +19 -29
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
function isDatabaseDescriptor(database) {
|
|
2
|
+
return 'kind' in database && database.kind === 'aphex/database';
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Connect once per `descriptor.key`. Schema hot reload re-evaluates the config and
|
|
6
|
+
* so produces a new descriptor each time; without this every edit would open
|
|
7
|
+
* another connection pool and re-run boot migrations. A failed attempt isn't kept,
|
|
8
|
+
* so the next request can retry once the database is reachable.
|
|
9
|
+
*/
|
|
10
|
+
function connectOnce(descriptor, options) {
|
|
11
|
+
const connections = (globalThis.__aphexDatabaseConnections ??= new Map());
|
|
12
|
+
const existing = connections.get(descriptor.key);
|
|
13
|
+
if (existing)
|
|
14
|
+
return existing;
|
|
15
|
+
const connection = descriptor.connect(options);
|
|
16
|
+
connections.set(descriptor.key, connection);
|
|
17
|
+
connection.catch(() => {
|
|
18
|
+
if (connections.get(descriptor.key) === connection)
|
|
19
|
+
connections.delete(descriptor.key);
|
|
20
|
+
});
|
|
21
|
+
return connection;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Whether this is SvelteKit's build pass. Imported dynamically because `$app/*` only
|
|
25
|
+
* exists under Vite, and `@aphexcms/cms-core/server` also loads in plain scripts.
|
|
26
|
+
*/
|
|
27
|
+
export async function isBuilding() {
|
|
28
|
+
try {
|
|
29
|
+
return (await import('$app/environment')).building;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Per declared config object, so a script or test calling `getAphex(config)` shares
|
|
36
|
+
// the auth provider and connection the request hook uses. Hot reload produces a new
|
|
37
|
+
// config object, which is how an edit to the auth factory takes effect.
|
|
38
|
+
const resolutions = new WeakMap();
|
|
39
|
+
/**
|
|
40
|
+
* The resolved CMS for code outside a request, such as scripts and tests. Inside a
|
|
41
|
+
* request, use `event.locals.aphexCMS`.
|
|
42
|
+
*/
|
|
43
|
+
export function getAphex(input) {
|
|
44
|
+
const existing = resolutions.get(input);
|
|
45
|
+
if (existing)
|
|
46
|
+
return existing;
|
|
47
|
+
const resolution = resolve(input);
|
|
48
|
+
resolutions.set(input, resolution);
|
|
49
|
+
resolution.catch(() => resolutions.delete(input));
|
|
50
|
+
return resolution;
|
|
51
|
+
}
|
|
52
|
+
export async function resolveCMSConfig(input) {
|
|
53
|
+
return (await getAphex(input)).config;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve deferred adapters, in dependency order: the database first, then auth,
|
|
57
|
+
* which is handed the database, cache and email it needs. That is what lets all of
|
|
58
|
+
* them be declared inline in one file with no shared singleton modules.
|
|
59
|
+
*/
|
|
60
|
+
async function resolve(input) {
|
|
61
|
+
const building = await isBuilding();
|
|
62
|
+
let database;
|
|
63
|
+
let connected = null;
|
|
64
|
+
if (isDatabaseDescriptor(input.database)) {
|
|
65
|
+
connected = await connectOnce(input.database, {
|
|
66
|
+
tables: input.auth?.tables?.[input.database.dialect],
|
|
67
|
+
building
|
|
68
|
+
});
|
|
69
|
+
database = connected.adapter;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
database = input.database;
|
|
73
|
+
}
|
|
74
|
+
if (!input.auth)
|
|
75
|
+
return { config: { ...input, database, auth: undefined }, database: connected };
|
|
76
|
+
const { provider, tables: _tables, ...auth } = input.auth;
|
|
77
|
+
if (typeof provider !== 'function') {
|
|
78
|
+
return {
|
|
79
|
+
config: { ...input, database, auth: { ...auth, provider } },
|
|
80
|
+
database: connected
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (!connected) {
|
|
84
|
+
throw new Error('[CMS] `auth.provider` is a function, but `database` is an already-built adapter, so ' +
|
|
85
|
+
'there is no Drizzle instance to give it. Declare `database` with a descriptor, or ' +
|
|
86
|
+
'build the auth provider yourself and pass the result.');
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
config: {
|
|
90
|
+
...input,
|
|
91
|
+
database,
|
|
92
|
+
auth: {
|
|
93
|
+
...auth,
|
|
94
|
+
provider: await provider({
|
|
95
|
+
database,
|
|
96
|
+
drizzleDb: connected.drizzleDb,
|
|
97
|
+
dialect: connected.dialect,
|
|
98
|
+
cache: input.cache ?? null,
|
|
99
|
+
email: input.email ?? null,
|
|
100
|
+
building
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
database: connected
|
|
105
|
+
};
|
|
106
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
2
|
/**
|
|
3
3
|
* Parse a single byte range against a known object size.
|
|
4
4
|
*
|
|
@@ -18,5 +18,10 @@ export declare function parseByteRange(header: string | null, size: number | nul
|
|
|
18
18
|
start: number;
|
|
19
19
|
end: number;
|
|
20
20
|
} | 'unsatisfiable' | null;
|
|
21
|
-
export declare const GET:
|
|
21
|
+
export declare const GET: ({ params, locals, setHeaders, request }: Pick<RequestEvent, "locals" | "setHeaders" | "request"> & {
|
|
22
|
+
params: {
|
|
23
|
+
id: string;
|
|
24
|
+
filename: string;
|
|
25
|
+
};
|
|
26
|
+
}) => Promise<Response>;
|
|
22
27
|
//# sourceMappingURL=assets-cdn.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets-cdn.d.ts","sourceRoot":"","sources":["../../src/lib/routes/assets-cdn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"assets-cdn.d.ts","sourceRoot":"","sources":["../../src/lib/routes/assets-cdn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA2BlD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,IAAI,EAAE,MAAM,GAAG,IAAI,GACjB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,eAAe,GAAG,IAAI,CA8BzD;AAsCD,eAAO,MAAM,GAAG,GAAU,yCAKvB,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC,GAAG;IAC5D,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CACzC,KAAG,OAAO,CAAC,QAAQ,CAqYnB,CAAC"}
|
|
@@ -97,7 +97,7 @@ const DEFAULT_SIGNED_URL_TTL_SECONDS = 900;
|
|
|
97
97
|
export const GET = async ({ params, locals, setHeaders, request }) => {
|
|
98
98
|
try {
|
|
99
99
|
const { assetService, databaseAdapter, storageAdapter, cmsEngine, config } = locals.aphexCMS;
|
|
100
|
-
let auth = locals.
|
|
100
|
+
let auth = locals.aphexAuth;
|
|
101
101
|
const { id, filename } = params;
|
|
102
102
|
cmsLogger.debug('[Asset CDN]', 'Request for asset:', id, filename);
|
|
103
103
|
// If no session auth, check for API key in headers
|
|
@@ -269,7 +269,13 @@ export const GET = async ({ params, locals, setHeaders, request }) => {
|
|
|
269
269
|
// that's what makes it addressable and immutable — but what the
|
|
270
270
|
// browser writes to disk is this route's business.
|
|
271
271
|
const downloadName = `${stripExtension(asset.originalFilename || asset.filename)}.${VARIANT_FORMAT}`;
|
|
272
|
-
setHeaders
|
|
272
|
+
// On the Response, not via `setHeaders`: both branches below can fall
|
|
273
|
+
// through to serving the original, which sets its own Content-Type —
|
|
274
|
+
// and SvelteKit's `setHeaders` throws on a header set twice. Set here
|
|
275
|
+
// before the fallback, these turned every "can't derive, serve the
|
|
276
|
+
// original" case (an animated GIF, a busy queue) into a 500 instead
|
|
277
|
+
// of the original bytes.
|
|
278
|
+
const variantHeaders = {
|
|
273
279
|
'Content-Type': `image/${VARIANT_FORMAT}`,
|
|
274
280
|
// Every variant URL embeds the config hash, so a change of ladder
|
|
275
281
|
// or quality produces a different URL rather than new bytes at the
|
|
@@ -277,12 +283,12 @@ export const GET = async ({ params, locals, setHeaders, request }) => {
|
|
|
277
283
|
'Cache-Control': isPrivate ? 'private, no-store' : 'public, max-age=31536000, immutable',
|
|
278
284
|
'Content-Disposition': `inline; filename="${asciiFilename(downloadName)}"; filename*=UTF-8''${encodeURIComponent(downloadName)}`,
|
|
279
285
|
'X-Content-Type-Options': 'nosniff'
|
|
280
|
-
}
|
|
286
|
+
};
|
|
281
287
|
if (existing) {
|
|
282
288
|
try {
|
|
283
289
|
const buffer = await storageAdapter.getObject(existing.path);
|
|
284
290
|
return new Response(toArrayBuffer(buffer), {
|
|
285
|
-
headers: { 'Content-Length': String(buffer.length) }
|
|
291
|
+
headers: { ...variantHeaders, 'Content-Length': String(buffer.length) }
|
|
286
292
|
});
|
|
287
293
|
}
|
|
288
294
|
catch (err) {
|
|
@@ -302,7 +308,7 @@ export const GET = async ({ params, locals, setHeaders, request }) => {
|
|
|
302
308
|
database: databaseAdapter
|
|
303
309
|
});
|
|
304
310
|
return new Response(toArrayBuffer(buffer), {
|
|
305
|
-
headers: { 'Content-Length': String(buffer.length) }
|
|
311
|
+
headers: { ...variantHeaders, 'Content-Length': String(buffer.length) }
|
|
306
312
|
});
|
|
307
313
|
}
|
|
308
314
|
catch (err) {
|
|
@@ -37,8 +37,7 @@ export declare function createAphexApi(): import("hono/hono-base").HonoBase<Aphe
|
|
|
37
37
|
* Mount cms-core's built-in resource routes onto an Aphex API app.
|
|
38
38
|
*
|
|
39
39
|
* Called by `createCMSHook` after `config.api?.(app)` runs, so user-provided
|
|
40
|
-
* middleware
|
|
41
|
-
* registers ahead of the built-in handler and gets the chance to wrap it.
|
|
40
|
+
* middleware registers ahead of the built-in handler and gets the chance to wrap it.
|
|
42
41
|
*/
|
|
43
42
|
export declare function mountAphexBuiltins(app: Hono<AphexEnv>): void;
|
|
44
43
|
export type ApiRoutes = ReturnType<typeof createAphexApi>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/server/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/server/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAkC7C;;;;;;;;;;GAUG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB,SAAS,EAAE;QACV,QAAQ,EAAE,YAAY,CAAC;QACvB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;KAClB,CAAC;IACF,QAAQ,EAAE;QACT,QAAQ,EAAE,YAAY,CAAC;QACvB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;QAClB,wEAAwE;QACxE,aAAa,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACF,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,cAAc,kGAqC7B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,QAkHrD;AAED,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AA0C1D;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,IACtE,GAAG,OAAO,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,uBAejD"}
|
package/dist/server/api/index.js
CHANGED
|
@@ -16,8 +16,12 @@ import { assetsReferencesRouter } from './routes/assets-references.js';
|
|
|
16
16
|
import { organizationsRouter } from './routes/organizations.js';
|
|
17
17
|
import { organizationsByIdRouter } from './routes/organizations-by-id.js';
|
|
18
18
|
import { organizationsInvitationsRouter } from './routes/organizations-invitations.js';
|
|
19
|
+
import { invitationsRouter } from './routes/invitations.js';
|
|
20
|
+
import { apiKeysRouter } from './routes/api-keys.js';
|
|
21
|
+
import { instanceSettingsRouter } from './routes/instance-settings.js';
|
|
19
22
|
import { organizationsMembersRouter } from './routes/organizations-members.js';
|
|
20
23
|
import { organizationsSwitchRouter } from './routes/organizations-switch.js';
|
|
24
|
+
import { organizationsTeamRouter } from './routes/organizations-team.js';
|
|
21
25
|
import { rolesRouter } from './routes/roles.js';
|
|
22
26
|
import { pluginSettingsRouter } from './routes/plugin-settings.js';
|
|
23
27
|
import { userPreferencesRouter } from './routes/user-preferences.js';
|
|
@@ -70,8 +74,7 @@ export function createAphexApi() {
|
|
|
70
74
|
* Mount cms-core's built-in resource routes onto an Aphex API app.
|
|
71
75
|
*
|
|
72
76
|
* Called by `createCMSHook` after `config.api?.(app)` runs, so user-provided
|
|
73
|
-
* middleware
|
|
74
|
-
* registers ahead of the built-in handler and gets the chance to wrap it.
|
|
77
|
+
* middleware registers ahead of the built-in handler and gets the chance to wrap it.
|
|
75
78
|
*/
|
|
76
79
|
export function mountAphexBuiltins(app) {
|
|
77
80
|
// Order matters: more-specific paths (`/documents/query`,
|
|
@@ -101,8 +104,14 @@ export function mountAphexBuiltins(app) {
|
|
|
101
104
|
app.route('/organizations', organizationsSwitchRouter);
|
|
102
105
|
app.route('/organizations', organizationsInvitationsRouter);
|
|
103
106
|
app.route('/organizations', organizationsMembersRouter);
|
|
107
|
+
app.route('/organizations', organizationsTeamRouter);
|
|
104
108
|
app.route('/organizations', organizationsByIdRouter);
|
|
105
109
|
app.route('/organizations', organizationsRouter);
|
|
110
|
+
// The signed-in user's own invitations.
|
|
111
|
+
app.route('/invitations', invitationsRouter);
|
|
112
|
+
// API keys, and the settings that apply to the whole instance.
|
|
113
|
+
app.route('/settings/api-keys', apiKeysRouter);
|
|
114
|
+
app.route('/instance-settings', instanceSettingsRouter);
|
|
106
115
|
// Roles — combined router covers /, /:name, no precedence concern.
|
|
107
116
|
app.route('/roles', rolesRouter);
|
|
108
117
|
// Plugin settings — the config plane. `/`, `/:pluginId`, no precedence concern.
|
|
@@ -220,7 +229,7 @@ export function toHonoHandler(skHandler) {
|
|
|
220
229
|
params: c.req.param(),
|
|
221
230
|
locals: {
|
|
222
231
|
aphexCMS: c.var.aphexCMS,
|
|
223
|
-
|
|
232
|
+
aphexAuth: c.var.auth
|
|
224
233
|
},
|
|
225
234
|
// No-op fallbacks — only used if a wrapped SK handler probes for them.
|
|
226
235
|
setHeaders: () => undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/api/openapi/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/api/openapi/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAiEnC,4EAA4E;AAC5E,MAAM,MAAM,QAAQ;AACnB,uDAAuD;AACrD,MAAM;AACR,oDAAoD;GAClD,OAAO;AACT,8EAA8E;GAC5E,eAAe;AACjB,+BAA+B;GAC7B,QAAQ;AACV,kEAAkE;GAChE,SAAS;AACX,0EAA0E;GACxE,QAAQ,CAAC;AAEZ,MAAM,WAAW,SAAS;IACzB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,QAAQ,CAAC;IACf,mDAAmD;IACnD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uEAAuE;IACvE,QAAQ,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;IAC/F;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxD,gEAAgE;IAChE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,cAAc,EAAE,SAAS,EA8qBrC,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAcnD,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createApiKeyRequest } from '../../../api/schemas/api-keys.js';
|
|
2
|
+
import { updateInstanceSettingsRequest } from '../../../api/schemas/instance.js';
|
|
1
3
|
import { listDocumentsQuery, listDocumentsResponse, getDocumentsByIdsQuery, createDocumentRequest, createDocumentResponse, getDocumentResponse, updateDocumentRequest, updateDocumentResponse, deleteDocumentResponse, publishDocumentRequest, publishDocumentResponse, unpublishDocumentRequest, unpublishDocumentResponse, queryDocumentsRequest, listVersionsQuery, listVersionsResponse, getVersionResponse, restoreVersionRequest, restoreVersionResponse, scheduleDocumentRequest, scheduleDocumentResponse } from '../../../api/schemas/documents.js';
|
|
2
4
|
import { listAssetsQuery, listAssetsResponse, getAssetResponse, updateAssetRequest, updateAssetResponse, deleteAssetResponse, bulkDeleteAssetsRequest, bulkDeleteAssetsResponse, getAssetReferencesResponse, assetReferenceCountsRequest, assetReferenceCountsResponse, createUploadUrlRequest, confirmUploadRequest } from '../../../api/schemas/assets.js';
|
|
3
5
|
import { createOrganizationRequest, updateOrganizationRequest, switchOrganizationRequest, inviteMemberRequest, cancelInvitationRequest, removeMemberRequest, updateMemberRoleRequest } from '../../../api/schemas/organizations.js';
|
|
@@ -360,6 +362,14 @@ export const ROUTE_REGISTRY = [
|
|
|
360
362
|
auth: 'write',
|
|
361
363
|
request: removeMemberRequest
|
|
362
364
|
},
|
|
365
|
+
{
|
|
366
|
+
path: '/api/organizations/team',
|
|
367
|
+
method: 'GET',
|
|
368
|
+
summary: 'Members, pending invitations and invitable roles',
|
|
369
|
+
description: 'Session only. Everything the members settings page needs in one call. Pending invitations carry their accept link (`inviteUrl`) only for callers with `member.invite`.',
|
|
370
|
+
tag: 'Organizations',
|
|
371
|
+
auth: 'session'
|
|
372
|
+
},
|
|
363
373
|
{
|
|
364
374
|
path: '/api/organizations/invitations',
|
|
365
375
|
method: 'POST',
|
|
@@ -376,6 +386,66 @@ export const ROUTE_REGISTRY = [
|
|
|
376
386
|
auth: 'write',
|
|
377
387
|
request: cancelInvitationRequest
|
|
378
388
|
},
|
|
389
|
+
{
|
|
390
|
+
path: '/api/invitations',
|
|
391
|
+
method: 'GET',
|
|
392
|
+
summary: "List the signed-in user's pending invitations",
|
|
393
|
+
tag: 'Organizations',
|
|
394
|
+
auth: 'session'
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
path: '/api/invitations/:id/accept',
|
|
398
|
+
method: 'POST',
|
|
399
|
+
summary: 'Accept an invitation',
|
|
400
|
+
tag: 'Organizations',
|
|
401
|
+
auth: 'session'
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
path: '/api/invitations/:id/reject',
|
|
405
|
+
method: 'POST',
|
|
406
|
+
summary: 'Decline an invitation',
|
|
407
|
+
tag: 'Organizations',
|
|
408
|
+
auth: 'session'
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
path: '/api/settings/api-keys',
|
|
412
|
+
method: 'GET',
|
|
413
|
+
summary: "List the signed-in user's API keys",
|
|
414
|
+
tag: 'Organizations',
|
|
415
|
+
auth: 'session'
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
path: '/api/settings/api-keys',
|
|
419
|
+
method: 'POST',
|
|
420
|
+
summary: 'Create an API key',
|
|
421
|
+
description: 'Session only, and needs `apiKey.manage`. The key itself is only returned here.',
|
|
422
|
+
tag: 'Organizations',
|
|
423
|
+
auth: 'session',
|
|
424
|
+
request: createApiKeyRequest
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
path: '/api/settings/api-keys/:id',
|
|
428
|
+
method: 'DELETE',
|
|
429
|
+
summary: 'Revoke an API key',
|
|
430
|
+
tag: 'Organizations',
|
|
431
|
+
auth: 'session'
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
path: '/api/instance-settings',
|
|
435
|
+
method: 'GET',
|
|
436
|
+
summary: 'Get the settings for this instance',
|
|
437
|
+
tag: 'Organizations',
|
|
438
|
+
auth: 'session'
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
path: '/api/instance-settings',
|
|
442
|
+
method: 'PATCH',
|
|
443
|
+
summary: 'Update the settings for this instance',
|
|
444
|
+
description: 'Super admins only.',
|
|
445
|
+
tag: 'Organizations',
|
|
446
|
+
auth: 'session',
|
|
447
|
+
request: updateInstanceSettingsRequest
|
|
448
|
+
},
|
|
379
449
|
{
|
|
380
450
|
path: '/api/organizations/:id',
|
|
381
451
|
method: 'GET',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/api/routes/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAK5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAmBzC,eAAO,MAAM,aAAa,EAAE,IAAI,CAAC,QAAQ,CAiFtC,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { zValidator } from '@hono/zod-validator';
|
|
3
|
+
import { createApiKeyRequest } from '../../../api/schemas/api-keys.js';
|
|
4
|
+
import { hasCapability } from '../../../types/capabilities.js';
|
|
5
|
+
import { cmsLogger } from '../../../utils/logger.js';
|
|
6
|
+
const UNAUTHORIZED = {
|
|
7
|
+
success: false,
|
|
8
|
+
error: 'Unauthorized',
|
|
9
|
+
message: 'Session authentication required'
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The row is gone but a cached copy survived, so the key may still authenticate. This
|
|
13
|
+
* is matched on its code because the error comes from the auth provider's package,
|
|
14
|
+
* which can load its own copy of any class (see `isAuthError`).
|
|
15
|
+
*/
|
|
16
|
+
function isIncompleteRevocation(error) {
|
|
17
|
+
return (error instanceof Error && 'code' in error && error.code === 'API_KEY_REVOCATION_INCOMPLETE');
|
|
18
|
+
}
|
|
19
|
+
export const apiKeysRouter = new Hono()
|
|
20
|
+
.get('/', async (c) => {
|
|
21
|
+
const auth = c.var.auth;
|
|
22
|
+
if (!auth || auth.type !== 'session')
|
|
23
|
+
return c.json(UNAUTHORIZED, 401);
|
|
24
|
+
try {
|
|
25
|
+
const data = (await c.var.aphexCMS.auth?.listApiKeys?.(auth.user.id)) ?? [];
|
|
26
|
+
return c.json({ success: true, data });
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
cmsLogger.error('Failed to fetch API keys:', error);
|
|
30
|
+
return c.json({ success: false, error: 'Failed to fetch API keys' }, 500);
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
.post('/', zValidator('json', createApiKeyRequest, (result, c) => {
|
|
34
|
+
if (!result.success) {
|
|
35
|
+
return c.json({ success: false, error: 'Invalid input', issues: result.error.issues }, 400);
|
|
36
|
+
}
|
|
37
|
+
}), async (c) => {
|
|
38
|
+
const auth = c.var.auth;
|
|
39
|
+
if (!auth || auth.type !== 'session')
|
|
40
|
+
return c.json(UNAUTHORIZED, 401);
|
|
41
|
+
if (!hasCapability(auth, 'apiKey.manage')) {
|
|
42
|
+
return c.json({
|
|
43
|
+
success: false,
|
|
44
|
+
error: 'Forbidden',
|
|
45
|
+
message: 'You do not have permission to create API keys'
|
|
46
|
+
}, 403);
|
|
47
|
+
}
|
|
48
|
+
const createApiKey = c.var.aphexCMS.auth?.createApiKey;
|
|
49
|
+
if (!createApiKey) {
|
|
50
|
+
return c.json({ success: false, error: 'API keys are not supported by this auth provider' }, 501);
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const apiKey = await createApiKey(auth.user.id, auth.organizationId, c.req.valid('json'));
|
|
54
|
+
return c.json({ success: true, data: { apiKey } });
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
cmsLogger.error('Failed to create API key:', error);
|
|
58
|
+
return c.json({ success: false, error: 'Failed to create API key' }, 500);
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
.delete('/:id', async (c) => {
|
|
62
|
+
const auth = c.var.auth;
|
|
63
|
+
if (!auth || auth.type !== 'session')
|
|
64
|
+
return c.json(UNAUTHORIZED, 401);
|
|
65
|
+
if (!hasCapability(auth, 'apiKey.manage')) {
|
|
66
|
+
return c.json({
|
|
67
|
+
success: false,
|
|
68
|
+
error: 'Forbidden',
|
|
69
|
+
message: 'You do not have permission to delete API keys'
|
|
70
|
+
}, 403);
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
// The provider scopes this to the caller, so another account's key id does nothing.
|
|
74
|
+
const deleted = await c.var.aphexCMS.auth?.deleteApiKey?.(auth.user.id, c.req.param('id'));
|
|
75
|
+
if (deleted)
|
|
76
|
+
return c.json({ success: true });
|
|
77
|
+
return c.json({ success: false, error: 'Failed to delete API key' }, 500);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
// Not "failed to delete": that implies retrying helps, and this needs a cache flush.
|
|
81
|
+
if (isIncompleteRevocation(error)) {
|
|
82
|
+
cmsLogger.error('Incomplete API key revocation:', error);
|
|
83
|
+
return c.json({ success: false, error: 'Revocation incomplete', message: error.message }, 500);
|
|
84
|
+
}
|
|
85
|
+
cmsLogger.error('Failed to delete API key:', error);
|
|
86
|
+
return c.json({ success: false, error: 'Failed to delete API key' }, 500);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents-by-id.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/api/routes/documents-by-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"documents-by-id.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/api/routes/documents-by-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAY5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,eAAO,MAAM,mBAAmB,EAAE,IAAI,CAAC,QAAQ,CA8P5C,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { Hono } from 'hono';
|
|
|
2
2
|
import { zValidator } from '@hono/zod-validator';
|
|
3
3
|
import { authToContext } from '../../../local-api/auth-helpers.js';
|
|
4
4
|
import { PermissionError } from '../../../local-api/permissions.js';
|
|
5
|
+
import { PublishValidationError } from '../../../local-api/collection-api.js';
|
|
5
6
|
import { SingletonOperationError, DocumentValidationError } from '../../../local-api/collection-api.js';
|
|
6
7
|
import { RevisionConflictError } from '../../../db/interfaces/index.js';
|
|
7
8
|
import { cmsLogger } from '../../../utils/logger.js';
|
|
@@ -117,8 +118,22 @@ export const documentsByIdRouter = new Hono()
|
|
|
117
118
|
issues: error.errors
|
|
118
119
|
}, 400);
|
|
119
120
|
}
|
|
121
|
+
if (error instanceof PublishValidationError) {
|
|
122
|
+
return c.json({
|
|
123
|
+
success: false,
|
|
124
|
+
error: 'Validation failed',
|
|
125
|
+
message: error.message,
|
|
126
|
+
issues: error.issues
|
|
127
|
+
}, 400);
|
|
128
|
+
}
|
|
129
|
+
// The same refusal from something that isn't the Local API (a plugin, an
|
|
130
|
+
// older adapter) still carries only a message.
|
|
120
131
|
if (error instanceof Error && error.message.includes('validation errors')) {
|
|
121
|
-
return c.json({
|
|
132
|
+
return c.json({
|
|
133
|
+
success: false,
|
|
134
|
+
error: 'Validation failed',
|
|
135
|
+
message: error.message
|
|
136
|
+
}, 400);
|
|
122
137
|
}
|
|
123
138
|
return c.json({
|
|
124
139
|
success: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents-publish.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/api/routes/documents-publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAW5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,eAAO,MAAM,sBAAsB,EAAE,IAAI,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"documents-publish.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/api/routes/documents-publish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAW5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,eAAO,MAAM,sBAAsB,EAAE,IAAI,CAAC,QAAQ,CA2V/C,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { Hono } from 'hono';
|
|
|
2
2
|
import { authToContext } from '../../../local-api/auth-helpers.js';
|
|
3
3
|
import { PermissionError } from '../../../local-api/permissions.js';
|
|
4
4
|
import { RevisionConflictError } from '../../../db/interfaces/index.js';
|
|
5
|
-
import { DocumentValidationError } from '../../../local-api/collection-api.js';
|
|
5
|
+
import { DocumentValidationError, PublishValidationError } from '../../../local-api/collection-api.js';
|
|
6
6
|
import { cmsLogger } from '../../../utils/logger.js';
|
|
7
7
|
import { scheduleDocumentRequest, publishDocumentRequest, unpublishDocumentRequest } from '../../../api/schemas/documents.js';
|
|
8
8
|
export const documentsPublishRouter = new Hono()
|
|
@@ -188,6 +188,16 @@ export const documentsPublishRouter = new Hono()
|
|
|
188
188
|
issues: error.errors
|
|
189
189
|
}, 400);
|
|
190
190
|
}
|
|
191
|
+
if (error instanceof PublishValidationError) {
|
|
192
|
+
return c.json({
|
|
193
|
+
success: false,
|
|
194
|
+
error: 'Cannot publish: validation errors',
|
|
195
|
+
message: error.message,
|
|
196
|
+
issues: error.issues
|
|
197
|
+
}, 400);
|
|
198
|
+
}
|
|
199
|
+
// The same refusal from something that isn't the Local API (a plugin, an
|
|
200
|
+
// older adapter) still carries only a message.
|
|
191
201
|
if (error instanceof Error && error.message.includes('validation errors')) {
|
|
192
202
|
return c.json({
|
|
193
203
|
success: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/api/routes/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAW5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKzC,eAAO,MAAM,eAAe,EAAE,IAAI,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/api/routes/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAW5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKzC,eAAO,MAAM,eAAe,EAAE,IAAI,CAAC,QAAQ,CAsQzC,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { Hono } from 'hono';
|
|
|
2
2
|
import { zValidator } from '@hono/zod-validator';
|
|
3
3
|
import { authToContext } from '../../../local-api/auth-helpers.js';
|
|
4
4
|
import { PermissionError } from '../../../local-api/permissions.js';
|
|
5
|
-
import { DocumentValidationError } from '../../../local-api/collection-api.js';
|
|
5
|
+
import { DocumentValidationError, PublishValidationError } from '../../../local-api/collection-api.js';
|
|
6
6
|
import { cmsLogger } from '../../../utils/logger.js';
|
|
7
7
|
import { createDocumentRequest, getDocumentsByIdsQuery, listDocumentsQuery } from '../../../api/schemas/documents.js';
|
|
8
8
|
const DEFAULT_PAGE_SIZE = 20;
|
|
@@ -185,8 +185,22 @@ export const documentsRouter = new Hono()
|
|
|
185
185
|
issues: error.errors
|
|
186
186
|
}, 400);
|
|
187
187
|
}
|
|
188
|
+
if (error instanceof PublishValidationError) {
|
|
189
|
+
return c.json({
|
|
190
|
+
success: false,
|
|
191
|
+
error: 'Validation failed',
|
|
192
|
+
message: error.message,
|
|
193
|
+
issues: error.issues
|
|
194
|
+
}, 400);
|
|
195
|
+
}
|
|
196
|
+
// The same refusal from something that isn't the Local API (a plugin, an
|
|
197
|
+
// older adapter) still carries only a message.
|
|
188
198
|
if (error instanceof Error && error.message.includes('validation errors')) {
|
|
189
|
-
return c.json({
|
|
199
|
+
return c.json({
|
|
200
|
+
success: false,
|
|
201
|
+
error: 'Validation failed',
|
|
202
|
+
message: error.message
|
|
203
|
+
}, 400);
|
|
190
204
|
}
|
|
191
205
|
return c.json({
|
|
192
206
|
success: false,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-settings.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/api/routes/instance-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAQzC,eAAO,MAAM,sBAAsB,EAAE,IAAI,CAAC,QAAQ,CA6ChD,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { zValidator } from '@hono/zod-validator';
|
|
3
|
+
import { updateInstanceSettingsRequest } from '../../../api/schemas/instance.js';
|
|
4
|
+
import { cmsLogger } from '../../../utils/logger.js';
|
|
5
|
+
const UNAUTHORIZED = {
|
|
6
|
+
success: false,
|
|
7
|
+
error: 'Unauthorized',
|
|
8
|
+
message: 'Session authentication required'
|
|
9
|
+
};
|
|
10
|
+
export const instanceSettingsRouter = new Hono()
|
|
11
|
+
.get('/', async (c) => {
|
|
12
|
+
const auth = c.var.auth;
|
|
13
|
+
if (!auth || auth.type !== 'session')
|
|
14
|
+
return c.json(UNAUTHORIZED, 401);
|
|
15
|
+
try {
|
|
16
|
+
const data = await c.var.aphexCMS.databaseAdapter.getInstanceSettings();
|
|
17
|
+
return c.json({ success: true, data });
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
cmsLogger.error('Failed to fetch instance settings:', error);
|
|
21
|
+
return c.json({ success: false, error: 'Failed to fetch instance settings' }, 500);
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
.patch('/', zValidator('json', updateInstanceSettingsRequest, (result, c) => {
|
|
25
|
+
if (!result.success) {
|
|
26
|
+
return c.json({ success: false, error: 'Invalid request body', issues: result.error.issues }, 400);
|
|
27
|
+
}
|
|
28
|
+
}), async (c) => {
|
|
29
|
+
const auth = c.var.auth;
|
|
30
|
+
if (!auth || auth.type !== 'session')
|
|
31
|
+
return c.json(UNAUTHORIZED, 401);
|
|
32
|
+
if (auth.user.role !== 'super_admin') {
|
|
33
|
+
return c.json({
|
|
34
|
+
success: false,
|
|
35
|
+
error: 'Forbidden',
|
|
36
|
+
message: 'Only super admins can update instance settings'
|
|
37
|
+
}, 403);
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const data = await c.var.aphexCMS.databaseAdapter.updateInstanceSettings(c.req.valid('json'));
|
|
41
|
+
return c.json({ success: true, data });
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
cmsLogger.error('Failed to update instance settings:', error);
|
|
45
|
+
return c.json({ success: false, error: 'Failed to update instance settings' }, 500);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import type { AphexEnv } from '../index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Invitations addressed to the signed-in user, as opposed to the ones an organization
|
|
5
|
+
* has sent (`/organizations/invitations`). A session with no organization can use
|
|
6
|
+
* these, because accepting an invitation is how it gets one.
|
|
7
|
+
*/
|
|
8
|
+
export declare const invitationsRouter: Hono<AphexEnv>;
|
|
9
|
+
//# sourceMappingURL=invitations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invitations.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/api/routes/invitations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAQzC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CA4D1C,CAAC"}
|