bigstate.client.javascript 0.0.4 → 0.0.5-alpha.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.
@@ -0,0 +1,10 @@
1
+ import { ResponseWitOutData, AuthKeys, GetObjectResponse, CreateObjectRequest, ListObjectsResponse } from '../types';
2
+ import { _apiUrl } from '../constants';
3
+ declare const objectService: {
4
+ [_apiUrl]: string;
5
+ apiUrl: string;
6
+ create(object: string, authKeys: AuthKeys, data?: CreateObjectRequest): Promise<ResponseWitOutData>;
7
+ get(object: string, authKeys: AuthKeys): Promise<GetObjectResponse>;
8
+ getList(object: string, authKeys: AuthKeys): Promise<ListObjectsResponse>;
9
+ };
10
+ export default objectService;
@@ -5,8 +5,8 @@ export interface Definition {
5
5
  resources: string[];
6
6
  }
7
7
  export interface Policy {
8
- policyId: string;
8
+ policy: string;
9
9
  definition: Definition;
10
10
  }
11
- export type ResponsePolicyList = FetchDataResponse<Policy[]>;
12
- export type ResponsePolicy = FetchDataResponse<Policy>;
11
+ export type ListPoliciesResponse = FetchDataResponse<Policy[]>;
12
+ export type GetPolicyResponse = FetchDataResponse<Policy>;
@@ -1,11 +1,11 @@
1
1
  import { _apiUrl } from '../constants';
2
- import { AuthKeys, Policy, ResponsePolicy, ResponsePolicyList, ResponseWitOutData } from '../types';
2
+ import { AuthKeys, Definition, GetPolicyResponse, ListPoliciesResponse, ResponseWitOutData } from '../types';
3
3
  declare const securityPolicyService: {
4
4
  [_apiUrl]: string;
5
5
  apiUrl: string;
6
- getList(authKeys?: AuthKeys): Promise<ResponsePolicyList>;
7
- create(data: Policy, authKeys?: AuthKeys): Promise<ResponseWitOutData>;
8
- get(policyId: string, authKeys?: AuthKeys): Promise<ResponsePolicy>;
9
- delete(policyId: string, authKeys?: AuthKeys): Promise<ResponseWitOutData>;
6
+ getList(authKeys?: AuthKeys): Promise<ListPoliciesResponse>;
7
+ create(policy: string, data: Definition, authKeys?: AuthKeys): Promise<ResponseWitOutData>;
8
+ get(policy: string, authKeys?: AuthKeys): Promise<GetPolicyResponse>;
9
+ delete(policy: string, authKeys?: AuthKeys): Promise<ResponseWitOutData>;
10
10
  };
11
11
  export default securityPolicyService;
@@ -3,10 +3,12 @@ export declare enum PrincipalType {
3
3
  App = 1,
4
4
  User = 2
5
5
  }
6
- export interface Principal {
7
- principalId: string;
6
+ export interface CreatePrincipalRequest {
8
7
  type: PrincipalType;
9
8
  name: string;
10
9
  }
11
- export type PrincipalsResponse = FetchDataResponse<Principal[]>;
12
- export type PrincipalResponse = FetchDataResponse<Principal>;
10
+ export interface Principal extends CreatePrincipalRequest {
11
+ principal: string;
12
+ }
13
+ export type ListPrincipalsResponse = FetchDataResponse<Principal[]>;
14
+ export type GetPrincipalResponse = FetchDataResponse<Principal>;
@@ -1,11 +1,13 @@
1
1
  import { AuthKeys, ResponseWitOutData } from '../types';
2
2
  import { _apiUrl } from '../constants';
3
- import { Principal, PrincipalResponse, PrincipalsResponse } from '../types';
3
+ import { GetPrincipalResponse, ListPrincipalsResponse } from '../types';
4
+ import { CreatePrincipalRequest } from './Principal';
4
5
  declare const securityPrincipalService: {
5
6
  [_apiUrl]: string;
6
7
  apiUrl: string;
7
- getList(authKeys?: AuthKeys): Promise<PrincipalsResponse>;
8
- create(data: Principal, authKeys?: AuthKeys): Promise<ResponseWitOutData>;
9
- get(principalId: string, authKeys?: AuthKeys): Promise<PrincipalResponse>;
8
+ getList(authKeys?: AuthKeys): Promise<ListPrincipalsResponse>;
9
+ create(principal: string, data: CreatePrincipalRequest, authKeys?: AuthKeys): Promise<ResponseWitOutData>;
10
+ get(principal: string, authKeys?: AuthKeys): Promise<GetPrincipalResponse>;
11
+ delete(principal: string, authKeys?: AuthKeys): Promise<ResponseWitOutData>;
10
12
  };
11
13
  export default securityPrincipalService;
@@ -1,19 +1,48 @@
1
- import { FetchDataResponse } from '../types';
1
+ import { FetchDataResponse, CreateObjectRequest } from '../types';
2
2
  export interface Version {
3
- version: string;
3
+ version: number;
4
4
  }
5
- export interface IStateResponse<T = any> extends Version {
5
+ export interface ValueRef {
6
+ valueRef: string;
7
+ }
8
+ export interface VersionInfo extends Version {
6
9
  at: string;
7
10
  rec: string;
11
+ }
12
+ export interface IStateResponse<T = any> extends VersionInfo {
13
+ ttl: string;
8
14
  value: T;
9
15
  }
10
- export interface IState<T = any> {
11
- at: string;
16
+ type WithValue<T> = {
12
17
  value: T;
18
+ valueRef?: never;
19
+ };
20
+ type WithValueRef = {
21
+ value?: never;
22
+ valueRef: string;
23
+ };
24
+ type StateBase = {
25
+ at?: string;
26
+ object?: CreateObjectRequest;
27
+ };
28
+ export type IState<T = any> = StateBase & (WithValue<T> | WithValueRef);
29
+ export interface GetStateBase {
30
+ object: string;
31
+ }
32
+ export type GetStateRequest = GetStateBase & Version;
33
+ export interface GetStateRefRequest extends GetStateBase {
34
+ valueRef: string;
35
+ }
36
+ export interface VersionRef extends Version {
37
+ object: string;
13
38
  }
14
- export interface GetStateRequest {
15
- sid: string;
16
- version?: string;
39
+ export interface ValueRefInfo extends ValueRef {
40
+ objects: VersionRef[];
17
41
  }
18
42
  export type SubjectStateResponse<T> = FetchDataResponse<IStateResponse<T>>;
19
43
  export type SetStateResponse = FetchDataResponse<Version>;
44
+ export type VersionListResponse = FetchDataResponse<VersionInfo[]>;
45
+ export type SetValueRefResponse = FetchDataResponse<ValueRef>;
46
+ export type GetValueRefResponse = FetchDataResponse<ArrayBuffer>;
47
+ export type ValueListRefResponse = FetchDataResponse<ValueRefInfo[]>;
48
+ export {};
@@ -1,10 +1,13 @@
1
- import { IState, SubjectStateResponse, AuthKeys, SetStateResponse } from '../types';
1
+ import { IState, SubjectStateResponse, AuthKeys, SetStateResponse, GetStateRequest, SetValueRefResponse, GetStateRefRequest, GetValueRefResponse, ValueListRefResponse } from '../types';
2
2
  import { _apiUrl } from '../constants';
3
- import { GetStateRequest } from './State';
4
3
  declare const stateService: {
5
4
  [_apiUrl]: string;
6
5
  apiUrl: string;
7
- setSubjectState<T>(sid: string, data: IState<T>, authKeys?: AuthKeys): Promise<SetStateResponse>;
8
- getSubjectState<T>(data: GetStateRequest, authKeys?: AuthKeys): Promise<SubjectStateResponse<T>>;
6
+ set<T>(object: string, data: IState<T>, authKeys?: AuthKeys): Promise<SetStateResponse>;
7
+ setRef(object: string, data: File, authKeys?: AuthKeys): Promise<SetValueRefResponse>;
8
+ get<T>(data: GetStateRequest, authKeys?: AuthKeys): Promise<SubjectStateResponse<T>>;
9
+ getRef(data: GetStateRefRequest, authKeys?: AuthKeys): Promise<GetValueRefResponse>;
10
+ getVersionList<T>(object: string, authKeys?: AuthKeys): Promise<SubjectStateResponse<T>>;
11
+ getRefList(object: string, authKeys?: AuthKeys): Promise<ValueListRefResponse>;
9
12
  };
10
13
  export default stateService;
@@ -1,10 +1,10 @@
1
1
  import { ResponseWitOutData, FetchDataResponse, ErrorResponse, IError, AuthKeys, BSHttpOptions, BSDeliveryWsOptions } from './common';
2
- import { SubjectResponse, ISubject, SubjectType, ISubjectResponse } from '../subjectService/Subject';
3
- import { IState, SubjectStateResponse, GetStateRequest, SetStateResponse, IStateResponse } from '../stateService/State';
4
- import { PrincipalResponse, PrincipalsResponse, Principal, PrincipalType } from '../securityPrincipalService/Principal';
5
- import { Definition, Policy, ResponsePolicy, ResponsePolicyList } from '../securityPolicyService/Policy';
6
- import { Delivery, DeliveryListResponse, DeliveryResponse, DeliveryType } from '../deliveryService/Delivery';
7
- import { AuthPrincipalRequest, AuthRequest, AuthData, IAuthInfo, ResponseAuth, ResponseAuthInfo } from '../authService/Auth';
8
- import { Message, MessageHandler, WebSocketOptions, SendHandler, ErrorHandler, OpenHandler, CloseHandler } from '../webSocketService/WebSocket';
9
- import { CreateApiKeyRequest, IApiKey, KeyId, ResponseCreateApiKey, ResponseListApiKey } from '../apiKeyService/ApiKey';
10
- export { ResponseWitOutData, FetchDataResponse, ErrorResponse, IError, AuthKeys, SubjectResponse, ISubject, SubjectType, ISubjectResponse, IState, SetStateResponse, GetStateRequest, IStateResponse, SubjectStateResponse, PrincipalResponse, PrincipalsResponse, Principal, PrincipalType, Definition, Policy, ResponsePolicyList, ResponsePolicy, Delivery, DeliveryListResponse, DeliveryResponse, DeliveryType, ResponseAuthInfo, AuthPrincipalRequest, AuthRequest, IAuthInfo, ResponseAuth, AuthData, Message, MessageHandler, WebSocketOptions, SendHandler, ErrorHandler, OpenHandler, CloseHandler, ResponseCreateApiKey, IApiKey, KeyId, CreateApiKeyRequest, ResponseListApiKey, BSHttpOptions, BSDeliveryWsOptions, };
2
+ import { IState, SubjectStateResponse, GetValueRefResponse, GetStateRequest, SetStateResponse, IStateResponse, VersionListResponse, SetValueRefResponse, GetStateRefRequest, ValueListRefResponse } from '../stateService/State';
3
+ import { GetPrincipalResponse, ListPrincipalsResponse, Principal, PrincipalType, CreatePrincipalRequest } from '../securityPrincipalService/Principal';
4
+ import { Definition, Policy, GetPolicyResponse, ListPoliciesResponse } from '../securityPolicyService/Policy';
5
+ import { CreateDeliveryRequest, Delivery, ListDeliveriesResponse, GetDeliveryResponse, DeliveryType } from '../deliveryService/Delivery';
6
+ import { AuthData, AuthenticateResponse, RegisterResponse, CreateKeyPairResponse, PublicKey, ListPublicKeysResponse } from '../authService/Auth';
7
+ import { MessageHandler, WebSocketOptions, SendHandler, ErrorHandler, OpenHandler, CloseHandler } from '../webSocketService/WebSocket';
8
+ import { ApiKeyRequest, ApiKey, CreateApiKeyResponse, ListApiKeysResponse } from '../apiKeyService/ApiKey';
9
+ import { ObjectResponse, GetObjectResponse, CreateObjectRequest, InfoObject, ObjectType, ListObjectsResponse } from '../objectService/Object';
10
+ export { ResponseWitOutData, FetchDataResponse, ErrorResponse, IError, AuthKeys, GetObjectResponse, ListObjectsResponse, ObjectResponse, CreateObjectRequest, InfoObject, ObjectType, IState, SetStateResponse, GetStateRequest, GetStateRefRequest, IStateResponse, SubjectStateResponse, SetValueRefResponse, ValueListRefResponse, VersionListResponse, GetValueRefResponse, GetPrincipalResponse, ListPrincipalsResponse, Principal, PrincipalType, CreatePrincipalRequest, Definition, Policy, ListPoliciesResponse, GetPolicyResponse, Delivery, ListDeliveriesResponse, GetDeliveryResponse, DeliveryType, CreateDeliveryRequest, AuthenticateResponse, ListPublicKeysResponse, RegisterResponse, PublicKey, CreateKeyPairResponse, AuthData, MessageHandler, WebSocketOptions, SendHandler, ErrorHandler, OpenHandler, CloseHandler, CreateApiKeyResponse, ApiKey, ApiKeyRequest, ListApiKeysResponse, BSHttpOptions, BSDeliveryWsOptions, };
@@ -1,13 +1,34 @@
1
1
  import { AuthKeys } from '../types';
2
- export interface Message {
3
- sid?: string;
4
- rec?: string;
2
+ export declare enum NotificationType {
3
+ Message = "message",
4
+ Info = "info",
5
+ Error = "error"
6
+ }
7
+ export interface MessageData {
8
+ object: string;
9
+ version: number;
10
+ rec: string;
5
11
  value?: any;
6
- error?: any;
7
- version?: string;
8
12
  }
13
+ export interface InfoData {
14
+ message: string;
15
+ }
16
+ export interface ErrorData {
17
+ error: string;
18
+ code?: string | number;
19
+ }
20
+ export type Notification = {
21
+ type: NotificationType.Error;
22
+ data: ErrorData;
23
+ } | {
24
+ type: NotificationType.Info;
25
+ data: InfoData;
26
+ } | {
27
+ type: NotificationType.Message;
28
+ data: MessageData;
29
+ };
9
30
  export type SendHandler = (deliveries: string[]) => void;
10
- export type MessageHandler = (message: Message) => void;
31
+ export type MessageHandler = (message: Notification) => void;
11
32
  export type ErrorHandler = (error: any) => void;
12
33
  export type OpenHandler = (send: SendHandler) => void;
13
34
  export type CloseHandler = (e: number | CloseEvent) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bigstate.client.javascript",
3
- "version": "0.0.4",
3
+ "version": "0.0.5-alpha.0",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -25,7 +25,8 @@
25
25
  "pack:publish": "npm run build && npm pack && npm publish --access public",
26
26
  "versionPatch": "npm version patch",
27
27
  "versionMinor": "npm version minor",
28
- "versionMajor": "npm version major"
28
+ "versionMajor": "npm version major",
29
+ "prerelease": "npm version prerelease --preid=alpha && npm run build && npm publish --tag alpha"
29
30
  },
30
31
  "keywords": [],
31
32
  "author": "bigstate",
@@ -1,15 +0,0 @@
1
- import { FetchDataResponse } from '../types';
2
- export declare enum SubjectType {
3
- Private = 1,
4
- Public = 2
5
- }
6
- export interface ISubject {
7
- name: string;
8
- desc: string;
9
- example: any;
10
- type: SubjectType;
11
- }
12
- export interface ISubjectResponse extends ISubject {
13
- sid: string;
14
- }
15
- export type SubjectResponse = FetchDataResponse<ISubjectResponse>;
@@ -1,9 +0,0 @@
1
- import { ISubject, SubjectResponse, ResponseWitOutData, AuthKeys } from '../types';
2
- import { _apiUrl } from '../constants';
3
- declare const subjectService: {
4
- [_apiUrl]: string;
5
- apiUrl: string;
6
- createSubject(data: ISubject, sid: string, authKeys: AuthKeys): Promise<ResponseWitOutData>;
7
- getSubject(sid: string, authKeys: AuthKeys): Promise<SubjectResponse>;
8
- };
9
- export default subjectService;