@steedos/client 2.2.52-beta.6 → 2.2.53-beta.2

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/LICENSE.txt CHANGED
@@ -6,14 +6,11 @@ To determine under which license you may use a file from the Steedos source code
6
6
  please resort to the header of that file.
7
7
 
8
8
  If the file has no header, the following rules apply
9
- 1. project templates are licensed under MIT, see License.MIT.txt
10
- 2. enterprise features are licensed under Steedos Enterprise Terms, see License.enterprise.txt
11
- 3. source code that is neither (1) nor (2) is licensed under AGPL, see License.AGPL.txt
9
+ 1. enterprise features are licensed under Steedos Enterprise Terms, see License.enterprise.txt
10
+ 2. source code that is neither (1) is licensed under MIT, see https://opensource.org/licenses/MIT
12
11
 
13
12
  On request, licenses under different terms are available.
14
13
 
15
- Project templates can be found in the folders steedos-projects/
16
-
17
14
  Source code of enterprise features are files that
18
15
  * are in folders named "ee" or start with "ee_", or in subfolders of such folders.
19
16
  * contain the strings "ee_" in its filename name.
@@ -0,0 +1,99 @@
1
+ import { Options, ClientResponse } from './types/client4';
2
+ import { UserProfile } from './types/users';
3
+ import { ServerError } from './types/errors';
4
+ import { Space } from './types/spaces';
5
+ import Graphql from './graphql';
6
+ export declare const HEADER_X_VERSION_ID = "X-Version-Id";
7
+ export declare const DEFAULT_LIMIT_BEFORE = 30;
8
+ export declare const DEFAULT_LIMIT_AFTER = 30;
9
+ export default class SteedosClient {
10
+ LOGIN_TOKEN_KEY: string;
11
+ LOGIN_TOKEN_EXPIRES_KEY: string;
12
+ USER_ID_KEY: string;
13
+ logToConsole: boolean;
14
+ _lastLoginTokenWhenPolled: null;
15
+ loginExpirationInDays: null;
16
+ serverVersion: string;
17
+ clusterId: string;
18
+ token: string;
19
+ spaceId: string;
20
+ authToken: string;
21
+ csrf: string;
22
+ url: string;
23
+ urlVersion: string;
24
+ userAgent: string | null;
25
+ enableLogging: boolean;
26
+ defaultHeaders: {
27
+ [x: string]: string;
28
+ };
29
+ userId: string;
30
+ diagnosticId: string;
31
+ includeCookies: boolean;
32
+ isRudderKeySet: boolean;
33
+ translations: {
34
+ connectionError: string;
35
+ unknownError: string;
36
+ };
37
+ userRoles?: string;
38
+ sobjects: {};
39
+ graphql: Graphql;
40
+ getUrl(): string;
41
+ getAbsoluteUrl(baseUrl: string): string;
42
+ setUrl(url: string): void;
43
+ setUserAgent(userAgent: string): void;
44
+ getToken(): string;
45
+ setToken(token: string): void;
46
+ getSpaceId(): string;
47
+ setSpaceId(spaceId: any): void;
48
+ getAuthToken(): string;
49
+ setCSRF(csrfToken: string): void;
50
+ setAcceptLanguage(locale: string): void;
51
+ setEnableLogging(enable: boolean): void;
52
+ setIncludeCookies(include: boolean): void;
53
+ setUserId(userId: string): void;
54
+ setUserRoles(roles: string): void;
55
+ setDiagnosticId(diagnosticId: string): void;
56
+ enableRudderEvents(): void;
57
+ getServerVersion(): string;
58
+ getUrlVersion(): string;
59
+ getBaseRoute(): string;
60
+ getAccountsRoute(): string;
61
+ getCSRFFromCookie(): string;
62
+ getOptions(options: Options): {
63
+ headers: {
64
+ [x: string]: string;
65
+ };
66
+ method?: string | undefined;
67
+ url?: string | undefined;
68
+ credentials?: "omit" | "same-origin" | "include" | undefined;
69
+ body?: any;
70
+ };
71
+ getTranslations: (url: string) => Promise<Record<string, string>>;
72
+ logClientError: (message: string, level?: string) => void;
73
+ login: (user: string | object, password: string, token?: string, deviceId?: string) => Promise<UserProfile>;
74
+ createUser: (user: UserProfile, token: string, inviteId: string, redirect: string) => any;
75
+ createSpace: (name: string) => any;
76
+ sendVerificationToken: (user: string) => Promise<UserProfile>;
77
+ getSettings: () => Promise<UserProfile>;
78
+ getMe: () => Promise<UserProfile>;
79
+ getMySpaces: () => Promise<Space[]>;
80
+ logout: () => Promise<Response>;
81
+ doFetch: <T>(url: string, options: Options) => Promise<T>;
82
+ doFetchWithResponse: <T>(url: string, options: Options) => Promise<ClientResponse<T>>;
83
+ trackEvent(category: string, event: string, props?: any): void;
84
+ changePassword: (oldPassword: string, newPassword: string) => Promise<UserProfile>;
85
+ verifyEmail: (email: string, code: string) => Promise<UserProfile>;
86
+ verifyMobile: (mobile: string, code: string) => Promise<UserProfile>;
87
+ sobject: (objectName: any) => any;
88
+ }
89
+ export declare class ClientError extends Error implements ServerError {
90
+ url?: string;
91
+ intl?: {
92
+ id: string;
93
+ defaultMessage: string;
94
+ values?: any;
95
+ };
96
+ server_error_id?: string;
97
+ status_code?: number;
98
+ constructor(baseUrl: string, data: ServerError);
99
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: (url?: any, options?: any) => any;
2
+ export default _default;
@@ -0,0 +1,8 @@
1
+ export default class Graphql {
2
+ client: any;
3
+ constructor(client: any);
4
+ query(query: string): Promise<any>;
5
+ insert(objectName: string, data: any): Promise<any>;
6
+ update(objectName: string, _id: string, data: any): Promise<any>;
7
+ delete(objectName: string, _id: string): Promise<any>;
8
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import SteedosClient, { DEFAULT_LIMIT_AFTER, DEFAULT_LIMIT_BEFORE, HEADER_X_VERSION_ID } from './client4';
2
+ export { SteedosClient, DEFAULT_LIMIT_AFTER, DEFAULT_LIMIT_BEFORE, HEADER_X_VERSION_ID, };
package/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,mDAAwG;AAGtG,wBAHK,iBAAa,CAGL;AAAE,oGAHM,6BAAmB,OAGN;AAAE,qGAHM,8BAAoB,OAGN;AAAE,oGAHM,6BAAmB,OAGN"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mDAAwG;AAGtG,wBAHK,iBAAa,CAGL;AAAE,oGAHM,6BAAmB,OAGN;AAAE,qGAHM,8BAAoB,OAGN;AAAE,oGAHM,6BAAmB,OAGN"}
@@ -0,0 +1,63 @@
1
+ import { Filters, Fields, Options, Record } from './types/sobject';
2
+ export default class SObject {
3
+ client: any;
4
+ objectName: string;
5
+ constructor(client: any, objectName: any);
6
+ private getFilter;
7
+ private getSelect;
8
+ private getQueryParams;
9
+ /**
10
+ * Find and fetch records which matches given conditions
11
+ *
12
+ * @param {String|Array} [filters] - filtering records
13
+ * @param {String|Array} [fields] - Fields to fetch.
14
+ * @param {Object} [options] - Query options.
15
+ * @param {Number} [options.$top] - Maximum number of records the query will return.
16
+ * @param {Number} [options.$skip] - Synonym of options.offset.
17
+ * @param {String} [options.$orderby] - sorting.
18
+ * @param {boolean} [options.$count] - count.
19
+ * @returns {Promise<Array<Record>>}
20
+ */
21
+ find(filters: Filters, fields: Fields, options: Options): Promise<any>;
22
+ /**
23
+ * TODO 根据条件查询数据,返回1条($top = 1)。
24
+ * @param filters
25
+ * @param fields
26
+ * @param options
27
+ * @returns {Promise<Record>}
28
+ */
29
+ findOne(filters: Filters, fields: Fields, options: Options): Promise<void>;
30
+ /**
31
+ * TODO 根据id查询数据。
32
+ * @param id
33
+ * @param fields
34
+ */
35
+ record(id: string, fields: Fields): Promise<void>;
36
+ /**
37
+ * TODO 根据ids查询数据。
38
+ * @param ids
39
+ * @param fields
40
+ */
41
+ retrieve(ids: Array<string>, fields: Fields): Promise<void>;
42
+ /**
43
+ * TODO 写入数据,并返回新记录
44
+ * @param doc
45
+ */
46
+ insert(doc: Record): Promise<void>;
47
+ /**
48
+ * TODO 根据id,修改记录,并返回新记录
49
+ * @param id
50
+ * @param doc
51
+ */
52
+ update(id: string, doc: Record): Promise<void>;
53
+ /**
54
+ * TODO 根据id, 删除记录
55
+ * @param id
56
+ */
57
+ delete(id: string): Promise<void>;
58
+ /**
59
+ * TODO 返回满足条件的记录数
60
+ * @param filters
61
+ */
62
+ count(filters: Filters): Promise<void>;
63
+ }
@@ -0,0 +1,36 @@
1
+ export declare type logLevel = 'ERROR' | 'WARNING' | 'INFO';
2
+ export declare type ClientResponse<T> = {
3
+ response: Response;
4
+ headers: Map<string, string>;
5
+ data: T;
6
+ };
7
+ declare type ErrorOffline = {
8
+ message: string;
9
+ url: string;
10
+ };
11
+ declare type ErrorInvalidResponse = {
12
+ intl: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ };
16
+ };
17
+ export declare type ErrorApi = {
18
+ message: string;
19
+ server_error_id: string;
20
+ status_code: number;
21
+ url: string;
22
+ };
23
+ export declare type Client4Error = ErrorOffline | ErrorInvalidResponse | ErrorApi;
24
+ export declare type Options = {
25
+ headers?: {
26
+ [x: string]: string;
27
+ };
28
+ method?: string;
29
+ url?: string;
30
+ credentials?: 'omit' | 'same-origin' | 'include';
31
+ body?: any;
32
+ };
33
+ export declare type StatusOK = {
34
+ status: 'OK';
35
+ };
36
+ export {};
@@ -0,0 +1,12 @@
1
+ export declare type ServerError = {
2
+ server_error_id?: string;
3
+ stack?: string;
4
+ intl?: {
5
+ id: string;
6
+ defaultMessage: string;
7
+ values?: any;
8
+ };
9
+ message: string;
10
+ status_code?: number;
11
+ url?: string;
12
+ };
@@ -0,0 +1,24 @@
1
+ declare type Optional<T> = T | undefined;
2
+ export interface Dictionary<T = unknown> {
3
+ [key: string]: Optional<T>;
4
+ }
5
+ export declare type JsonPrimitive = null | boolean | number | string;
6
+ /**
7
+ * Any valid JSON collection value.
8
+ */
9
+ export declare type JsonCollection = JsonMap | JsonArray;
10
+ /**
11
+ * Any valid JSON value.
12
+ */
13
+ export declare type AnyJson = JsonPrimitive | JsonCollection;
14
+ /**
15
+ * Any JSON-compatible object.
16
+ */
17
+ export interface JsonMap extends Dictionary<AnyJson> {
18
+ }
19
+ /**
20
+ * Any JSON-compatible array.
21
+ */
22
+ export interface JsonArray extends Array<AnyJson> {
23
+ }
24
+ export {};
@@ -0,0 +1,12 @@
1
+ import { JsonMap } from './json';
2
+ export declare type Filters = string | Array<any>;
3
+ export declare type Fields = string | Array<string>;
4
+ export declare type Options = {
5
+ $top?: Number;
6
+ $skip?: Number;
7
+ $orderby?: Number;
8
+ $count?: boolean;
9
+ $filter?: Filters;
10
+ $select?: Fields;
11
+ };
12
+ export declare type Record = JsonMap;
@@ -0,0 +1,16 @@
1
+ import { IDMappedObjects } from './utilities';
2
+ export declare type Space = {
3
+ _id: string;
4
+ name: string;
5
+ };
6
+ export declare type SpaceUser = {
7
+ _id: string;
8
+ space: string;
9
+ user: string;
10
+ };
11
+ export declare type SpacesState = {
12
+ currentSpaceId: string;
13
+ spaces: IDMappedObjects<Space>;
14
+ mySpaces: IDMappedObjects<Space>;
15
+ mySpacesCount: number;
16
+ };
@@ -0,0 +1,18 @@
1
+ import { IDMappedObjects } from './utilities';
2
+ export declare type UserProfile = {
3
+ _id: string;
4
+ create_at: number;
5
+ update_at: number;
6
+ delete_at: number;
7
+ username: string;
8
+ password: string;
9
+ email: string;
10
+ email_verified: boolean;
11
+ name: string;
12
+ failed_attempts: number;
13
+ locale: string;
14
+ };
15
+ export declare type UsersState = {
16
+ currentUserId: string;
17
+ users: IDMappedObjects<UserProfile>;
18
+ };
@@ -0,0 +1,53 @@
1
+ export declare type $ID<E extends {
2
+ _id: string;
3
+ }> = E['_id'];
4
+ export declare type $UserID<E extends {
5
+ user_id: string;
6
+ }> = E['user_id'];
7
+ export declare type $Name<E extends {
8
+ name: string;
9
+ }> = E['name'];
10
+ export declare type $Username<E extends {
11
+ username: string;
12
+ }> = E['username'];
13
+ export declare type $Email<E extends {
14
+ email: string;
15
+ }> = E['email'];
16
+ export declare type RelationOneToOne<E extends {
17
+ _id: string;
18
+ }, T> = {
19
+ [x in $ID<E>]: T;
20
+ };
21
+ export declare type RelationOneToMany<E1 extends {
22
+ _id: string;
23
+ }, E2 extends {
24
+ _id: string;
25
+ }> = {
26
+ [x in $ID<E1>]: Array<$ID<E2>>;
27
+ };
28
+ export declare type IDMappedObjects<E extends {
29
+ _id: string;
30
+ }> = RelationOneToOne<E, E>;
31
+ export declare type UserIDMappedObjects<E extends {
32
+ user_id: string;
33
+ }> = {
34
+ [x in $UserID<E>]: E;
35
+ };
36
+ export declare type NameMappedObjects<E extends {
37
+ name: string;
38
+ }> = {
39
+ [x in $Name<E>]: E;
40
+ };
41
+ export declare type UsernameMappedObjects<E extends {
42
+ username: string;
43
+ }> = {
44
+ [x in $Username<E>]: E;
45
+ };
46
+ export declare type EmailMappedObjects<E extends {
47
+ email: string;
48
+ }> = {
49
+ [x in $Email<E>]: E;
50
+ };
51
+ export declare type Dictionary<T> = {
52
+ [key: string]: T;
53
+ };
@@ -0,0 +1,2 @@
1
+ import { Dictionary } from '../types/utilities';
2
+ export declare function buildQueryString(parameters: Dictionary<any>): string;
@@ -0,0 +1 @@
1
+ export declare function cleanUrlForLogging(baseUrl: any, apiUrl: any): any;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@steedos/client",
4
- "version": "2.2.52-beta.6",
4
+ "version": "2.2.53-beta.2",
5
5
  "description": "client lib for steedos",
6
6
  "main": "lib/index.js",
7
7
  "scripts": {
@@ -10,16 +10,15 @@
10
10
  "test": "mocha test/unit/*.ts"
11
11
  },
12
12
  "devDependencies": {
13
- "ts-node": "^8.0.3",
14
- "typescript": "3.5.3"
13
+ "typescript": "4.6.3"
15
14
  },
16
15
  "publishConfig": {
17
16
  "access": "public"
18
17
  },
19
18
  "license": "MIT",
20
19
  "dependencies": {
21
- "@steedos/filters": "2.2.52-beta.6",
22
- "node-fetch": "^2.6.1"
20
+ "@steedos/filters": "2.2.53-beta.2",
21
+ "node-fetch": "^2.6.7"
23
22
  },
24
- "gitHead": "d255340f2b91b94ecc809ac7840552997b8ff5f5"
23
+ "gitHead": "d6d2230d72af49a72fc546093b553463cd2f0e9d"
25
24
  }