@devrev/typescript-sdk 1.1.51 → 1.1.53
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/README.md +106 -0
- package/dist/auto-generated/beta/beta-devrev-sdk.d.ts +346 -89
- package/dist/auto-generated/beta/beta-devrev-sdk.js +109 -51
- package/dist/auto-generated/public-devrev-sdk.d.ts +2504 -126
- package/dist/auto-generated/public-devrev-sdk.js +546 -12
- package/dist/snap-ins/beta-devrev-sdk-util.d.ts +9 -0
- package/dist/snap-ins/beta-devrev-sdk-util.js +121 -0
- package/dist/snap-ins/constants/error.d.ts +5 -0
- package/dist/snap-ins/constants/error.js +8 -0
- package/dist/snap-ins/constants/util.d.ts +12 -0
- package/dist/snap-ins/constants/util.js +16 -0
- package/dist/snap-ins/error.d.ts +1 -0
- package/dist/snap-ins/error.js +41 -0
- package/dist/snap-ins/util-types.d.ts +13 -0
- package/dist/snap-ins/util-types.js +2 -0
- package/dist/tests/beta-devrev-sdk-util.test.d.ts +1 -0
- package/dist/tests/beta-devrev-sdk-util.test.js +211 -0
- package/dist/tests/error.test.d.ts +1 -0
- package/dist/tests/error.test.js +118 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,3 +50,109 @@ test()
|
|
|
50
50
|
npm test
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
# Devrev SDK Utils Guide
|
|
54
|
+
|
|
55
|
+
## Basic Setup
|
|
56
|
+
|
|
57
|
+
First, initialize the SDK with your DevRev credentials:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { client } from '@devrev/typescript-sdk';
|
|
61
|
+
import { BetaSdkUtil } from '@devrev/sdk-utils';
|
|
62
|
+
|
|
63
|
+
// Initialize the DevRev SDK
|
|
64
|
+
const devrevSDK = new client.setupBeta({
|
|
65
|
+
// Your DevRev credentials
|
|
66
|
+
endpoint: "https://api.devrev.ai",
|
|
67
|
+
token: "YOUR_TOKEN"
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Initialize the utils SDK
|
|
71
|
+
const sdkUtil = new BetaSdkUtil(devrevSDK);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Core Features
|
|
75
|
+
|
|
76
|
+
### 1. User Management
|
|
77
|
+
|
|
78
|
+
Fetch all Rev users associated with an account:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
const accountId = "ACC-12345";
|
|
82
|
+
const revUsers = await sdkUtil.getAllRevUsersFromAccount(accountId);
|
|
83
|
+
// Returns array of RevUser objects
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 2. File Management
|
|
87
|
+
|
|
88
|
+
#### Upload Files
|
|
89
|
+
```typescript
|
|
90
|
+
import { FileTypes } from '@devrev/sdk-utils';
|
|
91
|
+
|
|
92
|
+
// Prepare file object
|
|
93
|
+
const fileObject = {
|
|
94
|
+
file_name: "example.txt",
|
|
95
|
+
file_type: FileTypes.OTHERS,
|
|
96
|
+
file: Buffer.from("Hello World"),
|
|
97
|
+
custom_file_type: "text/plain" // Required when file_type is OTHERS
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Upload file
|
|
101
|
+
const artifactId = await sdkUtil.uploadFileToArtifact(fileObject);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Retrieve File Content
|
|
105
|
+
```typescript
|
|
106
|
+
const artifactId = "ART-12345";
|
|
107
|
+
const fileContent = await sdkUtil.getFileContentFromArtifact(artifactId);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Error Handling
|
|
111
|
+
|
|
112
|
+
The SDK includes built-in `API` error handling that provides detailed error information:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
try {
|
|
116
|
+
await sdkUtil.uploadFileToArtifact(fileObject);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
// Error will be automatically handled with detailed logging:
|
|
119
|
+
// === Error Details ===
|
|
120
|
+
// Service: [function name]
|
|
121
|
+
// API: [API endpoint]
|
|
122
|
+
// Error Type: [error type]
|
|
123
|
+
// Status Code: [status code]
|
|
124
|
+
// Message: [error message]
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## TypeScript Support
|
|
129
|
+
|
|
130
|
+
The SDK is written in TypeScript and provides comprehensive type definitions for:
|
|
131
|
+
- File management operations
|
|
132
|
+
- User management
|
|
133
|
+
- API Error handling
|
|
134
|
+
|
|
135
|
+
## How to Contribute?
|
|
136
|
+
|
|
137
|
+
1. **Create a New Branch**
|
|
138
|
+
- Start by creating a separate branch for your feature or bug fix.
|
|
139
|
+
|
|
140
|
+
2. **Follow Best Coding Practices**
|
|
141
|
+
- Ensure your code adheres to the following guidelines:
|
|
142
|
+
- Handle potential errors using `try-catch` blocks.
|
|
143
|
+
- Use TypeScript types/interfaces from the SDK for type safety.
|
|
144
|
+
- Check file type requirements before uploading.
|
|
145
|
+
- Utilize built-in API error handling for consistent logging.
|
|
146
|
+
|
|
147
|
+
3. **Enhance `BetaSDKUtil`**
|
|
148
|
+
- Modify the `BetaSDKUtil` class to add new utilities.
|
|
149
|
+
- Write comprehensive test cases to ensure functionality.
|
|
150
|
+
|
|
151
|
+
4. **Run Tests**
|
|
152
|
+
- Execute tests using:
|
|
153
|
+
```
|
|
154
|
+
npm test
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
5. **Submit a Pull Request**
|
|
158
|
+
- Open a pull request with a clear and detailed description of your changes.
|