@bisondesk/core-sdk 1.0.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/README.md ADDED
File without changes
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@bisondesk/core-sdk",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "scripts": {
6
+ "clean": "rm -rf build dist lib *.tsbuildinfo",
7
+ "unittest": "echo \"No test specified\"",
8
+ "integrationtest": "echo \"No test specified\"",
9
+ "build": "npx tsc --build",
10
+ "watch": "npx tsc --build --watch"
11
+ },
12
+ "author": "Ivo Anastácio",
13
+ "dependencies": {
14
+ "@hapi/joi": "17.1.1",
15
+ "@bisondesk/commons-sdk": "1.0.0"
16
+ },
17
+ "devDependencies": {
18
+ "@types/hapi__joi": "17.1.6",
19
+ "@types/node": "14.14.37",
20
+ "typescript": "4.2.3"
21
+ }
22
+ }
@@ -0,0 +1,18 @@
1
+ //
2
+ // STATIC PICKLIST IDS
3
+ //
4
+ export const APP_LANGUAGES_PICKLIST_ID = 'appLanguages';
5
+ export const TIMEZONES_PICKLIST_ID = 'timezones';
6
+ export const COUNTRIES_PICKLIST_ID = 'countries';
7
+
8
+ //
9
+ // PICKLIST CONSTANTS
10
+ //
11
+ export const MAX_SORT_PRIORITY = 10000;
12
+ export const MIN_SORT_PRIORITY = 1;
13
+
14
+ //
15
+ // SEARCH
16
+ //
17
+ export const FILTER_RANGE_SEPARATOR = '__';
18
+ export const FILTER_MULTIPLE_SEPARATOR = '__';
@@ -0,0 +1,17 @@
1
+ export enum RecordAction {
2
+ // if you rename this, you also need to adjust the SNS subscription filters
3
+ Create = 'content.records.create',
4
+ Update = 'content.records.update',
5
+ Delete = 'content.records.delete',
6
+ }
7
+
8
+ export type ActionMessage = {
9
+ id: string;
10
+ action: RecordAction;
11
+ actionAt: string;
12
+ userId: string;
13
+ tenantId: string;
14
+ businessEntityId: string;
15
+ recordId: string;
16
+ fieldIds?: string[];
17
+ };
@@ -0,0 +1,42 @@
1
+ import { MultiLangValue } from '@bisondesk/commons-sdk/lib/types';
2
+
3
+ export enum FieldTypes {
4
+ checkbox = 'checkbox',
5
+ collaborator = 'collaborator',
6
+ date = 'date',
7
+ email = 'email',
8
+ image = 'image',
9
+ picklist = 'picklist',
10
+ multilang = 'multilang',
11
+ multiRecord = 'multiRecord',
12
+ multiline = 'multiline',
13
+ number = 'number',
14
+ phoneNumber = 'phoneNumber',
15
+ rating = 'rating',
16
+ record = 'record',
17
+ text = 'text',
18
+ location = 'location',
19
+ }
20
+
21
+ export type PhoneNumberValue = {
22
+ country?: string;
23
+ e164: string;
24
+ international: string;
25
+ national: string;
26
+ };
27
+
28
+ export type PhoneNumberRawValue = {
29
+ defaultCountry?: string;
30
+ input: string;
31
+ };
32
+
33
+ export type AttachmentValue = {
34
+ contentType: string;
35
+ fileName: string;
36
+ id: string;
37
+ size: number;
38
+ uploadedAt: string;
39
+ uploadedBy: string;
40
+ url: string;
41
+ descriptions?: string | MultiLangValue;
42
+ };
@@ -0,0 +1,67 @@
1
+ import { MultiLangValue } from '@bisondesk/commons-sdk/lib/types';
2
+ ////////////////////////////////////////////////////////////////////
3
+ // Picklist
4
+ ////////////////////////////////////////////////////////////////////
5
+
6
+ export type PicklistValueUpdateRequest = {
7
+ picklistId: string;
8
+ value: PicklistValue | NewPicklistValue;
9
+ };
10
+ export type NewPicklistValue = {
11
+ color?: string;
12
+ customId?: string;
13
+ sortPriority?: number;
14
+ titles: MultiLangValue;
15
+ };
16
+ export type PicklistValue = NewPicklistValue & {
17
+ id: string;
18
+ system?: boolean;
19
+ };
20
+ export type PicklistValueListRequest = {
21
+ picklistId: string;
22
+ limit: number;
23
+ offset: number;
24
+ };
25
+ export type PicklistValueRequest = {
26
+ picklistId: string;
27
+ valueId: string;
28
+ };
29
+ export type AdHocPicklistValues = {
30
+ [picklistId: string]: {
31
+ [valueId: string]: PicklistValue;
32
+ };
33
+ };
34
+ export type AdHocPicklistValueDisplay = {
35
+ [picklistId: string]: {
36
+ [valueId: string]: {
37
+ color?: string;
38
+ title: string;
39
+ };
40
+ };
41
+ };
42
+ export type PicklistOptionsRequest = {
43
+ picklistId: string;
44
+ lang: string;
45
+ };
46
+ export type QuickAddPicklistValue = {
47
+ customId?: string;
48
+ sortPriority?: number;
49
+ titles: MultiLangValue;
50
+ };
51
+ export type NewPicklist = {
52
+ titles: MultiLangValue;
53
+ values: QuickAddPicklistValue[];
54
+ customSort?: boolean;
55
+ customId?: string;
56
+ };
57
+ export type BasePicklist = {
58
+ customSort?: boolean;
59
+ id: string;
60
+ system?: boolean;
61
+ titles: MultiLangValue;
62
+ customId?: string;
63
+ };
64
+ export type PicklistInfo = BasePicklist & {
65
+ count: number;
66
+ modifiedAt: string;
67
+ };
@@ -0,0 +1,153 @@
1
+ import { SortFilter } from '@bisondesk/commons-sdk/lib/types';
2
+ import { FieldTypes } from './fields';
3
+
4
+ export enum ConditionType {
5
+ and = 'AND',
6
+ or = 'OR',
7
+ }
8
+
9
+ export type Filter<OP extends string = string> = {
10
+ data: string;
11
+ fieldId: string;
12
+ fieldType: FieldTypes;
13
+ operator: OP;
14
+ };
15
+
16
+ export type ComplexFilter<OP extends string = string> = {
17
+ condition: ConditionType;
18
+ filters: Array<Filter<OP> | ComplexFilter<OP>>;
19
+ };
20
+
21
+ export type SearchRequest<OP extends string = string> = {
22
+ fullText?: string;
23
+ limit: number;
24
+ offset?: number;
25
+ query?: ComplexFilter<OP>;
26
+ sortBy?: SortFilter[];
27
+ lang: string;
28
+ };
29
+
30
+ export type RecordSearchRequest<OP extends string = string> = SearchRequest<OP> & {
31
+ businessEntityId: string;
32
+ };
33
+
34
+ export type TextSearchRequest = {
35
+ businessEntityIds?: string[]; // omit to search across all valid business entities
36
+ fullText: string;
37
+ limit: number;
38
+ offset?: number;
39
+ lang: string;
40
+ };
41
+
42
+ export enum ElasticsearchOperator {
43
+ // all properties
44
+ empty = 'EMPTY',
45
+ notEmpty = 'NOT_EMPTY',
46
+ is = 'IS',
47
+ isNot = 'IS_NOT',
48
+ // number, date properties
49
+ greaterThanOrEqual = 'GTE',
50
+ greaterThan = 'GT',
51
+ lessThanEqual = 'LTE',
52
+ lessThan = 'LT',
53
+ between = 'BETWEEN',
54
+ // string properties
55
+ contains = 'CONTAINS',
56
+ notContains = 'NOT_CONTAINS',
57
+ startsWith = 'STARTS_WITH',
58
+ endsWith = 'ENDS_WITH',
59
+ }
60
+
61
+ export enum DateOperator {
62
+ after = 'GTE',
63
+ before = 'LTE',
64
+ empty = 'EMPTY',
65
+ is = 'IS',
66
+ lastMonth = 'LAST_MONTH',
67
+ lastWeek = 'LAST_WEEK',
68
+ notEmpty = 'NOT_EMPTY',
69
+ thisMonth = 'THIS_MONTH',
70
+ thisWeek = 'THIS_WEEK',
71
+ today = 'TODAY',
72
+ yesterday = 'YESTERDAY',
73
+ }
74
+
75
+ export enum NumberOperator {
76
+ between = 'BETWEEN',
77
+ empty = 'EMPTY',
78
+ greaterThan = 'GT',
79
+ greaterThanOrEqual = 'GTE',
80
+ is = 'IS',
81
+ isNot = 'IS_NOT',
82
+ lessThan = 'LT',
83
+ lessThanEqual = 'LTE',
84
+ notEmpty = 'NOT_EMPTY',
85
+ }
86
+
87
+ export enum CheckboxOperator {
88
+ empty = 'EMPTY',
89
+ is = 'IS',
90
+ notEmpty = 'NOT_EMPTY',
91
+ }
92
+
93
+ export enum PicklistOperator {
94
+ empty = 'EMPTY',
95
+ isMultiple = 'IS_MULTIPLE',
96
+ isNotMultiple = 'IS_NOT_MULTIPLE',
97
+ notEmpty = 'NOT_EMPTY',
98
+ }
99
+
100
+ export enum RatingOperator {
101
+ empty = 'EMPTY',
102
+ greaterThan = 'GT',
103
+ greaterThanOrEqual = 'GTE',
104
+ is = 'IS',
105
+ isNot = 'IS_NOT',
106
+ lessThan = 'LT',
107
+ lessThanEqual = 'LTE',
108
+ notEmpty = 'NOT_EMPTY',
109
+ }
110
+
111
+ export enum TextOperator {
112
+ contains = 'CONTAINS',
113
+ empty = 'EMPTY',
114
+ endsWith = 'ENDS_WITH',
115
+ is = 'IS',
116
+ isNot = 'IS_NOT',
117
+ notContains = 'NOT_CONTAINS',
118
+ notEmpty = 'NOT_EMPTY',
119
+ startsWith = 'STARTS_WITH',
120
+ }
121
+
122
+ export type SearchResponse<T = any> = {
123
+ took: number;
124
+ timed_out: boolean;
125
+ _scroll_id?: string;
126
+ _shards: unknown;
127
+ hits: {
128
+ total: {
129
+ value: number;
130
+ relation: 'eq' | 'gte';
131
+ };
132
+ max_score: number;
133
+ hits: Array<{
134
+ _index: string;
135
+ _type: string;
136
+ _id: string;
137
+ _score: number;
138
+ _source?: T;
139
+ _version?: number;
140
+ _explanation?: unknown;
141
+ fields?: any;
142
+ highlight?: any;
143
+ inner_hits?: any;
144
+ matched_queries?: string[];
145
+ sort?: Array<string | number>;
146
+ }>;
147
+ };
148
+ aggregations?: unknown;
149
+ };
150
+
151
+ export type FilterTransformer = (
152
+ filter: Filter<string>
153
+ ) => Filter<ElasticsearchOperator> | ComplexFilter<ElasticsearchOperator>;
@@ -0,0 +1,12 @@
1
+ export type UploadInfo = {
2
+ id: string;
3
+ uploadUrl: string;
4
+ downloadUrl: string;
5
+ };
6
+
7
+ export type GetUploadUrlRequest = {
8
+ businessEntityId: string;
9
+ fieldId: string;
10
+ fileName: string;
11
+ contentType: string;
12
+ };
@@ -0,0 +1,14 @@
1
+ import { Region } from '@bisondesk/commons-sdk/lib/types';
2
+
3
+ export type NewTenant = {
4
+ country: string;
5
+ region: Region;
6
+ name: string;
7
+ languages: string[];
8
+ subdomain: string;
9
+ };
10
+
11
+ export type Tenant = NewTenant & {
12
+ id: string;
13
+ subdomain: string;
14
+ };
@@ -0,0 +1,15 @@
1
+ import { AttachmentValue, PhoneNumberValue } from './fields';
2
+
3
+ export type User = {
4
+ active: boolean;
5
+ createdAt: string;
6
+ email: string;
7
+ firstName: string;
8
+ id: string;
9
+ language: string;
10
+ lastName: string;
11
+ phone: PhoneNumberValue;
12
+ picture?: AttachmentValue;
13
+ roles: string[];
14
+ updatedAt: string;
15
+ };
@@ -0,0 +1,27 @@
1
+ export type CountryInfo = {
2
+ code: string; // code is ISO 3166-1 alpha-2
3
+ name: string;
4
+ labels: {
5
+ city: string;
6
+ state: string;
7
+ postalCode?: string;
8
+ };
9
+ required: {
10
+ city: boolean;
11
+ state: boolean;
12
+ postalCode: boolean;
13
+ };
14
+ dialCode: number;
15
+ currencyCode: string;
16
+ states?: {
17
+ [code: string]: string; // code is ISO 3166-2
18
+ };
19
+ postalCodeFormat?: string;
20
+ postalCodeEx?: string;
21
+ };
22
+
23
+ export type Country = {
24
+ code: string;
25
+ name: string;
26
+ dialCode: number;
27
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "include": ["src"],
4
+ "compilerOptions": {
5
+ "composite": true,
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "outDir": "lib",
9
+ "rootDir": "src",
10
+ "sourceMap": true
11
+ },
12
+ "references": [{ "path": "../commons-sdk" }]
13
+ }