@replyke/core 7.0.0-beta.29 → 7.0.0-beta.30
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/cjs/hooks/entities/useCreateEntity.d.ts +27 -0
- package/dist/cjs/hooks/entities/useCreateEntity.js +88 -15
- package/dist/cjs/hooks/entities/useCreateEntity.js.map +1 -1
- package/dist/cjs/hooks/storage/index.d.ts +1 -0
- package/dist/cjs/hooks/storage/index.js +3 -1
- package/dist/cjs/hooks/storage/index.js.map +1 -1
- package/dist/cjs/hooks/storage/useUploadFile.d.ts +12 -1
- package/dist/cjs/hooks/storage/useUploadFile.js +22 -8
- package/dist/cjs/hooks/storage/useUploadFile.js.map +1 -1
- package/dist/cjs/hooks/storage/useUploadImage.d.ts +14 -0
- package/dist/cjs/hooks/storage/useUploadImage.js +161 -0
- package/dist/cjs/hooks/storage/useUploadImage.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/models/Entity.d.ts +40 -1
- package/dist/cjs/interfaces/models/Image.d.ts +35 -0
- package/dist/cjs/interfaces/models/Image.js +3 -0
- package/dist/cjs/interfaces/models/Image.js.map +1 -0
- package/dist/cjs/store/slices/entityListsSlice.d.ts +480 -0
- package/dist/esm/hooks/entities/useCreateEntity.d.ts +27 -0
- package/dist/esm/hooks/entities/useCreateEntity.js +88 -15
- package/dist/esm/hooks/entities/useCreateEntity.js.map +1 -1
- package/dist/esm/hooks/storage/index.d.ts +1 -0
- package/dist/esm/hooks/storage/index.js +1 -0
- package/dist/esm/hooks/storage/index.js.map +1 -1
- package/dist/esm/hooks/storage/useUploadFile.d.ts +12 -1
- package/dist/esm/hooks/storage/useUploadFile.js +22 -8
- package/dist/esm/hooks/storage/useUploadFile.js.map +1 -1
- package/dist/esm/hooks/storage/useUploadImage.d.ts +14 -0
- package/dist/esm/hooks/storage/useUploadImage.js +156 -0
- package/dist/esm/hooks/storage/useUploadImage.js.map +1 -0
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/models/Entity.d.ts +40 -1
- package/dist/esm/interfaces/models/Image.d.ts +35 -0
- package/dist/esm/interfaces/models/Image.js +2 -0
- package/dist/esm/interfaces/models/Image.js.map +1 -0
- package/dist/esm/store/slices/entityListsSlice.d.ts +480 -0
- package/package.json +1 -1
|
@@ -37,35 +37,108 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
import { useCallback } from "react";
|
|
38
38
|
import useAxiosPrivate from "../../config/useAxiosPrivate";
|
|
39
39
|
import useProject from "../projects/useProject";
|
|
40
|
+
function isBrowserFile(file) {
|
|
41
|
+
return typeof File !== "undefined" && file instanceof File;
|
|
42
|
+
}
|
|
40
43
|
function useCreateEntity() {
|
|
41
44
|
var _this = this;
|
|
42
45
|
var axios = useAxiosPrivate();
|
|
43
46
|
var projectId = useProject().projectId;
|
|
44
47
|
var createEntity = useCallback(function (props) { return __awaiter(_this, void 0, void 0, function () {
|
|
45
|
-
var foreignId, sourceId, spaceId, title, content, attachments, keywords, mentions, location, metadata, excludeUserId, response;
|
|
48
|
+
var foreignId, sourceId, spaceId, title, content, attachments, keywords, mentions, location, metadata, excludeUserId, images, files, hasImages, hasFiles, formData_1, response, response;
|
|
46
49
|
return __generator(this, function (_a) {
|
|
47
50
|
switch (_a.label) {
|
|
48
51
|
case 0:
|
|
49
|
-
foreignId = props.foreignId, sourceId = props.sourceId, spaceId = props.spaceId, title = props.title, content = props.content, attachments = props.attachments, keywords = props.keywords, mentions = props.mentions, location = props.location, metadata = props.metadata, excludeUserId = props.excludeUserId;
|
|
52
|
+
foreignId = props.foreignId, sourceId = props.sourceId, spaceId = props.spaceId, title = props.title, content = props.content, attachments = props.attachments, keywords = props.keywords, mentions = props.mentions, location = props.location, metadata = props.metadata, excludeUserId = props.excludeUserId, images = props.images, files = props.files;
|
|
50
53
|
if (!projectId) {
|
|
51
54
|
throw new Error("No projectId available.");
|
|
52
55
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
hasImages = images && images.files.length > 0;
|
|
57
|
+
hasFiles = files && files.files.length > 0;
|
|
58
|
+
if (!(hasImages || hasFiles)) return [3 /*break*/, 2];
|
|
59
|
+
formData_1 = new FormData();
|
|
60
|
+
// Append standard entity fields
|
|
61
|
+
if (foreignId !== undefined)
|
|
62
|
+
formData_1.append("foreignId", foreignId);
|
|
63
|
+
if (sourceId !== undefined)
|
|
64
|
+
formData_1.append("sourceId", sourceId);
|
|
65
|
+
if (spaceId !== undefined)
|
|
66
|
+
formData_1.append("spaceId", spaceId);
|
|
67
|
+
if (title !== undefined)
|
|
68
|
+
formData_1.append("title", title);
|
|
69
|
+
if (content !== undefined)
|
|
70
|
+
formData_1.append("content", content);
|
|
71
|
+
if (attachments !== undefined)
|
|
72
|
+
formData_1.append("attachments", JSON.stringify(attachments));
|
|
73
|
+
if (keywords !== undefined)
|
|
74
|
+
formData_1.append("keywords", JSON.stringify(keywords));
|
|
75
|
+
if (mentions !== undefined)
|
|
76
|
+
formData_1.append("mentions", JSON.stringify(mentions));
|
|
77
|
+
if (location !== undefined)
|
|
78
|
+
formData_1.append("location", JSON.stringify(location));
|
|
79
|
+
if (metadata !== undefined)
|
|
80
|
+
formData_1.append("metadata", JSON.stringify(metadata));
|
|
81
|
+
if (excludeUserId !== undefined)
|
|
82
|
+
formData_1.append("excludeUserId", excludeUserId.toString());
|
|
83
|
+
// Append images
|
|
84
|
+
if (hasImages) {
|
|
85
|
+
images.files.forEach(function (file) {
|
|
86
|
+
if (isBrowserFile(file)) {
|
|
87
|
+
formData_1.append("images.files", file, file.name);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
formData_1.append("images.files", {
|
|
91
|
+
uri: file.uri,
|
|
92
|
+
type: file.type || "image/jpeg",
|
|
93
|
+
name: file.name,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
if (images.options) {
|
|
98
|
+
formData_1.append("images.options", JSON.stringify(images.options));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Append files
|
|
102
|
+
if (hasFiles) {
|
|
103
|
+
files.files.forEach(function (file) {
|
|
104
|
+
if (isBrowserFile(file)) {
|
|
105
|
+
formData_1.append("files.files", file, file.name);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
formData_1.append("files.files", {
|
|
109
|
+
uri: file.uri,
|
|
110
|
+
type: file.type || "application/octet-stream",
|
|
111
|
+
name: file.name,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
if (files.options) {
|
|
116
|
+
formData_1.append("files.options", JSON.stringify(files.options));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return [4 /*yield*/, axios.post("/".concat(projectId, "/entities"), formData_1, {
|
|
120
|
+
headers: { "Content-Type": "multipart/form-data" },
|
|
121
|
+
withCredentials: true,
|
|
122
|
+
})];
|
|
66
123
|
case 1:
|
|
67
124
|
response = _a.sent();
|
|
68
125
|
return [2 /*return*/, response.data];
|
|
126
|
+
case 2: return [4 /*yield*/, axios.post("/".concat(projectId, "/entities"), {
|
|
127
|
+
foreignId: foreignId,
|
|
128
|
+
sourceId: sourceId,
|
|
129
|
+
spaceId: spaceId,
|
|
130
|
+
title: title,
|
|
131
|
+
content: content,
|
|
132
|
+
attachments: attachments,
|
|
133
|
+
keywords: keywords,
|
|
134
|
+
mentions: mentions,
|
|
135
|
+
location: location,
|
|
136
|
+
metadata: metadata,
|
|
137
|
+
excludeUserId: excludeUserId,
|
|
138
|
+
}, { withCredentials: true })];
|
|
139
|
+
case 3:
|
|
140
|
+
response = _a.sent();
|
|
141
|
+
return [2 /*return*/, response.data];
|
|
69
142
|
}
|
|
70
143
|
});
|
|
71
144
|
}); }, [projectId, axios]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateEntity.js","sourceRoot":"","sources":["../../../../src/hooks/entities/useCreateEntity.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,OAAO,UAAU,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"useCreateEntity.js","sourceRoot":"","sources":["../../../../src/hooks/entities/useCreateEntity.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAShD,SAAS,aAAa,CAAC,IAAmB;IACxC,OAAO,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,IAAI,CAAC;AAC7D,CAAC;AAuBD,SAAS,eAAe;IAAxB,iBA+IC;IA9IC,IAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IACxB,IAAA,SAAS,GAAK,UAAU,EAAE,UAAjB,CAAkB;IAEnC,IAAM,YAAY,GAAG,WAAW,CAC9B,UAAO,KAoBN;;;;;oBAEG,SAAS,GAaP,KAAK,UAbE,EACT,QAAQ,GAYN,KAAK,SAZC,EACR,OAAO,GAWL,KAAK,QAXA,EACP,KAAK,GAUH,KAAK,MAVF,EACL,OAAO,GASL,KAAK,QATA,EACP,WAAW,GAQT,KAAK,YARI,EACX,QAAQ,GAON,KAAK,SAPC,EACR,QAAQ,GAMN,KAAK,SANC,EACR,QAAQ,GAKN,KAAK,SALC,EACR,QAAQ,GAIN,KAAK,SAJC,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,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -5,10 +5,21 @@ type RNFile = {
|
|
|
5
5
|
type?: string;
|
|
6
6
|
};
|
|
7
7
|
type UniversalFile = BrowserFile | RNFile;
|
|
8
|
+
type UploadFileOptions = {
|
|
9
|
+
entityId?: string;
|
|
10
|
+
commentId?: string;
|
|
11
|
+
spaceId?: string;
|
|
12
|
+
position?: number;
|
|
13
|
+
metadata?: Record<string, any>;
|
|
14
|
+
};
|
|
8
15
|
type UploadResponse = {
|
|
9
16
|
fileId: string;
|
|
17
|
+
type: "image" | "video" | "document" | "other";
|
|
10
18
|
relativePath: string;
|
|
11
19
|
publicPath: string;
|
|
20
|
+
size: number;
|
|
21
|
+
mimeType: string;
|
|
22
|
+
createdAt: string;
|
|
12
23
|
};
|
|
13
|
-
declare function useUploadFile(): (file: UniversalFile, pathParts: string[]) => Promise<UploadResponse
|
|
24
|
+
declare function useUploadFile(): (file: UniversalFile, pathParts: string[], options?: UploadFileOptions) => Promise<UploadResponse>;
|
|
14
25
|
export default useUploadFile;
|
|
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
import { useCallback } from "react";
|
|
38
38
|
import useAxiosPrivate from "../../config/useAxiosPrivate";
|
|
39
39
|
import useProject from "../projects/useProject";
|
|
40
|
-
// Type guard to detect if it
|
|
40
|
+
// Type guard to detect if it's a real browser File
|
|
41
41
|
function isBrowserFile(file) {
|
|
42
42
|
return typeof File !== "undefined" && file instanceof File;
|
|
43
43
|
}
|
|
@@ -45,7 +45,7 @@ function useUploadFile() {
|
|
|
45
45
|
var _this = this;
|
|
46
46
|
var axios = useAxiosPrivate();
|
|
47
47
|
var projectId = useProject().projectId;
|
|
48
|
-
var uploadFile = useCallback(function (file, pathParts) { return __awaiter(_this, void 0, void 0, function () {
|
|
48
|
+
var uploadFile = useCallback(function (file, pathParts, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
49
49
|
var formData, response;
|
|
50
50
|
return __generator(this, function (_a) {
|
|
51
51
|
switch (_a.label) {
|
|
@@ -57,21 +57,35 @@ function useUploadFile() {
|
|
|
57
57
|
throw new Error("Invalid arguments. File and pathParts are required.");
|
|
58
58
|
}
|
|
59
59
|
formData = new FormData();
|
|
60
|
-
//
|
|
60
|
+
// Append file (browser or React Native)
|
|
61
61
|
if (isBrowserFile(file)) {
|
|
62
|
-
// We are dealing with a real browser File
|
|
63
62
|
formData.append("file", file, file.name);
|
|
64
63
|
}
|
|
65
64
|
else {
|
|
66
|
-
// We assume it’s a React Native { uri, type, name } shape
|
|
67
65
|
formData.append("file", {
|
|
68
66
|
uri: file.uri,
|
|
69
67
|
type: file.type || "application/octet-stream",
|
|
70
68
|
name: file.name,
|
|
71
|
-
});
|
|
69
|
+
});
|
|
72
70
|
}
|
|
73
|
-
//
|
|
71
|
+
// Append pathParts
|
|
74
72
|
formData.append("pathParts", JSON.stringify(pathParts));
|
|
73
|
+
// Append optional associations
|
|
74
|
+
if (options === null || options === void 0 ? void 0 : options.entityId) {
|
|
75
|
+
formData.append("entityId", options.entityId);
|
|
76
|
+
}
|
|
77
|
+
if (options === null || options === void 0 ? void 0 : options.commentId) {
|
|
78
|
+
formData.append("commentId", options.commentId);
|
|
79
|
+
}
|
|
80
|
+
if (options === null || options === void 0 ? void 0 : options.spaceId) {
|
|
81
|
+
formData.append("spaceId", options.spaceId);
|
|
82
|
+
}
|
|
83
|
+
if ((options === null || options === void 0 ? void 0 : options.position) !== undefined) {
|
|
84
|
+
formData.append("position", options.position.toString());
|
|
85
|
+
}
|
|
86
|
+
if (options === null || options === void 0 ? void 0 : options.metadata) {
|
|
87
|
+
formData.append("metadata", JSON.stringify(options.metadata));
|
|
88
|
+
}
|
|
75
89
|
return [4 /*yield*/, axios.post("/".concat(projectId, "/storage"), formData, {
|
|
76
90
|
headers: {
|
|
77
91
|
"Content-Type": "multipart/form-data",
|
|
@@ -80,7 +94,7 @@ function useUploadFile() {
|
|
|
80
94
|
})];
|
|
81
95
|
case 1:
|
|
82
96
|
response = _a.sent();
|
|
83
|
-
return [2 /*return*/, response.data];
|
|
97
|
+
return [2 /*return*/, response.data];
|
|
84
98
|
}
|
|
85
99
|
});
|
|
86
100
|
}); }, [projectId, axios]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUploadFile.js","sourceRoot":"","sources":["../../../../src/hooks/storage/useUploadFile.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD,mDAAmD;AACnD,SAAS,aAAa,CAAC,IAAmB;IACxC,OAAO,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,IAAI,CAAC;AAC7D,CAAC;
|
|
1
|
+
{"version":3,"file":"useUploadFile.js","sourceRoot":"","sources":["../../../../src/hooks/storage/useUploadFile.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,UAAU,MAAM,wBAAwB,CAAC;AA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;
|
|
3
|
+
type RNFile = {
|
|
4
|
+
uri: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
};
|
|
8
|
+
type UniversalFile = BrowserFile | RNFile;
|
|
9
|
+
declare function useUploadImage(): {
|
|
10
|
+
uploadImage: (file: UniversalFile, options?: UploadImageOptions) => Promise<Image>;
|
|
11
|
+
uploading: boolean;
|
|
12
|
+
progress: number;
|
|
13
|
+
};
|
|
14
|
+
export default useUploadImage;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
46
|
+
import { useCallback, useState } from "react";
|
|
47
|
+
import useAxiosPrivate from "../../config/useAxiosPrivate";
|
|
48
|
+
import useProject from "../projects/useProject";
|
|
49
|
+
// Type guard to detect browser File vs React Native file object
|
|
50
|
+
function isBrowserFile(file) {
|
|
51
|
+
return typeof File !== "undefined" && file instanceof File;
|
|
52
|
+
}
|
|
53
|
+
function useUploadImage() {
|
|
54
|
+
var _this = this;
|
|
55
|
+
var axios = useAxiosPrivate();
|
|
56
|
+
var projectId = useProject().projectId;
|
|
57
|
+
var _a = useState(false), uploading = _a[0], setUploading = _a[1];
|
|
58
|
+
var _b = useState(0), progress = _b[0], setProgress = _b[1];
|
|
59
|
+
var uploadImage = useCallback(function (file_1) {
|
|
60
|
+
var args_1 = [];
|
|
61
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
62
|
+
args_1[_i - 1] = arguments[_i];
|
|
63
|
+
}
|
|
64
|
+
return __awaiter(_this, __spreadArray([file_1], args_1, true), void 0, function (file, options) {
|
|
65
|
+
var formData, response;
|
|
66
|
+
if (options === void 0) { options = {}; }
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
switch (_a.label) {
|
|
69
|
+
case 0:
|
|
70
|
+
// Validate required inputs
|
|
71
|
+
if (!projectId) {
|
|
72
|
+
throw new Error("No projectId available.");
|
|
73
|
+
}
|
|
74
|
+
if (!file) {
|
|
75
|
+
throw new Error("No file provided.");
|
|
76
|
+
}
|
|
77
|
+
setUploading(true);
|
|
78
|
+
setProgress(0);
|
|
79
|
+
_a.label = 1;
|
|
80
|
+
case 1:
|
|
81
|
+
_a.trys.push([1, , 3, 4]);
|
|
82
|
+
formData = new FormData();
|
|
83
|
+
// Append file (handle both browser and React Native)
|
|
84
|
+
if (isBrowserFile(file)) {
|
|
85
|
+
formData.append("file", file, file.name);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
formData.append("file", {
|
|
89
|
+
uri: file.uri,
|
|
90
|
+
type: file.type || "image/jpeg",
|
|
91
|
+
name: file.name,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
// Append all optional configuration fields
|
|
95
|
+
if (options.pathParts) {
|
|
96
|
+
formData.append("pathParts", JSON.stringify(options.pathParts));
|
|
97
|
+
}
|
|
98
|
+
if (options.sizes) {
|
|
99
|
+
formData.append("sizes", JSON.stringify(options.sizes));
|
|
100
|
+
}
|
|
101
|
+
if (options.quality !== undefined) {
|
|
102
|
+
formData.append("quality", options.quality.toString());
|
|
103
|
+
}
|
|
104
|
+
if (options.format) {
|
|
105
|
+
formData.append("format", options.format);
|
|
106
|
+
}
|
|
107
|
+
if (options.stripExif !== undefined) {
|
|
108
|
+
formData.append("stripExif", options.stripExif.toString());
|
|
109
|
+
}
|
|
110
|
+
if (options.fit) {
|
|
111
|
+
formData.append("fit", options.fit);
|
|
112
|
+
}
|
|
113
|
+
// Append optional associations
|
|
114
|
+
if (options.entityId) {
|
|
115
|
+
formData.append("entityId", options.entityId);
|
|
116
|
+
}
|
|
117
|
+
if (options.commentId) {
|
|
118
|
+
formData.append("commentId", options.commentId);
|
|
119
|
+
}
|
|
120
|
+
if (options.spaceId) {
|
|
121
|
+
formData.append("spaceId", options.spaceId);
|
|
122
|
+
}
|
|
123
|
+
return [4 /*yield*/, axios.post("/".concat(projectId, "/storage/images"), formData, {
|
|
124
|
+
headers: {
|
|
125
|
+
"Content-Type": "multipart/form-data",
|
|
126
|
+
},
|
|
127
|
+
withCredentials: true,
|
|
128
|
+
onUploadProgress: function (progressEvent) {
|
|
129
|
+
var _a;
|
|
130
|
+
if (progressEvent.total) {
|
|
131
|
+
var percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
|
132
|
+
setProgress(percentCompleted);
|
|
133
|
+
(_a = options.onProgress) === null || _a === void 0 ? void 0 : _a.call(options, percentCompleted);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
})];
|
|
137
|
+
case 2:
|
|
138
|
+
response = _a.sent();
|
|
139
|
+
return [2 /*return*/, response.data];
|
|
140
|
+
case 3:
|
|
141
|
+
setUploading(false);
|
|
142
|
+
setProgress(0);
|
|
143
|
+
return [7 /*endfinally*/];
|
|
144
|
+
case 4: return [2 /*return*/];
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}, [projectId, axios]);
|
|
149
|
+
return {
|
|
150
|
+
uploadImage: uploadImage,
|
|
151
|
+
uploading: uploading,
|
|
152
|
+
progress: progress,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
export default useUploadImage;
|
|
156
|
+
//# sourceMappingURL=useUploadImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUploadImage.js","sourceRoot":"","sources":["../../../../src/hooks/storage/useUploadImage.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAGhD,gEAAgE;AAChE,SAAS,aAAa,CAAC,IAAmB;IACxC,OAAO,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,YAAY,IAAI,CAAC;AAC7D,CAAC;AAMD,SAAS,cAAc;IAAvB,iBA8GC;IA7GC,IAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IACxB,IAAA,SAAS,GAAK,UAAU,EAAE,UAAjB,CAAkB;IAC7B,IAAA,KAA4B,QAAQ,CAAC,KAAK,CAAC,EAA1C,SAAS,QAAA,EAAE,YAAY,QAAmB,CAAC;IAC5C,IAAA,KAA0B,QAAQ,CAAC,CAAC,CAAC,EAApC,QAAQ,QAAA,EAAE,WAAW,QAAe,CAAC;IAE5C,IAAM,WAAW,GAAG,WAAW,CAC7B;;;;;yFACE,IAAmB,EACnB,OAAgC;;YAAhC,wBAAA,EAAA,YAAgC;;;;wBAEhC,2BAA2B;wBAC3B,IAAI,CAAC,SAAS,EAAE,CAAC;4BACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;wBAC7C,CAAC;wBAED,IAAI,CAAC,IAAI,EAAE,C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AAC,IAAa,EAAC;;wBAE9B,YAAY,CAAC,KAAK,CAAC,CAAC;wBACpB,WAAW,CAAC,CAAC,CAAC,CAAC;;;;;;KAElB,EACD,CAAC,SAAS,EAAE,KAAK,CAAC,CACnB,CAAC;IAEF,OAAO;QACL,WAAW,aAAA;QACX,SAAS,WAAA;QACT,QAAQ,UAAA;KACT,CAAC;AACJ,CAAC;AAED,eAAe,cAAc,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export { useFetchSpaceReports } from "./hooks/reports";
|
|
|
27
27
|
export { useHandleSpaceEntityReport } from "./hooks/reports";
|
|
28
28
|
export { useHandleSpaceCommentReport } from "./hooks/reports";
|
|
29
29
|
export { useGetMetadata } from "./hooks/utils";
|
|
30
|
-
export { useUploadFile } from "./hooks/storage";
|
|
30
|
+
export { useUploadFile, useUploadImage } from "./hooks/storage";
|
|
31
31
|
export type { PaginatedResponse, PaginationMetadata, } from "./interfaces/IPaginatedResponse";
|
|
32
32
|
export type { EntityCommentsTree } from "./interfaces/EntityCommentsTree";
|
|
33
33
|
export type { UserFull, User, AuthUser, UserRole, } from "./interfaces/models/User";
|
|
@@ -46,3 +46,4 @@ export type { EntityListSortByOptions, SortDirection, SortType, } from "./interf
|
|
|
46
46
|
export { validateSortBy, validateMetadataPropertyName, validateSortType, } from "./interfaces/EntityListSortByOptions";
|
|
47
47
|
export type { TimeFrame } from "./interfaces/TimeFrame";
|
|
48
48
|
export type { Connection, EstablishedConnection, PendingConnection, ConnectionsResponse, PendingConnectionsResponse, PendingConnectionListResponse, ConnectionRequestParams, ConnectionActionResponse, ConnectionWithdrawResponse, ConnectionCountResponse, RemoveConnectionByUserIdResponse, ConnectionStatusResponse, ConnectionStatus, } from "./interfaces/models/Connection";
|
|
49
|
+
export type { Image, ImageVariant, ImageSizeConfig, UploadImageOptions, } from "./interfaces/models/Image";
|
package/dist/esm/index.js
CHANGED
|
@@ -47,7 +47,7 @@ export { useHandleSpaceCommentReport } from "./hooks/reports";
|
|
|
47
47
|
// -- general
|
|
48
48
|
export { useGetMetadata } from "./hooks/utils";
|
|
49
49
|
// -- storage
|
|
50
|
-
export { useUploadFile } from "./hooks/storage";
|
|
50
|
+
export { useUploadFile, useUploadImage } from "./hooks/storage";
|
|
51
51
|
export * as AppNotification from "./interfaces/models/AppNotification";
|
|
52
52
|
export { validateSortBy, validateMetadataPropertyName, validateSortType, } from "./interfaces/EntityListSortByOptions";
|
|
53
53
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,SAAS,GACV,MAAM,aAAa,CAAC;AAErB,YAAY;AACZ,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D,+CAA+C;AAC/C,OAAO,EACL,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE9D,YAAY;AACZ,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,oBAAoB;AACpB,OAAO,EAAE,OAAO,EAAsB,MAAM,cAAc,CAAC;AAE3D,oBAAoB;AACpB,OAAO,EACL,OAAO,EACP,cAAc,GAGf,MAAM,cAAc,CAAC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E,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAE9D,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,aAAa;AACb,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAchE,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AAwDvE,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,sCAAsC,CAAC"}
|
|
@@ -9,6 +9,44 @@ export interface TopComment {
|
|
|
9
9
|
content: string;
|
|
10
10
|
createdAt: string;
|
|
11
11
|
}
|
|
12
|
+
export interface EntityImageVariant {
|
|
13
|
+
path: string;
|
|
14
|
+
publicPath: string;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
size: number;
|
|
18
|
+
format: string;
|
|
19
|
+
}
|
|
20
|
+
export interface EntityImage {
|
|
21
|
+
fileId: string;
|
|
22
|
+
originalWidth: number;
|
|
23
|
+
originalHeight: number;
|
|
24
|
+
variants: Record<string, EntityImageVariant>;
|
|
25
|
+
processingStatus: "completed" | "failed";
|
|
26
|
+
processingError: string | null;
|
|
27
|
+
format: string;
|
|
28
|
+
quality: number;
|
|
29
|
+
exifStripped: boolean;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
}
|
|
33
|
+
export interface EntityFile {
|
|
34
|
+
id: string;
|
|
35
|
+
projectId: string;
|
|
36
|
+
userId: string | null;
|
|
37
|
+
entityId: string | null;
|
|
38
|
+
commentId: string | null;
|
|
39
|
+
spaceId: string | null;
|
|
40
|
+
type: "image" | "video" | "document" | "other";
|
|
41
|
+
originalPath: string;
|
|
42
|
+
originalSize: number;
|
|
43
|
+
originalMimeType: string;
|
|
44
|
+
position: number;
|
|
45
|
+
metadata: Record<string, any>;
|
|
46
|
+
image?: EntityImage;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
updatedAt: string;
|
|
49
|
+
}
|
|
12
50
|
export interface Entity {
|
|
13
51
|
id: string;
|
|
14
52
|
foreignId: string | null;
|
|
@@ -22,6 +60,7 @@ export interface Entity {
|
|
|
22
60
|
content: string | null;
|
|
23
61
|
mentions: Mention[];
|
|
24
62
|
attachments: Record<string, any>[];
|
|
63
|
+
files?: EntityFile[];
|
|
25
64
|
keywords: string[];
|
|
26
65
|
upvotes: string[];
|
|
27
66
|
downvotes: string[];
|
|
@@ -42,6 +81,6 @@ export interface Entity {
|
|
|
42
81
|
updatedAt: Date;
|
|
43
82
|
deletedAt: Date | null;
|
|
44
83
|
}
|
|
45
|
-
export type EntityInclude = "space" | "user" | "topComment" | "saved";
|
|
84
|
+
export type EntityInclude = "space" | "user" | "topComment" | "saved" | "files";
|
|
46
85
|
export type EntityIncludeArray = EntityInclude[];
|
|
47
86
|
export type EntityIncludeParam = string | EntityIncludeArray;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface ImageVariant {
|
|
2
|
+
path: string;
|
|
3
|
+
publicPath: string;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
size: number;
|
|
7
|
+
format: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Image {
|
|
10
|
+
fileId: string;
|
|
11
|
+
imageId: string;
|
|
12
|
+
status: "completed" | "failed";
|
|
13
|
+
original: ImageVariant;
|
|
14
|
+
variants: Record<string, ImageVariant>;
|
|
15
|
+
metadata: {
|
|
16
|
+
originalFormat: string;
|
|
17
|
+
originalSize: number;
|
|
18
|
+
exifStripped: boolean;
|
|
19
|
+
processingTime: number;
|
|
20
|
+
};
|
|
21
|
+
createdAt: string;
|
|
22
|
+
}
|
|
23
|
+
export type ImageSizeConfig = number[] | Record<string, number>;
|
|
24
|
+
export interface UploadImageOptions {
|
|
25
|
+
sizes?: ImageSizeConfig;
|
|
26
|
+
quality?: number;
|
|
27
|
+
format?: "webp" | "jpeg" | "png" | "original";
|
|
28
|
+
stripExif?: boolean;
|
|
29
|
+
fit?: "cover" | "contain" | "inside" | "outside";
|
|
30
|
+
pathParts?: string[];
|
|
31
|
+
entityId?: string;
|
|
32
|
+
commentId?: string;
|
|
33
|
+
spaceId?: string;
|
|
34
|
+
onProgress?: (progress: number) => void;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../../src/interfaces/models/Image.ts"],"names":[],"mappings":""}
|