epicenter-libs 3.11.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.
Files changed (107) hide show
  1. package/CHANGELOG.md +345 -0
  2. package/LICENSE.md +37 -0
  3. package/README.md +134 -0
  4. package/dist/browser/AckExtension-e67c6a28.js +129 -0
  5. package/dist/browser/AckExtension-e67c6a28.js.map +1 -0
  6. package/dist/browser/ReloadExtension-b1e50033.js +253 -0
  7. package/dist/browser/ReloadExtension-b1e50033.js.map +1 -0
  8. package/dist/browser/cometd-eeabdcd4.js +3438 -0
  9. package/dist/browser/cometd-eeabdcd4.js.map +1 -0
  10. package/dist/browser/epicenter-2cce2971.js +6086 -0
  11. package/dist/browser/epicenter-2cce2971.js.map +1 -0
  12. package/dist/browser/epicenter.js +2 -0
  13. package/dist/browser/epicenter.js.map +1 -0
  14. package/dist/cjs/AckExtension-f5178e19.js +131 -0
  15. package/dist/cjs/AckExtension-f5178e19.js.map +1 -0
  16. package/dist/cjs/ReloadExtension-65b036ba.js +255 -0
  17. package/dist/cjs/ReloadExtension-65b036ba.js.map +1 -0
  18. package/dist/cjs/cometd-473408f4.js +3441 -0
  19. package/dist/cjs/cometd-473408f4.js.map +1 -0
  20. package/dist/cjs/epicenter-12ceb814.js +7248 -0
  21. package/dist/cjs/epicenter-12ceb814.js.map +1 -0
  22. package/dist/cjs/epicenter.js +54 -0
  23. package/dist/cjs/epicenter.js.map +1 -0
  24. package/dist/epicenter.js +9895 -0
  25. package/dist/epicenter.js.map +1 -0
  26. package/dist/epicenter.min.js +2 -0
  27. package/dist/epicenter.min.js.map +1 -0
  28. package/dist/module/AckExtension-6181d8b5.js +129 -0
  29. package/dist/module/AckExtension-6181d8b5.js.map +1 -0
  30. package/dist/module/ReloadExtension-eaa8c42c.js +253 -0
  31. package/dist/module/ReloadExtension-eaa8c42c.js.map +1 -0
  32. package/dist/module/cometd-af78008d.js +3438 -0
  33. package/dist/module/cometd-af78008d.js.map +1 -0
  34. package/dist/module/epicenter-9b8c92a9.js +7213 -0
  35. package/dist/module/epicenter-9b8c92a9.js.map +1 -0
  36. package/dist/module/epicenter.js +7 -0
  37. package/dist/module/epicenter.js.map +1 -0
  38. package/dist/types/adapters/account.d.ts +44 -0
  39. package/dist/types/adapters/admin.d.ts +33 -0
  40. package/dist/types/adapters/asset.d.ts +46 -0
  41. package/dist/types/adapters/authentication.d.ts +62 -0
  42. package/dist/types/adapters/channel.d.ts +39 -0
  43. package/dist/types/adapters/chat.d.ts +105 -0
  44. package/dist/types/adapters/cometd.d.ts +25 -0
  45. package/dist/types/adapters/email.d.ts +86 -0
  46. package/dist/types/adapters/episode.d.ts +91 -0
  47. package/dist/types/adapters/group.d.ts +273 -0
  48. package/dist/types/adapters/index.d.ts +21 -0
  49. package/dist/types/adapters/leaderboard.d.ts +68 -0
  50. package/dist/types/adapters/presence.d.ts +35 -0
  51. package/dist/types/adapters/project.d.ts +99 -0
  52. package/dist/types/adapters/recaptcha.d.ts +1 -0
  53. package/dist/types/adapters/run.d.ts +253 -0
  54. package/dist/types/adapters/task.d.ts +154 -0
  55. package/dist/types/adapters/time.d.ts +2 -0
  56. package/dist/types/adapters/user.d.ts +38 -0
  57. package/dist/types/adapters/vault.d.ts +94 -0
  58. package/dist/types/adapters/world.d.ts +230 -0
  59. package/dist/types/epicenter.d.ts +10 -0
  60. package/dist/types/utils/config.d.ts +90 -0
  61. package/dist/types/utils/constants.d.ts +290 -0
  62. package/dist/types/utils/cookies.d.ts +16 -0
  63. package/dist/types/utils/error-manager.d.ts +21 -0
  64. package/dist/types/utils/error.d.ts +4 -0
  65. package/dist/types/utils/fault.d.ts +17 -0
  66. package/dist/types/utils/helpers.d.ts +4 -0
  67. package/dist/types/utils/identification.d.ts +47 -0
  68. package/dist/types/utils/index.d.ts +11 -0
  69. package/dist/types/utils/result.d.ts +6 -0
  70. package/dist/types/utils/router.d.ts +157 -0
  71. package/dist/types/utils/store.d.ts +31 -0
  72. package/package.json +103 -0
  73. package/src/adapters/account.ts +104 -0
  74. package/src/adapters/admin.ts +53 -0
  75. package/src/adapters/asset.ts +195 -0
  76. package/src/adapters/authentication.ts +173 -0
  77. package/src/adapters/channel.ts +83 -0
  78. package/src/adapters/chat.ts +186 -0
  79. package/src/adapters/cometd.ts +297 -0
  80. package/src/adapters/email.ts +146 -0
  81. package/src/adapters/episode.ts +163 -0
  82. package/src/adapters/group.ts +511 -0
  83. package/src/adapters/index.ts +43 -0
  84. package/src/adapters/leaderboard.ts +122 -0
  85. package/src/adapters/presence.ts +63 -0
  86. package/src/adapters/project.ts +123 -0
  87. package/src/adapters/recaptcha.ts +11 -0
  88. package/src/adapters/run.ts +726 -0
  89. package/src/adapters/task.ts +213 -0
  90. package/src/adapters/time.ts +36 -0
  91. package/src/adapters/user.ts +75 -0
  92. package/src/adapters/vault.ts +232 -0
  93. package/src/adapters/world.ts +412 -0
  94. package/src/epicenter.ts +96 -0
  95. package/src/globals.d.ts +16 -0
  96. package/src/utils/config.ts +168 -0
  97. package/src/utils/constants.ts +324 -0
  98. package/src/utils/cookies.ts +71 -0
  99. package/src/utils/error-manager.ts +66 -0
  100. package/src/utils/error.ts +9 -0
  101. package/src/utils/fault.ts +39 -0
  102. package/src/utils/helpers.ts +7 -0
  103. package/src/utils/identification.ts +128 -0
  104. package/src/utils/index.ts +11 -0
  105. package/src/utils/result.ts +15 -0
  106. package/src/utils/router.ts +547 -0
  107. package/src/utils/store.ts +82 -0
@@ -0,0 +1,47 @@
1
+ import { SessionStore, CookieStore } from './store';
2
+ import { BROWSER_STORAGE_TYPE, ROLE } from './constants';
3
+ export interface UserSession {
4
+ token: string;
5
+ userKey: string;
6
+ groupKey?: string;
7
+ groupName?: string;
8
+ groupRole?: string;
9
+ multipleGroups?: boolean;
10
+ accountShortName: string;
11
+ projectShortName?: string;
12
+ projectKey?: string;
13
+ displayName: string;
14
+ objectType: 'user';
15
+ loginMethod: {
16
+ objectType: string;
17
+ };
18
+ }
19
+ export interface AdminSession {
20
+ adminHandle: string;
21
+ adminKey: string;
22
+ expires: boolean;
23
+ multipleAccounts: boolean;
24
+ objectType: 'admin';
25
+ teamAccountRole: ROLE.AUTHOR | ROLE.SUPPORT;
26
+ teamAccountShortName: string;
27
+ projectShortName?: string;
28
+ projectKey?: string;
29
+ timeoutMinutes: number;
30
+ token: string;
31
+ }
32
+ export declare type Session = UserSession | AdminSession;
33
+ declare class Identification {
34
+ type: "COOKIE" | "SESSION";
35
+ constructor(storeType: keyof typeof BROWSER_STORAGE_TYPE);
36
+ get session(): Session | undefined;
37
+ set session(session: Session | undefined);
38
+ getStore(): typeof SessionStore | typeof CookieStore;
39
+ getStoreOptions(session?: Session): "" | {
40
+ path: string;
41
+ samesite: string;
42
+ secure: boolean;
43
+ };
44
+ consumeSSO(): void;
45
+ }
46
+ declare const identification: Identification;
47
+ export default identification;
@@ -0,0 +1,11 @@
1
+ export * from './constants';
2
+ export * from './helpers';
3
+ export * from './store';
4
+ export { default as cookies } from './cookies';
5
+ export { default as EpicenterError } from './error';
6
+ export { default as Fault } from './fault';
7
+ export { default as Result } from './result';
8
+ export { default as config } from './config';
9
+ export { default as identification } from './identification';
10
+ export { default as errorManager } from './error-manager';
11
+ export { default as Router } from './router';
@@ -0,0 +1,6 @@
1
+ export default class Result {
2
+ status: number;
3
+ headers: Headers;
4
+ body: any;
5
+ constructor(body: any, response: Response);
6
+ }
@@ -0,0 +1,157 @@
1
+ import Result from './result';
2
+ declare type Version = number | undefined;
3
+ declare type Server = string | undefined;
4
+ declare type AccountShortName = string | undefined;
5
+ declare type ProjectShortName = string | undefined;
6
+ declare type Authorization = string | undefined;
7
+ declare type QueryObject = Record<string, unknown>;
8
+ declare type SearchParams = string | string[][] | URLSearchParams | QueryObject;
9
+ export interface RoutingOptions {
10
+ authorization?: Authorization;
11
+ server?: Server;
12
+ accountShortName?: AccountShortName;
13
+ projectShortName?: ProjectShortName;
14
+ query?: SearchParams;
15
+ headers?: Record<string, string>;
16
+ body?: unknown;
17
+ includeAuthorization?: boolean;
18
+ inert?: boolean;
19
+ paginated?: boolean;
20
+ parsePage?: (values: any[]) => any[];
21
+ }
22
+ interface RequestOptions extends RoutingOptions {
23
+ method: string;
24
+ }
25
+ export interface RetryFunction<Output> {
26
+ (): Promise<Output>;
27
+ requestArguments?: {
28
+ url: URL;
29
+ } & RequestOptions;
30
+ }
31
+ export interface Page<Item> {
32
+ firstResult: number;
33
+ maxResults: number;
34
+ totalResults: number;
35
+ values: Item[];
36
+ prev: () => Promise<Item[]>;
37
+ next: () => Promise<Item[]>;
38
+ all: (first?: number, allValues?: Item[]) => Promise<Item[]>;
39
+ }
40
+ export interface GenericSearchOptions {
41
+ filter?: string[];
42
+ sort?: string[];
43
+ first?: number;
44
+ max?: number;
45
+ }
46
+ /**
47
+ * Used to make the network calls in all API adapters
48
+ */
49
+ export default class Router {
50
+ _version: Version;
51
+ _server: Server;
52
+ _accountShortName: AccountShortName;
53
+ _projectShortName: ProjectShortName;
54
+ _authorization: Authorization;
55
+ _searchParams: URLSearchParams;
56
+ /**
57
+ * The version of the Epicenter APIs being invoked; expected to stay at `3`
58
+ */
59
+ get version(): Version;
60
+ set version(value: Version);
61
+ /**
62
+ * The root path used for the call, essentially protocol + hostname
63
+ * @type {string}
64
+ */
65
+ get server(): Server;
66
+ set server(value: Server);
67
+ /**
68
+ * Name of the account; for administrative use, this value should be set to 'epicenter'
69
+ * @type {string}
70
+ */
71
+ get accountShortName(): AccountShortName;
72
+ set accountShortName(value: AccountShortName);
73
+ /**
74
+ * Name of the project; for administrative use, this value should be set to 'manager'
75
+ * @type {string}
76
+ */
77
+ get projectShortName(): ProjectShortName;
78
+ set projectShortName(value: ProjectShortName);
79
+ /**
80
+ * Auth header; looks like `Bearer TOKEN` or `Basic TOKEN`
81
+ * @type {string}
82
+ */
83
+ get authorization(): Authorization;
84
+ set authorization(value: Authorization);
85
+ /**
86
+ * The search parameters for to use when making a network request. This property has should always return an instance of URLSearchParams or undefined. It has unique properties when used with the assignment operator (`=`); see the examples below for more details.
87
+ * @type {URLSearchParams}
88
+ *
89
+ * @example
90
+ * const router = new Router();
91
+ * router.searchParams = '?foo=123';
92
+ * console.log(router.searchParams); // always returns an instance object: URLSearchParams {}
93
+ * console.log(router.searchParams.toString()); // logs 'foo=123'
94
+ *
95
+ * router.searchParams = 'foo=123'; // can omit the question mark
96
+ * console.log(router.searchParams.toString()); // logs 'foo=123'
97
+ *
98
+ * router.searchParams = [['foo', '123'], ['bar', '456']]; // can accept arrays
99
+ * console.log(router.searchParams.toString()); // logs 'foo=123&bar=456'
100
+ *
101
+ * router.searchParams = { foo: '123', bar: '456' }; // can accept objects
102
+ * console.log(router.searchParams.toString()); // logs 'foo=123&bar=456'
103
+ *
104
+ * router.searchParams = { foo: '123', bar: ['4', '5', '6'] }; // can accept objects with arrayed values
105
+ * console.log(router.searchParams.toString()); // logs 'foo=123&bar=4&bar=5&bar=6'
106
+ *
107
+ * router.searchParams = new URLSearchParams('foo=123'); // can accept instances of URLSearchParams
108
+ * console.log(router.searchParams.toString()); // logs 'foo=123'
109
+ *
110
+ * @param {object|array|string|URLSearchParams} query Value used to set the search parameters
111
+ */
112
+ get searchParams(): SearchParams;
113
+ set searchParams(query: SearchParams);
114
+ /**
115
+ * Sets the version. Does nothing if invoked with no input. This is a part of a series of convenience functions for chaining sets on values.
116
+ * @param {string} [version] Version to use
117
+ * @returns {Router} The Router instance
118
+ */
119
+ withVersion(version?: Version): Router;
120
+ /**
121
+ * Sets the root path. Does nothing if invoked with no input. This is a part of a series of convenience functions for chaining sets on values.
122
+ * @param {string} [server] Root path to use
123
+ * @returns {Router} The Router instance
124
+ */
125
+ withServer(server?: Server): Router;
126
+ /**
127
+ * Sets the account. Does nothing if invoked with no input. This is a part of a series of convenience functions for chaining sets on values.
128
+ * @param {string} [accountShortName] Account name to use
129
+ * @returns {Router} The Router instance
130
+ */
131
+ withAccountShortName(accountShortName?: AccountShortName): Router;
132
+ /**
133
+ * Sets the project. Does nothing if invoked with no input. This is a part of a series of convenience functions for chaining sets on values.
134
+ * @param {string} [projectShortName] Project name to use
135
+ * @returns {Router} The Router instance
136
+ */
137
+ withProjectShortName(projectShortName?: ProjectShortName): Router;
138
+ /**
139
+ * Sets the project. Does nothing if invoked with no input. This is a part of a series of convenience functions for chaining sets on values.
140
+ * @param {string} [projectShortName] Project name to use
141
+ * @returns {Router} The Router instance
142
+ */
143
+ withAuthorization(authorization?: Authorization): Router;
144
+ /**
145
+ * Sets the search parameters. Does nothing if invoked with no input. This is a part of a series of convenience functions for chaining sets on values.
146
+ * @param {string|array|object|URLSearchParams} [searchParams] Search parameters to use, utilizes the same setter as [searchParams](#Router-searchParams)
147
+ * @returns {Router} The Router instance
148
+ */
149
+ withSearchParams(searchParams?: SearchParams): Router;
150
+ getURL(uriComponent: string): URL;
151
+ get(uriComponent: string, options?: RoutingOptions): Promise<Result>;
152
+ delete(uriComponent: string, options?: RoutingOptions): Promise<Result>;
153
+ patch(uriComponent: string, options?: RoutingOptions): Promise<Result>;
154
+ post(uriComponent: string, options?: RoutingOptions): Promise<Result>;
155
+ put(uriComponent: string, options?: RoutingOptions): Promise<Result>;
156
+ }
157
+ export {};
@@ -0,0 +1,31 @@
1
+ declare type NodeMap = Record<any, any>;
2
+ declare type JavaScriptObject = Record<string, any>;
3
+ declare type EpicenterStore = NodeMap | Storage;
4
+ declare class Store {
5
+ _store: EpicenterStore;
6
+ constructor(store: EpicenterStore);
7
+ clear(): void;
8
+ get store(): EpicenterStore;
9
+ set store(store: EpicenterStore);
10
+ }
11
+ export declare class NodeStore extends Store {
12
+ constructor();
13
+ getItem(key: string): NodeMap;
14
+ setItem(key: string, value: JavaScriptObject): NodeMap;
15
+ removeItem(key: string): boolean;
16
+ }
17
+ export declare class SessionStore extends Store {
18
+ constructor();
19
+ getItem(key: string): JavaScriptObject;
20
+ setItem(key: string, value: JavaScriptObject): void;
21
+ removeItem(key: string): void;
22
+ }
23
+ export declare class CookieStore {
24
+ options: {};
25
+ constructor(options?: {});
26
+ getItem(key: string): JavaScriptObject;
27
+ setItem(key: string, value: JavaScriptObject): boolean;
28
+ removeItem(key: string): boolean;
29
+ clear(): string[];
30
+ }
31
+ export {};
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "epicenter-libs",
3
+ "version": "3.11.0",
4
+ "main": "dist/cjs/epicenter.js",
5
+ "module": "dist/module/epicenter.js",
6
+ "browser": "dist/browser/epicenter.js",
7
+ "types": "dist/types/epicenter.d.ts",
8
+ "files": [
9
+ "dist/",
10
+ "src/",
11
+ "CHANGELOG.md"
12
+ ],
13
+ "scripts": {
14
+ "test": "karma start --browsers ChromeHeadless karma.conf.js",
15
+ "single-test": "karma start --browsers ChromeHeadless karma.conf.js --single-run",
16
+ "changelog": "npx conventional-changelog-cli -p angular -i CHANGELOG.md -s",
17
+ "changelog:all": "npx conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
18
+ "type-check": "tsc --noEmit",
19
+ "type-check:watch": "npm run type-check -- --watch",
20
+ "build:clean": "rimraf dist",
21
+ "build:types": "tsc --emitDeclarationOnly",
22
+ "build:js": "rollup -c -m",
23
+ "build": "npm run build:clean && npm run build:types && npm run build:js",
24
+ "start": "rollup -c -m inline -w"
25
+ },
26
+ "browserslist": [
27
+ "defaults",
28
+ "not IE 11",
29
+ "maintained node versions"
30
+ ],
31
+ "commitlint": {
32
+ "extends": [
33
+ "@commitlint/config-conventional"
34
+ ],
35
+ "rules": {
36
+ "header-max-length": [
37
+ 2,
38
+ "always",
39
+ 72
40
+ ]
41
+ }
42
+ },
43
+ "pre-push": {
44
+ "run": [
45
+ "single-test"
46
+ ]
47
+ },
48
+ "husky": {
49
+ "hooks": {
50
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
51
+ }
52
+ },
53
+ "dependencies": {
54
+ "cometd": "^4.0.9",
55
+ "cross-fetch": "^3.0.6"
56
+ },
57
+ "devDependencies": {
58
+ "@babel/cli": "^7.12.10",
59
+ "@babel/core": "^7.12.10",
60
+ "@babel/plugin-proposal-class-properties": "^7.12.1",
61
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
62
+ "@babel/plugin-proposal-numeric-separator": "^7.12.7",
63
+ "@babel/plugin-proposal-optional-chaining": "^7.12.7",
64
+ "@babel/plugin-proposal-private-methods": "^7.12.1",
65
+ "@babel/plugin-transform-runtime": "^7.15.0",
66
+ "@babel/preset-env": "^7.12.11",
67
+ "@babel/preset-typescript": "^7.12.7",
68
+ "@commitlint/cli": "^11.0.0",
69
+ "@commitlint/config-conventional": "^11.0.0",
70
+ "@rollup/plugin-alias": "^3.1.2",
71
+ "@rollup/plugin-babel": "^5.2.3",
72
+ "@rollup/plugin-commonjs": "^16.0.0",
73
+ "@rollup/plugin-node-resolve": "^10.0.0",
74
+ "@rollup/plugin-replace": "^2.3.4",
75
+ "@types/cometd": "^4.0.8",
76
+ "@typescript-eslint/eslint-plugin": "^4.14.2",
77
+ "@typescript-eslint/parser": "^4.14.2",
78
+ "babel-eslint": "^10.1.0",
79
+ "babel-loader": "^8.2.2",
80
+ "chai": "^4.2.0",
81
+ "conventional-changelog-cli": "^2.1.1",
82
+ "eslint": "^6.8.0",
83
+ "husky": "^4.3.8",
84
+ "karma": "^3.1.4",
85
+ "karma-chai": "^0.1.0",
86
+ "karma-chrome-launcher": "^2.2.0",
87
+ "karma-mocha": "^1.3.0",
88
+ "karma-mocha-reporter": "^2.2.5",
89
+ "karma-webpack": "^3.0.5",
90
+ "mocha": "^5.2.0",
91
+ "pre-push": "^0.1.1",
92
+ "rollup": "^2.38.4",
93
+ "rollup-plugin-filesize": "^9.1.0",
94
+ "rollup-plugin-progress": "^1.1.2",
95
+ "rollup-plugin-terser": "^7.0.2",
96
+ "rollup-plugin-visualizer": "^4.2.0",
97
+ "sinon": "^7.2.2",
98
+ "sinon-chai": "^3.5.0",
99
+ "typedoc": "^0.21.9",
100
+ "typescript": "^4.1.3",
101
+ "webpack": "^4.46.0"
102
+ }
103
+ }
@@ -0,0 +1,104 @@
1
+ import type { RoutingOptions } from 'utils/router';
2
+ import Router from 'utils/router';
3
+
4
+
5
+ interface AccountReadView {
6
+ name: string;
7
+ objectType: string;
8
+ }
9
+
10
+ interface AccountCreateView {
11
+ adminKey: string;
12
+ name: string;
13
+ shortName: string;
14
+ sharedSecret?: string;
15
+ workerPartition?: string;
16
+ active?: boolean;
17
+ }
18
+
19
+ interface PersonalAccountCreateView extends AccountCreateView {
20
+ objectType: 'personal';
21
+ }
22
+
23
+ interface TeamAccountCreateView extends AccountCreateView {
24
+ objectType: 'team';
25
+ billingInterval: string;
26
+ subscriptionPlan: string;
27
+ }
28
+
29
+ interface AccountUpdateView {
30
+ name?: string;
31
+ workerPartition?: string;
32
+ active?: boolean;
33
+ }
34
+
35
+ interface PersonalAccountUpdateView extends AccountUpdateView {
36
+ objectType: 'personal';
37
+ }
38
+
39
+ interface TeamAccountUpdateView extends AccountUpdateView {
40
+ objectType: 'team';
41
+ billingInterval?: string;
42
+ }
43
+
44
+ export async function getAccount(accountShortName: string): Promise<AccountReadView> {
45
+ return await new Router()
46
+ .withAccountShortName(accountShortName)
47
+ .get('/account')
48
+ .then(({body}) => body);
49
+ }
50
+
51
+ export async function createAccount(view: PersonalAccountCreateView | TeamAccountCreateView): Promise<AccountReadView> {
52
+
53
+ return await new Router()
54
+ .withAccountShortName('epicenter')
55
+ .withProjectShortName('manager')
56
+ .post('/account', {
57
+ body: view,
58
+ }).then(({body}) => body);
59
+ }
60
+
61
+ export async function updateAccount(
62
+ view: PersonalAccountUpdateView | TeamAccountUpdateView,
63
+ optionals: RoutingOptions = {},
64
+ ): Promise<AccountReadView> {
65
+ return await new Router()
66
+ .patch('/account', {
67
+ body: view,
68
+ ...optionals,
69
+ }).then(({body}) => body);
70
+ }
71
+
72
+ export async function removeAccount(
73
+ accountShortName: string
74
+ ): Promise<void> {
75
+ return await new Router()
76
+ .withAccountShortName(accountShortName)
77
+ .delete('/account')
78
+ .then(({body}) => body);
79
+ }
80
+
81
+ export async function teamForAdmin(
82
+ adminKey: string,
83
+ optionals: {
84
+ includeAllMembers?: boolean,
85
+ filter?: string,
86
+ first?: number,
87
+ max?: number,
88
+ } & RoutingOptions = {},
89
+ ): Promise<AccountReadView[]> {
90
+ const {
91
+ includeAllMembers, filter, first, max,
92
+ ...routingOptions
93
+ } = optionals;
94
+ const searchParams = {
95
+ includeAllMembers, filter, first, max,
96
+ };
97
+
98
+ return await new Router()
99
+ .withAccountShortName('epicenter')
100
+ .withProjectShortName('manager')
101
+ .withSearchParams(searchParams)
102
+ .get(`/account/team/for/${adminKey}`, routingOptions)
103
+ .then(({body}) => body);
104
+ }
@@ -0,0 +1,53 @@
1
+ import type { RoutingOptions } from '../utils/router';
2
+ import Router from '../utils/router';
3
+
4
+ export interface Secret {
5
+ password: string;
6
+ }
7
+
8
+ export interface AdminCreateView {
9
+ [key: string]: unknown,
10
+ handle: string;
11
+ email: string;
12
+ givenName?: string;
13
+ familyName?: string;
14
+ verified: true;
15
+ active?: true;
16
+ }
17
+
18
+ interface Admin {
19
+ lastUpdated: string,
20
+ lastLogin: string,
21
+ created: string,
22
+ familyName: string,
23
+ givenName: string,
24
+ verified: boolean,
25
+ handle: string,
26
+ active: boolean,
27
+ adminKey: string,
28
+ email: string,
29
+ objectType: 'external' | 'native',
30
+ }
31
+
32
+ export interface NativeAdminCreateView extends AdminCreateView {
33
+ objectType: 'native';
34
+ secret: Secret;
35
+ }
36
+
37
+ export async function createAdmin(view: AdminCreateView): Promise<Admin> {
38
+
39
+ return await new Router()
40
+ .withAccountShortName('epicenter')
41
+ .withProjectShortName('manager')
42
+ .post('/admin', {
43
+ body: view,
44
+ }).then(({body}) => body);
45
+ }
46
+
47
+ export async function getWithHandle(handle: string, optionals: RoutingOptions = {}) {
48
+ return await new Router()
49
+ .withAccountShortName('epicenter')
50
+ .withProjectShortName('manager')
51
+ .get(`/admin/with/${handle}`, optionals)
52
+ .then(({body}) => body);
53
+ }