mirror of
https://github.com/djdevin/recflare.git
synced 2026-10-25 23:18:51 -07:00
[econ] stub for consumables that do not exist here
This commit is contained in:
@@ -134,6 +134,7 @@ import {
|
|||||||
PurchaseRoomCurrencyRequest,
|
PurchaseRoomCurrencyRequest,
|
||||||
PurchaseRoomKeyWithCurrencyRequest,
|
PurchaseRoomKeyWithCurrencyRequest,
|
||||||
PurchaseRoomKeyWithCurrencyResponse,
|
PurchaseRoomKeyWithCurrencyResponse,
|
||||||
|
QueryConsumablesRequest,
|
||||||
ReferralProgressResponse,
|
ReferralProgressResponse,
|
||||||
RemoveInfluencerBody,
|
RemoveInfluencerBody,
|
||||||
RoomConsumableDto,
|
RoomConsumableDto,
|
||||||
@@ -4992,6 +4993,34 @@ const app = new Hono<App>({ strict: false })
|
|||||||
(c) => c.json(consumableDefinitions)
|
(c) => c.json(consumableDefinitions)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// STUB. The client's lookup of consumable definitions by descriptor
|
||||||
|
// (`?configurationVersion=2`), form-encoded with one repeated key:
|
||||||
|
// `descriptors=xfeDIDboPES-AS90CCn2xQ&descriptors=test_bad`. The answer is an array of
|
||||||
|
// definitions — `{ ConsumableItemDesc, InitialCount, CreatedAt, ThumbnailImageName,
|
||||||
|
// FriendlyName, RoomieCategory, ConsumableToolName, ConfigurationData }`, with
|
||||||
|
// `ConfigurationData` JSON escaped into a string as on `/all` — holding only the
|
||||||
|
// descriptors that resolve. Nothing here can resolve one yet, so every query answers [].
|
||||||
|
.post(
|
||||||
|
'/api/consumables/v1/query/bulk',
|
||||||
|
describeRoute({
|
||||||
|
tags: ['Consumables'],
|
||||||
|
summary: 'Look up consumable definitions by descriptor (stub)',
|
||||||
|
description: [
|
||||||
|
'STUB. Takes a form body repeating `descriptors` once per consumable descriptor and',
|
||||||
|
'answers the definitions that resolve. There is no lookup behind it yet, so the',
|
||||||
|
'answer is always []. configurationVersion is ignored.',
|
||||||
|
].join(' '),
|
||||||
|
requestBody: form(QueryConsumablesRequest, 'The descriptors to look up'),
|
||||||
|
responses: { 200: json(JsonArray, 'The matching definitions (always empty for now)') },
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
const body = await c.req.parseBody({ all: true }).catch(() => ({}) as Record<string, unknown>)
|
||||||
|
const descriptors = body['descriptors']
|
||||||
|
logger.info('consumable query/bulk (stub, nothing resolved)', { descriptors })
|
||||||
|
return c.json([])
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
// Unlocked consumables. [Authorize]. The consumables the player has bought (from
|
// Unlocked consumables. [Authorize]. The consumables the player has bought (from
|
||||||
// `buyItem`, stored in the `consumable` table), grouped by item into the client's
|
// `buyItem`, stored in the `consumable` table), grouped by item into the client's
|
||||||
// unlocked-consumable DTO. A player who has bought none gets an empty list.
|
// unlocked-consumable DTO. A player who has bought none gets an empty list.
|
||||||
|
|||||||
@@ -1299,6 +1299,17 @@ export const ConsumeConsumableRequest = z.object({
|
|||||||
DeltaCount: z.int().optional().describe('How many to spend; defaults to 1'),
|
DeltaCount: z.int().optional().describe('How many to spend; defaults to 1'),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `POST /api/consumables/v1/query/bulk` form body — `descriptors` repeated once per
|
||||||
|
* consumable to look up.
|
||||||
|
*/
|
||||||
|
export const QueryConsumablesRequest = z.object({
|
||||||
|
descriptors: z
|
||||||
|
.union([z.string(), z.array(z.string())])
|
||||||
|
.optional()
|
||||||
|
.describe('A ConsumableItemDesc; the key repeats for each one asked about'),
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `POST /api/consumables/v1/updateActive` JSON body — the client marking one of its
|
* `POST /api/consumables/v1/updateActive` JSON body — the client marking one of its
|
||||||
* consumables active or not. Accepted and NOT acted on yet; see the route.
|
* consumables active or not. Accepted and NOT acted on yet; see the route.
|
||||||
|
|||||||
@@ -3798,6 +3798,19 @@ describe('econ endpoints', () => {
|
|||||||
expect(await res.json()).toEqual([])
|
expect(await res.json()).toEqual([])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('POST /api/consumables/v1/query/bulk is a stub: resolves nothing, answers []', async () => {
|
||||||
|
const res = await exports.default.fetch(
|
||||||
|
`${ORIGIN}/api/consumables/v1/query/bulk?configurationVersion=2`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
|
body: 'descriptors=xfeDIDboPES-AS90CCn2xQ&descriptors=test_bad',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
expect(res.status).toBe(200)
|
||||||
|
expect(await res.json()).toEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
test('POST /api/consumables/v1/updateActive is a stub: auth-gated, stores nothing, answers nothing', async () => {
|
test('POST /api/consumables/v1/updateActive is a stub: auth-gated, stores nothing, answers nothing', async () => {
|
||||||
const before = await env.DB.prepare('SELECT * FROM consumable ORDER BY id').all()
|
const before = await env.DB.prepare('SELECT * FROM consumable ORDER BY id').all()
|
||||||
const body = { Id: 7550, IsActive: true, ActivatedByRoomie: false }
|
const body = { Id: 7550, IsActive: true, ActivatedByRoomie: false }
|
||||||
@@ -7391,6 +7404,7 @@ describe('econ endpoints', () => {
|
|||||||
'POST /api/checklist/v1/complete',
|
'POST /api/checklist/v1/complete',
|
||||||
'POST /api/checklist/v2/complete',
|
'POST /api/checklist/v2/complete',
|
||||||
'POST /api/consumables/v1/consume',
|
'POST /api/consumables/v1/consume',
|
||||||
|
'POST /api/consumables/v1/query/bulk',
|
||||||
'POST /api/consumables/v1/updateActive',
|
'POST /api/consumables/v1/updateActive',
|
||||||
'POST /api/distanceMovedRewardTracks/distance',
|
'POST /api/distanceMovedRewardTracks/distance',
|
||||||
'POST /api/equipment/v1/update',
|
'POST /api/equipment/v1/update',
|
||||||
|
|||||||
Reference in New Issue
Block a user