@reforma/types 0.1.0 → 0.1.2

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/index.js CHANGED
@@ -343,7 +343,8 @@ const DEFAULT_PROJECT_SETTINGS = {
343
343
  defaultPageTitle: "",
344
344
  defaultMetaDescription: "",
345
345
  faviconUrl: null,
346
- indexingEnabled: true
346
+ indexingEnabled: true,
347
+ analyticsEnabled: true
347
348
  },
348
349
  pendingPublish: false
349
350
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@reforma/types",
3
3
  "author": "Reforma, Inc. <dev@reforma.ai>",
4
4
  "description": "Shared types between Reforma apps/packages",
5
- "version": "0.1.0",
5
+ "version": "0.1.2",
6
6
  "license": "UNLICENSED",
7
7
  "repository": {
8
8
  "type": "git",
@@ -0,0 +1,47 @@
1
+ /** Public file id from `POST /files/public/presign`. The API fills url and name from that row. */
2
+ export type CreateComposerDraftAttachment = {
3
+ id: string;
4
+ };
5
+
6
+ /** What a marketing site sends before redirecting to `/new?draft=`. */
7
+ export type CreateComposerDraft = {
8
+ prompt: string;
9
+ planMode?: boolean;
10
+ attachments?: CreateComposerDraftAttachment[];
11
+ /** When the visitor submitted. ISO 8601. The API stamps now when this is omitted. */
12
+ createdAt?: string;
13
+ };
14
+
15
+ export type ComposerDraftAttachment = {
16
+ id: string;
17
+ url: string;
18
+ filename: string;
19
+ mediaType: string;
20
+ size: number;
21
+ };
22
+
23
+ /** Stored handoff. Attachments are public uploads, not client-supplied URLs. */
24
+ export type ComposerDraft = {
25
+ prompt: string;
26
+ planMode: boolean;
27
+ attachments: ComposerDraftAttachment[];
28
+ /** ISO 8601 submit time. */
29
+ createdAt: string;
30
+ /** Set once this handoff has created a project. Later visits open that project. */
31
+ projectId?: number;
32
+ };
33
+
34
+ /** Remember the project a handoff already created. The first id wins. */
35
+ export type ClaimComposerDraftProject = {
36
+ projectId: number;
37
+ };
38
+
39
+ /** Result of claiming. `fresh` is true only for the call that recorded the project. */
40
+ export type ClaimedComposerDraftProject = {
41
+ projectId: number;
42
+ fresh: boolean;
43
+ };
44
+
45
+ export type CreateComposerDraftResponse = {
46
+ id: string;
47
+ };
package/src/api/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './auth';
2
2
  export * from './billing';
3
3
  export * from './chat';
4
+ export * from './composer-drafts';
4
5
  export * from './file';
5
6
  export * from './files/buffer-upload';
6
7
  export * from './files/file-owner-type.enum';
@@ -0,0 +1,15 @@
1
+ /** Body for public `POST /analytics/collect`. */
2
+ export interface AnalyticsCollect {
3
+ /** Project write key baked into `REFORMA_ANALYTICS_KEY`. */
4
+ key: string;
5
+ /** Full page URL or path; server extracts path and UTM. */
6
+ url: string;
7
+ referrer?: string;
8
+ /**
9
+ * Event name. Omit or `pageview` for a traffic pageview; any other name is a
10
+ * custom event (goal conversion).
11
+ */
12
+ name?: string;
13
+ /** Optional string props for custom events (ignored for pageviews). */
14
+ props?: Record<string, string>;
15
+ }
@@ -0,0 +1,93 @@
1
+ /** Aggregated traffic for a project date range. */
2
+ export interface AnalyticsSummary {
3
+ uniqueVisitors: number;
4
+ totalVisits: number;
5
+ totalPageviews: number;
6
+ viewsPerVisit: number;
7
+ bounceRate: number;
8
+ /** Mean visit duration in seconds. */
9
+ visitDuration: number;
10
+ timeseries: AnalyticsTimeseriesPoint[];
11
+ topPages: AnalyticsBreakdownRow[];
12
+ entryPages: AnalyticsBreakdownRow[];
13
+ exitPages: AnalyticsBreakdownRow[];
14
+ /** Referrer host or utm_source (Direct when neither). */
15
+ topSources: AnalyticsBreakdownRow[];
16
+ /** Coarse: Direct | Referral | Campaign. */
17
+ channels: AnalyticsBreakdownRow[];
18
+ /** utm_medium values. Pageviews without a medium are omitted. */
19
+ mediums: AnalyticsBreakdownRow[];
20
+ campaigns: AnalyticsBreakdownRow[];
21
+ countries: AnalyticsBreakdownRow[];
22
+ browsers: AnalyticsBreakdownRow[];
23
+ operatingSystems: AnalyticsBreakdownRow[];
24
+ devices: AnalyticsBreakdownRow[];
25
+ /**
26
+ * Custom events in the range (no registry). Capped at the API goals limit;
27
+ * when `goalsTruncated` is true more names exist than were returned.
28
+ */
29
+ goals: AnalyticsGoalRow[];
30
+ goalsTruncated: boolean;
31
+ comparison?: AnalyticsComparison;
32
+ }
33
+
34
+ export interface AnalyticsTimeseriesPoint {
35
+ /** ISO date (day) or hour bucket start. */
36
+ t: string;
37
+ visitors: number;
38
+ pageviews: number;
39
+ visits: number;
40
+ bounceRate: number;
41
+ /** Mean visit duration in seconds for the bucket. */
42
+ visitDuration: number;
43
+ }
44
+
45
+ export interface AnalyticsBreakdownRow {
46
+ name: string;
47
+ visitors: number;
48
+ pageviews: number;
49
+ }
50
+
51
+ /** One custom event name aggregated as a conversion goal. */
52
+ export interface AnalyticsGoalRow {
53
+ name: string;
54
+ /** Distinct visitors who fired this event at least once. */
55
+ visitors: number;
56
+ /** Total event firings. */
57
+ conversions: number;
58
+ /**
59
+ * Converters / pageview unique visitors, clamped to at most 1. Zero when
60
+ * there were no pageview visitors in the range (event-only traffic).
61
+ */
62
+ conversionRate: number;
63
+ /**
64
+ * Top prop pairs as `key=value` rows. `pageviews` and `visitors` are firing
65
+ * counts for that pair (not distinct people across combinations).
66
+ */
67
+ props: AnalyticsBreakdownRow[];
68
+ }
69
+
70
+ /** Distinct visitors with a pageview in the last few minutes. */
71
+ export interface AnalyticsRealtime {
72
+ currentVisitors: number;
73
+ }
74
+
75
+ export type AnalyticsPeriod = 'today' | 'yesterday' | '24h' | '7d' | '30d' | '90d' | 'month' | 'lastMonth';
76
+
77
+ export interface AnalyticsComparisonQuery {
78
+ compare: 'previous';
79
+ period?: AnalyticsPeriod;
80
+ timeZone?: string;
81
+ }
82
+
83
+ export type AnalyticsMetrics = Pick<AnalyticsSummary,
84
+ 'uniqueVisitors' | 'totalVisits' | 'totalPageviews' | 'viewsPerVisit' | 'bounceRate' | 'visitDuration'
85
+ >;
86
+
87
+ export interface AnalyticsComparison {
88
+ from: string;
89
+ to: string;
90
+ status: 'available' | 'outside_retention' | 'error';
91
+ /** Null means unavailable; an available period with no traffic has zero-valued metrics. */
92
+ metrics: AnalyticsMetrics | null;
93
+ }
@@ -0,0 +1,12 @@
1
+ export type { AnalyticsCollect } from './analytics-collect';
2
+ export type {
3
+ AnalyticsBreakdownRow,
4
+ AnalyticsComparison,
5
+ AnalyticsComparisonQuery,
6
+ AnalyticsGoalRow,
7
+ AnalyticsMetrics,
8
+ AnalyticsPeriod,
9
+ AnalyticsRealtime,
10
+ AnalyticsSummary,
11
+ AnalyticsTimeseriesPoint,
12
+ } from './analytics-summary';
@@ -10,6 +10,11 @@ export interface ProjectEnvVar {
10
10
  key: string;
11
11
  /** Covers both environments. */
12
12
  isSecret: boolean;
13
+ /**
14
+ * Set by Reforma (public hostname, default title, and the other publish
15
+ * keys). Present on list reads. Not stored, and writes reject the key.
16
+ */
17
+ managed?: boolean;
13
18
  /** Always set — a variable cannot exist without a production value. */
14
19
  production: ProjectEnvVarValue;
15
20
  /** `null` means development inherits the production value. */
@@ -1,5 +1,6 @@
1
1
  export * from './admin-oauth-client';
2
2
  export * from './admin-project';
3
+ export * from './analytics/index';
3
4
  export * from './create-project';
4
5
  export * from './deployments/index';
5
6
  export * from './domains/index';
@@ -26,6 +26,8 @@ export interface ProjectSettings {
26
26
  defaultMetaDescription: string;
27
27
  faviconUrl: string | null;
28
28
  indexingEnabled: boolean;
29
+ /** First-party pageview collection. Default on; publish bakes `REFORMA_ANALYTICS`. */
30
+ analyticsEnabled: boolean;
29
31
  };
30
32
  editor?: ProjectEditorSettings;
31
33
  /** SEO or env changed since the last successful publish. */
@@ -41,6 +43,7 @@ export const DEFAULT_PROJECT_SETTINGS: ProjectSettings = {
41
43
  defaultMetaDescription: '',
42
44
  faviconUrl: null,
43
45
  indexingEnabled: true,
46
+ analyticsEnabled: true,
44
47
  },
45
48
  pendingPublish: false,
46
49
  };
@@ -33,7 +33,7 @@ export type VersionListChanges = {
33
33
  * Optional `versionChanges` patches the version list in the same event.
34
34
  */
35
35
  export type VersionStatus = {
36
- /** Version on HEAD (`reforma-version` trailer), or null when unversioned. */
36
+ /** Version on HEAD or its nearest ancestor across service commits; null when unversioned. */
37
37
  currentVersion: string | null;
38
38
  /** Working tree has uncommitted changes. */
39
39
  uncommitted: boolean;
@@ -18,6 +18,11 @@ export interface CommandSpec {
18
18
  * The sandbox will manage bounded rolling segments (e.g. `${logFile}.0.jsonl`).
19
19
  */
20
20
  logFile?: string;
21
+ /**
22
+ * When true with `logFile`, open the JSONL for append instead of truncating on start.
23
+ * Used for session channels (install) that accumulate across runs.
24
+ */
25
+ appendLog?: boolean;
21
26
  /** Automatically remove executed command from registry after TTL. Default true. */
22
27
  autoClean?: boolean;
23
28
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  export type ChooseDesignDirectionVariant = {
4
4
  id: string;
5
- /** Short name on the card, in the user's language. */
5
+ /** Short English name on the card. */
6
6
  label: string;
7
7
  /** Optional note. For a generated preview, the English prompt. Not shown on the card. */
8
8
  description?: string;
@@ -14,6 +14,8 @@ export type ProjectEnvToolListedVariable = {
14
14
  key: string;
15
15
  secret: boolean;
16
16
  developmentOverride: boolean;
17
+ /** Set by Reforma. Read it from the environment; do not change it. */
18
+ managed?: boolean;
17
19
  };
18
20
 
19
21
  export type ProjectEnvToolOutput = {