@forumone/throughline-plugin-contract 0.2.1 → 0.3.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Forum One Communications Corporation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/auth.d.ts CHANGED
@@ -15,5 +15,16 @@ export interface McpAuthResult {
15
15
  user: AuthenticatedUser;
16
16
  apiKeyName: string;
17
17
  apiKeyId: string;
18
+ /**
19
+ * What this key was granted, from the key record. A tool declaring a
20
+ * `requiredScope` is refused — and hidden from `tools/list` — unless it is
21
+ * named here.
22
+ *
23
+ * Optional so an authenticator predating scopes still type-checks; absent is
24
+ * read as "no scopes", which refuses every scoped tool rather than allowing
25
+ * them. A key that cannot say what it may do may not do the consequential
26
+ * things.
27
+ */
28
+ scopes?: string[];
18
29
  }
19
30
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;CAC9D;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;CACjB"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;CAC9D;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB"}
package/dist/index.d.ts CHANGED
@@ -29,5 +29,4 @@ export type CorePlugin<Options extends BaseCorePluginOptions = BaseCorePluginOpt
29
29
  export * from './mcp.js';
30
30
  export * from './auth.js';
31
31
  export * from './registry.js';
32
- export * from './example-plugin-pattern.js';
33
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC;;;GAGG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;CAChB;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IACnE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IAClE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IAClE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;CACpE;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,qBAAqB,GAAG,qBAAqB,IAAI,CACtF,OAAO,EAAE,OAAO,KACb,MAAM,CAAA;AAEX,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA"}
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './mcp.js';
2
2
  export * from './auth.js';
3
3
  export * from './registry.js';
4
- export * from './example-plugin-pattern.js';
5
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkCA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,6BAA6B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkCA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA"}
package/dist/mcp.d.ts CHANGED
@@ -10,6 +10,14 @@ export interface McpToolDefinition<Input extends z.ZodType = z.ZodType, Output =
10
10
  description: string;
11
11
  /** Zod schema for the input; used for validation and for generating the MCP tool schema. */
12
12
  inputSchema: Input;
13
+ /**
14
+ * The API-key scope a caller must hold, e.g. `'publishing.execute'`.
15
+ *
16
+ * Declared on the consequential tools — the ones that write, publish or
17
+ * decide. A tool with no `requiredScope` is callable by any authenticated
18
+ * key, which is the right default for a read.
19
+ */
20
+ requiredScope?: string;
13
21
  /** Handler invoked with validated input plus per-request context. */
14
22
  handler: (input: z.infer<Input>, context: McpToolContext) => Promise<Output>;
15
23
  }
package/dist/mcp.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,KAAK,SAAS,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IACtF,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAA;IACZ,uFAAuF;IACvF,WAAW,EAAE,MAAM,CAAA;IACnB,4FAA4F;IAC5F,WAAW,EAAE,KAAK,CAAA;IAClB,qEAAqE;IACrE,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAC7E;AAED,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAC9B,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAA;IAClB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAA;CACf;A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,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forumone/throughline-plugin-contract",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Shared plugin and MCP contract types and the cross-plugin registry for @forumone/throughline core packages.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,22 +24,22 @@
24
24
  "files": [
25
25
  "dist"
26
26
  ],
27
- "scripts": {
28
- "build": "tsc -b",
29
- "dev": "tsc -b -w",
30
- "clean": "rm -rf dist .turbo *.tsbuildinfo",
31
- "typecheck": "tsc --noEmit",
32
- "lint": "eslint src"
33
- },
34
27
  "dependencies": {
35
28
  "payload": "^3.0.0",
36
29
  "zod": "^3.23.0"
37
30
  },
38
31
  "devDependencies": {
39
- "@forumone/throughline-eslint-config": "workspace:*",
40
- "@forumone/throughline-tsconfig": "workspace:*",
41
32
  "@types/node": "^20.17.0",
42
33
  "eslint": "^9.15.0",
43
- "typescript": "^5.6.0"
34
+ "typescript": "^5.6.0",
35
+ "@forumone/throughline-eslint-config": "0.0.0",
36
+ "@forumone/throughline-tsconfig": "0.0.0"
37
+ },
38
+ "scripts": {
39
+ "build": "tsc -b",
40
+ "dev": "tsc -b -w",
41
+ "clean": "rm -rf dist .turbo *.tsbuildinfo",
42
+ "typecheck": "tsc --noEmit",
43
+ "lint": "eslint src"
44
44
  }
45
- }
45
+ }
@@ -1,12 +0,0 @@
1
- import type { BaseCorePluginOptions, CorePlugin } from './index.js';
2
- /**
3
- * EXAMPLE ONLY — not a real plugin. Reference implementation showing the
4
- * shape every Throughline core plugin follows. Every future plugin should
5
- * lift this structure and fill in the feature-specific parts.
6
- */
7
- export interface ExamplePluginOptions extends BaseCorePluginOptions {
8
- /** A plugin-specific option. */
9
- greeting?: string;
10
- }
11
- export declare const examplePlugin: CorePlugin<ExamplePluginOptions>;
12
- //# sourceMappingURL=example-plugin-pattern.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"example-plugin-pattern.d.ts","sourceRoot":"","sources":["../src/example-plugin-pattern.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGnE;;;;GAIG;AAEH,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,gCAAgC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAKD,eAAO,MAAM,aAAa,EAAE,UAAU,CAAC,oBAAoB,CAuD1D,CAAA"}
@@ -1,58 +0,0 @@
1
- import { getPluginRegistry } from './registry.js';
2
- const EXAMPLE_PLUGIN_ID = '@forumone/throughline-example';
3
- const EXAMPLE_PLUGIN_VERSION = '0.0.0';
4
- export const examplePlugin = (options) => {
5
- return (incomingConfig) => {
6
- // Step 1 — honour the disabled flag before doing any work.
7
- if (options.enabled === false)
8
- return incomingConfig;
9
- // Step 2 — apply defaults. Note: route prefixes here MUST NOT include
10
- // `/api` — Payload mounts top-level endpoints under its API base
11
- // (default `/api`), so the user-facing URL becomes `/api/example/mcp`.
12
- const greeting = options.greeting ?? 'Hello';
13
- const routePrefix = options.routePrefix ?? '/example';
14
- // Step 3 — extend the incoming config by spreading and appending.
15
- // Never replace existing arrays; always concatenate.
16
- return {
17
- ...incomingConfig,
18
- collections: [
19
- ...(incomingConfig.collections ?? []),
20
- // Plugin's own collections go here.
21
- ],
22
- endpoints: [
23
- ...(incomingConfig.endpoints ?? []),
24
- {
25
- path: `${routePrefix}/mcp`,
26
- method: 'post',
27
- handler: async () => {
28
- // Real plugins delegate this to an MCP server implementation.
29
- return new Response(JSON.stringify({ greeting }), {
30
- headers: { 'content-type': 'application/json' },
31
- });
32
- },
33
- },
34
- ],
35
- hooks: {
36
- ...(incomingConfig.hooks ?? {}),
37
- afterError: [
38
- ...(incomingConfig.hooks?.afterError ?? []),
39
- // Plugin's global error hooks go here.
40
- ],
41
- },
42
- onInit: async (payload) => {
43
- // Always run any pre-existing onInit first so plugins compose cleanly.
44
- if (incomingConfig.onInit) {
45
- await incomingConfig.onInit(payload);
46
- }
47
- // Announce presence and assert required capabilities from siblings.
48
- const registry = getPluginRegistry(payload);
49
- registry.register({
50
- id: EXAMPLE_PLUGIN_ID,
51
- version: EXAMPLE_PLUGIN_VERSION,
52
- capabilities: ['example'],
53
- });
54
- },
55
- };
56
- };
57
- };
58
- //# sourceMappingURL=example-plugin-pattern.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"example-plugin-pattern.js","sourceRoot":"","sources":["../src/example-plugin-pattern.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAajD,MAAM,iBAAiB,GAAG,+BAA+B,CAAA;AACzD,MAAM,sBAAsB,GAAG,OAAO,CAAA;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAqC,CAAC,OAAO,EAAE,EAAE;IACzE,OAAO,CAAC,cAAsB,EAAU,EAAE;QACxC,2DAA2D;QAC3D,IAAI,OAAO,CAAC,OAAO,KAAK,KAAK;YAAE,OAAO,cAAc,CAAA;QAEpD,sEAAsE;QACtE,iEAAiE;QACjE,uEAAuE;QACvE,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAA;QAC5C,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,UAAU,CAAA;QAErD,kEAAkE;QAClE,8DAA8D;QAC9D,OAAO;YACL,GAAG,cAAc;YACjB,WAAW,EAAE;gBACX,GAAG,CAAC,cAAc,C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