@devwithbobby/loops 0.1.12 → 0.1.14

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 (41) hide show
  1. package/dist/client/index.d.ts +305 -44
  2. package/dist/client/index.d.ts.map +1 -1
  3. package/dist/client/index.js +21 -32
  4. package/dist/component/convex.config.d.ts +1 -1
  5. package/dist/component/convex.config.d.ts.map +1 -1
  6. package/dist/component/convex.config.js +1 -1
  7. package/dist/component/helpers.d.ts +7 -0
  8. package/dist/component/helpers.d.ts.map +1 -0
  9. package/dist/component/helpers.js +30 -0
  10. package/dist/component/http.d.ts +3 -0
  11. package/dist/component/http.d.ts.map +1 -0
  12. package/dist/component/http.js +268 -0
  13. package/dist/component/lib.d.ts +237 -22
  14. package/dist/component/lib.d.ts.map +1 -1
  15. package/dist/component/lib.js +91 -143
  16. package/dist/component/schema.d.ts +66 -1
  17. package/dist/component/schema.d.ts.map +1 -1
  18. package/dist/component/tables/contacts.d.ts +123 -1
  19. package/dist/component/tables/contacts.d.ts.map +1 -1
  20. package/dist/component/tables/emailOperations.d.ts +151 -1
  21. package/dist/component/tables/emailOperations.d.ts.map +1 -1
  22. package/dist/component/tables/emailOperations.js +1 -6
  23. package/dist/component/validators.d.ts +20 -3
  24. package/dist/component/validators.d.ts.map +1 -1
  25. package/dist/types.d.ts +97 -0
  26. package/dist/types.d.ts.map +1 -0
  27. package/dist/types.js +2 -0
  28. package/dist/utils.d.ts +186 -3
  29. package/dist/utils.d.ts.map +1 -1
  30. package/package.json +101 -101
  31. package/src/client/index.ts +40 -52
  32. package/src/component/_generated/api.d.ts +3 -11
  33. package/src/component/convex.config.ts +7 -2
  34. package/src/component/helpers.ts +44 -0
  35. package/src/component/http.ts +304 -0
  36. package/src/component/lib.ts +189 -204
  37. package/src/component/tables/contacts.ts +0 -1
  38. package/src/component/tables/emailOperations.ts +1 -7
  39. package/src/component/validators.ts +0 -1
  40. package/src/types.ts +168 -0
  41. package/src/client/types.ts +0 -64
@@ -13,4 +13,3 @@ export const Contacts = zodTable("contacts", {
13
13
  createdAt: z.number(),
14
14
  updatedAt: z.number(),
15
15
  });
16
-
@@ -2,12 +2,7 @@ import { z } from "zod";
2
2
  import { zodTable } from "zodvex";
3
3
 
4
4
  export const EmailOperations = zodTable("emailOperations", {
5
- operationType: z.enum([
6
- "transactional",
7
- "event",
8
- "campaign",
9
- "loop",
10
- ]),
5
+ operationType: z.enum(["transactional", "event", "campaign", "loop"]),
11
6
  email: z.string().email(),
12
7
  actorId: z.string().optional(),
13
8
  transactionalId: z.string().optional(),
@@ -19,4 +14,3 @@ export const EmailOperations = zodTable("emailOperations", {
19
14
  messageId: z.string().optional(),
20
15
  metadata: z.optional(z.record(z.string(), z.any())),
21
16
  });
22
-
@@ -36,4 +36,3 @@ export const eventValidator = z.object({
36
36
  eventName: z.string(),
37
37
  eventProperties: z.record(z.string(), z.any()).optional(),
38
38
  });
39
-
package/src/types.ts ADDED
@@ -0,0 +1,168 @@
1
+ import type {
2
+ Expand,
3
+ FunctionArgs,
4
+ FunctionReference,
5
+ FunctionReturnType,
6
+ StorageActionWriter,
7
+ StorageReader,
8
+ } from "convex/server";
9
+ import type { GenericId } from "convex/values";
10
+ import { internal } from "./component/_generated/api";
11
+
12
+ export type RunQueryCtx = {
13
+ runQuery: <Query extends FunctionReference<"query", "internal">>(
14
+ query: Query,
15
+ args: FunctionArgs<Query>,
16
+ ) => Promise<FunctionReturnType<Query>>;
17
+ };
18
+
19
+ export type RunMutationCtx = RunQueryCtx & {
20
+ runMutation: <Mutation extends FunctionReference<"mutation", "internal">>(
21
+ mutation: Mutation,
22
+ args: FunctionArgs<Mutation>,
23
+ ) => Promise<FunctionReturnType<Mutation>>;
24
+ };
25
+
26
+ export type RunActionCtx = RunMutationCtx & {
27
+ runAction<Action extends FunctionReference<"action", "internal">>(
28
+ action: Action,
29
+ args: FunctionArgs<Action>,
30
+ ): Promise<FunctionReturnType<Action>>;
31
+ };
32
+
33
+ export type ActionCtx = RunActionCtx & {
34
+ storage: StorageActionWriter;
35
+ };
36
+
37
+ export type QueryCtx = RunQueryCtx & {
38
+ storage: StorageReader;
39
+ };
40
+
41
+ export type OpaqueIds<T> = T extends GenericId<infer _T>
42
+ ? string
43
+ : T extends (infer U)[]
44
+ ? OpaqueIds<U>[]
45
+ : T extends ArrayBuffer
46
+ ? ArrayBuffer
47
+ : T extends object
48
+ ? {
49
+ [K in keyof T]: OpaqueIds<T[K]>;
50
+ }
51
+ : T;
52
+
53
+ export type UseApi<API> = Expand<{
54
+ [mod in keyof API]: API[mod] extends FunctionReference<
55
+ infer FType,
56
+ "public",
57
+ infer FArgs,
58
+ infer FReturnType,
59
+ infer FComponentPath
60
+ >
61
+ ? FunctionReference<
62
+ FType,
63
+ "internal",
64
+ OpaqueIds<FArgs>,
65
+ OpaqueIds<FReturnType>,
66
+ FComponentPath
67
+ >
68
+ : UseApi<API[mod]>;
69
+ }>;
70
+
71
+ export type HeadersInitParam = ConstructorParameters<typeof Headers>[0];
72
+
73
+ export interface ContactPayload {
74
+ email: string;
75
+ firstName?: string;
76
+ lastName?: string;
77
+ userId?: string;
78
+ source?: string;
79
+ subscribed?: boolean;
80
+ userGroup?: string;
81
+ }
82
+
83
+ export interface UpdateContactPayload extends Partial<ContactPayload> {
84
+ email: string;
85
+ dataVariables?: Record<string, unknown>;
86
+ }
87
+
88
+ export interface DeleteContactPayload {
89
+ email?: string;
90
+ }
91
+
92
+ export interface TransactionalPayload {
93
+ transactionalId?: string;
94
+ email?: string;
95
+ dataVariables?: Record<string, unknown>;
96
+ }
97
+
98
+ export interface EventPayload {
99
+ email?: string;
100
+ eventName?: string;
101
+ eventProperties?: Record<string, unknown>;
102
+ }
103
+
104
+ export interface TriggerPayload {
105
+ loopId?: string;
106
+ email?: string;
107
+ dataVariables?: Record<string, unknown>;
108
+ eventName?: string;
109
+ }
110
+
111
+ export type InternalActionRef<
112
+ Args extends Record<string, unknown> = Record<string, unknown>,
113
+ Result = unknown,
114
+ > = FunctionReference<"action", "internal", Args, Result>;
115
+
116
+ export type InternalMutationRef<
117
+ Args extends Record<string, unknown> = Record<string, unknown>,
118
+ Result = unknown,
119
+ > = FunctionReference<"mutation", "internal", Args, Result>;
120
+
121
+ export type InternalQueryRef<
122
+ Args extends Record<string, unknown> = Record<string, unknown>,
123
+ Result = unknown,
124
+ > = FunctionReference<"query", "internal", Args, Result>;
125
+
126
+ type AddContactArgs = {
127
+ apiKey: string;
128
+ contact: ContactPayload;
129
+ };
130
+
131
+ type AddContactResult = {
132
+ success: boolean;
133
+ id?: string;
134
+ };
135
+
136
+ export interface InternalActionLib {
137
+ addContact: InternalActionRef<AddContactArgs, AddContactResult>;
138
+ updateContact: InternalActionRef;
139
+ findContact: InternalActionRef;
140
+ deleteContact: InternalActionRef;
141
+ sendTransactional: InternalActionRef;
142
+ sendEvent: InternalActionRef;
143
+ triggerLoop: InternalActionRef;
144
+ batchCreateContacts: InternalActionRef;
145
+ unsubscribeContact: InternalActionRef;
146
+ resubscribeContact: InternalActionRef;
147
+ storeContact: InternalMutationRef;
148
+ removeContact: InternalMutationRef;
149
+ logEmailOperation: InternalMutationRef;
150
+ }
151
+
152
+ export interface InternalQueryLib {
153
+ countContacts: InternalQueryRef;
154
+ listContacts: InternalQueryRef;
155
+ detectRecipientSpam: InternalQueryRef;
156
+ detectActorSpam: InternalQueryRef;
157
+ getEmailStats: InternalQueryRef;
158
+ detectRapidFirePatterns: InternalQueryRef;
159
+ checkRecipientRateLimit: InternalQueryRef;
160
+ checkActorRateLimit: InternalQueryRef;
161
+ checkGlobalRateLimit: InternalQueryRef;
162
+ }
163
+
164
+ export type InternalLibReferences = InternalActionLib & InternalQueryLib;
165
+
166
+ export const internalLib = (
167
+ internal as unknown as { lib: InternalLibReferences }
168
+ ).lib;
@@ -1,64 +0,0 @@
1
- import type {
2
- Expand,
3
- FunctionArgs,
4
- FunctionReference,
5
- FunctionReturnType,
6
- StorageActionWriter,
7
- StorageReader,
8
- } from "convex/server";
9
- import type { GenericId } from "convex/values";
10
-
11
- export type RunQueryCtx = {
12
- runQuery: <Query extends FunctionReference<"query", "internal">>(
13
- query: Query,
14
- args: FunctionArgs<Query>,
15
- ) => Promise<FunctionReturnType<Query>>;
16
- };
17
- export type RunMutationCtx = RunQueryCtx & {
18
- runMutation: <Mutation extends FunctionReference<"mutation", "internal">>(
19
- mutation: Mutation,
20
- args: FunctionArgs<Mutation>,
21
- ) => Promise<FunctionReturnType<Mutation>>;
22
- };
23
- export type RunActionCtx = RunMutationCtx & {
24
- runAction<Action extends FunctionReference<"action", "internal">>(
25
- action: Action,
26
- args: FunctionArgs<Action>,
27
- ): Promise<FunctionReturnType<Action>>;
28
- };
29
- export type ActionCtx = RunActionCtx & {
30
- storage: StorageActionWriter;
31
- };
32
- export type QueryCtx = RunQueryCtx & {
33
- storage: StorageReader;
34
- };
35
-
36
- export type OpaqueIds<T> = T extends GenericId<infer _T>
37
- ? string
38
- : T extends (infer U)[]
39
- ? OpaqueIds<U>[]
40
- : T extends ArrayBuffer
41
- ? ArrayBuffer
42
- : T extends object
43
- ? {
44
- [K in keyof T]: OpaqueIds<T[K]>;
45
- }
46
- : T;
47
-
48
- export type UseApi<API> = Expand<{
49
- [mod in keyof API]: API[mod] extends FunctionReference<
50
- infer FType,
51
- "public",
52
- infer FArgs,
53
- infer FReturnType,
54
- infer FComponentPath
55
- >
56
- ? FunctionReference<
57
- FType,
58
- "internal",
59
- OpaqueIds<FArgs>,
60
- OpaqueIds<FReturnType>,
61
- FComponentPath
62
- >
63
- : UseApi<API[mod]>;
64
- }>;