@drfed/graphql 0.2.0-dev.685 → 0.2.0-dev.703

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.
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.mts","names":[],"sources":["../src/object.ts"],"mappings":";;cA4Ia,mBAAmB"}
1
+ {"version":3,"file":"object.d.mts","names":[],"sources":["../src/object.ts"],"mappings":";;cAiIa,mBAAmB"}
package/dist/object.mjs CHANGED
@@ -3,11 +3,10 @@ import { a as readableResource } from "./readable-CSN0MPlO.mjs";
3
3
  import { a as ResourceDetail, i as ActivityType, o as registerAddressingFields, r as Activity, t as Actor } from "./actor-B1FAD_C_.mjs";
4
4
  import { objectTypeEnum } from "@drfed/models/schema";
5
5
  import { drizzleConnectionHelpers } from "@pothos/plugin-drizzle";
6
- import { addActorCollectionItem, captureLegacyResourceRevision, ensureResource, lockActorCollection, promoteResource, schema, storeAddressing } from "@drfed/models";
7
- import { uuidV7, validateUuid } from "@drfed/models/uuid";
8
- import { and, eq, gt, isNotNull, isNull } from "drizzle-orm";
9
- import { activitySelection, objectSelection, toCreate, toObject } from "@drfed/federation/object";
10
- import { Create, Object as Object$1 } from "@fedify/vocab";
6
+ import { schema } from "@drfed/models";
7
+ import { validateUuid } from "@drfed/models/uuid";
8
+ import { and, eq, isNull } from "drizzle-orm";
9
+ import { createLegacyObject, isLocalWriteError } from "@drfed/federation/local-write";
11
10
  //#region src/object.ts
12
11
  const ObjectType = builder.enumType("ObjectType", { values: objectTypeEnum.enumValues });
13
12
  const AddressingInput = builder.inputType("AddressingInput", { fields: (t) => ({
@@ -180,7 +179,7 @@ const actorNotFound = {
180
179
  };
181
180
  builder.mutationFields((t) => ({ createObject: t.field({
182
181
  type: CreateObjectResult,
183
- description: "Create a local ActivityPub object without delivering it to remote servers.",
182
+ description: "Create a local Note or Article together with a `Create` activity in the author's outbox, without delivering it to remote servers. This mutation keeps that established behavior; it does not save an object alone.",
184
183
  authScopes: { authenticated: true },
185
184
  args: {
186
185
  actor: t.arg.globalID({
@@ -231,92 +230,24 @@ builder.mutationFields((t) => ({ createObject: t.field({
231
230
  const { account } = ctx;
232
231
  if (account == null) throw new Error("You must be authenticated to create objects.");
233
232
  if (!validateUuid(actorId)) return actorNotFound;
234
- return await ctx.db.transaction(async (tx) => {
235
- const [actor] = await tx.select({
236
- id: schema.actors.id,
237
- host: schema.instances.host
238
- }).from(schema.actors).for("update", { of: schema.actors }).innerJoin(schema.instances, eq(schema.actors.instanceId, schema.instances.id)).innerJoin(schema.localInstances, eq(schema.instances.localId, schema.localInstances.id)).innerJoin(schema.instanceMembers, eq(schema.instanceMembers.instanceId, schema.instances.id)).where(and(eq(schema.actors.id, actorId), isNotNull(schema.actors.localId), isNull(schema.actors.deleted), gt(schema.localInstances.expires, Temporal.Now.instant()), eq(schema.instanceMembers.accountId, account.id), isNotNull(schema.instanceMembers.accepted))).limit(1);
239
- if (actor == null) return actorNotFound;
240
- const instanceUrl = `${ctx.rootOrigin.protocol}//${actor.host}`;
241
- if (!URL.canParse(instanceUrl)) return {
242
- type: "InvalidInstanceHost",
243
- message: `The instance host ${JSON.stringify(actor.host)} cannot be parsed by this server. Contact the server administrator.`
244
- };
245
- await lockActorCollection(tx, actorId, "outbox");
246
- const published = Temporal.Now.instant();
247
- const id = uuidV7();
248
- const fedCtx = ctx.federation.createContext(new URL(instanceUrl), void 0);
249
- const iri = fedCtx.getObjectUri(Object$1, {
250
- identifier: actorId,
251
- id
252
- }).href;
253
- const activityId = uuidV7();
254
- const activityIri = fedCtx.getObjectUri(Create, { id: activityId }).href;
255
- await ensureResource(tx, activityIri, activityId);
256
- const object = await promoteResource(tx, iri, "object", async (inner, resource) => {
257
- const [row] = await inner.insert(schema.objects).values({
258
- ...input,
259
- name: normalizeOptionalText(input.name),
260
- summary: normalizeOptionalText(input.summary),
261
- id: resource.id,
262
- actorId,
263
- activityId,
264
- language: canonicalLanguage,
265
- published
266
- }).returning();
267
- if (row == null) throw new Error("Object insertion returned no row.");
268
- return row;
269
- }, id);
270
- await storeAddressing(tx, object.id, addressing);
271
- await promoteResource(tx, activityIri, "activity", async (inner, resource) => {
272
- await inner.insert(schema.activities).values({
273
- id: resource.id,
274
- type: "Create",
275
- actorId,
276
- objectId: object.id,
277
- published: object.published
278
- });
279
- await storeAddressing(inner, resource.id, addressing);
280
- await addActorCollectionItem(inner, actorId, "outbox", resource.id);
281
- }, activityId);
282
- const storedObject = await tx.query.objects.findFirst({
283
- where: { id: object.id },
284
- with: objectSelection
285
- });
286
- const storedActivity = await tx.query.activities.findFirst({
287
- where: { id: activityId },
288
- with: activitySelection
289
- });
290
- if (storedObject == null || storedActivity == null) throw new Error("Missing newly created resource.");
291
- const snapshot = {
292
- ...asDocument(await toObject(fedCtx, storedObject).toJsonLd()),
293
- ...addressing
294
- };
295
- await tx.update(schema.objects).set({
296
- document: snapshot,
297
- updated: object.updated
298
- }).where(eq(schema.objects.id, object.id));
299
- await tx.update(schema.activities).set({ document: {
300
- ...asDocument(await toCreate(fedCtx, storedActivity).toJsonLd()),
301
- ...addressing
302
- } }).where(eq(schema.activities.id, activityId));
303
- await captureLegacyResourceRevision(tx, object.id);
304
- await captureLegacyResourceRevision(tx, activityId);
305
- return {
306
- ...object,
307
- actor: storedObject.actor,
308
- document: snapshot
309
- };
233
+ const result = await createLegacyObject(ctx, { accountId: account.id }, {
234
+ ...input,
235
+ actorId,
236
+ name: normalizeOptionalText(input.name),
237
+ summary: normalizeOptionalText(input.summary),
238
+ language: canonicalLanguage,
239
+ addressing
310
240
  });
241
+ if (!isLocalWriteError(result)) return result;
242
+ return result.type === "invalid_instance_host" ? {
243
+ type: "InvalidInstanceHost",
244
+ message: result.message
245
+ } : actorNotFound;
311
246
  }
312
247
  }) }));
313
248
  function normalizeOptionalText(value) {
314
249
  return value == null || value.trim() === "" ? null : value;
315
250
  }
316
- function asDocument(value) {
317
- if (value == null || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Expected a JSON-LD object.");
318
- return value;
319
- }
320
251
  //#endregion
321
252
  export { ActivityPubObject };
322
253
 
@@ -1 +1 @@
1
- {"version":3,"file":"object.mjs","names":["uuid","APObject"],"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 activitySelection,\n objectSelection,\n toCreate,\n toObject,\n} from \"@drfed/federation/object\";\nimport {\n addActorCollectionItem,\n captureLegacyResourceRevision,\n ensureResource,\n lockActorCollection,\n promoteResource,\n schema,\n storeAddressing,\n} from \"@drfed/models\";\nimport { objectTypeEnum } from \"@drfed/models/schema\";\nimport { uuidV7 as uuid, validateUuid } from \"@drfed/models/uuid\";\nimport { Object as APObject, Create } from \"@fedify/vocab\";\nimport { drizzleConnectionHelpers } from \"@pothos/plugin-drizzle\";\nimport { and, eq, gt, isNotNull, 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 ActivityPub object without delivering it to remote servers.\",\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 // Keep host validation and resource creation under the same actor lock.\n return await ctx.db.transaction(async (tx) => {\n const [actor] = await tx\n .select({ id: schema.actors.id, host: schema.instances.host })\n .from(schema.actors)\n .for(\"update\", { of: schema.actors })\n .innerJoin(\n schema.instances,\n eq(schema.actors.instanceId, schema.instances.id),\n )\n .innerJoin(\n schema.localInstances,\n eq(schema.instances.localId, schema.localInstances.id),\n )\n .innerJoin(\n schema.instanceMembers,\n eq(schema.instanceMembers.instanceId, schema.instances.id),\n )\n .where(\n and(\n eq(schema.actors.id, actorId),\n isNotNull(schema.actors.localId),\n isNull(schema.actors.deleted),\n gt(schema.localInstances.expires, Temporal.Now.instant()),\n eq(schema.instanceMembers.accountId, account.id),\n isNotNull(schema.instanceMembers.accepted),\n ),\n )\n .limit(1);\n if (actor == null) return actorNotFound;\n const instanceUrl = `${ctx.rootOrigin.protocol}//${actor.host}`;\n // Stored authorities can outlive the runtime that accepted them.\n if (!URL.canParse(instanceUrl)) {\n return {\n type: \"InvalidInstanceHost\" as const,\n message:\n `The instance host ${JSON.stringify(actor.host)} cannot be ` +\n \"parsed by this server. Contact the server administrator.\",\n };\n }\n await lockActorCollection(tx, actorId, \"outbox\");\n const published = Temporal.Now.instant();\n const id = uuid();\n const fedCtx = ctx.federation.createContext(\n new URL(instanceUrl),\n undefined,\n );\n const iri = fedCtx.getObjectUri(APObject, {\n identifier: actorId,\n id,\n }).href;\n const activityId = uuid();\n const activityIri = fedCtx.getObjectUri(Create, {\n id: activityId,\n }).href;\n await ensureResource(tx, activityIri, activityId);\n const object = await promoteResource(\n tx,\n iri,\n \"object\",\n async (inner, resource) => {\n const [row] = await inner\n .insert(schema.objects)\n .values({\n ...input,\n name: normalizeOptionalText(input.name),\n summary: normalizeOptionalText(input.summary),\n id: resource.id,\n actorId,\n activityId,\n language: canonicalLanguage,\n published,\n })\n .returning();\n if (row == null) {\n throw new Error(\"Object insertion returned no row.\");\n }\n return row;\n },\n id,\n );\n await storeAddressing(tx, object.id, addressing);\n await promoteResource(\n tx,\n activityIri,\n \"activity\",\n async (inner, resource) => {\n await inner.insert(schema.activities).values({\n id: resource.id,\n type: \"Create\",\n actorId,\n objectId: object.id,\n published: object.published,\n });\n await storeAddressing(inner, resource.id, addressing);\n await addActorCollectionItem(inner, actorId, \"outbox\", resource.id);\n },\n activityId,\n );\n const storedObject = await tx.query.objects.findFirst({\n where: { id: object.id },\n with: objectSelection,\n });\n const storedActivity = await tx.query.activities.findFirst({\n where: { id: activityId },\n with: activitySelection,\n });\n if (storedObject == null || storedActivity == null) {\n throw new Error(\"Missing newly created resource.\");\n }\n // Preserve blind recipients in the local snapshot; serving strips them.\n const snapshot = {\n ...asDocument(await toObject(fedCtx, storedObject).toJsonLd()),\n ...addressing,\n };\n await tx\n .update(schema.objects)\n .set({ document: snapshot, updated: object.updated })\n .where(eq(schema.objects.id, object.id));\n await tx\n .update(schema.activities)\n .set({\n document: {\n ...asDocument(await toCreate(fedCtx, storedActivity).toJsonLd()),\n ...addressing,\n },\n })\n .where(eq(schema.activities.id, activityId));\n await captureLegacyResourceRevision(tx, object.id);\n await captureLegacyResourceRevision(tx, activityId);\n return { ...object, actor: storedObject.actor, document: snapshot };\n });\n },\n }),\n}));\n\nfunction normalizeOptionalText(\n value: string | null | undefined,\n): string | null {\n return value == null || value.trim() === \"\" ? null : value;\n}\n\nfunction asDocument(value: unknown): Record<string, unknown> {\n if (value == null || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(\"Expected a JSON-LD object.\");\n }\n return value as Record<string, unknown>;\n}\n"],"mappings":";;;;;;;;;;;AA+CA,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;EAAE,MAAM,CAAC,KAAK;EAAG,UAAU;EAAM,cAAc,CAAC;CAAE,CAAC;CAChE,KAAK,EAAE,MAAM;EAAE,MAAM,CAAC,KAAK;EAAG,UAAU;EAAM,cAAc,CAAC;CAAE,CAAC;CAChE,UAAU,EAAE,MAAM;EAAE,MAAM,CAAC,KAAK;EAAG,UAAU;EAAM,cAAc,CAAC;CAAE,CAAC;AACvE,GACF,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C;CACH;AACF,CAAC,EACH,EAAE;AAEF,SAAS,sBACP,OACe;CACf,OAAO,SAAS,QAAQ,MAAM,KAAK,MAAM,KAAK,OAAO;AACvD;AAEA,SAAS,WAAW,OAAyC;CAC3D,IAAI,SAAS,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GACnE,MAAM,IAAI,UAAU,4BAA4B;CAElD,OAAO;AACT"}
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,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;EAAE,MAAM,CAAC,KAAK;EAAG,UAAU;EAAM,cAAc,CAAC;CAAE,CAAC;CAChE,KAAK,EAAE,MAAM;EAAE,MAAM,CAAC,KAAK;EAAG,UAAU;EAAM,cAAc,CAAC;CAAE,CAAC;CAChE,UAAU,EAAE,MAAM;EAAE,MAAM,CAAC,KAAK;EAAG,UAAU;EAAM,cAAc,CAAC;CAAE,CAAC;AACvE,GACF,CAAC;AACD,MAAM,YAAY,QAAQ,YAAY,WAAW;CAC/C,MAAM;CACN,QAAQ;EACN,SAAS;GAAE,IAAI;GAAM,SAAS;EAAK;EACnC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,KAAK,EAAE,EAAE;CAChD;CACA,aACE;CAMF,IAAI;EACF,SAAS,EAAE,SAAS;EACpB,aAAa;CACf;CACA,SAAS,OAAO;EACd,UAAU,EAAE,SAAS,UAAU;EAC/B,KAAK,EAAE,MAAM;GACX,MAAM;GACN,QAAQ,EAAE,MAAM,EAAE,UAAU,KAAK,EAAE;GACnC,UAAU,QAAQ,IAAI,SAAS;EACjC,CAAC;EACD,MAAM,EAAE,OAAO,MAAM;GACnB,MAAM;GACN,aAAa;EACf,CAAC;EACD,KAAK,EAAE,OAAO,OAAO;GACnB,MAAM;GACN,UAAU;GACV,aAAa;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BAA2B;EAEpD,SAAS,OAAO;GACd,IAAI,EAAE,iBAAiB,aAAa,MAAM;GAC1C,OAAO;IACL,MAAM;IACN,SACE;GACJ;EACF;EAEF,MAAM,EAAE,YAAY;EACpB,IAAI,WAAW,MACb,MAAM,IAAI,MAAM,8CAA8C;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drfed/graphql",
3
- "version": "0.2.0-dev.685",
3
+ "version": "0.2.0-dev.703",
4
4
  "description": "A GraphQL server for DrFed.",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -109,8 +109,8 @@
109
109
  "typescript": "^7.0.2"
110
110
  },
111
111
  "dependencies": {
112
- "@drfed/federation": "0.2.0-dev.685",
113
- "@drfed/models": "0.2.0-dev.685",
112
+ "@drfed/federation": "0.2.0-dev.703",
113
+ "@drfed/models": "0.2.0-dev.703",
114
114
  "@faker-js/faker": "^10.5.0",
115
115
  "@fedify/uri-template": "^2.3.1",
116
116
  "@fedify/fedify": "2.4.3",
@@ -140,13 +140,13 @@
140
140
  },
141
141
  "drfedBuild": {
142
142
  "enabled": true,
143
- "version": "0.2.0-dev.685",
144
- "fullVersion": "0.2.0-dev.685+42250f6c",
143
+ "version": "0.2.0-dev.703",
144
+ "fullVersion": "0.2.0-dev.703+a34fc230",
145
145
  "baseVersion": "0.2.0",
146
146
  "channel": "dev",
147
- "sha": "42250f6c18c384d81fa57ad8fa72e08d1fdeb6d7",
148
- "runNumber": "685",
149
- "runId": "41419325359",
147
+ "sha": "a34fc2304b78997824db72f9edee44be2adb2f65",
148
+ "runNumber": "703",
149
+ "runId": "41786716066",
150
150
  "ref": "refs/heads/main",
151
151
  "workflow": ".github/workflows/main.yaml"
152
152
  },