@base44-preview/platform 0.2.0-pr.335.2bd5f4f → 0.2.0-pr.337.2f0349e
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/README.md +68 -35
- package/dist/react/chat-items.d.ts +6 -6
- package/dist/react/chat-items.js +79 -19
- package/dist/react/chat.types.d.ts +39 -4
- package/dist/react/index.d.ts +2 -6
- package/dist/react/index.js +1 -4
- package/dist/react/useBase44Chat.js +55 -15
- package/dist/server/errors.d.ts +53 -0
- package/dist/server/errors.js +56 -0
- package/dist/server/errors.types.d.ts +60 -0
- package/dist/server/index.d.ts +6 -2
- package/dist/server/index.js +2 -1
- package/dist/server/modules/webhooks-signature.d.ts +11 -0
- package/dist/server/modules/webhooks-signature.js +65 -0
- package/dist/server/modules/webhooks.d.ts +3 -0
- package/dist/server/modules/webhooks.events.generated.d.ts +235 -0
- package/dist/server/modules/webhooks.events.generated.js +4 -0
- package/dist/server/modules/webhooks.js +91 -0
- package/dist/server/modules/webhooks.types.d.ts +218 -0
- package/dist/server/modules/webhooks.types.js +1 -0
- package/dist/server/server.d.ts +28 -3
- package/dist/server/server.js +31 -7
- package/dist/server/server.types.d.ts +8 -8
- package/package.json +11 -5
- package/dist/react/Base44ChatProvider.d.ts +0 -43
- package/dist/react/Base44ChatProvider.js +0 -68
- package/dist/react/Message.d.ts +0 -39
- package/dist/react/Message.js +0 -55
- package/dist/react/components.types.d.ts +0 -63
- package/dist/react/context.d.ts +0 -50
- package/dist/react/context.js +0 -57
- package/dist/react/fallbacks.d.ts +0 -3
- package/dist/react/fallbacks.js +0 -13
- package/dist/server/server-url.d.ts +0 -2
- package/dist/server/server-url.js +0 -8
- /package/dist/{react/components.types.js → server/errors.types.js} +0 -0
package/dist/react/context.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { ChatActions, ChatState, MessageComponents, QuestionComponents } from "./components.types.js";
|
|
2
|
-
/** @internal The parts with the fallbacks applied, as {@link Base44ChatProvider} shares them. */
|
|
3
|
-
export interface ResolvedComponents {
|
|
4
|
-
message: MessageComponents;
|
|
5
|
-
question: QuestionComponents;
|
|
6
|
-
}
|
|
7
|
-
/** @internal Filled by {@link Base44ChatProvider}. State changes on every event; actions and parts do not. */
|
|
8
|
-
export declare const StateContext: import("react").Context<ChatState | null>;
|
|
9
|
-
/** @internal */
|
|
10
|
-
export declare const ActionsContext: import("react").Context<ChatActions | null>;
|
|
11
|
-
/** @internal */
|
|
12
|
-
export declare const ComponentsContext: import("react").Context<ResolvedComponents | null>;
|
|
13
|
-
/**
|
|
14
|
-
* Reads the chat's state from the nearest {@link Base44ChatProvider}: `items`, `status`,
|
|
15
|
-
* `connection` and `error`. A component that calls it re-renders on every live event.
|
|
16
|
-
*
|
|
17
|
-
* @returns The state of the chat the provider runs.
|
|
18
|
-
* @throws {Error} When there is no provider above the component.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```tsx
|
|
22
|
-
* // The message list
|
|
23
|
-
* function Messages() {
|
|
24
|
-
* const { items } = useChatState();
|
|
25
|
-
* return items.map((item) => <div key={item.id}><Message item={item} /></div>);
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export declare function useChatState(): ChatState;
|
|
30
|
-
/**
|
|
31
|
-
* Reads the chat's actions from the nearest {@link Base44ChatProvider}: `send`, `create` and
|
|
32
|
-
* `clearError`. They keep their identity while the app stays the same, also with an inline
|
|
33
|
-
* `backend` or `onAppCreated`, so a component that reads only actions doesn't re-render when a
|
|
34
|
-
* message arrives.
|
|
35
|
-
*
|
|
36
|
-
* @returns The actions of the chat the provider runs.
|
|
37
|
-
* @throws {Error} When there is no provider above the component.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```tsx
|
|
41
|
-
* // A button outside the chat that starts a new app
|
|
42
|
-
* function NewAppButton({ prompt }: { prompt: string }) {
|
|
43
|
-
* const { create } = useChatActions();
|
|
44
|
-
* return <button onClick={() => create(prompt)}>Create</button>;
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare function useChatActions(): ChatActions;
|
|
49
|
-
/** @internal The parts from the nearest provider. */
|
|
50
|
-
export declare function useResolvedComponents(component: string): ResolvedComponents;
|
package/dist/react/context.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
/** @internal Filled by {@link Base44ChatProvider}. State changes on every event; actions and parts do not. */
|
|
4
|
-
export const StateContext = createContext(null);
|
|
5
|
-
/** @internal */
|
|
6
|
-
export const ActionsContext = createContext(null);
|
|
7
|
-
/** @internal */
|
|
8
|
-
export const ComponentsContext = createContext(null);
|
|
9
|
-
/**
|
|
10
|
-
* Reads the chat's state from the nearest {@link Base44ChatProvider}: `items`, `status`,
|
|
11
|
-
* `connection` and `error`. A component that calls it re-renders on every live event.
|
|
12
|
-
*
|
|
13
|
-
* @returns The state of the chat the provider runs.
|
|
14
|
-
* @throws {Error} When there is no provider above the component.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* // The message list
|
|
19
|
-
* function Messages() {
|
|
20
|
-
* const { items } = useChatState();
|
|
21
|
-
* return items.map((item) => <div key={item.id}><Message item={item} /></div>);
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export function useChatState() {
|
|
26
|
-
return inside(useContext(StateContext), "useChatState");
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Reads the chat's actions from the nearest {@link Base44ChatProvider}: `send`, `create` and
|
|
30
|
-
* `clearError`. They keep their identity while the app stays the same, also with an inline
|
|
31
|
-
* `backend` or `onAppCreated`, so a component that reads only actions doesn't re-render when a
|
|
32
|
-
* message arrives.
|
|
33
|
-
*
|
|
34
|
-
* @returns The actions of the chat the provider runs.
|
|
35
|
-
* @throws {Error} When there is no provider above the component.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```tsx
|
|
39
|
-
* // A button outside the chat that starts a new app
|
|
40
|
-
* function NewAppButton({ prompt }: { prompt: string }) {
|
|
41
|
-
* const { create } = useChatActions();
|
|
42
|
-
* return <button onClick={() => create(prompt)}>Create</button>;
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
export function useChatActions() {
|
|
47
|
-
return inside(useContext(ActionsContext), "useChatActions");
|
|
48
|
-
}
|
|
49
|
-
/** @internal The parts from the nearest provider. */
|
|
50
|
-
export function useResolvedComponents(component) {
|
|
51
|
-
return inside(useContext(ComponentsContext), component);
|
|
52
|
-
}
|
|
53
|
-
function inside(value, reader) {
|
|
54
|
-
if (!value)
|
|
55
|
-
throw new Error(`${reader} needs a <Base44ChatProvider> above it`);
|
|
56
|
-
return value;
|
|
57
|
-
}
|
package/dist/react/fallbacks.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
// The message parts a partner does not replace: plain HTML, no classes, so the library has no look
|
|
4
|
-
// of its own. Each carries a `data-base44` attribute for CSS to hook on. Questions have no
|
|
5
|
-
// fallback: the partner supplies a part for every kind.
|
|
6
|
-
function Text({ text, role, pending }) {
|
|
7
|
-
return (_jsx("p", { "data-base44": "text", "data-role": role, "data-pending": pending || undefined, children: text }));
|
|
8
|
-
}
|
|
9
|
-
function Step({ label, status }) {
|
|
10
|
-
return (_jsx("p", { "data-base44": "step", "data-status": status, children: label }));
|
|
11
|
-
}
|
|
12
|
-
/** @internal */
|
|
13
|
-
export const fallbackMessageComponents = { Text, Step };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Validate a platform origin and return it normalized. Used by the server entrypoint. */
|
|
2
|
-
export function normalizeServerUrl(serverUrl) {
|
|
3
|
-
const url = new URL(serverUrl);
|
|
4
|
-
if (!["https:", "http:"].includes(url.protocol) || url.username || url.password || url.search || url.hash || url.pathname !== "/") {
|
|
5
|
-
throw new TypeError("serverUrl must be an HTTP(S) origin without credentials, path, query or fragment");
|
|
6
|
-
}
|
|
7
|
-
return url.origin;
|
|
8
|
-
}
|
|
File without changes
|