@vllnt/convex-events 0.1.0-canary.2310a69
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 +21 -0
- package/README.md +140 -0
- package/dist/client/index.d.ts +134 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +144 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +58 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +3 -0
- package/dist/client/types.js.map +1 -0
- package/dist/component/_generated/api.d.ts +40 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +93 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts +8 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +9 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/crons.d.ts +8 -0
- package/dist/component/crons.d.ts.map +1 -0
- package/dist/component/crons.js +11 -0
- package/dist/component/crons.js.map +1 -0
- package/dist/component/mutations.d.ts +30 -0
- package/dist/component/mutations.d.ts.map +1 -0
- package/dist/component/mutations.js +105 -0
- package/dist/component/mutations.js.map +1 -0
- package/dist/component/queries.d.ts +54 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +103 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +35 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +28 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/validators.d.ts +82 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +29 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/react/index.d.ts +63 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +40 -0
- package/dist/react/index.js.map +1 -0
- package/dist/shared.d.ts +23 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +23 -0
- package/dist/shared.js.map +1 -0
- package/package.json +112 -0
- package/src/client/index.ts +297 -0
- package/src/client/types.ts +62 -0
- package/src/component/_generated/api.ts +56 -0
- package/src/component/_generated/component.ts +113 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/component/convex.config.ts +10 -0
- package/src/component/crons.ts +18 -0
- package/src/component/mutations.ts +108 -0
- package/src/component/queries.ts +109 -0
- package/src/component/schema.ts +28 -0
- package/src/component/validators.ts +32 -0
- package/src/react/index.test.tsx +133 -0
- package/src/react/index.tsx +83 -0
- package/src/shared.ts +35 -0
- package/src/test.ts +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,IAAI;;;;;;;;;;;;;KA8Bf,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;IA8BxB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,KAAK;;;;;;;GA0BhB,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { paginationOptsValidator } from "convex/server";
|
|
3
|
+
import { query } from "./_generated/server";
|
|
4
|
+
import { eventDoc, eventPage, countResult } from "./validators";
|
|
5
|
+
/** Default scan bound for a capped `count` before it reports `isExact: false`. */
|
|
6
|
+
const DEFAULT_MAX_COUNT = 1000;
|
|
7
|
+
export const list = query({
|
|
8
|
+
args: {
|
|
9
|
+
subjectRef: v.string(),
|
|
10
|
+
type: v.optional(v.string()),
|
|
11
|
+
since: v.optional(v.number()),
|
|
12
|
+
limit: v.number(),
|
|
13
|
+
},
|
|
14
|
+
returns: v.array(eventDoc),
|
|
15
|
+
handler: async (ctx, args) => {
|
|
16
|
+
const since = args.since;
|
|
17
|
+
const type = args.type;
|
|
18
|
+
if (type === undefined) {
|
|
19
|
+
return await ctx.db
|
|
20
|
+
.query("events")
|
|
21
|
+
.withIndex("by_subject", (q) => {
|
|
22
|
+
const scoped = q.eq("subjectRef", args.subjectRef);
|
|
23
|
+
return since === undefined ? scoped : scoped.gte("createdAt", since);
|
|
24
|
+
})
|
|
25
|
+
.order("desc")
|
|
26
|
+
.take(args.limit);
|
|
27
|
+
}
|
|
28
|
+
return await ctx.db
|
|
29
|
+
.query("events")
|
|
30
|
+
.withIndex("by_subject_type", (q) => {
|
|
31
|
+
const scoped = q.eq("subjectRef", args.subjectRef).eq("type", type);
|
|
32
|
+
return since === undefined ? scoped : scoped.gte("createdAt", since);
|
|
33
|
+
})
|
|
34
|
+
.order("desc")
|
|
35
|
+
.take(args.limit);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Cursor-paginated feed, newest-first, honoring the same `type` / `since`
|
|
40
|
+
* filters as `list`. Returns Convex's `{ page, isDone, continueCursor }` so a
|
|
41
|
+
* host can page past any single-call `limit`.
|
|
42
|
+
*/
|
|
43
|
+
export const listPaginated = query({
|
|
44
|
+
args: {
|
|
45
|
+
subjectRef: v.string(),
|
|
46
|
+
type: v.optional(v.string()),
|
|
47
|
+
since: v.optional(v.number()),
|
|
48
|
+
paginationOpts: paginationOptsValidator,
|
|
49
|
+
},
|
|
50
|
+
returns: eventPage,
|
|
51
|
+
handler: async (ctx, args) => {
|
|
52
|
+
const since = args.since;
|
|
53
|
+
const type = args.type;
|
|
54
|
+
if (type === undefined) {
|
|
55
|
+
return await ctx.db
|
|
56
|
+
.query("events")
|
|
57
|
+
.withIndex("by_subject", (q) => {
|
|
58
|
+
const scoped = q.eq("subjectRef", args.subjectRef);
|
|
59
|
+
return since === undefined ? scoped : scoped.gte("createdAt", since);
|
|
60
|
+
})
|
|
61
|
+
.order("desc")
|
|
62
|
+
.paginate(args.paginationOpts);
|
|
63
|
+
}
|
|
64
|
+
return await ctx.db
|
|
65
|
+
.query("events")
|
|
66
|
+
.withIndex("by_subject_type", (q) => {
|
|
67
|
+
const scoped = q.eq("subjectRef", args.subjectRef).eq("type", type);
|
|
68
|
+
return since === undefined ? scoped : scoped.gte("createdAt", since);
|
|
69
|
+
})
|
|
70
|
+
.order("desc")
|
|
71
|
+
.paginate(args.paginationOpts);
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* Bounded count for `subjectRef` (optionally one `type`). Scans at most
|
|
76
|
+
* `maxCount + 1` rows: if more exist, returns `{ count: maxCount, isExact: false }`
|
|
77
|
+
* rather than loading the whole feed.
|
|
78
|
+
*/
|
|
79
|
+
export const count = query({
|
|
80
|
+
args: {
|
|
81
|
+
subjectRef: v.string(),
|
|
82
|
+
type: v.optional(v.string()),
|
|
83
|
+
maxCount: v.optional(v.number()),
|
|
84
|
+
},
|
|
85
|
+
returns: countResult,
|
|
86
|
+
handler: async (ctx, args) => {
|
|
87
|
+
const type = args.type;
|
|
88
|
+
const maxCount = args.maxCount ?? DEFAULT_MAX_COUNT;
|
|
89
|
+
const rows = type === undefined
|
|
90
|
+
? await ctx.db
|
|
91
|
+
.query("events")
|
|
92
|
+
.withIndex("by_subject", (q) => q.eq("subjectRef", args.subjectRef))
|
|
93
|
+
.take(maxCount + 1)
|
|
94
|
+
: await ctx.db
|
|
95
|
+
.query("events")
|
|
96
|
+
.withIndex("by_subject_type", (q) => q.eq("subjectRef", args.subjectRef).eq("type", type))
|
|
97
|
+
.take(maxCount + 1);
|
|
98
|
+
return rows.length > maxCount
|
|
99
|
+
? { count: maxCount, isExact: false }
|
|
100
|
+
: { count: rows.length, isExact: true };
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhE,kFAAkF;AAClF,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC;IACxB,IAAI,EAAE;QACJ,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC5B,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;KAClB;IACD,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC1B,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,MAAM,GAAG,CAAC,EAAE;iBAChB,KAAK,CAAC,QAAQ,CAAC;iBACf,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE;gBAC7B,MAAM,MAA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`actorRef` are opaque host-owned references (never assume their shape).
|
|
4
|
+
* Events are append-only; ordering is by the host-stamped `createdAt`.
|
|
5
|
+
*/
|
|
6
|
+
declare const _default: import("convex/server").SchemaDefinition<{
|
|
7
|
+
events: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
8
|
+
actorRef?: string | undefined;
|
|
9
|
+
metadata?: any;
|
|
10
|
+
subjectRef: string;
|
|
11
|
+
type: string;
|
|
12
|
+
createdAt: number;
|
|
13
|
+
}, {
|
|
14
|
+
subjectRef: import("convex/values").VString<string, "required">;
|
|
15
|
+
type: import("convex/values").VString<string, "required">;
|
|
16
|
+
actorRef: import("convex/values").VString<string | undefined, "optional">;
|
|
17
|
+
metadata: import("convex/values").VAny<any, "optional", string>;
|
|
18
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
19
|
+
}, "required", "subjectRef" | "type" | "actorRef" | "metadata" | "createdAt" | `metadata.${string}`>, {
|
|
20
|
+
by_subject: ["subjectRef", "createdAt", "_creationTime"];
|
|
21
|
+
by_subject_type: ["subjectRef", "type", "createdAt", "_creationTime"];
|
|
22
|
+
by_createdAt: ["createdAt", "_creationTime"];
|
|
23
|
+
}, {}, {}>;
|
|
24
|
+
/**
|
|
25
|
+
* Singleton retention config, written by the host via `configure`. The daily
|
|
26
|
+
* cron reads it to prune events older than `retentionMs`; absent ⇒ no-op.
|
|
27
|
+
*/
|
|
28
|
+
config: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
29
|
+
retentionMs?: number | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
retentionMs: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
32
|
+
}, "required", "retentionMs">, {}, {}, {}>;
|
|
33
|
+
}, true>;
|
|
34
|
+
export default _default;
|
|
35
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAIA;;;;GAIG;;;;;;;;;;;;;;;;;;;IAYD;;;OAGG;;;;;;;AAdL,wBAkBG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineSchema, defineTable } from "convex/server";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
import { jsonValue } from "./validators";
|
|
4
|
+
/**
|
|
5
|
+
* Sandboxed tables — the activity ledger's own concern. `subjectRef` and
|
|
6
|
+
* `actorRef` are opaque host-owned references (never assume their shape).
|
|
7
|
+
* Events are append-only; ordering is by the host-stamped `createdAt`.
|
|
8
|
+
*/
|
|
9
|
+
export default defineSchema({
|
|
10
|
+
events: defineTable({
|
|
11
|
+
subjectRef: v.string(),
|
|
12
|
+
type: v.string(),
|
|
13
|
+
actorRef: v.optional(v.string()),
|
|
14
|
+
metadata: v.optional(jsonValue),
|
|
15
|
+
createdAt: v.number(),
|
|
16
|
+
})
|
|
17
|
+
.index("by_subject", ["subjectRef", "createdAt"])
|
|
18
|
+
.index("by_subject_type", ["subjectRef", "type", "createdAt"])
|
|
19
|
+
.index("by_createdAt", ["createdAt"]),
|
|
20
|
+
/**
|
|
21
|
+
* Singleton retention config, written by the host via `configure`. The daily
|
|
22
|
+
* cron reads it to prune events older than `retentionMs`; absent ⇒ no-op.
|
|
23
|
+
*/
|
|
24
|
+
config: defineTable({
|
|
25
|
+
retentionMs: v.optional(v.number()),
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;;;GAIG;AACH,eAAe,YAAY,CAAC;IAC1B,MAAM,EAAE,WAAW,CAAC;QAClB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAChC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC/B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACtB,CAAC;SACC,KAAK,CAAC,YAAY,EAAE,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;SAChD,KAAK,CAAC,iBAAiB,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;SAC7D,KAAK,CAAC,cAAc,EAAE,CAAC,WAAW,CAAC,CAAC;IACvC;;;OAGG;IACH,MAAM,EAAE,WAAW,CAAC;QAClB,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KACpC,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opaque host-owned event payload. The component never inspects it.
|
|
3
|
+
* Prefer a host-supplied validator / typed generic on the client class;
|
|
4
|
+
* `jsonValue` is the documented last resort for genuinely arbitrary data.
|
|
5
|
+
*/
|
|
6
|
+
export declare const jsonValue: import("convex/values").VAny<any, "required", string>;
|
|
7
|
+
/** Shape of a stored event row, as returned by the read queries. */
|
|
8
|
+
export declare const eventDoc: import("convex/values").VObject<{
|
|
9
|
+
actorRef?: string | undefined;
|
|
10
|
+
metadata?: any;
|
|
11
|
+
subjectRef: string;
|
|
12
|
+
type: string;
|
|
13
|
+
_id: import("convex/values").GenericId<"events">;
|
|
14
|
+
_creationTime: number;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
}, {
|
|
17
|
+
_id: import("convex/values").VId<import("convex/values").GenericId<"events">, "required">;
|
|
18
|
+
_creationTime: import("convex/values").VFloat64<number, "required">;
|
|
19
|
+
subjectRef: import("convex/values").VString<string, "required">;
|
|
20
|
+
type: import("convex/values").VString<string, "required">;
|
|
21
|
+
actorRef: import("convex/values").VString<string | undefined, "optional">;
|
|
22
|
+
metadata: import("convex/values").VAny<any, "optional", string>;
|
|
23
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
24
|
+
}, "required", "subjectRef" | "type" | "actorRef" | "metadata" | "_id" | "_creationTime" | "createdAt" | `metadata.${string}`>;
|
|
25
|
+
/** One page of events, as returned by the paginated read (Convex's pagination shape). */
|
|
26
|
+
export declare const eventPage: import("convex/values").VObject<{
|
|
27
|
+
splitCursor?: string | null;
|
|
28
|
+
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
29
|
+
page: {
|
|
30
|
+
actorRef?: string | undefined;
|
|
31
|
+
metadata?: any;
|
|
32
|
+
subjectRef: string;
|
|
33
|
+
type: string;
|
|
34
|
+
_id: import("convex/values").GenericId<"events">;
|
|
35
|
+
_creationTime: number;
|
|
36
|
+
createdAt: number;
|
|
37
|
+
}[];
|
|
38
|
+
continueCursor: string;
|
|
39
|
+
isDone: boolean;
|
|
40
|
+
}, {
|
|
41
|
+
page: import("convex/values").VArray<{
|
|
42
|
+
actorRef?: string | undefined;
|
|
43
|
+
metadata?: any;
|
|
44
|
+
subjectRef: string;
|
|
45
|
+
type: string;
|
|
46
|
+
_id: import("convex/values").GenericId<"events">;
|
|
47
|
+
_creationTime: number;
|
|
48
|
+
createdAt: number;
|
|
49
|
+
}[], import("convex/values").VObject<{
|
|
50
|
+
actorRef?: string | undefined;
|
|
51
|
+
metadata?: any;
|
|
52
|
+
subjectRef: string;
|
|
53
|
+
type: string;
|
|
54
|
+
_id: import("convex/values").GenericId<"events">;
|
|
55
|
+
_creationTime: number;
|
|
56
|
+
createdAt: number;
|
|
57
|
+
}, {
|
|
58
|
+
_id: import("convex/values").VId<import("convex/values").GenericId<"events">, "required">;
|
|
59
|
+
_creationTime: import("convex/values").VFloat64<number, "required">;
|
|
60
|
+
subjectRef: import("convex/values").VString<string, "required">;
|
|
61
|
+
type: import("convex/values").VString<string, "required">;
|
|
62
|
+
actorRef: import("convex/values").VString<string | undefined, "optional">;
|
|
63
|
+
metadata: import("convex/values").VAny<any, "optional", string>;
|
|
64
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
65
|
+
}, "required", "subjectRef" | "type" | "actorRef" | "metadata" | "_id" | "_creationTime" | "createdAt" | `metadata.${string}`>, "required">;
|
|
66
|
+
continueCursor: import("convex/values").VString<string, "required">;
|
|
67
|
+
isDone: import("convex/values").VBoolean<boolean, "required">;
|
|
68
|
+
splitCursor: import("convex/values").VUnion<string | null | undefined, [import("convex/values").VString<string, "required">, import("convex/values").VNull<null, "required">], "optional", never>;
|
|
69
|
+
pageStatus: import("convex/values").VUnion<"SplitRecommended" | "SplitRequired" | null | undefined, [import("convex/values").VLiteral<"SplitRecommended", "required">, import("convex/values").VLiteral<"SplitRequired", "required">, import("convex/values").VNull<null, "required">], "optional", never>;
|
|
70
|
+
}, "required", "page" | "continueCursor" | "isDone" | "splitCursor" | "pageStatus">;
|
|
71
|
+
/**
|
|
72
|
+
* A capped count. `isExact` is `false` when the feed has more events than the
|
|
73
|
+
* scan bound, so `count` is the bound rather than the true total.
|
|
74
|
+
*/
|
|
75
|
+
export declare const countResult: import("convex/values").VObject<{
|
|
76
|
+
count: number;
|
|
77
|
+
isExact: boolean;
|
|
78
|
+
}, {
|
|
79
|
+
count: import("convex/values").VFloat64<number, "required">;
|
|
80
|
+
isExact: import("convex/values").VBoolean<boolean, "required">;
|
|
81
|
+
}, "required", "count" | "isExact">;
|
|
82
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/component/validators.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,SAAS,uDAAU,CAAC;AAEjC,oEAAoE;AACpE,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;8HAQnB,CAAC;AAEH,yFAAyF;AACzF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mFAAsC,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;mCAGtB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { paginationResultValidator } from "convex/server";
|
|
3
|
+
/**
|
|
4
|
+
* Opaque host-owned event payload. The component never inspects it.
|
|
5
|
+
* Prefer a host-supplied validator / typed generic on the client class;
|
|
6
|
+
* `jsonValue` is the documented last resort for genuinely arbitrary data.
|
|
7
|
+
*/
|
|
8
|
+
export const jsonValue = v.any();
|
|
9
|
+
/** Shape of a stored event row, as returned by the read queries. */
|
|
10
|
+
export const eventDoc = v.object({
|
|
11
|
+
_id: v.id("events"),
|
|
12
|
+
_creationTime: v.number(),
|
|
13
|
+
subjectRef: v.string(),
|
|
14
|
+
type: v.string(),
|
|
15
|
+
actorRef: v.optional(v.string()),
|
|
16
|
+
metadata: v.optional(jsonValue),
|
|
17
|
+
createdAt: v.number(),
|
|
18
|
+
});
|
|
19
|
+
/** One page of events, as returned by the paginated read (Convex's pagination shape). */
|
|
20
|
+
export const eventPage = paginationResultValidator(eventDoc);
|
|
21
|
+
/**
|
|
22
|
+
* A capped count. `isExact` is `false` when the feed has more events than the
|
|
23
|
+
* scan bound, so `count` is the bound rather than the true total.
|
|
24
|
+
*/
|
|
25
|
+
export const countResult = v.object({
|
|
26
|
+
count: v.number(),
|
|
27
|
+
isExact: v.boolean(),
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/component/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;AAEjC,oEAAoE;AACpE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC;IACnB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAChC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;IAC/B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC;AAEH,yFAAyF;AACzF,MAAM,CAAC,MAAM,SAAS,GAAG,yBAAyB,CAAC,QAAQ,CAAC,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;CACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional React front-tooling for `@vllnt/convex-events`.
|
|
3
|
+
*
|
|
4
|
+
* Thin hooks over `convex/react` for the reactive activity-feed surface. They
|
|
5
|
+
* never import the host's `api`: the host passes its own **re-exported** public
|
|
6
|
+
* function reference (a `paginate` query, a `count` query) plus args. `react`
|
|
7
|
+
* and `convex` are optional peer deps — a backend-only consumer pulls none of
|
|
8
|
+
* this code (tree-shakeable, separate `./react` entry).
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { type PaginatedQueryArgs, type PaginatedQueryItem, type UsePaginatedQueryResult } from "convex/react";
|
|
13
|
+
import type { FunctionReference, PaginationOptions } from "convex/server";
|
|
14
|
+
import type { CountResult } from "../client/types.js";
|
|
15
|
+
export type { CountResult };
|
|
16
|
+
/**
|
|
17
|
+
* The host's re-exported **paginated** feed query. A public query taking
|
|
18
|
+
* `{ subjectRef, type?, paginationOpts }` and returning a Convex page —
|
|
19
|
+
* exactly the ref shape `usePaginatedQuery` consumes.
|
|
20
|
+
*/
|
|
21
|
+
export type ActivityFeedRef = FunctionReference<"query", "public", {
|
|
22
|
+
subjectRef: string;
|
|
23
|
+
type?: string;
|
|
24
|
+
paginationOpts: PaginationOptions;
|
|
25
|
+
}, {
|
|
26
|
+
page: unknown[];
|
|
27
|
+
isDone: boolean;
|
|
28
|
+
continueCursor: string;
|
|
29
|
+
}>;
|
|
30
|
+
/** The host's re-exported `count` query: `{ subjectRef, type? }` → {@link CountResult}. */
|
|
31
|
+
export type EventCountRef = FunctionReference<"query", "public", {
|
|
32
|
+
subjectRef: string;
|
|
33
|
+
type?: string;
|
|
34
|
+
}, CountResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Reactive, cursor-paginated activity feed for one `subjectRef`.
|
|
37
|
+
*
|
|
38
|
+
* Thin wrapper over `usePaginatedQuery` against the host's re-exported
|
|
39
|
+
* `paginate` query reference — the component never owns the host's `api`. Stays
|
|
40
|
+
* generic over the exact ref so the host's page item type flows through.
|
|
41
|
+
*
|
|
42
|
+
* @param paginateRef - the host's re-exported paginated feed query.
|
|
43
|
+
* @param args - `{ subjectRef, type? }` (the page's `paginationOpts` are managed by the hook).
|
|
44
|
+
* @param opts - `{ initialNumItems }` page size for the first load.
|
|
45
|
+
* @returns `{ results, status, loadMore }` from `usePaginatedQuery`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function useActivityFeed<Ref extends ActivityFeedRef>(paginateRef: Ref, args: PaginatedQueryArgs<Ref>, opts: {
|
|
48
|
+
initialNumItems: number;
|
|
49
|
+
}): UsePaginatedQueryResult<PaginatedQueryItem<Ref>>;
|
|
50
|
+
/**
|
|
51
|
+
* Reactive bounded count for one `subjectRef` (optionally one `type`).
|
|
52
|
+
*
|
|
53
|
+
* Thin wrapper over `useQuery` against the host's re-exported `count` query.
|
|
54
|
+
*
|
|
55
|
+
* @param countRef - the host's re-exported `count` query.
|
|
56
|
+
* @param args - `{ subjectRef, type? }`.
|
|
57
|
+
* @returns the `{ count, isExact }` result, or `undefined` while loading.
|
|
58
|
+
*/
|
|
59
|
+
export declare function useEventCount(countRef: EventCountRef, args: {
|
|
60
|
+
subjectRef: string;
|
|
61
|
+
type?: string;
|
|
62
|
+
}): CountResult | undefined;
|
|
63
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,iBAAiB,CAC7C,OAAO,EACP,QAAQ,EACR;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,iBAAiB,CAAC;CACnC,EACD;IAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAC7D,CAAC;AAEF,2FAA2F;AAC3F,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAC3C,OAAO,EACP,QAAQ,EACR;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EACrC,WAAW,CACZ,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,GAAG,SAAS,eAAe,EACzD,WAAW,EAAE,GAAG,EAChB,IAAI,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAC7B,IAAI,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GAChC,uBAAuB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAElD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1C,WAAW,GAAG,SAAS,CAEzB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional React front-tooling for `@vllnt/convex-events`.
|
|
3
|
+
*
|
|
4
|
+
* Thin hooks over `convex/react` for the reactive activity-feed surface. They
|
|
5
|
+
* never import the host's `api`: the host passes its own **re-exported** public
|
|
6
|
+
* function reference (a `paginate` query, a `count` query) plus args. `react`
|
|
7
|
+
* and `convex` are optional peer deps — a backend-only consumer pulls none of
|
|
8
|
+
* this code (tree-shakeable, separate `./react` entry).
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { useQuery, usePaginatedQuery, } from "convex/react";
|
|
13
|
+
/**
|
|
14
|
+
* Reactive, cursor-paginated activity feed for one `subjectRef`.
|
|
15
|
+
*
|
|
16
|
+
* Thin wrapper over `usePaginatedQuery` against the host's re-exported
|
|
17
|
+
* `paginate` query reference — the component never owns the host's `api`. Stays
|
|
18
|
+
* generic over the exact ref so the host's page item type flows through.
|
|
19
|
+
*
|
|
20
|
+
* @param paginateRef - the host's re-exported paginated feed query.
|
|
21
|
+
* @param args - `{ subjectRef, type? }` (the page's `paginationOpts` are managed by the hook).
|
|
22
|
+
* @param opts - `{ initialNumItems }` page size for the first load.
|
|
23
|
+
* @returns `{ results, status, loadMore }` from `usePaginatedQuery`.
|
|
24
|
+
*/
|
|
25
|
+
export function useActivityFeed(paginateRef, args, opts) {
|
|
26
|
+
return usePaginatedQuery(paginateRef, args, opts);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Reactive bounded count for one `subjectRef` (optionally one `type`).
|
|
30
|
+
*
|
|
31
|
+
* Thin wrapper over `useQuery` against the host's re-exported `count` query.
|
|
32
|
+
*
|
|
33
|
+
* @param countRef - the host's re-exported `count` query.
|
|
34
|
+
* @param args - `{ subjectRef, type? }`.
|
|
35
|
+
* @returns the `{ count, isExact }` result, or `undefined` while loading.
|
|
36
|
+
*/
|
|
37
|
+
export function useEventCount(countRef, args) {
|
|
38
|
+
return useQuery(countRef, args);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,QAAQ,EACR,iBAAiB,GAIlB,MAAM,cAAc,CAAC;AA8BtB;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAC7B,WAAgB,EAChB,IAA6B,EAC7B,IAAiC;IAEjC,OAAO,iBAAiB,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACpD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAuB,EACvB,IAA2C;IAE3C,OAAO,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Shared constants + types used by both `client/` and `component/`. */
|
|
2
|
+
export declare const COMPONENT_NAME = "events";
|
|
3
|
+
/** Default page size when a `list` call omits `limit`. */
|
|
4
|
+
export declare const DEFAULT_LIMIT = 50;
|
|
5
|
+
/** Default scan bound for a capped `count` before it reports `isExact: false`. */
|
|
6
|
+
export declare const DEFAULT_MAX_COUNT = 1000;
|
|
7
|
+
/** Opaque host-supplied subject reference. Never assume its shape or source. */
|
|
8
|
+
export type SubjectRef = string;
|
|
9
|
+
/** Stable, code-tagged reasons a boundary guard in `record` can reject input. */
|
|
10
|
+
export declare const EVENT_ERROR_CODES: {
|
|
11
|
+
readonly TYPE_NOT_ALLOWED: "EVENTS_TYPE_NOT_ALLOWED";
|
|
12
|
+
readonly TYPE_TOO_LONG: "EVENTS_TYPE_TOO_LONG";
|
|
13
|
+
readonly METADATA_TOO_LARGE: "EVENTS_METADATA_TOO_LARGE";
|
|
14
|
+
readonly METADATA_INVALID: "EVENTS_METADATA_INVALID";
|
|
15
|
+
};
|
|
16
|
+
/** One of the {@link EVENT_ERROR_CODES} values. */
|
|
17
|
+
export type EventErrorCode = (typeof EVENT_ERROR_CODES)[keyof typeof EVENT_ERROR_CODES];
|
|
18
|
+
/** A code-tagged client-boundary rejection from `record`. */
|
|
19
|
+
export declare class EventValidationError extends Error {
|
|
20
|
+
readonly code: EventErrorCode;
|
|
21
|
+
constructor(code: EventErrorCode, message: string);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,wEAAwE;AAExE,eAAO,MAAM,cAAc,WAAW,CAAC;AAEvC,0DAA0D;AAC1D,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,iFAAiF;AACjF,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAC;AAEX,mDAAmD;AACnD,MAAM,MAAM,cAAc,GACxB,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D,6DAA6D;AAC7D,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,QAAQ,CAAC,IAAI,EAAE,cAAc;gBAApB,IAAI,EAAE,cAAc,EAC7B,OAAO,EAAE,MAAM;CAKlB"}
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Shared constants + types used by both `client/` and `component/`. */
|
|
2
|
+
export const COMPONENT_NAME = "events";
|
|
3
|
+
/** Default page size when a `list` call omits `limit`. */
|
|
4
|
+
export const DEFAULT_LIMIT = 50;
|
|
5
|
+
/** Default scan bound for a capped `count` before it reports `isExact: false`. */
|
|
6
|
+
export const DEFAULT_MAX_COUNT = 1000;
|
|
7
|
+
/** Stable, code-tagged reasons a boundary guard in `record` can reject input. */
|
|
8
|
+
export const EVENT_ERROR_CODES = {
|
|
9
|
+
TYPE_NOT_ALLOWED: "EVENTS_TYPE_NOT_ALLOWED",
|
|
10
|
+
TYPE_TOO_LONG: "EVENTS_TYPE_TOO_LONG",
|
|
11
|
+
METADATA_TOO_LARGE: "EVENTS_METADATA_TOO_LARGE",
|
|
12
|
+
METADATA_INVALID: "EVENTS_METADATA_INVALID",
|
|
13
|
+
};
|
|
14
|
+
/** A code-tagged client-boundary rejection from `record`. */
|
|
15
|
+
export class EventValidationError extends Error {
|
|
16
|
+
code;
|
|
17
|
+
constructor(code, message) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.code = code;
|
|
20
|
+
this.name = "EventValidationError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,wEAAwE;AAExE,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEvC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAEhC,kFAAkF;AAClF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAKtC,iFAAiF;AACjF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,gBAAgB,EAAE,yBAAyB;IAC3C,aAAa,EAAE,sBAAsB;IACrC,kBAAkB,EAAE,2BAA2B;IAC/C,gBAAgB,EAAE,yBAAyB;CACnC,CAAC;AAMX,6DAA6D;AAC7D,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAElC;IADX,YACW,IAAoB,EAC7B,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,SAAI,GAAJ,IAAI,CAAgB;QAI7B,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vllnt/convex-events",
|
|
3
|
+
"version": "0.1.0-canary.2310a69",
|
|
4
|
+
"description": "Append-only per-subject activity feed and event ledger, as a Convex component",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"packageManager": "pnpm@9.15.4",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/client/index.d.ts",
|
|
16
|
+
"default": "./dist/client/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./react": {
|
|
19
|
+
"types": "./dist/react/index.d.ts",
|
|
20
|
+
"default": "./dist/react/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./test": "./src/test.ts",
|
|
23
|
+
"./_generated/component.js": {
|
|
24
|
+
"types": "./dist/component/_generated/component.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./_generated/component": {
|
|
27
|
+
"types": "./dist/component/_generated/component.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./convex.config": {
|
|
30
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
31
|
+
"default": "./dist/component/convex.config.js"
|
|
32
|
+
},
|
|
33
|
+
"./convex.config.js": {
|
|
34
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
35
|
+
"default": "./dist/component/convex.config.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"types": "./dist/client/index.d.ts",
|
|
39
|
+
"module": "./dist/client/index.js",
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc --project ./tsconfig.build.json",
|
|
42
|
+
"build:codegen": "pnpm convex codegen --component-dir ./src/component && pnpm build",
|
|
43
|
+
"build:clean": "rm -rf dist *.tsbuildinfo && pnpm build:codegen",
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"typecheck:ci": "tsc --noEmit --project tsconfig.ci.json",
|
|
46
|
+
"lint": "eslint .",
|
|
47
|
+
"test": "vitest run --passWithNoTests",
|
|
48
|
+
"test:watch": "vitest --typecheck --clearScreen false",
|
|
49
|
+
"test:coverage": "vitest run --coverage --coverage.reporter=text",
|
|
50
|
+
"generate:llms": "node scripts/generate-llms.mjs",
|
|
51
|
+
"preversion": "pnpm install --frozen-lockfile && pnpm build && pnpm test:coverage && pnpm typecheck && pnpm generate:llms",
|
|
52
|
+
"prepublishOnly": "npm whoami || npm login",
|
|
53
|
+
"alpha": "npm version prerelease --preid alpha && npm publish --tag alpha && git push --follow-tags",
|
|
54
|
+
"release": "npm version patch && npm publish && git push --follow-tags"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"convex": "^1.41.0",
|
|
59
|
+
"react": ">=18"
|
|
60
|
+
},
|
|
61
|
+
"peerDependenciesMeta": {
|
|
62
|
+
"react": {
|
|
63
|
+
"optional": true
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@edge-runtime/vm": "^5.0.0",
|
|
68
|
+
"@testing-library/react": "^16.3.2",
|
|
69
|
+
"@types/react": "^19.2.17",
|
|
70
|
+
"@types/react-dom": "^19.2.3",
|
|
71
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
72
|
+
"@vllnt/eslint-config": "^1.0.0",
|
|
73
|
+
"@vllnt/typescript": "^1.0.0",
|
|
74
|
+
"convex": "^1.41.0",
|
|
75
|
+
"convex-test": "^0.0.53",
|
|
76
|
+
"eslint": "^9.0.0",
|
|
77
|
+
"jsdom": "^29.1.1",
|
|
78
|
+
"prettier": "^3.4.0",
|
|
79
|
+
"react": "^19.2.7",
|
|
80
|
+
"react-dom": "^19.2.7",
|
|
81
|
+
"typescript": "^5.7.0",
|
|
82
|
+
"vitest": "^4.1.8"
|
|
83
|
+
},
|
|
84
|
+
"homepage": "https://github.com/vllnt/convex-events#readme",
|
|
85
|
+
"bugs": {
|
|
86
|
+
"url": "https://github.com/vllnt/convex-events/issues"
|
|
87
|
+
},
|
|
88
|
+
"author": {
|
|
89
|
+
"name": "bntvllnt",
|
|
90
|
+
"url": "https://bntvllnt.com"
|
|
91
|
+
},
|
|
92
|
+
"funding": {
|
|
93
|
+
"type": "github",
|
|
94
|
+
"url": "https://github.com/sponsors/bntvllnt"
|
|
95
|
+
},
|
|
96
|
+
"repository": {
|
|
97
|
+
"type": "git",
|
|
98
|
+
"url": "https://github.com/vllnt/convex-events"
|
|
99
|
+
},
|
|
100
|
+
"engines": {
|
|
101
|
+
"node": ">=18"
|
|
102
|
+
},
|
|
103
|
+
"publishConfig": {
|
|
104
|
+
"access": "public"
|
|
105
|
+
},
|
|
106
|
+
"sideEffects": false,
|
|
107
|
+
"keywords": [
|
|
108
|
+
"convex",
|
|
109
|
+
"convex-component",
|
|
110
|
+
"events"
|
|
111
|
+
]
|
|
112
|
+
}
|