@react-pakistan/util-functions 1.23.26 → 1.23.28

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.
@@ -1,7 +1,7 @@
1
- export interface fetchSupabaseImageArgs {
1
+ export interface fetchSupabasePrivateImageArgs {
2
2
  apikey: string;
3
3
  callback: (url: string) => void;
4
4
  fetchUrl: string;
5
5
  token: string;
6
6
  }
7
- export declare const fetchSupabaseImage: ({ apikey, callback, fetchUrl, token, }: fetchSupabaseImageArgs) => Promise<void>;
7
+ export declare const fetchSupabasePrivateImage: ({ apikey, callback, fetchUrl, token, }: fetchSupabasePrivateImageArgs) => Promise<void>;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- /* eslint-disable no-console */
2
+ /* eslint-disable @typescript-eslint/type-annotation-spacing */
3
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  });
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.fetchSupabaseImage = void 0;
13
+ exports.fetchSupabasePrivateImage = void 0;
14
14
  const constants_1 = require("../constants");
15
- const fetchSupabaseImage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apikey, callback, fetchUrl, token, }) {
15
+ const fetchSupabasePrivateImage = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apikey, callback, fetchUrl, token, }) {
16
16
  const response = yield fetch(fetchUrl, {
17
17
  method: constants_1.API_METHODS.GET,
18
18
  headers: {
@@ -26,8 +26,5 @@ const fetchSupabaseImage = (_a) => __awaiter(void 0, [_a], void 0, function* ({
26
26
  const url = URL.createObjectURL(blob);
27
27
  callback(url);
28
28
  }
29
- else {
30
- console.error(`Error fetching image: ${response.statusText}`);
31
- }
32
29
  });
33
- exports.fetchSupabaseImage = fetchSupabaseImage;
30
+ exports.fetchSupabasePrivateImage = fetchSupabasePrivateImage;
@@ -31,8 +31,10 @@ export * from './resolve-initials';
31
31
  export * from './slugify';
32
32
  export * from './text-to-enum';
33
33
  export * from './truncate-text';
34
- export * from './upload-image-blob-to-supabase';
35
- export * from './upload-image-to-supabase';
34
+ export * from './upload-image-blob-to-private-supabase';
35
+ export * from './upload-image-blob-to-public-supabase';
36
+ export * from './upload-image-to-private-supabase';
37
+ export * from './upload-image-to-public-supabase';
36
38
  export * from './url-to-sentence-case';
37
39
  export * from './validate-comment';
38
40
  export * from './validate-email';
package/general/index.js CHANGED
@@ -48,8 +48,10 @@ __exportStar(require("./resolve-initials"), exports);
48
48
  __exportStar(require("./slugify"), exports);
49
49
  __exportStar(require("./text-to-enum"), exports);
50
50
  __exportStar(require("./truncate-text"), exports);
51
- __exportStar(require("./upload-image-blob-to-supabase"), exports);
52
- __exportStar(require("./upload-image-to-supabase"), exports);
51
+ __exportStar(require("./upload-image-blob-to-private-supabase"), exports);
52
+ __exportStar(require("./upload-image-blob-to-public-supabase"), exports);
53
+ __exportStar(require("./upload-image-to-private-supabase"), exports);
54
+ __exportStar(require("./upload-image-to-public-supabase"), exports);
53
55
  __exportStar(require("./url-to-sentence-case"), exports);
54
56
  __exportStar(require("./validate-comment"), exports);
55
57
  __exportStar(require("./validate-email"), exports);
@@ -0,0 +1,11 @@
1
+ export interface UploadImageBlobToPrivateSupabaseArgs {
2
+ blob: Blob;
3
+ contentType: string;
4
+ fileRef: string;
5
+ supabase: any;
6
+ upsert: boolean;
7
+ }
8
+ export declare const uploadImageBlobToPrivateSupabase: ({ blob, contentType, fileRef, supabase, upsert, }: UploadImageBlobToPrivateSupabaseArgs) => Promise<{
9
+ data: any;
10
+ error: any;
11
+ }>;
@@ -10,18 +10,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  });
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.uploadImageBlobToSupabase = void 0;
14
- const uploadImageBlobToSupabase = (_a) => __awaiter(void 0, [_a], void 0, function* ({ blob, contentType, fileRef, supabase, upsert, }) {
13
+ exports.uploadImageBlobToPrivateSupabase = void 0;
14
+ const uploadImageBlobToPrivateSupabase = (_a) => __awaiter(void 0, [_a], void 0, function* ({ blob, contentType, fileRef, supabase, upsert, }) {
15
15
  const { data, error } = yield supabase.storage
16
16
  .from(process.env.NEXT_PUBLIC_SUPABASE_PRIVATE_BUCKET)
17
17
  .upload(fileRef, blob, {
18
- upsert,
19
18
  cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
20
19
  contentType,
20
+ upsert,
21
21
  });
22
22
  return {
23
23
  data,
24
24
  error,
25
25
  };
26
26
  });
27
- exports.uploadImageBlobToSupabase = uploadImageBlobToSupabase;
27
+ exports.uploadImageBlobToPrivateSupabase = uploadImageBlobToPrivateSupabase;
@@ -0,0 +1,11 @@
1
+ export interface UploadImageBlobToPublicSupabaseArgs {
2
+ blob: Blob;
3
+ contentType: string;
4
+ fileRef: string;
5
+ supabase: any;
6
+ upsert: boolean;
7
+ }
8
+ export declare const uploadImageBlobToPublicSupabase: ({ blob, contentType, fileRef, supabase, upsert, }: UploadImageBlobToPublicSupabaseArgs) => Promise<{
9
+ data: any;
10
+ error: any;
11
+ }>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
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
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.uploadImageBlobToPublicSupabase = void 0;
14
+ const uploadImageBlobToPublicSupabase = (_a) => __awaiter(void 0, [_a], void 0, function* ({ blob, contentType, fileRef, supabase, upsert, }) {
15
+ const { data, error } = yield supabase.storage
16
+ .from(process.env.NEXT_PUBLIC_SUPABASE_PUBLIC_BUCKET)
17
+ .upload(fileRef, blob, {
18
+ cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
19
+ contentType,
20
+ upsert,
21
+ });
22
+ return {
23
+ data,
24
+ error,
25
+ };
26
+ });
27
+ exports.uploadImageBlobToPublicSupabase = uploadImageBlobToPublicSupabase;
@@ -0,0 +1,8 @@
1
+ export interface UploadImageToPrivateSupabaseArgs {
2
+ blob: string;
3
+ contentType: string;
4
+ fileRef: string;
5
+ supabase: any;
6
+ upsert: boolean;
7
+ }
8
+ export declare const uploadImageToPrivateSupabase: ({ blob, contentType, fileRef, supabase, upsert, }: UploadImageToPrivateSupabaseArgs) => Promise<void>;
@@ -10,21 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  });
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.uploadImageToSupabase = void 0;
13
+ exports.uploadImageToPrivateSupabase = void 0;
14
14
  const remove_data_image_prefix_1 = require("./remove-data-image-prefix");
15
- const uploadImageToSupabase = (_a) => __awaiter(void 0, [_a], void 0, function* ({ blob, supabase, fileRef, contentType, }) {
15
+ const uploadImageToPrivateSupabase = (_a) => __awaiter(void 0, [_a], void 0, function* ({ blob, contentType, fileRef, supabase, upsert, }) {
16
16
  const base64StringWithoutPrefix = (0, remove_data_image_prefix_1.removeDataImagePrefix)(blob);
17
17
  const buffer = Buffer.from(base64StringWithoutPrefix, 'base64');
18
18
  const { data, error } = yield supabase.storage
19
19
  .from(process.env.NEXT_PUBLIC_SUPABASE_PRIVATE_BUCKET)
20
20
  .upload(fileRef, buffer, {
21
- upsert: false,
22
21
  cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
23
22
  contentType,
23
+ upsert,
24
24
  });
25
25
  if (error) {
26
26
  return error;
27
27
  }
28
28
  return data;
29
29
  });
30
- exports.uploadImageToSupabase = uploadImageToSupabase;
30
+ exports.uploadImageToPrivateSupabase = uploadImageToPrivateSupabase;
@@ -0,0 +1,8 @@
1
+ export interface UploadImageToPublicSupabaseArgs {
2
+ blob: string;
3
+ contentType: string;
4
+ fileRef: string;
5
+ supabase: any;
6
+ upsert: boolean;
7
+ }
8
+ export declare const uploadImageToPublicSupabase: ({ blob, contentType, fileRef, supabase, upsert, }: UploadImageToPublicSupabaseArgs) => Promise<void>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
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
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.uploadImageToPublicSupabase = void 0;
14
+ const remove_data_image_prefix_1 = require("./remove-data-image-prefix");
15
+ const uploadImageToPublicSupabase = (_a) => __awaiter(void 0, [_a], void 0, function* ({ blob, contentType, fileRef, supabase, upsert, }) {
16
+ const base64StringWithoutPrefix = (0, remove_data_image_prefix_1.removeDataImagePrefix)(blob);
17
+ const buffer = Buffer.from(base64StringWithoutPrefix, 'base64');
18
+ const { data, error } = yield supabase.storage
19
+ .from(process.env.NEXT_PUBLIC_SUPABASE_PUBLIC_BUCKET)
20
+ .upload(fileRef, buffer, {
21
+ cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
22
+ contentType,
23
+ upsert,
24
+ });
25
+ if (error) {
26
+ return error;
27
+ }
28
+ return data;
29
+ });
30
+ exports.uploadImageToPublicSupabase = uploadImageToPublicSupabase;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.23.26",
3
+ "version": "1.23.28",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,11 +0,0 @@
1
- export interface UploadImageBlobToSupabaseArgs {
2
- blob: Blob;
3
- contentType: string;
4
- fileRef: string;
5
- supabase: any;
6
- upsert: boolean;
7
- }
8
- export declare const uploadImageBlobToSupabase: ({ blob, contentType, fileRef, supabase, upsert, }: UploadImageBlobToSupabaseArgs) => Promise<{
9
- data: any;
10
- error: any;
11
- }>;
@@ -1,7 +0,0 @@
1
- export interface UploadImageToSupabaseArgs {
2
- blob: string;
3
- supabase: any;
4
- fileRef: string;
5
- contentType: string;
6
- }
7
- export declare const uploadImageToSupabase: ({ blob, supabase, fileRef, contentType, }: UploadImageToSupabaseArgs) => Promise<void>;