@bodhiapp/bodhi-js-core 0.0.19 → 0.0.21
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/bodhi-core.cjs.js +4 -4
- package/dist/bodhi-core.esm.js +192 -224
- package/dist/cli/setup-modal.js +2 -2
- package/dist/errors.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/onboarding/config.d.ts +1 -1
- package/dist/onboarding/modal.d.ts +2 -2
- package/dist/onboarding/protocol-utils.d.ts +1 -1
- package/dist/protocol-utils-DEc2a39H.cjs +1 -0
- package/dist/{index-BKHQmfVT.js → protocol-utils-VhZr6CdP.js} +78 -87
- package/dist/types/api.d.ts +1 -1
- package/dist/types/client-state.d.ts +1 -1
- package/dist/types/index.cjs.js +1 -1
- package/dist/types/index.esm.js +3 -3
- package/dist/types/platform.d.ts +1 -1
- package/package.json +3 -1
- package/dist/index-DYd1YrrH.cjs +0 -1
package/dist/errors.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export * from './toolset-utils';
|
|
|
19
19
|
export * from './direct-client-base';
|
|
20
20
|
export * from './facade-client-base';
|
|
21
21
|
export * from './openai-client-compat';
|
|
22
|
-
export { isOperationError, type OperationError } from '
|
|
22
|
+
export { isOperationError, type OperationError } from '@bodhiapp/bodhi-browser-types';
|
|
23
23
|
export { BUILD_MODE as CORE_BUILD_MODE } from './build-info';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MessageType, RequestMessage, ResponsePayload } from '
|
|
2
|
-
import type * as ModalTypes from '@bodhiapp/setup-modal
|
|
1
|
+
import { MessageType, RequestMessage, ResponsePayload } from '@bodhiapp/setup-modal-types';
|
|
2
|
+
import type * as ModalTypes from '@bodhiapp/setup-modal-types';
|
|
3
3
|
/**
|
|
4
4
|
* Async handler for modal requests
|
|
5
5
|
* Supports both sync and async responses
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessageType, RequestPayload, ResponsePayload, RequestMessage, RequestId } from '
|
|
1
|
+
import { MessageType, RequestPayload, ResponsePayload, RequestMessage, RequestId } from '@bodhiapp/setup-modal-types';
|
|
2
2
|
/** Build fire-and-forget event message */
|
|
3
3
|
export declare function buildEvent<T extends MessageType>(type: T, payload: RequestPayload<T>): {
|
|
4
4
|
kind: "event";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const E=require("@bodhiapp/bodhi-browser-types");function _(e){return e!==null&&typeof e=="object"&&"error"in e&&!("body"in e)&&E.isOperationErrorStructure(e.error)}function y(e){return"body"in e&&"status"in e&&typeof e.status=="number"&&e.status>=200&&e.status<300}function p(e){return"body"in e&&"status"in e&&typeof e.status=="number"&&e.status>=400&&E.isOpenAiApiErrorBody(e.body)}const I=(e,t,r,n)=>{const c=new Error(e);return c.response={status:t,body:r,headers:n},c},O=(e,t)=>{const r=new Error(e);return r.error={message:e,type:t},r},i={NOT_REACHABLE:{message:"server is not reachable on given url",type:"network_error"},SERVER_NOT_READY:{message:"server is not in ready state, configure to complete setup",type:"extension_error"}},a={status:"not-reachable",version:null,error:i.NOT_REACHABLE},o={status:"pending-extension-ready",version:null,error:null},d={status:"not-connected",version:null,error:null};function s(e){return e.status==="ready"}function v(e,t="unknown",r=i.SERVER_NOT_READY){return{status:e,version:t,error:r}}function u(e){return e.type==="extension"}function R(e){return e.type==="direct"}function f(e){return typeof e.server=="object"&&e.server.status!=="not-connected"&&s(e.server)}function N(e){return e.url!==null}const D={type:"direct",url:null,server:d};function C(e,t="unknown"){return{type:"direct",server:{status:"ready",version:t,error:null},url:e}}function x(e){return{type:"direct",server:a,url:e}}function b(e,t){return{type:"direct",server:t,url:e}}const S={type:"extension",extension:"not-initialized",extensionId:null,server:o},l={type:"extension",extension:"not-found",extensionId:null,server:o};function L(e){return e.extension==="ready"&&e.server.status!=="pending-extension-ready"&&s(e.server)}function A(e){return e.extension==="ready"}function h(){return S}function B(){return l}function g(e){return u(e)?A(e):N(e)}function k(e){return e.server}function V(e){return u(e)?e.extensionId??void 0:void 0}function w(e){return R(e)?e.url??void 0:void 0}function H(e){return e.status==="authenticated"}function K(e){return e.status==="loading"}function U(e){return e.status==="error"}const X={status:"idle",user:null,accessToken:null,error:null},q=()=>{};function F(e,t){return{kind:"event",type:e,payload:t}}function T(e,t,r){return{kind:"response",type:t,requestId:e,payload:r}}function P(e,t){return{kind:"error",requestId:e,error:t}}function Y(e,t){const r=t[e.type];if(!r)return null;const n=r(e.payload);return T(e.requestId,e.type,n)}exports.BACKEND_SERVER_NOT_CONNECTED=d;exports.BACKEND_SERVER_NOT_REACHABLE=a;exports.DIRECT_STATE_NOT_INITIALIZED=D;exports.EXTENSION_STATE_NOT_FOUND=l;exports.EXTENSION_STATE_NOT_INITIALIZED=S;exports.INITIAL_AUTH_STATE=X;exports.NOOP_STATE_CALLBACK=q;exports.PENDING_EXTENSION_READY=o;exports.SERVER_ERROR_CODES=i;exports.backendServerNotReady=v;exports.buildError=P;exports.buildEvent=F;exports.buildResponse=T;exports.createApiError=I;exports.createDirectStateNotReachable=x;exports.createDirectStateNotReady=b;exports.createDirectStateReady=C;exports.createExtensionStateNotFound=B;exports.createExtensionStateNotInitialized=h;exports.createOperationError=O;exports.getBackendServerState=k;exports.getExtensionId=V;exports.getServerUrl=w;exports.handleRequest=Y;exports.isApiResultError=p;exports.isApiResultOperationError=_;exports.isApiResultSuccess=y;exports.isAuthError=U;exports.isAuthLoading=K;exports.isAuthenticated=H;exports.isClientReady=g;exports.isDirectClientReady=N;exports.isDirectServerReady=f;exports.isDirectState=R;exports.isExtensionClientReady=A;exports.isExtensionServerReady=L;exports.isExtensionState=u;exports.isServerReady=s;
|
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
return e !== null && typeof e == "object";
|
|
3
|
-
}
|
|
4
|
-
function E(e) {
|
|
5
|
-
return s(e) && "error" in e && s(e.error) && "message" in e.error && typeof e.error.message == "string" && "type" in e.error && typeof e.error.type == "string";
|
|
6
|
-
}
|
|
7
|
-
function d(e) {
|
|
8
|
-
return s(e) && "message" in e && typeof e.message == "string" && "type" in e && typeof e.type == "string";
|
|
9
|
-
}
|
|
1
|
+
import { isOperationErrorStructure as c, isOpenAiApiErrorBody as d } from "@bodhiapp/bodhi-browser-types";
|
|
10
2
|
function _(e) {
|
|
11
|
-
return e !== null && typeof e == "object" && "error" in e && !("body" in e) &&
|
|
3
|
+
return e !== null && typeof e == "object" && "error" in e && !("body" in e) && c(e.error);
|
|
12
4
|
}
|
|
13
5
|
function v(e) {
|
|
14
6
|
return "body" in e && "status" in e && typeof e.status == "number" && e.status >= 200 && e.status < 300;
|
|
15
7
|
}
|
|
16
8
|
function T(e) {
|
|
17
|
-
return "body" in e && "status" in e && typeof e.status == "number" && e.status >= 400 &&
|
|
9
|
+
return "body" in e && "status" in e && typeof e.status == "number" && e.status >= 400 && d(e.body);
|
|
18
10
|
}
|
|
19
11
|
const I = (e, n, r, t) => {
|
|
20
12
|
const o = new Error(e);
|
|
@@ -22,7 +14,7 @@ const I = (e, n, r, t) => {
|
|
|
22
14
|
}, O = (e, n) => {
|
|
23
15
|
const r = new Error(e);
|
|
24
16
|
return r.error = { message: e, type: n }, r;
|
|
25
|
-
},
|
|
17
|
+
}, s = {
|
|
26
18
|
NOT_REACHABLE: {
|
|
27
19
|
message: "server is not reachable on given url",
|
|
28
20
|
type: "network_error"
|
|
@@ -31,159 +23,158 @@ const I = (e, n, r, t) => {
|
|
|
31
23
|
message: "server is not in ready state, configure to complete setup",
|
|
32
24
|
type: "extension_error"
|
|
33
25
|
}
|
|
34
|
-
},
|
|
26
|
+
}, E = {
|
|
35
27
|
status: "not-reachable",
|
|
36
28
|
version: null,
|
|
37
|
-
error:
|
|
38
|
-
},
|
|
29
|
+
error: s.NOT_REACHABLE
|
|
30
|
+
}, i = {
|
|
39
31
|
status: "pending-extension-ready",
|
|
40
32
|
version: null,
|
|
41
33
|
error: null
|
|
42
|
-
},
|
|
34
|
+
}, l = {
|
|
43
35
|
status: "not-connected",
|
|
44
36
|
version: null,
|
|
45
37
|
error: null
|
|
46
38
|
};
|
|
47
|
-
function
|
|
39
|
+
function u(e) {
|
|
48
40
|
return e.status === "ready";
|
|
49
41
|
}
|
|
50
|
-
function x(e, n = "unknown", r =
|
|
42
|
+
function x(e, n = "unknown", r = s.SERVER_NOT_READY) {
|
|
51
43
|
return {
|
|
52
44
|
status: e,
|
|
53
45
|
version: n,
|
|
54
46
|
error: r
|
|
55
47
|
};
|
|
56
48
|
}
|
|
57
|
-
function
|
|
49
|
+
function a(e) {
|
|
58
50
|
return e.type === "extension";
|
|
59
51
|
}
|
|
60
|
-
function
|
|
52
|
+
function y(e) {
|
|
61
53
|
return e.type === "direct";
|
|
62
54
|
}
|
|
63
55
|
function D(e) {
|
|
64
|
-
return typeof e.server == "object" && e.server.status !== "not-connected" &&
|
|
56
|
+
return typeof e.server == "object" && e.server.status !== "not-connected" && u(e.server);
|
|
65
57
|
}
|
|
66
|
-
function
|
|
58
|
+
function p(e) {
|
|
67
59
|
return e.url !== null;
|
|
68
60
|
}
|
|
69
|
-
const
|
|
61
|
+
const b = {
|
|
70
62
|
type: "direct",
|
|
71
63
|
url: null,
|
|
72
|
-
server:
|
|
64
|
+
server: l
|
|
73
65
|
};
|
|
74
66
|
function C(e, n = "unknown") {
|
|
75
67
|
return { type: "direct", server: { status: "ready", version: n, error: null }, url: e };
|
|
76
68
|
}
|
|
77
69
|
function h(e) {
|
|
78
|
-
return { type: "direct", server:
|
|
70
|
+
return { type: "direct", server: E, url: e };
|
|
79
71
|
}
|
|
80
72
|
function k(e, n) {
|
|
81
73
|
return { type: "direct", server: n, url: e };
|
|
82
74
|
}
|
|
83
|
-
const
|
|
75
|
+
const f = {
|
|
84
76
|
type: "extension",
|
|
85
77
|
extension: "not-initialized",
|
|
86
78
|
extensionId: null,
|
|
87
|
-
server:
|
|
88
|
-
},
|
|
79
|
+
server: i
|
|
80
|
+
}, R = {
|
|
89
81
|
type: "extension",
|
|
90
82
|
extension: "not-found",
|
|
91
83
|
extensionId: null,
|
|
92
|
-
server:
|
|
84
|
+
server: i
|
|
93
85
|
};
|
|
94
86
|
function B(e) {
|
|
95
|
-
return e.extension === "ready" && e.server.status !== "pending-extension-ready" &&
|
|
87
|
+
return e.extension === "ready" && e.server.status !== "pending-extension-ready" && u(e.server);
|
|
96
88
|
}
|
|
97
89
|
function A(e) {
|
|
98
90
|
return e.extension === "ready";
|
|
99
91
|
}
|
|
100
92
|
function L() {
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
function b() {
|
|
104
|
-
return N;
|
|
93
|
+
return f;
|
|
105
94
|
}
|
|
106
|
-
function
|
|
107
|
-
return
|
|
95
|
+
function g() {
|
|
96
|
+
return R;
|
|
108
97
|
}
|
|
109
98
|
function w(e) {
|
|
110
|
-
return e
|
|
99
|
+
return a(e) ? A(e) : p(e);
|
|
111
100
|
}
|
|
112
101
|
function H(e) {
|
|
113
|
-
return
|
|
102
|
+
return e.server;
|
|
114
103
|
}
|
|
115
104
|
function V(e) {
|
|
116
|
-
return
|
|
105
|
+
return a(e) ? e.extensionId ?? void 0 : void 0;
|
|
117
106
|
}
|
|
118
|
-
function
|
|
107
|
+
function m(e) {
|
|
108
|
+
return y(e) ? e.url ?? void 0 : void 0;
|
|
109
|
+
}
|
|
110
|
+
function j(e) {
|
|
119
111
|
return e.status === "authenticated";
|
|
120
112
|
}
|
|
121
|
-
function
|
|
113
|
+
function q(e) {
|
|
122
114
|
return e.status === "loading";
|
|
123
115
|
}
|
|
124
|
-
function
|
|
116
|
+
function z(e) {
|
|
125
117
|
return e.status === "error";
|
|
126
118
|
}
|
|
127
|
-
const
|
|
119
|
+
const F = {
|
|
128
120
|
status: "idle",
|
|
129
121
|
user: null,
|
|
130
122
|
accessToken: null,
|
|
131
123
|
error: null
|
|
132
|
-
},
|
|
124
|
+
}, K = () => {
|
|
133
125
|
};
|
|
134
|
-
function
|
|
126
|
+
function P(e, n) {
|
|
135
127
|
return { kind: "event", type: e, payload: n };
|
|
136
128
|
}
|
|
137
|
-
function
|
|
129
|
+
function N(e, n, r) {
|
|
138
130
|
return { kind: "response", type: n, requestId: e, payload: r };
|
|
139
131
|
}
|
|
140
|
-
function
|
|
132
|
+
function U(e, n) {
|
|
141
133
|
return { kind: "error", requestId: e, error: n };
|
|
142
134
|
}
|
|
143
|
-
function
|
|
135
|
+
function X(e, n) {
|
|
144
136
|
const r = n[e.type];
|
|
145
137
|
if (!r) return null;
|
|
146
138
|
const t = r(e.payload);
|
|
147
|
-
return
|
|
139
|
+
return N(e.requestId, e.type, t);
|
|
148
140
|
}
|
|
149
141
|
export {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
F,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
U as c,
|
|
142
|
+
j as A,
|
|
143
|
+
l as B,
|
|
144
|
+
U as C,
|
|
145
|
+
b as D,
|
|
146
|
+
R as E,
|
|
147
|
+
P as F,
|
|
148
|
+
N as G,
|
|
149
|
+
X as H,
|
|
150
|
+
F as I,
|
|
151
|
+
K as N,
|
|
152
|
+
i as P,
|
|
153
|
+
s as S,
|
|
154
|
+
_ as a,
|
|
155
|
+
v as b,
|
|
156
|
+
I as c,
|
|
166
157
|
O as d,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
158
|
+
E as e,
|
|
159
|
+
x as f,
|
|
160
|
+
h as g,
|
|
161
|
+
k as h,
|
|
162
|
+
T as i,
|
|
163
|
+
C as j,
|
|
164
|
+
g as k,
|
|
165
|
+
L as l,
|
|
166
|
+
f as m,
|
|
167
|
+
H as n,
|
|
168
|
+
V as o,
|
|
169
|
+
m as p,
|
|
170
|
+
w as q,
|
|
171
|
+
p as r,
|
|
172
|
+
D as s,
|
|
173
|
+
y as t,
|
|
174
|
+
A as u,
|
|
175
|
+
B as v,
|
|
176
|
+
a as w,
|
|
177
|
+
u as x,
|
|
178
|
+
z as y,
|
|
179
|
+
q as z
|
|
189
180
|
};
|
package/dist/types/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiResponse, OperationErrorResponse } from '
|
|
1
|
+
import { ApiResponse, OperationErrorResponse } from '@bodhiapp/bodhi-browser-types';
|
|
2
2
|
import { OpenAiApiError } from '@bodhiapp/ts-client';
|
|
3
3
|
/**
|
|
4
4
|
* Public API result type - discriminated union without protocol fields
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OperationErrorResponse } from '
|
|
1
|
+
import { OperationErrorResponse } from '@bodhiapp/bodhi-browser-types';
|
|
2
2
|
/**
|
|
3
3
|
* Serialized direct client state for persistence
|
|
4
4
|
* Stores minimal state needed to restore direct connection
|
package/dist/types/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../protocol-utils-DEc2a39H.cjs");exports.BACKEND_SERVER_NOT_CONNECTED=e.BACKEND_SERVER_NOT_CONNECTED;exports.BACKEND_SERVER_NOT_REACHABLE=e.BACKEND_SERVER_NOT_REACHABLE;exports.DIRECT_STATE_NOT_INITIALIZED=e.DIRECT_STATE_NOT_INITIALIZED;exports.EXTENSION_STATE_NOT_FOUND=e.EXTENSION_STATE_NOT_FOUND;exports.EXTENSION_STATE_NOT_INITIALIZED=e.EXTENSION_STATE_NOT_INITIALIZED;exports.INITIAL_AUTH_STATE=e.INITIAL_AUTH_STATE;exports.NOOP_STATE_CALLBACK=e.NOOP_STATE_CALLBACK;exports.PENDING_EXTENSION_READY=e.PENDING_EXTENSION_READY;exports.SERVER_ERROR_CODES=e.SERVER_ERROR_CODES;exports.backendServerNotReady=e.backendServerNotReady;exports.buildError=e.buildError;exports.buildEvent=e.buildEvent;exports.buildResponse=e.buildResponse;exports.createApiError=e.createApiError;exports.createDirectStateNotReachable=e.createDirectStateNotReachable;exports.createDirectStateNotReady=e.createDirectStateNotReady;exports.createDirectStateReady=e.createDirectStateReady;exports.createExtensionStateNotFound=e.createExtensionStateNotFound;exports.createExtensionStateNotInitialized=e.createExtensionStateNotInitialized;exports.createOperationError=e.createOperationError;exports.getBackendServerState=e.getBackendServerState;exports.getExtensionId=e.getExtensionId;exports.getServerUrl=e.getServerUrl;exports.handleRequest=e.handleRequest;exports.isApiResultError=e.isApiResultError;exports.isApiResultOperationError=e.isApiResultOperationError;exports.isApiResultSuccess=e.isApiResultSuccess;exports.isAuthError=e.isAuthError;exports.isAuthLoading=e.isAuthLoading;exports.isAuthenticated=e.isAuthenticated;exports.isClientReady=e.isClientReady;exports.isDirectClientReady=e.isDirectClientReady;exports.isDirectServerReady=e.isDirectServerReady;exports.isDirectState=e.isDirectState;exports.isExtensionClientReady=e.isExtensionClientReady;exports.isExtensionServerReady=e.isExtensionServerReady;exports.isExtensionState=e.isExtensionState;exports.isServerReady=e.isServerReady;
|
package/dist/types/index.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { B as s,
|
|
1
|
+
import { B as s, e as t, D as r, E as i, m as E, I as N, N as S, P as n, S as R, f as o, C as A, F as T, G as _, c as d, g as c, h as I, j as D, k as O, l, d as u, n as C, o as y, p, H as v, i as x, a as L, b, y as h, z as B, A as g, q as k, r as F, s as H, t as K, u as P, v as U, w as V, x as X } from "../protocol-utils-VhZr6CdP.js";
|
|
2
2
|
export {
|
|
3
3
|
s as BACKEND_SERVER_NOT_CONNECTED,
|
|
4
4
|
t as BACKEND_SERVER_NOT_REACHABLE,
|
|
5
5
|
r as DIRECT_STATE_NOT_INITIALIZED,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
i as EXTENSION_STATE_NOT_FOUND,
|
|
7
|
+
E as EXTENSION_STATE_NOT_INITIALIZED,
|
|
8
8
|
N as INITIAL_AUTH_STATE,
|
|
9
9
|
S as NOOP_STATE_CALLBACK,
|
|
10
10
|
n as PENDING_EXTENSION_READY,
|
package/dist/types/platform.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bodhiapp/bodhi-js-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "Core types and interfaces for Bodhi Browser SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/bodhi-core.cjs.js",
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
"typecheck": "tsc --noEmit"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
+
"@bodhiapp/bodhi-browser-types": "0.0.21",
|
|
60
|
+
"@bodhiapp/setup-modal-types": "0.0.21",
|
|
59
61
|
"@bodhiapp/ts-client": "0.1.14",
|
|
60
62
|
"ua-parser-js": "^1.0.40"
|
|
61
63
|
},
|
package/dist/index-DYd1YrrH.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function i(e){return e!==null&&typeof e=="object"}function p(e){return i(e)&&"error"in e&&i(e.error)&&"message"in e.error&&typeof e.error.message=="string"&&"type"in e.error&&typeof e.error.type=="string"}function E(e){return i(e)&&"message"in e&&typeof e.message=="string"&&"type"in e&&typeof e.type=="string"}function y(e){return e!==null&&typeof e=="object"&&"error"in e&&!("body"in e)&&E(e.error)}function f(e){return"body"in e&&"status"in e&&typeof e.status=="number"&&e.status>=200&&e.status<300}function I(e){return"body"in e&&"status"in e&&typeof e.status=="number"&&e.status>=400&&p(e.body)}const O=(e,r,t,n)=>{const a=new Error(e);return a.response={status:r,body:t,headers:n},a},v=(e,r)=>{const t=new Error(e);return t.error={message:e,type:r},t},o={NOT_REACHABLE:{message:"server is not reachable on given url",type:"network_error"},SERVER_NOT_READY:{message:"server is not in ready state, configure to complete setup",type:"extension_error"}},d={status:"not-reachable",version:null,error:o.NOT_REACHABLE},s={status:"pending-extension-ready",version:null,error:null},R={status:"not-connected",version:null,error:null};function u(e){return e.status==="ready"}function D(e,r="unknown",t=o.SERVER_NOT_READY){return{status:e,version:r,error:t}}function c(e){return e.type==="extension"}function N(e){return e.type==="direct"}function C(e){return typeof e.server=="object"&&e.server.status!=="not-connected"&&u(e.server)}function l(e){return e.url!==null}const x={type:"direct",url:null,server:R};function g(e,r="unknown"){return{type:"direct",server:{status:"ready",version:r,error:null},url:e}}function L(e){return{type:"direct",server:d,url:e}}function h(e,r){return{type:"direct",server:r,url:e}}const S={type:"extension",extension:"not-initialized",extensionId:null,server:s},A={type:"extension",extension:"not-found",extensionId:null,server:s};function B(e){return e.extension==="ready"&&e.server.status!=="pending-extension-ready"&&u(e.server)}function _(e){return e.extension==="ready"}function b(){return S}function k(){return A}function V(e){return c(e)?_(e):l(e)}function H(e){return e.server}function K(e){return c(e)?e.extensionId??void 0:void 0}function U(e){return N(e)?e.url??void 0:void 0}function X(e){return e.status==="authenticated"}function m(e){return e.status==="loading"}function w(e){return e.status==="error"}const F={status:"idle",user:null,accessToken:null,error:null},P=()=>{};function Y(e,r){return{kind:"event",type:e,payload:r}}function T(e,r,t){return{kind:"response",type:r,requestId:e,payload:t}}function Z(e,r){return{kind:"error",requestId:e,error:r}}function q(e,r){const t=r[e.type];if(!t)return null;const n=t(e.payload);return T(e.requestId,e.type,n)}exports.BACKEND_SERVER_NOT_CONNECTED=R;exports.BACKEND_SERVER_NOT_REACHABLE=d;exports.DIRECT_STATE_NOT_INITIALIZED=x;exports.EXTENSION_STATE_NOT_FOUND=A;exports.EXTENSION_STATE_NOT_INITIALIZED=S;exports.INITIAL_AUTH_STATE=F;exports.NOOP_STATE_CALLBACK=P;exports.PENDING_EXTENSION_READY=s;exports.SERVER_ERROR_CODES=o;exports.backendServerNotReady=D;exports.buildError=Z;exports.buildEvent=Y;exports.buildResponse=T;exports.createApiError=O;exports.createDirectStateNotReachable=L;exports.createDirectStateNotReady=h;exports.createDirectStateReady=g;exports.createExtensionStateNotFound=k;exports.createExtensionStateNotInitialized=b;exports.createOperationError=v;exports.getBackendServerState=H;exports.getExtensionId=K;exports.getServerUrl=U;exports.handleRequest=q;exports.isApiResultError=I;exports.isApiResultOperationError=y;exports.isApiResultSuccess=f;exports.isAuthError=w;exports.isAuthLoading=m;exports.isAuthenticated=X;exports.isClientReady=V;exports.isDirectClientReady=l;exports.isDirectServerReady=C;exports.isDirectState=N;exports.isExtensionClientReady=_;exports.isExtensionServerReady=B;exports.isExtensionState=c;exports.isOperationErrorStructure=E;exports.isServerReady=u;
|