Skip to content

Commit 257afbf

Browse files
committed
update
1 parent 5668b0a commit 257afbf

File tree

91 files changed

+893
-669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+893
-669
lines changed

‎buildDocs.sh‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
docs_dir="./docs"
4+
docs_temp_dir="./documentation"
5+
swap_dir="./temp_swap_dir"
6+
7+
# Function to build and replace 'docs'
8+
build_and_replace_docs() {
9+
# Create the documenation using chatGPT
10+
node mkdocs.js
11+
mkdocs build
12+
rm -r "$docs_dir"
13+
mv "site" "$docs_dir"
14+
}
15+
16+
# Check if '/docs' directory exists and has '.md' files
17+
if [ -d "$docs_dir" ] && [ "$(find "$docs_dir" -name '*.md' | wc -l)" -gt 0 ]; then
18+
# Swap 'docs' and 'docs_temp' directories
19+
mv "$docs_dir" "$swap_dir"
20+
mv "$docs_temp_dir" "$docs_dir"
21+
mv "$swap_dir" "$docs_temp_dir"
22+
echo "Swapped '$docs_dir' and '$docs_temp_dir' directories."
23+
fi
24+
25+
# Build and replace 'docs' regardless of whether a swap happened or not
26+
build_and_replace_docs
File renamed without changes.
File renamed without changes.

‎docs/api/email.md‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# EmailRetriever Documentation
2+
3+
**Description**: The `EmailRetriever` class is designed to fetch emails from specific folders within an email account. It supports multiple email clients and allows for easy email retrieval with support for IMAP search commands. It leverages proprietary Addy AI technology to interact with email servers and facilitates the extraction of email data for use in applications.
4+
5+
### Constructor: `EmailRetriever()`
6+
7+
**Returns**: An instance of the `EmailRetriever` class.
8+
9+
**Description**:
10+
11+
- Initializes an `EmailRetriever` instance with the provided details for email access and retrieval.
12+
- Throws an error if the specified email client is not supported.
13+
14+
**Example**: Instantiate the `EmailRetriever` for a Gmail account with verbose error logging.
15+
16+
```javascript
17+
const retriever = new EmailRetriever(
18+
'your-email@gmail.com',
19+
'your-password',
20+
'gmail',
21+
true
22+
);
23+
```
24+
25+
**Parameters**:
26+
27+
| Parameter Name | Description | Accepted Values/Data Types |
28+
| -------------- | ----------- | --------------------------- |
29+
| emailAddress | The email address of the account to initialize | String |
30+
| emailPassword | The password of the email account | String |
31+
| emailClient | The email client hosting the email address | "gmail" \| "outlook" |
32+
| verbose | Indicates if errors should be printed out | Boolean |
33+
34+
35+
### Method: `getEmailsInFolder()`
36+
37+
**Returns**: A promise that resolves to an array of emails upon successful retrieval or undefined if unsuccessful.
38+
39+
**Description**:
40+
41+
- Fetches emails from a specified folder within the user's email account up to a specified limit.
42+
- If `verbose` is `true`, any errors encountered will be printed to the console.
43+
44+
**Example**: Retrieve the last 10 unseen emails in the Inbox folder.
45+
46+
```javascript
47+
retriever.getEmailsInFolder('Inbox', '10', 'UNSEEN')
48+
.then(emails => {
49+
if (emails) {
50+
console.log('Retrieved Emails:', emails);
51+
} else {
52+
console.log('No emails fetched or an error occurred');
53+
}
54+
})
55+
.catch(error => console.error(error));
56+
```
57+
58+
**Parameters**:
59+
60+
| Parameter Name | Description | Accepted Values/Data Types |
61+
| ------------------ | ----------- | --------------------------- |
62+
| folderName | The name of the folder to scan for emails | String |
63+
| limit | The maximum number of emails to retrieve | String |
64+
| IMAPSearchCommand | The IMAP command to determine which emails to fetch | "ALL" \| "UNSEEN" \| "SEEN" |
65+
66+
67+
---

‎docs/api/firestore.md‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Firestore Documentation
2+
3+
**Description**: The Firestore class provides a variety of methods to interact with documents and collections in Firebase Firestore. It allows you to filter, add, create, update, and delete documents in Firestore collections, including subcollections.
4+
5+
For each method follow this structure:
6+
7+
### Method: `filterCollectionWithWhereClause(collection, filterKey, filterData, operation)`
8+
9+
**Returns**: An array of documents that match the provided filters.
10+
11+
**Description**:
12+
- Filters a collection using a where clause and returns the resulting documents.
13+
- Throws an error if there is an issue retrieving the documents.
14+
15+
**Example**: Using this method in a larger project to retrieve documents from a "users" collection where the "status" equals "active".
16+
```javascript
17+
const userDocs = await firestoreInstance.filterCollectionWithWhereClause(
18+
"users",
19+
"status",
20+
"active",
21+
"=="
22+
);
23+
```
24+
25+
**Parameters**:
26+
27+
| Parameter Name | Description | Accepted Values/Data Types |
28+
| -------------- | ------------------------------------------- | ------------------------------- |
29+
| collection | The name of the collection to be filtered. | String |
30+
| filterKey | The key/field name to filter by. | String |
31+
| filterData | The value to match for the given filterKey. | String |
32+
| operation | The Firestore query operator. | String (Firestore query operators) |
33+
34+
35+
### Method: `addDocumentToCollection(document, collection)`
36+
37+
**Returns**: An object containing the success status and the ID of the document added.
38+
39+
**Description**:
40+
- Adds a new document to the specified collection.
41+
- If an error occurs, it throws an exception with the error details.
42+
43+
**Example**: Adding a new user object to the "users" collection in Firestore.
44+
```javascript
45+
const addResult = await firestoreInstance.addDocumentToCollection(newUser, "users");
46+
if (addResult.success) {
47+
console.log(`Added document with ID: ${addResult.docID}`);
48+
}
49+
```
50+
51+
**Parameters**:
52+
53+
| Parameter Name | Description | Accepted Values/Data Types |
54+
| -------------- | -------------------------------- | -------------------------- |
55+
| document | The data object of the document. | Object |
56+
| collection | The name of the target collection. | String |
57+
58+
(Note: The documentation template above is applied to only the `filterCollectionWithWhereClause` method and `addDocumentToCollection`. Similar formatting would follow for each method defined within the `Firestore` class itself, but due to the length and number of methods, not all methods have been templated here. Each method should get its own section following the given structure.)

‎docs/api/gdrive.md‎

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
```markdown
2+
# Gdrive Documentation
3+
4+
**Description**: Gdrive is a JavaScript class designed for Node.js, intended to simplify interactions with Google Drive API. It allows developers to authenticate access, list directories and files, upload, update, and download files within Google Drive using Google's API.
5+
6+
### Method: `init(config)`
7+
8+
**Returns**: An instance of the Gdrive class.
9+
10+
**Description**:
11+
12+
- Initializes a new instance of the Gdrive class using the provided configuration object.
13+
- Handles errors encountered during the initialization process.
14+
15+
**Example**: How to initialize a Gdrive instance.
16+
17+
```javascript
18+
const Gdrive = require("./Gdrive");
19+
const config = {
20+
verbose: true,
21+
appType: 'server',
22+
client_id: 'your-client-id',
23+
client_secret: 'your-client-secret',
24+
redirect_uri: 'your-redirect-uri',
25+
scopes: 'https://www.googleapis.com/auth/drive',
26+
keyFilePath: 'path-to-keyfile.json'
27+
};
28+
const driveInstance = await Gdrive.init(config);
29+
```
30+
31+
**Parameters**:
32+
33+
| Parameter Name | Description | Accepted Values/Data Types |
34+
|----------------|--------------------------------------------|-------------------------------------|
35+
| config | An object containing the configuration for | Object |
36+
| | Gdrive initialization. | |
37+
38+
### Method: `listFilez()`
39+
40+
**Returns**: Nothing directly, but logs the list of files to the console.
41+
42+
**Description**:
43+
44+
- Lists up to 10 files from the authenticated user's Google Drive.
45+
- Outputs the file names and IDs to the console.
46+
- Handles errors and logs them to the console if listing fails.
47+
48+
**Example**: List files in Google Drive.
49+
50+
```javascript
51+
await driveInstance.listFilez();
52+
```
53+
54+
### Method: `listFiles(props)`
55+
56+
**Returns**: An object with a status code, message, and data containing the list of files.
57+
58+
**Description**:
59+
60+
- Retrieves a list of files from Google Drive based on various filter criteria such as directories, MIME type, and filename.
61+
- Accepts a properties object to further customize the file listing.
62+
- Handles exceptions and returns an error object if the operation fails.
63+
64+
**Example**: Retrieve a specific list of files.
65+
66+
```javascript
67+
const properties = {
68+
directory: 'Documents',
69+
mimeType: 'image/jpeg'
70+
};
71+
const fileList = await driveInstance.listFiles(properties);
72+
```
73+
74+
**Parameters**:
75+
76+
| Parameter Name | Description | Accepted Values/Data Types |
77+
|----------------|----------------------------------------------|----------------------------|
78+
| props | An object containing properties for listing | Object |
79+
| | the files, including directory, MIME type, | |
80+
| | and filename. | |
81+
82+
### Method: `createFile(props)`
83+
84+
**Returns**: An object containing the status, message, and response data with the details of the created file.
85+
86+
**Description**:
87+
88+
- Creates a file in Google Drive with specified properties including filename, MIME type, and contents.
89+
- Accepts a properties object to customize the created file.
90+
- Handles errors and returns an error object if the creation fails.
91+
92+
**Example**: Create a new file in Google Drive.
93+
94+
```javascript
95+
const fileProps = {
96+
filename: 'NewDocument.txt',
97+
mimeType: 'text/plain',
98+
message: 'Hello World'
99+
};
100+
const createdFile = await driveInstance.createFile(fileProps);
101+
```
102+
103+
**Parameters**:
104+
105+
| Parameter Name | Description | Accepted Values/Data Types |
106+
|----------------|------------------------------------------------|----------------------------|
107+
| props | An object containing properties for the file | Object |
108+
| | to be created, such as filename, MIME type, | |
109+
| | and content. | |
110+
111+
### Method: `createAndOrGetContent(props)`
112+
113+
**Returns**: An object containing the status, message, and data with the details of the requested content or the content that was created.
114+
115+
**Description**:
116+
117+
- Creates or retrieves the content specified by the path and MIME type from Google Drive.
118+
- Recursively handles directory creation if not existing and retrieves or creates the final file or folder.
119+
- Returns details of the content including metadata and file data.
120+
- Handles error cases returning structured error responses.
121+
122+
**Example**: Create or get content within a specified path.
123+
124+
```javascript
125+
const contentProps = {
126+
path: '/MyDocuments/Project',
127+
mimeType: 'application/vnd.google-apps.folder'
128+
};
129+
const content = await driveInstance.createAndOrGetContent(contentProps);
130+
```
131+
132+
**Parameters**:
133+
134+
| Parameter Name | Description | Accepted Values/Data Types |
135+
|----------------|----------------------------------------------------|----------------------------|
136+
| props | An object containing properties for the path, MIME | Object |
137+
| | type, and optional message content. | |
138+
139+
### Method: `updateFile(props)`
140+
141+
**Returns**: An object containing the status, message, and response data with the details of the updated file.
142+
143+
**Description**:
144+
145+
- Updates an existing file's content identified by the fileId in Google Drive.
146+
- Accepts a properties object containing fileId, MIME type, and new contents for the file.
147+
- Handles error cases and returns an error object if the update fails.
148+
149+
**Example**: Update an existing file's content.
150+
151+
```javascript
152+
const updateProps = {
153+
fileId: 'file-id',
154+
mimeType: 'text/plain',
155+
message: 'Updated Content'
156+
};
157+
const updatedFile = await driveInstance.updateFile(updateProps);
158+
```
159+
160+
**Parameters**:
161+
162+
| Parameter Name | Description | Accepted Values/Data Types |
163+
|----------------|---------------------------------------------------|----------------------------|
164+
| props | An object containing the fileId, MIME type, and | Object |
165+
| | new content for the file to be updated. | |
166+
167+
### Additional Static Methods:
168+
169+
- `createOAuthServer`: Creates and returns an Express server instance to facilitate OAuth authentication.
170+
- `getAuthUrl(config)`: Creates and returns a Google OAuth URL based on provided parameters.
171+
- `handleAuthCallback(config)`: Handles the OAuth callback to retrieve access tokens.
172+
- `checkAndRefresh(config)`: Checks if an access token has expired and attempts to refresh it.
173+
- `refreshToken(config)`: Refreshes the access token using the stored refresh token and returns the new access token.
174+
175+
Static methods are invoked on the Gdrive class itself and not on instances of the class. They are commonly used for initial OAuth setup, token handling, and to check or refresh access tokens when needed.
176+
177+
---
178+
179+
Navigate through our sections to find comprehensive guides and insights that suit your development needs!
180+
```

0 commit comments

Comments
 (0)