@allthings/sdk 6.1.0 → 6.2.0-1

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.
@@ -3,6 +3,7 @@ import { MethodHttpDelete } from './delete';
3
3
  import { MethodHttpGet } from './get';
4
4
  import { MethodAgentCreate, MethodAgentCreatePermissions } from './methods/agent';
5
5
  import { MethodAppCreate, MethodAppGetById } from './methods/app';
6
+ import { MethodBookingGetById, MethodBookingUpdateById } from './methods/booking';
6
7
  import { MethodBucketAddFile, MethodBucketCreate, MethodBucketGet, MethodBucketRemoveFile, MethodBucketRemoveFilesInPath } from './methods/bucket';
7
8
  import { MethodConversationCreateMessage, MethodConversationGetById } from './methods/conversation';
8
9
  import { MethodFileCreate, MethodFileDelete } from './methods/file';
@@ -21,7 +22,6 @@ import { MethodUtilisationPeriodAddRegistrationCode, MethodUtilisationPeriodChec
21
22
  import { MethodHttpPatch } from './patch';
22
23
  import { MethodHttpPost } from './post';
23
24
  import { MethodHttpPut } from './put';
24
- import { MethodBookingGetById, MethodBookingUpdateById } from './methods/booking';
25
25
  export declare enum EnumResource {
26
26
  group = "group",
27
27
  property = "property",
@@ -78,16 +78,18 @@ export declare enum EnumLookupUserType {
78
78
  }
79
79
  export type EntityResultList<Entity, ExtensionInterface = {}> = Promise<{
80
80
  readonly _embedded: {
81
- readonly items: ReadonlyArray<Entity>;
81
+ readonly items: readonly Entity[];
82
82
  };
83
83
  readonly total: number;
84
84
  } & ExtensionInterface>;
85
85
  export interface IAllthingsRestClientOptions {
86
+ readonly accessToken?: string;
86
87
  readonly apiUrl: string;
87
88
  readonly authorizationCode?: string;
88
- readonly accessToken?: string;
89
+ readonly authorizationRedirect?: (url: string) => any;
89
90
  readonly clientId?: string;
90
91
  readonly clientSecret?: string;
92
+ readonly implicit?: boolean;
91
93
  readonly oauthUrl: string;
92
94
  readonly password?: string;
93
95
  readonly redirectUri?: string;
@@ -99,23 +101,21 @@ export interface IAllthingsRestClientOptions {
99
101
  readonly state?: string;
100
102
  readonly tokenStore?: ITokenStore;
101
103
  readonly username?: string;
102
- readonly implicit?: boolean;
103
- readonly authorizationRedirect?: (url: string) => any;
104
104
  }
105
105
  export interface IClientExposedOAuth {
106
106
  readonly authorizationCode: {
107
107
  readonly getUri: (state?: string) => string;
108
108
  readonly requestToken: (authorizationCode?: string) => ReturnType<TokenRequester>;
109
109
  };
110
- readonly refreshToken: (refreshToken?: string) => ReturnType<TokenRequester>;
111
110
  readonly generateState: () => string;
111
+ readonly refreshToken: (refreshToken?: string) => ReturnType<TokenRequester>;
112
112
  }
113
113
  export interface IAllthingsRestClient {
114
- readonly options: Required<IAllthingsRestClientOptions>;
115
114
  readonly delete: MethodHttpDelete;
116
115
  readonly get: MethodHttpGet;
117
- readonly post: MethodHttpPost;
116
+ readonly options: Required<IAllthingsRestClientOptions>;
118
117
  readonly patch: MethodHttpPatch;
118
+ readonly post: MethodHttpPost;
119
119
  readonly put: MethodHttpPut;
120
120
  readonly oauth: IClientExposedOAuth;
121
121
  readonly agentCreate: MethodAgentCreate;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- export type List<T> = ReadonlyArray<T>;
2
+ export type List<T> = readonly T[];
3
3
  export declare const partial: (fn: (...args: any[]) => any | Promise<any>, ...partialArgs: any[]) => (...args: any[]) => any;
4
4
  export declare function times<T>(fn: (item: number, index: number) => T, n: number): List<T>;
5
5
  export declare function until<A, B>(predicate: (value: B, iteration: number) => boolean | Promise<boolean>, transformer: (value: A | B | undefined, iteration: number) => B | Promise<B>, initialValue?: A | B, iterationCount?: number): Promise<B>;
@@ -1 +1 @@
1
- export default function sleep(miliseconds: number): Promise<boolean>;
1
+ export default function sleep(milliseconds: number): Promise<boolean>;
@@ -1,14 +1,14 @@
1
1
  /// <reference types="node" />
2
2
  import { IAllthingsRestClient } from '..';
3
3
  import { IFile } from '../rest/methods/file';
4
- export declare const createManyFiles: (attachments: ReadonlyArray<{
4
+ export declare const createManyFiles: (attachments: readonly {
5
5
  readonly content: Buffer;
6
6
  readonly filename: string;
7
- }>, apiClient: IAllthingsRestClient) => Promise<ReadonlyArray<IFile | Error>>;
8
- export declare function createManyFilesSorted(files: ReadonlyArray<{
7
+ }[], apiClient: IAllthingsRestClient) => Promise<readonly (IFile | Error)[]>;
8
+ export declare function createManyFilesSorted(files: readonly {
9
9
  readonly content: Buffer;
10
10
  readonly filename: string;
11
- }>, client: IAllthingsRestClient): Promise<{
12
- readonly success: ReadonlyArray<string>;
13
- readonly error: ReadonlyArray<Error>;
11
+ }[], client: IAllthingsRestClient): Promise<{
12
+ readonly error: readonly Error[];
13
+ readonly success: readonly string[];
14
14
  }>;
@@ -0,0 +1,16 @@
1
+ import { EnumCommunicationMethodType, EnumInputChannel, } from '../src/rest/types';
2
+ export const APP_ID = '575027e58178f56a008b4568';
3
+ export const APP_CHANNEL = 'App-575027e58178f56a008b4568';
4
+ export const APP_PROPERTY_MANAGER_ID = '5a818c07ef5f2f00441146a2';
5
+ export const CATEGORY_ID = '5eb9a4ff2a4433163d0e540a';
6
+ export const COMMUNICATION_METHOD = {
7
+ id: '5dd7ca6bfbdbb4af89be9c37',
8
+ type: EnumCommunicationMethodType.email,
9
+ value: 'pr-coreyplatt@allthings.me',
10
+ };
11
+ export const CONVERSATION_ID = '5aa7cd7bd4959e004112e136';
12
+ export const INPUT_CHANNEL = EnumInputChannel.EMAIL;
13
+ export const SERVICE_PROVIDER_ID = '5a818c07ef5f2f00441146a2';
14
+ export const USER_ID = '50f66beaeabc88ab0e000000';
15
+ export const UTILISATION_PERIOD_ID = '5a9d65cd0ecb330045742be3';
16
+ export const BOOKING_ID = '5aa68870d4959e00447d6f87';
@@ -0,0 +1,55 @@
1
+ import { nanoid as generateId } from 'nanoid';
2
+ import restClient, { EnumUnitType } from '../src/rest';
3
+ import { EnumLocale, EnumTimezone, } from '../src/rest/types';
4
+ import { APP_ID, APP_PROPERTY_MANAGER_ID } from './constants';
5
+ export async function createUserAndClient() {
6
+ const defaultClient = restClient();
7
+ const email = `${generateId()}@foobar.test`;
8
+ const password = generateId();
9
+ const data = {
10
+ description: 'Foobar User',
11
+ email,
12
+ externalId: generateId(),
13
+ locale: EnumLocale.en_US,
14
+ plainPassword: password,
15
+ };
16
+ return {
17
+ client: restClient({
18
+ password,
19
+ username: email,
20
+ }),
21
+ user: await defaultClient.userCreate(APP_ID, generateId(), data),
22
+ };
23
+ }
24
+ export async function createUtilisationPeriod() {
25
+ const defaultClient = restClient();
26
+ const property = await defaultClient.propertyCreate(APP_ID, {
27
+ name: 'CommunityArticleStatsGetByUser Test Property',
28
+ timezone: EnumTimezone.EuropeBerlin,
29
+ });
30
+ const group = await defaultClient.groupCreate(property.id, {
31
+ name: 'CommunityArticleStatsGetByUser Test Group',
32
+ propertyManagerId: APP_PROPERTY_MANAGER_ID,
33
+ });
34
+ const unit = await defaultClient.unitCreate(group.id, {
35
+ name: 'CommunityArticleStatsGetByUser Test Unit',
36
+ type: EnumUnitType.rented,
37
+ });
38
+ return defaultClient.utilisationPeriodCreate(unit.id, {
39
+ endDate: '2050-01-03',
40
+ externalId: generateId(),
41
+ startDate: '2015-01-03',
42
+ });
43
+ }
44
+ export async function createUserWithUtilizationPeriod() {
45
+ const defaultClient = restClient();
46
+ const [utilisationPeriod, { client, user }] = await Promise.all([
47
+ await createUtilisationPeriod(),
48
+ await createUserAndClient(),
49
+ ]);
50
+ await defaultClient.userCheckInToUtilisationPeriod(user.id, utilisationPeriod.id);
51
+ return {
52
+ client,
53
+ user,
54
+ };
55
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allthings/sdk",
3
- "version": "6.1.0",
3
+ "version": "6.2.0-1",
4
4
  "description": "",
5
5
  "author": "Allthings GmbH",
6
6
  "keywords": [
@@ -35,8 +35,8 @@
35
35
  "test:ci": "jest --runInBand",
36
36
  "watch:build": "tsc -d -w & rollup -c --watch",
37
37
  "watch:test": "jest --watch",
38
- "lint": "yarn lint:tsc && yarn lint:tslint",
39
- "lint:tslint": "tslint -p tsconfig.json -t stylish",
38
+ "lint": "yarn lint:tsc && yarn lint:eslint",
39
+ "lint:eslint": "eslint src",
40
40
  "lint:tsc": "tsc --noEmit --pretty",
41
41
  "prebuild": "npm run clean",
42
42
  "build": "tsc -d && cp package.json dist/ && rollup -c --bundleConfigAsCjs && rm dist/package.json",
@@ -52,19 +52,22 @@
52
52
  "test:authorization-code": "open http://localhost:3333/test/fixtures/authorization-code?clientId=$ALLTHINGS_OAUTH_CLIENT_ID&clientSecret=$ALLTHINGS_OAUTH_CLIENT_SECRET"
53
53
  },
54
54
  "dependencies": {
55
+ "@aws-sdk/client-ssm": "3.574.0",
55
56
  "bottleneck": "2.19.5",
56
57
  "cross-fetch": "4.0.0",
57
58
  "query-string": "7.1.3"
58
59
  },
59
60
  "devDependencies": {
60
- "@allthings/tslint-preset": "2.0.0",
61
- "@commitlint/cli": "19.2.1",
62
- "@commitlint/config-conventional": "19.1.0",
61
+ "@allthings/eslint-config": "1.1.0",
62
+ "@commitlint/cli": "19.3.0",
63
+ "@commitlint/config-conventional": "19.2.2",
64
+ "@rollup/plugin-node-resolve": "15.2.3",
63
65
  "@types/form-data": "2.5.0",
64
66
  "@types/jest": "26.0.24",
65
- "@types/node": "18.19.30",
67
+ "@types/node": "18.19.31",
66
68
  "@types/query-string": "6.3.0",
67
69
  "coveralls": "3.1.1",
70
+ "eslint": "8.57.0",
68
71
  "form-data": "4.0.0",
69
72
  "husky": "9.0.11",
70
73
  "jest": "26.6.3",
@@ -77,12 +80,10 @@
77
80
  "rollup-plugin-commonjs": "10.1.0",
78
81
  "rollup-plugin-hashbang": "2.2.2",
79
82
  "rollup-plugin-json": "4.0.0",
80
- "@rollup/plugin-node-resolve": "15.2.3",
81
83
  "rollup-plugin-replace": "2.2.0",
82
84
  "rollup-plugin-terser": "7.0.2",
83
85
  "semantic-release": "19.0.5",
84
86
  "ts-jest": "26.5.6",
85
- "tslint": "6.1.3",
86
87
  "typescript": "4.9.5"
87
88
  },
88
89
  "prettier": {