@drfed/models 0.0.0-stage → 0.1.0-dev.0

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.
Files changed (132) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +230 -2
  3. package/dist/activity-delivery.d.mts +111 -0
  4. package/dist/activity-delivery.d.mts.map +1 -0
  5. package/dist/activity-delivery.mjs +240 -0
  6. package/dist/activity-delivery.mjs.map +1 -0
  7. package/dist/db-DtcLuISw.d.mts +3098 -0
  8. package/dist/db-DtcLuISw.d.mts.map +1 -0
  9. package/dist/db.d.mts +2 -0
  10. package/dist/db.mjs +3 -0
  11. package/dist/email.d.mts +39 -0
  12. package/dist/email.d.mts.map +1 -0
  13. package/dist/email.mjs +12 -0
  14. package/dist/email.mjs.map +1 -0
  15. package/dist/index.d.mts +14 -0
  16. package/dist/index.mjs +18 -0
  17. package/dist/instance.d.mts +11 -0
  18. package/dist/instance.d.mts.map +1 -0
  19. package/dist/instance.mjs +21 -0
  20. package/dist/instance.mjs.map +1 -0
  21. package/dist/key.d.mts +2 -0
  22. package/dist/key.mjs +86 -0
  23. package/dist/key.mjs.map +1 -0
  24. package/dist/login.d.mts +49 -0
  25. package/dist/login.d.mts.map +1 -0
  26. package/dist/login.mjs +71 -0
  27. package/dist/login.mjs.map +1 -0
  28. package/dist/migrate.d.mts +46 -0
  29. package/dist/migrate.d.mts.map +1 -0
  30. package/dist/migrate.mjs +58 -0
  31. package/dist/migrate.mjs.map +1 -0
  32. package/dist/migration-manifest.d.mts +39 -0
  33. package/dist/migration-manifest.d.mts.map +1 -0
  34. package/dist/migration-manifest.mjs +77 -0
  35. package/dist/migration-manifest.mjs.map +1 -0
  36. package/dist/migration-session-B4xHeU_a.d.mts +56 -0
  37. package/dist/migration-session-B4xHeU_a.d.mts.map +1 -0
  38. package/dist/migration-session.d.mts +2 -0
  39. package/dist/migration-session.mjs +204 -0
  40. package/dist/migration-session.mjs.map +1 -0
  41. package/dist/migration-snapshot-OM5jQN1-.mjs +69 -0
  42. package/dist/migration-snapshot-OM5jQN1-.mjs.map +1 -0
  43. package/dist/migration-state.d.mts +41 -0
  44. package/dist/migration-state.d.mts.map +1 -0
  45. package/dist/migration-state.mjs +155 -0
  46. package/dist/migration-state.mjs.map +1 -0
  47. package/dist/migrations-manifest.json +109 -0
  48. package/dist/pglite-preparation.d.mts +23 -0
  49. package/dist/pglite-preparation.d.mts.map +1 -0
  50. package/dist/pglite-preparation.mjs +77 -0
  51. package/dist/pglite-preparation.mjs.map +1 -0
  52. package/dist/pglite-store.d.mts +29 -0
  53. package/dist/pglite-store.d.mts.map +1 -0
  54. package/dist/pglite-store.mjs +117 -0
  55. package/dist/pglite-store.mjs.map +1 -0
  56. package/dist/relations.d.mts +2 -0
  57. package/dist/relations.mjs +307 -0
  58. package/dist/relations.mjs.map +1 -0
  59. package/dist/resource.d.mts +50 -0
  60. package/dist/resource.d.mts.map +1 -0
  61. package/dist/resource.mjs +123 -0
  62. package/dist/resource.mjs.map +1 -0
  63. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  64. package/dist/schema.d.mts +2 -0
  65. package/dist/schema.mjs +495 -0
  66. package/dist/schema.mjs.map +1 -0
  67. package/dist/slug.d.mts +28 -0
  68. package/dist/slug.d.mts.map +1 -0
  69. package/dist/slug.mjs +55 -0
  70. package/dist/slug.mjs.map +1 -0
  71. package/dist/text.d.mts +10 -0
  72. package/dist/text.d.mts.map +1 -0
  73. package/dist/text.mjs +11 -0
  74. package/dist/text.mjs.map +1 -0
  75. package/dist/uuid-CKMzlIND.d.mts +26 -0
  76. package/dist/uuid-CKMzlIND.d.mts.map +1 -0
  77. package/dist/uuid.d.mts +2 -0
  78. package/dist/uuid.mjs +28 -0
  79. package/dist/uuid.mjs.map +1 -0
  80. package/drizzle/20260622021748_init/migration.sql +25 -0
  81. package/drizzle/20260622021748_init/snapshot.json +246 -0
  82. package/drizzle/20260623162238_dear_felicia_hardy/migration.sql +5 -0
  83. package/drizzle/20260623162238_dear_felicia_hardy/snapshot.json +321 -0
  84. package/drizzle/20260624094817_lethal_sinister_six/migration.sql +2 -0
  85. package/drizzle/20260624094817_lethal_sinister_six/snapshot.json +347 -0
  86. package/drizzle/20260716000333_email_auth/migration.sql +20 -0
  87. package/drizzle/20260716000333_email_auth/snapshot.json +575 -0
  88. package/drizzle/20260723065002_chief_colleen_wing/migration.sql +2 -0
  89. package/drizzle/20260723065002_chief_colleen_wing/snapshot.json +595 -0
  90. package/drizzle/20260802205417_separate-instance-local-remote/migration.sql +26 -0
  91. package/drizzle/20260802205417_separate-instance-local-remote/snapshot.json +768 -0
  92. package/drizzle/20260804061119_instances-local-remote-constraint/migration.sql +7 -0
  93. package/drizzle/20260804061119_instances-local-remote-constraint/snapshot.json +843 -0
  94. package/drizzle/20260818080259_dark_night_thrasher/migration.sql +15 -0
  95. package/drizzle/20260818080259_dark_night_thrasher/snapshot.json +722 -0
  96. package/drizzle/20260821072150_merge_remote_actors/migration.sql +54 -0
  97. package/drizzle/20260821072150_merge_remote_actors/snapshot.json +1312 -0
  98. package/drizzle/20260906052949_rename_followees_to_following/migration.sql +2 -0
  99. package/drizzle/20260906052949_rename_followees_to_following/snapshot.json +1315 -0
  100. package/drizzle/20260908062446_rename_login_tokens_to_login_challenges/migration.sql +1 -0
  101. package/drizzle/20260908062446_rename_login_tokens_to_login_challenges/snapshot.json +1312 -0
  102. package/drizzle/20260908065945_simplify_login_challenges/migration.sql +7 -0
  103. package/drizzle/20260908065945_simplify_login_challenges/snapshot.json +1290 -0
  104. package/drizzle/20260915061356_tighten_slug_constraint/migration.sql +12 -0
  105. package/drizzle/20260915061356_tighten_slug_constraint/snapshot.json +1290 -0
  106. package/drizzle/20260915063339_widen_instance_host/migration.sql +1 -0
  107. package/drizzle/20260915063339_widen_instance_host/snapshot.json +1290 -0
  108. package/drizzle/20260916085902_add_objects_activities_and_resources/migration.sql +110 -0
  109. package/drizzle/20260916085902_add_objects_activities_and_resources/snapshot.json +2263 -0
  110. package/drizzle/20260917163517_order_local_outbox_items/migration.sql +22 -0
  111. package/drizzle/20260917163517_order_local_outbox_items/snapshot.json +2263 -0
  112. package/drizzle/20260918071839_add_activity_object_index/migration.sql +1 -0
  113. package/drizzle/20260918071839_add_activity_object_index/snapshot.json +2298 -0
  114. package/drizzle/20261006061745_add_activity_deliveries_and_keys/migration.sql +106 -0
  115. package/drizzle/20261006061745_add_activity_deliveries_and_keys/snapshot.json +3538 -0
  116. package/drizzle/20261006085045_snake_case_columns/migration.sql +42 -0
  117. package/drizzle/20261006085045_snake_case_columns/snapshot.json +3570 -0
  118. package/drizzle/20261006122653_local_actor_keys/migration.sql +11 -0
  119. package/drizzle/20261006122653_local_actor_keys/snapshot.json +3627 -0
  120. package/drizzle/20261010044954_link_activity_deliveries_to_activities/migration.sql +8 -0
  121. package/drizzle/20261010044954_link_activity_deliveries_to_activities/snapshot.json +3714 -0
  122. package/drizzle/20261010073134_check_inbound_activity_link/migration.sql +1 -0
  123. package/drizzle/20261010073134_check_inbound_activity_link/snapshot.json +3721 -0
  124. package/drizzle/20261010104304_record_object_activity/migration.sql +3 -0
  125. package/drizzle/20261010104304_record_object_activity/snapshot.json +3756 -0
  126. package/drizzle/20261010111648_record_delivery_snapshot/migration.sql +29 -0
  127. package/drizzle/20261010111648_record_delivery_snapshot/snapshot.json +3769 -0
  128. package/drizzle/20261011144453_record_object_snapshot/migration.sql +10 -0
  129. package/drizzle/20261011144453_record_object_snapshot/snapshot.json +3808 -0
  130. package/drizzle/20261011192718_record_actor_followers/migration.sql +1 -0
  131. package/drizzle/20261011192718_record_actor_followers/snapshot.json +3821 -0
  132. package/package.json +181 -3
@@ -0,0 +1,495 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { desc, sql } from "drizzle-orm";
3
+ import { boolean, bytea, char, check, customType, foreignKey, index, integer, json, jsonb, pgEnum, pgTable, primaryKey, text, unique, uniqueIndex, uuid, varchar } from "drizzle-orm/pg-core";
4
+ //#region src/schema.ts
5
+ var schema_exports = /* @__PURE__ */ __exportAll({
6
+ LOGIN_CHALLENGE_CODE_LENGTH: () => 6,
7
+ accounts: () => accounts,
8
+ activities: () => activities,
9
+ activityDeliveries: () => activityDeliveries,
10
+ activityDeliveryActorCollections: () => activityDeliveryActorCollections,
11
+ activityDeliveryActors: () => activityDeliveryActors,
12
+ activityDeliveryAttempts: () => activityDeliveryAttempts,
13
+ activityDeliveryDirectionEnum: () => activityDeliveryDirectionEnum,
14
+ activityDeliveryStatusEnum: () => activityDeliveryStatusEnum,
15
+ activityDeliveryVerificationMechanismEnum: () => activityDeliveryVerificationMechanismEnum,
16
+ activityDeliveryVerificationResultEnum: () => activityDeliveryVerificationResultEnum,
17
+ activityTypeEnum: () => activityTypeEnum,
18
+ actorCollectionReferences: () => actorCollectionReferences,
19
+ actorTypeEnum: () => actorTypeEnum,
20
+ actors: () => actors,
21
+ addressing: () => addressing,
22
+ addressingPropertyEnum: () => addressingPropertyEnum,
23
+ collectionItems: () => collectionItems,
24
+ collectionRoleEnum: () => collectionRoleEnum,
25
+ collectionTypeEnum: () => collectionTypeEnum,
26
+ collections: () => collections,
27
+ instanceMembers: () => instanceMembers,
28
+ instances: () => instances,
29
+ keyVersions: () => keyVersions,
30
+ keys: () => keys,
31
+ localActorKeyTypeEnum: () => localActorKeyTypeEnum,
32
+ localActorKeys: () => localActorKeys,
33
+ localActors: () => localActors,
34
+ localInstances: () => localInstances,
35
+ loginChallenges: () => loginChallenges,
36
+ objectTypeEnum: () => objectTypeEnum,
37
+ objects: () => objects,
38
+ resourceKindEnum: () => resourceKindEnum,
39
+ resources: () => resources,
40
+ sessions: () => sessions
41
+ });
42
+ /** A timestamptz column preserving PostgreSQL's microsecond precision. */
43
+ const instant = customType({
44
+ dataType: () => "timestamp with time zone",
45
+ fromDriver: (value) => Temporal.Instant.from(value),
46
+ toDriver(value) {
47
+ if (typeof value === "string") return value;
48
+ if (value instanceof Temporal.Instant) return value.toString();
49
+ throw new TypeError("Expected a Temporal.Instant or a cursor timestamp string.");
50
+ }
51
+ });
52
+ const currentTimestamp = sql`CURRENT_TIMESTAMP`;
53
+ /**
54
+ * The database table to represent accounts.
55
+ */
56
+ const accounts = pgTable("accounts", {
57
+ id: uuid().$type().primaryKey(),
58
+ email: varchar({ length: 255 }).notNull().unique(),
59
+ name: varchar({ length: 100 }).notNull(),
60
+ maxInstances: integer("max_instances").notNull().default(10),
61
+ admin: boolean().notNull().default(false),
62
+ created: instant().notNull().default(currentTimestamp)
63
+ }, (table) => [
64
+ check("accounts_email_check", sql`${table.email} ~ '^[^@]+@[^@]+\\.[^@]+$'`),
65
+ check("accounts_max_instances_check", sql`${table.maxInstances} >= 0`),
66
+ check("accounts_name_check", sql`trim(both from ${table.name}) <> ''`)
67
+ ]);
68
+ /**
69
+ * The database table to represent instances.
70
+ */
71
+ const instances = pgTable("instances", {
72
+ id: uuid().$type().primaryKey(),
73
+ localId: uuid("local_id").$type().references(() => localInstances.id, { onDelete: "cascade" }),
74
+ created: instant().notNull().default(currentTimestamp),
75
+ host: varchar({ length: 259 }).notNull().unique(),
76
+ nodeInfoUrl: text("node_info_url"),
77
+ software: text(),
78
+ softwareVersion: text("software_version")
79
+ });
80
+ const localInstances = pgTable("local_instances", {
81
+ id: uuid().$type().primaryKey(),
82
+ slug: varchar({ length: 63 }).notNull().unique(),
83
+ expires: instant().notNull(),
84
+ maxActors: integer("max_actors").notNull().default(10)
85
+ }, (table) => [check("local_instances_slug_check", sql`${table.slug} ~ '^[a-z0-9][a-z0-9-]{2,61}[a-z0-9]$'
86
+ AND (${table.slug} !~ '^..--' OR ${table.slug} ~ '^xn--')`), check("instances_max_actors_check", sql`${table.maxActors} > 0`)]);
87
+ /**
88
+ * The association table between instances and its member accounts.
89
+ * Note that it also contains the just invited members, which are not yet
90
+ * accepted. The `accepted` field is `NULL` for those members.
91
+ */
92
+ const instanceMembers = pgTable("instance_members", {
93
+ accountId: uuid("account_id").$type().notNull().references(() => accounts.id),
94
+ instanceId: uuid("instance_id").$type().notNull().references(() => instances.id),
95
+ admin: boolean().notNull().default(false),
96
+ accepted: instant(),
97
+ created: instant().notNull().default(currentTimestamp)
98
+ }, (table) => [
99
+ primaryKey({ columns: [table.instanceId, table.accountId] }),
100
+ index().on(table.accountId).where(sql`${table.accepted} IS NOT NULL`),
101
+ index().on(table.instanceId).where(sql`${table.accepted} IS NOT NULL`)
102
+ ]);
103
+ /** The length of an email login verification code. */
104
+ const LOGIN_CHALLENGE_CODE_LENGTH = 6;
105
+ /**
106
+ * Email login challenges identified by a public UUID and verified by a
107
+ * plaintext code. Each challenge expires after 15 minutes and is single-use.
108
+ */
109
+ const loginChallenges = pgTable("login_challenges", {
110
+ id: uuid().$type().primaryKey(),
111
+ accountId: uuid("account_id").$type().notNull().references(() => accounts.id, { onDelete: "cascade" }),
112
+ code: char({ length: 6 }).notNull(),
113
+ created: instant().notNull().default(currentTimestamp),
114
+ expires: instant().notNull().default(sql`CURRENT_TIMESTAMP + INTERVAL '15 minutes'`),
115
+ consumed: instant()
116
+ });
117
+ /**
118
+ * Authenticated sessions. The `id` field is used to revoke a session, and
119
+ * the `tokenHash` is the hash of the bearer access token.
120
+ */
121
+ const sessions = pgTable("sessions", {
122
+ id: uuid().$type().primaryKey(),
123
+ accountId: uuid("account_id").$type().notNull().references(() => accounts.id, { onDelete: "cascade" }),
124
+ tokenHash: varchar("token_hash", { length: 64 }).notNull().unique(),
125
+ created: instant().notNull().default(currentTimestamp),
126
+ expires: instant().notNull().default(sql`CURRENT_TIMESTAMP + INTERVAL '1 month'`)
127
+ });
128
+ const actorTypeEnum = pgEnum("actor_type", [
129
+ "Application",
130
+ "Group",
131
+ "Organization",
132
+ "Person",
133
+ "Service"
134
+ ]);
135
+ const resourceKindEnum = pgEnum("resource_kind", [
136
+ "actor",
137
+ "object",
138
+ "activity",
139
+ "collection",
140
+ "unknown"
141
+ ]);
142
+ /**
143
+ * Canonical IRI registry. Physical deletion of an actor, object, activity or
144
+ * collection must also delete its source addressing and resource in the same
145
+ * transaction. References from other resources intentionally restrict deletion.
146
+ */
147
+ const resources = pgTable("resources", {
148
+ id: uuid().$type().primaryKey(),
149
+ iri: text().notNull().unique(),
150
+ kind: resourceKindEnum().notNull(),
151
+ created: instant().notNull().default(currentTimestamp)
152
+ });
153
+ const actors = pgTable("actors", {
154
+ id: uuid().$type().primaryKey().references(() => resources.id, { onDelete: "cascade" }),
155
+ localId: uuid("local_id").$type().unique().references(() => localActors.id, { onDelete: "cascade" }),
156
+ type: actorTypeEnum().notNull(),
157
+ /**
158
+ * A local actor's handle username; a remote actor's `preferredUsername`
159
+ * as received, which ActivityPub neither requires nor makes unique.
160
+ */
161
+ username: text(),
162
+ instanceId: uuid("instance_id").$type().notNull().references(() => instances.id, { onDelete: "cascade" }),
163
+ document: json(),
164
+ inboxUrl: text("inbox_url").notNull(),
165
+ /**
166
+ * The IRI of the followers collection a remote actor declares, as
167
+ * received. It is never fetched, so it is no `collections` row: what the
168
+ * collection is and holds is unknown.
169
+ */
170
+ followersUrl: text("followers_url"),
171
+ profileUrl: text("profile_url"),
172
+ avatarUrl: text("avatar_url"),
173
+ headerUrl: text("header_url"),
174
+ name: text(),
175
+ bioHtml: text("bio_html"),
176
+ automaticallyApprovesFollowers: boolean("automatically_approves_followers").notNull().default(false),
177
+ fieldHtmls: jsonb("field_htmls").$type().notNull().default({}),
178
+ emojis: jsonb().$type().notNull().default({}),
179
+ tags: jsonb().$type().notNull().default({}),
180
+ sensitive: boolean().notNull().default(false),
181
+ suspended: instant(),
182
+ suspendedUntil: instant("suspended_until"),
183
+ successorId: uuid("successor_id").$type().references(() => actors.id, { onDelete: "set null" }),
184
+ aliases: text().array().notNull().default(sql`(ARRAY[]::text[])`),
185
+ followingCount: integer("following_count").notNull().default(0),
186
+ followersCount: integer("followers_count").notNull().default(0),
187
+ updated: instant().notNull().default(currentTimestamp).$onUpdate(() => currentTimestamp),
188
+ published: instant(),
189
+ created: instant().notNull().default(currentTimestamp),
190
+ deleted: instant()
191
+ }, (t) => [
192
+ uniqueIndex("username_key").on(t.username, t.instanceId).where(sql`${t.localId} IS NOT NULL`),
193
+ check("actors_username_check", sql`${t.localId} IS NULL OR ${t.username} NOT LIKE '%@%'`),
194
+ check("actors_local_username_check", sql`${t.localId} IS NULL OR ${t.username} IS NOT NULL`),
195
+ check("actors_suspended_check", sql`
196
+ ${t.suspendedUntil} IS NULL OR (
197
+ ${t.suspended} IS NOT NULL AND
198
+ ${t.suspendedUntil} > ${t.suspended}
199
+ )
200
+ `),
201
+ index("actor_instance_index").on(t.instanceId)
202
+ ]);
203
+ const localActors = pgTable("local_actors", {
204
+ id: uuid().$type().primaryKey(),
205
+ avatar: text(),
206
+ header: text()
207
+ });
208
+ /** Signing algorithms available to local actors. */
209
+ const localActorKeyTypeEnum = pgEnum("local_actor_key_type", ["RSASSA-PKCS1-v1_5", "Ed25519"]);
210
+ /** Private signing material; never expose this table through GraphQL. */
211
+ const localActorKeys = pgTable("local_actor_keys", {
212
+ localActorId: uuid("local_actor_id").$type().notNull().references(() => localActors.id, { onDelete: "cascade" }),
213
+ type: localActorKeyTypeEnum().notNull(),
214
+ publicKey: jsonb("public_key").$type().notNull(),
215
+ privateKey: jsonb("private_key").$type().notNull()
216
+ }, (table) => [primaryKey({ columns: [table.localActorId, table.type] }), check("local_actor_keys_public_key_check", sql`jsonb_typeof(${table.publicKey}) = 'object' AND NOT (${table.publicKey} ?| array['d','p','q','dp','dq','qi','oth','k'])`)]);
217
+ const objectTypeEnum = pgEnum("object_type", ["Article", "Note"]);
218
+ /** ActivityPub objects authored by actors. */
219
+ const objects = pgTable("objects", {
220
+ id: uuid().$type().primaryKey().references(() => resources.id, { onDelete: "cascade" }),
221
+ actorId: uuid("actor_id").$type().notNull().references(() => actors.id, { onDelete: "cascade" }),
222
+ /**
223
+ * The activity that carried the stored snapshot. Who may read a remote
224
+ * object follows it, not the activities that refer to the object later
225
+ * with another version of it.
226
+ */
227
+ activityId: uuid("activity_id").$type().references(() => resources.id, { onDelete: "set null" }),
228
+ /**
229
+ * Whether `document` was fetched from the object's IRI rather than taken
230
+ * from the activity that carried it, which then proves nothing of it.
231
+ */
232
+ fetched: boolean().notNull().default(false),
233
+ type: objectTypeEnum().notNull(),
234
+ document: json(),
235
+ url: text(),
236
+ name: text(),
237
+ summary: text(),
238
+ contentHtml: text("content_html").notNull(),
239
+ language: varchar({ length: 35 }),
240
+ sensitive: boolean().notNull().default(false),
241
+ published: instant().notNull().default(currentTimestamp),
242
+ updated: instant().notNull().default(currentTimestamp).$onUpdate(() => currentTimestamp),
243
+ created: instant().notNull().default(currentTimestamp),
244
+ deleted: instant()
245
+ }, (t) => [
246
+ check("objects_content_html_check", sql`trim(both from ${t.contentHtml}) <> ''`),
247
+ unique("objects_activity_id_key").on(t.activityId),
248
+ index("object_actor_published_index").on(t.actorId, desc(t.published), desc(t.id))
249
+ ]);
250
+ const collectionTypeEnum = pgEnum("collection_type", ["Collection", "OrderedCollection"]);
251
+ const collectionRoleEnum = pgEnum("collection_role", [
252
+ "followers",
253
+ "following",
254
+ "featured",
255
+ "outbox"
256
+ ]);
257
+ const collections = pgTable("collections", {
258
+ id: uuid().$type().primaryKey().references(() => resources.id, { onDelete: "cascade" }),
259
+ type: collectionTypeEnum().notNull(),
260
+ /**
261
+ * Lifecycle owner of a locally managed collection. Physical deletion of
262
+ * the owner cascades to the collection and all references. Soft deletion
263
+ * hides the collection and every actor's reference to it from GraphQL.
264
+ */
265
+ ownerActorId: uuid("owner_actor_id").$type().references(() => actors.id, { onDelete: "cascade" }),
266
+ totalItems: integer("total_items"),
267
+ document: json(),
268
+ updated: instant().notNull().default(currentTimestamp).$onUpdate(() => currentTimestamp)
269
+ });
270
+ /** Actor-declared collection roles; a collection may be shared across roles or actors. */
271
+ const actorCollectionReferences = pgTable("actor_collection_references", {
272
+ actorId: uuid("actor_id").$type().notNull().references(() => actors.id, { onDelete: "cascade" }),
273
+ role: collectionRoleEnum().notNull(),
274
+ collectionId: uuid("collection_id").$type().notNull().references(() => collections.id, { onDelete: "cascade" })
275
+ }, (t) => [primaryKey({ columns: [t.actorId, t.role] }), index("actor_collection_reference_collection_index").on(t.collectionId)]);
276
+ const collectionItems = pgTable("collection_items", {
277
+ collectionId: uuid("collection_id").$type().notNull().references(() => collections.id, { onDelete: "cascade" }),
278
+ itemId: uuid("item_id").$type().notNull().references(() => resources.id, { onDelete: "cascade" }),
279
+ position: integer(),
280
+ observed: instant().notNull().default(currentTimestamp)
281
+ }, (t) => [primaryKey({ columns: [t.collectionId, t.itemId] }), index("collection_item_position_index").on(t.collectionId, t.position)]);
282
+ const activityTypeEnum = pgEnum("activity_type", ["Create"]);
283
+ const activities = pgTable("activities", {
284
+ id: uuid().$type().primaryKey().references(() => resources.id, { onDelete: "cascade" }),
285
+ type: activityTypeEnum().notNull(),
286
+ actorId: uuid("actor_id").$type().notNull().references(() => actors.id, { onDelete: "cascade" }),
287
+ objectId: uuid("object_id").$type().references(() => resources.id, { onDelete: "cascade" }),
288
+ published: instant().notNull(),
289
+ document: json(),
290
+ created: instant().notNull().default(currentTimestamp)
291
+ }, (t) => [index("activity_actor_published_index").on(t.actorId, desc(t.published), desc(t.id)), index("activity_object_published_index").on(t.objectId, t.published, t.id)]);
292
+ const addressingPropertyEnum = pgEnum("addressing_property", [
293
+ "to",
294
+ "cc",
295
+ "bto",
296
+ "bcc",
297
+ "audience"
298
+ ]);
299
+ const addressing = pgTable("addressing", {
300
+ id: uuid().$type().primaryKey(),
301
+ sourceId: uuid("source_id").$type().notNull().references(() => resources.id, { onDelete: "cascade" }),
302
+ property: addressingPropertyEnum().notNull(),
303
+ position: integer().notNull(),
304
+ targetId: uuid("target_id").$type().notNull().references(() => resources.id, { onDelete: "restrict" })
305
+ }, (t) => [unique("addressing_source_property_position_key").on(t.sourceId, t.property, t.position), index("addressing_target_property_index").on(t.targetId, t.property)]);
306
+ /** Direction of an observed delivery. */
307
+ const activityDeliveryDirectionEnum = pgEnum("activity_delivery_direction", ["inbound", "outbound"]);
308
+ /**
309
+ * Inbound: `received` (2xx, listener ran), `acknowledged` (2xx, listener did
310
+ * not run), `unverified`, `rejected` (refused although verified); a request
311
+ * whose handling threw is one of the last two, without a status code. Outbound:
312
+ * `queued` (no attempt ended yet), `sent`, `failed` (the latest attempt
313
+ * failed; a queued delivery may be retried), `permanently_failed`,
314
+ * `abandoned` (the retry policy ran out).
315
+ */
316
+ const activityDeliveryStatusEnum = pgEnum("activity_delivery_status", [
317
+ "received",
318
+ "acknowledged",
319
+ "unverified",
320
+ "rejected",
321
+ "queued",
322
+ "sent",
323
+ "failed",
324
+ "permanently_failed",
325
+ "abandoned"
326
+ ]);
327
+ /** The mechanism that authenticated an inbound activity. */
328
+ const activityDeliveryVerificationMechanismEnum = pgEnum("activity_delivery_verification_mechanism", [
329
+ "http_signature",
330
+ "ld_signature",
331
+ "object_integrity_proof"
332
+ ]);
333
+ /**
334
+ * What Fedify reported of an inbound verification; `unattempted` when it
335
+ * answered before verifying, and `unobserved` when recording failed.
336
+ */
337
+ const activityDeliveryVerificationResultEnum = pgEnum("activity_delivery_verification_result", [
338
+ "verified",
339
+ "invalid_signature",
340
+ "key_fetch_error",
341
+ "no_signature",
342
+ "unattempted",
343
+ "unobserved"
344
+ ]);
345
+ /** Logical public keys, identified by their exact IRI. */
346
+ const keys = pgTable("keys", {
347
+ id: uuid().$type().primaryKey(),
348
+ iri: text().notNull().unique(),
349
+ created: instant().notNull().default(currentTimestamp)
350
+ });
351
+ /** Immutable key material, independently retained from Fedify's KV cache. */
352
+ const keyVersions = pgTable("key_versions", {
353
+ id: uuid().$type().primaryKey(),
354
+ keyId: uuid("key_id").$type().notNull().references(() => keys.id, { onDelete: "restrict" }),
355
+ publicKey: jsonb("public_key").$type().notNull(),
356
+ fingerprint: text().notNull(),
357
+ /** DrFed observation time, not remote rotation time or evidence of continuous use. */
358
+ firstSeen: instant("first_seen").notNull(),
359
+ /** DrFed observation time, not remote rotation time or evidence of continuous use. */
360
+ lastSeen: instant("last_seen").notNull()
361
+ }, (table) => [
362
+ unique("key_versions_key_id_fingerprint_unique").on(table.keyId, table.fingerprint),
363
+ check("key_versions_seen_check", sql`${table.lastSeen} >= ${table.firstSeen}`),
364
+ check("key_versions_public_key_check", sql`NOT (${table.publicKey} ?| array['d','p','q','dp','dq','qi','oth','k'])`),
365
+ index("key_version_key_first_seen_index").on(table.keyId, table.firstSeen, table.id)
366
+ ]);
367
+ /** Delivery observations; payloads may contain unverified, private remote input. */
368
+ const activityDeliveries = pgTable("activity_deliveries", {
369
+ id: uuid().$type().primaryKey(),
370
+ instanceId: uuid("instance_id").$type().notNull().references(() => instances.id, { onDelete: "cascade" }),
371
+ /** The owner of the inbox the request arrived at, or the sending actor. */
372
+ actorId: uuid("actor_id").$type().references(() => actors.id, { onDelete: "set null" }),
373
+ direction: activityDeliveryDirectionEnum().notNull(),
374
+ status: activityDeliveryStatusEnum().notNull(),
375
+ verificationMechanism: activityDeliveryVerificationMechanismEnum("verification_mechanism"),
376
+ verificationResult: activityDeliveryVerificationResultEnum("verification_result"),
377
+ type: text(),
378
+ types: text().array().notNull().default(sql`'{}'`),
379
+ activityIri: text("activity_iri"),
380
+ /**
381
+ * The stored activity `activityIri` names: for an inbound delivery, only
382
+ * one Fedify verified and accepted. The database enforces the latter;
383
+ * `linkInboundActivity()` matches the IRI.
384
+ */
385
+ activityId: uuid("activity_id").$type().references(() => activities.id, { onDelete: "set null" }),
386
+ /**
387
+ * Whether an inbound delivery carried the stored activity as it is, not
388
+ * only its IRI. `linkInboundActivity()` decides it, and only such a
389
+ * delivery opens the activity to its instance.
390
+ */
391
+ carriedSnapshot: boolean("carried_snapshot").notNull().default(false),
392
+ /**
393
+ * The object an inbound delivery's inbox listener fetched from its IRI,
394
+ * when it had to.
395
+ */
396
+ fetchedObject: jsonb("fetched_object").$type(),
397
+ /**
398
+ * Whether an inbound delivery carried the object stored with its activity
399
+ * as it is: the activity carried it, or the delivery fetched it as stored.
400
+ * `linkInboundActivity()` decides it, and only such a delivery opens the
401
+ * object to its instance.
402
+ */
403
+ carriedObjectSnapshot: boolean("carried_object_snapshot").notNull().default(false),
404
+ objectType: text("object_type"),
405
+ objectIri: text("object_iri"),
406
+ signedKeyIri: text("signed_key_iri"),
407
+ /** A referenced version does not imply successful verification. */
408
+ verificationKeyId: uuid("verification_key_id").$type().references(() => keyVersions.id, { onDelete: "restrict" }),
409
+ /** Inbound, only the first `actor`; the rest are in `payload`. */
410
+ remoteActorIri: text("remote_actor_iri"),
411
+ remoteHost: text("remote_host"),
412
+ inboxUrl: text("inbox_url").notNull(),
413
+ requestUrl: text("request_url"),
414
+ /** Names are lowercase; original order and case are not kept. */
415
+ headers: jsonb().$type(),
416
+ body: bytea(),
417
+ statusCode: integer("status_code"),
418
+ responseBody: text("response_body"),
419
+ error: text(),
420
+ payload: jsonb().$type(),
421
+ recipientIris: text("recipient_iris").array().notNull().default(sql`'{}'`),
422
+ /** Inbound, when the request arrived; outbound, when delivery started. */
423
+ created: instant().notNull().default(currentTimestamp),
424
+ /** Inbound, when DrFed answered; outbound, the latest status change. */
425
+ completed: instant()
426
+ }, (table) => [
427
+ check("activity_deliveries_direction_status_check", sql`(${table.direction} = 'inbound' AND ${table.status} IN ('received', 'acknowledged', 'unverified', 'rejected')) OR (${table.direction} = 'outbound' AND ${table.status} IN ('queued', 'sent', 'failed', 'permanently_failed', 'abandoned'))`),
428
+ check("activity_deliveries_completed_check", sql`(${table.completed} IS NULL) = (${table.status} = 'queued')`),
429
+ check("activity_deliveries_status_code_check", sql`${table.statusCode} IS NULL OR ${table.statusCode} BETWEEN 100 AND 599`),
430
+ check("activity_deliveries_outbound_key_check", sql`${table.direction} <> 'outbound' OR ${table.verificationKeyId} IS NULL`),
431
+ check("activity_deliveries_verification_result_check", sql`(${table.direction} = 'inbound') = (${table.verificationResult} IS NOT NULL)`),
432
+ check("activity_deliveries_verification_mechanism_check", sql`${table.verificationMechanism} IS NULL OR (${table.direction} = 'inbound' AND ${table.verificationResult} NOT IN ('unattempted', 'unobserved'))`),
433
+ check("activity_deliveries_body_check", sql`(${table.direction} = 'inbound') = (${table.body} IS NOT NULL)`),
434
+ check("activity_deliveries_activity_check", sql`${table.activityId} IS NULL OR ${table.direction} = 'outbound' OR (${table.verificationResult} = 'verified' AND ${table.status} IN ('received', 'acknowledged'))`),
435
+ index("activity_delivery_instance_created_index").on(table.instanceId, desc(table.created), desc(table.id)),
436
+ index("activity_delivery_actor_index").on(table.actorId),
437
+ index("activity_delivery_activity_created_index").on(table.activityId, desc(table.created), desc(table.id)),
438
+ index("activity_delivery_verification_key_index").on(table.verificationKeyId),
439
+ index("activity_delivery_outbound_index").on(table.activityIri, table.inboxUrl).where(sql`${table.direction} = 'outbound'`)
440
+ ]);
441
+ /** Each ended attempt of an outbound delivery. */
442
+ const activityDeliveryAttempts = pgTable("activity_delivery_attempts", {
443
+ id: uuid().$type().primaryKey(),
444
+ deliveryId: uuid("delivery_id").$type().notNull().references(() => activityDeliveries.id, { onDelete: "cascade" }),
445
+ succeeded: boolean().notNull(),
446
+ statusCode: integer("status_code"),
447
+ responseBody: text("response_body"),
448
+ error: text(),
449
+ /** When the attempt ended. */
450
+ created: instant().notNull().default(currentTimestamp)
451
+ }, (table) => [
452
+ check("activity_delivery_attempts_status_code_check", sql`${table.statusCode} IS NULL OR ${table.statusCode} BETWEEN 100 AND 599`),
453
+ check("activity_delivery_attempts_error_check", sql`${table.succeeded} = (${table.error} IS NULL)`),
454
+ index("activity_delivery_attempt_delivery_index").on(table.deliveryId, table.created, table.id)
455
+ ]);
456
+ /**
457
+ * The local actors a delivery concerns, one row per delivery and actor; each
458
+ * must be a local actor of the delivery's instance, which the record functions
459
+ * check.
460
+ */
461
+ const activityDeliveryActors = pgTable("activity_delivery_actors", {
462
+ deliveryId: uuid("delivery_id").$type().notNull().references(() => activityDeliveries.id, { onDelete: "cascade" }),
463
+ actorId: uuid("actor_id").$type().notNull().references(() => actors.id, { onDelete: "cascade" }),
464
+ inboxOwner: boolean("inbox_owner").notNull().default(false),
465
+ /** Addressed directly or through a collection. */
466
+ addressed: boolean().notNull().default(false),
467
+ /** Addressed by its own IRI; collections are in a row each. */
468
+ addressedDirectly: boolean("addressed_directly").notNull().default(false),
469
+ sender: boolean().notNull().default(false),
470
+ /** The delivery's `created`, which an actor's deliveries are ordered by. */
471
+ created: instant().notNull()
472
+ }, (table) => [
473
+ primaryKey({ columns: [table.deliveryId, table.actorId] }),
474
+ check("activity_delivery_actors_role_check", sql`${table.inboxOwner} OR ${table.addressed} OR ${table.sender}`),
475
+ check("activity_delivery_actors_addressed_directly_check", sql`NOT ${table.addressedDirectly} OR ${table.addressed}`),
476
+ index("activity_delivery_actor_created_index").on(table.actorId, desc(table.created), desc(table.deliveryId))
477
+ ]);
478
+ /** Each addressed collection a delivery reached a local actor through. */
479
+ const activityDeliveryActorCollections = pgTable("activity_delivery_actor_collections", {
480
+ deliveryId: uuid("delivery_id").$type().notNull(),
481
+ actorId: uuid("actor_id").$type().notNull(),
482
+ collectionIri: text("collection_iri").notNull()
483
+ }, (table) => [primaryKey({ columns: [
484
+ table.deliveryId,
485
+ table.actorId,
486
+ table.collectionIri
487
+ ] }), foreignKey({
488
+ name: "activity_delivery_actor_collections_link_fkey",
489
+ columns: [table.deliveryId, table.actorId],
490
+ foreignColumns: [activityDeliveryActors.deliveryId, activityDeliveryActors.actorId]
491
+ }).onDelete("cascade")]);
492
+ //#endregion
493
+ export { LOGIN_CHALLENGE_CODE_LENGTH, accounts, activities, activityDeliveries, activityDeliveryActorCollections, activityDeliveryActors, activityDeliveryAttempts, activityDeliveryDirectionEnum, activityDeliveryStatusEnum, activityDeliveryVerificationMechanismEnum, activityDeliveryVerificationResultEnum, activityTypeEnum, actorCollectionReferences, actorTypeEnum, actors, addressing, addressingPropertyEnum, collectionItems, collectionRoleEnum, collectionTypeEnum, collections, instanceMembers, instances, keyVersions, keys, localActorKeyTypeEnum, localActorKeys, localActors, localInstances, loginChallenges, objectTypeEnum, objects, resourceKindEnum, resources, sessions, schema_exports as t };
494
+
495
+ //# sourceMappingURL=schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.mjs","names":[],"sources":["../src/schema.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 type { webcrypto } from \"node:crypto\";\n\nimport { desc, sql } from \"drizzle-orm\";\nimport {\n type AnyPgColumn,\n boolean,\n bytea,\n char,\n check,\n customType,\n foreignKey,\n index,\n integer,\n json,\n jsonb,\n pgEnum,\n pgTable,\n primaryKey,\n text,\n unique,\n uniqueIndex,\n uuid,\n varchar,\n} from \"drizzle-orm/pg-core\";\n\nimport type { PublicJwk } from \"./key.ts\";\nimport type { Uuid } from \"./uuid.ts\";\n\n/** A timestamptz column preserving PostgreSQL's microsecond precision. */\nconst instant = customType<{ data: Temporal.Instant; driverData: string }>({\n dataType: () => \"timestamp with time zone\",\n fromDriver: (value) => Temporal.Instant.from(value),\n toDriver(value: Temporal.Instant | string) {\n // Pothos composite cursors decode timestamps as strings.\n if (typeof value === \"string\") return value;\n if (value instanceof Temporal.Instant) return value.toString();\n throw new TypeError(\n \"Expected a Temporal.Instant or a cursor timestamp string.\",\n );\n },\n});\n\nconst currentTimestamp = sql`CURRENT_TIMESTAMP`;\n\n/**\n * The database table to represent accounts.\n */\nexport const accounts = pgTable(\n \"accounts\",\n {\n id: uuid().$type<Uuid>().primaryKey(),\n email: varchar({ length: 255 }).notNull().unique(),\n name: varchar({ length: 100 }).notNull(),\n maxInstances: integer(\"max_instances\").notNull().default(10),\n admin: boolean().notNull().default(false),\n created: instant().notNull().default(currentTimestamp),\n },\n (table) => [\n check(\n \"accounts_email_check\",\n sql`${table.email} ~ '^[^@]+@[^@]+\\\\.[^@]+$'`,\n ),\n check(\"accounts_max_instances_check\", sql`${table.maxInstances} >= 0`),\n check(\"accounts_name_check\", sql`trim(both from ${table.name}) <> ''`),\n ],\n);\n\nexport type Account = typeof accounts.$inferSelect;\nexport type NewAccount = typeof accounts.$inferInsert;\n\n/**\n * The database table to represent instances.\n */\nexport const instances = pgTable(\"instances\", {\n id: uuid().$type<Uuid>().primaryKey(),\n localId: uuid(\"local_id\")\n .$type<Uuid>()\n .references(() => localInstances.id, {\n onDelete: \"cascade\",\n }),\n created: instant().notNull().default(currentTimestamp),\n // The authority an instance is federated under, which is what Fedify's\n // `Context.host` reports and therefore what dispatchers look instances up\n // by. That is a DNS name, at most 253 octets, plus a `:port` suffix of up\n // to 6 more characters when the deployment is not on the scheme's default\n // port. Both locally composed `<slug>.<root domain>` names and remote\n // hosts discovered from the fediverse live here.\n host: varchar({ length: 259 }).notNull().unique(),\n nodeInfoUrl: text(\"node_info_url\"),\n software: text(),\n softwareVersion: text(\"software_version\"),\n});\n\nexport type Instance = typeof instances.$inferSelect;\nexport type NewInstance = typeof instances.$inferInsert;\n\nexport const localInstances = pgTable(\n \"local_instances\",\n {\n id: uuid().$type<Uuid>().primaryKey(),\n slug: varchar({ length: 63 }).notNull().unique(),\n expires: instant().notNull(),\n maxActors: integer(\"max_actors\").notNull().default(10),\n },\n (table) => [\n // Keep this in agreement with `isValidSlug()` in ./slug.ts. A slug\n // becomes the leftmost label of the instance's host name, so it has to be\n // a valid DNS label: no leading or trailing hyphen, and none of RFC 5891's\n // reserved LDH labels except the `xn--` prefix of an A-label, which stays\n // allowed so that instances can carry internationalized domain names.\n check(\n \"local_instances_slug_check\",\n sql`${table.slug} ~ '^[a-z0-9][a-z0-9-]{2,61}[a-z0-9]$'\n AND (${table.slug} !~ '^..--' OR ${table.slug} ~ '^xn--')`,\n ),\n check(\"instances_max_actors_check\", sql`${table.maxActors} > 0`),\n ],\n);\n\nexport type LocalInstance = typeof localInstances.$inferSelect;\nexport type NewLocalInstance = typeof localInstances.$inferInsert;\n\n/**\n * The association table between instances and its member accounts.\n * Note that it also contains the just invited members, which are not yet\n * accepted. The `accepted` field is `NULL` for those members.\n */\nexport const instanceMembers = pgTable(\n \"instance_members\",\n {\n accountId: uuid(\"account_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => accounts.id),\n instanceId: uuid(\"instance_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => instances.id),\n admin: boolean().notNull().default(false),\n accepted: instant(),\n created: instant().notNull().default(currentTimestamp),\n },\n (table) => [\n primaryKey({ columns: [table.instanceId, table.accountId] }),\n index()\n .on(table.accountId)\n .where(sql`${table.accepted} IS NOT NULL`),\n index()\n .on(table.instanceId)\n .where(sql`${table.accepted} IS NOT NULL`),\n ],\n);\n\nexport type InstanceMember = typeof instanceMembers.$inferSelect;\nexport type NewInstanceMember = typeof instanceMembers.$inferInsert;\n\n/** The length of an email login verification code. */\nexport const LOGIN_CHALLENGE_CODE_LENGTH = 6;\n\n/**\n * Email login challenges identified by a public UUID and verified by a\n * plaintext code. Each challenge expires after 15 minutes and is single-use.\n */\nexport const loginChallenges = pgTable(\"login_challenges\", {\n id: uuid().$type<Uuid>().primaryKey(),\n accountId: uuid(\"account_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => accounts.id, { onDelete: \"cascade\" }),\n code: char({ length: LOGIN_CHALLENGE_CODE_LENGTH }).notNull(),\n created: instant().notNull().default(currentTimestamp),\n expires: instant()\n .notNull()\n .default(sql`CURRENT_TIMESTAMP + INTERVAL '15 minutes'`),\n consumed: instant(),\n});\n\nexport type LoginChallenge = typeof loginChallenges.$inferSelect;\nexport type NewLoginChallenge = typeof loginChallenges.$inferInsert;\n\n/**\n * Authenticated sessions. The `id` field is used to revoke a session, and\n * the `tokenHash` is the hash of the bearer access token.\n */\nexport const sessions = pgTable(\"sessions\", {\n id: uuid().$type<Uuid>().primaryKey(),\n accountId: uuid(\"account_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => accounts.id, { onDelete: \"cascade\" }),\n tokenHash: varchar(\"token_hash\", { length: 64 }).notNull().unique(),\n created: instant().notNull().default(currentTimestamp),\n expires: instant()\n .notNull()\n .default(sql`CURRENT_TIMESTAMP + INTERVAL '1 month'`),\n});\n\nexport type Session = typeof sessions.$inferSelect;\nexport type NewSession = typeof sessions.$inferInsert;\n\nexport const actorTypeEnum = pgEnum(\"actor_type\", [\n \"Application\",\n \"Group\",\n \"Organization\",\n \"Person\",\n \"Service\",\n]);\n\nexport type ActorType = (typeof actorTypeEnum.enumValues)[number];\n\nexport const resourceKindEnum = pgEnum(\"resource_kind\", [\n \"actor\",\n \"object\",\n \"activity\",\n \"collection\",\n \"unknown\",\n]);\n\n/**\n * Canonical IRI registry. Physical deletion of an actor, object, activity or\n * collection must also delete its source addressing and resource in the same\n * transaction. References from other resources intentionally restrict deletion.\n */\nexport const resources = pgTable(\"resources\", {\n id: uuid().$type<Uuid>().primaryKey(),\n iri: text().notNull().unique(),\n kind: resourceKindEnum().notNull(),\n created: instant().notNull().default(currentTimestamp),\n});\nexport type Resource = typeof resources.$inferSelect;\n\nexport const actors = pgTable(\n \"actors\",\n {\n id: uuid()\n .$type<Uuid>()\n .primaryKey()\n .references(() => resources.id, { onDelete: \"cascade\" }),\n localId: uuid(\"local_id\")\n .$type<Uuid>()\n .unique()\n .references(() => localActors.id, { onDelete: \"cascade\" }),\n type: actorTypeEnum().notNull(),\n /**\n * A local actor's handle username; a remote actor's `preferredUsername`\n * as received, which ActivityPub neither requires nor makes unique.\n */\n username: text(),\n instanceId: uuid(\"instance_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => instances.id, { onDelete: \"cascade\" }),\n document: json(),\n inboxUrl: text(\"inbox_url\").notNull(),\n /**\n * The IRI of the followers collection a remote actor declares, as\n * received. It is never fetched, so it is no `collections` row: what the\n * collection is and holds is unknown.\n */\n followersUrl: text(\"followers_url\"),\n profileUrl: text(\"profile_url\"),\n avatarUrl: text(\"avatar_url\"),\n headerUrl: text(\"header_url\"),\n name: text(),\n bioHtml: text(\"bio_html\"),\n automaticallyApprovesFollowers: boolean(\"automatically_approves_followers\")\n .notNull()\n .default(false),\n fieldHtmls: jsonb(\"field_htmls\")\n .$type<Record<string, string>>()\n .notNull()\n .default({}),\n emojis: jsonb().$type<Record<string, string>>().notNull().default({}),\n tags: jsonb().$type<Record<string, string>>().notNull().default({}),\n sensitive: boolean().notNull().default(false),\n // Moderation sanction state, denormalized from flag_action records\n // (which remain the audit source of truth):\n // - Not sanctioned: suspended IS NULL\n // - Temporary suspension: suspended = start, suspendedUntil = end\n // - Permanent suspension (ban) for local actors, or permanent federation\n // block for remote actors: suspended set, suspendedUntil IS NULL\n // Whether a sanction is *currently* active is always determined by\n // comparing against the current time (lazy expiry; no cron):\n // Temporal.Instant.compare(suspended, now) <= 0 AND (suspendedUntil IS NULL OR Temporal.Instant.compare(suspendedUntil, now) > 0).\n suspended: instant(),\n suspendedUntil: instant(\"suspended_until\"),\n successorId: uuid(\"successor_id\")\n .$type<Uuid>()\n .references((): AnyPgColumn => actors.id, {\n onDelete: \"set null\",\n }),\n aliases: text()\n .array()\n .notNull()\n .default(sql`(ARRAY[]::text[])`),\n followingCount: integer(\"following_count\").notNull().default(0),\n followersCount: integer(\"followers_count\").notNull().default(0),\n updated: instant()\n .notNull()\n .default(currentTimestamp)\n .$onUpdate(() => currentTimestamp),\n published: instant(),\n created: instant().notNull().default(currentTimestamp),\n // When implementing actor deletion, add activities.deleted and set it\n // together with objects.deleted in the same transaction.\n // FIXME: https://github.com/fedify-dev/drfed/issues/89\n deleted: instant(),\n },\n (t) => [\n uniqueIndex(\"username_key\")\n .on(t.username, t.instanceId)\n .where(sql`${t.localId} IS NOT NULL`),\n check(\n \"actors_username_check\",\n sql`${t.localId} IS NULL OR ${t.username} NOT LIKE '%@%'`,\n ),\n check(\n \"actors_local_username_check\",\n sql`${t.localId} IS NULL OR ${t.username} IS NOT NULL`,\n ),\n check(\n \"actors_suspended_check\",\n sql`\n ${t.suspendedUntil} IS NULL OR (\n ${t.suspended} IS NOT NULL AND\n ${t.suspendedUntil} > ${t.suspended}\n )\n `,\n ),\n index(\"actor_instance_index\").on(t.instanceId),\n ],\n);\n\nexport type Actor = typeof actors.$inferSelect;\nexport type NewActor = typeof actors.$inferInsert;\n\nexport const localActors = pgTable(\"local_actors\", {\n id: uuid().$type<Uuid>().primaryKey(),\n avatar: text(),\n header: text(),\n});\n\nexport type LocalActor = typeof localActors.$inferSelect;\nexport type NewLocalActor = typeof localActors.$inferInsert;\n\n/** Signing algorithms available to local actors. */\nexport const localActorKeyTypeEnum = pgEnum(\"local_actor_key_type\", [\n \"RSASSA-PKCS1-v1_5\",\n \"Ed25519\",\n]);\nexport type LocalActorKeyType =\n (typeof localActorKeyTypeEnum.enumValues)[number];\n/** Private signing material; never expose this table through GraphQL. */\nexport const localActorKeys = pgTable(\n \"local_actor_keys\",\n {\n localActorId: uuid(\"local_actor_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => localActors.id, { onDelete: \"cascade\" }),\n type: localActorKeyTypeEnum().notNull(),\n publicKey: jsonb(\"public_key\").$type<PublicJwk>().notNull(),\n privateKey: jsonb(\"private_key\").$type<webcrypto.JsonWebKey>().notNull(),\n },\n (table) => [\n primaryKey({ columns: [table.localActorId, table.type] }),\n check(\n \"local_actor_keys_public_key_check\",\n sql`jsonb_typeof(${table.publicKey}) = 'object' AND NOT (${table.publicKey} ?| array['d','p','q','dp','dq','qi','oth','k'])`,\n ),\n ],\n);\nexport type LocalActorKey = typeof localActorKeys.$inferSelect;\nexport type NewLocalActorKey = typeof localActorKeys.$inferInsert;\n\nexport const objectTypeEnum = pgEnum(\"object_type\", [\"Article\", \"Note\"]);\nexport type ObjectType = (typeof objectTypeEnum.enumValues)[number];\n/** ActivityPub objects authored by actors. */\nexport const objects = pgTable(\n \"objects\",\n {\n id: uuid()\n .$type<Uuid>()\n .primaryKey()\n .references(() => resources.id, { onDelete: \"cascade\" }),\n actorId: uuid(\"actor_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => actors.id, { onDelete: \"cascade\" }),\n /**\n * The activity that carried the stored snapshot. Who may read a remote\n * object follows it, not the activities that refer to the object later\n * with another version of it.\n */\n activityId: uuid(\"activity_id\")\n .$type<Uuid>()\n .references(() => resources.id, { onDelete: \"set null\" }),\n /**\n * Whether `document` was fetched from the object's IRI rather than taken\n * from the activity that carried it, which then proves nothing of it.\n */\n fetched: boolean().notNull().default(false),\n type: objectTypeEnum().notNull(),\n document: json(),\n url: text(),\n name: text(),\n summary: text(),\n contentHtml: text(\"content_html\").notNull(),\n language: varchar({ length: 35 }),\n sensitive: boolean().notNull().default(false),\n published: instant().notNull().default(currentTimestamp),\n updated: instant()\n .notNull()\n .default(currentTimestamp)\n .$onUpdate(() => currentTimestamp),\n created: instant().notNull().default(currentTimestamp),\n deleted: instant(),\n },\n (t) => [\n check(\n \"objects_content_html_check\",\n sql`trim(both from ${t.contentHtml}) <> ''`,\n ),\n unique(\"objects_activity_id_key\").on(t.activityId),\n index(\"object_actor_published_index\").on(\n t.actorId,\n desc(t.published),\n desc(t.id),\n ),\n ],\n);\nexport type ActivityPubObject = typeof objects.$inferSelect;\nexport type NewActivityPubObject = typeof objects.$inferInsert;\n\nexport const collectionTypeEnum = pgEnum(\"collection_type\", [\n \"Collection\",\n \"OrderedCollection\",\n]);\nexport const collectionRoleEnum = pgEnum(\"collection_role\", [\n \"followers\",\n \"following\",\n \"featured\",\n \"outbox\",\n]);\nexport type CollectionRole = (typeof collectionRoleEnum.enumValues)[number];\nexport const collections = pgTable(\"collections\", {\n id: uuid()\n .$type<Uuid>()\n .primaryKey()\n .references(() => resources.id, { onDelete: \"cascade\" }),\n type: collectionTypeEnum().notNull(),\n /**\n * Lifecycle owner of a locally managed collection. Physical deletion of\n * the owner cascades to the collection and all references. Soft deletion\n * hides the collection and every actor's reference to it from GraphQL.\n */\n ownerActorId: uuid(\"owner_actor_id\")\n .$type<Uuid>()\n .references(() => actors.id, { onDelete: \"cascade\" }),\n totalItems: integer(\"total_items\"),\n document: json(),\n updated: instant()\n .notNull()\n .default(currentTimestamp)\n .$onUpdate(() => currentTimestamp),\n});\nexport type Collection = typeof collections.$inferSelect;\n\n/** Actor-declared collection roles; a collection may be shared across roles or actors. */\nexport const actorCollectionReferences = pgTable(\n \"actor_collection_references\",\n {\n actorId: uuid(\"actor_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => actors.id, { onDelete: \"cascade\" }),\n role: collectionRoleEnum().notNull(),\n collectionId: uuid(\"collection_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => collections.id, { onDelete: \"cascade\" }),\n },\n (t) => [\n primaryKey({ columns: [t.actorId, t.role] }),\n index(\"actor_collection_reference_collection_index\").on(t.collectionId),\n ],\n);\n\nexport const collectionItems = pgTable(\n \"collection_items\",\n {\n collectionId: uuid(\"collection_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => collections.id, { onDelete: \"cascade\" }),\n itemId: uuid(\"item_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => resources.id, { onDelete: \"cascade\" }),\n position: integer(),\n observed: instant().notNull().default(currentTimestamp),\n },\n (t) => [\n primaryKey({ columns: [t.collectionId, t.itemId] }),\n index(\"collection_item_position_index\").on(t.collectionId, t.position),\n ],\n);\n\nexport const activityTypeEnum = pgEnum(\"activity_type\", [\"Create\"]);\nexport const activities = pgTable(\n \"activities\",\n {\n id: uuid()\n .$type<Uuid>()\n .primaryKey()\n .references(() => resources.id, { onDelete: \"cascade\" }),\n type: activityTypeEnum().notNull(),\n actorId: uuid(\"actor_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => actors.id, { onDelete: \"cascade\" }),\n objectId: uuid(\"object_id\")\n .$type<Uuid>()\n .references(() => resources.id, { onDelete: \"cascade\" }),\n published: instant().notNull(),\n document: json(),\n created: instant().notNull().default(currentTimestamp),\n },\n (t) => [\n index(\"activity_actor_published_index\").on(\n t.actorId,\n desc(t.published),\n desc(t.id),\n ),\n index(\"activity_object_published_index\").on(t.objectId, t.published, t.id),\n ],\n);\nexport type StoredActivity = typeof activities.$inferSelect;\n\nexport const addressingPropertyEnum = pgEnum(\"addressing_property\", [\n \"to\",\n \"cc\",\n \"bto\",\n \"bcc\",\n \"audience\",\n]);\nexport type AddressingProperty =\n (typeof addressingPropertyEnum.enumValues)[number];\nexport const addressing = pgTable(\n \"addressing\",\n {\n id: uuid().$type<Uuid>().primaryKey(),\n sourceId: uuid(\"source_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => resources.id, { onDelete: \"cascade\" }),\n property: addressingPropertyEnum().notNull(),\n position: integer().notNull(),\n targetId: uuid(\"target_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => resources.id, { onDelete: \"restrict\" }),\n },\n (t) => [\n unique(\"addressing_source_property_position_key\").on(\n t.sourceId,\n t.property,\n t.position,\n ),\n index(\"addressing_target_property_index\").on(t.targetId, t.property),\n ],\n);\nexport type Addressing = typeof addressing.$inferSelect;\n\n/** Direction of an observed delivery. */\nexport const activityDeliveryDirectionEnum = pgEnum(\n \"activity_delivery_direction\",\n [\"inbound\", \"outbound\"],\n);\n\n/**\n * Inbound: `received` (2xx, listener ran), `acknowledged` (2xx, listener did\n * not run), `unverified`, `rejected` (refused although verified); a request\n * whose handling threw is one of the last two, without a status code. Outbound:\n * `queued` (no attempt ended yet), `sent`, `failed` (the latest attempt\n * failed; a queued delivery may be retried), `permanently_failed`,\n * `abandoned` (the retry policy ran out).\n */\nexport const activityDeliveryStatusEnum = pgEnum(\"activity_delivery_status\", [\n \"received\",\n \"acknowledged\",\n \"unverified\",\n \"rejected\",\n \"queued\",\n \"sent\",\n \"failed\",\n \"permanently_failed\",\n \"abandoned\",\n]);\n\n/** The mechanism that authenticated an inbound activity. */\nexport const activityDeliveryVerificationMechanismEnum = pgEnum(\n \"activity_delivery_verification_mechanism\",\n [\"http_signature\", \"ld_signature\", \"object_integrity_proof\"],\n);\n\n/**\n * What Fedify reported of an inbound verification; `unattempted` when it\n * answered before verifying, and `unobserved` when recording failed.\n */\nexport const activityDeliveryVerificationResultEnum = pgEnum(\n \"activity_delivery_verification_result\",\n [\n \"verified\",\n \"invalid_signature\",\n \"key_fetch_error\",\n \"no_signature\",\n \"unattempted\",\n \"unobserved\",\n ],\n);\n\n/** Logical public keys, identified by their exact IRI. */\nexport const keys = pgTable(\"keys\", {\n id: uuid().$type<Uuid>().primaryKey(),\n iri: text().notNull().unique(),\n created: instant().notNull().default(currentTimestamp),\n});\n\n/** Immutable key material, independently retained from Fedify's KV cache. */\nexport const keyVersions = pgTable(\n \"key_versions\",\n {\n id: uuid().$type<Uuid>().primaryKey(),\n keyId: uuid(\"key_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => keys.id, { onDelete: \"restrict\" }),\n publicKey: jsonb(\"public_key\").$type<PublicJwk>().notNull(),\n fingerprint: text().notNull(),\n /** DrFed observation time, not remote rotation time or evidence of continuous use. */\n firstSeen: instant(\"first_seen\").notNull(),\n /** DrFed observation time, not remote rotation time or evidence of continuous use. */\n lastSeen: instant(\"last_seen\").notNull(),\n },\n (table) => [\n unique(\"key_versions_key_id_fingerprint_unique\").on(\n table.keyId,\n table.fingerprint,\n ),\n check(\n \"key_versions_seen_check\",\n sql`${table.lastSeen} >= ${table.firstSeen}`,\n ),\n check(\n \"key_versions_public_key_check\",\n sql`NOT (${table.publicKey} ?| array['d','p','q','dp','dq','qi','oth','k'])`,\n ),\n index(\"key_version_key_first_seen_index\").on(\n table.keyId,\n table.firstSeen,\n table.id,\n ),\n ],\n);\n\n/** Delivery observations; payloads may contain unverified, private remote input. */\nexport const activityDeliveries = pgTable(\n \"activity_deliveries\",\n {\n id: uuid().$type<Uuid>().primaryKey(),\n instanceId: uuid(\"instance_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => instances.id, { onDelete: \"cascade\" }),\n /** The owner of the inbox the request arrived at, or the sending actor. */\n actorId: uuid(\"actor_id\")\n .$type<Uuid>()\n .references(() => actors.id, { onDelete: \"set null\" }),\n direction: activityDeliveryDirectionEnum().notNull(),\n status: activityDeliveryStatusEnum().notNull(),\n verificationMechanism: activityDeliveryVerificationMechanismEnum(\n \"verification_mechanism\",\n ),\n verificationResult: activityDeliveryVerificationResultEnum(\n \"verification_result\",\n ),\n type: text(),\n types: text()\n .array()\n .notNull()\n .default(sql`'{}'`),\n activityIri: text(\"activity_iri\"),\n /**\n * The stored activity `activityIri` names: for an inbound delivery, only\n * one Fedify verified and accepted. The database enforces the latter;\n * `linkInboundActivity()` matches the IRI.\n */\n activityId: uuid(\"activity_id\")\n .$type<Uuid>()\n .references(() => activities.id, { onDelete: \"set null\" }),\n /**\n * Whether an inbound delivery carried the stored activity as it is, not\n * only its IRI. `linkInboundActivity()` decides it, and only such a\n * delivery opens the activity to its instance.\n */\n carriedSnapshot: boolean(\"carried_snapshot\").notNull().default(false),\n /**\n * The object an inbound delivery's inbox listener fetched from its IRI,\n * when it had to.\n */\n fetchedObject: jsonb(\"fetched_object\").$type<unknown>(),\n /**\n * Whether an inbound delivery carried the object stored with its activity\n * as it is: the activity carried it, or the delivery fetched it as stored.\n * `linkInboundActivity()` decides it, and only such a delivery opens the\n * object to its instance.\n */\n carriedObjectSnapshot: boolean(\"carried_object_snapshot\")\n .notNull()\n .default(false),\n objectType: text(\"object_type\"),\n objectIri: text(\"object_iri\"),\n signedKeyIri: text(\"signed_key_iri\"),\n /** A referenced version does not imply successful verification. */\n verificationKeyId: uuid(\"verification_key_id\")\n .$type<Uuid>()\n .references(() => keyVersions.id, { onDelete: \"restrict\" }),\n /** Inbound, only the first `actor`; the rest are in `payload`. */\n remoteActorIri: text(\"remote_actor_iri\"),\n remoteHost: text(\"remote_host\"),\n inboxUrl: text(\"inbox_url\").notNull(),\n requestUrl: text(\"request_url\"),\n /** Names are lowercase; original order and case are not kept. */\n headers: jsonb().$type<readonly (readonly [string, string])[]>(),\n body: bytea(),\n statusCode: integer(\"status_code\"),\n responseBody: text(\"response_body\"),\n error: text(),\n payload: jsonb().$type<unknown>(),\n recipientIris: text(\"recipient_iris\")\n .array()\n .notNull()\n .default(sql`'{}'`),\n /** Inbound, when the request arrived; outbound, when delivery started. */\n created: instant().notNull().default(currentTimestamp),\n /** Inbound, when DrFed answered; outbound, the latest status change. */\n completed: instant(),\n },\n (table) => [\n check(\n \"activity_deliveries_direction_status_check\",\n sql`(${table.direction} = 'inbound' AND ${table.status} IN ('received', 'acknowledged', 'unverified', 'rejected')) OR (${table.direction} = 'outbound' AND ${table.status} IN ('queued', 'sent', 'failed', 'permanently_failed', 'abandoned'))`,\n ),\n check(\n \"activity_deliveries_completed_check\",\n sql`(${table.completed} IS NULL) = (${table.status} = 'queued')`,\n ),\n check(\n \"activity_deliveries_status_code_check\",\n sql`${table.statusCode} IS NULL OR ${table.statusCode} BETWEEN 100 AND 599`,\n ),\n check(\n \"activity_deliveries_outbound_key_check\",\n sql`${table.direction} <> 'outbound' OR ${table.verificationKeyId} IS NULL`,\n ),\n check(\n \"activity_deliveries_verification_result_check\",\n sql`(${table.direction} = 'inbound') = (${table.verificationResult} IS NOT NULL)`,\n ),\n check(\n \"activity_deliveries_verification_mechanism_check\",\n sql`${table.verificationMechanism} IS NULL OR (${table.direction} = 'inbound' AND ${table.verificationResult} NOT IN ('unattempted', 'unobserved'))`,\n ),\n check(\n \"activity_deliveries_body_check\",\n sql`(${table.direction} = 'inbound') = (${table.body} IS NOT NULL)`,\n ),\n check(\n \"activity_deliveries_activity_check\",\n sql`${table.activityId} IS NULL OR ${table.direction} = 'outbound' OR (${table.verificationResult} = 'verified' AND ${table.status} IN ('received', 'acknowledged'))`,\n ),\n index(\"activity_delivery_instance_created_index\").on(\n table.instanceId,\n desc(table.created),\n desc(table.id),\n ),\n index(\"activity_delivery_actor_index\").on(table.actorId),\n index(\"activity_delivery_activity_created_index\").on(\n table.activityId,\n desc(table.created),\n desc(table.id),\n ),\n index(\"activity_delivery_verification_key_index\").on(\n table.verificationKeyId,\n ),\n index(\"activity_delivery_outbound_index\")\n .on(table.activityIri, table.inboxUrl)\n .where(sql`${table.direction} = 'outbound'`),\n ],\n);\n\n/** Each ended attempt of an outbound delivery. */\nexport const activityDeliveryAttempts = pgTable(\n \"activity_delivery_attempts\",\n {\n id: uuid().$type<Uuid>().primaryKey(),\n deliveryId: uuid(\"delivery_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => activityDeliveries.id, { onDelete: \"cascade\" }),\n succeeded: boolean().notNull(),\n statusCode: integer(\"status_code\"),\n responseBody: text(\"response_body\"),\n error: text(),\n /** When the attempt ended. */\n created: instant().notNull().default(currentTimestamp),\n },\n (table) => [\n check(\n \"activity_delivery_attempts_status_code_check\",\n sql`${table.statusCode} IS NULL OR ${table.statusCode} BETWEEN 100 AND 599`,\n ),\n check(\n \"activity_delivery_attempts_error_check\",\n sql`${table.succeeded} = (${table.error} IS NULL)`,\n ),\n index(\"activity_delivery_attempt_delivery_index\").on(\n table.deliveryId,\n table.created,\n table.id,\n ),\n ],\n);\n\n/**\n * The local actors a delivery concerns, one row per delivery and actor; each\n * must be a local actor of the delivery's instance, which the record functions\n * check.\n */\nexport const activityDeliveryActors = pgTable(\n \"activity_delivery_actors\",\n {\n deliveryId: uuid(\"delivery_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => activityDeliveries.id, { onDelete: \"cascade\" }),\n actorId: uuid(\"actor_id\")\n .$type<Uuid>()\n .notNull()\n .references(() => actors.id, { onDelete: \"cascade\" }),\n inboxOwner: boolean(\"inbox_owner\").notNull().default(false),\n /** Addressed directly or through a collection. */\n addressed: boolean().notNull().default(false),\n /** Addressed by its own IRI; collections are in a row each. */\n addressedDirectly: boolean(\"addressed_directly\").notNull().default(false),\n sender: boolean().notNull().default(false),\n /** The delivery's `created`, which an actor's deliveries are ordered by. */\n created: instant().notNull(),\n },\n (table) => [\n primaryKey({ columns: [table.deliveryId, table.actorId] }),\n check(\n \"activity_delivery_actors_role_check\",\n sql`${table.inboxOwner} OR ${table.addressed} OR ${table.sender}`,\n ),\n check(\n \"activity_delivery_actors_addressed_directly_check\",\n sql`NOT ${table.addressedDirectly} OR ${table.addressed}`,\n ),\n index(\"activity_delivery_actor_created_index\").on(\n table.actorId,\n desc(table.created),\n desc(table.deliveryId),\n ),\n ],\n);\n\n/** Each addressed collection a delivery reached a local actor through. */\nexport const activityDeliveryActorCollections = pgTable(\n \"activity_delivery_actor_collections\",\n {\n deliveryId: uuid(\"delivery_id\").$type<Uuid>().notNull(),\n actorId: uuid(\"actor_id\").$type<Uuid>().notNull(),\n collectionIri: text(\"collection_iri\").notNull(),\n },\n (table) => [\n primaryKey({\n columns: [table.deliveryId, table.actorId, table.collectionIri],\n }),\n foreignKey({\n name: \"activity_delivery_actor_collections_link_fkey\",\n columns: [table.deliveryId, table.actorId],\n foreignColumns: [\n activityDeliveryActors.deliveryId,\n activityDeliveryActors.actorId,\n ],\n }).onDelete(\"cascade\"),\n ],\n);\nexport type Key = typeof keys.$inferSelect;\nexport type KeyVersion = typeof keyVersions.$inferSelect;\nexport type ActivityDelivery = typeof activityDeliveries.$inferSelect;\nexport type NewActivityDelivery = typeof activityDeliveries.$inferInsert;\nexport type ActivityDeliveryAttempt =\n typeof activityDeliveryAttempts.$inferSelect;\nexport type ActivityDeliveryActor = typeof activityDeliveryActors.$inferSelect;\nexport type NewActivityDeliveryActor =\n typeof activityDeliveryActors.$inferInsert;\nexport type ActivityDeliveryActorCollection =\n typeof activityDeliveryActorCollections.$inferSelect;\nexport type ActivityDeliveryDirection =\n (typeof activityDeliveryDirectionEnum.enumValues)[number];\nexport type ActivityDeliveryStatus =\n (typeof activityDeliveryStatusEnum.enumValues)[number];\nexport type ActivityDeliveryVerificationMechanism =\n (typeof activityDeliveryVerificationMechanismEnum.enumValues)[number];\nexport type ActivityDeliveryVerificationResult =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,CAAC,MAAY,CAAC,CAAC,QAAQ;CACtD,SAAS,KAAK,UAAU,CAAC,CAAC,MAAY,CAAC,CAAC,QAAQ;CAChD,eAAe,KAAK,gBAAgB,CAAC,CAAC,QAAQ;AAChD,IACC,UAAU,CACT,WAAW,EACT,SAAS;CAAC,MAAM;CAAY,MAAM;CAAS,MAAM;AAAa,EAChE,CAAC,GACD,WAAW;CACT,MAAM;CACN,SAAS,CAAC,MAAM,YAAY,MAAM,OAAO;CACzC,gBAAgB,CACd,uBAAuB,YACvB,uBAAuB,OACzB;AACF,CAAC,CAAC,CAAC,SAAS,SAAS,CACvB,CACF"}
@@ -0,0 +1,28 @@
1
+ //#region src/slug.d.ts
2
+ /**
3
+ * Checks whether a slug can be used as the leftmost label of an instance's
4
+ * host name.
5
+ *
6
+ * A slug has to be a valid DNS label, because it becomes one: an instance with
7
+ * the slug `foo-bar` is served at `foo-bar.<root domain>`. That rules out
8
+ * leading and trailing hyphens, which no resolver accepts, and the reserved
9
+ * LDH labels of RFC 5891 — except for `xn--`, which is deliberately allowed so
10
+ * that instances can carry internationalized domain names. DrFed is a tool for
11
+ * debugging federation, and IDN host names are one of the things that break it.
12
+ *
13
+ * Whether such a label is decodable Punycode is deliberately not checked here.
14
+ * Node answers that out of its bundled ICU, so the answer moves with the
15
+ * runtime, and a rule that accepts a slug on one deployment while rejecting it
16
+ * on another is worse than no rule at all. `createInstance` instead refuses a
17
+ * slug whose composed host the local runtime cannot parse, which is the thing
18
+ * that actually matters.
19
+ *
20
+ * This duplicates the `local_instances_slug_check` constraint in
21
+ * {@link file://./schema.ts}; the two must be kept in agreement.
22
+ * @param slug The slug to check.
23
+ * @returns `true` if the slug is usable, `false` otherwise.
24
+ */
25
+ declare function isValidSlug(slug: string): boolean;
26
+ //#endregion
27
+ export { isValidSlug };
28
+ //# sourceMappingURL=slug.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slug.d.mts","names":[],"sources":["../src/slug.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;iBAiEgB,YAAY"}