@or-sdk/users 0.20.1-usersapi.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.
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.Users = void 0;
55
+ var base_1 = require("@or-sdk/base");
56
+ var constants_1 = require("./constants");
57
+ var Users = (function (_super) {
58
+ __extends(Users, _super);
59
+ function Users(params) {
60
+ var token = params.token, discoveryUrl = params.discoveryUrl, accountId = params.accountId, serviceUrl = params.serviceUrl;
61
+ return _super.call(this, {
62
+ token: token,
63
+ discoveryUrl: discoveryUrl,
64
+ serviceKey: constants_1.SERVICE_KEY,
65
+ accountId: accountId,
66
+ serviceUrl: serviceUrl,
67
+ }) || this;
68
+ }
69
+ Users.prototype.listUsers = function (params) {
70
+ if (params === void 0) { params = {}; }
71
+ return __awaiter(this, void 0, void 0, function () {
72
+ var _a, from, size, orderDirection, orderProperty;
73
+ return __generator(this, function (_b) {
74
+ _a = params.from, from = _a === void 0 ? 0 : _a, size = params.size, orderDirection = params.orderDirection, orderProperty = params.orderProperty;
75
+ return [2, this.callApiV2({
76
+ route: '/users',
77
+ method: 'GET',
78
+ params: {
79
+ from: from,
80
+ size: size,
81
+ orderDirection: orderDirection,
82
+ orderProperty: orderProperty,
83
+ },
84
+ })];
85
+ });
86
+ });
87
+ };
88
+ return Users;
89
+ }(base_1.Base));
90
+ exports.Users = Users;
91
+ //# sourceMappingURL=Users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Users.js","sourceRoot":"","sources":["../../src/Users.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA0C;AAC1C,yCAA0C;AAU1C;IAA2B,yBAAI;IAO7B,eAAY,MAAmB;QACrB,IAAA,KAAK,GAA0C,MAAM,MAAhD,EAAE,YAAY,GAA4B,MAAM,aAAlC,EAAE,SAAS,GAAiB,MAAM,UAAvB,EAAE,UAAU,GAAK,MAAM,WAAX,CAAY;eAE9D,kBAAM;YACJ,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,UAAU,EAAE,uBAAW;YACvB,SAAS,WAAA;YACT,UAAU,YAAA;SACX,CAAC;IACJ,CAAC;IAUY,yBAAS,GAAtB,UAAuB,MAA8B;QAA9B,uBAAA,EAAA,SAAS,EAAqB;;;;gBAC3C,KAAkD,MAAM,KAAhD,EAAR,IAAI,mBAAG,CAAC,KAAA,EAAE,IAAI,GAAoC,MAAM,KAA1C,EAAE,cAAc,GAAoB,MAAM,eAA1B,EAAE,aAAa,GAAK,MAAM,cAAX,CAAY;gBACjE,WAAO,IAAI,CAAC,SAAS,CAAC;wBACpB,KAAK,EAAE,QAAQ;wBACf,MAAM,EAAE,KAAK;wBACb,MAAM,EAAE;4BACN,IAAI,MAAA;4BACJ,IAAI,MAAA;4BACJ,cAAc,gBAAA;4BACd,aAAa,eAAA;yBACd;qBACF,CAAC,EAAC;;;KACJ;IACH,YAAC;AAAD,CAAC,AAxCD,CAA2B,WAAI,GAwC9B;AAxCY,sBAAK"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SERVICE_KEY = void 0;
4
+ exports.SERVICE_KEY = 'users-api';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,WAAW,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Users = void 0;
18
+ var Users_1 = require("./Users");
19
+ Object.defineProperty(exports, "Users", { enumerable: true, get: function () { return Users_1.Users; } });
20
+ __exportStar(require("./types"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,0CAAwB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { Base } from '@or-sdk/base';
11
+ import { SERVICE_KEY } from './constants';
12
+ export class Users extends Base {
13
+ constructor(params) {
14
+ const { token, discoveryUrl, accountId, serviceUrl } = params;
15
+ super({
16
+ token,
17
+ discoveryUrl,
18
+ serviceKey: SERVICE_KEY,
19
+ accountId,
20
+ serviceUrl,
21
+ });
22
+ }
23
+ listUsers(params = {}) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const { from = 0, size, orderDirection, orderProperty } = params;
26
+ return this.callApiV2({
27
+ route: '/users',
28
+ method: 'GET',
29
+ params: {
30
+ from,
31
+ size,
32
+ orderDirection,
33
+ orderProperty,
34
+ },
35
+ });
36
+ });
37
+ }
38
+ }
39
+ //# sourceMappingURL=Users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Users.js","sourceRoot":"","sources":["../../src/Users.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAQ,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU1C,MAAM,OAAO,KAAM,SAAQ,IAAI;IAO7B,YAAY,MAAmB;QAC7B,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QAE9D,KAAK,CAAC;YACJ,KAAK;YACL,YAAY;YACZ,UAAU,EAAE,WAAW;YACvB,SAAS;YACT,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAUY,SAAS,CAAC,SAAS,EAAqB;;YACnD,MAAM,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC;YACjE,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,KAAK,EAAE,QAAQ;gBACf,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE;oBACN,IAAI;oBACJ,IAAI;oBACJ,cAAc;oBACd,aAAa;iBACd;aACF,CAAC,CAAC;QACL,CAAC;KAAA;CACF"}
@@ -0,0 +1,2 @@
1
+ export const SERVICE_KEY = 'users-api';
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Users } from './Users';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { Base, List } from '@or-sdk/base';
2
+ import { ListUsersParams, UserItem, UsersConfig } from './types';
3
+ export declare class Users extends Base {
4
+ constructor(params: UsersConfig);
5
+ listUsers(params?: ListUsersParams): Promise<List<UserItem>>;
6
+ }
@@ -0,0 +1 @@
1
+ export declare const SERVICE_KEY = "users-api";
@@ -0,0 +1,2 @@
1
+ export { Users } from './Users';
2
+ export * from './types';
@@ -0,0 +1,18 @@
1
+ import { Token, OrderOptions, PaginationOptions } from '@or-sdk/base';
2
+ export declare type UsersConfig = {
3
+ token: Token;
4
+ discoveryUrl?: string;
5
+ accountId?: string;
6
+ serviceUrl?: string;
7
+ };
8
+ export declare type ListUsersParams = OrderOptions & PaginationOptions;
9
+ export declare type UserItem = {
10
+ id: string;
11
+ email: string;
12
+ username: string;
13
+ data: {
14
+ firstName: string;
15
+ lastName: string;
16
+ contactPhone: string;
17
+ };
18
+ };
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "version": "0.20.1-usersapi.0",
3
+ "name": "@or-sdk/users",
4
+ "main": "dist/cjs/index.js",
5
+ "module": "dist/esm/index.js",
6
+ "types": "dist/types/index.d.ts",
7
+ "scripts": {
8
+ "build": "npm run clean && concurrently \"npm run build:cjs\" \"npm run build:esm\" \"npm run build:types\"",
9
+ "build:watch": "concurrently -r --hide 1,2 \"npm run build:watch:cjs\" \"npm run build:watch:esm\" \"npm run build:watch:types\"",
10
+ "build:cjs": "tsc --project tsconfig.json",
11
+ "build:watch:cjs": "tsc --project tsconfig.json -w",
12
+ "build:esm": "tsc --project tsconfig.esm.json",
13
+ "build:watch:esm": "tsc --project tsconfig.esm.json -w",
14
+ "build:types": "tsc --project tsconfig.types.json",
15
+ "build:watch:types": "tsc --project tsconfig.types.json -w",
16
+ "clean": "rm -rf ./dist"
17
+ },
18
+ "devDependencies": {
19
+ "concurrently": "^6.4.0",
20
+ "typescript": "^4.4.4"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "dependencies": {
26
+ "@or-sdk/base": "^0.20.1-usersapi.0"
27
+ },
28
+ "gitHead": "f7429c9557d6efa1bf423e00d9651797d525fe8d"
29
+ }
package/src/Users.ts ADDED
@@ -0,0 +1,53 @@
1
+ import { Base, List } from '@or-sdk/base';
2
+ import { SERVICE_KEY } from './constants';
3
+ import { ListUsersParams, UserItem, UsersConfig } from './types';
4
+
5
+ /**
6
+ * OneReach Users service client
7
+ * ## Installation:
8
+ * ```
9
+ * $ npm i @or-sdk/users-api
10
+ * ```
11
+ */
12
+ export class Users extends Base {
13
+ /**
14
+ * ```typescript
15
+ * import { Users } from '@or-sdk/users-api'
16
+ * const users = new Users({token: 'my-account-token-string', discoveryUrl: 'http://example.tables/endpoint', accountId: 'guid'});
17
+ * ```
18
+ */
19
+ constructor(params: UsersConfig) {
20
+ const { token, discoveryUrl, accountId, serviceUrl } = params;
21
+
22
+ super({
23
+ token,
24
+ discoveryUrl,
25
+ serviceKey: SERVICE_KEY,
26
+ accountId,
27
+ serviceUrl,
28
+ });
29
+ }
30
+
31
+
32
+ /**
33
+ * List users
34
+ * ```typescript
35
+ * await users.listUsers({from:0, size: 1, orderDirection: 'asc', orderProperty: 'email'});
36
+ * ```
37
+ */
38
+
39
+ public async listUsers(params = {} as ListUsersParams): Promise<List<UserItem>> {
40
+ const { from = 0, size, orderDirection, orderProperty } = params;
41
+ return this.callApiV2({
42
+ route: '/users',
43
+ method: 'GET',
44
+ params: {
45
+ from,
46
+ size,
47
+ orderDirection,
48
+ orderProperty,
49
+ },
50
+ });
51
+ }
52
+ }
53
+
@@ -0,0 +1 @@
1
+ export const SERVICE_KEY = 'users-api';
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { Users } from './Users';
2
+ export * from './types';
package/src/types.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { Token, OrderOptions, PaginationOptions } from '@or-sdk/base';
2
+
3
+ export type UsersConfig = {
4
+ /**
5
+ * token
6
+ */
7
+ token: Token;
8
+ /**
9
+ * function which return token
10
+ */
11
+ discoveryUrl?: string;
12
+ accountId?: string;
13
+ serviceUrl?: string;
14
+ };
15
+
16
+ export type ListUsersParams = OrderOptions & PaginationOptions;
17
+
18
+ export type UserItem = {id: string; email: string; username: string; data: {firstName: string;lastName: string;contactPhone: string;};};
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "ES6",
5
+ "target": "es6",
6
+ "outDir": "./dist/esm/",
7
+ "rootDir": "./src"
8
+ }
9
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/cjs/",
5
+ "rootDir": "./src"
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist/types/",
5
+ "rootDir": "./src",
6
+ "declaration": true,
7
+ "emitDeclarationOnly": true
8
+ }
9
+ }