@allthings/sdk 10.0.0-beta.1 → 10.0.0-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/dist/cli.js +1 -1
- package/dist/lib.cjs.js +1 -1
- package/dist/src/cli.js +15 -0
- package/dist/src/constants.js +25 -0
- package/dist/src/index.js +4 -0
- package/dist/src/oauth/authorizationCodeGrant.js +56 -0
- package/dist/src/oauth/clientCredentialsGrant.js +25 -0
- package/dist/src/oauth/createTokenStore.js +8 -0
- package/dist/src/oauth/implicitGrant.js +24 -0
- package/dist/src/oauth/makeFetchTokenRequester.js +38 -0
- package/dist/src/oauth/maybeUpdateToken.js +44 -0
- package/dist/src/oauth/passwordGrant.js +30 -0
- package/dist/src/oauth/refreshTokenGrant.js +26 -0
- package/dist/src/oauth/requestAndSaveToStore.js +5 -0
- package/dist/src/oauth/types.js +1 -0
- package/dist/src/rest/delete.js +3 -0
- package/dist/src/rest/get.js +3 -0
- package/dist/src/rest/index.js +160 -0
- package/dist/src/rest/methods/agent.js +26 -0
- package/dist/src/rest/methods/app.js +10 -0
- package/dist/src/rest/methods/booking.js +6 -0
- package/dist/src/rest/methods/bucket.js +22 -0
- package/dist/src/rest/methods/conversation.js +28 -0
- package/dist/src/rest/methods/file.js +11 -0
- package/dist/src/rest/methods/group.js +22 -0
- package/dist/src/rest/methods/idLookup.js +12 -0
- package/dist/src/rest/methods/notification.js +57 -0
- package/dist/src/rest/methods/notificationSettings.js +19 -0
- package/dist/src/rest/methods/property.js +17 -0
- package/dist/src/rest/methods/registrationCode.js +24 -0
- package/dist/src/rest/methods/serviceProvider.js +9 -0
- package/dist/src/rest/methods/ticket.js +34 -0
- package/dist/src/rest/methods/unit.js +95 -0
- package/dist/src/rest/methods/user.js +134 -0
- package/dist/src/rest/methods/userRelation.js +22 -0
- package/dist/src/rest/methods/utilisationPeriod.js +49 -0
- package/dist/src/rest/patch.js +3 -0
- package/dist/src/rest/post.js +3 -0
- package/dist/src/rest/put.js +3 -0
- package/dist/src/rest/request.js +159 -0
- package/dist/src/rest/types.js +62 -0
- package/dist/src/utils/environment.js +1 -0
- package/dist/src/utils/functional.js +14 -0
- package/dist/src/utils/logger.js +15 -0
- package/dist/src/utils/object.js +6 -0
- package/dist/src/utils/queryString.js +13 -0
- package/dist/src/utils/random.js +7 -0
- package/dist/src/utils/sleep.js +3 -0
- package/dist/src/utils/string.js +6 -0
- package/dist/src/utils/stringToDate.js +6 -0
- package/dist/src/utils/upload.js +24 -0
- package/package.json +10 -8
- package/dist/lib.esm.js +0 -1350
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export var EnumResource;
|
|
2
|
+
(function (EnumResource) {
|
|
3
|
+
EnumResource["group"] = "group";
|
|
4
|
+
EnumResource["property"] = "property";
|
|
5
|
+
EnumResource["serviceProvider"] = "propertyManager";
|
|
6
|
+
EnumResource["registrationCode"] = "registrationCode";
|
|
7
|
+
EnumResource["unit"] = "unit";
|
|
8
|
+
EnumResource["user"] = "user";
|
|
9
|
+
EnumResource["utilisationPeriod"] = "utilisationPeriod";
|
|
10
|
+
})(EnumResource || (EnumResource = {}));
|
|
11
|
+
export var EnumCountryCode;
|
|
12
|
+
(function (EnumCountryCode) {
|
|
13
|
+
EnumCountryCode["CH"] = "CH";
|
|
14
|
+
EnumCountryCode["DE"] = "DE";
|
|
15
|
+
EnumCountryCode["FR"] = "FR";
|
|
16
|
+
EnumCountryCode["IT"] = "IT";
|
|
17
|
+
EnumCountryCode["NL"] = "NL";
|
|
18
|
+
EnumCountryCode["PT"] = "PT";
|
|
19
|
+
EnumCountryCode["US"] = "US";
|
|
20
|
+
})(EnumCountryCode || (EnumCountryCode = {}));
|
|
21
|
+
export var EnumLocale;
|
|
22
|
+
(function (EnumLocale) {
|
|
23
|
+
EnumLocale["ch_de"] = "ch_DE";
|
|
24
|
+
EnumLocale["ch_fr"] = "ch_FR";
|
|
25
|
+
EnumLocale["ch_it"] = "ch_it";
|
|
26
|
+
EnumLocale["de_DE"] = "de_DE";
|
|
27
|
+
EnumLocale["it_IT"] = "it_IT";
|
|
28
|
+
EnumLocale["fr_FR"] = "fr_FR";
|
|
29
|
+
EnumLocale["pt_PT"] = "pt_PT";
|
|
30
|
+
EnumLocale["en_US"] = "en_US";
|
|
31
|
+
})(EnumLocale || (EnumLocale = {}));
|
|
32
|
+
export var EnumTimezone;
|
|
33
|
+
(function (EnumTimezone) {
|
|
34
|
+
EnumTimezone["EuropeBerlin"] = "Europe/Berlin";
|
|
35
|
+
EnumTimezone["EuropeLondon"] = "Europe/London";
|
|
36
|
+
EnumTimezone["EuropeSofia"] = "Europe/Sofia";
|
|
37
|
+
EnumTimezone["EuropeZurich"] = "Europe/Zurich";
|
|
38
|
+
EnumTimezone["UTC"] = "UTC";
|
|
39
|
+
})(EnumTimezone || (EnumTimezone = {}));
|
|
40
|
+
export var EnumServiceProviderType;
|
|
41
|
+
(function (EnumServiceProviderType) {
|
|
42
|
+
EnumServiceProviderType["propertyManager"] = "property-manager";
|
|
43
|
+
EnumServiceProviderType["craftspeople"] = "craftspeople";
|
|
44
|
+
})(EnumServiceProviderType || (EnumServiceProviderType = {}));
|
|
45
|
+
export var EnumCommunicationMethodType;
|
|
46
|
+
(function (EnumCommunicationMethodType) {
|
|
47
|
+
EnumCommunicationMethodType["email"] = "email";
|
|
48
|
+
})(EnumCommunicationMethodType || (EnumCommunicationMethodType = {}));
|
|
49
|
+
export var EnumInputChannel;
|
|
50
|
+
(function (EnumInputChannel) {
|
|
51
|
+
EnumInputChannel["APP"] = "app";
|
|
52
|
+
EnumInputChannel["COCKPIT"] = "cockpit";
|
|
53
|
+
EnumInputChannel["CRAFTSMEN"] = "craftsmen";
|
|
54
|
+
EnumInputChannel["EMAIL"] = "email";
|
|
55
|
+
EnumInputChannel["PHONE"] = "phone";
|
|
56
|
+
EnumInputChannel["WHATS_APP"] = "whats_app";
|
|
57
|
+
})(EnumInputChannel || (EnumInputChannel = {}));
|
|
58
|
+
export var EnumLookupUserType;
|
|
59
|
+
(function (EnumLookupUserType) {
|
|
60
|
+
EnumLookupUserType["agent"] = "agent";
|
|
61
|
+
EnumLookupUserType["tenant"] = "tenant";
|
|
62
|
+
})(EnumLookupUserType || (EnumLookupUserType = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const environment = typeof process !== 'undefined' && process.env ? process.env : {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const partial = (function_, ...partialArguments) => (...arguments_) => function_(...partialArguments, ...arguments_);
|
|
2
|
+
export function times(function_, n) {
|
|
3
|
+
return [...new Array(n)].map(function_);
|
|
4
|
+
}
|
|
5
|
+
export async function until(predicate, transformer, initialValue, iterationCount = 0) {
|
|
6
|
+
const transformed = await transformer(initialValue, iterationCount);
|
|
7
|
+
return (await predicate(transformed, iterationCount))
|
|
8
|
+
? transformed
|
|
9
|
+
: until(predicate, transformer, transformed, iterationCount + 1);
|
|
10
|
+
}
|
|
11
|
+
export function clearIntervalFunction(intervalId) {
|
|
12
|
+
clearInterval(intervalId);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { environment } from './environment';
|
|
2
|
+
const SUBSCRIPTIONS = environment.DEBUG?.split(',').map((item) => item.trim()) || [];
|
|
3
|
+
export default function makeLogger(name) {
|
|
4
|
+
return ['log', 'info', 'warn', 'error'].reduce((logger, type) => ({
|
|
5
|
+
...logger,
|
|
6
|
+
[type]: function log(...logs) {
|
|
7
|
+
if (SUBSCRIPTIONS.includes('*') ||
|
|
8
|
+
SUBSCRIPTIONS.includes(name) ||
|
|
9
|
+
SUBSCRIPTIONS.includes(name.toLocaleLowerCase())) {
|
|
10
|
+
console[type](`${name}:`, ...logs);
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
},
|
|
14
|
+
}), {});
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function buildQueryString(params) {
|
|
2
|
+
const usp = new URLSearchParams();
|
|
3
|
+
for (const [key, value] of Object.entries(params).sort(([a], [b]) => a.localeCompare(b))) {
|
|
4
|
+
if (value != null && value !== '') {
|
|
5
|
+
usp.append(key, String(value));
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return usp.toString();
|
|
9
|
+
}
|
|
10
|
+
export function parseQueryString(query) {
|
|
11
|
+
const cleaned = query.startsWith('#') ? query.slice(1) : query;
|
|
12
|
+
return Object.fromEntries(new URLSearchParams(cleaned));
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const createManyFiles = async (attachments, apiClient) => {
|
|
2
|
+
const responses = await Promise.all(attachments.map(async (attachment) => {
|
|
3
|
+
try {
|
|
4
|
+
const result = await apiClient.fileCreate({
|
|
5
|
+
file: attachment.content,
|
|
6
|
+
name: attachment.filename,
|
|
7
|
+
});
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
return responses;
|
|
15
|
+
};
|
|
16
|
+
export async function createManyFilesSorted(files, client) {
|
|
17
|
+
const result = await createManyFiles(files, client);
|
|
18
|
+
return {
|
|
19
|
+
error: result.filter((item) => item instanceof Error),
|
|
20
|
+
success: result
|
|
21
|
+
.filter((item) => !(item instanceof Error))
|
|
22
|
+
.map((item) => item.id),
|
|
23
|
+
};
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allthings/sdk",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Allthings GmbH",
|
|
6
6
|
"keywords": [
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"repositoryUrl": "https://github.com/allthings/node-sdk.git"
|
|
22
22
|
},
|
|
23
23
|
"main": "dist/lib.cjs.js",
|
|
24
|
-
"module": "dist/
|
|
25
|
-
"browser": "dist/
|
|
24
|
+
"module": "dist/src/index.js",
|
|
25
|
+
"browser": "dist/src/index.js",
|
|
26
26
|
"types": "dist/src/index.d.ts",
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
29
|
"types": "./dist/src/index.d.ts",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
30
|
+
"require": "./dist/lib.cjs.js",
|
|
31
|
+
"browser": "./dist/src/index.js",
|
|
32
|
+
"import": "./dist/src/index.js"
|
|
33
33
|
},
|
|
34
34
|
"./package.json": "./package.json"
|
|
35
35
|
},
|
|
@@ -37,8 +37,10 @@
|
|
|
37
37
|
"./dist/cli.js"
|
|
38
38
|
],
|
|
39
39
|
"files": [
|
|
40
|
-
"dist
|
|
41
|
-
"dist
|
|
40
|
+
"dist/cli.js",
|
|
41
|
+
"dist/lib.cjs.js",
|
|
42
|
+
"dist/src/**/*.js",
|
|
43
|
+
"dist/src/**/*.d.ts"
|
|
42
44
|
],
|
|
43
45
|
"bin": {
|
|
44
46
|
"allthings": "dist/cli.js"
|