zudello-integration-sdk 1.0.46 → 1.0.47

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudello-integration-sdk",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "description": "Zudello Integrations SDK",
5
5
  "main": "./src/index.js",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -25,6 +25,8 @@ const EDISDK = require('./sdk/EDI')
25
25
  const SunSystemsSDK = require('./sdk/SunSystems')
26
26
 
27
27
  const AI = require('./utils/ai')
28
+ const FileBucket = require('./utils/fileBucket')
29
+ const EDIBucket = require('./utils/ediBucket')
28
30
  const Logger = require('./utils/logger')
29
31
  const Metadata = require('./utils/metadata')
30
32
  const Message = require('./utils/message')
@@ -57,6 +59,8 @@ const S3Client = {
57
59
  module.exports = {
58
60
  Auth,
59
61
  AI,
62
+ FileBucket,
63
+ EDIBucket,
60
64
  ZudelloSDK,
61
65
  ZudelloAuthSDK,
62
66
  NetsuiteSDK,
@@ -0,0 +1,118 @@
1
+ 'use strict'
2
+
3
+ class Bucket {
4
+ constructor(apiInstance = null, teamUUID = null, type = null) {
5
+ this.apiInstance = apiInstance
6
+ this.teamUUID = teamUUID
7
+ this.type = type
8
+ }
9
+
10
+ async list(path, recursive = false, page = 1, limit = 1000) {
11
+ if (!this._canPerformOperation()) {
12
+ return
13
+ }
14
+
15
+ return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/list`, {
16
+ path,
17
+ recursive,
18
+ page,
19
+ limit
20
+ }, {
21
+ 'x-team': this.teamUUID
22
+ })
23
+ }
24
+
25
+ async get(path, fileName) {
26
+ if (!this._canPerformOperation()) {
27
+ return
28
+ }
29
+
30
+ return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/get`, {
31
+ path,
32
+ fileName
33
+ }, {
34
+ 'x-team': this.teamUUID
35
+ })
36
+ }
37
+
38
+ async getSignedUrl(path, fileName, expiresIn = 300) {
39
+ if (!this._canPerformOperation()) {
40
+ return
41
+ }
42
+
43
+ return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/signed`, {
44
+ path,
45
+ fileName,
46
+ expiresIn
47
+ }, {
48
+ 'x-team': this.teamUUID
49
+ })
50
+ }
51
+
52
+ async create(path, fileName, contents, contentType, overwrite = false) {
53
+ if (!this._canPerformOperation()) {
54
+ return
55
+ }
56
+
57
+ return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/create`, {
58
+ path,
59
+ fileName,
60
+ contents,
61
+ contentType,
62
+ overwrite
63
+ }, {
64
+ 'x-team': this.teamUUID
65
+ })
66
+ }
67
+
68
+ async update(path, fileName, contents, contentType = null) {
69
+ if (!this._canPerformOperation()) {
70
+ return
71
+ }
72
+
73
+ let data = {
74
+ path,
75
+ fileName,
76
+ contents
77
+ }
78
+
79
+ if (contentType) {
80
+ data.contentType = contentType
81
+ }
82
+
83
+ return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/update`, data, {
84
+ 'x-team': this.teamUUID
85
+ })
86
+ }
87
+
88
+ async deleteFolder(path) {
89
+ if (!this._canPerformOperation()) {
90
+ return
91
+ }
92
+
93
+ return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/delete-folder`, {
94
+ path
95
+ }, {
96
+ 'x-team': this.teamUUID
97
+ })
98
+ }
99
+
100
+ async deleteFile(path, fileName) {
101
+ if (!this._canPerformOperation()) {
102
+ return
103
+ }
104
+
105
+ return await this.apiInstance.post(`${process.env.ZUDELLO_API_URL}/s3/${this.type}/delete-file`, {
106
+ path,
107
+ fileName
108
+ }, {
109
+ 'x-team': this.teamUUID
110
+ })
111
+ }
112
+
113
+ _canPerformOperation() {
114
+ return this.apiInstance && this.teamUUID && process.env.ZUDELLO_API_URL && this.type
115
+ }
116
+ }
117
+
118
+ module.exports = Bucket
@@ -0,0 +1,11 @@
1
+ 'use strict'
2
+
3
+ const Bucket = require('./bucket')
4
+
5
+ class EDIBucket extends Bucket {
6
+ constructor(apiInstance = null, teamUUID = null) {
7
+ super(apiInstance, teamUUID, 'edi')
8
+ }
9
+ }
10
+
11
+ module.exports = EDIBucket
@@ -0,0 +1,11 @@
1
+ 'use strict'
2
+
3
+ const Bucket = require('./bucket')
4
+
5
+ class FileBucket extends Bucket {
6
+ constructor(apiInstance = null, teamUUID = null) {
7
+ super(apiInstance, teamUUID, 'file')
8
+ }
9
+ }
10
+
11
+ module.exports = FileBucket