@allthings/sdk 6.7.0 → 7.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 CHANGED
@@ -473,3 +473,23 @@ When you squash merge, GitHub takes the title of the PR for the squash-merge's c
473
473
 
474
474
  By choosing a proper PR title e.g. `feat: my new feature` your merged PR will trigger a new release.
475
475
  See semantic-releases [docs](https://github.com/semantic-release/semantic-release#how-does-it-work) for available prefixes.
476
+
477
+ ## Local tests
478
+
479
+ To run local tests, init the shell from devenv and use this command:
480
+
481
+ ```shell
482
+ ALLTHINGS_OAUTH_CLIENT_ID='<oauth_client_id>' \
483
+ ALLTHINGS_OAUTH_CLIENT_SECRET='<oauth_client_secret>' \
484
+ ALLTHINGS_OAUTH_USERNAME='<oauth_username' \
485
+ ALLTHINGS_OAUTH_PASSWORD="<oauth_password>" \
486
+ ./bin/test-ci.sh --update --log accounts,events,php
487
+
488
+ ```
489
+
490
+ if you don't want to init the shell, please also provide next env variables to command as well:
491
+ - ALLTHINGS_ACCOUNTS_RECAPTCHA_SECRET_KEY
492
+ - SSL_PASS
493
+
494
+ Credentials could be found in `dev.secrets` repo.
495
+
package/dist/cli.js CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- require('@aws-sdk/client-ssm');
5
4
  var querystring = require('query-string');
6
5
  var fetch = require('cross-fetch');
7
6
  var Bottleneck = require('bottleneck');
@@ -13,7 +12,16 @@ var require$$4 = require('https');
13
12
  var require$$5 = require('url');
14
13
  var require$$6 = require('fs');
15
14
 
16
- const version = "6.7.0";
15
+ function createTokenStore(initialToken) {
16
+ const token = new Map(Object.entries(initialToken || {}));
17
+ return {
18
+ get: (key) => token.get(key),
19
+ reset: () => token.clear(),
20
+ set: (update) => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
21
+ };
22
+ }
23
+
24
+ const version = "7.0.0";
17
25
 
18
26
  const REST_API_URL = 'https://api.allthings.me';
19
27
  const OAUTH_URL = 'https://accounts.allthings.me';
@@ -35,35 +43,6 @@ const DEFAULT_API_WRAPPER_OPTIONS = {
35
43
  username: process.env.ALLTHINGS_OAUTH_USERNAME,
36
44
  };
37
45
  const USER_AGENT = `Allthings Node SDK REST Client/${version}`;
38
- const DEFAULT_AWS_CONFIGURATION = {
39
- region: 'eu-central-2',
40
- };
41
-
42
- (undefined && undefined.__rest) || function (s, e) {
43
- var t = {};
44
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
45
- t[p] = s[p];
46
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
47
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
48
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
49
- t[p[i]] = s[p[i]];
50
- }
51
- return t;
52
- };
53
- ({
54
- clientConfig: DEFAULT_AWS_CONFIGURATION,
55
- onlyDefault: false,
56
- prefix: process.env.SSM_PARAM_PATH,
57
- });
58
-
59
- function createTokenStore(initialToken) {
60
- const token = new Map(Object.entries(initialToken || {}));
61
- return {
62
- get: (key) => token.get(key),
63
- reset: () => token.clear(),
64
- set: (update) => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
65
- };
66
- }
67
46
 
68
47
  const RESPONSE_TYPE$1 = 'code';
69
48
  const GRANT_TYPE$3 = 'authorization_code';
@@ -12681,7 +12660,7 @@ function requireForm_data () {
12681
12660
  }
12682
12661
 
12683
12662
  // https://github.com/felixge/node-form-data/issues/38
12684
- if (util.isArray(value)) {
12663
+ if (Array.isArray(value)) {
12685
12664
  // Please convert your array into string
12686
12665
  // the way web server expects it
12687
12666
  this._error(new Error('Arrays are not supported.'));
package/dist/lib.cjs.js CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var clientSsm = require('@aws-sdk/client-ssm');
4
3
  var querystring = require('query-string');
5
4
  var fetch = require('cross-fetch');
6
5
  var Bottleneck = require('bottleneck');
@@ -12,7 +11,16 @@ var require$$4 = require('https');
12
11
  var require$$5 = require('url');
13
12
  var require$$6 = require('fs');
14
13
 
15
- const version = "6.7.0";
14
+ function createTokenStore(initialToken) {
15
+ const token = new Map(Object.entries(initialToken || {}));
16
+ return {
17
+ get: (key) => token.get(key),
18
+ reset: () => token.clear(),
19
+ set: (update) => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
20
+ };
21
+ }
22
+
23
+ const version = "7.0.0";
16
24
 
17
25
  const REST_API_URL = 'https://api.allthings.me';
18
26
  const OAUTH_URL = 'https://accounts.allthings.me';
@@ -34,81 +42,6 @@ const DEFAULT_API_WRAPPER_OPTIONS = {
34
42
  username: process.env.ALLTHINGS_OAUTH_USERNAME,
35
43
  };
36
44
  const USER_AGENT = `Allthings Node SDK REST Client/${version}`;
37
- const DEFAULT_AWS_CONFIGURATION = {
38
- region: 'eu-central-2',
39
- };
40
-
41
- var __rest$5 = (undefined && undefined.__rest) || function (s, e) {
42
- var t = {};
43
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
44
- t[p] = s[p];
45
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
46
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
47
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
48
- t[p[i]] = s[p[i]];
49
- }
50
- return t;
51
- };
52
- const DEFAULT_CLIENT_CONFIG = {
53
- clientConfig: DEFAULT_AWS_CONFIGURATION,
54
- onlyDefault: false,
55
- prefix: process.env.SSM_PARAM_PATH,
56
- };
57
- const getSecrets = async (ssm, config, params, defaultValue) => {
58
- var _a, _b;
59
- if (config.onlyDefault) {
60
- return [defaultValue];
61
- }
62
- try {
63
- const parameters = await ssm.send(new clientSsm.GetParametersCommand({
64
- Names: params.map((param) => `${config.prefix ? config.prefix : ''}${param}`),
65
- WithDecryption: true,
66
- }));
67
- return ((_b = (_a = parameters === null || parameters === void 0 ? void 0 : parameters.Parameters) === null || _a === void 0 ? void 0 : _a.map((parameter) => { var _a; return (_a = parameter.Value) !== null && _a !== void 0 ? _a : defaultValue; })) !== null && _b !== void 0 ? _b : [defaultValue]);
68
- }
69
- catch (e) {
70
- if (config.logger) {
71
- config.logger(e);
72
- }
73
- return [defaultValue];
74
- }
75
- };
76
- const getSecret = async (ssm, config, param, defaultValue) => {
77
- var _a, _b;
78
- if (config.onlyDefault) {
79
- return defaultValue;
80
- }
81
- try {
82
- const parameter = await ssm.send(new clientSsm.GetParameterCommand({
83
- Name: `${config.prefix ? config.prefix : ''}${param}`,
84
- WithDecryption: true,
85
- }));
86
- return (_b = (_a = parameter === null || parameter === void 0 ? void 0 : parameter.Parameter) === null || _a === void 0 ? void 0 : _a.Value) !== null && _b !== void 0 ? _b : defaultValue;
87
- }
88
- catch (e) {
89
- if (config.logger) {
90
- config.logger(e);
91
- }
92
- return defaultValue;
93
- }
94
- };
95
- const parameterStore = (userConfig) => {
96
- const _a = Object.assign(Object.assign({}, DEFAULT_CLIENT_CONFIG), userConfig), { clientConfig } = _a, config = __rest$5(_a, ["clientConfig"]);
97
- const ssm = new clientSsm.SSMClient(clientConfig);
98
- return {
99
- getSecret: (param, defaultValue = '') => getSecret(ssm, config, param, defaultValue),
100
- getSecrets: (params, defaultValue = '') => getSecrets(ssm, config, params, defaultValue),
101
- };
102
- };
103
-
104
- function createTokenStore(initialToken) {
105
- const token = new Map(Object.entries(initialToken || {}));
106
- return {
107
- get: (key) => token.get(key),
108
- reset: () => token.clear(),
109
- set: (update) => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
110
- };
111
- }
112
45
 
113
46
  const RESPONSE_TYPE$1 = 'code';
114
47
  const GRANT_TYPE$3 = 'authorization_code';
@@ -12726,7 +12659,7 @@ function requireForm_data () {
12726
12659
  }
12727
12660
 
12728
12661
  // https://github.com/felixge/node-form-data/issues/38
12729
- if (util.isArray(value)) {
12662
+ if (Array.isArray(value)) {
12730
12663
  // Please convert your array into string
12731
12664
  // the way web server expects it
12732
12665
  this._error(new Error('Arrays are not supported.'));
@@ -13587,7 +13520,5 @@ exports.EnumLookupUserType = void 0;
13587
13520
  EnumLookupUserType["tenant"] = "tenant";
13588
13521
  })(exports.EnumLookupUserType || (exports.EnumLookupUserType = {}));
13589
13522
 
13590
- exports.DEFAULT_PARAMETER_STORE_CLIENT_CONFIG = DEFAULT_CLIENT_CONFIG;
13591
13523
  exports.createTokenStore = createTokenStore;
13592
- exports.parameterStore = parameterStore;
13593
13524
  exports.restClient = restClient;
package/dist/lib.esm.js CHANGED
@@ -1,4 +1,3 @@
1
- import { SSMClient, GetParametersCommand, GetParameterCommand } from '@aws-sdk/client-ssm';
2
1
  import querystring from 'query-string';
3
2
  import fetch from 'cross-fetch';
4
3
  import Bottleneck from 'bottleneck';
@@ -10,7 +9,16 @@ import require$$4 from 'https';
10
9
  import require$$5 from 'url';
11
10
  import require$$6 from 'fs';
12
11
 
13
- const version = "6.7.0";
12
+ function createTokenStore(initialToken) {
13
+ const token = new Map(Object.entries(initialToken || {}));
14
+ return {
15
+ get: (key) => token.get(key),
16
+ reset: () => token.clear(),
17
+ set: (update) => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
18
+ };
19
+ }
20
+
21
+ const version = "7.0.0";
14
22
 
15
23
  const REST_API_URL = 'https://api.allthings.me';
16
24
  const OAUTH_URL = 'https://accounts.allthings.me';
@@ -32,81 +40,6 @@ const DEFAULT_API_WRAPPER_OPTIONS = {
32
40
  username: process.env.ALLTHINGS_OAUTH_USERNAME,
33
41
  };
34
42
  const USER_AGENT = `Allthings Node SDK REST Client/${version}`;
35
- const DEFAULT_AWS_CONFIGURATION = {
36
- region: 'eu-central-2',
37
- };
38
-
39
- var __rest$5 = (undefined && undefined.__rest) || function (s, e) {
40
- var t = {};
41
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
42
- t[p] = s[p];
43
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
44
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
45
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
46
- t[p[i]] = s[p[i]];
47
- }
48
- return t;
49
- };
50
- const DEFAULT_CLIENT_CONFIG = {
51
- clientConfig: DEFAULT_AWS_CONFIGURATION,
52
- onlyDefault: false,
53
- prefix: process.env.SSM_PARAM_PATH,
54
- };
55
- const getSecrets = async (ssm, config, params, defaultValue) => {
56
- var _a, _b;
57
- if (config.onlyDefault) {
58
- return [defaultValue];
59
- }
60
- try {
61
- const parameters = await ssm.send(new GetParametersCommand({
62
- Names: params.map((param) => `${config.prefix ? config.prefix : ''}${param}`),
63
- WithDecryption: true,
64
- }));
65
- return ((_b = (_a = parameters === null || parameters === void 0 ? void 0 : parameters.Parameters) === null || _a === void 0 ? void 0 : _a.map((parameter) => { var _a; return (_a = parameter.Value) !== null && _a !== void 0 ? _a : defaultValue; })) !== null && _b !== void 0 ? _b : [defaultValue]);
66
- }
67
- catch (e) {
68
- if (config.logger) {
69
- config.logger(e);
70
- }
71
- return [defaultValue];
72
- }
73
- };
74
- const getSecret = async (ssm, config, param, defaultValue) => {
75
- var _a, _b;
76
- if (config.onlyDefault) {
77
- return defaultValue;
78
- }
79
- try {
80
- const parameter = await ssm.send(new GetParameterCommand({
81
- Name: `${config.prefix ? config.prefix : ''}${param}`,
82
- WithDecryption: true,
83
- }));
84
- return (_b = (_a = parameter === null || parameter === void 0 ? void 0 : parameter.Parameter) === null || _a === void 0 ? void 0 : _a.Value) !== null && _b !== void 0 ? _b : defaultValue;
85
- }
86
- catch (e) {
87
- if (config.logger) {
88
- config.logger(e);
89
- }
90
- return defaultValue;
91
- }
92
- };
93
- const parameterStore = (userConfig) => {
94
- const _a = Object.assign(Object.assign({}, DEFAULT_CLIENT_CONFIG), userConfig), { clientConfig } = _a, config = __rest$5(_a, ["clientConfig"]);
95
- const ssm = new SSMClient(clientConfig);
96
- return {
97
- getSecret: (param, defaultValue = '') => getSecret(ssm, config, param, defaultValue),
98
- getSecrets: (params, defaultValue = '') => getSecrets(ssm, config, params, defaultValue),
99
- };
100
- };
101
-
102
- function createTokenStore(initialToken) {
103
- const token = new Map(Object.entries(initialToken || {}));
104
- return {
105
- get: (key) => token.get(key),
106
- reset: () => token.clear(),
107
- set: (update) => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
108
- };
109
- }
110
43
 
111
44
  const RESPONSE_TYPE$1 = 'code';
112
45
  const GRANT_TYPE$3 = 'authorization_code';
@@ -12724,7 +12657,7 @@ function requireForm_data () {
12724
12657
  }
12725
12658
 
12726
12659
  // https://github.com/felixge/node-form-data/issues/38
12727
- if (util.isArray(value)) {
12660
+ if (Array.isArray(value)) {
12728
12661
  // Please convert your array into string
12729
12662
  // the way web server expects it
12730
12663
  this._error(new Error('Arrays are not supported.'));
@@ -13585,4 +13518,4 @@ var EnumLookupUserType;
13585
13518
  EnumLookupUserType["tenant"] = "tenant";
13586
13519
  })(EnumLookupUserType || (EnumLookupUserType = {}));
13587
13520
 
13588
- export { DEFAULT_CLIENT_CONFIG as DEFAULT_PARAMETER_STORE_CLIENT_CONFIG, EnumCommunicationMethodType, EnumCommunicationPreferenceChannel, EnumCountryCode, EnumInputChannel, EnumLocale, EnumLookupUserType, EnumResource, EnumServiceProviderType, EnumTimezone, EnumUnitObjectType, EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole, EnumUserRelationType, EnumUtilisationPeriodType, createTokenStore, parameterStore, restClient };
13521
+ export { EnumCommunicationMethodType, EnumCommunicationPreferenceChannel, EnumCountryCode, EnumInputChannel, EnumLocale, EnumLookupUserType, EnumResource, EnumServiceProviderType, EnumTimezone, EnumUnitObjectType, EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole, EnumUserRelationType, EnumUtilisationPeriodType, createTokenStore, restClient };