build: refresh release artifacts after upload limits and survey access
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
5593cef462
commit
41399a33bb
+61
-19
@@ -93298,6 +93298,12 @@ var require_upload_path = __commonJS({
|
||||
".gif": "image/gif",
|
||||
".webp": "image/webp",
|
||||
".avif": "image/avif",
|
||||
".bmp": "image/bmp",
|
||||
".tif": "image/tiff",
|
||||
".tiff": "image/tiff",
|
||||
".heic": "image/heic",
|
||||
".heif": "image/heif",
|
||||
".jxl": "image/jxl",
|
||||
".svg": "image/svg+xml",
|
||||
".pdf": "application/pdf"
|
||||
};
|
||||
@@ -93343,9 +93349,25 @@ var require_image_variants_service = __commonJS({
|
||||
var node_path_12 = require("node:path");
|
||||
var upload_path_1 = require_upload_path();
|
||||
exports2.IMAGE_WIDTHS = [200, 400, 600, 800, 1200, 1600];
|
||||
var WARM_WIDTHS = [600, 1600];
|
||||
var RESIZABLE = /* @__PURE__ */ new Set([".jpg", ".jpeg", ".png", ".webp", ".avif"]);
|
||||
var RESIZABLE_MIME = /* @__PURE__ */ new Set(["image/jpeg", "image/png", "image/webp", "image/avif"]);
|
||||
var WARM_WIDTHS = [200, 400, 600, 1600];
|
||||
var RESIZABLE = /* @__PURE__ */ new Set([".jpg", ".jpeg", ".png", ".webp", ".avif", ".bmp", ".tif", ".tiff", ".heic", ".heif"]);
|
||||
var RESIZABLE_MIME = /* @__PURE__ */ new Set([
|
||||
"image/jpeg",
|
||||
"image/jpg",
|
||||
"image/pjpeg",
|
||||
"image/png",
|
||||
"image/apng",
|
||||
"image/webp",
|
||||
"image/avif",
|
||||
"image/bmp",
|
||||
"image/x-ms-bmp",
|
||||
"image/tiff",
|
||||
"image/heic",
|
||||
"image/heif",
|
||||
"image/jxl"
|
||||
]);
|
||||
var BROWSER_UNSAFE_MIME = /* @__PURE__ */ new Set(["image/tiff", "image/heic", "image/heif", "image/jxl"]);
|
||||
var MAX_INPUT_PIXELS = 8e3 * 8e3;
|
||||
var WEBP_QUALITY = 78;
|
||||
exports2.ORIGINAL_TARGET_BYTES = 500 * 1024;
|
||||
exports2.ORIGINAL_CEILING_BYTES = 1024 * 1024;
|
||||
@@ -93396,27 +93418,30 @@ var require_image_variants_service = __commonJS({
|
||||
* resizable format, sharp is missing, or re-encoding would not make it smaller.
|
||||
*/
|
||||
async compressUpload(buffer, mimeType, filename) {
|
||||
if (buffer.length <= exports2.ORIGINAL_TARGET_BYTES)
|
||||
return null;
|
||||
if (!RESIZABLE_MIME.has(mimeType))
|
||||
return null;
|
||||
const mustConvert = BROWSER_UNSAFE_MIME.has(mimeType);
|
||||
if (buffer.length <= exports2.ORIGINAL_TARGET_BYTES && !mustConvert)
|
||||
return null;
|
||||
const sharp = this.loadSharp();
|
||||
if (!sharp)
|
||||
return null;
|
||||
let smallest = null;
|
||||
try {
|
||||
for (const { side, quality } of ORIGINAL_ATTEMPTS) {
|
||||
const out = await sharp(buffer, { failOn: "none" }).rotate().resize({ width: side, height: side, fit: "inside", withoutEnlargement: true }).webp({ quality }).toBuffer();
|
||||
const out = await sharp(buffer, { failOn: "none", limitInputPixels: MAX_INPUT_PIXELS }).rotate().resize({ width: side, height: side, fit: "inside", withoutEnlargement: true }).webp({ quality }).toBuffer();
|
||||
if (!smallest || out.length < smallest.length)
|
||||
smallest = out;
|
||||
if (out.length <= exports2.ORIGINAL_TARGET_BYTES)
|
||||
if (out.length <= exports2.ORIGINAL_TARGET_BYTES && !mustConvert)
|
||||
break;
|
||||
}
|
||||
} catch (err) {
|
||||
this.logger.warn(`compress failed for ${filename}: ${err.message}`);
|
||||
return null;
|
||||
}
|
||||
if (!smallest || smallest.length >= buffer.length)
|
||||
if (!smallest)
|
||||
return null;
|
||||
if (!mustConvert && smallest.length >= buffer.length)
|
||||
return null;
|
||||
if (smallest.length > exports2.ORIGINAL_CEILING_BYTES) {
|
||||
this.logger.warn(`${filename} is still ${smallest.length} bytes after compression`);
|
||||
@@ -93448,7 +93473,7 @@ var require_image_variants_service = __commonJS({
|
||||
const tmp = `${target}.${process.pid}.${Date.now()}.tmp`;
|
||||
try {
|
||||
await (0, promises_1.mkdir)((0, node_path_12.dirname)(target), { recursive: true });
|
||||
await sharp(original, { failOn: "none" }).rotate().resize({ width, withoutEnlargement: true }).webp({ quality: WEBP_QUALITY }).toFile(tmp);
|
||||
await sharp(original, { failOn: "none", limitInputPixels: MAX_INPUT_PIXELS }).rotate().resize({ width, withoutEnlargement: true }).webp({ quality: WEBP_QUALITY }).toFile(tmp);
|
||||
await (0, promises_1.rename)(tmp, target);
|
||||
return target;
|
||||
} catch (err) {
|
||||
@@ -93516,10 +93541,14 @@ var require_admin_uploads_service = __commonJS({
|
||||
/** Matches legacy's flat public/storage directory. */
|
||||
dir = (0, upload_path_1.getUploadDir)();
|
||||
/** Mirrors legacy's `type` field: 1 = image, 2 = any other document. */
|
||||
static IMAGE_MIME = /^image\/(jpeg|png|gif|webp|svg\+xml)$/;
|
||||
static ALLOWED = /^(image\/(jpeg|png|gif|webp|svg\+xml)|application\/pdf)$/;
|
||||
/** 8 MB. Legacy relied on PHP's upload_max_filesize; this makes it explicit. */
|
||||
static MAX_BYTES = 8 * 1024 * 1024;
|
||||
static IMAGE_MIME = /^image\/(jpeg|jpg|pjpeg|png|apng|gif|webp|svg\+xml|avif|bmp|x-ms-bmp|tiff|heic|heif|jxl)$/;
|
||||
static ALLOWED = /^(image\/(jpeg|jpg|pjpeg|png|apng|gif|webp|svg\+xml|avif|bmp|x-ms-bmp|tiff|heic|heif|jxl)|application\/pdf)$/;
|
||||
/**
|
||||
* 15 MB. Legacy relied on PHP's upload_max_filesize; this makes it explicit.
|
||||
* The ceiling is paired with ImageVariantService's `limitInputPixels`, which
|
||||
* accepts up to 8000×8000 (64 MP) rasters.
|
||||
*/
|
||||
static MAX_BYTES = 15 * 1024 * 1024;
|
||||
constructor(prisma, variants) {
|
||||
this.prisma = prisma;
|
||||
this.variants = variants;
|
||||
@@ -93527,13 +93556,14 @@ var require_admin_uploads_service = __commonJS({
|
||||
async store(file2, purpose, actorAdminUserId) {
|
||||
if (!file2)
|
||||
throw new common_12.BadRequestException("\u0641\u0627\u06CC\u0644\u06CC \u0627\u0646\u062A\u062E\u0627\u0628 \u0646\u0634\u062F\u0647 \u0627\u0633\u062A");
|
||||
const mime = (0, upload_path_1.mimeForUpload)(file2.originalname) ?? file2.mimetype;
|
||||
if (file2.size > AdminUploadsService_1.MAX_BYTES) {
|
||||
throw new common_12.BadRequestException("\u062D\u062C\u0645 \u0641\u0627\u06CC\u0644 \u0628\u06CC\u0634\u062A\u0631 \u0627\u0632 \u06F8 \u0645\u06AF\u0627\u0628\u0627\u06CC\u062A \u0627\u0633\u062A\u061B \u0641\u0627\u06CC\u0644 \u06A9\u0648\u0686\u06A9\u200C\u062A\u0631\u06CC \u0627\u0646\u062A\u062E\u0627\u0628 \u06A9\u0646\u06CC\u062F");
|
||||
throw new common_12.BadRequestException("\u062D\u062C\u0645 \u0641\u0627\u06CC\u0644 \u0628\u06CC\u0634\u062A\u0631 \u0627\u0632 \u06F1\u06F5 \u0645\u06AF\u0627\u0628\u0627\u06CC\u062A \u0627\u0633\u062A\u061B \u0641\u0627\u06CC\u0644 \u06A9\u0648\u0686\u06A9\u200C\u062A\u0631\u06CC \u0627\u0646\u062A\u062E\u0627\u0628 \u06A9\u0646\u06CC\u062F");
|
||||
}
|
||||
if (!AdminUploadsService_1.ALLOWED.test(file2.mimetype)) {
|
||||
throw new common_12.BadRequestException("\u0627\u06CC\u0646 \u0646\u0648\u0639 \u0641\u0627\u06CC\u0644 \u067E\u0634\u062A\u06CC\u0628\u0627\u0646\u06CC \u0646\u0645\u06CC\u200C\u0634\u0648\u062F\u061B \u0641\u0642\u0637 JPG\u060C PNG\u060C WebP\u060C GIF\u060C SVG \u06CC\u0627 PDF");
|
||||
if (!AdminUploadsService_1.ALLOWED.test(mime)) {
|
||||
throw new common_12.BadRequestException("\u0627\u06CC\u0646 \u0646\u0648\u0639 \u0641\u0627\u06CC\u0644 \u067E\u0634\u062A\u06CC\u0628\u0627\u0646\u06CC \u0646\u0645\u06CC\u200C\u0634\u0648\u062F\u061B \u062A\u0635\u0648\u06CC\u0631 JPG\u060C PNG\u060C WebP\u060C GIF\u060C SVG\u060C AVIF\u060C BMP\u060C TIFF\u060C HEIC \u06CC\u0627 \u0633\u0646\u062F PDF \u0627\u0646\u062A\u062E\u0627\u0628 \u06A9\u0646\u06CC\u062F");
|
||||
}
|
||||
const compressed = await this.variants.compressUpload(file2.buffer, file2.mimetype, file2.originalname);
|
||||
const compressed = await this.variants.compressUpload(file2.buffer, mime, file2.originalname);
|
||||
const buffer = compressed?.buffer ?? file2.buffer;
|
||||
const ext = compressed?.ext ?? (0, node_path_12.extname)(file2.originalname).toLowerCase();
|
||||
const stored = (0, node_crypto_1.createHash)("md5").update(`${Date.now()}${file2.originalname}${(0, node_crypto_1.randomUUID)()}`).digest("hex") + ext;
|
||||
@@ -93544,7 +93574,7 @@ var require_admin_uploads_service = __commonJS({
|
||||
data: {
|
||||
url: `/uploads/${stored}`,
|
||||
originalName: file2.originalname,
|
||||
mimeType: compressed?.mimeType ?? file2.mimetype,
|
||||
mimeType: compressed?.mimeType ?? mime,
|
||||
sizeBytes: buffer.length,
|
||||
purpose: purpose ?? null,
|
||||
uploadedByAdminId: actorAdminUserId
|
||||
@@ -166993,6 +167023,12 @@ var require_migrate = __commonJS({
|
||||
)`);
|
||||
const alreadyApplied = await prisma.$queryRawUnsafe(`SELECT name FROM "${TRACKING_TABLE}"`);
|
||||
const appliedNames = new Set(alreadyApplied.map((row) => row.name));
|
||||
try {
|
||||
const prismaApplied = await prisma.$queryRawUnsafe(`SELECT migration_name FROM "_prisma_migrations" WHERE finished_at IS NOT NULL`);
|
||||
for (const row of prismaApplied)
|
||||
appliedNames.add(row.migration_name);
|
||||
} catch {
|
||||
}
|
||||
const applied = [];
|
||||
for (const file2 of files) {
|
||||
const legacyName = LEGACY_NAME_ALIASES[file2.name];
|
||||
@@ -167245,7 +167281,13 @@ var production_checks_1 = require_production_checks();
|
||||
var boot_secrets_1 = require_boot_secrets();
|
||||
var customer_auth_service_1 = require_customer_auth_service();
|
||||
var EXTRA_MIME_TYPES = {
|
||||
".avif": "image/avif"
|
||||
".avif": "image/avif",
|
||||
".bmp": "image/bmp",
|
||||
".tif": "image/tiff",
|
||||
".tiff": "image/tiff",
|
||||
".heic": "image/heic",
|
||||
".heif": "image/heif",
|
||||
".jxl": "image/jxl"
|
||||
};
|
||||
function warnProductionConfig(problems) {
|
||||
if (!problems.length)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
-- Product design survey visible to EVERY admin user, whatever their user type.
|
||||
--
|
||||
-- Before this, the survey screen (nav item, route guard, in-view check and the
|
||||
-- API's @RequirePermission('product.survey')) only appeared for admins whose
|
||||
-- user type had been granted `product.survey` — in practice the super admin.
|
||||
--
|
||||
-- Granting both rids to every existing user type fixes that:
|
||||
-- `product` - the «محصولات» menu group itself (children are still
|
||||
-- gated by their own rids, so nothing else new appears)
|
||||
-- `product.survey` - the «نظرسنجی طرح» item and its API endpoints
|
||||
--
|
||||
-- Idempotent: re-running adds nothing. User types created later are granted
|
||||
-- through the normal permission screen, and the seed does the same for fresh
|
||||
-- databases.
|
||||
INSERT INTO "permission" ("rid", "userTypeId")
|
||||
SELECT r.rid, ut.id
|
||||
FROM (VALUES ('product'), ('product.survey')) AS r(rid)
|
||||
CROSS JOIN "user_type" AS ut
|
||||
ON CONFLICT ("rid", "userTypeId") DO NOTHING;
|
||||
@@ -1808,6 +1808,13 @@ async function seedAccessControl() {
|
||||
skipDuplicates: true
|
||||
});
|
||||
}
|
||||
const allTypes = await prisma.userType.findMany({ select: { id: true } });
|
||||
await prisma.permission.createMany({
|
||||
data: allTypes.flatMap(
|
||||
(ut) => ["product", "product.survey"].map((rid) => ({ rid, userTypeId: ut.id }))
|
||||
),
|
||||
skipDuplicates: true
|
||||
});
|
||||
}
|
||||
function demoDataAllowed() {
|
||||
if (process.env.SEED_DEMO_DATA?.trim() === "true") return true;
|
||||
|
||||
Reference in New Issue
Block a user