@wrcb/cb-common 1.0.873 → 1.0.875

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/build/server.d.ts CHANGED
@@ -97,5 +97,6 @@ export * from './events/linkedin-automator/linkedinPostPublishedPublisher';
97
97
  export * from './services/RedisService';
98
98
  export * from './services/TenantDataService';
99
99
  export * from './services/WasabiUploader';
100
+ export * from './services/imageResize';
100
101
  export * from './services/WhatsappService';
101
102
  export * from './services/ai/AIClient';
package/build/server.js CHANGED
@@ -116,5 +116,6 @@ __exportStar(require("./events/linkedin-automator/linkedinPostPublishedPublisher
116
116
  __exportStar(require("./services/RedisService"), exports);
117
117
  __exportStar(require("./services/TenantDataService"), exports);
118
118
  __exportStar(require("./services/WasabiUploader"), exports);
119
+ __exportStar(require("./services/imageResize"), exports);
119
120
  __exportStar(require("./services/WhatsappService"), exports);
120
121
  __exportStar(require("./services/ai/AIClient"), exports);
@@ -7,5 +7,8 @@ export interface UploadToWasabiParams {
7
7
  region?: string;
8
8
  endpoint?: string;
9
9
  folder?: string;
10
+ contentType?: string;
11
+ extension?: string;
12
+ cacheControl?: string;
10
13
  }
11
- export declare function uploadToWasabi({ fileBuffer, originalName, accessKeyId, secretAccessKey, bucketName, region, endpoint, folder }: UploadToWasabiParams): Promise<string>;
14
+ export declare function uploadToWasabi({ fileBuffer, originalName, accessKeyId, secretAccessKey, bucketName, region, endpoint, folder, contentType: contentTypeOverride, extension: extensionOverride, cacheControl }: UploadToWasabiParams): Promise<string>;
@@ -18,9 +18,9 @@ const client_s3_1 = require("@aws-sdk/client-s3");
18
18
  const uuid_1 = require("uuid");
19
19
  const mime_types_1 = __importDefault(require("mime-types"));
20
20
  function uploadToWasabi(_a) {
21
- return __awaiter(this, arguments, void 0, function* ({ fileBuffer, originalName, accessKeyId, secretAccessKey, bucketName, region = 'us-east-1', endpoint = 'https://s3.us-east-1.wasabisys.com', folder = 'uploads' }) {
22
- const extension = originalName.split('.').pop() || 'jpg';
23
- const contentType = mime_types_1.default.lookup(extension) || 'application/octet-stream';
21
+ return __awaiter(this, arguments, void 0, function* ({ fileBuffer, originalName, accessKeyId, secretAccessKey, bucketName, region = 'us-east-1', endpoint = 'https://s3.us-east-1.wasabisys.com', folder = 'uploads', contentType: contentTypeOverride, extension: extensionOverride, cacheControl }) {
22
+ const extension = extensionOverride || originalName.split('.').pop() || 'jpg';
23
+ const contentType = contentTypeOverride || mime_types_1.default.lookup(extension) || 'application/octet-stream';
24
24
  const filename = `${folder}/${(0, uuid_1.v4)()}.${extension}`;
25
25
  const wasabiClient = new client_s3_1.S3Client({
26
26
  region,
@@ -31,13 +31,7 @@ function uploadToWasabi(_a) {
31
31
  secretAccessKey
32
32
  }
33
33
  });
34
- const params = {
35
- Bucket: bucketName,
36
- Key: filename,
37
- Body: fileBuffer,
38
- ContentType: contentType,
39
- ACL: 'public-read'
40
- };
34
+ const params = Object.assign({ Bucket: bucketName, Key: filename, Body: fileBuffer, ContentType: contentType, ACL: 'public-read' }, (cacheControl ? { CacheControl: cacheControl } : {}));
41
35
  yield wasabiClient.send(new client_s3_1.PutObjectCommand(params));
42
36
  return `${endpoint.replace(/\/$/, '')}/${bucketName}/${filename}`;
43
37
  });
@@ -0,0 +1,10 @@
1
+ export interface ResizeImageForWebOptions {
2
+ maxDimension: number;
3
+ quality?: number;
4
+ }
5
+ export interface ResizedImage {
6
+ buffer: Buffer;
7
+ contentType: 'image/webp';
8
+ extension: 'webp';
9
+ }
10
+ export declare function resizeImageForWeb(input: Buffer, { maxDimension, quality }: ResizeImageForWebOptions): Promise<ResizedImage>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.resizeImageForWeb = resizeImageForWeb;
16
+ const sharp_1 = __importDefault(require("sharp"));
17
+ // Redimensiona (sem ampliar) para caber em `maxDimension`, respeita a
18
+ // orientação EXIF, achata transparência em branco e recomprime em WebP.
19
+ // Lança em imagem inválida — quem chama decide o fallback (ex.: subir o
20
+ // original).
21
+ function resizeImageForWeb(input_1, _a) {
22
+ return __awaiter(this, arguments, void 0, function* (input, { maxDimension, quality = 78 }) {
23
+ const buffer = yield (0, sharp_1.default)(input, { failOn: 'none', animated: false })
24
+ .rotate()
25
+ .resize({
26
+ width: maxDimension,
27
+ height: maxDimension,
28
+ fit: 'inside',
29
+ withoutEnlargement: true
30
+ })
31
+ .flatten({ background: '#ffffff' })
32
+ .webp({ quality })
33
+ .toBuffer();
34
+ return { buffer, contentType: 'image/webp', extension: 'webp' };
35
+ });
36
+ }
@@ -86,6 +86,30 @@ export declare enum ThoFavoriteType {
86
86
  JobListing = "JobListing",
87
87
  Freelancer = "Freelancer"
88
88
  }
89
+ export declare enum ThoReportType {
90
+ JobListing = "JobListing",
91
+ Service = "Service",
92
+ Message = "Message",
93
+ Other = "Other"
94
+ }
95
+ export declare enum ThoReportStatus {
96
+ Open = "Open",
97
+ Reviewing = "Reviewing",
98
+ Resolved = "Resolved",
99
+ Dismissed = "Dismissed"
100
+ }
101
+ export interface ThoReportDTO {
102
+ id: string;
103
+ type: ThoReportType;
104
+ targetUrl: string | null;
105
+ description: string;
106
+ contact: string | null;
107
+ status: ThoReportStatus;
108
+ adminNote: string | null;
109
+ reporterUserId: string | null;
110
+ createdAt: string;
111
+ updatedAt: string;
112
+ }
89
113
  export interface ThoNotificationSummary {
90
114
  unreadMessages: number;
91
115
  jobApplicationsReceived: number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ThoPaymentMode = exports.ThoRatingCriterion = exports.ThoOrderSettlementReason = exports.ThoDisputeResolution = exports.ThoOrderLineKind = exports.ThoOrderStatus = exports.ConversationContextType = exports.ApplicationStatus = exports.DeliveryUnit = exports.ServicePriceType = exports.ThoFavoriteType = exports.JobApplyMode = exports.JobListingSort = exports.RemoteScope = exports.JobSeniority = exports.JobListingStatus = exports.JobListingSource = exports.JobListingOrigin = exports.JobPostingStatus = exports.WorkRegime = exports.JobContractType = void 0;
3
+ exports.ThoPaymentMode = exports.ThoRatingCriterion = exports.ThoOrderSettlementReason = exports.ThoDisputeResolution = exports.ThoOrderLineKind = exports.ThoOrderStatus = exports.ConversationContextType = exports.ApplicationStatus = exports.DeliveryUnit = exports.ServicePriceType = exports.ThoReportStatus = exports.ThoReportType = exports.ThoFavoriteType = exports.JobApplyMode = exports.JobListingSort = exports.RemoteScope = exports.JobSeniority = exports.JobListingStatus = exports.JobListingSource = exports.JobListingOrigin = exports.JobPostingStatus = exports.WorkRegime = exports.JobContractType = void 0;
4
4
  var JobContractType;
5
5
  (function (JobContractType) {
6
6
  JobContractType["Clt"] = "Clt";
@@ -102,6 +102,31 @@ var ThoFavoriteType;
102
102
  ThoFavoriteType["JobListing"] = "JobListing";
103
103
  ThoFavoriteType["Freelancer"] = "Freelancer";
104
104
  })(ThoFavoriteType || (exports.ThoFavoriteType = ThoFavoriteType = {}));
105
+ // ---------------------------------------------------------------------------
106
+ // Denúncias de oferta suspeita (coleção tho_reports no home-office-backend).
107
+ // Uso INTERNO: qualquer visitante envia pelo formulário público, mas só o
108
+ // administrador lê, no painel.
109
+ // ---------------------------------------------------------------------------
110
+ // O que está sendo denunciado.
111
+ var ThoReportType;
112
+ (function (ThoReportType) {
113
+ ThoReportType["JobListing"] = "JobListing";
114
+ ThoReportType["Service"] = "Service";
115
+ ThoReportType["Message"] = "Message";
116
+ ThoReportType["Other"] = "Other";
117
+ })(ThoReportType || (exports.ThoReportType = ThoReportType = {}));
118
+ // Fila de triagem do administrador.
119
+ // Open — chegou, ninguém olhou.
120
+ // Reviewing — um administrador assumiu.
121
+ // Resolved — procedia; ação tomada (remoção, aviso).
122
+ // Dismissed — analisado e não procedia.
123
+ var ThoReportStatus;
124
+ (function (ThoReportStatus) {
125
+ ThoReportStatus["Open"] = "Open";
126
+ ThoReportStatus["Reviewing"] = "Reviewing";
127
+ ThoReportStatus["Resolved"] = "Resolved";
128
+ ThoReportStatus["Dismissed"] = "Dismissed";
129
+ })(ThoReportStatus || (exports.ThoReportStatus = ThoReportStatus = {}));
105
130
  var ServicePriceType;
106
131
  (function (ServicePriceType) {
107
132
  ServicePriceType["Fixed"] = "Fixed";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrcb/cb-common",
3
- "version": "1.0.873",
3
+ "version": "1.0.875",
4
4
  "description": "Common resources between services",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",