@decocms/runtime 1.0.0-alpha.10 → 1.0.0-alpha.12
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 +4 -13
- 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 +7 -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
- package/src/well-known.ts +0 -20
package/src/resources.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import mimeDb from "mime-db";
|
|
3
|
-
|
|
4
|
-
type MimeDb = Record<string, { extensions?: string[] }>;
|
|
5
|
-
|
|
6
|
-
const EXTENSION_TO_MIME = (() => {
|
|
7
|
-
const map = new Map<string, string>();
|
|
8
|
-
Object.entries(mimeDb as MimeDb).forEach(([type, meta]) => {
|
|
9
|
-
meta.extensions?.forEach((ext) => {
|
|
10
|
-
if (!map.has(ext)) {
|
|
11
|
-
map.set(ext, type);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
return map;
|
|
16
|
-
})();
|
|
17
|
-
|
|
18
|
-
function extractExtension(value: string): string | undefined {
|
|
19
|
-
if (!value) return undefined;
|
|
20
|
-
const trimmed = value.trim();
|
|
21
|
-
if (!trimmed) return undefined;
|
|
22
|
-
|
|
23
|
-
const sanitized = trimmed.replace(/^[^?#]*/g, (match) => match);
|
|
24
|
-
const withoutQuery = sanitized.split(/[?#]/)[0];
|
|
25
|
-
|
|
26
|
-
if (withoutQuery.startsWith(".")) {
|
|
27
|
-
return withoutQuery.slice(1).toLowerCase();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (!withoutQuery.includes(".")) {
|
|
31
|
-
if (!withoutQuery.includes("/") && !withoutQuery.includes("\\")) {
|
|
32
|
-
return withoutQuery.toLowerCase();
|
|
33
|
-
}
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const lastDot = withoutQuery.lastIndexOf(".");
|
|
38
|
-
if (lastDot === -1 || lastDot === withoutQuery.length - 1) return undefined;
|
|
39
|
-
return withoutQuery.slice(lastDot + 1).toLowerCase();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Base Resource Schema (enhanced)
|
|
43
|
-
const ResourceSchema = z.object({
|
|
44
|
-
name: z.string(),
|
|
45
|
-
title: z.string().optional(),
|
|
46
|
-
description: z.string().optional(),
|
|
47
|
-
uri: z.string().url(),
|
|
48
|
-
mimeType: z.string().optional(),
|
|
49
|
-
thumbnail: z.string().url().optional(),
|
|
50
|
-
timestamp: z.string().datetime().optional(),
|
|
51
|
-
size: z.number().positive().optional(),
|
|
52
|
-
annotations: z.record(z.string(), z.string()).optional(),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Tool Input/Output Schemas (unified)
|
|
56
|
-
export const ResourcesReadInputSchema = z.object({
|
|
57
|
-
name: z.string().describe("Resource type name (e.g., 'Page', 'GoogleDrive')"),
|
|
58
|
-
uri: z
|
|
59
|
-
.string()
|
|
60
|
-
.url()
|
|
61
|
-
.describe(
|
|
62
|
-
"The URI of the resource to read. It's important to add the url scheme. Use file:// for files. Use https:// or http:// for remote files",
|
|
63
|
-
),
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
export const ResourcesReadOutputSchema = ResourceSchema.extend({
|
|
67
|
-
data: z.string().describe("The resource content as a string"),
|
|
68
|
-
type: z
|
|
69
|
-
.enum(["text", "blob"])
|
|
70
|
-
.describe(
|
|
71
|
-
"Type of data: 'text' for plain text, 'blob' for base64-encoded binary",
|
|
72
|
-
),
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
export const ResourceSearchInputSchema = z.object({
|
|
76
|
-
name: z.string().describe("Resource type name (e.g., 'Page', 'GoogleDrive')"),
|
|
77
|
-
term: z.string().describe("The term to search for"),
|
|
78
|
-
cursor: z.string().optional(),
|
|
79
|
-
limit: z.number().positive().optional(),
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
export const ResourceSearchOutputSchema = z.object({
|
|
83
|
-
items: z.array(ResourceSchema),
|
|
84
|
-
hasMore: z.boolean(),
|
|
85
|
-
nextCursor: z.string().optional(),
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
export const ResourceCreateInputSchema = z.object({
|
|
89
|
-
name: z.string().describe("Resource type name (e.g., 'Page', 'GoogleDrive')"),
|
|
90
|
-
resourceName: z
|
|
91
|
-
.string()
|
|
92
|
-
.describe(
|
|
93
|
-
"Name of the specific resource instance. DO NOT ADD EXTENSIONS TO THE NAME",
|
|
94
|
-
),
|
|
95
|
-
title: z.string().optional(),
|
|
96
|
-
description: z.string().optional(),
|
|
97
|
-
content: z
|
|
98
|
-
.object({
|
|
99
|
-
data: z.string(),
|
|
100
|
-
type: z.enum(["text", "blob"]),
|
|
101
|
-
mimeType: z.string().optional(),
|
|
102
|
-
})
|
|
103
|
-
.describe("Content to create the resource with"),
|
|
104
|
-
metadata: z.record(z.string(), z.any()).optional(),
|
|
105
|
-
});
|
|
106
|
-
export const ResourceCreateOutputSchema = ResourceSchema;
|
|
107
|
-
|
|
108
|
-
export const ResourceUpdateInputSchema = z.object({
|
|
109
|
-
name: z.string().describe("Resource type name (e.g., 'Page', 'GoogleDrive')"),
|
|
110
|
-
uri: z.string().url().describe("URI of the resource to update"),
|
|
111
|
-
resourceName: z.string().optional(),
|
|
112
|
-
title: z.string().optional(),
|
|
113
|
-
description: z.string().optional(),
|
|
114
|
-
content: z
|
|
115
|
-
.object({
|
|
116
|
-
data: z.string(),
|
|
117
|
-
type: z.enum(["text", "blob"]),
|
|
118
|
-
mimeType: z.string().optional(),
|
|
119
|
-
})
|
|
120
|
-
.optional(),
|
|
121
|
-
metadata: z.record(z.string(), z.any()).optional(),
|
|
122
|
-
});
|
|
123
|
-
export const ResourceUpdateOutputSchema = ResourceSchema;
|
|
124
|
-
|
|
125
|
-
export const ResourceDeleteInputSchema = z.object({
|
|
126
|
-
name: z.string().describe("Resource type name (e.g., 'Page', 'GoogleDrive')"),
|
|
127
|
-
uri: z.string().url().describe("URI of the resource to delete"),
|
|
128
|
-
force: z.boolean().optional(),
|
|
129
|
-
});
|
|
130
|
-
export const ResourceDeleteOutputSchema = z.object({
|
|
131
|
-
deletedUri: z.string().url(),
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
export const ResourcesListInputSchema = z.object({});
|
|
135
|
-
export const ResourcesListOutputSchema = z.object({
|
|
136
|
-
resources: z.array(
|
|
137
|
-
z.object({
|
|
138
|
-
name: z.string(),
|
|
139
|
-
icon: z.string(),
|
|
140
|
-
title: z.string(),
|
|
141
|
-
description: z.string(),
|
|
142
|
-
hasCreate: z.boolean().optional(),
|
|
143
|
-
hasUpdate: z.boolean().optional(),
|
|
144
|
-
hasDelete: z.boolean().optional(),
|
|
145
|
-
}),
|
|
146
|
-
),
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// Export Types
|
|
150
|
-
export type Resource = z.infer<typeof ResourceCreateOutputSchema>;
|
|
151
|
-
export type ResourcesReadInput = z.infer<typeof ResourcesReadInputSchema>;
|
|
152
|
-
export type ResourcesReadOutput = z.infer<typeof ResourcesReadOutputSchema>;
|
|
153
|
-
export type ResourcesSearchInput = z.infer<typeof ResourceSearchInputSchema>;
|
|
154
|
-
export type ResourcesSearchOutput = z.infer<typeof ResourceSearchOutputSchema>;
|
|
155
|
-
export type ResourceCreateInput = z.infer<typeof ResourceCreateInputSchema>;
|
|
156
|
-
export type ResourceCreateOutput = z.infer<typeof ResourceCreateOutputSchema>;
|
|
157
|
-
export type ResourceUpdateInput = z.infer<typeof ResourceUpdateInputSchema>;
|
|
158
|
-
export type ResourceUpdateOutput = z.infer<typeof ResourceUpdateOutputSchema>;
|
|
159
|
-
export type ResourceDeleteInput = z.infer<typeof ResourceDeleteInputSchema>;
|
|
160
|
-
export type ResourceDeleteOutput = z.infer<typeof ResourceDeleteOutputSchema>;
|
|
161
|
-
export type ResourcesListInput = z.infer<typeof ResourcesListInputSchema>;
|
|
162
|
-
export type ResourcesListOutput = z.infer<typeof ResourcesListOutputSchema>;
|
|
163
|
-
|
|
164
|
-
export const mimeType = (filePathOrExtension: string) => {
|
|
165
|
-
const ext = extractExtension(filePathOrExtension);
|
|
166
|
-
if (!ext) return "text/plain";
|
|
167
|
-
return EXTENSION_TO_MIME.get(ext) ?? "text/plain";
|
|
168
|
-
};
|
package/src/views.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
const installBehavior = z.enum(["none", "open", "autoPin"]);
|
|
4
|
-
|
|
5
|
-
// New, richer schema with backward-compat fields kept optional
|
|
6
|
-
export const ViewsListOutputSchema = z.object({
|
|
7
|
-
views: z.array(
|
|
8
|
-
z.object({
|
|
9
|
-
id: z.string().optional(),
|
|
10
|
-
name: z.string().optional(),
|
|
11
|
-
title: z.string(),
|
|
12
|
-
description: z.string().optional(),
|
|
13
|
-
icon: z.string(),
|
|
14
|
-
url: z.string().optional(),
|
|
15
|
-
// New acceptance rules
|
|
16
|
-
mimeTypePattern: z.string().optional(),
|
|
17
|
-
resourceName: z.string().optional(),
|
|
18
|
-
// Legacy/compat fields
|
|
19
|
-
tools: z.array(z.string()).optional().default([]),
|
|
20
|
-
prompt: z.string().optional(),
|
|
21
|
-
installBehavior: installBehavior.optional(),
|
|
22
|
-
}),
|
|
23
|
-
),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export type ViewsListOutput = z.infer<typeof ViewsListOutputSchema>;
|
package/src/well-known.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const Hosts = {
|
|
2
|
-
API: "api.decocms.com",
|
|
3
|
-
WEB_APP: "admin.decocms.com",
|
|
4
|
-
APPS: "deco.page",
|
|
5
|
-
LOCALHOST: "localhost:3000",
|
|
6
|
-
API_LEGACY: "api.deco.chat",
|
|
7
|
-
WEB_APP_LEGACY: "deco.chat",
|
|
8
|
-
} as const;
|
|
9
|
-
|
|
10
|
-
export const WELL_KNOWN_API_HOSTNAMES = [
|
|
11
|
-
Hosts.API,
|
|
12
|
-
Hosts.API_LEGACY,
|
|
13
|
-
Hosts.LOCALHOST.split(":")[0],
|
|
14
|
-
] as const;
|
|
15
|
-
|
|
16
|
-
export const WELL_KNOWN_ORIGINS = [
|
|
17
|
-
`http://${Hosts.LOCALHOST}`,
|
|
18
|
-
`https://${Hosts.WEB_APP}`,
|
|
19
|
-
`https://${Hosts.WEB_APP_LEGACY}`,
|
|
20
|
-
] as const;
|