@fedify/adonisjs 2.4.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 (82) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +420 -0
  3. package/dist/configure.cjs +108 -0
  4. package/dist/configure.cjs.map +1 -0
  5. package/dist/configure.d.cts +14 -0
  6. package/dist/configure.d.ts +14 -0
  7. package/dist/configure.js +107 -0
  8. package/dist/configure.js.map +1 -0
  9. package/dist/index.cjs +19 -0
  10. package/dist/index.d.cts +8 -0
  11. package/dist/index.d.ts +8 -0
  12. package/dist/index.js +8 -0
  13. package/dist/package.cjs +121 -0
  14. package/dist/package.cjs.map +1 -0
  15. package/dist/package.js +115 -0
  16. package/dist/package.js.map +1 -0
  17. package/dist/providers/fedify_provider.cjs +270 -0
  18. package/dist/providers/fedify_provider.cjs.map +1 -0
  19. package/dist/providers/fedify_provider.d.cts +54 -0
  20. package/dist/providers/fedify_provider.d.ts +55 -0
  21. package/dist/providers/fedify_provider.js +269 -0
  22. package/dist/providers/fedify_provider.js.map +1 -0
  23. package/dist/services/builder.cjs +9 -0
  24. package/dist/services/builder.cjs.map +1 -0
  25. package/dist/services/builder.d.cts +7 -0
  26. package/dist/services/builder.d.ts +8 -0
  27. package/dist/services/builder.js +8 -0
  28. package/dist/services/builder.js.map +1 -0
  29. package/dist/src/builder.cjs +55 -0
  30. package/dist/src/builder.cjs.map +1 -0
  31. package/dist/src/builder.d.cts +14 -0
  32. package/dist/src/builder.d.ts +14 -0
  33. package/dist/src/builder.js +54 -0
  34. package/dist/src/builder.js.map +1 -0
  35. package/dist/src/define_config.cjs +114 -0
  36. package/dist/src/define_config.cjs.map +1 -0
  37. package/dist/src/define_config.d.cts +30 -0
  38. package/dist/src/define_config.d.ts +30 -0
  39. package/dist/src/define_config.js +113 -0
  40. package/dist/src/define_config.js.map +1 -0
  41. package/dist/src/errors.cjs +77 -0
  42. package/dist/src/errors.cjs.map +1 -0
  43. package/dist/src/errors.d.cts +56 -0
  44. package/dist/src/errors.d.ts +56 -0
  45. package/dist/src/errors.js +73 -0
  46. package/dist/src/errors.js.map +1 -0
  47. package/dist/src/fedify_middleware.cjs +507 -0
  48. package/dist/src/fedify_middleware.cjs.map +1 -0
  49. package/dist/src/fedify_middleware.d.cts +85 -0
  50. package/dist/src/fedify_middleware.d.ts +85 -0
  51. package/dist/src/fedify_middleware.js +505 -0
  52. package/dist/src/fedify_middleware.js.map +1 -0
  53. package/dist/src/http_context.cjs +79 -0
  54. package/dist/src/http_context.cjs.map +1 -0
  55. package/dist/src/http_context.d.cts +31 -0
  56. package/dist/src/http_context.d.ts +31 -0
  57. package/dist/src/http_context.js +76 -0
  58. package/dist/src/http_context.js.map +1 -0
  59. package/dist/src/logging.cjs +106 -0
  60. package/dist/src/logging.cjs.map +1 -0
  61. package/dist/src/logging.d.cts +45 -0
  62. package/dist/src/logging.d.ts +45 -0
  63. package/dist/src/logging.js +106 -0
  64. package/dist/src/logging.js.map +1 -0
  65. package/dist/src/types.cjs +1 -0
  66. package/dist/src/types.d.cts +269 -0
  67. package/dist/src/types.d.ts +269 -0
  68. package/dist/src/types.js +1 -0
  69. package/dist/src/unusable_authority.cjs +79 -0
  70. package/dist/src/unusable_authority.cjs.map +1 -0
  71. package/dist/src/unusable_authority.js +76 -0
  72. package/dist/src/unusable_authority.js.map +1 -0
  73. package/dist/stubs/config/fedify.stub +105 -0
  74. package/dist/stubs/federation/main.stub +64 -0
  75. package/dist/stubs/main.cjs +16 -0
  76. package/dist/stubs/main.cjs.map +1 -0
  77. package/dist/stubs/main.d.cts +11 -0
  78. package/dist/stubs/main.d.ts +11 -0
  79. package/dist/stubs/main.js +15 -0
  80. package/dist/stubs/main.js.map +1 -0
  81. package/dist/stubs/start/federation.stub +20 -0
  82. package/package.json +124 -0
@@ -0,0 +1,30 @@
1
+ import { FedifyConfig, ResolvedFedifyConfig } from "./types.cjs";
2
+ import { ConfigProvider } from "@adonisjs/core/types";
3
+
4
+ //#region src/define_config.d.ts
5
+ /**
6
+ * Defines the Fedify configuration of an AdonisJS application.
7
+ *
8
+ * The return value is an AdonisJS *config provider* rather than a plain object,
9
+ * which lets the resolution step reach the application instance — needed to
10
+ * detect production mode and to log through the application's logger — while
11
+ * `config/fedify.ts` itself stays a simple, synchronous, statically analysable
12
+ * module.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // config/fedify.ts
17
+ * import { defineConfig } from '@fedify/adonisjs'
18
+ * import { SqliteKvStore } from '@fedify/sqlite'
19
+ * import env from '#start/env'
20
+ *
21
+ * export default defineConfig({
22
+ * origin: env.get('PUBLIC_URL'),
23
+ * kv: new SqliteKvStore(database),
24
+ * })
25
+ * ```
26
+ */
27
+ declare function defineConfig(config: FedifyConfig): ConfigProvider<ResolvedFedifyConfig>;
28
+ //#endregion
29
+ export { defineConfig };
30
+ //# sourceMappingURL=define_config.d.cts.map
@@ -0,0 +1,30 @@
1
+ import { FedifyConfig, ResolvedFedifyConfig } from "./types.js";
2
+ import { ConfigProvider } from "@adonisjs/core/types";
3
+
4
+ //#region src/define_config.d.ts
5
+ /**
6
+ * Defines the Fedify configuration of an AdonisJS application.
7
+ *
8
+ * The return value is an AdonisJS *config provider* rather than a plain object,
9
+ * which lets the resolution step reach the application instance — needed to
10
+ * detect production mode and to log through the application's logger — while
11
+ * `config/fedify.ts` itself stays a simple, synchronous, statically analysable
12
+ * module.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // config/fedify.ts
17
+ * import { defineConfig } from '@fedify/adonisjs'
18
+ * import { SqliteKvStore } from '@fedify/sqlite'
19
+ * import env from '#start/env'
20
+ *
21
+ * export default defineConfig({
22
+ * origin: env.get('PUBLIC_URL'),
23
+ * kv: new SqliteKvStore(database),
24
+ * })
25
+ * ```
26
+ */
27
+ declare function defineConfig(config: FedifyConfig): ConfigProvider<ResolvedFedifyConfig>;
28
+ //#endregion
29
+ export { defineConfig };
30
+ //# sourceMappingURL=define_config.d.ts.map
@@ -0,0 +1,113 @@
1
+ import { configProvider } from "@adonisjs/core";
2
+ import { InvalidArgumentsException } from "@adonisjs/core/exceptions";
3
+
4
+ //#region src/define_config.ts
5
+ /**
6
+ * The `defineConfig` helper used by `config/fedify.ts`.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Whether the `queue` option carries a queue at all.
12
+ *
13
+ * `FederationOptions.queue` takes either one `MessageQueue` for every role or
14
+ * an object of per-role queues, and Fedify reads an object whose members are
15
+ * all `undefined` as no queue. Testing the option's presence would therefore
16
+ * misfire in both directions: `queue: { outbox: app.inProduction ? q :
17
+ * undefined }` looks configured in development, and `queue: {}` looks like a
18
+ * queue that needs draining.
19
+ */
20
+ function hasQueue(queue) {
21
+ if (queue == null) return false;
22
+ if ("enqueue" in queue && "listen" in queue) return true;
23
+ return Object.values(queue).some((role) => role != null);
24
+ }
25
+ /**
26
+ * Defines the Fedify configuration of an AdonisJS application.
27
+ *
28
+ * The return value is an AdonisJS *config provider* rather than a plain object,
29
+ * which lets the resolution step reach the application instance — needed to
30
+ * detect production mode and to log through the application's logger — while
31
+ * `config/fedify.ts` itself stays a simple, synchronous, statically analysable
32
+ * module.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * // config/fedify.ts
37
+ * import { defineConfig } from '@fedify/adonisjs'
38
+ * import { SqliteKvStore } from '@fedify/sqlite'
39
+ * import env from '#start/env'
40
+ *
41
+ * export default defineConfig({
42
+ * origin: env.get('PUBLIC_URL'),
43
+ * kv: new SqliteKvStore(database),
44
+ * })
45
+ * ```
46
+ */
47
+ function defineConfig(config) {
48
+ return configProvider.create(async (app) => {
49
+ if (!config.origin) {
50
+ throw new InvalidArgumentsException("Missing \"origin\" in config/fedify.ts. It must be the canonical public URL of this server, " + "usually read from the PUBLIC_URL environment variable");
51
+ }
52
+ let kv = config.kv;
53
+ if (kv === undefined) {
54
+ const { MemoryKvStore } = await import("@fedify/fedify");
55
+ kv = new MemoryKvStore();
56
+ if (app.inProduction) {
57
+ const logger = await app.container.make("logger");
58
+ logger.warn("Fedify is using an in-memory key-value store in production. Inbox idempotency, " + "the document cache and outbox state will be lost on restart and cannot be shared " + "between processes. Configure \"kv\" in config/fedify.ts with a persistent store such " + "as @fedify/sqlite, @fedify/postgres or @fedify/redis");
59
+ }
60
+ }
61
+ const { contextDataFactory, ignoreRoutePrefixes, logging, queueContextData, ...federationOptions } = config;
62
+ /**
63
+ * A configured queue forces the "who drains it" decision to be explicit.
64
+ *
65
+ * Fedify's own default starts the queue lazily on the first enqueued task,
66
+ * capturing that request's context data and reusing it for every background
67
+ * job thereafter. For this integration the captured value would be a single
68
+ * stale `HttpContext`, whose request has long since finished. Rather than
69
+ * pick a wrong default, refuse to guess.
70
+ */
71
+ if (hasQueue(federationOptions.queue) && queueContextData === undefined) {
72
+ throw new InvalidArgumentsException("config/fedify.ts configures a \"queue\" but not \"queueContextData\". Set " + "\"queueContextData\" to a callback to have this process drain the queue, or to " + "\"false\" when a separate worker process owns it");
73
+ }
74
+ /**
75
+ * The mirror image: a drainer for a queue that does not exist. Nothing
76
+ * fails on its own — `startQueue()` resolves over no queues and
77
+ * `sendActivity()` delivers inline without retry, so failed deliveries are
78
+ * silently lost.
79
+ *
80
+ * Only a warning, because a task registered with
81
+ * `defineTask(name, { queue })` from a preload file brings its own queue,
82
+ * which this configuration cannot see. Refusing would break a valid
83
+ * application, and dropping the callback would hand that queue back to
84
+ * Fedify's lazy start. Only a *callback* is reported: `false` stays valid
85
+ * without a queue, so `queue: app.inProduction ? … : undefined` still
86
+ * boots in development and test.
87
+ */
88
+ if (!hasQueue(federationOptions.queue) && typeof queueContextData === "function") {
89
+ const logger = await app.container.make("logger");
90
+ logger.warn("config/fedify.ts sets \"queueContextData\" but no \"queue\". Unless a task registers its own " + "queue through defineTask(), there is nothing to drain and activity delivery stays " + "inline, with failed deliveries never retried. Configure \"queue\" with a message queue " + "such as @fedify/sqlite, @fedify/postgres, @fedify/redis or @fedify/amqp, or remove " + "\"queueContextData\"");
91
+ }
92
+ return {
93
+ ...federationOptions,
94
+ kv,
95
+ manuallyStartQueue: queueContextData !== undefined ? true : config.manuallyStartQueue,
96
+ /**
97
+ * The cast is sound because `ContextDataFactoryOption` makes
98
+ * `contextDataFactory` a *required* key the moment an application
99
+ * augments `FedifyTypes`. This branch is therefore only reachable while
100
+ * `ContextData` still includes `HttpContext`, which is exactly what it
101
+ * returns.
102
+ */
103
+ contextDataFactory: contextDataFactory ?? ((ctx) => ctx),
104
+ ignoreRoutePrefixes: ignoreRoutePrefixes ?? [],
105
+ logging: logging ?? true,
106
+ queueContextData
107
+ };
108
+ });
109
+ }
110
+
111
+ //#endregion
112
+ export { defineConfig };
113
+ //# sourceMappingURL=define_config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define_config.js","names":[],"sources":["../../src/define_config.ts"],"sourcesContent":["/**\n * The `defineConfig` helper used by `config/fedify.ts`.\n *\n * @module\n */\nimport { configProvider } from \"@adonisjs/core\";\nimport { InvalidArgumentsException } from \"@adonisjs/core/exceptions\";\nimport type { ConfigProvider } from \"@adonisjs/core/types\";\nimport type { FederationOptions } from \"@fedify/fedify\";\n\nimport type {\n ContextData,\n FedifyConfig,\n ResolvedFedifyConfig,\n} from \"./types.ts\";\n\n/**\n * Whether the `queue` option carries a queue at all.\n *\n * `FederationOptions.queue` takes either one `MessageQueue` for every role or\n * an object of per-role queues, and Fedify reads an object whose members are\n * all `undefined` as no queue. Testing the option's presence would therefore\n * misfire in both directions: `queue: { outbox: app.inProduction ? q :\n * undefined }` looks configured in development, and `queue: {}` looks like a\n * queue that needs draining.\n */\nfunction hasQueue(queue: FederationOptions<unknown>[\"queue\"]): boolean {\n if (queue == null) return false;\n if (\"enqueue\" in queue && \"listen\" in queue) return true;\n return Object.values(queue).some((role) => role != null);\n}\n\n/**\n * Defines the Fedify configuration of an AdonisJS application.\n *\n * The return value is an AdonisJS *config provider* rather than a plain object,\n * which lets the resolution step reach the application instance — needed to\n * detect production mode and to log through the application's logger — while\n * `config/fedify.ts` itself stays a simple, synchronous, statically analysable\n * module.\n *\n * @example\n * ```ts\n * // config/fedify.ts\n * import { defineConfig } from '@fedify/adonisjs'\n * import { SqliteKvStore } from '@fedify/sqlite'\n * import env from '#start/env'\n *\n * export default defineConfig({\n * origin: env.get('PUBLIC_URL'),\n * kv: new SqliteKvStore(database),\n * })\n * ```\n */\nexport function defineConfig(\n config: FedifyConfig,\n): ConfigProvider<ResolvedFedifyConfig> {\n return configProvider.create<ResolvedFedifyConfig>(async (app) => {\n if (!config.origin) {\n throw new InvalidArgumentsException(\n 'Missing \"origin\" in config/fedify.ts. It must be the canonical public URL of this server, ' +\n \"usually read from the PUBLIC_URL environment variable\",\n );\n }\n\n let kv = config.kv;\n if (kv === undefined) {\n const { MemoryKvStore } = await import(\"@fedify/fedify\");\n kv = new MemoryKvStore();\n\n if (app.inProduction) {\n // Not fatal — an application may genuinely run a single process and\n // accept the trade-off — but silently losing inbox idempotency and the\n // document cache on every restart is worth shouting about.\n const logger = await app.container.make(\"logger\");\n logger.warn(\n \"Fedify is using an in-memory key-value store in production. Inbox idempotency, \" +\n \"the document cache and outbox state will be lost on restart and cannot be shared \" +\n 'between processes. Configure \"kv\" in config/fedify.ts with a persistent store such ' +\n \"as @fedify/sqlite, @fedify/postgres or @fedify/redis\",\n );\n }\n }\n\n const {\n contextDataFactory,\n ignoreRoutePrefixes,\n logging,\n queueContextData,\n ...federationOptions\n } = config;\n\n /**\n * A configured queue forces the \"who drains it\" decision to be explicit.\n *\n * Fedify's own default starts the queue lazily on the first enqueued task,\n * capturing that request's context data and reusing it for every background\n * job thereafter. For this integration the captured value would be a single\n * stale `HttpContext`, whose request has long since finished. Rather than\n * pick a wrong default, refuse to guess.\n */\n if (hasQueue(federationOptions.queue) && queueContextData === undefined) {\n throw new InvalidArgumentsException(\n 'config/fedify.ts configures a \"queue\" but not \"queueContextData\". Set ' +\n '\"queueContextData\" to a callback to have this process drain the queue, or to ' +\n '\"false\" when a separate worker process owns it',\n );\n }\n\n /**\n * The mirror image: a drainer for a queue that does not exist. Nothing\n * fails on its own — `startQueue()` resolves over no queues and\n * `sendActivity()` delivers inline without retry, so failed deliveries are\n * silently lost.\n *\n * Only a warning, because a task registered with\n * `defineTask(name, { queue })` from a preload file brings its own queue,\n * which this configuration cannot see. Refusing would break a valid\n * application, and dropping the callback would hand that queue back to\n * Fedify's lazy start. Only a *callback* is reported: `false` stays valid\n * without a queue, so `queue: app.inProduction ? … : undefined` still\n * boots in development and test.\n */\n if (\n !hasQueue(federationOptions.queue) &&\n typeof queueContextData === \"function\"\n ) {\n const logger = await app.container.make(\"logger\");\n logger.warn(\n 'config/fedify.ts sets \"queueContextData\" but no \"queue\". Unless a task registers its own ' +\n \"queue through defineTask(), there is nothing to drain and activity delivery stays \" +\n 'inline, with failed deliveries never retried. Configure \"queue\" with a message queue ' +\n \"such as @fedify/sqlite, @fedify/postgres, @fedify/redis or @fedify/amqp, or remove \" +\n '\"queueContextData\"',\n );\n }\n\n return {\n ...federationOptions,\n kv,\n\n // The queue is always started deliberately — by this package's service\n // provider, or by a separate worker — never lazily by Fedify.\n manuallyStartQueue: queueContextData !== undefined\n ? true\n : config.manuallyStartQueue,\n\n /**\n * The cast is sound because `ContextDataFactoryOption` makes\n * `contextDataFactory` a *required* key the moment an application\n * augments `FedifyTypes`. This branch is therefore only reachable while\n * `ContextData` still includes `HttpContext`, which is exactly what it\n * returns.\n */\n contextDataFactory: contextDataFactory ?? ((ctx) => ctx as ContextData),\n ignoreRoutePrefixes: ignoreRoutePrefixes ?? [],\n logging: logging ?? true,\n queueContextData,\n };\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,SAAS,SAAS,OAAqD;CACrE,IAAI,SAAS,MAAM,OAAO;CAC1B,IAAI,aAAa,SAAS,YAAY,OAAO,OAAO;CACpD,OAAO,OAAO,OAAO,KAAK,CAAC,CAAC,MAAM,SAAS,QAAQ,IAAI;AACzD;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,aACd,QACsC;CACtC,OAAO,eAAe,OAA6B,OAAO,QAAQ;EAChE,IAAI,CAAC,OAAO,QAAQ;GAClB,MAAM,IAAI,0BACR,iGACE,uDACJ;EACF;EAEA,IAAI,KAAK,OAAO;EAChB,IAAI,OAAO,WAAW;GACpB,MAAM,EAAE,kBAAkB,MAAM,OAAO;GACvC,KAAK,IAAI,cAAc;GAEvB,IAAI,IAAI,cAAc;IAIpB,MAAM,SAAS,MAAM,IAAI,UAAU,KAAK,QAAQ;IAChD,OAAO,KACL,oFACE,sFACA,0FACA,sDACJ;GACF;EACF;EAEA,MAAM,EACJ,oBACA,qBACA,SACA,kBACA,GAAG,sBACD;;;;;;;;;;EAWJ,IAAI,SAAS,kBAAkB,KAAK,KAAK,qBAAqB,WAAW;GACvE,MAAM,IAAI,0BACR,+EACE,oFACA,kDACJ;EACF;;;;;;;;;;;;;;;EAgBA,IACE,CAAC,SAAS,kBAAkB,KAAK,KACjC,OAAO,qBAAqB,YAC5B;GACA,MAAM,SAAS,MAAM,IAAI,UAAU,KAAK,QAAQ;GAChD,OAAO,KACL,kGACE,uFACA,4FACA,wFACA,sBACJ;EACF;EAEA,OAAO;GACL,GAAG;GACH;GAIA,oBAAoB,qBAAqB,YACrC,OACA,OAAO;;;;;;;;GASX,oBAAoB,wBAAwB,QAAQ;GACpD,qBAAqB,uBAAuB,CAAC;GAC7C,SAAS,WAAW;GACpB;EACF;CACF,CAAC;AACH"}
@@ -0,0 +1,77 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let _adonisjs_core_exceptions = require("@adonisjs/core/exceptions");
3
+
4
+ //#region src/errors.ts
5
+ /**
6
+ * Exceptions raised by `@fedify/adonisjs`.
7
+ *
8
+ * They extend AdonisJS's `Exception` base class, so applications can match on
9
+ * `error.code` and the framework's exception handler renders them with the
10
+ * right HTTP status.
11
+ *
12
+ * Every message says what to do about the problem rather than only what went
13
+ * wrong: all three of these are configuration and lifecycle mistakes whose
14
+ * natural symptom would otherwise be a silent 404 from every federation
15
+ * endpoint.
16
+ *
17
+ * @module
18
+ */
19
+ /**
20
+ * Raised when `config/fedify.ts` is missing, or does not export the result of
21
+ * `defineConfig()`.
22
+ */
23
+ var E_INVALID_FEDIFY_CONFIG = class extends _adonisjs_core_exceptions.Exception {
24
+ static code = "E_INVALID_FEDIFY_CONFIG";
25
+ static status = 500;
26
+ static message = "Invalid \"config/fedify.ts\" file. Make sure to export the return value of the \"defineConfig\" method";
27
+ };
28
+ /**
29
+ * Raised when the `Federation` instance is resolved from the container before
30
+ * the application has finished booting.
31
+ *
32
+ * Dispatchers are registered on the `FederationBuilder` by preload files, and
33
+ * the builder can only be turned into a `Federation` once every preload has
34
+ * run. Resolving `'fedify'` earlier would silently produce a `Federation` with
35
+ * no routes at all, which is far harder to debug than an explicit error.
36
+ */
37
+ var E_FEDERATION_NOT_READY = class extends _adonisjs_core_exceptions.Exception {
38
+ static code = "E_FEDERATION_NOT_READY";
39
+ static status = 500;
40
+ static message = "The Federation instance is not available yet. It is built after the application boots, so it cannot be resolved from a service provider's register or boot method. Use \"ctx.federation\" inside HTTP requests, the \"Context\" argument inside dispatchers, or resolve it with \"app.container.make('fedify')\" from code that runs once the application is ready";
41
+ };
42
+ /**
43
+ * Raised when `FedifyMiddleware` is constructed without a `Federation`.
44
+ *
45
+ * The container falls back to a zero-argument construction when the class it
46
+ * resolves is not the object the provider bound — a duplicated copy of this
47
+ * package in the dependency tree, or its ESM and CJS builds mixed in one
48
+ * process. Failing at construction with an actionable message beats the
49
+ * `TypeError` every request would otherwise throw.
50
+ *
51
+ * The `fedifyMiddleware()` factory raises it too, with a message of its own,
52
+ * when it is called without a `Federation` — typically an import from a
53
+ * module that does not default-export one.
54
+ */
55
+ var E_MISSING_FEDERATION = class extends _adonisjs_core_exceptions.Exception {
56
+ static code = "E_MISSING_FEDERATION";
57
+ static status = 500;
58
+ static message = "FedifyMiddleware was constructed without a Federation instance. Register \"@fedify/adonisjs/fedify_provider\" so the container binding supplies it, or build the middleware with the \"fedifyMiddleware\" factory. If the provider is registered, this process is loading two copies of \"@fedify/adonisjs\" (for example its ESM and CJS builds), so the class the kernel resolved is not the one the provider bound";
59
+ };
60
+ /**
61
+ * Raised when `ctx.federation` is accessed on a request the Fedify middleware
62
+ * deliberately skipped, or on a request it never saw at all.
63
+ */
64
+ var E_FEDIFY_CONTEXT_UNAVAILABLE = class extends _adonisjs_core_exceptions.Exception {
65
+ static code = "E_FEDIFY_CONTEXT_UNAVAILABLE";
66
+ static status = 500;
67
+ constructor(path) {
68
+ super(`Cannot access "ctx.federation" for "${path}". Either the request path matches "ignoreRoutePrefixes" in config/fedify.ts, the request method is one the Fetch API cannot represent (CONNECT, TRACE, TRACK), or the Fedify middleware is not registered in the server middleware stack of start/kernel.ts`);
69
+ }
70
+ };
71
+
72
+ //#endregion
73
+ exports.E_FEDERATION_NOT_READY = E_FEDERATION_NOT_READY;
74
+ exports.E_FEDIFY_CONTEXT_UNAVAILABLE = E_FEDIFY_CONTEXT_UNAVAILABLE;
75
+ exports.E_INVALID_FEDIFY_CONFIG = E_INVALID_FEDIFY_CONFIG;
76
+ exports.E_MISSING_FEDERATION = E_MISSING_FEDERATION;
77
+ //# sourceMappingURL=errors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.cjs","names":["Exception"],"sources":["../../src/errors.ts"],"sourcesContent":["/**\n * Exceptions raised by `@fedify/adonisjs`.\n *\n * They extend AdonisJS's `Exception` base class, so applications can match on\n * `error.code` and the framework's exception handler renders them with the\n * right HTTP status.\n *\n * Every message says what to do about the problem rather than only what went\n * wrong: all three of these are configuration and lifecycle mistakes whose\n * natural symptom would otherwise be a silent 404 from every federation\n * endpoint.\n *\n * @module\n */\nimport { Exception } from \"@adonisjs/core/exceptions\";\n\n/**\n * Raised when `config/fedify.ts` is missing, or does not export the result of\n * `defineConfig()`.\n */\nexport class E_INVALID_FEDIFY_CONFIG extends Exception {\n static override code = \"E_INVALID_FEDIFY_CONFIG\";\n static override status = 500;\n static override message =\n 'Invalid \"config/fedify.ts\" file. Make sure to export the return value of the \"defineConfig\" method';\n}\n\n/**\n * Raised when the `Federation` instance is resolved from the container before\n * the application has finished booting.\n *\n * Dispatchers are registered on the `FederationBuilder` by preload files, and\n * the builder can only be turned into a `Federation` once every preload has\n * run. Resolving `'fedify'` earlier would silently produce a `Federation` with\n * no routes at all, which is far harder to debug than an explicit error.\n */\nexport class E_FEDERATION_NOT_READY extends Exception {\n static override code = \"E_FEDERATION_NOT_READY\";\n static override status = 500;\n static override message =\n 'The Federation instance is not available yet. It is built after the application boots, so it cannot be resolved from a service provider\\'s register or boot method. Use \"ctx.federation\" inside HTTP requests, the \"Context\" argument inside dispatchers, or resolve it with \"app.container.make(\\'fedify\\')\" from code that runs once the application is ready';\n}\n\n/**\n * Raised when `FedifyMiddleware` is constructed without a `Federation`.\n *\n * The container falls back to a zero-argument construction when the class it\n * resolves is not the object the provider bound — a duplicated copy of this\n * package in the dependency tree, or its ESM and CJS builds mixed in one\n * process. Failing at construction with an actionable message beats the\n * `TypeError` every request would otherwise throw.\n *\n * The `fedifyMiddleware()` factory raises it too, with a message of its own,\n * when it is called without a `Federation` — typically an import from a\n * module that does not default-export one.\n */\nexport class E_MISSING_FEDERATION extends Exception {\n static override code = \"E_MISSING_FEDERATION\";\n static override status = 500;\n static override message =\n 'FedifyMiddleware was constructed without a Federation instance. Register \"@fedify/adonisjs/fedify_provider\" so the container binding supplies it, or build the middleware with the \"fedifyMiddleware\" factory. If the provider is registered, this process is loading two copies of \"@fedify/adonisjs\" (for example its ESM and CJS builds), so the class the kernel resolved is not the one the provider bound';\n}\n\n/**\n * Raised when `ctx.federation` is accessed on a request the Fedify middleware\n * deliberately skipped, or on a request it never saw at all.\n */\nexport class E_FEDIFY_CONTEXT_UNAVAILABLE extends Exception {\n static override code = \"E_FEDIFY_CONTEXT_UNAVAILABLE\";\n static override status = 500;\n\n constructor(path: string) {\n super(\n `Cannot access \"ctx.federation\" for \"${path}\". Either the request path matches \"ignoreRoutePrefixes\" in config/fedify.ts, the request method is one the Fetch API cannot represent (CONNECT, TRACE, TRACK), or the Fedify middleware is not registered in the server middleware stack of start/kernel.ts`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,0BAAb,cAA6CA,oCAAU;CACrD,OAAgB,OAAO;CACvB,OAAgB,SAAS;CACzB,OAAgB,UACd;AACJ;;;;;;;;;;AAWA,IAAa,yBAAb,cAA4CA,oCAAU;CACpD,OAAgB,OAAO;CACvB,OAAgB,SAAS;CACzB,OAAgB,UACd;AACJ;;;;;;;;;;;;;;AAeA,IAAa,uBAAb,cAA0CA,oCAAU;CAClD,OAAgB,OAAO;CACvB,OAAgB,SAAS;CACzB,OAAgB,UACd;AACJ;;;;;AAMA,IAAa,+BAAb,cAAkDA,oCAAU;CAC1D,OAAgB,OAAO;CACvB,OAAgB,SAAS;CAEzB,YAAY,MAAc;EACxB,MACE,uCAAuC,KAAK,6PAC9C;CACF;AACF"}
@@ -0,0 +1,56 @@
1
+ import { Exception } from "@adonisjs/core/exceptions";
2
+
3
+ //#region src/errors.d.ts
4
+ /**
5
+ * Raised when `config/fedify.ts` is missing, or does not export the result of
6
+ * `defineConfig()`.
7
+ */
8
+ declare class E_INVALID_FEDIFY_CONFIG extends Exception {
9
+ static override code: string;
10
+ static override status: number;
11
+ static override message: string;
12
+ }
13
+ /**
14
+ * Raised when the `Federation` instance is resolved from the container before
15
+ * the application has finished booting.
16
+ *
17
+ * Dispatchers are registered on the `FederationBuilder` by preload files, and
18
+ * the builder can only be turned into a `Federation` once every preload has
19
+ * run. Resolving `'fedify'` earlier would silently produce a `Federation` with
20
+ * no routes at all, which is far harder to debug than an explicit error.
21
+ */
22
+ declare class E_FEDERATION_NOT_READY extends Exception {
23
+ static override code: string;
24
+ static override status: number;
25
+ static override message: string;
26
+ }
27
+ /**
28
+ * Raised when `FedifyMiddleware` is constructed without a `Federation`.
29
+ *
30
+ * The container falls back to a zero-argument construction when the class it
31
+ * resolves is not the object the provider bound — a duplicated copy of this
32
+ * package in the dependency tree, or its ESM and CJS builds mixed in one
33
+ * process. Failing at construction with an actionable message beats the
34
+ * `TypeError` every request would otherwise throw.
35
+ *
36
+ * The `fedifyMiddleware()` factory raises it too, with a message of its own,
37
+ * when it is called without a `Federation` — typically an import from a
38
+ * module that does not default-export one.
39
+ */
40
+ declare class E_MISSING_FEDERATION extends Exception {
41
+ static override code: string;
42
+ static override status: number;
43
+ static override message: string;
44
+ }
45
+ /**
46
+ * Raised when `ctx.federation` is accessed on a request the Fedify middleware
47
+ * deliberately skipped, or on a request it never saw at all.
48
+ */
49
+ declare class E_FEDIFY_CONTEXT_UNAVAILABLE extends Exception {
50
+ static override code: string;
51
+ static override status: number;
52
+ constructor(path: string);
53
+ }
54
+ //#endregion
55
+ export { E_FEDERATION_NOT_READY, E_FEDIFY_CONTEXT_UNAVAILABLE, E_INVALID_FEDIFY_CONFIG, E_MISSING_FEDERATION };
56
+ //# sourceMappingURL=errors.d.cts.map
@@ -0,0 +1,56 @@
1
+ import { Exception } from "@adonisjs/core/exceptions";
2
+
3
+ //#region src/errors.d.ts
4
+ /**
5
+ * Raised when `config/fedify.ts` is missing, or does not export the result of
6
+ * `defineConfig()`.
7
+ */
8
+ declare class E_INVALID_FEDIFY_CONFIG extends Exception {
9
+ static override code: string;
10
+ static override status: number;
11
+ static override message: string;
12
+ }
13
+ /**
14
+ * Raised when the `Federation` instance is resolved from the container before
15
+ * the application has finished booting.
16
+ *
17
+ * Dispatchers are registered on the `FederationBuilder` by preload files, and
18
+ * the builder can only be turned into a `Federation` once every preload has
19
+ * run. Resolving `'fedify'` earlier would silently produce a `Federation` with
20
+ * no routes at all, which is far harder to debug than an explicit error.
21
+ */
22
+ declare class E_FEDERATION_NOT_READY extends Exception {
23
+ static override code: string;
24
+ static override status: number;
25
+ static override message: string;
26
+ }
27
+ /**
28
+ * Raised when `FedifyMiddleware` is constructed without a `Federation`.
29
+ *
30
+ * The container falls back to a zero-argument construction when the class it
31
+ * resolves is not the object the provider bound — a duplicated copy of this
32
+ * package in the dependency tree, or its ESM and CJS builds mixed in one
33
+ * process. Failing at construction with an actionable message beats the
34
+ * `TypeError` every request would otherwise throw.
35
+ *
36
+ * The `fedifyMiddleware()` factory raises it too, with a message of its own,
37
+ * when it is called without a `Federation` — typically an import from a
38
+ * module that does not default-export one.
39
+ */
40
+ declare class E_MISSING_FEDERATION extends Exception {
41
+ static override code: string;
42
+ static override status: number;
43
+ static override message: string;
44
+ }
45
+ /**
46
+ * Raised when `ctx.federation` is accessed on a request the Fedify middleware
47
+ * deliberately skipped, or on a request it never saw at all.
48
+ */
49
+ declare class E_FEDIFY_CONTEXT_UNAVAILABLE extends Exception {
50
+ static override code: string;
51
+ static override status: number;
52
+ constructor(path: string);
53
+ }
54
+ //#endregion
55
+ export { E_FEDERATION_NOT_READY, E_FEDIFY_CONTEXT_UNAVAILABLE, E_INVALID_FEDIFY_CONFIG, E_MISSING_FEDERATION };
56
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,73 @@
1
+ import { Exception } from "@adonisjs/core/exceptions";
2
+
3
+ //#region src/errors.ts
4
+ /**
5
+ * Exceptions raised by `@fedify/adonisjs`.
6
+ *
7
+ * They extend AdonisJS's `Exception` base class, so applications can match on
8
+ * `error.code` and the framework's exception handler renders them with the
9
+ * right HTTP status.
10
+ *
11
+ * Every message says what to do about the problem rather than only what went
12
+ * wrong: all three of these are configuration and lifecycle mistakes whose
13
+ * natural symptom would otherwise be a silent 404 from every federation
14
+ * endpoint.
15
+ *
16
+ * @module
17
+ */
18
+ /**
19
+ * Raised when `config/fedify.ts` is missing, or does not export the result of
20
+ * `defineConfig()`.
21
+ */
22
+ var E_INVALID_FEDIFY_CONFIG = class extends Exception {
23
+ static code = "E_INVALID_FEDIFY_CONFIG";
24
+ static status = 500;
25
+ static message = "Invalid \"config/fedify.ts\" file. Make sure to export the return value of the \"defineConfig\" method";
26
+ };
27
+ /**
28
+ * Raised when the `Federation` instance is resolved from the container before
29
+ * the application has finished booting.
30
+ *
31
+ * Dispatchers are registered on the `FederationBuilder` by preload files, and
32
+ * the builder can only be turned into a `Federation` once every preload has
33
+ * run. Resolving `'fedify'` earlier would silently produce a `Federation` with
34
+ * no routes at all, which is far harder to debug than an explicit error.
35
+ */
36
+ var E_FEDERATION_NOT_READY = class extends Exception {
37
+ static code = "E_FEDERATION_NOT_READY";
38
+ static status = 500;
39
+ static message = "The Federation instance is not available yet. It is built after the application boots, so it cannot be resolved from a service provider's register or boot method. Use \"ctx.federation\" inside HTTP requests, the \"Context\" argument inside dispatchers, or resolve it with \"app.container.make('fedify')\" from code that runs once the application is ready";
40
+ };
41
+ /**
42
+ * Raised when `FedifyMiddleware` is constructed without a `Federation`.
43
+ *
44
+ * The container falls back to a zero-argument construction when the class it
45
+ * resolves is not the object the provider bound — a duplicated copy of this
46
+ * package in the dependency tree, or its ESM and CJS builds mixed in one
47
+ * process. Failing at construction with an actionable message beats the
48
+ * `TypeError` every request would otherwise throw.
49
+ *
50
+ * The `fedifyMiddleware()` factory raises it too, with a message of its own,
51
+ * when it is called without a `Federation` — typically an import from a
52
+ * module that does not default-export one.
53
+ */
54
+ var E_MISSING_FEDERATION = class extends Exception {
55
+ static code = "E_MISSING_FEDERATION";
56
+ static status = 500;
57
+ static message = "FedifyMiddleware was constructed without a Federation instance. Register \"@fedify/adonisjs/fedify_provider\" so the container binding supplies it, or build the middleware with the \"fedifyMiddleware\" factory. If the provider is registered, this process is loading two copies of \"@fedify/adonisjs\" (for example its ESM and CJS builds), so the class the kernel resolved is not the one the provider bound";
58
+ };
59
+ /**
60
+ * Raised when `ctx.federation` is accessed on a request the Fedify middleware
61
+ * deliberately skipped, or on a request it never saw at all.
62
+ */
63
+ var E_FEDIFY_CONTEXT_UNAVAILABLE = class extends Exception {
64
+ static code = "E_FEDIFY_CONTEXT_UNAVAILABLE";
65
+ static status = 500;
66
+ constructor(path) {
67
+ super(`Cannot access "ctx.federation" for "${path}". Either the request path matches "ignoreRoutePrefixes" in config/fedify.ts, the request method is one the Fetch API cannot represent (CONNECT, TRACE, TRACK), or the Fedify middleware is not registered in the server middleware stack of start/kernel.ts`);
68
+ }
69
+ };
70
+
71
+ //#endregion
72
+ export { E_FEDERATION_NOT_READY, E_FEDIFY_CONTEXT_UNAVAILABLE, E_INVALID_FEDIFY_CONFIG, E_MISSING_FEDERATION };
73
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../../src/errors.ts"],"sourcesContent":["/**\n * Exceptions raised by `@fedify/adonisjs`.\n *\n * They extend AdonisJS's `Exception` base class, so applications can match on\n * `error.code` and the framework's exception handler renders them with the\n * right HTTP status.\n *\n * Every message says what to do about the problem rather than only what went\n * wrong: all three of these are configuration and lifecycle mistakes whose\n * natural symptom would otherwise be a silent 404 from every federation\n * endpoint.\n *\n * @module\n */\nimport { Exception } from \"@adonisjs/core/exceptions\";\n\n/**\n * Raised when `config/fedify.ts` is missing, or does not export the result of\n * `defineConfig()`.\n */\nexport class E_INVALID_FEDIFY_CONFIG extends Exception {\n static override code = \"E_INVALID_FEDIFY_CONFIG\";\n static override status = 500;\n static override message =\n 'Invalid \"config/fedify.ts\" file. Make sure to export the return value of the \"defineConfig\" method';\n}\n\n/**\n * Raised when the `Federation` instance is resolved from the container before\n * the application has finished booting.\n *\n * Dispatchers are registered on the `FederationBuilder` by preload files, and\n * the builder can only be turned into a `Federation` once every preload has\n * run. Resolving `'fedify'` earlier would silently produce a `Federation` with\n * no routes at all, which is far harder to debug than an explicit error.\n */\nexport class E_FEDERATION_NOT_READY extends Exception {\n static override code = \"E_FEDERATION_NOT_READY\";\n static override status = 500;\n static override message =\n 'The Federation instance is not available yet. It is built after the application boots, so it cannot be resolved from a service provider\\'s register or boot method. Use \"ctx.federation\" inside HTTP requests, the \"Context\" argument inside dispatchers, or resolve it with \"app.container.make(\\'fedify\\')\" from code that runs once the application is ready';\n}\n\n/**\n * Raised when `FedifyMiddleware` is constructed without a `Federation`.\n *\n * The container falls back to a zero-argument construction when the class it\n * resolves is not the object the provider bound — a duplicated copy of this\n * package in the dependency tree, or its ESM and CJS builds mixed in one\n * process. Failing at construction with an actionable message beats the\n * `TypeError` every request would otherwise throw.\n *\n * The `fedifyMiddleware()` factory raises it too, with a message of its own,\n * when it is called without a `Federation` — typically an import from a\n * module that does not default-export one.\n */\nexport class E_MISSING_FEDERATION extends Exception {\n static override code = \"E_MISSING_FEDERATION\";\n static override status = 500;\n static override message =\n 'FedifyMiddleware was constructed without a Federation instance. Register \"@fedify/adonisjs/fedify_provider\" so the container binding supplies it, or build the middleware with the \"fedifyMiddleware\" factory. If the provider is registered, this process is loading two copies of \"@fedify/adonisjs\" (for example its ESM and CJS builds), so the class the kernel resolved is not the one the provider bound';\n}\n\n/**\n * Raised when `ctx.federation` is accessed on a request the Fedify middleware\n * deliberately skipped, or on a request it never saw at all.\n */\nexport class E_FEDIFY_CONTEXT_UNAVAILABLE extends Exception {\n static override code = \"E_FEDIFY_CONTEXT_UNAVAILABLE\";\n static override status = 500;\n\n constructor(path: string) {\n super(\n `Cannot access \"ctx.federation\" for \"${path}\". Either the request path matches \"ignoreRoutePrefixes\" in config/fedify.ts, the request method is one the Fetch API cannot represent (CONNECT, TRACE, TRACK), or the Fedify middleware is not registered in the server middleware stack of start/kernel.ts`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,0BAAb,cAA6C,UAAU;CACrD,OAAgB,OAAO;CACvB,OAAgB,SAAS;CACzB,OAAgB,UACd;AACJ;;;;;;;;;;AAWA,IAAa,yBAAb,cAA4C,UAAU;CACpD,OAAgB,OAAO;CACvB,OAAgB,SAAS;CACzB,OAAgB,UACd;AACJ;;;;;;;;;;;;;;AAeA,IAAa,uBAAb,cAA0C,UAAU;CAClD,OAAgB,OAAO;CACvB,OAAgB,SAAS;CACzB,OAAgB,UACd;AACJ;;;;;AAMA,IAAa,+BAAb,cAAkD,UAAU;CAC1D,OAAgB,OAAO;CACvB,OAAgB,SAAS;CAEzB,YAAY,MAAc;EACxB,MACE,uCAAuC,KAAK,6PAC9C;CACF;AACF"}