@niama/loops 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 (74) hide show
  1. package/README.md +506 -0
  2. package/dist/client/index.d.ts +510 -0
  3. package/dist/client/index.d.ts.map +1 -0
  4. package/dist/client/index.js +464 -0
  5. package/dist/component/_generated/api.d.ts +232 -0
  6. package/dist/component/_generated/api.d.ts.map +1 -0
  7. package/dist/component/_generated/api.js +30 -0
  8. package/dist/component/_generated/component.d.ts +245 -0
  9. package/dist/component/_generated/component.d.ts.map +1 -0
  10. package/dist/component/_generated/component.js +9 -0
  11. package/dist/component/_generated/dataModel.d.ts +46 -0
  12. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  13. package/dist/component/_generated/dataModel.js +10 -0
  14. package/dist/component/_generated/server.d.ts +121 -0
  15. package/dist/component/_generated/server.d.ts.map +1 -0
  16. package/dist/component/_generated/server.js +77 -0
  17. package/dist/component/actions.d.ts +159 -0
  18. package/dist/component/actions.d.ts.map +1 -0
  19. package/dist/component/actions.js +468 -0
  20. package/dist/component/aggregates.d.ts +42 -0
  21. package/dist/component/aggregates.d.ts.map +1 -0
  22. package/dist/component/aggregates.js +54 -0
  23. package/dist/component/convex.config.d.ts +3 -0
  24. package/dist/component/convex.config.d.ts.map +1 -0
  25. package/dist/component/convex.config.js +5 -0
  26. package/dist/component/helpers.d.ts +16 -0
  27. package/dist/component/helpers.d.ts.map +1 -0
  28. package/dist/component/helpers.js +98 -0
  29. package/dist/component/http.d.ts +3 -0
  30. package/dist/component/http.d.ts.map +1 -0
  31. package/dist/component/http.js +208 -0
  32. package/dist/component/mutations.d.ts +55 -0
  33. package/dist/component/mutations.d.ts.map +1 -0
  34. package/dist/component/mutations.js +167 -0
  35. package/dist/component/queries.d.ts +171 -0
  36. package/dist/component/queries.d.ts.map +1 -0
  37. package/dist/component/queries.js +516 -0
  38. package/dist/component/schema.d.ts +63 -0
  39. package/dist/component/schema.d.ts.map +1 -0
  40. package/dist/component/schema.js +16 -0
  41. package/dist/component/tables/contacts.d.ts +16 -0
  42. package/dist/component/tables/contacts.d.ts.map +1 -0
  43. package/dist/component/tables/contacts.js +16 -0
  44. package/dist/component/tables/emailOperations.d.ts +17 -0
  45. package/dist/component/tables/emailOperations.d.ts.map +1 -0
  46. package/dist/component/tables/emailOperations.js +17 -0
  47. package/dist/component/validators.d.ts +338 -0
  48. package/dist/component/validators.d.ts.map +1 -0
  49. package/dist/component/validators.js +167 -0
  50. package/dist/test.d.ts +78 -0
  51. package/dist/test.d.ts.map +1 -0
  52. package/dist/test.js +16 -0
  53. package/dist/types.d.ts +39 -0
  54. package/dist/types.d.ts.map +1 -0
  55. package/dist/types.js +0 -0
  56. package/package.json +112 -0
  57. package/src/client/index.ts +618 -0
  58. package/src/component/_generated/api.ts +253 -0
  59. package/src/component/_generated/component.ts +291 -0
  60. package/src/component/_generated/dataModel.ts +60 -0
  61. package/src/component/_generated/server.ts +161 -0
  62. package/src/component/actions.ts +556 -0
  63. package/src/component/aggregates.ts +89 -0
  64. package/src/component/convex.config.ts +8 -0
  65. package/src/component/helpers.ts +130 -0
  66. package/src/component/http.ts +236 -0
  67. package/src/component/mutations.ts +192 -0
  68. package/src/component/queries.ts +604 -0
  69. package/src/component/schema.ts +17 -0
  70. package/src/component/tables/contacts.ts +17 -0
  71. package/src/component/tables/emailOperations.ts +23 -0
  72. package/src/component/validators.ts +197 -0
  73. package/src/test.ts +27 -0
  74. package/src/types.ts +62 -0
@@ -0,0 +1,253 @@
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 actions from "../actions.js";
12
+ import type * as aggregates from "../aggregates.js";
13
+ import type * as helpers from "../helpers.js";
14
+ import type * as http from "../http.js";
15
+ import type * as mutations from "../mutations.js";
16
+ import type * as queries from "../queries.js";
17
+ import type * as tables_contacts from "../tables/contacts.js";
18
+ import type * as tables_emailOperations from "../tables/emailOperations.js";
19
+ import type * as validators from "../validators.js";
20
+
21
+ import type {
22
+ ApiFromModules,
23
+ FilterApi,
24
+ FunctionReference,
25
+ } from "convex/server";
26
+ import { anyApi, componentsGeneric } from "convex/server";
27
+
28
+ const fullApi: ApiFromModules<{
29
+ actions: typeof actions;
30
+ aggregates: typeof aggregates;
31
+ helpers: typeof helpers;
32
+ http: typeof http;
33
+ mutations: typeof mutations;
34
+ queries: typeof queries;
35
+ "tables/contacts": typeof tables_contacts;
36
+ "tables/emailOperations": typeof tables_emailOperations;
37
+ validators: typeof validators;
38
+ }> = anyApi as any;
39
+
40
+ /**
41
+ * A utility for referencing Convex functions in your app's public API.
42
+ *
43
+ * Usage:
44
+ * ```js
45
+ * const myFunctionReference = api.myModule.myFunction;
46
+ * ```
47
+ */
48
+ export const api: FilterApi<
49
+ typeof fullApi,
50
+ FunctionReference<any, "public">
51
+ > = anyApi as any;
52
+
53
+ /**
54
+ * A utility for referencing Convex functions in your app's internal API.
55
+ *
56
+ * Usage:
57
+ * ```js
58
+ * const myFunctionReference = internal.myModule.myFunction;
59
+ * ```
60
+ */
61
+ export const internal: FilterApi<
62
+ typeof fullApi,
63
+ FunctionReference<any, "internal">
64
+ > = anyApi as any;
65
+
66
+ export const components = componentsGeneric() as unknown as {
67
+ contactAggregate: {
68
+ btree: {
69
+ aggregateBetween: FunctionReference<
70
+ "query",
71
+ "internal",
72
+ { k1?: any; k2?: any; namespace?: any },
73
+ { count: number; sum: number }
74
+ >;
75
+ aggregateBetweenBatch: FunctionReference<
76
+ "query",
77
+ "internal",
78
+ { queries: Array<{ k1?: any; k2?: any; namespace?: any }> },
79
+ Array<{ count: number; sum: number }>
80
+ >;
81
+ atNegativeOffset: FunctionReference<
82
+ "query",
83
+ "internal",
84
+ { k1?: any; k2?: any; namespace?: any; offset: number },
85
+ { k: any; s: number; v: any }
86
+ >;
87
+ atOffset: FunctionReference<
88
+ "query",
89
+ "internal",
90
+ { k1?: any; k2?: any; namespace?: any; offset: number },
91
+ { k: any; s: number; v: any }
92
+ >;
93
+ atOffsetBatch: FunctionReference<
94
+ "query",
95
+ "internal",
96
+ {
97
+ queries: Array<{
98
+ k1?: any;
99
+ k2?: any;
100
+ namespace?: any;
101
+ offset: number;
102
+ }>;
103
+ },
104
+ Array<{ k: any; s: number; v: any }>
105
+ >;
106
+ get: FunctionReference<
107
+ "query",
108
+ "internal",
109
+ { key: any; namespace?: any },
110
+ null | { k: any; s: number; v: any }
111
+ >;
112
+ offset: FunctionReference<
113
+ "query",
114
+ "internal",
115
+ { k1?: any; key: any; namespace?: any },
116
+ number
117
+ >;
118
+ offsetUntil: FunctionReference<
119
+ "query",
120
+ "internal",
121
+ { k2?: any; key: any; namespace?: any },
122
+ number
123
+ >;
124
+ paginate: FunctionReference<
125
+ "query",
126
+ "internal",
127
+ {
128
+ cursor?: string;
129
+ k1?: any;
130
+ k2?: any;
131
+ limit: number;
132
+ namespace?: any;
133
+ order: "asc" | "desc";
134
+ },
135
+ {
136
+ cursor: string;
137
+ isDone: boolean;
138
+ page: Array<{ k: any; s: number; v: any }>;
139
+ }
140
+ >;
141
+ paginateNamespaces: FunctionReference<
142
+ "query",
143
+ "internal",
144
+ { cursor?: string; limit: number },
145
+ { cursor: string; isDone: boolean; page: Array<any> }
146
+ >;
147
+ validate: FunctionReference<
148
+ "query",
149
+ "internal",
150
+ { namespace?: any },
151
+ any
152
+ >;
153
+ };
154
+ inspect: {
155
+ display: FunctionReference<"query", "internal", { namespace?: any }, any>;
156
+ dump: FunctionReference<"query", "internal", { namespace?: any }, string>;
157
+ inspectNode: FunctionReference<
158
+ "query",
159
+ "internal",
160
+ { namespace?: any; node?: string },
161
+ null
162
+ >;
163
+ listTreeNodes: FunctionReference<
164
+ "query",
165
+ "internal",
166
+ { take?: number },
167
+ Array<{
168
+ _creationTime: number;
169
+ _id: string;
170
+ aggregate?: { count: number; sum: number };
171
+ items: Array<{ k: any; s: number; v: any }>;
172
+ subtrees: Array<string>;
173
+ }>
174
+ >;
175
+ listTrees: FunctionReference<
176
+ "query",
177
+ "internal",
178
+ { take?: number },
179
+ Array<{
180
+ _creationTime: number;
181
+ _id: string;
182
+ maxNodeSize: number;
183
+ namespace?: any;
184
+ root: string;
185
+ }>
186
+ >;
187
+ };
188
+ public: {
189
+ clear: FunctionReference<
190
+ "mutation",
191
+ "internal",
192
+ { maxNodeSize?: number; namespace?: any; rootLazy?: boolean },
193
+ null
194
+ >;
195
+ delete_: FunctionReference<
196
+ "mutation",
197
+ "internal",
198
+ { key: any; namespace?: any },
199
+ null
200
+ >;
201
+ deleteIfExists: FunctionReference<
202
+ "mutation",
203
+ "internal",
204
+ { key: any; namespace?: any },
205
+ any
206
+ >;
207
+ init: FunctionReference<
208
+ "mutation",
209
+ "internal",
210
+ { maxNodeSize?: number; namespace?: any; rootLazy?: boolean },
211
+ null
212
+ >;
213
+ insert: FunctionReference<
214
+ "mutation",
215
+ "internal",
216
+ { key: any; namespace?: any; summand?: number; value: any },
217
+ null
218
+ >;
219
+ makeRootLazy: FunctionReference<
220
+ "mutation",
221
+ "internal",
222
+ { namespace?: any },
223
+ null
224
+ >;
225
+ replace: FunctionReference<
226
+ "mutation",
227
+ "internal",
228
+ {
229
+ currentKey: any;
230
+ namespace?: any;
231
+ newKey: any;
232
+ newNamespace?: any;
233
+ summand?: number;
234
+ value: any;
235
+ },
236
+ null
237
+ >;
238
+ replaceOrInsert: FunctionReference<
239
+ "mutation",
240
+ "internal",
241
+ {
242
+ currentKey: any;
243
+ namespace?: any;
244
+ newKey: any;
245
+ newNamespace?: any;
246
+ summand?: number;
247
+ value: any;
248
+ },
249
+ any
250
+ >;
251
+ };
252
+ };
253
+ };
@@ -0,0 +1,291 @@
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
+ actions: {
27
+ addContact: FunctionReference<
28
+ "action",
29
+ "internal",
30
+ {
31
+ apiKey: string;
32
+ contact: {
33
+ email: string;
34
+ firstName?: string;
35
+ lastName?: string;
36
+ source?: string;
37
+ subscribed?: boolean;
38
+ userGroup?: string;
39
+ userId?: string;
40
+ };
41
+ },
42
+ { id?: string; success: boolean },
43
+ Name
44
+ >;
45
+ batchCreateContacts: FunctionReference<
46
+ "action",
47
+ "internal",
48
+ {
49
+ apiKey: string;
50
+ contacts: Array<{
51
+ email: string;
52
+ firstName?: string;
53
+ lastName?: string;
54
+ source?: string;
55
+ subscribed?: boolean;
56
+ userGroup?: string;
57
+ userId?: string;
58
+ }>;
59
+ },
60
+ {
61
+ created?: number;
62
+ failed?: number;
63
+ results?: Array<{ email: string; error?: string; success: boolean }>;
64
+ success: boolean;
65
+ },
66
+ Name
67
+ >;
68
+ deleteContact: FunctionReference<
69
+ "action",
70
+ "internal",
71
+ { apiKey: string; email: string },
72
+ { success: boolean },
73
+ Name
74
+ >;
75
+ findContact: FunctionReference<
76
+ "action",
77
+ "internal",
78
+ { apiKey: string; email: string },
79
+ {
80
+ contact?: {
81
+ createdAt?: string | null;
82
+ email?: string | null;
83
+ firstName?: string | null;
84
+ id?: string | null;
85
+ lastName?: string | null;
86
+ source?: string | null;
87
+ subscribed?: boolean | null;
88
+ userGroup?: string | null;
89
+ userId?: string | null;
90
+ };
91
+ success: boolean;
92
+ },
93
+ Name
94
+ >;
95
+ resubscribeContact: FunctionReference<
96
+ "action",
97
+ "internal",
98
+ { apiKey: string; email: string },
99
+ { success: boolean },
100
+ Name
101
+ >;
102
+ sendEvent: FunctionReference<
103
+ "action",
104
+ "internal",
105
+ {
106
+ apiKey: string;
107
+ email: string;
108
+ eventName: string;
109
+ eventProperties?: Record<string, any>;
110
+ },
111
+ { success: boolean },
112
+ Name
113
+ >;
114
+ sendTransactional: FunctionReference<
115
+ "action",
116
+ "internal",
117
+ {
118
+ apiKey: string;
119
+ dataVariables?: Record<string, any>;
120
+ email: string;
121
+ transactionalId: string;
122
+ },
123
+ { messageId?: string; success: boolean },
124
+ Name
125
+ >;
126
+ triggerLoop: FunctionReference<
127
+ "action",
128
+ "internal",
129
+ {
130
+ apiKey: string;
131
+ dataVariables?: Record<string, any>;
132
+ email: string;
133
+ eventName?: string;
134
+ loopId: string;
135
+ },
136
+ { success: boolean; warning?: string },
137
+ Name
138
+ >;
139
+ unsubscribeContact: FunctionReference<
140
+ "action",
141
+ "internal",
142
+ { apiKey: string; email: string },
143
+ { success: boolean },
144
+ Name
145
+ >;
146
+ updateContact: FunctionReference<
147
+ "action",
148
+ "internal",
149
+ {
150
+ apiKey: string;
151
+ dataVariables?: Record<string, any>;
152
+ email: string;
153
+ firstName?: string;
154
+ lastName?: string;
155
+ source?: string;
156
+ subscribed?: boolean;
157
+ userGroup?: string;
158
+ userId?: string;
159
+ },
160
+ { success: boolean },
161
+ Name
162
+ >;
163
+ };
164
+ mutations: {
165
+ backfillContactAggregate: FunctionReference<
166
+ "mutation",
167
+ "internal",
168
+ { batchSize?: number; clear?: boolean; cursor?: string | null },
169
+ { cursor: string | null; isDone: boolean; processed: number },
170
+ Name
171
+ >;
172
+ };
173
+ queries: {
174
+ checkActorRateLimit: FunctionReference<
175
+ "query",
176
+ "internal",
177
+ { actorId: string; maxEmails: number; timeWindowMs: number },
178
+ {
179
+ allowed: boolean;
180
+ count: number;
181
+ limit: number;
182
+ retryAfter?: number;
183
+ timeWindowMs: number;
184
+ },
185
+ Name
186
+ >;
187
+ checkGlobalRateLimit: FunctionReference<
188
+ "query",
189
+ "internal",
190
+ { maxEmails: number; timeWindowMs: number },
191
+ {
192
+ allowed: boolean;
193
+ count: number;
194
+ limit: number;
195
+ timeWindowMs: number;
196
+ },
197
+ Name
198
+ >;
199
+ checkRecipientRateLimit: FunctionReference<
200
+ "query",
201
+ "internal",
202
+ { email: string; maxEmails: number; timeWindowMs: number },
203
+ {
204
+ allowed: boolean;
205
+ count: number;
206
+ limit: number;
207
+ retryAfter?: number;
208
+ timeWindowMs: number;
209
+ },
210
+ Name
211
+ >;
212
+ countContacts: FunctionReference<
213
+ "query",
214
+ "internal",
215
+ { source?: string; subscribed?: boolean; userGroup?: string },
216
+ number,
217
+ Name
218
+ >;
219
+ detectActorSpam: FunctionReference<
220
+ "query",
221
+ "internal",
222
+ { maxEmailsPerActor?: number; timeWindowMs?: number },
223
+ Array<{ actorId: string; count: number; timeWindowMs: number }>,
224
+ Name
225
+ >;
226
+ detectRapidFirePatterns: FunctionReference<
227
+ "query",
228
+ "internal",
229
+ { minEmailsInWindow?: number; timeWindowMs?: number },
230
+ Array<{
231
+ actorId?: string;
232
+ count: number;
233
+ email?: string;
234
+ firstTimestamp: number;
235
+ lastTimestamp: number;
236
+ timeWindowMs: number;
237
+ }>,
238
+ Name
239
+ >;
240
+ detectRecipientSpam: FunctionReference<
241
+ "query",
242
+ "internal",
243
+ { maxEmailsPerRecipient?: number; timeWindowMs?: number },
244
+ Array<{ count: number; email: string; timeWindowMs: number }>,
245
+ Name
246
+ >;
247
+ getEmailStats: FunctionReference<
248
+ "query",
249
+ "internal",
250
+ { timeWindowMs?: number },
251
+ {
252
+ failedOperations: number;
253
+ operationsByType: Record<string, number>;
254
+ successfulOperations: number;
255
+ totalOperations: number;
256
+ uniqueActors: number;
257
+ uniqueRecipients: number;
258
+ },
259
+ Name
260
+ >;
261
+ listContacts: FunctionReference<
262
+ "query",
263
+ "internal",
264
+ {
265
+ cursor?: string | null;
266
+ limit?: number;
267
+ source?: string;
268
+ subscribed?: boolean;
269
+ userGroup?: string;
270
+ },
271
+ {
272
+ contacts: Array<{
273
+ _id: string;
274
+ createdAt: number;
275
+ email: string;
276
+ firstName?: string;
277
+ lastName?: string;
278
+ loopsContactId?: string;
279
+ source?: string;
280
+ subscribed: boolean;
281
+ updatedAt: number;
282
+ userGroup?: string;
283
+ userId?: string;
284
+ }>;
285
+ continueCursor: string | null;
286
+ isDone: boolean;
287
+ },
288
+ Name
289
+ >;
290
+ };
291
+ };
@@ -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(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>;