@drfed/graphql 0.2.0-dev.712 → 0.2.0-dev.716

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/README.md CHANGED
@@ -75,13 +75,57 @@ when addressed to the public (section 5.6):
75
75
 
76
76
  `as:Public` and `Public` count as the public as well as its full IRI. What the
77
77
  viewer may not read is left out as if it did not exist: `node` and `nodes`
78
- return null for it, as do `Resource.detail` and `Activity.object`, and
79
- `Actor.objects`, `Object.activities`, and `Collection.items` leave it out
80
- before paging, so that neither cursors nor `totalCount` tell of it.
78
+ return null for it, as does `Resource.detail`, and `Actor.objects`,
79
+ `Object.activities`, and `Collection.items` leave it out before paging, so
80
+ that neither cursors nor `totalCount` tell of it. A `Resource`, which a
81
+ history is read through, is returned by `node`, `Activity.object`, and the
82
+ `resource` of relations and recipients also when the viewer may read any of
83
+ its revisions; see below.
81
84
 
82
85
  [ActivityPub]: https://www.w3.org/TR/activitypub/
83
86
 
84
87
 
88
+ Resource revisions
89
+ ------------------
90
+
91
+ `Resource.currentRevision` and `Resource.revisions`, newest first, return the
92
+ saved revisions of any resource, including those saved without legacy
93
+ details; `node` and `nodes` look up a `ResourceRevision` by its ID.
94
+ `ResourceRevision.document` is the saved JSON as is, and `root` describes it
95
+ by meaning: each `DocumentNode`, the root or one embedded at any depth, has
96
+ its type IRI, its own `id` or `href`, its relations and recipients in source
97
+ order, and its custom extension properties. A relation or recipient names
98
+ the resource currently registered under its IRI, opened as
99
+ `Activity.object` is, while `node` keeps the embedded value as saved. When
100
+ the validator cannot read the document, `interpreted` is false and
101
+ `diagnostics` tell why.
102
+
103
+ Each revision is read by evidence of its own: anyone reads local revisions,
104
+ blind recipients included, and revisions addressed to the public; members of
105
+ a local instance read what a delivery to it carried; and a revision without
106
+ such evidence is readable only while it is current and its resource is, as
107
+ above. A `Resource` with a revision the viewer may read is found even when
108
+ its current state is restricted, while its typed details stay hidden.
109
+ Where a revision's embedded documents came from never hides it.
110
+ Deletion hides no revision by itself, while `Resource.detail` and the other
111
+ existing fields keep hiding what was deleted; `Actor.objects` lists deleted
112
+ objects, with `Object.deleted`, only when its filter sets `includeDeleted`.
113
+ `Resource.revision(sequence:)` returns one revision by its sequence.
114
+ `DocumentNode.source` names the revision an embedded document came from,
115
+ whether it keeps that revision's contents or was derived from it, and whether
116
+ that revision is still current, superseded, or deleted; it is null when the
117
+ viewer may not read the source revision, and nothing else of the document
118
+ changes. See [resource revision internals].
119
+
120
+ `unreadableRevisions(viewer, ids)` in `@drfed/graphql/readable` tells which
121
+ revisions a viewer may not read by the same rule. Pass it to
122
+ `previewLocalWrite()` and `commitLocalWrite()` of
123
+ `@drfed/federation/local-write`, which check that a writer declares as
124
+ sources only revisions they may read.
125
+
126
+ [resource revision internals]: https://drfed.org/internals/resource-revisions#graphql-reads
127
+
128
+
85
129
  Login mail and shutdown
86
130
  -----------------------
87
131
 
package/dist/account.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as builder } from "./builder-BLioFAdv.mjs";
1
+ import { n as builder } from "./builder-BrcxJqIz.mjs";
2
2
  import { Instance } from "./instance.mjs";
3
3
  import { instanceMembers } from "@drfed/models/schema";
4
4
  import { drizzleConnectionHelpers } from "@pothos/plugin-drizzle";
@@ -1,5 +1,5 @@
1
- import { n as builder } from "../builder-BLioFAdv.mjs";
2
- import { a as readableResource, o as viewableInstance } from "../readable-CSN0MPlO.mjs";
1
+ import { n as builder } from "../builder-BrcxJqIz.mjs";
2
+ import { readableResource, viewableInstance } from "../readable.mjs";
3
3
  import { activityDeliveryDirectionEnum } from "@drfed/models/schema";
4
4
  import { drizzleConnectionHelpers } from "@pothos/plugin-drizzle";
5
5
  //#region src/activity-delivery/entry.ts
@@ -1,5 +1,5 @@
1
- import { n as builder } from "./builder-BLioFAdv.mjs";
2
- import { a as readableResource, r as isReadableResource } from "./readable-CSN0MPlO.mjs";
1
+ import { n as builder } from "./builder-BrcxJqIz.mjs";
2
+ import { isReadableResource, isReadableResourceNode, readableResource, visibleResource } from "./readable.mjs";
3
3
  import { Instance } from "./instance.mjs";
4
4
  import { classificationAuthor, classificationInput, classifyMastodon, classifyMisskey } from "./classification.mjs";
5
5
  import { actorTypeEnum } from "@drfed/models/schema";
@@ -218,9 +218,9 @@ const Activity = builder.drizzleNode("activities", {
218
218
  object: t.field({
219
219
  type: Resource,
220
220
  nullable: true,
221
- description: "The resource the activity acts on, or null when there is none or the viewer may not read it.",
221
+ description: "The resource the activity acts on, or null when there is none or the viewer may read neither it nor any of its revisions.",
222
222
  select: { with: { object: true } },
223
- resolve: async (row, _, ctx) => row.object != null && await isReadableResource(ctx, row.object.id) ? row.object : null
223
+ resolve: async (row, _, ctx) => row.object != null && await isReadableResourceNode(ctx, row.object.id) ? row.object : null
224
224
  }),
225
225
  expectedClassifications: t.field({
226
226
  type: [ExpectedClassification],
@@ -261,30 +261,6 @@ const Activity = builder.drizzleNode("activities", {
261
261
  })
262
262
  });
263
263
  registerAddressingFields("activities");
264
- /**
265
- * Excludes deleted actors and objects, including resources authored or
266
- * owned by deleted actors.
267
- * @returns A predicate for a resource ID in an outer query.
268
- */
269
- function visibleResource(id) {
270
- return sql`not exists (
271
- select 1 from ${schema.actors}
272
- where ${schema.actors.id} = ${id} and ${schema.actors.deleted} is not null
273
- ) and not exists (
274
- select 1 from ${schema.objects}
275
- join ${schema.actors} on ${schema.actors.id} = ${schema.objects.actorId}
276
- where ${schema.objects.id} = ${id}
277
- and (${schema.objects.deleted} is not null or ${schema.actors.deleted} is not null)
278
- ) and not exists (
279
- select 1 from ${schema.activities}
280
- join ${schema.actors} on ${schema.actors.id} = ${schema.activities.actorId}
281
- where ${schema.activities.id} = ${id} and ${schema.actors.deleted} is not null
282
- ) and not exists (
283
- select 1 from ${schema.collections}
284
- join ${schema.actors} on ${schema.actors.id} = ${schema.collections.ownerActorId}
285
- where ${schema.collections.id} = ${id} and ${schema.actors.deleted} is not null
286
- )`;
287
- }
288
264
  //#endregion
289
265
  //#region src/actor.ts
290
266
  const ActorType = builder.enumType("ActorType", { values: actorTypeEnum.enumValues });
@@ -593,6 +569,6 @@ builder.drizzleObjectField("instances", "actors", (t) => t.connection({
593
569
  };
594
570
  } }));
595
571
  //#endregion
596
- export { ResourceDetail as a, ActivityType as i, LocalActor as n, registerAddressingFields as o, Activity as r, Actor as t };
572
+ export { Resource as a, ActivityType as i, LocalActor as n, ResourceDetail as o, Activity as r, registerAddressingFields as s, Actor as t };
597
573
 
598
- //# sourceMappingURL=actor-B1FAD_C_.mjs.map
574
+ //# sourceMappingURL=actor-Bd7xAMeW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor-Bd7xAMeW.mjs","names":["and","eq","uuid"],"sources":["../src/resource.ts","../src/actor.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { activitySelection, objectSelection } from \"@drfed/federation/object\";\nimport { schema } from \"@drfed/models\";\nimport type { Resource as ResourceRow } from \"@drfed/models/schema\";\nimport { type Uuid, validateUuid } from \"@drfed/models/uuid\";\nimport { PothosValidationError } from \"@pothos/core\";\nimport { resolveCursorConnection } from \"@pothos/plugin-relay\";\nimport { type SQL, type SQLWrapper, and, eq, sql } from \"drizzle-orm\";\n\nimport builder, { type DrFedObjectRef } from \"./builder.ts\";\nimport {\n classificationAuthor,\n classificationInput,\n classifyMastodon,\n classifyMisskey,\n} from \"./classification.ts\";\nimport {\n type Viewer,\n isReadableResource,\n isReadableResourceNode,\n readableResource,\n visibleResource,\n} from \"./readable.ts\";\n\nexport const ResourceKind = builder.enumType(\"ResourceKind\", {\n values: schema.resourceKindEnum.enumValues,\n});\nexport const ResourceDetail = builder.unionType(\"ResourceDetail\", {\n types: () => [Activity, Collection],\n resolveType: async (value, ctx) => {\n const { id } = value as { id: Uuid };\n const row = await ctx.db.query.resources.findFirst({ where: { id } });\n if (row == null || row.kind === \"unknown\") {\n throw new Error(\"Missing typed resource.\");\n }\n return (\n {\n actor: \"Actor\",\n object: \"Object\",\n activity: \"Activity\",\n collection: \"Collection\",\n } as const\n )[row.kind];\n },\n});\nconst ResourceRef = builder.drizzleNode(\"resources\", {\n name: \"Resource\",\n id: { column: (row) => row.id },\n fields: (t) => ({\n iri: t.expose(\"iri\", { type: \"URL\" }),\n kind: t.expose(\"kind\", { type: ResourceKind }),\n detail: t.field({\n type: ResourceDetail,\n nullable: true,\n description:\n \"Typed details, or null while unknown, when the typed row or its author/owner is deleted, or when the viewer may not read it.\",\n select: { columns: { id: true, iri: true, kind: true } },\n resolve: (row, _, ctx) => resolveResource(ctx, row),\n }),\n }),\n});\nexport const Resource: DrFedObjectRef = ResourceRef;\n\n/**\n * Loads the typed record so union fragments see the complete entity.\n * @returns The typed entity, or null when it or its author is deleted, or when\n * the viewer may not read it.\n */\nexport async function resolveResource(\n viewer: Viewer,\n row: ResourceRow,\n): Promise<{ id: Uuid } | null> {\n const { db } = viewer;\n const visible = await db.query.resources.findFirst({\n where: {\n id: row.id,\n RAW: (table) =>\n and(visibleResource(table.id), readableResource(viewer, table.id))!,\n },\n columns: { id: true },\n });\n if (visible == null) return null;\n if (row.kind === \"unknown\") return null;\n const where = { id: row.id };\n const result =\n row.kind === \"actor\"\n ? await db.query.actors.findFirst({ where })\n : row.kind === \"object\"\n ? await db.query.objects.findFirst({ where })\n : row.kind === \"activity\"\n ? await db.query.activities.findFirst({ where })\n : await db.query.collections.findFirst({ where });\n // Generic revision-backed resources have no legacy typed details yet.\n return result ?? null;\n}\n\nexport function registerAddressingFields(\n table: \"objects\" | \"activities\",\n): void {\n for (const property of schema.addressingPropertyEnum.enumValues) {\n builder.drizzleObjectField(table, property, (t) =>\n t.field({\n type: [Resource],\n description: `Stored ${property} occurrences, in original order including duplicates.`,\n select: { columns: { id: true } },\n resolve: async (row, _, ctx) =>\n (\n await ctx.db.query.addressing.findMany({\n where: { sourceId: row.id, property },\n orderBy: { position: \"asc\" },\n with: { targetResource: true },\n })\n ).map((entry) => entry.targetResource),\n }),\n );\n }\n}\n\nconst CollectionType = builder.enumType(\"CollectionType\", {\n values: schema.collectionTypeEnum.enumValues,\n});\nconst CollectionRef = builder.drizzleNode(\"collections\", {\n name: \"Collection\",\n select: {\n columns: { id: true },\n with: { ownerActor: { columns: { deleted: true } } },\n },\n id: { column: (row) => row.id },\n fields: (t) => ({\n resource: t.relation(\"resource\"),\n iri: t.field({\n type: \"URL\",\n select: { with: { resource: true } },\n resolve: (row) => row.resource.iri,\n }),\n type: t.expose(\"type\", { type: CollectionType }),\n owner: t.relation(\"ownerActor\", {\n nullable: true,\n query: { where: { deleted: { isNull: true } } },\n }),\n declaredTotalItems: t.exposeInt(\"totalItems\", {\n nullable: true,\n description:\n \"The `totalItems` reported by the collection document. It can differ from the locally observed count and is null for local collections. Unlike `totalCount` and `items`, this value is not recalculated when deleted actors, deleted objects, or resources authored by deleted actors are excluded.\",\n }),\n totalCount: t.int({\n description:\n \"The number of locally stored, visible members. It can differ from `declaredTotalItems`. Deleted actors, deleted objects, resources authored by deleted actors, and resources the viewer may not read are excluded from this count and `items`.\",\n select: { columns: { id: true } },\n resolve: (row, _, ctx) =>\n ctx.db.$count(\n schema.collectionItems,\n and(\n eq(schema.collectionItems.collectionId, row.id),\n visibleResource(schema.collectionItems.itemId),\n readableResource(ctx, schema.collectionItems.itemId),\n ),\n ),\n }),\n items: t.connection({\n type: Resource,\n description:\n \"The locally stored, visible members. Deleted actors, deleted objects, resources authored by deleted actors, and resources the viewer may not read are excluded from this connection and `totalCount`.\",\n select: { columns: { id: true } },\n resolve: (row, args, ctx) => {\n const positions = new Map<Uuid, number | null>();\n return resolveCursorConnection<Promise<ResourceRow[]>>(\n {\n args,\n toCursor: (item: ResourceRow) => {\n if (!positions.has(item.id)) {\n throw new Error(\"Missing collection item position.\");\n }\n return encodeCollectionCursor({\n position: positions.get(item.id)!,\n itemId: item.id,\n });\n },\n },\n async ({ before, after, limit, inverted }) => {\n const parsedBefore =\n before == null ? undefined : parseCollectionCursor(before);\n const parsedAfter =\n after == null ? undefined : parseCollectionCursor(after);\n const items = await ctx.db.query.collectionItems.findMany({\n where: {\n collectionId: row.id,\n RAW: (table) =>\n and(\n visibleResource(table.itemId),\n readableResource(ctx, table.itemId),\n collectionCursorPredicate(\n table.position,\n table.itemId,\n parsedBefore,\n parsedAfter,\n ),\n )!,\n },\n orderBy: collectionItemsOrder(inverted),\n limit,\n with: { item: true },\n });\n for (const item of items) {\n positions.set(item.itemId, item.position);\n }\n return items.map((item) => item.item);\n },\n );\n },\n }),\n }),\n});\nexport const Collection: DrFedObjectRef = CollectionRef;\n\ninterface CollectionCursor {\n position: number | null;\n itemId: Uuid;\n}\n\nconst BASE64_PATTERN =\n /^(?:[A-Za-z\\d+/]{4})*(?:[A-Za-z\\d+/]{2}==|[A-Za-z\\d+/]{3}=)?$/u;\n\nfunction encodeCollectionCursor(cursor: CollectionCursor): string {\n return Buffer.from(JSON.stringify([cursor.position, cursor.itemId])).toString(\n \"base64\",\n );\n}\n\nfunction parseCollectionCursor(cursor: string): CollectionCursor {\n if (cursor === \"\" || !BASE64_PATTERN.test(cursor)) {\n throw new PothosValidationError(\"Invalid collection cursor.\");\n }\n const decoded = Buffer.from(cursor, \"base64\");\n if (decoded.toString(\"base64\") !== cursor) {\n throw new PothosValidationError(\"Invalid collection cursor.\");\n }\n let value: unknown;\n try {\n value = JSON.parse(decoded.toString(\"utf8\"));\n } catch {\n throw new PothosValidationError(\"Invalid collection cursor.\");\n }\n if (!Array.isArray(value) || value.length !== 2) {\n throw new PothosValidationError(\"Invalid collection cursor.\");\n }\n const [position, itemId] = value;\n if (\n (position !== null &&\n (!Number.isInteger(position) ||\n position < -2_147_483_648 ||\n position > 2_147_483_647)) ||\n !validateUuid(itemId)\n ) {\n throw new PothosValidationError(\"Invalid collection cursor.\");\n }\n return { position, itemId };\n}\n\nfunction collectionCursorPredicate(\n positionColumn: SQLWrapper,\n itemIdColumn: SQLWrapper,\n before?: CollectionCursor,\n after?: CollectionCursor,\n): SQL | undefined {\n return and(\n after == null\n ? undefined\n : after.position == null\n ? sql`${positionColumn} is null and ${itemIdColumn} > ${after.itemId}`\n : sql`(\n ${positionColumn} > ${after.position}\n or (${positionColumn} = ${after.position} and ${itemIdColumn} > ${after.itemId})\n or ${positionColumn} is null\n )`,\n before == null\n ? undefined\n : before.position == null\n ? sql`(\n ${positionColumn} is not null\n or (${positionColumn} is null and ${itemIdColumn} < ${before.itemId})\n )`\n : sql`(\n ${positionColumn} < ${before.position}\n or (${positionColumn} = ${before.position} and ${itemIdColumn} < ${before.itemId})\n )`,\n );\n}\n\nfunction collectionItemsOrder(inverted: boolean): {\n position: \"asc\" | \"desc\";\n itemId: \"asc\" | \"desc\";\n} {\n // The keyset predicates rely on PostgreSQL's default ASC NULLS LAST and\n // DESC NULLS FIRST ordering.\n const direction = inverted ? \"desc\" : \"asc\";\n return { position: direction, itemId: direction };\n}\n\nconst Implementation = builder.enumType(\"Implementation\", {\n values: [\"MASTODON\", \"MISSKEY\"] as const,\n});\nconst ExpectedClassification = builder.objectRef<\n ReturnType<typeof classifyMastodon>\n>(\"ExpectedClassification\");\nExpectedClassification.implement({\n description:\n \"Expected classification; actual access depends on receiver state and policy.\",\n fields: (t) => ({\n implementation: t.expose(\"implementation\", { type: Implementation }),\n version: t.exposeString(\"version\"),\n classification: t.exposeString(\"classification\"),\n reason: t.exposeString(\"reason\"),\n }),\n});\nexport const ActivityType = builder.enumType(\"ActivityType\", {\n values: schema.activityTypeEnum.enumValues,\n});\nconst ActivityRef = builder.drizzleNode(\"activities\", {\n name: \"Activity\",\n description:\n \"Represents an ActivityPub activity. An activity of a local actor is \" +\n \"readable whatever its addressing. One of a remote actor is readable \" +\n \"only when it is addressed to the public, by members of the local \" +\n \"instances that received it, and by administrators; otherwise it is \" +\n \"left out as if it did not exist.\",\n select: {\n columns: { id: true },\n with: { actor: { columns: { deleted: true } } },\n },\n id: { column: (row) => row.id },\n fields: (t) => ({\n resource: t.relation(\"resource\"),\n iri: t.field({\n type: \"URL\",\n select: { with: { resource: true } },\n resolve: (row) => row.resource.iri,\n }),\n type: t.expose(\"type\", { type: ActivityType }),\n actor: t.relation(\"actor\"),\n object: t.field({\n type: Resource,\n nullable: true,\n description:\n \"The resource the activity acts on, or null when there is none or \" +\n \"the viewer may read neither it nor any of its revisions.\",\n select: { with: { object: true } },\n resolve: async (row, _, ctx) =>\n row.object != null && (await isReadableResourceNode(ctx, row.object.id))\n ? row.object\n : null,\n }),\n expectedClassifications: t.field({\n type: [ExpectedClassification],\n description:\n \"Expected classifications for this activity and its Object. Empty if the object is absent, hidden, or not an Object.\",\n select: { columns: { id: true } },\n resolve: async (activity, _, ctx) => {\n const row = await ctx.db.query.activities.findFirst({\n where: { id: activity.id },\n with: activitySelection,\n });\n // As hidden from this viewer as `object` is, its addressing included.\n if (\n row?.objectId == null ||\n !(await isReadableResource(ctx, row.objectId))\n ) {\n return [];\n }\n const object = await ctx.db.query.objects.findFirst({\n where: {\n id: row.objectId,\n deleted: { isNull: true },\n actor: { deleted: { isNull: true } },\n },\n with: {\n ...objectSelection,\n actor: {\n with: {\n resource: true,\n collectionReferences: {\n with: { collection: { with: { resource: true } } },\n },\n },\n },\n },\n });\n if (object == null) return [];\n const addressing = classificationInput(object);\n const input = classificationInput(row);\n const author = classificationAuthor(object.actor);\n return [\n classifyMastodon(addressing, input, author),\n classifyMisskey(addressing, input, author),\n ];\n },\n }),\n published: t.expose(\"published\", { type: \"DateTime\" }),\n document: t.expose(\"document\", { type: \"JSON\", nullable: true }),\n }),\n});\nexport const Activity: DrFedObjectRef = ActivityRef;\nregisterAddressingFields(\"activities\");\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\n// oxlint-disable max-lines-per-function eslint/max-lines\n\n// Keep dependent database writes and observations sequential.\n// oxlint-disable no-await-in-loop\n\nimport { enqueueActorKeyGeneration } from \"@drfed/federation\";\nimport { type Database, promoteResource, schema } from \"@drfed/models\";\nimport { type CollectionRole, actorTypeEnum } from \"@drfed/models/schema\";\nimport { type Uuid, uuidV7 as uuid } from \"@drfed/models/uuid\";\nimport { faker } from \"@faker-js/faker\";\nimport type { Context } from \"@fedify/fedify\";\nimport { drizzleConnectionHelpers } from \"@pothos/plugin-drizzle\";\nimport type { PgInsertValue } from \"drizzle-orm/pg-core\";\nimport { and, eq, gt, isNotNull, isNull } from \"drizzle-orm/sql/expressions\";\n\nimport builder, { type DrFedObjectRef } from \"./builder.ts\";\nimport { Instance } from \"./instance.ts\";\nimport { Collection, ResourceDetail } from \"./resource.ts\";\n\nconst ActorType = builder.enumType(\"ActorType\", {\n values: actorTypeEnum.enumValues,\n});\n\nconst ACTOR_TYPES_DOC = actorTypeEnum.enumValues\n .map((t) => `\\`${t}\\``)\n .join(\" | \");\n\nasync function resolveActorCollection(\n db: Database,\n actorId: Uuid,\n role: CollectionRole,\n) {\n const reference = await db.query.actorCollectionReferences.findFirst({\n where: { actorId, role },\n with: {\n collection: {\n with: { ownerActor: { columns: { deleted: true } } },\n },\n },\n });\n const collection = reference?.collection;\n return collection?.ownerActor?.deleted == null ? (collection ?? null) : null;\n}\n\nconst USERNAME_DOC =\n \"The username of the `Actor`. A remote actor's is its \" +\n \"`preferredUsername` as received, which is null when it has none and \" +\n \"need not be unique.\";\n\nconst ActorRef = builder.drizzleNode(\"actors\", {\n name: \"Actor\",\n description: \"Represents an `Actor` in the DrFed platform.\",\n id: {\n column: ({ id }) => id,\n description: \"The unique identifier of the `Actor`.\",\n },\n fields: (t) => ({\n resource: t.relation(\"resource\"),\n iri: t.field({\n type: \"URL\",\n select: { with: { resource: true } },\n resolve: (row) => row.resource.iri,\n }),\n uuid: t.expose(\"id\", {\n type: \"UUID\",\n description: \"The UUID of the `Actor`.\",\n }),\n handle: t.field({\n type: \"String\",\n nullable: true,\n description:\n \"The handle of the `Actor`, its `username` and its `Instance`'s \" +\n \"host. For a remote actor, this is not a verified WebFinger \" +\n \"address. Null when `username` is.\",\n select: {\n columns: { username: true },\n with: { instance: { columns: { host: true } } },\n },\n resolve: ({ instance, username }) =>\n username == null ? null : `@${username}@${instance.host}`,\n }),\n type: t.expose(\"type\", {\n type: ActorType,\n description: `The type of the \\`Actor\\`: ${ACTOR_TYPES_DOC}`,\n }),\n username: t.exposeString(\"username\", {\n nullable: true,\n description: USERNAME_DOC,\n }),\n instance: t.relation(\"instance\", {\n description: \"The `Instance` that the `Actor` belongs to.\",\n }),\n local: t.relation(\"localActor\", {\n nullable: true,\n description: \"The local details of the `Actor`, or null if it is remote.\",\n }),\n inboxUrl: t.expose(\"inboxUrl\", {\n type: \"URL\",\n description: \"The inbox URL of the `Actor`.\",\n }),\n outbox: t.field({\n type: Collection,\n nullable: true,\n description:\n \"The stored outbox collection. For local actors, it contains every stored `Create` activity regardless of addressing and retains activities whose objects are deleted so their recorded history remains inspectable. The ActivityPub outbox serves only activities with Public addressing whose objects are not deleted.\",\n select: { columns: { id: true } },\n resolve: (actor, _, ctx) =>\n resolveActorCollection(ctx.db, actor.id, \"outbox\"),\n }),\n avatarUrl: t.expose(\"avatarUrl\", {\n type: \"URL\",\n description: \"The avatar URL of the `Actor`.\",\n nullable: true,\n }),\n followers: t.field({\n type: Collection,\n nullable: true,\n select: { columns: { id: true } },\n resolve: (actor, _, ctx) =>\n resolveActorCollection(ctx.db, actor.id, \"followers\"),\n }),\n following: t.field({\n type: Collection,\n nullable: true,\n select: { columns: { id: true } },\n resolve: (actor, _, ctx) =>\n resolveActorCollection(ctx.db, actor.id, \"following\"),\n }),\n headerUrl: t.expose(\"headerUrl\", {\n type: \"URL\",\n description: \"The header URL of the `Actor`.\",\n nullable: true,\n }),\n profileUrl: t.expose(\"profileUrl\", {\n type: \"URL\",\n description: \"The profile URL of the `Actor`.\",\n nullable: true,\n }),\n featured: t.field({\n type: Collection,\n nullable: true,\n select: { columns: { id: true } },\n resolve: (actor, _, ctx) =>\n resolveActorCollection(ctx.db, actor.id, \"featured\"),\n }),\n created: t.expose(\"created\", {\n type: \"DateTime\",\n description: \"The creation date/time of the `Actor`.\",\n }),\n }),\n});\n\nexport const Actor: DrFedObjectRef = ActorRef;\nResourceDetail.addTypes([Actor]);\n\nconst LocalActorRef = builder.drizzleNode(\"localActors\", {\n name: \"LocalActor\",\n select: {\n columns: { id: true },\n with: { actor: { columns: { deleted: true } } },\n },\n description: \"Represents the local details of an `Actor`.\",\n id: {\n column: ({ id }) => id,\n description: \"The unique identifier of the local actor details.\",\n },\n fields: (t) => ({\n uuid: t.expose(\"id\", {\n type: \"UUID\",\n description: \"The UUID of the local actor details.\",\n }),\n avatar: t.exposeString(\"avatar\", {\n nullable: true,\n description: \"The profile image of the actor.\",\n }),\n header: t.exposeString(\"header\", {\n nullable: true,\n description: \"The profile banner image of the actor.\",\n }),\n }),\n});\n\nexport const LocalActor: DrFedObjectRef = LocalActorRef;\n\ninterface CreateActorsSuccess {\n readonly actors: readonly (typeof ActorRef.$inferType)[];\n}\n\nconst CreateActorsSuccessRef = builder.objectRef<CreateActorsSuccess>(\n \"CreateActorsSuccess\",\n);\n\nCreateActorsSuccessRef.implement({\n fields: (t) => ({\n actors: t.field({\n type: [ActorRef],\n resolve: ({ actors }) => actors,\n }),\n }),\n});\n\nconst INVALID_SIZE = \"InvalidSize\" as const;\nconst INSTANCE_NOT_FOUND = \"InstanceNotFound\" as const;\nconst INVALID_INSTANCE_HOST = \"InvalidInstanceHost\" as const;\nconst TOO_MANY_ACTORS = \"TooManyActors\" as const;\nconst CreateActorsErrors = [\n INVALID_SIZE,\n INSTANCE_NOT_FOUND,\n INVALID_INSTANCE_HOST,\n TOO_MANY_ACTORS,\n] as const;\n\nconst CreateActorsErrorType = builder.enumType(\"CreateActorsErrorType\", {\n values: CreateActorsErrors,\n});\n\ninterface CreateActorsError {\n readonly type: typeof CreateActorsErrorType.$inferType;\n readonly message: string;\n}\n\nconst CreateActorsErrorRef =\n builder.objectRef<CreateActorsError>(\"CreateActorsError\");\n\nCreateActorsErrorRef.implement({\n description: \"Represents an error that occurred while creating an `Actor`.\",\n fields: (t) => ({\n type: t.expose(\"type\", {\n type: CreateActorsErrorType,\n description:\n \"The type of the error. Use this for programmatic error handling.\",\n }),\n message: t.exposeString(\"message\", {\n description:\n \"A human-readable message describing the error. \" +\n \"Don't use this for programmatic error handling, \" +\n \"use the `type` field instead.\",\n }),\n }),\n});\n\nconst CreateActorsResult = builder.unionType(\"CreateActorsResult\", {\n types: [CreateActorsSuccessRef, CreateActorsErrorRef],\n resolveType(value) {\n if (\"message\" in value) return CreateActorsErrorRef;\n return CreateActorsSuccessRef;\n },\n});\n\nbuilder.mutationFields((t) => ({\n generateActors: t.field({\n type: CreateActorsResult,\n description: \"Create actors.\",\n authScopes: { authenticated: true },\n args: {\n instance: t.arg.globalID({\n for: Instance,\n required: true,\n description: \"The ID of the target instance\",\n }),\n size: t.arg({\n type: \"Int\",\n required: true,\n description: \"How many actors to generate\",\n }),\n },\n async resolve(_query, { instance: { id: instanceId }, size }, ctx) {\n if (size < 1) {\n return {\n type: INVALID_SIZE,\n message: `${size} is too small. At least 1 or more.`,\n };\n }\n if (ctx.account == null) {\n // Note that the following error is not expected to be thrown,\n // because the `authScopes` option above should prevent this resolver\n throw new Error(\"You must be authenticated to create actors.\");\n }\n const { account } = ctx;\n // Relay decodes global IDs as strings; Instance uses UUID identifiers.\n const targetInstanceId = instanceId as Uuid;\n\n let createdOrigin: URL | undefined;\n const result = await ctx.db.transaction(async (tx) => {\n // Find the instance that the account is included\n const [instance] = await tx\n .select({\n host: schema.instances.host,\n maxActors: schema.localInstances.maxActors,\n })\n .from(schema.instanceMembers)\n .for(\"update\", { of: schema.localInstances })\n .innerJoin(\n schema.instances,\n eq(schema.instanceMembers.instanceId, schema.instances.id),\n )\n .innerJoin(\n schema.localInstances,\n eq(schema.instances.localId, schema.localInstances.id),\n )\n .where(\n and(\n eq(schema.instanceMembers.accountId, account.id),\n gt(schema.localInstances.expires, Temporal.Now.instant()),\n eq(schema.instances.id, targetInstanceId),\n isNotNull(schema.instanceMembers.accepted),\n ),\n )\n .limit(1);\n if (instance == null) {\n return {\n type: INSTANCE_NOT_FOUND,\n message: \"Can't find the instance.\",\n };\n }\n // Read the stored authority rather than recomposing it from the\n // slug, so that actor URIs cannot drift from the instance the rest of\n // the fediverse already knows.\n const { host, maxActors } = instance;\n const instanceUrl = `${ctx.rootOrigin.protocol}//${host}`;\n // Stored authorities can outlive the runtime that accepted them.\n if (!URL.canParse(instanceUrl)) {\n return {\n type: INVALID_INSTANCE_HOST,\n message:\n `The instance host ${JSON.stringify(host)} cannot be parsed by ` +\n \"this server. Contact the server administrator.\",\n };\n }\n const currActors = await tx.$count(\n schema.actors,\n eq(schema.actors.instanceId, targetInstanceId),\n );\n\n if (size + currActors > maxActors) {\n return {\n type: TOO_MANY_ACTORS,\n message: `${size} is too big. The maximum number of actors of ${\n host\n } is ${maxActors} and the current number of actors is ${\n currActors\n }.`,\n };\n }\n // Create actors\n createdOrigin = new URL(instanceUrl);\n const fedCtx = ctx.federation.createContext(\n new URL(instanceUrl),\n undefined,\n );\n const ids = Array.from({ length: size }, () => ({ id: uuid() }));\n await tx.insert(schema.localActors).values(ids);\n const createdActors = [];\n for (const { id } of ids) {\n const actor = await promoteResource(\n tx,\n fedCtx.getActorUri(id).href,\n \"actor\",\n async (inner, resource) => {\n for (let attempt = 0; attempt < 10; attempt += 1) {\n const [createdActor] = await inner\n .insert(schema.actors)\n .values(generateActor(resource.id, targetInstanceId, fedCtx))\n .onConflictDoNothing({\n target: [schema.actors.username, schema.actors.instanceId],\n // Only the partial index of local actors' usernames.\n where: isNotNull(schema.actors.localId),\n })\n .returning();\n if (createdActor != null) {\n return createdActor;\n }\n }\n throw new Error(\"Actor insertion returned no row.\");\n },\n id,\n );\n for (const [role, iri] of [\n [\"followers\", fedCtx.getFollowersUri(id).href],\n [\"following\", fedCtx.getFollowingUri(id).href],\n [\"featured\", fedCtx.getFeaturedUri(id).href],\n [\"outbox\", fedCtx.getOutboxUri(id).href],\n ] as const) {\n await promoteResource(\n tx,\n iri,\n \"collection\",\n async (inner, resource) => {\n await inner.insert(schema.collections).values({\n id: resource.id,\n type: \"OrderedCollection\",\n ownerActorId: actor.id,\n });\n await inner.insert(schema.actorCollectionReferences).values({\n actorId: actor.id,\n role,\n collectionId: resource.id,\n });\n },\n );\n }\n createdActors.push(actor);\n }\n return { actors: createdActors };\n });\n if (\"actors\" in result && createdOrigin != null) {\n await enqueueActorKeyGeneration(\n ctx.federation.createContext(createdOrigin, undefined),\n result.actors.map((actor) => actor.id),\n );\n }\n return result;\n },\n }),\n}));\n\nfunction generateActor(\n id: Uuid,\n instanceId: Uuid,\n fedCtx: Context<unknown>,\n): PgInsertValue<typeof schema.actors> {\n const username = faker.internet\n .username()\n .toLowerCase()\n .replace(/[^a-z0-9_]/gu, \"_\");\n\n return {\n id,\n localId: id,\n username,\n instanceId,\n type: \"Person\",\n inboxUrl: fedCtx.getInboxUri(id).href,\n profileUrl: new URL(`/@${username}`, fedCtx.origin).href,\n };\n}\n\nconst actorsConnection = drizzleConnectionHelpers(builder, \"actors\", {\n query: { orderBy: { created: \"desc\", id: \"desc\" } },\n});\n\nbuilder.drizzleObjectField(\"instances\", \"actors\", (t) =>\n t.connection(\n {\n type: Actor,\n description: \"The `Actor`s that belong to the `Instance`.\",\n select(args, ctx, nestedSelection) {\n return {\n with: {\n actors: actorsConnection.getQuery(args, ctx, nestedSelection),\n },\n };\n },\n resolve(instance, args, ctx) {\n return {\n ...actorsConnection.resolve(instance.actors, args, ctx, instance),\n totalCount() {\n return ctx.db.$count(\n schema.actors,\n and(\n eq(schema.actors.instanceId, instance.id),\n isNull(schema.actors.deleted),\n ),\n );\n },\n };\n },\n },\n {\n fields(fb) {\n return {\n totalCount: fb.int({\n description:\n \"The total number of `Actor`s that belong to the `Instance`.\",\n resolve(connection) {\n return connection.totalCount();\n },\n }),\n };\n },\n },\n {\n fields(fb) {\n return {\n created: fb.expose(\"created\", {\n type: \"DateTime\",\n description:\n \"The date/time when the `Actor` was added to the `Instance`.\",\n }),\n type: fb.expose(\"type\", {\n type: ActorType,\n description: `The type of the \\`Actor\\`: ${ACTOR_TYPES_DOC}`,\n }),\n username: fb.exposeString(\"username\", {\n nullable: true,\n description: USERNAME_DOC,\n }),\n };\n },\n },\n ),\n);\n"],"mappings":";;;;;;;;;;;;;;;;AAuCA,MAAa,eAAe,QAAQ,SAAS,gBAAgB,EAC3D,QAAQ,OAAO,iBAAiB,WAClC,CAAC;AACD,MAAa,iBAAiB,QAAQ,UAAU,kBAAkB;CAChE,aAAa,CAAC,UAAU,UAAU;CAClC,aAAa,OAAO,OAAO,QAAQ;EACjC,MAAM,EAAE,OAAO;EACf,MAAM,MAAM,MAAM,IAAI,GAAG,MAAM,UAAU,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;EACpE,IAAI,OAAO,QAAQ,IAAI,SAAS,WAC9B,MAAM,IAAI,MAAM,yBAAyB;EAE3C,OACE;GACE,OAAO;GACP,QAAQ;GACR,UAAU;GACV,YAAY;EACd,EACA,IAAI;CACR;AACF,CAAC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AAO,OAAO,CAC9B,CACF;GACF;EACF;CACF;AACF,GACA,EACE,OAAO,IAAI;CACT,OAAO,EACL,YAAY,GAAG,IAAI;EACjB,aACE;EACF,QAAQ,YAAY;GAClB,OAAO,WAAW,WAAW;EAC/B;CACF,CAAC,EACH;AACF,EACF,GACA,EACE,OAAO,IAAI;CACT,OAAO;EACL,SAAS,GAAG,OAAO,WAAW;GAC5B,MAAM;GACN,aACE;EACJ,CAAC;EACD,MAAM,GAAG,OAAO,QAAQ;GACtB,MAAM;GACN,aAAa,8BAA8B;EAC7C,CAAC;EACD,UAAU,GAAG,aAAa,YAAY;GACpC,UAAU;GACV,aAAa;EACf,CAAC;CACH;AACF,EACF,CACF,CACF"}
package/dist/actor.mjs CHANGED
@@ -1 +1 @@
1
- export { t as Actor, n as LocalActor } from "./actor-B1FAD_C_.mjs";
1
+ export { t as Actor, n as LocalActor } from "./actor-Bd7xAMeW.mjs";
@@ -1,4 +1,4 @@
1
- import { i as memberInstances, n as hideUnreadableNodes } from "./readable-CSN0MPlO.mjs";
1
+ import { hideUnreadableNodes, memberInstances, owningResourceOf } from "./readable.mjs";
2
2
  import { instances } from "@drfed/models/schema";
3
3
  import DrizzlePlugin from "@pothos/plugin-drizzle";
4
4
  import { eq } from "drizzle-orm/sql/expressions";
@@ -58,10 +58,10 @@ const builder = new SchemaBuilder({
58
58
  errors: { defaultTypes: [] },
59
59
  relay: {
60
60
  nodeQueryOptions: { resolve: async (_, { id }, ctx, __, resolveNode) => {
61
- const [node] = await hideUnreadableNodes(ctx, [filterDeleted(await resolveNode(id))]);
61
+ const [node] = await hideHiddenNodes(ctx, [id], [await resolveNode(id)]);
62
62
  return node;
63
63
  } },
64
- nodesQueryOptions: { resolve: async (_, { ids }, ctx, __, resolveNodes) => await hideUnreadableNodes(ctx, (await resolveNodes(ids)).map(filterDeleted)) }
64
+ nodesQueryOptions: { resolve: async (_, { ids }, ctx, __, resolveNodes) => await hideHiddenNodes(ctx, ids, await resolveNodes(ids)) }
65
65
  },
66
66
  scopeAuth: {
67
67
  authorizeOnSubscribe: true,
@@ -82,6 +82,8 @@ const builder = new SchemaBuilder({
82
82
  const isDeleted = (node) => node != null && typeof node === "object" && "deleted" in node && node.deleted != null;
83
83
  const OWNER_RELATIONS = ["actor", "ownerActor"];
84
84
  const filterDeleted = (node) => isDeleted(node) || node != null && typeof node === "object" && OWNER_RELATIONS.some((key) => isDeleted(node[key])) ? null : node;
85
+ const RESOURCE_TYPENAME = "Resource";
86
+ const hideHiddenNodes = (context, ids, nodes) => hideUnreadableNodes(context, nodes.map((node) => owningResourceOf(node) == null ? filterDeleted(node) : node), ids.map(({ typename }) => typename === RESOURCE_TYPENAME));
85
87
  /**
86
88
  * Determines whether the viewer is an accepted member of the `Instance` that
87
89
  * the given `LocalInstance` backs. Pending members, i.e. those who have been
@@ -149,4 +151,4 @@ const Node = builder.nodeInterfaceRef();
149
151
  //#endregion
150
152
  export { builder as n, Node as t };
151
153
 
152
- //# sourceMappingURL=builder-BLioFAdv.mjs.map
154
+ //# sourceMappingURL=builder-BrcxJqIz.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder-BrcxJqIz.mjs","names":["OperationsPlugin"],"sources":["../src/operations.ts","../src/builder.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport SchemaBuilder, { BasePlugin, type SchemaTypes } from \"@pothos/core\";\nimport type {\n GraphQLFieldResolver,\n GraphQLIsTypeOfFn,\n GraphQLTypeResolver,\n} from \"graphql\";\n\n/** Track the lifetime of work that may outlive a cancelled HTTP request. */\nexport type OperationTracker = <T>(\n operation: () => T | Promise<T>,\n) => Promise<T>;\n\nclass OperationsPlugin<Types extends SchemaTypes> extends BasePlugin<Types> {\n // Pothos requires an instance hook even when the wrapper has no plugin state.\n // oxlint-disable-next-line class-methods-use-this\n override wrapResolve(\n resolve: GraphQLFieldResolver<unknown, Types[\"Context\"], object>,\n ): GraphQLFieldResolver<unknown, Types[\"Context\"], object> {\n return (parent, args, context, info) => {\n const { trackOperation } = context as {\n trackOperation?: OperationTracker;\n };\n return trackOperation == null\n ? resolve(parent, args, context, info)\n : trackOperation(() => resolve(parent, args, context, info));\n };\n }\n // Pothos dispatches abstract type resolution separately from field resolution.\n // oxlint-disable-next-line class-methods-use-this\n override wrapResolveType(\n resolveType: GraphQLTypeResolver<unknown, Types[\"Context\"]>,\n ): GraphQLTypeResolver<unknown, Types[\"Context\"]> {\n return (parent, context, info, type) => {\n const { trackOperation } = context as {\n trackOperation?: OperationTracker;\n };\n return trackOperation == null\n ? resolveType(parent, context, info, type)\n : trackOperation(() => resolveType(parent, context, info, type));\n };\n }\n\n // ScopeAuth performs type-level authorization through this separate hook.\n // oxlint-disable-next-line class-methods-use-this\n override wrapIsTypeOf(\n isTypeOf: GraphQLIsTypeOfFn<unknown, Types[\"Context\"]> | undefined,\n ): GraphQLIsTypeOfFn<unknown, Types[\"Context\"]> | undefined {\n if (isTypeOf == null) return isTypeOf;\n return (parent, context, info) => {\n const { trackOperation } = context as {\n trackOperation?: OperationTracker;\n };\n return trackOperation == null\n ? isTypeOf(parent, context, info)\n : trackOperation(() => isTypeOf(parent, context, info));\n };\n }\n}\n\ndeclare global {\n // Pothos registers plugin types through this namespace.\n // oxlint-disable-next-line typescript/no-namespace\n namespace PothosSchemaTypes {\n interface Plugins<Types extends SchemaTypes> {\n drfedOperations: OperationsPlugin<Types>;\n }\n }\n}\n\nSchemaBuilder.registerPlugin(\"drfedOperations\", OperationsPlugin);\n\nexport default \"drfedOperations\" as const;\n","// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport { type Database, normalizeEmail, relations } from \"@drfed/models\";\nimport { type Account, type Session, instances } from \"@drfed/models/schema\";\nimport type { Uuid } from \"@drfed/models/uuid\";\nimport type { Federation } from \"@fedify/fedify\";\nimport { Template } from \"@fedify/uri-template\";\nimport SchemaBuilder, { type ObjectRef } from \"@pothos/core\";\nimport DrizzlePlugin from \"@pothos/plugin-drizzle\";\nimport ErrorsPlugin from \"@pothos/plugin-errors\";\nimport RelayPlugin from \"@pothos/plugin-relay\";\nimport ScopeAuthPlugin from \"@pothos/plugin-scope-auth\";\nimport type { Transport } from \"@upyo/core\";\nimport { getTableConfig } from \"drizzle-orm/pg-core\";\nimport { eq } from \"drizzle-orm/sql/expressions\";\nimport { GraphQLScalarType, Kind } from \"graphql\";\nimport { JSONResolver, URLResolver, UUIDResolver } from \"graphql-scalars\";\n\nimport OperationsPlugin, { type OperationTracker } from \"./operations.ts\";\nimport {\n hideUnreadableNodes,\n memberInstances,\n owningResourceOf,\n} from \"./readable.ts\";\n\n/**\n * The context data for the GraphQL server, which includes the incoming request\n * object and any additional information needed for processing GraphQL queries\n * and mutations.\n */\nexport interface ServerContext {\n /** Combined request and runtime shutdown cancellation for active work. */\n readonly operationSignal?: AbortSignal | undefined;\n\n /** Optional runtime owner for work that survives HTTP cancellation. */\n readonly trackOperation?: OperationTracker | undefined;\n\n /**\n * The incoming HTTP request.\n */\n readonly request: Request;\n\n /**\n * The database instance.\n */\n readonly db: Database;\n\n /**\n * Email sending services.\n */\n readonly mailer: Transport;\n\n /**\n * The address login mail is sent from.\n */\n readonly emailFrom: string;\n\n /**\n * Origins for login.\n */\n readonly loginOrigins: ReadonlySet<string>;\n\n /**\n * The root origin of this deployment, which every instance's subdomain is\n * derived from. It is always equal to its own origin, i.e. it carries no\n * path, query or credentials.\n */\n readonly rootOrigin: URL;\n\n /**\n * The federation instance.\n */\n readonly federation: Federation<unknown>;\n}\n\n/**\n * The user-related context data for the GraphQL server, which include every\n * field from the {@link ServerContext}.\n */\nexport interface UserContext extends ServerContext {\n /**\n * Session information.\n */\n readonly session?: Session;\n\n /**\n * Current viewer.\n */\n readonly account?: Account;\n}\n\nexport interface SchemaTypes {\n Context: UserContext;\n Scalars: {\n JSON: { Input: unknown; Output: unknown };\n DateTime: {\n Input: Temporal.Instant;\n Output: Temporal.Instant;\n };\n Email: {\n Input: string;\n Output: string;\n };\n UUID: {\n Input: Uuid;\n Output: Uuid;\n };\n URITemplate: {\n Input: Template;\n Output: Template;\n };\n URL: {\n Input: string;\n Output: string;\n };\n };\n DefaultFieldNullability: false;\n DrizzleRelations: typeof relations;\n AuthScopes: {\n authenticated: boolean;\n admin: boolean;\n /**\n * Whether the viewer is an accepted member of the `Instance` backed by\n * the `LocalInstance` with the given UUID.\n */\n localInstanceMember: Uuid;\n /**\n * Whether the viewer is the `Account` with the given UUID.\n */\n accountSelf: Uuid;\n };\n}\n\nexport type DrFedSchemaTypes =\n PothosSchemaTypes.ExtendDefaultTypes<SchemaTypes>;\n\nexport type DrFedObjectRef<Shape = unknown, Parent = Shape> = ObjectRef<\n DrFedSchemaTypes,\n Shape,\n Parent\n>;\n\n/**\n * The GraphQL schema builder.\n */\nexport const builder = new SchemaBuilder<SchemaTypes>({\n defaultFieldNullability: false,\n drizzle: {\n client(ctx) {\n return ctx.db;\n },\n getTableConfig,\n relations,\n },\n plugins: [\n OperationsPlugin,\n DrizzlePlugin,\n RelayPlugin,\n ErrorsPlugin,\n ScopeAuthPlugin,\n ],\n errors: { defaultTypes: [] },\n relay: {\n nodeQueryOptions: {\n resolve: async (_, { id }, ctx, __, resolveNode) => {\n const [node] = await hideHiddenNodes(\n ctx,\n [id],\n [await resolveNode(id)],\n );\n return node;\n },\n },\n nodesQueryOptions: {\n resolve: async (_, { ids }, ctx, __, resolveNodes) =>\n await hideHiddenNodes(ctx, ids, await resolveNodes(ids)),\n },\n },\n scopeAuth: {\n authorizeOnSubscribe: true,\n authScopes(context) {\n return {\n authenticated: Boolean(context.session),\n admin: Boolean(context.account?.admin),\n localInstanceMember(localInstanceId) {\n return isLocalInstanceMember(context, localInstanceId);\n },\n accountSelf(accountId) {\n return context.account?.id === accountId;\n },\n };\n },\n },\n});\n\nconst isDeleted = (node: unknown): boolean =>\n node != null &&\n typeof node === \"object\" &&\n \"deleted\" in node &&\n node.deleted != null;\n\n// Relations whose deletion hides the node: an object's or activity's\n// author, or a collection's owner.\nconst OWNER_RELATIONS = [\"actor\", \"ownerActor\"] as const;\n\nconst filterDeleted = (node: unknown): unknown =>\n isDeleted(node) ||\n (node != null &&\n typeof node === \"object\" &&\n OWNER_RELATIONS.some((key) =>\n isDeleted((node as Record<string, unknown>)[key]),\n ))\n ? null\n : node;\n\nconst RESOURCE_TYPENAME = \"Resource\";\n\n// A node that belongs to a resource, such as a revision, is hidden by its own\n// readability, by hideUnreadableNodes(); its own deletion time, as that of a\n// whiteout, tells of the history it records and hides nothing. A `Resource`\n// node, which shares its ID with the typed node of the same resource, is\n// told apart by the typename its global ID names.\nconst hideHiddenNodes = (\n context: UserContext,\n ids: readonly { readonly typename: string }[],\n nodes: readonly unknown[],\n): Promise<unknown[]> =>\n hideUnreadableNodes(\n context,\n nodes.map((node) =>\n owningResourceOf(node) == null ? filterDeleted(node) : node,\n ),\n ids.map(({ typename }) => typename === RESOURCE_TYPENAME),\n );\n\n/**\n * Determines whether the viewer is an accepted member of the `Instance` that\n * the given `LocalInstance` backs. Pending members, i.e. those who have been\n * invited but have not accepted yet, do not count.\n *\n * Pothos caches scope results per request by scope name and parameter, so this\n * runs at most once per `LocalInstance` per request.\n *\n * @param context The request context, whose `account` is the viewer.\n * @param localInstanceId The UUID of the `LocalInstance` to check.\n * @returns Whether the viewer is an accepted member.\n */\nasync function isLocalInstanceMember(\n context: UserContext,\n localInstanceId: Uuid,\n): Promise<boolean> {\n const { account } = context;\n if (account == null) return false;\n const rows = await memberInstances(\n context.db,\n account.id,\n eq(instances.localId, localInstanceId),\n ).limit(1);\n return rows.length > 0;\n}\n\nbuilder.scalarType(\"DateTime\", {\n description: \"An ISO 8601 instant preserving sub-millisecond precision.\",\n serialize(value) {\n if (!(value instanceof Temporal.Instant)) {\n throw new TypeError(\"Expected a Temporal.Instant.\");\n }\n return value.toString();\n },\n parseValue(value) {\n if (typeof value !== \"string\") {\n throw new TypeError(\"Expected an instant string.\");\n }\n return Temporal.Instant.from(value);\n },\n parseLiteral(node) {\n if (node.kind !== Kind.STRING) {\n throw new TypeError(\"Expected an instant string.\");\n }\n return Temporal.Instant.from(node.value);\n },\n});\nbuilder.addScalarType(\n \"URL\",\n new GraphQLScalarType({\n ...URLResolver.toConfig(),\n serialize(value) {\n URLResolver.serialize(value);\n return String(value);\n },\n // Validate URLs while preserving the caller's exact spelling.\n parseValue(value) {\n URLResolver.parseValue(value);\n return String(value);\n },\n parseLiteral(node, variables) {\n URLResolver.parseLiteral(node, variables);\n if (node.kind !== Kind.STRING) {\n throw new TypeError(\"Expected a URL string.\");\n }\n return node.value;\n },\n }),\n);\nbuilder.addScalarType(\"JSON\", JSONResolver);\n\nbuilder.scalarType(\"Email\", {\n parseValue: (v) => normalizeEmail(String(v)),\n serialize: (v) => normalizeEmail(v),\n});\n\nbuilder.addScalarType(\"UUID\", UUIDResolver);\n\nbuilder.scalarType(\"URITemplate\", {\n parseValue(v) {\n if (v instanceof Template) {\n return v;\n }\n return Template.parse(String(v));\n },\n serialize(v) {\n return v.toString();\n },\n});\n\nexport const Node = builder.nodeInterfaceRef();\n\nexport default builder;\n"],"mappings":";;;;;;;;;;;;;;AA4BA,IAAM,mBAAN,cAA0D,WAAkB;CAG1E,YACE,SACyD;EACzD,QAAQ,QAAQ,MAAM,SAAS,SAAS;GACtC,MAAM,EAAE,mBAAmB;GAG3B,OAAO,kBAAkB,OACrB,QAAQ,QAAQ,MAAM,SAAS,IAAI,IACnC,qBAAqB,QAAQ,QAAQ,MAAM,SAAS,IAAI,CAAC;EAC/D;CACF;CAGA,gBACE,aACgD;EAChD,QAAQ,QAAQ,SAAS,MAAM,SAAS;GACtC,MAAM,EAAE,mBAAmB;GAG3B,OAAO,kBAAkB,OACrB,YAAY,QAAQ,SAAS,MAAM,IAAI,IACvC,qBAAqB,YAAY,QAAQ,SAAS,MAAM,IAAI,CAAC;EACnE;CACF;CAIA,aACE,UAC0D;EAC1D,IAAI,YAAY,MAAM,OAAO;EAC7B,QAAQ,QAAQ,SAAS,SAAS;GAChC,MAAM,EAAE,mBAAmB;GAG3B,OAAO,kBAAkB,OACrB,SAAS,QAAQ,SAAS,IAAI,IAC9B,qBAAqB,SAAS,QAAQ,SAAS,IAAI,CAAC;EAC1D;CACF;AACF;AAYA,cAAc,eAAe,mBAAmB,gBAAgB;;;;;;AC0EhE,MAAa,UAAU,IAAI,cAA2B;CACpD,yBAAyB;CACzB,SAAS;EACP,OAAO,KAAK;GACV,OAAO,IAAI;EACb;EACA;EACA;CACF;CACA,SAAS;EACPA;EACA;EACA;EACA;EACA;CACF;CACA,QAAQ,EAAE,cAAc,CAAC,EAAE;CAC3B,OAAO;EACL,kBAAkB,EAChB,SAAS,OAAO,GAAG,EAAE,MAAM,KAAK,IAAI,gBAAgB;GAClD,MAAM,CAAC,QAAQ,MAAM,gBACnB,KACA,CAAC,EAAE,GACH,CAAC,MAAM,YAAY,EAAE,CAAC,CACxB;GACA,OAAO;EACT,EACF;EACA,mBAAmB,EACjB,SAAS,OAAO,GAAG,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;WAKA,cAAc;;;;;;WAOd,YAAY;;;;WAKZ,YAAY;;;;;;UAON,oBAAoB;;;;WAI1B,UAAU;;;;WAKV,UAAU;;UAGJA;EACf,SAAS;EACT;IACE;MAAQ;MAAgB;;IACxB;MACE,OAAO,SAAS;MAChB,QAAQ,SAAS;;IAEnB;MACE;MACA;;IAEF;MACE,OAAO;MACP,QAAQ;;IAEV;MACE,OAAO;MACP,QAAQ;;IAEV;MACE;MACA;;;EAGJ;EACA,yBAAyB;EACzB;IACE;IACA;;;;;IAKA,qBAAqB;;;;IAIrB,aAAa;;;KAIL,mBACV,kBAAkB,mBAAmBA;KAE3B,eAAe,iBAAiB,SAAS,SAAS,UAC5D,kBACA,OACA;;;;cAMW,SAAO,kBAAA,cAAA,kBAAA,mBAAAA;cAoLP,MAAI,kBAAA,aAAA,kBAAA,mBAAAA"}
package/dist/builder.mjs CHANGED
@@ -1 +1 @@
1
- export { t as Node, n as builder, n as default } from "./builder-BLioFAdv.mjs";
1
+ export { t as Node, n as builder, n as default } from "./builder-BrcxJqIz.mjs";
@@ -1,4 +1,4 @@
1
- import { t as PUBLIC_IRIS } from "./readable-CSN0MPlO.mjs";
1
+ import { PUBLIC_IRIS } from "./readable.mjs";
2
2
  //#region src/classification.ts
3
3
  const isPublic = (iri) => PUBLIC_IRIS.includes(iri);
4
4
  /**
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as hashSecret, t as schema } from "./schema-f-SnZVb9.mjs";
1
+ import { n as hashSecret, t as schema } from "./schema-eJO_-DWq.mjs";
2
2
  import { canonicalHostname } from "@drfed/federation/origin";
3
3
  import { getYogaLogger } from "@logtape/graphql-yoga";
4
4
  import { getLogger } from "@logtape/logtape";
package/dist/instance.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as builder } from "./builder-BLioFAdv.mjs";
1
+ import { n as builder } from "./builder-BrcxJqIz.mjs";
2
2
  import { instanceHost } from "@drfed/federation/origin";
3
3
  import { eq } from "drizzle-orm/sql/expressions";
4
4
  import { schema } from "@drfed/models";
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.mts","names":[],"sources":["../src/object.ts"],"mappings":";;cAiIa,mBAAmB"}
1
+ {"version":3,"file":"object.d.mts","names":[],"sources":["../src/object.ts"],"mappings":";;cA0Ia,mBAAmB"}
package/dist/object.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { n as builder } from "./builder-BLioFAdv.mjs";
2
- import { a as readableResource } from "./readable-CSN0MPlO.mjs";
3
- import { a as ResourceDetail, i as ActivityType, o as registerAddressingFields, r as Activity, t as Actor } from "./actor-B1FAD_C_.mjs";
1
+ import { n as builder } from "./builder-BrcxJqIz.mjs";
2
+ import { readableResource } from "./readable.mjs";
3
+ import { i as ActivityType, o as ResourceDetail, r as Activity, s as registerAddressingFields, t as Actor } from "./actor-Bd7xAMeW.mjs";
4
4
  import { objectTypeEnum } from "@drfed/models/schema";
5
5
  import { drizzleConnectionHelpers } from "@pothos/plugin-drizzle";
6
6
  import { schema } from "@drfed/models";
@@ -101,6 +101,11 @@ const ObjectRef = builder.drizzleNode("objects", {
101
101
  created: t.expose("created", {
102
102
  type: "DateTime",
103
103
  description: "The time the object was stored in DrFed, distinct from its publication time."
104
+ }),
105
+ deleted: t.expose("deleted", {
106
+ type: "DateTime",
107
+ nullable: true,
108
+ description: "When the object was deleted, or null while it is not. Only `Actor.objects` returns deleted objects, when its filter includes them; its revisions, a whiteout last, stay readable through `resource`."
104
109
  })
105
110
  })
106
111
  });
@@ -127,8 +132,20 @@ builder.drizzleObjectField("objects", "activities", (t) => t.connection({
127
132
  },
128
133
  resolve: (object, args, ctx) => activitiesConnection.resolve(object.activities, args, ctx, object)
129
134
  }));
130
- const objectsConnection = drizzleConnectionHelpers(builder, "objects", { query: (_, ctx) => ({
131
- where: { RAW: (table) => readableResource(ctx, table.id) },
135
+ const ActorObjectFilter = builder.inputType("ActorObjectFilter", {
136
+ description: "Narrows the objects `Actor.objects` lists.",
137
+ fields: (t) => ({ includeDeleted: t.boolean({
138
+ required: true,
139
+ defaultValue: false,
140
+ description: "Whether deleted objects are listed too, so that their histories can be inspected."
141
+ }) })
142
+ });
143
+ const includesDeleted = (filter) => filter?.includeDeleted === true;
144
+ const objectsConnection = drizzleConnectionHelpers(builder, "objects", { query: ({ filter }, ctx) => ({
145
+ where: {
146
+ ...includesDeleted(filter) ? {} : { deleted: { isNull: true } },
147
+ RAW: (table) => readableResource(ctx, table.id)
148
+ },
132
149
  orderBy: {
133
150
  published: "desc",
134
151
  id: "desc"
@@ -136,7 +153,8 @@ const objectsConnection = drizzleConnectionHelpers(builder, "objects", { query:
136
153
  }) });
137
154
  builder.drizzleObjectField("actors", "objects", (t) => t.connection({
138
155
  type: ActivityPubObject,
139
- description: "Non-deleted objects the viewer may read, newest publication first. A local actor's objects are readable whatever their addressing; see `Object` for a remote actor's.",
156
+ args: { filter: t.arg({ type: ActorObjectFilter }) },
157
+ description: "Objects the viewer may read, newest publication first, without deleted ones unless the filter includes them. A local actor's objects are readable whatever their addressing; see `Object` for a remote actor's.",
140
158
  select(args, ctx, nestedSelection) {
141
159
  return { with: { objects: objectsConnection.getQuery(args, ctx, nestedSelection) } };
142
160
  },
@@ -144,14 +162,14 @@ builder.drizzleObjectField("actors", "objects", (t) => t.connection({
144
162
  return {
145
163
  ...objectsConnection.resolve(actor.objects, args, ctx, actor),
146
164
  totalCount() {
147
- return ctx.db.$count(schema.objects, and(eq(schema.objects.actorId, actor.id), isNull(schema.objects.deleted), readableResource(ctx, schema.objects.id)));
165
+ return ctx.db.$count(schema.objects, and(eq(schema.objects.actorId, actor.id), includesDeleted(args.filter) ? void 0 : isNull(schema.objects.deleted), readableResource(ctx, schema.objects.id)));
148
166
  }
149
167
  };
150
168
  }
151
169
  }, {
152
170
  name: "ObjectConnection",
153
171
  fields: (fb) => ({ totalCount: fb.int({
154
- description: "The number of non-deleted objects authored by this actor that the viewer may read.",
172
+ description: "The number of objects authored by this actor that the viewer may read, counted with the same filter as the list.",
155
173
  resolve: (connection) => connection.totalCount()
156
174
  }) })
157
175
  }, { name: "ObjectEdge" }));
@@ -1 +1 @@
1
- {"version":3,"file":"object.mjs","names":[],"sources":["../src/object.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport {\n createLegacyObject,\n isLocalWriteError,\n} from \"@drfed/federation/local-write\";\nimport { schema } from \"@drfed/models\";\nimport { objectTypeEnum } from \"@drfed/models/schema\";\nimport { validateUuid } from \"@drfed/models/uuid\";\nimport { drizzleConnectionHelpers } from \"@pothos/plugin-drizzle\";\nimport { and, eq, isNull } from \"drizzle-orm\";\n\nimport { Actor } from \"./actor.ts\";\nimport builder, { type DrFedObjectRef } from \"./builder.ts\";\nimport { readableResource } from \"./readable.ts\";\nimport {\n Activity,\n ActivityType,\n ResourceDetail,\n registerAddressingFields,\n} from \"./resource.ts\";\n\nconst ObjectType = builder.enumType(\"ObjectType\", {\n values: objectTypeEnum.enumValues,\n});\nconst AddressingInput = builder.inputType(\"AddressingInput\", {\n fields: (t) => ({\n to: t.field({ type: [\"URL\"], required: true, defaultValue: [] }),\n cc: t.field({ type: [\"URL\"], required: true, defaultValue: [] }),\n bto: t.field({ type: [\"URL\"], required: true, defaultValue: [] }),\n bcc: t.field({ type: [\"URL\"], required: true, defaultValue: [] }),\n audience: t.field({ type: [\"URL\"], required: true, defaultValue: [] }),\n }),\n});\nconst ObjectRef = builder.drizzleNode(\"objects\", {\n name: \"Object\",\n select: {\n columns: { id: true, deleted: true },\n with: { actor: { columns: { deleted: true } } },\n },\n description:\n \"Represents an ActivityPub object authored by an `Actor`. An object of \" +\n \"a local actor is readable whatever its addressing. One of a remote \" +\n \"actor is readable only when it or the activity it was received in is \" +\n \"addressed to the public, by members of the local instances that \" +\n \"received that activity and the object as stored with it, and by \" +\n \"administrators; otherwise it is left out as if it did not exist.\",\n id: {\n column: ({ id }) => id,\n description: \"The Relay global ID of the object.\",\n },\n fields: (t) => ({\n resource: t.relation(\"resource\"),\n iri: t.field({\n type: \"URL\",\n select: { with: { resource: true } },\n resolve: (row) => row.resource.iri,\n }),\n uuid: t.expose(\"id\", {\n type: \"UUID\",\n description: \"The UUID of the ActivityPub Object.\",\n }),\n url: t.expose(\"url\", {\n type: \"URL\",\n nullable: true,\n description: \"The human-readable page URL, if available.\",\n }),\n type: t.expose(\"type\", {\n type: ObjectType,\n description: \"The ActivityStreams vocabulary type: Note or Article.\",\n }),\n actor: t.relation(\"actor\", {\n description: \"The actor that authored the object.\",\n }),\n document: t.expose(\"document\", {\n type: \"JSON\",\n nullable: true,\n description:\n \"The JSON-LD document of the object. For a remote object embedded in the Create that delivered it, the object as received; null when it was not found within the first 64 places of that document, in which case the document of the Create, reachable through activities, holds it as received.\",\n }),\n name: t.exposeString(\"name\", {\n nullable: true,\n description: \"The optional title of the object.\",\n }),\n summary: t.exposeString(\"summary\", {\n nullable: true,\n description: \"The optional summary or content warning.\",\n }),\n contentHtml: t.exposeString(\"contentHtml\", {\n description:\n \"HTML preserved verbatim. Clients must sanitize it before browser rendering.\",\n }),\n language: t.exposeString(\"language\", {\n nullable: true,\n description:\n \"The canonical BCP 47 tag used for contentMap, if specified.\",\n }),\n sensitive: t.exposeBoolean(\"sensitive\", {\n description: \"Whether the content is marked sensitive.\",\n }),\n published: t.expose(\"published\", {\n type: \"DateTime\",\n description: \"The ActivityStreams publication time.\",\n }),\n updated: t.expose(\"updated\", {\n type: \"DateTime\",\n description: \"The time the stored object was last updated.\",\n }),\n created: t.expose(\"created\", {\n type: \"DateTime\",\n description:\n \"The time the object was stored in DrFed, distinct from its publication time.\",\n }),\n }),\n});\nexport const ActivityPubObject: DrFedObjectRef = ObjectRef;\nResourceDetail.addTypes([ActivityPubObject]);\nregisterAddressingFields(\"objects\");\n\nconst activitiesConnection = drizzleConnectionHelpers(builder, \"activities\", {\n query: (\n args: {\n type?: typeof schema.activities.$inferSelect.type | null;\n },\n ctx,\n ) => ({\n where: {\n actor: { deleted: { isNull: true } },\n ...(args.type == null ? {} : { type: args.type }),\n RAW: (table) => readableResource(ctx, table.id),\n },\n orderBy: { published: \"asc\", id: \"asc\" },\n }),\n});\nbuilder.drizzleObjectField(\"objects\", \"activities\", (t) =>\n t.connection({\n type: Activity,\n args: { type: t.arg({ type: ActivityType }) },\n description:\n \"Activities referencing this object that the viewer may read, optionally filtered by type. Excludes deleted authors; ordered by published ASC, id ASC.\",\n select(args, ctx, nestedSelection) {\n return {\n with: {\n activities: activitiesConnection.getQuery(args, ctx, nestedSelection),\n },\n };\n },\n resolve: (object, args, ctx) =>\n activitiesConnection.resolve(object.activities, args, ctx, object),\n }),\n);\n\nconst objectsConnection = drizzleConnectionHelpers(builder, \"objects\", {\n query: (_, ctx) => ({\n where: { RAW: (table) => readableResource(ctx, table.id) },\n orderBy: { published: \"desc\", id: \"desc\" },\n }),\n});\nbuilder.drizzleObjectField(\"actors\", \"objects\", (t) =>\n t.connection(\n {\n type: ActivityPubObject,\n description:\n \"Non-deleted objects the viewer may read, newest publication first. A local actor's objects are readable whatever their addressing; see `Object` for a remote actor's.\",\n select(args, ctx, nestedSelection) {\n return {\n with: {\n objects: objectsConnection.getQuery(args, ctx, nestedSelection),\n },\n };\n },\n resolve(actor, args, ctx) {\n return {\n ...objectsConnection.resolve(actor.objects, args, ctx, actor),\n totalCount() {\n return ctx.db.$count(\n schema.objects,\n and(\n eq(schema.objects.actorId, actor.id),\n isNull(schema.objects.deleted),\n readableResource(ctx, schema.objects.id),\n ),\n );\n },\n };\n },\n },\n {\n name: \"ObjectConnection\",\n fields: (fb) => ({\n totalCount: fb.int({\n description:\n \"The number of non-deleted objects authored by this actor that the viewer may read.\",\n resolve: (connection) => connection.totalCount(),\n }),\n }),\n },\n { name: \"ObjectEdge\" },\n ),\n);\n\nconst CreateObjectErrorType = builder.enumType(\"CreateObjectErrorType\", {\n values: [\n \"ActorNotFound\",\n \"InvalidContent\",\n \"InvalidInstanceHost\",\n \"InvalidLanguage\",\n ] as const,\n});\ninterface CreateObjectError {\n readonly type: typeof CreateObjectErrorType.$inferType;\n readonly message: string;\n}\nconst CreateObjectErrorRef =\n builder.objectRef<CreateObjectError>(\"CreateObjectError\");\nCreateObjectErrorRef.implement({\n fields: (t) => ({\n type: t.expose(\"type\", {\n type: CreateObjectErrorType,\n description:\n \"The type of the error. Use this for programmatic error handling.\",\n }),\n message: t.exposeString(\"message\", {\n description:\n \"A human-readable message describing the error. \" +\n \"Don't use this for programmatic error handling, \" +\n \"use the `type` field instead.\",\n }),\n }),\n});\nconst CreateObjectResult = builder.unionType(\"CreateObjectResult\", {\n types: [ObjectRef, CreateObjectErrorRef],\n resolveType: (value) =>\n \"message\" in value ? CreateObjectErrorRef : ObjectRef,\n});\nconst actorNotFound: CreateObjectError = {\n type: \"ActorNotFound\",\n message: \"Can't find the actor.\",\n};\n\nbuilder.mutationFields((t) => ({\n createObject: t.field({\n type: CreateObjectResult,\n description:\n \"Create a local Note or Article together with a `Create` activity in \" +\n \"the author's outbox, without delivering it to remote servers. This \" +\n \"mutation keeps that established behavior; it does not save an object \" +\n \"alone.\",\n authScopes: { authenticated: true },\n args: {\n actor: t.arg.globalID({\n for: Actor,\n required: true,\n description:\n \"The local author actor ID. The viewer must be an accepted instance member.\",\n }),\n type: t.arg({\n type: ObjectType,\n required: true,\n defaultValue: \"Note\",\n description: \"The ActivityStreams object type to create.\",\n }),\n contentHtml: t.arg.string({\n required: true,\n description:\n \"Non-empty HTML stored verbatim; browser clients must sanitize it before rendering.\",\n }),\n name: t.arg.string({\n description:\n \"Optional title. Empty or whitespace-only values are stored as null.\",\n }),\n summary: t.arg.string({\n description:\n \"Optional summary or content warning. Empty or whitespace-only values are stored as null.\",\n }),\n language: t.arg.string({\n description:\n \"A BCP 47 language tag, canonicalized and limited to 35 characters.\",\n }),\n sensitive: t.arg.boolean({\n required: true,\n defaultValue: false,\n description: \"Whether to mark the content as sensitive.\",\n }),\n addressing: t.arg({\n type: AddressingInput,\n required: true,\n description:\n \"Explicit addressing preserved in order, including duplicates. Empty lists are allowed.\",\n }),\n },\n async resolve(\n _parent,\n { actor: { id: actorId }, language, addressing, ...input },\n ctx,\n ) {\n if (input.contentHtml.trim() === \"\") {\n return {\n type: \"InvalidContent\" as const,\n message: \"Content must not be empty.\",\n };\n }\n let canonicalLanguage: string | null = null;\n if (language != null) {\n try {\n canonicalLanguage = Intl.getCanonicalLocales(language)[0] ?? null;\n if (canonicalLanguage == null || canonicalLanguage.length > 35) {\n throw new RangeError(\"Language tag is too long.\");\n }\n } catch (error) {\n if (!(error instanceof RangeError)) throw error;\n return {\n type: \"InvalidLanguage\" as const,\n message:\n \"Language must be a valid BCP 47 tag of at most 35 characters.\",\n };\n }\n }\n const { account } = ctx;\n if (account == null) {\n throw new Error(\"You must be authenticated to create objects.\");\n }\n if (!validateUuid(actorId)) return actorNotFound;\n const result = await createLegacyObject(\n ctx,\n { accountId: account.id },\n {\n ...input,\n actorId,\n name: normalizeOptionalText(input.name),\n summary: normalizeOptionalText(input.summary),\n language: canonicalLanguage,\n addressing,\n },\n );\n if (!isLocalWriteError(result)) return result;\n return result.type === \"invalid_instance_host\"\n ? { type: \"InvalidInstanceHost\" as const, message: result.message }\n : actorNotFound;\n },\n }),\n}));\n\nfunction normalizeOptionalText(\n value: string | null | undefined,\n): string | null {\n return value == null || value.trim() === \"\" ? null : value;\n}\n"],"mappings":";;;;;;;;;;AAoCA,MAAM,aAAa,QAAQ,SAAS,cAAc,EAChD,QAAQ,eAAe,WACzB,CAAC;AACD,MAAM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8C;EAEhE,IAAI,CAAC,aAAa,OAAO,GAAG,OAAO;EACnC,MAAM,SAAS,MAAM,mBACnB,KACA,EAAE,WAAW,QAAQ,GAAG,GACxB;GACE,GAAG;GACH;GACA,MAAM,sBAAsB,MAAM,IAAI;GACtC,SAAS,sBAAsB,MAAM,OAAO;GAC5C,UAAU;GACV;EACF,CACF;EACA,IAAI,CAAC,kBAAkB,MAAM,GAAG,OAAO;EACvC,OAAO,OAAO,SAAS,0BACnB;GAAE,MAAM;GAAgC,SAAS,OAAO;EAAQ,IAChE;CACN;AACF,CAAC,EACH,EAAE;AAEF,SAAS,sBACP,OACe;CACf,OAAO,SAAS,QAAQ,MAAM,KAAK,MAAM,KAAK,OAAO;AACvD"}
1
+ {"version":3,"file":"object.mjs","names":[],"sources":["../src/object.ts"],"sourcesContent":["// DrFed: A web-based platform for developing and debugging ActivityPub apps\n// Copyright (C) 2026 DrFed team\n//\n// This program is free software: you can redistribute it and/or modify\n// it under the terms of the GNU Affero General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU Affero General Public License for more details.\n//\n// You should have received a copy of the GNU Affero General Public License\n// along with this program. If not, see <https://www.gnu.org/licenses/>.\n\nimport {\n createLegacyObject,\n isLocalWriteError,\n} from \"@drfed/federation/local-write\";\nimport { schema } from \"@drfed/models\";\nimport { objectTypeEnum } from \"@drfed/models/schema\";\nimport { validateUuid } from \"@drfed/models/uuid\";\nimport { drizzleConnectionHelpers } from \"@pothos/plugin-drizzle\";\nimport { and, eq, isNull } from \"drizzle-orm\";\n\nimport { Actor } from \"./actor.ts\";\nimport builder, { type DrFedObjectRef } from \"./builder.ts\";\nimport { readableResource } from \"./readable.ts\";\nimport {\n Activity,\n ActivityType,\n ResourceDetail,\n registerAddressingFields,\n} from \"./resource.ts\";\n\nconst ObjectType = builder.enumType(\"ObjectType\", {\n values: objectTypeEnum.enumValues,\n});\nconst AddressingInput = builder.inputType(\"AddressingInput\", {\n fields: (t) => ({\n to: t.field({ type: [\"URL\"], required: true, defaultValue: [] }),\n cc: t.field({ type: [\"URL\"], required: true, defaultValue: [] }),\n bto: t.field({ type: [\"URL\"], required: true, defaultValue: [] }),\n bcc: t.field({ type: [\"URL\"], required: true, defaultValue: [] }),\n audience: t.field({ type: [\"URL\"], required: true, defaultValue: [] }),\n }),\n});\nconst ObjectRef = builder.drizzleNode(\"objects\", {\n name: \"Object\",\n select: {\n columns: { id: true, deleted: true },\n with: { actor: { columns: { deleted: true } } },\n },\n description:\n \"Represents an ActivityPub object authored by an `Actor`. An object of \" +\n \"a local actor is readable whatever its addressing. One of a remote \" +\n \"actor is readable only when it or the activity it was received in is \" +\n \"addressed to the public, by members of the local instances that \" +\n \"received that activity and the object as stored with it, and by \" +\n \"administrators; otherwise it is left out as if it did not exist.\",\n id: {\n column: ({ id }) => id,\n description: \"The Relay global ID of the object.\",\n },\n fields: (t) => ({\n resource: t.relation(\"resource\"),\n iri: t.field({\n type: \"URL\",\n select: { with: { resource: true } },\n resolve: (row) => row.resource.iri,\n }),\n uuid: t.expose(\"id\", {\n type: \"UUID\",\n description: \"The UUID of the ActivityPub Object.\",\n }),\n url: t.expose(\"url\", {\n type: \"URL\",\n nullable: true,\n description: \"The human-readable page URL, if available.\",\n }),\n type: t.expose(\"type\", {\n type: ObjectType,\n description: \"The ActivityStreams vocabulary type: Note or Article.\",\n }),\n actor: t.relation(\"actor\", {\n description: \"The actor that authored the object.\",\n }),\n document: t.expose(\"document\", {\n type: \"JSON\",\n nullable: true,\n description:\n \"The JSON-LD document of the object. For a remote object embedded in the Create that delivered it, the object as received; null when it was not found within the first 64 places of that document, in which case the document of the Create, reachable through activities, holds it as received.\",\n }),\n name: t.exposeString(\"name\", {\n nullable: true,\n description: \"The optional title of the object.\",\n }),\n summary: t.exposeString(\"summary\", {\n nullable: true,\n description: \"The optional summary or content warning.\",\n }),\n contentHtml: t.exposeString(\"contentHtml\", {\n description:\n \"HTML preserved verbatim. Clients must sanitize it before browser rendering.\",\n }),\n language: t.exposeString(\"language\", {\n nullable: true,\n description:\n \"The canonical BCP 47 tag used for contentMap, if specified.\",\n }),\n sensitive: t.exposeBoolean(\"sensitive\", {\n description: \"Whether the content is marked sensitive.\",\n }),\n published: t.expose(\"published\", {\n type: \"DateTime\",\n description: \"The ActivityStreams publication time.\",\n }),\n updated: t.expose(\"updated\", {\n type: \"DateTime\",\n description: \"The time the stored object was last updated.\",\n }),\n created: t.expose(\"created\", {\n type: \"DateTime\",\n description:\n \"The time the object was stored in DrFed, distinct from its publication time.\",\n }),\n deleted: t.expose(\"deleted\", {\n type: \"DateTime\",\n nullable: true,\n description:\n \"When the object was deleted, or null while it is not. Only \" +\n \"`Actor.objects` returns deleted objects, when its filter includes \" +\n \"them; its revisions, a whiteout last, stay readable through \" +\n \"`resource`.\",\n }),\n }),\n});\nexport const ActivityPubObject: DrFedObjectRef = ObjectRef;\nResourceDetail.addTypes([ActivityPubObject]);\nregisterAddressingFields(\"objects\");\n\nconst activitiesConnection = drizzleConnectionHelpers(builder, \"activities\", {\n query: (\n args: {\n type?: typeof schema.activities.$inferSelect.type | null;\n },\n ctx,\n ) => ({\n where: {\n actor: { deleted: { isNull: true } },\n ...(args.type == null ? {} : { type: args.type }),\n RAW: (table) => readableResource(ctx, table.id),\n },\n orderBy: { published: \"asc\", id: \"asc\" },\n }),\n});\nbuilder.drizzleObjectField(\"objects\", \"activities\", (t) =>\n t.connection({\n type: Activity,\n args: { type: t.arg({ type: ActivityType }) },\n description:\n \"Activities referencing this object that the viewer may read, optionally filtered by type. Excludes deleted authors; ordered by published ASC, id ASC.\",\n select(args, ctx, nestedSelection) {\n return {\n with: {\n activities: activitiesConnection.getQuery(args, ctx, nestedSelection),\n },\n };\n },\n resolve: (object, args, ctx) =>\n activitiesConnection.resolve(object.activities, args, ctx, object),\n }),\n);\n\nconst ActorObjectFilter = builder.inputType(\"ActorObjectFilter\", {\n description: \"Narrows the objects `Actor.objects` lists.\",\n fields: (t) => ({\n includeDeleted: t.boolean({\n required: true,\n defaultValue: false,\n description:\n \"Whether deleted objects are listed too, so that their histories \" +\n \"can be inspected.\",\n }),\n }),\n});\ntype ObjectFilter = typeof ActorObjectFilter.$inferInput | null | undefined;\nconst includesDeleted = (filter: ObjectFilter): boolean =>\n filter?.includeDeleted === true;\n\nconst objectsConnection = drizzleConnectionHelpers(builder, \"objects\", {\n query: ({ filter }: { filter?: ObjectFilter }, ctx) => ({\n where: {\n ...(includesDeleted(filter) ? {} : { deleted: { isNull: true } }),\n RAW: (table) => readableResource(ctx, table.id),\n },\n orderBy: { published: \"desc\", id: \"desc\" },\n }),\n});\nbuilder.drizzleObjectField(\"actors\", \"objects\", (t) =>\n t.connection(\n {\n type: ActivityPubObject,\n args: { filter: t.arg({ type: ActorObjectFilter }) },\n description:\n \"Objects the viewer may read, newest publication first, without deleted ones unless the filter includes them. A local actor's objects are readable whatever their addressing; see `Object` for a remote actor's.\",\n select(args, ctx, nestedSelection) {\n return {\n with: {\n objects: objectsConnection.getQuery(args, ctx, nestedSelection),\n },\n };\n },\n resolve(actor, args, ctx) {\n return {\n ...objectsConnection.resolve(actor.objects, args, ctx, actor),\n totalCount() {\n return ctx.db.$count(\n schema.objects,\n and(\n eq(schema.objects.actorId, actor.id),\n includesDeleted(args.filter)\n ? undefined\n : isNull(schema.objects.deleted),\n readableResource(ctx, schema.objects.id),\n ),\n );\n },\n };\n },\n },\n {\n name: \"ObjectConnection\",\n fields: (fb) => ({\n totalCount: fb.int({\n description:\n \"The number of objects authored by this actor that the viewer may read, counted with the same filter as the list.\",\n resolve: (connection) => connection.totalCount(),\n }),\n }),\n },\n { name: \"ObjectEdge\" },\n ),\n);\n\nconst CreateObjectErrorType = builder.enumType(\"CreateObjectErrorType\", {\n values: [\n \"ActorNotFound\",\n \"InvalidContent\",\n \"InvalidInstanceHost\",\n \"InvalidLanguage\",\n ] as const,\n});\ninterface CreateObjectError {\n readonly type: typeof CreateObjectErrorType.$inferType;\n readonly message: string;\n}\nconst CreateObjectErrorRef =\n builder.objectRef<CreateObjectError>(\"CreateObjectError\");\nCreateObjectErrorRef.implement({\n fields: (t) => ({\n type: t.expose(\"type\", {\n type: CreateObjectErrorType,\n description:\n \"The type of the error. Use this for programmatic error handling.\",\n }),\n message: t.exposeString(\"message\", {\n description:\n \"A human-readable message describing the error. \" +\n \"Don't use this for programmatic error handling, \" +\n \"use the `type` field instead.\",\n }),\n }),\n});\nconst CreateObjectResult = builder.unionType(\"CreateObjectResult\", {\n types: [ObjectRef, CreateObjectErrorRef],\n resolveType: (value) =>\n \"message\" in value ? CreateObjectErrorRef : ObjectRef,\n});\nconst actorNotFound: CreateObjectError = {\n type: \"ActorNotFound\",\n message: \"Can't find the actor.\",\n};\n\nbuilder.mutationFields((t) => ({\n createObject: t.field({\n type: CreateObjectResult,\n description:\n \"Create a local Note or Article together with a `Create` activity in \" +\n \"the author's outbox, without delivering it to remote servers. This \" +\n \"mutation keeps that established behavior; it does not save an object \" +\n \"alone.\",\n authScopes: { authenticated: true },\n args: {\n actor: t.arg.globalID({\n for: Actor,\n required: true,\n description:\n \"The local author actor ID. The viewer must be an accepted instance member.\",\n }),\n type: t.arg({\n type: ObjectType,\n required: true,\n defaultValue: \"Note\",\n description: \"The ActivityStreams object type to create.\",\n }),\n contentHtml: t.arg.string({\n required: true,\n description:\n \"Non-empty HTML stored verbatim; browser clients must sanitize it before rendering.\",\n }),\n name: t.arg.string({\n description:\n \"Optional title. Empty or whitespace-only values are stored as null.\",\n }),\n summary: t.arg.string({\n description:\n \"Optional summary or content warning. Empty or whitespace-only values are stored as null.\",\n }),\n language: t.arg.string({\n description:\n \"A BCP 47 language tag, canonicalized and limited to 35 characters.\",\n }),\n sensitive: t.arg.boolean({\n required: true,\n defaultValue: false,\n description: \"Whether to mark the content as sensitive.\",\n }),\n addressing: t.arg({\n type: AddressingInput,\n required: true,\n description:\n \"Explicit addressing preserved in order, including duplicates. Empty lists are allowed.\",\n }),\n },\n async resolve(\n _parent,\n { actor: { id: actorId }, language, addressing, ...input },\n ctx,\n ) {\n if (input.contentHtml.trim() === \"\") {\n return {\n type: \"InvalidContent\" as const,\n message: \"Content must not be empty.\",\n };\n }\n let canonicalLanguage: string | null = null;\n if (language != null) {\n try {\n canonicalLanguage = Intl.getCanonicalLocales(language)[0] ?? null;\n if (canonicalLanguage == null || canonicalLanguage.length > 35) {\n throw new RangeError(\"Language tag is too long.\");\n }\n } catch (error) {\n if (!(error instanceof RangeError)) throw error;\n return {\n type: \"InvalidLanguage\" as const,\n message:\n \"Language must be a valid BCP 47 tag of at most 35 characters.\",\n };\n }\n }\n const { account } = ctx;\n if (account == null) {\n throw new Error(\"You must be authenticated to create objects.\");\n }\n if (!validateUuid(actorId)) return actorNotFound;\n const result = await createLegacyObject(\n ctx,\n { accountId: account.id },\n {\n ...input,\n actorId,\n name: normalizeOptionalText(input.name),\n summary: normalizeOptionalText(input.summary),\n language: canonicalLanguage,\n addressing,\n },\n );\n if (!isLocalWriteError(result)) return result;\n return result.type === \"invalid_instance_host\"\n ? { type: \"InvalidInstanceHost\" as const, message: result.message }\n : actorNotFound;\n },\n }),\n}));\n\nfunction normalizeOptionalText(\n value: string | null | undefined,\n): string | null {\n return value == null || value.trim() === \"\" ? null : value;\n}\n"],"mappings":";;;;;;;;;;AAoCA,MAAM,aAAa,QAAQ,SAAS,cAAc,EAChD,QAAQ,eAAe,WACzB,CAAC;AACD,MAAM,kBAAkB,QAAQ,UAAU,mBAAmB,EAC3D,SAAS,OAAO;CACd,IAAI,EAAE,MAAM;EAAE,MAAM,CAAC,KAAK;EAAG,UAAU;EAAM,cAAc,CAAC;CAAE,CAAC;CAC/D,IAAI,EAAE,MAAM;EAAE,MAAM,CAAC,KAAK;EAAG,UAAU;EAAM,cAAc,CAAC;CAAE,CAAC;CAC/D,KAAK,EAAE,MAAM;E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