@devwithbobby/loops 0.1.4 → 0.1.5
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 +4 -4
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +22 -0
- package/package.json +1 -1
- package/src/client/index.ts +42 -2
package/dist/client/index.d.ts
CHANGED
|
@@ -21,13 +21,13 @@ export interface EventOptions {
|
|
|
21
21
|
eventProperties?: Record<string, any>;
|
|
22
22
|
}
|
|
23
23
|
export declare class Loops {
|
|
24
|
-
component
|
|
25
|
-
options?: {
|
|
24
|
+
private readonly component;
|
|
25
|
+
readonly options?: {
|
|
26
26
|
apiKey?: string;
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
28
|
constructor(component: LoopsComponent, options?: {
|
|
29
29
|
apiKey?: string;
|
|
30
|
-
}
|
|
30
|
+
});
|
|
31
31
|
private readonly apiKey;
|
|
32
32
|
/**
|
|
33
33
|
* Add or update a contact in Loops
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,yBAAyB;IACzC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GAAG,CAAC,CAAC;QACpC,eAAe,CAAC,EAAE;YACjB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,MAAM,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;KACF;IAQF;;;OAGG;IACG,WAAW,CAChB,GAAG,EAAE,YAAY,EACjB,OAAO,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACpC;IAQF;;;;;;OAMG;IACH,GAAG;;;;;;;;;;;;;;;;;;;;;CA6MH"}
|
package/dist/client/index.js
CHANGED
|
@@ -4,6 +4,17 @@ export class Loops {
|
|
|
4
4
|
component;
|
|
5
5
|
options;
|
|
6
6
|
constructor(component, options) {
|
|
7
|
+
if (!component) {
|
|
8
|
+
throw new Error("Loops component reference is required. " +
|
|
9
|
+
"Make sure the component is mounted in your convex.config.ts and use: " +
|
|
10
|
+
"new Loops(components.loops)");
|
|
11
|
+
}
|
|
12
|
+
if (!component.lib) {
|
|
13
|
+
throw new Error("Invalid component reference. " +
|
|
14
|
+
"The component may not be properly mounted. " +
|
|
15
|
+
"Ensure the component is correctly mounted in convex.config.ts: " +
|
|
16
|
+
"app.use(loops);");
|
|
17
|
+
}
|
|
7
18
|
this.component = component;
|
|
8
19
|
this.options = options;
|
|
9
20
|
const apiKey = options?.apiKey ?? process.env.LOOPS_API_KEY;
|
|
@@ -22,6 +33,17 @@ export class Loops {
|
|
|
22
33
|
* Add or update a contact in Loops
|
|
23
34
|
*/
|
|
24
35
|
async addContact(ctx, contact) {
|
|
36
|
+
if (!this.component) {
|
|
37
|
+
throw new Error("Loops component is not initialized. " +
|
|
38
|
+
"Make sure to pass components.loops to the Loops constructor: " +
|
|
39
|
+
"new Loops(components.loops)");
|
|
40
|
+
}
|
|
41
|
+
if (!this.component.lib) {
|
|
42
|
+
throw new Error("Invalid component reference. " +
|
|
43
|
+
"The component may not be properly mounted. " +
|
|
44
|
+
"Ensure the component is correctly mounted in convex.config.ts: " +
|
|
45
|
+
"app.use(loops);");
|
|
46
|
+
}
|
|
25
47
|
return ctx.runAction(this.component.lib.addContact, {
|
|
26
48
|
apiKey: this.apiKey,
|
|
27
49
|
contact,
|
package/package.json
CHANGED
package/src/client/index.ts
CHANGED
|
@@ -28,12 +28,37 @@ export interface EventOptions {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export class Loops {
|
|
31
|
+
private readonly component: LoopsComponent;
|
|
32
|
+
public readonly options?: {
|
|
33
|
+
apiKey?: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
31
36
|
constructor(
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
component: LoopsComponent,
|
|
38
|
+
options?: {
|
|
34
39
|
apiKey?: string;
|
|
35
40
|
},
|
|
36
41
|
) {
|
|
42
|
+
if (!component) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
"Loops component reference is required. " +
|
|
45
|
+
"Make sure the component is mounted in your convex.config.ts and use: " +
|
|
46
|
+
"new Loops(components.loops)"
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!component.lib) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
"Invalid component reference. " +
|
|
53
|
+
"The component may not be properly mounted. " +
|
|
54
|
+
"Ensure the component is correctly mounted in convex.config.ts: " +
|
|
55
|
+
"app.use(loops);"
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
this.component = component;
|
|
60
|
+
this.options = options;
|
|
61
|
+
|
|
37
62
|
const apiKey = options?.apiKey ?? process.env.LOOPS_API_KEY;
|
|
38
63
|
if (!apiKey) {
|
|
39
64
|
throw new Error(
|
|
@@ -58,6 +83,21 @@ export class Loops {
|
|
|
58
83
|
* Add or update a contact in Loops
|
|
59
84
|
*/
|
|
60
85
|
async addContact(ctx: RunActionCtx, contact: ContactData) {
|
|
86
|
+
if (!this.component) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
"Loops component is not initialized. " +
|
|
89
|
+
"Make sure to pass components.loops to the Loops constructor: " +
|
|
90
|
+
"new Loops(components.loops)"
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (!this.component.lib) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
"Invalid component reference. " +
|
|
96
|
+
"The component may not be properly mounted. " +
|
|
97
|
+
"Ensure the component is correctly mounted in convex.config.ts: " +
|
|
98
|
+
"app.use(loops);"
|
|
99
|
+
);
|
|
100
|
+
}
|
|
61
101
|
return ctx.runAction((this.component.lib as any).addContact, {
|
|
62
102
|
apiKey: this.apiKey,
|
|
63
103
|
contact,
|