@matreshka/bff 0.25.1 → 0.25.3
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/components/file-upload-area.js +18 -18
- package/dist/components/for-each.js +2 -2
- package/dist/components/item-list/list-from-ref-context.js +2 -2
- package/dist/components/webmcp/web-mcp-tool.d.ts +1 -1
- package/dist/components/webmcp/web-mcp-tool.js +7 -4
- package/dist/core/client.d.ts +1 -1
- package/dist/core/client.js +22 -22
- package/dist/core/context/context.d.ts +1 -1
- package/dist/core/context/context.js +2 -2
- package/dist/core/utils/deep-pick.d.ts +1 -1
- package/dist/core/utils/deep-pick.js +3 -3
- package/dist/core/utils/targeted-client-action.js +3 -3
- package/dist/platforms/browser-platform.js +14 -14
- package/dist/platforms/max-mini-app-platform.d.ts +1 -1
- package/dist/platforms/max-mini-app-platform.js +3 -3
- package/dist/platforms/mobile-platform.d.ts +1 -1
- package/dist/platforms/mobile-platform.js +21 -21
- package/dist/platforms/platform.js +10 -10
- package/dist/platforms/telegram-mini-app-platform.d.ts +1 -1
- package/dist/platforms/telegram-mini-app-platform.js +16 -16
- package/dist/platforms/utils/mobile-ble-services.d.ts +1 -1
- package/dist/platforms/utils/mobile-ble-services.js +19 -19
- package/dist/platforms/utils/targeted-client-platform-stream.js +3 -3
- package/package.json +2 -2
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FileUploadArea = void 0;
|
|
4
4
|
exports.fileUploadArea = fileUploadArea;
|
|
5
5
|
const server_component_class_1 = require("@matreshka/shared/enums/server-component-class");
|
|
6
|
-
const
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
7
|
const core_1 = require("../core");
|
|
8
8
|
const component_1 = require("./component");
|
|
9
9
|
function fileUploadArea(arg0, arg1) {
|
|
@@ -23,13 +23,13 @@ class FileUploadArea extends component_1.Component {
|
|
|
23
23
|
super(config);
|
|
24
24
|
this.uploadMap = new Map();
|
|
25
25
|
this.onInteraction("start", ({ payload }) => {
|
|
26
|
-
const schema =
|
|
27
|
-
id:
|
|
28
|
-
type:
|
|
29
|
-
size:
|
|
30
|
-
name:
|
|
31
|
-
lastModified:
|
|
32
|
-
url:
|
|
26
|
+
const schema = zod_1.z.strictObject({
|
|
27
|
+
id: zod_1.z.string(),
|
|
28
|
+
type: zod_1.z.string(),
|
|
29
|
+
size: zod_1.z.number(),
|
|
30
|
+
name: zod_1.z.string(),
|
|
31
|
+
lastModified: zod_1.z.number(),
|
|
32
|
+
url: zod_1.z.string().refine((val) => val.startsWith("blob:"), {
|
|
33
33
|
message: "url must be a blob",
|
|
34
34
|
}),
|
|
35
35
|
});
|
|
@@ -38,10 +38,10 @@ class FileUploadArea extends component_1.Component {
|
|
|
38
38
|
this.config.onStart?.(safePayload);
|
|
39
39
|
});
|
|
40
40
|
this.onInteraction("progress", ({ payload }) => {
|
|
41
|
-
const schema =
|
|
41
|
+
const schema = zod_1.z
|
|
42
42
|
.strictObject({
|
|
43
|
-
id:
|
|
44
|
-
progress:
|
|
43
|
+
id: zod_1.z.string(),
|
|
44
|
+
progress: zod_1.z.number().min(0).max(100),
|
|
45
45
|
})
|
|
46
46
|
.refine((data) => this.uploadMap.has(data.id), {
|
|
47
47
|
message: "Unknown upload id",
|
|
@@ -54,10 +54,10 @@ class FileUploadArea extends component_1.Component {
|
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
this.onInteraction("complete", ({ payload }) => {
|
|
57
|
-
const schema =
|
|
57
|
+
const schema = zod_1.z
|
|
58
58
|
.strictObject({
|
|
59
|
-
id:
|
|
60
|
-
response:
|
|
59
|
+
id: zod_1.z.string(),
|
|
60
|
+
response: zod_1.z.unknown(),
|
|
61
61
|
})
|
|
62
62
|
.refine((data) => this.uploadMap.has(data.id), {
|
|
63
63
|
message: "Unknown upload id",
|
|
@@ -70,11 +70,11 @@ class FileUploadArea extends component_1.Component {
|
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
this.onInteraction("error", ({ payload }) => {
|
|
73
|
-
const schema =
|
|
73
|
+
const schema = zod_1.z
|
|
74
74
|
.strictObject({
|
|
75
|
-
id:
|
|
76
|
-
response:
|
|
77
|
-
code:
|
|
75
|
+
id: zod_1.z.string(),
|
|
76
|
+
response: zod_1.z.unknown(),
|
|
77
|
+
code: zod_1.z.number(), // Не StatusCode, потому что может быть 0, который не содержится в словаре
|
|
78
78
|
})
|
|
79
79
|
.refine((data) => this.uploadMap.has(data.id), {
|
|
80
80
|
message: "Unknown upload id",
|
|
@@ -4,7 +4,7 @@ exports.ForEach = exports.forEach = void 0;
|
|
|
4
4
|
const server_component_class_1 = require("@matreshka/shared/enums/server-component-class");
|
|
5
5
|
const for_each_sync_components_message_1 = require("@matreshka/shared/messages/bff-to-client/components/for-each/for-each-sync-components-message");
|
|
6
6
|
const rxjs_1 = require("rxjs");
|
|
7
|
-
const
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
8
|
const core_1 = require("../core");
|
|
9
9
|
const serialize_component_tree_1 = require("../core/utils/serialize-component-tree");
|
|
10
10
|
const track_created_instances_1 = require("../core/utils/track-created-instances");
|
|
@@ -47,7 +47,7 @@ class ForEachContext extends core_1.Context {
|
|
|
47
47
|
super({
|
|
48
48
|
data: async () => ({}),
|
|
49
49
|
preload: preload,
|
|
50
|
-
schema:
|
|
50
|
+
schema: zod_1.z.strictObject({}), // Запрет изменения из внешних источников
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ItemListIndexStore = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
|
-
const
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
6
|
const core_1 = require("../../core");
|
|
7
7
|
/** Контекст индексов элементов ItemList; данные не загружаются снаружи. */
|
|
8
8
|
class ItemListIndexStore extends core_1.Context {
|
|
@@ -22,7 +22,7 @@ class ItemListIndexStore extends core_1.Context {
|
|
|
22
22
|
super({
|
|
23
23
|
data: async () => ({}),
|
|
24
24
|
preload,
|
|
25
|
-
schema:
|
|
25
|
+
schema: zod_1.z.strictObject({}),
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WebMcpToolAnnotation } from "@matreshka/shared/enums/web-mcp-tool-annotation";
|
|
2
2
|
import type { Condition as SerializedCondition } from "@matreshka/shared/types/condition";
|
|
3
3
|
import type { WebMcpToolConfig } from "@matreshka/shared/types/web-mcp-tool-config";
|
|
4
|
-
import { z } from "zod
|
|
4
|
+
import { z } from "zod";
|
|
5
5
|
import type { Client } from "../../core/client";
|
|
6
6
|
import { Condition } from "../../core/conditions/condition";
|
|
7
7
|
export { WebMcpToolAnnotation };
|
|
@@ -44,12 +44,15 @@ const web_mcp_tool_error_message_1 = require("@matreshka/shared/messages/bff-to-
|
|
|
44
44
|
const web_mcp_tool_result_message_1 = require("@matreshka/shared/messages/bff-to-client/webmcp/web-mcp-tool-result-message");
|
|
45
45
|
const crypto = __importStar(require("node:crypto"));
|
|
46
46
|
const zod_1 = require("zod");
|
|
47
|
-
|
|
47
|
+
/** MCP: латиница, цифры, `-`, `_` (после trim). */
|
|
48
|
+
const WEB_MCP_TOOL_NAME_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
48
49
|
const webMcpToolSchema = zod_1.z.object({
|
|
49
|
-
name: zod_1.z.string().trim().min(1),
|
|
50
|
+
name: zod_1.z.string().trim().min(1).regex(WEB_MCP_TOOL_NAME_PATTERN, {
|
|
51
|
+
message: "Tool name must contain only Latin letters, digits, hyphens (-), and underscores (_)",
|
|
52
|
+
}),
|
|
50
53
|
description: zod_1.z.string().trim().min(1),
|
|
51
54
|
annotations: zod_1.z
|
|
52
|
-
.array(zod_1.z.
|
|
55
|
+
.array(zod_1.z.enum(web_mcp_tool_annotation_1.WebMcpToolAnnotation))
|
|
53
56
|
.refine((items) => new Set(items).size === items.length, {
|
|
54
57
|
message: "Annotations must be unique",
|
|
55
58
|
})
|
|
@@ -106,7 +109,7 @@ function resolveWebMcpToolConditions(conditions) {
|
|
|
106
109
|
return list.map((condition) => condition.toJSON());
|
|
107
110
|
}
|
|
108
111
|
function webMcpInputJsonSchema(schema) {
|
|
109
|
-
return
|
|
112
|
+
return zod_1.z.toJSONSchema(schema);
|
|
110
113
|
}
|
|
111
114
|
/** Проверяет input, вызывает execute и отвечает клиенту результатом или ошибкой. */
|
|
112
115
|
async function dispatchWebMcpToolCall(client, tool, callId, input) {
|
package/dist/core/client.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { AnyBffToClientMessage, BffToClientMessage } from "@matreshka/shared/mes
|
|
|
7
7
|
import { AnyClientToBffMessage } from "@matreshka/shared/messages/client-to-bff/client-to-bff-message";
|
|
8
8
|
import { ClientState } from "@matreshka/shared/types/client-state";
|
|
9
9
|
import { BehaviorSubject, Observable, Subject } from "rxjs";
|
|
10
|
-
import { z } from "zod
|
|
10
|
+
import { z } from "zod";
|
|
11
11
|
import { Page } from "../components";
|
|
12
12
|
import { App } from "../components/app";
|
|
13
13
|
import { ClientStorage } from "./client-storage";
|
package/dist/core/client.js
CHANGED
|
@@ -12,7 +12,7 @@ const message_received_message_2 = require("@matreshka/shared/messages/client-to
|
|
|
12
12
|
const parse_client_to_bff_message_1 = require("@matreshka/shared/messages/client-to-bff/parse-client-to-bff-message");
|
|
13
13
|
const reliable_delivery_1 = require("@matreshka/shared/messages/reliable-delivery");
|
|
14
14
|
const rxjs_1 = require("rxjs");
|
|
15
|
-
const
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
16
|
const app_1 = require("../components/app");
|
|
17
17
|
const component_1 = require("../components/component");
|
|
18
18
|
const client_context_1 = require("./client-context");
|
|
@@ -36,22 +36,22 @@ const resolveDeviceTypeFromUserAgent = shared_1.getDeviceTypeFromUserAgent;
|
|
|
36
36
|
* @property platform.id Идентификатор платформы.
|
|
37
37
|
* @property platform.payload Дополнительные данные о платформе.
|
|
38
38
|
*/
|
|
39
|
-
exports.ClientHandshakePayloadSchema =
|
|
40
|
-
applicationId:
|
|
39
|
+
exports.ClientHandshakePayloadSchema = zod_1.z.strictObject({
|
|
40
|
+
applicationId: zod_1.z.string(),
|
|
41
41
|
});
|
|
42
|
-
exports.ClientStateSchema =
|
|
43
|
-
route:
|
|
44
|
-
visitedAt:
|
|
45
|
-
path:
|
|
46
|
-
query:
|
|
42
|
+
exports.ClientStateSchema = zod_1.z.strictObject({
|
|
43
|
+
route: zod_1.z.strictObject({
|
|
44
|
+
visitedAt: zod_1.z.number(),
|
|
45
|
+
path: zod_1.z.string(),
|
|
46
|
+
query: zod_1.z.record(zod_1.z.string(), zod_1.z.string()),
|
|
47
47
|
}),
|
|
48
|
-
storage:
|
|
49
|
-
language:
|
|
50
|
-
userAgent:
|
|
51
|
-
prefersColorScheme:
|
|
52
|
-
platform:
|
|
53
|
-
id:
|
|
54
|
-
payload:
|
|
48
|
+
storage: zod_1.z.record(zod_1.z.string(), zod_1.z.string()),
|
|
49
|
+
language: zod_1.z.string(),
|
|
50
|
+
userAgent: zod_1.z.string(),
|
|
51
|
+
prefersColorScheme: zod_1.z.literal(["light", "dark", "system"]),
|
|
52
|
+
platform: zod_1.z.strictObject({
|
|
53
|
+
id: zod_1.z.enum(platform_id_1.PlatformId),
|
|
54
|
+
payload: zod_1.z.unknown(),
|
|
55
55
|
}),
|
|
56
56
|
});
|
|
57
57
|
class Client {
|
|
@@ -174,13 +174,13 @@ class Client {
|
|
|
174
174
|
*/
|
|
175
175
|
newMessage(messageString) {
|
|
176
176
|
try {
|
|
177
|
-
const abstractMessageSchema =
|
|
178
|
-
type:
|
|
179
|
-
payload:
|
|
180
|
-
target:
|
|
181
|
-
id:
|
|
182
|
-
attempt:
|
|
183
|
-
handlers:
|
|
177
|
+
const abstractMessageSchema = zod_1.z.object({
|
|
178
|
+
type: zod_1.z.string(),
|
|
179
|
+
payload: zod_1.z.unknown().optional(),
|
|
180
|
+
target: zod_1.z.string().optional(),
|
|
181
|
+
id: zod_1.z.string().optional(),
|
|
182
|
+
attempt: zod_1.z.number().int().positive().optional(),
|
|
183
|
+
handlers: zod_1.z.array(zod_1.z.number().int().nonnegative()).optional(),
|
|
184
184
|
});
|
|
185
185
|
const message = abstractMessageSchema.parse(JSON.parse(messageString));
|
|
186
186
|
(0, client_context_1.runWithClient)(this, () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JsonObject } from "@matreshka/shared/types/json";
|
|
2
2
|
import { BehaviorSubject, Observable } from "rxjs";
|
|
3
3
|
import { Paths, PathValue } from "ts-essentials";
|
|
4
|
-
import { ZodObject } from "zod
|
|
4
|
+
import { ZodObject } from "zod";
|
|
5
5
|
import { ActionConfig } from "../actions/action";
|
|
6
6
|
import { LocalContextPathPatch } from "../actions/set-context";
|
|
7
7
|
import type { Client } from "../client";
|
|
@@ -6,7 +6,7 @@ const index_2 = require("@matreshka/shared/messages/client-to-bff/context/index"
|
|
|
6
6
|
const targeted_message_1 = require("@matreshka/shared/messages/targeted-message");
|
|
7
7
|
const fetch_from_object_1 = require("@matreshka/shared/utils/fetch-from-object");
|
|
8
8
|
const rxjs_1 = require("rxjs");
|
|
9
|
-
const
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
10
|
const dec_context_value_1 = require("../actions/dec-context-value");
|
|
11
11
|
const inc_context_value_1 = require("../actions/inc-context-value");
|
|
12
12
|
const set_context_1 = require("../actions/set-context");
|
|
@@ -215,7 +215,7 @@ class Context {
|
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
217
|
if (unsafeMessage instanceof index_2.ContextValuesMessage) {
|
|
218
|
-
const payloadSchema =
|
|
218
|
+
const payloadSchema = zod_1.z.array(zod_1.z.strictObject({ key: zod_1.z.string(), value: zod_1.z.unknown() }));
|
|
219
219
|
const changes = payloadSchema.parse(unsafeMessage.payload);
|
|
220
220
|
const patch = {};
|
|
221
221
|
changes.forEach((change) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { z } from "zod
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
export declare function zodDeepPick(schema: z.ZodTypeAny, propertyPath: string): z.ZodTypeAny;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.zodDeepPick = zodDeepPick;
|
|
4
|
-
const
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
5
|
function isZodObject(schema) {
|
|
6
|
-
return schema instanceof
|
|
6
|
+
return schema instanceof zod_1.z.ZodObject;
|
|
7
7
|
}
|
|
8
8
|
function isZodArray(schema) {
|
|
9
|
-
return schema instanceof
|
|
9
|
+
return schema instanceof zod_1.z.ZodArray;
|
|
10
10
|
}
|
|
11
11
|
function pickObject(schema, path) {
|
|
12
12
|
if (!isZodObject(schema))
|
|
@@ -6,10 +6,10 @@ const action_completed_message_1 = require("@matreshka/shared/messages/client-to
|
|
|
6
6
|
const error_message_1 = require("@matreshka/shared/messages/client-to-bff/error-message");
|
|
7
7
|
const targeted_message_1 = require("@matreshka/shared/messages/targeted-message");
|
|
8
8
|
const rxjs_1 = require("rxjs");
|
|
9
|
-
const
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
10
|
const incoming_message_observer_1 = require("./incoming-message-observer");
|
|
11
|
-
const errorMessagePayloadSchema =
|
|
12
|
-
message:
|
|
11
|
+
const errorMessagePayloadSchema = zod_1.z.strictObject({
|
|
12
|
+
message: zod_1.z.string(),
|
|
13
13
|
});
|
|
14
14
|
function createTargetedActionScope(prefix) {
|
|
15
15
|
return prefix + crypto.randomUUID();
|
|
@@ -14,16 +14,16 @@ const browser_get_geolocation_success_message_1 = require("@matreshka/shared/mes
|
|
|
14
14
|
const browser_request_push_notifications_action_granted_message_1 = require("@matreshka/shared/messages/client-to-bff/platforms/browser/browser-request-push-notifications-action-granted-message");
|
|
15
15
|
const platform_webauthn_create_credential_success_message_1 = require("@matreshka/shared/messages/client-to-bff/platforms/platform-webauthn-create-credential-success-message");
|
|
16
16
|
const platform_webauthn_get_credential_success_message_1 = require("@matreshka/shared/messages/client-to-bff/platforms/platform-webauthn-get-credential-success-message");
|
|
17
|
-
const
|
|
17
|
+
const zod_1 = require("zod");
|
|
18
18
|
const targeted_client_platform_action_1 = require("./utils/targeted-client-platform-action");
|
|
19
19
|
const web_platform_1 = require("./web-platform");
|
|
20
|
-
const pushSubscriptionGrantedMessageSchema =
|
|
21
|
-
subscription:
|
|
22
|
-
endpoint:
|
|
23
|
-
expirationTime:
|
|
24
|
-
keys:
|
|
25
|
-
auth:
|
|
26
|
-
p256dh:
|
|
20
|
+
const pushSubscriptionGrantedMessageSchema = zod_1.z.strictObject({
|
|
21
|
+
subscription: zod_1.z.strictObject({
|
|
22
|
+
endpoint: zod_1.z.string(),
|
|
23
|
+
expirationTime: zod_1.z.number().nullable().optional(),
|
|
24
|
+
keys: zod_1.z.strictObject({
|
|
25
|
+
auth: zod_1.z.string(),
|
|
26
|
+
p256dh: zod_1.z.string(),
|
|
27
27
|
}),
|
|
28
28
|
}),
|
|
29
29
|
});
|
|
@@ -42,10 +42,10 @@ class BrowserPlatform extends web_platform_1.WebPlatform {
|
|
|
42
42
|
outgoingMessage: (scope) => new browser_get_geolocation_message_1.BrowserGetGeolocationMessage(scope),
|
|
43
43
|
parseSuccess: (unsafeMessage) => {
|
|
44
44
|
if (unsafeMessage instanceof browser_get_geolocation_success_message_1.BrowserGetGeolocationSuccessMessage) {
|
|
45
|
-
return
|
|
45
|
+
return zod_1.z
|
|
46
46
|
.strictObject({
|
|
47
|
-
latitude:
|
|
48
|
-
longitude:
|
|
47
|
+
latitude: zod_1.z.number(),
|
|
48
|
+
longitude: zod_1.z.number(),
|
|
49
49
|
})
|
|
50
50
|
.parse(unsafeMessage.payload);
|
|
51
51
|
}
|
|
@@ -159,10 +159,10 @@ class BrowserPlatform extends web_platform_1.WebPlatform {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
exports.BrowserPlatform = BrowserPlatform;
|
|
162
|
-
const webAuthnJsonObjectSchema =
|
|
163
|
-
const webAuthnRegistrationResponseSchema =
|
|
162
|
+
const webAuthnJsonObjectSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
|
|
163
|
+
const webAuthnRegistrationResponseSchema = zod_1.z.strictObject({
|
|
164
164
|
credentialJSON: webAuthnJsonObjectSchema,
|
|
165
165
|
});
|
|
166
|
-
const webAuthnAuthenticationResponseSchema =
|
|
166
|
+
const webAuthnAuthenticationResponseSchema = zod_1.z.strictObject({
|
|
167
167
|
credentialJSON: webAuthnJsonObjectSchema,
|
|
168
168
|
});
|
|
@@ -7,14 +7,14 @@ exports.MaxMiniAppPlatform = void 0;
|
|
|
7
7
|
const max_mini_app_request_contact_message_1 = require("@matreshka/shared/messages/bff-to-client/platforms/max-mini-app/max-mini-app-request-contact-message");
|
|
8
8
|
const max_mini_app_request_contact_action_success_message_1 = require("@matreshka/shared/messages/client-to-bff/platforms/max-mini-app/max-mini-app-request-contact-action-success-message");
|
|
9
9
|
const crypto_1 = __importDefault(require("crypto"));
|
|
10
|
-
const
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
11
|
const targeted_client_platform_action_1 = require("./utils/targeted-client-platform-action");
|
|
12
12
|
const web_platform_1 = require("./web-platform");
|
|
13
13
|
/**
|
|
14
14
|
* Входящее сообщение с данными пользователя после успешного запроса контакта.
|
|
15
15
|
*/
|
|
16
|
-
const requestContactSuccessMessageSchema =
|
|
17
|
-
phone:
|
|
16
|
+
const requestContactSuccessMessageSchema = zod_1.z.strictObject({
|
|
17
|
+
phone: zod_1.z.string(),
|
|
18
18
|
});
|
|
19
19
|
/**
|
|
20
20
|
* Платформа для Max Mini App.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MobileBleService } from "@matreshka/shared/types/mobile-ble-services";
|
|
2
2
|
import { Observable, Subject } from "rxjs";
|
|
3
|
-
import { z } from "zod
|
|
3
|
+
import { z } from "zod";
|
|
4
4
|
import { Client } from "../core";
|
|
5
5
|
import { ClientPlatform } from "./client-platform";
|
|
6
6
|
/**
|
|
@@ -22,7 +22,7 @@ const mobile_get_geolocation_success_message_1 = require("@matreshka/shared/mess
|
|
|
22
22
|
const mobile_request_push_notifications_action_granted_message_1 = require("@matreshka/shared/messages/client-to-bff/platforms/mobile/mobile-request-push-notifications-action-granted-message");
|
|
23
23
|
const targeted_message_1 = require("@matreshka/shared/messages/targeted-message");
|
|
24
24
|
const rxjs_1 = require("rxjs");
|
|
25
|
-
const
|
|
25
|
+
const zod_1 = require("zod");
|
|
26
26
|
const incoming_message_observer_1 = require("../core/utils/incoming-message-observer");
|
|
27
27
|
const client_platform_1 = require("./client-platform");
|
|
28
28
|
const mobile_ble_services_1 = require("./utils/mobile-ble-services");
|
|
@@ -31,27 +31,27 @@ const targeted_client_platform_stream_1 = require("./utils/targeted-client-platf
|
|
|
31
31
|
/**
|
|
32
32
|
* Входящее сообщение, содержащее успешно полученный push-токен.
|
|
33
33
|
*/
|
|
34
|
-
const pushTokenGrantedMessageSchema =
|
|
35
|
-
token:
|
|
36
|
-
value:
|
|
34
|
+
const pushTokenGrantedMessageSchema = zod_1.z.strictObject({
|
|
35
|
+
token: zod_1.z.strictObject({
|
|
36
|
+
value: zod_1.z.string(),
|
|
37
37
|
}),
|
|
38
38
|
});
|
|
39
39
|
/**
|
|
40
40
|
* Входящее сообщение с найденным устройством BLE
|
|
41
41
|
*/
|
|
42
|
-
exports.bleScanResultSchema =
|
|
42
|
+
exports.bleScanResultSchema = zod_1.z.object({
|
|
43
43
|
// Не strictObject, потому что на андройде еще прилетает rawAdvertisement
|
|
44
44
|
// https://github.com/capacitor-community/bluetooth-le?tab=readme-ov-file#scanresult
|
|
45
|
-
device:
|
|
46
|
-
name:
|
|
47
|
-
deviceId:
|
|
45
|
+
device: zod_1.z.strictObject({
|
|
46
|
+
name: zod_1.z.string().optional(),
|
|
47
|
+
deviceId: zod_1.z.string(),
|
|
48
48
|
}),
|
|
49
|
-
localName:
|
|
50
|
-
txPower:
|
|
51
|
-
rssi:
|
|
52
|
-
manufacturerData:
|
|
53
|
-
serviceData:
|
|
54
|
-
uuids:
|
|
49
|
+
localName: zod_1.z.string().optional(),
|
|
50
|
+
txPower: zod_1.z.number(),
|
|
51
|
+
rssi: zod_1.z.number(),
|
|
52
|
+
manufacturerData: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
53
|
+
serviceData: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
54
|
+
uuids: zod_1.z.array(zod_1.z.string()),
|
|
55
55
|
});
|
|
56
56
|
/**
|
|
57
57
|
* Абстрактная платформа, реализующая функции взаимодействия с нативной мобильной средой.
|
|
@@ -98,10 +98,10 @@ class MobilePlatform extends client_platform_1.ClientPlatform {
|
|
|
98
98
|
outgoingMessage: (scope) => new mobile_get_geolocation_message_1.MobileGetGeolocationMessage(scope),
|
|
99
99
|
parseSuccess: (unsafeMessage) => {
|
|
100
100
|
if (unsafeMessage instanceof mobile_get_geolocation_success_message_1.MobileGetGeolocationSuccessMessage) {
|
|
101
|
-
return
|
|
101
|
+
return zod_1.z
|
|
102
102
|
.strictObject({
|
|
103
|
-
latitude:
|
|
104
|
-
longitude:
|
|
103
|
+
latitude: zod_1.z.number(),
|
|
104
|
+
longitude: zod_1.z.number(),
|
|
105
105
|
})
|
|
106
106
|
.parse(unsafeMessage.payload);
|
|
107
107
|
}
|
|
@@ -207,9 +207,9 @@ class BLEDevice {
|
|
|
207
207
|
}),
|
|
208
208
|
parseSuccess: (unsafeMessage) => {
|
|
209
209
|
if (unsafeMessage instanceof mobile_ble_value_message_1.MobileBleValueMessage) {
|
|
210
|
-
const payload =
|
|
210
|
+
const payload = zod_1.z
|
|
211
211
|
.strictObject({
|
|
212
|
-
value:
|
|
212
|
+
value: zod_1.z.number(),
|
|
213
213
|
})
|
|
214
214
|
.parse(unsafeMessage.payload);
|
|
215
215
|
return payload.value;
|
|
@@ -222,7 +222,7 @@ class BLEDevice {
|
|
|
222
222
|
outgoingMessage: (scope) => new mobile_get_ble_services_message_1.MobileGetBleServicesMessage(scope, { deviceId: this.id }),
|
|
223
223
|
parseSuccess: (unsafeMessage) => {
|
|
224
224
|
if (unsafeMessage instanceof mobile_ble_services_message_1.MobileBleServicesMessage) {
|
|
225
|
-
const payload =
|
|
225
|
+
const payload = zod_1.z
|
|
226
226
|
.strictObject({ services: mobile_ble_services_1.mobileBleServicesSchema })
|
|
227
227
|
.parse(unsafeMessage.payload);
|
|
228
228
|
return payload.services;
|
|
@@ -235,7 +235,7 @@ class BLEDevice {
|
|
|
235
235
|
outgoingMessage: (scope) => new mobile_discover_ble_services_message_1.MobileDiscoverBleServicesMessage(scope, { deviceId: this.id }),
|
|
236
236
|
parseSuccess: (unsafeMessage) => {
|
|
237
237
|
if (unsafeMessage instanceof mobile_ble_services_message_1.MobileBleServicesMessage) {
|
|
238
|
-
const payload =
|
|
238
|
+
const payload = zod_1.z
|
|
239
239
|
.strictObject({ services: mobile_ble_services_1.mobileBleServicesSchema })
|
|
240
240
|
.parse(unsafeMessage.payload);
|
|
241
241
|
return payload.services;
|
|
@@ -13,7 +13,7 @@ const platform_show_native_picker_message_1 = require("@matreshka/shared/message
|
|
|
13
13
|
const platform_enumerate_devices_success_message_1 = require("@matreshka/shared/messages/client-to-bff/platforms/platform-enumerate-devices-success-message");
|
|
14
14
|
const web_mcp_tool_call_message_1 = require("@matreshka/shared/messages/client-to-bff/webmcp/web-mcp-tool-call-message");
|
|
15
15
|
const rxjs_1 = require("rxjs");
|
|
16
|
-
const
|
|
16
|
+
const zod_1 = require("zod");
|
|
17
17
|
const web_mcp_tool_1 = require("../components/webmcp/web-mcp-tool");
|
|
18
18
|
const core_1 = require("../core");
|
|
19
19
|
const incoming_message_observer_1 = require("../core/utils/incoming-message-observer");
|
|
@@ -22,13 +22,13 @@ const client_back_platform_action_1 = require("./utils/client-back-platform-acti
|
|
|
22
22
|
const client_navigate_platform_action_1 = require("./utils/client-navigate-platform-action");
|
|
23
23
|
const client_reload_platform_action_1 = require("./utils/client-reload-platform-action");
|
|
24
24
|
const targeted_client_platform_action_1 = require("./utils/targeted-client-platform-action");
|
|
25
|
-
const enumeratedDeviceSchema =
|
|
26
|
-
kind:
|
|
27
|
-
deviceId:
|
|
28
|
-
groupId:
|
|
29
|
-
label:
|
|
30
|
-
capabilities:
|
|
31
|
-
settings:
|
|
25
|
+
const enumeratedDeviceSchema = zod_1.z.strictObject({
|
|
26
|
+
kind: zod_1.z.enum(["audioinput", "audiooutput", "videoinput"]),
|
|
27
|
+
deviceId: zod_1.z.string(),
|
|
28
|
+
groupId: zod_1.z.string(),
|
|
29
|
+
label: zod_1.z.string().optional(),
|
|
30
|
+
capabilities: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
31
|
+
settings: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
|
|
32
32
|
});
|
|
33
33
|
/**
|
|
34
34
|
* Абстрактный класс платформы, управляющий клиентом и его состоянием.
|
|
@@ -206,9 +206,9 @@ class Platform {
|
|
|
206
206
|
outgoingMessage: (scope) => new platform_enumerate_devices_message_1.PlatformEnumerateDevicesMessage(scope),
|
|
207
207
|
parseSuccess: (unsafeMessage) => {
|
|
208
208
|
if (unsafeMessage instanceof platform_enumerate_devices_success_message_1.PlatformEnumerateDevicesSuccessMessage) {
|
|
209
|
-
const payload =
|
|
209
|
+
const payload = zod_1.z
|
|
210
210
|
.strictObject({
|
|
211
|
-
devices:
|
|
211
|
+
devices: zod_1.z.array(enumeratedDeviceSchema),
|
|
212
212
|
})
|
|
213
213
|
.parse(unsafeMessage.payload);
|
|
214
214
|
return payload.devices.map((d) => toDeviceInstance(d));
|
|
@@ -12,28 +12,28 @@ const telegram_mini_app_get_geolocation_success_message_1 = require("@matreshka/
|
|
|
12
12
|
const telegram_mini_app_request_contact_action_cancel_message_1 = require("@matreshka/shared/messages/client-to-bff/platforms/telegram-mini-app/telegram-mini-app-request-contact-action-cancel-message");
|
|
13
13
|
const telegram_mini_app_request_contact_action_success_message_1 = require("@matreshka/shared/messages/client-to-bff/platforms/telegram-mini-app/telegram-mini-app-request-contact-action-success-message");
|
|
14
14
|
const crypto_1 = __importDefault(require("crypto"));
|
|
15
|
-
const
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
16
|
const targeted_client_platform_action_1 = require("./utils/targeted-client-platform-action");
|
|
17
17
|
const web_platform_1 = require("./web-platform");
|
|
18
18
|
/**
|
|
19
19
|
* Входящее сообщение с данными пользователя после успешного запроса контакта.
|
|
20
20
|
*/
|
|
21
|
-
const requestContactSuccessMessageSchema =
|
|
22
|
-
phone_number:
|
|
23
|
-
first_name:
|
|
24
|
-
last_name:
|
|
25
|
-
user_id:
|
|
21
|
+
const requestContactSuccessMessageSchema = zod_1.z.strictObject({
|
|
22
|
+
phone_number: zod_1.z.string(),
|
|
23
|
+
first_name: zod_1.z.string(),
|
|
24
|
+
last_name: zod_1.z.string().optional(),
|
|
25
|
+
user_id: zod_1.z.number(),
|
|
26
26
|
});
|
|
27
|
-
const telegramGeolocationSuccessSchema =
|
|
28
|
-
latitude:
|
|
29
|
-
longitude:
|
|
30
|
-
altitude:
|
|
31
|
-
course:
|
|
32
|
-
speed:
|
|
33
|
-
horizontal_accuracy:
|
|
34
|
-
vertical_accuracy:
|
|
35
|
-
course_accuracy:
|
|
36
|
-
speed_accuracy:
|
|
27
|
+
const telegramGeolocationSuccessSchema = zod_1.z.strictObject({
|
|
28
|
+
latitude: zod_1.z.number(),
|
|
29
|
+
longitude: zod_1.z.number(),
|
|
30
|
+
altitude: zod_1.z.number().nullable(),
|
|
31
|
+
course: zod_1.z.number().nullable(),
|
|
32
|
+
speed: zod_1.z.number().nullable(),
|
|
33
|
+
horizontal_accuracy: zod_1.z.number().nullable(),
|
|
34
|
+
vertical_accuracy: zod_1.z.number().nullable(),
|
|
35
|
+
course_accuracy: zod_1.z.number().nullable(),
|
|
36
|
+
speed_accuracy: zod_1.z.number().nullable(),
|
|
37
37
|
});
|
|
38
38
|
/**
|
|
39
39
|
* Платформа для Telegram Mini App.
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mobileBleServicesSchema = void 0;
|
|
4
|
-
const
|
|
5
|
-
exports.mobileBleServicesSchema =
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.mobileBleServicesSchema = zod_1.z.array(zod_1.z
|
|
6
6
|
.object({
|
|
7
|
-
uuid:
|
|
8
|
-
characteristics:
|
|
7
|
+
uuid: zod_1.z.string(),
|
|
8
|
+
characteristics: zod_1.z.array(zod_1.z
|
|
9
9
|
.object({
|
|
10
|
-
uuid:
|
|
11
|
-
properties:
|
|
10
|
+
uuid: zod_1.z.string(),
|
|
11
|
+
properties: zod_1.z
|
|
12
12
|
.object({
|
|
13
|
-
broadcast:
|
|
14
|
-
read:
|
|
15
|
-
writeWithoutResponse:
|
|
16
|
-
write:
|
|
17
|
-
notify:
|
|
18
|
-
indicate:
|
|
19
|
-
authenticatedSignedWrites:
|
|
20
|
-
reliableWrite:
|
|
21
|
-
writableAuxiliaries:
|
|
22
|
-
extendedProperties:
|
|
23
|
-
notifyEncryptionRequired:
|
|
24
|
-
indicateEncryptionRequired:
|
|
13
|
+
broadcast: zod_1.z.boolean().optional(),
|
|
14
|
+
read: zod_1.z.boolean().optional(),
|
|
15
|
+
writeWithoutResponse: zod_1.z.boolean().optional(),
|
|
16
|
+
write: zod_1.z.boolean().optional(),
|
|
17
|
+
notify: zod_1.z.boolean().optional(),
|
|
18
|
+
indicate: zod_1.z.boolean().optional(),
|
|
19
|
+
authenticatedSignedWrites: zod_1.z.boolean().optional(),
|
|
20
|
+
reliableWrite: zod_1.z.boolean().optional(),
|
|
21
|
+
writableAuxiliaries: zod_1.z.boolean().optional(),
|
|
22
|
+
extendedProperties: zod_1.z.boolean().optional(),
|
|
23
|
+
notifyEncryptionRequired: zod_1.z.boolean().optional(),
|
|
24
|
+
indicateEncryptionRequired: zod_1.z.boolean().optional(),
|
|
25
25
|
})
|
|
26
26
|
.passthrough(),
|
|
27
|
-
descriptors:
|
|
27
|
+
descriptors: zod_1.z.array(zod_1.z.object({ uuid: zod_1.z.string() })),
|
|
28
28
|
})
|
|
29
29
|
.passthrough()),
|
|
30
30
|
})
|
|
@@ -5,10 +5,10 @@ const action_completed_message_1 = require("@matreshka/shared/messages/client-to
|
|
|
5
5
|
const error_message_1 = require("@matreshka/shared/messages/client-to-bff/error-message");
|
|
6
6
|
const targeted_message_1 = require("@matreshka/shared/messages/targeted-message");
|
|
7
7
|
const rxjs_1 = require("rxjs");
|
|
8
|
-
const
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
9
|
const incoming_message_observer_1 = require("../../core/utils/incoming-message-observer");
|
|
10
|
-
const errorMessagePayloadSchema =
|
|
11
|
-
message:
|
|
10
|
+
const errorMessagePayloadSchema = zod_1.z.strictObject({
|
|
11
|
+
message: zod_1.z.string(),
|
|
12
12
|
});
|
|
13
13
|
/**
|
|
14
14
|
* Hot platform-action stream: исходящее сообщение при вызове, много входящих с тем же target.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matreshka/bff",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.3",
|
|
4
4
|
"description": "Matreshka BFF: server-driven UI runtime — routing, pages, context, component DSL, and platform APIs",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"fast-xml-parser": "^5.3.3",
|
|
69
69
|
"rxjs": "^7.8.2",
|
|
70
70
|
"ws": "^8.14.2",
|
|
71
|
-
"zod": "^
|
|
71
|
+
"zod": "^4.6.7"
|
|
72
72
|
},
|
|
73
73
|
"exports": {
|
|
74
74
|
".": {
|