@cogenta/schema 0.2.0 → 0.4.1
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/define-collection.d.ts.map +1 -1
- package/dist/define-collection.js +53 -3
- package/dist/define-collection.js.map +1 -1
- package/dist/generate-types.d.ts.map +1 -1
- package/dist/generate-types.js +6 -1
- package/dist/generate-types.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/media-usage.d.ts +56 -0
- package/dist/media-usage.d.ts.map +1 -0
- package/dist/media-usage.js +89 -0
- package/dist/media-usage.js.map +1 -0
- package/dist/rich-text.d.ts +28 -2
- package/dist/rich-text.d.ts.map +1 -1
- package/dist/rich-text.js +26 -3
- package/dist/rich-text.js.map +1 -1
- package/dist/routing/index.d.ts +5 -1
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +2 -0
- package/dist/routing/index.js.map +1 -1
- package/dist/routing/not-found-log.d.ts +78 -0
- package/dist/routing/not-found-log.d.ts.map +1 -0
- package/dist/routing/not-found-log.js +153 -0
- package/dist/routing/not-found-log.js.map +1 -0
- package/dist/routing/redirect-patterns.d.ts +61 -0
- package/dist/routing/redirect-patterns.d.ts.map +1 -0
- package/dist/routing/redirect-patterns.js +173 -0
- package/dist/routing/redirect-patterns.js.map +1 -0
- package/dist/routing/redirects.d.ts +27 -4
- package/dist/routing/redirects.d.ts.map +1 -1
- package/dist/routing/redirects.js +160 -48
- package/dist/routing/redirects.js.map +1 -1
- package/dist/scheduling/index.d.ts +2 -0
- package/dist/scheduling/index.d.ts.map +1 -1
- package/dist/scheduling/index.js +1 -0
- package/dist/scheduling/index.js.map +1 -1
- package/dist/scheduling/registry.d.ts +147 -0
- package/dist/scheduling/registry.d.ts.map +1 -0
- package/dist/scheduling/registry.js +318 -0
- package/dist/scheduling/registry.js.map +1 -0
- package/dist/search/extract.d.ts +24 -0
- package/dist/search/extract.d.ts.map +1 -1
- package/dist/search/extract.js +63 -8
- package/dist/search/extract.js.map +1 -1
- package/dist/search/index.d.ts +2 -1
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +1 -9
- package/dist/search/index.js.map +1 -1
- package/dist/store/admin-theme-store.d.ts +26 -0
- package/dist/store/admin-theme-store.d.ts.map +1 -0
- package/dist/store/admin-theme-store.js +81 -0
- package/dist/store/admin-theme-store.js.map +1 -0
- package/dist/store/admin-theme-tables.d.ts +24 -0
- package/dist/store/admin-theme-tables.d.ts.map +1 -0
- package/dist/store/admin-theme-tables.js +41 -0
- package/dist/store/admin-theme-tables.js.map +1 -0
- package/dist/store/admin-theme-templates.d.ts +135 -0
- package/dist/store/admin-theme-templates.d.ts.map +1 -0
- package/dist/store/admin-theme-templates.js +217 -0
- package/dist/store/admin-theme-templates.js.map +1 -0
- package/dist/store/columns.d.ts.map +1 -1
- package/dist/store/columns.js +8 -2
- package/dist/store/columns.js.map +1 -1
- package/dist/store/diff.d.ts +40 -0
- package/dist/store/diff.d.ts.map +1 -1
- package/dist/store/diff.js +148 -0
- package/dist/store/diff.js.map +1 -1
- package/dist/store/index.d.ts +47 -4
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +26 -2
- package/dist/store/index.js.map +1 -1
- package/dist/store/maintenance-store.d.ts +34 -0
- package/dist/store/maintenance-store.d.ts.map +1 -0
- package/dist/store/maintenance-store.js +92 -0
- package/dist/store/maintenance-store.js.map +1 -0
- package/dist/store/menu-store.d.ts +146 -0
- package/dist/store/menu-store.d.ts.map +1 -0
- package/dist/store/menu-store.js +565 -0
- package/dist/store/menu-store.js.map +1 -0
- package/dist/store/menu-tables.d.ts +38 -0
- package/dist/store/menu-tables.d.ts.map +1 -0
- package/dist/store/menu-tables.js +117 -0
- package/dist/store/menu-tables.js.map +1 -0
- package/dist/store/naming.d.ts +1 -1
- package/dist/store/naming.d.ts.map +1 -1
- package/dist/store/naming.js +2 -0
- package/dist/store/naming.js.map +1 -1
- package/dist/store/pattern-store.d.ts +75 -0
- package/dist/store/pattern-store.d.ts.map +1 -0
- package/dist/store/pattern-store.js +118 -0
- package/dist/store/pattern-store.js.map +1 -0
- package/dist/store/pattern-tables.d.ts +29 -0
- package/dist/store/pattern-tables.d.ts.map +1 -0
- package/dist/store/pattern-tables.js +53 -0
- package/dist/store/pattern-tables.js.map +1 -0
- package/dist/store/read-only.d.ts +3 -3
- package/dist/store/read-only.d.ts.map +1 -1
- package/dist/store/read-only.js +4 -3
- package/dist/store/read-only.js.map +1 -1
- package/dist/store/redirect-tracking.d.ts +50 -0
- package/dist/store/redirect-tracking.d.ts.map +1 -0
- package/dist/store/redirect-tracking.js +91 -0
- package/dist/store/redirect-tracking.js.map +1 -0
- package/dist/store/review-transitions.d.ts +34 -0
- package/dist/store/review-transitions.d.ts.map +1 -0
- package/dist/store/review-transitions.js +51 -0
- package/dist/store/review-transitions.js.map +1 -0
- package/dist/store/role-permission-export.d.ts +22 -0
- package/dist/store/role-permission-export.d.ts.map +1 -0
- package/dist/store/role-permission-export.js +0 -0
- package/dist/store/role-permission-export.js.map +1 -0
- package/dist/store/role-permission-overlay.d.ts +27 -0
- package/dist/store/role-permission-overlay.d.ts.map +1 -0
- package/dist/store/role-permission-overlay.js +0 -0
- package/dist/store/role-permission-overlay.js.map +1 -0
- package/dist/store/role-permission-store.d.ts +72 -0
- package/dist/store/role-permission-store.d.ts.map +1 -0
- package/dist/store/role-permission-store.js +148 -0
- package/dist/store/role-permission-store.js.map +1 -0
- package/dist/store/role-permission-tables.d.ts +27 -0
- package/dist/store/role-permission-tables.d.ts.map +1 -0
- package/dist/store/role-permission-tables.js +52 -0
- package/dist/store/role-permission-tables.js.map +1 -0
- package/dist/store/scheduled-publish-enqueue.d.ts +37 -0
- package/dist/store/scheduled-publish-enqueue.d.ts.map +1 -0
- package/dist/store/scheduled-publish-enqueue.js +51 -0
- package/dist/store/scheduled-publish-enqueue.js.map +1 -0
- package/dist/store/scheduled-publish-failures.d.ts +36 -0
- package/dist/store/scheduled-publish-failures.d.ts.map +1 -0
- package/dist/store/scheduled-publish-failures.js +67 -0
- package/dist/store/scheduled-publish-failures.js.map +1 -0
- package/dist/store/schema-2-1-migration.d.ts +29 -0
- package/dist/store/schema-2-1-migration.d.ts.map +1 -0
- package/dist/store/schema-2-1-migration.js +71 -0
- package/dist/store/schema-2-1-migration.js.map +1 -0
- package/dist/store/search-console-store.d.ts +44 -0
- package/dist/store/search-console-store.d.ts.map +1 -0
- package/dist/store/search-console-store.js +90 -0
- package/dist/store/search-console-store.js.map +1 -0
- package/dist/store/search-console-tables.d.ts +14 -0
- package/dist/store/search-console-tables.d.ts.map +1 -0
- package/dist/store/search-console-tables.js +29 -0
- package/dist/store/search-console-tables.js.map +1 -0
- package/dist/store/search-indexing.d.ts +36 -0
- package/dist/store/search-indexing.d.ts.map +1 -1
- package/dist/store/search-indexing.js +33 -0
- package/dist/store/search-indexing.js.map +1 -1
- package/dist/store/site-settings-registry.d.ts +164 -0
- package/dist/store/site-settings-registry.d.ts.map +1 -0
- package/dist/store/site-settings-registry.js +1160 -0
- package/dist/store/site-settings-registry.js.map +1 -0
- package/dist/store/site-settings-store.d.ts +42 -0
- package/dist/store/site-settings-store.d.ts.map +1 -0
- package/dist/store/site-settings-store.js +97 -0
- package/dist/store/site-settings-store.js.map +1 -0
- package/dist/store/site-settings-tables.d.ts +29 -0
- package/dist/store/site-settings-tables.d.ts.map +1 -0
- package/dist/store/site-settings-tables.js +48 -0
- package/dist/store/site-settings-tables.js.map +1 -0
- package/dist/store/store.d.ts +57 -2
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/store.js +278 -37
- package/dist/store/store.js.map +1 -1
- package/dist/store/tables.d.ts.map +1 -1
- package/dist/store/tables.js +11 -0
- package/dist/store/tables.js.map +1 -1
- package/dist/store/taxonomy-store.d.ts.map +1 -1
- package/dist/store/taxonomy-store.js +90 -39
- package/dist/store/taxonomy-store.js.map +1 -1
- package/dist/store/taxonomy-usage.d.ts +47 -0
- package/dist/store/taxonomy-usage.d.ts.map +1 -0
- package/dist/store/taxonomy-usage.js +101 -0
- package/dist/store/taxonomy-usage.js.map +1 -0
- package/dist/store/theme-store.d.ts +73 -0
- package/dist/store/theme-store.d.ts.map +1 -0
- package/dist/store/theme-store.js +193 -0
- package/dist/store/theme-store.js.map +1 -0
- package/dist/store/types.d.ts +36 -1
- package/dist/store/types.d.ts.map +1 -1
- package/dist/store/values.d.ts.map +1 -1
- package/dist/store/values.js +28 -1
- package/dist/store/values.js.map +1 -1
- package/dist/system-fields.d.ts +8 -1
- package/dist/system-fields.d.ts.map +1 -1
- package/dist/system-fields.js +14 -1
- package/dist/system-fields.js.map +1 -1
- package/dist/types.d.ts +54 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +21 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { CogentaError, identifier, sql } from '@cogenta/core';
|
|
2
|
+
import { ADMIN_THEME_SINGLETON_ID, ADMIN_THEME_TABLE } from './admin-theme-tables.js';
|
|
3
|
+
import { adminThemeOverridesSchema, adminThemeTemplateById, DEFAULT_ADMIN_THEME_TEMPLATE_ID, } from './admin-theme-templates.js';
|
|
4
|
+
function text(value) {
|
|
5
|
+
return typeof value === 'string' ? value : String(value);
|
|
6
|
+
}
|
|
7
|
+
function nullableText(value) {
|
|
8
|
+
return value === null || value === undefined ? null : text(value);
|
|
9
|
+
}
|
|
10
|
+
function unknownTemplate(templateId) {
|
|
11
|
+
return new CogentaError({
|
|
12
|
+
code: 'ADMIN_THEME_TEMPLATE_UNKNOWN',
|
|
13
|
+
message: `"${templateId}" is not a built-in admin theme template.`,
|
|
14
|
+
hint: 'Choose one of the templates the admin theme gallery offers.',
|
|
15
|
+
details: { templateId },
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function toRecord(row) {
|
|
19
|
+
return {
|
|
20
|
+
templateId: text(row['template_id']),
|
|
21
|
+
overrides: JSON.parse(text(row['overrides'])),
|
|
22
|
+
updatedAt: text(row['updated_at']),
|
|
23
|
+
updatedBy: nullableText(row['updated_by']),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function createAdminThemeStore(options) {
|
|
27
|
+
const { db } = options;
|
|
28
|
+
const dialect = db.dialect;
|
|
29
|
+
const now = options.now ?? (() => new Date());
|
|
30
|
+
const table = identifier(ADMIN_THEME_TABLE, dialect);
|
|
31
|
+
const idColumn = identifier('id', dialect);
|
|
32
|
+
const templateIdColumn = identifier('template_id', dialect);
|
|
33
|
+
const overridesColumn = identifier('overrides', dialect);
|
|
34
|
+
const updatedAtColumn = identifier('updated_at', dialect);
|
|
35
|
+
const updatedByColumn = identifier('updated_by', dialect);
|
|
36
|
+
return {
|
|
37
|
+
get: async () => {
|
|
38
|
+
const found = await db.query(sql `select * from ${table} where ${idColumn} = ${ADMIN_THEME_SINGLETON_ID}`);
|
|
39
|
+
const row = found.rows[0];
|
|
40
|
+
return row === undefined ? null : toRecord(row);
|
|
41
|
+
},
|
|
42
|
+
set: async (templateId, overrides, updatedBy) => {
|
|
43
|
+
if (adminThemeTemplateById(templateId) === undefined)
|
|
44
|
+
throw unknownTemplate(templateId);
|
|
45
|
+
const parsed = adminThemeOverridesSchema.safeParse(overrides);
|
|
46
|
+
if (!parsed.success) {
|
|
47
|
+
throw new CogentaError({
|
|
48
|
+
code: 'ADMIN_THEME_INVALID',
|
|
49
|
+
message: `The admin theme overrides do not match the declared shape: ${parsed.error.issues
|
|
50
|
+
.map((issue) => issue.message)
|
|
51
|
+
.join('; ')}`,
|
|
52
|
+
hint: 'Only the levers the admin theme settings screen offers may be set.',
|
|
53
|
+
details: { issues: parsed.error.issues.map((issue) => issue.message) },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const at = now().toISOString();
|
|
57
|
+
const serialisedOverrides = JSON.stringify(parsed.data);
|
|
58
|
+
await db.transaction(async (tx) => {
|
|
59
|
+
const existing = await tx.query(sql `select ${idColumn} from ${table} where ${idColumn} = ${ADMIN_THEME_SINGLETON_ID}`);
|
|
60
|
+
if (existing.rows.length > 0) {
|
|
61
|
+
await tx.query(sql `update ${table}
|
|
62
|
+
set ${templateIdColumn} = ${templateId}, ${overridesColumn} = ${serialisedOverrides},
|
|
63
|
+
${updatedAtColumn} = ${at}, ${updatedByColumn} = ${updatedBy}
|
|
64
|
+
where ${idColumn} = ${ADMIN_THEME_SINGLETON_ID}`);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
await tx.query(sql `insert into ${table} (${idColumn}, ${templateIdColumn}, ${overridesColumn}, ${updatedAtColumn}, ${updatedByColumn})
|
|
68
|
+
values (${ADMIN_THEME_SINGLETON_ID}, ${templateId}, ${serialisedOverrides}, ${at}, ${updatedBy})`);
|
|
69
|
+
}
|
|
70
|
+
}, { immediate: true });
|
|
71
|
+
return {
|
|
72
|
+
templateId: templateId,
|
|
73
|
+
overrides: parsed.data,
|
|
74
|
+
updatedAt: at,
|
|
75
|
+
updatedBy,
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export { DEFAULT_ADMIN_THEME_TEMPLATE_ID };
|
|
81
|
+
//# sourceMappingURL=admin-theme-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-theme-store.js","sourceRoot":"","sources":["../../src/store/admin-theme-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,UAAU,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AAClF,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AACrF,OAAO,EAGL,yBAAyB,EACzB,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,4BAA4B,CAAA;AA4BnC,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,K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ogenta/core';
|
|
2
|
+
/**
|
|
3
|
+
* The admin's own theme choice (L21 task 2) — one fixed table, exactly
|
|
4
|
+
* `site-settings-tables.ts`'s pattern: this is runtime, admin-editable
|
|
5
|
+
* state, not a schema-declared collection, so there is no per-name table to
|
|
6
|
+
* mint and no versioned `cogenta migrate` entry either (the same reasoning
|
|
7
|
+
* `menu-tables.ts` and `site-settings-tables.ts` already give for their own
|
|
8
|
+
* fixed tables — reused here rather than a third explanation of the same
|
|
9
|
+
* choice).
|
|
10
|
+
*
|
|
11
|
+
* Exactly one row ever exists, at the fixed id `SINGLETON_ID` — there is one
|
|
12
|
+
* admin, not one per visitor, so "the current admin theme" is a singleton,
|
|
13
|
+
* not a registry keyed by anything. `templateId` names one of
|
|
14
|
+
* `ADMIN_THEME_TEMPLATES`; `overrides` is the serialised, curated
|
|
15
|
+
* personalisation (`admin-theme-templates.ts`'s `AdminThemeOverrides`) layered
|
|
16
|
+
* on top of it — never the templates themselves, which stay code, not data.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ADMIN_THEME_TABLE = "cogenta_admin_theme";
|
|
19
|
+
/** The one row this table ever holds. */
|
|
20
|
+
export declare const ADMIN_THEME_SINGLETON_ID = "singleton";
|
|
21
|
+
/** Generous for a JSON object with at most seven short fields. */
|
|
22
|
+
export declare const ADMIN_THEME_OVERRIDES_LENGTH = 4000;
|
|
23
|
+
export declare function ensureAdminThemeTable(db: DatabaseHandle): Promise<void>;
|
|
24
|
+
//# sourceMappingURL=admin-theme-tables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-theme-tables.d.ts","sourceRoot":"","sources":["../../src/store/admin-theme-tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAqC,MAAM,eAAe,CAAA;AAGtF;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,iBAAiB,wBAAwB,CAAA;AAEtD,yCAAyC;AACzC,eAAO,MAAM,wBAAwB,cAAc,CAAA;AAEnD,kEAAkE;AAClE,eAAO,MAAM,4BAA4B,OAAO,CAAA;AAEhD,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB7E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { identifier, sql } from '@cogenta/core';
|
|
2
|
+
import { textColumn, timestampColumn } from './columns.js';
|
|
3
|
+
/**
|
|
4
|
+
* The admin's own theme choice (L21 task 2) — one fixed table, exactly
|
|
5
|
+
* `site-settings-tables.ts`'s pattern: this is runtime, admin-editable
|
|
6
|
+
* state, not a schema-declared collection, so there is no per-name table to
|
|
7
|
+
* mint and no versioned `cogenta migrate` entry either (the same reasoning
|
|
8
|
+
* `menu-tables.ts` and `site-settings-tables.ts` already give for their own
|
|
9
|
+
* fixed tables — reused here rather than a third explanation of the same
|
|
10
|
+
* choice).
|
|
11
|
+
*
|
|
12
|
+
* Exactly one row ever exists, at the fixed id `SINGLETON_ID` — there is one
|
|
13
|
+
* admin, not one per visitor, so "the current admin theme" is a singleton,
|
|
14
|
+
* not a registry keyed by anything. `templateId` names one of
|
|
15
|
+
* `ADMIN_THEME_TEMPLATES`; `overrides` is the serialised, curated
|
|
16
|
+
* personalisation (`admin-theme-templates.ts`'s `AdminThemeOverrides`) layered
|
|
17
|
+
* on top of it — never the templates themselves, which stay code, not data.
|
|
18
|
+
*/
|
|
19
|
+
export const ADMIN_THEME_TABLE = 'cogenta_admin_theme';
|
|
20
|
+
/** The one row this table ever holds. */
|
|
21
|
+
export const ADMIN_THEME_SINGLETON_ID = 'singleton';
|
|
22
|
+
/** Generous for a JSON object with at most seven short fields. */
|
|
23
|
+
export const ADMIN_THEME_OVERRIDES_LENGTH = 4000;
|
|
24
|
+
export async function ensureAdminThemeTable(db) {
|
|
25
|
+
const dialect = db.dialect;
|
|
26
|
+
const table = identifier(ADMIN_THEME_TABLE, dialect);
|
|
27
|
+
const idColumn = identifier('id', dialect);
|
|
28
|
+
const statements = [
|
|
29
|
+
sql `create table if not exists ${table} (
|
|
30
|
+
${idColumn} ${textColumn(dialect, 16)} not null primary key,
|
|
31
|
+
${identifier('template_id', dialect)} ${textColumn(dialect, 32)} not null,
|
|
32
|
+
${identifier('overrides', dialect)} ${textColumn(dialect, ADMIN_THEME_OVERRIDES_LENGTH)} not null,
|
|
33
|
+
${identifier('updated_at', dialect)} ${timestampColumn(dialect)} not null,
|
|
34
|
+
${identifier('updated_by', dialect)} ${textColumn(dialect, 36)}
|
|
35
|
+
)`,
|
|
36
|
+
];
|
|
37
|
+
for (const statement of statements) {
|
|
38
|
+
await db.query(statement);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=admin-theme-tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-theme-tables.js","sourceRoot":"","sources":["../../src/store/admin-theme-tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,UAAU,EAAoB,GAAG,EAAE,MAAM,eAAe,CAAA;AACtF,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE1D;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAA;AAEtD,yCAAyC;AACzC,MAAM,CAAC,MAAM,wBAAwB,GAAG,WAAW,CAAA;AAEnD,kEAAkE;AAClE,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAA;AAEhD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,EAAkB;IAC5D,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAA;IAC1B,MAAM,KAAK,GAAG,UAAU,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;IACpD,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAE1C,MAAM,UAAU,GAAkB;QAChC,GAAG,CAAA,8BAA8B,KAAK;QAClC,QAAQ,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;QACnC,UAAU,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;QAC7D,UAAU,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,4BAA4B,CAAC;QACrF,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC;QAC7D,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;MAC9D;KACH,CAAA;IAED,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IAC3B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The admin's own runtime theming system (L21 task 2).
|
|
4
|
+
*
|
|
5
|
+
* `packages/admin/src/styles/theme.css` ships exactly one design, hard-coded
|
|
6
|
+
* ("Nightops" as of this session — see that file's own header for the full
|
|
7
|
+
* design rationale). Nothing lets an install pick a different one, or nudge
|
|
8
|
+
* a handful of tokens (a brand colour, a logo) without editing and
|
|
9
|
+
* rebuilding the CSS. This module is the data half of the fix: two built-in
|
|
10
|
+
* **templates** — complete, self-contained token sets an install starts
|
|
11
|
+
* from — plus a small, curated set of **overrides** a template can be
|
|
12
|
+
* personalised with (`AdminThemeOverrides`). `admin-theme-store.ts` is the
|
|
13
|
+
* persistence half; `packages/admin/src/theme/admin-theme-context.tsx` is
|
|
14
|
+
* the half that actually paints the result.
|
|
15
|
+
*
|
|
16
|
+
* Two decisions this module encodes and the rest of the feature depends on:
|
|
17
|
+
*
|
|
18
|
+
* 1. **A template is complete, never partial.** Both built-in templates
|
|
19
|
+
* below carry every token `theme.css` defines — surfaces, actions,
|
|
20
|
+
* status colours, shadows, radius, type — for both colour schemes. A
|
|
21
|
+
* template that only redefined "the interesting" tokens would leave an
|
|
22
|
+
* install with, say, Nightops' status colours under Atelier's surfaces:
|
|
23
|
+
* a broken hybrid nobody asked for. Copied verbatim from the CSS each
|
|
24
|
+
* template represents (`theme.css` itself for "nightops"; `git show
|
|
25
|
+
* 6c1c5bf^:packages/admin/src/styles/theme.css` for "atelier", the
|
|
26
|
+
* design that shipped immediately before the Nightops reskin).
|
|
27
|
+
* 2. **Personalising never rewrites a template.** `AdminThemeOverrides` is a
|
|
28
|
+
* much smaller, separate shape — the handful of levers the settings
|
|
29
|
+
* screen actually exposes (fiche's own list: primary/background/text
|
|
30
|
+
* colour, display font, body font, logo, corner radius) — stored
|
|
31
|
+
* alongside a `templateId`, never merged into `ADMIN_THEME_TEMPLATES`
|
|
32
|
+
* itself. Switching template throws no personalisation away by
|
|
33
|
+
* accident (it stays applied to whichever template is active next), and
|
|
34
|
+
* the two built-in constants below stay exactly what a fresh install
|
|
35
|
+
* ships, forever.
|
|
36
|
+
*/
|
|
37
|
+
export type AdminThemeTemplateId = 'nightops' | 'atelier';
|
|
38
|
+
export declare const ADMIN_THEME_TEMPLATE_IDS: readonly AdminThemeTemplateId[];
|
|
39
|
+
export interface AdminThemeColorTokens {
|
|
40
|
+
readonly background: string;
|
|
41
|
+
readonly foreground: string;
|
|
42
|
+
readonly card: string;
|
|
43
|
+
readonly cardForeground: string;
|
|
44
|
+
readonly muted: string;
|
|
45
|
+
readonly mutedForeground: string;
|
|
46
|
+
readonly border: string;
|
|
47
|
+
readonly input: string;
|
|
48
|
+
readonly ring: string;
|
|
49
|
+
readonly primary: string;
|
|
50
|
+
readonly primaryForeground: string;
|
|
51
|
+
readonly secondary: string;
|
|
52
|
+
readonly secondaryForeground: string;
|
|
53
|
+
readonly accent: string;
|
|
54
|
+
readonly accentForeground: string;
|
|
55
|
+
readonly destructive: string;
|
|
56
|
+
readonly destructiveForeground: string;
|
|
57
|
+
readonly destructiveSurface: string;
|
|
58
|
+
readonly success: string;
|
|
59
|
+
readonly successForeground: string;
|
|
60
|
+
readonly successSurface: string;
|
|
61
|
+
readonly warning: string;
|
|
62
|
+
readonly warningForeground: string;
|
|
63
|
+
readonly warningSurface: string;
|
|
64
|
+
readonly info: string;
|
|
65
|
+
readonly infoForeground: string;
|
|
66
|
+
readonly infoSurface: string;
|
|
67
|
+
readonly shadowCard: string;
|
|
68
|
+
readonly shadowRaised: string;
|
|
69
|
+
readonly shadowOverlay: string;
|
|
70
|
+
}
|
|
71
|
+
export interface AdminThemeRadiusTokens {
|
|
72
|
+
readonly sm: string;
|
|
73
|
+
readonly md: string;
|
|
74
|
+
readonly lg: string;
|
|
75
|
+
readonly xl: string;
|
|
76
|
+
}
|
|
77
|
+
export interface AdminThemeTemplate {
|
|
78
|
+
readonly id: AdminThemeTemplateId;
|
|
79
|
+
/** Plain proper noun, not translated — the same convention `GallerySkin.displayName` already uses for the site's own skin gallery. */
|
|
80
|
+
readonly name: string;
|
|
81
|
+
readonly description: string;
|
|
82
|
+
readonly light: AdminThemeColorTokens;
|
|
83
|
+
readonly dark: AdminThemeColorTokens;
|
|
84
|
+
readonly radius: AdminThemeRadiusTokens;
|
|
85
|
+
/** A font option id from `ADMIN_THEME_FONTS` below. */
|
|
86
|
+
readonly fontDisplay: string;
|
|
87
|
+
readonly fontBody: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Every font a template or an override may name. A closed list, not free
|
|
91
|
+
* text: the admin only ever self-hosts these four families plus the
|
|
92
|
+
* platform default (R1 — no runtime request to Google Fonts), so a
|
|
93
|
+
* personalisation cannot ask for a face nothing actually serves.
|
|
94
|
+
*/
|
|
95
|
+
export interface AdminThemeFontOption {
|
|
96
|
+
readonly id: string;
|
|
97
|
+
readonly label: string;
|
|
98
|
+
readonly family: string;
|
|
99
|
+
}
|
|
100
|
+
export declare const ADMIN_THEME_FONTS: readonly AdminThemeFontOption[];
|
|
101
|
+
export declare function adminThemeFontById(id: string): AdminThemeFontOption | undefined;
|
|
102
|
+
export declare const ADMIN_THEME_TEMPLATES: readonly AdminThemeTemplate[];
|
|
103
|
+
export declare function adminThemeTemplateById(id: string): AdminThemeTemplate | undefined;
|
|
104
|
+
export declare const DEFAULT_ADMIN_THEME_TEMPLATE_ID: AdminThemeTemplateId;
|
|
105
|
+
/**
|
|
106
|
+
* The curated, small set of levers the settings screen exposes — fiche's
|
|
107
|
+
* own list, kept identical: primary/background/text colour, display font,
|
|
108
|
+
* body font, admin logo, corner radius. Every field is optional: an
|
|
109
|
+
* override object only carries what a human actually changed, and an unset
|
|
110
|
+
* field falls back to the active template's own value, never to a second
|
|
111
|
+
* hard-coded default that could drift from it.
|
|
112
|
+
*
|
|
113
|
+
* Colours are plain `#rrggbb` (an `<input type="color">` cannot produce
|
|
114
|
+
* anything else) applied to both colour schemes alike — a real
|
|
115
|
+
* simplification against Nightops' own "never the same literal colour in
|
|
116
|
+
* both modes" rule, accepted deliberately: per-scheme personalisation would
|
|
117
|
+
* double the form for a lever this task scopes as a handful of fields, and
|
|
118
|
+
* a slightly-off shade in one scheme is a cosmetic cost, not a functional
|
|
119
|
+
* one.
|
|
120
|
+
*/
|
|
121
|
+
export declare const adminThemeOverridesSchema: z.ZodObject<{
|
|
122
|
+
primaryColor: z.ZodOptional<z.ZodString>;
|
|
123
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
124
|
+
textColor: z.ZodOptional<z.ZodString>;
|
|
125
|
+
fontDisplay: z.ZodOptional<z.ZodEnum<{
|
|
126
|
+
[x: string]: string;
|
|
127
|
+
}>>;
|
|
128
|
+
fontBody: z.ZodOptional<z.ZodEnum<{
|
|
129
|
+
[x: string]: string;
|
|
130
|
+
}>>;
|
|
131
|
+
radius: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
logoMediaId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
133
|
+
}, z.core.$strict>;
|
|
134
|
+
export type AdminThemeOverrides = z.infer<typeof adminThemeOverridesSchema>;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AAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,eAAO,MAAM,iBAAiB,EAAE,SAAS,oBAAoB,EAsBnD,CAAA;AAIV,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAE/E;AA8JD,eAAO,MAAM,qBAAqB,EAAE,SAAS,kBAAkB,EAAwB,CAAA;AAEvF,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAEjF;AAED,eAAO,MAAM,+BAA+B,EAAE,oBAAiC,CAAA;AAI/E;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;kBAY3B,CAAA;AAEX,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const ADMIN_THEME_TEMPLATE_IDS = ['nightops', 'atelier'];
|
|
3
|
+
export const ADMIN_THEME_FONTS = [
|
|
4
|
+
{
|
|
5
|
+
id: 'space-grotesk',
|
|
6
|
+
label: 'Space Grotesk',
|
|
7
|
+
family: '"Space Grotesk", "Segoe UI", system-ui, sans-serif',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
id: 'jetbrains-mono',
|
|
11
|
+
label: 'JetBrains Mono',
|
|
12
|
+
family: '"JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: 'plex-sans',
|
|
16
|
+
label: 'IBM Plex Sans',
|
|
17
|
+
family: '"Plex Sans", "Segoe UI", system-ui, sans-serif',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'plex-mono',
|
|
21
|
+
label: 'IBM Plex Mono',
|
|
22
|
+
family: '"Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
|
|
23
|
+
},
|
|
24
|
+
{ id: 'system', label: 'System UI', family: 'system-ui, "Segoe UI", sans-serif' },
|
|
25
|
+
];
|
|
26
|
+
const ADMIN_THEME_FONT_IDS = ADMIN_THEME_FONTS.map((font) => font.id);
|
|
27
|
+
export function adminThemeFontById(id) {
|
|
28
|
+
return ADMIN_THEME_FONTS.find((font) => font.id === id);
|
|
29
|
+
}
|
|
30
|
+
/** "Nightops" — the console direction this admin currently ships (`theme.css`, verbatim). */
|
|
31
|
+
const NIGHTOPS = {
|
|
32
|
+
id: 'nightops',
|
|
33
|
+
name: 'Nightops',
|
|
34
|
+
description: 'A dark navy navigation rail beside a crisp workspace, one electric-indigo accent. Space Grotesk throughout, JetBrains Mono for technical details.',
|
|
35
|
+
light: {
|
|
36
|
+
background: '#f4f6fb',
|
|
37
|
+
foreground: '#0d1220',
|
|
38
|
+
card: '#ffffff',
|
|
39
|
+
cardForeground: '#0d1220',
|
|
40
|
+
muted: '#eef1f7',
|
|
41
|
+
mutedForeground: '#5b6478',
|
|
42
|
+
border: '#e2e6ef',
|
|
43
|
+
input: '#cdd3e0',
|
|
44
|
+
ring: 'oklch(0.55 0.21 268)',
|
|
45
|
+
primary: 'oklch(0.55 0.21 268)',
|
|
46
|
+
primaryForeground: '#f5f6ff',
|
|
47
|
+
secondary: '#f1f3f9',
|
|
48
|
+
secondaryForeground: '#0d1220',
|
|
49
|
+
accent: 'oklch(0.55 0.21 268 / 10%)',
|
|
50
|
+
accentForeground: 'oklch(0.42 0.19 268)',
|
|
51
|
+
destructive: 'oklch(0.58 0.22 25)',
|
|
52
|
+
destructiveForeground: '#fff6f5',
|
|
53
|
+
destructiveSurface: 'oklch(0.58 0.22 25 / 10%)',
|
|
54
|
+
success: 'oklch(0.6 0.16 155)',
|
|
55
|
+
successForeground: '#f2fff7',
|
|
56
|
+
successSurface: 'oklch(0.6 0.16 155 / 12%)',
|
|
57
|
+
warning: 'oklch(0.7 0.16 70)',
|
|
58
|
+
warningForeground: '#211703',
|
|
59
|
+
warningSurface: 'oklch(0.7 0.16 70 / 14%)',
|
|
60
|
+
info: 'oklch(0.6 0.15 235)',
|
|
61
|
+
infoForeground: '#f5f9ff',
|
|
62
|
+
infoSurface: 'oklch(0.6 0.15 235 / 10%)',
|
|
63
|
+
shadowCard: '0 1px 2px rgb(13 18 32 / 0.04), 0 2px 6px rgb(13 18 32 / 0.05)',
|
|
64
|
+
shadowRaised: '0 4px 10px -2px rgb(13 18 32 / 0.08), 0 16px 32px -8px rgb(13 18 32 / 0.12)',
|
|
65
|
+
shadowOverlay: '0 8px 16px -4px rgb(13 18 32 / 0.12), 0 32px 64px -16px rgb(13 18 32 / 0.2)',
|
|
66
|
+
},
|
|
67
|
+
dark: {
|
|
68
|
+
background: '#090b12',
|
|
69
|
+
foreground: 'oklch(0.93 0.008 270)',
|
|
70
|
+
card: '#10131c',
|
|
71
|
+
cardForeground: 'oklch(0.93 0.008 270)',
|
|
72
|
+
muted: '#161a26',
|
|
73
|
+
mutedForeground: 'oklch(0.7 0.015 270)',
|
|
74
|
+
border: 'oklch(1 0 0 / 8%)',
|
|
75
|
+
input: 'oklch(1 0 0 / 14%)',
|
|
76
|
+
ring: 'oklch(0.76 0.16 268)',
|
|
77
|
+
primary: 'oklch(0.76 0.16 268)',
|
|
78
|
+
primaryForeground: '#0b0d1a',
|
|
79
|
+
secondary: '#161a26',
|
|
80
|
+
secondaryForeground: 'oklch(0.93 0.008 270)',
|
|
81
|
+
accent: 'oklch(0.76 0.16 268 / 16%)',
|
|
82
|
+
accentForeground: 'oklch(0.82 0.14 268)',
|
|
83
|
+
destructive: 'oklch(0.7 0.19 25)',
|
|
84
|
+
destructiveForeground: '#1c0704',
|
|
85
|
+
destructiveSurface: 'oklch(0.7 0.19 25 / 14%)',
|
|
86
|
+
success: 'oklch(0.78 0.17 155)',
|
|
87
|
+
successForeground: '#04130a',
|
|
88
|
+
successSurface: 'oklch(0.78 0.17 155 / 14%)',
|
|
89
|
+
warning: 'oklch(0.8 0.15 75)',
|
|
90
|
+
warningForeground: '#1f1503',
|
|
91
|
+
warningSurface: 'oklch(0.8 0.15 75 / 14%)',
|
|
92
|
+
info: 'oklch(0.76 0.13 235)',
|
|
93
|
+
infoForeground: '#071420',
|
|
94
|
+
infoSurface: 'oklch(0.76 0.13 235 / 14%)',
|
|
95
|
+
shadowCard: '0 1px 0 rgb(0 0 0 / 0.4), 0 4px 12px -2px rgb(0 0 0 / 0.45)',
|
|
96
|
+
shadowRaised: '0 2px 0 rgb(0 0 0 / 0.45), 0 16px 32px -8px rgb(0 0 0 / 0.55)',
|
|
97
|
+
shadowOverlay: '0 4px 0 rgb(0 0 0 / 0.5), 0 40px 80px -16px rgb(0 0 0 / 0.7)',
|
|
98
|
+
},
|
|
99
|
+
radius: { sm: '0.5rem', md: '0.75rem', lg: '1rem', xl: '1.25rem' },
|
|
100
|
+
fontDisplay: 'space-grotesk',
|
|
101
|
+
fontBody: 'space-grotesk',
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* "Atelier" — the warm, printed-paper design that shipped before the
|
|
105
|
+
* Nightops reskin, recovered from git history
|
|
106
|
+
* (`git show 6c1c5bf^:packages/admin/src/styles/theme.css`) rather than
|
|
107
|
+
* rewritten from memory, so its values are exactly what shipped, not an
|
|
108
|
+
* approximation of it.
|
|
109
|
+
*/
|
|
110
|
+
const ATELIER = {
|
|
111
|
+
id: 'atelier',
|
|
112
|
+
name: 'Atelier',
|
|
113
|
+
description: 'Warm, unbleached paper and a burnt-orange accent, set in IBM Plex — an editorial, printed-form register rather than a console.',
|
|
114
|
+
light: {
|
|
115
|
+
background: '#f2ede2',
|
|
116
|
+
foreground: '#201a11',
|
|
117
|
+
card: '#faf7f0',
|
|
118
|
+
cardForeground: '#201a11',
|
|
119
|
+
muted: '#e6dfcf',
|
|
120
|
+
mutedForeground: '#6b6152',
|
|
121
|
+
border: '#d8cfb8',
|
|
122
|
+
input: '#c2b799',
|
|
123
|
+
ring: '#c23d0a',
|
|
124
|
+
primary: '#c23d0a',
|
|
125
|
+
primaryForeground: '#fff6ec',
|
|
126
|
+
secondary: '#faf7f0',
|
|
127
|
+
secondaryForeground: '#201a11',
|
|
128
|
+
accent: '#ece0c8',
|
|
129
|
+
accentForeground: '#5c2c0c',
|
|
130
|
+
destructive: '#a3140a',
|
|
131
|
+
destructiveForeground: '#fff6ec',
|
|
132
|
+
destructiveSurface: '#f8e6de',
|
|
133
|
+
success: '#266b3d',
|
|
134
|
+
successForeground: '#f4fbf1',
|
|
135
|
+
successSurface: '#e6f0dd',
|
|
136
|
+
warning: '#8a5a05',
|
|
137
|
+
warningForeground: '#fdf6e6',
|
|
138
|
+
warningSurface: '#f3e7c9',
|
|
139
|
+
info: '#295a8a',
|
|
140
|
+
infoForeground: '#eff6ff',
|
|
141
|
+
infoSurface: '#dfe9f3',
|
|
142
|
+
shadowCard: '0 1px 0 rgb(32 26 17 / 0.08), 0 3px 8px -2px rgb(32 26 17 / 0.1)',
|
|
143
|
+
shadowRaised: '0 2px 0 rgb(32 26 17 / 0.1), 0 12px 24px -8px rgb(32 26 17 / 0.18)',
|
|
144
|
+
shadowOverlay: '0 4px 0 rgb(32 26 17 / 0.14), 0 32px 64px -16px rgb(32 26 17 / 0.32)',
|
|
145
|
+
},
|
|
146
|
+
dark: {
|
|
147
|
+
background: '#14100b',
|
|
148
|
+
foreground: '#f1e9d8',
|
|
149
|
+
card: '#1c1710',
|
|
150
|
+
cardForeground: '#f1e9d8',
|
|
151
|
+
muted: '#241d13',
|
|
152
|
+
mutedForeground: '#a99a80',
|
|
153
|
+
border: '#362b1a',
|
|
154
|
+
input: '#4a3b23',
|
|
155
|
+
ring: '#ff7a3d',
|
|
156
|
+
primary: '#ff7a3d',
|
|
157
|
+
primaryForeground: '#1c0f04',
|
|
158
|
+
secondary: '#241d13',
|
|
159
|
+
secondaryForeground: '#f1e9d8',
|
|
160
|
+
accent: '#2c2213',
|
|
161
|
+
accentForeground: '#ffcda3',
|
|
162
|
+
destructive: '#ff6350',
|
|
163
|
+
destructiveForeground: '#1c0704',
|
|
164
|
+
destructiveSurface: '#2c1510',
|
|
165
|
+
success: '#6bc98d',
|
|
166
|
+
successForeground: '#07170c',
|
|
167
|
+
successSurface: '#142016',
|
|
168
|
+
warning: '#e0ab3f',
|
|
169
|
+
warningForeground: '#1f1503',
|
|
170
|
+
warningSurface: '#26200e',
|
|
171
|
+
info: '#7fb3e0',
|
|
172
|
+
infoForeground: '#071420',
|
|
173
|
+
infoSurface: '#14202c',
|
|
174
|
+
shadowCard: '0 1px 0 rgb(0 0 0 / 0.5), 0 3px 10px -2px rgb(0 0 0 / 0.5)',
|
|
175
|
+
shadowRaised: '0 2px 0 rgb(0 0 0 / 0.55), 0 16px 32px -8px rgb(0 0 0 / 0.6)',
|
|
176
|
+
shadowOverlay: '0 4px 0 rgb(0 0 0 / 0.6), 0 40px 80px -16px rgb(0 0 0 / 0.75)',
|
|
177
|
+
},
|
|
178
|
+
radius: { sm: '0.125rem', md: '0.25rem', lg: '0.375rem', xl: '0.5rem' },
|
|
179
|
+
fontDisplay: 'plex-mono',
|
|
180
|
+
fontBody: 'plex-sans',
|
|
181
|
+
};
|
|
182
|
+
export const ADMIN_THEME_TEMPLATES = [NIGHTOPS, ATELIER];
|
|
183
|
+
export function adminThemeTemplateById(id) {
|
|
184
|
+
return ADMIN_THEME_TEMPLATES.find((template) => template.id === id);
|
|
185
|
+
}
|
|
186
|
+
export const DEFAULT_ADMIN_THEME_TEMPLATE_ID = 'nightops';
|
|
187
|
+
const HEX_COLOR = /^#[0-9a-fA-F]{6}$/u;
|
|
188
|
+
/**
|
|
189
|
+
* The curated, small set of levers the settings screen exposes — fiche's
|
|
190
|
+
* own list, kept identical: primary/background/text colour, display font,
|
|
191
|
+
* body font, admin logo, corner radius. Every field is optional: an
|
|
192
|
+
* override object only carries what a human actually changed, and an unset
|
|
193
|
+
* field falls back to the active template's own value, never to a second
|
|
194
|
+
* hard-coded default that could drift from it.
|
|
195
|
+
*
|
|
196
|
+
* Colours are plain `#rrggbb` (an `<input type="color">` cannot produce
|
|
197
|
+
* anything else) applied to both colour schemes alike — a real
|
|
198
|
+
* simplification against Nightops' own "never the same literal colour in
|
|
199
|
+
* both modes" rule, accepted deliberately: per-scheme personalisation would
|
|
200
|
+
* double the form for a lever this task scopes as a handful of fields, and
|
|
201
|
+
* a slightly-off shade in one scheme is a cosmetic cost, not a functional
|
|
202
|
+
* one.
|
|
203
|
+
*/
|
|
204
|
+
export const adminThemeOverridesSchema = z
|
|
205
|
+
.object({
|
|
206
|
+
primaryColor: z.string().regex(HEX_COLOR, 'Expected a #rrggbb colour.').optional(),
|
|
207
|
+
backgroundColor: z.string().regex(HEX_COLOR, 'Expected a #rrggbb colour.').optional(),
|
|
208
|
+
textColor: z.string().regex(HEX_COLOR, 'Expected a #rrggbb colour.').optional(),
|
|
209
|
+
fontDisplay: z.enum(ADMIN_THEME_FONT_IDS).optional(),
|
|
210
|
+
fontBody: z.enum(ADMIN_THEME_FONT_IDS).optional(),
|
|
211
|
+
/** Base (`md`) corner radius in rem; `sm`/`lg`/`xl` scale from it using the active template's own ratios. */
|
|
212
|
+
radius: z.number().min(0).max(2).optional(),
|
|
213
|
+
/** A `@cogenta/schema` media asset id, or `null` to clear a previously set logo. */
|
|
214
|
+
logoMediaId: z.string().min(1).nullable().optional(),
|
|
215
|
+
})
|
|
216
|
+
.strict();
|
|
217
|
+
//# sourceMappingURL=admin-theme-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-theme-templates.js","sourceRoot":"","sources":["../../src/store/admin-theme-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAwCvB,MAAM,CAAC,MAAM,wBAAwB,GAAoC,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;AAmEhG,MAAM,CAAC,MAAM,iBAAiB,GAAoC;IA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js
CHANGED
|
@@ -65,7 +65,10 @@ export function columnTypeFor(field, dialect) {
|
|
|
65
65
|
case 'slug':
|
|
66
66
|
return textColumn(dialect, 255);
|
|
67
67
|
case 'select':
|
|
68
|
-
|
|
68
|
+
// `many: true` holds several choices as an ordered JSON array (values.ts)
|
|
69
|
+
// rather than a join table: a choice references nothing, so there is no
|
|
70
|
+
// foreign key a join table would exist to enforce.
|
|
71
|
+
return field.options['many'] === true ? jsonColumn() : textColumn(dialect, 255);
|
|
69
72
|
case 'color':
|
|
70
73
|
return textColumn(dialect, 32);
|
|
71
74
|
case 'number':
|
|
@@ -81,7 +84,10 @@ export function columnTypeFor(field, dialect) {
|
|
|
81
84
|
case 'media':
|
|
82
85
|
// No foreign key: the media library is its own subsystem and a content
|
|
83
86
|
// table must not refuse to be created because it is not installed yet.
|
|
84
|
-
|
|
87
|
+
// `many: true` follows `select`'s lead just above, for the same reason —
|
|
88
|
+
// an ordered JSON array of ids, never a join table, since there is no
|
|
89
|
+
// foreign key on either side to justify one.
|
|
90
|
+
return field.options['many'] === true ? jsonColumn() : textColumn(dialect, 36);
|
|
85
91
|
case 'relation':
|
|
86
92
|
case 'taxonomy':
|
|
87
93
|
return uuidColumn(dialect);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columns.js","sourceRoot":"","sources":["../../src/store/columns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA0C,SAAS,EAAE,MAAM,eAAe,CAAA;AAG/F;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,UAAU,UAAU,CAAC,OAAwB;IACjD,IAAI,OAAO,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC,MAAM,CAAC,CAAA;IACpD,IAAI,OAAO,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC,UAAU,CAAC,CAAA;IACrD,OAAO,SAAS,CAAC,MAAM,CAAC,CAAA;AAC1B,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,UAAU,CAAC,OAA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AAI,EAAE;aAC9B,CAAC,CAAA;IACN,CAAC;AACH,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,cAAc,CAAC,QAA8B;IAC3D,MAAM,MAAM,GAAG,QAAQ,IAAI,UAAU,CAAA;IACrC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC,mBAAmB,CAAC,CAAA;IAC/D,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC,oBAAoB,CAAC,CAAA;IAChE,OAAO,SAAS,CAAC,oBAAoB,CAAC,CAAA;AACxC,CAAC"}
|
package/dist/store/diff.d.ts
CHANGED
|
@@ -13,6 +13,14 @@ export interface FieldChange {
|
|
|
13
13
|
readonly change: ChangeKind;
|
|
14
14
|
readonly before: unknown;
|
|
15
15
|
readonly after: unknown;
|
|
16
|
+
/**
|
|
17
|
+
* A word-level diff of `before`/`after`, populated only by `enrichWordDiffs`
|
|
18
|
+
* — never by `diffValues` itself, so the plain structural diff this file
|
|
19
|
+
* has always produced stays exactly as it was for every existing caller.
|
|
20
|
+
* Present only for a `changed` field whose two values are both plain text
|
|
21
|
+
* (a `text` field) or both extract to plain text (a `richText` document).
|
|
22
|
+
*/
|
|
23
|
+
readonly words?: readonly WordChange[];
|
|
16
24
|
}
|
|
17
25
|
export interface BlockChange {
|
|
18
26
|
/** The block zone this block belongs to. */
|
|
@@ -56,4 +64,36 @@ export declare function diffContent(before: {
|
|
|
56
64
|
readonly values: ContentValues;
|
|
57
65
|
readonly blocks: BlockZones;
|
|
58
66
|
}): ContentDiff;
|
|
67
|
+
/**
|
|
68
|
+
* Word-level diff, task 06-3 ("un mot corrigé apparaît comme un mot corrigé,
|
|
69
|
+
* pas « changé »"). A "word" is a maximal run of non-whitespace, or a maximal
|
|
70
|
+
* run of whitespace — so the reconstruction of either side is exactly
|
|
71
|
+
* `words.map(w => w.text).join('')`, whitespace included. `Array.from`-free by
|
|
72
|
+
* construction: the `u` flag makes `\S`/`\s` match by code point, so an
|
|
73
|
+
* astral character (outside the BMP) is one token, never a lone surrogate.
|
|
74
|
+
*/
|
|
75
|
+
export type WordOp = 'equal' | 'added' | 'removed';
|
|
76
|
+
export interface WordChange {
|
|
77
|
+
readonly op: WordOp;
|
|
78
|
+
readonly text: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Longest common subsequence of words, walked into a left-to-right script of
|
|
82
|
+
* equal/removed/added runs. Plain dynamic programming, ~30 lines — R9: no
|
|
83
|
+
* diff library for this.
|
|
84
|
+
*/
|
|
85
|
+
export declare function diffWords(before: string, after: string): readonly WordChange[];
|
|
86
|
+
/**
|
|
87
|
+
* Plain text out of a `text` field (a string, returned as-is) or a `richText`
|
|
88
|
+
* document (contract A: an array of `block`/`media`/`hr` nodes — the last
|
|
89
|
+
* since fiche 42 task 2 — `@cogenta/blocks`'s `richTextDocumentSchema`).
|
|
90
|
+
* Returns `null` for anything else, including a
|
|
91
|
+
* shape that merely looks like a document — the piège this file's own
|
|
92
|
+
* comment warns about: "le portable-text est un arbre; comparer
|
|
93
|
+
* `JSON.stringify` produit du bruit", so an unrecognised node refuses rather
|
|
94
|
+
* than guesses.
|
|
95
|
+
*/
|
|
96
|
+
export declare function extractPlainText(value: unknown): string | null;
|
|
97
|
+
/** Same enrichment, walked into every block's own field changes as well. */
|
|
98
|
+
export declare function enrichWordDiffs(diff: ContentDiff): ContentDiff;
|
|
59
99
|
//# sourceMappingURL=diff.d.ts.map
|