@convex-dev/sharded-counter 0.1.7 → 0.2.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.
Files changed (84) hide show
  1. package/README.md +39 -41
  2. package/dist/{commonjs/client → client}/index.d.ts +6 -12
  3. package/dist/client/index.d.ts.map +1 -0
  4. package/dist/client/index.js.map +1 -0
  5. package/dist/component/_generated/api.d.ts +34 -0
  6. package/dist/component/_generated/api.d.ts.map +1 -0
  7. package/{src → dist}/component/_generated/api.js +11 -3
  8. package/dist/component/_generated/api.js.map +1 -0
  9. package/dist/component/_generated/component.d.ts +46 -0
  10. package/dist/component/_generated/component.d.ts.map +1 -0
  11. package/dist/component/_generated/component.js +11 -0
  12. package/dist/component/_generated/component.js.map +1 -0
  13. package/dist/component/_generated/dataModel.d.ts +46 -0
  14. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  15. package/dist/component/_generated/dataModel.js +11 -0
  16. package/dist/component/_generated/dataModel.js.map +1 -0
  17. package/{src → dist}/component/_generated/server.d.ts +10 -38
  18. package/dist/component/_generated/server.d.ts.map +1 -0
  19. package/dist/{esm/component → component}/_generated/server.js +9 -5
  20. package/dist/component/_generated/server.js.map +1 -0
  21. package/dist/component/convex.config.d.ts.map +1 -0
  22. package/dist/component/convex.config.js.map +1 -0
  23. package/dist/{commonjs/component → component}/public.d.ts +1 -1
  24. package/dist/component/public.d.ts.map +1 -0
  25. package/dist/component/public.js.map +1 -0
  26. package/dist/{commonjs/component → component}/schema.d.ts +2 -2
  27. package/dist/component/schema.d.ts.map +1 -0
  28. package/dist/component/schema.js.map +1 -0
  29. package/package.json +62 -38
  30. package/src/client/index.ts +4 -34
  31. package/src/component/_generated/api.ts +50 -0
  32. package/src/component/_generated/component.ts +63 -0
  33. package/src/component/_generated/server.ts +161 -0
  34. package/src/component/counter.test.ts +12 -9
  35. package/src/test.ts +18 -0
  36. package/dist/commonjs/client/index.d.ts.map +0 -1
  37. package/dist/commonjs/client/index.js.map +0 -1
  38. package/dist/commonjs/component/_generated/api.d.ts +0 -14
  39. package/dist/commonjs/component/_generated/api.d.ts.map +0 -1
  40. package/dist/commonjs/component/_generated/api.js +0 -22
  41. package/dist/commonjs/component/_generated/api.js.map +0 -1
  42. package/dist/commonjs/component/_generated/server.d.ts +0 -64
  43. package/dist/commonjs/component/_generated/server.d.ts.map +0 -1
  44. package/dist/commonjs/component/_generated/server.js +0 -74
  45. package/dist/commonjs/component/_generated/server.js.map +0 -1
  46. package/dist/commonjs/component/convex.config.d.ts.map +0 -1
  47. package/dist/commonjs/component/convex.config.js.map +0 -1
  48. package/dist/commonjs/component/public.d.ts.map +0 -1
  49. package/dist/commonjs/component/public.js.map +0 -1
  50. package/dist/commonjs/component/schema.d.ts.map +0 -1
  51. package/dist/commonjs/component/schema.js.map +0 -1
  52. package/dist/commonjs/package.json +0 -3
  53. package/dist/esm/client/index.d.ts +0 -178
  54. package/dist/esm/client/index.d.ts.map +0 -1
  55. package/dist/esm/client/index.js +0 -193
  56. package/dist/esm/client/index.js.map +0 -1
  57. package/dist/esm/component/_generated/api.d.ts +0 -14
  58. package/dist/esm/component/_generated/api.d.ts.map +0 -1
  59. package/dist/esm/component/_generated/api.js +0 -22
  60. package/dist/esm/component/_generated/api.js.map +0 -1
  61. package/dist/esm/component/_generated/server.d.ts +0 -64
  62. package/dist/esm/component/_generated/server.d.ts.map +0 -1
  63. package/dist/esm/component/_generated/server.js.map +0 -1
  64. package/dist/esm/component/convex.config.d.ts +0 -3
  65. package/dist/esm/component/convex.config.d.ts.map +0 -1
  66. package/dist/esm/component/convex.config.js +0 -3
  67. package/dist/esm/component/convex.config.js.map +0 -1
  68. package/dist/esm/component/public.d.ts +0 -23
  69. package/dist/esm/component/public.d.ts.map +0 -1
  70. package/dist/esm/component/public.js +0 -115
  71. package/dist/esm/component/public.js.map +0 -1
  72. package/dist/esm/component/schema.d.ts +0 -15
  73. package/dist/esm/component/schema.d.ts.map +0 -1
  74. package/dist/esm/component/schema.js +0 -10
  75. package/dist/esm/component/schema.js.map +0 -1
  76. package/dist/esm/package.json +0 -3
  77. package/src/component/_generated/api.d.ts +0 -67
  78. package/src/component/_generated/server.js +0 -90
  79. /package/dist/{commonjs/client → client}/index.js +0 -0
  80. /package/dist/{commonjs/component → component}/convex.config.d.ts +0 -0
  81. /package/dist/{commonjs/component → component}/convex.config.js +0 -0
  82. /package/dist/{commonjs/component → component}/public.js +0 -0
  83. /package/dist/{commonjs/component → component}/schema.js +0 -0
  84. /package/src/component/_generated/{dataModel.d.ts → dataModel.ts} +0 -0
@@ -1,64 +0,0 @@
1
- /**
2
- * Define a query in this Convex app's public API.
3
- *
4
- * This function will be allowed to read your Convex database and will be accessible from the client.
5
- *
6
- * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
7
- * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
8
- */
9
- export const query: import("convex/server").QueryBuilder<any, "public">;
10
- /**
11
- * Define a query that is only accessible from other Convex functions (but not from the client).
12
- *
13
- * This function will be allowed to read from your Convex database. It will not be accessible from the client.
14
- *
15
- * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
16
- * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
17
- */
18
- export const internalQuery: import("convex/server").QueryBuilder<any, "internal">;
19
- /**
20
- * Define a mutation in this Convex app's public API.
21
- *
22
- * This function will be allowed to modify your Convex database and will be accessible from the client.
23
- *
24
- * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
25
- * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
26
- */
27
- export const mutation: import("convex/server").MutationBuilder<any, "public">;
28
- /**
29
- * Define a mutation that is only accessible from other Convex functions (but not from the client).
30
- *
31
- * This function will be allowed to modify your Convex database. It will not be accessible from the client.
32
- *
33
- * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
34
- * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
35
- */
36
- export const internalMutation: import("convex/server").MutationBuilder<any, "internal">;
37
- /**
38
- * Define an action in this Convex app's public API.
39
- *
40
- * An action is a function which can execute any JavaScript code, including non-deterministic
41
- * code and code with side-effects, like calling third-party services.
42
- * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
43
- * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
44
- *
45
- * @param func - The action. It receives an {@link ActionCtx} as its first argument.
46
- * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
47
- */
48
- export const action: import("convex/server").ActionBuilder<any, "public">;
49
- /**
50
- * Define an action that is only accessible from other Convex functions (but not from the client).
51
- *
52
- * @param func - The function. It receives an {@link ActionCtx} as its first argument.
53
- * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
54
- */
55
- export const internalAction: import("convex/server").ActionBuilder<any, "internal">;
56
- /**
57
- * Define a Convex HTTP action.
58
- *
59
- * @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object
60
- * as its second.
61
- * @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`.
62
- */
63
- export const httpAction: (func: (ctx: import("convex/server").GenericActionCtx<import("convex/server").GenericDataModel>, request: Request) => Promise<Response>) => import("convex/server").PublicHttpAction;
64
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/component/_generated/server.js"],"names":[],"mappings":"AAqBA;;;;;;;GAOG;AACH,wEAAkC;AAElC;;;;;;;GAOG;AACH,kFAAkD;AAElD;;;;;;;GAOG;AACH,8EAAwC;AAExC;;;;;;;GAOG;AACH,wFAAwD;AAExD;;;;;;;;;;GAUG;AACH,0EAAoC;AAEpC;;;;;GAKG;AACH,oFAAoD;AAEpD;;;;;;GAMG;AACH,8MAA4C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../src/component/_generated/server.js"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAEH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,YAAY,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAExD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAC"}
@@ -1,3 +0,0 @@
1
- declare const _default: import("convex/server").ComponentDefinition<any>;
2
- export default _default;
3
- //# sourceMappingURL=convex.config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../../src/component/convex.config.ts"],"names":[],"mappings":";AAEA,wBAAiD"}
@@ -1,3 +0,0 @@
1
- import { defineComponent } from "convex/server";
2
- export default defineComponent("shardedCounter");
3
- //# sourceMappingURL=convex.config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convex.config.js","sourceRoot":"","sources":["../../../src/component/convex.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAe,eAAe,CAAC,gBAAgB,CAAC,CAAC"}
@@ -1,23 +0,0 @@
1
- export declare const DEFAULT_SHARD_COUNT = 16;
2
- export declare const add: import("convex/server").RegisteredMutation<"public", {
3
- shard?: number | undefined;
4
- shards?: number | undefined;
5
- name: string;
6
- count: number;
7
- }, Promise<number>>;
8
- export declare const count: import("convex/server").RegisteredQuery<"public", {
9
- name: string;
10
- }, Promise<number>>;
11
- export declare const rebalance: import("convex/server").RegisteredMutation<"public", {
12
- shards?: number | undefined;
13
- name: string;
14
- }, Promise<void>>;
15
- export declare const reset: import("convex/server").RegisteredMutation<"public", {
16
- name: string;
17
- }, Promise<void>>;
18
- export declare const estimateCount: import("convex/server").RegisteredQuery<"public", {
19
- shards?: number | undefined;
20
- readFromShards?: number | undefined;
21
- name: string;
22
- }, Promise<number>>;
23
- //# sourceMappingURL=public.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/component/public.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,eAAO,MAAM,GAAG;;;;;mBA6Bd,CAAC;AAEH,eAAO,MAAM,KAAK;;mBAUhB,CAAC;AAEH,eAAO,MAAM,SAAS;;;iBA2BpB,CAAC;AAEH,eAAO,MAAM,KAAK;;iBAWhB,CAAC;AAEH,eAAO,MAAM,aAAa;;;;mBA2BxB,CAAC"}
@@ -1,115 +0,0 @@
1
- import { v } from "convex/values";
2
- import { mutation, query } from "./_generated/server";
3
- export const DEFAULT_SHARD_COUNT = 16;
4
- export const add = mutation({
5
- args: {
6
- name: v.string(),
7
- count: v.number(),
8
- shard: v.optional(v.number()),
9
- shards: v.optional(v.number()),
10
- },
11
- returns: v.number(),
12
- handler: async (ctx, args) => {
13
- const shard = args.shard ??
14
- Math.floor(Math.random() * (args.shards ?? DEFAULT_SHARD_COUNT));
15
- const counter = await ctx.db
16
- .query("counters")
17
- .withIndex("name", (q) => q.eq("name", args.name).eq("shard", shard))
18
- .unique();
19
- if (counter) {
20
- await ctx.db.patch(counter._id, {
21
- value: counter.value + args.count,
22
- });
23
- }
24
- else {
25
- await ctx.db.insert("counters", {
26
- name: args.name,
27
- value: args.count,
28
- shard,
29
- });
30
- }
31
- return shard;
32
- },
33
- });
34
- export const count = query({
35
- args: { name: v.string() },
36
- returns: v.number(),
37
- handler: async (ctx, args) => {
38
- const counters = await ctx.db
39
- .query("counters")
40
- .withIndex("name", (q) => q.eq("name", args.name))
41
- .collect();
42
- return counters.reduce((sum, counter) => sum + counter.value, 0);
43
- },
44
- });
45
- export const rebalance = mutation({
46
- args: { name: v.string(), shards: v.optional(v.number()) },
47
- handler: async (ctx, args) => {
48
- const counters = await ctx.db
49
- .query("counters")
50
- .withIndex("name", (q) => q.eq("name", args.name))
51
- .collect();
52
- const count = counters.reduce((sum, counter) => sum + counter.value, 0);
53
- const shardCount = args.shards ?? DEFAULT_SHARD_COUNT;
54
- const value = count / shardCount;
55
- for (let i = 0; i < shardCount; i++) {
56
- const shard = counters.find((c) => c.shard === i);
57
- if (shard) {
58
- await ctx.db.patch(shard._id, { value });
59
- }
60
- else {
61
- await ctx.db.insert("counters", {
62
- name: args.name,
63
- value,
64
- shard: i,
65
- });
66
- }
67
- }
68
- const toDelete = counters.filter((c) => c.shard >= shardCount);
69
- for (const counter of toDelete) {
70
- await ctx.db.delete(counter._id);
71
- }
72
- },
73
- });
74
- export const reset = mutation({
75
- args: { name: v.string() },
76
- handler: async (ctx, args) => {
77
- await ctx.db
78
- .query("counters")
79
- .withIndex("name", (q) => q.eq("name", args.name))
80
- .collect()
81
- .then((counters) => Promise.all(counters.map((c) => ctx.db.delete(c._id))));
82
- },
83
- });
84
- export const estimateCount = query({
85
- args: {
86
- name: v.string(),
87
- readFromShards: v.optional(v.number()),
88
- shards: v.optional(v.number()),
89
- },
90
- handler: async (ctx, args) => {
91
- const shardCount = args.shards ?? DEFAULT_SHARD_COUNT;
92
- const readFromShards = Math.min(Math.max(1, args.readFromShards ?? 1), shardCount);
93
- const shards = shuffle(Array.from({ length: shardCount }, (_, i) => i)).slice(0, readFromShards);
94
- let readCount = 0;
95
- for (const shard of shards) {
96
- const counter = await ctx.db
97
- .query("counters")
98
- .withIndex("name", (q) => q.eq("name", args.name).eq("shard", shard))
99
- .unique();
100
- if (counter) {
101
- readCount += counter.value;
102
- }
103
- }
104
- return (readCount * shardCount) / readFromShards;
105
- },
106
- });
107
- // Fisher-Yates shuffle
108
- function shuffle(array) {
109
- for (let i = array.length - 1; i > 0; i--) {
110
- const j = Math.floor(Math.random() * (i + 1));
111
- [array[i], array[j]] = [array[j], array[i]];
112
- }
113
- return array;
114
- }
115
- //# sourceMappingURL=public.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"public.js","sourceRoot":"","sources":["../../../src/component/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,MAAM,CAAC,MAAM,GAAG,GAAG,QAAQ,CAAC;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;QACjB,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC7B,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KAC/B;IACD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,KAAK,GACT,IAAI,CAAC,KAAK;YACV,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,mBAAmB,CAAC,CAAC,CAAC;QACnE,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,EAAE;aACzB,KAAK,CAAC,UAAU,CAAC;aACjB,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAA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CAAC;KAC7C;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,15 +0,0 @@
1
- declare const _default: import("convex/server").SchemaDefinition<{
2
- counters: import("convex/server").TableDefinition<import("convex/values").VObject<{
3
- name: string;
4
- value: number;
5
- shard: number;
6
- }, {
7
- name: import("convex/values").VString<string, "required">;
8
- value: import("convex/values").VFloat64<number, "required">;
9
- shard: import("convex/values").VFloat64<number, "required">;
10
- }, "required", "name" | "value" | "shard">, {
11
- name: ["name", "shard", "_creationTime"];
12
- }, {}, {}>;
13
- }, true>;
14
- export default _default;
15
- //# sourceMappingURL=schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAGA,wBAMG"}
@@ -1,10 +0,0 @@
1
- import { defineSchema, defineTable } from "convex/server";
2
- import { v } from "convex/values";
3
- export default defineSchema({
4
- counters: defineTable({
5
- name: v.string(),
6
- value: v.number(),
7
- shard: v.number(),
8
- }).index("name", ["name", "shard"]),
9
- });
10
- //# sourceMappingURL=schema.js.map
@@ -1 +0,0 @@
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;AAElC,eAAe,YAAY,CAAC;IAC1B,QAAQ,EAAE,WAAW,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;QACjB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;KAClB,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
@@ -1,67 +0,0 @@
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 public from "../public.js";
12
-
13
- import type {
14
- ApiFromModules,
15
- FilterApi,
16
- FunctionReference,
17
- } from "convex/server";
18
- /**
19
- * A utility for referencing Convex functions in your app's API.
20
- *
21
- * Usage:
22
- * ```js
23
- * const myFunctionReference = api.myModule.myFunction;
24
- * ```
25
- */
26
- declare const fullApi: ApiFromModules<{
27
- public: typeof public;
28
- }>;
29
- export type Mounts = {
30
- public: {
31
- add: FunctionReference<
32
- "mutation",
33
- "public",
34
- { count: number; name: string; shard?: number; shards?: number },
35
- number
36
- >;
37
- count: FunctionReference<"query", "public", { name: string }, number>;
38
- estimateCount: FunctionReference<
39
- "query",
40
- "public",
41
- { name: string; readFromShards?: number; shards?: number },
42
- any
43
- >;
44
- rebalance: FunctionReference<
45
- "mutation",
46
- "public",
47
- { name: string; shards?: number },
48
- any
49
- >;
50
- reset: FunctionReference<"mutation", "public", { name: string }, any>;
51
- };
52
- };
53
- // For now fullApiWithMounts is only fullApi which provides
54
- // jump-to-definition in component client code.
55
- // Use Mounts for the same type without the inference.
56
- declare const fullApiWithMounts: typeof fullApi;
57
-
58
- export declare const api: FilterApi<
59
- typeof fullApiWithMounts,
60
- FunctionReference<any, "public">
61
- >;
62
- export declare const internal: FilterApi<
63
- typeof fullApiWithMounts,
64
- FunctionReference<any, "internal">
65
- >;
66
-
67
- export declare const components: {};
@@ -1,90 +0,0 @@
1
- /* eslint-disable */
2
- /**
3
- * Generated utilities for implementing server-side Convex query and mutation functions.
4
- *
5
- * THIS CODE IS AUTOMATICALLY GENERATED.
6
- *
7
- * To regenerate, run `npx convex dev`.
8
- * @module
9
- */
10
-
11
- import {
12
- actionGeneric,
13
- httpActionGeneric,
14
- queryGeneric,
15
- mutationGeneric,
16
- internalActionGeneric,
17
- internalMutationGeneric,
18
- internalQueryGeneric,
19
- componentsGeneric,
20
- } from "convex/server";
21
-
22
- /**
23
- * Define a query in this Convex app's public API.
24
- *
25
- * This function will be allowed to read your Convex database and will be accessible from the client.
26
- *
27
- * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
28
- * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
29
- */
30
- export const query = queryGeneric;
31
-
32
- /**
33
- * Define a query that is only accessible from other Convex functions (but not from the client).
34
- *
35
- * This function will be allowed to read from your Convex database. It will not be accessible from the client.
36
- *
37
- * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
38
- * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
39
- */
40
- export const internalQuery = internalQueryGeneric;
41
-
42
- /**
43
- * Define a mutation in this Convex app's public API.
44
- *
45
- * This function will be allowed to modify your Convex database and will be accessible from the client.
46
- *
47
- * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
48
- * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
49
- */
50
- export const mutation = mutationGeneric;
51
-
52
- /**
53
- * Define a mutation that is only accessible from other Convex functions (but not from the client).
54
- *
55
- * This function will be allowed to modify your Convex database. It will not be accessible from the client.
56
- *
57
- * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
58
- * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
59
- */
60
- export const internalMutation = internalMutationGeneric;
61
-
62
- /**
63
- * Define an action in this Convex app's public API.
64
- *
65
- * An action is a function which can execute any JavaScript code, including non-deterministic
66
- * code and code with side-effects, like calling third-party services.
67
- * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
68
- * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
69
- *
70
- * @param func - The action. It receives an {@link ActionCtx} as its first argument.
71
- * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
72
- */
73
- export const action = actionGeneric;
74
-
75
- /**
76
- * Define an action that is only accessible from other Convex functions (but not from the client).
77
- *
78
- * @param func - The function. It receives an {@link ActionCtx} as its first argument.
79
- * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
80
- */
81
- export const internalAction = internalActionGeneric;
82
-
83
- /**
84
- * Define a Convex HTTP action.
85
- *
86
- * @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object
87
- * as its second.
88
- * @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`.
89
- */
90
- export const httpAction = httpActionGeneric;
File without changes