@echovisionlab/geul-common 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +6 -0
- package/README.md +37 -0
- package/package.json +89 -0
- package/src/collaboration/artist.ts +63 -0
- package/src/collaboration/block-room-codec/ai-document-applicator.ts +319 -0
- package/src/collaboration/block-room-codec/ai-document-field-mutations.ts +557 -0
- package/src/collaboration/block-room-codec/ai-document-page-structure-mutations.ts +449 -0
- package/src/collaboration/block-room-codec/ai-document-values.ts +368 -0
- package/src/collaboration/block-room-codec/hydration.ts +257 -0
- package/src/collaboration/block-room-codec/internal.ts +432 -0
- package/src/collaboration/block-room-codec/locale-change-validation.ts +237 -0
- package/src/collaboration/block-room-codec/locale-presence.ts +827 -0
- package/src/collaboration/block-room-codec/materialization.ts +450 -0
- package/src/collaboration/block-room-codec/observation.ts +518 -0
- package/src/collaboration/block-room-codec/payload-mutations.ts +347 -0
- package/src/collaboration/block-room-codec/room-access.ts +154 -0
- package/src/collaboration/block-room-codec/structure-mutations.ts +456 -0
- package/src/collaboration/block-room-codec.ts +86 -0
- package/src/collaboration/campaign.ts +37 -0
- package/src/collaboration/document-layout.ts +75 -0
- package/src/collaboration/document.ts +185 -0
- package/src/collaboration/email-layout.ts +150 -0
- package/src/collaboration/form.ts +513 -0
- package/src/collaboration/label.ts +49 -0
- package/src/collaboration/map-theme.ts +157 -0
- package/src/collaboration/member-id.ts +9 -0
- package/src/collaboration/menu.ts +258 -0
- package/src/collaboration/metadata-ai.ts +99 -0
- package/src/collaboration/page.ts +483 -0
- package/src/collaboration/post-series.ts +96 -0
- package/src/collaboration/post.ts +59 -0
- package/src/collaboration/release.ts +221 -0
- package/src/collaboration/runtime-events.ts +547 -0
- package/src/collaboration/work.ts +107 -0
- package/src/editor/link-normalization.ts +212 -0
- package/src/editor/materialized-blocks.ts +58 -0
- package/src/index.ts +22 -0
- package/src/media/block-schemas.ts +78 -0
- package/src/media/hydration.ts +226 -0
- package/src/page/block-fixtures.ts +586 -0
- package/src/page/index.ts +3 -0
- package/src/page/types.ts +57 -0
- package/src/post/index.ts +1 -0
- package/src/post/types.ts +13 -0
- package/src/test/random-id.ts +9 -0
- package/src/translation/release.ts +88 -0
- package/src/types.ts +14 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export type ReleaseDescriptionTranslation = unknown[];
|
|
2
|
+
export type ReleaseCreditNoteTranslations = Record<string, string>;
|
|
3
|
+
|
|
4
|
+
export interface LegacyReleaseTranslationContent {
|
|
5
|
+
description: ReleaseDescriptionTranslation;
|
|
6
|
+
creditNotes: ReleaseCreditNoteTranslations;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function readRecord(value: unknown): Record<string, unknown> | null {
|
|
10
|
+
return value && typeof value === "object"
|
|
11
|
+
? (value as Record<string, unknown>)
|
|
12
|
+
: null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function normalizeReleaseDescriptionTranslation(
|
|
16
|
+
value: unknown,
|
|
17
|
+
): ReleaseDescriptionTranslation {
|
|
18
|
+
return Array.isArray(value) ? value : [];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function normalizeReleaseCreditNoteTranslations(
|
|
22
|
+
value: unknown,
|
|
23
|
+
): ReleaseCreditNoteTranslations {
|
|
24
|
+
const record = readRecord(value);
|
|
25
|
+
if (!record) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return Object.fromEntries(
|
|
30
|
+
Object.entries(record).flatMap(([creditId, note]) => {
|
|
31
|
+
const normalizedCreditId = creditId.trim();
|
|
32
|
+
const normalizedNote = typeof note === "string" ? note.trim() : "";
|
|
33
|
+
if (!normalizedCreditId || !normalizedNote) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
return [[normalizedCreditId, normalizedNote]];
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Converter-only decoder for pre-Block combined translation payloads. */
|
|
42
|
+
export function decodeReleaseTranslationContent(
|
|
43
|
+
contentJson?: Uint8Array | null,
|
|
44
|
+
): LegacyReleaseTranslationContent | null {
|
|
45
|
+
if (!contentJson || contentJson.length === 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
const parsed = JSON.parse(new TextDecoder().decode(contentJson)) as unknown;
|
|
51
|
+
if (Array.isArray(parsed)) {
|
|
52
|
+
return {
|
|
53
|
+
description: parsed,
|
|
54
|
+
creditNotes: {},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const record = readRecord(parsed);
|
|
59
|
+
if (!record) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
description: normalizeReleaseDescriptionTranslation(record.description),
|
|
65
|
+
creditNotes: normalizeReleaseCreditNoteTranslations(record.creditNotes),
|
|
66
|
+
};
|
|
67
|
+
} catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Converter-only encoder for pre-Block combined translation payloads. */
|
|
73
|
+
export function encodeReleaseTranslationContent(
|
|
74
|
+
content: LegacyReleaseTranslationContent,
|
|
75
|
+
): Uint8Array {
|
|
76
|
+
const payload: Record<string, unknown> = {
|
|
77
|
+
description: normalizeReleaseDescriptionTranslation(content.description),
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const creditNotes = normalizeReleaseCreditNoteTranslations(
|
|
81
|
+
content.creditNotes,
|
|
82
|
+
);
|
|
83
|
+
if (Object.keys(creditNotes).length > 0) {
|
|
84
|
+
payload.creditNotes = creditNotes;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return new TextEncoder().encode(JSON.stringify(payload));
|
|
88
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common types shared across apps
|
|
3
|
+
* These are simplified versions of Kysely-generated types for apps that don't need full DB access
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// JSON types
|
|
7
|
+
export type JsonPrimitive = boolean | number | string | null;
|
|
8
|
+
export type JsonArray = JsonValue[];
|
|
9
|
+
export type JsonObject = { [x: string]: JsonValue | undefined };
|
|
10
|
+
export type JsonValue = JsonArray | JsonObject | JsonPrimitive;
|
|
11
|
+
export type Json = JsonValue;
|
|
12
|
+
|
|
13
|
+
// Enum type consumed by form clients.
|
|
14
|
+
export type FormStatus = "draft" | "published";
|