@growth-labs/cms 0.2.0 → 0.3.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/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  // @growth-labs/cms — the reusable Fronts-proven publishing/admin engine, as a
2
2
  // package (NOT a shared engine). See docs/reference/cms-reuse-decision.md.
3
3
  //
4
- // This package ships the D1 schema contract (the 11-table
5
- // content/revision/media/authors/foundry-callback set) + its TypeScript row
4
+ // This package ships the D1 schema contract (the original 11-table
5
+ // content/revision/media/authors/foundry-callback set plus additive migrations) + its TypeScript row
6
6
  // types (WS7-04/06 foundation) AND the publishing engine — the content
7
7
  // data-access core (WS7-05):
8
8
  //
@@ -50,6 +50,7 @@ export {
50
50
  type CmsActivityLogRow,
51
51
  type CmsApiKeyRow,
52
52
  type CmsNotificationRow,
53
+ type CmsReaderStateRow,
53
54
  type CmsRole,
54
55
  type CmsTableName,
55
56
  type CmsWebhookRow,
@@ -73,6 +74,7 @@ export {
73
74
  type MediaAssetRow,
74
75
  NON_CMS_TABLES,
75
76
  type PodcastContentRow,
77
+ type ReaderManualReadState,
76
78
  splitStatements,
77
79
  type VideoContentRow,
78
80
  type VideoProcessingState,
@@ -20,6 +20,7 @@ export type {
20
20
  CmsActivityLogRow,
21
21
  CmsApiKeyRow,
22
22
  CmsNotificationRow,
23
+ CmsReaderStateRow,
23
24
  CmsRole,
24
25
  CmsWebhookRow,
25
26
  ContentContributorRow,
@@ -40,6 +41,7 @@ export type {
40
41
  MastheadUserRow,
41
42
  MediaAssetRow,
42
43
  PodcastContentRow,
44
+ ReaderManualReadState,
43
45
  VideoContentRow,
44
46
  VideoProcessingState,
45
47
  WorkspaceInviteRow,
@@ -741,6 +741,43 @@ CREATE INDEX idx_content_publication_attempts_recovery
741
741
  ON content_publication_attempts(state, updated_at);
742
742
  CREATE INDEX idx_content_publication_attempts_content
743
743
  ON content_publication_attempts(content_id, created_at DESC);
744
+ `,
745
+ },
746
+ {
747
+ id: '0019_reader_state',
748
+ sql: `
749
+ CREATE TABLE cms_reader_state (
750
+ identity_user_id TEXT NOT NULL,
751
+ site_id TEXT NOT NULL,
752
+ content_type TEXT NOT NULL CHECK (content_type IN ('article','video','podcast','newsletter','page')),
753
+ content_id TEXT NOT NULL,
754
+ first_opened_at INTEGER,
755
+ last_opened_at INTEGER,
756
+ max_progress_bps INTEGER NOT NULL DEFAULT 0 CHECK (max_progress_bps BETWEEN 0 AND 10000),
757
+ media_position_ms INTEGER CHECK (media_position_ms IS NULL OR media_position_ms >= 0),
758
+ media_duration_ms INTEGER CHECK (media_duration_ms IS NULL OR media_duration_ms >= 0),
759
+ progress_observed_at INTEGER,
760
+ automatic_completed_at INTEGER,
761
+ manual_read_state TEXT CHECK (manual_read_state IS NULL OR manual_read_state IN ('read','unread')),
762
+ manual_state_at INTEGER,
763
+ manual_mutation_id TEXT,
764
+ saved INTEGER NOT NULL DEFAULT 0 CHECK (saved IN (0,1)),
765
+ saved_at INTEGER,
766
+ saved_mutation_id TEXT,
767
+ preferences_json TEXT NOT NULL DEFAULT '{}',
768
+ preferences_at INTEGER,
769
+ preferences_mutation_id TEXT,
770
+ version INTEGER NOT NULL DEFAULT 0 CHECK (version >= 0),
771
+ created_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
772
+ updated_at INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
773
+ PRIMARY KEY (identity_user_id, site_id, content_type, content_id)
774
+ );
775
+ CREATE INDEX idx_cms_reader_state_library
776
+ ON cms_reader_state(identity_user_id, site_id, updated_at DESC, content_type, content_id);
777
+ CREATE INDEX idx_cms_reader_state_export
778
+ ON cms_reader_state(identity_user_id, site_id, created_at DESC, content_type, content_id);
779
+ CREATE INDEX idx_cms_reader_state_saved
780
+ ON cms_reader_state(identity_user_id, site_id, saved, updated_at DESC);
744
781
  `,
745
782
  },
746
783
  ]
@@ -1,5 +1,7 @@
1
- // The 11-table content/revision/media/authors/foundry-callback contract that
2
- // `@growth-labs/cms` owns. Verified against prod `fronts-data` 2026-05-29.
1
+ // The content/revision/media/authors/foundry-callback contract plus additive
2
+ // package-owned CMS platform/product tables. The original 11-table core was
3
+ // verified against prod `fronts-data` 2026-05-29; later entries are versioned
4
+ // migrations with their own workerd contract tests.
3
5
  //
4
6
  // This list is the CMS boundary made executable: it is exactly the tables the
5
7
  // package migration creates and nothing else. Identity/entitlement tables
@@ -23,6 +25,7 @@ export const CMS_TABLES = [
23
25
  'content_contributors',
24
26
  'content_slug_redirects',
25
27
  'content_publication_attempts',
28
+ 'cms_reader_state',
26
29
  // Masthead platform tables (migrations 0008–0011)
27
30
  'workspace_settings',
28
31
  'masthead_users',
@@ -567,6 +567,35 @@ export interface ContentPublicationAttemptRow {
567
567
  updated_at: number
568
568
  }
569
569
 
570
+ export type ReaderManualReadState = 'read' | 'unread'
571
+
572
+ /** Package-owned reader product state from migration 0019. */
573
+ export interface CmsReaderStateRow {
574
+ identity_user_id: string
575
+ site_id: string
576
+ content_type: ContentType
577
+ content_id: string
578
+ first_opened_at: number | null
579
+ last_opened_at: number | null
580
+ max_progress_bps: number
581
+ media_position_ms: number | null
582
+ media_duration_ms: number | null
583
+ progress_observed_at: number | null
584
+ automatic_completed_at: number | null
585
+ manual_read_state: ReaderManualReadState | null
586
+ manual_state_at: number | null
587
+ manual_mutation_id: string | null
588
+ saved: number
589
+ saved_at: number | null
590
+ saved_mutation_id: string | null
591
+ preferences_json: string
592
+ preferences_at: number | null
593
+ preferences_mutation_id: string | null
594
+ version: number
595
+ created_at: number
596
+ updated_at: number
597
+ }
598
+
570
599
  /**
571
600
  * Schema version for the intent_key derivation. Bump ONLY on a breaking change
572
601
  * to the canonical-cluster-id semantics; bumping rotates every intent_key (and