@decocms/runtime 1.0.0-alpha.10 → 1.0.0-alpha.11
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/config-schema.json +8 -8
- package/package.json +3 -8
- package/src/bindings/binder.ts +1 -4
- package/src/bindings/index.ts +0 -33
- package/src/bindings.ts +31 -110
- package/src/client.ts +1 -145
- package/src/index.ts +48 -157
- package/src/mcp.ts +8 -161
- package/src/proxy.ts +3 -54
- package/src/state.ts +3 -31
- package/src/tools.ts +342 -0
- package/src/wrangler.ts +5 -5
- package/tsconfig.json +1 -1
- package/src/admin.ts +0 -16
- package/src/auth.ts +0 -233
- package/src/bindings/deconfig/helpers.ts +0 -107
- package/src/bindings/deconfig/index.ts +0 -1
- package/src/bindings/deconfig/resources.ts +0 -689
- package/src/bindings/deconfig/types.ts +0 -106
- package/src/bindings/resources/bindings.ts +0 -99
- package/src/bindings/resources/helpers.ts +0 -95
- package/src/bindings/resources/schemas.ts +0 -265
- package/src/bindings/views.ts +0 -14
- package/src/drizzle.ts +0 -201
- package/src/mastra.ts +0 -670
- package/src/resources.ts +0 -168
- package/src/views.ts +0 -26
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
// Types for DeconfigResource
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import type { DefaultEnv } from "../../index.ts";
|
|
4
|
-
import type { MCPClientFetchStub, ToolBinder } from "../../mcp.ts";
|
|
5
|
-
import type { BaseResourceDataSchema } from "../resources/bindings.ts";
|
|
6
|
-
|
|
7
|
-
export type ResourcesBinding<TDataSchema extends BaseResourceDataSchema> =
|
|
8
|
-
ReturnType<
|
|
9
|
-
typeof import("../resources/bindings.ts").createResourceBindings<TDataSchema>
|
|
10
|
-
>;
|
|
11
|
-
|
|
12
|
-
export type ResourcesTools<TDataSchema extends BaseResourceDataSchema> =
|
|
13
|
-
ResourcesBinding<TDataSchema>[number]["name"];
|
|
14
|
-
|
|
15
|
-
export type EnhancedResourcesTools<TDataSchema extends BaseResourceDataSchema> =
|
|
16
|
-
Partial<
|
|
17
|
-
Record<
|
|
18
|
-
ResourcesTools<TDataSchema>,
|
|
19
|
-
{
|
|
20
|
-
description: string;
|
|
21
|
-
}
|
|
22
|
-
>
|
|
23
|
-
>;
|
|
24
|
-
|
|
25
|
-
// Define deconfig tools as ToolBinder array (same pattern as workspaceTools in mcp.ts)
|
|
26
|
-
export const deconfigTools = [
|
|
27
|
-
{
|
|
28
|
-
name: "LIST_FILES" as const,
|
|
29
|
-
inputSchema: z.object({
|
|
30
|
-
branch: z.string().optional(),
|
|
31
|
-
prefix: z.string().optional(),
|
|
32
|
-
select: z.array(z.string()).optional(),
|
|
33
|
-
includeContent: z.boolean().optional(),
|
|
34
|
-
}),
|
|
35
|
-
outputSchema: z.object({
|
|
36
|
-
files: z.record(
|
|
37
|
-
z.string(),
|
|
38
|
-
z.object({
|
|
39
|
-
address: z.string(),
|
|
40
|
-
metadata: z.record(z.string(), z.any()),
|
|
41
|
-
sizeInBytes: z.number(),
|
|
42
|
-
mtime: z.number(),
|
|
43
|
-
ctime: z.number(),
|
|
44
|
-
content: z.string().optional(),
|
|
45
|
-
}),
|
|
46
|
-
),
|
|
47
|
-
count: z.number(),
|
|
48
|
-
}),
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "READ_FILE" as const,
|
|
52
|
-
inputSchema: z.object({
|
|
53
|
-
branch: z.string().optional(),
|
|
54
|
-
path: z.string(),
|
|
55
|
-
format: z.enum(["base64", "byteArray", "plainString", "json"]).optional(),
|
|
56
|
-
}),
|
|
57
|
-
outputSchema: z.object({
|
|
58
|
-
content: z.any(),
|
|
59
|
-
address: z.string(),
|
|
60
|
-
metadata: z.record(z.any()),
|
|
61
|
-
mtime: z.number(),
|
|
62
|
-
ctime: z.number(),
|
|
63
|
-
}),
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "PUT_FILE" as const,
|
|
67
|
-
inputSchema: z.object({
|
|
68
|
-
branch: z.string().optional(),
|
|
69
|
-
path: z.string(),
|
|
70
|
-
content: z.union([
|
|
71
|
-
z.string(),
|
|
72
|
-
z.object({ base64: z.string() }),
|
|
73
|
-
z.array(z.number()),
|
|
74
|
-
]),
|
|
75
|
-
metadata: z.record(z.any()).optional(),
|
|
76
|
-
expectedCtime: z.number().optional(),
|
|
77
|
-
}),
|
|
78
|
-
outputSchema: z.object({
|
|
79
|
-
conflict: z.boolean().optional(),
|
|
80
|
-
}),
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
name: "DELETE_FILE" as const,
|
|
84
|
-
inputSchema: z.object({
|
|
85
|
-
branch: z.string().optional(),
|
|
86
|
-
path: z.string(),
|
|
87
|
-
}),
|
|
88
|
-
outputSchema: z.object({
|
|
89
|
-
deleted: z.boolean(),
|
|
90
|
-
}),
|
|
91
|
-
},
|
|
92
|
-
] as const satisfies readonly ToolBinder[];
|
|
93
|
-
|
|
94
|
-
// DeconfigClient is now a typed MCP client stub (same pattern as workspaceTools)
|
|
95
|
-
export type DeconfigClient = MCPClientFetchStub<typeof deconfigTools>;
|
|
96
|
-
|
|
97
|
-
export interface DeconfigResourceOptions<
|
|
98
|
-
TDataSchema extends BaseResourceDataSchema,
|
|
99
|
-
> {
|
|
100
|
-
directory?: string; // defaults to /resources/$resourceName
|
|
101
|
-
resourceName: string;
|
|
102
|
-
env: DefaultEnv & { DECONFIG: DeconfigClient };
|
|
103
|
-
dataSchema: TDataSchema;
|
|
104
|
-
enhancements?: EnhancedResourcesTools<TDataSchema>;
|
|
105
|
-
validate?: (data: z.infer<TDataSchema>) => Promise<void>;
|
|
106
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { ToolBinder } from "../../mcp.ts";
|
|
3
|
-
import {
|
|
4
|
-
createCreateInputSchema,
|
|
5
|
-
createCreateOutputSchema,
|
|
6
|
-
createItemSchema,
|
|
7
|
-
createReadOutputSchema,
|
|
8
|
-
createSearchOutputSchema,
|
|
9
|
-
createUpdateInputSchema,
|
|
10
|
-
createUpdateOutputSchema,
|
|
11
|
-
DeleteInputSchema,
|
|
12
|
-
DeleteOutputSchema,
|
|
13
|
-
DescribeInputSchema,
|
|
14
|
-
DescribeOutputSchema,
|
|
15
|
-
ReadInputSchema,
|
|
16
|
-
SearchInputSchema,
|
|
17
|
-
} from "./schemas.ts";
|
|
18
|
-
export type BaseResourceDataSchema = z.ZodObject<{
|
|
19
|
-
name: z.ZodString;
|
|
20
|
-
description: z.ZodString;
|
|
21
|
-
}>;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Resources 2.0 Bindings
|
|
25
|
-
*
|
|
26
|
-
* This module provides standardized tool bindings for Resources 2.0, a major version upgrade
|
|
27
|
-
* that introduces standardized resource management with `rsc://` URI format and
|
|
28
|
-
* consistent CRUD operations across all resource types.
|
|
29
|
-
*
|
|
30
|
-
* Key Features:
|
|
31
|
-
* - Generic resource bindings that work with any resource type
|
|
32
|
-
* - Standardized tool naming: `deco_resource_*`
|
|
33
|
-
* - Full TypeScript support with proper type constraints
|
|
34
|
-
* - Integration with existing binding system
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Creates generic resource bindings for Resources 2.0
|
|
39
|
-
*
|
|
40
|
-
* This function generates standardized tool bindings that work with any resource type
|
|
41
|
-
* by accepting a custom data schema and resource name. The bindings provide the standard CRUD operations:
|
|
42
|
-
* - DECO_RESOURCE_{RESOURCE}_SEARCH - Search resources with pagination and filtering
|
|
43
|
-
* - DECO_RESOURCE_{RESOURCE}_READ - Read a single resource by URI
|
|
44
|
-
* - DECO_RESOURCE_{RESOURCE}_CREATE - Create new resources (optional)
|
|
45
|
-
* - DECO_RESOURCE_{RESOURCE}_UPDATE - Update existing resources (optional)
|
|
46
|
-
* - DECO_RESOURCE_{RESOURCE}_DELETE - Delete resources (optional)
|
|
47
|
-
*
|
|
48
|
-
* @param resourceName - The name of the resource type (e.g., "workflow", "document", "user")
|
|
49
|
-
* @param dataSchema - The Zod schema for the resource data type
|
|
50
|
-
* @returns Array of tool bindings for Resources 2.0 CRUD operations
|
|
51
|
-
*/
|
|
52
|
-
export function createResourceBindings<
|
|
53
|
-
TDataSchema extends BaseResourceDataSchema,
|
|
54
|
-
>(resourceName: string, dataSchema: TDataSchema) {
|
|
55
|
-
const readOutputSchema = createReadOutputSchema(dataSchema);
|
|
56
|
-
return [
|
|
57
|
-
{
|
|
58
|
-
name: `DECO_RESOURCE_${resourceName.toUpperCase()}_SEARCH` as const,
|
|
59
|
-
inputSchema: SearchInputSchema,
|
|
60
|
-
outputSchema: createSearchOutputSchema(
|
|
61
|
-
createItemSchema(dataSchema.pick({ name: true, description: true })),
|
|
62
|
-
),
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: `DECO_RESOURCE_${resourceName.toUpperCase()}_READ` as const,
|
|
66
|
-
inputSchema: ReadInputSchema,
|
|
67
|
-
outputSchema: readOutputSchema,
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: `DECO_RESOURCE_${resourceName.toUpperCase()}_CREATE` as const,
|
|
71
|
-
inputSchema: createCreateInputSchema(dataSchema),
|
|
72
|
-
outputSchema: createCreateOutputSchema(dataSchema),
|
|
73
|
-
opt: true,
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: `DECO_RESOURCE_${resourceName.toUpperCase()}_UPDATE` as const,
|
|
77
|
-
inputSchema: createUpdateInputSchema(dataSchema),
|
|
78
|
-
outputSchema: createUpdateOutputSchema(dataSchema),
|
|
79
|
-
opt: true,
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: `DECO_RESOURCE_${resourceName.toUpperCase()}_DELETE` as const,
|
|
83
|
-
inputSchema: DeleteInputSchema,
|
|
84
|
-
outputSchema: DeleteOutputSchema,
|
|
85
|
-
opt: true,
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
name: `DECO_RESOURCE_${resourceName.toUpperCase()}_DESCRIBE` as const,
|
|
89
|
-
inputSchema: DescribeInputSchema,
|
|
90
|
-
outputSchema: DescribeOutputSchema,
|
|
91
|
-
opt: true,
|
|
92
|
-
},
|
|
93
|
-
] as const satisfies readonly ToolBinder[];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Export types for TypeScript usage
|
|
97
|
-
export type ResourceBinding<TDataSchema extends BaseResourceDataSchema> =
|
|
98
|
-
ReturnType<typeof createResourceBindings<TDataSchema>>;
|
|
99
|
-
export type ResourceBindingsFunction = typeof createResourceBindings;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ResourceUriSchema,
|
|
3
|
-
type CreateInput,
|
|
4
|
-
type CreateOutput,
|
|
5
|
-
type DeleteInput,
|
|
6
|
-
type DeleteOutput,
|
|
7
|
-
type ReadInput,
|
|
8
|
-
type ReadOutput,
|
|
9
|
-
type SearchInput,
|
|
10
|
-
type SearchOutput,
|
|
11
|
-
} from "./schemas.ts";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Resources 2.0 Helper Functions
|
|
15
|
-
*
|
|
16
|
-
* This module provides helper functions for working with Resources 2.0
|
|
17
|
-
* URI format and validation.
|
|
18
|
-
*
|
|
19
|
-
* Key Features:
|
|
20
|
-
* - URI validation and parsing utilities
|
|
21
|
-
* - URI construction helpers
|
|
22
|
-
* - Type-safe resource URI handling
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Utility function to validate a resource URI format
|
|
27
|
-
*
|
|
28
|
-
* @param uri - The URI to validate
|
|
29
|
-
* @returns True if the URI is valid, false otherwise
|
|
30
|
-
*/
|
|
31
|
-
export function validateResourceUri(uri: string): boolean {
|
|
32
|
-
try {
|
|
33
|
-
ResourceUriSchema.parse(uri);
|
|
34
|
-
return true;
|
|
35
|
-
} catch {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Utility function to parse a resource URI into its components
|
|
42
|
-
*
|
|
43
|
-
* @param uri - The URI to parse
|
|
44
|
-
* @returns Object containing the parsed components or null if invalid
|
|
45
|
-
*/
|
|
46
|
-
export function parseResourceUri(uri: string): {
|
|
47
|
-
workspace: string;
|
|
48
|
-
project: string;
|
|
49
|
-
resourceId: string;
|
|
50
|
-
} | null {
|
|
51
|
-
try {
|
|
52
|
-
const validated = ResourceUriSchema.parse(uri);
|
|
53
|
-
const match = validated.match(/^rsc:\/\/([^/]+)\/([^/]+)\/(.+)$/);
|
|
54
|
-
|
|
55
|
-
if (!match) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
workspace: match[1],
|
|
61
|
-
project: match[2],
|
|
62
|
-
resourceId: match[3],
|
|
63
|
-
};
|
|
64
|
-
} catch {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Utility function to construct a resource URI from components
|
|
71
|
-
*
|
|
72
|
-
* @param workspace - The workspace identifier
|
|
73
|
-
* @param project - The project identifier
|
|
74
|
-
* @param resourceId - The resource identifier
|
|
75
|
-
* @returns The constructed resource URI
|
|
76
|
-
*/
|
|
77
|
-
export function constructResourceUri(
|
|
78
|
-
workspace: string,
|
|
79
|
-
project: string,
|
|
80
|
-
resourceId: string,
|
|
81
|
-
): string {
|
|
82
|
-
return `rsc://${workspace}/${project}/${resourceId}`;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Re-export types for convenience
|
|
86
|
-
export type {
|
|
87
|
-
CreateInput,
|
|
88
|
-
CreateOutput,
|
|
89
|
-
DeleteInput,
|
|
90
|
-
DeleteOutput,
|
|
91
|
-
ReadInput,
|
|
92
|
-
ReadOutput,
|
|
93
|
-
SearchInput,
|
|
94
|
-
SearchOutput,
|
|
95
|
-
};
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Resources 2.0 Schemas
|
|
5
|
-
*
|
|
6
|
-
* This module provides standardized schemas for Resources 2.0, a major version upgrade
|
|
7
|
-
* that introduces standardized resource management with `rsc://` URI format and
|
|
8
|
-
* consistent CRUD operations across all resource types.
|
|
9
|
-
*
|
|
10
|
-
* Key Features:
|
|
11
|
-
* - Standardized `rsc://` URI format for all resources
|
|
12
|
-
* - Generic CRUD operation schemas that work with any resource type
|
|
13
|
-
* - Type-safe factory functions for creating resource-specific schemas
|
|
14
|
-
* - Comprehensive validation and error handling
|
|
15
|
-
* - Full TypeScript support with Zod validation
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
// Common URI format validation for Resources 2.0
|
|
19
|
-
export const ResourceUriSchema = z
|
|
20
|
-
.string()
|
|
21
|
-
.regex(
|
|
22
|
-
/^rsc:\/\/[^/]+\/[^/]+\/.+$/,
|
|
23
|
-
"Invalid resource URI format. Expected format: rsc://workspace/project/resource-id",
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export const DescribeInputSchema = z.object({});
|
|
27
|
-
export const DescribeOutputSchema = z.object({
|
|
28
|
-
uriTemplate: ResourceUriSchema.describe("URI template for the resource"),
|
|
29
|
-
features: z.object({
|
|
30
|
-
watch: z.object({
|
|
31
|
-
pathname: z.string().describe("Pathname to watch"),
|
|
32
|
-
}),
|
|
33
|
-
}),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Search input schema for resource queries
|
|
38
|
-
* Supports pagination, filtering, sorting, and search terms
|
|
39
|
-
*/
|
|
40
|
-
export const SearchInputSchema = z.object({
|
|
41
|
-
term: z.string().optional().describe("Search term to filter resources"),
|
|
42
|
-
page: z.number().int().min(1).default(1).describe("Page number (1-based)"),
|
|
43
|
-
pageSize: z
|
|
44
|
-
.number()
|
|
45
|
-
.int()
|
|
46
|
-
.min(1)
|
|
47
|
-
.max(100)
|
|
48
|
-
.default(20)
|
|
49
|
-
.describe("Number of items per page"),
|
|
50
|
-
filters: z.record(z.any()).optional().describe("Additional filters to apply"),
|
|
51
|
-
sortBy: z.string().optional().describe("Field to sort by"),
|
|
52
|
-
sortOrder: z
|
|
53
|
-
.enum(["asc", "desc"])
|
|
54
|
-
.optional()
|
|
55
|
-
.default("asc")
|
|
56
|
-
.describe("Sort order"),
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Factory function to create search output schema for a specific resource type
|
|
61
|
-
* @param itemSchema - The schema for individual resource items
|
|
62
|
-
* @returns Zod schema for search results with pagination metadata
|
|
63
|
-
*/
|
|
64
|
-
export function createSearchOutputSchema<T extends z.ZodTypeAny>(
|
|
65
|
-
itemSchema: T,
|
|
66
|
-
) {
|
|
67
|
-
return z.object({
|
|
68
|
-
items: z.array(itemSchema).describe("Array of matching resources"),
|
|
69
|
-
totalCount: z
|
|
70
|
-
.number()
|
|
71
|
-
.int()
|
|
72
|
-
.min(0)
|
|
73
|
-
.describe("Total number of matching resources"),
|
|
74
|
-
page: z.number().int().min(1).describe("Current page number"),
|
|
75
|
-
pageSize: z.number().int().min(1).describe("Number of items per page"),
|
|
76
|
-
totalPages: z.number().int().min(0).describe("Total number of pages"),
|
|
77
|
-
hasNextPage: z.boolean().describe("Whether there are more pages available"),
|
|
78
|
-
hasPreviousPage: z
|
|
79
|
-
.boolean()
|
|
80
|
-
.describe("Whether there are previous pages available"),
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Read input schema for retrieving a single resource
|
|
86
|
-
*/
|
|
87
|
-
export const ReadInputSchema = z.object({
|
|
88
|
-
uri: ResourceUriSchema.describe("URI of the resource to read"),
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Factory function to create read output schema for a specific resource type
|
|
93
|
-
* @param dataSchema - The schema for the resource data
|
|
94
|
-
* @returns Zod schema for read operation results
|
|
95
|
-
*/
|
|
96
|
-
export function createReadOutputSchema<T extends z.ZodTypeAny>(dataSchema: T) {
|
|
97
|
-
return z.object({
|
|
98
|
-
uri: ResourceUriSchema.describe("URI of the resource"),
|
|
99
|
-
data: dataSchema.describe("Resource data"),
|
|
100
|
-
created_at: z.string().datetime().optional().describe("Creation timestamp"),
|
|
101
|
-
updated_at: z
|
|
102
|
-
.string()
|
|
103
|
-
.datetime()
|
|
104
|
-
.optional()
|
|
105
|
-
.describe("Last update timestamp"),
|
|
106
|
-
created_by: z.string().optional().describe("User who created the resource"),
|
|
107
|
-
updated_by: z
|
|
108
|
-
.string()
|
|
109
|
-
.optional()
|
|
110
|
-
.describe("User who last updated the resource"),
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Factory function to create create input schema for a specific resource type
|
|
116
|
-
* @param dataSchema - The schema for the resource data to create
|
|
117
|
-
* @returns Zod schema for create operation input
|
|
118
|
-
*/
|
|
119
|
-
export function createCreateInputSchema<T extends z.ZodTypeAny>(dataSchema: T) {
|
|
120
|
-
return z.object({
|
|
121
|
-
data: dataSchema.describe("Resource data to create"),
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Factory function to create create output schema for a specific resource type
|
|
127
|
-
* @param dataSchema - The schema for the created resource data
|
|
128
|
-
* @returns Zod schema for create operation results
|
|
129
|
-
*/
|
|
130
|
-
export function createCreateOutputSchema<T extends z.ZodTypeAny>(
|
|
131
|
-
dataSchema: T,
|
|
132
|
-
) {
|
|
133
|
-
return z.object({
|
|
134
|
-
uri: ResourceUriSchema.describe("URI of the created resource"),
|
|
135
|
-
data: dataSchema.describe("Created resource data"),
|
|
136
|
-
created_at: z.string().datetime().optional().describe("Creation timestamp"),
|
|
137
|
-
updated_at: z
|
|
138
|
-
.string()
|
|
139
|
-
.datetime()
|
|
140
|
-
.optional()
|
|
141
|
-
.describe("Last update timestamp"),
|
|
142
|
-
created_by: z.string().optional().describe("User who created the resource"),
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Factory function to create update input schema for a specific resource type
|
|
148
|
-
* @param dataSchema - The schema for the resource data to update
|
|
149
|
-
* @returns Zod schema for update operation input
|
|
150
|
-
*/
|
|
151
|
-
export function createUpdateInputSchema<T extends z.ZodTypeAny>(dataSchema: T) {
|
|
152
|
-
return z.object({
|
|
153
|
-
uri: ResourceUriSchema.describe("URI of the resource to update"),
|
|
154
|
-
data: dataSchema.describe("Updated resource data"),
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Factory function to create update output schema for a specific resource type
|
|
160
|
-
* @param dataSchema - The schema for the updated resource data
|
|
161
|
-
* @returns Zod schema for update operation results
|
|
162
|
-
*/
|
|
163
|
-
export function createUpdateOutputSchema<T extends z.ZodTypeAny>(
|
|
164
|
-
dataSchema: T,
|
|
165
|
-
) {
|
|
166
|
-
return z.object({
|
|
167
|
-
uri: ResourceUriSchema.describe("URI of the updated resource"),
|
|
168
|
-
data: dataSchema.describe("Updated resource data"),
|
|
169
|
-
created_at: z
|
|
170
|
-
.string()
|
|
171
|
-
.datetime()
|
|
172
|
-
.optional()
|
|
173
|
-
.describe("Original creation timestamp"),
|
|
174
|
-
updated_at: z
|
|
175
|
-
.string()
|
|
176
|
-
.datetime()
|
|
177
|
-
.optional()
|
|
178
|
-
.describe("Last update timestamp"),
|
|
179
|
-
created_by: z
|
|
180
|
-
.string()
|
|
181
|
-
.optional()
|
|
182
|
-
.describe("User who originally created the resource"),
|
|
183
|
-
updated_by: z
|
|
184
|
-
.string()
|
|
185
|
-
.optional()
|
|
186
|
-
.describe("User who last updated the resource"),
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Delete input schema for removing a resource
|
|
192
|
-
*/
|
|
193
|
-
export const DeleteInputSchema = z.object({
|
|
194
|
-
uri: ResourceUriSchema.describe("URI of the resource to delete"),
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Delete output schema for delete operation results
|
|
199
|
-
*/
|
|
200
|
-
export const DeleteOutputSchema = z.object({
|
|
201
|
-
success: z.boolean().describe("Whether the deletion was successful"),
|
|
202
|
-
uri: ResourceUriSchema.describe("URI of the deleted resource"),
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Factory function to create item schema for a specific resource type
|
|
207
|
-
* This schema is used in search results and lists
|
|
208
|
-
* @param dataSchema - The schema for the resource data
|
|
209
|
-
* @returns Zod schema for resource items with metadata
|
|
210
|
-
*/
|
|
211
|
-
export function createItemSchema<T extends z.ZodTypeAny>(dataSchema: T) {
|
|
212
|
-
return z.object({
|
|
213
|
-
uri: ResourceUriSchema.describe("URI of the resource"),
|
|
214
|
-
data: z
|
|
215
|
-
.object({
|
|
216
|
-
name: z.string().min(1, "Name is required"),
|
|
217
|
-
description: z
|
|
218
|
-
.string()
|
|
219
|
-
.optional()
|
|
220
|
-
.describe("Description of the resource"),
|
|
221
|
-
icon: z.string().url().optional().describe("URL to the resource icon"),
|
|
222
|
-
})
|
|
223
|
-
.and(dataSchema)
|
|
224
|
-
.describe("Resource data with required name"),
|
|
225
|
-
created_at: z.string().datetime().optional().describe("Creation timestamp"),
|
|
226
|
-
updated_at: z
|
|
227
|
-
.string()
|
|
228
|
-
.datetime()
|
|
229
|
-
.optional()
|
|
230
|
-
.describe("Last update timestamp"),
|
|
231
|
-
created_by: z.string().optional().describe("User who created the resource"),
|
|
232
|
-
updated_by: z
|
|
233
|
-
.string()
|
|
234
|
-
.optional()
|
|
235
|
-
.describe("User who last updated the resource"),
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// Export types for TypeScript usage
|
|
240
|
-
export type ResourceUri = z.infer<typeof ResourceUriSchema>;
|
|
241
|
-
export type SearchInput = z.infer<typeof SearchInputSchema>;
|
|
242
|
-
export type SearchOutput<T extends z.ZodTypeAny> = z.infer<
|
|
243
|
-
ReturnType<typeof createSearchOutputSchema<T>>
|
|
244
|
-
>;
|
|
245
|
-
export type ReadInput = z.infer<typeof ReadInputSchema>;
|
|
246
|
-
export type ReadOutput<T extends z.ZodTypeAny> = z.infer<
|
|
247
|
-
ReturnType<typeof createReadOutputSchema<T>>
|
|
248
|
-
>;
|
|
249
|
-
export type CreateInput<T extends z.ZodTypeAny> = z.infer<
|
|
250
|
-
ReturnType<typeof createCreateInputSchema<T>>
|
|
251
|
-
>;
|
|
252
|
-
export type CreateOutput<T extends z.ZodTypeAny> = z.infer<
|
|
253
|
-
ReturnType<typeof createCreateOutputSchema<T>>
|
|
254
|
-
>;
|
|
255
|
-
export type UpdateInput<T extends z.ZodTypeAny> = z.infer<
|
|
256
|
-
ReturnType<typeof createUpdateInputSchema<T>>
|
|
257
|
-
>;
|
|
258
|
-
export type UpdateOutput<T extends z.ZodTypeAny> = z.infer<
|
|
259
|
-
ReturnType<typeof createUpdateOutputSchema<T>>
|
|
260
|
-
>;
|
|
261
|
-
export type DeleteInput = z.infer<typeof DeleteInputSchema>;
|
|
262
|
-
export type DeleteOutput = z.infer<typeof DeleteOutputSchema>;
|
|
263
|
-
export type ResourceItem<T extends z.ZodTypeAny> = z.infer<
|
|
264
|
-
ReturnType<typeof createItemSchema<T>>
|
|
265
|
-
>;
|
package/src/bindings/views.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ViewsListOutputSchema } from "../views.ts";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import type { ToolBinder } from "../mcp.ts";
|
|
4
|
-
|
|
5
|
-
export const VIEW_BINDING = [
|
|
6
|
-
{
|
|
7
|
-
name: "DECO_CHAT_VIEWS_LIST" as const,
|
|
8
|
-
inputSchema: z.any(),
|
|
9
|
-
outputSchema: ViewsListOutputSchema,
|
|
10
|
-
},
|
|
11
|
-
] as const satisfies readonly ToolBinder[];
|
|
12
|
-
|
|
13
|
-
// Re-export for existing imports expecting listViewsSchema
|
|
14
|
-
export const listViewsSchema = ViewsListOutputSchema;
|