@clonecommand/cloud 0.0.4 → 0.0.7
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/email/index.d.ts +4 -19
- package/dist/email/index.js +5 -67
- package/dist/email/types.d.ts +0 -19
- package/docs/email.md +5 -5
- package/package.json +1 -1
package/dist/email/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CloneCommandCloud } from "..";
|
|
2
|
-
import {
|
|
2
|
+
import { InboundEmail, SendEmailOptions } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Client for interacting with CloneCommand Email services.
|
|
5
5
|
*/
|
|
@@ -7,20 +7,11 @@ export declare class EmailClient {
|
|
|
7
7
|
private ccc;
|
|
8
8
|
constructor(ccc: CloneCommandCloud);
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Checks if the email service is enabled for the current project.
|
|
11
11
|
*
|
|
12
|
-
* @returns A promise resolving to
|
|
13
|
-
* @throws Error if projectId is missing or the API returns an error.
|
|
12
|
+
* @returns A promise resolving to true if enabled, false otherwise.
|
|
14
13
|
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Enables the email service for a specific domain.
|
|
18
|
-
*
|
|
19
|
-
* @param domainId - The ID of the domain to enable email for.
|
|
20
|
-
* @returns A promise resolving to the updated EmailConfig.
|
|
21
|
-
* @throws Error if activation fails.
|
|
22
|
-
*/
|
|
23
|
-
enable(domainId: string): Promise<EmailConfig>;
|
|
14
|
+
isEnabled(): Promise<boolean>;
|
|
24
15
|
/**
|
|
25
16
|
* Sends an email message.
|
|
26
17
|
*
|
|
@@ -67,10 +58,4 @@ export declare class EmailClient {
|
|
|
67
58
|
* @returns A promise resolving to true if successful.
|
|
68
59
|
*/
|
|
69
60
|
delete(emailId: string): Promise<boolean>;
|
|
70
|
-
/**
|
|
71
|
-
* Refreshes the email verification status for the current project.
|
|
72
|
-
*
|
|
73
|
-
* @returns A promise resolving to the status string.
|
|
74
|
-
*/
|
|
75
|
-
refreshEmailVerificationStatus(): Promise<string>;
|
|
76
61
|
}
|
package/dist/email/index.js
CHANGED
|
@@ -7,24 +7,18 @@ export class EmailClient {
|
|
|
7
7
|
this.ccc = ccc;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Checks if the email service is enabled for the current project.
|
|
11
11
|
*
|
|
12
|
-
* @returns A promise resolving to
|
|
13
|
-
* @throws Error if projectId is missing or the API returns an error.
|
|
12
|
+
* @returns A promise resolving to true if enabled, false otherwise.
|
|
14
13
|
*/
|
|
15
|
-
async
|
|
14
|
+
async isEnabled() {
|
|
16
15
|
const pid = this.ccc.projectId;
|
|
17
16
|
if (!pid)
|
|
18
17
|
throw new Error("projectId could not be resolved. Ensure CC_PROJECT_TOKEN is set.");
|
|
19
18
|
const query = `
|
|
20
|
-
query
|
|
19
|
+
query EmailStatus($projectId: ID!) {
|
|
21
20
|
emailConfig(projectId: $projectId) {
|
|
22
|
-
id
|
|
23
|
-
projectId
|
|
24
|
-
domainId
|
|
25
21
|
isEnabled
|
|
26
|
-
sesVerificationStatus
|
|
27
|
-
dkimTokens
|
|
28
22
|
}
|
|
29
23
|
}
|
|
30
24
|
`;
|
|
@@ -38,42 +32,7 @@ export class EmailClient {
|
|
|
38
32
|
});
|
|
39
33
|
if (result.errors)
|
|
40
34
|
throw new Error(result.errors[0].message);
|
|
41
|
-
return result.data.emailConfig;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Enables the email service for a specific domain.
|
|
45
|
-
*
|
|
46
|
-
* @param domainId - The ID of the domain to enable email for.
|
|
47
|
-
* @returns A promise resolving to the updated EmailConfig.
|
|
48
|
-
* @throws Error if activation fails.
|
|
49
|
-
*/
|
|
50
|
-
async enable(domainId) {
|
|
51
|
-
const pid = this.ccc.projectId;
|
|
52
|
-
if (!pid)
|
|
53
|
-
throw new Error("projectId could not be resolved. Ensure CC_PROJECT_TOKEN is set.");
|
|
54
|
-
const query = `
|
|
55
|
-
mutation EnableEmail($projectId: ID!, $domainId: ID!) {
|
|
56
|
-
enableEmail(projectId: $projectId, domainId: $domainId) {
|
|
57
|
-
id
|
|
58
|
-
projectId
|
|
59
|
-
domainId
|
|
60
|
-
isEnabled
|
|
61
|
-
sesVerificationStatus
|
|
62
|
-
dkimTokens
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
`;
|
|
66
|
-
const result = await this.ccc.request('/graphql', {
|
|
67
|
-
method: 'POST',
|
|
68
|
-
headers: { 'Content-Type': 'application/json' },
|
|
69
|
-
body: JSON.stringify({
|
|
70
|
-
query,
|
|
71
|
-
variables: { projectId: pid, domainId }
|
|
72
|
-
})
|
|
73
|
-
});
|
|
74
|
-
if (result.errors)
|
|
75
|
-
throw new Error(result.errors[0].message);
|
|
76
|
-
return result.data.enableEmail;
|
|
35
|
+
return !!result.data.emailConfig?.isEnabled;
|
|
77
36
|
}
|
|
78
37
|
/**
|
|
79
38
|
* Sends an email message.
|
|
@@ -243,25 +202,4 @@ export class EmailClient {
|
|
|
243
202
|
throw new Error(result.errors[0].message);
|
|
244
203
|
return result.data.deleteEmail;
|
|
245
204
|
}
|
|
246
|
-
/**
|
|
247
|
-
* Refreshes the email verification status for the current project.
|
|
248
|
-
*
|
|
249
|
-
* @returns A promise resolving to the status string.
|
|
250
|
-
*/
|
|
251
|
-
async refreshEmailVerificationStatus() {
|
|
252
|
-
const pid = this.ccc.projectId;
|
|
253
|
-
if (!pid)
|
|
254
|
-
throw new Error("projectId could not be resolved. Ensure CC_PROJECT_TOKEN is set.");
|
|
255
|
-
const status = await this.ccc.request('/graphql', {
|
|
256
|
-
method: 'POST',
|
|
257
|
-
headers: { 'Content-Type': 'application/json' },
|
|
258
|
-
body: JSON.stringify({
|
|
259
|
-
query: `mutation RefreshVerification($projectId: ID!) { refreshEmailVerificationStatus(projectId: $projectId) }`,
|
|
260
|
-
variables: { projectId: pid }
|
|
261
|
-
})
|
|
262
|
-
});
|
|
263
|
-
if (status.errors)
|
|
264
|
-
throw new Error(status.errors[0].message);
|
|
265
|
-
return status.data.refreshEmailVerificationStatus;
|
|
266
|
-
}
|
|
267
205
|
}
|
package/dist/email/types.d.ts
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration for the email service.
|
|
3
|
-
*/
|
|
4
|
-
export interface EmailConfig {
|
|
5
|
-
/** Unique ID for the email configuration. */
|
|
6
|
-
id: string;
|
|
7
|
-
/** Project ID this configuration belongs to. */
|
|
8
|
-
projectId: string;
|
|
9
|
-
/** The domain ID associated with this email service. */
|
|
10
|
-
domainId: string;
|
|
11
|
-
/** Whether the email service is currently enabled. */
|
|
12
|
-
isEnabled: boolean;
|
|
13
|
-
/** The Amazon SES Identity ARN. */
|
|
14
|
-
sesIdentityArn?: string;
|
|
15
|
-
/** Current verification status in SES. */
|
|
16
|
-
sesVerificationStatus?: string;
|
|
17
|
-
/** DKIM verification tokens as a JSON string. */
|
|
18
|
-
dkimTokens?: string;
|
|
19
|
-
}
|
|
20
1
|
/**
|
|
21
2
|
* Represents an inbound email received by the system.
|
|
22
3
|
*/
|
package/docs/email.md
CHANGED
|
@@ -10,17 +10,17 @@ Managed email sending and receiving with inbound processing and domain verificat
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
###
|
|
13
|
+
### Checking Status
|
|
14
14
|
|
|
15
|
-
Check if email is enabled for the current project.
|
|
15
|
+
Check if the email service is enabled and ready to use for the current project.
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
import { ccc } from '@clonecommand/cloud';
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const enabled = await ccc.email.isEnabled();
|
|
21
21
|
|
|
22
|
-
if (
|
|
23
|
-
console.log('Email is active!');
|
|
22
|
+
if (enabled) {
|
|
23
|
+
console.log('Email is active and ready to send!');
|
|
24
24
|
}
|
|
25
25
|
```
|
|
26
26
|
|