fix: 0.1.0 사전 점검 차단 결함을 보정

공유 archive 마이그레이션과 런타임 설정 보존, AVIF 판별 및 문서 생성을 수정한다. 조건부 통합 격리를 보강하고 취약 의존성을 갱신하며 릴리스 메타데이터를 정리한다.
This commit is contained in:
2026-08-19 11:20:44 +00:00
parent b43d7601e7
commit 769d81f894
20 changed files with 1257 additions and 1888 deletions
+2 -2
View File
@@ -32,7 +32,7 @@
},
"dependencies": {
"@fastify/cors": "^11.2.0",
"@fastify/static": "^9.0.0",
"@fastify/static": "^10.1.3",
"@sammo-ts/common": "workspace:*",
"@sammo-ts/game-engine": "workspace:*",
"@sammo-ts/infra": "workspace:*",
@@ -43,7 +43,7 @@
"fastify": "^5.6.2",
"redis": "^5.10.0",
"sanitize-html": "2.17.6",
"sharp": "^0.34.4",
"sharp": "^0.35.0",
"zod": "^4.3.5"
}
}
+3 -2
View File
@@ -228,6 +228,7 @@ export const boardRouter = router({
}
const format = metadata.format;
const isAvif = metadata.mediaType === 'image/avif';
const isAnimated = (metadata.pages ?? 1) > 1;
const needsResize = Math.max(metadata.width, metadata.height) > MAX_LONG_EDGE;
@@ -237,9 +238,9 @@ export const boardRouter = router({
}
let outputBuffer = buffer;
let outputFormat = format === 'avif' ? 'avif' : 'webp';
let outputFormat = isAvif ? 'avif' : 'webp';
if (format === 'avif') {
if (isAvif) {
if (needsResize) {
outputBuffer = await buildAvifBuffer(buffer, true);
}
+23
View File
@@ -288,6 +288,29 @@ describe('board router actor, nation, and secret permissions', () => {
expect(result).toMatchObject({ width: 64, height: 48, format: 'webp', animated: false });
});
it('preserves an AVIF editor image when resizing is unnecessary', async () => {
const upload = vi.fn(async ({ filename }: { filename: string }) => ({
publicUrl: `https://sam-image.hided.net/uploads/core2026/${filename}`,
}));
const fixture = buildContext({
me: buildGeneral({ officerLevel: 5 }),
contentImageUpload: { upload },
});
const avif = await sharp({
create: { width: 64, height: 48, channels: 4, background: '#224466' },
})
.avif()
.toBuffer();
const result = await appRouter.createCaller(fixture.context).board.uploadImage({
dataUrl: `data:image/avif;base64,${avif.toString('base64')}`,
});
expect(result.url).toMatch(/^https:\/\/sam-image\.hided\.net\/uploads\/core2026\/[a-f0-9]{32}\.avif$/);
expect(upload).toHaveBeenCalledWith(expect.objectContaining({ contentType: 'image/avif', body: avif }));
expect(result).toMatchObject({ width: 64, height: 48, format: 'avif', animated: false });
});
it('rejects editor image uploads from an ordinary nation member', async () => {
const upload = vi.fn();
const fixture = buildContext({
@@ -204,9 +204,8 @@ integration('scenario 903 select pool through the durable turn daemon', () => {
await expect(
appRouter.createCaller(buildContext('select-pool-public-lobby')).lobby.info()
).resolves.toMatchObject({ selectionPoolEnabled: true });
await expect(
appRouter.createCaller(buildContext('select-pool-config')).join.getConfig()
).resolves.toMatchObject({
const joinConfig = await appRouter.createCaller(buildContext('select-pool-config')).join.getConfig();
expect(joinConfig).toMatchObject({
serverInfo: {
currentYear: 180,
currentMonth: 1,
@@ -392,6 +391,7 @@ integration('scenario 903 select pool through the durable turn daemon', () => {
const fullWorld = await db.worldState.findUniqueOrThrow({ where: { id: worldStateId } });
const fullConfig = fullWorld.config as Record<string, unknown>;
runtime!.world.updateWorldConfig({ maxGeneral: 1 });
await db.worldState.update({
where: { id: worldStateId },
data: { config: { ...fullConfig, maxGeneral: 1 } as GamePrisma.InputJsonValue },
@@ -427,6 +427,7 @@ integration('scenario 903 select pool through the durable turn daemon', () => {
})
).rejects.toMatchObject({ message: '더 이상 등록 할 수 없습니다.' });
expect(await db.general.count({ where: { userId: otherUserId } })).toBe(0);
runtime!.world.updateWorldConfig({ maxGeneral: joinConfig.serverInfo.maxGeneral });
await db.worldState.update({
where: { id: worldStateId },
data: { config: fullConfig as GamePrisma.InputJsonValue },
+1 -1
View File
@@ -489,7 +489,7 @@ export class InMemoryTurnWorld {
// Runtime callbacks created before the world keep the original object
// reference. Mutate this object in place so a live settings action is
// observed by monthly handlers without restarting the daemon.
this.worldConfig = snapshot.worldConfig ?? {};
this.worldConfig = snapshot.worldConfig ?? { ...snapshot.scenarioConfig };
this.unitSet = snapshot.unitSet;
this.schedule = options.schedule;
this.generalTurnHandler =
@@ -82,6 +82,18 @@ const buildWorld = (stateOverride: Partial<TurnWorldState> = {}): InMemoryTurnWo
};
describe('runtime clock shift', () => {
it('preserves the scenario config when the raw world config is unavailable', () => {
const world = buildWorld();
expect(world.getWorldConfig()).toMatchObject({
stat: { total: 300 },
iconPath: '',
map: {},
const: {},
environment: { mapName: 'test', unitSet: 'default' },
});
});
it.each([
['accelerates', -15, '2026-07-30T09:45:00.000Z', '2026-07-30T09:55:00.000Z'],
['delays', 15, '2026-07-30T10:15:00.000Z', '2026-07-30T10:25:00.000Z'],
@@ -35,6 +35,8 @@ const nationCommands = [
'che_물자원조',
];
const capitalCommands = ['che_증축', 'che_감축'];
const otherArgumentCommands = [
'che_증여',
'che_헌납',
@@ -58,7 +60,7 @@ const otherArgumentCommands = [
];
void test('provides Ref-level guidance for every in-scope argument command', () => {
const expected = [...cityCommands, ...nationCommands, ...otherArgumentCommands].sort();
const expected = [...cityCommands, ...nationCommands, ...capitalCommands, ...otherArgumentCommands].sort();
assert.deepEqual(presentedCommandKeys().sort(), expected);
for (const commandKey of expected) {
assert.ok(commandArgumentPresentation(commandKey).lines.join(' ').length >= 12, commandKey);
@@ -76,4 +78,7 @@ void test('marks the same city and nation target families that Ref renders with
for (const commandKey of nationCommands) {
assert.equal(commandArgumentPresentation(commandKey).mapTarget, 'nation', commandKey);
}
for (const commandKey of capitalCommands) {
assert.equal(commandArgumentPresentation(commandKey).mapTarget, 'capital', commandKey);
}
});
@@ -104,7 +104,7 @@ const table: CommandTable = {
},
};
test('Ref getBrief를 상속하는 출병·계략·모병까지 실제 인자 요약으로 표시한다', () => {
void test('Ref getBrief를 상속하는 출병·계략·모병까지 실제 인자 요약으로 표시한다', () => {
assert.equal(formatReservedCommandBrief('general', 'che_출병', { destCityId: 2 }, table), '【단양】으로 출병');
assert.equal(formatReservedCommandBrief('general', 'che_화계', { destCityId: 3 }, table), '【업】에 화계실행');
assert.equal(formatReservedCommandBrief('general', 'che_선동', { destCityId: 2 }, table), '【단양】에 선동실행');
@@ -114,7 +114,7 @@ test('Ref getBrief를 상속하는 출병·계략·모병까지 실제 인자
);
});
test('개인·인사·국가 명령의 Ref brief 변형을 보존한다', () => {
void test('개인·인사·국가 명령의 Ref brief 변형을 보존한다', () => {
const cases: Array<[string, Record<string, unknown>, string]> = [
['che_이동', { destCityId: 3 }, '【업】으로 이동'],
['che_강행', { destCityId: 2 }, '【단양】으로 강행'],
@@ -139,7 +139,7 @@ test('개인·인사·국가 명령의 Ref brief 변형을 보존한다', () =>
}
});
test('국가 명령의 도시·국가·장수·자원 인자를 Ref brief로 표시한다', () => {
void test('국가 명령의 도시·국가·장수·자원 인자를 Ref brief로 표시한다', () => {
const cases: Array<[string, Record<string, unknown>, string]> = [
['che_발령', { destGeneralId: 8, destCityId: 3 }, '【손권】【업】으로 발령'],
['che_부대탈퇴지시', { destGeneralId: 8 }, '【손권】부대 탈퇴 지시'],
@@ -177,7 +177,7 @@ test('국가 명령의 도시·국가·장수·자원 인자를 Ref brief로 표
);
});
test('Ref가 getBrief를 재정의하지 않은 명령은 실제 표시명을 유지한다', () => {
void test('Ref가 getBrief를 재정의하지 않은 명령은 실제 표시명을 유지한다', () => {
assert.equal(formatReservedCommandBrief('general', '휴식', {}, table), '휴식');
assert.equal(formatReservedCommandBrief('general', 'che_훈련', {}, table), '훈련');
assert.equal(formatReservedCommandBrief('nation', 'che_필사즉생', {}, table), '필사즉생');
+3 -3
View File
@@ -30,7 +30,7 @@
},
"dependencies": {
"@fastify/cors": "^11.2.0",
"@fastify/static": "^9.0.0",
"@fastify/static": "^10.1.3",
"@prisma/client": "^7.9.1",
"@sammo-ts/common": "workspace:*",
"@sammo-ts/game-engine": "workspace:*",
@@ -40,10 +40,10 @@
"date-fns": "^4.1.0",
"es-toolkit": "^1.43.0",
"fastify": "^5.6.2",
"pm2": "^5.4.3",
"pm2": "^7.0.3",
"redis": "^5.10.0",
"sanitize-html": "2.17.6",
"sharp": "^0.34.4",
"sharp": "^0.35.0",
"zod": "^4.3.5"
}
}
+3 -2
View File
@@ -202,7 +202,8 @@ export const accountRouter = router({
const profiles = await listIconSyncProfiles(ctx, user.id);
const buffer = decodeImage(input.imageData);
const metadata = await sharp(buffer, { animated: true }).metadata();
if (!metadata.format || !ALLOWED_ICON_FORMATS.has(metadata.format)) {
const detectedFormat = metadata.mediaType === 'image/avif' ? 'avif' : metadata.format;
if (!detectedFormat || !ALLOWED_ICON_FORMATS.has(detectedFormat)) {
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'avif, webp, jpg, gif, png 아이콘만 사용할 수 있습니다.',
@@ -214,7 +215,7 @@ export const accountRouter = router({
message: '아이콘은 64x64~128x128 범위의 정사각형이어야 합니다.',
});
}
const extension = metadata.format === 'jpeg' ? 'jpg' : metadata.format;
const extension = detectedFormat === 'jpeg' ? 'jpg' : detectedFormat;
const filename = `${randomBytes(16).toString('hex')}.${extension}`;
if (!ctx.userIconUpload) {
throw new TRPCError({ code: 'INTERNAL_SERVER_ERROR', message: '이미지 저장소가 설정되지 않았습니다.' });
+31
View File
@@ -1359,6 +1359,37 @@ describe('account self service', () => {
}
});
it('stores AVIF account icons with the public AVIF extension and media type', async () => {
const iconDir = await fs.mkdtemp(path.join(os.tmpdir(), 'sammo-account-icon-avif-'));
try {
const { caller, users, sessions, userIconUpload } = buildCaller({ userIconDir: iconDir });
const user = await users.createUser({
username: 'icon-avif',
password: 'current-password',
});
const session = await sessions.createSession(user);
const avif = await sharp({
create: { width: 64, height: 64, channels: 4, background: '#334455' },
})
.avif()
.toBuffer();
const result = await caller.account.changeIcon({
sessionToken: session.sessionToken,
imageData: `data:image/avif;base64,${avif.toString('base64')}`,
});
expect(result.iconUrl).toMatch(
/^https:\/\/sam-image\.hided\.net\/icons\/users\/core2026\/[a-f0-9]{32}\.avif$/
);
expect(userIconUpload.upload).toHaveBeenCalledWith(
expect.objectContaining({ contentType: 'image/avif', body: avif })
);
} finally {
await fs.rm(iconDir, { recursive: true, force: true });
}
});
it('atomically allows only one icon change per KST day and removes the losing file', async () => {
const iconDir = await fs.mkdtemp(path.join(os.tmpdir(), 'sammo-account-icon-race-'));
try {