@allthings/sdk 6.0.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;
@@ -95,26 +97,25 @@ export interface IAllthingsRestClientOptions {
95
97
  readonly requestBackOffInterval: number;
96
98
  readonly requestMaxRetries: number;
97
99
  readonly scope?: string;
100
+ readonly serviceName?: string;
98
101
  readonly state?: string;
99
102
  readonly tokenStore?: ITokenStore;
100
103
  readonly username?: string;
101
- readonly implicit?: boolean;
102
- readonly authorizationRedirect?: (url: string) => any;
103
104
  }
104
105
  export interface IClientExposedOAuth {
105
106
  readonly authorizationCode: {
106
107
  readonly getUri: (state?: string) => string;
107
108
  readonly requestToken: (authorizationCode?: string) => ReturnType<TokenRequester>;
108
109
  };
109
- readonly refreshToken: (refreshToken?: string) => ReturnType<TokenRequester>;
110
110
  readonly generateState: () => string;
111
+ readonly refreshToken: (refreshToken?: string) => ReturnType<TokenRequester>;
111
112
  }
112
113
  export interface IAllthingsRestClient {
113
- readonly options: Required<IAllthingsRestClientOptions>;
114
114
  readonly delete: MethodHttpDelete;
115
115
  readonly get: MethodHttpGet;
116
- readonly post: MethodHttpPost;
116
+ readonly options: Required<IAllthingsRestClientOptions>;
117
117
  readonly patch: MethodHttpPatch;
118
+ readonly post: MethodHttpPost;
118
119
  readonly put: MethodHttpPut;
119
120
  readonly oauth: IClientExposedOAuth;
120
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,14 +1,8 @@
1
1
  {
2
2
  "name": "@allthings/sdk",
3
- "version": "6.0.0",
3
+ "version": "6.2.0-1",
4
4
  "description": "",
5
5
  "author": "Allthings GmbH",
6
- "maintainers": [
7
- "Marco Lüthy <marco.luethy@gmail.com> (https://github.com/adieuadieu)"
8
- ],
9
- "contributors": [
10
- "Marco Lüthy <marco.luethy@gmail.com> (https://github.com/adieuadieu)"
11
- ],
12
6
  "keywords": [
13
7
  "allthings",
14
8
  "sdk"
@@ -20,7 +14,7 @@
20
14
  },
21
15
  "homepage": "https://github.com/allthings/node-sdk",
22
16
  "engines": {
23
- "node": ">=18.5"
17
+ "node": ">=18.16"
24
18
  },
25
19
  "main": "dist/lib.cjs.js",
26
20
  "module": "dist/lib.esm.js",
@@ -41,13 +35,13 @@
41
35
  "test:ci": "jest --runInBand",
42
36
  "watch:build": "tsc -d -w & rollup -c --watch",
43
37
  "watch:test": "jest --watch",
44
- "lint": "yarn lint:tsc && yarn lint:tslint",
45
- "lint:tslint": "tslint -p tsconfig.json -t stylish",
38
+ "lint": "yarn lint:tsc && yarn lint:eslint",
39
+ "lint:eslint": "eslint src",
46
40
  "lint:tsc": "tsc --noEmit --pretty",
47
41
  "prebuild": "npm run clean",
48
42
  "build": "tsc -d && cp package.json dist/ && rollup -c --bundleConfigAsCjs && rm dist/package.json",
49
43
  "dev": "tsc -w",
50
- "prepare": "husky install",
44
+ "prepare": "husky",
51
45
  "prepublishOnly": "npm run build",
52
46
  "prettier": "prettier --write",
53
47
  "security-check": "yarn audit --groups dependencies --level high || test $? -lt 7",
@@ -58,24 +52,27 @@
58
52
  "test:authorization-code": "open http://localhost:3333/test/fixtures/authorization-code?clientId=$ALLTHINGS_OAUTH_CLIENT_ID&clientSecret=$ALLTHINGS_OAUTH_CLIENT_SECRET"
59
53
  },
60
54
  "dependencies": {
55
+ "@aws-sdk/client-ssm": "3.574.0",
61
56
  "bottleneck": "2.19.5",
62
57
  "cross-fetch": "4.0.0",
63
58
  "query-string": "7.1.3"
64
59
  },
65
60
  "devDependencies": {
66
- "@allthings/tslint-preset": "2.0.0",
67
- "@commitlint/cli": "17.8.1",
68
- "@commitlint/config-conventional": "17.8.1",
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",
69
65
  "@types/form-data": "2.5.0",
70
66
  "@types/jest": "26.0.24",
71
- "@types/node": "18.17.13",
67
+ "@types/node": "18.19.31",
72
68
  "@types/query-string": "6.3.0",
73
69
  "coveralls": "3.1.1",
70
+ "eslint": "8.57.0",
74
71
  "form-data": "4.0.0",
75
- "husky": "8.0.3",
72
+ "husky": "9.0.11",
76
73
  "jest": "26.6.3",
77
74
  "jest-environment-jsdom": "26.6.2",
78
- "lint-staged": "14.0.1",
75
+ "lint-staged": "15.2.2",
79
76
  "nanoid": "3.3.7",
80
77
  "prettier": "3.2.5",
81
78
  "rimraf": "5.0.5",
@@ -83,12 +80,10 @@
83
80
  "rollup-plugin-commonjs": "10.1.0",
84
81
  "rollup-plugin-hashbang": "2.2.2",
85
82
  "rollup-plugin-json": "4.0.0",
86
- "@rollup/plugin-node-resolve": "15.2.3",
87
83
  "rollup-plugin-replace": "2.2.0",
88
84
  "rollup-plugin-terser": "7.0.2",
89
85
  "semantic-release": "19.0.5",
90
86
  "ts-jest": "26.5.6",
91
- "tslint": "6.1.3",
92
87
  "typescript": "4.9.5"
93
88
  },
94
89
  "prettier": {
@@ -141,7 +136,7 @@
141
136
  ],
142
137
  "coverageThreshold": {
143
138
  "global": {
144
- "branches": 100,
139
+ "branches": 99,
145
140
  "functions": 100,
146
141
  "lines": 100,
147
142
  "statements": 100