@internxt/sdk 1.4.76
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/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/auth/index.d.ts +81 -0
- package/dist/auth/index.js +233 -0
- package/dist/auth/types.d.ts +43 -0
- package/dist/auth/types.js +26 -0
- package/dist/drive/backups/index.d.ts +18 -0
- package/dist/drive/backups/index.js +40 -0
- package/dist/drive/backups/types.d.ts +27 -0
- package/dist/drive/backups/types.js +2 -0
- package/dist/drive/index.d.ts +7 -0
- package/dist/drive/index.js +19 -0
- package/dist/drive/payments/index.d.ts +40 -0
- package/dist/drive/payments/index.js +91 -0
- package/dist/drive/payments/types.d.ts +104 -0
- package/dist/drive/payments/types.js +32 -0
- package/dist/drive/referrals/index.d.ts +19 -0
- package/dist/drive/referrals/index.js +51 -0
- package/dist/drive/referrals/types.d.ts +21 -0
- package/dist/drive/referrals/types.js +18 -0
- package/dist/drive/share/index.d.ts +74 -0
- package/dist/drive/share/index.js +156 -0
- package/dist/drive/share/types.d.ts +78 -0
- package/dist/drive/share/types.js +2 -0
- package/dist/drive/storage/index.d.ts +93 -0
- package/dist/drive/storage/index.js +243 -0
- package/dist/drive/storage/types.d.ts +174 -0
- package/dist/drive/storage/types.js +7 -0
- package/dist/drive/trash/index.d.ts +44 -0
- package/dist/drive/trash/index.js +132 -0
- package/dist/drive/trash/types.d.ts +19 -0
- package/dist/drive/trash/types.js +2 -0
- package/dist/drive/users/index.d.ts +67 -0
- package/dist/drive/users/index.js +123 -0
- package/dist/drive/users/types.d.ts +21 -0
- package/dist/drive/users/types.js +2 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +30 -0
- package/dist/network/download.d.ts +8 -0
- package/dist/network/download.js +123 -0
- package/dist/network/errors/codes.d.ts +24 -0
- package/dist/network/errors/codes.js +48 -0
- package/dist/network/errors/context.d.ts +35 -0
- package/dist/network/errors/context.js +39 -0
- package/dist/network/errors/download.d.ts +4 -0
- package/dist/network/errors/download.js +48 -0
- package/dist/network/errors/index.d.ts +3 -0
- package/dist/network/errors/index.js +15 -0
- package/dist/network/errors/upload.d.ts +13 -0
- package/dist/network/errors/upload.js +78 -0
- package/dist/network/index.d.ts +71 -0
- package/dist/network/index.js +310 -0
- package/dist/network/types.d.ts +102 -0
- package/dist/network/types.js +18 -0
- package/dist/network/upload.d.ts +4 -0
- package/dist/network/upload.js +159 -0
- package/dist/photos/devices/index.d.ts +10 -0
- package/dist/photos/devices/index.js +79 -0
- package/dist/photos/index.d.ts +17 -0
- package/dist/photos/index.js +52 -0
- package/dist/photos/photos/index.d.ts +60 -0
- package/dist/photos/photos/index.js +225 -0
- package/dist/photos/shares/index.d.ts +8 -0
- package/dist/photos/shares/index.js +34 -0
- package/dist/photos/types.d.ts +154 -0
- package/dist/photos/types.js +19 -0
- package/dist/photos/users/index.d.ts +7 -0
- package/dist/photos/users/index.js +46 -0
- package/dist/shared/headers/index.d.ts +45 -0
- package/dist/shared/headers/index.js +71 -0
- package/dist/shared/http/client.d.ts +78 -0
- package/dist/shared/http/client.js +166 -0
- package/dist/shared/http/types.d.ts +7 -0
- package/dist/shared/http/types.js +2 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +13 -0
- package/dist/shared/types/apiConnection.d.ts +12 -0
- package/dist/shared/types/apiConnection.js +2 -0
- package/dist/shared/types/appsumo.d.ts +16 -0
- package/dist/shared/types/appsumo.js +12 -0
- package/dist/shared/types/errors.d.ts +4 -0
- package/dist/shared/types/errors.js +27 -0
- package/dist/shared/types/teams.d.ts +9 -0
- package/dist/shared/types/teams.js +2 -0
- package/dist/shared/types/userSettings.d.ts +27 -0
- package/dist/shared/types/userSettings.js +2 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +25 -0
- package/package.json +53 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var axios_1 = __importDefault(require("axios"));
|
|
18
|
+
var utils_1 = require("../../utils");
|
|
19
|
+
var DevicesSubmodule = /** @class */ (function () {
|
|
20
|
+
function DevicesSubmodule(model) {
|
|
21
|
+
this.model = model;
|
|
22
|
+
}
|
|
23
|
+
DevicesSubmodule.prototype.getDeviceById = function (deviceId) {
|
|
24
|
+
var _this = this;
|
|
25
|
+
return axios_1.default
|
|
26
|
+
.get(this.model.baseUrl + "/devices/" + deviceId, {
|
|
27
|
+
headers: {
|
|
28
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
.then(function (res) { return _this.parse(res.data); })
|
|
32
|
+
.catch(function (err) {
|
|
33
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
DevicesSubmodule.prototype.getDevices = function () {
|
|
37
|
+
var _this = this;
|
|
38
|
+
return axios_1.default
|
|
39
|
+
.get(this.model.baseUrl + "/devices", {
|
|
40
|
+
headers: {
|
|
41
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
.then(function (res) { return res.data.results.map(function (json) { return _this.parse(json); }); })
|
|
45
|
+
.catch(function (err) {
|
|
46
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
DevicesSubmodule.prototype.createDevice = function (data) {
|
|
50
|
+
var _this = this;
|
|
51
|
+
return axios_1.default
|
|
52
|
+
.post(this.model.baseUrl + "/devices", data, {
|
|
53
|
+
headers: {
|
|
54
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
55
|
+
},
|
|
56
|
+
})
|
|
57
|
+
.then(function (res) { return _this.parse(res.data); })
|
|
58
|
+
.catch(function (err) {
|
|
59
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
DevicesSubmodule.prototype.deleteDevice = function (deviceId) {
|
|
63
|
+
return axios_1.default
|
|
64
|
+
.delete(this.model.baseUrl + "/devices/" + deviceId, {
|
|
65
|
+
headers: {
|
|
66
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
.then(function () { return undefined; })
|
|
70
|
+
.catch(function (err) {
|
|
71
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
DevicesSubmodule.prototype.parse = function (json) {
|
|
75
|
+
return __assign(__assign({}, json), { newestDate: new Date(json.newestDate), oldestDate: json.oldestDate === null ? json.oldestDate : new Date(json.oldestDate), createdAt: new Date(json.createdAt), updatedAt: new Date(json.updatedAt) });
|
|
76
|
+
};
|
|
77
|
+
return DevicesSubmodule;
|
|
78
|
+
}());
|
|
79
|
+
exports.default = DevicesSubmodule;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import UsersSubmodule from './users';
|
|
2
|
+
import DevicesSubmodule from './devices';
|
|
3
|
+
import PhotosSubmodule from './photos';
|
|
4
|
+
import SharesSubmodule from './shares';
|
|
5
|
+
export declare class Photos {
|
|
6
|
+
private readonly model;
|
|
7
|
+
readonly users: UsersSubmodule;
|
|
8
|
+
readonly photos: PhotosSubmodule;
|
|
9
|
+
readonly devices: DevicesSubmodule;
|
|
10
|
+
readonly shares: SharesSubmodule;
|
|
11
|
+
constructor(baseUrl: string, accessToken?: string);
|
|
12
|
+
setBaseUrl(baseUrl: string): void;
|
|
13
|
+
setAccessToken(accessToken: string): void;
|
|
14
|
+
get baseUrl(): string | undefined;
|
|
15
|
+
get accessToken(): string | undefined;
|
|
16
|
+
}
|
|
17
|
+
export * from './types';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.Photos = void 0;
|
|
17
|
+
var users_1 = __importDefault(require("./users"));
|
|
18
|
+
var devices_1 = __importDefault(require("./devices"));
|
|
19
|
+
var photos_1 = __importDefault(require("./photos"));
|
|
20
|
+
var shares_1 = __importDefault(require("./shares"));
|
|
21
|
+
var Photos = /** @class */ (function () {
|
|
22
|
+
function Photos(baseUrl, accessToken) {
|
|
23
|
+
this.model = { baseUrl: baseUrl, accessToken: accessToken };
|
|
24
|
+
this.users = new users_1.default(this.model);
|
|
25
|
+
this.photos = new photos_1.default(this.model);
|
|
26
|
+
this.devices = new devices_1.default(this.model);
|
|
27
|
+
this.shares = new shares_1.default(this.model);
|
|
28
|
+
}
|
|
29
|
+
Photos.prototype.setBaseUrl = function (baseUrl) {
|
|
30
|
+
this.model.baseUrl = baseUrl;
|
|
31
|
+
};
|
|
32
|
+
Photos.prototype.setAccessToken = function (accessToken) {
|
|
33
|
+
this.model.accessToken = accessToken;
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(Photos.prototype, "baseUrl", {
|
|
36
|
+
get: function () {
|
|
37
|
+
return this.model.baseUrl;
|
|
38
|
+
},
|
|
39
|
+
enumerable: false,
|
|
40
|
+
configurable: true
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(Photos.prototype, "accessToken", {
|
|
43
|
+
get: function () {
|
|
44
|
+
return this.model.accessToken;
|
|
45
|
+
},
|
|
46
|
+
enumerable: false,
|
|
47
|
+
configurable: true
|
|
48
|
+
});
|
|
49
|
+
return Photos;
|
|
50
|
+
}());
|
|
51
|
+
exports.Photos = Photos;
|
|
52
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { CreatePhotoData, Photo, PhotoId, PhotosSdkModel, PhotoStatus } from '..';
|
|
2
|
+
import { PhotoWithDownloadLink, PhotoExistsPayload, PhotoExistsData, PhotosUsage, UpdatePhotoPayload, PhotosCount, PhotosSortBy } from '../types';
|
|
3
|
+
export default class PhotosSubmodule {
|
|
4
|
+
private model;
|
|
5
|
+
constructor(model: PhotosSdkModel);
|
|
6
|
+
getPhotoById(photoId: PhotoId): Promise<Photo>;
|
|
7
|
+
getPhotosSorted(filter: {
|
|
8
|
+
status?: PhotoStatus;
|
|
9
|
+
updatedAt?: Date;
|
|
10
|
+
}, sort: {
|
|
11
|
+
sortBy: PhotosSortBy;
|
|
12
|
+
sortType: 'ASC' | 'DESC';
|
|
13
|
+
}, skip: number, limit: number, includeDownloadLinks: true): Promise<{
|
|
14
|
+
results: PhotoWithDownloadLink[];
|
|
15
|
+
bucketId: string;
|
|
16
|
+
}>;
|
|
17
|
+
getPhotosSorted(filter: {
|
|
18
|
+
status?: PhotoStatus;
|
|
19
|
+
updatedAt?: Date;
|
|
20
|
+
}, sort: {
|
|
21
|
+
sortBy: PhotosSortBy;
|
|
22
|
+
sortType: 'ASC' | 'DESC';
|
|
23
|
+
}, skip: number, limit: number, includeDownloadLinks: false): Promise<{
|
|
24
|
+
results: Photo[];
|
|
25
|
+
bucketId: string;
|
|
26
|
+
}>;
|
|
27
|
+
getPhotos(filter: {
|
|
28
|
+
name?: string;
|
|
29
|
+
status?: PhotoStatus;
|
|
30
|
+
updatedAt?: Date;
|
|
31
|
+
}, skip: number, limit: number): Promise<{
|
|
32
|
+
results: Photo[];
|
|
33
|
+
bucketId: string;
|
|
34
|
+
}>;
|
|
35
|
+
getPhotos(filter: {
|
|
36
|
+
name?: string;
|
|
37
|
+
status?: PhotoStatus;
|
|
38
|
+
updatedAt?: Date;
|
|
39
|
+
}, skip: number, limit: number, includeDownloadLinks: true): Promise<{
|
|
40
|
+
results: PhotoWithDownloadLink[];
|
|
41
|
+
bucketId: string;
|
|
42
|
+
}>;
|
|
43
|
+
createPhoto(data: CreatePhotoData): Promise<Photo>;
|
|
44
|
+
findOrCreatePhoto(data: CreatePhotoData): Promise<Photo>;
|
|
45
|
+
deletePhotosById(photos: {
|
|
46
|
+
id: PhotoId;
|
|
47
|
+
}[]): Promise<void>;
|
|
48
|
+
deletePhotoById(photoId: PhotoId): Promise<void>;
|
|
49
|
+
trashPhotosById(photos: {
|
|
50
|
+
id: PhotoId;
|
|
51
|
+
}[]): Promise<void>;
|
|
52
|
+
trashPhotoById(photoId: PhotoId): Promise<void>;
|
|
53
|
+
getUsage(): Promise<PhotosUsage>;
|
|
54
|
+
photosExists(photosExistPayload: PhotoExistsPayload[]): Promise<PhotoExistsData[]>;
|
|
55
|
+
updatePhoto(photoId: PhotoId, data: UpdatePhotoPayload): Promise<{
|
|
56
|
+
message: string;
|
|
57
|
+
}>;
|
|
58
|
+
getCount(): Promise<PhotosCount>;
|
|
59
|
+
private parse;
|
|
60
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var axios_1 = __importDefault(require("axios"));
|
|
18
|
+
var query_string_1 = __importDefault(require("query-string"));
|
|
19
|
+
var utils_1 = require("../../utils");
|
|
20
|
+
var PhotosSubmodule = /** @class */ (function () {
|
|
21
|
+
function PhotosSubmodule(model) {
|
|
22
|
+
this.model = model;
|
|
23
|
+
}
|
|
24
|
+
PhotosSubmodule.prototype.getPhotoById = function (photoId) {
|
|
25
|
+
var _this = this;
|
|
26
|
+
return axios_1.default
|
|
27
|
+
.get(this.model.baseUrl + "/photos/" + photoId, {
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
.then(function (res) { return _this.parse(res.data); })
|
|
33
|
+
.catch(function (err) {
|
|
34
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
PhotosSubmodule.prototype.getPhotosSorted = function (filter, sort, skip, limit, includeDownloadLinks) {
|
|
38
|
+
var _this = this;
|
|
39
|
+
var query = query_string_1.default.stringify(__assign(__assign(__assign(__assign({}, filter), { skip: skip, limit: limit }), sort), { includeDownloadLinks: includeDownloadLinks === true }));
|
|
40
|
+
if (skip < 0) {
|
|
41
|
+
throw new Error('Invalid skip. Skip should be positive. Provided skip was: ' + skip);
|
|
42
|
+
}
|
|
43
|
+
return axios_1.default
|
|
44
|
+
.get(this.model.baseUrl + "/photos/sorted?" + query, {
|
|
45
|
+
headers: {
|
|
46
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
.then(function (res) { return ({
|
|
50
|
+
results: res.data.results.map(function (photoJson) { return _this.parse(photoJson); }),
|
|
51
|
+
bucketId: res.data.bucketId,
|
|
52
|
+
}); })
|
|
53
|
+
.catch(function (err) {
|
|
54
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
PhotosSubmodule.prototype.getPhotos = function (filter, skip, limit, includeDownloadLinks) {
|
|
58
|
+
var _this = this;
|
|
59
|
+
if (skip === void 0) { skip = 0; }
|
|
60
|
+
if (limit === void 0) { limit = 1; }
|
|
61
|
+
var query = query_string_1.default.stringify(__assign(__assign({}, filter), { skip: skip, limit: limit, includeDownloadLinks: includeDownloadLinks }));
|
|
62
|
+
if (skip < 0) {
|
|
63
|
+
throw new Error('Invalid skip. Skip should be positive. Provided skip was: ' + skip);
|
|
64
|
+
}
|
|
65
|
+
return axios_1.default
|
|
66
|
+
.get(this.model.baseUrl + "/photos/?" + query, {
|
|
67
|
+
headers: {
|
|
68
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
.then(function (res) { return ({
|
|
72
|
+
results: res.data.results.map(function (photoJson) { return _this.parse(photoJson); }),
|
|
73
|
+
bucketId: res.data.bucketId,
|
|
74
|
+
}); })
|
|
75
|
+
.catch(function (err) {
|
|
76
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
PhotosSubmodule.prototype.createPhoto = function (data) {
|
|
80
|
+
var _this = this;
|
|
81
|
+
return axios_1.default
|
|
82
|
+
.post(this.model.baseUrl + "/photos", data, {
|
|
83
|
+
headers: {
|
|
84
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
.then(function (res) { return _this.parse(res.data); })
|
|
88
|
+
.catch(function (err) {
|
|
89
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
PhotosSubmodule.prototype.findOrCreatePhoto = function (data) {
|
|
93
|
+
var _this = this;
|
|
94
|
+
return axios_1.default
|
|
95
|
+
.post(this.model.baseUrl + "/photos/photo/exists", data, {
|
|
96
|
+
headers: {
|
|
97
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
98
|
+
},
|
|
99
|
+
})
|
|
100
|
+
.then(function (res) { return _this.parse(res.data); })
|
|
101
|
+
.catch(function (err) {
|
|
102
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
PhotosSubmodule.prototype.deletePhotosById = function (photos) {
|
|
106
|
+
return axios_1.default
|
|
107
|
+
.delete(this.model.baseUrl + "/photos/photos", {
|
|
108
|
+
headers: {
|
|
109
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
110
|
+
},
|
|
111
|
+
data: {
|
|
112
|
+
photos: photos,
|
|
113
|
+
},
|
|
114
|
+
})
|
|
115
|
+
.then(function () { return undefined; })
|
|
116
|
+
.catch(function (err) {
|
|
117
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
PhotosSubmodule.prototype.deletePhotoById = function (photoId) {
|
|
121
|
+
return axios_1.default
|
|
122
|
+
.delete(this.model.baseUrl + "/photos/" + photoId, {
|
|
123
|
+
headers: {
|
|
124
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
125
|
+
},
|
|
126
|
+
})
|
|
127
|
+
.then(function () { return undefined; })
|
|
128
|
+
.catch(function (err) {
|
|
129
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
PhotosSubmodule.prototype.trashPhotosById = function (photos) {
|
|
133
|
+
return axios_1.default
|
|
134
|
+
.post(this.model.baseUrl + "/photos/photos/trash", {
|
|
135
|
+
photos: photos,
|
|
136
|
+
}, {
|
|
137
|
+
headers: {
|
|
138
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
139
|
+
},
|
|
140
|
+
})
|
|
141
|
+
.then(function () { return undefined; })
|
|
142
|
+
.catch(function (err) {
|
|
143
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
PhotosSubmodule.prototype.trashPhotoById = function (photoId) {
|
|
147
|
+
return axios_1.default
|
|
148
|
+
.post(this.model.baseUrl + "/photos/" + photoId + "/trash", {}, {
|
|
149
|
+
headers: {
|
|
150
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
151
|
+
},
|
|
152
|
+
})
|
|
153
|
+
.then(function () { return undefined; })
|
|
154
|
+
.catch(function (err) {
|
|
155
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
PhotosSubmodule.prototype.getUsage = function () {
|
|
159
|
+
return axios_1.default
|
|
160
|
+
.get(this.model.baseUrl + "/photos/usage", {
|
|
161
|
+
headers: {
|
|
162
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
163
|
+
},
|
|
164
|
+
})
|
|
165
|
+
.then(function (result) {
|
|
166
|
+
return result.data;
|
|
167
|
+
})
|
|
168
|
+
.catch(function (err) {
|
|
169
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
PhotosSubmodule.prototype.photosExists = function (photosExistPayload) {
|
|
173
|
+
var _this = this;
|
|
174
|
+
return axios_1.default
|
|
175
|
+
.post(this.model.baseUrl + "/photos/exists", { photos: photosExistPayload }, {
|
|
176
|
+
headers: {
|
|
177
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
178
|
+
},
|
|
179
|
+
})
|
|
180
|
+
.then(function (res) {
|
|
181
|
+
return res.data.photos.map(function (result) {
|
|
182
|
+
if ('id' in result) {
|
|
183
|
+
return __assign(__assign({}, _this.parse(result)), { exists: true });
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
return __assign(__assign({}, result), { takenAt: new Date(result.takenAt) });
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
})
|
|
190
|
+
.catch(function (err) {
|
|
191
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
PhotosSubmodule.prototype.updatePhoto = function (photoId, data) {
|
|
195
|
+
return axios_1.default
|
|
196
|
+
.patch(this.model.baseUrl + "/photos/" + photoId, data, {
|
|
197
|
+
headers: {
|
|
198
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
199
|
+
},
|
|
200
|
+
})
|
|
201
|
+
.then(function (result) {
|
|
202
|
+
return result.data;
|
|
203
|
+
})
|
|
204
|
+
.catch(function (err) {
|
|
205
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
PhotosSubmodule.prototype.getCount = function () {
|
|
209
|
+
return axios_1.default
|
|
210
|
+
.get(this.model.baseUrl + "/photos/count", {
|
|
211
|
+
headers: {
|
|
212
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
213
|
+
},
|
|
214
|
+
})
|
|
215
|
+
.then(function (result) { return result.data; })
|
|
216
|
+
.catch(function (err) {
|
|
217
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
PhotosSubmodule.prototype.parse = function (json) {
|
|
221
|
+
return __assign(__assign({}, json), { takenAt: new Date(json.takenAt), statusChangedAt: new Date(json.statusChangedAt), createdAt: new Date(json.createdAt), updatedAt: new Date(json.updatedAt) });
|
|
222
|
+
};
|
|
223
|
+
return PhotosSubmodule;
|
|
224
|
+
}());
|
|
225
|
+
exports.default = PhotosSubmodule;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CreatePhotoShareBody, PhotosSdkModel } from '..';
|
|
2
|
+
import { GetPhotoShareResponse, Share } from '../types';
|
|
3
|
+
export default class SharesSubmodule {
|
|
4
|
+
private model;
|
|
5
|
+
constructor(model: PhotosSdkModel);
|
|
6
|
+
getShare(id: string, code: string): Promise<GetPhotoShareResponse>;
|
|
7
|
+
createShare(body: CreatePhotoShareBody): Promise<Share>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var axios_1 = __importDefault(require("axios"));
|
|
7
|
+
var utils_1 = require("../../utils");
|
|
8
|
+
var SharesSubmodule = /** @class */ (function () {
|
|
9
|
+
function SharesSubmodule(model) {
|
|
10
|
+
this.model = model;
|
|
11
|
+
}
|
|
12
|
+
SharesSubmodule.prototype.getShare = function (id, code) {
|
|
13
|
+
return axios_1.default
|
|
14
|
+
.get(this.model.baseUrl + "/shares/" + id + "?code=" + code)
|
|
15
|
+
.then(function (response) { return response.data; })
|
|
16
|
+
.catch(function (err) {
|
|
17
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
SharesSubmodule.prototype.createShare = function (body) {
|
|
21
|
+
return axios_1.default
|
|
22
|
+
.post(this.model.baseUrl + "/shares", body, {
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: "Bearer " + this.model.accessToken,
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
.then(function (response) { return response.data; })
|
|
28
|
+
.catch(function (err) {
|
|
29
|
+
throw new Error((0, utils_1.extractAxiosErrorMessage)(err));
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
return SharesSubmodule;
|
|
33
|
+
}());
|
|
34
|
+
exports.default = SharesSubmodule;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
export interface PhotosSdkModel {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
accessToken?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare type UserId = string;
|
|
6
|
+
export interface User {
|
|
7
|
+
id: UserId;
|
|
8
|
+
uuid: string;
|
|
9
|
+
bucketId: string;
|
|
10
|
+
createdAt: Date;
|
|
11
|
+
updatedAt: Date;
|
|
12
|
+
}
|
|
13
|
+
export interface UserJSON extends Omit<User, 'createdAt' | 'updatedAt'> {
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
}
|
|
17
|
+
export interface InitializeUserData {
|
|
18
|
+
mac: string;
|
|
19
|
+
name: string;
|
|
20
|
+
bridgeUser: string;
|
|
21
|
+
bridgePassword: string;
|
|
22
|
+
}
|
|
23
|
+
export declare type DeviceId = string;
|
|
24
|
+
export interface Device {
|
|
25
|
+
id: DeviceId;
|
|
26
|
+
mac: string;
|
|
27
|
+
name: string;
|
|
28
|
+
userId: string;
|
|
29
|
+
newestDate: Date;
|
|
30
|
+
oldestDate: Date | null;
|
|
31
|
+
createdAt: Date;
|
|
32
|
+
updatedAt: Date;
|
|
33
|
+
}
|
|
34
|
+
export interface DeviceJSON extends Omit<Device, 'newestDate' | 'oldestDate' | 'createdAt' | 'updatedAt'> {
|
|
35
|
+
newestDate: string;
|
|
36
|
+
oldestDate: string | null;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
updatedAt: string;
|
|
39
|
+
}
|
|
40
|
+
export interface CreateDeviceData {
|
|
41
|
+
mac: string;
|
|
42
|
+
name: string;
|
|
43
|
+
userId: string;
|
|
44
|
+
}
|
|
45
|
+
export declare enum PhotoStatus {
|
|
46
|
+
Exists = "EXISTS",
|
|
47
|
+
Trashed = "TRASHED",
|
|
48
|
+
Deleted = "DELETED"
|
|
49
|
+
}
|
|
50
|
+
export declare enum PhotosSortBy {
|
|
51
|
+
UpdatedAt = "updatedAt",
|
|
52
|
+
TakenAt = "takenAt"
|
|
53
|
+
}
|
|
54
|
+
export declare type FileId = string;
|
|
55
|
+
export declare type PhotoId = string;
|
|
56
|
+
export declare type PhotoPreviewType = 'PNG' | 'JPEG';
|
|
57
|
+
export declare enum PhotosItemType {
|
|
58
|
+
PHOTO = "PHOTO",
|
|
59
|
+
VIDEO = "VIDEO"
|
|
60
|
+
}
|
|
61
|
+
export interface Photo {
|
|
62
|
+
id: PhotoId;
|
|
63
|
+
name: string;
|
|
64
|
+
type: string;
|
|
65
|
+
size: number;
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
fileId: FileId;
|
|
69
|
+
previewId: FileId;
|
|
70
|
+
previews?: {
|
|
71
|
+
width: number;
|
|
72
|
+
height: number;
|
|
73
|
+
size: number;
|
|
74
|
+
fileId: FileId;
|
|
75
|
+
type: PhotoPreviewType;
|
|
76
|
+
}[];
|
|
77
|
+
deviceId: DeviceId;
|
|
78
|
+
userId: string;
|
|
79
|
+
status: PhotoStatus;
|
|
80
|
+
statusChangedAt: Date;
|
|
81
|
+
hash: string;
|
|
82
|
+
takenAt: Date;
|
|
83
|
+
createdAt: Date;
|
|
84
|
+
updatedAt: Date;
|
|
85
|
+
duration?: number;
|
|
86
|
+
itemType: PhotosItemType;
|
|
87
|
+
networkBucketId?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface UpdatePhotoPayload {
|
|
90
|
+
previews?: {
|
|
91
|
+
width: number;
|
|
92
|
+
height: number;
|
|
93
|
+
size: number;
|
|
94
|
+
fileId: FileId;
|
|
95
|
+
type: PhotoPreviewType;
|
|
96
|
+
}[];
|
|
97
|
+
}
|
|
98
|
+
export interface PhotoWithDownloadLink extends Photo {
|
|
99
|
+
previewLink: string;
|
|
100
|
+
previewIndex: string;
|
|
101
|
+
}
|
|
102
|
+
export interface PhotoJSON extends Omit<Photo, 'statusChangedAt' | 'takenAt' | 'createdAt' | 'updatedAt'> {
|
|
103
|
+
statusChangedAt: string;
|
|
104
|
+
takenAt: string;
|
|
105
|
+
createdAt: string;
|
|
106
|
+
updatedAt: string;
|
|
107
|
+
}
|
|
108
|
+
export declare type CreatePhotoData = Omit<Photo, 'id' | 'status' | 'statusChangedAt' | 'createdAt' | 'updatedAt'> & {
|
|
109
|
+
networkBucketId: string;
|
|
110
|
+
};
|
|
111
|
+
export declare type ShareId = string;
|
|
112
|
+
export interface Share {
|
|
113
|
+
id: ShareId;
|
|
114
|
+
bucket: string;
|
|
115
|
+
photoIds: PhotoId[];
|
|
116
|
+
token: string;
|
|
117
|
+
views: number;
|
|
118
|
+
createdAt: Date;
|
|
119
|
+
updatedAt: Date;
|
|
120
|
+
}
|
|
121
|
+
export interface ShareJSON extends Omit<Share, 'createdAt' | 'updatedAt'> {
|
|
122
|
+
createdAt: string;
|
|
123
|
+
updatedAt: string;
|
|
124
|
+
}
|
|
125
|
+
export declare type CreatePhotoShareBody = Pick<Share, 'views' | 'photoIds' | 'bucket' | 'token'> & {
|
|
126
|
+
encryptedMnemonic: string;
|
|
127
|
+
};
|
|
128
|
+
export declare type GetPhotoShareResponse = Share & {
|
|
129
|
+
photos: (Pick<Photo, 'fileId' | 'name' | 'size' | 'type'> & {
|
|
130
|
+
decryptionKey: string;
|
|
131
|
+
})[];
|
|
132
|
+
};
|
|
133
|
+
export declare type PhotoExistsPayload = {
|
|
134
|
+
hash: string;
|
|
135
|
+
name: string;
|
|
136
|
+
takenAt: string;
|
|
137
|
+
};
|
|
138
|
+
export declare type PhotoExistsDataJSON = (PhotoExistsPayload | PhotoJSON) & {
|
|
139
|
+
exists: boolean;
|
|
140
|
+
};
|
|
141
|
+
export declare type PhotoExistsData = ((Omit<PhotoExistsPayload, 'takenAt'> & {
|
|
142
|
+
takenAt: Date;
|
|
143
|
+
}) | Photo) & {
|
|
144
|
+
exists: boolean;
|
|
145
|
+
};
|
|
146
|
+
export declare type PhotosUsage = {
|
|
147
|
+
usage: number;
|
|
148
|
+
};
|
|
149
|
+
export declare type PhotosCount = {
|
|
150
|
+
existent: number;
|
|
151
|
+
trashed: number;
|
|
152
|
+
deleted: number;
|
|
153
|
+
total: number;
|
|
154
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PhotosItemType = exports.PhotosSortBy = exports.PhotoStatus = void 0;
|
|
4
|
+
var PhotoStatus;
|
|
5
|
+
(function (PhotoStatus) {
|
|
6
|
+
PhotoStatus["Exists"] = "EXISTS";
|
|
7
|
+
PhotoStatus["Trashed"] = "TRASHED";
|
|
8
|
+
PhotoStatus["Deleted"] = "DELETED";
|
|
9
|
+
})(PhotoStatus = exports.PhotoStatus || (exports.PhotoStatus = {}));
|
|
10
|
+
var PhotosSortBy;
|
|
11
|
+
(function (PhotosSortBy) {
|
|
12
|
+
PhotosSortBy["UpdatedAt"] = "updatedAt";
|
|
13
|
+
PhotosSortBy["TakenAt"] = "takenAt";
|
|
14
|
+
})(PhotosSortBy = exports.PhotosSortBy || (exports.PhotosSortBy = {}));
|
|
15
|
+
var PhotosItemType;
|
|
16
|
+
(function (PhotosItemType) {
|
|
17
|
+
PhotosItemType["PHOTO"] = "PHOTO";
|
|
18
|
+
PhotosItemType["VIDEO"] = "VIDEO";
|
|
19
|
+
})(PhotosItemType = exports.PhotosItemType || (exports.PhotosItemType = {}));
|