Skip to content

Commit aef8d77

Browse files
committed
refactor(providers): port providers to hosted runtime and delete tests
1 parent 96f8981 commit aef8d77

69 files changed

Lines changed: 560 additions & 6249 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
## Providers
3030

3131
- Provider code normally lives in `src/providers/<service>/definition.ts`, `actions.ts`, `executors.ts`, and provider-local runtime helper files when needed.
32+
- When purely migrating a provider from the OOMOL-hosted connector, do not copy or add provider-local tests because the source repository already owns that regression coverage. Tests may be removed from this repository after an OSS-originated provider change is reverse-ported and covered in private. Keep open-source-only shared-infrastructure tests beside the shared module rather than inside a provider directory.
3233
- Prefer provider-local constants for official scopes, permissions, URLs, and API versions. Action `requiredScopes` should use provider-native scopes/capabilities, not private internal aliases.
3334
- Avoid repeated action-name wiring. Define action handlers once and derive executor maps through shared provider runtime helpers when an existing helper fits. Do not add provider-local action-name unions, tuple builders, or casts solely to prove the handler keys to TypeScript.
3435
- Do not import provider definitions from executor modules just to reuse metadata; inject catalog metadata from the server/loader side when needed.

src/core/json-schema.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,12 @@ export const jsonSchema = {
163163
return withOptions({ type: "string", pattern }, options);
164164
},
165165

166-
stringEnum(valuesOrDescription: string[] | string, optionsOrValues: JsonSchemaOptions | string[] = {}): JsonSchema {
167-
const values = typeof valuesOrDescription === "string" ? (optionsOrValues as string[]) : valuesOrDescription;
166+
stringEnum(
167+
valuesOrDescription: readonly string[] | string,
168+
optionsOrValues: JsonSchemaOptions | readonly string[] = {},
169+
): JsonSchema {
170+
const values =
171+
typeof valuesOrDescription === "string" ? (optionsOrValues as readonly string[]) : valuesOrDescription;
168172
const options =
169173
typeof valuesOrDescription === "string"
170174
? { description: valuesOrDescription }

src/core/provider-definition.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import type { ActionDefinition, JsonSchema } from "./types.ts";
44
* Input for defining one provider action without repeating provider-level
55
* fields in every action object.
66
*/
7-
export type DefineProviderActionInput<TName extends string = string> = {
7+
export interface DefineProviderActionInput<TName extends string = string> {
88
name: TName;
99
description: string;
1010
inputSchema: JsonSchema;
1111
outputSchema: JsonSchema;
12-
requiredScopes?: string[];
13-
providerPermissions?: string[];
14-
followUpActions?: string[];
12+
requiredScopes?: readonly string[];
13+
providerPermissions?: readonly string[];
14+
followUpActions?: readonly string[];
1515
asyncLifecycle?: ActionDefinition["asyncLifecycle"];
16-
};
16+
}
1717

1818
export type ProviderActionDefinition<TName extends string = string> = ActionDefinition & { name: TName };
1919

@@ -32,11 +32,11 @@ export function defineProviderAction<TName extends string>(
3232
service,
3333
name: input.name,
3434
description: input.description,
35-
requiredScopes: input.requiredScopes ?? [],
36-
providerPermissions: input.providerPermissions ?? [],
35+
requiredScopes: input.requiredScopes ? [...input.requiredScopes] : [],
36+
providerPermissions: input.providerPermissions ? [...input.providerPermissions] : [],
3737
inputSchema: input.inputSchema,
3838
outputSchema: input.outputSchema,
39-
followUpActions: input.followUpActions,
39+
followUpActions: input.followUpActions ? [...input.followUpActions] : undefined,
4040
asyncLifecycle: input.asyncLifecycle,
4141
};
4242
}

src/providers/aliyun_oss/executors.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ function createAliyunOssClient(input: AliyunClientOptions): AliyunOssClient {
324324
return new AliOss({
325325
accessKeyId: input.accessKeyId,
326326
accessKeySecret: input.accessKeySecret,
327-
...(input.securityToken ? { stsToken: input.securityToken } : {}),
327+
stsToken: input.securityToken,
328328
endpoint: stripProtocol(normalizeEndpoint(input.endpoint)),
329-
...(input.bucket ? { bucket: input.bucket } : {}),
329+
bucket: input.bucket,
330330
secure: true,
331331
}) as unknown as AliyunOssClient;
332332
}
@@ -681,11 +681,8 @@ function normalizeAliyunError(error: unknown, phase: "validate" | "execute"): Pr
681681
}
682682

683683
function readAliyunErrorStatus(error: unknown): number | undefined {
684-
if (!error || typeof error !== "object") {
685-
return undefined;
686-
}
687-
688-
const record = error as Record<string, unknown>;
684+
const record = optionalRecord(error);
685+
if (!record) return undefined;
689686
const status = record.status ?? record.statusCode ?? record.code;
690687
return typeof status === "number" ? status : undefined;
691688
}

src/providers/aliyun_oss/network-access.test.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/providers/aliyun_sls/actions.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,6 @@ const queryTimeProperties: Record<string, JsonSchema> = {
8686
query: s.string("An optional Simple Log Service search or analytic statement."),
8787
};
8888

89-
export type AliyunSlsActionName =
90-
| "list_projects"
91-
| "list_projects_across_regions"
92-
| "list_logstores"
93-
| "query_logs"
94-
| "get_histograms";
95-
9689
export const aliyunSlsActions: ActionDefinition[] = [
9790
defineProviderAction(service, {
9891
name: "list_projects",

src/providers/aliyun_sls/resources.test.ts

Lines changed: 0 additions & 149 deletions
This file was deleted.

0 commit comments

Comments
 (0)