@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.
Files changed (53) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/lib.cjs.js +1 -1
  3. package/dist/src/cli.js +15 -0
  4. package/dist/src/constants.js +25 -0
  5. package/dist/src/index.js +4 -0
  6. package/dist/src/oauth/authorizationCodeGrant.js +56 -0
  7. package/dist/src/oauth/clientCredentialsGrant.js +25 -0
  8. package/dist/src/oauth/createTokenStore.js +8 -0
  9. package/dist/src/oauth/implicitGrant.js +24 -0
  10. package/dist/src/oauth/makeFetchTokenRequester.js +38 -0
  11. package/dist/src/oauth/maybeUpdateToken.js +44 -0
  12. package/dist/src/oauth/passwordGrant.js +30 -0
  13. package/dist/src/oauth/refreshTokenGrant.js +26 -0
  14. package/dist/src/oauth/requestAndSaveToStore.js +5 -0
  15. package/dist/src/oauth/types.js +1 -0
  16. package/dist/src/rest/delete.js +3 -0
  17. package/dist/src/rest/get.js +3 -0
  18. package/dist/src/rest/index.js +160 -0
  19. package/dist/src/rest/methods/agent.js +26 -0
  20. package/dist/src/rest/methods/app.js +10 -0
  21. package/dist/src/rest/methods/booking.js +6 -0
  22. package/dist/src/rest/methods/bucket.js +22 -0
  23. package/dist/src/rest/methods/conversation.js +28 -0
  24. package/dist/src/rest/methods/file.js +11 -0
  25. package/dist/src/rest/methods/group.js +22 -0
  26. package/dist/src/rest/methods/idLookup.js +12 -0
  27. package/dist/src/rest/methods/notification.js +57 -0
  28. package/dist/src/rest/methods/notificationSettings.js +19 -0
  29. package/dist/src/rest/methods/property.js +17 -0
  30. package/dist/src/rest/methods/registrationCode.js +24 -0
  31. package/dist/src/rest/methods/serviceProvider.js +9 -0
  32. package/dist/src/rest/methods/ticket.js +34 -0
  33. package/dist/src/rest/methods/unit.js +95 -0
  34. package/dist/src/rest/methods/user.js +134 -0
  35. package/dist/src/rest/methods/userRelation.js +22 -0
  36. package/dist/src/rest/methods/utilisationPeriod.js +49 -0
  37. package/dist/src/rest/patch.js +3 -0
  38. package/dist/src/rest/post.js +3 -0
  39. package/dist/src/rest/put.js +3 -0
  40. package/dist/src/rest/request.js +159 -0
  41. package/dist/src/rest/types.js +62 -0
  42. package/dist/src/utils/environment.js +1 -0
  43. package/dist/src/utils/functional.js +14 -0
  44. package/dist/src/utils/logger.js +15 -0
  45. package/dist/src/utils/object.js +6 -0
  46. package/dist/src/utils/queryString.js +13 -0
  47. package/dist/src/utils/random.js +7 -0
  48. package/dist/src/utils/sleep.js +3 -0
  49. package/dist/src/utils/string.js +6 -0
  50. package/dist/src/utils/stringToDate.js +6 -0
  51. package/dist/src/utils/upload.js +24 -0
  52. package/package.json +10 -8
  53. 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,6 @@
1
+ export function remapKeys(input, mapFunction) {
2
+ return Object.entries(input).reduce((accumulator, entry) => ({
3
+ ...accumulator,
4
+ [mapFunction(entry[0])]: entry[1],
5
+ }), {});
6
+ }
@@ -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,7 @@
1
+ export function pseudoRandomString(length = 16) {
2
+ let token = '';
3
+ while (token.length < length) {
4
+ token += Math.random().toString(36).slice(2);
5
+ }
6
+ return token.slice(0, Math.max(0, length));
7
+ }
@@ -0,0 +1,3 @@
1
+ export default function sleep(milliseconds) {
2
+ return new Promise((resolve) => setTimeout(() => resolve(true), milliseconds));
3
+ }
@@ -0,0 +1,6 @@
1
+ export function camelCaseToDash(input) {
2
+ return input.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`);
3
+ }
4
+ export function dashCaseToCamel(input) {
5
+ return input.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
6
+ }
@@ -0,0 +1,6 @@
1
+ export function stringToDate(s) {
2
+ return new Date(Date.parse(s));
3
+ }
4
+ export function dateToString(d) {
5
+ return d.toISOString();
6
+ }
@@ -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.1",
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/lib.esm.js",
25
- "browser": "dist/lib.esm.js",
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
- "browser": "./dist/lib.esm.js",
31
- "import": "./dist/lib.esm.js",
32
- "require": "./dist/lib.cjs.js"
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/*.js",
41
- "dist/**/*.d.ts"
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"