@devwithbobby/loops 0.1.19 → 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.
- package/dist/client/index.d.ts +47 -12
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +42 -4
- package/dist/component/_generated/api.d.ts +185 -1
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/component.d.ts +12 -5
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/_generated/dataModel.d.ts +1 -1
- package/dist/component/aggregates.d.ts +42 -0
- package/dist/component/aggregates.d.ts.map +1 -0
- package/dist/component/aggregates.js +54 -0
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/convex.config.js +2 -0
- package/dist/component/helpers.d.ts.map +1 -1
- package/dist/component/http.js +1 -1
- package/dist/component/lib.d.ts +66 -17
- package/dist/component/lib.d.ts.map +1 -1
- package/dist/component/lib.js +194 -73
- package/dist/component/schema.d.ts +2 -2
- package/dist/component/tables/contacts.d.ts.map +1 -1
- package/dist/component/tables/emailOperations.d.ts +4 -4
- package/dist/component/tables/emailOperations.d.ts.map +1 -1
- package/dist/test.d.ts +2 -2
- package/dist/types.d.ts +249 -62
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -2
- package/dist/utils.d.ts +6 -6
- package/package.json +15 -9
- package/src/client/index.ts +52 -6
- package/src/component/_generated/api.ts +190 -1
- package/src/component/_generated/component.ts +10 -5
- package/src/component/_generated/dataModel.ts +1 -1
- package/src/component/aggregates.ts +89 -0
- package/src/component/convex.config.ts +3 -0
- package/src/component/http.ts +1 -1
- package/src/component/lib.ts +226 -89
- package/src/types.ts +20 -122
package/src/types.ts
CHANGED
|
@@ -1,75 +1,28 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
StorageActionWriter,
|
|
7
|
-
StorageReader,
|
|
2
|
+
GenericActionCtx,
|
|
3
|
+
GenericDataModel,
|
|
4
|
+
GenericMutationCtx,
|
|
5
|
+
GenericQueryCtx,
|
|
8
6
|
} from "convex/server";
|
|
9
|
-
import
|
|
10
|
-
import { internal } from "./component/_generated/api";
|
|
7
|
+
import { api } from "./component/_generated/api";
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
query: Query,
|
|
15
|
-
args: FunctionArgs<Query>,
|
|
16
|
-
) => Promise<FunctionReturnType<Query>>;
|
|
17
|
-
};
|
|
9
|
+
// Convenient types for `ctx` args, that only include the bare minimum.
|
|
10
|
+
export type RunQueryCtx = Pick<GenericQueryCtx<GenericDataModel>, "runQuery">;
|
|
18
11
|
|
|
19
|
-
export type RunMutationCtx =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
) => Promise<FunctionReturnType<Mutation>>;
|
|
24
|
-
};
|
|
12
|
+
export type RunMutationCtx = Pick<
|
|
13
|
+
GenericMutationCtx<GenericDataModel>,
|
|
14
|
+
"runQuery" | "runMutation"
|
|
15
|
+
>;
|
|
25
16
|
|
|
26
|
-
export type RunActionCtx =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
}>;
|
|
17
|
+
export type RunActionCtx = Pick<
|
|
18
|
+
GenericActionCtx<GenericDataModel>,
|
|
19
|
+
"runQuery" | "runMutation" | "runAction"
|
|
20
|
+
>;
|
|
70
21
|
|
|
22
|
+
// Type for Headers constructor parameter
|
|
71
23
|
export type HeadersInitParam = ConstructorParameters<typeof Headers>[0];
|
|
72
24
|
|
|
25
|
+
// Payload types for the Loops API
|
|
73
26
|
export interface ContactPayload {
|
|
74
27
|
email: string;
|
|
75
28
|
firstName?: string;
|
|
@@ -108,61 +61,6 @@ export interface TriggerPayload {
|
|
|
108
61
|
eventName?: string;
|
|
109
62
|
}
|
|
110
63
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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;
|
|
64
|
+
// Lib reference for component internals
|
|
65
|
+
// This is used internally by the component to call its own functions
|
|
66
|
+
export const internalLib = api.lib;
|