libshv-js 3.16.1 → 3.20.0
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/access.d.ts +69 -0
- package/dist/access.js +98 -0
- package/dist/chainpack.d.ts +39 -0
- package/{src/chainpack.ts → dist/chainpack.js} +120 -218
- package/dist/cpcontext.d.ts +18 -0
- package/{src/cpcontext.ts → dist/cpcontext.js} +18 -27
- package/dist/cpon.d.ts +55 -0
- package/{src/cpon.ts → dist/cpon.js} +192 -292
- package/dist/index.d.ts +10 -0
- package/dist/index.js +26 -0
- package/dist/json.d.ts +3 -0
- package/{src/json.ts → dist/json.js} +31 -49
- package/dist/rpcmessage.d.ts +285 -0
- package/dist/rpcmessage.js +111 -0
- package/dist/rpcvalue.d.ts +56 -0
- package/dist/rpcvalue.js +100 -0
- package/dist/vue-shv.d.ts +91 -0
- package/{src/vue-shv.ts → dist/vue-shv.js} +104 -164
- package/dist/ws-client.d.ts +232 -0
- package/dist/ws-client.js +586 -0
- package/dist/zod.d.ts +30 -0
- package/dist/zod.js +112 -0
- package/package.json +21 -13
- package/.github/workflows/check-version-bump.yml +0 -22
- package/.github/workflows/lint.yml +0 -33
- package/.github/workflows/publish.yml +0 -24
- package/.github/workflows/test.yml +0 -31
- package/eslint.config.js +0 -103
- package/examples/websocketosaurus.html +0 -44
- package/examples/websocketosaurus.js +0 -94
- package/src/access.ts +0 -103
- package/src/rpcmessage.ts +0 -91
- package/src/rpcvalue.ts +0 -147
- package/src/ws-client.ts +0 -708
- package/src/zod.ts +0 -95
- package/test.ts +0 -110
- package/test_json.ts +0 -44
- package/test_zod.ts +0 -24
- package/tsconfig.json +0 -108
package/dist/rpcvalue.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isShvMap = exports.isMetaMap = exports.isIMap = exports.makeMetaMap = exports.makeIMap = exports.makeMap = exports.withOffset = exports.UInt = exports.RpcValueWithMetaData = exports.Double = exports.Decimal = exports.shvMapType = exports.typeName = void 0;
|
|
4
|
+
class UInt {
|
|
5
|
+
value;
|
|
6
|
+
constructor(u) {
|
|
7
|
+
if (u instanceof UInt) {
|
|
8
|
+
this.value = u.value;
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (u < 0 || !Number.isInteger(u)) {
|
|
12
|
+
throw new Error(`Invalid value '${u}' for UInt must a positive integral number`);
|
|
13
|
+
}
|
|
14
|
+
this.value = u;
|
|
15
|
+
}
|
|
16
|
+
[Symbol.toPrimitive]() {
|
|
17
|
+
return this.value;
|
|
18
|
+
}
|
|
19
|
+
toString() {
|
|
20
|
+
return `${this.value.toString()}`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.UInt = UInt;
|
|
24
|
+
class Double {
|
|
25
|
+
value;
|
|
26
|
+
constructor(u) {
|
|
27
|
+
this.value = u;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.Double = Double;
|
|
31
|
+
class Decimal {
|
|
32
|
+
mantisa;
|
|
33
|
+
exponent;
|
|
34
|
+
constructor(mantisa, exponent) {
|
|
35
|
+
if (!Number.isInteger(exponent)) {
|
|
36
|
+
throw new TypeError(`Decimal: exponent must be integral (${exponent})`);
|
|
37
|
+
}
|
|
38
|
+
this.mantisa = mantisa;
|
|
39
|
+
this.exponent = exponent;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.Decimal = Decimal;
|
|
43
|
+
const withOffset = (date, utcOffset) => {
|
|
44
|
+
const clonedDate = new Date(date);
|
|
45
|
+
clonedDate.utc_offset = utcOffset;
|
|
46
|
+
return clonedDate;
|
|
47
|
+
};
|
|
48
|
+
exports.withOffset = withOffset;
|
|
49
|
+
const shvMapType = Symbol('shvMapType');
|
|
50
|
+
exports.shvMapType = shvMapType;
|
|
51
|
+
const isShvMap = (x) => typeof x === 'object' && x[shvMapType] === 'map';
|
|
52
|
+
exports.isShvMap = isShvMap;
|
|
53
|
+
const isIMap = (x) => typeof x === 'object' && x[shvMapType] === 'imap';
|
|
54
|
+
exports.isIMap = isIMap;
|
|
55
|
+
const isMetaMap = (x) => typeof x === 'object' && x[shvMapType] === 'metamap';
|
|
56
|
+
exports.isMetaMap = isMetaMap;
|
|
57
|
+
const typeName = (x) => {
|
|
58
|
+
switch (true) {
|
|
59
|
+
case x === undefined: return 'Null';
|
|
60
|
+
case typeof x === 'boolean': return 'Bool';
|
|
61
|
+
case typeof x === 'string': return 'String';
|
|
62
|
+
case x instanceof ArrayBuffer: return 'Blob';
|
|
63
|
+
case x instanceof UInt: return 'UInt';
|
|
64
|
+
case typeof x === 'number': return 'Int';
|
|
65
|
+
case x instanceof Double: return 'Double';
|
|
66
|
+
case x instanceof Decimal: return 'Decimal';
|
|
67
|
+
case Array.isArray(x): return 'List';
|
|
68
|
+
case x instanceof Date: return 'Date';
|
|
69
|
+
case isShvMap(x): return 'ShvMap';
|
|
70
|
+
case isIMap(x): return 'IMap';
|
|
71
|
+
case isMetaMap(x): return 'MetaMap';
|
|
72
|
+
default: return '<unknown type>';
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
exports.typeName = typeName;
|
|
76
|
+
const makeMetaMap = (x = {}) => ({
|
|
77
|
+
...x,
|
|
78
|
+
[shvMapType]: 'metamap',
|
|
79
|
+
});
|
|
80
|
+
exports.makeMetaMap = makeMetaMap;
|
|
81
|
+
const makeIMap = (x = {}) => ({
|
|
82
|
+
...x,
|
|
83
|
+
[shvMapType]: 'imap',
|
|
84
|
+
});
|
|
85
|
+
exports.makeIMap = makeIMap;
|
|
86
|
+
const makeMap = (x = {}) => ({
|
|
87
|
+
...x,
|
|
88
|
+
[shvMapType]: 'map',
|
|
89
|
+
});
|
|
90
|
+
exports.makeMap = makeMap;
|
|
91
|
+
class RpcValueWithMetaData {
|
|
92
|
+
meta;
|
|
93
|
+
value;
|
|
94
|
+
constructor(meta, value) {
|
|
95
|
+
this.meta = meta;
|
|
96
|
+
this.value = value;
|
|
97
|
+
/* nothing */
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.RpcValueWithMetaData = RpcValueWithMetaData;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import { WsClient, WsClientOptionsLogin } from './ws-client';
|
|
3
|
+
import PKCE from 'js-pkce';
|
|
4
|
+
import * as z from './zod';
|
|
5
|
+
import { type shvMapType } from './rpcvalue';
|
|
6
|
+
import { RpcValue } from './rpcvalue';
|
|
7
|
+
type GlobalResourceOptions<ResourceType> = {
|
|
8
|
+
shvPath: string;
|
|
9
|
+
method: string;
|
|
10
|
+
validator: z.ZodType<ResourceType>;
|
|
11
|
+
signalName: string;
|
|
12
|
+
signalHandler: (param: RpcValue, resource: Ref<ResourceType | undefined>, reinit: () => void) => void;
|
|
13
|
+
};
|
|
14
|
+
type VueShvOptions = {
|
|
15
|
+
wsUri: string;
|
|
16
|
+
onRequest: WsClientOptionsLogin['onRequest'];
|
|
17
|
+
azureCodeRedirect?: string;
|
|
18
|
+
};
|
|
19
|
+
type ShvLocalStorage = {
|
|
20
|
+
azureAccessToken?: string;
|
|
21
|
+
azureRedirectTo?: string;
|
|
22
|
+
};
|
|
23
|
+
type ShvSessionStorage = {
|
|
24
|
+
shvLoginUser?: string;
|
|
25
|
+
shvLoginPassword?: string;
|
|
26
|
+
azureWorkflow?: z.infer<typeof OAuth2AzureWorkflowZod>;
|
|
27
|
+
};
|
|
28
|
+
declare const OAuth2AzureWorkflowZod: z.ZodCustom<{
|
|
29
|
+
type: "oauth2-azure";
|
|
30
|
+
authorizeUrl: string;
|
|
31
|
+
tokenUrl: string;
|
|
32
|
+
clientId: string;
|
|
33
|
+
scopes: string | string[];
|
|
34
|
+
} & {
|
|
35
|
+
[shvMapType]: "map";
|
|
36
|
+
}, {
|
|
37
|
+
type: "oauth2-azure";
|
|
38
|
+
authorizeUrl: string;
|
|
39
|
+
tokenUrl: string;
|
|
40
|
+
clientId: string;
|
|
41
|
+
scopes: string | string[];
|
|
42
|
+
} & {
|
|
43
|
+
[shvMapType]: "map";
|
|
44
|
+
}>;
|
|
45
|
+
export declare enum LoginFailureReason {
|
|
46
|
+
NoCredentials = 0,
|
|
47
|
+
AzureTimedOut = 1,
|
|
48
|
+
AzureUnsupported = 2,
|
|
49
|
+
CouldntLogin = 3,
|
|
50
|
+
LoggedOut = 4
|
|
51
|
+
}
|
|
52
|
+
type LoginFailure = {
|
|
53
|
+
reason: LoginFailureReason;
|
|
54
|
+
message?: string;
|
|
55
|
+
};
|
|
56
|
+
declare const makePkce: (oauthOptions: {
|
|
57
|
+
azureCodeRedirect: string;
|
|
58
|
+
clientId: string;
|
|
59
|
+
authorizeUrl: string;
|
|
60
|
+
tokenUrl: string;
|
|
61
|
+
scopes: string | string[];
|
|
62
|
+
}) => PKCE;
|
|
63
|
+
export { makePkce as azure };
|
|
64
|
+
export declare function useShv(options: VueShvOptions): {
|
|
65
|
+
azureAuth: (redirectTo?: string) => void;
|
|
66
|
+
azureHandlerError: Ref<string, string>;
|
|
67
|
+
connected: Ref<"connected" | "connecting" | "disconnected", "connected" | "connecting" | "disconnected">;
|
|
68
|
+
displayEmail: Ref<string, string>;
|
|
69
|
+
displayFullName: Ref<string, string>;
|
|
70
|
+
displayName: Ref<string, string>;
|
|
71
|
+
displayPhoto: Ref<string | undefined, string | undefined>;
|
|
72
|
+
displayShortName: Ref<string, string>;
|
|
73
|
+
getConnection: () => Promise<WsClient>;
|
|
74
|
+
handleAzureCode: () => Promise<string | void>;
|
|
75
|
+
logContents: Ref<string, string>;
|
|
76
|
+
loginFailure: Ref<LoginFailure | undefined, LoginFailure | undefined>;
|
|
77
|
+
makeGlobalResource: {
|
|
78
|
+
<ResourceType>(options: GlobalResourceOptions<ResourceType>): () => Ref<ResourceType | undefined>;
|
|
79
|
+
<ResourceType>(options: GlobalResourceOptions<ResourceType> & {
|
|
80
|
+
default: ResourceType;
|
|
81
|
+
}): () => ComputedRef<ResourceType>;
|
|
82
|
+
};
|
|
83
|
+
makeRpcCall: <ResultType>(shvPath: string, method: string, validator: z.ZodType<ResultType>) => () => Promise<Error | ResultType>;
|
|
84
|
+
makeRpcCallParam: <ResultType, ParamType extends RpcValue>(shvPath: string, method: string, _paramType: z.ZodType<ParamType>, validator: z.ZodType<ResultType>) => (param: ParamType) => Promise<Error | ResultType>;
|
|
85
|
+
rpcCall: (shvPath: string, method: string, params?: RpcValue) => Promise<Error | RpcValue>;
|
|
86
|
+
setShvCredentials: (userName: string, password: string) => void;
|
|
87
|
+
shvLocalStorage: import("@vueuse/shared").RemovableRef<ShvLocalStorage>;
|
|
88
|
+
shvLogout: () => void;
|
|
89
|
+
shvSessionStorage: import("@vueuse/shared").RemovableRef<ShvSessionStorage>;
|
|
90
|
+
};
|
|
91
|
+
export declare const fullReloadHandler: (_param: RpcValue, _resource: unknown, reinit: () => void) => void;
|