@dxos/plugin-space 0.8.1-main.ba2dec9 → 0.8.1-staging.391c573
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/dist/lib/browser/{chunk-PCEP3KQY.mjs → chunk-OWVFWTX4.mjs} +6 -4
- package/dist/lib/browser/chunk-OWVFWTX4.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +8 -2
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-GPNAQ2SG.mjs → intent-resolver-7PY5WDYC.mjs} +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-root-4CCSD7TZ.mjs → react-root-EP4XP4IK.mjs} +2 -2
- package/dist/lib/browser/{react-surface-FKMRI3WV.mjs → react-surface-VNNI5POA.mjs} +2 -2
- package/dist/lib/browser/schema-tools-6J5ZEDBC.mjs +123 -0
- package/dist/lib/browser/schema-tools-6J5ZEDBC.mjs.map +7 -0
- package/dist/lib/node/{chunk-QE4GVR6C.cjs → chunk-53J7HLYX.cjs} +12 -9
- package/dist/lib/node/chunk-53J7HLYX.cjs.map +7 -0
- package/dist/lib/node/index.cjs +49 -44
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-ICHHI6I6.cjs → intent-resolver-QEIKJ5FR.cjs} +13 -13
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-root-TCBTUOOJ.cjs → react-root-OW5NTN2U.cjs} +6 -6
- package/dist/lib/node/{react-surface-JSCCIZS5.cjs → react-surface-JTIQUBHB.cjs} +38 -38
- package/dist/lib/node/schema-tools-OZS4OC6X.cjs +146 -0
- package/dist/lib/node/schema-tools-OZS4OC6X.cjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HJCEJNW3.mjs → chunk-FDVNOFE3.mjs} +6 -4
- package/dist/lib/node-esm/chunk-FDVNOFE3.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +8 -2
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-VR42K5GE.mjs → intent-resolver-7EYVRN3R.mjs} +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-root-THJBSTQS.mjs → react-root-RCKGZSZB.mjs} +2 -2
- package/dist/lib/node-esm/{react-surface-Z3BBQ5HX.mjs → react-surface-WKKBE5V4.mjs} +2 -2
- package/dist/lib/node-esm/schema-tools-KJVXGDBO.mjs +125 -0
- package/dist/lib/node-esm/schema-tools-KJVXGDBO.mjs.map +7 -0
- package/dist/types/src/SpacePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/schema-tool.test.d.ts +2 -0
- package/dist/types/src/capabilities/schema-tool.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/schema-tools.d.ts +13 -0
- package/dist/types/src/capabilities/schema-tools.d.ts.map +1 -0
- package/package.json +42 -39
- package/src/SpacePlugin.tsx +6 -0
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/schema-tool.test.ts +45 -0
- package/src/capabilities/schema-tools.ts +124 -0
- package/dist/lib/browser/chunk-PCEP3KQY.mjs.map +0 -7
- package/dist/lib/node/chunk-QE4GVR6C.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-HJCEJNW3.mjs.map +0 -7
- /package/dist/lib/browser/{intent-resolver-GPNAQ2SG.mjs.map → intent-resolver-7PY5WDYC.mjs.map} +0 -0
- /package/dist/lib/browser/{react-root-4CCSD7TZ.mjs.map → react-root-EP4XP4IK.mjs.map} +0 -0
- /package/dist/lib/browser/{react-surface-FKMRI3WV.mjs.map → react-surface-VNNI5POA.mjs.map} +0 -0
- /package/dist/lib/node/{intent-resolver-ICHHI6I6.cjs.map → intent-resolver-QEIKJ5FR.cjs.map} +0 -0
- /package/dist/lib/node/{react-root-TCBTUOOJ.cjs.map → react-root-OW5NTN2U.cjs.map} +0 -0
- /package/dist/lib/node/{react-surface-JSCCIZS5.cjs.map → react-surface-JTIQUBHB.cjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-resolver-VR42K5GE.mjs.map → intent-resolver-7EYVRN3R.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-root-THJBSTQS.mjs.map → react-root-RCKGZSZB.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-surface-Z3BBQ5HX.mjs.map → react-surface-WKKBE5V4.mjs.map} +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/plugins/plugin-space/src/capabilities/schema-tools.ts
|
|
4
|
+
import { DescriptionAnnotationId, ExamplesAnnotationId, TitleAnnotationId } from "effect/SchemaAST";
|
|
5
|
+
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
6
|
+
import { defineTool, ToolResult } from "@dxos/artifact";
|
|
7
|
+
import { FormatEnum, FormatEnums, S, SelectOptionSchema, GeoPoint, toJsonSchema } from "@dxos/echo-schema";
|
|
8
|
+
import { invariant } from "@dxos/invariant";
|
|
9
|
+
import { hues } from "@dxos/react-ui-theme";
|
|
10
|
+
import { echoSchemaFromPropertyDefinitions } from "@dxos/schema";
|
|
11
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/capabilities/schema-tools.ts";
|
|
12
|
+
var TypeNameSchema = S.String.pipe(S.pattern(/^\w+\.\w{2,}\/[\w/]+$/i), S.annotations({
|
|
13
|
+
[TitleAnnotationId]: "TypeName",
|
|
14
|
+
[DescriptionAnnotationId]: "Domain-style type name path. Dashes are not allowed. Use camel case for the final component of the type name.",
|
|
15
|
+
[ExamplesAnnotationId]: [
|
|
16
|
+
"example.com/type/Document",
|
|
17
|
+
"example.com/type/FlightList"
|
|
18
|
+
]
|
|
19
|
+
}));
|
|
20
|
+
var formatDescription = `The format of the property. Additional information:
|
|
21
|
+
${FormatEnum.GeoPoint}: ${JSON.stringify(toJsonSchema(GeoPoint))}
|
|
22
|
+
This tuple is GeoJSON. You must specify \`${FormatEnum.GeoPoint}\` as [Longitude, Latitude]`;
|
|
23
|
+
var PropertyDefinitionSchema = S.Struct({
|
|
24
|
+
name: S.String.annotations({
|
|
25
|
+
[DescriptionAnnotationId]: "The name of the property."
|
|
26
|
+
}),
|
|
27
|
+
format: S.Union(...FormatEnums.map((format) => S.Literal(format))).annotations({
|
|
28
|
+
[DescriptionAnnotationId]: formatDescription
|
|
29
|
+
}),
|
|
30
|
+
config: S.optional(S.Struct({
|
|
31
|
+
options: S.optional(S.Array(SelectOptionSchema).annotations({
|
|
32
|
+
description: `Options for SingleSelect/MultiSelect formats. Available colors: ${hues.join(", ")}`
|
|
33
|
+
}).pipe(S.mutable))
|
|
34
|
+
}))
|
|
35
|
+
}).pipe(S.mutable);
|
|
36
|
+
var SYSTEM_NAMESPACE = "dxos.org/echo/schema";
|
|
37
|
+
var schema_tools_default = () => contributes(Capabilities.Tools, [
|
|
38
|
+
defineTool(SYSTEM_NAMESPACE, {
|
|
39
|
+
name: "list",
|
|
40
|
+
description: "List registered schemas in the space.",
|
|
41
|
+
caption: "Listing registered schemas...",
|
|
42
|
+
schema: S.Struct({}),
|
|
43
|
+
execute: async (_input, { extensions }) => {
|
|
44
|
+
invariant(extensions?.space, "No space.", {
|
|
45
|
+
F: __dxlog_file,
|
|
46
|
+
L: 67,
|
|
47
|
+
S: void 0,
|
|
48
|
+
A: [
|
|
49
|
+
"extensions?.space",
|
|
50
|
+
"'No space.'"
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
const space = extensions.space;
|
|
54
|
+
const schemas = await space.db.schemaRegistry.query({}).run();
|
|
55
|
+
return ToolResult.Success(schemas.map((schema) => ({
|
|
56
|
+
typename: schema.typename,
|
|
57
|
+
version: schema.version
|
|
58
|
+
})));
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
defineTool(SYSTEM_NAMESPACE, {
|
|
62
|
+
name: "get",
|
|
63
|
+
description: "Get a specific schema by its typename.",
|
|
64
|
+
caption: "Getting schema...",
|
|
65
|
+
schema: S.Struct({
|
|
66
|
+
typename: S.String.annotations({
|
|
67
|
+
description: "The fully qualified typename of the schema."
|
|
68
|
+
})
|
|
69
|
+
}),
|
|
70
|
+
execute: async ({ typename }, { extensions }) => {
|
|
71
|
+
invariant(extensions?.space, "No space.", {
|
|
72
|
+
F: __dxlog_file,
|
|
73
|
+
L: 89,
|
|
74
|
+
S: void 0,
|
|
75
|
+
A: [
|
|
76
|
+
"extensions?.space",
|
|
77
|
+
"'No space.'"
|
|
78
|
+
]
|
|
79
|
+
});
|
|
80
|
+
const space = extensions.space;
|
|
81
|
+
const schema = await space.db.schemaRegistry.query({
|
|
82
|
+
typename
|
|
83
|
+
}).firstOrUndefined();
|
|
84
|
+
if (!schema) {
|
|
85
|
+
return ToolResult.Error(`Schema not found: ${typename}`);
|
|
86
|
+
}
|
|
87
|
+
return ToolResult.Success(schema);
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
defineTool(SYSTEM_NAMESPACE, {
|
|
91
|
+
name: "create",
|
|
92
|
+
description: "Create a new schema with the provided definition.",
|
|
93
|
+
caption: "Creating schema...",
|
|
94
|
+
schema: S.Struct({
|
|
95
|
+
typename: TypeNameSchema.annotations({
|
|
96
|
+
description: 'The fully qualified schema typename. Must start with a domain, and then one or more path components (e.g., "example.com/type/TypeName").'
|
|
97
|
+
}),
|
|
98
|
+
properties: S.Array(PropertyDefinitionSchema).pipe(S.annotations({
|
|
99
|
+
description: "Array of property definitions for the schema."
|
|
100
|
+
}), S.mutable)
|
|
101
|
+
}),
|
|
102
|
+
execute: async ({ typename, properties }, { extensions }) => {
|
|
103
|
+
invariant(extensions?.space, "No space.", {
|
|
104
|
+
F: __dxlog_file,
|
|
105
|
+
L: 115,
|
|
106
|
+
S: void 0,
|
|
107
|
+
A: [
|
|
108
|
+
"extensions?.space",
|
|
109
|
+
"'No space.'"
|
|
110
|
+
]
|
|
111
|
+
});
|
|
112
|
+
const space = extensions.space;
|
|
113
|
+
const schema = echoSchemaFromPropertyDefinitions(typename, properties);
|
|
114
|
+
const [registeredSchema] = await space.db.schemaRegistry.register([
|
|
115
|
+
schema
|
|
116
|
+
]);
|
|
117
|
+
return ToolResult.Success(registeredSchema);
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
]);
|
|
121
|
+
export {
|
|
122
|
+
TypeNameSchema,
|
|
123
|
+
schema_tools_default as default
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=schema-tools-KJVXGDBO.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/schema-tools.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { DescriptionAnnotationId, ExamplesAnnotationId, TitleAnnotationId } from 'effect/SchemaAST';\n\nimport { Capabilities, contributes, type PromiseIntentDispatcher } from '@dxos/app-framework';\nimport { defineTool, ToolResult } from '@dxos/artifact';\nimport { type Space } from '@dxos/client/echo';\nimport { FormatEnum, FormatEnums, S, SelectOptionSchema, GeoPoint, toJsonSchema } from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { hues } from '@dxos/react-ui-theme';\nimport { echoSchemaFromPropertyDefinitions } from '@dxos/schema';\n\n// TODO(burdon): Factor out.\ndeclare global {\n interface ToolContextExtensions {\n space?: Space;\n dispatch?: PromiseIntentDispatcher;\n }\n}\n\n// TODO(ZaymonFC): Move this somewhere common.\nexport const TypeNameSchema = S.String.pipe(\n S.pattern(/^\\w+\\.\\w{2,}\\/[\\w/]+$/i),\n S.annotations({\n [TitleAnnotationId]: 'TypeName',\n [DescriptionAnnotationId]:\n 'Domain-style type name path. Dashes are not allowed. Use camel case for the final component of the type name.',\n [ExamplesAnnotationId]: ['example.com/type/Document', 'example.com/type/FlightList'],\n }),\n);\n\nconst formatDescription = `The format of the property. Additional information:\n ${FormatEnum.GeoPoint}: ${JSON.stringify(toJsonSchema(GeoPoint))}\n This tuple is GeoJSON. You must specify \\`${FormatEnum.GeoPoint}\\` as [Longitude, Latitude]`;\n\n// TODO(ZaymonFC): All properties are default optional, but maybe we should allow for required properties.\nconst PropertyDefinitionSchema = S.Struct({\n name: S.String.annotations({ [DescriptionAnnotationId]: 'The name of the property.' }),\n format: S.Union(...FormatEnums.map((format) => S.Literal(format))).annotations({\n [DescriptionAnnotationId]: formatDescription,\n }),\n config: S.optional(\n S.Struct({\n options: S.optional(\n S.Array(SelectOptionSchema)\n .annotations({\n description: `Options for SingleSelect/MultiSelect formats. Available colors: ${hues.join(', ')}`,\n })\n .pipe(S.mutable),\n ),\n }),\n ),\n}).pipe(S.mutable);\n\nconst SYSTEM_NAMESPACE = 'dxos.org/echo/schema';\n\nexport default () =>\n contributes(Capabilities.Tools, [\n defineTool(SYSTEM_NAMESPACE, {\n name: 'list',\n description: 'List registered schemas in the space.',\n caption: 'Listing registered schemas...',\n schema: S.Struct({}),\n execute: async (_input, { extensions }) => {\n invariant(extensions?.space, 'No space.');\n const space = extensions.space;\n\n const schemas = await space.db.schemaRegistry.query({}).run();\n return ToolResult.Success(\n schemas.map((schema) => ({\n typename: schema.typename,\n version: schema.version,\n })),\n );\n },\n }),\n defineTool(SYSTEM_NAMESPACE, {\n name: 'get',\n description: 'Get a specific schema by its typename.',\n caption: 'Getting schema...',\n schema: S.Struct({\n typename: S.String.annotations({\n description: 'The fully qualified typename of the schema.',\n }),\n }),\n execute: async ({ typename }, { extensions }) => {\n invariant(extensions?.space, 'No space.');\n const space = extensions.space;\n\n const schema = await space.db.schemaRegistry.query({ typename }).firstOrUndefined();\n if (!schema) {\n return ToolResult.Error(`Schema not found: ${typename}`);\n }\n\n return ToolResult.Success(schema);\n },\n }),\n defineTool(SYSTEM_NAMESPACE, {\n name: 'create',\n description: 'Create a new schema with the provided definition.',\n caption: 'Creating schema...',\n schema: S.Struct({\n typename: TypeNameSchema.annotations({\n description:\n 'The fully qualified schema typename. Must start with a domain, and then one or more path components (e.g., \"example.com/type/TypeName\").',\n }),\n properties: S.Array(PropertyDefinitionSchema).pipe(\n S.annotations({ description: 'Array of property definitions for the schema.' }),\n S.mutable,\n ),\n }),\n execute: async ({ typename, properties }, { extensions }) => {\n invariant(extensions?.space, 'No space.');\n const space = extensions.space;\n\n const schema = echoSchemaFromPropertyDefinitions(typename, properties);\n const [registeredSchema] = await space.db.schemaRegistry.register([schema]);\n\n return ToolResult.Success(registeredSchema);\n },\n }),\n ]);\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["DescriptionAnnotationId", "ExamplesAnnotationId", "TitleAnnotationId", "Capabilities", "contributes", "defineTool", "ToolResult", "FormatEnum", "FormatEnums", "S", "SelectOptionSchema", "GeoPoint", "toJsonSchema", "invariant", "hues", "echoSchemaFromPropertyDefinitions", "TypeNameSchema", "String", "pipe", "pattern", "annotations", "formatDescription", "JSON", "stringify", "PropertyDefinitionSchema", "Struct", "name", "format", "Union", "map", "Literal", "config", "optional", "options", "Array", "description", "join", "mutable", "SYSTEM_NAMESPACE", "Tools", "caption", "schema", "execute", "_input", "extensions", "space", "schemas", "db", "schemaRegistry", "query", "run", "Success", "typename", "version", "firstOrUndefined", "Error", "properties", "registeredSchema", "register"]
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpacePlugin.d.ts","sourceRoot":"","sources":["../../../src/SpacePlugin.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SpacePlugin.d.ts","sourceRoot":"","sources":["../../../src/SpacePlugin.tsx"],"names":[],"mappings":"AAyCA,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,WAAW,wDAIrB,kBAAkB,yCA6HpB,CAAC"}
|
|
@@ -190,6 +190,7 @@ export declare const ReactSurface: (props?: {
|
|
|
190
190
|
createInvitationUrl: (invitationCode: string) => string;
|
|
191
191
|
} | undefined) => Promise<() => Promise<import("@dxos/app-framework").Capability<import("@dxos/app-framework").Capabilities.ReactSurface> | import("@dxos/app-framework").AnyCapability[]>>;
|
|
192
192
|
export declare const Schema: (props?: import("@dxos/app-framework").PluginsContext | undefined) => Promise<() => Promise<import("@dxos/app-framework").Capability<null> | import("@dxos/app-framework").AnyCapability[]>>;
|
|
193
|
+
export declare const Tools: (props?: unknown) => Promise<() => Promise<import("@dxos/app-framework").Capability<import("@dxos/artifact").Tool[]> | import("@dxos/app-framework").AnyCapability[]>>;
|
|
193
194
|
export declare const SpaceSettings: (props?: unknown) => Promise<() => Promise<import("@dxos/app-framework").Capability<import("@dxos/app-framework").Capabilities.Settings> | import("@dxos/app-framework").AnyCapability[]>>;
|
|
194
195
|
export declare const SpaceState: (props?: import("@dxos/app-framework").PluginsContext | undefined) => Promise<() => Promise<import("@dxos/app-framework").Capability<import("@dxos/util").DeepReadonly<import("../types").PluginState>> | import("@dxos/app-framework").AnyCapability[]>>;
|
|
195
196
|
export declare const SpacesReady: (props?: import("@dxos/app-framework").PluginsContext | undefined) => Promise<() => Promise<import("@dxos/app-framework").Capability<null> | import("@dxos/app-framework").AnyCapability[]>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,eAAe;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,eAAe;;qBAaijF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAqF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAwF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAqF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAwF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAqF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAwF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAqF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAwF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAqF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAwF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAqF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAwF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAqF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAwF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAqF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAwF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAqF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAwF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAqF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAwF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;;;qBAAqF,YAAY;sBAAsC,iBAAiB;uBAAgD,iBAAiB;sBAAgD,iBAAiB;;2BAAkE,iBAAiB;qFAb5yU,CAAC;AACzE,eAAO,MAAM,kBAAkB,wOAA+C,CAAC;AAC/E,eAAO,MAAM,eAAe,8LAA2C,CAAC;AACxE,eAAO,MAAM,cAAc;;;;6LAA0C,CAAC;AACtE,eAAO,MAAM,SAAS;;;qDAAqC,CAAC;AAC5D,eAAO,MAAM,YAAY;;2LAAwC,CAAC;AAClE,eAAO,MAAM,MAAM,8LAAiC,CAAC;AACrD,eAAO,MAAM,KAAK,wKAAuC,CAAC;AAC1D,eAAO,MAAM,aAAa,4LAAmC,CAAC;AAC9D,eAAO,MAAM,UAAU,2PAAgC,CAAC;AACxD,eAAO,MAAM,WAAW,8LAAuC,CAAC;AAEhE,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-tool.test.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/schema-tool.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
2
|
+
import { type Space } from '@dxos/client/echo';
|
|
3
|
+
import { S } from '@dxos/echo-schema';
|
|
4
|
+
declare global {
|
|
5
|
+
interface ToolContextExtensions {
|
|
6
|
+
space?: Space;
|
|
7
|
+
dispatch?: PromiseIntentDispatcher;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare const TypeNameSchema: S.refine<string, typeof S.String>;
|
|
11
|
+
declare const _default: () => import("@dxos/app-framework").Capability<import("@dxos/artifact").Tool[]>;
|
|
12
|
+
export default _default;
|
|
13
|
+
//# sourceMappingURL=schema-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-tools.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/schema-tools.ts"],"names":[],"mappings":"AAMA,OAAO,EAA6B,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9F,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAA2B,CAAC,EAA8C,MAAM,mBAAmB,CAAC;AAM3G,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,QAAQ,CAAC,EAAE,uBAAuB,CAAC;KACpC;CACF;AAGD,eAAO,MAAM,cAAc,mCAQ1B,CAAC;;AA2BF,wBAiEK"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-space",
|
|
3
|
-
"version": "0.8.1-
|
|
3
|
+
"version": "0.8.1-staging.391c573",
|
|
4
4
|
"description": "DXOS Surface plugin for DXOS ECHO Spaces",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -40,38 +40,41 @@
|
|
|
40
40
|
"lodash.get": "^4.4.2",
|
|
41
41
|
"react-drag-drop-files": "^2.3.8",
|
|
42
42
|
"react-is": "~18.2.0",
|
|
43
|
-
"@dxos/app-framework": "0.8.1-
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/echo-
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/log": "0.8.1-
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/plugin-attention": "0.8.1-
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/plugin-
|
|
60
|
-
"@dxos/plugin-
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/plugin-
|
|
63
|
-
"@dxos/plugin-
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/react-
|
|
66
|
-
"@dxos/react-ui-
|
|
67
|
-
"@dxos/react-ui-
|
|
68
|
-
"@dxos/react-ui-searchlist": "0.8.1-
|
|
69
|
-
"@dxos/react-ui-
|
|
70
|
-
"@dxos/react-ui-
|
|
71
|
-
"@dxos/react-ui-stack": "0.8.1-
|
|
72
|
-
"@dxos/react-ui-
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
43
|
+
"@dxos/app-framework": "0.8.1-staging.391c573",
|
|
44
|
+
"@dxos/artifact": "0.8.1-staging.391c573",
|
|
45
|
+
"@dxos/async": "0.8.1-staging.391c573",
|
|
46
|
+
"@dxos/client": "0.8.1-staging.391c573",
|
|
47
|
+
"@dxos/display-name": "0.8.1-staging.391c573",
|
|
48
|
+
"@dxos/context": "0.8.1-staging.391c573",
|
|
49
|
+
"@dxos/automerge": "0.8.1-staging.391c573",
|
|
50
|
+
"@dxos/echo-schema": "0.8.1-staging.391c573",
|
|
51
|
+
"@dxos/echo-signals": "0.8.1-staging.391c573",
|
|
52
|
+
"@dxos/invariant": "0.8.1-staging.391c573",
|
|
53
|
+
"@dxos/keys": "0.8.1-staging.391c573",
|
|
54
|
+
"@dxos/live-object": "0.8.1-staging.391c573",
|
|
55
|
+
"@dxos/log": "0.8.1-staging.391c573",
|
|
56
|
+
"@dxos/local-storage": "0.8.1-staging.391c573",
|
|
57
|
+
"@dxos/plugin-attention": "0.8.1-staging.391c573",
|
|
58
|
+
"@dxos/migrations": "0.8.1-staging.391c573",
|
|
59
|
+
"@dxos/plugin-client": "0.8.1-staging.391c573",
|
|
60
|
+
"@dxos/plugin-observability": "0.8.1-staging.391c573",
|
|
61
|
+
"@dxos/plugin-graph": "0.8.1-staging.391c573",
|
|
62
|
+
"@dxos/plugin-status-bar": "0.8.1-staging.391c573",
|
|
63
|
+
"@dxos/plugin-deck": "0.8.1-staging.391c573",
|
|
64
|
+
"@dxos/protocols": "0.8.1-staging.391c573",
|
|
65
|
+
"@dxos/react-client": "0.8.1-staging.391c573",
|
|
66
|
+
"@dxos/react-ui-attention": "0.8.1-staging.391c573",
|
|
67
|
+
"@dxos/react-ui-editor": "0.8.1-staging.391c573",
|
|
68
|
+
"@dxos/react-ui-searchlist": "0.8.1-staging.391c573",
|
|
69
|
+
"@dxos/react-ui-pickers": "0.8.1-staging.391c573",
|
|
70
|
+
"@dxos/react-ui-form": "0.8.1-staging.391c573",
|
|
71
|
+
"@dxos/react-ui-stack": "0.8.1-staging.391c573",
|
|
72
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.1-staging.391c573",
|
|
73
|
+
"@dxos/react-ui-tabs": "0.8.1-staging.391c573",
|
|
74
|
+
"@dxos/schema": "0.8.1-staging.391c573",
|
|
75
|
+
"@dxos/react-ui-theme": "0.8.1-staging.391c573",
|
|
76
|
+
"@dxos/util": "0.8.1-staging.391c573",
|
|
77
|
+
"@dxos/shell": "0.8.1-staging.391c573"
|
|
75
78
|
},
|
|
76
79
|
"devDependencies": {
|
|
77
80
|
"@babel/core": "^7.18.13",
|
|
@@ -82,17 +85,17 @@
|
|
|
82
85
|
"react": "~18.2.0",
|
|
83
86
|
"react-dom": "~18.2.0",
|
|
84
87
|
"vite": "5.4.7",
|
|
85
|
-
"@dxos/random": "0.8.1-
|
|
86
|
-
"@dxos/
|
|
87
|
-
"@dxos/react-ui
|
|
88
|
-
"@dxos/
|
|
88
|
+
"@dxos/random": "0.8.1-staging.391c573",
|
|
89
|
+
"@dxos/storybook-utils": "0.8.1-staging.391c573",
|
|
90
|
+
"@dxos/react-ui": "0.8.1-staging.391c573",
|
|
91
|
+
"@dxos/react-ui-theme": "0.8.1-staging.391c573"
|
|
89
92
|
},
|
|
90
93
|
"peerDependencies": {
|
|
91
94
|
"@phosphor-icons/react": "^2.1.5",
|
|
92
95
|
"react": "~18.2.0",
|
|
93
96
|
"react-dom": "~18.2.0",
|
|
94
|
-
"@dxos/react-ui": "0.8.1-
|
|
95
|
-
"@dxos/react-ui-theme": "0.8.1-
|
|
97
|
+
"@dxos/react-ui": "0.8.1-staging.391c573",
|
|
98
|
+
"@dxos/react-ui-theme": "0.8.1-staging.391c573"
|
|
96
99
|
},
|
|
97
100
|
"publishConfig": {
|
|
98
101
|
"access": "public"
|
package/src/SpacePlugin.tsx
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
ReactRoot,
|
|
29
29
|
ReactSurface,
|
|
30
30
|
Schema,
|
|
31
|
+
Tools,
|
|
31
32
|
SpaceCapabilities,
|
|
32
33
|
SpaceSettings,
|
|
33
34
|
SpacesReady,
|
|
@@ -178,5 +179,10 @@ export const SpacePlugin = ({
|
|
|
178
179
|
),
|
|
179
180
|
activate: SpacesReady,
|
|
180
181
|
}),
|
|
182
|
+
defineModule({
|
|
183
|
+
id: `${meta.id}/module/tools`,
|
|
184
|
+
activatesOn: Events.SetupArtifactDefinition,
|
|
185
|
+
activate: Tools,
|
|
186
|
+
}),
|
|
181
187
|
]);
|
|
182
188
|
};
|
|
@@ -11,6 +11,7 @@ export const IntentResolver = lazy(() => import('./intent-resolver'));
|
|
|
11
11
|
export const ReactRoot = lazy(() => import('./react-root'));
|
|
12
12
|
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
13
13
|
export const Schema = lazy(() => import('./schema'));
|
|
14
|
+
export const Tools = lazy(() => import('./schema-tools'));
|
|
14
15
|
export const SpaceSettings = lazy(() => import('./settings'));
|
|
15
16
|
export const SpaceState = lazy(() => import('./state'));
|
|
16
17
|
export const SpacesReady = lazy(() => import('./spaces-ready'));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, it, expect } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { S } from '@dxos/echo-schema';
|
|
8
|
+
|
|
9
|
+
import { TypeNameSchema } from './schema-tools';
|
|
10
|
+
|
|
11
|
+
describe('TypeNameSchema format', () => {
|
|
12
|
+
const valid = [
|
|
13
|
+
'example.com/usCities',
|
|
14
|
+
'dxos.org/Contact',
|
|
15
|
+
'dxos.org/Table',
|
|
16
|
+
'dxos.org/Table/Contact',
|
|
17
|
+
'dxos.org/PluginName/TypeName',
|
|
18
|
+
// Case variations
|
|
19
|
+
'DXOS.org/Table',
|
|
20
|
+
'dxos.ORG/table',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const invalid = [
|
|
24
|
+
'http://dxos.org/Table', // No protocol allowed
|
|
25
|
+
'dxos.org/', // Must have type path
|
|
26
|
+
// TODO(dmaretskyi): Decide if we want to ban numbers.
|
|
27
|
+
// 'dxos.org/1Type', // Path segments must start with letter
|
|
28
|
+
'dxos.org/Type!', // Invalid character
|
|
29
|
+
'.org/Type', // Must have domain
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const validate = S.validateSync(TypeNameSchema);
|
|
33
|
+
|
|
34
|
+
valid.forEach((typename) => {
|
|
35
|
+
it(`should accept valid typename: ${typename}`, () => {
|
|
36
|
+
expect(() => validate(typename)).not.toThrow();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
invalid.forEach((typename) => {
|
|
41
|
+
it(`should reject invalid typename: ${typename}`, () => {
|
|
42
|
+
expect(() => validate(typename)).toThrow();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { DescriptionAnnotationId, ExamplesAnnotationId, TitleAnnotationId } from 'effect/SchemaAST';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, contributes, type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
+
import { defineTool, ToolResult } from '@dxos/artifact';
|
|
9
|
+
import { type Space } from '@dxos/client/echo';
|
|
10
|
+
import { FormatEnum, FormatEnums, S, SelectOptionSchema, GeoPoint, toJsonSchema } from '@dxos/echo-schema';
|
|
11
|
+
import { invariant } from '@dxos/invariant';
|
|
12
|
+
import { hues } from '@dxos/react-ui-theme';
|
|
13
|
+
import { echoSchemaFromPropertyDefinitions } from '@dxos/schema';
|
|
14
|
+
|
|
15
|
+
// TODO(burdon): Factor out.
|
|
16
|
+
declare global {
|
|
17
|
+
interface ToolContextExtensions {
|
|
18
|
+
space?: Space;
|
|
19
|
+
dispatch?: PromiseIntentDispatcher;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// TODO(ZaymonFC): Move this somewhere common.
|
|
24
|
+
export const TypeNameSchema = S.String.pipe(
|
|
25
|
+
S.pattern(/^\w+\.\w{2,}\/[\w/]+$/i),
|
|
26
|
+
S.annotations({
|
|
27
|
+
[TitleAnnotationId]: 'TypeName',
|
|
28
|
+
[DescriptionAnnotationId]:
|
|
29
|
+
'Domain-style type name path. Dashes are not allowed. Use camel case for the final component of the type name.',
|
|
30
|
+
[ExamplesAnnotationId]: ['example.com/type/Document', 'example.com/type/FlightList'],
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const formatDescription = `The format of the property. Additional information:
|
|
35
|
+
${FormatEnum.GeoPoint}: ${JSON.stringify(toJsonSchema(GeoPoint))}
|
|
36
|
+
This tuple is GeoJSON. You must specify \`${FormatEnum.GeoPoint}\` as [Longitude, Latitude]`;
|
|
37
|
+
|
|
38
|
+
// TODO(ZaymonFC): All properties are default optional, but maybe we should allow for required properties.
|
|
39
|
+
const PropertyDefinitionSchema = S.Struct({
|
|
40
|
+
name: S.String.annotations({ [DescriptionAnnotationId]: 'The name of the property.' }),
|
|
41
|
+
format: S.Union(...FormatEnums.map((format) => S.Literal(format))).annotations({
|
|
42
|
+
[DescriptionAnnotationId]: formatDescription,
|
|
43
|
+
}),
|
|
44
|
+
config: S.optional(
|
|
45
|
+
S.Struct({
|
|
46
|
+
options: S.optional(
|
|
47
|
+
S.Array(SelectOptionSchema)
|
|
48
|
+
.annotations({
|
|
49
|
+
description: `Options for SingleSelect/MultiSelect formats. Available colors: ${hues.join(', ')}`,
|
|
50
|
+
})
|
|
51
|
+
.pipe(S.mutable),
|
|
52
|
+
),
|
|
53
|
+
}),
|
|
54
|
+
),
|
|
55
|
+
}).pipe(S.mutable);
|
|
56
|
+
|
|
57
|
+
const SYSTEM_NAMESPACE = 'dxos.org/echo/schema';
|
|
58
|
+
|
|
59
|
+
export default () =>
|
|
60
|
+
contributes(Capabilities.Tools, [
|
|
61
|
+
defineTool(SYSTEM_NAMESPACE, {
|
|
62
|
+
name: 'list',
|
|
63
|
+
description: 'List registered schemas in the space.',
|
|
64
|
+
caption: 'Listing registered schemas...',
|
|
65
|
+
schema: S.Struct({}),
|
|
66
|
+
execute: async (_input, { extensions }) => {
|
|
67
|
+
invariant(extensions?.space, 'No space.');
|
|
68
|
+
const space = extensions.space;
|
|
69
|
+
|
|
70
|
+
const schemas = await space.db.schemaRegistry.query({}).run();
|
|
71
|
+
return ToolResult.Success(
|
|
72
|
+
schemas.map((schema) => ({
|
|
73
|
+
typename: schema.typename,
|
|
74
|
+
version: schema.version,
|
|
75
|
+
})),
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
defineTool(SYSTEM_NAMESPACE, {
|
|
80
|
+
name: 'get',
|
|
81
|
+
description: 'Get a specific schema by its typename.',
|
|
82
|
+
caption: 'Getting schema...',
|
|
83
|
+
schema: S.Struct({
|
|
84
|
+
typename: S.String.annotations({
|
|
85
|
+
description: 'The fully qualified typename of the schema.',
|
|
86
|
+
}),
|
|
87
|
+
}),
|
|
88
|
+
execute: async ({ typename }, { extensions }) => {
|
|
89
|
+
invariant(extensions?.space, 'No space.');
|
|
90
|
+
const space = extensions.space;
|
|
91
|
+
|
|
92
|
+
const schema = await space.db.schemaRegistry.query({ typename }).firstOrUndefined();
|
|
93
|
+
if (!schema) {
|
|
94
|
+
return ToolResult.Error(`Schema not found: ${typename}`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return ToolResult.Success(schema);
|
|
98
|
+
},
|
|
99
|
+
}),
|
|
100
|
+
defineTool(SYSTEM_NAMESPACE, {
|
|
101
|
+
name: 'create',
|
|
102
|
+
description: 'Create a new schema with the provided definition.',
|
|
103
|
+
caption: 'Creating schema...',
|
|
104
|
+
schema: S.Struct({
|
|
105
|
+
typename: TypeNameSchema.annotations({
|
|
106
|
+
description:
|
|
107
|
+
'The fully qualified schema typename. Must start with a domain, and then one or more path components (e.g., "example.com/type/TypeName").',
|
|
108
|
+
}),
|
|
109
|
+
properties: S.Array(PropertyDefinitionSchema).pipe(
|
|
110
|
+
S.annotations({ description: 'Array of property definitions for the schema.' }),
|
|
111
|
+
S.mutable,
|
|
112
|
+
),
|
|
113
|
+
}),
|
|
114
|
+
execute: async ({ typename, properties }, { extensions }) => {
|
|
115
|
+
invariant(extensions?.space, 'No space.');
|
|
116
|
+
const space = extensions.space;
|
|
117
|
+
|
|
118
|
+
const schema = echoSchemaFromPropertyDefinitions(typename, properties);
|
|
119
|
+
const [registeredSchema] = await space.db.schemaRegistry.register([schema]);
|
|
120
|
+
|
|
121
|
+
return ToolResult.Success(registeredSchema);
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
]);
|