@plitzi/sdk-shared 0.30.19 → 0.31.1
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/CHANGELOG.md +22 -3
- package/dist/dataSource/hooks/index.d.ts +3 -3
- package/dist/dataSource/hooks/index.mjs +2 -2
- package/dist/dataSource/hooks/useRegisterSource.d.ts +9 -0
- package/dist/dataSource/hooks/useRegisterSource.mjs +25 -0
- package/dist/dataSource/index.d.ts +0 -1
- package/dist/dataSource/index.mjs +2 -2
- package/dist/devTools/utils/PlitziConsole.d.ts +2 -2
- package/dist/devTools/utils/PlitziConsole.mjs +1 -1
- package/dist/hooks/usePlitziServiceContext.d.ts +1 -2
- package/dist/index.mjs +2 -2
- package/dist/server/rsc/RscProvider.mjs +4 -4
- package/dist/types/AITypes.d.ts +80 -0
- package/dist/types/DataSourceTypes.d.ts +2 -16
- package/dist/types/McpTypes/McpAdapters.d.ts +455 -0
- package/dist/types/McpTypes/McpAdapters.mjs +0 -0
- package/dist/types/McpTypes/index.d.ts +96 -0
- package/dist/types/McpTypes/index.mjs +0 -0
- package/dist/types/SchemaTypes.d.ts +9 -8
- package/dist/types/StateTypes.d.ts +2 -2
- package/dist/types/StoreTypes.d.ts +14 -0
- package/dist/types/index.d.ts +1 -0
- package/eslint.config.mjs +2 -2
- package/package.json +42 -37
- package/dist/dataSource/DataSourceContext.d.ts +0 -3
- package/dist/dataSource/DataSourceContext.mjs +0 -5
- package/dist/dataSource/hooks/useDataSource.d.ts +0 -20
- package/dist/dataSource/hooks/useDataSource.mjs +0 -45
- package/dist/types/McpTypes.d.ts +0 -164
- /package/dist/types/{McpTypes.mjs → AITypes.mjs} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
# @plitzi/sdk-shared
|
|
2
2
|
|
|
3
|
+
## 0.31.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- v0.31.1
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @plitzi/nexus@0.31.1
|
|
10
|
+
|
|
11
|
+
## 0.31.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- v0.31.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @plitzi/nexus@0.31.0
|
|
21
|
+
|
|
3
22
|
## 0.30.19
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
6
25
|
|
|
7
26
|
- v0.30.19
|
|
8
27
|
- Updated dependencies
|
|
9
|
-
- @plitzi/
|
|
28
|
+
- @plitzi/nexus@0.30.19
|
|
10
29
|
|
|
11
30
|
## 0.30.18
|
|
12
31
|
|
|
@@ -14,7 +33,7 @@
|
|
|
14
33
|
|
|
15
34
|
- v0.30.18
|
|
16
35
|
- Updated dependencies
|
|
17
|
-
- @plitzi/
|
|
36
|
+
- @plitzi/nexus@0.30.18
|
|
18
37
|
|
|
19
38
|
## 0.30.17
|
|
20
39
|
|
|
@@ -22,7 +41,7 @@
|
|
|
22
41
|
|
|
23
42
|
- v0.31.0
|
|
24
43
|
- Updated dependencies
|
|
25
|
-
- @plitzi/
|
|
44
|
+
- @plitzi/nexus@0.30.17
|
|
26
45
|
|
|
27
46
|
## 0.30.16
|
|
28
47
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
export * from './
|
|
3
|
-
export {
|
|
1
|
+
import { default as useRegisterSource } from './useRegisterSource';
|
|
2
|
+
export * from './useRegisterSource';
|
|
3
|
+
export { useRegisterSource };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from "./
|
|
2
|
-
export { e as
|
|
1
|
+
import e from "./useRegisterSource.mjs";
|
|
2
|
+
export { e as useRegisterSource };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SourceMeta } from '../../types';
|
|
2
|
+
export type UseRegisterSourceProps = {
|
|
3
|
+
id?: string;
|
|
4
|
+
source: string;
|
|
5
|
+
name: string;
|
|
6
|
+
fields?: SourceMeta['fields'];
|
|
7
|
+
};
|
|
8
|
+
declare const useRegisterSource: ({ id, source, name, fields }: UseRegisterSourceProps) => void;
|
|
9
|
+
export default useRegisterSource;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { makeId as e } from "../../helpers/utils.mjs";
|
|
2
|
+
import { useEffect as t, useMemo as n } from "react";
|
|
3
|
+
import { omit as r } from "@plitzi/plitzi-ui/helpers";
|
|
4
|
+
import { createStoreHook as i } from "@plitzi/nexus/createStore";
|
|
5
|
+
//#region src/dataSource/hooks/useRegisterSource.ts
|
|
6
|
+
var a = ({ id: a = "", source: o, name: s, fields: c = [] }) => {
|
|
7
|
+
let { useStoreSetter: l } = i(), u = l(), d = n(() => `${a}_${e(8)}`, [a]);
|
|
8
|
+
t(() => (u(`sources.${d}`, {
|
|
9
|
+
id: d,
|
|
10
|
+
meta: {
|
|
11
|
+
id: a,
|
|
12
|
+
source: o,
|
|
13
|
+
name: s,
|
|
14
|
+
fields: c
|
|
15
|
+
}
|
|
16
|
+
}), () => u("sources", (e) => r(e ?? {}, d))), [d]), t(() => {
|
|
17
|
+
u(`sources.${d}.meta.fields`, c);
|
|
18
|
+
}, [
|
|
19
|
+
c,
|
|
20
|
+
d,
|
|
21
|
+
u
|
|
22
|
+
]);
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { a as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from "./hooks/
|
|
2
|
-
export { e as
|
|
1
|
+
import e from "./hooks/useRegisterSource.mjs";
|
|
2
|
+
export { e as useRegisterSource };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Log, ProviderCallback } from '../../types/DevToolsTypes';
|
|
2
|
-
import {
|
|
2
|
+
import { ChangeListener } from '@plitzi/nexus';
|
|
3
3
|
type CallbackInternal = (logType: Log['logType'], category: Log['category'], message: Log['message'], params: Record<string, unknown> | Log['params'], time?: Log['time']) => void;
|
|
4
4
|
type CallbackAddProvider = (methodName: string, callback: ProviderCallback) => void;
|
|
5
5
|
type CallbackRemoveProvider = (methodName: string) => void;
|
|
@@ -35,5 +35,5 @@ declare class PlitziConsole {
|
|
|
35
35
|
end(): void;
|
|
36
36
|
}
|
|
37
37
|
export declare const pConsole: PlitziConsole;
|
|
38
|
-
export declare function createStoreDevToolsLogger<TState extends object>(storeName?: string):
|
|
38
|
+
export declare function createStoreDevToolsLogger<TState extends object>(storeName?: string): ChangeListener<TState>;
|
|
39
39
|
export default PlitziConsole;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BuilderContextValue } from '../builder';
|
|
2
2
|
import { NetworkContextValue } from '../network';
|
|
3
|
-
import { CollectionContextValue, ComponentContextValue,
|
|
3
|
+
import { CollectionContextValue, ComponentContextValue, EventBridgeContextValue, InteractionsContextValue, NavigationContextValue, PluginsContextValue, SegmentsContextValue, StateManagerContextValue, Theme } from '../types';
|
|
4
4
|
import { Context, ReactNode, RefObject } from 'react';
|
|
5
5
|
export type PlitziServiceContextValue<TEventBridge = any, TInteractions = any> = {
|
|
6
6
|
settings: {
|
|
@@ -19,7 +19,6 @@ export type PlitziServiceContextValue<TEventBridge = any, TInteractions = any> =
|
|
|
19
19
|
};
|
|
20
20
|
customContexts: Record<string, Context<any>>;
|
|
21
21
|
contexts: {
|
|
22
|
-
DataSourceContext: Context<DataSourceContextValue>;
|
|
23
22
|
SegmentsContext: Context<SegmentsContextValue>;
|
|
24
23
|
NavigationContext: Context<NavigationContextValue>;
|
|
25
24
|
CollectionContext: Context<CollectionContextValue>;
|
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { hasValidToken as h, processTwig as g } from "./helpers/twigWrapper.mjs"
|
|
|
9
9
|
import { ParamsFromURL as _, delay as v, emptyObject as y, generateID as b, getDisplayName as x, getKeyDecoded as S, getPathsFromObeject as C, hexToRGB as w, isInViewport as T, isTestMode as E, makeId as D } from "./helpers/utils.mjs";
|
|
10
10
|
import { disableReactDevTools as O } from "./helpers/security.mjs";
|
|
11
11
|
import { createStripTypenameLink as k, stripTypenameDeep as A } from "./helpers/stripTypename.mjs";
|
|
12
|
-
import j from "./dataSource/hooks/
|
|
12
|
+
import j from "./dataSource/hooks/useRegisterSource.mjs";
|
|
13
13
|
import M from "./devTools/DevToolsContext.mjs";
|
|
14
14
|
import N, { createStoreDevToolsLogger as P, pConsole as F } from "./devTools/utils/PlitziConsole.mjs";
|
|
15
15
|
import I from "./elements/ComponentContext.mjs";
|
|
@@ -34,4 +34,4 @@ import fe, { ThemeContext as pe } from "./theme/ThemeProvider.mjs";
|
|
|
34
34
|
import me from "./server/rsc/RscContext.mjs";
|
|
35
35
|
import he from "./server/hooks/useRscData.mjs";
|
|
36
36
|
import ge from "./server/rsc/RscProvider.mjs";
|
|
37
|
-
export { e as BuilderContext, ee as BuilderMutations, te as BuilderQueries, ne as BuilderSubscriptions, n as CollectionContext, I as ComponentContext, M as DevToolsContext, X as EMPTY_SCHEMA, G as EMPTY_STYLE_SCHEMA, L as ElementContext, Q as NetworkContext, $ as NetworkInternalContext, _ as ParamsFromURL, N as PlitziConsole, V as PlitziServiceContext, H as PlitziServiceProvider, oe as RTCodec, se as RTEvent, ce as RTEventCloseCode, me as RscContext, ge as RscProvider, Y as SchemaContext, re as SdkMutations, ie as SdkQueries, ae as SegmentsContext, K as StyleBindingsAllowed, U as StyleVariableCategory, pe as ThemeContext, fe as ThemeProvider, Z as VARIABLE_REGEX, q as baseDefaultValue, t as contexts, P as createStoreDevToolsLogger, k as createStripTypenameLink, v as delay, O as disableReactDevTools, y as emptyObject, r as fetchManifest, o as formatDate, s as formatDateUTC, c as formatFromNow, l as formatUTCToLocal, i as generateFacade, b as generateID, x as getDisplayName, u as getDurationMs, le as getInstance, S as getKeyDecoded, C as getPathsFromObeject, h as hasValidToken, w as hexToRGB, J as inheritableAttributesBase, d as isDate, T as isInViewport, ue as isRTEvent, E as isTestMode, f as isValidFormat, D as makeId, F as pConsole, p as parseDate, g as processTwig, de as setInstance, A as stripTypenameDeep, W as styleConstants, a as syntaxHighlight, m as toUnixSeconds,
|
|
37
|
+
export { e as BuilderContext, ee as BuilderMutations, te as BuilderQueries, ne as BuilderSubscriptions, n as CollectionContext, I as ComponentContext, M as DevToolsContext, X as EMPTY_SCHEMA, G as EMPTY_STYLE_SCHEMA, L as ElementContext, Q as NetworkContext, $ as NetworkInternalContext, _ as ParamsFromURL, N as PlitziConsole, V as PlitziServiceContext, H as PlitziServiceProvider, oe as RTCodec, se as RTEvent, ce as RTEventCloseCode, me as RscContext, ge as RscProvider, Y as SchemaContext, re as SdkMutations, ie as SdkQueries, ae as SegmentsContext, K as StyleBindingsAllowed, U as StyleVariableCategory, pe as ThemeContext, fe as ThemeProvider, Z as VARIABLE_REGEX, q as baseDefaultValue, t as contexts, P as createStoreDevToolsLogger, k as createStripTypenameLink, v as delay, O as disableReactDevTools, y as emptyObject, r as fetchManifest, o as formatDate, s as formatDateUTC, c as formatFromNow, l as formatUTCToLocal, i as generateFacade, b as generateID, x as getDisplayName, u as getDurationMs, le as getInstance, S as getKeyDecoded, C as getPathsFromObeject, h as hasValidToken, w as hexToRGB, J as inheritableAttributesBase, d as isDate, T as isInViewport, ue as isRTEvent, E as isTestMode, f as isValidFormat, D as makeId, F as pConsole, p as parseDate, g as processTwig, de as setInstance, A as stripTypenameDeep, W as styleConstants, a as syntaxHighlight, m as toUnixSeconds, R as useElement, z as useNetwork, B as usePlitziServiceContext, j as useRegisterSource, he as useRscData };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import e from "./RscContext.mjs";
|
|
2
2
|
import { useCallback as t, useEffect as n, useMemo as r, useState as i } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { createStoreHook as a } from "@plitzi/nexus/createStore";
|
|
4
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
5
5
|
//#region src/server/rsc/RscProvider.tsx
|
|
6
6
|
var s = ({ children: s, rscPath: c, rscData: l, navigationKey: u }) => {
|
|
7
|
-
let { useStore: d } =
|
|
7
|
+
let { useStore: d } = a(), [f] = d("schema.rsc", { mode: "mount" }), [p, m] = i(l ?? {}), h = f?.enabled ?? !1, g = c ?? f?.path ?? "/_rsc", _ = t(async (e) => {
|
|
8
8
|
if (!(!h || typeof window > "u")) try {
|
|
9
9
|
let t = e?.length ? `${g}?ids=${e.join(",")}` : g, n = await fetch(t, { headers: { Accept: "application/json" } });
|
|
10
10
|
if (!n.ok) return;
|
|
@@ -23,7 +23,7 @@ var s = ({ children: s, rscPath: c, rscData: l, navigationKey: u }) => {
|
|
|
23
23
|
u
|
|
24
24
|
]);
|
|
25
25
|
let v = t((e) => p.serverData?.[e], [p.serverData]);
|
|
26
|
-
return /* @__PURE__ */
|
|
26
|
+
return /* @__PURE__ */ o(e, {
|
|
27
27
|
value: r(() => ({
|
|
28
28
|
enabled: h,
|
|
29
29
|
serverData: p.serverData,
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Environment } from './CommonTypes';
|
|
2
|
+
import { ToolCallEvent } from './McpTypes';
|
|
3
|
+
export type PromptRole = 'user' | 'assistant' | 'system';
|
|
4
|
+
export type AiMode = 'plan' | 'build';
|
|
5
|
+
export type AiRole = 'user' | 'assistant';
|
|
6
|
+
export type AiEffort = 'auto' | 'low' | 'medium' | 'high';
|
|
7
|
+
export type AIToolStatus = 'running' | 'done' | 'failed' | 'interrupted';
|
|
8
|
+
export type AiProviderType = 'openai' | 'anthropic' | 'ollama' | 'openrouter' | 'opencode';
|
|
9
|
+
export type AiUsage = {
|
|
10
|
+
inputTokens: number;
|
|
11
|
+
outputTokens: number;
|
|
12
|
+
totalTokens: number;
|
|
13
|
+
thinkingTokens?: number;
|
|
14
|
+
contextLimit: number;
|
|
15
|
+
usedPercent: number;
|
|
16
|
+
};
|
|
17
|
+
export type AiMessageAttachment = {
|
|
18
|
+
type: 'image';
|
|
19
|
+
mimeType: string;
|
|
20
|
+
data: string;
|
|
21
|
+
};
|
|
22
|
+
export type AiToolCall = {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
args?: Record<string, unknown>;
|
|
26
|
+
result?: unknown;
|
|
27
|
+
error?: string;
|
|
28
|
+
status: AIToolStatus;
|
|
29
|
+
};
|
|
30
|
+
export type AiMessageStep = {
|
|
31
|
+
type: 'thinking';
|
|
32
|
+
text: string;
|
|
33
|
+
durationMs?: number;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'tool';
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
args?: Record<string, unknown>;
|
|
39
|
+
result?: unknown;
|
|
40
|
+
error?: string;
|
|
41
|
+
status: AIToolStatus;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'resource';
|
|
44
|
+
name: string;
|
|
45
|
+
uri: string;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'text';
|
|
48
|
+
text: string;
|
|
49
|
+
};
|
|
50
|
+
export type ConversationSummary = {
|
|
51
|
+
id: string;
|
|
52
|
+
spaceId: number;
|
|
53
|
+
messageCount: number;
|
|
54
|
+
preview: string;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
updatedAt: string;
|
|
57
|
+
};
|
|
58
|
+
export type StreamCallbacks = {
|
|
59
|
+
onLog?: (level: 'error' | 'info' | 'debug', content: string) => void;
|
|
60
|
+
onChunk?: (text: string) => void;
|
|
61
|
+
onThinking?: (text: string) => void;
|
|
62
|
+
onUsage?: (usage: Omit<AiUsage, 'usedPercent' | 'contextLimit'> & {
|
|
63
|
+
contextLimit?: number;
|
|
64
|
+
}) => void;
|
|
65
|
+
onBusy?: () => void;
|
|
66
|
+
onBeforeTool?: (name: string, args: Record<string, unknown>) => void;
|
|
67
|
+
onToolSuccess?: (event: ToolCallEvent) => void;
|
|
68
|
+
onToolError?: (event: ToolCallEvent) => void;
|
|
69
|
+
onResourceRead?: (name: string, uri: string) => void;
|
|
70
|
+
};
|
|
71
|
+
export type AiContext = {
|
|
72
|
+
userId: number;
|
|
73
|
+
spaceId: number;
|
|
74
|
+
environment: Environment;
|
|
75
|
+
pubSub?: unknown;
|
|
76
|
+
mode: AiMode;
|
|
77
|
+
currentPageId?: string;
|
|
78
|
+
elementSelected?: string;
|
|
79
|
+
theme?: 'light' | 'dark';
|
|
80
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { Element
|
|
2
|
-
import { default as useDataSource } from '../dataSource/hooks/useDataSource';
|
|
1
|
+
import { Element } from './SchemaTypes';
|
|
3
2
|
import { Field, RuleValue } from '@plitzi/plitzi-ui/QueryBuilder';
|
|
4
|
-
import { Context } from 'react';
|
|
5
3
|
export type DataSourceUtilityParams<TParams = string | boolean | number> = Record<string, {
|
|
6
4
|
type?: DataSourceUtilityParamType | ((params: DataSourceUtilityParamsValue<TParams>) => DataSourceUtilityParamType);
|
|
7
5
|
label?: string;
|
|
@@ -38,19 +36,7 @@ export type SourceMeta = {
|
|
|
38
36
|
source?: string;
|
|
39
37
|
fields?: SourceField[] | (() => SourceField[] | Promise<SourceField[]>);
|
|
40
38
|
};
|
|
41
|
-
export type Source
|
|
39
|
+
export type Source = {
|
|
42
40
|
id: string;
|
|
43
41
|
meta: SourceMeta;
|
|
44
|
-
context: Context<T>;
|
|
45
|
-
};
|
|
46
|
-
export type DataSourceContextValue = {
|
|
47
|
-
useDataSource: typeof useDataSource;
|
|
48
|
-
addSource: <T = unknown>(id: string, meta?: SourceMeta) => Context<T>;
|
|
49
|
-
updateFields: (id: string, fields: SourceMeta['fields']) => void;
|
|
50
|
-
removeSource: (id: string) => void;
|
|
51
|
-
getSources: {
|
|
52
|
-
(id: string): Source | undefined;
|
|
53
|
-
(): Record<string, Source>;
|
|
54
|
-
};
|
|
55
|
-
getSourcesByElementId: (schemaFlat?: Schema['flat'], id?: string) => Record<string, Source>;
|
|
56
42
|
};
|