@react-pakistan/util-functions 1.24.49 → 1.24.51
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/general/fetch-supabase-private-assets.d.ts +6 -0
- package/general/fetch-supabase-private-assets.js +68 -0
- package/general/upload-blob-to-private-supabase.d.ts +2 -1
- package/general/upload-blob-to-private-supabase.js +2 -2
- package/general/upload-blob-to-public-supabase.d.ts +2 -1
- package/general/upload-blob-to-public-supabase.js +2 -2
- package/general/upload-image-to-private-supabase.d.ts +2 -1
- package/general/upload-image-to-private-supabase.js +2 -2
- package/general/upload-image-to-public-supabase.d.ts +2 -1
- package/general/upload-image-to-public-supabase.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/type-annotation-spacing */
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
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);
|
|
14
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
+
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;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.fetchSupabasePrivateAssets = void 0;
|
|
41
|
+
var constants_1 = require("../constants");
|
|
42
|
+
var fetchSupabasePrivateAssets = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
43
|
+
var fetchPromises, results;
|
|
44
|
+
var apikey = _b.apikey, fetchUrls = _b.fetchUrls, token = _b.token;
|
|
45
|
+
return __generator(this, function (_c) {
|
|
46
|
+
switch (_c.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
fetchPromises = fetchUrls.map(function (url) { return fetch(url, {
|
|
49
|
+
method: constants_1.API_METHODS.GET,
|
|
50
|
+
headers: {
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
apikey: apikey,
|
|
53
|
+
Authorization: "Bearer ".concat(token),
|
|
54
|
+
},
|
|
55
|
+
}).then(function (response) {
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
throw new Error("HTTP error! status: ".concat(response.status, " from ").concat(url));
|
|
58
|
+
}
|
|
59
|
+
return response.json();
|
|
60
|
+
}); });
|
|
61
|
+
return [4 /*yield*/, Promise.all(fetchPromises)];
|
|
62
|
+
case 1:
|
|
63
|
+
results = _c.sent();
|
|
64
|
+
return [2 /*return*/, results];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}); };
|
|
68
|
+
exports.fetchSupabasePrivateAssets = fetchSupabasePrivateAssets;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export interface UploadBlobToPrivateSupabaseArgs {
|
|
2
2
|
blob: Blob;
|
|
3
|
+
cacheControl?: string;
|
|
3
4
|
contentType: string;
|
|
4
5
|
fileRef: string;
|
|
5
6
|
supabase: any;
|
|
6
7
|
upsert: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare const uploadBlobToPrivateSupabase: ({ blob, contentType, fileRef, supabase, upsert, }: UploadBlobToPrivateSupabaseArgs) => Promise<{
|
|
9
|
+
export declare const uploadBlobToPrivateSupabase: ({ blob, cacheControl, contentType, fileRef, supabase, upsert, }: UploadBlobToPrivateSupabaseArgs) => Promise<{
|
|
9
10
|
data: any;
|
|
10
11
|
error: any;
|
|
11
12
|
}>;
|
|
@@ -40,13 +40,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
exports.uploadBlobToPrivateSupabase = void 0;
|
|
41
41
|
var uploadBlobToPrivateSupabase = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
42
|
var _c, data, error;
|
|
43
|
-
var blob = _b.blob, contentType = _b.contentType, fileRef = _b.fileRef, supabase = _b.supabase, upsert = _b.upsert;
|
|
43
|
+
var blob = _b.blob, cacheControl = _b.cacheControl, contentType = _b.contentType, fileRef = _b.fileRef, supabase = _b.supabase, upsert = _b.upsert;
|
|
44
44
|
return __generator(this, function (_d) {
|
|
45
45
|
switch (_d.label) {
|
|
46
46
|
case 0: return [4 /*yield*/, supabase.storage
|
|
47
47
|
.from(process.env.NEXT_PUBLIC_SUPABASE_PRIVATE_BUCKET)
|
|
48
48
|
.upload(fileRef, blob, {
|
|
49
|
-
cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
|
|
49
|
+
cacheControl: cacheControl || process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
|
|
50
50
|
contentType: contentType,
|
|
51
51
|
upsert: upsert,
|
|
52
52
|
})];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export interface UploadBlobToPublicSupabaseArgs {
|
|
2
2
|
blob: Blob;
|
|
3
|
+
cacheControl?: string;
|
|
3
4
|
contentType: string;
|
|
4
5
|
fileRef: string;
|
|
5
6
|
supabase: any;
|
|
6
7
|
upsert: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare const uploadBlobToPublicSupabase: ({ blob, contentType, fileRef, supabase, upsert, }: UploadBlobToPublicSupabaseArgs) => Promise<{
|
|
9
|
+
export declare const uploadBlobToPublicSupabase: ({ blob, cacheControl, contentType, fileRef, supabase, upsert, }: UploadBlobToPublicSupabaseArgs) => Promise<{
|
|
9
10
|
data: any;
|
|
10
11
|
error: any;
|
|
11
12
|
}>;
|
|
@@ -40,13 +40,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
exports.uploadBlobToPublicSupabase = void 0;
|
|
41
41
|
var uploadBlobToPublicSupabase = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
42
|
var _c, data, error;
|
|
43
|
-
var blob = _b.blob, contentType = _b.contentType, fileRef = _b.fileRef, supabase = _b.supabase, upsert = _b.upsert;
|
|
43
|
+
var blob = _b.blob, cacheControl = _b.cacheControl, contentType = _b.contentType, fileRef = _b.fileRef, supabase = _b.supabase, upsert = _b.upsert;
|
|
44
44
|
return __generator(this, function (_d) {
|
|
45
45
|
switch (_d.label) {
|
|
46
46
|
case 0: return [4 /*yield*/, supabase.storage
|
|
47
47
|
.from(process.env.NEXT_PUBLIC_SUPABASE_PUBLIC_BUCKET)
|
|
48
48
|
.upload(fileRef, blob, {
|
|
49
|
-
cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
|
|
49
|
+
cacheControl: cacheControl || process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
|
|
50
50
|
contentType: contentType,
|
|
51
51
|
upsert: upsert,
|
|
52
52
|
})];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export interface UploadImageToPrivateSupabaseArgs {
|
|
2
|
+
cacheControl?: string;
|
|
2
3
|
blob: string;
|
|
3
4
|
contentType: string;
|
|
4
5
|
fileRef: string;
|
|
@@ -10,4 +11,4 @@ export interface PrivateReturn {
|
|
|
10
11
|
id: string;
|
|
11
12
|
path: string;
|
|
12
13
|
}
|
|
13
|
-
export declare const uploadImageToPrivateSupabase: ({ blob, contentType, fileRef, supabase, upsert, }: UploadImageToPrivateSupabaseArgs) => Promise<PrivateReturn>;
|
|
14
|
+
export declare const uploadImageToPrivateSupabase: ({ blob, cacheControl, contentType, fileRef, supabase, upsert, }: UploadImageToPrivateSupabaseArgs) => Promise<PrivateReturn>;
|
|
@@ -41,7 +41,7 @@ exports.uploadImageToPrivateSupabase = void 0;
|
|
|
41
41
|
var remove_data_image_prefix_1 = require("./remove-data-image-prefix");
|
|
42
42
|
var uploadImageToPrivateSupabase = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
43
43
|
var base64StringWithoutPrefix, buffer, _c, data, error;
|
|
44
|
-
var blob = _b.blob, contentType = _b.contentType, fileRef = _b.fileRef, supabase = _b.supabase, upsert = _b.upsert;
|
|
44
|
+
var blob = _b.blob, cacheControl = _b.cacheControl, contentType = _b.contentType, fileRef = _b.fileRef, supabase = _b.supabase, upsert = _b.upsert;
|
|
45
45
|
return __generator(this, function (_d) {
|
|
46
46
|
switch (_d.label) {
|
|
47
47
|
case 0:
|
|
@@ -50,7 +50,7 @@ var uploadImageToPrivateSupabase = function (_a) { return __awaiter(void 0, [_a]
|
|
|
50
50
|
return [4 /*yield*/, supabase.storage
|
|
51
51
|
.from(process.env.NEXT_PUBLIC_SUPABASE_PRIVATE_BUCKET)
|
|
52
52
|
.upload(fileRef, buffer, {
|
|
53
|
-
cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
|
|
53
|
+
cacheControl: cacheControl || process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
|
|
54
54
|
contentType: contentType,
|
|
55
55
|
upsert: upsert,
|
|
56
56
|
})];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export interface UploadImageToPublicSupabaseArgs {
|
|
2
2
|
blob: string;
|
|
3
|
+
cacheControl?: string;
|
|
3
4
|
contentType: string;
|
|
4
5
|
fileRef: string;
|
|
5
6
|
supabase: any;
|
|
@@ -10,4 +11,4 @@ export interface PublicReturn {
|
|
|
10
11
|
id: string;
|
|
11
12
|
path: string;
|
|
12
13
|
}
|
|
13
|
-
export declare const uploadImageToPublicSupabase: ({ blob, contentType, fileRef, supabase, upsert, }: UploadImageToPublicSupabaseArgs) => Promise<PublicReturn>;
|
|
14
|
+
export declare const uploadImageToPublicSupabase: ({ blob, cacheControl, contentType, fileRef, supabase, upsert, }: UploadImageToPublicSupabaseArgs) => Promise<PublicReturn>;
|
|
@@ -41,7 +41,7 @@ exports.uploadImageToPublicSupabase = void 0;
|
|
|
41
41
|
var remove_data_image_prefix_1 = require("./remove-data-image-prefix");
|
|
42
42
|
var uploadImageToPublicSupabase = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
43
43
|
var base64StringWithoutPrefix, buffer, _c, data, error;
|
|
44
|
-
var blob = _b.blob, contentType = _b.contentType, fileRef = _b.fileRef, supabase = _b.supabase, upsert = _b.upsert;
|
|
44
|
+
var blob = _b.blob, cacheControl = _b.cacheControl, contentType = _b.contentType, fileRef = _b.fileRef, supabase = _b.supabase, upsert = _b.upsert;
|
|
45
45
|
return __generator(this, function (_d) {
|
|
46
46
|
switch (_d.label) {
|
|
47
47
|
case 0:
|
|
@@ -50,7 +50,7 @@ var uploadImageToPublicSupabase = function (_a) { return __awaiter(void 0, [_a],
|
|
|
50
50
|
return [4 /*yield*/, supabase.storage
|
|
51
51
|
.from(process.env.NEXT_PUBLIC_SUPABASE_PUBLIC_BUCKET)
|
|
52
52
|
.upload(fileRef, buffer, {
|
|
53
|
-
cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
|
|
53
|
+
cacheControl: cacheControl || process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
|
|
54
54
|
contentType: contentType,
|
|
55
55
|
upsert: upsert,
|
|
56
56
|
})];
|