feat(imports): Access Pass products through the importer's signed-in account (#20)
Release / release (push) Successful in 4s
CI / test (push) Successful in 7m28s
CI / image (apps/api/Dockerfile, t5de-hub-api) (push) Successful in 5s
CI / image (apps/web/Dockerfile, t5de-hub-web) (push) Successful in 16s

Co-authored-by: dhkatz <[email protected]>
This commit was merged in pull request #20.
This commit is contained in:
dhkatz authored and dhkatz committed 2026-11-08 16:10:34 +00:00
1 parent 56d25f7507
commit cc6959082c
12 files changed
+4871 -51

No files matched your search

+52 -1
View File
@@ -406,17 +406,27 @@ export function createApp({
// A whole shop: when the hub last listed its products on IMVU (null: not yet), and how many IMVU listed.
shopListedAt: r.grant.shopListedAt?.toISOString() ?? null,
shopListed: r.grant.shopListed,
shopListedSignedIn: r.grant.shopListedSignedIn,
status: r.grant.status as "pending" | "active" | "declined" | "suspended" | "withdrawn",
statusReason: r.grant.statusReason,
createdAt: r.grant.createdAt.toISOString(),
decidedAt: r.grant.decidedAt?.toISOString() ?? null,
});
/** A product as an importer's IMVU account sees it. */
const seenProduct = t.Object({
id: t.Integer({ minimum: 1 }),
name: t.String({ maxLength: 200 }),
rating: t.Union([t.Literal("general"), t.Literal("adult")]),
creatorId: t.Integer({ minimum: 1 }),
creatorName: t.String({ maxLength: 64 }),
purchasable: t.Boolean(),
});
const jobView = (j: typeof schema.importJob.$inferSelect) => ({
id: j.id,
grant: j.grantId,
imvuProduct: j.imvuProduct,
kind: j.kind as "import" | "recheck",
kind: j.kind as "import" | "recheck" | "list",
status: j.status as "queued" | "claimed" | "done" | "failed",
imvuRevision: j.imvuRevision,
reason: j.reason,
@@ -1943,6 +1953,45 @@ export function createApp({
},
{ body: t.Object({ imvuRevision: t.Integer({ minimum: 1 }) }) },
)
.post(
"/importer/jobs/:id/listing",
async ({ request, params, body }) => {
const c = await imports.importerFor(request.headers.get("authorization"));
if (!c) throw new Problem(401, "forbidden", "Not an importer of an approved catalog with imports on.");
return productCall(() => imports.reportListing(c, params.id, body.products));
},
{ body: t.Object({ products: t.Array(seenProduct, { maxItems: 10000 }) }) },
)
.post(
"/importer/jobs/:id/info",
async ({ request, params, body }) => {
const c = await imports.importerFor(request.headers.get("authorization"));
if (!c) throw new Problem(401, "forbidden", "Not an importer of an approved catalog with imports on.");
return productCall(() =>
imvuSafe(() =>
imports.reportInfo(c, params.id, {
id: 0,
found: body.found,
name: body.name ?? "",
rating: body.rating ?? "general",
creatorId: body.creatorId ?? 0,
creatorName: body.creatorName ?? "",
purchasable: body.purchasable ?? true,
}),
),
);
},
{
body: t.Object({
found: t.Boolean(),
name: t.Optional(t.String({ maxLength: 200 })),
rating: t.Optional(t.Union([t.Literal("general"), t.Literal("adult")])),
creatorId: t.Optional(t.Integer({ minimum: 1 })),
creatorName: t.Optional(t.String({ maxLength: 64 })),
purchasable: t.Optional(t.Boolean()),
}),
},
)
.post(
"/importer/jobs/:id",
async ({ request, params, body }) => {
@@ -1986,6 +2035,8 @@ export function createApp({
const c = await imports.importerFor(request.headers.get("authorization"));
if (!c) throw new Problem(401, "forbidden", "Not an importer of an approved catalog with imports on.");
const a = await productCall(() => importers.report(c, params.id, body));
// An account signed in with Access Pass: list the catalog's whole shops with it (Access Pass products too).
if (body.state === "ok" && body.accessPass) await imports.queueListings(c.id);
return { account: importerAccountView(a) };
},
{