@vllnt/convex-analytics 0.1.0-canary.2b9f918

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.
Files changed (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +198 -0
  3. package/dist/client/index.d.ts +94 -0
  4. package/dist/client/index.d.ts.map +1 -0
  5. package/dist/client/index.js +132 -0
  6. package/dist/client/index.js.map +1 -0
  7. package/dist/client/types.d.ts +109 -0
  8. package/dist/client/types.d.ts.map +1 -0
  9. package/dist/client/types.js +2 -0
  10. package/dist/client/types.js.map +1 -0
  11. package/dist/component/_generated/api.d.ts +46 -0
  12. package/dist/component/_generated/api.d.ts.map +1 -0
  13. package/dist/component/_generated/api.js +31 -0
  14. package/dist/component/_generated/api.js.map +1 -0
  15. package/dist/component/_generated/component.d.ts +181 -0
  16. package/dist/component/_generated/component.d.ts.map +1 -0
  17. package/dist/component/_generated/component.js +11 -0
  18. package/dist/component/_generated/component.js.map +1 -0
  19. package/dist/component/_generated/dataModel.d.ts +46 -0
  20. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  21. package/dist/component/_generated/dataModel.js +11 -0
  22. package/dist/component/_generated/dataModel.js.map +1 -0
  23. package/dist/component/_generated/server.d.ts +133 -0
  24. package/dist/component/_generated/server.d.ts.map +1 -0
  25. package/dist/component/_generated/server.js +80 -0
  26. package/dist/component/_generated/server.js.map +1 -0
  27. package/dist/component/convex.config.d.ts +3 -0
  28. package/dist/component/convex.config.d.ts.map +1 -0
  29. package/dist/component/convex.config.js +10 -0
  30. package/dist/component/convex.config.js.map +1 -0
  31. package/dist/component/http.d.ts +13 -0
  32. package/dist/component/http.d.ts.map +1 -0
  33. package/dist/component/http.js +180 -0
  34. package/dist/component/http.js.map +1 -0
  35. package/dist/component/internal_mutations.d.ts +26 -0
  36. package/dist/component/internal_mutations.d.ts.map +1 -0
  37. package/dist/component/internal_mutations.js +126 -0
  38. package/dist/component/internal_mutations.js.map +1 -0
  39. package/dist/component/mutations.d.ts +24 -0
  40. package/dist/component/mutations.d.ts.map +1 -0
  41. package/dist/component/mutations.js +209 -0
  42. package/dist/component/mutations.js.map +1 -0
  43. package/dist/component/queries.d.ts +148 -0
  44. package/dist/component/queries.d.ts.map +1 -0
  45. package/dist/component/queries.js +376 -0
  46. package/dist/component/queries.js.map +1 -0
  47. package/dist/component/schema.d.ts +104 -0
  48. package/dist/component/schema.d.ts.map +1 -0
  49. package/dist/component/schema.js +72 -0
  50. package/dist/component/schema.js.map +1 -0
  51. package/dist/component/validators.d.ts +195 -0
  52. package/dist/component/validators.d.ts.map +1 -0
  53. package/dist/component/validators.js +71 -0
  54. package/dist/component/validators.js.map +1 -0
  55. package/dist/react/index.d.ts +89 -0
  56. package/dist/react/index.d.ts.map +1 -0
  57. package/dist/react/index.js +63 -0
  58. package/dist/react/index.js.map +1 -0
  59. package/dist/shared.d.ts +14 -0
  60. package/dist/shared.d.ts.map +1 -0
  61. package/dist/shared.js +18 -0
  62. package/dist/shared.js.map +1 -0
  63. package/dist/test.d.ts +117 -0
  64. package/dist/test.d.ts.map +1 -0
  65. package/dist/test.js +28 -0
  66. package/dist/test.js.map +1 -0
  67. package/dist/web/index.d.ts +121 -0
  68. package/dist/web/index.d.ts.map +1 -0
  69. package/dist/web/index.js +169 -0
  70. package/dist/web/index.js.map +1 -0
  71. package/package.json +121 -0
  72. package/src/client/index.ts +259 -0
  73. package/src/client/types.ts +121 -0
  74. package/src/component/_generated/api.ts +62 -0
  75. package/src/component/_generated/component.ts +196 -0
  76. package/src/component/_generated/dataModel.ts +60 -0
  77. package/src/component/_generated/server.ts +169 -0
  78. package/src/component/convex.config.ts +12 -0
  79. package/src/component/http.ts +204 -0
  80. package/src/component/internal_mutations.ts +167 -0
  81. package/src/component/mutations.ts +255 -0
  82. package/src/component/queries.ts +436 -0
  83. package/src/component/schema.ts +76 -0
  84. package/src/component/validators.ts +94 -0
  85. package/src/react/index.tsx +127 -0
  86. package/src/shared.ts +30 -0
  87. package/src/test.ts +44 -0
  88. package/src/web/index.ts +232 -0
@@ -0,0 +1,259 @@
1
+ import type {
2
+ GenericMutationCtx,
3
+ GenericQueryCtx,
4
+ GenericDataModel,
5
+ } from "convex/server";
6
+ import type {
7
+ AnalyticsConfig,
8
+ Props,
9
+ Granularity,
10
+ Range,
11
+ Where,
12
+ TrackOpts,
13
+ TrackResult,
14
+ TopRow,
15
+ TimeseriesPoint,
16
+ UniquesView,
17
+ FunnelStep,
18
+ RetentionCohort,
19
+ DistributionView,
20
+ PaginationOpts,
21
+ EventPage,
22
+ } from "./types.js";
23
+
24
+ export type {
25
+ AnalyticsConfig,
26
+ Range,
27
+ Where,
28
+ TrackOpts,
29
+ TrackResult,
30
+ TopRow,
31
+ TimeseriesPoint,
32
+ UniquesView,
33
+ FunnelStep,
34
+ RetentionCohort,
35
+ DistributionBin,
36
+ DistributionView,
37
+ PaginationOpts,
38
+ EventPage,
39
+ EventView,
40
+ } from "./types.js";
41
+ export type { Scalar, Props, Granularity } from "../shared.js";
42
+
43
+ type MutationCtx = {
44
+ runMutation: GenericMutationCtx<GenericDataModel>["runMutation"];
45
+ };
46
+ type QueryCtx = { runQuery: GenericQueryCtx<GenericDataModel>["runQuery"] };
47
+
48
+ interface ComponentApi {
49
+ mutations: {
50
+ track: unknown;
51
+ configure: unknown;
52
+ configSet: unknown;
53
+ };
54
+ queries: {
55
+ metric: unknown;
56
+ top: unknown;
57
+ timeseries: unknown;
58
+ uniques: unknown;
59
+ funnel: unknown;
60
+ retention: unknown;
61
+ distribution: unknown;
62
+ list: unknown;
63
+ configGet: unknown;
64
+ };
65
+ }
66
+
67
+ const DEFAULT_SCOPE = "default";
68
+
69
+ /**
70
+ * AnalyticsClient — typed, configurable wrapper over the analytics component.
71
+ *
72
+ * Generic over the host's props shape `TProps` for compile-time typing of
73
+ * `track`. Config (`scope`, `dimensions`, `granularities`, ...) is stored on
74
+ * the client and applied to every call — not ignored.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const analytics = new AnalyticsClient(components.analytics, {
79
+ * dimensions: ["plan", "source"],
80
+ * granularities: ["hour", "day"],
81
+ * });
82
+ * await analytics.track(ctx, "signup", { subjectRef: userId, props: { plan: "pro" } });
83
+ * const total = await analytics.metric(ctx, "signup");
84
+ * ```
85
+ */
86
+ export class AnalyticsClient<TProps extends Props = Props> {
87
+ private readonly component: ComponentApi;
88
+ private readonly scope: string;
89
+ private readonly dimensions: string[];
90
+ private readonly granularities: Granularity[];
91
+ private readonly sampleRate: number;
92
+ private readonly config: AnalyticsConfig;
93
+
94
+ constructor(component: unknown, config: AnalyticsConfig = {}) {
95
+ this.component = component as ComponentApi;
96
+ this.config = config;
97
+ this.scope = config.scope ?? DEFAULT_SCOPE;
98
+ this.dimensions = config.dimensions ?? [];
99
+ this.granularities = config.granularities ?? ["day"];
100
+ this.sampleRate = config.sampleRate ?? 1;
101
+ }
102
+
103
+ /** Ingest an event: rollup-on-write + raw event + counter. Sampling + dedupe applied. */
104
+ async track(
105
+ ctx: MutationCtx,
106
+ name: string,
107
+ opts: TrackOpts<TProps> = {},
108
+ ): Promise<TrackResult> {
109
+ return (await ctx.runMutation(this.component.mutations.track as never, {
110
+ scope: opts.scope ?? this.scope,
111
+ name,
112
+ subjectRef: opts.subjectRef,
113
+ sessionRef: opts.sessionRef,
114
+ props: opts.props,
115
+ ts: opts.ts,
116
+ dedupeKey: opts.dedupeKey,
117
+ dimensions: this.dimensions,
118
+ granularities: this.granularities,
119
+ sampleRate: this.sampleRate,
120
+ } as never)) as TrackResult;
121
+ }
122
+
123
+ /** Total count over a range, optionally filtered by a dimension value. */
124
+ async metric(
125
+ ctx: QueryCtx,
126
+ name: string,
127
+ opts: { range?: Range; where?: Where; scope?: string } = {},
128
+ ): Promise<number> {
129
+ return (await ctx.runQuery(this.component.queries.metric as never, {
130
+ scope: opts.scope ?? this.scope,
131
+ name,
132
+ range: opts.range,
133
+ where: opts.where,
134
+ } as never)) as number;
135
+ }
136
+
137
+ /** Top values of a dimension (breakdown). */
138
+ async top(
139
+ ctx: QueryCtx,
140
+ name: string,
141
+ dimension: string,
142
+ opts: { range?: Range; limit?: number; scope?: string } = {},
143
+ ): Promise<TopRow[]> {
144
+ return (await ctx.runQuery(this.component.queries.top as never, {
145
+ scope: opts.scope ?? this.scope,
146
+ name,
147
+ dimension,
148
+ range: opts.range,
149
+ limit: opts.limit,
150
+ } as never)) as TopRow[];
151
+ }
152
+
153
+ /** Bucketed counts over a range. */
154
+ async timeseries(
155
+ ctx: QueryCtx,
156
+ name: string,
157
+ opts: { granularity: Granularity; range: Range; where?: Where; scope?: string },
158
+ ): Promise<TimeseriesPoint[]> {
159
+ return (await ctx.runQuery(this.component.queries.timeseries as never, {
160
+ scope: opts.scope ?? this.scope,
161
+ name,
162
+ granularity: opts.granularity,
163
+ range: opts.range,
164
+ where: opts.where,
165
+ } as never)) as TimeseriesPoint[];
166
+ }
167
+
168
+ /** DAU/WAU/MAU from subjects. */
169
+ async uniques(
170
+ ctx: QueryCtx,
171
+ opts: { range: Range; granularity: Granularity; scope?: string },
172
+ ): Promise<UniquesView> {
173
+ return (await ctx.runQuery(this.component.queries.uniques as never, {
174
+ scope: opts.scope ?? this.scope,
175
+ range: opts.range,
176
+ granularity: opts.granularity,
177
+ } as never)) as UniquesView;
178
+ }
179
+
180
+ /** Ordered step conversion (generic, keyed by subjectRef). */
181
+ async funnel(
182
+ ctx: QueryCtx,
183
+ steps: string[],
184
+ opts: { range: Range; scope?: string },
185
+ ): Promise<FunnelStep[]> {
186
+ return (await ctx.runQuery(this.component.queries.funnel as never, {
187
+ scope: opts.scope ?? this.scope,
188
+ steps,
189
+ range: opts.range,
190
+ } as never)) as FunnelStep[];
191
+ }
192
+
193
+ /** Cohort return rates by first-seen period. */
194
+ async retention(
195
+ ctx: QueryCtx,
196
+ opts: {
197
+ cohortRange: Range;
198
+ periods: number;
199
+ granularity?: Granularity;
200
+ scope?: string;
201
+ },
202
+ ): Promise<RetentionCohort[]> {
203
+ return (await ctx.runQuery(this.component.queries.retention as never, {
204
+ scope: opts.scope ?? this.scope,
205
+ cohortRange: opts.cohortRange,
206
+ periods: opts.periods,
207
+ granularity: opts.granularity,
208
+ } as never)) as RetentionCohort[];
209
+ }
210
+
211
+ /** Histogram of a numeric measure: ascending upper-bound bins + overflow. */
212
+ async distribution(
213
+ ctx: QueryCtx,
214
+ name: string,
215
+ measure: string,
216
+ opts: { buckets: number[]; range?: Range; where?: Where; scope?: string },
217
+ ): Promise<DistributionView> {
218
+ return (await ctx.runQuery(this.component.queries.distribution as never, {
219
+ scope: opts.scope ?? this.scope,
220
+ name,
221
+ measure,
222
+ buckets: opts.buckets,
223
+ range: opts.range,
224
+ where: opts.where,
225
+ } as never)) as DistributionView;
226
+ }
227
+
228
+ /** Paginated raw events for an event name, newest first. */
229
+ async list(
230
+ ctx: QueryCtx,
231
+ name: string,
232
+ paginationOpts: PaginationOpts,
233
+ opts: { scope?: string } = {},
234
+ ): Promise<EventPage> {
235
+ return (await ctx.runQuery(this.component.queries.list as never, {
236
+ scope: opts.scope ?? this.scope,
237
+ name,
238
+ paginationOpts,
239
+ } as never)) as EventPage;
240
+ }
241
+
242
+ /** Persist cron-relevant config (retention/sampling/idle) for the scope. */
243
+ async configure(
244
+ ctx: MutationCtx,
245
+ opts: {
246
+ retentionDays?: number;
247
+ sampleRate?: number;
248
+ sessionIdleMs?: number;
249
+ scope?: string;
250
+ } = {},
251
+ ): Promise<void> {
252
+ await ctx.runMutation(this.component.mutations.configure as never, {
253
+ scope: opts.scope ?? this.scope,
254
+ retentionDays: opts.retentionDays ?? this.config.retentionDays,
255
+ sampleRate: opts.sampleRate ?? this.config.sampleRate,
256
+ sessionIdleMs: opts.sessionIdleMs ?? this.config.sessionIdleMs,
257
+ } as never);
258
+ }
259
+ }
@@ -0,0 +1,121 @@
1
+ import type { Scalar, Props, Granularity } from "../shared.js";
2
+
3
+ export type { Scalar, Props, Granularity };
4
+
5
+ /** A time range in epoch millis. */
6
+ export interface Range {
7
+ from?: number;
8
+ to?: number;
9
+ }
10
+
11
+ /** Filter a query to events where one dimension equals one value. */
12
+ export interface Where {
13
+ dim: string;
14
+ val: Scalar;
15
+ }
16
+
17
+ /** Client-owned config. Stored on the client and applied to every call. */
18
+ export interface AnalyticsConfig {
19
+ /** Multi-tenant partition. Default `"default"`. */
20
+ scope?: string;
21
+ /** Prop keys to roll up on (drives rollup-on-write). Default `[]`. */
22
+ dimensions?: string[];
23
+ /** Rollup bucket granularities. Default `["day"]`. */
24
+ granularities?: Granularity[];
25
+ /** Raw-event TTL in days (rollups kept forever). Default `90`. */
26
+ retentionDays?: number;
27
+ /** Sampling rate `0..1`. Default `1`. */
28
+ sampleRate?: number;
29
+ /** Session idle-close timeout in millis. Default `1800000` (30m). */
30
+ sessionIdleMs?: number;
31
+ }
32
+
33
+ /** Options for a single `track` call. */
34
+ export interface TrackOpts<TProps extends Props = Props> {
35
+ subjectRef?: string;
36
+ sessionRef?: string;
37
+ props?: TProps;
38
+ ts?: number;
39
+ /** Override the client's default scope for this event. */
40
+ scope?: string;
41
+ /** Skip if an event with this dedupe key already exists in the scope. */
42
+ dedupeKey?: string;
43
+ }
44
+
45
+ /** Outcome of a `track` call. */
46
+ export type TrackResult = "tracked" | "dropped" | "duplicate";
47
+
48
+ /** A `(value, count)` breakdown row. */
49
+ export interface TopRow {
50
+ value: string;
51
+ count: number;
52
+ }
53
+
54
+ /** A `(bucket, count)` timeseries point. */
55
+ export interface TimeseriesPoint {
56
+ bucket: number;
57
+ count: number;
58
+ }
59
+
60
+ /** DAU/WAU/MAU rollup. */
61
+ export interface UniquesView {
62
+ dau: number;
63
+ wau: number;
64
+ mau: number;
65
+ trend: Array<{ bucket: number; uniques: number }>;
66
+ }
67
+
68
+ /** A funnel step result. */
69
+ export interface FunnelStep {
70
+ name: string;
71
+ count: number;
72
+ rate: number;
73
+ }
74
+
75
+ /** A retention cohort row. */
76
+ export interface RetentionCohort {
77
+ cohort: number;
78
+ size: number;
79
+ retained: number[];
80
+ }
81
+
82
+ /** A histogram bin: events whose measure is at or below `upper`. */
83
+ export interface DistributionBin {
84
+ upper: number;
85
+ count: number;
86
+ }
87
+
88
+ /** Histogram of a numeric measure: bins by ascending upper bound + overflow. */
89
+ export interface DistributionView {
90
+ bins: DistributionBin[];
91
+ overflow: number;
92
+ count: number;
93
+ sum: number;
94
+ }
95
+
96
+ /** A raw event as returned by `list`. */
97
+ export interface EventView {
98
+ _id: string;
99
+ _creationTime: number;
100
+ scope: string;
101
+ name: string;
102
+ subjectRef?: string;
103
+ sessionRef?: string;
104
+ props: Props;
105
+ ts: number;
106
+ seq: number;
107
+ dedupeKey?: string;
108
+ }
109
+
110
+ /** Convex pagination options. */
111
+ export interface PaginationOpts {
112
+ numItems: number;
113
+ cursor: string | null;
114
+ }
115
+
116
+ /** A page of raw events. */
117
+ export interface EventPage {
118
+ page: EventView[];
119
+ isDone: boolean;
120
+ continueCursor: string;
121
+ }
@@ -0,0 +1,62 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated `api` utility.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+
11
+ import type * as http from "../http.js";
12
+ import type * as internal_mutations from "../internal_mutations.js";
13
+ import type * as mutations from "../mutations.js";
14
+ import type * as queries from "../queries.js";
15
+ import type * as validators from "../validators.js";
16
+
17
+ import type {
18
+ ApiFromModules,
19
+ FilterApi,
20
+ FunctionReference,
21
+ } from "convex/server";
22
+ import { anyApi, componentsGeneric } from "convex/server";
23
+
24
+ const fullApi: ApiFromModules<{
25
+ http: typeof http;
26
+ internal_mutations: typeof internal_mutations;
27
+ mutations: typeof mutations;
28
+ queries: typeof queries;
29
+ validators: typeof validators;
30
+ }> = anyApi as any;
31
+
32
+ /**
33
+ * A utility for referencing Convex functions in your app's public API.
34
+ *
35
+ * Usage:
36
+ * ```js
37
+ * const myFunctionReference = api.myModule.myFunction;
38
+ * ```
39
+ */
40
+ export const api: FilterApi<
41
+ typeof fullApi,
42
+ FunctionReference<any, "public">
43
+ > = anyApi as any;
44
+
45
+ /**
46
+ * A utility for referencing Convex functions in your app's internal API.
47
+ *
48
+ * Usage:
49
+ * ```js
50
+ * const myFunctionReference = internal.myModule.myFunction;
51
+ * ```
52
+ */
53
+ export const internal: FilterApi<
54
+ typeof fullApi,
55
+ FunctionReference<any, "internal">
56
+ > = anyApi as any;
57
+
58
+ export const components = componentsGeneric() as unknown as {
59
+ aggregate: import("@convex-dev/aggregate/_generated/component.js").ComponentApi<"aggregate">;
60
+ shardedCounter: import("@convex-dev/sharded-counter/_generated/component.js").ComponentApi<"shardedCounter">;
61
+ rateLimiter: import("@convex-dev/rate-limiter/_generated/component.js").ComponentApi<"rateLimiter">;
62
+ };
@@ -0,0 +1,196 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated `ComponentApi` utility.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+
11
+ import type { FunctionReference } from "convex/server";
12
+
13
+ /**
14
+ * A utility for referencing a Convex component's exposed API.
15
+ *
16
+ * Useful when expecting a parameter like `components.myComponent`.
17
+ * Usage:
18
+ * ```ts
19
+ * async function myFunction(ctx: QueryCtx, component: ComponentApi) {
20
+ * return ctx.runQuery(component.someFile.someQuery, { ...args });
21
+ * }
22
+ * ```
23
+ */
24
+ export type ComponentApi<Name extends string | undefined = string | undefined> =
25
+ {
26
+ mutations: {
27
+ configSet: FunctionReference<
28
+ "mutation",
29
+ "internal",
30
+ { key: string; scope: string; value: string },
31
+ null,
32
+ Name
33
+ >;
34
+ configure: FunctionReference<
35
+ "mutation",
36
+ "internal",
37
+ {
38
+ retentionDays?: number;
39
+ sampleRate?: number;
40
+ scope: string;
41
+ sessionIdleMs?: number;
42
+ },
43
+ null,
44
+ Name
45
+ >;
46
+ track: FunctionReference<
47
+ "mutation",
48
+ "internal",
49
+ {
50
+ dedupeKey?: string;
51
+ dimensions: Array<string>;
52
+ granularities: Array<"minute" | "hour" | "day">;
53
+ name: string;
54
+ props?: Record<string, string | number | boolean | null>;
55
+ sampleRate?: number;
56
+ scope: string;
57
+ sessionRef?: string;
58
+ subjectRef?: string;
59
+ ts?: number;
60
+ },
61
+ "tracked" | "dropped" | "duplicate",
62
+ Name
63
+ >;
64
+ };
65
+ queries: {
66
+ configGet: FunctionReference<
67
+ "query",
68
+ "internal",
69
+ { key: string; scope: string },
70
+ string | null,
71
+ Name
72
+ >;
73
+ distribution: FunctionReference<
74
+ "query",
75
+ "internal",
76
+ {
77
+ buckets: Array<number>;
78
+ measure: string;
79
+ name: string;
80
+ range?: { from?: number; to?: number };
81
+ scope: string;
82
+ where?: { dim: string; val: string | number | boolean | null };
83
+ },
84
+ {
85
+ bins: Array<{ count: number; upper: number }>;
86
+ count: number;
87
+ overflow: number;
88
+ sum: number;
89
+ },
90
+ Name
91
+ >;
92
+ funnel: FunctionReference<
93
+ "query",
94
+ "internal",
95
+ {
96
+ range: { from?: number; to?: number };
97
+ scope: string;
98
+ steps: Array<string>;
99
+ },
100
+ Array<{ count: number; name: string; rate: number }>,
101
+ Name
102
+ >;
103
+ list: FunctionReference<
104
+ "query",
105
+ "internal",
106
+ {
107
+ name: string;
108
+ paginationOpts: { cursor: string | null; numItems: number };
109
+ scope: string;
110
+ },
111
+ {
112
+ continueCursor: string;
113
+ isDone: boolean;
114
+ page: Array<{
115
+ _creationTime: number;
116
+ _id: string;
117
+ dedupeKey?: string;
118
+ name: string;
119
+ props: Record<string, string | number | boolean | null>;
120
+ scope: string;
121
+ seq: number;
122
+ sessionRef?: string;
123
+ subjectRef?: string;
124
+ ts: number;
125
+ }>;
126
+ },
127
+ Name
128
+ >;
129
+ metric: FunctionReference<
130
+ "query",
131
+ "internal",
132
+ {
133
+ name: string;
134
+ range?: { from?: number; to?: number };
135
+ scope: string;
136
+ where?: { dim: string; val: string | number | boolean | null };
137
+ },
138
+ number,
139
+ Name
140
+ >;
141
+ retention: FunctionReference<
142
+ "query",
143
+ "internal",
144
+ {
145
+ cohortRange: { from?: number; to?: number };
146
+ granularity?: "minute" | "hour" | "day";
147
+ periods: number;
148
+ scope: string;
149
+ },
150
+ Array<{ cohort: number; retained: Array<number>; size: number }>,
151
+ Name
152
+ >;
153
+ timeseries: FunctionReference<
154
+ "query",
155
+ "internal",
156
+ {
157
+ granularity: "minute" | "hour" | "day";
158
+ name: string;
159
+ range: { from?: number; to?: number };
160
+ scope: string;
161
+ where?: { dim: string; val: string | number | boolean | null };
162
+ },
163
+ Array<{ bucket: number; count: number }>,
164
+ Name
165
+ >;
166
+ top: FunctionReference<
167
+ "query",
168
+ "internal",
169
+ {
170
+ dimension: string;
171
+ limit?: number;
172
+ name: string;
173
+ range?: { from?: number; to?: number };
174
+ scope: string;
175
+ },
176
+ Array<{ count: number; value: string }>,
177
+ Name
178
+ >;
179
+ uniques: FunctionReference<
180
+ "query",
181
+ "internal",
182
+ {
183
+ granularity: "minute" | "hour" | "day";
184
+ range: { from?: number; to?: number };
185
+ scope: string;
186
+ },
187
+ {
188
+ dau: number;
189
+ mau: number;
190
+ trend: Array<{ bucket: number; uniques: number }>;
191
+ wau: number;
192
+ },
193
+ Name
194
+ >;
195
+ };
196
+ };
@@ -0,0 +1,60 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated data model types.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+
11
+ import type {
12
+ DataModelFromSchemaDefinition,
13
+ DocumentByName,
14
+ TableNamesInDataModel,
15
+ SystemTableNames,
16
+ } from "convex/server";
17
+ import type { GenericId } from "convex/values";
18
+ import schema from "../schema.js";
19
+
20
+ /**
21
+ * The names of all of your Convex tables.
22
+ */
23
+ export type TableNames = TableNamesInDataModel<DataModel>;
24
+
25
+ /**
26
+ * The type of a document stored in Convex.
27
+ *
28
+ * @typeParam TableName - A string literal type of the table name (like "users").
29
+ */
30
+ export type Doc<TableName extends TableNames> = DocumentByName<
31
+ DataModel,
32
+ TableName
33
+ >;
34
+
35
+ /**
36
+ * An identifier for a document in Convex.
37
+ *
38
+ * Convex documents are uniquely identified by their `Id`, which is accessible
39
+ * on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
40
+ *
41
+ * Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
42
+ *
43
+ * IDs are just strings at runtime, but this type can be used to distinguish them from other
44
+ * strings when type checking.
45
+ *
46
+ * @typeParam TableName - A string literal type of the table name (like "users").
47
+ */
48
+ export type Id<TableName extends TableNames | SystemTableNames> =
49
+ GenericId<TableName>;
50
+
51
+ /**
52
+ * A type describing your Convex data model.
53
+ *
54
+ * This type includes information about what tables you have, the type of
55
+ * documents stored in those tables, and the indexes defined on them.
56
+ *
57
+ * This type is used to parameterize methods like `queryGeneric` and
58
+ * `mutationGeneric` to make them type-safe.
59
+ */
60
+ export type DataModel = DataModelFromSchemaDefinition<typeof schema>;