@dyrra/protocol 0.1.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/dist/errors.js ADDED
@@ -0,0 +1,84 @@
1
+ import { z } from "zod";
2
+ /** Коды ошибок публичного API (ТЗ 8.2). Источник правды для gateway и приложения. */
3
+ export const ErrorCode = z
4
+ .enum([
5
+ "invalid_request",
6
+ "unauthorized",
7
+ "payment_required",
8
+ "forbidden",
9
+ "scope_denied",
10
+ "not_found",
11
+ "machine_offline",
12
+ "machine_unavailable",
13
+ "machine_paused",
14
+ "machine_busy",
15
+ "permission_missing",
16
+ "lease_not_active",
17
+ "app_update_required",
18
+ "rate_limited",
19
+ "timeout",
20
+ "internal_error",
21
+ "hidden_app_active",
22
+ "denied_by_user",
23
+ "confirmation_timeout",
24
+ "snapshot_expired",
25
+ "link_session_expired",
26
+ "app_not_frontmost",
27
+ "recording_not_shared",
28
+ "machine_already_linked_to_other_user",
29
+ ])
30
+ .meta({ id: "ErrorCode" });
31
+ export const ApiError = z
32
+ .object({
33
+ error: z.object({
34
+ code: ErrorCode,
35
+ message: z.string(),
36
+ request_id: z.string(),
37
+ details: z.record(z.string(), z.unknown()).optional(),
38
+ }),
39
+ })
40
+ .meta({ id: "ApiError" });
41
+ /** HTTP-статус для каждого кода. Единственное место, где задаётся это соответствие. */
42
+ export const ERROR_HTTP_STATUS = {
43
+ invalid_request: 400,
44
+ unauthorized: 401,
45
+ payment_required: 402,
46
+ forbidden: 403,
47
+ scope_denied: 403,
48
+ not_found: 404,
49
+ machine_offline: 409,
50
+ machine_unavailable: 409,
51
+ machine_paused: 409,
52
+ machine_busy: 409,
53
+ permission_missing: 409,
54
+ lease_not_active: 409,
55
+ app_update_required: 426,
56
+ rate_limited: 429,
57
+ timeout: 504,
58
+ internal_error: 500,
59
+ hidden_app_active: 409,
60
+ denied_by_user: 403,
61
+ confirmation_timeout: 408,
62
+ snapshot_expired: 410,
63
+ // 410: ссылка существовала, но её время вышло — это не «не найдено».
64
+ link_session_expired: 410,
65
+ // 409: активно не то приложение — ввод не выполнен, чтобы не уйти в чужое окно.
66
+ app_not_frontmost: 409,
67
+ recording_not_shared: 403,
68
+ machine_already_linked_to_other_user: 409,
69
+ };
70
+ /** Ошибка домена, которую и gateway, и RPC-слой превращают в ApiError. */
71
+ export class DyrraError extends Error {
72
+ code;
73
+ details;
74
+ constructor(code, message, details) {
75
+ super(message ?? code);
76
+ this.code = code;
77
+ this.details = details;
78
+ this.name = "DyrraError";
79
+ }
80
+ get status() {
81
+ return ERROR_HTTP_STATUS[this.code];
82
+ }
83
+ }
84
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qFAAqF;AACrF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC;KACvB,IAAI,CAAC;IACJ,iBAAiB;IACjB,cAAc;IACd,kBAAkB;IAClB,WAAW;IACX,cAAc;IACd,WAAW;IACX,iBAAiB;IACjB,qBAAqB;IACrB,gBAAgB;IAChB,cAAc;IACd,oBAAoB;IACpB,kBAAkB;IAClB,qBAAqB;IACrB,cAAc;IACd,SAAS;IACT,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,sBAAsB;IACtB,kBAAkB;IAClB,sBAAsB;IACtB,mBAAmB;IACnB,sBAAsB;IACtB,sCAAsC;CACvC,CAAC;KACD,IAAI,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;AAG7B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC;KACtB,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,OAAO,E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CACF"}
@@ -0,0 +1,10 @@
1
+ export * from "./common.js";
2
+ export * from "./endpoints.js";
3
+ export * from "./errors.js";
4
+ export * from "./actions.js";
5
+ export * from "./screen.js";
6
+ export * from "./system.js";
7
+ export * from "./rpc.js";
8
+ export * from "./api.js";
9
+ export * from "./registry.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export * from "./common.js";
2
+ export * from "./endpoints.js";
3
+ export * from "./errors.js";
4
+ export * from "./actions.js";
5
+ export * from "./screen.js";
6
+ export * from "./system.js";
7
+ export * from "./rpc.js";
8
+ export * from "./api.js";
9
+ export * from "./registry.js";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC"}