@or-sdk/accounts 1.0.1-387.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,132 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Accounts = void 0;
40
+ var base_1 = require("@or-sdk/base");
41
+ var sdk_api_1 = require("@or-sdk/sdk-api");
42
+ var Accounts = (function () {
43
+ function Accounts(params) {
44
+ var token = params.token, discoveryUrl = params.discoveryUrl, sdkUrl = params.sdkUrl;
45
+ this.sdkApi = new sdk_api_1.SdkApi({
46
+ token: token,
47
+ discoveryUrl: discoveryUrl,
48
+ sdkUrl: sdkUrl,
49
+ });
50
+ }
51
+ Accounts.prototype.listAccounts = function () {
52
+ return __awaiter(this, void 0, void 0, function () {
53
+ var result;
54
+ return __generator(this, function (_a) {
55
+ switch (_a.label) {
56
+ case 0: return [4, this.sdkApi.makeRequest({
57
+ method: 'GET',
58
+ route: '/accounts',
59
+ })];
60
+ case 1:
61
+ result = _a.sent();
62
+ return [2, (0, base_1.makeList)(result)];
63
+ }
64
+ });
65
+ });
66
+ };
67
+ Accounts.prototype.getAccount = function (accountId) {
68
+ return __awaiter(this, void 0, void 0, function () {
69
+ return __generator(this, function (_a) {
70
+ return [2, this.sdkApi.makeRequest({
71
+ method: 'GET',
72
+ route: "/accounts/".concat(encodeURIComponent(accountId)),
73
+ })];
74
+ });
75
+ });
76
+ };
77
+ Accounts.prototype.getAccountData = function (accountId) {
78
+ return __awaiter(this, void 0, void 0, function () {
79
+ return __generator(this, function (_a) {
80
+ return [2, this.sdkApi.makeRequest({
81
+ method: 'GET',
82
+ route: "/accounts/".concat(encodeURIComponent(accountId), "/account-data"),
83
+ })];
84
+ });
85
+ });
86
+ };
87
+ Accounts.prototype.createAccount = function (data) {
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ return __generator(this, function (_a) {
90
+ return [2, this.sdkApi.makeRequest({
91
+ method: 'POST',
92
+ route: '/accounts',
93
+ data: data,
94
+ })];
95
+ });
96
+ });
97
+ };
98
+ Accounts.prototype.disableAccount = function (accountId) {
99
+ return __awaiter(this, void 0, void 0, function () {
100
+ return __generator(this, function (_a) {
101
+ return [2, this.sdkApi.makeRequest({
102
+ method: 'PUT',
103
+ route: "/accounts/".concat(encodeURIComponent(accountId), "/disable"),
104
+ })];
105
+ });
106
+ });
107
+ };
108
+ Accounts.prototype.enableAccount = function (accountId) {
109
+ return __awaiter(this, void 0, void 0, function () {
110
+ return __generator(this, function (_a) {
111
+ return [2, this.sdkApi.makeRequest({
112
+ method: 'PUT',
113
+ route: "/accounts/".concat(encodeURIComponent(accountId), "/enable"),
114
+ })];
115
+ });
116
+ });
117
+ };
118
+ Accounts.prototype.updateAccountData = function (accountId, data) {
119
+ return __awaiter(this, void 0, void 0, function () {
120
+ return __generator(this, function (_a) {
121
+ return [2, this.sdkApi.makeRequest({
122
+ method: 'PUT',
123
+ route: "/accounts/".concat(encodeURIComponent(accountId)),
124
+ data: data,
125
+ })];
126
+ });
127
+ });
128
+ };
129
+ return Accounts;
130
+ }());
131
+ exports.Accounts = Accounts;
132
+ //# sourceMappingURL=Accounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Accounts.js","sourceRoot":"","sources":["../../src/Accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA8C;AAC9C,2CAAyC;AAUzC;IAQE,kBAAY,MAAsB;QACxB,IAAA,KAAK,GAA2B,MAAM,MAAjC,EAAE,YAAY,GAAa,MAAM,aAAnB,EAAE,MAAM,GAAK,MAAM,OAAX,CAAY;QAE/C,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAM,CAAC;YACvB,KAAK,O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AAS,CAAC,YAAS;qBAC3D,CAAC,EAAC;;;KACJ;IAQY,oCAAiB,GAA9B,UAA+B,SAAiB,EAAE,IAAiB;;;gBACjE,WAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAU;wBACtC,MAAM,EAAE,KAAK;wBACb,KAAK,EAAE,oBAAa,kBAAkB,CAAC,SAAS,CAAC,CAAE;wBACnD,IAAI,MAAA;qBACL,CAAC,EAAC;;;KACJ;IACH,eAAC;AAAD,CAAC,AAhHD,IAgHC;AAhHY,4BAAQ"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":""}
@@ -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.Accounts = void 0;
18
+ var Accounts_1 = require("./Accounts");
19
+ Object.defineProperty(exports, "Accounts", { enumerable: true, get: function () { return Accounts_1.Accounts; } });
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,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,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,81 @@
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 { makeList } from '@or-sdk/base';
11
+ import { SdkApi } from '@or-sdk/sdk-api';
12
+ export class Accounts {
13
+ constructor(params) {
14
+ const { token, discoveryUrl, sdkUrl } = params;
15
+ this.sdkApi = new SdkApi({
16
+ token,
17
+ discoveryUrl,
18
+ sdkUrl,
19
+ });
20
+ }
21
+ listAccounts() {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const result = yield this.sdkApi.makeRequest({
24
+ method: 'GET',
25
+ route: '/accounts',
26
+ });
27
+ return makeList(result);
28
+ });
29
+ }
30
+ getAccount(accountId) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ return this.sdkApi.makeRequest({
33
+ method: 'GET',
34
+ route: `/accounts/${encodeURIComponent(accountId)}`,
35
+ });
36
+ });
37
+ }
38
+ getAccountData(accountId) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ return this.sdkApi.makeRequest({
41
+ method: 'GET',
42
+ route: `/accounts/${encodeURIComponent(accountId)}/account-data`,
43
+ });
44
+ });
45
+ }
46
+ createAccount(data) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ return this.sdkApi.makeRequest({
49
+ method: 'POST',
50
+ route: '/accounts',
51
+ data,
52
+ });
53
+ });
54
+ }
55
+ disableAccount(accountId) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ return this.sdkApi.makeRequest({
58
+ method: 'PUT',
59
+ route: `/accounts/${encodeURIComponent(accountId)}/disable`,
60
+ });
61
+ });
62
+ }
63
+ enableAccount(accountId) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ return this.sdkApi.makeRequest({
66
+ method: 'PUT',
67
+ route: `/accounts/${encodeURIComponent(accountId)}/enable`,
68
+ });
69
+ });
70
+ }
71
+ updateAccountData(accountId, data) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ return this.sdkApi.makeRequest({
74
+ method: 'PUT',
75
+ route: `/accounts/${encodeURIComponent(accountId)}`,
76
+ data,
77
+ });
78
+ });
79
+ }
80
+ }
81
+ //# sourceMappingURL=Accounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Accounts.js","sourceRoot":"","sources":["../../src/Accounts.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAUzC,MAAM,OAAO,QAAQ;IAQnB,YAAY,MAAsB;QAChC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QAE/C,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC;YACvB,KAAK;YACL,YAAY;YACZ,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAQY,YAAY;;YACvB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAY;gBACtD,MAAM,EAAE,KAAK;gBACb,KAAK,EAAE,WAAW;aACnB,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAU,MAAM,CAAC,C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sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export { Accounts } from './Accounts';
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,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,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,13 @@
1
+ import { List } from '@or-sdk/base';
2
+ import { Account, AccountData, AccountsConfig } from './types';
3
+ export declare class Accounts {
4
+ private readonly sdkApi;
5
+ constructor(params: AccountsConfig);
6
+ listAccounts(): Promise<List<Account>>;
7
+ getAccount(accountId: string): Promise<Account>;
8
+ getAccountData(accountId: string): Promise<AccountData>;
9
+ createAccount(data: AccountData): Promise<Account>;
10
+ disableAccount(accountId: string): Promise<void>;
11
+ enableAccount(accountId: string): Promise<void>;
12
+ updateAccountData(accountId: string, data: AccountData): Promise<Account>;
13
+ }
File without changes
@@ -0,0 +1,2 @@
1
+ export { Accounts } from './Accounts';
2
+ export * from './types';
@@ -0,0 +1,29 @@
1
+ import { Token } from '@or-sdk/base';
2
+ export declare type AccountsConfig = {
3
+ token: Token;
4
+ discoveryUrl?: string;
5
+ sdkUrl?: string;
6
+ };
7
+ export declare type Account = {
8
+ version: number;
9
+ dateCreated: number;
10
+ data: {
11
+ createdBy: string;
12
+ updatedBy?: string;
13
+ purpose?: string;
14
+ billable?: boolean;
15
+ customerId?: string;
16
+ type?: string;
17
+ settings?: {
18
+ [key: string]: unknown;
19
+ };
20
+ [key: string]: unknown;
21
+ };
22
+ accountName: string;
23
+ dateModified: number;
24
+ id: string;
25
+ };
26
+ export declare type AccountData = {
27
+ accountName?: string;
28
+ [key: string]: unknown;
29
+ };
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "version": "1.0.1-387.0",
3
+ "name": "@or-sdk/accounts",
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.23.1",
27
+ "@or-sdk/sdk-api": "^0.23.1"
28
+ }
29
+ }
@@ -0,0 +1,124 @@
1
+ import { List, makeList } from '@or-sdk/base';
2
+ import { SdkApi } from '@or-sdk/sdk-api';
3
+ import { Account, AccountData, AccountsConfig } from './types';
4
+
5
+ /**
6
+ * OneReach Accounts service client
7
+ * ## Installation:
8
+ * ```
9
+ * $ npm i @or-sdk/accounts
10
+ * ```
11
+ */
12
+ export class Accounts {
13
+ private readonly sdkApi: SdkApi;
14
+ /**
15
+ * ```typescript
16
+ * import { Accounts } from '@or-sdk/accounts'
17
+ * const accounts = new Accounts({token: 'my-account-token-string', discoveryUrl: 'http://example.accounts/endpoint'});
18
+ * ```
19
+ */
20
+ constructor(params: AccountsConfig) {
21
+ const { token, discoveryUrl, sdkUrl } = params;
22
+
23
+ this.sdkApi = new SdkApi({
24
+ token,
25
+ discoveryUrl,
26
+ sdkUrl,
27
+ });
28
+ }
29
+
30
+ /**
31
+ * List accounts
32
+ * ```typescript
33
+ * const result = await accounts.listAccounts();
34
+ * ```
35
+ */
36
+ public async listAccounts(): Promise<List<Account>> {
37
+ const result = await this.sdkApi.makeRequest<Account[]>({
38
+ method: 'GET',
39
+ route: '/accounts',
40
+ });
41
+
42
+ return makeList<Account>(result);
43
+ }
44
+
45
+ /**
46
+ * Get account by id
47
+ * ```typescript
48
+ * const result = await accounts.getAccount('account-id');
49
+ * ```
50
+ */
51
+ public async getAccount(accountId: string): Promise<Account> {
52
+ return this.sdkApi.makeRequest<Account>({
53
+ method: 'GET',
54
+ route: `/accounts/${encodeURIComponent(accountId)}`,
55
+ });
56
+ }
57
+
58
+ /**
59
+ * Get account data by id
60
+ * ```typescript
61
+ * const result = await accounts.getAccountData('account-id');
62
+ * ```
63
+ */
64
+ public async getAccountData(accountId: string): Promise<AccountData> {
65
+ return this.sdkApi.makeRequest<AccountData>({
66
+ method: 'GET',
67
+ route: `/accounts/${encodeURIComponent(accountId)}/account-data`,
68
+ });
69
+ }
70
+
71
+ /**
72
+ * Create account
73
+ * ```typescript
74
+ * const result = await accounts.createAccount(accountData);
75
+ * ```
76
+ */
77
+ public async createAccount(data: AccountData): Promise<Account> {
78
+ return this.sdkApi.makeRequest<Account>({
79
+ method: 'POST',
80
+ route: '/accounts',
81
+ data,
82
+ });
83
+ }
84
+
85
+ /**
86
+ * Disable account
87
+ * ```typescript
88
+ * await accounts.disableAccount('account-id');
89
+ * ```
90
+ */
91
+ public async disableAccount(accountId: string): Promise<void> {
92
+ return this.sdkApi.makeRequest<void>({
93
+ method: 'PUT',
94
+ route: `/accounts/${encodeURIComponent(accountId)}/disable`,
95
+ });
96
+ }
97
+
98
+ /**
99
+ * Enable account
100
+ * ```typescript
101
+ * await accounts.enableAccount('account-id');
102
+ * ```
103
+ */
104
+ public async enableAccount(accountId: string): Promise<void> {
105
+ return this.sdkApi.makeRequest<void>({
106
+ method: 'PUT',
107
+ route: `/accounts/${encodeURIComponent(accountId)}/enable`,
108
+ });
109
+ }
110
+
111
+ /**
112
+ * Update account
113
+ * ```typescript
114
+ * const result = await accounts.updateAccountData('account-id', accountData);
115
+ * ```
116
+ */
117
+ public async updateAccountData(accountId: string, data: AccountData): Promise<Account> {
118
+ return this.sdkApi.makeRequest<Account>({
119
+ method: 'PUT',
120
+ route: `/accounts/${encodeURIComponent(accountId)}`,
121
+ data,
122
+ });
123
+ }
124
+ }
@@ -0,0 +1 @@
1
+
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { Accounts } from './Accounts';
2
+ export * from './types';
package/src/types.ts ADDED
@@ -0,0 +1,43 @@
1
+ import { Token } from '@or-sdk/base';
2
+
3
+ export type AccountsConfig = {
4
+ /**
5
+ * token
6
+ */
7
+ token: Token;
8
+
9
+ /**
10
+ * Url of OneReach service discovery api
11
+ */
12
+ discoveryUrl?: string;
13
+
14
+ /**
15
+ * Url of OneReach SDK api
16
+ */
17
+ sdkUrl?: string;
18
+ };
19
+
20
+ export type Account = {
21
+ version: number;
22
+ dateCreated: number;
23
+ data: {
24
+ createdBy: string;
25
+ updatedBy?: string;
26
+ purpose?: string;
27
+ billable?: boolean;
28
+ customerId?: string;
29
+ type?: string;
30
+ settings?: {
31
+ [key: string]: unknown;
32
+ };
33
+ [key: string]: unknown;
34
+ };
35
+ accountName: string;
36
+ dateModified: number;
37
+ id: string;
38
+ };
39
+
40
+ export type AccountData = {
41
+ accountName?: string;
42
+ [key: string]: unknown;
43
+ };
@@ -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
+ }