dropsh 0.7.5 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/src/core/command-context.d.ts +17 -0
- package/dist/src/core/command-context.js +1 -0
- package/dist/src/core/plugin.d.ts +2 -1
- package/dist/src/index.d.ts +3 -11
- package/dist/src/index.js +22 -12
- package/dist/src/plugin-api.d.ts +17 -2
- package/dist/src/plugin-api.js +11 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -599,6 +599,8 @@ shipped inside the `dropsh` npm tarball — each is a separately published packa
|
|
|
599
599
|
| [`@dropsh/plugin-schemata`](plugins/schemata/README.md) | `schemataPlugin` | authoritative JSON Schema from Drupal `schemata` (legacy) |
|
|
600
600
|
| [`@dropsh/plugin-canvas`](plugins/canvas/README.md) | `canvasPlugin` | Canvas component schemas from `jsonapi_sdc` |
|
|
601
601
|
| [`@dropsh/plugin-display-builder`](plugins/display-builder/README.md) | `displayBuilderPlugin` | Display Builder operation schemas and metadata |
|
|
602
|
+
| [`@dropsh/plugin-mcp`](plugins/mcp/README.md) | `mcpPlugin` | Model Context Protocol server (stdio and loopback HTTP) |
|
|
603
|
+
| [`@dropsh/plugin-tool`](plugins/tool/README.md) | `toolPlugin` | list and call Drupal Tool API tools over the site's `mcp_server` endpoint |
|
|
602
604
|
|
|
603
605
|
Basic auth is not a separate package — its `basicAuthPlugin` factory ships in the
|
|
604
606
|
core CLI's `dropsh/plugin` entry.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AuthAdapter } from "./auth/types.js";
|
|
2
|
+
import type { HttpClient } from "./http.js";
|
|
3
|
+
import type { JsonApiClient } from "./jsonapi/client.js";
|
|
4
|
+
import type { DropSHPlugin } from "./plugin.js";
|
|
5
|
+
export interface CommandContext {
|
|
6
|
+
client: JsonApiClient;
|
|
7
|
+
http: HttpClient;
|
|
8
|
+
auth: AuthAdapter;
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
jsonapiPrefix: string;
|
|
11
|
+
cwd: string;
|
|
12
|
+
plugins: DropSHPlugin[];
|
|
13
|
+
}
|
|
14
|
+
export interface PluginCommandServices {
|
|
15
|
+
getContext(auth?: AuthAdapter): Promise<CommandContext>;
|
|
16
|
+
stderr(message: string): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Command } from "commander";
|
|
2
2
|
import type { AuthAdapter, AuthProvider } from "./auth/types.js";
|
|
3
3
|
import type { AnyRenderer } from "./cli/render.js";
|
|
4
|
+
import type { PluginCommandServices } from "./command-context.js";
|
|
4
5
|
import type { HttpClient, HttpRequest } from "./http.js";
|
|
5
6
|
import type { DropSHOperation } from "./jsonapi/client.js";
|
|
6
7
|
import type { Operation } from "./schema/to-jsonschema.js";
|
|
@@ -57,7 +58,7 @@ export interface DropSHPlugin {
|
|
|
57
58
|
extendSchema?(entityType: string, bundle: string, baseSchema: unknown, ctx: PluginContext): Promise<unknown>;
|
|
58
59
|
extendOperationSchema?(entityType: string, bundle: string, operation: SchemaOperation, operationSchema: unknown, ctx: PluginContext): Promise<unknown>;
|
|
59
60
|
alterRequest?(req: HttpRequest, ctx: RequestContext): Promise<HttpRequest>;
|
|
60
|
-
registerCommands?(program: Command): void;
|
|
61
|
+
registerCommands?(program: Command, services: PluginCommandServices): void;
|
|
61
62
|
renderers?: AnyRenderer[];
|
|
62
63
|
}
|
|
63
64
|
/**
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import type { AuthAdapter, AuthStatusInfo } from "./core/auth/types.js";
|
|
4
|
+
import type { CommandContext } from "./core/command-context.js";
|
|
4
5
|
import type { HttpClient } from "./core/http.js";
|
|
5
|
-
import { type JsonApiClient } from "./core/jsonapi/client.js";
|
|
6
6
|
import type { DropSHPlugin } from "./core/plugin.js";
|
|
7
|
-
export
|
|
8
|
-
client: JsonApiClient;
|
|
9
|
-
http: HttpClient;
|
|
10
|
-
auth: AuthAdapter;
|
|
11
|
-
baseUrl: string;
|
|
12
|
-
jsonapiPrefix: string;
|
|
13
|
-
cwd: string;
|
|
14
|
-
plugins: DropSHPlugin[];
|
|
15
|
-
}
|
|
7
|
+
export type { CommandContext, PluginCommandServices } from "./core/command-context.js";
|
|
16
8
|
export interface ProgramOptions {
|
|
17
|
-
contextFactory?: () => Promise<CommandContext>;
|
|
9
|
+
contextFactory?: (auth?: AuthAdapter) => Promise<CommandContext>;
|
|
18
10
|
stdout?: (s: string) => void;
|
|
19
11
|
stderr?: (s: string) => void;
|
|
20
12
|
setExitCode?: (code: number) => void;
|
package/dist/src/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { runDelete } from "./commands/delete.js";
|
|
|
9
9
|
import { runRead } from "./commands/read.js";
|
|
10
10
|
import { applyOperationSchemaPlugins, operationHookPluginIds, runSchema, SCHEMA_PIPELINE_VERSION, schemaCacheMetadataMatches, siteCacheRoot, } from "./commands/schema.js";
|
|
11
11
|
import { runSearch } from "./commands/search.js";
|
|
12
|
-
import { assertUpdateTarget, runUpdate
|
|
12
|
+
import { assertUpdateTarget, runUpdate } from "./commands/update.js";
|
|
13
13
|
import { runUploadFile } from "./commands/upload-file.js";
|
|
14
14
|
import { collectProviders, defaultProvider, providerById, sessionlessProvider, } from "./core/auth/registry.js";
|
|
15
15
|
import { readProfiles, writeProfile } from "./core/auth/session-store.js";
|
|
@@ -114,16 +114,20 @@ export async function authStatus(deps) {
|
|
|
114
114
|
}
|
|
115
115
|
return provider.status(rec.session);
|
|
116
116
|
}
|
|
117
|
-
async function defaultContext(configPath, profile) {
|
|
117
|
+
async function defaultContext(configPath, profile, authOverride) {
|
|
118
118
|
const cfg = await loadConfig(configPath);
|
|
119
|
-
const http = createHttpClient({
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
plugins: cfg.plugins,
|
|
123
|
-
http,
|
|
124
|
-
now: Date.now,
|
|
125
|
-
...(profile !== undefined ? { profile } : {}),
|
|
119
|
+
const http = createHttpClient({
|
|
120
|
+
timeoutMs: cfg.defaults.timeout_ms,
|
|
121
|
+
...(authOverride !== undefined ? { maxRetries: 0 } : {}),
|
|
126
122
|
});
|
|
123
|
+
const auth = authOverride ??
|
|
124
|
+
(await resolveAuth({
|
|
125
|
+
baseUrl: cfg.site.base_url,
|
|
126
|
+
plugins: cfg.plugins,
|
|
127
|
+
http,
|
|
128
|
+
now: Date.now,
|
|
129
|
+
...(profile !== undefined ? { profile } : {}),
|
|
130
|
+
}));
|
|
127
131
|
const pluginContext = {
|
|
128
132
|
http,
|
|
129
133
|
auth,
|
|
@@ -184,10 +188,16 @@ export function buildProgram(opts = {}) {
|
|
|
184
188
|
});
|
|
185
189
|
}
|
|
186
190
|
const contextFactory = opts.contextFactory ??
|
|
187
|
-
(() => {
|
|
191
|
+
((auth) => {
|
|
188
192
|
const profile = program.opts().authProfile ?? process.env.DROPSH_AUTH_PROFILE;
|
|
189
|
-
return
|
|
193
|
+
return auth !== undefined
|
|
194
|
+
? defaultContext(currentConfigSource().path, profile, auth)
|
|
195
|
+
: defaultContext(currentConfigSource().path, profile);
|
|
190
196
|
});
|
|
197
|
+
const commandServices = {
|
|
198
|
+
getContext: (auth) => auth !== undefined ? contextFactory(auth) : contextFactory(),
|
|
199
|
+
stderr,
|
|
200
|
+
};
|
|
191
201
|
const renderers = (opts.plugins ?? []).flatMap((p) => p.renderers ?? []);
|
|
192
202
|
const output = createOutput({
|
|
193
203
|
stdout,
|
|
@@ -592,7 +602,7 @@ Example:
|
|
|
592
602
|
.action((o) => run2(async () => runAuthStatus(o, await authDeps())));
|
|
593
603
|
if (opts.plugins) {
|
|
594
604
|
for (const plugin of opts.plugins) {
|
|
595
|
-
plugin.registerCommands?.(program);
|
|
605
|
+
plugin.registerCommands?.(program, commandServices);
|
|
596
606
|
}
|
|
597
607
|
}
|
|
598
608
|
program.exitOverride();
|
package/dist/src/plugin-api.d.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
export { readDataArg } from "./commands/_data.js";
|
|
2
|
+
export type { CreateArgs, CreateDeps } from "./commands/create.js";
|
|
3
|
+
export { runCreate } from "./commands/create.js";
|
|
4
|
+
export type { ReadArgs, ReadDeps } from "./commands/read.js";
|
|
5
|
+
export { runRead } from "./commands/read.js";
|
|
6
|
+
export { applyOperationSchemaPlugins } from "./commands/schema.js";
|
|
7
|
+
export type { SearchArgs, SearchDeps } from "./commands/search.js";
|
|
8
|
+
export { runSearch } from "./commands/search.js";
|
|
9
|
+
export type { UpdateArgs, UpdateDeps } from "./commands/update.js";
|
|
10
|
+
export { runUpdate } from "./commands/update.js";
|
|
1
11
|
export type { BasicAuthConfig } from "./core/auth/basic.js";
|
|
2
12
|
export { basicAuthPlugin, basicAuthProvider } from "./core/auth/basic.js";
|
|
3
13
|
export type { AdapterRuntime, AuthAdapter, AuthContext, AuthProvider, AuthSession, AuthStatusInfo, } from "./core/auth/types.js";
|
|
4
14
|
export type { AnyRenderer, InteractiveRenderer, RenderContext, Renderer, RenderServices, } from "./core/cli/render.js";
|
|
5
15
|
export { indexIncluded, isInteractive } from "./core/cli/render.js";
|
|
16
|
+
export type { CommandContext, PluginCommandServices } from "./core/command-context.js";
|
|
6
17
|
export type { Config, SiteConfig } from "./core/config.js";
|
|
7
18
|
export { loadConfig } from "./core/config.js";
|
|
8
19
|
export type { ConfigSource, ConfigSourceKind, ConnectionEntry, ResolveConfigSourceInput, ResolveConnectionsDirInput, } from "./core/connections.js";
|
|
@@ -21,5 +32,9 @@ export type { FieldDescriptor, SchemaFieldIndex } from "./core/params/schema-fie
|
|
|
21
32
|
export { indexSchemaFields, propertiesOf } from "./core/params/schema-fields.js";
|
|
22
33
|
export type { DropSHPlugin, PluginContext, PluginDescriptor, RequestContext, SchemaOperation, } from "./core/plugin.js";
|
|
23
34
|
export { composePlugins } from "./core/plugin.js";
|
|
24
|
-
export {
|
|
25
|
-
export
|
|
35
|
+
export { fetchCatalog } from "./core/schema/catalog.js";
|
|
36
|
+
export { fetchJsonSchema } from "./core/schema/jsonschema-source.js";
|
|
37
|
+
export type { Operation } from "./core/schema/to-jsonschema.js";
|
|
38
|
+
export { toOperationVariant } from "./core/schema/to-jsonschema.js";
|
|
39
|
+
export { validatePayload } from "./core/schema/validate.js";
|
|
40
|
+
export { AuthError, CliError, ConfigError, exitCodeFor, HttpError, PluginError, ValidationError, } from "./errors.js";
|
package/dist/src/plugin-api.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export { readDataArg } from "./commands/_data.js";
|
|
2
|
+
export { runCreate } from "./commands/create.js";
|
|
3
|
+
export { runRead } from "./commands/read.js";
|
|
4
|
+
export { applyOperationSchemaPlugins } from "./commands/schema.js";
|
|
5
|
+
export { runSearch } from "./commands/search.js";
|
|
6
|
+
export { runUpdate } from "./commands/update.js";
|
|
1
7
|
export { basicAuthPlugin, basicAuthProvider } from "./core/auth/basic.js";
|
|
2
8
|
export { indexIncluded, isInteractive } from "./core/cli/render.js";
|
|
3
9
|
export { loadConfig } from "./core/config.js";
|
|
@@ -7,4 +13,8 @@ export { createJsonApiClient } from "./core/jsonapi/client.js";
|
|
|
7
13
|
export { buildPayloadFromParameters } from "./core/params/from-parameters.js";
|
|
8
14
|
export { indexSchemaFields, propertiesOf } from "./core/params/schema-fields.js";
|
|
9
15
|
export { composePlugins } from "./core/plugin.js";
|
|
10
|
-
export {
|
|
16
|
+
export { fetchCatalog } from "./core/schema/catalog.js";
|
|
17
|
+
export { fetchJsonSchema } from "./core/schema/jsonschema-source.js";
|
|
18
|
+
export { toOperationVariant } from "./core/schema/to-jsonschema.js";
|
|
19
|
+
export { validatePayload } from "./core/schema/validate.js";
|
|
20
|
+
export { AuthError, CliError, ConfigError, exitCodeFor, HttpError, PluginError, ValidationError, } from "./errors.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dropsh",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Entity-agnostic helper CLI for Drupal 11 JSON:API, used by the dropsh Claude skill for editorial publishing workflows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@biomejs/biome": "^2.4.14",
|
|
51
|
+
"@modelcontextprotocol/sdk": "1.32.1",
|
|
51
52
|
"@types/node": "^20.14.0",
|
|
52
53
|
"tsx": "^4.19.0",
|
|
53
54
|
"typescript": "^5.6.0",
|